@sprig-technologies/sprig-browser 2.43.0 → 2.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,80 +1,86 @@
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
- import { d as Ne } from "./debounce-CMb8f7wh.js";
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]);
1
+ import { u as v, c as _, a as U, F as Me, h as de, p as J, _ as K, g as Ce, S as Oe, b as le, y as ue, d as Be } from "./view-MpYHLeMt.js";
2
+ import { g as He, i as Se, E as Ve, b as ye } from "./core-CWHAsU-S.js";
3
+ import { d as Ue } from "./debounce-CMb8f7wh.js";
4
+ import { v as Fe } from "./metricsReporter-Bg5aC8mO.js";
5
+ const Ne = (e) => v("button", { ...e, className: _("ul-card-text__button", e.className), id: "ul-card-text__button" }), $e = ({ html: e, ...n }) => {
6
+ const { enableCspTrustedTypes: o } = U((r) => ({ enableCspTrustedTypes: r.enableCspTrustedTypes })), t = Me(() => He(e, o), [o, e]);
7
7
  return v("div", { ...n, dangerouslySetInnerHTML: { __html: t } });
8
8
  }, xe = () => {
9
- const { viewDocument: e } = $((t) => ({ viewDocument: t.viewDocument })), [n, o] = de(!1);
10
- return ne(() => {
11
- const t = e.querySelector(".sprig-question-body"), i = new ResizeObserver(() => {
9
+ const { viewDocument: e } = U((t) => ({ viewDocument: t.viewDocument })), [n, o] = de(!1);
10
+ return J(() => {
11
+ const t = e.querySelector(".sprig-question-body"), r = new ResizeObserver(() => {
12
12
  window.requestAnimationFrame(() => {
13
13
  o(!!(t && Se(t) && t.scrollHeight > t.offsetHeight));
14
14
  });
15
15
  });
16
- return t && i.observe(t), () => {
17
- t && i.disconnect();
16
+ return t && r.observe(t), () => {
17
+ t && r.disconnect();
18
18
  };
19
19
  }, [e]), n;
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);
20
+ }, ve = ({ plainText: e, richText: n, id: o, className: t, isHeader: r, showAsterisk: s }) => n ? v($e, { className: t, html: n, id: o }) : e ? r ? v("h1", { className: t, id: o, children: [e, s && "*"] }) : v("p", { className: t, id: o, children: e }) : null, sn = ({ message: e, properties: n, isRequired: o }) => {
21
+ const t = K(null), r = 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: r, 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" }) }), ln = ({ isSubmitDisabled: e, handleSubmit: n }) => v("div", { className: "ul-card-longform__submit-button-container", children: v(Ne, { className: "ul-card-longform__submit-button", disabled: e, onClick: n, children: ["OK ", v(Ae, {})] }) }), ze = (e, n) => {
24
+ const o = K(0);
25
25
  return () => {
26
26
  if (e.current) {
27
27
  const t = e.current;
28
28
  t.style.height = "1px";
29
- const i = t.scrollHeight + (t.offsetHeight - t.clientHeight), s = parseInt(window.getComputedStyle(t).getPropertyValue("max-height")), l = i <= s ? i : s;
29
+ const r = t.scrollHeight + (t.offsetHeight - t.clientHeight), s = parseInt(window.getComputedStyle(t).getPropertyValue("max-height")), l = r <= s ? r : 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
- }, 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 }) => {
35
+ }, an = (e) => {
36
+ const n = K(), { setAllResponsesRaw: o } = U((t) => ({ setAllResponsesRaw: t.setAllResponsesRaw }));
37
+ J(() => {
38
+ const t = n.current;
39
+ (!t || Object.keys(e).length !== Object.keys(t).length || Object.keys(e).some((r) => e[r] !== t[r])) && (o(e), n.current = e);
40
+ }, [e, o]);
41
+ }, he = ({ buttonText: e = "View Prototype", handleClick: n }) => v("button", { className: "prototype-button", onClick: n, children: e }, "prototype-btn"), dn = ({ embeddedType: e = "prototype", properties: n, children: o }) => {
36
42
  var I;
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) => {
43
+ const { handleClickEmbedButton: t, hasViewedEmbed: r, headers: s, useDesktopPrototype: l } = U((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), i = window.innerWidth < Ve, p = s["userleap-platform"], h = (g, T) => {
38
44
  g.preventDefault(), t(T);
39
45
  };
40
46
  if ((() => {
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
- ne(() => {
47
+ const { update: g, index: T, isConversationalUI: f, viewDocument: L } = U(({ update: w, index: j, isConversationalUI: b, viewDocument: k }) => ({ update: w, index: j, isConversationalUI: b, viewDocument: k })), d = Ue(g, 100);
48
+ J(() => {
43
49
  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();
50
+ const w = new ResizeObserver(d), j = L.querySelector(".ul-card__container");
51
+ return j && w.observe(j, { box: "border-box" }), () => {
52
+ w.disconnect();
47
53
  };
48
54
  }, [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");
55
+ })(), !l && i && !r && c && ["email", "link"].includes(p)) {
56
+ if (e === "prototype") return v(he, { handleClick: (g) => {
57
+ h(g, "question.prototype.click");
52
58
  } });
53
- if (e === "pdf") return v(me, { buttonText: (n == null ? void 0 : n.viewDocumentText) || "View Document", handleClick: (g) => {
54
- m(g, "question.agreement.click");
59
+ if (e === "pdf") return v(he, { buttonText: (n == null ? void 0 : n.viewDocumentText) || "View Document", handleClick: (g) => {
60
+ h(g, "question.agreement.click");
55
61
  } });
56
62
  }
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));
63
+ return v(Ce, { children: o });
64
+ }, je = ({ isSelected: e, id: n, divId: o, themeColor: t, disabled: r = !1 }) => v("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 && v(Oe, {}) }), cn = ({ ariaLabel: e, border: n, choiceStyle: o = {}, label: t, isSelected: r, value: s, text: l, id: c, isRadio: i, useMobileStyling: p, error: h, allowTextEntry: I, noneOfTheAbove: g, promptText: T, disabled: f = !1, onUserInputChanged: L }) => {
65
+ const { styleNonce: d, viewDocument: w } = U((E) => ({ styleNonce: E.styleNonce, viewDocument: E.viewDocument })), [j, b] = de(!1);
66
+ Ze(w, n, d);
67
+ const k = ({ isSelected: E, userText: y }) => {
68
+ L && L({ id: c, selected: E, value: s, userText: y, noneOfTheAbove: g });
69
+ }, M = (E) => {
70
+ f || (E.stopPropagation(), k({ isSelected: i || !r, userText: l }), b(!1));
65
71
  }, Y = () => {
66
- E || b(!0);
72
+ j || b(!0);
67
73
  }, O = () => {
68
- E && b(!1);
69
- }, B = { onClick: (j) => M(j), onKeyPress: (j) => ((y) => {
74
+ j && b(!1);
75
+ }, B = { onClick: (E) => M(E), onKeyPress: (E) => ((y) => {
70
76
  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 }) })] });
77
+ })(E) };
78
+ "ontouchstart" in w.documentElement ? (B.onTouchStart = O, B.onTouchCancel = O, B.onTouchEnd = O) : (B.onMouseDown = Y, B.onMouseLeave = O);
79
+ const W = i ? `radio-${c}` : `checkbox-${c}`, u = r || j ? [ee] : [], C = [...h ? [Ee] : [], ...u, ...f ? ["ul-choice-disabled"] : []], m = t ? { "aria-labelledby": `label-${c}` } : { "aria-label": e };
80
+ return v("div", { className: _(le("choice", p), ...C), id: `choice-div-${c}`, style: { ...o, ...h ? { borderColor: ye } : {}, ...f ? { opacity: 0.5, cursor: "not-allowed" } : {} }, ...f ? {} : B, "aria-disabled": f, children: [v("div", { className: _("choice-label-container"), children: [i ? v("div", { ...m, className: _("select-radio", ...u), id: W, role: "radio", tabIndex: 0 }) : v(je, { disabled: f, divId: W, id: c, isSelected: r, themeColor: n }), t && v("label", { className: _(le("select-label", p)), htmlFor: W, id: `label-${c}`, children: t })] }), I && r && v("div", { className: _("choice-text-entry-container", ...u), children: v(qe, { onTextChange: (E) => k({ isSelected: r, userText: E }), promptText: T || "Please specify", textValue: l, useMobileStyling: p }) })] });
75
81
  }, qe = ({ promptText: e, textValue: n, onTextChange: o, useMobileStyling: t }) => {
76
- const i = oe(null), { update: s } = $((c) => ({ update: c.update })), l = ze(i, () => s());
77
- return ne(() => (l(), i.current && i.current.focus(), () => {
82
+ const r = K(null), { update: s } = U((c) => ({ update: c.update })), l = ze(r, () => s());
83
+ return J(() => (l(), r.current && r.current.focus(), () => {
78
84
  s();
79
85
  }), []), 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
86
  l(), c.stopPropagation(), o(c.currentTarget.value);
@@ -82,82 +88,74 @@ const Fe = (e) => v("button", { ...e, className: _("ul-card-text__button", e.cla
82
88
  c.stopPropagation();
83
89
  }, onKeyPress: (c) => {
84
90
  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));
91
+ }, placeholder: e, ref: r, role: "textbox", rows: 1, value: n });
92
+ }, me = "ul-select-style-element", ee = "ul-select-active-dynamic-style", Ee = "ul-select-error-dynamic-style", Ze = (e, n, o) => {
93
+ let t = e.getElementById(me), r = !1;
94
+ t || (t = e.createElement("style"), r = !0), t.tagName.toLowerCase() === "style" && (t.id = me, o && (t.nonce = o), t.textContent = Ge(n), r && e.head.appendChild(t));
89
95
  }, Ge = (e) => `
90
- .${Q} {
96
+ .${ee} {
91
97
  border-color: ${e};
92
98
  }
93
- .${Q} .select-radio, .${Q}.select-radio {
99
+ .${ee} .select-radio, .${ee}.select-radio {
94
100
  border: 6px solid ${e};
95
101
  box-shadow: none;
96
102
  }
97
- .${je} {
103
+ .${Ee} {
98
104
  border-color: ${ye};
99
105
  }
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 }));
106
+ `, pn = ({ children: e }) => v("div", { className: "sprig-question-body", children: e }), un = ({ children: e }) => {
107
+ const n = xe(), { isConversationalUI: o } = U((t) => ({ isConversationalUI: t.isConversationalUI }));
102
108
  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;
109
+ }, We = ({ options: e, selectItem: n, selectedOptions: o, showCheckbox: t, disabledOptions: r, dropdownFooter: s, panelRef: l }) => {
110
+ const { themeColor: c } = U((i) => ({ doc: i.viewDocument, themeColor: i.border }));
111
+ return v("div", { className: "select-list", ref: l, children: [e.map((i) => {
112
+ return v("div", { "aria-disabled": r == null ? void 0 : r.includes(i), className: _("select-option", r != null && r.includes(i) ? "ul-choice-disabled" : ""), onClick: (h) => {
113
+ r != null && r.includes(i) || (n(i), h.stopPropagation());
114
+ }, role: "option", style: { ...r != null && r.includes(i) ? { opacity: 0.5, cursor: "not-allowed" } : {} }, children: [t && v(je, { divId: (p = i.id, `checkbox-div-${p}`), id: i.id, isSelected: o.includes(i), themeColor: c }), i.label] }, i.id);
115
+ var p;
118
116
  }), 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);
117
+ }, vn = ({ isMultiSelect: e = !1, multiselectText: n = "choices selected", onChange: o, options: t, placeholderText: r, value: s, disabledOptions: l = [], dropdownFooter: c }) => {
118
+ const [i, p] = de(!1), h = K(null), { viewDocument: I, update: g, isConversationalUI: T } = U((d) => ({ viewDocument: d.viewDocument, update: d.update, isConversationalUI: d.isConversationalUI })), f = () => {
119
+ p(!i);
122
120
  };
123
- pe(() => {
121
+ ue(() => {
124
122
  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);
123
+ }, [i, T, g]), ue(() => {
124
+ i && h.current && h.current.scrollIntoView({ behavior: "smooth", block: "nearest" });
125
+ }, [i]), J(() => {
126
+ var w;
127
+ const d = (j) => {
128
+ const b = j.target;
129
+ (b == null ? void 0 : b.closest(".select-option.ul-choice-disabled")) || p(!1);
132
130
  };
133
131
  I.addEventListener("click", d);
134
132
  try {
135
- (C = window.parent) == null || C.addEventListener("click", d);
133
+ (w = window.parent) == null || w.addEventListener("click", d);
136
134
  } catch {
137
135
  window.addEventListener("click", d);
138
136
  }
139
137
  return () => {
140
- var E;
138
+ var j;
141
139
  I.removeEventListener("click", d);
142
140
  try {
143
- (E = window.parent) == null || E.removeEventListener("click", d);
141
+ (j = window.parent) == null || j.removeEventListener("click", d);
144
142
  } catch {
145
143
  window.removeEventListener("click", d);
146
144
  }
147
145
  };
148
146
  }, [I]);
149
147
  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) => {
148
+ return v(Ce, { children: [v("button", { "aria-label": "choice dropdown button", className: _("select-button", ...L), onClick: (d) => {
151
149
  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) => {
150
+ }, type: "button", children: [v("span", { children: s.length === 0 ? r : s.length === 1 ? s[0].label : `${s.length} ${n}` }), v(Be, {})] }), i && v(We, { disabledOptions: l, dropdownFooter: c, options: t, panelRef: h, selectedOptions: s, selectItem: (d) => {
153
151
  var b;
154
- const C = s.some((k) => k.id === d.id), E = s.some((k) => {
152
+ const w = s.some((k) => k.id === d.id), j = s.some((k) => {
155
153
  var M;
156
154
  return (M = k.optionProperties) == null ? void 0 : M.noneOfTheAbove;
157
155
  });
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();
156
+ (b = d.optionProperties) != null && b.noneOfTheAbove && !w ? o([d]) : e ? o(w ? s.filter((k) => k.id !== d.id) : j ? [d] : [...s, d]) : w || o([d]), e || f();
159
157
  }, showCheckbox: e })] });
160
- }, Ke = { "{{user_id}}": "externalUserId", "{{email}}": "email" }, gn = (e = void 0, n = {}) => {
158
+ }, Ye = { "{{user_id}}": "externalUserId", "{{email}}": "email" }, hn = (e = void 0, n = {}) => {
161
159
  if (!e) return e;
162
160
  const o = ["http:", "https:", "itms-apps:", "market:"], t = ((l) => /^[a-zA-Z][a-zA-Z0-9+\-.]*:\/\//.test(l) ? l : `http://${l}`)(e);
163
161
  if (!t) return;
@@ -167,20 +165,20 @@ const Je = ({ options: e, selectItem: n, selectedOptions: o, showCheckbox: t, di
167
165
  } catch {
168
166
  return;
169
167
  }
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) => {
168
+ const r = [], s = ((l, c, i) => {
169
+ let p = l;
170
+ for (const [h, I] of Object.entries(Ye)) if (p.toLowerCase().includes(h)) if (c[I]) {
171
+ const g = new RegExp(h, "gi");
172
+ p = p.replace(g, c[I]);
173
+ } else i.push(h);
174
+ return p;
175
+ })(t, n, r);
176
+ return r.length === 0 ? s : ((l, c) => {
179
177
  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 */
178
+ const i = l.slice(0, l.indexOf("?")), p = l.slice(l.indexOf("?") + 1).split("&").map((h) => h.split("=")).filter((h) => !c.includes(h[1]));
179
+ return p.length === 0 ? i : `${i}?${p.map((h) => h.join("=")).join("&")}`;
180
+ })(s, r);
181
+ }, 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", Je = [{ 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 */
184
182
  .video-js .vjs-control {
185
183
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
186
184
  }
@@ -838,31 +836,31 @@ span.ul-button-text {
838
836
  background-size: cover;
839
837
  }
840
838
  ` }], 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 }) => {
839
+ let V, fe;
840
+ const z = async ({ event: e, apiBase: n, headers: o, visitorId: t, envId: r, metadata: s }) => {
843
841
  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 } };
842
+ if (!t || !r) return;
843
+ const c = { 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 } };
846
844
  (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);
845
+ }, $ = async (e, n, o, t, r, s) => {
846
+ z({ event: `Video Error ${n}`, apiBase: o, headers: t, visitorId: r, envId: s, metadata: { errorMessage: e.message } });
847
+ 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 }, i = { action: n, err: { message: e.message, stack: e.stack }, meta: c, vid: r, envId: s };
848
+ (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);
851
849
  }, Te = (e, n) => {
852
850
  if (e.length === 0) return 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() {
851
+ Promise.all(e.reduce((o, t) => (o.push(((r, { type: s, content: l }) => new Promise(function(c, i) {
852
+ let p;
853
+ s === "script" ? (p = a.document.createElement("script"), p.src = l) : s === "link" ? (p = a.document.createElement("link"), p.rel = "stylesheet", p.href = l, p.type = "text/css") : (p = a.document.createElement("style"), p.innerHTML = l), p.onload = function() {
856
854
  c(l);
857
- }, u.onerror = function() {
858
- r(l);
859
- }, u.async = !1, u.id = btoa(l), i.appendChild(u);
855
+ }, p.onerror = function() {
856
+ i(l);
857
+ }, p.async = !1, p.id = btoa(l), r.appendChild(p);
860
858
  }))(a.document.head, t)), o), [])).then(() => {
861
859
  a.videojs = a.document.defaultView.videojs, n && n();
862
860
  }).catch(function(o) {
863
861
  console.log(o + " failed to load");
864
862
  });
865
- }, Ce = (e, n, o) => {
863
+ }, we = (e, n, o) => {
866
864
  if (n === "start" && (e.style.visibility = "visible"), n === "none") e.style.visibility = D;
867
865
  else if (n === "success") e.style.visibility = D, e.innerHTML = "Upload succeeded!";
868
866
  else {
@@ -876,24 +874,24 @@ const z = async ({ event: e, apiBase: n, headers: o, visitorId: t, envId: i, met
876
874
  const o = new (a.videojs.getComponent("Component"))(e);
877
875
  return o.addClass("ul-buttons-panel"), n.map((t) => {
878
876
  o.addChild(t);
879
- }), Xe(o), o;
880
- }, Xe = (e) => {
877
+ }), Ke(o), o;
878
+ }, Ke = (e) => {
881
879
  e.children().forEach((n) => {
882
- if (R[n.name_]) {
883
- const o = X(R[n.name_], `ul-${R[n.name_]}`);
880
+ if (P[n.name_]) {
881
+ const o = ne(P[n.name_], `ul-${P[n.name_]}`);
884
882
  n.el_.appendChild(o);
885
883
  }
886
884
  });
887
- }, X = (e, n = "") => {
885
+ }, ne = (e, n = "") => {
888
886
  const o = a.document.createElement("span");
889
887
  return o.className = "ul-button-text", o.innerHTML = e, o.id = n, o;
890
- }, Pe = (e, n, o, t, i = !1, s) => {
888
+ }, Re = (e, n, o, t, r = !1, s) => {
891
889
  e.addClass("ul-video-player");
892
890
  const l = new (a.videojs.getComponent("Component"))(e);
893
891
  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();
892
+ const c = o && o.src ? en(o.src) : null;
893
+ !o || !r && 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", () => {
894
+ r || !o || c || Xe(e), s == null || s.play();
897
895
  }), e.on("pause", () => {
898
896
  s == null || s.pause();
899
897
  }), e.on("seeked", () => {
@@ -901,118 +899,118 @@ const z = async ({ event: e, apiBase: n, headers: o, visitorId: t, envId: i, met
901
899
  }), e.on("ratechange", () => {
902
900
  s == null || s.playbackRate(e.playbackRate());
903
901
  }), e.addChild(e.audioPlayerPlaceholder, {}, 1), l.addChild(n), e.addChild(l), t && t(e);
904
- }, en = (e, n, o, t, i, s, l, c = !1) => {
902
+ }, Qe = (e, n, o, t, r, s, l, c = !1) => {
905
903
  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;
904
+ const i = oe(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 } } });
905
+ if (!i) return;
906
+ i.payload = o;
907
+ const { surveyId: p, questionId: h, responseGroupUid: I, visitorId: g, envId: T } = o;
910
908
  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) => {
909
+ const L = (u) => {
910
+ const C = re, m = re + "-audio-only";
911
+ we(i.uploadProgressLabel, "none"), V && V.startTime >= fe && V.abort();
912
+ const E = a.document.getElementById("ul-camera-button");
913
+ u ? (i.children()[0].classList.add("vjs-hidden"), b.removeClass(C), b.addClass(m), E.innerHTML = P.TurnOnCamera, i.audioPlayerPlaceholder.removeClass("vjs-hidden"), f == null || f.getTracks().forEach((y) => {
916
914
  y.stop();
917
915
  }), window.navigator.mediaDevices.getUserMedia({ video: !0, audio: !0 }).then((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) => {
916
+ f = y, y.getVideoTracks().forEach((F) => {
917
+ F.enabled = !1;
918
+ }), i.record().onDeviceReady(y);
919
+ }).catch(i.record().onDeviceError.bind(i.record()))) : (f == null || f.getVideoTracks().forEach((y) => {
922
920
  y.enabled = !0;
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));
921
+ }), i.children()[0].classList.remove("vjs-hidden"), i.record().getDevice(), b.removeClass(m), b.addClass(C), E.innerHTML = P.TurnOffCamera, i.audioPlayerPlaceholder.addClass("vjs-hidden"));
922
+ }, d = new (a.videojs.getComponent("Button"))(i, { clickHandler: () => {
923
+ d.hasClass(D) || (z({ event: "Video Delete Button Clicked", apiBase: t, headers: l, visitorId: g, envId: T, metadata: { questionId: h, responseGroupUid: I, surveyId: p } }), L(i.cameraOff), r(x.DELETE, {}), b.removeClass(D), d.addClass(D));
926
924
  } });
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";
925
+ d.addClass("ul-video-recorder-delete-button"), d.el_.appendChild(ne(P.DeleteButton, "ul-delete-button"));
926
+ const w = a.document.getElementById(n), j = () => {
927
+ w.classList.contains("vjs-fullscreen") && i.cameraOff ? w.style.display = "table" : w.style.display = "flex";
930
928
  };
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());
929
+ j();
930
+ const b = new (a.videojs.getComponent("Button"))(i, { clickHandler: () => {
931
+ i.record().isRecording() || (i.cameraOff = !i.cameraOff, z({ event: "Video Camera Button Clicked", apiBase: t, headers: l, visitorId: o.visitorId, envId: o.envId, metadata: { questionId: h, responseGroupUid: I, surveyId: p, cameraOff: i.cameraOff } }), L(i.cameraOff), !d.hasClass(D) && d.addClass(D), r(x.DELETE, {}), j());
934
932
  } });
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);
933
+ b.addClass(re), b.el_.appendChild(ne(P.TurnOffCamera, "ul-camera-button"));
934
+ const k = new (a.videojs.getComponent("Button"))(i, { clickHandler: () => {
935
+ const u = a.document.getElementById("ul-recorder-toggle");
936
+ if (i.record().isRecording()) i.record().stop(), u && (u.innerHTML = P.RecordButton), k.removeClass(ie), d.removeClass(D);
939
937
  else {
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();
938
+ const C = a.document.getElementById("ul-recording-countdown-screen");
939
+ if (C) C.remove(), u && (u.innerHTML = P.RecordButton), L(i.cameraOff), r(x.DELETE, {}), b.removeClass(D), d.addClass(D), k.removeClass(ie), O.show();
942
940
  else {
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);
941
+ k.addClass(ie), O.hide(), b.addClass(D), d.addClass(D), u && (u.innerHTML = P.StopButton);
942
+ const m = a.document.createElement("div");
943
+ m.id = "ul-recording-countdown-screen", w.insertBefore(m, w.children[1]), m.style.height = `${w.offsetHeight}px`, Pe(i, 3);
946
944
  }
947
945
  }
948
946
  } });
949
- k.addClass("ul-video-recorder-toggle-button"), k.el_.appendChild(X(R.RecordButton, "ul-recorder-toggle"));
947
+ k.addClass("ul-video-recorder-toggle-button"), k.el_.appendChild(ne(P.RecordButton, "ul-recorder-toggle"));
950
948
  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");
949
+ M.style.visibility = "hidden", M.className = "ul-upload-progress-label", e.appendChild(M), i.uploadProgressLabel = M;
950
+ const Y = Le(i, [d, b, "PlayToggle", k, "FullscreenToggle"]), O = Y.children().find((u) => u.name_ === "FullscreenToggle");
953
951
  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", () => {
952
+ const B = Y.children().find((u) => u.name_ === "PlayToggle");
953
+ B.hide(), d.addClass(D), Re(i, Y, s, !1, c), i.on("stopRecord", () => {
956
954
  k.hide(), B.show(), O.show(), d.removeClass(D);
957
- }), r.on("deviceReady", () => {
955
+ }), i.on("deviceReady", () => {
958
956
  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;
961
- p.on("deviceError", function() {
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 } });
967
- }), p.on("finishRecord", async function() {
968
- j(p.uploadProgressLabel, "start", 0);
969
- const Z = se(p, te);
970
- if (!N) {
957
+ }), ((u, C, m, E, y) => {
958
+ const { surveyId: F, responseGroupUid: q, visitorId: R, envId: H } = u.payload;
959
+ u.on("deviceError", function() {
960
+ console.warn("device error: ", u.deviceErrorCode), u.deviceErrorCode.message === "Permission denied" ? (u.deviceButton.addClass("permission-denied"), m && m(x.ERROR, { type: x.PERMISSION_DENIED }), z({ event: "Video Permission Denied", apiBase: C, headers: y, visitorId: R, envId: H, metadata: { questionId: se(u, te), responseGroupUid: q, surveyId: F } })) : (m && m(x.ERROR, { type: x.OTHER }), $(new Error(u.deviceErrorCode.message), "recorderDeviceError", C, y, R, H));
961
+ }), u.on("error", function(Z, N) {
962
+ $(N || u.error(), "recorderError", C, y, R, H);
963
+ }), u.on("startRecord", function(Z, N) {
964
+ E(u.uploadProgressLabel, "none"), z({ event: "Video Record Start", apiBase: C, headers: y, visitorId: R, envId: H, metadata: { questionId: se(u, te), responseGroupUid: q, surveyId: F } });
965
+ }), u.on("finishRecord", async function() {
966
+ E(u.uploadProgressLabel, "start", 0);
967
+ const Z = se(u, te);
968
+ if (!F) {
971
969
  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;
970
+ return m && m(x.ERROR, { type: x.OTHER }), $(new Error(S), "finishRecord", C, y, R, H), null;
973
971
  }
974
- p.record().stopDevice();
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 };
978
- Z && (J.questionId = Z), q && (J.responseGroupUid = q), P && (J.visitorId = P);
979
- const K = await (async () => {
980
- const S = await fetch(`${w}/2/environments/integrations/upload`, { method: "POST", cache: "no-cache", headers: { "Content-Type": "application/json" }, body: JSON.stringify(J) });
972
+ u.record().stopDevice();
973
+ const N = u.cameraOff ? x.MEDIA_TYPE_AUDIO : x.MEDIA_TYPE_VIDEO, A = Fe();
974
+ z({ event: "Video Record Finish", apiBase: C, headers: y, visitorId: R, envId: H, metadata: { mediaRecordingUid: A, questionId: Z, responseGroupUid: q, surveyId: F, mediaType: N } });
975
+ const Q = { surveyId: F, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), mediaType: N, mediaRecordingUid: A };
976
+ Z && (Q.questionId = Z), q && (Q.responseGroupUid = q), R && (Q.visitorId = R);
977
+ const X = await (async () => {
978
+ const S = await fetch(`${C}/2/environments/integrations/upload`, { method: "POST", cache: "no-cache", headers: { "Content-Type": "application/json" }, body: JSON.stringify(Q) });
981
979
  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;
980
+ const pe = await S.json();
981
+ return m && m(x.UPLOAD_STARTED, { [x.UPLOAD_ID]: pe.upload.id, [x.MEDIA_TYPE]: N, [x.MEDIA_RECORDING_UID]: A }), pe.upload.url;
984
982
  }
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;
983
+ return m && m(x.ERROR, { type: x.OTHER, response: S }), $(new Error("failed to get upload response with url"), "finishRecord", C, y, R, H), null;
986
984
  })();
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 } });
985
+ X && (V = a.document.defaultView.UpChunk.createUpload({ endpoint: X, file: new a.document.defaultView.File([u.recordedData], `recording ${N} ${Date.now()}`), chunkSize: 5120 }), V.startTime = Date.now(), z({ event: "Video Upload Start", apiBase: C, headers: y, visitorId: R, envId: H, metadata: { mediaRecordingUid: A, questionId: Z, responseGroupUid: q, surveyId: F, mediaType: N, url: X } }), V.on("error", (S) => {
986
+ E(u.uploadProgressLabel, "none"), m && m(x.UPLOAD_FINISHED, { [x.MEDIA_RECORDING_UID]: A }), $(S, "finishRecord", C, y, R, H);
987
+ }), V.on("progress", (S) => {
988
+ m && m(x.UPLOAD_PROGRESS, { [x.MEDIA_RECORDING_UID]: A, [x.UPLOAD_PROGRESS_PCT]: S.detail }), E(u.uploadProgressLabel, "progress", S.detail);
989
+ }), V.on("success", () => {
990
+ E(u.uploadProgressLabel, "success"), m && m(x.UPLOAD_FINISHED, { [x.MEDIA_RECORDING_UID]: A }), z({ event: "Video Upload Success", apiBase: C, headers: y, visitorId: R, envId: H, metadata: { mediaRecordingUid: A, questionId: Z, responseGroupUid: q, surveyId: F, mediaType: N, url: X, elapsedMs: V.startTime && Date.now() - V.startTime } });
993
991
  }));
994
992
  });
995
- })(r, t, i, Ce, l);
993
+ })(i, t, r, we, l);
996
994
  const W = [{ name: "microphone" }];
997
- !r.cameraOff && W.push({ name: "camera" }), Promise.all(W.map((p) => {
998
- var w;
999
- return (w = navigator == null ? void 0 : navigator.permissions) == null ? void 0 : w.query(p);
1000
- })).then((p) => {
1001
- p.reduce((w, h) => w & h.state === "granted", !0) && r && (r.deviceButton && r.deviceButton.hide(), r.record().getDevice());
1002
- }).catch((p) => {
995
+ !i.cameraOff && W.push({ name: "camera" }), Promise.all(W.map((u) => {
996
+ var C;
997
+ return (C = navigator == null ? void 0 : navigator.permissions) == null ? void 0 : C.query(u);
998
+ })).then((u) => {
999
+ u.reduce((C, m) => C & m.state === "granted", !0) && i && (i.deviceButton && i.deviceButton.hide(), i.record().getDevice());
1000
+ }).catch((u) => {
1003
1001
  });
1004
- }, Re = (e, n = 3) => {
1002
+ }, Pe = (e, n = 3) => {
1005
1003
  const o = a.document.getElementById("ul-recording-countdown-screen");
1006
1004
  o && n === 0 ? (o.remove(), e.record().start()) : o && (o.innerHTML = `<span class='ul-countdown-text'>Recording in... ${n}</span>`, setTimeout(() => {
1007
- Re(e, n - 1);
1005
+ Pe(e, n - 1);
1008
1006
  }, 1e3));
1009
1007
  }, _e = (e) => {
1010
1008
  const n = a.document.createElement("div");
1011
1009
  return n.className = "ul-video-container", n.appendChild(((o) => {
1012
1010
  const t = a.document.createElement("div");
1013
- return t.className = "ul-video-player-loading", t.id = ce(o), ["first", "second", "third", "fourth"].map((i) => {
1011
+ return t.className = "ul-video-player-loading", t.id = ce(o), ["first", "second", "third", "fourth"].map((r) => {
1014
1012
  const s = a.document.createElement("div");
1015
- s.className = i, t.appendChild(s);
1013
+ s.className = r, t.appendChild(s);
1016
1014
  }), t;
1017
1015
  })(e)), n;
1018
1016
  }, ae = (e, n) => {
@@ -1020,48 +1018,48 @@ const z = async ({ event: e, apiBase: n, headers: o, visitorId: t, envId: i, met
1020
1018
  o.id = e, o.className = "video-js vjs-default-skin ul-video-player-video";
1021
1019
  const t = a.document.createElement("p");
1022
1020
  t.className = "vjs-no-js", t.innerHTML = "To view this video please enable JavaScript, and consider upgrading to a web browser that";
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) => {
1021
+ const r = a.document.createElement("a");
1022
+ 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;
1023
+ }, Xe = (e, n) => {
1026
1024
  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) => {
1025
+ }, oe = (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), mn = (e, n, o, t = !1, r = "https://api.sprig.com", s = document, l = null, c = null) => {
1028
1026
  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, {});
1027
+ const i = e + Ie, p = _e(i);
1028
+ return a.document.addEventListener("securitypolicyviolation", (h) => {
1029
+ $(new Error(`Voice & Video feature violates ${h.violatedDirective} web page CSP policies for the question player.`), "playerDeviceError", r, {});
1032
1030
  }), Te(ke, () => {
1033
- a.document.getElementById(ce(r)).remove(), ae(r, u);
1034
- const m = { playsinline: !0, playbackRates: [0.5, 1, 1.5, 2], fill: !0 };
1031
+ a.document.getElementById(ce(i)).remove(), ae(i, p);
1032
+ const h = { playsinline: !0, playbackRates: [0.5, 1, 1.5, 2], fill: !0 };
1035
1033
  try {
1036
1034
  const I = e + be;
1037
- ae(I, u);
1038
- const g = ee(r, m), T = ee(I, { muted: !0, ...m });
1035
+ ae(I, p);
1036
+ const g = oe(i, h), T = oe(I, { muted: !0, ...h });
1039
1037
  if (!g || !T) return;
1040
- ((d, C, E) => {
1038
+ ((d, w, j) => {
1041
1039
  d.addClass(`ul${be}`);
1042
1040
  const b = new (a.videojs.getComponent("Component"))(d);
1043
- C && d.src(C), d.addChild(b), E && E(d);
1041
+ w && d.src(w), d.addChild(b), j && j(d);
1044
1042
  })(T, l, c), l || T.addClass(D);
1045
1043
  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);
1044
+ L.hasClass("vjs-disabled") && L.hide(), Re(g, f, n, o, t, T);
1047
1045
  } catch (I) {
1048
- return void F(new Error(`Error when creating video player object ${I}`), "playerDeviceError", i, {});
1046
+ return void $(new Error(`Error when creating video player object ${I}`), "playerDeviceError", r, {});
1049
1047
  }
1050
- }), u;
1051
- }, fn = (e, n = {}, o = "https://api.userleap.com", t, i, s, l = !1, c = document) => {
1048
+ }), p;
1049
+ }, gn = (e, n = {}, o = "https://api.userleap.com", t, r, s, l = !1, c = document) => {
1052
1050
  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();
1051
+ const i = e + De, p = _e(i);
1052
+ return a.document.addEventListener("securitypolicyviolation", (h) => {
1053
+ $(new Error(`Voice & Video feature violates ${h.violatedDirective} web page CSP policies for the recorder player.`), "recorderDeviceError", o, s, n.visitorId, n.envId);
1054
+ }), Te(ke.concat(Je), () => {
1055
+ ae(i, p), a.document.getElementById(ce(i)).remove();
1058
1056
  try {
1059
- en(u, r, n, o, t, i, s, l);
1060
- } catch (m) {
1061
- return void F(new Error(`Error when creating video recorder player object ${m}`), "recorderDeviceError", o, s, n.visitorId, n.envId);
1057
+ Qe(p, i, n, o, t, r, s, l);
1058
+ } catch (h) {
1059
+ return void $(new Error(`Error when creating video recorder player object ${h}`), "recorderDeviceError", o, s, n.visitorId, n.envId);
1062
1060
  }
1063
- }), u;
1064
- }, Cn = (e) => {
1061
+ }), p;
1062
+ }, bn = (e) => {
1065
1063
  const n = e + De;
1066
1064
  if (a.document.getElementById(n) && a.videojs) {
1067
1065
  try {
@@ -1071,33 +1069,31 @@ const z = async ({ event: e, apiBase: n, headers: o, visitorId: t, envId: i, met
1071
1069
  }
1072
1070
  a.videojs(n).record().stop(), a.videojs(n).record().stopDevice();
1073
1071
  }
1074
- }, wn = (e) => {
1075
- const n = ee(e + Ie);
1072
+ }, fn = (e) => {
1073
+ const n = oe(e + Ie);
1076
1074
  n == null || n.pause();
1077
- }, on = (e) => {
1075
+ }, en = (e) => {
1078
1076
  if (!e) return null;
1079
1077
  const n = e.match(/https:\/\/stream.mux.com\/(.*)/);
1080
1078
  let o = n ? n[1] : null;
1081
1079
  return o.includes(ge) && (o = o.replace(ge, "")), o ? `https://image.mux.com/${o}/thumbnail.jpg?time=0` : null;
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" };
1080
+ }, 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" }, P = { PlaybackRateMenuButton: "Speed", PlayToggle: "Play", FullscreenToggle: "Expand", TurnOnCamera: "Turn on", TurnOffCamera: "Turn off", DeleteButton: "Delete", RecordButton: "Record", StopButton: "Stop", PauseButton: "Pause" };
1083
1081
  export {
1084
- Fe as B,
1082
+ Ne as B,
1085
1083
  $e as H,
1086
- dn as L,
1087
- cn as M,
1088
- un as O,
1089
- We as P,
1090
- vn as Q,
1084
+ ln as L,
1085
+ dn as M,
1086
+ cn as O,
1087
+ un as Q,
1091
1088
  x as R,
1092
- hn as S,
1089
+ vn as S,
1093
1090
  pn as a,
1094
- Ye as b,
1095
- an as c,
1096
- fn as d,
1097
- mn as e,
1098
- gn as g,
1099
- wn as p,
1100
- Cn as s,
1091
+ sn as b,
1092
+ gn as c,
1093
+ an as d,
1094
+ hn as g,
1095
+ fn as p,
1096
+ bn as s,
1101
1097
  ze as u,
1102
- bn as v
1098
+ mn as v
1103
1099
  };