@magicfeedback/popup-sdk 1.0.11 → 1.0.13

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.
package/dist/index.js CHANGED
@@ -46,14 +46,14 @@ var require_magicfeedback_sdk_browser = __commonJS({
46
46
  })();
47
47
  !(function(e3) {
48
48
  !(function(t3) {
49
- var i2 = "URLSearchParams" in e3, n2 = "Symbol" in e3 && "iterator" in Symbol, a2 = "FileReader" in e3 && "Blob" in e3 && (function() {
49
+ var i2 = "URLSearchParams" in e3, n2 = "Symbol" in e3 && "iterator" in Symbol, r2 = "FileReader" in e3 && "Blob" in e3 && (function() {
50
50
  try {
51
51
  return new Blob(), true;
52
52
  } catch (e4) {
53
53
  return false;
54
54
  }
55
- })(), s = "FormData" in e3, r = "ArrayBuffer" in e3;
56
- if (r) var o = ["[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]"], l = ArrayBuffer.isView || function(e4) {
55
+ })(), s = "FormData" in e3, a = "ArrayBuffer" in e3;
56
+ if (a) var o = ["[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]"], l = ArrayBuffer.isView || function(e4) {
57
57
  return e4 && o.indexOf(Object.prototype.toString.call(e4)) > -1;
58
58
  };
59
59
  function d(e4) {
@@ -81,11 +81,11 @@ var require_magicfeedback_sdk_browser = __commonJS({
81
81
  this.append(t4, e4[t4]);
82
82
  }), this);
83
83
  }
84
- function h(e4) {
84
+ function m(e4) {
85
85
  if (e4.bodyUsed) return Promise.reject(new TypeError("Already read"));
86
86
  e4.bodyUsed = true;
87
87
  }
88
- function m(e4) {
88
+ function h(e4) {
89
89
  return new Promise((function(t4, i3) {
90
90
  e4.onload = function() {
91
91
  t4(e4.result);
@@ -95,31 +95,31 @@ var require_magicfeedback_sdk_browser = __commonJS({
95
95
  }));
96
96
  }
97
97
  function f(e4) {
98
- var t4 = new FileReader(), i3 = m(t4);
98
+ var t4 = new FileReader(), i3 = h(t4);
99
99
  return t4.readAsArrayBuffer(e4), i3;
100
100
  }
101
- function g(e4) {
101
+ function v(e4) {
102
102
  if (e4.slice) return e4.slice(0);
103
103
  var t4 = new Uint8Array(e4.byteLength);
104
104
  return t4.set(new Uint8Array(e4)), t4.buffer;
105
105
  }
106
- function v() {
106
+ function g() {
107
107
  return this.bodyUsed = false, this._initBody = function(e4) {
108
108
  var t4;
109
- this._bodyInit = e4, e4 ? "string" == typeof e4 ? this._bodyText = e4 : a2 && Blob.prototype.isPrototypeOf(e4) ? this._bodyBlob = e4 : s && FormData.prototype.isPrototypeOf(e4) ? this._bodyFormData = e4 : i2 && URLSearchParams.prototype.isPrototypeOf(e4) ? this._bodyText = e4.toString() : r && a2 && (t4 = e4) && DataView.prototype.isPrototypeOf(t4) ? (this._bodyArrayBuffer = g(e4.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : r && (ArrayBuffer.prototype.isPrototypeOf(e4) || l(e4)) ? this._bodyArrayBuffer = g(e4) : this._bodyText = e4 = Object.prototype.toString.call(e4) : this._bodyText = "", this.headers.get("content-type") || ("string" == typeof e4 ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : i2 && URLSearchParams.prototype.isPrototypeOf(e4) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
110
- }, a2 && (this.blob = function() {
111
- var e4 = h(this);
109
+ this._bodyInit = e4, e4 ? "string" == typeof e4 ? this._bodyText = e4 : r2 && Blob.prototype.isPrototypeOf(e4) ? this._bodyBlob = e4 : s && FormData.prototype.isPrototypeOf(e4) ? this._bodyFormData = e4 : i2 && URLSearchParams.prototype.isPrototypeOf(e4) ? this._bodyText = e4.toString() : a && r2 && (t4 = e4) && DataView.prototype.isPrototypeOf(t4) ? (this._bodyArrayBuffer = v(e4.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : a && (ArrayBuffer.prototype.isPrototypeOf(e4) || l(e4)) ? this._bodyArrayBuffer = v(e4) : this._bodyText = e4 = Object.prototype.toString.call(e4) : this._bodyText = "", this.headers.get("content-type") || ("string" == typeof e4 ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : i2 && URLSearchParams.prototype.isPrototypeOf(e4) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
110
+ }, r2 && (this.blob = function() {
111
+ var e4 = m(this);
112
112
  if (e4) return e4;
113
113
  if (this._bodyBlob) return Promise.resolve(this._bodyBlob);
114
114
  if (this._bodyArrayBuffer) return Promise.resolve(new Blob([this._bodyArrayBuffer]));
115
115
  if (this._bodyFormData) throw new Error("could not read FormData body as blob");
116
116
  return Promise.resolve(new Blob([this._bodyText]));
117
117
  }, this.arrayBuffer = function() {
118
- return this._bodyArrayBuffer ? h(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(f);
118
+ return this._bodyArrayBuffer ? m(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(f);
119
119
  }), this.text = function() {
120
- var e4, t4, i3, n3 = h(this);
120
+ var e4, t4, i3, n3 = m(this);
121
121
  if (n3) return n3;
122
- if (this._bodyBlob) return e4 = this._bodyBlob, i3 = m(t4 = new FileReader()), t4.readAsText(e4), i3;
122
+ if (this._bodyBlob) return e4 = this._bodyBlob, i3 = h(t4 = new FileReader()), t4.readAsText(e4), i3;
123
123
  if (this._bodyArrayBuffer) return Promise.resolve((function(e5) {
124
124
  for (var t5 = new Uint8Array(e5), i4 = new Array(t5.length), n4 = 0; n4 < t5.length; n4++) i4[n4] = String.fromCharCode(t5[n4]);
125
125
  return i4.join("");
@@ -127,7 +127,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
127
127
  if (this._bodyFormData) throw new Error("could not read FormData body as text");
128
128
  return Promise.resolve(this._bodyText);
129
129
  }, s && (this.formData = function() {
130
- return this.text().then(b);
130
+ return this.text().then(E);
131
131
  }), this.json = function() {
132
132
  return this.text().then(JSON.parse);
133
133
  }, this;
@@ -163,39 +163,39 @@ var require_magicfeedback_sdk_browser = __commonJS({
163
163
  })), u(e4);
164
164
  }, n2 && (p.prototype[Symbol.iterator] = p.prototype.entries);
165
165
  var y = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
166
- function E(e4, t4) {
167
- var i3, n3, a3 = (t4 = t4 || {}).body;
168
- if (e4 instanceof E) {
166
+ function b(e4, t4) {
167
+ var i3, n3, r3 = (t4 = t4 || {}).body;
168
+ if (e4 instanceof b) {
169
169
  if (e4.bodyUsed) throw new TypeError("Already read");
170
- this.url = e4.url, this.credentials = e4.credentials, t4.headers || (this.headers = new p(e4.headers)), this.method = e4.method, this.mode = e4.mode, this.signal = e4.signal, a3 || null == e4._bodyInit || (a3 = e4._bodyInit, e4.bodyUsed = true);
170
+ this.url = e4.url, this.credentials = e4.credentials, t4.headers || (this.headers = new p(e4.headers)), this.method = e4.method, this.mode = e4.mode, this.signal = e4.signal, r3 || null == e4._bodyInit || (r3 = e4._bodyInit, e4.bodyUsed = true);
171
171
  } else this.url = String(e4);
172
- if (this.credentials = t4.credentials || this.credentials || "same-origin", !t4.headers && this.headers || (this.headers = new p(t4.headers)), this.method = (n3 = (i3 = t4.method || this.method || "GET").toUpperCase(), y.indexOf(n3) > -1 ? n3 : i3), this.mode = t4.mode || this.mode || null, this.signal = t4.signal || this.signal, this.referrer = null, ("GET" === this.method || "HEAD" === this.method) && a3) throw new TypeError("Body not allowed for GET or HEAD requests");
173
- this._initBody(a3);
172
+ if (this.credentials = t4.credentials || this.credentials || "same-origin", !t4.headers && this.headers || (this.headers = new p(t4.headers)), this.method = (n3 = (i3 = t4.method || this.method || "GET").toUpperCase(), y.indexOf(n3) > -1 ? n3 : i3), this.mode = t4.mode || this.mode || null, this.signal = t4.signal || this.signal, this.referrer = null, ("GET" === this.method || "HEAD" === this.method) && r3) throw new TypeError("Body not allowed for GET or HEAD requests");
173
+ this._initBody(r3);
174
174
  }
175
- function b(e4) {
175
+ function E(e4) {
176
176
  var t4 = new FormData();
177
177
  return e4.trim().split("&").forEach((function(e5) {
178
178
  if (e5) {
179
- var i3 = e5.split("="), n3 = i3.shift().replace(/\+/g, " "), a3 = i3.join("=").replace(/\+/g, " ");
180
- t4.append(decodeURIComponent(n3), decodeURIComponent(a3));
179
+ var i3 = e5.split("="), n3 = i3.shift().replace(/\+/g, " "), r3 = i3.join("=").replace(/\+/g, " ");
180
+ t4.append(decodeURIComponent(n3), decodeURIComponent(r3));
181
181
  }
182
182
  })), t4;
183
183
  }
184
- function A(e4, t4) {
184
+ function k(e4, t4) {
185
185
  t4 || (t4 = {}), this.type = "default", this.status = void 0 === t4.status ? 200 : t4.status, this.ok = this.status >= 200 && this.status < 300, this.statusText = "statusText" in t4 ? t4.statusText : "OK", this.headers = new p(t4.headers), this.url = t4.url || "", this._initBody(e4);
186
186
  }
187
- E.prototype.clone = function() {
188
- return new E(this, { body: this._bodyInit });
189
- }, v.call(E.prototype), v.call(A.prototype), A.prototype.clone = function() {
190
- return new A(this._bodyInit, { status: this.status, statusText: this.statusText, headers: new p(this.headers), url: this.url });
191
- }, A.error = function() {
192
- var e4 = new A(null, { status: 0, statusText: "" });
187
+ b.prototype.clone = function() {
188
+ return new b(this, { body: this._bodyInit });
189
+ }, g.call(b.prototype), g.call(k.prototype), k.prototype.clone = function() {
190
+ return new k(this._bodyInit, { status: this.status, statusText: this.statusText, headers: new p(this.headers), url: this.url });
191
+ }, k.error = function() {
192
+ var e4 = new k(null, { status: 0, statusText: "" });
193
193
  return e4.type = "error", e4;
194
194
  };
195
- var k = [301, 302, 303, 307, 308];
196
- A.redirect = function(e4, t4) {
197
- if (-1 === k.indexOf(t4)) throw new RangeError("Invalid status code");
198
- return new A(null, { status: t4, headers: { location: e4 } });
195
+ var A = [301, 302, 303, 307, 308];
196
+ k.redirect = function(e4, t4) {
197
+ if (-1 === A.indexOf(t4)) throw new RangeError("Invalid status code");
198
+ return new k(null, { status: t4, headers: { location: e4 } });
199
199
  }, t3.DOMException = e3.DOMException;
200
200
  try {
201
201
  new t3.DOMException();
@@ -208,8 +208,8 @@ var require_magicfeedback_sdk_browser = __commonJS({
208
208
  }
209
209
  function C(e4, i3) {
210
210
  return new Promise((function(n3, s2) {
211
- var r2 = new E(e4, i3);
212
- if (r2.signal && r2.signal.aborted) return s2(new t3.DOMException("Aborted", "AbortError"));
211
+ var a2 = new b(e4, i3);
212
+ if (a2.signal && a2.signal.aborted) return s2(new t3.DOMException("Aborted", "AbortError"));
213
213
  var o2 = new XMLHttpRequest();
214
214
  function l2() {
215
215
  o2.abort();
@@ -218,31 +218,31 @@ var require_magicfeedback_sdk_browser = __commonJS({
218
218
  var e5, t4, i4 = { status: o2.status, statusText: o2.statusText, headers: (e5 = o2.getAllResponseHeaders() || "", t4 = new p(), e5.replace(/\r?\n[\t ]+/g, " ").split(/\r?\n/).forEach((function(e6) {
219
219
  var i5 = e6.split(":"), n4 = i5.shift().trim();
220
220
  if (n4) {
221
- var a4 = i5.join(":").trim();
222
- t4.append(n4, a4);
221
+ var r4 = i5.join(":").trim();
222
+ t4.append(n4, r4);
223
223
  }
224
224
  })), t4) };
225
225
  i4.url = "responseURL" in o2 ? o2.responseURL : i4.headers.get("X-Request-URL");
226
- var a3 = "response" in o2 ? o2.response : o2.responseText;
227
- n3(new A(a3, i4));
226
+ var r3 = "response" in o2 ? o2.response : o2.responseText;
227
+ n3(new k(r3, i4));
228
228
  }, o2.onerror = function() {
229
229
  s2(new TypeError("Network request failed"));
230
230
  }, o2.ontimeout = function() {
231
231
  s2(new TypeError("Network request failed"));
232
232
  }, o2.onabort = function() {
233
233
  s2(new t3.DOMException("Aborted", "AbortError"));
234
- }, o2.open(r2.method, r2.url, true), "include" === r2.credentials ? o2.withCredentials = true : "omit" === r2.credentials && (o2.withCredentials = false), "responseType" in o2 && a2 && (o2.responseType = "blob"), r2.headers.forEach((function(e5, t4) {
234
+ }, o2.open(a2.method, a2.url, true), "include" === a2.credentials ? o2.withCredentials = true : "omit" === a2.credentials && (o2.withCredentials = false), "responseType" in o2 && r2 && (o2.responseType = "blob"), a2.headers.forEach((function(e5, t4) {
235
235
  o2.setRequestHeader(t4, e5);
236
- })), r2.signal && (r2.signal.addEventListener("abort", l2), o2.onreadystatechange = function() {
237
- 4 === o2.readyState && r2.signal.removeEventListener("abort", l2);
238
- }), o2.send(void 0 === r2._bodyInit ? null : r2._bodyInit);
236
+ })), a2.signal && (a2.signal.addEventListener("abort", l2), o2.onreadystatechange = function() {
237
+ 4 === o2.readyState && a2.signal.removeEventListener("abort", l2);
238
+ }), o2.send(void 0 === a2._bodyInit ? null : a2._bodyInit);
239
239
  }));
240
240
  }
241
- C.polyfill = true, e3.fetch || (e3.fetch = C, e3.Headers = p, e3.Request = E, e3.Response = A), t3.Headers = p, t3.Request = E, t3.Response = A, t3.fetch = C, Object.defineProperty(t3, "__esModule", { value: true });
241
+ C.polyfill = true, e3.fetch || (e3.fetch = C, e3.Headers = p, e3.Request = b, e3.Response = k), t3.Headers = p, t3.Request = b, t3.Response = k, t3.fetch = C, Object.defineProperty(t3, "__esModule", { value: true });
242
242
  })({});
243
243
  })(n), n.fetch.ponyfill = true, delete n.fetch.polyfill;
244
- var a = n;
245
- (t2 = a.fetch).default = a.fetch, t2.fetch = a.fetch, t2.Headers = a.Headers, t2.Request = a.Request, t2.Response = a.Response, e2.exports = t2;
244
+ var r = n;
245
+ (t2 = r.fetch).default = r.fetch, t2.fetch = r.fetch, t2.Headers = r.Headers, t2.Request = r.Request, t2.Response = r.Response, e2.exports = t2;
246
246
  }, 317: (e2, t2) => {
247
247
  "use strict";
248
248
  Object.defineProperty(t2, "__esModule", { value: true }), t2.HOST_API_URL_DEV = t2.HOST_API_URL = void 0, t2.HOST_API_URL = "https://api.deepdots.com/", t2.HOST_API_URL_DEV = "https://api-dev.deepdots.com/";
@@ -252,14 +252,14 @@ var require_magicfeedback_sdk_browser = __commonJS({
252
252
  return e3 && e3.__esModule ? e3 : { default: e3 };
253
253
  };
254
254
  Object.defineProperty(t2, "__esModule", { value: true });
255
- const a = n(i(927));
255
+ const r = n(i(927));
256
256
  let s = null;
257
- s || (s = (0, a.default)()), t2.default = s;
257
+ s || (s = (0, r.default)()), t2.default = s;
258
258
  }, 927: function(e2, t2, i) {
259
259
  "use strict";
260
260
  var n = this && this.__awaiter || function(e3, t3, i2, n2) {
261
- return new (i2 || (i2 = Promise))((function(a2, s2) {
262
- function r2(e4) {
261
+ return new (i2 || (i2 = Promise))((function(r2, s2) {
262
+ function a2(e4) {
263
263
  try {
264
264
  l2(n2.next(e4));
265
265
  } catch (e5) {
@@ -275,35 +275,36 @@ var require_magicfeedback_sdk_browser = __commonJS({
275
275
  }
276
276
  function l2(e4) {
277
277
  var t4;
278
- e4.done ? a2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
278
+ e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
279
279
  e5(t4);
280
- }))).then(r2, o2);
280
+ }))).then(a2, o2);
281
281
  }
282
282
  l2((n2 = n2.apply(e3, t3 || [])).next());
283
283
  }));
284
284
  };
285
285
  Object.defineProperty(t2, "__esModule", { value: true });
286
- const a = i(57), s = i(665), r = i(256), o = i(313), l = i(317);
286
+ const r = i(57), s = i(665), a = i(256), o = i(313), l = i(317);
287
287
  t2.default = function() {
288
288
  const e3 = new s.Config();
289
- let t3;
289
+ let t3 = new a.Log(e3);
290
290
  return { init: function(i2) {
291
- (null == i2 ? void 0 : i2.debug) && e3.set("debug", null == i2 ? void 0 : i2.debug), e3.set("url", (null == i2 ? void 0 : i2.env) && "dev" === (null == i2 ? void 0 : i2.env) ? l.HOST_API_URL_DEV : l.HOST_API_URL), e3.set("env", null == i2 ? void 0 : i2.env), t3 = new r.Log(e3), t3.log("Initialized Magicfeedback", e3);
292
- }, send: function(i2, a2, s2, r2 = true, l2, d) {
291
+ "boolean" == typeof (null == i2 ? void 0 : i2.debug) && e3.set("debug", i2.debug), "boolean" == typeof (null == i2 ? void 0 : i2.dryRun) && e3.set("dryRun", i2.dryRun), e3.set("url", (null == i2 ? void 0 : i2.env) && "dev" === (null == i2 ? void 0 : i2.env) ? l.HOST_API_URL_DEV : l.HOST_API_URL), e3.set("env", null == i2 ? void 0 : i2.env), t3.log("Initialized Magicfeedback", e3);
292
+ }, send: function(i2, r2, s2, a2 = true, l2, d) {
293
293
  return n(this, void 0, void 0, (function* () {
294
- i2 || t3.err("No appID provided"), a2 || t3.err("No publicKey provided"), s2 || t3.err("No feedback provided"), s2.answers || s2.profile || s2.metrics || s2.metadata || t3.err("No feedback data provided");
295
- const n2 = e3.get("url"), c = { integration: i2, publicKey: a2, privateKey: d, completed: r2, id: l2, feedback: s2 };
294
+ i2 || t3.err("No appID provided"), r2 || t3.err("No publicKey provided"), s2 || t3.err("No feedback provided"), s2.answers || s2.profile || s2.metrics || s2.metadata || t3.err("No feedback data provided");
295
+ const n2 = e3.get("url"), c = { integration: i2, publicKey: r2, privateKey: d, completed: a2, id: l2, feedback: s2 };
296
296
  try {
297
- const e4 = yield (0, o.sendFeedback)(n2, c, t3);
298
- return t3.log("sent native feedback"), e4;
297
+ if (e3.get("dryRun")) return t3.log("Dry run enabled: skipping native feedback submit"), `dry-run-${Date.now()}`;
298
+ const i3 = yield (0, o.sendFeedback)(n2, c, t3);
299
+ return t3.log("sent native feedback"), i3;
299
300
  } catch (e4) {
300
301
  return t3.err("error native feedback", e4), false;
301
302
  }
302
303
  }));
303
- }, form: function(i2, n2) {
304
- return i2 || t3.err("No appID provided"), n2 || t3.err("No publicKey provided"), new a.Form(e3, i2, n2);
304
+ }, form: function(i2, n2, s2, a2) {
305
+ return i2 || t3.err("No appID provided"), n2 || t3.err("No publicKey provided"), new r.Form(e3, i2, n2, s2, a2);
305
306
  }, session: function(i2) {
306
- return i2 || t3.err("No sessionId provided"), new a.Form(e3, i2);
307
+ return i2 || t3.err("No sessionId provided"), new r.Form(e3, i2);
307
308
  } };
308
309
  };
309
310
  }, 79: (e2, t2) => {
@@ -341,7 +342,7 @@ var require_magicfeedback_sdk_browser = __commonJS({
341
342
  "use strict";
342
343
  Object.defineProperty(t2, "__esModule", { value: true }), t2.Config = void 0, t2.Config = class {
343
344
  constructor() {
344
- this.variables = {}, this.variables.env = "prod", this.variables.debug = false;
345
+ this.variables = {}, this.variables.env = "prod", this.variables.debug = false, this.variables.dryRun = false;
345
346
  }
346
347
  get(e3) {
347
348
  return this.variables[e3];
@@ -353,8 +354,8 @@ var require_magicfeedback_sdk_browser = __commonJS({
353
354
  }, 57: function(e2, t2, i) {
354
355
  "use strict";
355
356
  var n = this && this.__awaiter || function(e3, t3, i2, n2) {
356
- return new (i2 || (i2 = Promise))((function(a2, s2) {
357
- function r2(e4) {
357
+ return new (i2 || (i2 = Promise))((function(r2, s2) {
358
+ function a2(e4) {
358
359
  try {
359
360
  l2(n2.next(e4));
360
361
  } catch (e5) {
@@ -370,28 +371,28 @@ var require_magicfeedback_sdk_browser = __commonJS({
370
371
  }
371
372
  function l2(e4) {
372
373
  var t4;
373
- e4.done ? a2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
374
+ e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
374
375
  e5(t4);
375
- }))).then(r2, o2);
376
+ }))).then(a2, o2);
376
377
  }
377
378
  l2((n2 = n2.apply(e3, t3 || [])).next());
378
379
  }));
379
380
  };
380
381
  Object.defineProperty(t2, "__esModule", { value: true }), t2.Form = void 0;
381
- const a = i(558), s = i(256), r = i(313), o = i(213), l = i(217), d = i(700), c = i(591), u = i(79), p = i(636);
382
+ const r = i(558), s = i(256), a = i(313), o = i(213), l = i(989), d = i(700), c = i(591), u = i(79), p = i(636);
382
383
  t2.Form = class {
383
- constructor(e3, t3, i2) {
384
- this.config = e3, this.log = new s.Log(e3), this.formOptionsConfig = { addButton: true, sendButtonText: "Send", backButtonText: "Back", nextButtonText: "Next", addSuccessScreen: true, getMetaData: true, questionFormat: "standard" }, this.selector = "", this.appId = t3, this.publicKey = i2 || "", this.url = e3.get("url"), this.id = "", this.formData = null, this.feedback = { text: "", answers: [], profile: [], metrics: [], metadata: [] }, this.history = new u.History(), this.graph = new l.PageGraph([]), this.progress = 0, this.total = 0, this.completed = false, this.timeToCompleted = 0;
384
+ constructor(e3, t3, i2, n2, r2) {
385
+ this.config = e3, this.log = new s.Log(e3), this.formOptionsConfig = { addButton: true, sendButtonText: "Send", backButtonText: "Back", nextButtonText: "Next", 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.feedback = { text: "", answers: [], profile: null != n2 ? n2 : [], metrics: [], metadata: null != r2 ? r2 : [] }, this.history = new u.History(), this.graph = new l.PageGraph([]), this.progress = 0, this.total = 0, this.completed = false, this.timeToCompleted = 0;
385
386
  }
386
387
  generate(e3, t3) {
387
- var i2, a2, s2, o2, l2, d2, c2;
388
+ var i2, r2, s2, o2, l2, d2, c2;
388
389
  return n(this, void 0, void 0, (function* () {
389
390
  try {
390
391
  this.formOptionsConfig = Object.assign(Object.assign({}, this.formOptionsConfig), t3), this.selector = e3;
391
392
  let n2 = this.formData;
392
- if (void 0 !== this.formData && this.formData || (n2 = "" !== this.publicKey ? yield (0, r.getForm)(this.url, this.appId, this.publicKey, this.log) : yield (0, r.getSessionForm)(this.url, this.appId, this.log)), void 0 === n2 || !n2) throw new Error(`No data for app ${this.appId}`);
393
+ if (void 0 !== this.formData && this.formData || (n2 = "" !== this.publicKey ? yield (0, a.getForm)(this.url, this.appId, this.publicKey, this.log) : yield (0, a.getSessionForm)(this.url, this.appId, this.log)), void 0 === n2 || !n2) throw new Error(`No data for app ${this.appId}`);
393
394
  if (null === (i2 = n2.error) || void 0 === i2 ? void 0 : i2.message) throw new Error(n2.error.message);
394
- if (n2.questions = (null === (a2 = n2.questions) || void 0 === a2 ? void 0 : a2.filter(((e4) => "ACTIVE" === e4.status))) || [], n2.pages = (null === (s2 = n2.pages) || void 0 === s2 ? void 0 : s2.filter(((e4) => "ACTIVE" === e4.status))) || [], null === (o2 = n2.pages) || void 0 === o2 || o2.forEach(((e4) => {
395
+ if (n2.questions = (null === (r2 = n2.questions) || void 0 === r2 ? void 0 : r2.filter(((e4) => "ACTIVE" === e4.status))) || [], n2.pages = (null === (s2 = n2.pages) || void 0 === s2 ? void 0 : s2.filter(((e4) => "ACTIVE" === e4.status))) || [], null === (o2 = n2.pages) || void 0 === o2 || o2.forEach(((e4) => {
395
396
  var t4;
396
397
  return e4.integrationQuestions = null === (t4 = e4.integrationQuestions) || void 0 === t4 ? void 0 : t4.filter(((e5) => "ACTIVE" === e5.status));
397
398
  })), this.formData = n2, this.formData.savedAt || (this.formData.savedAt = /* @__PURE__ */ new Date(), localStorage.setItem(`magicfeedback-${this.appId}`, JSON.stringify(this.formData))), void 0 === this.formData.questions || !this.formData.questions) throw new Error(`No questions for app ${this.appId}`);
@@ -410,8 +411,8 @@ var require_magicfeedback_sdk_browser = __commonJS({
410
411
  case "MAGICSURVEY":
411
412
  this.formData.pages = [], null === (e3 = this.formData.questions) || void 0 === e3 || e3.forEach(((e4) => {
412
413
  var t4, i2;
413
- const n2 = new c.PageRoute(e4.id, e4.ref, c.OperatorType.NOEQUAL, [], c.TransitionType.PAGE, (e4.position + 1).toString(), e4.position.toString()), a2 = new d.Page(e4.position.toString(), e4.position, this.appId, [e4], [n2]);
414
- null === (i2 = null === (t4 = this.formData) || void 0 === t4 ? void 0 : t4.pages) || void 0 === i2 || i2.push(a2);
414
+ const n2 = new c.PageRoute(e4.id, e4.ref, c.OperatorType.NOEQUAL, [], c.TransitionType.PAGE, (e4.position + 1).toString(), e4.position.toString()), r2 = new d.Page(e4.position.toString(), e4.position, this.appId, [e4], [n2]);
415
+ null === (i2 = null === (t4 = this.formData) || void 0 === t4 ? void 0 : t4.pages) || void 0 === i2 || i2.push(r2);
415
416
  }));
416
417
  break;
417
418
  case "MAGICFORM":
@@ -425,25 +426,25 @@ var require_magicfeedback_sdk_browser = __commonJS({
425
426
  return e3.classList.add("magicfeedback-container"), e3.id = "magicfeedback-container-" + this.appId, e3.innerHTML = "", e3;
426
427
  }
427
428
  generateForm() {
428
- var e3, t3, i2, a2;
429
+ var e3, t3, i2, r2;
429
430
  return n(this, void 0, void 0, (function* () {
430
431
  try {
431
- if (console.log("Generating form for appId:", this.appId), !this.formData || !this.formData.pages || 0 === this.formData.pages.length) throw new Error("No form data");
432
+ if (!this.formData || !this.formData.pages || 0 === this.formData.pages.length) throw new Error("No form data");
432
433
  this.graph = new l.PageGraph(this.formData.pages.sort(((e4, t4) => e4.position - t4.position)));
433
434
  let n2 = this.generateContainer();
434
435
  const s2 = document.createElement("form");
435
436
  s2.classList.add("magicfeedback-form"), s2.id = "magicfeedback-" + this.appId, s2.addEventListener("submit", ((e4) => e4.preventDefault()));
436
- const r2 = document.createElement("div");
437
- r2.classList.add("magicfeedback-questions"), r2.id = "magicfeedback-questions-" + this.appId;
437
+ const a2 = document.createElement("div");
438
+ a2.classList.add("magicfeedback-questions"), a2.id = "magicfeedback-questions-" + this.appId;
438
439
  const d2 = this.graph.getFirstPage();
439
440
  if (!d2) throw new Error("No page found");
440
- if (this.total = this.graph.findMaxDepth(), d2.elements = (0, o.renderQuestions)(d2.questions, this.formOptionsConfig.questionFormat, null === (e3 = this.formData) || void 0 === e3 ? void 0 : e3.lang[0], null === (t3 = this.formData) || void 0 === t3 ? void 0 : t3.product, (() => this.send())), null === (i2 = d2.elements) || void 0 === i2 || i2.forEach(((e4) => r2.appendChild(e4))), s2.appendChild(r2), this.history.enqueue(d2), n2.appendChild(s2), this.progress = this.total - this.graph.findMaxDepth(d2), this.formOptionsConfig.addButton) {
441
- const e4 = (0, o.renderActions)(null === (a2 = this.formData) || void 0 === a2 ? void 0 : a2.identity, (() => this.back()), this.formOptionsConfig.sendButtonText, this.formOptionsConfig.backButtonText, this.formOptionsConfig.nextButtonText);
441
+ if (this.total = this.graph.findMaxDepth(), d2.elements = (0, o.renderQuestions)(d2.questions, this.formOptionsConfig.questionFormat, null === (e3 = this.formData) || void 0 === e3 ? void 0 : e3.lang[0], null === (t3 = this.formData) || void 0 === t3 ? void 0 : t3.product, (() => this.send())), null === (i2 = d2.elements) || void 0 === i2 || i2.forEach(((e4) => a2.appendChild(e4))), s2.appendChild(a2), this.history.enqueue(d2), n2.appendChild(s2), this.progress = this.total - this.graph.findMaxDepth(d2), this.formOptionsConfig.addButton) {
442
+ const e4 = (0, o.renderActions)(null === (r2 = this.formData) || void 0 === r2 ? void 0 : r2.identity, (() => this.back()), this.formOptionsConfig.sendButtonText, this.formOptionsConfig.backButtonText, this.formOptionsConfig.nextButtonText);
442
443
  s2.appendChild(e4);
443
444
  }
444
445
  this.formOptionsConfig.addButton && s2.addEventListener("submit", ((e4) => {
445
446
  e4.preventDefault(), this.send();
446
- })), this.timeToCompleted = (/* @__PURE__ */ new Date()).getTime() / 1e3, this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, progress: this.progress, total: this.total, formData: this.formData }));
447
+ })), this.timeToCompleted = Date.now(), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, progress: this.progress, total: this.total, formData: this.formData, formOptionsConfig: this.formOptionsConfig }));
447
448
  } catch (e4) {
448
449
  return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 }));
449
450
  }
@@ -463,7 +464,12 @@ var require_magicfeedback_sdk_browser = __commonJS({
463
464
  }));
464
465
  }
465
466
  getMetaData() {
466
- this.feedback.metadata.push({ key: "navigator-url", value: [window.location.href] }), this.feedback.metadata.push({ key: "navigator-origin", value: [window.location.origin] }), this.feedback.metadata.push({ key: "navigator-pathname", value: [window.location.pathname] }), this.feedback.metadata.push({ key: "navigator-search", value: [window.location.search] }), this.feedback.metadata.push({ key: "navigator-user", value: [navigator.userAgent] }), this.feedback.metadata.push({ key: "navigator-language", value: [navigator.language] }), this.feedback.metadata.push({ key: "navigator-platform", value: [navigator.platform] }), this.feedback.metadata.push({ key: "navigator-appVersion", value: [navigator.appVersion] }), this.feedback.metadata.push({ key: "navigator-appName", value: [navigator.appName] }), this.feedback.metadata.push({ key: "navigator-product", value: [navigator.product] }), this.feedback.metadata.push({ key: "screen-width", value: [window.screen.width.toString()] }), this.feedback.metadata.push({ key: "screen-height", value: [window.screen.height.toString()] }), this.appId && "" === this.publicKey && this.feedback.metadata.push({ key: "MAGICFEEDBACK_SESSION", value: [this.appId] });
467
+ this.formOptionsConfig.customMetaData && (this.feedback.metadata = [...this.feedback.metadata, ...this.formOptionsConfig.customMetaData]), this.feedback.metadata.push({ key: "navigator-url", value: [window.location.href] }), this.feedback.metadata.push({ key: "navigator-origin", value: [window.location.origin] }), this.feedback.metadata.push({ key: "navigator-pathname", value: [window.location.pathname] }), this.feedback.metadata.push({ key: "navigator-search", value: [window.location.search] });
468
+ const e3 = new URLSearchParams(window.location.search);
469
+ Array.from(new Set(e3.keys())).forEach(((t3) => {
470
+ const i2 = e3.getAll(t3);
471
+ i2.length > 0 && this.feedback.metadata.push({ key: `query-${t3}`, value: i2 });
472
+ })), this.feedback.metadata.push({ key: "navigator-user", value: [navigator.userAgent] }), this.feedback.metadata.push({ key: "navigator-language", value: [navigator.language] }), this.feedback.metadata.push({ key: "navigator-platform", value: [navigator.platform] }), this.feedback.metadata.push({ key: "navigator-appVersion", value: [navigator.appVersion] }), this.feedback.metadata.push({ key: "navigator-appName", value: [navigator.appName] }), this.feedback.metadata.push({ key: "navigator-product", value: [navigator.product] }), this.feedback.metadata.push({ key: "screen-width", value: [window.screen.width.toString()] }), this.feedback.metadata.push({ key: "screen-height", value: [window.screen.height.toString()] }), this.appId && "" === this.publicKey && this.feedback.metadata.push({ key: "MAGICFEEDBACK_SESSION", value: [this.appId] });
467
473
  }
468
474
  send(e3, t3, i2) {
469
475
  return n(this, void 0, void 0, (function* () {
@@ -472,17 +478,28 @@ var require_magicfeedback_sdk_browser = __commonJS({
472
478
  i2 && (this.feedback.profile = [...this.feedback.profile, ...i2]), t3 && (this.feedback.metrics = [...this.feedback.metrics, ...t3]), e3 && (this.feedback.metadata = [...this.feedback.metadata, ...e3]), this.answer(), this.formOptionsConfig.beforeSubmitEvent && (yield this.formOptionsConfig.beforeSubmitEvent({ loading: true, progress: this.progress, total: this.total }));
473
479
  const s2 = this.history.back();
474
480
  if (!s2) throw new Error("No page found");
475
- for (const e4 of s2.questions.filter(((e5) => e5.require && ![a.FEEDBACKAPPANSWERTYPE.CONSENT, a.FEEDBACKAPPANSWERTYPE.INFO_PAGE].includes(e5.type)))) {
481
+ for (const e4 of s2.questions.filter(((e5) => e5.require && ![r.FEEDBACKAPPANSWERTYPE.CONSENT, r.FEEDBACKAPPANSWERTYPE.INFO_PAGE].includes(e5.type)))) {
476
482
  const t4 = e4.assets, i3 = this.feedback.answers.filter(((t5) => t5.key.includes(e4.ref) && !t5.key.includes("extra-option")));
477
483
  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");
478
484
  if (null == t4 ? void 0 : t4.minOptions) {
479
485
  let n3 = [];
480
486
  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");
481
487
  }
488
+ if (e4.type === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) {
489
+ const i4 = this.feedback.answers.find(((t5) => t5.key === e4.ref));
490
+ if (!i4) throw this.log.err(`The matrix question ${e4.ref} is required`), new Error("No response");
491
+ const n3 = this.parseMatrixAnswerPre(i4), r2 = Array.isArray(null == t4 ? void 0 : t4.options) ? t4.options : [];
492
+ if (r2.length > 0) {
493
+ if (r2.find(((e5) => {
494
+ const t5 = n3.find(((t6) => t6.key === e5));
495
+ return !t5 || !Array.isArray(t5.value) || 0 === t5.value.length;
496
+ }))) throw this.log.err(`The matrix question ${e4.ref} requires an answer in every row`), new Error("No response");
497
+ } 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");
498
+ }
482
499
  }
483
- const r2 = yield this.pushAnswers(false);
484
- if (!r2) throw new Error("No response");
485
- this.id = r2, yield this.processNextQuestion(n2);
500
+ const a2 = yield this.pushAnswers(false);
501
+ if (!a2) throw new Error("No response");
502
+ this.id = a2, yield this.processNextQuestion(n2);
486
503
  } catch (e4) {
487
504
  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 }));
488
505
  }
@@ -490,86 +507,108 @@ var require_magicfeedback_sdk_browser = __commonJS({
490
507
  }
491
508
  answer() {
492
509
  const e3 = document.getElementById("magicfeedback-" + this.appId);
493
- if (!e3) return this.log.err(`Form "${e3}" not found.`), void (this.feedback.answers = []);
510
+ if (!e3) return this.log.err(`Form "${e3}" not found.`), this.feedback.answers = [], [];
494
511
  const t3 = this.history.back();
495
- if (!t3) throw new Error("No page found");
512
+ if (!t3) {
513
+ const t4 = e3.querySelectorAll(".magicfeedback-input"), i3 = [], n3 = {};
514
+ return t4.forEach(((e4) => {
515
+ var t5;
516
+ const r2 = e4, s3 = r2.name;
517
+ if (!s3) return;
518
+ const a2 = r2.type;
519
+ if (("radio" === a2 || "checkbox" === a2) && !r2.checked) return;
520
+ const o3 = r2.value, l3 = r2.classList[0];
521
+ if ((null == l3 ? void 0 : l3.includes("magicfeedback-priority-list")) || (null === (t5 = r2.id) || void 0 === t5 ? void 0 : t5.startsWith("priority-list-"))) return n3[s3] || (n3[s3] = []), void n3[s3].push(o3);
522
+ const d3 = "magicfeedback-consent" === l3 ? r2.checked.toString() : o3;
523
+ if (null == d3) return;
524
+ const c2 = { key: s3, value: [d3] };
525
+ i3.push(c2);
526
+ })), Object.entries(n3).forEach((([e4, t5]) => {
527
+ const n4 = t5.slice().sort(((e5, t6) => Number(e5.split(".")[0]) - Number(t6.split(".")[0])));
528
+ i3.push({ key: e4, value: n4 });
529
+ })), this.feedback.answers = i3, i3;
530
+ }
496
531
  const i2 = [];
497
532
  let n2 = false;
498
- if (e3.querySelectorAll(".magicfeedback-input").forEach(((e4) => {
499
- const s2 = t3.questions.find(((t4) => {
500
- var i3;
501
- return null === (i3 = e4.name) || void 0 === i3 ? void 0 : i3.includes(t4.ref);
502
- })), o2 = e4.type, l2 = e4.classList[0], d2 = { key: e4.name, value: [] }, c2 = "magicfeedback-consent" === l2 ? e4.checked.toString() : e4.value;
503
- if (d2.key && "" !== d2.key) {
504
- switch (null == s2 ? void 0 : s2.type) {
505
- case a.FEEDBACKAPPANSWERTYPE.EMAIL:
506
- case a.FEEDBACKAPPANSWERTYPE.TEXT:
507
- case a.FEEDBACKAPPANSWERTYPE.LONGTEXT:
508
- case a.FEEDBACKAPPANSWERTYPE.NUMBER:
509
- case a.FEEDBACKAPPANSWERTYPE.DATE:
510
- case a.FEEDBACKAPPANSWERTYPE.CONTACT:
511
- if ("" !== c2) {
512
- if ("email" === o2) {
513
- if (!(0, r.validateEmail)(c2)) {
514
- this.log.err("Invalid email"), n2 = true;
515
- break;
516
- }
517
- this.feedback.profile.push({ key: "email", value: [c2] });
518
- }
519
- d2.value.push(c2);
520
- }
521
- break;
522
- case a.FEEDBACKAPPANSWERTYPE.CONSENT:
523
- d2.value.push(String(e4.checked));
524
- break;
525
- case a.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM:
526
- const t4 = e4.id;
527
- d2.value.push(`${t4}:${c2}%`);
528
- break;
529
- case a.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE:
530
- case a.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE:
531
- case a.FEEDBACKAPPANSWERTYPE.RATING_STAR:
532
- case a.FEEDBACKAPPANSWERTYPE.RADIO:
533
- case a.FEEDBACKAPPANSWERTYPE.RATING_EMOJI:
534
- case a.FEEDBACKAPPANSWERTYPE.RATING_NUMBER:
535
- (e4.checked || e4.id.includes("extra-option-")) && d2.value.push(c2);
536
- break;
537
- case a.FEEDBACKAPPANSWERTYPE.SELECT:
538
- d2.value.push(c2);
539
- break;
540
- case a.FEEDBACKAPPANSWERTYPE.BOOLEAN:
541
- case a.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX:
542
- e4.checked && d2.value.push(c2);
543
- break;
544
- case a.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST:
545
- d2.value.push(c2);
546
- }
547
- if ((null == i2 ? void 0 : i2.length) > 0 && (null == i2 ? void 0 : i2.find(((e5) => e5.key === d2.key)))) {
548
- const e5 = i2.findIndex(((e6) => e6.key === d2.key));
549
- i2[e5].value = [...i2[e5].value, ...d2.value];
550
- } else i2.push(d2);
533
+ const s2 = e3.querySelectorAll(".magicfeedback-input"), o2 = {}, l2 = {}, d2 = {};
534
+ if (s2.forEach(((e4) => {
535
+ const s3 = e4, c2 = t3.questions.find(((e5) => {
536
+ var t4;
537
+ return null === (t4 = s3.name) || void 0 === t4 ? void 0 : t4.includes(e5.ref);
538
+ })), u2 = s3.type, p2 = s3.classList[0], m = { key: s3.name, value: [] }, h = "magicfeedback-consent" === p2 ? s3.checked.toString() : s3.value;
539
+ if (m.key && "" !== m.key) if (m.key.startsWith("extra-option-")) "" !== h && (m.value.push(h), i2.push(m));
540
+ else switch (null == c2 ? void 0 : c2.type) {
541
+ case r.FEEDBACKAPPANSWERTYPE.EMAIL:
542
+ case r.FEEDBACKAPPANSWERTYPE.TEXT:
543
+ case r.FEEDBACKAPPANSWERTYPE.LONGTEXT:
544
+ case r.FEEDBACKAPPANSWERTYPE.NUMBER:
545
+ case r.FEEDBACKAPPANSWERTYPE.DATE:
546
+ case r.FEEDBACKAPPANSWERTYPE.CONTACT:
547
+ case r.FEEDBACKAPPANSWERTYPE.PASSWORD:
548
+ "" !== h && ("email" === u2 ? (0, a.validateEmail)(h) ? (this.feedback.profile.push({ key: "email", value: [h] }), m.value.push(h), i2.push(m)) : (this.log.err("Invalid email"), n2 = true) : (m.value.push(h), i2.push(m)));
549
+ break;
550
+ case r.FEEDBACKAPPANSWERTYPE.RADIO:
551
+ s3.checked && (m.value.push(h), i2.push(m));
552
+ break;
553
+ case r.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE:
554
+ case r.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE:
555
+ s3.checked && (l2[m.key] || (l2[m.key] = []), l2[m.key].push(h));
556
+ break;
557
+ case r.FEEDBACKAPPANSWERTYPE.BOOLEAN:
558
+ s3.checked && (m.value.push(h), i2.push(m));
559
+ break;
560
+ case r.FEEDBACKAPPANSWERTYPE.CONSENT:
561
+ m.value.push(s3.checked.toString()), i2.push(m);
562
+ break;
563
+ case r.FEEDBACKAPPANSWERTYPE.RATING_EMOJI:
564
+ case r.FEEDBACKAPPANSWERTYPE.RATING_NUMBER:
565
+ case r.FEEDBACKAPPANSWERTYPE.RATING_STAR:
566
+ s3.checked && (m.value.push(h), i2.push(m));
567
+ break;
568
+ case r.FEEDBACKAPPANSWERTYPE.SELECT:
569
+ "" !== h && (m.value.push(h), i2.push(m));
570
+ break;
571
+ case r.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM:
572
+ "number" === u2 && s3.id && (d2[m.key] || (d2[m.key] = []), "" !== h && d2[m.key].push(`${s3.id}:${h}%`));
573
+ break;
574
+ case r.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST:
575
+ "hidden" === u2 && (o2[m.key] || (o2[m.key] = []), o2[m.key].push(h));
576
+ break;
577
+ case r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX:
578
+ e4.checked && (m.value.push(h), i2.push(m));
579
+ case r.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE:
580
+ case r.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE:
551
581
  }
552
- })), n2) return this.feedback.answers = [], void t3.setAnswer([]);
582
+ })), n2) return [];
583
+ Object.entries(l2).forEach((([e4, t4]) => {
584
+ t4 && 0 !== t4.length && i2.push({ key: e4, value: t4 });
585
+ })), Object.entries(d2).forEach((([e4, t4]) => {
586
+ t4 && 0 !== t4.length && i2.push({ key: e4, value: t4 });
587
+ })), Object.entries(o2).forEach((([e4, t4]) => {
588
+ if (!t4 || 0 === t4.length) return;
589
+ const n3 = t4.slice().sort(((e5, t5) => Number(e5.split(".")[0]) - Number(t5.split(".")[0])));
590
+ i2.push({ key: e4, value: n3 });
591
+ }));
553
592
  try {
554
- t3.questions.filter(((e4) => e4.type === a.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX)).forEach(((e4) => {
593
+ t3.questions.filter(((e4) => e4.type === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX)).forEach(((e4) => {
555
594
  const t4 = e4.ref + "-", n3 = i2.filter(((e5) => e5.key.startsWith(t4)));
556
595
  if (0 === n3.length) return;
557
- const a2 = n3.map(((e5) => ({ key: e5.key.substring(t4.length), value: e5.value }))), s2 = { key: e4.ref, value: [JSON.stringify(a2)] };
596
+ const r2 = n3.map(((e5) => ({ key: e5.key.substring(t4.length), value: e5.value }))), s3 = { key: e4.ref, value: [JSON.stringify(r2)] };
558
597
  for (const e5 of n3) {
559
598
  const t5 = i2.findIndex(((t6) => t6.key === e5.key));
560
599
  -1 !== t5 && i2.splice(t5, 1);
561
600
  }
562
- const r2 = i2.findIndex(((t5) => t5.key === e4.ref));
563
- -1 !== r2 ? i2[r2] = s2 : i2.push(s2);
601
+ const a2 = i2.findIndex(((t5) => t5.key === e4.ref));
602
+ -1 !== a2 ? i2[a2] = s3 : i2.push(s3);
564
603
  }));
565
604
  } catch (e4) {
566
605
  this.log.err("Error agrupando MULTI_QUESTION_MATRIX", e4);
567
606
  }
568
- this.feedback.answers = i2, t3.setAnswer(i2);
607
+ return this.feedback.answers = i2, t3.setAnswer(i2), i2;
569
608
  }
570
609
  finish() {
571
610
  return n(this, void 0, void 0, (function* () {
572
- if (this.completed = true, this.timeToCompleted = (/* @__PURE__ */ new Date()).getTime() - this.timeToCompleted, this.feedback.metadata.push({ key: "time-to-complete", value: [this.timeToCompleted.toString()] }), this.formOptionsConfig.addSuccessScreen) {
611
+ if (this.completed = true, this.timeToCompleted = Date.now() - this.timeToCompleted, this.feedback.metadata.push({ key: "time-to-complete", value: [this.timeToCompleted.toString()] }), this.formOptionsConfig.addSuccessScreen) {
573
612
  const e3 = document.getElementById("magicfeedback-container-" + this.appId);
574
613
  e3.childNodes.length > 0 && e3.removeChild(e3.childNodes[0]);
575
614
  const t3 = (0, o.renderSuccess)(this.formOptionsConfig.successMessage || "Thank you for your feedback!");
@@ -588,8 +627,12 @@ var require_magicfeedback_sdk_browser = __commonJS({
588
627
  pushAnswers(e3 = false) {
589
628
  return n(this, void 0, void 0, (function* () {
590
629
  try {
630
+ if (this.config.get("dryRun")) {
631
+ const e4 = this.id || `dry-run-${this.appId}-${Date.now()}`;
632
+ return this.log.log(`Dry run enabled: skipping feedback submit for form ${this.appId}`), e4;
633
+ }
591
634
  const t3 = this.config.get("url"), i2 = { integration: this.appId, publicKey: this.publicKey, feedback: this.feedback, completed: e3 };
592
- return yield (0, r.sendFeedback)(t3, this.id ? Object.assign(Object.assign({}, i2), { sessionId: this.id }) : i2, this.log);
635
+ return yield (0, a.sendFeedback)(t3, this.id ? Object.assign(Object.assign({}, i2), { sessionId: this.id }) : i2, this.log);
593
636
  } catch (e4) {
594
637
  return this.log.err(`An error occurred while submitting the form ${this.appId}:`, e4), "";
595
638
  }
@@ -600,83 +643,82 @@ var require_magicfeedback_sdk_browser = __commonJS({
600
643
  return n(this, void 0, void 0, (function* () {
601
644
  if (!(null == e3 ? void 0 : e3.followup)) return null;
602
645
  try {
646
+ if (this.config.get("dryRun")) return this.log.log(`Dry run enabled: skipping follow up API for question ${e3.ref}`), null;
603
647
  if (0 === this.feedback.answers.length) throw new Error("No answers provided");
604
648
  const i2 = this.config.get("url"), n2 = Object.assign(Object.assign(Object.assign({ answer: null === (t3 = this.feedback.answers.find(((t4) => t4.key === e3.ref))) || void 0 === t3 ? void 0 : t3.value[0] }, "" !== this.publicKey && { publicKey: this.publicKey }), "" === this.publicKey && { campaignSessionId: this.appId }), { sessionId: this.id, question: e3 });
605
- return yield (0, r.getFollowUpQuestion)(i2, n2, this.log);
649
+ return yield (0, a.getFollowUpQuestion)(i2, n2, this.log);
606
650
  } catch (e4) {
607
651
  throw this.log.err(`An error occurred while submitting the form ${this.appId}:`, e4), e4;
608
652
  }
609
653
  }));
610
654
  }
611
655
  processNextQuestion(e3) {
612
- var t3, i2, a2;
656
+ var t3, i2, r2;
613
657
  return n(this, void 0, void 0, (function* () {
614
658
  const n2 = this.history.back();
615
659
  if (!n2) throw new Error("No page found");
616
660
  const s2 = n2.getFollowupQuestions();
617
661
  if (0 === (null == s2 ? void 0 : s2.length)) return void (yield this.renderNextQuestion(e3, n2));
618
- const r2 = [];
662
+ const a2 = [];
619
663
  for (const e4 of s2) {
620
664
  const t4 = n2.questions.find(((t5) => t5.ref === e4));
621
665
  if (t4) {
622
666
  const e5 = yield this.callFollowUpQuestion(t4);
623
- e5 && r2.push(e5);
667
+ e5 && a2.push(e5);
624
668
  }
625
669
  }
626
- if (0 === r2.length) return void (yield this.renderNextQuestion(e3, n2));
627
- const l2 = new d.Page(n2.id, n2.position, this.appId, r2, n2.edges), c2 = new p.PageNode(n2.id, n2.position, n2.edges, l2, r2, true);
628
- c2.elements = (0, o.renderQuestions)(r2, this.formOptionsConfig.questionFormat, null === (t3 = this.formData) || void 0 === t3 ? void 0 : t3.lang[0], null === (i2 = this.formData) || void 0 === i2 ? void 0 : i2.product, (() => this.send())), this.history.enqueue(c2), this.progress += 0.5, e3.innerHTML = "", null === (a2 = c2.elements) || void 0 === a2 || a2.forEach(((t4) => e3.appendChild(t4))), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.id, loading: false, progress: this.progress, total: this.total, followup: c2.isFollowup, completed: this.completed, error: null }));
670
+ if (0 === a2.length) return void (yield this.renderNextQuestion(e3, n2));
671
+ const l2 = new d.Page(n2.id, n2.position, this.appId, a2, n2.edges), c2 = new p.PageNode(n2.id, n2.position, n2.edges, l2, a2, true);
672
+ c2.elements = (0, o.renderQuestions)(a2, this.formOptionsConfig.questionFormat, null === (t3 = this.formData) || void 0 === t3 ? void 0 : t3.lang[0], null === (i2 = this.formData) || void 0 === i2 ? void 0 : i2.product, (() => this.send())), this.history.enqueue(c2), this.progress += 0.5, e3.innerHTML = "", null === (r2 = c2.elements) || void 0 === r2 || r2.forEach(((t4) => e3.appendChild(t4))), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.id, loading: false, progress: this.progress, total: this.total, followup: c2.isFollowup, completed: this.completed, error: null }));
629
673
  }));
630
674
  }
631
675
  renderNextQuestion(e3, t3) {
632
- var i2, s2, r2, l2, d2;
676
+ var i2, s2, a2, l2, d2;
633
677
  return n(this, void 0, void 0, (function* () {
634
678
  let n2 = this.graph.getNextPage(t3, this.feedback.answers);
635
679
  if (!n2) return void this.finish();
636
680
  const u2 = n2.edges.filter(((e4) => "PRECONDITIONAL" === e4.typeCondition)).sort(((e4, t4) => e4.position < t4.position ? -1 : e4.position > t4.position ? 1 : 0));
637
681
  if ((null == u2 ? void 0 : u2.length) > 0) {
638
- let t4 = null;
639
- const r3 = u2.map(((e4) => e4.questionRef));
640
- for (let e4 = this.history.size() - 1; e4 >= 0; e4--) {
641
- const n3 = this.history.get(e4);
642
- if (n3 && (t4 = null === (i2 = n3.answers) || void 0 === i2 ? void 0 : i2.find(((e5) => r3.includes(e5.key))), t4)) break;
643
- }
644
- let o2 = !u2.some(((e4) => e4.transition === c.TransitionType.ALLOW));
645
- if (t4) for (const i3 of u2) {
646
- let r4 = false;
647
- const l3 = null === (s2 = this.formData) || void 0 === s2 ? void 0 : s2.questions.find(((e4) => e4.ref === i3.questionRef)), d3 = Array.isArray(t4.value) ? t4.value : [t4.value], u3 = Array.isArray(i3.value) ? i3.value : [i3.value];
648
- if ((null == l3 ? void 0 : l3.type) === a.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) r4 = this.evaluateMatrixPreconditional(i3, t4);
649
- else switch (i3.typeOperator) {
650
- case "EQUAL":
651
- case "INQ":
652
- r4 = d3.some(((e4) => u3.includes(e4)));
653
- break;
654
- case "NOEQUAL":
655
- case "NINQ":
656
- r4 = d3.every(((e4) => !u3.includes(e4)));
657
- break;
658
- case "GREATER":
659
- r4 = d3.some(((e4) => Number(e4) > Number(u3[0])));
660
- break;
661
- case "LESS":
662
- r4 = d3.some(((e4) => Number(e4) < Number(u3[0])));
663
- break;
664
- case "GREATEREQUAL":
665
- r4 = d3.some(((e4) => Number(e4) >= Number(u3[0])));
666
- break;
667
- case "LESSEQUAL":
668
- r4 = d3.some(((e4) => Number(e4) <= Number(u3[0])));
682
+ const t4 = u2.some(((e4) => e4.transition === c.TransitionType.ALLOW));
683
+ let a3 = t4;
684
+ for (const t5 of u2) {
685
+ let o2;
686
+ for (let e4 = this.history.size() - 1; e4 >= 0; e4--) {
687
+ const n3 = this.history.get(e4);
688
+ if (n3 && (o2 = null === (i2 = n3.answers) || void 0 === i2 ? void 0 : i2.find(((e5) => e5.key === t5.questionRef)), o2)) break;
669
689
  }
670
- if (r4) switch (this.feedback.answers = [], i3.transition) {
671
- case c.TransitionType.NEXT:
672
- return void (n2 && (yield this.renderNextQuestion(e3, n2)));
673
- case c.TransitionType.ALLOW:
674
- o2 = true;
690
+ let l3 = false;
691
+ if (o2) {
692
+ const e4 = null === (s2 = this.formData) || void 0 === s2 ? void 0 : s2.questions.find(((e5) => e5.ref === t5.questionRef)), i3 = Array.isArray(o2.value) ? o2.value : [o2.value], n3 = Array.isArray(t5.value) ? t5.value : [t5.value];
693
+ if ((null == e4 ? void 0 : e4.type) === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) l3 = this.evaluateMatrixPreconditional(t5, o2);
694
+ else switch (t5.typeOperator) {
695
+ case "EQUAL":
696
+ case "INQ":
697
+ l3 = i3.some(((e5) => n3.includes(e5)));
698
+ break;
699
+ case "NOEQUAL":
700
+ case "NINQ":
701
+ l3 = i3.every(((e5) => !n3.includes(e5)));
702
+ break;
703
+ case "GREATER":
704
+ l3 = i3.some(((e5) => Number(e5) > Number(n3[0])));
705
+ break;
706
+ case "LESS":
707
+ l3 = i3.some(((e5) => Number(e5) < Number(n3[0])));
708
+ break;
709
+ case "GREATEREQUAL":
710
+ l3 = i3.some(((e5) => Number(e5) >= Number(n3[0])));
711
+ break;
712
+ case "LESSEQUAL":
713
+ l3 = i3.some(((e5) => Number(e5) <= Number(n3[0])));
714
+ }
675
715
  }
716
+ if (t5.transition === c.TransitionType.ALLOW) l3 || (a3 = false);
717
+ else if (t5.transition === c.TransitionType.NEXT && l3) return this.feedback.answers = [], void (n2 && (yield this.renderNextQuestion(e3, n2)));
676
718
  }
677
- if (!o2) return this.feedback.answers = [], void (n2 && (yield this.renderNextQuestion(e3, n2)));
719
+ if (t4 && !a3) return this.feedback.answers = [], void (n2 && (yield this.renderNextQuestion(e3, n2)));
678
720
  }
679
- n2.elements = (0, o.renderQuestions)(n2.questions, this.formOptionsConfig.questionFormat, null === (r2 = this.formData) || void 0 === r2 ? void 0 : r2.lang[0], null === (l2 = this.formData) || void 0 === l2 ? void 0 : l2.product, (() => this.send())), e3.innerHTML = "", null === (d2 = n2.elements) || void 0 === d2 || d2.forEach(((t4) => e3.appendChild(t4))), this.history.enqueue(n2), this.progress = this.total - this.graph.findMaxDepth(n2), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.id, loading: false, progress: this.progress, total: this.total, followup: n2.isFollowup, completed: this.completed, error: null }));
721
+ n2.elements = (0, o.renderQuestions)(n2.questions, this.formOptionsConfig.questionFormat, null === (a2 = this.formData) || void 0 === a2 ? void 0 : a2.lang[0], null === (l2 = this.formData) || void 0 === l2 ? void 0 : l2.product, (() => this.send())), e3.innerHTML = "", null === (d2 = n2.elements) || void 0 === d2 || d2.forEach(((t4) => e3.appendChild(t4))), this.history.enqueue(n2), this.progress = this.total - this.graph.findMaxDepth(n2), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.id, loading: false, progress: this.progress, total: this.total, followup: n2.isFollowup, completed: this.completed, error: null }));
680
722
  }));
681
723
  }
682
724
  back() {
@@ -690,25 +732,25 @@ var require_magicfeedback_sdk_browser = __commonJS({
690
732
  }));
691
733
  }
692
734
  previewQuestion(e3, t3, i2) {
693
- var n2, a2;
735
+ var n2, r2;
694
736
  const s2 = Array.isArray(t3) ? t3 : [t3];
695
737
  if (!s2 || 0 === s2.length) throw new Error("[MagicFeedback] No question provided for preview");
696
- const r2 = document.getElementById(e3);
697
- if (!r2) throw new Error(`[MagicFeedback] Element with ID '${e3}' not found.`);
698
- const { format: l2 = this.formOptionsConfig.questionFormat || "standard", language: d2 = (null === (n2 = this.formData) || void 0 === n2 ? void 0 : n2.lang) && this.formData.lang[0] || "en", product: c2 = (null === (a2 = this.formData) || void 0 === a2 ? void 0 : a2.product) || { customIcons: false }, clearContainer: u2 = true, wrap: p2 = true } = i2 || {};
699
- u2 && (r2.innerHTML = "");
700
- let h = [];
738
+ const a2 = document.getElementById(e3);
739
+ if (!a2) throw new Error(`[MagicFeedback] Element with ID '${e3}' not found.`);
740
+ const { format: l2 = this.formOptionsConfig.questionFormat || "standard", language: d2 = (null === (n2 = this.formData) || void 0 === n2 ? void 0 : n2.lang) && this.formData.lang[0] || "en", product: c2 = (null === (r2 = this.formData) || void 0 === r2 ? void 0 : r2.product) || { customIcons: false }, clearContainer: u2 = true, wrap: p2 = true } = i2 || {};
741
+ u2 && (a2.innerHTML = "");
742
+ let m = [];
701
743
  try {
702
- h = (0, o.renderQuestions)(s2, l2, d2, c2);
744
+ m = (0, o.renderQuestions)(s2, l2, d2, c2);
703
745
  } catch (e4) {
704
746
  throw this.log.err(e4), e4;
705
747
  }
706
- let m = r2;
748
+ let h = a2;
707
749
  if (p2) {
708
750
  const e4 = document.createElement("div");
709
- e4.classList.add("magicfeedback-preview-question"), m.appendChild(e4), m = e4;
751
+ e4.classList.add("magicfeedback-preview-question"), h.appendChild(e4), h = e4;
710
752
  }
711
- return h.forEach(((e4) => m.appendChild(e4))), r2;
753
+ return m.forEach(((e4) => h.appendChild(e4))), a2;
712
754
  }
713
755
  parseMatrixAnswerPre(e3) {
714
756
  if (!e3 || !e3.value) return [];
@@ -721,9 +763,9 @@ var require_magicfeedback_sdk_browser = __commonJS({
721
763
  return Array.isArray(e3.value) && e3.value.length > 0 && "object" == typeof e3.value[0] && null !== e3.value[0] && "key" in e3.value[0] ? e3.value : [];
722
764
  }
723
765
  evaluateMatrixPreconditional(e3, t3) {
724
- const i2 = Array.isArray(e3.value) ? e3.value : [e3.value], n2 = new Set(e3.option || []), a2 = this.parseMatrixAnswerPre(t3);
725
- if (!a2.length) return false;
726
- const s2 = n2.size > 0 ? a2.filter(((e4) => n2.has(e4.key))) : a2;
766
+ const i2 = Array.isArray(e3.value) ? e3.value : [e3.value], n2 = new Set(e3.option || []), r2 = this.parseMatrixAnswerPre(t3);
767
+ if (!r2.length) return false;
768
+ const s2 = n2.size > 0 ? r2.filter(((e4) => n2.has(e4.key))) : r2;
727
769
  if (!s2.length) return false;
728
770
  switch (e3.typeOperator) {
729
771
  case "EQUAL":
@@ -748,14 +790,14 @@ var require_magicfeedback_sdk_browser = __commonJS({
748
790
  }, 700: (e2, t2) => {
749
791
  "use strict";
750
792
  Object.defineProperty(t2, "__esModule", { value: true }), t2.Page = void 0, t2.Page = class {
751
- constructor(e3, t3, i, n, a) {
752
- this.id = e3, this.position = t3, this.generatedAt = (/* @__PURE__ */ new Date()).toISOString(), this.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), this.status = "ACTIVE", this.integrationId = i, this.integrationQuestions = n, this.integrationPageRoutes = a;
793
+ constructor(e3, t3, i, n, r) {
794
+ this.id = e3, this.position = t3, this.generatedAt = (/* @__PURE__ */ new Date()).toISOString(), this.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), this.status = "ACTIVE", this.integrationId = i, this.integrationQuestions = n, this.integrationPageRoutes = r;
753
795
  }
754
796
  };
755
- }, 217: (e2, t2, i) => {
797
+ }, 989: (e2, t2, i) => {
756
798
  "use strict";
757
799
  Object.defineProperty(t2, "__esModule", { value: true }), t2.PageGraph = void 0;
758
- const n = i(636), a = i(558), s = i(591);
800
+ const n = i(636), r = i(558), s = i(591);
759
801
  t2.PageGraph = class {
760
802
  constructor(e3) {
761
803
  this.nodes = /* @__PURE__ */ new Map(), this.buildGraph(e3);
@@ -763,7 +805,10 @@ var require_magicfeedback_sdk_browser = __commonJS({
763
805
  buildGraph(e3) {
764
806
  e3.forEach(((e4) => {
765
807
  var t3;
766
- e4.integrationPageRoutes && (e4.integrationPageRoutes = (null === (t3 = e4.integrationPageRoutes) || void 0 === t3 ? void 0 : t3.sort(((e5, t4) => new Date((null == e5 ? void 0 : e5.generatedAt) || "").getTime() - new Date((null == t4 ? void 0 : t4.generatedAt) || "").getTime() ? "DIRECT" === e5.typeCondition ? 1 : -1 : 0))) || []);
808
+ e4.integrationPageRoutes && (e4.integrationPageRoutes = (null === (t3 = e4.integrationPageRoutes) || void 0 === t3 ? void 0 : t3.sort(((e5, t4) => {
809
+ const i3 = new Date((null == e5 ? void 0 : e5.generatedAt) || 0).getTime(), n2 = new Date((null == t4 ? void 0 : t4.generatedAt) || 0).getTime();
810
+ return i3 !== n2 ? i3 - n2 : "DIRECT" === e5.typeCondition && "DIRECT" !== t4.typeCondition ? 1 : "DIRECT" !== e5.typeCondition && "DIRECT" === t4.typeCondition ? -1 : 0;
811
+ }))) || []);
767
812
  const i2 = new n.PageNode(e4.id, e4.position, e4.integrationPageRoutes || [], e4, e4.integrationQuestions);
768
813
  this.nodes.set(i2.id, i2);
769
814
  }));
@@ -789,28 +834,28 @@ var require_magicfeedback_sdk_browser = __commonJS({
789
834
  if (!e3) return;
790
835
  e3.edges.sort(((e4, t4) => "DIRECT" === e4.typeCondition ? 1 : "DIRECT" === t4.typeCondition ? -1 : 0));
791
836
  const n2 = e3.edges.find(((i3) => {
792
- const n3 = e3.questions.find(((e4) => e4.ref === i3.questionRef)), r = null == t3 ? void 0 : t3.filter(((e4) => e4.key === i3.questionRef));
837
+ const n3 = e3.questions.find(((e4) => e4.ref === i3.questionRef)), a = null == t3 ? void 0 : t3.filter(((e4) => e4.key === i3.questionRef));
793
838
  if ("DIRECT" === i3.typeCondition) return true;
794
- if (!r || 0 === r.length) return false;
795
- if ((null == n3 ? void 0 : n3.type) === a.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) return this.evaluateMatrixCondition(i3, r);
839
+ if (!a || 0 === a.length) return false;
840
+ if ((null == n3 ? void 0 : n3.type) === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) return this.evaluateMatrixCondition(i3, a);
796
841
  const o = Array.isArray(i3.value) ? i3.value : [i3.value];
797
842
  switch (i3.typeOperator) {
798
843
  case s.OperatorType.EQUAL:
799
- return r.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.includes(e5)))));
844
+ return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.includes(e5)))));
800
845
  case s.OperatorType.NOEQUAL:
801
- return r.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !o.includes(e5)))));
846
+ return a.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !o.includes(e5)))));
802
847
  case s.OperatorType.GREATER:
803
- return r.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) > Number(t4)))))));
848
+ return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) > Number(t4)))))));
804
849
  case s.OperatorType.LESS:
805
- return r.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) < Number(t4)))))));
850
+ return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) < Number(t4)))))));
806
851
  case s.OperatorType.GREATEREQUAL:
807
- return r.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) >= Number(t4)))))));
852
+ return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) >= Number(t4)))))));
808
853
  case s.OperatorType.LESSEQUAL:
809
- return r.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) <= Number(t4)))))));
854
+ return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) <= Number(t4)))))));
810
855
  case s.OperatorType.INQ:
