@sprig-technologies/sprig-browser 2.42.1 → 2.43.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,91 +1,91 @@
1
- import { u, c as _, a as F, F as _e, h as ae, p as ne, _ as de, g as Ce, S as Me, b as se, y as Oe, d as Be } from "./view-q6KAoLll.js";
2
- import { g as He, i as Se, E as Ue, b as we } from "./core-D9RfS2Z8.js";
1
+ import { u as v, c as _, a as $, F as Me, h as de, p as ne, _ as oe, g as we, S as Oe, b as le, y as pe, d as Be } from "./view-Ctyh240J.js";
2
+ import { g as He, i as Se, E as Ue, b as ye } from "./core-DJ3Dpomz.js";
3
3
  import { d as Ne } from "./debounce-CMb8f7wh.js";
4
- import { v as Ve } from "./metricsReporter-DqmmYkn-.js";
5
- const Fe = (e) => u("button", { ...e, className: _("ul-card-text__button", e.className), id: "ul-card-text__button" }), $e = ({ html: e, ...n }) => {
6
- const { enableCspTrustedTypes: o } = F((r) => ({ enableCspTrustedTypes: r.enableCspTrustedTypes })), t = _e(() => He(e, o), [o, e]);
7
- return u("div", { ...n, dangerouslySetInnerHTML: { __html: t } });
8
- }, ye = () => {
9
- const { viewDocument: e } = F((t) => ({ viewDocument: t.viewDocument })), [n, o] = ae(!1);
4
+ import { v as Ve } from "./metricsReporter-DDWVWGid.js";
5
+ const Fe = (e) => v("button", { ...e, className: _("ul-card-text__button", e.className), id: "ul-card-text__button" }), $e = ({ html: e, ...n }) => {
6
+ const { enableCspTrustedTypes: o } = $((i) => ({ enableCspTrustedTypes: i.enableCspTrustedTypes })), t = Me(() => He(e, o), [o, e]);
7
+ return v("div", { ...n, dangerouslySetInnerHTML: { __html: t } });
8
+ }, xe = () => {
9
+ const { viewDocument: e } = $((t) => ({ viewDocument: t.viewDocument })), [n, o] = de(!1);
10
10
  return ne(() => {
11
- const t = e.querySelector(".sprig-question-body"), r = new ResizeObserver(() => {
11
+ const t = e.querySelector(".sprig-question-body"), i = new ResizeObserver(() => {
12
12
  window.requestAnimationFrame(() => {
13
13
  o(!!(t && Se(t) && t.scrollHeight > t.offsetHeight));
14
14
  });
15
15
  });
16
- return t && r.observe(t), () => {
17
- t && r.disconnect();
16
+ return t && i.observe(t), () => {
17
+ t && i.disconnect();
18
18
  };
19
19
  }, [e]), n;
20
- }, ue = ({ plainText: e, richText: n, id: o, className: t, isHeader: r, showAsterisk: s }) => n ? u($e, { className: t, html: n, id: o }) : e ? r ? u("h1", { className: t, id: o, children: [e, s && "*"] }) : u("p", { className: t, id: o, children: e }) : null, an = ({ message: e, properties: n, isRequired: o }) => {
21
- const t = de(null), r = n == null ? void 0 : n.captionText, s = ye();
22
- return u("div", { className: _("question-header-container", "sprig-header-container", s ? "sprig-border-bottom" : null), ref: t, children: [u("div", { className: "question-header-button-container", children: u(ue, { className: "ul-question", id: "ul-question", isHeader: !0, plainText: e, richText: n == null ? void 0 : n.questionHtml, showAsterisk: o }) }), u(ue, { className: "ul-caption", id: "ul-caption", plainText: r, richText: n == null ? void 0 : n.captionHtml })] });
23
- }, Ae = () => u("svg", { fill: "none", height: "10", viewBox: "0 0 13 10", width: "13", xmlns: "http://www.w3.org/2000/svg", children: u("path", { d: "M11.5 1.5L4.5 8.5L1 5", stroke: "#FFFFFF", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "1.5" }) }), dn = ({ isSubmitDisabled: e, handleSubmit: n }) => u("div", { className: "ul-card-longform__submit-button-container", children: u(Fe, { className: "ul-card-longform__submit-button", disabled: e, onClick: n, children: ["OK ", u(Ae, {})] }) }), ze = (e, n) => {
24
- const o = de(0);
20
+ }, ve = ({ plainText: e, richText: n, id: o, className: t, isHeader: i, showAsterisk: s }) => n ? v($e, { className: t, html: n, id: o }) : e ? i ? v("h1", { className: t, id: o, children: [e, s && "*"] }) : v("p", { className: t, id: o, children: e }) : null, an = ({ message: e, properties: n, isRequired: o }) => {
21
+ const t = oe(null), i = n == null ? void 0 : n.captionText, s = xe();
22
+ return v("div", { className: _("question-header-container", "sprig-header-container", s ? "sprig-border-bottom" : null), ref: t, children: [v("div", { className: "question-header-button-container", children: v(ve, { className: "ul-question", id: "ul-question", isHeader: !0, plainText: e, richText: n == null ? void 0 : n.questionHtml, showAsterisk: o }) }), v(ve, { className: "ul-caption", id: "ul-caption", plainText: i, richText: n == null ? void 0 : n.captionHtml })] });
23
+ }, Ae = () => v("svg", { fill: "none", height: "10", viewBox: "0 0 13 10", width: "13", xmlns: "http://www.w3.org/2000/svg", children: v("path", { d: "M11.5 1.5L4.5 8.5L1 5", stroke: "#FFFFFF", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "1.5" }) }), dn = ({ isSubmitDisabled: e, handleSubmit: n }) => v("div", { className: "ul-card-longform__submit-button-container", children: v(Fe, { className: "ul-card-longform__submit-button", disabled: e, onClick: n, children: ["OK ", v(Ae, {})] }) }), ze = (e, n) => {
24
+ const o = oe(0);
25
25
  return () => {
26
26
  if (e.current) {
27
27
  const t = e.current;
28
28
  t.style.height = "1px";
29
- const r = t.scrollHeight + (t.offsetHeight - t.clientHeight), s = parseInt(window.getComputedStyle(t).getPropertyValue("max-height")), l = r <= s ? r : s;
29
+ const i = t.scrollHeight + (t.offsetHeight - t.clientHeight), s = parseInt(window.getComputedStyle(t).getPropertyValue("max-height")), l = i <= s ? i : s;
30
30
  o.current !== l && requestAnimationFrame(() => {
31
31
  n();
32
32
  }), o.current = l, t.style.height = `${l}px`;
33
33
  }
34
34
  };
35
- }, ve = ({ buttonText: e = "View Prototype", handleClick: n }) => u("button", { className: "prototype-button", onClick: n, children: e }, "prototype-btn"), cn = ({ embeddedType: e = "prototype", properties: n, children: o }) => {
35
+ }, me = ({ buttonText: e = "View Prototype", handleClick: n }) => v("button", { className: "prototype-button", onClick: n, children: e }, "prototype-btn"), cn = ({ embeddedType: e = "prototype", properties: n, children: o }) => {
36
36
  var I;
37
- const { handleClickEmbedButton: t, hasViewedEmbed: r, headers: s, useDesktopPrototype: l } = F((b) => ({ handleClickEmbedButton: b.handleClickEmbedButton, hasViewedEmbed: b.hasViewedEmbed, headers: b.headers, useDesktopPrototype: b.useDesktopPrototype })), a = (n == null ? void 0 : n.conceptUrl) || ((I = n == null ? void 0 : n.consentDocument) == null ? void 0 : I.url), i = window.innerWidth < Ue, c = s["userleap-platform"], m = (b, L) => {
38
- b.preventDefault(), t(L);
37
+ const { handleClickEmbedButton: t, hasViewedEmbed: i, headers: s, useDesktopPrototype: l } = $((g) => ({ handleClickEmbedButton: g.handleClickEmbedButton, hasViewedEmbed: g.hasViewedEmbed, headers: g.headers, useDesktopPrototype: g.useDesktopPrototype })), c = (n == null ? void 0 : n.conceptUrl) || ((I = n == null ? void 0 : n.consentDocument) == null ? void 0 : I.url), r = window.innerWidth < Ue, u = s["userleap-platform"], m = (g, T) => {
38
+ g.preventDefault(), t(T);
39
39
  };
40
40
  if ((() => {
41
- const { update: b, index: L, isConversationalUI: E, viewDocument: v } = F(({ update: f, index: j, isConversationalUI: C, viewDocument: D }) => ({ update: f, index: j, isConversationalUI: C, viewDocument: D })), h = Ne(b, 100);
41
+ const { update: g, index: T, isConversationalUI: f, viewDocument: L } = $(({ update: C, index: E, isConversationalUI: b, viewDocument: k }) => ({ update: C, index: E, isConversationalUI: b, viewDocument: k })), d = Ne(g, 100);
42
42
  ne(() => {
43
- if (E) return;
44
- const f = new ResizeObserver(h), j = v.querySelector(".ul-card__container");
45
- return j && f.observe(j, { box: "border-box" }), () => {
46
- f.disconnect();
43
+ if (f) return;
44
+ const C = new ResizeObserver(d), E = L.querySelector(".ul-card__container");
45
+ return E && C.observe(E, { box: "border-box" }), () => {
46
+ C.disconnect();
47
47
  };
48
- }, [h, b, L, E, v]);
49
- })(), !l && i && !r && a && ["email", "link"].includes(c)) {
50
- if (e === "prototype") return u(ve, { handleClick: (b) => {
51
- m(b, "question.prototype.click");
48
+ }, [d, g, T, f, L]);
49
+ })(), !l && r && !i && c && ["email", "link"].includes(u)) {
50
+ if (e === "prototype") return v(me, { handleClick: (g) => {
51
+ m(g, "question.prototype.click");
52
52
  } });
53
- if (e === "pdf") return u(ve, { buttonText: (n == null ? void 0 : n.viewDocumentText) || "View Document", handleClick: (b) => {
54
- m(b, "question.agreement.click");
53
+ if (e === "pdf") return v(me, { buttonText: (n == null ? void 0 : n.viewDocumentText) || "View Document", handleClick: (g) => {
54
+ m(g, "question.agreement.click");
55
55
  } });
56
56
  }
57
- return u(Ce, { children: o });
58
- }, xe = ({ isSelected: e, id: n, divId: o, themeColor: t, disabled: r = !1 }) => u("div", { "aria-checked": e, "aria-disabled": r, "aria-labelledby": `label-${n}`, className: "select-checkbox", id: o, role: "checkbox", style: { ...e ? { backgroundColor: t, borderColor: t, boxShadow: "none" } : {}, ...r ? { opacity: 0.5 } : {} }, tabIndex: r ? -1 : 0, children: e && u(Me, {}) }), pn = ({ ariaLabel: e, border: n, choiceStyle: o = {}, label: t, isSelected: r, value: s, text: l, id: a, isRadio: i, useMobileStyling: c, error: m, allowTextEntry: I, noneOfTheAbove: b, promptText: L, disabled: E = !1, onUserInputChanged: v }) => {
59
- const { styleNonce: h, viewDocument: f } = F((k) => ({ styleNonce: k.styleNonce, viewDocument: k.viewDocument })), [j, C] = ae(!1);
60
- Ze(f, n, h);
61
- const D = ({ isSelected: k, userText: y }) => {
62
- v && v({ id: a, selected: k, value: s, userText: y, noneOfTheAbove: b });
63
- }, z = (k) => {
64
- E || (k.stopPropagation(), D({ isSelected: i || !r, userText: l }), C(!1));
57
+ return v(we, { children: o });
58
+ }, Ee = ({ isSelected: e, id: n, divId: o, themeColor: t, disabled: i = !1 }) => v("div", { "aria-checked": e, "aria-disabled": i, "aria-labelledby": `label-${n}`, className: "select-checkbox", id: o, role: "checkbox", style: { ...e ? { backgroundColor: t, borderColor: t, boxShadow: "none" } : {}, ...i ? { opacity: 0.5 } : {} }, tabIndex: i ? -1 : 0, children: e && v(Oe, {}) }), un = ({ ariaLabel: e, border: n, choiceStyle: o = {}, label: t, isSelected: i, value: s, text: l, id: c, isRadio: r, useMobileStyling: u, error: m, allowTextEntry: I, noneOfTheAbove: g, promptText: T, disabled: f = !1, onUserInputChanged: L }) => {
59
+ const { styleNonce: d, viewDocument: C } = $((j) => ({ styleNonce: j.styleNonce, viewDocument: j.viewDocument })), [E, b] = de(!1);
60
+ Ze(C, n, d);
61
+ const k = ({ isSelected: j, userText: y }) => {
62
+ L && L({ id: c, selected: j, value: s, userText: y, noneOfTheAbove: g });
63
+ }, M = (j) => {
64
+ f || (j.stopPropagation(), k({ isSelected: r || !i, userText: l }), b(!1));
65
65
  }, Y = () => {
66
- j || C(!0);
67
- }, M = () => {
68
- j && C(!1);
69
- }, O = { onClick: (k) => z(k), onKeyPress: (k) => ((y) => {
70
- E || y.key !== "Enter" && y.key !== " " || z(y);
71
- })(k) };
72
- "ontouchstart" in f.documentElement ? (O.onTouchStart = M, O.onTouchCancel = M, O.onTouchEnd = M) : (O.onMouseDown = Y, O.onMouseLeave = M);
73
- const W = i ? `radio-${a}` : `checkbox-${a}`, p = r || j ? [Q] : [], w = [...m ? [Ee] : [], ...p, ...E ? ["ul-choice-disabled"] : []], g = t ? { "aria-labelledby": `label-${a}` } : { "aria-label": e };
74
- return u("div", { className: _(se("choice", c), ...w), id: `choice-div-${a}`, style: { ...o, ...m ? { borderColor: we } : {}, ...E ? { opacity: 0.5, cursor: "not-allowed" } : {} }, ...E ? {} : O, "aria-disabled": E, children: [u("div", { className: _("choice-label-container"), children: [i ? u("div", { ...g, className: _("select-radio", ...p), id: W, role: "radio", tabIndex: 0 }) : u(xe, { disabled: E, divId: W, id: a, isSelected: r, themeColor: n }), t && u("label", { className: _(se("select-label", c)), htmlFor: W, id: `label-${a}`, children: t })] }), I && r && u("div", { className: _("choice-text-entry-container", ...p), children: u(qe, { onTextChange: (k) => D({ isSelected: r, userText: k }), promptText: L || "Please specify", textValue: l, useMobileStyling: c }) })] });
66
+ E || b(!0);
67
+ }, O = () => {
68
+ E && b(!1);
69
+ }, B = { onClick: (j) => M(j), onKeyPress: (j) => ((y) => {
70
+ f || y.key !== "Enter" && y.key !== " " || M(y);
71
+ })(j) };
72
+ "ontouchstart" in C.documentElement ? (B.onTouchStart = O, B.onTouchCancel = O, B.onTouchEnd = O) : (B.onMouseDown = Y, B.onMouseLeave = O);
73
+ const W = r ? `radio-${c}` : `checkbox-${c}`, p = i || E ? [Q] : [], w = [...m ? [je] : [], ...p, ...f ? ["ul-choice-disabled"] : []], h = t ? { "aria-labelledby": `label-${c}` } : { "aria-label": e };
74
+ return v("div", { className: _(le("choice", u), ...w), id: `choice-div-${c}`, style: { ...o, ...m ? { borderColor: ye } : {}, ...f ? { opacity: 0.5, cursor: "not-allowed" } : {} }, ...f ? {} : B, "aria-disabled": f, children: [v("div", { className: _("choice-label-container"), children: [r ? v("div", { ...h, className: _("select-radio", ...p), id: W, role: "radio", tabIndex: 0 }) : v(Ee, { disabled: f, divId: W, id: c, isSelected: i, themeColor: n }), t && v("label", { className: _(le("select-label", u)), htmlFor: W, id: `label-${c}`, children: t })] }), I && i && v("div", { className: _("choice-text-entry-container", ...p), children: v(qe, { onTextChange: (j) => k({ isSelected: i, userText: j }), promptText: T || "Please specify", textValue: l, useMobileStyling: u }) })] });
75
75
  }, qe = ({ promptText: e, textValue: n, onTextChange: o, useMobileStyling: t }) => {
76
- const r = de(null), { update: s } = F((a) => ({ update: a.update })), l = ze(r, () => s());
77
- return ne(() => (l(), r.current && r.current.focus(), () => {
76
+ const i = oe(null), { update: s } = $((c) => ({ update: c.update })), l = ze(i, () => s());
77
+ return ne(() => (l(), i.current && i.current.focus(), () => {
78
78
  s();
79
- }), []), u("textarea", { "aria-label": e, "aria-multiline": "true", "aria-placeholder": e, className: _(se("choice-text-input", t)), "data-gramm": "false", maxLength: 5e3, name: "text", onChange: (a) => {
80
- l(), a.stopPropagation(), o(a.currentTarget.value);
81
- }, onClick: (a) => {
82
- a.stopPropagation();
83
- }, onKeyPress: (a) => {
84
- a.stopPropagation();
85
- }, placeholder: e, ref: r, role: "textbox", rows: 1, value: n });
86
- }, he = "ul-select-style-element", Q = "ul-select-active-dynamic-style", Ee = "ul-select-error-dynamic-style", Ze = (e, n, o) => {
87
- let t = e.getElementById(he), r = !1;
88
- t || (t = e.createElement("style"), r = !0), t.tagName.toLowerCase() === "style" && (t.id = he, o && (t.nonce = o), t.textContent = Ge(n), r && e.head.appendChild(t));
79
+ }), []), v("textarea", { "aria-label": e, "aria-multiline": "true", "aria-placeholder": e, className: _(le("choice-text-input", t)), "data-gramm": "false", maxLength: 5e3, name: "text", onChange: (c) => {
80
+ l(), c.stopPropagation(), o(c.currentTarget.value);
81
+ }, onClick: (c) => {
82
+ c.stopPropagation();
83
+ }, onKeyPress: (c) => {
84
+ c.stopPropagation();
85
+ }, placeholder: e, ref: i, role: "textbox", rows: 1, value: n });
86
+ }, he = "ul-select-style-element", Q = "ul-select-active-dynamic-style", je = "ul-select-error-dynamic-style", Ze = (e, n, o) => {
87
+ let t = e.getElementById(he), i = !1;
88
+ t || (t = e.createElement("style"), i = !0), t.tagName.toLowerCase() === "style" && (t.id = he, o && (t.nonce = o), t.textContent = Ge(n), i && e.head.appendChild(t));
89
89
  }, Ge = (e) => `
90
90
  .${Q} {
91
91
  border-color: ${e};
@@ -94,13 +94,93 @@ const Fe = (e) => u("button", { ...e, className: _("ul-card-text__button", e.cla
94
94
  border: 6px solid ${e};
95
95
  box-shadow: none;
96
96
  }
97
- .${Ee} {
98
- border-color: ${we};
97
+ .${je} {
98
+ border-color: ${ye};
99
99
  }
100
- `, un = ({ children: e }) => u("div", { className: "sprig-question-body", children: e }), vn = ({ children: e }) => {
101
- const n = ye(), { isConversationalUI: o } = F((t) => ({ isConversationalUI: t.isConversationalUI }));
102
- return u("div", { className: _("sprig-question-footer-container", n && !o ? "sprig-border-top" : null), children: e });
103
- }, G = "https://cdn.sprig.com", d = { document: void 0, videojs: void 0 }, ce = (e) => e + "-loading-spiner", T = "hidden", me = ".m3u8", oe = "questionId", te = "ul-video-recorder-camera-off-button", re = "ul-recording-in-session", We = [{ type: "link", content: `${G}/dependencies/videojs-record-4.5.0.min.css` }, { type: "script", content: `${G}/dependencies/RecordRTC-5.6.2.js` }, { type: "script", content: `${G}/dependencies/adapter.8.0.0.min.js` }, { type: "script", content: `${G}/dependencies/videojs-record-4.5.0.min.js` }, { type: "script", content: `${G}/userleap-web-upchunk-v2.2.2.js` }], je = [{ type: "link", content: `${G}/dependencies/video-js-7.18.0.min.css` }, { type: "script", content: `${G}/dependencies/video-js-7.18.0.min.js` }, { type: "style", content: `/* progress control styles */
100
+ `, pn = ({ children: e }) => v("div", { className: "sprig-question-body", children: e }), vn = ({ children: e }) => {
101
+ const n = xe(), { isConversationalUI: o } = $((t) => ({ isConversationalUI: t.isConversationalUI }));
102
+ return v("div", { className: _("sprig-question-footer-container", n && !o ? "sprig-border-top" : null), children: e });
103
+ };
104
+ var We = ((e) => (e.CONTINUE = "CONTINUE", e.EXTERNAL = "EXTERNAL", e.NO_BUTTON = "NO_BUTTON", e))(We || {}), Ye = ((e) => (e.Unlimited = "Unlimited", e.Maximum = "Maximum", e.Range = "Range", e))(Ye || {});
105
+ function mn(e) {
106
+ const n = e.props;
107
+ if (n === null || typeof n != "object") return !1;
108
+ const o = Reflect.get(n, "properties");
109
+ return typeof o == "object" && o !== null && "required" in o;
110
+ }
111
+ const Je = ({ options: e, selectItem: n, selectedOptions: o, showCheckbox: t, disabledOptions: i, dropdownFooter: s, panelRef: l }) => {
112
+ const { themeColor: c } = $((r) => ({ doc: r.viewDocument, themeColor: r.border }));
113
+ return v("div", { className: "select-list", ref: l, children: [e.map((r) => {
114
+ return v("div", { "aria-disabled": i == null ? void 0 : i.includes(r), className: _("select-option", i != null && i.includes(r) ? "ul-choice-disabled" : ""), onClick: (m) => {
115
+ i != null && i.includes(r) || (n(r), m.stopPropagation());
116
+ }, role: "option", style: { ...i != null && i.includes(r) ? { opacity: 0.5, cursor: "not-allowed" } : {} }, children: [t && v(Ee, { divId: (u = r.id, `checkbox-div-${u}`), id: r.id, isSelected: o.includes(r), themeColor: c }), r.label] }, r.id);
117
+ var u;
118
+ }), s] });
119
+ }, hn = ({ isMultiSelect: e = !1, multiselectText: n = "choices selected", onChange: o, options: t, placeholderText: i, value: s, disabledOptions: l = [], dropdownFooter: c }) => {
120
+ const [r, u] = de(!1), m = oe(null), { viewDocument: I, update: g, isConversationalUI: T } = $((d) => ({ viewDocument: d.viewDocument, update: d.update, isConversationalUI: d.isConversationalUI })), f = () => {
121
+ u(!r);
122
+ };
123
+ pe(() => {
124
+ T || g();
125
+ }, [r, T, g]), pe(() => {
126
+ r && m.current && m.current.scrollIntoView({ behavior: "smooth", block: "nearest" });
127
+ }, [r]), ne(() => {
128
+ var C;
129
+ const d = (E) => {
130
+ const b = E.target;
131
+ (b == null ? void 0 : b.closest(".select-option.ul-choice-disabled")) || u(!1);
132
+ };
133
+ I.addEventListener("click", d);
134
+ try {
135
+ (C = window.parent) == null || C.addEventListener("click", d);
136
+ } catch {
137
+ window.addEventListener("click", d);
138
+ }
139
+ return () => {
140
+ var E;
141
+ I.removeEventListener("click", d);
142
+ try {
143
+ (E = window.parent) == null || E.removeEventListener("click", d);
144
+ } catch {
145
+ window.removeEventListener("click", d);
146
+ }
147
+ };
148
+ }, [I]);
149
+ const L = s.length === 0 ? ["select-button-placeholder"] : [];
150
+ return v(we, { children: [v("button", { "aria-label": "choice dropdown button", className: _("select-button", ...L), onClick: (d) => {
151
+ d.stopPropagation(), f();
152
+ }, type: "button", children: [v("span", { children: s.length === 0 ? i : s.length === 1 ? s[0].label : `${s.length} ${n}` }), v(Be, {})] }), r && v(Je, { disabledOptions: l, dropdownFooter: c, options: t, panelRef: m, selectedOptions: s, selectItem: (d) => {
153
+ var b;
154
+ const C = s.some((k) => k.id === d.id), E = s.some((k) => {
155
+ var M;
156
+ return (M = k.optionProperties) == null ? void 0 : M.noneOfTheAbove;
157
+ });
158
+ (b = d.optionProperties) != null && b.noneOfTheAbove && !C ? o([d]) : e ? o(C ? s.filter((k) => k.id !== d.id) : E ? [d] : [...s, d]) : C || o([d]), e || f();
159
+ }, showCheckbox: e })] });
160
+ }, Ke = { "{{user_id}}": "externalUserId", "{{email}}": "email" }, gn = (e = void 0, n = {}) => {
161
+ if (!e) return e;
162
+ const o = ["http:", "https:", "itms-apps:", "market:"], t = ((l) => /^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//.test(l) ? l : `http://${l}`)(e);
163
+ if (!t) return;
164
+ try {
165
+ const l = new URL(t);
166
+ if (!l.protocol || !o.includes(l.protocol)) return;
167
+ } catch {
168
+ return;
169
+ }
170
+ const i = [], s = ((l, c, r) => {
171
+ let u = l;
172
+ for (const [m, I] of Object.entries(Ke)) if (u.toLowerCase().includes(m)) if (c[I]) {
173
+ const g = new RegExp(m, "gi");
174
+ u = u.replace(g, c[I]);
175
+ } else r.push(m);
176
+ return u;
177
+ })(t, n, i);
178
+ return i.length === 0 ? s : ((l, c) => {
179
+ if (!l.includes("?")) return l;
180
+ const r = l.slice(0, l.indexOf("?")), u = l.slice(l.indexOf("?") + 1).split("&").map((m) => m.split("=")).filter((m) => !c.includes(m[1]));
181
+ return u.length === 0 ? r : `${r}?${u.map((m) => m.join("=")).join("&")}`;
182
+ })(s, i);
183
+ }, G = "https://cdn.sprig.com", a = { document: void 0, videojs: void 0 }, ce = (e) => e + "-loading-spiner", D = "hidden", ge = ".m3u8", te = "questionId", re = "ul-video-recorder-camera-off-button", ie = "ul-recording-in-session", Qe = [{ type: "link", content: `${G}/dependencies/videojs-record-4.5.0.min.css` }, { type: "script", content: `${G}/dependencies/RecordRTC-5.6.2.js` }, { type: "script", content: `${G}/dependencies/adapter.8.0.0.min.js` }, { type: "script", content: `${G}/dependencies/videojs-record-4.5.0.min.js` }, { type: "script", content: `${G}/userleap-web-upchunk-v2.2.2.js` }], ke = [{ type: "link", content: `${G}/dependencies/video-js-7.18.0.min.css` }, { type: "script", content: `${G}/dependencies/video-js-7.18.0.min.js` }, { type: "style", content: `/* progress control styles */
104
184
  .video-js .vjs-control {
105
185
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
106
186
  }
@@ -757,47 +837,47 @@ span.ul-button-text {
757
837
  .vjs-poster {
758
838
  background-size: cover;
759
839
  }
760
- ` }], ke = "-video-player", ge = "-secondary-video-player", Ie = "-video-recorder";
761
- let S, be;
762
- const A = async ({ event: e, apiBase: n, headers: o, visitorId: t, envId: r, metadata: s }) => {
763
- const l = d.document.documentElement;
764
- if (!t || !r) return;
765
- const a = { event: `SDK - ${e}`, visitorId: t, environmentId: r, metadata: { ...s || {}, screenWidth: window.screen.width, screenHeight: window.screen.height, clientWidth: l.clientWidth, clientHeight: l.clientHeight, location: window.location.href, language: navigator.language } };
766
- (await fetch(`${n}/sdk/1/visitors/${t}/analytics`, { method: "POST", cache: "no-cache", headers: o, body: JSON.stringify(a) })).ok || console.warn("[Sprig] (ERR-444) Failed to track analytics", e);
767
- }, V = async (e, n, o, t, r, s) => {
768
- A({ event: `Video Error ${n}`, apiBase: o, headers: t, visitorId: r, envId: s, metadata: { errorMessage: e.message } });
769
- const l = d.document.documentElement, a = { screenWidth: window.screen.width, screenHeight: window.screen.height, clientWidth: l.clientWidth, clientHeight: l.clientHeight, location: window.location.href, language: navigator.language }, i = { action: n, err: { message: e.message, stack: e.stack }, meta: a, vid: r, envId: s };
770
- (await fetch(`${o}/sdk/1/errors`, { method: "POST", cache: "no-cache", headers: { ...t, "userleap-platform": "video_recorder", "x-ul-error": window.btoa(`userleap-${Date.now()}-error`) }, body: JSON.stringify(i) })).ok || console.warn("[Sprig] (ERR-444) Failed to report error to API", e);
771
- }, De = (e, n) => {
840
+ ` }], Ie = "-video-player", be = "-secondary-video-player", De = "-video-recorder";
841
+ let U, fe;
842
+ const z = async ({ event: e, apiBase: n, headers: o, visitorId: t, envId: i, metadata: s }) => {
843
+ const l = a.document.documentElement;
844
+ if (!t || !i) return;
845
+ const c = { event: `SDK - ${e}`, visitorId: t, environmentId: i, metadata: { ...s || {}, screenWidth: window.screen.width, screenHeight: window.screen.height, clientWidth: l.clientWidth, clientHeight: l.clientHeight, location: window.location.href, language: navigator.language } };
846
+ (await fetch(`${n}/sdk/1/visitors/${t}/analytics`, { method: "POST", cache: "no-cache", headers: o, body: JSON.stringify(c) })).ok || console.warn("[Sprig] (ERR-444) Failed to track analytics", e);
847
+ }, F = async (e, n, o, t, i, s) => {
848
+ z({ event: `Video Error ${n}`, apiBase: o, headers: t, visitorId: i, envId: s, metadata: { errorMessage: e.message } });
849
+ const l = a.document.documentElement, c = { screenWidth: window.screen.width, screenHeight: window.screen.height, clientWidth: l.clientWidth, clientHeight: l.clientHeight, location: window.location.href, language: navigator.language }, r = { action: n, err: { message: e.message, stack: e.stack }, meta: c, vid: i, envId: s };
850
+ (await fetch(`${o}/sdk/1/errors`, { method: "POST", cache: "no-cache", headers: { ...t, "userleap-platform": "video_recorder", "x-ul-error": window.btoa(`userleap-${Date.now()}-error`) }, body: JSON.stringify(r) })).ok || console.warn("[Sprig] (ERR-444) Failed to report error to API", e);
851
+ }, Te = (e, n) => {
772
852
  if (e.length === 0) return n && n();
773
- Promise.all(e.reduce((o, t) => (o.push(((r, { type: s, content: l }) => new Promise(function(a, i) {
774
- let c;
775
- s === "script" ? (c = d.document.createElement("script"), c.src = l) : s === "link" ? (c = d.document.createElement("link"), c.rel = "stylesheet", c.href = l, c.type = "text/css") : (c = d.document.createElement("style"), c.innerHTML = l), c.onload = function() {
776
- a(l);
777
- }, c.onerror = function() {
778
- i(l);
779
- }, c.async = !1, c.id = btoa(l), r.appendChild(c);
780
- }))(d.document.head, t)), o), [])).then(() => {
781
- d.videojs = d.document.defaultView.videojs, n && n();
853
+ Promise.all(e.reduce((o, t) => (o.push(((i, { type: s, content: l }) => new Promise(function(c, r) {
854
+ let u;
855
+ s === "script" ? (u = a.document.createElement("script"), u.src = l) : s === "link" ? (u = a.document.createElement("link"), u.rel = "stylesheet", u.href = l, u.type = "text/css") : (u = a.document.createElement("style"), u.innerHTML = l), u.onload = function() {
856
+ c(l);
857
+ }, u.onerror = function() {
858
+ r(l);
859
+ }, u.async = !1, u.id = btoa(l), i.appendChild(u);
860
+ }))(a.document.head, t)), o), [])).then(() => {
861
+ a.videojs = a.document.defaultView.videojs, n && n();
782
862
  }).catch(function(o) {
783
863
  console.log(o + " failed to load");
784
864
  });
785
- }, fe = (e, n, o) => {
786
- if (n === "start" && (e.style.visibility = "visible"), n === "none") e.style.visibility = T;
787
- else if (n === "success") e.style.visibility = T, e.innerHTML = "Upload succeeded!";
865
+ }, Ce = (e, n, o) => {
866
+ if (n === "start" && (e.style.visibility = "visible"), n === "none") e.style.visibility = D;
867
+ else if (n === "success") e.style.visibility = D, e.innerHTML = "Upload succeeded!";
788
868
  else {
789
869
  const t = Math.round(parseFloat(o));
790
870
  e.innerHTML = `Uploading <span class="ul-upload-progress-label__time">${t}%</span>`, e.style.background = `linear-gradient(to right, #E0E0EB 0%, #E0E0EB ${t}%, #FCFCFD ${t}%, #FCFCFD 100%)`;
791
871
  }
792
- }, ie = (e, n) => {
793
- const o = d.videojs(e.id());
872
+ }, se = (e, n) => {
873
+ const o = a.videojs(e.id());
794
874
  return o == null ? void 0 : o.payload[n];
795
- }, Te = (e, n) => {
796
- const o = new (d.videojs.getComponent("Component"))(e);
875
+ }, Le = (e, n) => {
876
+ const o = new (a.videojs.getComponent("Component"))(e);
797
877
  return o.addClass("ul-buttons-panel"), n.map((t) => {
798
878
  o.addChild(t);
799
- }), Ye(o), o;
800
- }, Ye = (e) => {
879
+ }), Xe(o), o;
880
+ }, Xe = (e) => {
801
881
  e.children().forEach((n) => {
802
882
  if (R[n.name_]) {
803
883
  const o = X(R[n.name_], `ul-${R[n.name_]}`);
@@ -805,15 +885,15 @@ const A = async ({ event: e, apiBase: n, headers: o, visitorId: t, envId: r, met
805
885
  }
806
886
  });
807
887
  }, X = (e, n = "") => {
808
- const o = d.document.createElement("span");
888
+ const o = a.document.createElement("span");
809
889
  return o.className = "ul-button-text", o.innerHTML = e, o.id = n, o;
810
- }, Le = (e, n, o, t, r = !1, s) => {
890
+ }, Pe = (e, n, o, t, i = !1, s) => {
811
891
  e.addClass("ul-video-player");
812
- const l = new (d.videojs.getComponent("Component"))(e);
813
- l.addClass("ul-control-panel"), e.progressBar = l.addChild("ProgressControl"), o && e.src(o), e.audioPlayerPlaceholder = new (d.videojs.getComponent("Component"))(e), e.audioPlayerPlaceholder.addClass("ul-audio-recorder-placeholder");
814
- const a = o && o.src ? Qe(o.src) : null;
815
- !o || !r && a ? (e.audioPlayerPlaceholder.hide(), d.document.getElementById(`${e.id()}_html5_api`).style.height = "100%", a && e.poster(a)) : (e.children()[0].classList.add("vjs-hidden"), d.document.getElementById(`${e.id()}_html5_api`).style.height = "0px"), e.on("play", () => {
816
- r || !o || a || Ke(e), s == null || s.play();
892
+ const l = new (a.videojs.getComponent("Component"))(e);
893
+ l.addClass("ul-control-panel"), e.progressBar = l.addChild("ProgressControl"), o && e.src(o), e.audioPlayerPlaceholder = new (a.videojs.getComponent("Component"))(e), e.audioPlayerPlaceholder.addClass("ul-audio-recorder-placeholder");
894
+ const c = o && o.src ? on(o.src) : null;
895
+ !o || !i && c ? (e.audioPlayerPlaceholder.hide(), a.document.getElementById(`${e.id()}_html5_api`).style.height = "100%", c && e.poster(c)) : (e.children()[0].classList.add("vjs-hidden"), a.document.getElementById(`${e.id()}_html5_api`).style.height = "0px"), e.on("play", () => {
896
+ i || !o || c || nn(e), s == null || s.play();
817
897
  }), e.on("pause", () => {
818
898
  s == null || s.pause();
819
899
  }), e.on("seeked", () => {
@@ -821,281 +901,203 @@ const A = async ({ event: e, apiBase: n, headers: o, visitorId: t, envId: r, met
821
901
  }), e.on("ratechange", () => {
822
902
  s == null || s.playbackRate(e.playbackRate());
823
903
  }), e.addChild(e.audioPlayerPlaceholder, {}, 1), l.addChild(n), e.addChild(l), t && t(e);
824
- }, Je = (e, n, o, t, r, s, l, a = !1) => {
825
- be = Date.now();
826
- const i = ee(n, { controls: !1, bigPlayButton: !1, fluid: !1, width: 1280, height: 720, playsinline: !0, plugins: { record: { audio: !0, video: { mandatory: { minWidth: 1280, minHeight: 720 } }, frameWidth: 1280, frameHeight: 720, maxLength: 600, autoMuteDevice: !0 } } });
827
- if (!i) return;
828
- i.payload = o;
829
- const { surveyId: c, questionId: m, responseGroupUid: I, visitorId: b, envId: L } = o;
830
- let E;
831
- const v = (p) => {
832
- const w = te, g = te + "-audio-only";
833
- fe(i.uploadProgressLabel, "none"), S && S.startTime >= be && S.abort();
834
- const k = d.document.getElementById("ul-camera-button");
835
- p ? (i.children()[0].classList.add("vjs-hidden"), C.removeClass(w), C.addClass(g), k.innerHTML = R.TurnOnCamera, i.audioPlayerPlaceholder.removeClass("vjs-hidden"), E == null || E.getTracks().forEach((y) => {
904
+ }, en = (e, n, o, t, i, s, l, c = !1) => {
905
+ fe = Date.now();
906
+ const r = ee(n, { controls: !1, bigPlayButton: !1, fluid: !1, width: 1280, height: 720, playsinline: !0, plugins: { record: { audio: !0, video: { mandatory: { minWidth: 1280, minHeight: 720 } }, frameWidth: 1280, frameHeight: 720, maxLength: 600, autoMuteDevice: !0 } } });
907
+ if (!r) return;
908
+ r.payload = o;
909
+ const { surveyId: u, questionId: m, responseGroupUid: I, visitorId: g, envId: T } = o;
910
+ let f;
911
+ const L = (p) => {
912
+ const w = re, h = re + "-audio-only";
913
+ Ce(r.uploadProgressLabel, "none"), U && U.startTime >= fe && U.abort();
914
+ const j = a.document.getElementById("ul-camera-button");
915
+ p ? (r.children()[0].classList.add("vjs-hidden"), b.removeClass(w), b.addClass(h), j.innerHTML = R.TurnOnCamera, r.audioPlayerPlaceholder.removeClass("vjs-hidden"), f == null || f.getTracks().forEach((y) => {
836
916
  y.stop();
837
917
  }), window.navigator.mediaDevices.getUserMedia({ video: !0, audio: !0 }).then((y) => {
838
- E = y, y.getVideoTracks().forEach((U) => {
839
- U.enabled = !1;
840
- }), i.record().onDeviceReady(y);
841
- }).catch(i.record().onDeviceError.bind(i.record()))) : (E == null || E.getVideoTracks().forEach((y) => {
918
+ f = y, y.getVideoTracks().forEach((N) => {
919
+ N.enabled = !1;
920
+ }), r.record().onDeviceReady(y);
921
+ }).catch(r.record().onDeviceError.bind(r.record()))) : (f == null || f.getVideoTracks().forEach((y) => {
842
922
  y.enabled = !0;
843
- }), i.children()[0].classList.remove("vjs-hidden"), i.record().getDevice(), C.removeClass(g), C.addClass(w), k.innerHTML = R.TurnOffCamera, i.audioPlayerPlaceholder.addClass("vjs-hidden"));
844
- }, h = new (d.videojs.getComponent("Button"))(i, { clickHandler: () => {
845
- h.hasClass(T) || (A({ event: "Video Delete Button Clicked", apiBase: t, headers: l, visitorId: b, envId: L, metadata: { questionId: m, responseGroupUid: I, surveyId: c } }), v(i.cameraOff), r(x.DELETE, {}), C.removeClass(T), h.addClass(T));
923
+ }), r.children()[0].classList.remove("vjs-hidden"), r.record().getDevice(), b.removeClass(h), b.addClass(w), j.innerHTML = R.TurnOffCamera, r.audioPlayerPlaceholder.addClass("vjs-hidden"));
924
+ }, d = new (a.videojs.getComponent("Button"))(r, { clickHandler: () => {
925
+ d.hasClass(D) || (z({ event: "Video Delete Button Clicked", apiBase: t, headers: l, visitorId: g, envId: T, metadata: { questionId: m, responseGroupUid: I, surveyId: u } }), L(r.cameraOff), i(x.DELETE, {}), b.removeClass(D), d.addClass(D));
846
926
  } });
847
- h.addClass("ul-video-recorder-delete-button"), h.el_.appendChild(X(R.DeleteButton, "ul-delete-button"));
848
- const f = d.document.getElementById(n), j = () => {
849
- f.classList.contains("vjs-fullscreen") && i.cameraOff ? f.style.display = "table" : f.style.display = "flex";
927
+ d.addClass("ul-video-recorder-delete-button"), d.el_.appendChild(X(R.DeleteButton, "ul-delete-button"));
928
+ const C = a.document.getElementById(n), E = () => {
929
+ C.classList.contains("vjs-fullscreen") && r.cameraOff ? C.style.display = "table" : C.style.display = "flex";
850
930
  };
851
- j();
852
- const C = new (d.videojs.getComponent("Button"))(i, { clickHandler: () => {
853
- i.record().isRecording() || (i.cameraOff = !i.cameraOff, A({ event: "Video Camera Button Clicked", apiBase: t, headers: l, visitorId: o.visitorId, envId: o.envId, metadata: { questionId: m, responseGroupUid: I, surveyId: c, cameraOff: i.cameraOff } }), v(i.cameraOff), !h.hasClass(T) && h.addClass(T), r(x.DELETE, {}), j());
931
+ E();
932
+ const b = new (a.videojs.getComponent("Button"))(r, { clickHandler: () => {
933
+ r.record().isRecording() || (r.cameraOff = !r.cameraOff, z({ event: "Video Camera Button Clicked", apiBase: t, headers: l, visitorId: o.visitorId, envId: o.envId, metadata: { questionId: m, responseGroupUid: I, surveyId: u, cameraOff: r.cameraOff } }), L(r.cameraOff), !d.hasClass(D) && d.addClass(D), i(x.DELETE, {}), E());
854
934
  } });
855
- C.addClass(te), C.el_.appendChild(X(R.TurnOffCamera, "ul-camera-button"));
856
- const D = new (d.videojs.getComponent("Button"))(i, { clickHandler: () => {
857
- const p = d.document.getElementById("ul-recorder-toggle");
858
- if (i.record().isRecording()) i.record().stop(), p && (p.innerHTML = R.RecordButton), D.removeClass(re), h.removeClass(T);
935
+ b.addClass(re), b.el_.appendChild(X(R.TurnOffCamera, "ul-camera-button"));
936
+ const k = new (a.videojs.getComponent("Button"))(r, { clickHandler: () => {
937
+ const p = a.document.getElementById("ul-recorder-toggle");
938
+ if (r.record().isRecording()) r.record().stop(), p && (p.innerHTML = R.RecordButton), k.removeClass(ie), d.removeClass(D);
859
939
  else {
860
- const w = d.document.getElementById("ul-recording-countdown-screen");
861
- if (w) w.remove(), p && (p.innerHTML = R.RecordButton), v(i.cameraOff), r(x.DELETE, {}), C.removeClass(T), h.addClass(T), D.removeClass(re), M.show();
940
+ const w = a.document.getElementById("ul-recording-countdown-screen");
941
+ if (w) w.remove(), p && (p.innerHTML = R.RecordButton), L(r.cameraOff), i(x.DELETE, {}), b.removeClass(D), d.addClass(D), k.removeClass(ie), O.show();
862
942
  else {
863
- D.addClass(re), M.hide(), C.addClass(T), h.addClass(T), p && (p.innerHTML = R.StopButton);
864
- const g = d.document.createElement("div");
865
- g.id = "ul-recording-countdown-screen", f.insertBefore(g, f.children[1]), g.style.height = `${f.offsetHeight}px`, Pe(i, 3);
943
+ k.addClass(ie), O.hide(), b.addClass(D), d.addClass(D), p && (p.innerHTML = R.StopButton);
944
+ const h = a.document.createElement("div");
945
+ h.id = "ul-recording-countdown-screen", C.insertBefore(h, C.children[1]), h.style.height = `${C.offsetHeight}px`, Re(r, 3);
866
946
  }
867
947
  }
868
948
  } });
869
- D.addClass("ul-video-recorder-toggle-button"), D.el_.appendChild(X(R.RecordButton, "ul-recorder-toggle"));
870
- const z = d.document.createElement("p");
871
- z.style.visibility = "hidden", z.className = "ul-upload-progress-label", e.appendChild(z), i.uploadProgressLabel = z;
872
- const Y = Te(i, [h, C, "PlayToggle", D, "FullscreenToggle"]), M = Y.children().find((p) => p.name_ === "FullscreenToggle");
873
- M.hasClass("vjs-disabled") && M.hide();
874
- const O = Y.children().find((p) => p.name_ === "PlayToggle");
875
- O.hide(), h.addClass(T), Le(i, Y, s, !1, a), i.on("stopRecord", () => {
876
- D.hide(), O.show(), M.show(), h.removeClass(T);
877
- }), i.on("deviceReady", () => {
878
- D.show(), O.hide(), h.addClass(T);
879
- }), ((p, w, g, k, y) => {
880
- const { surveyId: U, responseGroupUid: q, visitorId: P, envId: B } = p.payload;
949
+ k.addClass("ul-video-recorder-toggle-button"), k.el_.appendChild(X(R.RecordButton, "ul-recorder-toggle"));
950
+ const M = a.document.createElement("p");
951
+ M.style.visibility = "hidden", M.className = "ul-upload-progress-label", e.appendChild(M), r.uploadProgressLabel = M;
952
+ const Y = Le(r, [d, b, "PlayToggle", k, "FullscreenToggle"]), O = Y.children().find((p) => p.name_ === "FullscreenToggle");
953
+ O.hasClass("vjs-disabled") && O.hide();
954
+ const B = Y.children().find((p) => p.name_ === "PlayToggle");
955
+ B.hide(), d.addClass(D), Pe(r, Y, s, !1, c), r.on("stopRecord", () => {
956
+ k.hide(), B.show(), O.show(), d.removeClass(D);
957
+ }), r.on("deviceReady", () => {
958
+ k.show(), B.hide(), d.addClass(D);
959
+ }), ((p, w, h, j, y) => {
960
+ const { surveyId: N, responseGroupUid: q, visitorId: P, envId: H } = p.payload;
881
961
  p.on("deviceError", function() {
882
- console.warn("device error: ", p.deviceErrorCode), p.deviceErrorCode.message === "Permission denied" ? (p.deviceButton.addClass("permission-denied"), g && g(x.ERROR, { type: x.PERMISSION_DENIED }), A({ event: "Video Permission Denied", apiBase: w, headers: y, visitorId: P, envId: B, metadata: { questionId: ie(p, oe), responseGroupUid: q, surveyId: U } })) : (g && g(x.ERROR, { type: x.OTHER }), V(new Error(p.deviceErrorCode.message), "recorderDeviceError", w, y, P, B));
883
- }), p.on("error", function(Z, N) {
884
- V(N || p.error(), "recorderError", w, y, P, B);
885
- }), p.on("startRecord", function(Z, N) {
886
- k(p.uploadProgressLabel, "none"), A({ event: "Video Record Start", apiBase: w, headers: y, visitorId: P, envId: B, metadata: { questionId: ie(p, oe), responseGroupUid: q, surveyId: U } });
962
+ console.warn("device error: ", p.deviceErrorCode), p.deviceErrorCode.message === "Permission denied" ? (p.deviceButton.addClass("permission-denied"), h && h(x.ERROR, { type: x.PERMISSION_DENIED }), z({ event: "Video Permission Denied", apiBase: w, headers: y, visitorId: P, envId: H, metadata: { questionId: se(p, te), responseGroupUid: q, surveyId: N } })) : (h && h(x.ERROR, { type: x.OTHER }), F(new Error(p.deviceErrorCode.message), "recorderDeviceError", w, y, P, H));
963
+ }), p.on("error", function(Z, V) {
964
+ F(V || p.error(), "recorderError", w, y, P, H);
965
+ }), p.on("startRecord", function(Z, V) {
966
+ j(p.uploadProgressLabel, "none"), z({ event: "Video Record Start", apiBase: w, headers: y, visitorId: P, envId: H, metadata: { questionId: se(p, te), responseGroupUid: q, surveyId: N } });
887
967
  }), p.on("finishRecord", async function() {
888
- k(p.uploadProgressLabel, "start", 0);
889
- const Z = ie(p, oe);
890
- if (!U) {
891
- const H = "internal error: missing fields in payload";
892
- return g && g(x.ERROR, { type: x.OTHER }), V(new Error(H), "finishRecord", w, y, P, B), null;
968
+ j(p.uploadProgressLabel, "start", 0);
969
+ const Z = se(p, te);
970
+ if (!N) {
971
+ const S = "internal error: missing fields in payload";
972
+ return h && h(x.ERROR, { type: x.OTHER }), F(new Error(S), "finishRecord", w, y, P, H), null;
893
973
  }
894
974
  p.record().stopDevice();
895
- const N = p.cameraOff ? x.MEDIA_TYPE_AUDIO : x.MEDIA_TYPE_VIDEO, $ = Ve();
896
- A({ event: "Video Record Finish", apiBase: w, headers: y, visitorId: P, envId: B, metadata: { mediaRecordingUid: $, questionId: Z, responseGroupUid: q, surveyId: U, mediaType: N } });
897
- const J = { surveyId: U, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), mediaType: N, mediaRecordingUid: $ };
975
+ const V = p.cameraOff ? x.MEDIA_TYPE_AUDIO : x.MEDIA_TYPE_VIDEO, A = Ve();
976
+ z({ event: "Video Record Finish", apiBase: w, headers: y, visitorId: P, envId: H, metadata: { mediaRecordingUid: A, questionId: Z, responseGroupUid: q, surveyId: N, mediaType: V } });
977
+ const J = { surveyId: N, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), mediaType: V, mediaRecordingUid: A };
898
978
  Z && (J.questionId = Z), q && (J.responseGroupUid = q), P && (J.visitorId = P);
899
979
  const K = await (async () => {
900
- const H = await fetch(`${w}/2/environments/integrations/upload`, { method: "POST", cache: "no-cache", headers: { "Content-Type": "application/json" }, body: JSON.stringify(J) });
901
- if (H.ok) {
902
- const pe = await H.json();
903
- return g && g(x.UPLOAD_STARTED, { [x.UPLOAD_ID]: pe.upload.id, [x.MEDIA_TYPE]: N, [x.MEDIA_RECORDING_UID]: $ }), pe.upload.url;
980
+ const S = await fetch(`${w}/2/environments/integrations/upload`, { method: "POST", cache: "no-cache", headers: { "Content-Type": "application/json" }, body: JSON.stringify(J) });
981
+ if (S.ok) {
982
+ const ue = await S.json();
983
+ return h && h(x.UPLOAD_STARTED, { [x.UPLOAD_ID]: ue.upload.id, [x.MEDIA_TYPE]: V, [x.MEDIA_RECORDING_UID]: A }), ue.upload.url;
904
984
  }
905
- return g && g(x.ERROR, { type: x.OTHER, response: H }), V(new Error("failed to get upload response with url"), "finishRecord", w, y, P, B), null;
985
+ return h && h(x.ERROR, { type: x.OTHER, response: S }), F(new Error("failed to get upload response with url"), "finishRecord", w, y, P, H), null;
906
986
  })();
907
- K && (S = d.document.defaultView.UpChunk.createUpload({ endpoint: K, file: new d.document.defaultView.File([p.recordedData], `recording ${N} ${Date.now()}`), chunkSize: 5120 }), S.startTime = Date.now(), A({ event: "Video Upload Start", apiBase: w, headers: y, visitorId: P, envId: B, metadata: { mediaRecordingUid: $, questionId: Z, responseGroupUid: q, surveyId: U, mediaType: N, url: K } }), S.on("error", (H) => {
908
- k(p.uploadProgressLabel, "none"), g && g(x.UPLOAD_FINISHED, { [x.MEDIA_RECORDING_UID]: $ }), V(H, "finishRecord", w, y, P, B);
909
- }), S.on("progress", (H) => {
910
- g && g(x.UPLOAD_PROGRESS, { [x.MEDIA_RECORDING_UID]: $, [x.UPLOAD_PROGRESS_PCT]: H.detail }), k(p.uploadProgressLabel, "progress", H.detail);
911
- }), S.on("success", () => {
912
- k(p.uploadProgressLabel, "success"), g && g(x.UPLOAD_FINISHED, { [x.MEDIA_RECORDING_UID]: $ }), A({ event: "Video Upload Success", apiBase: w, headers: y, visitorId: P, envId: B, metadata: { mediaRecordingUid: $, questionId: Z, responseGroupUid: q, surveyId: U, mediaType: N, url: K, elapsedMs: S.startTime && Date.now() - S.startTime } });
987
+ K && (U = a.document.defaultView.UpChunk.createUpload({ endpoint: K, file: new a.document.defaultView.File([p.recordedData], `recording ${V} ${Date.now()}`), chunkSize: 5120 }), U.startTime = Date.now(), z({ event: "Video Upload Start", apiBase: w, headers: y, visitorId: P, envId: H, metadata: { mediaRecordingUid: A, questionId: Z, responseGroupUid: q, surveyId: N, mediaType: V, url: K } }), U.on("error", (S) => {
988
+ j(p.uploadProgressLabel, "none"), h && h(x.UPLOAD_FINISHED, { [x.MEDIA_RECORDING_UID]: A }), F(S, "finishRecord", w, y, P, H);
989
+ }), U.on("progress", (S) => {
990
+ h && h(x.UPLOAD_PROGRESS, { [x.MEDIA_RECORDING_UID]: A, [x.UPLOAD_PROGRESS_PCT]: S.detail }), j(p.uploadProgressLabel, "progress", S.detail);
991
+ }), U.on("success", () => {
992
+ j(p.uploadProgressLabel, "success"), h && h(x.UPLOAD_FINISHED, { [x.MEDIA_RECORDING_UID]: A }), z({ event: "Video Upload Success", apiBase: w, headers: y, visitorId: P, envId: H, metadata: { mediaRecordingUid: A, questionId: Z, responseGroupUid: q, surveyId: N, mediaType: V, url: K, elapsedMs: U.startTime && Date.now() - U.startTime } });
913
993
  }));
914
994
  });
915
- })(i, t, r, fe, l);
995
+ })(r, t, i, Ce, l);
916
996
  const W = [{ name: "microphone" }];
917
- !i.cameraOff && W.push({ name: "camera" }), Promise.all(W.map((p) => {
997
+ !r.cameraOff && W.push({ name: "camera" }), Promise.all(W.map((p) => {
918
998
  var w;
919
999
  return (w = navigator == null ? void 0 : navigator.permissions) == null ? void 0 : w.query(p);
920
1000
  })).then((p) => {
921
- p.reduce((w, g) => w & g.state === "granted", !0) && i && (i.deviceButton && i.deviceButton.hide(), i.record().getDevice());
1001
+ p.reduce((w, h) => w & h.state === "granted", !0) && r && (r.deviceButton && r.deviceButton.hide(), r.record().getDevice());
922
1002
  }).catch((p) => {
923
1003
  });
924
- }, Pe = (e, n = 3) => {
925
- const o = d.document.getElementById("ul-recording-countdown-screen");
1004
+ }, Re = (e, n = 3) => {
1005
+ const o = a.document.getElementById("ul-recording-countdown-screen");
926
1006
  o && n === 0 ? (o.remove(), e.record().start()) : o && (o.innerHTML = `<span class='ul-countdown-text'>Recording in... ${n}</span>`, setTimeout(() => {
927
- Pe(e, n - 1);
1007
+ Re(e, n - 1);
928
1008
  }, 1e3));
929
- }, Re = (e) => {
930
- const n = d.document.createElement("div");
1009
+ }, _e = (e) => {
1010
+ const n = a.document.createElement("div");
931
1011
  return n.className = "ul-video-container", n.appendChild(((o) => {
932
- const t = d.document.createElement("div");
933
- return t.className = "ul-video-player-loading", t.id = ce(o), ["first", "second", "third", "fourth"].map((r) => {
934
- const s = d.document.createElement("div");
935
- s.className = r, t.appendChild(s);
1012
+ const t = a.document.createElement("div");
1013
+ return t.className = "ul-video-player-loading", t.id = ce(o), ["first", "second", "third", "fourth"].map((i) => {
1014
+ const s = a.document.createElement("div");
1015
+ s.className = i, t.appendChild(s);
936
1016
  }), t;
937
1017
  })(e)), n;
938
- }, le = (e, n) => {
939
- const o = d.document.createElement("video");
1018
+ }, ae = (e, n) => {
1019
+ const o = a.document.createElement("video");
940
1020
  o.id = e, o.className = "video-js vjs-default-skin ul-video-player-video";
941
- const t = d.document.createElement("p");
1021
+ const t = a.document.createElement("p");
942
1022
  t.className = "vjs-no-js", t.innerHTML = "To view this video please enable JavaScript, and consider upgrading to a web browser that";
943
- const r = d.document.createElement("a");
944
- return r.href = "https://videojs.com/html5-video-support/", r.target = "_blank", r.innerHTML = "supports HTML5 video", t.appendChild(r), o.appendChild(t), n.appendChild(o), n;
945
- }, Ke = (e, n) => {
946
- e.children()[0].classList.remove("vjs-hidden"), e.audioPlayerPlaceholder.hide(), d.document.getElementById(`${e.id()}_html5_api`).style.height = "100%";
947
- }, ee = (e, n) => d.document.getElementById(e) ? n ? d.videojs(e, n) : d.videojs(e) : (console.error(`Error in finding player element with ID, ${e}`), null), hn = (e, n, o, t = !1, r = "https://api.sprig.com", s = document, l = null, a = null) => {
948
- d.document = s;
949
- const i = e + ke, c = Re(i);
950
- return d.document.addEventListener("securitypolicyviolation", (m) => {
951
- V(new Error(`Voice & Video feature violates ${m.violatedDirective} web page CSP policies for the question player.`), "playerDeviceError", r, {});
952
- }), De(je, () => {
953
- d.document.getElementById(ce(i)).remove(), le(i, c);
1023
+ const i = a.document.createElement("a");
1024
+ return i.href = "https://videojs.com/html5-video-support/", i.target = "_blank", i.innerHTML = "supports HTML5 video", t.appendChild(i), o.appendChild(t), n.appendChild(o), n;
1025
+ }, nn = (e, n) => {
1026
+ e.children()[0].classList.remove("vjs-hidden"), e.audioPlayerPlaceholder.hide(), a.document.getElementById(`${e.id()}_html5_api`).style.height = "100%";
1027
+ }, ee = (e, n) => a.document.getElementById(e) ? n ? a.videojs(e, n) : a.videojs(e) : (console.error(`Error in finding player element with ID, ${e}`), null), bn = (e, n, o, t = !1, i = "https://api.sprig.com", s = document, l = null, c = null) => {
1028
+ a.document = s;
1029
+ const r = e + Ie, u = _e(r);
1030
+ return a.document.addEventListener("securitypolicyviolation", (m) => {
1031
+ F(new Error(`Voice & Video feature violates ${m.violatedDirective} web page CSP policies for the question player.`), "playerDeviceError", i, {});
1032
+ }), Te(ke, () => {
1033
+ a.document.getElementById(ce(r)).remove(), ae(r, u);
954
1034
  const m = { playsinline: !0, playbackRates: [0.5, 1, 1.5, 2], fill: !0 };
955
1035
  try {
956
- const I = e + ge;
957
- le(I, c);
958
- const b = ee(i, m), L = ee(I, { muted: !0, ...m });
959
- if (!b || !L) return;
960
- ((h, f, j) => {
961
- h.addClass(`ul${ge}`);
962
- const C = new (d.videojs.getComponent("Component"))(h);
963
- f && h.src(f), h.addChild(C), j && j(h);
964
- })(L, l, a), l || L.addClass(T);
965
- const E = Te(b, ["PlaybackRateMenuButton", "PlayToggle", "FullscreenToggle"]), v = E.children().find((h) => h.name_ === "FullscreenToggle");
966
- v.hasClass("vjs-disabled") && v.hide(), Le(b, E, n, o, t, L);
1036
+ const I = e + be;
1037
+ ae(I, u);
1038
+ const g = ee(r, m), T = ee(I, { muted: !0, ...m });
1039
+ if (!g || !T) return;
1040
+ ((d, C, E) => {
1041
+ d.addClass(`ul${be}`);
1042
+ const b = new (a.videojs.getComponent("Component"))(d);
1043
+ C && d.src(C), d.addChild(b), E && E(d);
1044
+ })(T, l, c), l || T.addClass(D);
1045
+ const f = Le(g, ["PlaybackRateMenuButton", "PlayToggle", "FullscreenToggle"]), L = f.children().find((d) => d.name_ === "FullscreenToggle");
1046
+ L.hasClass("vjs-disabled") && L.hide(), Pe(g, f, n, o, t, T);
967
1047
  } catch (I) {
968
- return void V(new Error(`Error when creating video player object ${I}`), "playerDeviceError", r, {});
1048
+ return void F(new Error(`Error when creating video player object ${I}`), "playerDeviceError", i, {});
969
1049
  }
970
- }), c;
971
- }, mn = (e, n = {}, o = "https://api.userleap.com", t, r, s, l = !1, a = document) => {
972
- d.document = a;
973
- const i = e + Ie, c = Re(i);
974
- return d.document.addEventListener("securitypolicyviolation", (m) => {
975
- V(new Error(`Voice & Video feature violates ${m.violatedDirective} web page CSP policies for the recorder player.`), "recorderDeviceError", o, s, n.visitorId, n.envId);
976
- }), De(je.concat(We), () => {
977
- le(i, c), d.document.getElementById(ce(i)).remove();
1050
+ }), u;
1051
+ }, fn = (e, n = {}, o = "https://api.userleap.com", t, i, s, l = !1, c = document) => {
1052
+ a.document = c;
1053
+ const r = e + De, u = _e(r);
1054
+ return a.document.addEventListener("securitypolicyviolation", (m) => {
1055
+ F(new Error(`Voice & Video feature violates ${m.violatedDirective} web page CSP policies for the recorder player.`), "recorderDeviceError", o, s, n.visitorId, n.envId);
1056
+ }), Te(ke.concat(Qe), () => {
1057
+ ae(r, u), a.document.getElementById(ce(r)).remove();
978
1058
  try {
979
- Je(c, i, n, o, t, r, s, l);
1059
+ en(u, r, n, o, t, i, s, l);
980
1060
  } catch (m) {
981
- return void V(new Error(`Error when creating video recorder player object ${m}`), "recorderDeviceError", o, s, n.visitorId, n.envId);
1061
+ return void F(new Error(`Error when creating video recorder player object ${m}`), "recorderDeviceError", o, s, n.visitorId, n.envId);
982
1062
  }
983
- }), c;
984
- }, gn = (e) => {
985
- const n = e + Ie;
986
- if (d.document.getElementById(n) && d.videojs) {
1063
+ }), u;
1064
+ }, Cn = (e) => {
1065
+ const n = e + De;
1066
+ if (a.document.getElementById(n) && a.videojs) {
987
1067
  try {
988
- if (!d.videojs(n).record().stream) return;
1068
+ if (!a.videojs(n).record().stream) return;
989
1069
  } catch {
990
1070
  return;
991
1071
  }
992
- d.videojs(n).record().stop(), d.videojs(n).record().stopDevice();
1072
+ a.videojs(n).record().stop(), a.videojs(n).record().stopDevice();
993
1073
  }
994
- }, bn = (e) => {
995
- const n = ee(e + ke);
1074
+ }, wn = (e) => {
1075
+ const n = ee(e + Ie);
996
1076
  n == null || n.pause();
997
- }, Qe = (e) => {
1077
+ }, on = (e) => {
998
1078
  if (!e) return null;
999
1079
  const n = e.match(/https:\/\/stream.mux.com\/(.*)/);
1000
1080
  let o = n ? n[1] : null;
1001
- return o.includes(me) && (o = o.replace(me, "")), o ? `https://image.mux.com/${o}/thumbnail.jpg?time=0` : null;
1081
+ return o.includes(ge) && (o = o.replace(ge, "")), o ? `https://image.mux.com/${o}/thumbnail.jpg?time=0` : null;
1002
1082
  }, x = { UPLOAD_STARTED: "upload.started", UPLOAD_PROGRESS: "upload.progress", UPLOAD_FINISHED: "upload.finished", DELETE: "delete", ERROR: "error", MEDIA_TYPE: "media.type", PERMISSION_DENIED: "permission_denied", OTHER: "other", UPLOAD_ID: "upload.id", UPLOAD_PROGRESS_PCT: "upload.progress.pct", MEDIA_RECORDING_UID: "media.recording.uid", MEDIA_TYPE_VIDEO: "video", MEDIA_TYPE_AUDIO: "audio" }, R = { PlaybackRateMenuButton: "Speed", PlayToggle: "Play", FullscreenToggle: "Expand", TurnOnCamera: "Turn on", TurnOffCamera: "Turn off", DeleteButton: "Delete", RecordButton: "Record", StopButton: "Stop", PauseButton: "Pause" };
1003
- var Xe = ((e) => (e.CONTINUE = "CONTINUE", e.EXTERNAL = "EXTERNAL", e.NO_BUTTON = "NO_BUTTON", e))(Xe || {}), en = ((e) => (e.Unlimited = "Unlimited", e.Maximum = "Maximum", e.Range = "Range", e))(en || {});
1004
- function fn(e) {
1005
- const n = e.props;
1006
- if (n === null || typeof n != "object") return !1;
1007
- const o = Reflect.get(n, "properties");
1008
- return typeof o == "object" && o !== null && "required" in o;
1009
- }
1010
- const nn = ({ options: e, selectItem: n, selectedOptions: o, showCheckbox: t, disabledOptions: r, dropdownFooter: s }) => {
1011
- const { themeColor: l } = F((a) => ({ doc: a.viewDocument, themeColor: a.border }));
1012
- return u("div", { className: "select-list", children: [e.map((a) => {
1013
- return u("div", { "aria-disabled": r == null ? void 0 : r.includes(a), className: _("select-option", r != null && r.includes(a) ? "ul-choice-disabled" : ""), onClick: (c) => {
1014
- r != null && r.includes(a) || (n(a), c.stopPropagation());
1015
- }, role: "option", style: { ...r != null && r.includes(a) ? { opacity: 0.5, cursor: "not-allowed" } : {} }, children: [t && u(xe, { divId: (i = a.id, `checkbox-div-${i}`), id: a.id, isSelected: o.includes(a), themeColor: l }), a.label] }, a.id);
1016
- var i;
1017
- }), s] });
1018
- }, Cn = ({ isMultiSelect: e = !1, multiselectText: n = "choices selected", onChange: o, options: t, placeholderText: r, value: s, disabledOptions: l = [], dropdownFooter: a }) => {
1019
- const [i, c] = ae(!1), { viewDocument: m, update: I, isConversationalUI: b } = F((v) => ({ viewDocument: v.viewDocument, update: v.update, isConversationalUI: v.isConversationalUI })), L = () => {
1020
- c(!i);
1021
- };
1022
- Oe(() => {
1023
- b || I();
1024
- }, [i, b, I]), ne(() => {
1025
- var h;
1026
- const v = (f) => {
1027
- const j = f.target;
1028
- (j == null ? void 0 : j.closest(".select-option.ul-choice-disabled")) || c(!1);
1029
- };
1030
- m.addEventListener("click", v);
1031
- try {
1032
- (h = window.parent) == null || h.addEventListener("click", v);
1033
- } catch {
1034
- window.addEventListener("click", v);
1035
- }
1036
- return () => {
1037
- var f;
1038
- m.removeEventListener("click", v);
1039
- try {
1040
- (f = window.parent) == null || f.removeEventListener("click", v);
1041
- } catch {
1042
- window.removeEventListener("click", v);
1043
- }
1044
- };
1045
- }, [m]);
1046
- const E = s.length === 0 ? ["select-button-placeholder"] : [];
1047
- return u(Ce, { children: [u("button", { "aria-label": "choice dropdown button", className: _("select-button", ...E), onClick: (v) => {
1048
- v.stopPropagation(), L();
1049
- }, type: "button", children: [u("span", { children: s.length === 0 ? r : s.length === 1 ? s[0].label : `${s.length} ${n}` }), u(Be, {})] }), i && u(nn, { disabledOptions: l, dropdownFooter: a, options: t, selectedOptions: s, selectItem: (v) => {
1050
- var j;
1051
- const h = s.some((C) => C.id === v.id), f = s.some((C) => {
1052
- var D;
1053
- return (D = C.optionProperties) == null ? void 0 : D.noneOfTheAbove;
1054
- });
1055
- (j = v.optionProperties) != null && j.noneOfTheAbove && !h ? o([v]) : e ? o(h ? s.filter((C) => C.id !== v.id) : f ? [v] : [...s, v]) : h || o([v]), e || L();
1056
- }, showCheckbox: e })] });
1057
- }, on = { "{{user_id}}": "externalUserId", "{{email}}": "email" }, wn = (e = void 0, n = {}) => {
1058
- if (!e) return e;
1059
- const o = ["http:", "https:", "itms-apps:", "market:"], t = ((l) => /^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//.test(l) ? l : `http://${l}`)(e);
1060
- if (!t) return;
1061
- try {
1062
- const l = new URL(t);
1063
- if (!l.protocol || !o.includes(l.protocol)) return;
1064
- } catch {
1065
- return;
1066
- }
1067
- const r = [], s = ((l, a, i) => {
1068
- let c = l;
1069
- for (const [m, I] of Object.entries(on)) if (c.toLowerCase().includes(m)) if (a[I]) {
1070
- const b = new RegExp(m, "gi");
1071
- c = c.replace(b, a[I]);
1072
- } else i.push(m);
1073
- return c;
1074
- })(t, n, r);
1075
- return r.length === 0 ? s : ((l, a) => {
1076
- if (!l.includes("?")) return l;
1077
- const i = l.slice(0, l.indexOf("?")), c = l.slice(l.indexOf("?") + 1).split("&").map((m) => m.split("=")).filter((m) => !a.includes(m[1]));
1078
- return c.length === 0 ? i : `${i}?${c.map((m) => m.join("=")).join("&")}`;
1079
- })(s, r);
1080
- };
1081
1083
  export {
1082
1084
  Fe as B,
1083
1085
  $e as H,
1084
1086
  dn as L,
1085
1087
  cn as M,
1086
- pn as O,
1087
- Xe as P,
1088
+ un as O,
1089
+ We as P,
1088
1090
  vn as Q,
1089
1091
  x as R,
1090
- Cn as S,
1091
- un as a,
1092
- en as b,
1092
+ hn as S,
1093
+ pn as a,
1094
+ Ye as b,
1093
1095
  an as c,
1094
- mn as d,
1095
- fn as e,
1096
- wn as g,
1097
- bn as p,
1098
- gn as s,
1096
+ fn as d,
1097
+ mn as e,
1098
+ gn as g,
1099
+ wn as p,
1100
+ Cn as s,
1099
1101
  ze as u,
1100
- hn as v
1102
+ bn as v
1101
1103
  };