@magicfeedback/popup-sdk 1.18.0 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/MagicfeedbackPopupSdk.podspec +18 -0
  2. package/README.md +23 -0
  3. package/dist/2.2.38-CCK7SF4A.mjs +2343 -0
  4. package/dist/2.2.38-CCK7SF4A.mjs.map +1 -0
  5. package/dist/2.2.38-LGZRM7GX.mjs +2343 -0
  6. package/dist/2.2.38-LGZRM7GX.mjs.map +1 -0
  7. package/dist/2.2.39-BJJ3YRJ4.mjs +2344 -0
  8. package/dist/2.2.39-BJJ3YRJ4.mjs.map +1 -0
  9. package/dist/2.2.39-HPNDYUPP.mjs +2344 -0
  10. package/dist/2.2.39-HPNDYUPP.mjs.map +1 -0
  11. package/dist/assets/assets/style.css +107 -1
  12. package/dist/assets/assets/survey-css/2.2.38.css +2335 -0
  13. package/dist/assets/assets/survey-css/2.2.39.css +2336 -0
  14. package/dist/chunk-3QS3WKRC.mjs +31 -0
  15. package/dist/chunk-3QS3WKRC.mjs.map +1 -0
  16. package/dist/chunk-BJTO5JO5.mjs +11 -0
  17. package/dist/chunk-BJTO5JO5.mjs.map +1 -0
  18. package/dist/{chunk-DNBFTJCA.mjs → chunk-FROREHRG.mjs} +516 -52
  19. package/dist/chunk-FROREHRG.mjs.map +1 -0
  20. package/dist/{chunk-7ZVOPIWE.mjs → chunk-OPR5I7WO.mjs} +557 -11
  21. package/dist/chunk-OPR5I7WO.mjs.map +1 -0
  22. package/dist/chunk-ZJ5HG3QF.mjs +3357 -0
  23. package/dist/chunk-ZJ5HG3QF.mjs.map +1 -0
  24. package/dist/index.d.mts +217 -9
  25. package/dist/index.d.ts +217 -9
  26. package/dist/index.js +7253 -1519
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +389 -49
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/index.native.d.mts +1681 -0
  31. package/dist/index.native.d.ts +1681 -0
  32. package/dist/index.native.js +15972 -0
  33. package/dist/index.native.js.map +1 -0
  34. package/dist/index.native.mjs +4011 -0
  35. package/dist/index.native.mjs.map +1 -0
  36. package/dist/react-native.d.mts +113 -7
  37. package/dist/react-native.d.ts +113 -7
  38. package/dist/react-native.js +5846 -162
  39. package/dist/react-native.js.map +1 -1
  40. package/dist/react-native.mjs +396 -51
  41. package/dist/react-native.mjs.map +1 -1
  42. package/dist/{renderPopup-B6VIV4VS.mjs → renderPopup-I6CPIR75.mjs} +133 -6
  43. package/dist/renderPopup-I6CPIR75.mjs.map +1 -0
  44. package/dist/renderPopup-RUY3OBYV.mjs +3847 -0
  45. package/dist/renderPopup-RUY3OBYV.mjs.map +1 -0
  46. package/dist/renderPopup-XNVNP2ZU.mjs +3847 -0
  47. package/dist/renderPopup-XNVNP2ZU.mjs.map +1 -0
  48. package/ios/DeepdotsBackgroundTask.m +71 -0
  49. package/package.json +14 -5
  50. package/react-native.config.js +9 -0
  51. package/dist/chunk-7ZVOPIWE.mjs.map +0 -1
  52. package/dist/chunk-DNBFTJCA.mjs.map +0 -1
  53. package/dist/renderPopup-B6VIV4VS.mjs.map +0 -1
  54. package/dist/renderPopup-BKZPAZZG.mjs +0 -3682
  55. package/dist/renderPopup-BKZPAZZG.mjs.map +0 -1