811
- return r.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.includes(e5)))));
856
+ return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.includes(e5)))));
812
857
  case s.OperatorType.NINQ:
813
- return r.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !o.includes(e5)))));
858
+ return a.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !o.includes(e5)))));
814
859
  default:
815
860
  return false;
816
861
  }
@@ -847,17 +892,17 @@ var require_magicfeedback_sdk_browser = __commonJS({
847
892
  DFSUtil(e3, t3, i2) {
848
893
  t3.add(e3);
849
894
  let n2 = i2;
850
- const a2 = [...e3.edges.filter(((e4) => e4.typeCondition !== s.ConditionType.PRECONDITIONAL)) || []], r = this.getNextEdgeByDefault(e3);
851
- if (r) {
852
- const i3 = this.getNodeById(r);
853
- i3 && !t3.has(i3) && a2.push(new s.PageRoute(i3.id, "", s.OperatorType.DEFAULT, [""], s.TransitionType.PAGE, i3.id, e3.id));
895
+ const r2 = [...e3.edges.filter(((e4) => e4.typeCondition !== s.ConditionType.PRECONDITIONAL)) || []], a = this.getNextEdgeByDefault(e3);
896
+ if (a) {
897
+ const i3 = this.getNodeById(a);
898
+ i3 && !t3.has(i3) && r2.push(new s.PageRoute(i3.id, "", s.OperatorType.DEFAULT, [""], s.TransitionType.PAGE, i3.id, e3.id));
854
899
  }
855
- for (const e4 of a2) {
900
+ for (const e4 of r2) {
856
901
  if (!e4.transitionDestiny) continue;
857
- const a3 = this.getNodeById(e4.transitionDestiny);
858
- if (a3 && !t3.has(a3)) {
859
- const e5 = i2 + 1, s2 = new Set(t3), r2 = this.DFSUtil(a3, s2, e5);
860
- n2 = Math.max(n2, r2);
902
+ const r3 = this.getNodeById(e4.transitionDestiny);
903
+ if (r3 && !t3.has(r3)) {
904
+ const e5 = i2 + 1, s2 = new Set(t3), a2 = this.DFSUtil(r3, s2, e5);
905
+ n2 = Math.max(n2, a2);
861
906
  }
862
907
  }
863
908
  return n2;
@@ -873,9 +918,9 @@ var require_magicfeedback_sdk_browser = __commonJS({
873
918
  return Array.isArray(e3.value) && e3.value.length > 0 && "object" == typeof e3.value[0] && null !== e3.value[0] && "key" in e3.value[0] ? e3.value : [];
874
919
  }
875
920
  evaluateMatrixCondition(e3, t3) {
876
- const i2 = Array.isArray(e3.value) ? e3.value : [e3.value], n2 = new Set(e3.option || []), a2 = t3[0], r = this.parseMatrixAnswer(a2);
877
- if (!r.length) return false;
878
- const o = n2.size > 0 ? r.filter(((e4) => n2.has(e4.key))) : r;
921
+ const i2 = Array.isArray(e3.value) ? e3.value : [e3.value], n2 = new Set(e3.option || []), r2 = t3[0], a = this.parseMatrixAnswer(r2);
922
+ if (!a.length) return false;
923
+ const o = n2.size > 0 ? a.filter(((e4) => n2.has(e4.key))) : a;
879
924
  if (!o.length) return false;
880
925
  switch (e3.typeOperator) {
881
926
  case s.OperatorType.EQUAL:
@@ -900,8 +945,8 @@ var require_magicfeedback_sdk_browser = __commonJS({
900
945
  }, 636: (e2, t2) => {
901
946
  "use strict";
902
947
  Object.defineProperty(t2, "__esModule", { value: true }), t2.PageNode = void 0, t2.PageNode = class {
903
- constructor(e3, t3, i, n, a, s = false) {
904
- this.answers = [], this.id = e3, this.position = t3, this.edges = i, this.data = n, this.questions = a.sort(((e4, t4) => e4.position - t4.position)), this.elements = [], this.isFollowup = s;
948
+ constructor(e3, t3, i, n, r, s = false) {
949
+ this.answers = [], this.id = e3, this.position = t3, this.edges = i, this.data = n, this.questions = r.sort(((e4, t4) => e4.position - t4.position)), this.elements = [], this.isFollowup = s;
905
950
  }
906
951
  getFollowupQuestions() {
907
952
  return this.questions.filter(((e3) => e3.followup)).map(((e3) => e3.ref));
@@ -915,14 +960,14 @@ var require_magicfeedback_sdk_browser = __commonJS({
915
960
  };
916
961
  }, 591: (e2, t2) => {
917
962
  "use strict";
918
- var i, n, a, s;
963
+ var i, n, r, s;
919
964
  Object.defineProperty(t2, "__esModule", { value: true }), t2.PageRoute = t2.StatusType = t2.OperatorType = t2.ConditionType = t2.TransitionType = void 0, (s = t2.TransitionType || (t2.TransitionType = {})).PAGE = "PAGE", s.FINISH = "FINISH", s.REDIRECT = "REDIRECT", s.NEXT = "NEXT", s.ALLOW = "ALLOW", (function(e3) {
920
965
  e3.LOGICAL = "LOGICAL", e3.DIRECT = "DIRECT", e3.PRECONDITIONAL = "PRECONDITIONAL";
921
- })(i = t2.ConditionType || (t2.ConditionType = {})), (a = t2.OperatorType || (t2.OperatorType = {})).EQUAL = "EQUAL", a.NOEQUAL = "NOEQUAL", a.GREATER = "GREATER", a.LESS = "LESS", a.GREATEREQUAL = "GREATEREQUAL", a.LESSEQUAL = "LESSEQUAL", a.INQ = "INQ", a.NINQ = "NINQ", a.DEFAULT = "DEFAULT", (function(e3) {
966
+ })(i = t2.ConditionType || (t2.ConditionType = {})), (r = t2.OperatorType || (t2.OperatorType = {})).EQUAL = "EQUAL", r.NOEQUAL = "NOEQUAL", r.GREATER = "GREATER", r.LESS = "LESS", r.GREATEREQUAL = "GREATEREQUAL", r.LESSEQUAL = "LESSEQUAL", r.INQ = "INQ", r.NINQ = "NINQ", r.DEFAULT = "DEFAULT", (function(e3) {
922
967
  e3.ACTIVE = "ACTIVE", e3.DEPRECATED = "DEPRECATED", e3.DELETE = "DELETE";
923
968
  })(n = t2.StatusType || (t2.StatusType = {})), t2.PageRoute = class {
924
- constructor(e3, t3, a2, s2, r, o, l, d, c, u) {
925
- this.id = e3, this.questionRef = t3, this.typeCondition = d || i.LOGICAL, this.typeOperator = a2, this.value = s2 || [], this.transition = r, this.transitionDestiny = o, this.status = n.ACTIVE, this.generatedAt = /* @__PURE__ */ new Date(), this.updatedAt = /* @__PURE__ */ new Date(), this.integrationPageId = l, this.position = c || 0, this.option = u || [];
969
+ constructor(e3, t3, r2, s2, a, o, l, d, c, u) {
970
+ this.id = e3, this.questionRef = t3, this.typeCondition = d || i.LOGICAL, this.typeOperator = r2, this.value = s2 || [], this.transition = a, this.transitionDestiny = o, this.status = n.ACTIVE, this.generatedAt = /* @__PURE__ */ new Date(), this.updatedAt = /* @__PURE__ */ new Date(), this.integrationPageId = l, this.position = c || 0, this.option = u || [];
926
971
  }
927
972
  };
928
973
  }, 558: (e2, t2) => {
@@ -932,6 +977,653 @@ var require_magicfeedback_sdk_browser = __commonJS({
932
977
  }, (function(e3) {
933
978
  e3.FORM = "form", e3.DIV = "div";
934
979
  })(i || (i = {}));
980
+ }, 516: (e2, t2) => {
981
+ "use strict";
982
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.getUrlParam = t2.getBooleanOptions = t2.parseTitle = void 0, t2.parseTitle = function(e3, t3) {
983
+ return e3 ? "object" == typeof e3 ? e3[t3] || e3.en : e3 : "";
984
+ }, t2.getBooleanOptions = function(e3) {
985
+ switch (e3) {
986
+ case "es":
987
+ return ["S\xED", "No"];
988
+ case "fr":
989
+ return ["Oui", "Non"];
990
+ case "de":
991
+ return ["Ja", "Nein"];
992
+ case "it":
993
+ return ["S\xEC", "No"];
994
+ case "pt":
995
+ return ["Sim", "N\xE3o"];
996
+ case "nl":
997
+ return ["Ja", "Nee"];
998
+ case "pl":
999
+ return ["Tak", "Nie"];
1000
+ case "ru":
1001
+ return ["\u0414\u0430", "\u041D\u0435\u0442"];
1002
+ case "ja":
1003
+ return ["\u306F\u3044", "\u3044\u3044\u3048"];
1004
+ case "zh":
1005
+ return ["\u662F", "\u4E0D"];
1006
+ case "ko":
1007
+ return ["\uC608", "\uC544\uB2C8"];
1008
+ case "da":
1009
+ case "sv":
1010
+ return ["Ja", "Nej"];
1011
+ case "fi":
1012
+ return ["Kyll\xE4", "Ei"];
1013
+ case "no":
1014
+ return ["Ja", "Nei"];
1015
+ case "ar":
1016
+ return ["\u0646\u0639\u0645", "\u0644\u0627"];
1017
+ case "bn":
1018
+ return ["\u09B9\u09CD\u09AF\u09BE\u0981", "\u09A8\u09BE"];
1019
+ default:
1020
+ return ["Yes", "No"];
1021
+ }
1022
+ }, t2.getUrlParam = function(e3) {
1023
+ return new URLSearchParams(window.location.search).get(e3);
1024
+ };
1025
+ }, 559: (e2, t2) => {
1026
+ "use strict";
1027
+ function i(e3, t3, i2, n, r = false, s = true, a = "ltr", o = "row") {
1028
+ const l = document.createElement("div");
1029
+ l.classList.add("magicfeedback-rating-placeholder"), l.style.display = "flex", l.style.flexDirection = o, l.style.alignItems = "center", l.style.justifyContent = "space-between", l.style.width = r ? `calc(100% - (100% / ${t3 + 1}))` : "100%", l.style.marginRight = "auto", s && window.innerWidth < 600 && (l.style.flexDirection = "column");
1030
+ const d = document.createElement("span");
1031
+ d.textContent = null != i2 ? i2 : null, d.classList.add("magicfeedback-rating-placeholder-value"), d.style.fontSize = "15px", d.style.display = "block", d.style.minWidth = "0", d.style.overflowWrap = "anywhere", d.style.wordBreak = "break-word", d.style.textAlign = "ltr" === a ? "left" : "right", d.style.width = "50%", (s && window.innerWidth < 600 || "column" === o) && (d.textContent = `${e3} = ${i2}`, d.style.width = "100%", d.style.textAlign = "left", d.style.marginBottom = "5px");
1032
+ const c = document.createElement("span");
1033
+ return c.textContent = null != n ? n : null, c.classList.add("magicfeedback-rating-placeholder-value"), c.style.fontSize = "15px", c.style.display = "block", c.style.minWidth = "0", c.style.overflowWrap = "anywhere", c.style.wordBreak = "break-word", c.style.textAlign = "ltr" === a ? "right" : "left", c.style.width = "50%", (s && window.innerWidth < 600 || "column" === o) && (c.textContent = `${t3} = ${n}`, c.style.width = "100%", c.style.textAlign = "left", c.style.marginBottom = "5px"), "ltr" === a ? (i2 && l.appendChild(d), n && l.appendChild(c)) : (n && l.appendChild(c), i2 && l.appendChild(d)), l;
1034
+ }
1035
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.createRatingNumberElement = t2.createStarRating = t2.createRatingPlaceholder = void 0, t2.createRatingPlaceholder = i, t2.createStarRating = function(e3, t3, n, r = () => {
1036
+ }, s) {
1037
+ const a = "magicfeedback-rating-star-selected", o = document.createElement("div");
1038
+ o.classList.add("magicfeedback-rating-star-container"), o.style.maxWidth = "300px", o.style.margin = "auto", o.dataset.originalSelection = "0";
1039
+ for (let t4 = 1; t4 <= 5; t4++) {
1040
+ const i2 = document.createElement("label");
1041
+ i2.classList.add("magicfeedback-rating-star-option");
1042
+ const n2 = document.createElement("input");
1043
+ n2.id = `rating-${e3}-${t4}`, n2.type = "radio", n2.name = e3, n2.value = t4.toString(), n2.style.position = "absolute", n2.style.opacity = "0", n2.style.width = "0", n2.style.height = "0", n2.classList.add("magicfeedback-input"), s && s === n2.value && (n2.checked = true), n2.addEventListener("change", (() => {
1044
+ const e4 = o.querySelectorAll(".rating__star");
1045
+ for (let t5 = 0; t5 < e4.length; t5++) t5 + 1 <= Number(n2.value) ? e4[t5].classList.contains(a) || e4[t5].classList.add(a) : e4[t5].classList.contains(a) && e4[t5].classList.remove(a);
1046
+ o.dataset.originalSelection = n2.value, r && r();
1047
+ })), i2.appendChild(n2);
1048
+ const l2 = document.createElement("label");
1049
+ l2.htmlFor = `rating-${e3}-${t4}`, l2.classList.add("rating__star"), l2.textContent = "\u2605", l2.style.fontSize = "40px", l2.style.color = "#CCCCCC", l2.style.cursor = "pointer", l2.addEventListener("mouseenter", (() => {
1050
+ const e4 = o.querySelectorAll(".rating__star"), i3 = t4 - 1;
1051
+ e4.forEach(((e5, t5) => {
1052
+ t5 <= i3 ? e5.classList.contains(a) || e5.classList.add(a) : e5.classList.contains(a) && e5.classList.remove(a);
1053
+ }));
1054
+ })), l2.addEventListener("mouseleave", (() => {
1055
+ const e4 = Number(o.dataset.originalSelection || "0");
1056
+ o.querySelectorAll(".rating__star").forEach(((t5, i3) => {
1057
+ i3 < e4 ? t5.classList.contains(a) || t5.classList.add(a) : t5.classList.contains(a) && t5.classList.remove(a);
1058
+ }));
1059
+ })), i2.appendChild(l2), o.appendChild(i2);
1060
+ }
1061
+ const l = i(1, 5, t3, n, false, false);
1062
+ return l.childElementCount > 0 && (o.classList.add("magicfeedback-rating-container--with-placeholder"), o.insertBefore(l, o.firstChild)), o;
1063
+ }, t2.createRatingNumberElement = function(e3, t3, n, r, s, a, o, l) {
1064
+ var d;
1065
+ const c = document.createElement("div");
1066
+ c.classList.add("magicfeedback-rating-number");
1067
+ const u = "ltr" === n ? r : `${r}-reverse`, p = document.createElement("div");
1068
+ p.classList.add("magicfeedback-rating-number-container"), p.classList.add(`magicfeedback-rating-number-container-${n}`), p.classList.add(`magicfeedback-rating-number-container-${r}`), p.style.display = "flex", p.style.flexDirection = u, p.setAttribute("role", "radiogroup"), p.setAttribute("aria-label", (null == t3 ? void 0 : t3.ariaLabel) || "Rating");
1069
+ const m = (null == t3 ? void 0 : t3.max) ? Number(null == t3 ? void 0 : t3.max) : 10, h = (null == t3 ? void 0 : t3.min) ? Number(null == t3 ? void 0 : t3.min) : 0, f = (null == t3 ? void 0 : t3.numberPlaceholders) || null, v = !(s || "column" === r) && ((null == t3 ? void 0 : t3.minPlaceholder) || (null == t3 ? void 0 : t3.maxPlaceholder));
1070
+ if (v) {
1071
+ const e4 = i(h, m, null == t3 ? void 0 : t3.minPlaceholder, null == t3 ? void 0 : t3.maxPlaceholder, null !== (d = null == t3 ? void 0 : t3.extraOption) && void 0 !== d && d, false, n, "row");
1072
+ e4.childElementCount > 0 && (p.classList.add("magicfeedback-rating-number-container--with-placeholder"), p.insertBefore(e4, p.firstChild));
1073
+ }
1074
+ for (let i2 = h; i2 <= m; i2++) {
1075
+ const n2 = document.createElement("div");
1076
+ n2.classList.add("magicfeedback-rating-number-option"), n2.classList.add(`magicfeedback-rating-number-option-${r}`);
1077
+ const d2 = document.createElement("label");
1078
+ d2.htmlFor = `rating-${e3}-${i2}`, d2.classList.add("magicfeedback-rating-number-option-label-container");
1079
+ let c2 = i2.toString();
1080
+ v ? f && f[i2] && !s && (d2.title = f[i2]) : f && f[i2] ? c2 += ` = ${f[i2]}` : i2 === h && (null == t3 ? void 0 : t3.minPlaceholder) ? c2 += ` = ${null == t3 ? void 0 : t3.minPlaceholder}` : i2 === m && (null == t3 ? void 0 : t3.maxPlaceholder) && (c2 += ` = ${null == t3 ? void 0 : t3.maxPlaceholder}`);
1081
+ const u2 = document.createElement("input");
1082
+ u2.id = `rating-${e3}-${i2}`, u2.type = "radio", u2.name = e3, u2.value = i2.toString(), u2.classList.add(a), u2.classList.add("magicfeedback-input"), u2.setAttribute("aria-label", `${i2}`), o && u2.addEventListener("change", (() => o())), l && l === u2.value && (u2.checked = true);
1083
+ const g = document.createElement("label");
1084
+ g.htmlFor = `rating-${e3}-${i2}`, g.textContent = c2, g.classList.add("magicfeedback-rating-number-value"), d2.appendChild(u2), d2.appendChild(g), n2.appendChild(d2), p.appendChild(n2);
1085
+ }
1086
+ if ((null == t3 ? void 0 : t3.extraOption) && (null == t3 ? void 0 : t3.extraOptionText)) {
1087
+ const i2 = document.createElement("div");
1088
+ i2.classList.add("magicfeedback-rating-number-option");
1089
+ const r2 = document.createElement("label");
1090
+ r2.htmlFor = `rating-${e3}-extra`, r2.classList.add("magicfeedback-rating-number-option-label-container");
1091
+ const s2 = document.createElement("input");
1092
+ s2.id = `rating-${e3}-extra`, s2.type = "radio", s2.name = e3, s2.value = "-", s2.classList.add(a), s2.classList.add("magicfeedback-input"), s2.setAttribute("aria-label", null == t3 ? void 0 : t3.extraOptionText), o && s2.addEventListener("change", (() => o()));
1093
+ const l2 = document.createElement("label");
1094
+ l2.htmlFor = `rating-${e3}-extra`, l2.textContent = null == t3 ? void 0 : t3.extraOptionText, l2.classList.add("magicfeedback-rating-number-value"), r2.appendChild(s2), r2.appendChild(l2), i2.appendChild(r2), "ltr" === n ? p.appendChild(i2) : p.insertBefore(i2, p.firstChild);
1095
+ }
1096
+ return c.appendChild(p), c;
1097
+ };
1098
+ }, 42: (e2, t2, i) => {
1099
+ "use strict";
1100
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.getQuestionRenderer = void 0;
1101
+ const n = i(558), r = i(998), s = i(72), a = i(732), o = i(90), l = i(65), d = i(85), c = i(817), u = i(965), p = i(180), m = i(991), h = i(152), f = i(917), v = i(452), g = i(644), y = i(773), b = i(66), E = i(843), k = i(250), A = i(409), C = i(282), T = /* @__PURE__ */ new Map([[n.FEEDBACKAPPANSWERTYPE.TEXT, o.renderText], [n.FEEDBACKAPPANSWERTYPE.LONGTEXT, s.renderLongText], [n.FEEDBACKAPPANSWERTYPE.NUMBER, a.renderNumber], [n.FEEDBACKAPPANSWERTYPE.RADIO, r.renderChoice], [n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE, r.renderChoice], [n.FEEDBACKAPPANSWERTYPE.BOOLEAN, l.renderBoolean], [n.FEEDBACKAPPANSWERTYPE.SELECT, d.renderSelect], [n.FEEDBACKAPPANSWERTYPE.DATE, c.renderDate], [n.FEEDBACKAPPANSWERTYPE.EMAIL, u.renderEmail], [n.FEEDBACKAPPANSWERTYPE.PASSWORD, p.renderPassword], [n.FEEDBACKAPPANSWERTYPE.CONSENT, m.renderConsent], [n.FEEDBACKAPPANSWERTYPE.RATING_EMOJI, h.renderRatingEmoji], [n.FEEDBACKAPPANSWERTYPE.RATING_NUMBER, f.renderRatingNumber], [n.FEEDBACKAPPANSWERTYPE.RATING_STAR, v.renderRatingStar], [n.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX, g.renderMatrix], [n.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST, y.renderPriorityList], [n.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM, b.renderPointSystem], [n.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE, E.renderUploadImage], [n.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE, k.renderUploadFile], [n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE, A.renderMultipleChoiceImage], [n.FEEDBACKAPPANSWERTYPE.INFO_PAGE, C.renderInfoPage]]);
1102
+ t2.getQuestionRenderer = function(e3) {
1103
+ return T.get(e3);
1104
+ };
1105
+ }, 65: (e2, t2, i) => {
1106
+ "use strict";
1107
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderBoolean = void 0;
1108
+ const n = i(516);
1109
+ t2.renderBoolean = ({ question: e3, language: t3, urlParamValue: i2, send: r }) => {
1110
+ const { ref: s, assets: a } = e3, o = document.createElement("div"), l = "magicfeedback-radio", d = document.createElement("div");
1111
+ return d.classList.add("magicfeedback-boolean-container"), d.style.display = "flex", d.style.flexDirection = "row", d.style.justifyContent = "space-between", d.style.width = "70%", d.style.margin = "auto", ((null == a ? void 0 : a.addIcon) ? ["\u{1F44D}", "\u{1F44E}"] : (0, n.getBooleanOptions)(t3)).forEach(((e4, t4) => {
1112
+ const n2 = document.createElement("label");
1113
+ n2.classList.add("magicfeedback-boolean-option"), n2.htmlFor = `rating-${s}-${t4}`, n2.style.cursor = "pointer", n2.style.display = "flex", n2.style.justifyContent = "center", n2.style.alignItems = "center", n2.style.margin = "auto", n2.style.padding = "0", n2.style.width = "45%", n2.style.height = "38px";
1114
+ const a2 = document.createElement("label");
1115
+ a2.htmlFor = `rating-${s}-${t4}`, a2.textContent = e4, a2.style.margin = "0", a2.style.padding = "0";
1116
+ const o2 = document.createElement("input");
1117
+ o2.id = `rating-${s}-${t4}`, o2.type = "radio", o2.name = s, o2.value = ["Yes", "No"][t4], o2.classList.add(l), o2.classList.add("magicfeedback-input"), o2.style.position = "absolute", o2.style.opacity = "0", o2.style.width = "0", o2.style.height = "0", o2.style.margin = "0", o2.addEventListener("change", (() => {
1118
+ r && r();
1119
+ })), i2 && i2.toLowerCase() === o2.value.toLowerCase() && (o2.checked = true), n2.appendChild(o2), n2.appendChild(a2), d.appendChild(n2);
1120
+ })), o.appendChild(d), { element: o, elementTypeClass: l };
1121
+ };
1122
+ }, 998: (e2, t2, i) => {
1123
+ "use strict";
1124
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderChoice = void 0;
1125
+ const n = i(558), r = i(784);
1126
+ t2.renderChoice = ({ question: e3, language: t3, urlParamValue: i2, randomPosition: s, send: a }) => {
1127
+ const { type: o, ref: l, value: d, defaultValue: c, assets: u } = e3, p = document.createElement("div"), m = "magicfeedback-" + ("MULTIPLECHOICE" === o ? "checkbox" : "radio");
1128
+ let h = d || [];
1129
+ s && (h = h.sort((() => Math.random() - 0.5)));
1130
+ let f = (null == u ? void 0 : u.exclusiveAnswers) || [];
1131
+ (null == u ? void 0 : u.extraOption) && (f = f.filter(((e4) => e4 !== u.extraOptionText))), f.length > 0 && (null == f || f.forEach(((e4) => {
1132
+ h.includes(e4) || h.push(e4);
1133
+ })));
1134
+ const v = null == u ? void 0 : u.extraOptionText;
1135
+ return (null == u ? void 0 : u.extraOption) && v && !h.includes(v) && h.push(v), h.forEach(((e4, s2) => {
1136
+ const d2 = document.createElement("div");
1137
+ d2.classList.add(`magicfeedback-${"MULTIPLECHOICE" === o ? "checkbox" : "radio"}-container`);
1138
+ const v2 = document.createElement("label"), g = document.createElement("input");
1139
+ if (g.id = `rating-${l}-${s2}`, g.type = "MULTIPLECHOICE" === o ? "checkbox" : "radio", g.name = l, g.value = e4, g.classList.add(m), g.classList.add("magicfeedback-input"), o === n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE && (null == u ? void 0 : u.maxOptions) && (null == u ? void 0 : u.maxOptions) > 0 && g.addEventListener("change", (() => {
1140
+ document.querySelectorAll(`input[name="${l}"]:checked`).length > (null == u ? void 0 : u.maxOptions) && (g.checked = false);
1141
+ })), o === n.FEEDBACKAPPANSWERTYPE.RADIO && a && (!(null == u ? void 0 : u.extraOptionText) || (null == u ? void 0 : u.extraOptionText) && e4 !== (null == u ? void 0 : u.extraOptionText)) && g.addEventListener("change", (() => {
1142
+ a();
1143
+ })), e4 !== c && e4 !== i2 || (g.checked = true), v2.textContent = e4, v2.htmlFor = `rating-${l}-${s2}`, g.addEventListener("change", ((t4) => {
1144
+ const i3 = document.getElementById(`extra-option-${l}`);
1145
+ t4.target.checked && f.includes(e4) ? (h.forEach(((t5) => {
1146
+ t5 !== e4 && (document.querySelector(`input[value="${t5}"]`).checked = false);
1147
+ })), i3 && (i3.style.display = "none")) : f.forEach(((t5) => {
1148
+ t5 !== e4 && (document.querySelector(`input[value="${t5}"]`).checked = false);
1149
+ })), (null == u ? void 0 : u.extraOption) && e4 === (null == u ? void 0 : u.extraOptionText) && i3 && (i3.style.display = t4.target.checked ? "block" : "none");
1150
+ })), d2.appendChild(g), d2.appendChild(v2), p.appendChild(d2), (null == u ? void 0 : u.extraOption) && e4 === (null == u ? void 0 : u.extraOptionText)) {
1151
+ const e5 = document.createElement("input");
1152
+ e5.type = "text", e5.placeholder = (null == u ? void 0 : u.extraOptionPlaceholder) || r.placeholder.answer(t3 || "en"), e5.classList.add("magicfeedback-extra-option"), e5.classList.add("magicfeedback-input"), e5.id = `extra-option-${l}`, e5.name = `extra-option-${l}`, e5.style.display = "none", p.appendChild(e5);
1153
+ }
1154
+ })), { element: p, elementTypeClass: m };
1155
+ };
1156
+ }, 991: (e2, t2) => {
1157
+ "use strict";
1158
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderConsent = void 0, t2.renderConsent = ({ question: e3, urlParamValue: t3, send: i }) => {
1159
+ const { id: n, ref: r, value: s, require: a } = e3, o = document.createElement("input");
1160
+ return o.type = "checkbox", o.id = `magicfeedback-${n}`, o.name = r, o.value = "true", o.required = a, o.classList.add("magicfeedback-consent"), o.classList.add("magicfeedback-input"), t3 && s.includes(t3) && (o.checked = true), i && o.addEventListener("change", (() => {
1161
+ i();
1162
+ })), { element: o, elementTypeClass: "magicfeedback-consent" };
1163
+ };
1164
+ }, 817: (e2, t2, i) => {
1165
+ "use strict";
1166
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderDate = void 0;
1167
+ const n = i(784);
1168
+ t2.renderDate = ({ language: e3, placeholderText: t3, urlParamValue: i2 }) => {
1169
+ const r = document.createElement("input");
1170
+ return r.type = "date", r.placeholder = t3 || n.placeholder.date(e3 || "en"), i2 && (r.value = i2), { element: r, elementTypeClass: "magicfeedback-date" };
1171
+ };
1172
+ }, 965: (e2, t2) => {
1173
+ "use strict";
1174
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderEmail = void 0, t2.renderEmail = ({ placeholderText: e3, urlParamValue: t3 }) => {
1175
+ const i = document.createElement("input");
1176
+ return i.type = "email", i.placeholder = e3 || "you@example.com", t3 && (i.value = t3), { element: i, elementTypeClass: "magicfeedback-email" };
1177
+ };
1178
+ }, 282: (e2, t2) => {
1179
+ "use strict";
1180
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderInfoPage = void 0, t2.renderInfoPage = ({ question: e3, placeholderText: t3 }) => {
1181
+ var i, n;
1182
+ const r = document.createElement("div");
1183
+ if ("string" == typeof (null === (i = e3.assets) || void 0 === i ? void 0 : i.placeholder) ? "" !== e3.assets.placeholder.trim() : Boolean(null === (n = e3.assets) || void 0 === n ? void 0 : n.placeholder)) {
1184
+ const e4 = document.createElement("div");
1185
+ e4.classList.add("magicfeedback-info-message"), e4.innerHTML = t3 || "", r.appendChild(e4);
1186
+ }
1187
+ return { element: r, elementTypeClass: "magicfeedback-info-page" };
1188
+ };
1189
+ }, 72: (e2, t2, i) => {
1190
+ "use strict";
1191
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderLongText = void 0;
1192
+ const n = i(784);
1193
+ t2.renderLongText = ({ language: e3, placeholderText: t3, urlParamValue: i2, maxCharacters: r }) => {
1194
+ const s = document.createElement("textarea");
1195
+ return s.rows = 3, r > 0 && (s.maxLength = r), s.placeholder = t3 || n.placeholder.answer(e3 || "en"), i2 && (s.value = i2), { element: s, elementTypeClass: "magicfeedback-longtext" };
1196
+ };
1197
+ }, 644: (e2, t2) => {
1198
+ "use strict";
1199
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderMatrix = void 0, t2.renderMatrix = ({ question: e3, isPhone: t3, randomPosition: i }) => {
1200
+ const { ref: n, value: r, assets: s } = e3, a = document.createElement("div"), o = document.createElement("div");
1201
+ o.classList.add("magicfeedback-multi-question-matrix-container");
1202
+ let l = (null == s ? void 0 : s.options) || [], d = [...r], c = [];
1203
+ if (i && (l = null == l ? void 0 : l.sort((() => Math.random() - 0.5)), d = [...d].sort((() => Math.random() - 0.5))), (null == s ? void 0 : s.exclusiveAnswers) && (c = null == s ? void 0 : s.exclusiveAnswers, null == c || c.forEach(((e4) => {
1204
+ d.includes(e4) || d.push(e4);
1205
+ }))), t3) {
1206
+ const e4 = document.createElement("div");
1207
+ e4.classList.add("magicfeedback-multi-question-matrix-list"), null == l || l.forEach(((t4) => {
1208
+ const i2 = document.createElement("div");
1209
+ i2.classList.add("magicfeedback-multi-question-matrix-list-item"), i2.style.display = "flex", i2.style.flexDirection = "column", i2.style.alignItems = "flex-start", i2.style.marginBottom = "10px";
1210
+ const r2 = document.createElement("label");
1211
+ r2.classList.add("magicfeedback-multi-question-matrix-label"), r2.style.paddingBottom = "10px", r2.textContent = t4, i2.appendChild(r2), d.forEach(((e5) => {
1212
+ const r3 = document.createElement("div");
1213
+ r3.classList.add("magicfeedback-radio-container"), r3.style.display = "flex", r3.style.alignItems = "center", r3.style.justifyContent = "flex-start", r3.style.width = "99%", r3.style.margin = "5px auto";
1214
+ const s2 = document.createElement("label"), a2 = document.createElement("input");
1215
+ a2.id = `${n}-${t4}-${e5}`, a2.type = "radio", a2.name = `${n}-${t4}`, a2.value = e5, a2.classList.add("magicfeedback-input"), s2.textContent = e5, s2.htmlFor = `${n}-${t4}-${e5}`, r3.appendChild(a2), r3.appendChild(s2), i2.appendChild(r3);
1216
+ })), e4.appendChild(i2);
1217
+ })), o.appendChild(e4);
1218
+ } else {
1219
+ const e4 = document.createElement("table");
1220
+ e4.classList.add("magicfeedback-multi-question-matrix-table");
1221
+ const t4 = document.createElement("thead");
1222
+ t4.classList.add("magicfeedback-multi-question-matrix-header"), t4.style.paddingBottom = "15px";
1223
+ const i2 = document.createElement("tr"), r2 = document.createElement("th");
1224
+ i2.appendChild(r2), d.forEach(((e5) => {
1225
+ const t5 = document.createElement("th");
1226
+ t5.textContent = e5, i2.appendChild(t5);
1227
+ })), t4.appendChild(i2), e4.appendChild(t4);
1228
+ const s2 = document.createElement("tbody");
1229
+ null == l || l.forEach(((e5) => {
1230
+ const t5 = document.createElement("tr");
1231
+ t5.classList.add("magicfeedback-multi-question-matrix-row-tr");
1232
+ const i3 = document.createElement("td");
1233
+ i3.style.minWidth = "200px", i3.style.padding = "10px";
1234
+ const r3 = document.createElement("label");
1235
+ r3.classList.add("magicfeedback-multi-question-matrix-label"), r3.textContent = e5, i3.appendChild(r3), t5.appendChild(i3), d.forEach(((i4) => {
1236
+ const r4 = document.createElement("td"), s3 = document.createElement("input");
1237
+ s3.type = "radio", s3.name = `${n}-${e5}`, s3.value = i4, s3.id = `${n}-${e5}-${i4}`, s3.classList.add("magicfeedback-input"), r4.appendChild(s3), t5.appendChild(r4);
1238
+ })), s2.appendChild(t5);
1239
+ })), e4.appendChild(s2), o.appendChild(e4);
1240
+ }
1241
+ return a.appendChild(o), { element: a, elementTypeClass: "magicfeedback-multi-question-matrix" };
1242
+ };
1243
+ }, 409: (e2, t2) => {
1244
+ "use strict";
1245
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderMultipleChoiceImage = void 0, t2.renderMultipleChoiceImage = ({ question: e3, randomPosition: t3, urlParamValue: i, send: n }) => {
1246
+ const r = document.createElement("div"), { ref: s, assets: a } = e3;
1247
+ let o = [...e3.value];
1248
+ const l = document.createElement("div");
1249
+ l.classList.add("magicfeedback-multiple-choice-image-container"), l.style.display = "flex", l.style.flexDirection = "row", l.style.flexWrap = "wrap", l.style.justifyContent = "center";
1250
+ const d = o.length;
1251
+ let c = 1, u = 1;
1252
+ if (window.innerWidth < 600) c = 1, u = d;
1253
+ else switch (d) {
1254
+ case 1:
1255
+ case 2:
1256
+ case 3:
1257
+ c = d, u = 1;
1258
+ break;
1259
+ case 4:
1260
+ case 5:
1261
+ case 6:
1262
+ u = 2, c = Math.ceil(d / u);
1263
+ break;
1264
+ case 7:
1265
+ case 8:
1266
+ case 9:
1267
+ u = 3, c = Math.ceil(d / u);
1268
+ break;
1269
+ default:
1270
+ u = 4, c = Math.ceil(d / u);
1271
+ }
1272
+ const p = void 0 !== (null == a ? void 0 : a.addTitle) && (null == a ? void 0 : a.addTitle), m = void 0 !== (null == a ? void 0 : a.multiOption) && (null == a ? void 0 : a.multiOption), h = void 0 !== (null == a ? void 0 : a.extraOption) && (null == a ? void 0 : a.extraOption);
1273
+ function f(e4) {
1274
+ try {
1275
+ const { position: t4, url: r2, value: a2 } = e4, o2 = document.createElement("div");
1276
+ o2.classList.add("magicfeedback-multiple-choice-image-option"), o2.style.width = `calc(100% / ${c} - 2px)`, o2.style.height = `calc(100% / ${u} - 2px)`, o2.style.padding = "8px", o2.style.margin = "0";
1277
+ const d2 = document.createElement("label");
1278
+ d2.classList.add("magicfeedback-image-option-label-container"), d2.htmlFor = `rating-${s}-${t4}`, d2.style.cursor = "pointer", d2.addEventListener("click", (() => {
1279
+ d2.style.border = "2px solid #000";
1280
+ }));
1281
+ const h2 = document.createElement("label");
1282
+ h2.textContent = a2, h2.classList.add("magicfeedback-multiple-choice-image-label");
1283
+ const f2 = document.createElement("input");
1284
+ f2.id = `rating-${s}-${t4}`, f2.type = m ? "checkbox" : "radio", f2.name = s, f2.value = a2, f2.style.position = "absolute", f2.style.opacity = "0", f2.style.width = "0", f2.style.height = "0", f2.classList.add("magicfeedback-input"), i && i === f2.value && (f2.checked = true), !m && n && f2.addEventListener("change", (() => {
1285
+ n();
1286
+ }));
1287
+ const v = document.createElement("img");
1288
+ v.classList.add("magicfeedback-multiple-choice-image-image"), v.src = r2, v.style.cursor = "pointer", v.style.backgroundSize = "cover", v.style.backgroundPosition = "center", v.style.width = "100%", v.style.height = "100%", v.style.objectFit = "cover", v.style.margin = "auto", d2.appendChild(f2), d2.appendChild(v), p && d2.appendChild(h2), o2.appendChild(d2), l.appendChild(o2);
1289
+ } catch (e5) {
1290
+ console.error(e5);
1291
+ }
1292
+ }
1293
+ return t3 && (o = o.sort((() => Math.random() - 0.5))), o.forEach(((e4) => f(JSON.parse(e4)))), h && (null == a ? void 0 : a.extraOptionValue) && (null == a ? void 0 : a.extraOptionValue.length) > 0 && f(null == a ? void 0 : a.extraOptionValue[0]), r.appendChild(l), { element: r, elementTypeClass: "magicfeedback-multiple-choice-image" };
1294
+ };
1295
+ }, 732: (e2, t2, i) => {
1296
+ "use strict";
1297
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderNumber = void 0;
1298
+ const n = i(784), r = i(516);
1299
+ t2.renderNumber = ({ question: e3, format: t3, language: i2, urlParamValue: s }) => {
1300
+ const a = document.createElement("input");
1301
+ a.type = "number", a.placeholder = "slim" === t3 ? (0, r.parseTitle)(e3.title, i2) : n.placeholder.number(i2 || "en");
1302
+ const { value: o } = e3;
1303
+ return o.length && (o.sort(((e4, t4) => Number(e4) - Number(t4))), a.max = o[o.length - 1], a.min = o[0], a.value = o[0]), s && !isNaN(Number(s)) && (a.value = s), { element: a, elementTypeClass: "magicfeedback-number" };
1304
+ };
1305
+ }, 180: (e2, t2, i) => {
1306
+ "use strict";
1307
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderPassword = void 0;
1308
+ const n = i(784);
1309
+ t2.renderPassword = ({ language: e3, placeholderText: t3, urlParamValue: i2 }) => {
1310
+ const r = document.createElement("input");
1311
+ return r.type = "password", r.placeholder = t3 || n.placeholder.password(e3 || "en"), i2 && (r.value = i2), { element: r, elementTypeClass: "magicfeedback-password" };
1312
+ };
1313
+ }, 66: (e2, t2, i) => {
1314
+ "use strict";
1315
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderPointSystem = void 0;
1316
+ const n = i(784);
1317
+ t2.renderPointSystem = ({ question: e3, language: t3 }) => {
1318
+ const { ref: i2, value: r } = e3, s = document.createElement("div"), a = document.createElement("div");
1319
+ a.classList.add("magicfeedback-point-system-container");
1320
+ const o = document.createElement("ul");
1321
+ o.classList.add("magicfeedback-point-system-list"), o.style.padding = "0";
1322
+ const l = 100 / r.length, d = document.createElement("div");
1323
+ d.classList.add("magicfeedback-error"), d.textContent = n.placeholder.pointsystemerror(t3 || "en"), d.style.color = "#C70039", d.style.fontSize = "14px", d.style.textAlign = "right", d.style.width = "100%", d.style.display = "none";
1324
+ const c = document.createElement("div");
1325
+ return c.classList.add("magicfeedback-point-system-total"), c.textContent = "0 / 100 %", c.style.textAlign = "right", c.style.fontSize = "15px", c.style.marginTop = "5px", r.forEach(((e4, t4) => {
1326
+ const n2 = document.createElement("li");
1327
+ n2.classList.add("magicfeedback-point-system-item"), n2.style.display = "flex", n2.style.justifyContent = "space-between", n2.style.alignItems = "center", n2.style.margin = "5px";
1328
+ const r2 = document.createElement("label");
1329
+ r2.textContent = e4, r2.style.fontSize = "15px", n2.appendChild(r2);
1330
+ const s2 = document.createElement("span");
1331
+ s2.classList.add("magicfeedback-point-system-input-container");
1332
+ const a2 = document.createElement("input");
1333
+ a2.name = i2, a2.id = `${e4}`, a2.type = "number", a2.min = "0", a2.max = "100", a2.value = "0", a2.classList.add("magicfeedback-input"), a2.style.width = "40px", a2.style.border = "0", a2.style.textAlign = "center", a2.style.margin = "0 5px", a2.autofocus = 0 === t4;
1334
+ const u = document.createElement("span");
1335
+ u.textContent = "%", u.style.color = "#000", a2.addEventListener("input", (() => {
1336
+ const e5 = o.querySelectorAll("input");
1337
+ let t5 = 0;
1338
+ e5.forEach(((e6) => {
1339
+ t5 += Number(e6.value);
1340
+ })), t5 > 100 && (a2.value = `${l}%`, t5 -= Number(a2.value));
1341
+ const i3 = document.getElementById("magicfeedback-submit");
1342
+ i3 && (t5 < 100 ? (c.style.color = "orange", i3.setAttribute("disabled", "true")) : (d.style.display = "none", c.style.color = "green", i3.removeAttribute("disabled"))), c.textContent = `${t5} / 100 %`;
1343
+ })), a2.addEventListener("focus", (() => {
1344
+ const e5 = document.getElementById("magicfeedback-submit");
1345
+ e5 && (e5.setAttribute("disabled", "true"), e5.addEventListener("pointerover", (() => {
1346
+ const e6 = o.querySelectorAll("input");
1347
+ let t5 = 0;
1348
+ e6.forEach(((e7) => {
1349
+ t5 += Number(e7.value);
1350
+ })), t5 < 100 && (d.style.display = "block");
1351
+ })));
1352
+ })), s2.appendChild(a2), s2.appendChild(u), n2.appendChild(s2), o.appendChild(n2);
1353
+ })), a.appendChild(o), a.appendChild(c), a.appendChild(d), s.appendChild(a), { element: s, elementTypeClass: "magicfeedback-point-system" };
1354
+ };
1355
+ }, 773: (e2, t2) => {
1356
+ "use strict";
1357
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderPriorityList = void 0, t2.renderPriorityList = ({ question: e3, randomPosition: t3, language: i }) => {
1358
+ var n, r, s;
1359
+ const a = document.createElement("div"), o = (function(e4) {
1360
+ const { value: t4, ref: i2, randomPosition: n2 = false, limitPriority: r2 = false, maxPriority: s2 = 0, language: a2 = "en", placeholder: o2 = "" } = e4, l = (e5) => {
1361
+ const t5 = { en: { selectUpTo: "Select up to", options: "options", thenOrder: "and then order them", selectOptions: "Select options", cancel: "Cancel", confirm: "Confirm", selectOptionNumber: "Select option #", prioritized: "Prioritized", of: "of", instruction: "Your priority list can be seen below. If you wish, you can rearrange your choices using the arrows. Click 'Next' to confirm your selection and proceed." }, es: { selectUpTo: "Selecciona hasta", options: "opciones", thenOrder: "y luego ord\xE9nalas", selectOptions: "Seleccionar opciones", cancel: "Cancelar", confirm: "Confirmar", selectOptionNumber: "Selecciona la opci\xF3n #", prioritized: "Priorizadas", of: "de", instruction: 'Tu lista priorizada se muestra abajo. Si deseas, puedes reordenar las opciones con las flechas. Haz clic en "Siguiente" para confirmar y continuar.' }, pt: { selectUpTo: "Selecione at\xE9", options: "op\xE7\xF5es", thenOrder: "e depois ordene-as", selectOptions: "Selecionar op\xE7\xF5es", cancel: "Cancelar", confirm: "Confirmar", selectOptionNumber: "Selecione a op\xE7\xE3o #", prioritized: "Priorizadas", of: "de", instruction: 'Sua lista de prioridades pode ser vista abaixo. Se quiser, voc\xEA pode reorganizar suas escolhas usando as setas. Clique em "Pr\xF3ximo" para confirmar sua sele\xE7\xE3o e continuar.' }, fr: { selectUpTo: "S\xE9lectionnez jusqu'\xE0", options: "options", thenOrder: "puis classez-les", selectOptions: "S\xE9lectionner des options", cancel: "Annuler", confirm: "Confirmer", selectOptionNumber: "S\xE9lectionnez l'option #", prioritized: "Prioris\xE9es", of: "sur", instruction: `Votre liste de priorit\xE9s est affich\xE9e ci-dessous. Si vous le souhaitez, vous pouvez r\xE9organiser vos choix \xE0 l'aide des fl\xE8ches. Cliquez sur "Suivant" pour confirmer votre s\xE9lection et continuer.` }, de: { selectUpTo: "W\xE4hlen Sie bis zu", options: "Optionen", thenOrder: "und ordnen Sie sie dann", selectOptions: "Optionen ausw\xE4hlen", cancel: "Abbrechen", confirm: "Best\xE4tigen", selectOptionNumber: "W\xE4hlen Sie Option #", prioritized: "Priorisiert", of: "von", instruction: 'Ihre Priorit\xE4tenliste wird unten angezeigt. Wenn Sie m\xF6chten, k\xF6nnen Sie Ihre Auswahl mit den Pfeilen neu anordnen. Klicken Sie auf "Weiter", um Ihre Auswahl zu best\xE4tigen und fortzufahren.' }, it: { selectUpTo: "Seleziona fino a", options: "opzioni", thenOrder: "e poi ordinali", selectOptions: "Seleziona opzioni", cancel: "Annulla", confirm: "Conferma", selectOptionNumber: "Seleziona opzione #", prioritized: "Prioritizzate", of: "di", instruction: 'La tua lista di priorit\xE0 \xE8 mostrata qui sotto. Se vuoi, puoi riordinare le tue scelte usando le frecce. Clicca su "Avanti" per confermare la selezione e continuare.' }, nl: { selectUpTo: "Selecteer tot", options: "opties", thenOrder: "en rangschik ze vervolgens", selectOptions: "Selecteer opties", cancel: "Annuleren", confirm: "Bevestigen", selectOptionNumber: "Selecteer optie #", prioritized: "Geprioriteerd", of: "van", instruction: 'Je prioriteitenlijst wordt hieronder weergegeven. Als je wilt, kun je je keuzes herschikken met behulp van de pijlen. Klik op "Volgende" om je selectie te bevestigen en door te gaan.' }, pl: { selectUpTo: "Wybierz do", options: "opcje", thenOrder: "a nast\u0119pnie je uporz\u0105dkuj", selectOptions: "Wybierz opcje", cancel: "Anuluj", confirm: "Potwierd\u017A", selectOptionNumber: "Wybierz opcj\u0119 #", prioritized: "Priorytetowe", of: "z", instruction: 'Twoja lista priorytet\xF3w jest pokazana poni\u017Cej. Je\u015Bli chcesz, mo\u017Cesz zmieni\u0107 kolejno\u015B\u0107 swoich wybor\xF3w za pomoc\u0105 strza\u0142ek. Kliknij "Dalej", aby potwierdzi\u0107 wyb\xF3r i kontynuowa\u0107.' }, ru: { selectUpTo: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0434\u043E", options: "\u0432\u0430\u0440\u0438\u0430\u043D\u0442\u043E\u0432", thenOrder: "\u0430 \u0437\u0430\u0442\u0435\u043C \u0443\u043F\u043E\u0440\u044F\u0434\u043E\u0447\u044C\u0442\u0435 \u0438\u0445", selectOptions: "\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0430\u0440\u0438\u0430\u043D\u0442\u044B", cancel: "\u041E\u0442\u043C\u0435\u043D\u0430", confirm: "\u041F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044C", selectOptionNumber: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0430\u0440\u0438\u0430\u043D\u0442 #", prioritized: "\u041F\u0440\u0438\u043E\u0440\u0438\u0442\u0435\u0442\u044B", of: "\u0438\u0437", instruction: '\u0412\u0430\u0448 \u0441\u043F\u0438\u0441\u043E\u043A \u043F\u0440\u0438\u043E\u0440\u0438\u0442\u0435\u0442\u043E\u0432 \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044F \u043D\u0438\u0436\u0435. \u0415\u0441\u043B\u0438 \u0445\u043E\u0442\u0438\u0442\u0435, \u0432\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u0438\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u043F\u043E\u0440\u044F\u0434\u043E\u043A \u0432\u0430\u0440\u0438\u0430\u043D\u0442\u043E\u0432 \u0441 \u043F\u043E\u043C\u043E\u0449\u044C\u044E \u0441\u0442\u0440\u0435\u043B\u043E\u043A. \u041D\u0430\u0436\u043C\u0438\u0442\u0435 "\u0414\u0430\u043B\u0435\u0435", \u0447\u0442\u043E\u0431\u044B \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044C \u0432\u044B\u0431\u043E\u0440 \u0438 \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C.' }, ja: { selectUpTo: "\u6700\u5927", options: "\u500B\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u9078\u629E", thenOrder: "\u305D\u306E\u5F8C\u4E26\u3079\u66FF\u3048\u3066\u304F\u3060\u3055\u3044", selectOptions: "\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u9078\u629E", cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB", confirm: "\u78BA\u8A8D", selectOptionNumber: "\u30AA\u30D7\u30B7\u30E7\u30F3 # \u3092\u9078\u629E", prioritized: "\u512A\u5148\u9806\u4F4D", of: "\u306E\u3046\u3061", instruction: "\u512A\u5148\u9806\u4F4D\u30EA\u30B9\u30C8\u306F\u4EE5\u4E0B\u306B\u8868\u793A\u3055\u308C\u307E\u3059\u3002\u5FC5\u8981\u306B\u5FDC\u3058\u3066\u3001\u77E2\u5370\u3092\u4F7F\u3063\u3066\u9078\u629E\u80A2\u3092\u4E26\u3079\u66FF\u3048\u308B\u3053\u3068\u304C\u3067\u304D\u307E\u3059\u3002\u300C\u6B21\u3078\u300D\u3092\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u9078\u629E\u3092\u78BA\u5B9A\u3057\u3001\u7D9A\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002" }, zh: { selectUpTo: "\u6700\u591A\u9009\u62E9", options: "\u4E2A\u9009\u9879", thenOrder: "\u7136\u540E\u6392\u5E8F\u5B83\u4EEC", selectOptions: "\u9009\u62E9\u9009\u9879", cancel: "\u53D6\u6D88", confirm: "\u786E\u8BA4", selectOptionNumber: "\u9009\u62E9\u9009\u9879 #", prioritized: "\u5DF2\u4F18\u5148", of: "\u5171", instruction: "\u4F60\u7684\u4F18\u5148\u5217\u8868\u5982\u4E0B\u6240\u793A\u3002\u5982\u6709\u9700\u8981\uFF0C\u53EF\u4EE5\u4F7F\u7528\u7BAD\u5934\u91CD\u65B0\u6392\u5E8F\u9009\u9879\u3002\u70B9\u51FB\u201C\u4E0B\u4E00\u6B65\u201D\u786E\u8BA4\u9009\u62E9\u5E76\u7EE7\u7EED\u3002" }, ko: { selectUpTo: "\uCD5C\uB300", options: "\uAC1C\uC758 \uC635\uC158 \uC120\uD0DD", thenOrder: "\uADF8\uB7F0 \uB2E4\uC74C \uC815\uB82C\uD558\uC138\uC694", selectOptions: "\uC635\uC158 \uC120\uD0DD", cancel: "\uCDE8\uC18C", confirm: "\uD655\uC778", selectOptionNumber: "\uC635\uC158 # \uC120\uD0DD", prioritized: "\uC6B0\uC120\uC21C\uC704", of: "\uC911", instruction: '\uC6B0\uC120\uC21C\uC704 \uBAA9\uB85D\uC740 \uC544\uB798\uC5D0 \uD45C\uC2DC\uB429\uB2C8\uB2E4. \uC6D0\uD55C\uB2E4\uBA74 \uD654\uC0B4\uD45C\uB97C \uC0AC\uC6A9\uD574 \uC120\uD0DD \uD56D\uBAA9\uC744 \uC7AC\uC815\uB82C\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4. "\uB2E4\uC74C"\uC744 \uD074\uB9AD\uD558\uC5EC \uC120\uD0DD\uC744 \uD655\uC778\uD558\uACE0 \uACC4\uC18D\uD558\uC138\uC694.' }, ar: { selectUpTo: "\u0627\u062E\u062A\u0631 \u062D\u062A\u0649", options: "\u062E\u064A\u0627\u0631\u0627\u062A", thenOrder: "\u062B\u0645 \u0631\u062A\u0628\u0647\u0627", selectOptions: "\u0627\u062E\u062A\u0631 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A", cancel: "\u0625\u0644\u063A\u0627\u0621", confirm: "\u062A\u0623\u0643\u064A\u062F", selectOptionNumber: "\u0627\u062E\u062A\u0631 \u0627\u0644\u062E\u064A\u0627\u0631 #", prioritized: "\u062A\u0645 \u0627\u0644\u062A\u0631\u062A\u064A\u0628", of: "\u0645\u0646", instruction: '\u062A\u0638\u0647\u0631 \u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0623\u0648\u0644\u0648\u064A\u0627\u062A \u0627\u0644\u062E\u0627\u0635\u0629 \u0628\u0643 \u0623\u062F\u0646\u0627\u0647. \u0625\u0630\u0627 \u0631\u063A\u0628\u062A\u060C \u064A\u0645\u0643\u0646\u0643 \u0625\u0639\u0627\u062F\u0629 \u062A\u0631\u062A\u064A\u0628 \u0627\u062E\u062A\u064A\u0627\u0631\u0627\u062A\u0643 \u0628\u0627\u0633\u062A\u062E\u062F\u0627\u0645 \u0627\u0644\u0623\u0633\u0647\u0645. \u0627\u0646\u0642\u0631 \u0639\u0644\u0649 "\u0627\u0644\u062A\u0627\u0644\u064A" \u0644\u062A\u0623\u0643\u064A\u062F \u0627\u062E\u062A\u064A\u0627\u0631\u0643 \u0648\u0627\u0644\u0645\u062A\u0627\u0628\u0639\u0629.' }, bn: { selectUpTo: "\u09B8\u09B0\u09CD\u09AC\u09CB\u099A\u09CD\u099A \u09A8\u09BF\u09B0\u09CD\u09AC\u09BE\u099A\u09A8 \u0995\u09B0\u09C1\u09A8", options: "\u099F\u09BF \u09AC\u09BF\u0995\u09B2\u09CD\u09AA", thenOrder: "\u09A4\u09BE\u09B0\u09AA\u09B0 \u09B8\u09C7\u0997\u09C1\u09B2\u09CB \u09B8\u09BE\u099C\u09BE\u09A8", selectOptions: "\u09AC\u09BF\u0995\u09B2\u09CD\u09AA \u09A8\u09BF\u09B0\u09CD\u09AC\u09BE\u099A\u09A8 \u0995\u09B0\u09C1\u09A8", cancel: "\u09AC\u09BE\u09A4\u09BF\u09B2", confirm: "\u09A8\u09BF\u09B6\u09CD\u099A\u09BF\u09A4 \u0995\u09B0\u09C1\u09A8", selectOptionNumber: "\u09AC\u09BF\u0995\u09B2\u09CD\u09AA # \u09A8\u09BF\u09B0\u09CD\u09AC\u09BE\u099A\u09A8 \u0995\u09B0\u09C1\u09A8", prioritized: "\u0985\u0997\u09CD\u09B0\u09BE\u09A7\u09BF\u0995\u09BE\u09B0\u09AA\u09CD\u09B0\u09BE\u09AA\u09CD\u09A4", of: "\u098F\u09B0 \u09AE\u09A7\u09CD\u09AF\u09C7", instruction: "\u0986\u09AA\u09A8\u09BE\u09B0 \u0985\u0997\u09CD\u09B0\u09BE\u09A7\u09BF\u0995\u09BE\u09B0 \u09A4\u09BE\u09B2\u09BF\u0995\u09BE \u09A8\u09BF\u099A\u09C7 \u09A6\u09C7\u0996\u09BE\u09A8\u09CB \u09B9\u09AF\u09BC\u09C7\u099B\u09C7\u0964 \u099A\u09BE\u0987\u09B2\u09C7 \u09A4\u09C0\u09B0 \u099A\u09BF\u09B9\u09CD\u09A8 \u09AC\u09CD\u09AF\u09AC\u09B9\u09BE\u09B0 \u0995\u09B0\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0 \u09AA\u099B\u09A8\u09CD\u09A6\u0997\u09C1\u09B2\u09CB \u09AA\u09C1\u09A8\u09B0\u09BE\u09AF\u09BC \u09B8\u09BE\u099C\u09BE\u09A4\u09C7 \u09AA\u09BE\u09B0\u09C7\u09A8\u0964 \u201C\u09AA\u09B0\u09AC\u09B0\u09CD\u09A4\u09C0\u201D \u0995\u09CD\u09B2\u09BF\u0995 \u0995\u09B0\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0 \u09A8\u09BF\u09B0\u09CD\u09AC\u09BE\u099A\u09A8 \u09A8\u09BF\u09B6\u09CD\u099A\u09BF\u09A4 \u0995\u09B0\u09C1\u09A8 \u098F\u09AC\u0982 \u098F\u0997\u09BF\u09AF\u09BC\u09C7 \u09AF\u09BE\u09A8\u0964" }, da: { selectUpTo: "V\xE6lg op til", options: "muligheder", thenOrder: "og sorter dem derefter", selectOptions: "V\xE6lg muligheder", cancel: "Annuller", confirm: "Bekr\xE6ft", selectOptionNumber: "V\xE6lg mulighed #", prioritized: "Prioriteret", of: "af", instruction: 'Din prioritetsliste vises nedenfor. Hvis du \xF8nsker det, kan du omarrangere dine valg ved hj\xE6lp af pilene. Klik p\xE5 "N\xE6ste" for at bekr\xE6fte dit valg og forts\xE6tte.' }, fi: { selectUpTo: "Valitse enint\xE4\xE4n", options: "vaihtoehtoa", thenOrder: "ja j\xE4rjest\xE4 ne sitten", selectOptions: "Valitse vaihtoehdot", cancel: "Peruuta", confirm: "Vahvista", selectOptionNumber: "Valitse vaihtoehto #", prioritized: "Priorisoitu", of: " / ", instruction: 'Prioriteettilistasi n\xE4kyy alla. Voit halutessasi j\xE4rjest\xE4\xE4 valinnat uudelleen nuolien avulla. Napsauta "Seuraava" vahvistaaksesi valinnan ja jatkaaksesi.' }, sv: { selectUpTo: "V\xE4lj upp till", options: "alternativ", thenOrder: "och ordna dem sedan", selectOptions: "V\xE4lj alternativ", cancel: "Avbryt", confirm: "Bekr\xE4fta", selectOptionNumber: "V\xE4lj alternativ #", prioritized: "Prioriterat", of: "av", instruction: 'Din prioriteringslista visas nedan. Om du vill kan du ordna om dina val med hj\xE4lp av pilarna. Klicka p\xE5 "N\xE4sta" f\xF6r att bekr\xE4fta ditt val och forts\xE4tta.' }, no: { selectUpTo: "Velg opptil", options: "alternativer", thenOrder: "og ordne dem deretter", selectOptions: "Velg alternativer", cancel: "Avbryt", confirm: "Bekreft", selectOptionNumber: "Velg alternativ #", prioritized: "Prioritert", of: "av", instruction: 'Prioriteringslisten din vises nedenfor. Hvis du \xF8nsker det, kan du ordne valgene dine ved hjelp av pilene. Klikk p\xE5 "Neste" for \xE5 bekrefte valget ditt og fortsette.' } };
1362
+ return t5[t5[a2] ? a2 : "en"][e5];
1363
+ }, d = document.createElement("div");
1364
+ if (d.classList.add("magicfeedback-priority-list-container"), r2 && s2 && s2 > 0) {
1365
+ const e5 = [], r3 = document.createElement("div");
1366
+ r3.classList.add("magicfeedback-priority-list-header");
1367
+ const a3 = document.createElement("div");
1368
+ a3.classList.add("magicfeedback-priority-list-instruction"), a3.textContent = "" !== o2 ? o2 : `${l("instruction")}`, a3.style.display = "none";
1369
+ const c2 = document.createElement("button");
1370
+ c2.type = "button", c2.textContent = l("selectOptions"), c2.classList.add("magicfeedback-button"), c2.classList.add("magicfeedback-priority-list-open-btn"), r3.appendChild(c2), r3.appendChild(a3);
1371
+ const u2 = document.createElement("div");
1372
+ u2.classList.add("magicfeedback-priority-list-reorder");
1373
+ const p = document.createElement("ul");
1374
+ p.classList.add("magicfeedback-priority-list-list"), u2.appendChild(p);
1375
+ const m = () => {
1376
+ p.innerHTML = "", e5.forEach(((t5, n3) => {
1377
+ const r4 = document.createElement("li");
1378
+ r4.classList.add("magicfeedback-priority-list-item");
1379
+ const s3 = document.createElement("input");
1380
+ s3.classList.add("magicfeedback-input-magicfeedback-priority-list"), s3.classList.add("magicfeedback-input"), s3.type = "hidden", s3.id = `priority-list-${i2}`, s3.name = i2, s3.value = `${n3 + 1}. ${t5}`, r4.appendChild(s3);
1381
+ const a4 = document.createElement("label");
1382
+ a4.classList.add("magicfeedback-priority-list-item-label"), a4.textContent = `${n3 + 1}. ${t5}`, r4.appendChild(a4);
1383
+ const o3 = document.createElement("div");
1384
+ o3.classList.add("magicfeedback-priority-list-arrows");
1385
+ const l2 = document.createElement("img");
1386
+ l2.classList.add("magicfeedback-priority-list-arrow-up"), l2.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", l2.style.visibility = 0 === n3 ? "hidden" : "visible";
1387
+ const d2 = document.createElement("img");
1388
+ d2.classList.add("magicfeedback-priority-list-arrow-down"), d2.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", d2.style.transform = "rotate(180deg)", d2.style.visibility = n3 === e5.length - 1 ? "hidden" : "visible", l2.addEventListener("click", (() => {
1389
+ var i3, n4, o4, c3;
1390
+ const u3 = r4.previousElementSibling;
1391
+ if (u3) {
1392
+ const m2 = Number(null === (i3 = s3.value) || void 0 === i3 ? void 0 : i3.split(".")[0]) - 1;
1393
+ s3.value = `${m2}. ${t5}`, a4.textContent = `${m2}. ${t5}`, l2.style.visibility = 1 === m2 ? "hidden" : "visible", d2.style.visibility = m2 === e5.length ? "hidden" : "visible";
1394
+ const h2 = u3.querySelector(".magicfeedback-input-magicfeedback-priority-list"), f2 = u3.querySelector(".magicfeedback-priority-list-item-label"), v2 = u3.querySelector(".magicfeedback-priority-list-arrow-up"), g2 = u3.querySelector(".magicfeedback-priority-list-arrow-down");
1395
+ if (h2 && f2 && v2 && g2) {
1396
+ const t6 = Number(null === (n4 = h2.value) || void 0 === n4 ? void 0 : n4.split(".")[0]) + 1;
1397
+ h2.value = `${t6}.${null === (o4 = f2.textContent) || void 0 === o4 ? void 0 : o4.split(".")[1]}`, f2.textContent = `${t6}.${null === (c3 = f2.textContent) || void 0 === c3 ? void 0 : c3.split(".")[1]}`, v2.style.visibility = 1 === t6 ? "hidden" : "visible", g2.style.visibility = t6 === e5.length ? "hidden" : "visible";
1398
+ }
1399
+ p.insertBefore(r4, u3);
1400
+ }
1401
+ })), d2.addEventListener("click", (() => {
1402
+ var i3, n4, o4;
1403
+ const c3 = r4.nextElementSibling;
1404
+ if (c3) {
1405
+ const u3 = Number(null === (i3 = s3.value) || void 0 === i3 ? void 0 : i3.split(".")[0]) + 1;
1406
+ s3.value = `${u3}. ${t5}`, a4.textContent = `${u3}. ${t5}`, l2.style.visibility = 1 === u3 ? "hidden" : "visible", d2.style.visibility = u3 === e5.length ? "hidden" : "visible";
1407
+ const m2 = c3.querySelector(".magicfeedback-input-magicfeedback-priority-list"), h2 = c3.querySelector(".magicfeedback-priority-list-item-label"), f2 = c3.querySelector(".magicfeedback-priority-list-arrow-up"), v2 = c3.querySelector(".magicfeedback-priority-list-arrow-down");
1408
+ if (m2 && h2 && f2 && v2) {
1409
+ const t6 = Number(m2.value.split(".")[0]) - 1;
1410
+ m2.value = `${t6}.${null === (n4 = h2.textContent) || void 0 === n4 ? void 0 : n4.split(".")[1]}`, h2.textContent = `${t6}.${null === (o4 = h2.textContent) || void 0 === o4 ? void 0 : o4.split(".")[1]}`, f2.style.visibility = 1 === t6 ? "hidden" : "visible", v2.style.visibility = t6 === e5.length ? "hidden" : "visible";
1411
+ }
1412
+ p.insertBefore(c3, r4);
1413
+ }
1414
+ })), o3.appendChild(l2), o3.appendChild(d2), r4.appendChild(o3), p.appendChild(r4);
1415
+ }));
1416
+ }, h = document.createElement("div");
1417
+ h.classList.add("magicfeedback-modal-backdrop"), h.style.position = "fixed", h.style.top = "0", h.style.left = "0", h.style.width = "100vw", h.style.height = "100vh", h.style.background = "rgba(0,0,0,0.4)", h.style.display = "none", h.style.alignItems = "center", h.style.justifyContent = "center", h.style.zIndex = "9999";
1418
+ const f = document.createElement("div");
1419
+ f.classList.add("magicfeedback-modal"), f.style.background = "#fff", f.style.borderRadius = "8px", f.style.boxShadow = "0 8px 24px rgba(0,0,0,0.2)", f.style.maxWidth = "520px", f.style.width = "90%", f.style.maxHeight = "80vh", f.style.overflow = "auto", f.style.padding = "16px", f.style.position = "relative";
1420
+ const v = document.createElement("h5");
1421
+ v.classList.add("magicfeedback-modal-title");
1422
+ const g = () => Math.min(e5.length + 1, s2), y = () => {
1423
+ v.textContent = `${l("selectOptionNumber")}${g()}`;
1424
+ };
1425
+ y();
1426
+ const b = document.createElement("div");
1427
+ b.classList.add("magicfeedback-modal-list"), (n2 ? [...t4].sort((() => Math.random() - 0.5)) : [...t4]).forEach(((t5) => {
1428
+ const n3 = document.createElement("label");
1429
+ n3.classList.add("magicfeedback-modal-row");
1430
+ const r4 = document.createElement("input");
1431
+ r4.type = "checkbox", r4.classList.add("magicfeedback-input"), r4.name = `${i2}-selection`, r4.value = t5;
1432
+ const a4 = document.createElement("span");
1433
+ a4.textContent = t5, r4.addEventListener("change", (() => {
1434
+ if (r4.checked) {
1435
+ if (e5.length >= s2) return r4.checked = false, n3.classList.add("magicfeedback-warning"), void setTimeout((() => {
1436
+ n3.classList.remove("magicfeedback-warning");
1437
+ }), 800);
1438
+ e5.push(t5);
1439
+ } else {
1440
+ const i3 = e5.indexOf(t5);
1441
+ -1 !== i3 && e5.splice(i3, 1);
1442
+ }
1443
+ y(), A();
1444
+ })), n3.appendChild(r4), n3.appendChild(a4), b.appendChild(n3);
1445
+ }));
1446
+ const E = document.createElement("div");
1447
+ E.classList.add("magicfeedback-modal-actions");
1448
+ const k = document.createElement("div");
1449
+ k.classList.add("magicfeedback-modal-counter");
1450
+ const A = () => {
1451
+ const t5 = l("of");
1452
+ k.textContent = `${l("prioritized")} ${e5.length} ${t5} ${s2}`, a3.style.display = e5.length > 0 ? "block" : "none";
1453
+ };
1454
+ A();
1455
+ const C = document.createElement("button");
1456
+ C.type = "button", C.classList.add("magicfeedback-modal-close"), C.setAttribute("aria-label", l("cancel")), C.title = l("cancel"), C.textContent = "\xD7", C.style.position = "absolute", C.style.top = "8px", C.style.right = "8px", C.style.border = "none", C.style.background = "transparent", C.style.fontSize = "24px", C.style.cursor = "pointer", C.addEventListener("click", (() => {
1457
+ h.style.display = "none";
1458
+ }));
1459
+ const T = document.createElement("button");
1460
+ return T.type = "button", T.textContent = l("confirm"), T.classList.add("magicfeedback-button"), T.classList.add("magicfeedback-button-primary"), T.addEventListener("click", (() => {
1461
+ h.style.display = "none", m();
1462
+ })), E.appendChild(k), E.appendChild(T), f.appendChild(C), f.appendChild(v), f.appendChild(b), f.appendChild(E), h.appendChild(f), c2.addEventListener("click", (() => {
1463
+ h.style.display = "flex", y(), A();
1464
+ })), h.addEventListener("click", ((e6) => {
1465
+ e6.target === h && (h.style.display = "none");
1466
+ })), d.appendChild(r3), d.appendChild(u2), d.appendChild(h), m(), d;
1467
+ }
1468
+ const c = document.createElement("ul");
1469
+ c.classList.add("magicfeedback-priority-list-list");
1470
+ const u = n2 ? [...t4].sort((() => Math.random() - 0.5)) : [...t4];
1471
+ return u.forEach(((e5, t5) => {
1472
+ const n3 = document.createElement("li");
1473
+ n3.classList.add("magicfeedback-priority-list-item"), n3.style.display = "flex", n3.style.justifyContent = "space-between", n3.style.alignItems = "center", n3.style.margin = "5px";
1474
+ const r3 = document.createElement("input");
1475
+ r3.classList.add("magicfeedback-input-magicfeedback-priority-list"), r3.classList.add("magicfeedback-input"), r3.type = "hidden", r3.id = `priority-list-${i2}`, r3.name = i2, r3.value = `${t5 + 1}. ${e5}`, n3.appendChild(r3);
1476
+ const s3 = document.createElement("label");
1477
+ s3.classList.add("magicfeedback-priority-list-item-label"), s3.textContent = `${t5 + 1}. ${e5}`, n3.appendChild(s3);
1478
+ const a3 = document.createElement("div");
1479
+ a3.style.display = "flex", a3.style.alignItems = "center", a3.style.justifyContent = "space-between";
1480
+ const o3 = document.createElement("img");
1481
+ o3.classList.add("magicfeedback-priority-list-arrow-up"), o3.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", o3.style.width = "20px", o3.style.height = "20px", o3.style.cursor = "pointer", o3.style.margin = "0 5px", o3.style.color = "#000", o3.style.visibility = 0 === t5 ? "hidden" : "visible", o3.addEventListener("click", (() => {
1482
+ var t6, i3, a4, d2;
1483
+ const p = n3.previousElementSibling;
1484
+ if (p) {
1485
+ const m = Number(null === (t6 = r3.value) || void 0 === t6 ? void 0 : t6.split(".")[0]) - 1;
1486
+ r3.value = `${m}. ${e5}`, s3.textContent = `${m}. ${e5}`, o3.style.visibility = 1 === m ? "hidden" : "visible", l2.style.visibility = m === u.length ? "hidden" : "visible";
1487
+ const h = p.querySelector(".magicfeedback-input-magicfeedback-priority-list"), f = p.querySelector(".magicfeedback-priority-list-item-label"), v = p.querySelector(".magicfeedback-priority-list-arrow-up"), g = p.querySelector(".magicfeedback-priority-list-arrow-down");
1488
+ if (h && f && v && g) {
1489
+ const e6 = Number(null === (i3 = h.value) || void 0 === i3 ? void 0 : i3.split(".")[0]) + 1;
1490
+ h.value = `${e6}.${null === (a4 = f.textContent) || void 0 === a4 ? void 0 : a4.split(".")[1]}`, f.textContent = `${e6}.${null === (d2 = f.textContent) || void 0 === d2 ? void 0 : d2.split(".")[1]}`, v.style.visibility = 1 === e6 ? "hidden" : "visible", g.style.visibility = e6 === u.length ? "hidden" : "visible";
1491
+ }
1492
+ c.insertBefore(n3, p);
1493
+ }
1494
+ }));
1495
+ const l2 = document.createElement("img");
1496
+ l2.classList.add("magicfeedback-priority-list-arrow-down"), l2.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", l2.style.width = "20px", l2.style.height = "20px", l2.style.cursor = "pointer", l2.style.margin = "0 5px", l2.style.color = "#000", l2.style.transform = "rotate(180deg)", l2.style.visibility = t5 === u.length - 1 ? "hidden" : "visible", l2.addEventListener("click", (() => {
1497
+ var t6, i3, a4;
1498
+ const d2 = n3.nextElementSibling;
1499
+ if (d2) {
1500
+ const p = Number(null === (t6 = r3.value) || void 0 === t6 ? void 0 : t6.split(".")[0]) + 1;
1501
+ r3.value = `${p}. ${e5}`, s3.textContent = `${p}. ${e5}`, o3.style.visibility = 1 === p ? "hidden" : "visible", l2.style.visibility = p === u.length ? "hidden" : "visible";
1502
+ const m = d2.querySelector(".magicfeedback-input-magicfeedback-priority-list"), h = d2.querySelector(".magicfeedback-priority-list-item-label"), f = d2.querySelector(".magicfeedback-priority-list-arrow-up"), v = d2.querySelector(".magicfeedback-priority-list-arrow-down");
1503
+ if (m && h && f && v) {
1504
+ const e6 = Number(m.value.split(".")[0]) - 1;
1505
+ m.value = `${e6}.${null === (i3 = h.textContent) || void 0 === i3 ? void 0 : i3.split(".")[1]}`, h.textContent = `${e6}.${null === (a4 = h.textContent) || void 0 === a4 ? void 0 : a4.split(".")[1]}`, f.style.visibility = 1 === e6 ? "hidden" : "visible", v.style.visibility = e6 === u.length ? "hidden" : "visible";
1506
+ }
1507
+ c.insertBefore(d2, n3);
1508
+ }
1509
+ })), a3.appendChild(o3), a3.appendChild(l2), n3.appendChild(a3), c.appendChild(n3);
1510
+ })), d.appendChild(c), d;
1511
+ })({ value: e3.value, ref: e3.ref, randomPosition: t3, limitPriority: (null === (n = e3.assets) || void 0 === n ? void 0 : n.limitPriority) || false, maxPriority: (null === (r = e3.assets) || void 0 === r ? void 0 : r.maxPriority) || 0, placeholder: (null === (s = e3.assets) || void 0 === s ? void 0 : s.placeholder) || "", language: i || "en" });
1512
+ return a.appendChild(o), { element: a, elementTypeClass: "magicfeedback-priority-list" };
1513
+ };
1514
+ }, 152: (e2, t2, i) => {
1515
+ "use strict";
1516
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderRatingEmoji = void 0;
1517
+ const n = i(559), r = "https://survey-dev.magicfeedback.io/assets/emojis";
1518
+ t2.renderRatingEmoji = ({ question: e3, url: t3, send: i2, urlParamValue: s }) => {
1519
+ var a;
1520
+ const { ref: o, assets: l } = e3, d = document.createElement("div"), c = "magicfeedback-rating", u = document.createElement("div");
1521
+ u.classList.add("magicfeedback-rating-container");
1522
+ const p = (null == l ? void 0 : l.max) ? Number(null == l ? void 0 : l.max) : 5, m = (null == l ? void 0 : l.min) ? Number(null == l ? void 0 : l.min) : 1, h = (0, n.createRatingPlaceholder)(m, p, null == l ? void 0 : l.minPlaceholder, null == l ? void 0 : l.maxPlaceholder, null !== (a = null == l ? void 0 : l.extraOption) && void 0 !== a && a);
1523
+ for (let e4 = m; e4 <= p; e4++) {
1524
+ const n2 = document.createElement("div");
1525
+ n2.classList.add("magicfeedback-rating-option");
1526
+ const a2 = document.createElement("label");
1527
+ a2.htmlFor = `rating-${o}-${e4}`, a2.classList.add("magicfeedback-rating-option-label-container");
1528
+ const l2 = document.createElement("label");
1529
+ l2.htmlFor = `rating-${o}-${e4}`, l2.textContent = e4.toString();
1530
+ const d2 = document.createElement("img");
1531
+ if (d2.alt = `face-${o}-${e4}`, d2.className = `rating-image${e4}`, 0 === m && 10 === p) d2.src = `${t3}/${e4}.svg`, d2.onerror = () => d2.src = `${r}/${e4}.svg`;
1532
+ else if (1 === m && 5 === p) switch (e4) {
1533
+ case 1:
1534
+ d2.src = `${t3}/1.svg`, d2.onerror = () => d2.src = `${r}/1.svg`;
1535
+ break;
1536
+ case 2:
1537
+ d2.src = `${t3}/2.svg`, d2.onerror = () => d2.src = `${r}/2.svg`;
1538
+ break;
1539
+ case 3:
1540
+ d2.src = `${t3}/6.svg`, d2.onerror = () => d2.src = `${r}/6.svg`;
1541
+ break;
1542
+ case 4:
1543
+ d2.src = `${t3}/9.svg`, d2.onerror = () => d2.src = `${r}/9.svg`;
1544
+ break;
1545
+ case 5:
1546
+ d2.src = `${t3}/10.svg`, d2.onerror = () => d2.src = `${r}/10.svg`;
1547
+ }
1548
+ else {
1549
+ const i3 = Math.round(10 / (p - m) * (e4 - m));
1550
+ d2.src = `${t3}/${i3}.svg`, d2.onerror = () => d2.src = `${r}/${i3}.svg`;
1551
+ }
1552
+ const h2 = document.createElement("input");
1553
+ h2.id = `rating-${o}-${e4}`, h2.type = "radio", h2.name = o, h2.value = e4.toString(), h2.classList.add(c), h2.classList.add("magicfeedback-input"), i2 && h2.addEventListener("change", (() => {
1554
+ i2();
1555
+ })), s && s === h2.value && (h2.checked = true), a2.appendChild(h2), a2.appendChild(d2), a2.appendChild(l2), n2.appendChild(a2), u.appendChild(n2);
1556
+ }
1557
+ if ((null == l ? void 0 : l.extraOption) && (null == l ? void 0 : l.extraOptionText)) {
1558
+ const e4 = document.createElement("div");
1559
+ e4.classList.add("magicfeedback-rating-option");
1560
+ const t4 = document.createElement("label");
1561
+ t4.htmlFor = `rating-${o}-extra`, t4.classList.add("magicfeedback-rating-option-label-container");
1562
+ const n2 = document.createElement("label");
1563
+ n2.htmlFor = `rating-${o}-extra`, n2.textContent = null == l ? void 0 : l.extraOptionText;
1564
+ const r2 = document.createElement("img");
1565
+ r2.src = "https://magicfeedback-c6458-dev.web.app/assets/question.svg", r2.alt = `face-${o}-extra`, r2.className = "magicfeedback-rating-image-extra";
1566
+ const s2 = document.createElement("input");
1567
+ s2.id = `rating-${o}-extra`, s2.type = "radio", s2.name = o, s2.value = "-", s2.classList.add(c), s2.classList.add("magicfeedback-input"), i2 && s2.addEventListener("change", (() => {
1568
+ i2();
1569
+ })), t4.appendChild(s2), t4.appendChild(r2), t4.appendChild(n2), e4.appendChild(t4), u.appendChild(e4);
1570
+ }
1571
+ return h.childElementCount > 0 && (u.classList.add("magicfeedback-rating-container--with-placeholder"), u.insertBefore(h, u.firstChild)), d.appendChild(u), { element: d, elementTypeClass: c };
1572
+ };
1573
+ }, 917: (e2, t2, i) => {
1574
+ "use strict";
1575
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderRatingNumber = void 0;
1576
+ const n = i(559);
1577
+ t2.renderRatingNumber = ({ question: e3, order: t3, direction: i2, isPhone: r, send: s, urlParamValue: a }) => {
1578
+ const o = "magicfeedback-rating-number";
1579
+ return { element: (0, n.createRatingNumberElement)(e3.ref, e3.assets, t3, i2, r, o, s, a), elementTypeClass: o };
1580
+ };
1581
+ }, 452: (e2, t2, i) => {
1582
+ "use strict";
1583
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderRatingStar = void 0;
1584
+ const n = i(559);
1585
+ t2.renderRatingStar = ({ question: e3, send: t3, urlParamValue: i2 }) => {
1586
+ var r, s;
1587
+ const a = document.createElement("div"), o = (0, n.createStarRating)(e3.ref, null === (r = e3.assets) || void 0 === r ? void 0 : r.minPlaceholder, null === (s = e3.assets) || void 0 === s ? void 0 : s.maxPlaceholder, t3, i2);
1588
+ return a.appendChild(o), { element: a, elementTypeClass: "magicfeedback-rating-star" };
1589
+ };
1590
+ }, 85: (e2, t2, i) => {
1591
+ "use strict";
1592
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderSelect = void 0;
1593
+ const n = i(516);
1594
+ t2.renderSelect = ({ question: e3, format: t3, language: i2, urlParamValue: r, send: s }) => {
1595
+ const { title: a, value: o, defaultValue: l } = e3, d = document.createElement("select"), c = document.createElement("option");
1596
+ return c.value = "", c.text = "slim" === t3 ? (0, n.parseTitle)(a, i2) : l || "Select an option", c.disabled = true, c.selected = true, d.appendChild(c), o.forEach(((e4) => {
1597
+ const t4 = document.createElement("option");
1598
+ t4.value = e4, t4.text = e4, d.appendChild(t4);
1599
+ })), r && o.includes(r) && (d.value = r), s && d.addEventListener("change", (() => {
1600
+ s();
1601
+ })), { element: d, elementTypeClass: "magicfeedback-select" };
1602
+ };
1603
+ }, 90: (e2, t2, i) => {
1604
+ "use strict";
1605
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderText = void 0;
1606
+ const n = i(784);
1607
+ t2.renderText = ({ language: e3, placeholderText: t3, urlParamValue: i2, send: r }) => {
1608
+ const s = document.createElement("input");
1609
+ return s.type = "text", s.placeholder = t3 || n.placeholder.answer(e3 || "en"), i2 && (s.value = i2), s.addEventListener("keyup", ((e4) => {
1610
+ e4.preventDefault(), "Enter" === e4.key && r && r();
1611
+ })), { element: s, elementTypeClass: "magicfeedback-text" };
1612
+ };
1613
+ }, 250: (e2, t2) => {
1614
+ "use strict";
1615
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderUploadFile = void 0, t2.renderUploadFile = ({ question: e3 }) => {
1616
+ var t3, i;
1617
+ const n = document.createElement("input");
1618
+ return n.type = "file", n.required = e3.require, n.multiple = (null === (t3 = e3.assets) || void 0 === t3 ? void 0 : t3.multiple) || false, n.maxLength = (null === (i = e3.assets) || void 0 === i ? void 0 : i.maxFiles) || 1, { element: n, elementTypeClass: "magicfeedback-upload-file" };
1619
+ };
1620
+ }, 843: (e2, t2) => {
1621
+ "use strict";
1622
+ Object.defineProperty(t2, "__esModule", { value: true }), t2.renderUploadImage = void 0, t2.renderUploadImage = ({ question: e3 }) => {
1623
+ var t3, i;
1624
+ const n = document.createElement("input");
1625
+ return n.type = "file", n.accept = "image/*", n.required = e3.require, n.multiple = (null === (t3 = e3.assets) || void 0 === t3 ? void 0 : t3.multiple) || false, n.maxLength = (null === (i = e3.assets) || void 0 === i ? void 0 : i.maxFiles) || 1, { element: n, elementTypeClass: "magicfeedback-upload-image" };
1626
+ };
935
1627
  }, 857: (e2, t2) => {
936
1628
  "use strict";
937
1629
  Object.defineProperty(t2, "__esModule", { value: true }), t2.endpoints = void 0, t2.endpoints = { sdk: { app: (e3, t3) => `sdk/app/${e3}/${t3}`, app_info: (e3, t3) => `sdk/app/${e3}/${t3}/info`, session: (e3) => `sdk/app/session/${e3}/info`, feedback: "sdk/feedback", followUpQuestion: "sdk/followUpQuestion" } };
@@ -1061,534 +1753,79 @@ var require_magicfeedback_sdk_browser = __commonJS({
1061
1753
  }, 213: (e2, t2, i) => {
1062
1754
  "use strict";
1063
1755
  Object.defineProperty(t2, "__esModule", { value: true }), t2.renderStartMessage = t2.renderSuccess = t2.renderError = t2.renderActions = t2.renderQuestions = void 0;
1064
- const n = i(558), a = i(784), s = "https://survey-dev.magicfeedback.io/assets/emojis";
1065
- function r(e3, t3) {
1066
- return e3 ? "object" == typeof e3 ? e3[t3] || e3.en : e3 : "";
1067
- }
1068
- function o(e3, t3, i2, n2, a2, s2 = true, r2 = "ltr", o2 = "row") {
1069
- const l = document.createElement("div");
1070
- l.classList.add("magicfeedback-rating-placeholder"), l.style.display = "flex", l.style.flexDirection = o2, l.style.alignItems = "center", l.style.justifyContent = "space-between", l.style.width = a2 ? `calc(100% - (100% / ${t3 + 1}))` : "100%", l.style.marginRight = "auto", s2 && window.innerWidth < 600 && (l.style.flexDirection = "column");
1071
- const d = document.createElement("span");
1072
- d.textContent = i2, d.classList.add("magicfeedback-rating-placeholder-value"), d.style.fontSize = "15px", d.style.textAlign = "ltr" === r2 ? "left" : "right", d.style.width = "50%", (s2 && window.innerWidth < 600 || "column" === o2) && (d.textContent = `${e3} = ${i2}`, d.style.width = "100%", d.style.textAlign = "left", d.style.marginBottom = "5px");
1073
- const c = document.createElement("span");
1074
- return c.textContent = n2, c.classList.add("magicfeedback-rating-placeholder-value"), c.style.fontSize = "15px", c.style.textAlign = "ltr" === r2 ? "right" : "left", c.style.width = "50%", (s2 && window.innerWidth < 600 || "column" === o2) && (c.textContent = `${t3} = ${n2}`, c.style.width = "100%", c.style.textAlign = "left", c.style.marginBottom = "5px"), "ltr" === r2 ? (i2 && l.appendChild(d), n2 && l.appendChild(c)) : (n2 && l.appendChild(c), i2 && l.appendChild(d)), l;
1075
- }
1076
- t2.renderQuestions = function e3(t3, i2 = "standard", l = "en", d = { customIcons: false }, c) {
1756
+ const n = i(42), r = i(516), s = { small: "1rem", medium: "1.2rem", large: "1.5rem" };
1757
+ t2.renderQuestions = function e3(t3, i2 = "standard", a = "en", o = { customIcons: false }, l) {
1077
1758
  if (!t3) throw new Error("[MagicFeedback] No questions provided");
1078
- const u = [], { customIcons: p, id: h } = d;
1079
- return t3.forEach(((m) => {
1080
- var f, g;
1081
- if ((null === (g = null === (f = null == m ? void 0 : m.questionType) || void 0 === f ? void 0 : f.conf) || void 0 === g ? void 0 : g.length) > 0) {
1759
+ const d = [], { customIcons: c, id: u } = o;
1760
+ return t3.forEach(((p) => {
1761
+ var m, h;
1762
+ if ((null === (h = null === (m = null == p ? void 0 : p.questionType) || void 0 === m ? void 0 : m.conf) || void 0 === h ? void 0 : h.length) > 0) {
1082
1763
  let t4 = document.createElement("div");
1083
1764
  t4.classList.add("magicfeedback-div");
1084
1765
  const n2 = document.createElement("label");
1085
- n2.setAttribute("for", `magicfeedback-${m.id}`), n2.textContent = r(m.title, l), n2.classList.add("magicfeedback-label"), t4.appendChild(n2), m.questionType.conf.forEach(((e4) => {
1086
- e4.ref = m.ref, m.assets[e4.id] && (e4.assets = { placeholder: m.assets[e4.id] });
1087
- })), e3(m.questionType.conf, i2, l, d, c).forEach(((e4) => {
1766
+ n2.setAttribute("for", `magicfeedback-${p.id}`), n2.textContent = (0, r.parseTitle)(p.title, a), n2.classList.add("magicfeedback-label"), t4.appendChild(n2), p.questionType.conf.forEach(((e4) => {
1767
+ e4.ref = p.ref, p.assets[e4.id] && (e4.assets = { placeholder: p.assets[e4.id] });
1768
+ })), e3(p.questionType.conf, i2, a, o, l).forEach(((e4) => {
1088
1769
  t4.appendChild(e4);
1089
- })), u.push(t4);
1770
+ })), d.push(t4);
1090
1771
  } else {
1091
- const e4 = (function(e5, t4, i3, l2, d2) {
1092
- var c2, u2, p2;
1093
- let h2, m2, { id: f2, title: g2, type: v, ref: y, require: E, value: b, defaultValue: A, assets: k } = e5, C = document.createElement("div");
1094
- C.classList.add("magicfeedback-div");
1095
- const T = window.innerWidth < 600, x = "slim" === t4 ? r(g2, i3) : null == k ? void 0 : k.placeholder, w = (N = y, new URLSearchParams(window.location.search).get(N)), L = (null == k ? void 0 : k.maxCharacters) || 0, P = void 0 !== (null == k ? void 0 : k.randomPosition) && (null == k ? void 0 : k.randomPosition), S = (null == k ? void 0 : k.direction) || "row", O = (null == k ? void 0 : k.order) || "ltr";
1096
- var N;
1097
- switch (v) {
1098
- case n.FEEDBACKAPPANSWERTYPE.TEXT:
1099
- h2 = document.createElement("input"), h2.type = "text", h2.placeholder = x || a.placeholder.answer(i3 || "en"), w && (h2.value = w), h2.addEventListener("keyup", ((e6) => {
1100
- e6.preventDefault(), console.log(e6.key, e6), "Enter" === e6.key && d2 && d2();
1101
- })), m2 = "magicfeedback-text";
1102
- break;
1103
- case n.FEEDBACKAPPANSWERTYPE.LONGTEXT:
1104
- h2 = document.createElement("textarea"), h2.rows = 3, L > 0 && (h2.maxLength = L), h2.placeholder = x || a.placeholder.answer(i3 || "en"), w && (h2.value = w), m2 = "magicfeedback-longtext";
1105
- break;
1106
- case n.FEEDBACKAPPANSWERTYPE.NUMBER:
1107
- h2 = document.createElement("input"), h2.type = "number", h2.placeholder = "slim" === t4 ? r(g2, i3) : a.placeholder.number(i3 || "en"), m2 = "magicfeedback-number", b.length && (b.sort(((e6, t5) => Number(e6) - Number(t5))), h2.max = b[b.length - 1], h2.min = b[0], h2.value = b[0]), w && !isNaN(Number(w)) && (h2.value = w);
1108
- break;
1109
- case n.FEEDBACKAPPANSWERTYPE.RADIO:
1110
- case n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE:
1111
- h2 = document.createElement("div"), m2 = "magicfeedback-" + ("MULTIPLECHOICE" === v ? "checkbox" : "radio");
1112
- let R = b || [];
1113
- P && (R = R.sort((() => Math.random() - 0.5)));
1114
- let $ = (null == k ? void 0 : k.exclusiveAnswers) || [];
1115
- (null == k ? void 0 : k.extraOption) && ($ = $.filter(((e6) => e6 !== k.extraOptionText))), $.length > 0 && (null == $ || $.forEach(((e6) => {
1116
- R.includes(e6) || R.push(e6);
1117
- }))), (null == k ? void 0 : k.extraOption) && !R.includes(null == k ? void 0 : k.extraOptionText) && R.push(null == k ? void 0 : k.extraOptionText), R.forEach(((e6, t5) => {
1118
- const s2 = document.createElement("div");
1119
- s2.classList.add(`magicfeedback-${"MULTIPLECHOICE" === v ? "checkbox" : "radio"}-container`);
1120
- const r2 = document.createElement("label"), o2 = document.createElement("input");
1121
- if (o2.id = `rating-${y}-${t5}`, o2.type = "MULTIPLECHOICE" === v ? "checkbox" : "radio", o2.name = y, o2.value = e6, o2.classList.add(m2), o2.classList.add("magicfeedback-input"), v === n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE && (null == k ? void 0 : k.maxOptions) && (null == k ? void 0 : k.maxOptions) > 0 && o2.addEventListener("change", (() => {
1122
- document.querySelectorAll(`input[name="${y}"]:checked`).length > (null == k ? void 0 : k.maxOptions) && (o2.checked = false);
1123
- })), v === n.FEEDBACKAPPANSWERTYPE.RADIO && d2 && (!(null == k ? void 0 : k.extraOptionText) || (null == k ? void 0 : k.extraOptionText) && e6 !== (null == k ? void 0 : k.extraOptionText)) && o2.addEventListener("change", (() => {
1124
- d2();
1125
- })), e6 !== A && e6 !== w || (o2.checked = true), r2.textContent = e6, r2.htmlFor = `rating-${y}-${t5}`, o2.addEventListener("change", ((t6) => {
1126
- const i4 = document.getElementById(`extra-option-${y}`);
1127
- t6.target.checked && $.includes(e6) ? (console.log("exclusiveAnswers", $, e6), R.forEach(((t7) => {
1128
- t7 !== e6 && (document.querySelector(`input[value="${t7}"]`).checked = false);
1129
- })), i4 && (i4.style.display = "none")) : $.forEach(((t7) => {
1130
- t7 !== e6 && (document.querySelector(`input[value="${t7}"]`).checked = false);
1131
- })), (null == k ? void 0 : k.extraOption) && e6 === (null == k ? void 0 : k.extraOptionText) && i4 && (i4.style.display = t6.target.checked ? "block" : "none");
1132
- })), s2.appendChild(o2), s2.appendChild(r2), h2.appendChild(s2), (null == k ? void 0 : k.extraOption) && e6 === (null == k ? void 0 : k.extraOptionText)) {
1133
- const e7 = document.createElement("input");
1134
- e7.type = "text", e7.placeholder = (null == k ? void 0 : k.extraOptionPlaceholder) || a.placeholder.answer(i3 || "en"), e7.classList.add("magicfeedback-extra-option"), e7.classList.add("magicfeedback-input"), e7.id = `extra-option-${y}`, e7.name = `extra-option-${y}`, e7.style.display = "none", h2.appendChild(e7);
1135
- }
1136
- }));
1137
- break;
1138
- case n.FEEDBACKAPPANSWERTYPE.BOOLEAN:
1139
- h2 = document.createElement("div"), m2 = "magicfeedback-radio";
1140
- const _ = document.createElement("div");
1141
- _.classList.add("magicfeedback-boolean-container"), _.style.display = "flex", _.style.flexDirection = "row", _.style.justifyContent = "space-between", _.style.width = "70%", _.style.margin = "auto", ((null == k ? void 0 : k.addIcon) ? ["\u{1F44D}", "\u{1F44E}"] : (function(e6) {
1142
- switch (e6) {
1143
- case "es":
1144
- return ["S\xED", "No"];
1145
- case "fr":
1146
- return ["Oui", "Non"];
1147
- case "de":
1148
- return ["Ja", "Nein"];
1149
- case "it":
1150
- return ["S\xEC", "No"];
1151
- case "pt":
1152
- return ["Sim", "N\xE3o"];
1153
- case "nl":
1154
- return ["Ja", "Nee"];
1155
- case "pl":
1156
- return ["Tak", "Nie"];
1157
- case "ru":
1158
- return ["\u0414\u0430", "\u041D\u0435\u0442"];
1159
- case "ja":
1160
- return ["\u306F\u3044", "\u3044\u3044\u3048"];
1161
- case "zh":
1162
- return ["\u662F", "\u4E0D"];
1163
- case "ko":
1164
- return ["\uC608", "\uC544\uB2C8"];
1165
- case "da":
1166
- case "sv":
1167
- return ["Ja", "Nej"];
1168
- case "fi":
1169
- return ["Kyll\xE4", "Ei"];
1170
- case "no":
1171
- return ["Ja", "Nei"];
1172
- case "ar":
1173
- return ["\u0646\u0639\u0645", "\u0644\u0627"];
1174
- case "bn":
1175
- return ["\u09B9\u09CD\u09AF\u09BE\u0981", "\u09A8\u09BE"];
1176
- default:
1177
- return ["Yes", "No"];
1178
- }
1179
- })(i3)).forEach(((e6, t5) => {
1180
- const i4 = document.createElement("label");
1181
- i4.classList.add("magicfeedback-boolean-option"), i4.htmlFor = `rating-${y}-${t5}`, i4.style.cursor = "pointer", i4.style.border = "1px solid #000", i4.style.display = "flex", i4.style.justifyContent = "center", i4.style.alignItems = "center", i4.style.margin = "auto", i4.style.padding = "0", i4.style.width = "45%", i4.style.height = "38px";
1182
- const n2 = document.createElement("label");
1183
- n2.htmlFor = `rating-${y}-${t5}`, n2.textContent = e6, n2.style.margin = "0", n2.style.padding = "0";
1184
- const a2 = document.createElement("input");
1185
- a2.id = `rating-${y}-${t5}`, a2.type = "radio", a2.name = y, a2.value = ["Yes", "No"][t5], a2.classList.add(m2), a2.classList.add("magicfeedback-input"), a2.style.position = "absolute", a2.style.opacity = "0", a2.style.width = "0", a2.style.height = "0", a2.style.margin = "0", a2.addEventListener("change", (() => {
1186
- d2 && d2();
1187
- })), w && w.toLowerCase() === a2.value.toLowerCase() && (a2.checked = true), i4.appendChild(a2), i4.appendChild(n2), _.appendChild(i4);
1188
- })), h2.appendChild(_);
1189
- break;
1190
- case n.FEEDBACKAPPANSWERTYPE.RATING_EMOJI:
1191
- h2 = document.createElement("div"), m2 = "magicfeedback-rating";
1192
- const F = document.createElement("div");
1193
- F.classList.add("magicfeedback-rating-container");
1194
- const M = (null == k ? void 0 : k.max) ? Number(null == k ? void 0 : k.max) : 5, B = (null == k ? void 0 : k.min) ? Number(null == k ? void 0 : k.min) : 1, U = o(B, M, null == k ? void 0 : k.minPlaceholder, null == k ? void 0 : k.maxPlaceholder, null == k ? void 0 : k.extraOption);
1195
- for (let ce = B; ce <= M; ce++) {
1196
- const ue = document.createElement("div");
1197
- ue.classList.add("magicfeedback-rating-option");
1198
- const pe = document.createElement("label");
1199
- pe.htmlFor = `rating-${y}-${ce}`, pe.classList.add("magicfeedback-rating-option-label-container");
1200
- const he = document.createElement("label");
1201
- he.htmlFor = `rating-${y}-${ce}`, he.textContent = ce.toString();
1202
- const me = document.createElement("img");
1203
- if (me.alt = `face-${y}-${ce}`, me.className = `rating-image${ce}`, 0 === B && 10 === M) me.src = `${l2}/${ce}.svg`, me.onerror = () => me.src = `${s}/${ce}.svg`;
1204
- else if (1 === B && 5 === M) switch (ce) {
1205
- case 1:
1206
- me.src = `${l2}/1.svg`, me.onerror = () => me.src = `${s}/1.svg`;
1207
- break;
1208
- case 2:
1209
- me.src = `${l2}/2.svg`, me.onerror = () => me.src = `${s}/2.svg`;
1210
- break;
1211
- case 3:
1212
- me.src = `${l2}/6.svg`, me.onerror = () => me.src = `${s}/6.svg`;
1213
- break;
1214
- case 4:
1215
- me.src = `${l2}/9.svg`, me.onerror = () => me.src = `${s}/9.svg`;
1216
- break;
1217
- case 5:
1218
- me.src = `${l2}/10.svg`, me.onerror = () => me.src = `${s}/10.svg`;
1219
- }
1220
- else {
1221
- const ge = Math.round(10 / (M - B) * (ce - B));
1222
- me.src = `${l2}/${ge}.svg`, me.onerror = () => me.src = `${s}/${ge}.svg`;
1223
- }
1224
- const fe = document.createElement("input");
1225
- fe.id = `rating-${y}-${ce}`, fe.type = "radio", fe.name = y, fe.value = ce.toString(), fe.classList.add(m2), fe.classList.add("magicfeedback-input"), d2 && fe.addEventListener("change", (() => {
1226
- d2();
1227
- })), w && w === fe.value && (fe.checked = true), pe.appendChild(fe), pe.appendChild(me), pe.appendChild(he), ue.appendChild(pe), F.appendChild(ue);
1228
- }
1229
- if ((null == k ? void 0 : k.extraOption) && (null == k ? void 0 : k.extraOptionText)) {
1230
- const ve = document.createElement("div");
1231
- ve.classList.add("magicfeedback-rating-option");
1232
- const ye = document.createElement("label");
1233
- ye.htmlFor = `rating-${y}-extra`, ye.classList.add("magicfeedback-rating-option-label-container");
1234
- const Ee = document.createElement("label");
1235
- Ee.htmlFor = `rating-${y}-extra`, Ee.textContent = null == k ? void 0 : k.extraOptionText;
1236
- const be = document.createElement("img");
1237
- be.src = "https://magicfeedback-c6458-dev.web.app/assets/question.svg", be.alt = `face-${y}-extra`, be.className = "magicfeedback-rating-image-extra";
1238
- const Ae = document.createElement("input");
1239
- Ae.id = `rating-${y}-extra`, Ae.type = "radio", Ae.name = y, Ae.value = "-", Ae.classList.add(m2), Ae.classList.add("magicfeedback-input"), d2 && Ae.addEventListener("change", (() => {
1240
- d2();
1241
- })), ye.appendChild(Ae), ye.appendChild(be), ye.appendChild(Ee), ve.appendChild(ye), F.appendChild(ve);
1242
- }
1243
- h2.appendChild(U), h2.appendChild(F);
1244
- break;
1245
- case n.FEEDBACKAPPANSWERTYPE.RATING_NUMBER:
1246
- m2 = "magicfeedback-rating-number", h2 = (function(e6, t5, i4, n2, a2, s2, r2, o2) {
1247
- const l3 = document.createElement("div");
1248
- l3.classList.add("magicfeedback-rating-number");
1249
- const d3 = "ltr" === i4 ? n2 : `${n2}-reverse`, c3 = document.createElement("div");
1250
- c3.classList.add("magicfeedback-rating-number-container"), c3.classList.add(`magicfeedback-rating-number-container-${i4}`), c3.classList.add(`magicfeedback-rating-number-container-${n2}`), c3.style.display = "flex", c3.style.flexDirection = d3, c3.setAttribute("role", "radiogroup"), c3.setAttribute("aria-label", (null == t5 ? void 0 : t5.ariaLabel) || "Rating");
1251
- const u3 = (null == t5 ? void 0 : t5.max) ? Number(null == t5 ? void 0 : t5.max) : 10, p3 = (null == t5 ? void 0 : t5.min) ? Number(null == t5 ? void 0 : t5.min) : 0, h3 = !(a2 || "column" === n2);
1252
- for (let i5 = p3; i5 <= u3; i5++) {
1253
- const a3 = document.createElement("div");
1254
- a3.classList.add("magicfeedback-rating-number-option"), a3.classList.add(`magicfeedback-rating-number-option-${n2}`);
1255
- const l4 = document.createElement("label");
1256
- if (l4.htmlFor = `rating-${e6}-${i5}`, l4.classList.add("magicfeedback-rating-number-option-label-container"), h3 && (l4.style.position = "relative", l4.style.overflow = "visible"), h3) {
1257
- const e7 = document.createElement("span");
1258
- e7.classList.add("magicfeedback-rating-number-cap"), e7.classList.add("magicfeedback-rating-placeholder-value"), e7.style.fontSize = "14px", e7.style.whiteSpace = "nowrap", e7.style.wordBreak = "normal", i5 === p3 && (null == t5 ? void 0 : t5.minPlaceholder) ? (e7.textContent = t5.minPlaceholder, e7.dataset.capType = "min") : i5 === u3 && (null == t5 ? void 0 : t5.maxPlaceholder) ? (e7.textContent = t5.maxPlaceholder, e7.dataset.capType = "max") : e7.dataset.capType = "mid", l4.appendChild(e7);
1259
- }
1260
- let d4 = i5.toString();
1261
- h3 || (i5 === p3 && (null == t5 ? void 0 : t5.minPlaceholder) && (d4 += ` = ${null == t5 ? void 0 : t5.minPlaceholder}`), i5 === u3 && (null == t5 ? void 0 : t5.maxPlaceholder) && (d4 += ` = ${null == t5 ? void 0 : t5.maxPlaceholder}`));
1262
- const m3 = document.createElement("input");
1263
- m3.id = `rating-${e6}-${i5}`, m3.type = "radio", m3.name = e6, m3.value = i5.toString(), m3.classList.add(s2), m3.classList.add("magicfeedback-input"), m3.setAttribute("aria-label", `${i5}`), r2 && m3.addEventListener("change", (() => r2())), o2 && o2 === m3.value && (m3.checked = true);
1264
- const f3 = document.createElement("label");
1265
- f3.htmlFor = `rating-${e6}-${i5}`, f3.textContent = d4, f3.classList.add("magicfeedback-rating-number-value"), l4.appendChild(m3), l4.appendChild(f3), a3.appendChild(l4), c3.appendChild(a3);
1266
- }
1267
- if ((null == t5 ? void 0 : t5.extraOption) && (null == t5 ? void 0 : t5.extraOptionText)) {
1268
- const n3 = document.createElement("div");
1269
- n3.classList.add("magicfeedback-rating-number-option");
1270
- const a3 = document.createElement("label");
1271
- if (a3.htmlFor = `rating-${e6}-extra`, a3.classList.add("magicfeedback-rating-number-option-label-container"), h3 && (a3.style.position = "relative", a3.style.overflow = "visible"), h3) {
1272
- const e7 = document.createElement("span");
1273
- e7.classList.add("magicfeedback-rating-number-cap"), e7.dataset.capType = "extra", e7.style.fontSize = "12px", e7.style.whiteSpace = "nowrap", e7.style.wordBreak = "normal", a3.appendChild(e7);
1274
- }
1275
- const o3 = document.createElement("input");
1276
- o3.id = `rating-${e6}-extra`, o3.type = "radio", o3.name = e6, o3.value = "-", o3.classList.add(s2), o3.classList.add("magicfeedback-input"), o3.setAttribute("aria-label", null == t5 ? void 0 : t5.extraOptionText), r2 && o3.addEventListener("change", (() => r2()));
1277
- const l4 = document.createElement("label");
1278
- l4.htmlFor = `rating-${e6}-extra`, l4.textContent = null == t5 ? void 0 : t5.extraOptionText, l4.classList.add("magicfeedback-rating-number-value"), a3.appendChild(o3), a3.appendChild(l4), n3.appendChild(a3), "ltr" === i4 ? c3.appendChild(n3) : c3.insertBefore(n3, c3.firstChild);
1279
- }
1280
- return l3.appendChild(c3), h3 && requestAnimationFrame((() => {
1281
- const e7 = Array.from(c3.querySelectorAll(".magicfeedback-rating-number-cap"));
1282
- if (0 === e7.length) return;
1283
- let t6 = 0;
1284
- e7.forEach(((e8) => {
1285
- var i5;
1286
- if (null === (i5 = e8.textContent) || void 0 === i5 ? void 0 : i5.trim()) {
1287
- const i6 = e8.getBoundingClientRect().height || 0;
1288
- i6 > t6 && (t6 = i6);
1289
- }
1290
- })), c3.style.position = "relative", c3.style.paddingTop = `${0 === t6 ? "42" : t6 + 6}px`, e7.forEach(((e8) => {
1291
- const n3 = e8.getBoundingClientRect().height || 0;
1292
- console.log(t6, n3, 6), e8.style.position = "absolute", e8.style.top = `-${0 === t6 ? "42" : t6 + n3}px`, e8.style.zIndex = "1", e8.style.pointerEvents = "none", e8.style.padding = "0", e8.style.boxSizing = "border-box", e8.style.whiteSpace = "nowrap", e8.style.wordBreak = "normal", e8.style.maxWidth = "none", e8.style.width = "max-content";
1293
- const a3 = e8.dataset.capType;
1294
- "min" === a3 ? ("ltr" === i4 ? (e8.style.left = "10px", e8.style.textAlign = "left") : (e8.style.right = "10px", e8.style.textAlign = "right"), e8.style.transform = "none") : "max" === a3 ? ("ltr" === i4 ? (e8.style.right = "10px", e8.style.textAlign = "right") : (e8.style.left = "10px", e8.style.textAlign = "left"), e8.style.transform = "none") : (e8.style.left = "50%", e8.style.transform = "translateX(-50%)", e8.style.textAlign = "center");
1295
- })), c3.style.overflow = "visible";
1296
- })), l3;
1297
- })(y, k, O, S, T, m2, d2, w);
1298
- break;
1299
- case n.FEEDBACKAPPANSWERTYPE.RATING_STAR:
1300
- h2 = document.createElement("div"), m2 = "magicfeedback-rating-star";
1301
- const q = (function(e6, t5, i4, n2 = () => {
1302
- }, a2) {
1303
- const s2 = "magicfeedback-rating-star-selected", r2 = document.createElement("div");
1304
- r2.classList.add("magicfeedback-rating-star-container"), r2.style.maxWidth = "300px", r2.style.margin = "auto", r2.dataset.originalSelection = "0";
1305
- for (let t6 = 1; t6 <= 5; t6++) {
1306
- const i5 = document.createElement("label");
1307
- i5.classList.add("magicfeedback-rating-star-option");
1308
- const o2 = document.createElement("input");
1309
- o2.id = `rating-${e6}-${t6}`, o2.type = "radio", o2.name = e6, o2.value = t6.toString(), o2.style.position = "absolute", o2.style.opacity = "0", o2.style.width = "0", o2.style.height = "0", o2.classList.add("magicfeedback-input"), a2 && a2 === o2.value && (o2.checked = true), o2.addEventListener("change", (() => {
1310
- const e7 = r2.querySelectorAll(".rating__star");
1311
- for (let t7 = 0; t7 < e7.length; t7++) t7 + 1 <= Number(o2.value) ? e7[t7].classList.contains(s2) || e7[t7].classList.add(s2) : e7[t7].classList.contains(s2) && e7[t7].classList.remove(s2);
1312
- r2.dataset.originalSelection = o2.value, n2 && n2();
1313
- })), i5.appendChild(o2);
1314
- const l3 = document.createElement("label");
1315
- l3.htmlFor = `rating-${e6}-${t6}`, l3.classList.add("rating__star"), l3.textContent = "\u2605", l3.style.fontSize = "40px", l3.style.color = "#CCCCCC", l3.style.cursor = "pointer", l3.addEventListener("mouseenter", (() => {
1316
- const e7 = r2.querySelectorAll(".rating__star"), i6 = t6 - 1;
1317
- e7.forEach(((e8, t7) => {
1318
- t7 <= i6 ? e8.classList.contains(s2) || e8.classList.add(s2) : e8.classList.contains(s2) && e8.classList.remove(s2);
1319
- }));
1320
- })), l3.addEventListener("mouseleave", (() => {
1321
- const e7 = Number(r2.dataset.originalSelection || "0");
1322
- r2.querySelectorAll(".rating__star").forEach(((t7, i6) => {
1323
- i6 < e7 ? t7.classList.contains(s2) || t7.classList.add(s2) : t7.classList.contains(s2) && t7.classList.remove(s2);
1324
- }));
1325
- })), i5.appendChild(l3), r2.appendChild(i5);
1326
- }
1327
- return r2.appendChild(o(1, 5, t5, i4, false, false)), r2;
1328
- })(y, null == k ? void 0 : k.minPlaceholder, null == k ? void 0 : k.maxPlaceholder, d2, w);
1329
- h2.appendChild(q);
1330
- break;
1331
- case n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE:
1332
- let V = function(e6) {
1333
- try {
1334
- const { position: t5, url: i4, value: n2 } = e6, a2 = document.createElement("label");
1335
- a2.classList.add("magicfeedback-multiple-choice-image-option"), a2.style.width = `calc( ${100 / W}% - 10px)`, a2.style.height = `calc( ${100 / K}% - 10px)`, a2.style.margin = "5px";
1336
- const s2 = document.createElement("label");
1337
- s2.htmlFor = `rating-${y}-${t5}`, s2.classList.add("magicfeedback-image-option-label-container"), s2.style.display = "flex", s2.style.flexDirection = "column", s2.addEventListener("mouseover", (() => {
1338
- s2.style.border = "2px solid #000";
1339
- })), s2.addEventListener("mouseout", (() => {
1340
- s2.style.border = "none";
1341
- })), s2.addEventListener("click", (() => {
1342
- s2.style.border = "2px solid #000";
1343
- }));
1344
- const r2 = document.createElement("label");
1345
- r2.textContent = n2, r2.classList.add("magicfeedback-multiple-choice-image-label");
1346
- const o2 = document.createElement("input");
1347
- o2.id = `rating-${y}-${t5}`, o2.type = Y ? "checkbox" : "radio", o2.name = y, o2.value = n2, o2.style.position = "absolute", o2.style.opacity = "0", o2.style.width = "0", o2.style.height = "0", o2.classList.add("magicfeedback-input"), w && w === o2.value && (o2.checked = true), !Y && d2 && o2.addEventListener("change", (() => {
1348
- console.log("send"), d2();
1349
- }));
1350
- const l3 = document.createElement("img");
1351
- l3.classList.add("magicfeedback-multiple-choice-image-image"), l3.src = i4, l3.style.cursor = "pointer", l3.style.backgroundSize = "cover", l3.style.backgroundPosition = "center", l3.style.width = "100%", l3.style.height = "100%", l3.style.objectFit = "cover", l3.style.margin = "auto", s2.appendChild(o2), s2.appendChild(l3), G && s2.appendChild(r2), a2.appendChild(s2), j.appendChild(a2);
1352
- } catch (e7) {
1353
- console.error(e7);
1354
- }
1355
- };
1356
- h2 = document.createElement("div"), m2 = "magicfeedback-multiple-choice-image";
1357
- const j = document.createElement("div");
1358
- j.classList.add("magicfeedback-multiple-choice-image-container"), j.style.display = "flex", j.style.flexDirection = "row", j.style.flexWrap = "wrap", j.style.justifyContent = "center";
1359
- const Q = b.length;
1360
- let W = 1, K = 1;
1361
- if (window.innerWidth < 600) W = 1, K = Q;
1362
- else switch (Q) {
1363
- case 1:
1364
- case 2:
1365
- case 3:
1366
- W = Q, K = 1;
1367
- break;
1368
- case 4:
1369
- case 5:
1370
- case 6:
1371
- K = 2, W = Math.ceil(Q / K);
1372
- break;
1373
- case 7:
1374
- case 8:
1375
- case 9:
1376
- K = 3, W = Math.ceil(Q / K);
1377
- break;
1378
- default:
1379
- K = 4, W = Math.ceil(Q / K);
1380
- }
1381
- const G = void 0 !== (null == k ? void 0 : k.addTitle) && (null == k ? void 0 : k.addTitle), Y = void 0 !== (null == k ? void 0 : k.multiOption) && (null == k ? void 0 : k.multiOption), H = void 0 !== (null == k ? void 0 : k.extraOption) && (null == k ? void 0 : k.extraOption);
1382
- P && (b = b.sort((() => Math.random() - 0.5))), b.forEach(((e6) => V(JSON.parse(e6)))), H && (null == k ? void 0 : k.extraOptionValue) && (null == k ? void 0 : k.extraOptionValue.length) > 0 && V(null == k ? void 0 : k.extraOptionValue[0]), h2.appendChild(j);
1383
- break;
1384
- case n.FEEDBACKAPPANSWERTYPE.SELECT:
1385
- h2 = document.createElement("select"), m2 = "magicfeedback-select";
1386
- const X = document.createElement("option");
1387
- X.value = "", X.text = "slim" === t4 ? r(g2, i3) : A || "Select an option", X.disabled = true, X.selected = true, h2.appendChild(X), b.forEach(((e6) => {
1388
- const t5 = document.createElement("option");
1389
- t5.value = e6, t5.text = e6, h2.appendChild(t5);
1390
- })), w && b.includes(w) && (h2.value = w), d2 && h2.addEventListener("change", (() => {
1391
- d2();
1392
- }));
1393
- break;
1394
- case n.FEEDBACKAPPANSWERTYPE.DATE:
1395
- h2 = document.createElement("input"), h2.type = "date", h2.required = E, h2.placeholder = x || a.placeholder.date(i3 || "en"), m2 = "magicfeedback-date", w && (h2.value = w);
1396
- break;
1397
- case n.FEEDBACKAPPANSWERTYPE.CONSENT:
1398
- h2 = document.createElement("input"), m2 = "magicfeedback-consent", h2.type = "checkbox", h2.id = `magicfeedback-${f2}`, h2.name = y, h2.value = "true", h2.required = E, h2.classList.add("magicfeedback-consent"), h2.classList.add("magicfeedback-input"), w && b.includes(w) && (h2.checked = true), d2 && h2.addEventListener("change", (() => {
1399
- d2();
1400
- }));
1401
- break;
1402
- case n.FEEDBACKAPPANSWERTYPE.EMAIL:
1403
- h2 = document.createElement("input"), h2.type = "email", h2.required = E, h2.placeholder = x || "you@example.com", m2 = "magicfeedback-email", w && (h2.value = w);
1404
- break;
1405
- case n.FEEDBACKAPPANSWERTYPE.PASSWORD:
1406
- h2 = document.createElement("input"), h2.type = "password", h2.required = E, h2.placeholder = x || a.placeholder.password(i3 || "en"), m2 = "magicfeedback-password", w && (h2.value = w);
1407
- break;
1408
- case n.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX:
1409
- h2 = document.createElement("div"), m2 = "magicfeedback-multi-question-matrix";
1410
- const z = document.createElement("div");
1411
- z.classList.add("magicfeedback-multi-question-matrix-container");
1412
- let J = (null == k ? void 0 : k.options) || [], Z = [...b], ee = [];
1413
- if (P && (J = null == J ? void 0 : J.sort((() => Math.random() - 0.5)), Z = [...Z].sort((() => Math.random() - 0.5))), (null == k ? void 0 : k.exclusiveAnswers) && (ee = null == k ? void 0 : k.exclusiveAnswers, null == ee || ee.forEach(((e6) => {
1414
- Z.includes(e6) || Z.push(e6);
1415
- }))), window.innerWidth < 600) {
1416
- const ke = document.createElement("div");
1417
- ke.classList.add("magicfeedback-multi-question-matrix-list"), null == J || J.forEach(((e6) => {
1418
- const t5 = document.createElement("div");
1419
- t5.classList.add("magicfeedback-multi-question-matrix-list-item"), t5.style.display = "flex", t5.style.flexDirection = "column", t5.style.alignItems = "flex-start", t5.style.marginBottom = "10px";
1420
- const i4 = document.createElement("label");
1421
- i4.classList.add("magicfeedback-multi-question-matrix-label"), i4.style.paddingBottom = "10px", i4.textContent = e6, t5.appendChild(i4), Z.forEach(((i5) => {
1422
- const n2 = document.createElement("div");
1423
- n2.classList.add("magicfeedback-radio-container"), n2.style.display = "flex", n2.style.alignItems = "center", n2.style.justifyContent = "flex-start", n2.style.width = "99%", n2.style.margin = "5px auto";
1424
- const a2 = document.createElement("label"), s2 = document.createElement("input");
1425
- s2.id = `${y}-${e6}-${i5}`, s2.type = "radio", s2.name = `${y}-${e6}`, s2.value = i5, s2.classList.add("magicfeedback-input"), a2.textContent = i5, a2.htmlFor = `${y}-${e6}-${i5}`, n2.appendChild(s2), n2.appendChild(a2), t5.appendChild(n2);
1426
- })), ke.appendChild(t5);
1427
- })), z.appendChild(ke);
1428
- } else {
1429
- const Ce = document.createElement("table");
1430
- Ce.classList.add("magicfeedback-multi-question-matrix-table");
1431
- const Te = document.createElement("thead");
1432
- Te.classList.add("magicfeedback-multi-question-matrix-header"), Te.style.paddingBottom = "15px";
1433
- const xe = document.createElement("tr"), we = document.createElement("th");
1434
- xe.appendChild(we), Z.forEach(((e6) => {
1435
- const t5 = document.createElement("th");
1436
- t5.textContent = e6, xe.appendChild(t5);
1437
- })), Te.appendChild(xe), Ce.appendChild(Te);
1438
- const Le = document.createElement("tbody");
1439
- null == J || J.forEach(((e6) => {
1440
- const t5 = document.createElement("tr");
1441
- t5.classList.add("magicfeedback-multi-question-matrix-row-tr");
1442
- const i4 = document.createElement("td");
1443
- i4.style.minWidth = "200px", i4.style.padding = "10px";
1444
- const n2 = document.createElement("label");
1445
- n2.classList.add("magicfeedback-multi-question-matrix-label"), n2.textContent = e6, i4.appendChild(n2), t5.appendChild(i4), Z.forEach(((i5) => {
1446
- const n3 = document.createElement("td"), a2 = document.createElement("input");
1447
- a2.type = "radio", a2.name = `${y}-${e6}`, a2.value = i5, a2.id = `${y}-${e6}-${i5}`, a2.classList.add("magicfeedback-input"), n3.appendChild(a2), t5.appendChild(n3);
1448
- })), Le.appendChild(t5);
1449
- })), Ce.appendChild(Le), z.appendChild(Ce);
1450
- }
1451
- h2.appendChild(z);
1452
- break;
1453
- case n.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST:
1454
- h2 = document.createElement("div"), m2 = "magicfeedback-priority-list";
1455
- const te = document.createElement("div");
1456
- te.classList.add("magicfeedback-priority-list-container");
1457
- const ie = document.createElement("ul");
1458
- ie.classList.add("magicfeedback-priority-list-list"), P && (b = b.sort((() => Math.random() - 0.5))), b.forEach(((e6, t5) => {
1459
- const i4 = document.createElement("li");
1460
- i4.classList.add("magicfeedback-priority-list-item"), i4.style.display = "flex", i4.style.justifyContent = "space-between", i4.style.alignItems = "center", i4.style.margin = "5px";
1461
- const n2 = document.createElement("input");
1462
- n2.classList.add("magicfeedback-input-magicfeedback-priority-list"), n2.classList.add("magicfeedback-input"), n2.type = "hidden", n2.id = `priority-list-${y}`, n2.name = y, n2.value = `${t5 + 1}. ${e6}`, i4.appendChild(n2);
1463
- const a2 = document.createElement("label");
1464
- a2.classList.add("magicfeedback-priority-list-item-label"), a2.textContent = `${t5 + 1}. ${e6}`, i4.appendChild(a2);
1465
- const s2 = document.createElement("div");
1466
- s2.style.display = "flex", s2.style.alignItems = "center", s2.style.justifyContent = "space-between";
1467
- const r2 = document.createElement("img");
1468
- r2.classList.add("magicfeedback-priority-list-arrow-up"), r2.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", r2.style.width = "20px", r2.style.height = "20px", r2.style.cursor = "pointer", r2.style.margin = "0 5px", r2.style.color = "#000", r2.style.visibility = 0 === t5 ? "hidden" : "visible", r2.addEventListener("click", (() => {
1469
- var t6, s3, l3, d3;
1470
- const c3 = i4.previousElementSibling;
1471
- if (c3) {
1472
- const u3 = Number(null === (t6 = n2.value) || void 0 === t6 ? void 0 : t6.split(".")[0]) - 1;
1473
- n2.value = `${u3}. ${e6}`, a2.textContent = `${u3}. ${e6}`, r2.style.visibility = 1 === u3 ? "hidden" : "visible", o2.style.visibility = u3 === b.length ? "hidden" : "visible";
1474
- const p3 = c3.querySelector(".magicfeedback-input-magicfeedback-priority-list"), h3 = c3.querySelector(".magicfeedback-priority-list-item-label"), m3 = c3.querySelector(".magicfeedback-priority-list-arrow-up"), f3 = c3.querySelector(".magicfeedback-priority-list-arrow-down");
1475
- if (p3 && h3 && m3 && f3) {
1476
- const e7 = Number(null === (s3 = p3.value) || void 0 === s3 ? void 0 : s3.split(".")[0]) + 1;
1477
- p3.value = `${e7}.${null === (l3 = h3.textContent) || void 0 === l3 ? void 0 : l3.split(".")[1]}`, h3.textContent = `${e7}.${null === (d3 = h3.textContent) || void 0 === d3 ? void 0 : d3.split(".")[1]}`, m3.style.visibility = 1 === e7 ? "hidden" : "visible", f3.style.visibility = e7 === b.length ? "hidden" : "visible";
1478
- }
1479
- ie.insertBefore(i4, c3);
1480
- }
1481
- })), s2.appendChild(r2);
1482
- const o2 = document.createElement("img");
1483
- o2.classList.add("magicfeedback-priority-list-arrow-down"), o2.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", o2.style.width = "20px", o2.style.height = "20px", o2.style.cursor = "pointer", o2.style.margin = "0 5px", o2.style.color = "#000", o2.style.transform = "rotate(180deg)", o2.style.visibility = t5 === b.length - 1 ? "hidden" : "visible", o2.addEventListener("click", (() => {
1484
- var t6, s3, l3;
1485
- const d3 = i4.nextElementSibling;
1486
- if (d3) {
1487
- const c3 = Number(null === (t6 = n2.value) || void 0 === t6 ? void 0 : t6.split(".")[0]) + 1;
1488
- n2.value = c3.toString(), a2.textContent = `${c3.toString()}. ${e6}`, r2.style.visibility = 1 === c3 ? "hidden" : "visible", o2.style.visibility = c3 === b.length ? "hidden" : "visible";
1489
- const u3 = d3.querySelector(".magicfeedback-input-magicfeedback-priority-list"), p3 = d3.querySelector(".magicfeedback-priority-list-item-label"), h3 = d3.querySelector(".magicfeedback-priority-list-arrow-up"), m3 = d3.querySelector(".magicfeedback-priority-list-arrow-down");
1490
- if (u3 && p3 && h3 && m3) {
1491
- const e7 = Number(u3.value.split(".")[0]) - 1;
1492
- u3.value = `${e7}.${null === (s3 = p3.textContent) || void 0 === s3 ? void 0 : s3.split(".")[1]}`, p3.textContent = `${e7}.${null === (l3 = p3.textContent) || void 0 === l3 ? void 0 : l3.split(".")[1]}`, h3.style.visibility = 1 === e7 ? "hidden" : "visible", m3.style.visibility = e7 === b.length ? "hidden" : "visible";
1493
- }
1494
- ie.insertBefore(d3, i4);
1495
- }
1496
- })), s2.appendChild(o2), i4.appendChild(s2), ie.appendChild(i4);
1497
- })), te.appendChild(ie), h2.appendChild(te);
1498
- break;
1499
- case n.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM:
1500
- h2 = document.createElement("div"), m2 = "magicfeedback-point-system";
1501
- const ne = document.createElement("div");
1502
- ne.classList.add("magicfeedback-point-system-container");
1503
- const ae = document.createElement("ul");
1504
- ae.classList.add("magicfeedback-point-system-list"), ae.style.padding = "0";
1505
- const se = 100, re = se / b.length, oe = document.createElement("div");
1506
- oe.classList.add("magicfeedback-error"), oe.textContent = a.placeholder.pointsystemerror(i3 || "en"), oe.style.color = "#C70039", oe.style.fontSize = "14px", oe.style.textAlign = "right", oe.style.width = "100%", oe.style.display = "none";
1507
- const le = document.createElement("div");
1508
- le.classList.add("magicfeedback-point-system-total"), le.textContent = "0 / 100 %", le.style.textAlign = "right", le.style.fontSize = "15px", le.style.marginTop = "5px", b.forEach(((e6, t5) => {
1509
- const i4 = document.createElement("li");
1510
- i4.classList.add("magicfeedback-point-system-item"), i4.style.display = "flex", i4.style.justifyContent = "space-between", i4.style.alignItems = "center", i4.style.margin = "5px";
1511
- const n2 = document.createElement("label");
1512
- n2.textContent = e6, n2.style.fontSize = "15px", i4.appendChild(n2);
1513
- const a2 = document.createElement("span");
1514
- a2.classList.add("magicfeedback-point-system-input-container");
1515
- const s2 = document.createElement("input");
1516
- s2.name = y, s2.id = `${e6}`, s2.type = "number", s2.min = "0", s2.max = `${se}`, s2.value = "0", s2.classList.add("magicfeedback-input"), s2.style.width = "40px", s2.style.border = "0", s2.style.textAlign = "center", s2.style.margin = "0 5px", s2.autofocus = 0 === t5;
1517
- const r2 = document.createElement("span");
1518
- r2.textContent = "%", r2.style.color = "#000", s2.addEventListener("input", (() => {
1519
- const e7 = ae.querySelectorAll("input");
1520
- let t6 = 0;
1521
- e7.forEach(((e8) => {
1522
- t6 += Number(e8.value);
1523
- })), t6 > se && (s2.value = `${re}%`, t6 -= Number(s2.value));
1524
- const i5 = document.getElementById("magicfeedback-submit");
1525
- i5 && (t6 < 100 ? (le.style.color = "orange", i5.setAttribute("disabled", "true")) : (oe.style.display = "none", le.style.color = "green", i5.removeAttribute("disabled"))), le.textContent = `${t6} / 100 %`;
1526
- })), s2.addEventListener("focus", (() => {
1527
- const e7 = document.getElementById("magicfeedback-submit");
1528
- e7 && (e7.setAttribute("disabled", "true"), e7.addEventListener("pointerover", (() => {
1529
- const e8 = ae.querySelectorAll("input");
1530
- let t6 = 0;
1531
- e8.forEach(((e9) => {
1532
- t6 += Number(e9.value);
1533
- })), t6 < 100 && (oe.style.display = "block");
1534
- })));
1535
- })), a2.appendChild(s2), a2.appendChild(r2), i4.appendChild(a2), ae.appendChild(i4);
1536
- })), ne.appendChild(ae), ne.appendChild(le), ne.appendChild(oe), h2.appendChild(ne);
1537
- break;
1538
- case n.FEEDBACKAPPANSWERTYPE.INFO_PAGE:
1539
- h2 = document.createElement("div"), m2 = "magicfeedback-info-page";
1540
- const de = document.createElement("div");
1541
- de.classList.add("magicfeedback-info-message"), de.innerHTML = x, h2.appendChild(de);
1542
- break;
1543
- case n.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE:
1544
- h2 = document.createElement("input"), h2.type = "file", h2.accept = "image/*", h2.required = E, h2.multiple = (null == k ? void 0 : k.multiple) || false, h2.maxLength = (null == k ? void 0 : k.maxFiles) || 1, m2 = "magicfeedback-upload-image";
1545
- break;
1546
- case n.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE:
1547
- h2 = document.createElement("input"), h2.type = "file", h2.required = E, h2.multiple = (null == k ? void 0 : k.multiple) || false, h2.maxLength = (null == k ? void 0 : k.maxFiles) || 1, m2 = "magicfeedback-upload-file";
1548
- break;
1549
- default:
1550
- return C;
1772
+ const e4 = (function(e5, t4, i3, a2, o2) {
1773
+ var l2, d2, c2;
1774
+ let u2, p2, { id: m2, title: h2, type: f, ref: v, require: g, defaultValue: y, assets: b } = e5, E = document.createElement("div");
1775
+ E.classList.add("magicfeedback-div");
1776
+ const k = window.innerWidth < 600, A = "slim" === t4 ? (0, r.parseTitle)(h2, i3) : null == b ? void 0 : b.placeholder, C = (0, r.getUrlParam)(v), T = (null == b ? void 0 : b.maxCharacters) || 0, P = void 0 !== (null == b ? void 0 : b.randomPosition) && (null == b ? void 0 : b.randomPosition), w = (null == b ? void 0 : b.direction) || "row", x = (null == b ? void 0 : b.order) || "ltr", O = (0, n.getQuestionRenderer)(f);
1777
+ if (!O) return E;
1778
+ {
1779
+ const n2 = O({ question: e5, format: t4, language: i3, url: a2, send: o2, isPhone: k, urlParamValue: C, placeholderText: A, maxCharacters: T, randomPosition: P, direction: w, order: x });
1780
+ u2 = n2.element, p2 = n2.elementTypeClass;
1551
1781
  }
1552
- h2.id = `magicfeedback-${f2}`, h2.setAttribute("name", y), h2.classList.add(m2), (void 0 !== A || null !== w) && (h2.value = w || A), ["RADIO", "MULTIPLECHOICE"].includes(v) || (h2.classList.add("magicfeedback-input"), h2.required = E);
1553
- const I = document.createElement("label");
1554
- I.setAttribute("for", `magicfeedback-${f2}`), I.textContent = r(g2, i3), I.classList.add("magicfeedback-label");
1555
- const D = document.createElement("label");
1556
- if (D.textContent = r(null == k ? void 0 : k.subtitle, i3), D.classList.add("magicfeedback-sublabel"), (null === (c2 = null == k ? void 0 : k.subtitleStyle) || void 0 === c2 ? void 0 : c2.includes("italic")) && (D.style.fontStyle = "italic"), (null === (u2 = null == k ? void 0 : k.subtitleStyle) || void 0 === u2 ? void 0 : u2.includes("bold")) && (D.style.fontWeight = "bold"), (null === (p2 = null == k ? void 0 : k.subtitleStyle) || void 0 === p2 ? void 0 : p2.includes("underline")) && (D.style.textDecoration = "underline"), ["CONSENT"].includes(v)) C.classList.add("magicfeedback-consent-container"), C.appendChild(h2), C.appendChild(I), C.appendChild(D);
1782
+ u2.id = `magicfeedback-${m2}`, u2.setAttribute("name", v), u2.classList.add(p2), (void 0 !== y || null !== C) && (u2.value = C || y), ["RADIO", "MULTIPLECHOICE"].includes(f) || (u2.classList.add("magicfeedback-input"), u2.required = g);
1783
+ const L = document.createElement("label");
1784
+ L.setAttribute("for", `magicfeedback-${m2}`), L.textContent = (0, r.parseTitle)(h2, i3), L.classList.add("magicfeedback-label"), (function(e6, t5) {
1785
+ if ("INFO_PAGE" !== t5.type) return;
1786
+ const { assets: i4 } = t5, n2 = (function(e7) {
1787
+ if (e7) return s[e7] || e7;
1788
+ })(null == i4 ? void 0 : i4.titleSize), r2 = (a3 = null == i4 ? void 0 : i4.titleStyle, Array.isArray(a3) ? a3 : a3 ? [a3] : []);
1789
+ var a3;
1790
+ 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");
1791
+ })(L, e5);
1792
+ const S = document.createElement("label");
1793
+ if (S.textContent = (0, r.parseTitle)(null == b ? void 0 : b.subtitle, i3), S.classList.add("magicfeedback-sublabel"), (null === (l2 = null == b ? void 0 : b.subtitleStyle) || void 0 === l2 ? void 0 : l2.includes("italic")) && (S.style.fontStyle = "italic"), (null === (d2 = null == b ? void 0 : b.subtitleStyle) || void 0 === d2 ? void 0 : d2.includes("bold")) && (S.style.fontWeight = "bold"), (null === (c2 = null == b ? void 0 : b.subtitleStyle) || void 0 === c2 ? void 0 : c2.includes("underline")) && (S.style.textDecoration = "underline"), ["CONSENT"].includes(f)) E.classList.add("magicfeedback-consent-container"), E.appendChild(u2), E.appendChild(L), (null == b ? void 0 : b.subtitle) && E.appendChild(S);
1557
1794
  else {
1558
- if ("slim" !== t4 && (C.appendChild(I), C.appendChild(D), void 0 !== (null == k ? void 0 : k.general) && "" !== (null == k ? void 0 : k.general))) {
1559
- const Pe = document.createElement("img");
1560
- Pe.src = null == k ? void 0 : k.general, Pe.classList.add("magicfeedback-image"), Pe.style.maxWidth = "auto", Pe.style.height = "400px", Pe.style.margin = "10px 0", C.appendChild(Pe);
1795
+ if ("slim" !== t4 && (E.appendChild(L), (null == b ? void 0 : b.subtitle) && E.appendChild(S), void 0 !== (null == b ? void 0 : b.general) && "" !== (null == b ? void 0 : b.general))) {
1796
+ const e6 = document.createElement("img");
1797
+ e6.src = null == b ? void 0 : b.general, e6.classList.add("magicfeedback-image"), e6.style.maxWidth = "auto", e6.style.height = "400px", e6.style.margin = "10px 0", E.appendChild(e6);
1561
1798
  }
1562
- if ("LONGTEXT" === v && L > 0) {
1563
- const Se = document.createElement("div");
1564
- if (Se.classList.add("magicfeedback-counter"), Se.textContent = `${h2.value.length}/${L}`, Se.style.textAlign = "right", Se.style.fontSize = "15px", Se.style.marginTop = "5px", h2.addEventListener("input", (() => {
1565
- Se.textContent = `${h2.value.length}/${L}`;
1566
- })), C.appendChild(h2), C.appendChild(Se), (null == k ? void 0 : k.extraOption) && (null == k ? void 0 : k.extraOptionText)) {
1567
- const Oe = document.createElement("div");
1568
- Oe.classList.add("magicfeedback-skip-container"), Oe.classList.add("magicfeedback-checkbox-container"), Oe.style.display = "flex", Oe.style.justifyContent = "flex-start";
1569
- const Ne = document.createElement("input");
1570
- Ne.classList.add("magicfeedback-skip"), Ne.type = "checkbox", Ne.id = `skip-${y}`, Ne.name = y, Ne.value = "-", Ne.style.cursor = "pointer";
1571
- const Ie = document.createElement("label");
1572
- Ie.htmlFor = `skip-${y}`, Ie.textContent = null == k ? void 0 : k.extraOptionText, Ie.style.fontSize = "15px", Ie.style.cursor = "pointer", Ie.style.margin = "0 5px", Ne.addEventListener("click", (() => {
1573
- h2.value = "-", d2 && d2();
1574
- })), Oe.appendChild(Ne), Oe.appendChild(Ie), C.appendChild(Oe);
1799
+ if ("LONGTEXT" === f && T > 0) {
1800
+ const e6 = document.createElement("div");
1801
+ if (e6.classList.add("magicfeedback-counter"), e6.textContent = `${u2.value.length}/${T}`, e6.style.textAlign = "right", e6.style.fontSize = "15px", e6.style.marginTop = "5px", u2.addEventListener("input", (() => {
1802
+ e6.textContent = `${u2.value.length}/${T}`;
1803
+ })), E.appendChild(u2), E.appendChild(e6), (null == b ? void 0 : b.extraOption) && (null == b ? void 0 : b.extraOptionText)) {
1804
+ const e7 = document.createElement("div");
1805
+ e7.classList.add("magicfeedback-skip-container"), e7.classList.add("magicfeedback-checkbox-container"), e7.style.display = "flex", e7.style.justifyContent = "flex-start";
1806
+ const t5 = document.createElement("input");
1807
+ t5.classList.add("magicfeedback-skip"), t5.type = "checkbox", t5.id = `skip-${v}`, t5.name = v, t5.value = "-", t5.style.cursor = "pointer";
1808
+ const i4 = document.createElement("label");
1809
+ i4.htmlFor = `skip-${v}`, i4.textContent = null == b ? void 0 : b.extraOptionText, i4.style.fontSize = "15px", i4.style.cursor = "pointer", i4.style.margin = "0 5px", t5.addEventListener("click", (() => {
1810
+ u2.value = "-", o2 && o2();
1811
+ })), e7.appendChild(t5), e7.appendChild(i4), E.appendChild(e7);
1575
1812
  }
1576
- } else C.appendChild(h2);
1813
+ } else E.appendChild(u2);
1577
1814
  }
1578
- return C;
1579
- })(m, i2, l, `${s}${p ? `/${h}` : ""}`, 1 === t3.length ? c : void 0);
1580
- u.push(e4);
1815
+ return E;
1816
+ })(p, i2, a, "https://survey-dev.magicfeedback.io/assets/emojis" + (c ? `/${u}` : ""), 1 === t3.length ? l : void 0);
1817
+ d.push(e4);
1581
1818
  }
1582
- })), u;
1583
- }, t2.renderActions = function(e3 = "", t3, i2 = "Submit", n2 = "Back", a2 = "Next") {
1819
+ })), d;
1820
+ }, t2.renderActions = function(e3 = "", t3, i2 = "Submit", n2 = "Back", r2 = "Next") {
1584
1821
  const s2 = document.createElement("div");
1585
1822
  s2.classList.add("magicfeedback-action-container");
1586
- const r2 = document.createElement("button");
1587
- r2.id = "magicfeedback-submit", r2.type = "submit", r2.classList.add("magicfeedback-submit"), r2.textContent = "MAGICSURVEY" === e3 ? a2 || "Next" : i2 || "Submit";
1588
- const o2 = document.createElement("button");
1589
- return o2.id = "magicfeedback-back", o2.type = "button", o2.classList.add("magicfeedback-back"), o2.textContent = n2 || "Back", o2.addEventListener("click", t3), o2.addEventListener("click", (() => {
1590
- r2.removeAttribute("disabled");
1591
- })), "MAGICSURVEY" === e3 && s2.appendChild(o2), s2.appendChild(r2), s2;
1823
+ const a = document.createElement("button");
1824
+ a.id = "magicfeedback-submit", a.type = "submit", a.classList.add("magicfeedback-submit"), a.textContent = "MAGICSURVEY" === e3 ? r2 || "Next" : i2 || "Submit";
1825
+ const o = document.createElement("button");
1826
+ return o.id = "magicfeedback-back", o.type = "button", o.classList.add("magicfeedback-back"), o.textContent = n2 || "Back", o.addEventListener("click", t3), o.addEventListener("click", (() => {
1827
+ a.removeAttribute("disabled");
1828
+ })), "MAGICSURVEY" === e3 && s2.appendChild(o), s2.appendChild(a), s2;
1592
1829
  }, t2.renderError = function(e3) {
1593
1830
  const t3 = document.createElement("div");
1594
1831
  return t3.classList.add("magicfeedback-error"), t3.textContent = e3, t3;
@@ -1597,20 +1834,20 @@ var require_magicfeedback_sdk_browser = __commonJS({
1597
1834
  return t3.classList.add("magicfeedback-success"), t3.textContent = e3, t3;
1598
1835
  }, t2.renderStartMessage = function(e3, t3 = false, i2 = "Go!", n2 = () => {
1599
1836
  }) {
1600
- const a2 = document.createElement("div");
1601
- a2.classList.add("magicfeedback-start-message-container");
1837
+ const r2 = document.createElement("div");
1838
+ r2.classList.add("magicfeedback-start-message-container");
1602
1839
  const s2 = document.createElement("div");
1603
- if (s2.classList.add("magicfeedback-start-message"), s2.innerHTML = e3, a2.appendChild(s2), t3) {
1840
+ if (s2.classList.add("magicfeedback-start-message"), s2.innerHTML = e3, r2.appendChild(s2), t3) {
1604
1841
  const e4 = document.createElement("button");
1605
- e4.id = "magicfeedback-start-message-button", e4.classList.add("magicfeedback-start-message-button"), e4.textContent = i2, e4.addEventListener("click", (() => n2())), a2.appendChild(e4);
1842
+ e4.id = "magicfeedback-start-message-button", e4.classList.add("magicfeedback-start-message-button"), e4.textContent = i2, e4.addEventListener("click", (() => n2())), r2.appendChild(e4);
1606
1843
  }
1607
- return a2;
1844
+ return r2;
1608
1845
  };
1609
1846
  }, 313: function(e2, t2, i) {
1610
1847
  "use strict";
1611
1848
  var n = this && this.__awaiter || function(e3, t3, i2, n2) {
1612
- return new (i2 || (i2 = Promise))((function(a2, s2) {
1613
- function r2(e4) {
1849
+ return new (i2 || (i2 = Promise))((function(r2, s2) {
1850
+ function a2(e4) {
1614
1851
  try {
1615
1852
  l2(n2.next(e4));
1616
1853
  } catch (e5) {
@@ -1626,26 +1863,26 @@ var require_magicfeedback_sdk_browser = __commonJS({
1626
1863
  }
1627
1864
  function l2(e4) {
1628
1865
  var t4;
1629
- e4.done ? a2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
1866
+ e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
1630
1867
  e5(t4);
1631
- }))).then(r2, o2);
1868
+ }))).then(a2, o2);
1632
1869
  }
1633
1870
  l2((n2 = n2.apply(e3, t3 || [])).next());
1634
1871
  }));
1635
- }, a = this && this.__importDefault || function(e3) {
1872
+ }, r = this && this.__importDefault || function(e3) {
1636
1873
  return e3 && e3.__esModule ? e3 : { default: e3 };
1637
1874
  };
1638
1875
  Object.defineProperty(t2, "__esModule", { value: true }), t2.getFollowUpQuestion = t2.sendFeedback = t2.getQuestions = t2.getSessionForm = t2.getForm = t2.validateEmail = void 0;
1639
- const s = a(i(945)), r = a(i(330)), o = i(857), l = { Accept: "application/json", "Magicfeedback-Sdk-Version": r.default.version, "x-magicfeedback-parameters": window.location.search || "" };
1876
+ const s = r(i(945)), a = r(i(330)), o = i(857), l = { Accept: "application/json", "Magicfeedback-Sdk-Version": a.default.version, "x-magicfeedback-parameters": window.location.search || "" };
1640
1877
  t2.validateEmail = function(e3) {
1641
1878
  return /\S+@\S+\.\S+/.test(e3);
1642
- }, t2.getForm = function(e3, t3, i2, a2) {
1879
+ }, t2.getForm = function(e3, t3, i2, r2) {
1643
1880
  return n(this, void 0, void 0, (function* () {
1644
1881
  try {
1645
1882
  const n2 = yield (0, s.default)(e3 + o.endpoints.sdk.app_info(t3, i2), { method: "GET", headers: l });
1646
1883
  return yield n2.json();
1647
1884
  } catch (e4) {
1648
- a2.err(e4);
1885
+ r2.err(e4);
1649
1886
  }
1650
1887
  }));
1651
1888
  }, t2.getSessionForm = function(e3, t3, i2) {
@@ -1657,17 +1894,17 @@ var require_magicfeedback_sdk_browser = __commonJS({
1657
1894
  i2.err(e4);
1658
1895
  }
1659
1896
  }));
1660
- }, t2.getQuestions = function(e3, t3, i2, a2) {
1897
+ }, t2.getQuestions = function(e3, t3, i2, r2) {
1661
1898
  return n(this, void 0, void 0, (function* () {
1662
1899
  try {
1663
1900
  const n2 = yield (0, s.default)(e3 + o.endpoints.sdk.app(t3, i2), { method: "GET", headers: l });
1664
1901
  if (n2.ok) {
1665
1902
  const e4 = yield n2.json();
1666
- return a2.log(`Received questions for app ${t3}`, e4), e4;
1903
+ return r2.log(`Received questions for app ${t3}`, e4), e4;
1667
1904
  }
1668
- throw a2.err(`Failed to get questions for app ${t3}:`, n2.status, n2.statusText), new Error("[MagicFeedback] Bad response from server");
1905
+ throw r2.err(`Failed to get questions for app ${t3}:`, n2.status, n2.statusText), new Error("[MagicFeedback] Bad response from server");
1669
1906
  } catch (e4) {
1670
- return a2.err(e4), [];
1907
+ return r2.err(e4), [];
1671
1908
  }
1672
1909
  }));
1673
1910
  }, t2.sendFeedback = function(e3, t3, i2) {
@@ -1706,10 +1943,10 @@ var require_magicfeedback_sdk_browser = __commonJS({
1706
1943
  };
1707
1944
  }, 330: (e2) => {
1708
1945
  "use strict";
1709
- e2.exports = JSON.parse('{"name":"@magicfeedback/native","version":"2.1.4","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","publish":"npm publish --access public","publish:beta":"npm publish --access public --tag beta","publish:alpha":"npm publish --access public --tag alpha","test":"jest","test:watch":"jest --watchAll","coverage":"vitest run --coverage"},"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","vitest":"^0.5.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"}');
1946
+ e2.exports = JSON.parse('{"name":"@magicfeedback/native","version":"2.2.1","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":"vitest run --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","vitest":"^0.5.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"}');
1710
1947
  } }, t = {}, (function i(n) {
1711
- var a = t[n];
1712
- if (void 0 !== a) return a.exports;
1948
+ var r = t[n];
1949
+ if (void 0 !== r) return r.exports;
1713
1950
  var s = t[n] = { exports: {} };
1714
1951
  return e[n].call(s.exports, s, s.exports, i), s.exports;
1715
1952
  })(156).default;
@@ -1718,27 +1955,890 @@ var require_magicfeedback_sdk_browser = __commonJS({
1718
1955
  }
1719
1956
  });
1720
1957
 
1721
- // src/index.ts
1722
- var index_exports = {};
1723
- __export(index_exports, {
1724
- DeepdotsPopups: () => DeepdotsPopups
1725
- });
1726
- module.exports = __toCommonJS(index_exports);
1958
+ // src/index.ts
1959
+ var index_exports = {};
1960
+ __export(index_exports, {
1961
+ DeepdotsPopups: () => DeepdotsPopups,
1962
+ POPUP_TRIGGER_CONDITION_STATUSES: () => POPUP_TRIGGER_CONDITION_STATUSES
1963
+ });
1964
+ module.exports = __toCommonJS(index_exports);
1965
+
1966
+ // src/types/index.ts
1967
+ var POPUP_TRIGGER_CONDITION_STATUSES = [
1968
+ "SHOWED",
1969
+ "PARTIAL",
1970
+ "COMPLETED"
1971
+ ];
1972
+
1973
+ // src/ui/renderPopup.ts
1974
+ var import_native = __toESM(require_magicfeedback_sdk_browser());
1975
+
1976
+ // src/assets/style.css
1977
+ var style_default = `.magicfeedback-container {
1978
+ width: 100%;
1979
+ }
1980
+
1981
+
1982
+ .magicfeedback-success-message,
1983
+ .magicfeedback-info-message,
1984
+ .magicfeedback-start-message,
1985
+ .magicfeedback-container{
1986
+ animation-duration: 0.5s;
1987
+ animation-name: animate-fade;
1988
+ animation-delay: 0.25s;
1989
+ animation-fill-mode: backwards;
1990
+
1991
+ font-style: normal;
1992
+ text-align: justify;
1993
+ font-weight: 400;
1994
+ font-size: 1.2rem;
1995
+ color: #475569;
1996
+ line-height: 1.5;
1997
+ }
1998
+
1999
+ @keyframes animate-fade {
2000
+ 0% { opacity: 0; }
2001
+ 100% { opacity: 1; }
2002
+ }
2003
+
2004
+ .magicfeedback-form {
2005
+ display: flex;
2006
+ flex-direction: column;
2007
+ justify-content: flex-start;
2008
+ align-items: center;
2009
+ width: 100%;
2010
+ }
2011
+ .magicfeedback-questions {
2012
+ display: flex;
2013
+ flex-direction: column;
2014
+ justify-content: flex-start;
2015
+ align-items: flex-start;
2016
+ width: 100%;
2017
+ }
2018
+
2019
+ .magicfeedback-div {
2020
+ display: flex;
2021
+ flex-direction: column;
2022
+ justify-content: flex-start;
2023
+ align-items: flex-start;
2024
+ margin-bottom: 10px;
2025
+ width: 100%;
2026
+ }
2027
+
2028
+ .magicfeedback-label {
2029
+ margin-bottom: 25px;
2030
+ margin-top: 20px;
2031
+ font-weight: 400;
2032
+ font-family: inherit;
2033
+ font-size: 1.2rem;
2034
+ color: #212529;
2035
+ text-align: start;
2036
+ word-wrap: break-word;
2037
+ white-space: normal;
2038
+
2039
+ }
2040
+
2041
+ .magicfeedback-checkbox {
2042
+ display: flex;
2043
+ flex-direction: column;
2044
+ flex-wrap: wrap;
2045
+ width: 100%;
2046
+ }
2047
+
2048
+ .magicfeedback-checkbox-container {
2049
+ display: flex;
2050
+ flex-direction: row;
2051
+ justify-content: flex-start;
2052
+ align-items: center;
2053
+ margin-bottom: 5px;
2054
+ margin-top: 5px;
2055
+ }
2056
+
2057
+ .magicfeedback-radio {
2058
+ display: flex;
2059
+ flex-direction: column;
2060
+ justify-content: flex-start;
2061
+ flex-wrap: wrap;
2062
+ width: 100%;
2063
+ margin-right: 5px;
2064
+ padding: 5px;
2065
+ }
2066
+
2067
+ .magicfeedback-checkbox-container,
2068
+ .magicfeedback-radio-container {
2069
+ display: flex;
2070
+ flex-direction: row;
2071
+ justify-content: flex-start;
2072
+ align-items: center;
2073
+ margin: 5px;
2074
+ padding: 5px 0;
2075
+ background-color: #fff;
2076
+ border-radius: 5px;
2077
+ box-shadow: 0 0 3px #ccc;
2078
+ }
2079
+
2080
+ input::-webkit-outer-spin-button,
2081
+ input::-webkit-inner-spin-button {
2082
+ -webkit-appearance: none;
2083
+ -moz-appearance: textfield;
2084
+ }
2085
+
2086
+ .magicfeedback-checkbox input[type="checkbox"] {
2087
+ margin-right: 5px;
2088
+ margin-left: 5px;
2089
+ width: 20px;
2090
+ height: 20px;
2091
+ cursor: pointer;
2092
+ }
2093
+
2094
+
2095
+ .magicfeedback-checkbox label,
2096
+ .magicfeedback-radio-container label {
2097
+ margin-left: 5px;
2098
+ font-weight: 400;
2099
+ font-family: inherit;
2100
+ font-size: 16px;
2101
+ color: #212529;
2102
+ text-align: start;
2103
+ width: 100%;
2104
+ }
2105
+
2106
+ p {
2107
+ margin-bottom: 0px;
2108
+ font-size: 12px;
2109
+ }
2110
+
2111
+ h2 {
2112
+ line-height: 1.66;
2113
+ margin: 0;
2114
+ padding: 0;
2115
+ font-weight: 900;
2116
+ color: #222;
2117
+ font-family: 'Montserrat';
2118
+ font-size: 18px;
2119
+ text-transform: uppercase;
2120
+ text-align: center;
2121
+ margin-bottom: 40px;
2122
+ }
2123
+
2124
+ h6 {
2125
+ margin-bottom: 1rem;
2126
+ }
2127
+
2128
+ input[type="date"],
2129
+ input[type="text"],
2130
+ input[type="number"],
2131
+ input[type="email"],
2132
+ input[type="password"],
2133
+ textarea,
2134
+ select {
2135
+ box-sizing: border-box;
2136
+ padding: 10px;
2137
+ margin: 10px 0;
2138
+ width: 100%;
2139
+ border: 2px solid #ccc; /* Default border color - you can customize this */
2140
+ border-radius: 5px;
2141
+ font-size: 18px;
2142
+ outline: none;
2143
+ transition: border-color 0.3s ease;
2144
+ min-height: 50px;
2145
+ font-family: inherit;
2146
+ -webkit-appearance: none;
2147
+ }
2148
+
2149
+ select {
2150
+ background-image: linear-gradient(45deg, transparent 50%, gray 50%),
2151
+ linear-gradient(135deg, gray 50%, transparent 50%),
2152
+ linear-gradient(to right, #ccc, #ccc);
2153
+ background-position: calc(100% - 20px) calc(1em + 2px),
2154
+ calc(100% - 15px) calc(1em + 2px),
2155
+ calc(100% - 2.5em) 0.5em;
2156
+ background-size: 5px 5px,
2157
+ 5px 5px,
2158
+ 1px 1.5em;
2159
+ background-repeat: no-repeat;
2160
+ }
2161
+
2162
+ .magicfeedback-boolean-container {
2163
+ display: flex;
2164
+ flex-direction: row;
2165
+ justify-content: flex-start;
2166
+ align-items: center;
2167
+ margin: 10px 0;
2168
+ width: 100%;
2169
+ }
2170
+
2171
+ .magicfeedback-boolean-container label {
2172
+ margin-left: 10px;
2173
+ font-weight: 400;
2174
+ font-size: 16px;
2175
+ width: 100%;
2176
+ padding-top: 5px;
2177
+ }
2178
+
2179
+ .magicfeedback-boolean-option {
2180
+ margin-right: 10px;
2181
+ margin-left: 10px;
2182
+ width: 100%;
2183
+ height: 38px;
2184
+ border-radius: 8px;
2185
+ font-size: 16px;
2186
+ cursor: pointer;
2187
+ border: 1px solid #ced4da !important;
2188
+ }
2189
+
2190
+ .magicfeedback-boolean-option label {
2191
+ font-weight: 400;
2192
+ font-size: 16px;
2193
+ color: #475569;
2194
+ cursor: pointer;
2195
+ width: 100%;
2196
+ height: 100%;
2197
+ display: flex;
2198
+ justify-content: center;
2199
+ align-items: center;
2200
+ border-radius: inherit;
2201
+ }
2202
+
2203
+ .magicfeedback-boolean-option input[type=radio] + label:hover {
2204
+ color: #007bff;
2205
+ }
2206
+
2207
+ .magicfeedback-boolean-option input[type=radio]:checked + label {
2208
+ color: #007bff;
2209
+ background-color: #cadff8;
2210
+ }
2211
+
2212
+ input[type="radio"] {
2213
+ padding: 20px;
2214
+ margin: 10px 0 10px 15px;
2215
+ width: 40px;
2216
+ background-color: #fff;
2217
+ box-shadow: none;
2218
+ }
2219
+
2220
+ /* Style for focused input/select */
2221
+ input:focus, select:focus {
2222
+ border-color: #4CAF50; /* Highlight color when focused - you can customize this */
2223
+ }
2224
+
2225
+ /* Style for invalid input (example: validation error) */
2226
+ input.error, select.error {
2227
+ border-color: #ff3333; /* Red color for error state - you can customize this */
2228
+ }
2229
+
2230
+ .magicfeedback-action-container {
2231
+ display: flex;
2232
+ flex-direction: row;
2233
+ justify-content: space-between;
2234
+ align-items: center;
2235
+ margin-top: 10px;
2236
+ width: 100%;
2237
+ }
2238
+
2239
+ .magicfeedback-action-container .magicfeedback-submit {
2240
+ cursor: pointer;
2241
+ padding: 10px;
2242
+ margin: 10px 0;
2243
+ width: 100px;
2244
+ border-radius: 8px;
2245
+ font-size: 16px;
2246
+ outline: none;
2247
+ transition: border-color 0.3s ease;
2248
+ background-color: #1E293B;
2249
+ color: white;
2250
+ }
2251
+
2252
+ .magicfeedback-action-container .magicfeedback-back {
2253
+ cursor: pointer;
2254
+ padding: 10px;
2255
+ margin: 10px 0;
2256
+ width: 100px;
2257
+ border: 0;
2258
+ border-radius: 8px;
2259
+ font-size: 16px;
2260
+ outline: none;
2261
+ transition: border-color 0.3s ease;
2262
+ background-color: transparent;
2263
+ color: #212529;
2264
+ }
2265
+
2266
+
2267
+
2268
+ /* Rating styles */
2269
+ .magicfeedback-rating {
2270
+ width: 100%;
2271
+ }
2272
+
2273
+ .magicfeedback-rating-container {
2274
+ display: flex;
2275
+ flex-direction: row;
2276
+ justify-content: space-around;
2277
+ flex-wrap: wrap;
2278
+ align-items: center;
2279
+
2280
+ margin: 15px 5px;
2281
+ padding: 0;
2282
+
2283
+ list-style: none;
2284
+ font-size: 1.5rem;
2285
+ cursor: pointer;
2286
+ user-select: none;
2287
+ -webkit-user-select: none;
2288
+ -moz-user-select: none;
2289
+ -ms-user-select: none;
2290
+ }
2291
+
2292
+ .magicfeedback-rating-placeholder-value,
2293
+ .magicfeedback-rating-placeholder{
2294
+ text-align: center;
2295
+ align-content: center;
2296
+ justify-content: center;
2297
+ text-wrap: wrap;
2298
+ }
2299
+
2300
+ .magicfeedback-rating-option {
2301
+ margin: 0 0.5rem;
2302
+ padding: 0;
2303
+ }
2304
+
2305
+ @media (max-width: 1024px) {
2306
+ .magicfeedback-rating-option {
2307
+ margin: 10px 0;
2308
+ padding: 0;
2309
+ width: 20%;
2310
+ display: flex;
2311
+ justify-content: center;
2312
+ }
2313
+
2314
+ .magicfeedback-rating-placeholder-value {
2315
+ font-size: 0.75rem;
2316
+ margin-bottom: 1px;
2317
+ }
2318
+ .magicfeedback-rating-placeholder{
2319
+ justify-content: center;
2320
+ }
2321
+
2322
+ .magicfeedback-rating-container {
2323
+ flex-wrap: wrap;
2324
+ justify-content: flex-start;
2325
+ }
2326
+ }
2327
+
2328
+
2329
+ .magicfeedback-rating-option-label-container {
2330
+ display: flex;
2331
+ flex-direction: column;
2332
+ }
2333
+
2334
+
2335
+ .magicfeedback-rating-option-label-container label {
2336
+ display: inline-block;
2337
+ text-align: center;
2338
+ margin-bottom: 0;
2339
+ font-weight: 600;
2340
+ font-size: 18px;
2341
+ color: #475569;
2342
+ }
2343
+
2344
+ .magicfeedback-rating-option-label-container input[type=radio] {
2345
+ position: absolute;
2346
+ opacity: 0;
2347
+ width: 0;
2348
+ height: 0;
2349
+ }
2350
+
2351
+ /* IMAGE STYLES */
2352
+ .magicfeedback-rating-option-label-container input[type=radio] + img {
2353
+ cursor: pointer;
2354
+ height: 48px;
2355
+ width: 48px;
2356
+ }
2357
+
2358
+ /* LABEL STYLES */
2359
+ .magicfeedback-rating-option-label-container input[type=radio] + label {
2360
+ cursor: pointer;
2361
+ }
2362
+
2363
+ /* CHECKED STYLES */
2364
+ .magicfeedback-rating-option-label-container input[type=radio]:checked + img {
2365
+ box-shadow: #007bff 0px 1px 4px, #007BFFA0 0px 0px 0px 2px;
2366
+ border-radius: 50%;
2367
+ }
2368
+
2369
+ .magicfeedback-rating-number {
2370
+ width: 100%;
2371
+ }
2372
+ .magicfeedback-rating-container,
2373
+ .magicfeedback-rating-number-container {
2374
+ display: flex;
2375
+ flex-direction: row;
2376
+ justify-content: space-between;
2377
+ align-items: center;
2378
+
2379
+ margin: 15px 0;
2380
+ padding: 0;
2381
+
2382
+ list-style: none;
2383
+ font-size: 1.5rem;
2384
+ cursor: pointer;
2385
+ user-select: none;
2386
+ -webkit-user-select: none;
2387
+ -moz-user-select: none;
2388
+ -ms-user-select: none;
2389
+ }
2390
+
2391
+ /* Cuando hay placeholders (Very bad / Very good), el placeholder ocupa
2392
+ el 100% de la primera l\xEDnea y los boxes bajan a la siguiente */
2393
+ .magicfeedback-rating-number-container--with-placeholder {
2394
+ flex-wrap: wrap;
2395
+ align-items: flex-start;
2396
+ }
2397
+
2398
+ .magicfeedback-rating-number-container--with-placeholder .magicfeedback-rating-placeholder {
2399
+ width: 100%;
2400
+ margin-bottom: 8px;
2401
+ }
2402
+
2403
+ .magicfeedback-rating-number-container--with-placeholder .magicfeedback-rating-number-option {
2404
+ width: auto;
2405
+ flex: 1;
2406
+ }
2407
+
2408
+ .magicfeedback-rating-number-option {
2409
+ display: flex;
2410
+ flex-direction: row;
2411
+ justify-content: flex-start;
2412
+ align-items: center;
2413
+ margin: 5px;
2414
+ padding: 0;
2415
+ list-style: none;
2416
+ font-size: 1.5rem;
2417
+ cursor: pointer;
2418
+ user-select: none;
2419
+ -webkit-user-select: none;
2420
+ -moz-user-select: none;
2421
+ -ms-user-select: none;
2422
+ width: 100%;
2423
+ }
2424
+
2425
+ .magicfeedback-rating-number-option-row{
2426
+ max-width: 100% !important;
2427
+ }
2428
+
2429
+ .magicfeedback-rating-number-top-placeholder,
2430
+ .magicfeedback-rating-number-bottom-placeholder{
2431
+ text-align: center !important;
2432
+ align-content: center;
2433
+ justify-content: center;
2434
+ text-wrap: wrap;
2435
+
2436
+ font-size: 15px;
2437
+ color: #475569;
2438
+
2439
+ width: 100%;
2440
+ margin: auto;
2441
+ }
2442
+
2443
+ @media (min-width: 650px) {
2444
+ .magicfeedback-rating-number-option-row +.magicfeedback-rating-number-container-ltr:first-child,
2445
+ .magicfeedback-rating-number-option-row + +.magicfeedback-rating-number-container-rtl:last-child {
2446
+ margin-left: 0;
2447
+ width: calc(100% - 10px);
2448
+ }
2449
+
2450
+ .magicfeedback-rating-number-option-row +.magicfeedback-rating-number-container-rtl:first-child,
2451
+ .magicfeedback-rating-number-option-row + +.magicfeedback-rating-number-container-ltr:last-child {
2452
+ margin-right: 0;
2453
+ width: calc(100% - 10px);
2454
+ }
2455
+ }
2456
+
2457
+
2458
+ .magicfeedback-rating-number-option-label-container {
2459
+ display: flex;
2460
+ flex-direction: column;
2461
+ align-items: center;
2462
+ justify-content: center;
2463
+ width: 100%;
2464
+ height: 100%;
2465
+ }
2466
+
2467
+ .magicfeedback-rating-number-option-label-container label {
2468
+ display: flex;
2469
+ align-items: center;
2470
+ justify-content: center;
2471
+ white-space: nowrap;
2472
+ overflow: hidden;
2473
+ text-overflow: ellipsis;
2474
+ margin: 0 10px;
2475
+ font-weight: 600;
2476
+ font-size: 14px;
2477
+ color: #475569;
2478
+ cursor: pointer;
2479
+ width: 100%;
2480
+ height: 100%;
2481
+ min-height: 50px;
2482
+ text-align: center;
2483
+ padding: 0;
2484
+ border-radius: 4px;
2485
+ border: 1px solid #ced4da;
2486
+ background-color: rgba(246, 246, 246, 0.3);
2487
+ transition: background-color 0.15s ease-in-out;
2488
+ }
2489
+
2490
+ .magicfeedback-rating-number-option-label-container input[type=radio] {
2491
+ position: absolute;
2492
+ opacity: 0;
2493
+ width: 0;
2494
+ height: 0;
2495
+ }
2496
+
2497
+ .magicfeedback-rating-number-option-label-container input[type=radio] + label {
2498
+ cursor: pointer;
2499
+ }
2500
+
2501
+ .magicfeedback-rating-number-option-label-container input[type=radio] + label:hover,
2502
+ .magicfeedback-rating-number-option-label-container input[type=radio]:checked + label {
2503
+ color: #007bff;
2504
+ border: 1px solid #007bff;
2505
+ background-color: rgba(86, 168, 253, 0.29);
2506
+ }
2507
+
2508
+ .magicfeedback-rating-number-container-column{
2509
+ align-items: flex-start !important;
2510
+ }
2511
+
2512
+ @media (max-width: 650px) {
2513
+ .magicfeedback-rating-number-container-ltr {
2514
+ justify-content: center;
2515
+ flex-wrap: wrap;
2516
+ }
2517
+
2518
+ .magicfeedback-rating-number-container-rtl {
2519
+ justify-content: center;
2520
+ flex-wrap: wrap-reverse;
2521
+ }
2522
+
2523
+ .magicfeedback-rating-number-option {
2524
+ max-width: 100%;
2525
+ height: 55px;
2526
+ margin: 5px 0;
2527
+ }
2528
+ }
2529
+
2530
+ .magicfeedback-rating-star {
2531
+ width: 100%;
2532
+ }
2533
+
2534
+ .magicfeedback-rating-star-container {
2535
+ display: flex !important;
2536
+ flex-direction: row !important;
2537
+ justify-content: center !important;
2538
+ align-items: center !important;
2539
+ flex-wrap: wrap;
2540
+ margin: 15px 5px;
2541
+ padding: 0;
2542
+ list-style: none;
2543
+ font-size: 1.5rem;
2544
+ cursor: pointer;
2545
+ user-select: none;
2546
+ -webkit-user-select: none;
2547
+ -moz-user-select: none;
2548
+ -ms-user-select: none;
2549
+ }
2550
+
2551
+ .magicfeedback-rating-star-option:not(:checked) > .rating__star {
2552
+ float: right;
2553
+ width: 1em;
2554
+ overflow: hidden;
2555
+ white-space: nowrap;
2556
+ cursor: pointer;
2557
+ font-size: 30px;
2558
+ color: #ccc;
2559
+ margin: 0 10px;
2560
+ }
2561
+
2562
+ .magicfeedback-rating-star-option:not(:checked) > .rating__star:hover,
2563
+ .magicfeedback-rating-star-option:not(:checked) > .rating__star:hover ~ span {
2564
+ color: #deb217 !important;
2565
+ }
2566
+
2567
+ .magicfeedback-rating-star-selected {
2568
+ color: #ffc700 !important;
2569
+ }
2570
+
2571
+
2572
+ /* Style for multiple choice image */
2573
+ .magicfeedback-image-option-label-container:hover {
2574
+ cursor: pointer;
2575
+ border: 0 !important;
2576
+ }
2577
+
2578
+ .magicfeedback-image-option-label-container input[type=radio]:checked + img,
2579
+ .magicfeedback-image-option-label-container input[type=checkbox]:checked + img {
2580
+ border: 1px solid #007bff !important;
2581
+ box-shadow: 0 0 3px #007bff !important;
2582
+ }
2583
+
2584
+ .magicfeedback-image-option-label-container input[type=radio] + img,
2585
+ .magicfeedback-image-option-label-container input[type=checkbox] + img {
2586
+ border: 1px solid transparent !important;
2587
+ }
2588
+
2589
+ .magicfeedback-image-option-label-container{
2590
+ margin: 10px !important;
2591
+ height: calc(100% - 20px) !important;
2592
+ width: calc(100% - 20px) !important;
2593
+ }
2594
+
2595
+ .magicfeedback-multiple-choice-image-option {
2596
+ display: flex;
2597
+ height: auto !important;
2598
+ box-shadow: 0 0 3px #ccc;
2599
+ }
2600
+
2601
+ .magicfeedback-multiple-choice-image-label {
2602
+ font-size: 1rem;
2603
+ }
2604
+
2605
+ .magicfeedback-consent-container {
2606
+ display: flex;
2607
+ flex-direction: row;
2608
+ justify-content: flex-start;
2609
+ align-items: center;
2610
+ margin: 10px 0;
2611
+ width: 100%;
2612
+ }
2613
+
2614
+ .magicfeedback-consent-container label {
2615
+ margin-left: 10px;
2616
+ }
2617
+
2618
+ .magicfeedback-start-message-container {
2619
+ /* ... add your start message container styles here ... */
2620
+ }
2621
+
2622
+ .magicfeedback-success-message,
2623
+ .magicfeedback-info-message,
2624
+ .magicfeedback-start-message {
2625
+ margin: 35px 5px;
2626
+ }
2627
+
2628
+ .magicfeedback-success-message p,
2629
+ .magicfeedback-info-message p,
2630
+ .magicfeedback-start-message p {
2631
+ font-style: normal;
2632
+ text-align: start;
2633
+ font-weight: 400;
2634
+ font-size: 16px;
2635
+ color: #475569;
2636
+ line-height: 1.5;
2637
+ }
2638
+
2639
+ .magicfeedback-success-message img,
2640
+ .magicfeedback-info-message img,
2641
+ .magicfeedback-start-message img {
2642
+ width: 400px;
2643
+ max-width: 80%;
2644
+ height: auto;
2645
+ margin: 10px auto;
2646
+ }
2647
+
2648
+ .magicfeedback-counter,
2649
+ .magicfeedback-point-system-total {
2650
+ margin: 10px 0 0 0 !important;
2651
+ display: flex !important;
2652
+ justify-content: right !important;
2653
+ align-items: center !important;
2654
+ width: 100%;
2655
+ }
2656
+
2657
+ .magicfeedback-skip-container {
2658
+ background-color: transparent !important;
2659
+ border: 0 !important;
2660
+ color: #999999FF !important;
2661
+ padding: 0 !important;
2662
+ margin: 0 !important;
2663
+ cursor: pointer !important;
2664
+ font-size: 0.5em !important;
2665
+ font-weight: 400 !important;
2666
+ box-shadow: 0 0 0 !important;
2667
+
2668
+ &:hover {
2669
+ color: #0066ff;
2670
+ }
2671
+ }
2672
+
2673
+ .magicfeedback-skip-container input[type=checkbox] {
2674
+ border-color: #999999FF !important;
2675
+ border: 0 !important;
2676
+ cursor: pointer !important;
2677
+
2678
+ }
2679
+
2680
+ .magicfeedback-multi-question-matrix,
2681
+ .magicfeedback-point-system,
2682
+ .magicfeedback-priority-list {
2683
+ width: 100% !important;
2684
+ }
2685
+
2686
+ .magicfeedback-multi-question-matrix-container,
2687
+ .magicfeedback-point-system-container,
2688
+ .magicfeedback-priority-list-container {
2689
+ width: 100% !important;
2690
+ overflow-x: auto;
2691
+ }
2692
+
2693
+ .magicfeedback-point-system-list,
2694
+ .magicfeedback-priority-list-list,
2695
+ .magicfeedback-multi-question-matrix-table {
2696
+ width: 100% !important;
2697
+ padding: 0 !important;
2698
+ overflow-x: auto;
2699
+ }
2700
+
2701
+ .magicfeedback-multi-question-matrix {
2702
+ position: relative !important;
2703
+ }
2704
+
2705
+ .magicfeedback-multi-question-matrix-container {
2706
+ overflow: auto !important;
2707
+ padding-bottom: 10px;
2708
+ }
2709
+
2710
+ .magicfeedback-multi-question-matrix-label{
2711
+ text-align: left !important;
2712
+ }
2713
+ .magicfeedback-priority-list-item {
2714
+ display: flex;
2715
+ flex-direction: row;
2716
+ justify-content: space-between;
2717
+ align-items: center;
2718
+ padding: 10px 0 10px 10px;
2719
+
2720
+ border: 1px solid #ced4da;
2721
+ border-radius: 5px;
2722
+ margin: 10px 0 !important;
2723
+ }
2724
+
2725
+ .magicfeedback-point-system-item {
2726
+ height: 45px;
2727
+ margin: 5px 0 !important;
2728
+ }
2729
+
2730
+ .magicfeedback-point-system-item label,
2731
+ .magicfeedback-priority-list-item-label {
2732
+ font-family: inherit;
2733
+ font-size: 18px !important;
2734
+ color: #212529;
2735
+ text-align: start;
2736
+ word-wrap: break-word;
2737
+ white-space: normal;
2738
+ padding: 0 10px 0 0;
2739
+ }
2740
+
2741
+ .magicfeedback-point-system-input-container {
2742
+ padding: 0 10px 0 0;
2743
+ border-radius: 5px;
2744
+ font-size: 14px;
2745
+ border: 1px solid #ced4da;
2746
+ height: 42px;
2747
+ margin: auto 0;
2748
+ }
2749
+
2750
+ .magicfeedback-multi-question-matrix-table thead {
2751
+ margin-bottom: 20px;
2752
+ }
2753
+
2754
+ .magicfeedback-multi-question-matrix-table th{
2755
+ text-align: center;
2756
+ font-weight: 400 !important;
2757
+ font-size: 1rem !important;
2758
+ padding: 0 10px !important;
2759
+ }
2760
+
2761
+ .magicfeedback-multi-question-matrix-table th,
2762
+ .magicfeedback-multi-question-matrix-table td label,
2763
+ .magicfeedback-priority-list-arrow-up,
2764
+ .magicfeedback-priority-list-arrow-down {
2765
+ font-style: normal !important;
2766
+ font-weight: 400 !important;
2767
+ font-size: 1rem !important;
2768
+ color: #475569 !important;
2769
+ cursor: pointer !important;
2770
+ margin: 0 !important;
2771
+ line-height: inherit;
2772
+ }
2773
+
2774
+ .magicfeedback-multi-question-matrix-table tr {
2775
+ align-items: center;
2776
+ margin: 5px 0;
2777
+ }
2778
+
2779
+ .magicfeedback-multi-question-matrix-row-tr{
2780
+ border-radius: 5px;
2781
+ margin: 10px 0 !important;
2782
+ }
2783
+
2784
+ .magicfeedback-multi-question-matrix-row-tr:nth-child(odd) {
2785
+ background-color: #f1f6f6; /* Light gray background for odd rows */
2786
+ }
2787
+
2788
+ .magicfeedback-multi-question-matrix-row-tr:nth-child(even) {
2789
+ background-color: #ffffff; /* White background for even rows */
2790
+ }
2791
+
2792
+ .magicfeedback-multi-question-matrix-row-label {
2793
+ text-align: left !important;
2794
+ }
2795
+
2796
+ .magicfeedback-point-system-item span {
2797
+ color: #475569 !important;
2798
+ }
2799
+
2800
+ .magicfeedback-point-system-item input {
2801
+ padding: 0;
2802
+ margin: 0 !important;
2803
+ width: auto !important;
2804
+ min-width: 100px !important;
2805
+ height: auto !important;
2806
+ min-height: 42px;
2807
+ cursor: pointer;
2808
+ font-size: 14px;
2809
+ text-align: center !important;
2810
+ }
2811
+
2812
+ .magicfeedback-multi-question-matrix-table input {
2813
+ margin: auto !important;
2814
+ padding: 20px !important;
2815
+ width: 100% !important;
2816
+ height: 15px;
2817
+ border: 1px solid #ced4da;
2818
+ cursor: pointer;
2819
+ }
2820
+
2821
+ .magicfeedback-image{
2822
+ max-height: 400px !important;
2823
+ height: auto !important;
2824
+ max-width: 100% !important;
2825
+ margin: 10px auto !important;
2826
+ }
2827
+
2828
+ .magicfeedback-error{
2829
+ margin-top: 5px;
2830
+ }`;
1727
2831
 
1728
2832
  // src/ui/renderPopup.ts
1729
- var import_native = __toESM(require_magicfeedback_sdk_browser());
1730
- function ensureMagicFeedbackStyles(popup) {
1731
- const DATA_ATTR = "data-magicfeedback-css";
1732
- if (document.querySelector(`link[${DATA_ATTR}]`) || popup.querySelector(`link[${DATA_ATTR}]`)) {
1733
- return;
1734
- }
1735
- const link = document.createElement("link");
1736
- link.rel = "stylesheet";
1737
- link.href = "https://cdn.jsdelivr.net/npm/@magicfeedback/popup-sdk/dist/assets/assets/style.css";
1738
- link.setAttribute(DATA_ATTR, "true");
1739
- popup.appendChild(link);
2833
+ function ensureMagicFeedbackStyles(_popup) {
2834
+ const STYLE_ID = "magicfeedback-sdk-styles";
2835
+ if (document.getElementById(STYLE_ID)) return;
2836
+ const style = document.createElement("style");
2837
+ style.id = STYLE_ID;
2838
+ style.textContent = style_default;
2839
+ document.head.appendChild(style);
1740
2840
  }
1741
- function ensureSpinnerStyles(popup) {
2841
+ function ensureSpinnerStyles(_popup) {
1742
2842
  if (document.getElementById("deepdots-spinner-styles")) return;
1743
2843
  const style = document.createElement("style");
1744
2844
  style.id = "deepdots-spinner-styles";
@@ -1747,9 +2847,9 @@ function ensureSpinnerStyles(popup) {
1747
2847
  .mf-spinner { display:flex; justify-content:center; align-items:center; padding:8px 0; }
1748
2848
  .mf-spinner-circle { width:28px; height:28px; border:3px solid #e0e6ed; border-top-color:#1E293B; border-radius:50%; animation: ddspin 0.9s linear infinite; }
1749
2849
  `;
1750
- popup.appendChild(style);
2850
+ document.head.appendChild(style);
1751
2851
  }
1752
- function ensureResponsiveStyles(popup) {
2852
+ function ensureResponsiveStyles(_popup) {
1753
2853
  if (document.getElementById("deepdots-responsive-styles")) return;
1754
2854
  const style = document.createElement("style");
1755
2855
  style.id = "deepdots-responsive-styles";
@@ -1757,11 +2857,11 @@ function ensureResponsiveStyles(popup) {
1757
2857
  /* Responsive adjustments */
1758
2858
  @media (max-width: 640px) {
1759
2859
  .deepdots-popup {
1760
- width: 100% !important;
1761
- max-width: 100% !important;
1762
- height: 90vh !important;
1763
- max-height: 100vh !important;
1764
- border-radius: 0 !important;
2860
+ width: calc(100% - 24px) !important;
2861
+ max-width: calc(100% - 24px) !important;
2862
+ height: auto !important;
2863
+ max-height: 90vh !important;
2864
+ border-radius: 12px !important;
1765
2865
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)) 16px !important;
1766
2866
  box-sizing: border-box;
1767
2867
  }
@@ -1785,9 +2885,9 @@ function ensureResponsiveStyles(popup) {
1785
2885
  }
1786
2886
  }
1787
2887
  `;
1788
- popup.appendChild(style);
2888
+ document.head.appendChild(style);
1789
2889
  }
1790
- async function renderPopup(container, surveyId, productId, actions, emit, onClose, env = "production") {
2890
+ async function renderPopup(container, surveyId, productId, actions, emit, onClose, env = "production", userId) {
1791
2891
  let surveyCompletedEmitted = false;
1792
2892
  let stylesInjected = false;
1793
2893
  const popup = document.createElement("div");
@@ -2071,8 +3171,14 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2071
3171
  setLoading(false);
2072
3172
  return;
2073
3173
  }
2074
- import_native.default.init({ debug: true, env: env === "production" ? "prod" : "dev" });
2075
- formInstance = import_native.default.form(surveyId, productId);
3174
+ import_native.default.init(
3175
+ {
3176
+ debug: true,
3177
+ env: env === "production" ? "prod" : "dev"
3178
+ }
3179
+ );
3180
+ const profile = userId ? [{ key: "external-user-id", value: [userId] }] : [];
3181
+ formInstance = import_native.default.form(surveyId, productId, profile, profile);
2076
3182
  const generateOptions = {
2077
3183
  addButton: false,
2078
3184
  getMetaData: true
@@ -2102,7 +3208,8 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2102
3208
  closeButton.style.color = "#fff";
2103
3209
  }
2104
3210
  if (s.buttonSecondaryColor) {
2105
- backButton.style.color = "#fff";
3211
+ backButton.style.background = "#fff";
3212
+ backButton.style.color = s.buttonSecondaryColor;
2106
3213
  backButton.style.border = `1px solid ${s.buttonSecondaryColor}`;
2107
3214
  }
2108
3215
  if (s.logo) {
@@ -2186,6 +3293,7 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
2186
3293
  updateButtons("completed");
2187
3294
  return;
2188
3295
  }
3296
+ emit("popup_clicked", surveyId, { action: "partial" });
2189
3297
  if (total > 1 && progress > 0 && progress < total) {
2190
3298
  updateButtons("in_progress_next");
2191
3299
  } else {
@@ -2222,6 +3330,9 @@ function setupTrigger(popups, trigger) {
2222
3330
  case "exit":
2223
3331
  setupExitTrigger(popups, trigger);
2224
3332
  break;
3333
+ case "event":
3334
+ setupEventTrigger(popups, trigger);
3335
+ break;
2225
3336
  case "click":
2226
3337
  setupClickTrigger(popups, trigger);
2227
3338
  break;
@@ -2230,7 +3341,7 @@ function setupTrigger(popups, trigger) {
2230
3341
  function setupTimeTrigger(popups, trigger) {
2231
3342
  const delay = trigger.value || 5e3;
2232
3343
  setTimeout(() => {
2233
- popups.triggerSurvey(trigger.surveyId);
3344
+ popups.triggerSurvey(trigger.surveyId, trigger.popupId);
2234
3345
  }, delay);
2235
3346
  popups.debug(`Time trigger set for ${delay}ms`);
2236
3347
  }
@@ -2239,7 +3350,7 @@ function setupScrollTrigger(popups, trigger) {
2239
3350
  const handler = () => {
2240
3351
  const scrollPercentage = window.scrollY / (document.documentElement.scrollHeight - window.innerHeight) * 100;
2241
3352
  if (scrollPercentage >= threshold) {
2242
- popups.triggerSurvey(trigger.surveyId);
3353
+ popups.triggerSurvey(trigger.surveyId, trigger.popupId);
2243
3354
  window.removeEventListener("scroll", handler);
2244
3355
  }
2245
3356
  };
@@ -2247,86 +3358,103 @@ function setupScrollTrigger(popups, trigger) {
2247
3358
  popups.debug(`Scroll trigger set for ${threshold}%`);
2248
3359
  }
2249
3360
  function setupExitTrigger(popups, trigger) {
2250
- let fired = false;
2251
- let lastUrl = typeof window !== "undefined" ? window.location.href : "";
2252
- const historyRef = typeof window !== "undefined" ? window.history : null;
2253
- const originalPushState = historyRef ? historyRef.pushState.bind(historyRef) : null;
2254
- const originalReplaceState = historyRef ? historyRef.replaceState.bind(historyRef) : null;
2255
- const cleanup = () => {
2256
- document.removeEventListener("click", handleNavClick, true);
2257
- window.removeEventListener("popstate", handlePopState);
2258
- if (historyRef && originalPushState) historyRef.pushState = originalPushState;
2259
- if (historyRef && originalReplaceState) historyRef.replaceState = originalReplaceState;
3361
+ if (typeof window === "undefined") return;
3362
+ const delaySeconds = parseExitDelaySeconds(trigger.value);
3363
+ const historyRef = window.history;
3364
+ const originalPushState = historyRef.pushState.bind(historyRef);
3365
+ const originalReplaceState = historyRef.replaceState.bind(historyRef);
3366
+ let lastUrl = normalizeUrl(window.location.href);
3367
+ let lastQueuedKey = "";
3368
+ let lastQueuedAt = 0;
3369
+ const queueLeave = (fromRaw, toRaw) => {
3370
+ const from = normalizeUrl(fromRaw);
3371
+ const to = normalizeUrl(toRaw);
3372
+ if (!from || !to || from === to) return;
3373
+ const key = `${from}=>${to}`;
3374
+ const now = Date.now();
3375
+ if (key === lastQueuedKey && now - lastQueuedAt < 150) return;
3376
+ lastQueuedKey = key;
3377
+ lastQueuedAt = now;
3378
+ popups.queueExitPopup(trigger.surveyId, delaySeconds, from, trigger.popupId);
2260
3379
  };
2261
- const fireOnce = () => {
2262
- if (fired) return;
2263
- fired = true;
2264
- popups.triggerSurvey(trigger.surveyId);
2265
- cleanup();
3380
+ const handleNavigation = (to) => {
3381
+ const from = lastUrl;
3382
+ queueLeave(from, to);
3383
+ lastUrl = normalizeUrl(to);
2266
3384
  };
2267
- const handleNavClick = (e) => {
2268
- if (fired) return;
2269
- if (e.defaultPrevented) return;
2270
- if (e.button !== 0) return;
2271
- if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
2272
- const target = e.target?.closest?.("a");
2273
- if (!target) return;
2274
- const href = target.getAttribute("href");
2275
- if (!href || href.startsWith("#")) return;
2276
- const targetAttr = target.getAttribute("target");
2277
- if (targetAttr && targetAttr !== "_self") return;
2278
- let url;
2279
- try {
2280
- url = new URL(href, window.location.href);
2281
- } catch {
3385
+ const handleDocumentClick = (event) => {
3386
+ if (event.defaultPrevented) return;
3387
+ if (event.button !== 0) return;
3388
+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
3389
+ const anchor = event.target?.closest?.("a");
3390
+ if (!(anchor instanceof HTMLAnchorElement)) return;
3391
+ const href = anchor.getAttribute("href");
3392
+ if (!href || href.startsWith("javascript:") || href.startsWith("mailto:") || href.startsWith("tel:")) {
2282
3393
  return;
2283
3394
  }
2284
- if (url.origin !== window.location.origin) return;
2285
- e.preventDefault();
2286
- fireOnce();
2287
- };
2288
- const shouldBlockUrl = (rawUrl) => {
2289
- if (!rawUrl) return false;
2290
- let url;
3395
+ const target = anchor.getAttribute("target");
3396
+ if (target && target !== "_self") return;
3397
+ let destination;
2291
3398
  try {
2292
- url = rawUrl instanceof URL ? rawUrl : new URL(rawUrl, window.location.href);
3399
+ destination = new URL(href, window.location.href);
2293
3400
  } catch {
2294
- return false;
3401
+ return;
2295
3402
  }
2296
- if (url.origin !== window.location.origin) return false;
2297
- if (url.href === window.location.href) return false;
2298
- return true;
3403
+ if (destination.origin !== window.location.origin) return;
3404
+ queueLeave(window.location.href, destination.href);
3405
+ };
3406
+ const handleHashChange = (event) => {
3407
+ const to = event.newURL || window.location.href;
3408
+ const from = event.oldURL || lastUrl;
3409
+ queueLeave(from, to);
3410
+ lastUrl = normalizeUrl(to);
2299
3411
  };
2300
3412
  const handlePopState = () => {
2301
- if (fired) return;
2302
- fireOnce();
2303
- if (historyRef && originalPushState && lastUrl) {
2304
- originalPushState(null, document.title, lastUrl);
2305
- }
3413
+ handleNavigation(window.location.href);
2306
3414
  };
2307
- if (historyRef && originalPushState && originalReplaceState) {
2308
- historyRef.pushState = function(data, unused, url) {
2309
- if (!fired && shouldBlockUrl(url)) {
2310
- fireOnce();
2311
- return;
2312
- }
2313
- const result = originalPushState(data, unused, url);
2314
- lastUrl = window.location.href;
2315
- return result;
2316
- };
2317
- historyRef.replaceState = function(data, unused, url) {
2318
- if (!fired && shouldBlockUrl(url)) {
2319
- fireOnce();
2320
- return;
2321
- }
2322
- const result = originalReplaceState(data, unused, url);
2323
- lastUrl = window.location.href;
2324
- return result;
2325
- };
2326
- }
2327
- document.addEventListener("click", handleNavClick, true);
3415
+ historyRef.pushState = function(data, unused, url) {
3416
+ const from = window.location.href;
3417
+ const result = originalPushState(data, unused, url);
3418
+ queueLeave(from, window.location.href);
3419
+ lastUrl = normalizeUrl(window.location.href);
3420
+ return result;
3421
+ };
3422
+ historyRef.replaceState = function(data, unused, url) {
3423
+ const from = window.location.href;
3424
+ const result = originalReplaceState(data, unused, url);
3425
+ queueLeave(from, window.location.href);
3426
+ lastUrl = normalizeUrl(window.location.href);
3427
+ return result;
3428
+ };
3429
+ document.addEventListener("click", handleDocumentClick, true);
3430
+ window.addEventListener("hashchange", handleHashChange);
2328
3431
  window.addEventListener("popstate", handlePopState);
2329
- popups.debug("Exit intent trigger set (navigation/spa)");
3432
+ popups.debug("Exit trigger set (deferred to next route)", {
3433
+ surveyId: trigger.surveyId,
3434
+ delaySeconds
3435
+ });
3436
+ }
3437
+ function setupEventTrigger(popups, trigger) {
3438
+ popups.debug("Event trigger registered", {
3439
+ popupId: trigger.popupId,
3440
+ surveyId: trigger.surveyId,
3441
+ eventName: String(trigger.value || "")
3442
+ });
3443
+ }
3444
+ function parseExitDelaySeconds(value) {
3445
+ if (typeof value === "number" && Number.isFinite(value)) {
3446
+ return Math.max(0, value);
3447
+ }
3448
+ if (typeof value === "string" && value.trim()) {
3449
+ const parsed = Number(value);
3450
+ if (Number.isFinite(parsed)) return Math.max(0, parsed);
3451
+ }
3452
+ return 0;
3453
+ }
3454
+ function normalizeUrl(value) {
3455
+ if (!value) return "";
3456
+ const withoutIndex = value.replace(/\/index\.html(?=($|[?#]))/i, "");
3457
+ return withoutIndex.length > 1 && withoutIndex.endsWith("/") ? withoutIndex.slice(0, -1) : withoutIndex;
2330
3458
  }
2331
3459
  function setupClickTrigger(popups, trigger) {
2332
3460
  const targetId = typeof trigger.value === "string" ? trigger.value : "";
@@ -2342,7 +3470,7 @@ function setupClickTrigger(popups, trigger) {
2342
3470
  }
2343
3471
  const handler = (e) => {
2344
3472
  if (e.defaultPrevented) return;
2345
- popups.triggerSurvey(trigger.surveyId);
3473
+ popups.triggerSurvey(trigger.surveyId, trigger.popupId);
2346
3474
  el.removeEventListener("click", handler);
2347
3475
  };
2348
3476
  el.addEventListener("click", handler);
@@ -2421,6 +3549,7 @@ var NoopPopupRenderer = class {
2421
3549
  var BrowserPopupRenderer = class {
2422
3550
  constructor() {
2423
3551
  this.container = null;
3552
+ this.visible = false;
2424
3553
  }
2425
3554
  init() {
2426
3555
  if (typeof document === "undefined") return;
@@ -2439,15 +3568,20 @@ var BrowserPopupRenderer = class {
2439
3568
  justify-content: center;
2440
3569
  align-items: center;
2441
3570
  `;
3571
+ }
3572
+ if (!document.body.contains(this.container)) {
2442
3573
  document.body.appendChild(this.container);
2443
3574
  }
2444
3575
  }
2445
- show(surveyId, productId, actions, emit, onClose, env = "production") {
2446
- if (!this.container) this.init();
3576
+ show(surveyId, productId, actions, emit, onClose, env = "production", userId) {
3577
+ if (this.visible) return;
3578
+ if (!this.container || !document.body.contains(this.container)) this.init();
2447
3579
  if (!this.container) return;
2448
- renderPopup(this.container, surveyId, productId, actions, emit, onClose, env);
3580
+ this.visible = true;
3581
+ renderPopup(this.container, surveyId, productId, actions, emit, onClose, env, userId);
2449
3582
  }
2450
3583
  hide() {
3584
+ this.visible = false;
2451
3585
  if (this.container) {
2452
3586
  this.container.style.display = "none";
2453
3587
  this.container.innerHTML = "";
@@ -2464,6 +3598,8 @@ function createDefaultRenderer() {
2464
3598
  }
2465
3599
 
2466
3600
  // src/core/deepdots-popups.ts
3601
+ var EXIT_QUEUE_STORAGE_KEY = "__deepdots_exit_popup_queue__";
3602
+ var DAY_IN_MS = 24 * 60 * 60 * 1e3;
2467
3603
  var DeepdotsPopups = class {
2468
3604
  constructor() {
2469
3605
  this.config = null;
@@ -2477,10 +3613,12 @@ var DeepdotsPopups = class {
2477
3613
  this.popupsLoaded = false;
2478
3614
  this.pendingAutoLaunch = false;
2479
3615
  this.answeredSurveys = /* @__PURE__ */ new Set();
3616
+ this.surveyProgress = /* @__PURE__ */ new Map();
2480
3617
  this.lastShown = /* @__PURE__ */ new Map();
2481
3618
  // popupId -> timestamp mostrado
2482
3619
  this.surveyToPopupId = /* @__PURE__ */ new Map();
2483
3620
  // surveyId -> popupId
3621
+ this.deferredExitTimers = [];
2484
3622
  this.baseUrl = "";
2485
3623
  this.env = "production";
2486
3624
  }
@@ -2505,15 +3643,17 @@ var DeepdotsPopups = class {
2505
3643
  if (this.renderer.init) this.renderer.init();
2506
3644
  this.setupPopupContainer();
2507
3645
  if (this.config.mode === "client") {
2508
- this.popupDefinitions = this.config.popups || [];
3646
+ this.popupDefinitions = this.validatePopupDefinitions(this.config.popups || []);
2509
3647
  this.popupsLoaded = true;
2510
3648
  this.configureTriggersFromDefinitions();
3649
+ this.processDeferredExitQueue();
2511
3650
  } else {
2512
3651
  this.fetchPopupsFromServer().then((defs) => {
2513
- this.popupDefinitions = defs;
3652
+ this.popupDefinitions = this.validatePopupDefinitions(defs);
2514
3653
  this.popupsLoaded = true;
2515
- this.log("Popups loaded from server (fake)", defs);
3654
+ this.log("Popups loaded from server (fake)", this.popupDefinitions);
2516
3655
  this.configureTriggersFromDefinitions();
3656
+ this.processDeferredExitQueue();
2517
3657
  if (this.pendingAutoLaunch) {
2518
3658
  this.startTriggers();
2519
3659
  }
@@ -2539,7 +3679,6 @@ var DeepdotsPopups = class {
2539
3679
  }
2540
3680
  /** Show a popup immediately (supports legacy ShowOptions and new PopupDefinition) */
2541
3681
  show(options) {
2542
- console.log("Show popup called with options:", options);
2543
3682
  if (!this.initialized) {
2544
3683
  throw new Error("SDK not initialized. Call init() first.");
2545
3684
  }
@@ -2548,6 +3687,7 @@ var DeepdotsPopups = class {
2548
3687
  const def = options;
2549
3688
  this.log("Showing popup (definition)", def);
2550
3689
  this.surveyToPopupId.set(def.surveyId, def.id);
3690
+ this.lastShown.set(def.id, Date.now());
2551
3691
  this.renderPopup(def.surveyId, def.productId, def.actions);
2552
3692
  this.emitEvent("popup_shown", def.surveyId, { popupId: def.id });
2553
3693
  } else {
@@ -2559,7 +3699,7 @@ var DeepdotsPopups = class {
2559
3699
  }
2560
3700
  /** Mostrar popup por id de definición (usa surveyId interno) */
2561
3701
  showByPopupId(popupId) {
2562
- const def = this.popupDefinitions.find((p) => p.id === popupId);
3702
+ const def = this.popupDefinitions.find((popup) => popup.id === popupId);
2563
3703
  if (!def) {
2564
3704
  this.log("Popup definition not found", popupId);
2565
3705
  return;
@@ -2577,75 +3717,106 @@ var DeepdotsPopups = class {
2577
3717
  /** Deriva triggers desde las definiciones de popup */
2578
3718
  configureTriggersFromDefinitions() {
2579
3719
  const derived = [];
2580
- const validDefs = this.validatePopupDefinitions(this.popupDefinitions);
2581
- console.log("validDefs", validDefs);
2582
- validDefs.forEach((def) => {
2583
- if (!def.triggers) return;
2584
- const t = def.triggers;
2585
- let type;
2586
- switch (t.type) {
2587
- case "time_on_page":
2588
- type = "time";
2589
- break;
2590
- case "scroll":
2591
- type = "scroll";
2592
- break;
2593
- case "exit":
2594
- type = "exit";
2595
- break;
2596
- case "click":
2597
- type = "click";
2598
- break;
2599
- default:
2600
- this.debug("Unsupported trigger type", t.type);
3720
+ this.debug("Validated popup definitions", this.popupDefinitions);
3721
+ this.popupDefinitions.forEach((def) => {
3722
+ def.triggers.forEach((trigger) => {
3723
+ const type = this.mapPopupTriggerType(trigger.type);
3724
+ if (!type) {
3725
+ this.debug("Unsupported trigger type", trigger.type);
2601
3726
  return;
2602
- }
2603
- const value = type === "time" && typeof t.value === "number" ? t.value * 1e3 : t.value;
2604
- derived.push({ type, value, surveyId: def.surveyId });
3727
+ }
3728
+ const value = type === "time" && typeof trigger.value === "number" ? trigger.value * 1e3 : trigger.value;
3729
+ derived.push({ type, value, surveyId: def.surveyId, popupId: def.id });
3730
+ });
2605
3731
  });
2606
3732
  if (derived.length) {
2607
3733
  this.configureTriggers(derived);
2608
3734
  }
2609
3735
  }
2610
3736
  /** Lógica para evaluar condiciones antes de mostrar una encuesta */
2611
- triggerSurvey(surveyId) {
2612
- const def = this.popupDefinitions.find((p) => p.surveyId === surveyId);
3737
+ triggerSurvey(surveyId, popupId) {
3738
+ const def = this.findPopupDefinition(surveyId, popupId);
2613
3739
  if (!def) {
2614
- this.debug("No popup definition for surveyId", surveyId);
3740
+ this.debug("No popup definition for trigger", { surveyId, popupId });
2615
3741
  return;
2616
3742
  }
2617
3743
  if (!this.shouldShow(def)) {
2618
3744
  this.debug("Conditions prevented showing popup", def.id);
2619
3745
  return;
2620
3746
  }
3747
+ this.showDefinition(def);
3748
+ }
3749
+ /** Trigger popups configured with trigger.type = 'event' and matching trigger.value */
3750
+ triggerEvent(eventName) {
3751
+ if (!this.initialized) {
3752
+ throw new Error("SDK not initialized. Call init() first.");
3753
+ }
3754
+ const normalized = String(eventName || "").trim();
3755
+ if (!normalized) {
3756
+ this.debug("Ignoring empty event trigger name");
3757
+ return;
3758
+ }
3759
+ const candidates = this.popupDefinitions.filter((def) => {
3760
+ return def.triggers.some((trigger) => {
3761
+ const triggerValue = String(trigger.value ?? "").trim();
3762
+ return trigger.type === "event" && triggerValue === normalized;
3763
+ });
3764
+ });
3765
+ if (!candidates.length) {
3766
+ this.debug("No event popup definitions found", { eventName: normalized });
3767
+ return;
3768
+ }
3769
+ const matched = candidates.find((def) => this.shouldShow(def));
3770
+ if (!matched) {
3771
+ this.debug("Event popup blocked by conditions/segments", { eventName: normalized });
3772
+ return;
3773
+ }
3774
+ this.showDefinition(matched);
3775
+ }
3776
+ showDefinition(def) {
2621
3777
  this.show(def);
2622
- this.lastShown.set(def.id, Date.now());
2623
3778
  }
2624
- shouldShow(def) {
2625
- if (!this.matchesSegmentsPath(def)) {
3779
+ shouldShow(def, pathUrl, skipPathCheck = false) {
3780
+ if (!skipPathCheck && !this.matchesSegmentsPath(def, pathUrl)) {
3781
+ return false;
3782
+ }
3783
+ if (!this.matchesSegmentsLang(def)) {
3784
+ return false;
3785
+ }
3786
+ const cooldowns = def.cooldown || [];
3787
+ if (cooldowns.length && !cooldowns.every((cooldown) => this.evaluateCooldown(def, cooldown))) {
2626
3788
  return false;
2627
3789
  }
2628
- const conditions = def.triggers.condition || [];
2629
- if (!conditions.length) return true;
2630
- return conditions.every((c) => this.evaluateCondition(def, c));
3790
+ const legacyConditions = def.legacyConditions || [];
3791
+ if (!legacyConditions.length) return true;
3792
+ return legacyConditions.every((condition) => this.evaluateLegacyCondition(def, condition));
3793
+ }
3794
+ matchesSegmentsLang(def) {
3795
+ const langs = def.segments?.lang;
3796
+ if (!langs || langs.length === 0) return true;
3797
+ const browserLang = (typeof navigator !== "undefined" ? navigator.language : "").toLowerCase();
3798
+ if (!browserLang) {
3799
+ this.debug("No navigator.language available for lang comparison", { popupId: def.id, langs });
3800
+ return true;
3801
+ }
3802
+ const matches = langs.some((lang) => browserLang.startsWith(lang.toLowerCase()));
3803
+ if (!matches) {
3804
+ this.debug("Lang mismatch for popup", { popupId: def.id, langs, browserLang });
3805
+ }
3806
+ return matches;
2631
3807
  }
2632
- matchesSegmentsPath(def) {
3808
+ matchesSegmentsPath(def, pathUrl) {
2633
3809
  const paths = def.segments?.path;
2634
3810
  if (!paths || paths.length === 0) return true;
2635
3811
  if (typeof window === "undefined" || !window.location) {
2636
3812
  this.debug("No window.location available for path comparison", { popupId: def.id, paths });
2637
3813
  return true;
2638
3814
  }
2639
- const currentPath = window.location.pathname || "";
2640
- const currentHref = window.location.href || "";
2641
- const normalize = (value) => {
2642
- if (value.length > 1 && value.endsWith("/")) return value.slice(0, -1);
2643
- return value;
2644
- };
2645
- const normalizedPath = normalize(currentPath);
2646
- const normalizedHref = normalize(currentHref);
3815
+ const normalizedHref = this.normalizeUrl(pathUrl || window.location.href || "");
3816
+ const currentUrl = this.safeParseUrl(normalizedHref);
3817
+ const normalizedPath = this.normalizeUrl(currentUrl?.pathname || window.location.pathname || "");
2647
3818
  const matches = paths.some((rawCandidate) => {
2648
- const candidate = normalize(rawCandidate);
3819
+ const candidate = this.normalizeUrl(rawCandidate);
2649
3820
  let match = false;
2650
3821
  if (candidate.startsWith("http://") || candidate.startsWith("https://")) {
2651
3822
  match = normalizedHref === candidate;
@@ -2668,33 +3839,166 @@ var DeepdotsPopups = class {
2668
3839
  }
2669
3840
  return matches;
2670
3841
  }
2671
- evaluateCondition(def, condition) {
3842
+ evaluateCooldown(def, condition) {
3843
+ switch (condition.answered) {
3844
+ case "SHOWED":
3845
+ return this.hasCooldownElapsed(this.lastShown.get(def.id), condition.cooldownDays);
3846
+ case "PARTIAL":
3847
+ case "COMPLETED": {
3848
+ const progress = this.surveyProgress.get(def.surveyId);
3849
+ if (!progress || progress.status !== condition.answered) {
3850
+ return true;
3851
+ }
3852
+ return this.hasCooldownElapsed(progress.timestamp, condition.cooldownDays);
3853
+ }
3854
+ default:
3855
+ return true;
3856
+ }
3857
+ }
3858
+ evaluateLegacyCondition(def, condition) {
2672
3859
  if (!condition.answered && this.answeredSurveys.has(def.surveyId)) {
2673
3860
  return false;
2674
3861
  }
2675
- if (condition.cooldownDays) {
2676
- const last = this.lastShown.get(def.id);
2677
- if (last) {
2678
- const msSince = Date.now() - last;
2679
- const required = condition.cooldownDays * 24 * 60 * 60 * 1e3;
2680
- if (msSince < required) return false;
2681
- }
3862
+ return this.hasCooldownElapsed(this.lastShown.get(def.id), condition.cooldownDays);
3863
+ }
3864
+ hasCooldownElapsed(timestamp, cooldownDays) {
3865
+ if (!timestamp || !cooldownDays) {
3866
+ return true;
2682
3867
  }
2683
- return true;
3868
+ return Date.now() - timestamp >= cooldownDays * DAY_IN_MS;
2684
3869
  }
2685
3870
  /** Marcar encuesta como contestada externamente */
2686
3871
  markSurveyAnswered(surveyId) {
2687
3872
  this.answeredSurveys.add(surveyId);
3873
+ this.markSurveyProgress(surveyId, "COMPLETED");
3874
+ }
3875
+ /** Queue an exit popup so it can render after navigation */
3876
+ queueExitPopup(surveyId, delaySeconds, sourceUrl, popupId) {
3877
+ const def = this.findPopupDefinition(surveyId, popupId);
3878
+ if (!def) {
3879
+ this.debug("No popup definition for exit trigger", { surveyId, popupId });
3880
+ return;
3881
+ }
3882
+ const originUrl = sourceUrl || (typeof window !== "undefined" ? window.location.href : "");
3883
+ if (!originUrl) {
3884
+ this.debug("Exit popup skipped: missing source URL", { surveyId });
3885
+ return;
3886
+ }
3887
+ if (!this.shouldShow(def, originUrl)) {
3888
+ this.debug("Exit popup skipped by conditions/path", { popupId: def.id, sourceUrl: originUrl });
3889
+ return;
3890
+ }
3891
+ const safeDelayMs = Number.isFinite(delaySeconds) ? Math.max(0, delaySeconds * 1e3) : 0;
3892
+ const deferred = {
3893
+ id: def.id,
3894
+ surveyId: def.surveyId,
3895
+ sourceUrl: this.normalizeUrl(originUrl),
3896
+ dueAt: Date.now() + safeDelayMs
3897
+ };
3898
+ const queue = this.getDeferredExitQueue().filter((item) => !(item.id === deferred.id && item.sourceUrl === deferred.sourceUrl));
3899
+ queue.push(deferred);
3900
+ this.setDeferredExitQueue(queue);
3901
+ this.scheduleDeferredExitPopup(deferred);
3902
+ this.debug("Exit popup queued", deferred);
3903
+ }
3904
+ processDeferredExitQueue() {
3905
+ const queue = this.getDeferredExitQueue();
3906
+ if (!queue.length) return;
3907
+ const pending = [];
3908
+ const now = Date.now();
3909
+ queue.forEach((item) => {
3910
+ const def = this.popupDefinitions.find((popup) => popup.id === item.id && popup.surveyId === item.surveyId);
3911
+ if (!def) {
3912
+ return;
3913
+ }
3914
+ if (item.dueAt <= now) {
3915
+ this.tryShowDeferredExitPopup(item);
3916
+ return;
3917
+ }
3918
+ pending.push(item);
3919
+ this.scheduleDeferredExitPopup(item);
3920
+ });
3921
+ this.setDeferredExitQueue(pending);
3922
+ }
3923
+ scheduleDeferredExitPopup(item) {
3924
+ if (typeof window === "undefined") return;
3925
+ const delay = Math.max(0, item.dueAt - Date.now());
3926
+ const timer = window.setTimeout(() => this.tryShowDeferredExitPopup(item), delay);
3927
+ this.deferredExitTimers.push(timer);
3928
+ }
3929
+ tryShowDeferredExitPopup(item) {
3930
+ const def = this.popupDefinitions.find((popup) => popup.id === item.id && popup.surveyId === item.surveyId);
3931
+ if (!def) {
3932
+ this.removeDeferredExitPopup(item);
3933
+ return;
3934
+ }
3935
+ const currentUrl = typeof window !== "undefined" ? this.normalizeUrl(window.location.href || "") : "";
3936
+ if (!currentUrl || currentUrl === this.normalizeUrl(item.sourceUrl)) {
3937
+ this.removeDeferredExitPopup(item);
3938
+ this.debug("Exit popup dropped because route did not change", item);
3939
+ return;
3940
+ }
3941
+ if (!this.shouldShow(def, void 0, true)) {
3942
+ this.removeDeferredExitPopup(item);
3943
+ this.debug("Exit popup skipped at render-time conditions", item);
3944
+ return;
3945
+ }
3946
+ this.showDefinition(def);
3947
+ this.removeDeferredExitPopup(item);
3948
+ }
3949
+ findPopupDefinition(surveyId, popupId) {
3950
+ if (popupId) {
3951
+ const byId = this.popupDefinitions.find((popup) => popup.id === popupId);
3952
+ if (byId) return byId;
3953
+ }
3954
+ return this.popupDefinitions.find((popup) => popup.surveyId === surveyId);
3955
+ }
3956
+ removeDeferredExitPopup(item) {
3957
+ const queue = this.getDeferredExitQueue().filter((entry) => !(entry.id === item.id && entry.sourceUrl === item.sourceUrl));
3958
+ this.setDeferredExitQueue(queue);
3959
+ }
3960
+ getDeferredExitQueue() {
3961
+ if (typeof window === "undefined") return [];
3962
+ try {
3963
+ const raw = window.sessionStorage.getItem(EXIT_QUEUE_STORAGE_KEY);
3964
+ if (!raw) return [];
3965
+ const parsed = JSON.parse(raw);
3966
+ if (!Array.isArray(parsed)) return [];
3967
+ return parsed.filter((entry) => {
3968
+ if (typeof entry !== "object" || entry === null) return false;
3969
+ const item = entry;
3970
+ return typeof item.id === "string" && typeof item.surveyId === "string" && typeof item.sourceUrl === "string" && typeof item.dueAt === "number" && Number.isFinite(item.dueAt);
3971
+ }).map((item) => ({
3972
+ ...item,
3973
+ sourceUrl: this.normalizeUrl(item.sourceUrl)
3974
+ }));
3975
+ } catch {
3976
+ return [];
3977
+ }
3978
+ }
3979
+ setDeferredExitQueue(queue) {
3980
+ if (typeof window === "undefined") return;
3981
+ try {
3982
+ if (!queue.length) {
3983
+ window.sessionStorage.removeItem(EXIT_QUEUE_STORAGE_KEY);
3984
+ return;
3985
+ }
3986
+ window.sessionStorage.setItem(EXIT_QUEUE_STORAGE_KEY, JSON.stringify(queue));
3987
+ } catch {
3988
+ }
2688
3989
  }
2689
3990
  /** Fetch al servidor para obtener popups */
2690
3991
  async fetchPopupsFromServer() {
2691
3992
  const apiKey = this.config?.apiKey;
2692
3993
  const baseUrl = this.baseUrl;
3994
+ const userId = this.config?.userId;
2693
3995
  if (!apiKey || !baseUrl) {
2694
3996
  this.log("Missing apiKey or baseUrl. Skipping popups fetch.");
2695
3997
  return [];
2696
3998
  }
2697
- const endpoint = `${baseUrl}/sdk/${encodeURIComponent(apiKey)}/popups`;
3999
+ const filter = userId ? { where: { userId } } : null;
4000
+ const query = filter ? `?filter=${encodeURIComponent(JSON.stringify(filter))}` : "";
4001
+ const endpoint = `${baseUrl}/sdk/${encodeURIComponent(apiKey)}/popups${query}`;
2698
4002
  try {
2699
4003
  const response = await fetch(endpoint);
2700
4004
  if (!response.ok) {
@@ -2707,7 +4011,7 @@ var DeepdotsPopups = class {
2707
4011
  this.log("Unexpected popups payload", parsed);
2708
4012
  return [];
2709
4013
  }
2710
- console.log("res: ", parsed, this.validatePopupDefinitions(parsed));
4014
+ this.debug("Fetched popups payload", parsed);
2711
4015
  return parsed;
2712
4016
  } catch (error) {
2713
4017
  this.log("Error fetching popups", error);
@@ -2777,6 +4081,7 @@ var DeepdotsPopups = class {
2777
4081
  }
2778
4082
  /** Render the popup UI */
2779
4083
  renderPopup(surveyId, productId, actions) {
4084
+ const userId = this.config?.userId;
2780
4085
  if (this.renderer) {
2781
4086
  this.renderer.show(
2782
4087
  surveyId,
@@ -2784,7 +4089,8 @@ var DeepdotsPopups = class {
2784
4089
  actions,
2785
4090
  (type, id, payload) => this.emitEvent(type, id, payload),
2786
4091
  () => this.hidePopup(),
2787
- this.env
4092
+ this.env,
4093
+ userId
2788
4094
  );
2789
4095
  return;
2790
4096
  }
@@ -2796,7 +4102,8 @@ var DeepdotsPopups = class {
2796
4102
  actions,
2797
4103
  (type, id, payload) => this.emitEvent(type, id, payload),
2798
4104
  () => this.hidePopup(),
2799
- this.env
4105
+ this.env,
4106
+ userId
2800
4107
  );
2801
4108
  }
2802
4109
  /** Hide the popup */
@@ -2814,6 +4121,9 @@ var DeepdotsPopups = class {
2814
4121
  emitEvent(type, surveyId, data) {
2815
4122
  const event = { type, surveyId, timestamp: Date.now(), data };
2816
4123
  this.log("Event emitted", event);
4124
+ if (type === "popup_clicked" && data?.action === "partial") {
4125
+ this.markSurveyProgress(surveyId, "PARTIAL");
4126
+ }
2817
4127
  if (type === "survey_completed") {
2818
4128
  this.markSurveyAnswered(surveyId);
2819
4129
  }
@@ -2822,7 +4132,7 @@ var DeepdotsPopups = class {
2822
4132
  const popupId = popupIdFromData || this.surveyToPopupId.get(surveyId);
2823
4133
  if (popupId) {
2824
4134
  const userIdFromData = data?.userId;
2825
- void this.postPopupEvent(type === "popup_shown" ? "opened" : "completed", popupId, userIdFromData || this.config?.userId);
4135
+ void this.postPopupEvent(type === "popup_shown" ? "SHOWED" /* SHOWED */ : "COMPLETED" /* COMPLETED */, popupId, userIdFromData || this.config?.userId);
2826
4136
  } else {
2827
4137
  this.debug("No popupId available to post event", { type, surveyId });
2828
4138
  }
@@ -2855,26 +4165,103 @@ var DeepdotsPopups = class {
2855
4165
  this.renderer.init();
2856
4166
  }
2857
4167
  }
2858
- // Type guards
4168
+ normalizeUrl(value) {
4169
+ if (!value) return "";
4170
+ const withoutIndex = value.replace(/\/index\.html(?=($|[?#]))/i, "");
4171
+ return withoutIndex.length > 1 && withoutIndex.endsWith("/") ? withoutIndex.slice(0, -1) : withoutIndex;
4172
+ }
4173
+ safeParseUrl(url) {
4174
+ if (!url) return null;
4175
+ try {
4176
+ return new URL(url, typeof window !== "undefined" ? window.location.href : void 0);
4177
+ } catch {
4178
+ return null;
4179
+ }
4180
+ }
4181
+ mapPopupTriggerType(type) {
4182
+ switch (type) {
4183
+ case "time_on_page":
4184
+ return "time";
4185
+ case "scroll":
4186
+ return "scroll";
4187
+ case "exit":
4188
+ return "exit";
4189
+ case "click":
4190
+ return "click";
4191
+ case "event":
4192
+ return "event";
4193
+ default:
4194
+ return null;
4195
+ }
4196
+ }
4197
+ markSurveyProgress(surveyId, status) {
4198
+ const current = this.surveyProgress.get(surveyId);
4199
+ if (current?.status === "COMPLETED" && status !== "COMPLETED") {
4200
+ return;
4201
+ }
4202
+ this.surveyProgress.set(surveyId, { status, timestamp: Date.now() });
4203
+ }
2859
4204
  isPopupDefinition(value) {
2860
4205
  if (typeof value !== "object" || value === null) return false;
2861
- const v = value;
2862
- const trigger = v.triggers || v.triggers;
2863
- if (!trigger) return false;
2864
- return typeof v.id === "string" && typeof v.title === "string" && typeof v.message === "string" && typeof v.surveyId === "string" && typeof v.productId === "string";
4206
+ const popup = value;
4207
+ return typeof popup.id === "string" && typeof popup.title === "string" && typeof popup.message === "string" && typeof popup.surveyId === "string" && typeof popup.productId === "string" && Array.isArray(popup.triggers) && popup.triggers.length > 0 && popup.triggers.every((trigger) => this.isPopupTrigger(trigger)) && (!popup.cooldown || popup.cooldown.every((condition) => this.isPopupTriggerCondition(condition)));
4208
+ }
4209
+ isPopupTrigger(value) {
4210
+ if (typeof value !== "object" || value === null) return false;
4211
+ const trigger = value;
4212
+ return this.isPopupTriggerType(trigger.type) && (typeof trigger.value === "number" || typeof trigger.value === "string");
4213
+ }
4214
+ isPopupTriggerType(value) {
4215
+ return value === "time_on_page" || value === "scroll" || value === "exit" || value === "click" || value === "event";
4216
+ }
4217
+ isPopupTriggerCondition(value) {
4218
+ if (typeof value !== "object" || value === null) return false;
4219
+ const condition = value;
4220
+ return POPUP_TRIGGER_CONDITION_STATUSES.includes(condition.answered) && typeof condition.cooldownDays === "number" && Number.isFinite(condition.cooldownDays) && condition.cooldownDays >= 0;
4221
+ }
4222
+ isLegacyPopupTriggerCondition(value) {
4223
+ if (typeof value !== "object" || value === null) return false;
4224
+ const condition = value;
4225
+ if (condition.answered !== void 0 && typeof condition.answered !== "boolean") {
4226
+ return false;
4227
+ }
4228
+ if (condition.cooldownDays !== void 0) {
4229
+ return typeof condition.cooldownDays === "number" && Number.isFinite(condition.cooldownDays) && condition.cooldownDays >= 0;
4230
+ }
4231
+ return true;
4232
+ }
4233
+ normalizeTriggers(value) {
4234
+ const items = Array.isArray(value) ? value : value ? [value] : [];
4235
+ return items.filter((trigger) => this.isPopupTrigger(trigger)).map((trigger) => ({
4236
+ type: trigger.type,
4237
+ value: trigger.value
4238
+ }));
4239
+ }
4240
+ normalizeCooldown(value) {
4241
+ if (!Array.isArray(value)) return [];
4242
+ return value.filter((condition) => this.isPopupTriggerCondition(condition));
4243
+ }
4244
+ normalizeLegacyConditions(value) {
4245
+ if (!Array.isArray(value)) return [];
4246
+ return value.filter((condition) => this.isLegacyPopupTriggerCondition(condition));
2865
4247
  }
2866
4248
  normalizePopupDefinition(def) {
2867
4249
  if (typeof def !== "object" || def === null) return null;
2868
4250
  const raw = def;
2869
- const trigger = raw.triggers || raw.triggers;
2870
- if (!trigger) return null;
2871
- const condition = trigger.condition ?? raw.conditions ?? [];
4251
+ const rawTriggers = raw.triggers ?? raw.trigger;
4252
+ const triggers = this.normalizeTriggers(rawTriggers);
4253
+ if (!triggers.length) return null;
4254
+ const rawTriggerList = Array.isArray(rawTriggers) ? rawTriggers : rawTriggers ? [rawTriggers] : [];
4255
+ const legacyConditions = [
4256
+ ...this.normalizeLegacyConditions(raw.conditions),
4257
+ ...rawTriggerList.flatMap((trigger) => this.normalizeLegacyConditions(trigger.condition))
4258
+ ];
4259
+ const cooldown = this.normalizeCooldown(raw.cooldown);
2872
4260
  return {
2873
4261
  ...raw,
2874
- triggers: {
2875
- ...trigger,
2876
- condition
2877
- }
4262
+ triggers,
4263
+ cooldown,
4264
+ legacyConditions
2878
4265
  };
2879
4266
  }
2880
4267
  validatePopupDefinitions(defs) {