@magicfeedback/popup-sdk 1.17.2 → 1.18.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.
@@ -6,6 +6,7 @@ import {
6
6
  buildFontFaceCss,
7
7
  buildFontFamilyValue,
8
8
  buildSurveyIdentity,
9
+ classifySubmitError,
9
10
  directionFor,
10
11
  getLabels,
11
12
  resolveActionLabels,
@@ -15,7 +16,7 @@ import {
15
16
  sdkWarn,
16
17
  setSurveyBusy,
17
18
  style_default
18
- } from "./chunk-AFRHPS3K.mjs";
19
+ } from "./chunk-DNBFTJCA.mjs";
19
20
 
20
21
  // node_modules/@magicfeedback/native/dist/magicfeedback-sdk.browser.js
21
22
  var require_magicfeedback_sdk_browser = __commonJS({
@@ -640,7 +641,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
640
641
  }));
641
642
  };
642
643
  Object.defineProperty(t2, "__esModule", { value: true }), t2.Form = void 0;
643
- const r = i(4760), o = i(7490), a = i(4070), s = i(9071), l = i(7643), d = i(8129), c = i(2335), u = i(5349), p = i(1719), m = i(3378), h = i(7305), f = i(9481), g = i(7170), y = i(7627), v = i(3433), b = i(9089), E = i(4069), A = i(9039), k = [r.FEEDBACKAPPANSWERTYPE.INFO_PAGE, r.FEEDBACKAPPANSWERTYPE.PASSWORD, r.FEEDBACKAPPANSWERTYPE.EMAIL, r.FEEDBACKAPPANSWERTYPE.CONTACT, r.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE, r.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE, r.FEEDBACKAPPANSWERTYPE.MAX_DIFF];
644
+ const r = i(4760), o = i(7490), a = i(4070), s = i(9071), l = i(7643), d = i(8129), c = i(2335), u = i(5349), p = i(1719), m = i(3378), h = i(7305), f = i(9481), g = i(7170), y = i(7627), v = i(3433), b = i(9089), E = i(4069), A = i(9039), k = i(1012), T = [r.FEEDBACKAPPANSWERTYPE.INFO_PAGE, r.FEEDBACKAPPANSWERTYPE.PASSWORD, r.FEEDBACKAPPANSWERTYPE.EMAIL, r.FEEDBACKAPPANSWERTYPE.CONTACT, r.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE, r.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE, r.FEEDBACKAPPANSWERTYPE.MAX_DIFF];
644
645
  t2.Form = class {
645
646
  constructor(e3, t3, i2, n2, r2) {
646
647
  this.urlAutoAdvanceChecked = false, this.config = e3, this.log = new a.Log(e3), this.formOptionsConfig = { addButton: true, addSuccessScreen: true, getMetaData: true, customMetaData: [], questionFormat: "standard" }, this.selector = "", this.appId = t3, this.publicKey = i2 || "", this.url = e3.get("url"), this.id = "", this.formData = null, this.activeLang = null, this.feedback = { text: "", answers: [], profile: null != n2 ? n2 : [], metrics: [], metadata: null != r2 ? r2 : [] }, this.history = new f.History(), this.agentForm = null, this.graph = new p.PageGraph([]), this.progress = 0, this.total = 0, this.completed = false, this.sending = false, this.timeToCompleted = 0;
@@ -729,17 +730,17 @@ var require_magicfeedback_sdk_browser = __commonJS({
729
730
  }
730
731
  this.formOptionsConfig.addButton && o2.addEventListener("submit", ((e4) => {
731
732
  e4.preventDefault(), this.send();
732
- })), this.timeToCompleted = Date.now(), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, progress: this.progress, total: this.total, formData: this.formData, lang: this.lang(), formOptionsConfig: this.formOptionsConfig })), this.autofocusAfterRender(e3), this.autoAdvanceFromUrl(a2, s2);
733
+ })), this.timeToCompleted = Date.now();
734
+ const d2 = this.autoAdvanceFromUrl(a2, s2);
735
+ if (d2 && (a2.style.visibility = "hidden"), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: d2, autoAdvancing: d2, progress: this.progress, total: this.total, formData: this.formData, lang: this.lang(), formOptionsConfig: this.formOptionsConfig })), d2) return void (yield this.autoSend());
736
+ this.autofocusAfterRender(e3);
733
737
  } catch (e4) {
734
738
  return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 }));
735
739
  }
736
740
  }));
737
741
  }
738
742
  autoAdvanceFromUrl(e3, t3) {
739
- if (this.urlAutoAdvanceChecked) return;
740
- if (this.urlAutoAdvanceChecked = true, !(0, A.autoAdvanceRequested)() || 1 !== t3.questions.length) return;
741
- const i2 = (0, A.answeredInput)(e3, t3.questions[0].ref);
742
- i2 && (0, A.scheduleAutoAdvance)(i2, (() => this.autoSend()));
743
+ return !(this.urlAutoAdvanceChecked || (this.urlAutoAdvanceChecked = true, !(0, A.autoAdvanceRequested)() || 1 !== t3.questions.length || !(0, A.answeredInput)(e3, t3.questions[0].ref)));
743
744
  }
744
745
  startForm() {
745
746
  this.agentForm ? this.agentForm.startForm() : this.generateForm("navigation");
@@ -791,42 +792,42 @@ var require_magicfeedback_sdk_browser = __commonJS({
791
792
  if (i2 && (this.feedback.profile = [...this.feedback.profile, ...i2]), t3 && (this.feedback.metrics = [...this.feedback.metrics, ...t3]), e3 && (this.feedback.metadata = [...this.feedback.metadata, ...e3]), o2) {
792
793
  this.feedback.answers = [...this.feedback.answers, ...o2], this.formOptionsConfig.beforeSubmitEvent && (yield this.formOptionsConfig.beforeSubmitEvent({ loading: true, progress: this.progress, total: this.total }));
793
794
  const e4 = yield this.pushAnswers(false);
794
- if (!e4) throw new Error("No response");
795
+ if (!e4) throw new k.SubmitError("SEND_FAILED", "No response");
795
796
  return this.id = e4, void (this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total })));
796
797
  }
797
798
  yield (0, d.awaitUploadReady)(n2), this.answer(), this.formOptionsConfig.beforeSubmitEvent && (yield this.formOptionsConfig.beforeSubmitEvent({ loading: true, progress: this.progress, total: this.total }));
798
799
  const l2 = this.history.back();
