@bigbinary/neeto-form-frontend 3.3.2 → 3.4.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 (62) hide show
  1. package/app/javascript/src/translations/en.json +3 -3
  2. package/dist/BuildForm.js +2358 -0
  3. package/dist/BuildForm.js.map +1 -0
  4. package/dist/ExternalForm.js +657 -0
  5. package/dist/ExternalForm.js.map +1 -0
  6. package/dist/NeetoFormProvider.js +11 -0
  7. package/dist/NeetoFormProvider.js.map +1 -0
  8. package/dist/Submission.js +2700 -0
  9. package/dist/Submission.js.map +1 -0
  10. package/dist/UrlBuilder.js +297 -0
  11. package/dist/UrlBuilder.js.map +1 -0
  12. package/dist/buildForm-4a5a5251.js +35 -0
  13. package/dist/buildForm-4a5a5251.js.map +1 -0
  14. package/dist/buildForm-77b32f08.js +42 -0
  15. package/dist/buildForm-77b32f08.js.map +1 -0
  16. package/dist/cjs/BuildForm.js +2416 -0
  17. package/dist/cjs/BuildForm.js.map +1 -0
  18. package/dist/cjs/ExternalForm.js +697 -0
  19. package/dist/cjs/ExternalForm.js.map +1 -0
  20. package/dist/cjs/NeetoFormProvider.js +13 -0
  21. package/dist/cjs/NeetoFormProvider.js.map +1 -0
  22. package/dist/cjs/Submission.js +2711 -0
  23. package/dist/cjs/Submission.js.map +1 -0
  24. package/dist/cjs/UrlBuilder.js +308 -0
  25. package/dist/cjs/UrlBuilder.js.map +1 -0
  26. package/dist/cjs/hooks.js +34 -0
  27. package/dist/cjs/hooks.js.map +1 -0
  28. package/dist/cjs/index.js +115 -0
  29. package/dist/cjs/index.js.map +1 -0
  30. package/dist/constants-9310a7c2.js +342 -0
  31. package/dist/constants-9310a7c2.js.map +1 -0
  32. package/dist/constants-f0f38e6f.js +378 -0
  33. package/dist/constants-f0f38e6f.js.map +1 -0
  34. package/dist/hooks.js +20 -0
  35. package/dist/hooks.js.map +1 -0
  36. package/dist/index-2664c3e7.js +39 -0
  37. package/dist/index-2664c3e7.js.map +1 -0
  38. package/dist/index-b6bb805c.js +46 -0
  39. package/dist/index-b6bb805c.js.map +1 -0
  40. package/dist/index.js +94 -9325
  41. package/dist/index.js.map +1 -1
  42. package/dist/main.css +12 -1
  43. package/dist/main.css.map +1 -1
  44. package/dist/no-questions-832318c3.js +487 -0
  45. package/dist/no-questions-832318c3.js.map +1 -0
  46. package/dist/no-questions-995fd77e.js +538 -0
  47. package/dist/no-questions-995fd77e.js.map +1 -0
  48. package/dist/useFormApi-ca36173e.js +492 -0
  49. package/dist/useFormApi-ca36173e.js.map +1 -0
  50. package/dist/useFormApi-d733cb8d.js +467 -0
  51. package/dist/useFormApi-d733cb8d.js.map +1 -0
  52. package/dist/useFormSubmission-866195bb.js +24 -0
  53. package/dist/useFormSubmission-866195bb.js.map +1 -0
  54. package/dist/useFormSubmission-f8866b84.js +22 -0
  55. package/dist/useFormSubmission-f8866b84.js.map +1 -0
  56. package/dist/utils-7000103c.js +2157 -0
  57. package/dist/utils-7000103c.js.map +1 -0
  58. package/dist/utils-a487b8ff.js +2221 -0
  59. package/dist/utils-a487b8ff.js.map +1 -0
  60. package/package.json +19 -7
  61. package/dist/index.cjs.js +0 -9424
  62. package/dist/index.cjs.js.map +0 -1
