@sprig-technologies/sprig-browser 2.39.3 → 2.39.4

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