799
- if (!l2) throw new Error("No page found");
800
+ if (!l2) throw new k.SubmitError("NO_PAGE", "No page found");
800
801
  for (const e4 of l2.questions.filter(((e5) => e5.require && ![r.FEEDBACKAPPANSWERTYPE.CONSENT, r.FEEDBACKAPPANSWERTYPE.INFO_PAGE].includes(e5.type)))) {
801
802
  const t4 = e4.assets, i3 = this.feedback.answers.filter(((t5) => t5.key.includes(e4.ref) && !t5.key.includes("extra-option")));
802
- if (0 === i3.length || i3.find(((e5) => 0 === e5.value.length))) throw this.log.err(`The question ${e4.ref} is required`), new Error("No response");
803
+ if (0 === i3.length || i3.find(((e5) => 0 === e5.value.length))) throw this.log.err(`The question ${e4.ref} is required`), new k.SubmitError("REQUIRED", "No response");
803
804
  if (null == t4 ? void 0 : t4.minOptions) {
804
805
  let n3 = [];
805
- if ((null == t4 ? void 0 : t4.exclusiveAnswers) && (n3 = null == t4 ? void 0 : t4.exclusiveAnswers), !i3[0].value.find(((e5) => n3.includes(e5))) && i3[0].value.length < (null == t4 ? void 0 : t4.minOptions)) throw this.log.err(`The question ${e4.ref} requires at least ${null == t4 ? void 0 : t4.minOptions} options`), new Error("No response");
806
+ if ((null == t4 ? void 0 : t4.exclusiveAnswers) && (n3 = null == t4 ? void 0 : t4.exclusiveAnswers), !i3[0].value.find(((e5) => n3.includes(e5))) && i3[0].value.length < (null == t4 ? void 0 : t4.minOptions)) throw this.log.err(`The question ${e4.ref} requires at least ${null == t4 ? void 0 : t4.minOptions} options`), new k.SubmitError("REQUIRED", "No response");
806
807
  }
807
808
  if (e4.type === r.FEEDBACKAPPANSWERTYPE.MAX_DIFF) {
808
809
  const t5 = null !== (s2 = null === (a2 = e4.assets) || void 0 === a2 ? void 0 : a2.setIndex) && void 0 !== s2 ? s2 : 1, i4 = this.parseMaxDiffAnswer(this.feedback.answers.find(((t6) => t6.key === e4.ref))).find(((e5) => e5.set === t5));
809
- if (!(null == i4 ? void 0 : i4.best) || !(null == i4 ? void 0 : i4.worst)) throw this.log.err(`The MaxDiff question ${e4.ref} requires the most and the least important`), new Error("No response");
810
+ if (!(null == i4 ? void 0 : i4.best) || !(null == i4 ? void 0 : i4.worst)) throw this.log.err(`The MaxDiff question ${e4.ref} requires the most and the least important`), new k.SubmitError("REQUIRED", "No response");
810
811
  }
811
812
  if (e4.type === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) {
812
813
  const i4 = this.feedback.answers.find(((t5) => t5.key === e4.ref));
813
- if (!i4) throw this.log.err(`The matrix question ${e4.ref} is required`), new Error("No response");
814
+ if (!i4) throw this.log.err(`The matrix question ${e4.ref} is required`), new k.SubmitError("REQUIRED", "No response");
814
815
  const n3 = this.parseMatrixAnswerPre(i4), r2 = Array.isArray(null == t4 ? void 0 : t4.options) ? t4.options : [];
815
816
  if (r2.length > 0) {
816
817
  if (r2.find(((e5) => {
817
818
  const t5 = n3.find(((t6) => t6.key === e5));
818
819
  return !t5 || !Array.isArray(t5.value) || 0 === t5.value.length;
819
- }))) throw this.log.err(`The matrix question ${e4.ref} requires an answer in every row`), new Error("No response");
820
- } else if (0 === n3.length || n3.some(((e5) => !Array.isArray(e5.value) || 0 === e5.value.length))) throw this.log.err(`The matrix question ${e4.ref} requires an answer in every row`), new Error("No response");
820
+ }))) throw this.log.err(`The matrix question ${e4.ref} requires an answer in every row`), new k.SubmitError("REQUIRED", "No response");
821
+ } else if (0 === n3.length || n3.some(((e5) => !Array.isArray(e5.value) || 0 === e5.value.length))) throw this.log.err(`The matrix question ${e4.ref} requires an answer in every row`), new k.SubmitError("REQUIRED", "No response");
821
822
  }
822
823
  }
823
824
  const c2 = yield this.pushAnswers(false);
824
- if (!c2) throw new Error("No response");
825
+ if (!c2) throw new k.SubmitError("SEND_FAILED", "No response");
825
826
  this.id = c2, yield this.processNextQuestion(n2);
826
827
  } catch (e4) {
827
828
  this.log.err(`An error occurred while submitting the form ${this.appId}:`, e4), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total, error: e4 }));
828
829
  } finally {
829
- this.sending = false;
830
+ this.sending = false, null == n2 || n2.style.removeProperty("visibility");
830
831
  }
831
832
  }));
832
833
  }
@@ -959,7 +960,10 @@ var require_magicfeedback_sdk_browser = __commonJS({
959
960
  this.feedback.answers = [];
960
961
  try {
961
962
  const e3 = yield this.pushAnswers(true);
962
- if (!e3) throw this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total, completed: this.completed, error: `An error occurred while submitting the form ${this.appId}:` })), new Error("An error occurred while submitting the form ${this.appId}:");
963
+ if (!e3) {
964
+ const e4 = new k.SubmitError("SEND_FAILED", `An error occurred while submitting the form ${this.appId}:`);
965
+ throw this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total, completed: this.completed, error: e4 })), e4;
966
+ }
963
967
  this.id = e3, this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.id, loading: false, progress: this.progress, total: this.total, completed: this.completed, error: null }));
964
968
  } catch (e3) {
965
969
  this.log.err(`An error occurred while submitting the form ${this.appId}:`, e3), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total, completed: this.completed, error: e3 }));
@@ -1001,7 +1005,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
1001
1005
  const r2 = this.history.get(n2);
1002
1006
  if (r2) for (const n3 of r2.questions) {
1003
1007
  if (n3.ref === e3.ref) continue;
1004
- if (k.includes(n3.type)) continue;
1008
+ if (T.includes(n3.type)) continue;
1005
1009
  const o2 = this.followUpAnswerValue(n3, null === (t3 = r2.answers) || void 0 === t3 ? void 0 : t3.find(((e4) => e4.key === n3.ref)));
1006
1010
  void 0 !== o2 && (i2.delete(n3.ref), i2.set(n3.ref, { title: n3.title, answer: o2 }));
1007
1011
  }
@@ -1050,7 +1054,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
1050
1054
  var t3, i2;