@@ -1,3682 +0,0 @@
1
- import {
2
- REVEAL_TIMEOUT_MS,
3
- __commonJS,
4
- __toESM,
5
- applySurveyPrimaryColor,
6
- buildFontFaceCss,
7
- buildFontFamilyValue,
8
- buildSurveyIdentity,
9
- classifySubmitError,
10
- directionFor,
11
- getLabels,
12
- resolveActionLabels,
13
- revealWhenPainted,
14
- sdkError,
15
- sdkLog,
16
- sdkWarn,
17
- setSurveyBusy,
18
- style_default
19
- } from "./chunk-DNBFTJCA.mjs";
20
-
21
- // node_modules/@magicfeedback/native/dist/magicfeedback-sdk.browser.js
22
- var require_magicfeedback_sdk_browser = __commonJS({
23
- "node_modules/@magicfeedback/native/dist/magicfeedback-sdk.browser.js"(exports, module) {
24
- "use strict";
25
- !(function(e, t) {
26
- "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.magicfeedback = t() : e.magicfeedback = t();
27
- })(self, (() => {
28
- return e = { 6539: function(e2, t2) {
29
- var i = "undefined" != typeof self ? self : this, n = (function() {
30
- function e3() {
31
- this.fetch = false, this.DOMException = i.DOMException;
32
- }
33
- return e3.prototype = i, new e3();
34
- })();
35
- !(function(e3) {
36
- !(function(t3) {
37
- var i2 = "URLSearchParams" in e3, n2 = "Symbol" in e3 && "iterator" in Symbol, r2 = "FileReader" in e3 && "Blob" in e3 && (function() {
38
- try {
39
- return new Blob(), true;
40
- } catch (e4) {
41
- return false;
42
- }
43
- })(), o = "FormData" in e3, a = "ArrayBuffer" in e3;
44
- if (a) var s = ["[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]"], l = ArrayBuffer.isView || function(e4) {
45
- return e4 && s.indexOf(Object.prototype.toString.call(e4)) > -1;
46
- };
47
- function d(e4) {
48
- if ("string" != typeof e4 && (e4 = String(e4)), /[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e4)) throw new TypeError("Invalid character in header field name");
49
- return e4.toLowerCase();
50
- }
51
- function c(e4) {
52
- return "string" != typeof e4 && (e4 = String(e4)), e4;
53
- }
54
- function u(e4) {
55
- var t4 = { next: function() {
56
- var t5 = e4.shift();
57
- return { done: void 0 === t5, value: t5 };
58
- } };
59
- return n2 && (t4[Symbol.iterator] = function() {
60
- return t4;
61
- }), t4;
62
- }
63
- function p(e4) {
64
- this.map = {}, e4 instanceof p ? e4.forEach((function(e5, t4) {
65
- this.append(t4, e5);
66
- }), this) : Array.isArray(e4) ? e4.forEach((function(e5) {
67
- this.append(e5[0], e5[1]);
68
- }), this) : e4 && Object.getOwnPropertyNames(e4).forEach((function(t4) {
69
- this.append(t4, e4[t4]);
70
- }), this);
71
- }
72
- function m(e4) {
73
- if (e4.bodyUsed) return Promise.reject(new TypeError("Already read"));
74
- e4.bodyUsed = true;
75
- }
76
- function h(e4) {
77
- return new Promise((function(t4, i3) {
78
- e4.onload = function() {
79
- t4(e4.result);
80
- }, e4.onerror = function() {
81
- i3(e4.error);
82
- };
83
- }));
84
- }
85
- function f(e4) {
86
- var t4 = new FileReader(), i3 = h(t4);
87
- return t4.readAsArrayBuffer(e4), i3;
88
- }
89
- function g(e4) {
90
- if (e4.slice) return e4.slice(0);
91
- var t4 = new Uint8Array(e4.byteLength);
92
- return t4.set(new Uint8Array(e4)), t4.buffer;
93
- }
94
- function y() {
95
- return this.bodyUsed = false, this._initBody = function(e4) {
96
- var t4;
97
- this._bodyInit = e4, e4 ? "string" == typeof e4 ? this._bodyText = e4 : r2 && Blob.prototype.isPrototypeOf(e4) ? this._bodyBlob = e4 : o && 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 = g(e4.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : a && (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"));
98
- }, r2 && (this.blob = function() {
99
- var e4 = m(this);
100
- if (e4) return e4;
101
- if (this._bodyBlob) return Promise.resolve(this._bodyBlob);
102
- if (this._bodyArrayBuffer) return Promise.resolve(new Blob([this._bodyArrayBuffer]));
103
- if (this._bodyFormData) throw new Error("could not read FormData body as blob");
104
- return Promise.resolve(new Blob([this._bodyText]));
105
- }, this.arrayBuffer = function() {
106
- return this._bodyArrayBuffer ? m(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(f);
107
- }), this.text = function() {
108
- var e4, t4, i3, n3 = m(this);
109
- if (n3) return n3;
110
- if (this._bodyBlob) return e4 = this._bodyBlob, i3 = h(t4 = new FileReader()), t4.readAsText(e4), i3;
111
- if (this._bodyArrayBuffer) return Promise.resolve((function(e5) {
112
- for (var t5 = new Uint8Array(e5), i4 = new Array(t5.length), n4 = 0; n4 < t5.length; n4++) i4[n4] = String.fromCharCode(t5[n4]);
113
- return i4.join("");
114
- })(this._bodyArrayBuffer));
115
- if (this._bodyFormData) throw new Error("could not read FormData body as text");
116
- return Promise.resolve(this._bodyText);
117
- }, o && (this.formData = function() {
118
- return this.text().then(E);
119
- }), this.json = function() {
120
- return this.text().then(JSON.parse);
121
- }, this;
122
- }
123
- p.prototype.append = function(e4, t4) {
124
- e4 = d(e4), t4 = c(t4);
125
- var i3 = this.map[e4];
126
- this.map[e4] = i3 ? i3 + ", " + t4 : t4;
127
- }, p.prototype.delete = function(e4) {
128
- delete this.map[d(e4)];
129
- }, p.prototype.get = function(e4) {
130
- return e4 = d(e4), this.has(e4) ? this.map[e4] : null;
131
- }, p.prototype.has = function(e4) {
132
- return this.map.hasOwnProperty(d(e4));
133
- }, p.prototype.set = function(e4, t4) {
134
- this.map[d(e4)] = c(t4);
135
- }, p.prototype.forEach = function(e4, t4) {
136
- for (var i3 in this.map) this.map.hasOwnProperty(i3) && e4.call(t4, this.map[i3], i3, this);
137
- }, p.prototype.keys = function() {
138
- var e4 = [];
139
- return this.forEach((function(t4, i3) {
140
- e4.push(i3);
141
- })), u(e4);
142
- }, p.prototype.values = function() {
143
- var e4 = [];
144
- return this.forEach((function(t4) {
145
- e4.push(t4);
146
- })), u(e4);
147
- }, p.prototype.entries = function() {
148
- var e4 = [];
149
- return this.forEach((function(t4, i3) {
150
- e4.push([i3, t4]);
151
- })), u(e4);
152
- }, n2 && (p.prototype[Symbol.iterator] = p.prototype.entries);
153
- var v = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
154
- function b(e4, t4) {
155
- var i3, n3, r3 = (t4 = t4 || {}).body;
156
- if (e4 instanceof b) {
157
- if (e4.bodyUsed) throw new TypeError("Already read");
158
- 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);
159
- } else this.url = String(e4);
160
- 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(), v.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");
161
- this._initBody(r3);
162
- }
163
- function E(e4) {
164
- var t4 = new FormData();
165
- return e4.trim().split("&").forEach((function(e5) {
166
- if (e5) {
167
- var i3 = e5.split("="), n3 = i3.shift().replace(/\+/g, " "), r3 = i3.join("=").replace(/\+/g, " ");
168
- t4.append(decodeURIComponent(n3), decodeURIComponent(r3));
169
- }
170
- })), t4;
171
- }
172
- function A(e4, t4) {
173
- 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);
174
- }
175
- b.prototype.clone = function() {
176
- return new b(this, { body: this._bodyInit });
177
- }, y.call(b.prototype), y.call(A.prototype), A.prototype.clone = function() {
178
- return new A(this._bodyInit, { status: this.status, statusText: this.statusText, headers: new p(this.headers), url: this.url });
179
- }, A.error = function() {
180
- var e4 = new A(null, { status: 0, statusText: "" });
181
- return e4.type = "error", e4;
182
- };
183
- var k = [301, 302, 303, 307, 308];
184
- A.redirect = function(e4, t4) {
185
- if (-1 === k.indexOf(t4)) throw new RangeError("Invalid status code");
186
- return new A(null, { status: t4, headers: { location: e4 } });
187
- }, t3.DOMException = e3.DOMException;
188
- try {
189
- new t3.DOMException();
190
- } catch (e4) {
191
- t3.DOMException = function(e5, t4) {
192
- this.message = e5, this.name = t4;
193
- var i3 = Error(e5);
194
- this.stack = i3.stack;
195
- }, t3.DOMException.prototype = Object.create(Error.prototype), t3.DOMException.prototype.constructor = t3.DOMException;
196
- }
197
- function T(e4, i3) {
198
- return new Promise((function(n3, o2) {
199
- var a2 = new b(e4, i3);
200
- if (a2.signal && a2.signal.aborted) return o2(new t3.DOMException("Aborted", "AbortError"));
201
- var s2 = new XMLHttpRequest();
202
- function l2() {
203
- s2.abort();
204
- }
205
- s2.onload = function() {
206
- var e5, t4, i4 = { status: s2.status, statusText: s2.statusText, headers: (e5 = s2.getAllResponseHeaders() || "", t4 = new p(), e5.replace(/\r?\n[\t ]+/g, " ").split(/\r?\n/).forEach((function(e6) {
207
- var i5 = e6.split(":"), n4 = i5.shift().trim();
208
- if (n4) {
209
- var r4 = i5.join(":").trim();
210
- t4.append(n4, r4);
211
- }
212
- })), t4) };
213
- i4.url = "responseURL" in s2 ? s2.responseURL : i4.headers.get("X-Request-URL");
214
- var r3 = "response" in s2 ? s2.response : s2.responseText;
215
- n3(new A(r3, i4));
216
- }, s2.onerror = function() {
217
- o2(new TypeError("Network request failed"));
218
- }, s2.ontimeout = function() {
219
- o2(new TypeError("Network request failed"));
220
- }, s2.onabort = function() {
221
- o2(new t3.DOMException("Aborted", "AbortError"));
222
- }, s2.open(a2.method, a2.url, true), "include" === a2.credentials ? s2.withCredentials = true : "omit" === a2.credentials && (s2.withCredentials = false), "responseType" in s2 && r2 && (s2.responseType = "blob"), a2.headers.forEach((function(e5, t4) {
223
- s2.setRequestHeader(t4, e5);
224
- })), a2.signal && (a2.signal.addEventListener("abort", l2), s2.onreadystatechange = function() {
225
- 4 === s2.readyState && a2.signal.removeEventListener("abort", l2);
226
- }), s2.send(void 0 === a2._bodyInit ? null : a2._bodyInit);
227
- }));
228
- }
229
- T.polyfill = true, e3.fetch || (e3.fetch = T, e3.Headers = p, e3.Request = b, e3.Response = A), t3.Headers = p, t3.Request = b, t3.Response = A, t3.fetch = T, Object.defineProperty(t3, "__esModule", { value: true });
230
- })({});
231
- })(n), n.fetch.ponyfill = true, delete n.fetch.polyfill;
232
- var r = n;
233
- (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;
234
- }, 5867: (e2, t2) => {
235
- "use strict";
236
- 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/";
237
- }, 1422: function(e2, t2, i) {
238
- "use strict";
239
- var n = this && this.__importDefault || function(e3) {
240
- return e3 && e3.__esModule ? e3 : { default: e3 };
241
- };
242
- Object.defineProperty(t2, "__esModule", { value: true });
243
- const r = n(i(8453));
244
- let o = null;
245
- o || (o = (0, r.default)()), t2.default = o;
246
- }, 8453: function(e2, t2, i) {
247
- "use strict";
248
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
249
- return new (i2 || (i2 = Promise))((function(r2, o2) {
250
- function a2(e4) {
251
- try {
252
- l2(n2.next(e4));
253
- } catch (e5) {
254
- o2(e5);
255
- }
256
- }
257
- function s2(e4) {
258
- try {
259
- l2(n2.throw(e4));
260
- } catch (e5) {
261
- o2(e5);
262
- }
263
- }
264
- function l2(e4) {
265
- var t4;
266
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
267
- e5(t4);
268
- }))).then(a2, s2);
269
- }
270
- l2((n2 = n2.apply(e3, t3 || [])).next());
271
- }));
272
- };
273
- Object.defineProperty(t2, "__esModule", { value: true });
274
- const r = i(1167), o = i(7490), a = i(9303), s = i(4070), l = i(9071), d = i(5867), c = i(3433);
275
- t2.default = function() {
276
- const e3 = new a.Config();
277
- let t3 = new s.Log(e3);
278
- return { init: function(i2) {
279
- "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), (null == i2 ? void 0 : i2.lang) && e3.set("lang", (0, c.normalizeSurveyLang)(i2.lang)), e3.set("url", (null == i2 ? void 0 : i2.env) && "dev" === (null == i2 ? void 0 : i2.env) ? d.HOST_API_URL_DEV : d.HOST_API_URL), e3.set("env", null == i2 ? void 0 : i2.env), t3.log("Initialized Magicfeedback", e3);
280
- }, send: function(i2, r2, o2, a2 = true, s2, d2) {
281
- var u;
282
- return n(this, void 0, void 0, (function* () {
283
- i2 || t3.err("No appID provided"), r2 || t3.err("No publicKey provided"), o2 || t3.err("No feedback provided"), o2.answers || o2.profile || o2.metrics || o2.metadata || t3.err("No feedback data provided");
284
- const n2 = e3.get("url"), p = { integration: i2, publicKey: r2, privateKey: d2, completed: a2, id: s2, feedback: o2, lang: null !== (u = (0, c.detectSurveyLang)(e3.get("lang"))) && void 0 !== u ? u : void 0 };
285
- try {
286
- if (e3.get("dryRun")) return t3.log("Dry run enabled: skipping native feedback submit"), `dry-run-${Date.now()}`;
287
- const i3 = yield (0, l.sendFeedback)(n2, p, t3);
288
- return t3.log("sent native feedback"), i3;
289
- } catch (e4) {
290
- return t3.err("error native feedback", e4), false;
291
- }
292
- }));
293
- }, form: function(i2, n2, o2, a2) {
294
- return i2 || t3.err("No appID provided"), n2 || t3.err("No publicKey provided"), new r.Form(e3, i2, n2, o2, a2);
295
- }, agentForm: function(i2, n2, r2) {
296
- return i2 || t3.err("No integrationId provided"), n2 || t3.err("No publicKey provided"), new o.AgentForm(e3, i2, n2, r2);
297
- }, session: function(i2) {
298
- return i2 || t3.err("No sessionId provided"), new r.Form(e3, i2);
299
- }, previewPage: function(i2, o2, a2) {
300
- return n(this, void 0, void 0, (function* () {
301
- i2 || t3.err("No selector provided"), o2 && o2.page || t3.err("No page provided for preview");
302
- const n2 = (null == o2 ? void 0 : o2.appId) || `preview-${Date.now()}`, s2 = new r.Form(e3, n2);
303
- return yield s2.previewPage(i2, o2, a2), s2;
304
- }));
305
- } };
306
- };
307
- }, 9481: (e2, t2) => {
308
- "use strict";
309
- Object.defineProperty(t2, "__esModule", { value: true }), t2.History = void 0, t2.History = class {
310
- constructor() {
311
- this.items = [];
312
- }
313
- enqueue(e3) {
314
- this.items.push(e3);
315
- }
316
- dequeue() {
317
- return this.items.shift();
318
- }
319
- rollback() {
320
- return this.items.pop();
321
- }
322
- front() {
323
- return this.items[0];
324
- }
325
- back() {
326
- return this.items[this.items.length - 1];
327
- }
328
- isEmpty() {
329
- return 0 === this.items.length;
330
- }
331
- size() {
332
- return this.items.length;
333
- }
334
- get(e3) {
335
- return this.items[e3];
336
- }
337
- };
338
- }, 7490: function(e2, t2, i) {
339
- "use strict";
340
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
341
- return new (i2 || (i2 = Promise))((function(r2, o2) {
342
- function a2(e4) {
343
- try {
344
- l2(n2.next(e4));
345
- } catch (e5) {
346
- o2(e5);
347
- }
348
- }
349
- function s2(e4) {
350
- try {
351
- l2(n2.throw(e4));
352
- } catch (e5) {
353
- o2(e5);
354
- }
355
- }
356
- function l2(e4) {
357
- var t4;
358
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
359
- e5(t4);
360
- }))).then(a2, s2);
361
- }
362
- l2((n2 = n2.apply(e3, t3 || [])).next());
363
- }));
364
- };
365
- Object.defineProperty(t2, "__esModule", { value: true }), t2.AgentForm = void 0;
366
- const r = i(4070), o = i(3501), a = i(4759), s = i(1351), l = i(5349), d = i(2335), c = i(8129), u = i(7643), p = i(7627), m = i(9089), h = i(9039);
367
- t2.AgentForm = class {
368
- constructor(e3, t3, i2, n2) {
369
- this.config = e3, this.log = new r.Log(e3), this.url = e3.get("url"), this.integrationId = t3, this.publicKey = i2, this.privateKey = n2, this.formOptionsConfig = { addButton: true, addSuccessScreen: true, questionFormat: "standard", answerDelimiter: s.DEFAULT_ANSWER_DELIMITER, resume: true, allowBack: false, emptyAnswerText: "" }, this.selector = "", this.language = "en", this.product = { customIcons: false }, this.integrationData = null, this.started = false, this.sessionId = "", this.conversation = [], this.askedRefs = [], this.currentTurn = 1, this.maxTurns = 0, this.currentQuestion = null, this.questionHistory = [], this.busy = false, this.rateLimitTimer = null, this.progress = 0, this.total = 0, this.completed = false, this.timeToCompleted = 0;
370
- }
371
- generate(e3, t3 = {}) {
372
- var i2, r2;
373
- return n(this, void 0, void 0, (function* () {
374
- this.formOptionsConfig = Object.assign(Object.assign({}, this.formOptionsConfig), t3), this.selector = e3, t3.lang && (this.language = t3.lang), t3.primaryColor && (this.primaryColor = t3.primaryColor);
375
- const n2 = false === this.formOptionsConfig.resume || this.isPreview() ? null : this.restore(), o2 = null === (r2 = null === (i2 = this.integrationData) || void 0 === i2 ? void 0 : i2.style) || void 0 === r2 ? void 0 : r2.startMessage;
376
- if (n2 || !o2) yield this.open(n2);
377
- else try {
378
- this.renderWelcome(o2);
379
- } catch (e4) {
380
- this.log.err(`Could not show the introduction of ${this.integrationId}:`, e4), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 }));
381
- }
382
- }));
383
- }
384
- startForm() {
385
- return n(this, void 0, void 0, (function* () {
386
- this.started || (yield this.open(null));
387
- }));
388
- }
389
- renderWelcome(e3) {
390
- var t3;
391
- const i2 = (0, d.generateContainer)(this.selector, this.integrationId);
392
- this.primaryColor && (0, d.applyPrimaryColor)(i2, this.primaryColor), (0, d.applyDirection)(i2, this.language), i2.appendChild((0, u.renderStartMessage)(e3, this.formOptionsConfig.addButton, this.formOptionsConfig.startButtonText || (0, p.t)(this.language, "action.start"), (() => this.startForm()))), this.formOptionsConfig.onLoadedEvent && this.formOptionsConfig.onLoadedEvent({ loading: false, formData: null !== (t3 = this.integrationData) && void 0 !== t3 ? t3 : void 0, lang: this.language });
393
- }
394
- open(e3) {
395
- var t3, i2, r2;
396
- return n(this, void 0, void 0, (function* () {
397
- this.started = true;
398
- try {
399
- if (e3) this.log.log(`Resuming agent session ${e3.sessionId} at turn ${e3.currentTurn}`), this.mountForm(), this.renderStep();
400
- else {
401
- const e4 = yield this.startWithRetry();
402
- this.sessionId = e4.sessionId, this.maxTurns = e4.maxTurns, this.currentTurn = null !== (t3 = e4.currentTurn) && void 0 !== t3 ? t3 : 1, this.total = Math.max(this.maxTurns - 1, 0);
403
- const n2 = (0, s.toAgentStep)(e4, this.adapterContext());
404
- if (this.mountForm(), "END" === n2.kind) return yield this.renderEnd(n2), void (this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, progress: this.progress, total: this.total, sessionId: this.sessionId, formData: null !== (i2 = this.integrationData) && void 0 !== i2 ? i2 : void 0, lang: this.language, completed: true })));
405
- this.acceptQuestion(n2), this.renderStep(), this.persist();
406
- }
407
- this.timeToCompleted = Date.now(), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, progress: this.progress, total: this.total, sessionId: this.sessionId, formData: null !== (r2 = this.integrationData) && void 0 !== r2 ? r2 : void 0, lang: this.language, formOptionsConfig: this.formOptionsConfig }));
408
- } catch (e4) {
409
- this.log.err(`Could not start the agent survey ${this.integrationId}:`, e4), this.renderFatal(e4), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 }));
410
- }
411
- }));
412
- }
413
- next() {
414
- return n(this, void 0, void 0, (function* () {
415
- return this.runTurn();
416
- }));
417
- }
418
- answer() {
419
- const e3 = document.getElementById(this.formId());
420
- return e3 ? (0, l.scrapeInputs)(e3) : [];
421
- }
422
- getConversation() {
423
- return [...this.conversation];
424
- }
425
- getSessionId() {
426
- return this.sessionId;
427
- }
428
- reset() {
429
- this.sessionId = "", this.conversation = [], this.askedRefs = [], this.currentTurn = 1, this.maxTurns = 0, this.currentQuestion = null, this.questionHistory = [], this.busy = false, this.completed = false, this.progress = 0, this.clearRateLimitTimer(), this.clearPersisted();
430
- }
431
- runTurn() {
432
- var e3;
433
- return n(this, void 0, void 0, (function* () {
434
- if (this.busy || this.completed || !this.currentQuestion) return;
435
- (0, h.cancelAutoAdvance)(document.getElementById(this.questionsId())), this.busy = true, this.setSubmitDisabled(true), this.clearError();
436
- const t3 = this.currentQuestion;
437
- try {
438
- const i2 = document.getElementById(this.formId()), n2 = document.getElementById(this.questionsId());
439
- if (!i2) throw new Error("Agent form not found");
440
- yield (0, c.awaitUploadReady)(n2);
441
- const r2 = (0, l.scrapeInputs)(i2);
442
- let o2 = (0, s.encodeAnswer)(r2, t3, this.formOptionsConfig.answerDelimiter);
443
- if ("" === o2) {
444
- if (t3.require) return void this.showError(this.formOptionsConfig.requiredMessage || (0, p.t)(this.language, "message.required"));
445
- o2 = this.formOptionsConfig.emptyAnswerText || "";
446
- }
447
- this.formOptionsConfig.beforeSubmitEvent && (yield this.formOptionsConfig.beforeSubmitEvent({ loading: true, progress: this.progress, total: this.total }));
448
- const d2 = { role: "user", content: o2, questionType: t3.type, questionRef: t3.ref }, u2 = this.currentTurn + 1, m2 = yield (0, a.nextAgentTurn)(this.url, Object.assign({ publicKey: this.publicKey, privateKey: this.privateKey, integrationId: this.integrationId, sessionId: this.sessionId, conversation: [...this.conversation], currentTurn: u2, lastAnswer: o2, lastQuestionRef: t3.ref, askedRefs: [...this.askedRefs] }, this.previewFlag()), this.log);
449
- this.conversation.push(d2), this.currentTurn = null !== (e3 = m2.currentTurn) && void 0 !== e3 ? e3 : u2, m2.maxTurns && (this.maxTurns = m2.maxTurns), this.total = Math.max(this.maxTurns - 1, 0);
450
- const h2 = (0, s.toAgentStep)(m2, this.adapterContext());
451
- if ("END" === h2.kind) return void (yield this.renderEnd(h2));
452
- if (this.maxTurns > 0 && this.currentTurn > this.maxTurns + 1) return void (yield this.renderEnd({ kind: "END", reason: "MAX_TURNS", currentTurn: this.currentTurn, maxTurns: this.maxTurns }));
453
- this.acceptQuestion(h2), this.renderStep(), this.persist(), this.formOptionsConfig.onAgentTurnEvent && (yield this.formOptionsConfig.onAgentTurnEvent({ turn: this.currentTurn, maxTurns: this.maxTurns, question: h2.question, isFromBase: h2.isFromBase, topic: h2.topic, coverageGaps: h2.coverageGaps, coverageSummary: h2.coverageSummary, conversation: this.getConversation() })), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.sessionId, loading: false, progress: this.progress, total: this.total, completed: false, error: null }));
454
- } catch (e4) {
455
- yield this.handleTurnError(e4);
456
- } finally {
457
- this.completed || (this.busy = false, this.rateLimitTimer || this.setSubmitDisabled(false));
458
- }
459
- }));
460
- }
461
- handleTurnError(e3) {
462
- return n(this, void 0, void 0, (function* () {
463
- this.log.err(`An error occurred during the agent turn ${this.integrationId}:`, e3), e3 instanceof o.AgentApiError && "RATE_LIMITED" === e3.kind ? this.startRateLimitCountdown(e3.retryAfterMs || 6e4) : this.showError(this.errorMessageFor(e3)), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total, completed: false, error: e3 }));
464
- }));
465
- }
466
- acceptQuestion(e3) {
467
- const t3 = e3.question;
468
- e3.isFromBase && t3.ref && !this.askedRefs.includes(t3.ref) && this.askedRefs.push(t3.ref), this.conversation.push({ role: "agent", content: t3.title, questionType: t3.type, questionRef: t3.ref }), this.currentQuestion = t3, this.questionHistory.push(t3), this.progress = Math.max(this.currentTurn - 1, 0);
469
- }
470
- formId() {
471
- return "magicfeedback-agent-" + this.integrationId;
472
- }
473
- questionsId() {
474
- return "magicfeedback-agent-questions-" + this.integrationId;
475
- }
476
- mountForm() {
477
- const e3 = (0, d.generateContainer)(this.selector, this.integrationId);
478
- this.primaryColor && (0, d.applyPrimaryColor)(e3, this.primaryColor), (0, d.applyDirection)(e3, this.language);
479
- const t3 = document.createElement("form");
480
- t3.classList.add("magicfeedback-form"), t3.classList.add("magicfeedback-agent-form"), t3.id = this.formId(), t3.addEventListener("submit", ((e4) => {
481
- e4.preventDefault(), this.runTurn();
482
- }));
483
- const i2 = document.createElement("div");
484
- i2.classList.add("magicfeedback-questions"), i2.id = this.questionsId(), t3.appendChild(i2), this.formOptionsConfig.addButton && t3.appendChild((0, u.renderActions)(this.formOptionsConfig.allowBack ? "MAGICSURVEY" : "MAGICFORM", (() => this.back()), this.formOptionsConfig.sendButtonText || (0, p.t)(this.language, "action.send"), this.formOptionsConfig.backButtonText || (0, p.t)(this.language, "action.back"), this.formOptionsConfig.nextButtonText || (0, p.t)(this.language, "action.next"))), e3.appendChild(t3);
485
- }
486
- renderStep() {
487
- const e3 = document.getElementById(this.questionsId());
488
- e3 && this.currentQuestion && (e3.innerHTML = "", (0, u.renderQuestions)([this.currentQuestion], this.formOptionsConfig.questionFormat, this.language, this.product, (() => this.runTurn())).forEach(((t3) => e3.appendChild(t3))), (0, m.armGhostTapGuard)(e3));
489
- }
490
- renderEnd(e3) {
491
- return n(this, void 0, void 0, (function* () {
492
- this.completed = true, this.currentQuestion = null, this.busy = false, this.timeToCompleted = this.timeToCompleted ? Date.now() - this.timeToCompleted : 0, this.clearRateLimitTimer(), this.clearPersisted();
493
- const t3 = document.getElementById("magicfeedback-container-" + this.integrationId);
494
- if (t3 && false !== this.formOptionsConfig.addSuccessScreen) {
495
- t3.innerHTML = "";
496
- const i2 = "BLOCKED" === e3.reason ? this.formOptionsConfig.blockedMessage || (0, p.t)(this.language, "message.blocked") : this.formOptionsConfig.successMessage || (0, p.t)(this.language, "message.success"), n2 = (0, u.renderSuccess)(i2);
497
- n2.classList.add("magicfeedback-success-message"), n2.classList.add("magicfeedback-agent-end"), "BLOCKED" === e3.reason && n2.classList.add("magicfeedback-agent-end--blocked"), t3.appendChild(n2);
498
- }
499
- this.formOptionsConfig.onFinishEvent && (yield this.formOptionsConfig.onFinishEvent({ sessionId: this.sessionId, reason: e3.reason, turns: this.currentTurn, maxTurns: this.maxTurns, conversation: this.getConversation(), coverageSummary: e3.coverageSummary, timeToCompleted: this.timeToCompleted })), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.sessionId, loading: false, progress: this.progress, total: this.total, completed: true, error: null }));
500
- }));
501
- }
502
- back() {
503
- return n(this, void 0, void 0, (function* () {
504
- this.busy || this.completed || this.formOptionsConfig.allowBack && (this.questionHistory.length < 2 || (this.questionHistory.pop(), this.conversation.pop(), this.conversation.pop(), this.currentQuestion = this.questionHistory[this.questionHistory.length - 1], this.currentTurn = Math.max(this.currentTurn - 1, 1), this.progress = Math.max(this.currentTurn - 1, 0), this.clearError(), this.renderStep(), this.persist(), this.formOptionsConfig.onBackEvent && (yield this.formOptionsConfig.onBackEvent({ progress: this.progress, total: this.total }))));
505
- }));
506
- }
507
- renderFatal(e3) {
508
- try {
509
- (0, d.generateContainer)(this.selector, this.integrationId).appendChild((0, u.renderError)(this.errorMessageFor(e3)));
510
- } catch (e4) {
511
- }
512
- }
513
- errorMessageFor(e3) {
514
- if (!(e3 instanceof o.AgentApiError)) return "Something went wrong. Please try again.";
515
- switch (e3.kind) {
516
- case "AUTH":
517
- case "NOT_FOUND":
518
- case "BAD_CONFIG":
519
- return "This survey is not available right now.";
520
- case "AI_UNAVAILABLE":
521
- return "We couldn't start the survey. Please try again in a moment.";
522
- default:
523
- return "Something went wrong. Please try again.";
524
- }
525
- }
526
- adapterContext() {
527
- return { integrationId: this.integrationId, sessionId: this.sessionId, language: this.language, log: this.log };
528
- }
529
- startWithRetry() {
530
- return n(this, void 0, void 0, (function* () {
531
- const e3 = Object.assign({ publicKey: this.publicKey, privateKey: this.privateKey, integrationId: this.integrationId }, this.previewFlag());
532
- try {
533
- return yield (0, a.startAgentSurvey)(this.url, e3, this.log);
534
- } catch (t3) {
535
- if (t3 instanceof o.AgentApiError && "AI_UNAVAILABLE" === t3.kind) return this.log.log("Retrying /start after a transient AI failure"), yield new Promise(((e4) => setTimeout(e4, 1500))), yield (0, a.startAgentSurvey)(this.url, e3, this.log);
536
- throw t3;
537
- }
538
- }));
539
- }
540
- setSubmitDisabled(e3) {
541
- const t3 = document.getElementById("magicfeedback-submit");
542
- t3 && (t3.disabled = e3);
543
- }
544
- clearError() {
545
- const e3 = document.getElementById(this.questionsId());
546
- null == e3 || e3.querySelectorAll(".magicfeedback-error").forEach(((e4) => e4.remove()));
547
- }
548
- showError(e3) {
549
- const t3 = document.getElementById(this.questionsId());
550
- t3 && (this.clearError(), t3.insertBefore((0, u.renderError)(e3), t3.firstChild));
551
- }
552
- startRateLimitCountdown(e3) {
553
- this.clearRateLimitTimer(), this.setSubmitDisabled(true);
554
- let t3 = Math.ceil(e3 / 1e3);
555
- const i2 = this.formOptionsConfig.rateLimitMessage || (0, p.t)(this.language, "message.rateLimit"), n2 = () => {
556
- if (t3 <= 0) return this.clearRateLimitTimer(), this.clearError(), void this.setSubmitDisabled(false);
557
- this.showError(i2.replace("{seconds}", String(t3))), t3 -= 1;
558
- };
559
- n2(), this.rateLimitTimer = setInterval(n2, 1e3);
560
- }
561
- clearRateLimitTimer() {
562
- this.rateLimitTimer && (clearInterval(this.rateLimitTimer), this.rateLimitTimer = null);
563
- }
564
- storageKey() {
565
- return `magicfeedback-agent-${this.integrationId}`;
566
- }
567
- isPreview() {
568
- return Boolean(this.config.get("dryRun"));
569
- }
570
- previewFlag() {
571
- return this.isPreview() ? { preview: true } : {};
572
- }
573
- persist() {
574
- if (!this.isPreview() && false !== this.formOptionsConfig.resume) try {
575
- const e3 = { sessionId: this.sessionId, conversation: this.conversation, currentTurn: this.currentTurn, maxTurns: this.maxTurns, askedRefs: this.askedRefs, questionHistory: this.questionHistory, savedAt: Date.now() };
576
- localStorage.setItem(this.storageKey(), JSON.stringify(e3));
577
- } catch (e3) {
578
- this.log.log("Could not persist the agent session", e3);
579
- }
580
- }
581
- restore() {
582
- var e3;
583
- try {
584
- const t3 = localStorage.getItem(this.storageKey());
585
- if (!t3) return null;
586
- const i2 = JSON.parse(t3);
587
- return (null == i2 ? void 0 : i2.sessionId) && (null === (e3 = i2.questionHistory) || void 0 === e3 ? void 0 : e3.length) ? Date.now() - (i2.savedAt || 0) > 18e5 ? (this.clearPersisted(), null) : (this.sessionId = i2.sessionId, this.conversation = i2.conversation || [], this.currentTurn = i2.currentTurn || 1, this.maxTurns = i2.maxTurns || 0, this.askedRefs = i2.askedRefs || [], this.questionHistory = i2.questionHistory, this.currentQuestion = this.questionHistory[this.questionHistory.length - 1], this.total = Math.max(this.maxTurns - 1, 0), this.progress = Math.max(this.currentTurn - 1, 0), i2) : null;
588
- } catch (e4) {
589
- return this.log.log("Could not restore the agent session", e4), null;
590
- }
591
- }
592
- clearPersisted() {
593
- try {
594
- localStorage.removeItem(this.storageKey());
595
- } catch (e3) {
596
- }
597
- }
598
- applyIntegrationContext(e3) {
599
- var t3, i2;
600
- this.integrationData = e3, (null === (t3 = null == e3 ? void 0 : e3.lang) || void 0 === t3 ? void 0 : t3.length) && (this.language = e3.lang[0]), (null == e3 ? void 0 : e3.product) && (this.product = e3.product), (null === (i2 = null == e3 ? void 0 : e3.style) || void 0 === i2 ? void 0 : i2.primaryColor) && (this.primaryColor = e3.style.primaryColor);
601
- }
602
- };
603
- }, 9303: (e2, t2) => {
604
- "use strict";
605
- Object.defineProperty(t2, "__esModule", { value: true }), t2.Config = void 0, t2.Config = class {
606
- constructor() {
607
- this.variables = {}, this.variables.env = "prod", this.variables.debug = false, this.variables.dryRun = false;
608
- }
609
- get(e3) {
610
- return this.variables[e3];
611
- }
612
- set(e3, t3) {
613
- this.variables[e3] = t3;
614
- }
615
- };
616
- }, 1167: function(e2, t2, i) {
617
- "use strict";
618
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
619
- return new (i2 || (i2 = Promise))((function(r2, o2) {
620
- function a2(e4) {
621
- try {
622
- l2(n2.next(e4));
623
- } catch (e5) {
624
- o2(e5);
625
- }
626
- }
627
- function s2(e4) {
628
- try {
629
- l2(n2.throw(e4));
630
- } catch (e5) {
631
- o2(e5);
632
- }
633
- }
634
- function l2(e4) {
635
- var t4;
636
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
637
- e5(t4);
638
- }))).then(a2, s2);
639
- }
640
- l2((n2 = n2.apply(e3, t3 || [])).next());
641
- }));
642
- };
643
- Object.defineProperty(t2, "__esModule", { value: true }), t2.Form = void 0;
644
- const r = i(4760), o = i(7490), a = i(4070), s = i(9071), l = i(7643), d = i(8129), c = i(2335), u = i(5349), p = i(1719), m = i(3378), h = i(7305), f = i(9481), g = i(7170), y = i(7627), v = i(3433), b = i(9089), E = i(4069), A = i(9039), k = i(1012), T = [r.FEEDBACKAPPANSWERTYPE.INFO_PAGE, r.FEEDBACKAPPANSWERTYPE.PASSWORD, r.FEEDBACKAPPANSWERTYPE.EMAIL, r.FEEDBACKAPPANSWERTYPE.CONTACT, r.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE, r.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE, r.FEEDBACKAPPANSWERTYPE.MAX_DIFF];
645
- t2.Form = class {
646
- constructor(e3, t3, i2, n2, r2) {
647
- this.urlAutoAdvanceChecked = false, this.config = e3, this.log = new a.Log(e3), this.formOptionsConfig = { addButton: true, addSuccessScreen: true, getMetaData: true, customMetaData: [], questionFormat: "standard" }, this.selector = "", this.appId = t3, this.publicKey = i2 || "", this.url = e3.get("url"), this.id = "", this.formData = null, this.activeLang = null, this.feedback = { text: "", answers: [], profile: null != n2 ? n2 : [], metrics: [], metadata: null != r2 ? r2 : [] }, this.history = new f.History(), this.agentForm = null, this.graph = new p.PageGraph([]), this.progress = 0, this.total = 0, this.completed = false, this.sending = false, this.timeToCompleted = 0;
648
- }
649
- generate(e3, t3) {
650
- var i2, r2, a2, l2, d2, c2, u2;
651
- return n(this, void 0, void 0, (function* () {
652
- try {
653
- this.formOptionsConfig = Object.assign(Object.assign({}, this.formOptionsConfig), t3), this.selector = e3;
654
- let n2 = this.formData;
655
- const p2 = (0, v.detectSurveyLang)((null == t3 ? void 0 : t3.lang) || this.config.get("lang"));
656
- if (void 0 !== this.formData && this.formData || (n2 = "" !== this.publicKey ? yield (0, s.getForm)(this.url, this.appId, this.publicKey, this.log, p2) : yield (0, s.getSessionForm)(this.url, this.appId, this.log, p2)), void 0 === n2 || !n2) throw new Error(`No data for app ${this.appId}`);
657
- if (null === (i2 = n2.error) || void 0 === i2 ? void 0 : i2.message) throw new Error(n2.error.message);
658
- if ("AGENT" === n2.mode) return this.agentForm = new o.AgentForm(this.config, this.appId, this.publicKey), this.agentForm.applyIntegrationContext(n2), void (yield this.agentForm.generate(e3, t3));
659
- if (n2.questions = (null === (r2 = n2.questions) || void 0 === r2 ? void 0 : r2.filter(((e4) => "ACTIVE" === e4.status))) || [], n2.pages = (null === (a2 = n2.pages) || void 0 === a2 ? void 0 : a2.filter(((e4) => "ACTIVE" === e4.status))) || [], null === (l2 = n2.pages) || void 0 === l2 || l2.forEach(((e4) => {
660
- var t4;
661
- return e4.integrationQuestions = null === (t4 = e4.integrationQuestions) || void 0 === t4 ? void 0 : t4.filter(((e5) => "ACTIVE" === e5.status));
662
- })), this.formData = n2, this.activeLang = this.resolveActiveLang(p2), !this.formData.savedAt) {
663
- this.formData.savedAt = /* @__PURE__ */ new Date();
664
- try {
665
- localStorage.setItem(`magicfeedback-${this.appId}-${this.lang()}`, JSON.stringify(this.formData));
666
- } catch (e4) {
667
- this.log.log("Could not cache the form data", e4);
668
- }
669
- }
670
- if (void 0 === this.formData.questions || !this.formData.questions) throw new Error(`No questions for app ${this.appId}`);
671
- this.formData.pages && 0 !== (null === (d2 = this.formData.pages) || void 0 === d2 ? void 0 : d2.length) || this.formatPages(), null === (c2 = this.formData.questions) || void 0 === c2 || c2.sort(((e4, t4) => e4.position - t4.position)), this.formData.pages = this.formData.pages.filter(((e4) => {
672
- var t4;
673
- return (null === (t4 = e4.integrationQuestions) || void 0 === t4 ? void 0 : t4.length) > 0;
674
- })), this.formOptionsConfig.getMetaData && this.getMetaData(), (null === (u2 = this.formData.style) || void 0 === u2 ? void 0 : u2.startMessage) ? yield this.generateWelcomeMessage(this.formData.style.startMessage) : this.generateForm("open");
675
- } catch (e4) {
676
- return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 })));
677
- }
678
- }));
679
- }
680
- previewPage(e3, t3, i2 = {}) {
681
- var r2, o2, a2, s2, l2, d2, c2, u2, p2;
682
- return n(this, void 0, void 0, (function* () {
683
- try {
684
- if (!t3 || !t3.page) throw new Error("[MagicFeedback] No page provided for preview");
685
- if (!t3.page.integrationQuestions || 0 === t3.page.integrationQuestions.length) throw new Error("[MagicFeedback] No questions provided for preview");
686
- this.config.set("dryRun", true), this.formOptionsConfig = Object.assign(Object.assign(Object.assign({}, this.formOptionsConfig), { getMetaData: false }), i2), this.selector = e3;
687
- const n2 = (t3.page.integrationQuestions || []).filter(((e4) => !e4.status || "ACTIVE" === e4.status)).sort(((e4, t4) => e4.position - t4.position)), h2 = new m.Page(null !== (r2 = t3.page.id) && void 0 !== r2 ? r2 : "1", null !== (o2 = t3.page.position) && void 0 !== o2 ? o2 : 1, null !== (a2 = t3.appId) && void 0 !== a2 ? a2 : this.appId, n2, null !== (s2 = t3.page.integrationPageRoutes) && void 0 !== s2 ? s2 : []);
688
- this.formData = { id: null !== (l2 = t3.appId) && void 0 !== l2 ? l2 : this.appId, identity: null !== (d2 = t3.identity) && void 0 !== d2 ? d2 : "MAGICFORM", lang: [null !== (c2 = t3.lang) && void 0 !== c2 ? c2 : "en"], product: null !== (u2 = t3.product) && void 0 !== u2 ? u2 : { customIcons: false }, style: null !== (p2 = t3.style) && void 0 !== p2 ? p2 : {}, questions: n2, pages: [h2] }, yield this.generateForm();
689
- } catch (e4) {
690
- return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 })));
691
- }
692
- }));
693
- }
694
- formatPages() {
695
- var e3;
696
- if (this.formData) switch (this.formData.identity) {
697
- case "MAGICSURVEY":
698
- this.formData.pages = [], null === (e3 = this.formData.questions) || void 0 === e3 || e3.forEach(((e4) => {
699
- var t4, i2;
700
- const n2 = new h.PageRoute(e4.id, e4.ref, h.OperatorType.NOEQUAL, [], h.TransitionType.PAGE, (e4.position + 1).toString(), e4.position.toString()), r2 = new m.Page(e4.position.toString(), e4.position, this.appId, [e4], [n2]);
701
- null === (i2 = null === (t4 = this.formData) || void 0 === t4 ? void 0 : t4.pages) || void 0 === i2 || i2.push(r2);
702
- }));
703
- break;
704
- case "MAGICFORM":
705
- const t3 = new m.Page("1", 1, this.appId, this.formData.questions, []);
706
- this.formData.pages = [t3];
707
- }
708
- }
709
- generateContainer() {
710
- var e3, t3;
711
- const i2 = (0, c.generateContainer)(this.selector, this.appId), n2 = null === (t3 = null === (e3 = this.formData) || void 0 === e3 ? void 0 : e3.style) || void 0 === t3 ? void 0 : t3.primaryColor;
712
- return n2 && (0, c.applyPrimaryColor)(i2, n2), (0, c.applyDirection)(i2, this.lang()), i2;
713
- }
714
- generateForm(e3 = "open") {
715
- var t3, i2, r2;
716
- return n(this, void 0, void 0, (function* () {
717
- try {
718
- if (!this.formData || !this.formData.pages || 0 === this.formData.pages.length) throw new Error("No form data");
719
- this.graph = new p.PageGraph(this.formData.pages.sort(((e4, t4) => e4.position - t4.position)));
720
- let n2 = this.generateContainer();
721
- const o2 = document.createElement("form");
722
- o2.classList.add("magicfeedback-form"), o2.id = "magicfeedback-" + this.appId, o2.addEventListener("submit", ((e4) => e4.preventDefault()));
723
- const a2 = document.createElement("div");
724
- a2.classList.add("magicfeedback-questions"), a2.id = "magicfeedback-questions-" + this.appId;
725
- const s2 = this.graph.getFirstPage();
726
- if (!s2) throw new Error("No page found");
727
- if (this.total = this.graph.findMaxDepth(), s2.elements = (0, l.renderQuestions)(s2.questions, this.formOptionsConfig.questionFormat, this.lang(), null === (t3 = this.formData) || void 0 === t3 ? void 0 : t3.product, (() => this.autoSend())), null === (i2 = s2.elements) || void 0 === i2 || i2.forEach(((e4) => a2.appendChild(e4))), o2.appendChild(a2), (0, b.armGhostTapGuard)(a2), this.history.enqueue(s2), n2.appendChild(o2), this.progress = this.total - this.graph.findMaxDepth(s2), this.formOptionsConfig.addButton) {
728
- const e4 = (0, l.renderActions)(null === (r2 = this.formData) || void 0 === r2 ? void 0 : r2.identity, (() => this.back()), this.formOptionsConfig.sendButtonText || (0, y.t)(this.lang(), "action.send"), this.formOptionsConfig.backButtonText || (0, y.t)(this.lang(), "action.back"), this.formOptionsConfig.nextButtonText || (0, y.t)(this.lang(), "action.next"));
729
- o2.appendChild(e4), this.syncBackButton();
730
- }
731
- this.formOptionsConfig.addButton && o2.addEventListener("submit", ((e4) => {
732
- e4.preventDefault(), this.send();
733
- })), this.timeToCompleted = Date.now();
734
- const d2 = this.autoAdvanceFromUrl(a2, s2);
735
- if (d2 && (a2.style.visibility = "hidden"), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: d2, autoAdvancing: d2, progress: this.progress, total: this.total, formData: this.formData, lang: this.lang(), formOptionsConfig: this.formOptionsConfig })), d2) return void (yield this.autoSend());
736
- this.autofocusAfterRender(e3);
737
- } catch (e4) {
738
- return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 }));
739
- }
740
- }));
741
- }
742
- autoAdvanceFromUrl(e3, t3) {
743
- return !(this.urlAutoAdvanceChecked || (this.urlAutoAdvanceChecked = true, !(0, A.autoAdvanceRequested)() || 1 !== t3.questions.length || !(0, A.answeredInput)(e3, t3.questions[0].ref)));
744
- }
745
- startForm() {
746
- this.agentForm ? this.agentForm.startForm() : this.generateForm("navigation");
747
- }
748
- focusFirstQuestion() {
749
- return "undefined" != typeof document && (0, E.focusFirstTextQuestion)(document.getElementById("magicfeedback-questions-" + this.appId));
750
- }
751
- autofocusAfterRender(e3) {
752
- const t3 = this.formOptionsConfig.autofocus;
753
- t3 && ("open" === e3 && "always" !== t3 || this.focusFirstQuestion());
754
- }
755
- lang() {
756
- var e3;
757
- return this.activeLang || (null === (e3 = this.formData) || void 0 === e3 ? void 0 : e3.lang) && this.formData.lang[0] || "en";
758
- }
759
- getLang() {
760
- return this.lang();
761
- }
762
- resolveActiveLang(e3) {
763
- var t3, i2;
764
- const n2 = (null === (t3 = this.formData) || void 0 === t3 ? void 0 : t3.lang) || [];
765
- return (null === (i2 = this.formData) || void 0 === i2 ? void 0 : i2.servedLang) ? this.formData.servedLang : e3 && n2.includes(e3) ? e3 : n2[0] || null;
766
- }
767
- generateWelcomeMessage(e3) {
768
- return n(this, void 0, void 0, (function* () {
769
- try {
770
- const t3 = this.generateContainer(), i2 = (0, l.renderStartMessage)(e3, this.formOptionsConfig.addButton, this.formOptionsConfig.startButtonText || (0, y.t)(this.lang(), "action.start"), (() => this.startForm()));
771
- t3.appendChild(i2), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, formData: this.formData, lang: this.lang() }));
772
- } catch (e4) {
773
- return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 }));
774
- }
775
- }));
776
- }
777
- getMetaData() {
778
- 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] });
779
- const e3 = new URLSearchParams(window.location.search);
780
- Array.from(new Set(e3.keys())).forEach(((t3) => {
781
- const i2 = e3.getAll(t3);
782
- i2.length > 0 && this.feedback.metadata.push({ key: `query-${t3}`, value: i2 });
783
- })), 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] });
784
- }
785
- send(e3, t3, i2, o2) {
786
- var a2, s2;
787
- return n(this, void 0, void 0, (function* () {
788
- if (this.agentForm) return this.agentForm.next();
789
- const n2 = document.getElementById("magicfeedback-questions-" + this.appId);
790
- (0, A.cancelAutoAdvance)(n2), this.sending = true;
791
- try {
792
- if (i2 && (this.feedback.profile = [...this.feedback.profile, ...i2]), t3 && (this.feedback.metrics = [...this.feedback.metrics, ...t3]), e3 && (this.feedback.metadata = [...this.feedback.metadata, ...e3]), o2) {
793
- this.feedback.answers = [...this.feedback.answers, ...o2], this.formOptionsConfig.beforeSubmitEvent && (yield this.formOptionsConfig.beforeSubmitEvent({ loading: true, progress: this.progress, total: this.total }));
794
- const e4 = yield this.pushAnswers(false);
795
- if (!e4) throw new k.SubmitError("SEND_FAILED", "No response");
796
- return this.id = e4, void (this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total })));
797
- }
798
- yield (0, d.awaitUploadReady)(n2), this.answer(), this.formOptionsConfig.beforeSubmitEvent && (yield this.formOptionsConfig.beforeSubmitEvent({ loading: true, progress: this.progress, total: this.total }));
799
- const l2 = this.history.back();
800
- if (!l2) throw new k.SubmitError("NO_PAGE", "No page found");
801
- for (const e4 of l2.questions.filter(((e5) => e5.require && ![r.FEEDBACKAPPANSWERTYPE.CONSENT, r.FEEDBACKAPPANSWERTYPE.INFO_PAGE].includes(e5.type)))) {
802
- const t4 = e4.assets, i3 = this.feedback.answers.filter(((t5) => t5.key.includes(e4.ref) && !t5.key.includes("extra-option")));
803
- if (0 === i3.length || i3.find(((e5) => 0 === e5.value.length))) throw this.log.err(`The question ${e4.ref} is required`), new k.SubmitError("REQUIRED", "No response");
804
- if (null == t4 ? void 0 : t4.minOptions) {
805
- let n3 = [];
806
- if ((null == t4 ? void 0 : t4.exclusiveAnswers) && (n3 = null == t4 ? void 0 : t4.exclusiveAnswers), !i3[0].value.find(((e5) => n3.includes(e5))) && i3[0].value.length < (null == t4 ? void 0 : t4.minOptions)) throw this.log.err(`The question ${e4.ref} requires at least ${null == t4 ? void 0 : t4.minOptions} options`), new k.SubmitError("REQUIRED", "No response");
807
- }
808
- if (e4.type === r.FEEDBACKAPPANSWERTYPE.MAX_DIFF) {
809
- const t5 = null !== (s2 = null === (a2 = e4.assets) || void 0 === a2 ? void 0 : a2.setIndex) && void 0 !== s2 ? s2 : 1, i4 = this.parseMaxDiffAnswer(this.feedback.answers.find(((t6) => t6.key === e4.ref))).find(((e5) => e5.set === t5));
810
- if (!(null == i4 ? void 0 : i4.best) || !(null == i4 ? void 0 : i4.worst)) throw this.log.err(`The MaxDiff question ${e4.ref} requires the most and the least important`), new k.SubmitError("REQUIRED", "No response");
811
- }
812
- if (e4.type === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) {
813
- const i4 = this.feedback.answers.find(((t5) => t5.key === e4.ref));
814
- if (!i4) throw this.log.err(`The matrix question ${e4.ref} is required`), new k.SubmitError("REQUIRED", "No response");
815
- const n3 = this.parseMatrixAnswerPre(i4), r2 = Array.isArray(null == t4 ? void 0 : t4.options) ? t4.options : [];
816
- if (r2.length > 0) {
817
- if (r2.find(((e5) => {
818
- const t5 = n3.find(((t6) => t6.key === e5));
819
- return !t5 || !Array.isArray(t5.value) || 0 === t5.value.length;
820
- }))) throw this.log.err(`The matrix question ${e4.ref} requires an answer in every row`), new k.SubmitError("REQUIRED", "No response");
821
- } else if (0 === n3.length || n3.some(((e5) => !Array.isArray(e5.value) || 0 === e5.value.length))) throw this.log.err(`The matrix question ${e4.ref} requires an answer in every row`), new k.SubmitError("REQUIRED", "No response");
822
- }
823
- }
824
- const c2 = yield this.pushAnswers(false);
825
- if (!c2) throw new k.SubmitError("SEND_FAILED", "No response");
826
- this.id = c2, yield this.processNextQuestion(n2);
827
- } catch (e4) {
828
- this.log.err(`An error occurred while submitting the form ${this.appId}:`, e4), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total, error: e4 }));
829
- } finally {
830
- this.sending = false, null == n2 || n2.style.removeProperty("visibility");
831
- }
832
- }));
833
- }
834
- autoSend() {
835
- if (!this.sending) return this.send();
836
- }
837
- answer() {
838
- const e3 = "magicfeedback-" + this.appId, t3 = document.getElementById(e3);
839
- if (!t3) return this.log.err(`Form "${e3}" not found.`), this.feedback.answers = [], [];
840
- const i2 = this.history.back();
841
- if (!i2) return this.feedback.answers = (0, u.scrapeInputs)(t3), this.feedback.answers;
842
- const n2 = [];
843
- let o2 = false;
844
- const a2 = t3.querySelectorAll(".magicfeedback-input"), l2 = {}, c2 = {}, p2 = {}, m2 = {};
845
- if (a2.forEach(((e4) => {
846
- var t4, a3;
847
- const u2 = e4, h3 = i2.questions.find(((e5) => {
848
- var t5;
849
- return null === (t5 = u2.name) || void 0 === t5 ? void 0 : t5.includes(e5.ref);
850
- })), f2 = u2.type, g2 = u2.classList[0], y2 = { key: u2.name, value: [] }, v2 = "magicfeedback-consent" === g2 ? u2.checked.toString() : u2.value;
851
- if (y2.key && "" !== y2.key) if (y2.key.startsWith("extra-option-")) "" !== v2 && (y2.value.push(v2), n2.push(y2));
852
- else switch (null == h3 ? void 0 : h3.type) {
853
- case r.FEEDBACKAPPANSWERTYPE.EMAIL:
854
- case r.FEEDBACKAPPANSWERTYPE.TEXT:
855
- case r.FEEDBACKAPPANSWERTYPE.LONGTEXT:
856
- case r.FEEDBACKAPPANSWERTYPE.NUMBER:
857
- case r.FEEDBACKAPPANSWERTYPE.DATE:
858
- case r.FEEDBACKAPPANSWERTYPE.CONTACT:
859
- case r.FEEDBACKAPPANSWERTYPE.PASSWORD:
860
- "" !== v2 && ("email" === f2 ? (0, s.validateEmail)(v2) ? (this.feedback.profile.push({ key: "email", value: [v2] }), y2.value.push(v2), n2.push(y2)) : (this.log.err("Invalid email"), o2 = true) : (y2.value.push(v2), n2.push(y2)));
861
- break;
862
- case r.FEEDBACKAPPANSWERTYPE.RADIO:
863
- u2.checked && (y2.value.push(v2), n2.push(y2));
864
- break;
865
- case r.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE:
866
- case r.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE:
867
- u2.checked && (c2[y2.key] || (c2[y2.key] = []), c2[y2.key].push(v2));
868
- break;
869
- case r.FEEDBACKAPPANSWERTYPE.BOOLEAN:
870
- u2.checked && (y2.value.push(v2), n2.push(y2));
871
- break;
872
- case r.FEEDBACKAPPANSWERTYPE.CONSENT:
873
- y2.value.push(u2.checked.toString()), n2.push(y2);
874
- break;
875
- case r.FEEDBACKAPPANSWERTYPE.RATING_EMOJI:
876
- case r.FEEDBACKAPPANSWERTYPE.RATING_NUMBER:
877
- case r.FEEDBACKAPPANSWERTYPE.RATING_STAR:
878
- u2.checked && (y2.value.push(v2), n2.push(y2));
879
- break;
880
- case r.FEEDBACKAPPANSWERTYPE.SELECT:
881
- "" !== v2 && (y2.value.push(v2), n2.push(y2));
882
- break;
883
- case r.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM:
884
- "number" === f2 && u2.id && (p2[y2.key] || (p2[y2.key] = []), "" !== v2 && p2[y2.key].push(`${u2.id}:${v2}%`));
885
- break;
886
- case r.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST:
887
- "hidden" === f2 && (l2[y2.key] || (l2[y2.key] = []), l2[y2.key].push(v2));
888
- break;
889
- case r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX:
890
- e4.checked && (y2.value.push(v2), n2.push(y2));
891
- break;
892
- case r.FEEDBACKAPPANSWERTYPE.MAX_DIFF: {
893
- if ("radio" !== f2 || !h3) break;
894
- const e5 = y2.key === `${h3.ref}-best` ? "best" : y2.key === `${h3.ref}-worst` ? "worst" : null;
895
- if (!e5) break;
896
- m2[h3.ref] || (m2[h3.ref] = { set: null !== (a3 = null === (t4 = h3.assets) || void 0 === t4 ? void 0 : t4.setIndex) && void 0 !== a3 ? a3 : 1, shown: [], best: null, worst: null });
897
- const i3 = m2[h3.ref];
898
- "best" === e5 && i3.shown.push(v2), u2.checked && (i3[e5] = v2);
899
- break;
900
- }
901
- case r.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE:
902
- case r.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE: {
903
- const e5 = (0, d.getUploadValues)(u2);
904
- e5.length && (y2.value.push(...e5), n2.push(y2));
905
- break;
906
- }
907
- }
908
- })), o2) return [];
909
- Object.entries(c2).forEach((([e4, t4]) => {
910
- t4 && 0 !== t4.length && n2.push({ key: e4, value: t4 });
911
- })), Object.entries(p2).forEach((([e4, t4]) => {
912
- t4 && 0 !== t4.length && n2.push({ key: e4, value: t4 });
913
- })), Object.entries(l2).forEach((([e4, t4]) => {
914
- if (!t4 || 0 === t4.length) return;
915
- const i3 = t4.slice().sort(((e5, t5) => Number(e5.split(".")[0]) - Number(t5.split(".")[0])));
916
- n2.push({ key: e4, value: i3 });
917
- })), Object.entries(m2).forEach((([e4, t4]) => {
918
- (t4.best || t4.worst) && n2.push({ key: e4, value: [JSON.stringify([t4])] });
919
- }));
920
- try {
921
- i2.questions.filter(((e4) => e4.type === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX)).forEach(((e4) => {
922
- const t4 = e4.ref + "-", i3 = n2.filter(((e5) => e5.key.startsWith(t4)));
923
- if (0 === i3.length) return;
924
- const r2 = i3.map(((e5) => ({ key: e5.key.substring(t4.length), value: e5.value }))), o3 = { key: e4.ref, value: [JSON.stringify(r2)] };
925
- for (const e5 of i3) {
926
- const t5 = n2.findIndex(((t6) => t6.key === e5.key));
927
- -1 !== t5 && n2.splice(t5, 1);
928
- }
929
- const a3 = n2.findIndex(((t5) => t5.key === e4.ref));
930
- -1 !== a3 ? n2[a3] = o3 : n2.push(o3);
931
- }));
932
- } catch (e4) {
933
- this.log.err("Error agrupando MULTI_QUESTION_MATRIX", e4);
934
- }
935
- const h2 = this.withEarlierMaxDiffSets((0, v.toBaseAnswers)(n2, i2.questions), i2.questions);
936
- return this.feedback.answers = h2, i2.setAnswer(h2), h2;
937
- }
938
- withEarlierMaxDiffSets(e3, t3) {
939
- return e3.map(((e4) => {
940
- if (!t3.some(((t4) => t4.ref === e4.key && t4.type === r.FEEDBACKAPPANSWERTYPE.MAX_DIFF))) return e4;
941
- const i2 = this.parseMaxDiffAnswer(e4), n2 = [...this.parseMaxDiffAnswer(this.earlierAnswer(e4.key)).filter(((e5) => !i2.some(((t4) => t4.set === e5.set)))), ...i2].sort(((e5, t4) => e5.set - t4.set));
942
- return Object.assign(Object.assign({}, e4), { value: [JSON.stringify(n2)] });
943
- }));
944
- }
945
- earlierAnswer(e3) {
946
- var t3, i2;
947
- for (let n2 = this.history.size() - 2; n2 >= 0; n2--) {
948
- const r2 = null === (i2 = null === (t3 = this.history.get(n2)) || void 0 === t3 ? void 0 : t3.answers) || void 0 === i2 ? void 0 : i2.find(((t4) => t4.key === e3));
949
- if (r2) return r2;
950
- }
951
- }
952
- finish() {
953
- return n(this, void 0, void 0, (function* () {
954
- 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) {
955
- const e3 = document.getElementById("magicfeedback-container-" + this.appId);
956
- e3.childNodes.length > 0 && e3.removeChild(e3.childNodes[0]);
957
- const t3 = (0, l.renderSuccess)(this.formOptionsConfig.successMessage || (0, y.t)(this.lang(), "message.success"));
958
- e3.appendChild(t3);
959
- }
960
- this.feedback.answers = [];
961
- try {
962
- const e3 = yield this.pushAnswers(true);
963
- if (!e3) {
964
- const e4 = new k.SubmitError("SEND_FAILED", `An error occurred while submitting the form ${this.appId}:`);
965
- throw this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total, completed: this.completed, error: e4 })), e4;
966
- }
967
- this.id = e3, this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.id, loading: false, progress: this.progress, total: this.total, completed: this.completed, error: null }));
968
- } catch (e3) {
969
- this.log.err(`An error occurred while submitting the form ${this.appId}:`, e3), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ loading: false, progress: this.progress, total: this.total, completed: this.completed, error: e3 }));
970
- }
971
- }));
972
- }
973
- pushAnswers(e3 = false) {
974
- return n(this, void 0, void 0, (function* () {
975
- try {
976
- if (this.config.get("dryRun")) {
977
- const e4 = this.id || `dry-run-${this.appId}-${Date.now()}`;
978
- return this.log.log(`Dry run enabled: skipping feedback submit for form ${this.appId}`), e4;
979
- }
980
- const t3 = this.config.get("url"), i2 = { integration: this.appId, publicKey: this.publicKey, feedback: this.feedback, completed: e3, lang: this.lang() };
981
- return yield (0, s.sendFeedback)(t3, this.id ? Object.assign(Object.assign({}, i2), { sessionId: this.id }) : i2, this.log);
982
- } catch (e4) {
983
- return this.log.err(`An error occurred while submitting the form ${this.appId}:`, e4), "";
984
- }
985
- }));
986
- }
987
- callFollowUpQuestion(e3) {
988
- var t3, i2;
989
- return n(this, void 0, void 0, (function* () {
990
- if (!(null == e3 ? void 0 : e3.followup)) return null;
991
- const n2 = null !== (t3 = this.feedback.answers.find(((t4) => t4.key === e3.ref))) && void 0 !== t3 ? t3 : this.feedback.answers.find(((t4) => t4.key.includes(e3.ref) && !t4.key.includes("extra-option"))), r2 = null === (i2 = null == n2 ? void 0 : n2.value) || void 0 === i2 ? void 0 : i2.find(((e4) => null != e4 && "" !== e4));
992
- if (void 0 === r2) return this.log.log(`The question ${e3.ref} has no answer, skipping its follow up`), null;
993
- try {
994
- const t4 = this.config.get("url"), i3 = Object.assign(Object.assign(Object.assign({ answer: r2 }, "" !== this.publicKey && { publicKey: this.publicKey }), "" === this.publicKey && { campaignSessionId: this.appId }), { sessionId: this.id, question: e3, previousAnswers: this.previousAnswers(e3), upcomingQuestions: this.upcomingQuestions() });
995
- return yield (0, s.getFollowUpQuestion)(t4, i3, this.log);
996
- } catch (t4) {
997
- return this.log.err(`An error occurred while requesting the follow up of ${e3.ref} in the form ${this.appId}:`, t4), null;
998
- }
999
- }));
1000
- }
1001
- previousAnswers(e3) {
1002
- var t3;
1003
- const i2 = /* @__PURE__ */ new Map();
1004
- for (let n2 = 0; n2 < this.history.size(); n2++) {
1005
- const r2 = this.history.get(n2);
1006
- if (r2) for (const n3 of r2.questions) {
1007
- if (n3.ref === e3.ref) continue;
1008
- if (T.includes(n3.type)) continue;
1009
- const o2 = this.followUpAnswerValue(n3, null === (t3 = r2.answers) || void 0 === t3 ? void 0 : t3.find(((e4) => e4.key === n3.ref)));
1010
- void 0 !== o2 && (i2.delete(n3.ref), i2.set(n3.ref, { title: n3.title, answer: o2 }));
1011
- }
1012
- }
1013
- return [...i2.values()];
1014
- }
1015
- followUpAnswerValue(e3, t3) {
1016
- var i2;
1017
- const n2 = (null !== (i2 = null == t3 ? void 0 : t3.value) && void 0 !== i2 ? i2 : []).filter(((e4) => null != e4 && "" !== e4));
1018
- if (0 === n2.length) return;
1019
- if (e3.type === r.FEEDBACKAPPANSWERTYPE.BOOLEAN && 1 === n2.length && ["Yes", "No"].includes(n2[0])) return "Yes" === n2[0];
1020
- if (e3.type === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) {
1021
- const t4 = this.parseMatrixAnswerPre({ key: e3.ref, value: n2 }).map(((e4) => `${e4.key}: ${(Array.isArray(e4.value) ? e4.value : [e4.value]).join(", ")}`));
1022
- return t4.length > 0 ? t4 : void 0;
1023
- }
1024
- const o2 = n2.map(((e4) => "string" == typeof e4 ? e4 : JSON.stringify(e4)));
1025
- return 1 === o2.length ? o2[0] : o2;
1026
- }
1027
- upcomingQuestions() {
1028
- var e3, t3;
1029
- const i2 = this.history.back();
1030
- if (!i2) return [];
1031
- const n2 = [], o2 = /* @__PURE__ */ new Set(), a2 = /* @__PURE__ */ new Set();
1032
- let s2 = i2.isFollowup && i2.origin ? i2.origin : i2, l2 = null !== (e3 = s2.answers) && void 0 !== e3 ? e3 : [];
1033
- for (; !a2.has(s2.id); ) {
1034
- let e4;
1035
- if (a2.add(s2.id), l2) {
1036
- const i4 = this.graph.findRoute(s2, l2);
1037
- e4 = i4 ? i4.transition === h.TransitionType.PAGE && null !== (t3 = i4.transitionDestiny) && void 0 !== t3 ? t3 : void 0 : this.graph.getNextEdgeByDefault(s2);
1038
- } else {
1039
- if (s2.edges.some(((e5) => e5.typeCondition !== h.ConditionType.DIRECT && e5.typeCondition !== h.ConditionType.PRECONDITIONAL))) break;
1040
- e4 = this.graph.getNextEdgeByDefault(s2);
1041
- }
1042
- const i3 = e4 ? this.graph.getNodeById(e4) : void 0;
1043
- if (!i3) break;
1044
- if (i3.edges.filter(((e5) => e5.typeCondition === h.ConditionType.PRECONDITIONAL)).some(((e5) => !this.latestAnswer(e5.questionRef)))) break;
1045
- if (this.skipsByPreconditions(i3)) s2 = i3, l2 = [];
1046
- else {
1047
- for (const e5 of i3.questions) e5.type !== r.FEEDBACKAPPANSWERTYPE.INFO_PAGE && (o2.has(e5.ref) || (o2.add(e5.ref), n2.push({ title: e5.title })));
1048
- s2 = i3, l2 = null;
1049
- }
1050
- }
1051
- return n2;
1052
- }
1053
- processNextQuestion(e3) {
1054
- var t3, i2;
1055
- return n(this, void 0, void 0, (function* () {
1056
- const n2 = this.history.back();
1057
- if (!n2) throw new k.SubmitError("NO_PAGE", "No page found");
1058
- const r2 = n2.isFollowup ? [] : n2.getFollowupQuestions();
1059
- if (0 === (null == r2 ? void 0 : r2.length)) return void (yield this.renderNextQuestion(e3, n2));
1060
- const o2 = [];
1061
- for (const e4 of r2) {
1062
- const t4 = n2.questions.find(((t5) => t5.ref === e4));
1063
- if (t4) {
1064
- const e5 = yield this.callFollowUpQuestion(t4);
1065
- e5 && o2.push(e5);
1066
- }
1067
- }
1068
- if (0 === o2.length) return void (yield this.renderNextQuestion(e3, n2));
1069
- const a2 = new m.Page(n2.id, n2.position, this.appId, o2, n2.edges), s2 = new g.PageNode(n2.id, n2.position, n2.edges, a2, o2, true);
1070
- s2.origin = n2.isFollowup && n2.origin ? n2.origin : n2, s2.elements = (0, l.renderQuestions)(o2, this.formOptionsConfig.questionFormat, this.lang(), null === (t3 = this.formData) || void 0 === t3 ? void 0 : t3.product, (() => this.autoSend())), this.history.enqueue(s2), this.syncBackButton(), this.progress += 0.5, e3.innerHTML = "", null === (i2 = s2.elements) || void 0 === i2 || i2.forEach(((t4) => e3.appendChild(t4))), (0, b.armGhostTapGuard)(e3), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.id, loading: false, progress: this.progress, total: this.total, followup: s2.isFollowup, completed: this.completed, error: null })), this.autofocusAfterRender("navigation");
1071
- }));
1072
- }
1073
- renderNextQuestion(e3, t3) {
1074
- var i2, r2, o2;
1075
- return n(this, void 0, void 0, (function* () {
1076
- const n2 = t3.isFollowup && t3.origin ? t3.origin : t3, a2 = n2 === t3 ? this.feedback.answers : [...null !== (i2 = n2.answers) && void 0 !== i2 ? i2 : [], ...this.feedback.answers];
1077
- let s2 = this.graph.getNextPage(n2, a2);
1078
- if (s2) {
1079
- if (this.skipsByPreconditions(s2)) return this.feedback.answers = [], void (yield this.renderNextQuestion(e3, s2));
1080
- s2.elements = (0, l.renderQuestions)(s2.questions, this.formOptionsConfig.questionFormat, this.lang(), null === (r2 = this.formData) || void 0 === r2 ? void 0 : r2.product, (() => this.autoSend())), e3.innerHTML = "", null === (o2 = s2.elements) || void 0 === o2 || o2.forEach(((t4) => e3.appendChild(t4))), (0, b.armGhostTapGuard)(e3), this.history.enqueue(s2), this.syncBackButton(), this.progress = this.total - this.graph.findMaxDepth(s2), this.formOptionsConfig.afterSubmitEvent && (yield this.formOptionsConfig.afterSubmitEvent({ response: this.id, loading: false, progress: this.progress, total: this.total, followup: s2.isFollowup, completed: this.completed, error: null })), this.autofocusAfterRender("navigation");
1081
- } else this.finish();
1082
- }));
1083
- }
1084
- skipsByPreconditions(e3) {
1085
- var t3;
1086
- const i2 = e3.edges.filter(((e4) => "PRECONDITIONAL" === e4.typeCondition)).sort(((e4, t4) => e4.position < t4.position ? -1 : e4.position > t4.position ? 1 : 0));
1087
- if (0 === i2.length) return false;
1088
- const n2 = i2.some(((e4) => e4.transition === h.TransitionType.ALLOW));
1089
- let o2 = n2;
1090
- for (const e4 of i2) {
1091
- const i3 = this.latestAnswer(e4.questionRef);
1092
- let n3 = false;
1093
- if (i3) {
1094
- const o3 = null === (t3 = this.formData) || void 0 === t3 ? void 0 : t3.questions.find(((t4) => t4.ref === e4.questionRef)), a2 = Array.isArray(i3.value) ? i3.value : [i3.value], s2 = Array.isArray(e4.value) ? e4.value : [e4.value];
1095
- if ((null == o3 ? void 0 : o3.type) === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) n3 = this.evaluateMatrixPreconditional(e4, i3);
1096
- else switch (e4.typeOperator) {
1097
- case "EQUAL":
1098
- case "INQ":
1099
- n3 = a2.some(((e5) => s2.includes(e5)));
1100
- break;
1101
- case "NOEQUAL":
1102
- case "NINQ":
1103
- n3 = a2.every(((e5) => !s2.includes(e5)));
1104
- break;
1105
- case "GREATER":
1106
- n3 = a2.some(((e5) => Number(e5) > Number(s2[0])));
1107
- break;
1108
- case "LESS":
1109
- n3 = a2.some(((e5) => Number(e5) < Number(s2[0])));
1110
- break;
1111
- case "GREATEREQUAL":
1112
- n3 = a2.some(((e5) => Number(e5) >= Number(s2[0])));
1113
- break;
1114
- case "LESSEQUAL":
1115
- n3 = a2.some(((e5) => Number(e5) <= Number(s2[0])));
1116
- }
1117
- }
1118
- if (e4.transition === h.TransitionType.ALLOW) n3 || (o2 = false);
1119
- else if (e4.transition === h.TransitionType.NEXT && n3) return true;
1120
- }
1121
- return !!n2 && !o2;
1122
- }
1123
- latestAnswer(e3) {
1124
- var t3, i2;
1125
- for (let n2 = this.history.size() - 1; n2 >= 0; n2--) {
1126
- const r2 = null === (i2 = null === (t3 = this.history.get(n2)) || void 0 === t3 ? void 0 : t3.answers) || void 0 === i2 ? void 0 : i2.find(((t4) => t4.key === e3));
1127
- if (r2) return r2;
1128
- }
1129
- }
1130
- syncBackButton() {
1131
- const e3 = document.getElementById("magicfeedback-" + this.appId), t3 = null == e3 ? void 0 : e3.querySelector(".magicfeedback-back");
1132
- t3 && (t3.hidden = this.history.size() <= 1);
1133
- }
1134
- back() {
1135
- var e3;
1136
- return n(this, void 0, void 0, (function* () {
1137
- if (this.history.size() <= 1) return;
1138
- const t3 = document.getElementById("magicfeedback-questions-" + this.appId);
1139
- (0, A.cancelAutoAdvance)(t3), t3 && t3.childNodes.length > 0 && (t3.innerHTML = ""), this.history.rollback(), this.syncBackButton();
1140
- const i2 = this.history.back();
1141
- i2 ? (null === (e3 = i2.elements) || void 0 === e3 || e3.forEach(((e4) => t3.appendChild(e4))), (0, b.armGhostTapGuard)(t3), this.progress = this.total - this.graph.findMaxDepth(i2)) : this.progress = this.history.size(), this.formOptionsConfig.onBackEvent && (yield this.formOptionsConfig.onBackEvent({ loading: false, progress: this.progress, followup: (null == i2 ? void 0 : i2.isFollowup) || false, error: i2 ? null : "No page found" })), i2 && this.autofocusAfterRender("navigation");
1142
- }));
1143
- }
1144
- previewQuestion(e3, t3, i2) {
1145
- var n2, r2;
1146
- const o2 = Array.isArray(t3) ? t3 : [t3];
1147
- if (!o2 || 0 === o2.length) throw new Error("[MagicFeedback] No question provided for preview");
1148
- const a2 = document.getElementById(e3);
1149
- if (!a2) throw new Error(`[MagicFeedback] Element with ID '${e3}' not found.`);
1150
- const { format: s2 = this.formOptionsConfig.questionFormat || "standard", language: d2 = this.lang(), product: u2 = (null === (n2 = this.formData) || void 0 === n2 ? void 0 : n2.product) || { customIcons: false }, style: p2 = (null === (r2 = this.formData) || void 0 === r2 ? void 0 : r2.style) || {}, clearContainer: m2 = true, wrap: h2 = true } = i2 || {};
1151
- m2 && (a2.innerHTML = ""), (null == p2 ? void 0 : p2.primaryColor) && (0, c.applyPrimaryColor)(a2, p2.primaryColor), (0, c.applyDirection)(a2, d2);
1152
- let f2 = [];
1153
- try {
1154
- f2 = (0, l.renderQuestions)(o2, s2, d2, u2);
1155
- } catch (e4) {
1156
- throw this.log.err(e4), e4;
1157
- }
1158
- let g2 = a2;
1159
- if (h2) {
1160
- const e4 = document.createElement("div");
1161
- e4.classList.add("magicfeedback-preview-question"), g2.appendChild(e4), g2 = e4;
1162
- }
1163
- return f2.forEach(((e4) => g2.appendChild(e4))), a2;
1164
- }
1165
- parseMaxDiffAnswer(e3) {
1166
- var t3;
1167
- if (!e3 || "string" != typeof (null === (t3 = e3.value) || void 0 === t3 ? void 0 : t3[0])) return [];
1168
- try {
1169
- const t4 = JSON.parse(e3.value[0]);
1170
- return Array.isArray(t4) ? t4 : [];
1171
- } catch (e4) {
1172
- return [];
1173
- }
1174
- }
1175
- parseMatrixAnswerPre(e3) {
1176
- if (!e3 || !e3.value) return [];
1177
- if (1 === e3.value.length && "string" == typeof e3.value[0] && e3.value[0].trim().startsWith("[")) try {
1178
- const t3 = JSON.parse(e3.value[0]);
1179
- if (Array.isArray(t3)) return t3;
1180
- } catch (e4) {
1181
- return [];
1182
- }
1183
- 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 : [];
1184
- }
1185
- evaluateMatrixPreconditional(e3, t3) {
1186
- const i2 = Array.isArray(e3.value) ? e3.value : [e3.value], n2 = new Set(e3.option || []), r2 = this.parseMatrixAnswerPre(t3);
1187
- if (!r2.length) return false;
1188
- const o2 = n2.size > 0 ? r2.filter(((e4) => n2.has(e4.key))) : r2;
1189
- if (!o2.length) return false;
1190
- switch (e3.typeOperator) {
1191
- case "EQUAL":
1192
- case "INQ":
1193
- return o2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.includes(e5)))));
1194
- case "NOEQUAL":
1195
- case "NINQ":
1196
- return o2.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !i2.includes(e5)))));
1197
- case "GREATER":
1198
- return o2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) > Number(t4)))))));
1199
- case "LESS":
1200
- return o2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) < Number(t4)))))));
1201
- case "GREATEREQUAL":
1202
- return o2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) >= Number(t4)))))));
1203
- case "LESSEQUAL":
1204
- return o2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) <= Number(t4)))))));
1205
- default:
1206
- return false;
1207
- }
1208
- }
1209
- };
1210
- }, 3378: (e2, t2) => {
1211
- "use strict";
1212
- Object.defineProperty(t2, "__esModule", { value: true }), t2.Page = void 0, t2.Page = class {
1213
- constructor(e3, t3, i, n, r) {
1214
- 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;
1215
- }
1216
- };
1217
- }, 1719: (e2, t2, i) => {
1218
- "use strict";
1219
- Object.defineProperty(t2, "__esModule", { value: true }), t2.PageGraph = void 0;
1220
- const n = i(7170), r = i(4760), o = i(7305);
1221
- t2.PageGraph = class {
1222
- constructor(e3) {
1223
- this.nodes = /* @__PURE__ */ new Map(), this.buildGraph(e3);
1224
- }
1225
- buildGraph(e3) {
1226
- e3.forEach(((e4) => {
1227
- var t3;
1228
- e4.integrationPageRoutes && (e4.integrationPageRoutes = (null === (t3 = e4.integrationPageRoutes) || void 0 === t3 ? void 0 : t3.sort(((e5, t4) => {
1229
- const i3 = new Date((null == e5 ? void 0 : e5.generatedAt) || 0).getTime(), n2 = new Date((null == t4 ? void 0 : t4.generatedAt) || 0).getTime();
1230
- return i3 !== n2 ? i3 - n2 : "DIRECT" === e5.typeCondition && "DIRECT" !== t4.typeCondition ? 1 : "DIRECT" !== e5.typeCondition && "DIRECT" === t4.typeCondition ? -1 : 0;
1231
- }))) || []);
1232
- const i2 = new n.PageNode(e4.id, e4.position, e4.integrationPageRoutes || [], e4, e4.integrationQuestions);
1233
- this.nodes.set(i2.id, i2);
1234
- }));
1235
- }
1236
- getNodeById(e3) {
1237
- return this.nodes.get(e3);
1238
- }
1239
- getNextEdgeByDefault(e3) {
1240
- if (!e3) return;
1241
- const t3 = e3.edges.find(((e4) => e4.typeCondition === o.ConditionType.DIRECT));
1242
- if (!t3 || ![o.TransitionType.FINISH, o.TransitionType.REDIRECT].includes(t3.transition)) {
1243
- if (t3 && t3.transitionDestiny) return t3.transitionDestiny;
1244
- for (const t4 of this.nodes.values()) if (t4.position === e3.position + 1) return t4.id;
1245
- }
1246
- }
1247
- getFirstPage() {
1248
- let e3, t3 = Number.MAX_VALUE;
1249
- for (const i2 of this.nodes.values()) i2.position < t3 && (t3 = i2.position, e3 = i2);
1250
- return e3;
1251
- }
1252
- getNextPage(e3, t3) {
1253
- var i2;
1254
- if (!e3) return;
1255
- const n2 = this.findRoute(e3, t3);
1256
- if (!n2) {
1257
- const t4 = this.getNextEdgeByDefault(e3);
1258
- if (!t4) return;
1259
- return this.getNodeById(t4);
1260
- }
1261
- switch (n2.transition) {
1262
- case o.TransitionType.PAGE:
1263
- if (!n2.transitionDestiny) return;
1264
- return this.getNodeById(n2.transitionDestiny);
1265
- case o.TransitionType.FINISH:
1266
- return;
1267
- case o.TransitionType.REDIRECT:
1268
- return void (window.location.href = (null === (i2 = n2.transitionDestiny) || void 0 === i2 ? void 0 : i2.includes("?")) ? `${n2.transitionDestiny}&${window.location.search.slice(1)}` : `${n2.transitionDestiny}${window.location.search}`);
1269
- default:
1270
- return;
1271
- }
1272
- }
1273
- findRoute(e3, t3) {
1274
- return e3.edges.sort(((e4, t4) => "DIRECT" === e4.typeCondition ? 1 : "DIRECT" === t4.typeCondition ? -1 : 0)), e3.edges.find(((i2) => {
1275
- const n2 = e3.questions.find(((e4) => e4.ref === i2.questionRef)), a = null == t3 ? void 0 : t3.filter(((e4) => e4.key === i2.questionRef));
1276
- if ("DIRECT" === i2.typeCondition) return true;
1277
- if (!a || 0 === a.length) return false;
1278
- if ((null == n2 ? void 0 : n2.type) === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) return this.evaluateMatrixCondition(i2, a);
1279
- const s = Array.isArray(i2.value) ? i2.value : [i2.value];
1280
- switch (i2.typeOperator) {
1281
- case o.OperatorType.EQUAL:
1282
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => s.includes(e5)))));
1283
- case o.OperatorType.NOEQUAL:
1284
- return a.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !s.includes(e5)))));
1285
- case o.OperatorType.GREATER:
1286
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => s.some(((t4) => Number(e5) > Number(t4)))))));
1287
- case o.OperatorType.LESS:
1288
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => s.some(((t4) => Number(e5) < Number(t4)))))));
1289
- case o.OperatorType.GREATEREQUAL:
1290
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => s.some(((t4) => Number(e5) >= Number(t4)))))));
1291
- case o.OperatorType.LESSEQUAL:
1292
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => s.some(((t4) => Number(e5) <= Number(t4)))))));
1293
- case o.OperatorType.INQ:
1294
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => s.includes(e5)))));
1295
- case o.OperatorType.NINQ:
1296
- return a.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !s.includes(e5)))));
1297
- default:
1298
- return false;
1299
- }
1300
- }));
1301
- }
1302
- findDepth(e3) {
1303
- const t3 = this.getNodeById(e3);
1304
- if (!t3) return 0;
1305
- const i2 = /* @__PURE__ */ new Set();
1306
- return this.DFSUtil(t3, i2, 0);
1307
- }
1308
- findMaxDepth(e3) {
1309
- if (e3 || (e3 = this.getFirstPage()), !e3) return 0;
1310
- const t3 = /* @__PURE__ */ new Set();
1311
- let i2 = 1;
1312
- return i2 = Math.max(i2, this.DFSUtil(e3, t3, i2)), i2;
1313
- }
1314
- DFSUtil(e3, t3, i2) {
1315
- t3.add(e3);
1316
- let n2 = i2;
1317
- const r2 = [...e3.edges.filter(((e4) => e4.typeCondition !== o.ConditionType.PRECONDITIONAL)) || []], a = this.getNextEdgeByDefault(e3);
1318
- if (a) {
1319
- const i3 = this.getNodeById(a);
1320
- i3 && !t3.has(i3) && r2.push(new o.PageRoute(i3.id, "", o.OperatorType.DEFAULT, [""], o.TransitionType.PAGE, i3.id, e3.id));
1321
- }
1322
- for (const e4 of r2) {
1323
- if (!e4.transitionDestiny) continue;
1324
- const r3 = this.getNodeById(e4.transitionDestiny);
1325
- if (r3 && !t3.has(r3)) {
1326
- const e5 = i2 + 1, o2 = new Set(t3), a2 = this.DFSUtil(r3, o2, e5);
1327
- n2 = Math.max(n2, a2);
1328
- }
1329
- }
1330
- return n2;
1331
- }
1332
- parseMatrixAnswer(e3) {
1333
- if (!e3 || !e3.value) return [];
1334
- if (1 === e3.value.length && "string" == typeof e3.value[0] && e3.value[0].trim().startsWith("[")) try {
1335
- const t3 = JSON.parse(e3.value[0]);
1336
- if (Array.isArray(t3)) return t3;
1337
- } catch (e4) {
1338
- return [];
1339
- }
1340
- 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 : [];
1341
- }
1342
- evaluateMatrixCondition(e3, t3) {
1343
- const i2 = Array.isArray(e3.value) ? e3.value : [e3.value], n2 = new Set(e3.option || []), r2 = t3[0], a = this.parseMatrixAnswer(r2);
1344
- if (!a.length) return false;
1345
- const s = n2.size > 0 ? a.filter(((e4) => n2.has(e4.key))) : a;
1346
- if (!s.length) return false;
1347
- switch (e3.typeOperator) {
1348
- case o.OperatorType.EQUAL:
1349
- case o.OperatorType.INQ:
1350
- return s.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.includes(e5)))));
1351
- case o.OperatorType.NOEQUAL:
1352
- case o.OperatorType.NINQ:
1353
- return s.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !i2.includes(e5)))));
1354
- case o.OperatorType.GREATER:
1355
- return s.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) > Number(t4)))))));
1356
- case o.OperatorType.LESS:
1357
- return s.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) < Number(t4)))))));
1358
- case o.OperatorType.GREATEREQUAL:
1359
- return s.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) >= Number(t4)))))));
1360
- case o.OperatorType.LESSEQUAL:
1361
- return s.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) <= Number(t4)))))));
1362
- default:
1363
- return false;
1364
- }
1365
- }
1366
- };
1367
- }, 7170: (e2, t2) => {
1368
- "use strict";
1369
- Object.defineProperty(t2, "__esModule", { value: true }), t2.PageNode = void 0, t2.PageNode = class {
1370
- constructor(e3, t3, i, n, r, o = false) {
1371
- 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 = o;
1372
- }
1373
- getFollowupQuestions() {
1374
- return this.questions.filter(((e3) => e3.followup)).map(((e3) => e3.ref));
1375
- }
1376
- getRequiredQuestions() {
1377
- return this.questions.filter(((e3) => e3.require)).map(((e3) => e3.ref));
1378
- }
1379
- setAnswer(e3) {
1380
- this.answers = e3;
1381
- }
1382
- };
1383
- }, 7305: (e2, t2) => {
1384
- "use strict";
1385
- var i, n, r, o;
1386
- Object.defineProperty(t2, "__esModule", { value: true }), t2.PageRoute = t2.StatusType = t2.OperatorType = t2.ConditionType = t2.TransitionType = void 0, (o = t2.TransitionType || (t2.TransitionType = {})).PAGE = "PAGE", o.FINISH = "FINISH", o.REDIRECT = "REDIRECT", o.NEXT = "NEXT", o.ALLOW = "ALLOW", (function(e3) {
1387
- e3.LOGICAL = "LOGICAL", e3.DIRECT = "DIRECT", e3.PRECONDITIONAL = "PRECONDITIONAL";
1388
- })(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) {
1389
- e3.ACTIVE = "ACTIVE", e3.DEPRECATED = "DEPRECATED", e3.DELETE = "DELETE";
1390
- })(n = t2.StatusType || (t2.StatusType = {})), t2.PageRoute = class {
1391
- constructor(e3, t3, r2, o2, a, s, l, d, c, u) {
1392
- this.id = e3, this.questionRef = t3, this.typeCondition = d || i.LOGICAL, this.typeOperator = r2, this.value = o2 || [], this.transition = a, this.transitionDestiny = s, this.status = n.ACTIVE, this.generatedAt = /* @__PURE__ */ new Date(), this.updatedAt = /* @__PURE__ */ new Date(), this.integrationPageId = l, this.position = c || 0, this.option = u || [];
1393
- }
1394
- };
1395
- }, 4760: (e2, t2) => {
1396
- "use strict";
1397
- var i, n;
1398
- Object.defineProperty(t2, "__esModule", { value: true }), t2.AGENT_ANSWER_TYPE_BLOCKED = t2.QuestionType = t2.FEEDBACKAPPANSWERTYPE = void 0, (n = t2.FEEDBACKAPPANSWERTYPE || (t2.FEEDBACKAPPANSWERTYPE = {})).CONTACT = "CONTACT", n.MULTIPLECHOISE_IMAGE = "MULTIPLECHOISE_IMAGE", n.EMAIL = "EMAIL", n.RATING_STAR = "RATING_STAR", n.RADIO = "RADIO", n.MULTIPLECHOICE = "MULTIPLECHOICE", n.SELECT = "SELECT", n.TEXT = "TEXT", n.LONGTEXT = "LONGTEXT", n.NUMBER = "NUMBER", n.RATING_EMOJI = "RATING_EMOJI", n.RATING_NUMBER = "RATING_NUMBER", n.DATE = "DATE", n.BOOLEAN = "BOOLEAN", n.PASSWORD = "PASSWORD", n.CONSENT = "CONSENT", n.MULTI_QUESTION_MATRIX = "MULTI_QUESTION_MATRIX", n.POINT_SYSTEM = "POINT_SYSTEM", n.PRIORITY_LIST = "PRIORITY_LIST", n.INFO_PAGE = "INFO_PAGE", n.UPLOAD_FILE = "UPLOAD_FILE", n.UPLOAD_IMAGE = "UPLOAD_IMAGE", n.MAX_DIFF = "MAX_DIFF", t2.QuestionType = class {
1399
- }, t2.AGENT_ANSWER_TYPE_BLOCKED = "ABUSIVE_OR_OFFENSIVE", (function(e3) {
1400
- e3.FORM = "form", e3.DIV = "div";
1401
- })(i || (i = {}));
1402
- }, 2335: (e2, t2, i) => {
1403
- "use strict";
1404
- Object.defineProperty(t2, "__esModule", { value: true }), t2.applyDirection = t2.applyPrimaryColor = t2.generateContainer = void 0;
1405
- const n = i(7627);
1406
- t2.generateContainer = function(e3, t3) {
1407
- let i2 = document.getElementById(e3);
1408
- if (!i2 && (i2 = document.getElementById("magicfeedback-container-" + t3), !i2)) throw new Error(`Element with ID '${e3}' not found.`);
1409
- return i2.classList.add("magicfeedback-container"), i2.id = "magicfeedback-container-" + t3, i2.innerHTML = "", i2;
1410
- }, t2.applyPrimaryColor = function(e3, t3) {
1411
- e3.style.setProperty("--mf-primary", t3), e3.style.setProperty("--mf-primary-hover", `color-mix(in srgb, ${t3} 85%, black)`), e3.style.setProperty("--mf-primary-light", `color-mix(in srgb, ${t3} 15%, white)`), e3.style.setProperty("--mf-primary-border", `color-mix(in srgb, ${t3} 35%, transparent)`), e3.style.setProperty("--mf-border-focus", t3);
1412
- }, t2.applyDirection = function(e3, t3) {
1413
- const i2 = (0, n.isRtlLanguage)(t3);
1414
- e3.setAttribute("dir", i2 ? "rtl" : "ltr"), e3.classList.toggle("magicfeedback-rtl", i2);
1415
- };
1416
- }, 1366: (e2, t2, i) => {
1417
- "use strict";
1418
- Object.defineProperty(t2, "__esModule", { value: true }), t2.getUrlParam = t2.getBooleanOptions = t2.parseTitle = void 0;
1419
- const n = i(7627);
1420
- t2.parseTitle = function(e3, t3) {
1421
- return e3 ? "object" == typeof e3 ? e3[t3] || e3.en : e3 : "";
1422
- }, t2.getBooleanOptions = function(e3) {
1423
- return [(0, n.t)(e3, "boolean.yes"), (0, n.t)(e3, "boolean.no")];
1424
- }, t2.getUrlParam = function(e3) {
1425
- return new URLSearchParams(window.location.search).get(e3);
1426
- };
1427
- }, 2709: (e2, t2, i) => {
1428
- "use strict";
1429
- Object.defineProperty(t2, "__esModule", { value: true }), t2.RATING_NUMBER_MIN_CAPTIONED_WIDTH = t2.RATING_NUMBER_MIN_CHIP_WIDTH = t2.usesLegacyRatingNumber = t2.createRatingNumberElement = t2.createStarRating = t2.createRatingPlaceholder = void 0;
1430
- const n = i(7627), r = i(9039);
1431
- function o(e3, t3, i2 = "ltr") {
1432
- const n2 = document.createElement("div");
1433
- n2.classList.add("magicfeedback-rating-placeholder");
1434
- const r2 = document.createElement("span");
1435
- r2.textContent = null != e3 ? e3 : "", r2.classList.add("magicfeedback-rating-placeholder-value");
1436
- const o2 = document.createElement("span");
1437
- return o2.textContent = null != t3 ? t3 : "", o2.classList.add("magicfeedback-rating-placeholder-value"), "ltr" === i2 ? (e3 && n2.appendChild(r2), t3 && n2.appendChild(o2)) : (t3 && n2.appendChild(o2), e3 && n2.appendChild(r2)), n2;
1438
- }
1439
- t2.createRatingPlaceholder = o, t2.createStarRating = function(e3, t3, i2, n2 = () => {
1440
- }, a) {
1441
- const s = document.createElement("div");
1442
- s.classList.add("magicfeedback-rating-star-container"), s.style.maxWidth = "300px", s.style.margin = "auto", s.dataset.originalSelection = "0";
1443
- const l = (e4) => {
1444
- s.querySelectorAll(".rating__star").forEach(((t4, i3) => {
1445
- t4.classList.toggle("magicfeedback-rating-star-selected", i3 < e4);
1446
- }));
1447
- };
1448
- for (let t4 = 1; t4 <= 5; t4++) {
1449
- const i3 = document.createElement("label");
1450
- i3.classList.add("magicfeedback-rating-star-option");
1451
- const o2 = document.createElement("input");
1452
- o2.id = `rating-${e3}-${t4}`, o2.type = "radio", o2.name = e3, o2.value = t4.toString(), o2.style.position = "absolute", o2.style.opacity = "0", o2.style.width = "0", o2.style.height = "0", o2.classList.add("magicfeedback-input"), a && a === o2.value && (o2.checked = true), o2.addEventListener("change", (() => {
1453
- l(Number(o2.value)), s.dataset.originalSelection = o2.value;
1454
- })), (0, r.autoAdvanceOn)(o2, n2), i3.appendChild(o2);
1455
- const d2 = document.createElement("label");
1456
- d2.htmlFor = `rating-${e3}-${t4}`, d2.classList.add("rating__star"), d2.textContent = "\u2605", d2.style.fontSize = "40px", d2.style.color = "#CCCCCC", d2.style.cursor = "pointer", d2.addEventListener("mouseenter", (() => l(t4))), d2.addEventListener("mouseleave", (() => l(Number(s.dataset.originalSelection || "0")))), i3.appendChild(d2), s.appendChild(i3);
1457
- }
1458
- const d = s.querySelector("input:checked");
1459
- d && (s.dataset.originalSelection = d.value, l(Number(d.value)));
1460
- const c = o(t3, i2);
1461
- return c.childElementCount > 0 && s.appendChild(c), s;
1462
- }, t2.createRatingNumberElement = function(e3, i2, o2, a, s, l, d, c, u = {}) {
1463
- var p, m;
1464
- const h = document.createElement("div");
1465
- h.classList.add("magicfeedback-rating-number");
1466
- const f = !!u.legacy, g = f && !!u.isPhone, y = g ? (function(e4) {
1467
- const t3 = (null == e4 ? void 0 : e4.max) ? Number(e4.max) : 10, i3 = (null == e4 ? void 0 : e4.min) ? Number(e4.min) : 0;
1468
- return (n2) => {
1469
- var r2;
1470
- return (null === (r2 = null == e4 ? void 0 : e4.numberPlaceholders) || void 0 === r2 ? void 0 : r2[n2]) || (n2 === i3 ? null == e4 ? void 0 : e4.minPlaceholder : void 0) || (n2 === t3 ? null == e4 ? void 0 : e4.maxPlaceholder : void 0) || void 0;
1471
- };
1472
- })(i2) : null;
1473
- g && (a = "column", i2 = Object.assign(Object.assign({}, i2), { minPlaceholder: void 0, maxPlaceholder: void 0, numberPlaceholders: void 0 })), f && h.classList.add("magicfeedback-rating-number--legacy");
1474
- const v = "column" === a, b = "ltr" === o2 ? a : `${a}-reverse`, E = document.createElement("div");
1475
- E.classList.add("magicfeedback-rating-number-container"), E.classList.add(`magicfeedback-rating-number-container-${o2}`), E.classList.add(`magicfeedback-rating-number-container-${a}`), E.style.display = "flex", E.style.flexDirection = b, E.setAttribute("role", "radiogroup"), E.setAttribute("aria-label", (null == i2 ? void 0 : i2.ariaLabel) || (0, n.t)(c, "rating.ariaLabel"));
1476
- const A = (null == i2 ? void 0 : i2.max) ? Number(null == i2 ? void 0 : i2.max) : 10, k = (null == i2 ? void 0 : i2.min) ? Number(null == i2 ? void 0 : i2.min) : 0;
1477
- !v && A - k + 1 > 6 && E.classList.add("magicfeedback-rating-number-container-row--dense");
1478
- const T = (null == i2 ? void 0 : i2.numberPlaceholders) || null, C = !(!T || !Object.keys(T).length), P = !v && !f && !!T && Object.values(T).some(((e4) => !!e4)), S = "bottom" === (null == i2 ? void 0 : i2.numberPlaceholdersPosition) ? "bottom" : "top";
1479
- P && (E.style.alignItems = "stretch");
1480
- let w = null;
1481
- if (!v && !P && ((null == i2 ? void 0 : i2.minPlaceholder) || (null == i2 ? void 0 : i2.maxPlaceholder))) {
1482
- w = document.createElement("div"), w.classList.add("magicfeedback-rating-number-scale-labels");
1483
- const e4 = document.createElement("span");
1484
- e4.classList.add("magicfeedback-rating-number-scale-label"), e4.textContent = null !== (p = null == i2 ? void 0 : i2.minPlaceholder) && void 0 !== p ? p : "";
1485
- const t3 = document.createElement("span");
1486
- t3.classList.add("magicfeedback-rating-number-scale-label"), t3.textContent = null !== (m = null == i2 ? void 0 : i2.maxPlaceholder) && void 0 !== m ? m : "", "ltr" === o2 ? (w.appendChild(e4), w.appendChild(t3)) : (w.appendChild(t3), w.appendChild(e4));
1487
- }
1488
- let O = null;
1489
- if (v && !C && E.classList.add("magicfeedback-rating-number-container-column--bare"), (v ? !C : !P) && ((null == i2 ? void 0 : i2.minPlaceholder) || (null == i2 ? void 0 : i2.maxPlaceholder))) {
1490
- const e4 = "ltr" === o2 ? null == i2 ? void 0 : i2.minPlaceholder : null == i2 ? void 0 : i2.maxPlaceholder, t3 = "ltr" === o2 ? null == i2 ? void 0 : i2.maxPlaceholder : null == i2 ? void 0 : i2.minPlaceholder, n2 = (e5) => {
1491
- const t4 = document.createElement("div");
1492
- return t4.classList.add("magicfeedback-rating-number-scale-label-block"), v || (t4.classList.add("magicfeedback-rating-number-scale-label-block--stacked"), t4.style.display = "none"), t4.textContent = e5, t4;
1493
- };
1494
- e4 && h.appendChild(n2(e4)), t3 && (O = n2(t3));
1495
- }
1496
- for (let t3 = k; t3 <= A; t3++) {
1497
- const n2 = document.createElement("div");
1498
- n2.classList.add("magicfeedback-rating-number-option"), n2.classList.add(`magicfeedback-rating-number-option-${a}`);
1499
- const o3 = document.createElement("label");
1500
- o3.htmlFor = `rating-${e3}-${t3}`, o3.classList.add("magicfeedback-rating-number-option-label-container");
1501
- const c2 = C && (T[t3] || (t3 === k ? null == i2 ? void 0 : i2.minPlaceholder : void 0) || (t3 === A ? null == i2 ? void 0 : i2.maxPlaceholder : void 0)), u2 = document.createElement("input");
1502
- u2.id = `rating-${e3}-${t3}`, u2.type = "radio", u2.name = e3, u2.value = t3.toString(), u2.classList.add(s), u2.classList.add("magicfeedback-input");
1503
- const p2 = null == y ? void 0 : y(t3);
1504
- u2.setAttribute("aria-label", c2 ? `${t3} \u2014 ${c2}` : p2 ? `${t3} \u2014 ${p2}` : `${t3}`), (0, r.autoAdvanceOn)(u2, l), d && d === u2.value && (u2.checked = true), o3.appendChild(u2);
1505
- const m2 = document.createElement("span");
1506
- m2.classList.add("magicfeedback-rating-number-value");
1507
- const h2 = document.createElement("span");
1508
- if (h2.textContent = p2 ? `${t3} = ${p2}` : t3.toString(), h2.classList.add("magicfeedback-rating-number-value-num"), f && (h2.style.fontWeight = "normal"), m2.appendChild(h2), (v || P) && c2) {
1509
- const e4 = document.createElement("span");
1510
- e4.textContent = c2, e4.classList.add("magicfeedback-rating-number-value-label"), v || (e4.style.display = "none"), m2.appendChild(e4);
1511
- } else !v && !P && T && T[t3] && (o3.title = T[t3]);
1512
- if (o3.appendChild(m2), P) {
1513
- const e4 = document.createElement("label");
1514
- e4.htmlFor = u2.id, e4.classList.add("magicfeedback-rating-number-option-caption"), e4.textContent = c2 || "", n2.classList.add("magicfeedback-rating-number-option--captioned"), n2.classList.add(`magicfeedback-rating-number-option--caption-${S}`), n2.style.flexDirection = "top" === S ? "column" : "column-reverse", n2.style.justifyContent = "flex-end", n2.appendChild(e4);
1515
- }
1516
- n2.appendChild(o3), E.appendChild(n2);
1517
- }
1518
- if (h.appendChild(E), O && h.appendChild(O), w) {
1519
- const e4 = null == i2 ? void 0 : i2.minMaxPlaceholderPosition;
1520
- "top" !== e4 && "bottom" !== e4 || (w.classList.add(`magicfeedback-rating-number-scale-labels--${e4}`), w.style.order = "top" === e4 ? "-1" : "1"), "top" === e4 ? h.insertBefore(w, E) : h.appendChild(w);
1521
- }
1522
- if (v || f || (function(e4, i3, n2, r2, o3 = t2.RATING_NUMBER_MIN_CHIP_WIDTH) {
1523
- if ("undefined" == typeof ResizeObserver) return;
1524
- const a2 = i3.classList.contains("magicfeedback-rating-number-container-row--dense"), s2 = !!i3.querySelector(".magicfeedback-rating-number-option--captioned");
1525
- let l2 = 0, d2 = false;
1526
- const c2 = "function" == typeof requestAnimationFrame ? requestAnimationFrame : (e5) => (e5(0), 0);
1527
- let u2 = 0, p2 = false;
1528
- new ResizeObserver(((t3) => {
1529
- var m2;
1530
- const h2 = null === (m2 = t3[0]) || void 0 === m2 ? void 0 : m2.contentRect.width;
1531
- h2 && h2 !== u2 && (u2 = h2, p2 || (p2 = true, c2((() => {
1532
- var t4;
1533
- p2 = false, d2 || (l2 = parseFloat(getComputedStyle(i3).columnGap) || 0), (t4 = u2 < n2 * o3 + (n2 - 1) * l2) !== d2 && (d2 = t4, e4.classList.toggle("magicfeedback-rating-number--stacked", t4), e4.querySelectorAll(":scope > .magicfeedback-rating-number-scale-labels").forEach(((e5) => {
1534
- e5.style.display = t4 ? "none" : "";
1535
- })), e4.querySelectorAll(":scope > .magicfeedback-rating-number-scale-label-block--stacked").forEach(((e5) => {
1536
- e5.style.display = t4 ? "" : "none";
1537
- })), i3.classList.toggle("magicfeedback-rating-number-container-row", !t4), i3.classList.toggle("magicfeedback-rating-number-container-row--dense", !t4 && a2), i3.classList.toggle("magicfeedback-rating-number-container-column", t4), i3.classList.toggle("magicfeedback-rating-number-container-column--bare", t4 && !s2), i3.style.flexDirection = t4 ? "ltr" === r2 ? "column" : "column-reverse" : "ltr" === r2 ? "row" : "row-reverse", i3.querySelectorAll(":scope > .magicfeedback-rating-number-option").forEach(((e5) => {
1538
- if (e5.classList.toggle("magicfeedback-rating-number-option-row", !t4), e5.classList.toggle("magicfeedback-rating-number-option-column", t4), !e5.classList.contains("magicfeedback-rating-number-option--captioned")) return;
1539
- const i4 = e5.classList.contains("magicfeedback-rating-number-option--caption-top");
1540
- e5.style.flexDirection = t4 ? "" : i4 ? "column" : "column-reverse", e5.querySelectorAll(".magicfeedback-rating-number-option-caption").forEach(((e6) => {
1541
- e6.style.display = t4 ? "none" : "";
1542
- })), e5.querySelectorAll(".magicfeedback-rating-number-value-label").forEach(((e6) => {
1543
- e6.style.display = t4 ? "" : "none";
1544
- }));
1545
- })));
1546
- }))));
1547
- })).observe(e4);
1548
- })(h, E, A - k + 1, o2, P ? t2.RATING_NUMBER_MIN_CAPTIONED_WIDTH : t2.RATING_NUMBER_MIN_CHIP_WIDTH), (null == i2 ? void 0 : i2.extraOption) && (null == i2 ? void 0 : i2.extraOptionText)) {
1549
- const t3 = document.createElement("div");
1550
- t3.classList.add("magicfeedback-rating-number-extra-row");
1551
- const n2 = document.createElement("div");
1552
- n2.classList.add("magicfeedback-rating-number-option"), n2.classList.add("magicfeedback-rating-number-option--extra");
1553
- const o3 = document.createElement("label");
1554
- o3.htmlFor = `rating-${e3}-extra`, o3.classList.add("magicfeedback-rating-number-option-label-container");
1555
- const a2 = document.createElement("input");
1556
- a2.id = `rating-${e3}-extra`, a2.type = "radio", a2.name = e3, a2.value = "-", a2.classList.add(s), a2.classList.add("magicfeedback-input"), a2.setAttribute("aria-label", null == i2 ? void 0 : i2.extraOptionText), (0, r.autoAdvanceOn)(a2, l);
1557
- const d2 = document.createElement("span");
1558
- d2.classList.add("magicfeedback-rating-number-value");
1559
- const c2 = document.createElement("span");
1560
- c2.textContent = null == i2 ? void 0 : i2.extraOptionText, c2.classList.add("magicfeedback-rating-number-value-label"), d2.appendChild(c2), o3.appendChild(a2), o3.appendChild(d2), n2.appendChild(o3), t3.appendChild(n2), h.appendChild(t3);
1561
- }
1562
- return h;
1563
- }, t2.usesLegacyRatingNumber = function(e3) {
1564
- return !!e3 && /matas/i.test(e3);
1565
- }, t2.RATING_NUMBER_MIN_CHIP_WIDTH = 44, t2.RATING_NUMBER_MIN_CAPTIONED_WIDTH = 72;
1566
- }, 368: (e2, t2, i) => {
1567
- "use strict";
1568
- Object.defineProperty(t2, "__esModule", { value: true }), t2.getQuestionRenderer = void 0;
1569
- const n = i(4760), r = i(620), o = i(9006), a = i(3034), s = i(8924), l = i(2807), d = i(2311), c = i(8139), u = i(6363), p = i(7282), m = i(9369), h = i(2626), f = i(2255), g = i(1042), y = i(1994), v = i(1615), b = i(8160), E = i(9169), A = i(1724), k = i(2287), T = i(9796), C = i(5430), P = /* @__PURE__ */ new Map([[n.FEEDBACKAPPANSWERTYPE.TEXT, s.renderText], [n.FEEDBACKAPPANSWERTYPE.LONGTEXT, o.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, g.renderRatingStar], [n.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX, y.renderMatrix], [n.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST, v.renderPriorityList], [n.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM, b.renderPointSystem], [n.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE, E.renderUploadImage], [n.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE, A.renderUploadFile], [n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE, k.renderMultipleChoiceImage], [n.FEEDBACKAPPANSWERTYPE.INFO_PAGE, T.renderInfoPage], [n.FEEDBACKAPPANSWERTYPE.MAX_DIFF, C.renderMaxDiff]]);
1570
- t2.getQuestionRenderer = function(e3) {
1571
- return P.get(e3);
1572
- };
1573
- }, 2807: (e2, t2, i) => {
1574
- "use strict";
1575
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderBoolean = void 0;
1576
- const n = i(1366), r = i(9039);
1577
- t2.renderBoolean = ({ question: e3, language: t3, urlParamValue: i2, send: o }) => {
1578
- const { ref: a, assets: s } = e3, l = document.createElement("div"), d = "magicfeedback-radio", c = document.createElement("div");
1579
- return c.classList.add("magicfeedback-boolean-container"), c.style.display = "flex", c.style.flexDirection = "row", c.style.justifyContent = "space-between", c.style.width = "70%", c.style.margin = "auto", ((null == s ? void 0 : s.addIcon) ? ["\u{1F44D}", "\u{1F44E}"] : (0, n.getBooleanOptions)(t3)).forEach(((e4, t4) => {
1580
- const n2 = document.createElement("label");
1581
- n2.classList.add("magicfeedback-boolean-option"), n2.htmlFor = `rating-${a}-${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";
1582
- const s2 = document.createElement("label");
1583
- s2.htmlFor = `rating-${a}-${t4}`, s2.textContent = e4, s2.style.margin = "0", s2.style.padding = "0";
1584
- const l2 = document.createElement("input");
1585
- l2.id = `rating-${a}-${t4}`, l2.type = "radio", l2.name = a, l2.value = ["Yes", "No"][t4], l2.classList.add(d), l2.classList.add("magicfeedback-input"), l2.style.position = "absolute", l2.style.opacity = "0", l2.style.width = "0", l2.style.height = "0", l2.style.margin = "0", (0, r.autoAdvanceOn)(l2, o), i2 && i2.toLowerCase() === l2.value.toLowerCase() && (l2.checked = true), n2.appendChild(l2), n2.appendChild(s2), c.appendChild(n2);
1586
- })), l.appendChild(c), { element: l, elementTypeClass: d };
1587
- };
1588
- }, 620: (e2, t2, i) => {
1589
- "use strict";
1590
- Object.defineProperty(t2, "__esModule", { value: true }), t2.CHOICE_ROW_MIN_OPTION_WIDTH = t2.renderChoice = void 0;
1591
- const n = i(4760), r = i(3262), o = i(9039);
1592
- t2.renderChoice = ({ question: e3, language: i2, urlParamValue: s, randomPosition: l, send: d }) => {
1593
- const { type: c, ref: u, value: p, defaultValue: m, assets: h } = e3, f = document.createElement("div"), g = "magicfeedback-" + ("MULTIPLECHOICE" === c ? "checkbox" : "radio");
1594
- let y = p || [];
1595
- l && (y = y.sort((() => Math.random() - 0.5)));
1596
- let v = (null == h ? void 0 : h.exclusiveAnswers) || [];
1597
- (null == h ? void 0 : h.extraOption) && (v = v.filter(((e4) => e4 !== h.extraOptionText))), v.length > 0 && (null == v || v.forEach(((e4) => {
1598
- y.includes(e4) || y.push(e4);
1599
- })));
1600
- const b = null == h ? void 0 : h.extraOptionText;
1601
- return (null == h ? void 0 : h.extraOption) && b && !y.includes(b) && y.push(b), y.forEach(((e4, t3) => {
1602
- const a2 = document.createElement("div");
1603
- a2.classList.add(`magicfeedback-${"MULTIPLECHOICE" === c ? "checkbox" : "radio"}-container`);
1604
- const l2 = document.createElement("label"), p2 = document.createElement("input");
1605
- if (p2.id = `rating-${u}-${t3}`, p2.type = "MULTIPLECHOICE" === c ? "checkbox" : "radio", p2.name = u, p2.value = e4, p2.classList.add(g), p2.classList.add("magicfeedback-input"), c === n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE && (null == h ? void 0 : h.maxOptions) && (null == h ? void 0 : h.maxOptions) > 0 && p2.addEventListener("change", (() => {
1606
- document.querySelectorAll(`input[name="${u}"]:checked`).length > (null == h ? void 0 : h.maxOptions) && (p2.checked = false);
1607
- })), c === n.FEEDBACKAPPANSWERTYPE.RADIO && d && (!(null == h ? void 0 : h.extraOptionText) || (null == h ? void 0 : h.extraOptionText) && e4 !== (null == h ? void 0 : h.extraOptionText)) && (0, o.autoAdvanceOn)(p2, d), e4 !== m && e4 !== s || (p2.checked = true), l2.textContent = e4, l2.htmlFor = `rating-${u}-${t3}`, p2.addEventListener("change", ((t4) => {
1608
- const i3 = document.getElementById(`extra-option-${u}`);
1609
- t4.target.checked && v.includes(e4) ? (y.forEach(((t5) => {
1610
- t5 !== e4 && (document.querySelector(`input[value="${t5}"]`).checked = false);
1611
- })), i3 && (i3.style.display = "none")) : v.forEach(((t5) => {
1612
- t5 !== e4 && (document.querySelector(`input[value="${t5}"]`).checked = false);
1613
- })), (null == h ? void 0 : h.extraOption) && e4 === (null == h ? void 0 : h.extraOptionText) && i3 && (i3.style.display = t4.target.checked ? "block" : "none");
1614
- })), a2.appendChild(p2), a2.appendChild(l2), f.appendChild(a2), (null == h ? void 0 : h.extraOption) && e4 === (null == h ? void 0 : h.extraOptionText)) {
1615
- const e5 = document.createElement("input");
1616
- e5.type = "text", e5.placeholder = (null == h ? void 0 : h.extraOptionPlaceholder) || r.placeholder.answer(i2 || "en"), e5.classList.add("magicfeedback-extra-option"), e5.classList.add("magicfeedback-input"), e5.id = `extra-option-${u}`, e5.name = `extra-option-${u}`, e5.style.display = "none", f.appendChild(e5);
1617
- }
1618
- })), c === n.FEEDBACKAPPANSWERTYPE.RADIO && "row" === (null == h ? void 0 : h.direction) && (f.classList.add("magicfeedback-radio--row"), (function(e4, i3) {
1619
- if (e4.classList.toggle("magicfeedback-radio--stacked", window.innerWidth < a), "undefined" == typeof ResizeObserver) return;
1620
- const n2 = "function" == typeof requestAnimationFrame ? requestAnimationFrame : (e5) => (e5(0), 0);
1621
- let r2 = 0, o2 = false;
1622
- new ResizeObserver(((s2) => {
1623
- var l2;
1624
- const d2 = null === (l2 = s2[0]) || void 0 === l2 ? void 0 : l2.contentRect.width;
1625
- d2 && d2 !== r2 && (r2 = d2, o2 || (o2 = true, n2((() => {
1626
- o2 = false, ((n3) => {
1627
- const r3 = parseFloat(getComputedStyle(e4).columnGap) || 0, o3 = i3 * t2.CHOICE_ROW_MIN_OPTION_WIDTH + (i3 - 1) * r3;
1628
- e4.classList.toggle("magicfeedback-radio--stacked", window.innerWidth < a || n3 < o3);
1629
- })(r2);
1630
- }))));
1631
- })).observe(e4);
1632
- })(f, y.length)), { element: f, elementTypeClass: g };
1633
- }, t2.CHOICE_ROW_MIN_OPTION_WIDTH = 120;
1634
- const a = 600;
1635
- }, 9369: (e2, t2, i) => {
1636
- "use strict";
1637
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderConsent = void 0;
1638
- const n = i(9039);
1639
- t2.renderConsent = ({ question: e3, urlParamValue: t3, send: i2 }) => {
1640
- const { id: r, ref: o, value: a, require: s } = e3, l = document.createElement("input");
1641
- return l.type = "checkbox", l.id = `magicfeedback-${r}`, l.name = o, l.value = "true", l.required = s, l.classList.add("magicfeedback-consent"), l.classList.add("magicfeedback-input"), t3 && a.includes(t3) && (l.checked = true), (0, n.autoAdvanceOn)(l, i2), { element: l, elementTypeClass: "magicfeedback-consent" };
1642
- };
1643
- }, 8139: (e2, t2, i) => {
1644
- "use strict";
1645
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderDate = void 0;
1646
- const n = i(3262);
1647
- t2.renderDate = ({ language: e3, placeholderText: t3, urlParamValue: i2 }) => {
1648
- const r = document.createElement("input");
1649
- return r.type = "date", r.placeholder = t3 || n.placeholder.date(e3 || "en"), i2 && (r.value = i2), { element: r, elementTypeClass: "magicfeedback-date" };
1650
- };
1651
- }, 6363: (e2, t2) => {
1652
- "use strict";
1653
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderEmail = void 0, t2.renderEmail = ({ placeholderText: e3, urlParamValue: t3 }) => {
1654
- const i = document.createElement("input");
1655
- return i.type = "email", i.placeholder = e3 || "you@example.com", t3 && (i.value = t3), { element: i, elementTypeClass: "magicfeedback-email" };
1656
- };
1657
- }, 9796: (e2, t2) => {
1658
- "use strict";
1659
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderInfoPage = void 0, t2.renderInfoPage = ({ question: e3, placeholderText: t3 }) => {
1660
- var i, n;
1661
- const r = document.createElement("div");
1662
- 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)) {
1663
- const e4 = document.createElement("div");
1664
- e4.classList.add("magicfeedback-info-message"), e4.innerHTML = t3 || "", r.appendChild(e4);
1665
- }
1666
- return { element: r, elementTypeClass: "magicfeedback-info-page" };
1667
- };
1668
- }, 9006: (e2, t2, i) => {
1669
- "use strict";
1670
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderLongText = void 0;
1671
- const n = i(3262);
1672
- t2.renderLongText = ({ language: e3, placeholderText: t3, urlParamValue: i2, maxCharacters: r }) => {
1673
- const o = document.createElement("textarea");
1674
- return o.rows = 3, r > 0 && (o.maxLength = r), o.placeholder = t3 || n.placeholder.answer(e3 || "en"), i2 && (o.value = i2), { element: o, elementTypeClass: "magicfeedback-longtext" };
1675
- };
1676
- }, 1994: (e2, t2) => {
1677
- "use strict";
1678
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderMatrix = void 0, t2.renderMatrix = ({ question: e3, isPhone: t3, randomPosition: i }) => {
1679
- const { ref: n, value: r, assets: o } = e3, a = document.createElement("div"), s = document.createElement("div");
1680
- s.classList.add("magicfeedback-multi-question-matrix-container");
1681
- let l = (null == o ? void 0 : o.options) || [], d = [...r], c = [];
1682
- if (i && (l = null == l ? void 0 : l.sort((() => Math.random() - 0.5)), d = [...d].sort((() => Math.random() - 0.5))), (null == o ? void 0 : o.exclusiveAnswers) && (c = null == o ? void 0 : o.exclusiveAnswers, null == c || c.forEach(((e4) => {
1683
- d.includes(e4) || d.push(e4);
1684
- }))), t3) {
1685
- const e4 = document.createElement("div");
1686
- e4.classList.add("magicfeedback-multi-question-matrix-list"), null == l || l.forEach(((t4) => {
1687
- const i2 = document.createElement("div");
1688
- 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";
1689
- const r2 = document.createElement("label");
1690
- r2.classList.add("magicfeedback-multi-question-matrix-label"), r2.style.paddingBottom = "10px", r2.textContent = t4, i2.appendChild(r2), d.forEach(((e5) => {
1691
- const r3 = document.createElement("div");
1692
- 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";
1693
- const o2 = document.createElement("label"), a2 = document.createElement("input");
1694
- a2.id = `${n}-${t4}-${e5}`, a2.type = "radio", a2.name = `${n}-${t4}`, a2.value = e5, a2.classList.add("magicfeedback-input"), o2.textContent = e5, o2.htmlFor = `${n}-${t4}-${e5}`, r3.appendChild(a2), r3.appendChild(o2), i2.appendChild(r3);
1695
- })), e4.appendChild(i2);
1696
- })), s.appendChild(e4);
1697
- } else {
1698
- const e4 = document.createElement("table");
1699
- e4.classList.add("magicfeedback-multi-question-matrix-table");
1700
- const t4 = document.createElement("thead");
1701
- t4.classList.add("magicfeedback-multi-question-matrix-header"), t4.style.paddingBottom = "15px";
1702
- const i2 = document.createElement("tr"), r2 = document.createElement("th");
1703
- i2.appendChild(r2), d.forEach(((e5) => {
1704
- const t5 = document.createElement("th");
1705
- t5.textContent = e5, i2.appendChild(t5);
1706
- })), t4.appendChild(i2), e4.appendChild(t4);
1707
- const o2 = document.createElement("tbody");
1708
- null == l || l.forEach(((e5) => {
1709
- const t5 = document.createElement("tr");
1710
- t5.classList.add("magicfeedback-multi-question-matrix-row-tr");
1711
- const i3 = document.createElement("td");
1712
- i3.classList.add("magicfeedback-multi-question-matrix-question");
1713
- const r3 = document.createElement("label");
1714
- r3.classList.add("magicfeedback-multi-question-matrix-label"), r3.textContent = e5, i3.appendChild(r3), t5.appendChild(i3), d.forEach(((i4) => {
1715
- const r4 = document.createElement("td"), o3 = document.createElement("input");
1716
- o3.type = "radio", o3.name = `${n}-${e5}`, o3.value = i4, o3.id = `${n}-${e5}-${i4}`, o3.classList.add("magicfeedback-input");
1717
- const a2 = document.createElement("label");
1718
- a2.classList.add("magicfeedback-multi-question-matrix-option-label"), a2.htmlFor = o3.id, a2.textContent = i4, r4.classList.add("magicfeedback-multi-question-matrix-option"), r4.appendChild(o3), r4.appendChild(a2), t5.appendChild(r4);
1719
- })), o2.appendChild(t5);
1720
- })), e4.appendChild(o2), s.appendChild(e4);
1721
- }
1722
- return a.appendChild(s), { element: a, elementTypeClass: "magicfeedback-multi-question-matrix" };
1723
- };
1724
- }, 5430: (e2, t2, i) => {
1725
- "use strict";
1726
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderMaxDiff = void 0;
1727
- const n = i(1366), r = i(7627), o = "http://www.w3.org/2000/svg";
1728
- t2.renderMaxDiff = ({ question: e3, language: t3, randomPosition: i2 }) => {
1729
- const { ref: a, value: s, assets: l } = e3, d = document.createElement("div");
1730
- let c = [...s || []];
1731
- i2 && (c = c.sort((() => Math.random() - 0.5)));
1732
- const u = { best: (0, n.parseTitle)(null == l ? void 0 : l.bestLabel, t3) || (0, r.t)(t3, "maxDiff.best"), worst: (0, n.parseTitle)(null == l ? void 0 : l.worstLabel, t3) || (0, r.t)(t3, "maxDiff.worst") }, p = document.createElement("div");
1733
- p.classList.add("magicfeedback-max-diff-container");
1734
- const m = Number(null == l ? void 0 : l.setIndex) || 1, h = Number(null == l ? void 0 : l.setCount) || 1;
1735
- (null == l ? void 0 : l.showSetProgress) && h > 1 && p.appendChild((function(e4, t4, i3) {
1736
- const n2 = document.createElement("div");
1737
- n2.classList.add("magicfeedback-max-diff-progress");
1738
- const o2 = document.createElement("span");
1739
- o2.classList.add("magicfeedback-max-diff-progress-label"), o2.textContent = (0, r.t)(i3, "maxDiff.setProgress", { k: e4, n: t4 });
1740
- const a2 = document.createElement("span");
1741
- a2.classList.add("magicfeedback-max-diff-progress-track"), a2.setAttribute("aria-hidden", "true");
1742
- const s2 = document.createElement("span");
1743
- return s2.classList.add("magicfeedback-max-diff-progress-fill"), s2.style.width = `${Math.min(100, e4 / t4 * 100)}%`, a2.appendChild(s2), n2.appendChild(o2), n2.appendChild(a2), n2;
1744
- })(m, h, t3));
1745
- const f = document.createElement("table");
1746
- f.classList.add("magicfeedback-max-diff-table");
1747
- const g = (e4) => {
1748
- const t4 = document.createElement("th");
1749
- t4.scope = "col", t4.classList.add("magicfeedback-max-diff-head", `magicfeedback-max-diff-head-${e4}`);
1750
- const i3 = document.createElement("span");
1751
- return i3.classList.add("magicfeedback-max-diff-head-label"), i3.appendChild((function(e5) {
1752
- const t5 = document.createElementNS(o, "svg");
1753
- t5.setAttribute("viewBox", "0 0 24 24"), t5.setAttribute("width", "16"), t5.setAttribute("height", "16"), t5.setAttribute("fill", "none"), t5.setAttribute("stroke", "currentColor"), t5.setAttribute("stroke-width", "2.6"), t5.setAttribute("stroke-linecap", "round"), t5.setAttribute("stroke-linejoin", "round"), t5.setAttribute("aria-hidden", "true");
1754
- const i4 = document.createElementNS(o, "path");
1755
- return i4.setAttribute("d", "best" === e5 ? "M12 19V5M5 12l7-7 7 7" : "M12 5v14M19 12l-7 7-7-7"), t5.appendChild(i4), t5;
1756
- })(e4)), i3.appendChild(document.createTextNode(u[e4])), t4.appendChild(i3), t4;
1757
- }, y = document.createElement("thead"), v = document.createElement("tr"), b = document.createElement("td");
1758
- b.classList.add("magicfeedback-max-diff-head-spacer"), v.appendChild(g("best")), v.appendChild(b), v.appendChild(g("worst")), y.appendChild(v), f.appendChild(y);
1759
- const E = (e4, t4, i3) => {
1760
- const n2 = document.createElement("td");
1761
- n2.classList.add("magicfeedback-max-diff-cell");
1762
- const r2 = document.createElement("label");
1763
- r2.classList.add("magicfeedback-max-diff-pick");
1764
- const o2 = document.createElement("input");
1765
- return o2.type = "radio", o2.name = `${a}-${e4}`, o2.value = t4, o2.id = `${a}-${e4}-${i3}`, o2.classList.add("magicfeedback-input", "magicfeedback-max-diff-input", `magicfeedback-max-diff-${e4}`), o2.setAttribute("aria-label", `${t4}: ${u[e4]}`), r2.appendChild(o2), n2.appendChild(r2), n2;
1766
- }, A = document.createElement("tbody");
1767
- return c.forEach(((e4, t4) => {
1768
- const i3 = document.createElement("tr");
1769
- i3.classList.add("magicfeedback-max-diff-row");
1770
- const n2 = document.createElement("th");
1771
- n2.scope = "row", n2.classList.add("magicfeedback-max-diff-item"), n2.textContent = e4, i3.appendChild(E("best", e4, t4)), i3.appendChild(n2), i3.appendChild(E("worst", e4, t4)), A.appendChild(i3);
1772
- })), f.appendChild(A), f.addEventListener("change", ((e4) => {
1773
- var t4;
1774
- const i3 = e4.target;
1775
- i3.classList.contains("magicfeedback-max-diff-input") && (null === (t4 = i3.closest("tr")) || void 0 === t4 || t4.querySelectorAll(".magicfeedback-max-diff-input").forEach(((e5) => {
1776
- e5 !== i3 && (e5.checked = false);
1777
- })));
1778
- })), p.appendChild(f), d.appendChild(p), { element: d, elementTypeClass: "magicfeedback-max-diff" };
1779
- };
1780
- }, 2287: (e2, t2, i) => {
1781
- "use strict";
1782
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderMultipleChoiceImage = void 0;
1783
- const n = i(9039);
1784
- t2.renderMultipleChoiceImage = ({ question: e3, randomPosition: t3, urlParamValue: i2, send: r }) => {
1785
- const o = document.createElement("div"), { ref: a, assets: s } = e3;
1786
- let l = [...e3.value];
1787
- const d = document.createElement("div");
1788
- d.classList.add("magicfeedback-multiple-choice-image-container"), d.style.display = "flex", d.style.flexDirection = "row", d.style.flexWrap = "wrap", d.style.justifyContent = "center";
1789
- const c = l.length;
1790
- let u = 1, p = 1;
1791
- if (window.innerWidth < 600) u = 1, p = c;
1792
- else switch (c) {
1793
- case 1:
1794
- case 2:
1795
- case 3:
1796
- u = c, p = 1;
1797
- break;
1798
- case 4:
1799
- case 5:
1800
- case 6:
1801
- p = 2, u = Math.ceil(c / p);
1802
- break;
1803
- case 7:
1804
- case 8:
1805
- case 9:
1806
- p = 3, u = Math.ceil(c / p);
1807
- break;
1808
- default:
1809
- p = 4, u = Math.ceil(c / p);
1810
- }
1811
- const m = void 0 !== (null == s ? void 0 : s.addTitle) && (null == s ? void 0 : s.addTitle), h = void 0 !== (null == s ? void 0 : s.multiOption) && (null == s ? void 0 : s.multiOption), f = void 0 !== (null == s ? void 0 : s.extraOption) && (null == s ? void 0 : s.extraOption);
1812
- function g(e4) {
1813
- try {
1814
- const { position: t4, url: o2, value: s2 } = e4, l2 = document.createElement("div");
1815
- l2.classList.add("magicfeedback-multiple-choice-image-option"), l2.style.width = `calc(100% / ${u} - 2px)`, l2.style.height = `calc(100% / ${p} - 2px)`, l2.style.padding = "8px", l2.style.margin = "0";
1816
- const c2 = document.createElement("label");
1817
- c2.classList.add("magicfeedback-image-option-label-container"), c2.htmlFor = `rating-${a}-${t4}`, c2.style.cursor = "pointer", c2.addEventListener("click", (() => {
1818
- c2.style.border = "2px solid #000";
1819
- }));
1820
- const f2 = document.createElement("label");
1821
- f2.textContent = s2, f2.classList.add("magicfeedback-multiple-choice-image-label");
1822
- const g2 = document.createElement("input");
1823
- g2.id = `rating-${a}-${t4}`, g2.type = h ? "checkbox" : "radio", g2.name = a, g2.value = s2, g2.style.position = "absolute", g2.style.opacity = "0", g2.style.width = "0", g2.style.height = "0", g2.classList.add("magicfeedback-input"), i2 && i2 === g2.value && (g2.checked = true), h || (0, n.autoAdvanceOn)(g2, r);
1824
- const y = document.createElement("img");
1825
- y.classList.add("magicfeedback-multiple-choice-image-image"), y.src = o2, y.style.cursor = "pointer", y.style.backgroundSize = "cover", y.style.backgroundPosition = "center", y.style.width = "100%", y.style.height = "100%", y.style.objectFit = "cover", y.style.margin = "auto", c2.appendChild(g2), c2.appendChild(y), m && c2.appendChild(f2), l2.appendChild(c2), d.appendChild(l2);
1826
- } catch (e5) {
1827
- console.error(e5);
1828
- }
1829
- }
1830
- return t3 && (l = l.sort((() => Math.random() - 0.5))), l.forEach(((e4) => g(JSON.parse(e4)))), f && (null == s ? void 0 : s.extraOptionValue) && (null == s ? void 0 : s.extraOptionValue.length) > 0 && g(null == s ? void 0 : s.extraOptionValue[0]), o.appendChild(d), { element: o, elementTypeClass: "magicfeedback-multiple-choice-image" };
1831
- };
1832
- }, 3034: (e2, t2, i) => {
1833
- "use strict";
1834
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderNumber = void 0;
1835
- const n = i(3262), r = i(1366);
1836
- t2.renderNumber = ({ question: e3, format: t3, language: i2, urlParamValue: o }) => {
1837
- const a = document.createElement("input");
1838
- a.type = "number", a.placeholder = "slim" === t3 ? (0, r.parseTitle)(e3.title, i2) : n.placeholder.number(i2 || "en");
1839
- const { value: s } = e3;
1840
- return s.length && (s.sort(((e4, t4) => Number(e4) - Number(t4))), a.max = s[s.length - 1], a.min = s[0], a.value = s[0]), o && !isNaN(Number(o)) && (a.value = o), { element: a, elementTypeClass: "magicfeedback-number" };
1841
- };
1842
- }, 7282: (e2, t2, i) => {
1843
- "use strict";
1844
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderPassword = void 0;
1845
- const n = i(3262);
1846
- t2.renderPassword = ({ language: e3, placeholderText: t3, urlParamValue: i2 }) => {
1847
- const r = document.createElement("input");
1848
- return r.type = "password", r.placeholder = t3 || n.placeholder.password(e3 || "en"), i2 && (r.value = i2), { element: r, elementTypeClass: "magicfeedback-password" };
1849
- };
1850
- }, 8160: (e2, t2, i) => {
1851
- "use strict";
1852
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderPointSystem = void 0;
1853
- const n = i(3262);
1854
- t2.renderPointSystem = ({ question: e3, language: t3 }) => {
1855
- const { ref: i2, value: r } = e3, o = document.createElement("div"), a = document.createElement("div");
1856
- a.classList.add("magicfeedback-point-system-container");
1857
- const s = document.createElement("ul");
1858
- s.classList.add("magicfeedback-point-system-list"), s.style.padding = "0";
1859
- const l = 100 / r.length, d = document.createElement("div");
1860
- d.classList.add("magicfeedback-error"), d.textContent = n.placeholder.pointsystemerror(t3 || "en"), d.style.color = "#C70039", d.style.fontSize = "14px", d.style.textAlign = "end", d.style.width = "100%", d.style.display = "none";
1861
- const c = document.createElement("div");
1862
- c.classList.add("magicfeedback-point-system-total"), c.style.textAlign = "end", c.style.fontSize = "15px", c.style.marginTop = "5px";
1863
- const u = document.createElement("bdi");
1864
- return u.setAttribute("dir", "ltr"), u.textContent = "0 / 100 %", c.appendChild(u), r.forEach(((e4, t4) => {
1865
- const n2 = document.createElement("li");
1866
- n2.classList.add("magicfeedback-point-system-item"), n2.style.display = "flex", n2.style.justifyContent = "space-between", n2.style.alignItems = "center", n2.style.margin = "5px";
1867
- const r2 = document.createElement("label");
1868
- r2.textContent = e4, r2.style.fontSize = "15px", n2.appendChild(r2);
1869
- const o2 = document.createElement("span");
1870
- o2.classList.add("magicfeedback-point-system-input-container");
1871
- const a2 = document.createElement("input");
1872
- 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;
1873
- const p = document.createElement("span");
1874
- p.textContent = "%", p.style.color = "#000", a2.addEventListener("input", (() => {
1875
- const e5 = s.querySelectorAll("input");
1876
- let t5 = 0;
1877
- e5.forEach(((e6) => {
1878
- t5 += Number(e6.value);
1879
- })), t5 > 100 && (a2.value = `${l}%`, t5 -= Number(a2.value));
1880
- const i3 = document.getElementById("magicfeedback-submit");
1881
- i3 && (t5 < 100 ? (c.style.color = "orange", i3.setAttribute("disabled", "true")) : (d.style.display = "none", c.style.color = "green", i3.removeAttribute("disabled"))), u.textContent = `${t5} / 100 %`;
1882
- })), a2.addEventListener("focus", (() => {
1883
- const e5 = document.getElementById("magicfeedback-submit");
1884
- e5 && (e5.setAttribute("disabled", "true"), e5.addEventListener("pointerover", (() => {
1885
- const e6 = s.querySelectorAll("input");
1886
- let t5 = 0;
1887
- e6.forEach(((e7) => {
1888
- t5 += Number(e7.value);
1889
- })), t5 < 100 && (d.style.display = "block");
1890
- })));
1891
- })), o2.appendChild(a2), o2.appendChild(p), n2.appendChild(o2), s.appendChild(n2);
1892
- })), a.appendChild(s), a.appendChild(c), a.appendChild(d), o.appendChild(a), { element: o, elementTypeClass: "magicfeedback-point-system" };
1893
- };
1894
- }, 1615: (e2, t2, i) => {
1895
- "use strict";
1896
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderPriorityList = void 0;
1897
- const n = i(7627);
1898
- t2.renderPriorityList = ({ question: e3, randomPosition: t3, language: i2 }) => {
1899
- var r, o, a;
1900
- const s = document.createElement("div"), l = (function(e4) {
1901
- const { value: t4, ref: i3, randomPosition: r2 = false, limitPriority: o2 = false, maxPriority: a2 = 0, language: s2 = "en", placeholder: l2 = "" } = e4, d = (e5) => (0, n.t)(s2, "priority." + e5), c = document.createElement("div");
1902
- if (c.classList.add("magicfeedback-priority-list-container"), o2 && a2 && a2 > 0) {
1903
- const e5 = [], o3 = document.createElement("div");
1904
- o3.classList.add("magicfeedback-priority-list-header");
1905
- const u2 = document.createElement("div");
1906
- u2.classList.add("magicfeedback-priority-list-instruction"), u2.textContent = "" !== l2 ? l2 : `${d("instruction")}`, u2.style.display = "none";
1907
- const p2 = document.createElement("button");
1908
- p2.type = "button", p2.textContent = d("selectOptions"), p2.classList.add("magicfeedback-button"), p2.classList.add("magicfeedback-priority-list-open-btn"), o3.appendChild(p2), o3.appendChild(u2);
1909
- const m = document.createElement("div");
1910
- m.classList.add("magicfeedback-priority-list-reorder");
1911
- const h = document.createElement("ul");
1912
- h.classList.add("magicfeedback-priority-list-list"), m.appendChild(h);
1913
- const f = () => {
1914
- h.innerHTML = "", e5.forEach(((t5, n2) => {
1915
- const r3 = document.createElement("li");
1916
- r3.classList.add("magicfeedback-priority-list-item");
1917
- const o4 = document.createElement("input");
1918
- o4.classList.add("magicfeedback-input-magicfeedback-priority-list"), o4.classList.add("magicfeedback-input"), o4.type = "hidden", o4.id = `priority-list-${i3}`, o4.name = i3, o4.value = `${n2 + 1}. ${t5}`, r3.appendChild(o4);
1919
- const a3 = document.createElement("label");
1920
- a3.classList.add("magicfeedback-priority-list-item-label"), a3.textContent = `${n2 + 1}. ${t5}`, r3.appendChild(a3);
1921
- const s3 = document.createElement("div");
1922
- s3.classList.add("magicfeedback-priority-list-arrows");
1923
- const l3 = document.createElement("img");
1924
- l3.classList.add("magicfeedback-priority-list-arrow-up"), l3.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", l3.style.visibility = 0 === n2 ? "hidden" : "visible";
1925
- const d2 = document.createElement("img");
1926
- 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 = n2 === e5.length - 1 ? "hidden" : "visible", l3.addEventListener("click", (() => {
1927
- var i4, n3, s4, c2;
1928
- const u3 = r3.previousElementSibling;
1929
- if (u3) {
1930
- const p3 = Number(null === (i4 = o4.value) || void 0 === i4 ? void 0 : i4.split(".")[0]) - 1;
1931
- o4.value = `${p3}. ${t5}`, a3.textContent = `${p3}. ${t5}`, l3.style.visibility = 1 === p3 ? "hidden" : "visible", d2.style.visibility = p3 === e5.length ? "hidden" : "visible";
1932
- const m2 = u3.querySelector(".magicfeedback-input-magicfeedback-priority-list"), f2 = u3.querySelector(".magicfeedback-priority-list-item-label"), g2 = u3.querySelector(".magicfeedback-priority-list-arrow-up"), y2 = u3.querySelector(".magicfeedback-priority-list-arrow-down");
1933
- if (m2 && f2 && g2 && y2) {
1934
- const t6 = Number(null === (n3 = m2.value) || void 0 === n3 ? void 0 : n3.split(".")[0]) + 1;
1935
- m2.value = `${t6}.${null === (s4 = f2.textContent) || void 0 === s4 ? void 0 : s4.split(".")[1]}`, f2.textContent = `${t6}.${null === (c2 = f2.textContent) || void 0 === c2 ? void 0 : c2.split(".")[1]}`, g2.style.visibility = 1 === t6 ? "hidden" : "visible", y2.style.visibility = t6 === e5.length ? "hidden" : "visible";
1936
- }
1937
- h.insertBefore(r3, u3);
1938
- }
1939
- })), d2.addEventListener("click", (() => {
1940
- var i4, n3, s4;
1941
- const c2 = r3.nextElementSibling;
1942
- if (c2) {
1943
- const u3 = Number(null === (i4 = o4.value) || void 0 === i4 ? void 0 : i4.split(".")[0]) + 1;
1944
- o4.value = `${u3}. ${t5}`, a3.textContent = `${u3}. ${t5}`, l3.style.visibility = 1 === u3 ? "hidden" : "visible", d2.style.visibility = u3 === e5.length ? "hidden" : "visible";
1945
- const p3 = c2.querySelector(".magicfeedback-input-magicfeedback-priority-list"), m2 = c2.querySelector(".magicfeedback-priority-list-item-label"), f2 = c2.querySelector(".magicfeedback-priority-list-arrow-up"), g2 = c2.querySelector(".magicfeedback-priority-list-arrow-down");
1946
- if (p3 && m2 && f2 && g2) {
1947
- const t6 = Number(p3.value.split(".")[0]) - 1;
1948
- p3.value = `${t6}.${null === (n3 = m2.textContent) || void 0 === n3 ? void 0 : n3.split(".")[1]}`, m2.textContent = `${t6}.${null === (s4 = m2.textContent) || void 0 === s4 ? void 0 : s4.split(".")[1]}`, f2.style.visibility = 1 === t6 ? "hidden" : "visible", g2.style.visibility = t6 === e5.length ? "hidden" : "visible";
1949
- }
1950
- h.insertBefore(c2, r3);
1951
- }
1952
- })), s3.appendChild(l3), s3.appendChild(d2), r3.appendChild(s3), h.appendChild(r3);
1953
- }));
1954
- }, g = document.createElement("div");
1955
- g.classList.add("magicfeedback-modal-backdrop"), g.setAttribute("dir", (0, n.isRtlLanguage)(s2) ? "rtl" : "ltr"), g.style.position = "fixed", g.style.top = "0", g.style.left = "0", g.style.width = "100vw", g.style.height = "100vh", g.style.background = "rgba(0,0,0,0.4)", g.style.display = "none", g.style.alignItems = "center", g.style.justifyContent = "center", g.style.zIndex = "9999";
1956
- const y = document.createElement("div");
1957
- y.classList.add("magicfeedback-modal"), y.style.background = "#fff", y.style.borderRadius = "8px", y.style.boxShadow = "0 8px 24px rgba(0,0,0,0.2)", y.style.maxWidth = "520px", y.style.width = "90%", y.style.maxHeight = "80vh", y.style.display = "flex", y.style.flexDirection = "column", y.style.overflow = "hidden", y.style.padding = "16px", y.style.position = "relative";
1958
- const v = document.createElement("h5");
1959
- v.classList.add("magicfeedback-modal-title"), v.style.flexShrink = "0", v.style.marginTop = "0";
1960
- const b = () => Math.min(e5.length + 1, a2), E = () => {
1961
- v.textContent = `${d("selectOptionNumber")}${b()}`;
1962
- };
1963
- E();
1964
- const A = document.createElement("div");
1965
- A.classList.add("magicfeedback-modal-list"), A.style.flex = "1 1 auto", A.style.overflowY = "auto", A.style.minHeight = "0", (r2 ? [...t4].sort((() => Math.random() - 0.5)) : [...t4]).forEach(((t5) => {
1966
- const n2 = document.createElement("label");
1967
- n2.classList.add("magicfeedback-modal-row");
1968
- const r3 = document.createElement("input");
1969
- r3.type = "checkbox", r3.classList.add("magicfeedback-input"), r3.name = `${i3}-selection`, r3.value = t5;
1970
- const o4 = document.createElement("span");
1971
- o4.textContent = t5, r3.addEventListener("change", (() => {
1972
- if (r3.checked) {
1973
- if (e5.length >= a2) return r3.checked = false, n2.classList.add("magicfeedback-warning"), void setTimeout((() => {
1974
- n2.classList.remove("magicfeedback-warning");
1975
- }), 800);
1976
- e5.push(t5);
1977
- } else {
1978
- const i4 = e5.indexOf(t5);
1979
- -1 !== i4 && e5.splice(i4, 1);
1980
- }
1981
- E(), C();
1982
- })), n2.appendChild(r3), n2.appendChild(o4), A.appendChild(n2);
1983
- }));
1984
- const k = document.createElement("div");
1985
- k.classList.add("magicfeedback-modal-actions"), k.style.flexShrink = "0";
1986
- const T = document.createElement("div");
1987
- T.classList.add("magicfeedback-modal-counter");
1988
- const C = () => {
1989
- const t5 = d("of");
1990
- T.textContent = `${d("prioritized")} ${e5.length} ${t5} ${a2}`, u2.style.display = e5.length > 0 ? "block" : "none";
1991
- };
1992
- C();
1993
- const P = document.createElement("button");
1994
- P.type = "button", P.classList.add("magicfeedback-modal-close"), P.setAttribute("aria-label", d("cancel")), P.title = d("cancel"), P.textContent = "\xD7", P.style.position = "absolute", P.style.top = "8px", P.style.setProperty("inset-inline-end", "8px"), P.style.border = "none", P.style.background = "transparent", P.style.fontSize = "24px", P.style.cursor = "pointer";
1995
- const S = () => {
1996
- document.body.appendChild(g), g.style.display = "flex", E(), C();
1997
- }, w = () => {
1998
- g.style.display = "none", c.appendChild(g);
1999
- };
2000
- P.addEventListener("click", (() => {
2001
- w();
2002
- }));
2003
- const O = document.createElement("button");
2004
- return O.type = "button", O.textContent = d("confirm"), O.classList.add("magicfeedback-button"), O.classList.add("magicfeedback-button-primary"), O.addEventListener("click", (() => {
2005
- w(), f();
2006
- })), k.appendChild(T), k.appendChild(O), y.appendChild(P), y.appendChild(v), y.appendChild(A), y.appendChild(k), g.appendChild(y), p2.addEventListener("click", (() => {
2007
- S();
2008
- })), g.addEventListener("click", ((e6) => {
2009
- e6.target === g && w();
2010
- })), c.appendChild(o3), c.appendChild(m), c.appendChild(g), f(), c;
2011
- }
2012
- const u = document.createElement("ul");
2013
- u.classList.add("magicfeedback-priority-list-list");
2014
- const p = r2 ? [...t4].sort((() => Math.random() - 0.5)) : [...t4];
2015
- return p.forEach(((e5, t5) => {
2016
- const n2 = document.createElement("li");
2017
- n2.classList.add("magicfeedback-priority-list-item"), n2.style.display = "flex", n2.style.justifyContent = "space-between", n2.style.alignItems = "center", n2.style.margin = "5px";
2018
- const r3 = document.createElement("input");
2019
- r3.classList.add("magicfeedback-input-magicfeedback-priority-list"), r3.classList.add("magicfeedback-input"), r3.type = "hidden", r3.id = `priority-list-${i3}`, r3.name = i3, r3.value = `${t5 + 1}. ${e5}`, n2.appendChild(r3);
2020
- const o3 = document.createElement("label");
2021
- o3.classList.add("magicfeedback-priority-list-item-label"), o3.textContent = `${t5 + 1}. ${e5}`, n2.appendChild(o3);
2022
- const a3 = document.createElement("div");
2023
- a3.style.display = "flex", a3.style.alignItems = "center", a3.style.justifyContent = "space-between";
2024
- const s3 = document.createElement("img");
2025
- s3.classList.add("magicfeedback-priority-list-arrow-up"), s3.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", s3.style.width = "20px", s3.style.height = "20px", s3.style.cursor = "pointer", s3.style.margin = "0 5px", s3.style.color = "#000", s3.style.visibility = 0 === t5 ? "hidden" : "visible", s3.addEventListener("click", (() => {
2026
- var t6, i4, a4, d2;
2027
- const c2 = n2.previousElementSibling;
2028
- if (c2) {
2029
- const m = Number(null === (t6 = r3.value) || void 0 === t6 ? void 0 : t6.split(".")[0]) - 1;
2030
- r3.value = `${m}. ${e5}`, o3.textContent = `${m}. ${e5}`, s3.style.visibility = 1 === m ? "hidden" : "visible", l3.style.visibility = m === p.length ? "hidden" : "visible";
2031
- const h = c2.querySelector(".magicfeedback-input-magicfeedback-priority-list"), f = c2.querySelector(".magicfeedback-priority-list-item-label"), g = c2.querySelector(".magicfeedback-priority-list-arrow-up"), y = c2.querySelector(".magicfeedback-priority-list-arrow-down");
2032
- if (h && f && g && y) {
2033
- const e6 = Number(null === (i4 = h.value) || void 0 === i4 ? void 0 : i4.split(".")[0]) + 1;
2034
- 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]}`, g.style.visibility = 1 === e6 ? "hidden" : "visible", y.style.visibility = e6 === p.length ? "hidden" : "visible";
2035
- }
2036
- u.insertBefore(n2, c2);
2037
- }
2038
- }));
2039
- const l3 = document.createElement("img");
2040
- l3.classList.add("magicfeedback-priority-list-arrow-down"), l3.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", l3.style.width = "20px", l3.style.height = "20px", l3.style.cursor = "pointer", l3.style.margin = "0 5px", l3.style.color = "#000", l3.style.transform = "rotate(180deg)", l3.style.visibility = t5 === p.length - 1 ? "hidden" : "visible", l3.addEventListener("click", (() => {
2041
- var t6, i4, a4;
2042
- const d2 = n2.nextElementSibling;
2043
- if (d2) {
2044
- const c2 = Number(null === (t6 = r3.value) || void 0 === t6 ? void 0 : t6.split(".")[0]) + 1;
2045
- r3.value = `${c2}. ${e5}`, o3.textContent = `${c2}. ${e5}`, s3.style.visibility = 1 === c2 ? "hidden" : "visible", l3.style.visibility = c2 === p.length ? "hidden" : "visible";
2046
- 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"), g = d2.querySelector(".magicfeedback-priority-list-arrow-down");
2047
- if (m && h && f && g) {
2048
- const e6 = Number(m.value.split(".")[0]) - 1;
2049
- m.value = `${e6}.${null === (i4 = h.textContent) || void 0 === i4 ? void 0 : i4.split(".")[1]}`, h.textContent = `${e6}.${null === (a4 = h.textContent) || void 0 === a4 ? void 0 : a4.split(".")[1]}`, f.style.visibility = 1 === e6 ? "hidden" : "visible", g.style.visibility = e6 === p.length ? "hidden" : "visible";
2050
- }
2051
- u.insertBefore(d2, n2);
2052
- }
2053
- })), a3.appendChild(s3), a3.appendChild(l3), n2.appendChild(a3), u.appendChild(n2);
2054
- })), c.appendChild(u), c;
2055
- })({ value: e3.value, ref: e3.ref, randomPosition: t3, limitPriority: (null === (r = e3.assets) || void 0 === r ? void 0 : r.limitPriority) || false, maxPriority: (null === (o = e3.assets) || void 0 === o ? void 0 : o.maxPriority) || 0, placeholder: (null === (a = e3.assets) || void 0 === a ? void 0 : a.placeholder) || "", language: i2 || "en" });
2056
- return s.appendChild(l), { element: s, elementTypeClass: "magicfeedback-priority-list" };
2057
- };
2058
- }, 2626: (e2, t2, i) => {
2059
- "use strict";
2060
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderRatingEmoji = void 0;
2061
- const n = i(2709), r = i(9039), o = "https://survey-dev.magicfeedback.io/assets/emojis";
2062
- t2.renderRatingEmoji = ({ question: e3, url: t3, send: i2, urlParamValue: a }) => {
2063
- const { ref: s, assets: l } = e3, d = document.createElement("div"), c = "magicfeedback-rating", u = document.createElement("div");
2064
- u.classList.add("magicfeedback-rating-container");
2065
- 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)(null == l ? void 0 : l.minPlaceholder, null == l ? void 0 : l.maxPlaceholder);
2066
- for (let e4 = m; e4 <= p; e4++) {
2067
- const n2 = document.createElement("div");
2068
- n2.classList.add("magicfeedback-rating-option");
2069
- const l2 = document.createElement("label");
2070
- l2.htmlFor = `rating-${s}-${e4}`, l2.classList.add("magicfeedback-rating-option-label-container");
2071
- const d2 = document.createElement("label");
2072
- d2.htmlFor = `rating-${s}-${e4}`, d2.textContent = e4.toString();
2073
- const h2 = document.createElement("img");
2074
- if (h2.alt = `face-${s}-${e4}`, h2.className = `rating-image${e4}`, 0 === m && 10 === p) h2.src = `${t3}/${e4}.svg`, h2.onerror = () => h2.src = `${o}/${e4}.svg`;
2075
- else if (1 === m && 5 === p) switch (e4) {
2076
- case 1:
2077
- h2.src = `${t3}/1.svg`, h2.onerror = () => h2.src = `${o}/1.svg`;
2078
- break;
2079
- case 2:
2080
- h2.src = `${t3}/2.svg`, h2.onerror = () => h2.src = `${o}/2.svg`;
2081
- break;
2082
- case 3:
2083
- h2.src = `${t3}/6.svg`, h2.onerror = () => h2.src = `${o}/6.svg`;
2084
- break;
2085
- case 4:
2086
- h2.src = `${t3}/9.svg`, h2.onerror = () => h2.src = `${o}/9.svg`;
2087
- break;
2088
- case 5:
2089
- h2.src = `${t3}/10.svg`, h2.onerror = () => h2.src = `${o}/10.svg`;
2090
- }
2091
- else {
2092
- const i3 = Math.round(10 / (p - m) * (e4 - m));
2093
- h2.src = `${t3}/${i3}.svg`, h2.onerror = () => h2.src = `${o}/${i3}.svg`;
2094
- }
2095
- const f = document.createElement("input");
2096
- f.id = `rating-${s}-${e4}`, f.type = "radio", f.name = s, f.value = e4.toString(), f.classList.add(c), f.classList.add("magicfeedback-input"), (0, r.autoAdvanceOn)(f, i2), a && a === f.value && (f.checked = true), l2.appendChild(f), l2.appendChild(h2), l2.appendChild(d2), n2.appendChild(l2), u.appendChild(n2);
2097
- }
2098
- if ((null == l ? void 0 : l.extraOption) && (null == l ? void 0 : l.extraOptionText)) {
2099
- const e4 = document.createElement("div");
2100
- e4.classList.add("magicfeedback-rating-option");
2101
- const t4 = document.createElement("label");
2102
- t4.htmlFor = `rating-${s}-extra`, t4.classList.add("magicfeedback-rating-option-label-container");
2103
- const n2 = document.createElement("label");
2104
- n2.htmlFor = `rating-${s}-extra`, n2.textContent = null == l ? void 0 : l.extraOptionText;
2105
- const o2 = document.createElement("img");
2106
- o2.src = "https://magicfeedback-c6458-dev.web.app/assets/question.svg", o2.alt = `face-${s}-extra`, o2.className = "magicfeedback-rating-image-extra";
2107
- const a2 = document.createElement("input");
2108
- a2.id = `rating-${s}-extra`, a2.type = "radio", a2.name = s, a2.value = "-", a2.classList.add(c), a2.classList.add("magicfeedback-input"), (0, r.autoAdvanceOn)(a2, i2), t4.appendChild(a2), t4.appendChild(o2), t4.appendChild(n2), e4.appendChild(t4), u.appendChild(e4);
2109
- }
2110
- return h.childElementCount > 0 && u.appendChild(h), d.appendChild(u), { element: d, elementTypeClass: c };
2111
- };
2112
- }, 2255: (e2, t2, i) => {
2113
- "use strict";
2114
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderRatingNumber = void 0;
2115
- const n = i(2709);
2116
- t2.renderRatingNumber = ({ question: e3, order: t3, direction: i2, send: r, urlParamValue: o, language: a, isPhone: s, productId: l }) => {
2117
- const d = "magicfeedback-rating-number";
2118
- return { element: (0, n.createRatingNumberElement)(e3.ref, e3.assets, t3, i2, d, r, o, a, { legacy: (0, n.usesLegacyRatingNumber)(l), isPhone: s }), elementTypeClass: d };
2119
- };
2120
- }, 1042: (e2, t2, i) => {
2121
- "use strict";
2122
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderRatingStar = void 0;
2123
- const n = i(2709);
2124
- t2.renderRatingStar = ({ question: e3, send: t3, urlParamValue: i2 }) => {
2125
- var r, o;
2126
- const a = document.createElement("div"), s = (0, n.createStarRating)(e3.ref, null === (r = e3.assets) || void 0 === r ? void 0 : r.minPlaceholder, null === (o = e3.assets) || void 0 === o ? void 0 : o.maxPlaceholder, t3, i2);
2127
- return a.appendChild(s), { element: a, elementTypeClass: "magicfeedback-rating-star" };
2128
- };
2129
- }, 2311: (e2, t2, i) => {
2130
- "use strict";
2131
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderSelect = void 0;
2132
- const n = i(1366), r = i(7627);
2133
- t2.renderSelect = ({ question: e3, format: t3, language: i2, urlParamValue: o }) => {
2134
- const { title: a, value: s, defaultValue: l } = e3, d = document.createElement("select"), c = document.createElement("option");
2135
- return c.value = "", c.text = "slim" === t3 ? (0, n.parseTitle)(a, i2) : l || (0, r.t)(i2, "select.placeholder"), c.disabled = true, c.selected = true, d.appendChild(c), s.forEach(((e4) => {
2136
- const t4 = document.createElement("option");
2137
- t4.value = e4, t4.text = e4, d.appendChild(t4);
2138
- })), o && s.includes(o) && (d.value = o), { element: d, elementTypeClass: "magicfeedback-select" };
2139
- };
2140
- }, 8924: (e2, t2, i) => {
2141
- "use strict";
2142
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderText = void 0;
2143
- const n = i(3262);
2144
- t2.renderText = ({ language: e3, placeholderText: t3, urlParamValue: i2, send: r }) => {
2145
- const o = document.createElement("input");
2146
- return o.type = "text", o.placeholder = t3 || n.placeholder.answer(e3 || "en"), i2 && (o.value = i2), o.addEventListener("keyup", ((e4) => {
2147
- e4.preventDefault(), "Enter" === e4.key && r && r();
2148
- })), { element: o, elementTypeClass: "magicfeedback-text" };
2149
- };
2150
- }, 1724: (e2, t2, i) => {
2151
- "use strict";
2152
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderUploadFile = void 0;
2153
- const n = i(8129);
2154
- t2.renderUploadFile = ({ question: e3, language: t3 }) => (0, n.createUploadControl)(e3, t3, "file");
2155
- }, 9169: (e2, t2, i) => {
2156
- "use strict";
2157
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderUploadImage = void 0;
2158
- const n = i(8129);
2159
- t2.renderUploadImage = ({ question: e3, language: t3 }) => (0, n.createUploadControl)(e3, t3, "image");
2160
- }, 8129: function(e2, t2, i) {
2161
- "use strict";
2162
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
2163
- return new (i2 || (i2 = Promise))((function(r2, o2) {
2164
- function a2(e4) {
2165
- try {
2166
- l2(n2.next(e4));
2167
- } catch (e5) {
2168
- o2(e5);
2169
- }
2170
- }
2171
- function s2(e4) {
2172
- try {
2173
- l2(n2.throw(e4));
2174
- } catch (e5) {
2175
- o2(e5);
2176
- }
2177
- }
2178
- function l2(e4) {
2179
- var t4;
2180
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
2181
- e5(t4);
2182
- }))).then(a2, s2);
2183
- }
2184
- l2((n2 = n2.apply(e3, t3 || [])).next());
2185
- }));
2186
- };
2187
- Object.defineProperty(t2, "__esModule", { value: true }), t2.createUploadControl = t2.awaitUploadReady = t2.getUploadValues = t2.formatFileSize = void 0;
2188
- const r = i(3262), o = i(1366), a = "__mfUploadValues", s = "__mfUploadReady";
2189
- function l(e3) {
2190
- if ("number" != typeof e3 || isNaN(e3)) return "";
2191
- if (e3 < 1024) return `${e3} B`;
2192
- const t3 = e3 / 1024;
2193
- if (t3 < 1024) return `${t3 < 10 ? t3.toFixed(1) : Math.round(t3)} KB`;
2194
- const i2 = t3 / 1024;
2195
- return `${i2 < 10 ? i2.toFixed(1) : Math.round(i2)} MB`;
2196
- }
2197
- t2.formatFileSize = l, t2.getUploadValues = function(e3) {
2198
- const t3 = e3[a];
2199
- return Array.isArray(t3) ? t3 : [];
2200
- }, t2.awaitUploadReady = function(e3) {
2201
- return n(this, void 0, void 0, (function* () {
2202
- if (!e3) return;
2203
- const t3 = Array.from(e3.querySelectorAll(".magicfeedback-upload-native"));
2204
- yield Promise.all(t3.map(((e4) => e4[s])).filter(Boolean));
2205
- }));
2206
- }, t2.createUploadControl = function(e3, t3, i2) {
2207
- const { ref: n2, require: d, title: c, assets: u } = e3, p = "image" === i2 ? "magicfeedback-upload-image" : "magicfeedback-upload-file", m = (null == u ? void 0 : u.multiple) || false, h = m ? (null == u ? void 0 : u.maxFiles) || 0 : 1, f = Number(null == u ? void 0 : u.maxFileSize) > 0 ? Number(null == u ? void 0 : u.maxFileSize) : 0, g = 1024 * f * 1024, y = document.createElement("div");
2208
- y.classList.add("magicfeedback-upload");
2209
- const v = document.createElement("input");
2210
- v.type = "file", "image" === i2 && (v.accept = "image/*"), v.multiple = m, v.required = d, v.name = n2, v.id = `magicfeedback-upload-input-${n2}`, v.classList.add(p), v.classList.add("magicfeedback-input"), v.classList.add("magicfeedback-upload-native"), v[a] = [], v[s] = Promise.resolve();
2211
- const b = (0, o.parseTitle)(c, t3);
2212
- b && v.setAttribute("aria-label", b);
2213
- const E = document.createElement("div");
2214
- E.classList.add("magicfeedback-upload-dropzone");
2215
- const A = document.createElement("span");
2216
- A.classList.add("magicfeedback-upload-icon"), A.innerHTML = "image" === i2 ? '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="M21 15l-5-5L5 21"/></svg>' : '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M16 16l-4-4-4 4"/><path d="M12 12v9"/><path d="M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3"/></svg>';
2217
- const k = document.createElement("span");
2218
- k.classList.add("magicfeedback-upload-cta"), k.textContent = r.placeholder.upload.cta(t3);
2219
- const T = document.createElement("span");
2220
- T.classList.add("magicfeedback-upload-hint"), T.textContent = (function(e4, t4, i3, n3, o2) {
2221
- const a2 = [r.placeholder.upload.formats(e4, t4)];
2222
- return i3 && n3 > 0 && a2.push(r.placeholder.upload.maxFiles(e4, n3)), o2 > 0 && a2.push(r.placeholder.upload.maxSize(e4, o2)), a2.filter(Boolean).join(" \xB7 ");
2223
- })(t3, i2, m, h, f), E.appendChild(v), E.appendChild(A), E.appendChild(k), E.appendChild(T);
2224
- const C = document.createElement("div");
2225
- C.classList.add("magicfeedback-upload-error");
2226
- const P = document.createElement("ul");
2227
- P.classList.add("magicfeedback-upload-list"), y.appendChild(E), y.appendChild(C), y.appendChild(P);
2228
- const S = /* @__PURE__ */ new WeakMap(), w = (e4) => {
2229
- const t4 = S.get(e4);
2230
- return t4 ? Promise.resolve(t4) : new Promise(((t5) => {
2231
- const i3 = new FileReader(), n3 = (i4) => {
2232
- const n4 = JSON.stringify({ name: e4.name, type: e4.type, size: e4.size, content: i4 });
2233
- S.set(e4, n4), t5(n4);
2234
- };
2235
- i3.onload = () => n3("string" == typeof i3.result ? i3.result : ""), i3.onerror = () => n3(""), i3.readAsDataURL(e4);
2236
- }));
2237
- }, O = [], x = (e4) => {
2238
- try {
2239
- const t4 = h > 0 ? e4.slice(0, h) : e4, i3 = new DataTransfer();
2240
- t4.forEach(((e5) => i3.items.add(e5))), v.files = i3.files;
2241
- } catch (e5) {
2242
- }
2243
- !(function() {
2244
- O.forEach(((e6) => URL.revokeObjectURL(e6))), O.length = 0, P.innerHTML = "";
2245
- const e5 = Array.from(v.files || []);
2246
- y.classList.toggle("magicfeedback-upload--has-files", e5.length > 0), e5.forEach(((e6, n3) => {
2247
- const o2 = document.createElement("li");
2248
- o2.classList.add("magicfeedback-upload-file-item");
2249
- const a2 = document.createElement("span");
2250
- if (a2.classList.add("magicfeedback-upload-thumb"), "image" === i2 && e6.type.startsWith("image/")) {
2251
- const t4 = URL.createObjectURL(e6);
2252
- O.push(t4);
2253
- const i3 = document.createElement("img");
2254
- i3.src = t4, i3.alt = e6.name, a2.appendChild(i3);
2255
- } else a2.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/></svg>';
2256
- const s2 = document.createElement("span");
2257
- s2.classList.add("magicfeedback-upload-file-info");
2258
- const d2 = document.createElement("span");
2259
- d2.classList.add("magicfeedback-upload-file-name"), d2.textContent = e6.name, d2.title = e6.name;
2260
- const c2 = document.createElement("span");
2261
- c2.classList.add("magicfeedback-upload-file-size"), c2.textContent = l(e6.size), s2.appendChild(d2), s2.appendChild(c2);
2262
- const u2 = document.createElement("button");
2263
- u2.type = "button", u2.classList.add("magicfeedback-upload-remove"), u2.setAttribute("aria-label", `${r.placeholder.upload.remove(t3)}: ${e6.name}`), u2.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>', u2.addEventListener("click", ((e7) => {
2264
- e7.preventDefault(), e7.stopPropagation(), x(Array.from(v.files || []).filter(((e8, t4) => t4 !== n3)));
2265
- })), o2.appendChild(a2), o2.appendChild(s2), o2.appendChild(u2), P.appendChild(o2);
2266
- }));
2267
- })(), (() => {
2268
- const e5 = Array.from(v.files || []), t4 = Promise.all(e5.map(w)).then(((e6) => {
2269
- v[a] = e6;
2270
- }));
2271
- v[s] = t4;
2272
- })();
2273
- }, L = (e4) => {
2274
- if (!e4.length) return C.textContent = "", void C.classList.remove("is-visible");
2275
- const i3 = e4.map(((e5) => e5.name)).join(", ");
2276
- C.textContent = `${r.placeholder.upload.tooLarge(t3, f)}: ${i3}`, C.classList.add("is-visible");
2277
- }, N = (e4) => {
2278
- if (!g) return { accepted: e4, rejected: [] };
2279
- const t4 = [], i3 = [];
2280
- return e4.forEach(((e5) => (e5.size <= g ? t4 : i3).push(e5))), { accepted: t4, rejected: i3 };
2281
- };
2282
- v.addEventListener("change", (() => {
2283
- const { accepted: e4, rejected: t4 } = N(Array.from(v.files || []));
2284
- L(t4), x(e4);
2285
- }));
2286
- const I = (e4) => {
2287
- e4.preventDefault(), e4.stopPropagation();
2288
- };
2289
- return ["dragenter", "dragover"].forEach(((e4) => E.addEventListener(e4, ((e5) => {
2290
- I(e5), E.classList.add("is-dragover");
2291
- })))), ["dragleave", "dragend"].forEach(((e4) => E.addEventListener(e4, ((e5) => {
2292
- I(e5), E.classList.remove("is-dragover");
2293
- })))), E.addEventListener("drop", ((e4) => {
2294
- I(e4), E.classList.remove("is-dragover");
2295
- const t4 = e4.dataTransfer;
2296
- let n3 = t4 ? Array.from(t4.files) : [];
2297
- if ("image" === i2 && (n3 = n3.filter(((e5) => e5.type.startsWith("image/")))), !n3.length) return;
2298
- const { accepted: r2, rejected: o2 } = N(n3);
2299
- if (L(o2), !r2.length) return;
2300
- const a2 = m ? Array.from(v.files || []) : [];
2301
- x(a2.concat(r2));
2302
- })), { element: y, elementTypeClass: p };
2303
- };
2304
- }, 4759: function(e2, t2, i) {
2305
- "use strict";
2306
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
2307
- return new (i2 || (i2 = Promise))((function(r2, o2) {
2308
- function a2(e4) {
2309
- try {
2310
- l2(n2.next(e4));
2311
- } catch (e5) {
2312
- o2(e5);
2313
- }
2314
- }
2315
- function s2(e4) {
2316
- try {
2317
- l2(n2.throw(e4));
2318
- } catch (e5) {
2319
- o2(e5);
2320
- }
2321
- }
2322
- function l2(e4) {
2323
- var t4;
2324
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
2325
- e5(t4);
2326
- }))).then(a2, s2);
2327
- }
2328
- l2((n2 = n2.apply(e3, t3 || [])).next());
2329
- }));
2330
- }, r = this && this.__importDefault || function(e3) {
2331
- return e3 && e3.__esModule ? e3 : { default: e3 };
2332
- };
2333
- Object.defineProperty(t2, "__esModule", { value: true }), t2.nextAgentTurn = t2.startAgentSurvey = void 0;
2334
- const o = r(i(6539)), a = i(9071), s = i(5407), l = i(3501);
2335
- function d(e3, t3, i2, r2, s2) {
2336
- var d2;
2337
- return n(this, void 0, void 0, (function* () {
2338
- let n2;
2339
- try {
2340
- n2 = yield (0, o.default)(e3 + t3, { method: "POST", headers: Object.assign({ "Content-Type": "application/json" }, a.header), body: JSON.stringify(i2) });
2341
- } catch (e4) {
2342
- throw r2.err(`[agentSurvey/${s2}] network error`, e4), new l.AgentApiError("NETWORK", (null == e4 ? void 0 : e4.message) || "Network error");
2343
- }
2344
- if (!n2.ok) {
2345
- let e4 = null;
2346
- try {
2347
- e4 = yield n2.json();
2348
- } catch (e5) {
2349
- }
2350
- const t4 = (0, l.mapAgentStatus)(n2.status, s2);
2351
- throw r2.err(`[agentSurvey/${s2}] ${n2.status}`, e4), new l.AgentApiError(t4, (null === (d2 = null == e4 ? void 0 : e4.error) || void 0 === d2 ? void 0 : d2.message) || (null == e4 ? void 0 : e4.message) || n2.statusText, n2.status, "RATE_LIMITED" === t4 ? (function(e5) {
2352
- var t5, i3;
2353
- const n3 = null === (i3 = null === (t5 = null == e5 ? void 0 : e5.headers) || void 0 === t5 ? void 0 : t5.get) || void 0 === i3 ? void 0 : i3.call(t5, "Retry-After"), r3 = n3 ? Number(n3) : NaN;
2354
- return Number.isFinite(r3) && r3 > 0 ? 1e3 * r3 : 6e4;
2355
- })(n2) : void 0, e4);
2356
- }
2357
- try {
2358
- const e4 = yield n2.json();
2359
- return r2.log(`[agentSurvey/${s2}] ok`, e4), e4;
2360
- } catch (e4) {
2361
- throw new l.AgentApiError("MALFORMED", "Unreadable response body", n2.status);
2362
- }
2363
- }));
2364
- }
2365
- t2.startAgentSurvey = function(e3, t3, i2) {
2366
- return d(e3, s.endpoints.sdk.agentSurveyStart, t3, i2, "start");
2367
- }, t2.nextAgentTurn = function(e3, t3, i2) {
2368
- return d(e3, s.endpoints.sdk.agentSurveyNext, t3, i2, "next");
2369
- };
2370
- }, 3501: (e2, t2) => {
2371
- "use strict";
2372
- Object.defineProperty(t2, "__esModule", { value: true }), t2.mapAgentStatus = t2.AgentApiError = void 0;
2373
- class i extends Error {
2374
- constructor(e3, t3, n, r, o) {
2375
- super(t3), this.kind = e3, this.status = n, this.retryAfterMs = r, this.body = o, this.name = "AgentApiError", Object.setPrototypeOf(this, i.prototype);
2376
- }
2377
- get retryable() {
2378
- return "RATE_LIMITED" === this.kind || "AI_UNAVAILABLE" === this.kind || "NETWORK" === this.kind;
2379
- }
2380
- }
2381
- t2.AgentApiError = i, t2.mapAgentStatus = function(e3, t3) {
2382
- return 429 === e3 ? "RATE_LIMITED" : 406 === e3 || 401 === e3 || 403 === e3 ? "AUTH" : 404 === e3 ? "NOT_FOUND" : 400 === e3 || 422 === e3 ? "BAD_CONFIG" : e3 >= 500 ? "start" === t3 ? "AI_UNAVAILABLE" : "NETWORK" : "MALFORMED";
2383
- };
2384
- }, 1351: (e2, t2, i) => {
2385
- "use strict";
2386
- Object.defineProperty(t2, "__esModule", { value: true }), t2.encodeAnswer = t2.toAgentStep = t2.ratingBounds = t2.mapAgentType = t2.DEFAULT_ANSWER_DELIMITER = void 0;
2387
- const n = i(4760), r = i(1366);
2388
- t2.DEFAULT_ANSWER_DELIMITER = ", ";
2389
- const o = [n.FEEDBACKAPPANSWERTYPE.RADIO, n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE, n.FEEDBACKAPPANSWERTYPE.SELECT, n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE], a = Object.values(n.FEEDBACKAPPANSWERTYPE);
2390
- function s(e3, t3, i2) {
2391
- var s2, l2, d2;
2392
- const c2 = String(e3 || "").trim().toUpperCase();
2393
- return "RATING" === c2 ? n.FEEDBACKAPPANSWERTYPE.RATING_NUMBER : c2 === n.FEEDBACKAPPANSWERTYPE.CONTACT ? (null === (s2 = i2.log) || void 0 === s2 || s2.log("[agentSurvey] CONTACT has no renderer, falling back to TEXT"), n.FEEDBACKAPPANSWERTYPE.TEXT) : a.includes(c2) ? o.includes(c2) && 0 === t3.length ? (null === (d2 = i2.log) || void 0 === d2 || d2.err(`[agentSurvey] ${c2} arrived with no options, falling back to TEXT`), n.FEEDBACKAPPANSWERTYPE.TEXT) : c2 !== n.FEEDBACKAPPANSWERTYPE.BOOLEAN || 2 !== t3.length || (function(e4, t4) {
2394
- if (2 !== e4.length) return false;
2395
- const i3 = e4.map(((e5) => String(e5).trim().toLowerCase())), n2 = (0, r.getBooleanOptions)(t4).map(((e5) => e5.toLowerCase())), o2 = ["yes", "no"];
2396
- return i3[0] === o2[0] && i3[1] === o2[1] || i3[0] === n2[0] && i3[1] === n2[1];
2397
- })(t3, i2.language) ? c2 : n.FEEDBACKAPPANSWERTYPE.RADIO : (null === (l2 = i2.log) || void 0 === l2 || l2.err(`[agentSurvey] unknown question type "${e3}", falling back to TEXT`), n.FEEDBACKAPPANSWERTYPE.TEXT);
2398
- }
2399
- function l(e3) {
2400
- const t3 = e3.map(Number).filter(((e4) => Number.isFinite(e4)));
2401
- return t3.length >= 2 ? { min: Math.min(...t3), max: Math.max(...t3) } : { min: 1, max: 5 };
2402
- }
2403
- function d(e3, t3, i2) {
2404
- const r2 = { randomPosition: false, direction: "row", order: "ltr" };
2405
- return e3 !== n.FEEDBACKAPPANSWERTYPE.RATING_NUMBER && e3 !== n.FEEDBACKAPPANSWERTYPE.RATING_EMOJI || Object.assign(r2, l(t3)), e3 === n.FEEDBACKAPPANSWERTYPE.LONGTEXT && (r2.maxCharacters = 0), Object.assign(Object.assign({}, r2), (null == i2 ? void 0 : i2.assets) || {});
2406
- }
2407
- function c(e3, t3, i2) {
2408
- var n2, r2, o2, a2;
2409
- const { full: l2, title: c2 } = t3, u = [...null !== (r2 = null !== (n2 = e3.questionValues) && void 0 !== n2 ? n2 : null == l2 ? void 0 : l2.value) && void 0 !== r2 ? r2 : []], p = s(null !== (o2 = null == l2 ? void 0 : l2.type) && void 0 !== o2 ? o2 : e3.questionType, u, i2), m = e3.questionRef || (null == l2 ? void 0 : l2.ref) || `agent-q-${e3.currentTurn}`;
2410
- return { id: (null == l2 ? void 0 : l2.id) || `agent-${i2.sessionId}-${e3.currentTurn}`, title: c2 || "", type: p, questionType: { conf: null }, ref: m, require: null === (a2 = null == l2 ? void 0 : l2.require) || void 0 === a2 || a2, external_id: (null == l2 ? void 0 : l2.external_id) || "", value: u, defaultValue: (null == l2 ? void 0 : l2.defaultValue) || "", followup: false, position: e3.currentTurn, assets: d(p, u, l2), refMetric: (null == l2 ? void 0 : l2.refMetric) || "", integrationId: i2.integrationId, integrationPageId: "", status: "ACTIVE" };
2411
- }
2412
- t2.mapAgentType = s, t2.ratingBounds = l, t2.toAgentStep = function(e3, t3) {
2413
- var i2, r2, o2;
2414
- const a2 = e3, s2 = e3.currentTurn, l2 = e3.maxTurns, d2 = a2.coverageSummary, u = (e4) => ({ kind: "END", reason: e4, currentTurn: s2, maxTurns: l2, coverageSummary: d2 });
2415
- if (a2.answerType === n.AGENT_ANSWER_TYPE_BLOCKED) return u("BLOCKED");
2416
- if (true === a2.shouldEnd) return u("SHOULD_END");
2417
- const p = (function(e4) {
2418
- const t4 = e4.question && "object" == typeof e4.question ? e4.question : e4.nextQuestion && "object" == typeof e4.nextQuestion ? e4.nextQuestion : null;
2419
- if (t4) {
2420
- const e5 = t4, i3 = e5.title;
2421
- return { full: e5, title: "string" == typeof i3 ? i3 : i3 ? JSON.stringify(i3) : null };
2422
- }
2423
- return { full: null, title: "string" == typeof e4.nextQuestion ? e4.nextQuestion : null };
2424
- })(e3);
2425
- return "NONE" === String(null !== (o2 = null !== (r2 = null === (i2 = p.full) || void 0 === i2 ? void 0 : i2.type) && void 0 !== r2 ? r2 : e3.questionType) && void 0 !== o2 ? o2 : "").trim().toUpperCase() ? u("TYPE_NONE") : p.title && p.title.trim() ? { kind: "QUESTION", question: c(e3, p, t3), isFromBase: true === e3.isFromBase, currentTurn: s2, maxTurns: l2, topic: a2.topic, coverageGaps: e3.coverageGaps, coverageSummary: d2 } : u("NO_QUESTION");
2426
- }, t2.encodeAnswer = function(e3, i2, n2 = t2.DEFAULT_ANSWER_DELIMITER) {
2427
- const r2 = i2.ref, o2 = (e4) => e4.flatMap(((e5) => Array.isArray(e5.value) ? e5.value : [e5.value])).map(((e5) => "string" == typeof e5 ? e5 : JSON.stringify(e5))).map(((e5) => (e5 || "").trim())).filter(((e5) => "" !== e5)), a2 = o2(e3.filter(((e4) => e4.key === r2))), s2 = o2(e3.filter(((e4) => e4.key === `extra-option-${r2}`)));
2428
- return [a2.filter(((e4, t3) => a2.indexOf(e4) === t3)).join(n2), s2.join(n2)].filter(((e4) => "" !== e4)).join(n2);
2429
- };
2430
- }, 5349: (e2, t2, i) => {
2431
- "use strict";
2432
- Object.defineProperty(t2, "__esModule", { value: true }), t2.scrapeInputs = void 0;
2433
- const n = i(8129);
2434
- t2.scrapeInputs = function(e3) {
2435
- const t3 = e3.querySelectorAll(".magicfeedback-input"), i2 = [], r = {};
2436
- return t3.forEach(((e4) => {
2437
- var t4;
2438
- const o = e4, a = o.name;
2439
- if (!a) return;
2440
- const s = o.type;
2441
- if (("radio" === s || "checkbox" === s) && !o.checked) return;
2442
- const l = o.value, d = o.classList[0];
2443
- if ((null == d ? void 0 : d.includes("magicfeedback-priority-list")) || (null === (t4 = o.id) || void 0 === t4 ? void 0 : t4.startsWith("priority-list-"))) return r[a] || (r[a] = []), void r[a].push(l);
2444
- if (null == d ? void 0 : d.includes("magicfeedback-upload")) {
2445
- const e5 = (0, n.getUploadValues)(o);
2446
- return void (e5.length && i2.push({ key: a, value: e5 }));
2447
- }
2448
- const c = "magicfeedback-consent" === d ? o.checked.toString() : l;
2449
- null != c && i2.push({ key: a, value: [c] });
2450
- })), Object.entries(r).forEach((([e4, t4]) => {
2451
- const n2 = t4.slice().sort(((e5, t5) => Number(e5.split(".")[0]) - Number(t5.split(".")[0])));
2452
- i2.push({ key: e4, value: n2 });
2453
- })), i2;
2454
- };
2455
- }, 7627: (e2, t2) => {
2456
- "use strict";
2457
- Object.defineProperty(t2, "__esModule", { value: true }), t2.t = t2.isLanguageSupported = t2.isRtlLanguage = t2.hasOwnTranslation = t2.TRANSLATION_KEYS = t2.normalizeLanguage = t2.RTL_LANGUAGES = t2.AVAILABLE_LANGUAGES = t2.SUPPORTED_LANGUAGES = void 0;
2458
- const i = { "placeholder.answer": "Write your answer here...", "placeholder.number": "Write your number here...", "placeholder.email": "Write your email here...", "placeholder.date": "Write your date here...", "placeholder.password": "Write your password here...", "pointSystem.error": "The total points must be 100 %", "boolean.yes": "Yes", "boolean.no": "No", "upload.cta": "Drag & drop or click to upload", "upload.imagesOnly": "Images only", "upload.anyFileType": "Any file type", "upload.maxFiles": "Max {n} files", "upload.maxSize": "Max {mb} MB", "upload.tooLarge": "File is too large (max {mb} MB)", "upload.remove": "Remove", "select.placeholder": "Select an option", "rating.ariaLabel": "Rating", "maxDiff.best": "Most important", "maxDiff.worst": "Least important", "maxDiff.setProgress": "Block {k} of {n}", "priority.selectUpTo": "Select up to", "priority.options": "options", "priority.thenOrder": "and then order them", "priority.selectOptions": "Select options", "priority.cancel": "Cancel", "priority.confirm": "Confirm", "priority.selectOptionNumber": "Select option #", "priority.prioritized": "Prioritized", "priority.of": "of", "priority.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.", "action.send": "Send", "action.back": "Back", "action.next": "Next", "action.start": "Go!", "message.success": "Thank you for your feedback!", "message.blocked": "Thanks for your time - we'll end the conversation here.", "message.required": "Please answer before continuing.", "message.rateLimit": "Too many requests. Retrying in {seconds}s..." }, n = { en: i, es: { "placeholder.answer": "Escribe tu respuesta aqu\xED...", "placeholder.number": "Escribe tu n\xFAmero aqu\xED...", "placeholder.email": "Escribe tu correo electr\xF3nico aqu\xED...", "placeholder.date": "Escribe tu fecha aqu\xED...", "placeholder.password": "Escribe tu contrase\xF1a aqu\xED...", "pointSystem.error": "El total de puntos debe ser 100 %", "boolean.yes": "S\xED", "boolean.no": "No", "upload.cta": "Arrastra y suelta o haz clic para subir", "upload.imagesOnly": "Solo im\xE1genes", "upload.anyFileType": "Cualquier tipo de archivo", "upload.maxFiles": "M\xE1x. {n} archivos", "upload.maxSize": "M\xE1x. {mb} MB", "upload.tooLarge": "Archivo demasiado grande (m\xE1x. {mb} MB)", "upload.remove": "Eliminar", "select.placeholder": "Selecciona una opci\xF3n", "rating.ariaLabel": "Valoraci\xF3n", "maxDiff.best": "M\xE1s importante", "maxDiff.worst": "Menos importante", "maxDiff.setProgress": "Bloque {k} de {n}", "priority.selectUpTo": "Selecciona hasta", "priority.options": "opciones", "priority.thenOrder": "y luego ord\xE9nalas", "priority.selectOptions": "Seleccionar opciones", "priority.cancel": "Cancelar", "priority.confirm": "Confirmar", "priority.selectOptionNumber": "Selecciona la opci\xF3n #", "priority.prioritized": "Priorizadas", "priority.of": "de", "priority.instruction": 'Tu lista priorizada se muestra abajo. Si deseas, puedes reordenar las opciones con las flechas. Haz clic en "Siguiente" para confirmar y continuar.', "action.send": "Enviar", "action.back": "Atr\xE1s", "action.next": "Siguiente", "action.start": "\xA1Empezar!", "message.success": "\xA1Gracias por tus comentarios!", "message.blocked": "Gracias por tu tiempo, terminamos aqu\xED la conversaci\xF3n.", "message.required": "Por favor, responde antes de continuar.", "message.rateLimit": "Demasiadas solicitudes. Reintentando en {seconds} s..." }, de: { "placeholder.answer": "Schreiben Sie hier Ihre Antwort...", "placeholder.number": "Geben Sie hier Ihre Zahl ein...", "placeholder.email": "Geben Sie hier Ihre E-Mail-Adresse ein...", "placeholder.date": "Geben Sie hier Ihr Datum ein...", "placeholder.password": "Geben Sie hier Ihr Passwort ein...", "pointSystem.error": "Die Gesamtpunktzahl muss 100 % betragen", "boolean.yes": "Ja", "boolean.no": "Nein", "upload.cta": "Ziehen Sie Dateien hierher oder klicken Sie zum Hochladen", "upload.imagesOnly": "Nur Bilder", "upload.anyFileType": "Beliebiger Dateityp", "upload.maxFiles": "Max. {n} Dateien", "upload.maxSize": "Max. {mb} MB", "upload.tooLarge": "Datei ist zu gro\xDF (max. {mb} MB)", "upload.remove": "Entfernen", "select.placeholder": "Option ausw\xE4hlen", "rating.ariaLabel": "Bewertung", "maxDiff.best": "Am wichtigsten", "maxDiff.worst": "Am wenigsten wichtig", "maxDiff.setProgress": "Block {k} von {n}", "priority.selectUpTo": "W\xE4hlen Sie bis zu", "priority.options": "Optionen", "priority.thenOrder": "und ordnen Sie sie dann", "priority.selectOptions": "Optionen ausw\xE4hlen", "priority.cancel": "Abbrechen", "priority.confirm": "Best\xE4tigen", "priority.selectOptionNumber": "W\xE4hlen Sie Option #", "priority.prioritized": "Priorisiert", "priority.of": "von", "priority.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.', "action.send": "Senden", "action.back": "Zur\xFCck", "action.next": "Weiter", "action.start": "Los!", "message.success": "Vielen Dank f\xFCr Ihr Feedback!", "message.blocked": "Danke f\xFCr Ihre Zeit - wir beenden das Gespr\xE4ch hier.", "message.required": "Bitte antworten Sie, bevor Sie fortfahren.", "message.rateLimit": "Zu viele Anfragen. Erneuter Versuch in {seconds} s..." }, fr: { "placeholder.answer": "\xC9crivez votre r\xE9ponse ici...", "placeholder.number": "\xC9crivez votre nombre ici...", "placeholder.email": "\xC9crivez votre e-mail ici...", "placeholder.date": "\xC9crivez votre date ici...", "placeholder.password": "\xC9crivez votre mot de passe ici...", "pointSystem.error": "Le total des points doit \xEAtre de 100 %", "boolean.yes": "Oui", "boolean.no": "Non", "upload.cta": "Glissez-d\xE9posez ou cliquez pour t\xE9l\xE9verser", "upload.imagesOnly": "Images uniquement", "upload.anyFileType": "Tout type de fichier", "upload.maxFiles": "Max. {n} fichiers", "upload.maxSize": "Max. {mb} Mo", "upload.tooLarge": "Fichier trop volumineux (max. {mb} Mo)", "upload.remove": "Supprimer", "select.placeholder": "S\xE9lectionnez une option", "rating.ariaLabel": "\xC9valuation", "maxDiff.best": "Le plus important", "maxDiff.worst": "Le moins important", "maxDiff.setProgress": "Bloc {k} sur {n}", "priority.selectUpTo": "S\xE9lectionnez jusqu'\xE0", "priority.options": "options", "priority.thenOrder": "puis classez-les", "priority.selectOptions": "S\xE9lectionner des options", "priority.cancel": "Annuler", "priority.confirm": "Confirmer", "priority.selectOptionNumber": "S\xE9lectionnez l'option #", "priority.prioritized": "Prioris\xE9es", "priority.of": "sur", "priority.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.`, "action.send": "Envoyer", "action.back": "Retour", "action.next": "Suivant", "action.start": "C'est parti !", "message.success": "Merci pour votre retour !", "message.blocked": "Merci pour votre temps, nous terminons la conversation ici.", "message.required": "Veuillez r\xE9pondre avant de continuer.", "message.rateLimit": "Trop de requ\xEAtes. Nouvelle tentative dans {seconds} s..." }, pt: { "placeholder.answer": "Escreva sua resposta aqui...", "placeholder.number": "Escreva seu n\xFAmero aqui...", "placeholder.email": "Escreva seu e-mail aqui...", "placeholder.date": "Escreva sua data aqui...", "placeholder.password": "Escreva sua senha aqui...", "pointSystem.error": "O total de pontos deve ser 100 %", "boolean.yes": "Sim", "boolean.no": "N\xE3o", "upload.cta": "Arraste e solte ou clique para enviar", "upload.imagesOnly": "Somente imagens", "upload.anyFileType": "Qualquer tipo de arquivo", "upload.maxFiles": "M\xE1x. {n} arquivos", "upload.maxSize": "M\xE1x. {mb} MB", "upload.tooLarge": "Arquivo muito grande (m\xE1x. {mb} MB)", "upload.remove": "Remover", "select.placeholder": "Selecione uma op\xE7\xE3o", "rating.ariaLabel": "Avalia\xE7\xE3o", "maxDiff.best": "Mais importante", "maxDiff.worst": "Menos importante", "maxDiff.setProgress": "Bloco {k} de {n}", "priority.selectUpTo": "Selecione at\xE9", "priority.options": "op\xE7\xF5es", "priority.thenOrder": "e depois ordene-as", "priority.selectOptions": "Selecionar op\xE7\xF5es", "priority.cancel": "Cancelar", "priority.confirm": "Confirmar", "priority.selectOptionNumber": "Selecione a op\xE7\xE3o #", "priority.prioritized": "Priorizadas", "priority.of": "de", "priority.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.', "action.send": "Enviar", "action.back": "Voltar", "action.next": "Pr\xF3ximo", "action.start": "Come\xE7ar!", "message.success": "Obrigado pelo seu feedback!", "message.blocked": "Obrigado pelo seu tempo, encerramos a conversa por aqui.", "message.required": "Responda antes de continuar.", "message.rateLimit": "Muitas solicita\xE7\xF5es. Tentando novamente em {seconds} s..." }, da: { "placeholder.answer": "Skriv dit svar her...", "placeholder.number": "Skriv dit nummer her...", "placeholder.email": "Skriv din e-mail her...", "placeholder.date": "Skriv din dato her...", "placeholder.password": "Skriv dit kodeord her...", "pointSystem.error": "Samlet antal point skal v\xE6re 100 %", "boolean.yes": "Ja", "boolean.no": "Nej", "upload.cta": "Tr\xE6k og slip eller klik for at uploade", "upload.imagesOnly": "Kun billeder", "upload.anyFileType": "Enhver filtype", "upload.maxFiles": "Maks. {n} filer", "upload.maxSize": "Maks. {mb} MB", "upload.tooLarge": "Filen er for stor (maks. {mb} MB)", "upload.remove": "Fjern", "select.placeholder": "V\xE6lg en mulighed", "rating.ariaLabel": "Bed\xF8mmelse", "maxDiff.best": "Vigtigst", "maxDiff.worst": "Mindst vigtigt", "maxDiff.setProgress": "Blok {k} af {n}", "priority.selectUpTo": "V\xE6lg op til", "priority.options": "muligheder", "priority.thenOrder": "og sorter dem derefter", "priority.selectOptions": "V\xE6lg muligheder", "priority.cancel": "Annuller", "priority.confirm": "Bekr\xE6ft", "priority.selectOptionNumber": "V\xE6lg mulighed #", "priority.prioritized": "Prioriteret", "priority.of": "af", "priority.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.', "action.send": "Send", "action.back": "Tilbage", "action.next": "N\xE6ste", "action.start": "Start!", "message.success": "Tak for din feedback!", "message.blocked": "Tak for din tid - vi afslutter samtalen her.", "message.required": "Svar venligst, f\xF8r du forts\xE6tter.", "message.rateLimit": "For mange foresp\xF8rgsler. Pr\xF8ver igen om {seconds} s..." }, fi: { "placeholder.answer": "Kirjoita vastauksesi t\xE4h\xE4n...", "placeholder.number": "Kirjoita numerosi t\xE4h\xE4n...", "placeholder.email": "Kirjoita s\xE4hk\xF6postiosoitteesi t\xE4h\xE4n...", "placeholder.date": "Kirjoita p\xE4iv\xE4m\xE4\xE4r\xE4si t\xE4h\xE4n...", "placeholder.password": "Kirjoita salasanasi t\xE4h\xE4n...", "pointSystem.error": "Kokonaispisteiden on oltava 100 %", "boolean.yes": "Kyll\xE4", "boolean.no": "Ei", "upload.cta": "Ved\xE4 ja pudota tai napsauta ladataksesi", "upload.imagesOnly": "Vain kuvat", "upload.anyFileType": "Mik\xE4 tahansa tiedostotyyppi", "upload.maxFiles": "Enint\xE4\xE4n {n} tiedostoa", "upload.maxSize": "Enint\xE4\xE4n {mb} MB", "upload.tooLarge": "Tiedosto on liian suuri (enint\xE4\xE4n {mb} MB)", "upload.remove": "Poista", "select.placeholder": "Valitse vaihtoehto", "rating.ariaLabel": "Arvio", "maxDiff.best": "T\xE4rkein", "maxDiff.worst": "V\xE4hiten t\xE4rke\xE4", "maxDiff.setProgress": "Osa {k}/{n}", "priority.selectUpTo": "Valitse enint\xE4\xE4n", "priority.options": "vaihtoehtoa", "priority.thenOrder": "ja j\xE4rjest\xE4 ne sitten", "priority.selectOptions": "Valitse vaihtoehdot", "priority.cancel": "Peruuta", "priority.confirm": "Vahvista", "priority.selectOptionNumber": "Valitse vaihtoehto #", "priority.prioritized": "Priorisoitu", "priority.of": " / ", "priority.instruction": 'Prioriteettilistasi n\xE4kyy alla. Voit halutessasi j\xE4rjest\xE4\xE4 valinnat uudelleen nuolien avulla. Napsauta "Seuraava" vahvistaaksesi valinnan ja jatkaaksesi.', "action.send": "L\xE4het\xE4", "action.back": "Takaisin", "action.next": "Seuraava", "action.start": "Aloita!", "message.success": "Kiitos palautteestasi!", "message.blocked": "Kiitos ajastasi - lopetamme keskustelun t\xE4h\xE4n.", "message.required": "Vastaa ennen jatkamista.", "message.rateLimit": "Liikaa pyynt\xF6j\xE4. Yritet\xE4\xE4n uudelleen {seconds} s kuluttua..." }, no: { "placeholder.answer": "Skriv svaret ditt her...", "placeholder.number": "Skriv nummeret ditt her...", "placeholder.email": "Skriv e-posten din her...", "placeholder.date": "Skriv datoen din her...", "placeholder.password": "Skriv passordet ditt her...", "pointSystem.error": "Totalt antall poeng m\xE5 v\xE6re 100 %", "boolean.yes": "Ja", "boolean.no": "Nei", "upload.cta": "Dra og slipp eller klikk for \xE5 laste opp", "upload.imagesOnly": "Kun bilder", "upload.anyFileType": "Alle filtyper", "upload.maxFiles": "Maks {n} filer", "upload.maxSize": "Maks {mb} MB", "upload.tooLarge": "Filen er for stor (maks {mb} MB)", "upload.remove": "Fjern", "select.placeholder": "Velg et alternativ", "rating.ariaLabel": "Vurdering", "maxDiff.best": "Viktigst", "maxDiff.worst": "Minst viktig", "maxDiff.setProgress": "Blokk {k} av {n}", "priority.selectUpTo": "Velg opptil", "priority.options": "alternativer", "priority.thenOrder": "og ordne dem deretter", "priority.selectOptions": "Velg alternativer", "priority.cancel": "Avbryt", "priority.confirm": "Bekreft", "priority.selectOptionNumber": "Velg alternativ #", "priority.prioritized": "Prioritert", "priority.of": "av", "priority.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.', "action.send": "Send", "action.back": "Tilbake", "action.next": "Neste", "action.start": "Start!", "message.success": "Takk for tilbakemeldingen!", "message.blocked": "Takk for tiden din - vi avslutter samtalen her.", "message.required": "Vennligst svar f\xF8r du fortsetter.", "message.rateLimit": "For mange foresp\xF8rsler. Pr\xF8ver igjen om {seconds} s..." }, sv: { "placeholder.answer": "Skriv ditt svar h\xE4r...", "placeholder.number": "Skriv ditt nummer h\xE4r...", "placeholder.email": "Skriv din e-post h\xE4r...", "placeholder.date": "Skriv ditt datum h\xE4r...", "placeholder.password": "Skriv ditt l\xF6senord h\xE4r...", "pointSystem.error": "Totala po\xE4ng m\xE5ste vara 100 %", "boolean.yes": "Ja", "boolean.no": "Nej", "upload.cta": "Dra och sl\xE4pp eller klicka f\xF6r att ladda upp", "upload.imagesOnly": "Endast bilder", "upload.anyFileType": "Alla filtyper", "upload.maxFiles": "Max {n} filer", "upload.maxSize": "Max {mb} MB", "upload.tooLarge": "Filen \xE4r f\xF6r stor (max {mb} MB)", "upload.remove": "Ta bort", "select.placeholder": "V\xE4lj ett alternativ", "rating.ariaLabel": "Betyg", "maxDiff.best": "Viktigast", "maxDiff.worst": "Minst viktig", "maxDiff.setProgress": "Block {k} av {n}", "priority.selectUpTo": "V\xE4lj upp till", "priority.options": "alternativ", "priority.thenOrder": "och ordna dem sedan", "priority.selectOptions": "V\xE4lj alternativ", "priority.cancel": "Avbryt", "priority.confirm": "Bekr\xE4fta", "priority.selectOptionNumber": "V\xE4lj alternativ #", "priority.prioritized": "Prioriterat", "priority.of": "av", "priority.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.', "action.send": "Skicka", "action.back": "Tillbaka", "action.next": "N\xE4sta", "action.start": "K\xF6r!", "message.success": "Tack f\xF6r din feedback!", "message.blocked": "Tack f\xF6r din tid - vi avslutar samtalet h\xE4r.", "message.required": "Svara innan du forts\xE4tter.", "message.rateLimit": "F\xF6r m\xE5nga f\xF6rfr\xE5gningar. F\xF6rs\xF6ker igen om {seconds} s..." }, ar: { "placeholder.answer": "\u0627\u0643\u062A\u0628 \u0625\u062C\u0627\u0628\u062A\u0643 \u0647\u0646\u0627...", "placeholder.number": "\u0627\u0643\u062A\u0628 \u0631\u0642\u0645\u0643 \u0647\u0646\u0627...", "placeholder.email": "\u0627\u0643\u062A\u0628 \u0628\u0631\u064A\u062F\u0643 \u0627\u0644\u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A \u0647\u0646\u0627...", "placeholder.date": "\u0627\u0643\u062A\u0628 \u062A\u0627\u0631\u064A\u062E\u0643 \u0647\u0646\u0627...", "placeholder.password": "\u0627\u0643\u062A\u0628 \u0643\u0644\u0645\u0629 \u0627\u0644\u0645\u0631\u0648\u0631 \u0627\u0644\u062E\u0627\u0635\u0629 \u0628\u0643 \u0647\u0646\u0627...", "pointSystem.error": "\u064A\u062C\u0628 \u0623\u0646 \u062A\u0643\u0648\u0646 \u0627\u0644\u0646\u0642\u0627\u0637 \u0627\u0644\u0625\u062C\u0645\u0627\u0644\u064A\u0629 100 %", "boolean.yes": "\u0646\u0639\u0645", "boolean.no": "\u0644\u0627", "upload.cta": "\u0627\u0633\u062D\u0628 \u0648\u0623\u0641\u0644\u062A \u0623\u0648 \u0627\u0646\u0642\u0631 \u0644\u0644\u062A\u062D\u0645\u064A\u0644", "upload.imagesOnly": "\u0627\u0644\u0635\u0648\u0631 \u0641\u0642\u0637", "upload.anyFileType": "\u0623\u064A \u0646\u0648\u0639 \u0645\u0646 \u0627\u0644\u0645\u0644\u0641\u0627\u062A", "upload.maxFiles": "{n} \u0645\u0644\u0641\u0627\u062A \u0643\u062D\u062F \u0623\u0642\u0635\u0649", "upload.maxSize": "{mb} \u0645\u064A\u063A\u0627\u0628\u0627\u064A\u062A \u0643\u062D\u062F \u0623\u0642\u0635\u0649", "upload.tooLarge": "\u0627\u0644\u0645\u0644\u0641 \u0643\u0628\u064A\u0631 \u062C\u062F\u064B\u0627 (\u0627\u0644\u062D\u062F \u0627\u0644\u0623\u0642\u0635\u0649 {mb} \u0645\u064A\u063A\u0627\u0628\u0627\u064A\u062A)", "upload.remove": "\u0625\u0632\u0627\u0644\u0629", "select.placeholder": "\u0627\u062E\u062A\u0631 \u062E\u064A\u0627\u0631\u064B\u0627", "rating.ariaLabel": "\u0627\u0644\u062A\u0642\u064A\u064A\u0645", "maxDiff.best": "\u0627\u0644\u0623\u0643\u062B\u0631 \u0623\u0647\u0645\u064A\u0629", "maxDiff.worst": "\u0627\u0644\u0623\u0642\u0644 \u0623\u0647\u0645\u064A\u0629", "maxDiff.setProgress": "\u0627\u0644\u0645\u062C\u0645\u0648\u0639\u0629 {k} \u0645\u0646 {n}", "priority.selectUpTo": "\u0627\u062E\u062A\u0631 \u062D\u062A\u0649", "priority.options": "\u062E\u064A\u0627\u0631\u0627\u062A", "priority.thenOrder": "\u062B\u0645 \u0631\u062A\u0628\u0647\u0627", "priority.selectOptions": "\u0627\u062E\u062A\u0631 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A", "priority.cancel": "\u0625\u0644\u063A\u0627\u0621", "priority.confirm": "\u062A\u0623\u0643\u064A\u062F", "priority.selectOptionNumber": "\u0627\u062E\u062A\u0631 \u0627\u0644\u062E\u064A\u0627\u0631 #", "priority.prioritized": "\u062A\u0645 \u0627\u0644\u062A\u0631\u062A\u064A\u0628", "priority.of": "\u0645\u0646", "priority.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.', "action.send": "\u0625\u0631\u0633\u0627\u0644", "action.back": "\u0631\u062C\u0648\u0639", "action.next": "\u0627\u0644\u062A\u0627\u0644\u064A", "action.start": "\u0627\u0628\u062F\u0623!", "message.success": "\u0634\u0643\u0631\u064B\u0627 \u0644\u0645\u0644\u0627\u062D\u0638\u0627\u062A\u0643!", "message.blocked": "\u0634\u0643\u0631\u064B\u0627 \u0639\u0644\u0649 \u0648\u0642\u062A\u0643\u060C \u0633\u0646\u0646\u0647\u064A \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629 \u0647\u0646\u0627.", "message.required": "\u064A\u0631\u062C\u0649 \u0627\u0644\u0625\u062C\u0627\u0628\u0629 \u0642\u0628\u0644 \u0627\u0644\u0645\u062A\u0627\u0628\u0639\u0629.", "message.rateLimit": "\u0637\u0644\u0628\u0627\u062A \u0643\u062B\u064A\u0631\u0629 \u062C\u062F\u064B\u0627. \u0633\u0646\u0639\u064A\u062F \u0627\u0644\u0645\u062D\u0627\u0648\u0644\u0629 \u062E\u0644\u0627\u0644 {seconds} \u062B\u0627\u0646\u064A\u0629..." }, bn: { "placeholder.answer": "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0 \u0989\u09A4\u09CD\u09A4\u09B0 \u09B2\u09BF\u0996\u09C1\u09A8...", "placeholder.number": "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0 \u09B8\u0982\u0996\u09CD\u09AF\u09BE \u09B2\u09BF\u0996\u09C1\u09A8...", "placeholder.email": "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0 \u0987\u09AE\u09C7\u0987\u09B2 \u09B2\u09BF\u0996\u09C1\u09A8...", "placeholder.date": "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0 \u09A4\u09BE\u09B0\u09BF\u0996 \u09B2\u09BF\u0996\u09C1\u09A8...", "placeholder.password": "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0 \u09AA\u09BE\u09B8\u0993\u09AF\u09BC\u09BE\u09B0\u09CD\u09A1 \u09B2\u09BF\u0996\u09C1\u09A8...", "pointSystem.error": "\u09AE\u09CB\u099F \u09AA\u09AF\u09BC\u09C7\u09A8\u09CD\u099F 100 % \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7", "boolean.yes": "\u09B9\u09CD\u09AF\u09BE\u0981", "boolean.no": "\u09A8\u09BE", "upload.cta": "\u099F\u09C7\u09A8\u09C7 \u0986\u09A8\u09C1\u09A8 \u09AC\u09BE \u0986\u09AA\u09B2\u09CB\u09A1 \u0995\u09B0\u09A4\u09C7 \u0995\u09CD\u09B2\u09BF\u0995 \u0995\u09B0\u09C1\u09A8", "upload.imagesOnly": "\u09B6\u09C1\u09A7\u09C1\u09AE\u09BE\u09A4\u09CD\u09B0 \u099B\u09AC\u09BF", "upload.anyFileType": "\u09AF\u09C7\u0995\u09CB\u09A8\u09CB \u09A7\u09B0\u09A8\u09C7\u09B0 \u09AB\u09BE\u0987\u09B2", "upload.maxFiles": "\u09B8\u09B0\u09CD\u09AC\u09CB\u099A\u09CD\u099A {n}\u099F\u09BF \u09AB\u09BE\u0987\u09B2", "upload.maxSize": "\u09B8\u09B0\u09CD\u09AC\u09CB\u099A\u09CD\u099A {mb} MB", "upload.tooLarge": "\u09AB\u09BE\u0987\u09B2\u099F\u09BF \u0996\u09C1\u09AC \u09AC\u09A1\u09BC (\u09B8\u09B0\u09CD\u09AC\u09CB\u099A\u09CD\u099A {mb} MB)", "upload.remove": "\u09B8\u09B0\u09BE\u09A8", "select.placeholder": "\u098F\u0995\u099F\u09BF \u09AC\u09BF\u0995\u09B2\u09CD\u09AA \u09A8\u09BF\u09B0\u09CD\u09AC\u09BE\u099A\u09A8 \u0995\u09B0\u09C1\u09A8", "rating.ariaLabel": "\u09B0\u09C7\u099F\u09BF\u0982", "maxDiff.best": "\u09B8\u09AC\u099A\u09C7\u09AF\u09BC\u09C7 \u0997\u09C1\u09B0\u09C1\u09A4\u09CD\u09AC\u09AA\u09C2\u09B0\u09CD\u09A3", "maxDiff.worst": "\u09B8\u09AC\u099A\u09C7\u09AF\u09BC\u09C7 \u0995\u09AE \u0997\u09C1\u09B0\u09C1\u09A4\u09CD\u09AC\u09AA\u09C2\u09B0\u09CD\u09A3", "maxDiff.setProgress": "\u09AC\u09CD\u09B2\u0995 {k}/{n}", "priority.selectUpTo": "\u09B8\u09B0\u09CD\u09AC\u09CB\u099A\u09CD\u099A \u09A8\u09BF\u09B0\u09CD\u09AC\u09BE\u099A\u09A8 \u0995\u09B0\u09C1\u09A8", "priority.options": "\u099F\u09BF \u09AC\u09BF\u0995\u09B2\u09CD\u09AA", "priority.thenOrder": "\u09A4\u09BE\u09B0\u09AA\u09B0 \u09B8\u09C7\u0997\u09C1\u09B2\u09CB \u09B8\u09BE\u099C\u09BE\u09A8", "priority.selectOptions": "\u09AC\u09BF\u0995\u09B2\u09CD\u09AA \u09A8\u09BF\u09B0\u09CD\u09AC\u09BE\u099A\u09A8 \u0995\u09B0\u09C1\u09A8", "priority.cancel": "\u09AC\u09BE\u09A4\u09BF\u09B2", "priority.confirm": "\u09A8\u09BF\u09B6\u09CD\u099A\u09BF\u09A4 \u0995\u09B0\u09C1\u09A8", "priority.selectOptionNumber": "\u09AC\u09BF\u0995\u09B2\u09CD\u09AA # \u09A8\u09BF\u09B0\u09CD\u09AC\u09BE\u099A\u09A8 \u0995\u09B0\u09C1\u09A8", "priority.prioritized": "\u0985\u0997\u09CD\u09B0\u09BE\u09A7\u09BF\u0995\u09BE\u09B0\u09AA\u09CD\u09B0\u09BE\u09AA\u09CD\u09A4", "priority.of": "\u098F\u09B0 \u09AE\u09A7\u09CD\u09AF\u09C7", "priority.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 "\u09AA\u09B0\u09AC\u09B0\u09CD\u09A4\u09C0" \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', "action.send": "\u09AA\u09BE\u09A0\u09BE\u09A8", "action.back": "\u09AA\u09BF\u099B\u09A8\u09C7", "action.next": "\u09AA\u09B0\u09AC\u09B0\u09CD\u09A4\u09C0", "action.start": "\u09B6\u09C1\u09B0\u09C1 \u0995\u09B0\u09C1\u09A8!", "message.success": "\u0986\u09AA\u09A8\u09BE\u09B0 \u09AE\u09A4\u09BE\u09AE\u09A4\u09C7\u09B0 \u099C\u09A8\u09CD\u09AF \u09A7\u09A8\u09CD\u09AF\u09AC\u09BE\u09A6!", "message.blocked": "\u0986\u09AA\u09A8\u09BE\u09B0 \u09B8\u09AE\u09AF\u09BC\u09C7\u09B0 \u099C\u09A8\u09CD\u09AF \u09A7\u09A8\u09CD\u09AF\u09AC\u09BE\u09A6, \u0986\u09AE\u09B0\u09BE \u098F\u0996\u09BE\u09A8\u09C7\u0987 \u0995\u09A5\u09CB\u09AA\u0995\u09A5\u09A8 \u09B6\u09C7\u09B7 \u0995\u09B0\u099B\u09BF\u0964", "message.required": "\u099A\u09BE\u09B2\u09BF\u09AF\u09BC\u09C7 \u09AF\u09BE\u0993\u09AF\u09BC\u09BE\u09B0 \u0986\u0997\u09C7 \u0985\u09A8\u09C1\u0997\u09CD\u09B0\u09B9 \u0995\u09B0\u09C7 \u0989\u09A4\u09CD\u09A4\u09B0 \u09A6\u09BF\u09A8\u0964", "message.rateLimit": "\u0985\u09A8\u09C7\u0995 \u09AC\u09C7\u09B6\u09BF \u0985\u09A8\u09C1\u09B0\u09CB\u09A7\u0964 {seconds} \u09B8\u09C7\u0995\u09C7\u09A8\u09CD\u09A1\u09C7 \u0986\u09AC\u09BE\u09B0 \u099A\u09C7\u09B7\u09CD\u099F\u09BE \u0995\u09B0\u09BE \u09B9\u099A\u09CD\u099B\u09C7..." }, it: { "boolean.yes": "S\xEC", "boolean.no": "No", "priority.selectUpTo": "Seleziona fino a", "priority.options": "opzioni", "priority.thenOrder": "e poi ordinali", "priority.selectOptions": "Seleziona opzioni", "priority.cancel": "Annulla", "priority.confirm": "Conferma", "priority.selectOptionNumber": "Seleziona opzione #", "priority.prioritized": "Prioritizzate", "priority.of": "di", "priority.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: { "boolean.yes": "Ja", "boolean.no": "Nee", "priority.selectUpTo": "Selecteer tot", "priority.options": "opties", "priority.thenOrder": "en rangschik ze vervolgens", "priority.selectOptions": "Selecteer opties", "priority.cancel": "Annuleren", "priority.confirm": "Bevestigen", "priority.selectOptionNumber": "Selecteer optie #", "priority.prioritized": "Geprioriteerd", "priority.of": "van", "priority.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: { "boolean.yes": "Tak", "boolean.no": "Nie", "priority.selectUpTo": "Wybierz do", "priority.options": "opcje", "priority.thenOrder": "a nast\u0119pnie je uporz\u0105dkuj", "priority.selectOptions": "Wybierz opcje", "priority.cancel": "Anuluj", "priority.confirm": "Potwierd\u017A", "priority.selectOptionNumber": "Wybierz opcj\u0119 #", "priority.prioritized": "Priorytetowe", "priority.of": "z", "priority.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: { "boolean.yes": "\u0414\u0430", "boolean.no": "\u041D\u0435\u0442", "priority.selectUpTo": "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0434\u043E", "priority.options": "\u0432\u0430\u0440\u0438\u0430\u043D\u0442\u043E\u0432", "priority.thenOrder": "\u0430 \u0437\u0430\u0442\u0435\u043C \u0443\u043F\u043E\u0440\u044F\u0434\u043E\u0447\u044C\u0442\u0435 \u0438\u0445", "priority.selectOptions": "\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0430\u0440\u0438\u0430\u043D\u0442\u044B", "priority.cancel": "\u041E\u0442\u043C\u0435\u043D\u0430", "priority.confirm": "\u041F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044C", "priority.selectOptionNumber": "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0430\u0440\u0438\u0430\u043D\u0442 #", "priority.prioritized": "\u041F\u0440\u0438\u043E\u0440\u0438\u0442\u0435\u0442\u044B", "priority.of": "\u0438\u0437", "priority.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: { "boolean.yes": "\u306F\u3044", "boolean.no": "\u3044\u3044\u3048", "priority.selectUpTo": "\u6700\u5927", "priority.options": "\u500B\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u9078\u629E", "priority.thenOrder": "\u305D\u306E\u5F8C\u4E26\u3079\u66FF\u3048\u3066\u304F\u3060\u3055\u3044", "priority.selectOptions": "\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u9078\u629E", "priority.cancel": "\u30AD\u30E3\u30F3\u30BB\u30EB", "priority.confirm": "\u78BA\u8A8D", "priority.selectOptionNumber": "\u30AA\u30D7\u30B7\u30E7\u30F3 # \u3092\u9078\u629E", "priority.prioritized": "\u512A\u5148\u9806\u4F4D", "priority.of": "\u306E\u3046\u3061", "priority.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: { "boolean.yes": "\u662F", "boolean.no": "\u4E0D", "priority.selectUpTo": "\u6700\u591A\u9009\u62E9", "priority.options": "\u4E2A\u9009\u9879", "priority.thenOrder": "\u7136\u540E\u6392\u5E8F\u5B83\u4EEC", "priority.selectOptions": "\u9009\u62E9\u9009\u9879", "priority.cancel": "\u53D6\u6D88", "priority.confirm": "\u786E\u8BA4", "priority.selectOptionNumber": "\u9009\u62E9\u9009\u9879 #", "priority.prioritized": "\u5DF2\u4F18\u5148", "priority.of": "\u5171", "priority.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: { "boolean.yes": "\uC608", "boolean.no": "\uC544\uB2C8", "priority.selectUpTo": "\uCD5C\uB300", "priority.options": "\uAC1C\uC758 \uC635\uC158 \uC120\uD0DD", "priority.thenOrder": "\uADF8\uB7F0 \uB2E4\uC74C \uC815\uB82C\uD558\uC138\uC694", "priority.selectOptions": "\uC635\uC158 \uC120\uD0DD", "priority.cancel": "\uCDE8\uC18C", "priority.confirm": "\uD655\uC778", "priority.selectOptionNumber": "\uC635\uC158 # \uC120\uD0DD", "priority.prioritized": "\uC6B0\uC120\uC21C\uC704", "priority.of": "\uC911", "priority.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.' } };
2459
- t2.SUPPORTED_LANGUAGES = ["en", "da", "fi", "no", "es", "sv", "ar", "bn", "de", "pt", "fr"], t2.AVAILABLE_LANGUAGES = Object.keys(n), t2.RTL_LANGUAGES = ["ar"];
2460
- const r = { nb: "no", nn: "no", nob: "no", nno: "no", iw: "he", in: "id", cmn: "zh" };
2461
- function o(e3) {
2462
- if (!e3) return null;
2463
- const t3 = e3.trim().toLowerCase().replace(/_/g, "-");
2464
- if (!t3) return null;
2465
- if (n[t3]) return t3;
2466
- const i2 = t3.split("-")[0], o2 = r[i2] || i2;
2467
- return n[o2] ? o2 : null;
2468
- }
2469
- function a(e3) {
2470
- return o(e3) || "en";
2471
- }
2472
- t2.normalizeLanguage = a, t2.TRANSLATION_KEYS = Object.keys(i), t2.hasOwnTranslation = function(e3, t3) {
2473
- const i2 = o(e3);
2474
- return !!i2 && void 0 !== n[i2][t3];
2475
- }, t2.isRtlLanguage = function(e3) {
2476
- return -1 !== t2.RTL_LANGUAGES.indexOf(a(e3));
2477
- }, t2.isLanguageSupported = function(e3) {
2478
- const i2 = o(e3);
2479
- return !!i2 && -1 !== t2.SUPPORTED_LANGUAGES.indexOf(i2);
2480
- }, t2.t = function(e3, t3, r2) {
2481
- const o2 = n[a(e3)] || i, s = void 0 !== o2[t3] ? o2[t3] : i[t3];
2482
- return r2 ? (function(e4, t4) {
2483
- return Object.keys(t4).reduce(((e5, i2) => e5.replace(new RegExp("\\{" + i2 + "\\}", "g"), String(t4[i2]))), e4);
2484
- })(s, r2) : s;
2485
- };
2486
- }, 5407: (e2, t2) => {
2487
- "use strict";
2488
- 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", agentSurveyStart: "sdk/agentSurvey/start", agentSurveyNext: "sdk/agentSurvey/next" } };
2489
- }, 3262: (e2, t2, i) => {
2490
- "use strict";
2491
- Object.defineProperty(t2, "__esModule", { value: true }), t2.placeholder = void 0;
2492
- const n = i(7627);
2493
- t2.placeholder = { answer: (e3) => (0, n.t)(e3, "placeholder.answer"), number: (e3) => (0, n.t)(e3, "placeholder.number"), email: (e3) => (0, n.t)(e3, "placeholder.email"), date: (e3) => (0, n.t)(e3, "placeholder.date"), password: (e3) => (0, n.t)(e3, "placeholder.password"), pointsystemerror: (e3) => (0, n.t)(e3, "pointSystem.error"), upload: { cta: (e3) => (0, n.t)(e3, "upload.cta"), formats: (e3, t3) => (0, n.t)(e3, "image" === t3 ? "upload.imagesOnly" : "upload.anyFileType"), maxFiles: (e3, t3) => (0, n.t)(e3, "upload.maxFiles", { n: t3 }), maxSize: (e3, t3) => (0, n.t)(e3, "upload.maxSize", { mb: t3 }), tooLarge: (e3, t3) => (0, n.t)(e3, "upload.tooLarge", { mb: t3 }), remove: (e3) => (0, n.t)(e3, "upload.remove") } };
2494
- }, 7643: (e2, t2, i) => {
2495
- "use strict";
2496
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderStartMessage = t2.renderSuccess = t2.renderError = t2.renderActions = t2.renderQuestions = void 0;
2497
- const n = i(4760), r = i(368), o = i(1366), a = i(3433), s = i(9039), l = { small: "1rem", medium: "1.2rem", large: "1.5rem" };
2498
- t2.renderQuestions = function e3(t3, i2 = "standard", d = "en", c = { customIcons: false }, u) {
2499
- if (!t3) throw new Error("[MagicFeedback] No questions provided");
2500
- const p = [], { customIcons: m, id: h } = c;
2501
- return t3.forEach(((f) => {
2502
- var g, y;
2503
- if ((null === (y = null === (g = null == f ? void 0 : f.questionType) || void 0 === g ? void 0 : g.conf) || void 0 === y ? void 0 : y.length) > 0) {
2504
- let t4 = document.createElement("div");
2505
- t4.classList.add("magicfeedback-div");
2506
- const n2 = document.createElement("label");
2507
- n2.setAttribute("for", `magicfeedback-${f.id}`), n2.textContent = (0, o.parseTitle)(f.title, d), n2.classList.add("magicfeedback-label"), t4.appendChild(n2), f.questionType.conf.forEach(((e4) => {
2508
- e4.ref = f.ref, f.assets[e4.id] && (e4.assets = { placeholder: f.assets[e4.id] });
2509
- })), e3(f.questionType.conf, i2, d, c, u).forEach(((e4) => {
2510
- t4.appendChild(e4);
2511
- })), p.push(t4);
2512
- } else {
2513
- const e4 = (function(e5, t4, i3, d2, c2, u2) {
2514
- var p2, m2, h2;
2515
- let f2, g2, { id: y2, title: v, type: b, ref: E, require: A, defaultValue: k, assets: T } = e5, C = document.createElement("div");
2516
- C.classList.add("magicfeedback-div");
2517
- const P = window.innerWidth < 600, S = "slim" === t4 ? (0, o.parseTitle)(v, i3) : null == T ? void 0 : T.placeholder, w = (0, a.shownValueFor)(e5, (0, o.getUrlParam)(E)), O = (null == T ? void 0 : T.maxCharacters) || 0, x = false === (null == T ? void 0 : T.autoAdvance) ? void 0 : c2, L = void 0 !== (null == T ? void 0 : T.randomPosition) && (null == T ? void 0 : T.randomPosition), N = (null == T ? void 0 : T.direction) || "row", I = (null == T ? void 0 : T.order) || "ltr", D = (0, r.getQuestionRenderer)(b);
2518
- if (!D) return C;
2519
- {
2520
- const r2 = D({ question: e5, format: t4, language: i3, url: d2, send: b === n.FEEDBACKAPPANSWERTYPE.TEXT ? c2 : x, isPhone: P, urlParamValue: w, placeholderText: S, maxCharacters: O, randomPosition: L, direction: N, order: I, productId: u2 });
2521
- f2 = r2.element, g2 = r2.elementTypeClass;
2522
- }
2523
- f2.id = `magicfeedback-${y2}`, f2.setAttribute("name", E), f2.classList.add(g2), (void 0 !== k || null !== w) && (f2.value = w || k), ["RADIO", "MULTIPLECHOICE", "UPLOAD_IMAGE", "UPLOAD_FILE"].includes(b) || (f2.classList.add("magicfeedback-input"), f2.required = A);
2524
- const R = document.createElement("label");
2525
- R.setAttribute("for", `magicfeedback-${y2}`), R.textContent = (0, o.parseTitle)(v, i3), R.classList.add("magicfeedback-label"), (function(e6, t5) {
2526
- if ("INFO_PAGE" !== t5.type) return;
2527
- const { assets: i4 } = t5, n2 = (function(e7) {
2528
- if (e7) return l[e7] || e7;
2529
- })(null == i4 ? void 0 : i4.titleSize), r2 = (o2 = null == i4 ? void 0 : i4.titleStyle, Array.isArray(o2) ? o2 : o2 ? [o2] : []);
2530
- var o2;
2531
- n2 && e6.style.setProperty("font-size", n2, "important"), (null == i4 ? void 0 : i4.titleAlign) && (e6.style.setProperty("width", "100%", "important"), e6.style.setProperty("align-self", "stretch", "important"), e6.style.setProperty("text-align", i4.titleAlign, "important")), r2.includes("italic") && e6.style.setProperty("font-style", "italic", "important"), r2.includes("bold") && e6.style.setProperty("font-weight", "bold", "important"), r2.includes("underline") && e6.style.setProperty("text-decoration", "underline", "important");
2532
- })(R, e5);
2533
- const _ = document.createElement("label");
2534
- if (_.textContent = (0, o.parseTitle)(null == T ? void 0 : T.subtitle, i3), _.classList.add("magicfeedback-sublabel"), (null === (p2 = null == T ? void 0 : T.subtitleStyle) || void 0 === p2 ? void 0 : p2.includes("italic")) && (_.style.fontStyle = "italic"), (null === (m2 = null == T ? void 0 : T.subtitleStyle) || void 0 === m2 ? void 0 : m2.includes("bold")) && (_.style.fontWeight = "bold"), (null === (h2 = null == T ? void 0 : T.subtitleStyle) || void 0 === h2 ? void 0 : h2.includes("underline")) && (_.style.textDecoration = "underline"), ["CONSENT"].includes(b)) C.classList.add("magicfeedback-consent-container"), C.appendChild(f2), C.appendChild(R), (null == T ? void 0 : T.subtitle) && C.appendChild(_);
2535
- else {
2536
- if ("slim" !== t4 && (C.appendChild(R), (null == T ? void 0 : T.subtitle) && C.appendChild(_), void 0 !== (null == T ? void 0 : T.general) && "" !== (null == T ? void 0 : T.general))) {
2537
- const e6 = document.createElement("img");
2538
- e6.src = null == T ? void 0 : T.general, e6.classList.add("magicfeedback-image"), e6.style.maxWidth = "auto", e6.style.height = "400px", e6.style.margin = "10px 0", C.appendChild(e6);
2539
- }
2540
- if ("LONGTEXT" === b && O > 0) {
2541
- const e6 = document.createElement("div");
2542
- if (e6.classList.add("magicfeedback-counter"), e6.textContent = `${f2.value.length}/${O}`, e6.style.textAlign = "end", e6.style.fontSize = "15px", e6.style.marginTop = "5px", f2.addEventListener("input", (() => {
2543
- e6.textContent = `${f2.value.length}/${O}`;
2544
- })), C.appendChild(f2), C.appendChild(e6), (null == T ? void 0 : T.extraOption) && (null == T ? void 0 : T.extraOptionText)) {
2545
- const e7 = document.createElement("div");
2546
- e7.classList.add("magicfeedback-skip-container"), e7.classList.add("magicfeedback-checkbox-container"), e7.style.display = "flex", e7.style.justifyContent = "flex-start";
2547
- const t5 = document.createElement("input");
2548
- t5.classList.add("magicfeedback-skip"), t5.type = "checkbox", t5.id = `skip-${E}`, t5.name = E, t5.value = "-", t5.style.cursor = "pointer";
2549
- const i4 = document.createElement("label");
2550
- i4.htmlFor = `skip-${E}`, i4.textContent = null == T ? void 0 : T.extraOptionText, i4.style.fontSize = "15px", i4.style.cursor = "pointer", i4.style.margin = "0 5px", t5.addEventListener("click", (() => {
2551
- f2.value = "-";
2552
- })), (0, s.autoAdvanceOn)(t5, x, "click"), e7.appendChild(t5), e7.appendChild(i4), C.appendChild(e7);
2553
- }
2554
- } else C.appendChild(f2);
2555
- }
2556
- return C;
2557
- })(f, i2, d, "https://survey-dev.magicfeedback.io/assets/emojis" + (m ? `/${h}` : ""), 1 === t3.length ? u : void 0, h);
2558
- p.push(e4);
2559
- }
2560
- })), p;
2561
- }, t2.renderActions = function(e3 = "", t3, i2 = "Submit", n2 = "Back", r2 = "Next") {
2562
- const o2 = document.createElement("div");
2563
- o2.classList.add("magicfeedback-action-container");
2564
- const a2 = document.createElement("button");
2565
- a2.id = "magicfeedback-submit", a2.type = "submit", a2.classList.add("magicfeedback-submit"), a2.textContent = "MAGICSURVEY" === e3 ? r2 || "Next" : i2 || "Submit";
2566
- const s2 = document.createElement("button");
2567
- return s2.id = "magicfeedback-back", s2.type = "button", s2.classList.add("magicfeedback-back"), s2.textContent = n2 || "Back", s2.addEventListener("click", t3), s2.addEventListener("click", (() => {
2568
- a2.removeAttribute("disabled");
2569
- })), "MAGICSURVEY" === e3 && o2.appendChild(s2), o2.appendChild(a2), o2;
2570
- }, t2.renderError = function(e3) {
2571
- const t3 = document.createElement("div");
2572
- return t3.classList.add("magicfeedback-error"), t3.textContent = e3, t3;
2573
- }, t2.renderSuccess = function(e3) {
2574
- const t3 = document.createElement("div");
2575
- return t3.classList.add("magicfeedback-success"), t3.textContent = e3, t3;
2576
- }, t2.renderStartMessage = function(e3, t3 = false, i2 = "Go!", n2 = () => {
2577
- }) {
2578
- const r2 = document.createElement("div");
2579
- r2.classList.add("magicfeedback-start-message-container");
2580
- const o2 = document.createElement("div");
2581
- if (o2.classList.add("magicfeedback-start-message"), o2.innerHTML = e3, r2.appendChild(o2), t3) {
2582
- const e4 = document.createElement("button");
2583
- e4.id = "magicfeedback-start-message-button", e4.classList.add("magicfeedback-start-message-button"), e4.textContent = i2, e4.addEventListener("click", (() => n2())), r2.appendChild(e4);
2584
- }
2585
- return r2;
2586
- };
2587
- }, 9071: function(e2, t2, i) {
2588
- "use strict";
2589
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
2590
- return new (i2 || (i2 = Promise))((function(r2, o2) {
2591
- function a2(e4) {
2592
- try {
2593
- l2(n2.next(e4));
2594
- } catch (e5) {
2595
- o2(e5);
2596
- }
2597
- }
2598
- function s2(e4) {
2599
- try {
2600
- l2(n2.throw(e4));
2601
- } catch (e5) {
2602
- o2(e5);
2603
- }
2604
- }
2605
- function l2(e4) {
2606
- var t4;
2607
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
2608
- e5(t4);
2609
- }))).then(a2, s2);
2610
- }
2611
- l2((n2 = n2.apply(e3, t3 || [])).next());
2612
- }));
2613
- }, r = this && this.__importDefault || function(e3) {
2614
- return e3 && e3.__esModule ? e3 : { default: e3 };
2615
- };
2616
- Object.defineProperty(t2, "__esModule", { value: true }), t2.getFollowUpQuestion = t2.sendFeedback = t2.getQuestions = t2.getSessionForm = t2.getForm = t2.takePreloadedInfo = t2.validateEmail = t2.header = void 0;
2617
- const o = r(i(6539)), a = r(i(8330)), s = i(5407), l = i(3433);
2618
- function d(e3) {
2619
- if ("undefined" == typeof window) return;
2620
- const i2 = window, n2 = i2.__MAGICFEEDBACK_PRELOADED_INFO__;
2621
- if (n2 && n2.url === e3 && n2.parameters === t2.header["x-magicfeedback-parameters"]) {
2622
- delete i2.__MAGICFEEDBACK_PRELOADED_INFO__;
2623
- try {
2624
- return JSON.parse(n2.body);
2625
- } catch (e4) {
2626
- return;
2627
- }
2628
- }
2629
- }
2630
- t2.header = { Accept: "application/json", "Magicfeedback-Sdk-Version": a.default.version, "x-magicfeedback-parameters": window.location.search || "" }, t2.validateEmail = function(e3) {
2631
- return /\S+@\S+\.\S+/.test(e3);
2632
- }, t2.takePreloadedInfo = d, t2.getForm = function(e3, i2, r2, a2, c) {
2633
- return n(this, void 0, void 0, (function* () {
2634
- try {
2635
- const n2 = (0, l.withLangParam)(e3 + s.endpoints.sdk.app_info(i2, r2), c), a3 = d(n2);
2636
- if (void 0 !== a3) return a3;
2637
- const u = yield (0, o.default)(n2, { method: "GET", headers: t2.header });
2638
- return yield u.json();
2639
- } catch (e4) {
2640
- a2.err(e4);
2641
- }
2642
- }));
2643
- }, t2.getSessionForm = function(e3, i2, r2, a2) {
2644
- return n(this, void 0, void 0, (function* () {
2645
- try {
2646
- const n2 = (0, l.withLangParam)(e3 + s.endpoints.sdk.session(i2), a2), r3 = d(n2);
2647
- if (void 0 !== r3) return r3;
2648
- const c = yield (0, o.default)(n2, { method: "GET", headers: t2.header });
2649
- return yield c.json();
2650
- } catch (e4) {
2651
- r2.err(e4);
2652
- }
2653
- }));
2654
- }, t2.getQuestions = function(e3, i2, r2, a2, d2) {
2655
- return n(this, void 0, void 0, (function* () {
2656
- try {
2657
- const n2 = yield (0, o.default)((0, l.withLangParam)(e3 + s.endpoints.sdk.app(i2, r2), d2), { method: "GET", headers: t2.header });
2658
- if (n2.ok) {
2659
- const e4 = yield n2.json();
2660
- return a2.log(`Received questions for app ${i2}`, e4), e4;
2661
- }
2662
- throw a2.err(`Failed to get questions for app ${i2}:`, n2.status, n2.statusText), new Error("[MagicFeedback] Bad response from server");
2663
- } catch (e4) {
2664
- return a2.err(e4), [];
2665
- }
2666
- }));
2667
- }, t2.sendFeedback = function(e3, i2, r2) {
2668
- return n(this, void 0, void 0, (function* () {
2669
- try {
2670
- const n2 = yield (0, o.default)(e3 + s.endpoints.sdk.feedback, { method: "POST", headers: Object.assign({ "Content-Type": "application/json" }, t2.header), body: JSON.stringify(i2) });
2671
- if (n2.ok) return r2.log(`Form ${i2.integration} submitted successfully!`), (yield n2.json()).sessionId;
2672
- throw r2.err(`Failed to submit form ${i2.integration}:`, n2.status, n2.statusText), new Error(n2.statusText);
2673
- } catch (e4) {
2674
- return r2.err(e4), "";
2675
- }
2676
- }));
2677
- }, t2.getFollowUpQuestion = function(e3, i2, r2) {
2678
- return n(this, void 0, void 0, (function* () {
2679
- try {
2680
- const n2 = yield (0, o.default)(e3 + s.endpoints.sdk.followUpQuestion, { method: "POST", headers: Object.assign({ "Content-Type": "application/json" }, t2.header), body: JSON.stringify(i2) });
2681
- if (n2.ok) return r2.log(`Received follow up question for form ${i2.integration}`), (yield n2.json()) || "";
2682
- throw r2.err(`Failed to get follow up question for form ${i2.integration}:`, n2.status, n2.statusText), new Error(n2.statusText);
2683
- } catch (e4) {
2684
- return r2.err(e4), "";
2685
- }
2686
- }));
2687
- };
2688
- }, 1012: (e2, t2) => {
2689
- "use strict";
2690
- Object.defineProperty(t2, "__esModule", { value: true }), t2.SubmitError = void 0;
2691
- class i extends Error {
2692
- constructor(e3, t3) {
2693
- super(t3), this.code = e3, this.name = "SubmitError", Object.setPrototypeOf(this, i.prototype);
2694
- }
2695
- }
2696
- t2.SubmitError = i;
2697
- }, 3433: (e2, t2, i) => {
2698
- "use strict";
2699
- Object.defineProperty(t2, "__esModule", { value: true }), t2.toBaseAnswers = t2.shownValueFor = t2.baseValueMap = t2.withLangParam = t2.detectSurveyLang = t2.normalizeSurveyLang = void 0;
2700
- const n = i(4760), r = { nb: "no", nn: "no", nob: "no", nno: "no" };
2701
- function o(e3) {
2702
- if (!e3 || "string" != typeof e3) return null;
2703
- const t3 = e3.trim().toLowerCase().replace(/_/g, "-").split("-")[0];
2704
- return /^[a-z]{2,3}$/.test(t3) ? r[t3] || t3 : null;
2705
- }
2706
- function a(e3) {
2707
- if (null == e3) return null;
2708
- if ("string" == typeof e3 && e3.trim().startsWith("{")) try {
2709
- e3 = JSON.parse(e3);
2710
- } catch (t3) {
2711
- return e3;
2712
- }
2713
- return "object" == typeof e3 ? void 0 !== e3.value ? String(e3.value) : null : String(e3);
2714
- }
2715
- function s(e3) {
2716
- const t3 = /* @__PURE__ */ new Map(), i2 = null == e3 ? void 0 : e3.value, n2 = null == e3 ? void 0 : e3.baseValue;
2717
- return Array.isArray(i2) && Array.isArray(n2) ? (i2.forEach(((e4, i3) => {
2718
- const r2 = a(e4), o2 = a(n2[i3]);
2719
- null === r2 || null === o2 || t3.has(r2) || t3.set(r2, o2);
2720
- })), t3) : t3;
2721
- }
2722
- t2.normalizeSurveyLang = o, t2.detectSurveyLang = function(e3) {
2723
- return o(e3) || (function() {
2724
- if ("undefined" == typeof navigator) return null;
2725
- const e4 = [...Array.isArray(navigator.languages) ? navigator.languages : [], navigator.language];
2726
- for (const t3 of e4) {
2727
- const e5 = o(t3);
2728
- if (e5) return e5;
2729
- }
2730
- return null;
2731
- })();
2732
- }, t2.withLangParam = function(e3, t3) {
2733
- return t3 ? `${e3}${e3.includes("?") ? "&" : "?"}lang=${encodeURIComponent(t3)}` : e3;
2734
- }, t2.baseValueMap = s, t2.shownValueFor = function(e3, t3) {
2735
- var i2, n2;
2736
- if (null === t3 || !Array.isArray(null == e3 ? void 0 : e3.baseValue)) return t3;
2737
- const r2 = e3.baseValue.findIndex(((e4) => a(e4) === t3));
2738
- return -1 === r2 ? t3 : null !== (n2 = a(null === (i2 = e3.value) || void 0 === i2 ? void 0 : i2[r2])) && void 0 !== n2 ? n2 : t3;
2739
- };
2740
- const l = [n.FEEDBACKAPPANSWERTYPE.RADIO, n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE, n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE, n.FEEDBACKAPPANSWERTYPE.SELECT];
2741
- t2.toBaseAnswers = function(e3, t3) {
2742
- return e3.map(((e4) => {
2743
- if (e4.key.startsWith("extra-option-")) return e4;
2744
- const i2 = t3.find(((t4) => t4.ref === e4.key)) || t3.find(((t4) => e4.key.includes(t4.ref)));
2745
- if (!i2) return e4;
2746
- const r2 = s(i2);
2747
- if (0 === r2.size) return e4;
2748
- let o2;
2749
- if (l.includes(i2.type)) o2 = (e5) => {
2750
- var t4;
2751
- return "string" == typeof e5 && null !== (t4 = r2.get(e5)) && void 0 !== t4 ? t4 : e5;
2752
- };
2753
- else if (i2.type === n.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST) o2 = (e5) => "string" == typeof e5 ? (function(e6, t4) {
2754
- var i3, n2;
2755
- const r3 = /^(\d+)\.\s?(.*)$/.exec(e6);
2756
- if (!r3) return null !== (i3 = t4.get(e6)) && void 0 !== i3 ? i3 : e6;
2757
- const o3 = r3[2];
2758
- return `${r3[1]}. ${null !== (n2 = t4.get(o3)) && void 0 !== n2 ? n2 : o3}`;
2759
- })(e5, r2) : e5;
2760
- else if (i2.type === n.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM) o2 = (e5) => "string" == typeof e5 ? (function(e6, t4) {
2761
- var i3;
2762
- const n2 = e6.lastIndexOf(":");
2763
- if (-1 === n2) return e6;
2764
- const r3 = e6.substring(0, n2);
2765
- return `${null !== (i3 = t4.get(r3)) && void 0 !== i3 ? i3 : r3}${e6.substring(n2)}`;
2766
- })(e5, r2) : e5;
2767
- else if (i2.type === n.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) o2 = (e5) => "string" == typeof e5 ? (function(e6, t4) {
2768
- try {
2769
- const i3 = JSON.parse(e6);
2770
- return Array.isArray(i3) ? JSON.stringify(i3.map(((e7) => Object.assign(Object.assign({}, e7), { value: Array.isArray(null == e7 ? void 0 : e7.value) ? e7.value.map(((e8) => {
2771
- var i4;
2772
- return null !== (i4 = t4.get(e8)) && void 0 !== i4 ? i4 : e8;
2773
- })) : null == e7 ? void 0 : e7.value })))) : e6;
2774
- } catch (t5) {
2775
- return e6;
2776
- }
2777
- })(e5, r2) : e5;
2778
- else {
2779
- if (i2.type !== n.FEEDBACKAPPANSWERTYPE.MAX_DIFF) return e4;
2780
- o2 = (e5) => "string" == typeof e5 ? (function(e6, t4) {
2781
- try {
2782
- const i3 = JSON.parse(e6);
2783
- if (!Array.isArray(i3)) return e6;
2784
- const n2 = (e7) => {
2785
- var i4;
2786
- return "string" == typeof e7 && null !== (i4 = t4.get(e7)) && void 0 !== i4 ? i4 : e7;
2787
- };
2788
- return JSON.stringify(i3.map(((e7) => Object.assign(Object.assign({}, e7), { shown: Array.isArray(null == e7 ? void 0 : e7.shown) ? e7.shown.map(n2) : null == e7 ? void 0 : e7.shown, best: n2(null == e7 ? void 0 : e7.best), worst: n2(null == e7 ? void 0 : e7.worst) }))));
2789
- } catch (t5) {
2790
- return e6;
2791
- }
2792
- })(e5, r2) : e5;
2793
- }
2794
- return Object.assign(Object.assign({}, e4), { value: e4.value.map(o2) });
2795
- }));
2796
- };
2797
- }, 9039: (e2, t2) => {
2798
- "use strict";
2799
- Object.defineProperty(t2, "__esModule", { value: true }), t2.answeredInput = t2.autoAdvanceRequested = t2.AUTO_ADVANCE_PARAM = t2.cancelAutoAdvance = t2.autoAdvanceOn = t2.scheduleAutoAdvance = t2.AUTO_ADVANCE_DELAY_MS = void 0, t2.AUTO_ADVANCE_DELAY_MS = 300;
2800
- const i = /* @__PURE__ */ new Map();
2801
- function n(e3, n2) {
2802
- const r = i.get(n2);
2803
- r && clearTimeout(r.timer);
2804
- const o = setTimeout((() => {
2805
- i.delete(n2), e3.isConnected && n2();
2806
- }), t2.AUTO_ADVANCE_DELAY_MS);
2807
- i.set(n2, { timer: o, source: e3 });
2808
- }
2809
- t2.scheduleAutoAdvance = n, t2.autoAdvanceOn = function(e3, t3, i2 = "change") {
2810
- t3 && e3.addEventListener(i2, (() => n(e3, t3)));
2811
- }, t2.cancelAutoAdvance = function(e3) {
2812
- e3 && i.forEach((({ timer: t3, source: n2 }, r) => {
2813
- e3.contains(n2) && (clearTimeout(t3), i.delete(r));
2814
- }));
2815
- }, t2.AUTO_ADVANCE_PARAM = "autoadvance", t2.autoAdvanceRequested = function(e3 = window.location.search) {
2816
- const i2 = new URLSearchParams(e3).get(t2.AUTO_ADVANCE_PARAM);
2817
- return "true" === i2 || "1" === i2;
2818
- }, t2.answeredInput = function(e3, t3) {
2819
- return Array.from(e3.querySelectorAll(".magicfeedback-input")).filter(((e4) => e4.name === t3)).find(((e4) => "radio" === e4.type || "checkbox" === e4.type ? e4.checked : "" !== e4.value)) || null;
2820
- };
2821
- }, 4069: (e2, t2) => {
2822
- "use strict";
2823
- function i(e3) {
2824
- if (!e3) return null;
2825
- const i2 = e3.querySelector(".magicfeedback-div");
2826
- if (!i2) return null;
2827
- const n = i2.querySelector('input:not([type="hidden"]), textarea, select, button');
2828
- if (!n) return null;
2829
- const r = n;
2830
- return r.disabled || r.readOnly ? null : "TEXTAREA" === n.tagName || "INPUT" === n.tagName && t2.AUTOFOCUS_INPUT_TYPES.includes(n.type) ? r : null;
2831
- }
2832
- Object.defineProperty(t2, "__esModule", { value: true }), t2.focusFirstTextQuestion = t2.findAutofocusTarget = t2.AUTOFOCUS_INPUT_TYPES = void 0, t2.AUTOFOCUS_INPUT_TYPES = ["text", "email", "number", "tel", "url", "search"], t2.findAutofocusTarget = i, t2.focusFirstTextQuestion = function(e3) {
2833
- var t3, n;
2834
- if (!e3) return false;
2835
- const r = i(e3);
2836
- if (!r) return false;
2837
- const o = null === (t3 = e3.ownerDocument) || void 0 === t3 ? void 0 : t3.activeElement;
2838
- if (o && !e3.contains(o) && (function(e4) {
2839
- const t4 = e4.tagName;
2840
- return "INPUT" === t4 || "TEXTAREA" === t4 || "SELECT" === t4 || true === e4.isContentEditable;
2841
- })(o)) return false;
2842
- try {
2843
- r.focus({ preventScroll: true });
2844
- } catch (e4) {
2845
- r.focus();
2846
- }
2847
- return (null === (n = e3.ownerDocument) || void 0 === n ? void 0 : n.activeElement) === r;
2848
- };
2849
- }, 9089: (e2, t2) => {
2850
- "use strict";
2851
- Object.defineProperty(t2, "__esModule", { value: true }), t2.armGhostTapGuard = t2.GHOST_TAP_GUARD_MS = void 0, t2.GHOST_TAP_GUARD_MS = 400;
2852
- const i = /* @__PURE__ */ new WeakMap();
2853
- t2.armGhostTapGuard = function(e3) {
2854
- e3 && (i.has(e3) || e3.addEventListener("click", ((r) => {
2855
- var o;
2856
- 0 !== r.detail && (n() - (null !== (o = i.get(e3)) && void 0 !== o ? o : -1 / 0) >= t2.GHOST_TAP_GUARD_MS || (r.preventDefault(), r.stopPropagation()));
2857
- }), true), i.set(e3, n()));
2858
- };
2859
- const n = () => "undefined" != typeof performance ? performance.now() : Date.now();
2860
- }, 4070: (e2, t2) => {
2861
- "use strict";
2862
- Object.defineProperty(t2, "__esModule", { value: true }), t2.Log = void 0, t2.Log = class {
2863
- constructor(e3) {
2864
- this.config = e3;
2865
- }
2866
- log(...e3) {
2867
- this.config.get("debug") && console.log("[MagicFeedback]:", ...e3);
2868
- }
2869
- err(...e3) {
2870
- console.error("[MagicFeedback]:", ...e3);
2871
- }
2872
- };
2873
- }, 8330: (e2) => {
2874
- "use strict";
2875
- e2.exports = JSON.parse('{"name":"@magicfeedback/native","version":"2.2.37","main":"./dist/magicfeedback-sdk.node.js","browser":"./dist/magicfeedback-sdk.browser.js","types":"./dist/types/src/index.d.ts","repository":{"type":"git","url":"git+ssh://git@github.com/MagicFeedback/magicfeedback-sdk.git"},"author":"farias@magicfeedback.io","license":"MIT","private":false,"scripts":{"dev":"vite","build":"webpack","build:watch":"webpack --watch --mode development","release":"npm publish --access public","release:beta":"npm publish --access public --tag beta","release:alpha":"npm publish --access public --tag alpha","test":"jest","test:watch":"jest --watchAll","coverage":"jest --coverage","publish:sdk":"bash publish.sh","publish:sdk:dry-run":"NPM_DRY_RUN=1 bash publish.sh"},"files":["dist"],"devDependencies":{"@babel/preset-typescript":"^7.22.5","@types/node":"^17.0.21","@types/webpack":"^5.28.0","@types/webpack-node-externals":"^2.5.3","c8":"^7.11.0","copy-webpack-plugin":"^11.0.0","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","jest-fetch-mock":"^3.0.3","nock":"^13.2.4","ts-jest":"^29.1.0","ts-loader":"^9.2.7","ts-node":"^10.7.0","typescript":"^4.6.2","vite":"^2.8.0","vite-plugin-dts":"^0.9.9","webpack":"^5.70.0","webpack-cli":"^4.9.2","webpack-node-externals":"^3.0.0"},"dependencies":{"cross-fetch":"^3.1.5","is-bundling-for-browser-or-node":"^1.1.1"},"description":"MagicFeedbackAI JavaScript Library for [MagicFeedback.io](https://magicfeedback.io/)","bugs":{"url":"https://github.com/MagicFeedback/magicfeedback-sdk/issues"},"homepage":"https://github.com/MagicFeedback/magicfeedback-sdk#readme","directories":{"example":"examples","test":"test"},"style":"./dist/styles/magicfeedback-default.css"}');
2876
- } }, t = {}, (function i(n) {
2877
- var r = t[n];
2878
- if (void 0 !== r) return r.exports;
2879
- var o = t[n] = { exports: {} };
2880
- return e[n].call(o.exports, o, o.exports, i), o.exports;
2881
- })(1422).default;
2882
- var e, t;
2883
- }));
2884
- }
2885
- });
2886
-
2887
- // src/ui/logo.ts
2888
- var BASE_CSS = "max-height:40px; max-width:100%; object-fit:contain; display:block; margin:12px 0 0 0;";
2889
- var MAX_HEIGHT = {
2890
- small: "30px",
2891
- medium: "50px",
2892
- large: "70px"
2893
- };
2894
- function insertPopupLogo(parent, anchor, style, id) {
2895
- if (!style?.logo) return null;
2896
- if (parent.ownerDocument.getElementById(id)) return null;
2897
- const img = parent.ownerDocument.createElement("img");
2898
- img.id = id;
2899
- img.src = style.logo;
2900
- img.alt = "Logo";
2901
- img.style.cssText = BASE_CSS;
2902
- if (style.logoSize && MAX_HEIGHT[style.logoSize]) {
2903
- img.style.maxHeight = MAX_HEIGHT[style.logoSize];
2904
- }
2905
- switch (style.logoPosition) {
2906
- case "left":
2907
- img.style.margin = "12px 0 0 0";
2908
- img.style.setProperty("margin-inline-start", "0");
2909
- img.style.setProperty("margin-inline-end", "16px");
2910
- break;
2911
- case "right":
2912
- img.style.margin = "12px 0 0 0";
2913
- img.style.setProperty("margin-inline-start", "auto");
2914
- img.style.setProperty("margin-inline-end", "0");
2915
- break;
2916
- case "center":
2917
- img.style.margin = "12px auto 0 auto";
2918
- break;
2919
- }
2920
- parent.insertBefore(img, anchor);
2921
- return img;
2922
- }
2923
-
2924
- // src/ui/renderPopup.ts
2925
- var import_native = __toESM(require_magicfeedback_sdk_browser());
2926
- function ensureStyle(id, css, nonce) {
2927
- let el = document.getElementById(id);
2928
- if (el && nonce && el.getAttribute("nonce") !== nonce) {
2929
- el.remove();
2930
- el = null;
2931
- }
2932
- if (!el) {
2933
- el = document.createElement("style");
2934
- el.id = id;
2935
- if (nonce) el.setAttribute("nonce", nonce);
2936
- el.textContent = css;
2937
- document.head.appendChild(el);
2938
- } else if (el.textContent !== css) {
2939
- el.textContent = css;
2940
- }
2941
- return el;
2942
- }
2943
- function ensureMagicFeedbackStyles(nonce) {
2944
- ensureStyle("magicfeedback-sdk-styles", style_default, nonce);
2945
- }
2946
- var SURVEY_ALIGNMENT_STYLE_ID = "deepdots-survey-alignment";
2947
- function ensureSurveyAlignmentStyles(nonce) {
2948
- ensureStyle(SURVEY_ALIGNMENT_STYLE_ID, `
2949
- .deepdots-popup .magicfeedback-container,
2950
- .deepdots-popup .magicfeedback-form,
2951
- .deepdots-popup .magicfeedback-div { padding-left: 0; padding-right: 0; }
2952
- `, nonce);
2953
- }
2954
- function ensureSpinnerStyles(nonce) {
2955
- ensureStyle("deepdots-spinner-styles", `
2956
- /* El enunciado trae margin-top:20px del CSS de surveys, que sumaba al hueco de la barra
2957
- de progreso y descompensaba la simetr\xEDa. Solo se anula en el primero: entre preguntas
2958
- de la misma p\xE1gina sigue separando. */
2959
- .deepdots-popup .magicfeedback-questions .magicfeedback-div:first-child .magicfeedback-label { margin-top: 0; }
2960
- @keyframes ddspin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
2961
- .mf-spinner { display:flex; justify-content:center; align-items:center; padding:8px 0; }
2962
- .mf-spinner-circle { width:28px; height:28px; border:3px solid #e0e6ed; border-top-color:#1E293B; border-radius:50%; animation: ddspin 0.9s linear infinite; }
2963
- `, nonce);
2964
- }
2965
- function ensureResponsiveStyles(nonce) {
2966
- ensureStyle("deepdots-responsive-styles", `
2967
- /* Responsive adjustments */
2968
- @media (max-width: 640px) {
2969
- .deepdots-popup {
2970
- width: calc(100% - 24px) !important;
2971
- max-width: calc(100% - 24px) !important;
2972
- height: auto !important;
2973
- max-height: 90vh !important;
2974
- border-radius: 12px !important;
2975
- padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)) 16px !important;
2976
- box-sizing: border-box;
2977
- }
2978
- .deepdots-popup .mf-spinner-circle { width: 32px; height: 32px; border-width: 4px; }
2979
- .deepdots-popup button { font-size: 16px !important; }
2980
- .deepdots-popup-header button { width:48px; height:48px; }
2981
- .deepdots-popup-header button svg { width:26px; height:26px; }
2982
- /* Apilados en el orden del DOM: la acci\xF3n principal (Send/Start/Complete) arriba y
2983
- Back debajo. */
2984
- .deepdots-popup-footer { flex-direction: column !important; gap: 4px !important; }
2985
- .deepdots-popup-footer button { width: 100%; }
2986
- }
2987
- @media (max-width: 400px) {
2988
- .deepdots-popup { padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)) 12px !important; }
2989
- .deepdots-popup-header button { width:48px; height:48px; }
2990
- .deepdots-popup-header button svg { width:26px; height:26px; }
2991
- }
2992
- @media (orientation: landscape) and (max-height: 480px) {
2993
- .deepdots-popup {
2994
- height: 100vh !important;
2995
- max-height: 100vh !important;
2996
- overflow-y: auto !important;
2997
- }
2998
- }
2999
- `, nonce);
3000
- }
3001
- function ensureCustomCss(css, nonce) {
3002
- const STYLE_ID = "deepdots-custom-css";
3003
- if (!css) {
3004
- document.getElementById(STYLE_ID)?.remove();
3005
- return;
3006
- }
3007
- document.head.appendChild(ensureStyle(STYLE_ID, css, nonce));
3008
- }
3009
- function ensureFontFace(family, url, nonce) {
3010
- const css = buildFontFaceCss(family, url);
3011
- if (!css) return;
3012
- ensureStyle("deepdots-font-face", css, nonce);
3013
- }
3014
- function hasFinePointer() {
3015
- return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(pointer: fine)").matches;
3016
- }
3017
- async function renderPopup(container, surveyId, productId, actions, emit, onClose, env = "production", userId, style, sessionId, miniService, analyticsFeedbackSessionId, options) {
3018
- let surveyCompletedEmitted = false;
3019
- let stylesInjected = false;
3020
- let pageDepth = 0;
3021
- let onStartPage = false;
3022
- const cspNonce = options?.cspNonce?.trim() || void 0;
3023
- let labels = getLabels(options?.language);
3024
- let actionLabels = resolveActionLabels(actions, options?.language);
3025
- let direction = directionFor(options?.language);
3026
- const isDark = style?.theme === "dark";
3027
- const theme = {
3028
- popupBg: isDark ? "#1e1e1e" : "#fff",
3029
- // El popup fija su propio fondo, así que debe fijar también el esquema de color.
3030
- // Sin esto los controles de formulario (input/textarea/select) caen al estilo por
3031
- // defecto del navegador: en un host con `prefers-color-scheme: dark` se pintan
3032
- // oscuros con texto blanco sobre el fondo claro del popup.
3033
- colorScheme: isDark ? "dark" : "light",
3034
- textPrimary: isDark ? "#f0f0f0" : "#111",
3035
- closeBtnHoverColor: isDark ? "#fff" : "#000000",
3036
- textMuted: isDark ? "#9ca3af" : "#6b7280",
3037
- progressTrack: isDark ? "#3f3f46" : "#e5e7eb"
3038
- };
3039
- const positionMap = {
3040
- "center": { justifyContent: "center", alignItems: "center", background: "rgba(0,0,0,0.5)" },
3041
- "bottom": { justifyContent: "center", alignItems: "flex-end", padding: "16px", background: "transparent" },
3042
- "bottom-right": { justifyContent: "flex-end", alignItems: "flex-end", padding: "16px", background: "transparent" },
3043
- "bottom-left": { justifyContent: "flex-start", alignItems: "flex-end", padding: "16px", background: "transparent" },
3044
- "top": { justifyContent: "center", alignItems: "flex-start", padding: "16px", background: "transparent" },
3045
- "top-right": { justifyContent: "flex-end", alignItems: "flex-start", padding: "16px", background: "transparent" },
3046
- "top-left": { justifyContent: "flex-start", alignItems: "flex-start", padding: "16px", background: "transparent" }
3047
- };
3048
- const pos = positionMap[style?.position ?? "center"] ?? positionMap["center"];
3049
- const passThrough = pos.background === "transparent";
3050
- const popup = document.createElement("div");
3051
- popup.id = "dd-popup";
3052
- popup.className = "deepdots-popup";
3053
- popup.setAttribute("dir", direction);
3054
- popup.style.cssText = `
3055
- position: relative;
3056
- pointer-events: auto;
3057
- display: flex;
3058
- flex-direction: column;
3059
- justify-content: flex-start;
3060
- background: ${theme.popupBg};
3061
- color-scheme: ${theme.colorScheme};
3062
- border-radius: 8px;
3063
- padding: 24px;
3064
- box-shadow: 0 4px 6px rgba(0,0,0,0.1);
3065
- max-width: 600px;
3066
- width: 90%;
3067
- max-height: 90vh;
3068
- min-height: 200px;
3069
- `;
3070
- const font = style?.font;
3071
- if (font?.family) {
3072
- const familyValue = buildFontFamilyValue(font.family);
3073
- popup.style.fontFamily = familyValue;
3074
- popup.style.setProperty("--deepdots-font", familyValue);
3075
- popup.classList.add("deepdots-has-font");
3076
- if (font.url) ensureFontFace(font.family, font.url, cspNonce);
3077
- }
3078
- const header = document.createElement("div");
3079
- header.className = "deepdots-popup-header";
3080
- header.style.cssText = "display:flex; justify-content:space-between; align-items:center; gap:12px; width:100%; flex:0 0 auto;";
3081
- const titleEl = document.createElement("h2");
3082
- titleEl.id = "dd-title";
3083
- titleEl.className = "deepdots-popup-title";
3084
- titleEl.style.cssText = `margin:0; font-size:17px; font-weight:600; line-height:1.3; color:${theme.textPrimary}; text-transform:none; text-align:start; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;`;
3085
- titleEl.hidden = true;
3086
- const setTitle = (value) => {
3087
- if (!value) return;
3088
- titleEl.textContent = value;
3089
- titleEl.hidden = false;
3090
- };
3091
- setTitle(options?.title);
3092
- header.appendChild(titleEl);
3093
- const closeBtn = document.createElement("button");
3094
- closeBtn.id = "dd-close";
3095
- closeBtn.type = "button";
3096
- closeBtn.setAttribute("aria-label", labels.closeAria);
3097
- closeBtn.innerHTML = `
3098
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
3099
- <path d="M5 5L19 19M5 19L19 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="butt"/>
3100
- </svg>
3101
- `;
3102
- closeBtn.style.cssText = `
3103
- background:transparent;
3104
- border:none;
3105
- width:32px;
3106
- height:32px;
3107
- display:flex;
3108
- align-items:center;
3109
- justify-content:center;
3110
- border-radius: 8px;
3111
- cursor:pointer;
3112
- color:${theme.textPrimary};
3113
- padding:4px;
3114
- transition: color .15s ease, transform .15s ease;
3115
- box-shadow: none !important;
3116
- `;
3117
- closeBtn.onmouseenter = () => {
3118
- closeBtn.style.color = theme.closeBtnHoverColor;
3119
- closeBtn.style.transform = "scale(1.06)";
3120
- };
3121
- closeBtn.onmouseleave = () => {
3122
- closeBtn.style.color = theme.textPrimary;
3123
- closeBtn.style.transform = "scale(1)";
3124
- };
3125
- const closeFromChrome = () => {
3126
- emit("popup_clicked", surveyId, { action: "close_icon" });
3127
- onClose();
3128
- };
3129
- closeBtn.onclick = closeFromChrome;
3130
- closeBtn.style.flex = "0 0 auto";
3131
- closeBtn.style.marginLeft = "auto";
3132
- header.appendChild(closeBtn);
3133
- let progressEnabled = options?.showProgressBar === true;
3134
- let progressShowUnit = true;
3135
- let progressUnit = "fraction";
3136
- const progressEl = document.createElement("div");
3137
- progressEl.id = "dd-progress";
3138
- progressEl.className = "deepdots-progress";
3139
- progressEl.style.cssText = "display:none; flex-direction:column; gap:8px; width:100%; flex:0 0 auto; padding:16px 0; box-sizing:border-box;";
3140
- const progressHead = document.createElement("div");
3141
- progressHead.className = "deepdots-progress-head";
3142
- progressHead.style.cssText = "display:flex; flex-direction:row; justify-content:space-between; align-items:center; width:100%; gap:8px;";
3143
- const progressLabel = document.createElement("span");
3144
- progressLabel.id = "dd-progress-label";
3145
- progressLabel.style.cssText = "font-size:13px; line-height:1.2;";
3146
- const progressCurrent = document.createElement("span");
3147
- progressCurrent.id = "dd-progress-current";
3148
- progressCurrent.style.cssText = `font-weight:700; color:${theme.textPrimary};`;
3149
- const progressTotal = document.createElement("span");
3150
- progressTotal.id = "dd-progress-total";
3151
- progressTotal.style.cssText = `font-weight:400; color:${theme.textMuted};`;
3152
- progressLabel.appendChild(progressCurrent);
3153
- progressLabel.appendChild(progressTotal);
3154
- const progressFollowUp = document.createElement("span");
3155
- progressFollowUp.id = "dd-progress-followup";
3156
- progressFollowUp.textContent = labels.followUp;
3157
- progressFollowUp.style.cssText = "display:none; font-size:12px; font-weight:600; color:#fff; background:rgba(59,130,246,0.44); border-radius:999px; padding:2px 10px;";
3158
- progressHead.appendChild(progressLabel);
3159
- progressHead.appendChild(progressFollowUp);
3160
- const progressTrack = document.createElement("div");
3161
- progressTrack.className = "deepdots-progress-track";
3162
- progressTrack.style.cssText = `width:100%; height:4px; border-radius:999px; background:${theme.progressTrack}; overflow:hidden;`;
3163
- const progressBar = document.createElement("div");
3164
- progressBar.id = "dd-progress-bar";
3165
- progressBar.style.cssText = "height:100%; width:0%; background:#22C55E; border-radius:999px; transition:width 450ms ease;";
3166
- progressTrack.appendChild(progressBar);
3167
- progressEl.appendChild(progressHead);
3168
- progressEl.appendChild(progressTrack);
3169
- function updateProgress(p) {
3170
- const total = typeof p.total === "number" ? p.total : 0;
3171
- const progress = typeof p.progress === "number" ? p.progress : 0;
3172
- if (!progressEnabled || onStartPage || p.completed || total <= 1) {
3173
- progressEl.style.display = "none";
3174
- containerContent.style.paddingTop = "16px";
3175
- return;
3176
- }
3177
- progressEl.style.display = "flex";
3178
- containerContent.style.paddingTop = "0";
3179
- const current = Math.min(total, Math.max(1, progress + 1));
3180
- const pct = Math.min(100, Math.max(0, current / total * 100));
3181
- progressBar.style.width = `${pct}%`;
3182
- const label = Math.min(total, Math.max(1, Math.floor(progress) + 1));
3183
- progressLabel.style.display = progressShowUnit ? "block" : "none";
3184
- if (progressUnit === "percentage") {
3185
- progressCurrent.textContent = `${Math.round(pct)}%`;
3186
- progressTotal.textContent = "";
3187
- } else {
3188
- progressCurrent.textContent = `${labels.question} ${label}`;
3189
- progressTotal.textContent = ` ${labels.of} ${total}`;
3190
- }
3191
- progressFollowUp.style.display = p.followup ? "inline-block" : "none";
3192
- }
3193
- ensureMagicFeedbackStyles(cspNonce);
3194
- ensureSurveyAlignmentStyles(cspNonce);
3195
- ensureSpinnerStyles(cspNonce);
3196
- ensureResponsiveStyles(cspNonce);
3197
- ensureCustomCss(options?.surveyCss, cspNonce);
3198
- const containerContent = document.createElement("div");
3199
- containerContent.id = "dd-content";
3200
- containerContent.className = "deepdots-popup-container-content";
3201
- containerContent.style.cssText = "display:flex; flex-direction:column; flex:1 1 auto; min-height:0; padding:16px 0 0 0; overflow:hidden;";
3202
- const main = document.createElement("div");
3203
- main.id = "dd-main";
3204
- main.className = "deepdots-popup-main";
3205
- main.style.cssText = "display:flex; flex-direction:column; width:100%; flex:1 1 auto; min-height:0; overflow-y:auto;";
3206
- const formWrapper = document.createElement("div");
3207
- formWrapper.id = "dd-form-wrapper";
3208
- formWrapper.style.cssText = "width:100%; flex: 1 1 auto;";
3209
- const errorHint = document.createElement("div");
3210
- errorHint.id = "dd-error";
3211
- errorHint.className = "deepdots-error-hint";
3212
- errorHint.style.cssText = `
3213
- display: none;
3214
- margin: 12px 0 0 0;
3215
- padding: 10px 12px;
3216
- border-radius: 6px;
3217
- background: #FEF3C7; /* amber-100 */
3218
- color: #92400E; /* amber-700 */
3219
- border: 1px solid #FCD34D; /* amber-300 */
3220
- font-size: 13px;
3221
- `;
3222
- errorHint.setAttribute("role", "alert");
3223
- errorHint.setAttribute("aria-live", "polite");
3224
- const spinnerEl = document.createElement("div");
3225
- spinnerEl.className = "mf-spinner";
3226
- spinnerEl.setAttribute("role", "status");
3227
- spinnerEl.setAttribute("aria-label", labels.loadingAria);
3228
- spinnerEl.innerHTML = '<div class="mf-spinner-circle"></div>';
3229
- spinnerEl.style.cssText = "position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);";
3230
- const formDivId = `magicfeedback-form-${surveyId}`;
3231
- const formHost = document.createElement("div");
3232
- formHost.id = formDivId;
3233
- formHost.style.cssText = "width:100%; visibility:hidden;";
3234
- formWrapper.appendChild(spinnerEl);
3235
- formWrapper.appendChild(formHost);
3236
- main.appendChild(formWrapper);
3237
- const loadErrorEl = document.createElement("div");
3238
- loadErrorEl.id = "dd-load-error";
3239
- loadErrorEl.className = "deepdots-load-error";
3240
- loadErrorEl.setAttribute("role", "alert");
3241
- loadErrorEl.style.cssText = `display:none; width:100%; text-align:center; padding:24px 0; font-size:15px; color:${theme.textPrimary};`;
3242
- main.appendChild(loadErrorEl);
3243
- main.appendChild(errorHint);
3244
- const footer = document.createElement("div");
3245
- footer.id = "dd-footer";
3246
- footer.className = "deepdots-popup-footer";
3247
- footer.setAttribute("data-actions-wrapper", "true");
3248
- footer.style.cssText = "display:flex; flex-direction: row-reverse ;justify-content:space-between; align-items:center; gap:4px; margin-top:auto; width:100%; padding-top:12px;";
3249
- const backButton = document.createElement("button");
3250
- backButton.id = "dd-back";
3251
- backButton.className = "dd-nav-btn";
3252
- backButton.textContent = actionLabels.back;
3253
- backButton.style.cssText = `
3254
- background: transparent;
3255
- color: ${theme.textMuted};
3256
- border: none;
3257
- min-height: 44px;
3258
- padding: 12px 24px;
3259
- border-radius: 999px; /* p\xEDldora, como el Button de Material3 en KMP */
3260
- cursor: pointer;
3261
- font-size: 15px;
3262
- font-weight: 600;
3263
- transition: filter .15s ease;
3264
- display: inline-flex;
3265
- align-items: center;
3266
- justify-content: center;
3267
- text-align: center;
3268
- `;
3269
- backButton.onmouseenter = () => {
3270
- backButton.style.filter = "brightness(0.9)";
3271
- };
3272
- backButton.onmouseleave = () => {
3273
- backButton.style.filter = "brightness(1)";
3274
- };
3275
- backButton.onclick = () => {
3276
- emit("popup_clicked", surveyId, { action: "back" });
3277
- formInstance?.back?.();
3278
- };
3279
- const startButton = document.createElement("button");
3280
- startButton.id = "dd-start";
3281
- startButton.className = "dd-nav-btn";
3282
- startButton.textContent = actionLabels.start;
3283
- startButton.style.cssText = `
3284
- background: #1E293B;
3285
- color: #fff;
3286
- border: none;
3287
- min-height: 44px;
3288
- padding: 12px 24px;
3289
- border-radius: 999px; /* p\xEDldora, como el Button de Material3 en KMP */
3290
- cursor: pointer;
3291
- font-size: 15px;
3292
- font-weight: 600;
3293
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
3294
- transition: filter .15s ease;
3295
- display: inline-flex;
3296
- align-items: center;
3297
- justify-content: center;
3298
- text-align: center;
3299
- `;
3300
- startButton.onclick = () => {
3301
- emit("popup_clicked", surveyId, { action: "start_survey" });
3302
- formInstance?.startForm?.();
3303
- onStartPage = false;
3304
- updateProgress({ progress: formInstance?.progress, total: formInstance?.total });
3305
- };
3306
- const closeButton = document.createElement("button");
3307
- closeButton.id = "dd-complete";
3308
- closeButton.className = "dd-nav-btn";
3309
- closeButton.textContent = actionLabels.complete;
3310
- closeButton.style.cssText = `
3311
- background: #1E293B;
3312
- color: #fff;
3313
- border: none;
3314
- min-height: 44px;
3315
- padding: 12px 24px;
3316
- border-radius: 999px; /* p\xEDldora, como el Button de Material3 en KMP */
3317
- cursor: pointer;
3318
- font-size: 15px;
3319
- font-weight: 600;
3320
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
3321
- transition: filter .15s ease;
3322
- display: inline-flex;
3323
- align-items: center;
3324
- justify-content: center;
3325
- text-align: center;
3326
- `;
3327
- closeButton.onmouseenter = () => {
3328
- closeButton.style.filter = "brightness(0.9)";
3329
- };
3330
- closeButton.onmouseleave = () => {
3331
- closeButton.style.filter = "brightness(1)";
3332
- };
3333
- closeButton.onclick = () => {
3334
- emit("popup_clicked", surveyId, { action: "complete" });
3335
- onClose();
3336
- };
3337
- const submitButton = document.createElement("button");
3338
- submitButton.id = "dd-submit";
3339
- submitButton.className = "dd-nav-btn";
3340
- submitButton.textContent = actionLabels.accept;
3341
- submitButton.style.cssText = `
3342
- background: #1E293B;
3343
- color: #fff;
3344
- border: none;
3345
- min-height: 44px;
3346
- padding: 12px 24px;
3347
- border-radius: 999px; /* p\xEDldora, como el Button de Material3 en KMP */
3348
- cursor: pointer;
3349
- font-size: 15px;
3350
- font-weight: 600;
3351
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
3352
- transition: filter .15s ease;
3353
- display: inline-flex;
3354
- align-items: center;
3355
- justify-content: center;
3356
- text-align: center;
3357
- `;
3358
- const cancelButton = document.createElement("button");
3359
- cancelButton.id = "dd-cancel";
3360
- cancelButton.type = "button";
3361
- cancelButton.className = "dd-nav-btn";
3362
- cancelButton.textContent = actionLabels.decline;
3363
- cancelButton.style.cssText = submitButton.style.cssText;
3364
- cancelButton.onclick = closeFromChrome;
3365
- submitButton.onclick = () => {
3366
- if (!surveyCompletedEmitted) {
3367
- emit("popup_clicked", surveyId, { action: "manual_send" });
3368
- formInstance?.send?.();
3369
- }
3370
- };
3371
- function applyLabels(lang) {
3372
- labels = getLabels(lang);
3373
- actionLabels = resolveActionLabels(actions, lang);
3374
- backButton.textContent = actionLabels.back;
3375
- startButton.textContent = actionLabels.start;
3376
- closeButton.textContent = actionLabels.complete;
3377
- submitButton.textContent = actionLabels.accept;
3378
- cancelButton.textContent = actionLabels.decline;
3379
- loadErrorEl.textContent = labels.errorLoad;
3380
- closeBtn.setAttribute("aria-label", labels.closeAria);
3381
- spinnerEl.setAttribute("aria-label", labels.loadingAria);
3382
- progressFollowUp.textContent = labels.followUp;
3383
- direction = directionFor(lang);
3384
- popup.setAttribute("dir", direction);
3385
- }
3386
- backButton.style.display = "none";
3387
- startButton.style.display = "none";
3388
- submitButton.style.display = "none";
3389
- closeButton.style.display = "none";
3390
- cancelButton.style.display = "none";
3391
- footer.appendChild(submitButton);
3392
- footer.appendChild(backButton);
3393
- footer.appendChild(closeButton);
3394
- footer.appendChild(startButton);
3395
- footer.appendChild(cancelButton);
3396
- containerContent.appendChild(main);
3397
- footer.style.flex = "0 0 auto";
3398
- containerContent.appendChild(footer);
3399
- function updateButtons(state) {
3400
- backButton.style.display = "none";
3401
- startButton.style.display = "none";
3402
- submitButton.style.display = "none";
3403
- closeButton.style.display = "none";
3404
- cancelButton.style.display = "none";
3405
- backButton.style.width = "";
3406
- startButton.style.width = "";
3407
- submitButton.style.width = "";
3408
- closeButton.style.width = "";
3409
- switch (state) {
3410
- case "loading":
3411
- break;
3412
- case "start":
3413
- startButton.style.display = "inline-flex";
3414
- startButton.style.width = "100%";
3415
- break;
3416
- case "in_progress_first":
3417
- submitButton.style.display = "inline-flex";
3418
- submitButton.style.width = "";
3419
- setLoading(false);
3420
- break;
3421
- case "in_progress_next":
3422
- backButton.style.display = "inline-flex";
3423
- submitButton.style.display = "inline-flex";
3424
- setLoading(false);
3425
- break;
3426
- case "completed":
3427
- closeButton.style.display = "inline-flex";
3428
- closeButton.style.width = "100%";
3429
- setLoading(false);
3430
- break;
3431
- case "error":
3432
- setLoading(false);
3433
- break;
3434
- case "load_error":
3435
- cancelButton.style.display = "inline-flex";
3436
- break;
3437
- }
3438
- }
3439
- function updateNavButtons() {
3440
- updateButtons(pageDepth > 0 ? "in_progress_next" : "in_progress_first");
3441
- }
3442
- let successMessageHtml = "";
3443
- function showSuccessScreen() {
3444
- progressEl.style.display = "none";
3445
- formWrapper.style.display = "none";
3446
- let done = main.querySelector(".deepdots-success");
3447
- if (!done) {
3448
- done = document.createElement("div");
3449
- done.className = "deepdots-success";
3450
- done.style.cssText = `width:100%; text-align:center; padding:24px 0; color:${theme.textPrimary};`;
3451
- main.insertBefore(done, errorHint);
3452
- }
3453
- done.innerHTML = successMessageHtml || "<p>Thank you for your feedback!</p>";
3454
- done.querySelectorAll("img").forEach((img) => {
3455
- img.style.cssText = "max-width:100%; height:auto; margin:0 auto 16px auto; display:block;";
3456
- });
3457
- }
3458
- let loadFailed = false;
3459
- function showLoadError(reason) {
3460
- sdkWarn("[Deepdots] survey failed to load:", reason);
3461
- if (loadFailed) return;
3462
- loadFailed = true;
3463
- progressEl.style.display = "none";
3464
- formWrapper.style.display = "none";
3465
- errorHint.style.display = "none";
3466
- loadErrorEl.textContent = labels.errorLoad;
3467
- loadErrorEl.style.display = "block";
3468
- setLoading(false);
3469
- updateButtons("load_error");
3470
- reveal();
3471
- }
3472
- popup.appendChild(header);
3473
- popup.appendChild(progressEl);
3474
- popup.appendChild(containerContent);
3475
- container.innerHTML = "";
3476
- container.appendChild(popup);
3477
- container.style.display = "flex";
3478
- container.style.visibility = "hidden";
3479
- container.style.pointerEvents = "none";
3480
- container.style.justifyContent = pos.justifyContent;
3481
- container.style.alignItems = pos.alignItems;
3482
- container.style.background = pos.background;
3483
- if (pos.padding) container.style.padding = pos.padding;
3484
- let revealed = false;
3485
- let revealTimer = null;
3486
- let surveyLoaded = false;
3487
- let openFocusDone = false;
3488
- function autofocusOnOpen() {
3489
- if (openFocusDone || !revealed || !surveyLoaded) return;
3490
- openFocusDone = true;
3491
- if (hasFinePointer()) formInstance?.focusFirstQuestion?.();
3492
- }
3493
- function reveal() {
3494
- if (revealed) return;
3495
- revealed = true;
3496
- if (revealTimer !== null) {
3497
- clearTimeout(revealTimer);
3498
- revealTimer = null;
3499
- }
3500
- if (!container.contains(popup)) return;
3501
- container.style.visibility = "visible";
3502
- container.style.pointerEvents = passThrough ? "none" : "";
3503
- autofocusOnOpen();
3504
- }
3505
- function revealWhenPainted2() {
3506
- if (revealed) return;
3507
- revealWhenPainted(popup, reveal);
3508
- }
3509
- revealTimer = setTimeout(reveal, REVEAL_TIMEOUT_MS);
3510
- function setLoading(isLoading) {
3511
- spinnerEl.style.display = isLoading ? "flex" : "none";
3512
- setSurveyBusy(formWrapper, isLoading);
3513
- if (!isLoading) {
3514
- formHost.style.visibility = "visible";
3515
- revealWhenPainted2();
3516
- }
3517
- footer.style.display = isLoading ? "none" : "flex";
3518
- backButton.disabled = isLoading;
3519
- startButton.disabled = isLoading;
3520
- closeButton.disabled = isLoading;
3521
- submitButton.disabled = isLoading;
3522
- submitButton.style.opacity = isLoading ? "0.6" : "1";
3523
- submitButton.style.cursor = isLoading ? "not-allowed" : "pointer";
3524
- if (isLoading) {
3525
- updateButtons("loading");
3526
- }
3527
- }
3528
- setLoading(true);
3529
- if (typeof window === "undefined" || typeof document === "undefined") {
3530
- return;
3531
- }
3532
- let formInstance = null;
3533
- try {
3534
- if (!import_native.default || typeof import_native.default.form !== "function") {
3535
- sdkWarn("[MagicFeedback] form() no disponible. Fallback manual.");
3536
- showLoadError("form() not available");
3537
- return;
3538
- }
3539
- import_native.default.init(
3540
- {
3541
- debug: true,
3542
- env: env === "production" ? "prod" : "dev"
3543
- }
3544
- );
3545
- const { profile, metadata } = buildSurveyIdentity(userId ?? null, sessionId ?? null, miniService ?? null, analyticsFeedbackSessionId ?? null);
3546
- formInstance = import_native.default.form(surveyId, productId, profile, metadata);
3547
- const generateOptions = {
3548
- addButton: false,
3549
- getMetaData: true,
3550
- // La pantalla final la pinta el popup: `renderSuccess` de @magicfeedback/native usa
3551
- // textContent, así que el mensaje de la plataforma (HTML con imagen) no se vería, y
3552
- // su fallback es un literal genérico que ignora `style.successMessage`.
3553
- addSuccessScreen: false,
3554
- // Surveys multi-idioma: native pide a la API este idioma (el del init o el del
3555
- // dispositivo) y, si el survey no lo tiene, la API sirve el idioma por defecto.
3556
- lang: options?.language,
3557
- // Foco en la primera pregunta de escribir tras Start, Siguiente o Atrás. Native lo
3558
- // aplica después de afterSubmitEvent/onBackEvent, cuando `setLoading(false)` ya ha
3559
- // quitado el `inert`. La apertura va aparte (ver autofocusOnOpen).
3560
- autofocus: "navigation"
3561
- };
3562
- generateOptions.onLoadedEvent = ({ formData, lang, error }) => {
3563
- if (error) {
3564
- showLoadError(error);
3565
- return;
3566
- }
3567
- const shownLang = typeof lang === "string" && lang.trim().length > 0 ? lang : void 0;
3568
- const surveyLang = shownLang ?? (Array.isArray(formData?.lang) ? formData.lang.find((l) => typeof l === "string" && l.trim().length > 0) : void 0);
3569
- if (surveyLang) applyLabels(surveyLang);
3570
- try {
3571
- } catch {
3572
- }
3573
- const s = formData?.style;
3574
- if (s && !stylesInjected) {
3575
- stylesInjected = true;
3576
- if (s.successMessage) successMessageHtml = s.successMessage;
3577
- if (options?.showProgressBar === void 0) progressEnabled = s.showProgressBar === true;
3578
- if (s.showProgressUnit !== void 0) progressShowUnit = s.showProgressUnit !== false;
3579
- if (s.progressUnit) progressUnit = s.progressUnit;
3580
- if (s.loadingBarColor) {
3581
- progressBar.style.background = s.loadingBarColor;
3582
- progressFollowUp.style.background = s.loadingBarColor;
3583
- }
3584
- if (s.boxBackgroundColor) {
3585
- popup.style.background = s.boxBackgroundColor;
3586
- }
3587
- if (s.contentAlign) {
3588
- main.style.justifyContent = s.contentAlign === "center" ? "center" : "flex-start";
3589
- }
3590
- applySurveyPrimaryColor(popup, s);
3591
- if (s.buttonPrimaryColor) {
3592
- submitButton.style.background = s.buttonPrimaryColor;
3593
- submitButton.style.border = "none";
3594
- submitButton.style.color = "#fff";
3595
- startButton.style.background = s.buttonPrimaryColor;
3596
- startButton.style.border = "none";
3597
- startButton.style.color = "#fff";
3598
- closeButton.style.background = s.buttonPrimaryColor;
3599
- closeButton.style.border = "none";
3600
- closeButton.style.color = "#fff";
3601
- }
3602
- if (s.buttonSecondaryColor) {
3603
- backButton.style.background = "transparent";
3604
- backButton.style.color = s.buttonSecondaryColor;
3605
- backButton.style.border = "none";
3606
- }
3607
- insertPopupLogo(popup, progressEl, s, "deepdots-popup-logo");
3608
- if (s.startMessage && s.startMessage !== "") {
3609
- sdkLog(s.startMessage);
3610
- onStartPage = true;
3611
- updateButtons("start");
3612
- } else {
3613
- updateButtons("in_progress_first");
3614
- }
3615
- } else {
3616
- updateButtons("in_progress_first");
3617
- }
3618
- updateProgress({ progress: formInstance.progress, total: formInstance.total });
3619
- setLoading(false);
3620
- if (!surveyLoaded) {
3621
- surveyLoaded = true;
3622
- autofocusOnOpen();
3623
- }
3624
- };
3625
- let lastReportedError = null;
3626
- generateOptions.beforeSubmitEvent = () => {
3627
- setLoading(true);
3628
- };
3629
- generateOptions.afterSubmitEvent = ({ error, completed, total, progress, followup }) => {
3630
- if (error) {
3631
- setLoading(false);
3632
- const { reason, message } = classifySubmitError(error);
3633
- if (reason === "required") {
3634
- errorHint.textContent = labels.errorRequired;
3635
- errorHint.style.display = "block";
3636
- updateNavButtons();
3637
- return;
3638
- }
3639
- errorHint.textContent = labels.errorSubmit;
3640
- errorHint.style.display = "block";
3641
- sdkWarn("[Deepdots] survey submit error:", reason, message);
3642
- if (error !== lastReportedError) {
3643
- lastReportedError = error;
3644
- emit("survey_error", surveyId, { reason, message });
3645
- }
3646
- return;
3647
- }
3648
- errorHint.style.display = "none";
3649
- setLoading(false);
3650
- if (completed) {
3651
- emit("survey_completed", surveyId, { action: "completed" });
3652
- surveyCompletedEmitted = true;
3653
- showSuccessScreen();
3654
- updateButtons("completed");
3655
- updateProgress({ progress, total, completed: true });
3656
- return;
3657
- }
3658
- emit("popup_clicked", surveyId, { action: "partial" });
3659
- pageDepth++;
3660
- updateNavButtons();
3661
- updateProgress({ progress, total, followup });
3662
- };
3663
- generateOptions.onBackEvent = ({ progress, error, followup }) => {
3664
- if (!error) pageDepth = Math.max(0, pageDepth - 1);
3665
- updateNavButtons();
3666
- updateProgress({ progress, total: formInstance.total, followup });
3667
- };
3668
- formInstance.generate(formDivId, generateOptions).catch((err) => {
3669
- sdkError("[MagicFeedback] Error generating form:", err);
3670
- showLoadError(err);
3671
- });
3672
- } catch (e) {
3673
- sdkError("[MagicFeedback] Exception initializing form:", e);
3674
- showLoadError(e);
3675
- }
3676
- }
3677
- export {
3678
- REVEAL_TIMEOUT_MS,
3679
- SURVEY_ALIGNMENT_STYLE_ID,
3680
- renderPopup
3681
- };
3682
- //# sourceMappingURL=renderPopup-BKZPAZZG.mjs.map