@@ -0,0 +1,2157 @@
1
+ import * as React from 'react';
2
+ import { useEffect, useState, useImperativeHandle, useRef, useCallback, createElement, memo, Fragment } from 'react';
3
+ import { useFormikContext, useField, Field, FastField } from 'formik';
4
+ import { isPresent, isNotPresent, isNotEmpty, findBy, findById, getRandomInt, randomPick, noop, hyphenate, slugify, notEqualsDeep } from '@bigbinary/neeto-cist';
5
+ import { i as isFunction, b as isEmptyValues, f as fieldWithFallback } from './index-2664c3e7.js';
6
+ import dayjs from 'dayjs';
7
+ import { parsePhoneNumber } from 'libphonenumber-js';
8
+ import { pipe, toLower, reject, prop, map, includes, isNil, clamp, identity, pluck, values, assoc, isEmpty, isNotNil, equals, pick } from 'ramda';
9
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
10
+ import EditorContent from '@bigbinary/neeto-editor/EditorContent';
11
+ import { C as CAPTCHA_TYPES, p as generateArray } from './no-questions-832318c3.js';
12
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
13
+ import Button from '@bigbinary/neetoui/Button';
14
+ import NeetoUIMultiEmailInput from '@bigbinary/neetoui/MultiEmailInput';
15
+ import { useTranslation, Trans } from 'react-i18next';
16
+ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
17
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
18
+ import _regeneratorRuntime from '@babel/runtime/regenerator';
19
+ import { isEditorEmpty } from '@bigbinary/neeto-editor/utils';
20
+ import { validation, PhoneNumberInput } from '@bigbinary/neeto-molecules/PhoneNumber';
21
+ import * as yup from 'yup';
22
+ import i18next from 'i18next';
23
+ import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
24
+ import { Q as QUESTION_KIND, E as ERROR_CODES, e as EMAIL_REGEX, R as RATING_VALUES, S as SCHEMA_LESS_QUESTION_KINDS, f as RATING_OPTIONS, I as ICONS_MAP } from './constants-9310a7c2.js';
25
+ import classnames from 'classnames';
26
+ import path from 'path';
27
+ import { useUpdateEffect, withT, useDebounce } from '@bigbinary/neeto-commons-frontend/react-utils';
28
+ import { withEventTargetValue } from '@bigbinary/neeto-commons-frontend/utils';
29
+ import Refresh from '@bigbinary/neeto-icons/Refresh';
30
+ import Input from '@bigbinary/neetoui/Input';
31
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
32
+ import { globalProps } from '@bigbinary/neeto-commons-frontend/initializers';
33
+ import ReCAPTCHA from 'react-google-recaptcha';
34
+ import Checkbox from '@bigbinary/neetoui/Checkbox';
35
+ import localeData from 'dayjs/plugin/localeData';
36
+ import utc from 'dayjs/plugin/utc';
37
+ import weekday from 'dayjs/plugin/weekday';
38
+ import weekOfYear from 'dayjs/plugin/weekOfYear';
39
+ import DatePicker from '@bigbinary/neetoui/DatePicker';
40
+ import Label from '@bigbinary/neetoui/Label';
41
+ import Typography from '@bigbinary/neetoui/Typography';
42
+ import { DirectUpload } from '@rails/activestorage';
43
+ import { useDropzone } from 'react-dropzone';
44
+ import { D as DIRECT_UPLOAD_URL } from './useFormApi-d733cb8d.js';
45
+ import FileGeneric from '@bigbinary/neeto-icons/FileGeneric';
46
+ import Check from '@bigbinary/neeto-icons/Check';
47
+ import Close from '@bigbinary/neeto-icons/Close';
48
+ import { motion } from 'framer-motion';
49
+ import Select from '@bigbinary/neetoui/Select';
50
+ import Radio from '@bigbinary/neetoui/Radio';
51
+ import NeetoEditor from '@bigbinary/neeto-editor/Editor';
52
+ import Textarea from '@bigbinary/neetoui/Textarea';
53
+
54
+ var clientI18nInstance = i18next.cloneInstance();
55
+
56
+ var clearLocalStorageValues = function clearLocalStorageValues(key) {
57
+ try {
58
+ localStorage.removeItem(key);
59
+ } catch (error) {
60
+ // eslint-disable-next-line no-console
61
+ console.error(error);
62
+ }
63
+ };
64
+ var setWithExpiry = function setWithExpiry(key, value) {
65
+ var expireInDays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
66
+ var expiryDate = dayjs().add(expireInDays, "day").toDate();
67
+ var item = {
68
+ value: value,
69
+ localStorageExpiry: expiryDate.getTime()
70
+ };
71
+ try {
72
+ localStorage.setItem(key, JSON.stringify(item));
73
+ } catch (error) {
74
+ // eslint-disable-next-line no-console
75
+ console.error(error);
76
+ }
77
+ };
78
+ var getWithExpiry = function getWithExpiry(key) {
79
+ try {
80
+ var itemStr = localStorage.getItem(key);
81
+ if (!itemStr) {
82
+ return null;
83
+ }
84
+ var item = JSON.parse(itemStr);
85
+ var now = new Date();
86
+ if (now.getTime() > item.localStorageExpiry) {
87
+ localStorage.removeItem(key);
88
+ return null;
89
+ }
90
+ return item.value;
91
+ } catch (error) {
92
+ // eslint-disable-next-line no-console
93
+ console.error(error);
94
+ return null;
95
+ }
96
+ };
97
+
98
+ var FormikWrap = function FormikWrap(_ref) {
99
+ var onError = _ref.onError,
100
+ children = _ref.children,
101
+ formId = _ref.formId,
102
+ preserveValues = _ref.preserveValues,
103
+ onValuesChange = _ref.onValuesChange,
104
+ dataUpdateCount = _ref.dataUpdateCount;
105
+ var _useFormikContext = useFormikContext(),
106
+ errors = _useFormikContext.errors,
107
+ touched = _useFormikContext.touched,
108
+ isValid = _useFormikContext.isValid,
109
+ isSubmitting = _useFormikContext.isSubmitting,
110
+ values = _useFormikContext.values,
111
+ validateForm = _useFormikContext.validateForm;
112
+ var revalidate = function revalidate() {
113
+ return isPresent(errors) && validateForm();
114
+ };
115
+ useEffect(function () {
116
+ revalidate();
117
+ }, [clientI18nInstance.language, dataUpdateCount]);
118
+ var syncValuesWithLocalStorage = function syncValuesWithLocalStorage() {
119
+ return preserveValues && !isEmptyValues(values) && setWithExpiry("".concat(formId, "/values"), values);
120
+ };
121
+ useEffect(function () {
122
+ syncValuesWithLocalStorage();
123
+ onValuesChange && onValuesChange(values);
124
+ }, [values, formId, preserveValues]);
125
+ useEffect(function () {
126
+ if (isSubmitting || isValid) return;
127
+
128
+ // include only touched fields
129
+ var touchedErrors = Object.keys(errors).filter(function (key) {
130
+ return touched[key];
131
+ }).reduce(function (obj, key) {
132
+ obj[key] = errors[key];
133
+ return obj;
134
+ }, {});
135
+ if (isFunction(onError)) onError(touchedErrors);
136
+ }, [isValid, isSubmitting]);
137
+ return children;
138
+ };
139
+
140
+ var t$2 = clientI18nInstance.t;
141
+ var getInvalidFieldError = function getInvalidFieldError(label) {
142
+ return t$2("neetoForm.error.invalidField", {
143
+ label: label
144
+ });
145
+ };
146
+ var getRequiredFieldError = function getRequiredFieldError(label) {
147
+ return t$2("neetoForm.error.requiredField", {
148
+ label: label
149
+ });
150
+ };
151
+ var getSelectMinError = function getSelectMinError(min) {
152
+ var entity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : t$2("neetoForm.common.option");
153
+ return t$2("neetoForm.error.selectMin", {
154
+ min: min,
155
+ entity: entity
156
+ });
157
+ };
158
+ var getInvalidTypeError = function getInvalidTypeError(label, type) {
159
+ return t$2("neetoForm.error.invalidType", {
160
+ label: label,
161
+ type: type
162
+ });
163
+ };
164
+
165
+ var _excluded$4 = ["kind", "customValidator"];
166
+ var _fieldKindValidatorMa;
167
+ function ownKeys$g(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
168
+ function _objectSpread$g(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$g(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$g(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
169
+ var t$1 = clientI18nInstance.t;
170
+ yup.addMethod(yup.array, "unique", function () {
171
+ var field, message;
172
+ if (arguments.length > 1) {
173
+ field = arguments[0];
174
+ message = arguments[1];
175
+ } else {
176
+ message = arguments[0];
177
+ }
178
+ var getValue = function getValue(item) {
179
+ return field ? item[field] : item;
180
+ };
181
+ var valueInLowerCase = pipe(getValue, toLower);
182
+ return this.test("unique", message, function () {
183
+ var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
184
+ // ignore destroyed items in the array
185
+ var validItems = reject(prop("_destroy"), array);
186
+ var uniqueItems = new Set(map(valueInLowerCase, validItems));
187
+
188
+ // all items are unique
189
+ if (validItems.length === uniqueItems.size) return true;
190
+ return this.createError({
191
+ path: this.path,
192
+ message: message
193
+ });
194
+ });
195
+ });
196
+ var isValidDate = function isValidDate(date) {
197
+ return date && dayjs(date).isValid();
198
+ };
199
+ var extractEmailDomain = function extractEmailDomain(email) {
200
+ return email === null || email === void 0 ? void 0 : email.split("@")[1];
201
+ };
202
+ var isEmailFromRestrictedDomain = function isEmailFromRestrictedDomain(email, restrictedDomains) {
203
+ var domain = extractEmailDomain(email);
204
+ return includes(domain, restrictedDomains);
205
+ };
206
+ var validateTextField = function validateTextField(_ref) {
207
+ var kind = _ref.kind,
208
+ label = _ref.label,
209
+ isRequired = _ref.isRequired;
210
+ var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
211
+ if (kind === QUESTION_KIND.PHONE.value) {
212
+ schema = validation(getInvalidFieldError(t$1("neetoForm.common.phoneNumberValidation")));
213
+ }
214
+ if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
215
+ return schema.trim();
216
+ };
217
+ var validateEmailField = function validateEmailField(_ref2) {
218
+ var label = _ref2.label,
219
+ isRequired = _ref2.isRequired,
220
+ restrictedDomains = _ref2.restrictedDomains;
221
+ var schema = yup.string().typeError(getInvalidTypeError(label, "string")).email(getInvalidFieldError("Email")).test("verify domain", function (_ref3) {
222
+ var value = _ref3.value;
223
+ return t$1("neetoForm.error.emailFromRestrictedDomain", {
224
+ domain: extractEmailDomain(value)
225
+ });
226
+ }, function (value) {
227
+ return isNotPresent(value) || !isEmailFromRestrictedDomain(value, restrictedDomains);
228
+ });
229
+ if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
230
+ return schema.trim();
231
+ };
232
+ var validateNameField = function validateNameField(_ref4) {
233
+ var label = _ref4.label,
234
+ isRequired = _ref4.isRequired;
235
+ var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
236
+ if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
237
+ return schema.trim();
238
+ };
239
+ var validateSingleChoiceField = function validateSingleChoiceField(_ref5) {
240
+ var label = _ref5.label,
241
+ isRequired = _ref5.isRequired;
242
+ var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
243
+ if (isRequired) schema = schema.required(getSelectMinError("an"));
244
+ return schema.trim();
245
+ };
246
+ var validateMultiChoiceField = function validateMultiChoiceField(_ref6) {
247
+ var isRequired = _ref6.isRequired;
248
+ var schema = yup.array().of(yup["boolean"]());
249
+ if (isRequired) schema = schema.compact().min(1, getSelectMinError("an"));
250
+ return schema;
251
+ };
252
+ var validateRatingField = function validateRatingField(_ref7) {
253
+ var label = _ref7.label,
254
+ isRequired = _ref7.isRequired;
255
+ var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
256
+ if (isRequired) schema = schema.required(getSelectMinError("an"));
257
+ return schema.trim();
258
+ };
259
+ var validateStarRatingField = function validateStarRatingField(_ref8) {
260
+ var label = _ref8.label,
261
+ isRequired = _ref8.isRequired;
262
+ var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
263
+ if (isRequired) {
264
+ schema = schema.required(getSelectMinError("a", t$1("neetoForm.common.rating")));
265
+ }
266
+ return schema.trim();
267
+ };
268
+ var validateTermsField = function validateTermsField(_ref9) {
269
+ var _ref9$isRequired = _ref9.isRequired,
270
+ isRequired = _ref9$isRequired === void 0 ? true : _ref9$isRequired;
271
+ return isRequired ? yup["boolean"]().oneOf([true], t$1("neetoForm.common.mustAcceptTermsAndConditions")) : yup["boolean"]().notRequired();
272
+ };
273
+ var validateConditionField = function validateConditionField(_ref10) {
274
+ var _ref10$isRequired = _ref10.isRequired,
275
+ isRequired = _ref10$isRequired === void 0 ? true : _ref10$isRequired;
276
+ return isRequired ? yup["boolean"]().oneOf([true], t$1("neetoForm.common.mustAcceptCondition")) : yup["boolean"]().notRequired();
277
+ };
278
+ var validateDateField = function validateDateField(_ref11) {
279
+ var label = _ref11.label,
280
+ isRequired = _ref11.isRequired;
281
+ var schema = yup.string().test("is valid date", getInvalidTypeError(label, "date"), function (value) {
282
+ return isNotPresent(value) || isValidDate(value);
283
+ });
284
+ if (isRequired) {
285
+ schema = schema.required(getRequiredFieldError(label));
286
+ }
287
+ return schema;
288
+ };
289
+ var validateMultiEmailField = function validateMultiEmailField(_ref12) {
290
+ var isRequired = _ref12.isRequired;
291
+ var schema = yup.array().of(yup.object().shape({
292
+ value: yup.string().email(getInvalidFieldError("Email")).trim()
293
+ })).nullable();
294
+ if (isRequired) {
295
+ schema = schema.compact().min(1, getSelectMinError("an", t$1("neetoForm.common.email")));
296
+ }
297
+ return schema;
298
+ };
299
+ var editorHasValue = function editorHasValue(content) {
300
+ return !isEditorEmpty(content);
301
+ };
302
+ var validateRichTextField = function validateRichTextField(_ref13) {
303
+ var isRequired = _ref13.isRequired;
304
+ var schema = yup.string();
305
+ if (isRequired) {
306
+ schema = schema.test("required", getRequiredFieldError("content"), editorHasValue);
307
+ }
308
+ return schema.trim();
309
+ };
310
+ var validateFileUploadField = function validateFileUploadField(_ref14) {
311
+ var isRequired = _ref14.isRequired,
312
+ multipleFilesAllowed = _ref14.multipleFilesAllowed;
313
+ var files_schema = yup.array();
314
+ if (isRequired) {
315
+ files_schema = files_schema.of(yup.object().shape({
316
+ name: yup.string(),
317
+ signedId: yup.string().required(t$1("neetoForm.fileUpload.validations.waitForUpload")),
318
+ url: yup.string().required(t$1("neetoForm.fileUpload.validations.waitForUpload"))
319
+ })).unique("name", t$1("neetoForm.fileUpload.validations.removeDuplicates")).min(1, multipleFilesAllowed ? t$1("neetoForm.fileUpload.validations.atLeastOneFileRequired") : t$1("neetoForm.fileUpload.validations.fileIsRequired"));
320
+ }
321
+ return yup.object().shape({
322
+ files: files_schema
323
+ });
324
+ };
325
+ var validateCaptchaField = function validateCaptchaField(_ref15) {
326
+ var variant = _ref15.variant;
327
+ return variant === CAPTCHA_TYPES.MATH_CAPTCHA ? yup.mixed().test("verification failed", t$1("neetoForm.error.captchaVerificationFailed"), function (value) {
328
+ return isNotPresent(value) || value;
329
+ }).transform(function (value) {
330
+ return value === "" ? null : value;
331
+ }).required(t$1("neetoForm.error.incompleteCaptcha")) : yup.string().trim().required(t$1("neetoForm.error.incompleteCaptcha"));
332
+ };
333
+ var fieldKindValidatorMap = (_fieldKindValidatorMa = {}, _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.EMAIL.value, validateEmailField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.NAME.value, validateNameField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.PHONE.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.TEXT.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.QUESTION.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.TEXTAREA.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.DECIMAL.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.INTEGER.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.DROPDOWN.value, validateSingleChoiceField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.RADIO.value, validateSingleChoiceField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.CHECKBOX.value, validateMultiChoiceField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.RATING.value, validateRatingField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.TERMS.value, validateTermsField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.DATE.value, validateDateField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.STAR_RATING.value, validateStarRatingField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.ADDITIONAL_GUESTS.value, validateMultiEmailField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.RICH_TEXT.value, validateRichTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.CONDITION.value, validateConditionField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.FILE_UPLOAD.value, validateFileUploadField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.CAPTCHA.value, validateCaptchaField), _fieldKindValidatorMa);
334
+ var validateFieldValue = function validateFieldValue(_ref16) {
335
+ var kind = _ref16.kind,
336
+ customValidator = _ref16.customValidator,
337
+ otherProps = _objectWithoutProperties(_ref16, _excluded$4);
338
+ return function (value) {
339
+ if (!(kind in fieldKindValidatorMap)) return;
340
+ var validator = fieldKindValidatorMap[kind];
341
+ var schema = customValidator || validator(_objectSpread$g({
342
+ kind: kind
343
+ }, otherProps));
344
+
345
+ // eslint-disable-next-line consistent-return, no-async-promise-executor
346
+ return new Promise( /*#__PURE__*/function () {
347
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve) {
348
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
349
+ while (1) switch (_context.prev = _context.next) {
350
+ case 0:
351
+ _context.prev = 0;
352
+ _context.next = 3;
353
+ return schema.validate(value);
354
+ case 3:
355
+ resolve(undefined);
356
+ _context.next = 9;
357
+ break;
358
+ case 6:
359
+ _context.prev = 6;
360
+ _context.t0 = _context["catch"](0);
361
+ resolve(_context.t0.message);
362
+ case 9:
363
+ case "end":
364
+ return _context.stop();
365
+ }
366
+ }, _callee, null, [[0, 6]]);
367
+ }));
368
+ return function (_x) {
369
+ return _ref17.apply(this, arguments);
370
+ };
371
+ }());
372
+ };
373
+ };
374
+
375
+ var MultipleEmailInput = function MultipleEmailInput(_ref) {
376
+ var _jsx2;
377
+ var question = _ref.question,
378
+ customValidator = _ref.customValidator;
379
+ var name = question.id,
380
+ kind = question.kind,
381
+ isRequired = question.isRequired,
382
+ nodeId = question.nodeId;
383
+ var label = fieldWithFallback(question, "label");
384
+ var _useTranslation = useTranslation(),
385
+ t = _useTranslation.t;
386
+ var _useField = useField({
387
+ name: name || nodeId,
388
+ validate: validateFieldValue({
389
+ kind: kind,
390
+ label: label,
391
+ isRequired: isRequired,
392
+ customValidator: customValidator
393
+ })
394
+ }),
395
+ _useField2 = _slicedToArray(_useField, 3),
396
+ field = _useField2[0],
397
+ meta = _useField2[1],
398
+ _useField2$ = _useField2[2],
399
+ setValue = _useField2$.setValue,
400
+ setTouched = _useField2$.setTouched;
401
+ var _useState = useState(isPresent(field.value)),
402
+ _useState2 = _slicedToArray(_useState, 2),
403
+ isInputVisible = _useState2[0],
404
+ setIsInputVisible = _useState2[1];
405
+ return /*#__PURE__*/jsx("div", {
406
+ className: "neeto-form-engine-input__wrapper",
407
+ children: /*#__PURE__*/jsx("div", {
408
+ className: "neeto-ui-w-full",
409
+ children: isInputVisible ? /*#__PURE__*/jsx(NeetoUIMultiEmailInput, {
410
+ isRequired: isRequired,
411
+ label: label,
412
+ error: meta.touched ? meta.error : "",
413
+ helpText: t("neetoForm.common.addGuestsHelper"),
414
+ name: field.name,
415
+ placeholder: fieldWithFallback(question, "placeholder"),
416
+ value: field.value,
417
+ onBlur: function onBlur() {
418
+ return setTouched(true);
419
+ },
420
+ onChange: setValue
421
+ }) : /*#__PURE__*/jsx(Button, (_jsx2 = {
422
+ label: label
423
+ }, _defineProperty(_jsx2, "label", t("neetoForm.common.addGuests")), _defineProperty(_jsx2, "style", "secondary"), _defineProperty(_jsx2, "onClick", function onClick() {
424
+ return setIsInputVisible(true);
425
+ }), _jsx2))
426
+ })
427
+ });
428
+ };
429
+
430
+ function ownKeys$f(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
431
+ function _objectSpread$f(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$f(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$f(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
432
+ var t = clientI18nInstance.t;
433
+ var toEmailValues = function toEmailValues() {
434
+ var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
435
+ return values.map(function (value) {
436
+ return {
437
+ label: value,
438
+ value: value,
439
+ valid: true
440
+ };
441
+ });
442
+ };
443
+ var getPhoneNumberFromUrl = function getPhoneNumberFromUrl(fieldCodes, fieldCode) {
444
+ var countryCode = fieldCodes["".concat(fieldCode, ".country")];
445
+ var phoneNumber = fieldCodes["".concat(fieldCode, ".number")];
446
+ if (!countryCode || !phoneNumber) return undefined;
447
+ var formattedValue = getPhoneData(phoneNumber, countryCode);
448
+ if (!formattedValue) return undefined;
449
+ return formattedValue.formatInternational();
450
+ };
451
+ var getOptionFromURL = function getOptionFromURL(_ref) {
452
+ var _findBy;
453
+ var optionsAttributes = _ref.optionsAttributes,
454
+ fieldCodes = _ref.fieldCodes,
455
+ fieldCode = _ref.fieldCode;
456
+ var preFillOption = fieldCodes[fieldCode];
457
+ return (_findBy = findBy({
458
+ label: preFillOption
459
+ }, optionsAttributes)) === null || _findBy === void 0 ? void 0 : _findBy.id;
460
+ };
461
+ var getMultipleOptionsFromURL = function getMultipleOptionsFromURL(_ref2) {
462
+ var optionsAttributes = _ref2.optionsAttributes,
463
+ fieldCodes = _ref2.fieldCodes,
464
+ fieldCode = _ref2.fieldCode;
465
+ var fieldCodeValue = fieldCodes[fieldCode];
466
+ if (!fieldCodeValue) return new Array(optionsAttributes.length).fill(false);
467
+ var allOptions = fieldCodeValue.split(",");
468
+ return optionsAttributes.map(function (option) {
469
+ return allOptions.includes(option.label);
470
+ });
471
+ };
472
+ var getStarRatingFromUrl = function getStarRatingFromUrl(_ref3) {
473
+ var minValue = _ref3.minValue,
474
+ maxValue = _ref3.maxValue,
475
+ fieldCodes = _ref3.fieldCodes,
476
+ fieldCode = _ref3.fieldCode;
477
+ var fieldCodeValue = fieldCodes[fieldCode];
478
+ var rating = parseInt(fieldCodeValue);
479
+ return isNil(rating) || isNaN(rating) ? "" : clamp(minValue, maxValue, rating);
480
+ };
481
+ var getAdditionalGuestsFromUrl = function getAdditionalGuestsFromUrl(_ref4) {
482
+ var fieldCodes = _ref4.fieldCodes,
483
+ fieldCode = _ref4.fieldCode;
484
+ var fieldCodeValue = fieldCodes[fieldCode];
485
+ var allEmails = fieldCodeValue === null || fieldCodeValue === void 0 ? void 0 : fieldCodeValue.split(",");
486
+ if (!allEmails) return [];
487
+ return allEmails.map(function (email) {
488
+ return {
489
+ label: email,
490
+ value: email,
491
+ valid: EMAIL_REGEX.test(email)
492
+ };
493
+ });
494
+ };
495
+ var getRatingFromUrl = function getRatingFromUrl(_ref5) {
496
+ var fieldCodes = _ref5.fieldCodes,
497
+ fieldCode = _ref5.fieldCode;
498
+ var fieldCodeValue = fieldCodes[fieldCode];
499
+ var allowedValues = Object.values(RATING_VALUES).map(prop("value"));
500
+ return allowedValues.includes(fieldCodeValue) ? fieldCodeValue : "";
501
+ };
502
+ var getNumberFromUrl = function getNumberFromUrl(_ref6) {
503
+ var fieldCodes = _ref6.fieldCodes,
504
+ fieldCode = _ref6.fieldCode,
505
+ kind = _ref6.kind;
506
+ var fieldCodeValue = fieldCodes[fieldCode];
507
+ var parsedValue = kind === QUESTION_KIND.INTEGER.value ? parseInt(fieldCodeValue) : parseFloat(fieldCodeValue);
508
+ return parsedValue || "";
509
+ };
510
+ var getLabel = function getLabel(label, isRequired) {
511
+ return isRequired ? "".concat(label, "*") : label;
512
+ };
513
+ var generateInitValues = function generateInitValues(_ref7) {
514
+ var questions = _ref7.questions,
515
+ _ref7$initialValues = _ref7.initialValues,
516
+ initialValues = _ref7$initialValues === void 0 ? [] : _ref7$initialValues,
517
+ _ref7$localValues = _ref7.localValues,
518
+ localValues = _ref7$localValues === void 0 ? {} : _ref7$localValues,
519
+ _ref7$fieldCodes = _ref7.fieldCodes,
520
+ fieldCodes = _ref7$fieldCodes === void 0 ? {} : _ref7$fieldCodes;
521
+ var initValues = {};
522
+ var valuesMap = {};
523
+ if (initialValues) {
524
+ valuesMap = initialValues.reduce(function (acc, answer) {
525
+ return _objectSpread$f(_objectSpread$f({}, acc), {}, _defineProperty({}, answer.questionId, {
526
+ value: answer.value,
527
+ optionIds: answer.optionIds
528
+ }));
529
+ }, {});
530
+ }
531
+ questions.forEach(function (question) {
532
+ var id = question.id,
533
+ kind = question.kind,
534
+ optionsAttributes = question.optionsAttributes,
535
+ fieldCode = question.fieldCode,
536
+ minValue = question.minValue,
537
+ maxValue = question.maxValue;
538
+ switch (kind) {
539
+ case QUESTION_KIND.CONDITION.value:
540
+ {
541
+ var _valuesMap$id$value, _valuesMap;
542
+ initValues[id] = (_valuesMap$id$value = (_valuesMap = valuesMap) === null || _valuesMap === void 0 || (_valuesMap = _valuesMap[id]) === null || _valuesMap === void 0 ? void 0 : _valuesMap.value) !== null && _valuesMap$id$value !== void 0 ? _valuesMap$id$value : false;
543
+ return;
544
+ }
545
+ case QUESTION_KIND.ADDITIONAL_GUESTS.value:
546
+ {
547
+ var _valuesMap2;
548
+ var emailsFromSubmission = toEmailValues((_valuesMap2 = valuesMap) === null || _valuesMap2 === void 0 || (_valuesMap2 = _valuesMap2[id]) === null || _valuesMap2 === void 0 ? void 0 : _valuesMap2.value);
549
+ initValues[id] = isNotEmpty(emailsFromSubmission) ? emailsFromSubmission : getAdditionalGuestsFromUrl({
550
+ fieldCodes: fieldCodes,
551
+ fieldCode: fieldCode
552
+ });
553
+ return;
554
+ }
555
+ case QUESTION_KIND.CHECKBOX.value:
556
+ {
557
+ var _valuesMap$id;
558
+ initValues[id] = (_valuesMap$id = valuesMap[id]) !== null && _valuesMap$id !== void 0 && (_valuesMap$id = _valuesMap$id.optionIds) !== null && _valuesMap$id !== void 0 && _valuesMap$id.length ? optionsAttributes.map(function (option) {
559
+ var _valuesMap$id2;
560
+ return (_valuesMap$id2 = valuesMap[id]) === null || _valuesMap$id2 === void 0 || (_valuesMap$id2 = _valuesMap$id2.optionIds) === null || _valuesMap$id2 === void 0 ? void 0 : _valuesMap$id2.includes(option.id);
561
+ }) : getMultipleOptionsFromURL({
562
+ optionsAttributes: optionsAttributes,
563
+ fieldCodes: fieldCodes,
564
+ fieldCode: fieldCode
565
+ });
566
+ return;
567
+ }
568
+ case QUESTION_KIND.RADIO.value:
569
+ case QUESTION_KIND.DROPDOWN.value:
570
+ {
571
+ var _optionsAttributes$fi;
572
+ initValues[id] = ((_optionsAttributes$fi = optionsAttributes.find(function (option) {
573
+ var _valuesMap$id3;
574
+ return (_valuesMap$id3 = valuesMap[id]) === null || _valuesMap$id3 === void 0 || (_valuesMap$id3 = _valuesMap$id3.optionIds) === null || _valuesMap$id3 === void 0 ? void 0 : _valuesMap$id3.includes(option.id);
575
+ })) === null || _optionsAttributes$fi === void 0 ? void 0 : _optionsAttributes$fi.id) || getOptionFromURL({
576
+ optionsAttributes: optionsAttributes,
577
+ fieldCodes: fieldCodes,
578
+ fieldCode: fieldCode
579
+ });
580
+ return;
581
+ }
582
+ case QUESTION_KIND.INTEGER.value:
583
+ case QUESTION_KIND.DECIMAL.value:
584
+ {
585
+ var _valuesMap3;
586
+ initValues[id] = ((_valuesMap3 = valuesMap) === null || _valuesMap3 === void 0 || (_valuesMap3 = _valuesMap3[id]) === null || _valuesMap3 === void 0 ? void 0 : _valuesMap3.value) || getNumberFromUrl({
587
+ fieldCodes: fieldCodes,
588
+ fieldCode: fieldCode,
589
+ kind: kind
590
+ });
591
+ return;
592
+ }
593
+ case QUESTION_KIND.RATING.value:
594
+ {
595
+ var _valuesMap4;
596
+ initValues[id] = ((_valuesMap4 = valuesMap) === null || _valuesMap4 === void 0 || (_valuesMap4 = _valuesMap4[id]) === null || _valuesMap4 === void 0 ? void 0 : _valuesMap4.value) || getRatingFromUrl({
597
+ fieldCodes: fieldCodes,
598
+ fieldCode: fieldCode
599
+ });
600
+ return;
601
+ }
602
+ case QUESTION_KIND.TERMS.value:
603
+ {
604
+ initValues[id] = false;
605
+ return;
606
+ }
607
+ case QUESTION_KIND.FILE_UPLOAD.value:
608
+ {
609
+ var _valuesMap$id$value2, _valuesMap5;
610
+ initValues[id] = {
611
+ files: (_valuesMap$id$value2 = (_valuesMap5 = valuesMap) === null || _valuesMap5 === void 0 || (_valuesMap5 = _valuesMap5[id]) === null || _valuesMap5 === void 0 ? void 0 : _valuesMap5.value) !== null && _valuesMap$id$value2 !== void 0 ? _valuesMap$id$value2 : []
612
+ };
613
+ return;
614
+ }
615
+ case QUESTION_KIND.PHONE.value:
616
+ {
617
+ var _valuesMap$id$value3, _valuesMap6;
618
+ initValues[id] = (_valuesMap$id$value3 = (_valuesMap6 = valuesMap) === null || _valuesMap6 === void 0 || (_valuesMap6 = _valuesMap6[id]) === null || _valuesMap6 === void 0 ? void 0 : _valuesMap6.value) !== null && _valuesMap$id$value3 !== void 0 ? _valuesMap$id$value3 : getPhoneNumberFromUrl(fieldCodes, fieldCode);
619
+ return;
620
+ }
621
+ case QUESTION_KIND.STAR_RATING.value:
622
+ {
623
+ var _valuesMap$id$value4, _valuesMap7;
624
+ initValues[id] = (_valuesMap$id$value4 = (_valuesMap7 = valuesMap) === null || _valuesMap7 === void 0 || (_valuesMap7 = _valuesMap7[id]) === null || _valuesMap7 === void 0 ? void 0 : _valuesMap7.value) !== null && _valuesMap$id$value4 !== void 0 ? _valuesMap$id$value4 : getStarRatingFromUrl({
625
+ minValue: minValue,
626
+ maxValue: maxValue,
627
+ fieldCodes: fieldCodes,
628
+ fieldCode: fieldCode
629
+ });
630
+ return;
631
+ }
632
+ default:
633
+ {
634
+ var _valuesMap$id$value5, _valuesMap8;
635
+ initValues[id] = (_valuesMap$id$value5 = (_valuesMap8 = valuesMap) === null || _valuesMap8 === void 0 || (_valuesMap8 = _valuesMap8[id]) === null || _valuesMap8 === void 0 ? void 0 : _valuesMap8.value) !== null && _valuesMap$id$value5 !== void 0 ? _valuesMap$id$value5 : fieldCodes[fieldCode] || "";
636
+ return;
637
+ }
638
+ }
639
+ });
640
+ return !isEmptyValues(localValues) ? localValues : initValues;
641
+ };
642
+ var generateFormResponse = function generateFormResponse(response, questions) {
643
+ var formResponse = [];
644
+ questions.forEach(function (question) {
645
+ var id = question.id,
646
+ kind = question.kind,
647
+ optionsAttributes = question.optionsAttributes;
648
+ if (!SCHEMA_LESS_QUESTION_KINDS.includes(kind)) {
649
+ var responseValue = response[id];
650
+ if (kind === QUESTION_KIND.RADIO.value || kind === QUESTION_KIND.DROPDOWN.value) {
651
+ var option = findById(responseValue, optionsAttributes);
652
+ if (option) {
653
+ formResponse.push({
654
+ questionId: id,
655
+ questionOptionId: option.id,
656
+ value: option.label,
657
+ kind: kind
658
+ });
659
+ }
660
+ } else if (kind === QUESTION_KIND.CHECKBOX.value) {
661
+ responseValue.forEach(function (isChecked, index) {
662
+ if (!isChecked) return;
663
+ var option = optionsAttributes[index];
664
+ formResponse.push({
665
+ questionId: id,
666
+ questionOptionId: option.id,
667
+ value: option.label,
668
+ kind: kind
669
+ });
670
+ });
671
+ } else if (kind === QUESTION_KIND.PHONE.value) {
672
+ formResponse.push({
673
+ questionId: id,
674
+ value: responseValue ? parsePhoneNumber(responseValue).formatInternational() : "",
675
+ kind: kind
676
+ });
677
+ } else if (kind === QUESTION_KIND.ADDITIONAL_GUESTS.value) {
678
+ formResponse.push({
679
+ questionId: id,
680
+ value: responseValue ? pluck("value", responseValue) : null,
681
+ kind: kind
682
+ });
683
+ } else if (kind === QUESTION_KIND.FILE_UPLOAD.value) {
684
+ formResponse.push({
685
+ questionId: id,
686
+ files: isPresent(responseValue) ? responseValue.files : null,
687
+ kind: kind
688
+ });
689
+ } else formResponse.push({
690
+ questionId: id,
691
+ value: responseValue,
692
+ kind: kind
693
+ });
694
+ }
695
+ });
696
+ return formResponse;
697
+ };
698
+ var mergeRefs = function mergeRefs() {
699
+ for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
700
+ refs[_key] = arguments[_key];
701
+ }
702
+ return function (node) {
703
+ return refs.forEach(function (ref) {
704
+ return typeof ref === "function" ? ref(node) : ref.current = node;
705
+ });
706
+ };
707
+ };
708
+ var getError = function getError(meta) {
709
+ if (meta.error && meta.touched) {
710
+ return typeof meta.error === "string" ? meta.error : "";
711
+ }
712
+ return "";
713
+ };
714
+ var buildAutoCompleteAttribute = function buildAutoCompleteAttribute(kind, autoCompleteKinds, formDomProps) {
715
+ return (formDomProps === null || formDomProps === void 0 ? void 0 : formDomProps.autoComplete) === "off" && includes(kind, autoCompleteKinds) ? "on" : undefined;
716
+ };
717
+ var convertMbToBytes = function convertMbToBytes(mb) {
718
+ return mb * 1024 * 1024;
719
+ };
720
+ var renderErrorMessage = function renderErrorMessage(errorObject, maxFileSize, isMultiple) {
721
+ var error = errorObject.errors[0];
722
+ var file = errorObject.file;
723
+ if (error) {
724
+ var code = error.code;
725
+ switch (code) {
726
+ case ERROR_CODES.FILE_TOO_LARGE:
727
+ return t("neetoForm.fileUpload.dropzone.errors.fileTooLarge", {
728
+ fileName: file.name,
729
+ maxSize: Math.round(maxFileSize / 1048576)
730
+ });
731
+ case ERROR_CODES.FILE_INVALID_TYPE:
732
+ return t("neetoForm.fileUpload.dropzone.errors.fileInvalidType", {
733
+ fileType: path.extname(file.name)
734
+ });
735
+ case ERROR_CODES.TOO_MANY_FILES:
736
+ if (!isMultiple) {
737
+ return t("neetoForm.fileUpload.dropzone.errors.tooManyFiles");
738
+ }
739
+ }
740
+ }
741
+ return t("neetoForm.fileUpload.dropzone.errors.defaultError", {
742
+ fileName: file.name
743
+ });
744
+ };
745
+ var renderButtonsInOrder = function renderButtonsInOrder(buttonsArray, shouldReverse) {
746
+ var orderedButtons = shouldReverse ? buttonsArray.reverse() : buttonsArray;
747
+ return map(identity, orderedButtons);
748
+ };
749
+ var getSelectedRating = function getSelectedRating(value) {
750
+ var parsedValue = parseInt(value);
751
+ return isNaN(parsedValue) ? -1 : parsedValue;
752
+ };
753
+
754
+ var CaptchaField = function CaptchaField(_ref) {
755
+ var question = _ref.question,
756
+ preview = _ref.preview,
757
+ customValidator = _ref.customValidator,
758
+ captchaRef = _ref.captchaRef;
759
+ var name = question.id,
760
+ kind = question.kind,
761
+ isRequired = question.isRequired,
762
+ variant = question.variant,
763
+ nodeId = question.nodeId;
764
+ var label = fieldWithFallback(question, "label");
765
+ var _useField = useField({
766
+ name: name || nodeId,
767
+ validate: validateFieldValue({
768
+ kind: kind,
769
+ label: label,
770
+ isRequired: isRequired,
771
+ customValidator: customValidator,
772
+ variant: variant
773
+ })
774
+ }),
775
+ _useField2 = _slicedToArray(_useField, 3);
776
+ _useField2[0];
777
+ var _useField2$ = _useField2[1],
778
+ touched = _useField2$.touched,
779
+ error = _useField2$.error,
780
+ _useField2$2 = _useField2[2],
781
+ setValue = _useField2$2.setValue,
782
+ setTouched = _useField2$2.setTouched;
783
+ var handleVerifyCaptcha = function handleVerifyCaptcha(response) {
784
+ setTouched(true);
785
+ setValue(response);
786
+ };
787
+ var Component = CAPTCHA_COMPONENT_MAP[variant];
788
+ return /*#__PURE__*/jsxs("div", {
789
+ className: "neeto-form-engine-input__wrapper",
790
+ children: [/*#__PURE__*/jsx("div", {
791
+ className: "neeto-form-engine-input__label-wrapper",
792
+ children: label && /*#__PURE__*/jsx("label", {
793
+ className: "neeto-form-engine-label",
794
+ children: getLabel(label, isRequired)
795
+ })
796
+ }), /*#__PURE__*/jsx("div", {
797
+ className: classnames({
798
+ "pointer-events-none": preview
799
+ }),
800
+ children: /*#__PURE__*/jsx(Component, {
801
+ captchaRef: captchaRef,
802
+ handleVerifyCaptcha: handleVerifyCaptcha,
803
+ handleBlur: function handleBlur() {
804
+ return setTouched(true);
805
+ }
806
+ })
807
+ }), touched && error && /*#__PURE__*/jsx("p", {
808
+ className: "neeto-form-engine-input__error",
809
+ "data-cy": "neeto-form-engine-captcha-error",
810
+ children: error
811
+ })]
812
+ });
813
+ };
814
+
815
+ var MATH_OPERATORS = {
816
+ PLUS: "+",
817
+ MINUS: "-"
818
+ };
819
+
820
+ var generateRandomOperation = function generateRandomOperation() {
821
+ var firstNumber = getRandomInt(1, 50);
822
+ var secondNumber = getRandomInt(1, 50);
823
+ var operator = randomPick.apply(void 0, _toConsumableArray(values(MATH_OPERATORS)));
824
+ return {
825
+ firstNumber: firstNumber,
826
+ secondNumber: secondNumber,
827
+ operator: operator
828
+ };
829
+ };
830
+
831
+ var MathCaptcha = function MathCaptcha(_ref) {
832
+ var captchaRef = _ref.captchaRef,
833
+ handleVerifyCaptcha = _ref.handleVerifyCaptcha,
834
+ handleBlur = _ref.handleBlur;
835
+ var _useState = useState(generateRandomOperation()),
836
+ _useState2 = _slicedToArray(_useState, 2),
837
+ operation = _useState2[0],
838
+ setOperation = _useState2[1];
839
+ var _useState3 = useState(""),
840
+ _useState4 = _slicedToArray(_useState3, 2),
841
+ userInput = _useState4[0],
842
+ setUserInput = _useState4[1];
843
+ var firstNumber = operation.firstNumber,
844
+ secondNumber = operation.secondNumber,
845
+ operator = operation.operator;
846
+ var resetCaptcha = function resetCaptcha() {
847
+ setOperation(generateRandomOperation());
848
+ setUserInput("");
849
+ };
850
+ useImperativeHandle(captchaRef, function () {
851
+ return {
852
+ reset: resetCaptcha
853
+ };
854
+ });
855
+ var calculateResult = function calculateResult() {
856
+ switch (operator) {
857
+ case MATH_OPERATORS.PLUS:
858
+ return firstNumber + secondNumber;
859
+ case MATH_OPERATORS.MINUS:
860
+ return firstNumber - secondNumber;
861
+ default:
862
+ return null;
863
+ }
864
+ };
865
+ var verifyCaptcha = function verifyCaptcha() {
866
+ var result = calculateResult();
867
+ if (result === null) return;
868
+ handleVerifyCaptcha(result === Number(userInput));
869
+ };
870
+ useUpdateEffect(function () {
871
+ verifyCaptcha();
872
+ }, [userInput]);
873
+ return /*#__PURE__*/jsxs("div", {
874
+ className: "neeto-form-nano-math-captcha",
875
+ ref: captchaRef,
876
+ children: [/*#__PURE__*/jsx("button", {
877
+ className: "neeto-form-nano-math-captcha__button",
878
+ type: "button",
879
+ onClick: resetCaptcha,
880
+ children: /*#__PURE__*/jsx(Refresh, {})
881
+ }), /*#__PURE__*/jsxs("div", {
882
+ className: "neeto-form-nano-math-captcha__equation",
883
+ children: [/*#__PURE__*/jsx("span", {
884
+ children: firstNumber
885
+ }), /*#__PURE__*/jsx("span", {
886
+ children: operator
887
+ }), /*#__PURE__*/jsx("span", {
888
+ children: secondNumber
889
+ }), /*#__PURE__*/jsx("span", {
890
+ children: "="
891
+ })]
892
+ }), /*#__PURE__*/jsx(Input, {
893
+ required: true,
894
+ className: "neeto-form-nano-math-captcha__input",
895
+ value: userInput,
896
+ onBlur: handleBlur,
897
+ onChange: withEventTargetValue(setUserInput)
898
+ })]
899
+ });
900
+ };
901
+
902
+ var Recaptcha = function Recaptcha(_ref) {
903
+ var captchaRef = _ref.captchaRef,
904
+ handleVerifyCaptcha = _ref.handleVerifyCaptcha;
905
+ var verifyRecaptcha = function verifyRecaptcha(response) {
906
+ if (response === null) {
907
+ return;
908
+ }
909
+ handleVerifyCaptcha(response);
910
+ };
911
+ var expiredRecaptcha = function expiredRecaptcha() {
912
+ var _captchaRef$current;
913
+ captchaRef === null || captchaRef === void 0 || (_captchaRef$current = captchaRef.current) === null || _captchaRef$current === void 0 || _captchaRef$current.reset();
914
+ handleVerifyCaptcha("");
915
+ };
916
+ return /*#__PURE__*/jsx(ReCAPTCHA, {
917
+ hl: clientI18nInstance.language,
918
+ ref: captchaRef,
919
+ sitekey: globalProps.formNanoRecaptchaV2SiteKey,
920
+ onChange: verifyRecaptcha,
921
+ onErrored: noop,
922
+ onExpired: expiredRecaptcha
923
+ }, clientI18nInstance.language);
924
+ };
925
+
926
+ function ownKeys$e(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
927
+ function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$e(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$e(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
928
+ var ConditionField = function ConditionField(_ref) {
929
+ var question = _ref.question,
930
+ customValidator = _ref.customValidator;
931
+ var name = question.id,
932
+ kind = question.kind,
933
+ isRequired = question.isRequired,
934
+ nodeId = question.nodeId;
935
+ var label = fieldWithFallback(question, "label");
936
+ return /*#__PURE__*/jsx(Field, {
937
+ name: name || nodeId,
938
+ validate: validateFieldValue({
939
+ kind: kind,
940
+ label: label,
941
+ isRequired: isRequired,
942
+ customValidator: customValidator
943
+ }),
944
+ children: function children(_ref2) {
945
+ var meta = _ref2.meta,
946
+ field = _ref2.field;
947
+ return /*#__PURE__*/jsx(Checkbox, _objectSpread$e(_objectSpread$e({}, _objectSpread$e(_objectSpread$e({}, field), {}, {
948
+ label: label,
949
+ name: name
950
+ })), {}, {
951
+ checked: field.value,
952
+ error: meta.touched ? meta.error : "",
953
+ required: isRequired
954
+ }));
955
+ }
956
+ });
957
+ };
958
+
959
+ var _excluded$3 = ["value"];
960
+ function ownKeys$d(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
961
+ function _objectSpread$d(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$d(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$d(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
962
+ dayjs.extend(weekOfYear);
963
+ dayjs.extend(weekday);
964
+ dayjs.extend(localeData);
965
+ dayjs.extend(utc);
966
+ var DateField = function DateField(_ref) {
967
+ var question = _ref.question,
968
+ customValidator = _ref.customValidator;
969
+ var name = question.id,
970
+ kind = question.kind,
971
+ isRequired = question.isRequired,
972
+ nodeId = question.nodeId;
973
+ var label = fieldWithFallback(question, "label");
974
+ var _QUESTION_KIND$kind$t = QUESTION_KIND[kind.toUpperCase()].type,
975
+ type = _QUESTION_KIND$kind$t === void 0 ? "date" : _QUESTION_KIND$kind$t;
976
+ return /*#__PURE__*/jsxs("div", {
977
+ className: "neeto-form-engine-input__wrapper",
978
+ children: [/*#__PURE__*/jsx("div", {
979
+ className: "neeto-form-engine-input__label-wrapper",
980
+ children: label && /*#__PURE__*/jsx("label", {
981
+ className: "neeto-form-engine-label",
982
+ children: getLabel(label, isRequired)
983
+ })
984
+ }), /*#__PURE__*/jsx("div", {
985
+ className: "neeto-form-engine-date-picker",
986
+ children: /*#__PURE__*/jsx(Field, {
987
+ name: name || nodeId,
988
+ validate: validateFieldValue({
989
+ kind: kind,
990
+ label: label,
991
+ isRequired: isRequired,
992
+ customValidator: customValidator
993
+ }),
994
+ children: function children(_ref2) {
995
+ var meta = _ref2.meta,
996
+ _ref2$field = _ref2.field,
997
+ value = _ref2$field.value,
998
+ field = _objectWithoutProperties(_ref2$field, _excluded$3),
999
+ form = _ref2.form;
1000
+ return /*#__PURE__*/jsx(DatePicker, _objectSpread$d(_objectSpread$d({}, _objectSpread$d(_objectSpread$d({}, field), {}, {
1001
+ type: type
1002
+ })), {}, {
1003
+ dateFormat: "MMM D, YYYY",
1004
+ error: meta.touched ? meta.error : "",
1005
+ placeholder: fieldWithFallback(question, "placeholder"),
1006
+ popupClassName: "neeto-form-engine-date-picker-popup",
1007
+ required: isRequired,
1008
+ size: "small",
1009
+ value: getValidDate(value),
1010
+ onChange: function onChange(date) {
1011
+ form.setFieldValue(name, date ? date.toISOString() : "");
1012
+ }
1013
+ }));
1014
+ }
1015
+ })
1016
+ })]
1017
+ });
1018
+ };
1019
+
1020
+ function ownKeys$c(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1021
+ function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1022
+ var EmailField = function EmailField(_ref) {
1023
+ var question = _ref.question,
1024
+ customValidator = _ref.customValidator,
1025
+ autoComplete = _ref.autoComplete;
1026
+ var name = question.id,
1027
+ kind = question.kind,
1028
+ isRequired = question.isRequired,
1029
+ isDomainRestrictionEnabled = question.isDomainRestrictionEnabled,
1030
+ restrictedDomains = question.restrictedDomains,
1031
+ nodeId = question.nodeId;
1032
+ var label = fieldWithFallback(question, "label");
1033
+ var type = QUESTION_KIND[kind.toUpperCase()].type;
1034
+ var _useField = useField({
1035
+ name: name || nodeId,
1036
+ validate: validateFieldValue({
1037
+ kind: kind,
1038
+ label: label,
1039
+ isRequired: isRequired,
1040
+ customValidator: customValidator,
1041
+ restrictedDomains: isDomainRestrictionEnabled ? restrictedDomains : []
1042
+ })
1043
+ }),
1044
+ _useField2 = _slicedToArray(_useField, 3),
1045
+ field = _useField2[0],
1046
+ _useField2$ = _useField2[1],
1047
+ touched = _useField2$.touched,
1048
+ error = _useField2$.error,
1049
+ _useField2$2 = _useField2[2],
1050
+ setValue = _useField2$2.setValue,
1051
+ setTouched = _useField2$2.setTouched;
1052
+ var handleFieldChange = withEventTargetValue(setValue);
1053
+ return /*#__PURE__*/jsx(Input, _objectSpread$c(_objectSpread$c({}, _objectSpread$c(_objectSpread$c({
1054
+ type: type
1055
+ }, field), {}, {
1056
+ autoComplete: autoComplete,
1057
+ label: label
1058
+ })), {}, {
1059
+ error: touched ? error : "",
1060
+ name: kind,
1061
+ placeholder: fieldWithFallback(question, "placeholder"),
1062
+ required: isRequired,
1063
+ onBlur: function onBlur() {
1064
+ return setTouched(true);
1065
+ },
1066
+ onChange: handleFieldChange
1067
+ }));
1068
+ };
1069
+
1070
+ function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1071
+ function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1072
+ var useFileUpload = function useFileUpload(_ref) {
1073
+ var disabled = _ref.disabled,
1074
+ accept = _ref.accept,
1075
+ multiple = _ref.multiple,
1076
+ name = _ref.name,
1077
+ maxFileSize = _ref.maxFileSize;
1078
+ var _useState = useState({}),
1079
+ _useState2 = _slicedToArray(_useState, 2),
1080
+ uploadProgress = _useState2[0],
1081
+ setUploadProgress = _useState2[1];
1082
+ var _useState3 = useState(""),
1083
+ _useState4 = _slicedToArray(_useState3, 2),
1084
+ uploadError = _useState4[0],
1085
+ setUploadError = _useState4[1];
1086
+ var _useField = useField(name),
1087
+ _useField2 = _slicedToArray(_useField, 3);
1088
+ _useField2[0];
1089
+ var value = _useField2[1].value,
1090
+ _useField2$ = _useField2[2],
1091
+ setValue = _useField2$.setValue,
1092
+ setError = _useField2$.setError,
1093
+ setTouched = _useField2$.setTouched;
1094
+ var filesRef = useRef(value === null || value === void 0 ? void 0 : value.files);
1095
+ filesRef.current = value === null || value === void 0 ? void 0 : value.files;
1096
+ var cancel = useCallback(function (index) {
1097
+ return function () {
1098
+ var _value$files;
1099
+ setUploadProgress(assoc(value.files[index].name, null));
1100
+ var newFiles = (_value$files = value.files) === null || _value$files === void 0 ? void 0 : _value$files.filter(function (_, idx) {
1101
+ return idx !== index;
1102
+ });
1103
+ setValue({
1104
+ files: newFiles
1105
+ });
1106
+ };
1107
+ }, [value]);
1108
+ useEffect(function () {
1109
+ uploadError && setError(uploadError);
1110
+ }, [uploadError]);
1111
+ var onDropAccepted = /*#__PURE__*/function () {
1112
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(acceptedFiles) {
1113
+ var initialFiles, updatedFiles, newFiles;
1114
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1115
+ while (1) switch (_context.prev = _context.next) {
1116
+ case 0:
1117
+ setTouched(false);
1118
+ setUploadError("");
1119
+ initialFiles = acceptedFiles.map(function (file) {
1120
+ return {
1121
+ name: file.name,
1122
+ size: file.size
1123
+ };
1124
+ });
1125
+ updatedFiles = multiple ? [].concat(_toConsumableArray(value.files || []), _toConsumableArray(initialFiles)) : initialFiles;
1126
+ setValue({
1127
+ files: updatedFiles
1128
+ });
1129
+ _context.next = 7;
1130
+ return new Promise(function (resolve) {
1131
+ var files = [];
1132
+ acceptedFiles.forEach(function (file) {
1133
+ setUploadProgress(assoc(file.name, 0));
1134
+ var upload = new DirectUpload(file, DIRECT_UPLOAD_URL, {
1135
+ directUploadWillStoreFileWithXHR: function directUploadWillStoreFileWithXHR(xhr) {
1136
+ xhr.upload.addEventListener("progress", function (event) {
1137
+ var percentComplete = Math.round(event.loaded / event.total * 100);
1138
+ setUploadProgress(assoc(file.name, percentComplete));
1139
+ });
1140
+ xhr.upload.addEventListener("load", function () {
1141
+ setUploadProgress(assoc(file.name, undefined));
1142
+ });
1143
+ }
1144
+ });
1145
+ upload.create(function (error, blob) {
1146
+ if (error) {
1147
+ return setUploadError(error);
1148
+ }
1149
+ files.push({
1150
+ url: blob.blob_url,
1151
+ name: blob.filename,
1152
+ signedId: blob.signed_id
1153
+ });
1154
+ var isUploadCompleted = multiple ? acceptedFiles.length === files.length : files.length === 1;
1155
+ if (isUploadCompleted) {
1156
+ return resolve(files);
1157
+ }
1158
+ return "";
1159
+ });
1160
+ });
1161
+ return files;
1162
+ });
1163
+ case 7:
1164
+ newFiles = _context.sent;
1165
+ if (multiple) {
1166
+ setValue({
1167
+ files: filesRef.current.map(function (file) {
1168
+ var uploadedFile = findBy({
1169
+ name: file.name
1170
+ }, newFiles);
1171
+ return _objectSpread$b(_objectSpread$b({}, file), uploadedFile);
1172
+ })
1173
+ });
1174
+ } else {
1175
+ setValue({
1176
+ files: newFiles
1177
+ });
1178
+ }
1179
+ case 9:
1180
+ case "end":
1181
+ return _context.stop();
1182
+ }
1183
+ }, _callee);
1184
+ }));
1185
+ return function onDropAccepted(_x) {
1186
+ return _ref2.apply(this, arguments);
1187
+ };
1188
+ }();
1189
+ var onDropRejected = function onDropRejected(fileRejections) {
1190
+ fileRejections.forEach(function (fileObject) {
1191
+ setTouched(true);
1192
+ setUploadError(renderErrorMessage(fileObject, maxFileSize, multiple));
1193
+ });
1194
+ };
1195
+ var _useDropzone = useDropzone({
1196
+ disabled: disabled,
1197
+ accept: accept,
1198
+ multiple: multiple,
1199
+ onDropAccepted: onDropAccepted,
1200
+ onDropRejected: onDropRejected,
1201
+ maxSize: convertMbToBytes(maxFileSize)
1202
+ }),
1203
+ getRootProps = _useDropzone.getRootProps,
1204
+ getInputProps = _useDropzone.getInputProps,
1205
+ isDragActive = _useDropzone.isDragActive,
1206
+ fileRejections = _useDropzone.fileRejections;
1207
+ return {
1208
+ files: value === null || value === void 0 ? void 0 : value.files,
1209
+ progress: uploadProgress,
1210
+ cancel: cancel,
1211
+ getRootProps: getRootProps,
1212
+ getInputProps: getInputProps,
1213
+ isDragActive: isDragActive,
1214
+ fileRejections: fileRejections
1215
+ };
1216
+ };
1217
+
1218
+ var _path;
1219
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1220
+ const SvgFileUpload = props => /*#__PURE__*/React.createElement("svg", _extends({
1221
+ xmlns: "http://www.w3.org/2000/svg",
1222
+ width: 48,
1223
+ height: 36,
1224
+ fill: "none"
1225
+ }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
1226
+ fill: "currentColor",
1227
+ d: "M32 26h-6v10h-4V26h-6l8-8 8 8zm6.958-11.816C38.534 6.282 32.012 0 24 0S9.466 6.282 9.042 14.184C3.902 15.11 0 19.596 0 25c0 6.074 4.926 11 11 11h7v-4h-7c-3.86 0-7-3.14-7-7 0-5.594 4.958-7.666 8.866-7.44C12.532 9.124 17.282 4 24 4c6.906 0 11.782 5.594 11.134 13.56C38.624 17.468 44 19.062 44 25c0 3.86-3.14 7-7 7h-7v4h7c6.074 0 11-4.926 11-11 0-5.404-3.902-9.89-9.042-10.816z"
1228
+ })));
1229
+
1230
+ function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1231
+ function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1232
+ var DropZone = function DropZone(_ref) {
1233
+ var isDragActive = _ref.isDragActive,
1234
+ getRootProps = _ref.getRootProps,
1235
+ getInputProps = _ref.getInputProps,
1236
+ multipleFilesAllowed = _ref.multipleFilesAllowed,
1237
+ _ref$hasFileSizeLimit = _ref.hasFileSizeLimit,
1238
+ hasFileSizeLimit = _ref$hasFileSizeLimit === void 0 ? true : _ref$hasFileSizeLimit,
1239
+ maxFileSize = _ref.maxFileSize,
1240
+ allowedFileTypes = _ref.allowedFileTypes;
1241
+ var _useTranslation = useTranslation(),
1242
+ t = _useTranslation.t;
1243
+ var shouldShowFileSizeLimit = hasFileSizeLimit && maxFileSize;
1244
+ return /*#__PURE__*/jsx("div", _objectSpread$a(_objectSpread$a({}, getRootProps({
1245
+ className: classnames(["neeto-form-engine-file-upload__dropzone"], {
1246
+ "neeto-form-engine-file-upload__dropzone--drag-active": isDragActive
1247
+ })
1248
+ })), {}, {
1249
+ children: /*#__PURE__*/jsxs("div", {
1250
+ className: "neeto-form-engine-file-upload__dropzone-inner",
1251
+ "data-cy": "file-upload-body",
1252
+ children: [/*#__PURE__*/jsx(SvgFileUpload, {
1253
+ className: "neeto-form-engine-file-upload__upload-icon"
1254
+ }), /*#__PURE__*/jsxs("div", {
1255
+ className: "neeto-form-engine-file-upload__dropzone-content",
1256
+ children: [/*#__PURE__*/jsxs("label", {
1257
+ className: "neeto-form-engine-file-upload__upload-label",
1258
+ htmlFor: "file-upload",
1259
+ children: [/*#__PURE__*/jsx(Trans, {
1260
+ i18nKey: "neetoForm.fileUpload.dropzone.chooseOrDragFile",
1261
+ components: {
1262
+ typography: /*#__PURE__*/jsx(Typography, {
1263
+ component: "span",
1264
+ weight: "semibold"
1265
+ }),
1266
+ span: /*#__PURE__*/jsx(Typography, {
1267
+ component: "span",
1268
+ weight: "normal"
1269
+ })
1270
+ }
1271
+ }), /*#__PURE__*/jsx("input", _objectSpread$a(_objectSpread$a({}, getInputProps()), {}, {
1272
+ "data-cy": "file-browse-button"
1273
+ }))]
1274
+ }), /*#__PURE__*/jsxs("div", {
1275
+ className: "neeto-form-engine-file-upload__dropzone-helper-block",
1276
+ children: [!multipleFilesAllowed && /*#__PURE__*/jsx(Typography, {
1277
+ className: "neeto-form-engine-file-upload__dropzone-helper-text",
1278
+ "data-cy": "upload-only-one-file-text",
1279
+ style: "body3",
1280
+ children: t("neetoForm.fileUpload.dropzone.oneFileAllowed")
1281
+ }), shouldShowFileSizeLimit && /*#__PURE__*/jsx(Typography, {
1282
+ className: "neeto-form-engine-file-upload__dropzone-helper-text",
1283
+ "data-cy": "maximum-allowed-size-text",
1284
+ style: "body3",
1285
+ children: t("neetoForm.fileUpload.dropzone.maxFileSize", {
1286
+ size: maxFileSize,
1287
+ unit: t("neetoForm.fileUpload.mb")
1288
+ })
1289
+ }), allowedFileTypes && /*#__PURE__*/jsx(Typography, {
1290
+ className: "neeto-form-engine-file-upload__dropzone-helper-text",
1291
+ "data-cy": "allowed-files-types-text",
1292
+ style: "body3",
1293
+ children: t("neetoForm.fileUpload.dropzone.allowedFileTypes", {
1294
+ types: allowedFileTypes
1295
+ })
1296
+ })]
1297
+ })]
1298
+ })]
1299
+ })
1300
+ }));
1301
+ };
1302
+
1303
+ var Progress = function Progress(_ref) {
1304
+ var percents = _ref.percents,
1305
+ _ref$stroke = _ref.stroke,
1306
+ stroke = _ref$stroke === void 0 ? "blue" : _ref$stroke,
1307
+ _ref$emptyStroke = _ref.emptyStroke,
1308
+ emptyStroke = _ref$emptyStroke === void 0 ? stroke : _ref$emptyStroke,
1309
+ _ref$emptyStrokeOpaci = _ref.emptyStrokeOpacity,
1310
+ emptyStrokeOpacity = _ref$emptyStrokeOpaci === void 0 ? 0.25 : _ref$emptyStrokeOpaci,
1311
+ _ref$duration = _ref.duration,
1312
+ duration = _ref$duration === void 0 ? 0.5 : _ref$duration,
1313
+ _ref$delay = _ref.delay,
1314
+ delay = _ref$delay === void 0 ? 0 : _ref$delay,
1315
+ _ref$size = _ref.size,
1316
+ size = _ref$size === void 0 ? 100 : _ref$size,
1317
+ _ref$strokeWidth = _ref.strokeWidth,
1318
+ strokeWidth = _ref$strokeWidth === void 0 ? 12 : _ref$strokeWidth;
1319
+ var radius = 45;
1320
+ var circumference = Math.ceil(2 * Math.PI * radius);
1321
+ var fillPercents = Math.abs(Math.ceil(circumference / 100 * (percents - 100)));
1322
+ var transition = {
1323
+ duration: duration,
1324
+ delay: delay
1325
+ };
1326
+ var variants = {
1327
+ hidden: {
1328
+ strokeDashoffset: circumference,
1329
+ transition: transition
1330
+ },
1331
+ show: {
1332
+ strokeDashoffset: fillPercents,
1333
+ transition: transition
1334
+ }
1335
+ };
1336
+ return /*#__PURE__*/jsx("div", {
1337
+ className: "neeto-form-engine-progress__circle",
1338
+ children: /*#__PURE__*/jsxs("div", {
1339
+ className: "neeto-form-engine-progress__circle-wrapper",
1340
+ style: {
1341
+ height: size
1342
+ },
1343
+ children: [/*#__PURE__*/jsx("svg", {
1344
+ height: size,
1345
+ version: "1.1",
1346
+ viewBox: "0 0 100 100",
1347
+ width: size,
1348
+ xmlns: "http://www.w3.org/2000/svg",
1349
+ children: /*#__PURE__*/jsx("circle", {
1350
+ strokeWidth: strokeWidth,
1351
+ className: "circle",
1352
+ cx: "50",
1353
+ cy: "50",
1354
+ fill: "transparent",
1355
+ r: radius,
1356
+ stroke: emptyStroke,
1357
+ strokeOpacity: emptyStrokeOpacity
1358
+ })
1359
+ }), /*#__PURE__*/jsx("svg", {
1360
+ height: size,
1361
+ viewBox: "0 0 100 100",
1362
+ width: size,
1363
+ style: {
1364
+ position: "absolute",
1365
+ transform: "rotate(-90deg)",
1366
+ overflow: "visible",
1367
+ top: 0
1368
+ },
1369
+ children: /*#__PURE__*/jsx(motion.circle, {
1370
+ stroke: stroke,
1371
+ strokeWidth: strokeWidth,
1372
+ variants: variants,
1373
+ animate: "show",
1374
+ cx: "50",
1375
+ cy: "50",
1376
+ fill: "transparent",
1377
+ initial: "hidden",
1378
+ r: radius,
1379
+ strokeDasharray: circumference,
1380
+ strokeDashoffset: fillPercents
1381
+ })
1382
+ })]
1383
+ })
1384
+ });
1385
+ };
1386
+
1387
+ var FILE_MIME_TYPES = {
1388
+ pdf: ["application/pdf"],
1389
+ doc: ["application/msword", "application/wps-writer"],
1390
+ docx: ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
1391
+ xls: ["application/vnd.ms-excel"],
1392
+ xlsx: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
1393
+ csv: ["text/csv"],
1394
+ txt: ["text/plain"],
1395
+ rtf: ["application/rtf", "text/rtf"],
1396
+ html: ["text/html"],
1397
+ htm: ["text/html"],
1398
+ md: ["text/markdown", "text/x-markdown"],
1399
+ zip: ["application/zip"],
1400
+ mp3: ["audio/mpeg"],
1401
+ wma: ["audio/x-ms-wma", "video/x-ms-asf"],
1402
+ mp4: ["video/mp4"],
1403
+ mpg: ["video/mpeg"],
1404
+ mpeg: ["video/mpeg"],
1405
+ flv: ["video/x-flv"],
1406
+ avi: ["video/x-msvideo"],
1407
+ jpg: ["image/jpeg"],
1408
+ jpeg: ["image/jpeg"],
1409
+ png: ["image/png"],
1410
+ gif: ["image/gif"]
1411
+ };
1412
+
1413
+ var getAcceptedFileTypes = function getAcceptedFileTypes(allowedFileTypes) {
1414
+ var accepted = {};
1415
+ allowedFileTypes.split(", ").forEach(function (type) {
1416
+ var mimeTypes = FILE_MIME_TYPES[type];
1417
+ var extension = ".".concat(type);
1418
+ if (isNotPresent(type) || isNotPresent(mimeTypes)) return;
1419
+ mimeTypes.forEach(function (mimeType) {
1420
+ if (accepted[mimeType]) accepted[mimeType].push(extension);else accepted[mimeType] = [extension];
1421
+ });
1422
+ });
1423
+ return accepted;
1424
+ };
1425
+ var convertBytesToMb = function convertBytesToMb(bytes) {
1426
+ return (bytes / (1024 * 1024)).toFixed(2);
1427
+ };
1428
+
1429
+ var FilePreview = withT(function (_ref) {
1430
+ var t = _ref.t,
1431
+ file = _ref.file,
1432
+ isUploading = _ref.isUploading,
1433
+ cancel = _ref.cancel,
1434
+ progress = _ref.progress;
1435
+ return /*#__PURE__*/jsxs("li", {
1436
+ className: "neeto-form-engine-file-upload__uploaded-list-item",
1437
+ children: [/*#__PURE__*/jsxs("div", {
1438
+ className: "neeto-form-engine-file-upload__file-preview",
1439
+ children: [/*#__PURE__*/jsx(Button, {
1440
+ className: classnames("p-0", {
1441
+ invisible: isUploading
1442
+ }),
1443
+ href: file.url,
1444
+ icon: FileGeneric,
1445
+ iconSize: 24,
1446
+ rel: "noreferrer",
1447
+ size: "large",
1448
+ style: "text",
1449
+ target: "_blank"
1450
+ }), isUploading && /*#__PURE__*/jsx("div", {
1451
+ className: "neeto-form-engine-progress",
1452
+ children: /*#__PURE__*/jsx(Progress, {
1453
+ percents: progress || 0,
1454
+ size: 20
1455
+ })
1456
+ })]
1457
+ }), /*#__PURE__*/jsxs("div", {
1458
+ className: "flex min-w-0 grow flex-col break-words",
1459
+ children: [/*#__PURE__*/jsx(Typography, {
1460
+ className: "neeto-form-engine-file-upload__file-info-name",
1461
+ style: "body2",
1462
+ children: file.name
1463
+ }), /*#__PURE__*/jsx(Typography, {
1464
+ className: "neeto-form-engine-file-upload__file-info-size",
1465
+ style: "body3",
1466
+ children: file.size ? t("neetoForm.fileUpload.fileSizeInMb", {
1467
+ fileSize: convertBytesToMb(file.size)
1468
+ }) : ""
1469
+ })]
1470
+ }), /*#__PURE__*/jsxs("div", {
1471
+ className: "neeto-form-engine-file-upload__actions",
1472
+ children: [/*#__PURE__*/jsx("span", {
1473
+ className: classnames("neeto-form-engine-file-upload__success-indicator", {
1474
+ "neeto-form-engine-file-upload__success-indicator--active": file.url
1475
+ }),
1476
+ children: file.url && /*#__PURE__*/jsx(Check, {})
1477
+ }), /*#__PURE__*/jsx("button", {
1478
+ className: "neeto-form-engine-file-upload__button--red neeto-form-engine-file-upload__remove-button",
1479
+ type: "button",
1480
+ onClick: cancel,
1481
+ children: /*#__PURE__*/jsx(Close, {})
1482
+ })]
1483
+ })]
1484
+ }, file.url);
1485
+ });
1486
+
1487
+ var FileUploadField = function FileUploadField(_ref) {
1488
+ var question = _ref.question,
1489
+ _ref$preview = _ref.preview,
1490
+ preview = _ref$preview === void 0 ? false : _ref$preview,
1491
+ customValidator = _ref.customValidator;
1492
+ var name = question.id,
1493
+ kind = question.kind,
1494
+ isRequired = question.isRequired,
1495
+ nodeId = question.nodeId,
1496
+ allowedFileTypes = question.allowedFileTypes,
1497
+ multipleFilesAllowed = question.multipleFilesAllowed,
1498
+ maxFileSize = question.maxFileSize;
1499
+ var label = fieldWithFallback(question, "label");
1500
+ var _useField = useField({
1501
+ name: name || nodeId,
1502
+ validate: validateFieldValue({
1503
+ kind: kind,
1504
+ label: label,
1505
+ isRequired: isRequired,
1506
+ customValidator: customValidator,
1507
+ multipleFilesAllowed: multipleFilesAllowed
1508
+ })
1509
+ }),
1510
+ _useField2 = _slicedToArray(_useField, 2);
1511
+ _useField2[0];
1512
+ var _useField2$ = _useField2[1],
1513
+ touched = _useField2$.touched,
1514
+ error = _useField2$.error;
1515
+ var _useFileUpload = useFileUpload({
1516
+ disabled: preview,
1517
+ accept: getAcceptedFileTypes(allowedFileTypes),
1518
+ multiple: multipleFilesAllowed,
1519
+ name: name || nodeId,
1520
+ maxFileSize: maxFileSize
1521
+ }),
1522
+ files = _useFileUpload.files,
1523
+ progress = _useFileUpload.progress,
1524
+ cancel = _useFileUpload.cancel,
1525
+ getRootProps = _useFileUpload.getRootProps,
1526
+ getInputProps = _useFileUpload.getInputProps,
1527
+ isDragActive = _useFileUpload.isDragActive,
1528
+ fileRejections = _useFileUpload.fileRejections;
1529
+ var shouldShowError = touched && error && isEmpty(fileRejections);
1530
+ var maxFileSizeInBytes = convertMbToBytes(maxFileSize);
1531
+ var isUploadingFile = function isUploadingFile(file) {
1532
+ return isNotNil(progress[file.name]) && (progress[file.name] !== 100 || !file.url);
1533
+ };
1534
+ return /*#__PURE__*/jsxs("div", {
1535
+ className: "neeto-form-engine-input__wrapper",
1536
+ children: [/*#__PURE__*/jsx("div", {
1537
+ className: "neeto-form-engine-input__label-wrapper",
1538
+ children: /*#__PURE__*/jsx(Label, {
1539
+ className: "neeto-form-engine-label",
1540
+ required: isRequired,
1541
+ children: label
1542
+ })
1543
+ }), /*#__PURE__*/jsx(DropZone, {
1544
+ allowedFileTypes: allowedFileTypes,
1545
+ getInputProps: getInputProps,
1546
+ getRootProps: getRootProps,
1547
+ isDragActive: isDragActive,
1548
+ maxFileSize: maxFileSize,
1549
+ multipleFilesAllowed: multipleFilesAllowed
1550
+ }), isNotEmpty(files) && /*#__PURE__*/jsx("ul", {
1551
+ className: "neeto-form-engine-file-upload__uploaded-list",
1552
+ children: files === null || files === void 0 ? void 0 : files.map(function (file, idx) {
1553
+ return /*#__PURE__*/createElement(FilePreview, {
1554
+ file: file,
1555
+ cancel: cancel(idx),
1556
+ isUploading: isUploadingFile(file),
1557
+ key: idx,
1558
+ progress: progress[file.name]
1559
+ });
1560
+ })
1561
+ }), isNotEmpty(fileRejections) && fileRejections.map(function (file, index) {
1562
+ return /*#__PURE__*/jsx(Typography, {
1563
+ className: "neeto-ui-text-error-800 neeto-ui-bg-pastel-red neeto-ui-rounded-sm mt-2 inline-block w-full p-1 text-sm",
1564
+ children: renderErrorMessage(file, maxFileSizeInBytes, false)
1565
+ }, index);
1566
+ }), shouldShowError && /*#__PURE__*/jsx(Typography, {
1567
+ className: "neeto-ui-text-error-800 neeto-ui-bg-pastel-red neeto-ui-rounded-sm mt-2 inline-block w-full p-1 text-sm",
1568
+ children: error
1569
+ })]
1570
+ });
1571
+ };
1572
+
1573
+ function ownKeys$9(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1574
+ function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1575
+ var NameField = function NameField(_ref) {
1576
+ var question = _ref.question,
1577
+ customValidator = _ref.customValidator,
1578
+ autoComplete = _ref.autoComplete;
1579
+ var name = question.id,
1580
+ kind = question.kind,
1581
+ isRequired = question.isRequired,
1582
+ nodeId = question.nodeId;
1583
+ var label = fieldWithFallback(question, "label");
1584
+ var _QUESTION_KIND$kind$t = QUESTION_KIND[kind.toUpperCase()].type,
1585
+ type = _QUESTION_KIND$kind$t === void 0 ? "text" : _QUESTION_KIND$kind$t;
1586
+ var _useField = useField({
1587
+ name: name || nodeId,
1588
+ validate: validateFieldValue({
1589
+ kind: kind,
1590
+ label: label,
1591
+ isRequired: isRequired,
1592
+ customValidator: customValidator
1593
+ })
1594
+ }),
1595
+ _useField2 = _slicedToArray(_useField, 3),
1596
+ field = _useField2[0],
1597
+ _useField2$ = _useField2[1],
1598
+ touched = _useField2$.touched,
1599
+ error = _useField2$.error,
1600
+ _useField2$2 = _useField2[2],
1601
+ setValue = _useField2$2.setValue,
1602
+ setTouched = _useField2$2.setTouched;
1603
+ var handleFieldChange = withEventTargetValue(setValue);
1604
+ return /*#__PURE__*/jsx(Input, _objectSpread$9(_objectSpread$9({}, _objectSpread$9(_objectSpread$9({
1605
+ type: type
1606
+ }, field), {}, {
1607
+ autoComplete: autoComplete,
1608
+ label: label
1609
+ })), {}, {
1610
+ error: touched ? error : "",
1611
+ name: kind,
1612
+ placeholder: fieldWithFallback(question, "placeholder"),
1613
+ required: isRequired,
1614
+ onBlur: function onBlur() {
1615
+ return setTouched(true);
1616
+ },
1617
+ onChange: handleFieldChange
1618
+ }));
1619
+ };
1620
+
1621
+ var Choices = function Choices(_ref) {
1622
+ var label = _ref.label,
1623
+ options = _ref.options,
1624
+ type = _ref.type,
1625
+ name = _ref.name,
1626
+ value = _ref.value,
1627
+ onChange = _ref.onChange,
1628
+ error = _ref.error;
1629
+ var isCheckBox = type === "checkbox";
1630
+ var ChoiceWrapper = isCheckBox ? "div" : Radio;
1631
+ var Component = isCheckBox ? Checkbox : Radio.Item;
1632
+ return /*#__PURE__*/jsxs("div", {
1633
+ className: "neeto-form-engine-choices__wrapper",
1634
+ "data-cy": "".concat(hyphenate(label), "-select-container-wrapper"),
1635
+ children: [/*#__PURE__*/jsx("label", {
1636
+ className: "neeto-form-engine-label",
1637
+ children: label
1638
+ }), /*#__PURE__*/jsx(ChoiceWrapper, {
1639
+ className: "neeto-form-engine-choices",
1640
+ stacked: !isCheckBox,
1641
+ children: options.map(function (option, index) {
1642
+ var _value$index;
1643
+ return /*#__PURE__*/jsx("label", {
1644
+ htmlFor: option.id,
1645
+ className: classnames("neeto-form-engine-choice", {
1646
+ active: false
1647
+ }),
1648
+ children: /*#__PURE__*/jsx(Component, {
1649
+ onChange: onChange,
1650
+ type: type,
1651
+ id: option.id,
1652
+ label: option.label,
1653
+ name: isCheckBox ? "".concat(name, ".").concat(index) : name,
1654
+ value: option.id,
1655
+ checked: isCheckBox ? (_value$index = value === null || value === void 0 ? void 0 : value[index]) !== null && _value$index !== void 0 ? _value$index : false : value === option.id
1656
+ })
1657
+ }, option.id);
1658
+ })
1659
+ }), !!error && typeof error === "string" && /*#__PURE__*/jsx("p", {
1660
+ className: "neeto-form-engine-input__error",
1661
+ "data-cy": "neeto-form-engine-".concat(type, "-error"),
1662
+ children: error
1663
+ })]
1664
+ });
1665
+ };
1666
+ var Choices$1 = /*#__PURE__*/memo(Choices);
1667
+
1668
+ function ownKeys$8(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1669
+ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1670
+ var OptionsField = function OptionsField(_ref) {
1671
+ var question = _ref.question,
1672
+ customValidator = _ref.customValidator;
1673
+ var _useFormikContext = useFormikContext(),
1674
+ setFieldTouched = _useFormikContext.setFieldTouched,
1675
+ setFieldValue = _useFormikContext.setFieldValue,
1676
+ validateField = _useFormikContext.validateField;
1677
+ var name = question.id,
1678
+ kind = question.kind,
1679
+ isRequired = question.isRequired,
1680
+ _question$optionsAttr = question.optionsAttributes,
1681
+ options = _question$optionsAttr === void 0 ? [] : _question$optionsAttr;
1682
+ var isDropdown = kind === QUESTION_KIND.DROPDOWN.value;
1683
+ var label = fieldWithFallback(question, "label");
1684
+ var Component = isDropdown ? Select : Choices$1;
1685
+ var transformedOptions = isDropdown ? options.map(function (option) {
1686
+ return {
1687
+ label: fieldWithFallback(option, "label"),
1688
+ displayOrder: option.displayOrder,
1689
+ value: option.id
1690
+ };
1691
+ }) : options.map(function (option) {
1692
+ return _objectSpread$8(_objectSpread$8({}, option), {}, {
1693
+ label: fieldWithFallback(option, "label")
1694
+ });
1695
+ });
1696
+ var handleSelect = function handleSelect(option) {
1697
+ setFieldValue(name, option.value, false);
1698
+ setFieldTouched(name, true, false);
1699
+ setTimeout(function () {
1700
+ return validateField(name);
1701
+ });
1702
+ };
1703
+ return /*#__PURE__*/jsx(Field, {
1704
+ name: name,
1705
+ validate: validateFieldValue({
1706
+ kind: kind,
1707
+ label: label,
1708
+ isRequired: isRequired,
1709
+ customValidator: customValidator
1710
+ }),
1711
+ children: function children(_ref2) {
1712
+ var meta = _ref2.meta,
1713
+ field = _ref2.field;
1714
+ var onChange = field.onChange,
1715
+ value = field.value;
1716
+ return /*#__PURE__*/jsx(Component, {
1717
+ isRequired: isRequired,
1718
+ name: name,
1719
+ error: getError(meta),
1720
+ label: getLabel(label, isRequired),
1721
+ options: transformedOptions,
1722
+ type: kind,
1723
+ value: isDropdown ? findBy({
1724
+ value: value
1725
+ }, transformedOptions) || null : value,
1726
+ onChange: isDropdown ? handleSelect : onChange
1727
+ });
1728
+ }
1729
+ });
1730
+ };
1731
+
1732
+ var PhoneNumberField = function PhoneNumberField(_ref) {
1733
+ var _getPhoneData;
1734
+ var question = _ref.question,
1735
+ autoComplete = _ref.autoComplete;
1736
+ var name = question.id,
1737
+ kind = question.kind,
1738
+ isRequired = question.isRequired,
1739
+ nodeId = question.nodeId;
1740
+ var label = fieldWithFallback(question, "label");
1741
+ var _useField = useField({
1742
+ name: name || nodeId,
1743
+ validate: validateFieldValue({
1744
+ kind: kind,
1745
+ label: label,
1746
+ isRequired: isRequired
1747
+ })
1748
+ }),
1749
+ _useField2 = _slicedToArray(_useField, 3),
1750
+ value = _useField2[0].value,
1751
+ _useField2$ = _useField2[1],
1752
+ touched = _useField2$.touched,
1753
+ error = _useField2$.error,
1754
+ _useField2$2 = _useField2[2],
1755
+ setValue = _useField2$2.setValue,
1756
+ setTouched = _useField2$2.setTouched;
1757
+ return /*#__PURE__*/jsx(PhoneNumberInput, {
1758
+ autoComplete: autoComplete,
1759
+ label: label,
1760
+ value: value,
1761
+ className: "neeto-form-engine-input__wrapper items-stretch",
1762
+ error: touched ? error : "",
1763
+ initialCountryCode: (_getPhoneData = getPhoneData(value)) === null || _getPhoneData === void 0 ? void 0 : _getPhoneData.country,
1764
+ placeholder: fieldWithFallback(question, "placeholder"),
1765
+ required: isRequired,
1766
+ onBlur: function onBlur() {
1767
+ return setTouched(true);
1768
+ },
1769
+ onChange: setValue
1770
+ });
1771
+ };
1772
+
1773
+ var _excluded$2 = ["name", "label", "error", "lowestRatingLabel", "averageRatingLabel", "highestRatingLabel", "value"];
1774
+ function ownKeys$7(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1775
+ function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1776
+ var Rating = function Rating(_ref) {
1777
+ var name = _ref.name,
1778
+ label = _ref.label,
1779
+ error = _ref.error,
1780
+ lowestRatingLabel = _ref.lowestRatingLabel,
1781
+ averageRatingLabel = _ref.averageRatingLabel,
1782
+ highestRatingLabel = _ref.highestRatingLabel,
1783
+ value = _ref.value,
1784
+ other = _objectWithoutProperties(_ref, _excluded$2);
1785
+ var handleClick = function handleClick(e) {
1786
+ return e.currentTarget.nextElementSibling.click();
1787
+ };
1788
+ var render = function render() {
1789
+ var labels = [highestRatingLabel, averageRatingLabel, lowestRatingLabel];
1790
+ return RATING_OPTIONS.map(function (_ref2, index) {
1791
+ var Icon = _ref2.icon,
1792
+ modifier = _ref2.modifier,
1793
+ rating = _ref2.value;
1794
+ return /*#__PURE__*/jsxs(Fragment, {
1795
+ children: [/*#__PURE__*/jsxs("button", {
1796
+ type: "button",
1797
+ className: classnames("neeto-form-engine-rating__item neeto-form-engine-rating__item--".concat(modifier), {
1798
+ active: rating === value
1799
+ }),
1800
+ onClick: handleClick,
1801
+ children: [/*#__PURE__*/jsx(Icon, {}), /*#__PURE__*/jsx("label", {
1802
+ className: "neeto-form-engine-label",
1803
+ children: labels[index]
1804
+ })]
1805
+ }), /*#__PURE__*/jsx("input", _objectSpread$7({
1806
+ name: name,
1807
+ hidden: true,
1808
+ checked: rating === value,
1809
+ type: "radio",
1810
+ value: rating
1811
+ }, other))]
1812
+ }, rating);
1813
+ });
1814
+ };
1815
+ return /*#__PURE__*/jsxs("div", {
1816
+ className: "neeto-form-engine-rating",
1817
+ children: [/*#__PURE__*/jsx("label", {
1818
+ className: "neeto-form-engine-label",
1819
+ children: label
1820
+ }), /*#__PURE__*/jsx("div", {
1821
+ className: "neeto-form-engine-rating__row",
1822
+ children: render()
1823
+ }), !!error && typeof error === "string" && /*#__PURE__*/jsx("p", {
1824
+ className: "neeto-form-engine-input__error",
1825
+ "data-cy": "neeto-form-engine-rating-error",
1826
+ children: error
1827
+ })]
1828
+ });
1829
+ };
1830
+ var Rating$1 = /*#__PURE__*/memo(Rating);
1831
+
1832
+ function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1833
+ function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1834
+ var RatingField = function RatingField(_ref) {
1835
+ var question = _ref.question,
1836
+ customValidator = _ref.customValidator;
1837
+ var name = question.id,
1838
+ kind = question.kind,
1839
+ isRequired = question.isRequired;
1840
+ var label = fieldWithFallback(question, "label");
1841
+ return /*#__PURE__*/jsx(Field, {
1842
+ name: name,
1843
+ validate: validateFieldValue({
1844
+ kind: kind,
1845
+ label: label,
1846
+ isRequired: isRequired,
1847
+ customValidator: customValidator
1848
+ }),
1849
+ children: function children(_ref2) {
1850
+ var meta = _ref2.meta,
1851
+ field = _ref2.field;
1852
+ return /*#__PURE__*/jsx(Rating$1, _objectSpread$6(_objectSpread$6({}, field), {}, {
1853
+ error: meta.touched ? meta.error : "",
1854
+ label: getLabel(label, isRequired),
1855
+ averageRatingLabel: fieldWithFallback(question, "averageRatingLabel") || RATING_VALUES.AVERAGE.label,
1856
+ highestRatingLabel: fieldWithFallback(question, "highestRatingLabel") || RATING_VALUES.GOOD.label,
1857
+ lowestRatingLabel: fieldWithFallback(question, "lowestRatingLabel") || RATING_VALUES.BAD.label
1858
+ }));
1859
+ }
1860
+ });
1861
+ };
1862
+
1863
+ function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1864
+ function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1865
+ var RichTextEditor = function RichTextEditor(_ref) {
1866
+ var editorRef = _ref.editorRef,
1867
+ question = _ref.question,
1868
+ _ref$editorProps = _ref.editorProps,
1869
+ editorProps = _ref$editorProps === void 0 ? {} : _ref$editorProps;
1870
+ var _useFormikContext = useFormikContext(),
1871
+ errors = _useFormikContext.errors,
1872
+ touched = _useFormikContext.touched;
1873
+ var name = question.id,
1874
+ kind = question.kind,
1875
+ isRequired = question.isRequired,
1876
+ nodeId = question.nodeId;
1877
+ var label = fieldWithFallback(question, "label");
1878
+ var debouncedPlaceholder = useDebounce(fieldWithFallback(question, "placeholder"), 300);
1879
+ var propsToCompare = ["debouncedPlaceholder", "error", "touched"];
1880
+ return /*#__PURE__*/jsxs("div", {
1881
+ className: "neeto-form-engine-input__wrapper",
1882
+ children: [/*#__PURE__*/jsx("div", {
1883
+ className: "neeto-form-engine-input__label-wrapper",
1884
+ children: label && /*#__PURE__*/jsx("label", {
1885
+ className: "neeto-form-engine-label",
1886
+ children: getLabel(label, isRequired)
1887
+ })
1888
+ }), /*#__PURE__*/jsx(FastField, {
1889
+ debouncedPlaceholder: debouncedPlaceholder,
1890
+ error: errors[name],
1891
+ name: name || nodeId,
1892
+ shouldUpdate: isPropsUnequal(propsToCompare),
1893
+ touched: touched[name],
1894
+ validate: validateFieldValue({
1895
+ kind: kind,
1896
+ label: label,
1897
+ isRequired: isRequired
1898
+ }),
1899
+ children: function children(_ref2) {
1900
+ var field = _ref2.field,
1901
+ form = _ref2.form,
1902
+ meta = _ref2.meta;
1903
+ return /*#__PURE__*/jsx(NeetoEditor, _objectSpread$5({
1904
+ className: "neeto-form-engine-rich-text-input",
1905
+ error: meta.touched ? meta.error : "",
1906
+ initialValue: field.value,
1907
+ placeholder: debouncedPlaceholder,
1908
+ ref: editorRef,
1909
+ addons: ["attachments", "block-quote", "code-block", "image-upload"],
1910
+ onBlur: function onBlur() {
1911
+ return form.setFieldTouched(name, true);
1912
+ },
1913
+ onChange: function onChange(value) {
1914
+ return form.setFieldValue(name, value);
1915
+ }
1916
+ }, editorProps), debouncedPlaceholder);
1917
+ }
1918
+ })]
1919
+ });
1920
+ };
1921
+
1922
+ var _excluded$1 = ["value", "iconType", "label", "rating"];
1923
+ function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1924
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1925
+ var RatingButton = function RatingButton(_ref) {
1926
+ var _ref$value = _ref.value,
1927
+ value = _ref$value === void 0 ? 0 : _ref$value,
1928
+ iconType = _ref.iconType,
1929
+ label = _ref.label,
1930
+ rating = _ref.rating,
1931
+ otherProps = _objectWithoutProperties(_ref, _excluded$1);
1932
+ var handleClick = function handleClick(e) {
1933
+ return e.currentTarget.nextElementSibling.click();
1934
+ };
1935
+ var Icon = ICONS_MAP[iconType];
1936
+ var selectedRating = getSelectedRating(value);
1937
+ return /*#__PURE__*/jsxs(Fragment$1, {
1938
+ children: [/*#__PURE__*/jsxs("button", {
1939
+ className: classnames({
1940
+ active: rating === value
1941
+ }),
1942
+ type: "button",
1943
+ onClick: handleClick,
1944
+ children: [/*#__PURE__*/jsx(Icon, {
1945
+ size: 24,
1946
+ className: classnames("neeto-form-engine-star-rating__icon", {
1947
+ "neeto-form-engine-star-rating__icon--active": rating <= selectedRating
1948
+ })
1949
+ }), /*#__PURE__*/jsx("label", {
1950
+ className: "neeto-form-engine-label",
1951
+ children: label
1952
+ })]
1953
+ }), /*#__PURE__*/jsx("input", _objectSpread$4({
1954
+ hidden: true,
1955
+ checked: equals(rating, value),
1956
+ type: "radio",
1957
+ value: rating
1958
+ }, otherProps))]
1959
+ });
1960
+ };
1961
+ var RatingButton$1 = /*#__PURE__*/memo(RatingButton);
1962
+
1963
+ var _excluded = ["label", "minValue", "maxValue", "error"];
1964
+ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1965
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1966
+ var StarRating = function StarRating(_ref) {
1967
+ var label = _ref.label,
1968
+ minValue = _ref.minValue,
1969
+ maxValue = _ref.maxValue,
1970
+ error = _ref.error,
1971
+ props = _objectWithoutProperties(_ref, _excluded);
1972
+ return /*#__PURE__*/jsxs("div", {
1973
+ className: "neeto-form-engine-input__wrapper neeto-form-engine-star-rating",
1974
+ children: [/*#__PURE__*/jsx("div", {
1975
+ className: "neeto-form-engine-input__label-wrapper",
1976
+ children: /*#__PURE__*/jsx("label", {
1977
+ className: "neeto-form-engine-label",
1978
+ children: label
1979
+ })
1980
+ }), /*#__PURE__*/jsx("div", {
1981
+ className: "neeto-form-engine-star-rating__row",
1982
+ children: generateArray(minValue, maxValue).map(function (index) {
1983
+ return /*#__PURE__*/jsx(RatingButton$1, _objectSpread$3({
1984
+ label: index,
1985
+ rating: index
1986
+ }, props), index);
1987
+ })
1988
+ }), !!error && typeof error === "string" && /*#__PURE__*/jsx("p", {
1989
+ className: "neeto-form-engine-input__error",
1990
+ "data-cy": "neeto-form-engine-star-rating-error",
1991
+ children: error
1992
+ })]
1993
+ });
1994
+ };
1995
+ var StarRating$1 = /*#__PURE__*/memo(StarRating);
1996
+
1997
+ function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1998
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1999
+ var StarRatingField = function StarRatingField(_ref) {
2000
+ var question = _ref.question,
2001
+ customValidator = _ref.customValidator;
2002
+ var name = question.id,
2003
+ kind = question.kind,
2004
+ isRequired = question.isRequired,
2005
+ minValue = question.minValue,
2006
+ maxValue = question.maxValue,
2007
+ iconType = question.iconType;
2008
+ var label = fieldWithFallback(question, "label");
2009
+ return /*#__PURE__*/jsx(Field, {
2010
+ name: name,
2011
+ validate: validateFieldValue({
2012
+ kind: kind,
2013
+ label: label,
2014
+ isRequired: isRequired,
2015
+ customValidator: customValidator
2016
+ }),
2017
+ children: function children(_ref2) {
2018
+ var meta = _ref2.meta,
2019
+ field = _ref2.field;
2020
+ return /*#__PURE__*/jsx(StarRating$1, _objectSpread$2({
2021
+ iconType: iconType,
2022
+ maxValue: maxValue,
2023
+ minValue: minValue,
2024
+ name: name,
2025
+ error: meta.touched ? meta.error : "",
2026
+ label: getLabel(label, isRequired)
2027
+ }, field));
2028
+ }
2029
+ });
2030
+ };
2031
+
2032
+ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2033
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2034
+ var TermsField = function TermsField(_ref) {
2035
+ var question = _ref.question,
2036
+ customValidator = _ref.customValidator;
2037
+ var name = question.id,
2038
+ kind = question.kind,
2039
+ isRequired = question.isRequired,
2040
+ nodeId = question.nodeId;
2041
+ var label = fieldWithFallback(question, "label", true);
2042
+ return /*#__PURE__*/jsx(Field, {
2043
+ name: name || nodeId,
2044
+ validate: validateFieldValue({
2045
+ kind: kind,
2046
+ label: label,
2047
+ isRequired: isRequired,
2048
+ customValidator: customValidator
2049
+ }),
2050
+ children: function children(_ref2) {
2051
+ var meta = _ref2.meta,
2052
+ field = _ref2.field;
2053
+ return /*#__PURE__*/jsx("div", {
2054
+ className: "neeto-form-engine-terms",
2055
+ children: /*#__PURE__*/jsx(Checkbox, _objectSpread$1(_objectSpread$1({}, _objectSpread$1(_objectSpread$1({}, field), {}, {
2056
+ name: name
2057
+ })), {}, {
2058
+ checked: field.value,
2059
+ error: meta.touched ? meta.error : "",
2060
+ children: /*#__PURE__*/jsx(EditorContent, {
2061
+ content: label
2062
+ })
2063
+ }))
2064
+ });
2065
+ }
2066
+ });
2067
+ };
2068
+
2069
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2070
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2071
+ var TextField = function TextField(_ref) {
2072
+ var _otherProps$onChange;
2073
+ var question = _ref.question,
2074
+ customValidator = _ref.customValidator,
2075
+ autoComplete = _ref.autoComplete;
2076
+ var name = question.id,
2077
+ kind = question.kind,
2078
+ isRequired = question.isRequired,
2079
+ nodeId = question.nodeId;
2080
+ var label = fieldWithFallback(question, "label");
2081
+ var _QUESTION_KIND$kind$t = QUESTION_KIND[kind.toUpperCase()],
2082
+ _QUESTION_KIND$kind$t2 = _QUESTION_KIND$kind$t.type,
2083
+ type = _QUESTION_KIND$kind$t2 === void 0 ? "text" : _QUESTION_KIND$kind$t2,
2084
+ onKeyDown = _QUESTION_KIND$kind$t.onKeyDown,
2085
+ otherProps = _QUESTION_KIND$kind$t.otherProps;
2086
+ var Component = kind === QUESTION_KIND.TEXTAREA.value ? Textarea : Input;
2087
+ var _useField = useField({
2088
+ name: name || nodeId,
2089
+ validate: validateFieldValue({
2090
+ kind: kind,
2091
+ label: label,
2092
+ isRequired: isRequired,
2093
+ customValidator: customValidator
2094
+ })
2095
+ }),
2096
+ _useField2 = _slicedToArray(_useField, 3),
2097
+ field = _useField2[0],
2098
+ _useField2$ = _useField2[1],
2099
+ touched = _useField2$.touched,
2100
+ error = _useField2$.error,
2101
+ _useField2$2 = _useField2[2],
2102
+ setValue = _useField2$2.setValue,
2103
+ setTouched = _useField2$2.setTouched;
2104
+ var handleFieldChange = withEventTargetValue(setValue);
2105
+ return /*#__PURE__*/jsx(Component, _objectSpread(_objectSpread({}, _objectSpread(_objectSpread({
2106
+ type: type
2107
+ }, field), {}, {
2108
+ autoComplete: autoComplete,
2109
+ label: label,
2110
+ onKeyDown: onKeyDown
2111
+ })), {}, {
2112
+ error: touched ? error : "",
2113
+ name: slugify(label),
2114
+ placeholder: fieldWithFallback(question, "placeholder"),
2115
+ required: isRequired,
2116
+ onBlur: function onBlur() {
2117
+ return setTouched(true);
2118
+ },
2119
+ onChange: (_otherProps$onChange = otherProps === null || otherProps === void 0 ? void 0 : otherProps.onChange(handleFieldChange)) !== null && _otherProps$onChange !== void 0 ? _otherProps$onChange : handleFieldChange
2120
+ }));
2121
+ };
2122
+
2123
+ var _QUESTION_TO_COMPONEN, _CAPTCHA_COMPONENT_MA;
2124
+ var QUESTION_TO_COMPONENT_MAP = (_QUESTION_TO_COMPONEN = {}, _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.TEXT.value, TextField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.NAME.value, NameField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.EMAIL.value, EmailField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.INTEGER.value, TextField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.DECIMAL.value, TextField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.PHONE.value, PhoneNumberField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.QUESTION.value, TextField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.TEXTAREA.value, TextField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.CHECKBOX.value, OptionsField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.RADIO.value, OptionsField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.DROPDOWN.value, OptionsField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.RATING.value, RatingField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.PARAGRAPH.value, function (_ref) {
2125
+ var question = _ref.question;
2126
+ return /*#__PURE__*/jsx(EditorContent, {
2127
+ content: fieldWithFallback(question, "label", true)
2128
+ });
2129
+ }), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.TERMS.value, TermsField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.DATE.value, DateField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.STAR_RATING.value, StarRatingField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.ADDITIONAL_GUESTS.value, MultipleEmailInput), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.RICH_TEXT.value, RichTextEditor), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.CONDITION.value, ConditionField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.FILE_UPLOAD.value, FileUploadField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.CAPTCHA.value, CaptchaField), _QUESTION_TO_COMPONEN);
2130
+ var CAPTCHA_COMPONENT_MAP = (_CAPTCHA_COMPONENT_MA = {}, _defineProperty(_CAPTCHA_COMPONENT_MA, CAPTCHA_TYPES.RECAPTCHA_V2, Recaptcha), _defineProperty(_CAPTCHA_COMPONENT_MA, CAPTCHA_TYPES.MATH_CAPTCHA, MathCaptcha), _CAPTCHA_COMPONENT_MA);
2131
+
2132
+ var getFieldComponent = function getFieldComponent(_ref) {
2133
+ var kind = _ref.kind;
2134
+ if (kind in QUESTION_TO_COMPONENT_MAP) return QUESTION_TO_COMPONENT_MAP[kind];
2135
+ return function () {
2136
+ return null;
2137
+ };
2138
+ };
2139
+ var isPropsUnequal = function isPropsUnequal(props) {
2140
+ return function (nextProps, prevProps) {
2141
+ return notEqualsDeep(pick(props, nextProps), pick(props, prevProps));
2142
+ };
2143
+ };
2144
+ var getValidDate = function getValidDate(date) {
2145
+ if (!date) return "";
2146
+ return dayjs(date).isValid() ? dayjs(date) : "";
2147
+ };
2148
+ var getPhoneData = function getPhoneData(value, countryCode) {
2149
+ try {
2150
+ return parsePhoneNumber(value, countryCode);
2151
+ } catch (_unused) {
2152
+ return undefined;
2153
+ }
2154
+ };
2155
+
2156
+ export { FormikWrap as F, generateInitValues as a, getFieldComponent as b, clientI18nInstance as c, buildAutoCompleteAttribute as d, generateFormResponse as e, clearLocalStorageValues as f, getWithExpiry as g, mergeRefs as m, renderButtonsInOrder as r };
2157
+ //# sourceMappingURL=utils-7000103c.js.map