1051
1055
  return n(this, void 0, void 0, (function* () {
1052
1056
  const n2 = this.history.back();
1053
- if (!n2) throw new Error("No page found");
1057
+ if (!n2) throw new k.SubmitError("NO_PAGE", "No page found");
1054
1058
  const r2 = n2.isFollowup ? [] : n2.getFollowupQuestions();
1055
1059
  if (0 === (null == r2 ? void 0 : r2.length)) return void (yield this.renderNextQuestion(e3, n2));
1056
1060
  const o2 = [];
@@ -1422,7 +1426,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
1422
1426
  };
1423
1427
  }, 2709: (e2, t2, i) => {
1424
1428
  "use strict";
1425
- Object.defineProperty(t2, "__esModule", { value: true }), t2.RATING_NUMBER_MIN_CHIP_WIDTH = t2.usesLegacyRatingNumber = t2.createRatingNumberElement = t2.createStarRating = t2.createRatingPlaceholder = void 0;
1429
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.RATING_NUMBER_MIN_CAPTIONED_WIDTH = t2.RATING_NUMBER_MIN_CHIP_WIDTH = t2.usesLegacyRatingNumber = t2.createRatingNumberElement = t2.createStarRating = t2.createRatingPlaceholder = void 0;
1426
1430
  const n = i(7627), r = i(9039);
1427
1431
  function o(e3, t3, i2 = "ltr") {
1428
1432
  const n2 = document.createElement("div");
@@ -1471,22 +1475,23 @@ var require_magicfeedback_sdk_browser = __commonJS({
1471
1475
  E.classList.add("magicfeedback-rating-number-container"), E.classList.add(`magicfeedback-rating-number-container-${o2}`), E.classList.add(`magicfeedback-rating-number-container-${a}`), E.style.display = "flex", E.style.flexDirection = b, E.setAttribute("role", "radiogroup"), E.setAttribute("aria-label", (null == i2 ? void 0 : i2.ariaLabel) || (0, n.t)(c, "rating.ariaLabel"));
1472
1476
  const A = (null == i2 ? void 0 : i2.max) ? Number(null == i2 ? void 0 : i2.max) : 10, k = (null == i2 ? void 0 : i2.min) ? Number(null == i2 ? void 0 : i2.min) : 0;
1473
1477
  !v && A - k + 1 > 6 && E.classList.add("magicfeedback-rating-number-container-row--dense");
1474
- const T = (null == i2 ? void 0 : i2.numberPlaceholders) || null, C = !(!T || !Object.keys(T).length);
1475
- let P = null;
1476
- if (!v && ((null == i2 ? void 0 : i2.minPlaceholder) || (null == i2 ? void 0 : i2.maxPlaceholder))) {
1477
- P = document.createElement("div"), P.classList.add("magicfeedback-rating-number-scale-labels");
1478
+ const T = (null == i2 ? void 0 : i2.numberPlaceholders) || null, C = !(!T || !Object.keys(T).length), P = !v && !f && !!T && Object.values(T).some(((e4) => !!e4)), S = "bottom" === (null == i2 ? void 0 : i2.numberPlaceholdersPosition) ? "bottom" : "top";
1479
+ P && (E.style.alignItems = "stretch");
1480
+ let w = null;
1481
+ if (!v && !P && ((null == i2 ? void 0 : i2.minPlaceholder) || (null == i2 ? void 0 : i2.maxPlaceholder))) {
1482
+ w = document.createElement("div"), w.classList.add("magicfeedback-rating-number-scale-labels");
1478
1483
  const e4 = document.createElement("span");
1479
1484
  e4.classList.add("magicfeedback-rating-number-scale-label"), e4.textContent = null !== (p = null == i2 ? void 0 : i2.minPlaceholder) && void 0 !== p ? p : "";
1480
1485
  const t3 = document.createElement("span");
1481
- t3.classList.add("magicfeedback-rating-number-scale-label"), t3.textContent = null !== (m = null == i2 ? void 0 : i2.maxPlaceholder) && void 0 !== m ? m : "", "ltr" === o2 ? (P.appendChild(e4), P.appendChild(t3)) : (P.appendChild(t3), P.appendChild(e4));
1486
+ t3.classList.add("magicfeedback-rating-number-scale-label"), t3.textContent = null !== (m = null == i2 ? void 0 : i2.maxPlaceholder) && void 0 !== m ? m : "", "ltr" === o2 ? (w.appendChild(e4), w.appendChild(t3)) : (w.appendChild(t3), w.appendChild(e4));
1482
1487
  }
1483
- let w = null;
1484
- if (v && !C && E.classList.add("magicfeedback-rating-number-container-column--bare"), (!v || !C) && ((null == i2 ? void 0 : i2.minPlaceholder) || (null == i2 ? void 0 : i2.maxPlaceholder))) {
1488
+ let O = null;
1489
+ if (v && !C && E.classList.add("magicfeedback-rating-number-container-column--bare"), (v ? !C : !P) && ((null == i2 ? void 0 : i2.minPlaceholder) || (null == i2 ? void 0 : i2.maxPlaceholder))) {
1485
1490
  const e4 = "ltr" === o2 ? null == i2 ? void 0 : i2.minPlaceholder : null == i2 ? void 0 : i2.maxPlaceholder, t3 = "ltr" === o2 ? null == i2 ? void 0 : i2.maxPlaceholder : null == i2 ? void 0 : i2.minPlaceholder, n2 = (e5) => {
1486
1491
  const t4 = document.createElement("div");
1487
1492
  return t4.classList.add("magicfeedback-rating-number-scale-label-block"), v || (t4.classList.add("magicfeedback-rating-number-scale-label-block--stacked"), t4.style.display = "none"), t4.textContent = e5, t4;
1488
1493
  };
1489
- e4 && h.appendChild(n2(e4)), t3 && (w = n2(t3));
1494
+ e4 && h.appendChild(n2(e4)), t3 && (O = n2(t3));
1490
1495
  }
1491
1496
  for (let t3 = k; t3 <= A; t3++) {
1492
1497
  const n2 = document.createElement("div");
@@ -1500,37 +1505,47 @@ var require_magicfeedback_sdk_browser = __commonJS({
1500
1505
  const m2 = document.createElement("span");
1501
1506
  m2.classList.add("magicfeedback-rating-number-value");
1502
1507
  const h2 = document.createElement("span");
1503
- if (h2.textContent = p2 ? `${t3} = ${p2}` : t3.toString(), h2.classList.add("magicfeedback-rating-number-value-num"), f && (h2.style.fontWeight = "normal"), m2.appendChild(h2), v) {
1504
- if (c2) {
1505
- const e4 = document.createElement("span");
1506
- e4.textContent = c2, e4.classList.add("magicfeedback-rating-number-value-label"), m2.appendChild(e4);
1507
- }
1508
- } else T && T[t3] && (o3.title = T[t3]);
1509
- o3.appendChild(m2), n2.appendChild(o3), E.appendChild(n2);
1508
+ if (h2.textContent = p2 ? `${t3} = ${p2}` : t3.toString(), h2.classList.add("magicfeedback-rating-number-value-num"), f && (h2.style.fontWeight = "normal"), m2.appendChild(h2), (v || P) && c2) {
1509
+ const e4 = document.createElement("span");
1510
+ e4.textContent = c2, e4.classList.add("magicfeedback-rating-number-value-label"), v || (e4.style.display = "none"), m2.appendChild(e4);
1511
+ } else !v && !P && T && T[t3] && (o3.title = T[t3]);
1512
+ if (o3.appendChild(m2), P) {
1513
+ const e4 = document.createElement("label");
1514
+ e4.htmlFor = u2.id, e4.classList.add("magicfeedback-rating-number-option-caption"), e4.textContent = c2 || "", n2.classList.add("magicfeedback-rating-number-option--captioned"), n2.classList.add(`magicfeedback-rating-number-option--caption-${S}`), n2.style.flexDirection = "top" === S ? "column" : "column-reverse", n2.style.justifyContent = "flex-end", n2.appendChild(e4);
1515
+ }
1516
+ n2.appendChild(o3), E.appendChild(n2);
1517
+ }
1518
+ if (h.appendChild(E), O && h.appendChild(O), w) {
1519
+ const e4 = null == i2 ? void 0 : i2.minMaxPlaceholderPosition;
1520
+ "top" !== e4 && "bottom" !== e4 || (w.classList.add(`magicfeedback-rating-number-scale-labels--${e4}`), w.style.order = "top" === e4 ? "-1" : "1"), "top" === e4 ? h.insertBefore(w, E) : h.appendChild(w);
1510
1521
  }
1511
- if (h.appendChild(E), w && h.appendChild(w), P && h.appendChild(P), v || f || (function(e4, i3, n2, r2) {
1522
+ if (v || f || (function(e4, i3, n2, r2, o3 = t2.RATING_NUMBER_MIN_CHIP_WIDTH) {
1512
1523
  if ("undefined" == typeof ResizeObserver) return;
1513
- const o3 = i3.classList.contains("magicfeedback-rating-number-container-row--dense");
1514
- let a2 = 0, s2 = false;
1515
- const l2 = "function" == typeof requestAnimationFrame ? requestAnimationFrame : (e5) => (e5(0), 0);
1516
- let d2 = 0, c2 = false;
1517
- new ResizeObserver(((u2) => {
1518
- var p2;
1519
- const m2 = null === (p2 = u2[0]) || void 0 === p2 ? void 0 : p2.contentRect.width;
1520
- m2 && m2 !== d2 && (d2 = m2, c2 || (c2 = true, l2((() => {
1521
- c2 = false, s2 || (a2 = parseFloat(getComputedStyle(i3).columnGap) || 0);
1522
- const l3 = n2 * t2.RATING_NUMBER_MIN_CHIP_WIDTH + (n2 - 1) * a2;
1523
- var u3;
1524
- (u3 = d2 < l3) !== s2 && (s2 = u3, e4.classList.toggle("magicfeedback-rating-number--stacked", u3), e4.querySelectorAll(":scope > .magicfeedback-rating-number-scale-labels").forEach(((e5) => {
1525
- e5.style.display = u3 ? "none" : "";
1524
+ const a2 = i3.classList.contains("magicfeedback-rating-number-container-row--dense"), s2 = !!i3.querySelector(".magicfeedback-rating-number-option--captioned");
1525
+ let l2 = 0, d2 = false;
1526
+ const c2 = "function" == typeof requestAnimationFrame ? requestAnimationFrame : (e5) => (e5(0), 0);
1527
+ let u2 = 0, p2 = false;
1528
+ new ResizeObserver(((t3) => {
1529
+ var m2;
1530
+ const h2 = null === (m2 = t3[0]) || void 0 === m2 ? void 0 : m2.contentRect.width;
1531
+ h2 && h2 !== u2 && (u2 = h2, p2 || (p2 = true, c2((() => {
1532
+ var t4;
1533
+ p2 = false, d2 || (l2 = parseFloat(getComputedStyle(i3).columnGap) || 0), (t4 = u2 < n2 * o3 + (n2 - 1) * l2) !== d2 && (d2 = t4, e4.classList.toggle("magicfeedback-rating-number--stacked", t4), e4.querySelectorAll(":scope > .magicfeedback-rating-number-scale-labels").forEach(((e5) => {
1534
+ e5.style.display = t4 ? "none" : "";
1526
1535
  })), e4.querySelectorAll(":scope > .magicfeedback-rating-number-scale-label-block--stacked").forEach(((e5) => {
1527
- e5.style.display = u3 ? "" : "none";
1528
- })), i3.classList.toggle("magicfeedback-rating-number-container-row", !u3), i3.classList.toggle("magicfeedback-rating-number-container-row--dense", !u3 && o3), i3.classList.toggle("magicfeedback-rating-number-container-column", u3), i3.classList.toggle("magicfeedback-rating-number-container-column--bare", u3), i3.style.flexDirection = u3 ? "ltr" === r2 ? "column" : "column-reverse" : "ltr" === r2 ? "row" : "row-reverse", i3.querySelectorAll(":scope > .magicfeedback-rating-number-option").forEach(((e5) => {
1529
- e5.classList.toggle("magicfeedback-rating-number-option-row", !u3), e5.classList.toggle("magicfeedback-rating-number-option-column", u3);
1536
+ e5.style.display = t4 ? "" : "none";
1537
+ })), i3.classList.toggle("magicfeedback-rating-number-container-row", !t4), i3.classList.toggle("magicfeedback-rating-number-container-row--dense", !t4 && a2), i3.classList.toggle("magicfeedback-rating-number-container-column", t4), i3.classList.toggle("magicfeedback-rating-number-container-column--bare", t4 && !s2), i3.style.flexDirection = t4 ? "ltr" === r2 ? "column" : "column-reverse" : "ltr" === r2 ? "row" : "row-reverse", i3.querySelectorAll(":scope > .magicfeedback-rating-number-option").forEach(((e5) => {
1538
+ if (e5.classList.toggle("magicfeedback-rating-number-option-row", !t4), e5.classList.toggle("magicfeedback-rating-number-option-column", t4), !e5.classList.contains("magicfeedback-rating-number-option--captioned")) return;
1539
+ const i4 = e5.classList.contains("magicfeedback-rating-number-option--caption-top");
1540
+ e5.style.flexDirection = t4 ? "" : i4 ? "column" : "column-reverse", e5.querySelectorAll(".magicfeedback-rating-number-option-caption").forEach(((e6) => {
1541
+ e6.style.display = t4 ? "none" : "";
1542
+ })), e5.querySelectorAll(".magicfeedback-rating-number-value-label").forEach(((e6) => {
1543
+ e6.style.display = t4 ? "" : "none";
1544
+ }));
1530
1545
  })));
1531
1546
  }))));
1532
1547
  })).observe(e4);
1533
- })(h, E, A - k + 1, o2), (null == i2 ? void 0 : i2.extraOption) && (null == i2 ? void 0 : i2.extraOptionText)) {
1548
+ })(h, E, A - k + 1, o2, P ? t2.RATING_NUMBER_MIN_CAPTIONED_WIDTH : t2.RATING_NUMBER_MIN_CHIP_WIDTH), (null == i2 ? void 0 : i2.extraOption) && (null == i2 ? void 0 : i2.extraOptionText)) {
1534
1549
  const t3 = document.createElement("div");
1535
1550
  t3.classList.add("magicfeedback-rating-number-extra-row");
1536
1551
  const n2 = document.createElement("div");
@@ -1547,7 +1562,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
1547
1562
  return h;
1548
1563
  }, t2.usesLegacyRatingNumber = function(e3) {
1549
1564
  return !!e3 && /matas/i.test(e3);
1550
- }, t2.RATING_NUMBER_MIN_CHIP_WIDTH = 44;
1565
+ }, t2.RATING_NUMBER_MIN_CHIP_WIDTH = 44, t2.RATING_NUMBER_MIN_CAPTIONED_WIDTH = 72;
1551
1566
  }, 368: (e2, t2, i) => {
1552
1567
  "use strict";
1553
1568
  Object.defineProperty(t2, "__esModule", { value: true }), t2.getQuestionRenderer = void 0;
@@ -1572,36 +1587,51 @@ var require_magicfeedback_sdk_browser = __commonJS({
1572
1587
  };
1573
1588
  }, 620: (e2, t2, i) => {
1574
1589
  "use strict";
1575
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderChoice = void 0;
1590
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.CHOICE_ROW_MIN_OPTION_WIDTH = t2.renderChoice = void 0;
1576
1591
  const n = i(4760), r = i(3262), o = i(9039);
1577
- t2.renderChoice = ({ question: e3, language: t3, urlParamValue: i2, randomPosition: a, send: s }) => {
1578
- const { type: l, ref: d, value: c, defaultValue: u, assets: p } = e3, m = document.createElement("div"), h = "magicfeedback-" + ("MULTIPLECHOICE" === l ? "checkbox" : "radio");
1579
- let f = c || [];
1580
- a && (f = f.sort((() => Math.random() - 0.5)));
1581
- let g = (null == p ? void 0 : p.exclusiveAnswers) || [];
1582
- (null == p ? void 0 : p.extraOption) && (g = g.filter(((e4) => e4 !== p.extraOptionText))), g.length > 0 && (null == g || g.forEach(((e4) => {
1583
- f.includes(e4) || f.push(e4);
1592
+ t2.renderChoice = ({ question: e3, language: i2, urlParamValue: s, randomPosition: l, send: d }) => {
1593
+ const { type: c, ref: u, value: p, defaultValue: m, assets: h } = e3, f = document.createElement("div"), g = "magicfeedback-" + ("MULTIPLECHOICE" === c ? "checkbox" : "radio");
1594
+ let y = p || [];
1595
+ l && (y = y.sort((() => Math.random() - 0.5)));
1596
+ let v = (null == h ? void 0 : h.exclusiveAnswers) || [];
1597
+ (null == h ? void 0 : h.extraOption) && (v = v.filter(((e4) => e4 !== h.extraOptionText))), v.length > 0 && (null == v || v.forEach(((e4) => {
1598
+ y.includes(e4) || y.push(e4);
1584
1599
  })));
1585
- const y = null == p ? void 0 : p.extraOptionText;
1586
- return (null == p ? void 0 : p.extraOption) && y && !f.includes(y) && f.push(y), f.forEach(((e4, a2) => {
1587
- const c2 = document.createElement("div");
1588
- c2.classList.add(`magicfeedback-${"MULTIPLECHOICE" === l ? "checkbox" : "radio"}-container`);
1589
- const y2 = document.createElement("label"), v = document.createElement("input");
1590
- if (v.id = `rating-${d}-${a2}`, v.type = "MULTIPLECHOICE" === l ? "checkbox" : "radio", v.name = d, v.value = e4, v.classList.add(h), v.classList.add("magicfeedback-input"), l === n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE && (null == p ? void 0 : p.maxOptions) && (null == p ? void 0 : p.maxOptions) > 0 && v.addEventListener("change", (() => {
1591
- document.querySelectorAll(`input[name="${d}"]:checked`).length > (null == p ? void 0 : p.maxOptions) && (v.checked = false);
1592
- })), l === n.FEEDBACKAPPANSWERTYPE.RADIO && s && (!(null == p ? void 0 : p.extraOptionText) || (null == p ? void 0 : p.extraOptionText) && e4 !== (null == p ? void 0 : p.extraOptionText)) && (0, o.autoAdvanceOn)(v, s), e4 !== u && e4 !== i2 || (v.checked = true), y2.textContent = e4, y2.htmlFor = `rating-${d}-${a2}`, v.addEventListener("change", ((t4) => {
1593
- const i3 = document.getElementById(`extra-option-${d}`);
1594
- t4.target.checked && g.includes(e4) ? (f.forEach(((t5) => {
1600
+ const b = null == h ? void 0 : h.extraOptionText;
1601
+ return (null == h ? void 0 : h.extraOption) && b && !y.includes(b) && y.push(b), y.forEach(((e4, t3) => {
1602
+ const a2 = document.createElement("div");
1603
+ a2.classList.add(`magicfeedback-${"MULTIPLECHOICE" === c ? "checkbox" : "radio"}-container`);
1604
+ const l2 = document.createElement("label"), p2 = document.createElement("input");
1605
+ if (p2.id = `rating-${u}-${t3}`, p2.type = "MULTIPLECHOICE" === c ? "checkbox" : "radio", p2.name = u, p2.value = e4, p2.classList.add(g), p2.classList.add("magicfeedback-input"), c === n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE && (null == h ? void 0 : h.maxOptions) && (null == h ? void 0 : h.maxOptions) > 0 && p2.addEventListener("change", (() => {
1606
+ document.querySelectorAll(`input[name="${u}"]:checked`).length > (null == h ? void 0 : h.maxOptions) && (p2.checked = false);
1607
+ })), c === n.FEEDBACKAPPANSWERTYPE.RADIO && d && (!(null == h ? void 0 : h.extraOptionText) || (null == h ? void 0 : h.extraOptionText) && e4 !== (null == h ? void 0 : h.extraOptionText)) && (0, o.autoAdvanceOn)(p2, d), e4 !== m && e4 !== s || (p2.checked = true), l2.textContent = e4, l2.htmlFor = `rating-${u}-${t3}`, p2.addEventListener("change", ((t4) => {
1608
+ const i3 = document.getElementById(`extra-option-${u}`);
1609
+ t4.target.checked && v.includes(e4) ? (y.forEach(((t5) => {
1595
1610
  t5 !== e4 && (document.querySelector(`input[value="${t5}"]`).checked = false);
1596
- })), i3 && (i3.style.display = "none")) : g.forEach(((t5) => {
1611
+ })), i3 && (i3.style.display = "none")) : v.forEach(((t5) => {
1597
1612
  t5 !== e4 && (document.querySelector(`input[value="${t5}"]`).checked = false);
1598
- })), (null == p ? void 0 : p.extraOption) && e4 === (null == p ? void 0 : p.extraOptionText) && i3 && (i3.style.display = t4.target.checked ? "block" : "none");
1599
- })), c2.appendChild(v), c2.appendChild(y2), m.appendChild(c2), (null == p ? void 0 : p.extraOption) && e4 === (null == p ? void 0 : p.extraOptionText)) {
1613
+ })), (null == h ? void 0 : h.extraOption) && e4 === (null == h ? void 0 : h.extraOptionText) && i3 && (i3.style.display = t4.target.checked ? "block" : "none");
1614
+ })), a2.appendChild(p2), a2.appendChild(l2), f.appendChild(a2), (null == h ? void 0 : h.extraOption) && e4 === (null == h ? void 0 : h.extraOptionText)) {
1600
1615
  const e5 = document.createElement("input");
1601
- e5.type = "text", e5.placeholder = (null == p ? void 0 : p.extraOptionPlaceholder) || r.placeholder.answer(t3 || "en"), e5.classList.add("magicfeedback-extra-option"), e5.classList.add("magicfeedback-input"), e5.id = `extra-option-${d}`, e5.name = `extra-option-${d}`, e5.style.display = "none", m.appendChild(e5);
1602
- }
1603
- })), { element: m, elementTypeClass: h };
1604
- };
1616
+ e5.type = "text", e5.placeholder = (null == h ? void 0 : h.extraOptionPlaceholder) || r.placeholder.answer(i2 || "en"), e5.classList.add("magicfeedback-extra-option"), e5.classList.add("magicfeedback-input"), e5.id = `extra-option-${u}`, e5.name = `extra-option-${u}`, e5.style.display = "none", f.appendChild(e5);
1617
+ }
1618
+ })), c === n.FEEDBACKAPPANSWERTYPE.RADIO && "row" === (null == h ? void 0 : h.direction) && (f.classList.add("magicfeedback-radio--row"), (function(e4, i3) {
1619
+ if (e4.classList.toggle("magicfeedback-radio--stacked", window.innerWidth < a), "undefined" == typeof ResizeObserver) return;
1620
+ const n2 = "function" == typeof requestAnimationFrame ? requestAnimationFrame : (e5) => (e5(0), 0);
1621
+ let r2 = 0, o2 = false;
1622
+ new ResizeObserver(((s2) => {
1623
+ var l2;
1624
+ const d2 = null === (l2 = s2[0]) || void 0 === l2 ? void 0 : l2.contentRect.width;
1625
+ d2 && d2 !== r2 && (r2 = d2, o2 || (o2 = true, n2((() => {
1626
+ o2 = false, ((n3) => {
1627
+ const r3 = parseFloat(getComputedStyle(e4).columnGap) || 0, o3 = i3 * t2.CHOICE_ROW_MIN_OPTION_WIDTH + (i3 - 1) * r3;
1628
+ e4.classList.toggle("magicfeedback-radio--stacked", window.innerWidth < a || n3 < o3);
1629
+ })(r2);
1630
+ }))));
1631
+ })).observe(e4);
1632
+ })(f, y.length)), { element: f, elementTypeClass: g };
1633
+ }, t2.CHOICE_ROW_MIN_OPTION_WIDTH = 120;
1634
+ const a = 600;
1605
1635
  }, 9369: (e2, t2, i) => {
1606
1636
  "use strict";
1607
1637
  Object.defineProperty(t2, "__esModule", { value: true }), t2.renderConsent = void 0;
@@ -1962,21 +1992,21 @@ var require_magicfeedback_sdk_browser = __commonJS({
1962
1992
  C();
1963
1993
  const P = document.createElement("button");
1964
1994
  P.type = "button", P.classList.add("magicfeedback-modal-close"), P.setAttribute("aria-label", d("cancel")), P.title = d("cancel"), P.textContent = "\xD7", P.style.position = "absolute", P.style.top = "8px", P.style.setProperty("inset-inline-end", "8px"), P.style.border = "none", P.style.background = "transparent", P.style.fontSize = "24px", P.style.cursor = "pointer";
1965
- const w = () => {
1995
+ const S = () => {
1966
1996
  document.body.appendChild(g), g.style.display = "flex", E(), C();
1967
- }, x = () => {
1997
+ }, w = () => {
1968
1998
  g.style.display = "none", c.appendChild(g);
1969
1999
  };
1970
2000
  P.addEventListener("click", (() => {
1971
- x();
1972
- }));
1973
- const S = document.createElement("button");
1974
- return S.type = "button", S.textContent = d("confirm"), S.classList.add("magicfeedback-button"), S.classList.add("magicfeedback-button-primary"), S.addEventListener("click", (() => {
1975
- x(), f();
1976
- })), k.appendChild(T), k.appendChild(S), y.appendChild(P), y.appendChild(v), y.appendChild(A), y.appendChild(k), g.appendChild(y), p2.addEventListener("click", (() => {
1977
2001
  w();
2002
+ }));
2003
+ const O = document.createElement("button");
2004
+ return O.type = "button", O.textContent = d("confirm"), O.classList.add("magicfeedback-button"), O.classList.add("magicfeedback-button-primary"), O.addEventListener("click", (() => {
2005
+ w(), f();
2006
+ })), k.appendChild(T), k.appendChild(O), y.appendChild(P), y.appendChild(v), y.appendChild(A), y.appendChild(k), g.appendChild(y), p2.addEventListener("click", (() => {
2007
+ S();
1978
2008
  })), g.addEventListener("click", ((e6) => {
1979
- e6.target === g && x();
2009
+ e6.target === g && w();
1980
2010
  })), c.appendChild(o3), c.appendChild(m), c.appendChild(g), f(), c;
1981
2011
  }
1982
2012
  const u = document.createElement("ul");
@@ -2195,23 +2225,23 @@ var require_magicfeedback_sdk_browser = __commonJS({
2195
2225
  C.classList.add("magicfeedback-upload-error");
2196
2226
  const P = document.createElement("ul");
2197
2227
  P.classList.add("magicfeedback-upload-list"), y.appendChild(E), y.appendChild(C), y.appendChild(P);
2198
- const w = /* @__PURE__ */ new WeakMap(), x = (e4) => {
2199
- const t4 = w.get(e4);
2228
+ const S = /* @__PURE__ */ new WeakMap(), w = (e4) => {
2229
+ const t4 = S.get(e4);
2200
2230
  return t4 ? Promise.resolve(t4) : new Promise(((t5) => {
2201
2231
  const i3 = new FileReader(), n3 = (i4) => {
2202
2232
  const n4 = JSON.stringify({ name: e4.name, type: e4.type, size: e4.size, content: i4 });
2203
- w.set(e4, n4), t5(n4);
2233
+ S.set(e4, n4), t5(n4);
2204
2234
  };
2205
2235
  i3.onload = () => n3("string" == typeof i3.result ? i3.result : ""), i3.onerror = () => n3(""), i3.readAsDataURL(e4);
2206
2236
  }));
2207
- }, S = [], O = (e4) => {
2237
+ }, O = [], x = (e4) => {
2208
2238
  try {
2209
2239
  const t4 = h > 0 ? e4.slice(0, h) : e4, i3 = new DataTransfer();
2210
2240
  t4.forEach(((e5) => i3.items.add(e5))), v.files = i3.files;
2211
2241
  } catch (e5) {
2212
2242
  }
2213
2243
  !(function() {
2214
- S.forEach(((e6) => URL.revokeObjectURL(e6))), S.length = 0, P.innerHTML = "";
2244
+ O.forEach(((e6) => URL.revokeObjectURL(e6))), O.length = 0, P.innerHTML = "";
2215
2245
  const e5 = Array.from(v.files || []);
2216
2246
  y.classList.toggle("magicfeedback-upload--has-files", e5.length > 0), e5.forEach(((e6, n3) => {
2217
2247
  const o2 = document.createElement("li");
@@ -2219,7 +2249,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
2219
2249
  const a2 = document.createElement("span");
2220
2250
  if (a2.classList.add("magicfeedback-upload-thumb"), "image" === i2 && e6.type.startsWith("image/")) {
2221
2251
  const t4 = URL.createObjectURL(e6);
2222
- S.push(t4);
2252
+ O.push(t4);
2223
2253
  const i3 = document.createElement("img");
2224
2254
  i3.src = t4, i3.alt = e6.name, a2.appendChild(i3);
2225
2255
  } else a2.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/></svg>';
@@ -2231,11 +2261,11 @@ var require_magicfeedback_sdk_browser = __commonJS({
2231
2261
  c2.classList.add("magicfeedback-upload-file-size"), c2.textContent = l(e6.size), s2.appendChild(d2), s2.appendChild(c2);
2232
2262
  const u2 = document.createElement("button");
2233
2263
  u2.type = "button", u2.classList.add("magicfeedback-upload-remove"), u2.setAttribute("aria-label", `${r.placeholder.upload.remove(t3)}: ${e6.name}`), u2.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>', u2.addEventListener("click", ((e7) => {
2234
- e7.preventDefault(), e7.stopPropagation(), O(Array.from(v.files || []).filter(((e8, t4) => t4 !== n3)));
2264
+ e7.preventDefault(), e7.stopPropagation(), x(Array.from(v.files || []).filter(((e8, t4) => t4 !== n3)));
2235
2265
  })), o2.appendChild(a2), o2.appendChild(s2), o2.appendChild(u2), P.appendChild(o2);
2236
2266
  }));
2237
2267
  })(), (() => {
2238
- const e5 = Array.from(v.files || []), t4 = Promise.all(e5.map(x)).then(((e6) => {
2268
+ const e5 = Array.from(v.files || []), t4 = Promise.all(e5.map(w)).then(((e6) => {
2239
2269
  v[a] = e6;
2240
2270
  }));
2241
2271
  v[s] = t4;
@@ -2251,7 +2281,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
2251
2281
  };
2252
2282
  v.addEventListener("change", (() => {
2253
2283
  const { accepted: e4, rejected: t4 } = N(Array.from(v.files || []));
2254
- L(t4), O(e4);
2284
+ L(t4), x(e4);
2255
2285
  }));
2256
2286
  const I = (e4) => {
2257
2287
  e4.preventDefault(), e4.stopPropagation();
@@ -2268,7 +2298,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
2268
2298
  const { accepted: r2, rejected: o2 } = N(n3);
2269
2299
  if (L(o2), !r2.length) return;
2270
2300
  const a2 = m ? Array.from(v.files || []) : [];
2271
- O(a2.concat(r2));
2301
+ x(a2.concat(r2));
2272
2302
  })), { element: y, elementTypeClass: p };
2273
2303
  };
2274
2304
  }, 4759: function(e2, t2, i) {
@@ -2484,13 +2514,13 @@ var require_magicfeedback_sdk_browser = __commonJS({
2484
2514
  var p2, m2, h2;
2485
2515
  let f2, g2, { id: y2, title: v, type: b, ref: E, require: A, defaultValue: k, assets: T } = e5, C = document.createElement("div");
2486
2516
  C.classList.add("magicfeedback-div");
2487
- const P = window.innerWidth < 600, w = "slim" === t4 ? (0, o.parseTitle)(v, i3) : null == T ? void 0 : T.placeholder, x = (0, a.shownValueFor)(e5, (0, o.getUrlParam)(E)), S = (null == T ? void 0 : T.maxCharacters) || 0, O = false === (null == T ? void 0 : T.autoAdvance) ? void 0 : c2, L = void 0 !== (null == T ? void 0 : T.randomPosition) && (null == T ? void 0 : T.randomPosition), N = (null == T ? void 0 : T.direction) || "row", I = (null == T ? void 0 : T.order) || "ltr", D = (0, r.getQuestionRenderer)(b);
2517
+ const P = window.innerWidth < 600, S = "slim" === t4 ? (0, o.parseTitle)(v, i3) : null == T ? void 0 : T.placeholder, w = (0, a.shownValueFor)(e5, (0, o.getUrlParam)(E)), O = (null == T ? void 0 : T.maxCharacters) || 0, x = false === (null == T ? void 0 : T.autoAdvance) ? void 0 : c2, L = void 0 !== (null == T ? void 0 : T.randomPosition) && (null == T ? void 0 : T.randomPosition), N = (null == T ? void 0 : T.direction) || "row", I = (null == T ? void 0 : T.order) || "ltr", D = (0, r.getQuestionRenderer)(b);
2488
2518
  if (!D) return C;
2489
2519
  {
2490
- const r2 = D({ question: e5, format: t4, language: i3, url: d2, send: b === n.FEEDBACKAPPANSWERTYPE.TEXT ? c2 : O, isPhone: P, urlParamValue: x, placeholderText: w, maxCharacters: S, randomPosition: L, direction: N, order: I, productId: u2 });
2520
+ const r2 = D({ question: e5, format: t4, language: i3, url: d2, send: b === n.FEEDBACKAPPANSWERTYPE.TEXT ? c2 : x, isPhone: P, urlParamValue: w, placeholderText: S, maxCharacters: O, randomPosition: L, direction: N, order: I, productId: u2 });
2491
2521
  f2 = r2.element, g2 = r2.elementTypeClass;
2492
2522
  }
2493
- f2.id = `magicfeedback-${y2}`, f2.setAttribute("name", E), f2.classList.add(g2), (void 0 !== k || null !== x) && (f2.value = x || k), ["RADIO", "MULTIPLECHOICE", "UPLOAD_IMAGE", "UPLOAD_FILE"].includes(b) || (f2.classList.add("magicfeedback-input"), f2.required = A);
2523
+ f2.id = `magicfeedback-${y2}`, f2.setAttribute("name", E), f2.classList.add(g2), (void 0 !== k || null !== w) && (f2.value = w || k), ["RADIO", "MULTIPLECHOICE", "UPLOAD_IMAGE", "UPLOAD_FILE"].includes(b) || (f2.classList.add("magicfeedback-input"), f2.required = A);
2494
2524
  const R = document.createElement("label");
2495
2525
  R.setAttribute("for", `magicfeedback-${y2}`), R.textContent = (0, o.parseTitle)(v, i3), R.classList.add("magicfeedback-label"), (function(e6, t5) {
2496
2526
  if ("INFO_PAGE" !== t5.type) return;
@@ -2500,17 +2530,17 @@ var require_magicfeedback_sdk_browser = __commonJS({
2500
2530
  var o2;
2501
2531
  n2 && e6.style.setProperty("font-size", n2, "important"), (null == i4 ? void 0 : i4.titleAlign) && (e6.style.setProperty("width", "100%", "important"), e6.style.setProperty("align-self", "stretch", "important"), e6.style.setProperty("text-align", i4.titleAlign, "important")), r2.includes("italic") && e6.style.setProperty("font-style", "italic", "important"), r2.includes("bold") && e6.style.setProperty("font-weight", "bold", "important"), r2.includes("underline") && e6.style.setProperty("text-decoration", "underline", "important");
2502
2532
  })(R, e5);
2503
- const M = document.createElement("label");
2504
- if (M.textContent = (0, o.parseTitle)(null == T ? void 0 : T.subtitle, i3), M.classList.add("magicfeedback-sublabel"), (null === (p2 = null == T ? void 0 : T.subtitleStyle) || void 0 === p2 ? void 0 : p2.includes("italic")) && (M.style.fontStyle = "italic"), (null === (m2 = null == T ? void 0 : T.subtitleStyle) || void 0 === m2 ? void 0 : m2.includes("bold")) && (M.style.fontWeight = "bold"), (null === (h2 = null == T ? void 0 : T.subtitleStyle) || void 0 === h2 ? void 0 : h2.includes("underline")) && (M.style.textDecoration = "underline"), ["CONSENT"].includes(b)) C.classList.add("magicfeedback-consent-container"), C.appendChild(f2), C.appendChild(R), (null == T ? void 0 : T.subtitle) && C.appendChild(M);
2533
+ const _ = document.createElement("label");
2534
+ if (_.textContent = (0, o.parseTitle)(null == T ? void 0 : T.subtitle, i3), _.classList.add("magicfeedback-sublabel"), (null === (p2 = null == T ? void 0 : T.subtitleStyle) || void 0 === p2 ? void 0 : p2.includes("italic")) && (_.style.fontStyle = "italic"), (null === (m2 = null == T ? void 0 : T.subtitleStyle) || void 0 === m2 ? void 0 : m2.includes("bold")) && (_.style.fontWeight = "bold"), (null === (h2 = null == T ? void 0 : T.subtitleStyle) || void 0 === h2 ? void 0 : h2.includes("underline")) && (_.style.textDecoration = "underline"), ["CONSENT"].includes(b)) C.classList.add("magicfeedback-consent-container"), C.appendChild(f2), C.appendChild(R), (null == T ? void 0 : T.subtitle) && C.appendChild(_);
2505
2535
  else {
2506
- if ("slim" !== t4 && (C.appendChild(R), (null == T ? void 0 : T.subtitle) && C.appendChild(M), void 0 !== (null == T ? void 0 : T.general) && "" !== (null == T ? void 0 : T.general))) {
2536
+ if ("slim" !== t4 && (C.appendChild(R), (null == T ? void 0 : T.subtitle) && C.appendChild(_), void 0 !== (null == T ? void 0 : T.general) && "" !== (null == T ? void 0 : T.general))) {
2507
2537
  const e6 = document.createElement("img");
2508
2538
  e6.src = null == T ? void 0 : T.general, e6.classList.add("magicfeedback-image"), e6.style.maxWidth = "auto", e6.style.height = "400px", e6.style.margin = "10px 0", C.appendChild(e6);
2509
2539
  }
2510
- if ("LONGTEXT" === b && S > 0) {
2540
+ if ("LONGTEXT" === b && O > 0) {
2511
2541
  const e6 = document.createElement("div");
2512
- if (e6.classList.add("magicfeedback-counter"), e6.textContent = `${f2.value.length}/${S}`, e6.style.textAlign = "end", e6.style.fontSize = "15px", e6.style.marginTop = "5px", f2.addEventListener("input", (() => {
2513
- e6.textContent = `${f2.value.length}/${S}`;
2542
+ if (e6.classList.add("magicfeedback-counter"), e6.textContent = `${f2.value.length}/${O}`, e6.style.textAlign = "end", e6.style.fontSize = "15px", e6.style.marginTop = "5px", f2.addEventListener("input", (() => {
2543
+ e6.textContent = `${f2.value.length}/${O}`;
2514
2544
  })), C.appendChild(f2), C.appendChild(e6), (null == T ? void 0 : T.extraOption) && (null == T ? void 0 : T.extraOptionText)) {
2515
2545
  const e7 = document.createElement("div");
2516
2546
  e7.classList.add("magicfeedback-skip-container"), e7.classList.add("magicfeedback-checkbox-container"), e7.style.display = "flex", e7.style.justifyContent = "flex-start";
@@ -2519,7 +2549,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
2519
2549
  const i4 = document.createElement("label");
2520
2550
  i4.htmlFor = `skip-${E}`, i4.textContent = null == T ? void 0 : T.extraOptionText, i4.style.fontSize = "15px", i4.style.cursor = "pointer", i4.style.margin = "0 5px", t5.addEventListener("click", (() => {
2521
2551
  f2.value = "-";
2522
- })), (0, s.autoAdvanceOn)(t5, O, "click"), e7.appendChild(t5), e7.appendChild(i4), C.appendChild(e7);
2552
+ })), (0, s.autoAdvanceOn)(t5, x, "click"), e7.appendChild(t5), e7.appendChild(i4), C.appendChild(e7);
2523
2553
  }
2524
2554
  } else C.appendChild(f2);
2525
2555
  }
@@ -2583,15 +2613,29 @@ var require_magicfeedback_sdk_browser = __commonJS({
2583
2613
  }, r = this && this.__importDefault || function(e3) {
2584
2614
  return e3 && e3.__esModule ? e3 : { default: e3 };
2585
2615
  };
2586
- Object.defineProperty(t2, "__esModule", { value: true }), t2.getFollowUpQuestion = t2.sendFeedback = t2.getQuestions = t2.getSessionForm = t2.getForm = t2.validateEmail = t2.header = void 0;
2616
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.getFollowUpQuestion = t2.sendFeedback = t2.getQuestions = t2.getSessionForm = t2.getForm = t2.takePreloadedInfo = t2.validateEmail = t2.header = void 0;
2587
2617
  const o = r(i(6539)), a = r(i(8330)), s = i(5407), l = i(3433);
2618
+ function d(e3) {
2619
+ if ("undefined" == typeof window) return;
2620
+ const i2 = window, n2 = i2.__MAGICFEEDBACK_PRELOADED_INFO__;
2621
+ if (n2 && n2.url === e3 && n2.parameters === t2.header["x-magicfeedback-parameters"]) {
2622
+ delete i2.__MAGICFEEDBACK_PRELOADED_INFO__;
2623
+ try {
2624
+ return JSON.parse(n2.body);
2625
+ } catch (e4) {
2626
+ return;
2627
+ }
2628
+ }
2629
+ }
2588
2630
  t2.header = { Accept: "application/json", "Magicfeedback-Sdk-Version": a.default.version, "x-magicfeedback-parameters": window.location.search || "" }, t2.validateEmail = function(e3) {
2589
2631
  return /\S+@\S+\.\S+/.test(e3);
2590
- }, t2.getForm = function(e3, i2, r2, a2, d) {
2632
+ }, t2.takePreloadedInfo = d, t2.getForm = function(e3, i2, r2, a2, c) {
2591
2633
  return n(this, void 0, void 0, (function* () {
2592
2634
  try {
2593
- const n2 = yield (0, o.default)((0, l.withLangParam)(e3 + s.endpoints.sdk.app_info(i2, r2), d), { method: "GET", headers: t2.header });
2594
- return yield n2.json();
2635
+ const n2 = (0, l.withLangParam)(e3 + s.endpoints.sdk.app_info(i2, r2), c), a3 = d(n2);
2636
+ if (void 0 !== a3) return a3;
2637
+ const u = yield (0, o.default)(n2, { method: "GET", headers: t2.header });
2638
+ return yield u.json();
2595
2639
  } catch (e4) {
2596
2640
  a2.err(e4);
2597
2641
  }
@@ -2599,16 +2643,18 @@ var require_magicfeedback_sdk_browser = __commonJS({
2599
2643
  }, t2.getSessionForm = function(e3, i2, r2, a2) {
2600
2644
  return n(this, void 0, void 0, (function* () {
2601
2645
  try {
2602
- const n2 = yield (0, o.default)((0, l.withLangParam)(e3 + s.endpoints.sdk.session(i2), a2), { method: "GET", headers: t2.header });
2603
- return yield n2.json();
2646
+ const n2 = (0, l.withLangParam)(e3 + s.endpoints.sdk.session(i2), a2), r3 = d(n2);
2647
+ if (void 0 !== r3) return r3;
2648
+ const c = yield (0, o.default)(n2, { method: "GET", headers: t2.header });
2649
+ return yield c.json();
2604
2650
  } catch (e4) {
2605
2651
  r2.err(e4);
2606
2652
  }
2607
2653
  }));
2608
- }, t2.getQuestions = function(e3, i2, r2, a2, d) {
2654
+ }, t2.getQuestions = function(e3, i2, r2, a2, d2) {
2609
2655
  return n(this, void 0, void 0, (function* () {
2610
2656
  try {
2611
- const n2 = yield (0, o.default)((0, l.withLangParam)(e3 + s.endpoints.sdk.app(i2, r2), d), { method: "GET", headers: t2.header });
2657
+ const n2 = yield (0, o.default)((0, l.withLangParam)(e3 + s.endpoints.sdk.app(i2, r2), d2), { method: "GET", headers: t2.header });
2612
2658
  if (n2.ok) {
2613
2659
  const e4 = yield n2.json();
2614
2660
  return a2.log(`Received questions for app ${i2}`, e4), e4;
@@ -2639,6 +2685,15 @@ var require_magicfeedback_sdk_browser = __commonJS({
2639
2685
  }
2640
2686
  }));
2641
2687
  };
2688
+ }, 1012: (e2, t2) => {
2689
+ "use strict";
2690
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.SubmitError = void 0;
2691
+ class i extends Error {
2692
+ constructor(e3, t3) {
2693
+ super(t3), this.code = e3, this.name = "SubmitError", Object.setPrototypeOf(this, i.prototype);
2694
+ }
2695
+ }
2696
+ t2.SubmitError = i;
2642
2697
  }, 3433: (e2, t2, i) => {
2643
2698
  "use strict";
2644
2699
  Object.defineProperty(t2, "__esModule", { value: true }), t2.toBaseAnswers = t2.shownValueFor = t2.baseValueMap = t2.withLangParam = t2.detectSurveyLang = t2.normalizeSurveyLang = void 0;
@@ -2817,7 +2872,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
2817
2872
  };
2818
2873
  }, 8330: (e2) => {
2819
2874
  "use strict";
2820
- e2.exports = JSON.parse('{"name":"@magicfeedback/native","version":"2.2.33","main":"./dist/magicfeedback-sdk.node.js","browser":"./dist/magicfeedback-sdk.browser.js","types":"./dist/types/src/index.d.ts","repository":{"type":"git","url":"git+ssh://git@github.com/MagicFeedback/magicfeedback-sdk.git"},"author":"farias@magicfeedback.io","license":"MIT","private":false,"scripts":{"dev":"vite","build":"webpack","build:watch":"webpack --watch --mode development","release":"npm publish --access public","release:beta":"npm publish --access public --tag beta","release:alpha":"npm publish --access public --tag alpha","test":"jest","test:watch":"jest --watchAll","coverage":"jest --coverage","publish:sdk":"bash publish.sh","publish:sdk:dry-run":"NPM_DRY_RUN=1 bash publish.sh"},"files":["dist"],"devDependencies":{"@babel/preset-typescript":"^7.22.5","@types/node":"^17.0.21","@types/webpack":"^5.28.0","@types/webpack-node-externals":"^2.5.3","c8":"^7.11.0","copy-webpack-plugin":"^11.0.0","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","jest-fetch-mock":"^3.0.3","nock":"^13.2.4","ts-jest":"^29.1.0","ts-loader":"^9.2.7","ts-node":"^10.7.0","typescript":"^4.6.2","vite":"^2.8.0","vite-plugin-dts":"^0.9.9","webpack":"^5.70.0","webpack-cli":"^4.9.2","webpack-node-externals":"^3.0.0"},"dependencies":{"cross-fetch":"^3.1.5","is-bundling-for-browser-or-node":"^1.1.1"},"description":"MagicFeedbackAI JavaScript Library for [MagicFeedback.io](https://magicfeedback.io/)","bugs":{"url":"https://github.com/MagicFeedback/magicfeedback-sdk/issues"},"homepage":"https://github.com/MagicFeedback/magicfeedback-sdk#readme","directories":{"example":"examples","test":"test"},"style":"./dist/styles/magicfeedback-default.css"}');
2875
+ e2.exports = JSON.parse('{"name":"@magicfeedback/native","version":"2.2.37","main":"./dist/magicfeedback-sdk.node.js","browser":"./dist/magicfeedback-sdk.browser.js","types":"./dist/types/src/index.d.ts","repository":{"type":"git","url":"git+ssh://git@github.com/MagicFeedback/magicfeedback-sdk.git"},"author":"farias@magicfeedback.io","license":"MIT","private":false,"scripts":{"dev":"vite","build":"webpack","build:watch":"webpack --watch --mode development","release":"npm publish --access public","release:beta":"npm publish --access public --tag beta","release:alpha":"npm publish --access public --tag alpha","test":"jest","test:watch":"jest --watchAll","coverage":"jest --coverage","publish:sdk":"bash publish.sh","publish:sdk:dry-run":"NPM_DRY_RUN=1 bash publish.sh"},"files":["dist"],"devDependencies":{"@babel/preset-typescript":"^7.22.5","@types/node":"^17.0.21","@types/webpack":"^5.28.0","@types/webpack-node-externals":"^2.5.3","c8":"^7.11.0","copy-webpack-plugin":"^11.0.0","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","jest-fetch-mock":"^3.0.3","nock":"^13.2.4","ts-jest":"^29.1.0","ts-loader":"^9.2.7","ts-node":"^10.7.0","typescript":"^4.6.2","vite":"^2.8.0","vite-plugin-dts":"^0.9.9","webpack":"^5.70.0","webpack-cli":"^4.9.2","webpack-node-externals":"^3.0.0"},"dependencies":{"cross-fetch":"^3.1.5","is-bundling-for-browser-or-node":"^1.1.1"},"description":"MagicFeedbackAI JavaScript Library for [MagicFeedback.io](https://magicfeedback.io/)","bugs":{"url":"https://github.com/MagicFeedback/magicfeedback-sdk/issues"},"homepage":"https://github.com/MagicFeedback/magicfeedback-sdk#readme","directories":{"example":"examples","test":"test"},"style":"./dist/styles/magicfeedback-default.css"}');
2821
2876
  } }, t = {}, (function i(n) {
2822
2877
  var r = t[n];
2823
2878
  if (void 0 !== r) return r.exports;
@@ -3567,14 +3622,15 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
3567
3622
  autofocusOnOpen();
3568
3623
  }
3569
3624
  };
3625
+ let lastReportedError = null;
3570
3626
  generateOptions.beforeSubmitEvent = () => {
3571
3627
  setLoading(true);
3572
3628
  };
3573
3629
  generateOptions.afterSubmitEvent = ({ error, completed, total, progress, followup }) => {
3574
- const errText = error ? typeof error === "string" ? error : error.message ?? String(error) : "";
3575
- if (errText) {
3630
+ if (error) {
3576
3631
  setLoading(false);
3577
- if (errText.toLowerCase().includes("no response")) {
3632
+ const { reason, message } = classifySubmitError(error);
3633
+ if (reason === "required") {
3578
3634
  errorHint.textContent = labels.errorRequired;
3579
3635
  errorHint.style.display = "block";
3580
3636
  updateNavButtons();
@@ -3582,7 +3638,11 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
3582
3638
  }
3583
3639
  errorHint.textContent = labels.errorSubmit;
3584
3640
  errorHint.style.display = "block";
3585
- sdkWarn("[Deepdots] survey submit error:", errText);
3641
+ sdkWarn("[Deepdots] survey submit error:", reason, message);
3642
+ if (error !== lastReportedError) {
3643
+ lastReportedError = error;
3644
+ emit("survey_error", surveyId, { reason, message });
3645
+ }
3586
3646
  return;
3587
3647
  }
3588
3648
  errorHint.style.display = "none";
@@ -3619,4 +3679,4 @@ export {
3619
3679
  SURVEY_ALIGNMENT_STYLE_ID,
3620
3680
  renderPopup
3621
3681
  };
3622
- //# sourceMappingURL=renderPopup-PQWJSBOY.mjs.map
3682
+ //# sourceMappingURL=renderPopup-BKZPAZZG.mjs.map