@bigbinary/neeto-molecules 1.0.8 → 1.0.9

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 (39) hide show
  1. package/dist/BrowserSupport.cjs.js +2 -1462
  2. package/dist/BrowserSupport.js +2 -1456
  3. package/dist/Columns.cjs.js +1 -183
  4. package/dist/Columns.js +1 -177
  5. package/dist/CustomDomain.cjs.js +2 -753
  6. package/dist/CustomDomain.js +2 -727
  7. package/dist/DateFormat.cjs.js +1 -46
  8. package/dist/DateFormat.js +1 -40
  9. package/dist/DateRangeFilter.cjs.js +1 -234
  10. package/dist/DateRangeFilter.js +1 -227
  11. package/dist/DynamicVariables.cjs.js +1 -112
  12. package/dist/DynamicVariables.js +1 -106
  13. package/dist/EmailPreview.cjs.js +1 -89
  14. package/dist/EmailPreview.js +1 -83
  15. package/dist/ErrorPage.cjs.js +1 -189
  16. package/dist/ErrorPage.js +1 -165
  17. package/dist/IpRestriction.cjs.js +1 -3578
  18. package/dist/IpRestriction.js +1 -3552
  19. package/dist/KeyboardShortcuts.cjs.js +6 -2193
  20. package/dist/KeyboardShortcuts.js +6 -2186
  21. package/dist/LoginPage.cjs.js +1 -598
  22. package/dist/LoginPage.js +1 -573
  23. package/dist/NeetoWidget.cjs.js +3 -86957
  24. package/dist/NeetoWidget.js +3 -86931
  25. package/dist/PublishBlock.cjs.js +2 -184
  26. package/dist/PublishBlock.js +2 -178
  27. package/dist/Schedule.cjs.js +1 -950
  28. package/dist/Schedule.js +1 -919
  29. package/dist/ShareViaEmail.cjs.js +2 -2832
  30. package/dist/ShareViaEmail.js +2 -2805
  31. package/dist/ShareViaLink.cjs.js +2 -1243
  32. package/dist/ShareViaLink.js +2 -1237
  33. package/dist/Sidebar.cjs.js +1 -222
  34. package/dist/Sidebar.js +1 -195
  35. package/dist/TimeFormat.cjs.js +1 -11
  36. package/dist/TimeFormat.js +1 -5
  37. package/package.json +2 -1
  38. package/src/translations/en.json +0 -1
  39. package/types/ShareViaEmail.d.ts +9 -2
@@ -1,2837 +1,7 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var neetoIcons = require('@bigbinary/neeto-icons');
5
- var neetoui = require('@bigbinary/neetoui');
6
- var formik$1 = require('@bigbinary/neetoui/formik');
7
- var neetoEditor = require('@bigbinary/neeto-editor');
8
- var reactI18next = require('react-i18next');
9
- var i18n = require('i18next');
10
- var ramda = require('ramda');
11
- var yup = require('yup');
12
- var formik = require('formik');
13
- var dayjs = require('dayjs');
14
- var require$$0 = require('stream');
15
-
16
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
-
18
- function _interopNamespace(e) {
19
- if (e && e.__esModule) return e;
20
- var n = Object.create(null);
21
- if (e) {
22
- Object.keys(e).forEach(function (k) {
23
- if (k !== 'default') {
24
- var d = Object.getOwnPropertyDescriptor(e, k);
25
- Object.defineProperty(n, k, d.get ? d : {
26
- enumerable: true,
27
- get: function () { return e[k]; }
28
- });
29
- }
30
- });
31
- }
32
- n["default"] = e;
33
- return Object.freeze(n);
34
- }
35
-
36
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
37
- var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
38
- var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
39
- var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
40
- var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
41
-
42
- function _extends() {
43
- _extends = Object.assign ? Object.assign.bind() : function (target) {
44
- for (var i = 1; i < arguments.length; i++) {
45
- var source = arguments[i];
46
- for (var key in source) {
47
- if (Object.prototype.hasOwnProperty.call(source, key)) {
48
- target[key] = source[key];
49
- }
50
- }
51
- }
52
- return target;
53
- };
54
- return _extends.apply(this, arguments);
55
- }
56
-
57
- function _objectWithoutPropertiesLoose(source, excluded) {
58
- if (source == null) return {};
59
- var target = {};
60
- var sourceKeys = Object.keys(source);
61
- var key, i;
62
- for (i = 0; i < sourceKeys.length; i++) {
63
- key = sourceKeys[i];
64
- if (excluded.indexOf(key) >= 0) continue;
65
- target[key] = source[key];
66
- }
67
- return target;
68
- }
69
-
70
- function _objectWithoutProperties(source, excluded) {
71
- if (source == null) return {};
72
- var target = _objectWithoutPropertiesLoose(source, excluded);
73
- var key, i;
74
- if (Object.getOwnPropertySymbols) {
75
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
76
- for (i = 0; i < sourceSymbolKeys.length; i++) {
77
- key = sourceSymbolKeys[i];
78
- if (excluded.indexOf(key) >= 0) continue;
79
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
80
- target[key] = source[key];
81
- }
82
- }
83
- return target;
84
- }
85
-
86
- var EmailPreview = function EmailPreview(_ref) {
87
- var to = _ref.to,
88
- from = _ref.from,
89
- subject = _ref.subject,
90
- body = _ref.body,
91
- productName = _ref.productName,
92
- actionButtonText = _ref.actionButtonText,
93
- logo = _ref.logo;
94
- var _useTranslation = reactI18next.useTranslation(),
95
- t = _useTranslation.t;
96
- return /*#__PURE__*/React__default["default"].createElement("div", {
97
- className: "border neeto-ui-border-gray-300 neeto-ui-shadow-m neeto-ui-bg-white flex flex-1 flex-col"
98
- }, /*#__PURE__*/React__default["default"].createElement("div", {
99
- className: "border-b neeto-ui-border-gray-300 divide-y divide-gray-200 p-6 space-y-3"
100
- }, /*#__PURE__*/React__default["default"].createElement("div", {
101
- className: "flex items-center gap-2",
102
- "data-testid": "email-to-block"
103
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
104
- className: "neeto-ui-text-gray-500",
105
- lineHeight: "normal",
106
- style: "body2"
107
- }, t("neetoMolecules.emailPreview.to"), ":"), (to === null || to === void 0 ? void 0 : to.join(", ")) || /*#__PURE__*/React__default["default"].createElement("div", {
108
- className: "neeto-ui-bg-gray-300 h-2 w-40 rounded-full"
109
- })), from && /*#__PURE__*/React__default["default"].createElement("div", {
110
- className: "flex items-center gap-2 pt-3"
111
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
112
- className: "neeto-ui-text-gray-500",
113
- lineHeight: "normal",
114
- style: "body2"
115
- }, t("neetoMolecules.emailPreview.from"), ":"), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
116
- className: "neeto-ui-text-gray-800",
117
- lineHeight: "normal",
118
- style: "body2"
119
- }, from)), /*#__PURE__*/React__default["default"].createElement("div", {
120
- className: "flex items-center gap-2 pt-3"
121
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
122
- className: "neeto-ui-text-gray-500",
123
- lineHeight: "normal",
124
- style: "body2"
125
- }, t("neetoMolecules.emailPreview.subject"), ":"), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
126
- className: "neeto-ui-text-gray-800",
127
- lineHeight: "normal",
128
- style: "body2"
129
- }, subject || /*#__PURE__*/React__default["default"].createElement("span", {
130
- className: "neeto-ui-bg-gray-300 h-2 w-40 rounded-full"
131
- })))), /*#__PURE__*/React__default["default"].createElement("div", {
132
- className: "neeto-ui-text-gray-800 flex flex-1 flex-col justify-between space-y-6 p-6 pr-10 text-base leading-relaxed"
133
- }, body ? /*#__PURE__*/React__default["default"].createElement(neetoEditor.EditorContent, {
134
- content: body
135
- }) : /*#__PURE__*/React__default["default"].createElement("div", {
136
- className: "space-y-4"
137
- }, /*#__PURE__*/React__default["default"].createElement("div", {
138
- className: "neeto-ui-bg-gray-300 h-2 w-80 rounded-full"
139
- }), /*#__PURE__*/React__default["default"].createElement("div", {
140
- className: "neeto-ui-bg-gray-300 h-2 w-72 rounded-full"
141
- }), /*#__PURE__*/React__default["default"].createElement("div", {
142
- className: "neeto-ui-bg-gray-300 h-2 w-80 rounded-full"
143
- })), actionButtonText && /*#__PURE__*/React__default["default"].createElement("div", {
144
- className: "mt-6 flex w-full items-center justify-center"
145
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
146
- className: "pointer-events-none",
147
- label: actionButtonText
148
- })), logo && /*#__PURE__*/React__default["default"].createElement("img", {
149
- alt: t("neetoMolecules.emailPreview.logoAltText"),
150
- className: "h-20 w-36 object-cover",
151
- src: logo
152
- })), productName && /*#__PURE__*/React__default["default"].createElement("div", {
153
- className: "neeto-ui-bg-gray-100 mt-auto p-2",
154
- "data-testid": "product-name-block"
155
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
156
- className: "neeto-ui-text-gray-600 text-center leading-6",
157
- style: "body3"
158
- }, t("neetoMolecules.emailPreview.poweredBy"), /*#__PURE__*/React__default["default"].createElement("span", {
159
- className: "neeto-ui-text-gray-800 font-medium"
160
- }, productName))));
161
- };
162
-
163
- var SEND_EMAIL_FORM_VALIDATION_SCHEMA = yup__namespace.object().shape({
164
- emailSubject: yup__namespace.string().required(i18n__default["default"].t("neetoMolecules.shareViaEmail.validations.requiredField", {
165
- entity: i18n__default["default"].t("neetoMolecules.shareViaEmail.subject")
166
- })),
167
- emailBody: yup__namespace.string().test("emailBody", i18n__default["default"].t("neetoMolecules.shareViaEmail.validations.requiredField", {
168
- entity: i18n__default["default"].t("neetoMolecules.shareViaEmail.emailBody")
169
- }), function (value) {
170
- return !neetoEditor.isEditorEmpty(value);
171
- }),
172
- sendFromEmail: yup__namespace.string().trim().email(i18n__default["default"].t("neetoMolecules.shareViaEmail.validations.invalidField", {
173
- entity: i18n__default["default"].t("neetoMolecules.shareViaEmail.emailAddress")
174
- })).required(i18n__default["default"].t("neetoMolecules.shareViaEmail.validations.requiredField", {
175
- entity: i18n__default["default"].t("neetoMolecules.shareViaEmail.sendFromInput.errorLabel")
176
- })),
177
- replyToEmail: yup__namespace.string().trim().email(i18n__default["default"].t("neetoMolecules.shareViaEmail.validations.invalidField", {
178
- entity: i18n__default["default"].t("neetoMolecules.shareViaEmail.emailAddress")
179
- })).required(i18n__default["default"].t("neetoMolecules.shareViaEmail.validations.invalidField", {
180
- entity: i18n__default["default"].t("neetoMolecules.shareViaEmail.replyToInput.errorLabel")
181
- })),
182
- notifyEmails: yup__namespace.array().min(1, i18n__default["default"].t("neetoMolecules.shareViaEmail.validations.atleastOneIsRequired", {
183
- entity: i18n__default["default"].t("neetoMolecules.shareViaEmail.emailAddress")
184
- })).test("are-all-emails-valid", i18n__default["default"].t("neetoMolecules.shareViaEmail.validations.invalidField", {
185
- entity: i18n__default["default"].t("neetoMolecules.shareViaEmail.emailAddress")
186
- }), function (emails) {
187
- return emails.every(ramda.prop("valid"));
188
- }),
189
- isSendLaterEnabled: yup__namespace["boolean"](),
190
- sendEmailDatetime: yup__namespace.date().when("isSendLaterEnabled", {
191
- is: true,
192
- then: yup__namespace.date().required(i18n__default["default"].t("neetoMolecules.shareViaEmail.validations.requiredField", {
193
- entity: i18n__default["default"].t("neetoMolecules.shareViaEmail.sendLaterDateInput.label")
194
- }))
195
- }),
196
- name: yup__namespace.string()
197
- });
198
- var INITIAL_VALUES = {
199
- sendFromEmail: "",
200
- replyToEmail: "",
201
- notifyEmails: [],
202
- emailSubject: "",
203
- emailBody: "",
204
- isSendLaterEnabled: false,
205
- sendEmailDatetime: undefined,
206
- category: "email_share"
207
- };
208
- var EDITOR_ADDONS = ["emoji", "block-quote", "image-upload", "divider", "video-embed"];
209
- var ALLOWED_FILE_PICKER_TYPES = [".csv"];
210
- var DIRECT_UPLOAD_URL = "/api/direct_uploads";
211
-
212
- function _arrayWithHoles(arr) {
213
- if (Array.isArray(arr)) return arr;
214
- }
215
-
216
- function _iterableToArrayLimit(arr, i) {
217
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
218
- if (null != _i) {
219
- var _s,
220
- _e,
221
- _x,
222
- _r,
223
- _arr = [],
224
- _n = !0,
225
- _d = !1;
226
- try {
227
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
228
- if (Object(_i) !== _i) return;
229
- _n = !1;
230
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
231
- } catch (err) {
232
- _d = !0, _e = err;
233
- } finally {
234
- try {
235
- if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
236
- } finally {
237
- if (_d) throw _e;
238
- }
239
- }
240
- return _arr;
241
- }
242
- }
243
-
244
- function _arrayLikeToArray(arr, len) {
245
- if (len == null || len > arr.length) len = arr.length;
246
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
247
- return arr2;
248
- }
249
-
250
- function _unsupportedIterableToArray(o, minLen) {
251
- if (!o) return;
252
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
253
- var n = Object.prototype.toString.call(o).slice(8, -1);
254
- if (n === "Object" && o.constructor) n = o.constructor.name;
255
- if (n === "Map" || n === "Set") return Array.from(o);
256
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
257
- }
258
-
259
- function _nonIterableRest() {
260
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
261
- }
262
-
263
- function _slicedToArray(arr, i) {
264
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
265
- }
266
-
267
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
268
- try {
269
- var info = gen[key](arg);
270
- var value = info.value;
271
- } catch (error) {
272
- reject(error);
273
- return;
274
- }
275
- if (info.done) {
276
- resolve(value);
277
- } else {
278
- Promise.resolve(value).then(_next, _throw);
279
- }
280
- }
281
- function _asyncToGenerator(fn) {
282
- return function () {
283
- var self = this,
284
- args = arguments;
285
- return new Promise(function (resolve, reject) {
286
- var gen = fn.apply(self, args);
287
- function _next(value) {
288
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
289
- }
290
- function _throw(err) {
291
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
292
- }
293
- _next(undefined);
294
- });
295
- };
296
- }
297
-
298
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
299
-
300
- var regeneratorRuntime$1 = {exports: {}};
301
-
302
- var _typeof = {exports: {}};
303
-
304
- (function (module) {
305
- function _typeof(obj) {
306
- "@babel/helpers - typeof";
307
-
308
- return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
309
- return typeof obj;
310
- } : function (obj) {
311
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
312
- }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
313
- }
314
- module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
315
- } (_typeof));
316
-
317
- (function (module) {
318
- var _typeof$1 = _typeof.exports["default"];
319
- function _regeneratorRuntime() {
320
- module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
321
- return exports;
322
- }, module.exports.__esModule = true, module.exports["default"] = module.exports;
323
- var exports = {},
324
- Op = Object.prototype,
325
- hasOwn = Op.hasOwnProperty,
326
- defineProperty = Object.defineProperty || function (obj, key, desc) {
327
- obj[key] = desc.value;
328
- },
329
- $Symbol = "function" == typeof Symbol ? Symbol : {},
330
- iteratorSymbol = $Symbol.iterator || "@@iterator",
331
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
332
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
333
- function define(obj, key, value) {
334
- return Object.defineProperty(obj, key, {
335
- value: value,
336
- enumerable: !0,
337
- configurable: !0,
338
- writable: !0
339
- }), obj[key];
340
- }
341
- try {
342
- define({}, "");
343
- } catch (err) {
344
- define = function define(obj, key, value) {
345
- return obj[key] = value;
346
- };
347
- }
348
- function wrap(innerFn, outerFn, self, tryLocsList) {
349
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
350
- generator = Object.create(protoGenerator.prototype),
351
- context = new Context(tryLocsList || []);
352
- return defineProperty(generator, "_invoke", {
353
- value: makeInvokeMethod(innerFn, self, context)
354
- }), generator;
355
- }
356
- function tryCatch(fn, obj, arg) {
357
- try {
358
- return {
359
- type: "normal",
360
- arg: fn.call(obj, arg)
361
- };
362
- } catch (err) {
363
- return {
364
- type: "throw",
365
- arg: err
366
- };
367
- }
368
- }
369
- exports.wrap = wrap;
370
- var ContinueSentinel = {};
371
- function Generator() {}
372
- function GeneratorFunction() {}
373
- function GeneratorFunctionPrototype() {}
374
- var IteratorPrototype = {};
375
- define(IteratorPrototype, iteratorSymbol, function () {
376
- return this;
377
- });
378
- var getProto = Object.getPrototypeOf,
379
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
380
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
381
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
382
- function defineIteratorMethods(prototype) {
383
- ["next", "throw", "return"].forEach(function (method) {
384
- define(prototype, method, function (arg) {
385
- return this._invoke(method, arg);
386
- });
387
- });
388
- }
389
- function AsyncIterator(generator, PromiseImpl) {
390
- function invoke(method, arg, resolve, reject) {
391
- var record = tryCatch(generator[method], generator, arg);
392
- if ("throw" !== record.type) {
393
- var result = record.arg,
394
- value = result.value;
395
- return value && "object" == _typeof$1(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
396
- invoke("next", value, resolve, reject);
397
- }, function (err) {
398
- invoke("throw", err, resolve, reject);
399
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
400
- result.value = unwrapped, resolve(result);
401
- }, function (error) {
402
- return invoke("throw", error, resolve, reject);
403
- });
404
- }
405
- reject(record.arg);
406
- }
407
- var previousPromise;
408
- defineProperty(this, "_invoke", {
409
- value: function value(method, arg) {
410
- function callInvokeWithMethodAndArg() {
411
- return new PromiseImpl(function (resolve, reject) {
412
- invoke(method, arg, resolve, reject);
413
- });
414
- }
415
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
416
- }
417
- });
418
- }
419
- function makeInvokeMethod(innerFn, self, context) {
420
- var state = "suspendedStart";
421
- return function (method, arg) {
422
- if ("executing" === state) throw new Error("Generator is already running");
423
- if ("completed" === state) {
424
- if ("throw" === method) throw arg;
425
- return doneResult();
426
- }
427
- for (context.method = method, context.arg = arg;;) {
428
- var delegate = context.delegate;
429
- if (delegate) {
430
- var delegateResult = maybeInvokeDelegate(delegate, context);
431
- if (delegateResult) {
432
- if (delegateResult === ContinueSentinel) continue;
433
- return delegateResult;
434
- }
435
- }
436
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
437
- if ("suspendedStart" === state) throw state = "completed", context.arg;
438
- context.dispatchException(context.arg);
439
- } else "return" === context.method && context.abrupt("return", context.arg);
440
- state = "executing";
441
- var record = tryCatch(innerFn, self, context);
442
- if ("normal" === record.type) {
443
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
444
- return {
445
- value: record.arg,
446
- done: context.done
447
- };
448
- }
449
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
450
- }
451
- };
452
- }
453
- function maybeInvokeDelegate(delegate, context) {
454
- var methodName = context.method,
455
- method = delegate.iterator[methodName];
456
- if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
457
- var record = tryCatch(method, delegate.iterator, context.arg);
458
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
459
- var info = record.arg;
460
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
461
- }
462
- function pushTryEntry(locs) {
463
- var entry = {
464
- tryLoc: locs[0]
465
- };
466
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
467
- }
468
- function resetTryEntry(entry) {
469
- var record = entry.completion || {};
470
- record.type = "normal", delete record.arg, entry.completion = record;
471
- }
472
- function Context(tryLocsList) {
473
- this.tryEntries = [{
474
- tryLoc: "root"
475
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
476
- }
477
- function values(iterable) {
478
- if (iterable) {
479
- var iteratorMethod = iterable[iteratorSymbol];
480
- if (iteratorMethod) return iteratorMethod.call(iterable);
481
- if ("function" == typeof iterable.next) return iterable;
482
- if (!isNaN(iterable.length)) {
483
- var i = -1,
484
- next = function next() {
485
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
486
- return next.value = undefined, next.done = !0, next;
487
- };
488
- return next.next = next;
489
- }
490
- }
491
- return {
492
- next: doneResult
493
- };
494
- }
495
- function doneResult() {
496
- return {
497
- value: undefined,
498
- done: !0
499
- };
500
- }
501
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
502
- value: GeneratorFunctionPrototype,
503
- configurable: !0
504
- }), defineProperty(GeneratorFunctionPrototype, "constructor", {
505
- value: GeneratorFunction,
506
- configurable: !0
507
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
508
- var ctor = "function" == typeof genFun && genFun.constructor;
509
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
510
- }, exports.mark = function (genFun) {
511
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
512
- }, exports.awrap = function (arg) {
513
- return {
514
- __await: arg
515
- };
516
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
517
- return this;
518
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
519
- void 0 === PromiseImpl && (PromiseImpl = Promise);
520
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
521
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
522
- return result.done ? result.value : iter.next();
523
- });
524
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
525
- return this;
526
- }), define(Gp, "toString", function () {
527
- return "[object Generator]";
528
- }), exports.keys = function (val) {
529
- var object = Object(val),
530
- keys = [];
531
- for (var key in object) keys.push(key);
532
- return keys.reverse(), function next() {
533
- for (; keys.length;) {
534
- var key = keys.pop();
535
- if (key in object) return next.value = key, next.done = !1, next;
536
- }
537
- return next.done = !0, next;
538
- };
539
- }, exports.values = values, Context.prototype = {
540
- constructor: Context,
541
- reset: function reset(skipTempReset) {
542
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
543
- },
544
- stop: function stop() {
545
- this.done = !0;
546
- var rootRecord = this.tryEntries[0].completion;
547
- if ("throw" === rootRecord.type) throw rootRecord.arg;
548
- return this.rval;
549
- },
550
- dispatchException: function dispatchException(exception) {
551
- if (this.done) throw exception;
552
- var context = this;
553
- function handle(loc, caught) {
554
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
555
- }
556
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
557
- var entry = this.tryEntries[i],
558
- record = entry.completion;
559
- if ("root" === entry.tryLoc) return handle("end");
560
- if (entry.tryLoc <= this.prev) {
561
- var hasCatch = hasOwn.call(entry, "catchLoc"),
562
- hasFinally = hasOwn.call(entry, "finallyLoc");
563
- if (hasCatch && hasFinally) {
564
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
565
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
566
- } else if (hasCatch) {
567
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
568
- } else {
569
- if (!hasFinally) throw new Error("try statement without catch or finally");
570
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
571
- }
572
- }
573
- }
574
- },
575
- abrupt: function abrupt(type, arg) {
576
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
577
- var entry = this.tryEntries[i];
578
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
579
- var finallyEntry = entry;
580
- break;
581
- }
582
- }
583
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
584
- var record = finallyEntry ? finallyEntry.completion : {};
585
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
586
- },
587
- complete: function complete(record, afterLoc) {
588
- if ("throw" === record.type) throw record.arg;
589
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
590
- },
591
- finish: function finish(finallyLoc) {
592
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
593
- var entry = this.tryEntries[i];
594
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
595
- }
596
- },
597
- "catch": function _catch(tryLoc) {
598
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
599
- var entry = this.tryEntries[i];
600
- if (entry.tryLoc === tryLoc) {
601
- var record = entry.completion;
602
- if ("throw" === record.type) {
603
- var thrown = record.arg;
604
- resetTryEntry(entry);
605
- }
606
- return thrown;
607
- }
608
- }
609
- throw new Error("illegal catch attempt");
610
- },
611
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
612
- return this.delegate = {
613
- iterator: values(iterable),
614
- resultName: resultName,
615
- nextLoc: nextLoc
616
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
617
- }
618
- }, exports;
619
- }
620
- module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
621
- } (regeneratorRuntime$1));
622
-
623
- // TODO(Babel 8): Remove this file.
624
-
625
- var runtime = regeneratorRuntime$1.exports();
626
- var regenerator = runtime;
627
-
628
- // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
629
- try {
630
- regeneratorRuntime = runtime;
631
- } catch (accidentalStrictMode) {
632
- if (typeof globalThis === "object") {
633
- globalThis.regeneratorRuntime = runtime;
634
- } else {
635
- Function("r", "regeneratorRuntime = r")(runtime);
636
- }
637
- }
638
-
639
- var EmailBody = function EmailBody(_ref, ref) {
640
- var id = _ref.id;
641
- var _useTranslation = reactI18next.useTranslation(),
642
- t = _useTranslation.t;
643
- return /*#__PURE__*/React__default["default"].createElement(neetoEditor.FormikEditor, {
644
- required: true,
645
- addons: EDITOR_ADDONS,
646
- className: "mb-6",
647
- "data-cy": "email-body",
648
- id: id,
649
- label: t("neetoMolecules.shareViaEmail.emailBody"),
650
- name: "emailBody",
651
- ref: ref,
652
- uploadEndpoint: DIRECT_UPLOAD_URL
653
- });
654
- };
655
- var EmailBody$1 = /*#__PURE__*/React.forwardRef(EmailBody);
656
-
657
- var FilePicker = function FilePicker(_ref) {
658
- var _ref$types = _ref.types,
659
- types = _ref$types === void 0 ? [] : _ref$types,
660
- onChange = _ref.onChange;
661
- var _useTranslation = reactI18next.useTranslation(),
662
- t = _useTranslation.t;
663
- var inputRef = React.useRef();
664
- var accept = types.join(", ");
665
- var handleInputChange = function handleInputChange(_ref2) {
666
- var target = _ref2.target;
667
- if (!target.files) return;
668
- onChange(target.files);
669
-
670
- // This will trigger handleClick when same file is uploaded again.
671
- inputRef.current.value = "";
672
- handleClick();
673
- };
674
- var handleClick = function handleClick() {
675
- if (!inputRef.current) return;
676
- inputRef.current.click();
677
- };
678
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
679
- icon: neetoIcons.Upload,
680
- label: t("neetoMolecules.shareViaEmail.uploadCsv"),
681
- size: "small",
682
- style: "link",
683
- tooltipProps: {
684
- content: t("neetoMolecules.shareViaEmail.uploadCsvTooltip")
685
- },
686
- onClick: handleClick
687
- }), /*#__PURE__*/React__default["default"].createElement("input", {
688
- accept: accept,
689
- className: "hidden",
690
- ref: inputRef,
691
- type: "file",
692
- onChange: handleInputChange
693
- }));
694
- };
695
-
696
- var _excluded$1 = ["name"];
697
- var FormikDatePicker = function FormikDatePicker(_ref) {
698
- var name = _ref.name,
699
- props = _objectWithoutProperties(_ref, _excluded$1);
700
- var _useField = formik.useField(name),
701
- _useField2 = _slicedToArray(_useField, 3),
702
- field = _useField2[0],
703
- meta = _useField2[1],
704
- setValue = _useField2[2].setValue;
705
- return /*#__PURE__*/React__default["default"].createElement(neetoui.DatePicker, _extends({}, field, meta, {
706
- onChange: setValue
707
- }, props, {
708
- "data-cy": "email-share-date-input"
709
- }));
710
- };
711
-
712
- var papaparse = {exports: {}};
713
-
1
+ "use strict";var e=require("react"),t=require("@bigbinary/neeto-icons"),r=require("@bigbinary/neetoui"),n=require("@bigbinary/neetoui/formik"),i=require("@bigbinary/neeto-editor"),a=require("react-i18next"),o=require("i18next"),s=require("ramda"),l=require("yup"),u=require("formik"),c=require("dayjs"),d=require("stream");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function h(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var p=f(e),m=f(o),y=h(l),g=f(c),v=f(d);function b(){return b=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},b.apply(this,arguments)}function _(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var E=function(e){var t=e.to,n=e.from,o=e.subject,s=e.body,l=e.productName,u=e.actionButtonText,c=e.logo,d=a.useTranslation().t;return p.default.createElement("div",{className:"border neeto-ui-border-gray-300 neeto-ui-shadow-m neeto-ui-bg-white flex flex-1 flex-col"},p.default.createElement("div",{className:"border-b neeto-ui-border-gray-300 divide-y divide-gray-200 p-6 space-y-3"},p.default.createElement("div",{className:"flex items-center gap-2","data-testid":"email-to-block"},p.default.createElement(r.Typography,{className:"neeto-ui-text-gray-500",lineHeight:"normal",style:"body2"},d("neetoMolecules.emailPreview.to"),":"),(null==t?void 0:t.join(", "))||p.default.createElement("div",{className:"neeto-ui-bg-gray-300 h-2 w-40 rounded-full"})),n&&p.default.createElement("div",{className:"flex items-center gap-2 pt-3"},p.default.createElement(r.Typography,{className:"neeto-ui-text-gray-500",lineHeight:"normal",style:"body2"},d("neetoMolecules.emailPreview.from"),":"),p.default.createElement(r.Typography,{className:"neeto-ui-text-gray-800",lineHeight:"normal",style:"body2"},n)),p.default.createElement("div",{className:"flex items-center gap-2 pt-3"},p.default.createElement(r.Typography,{className:"neeto-ui-text-gray-500",lineHeight:"normal",style:"body2"},d("neetoMolecules.emailPreview.subject"),":"),p.default.createElement(r.Typography,{className:"neeto-ui-text-gray-800",lineHeight:"normal",style:"body2"},o||p.default.createElement("span",{className:"neeto-ui-bg-gray-300 h-2 w-40 rounded-full"})))),p.default.createElement("div",{className:"neeto-ui-text-gray-800 flex flex-1 flex-col justify-between space-y-6 p-6 pr-10 text-base leading-relaxed"},s?p.default.createElement(i.EditorContent,{content:s}):p.default.createElement("div",{className:"space-y-4"},p.default.createElement("div",{className:"neeto-ui-bg-gray-300 h-2 w-80 rounded-full"}),p.default.createElement("div",{className:"neeto-ui-bg-gray-300 h-2 w-72 rounded-full"}),p.default.createElement("div",{className:"neeto-ui-bg-gray-300 h-2 w-80 rounded-full"})),u&&p.default.createElement("div",{className:"mt-6 flex w-full items-center justify-center"},p.default.createElement(r.Button,{className:"pointer-events-none",label:u})),c&&p.default.createElement("img",{alt:d("neetoMolecules.emailPreview.logoAltText"),className:"h-20 w-36 object-cover",src:c})),l&&p.default.createElement("div",{className:"neeto-ui-bg-gray-100 mt-auto p-2","data-testid":"product-name-block"},p.default.createElement(r.Typography,{className:"neeto-ui-text-gray-600 text-center leading-6",style:"body3"},d("neetoMolecules.emailPreview.poweredBy"),p.default.createElement("span",{className:"neeto-ui-text-gray-800 font-medium"},l))))},w=y.object().shape({emailSubject:y.string().required(m.default.t("neetoMolecules.shareViaEmail.validations.requiredField",{entity:m.default.t("neetoMolecules.shareViaEmail.subject")})),emailBody:y.string().test("emailBody",m.default.t("neetoMolecules.shareViaEmail.validations.requiredField",{entity:m.default.t("neetoMolecules.shareViaEmail.emailBody")}),(function(e){return!i.isEditorEmpty(e)})),sendFromEmail:y.string().trim().email(m.default.t("neetoMolecules.shareViaEmail.validations.invalidField",{entity:m.default.t("neetoMolecules.shareViaEmail.emailAddress")})).required(m.default.t("neetoMolecules.shareViaEmail.validations.requiredField",{entity:m.default.t("neetoMolecules.shareViaEmail.sendFromInput.errorLabel")})),replyToEmail:y.string().trim().email(m.default.t("neetoMolecules.shareViaEmail.validations.invalidField",{entity:m.default.t("neetoMolecules.shareViaEmail.emailAddress")})).required(m.default.t("neetoMolecules.shareViaEmail.validations.requiredField",{entity:m.default.t("neetoMolecules.shareViaEmail.replyToInput.errorLabel")})),notifyEmails:y.array().min(1,m.default.t("neetoMolecules.shareViaEmail.validations.atleastOneIsRequired",{entity:m.default.t("neetoMolecules.shareViaEmail.emailAddress")})).test("are-all-emails-valid",m.default.t("neetoMolecules.shareViaEmail.validations.invalidField",{entity:m.default.t("neetoMolecules.shareViaEmail.emailAddress")}),(function(e){return e.every(s.prop("valid"))})),isSendLaterEnabled:y.boolean(),sendEmailDatetime:y.date().when("isSendLaterEnabled",{is:!0,then:y.date().required(m.default.t("neetoMolecules.shareViaEmail.validations.requiredField",{entity:m.default.t("neetoMolecules.shareViaEmail.sendLaterDateInput.label")}))}),name:y.string()}),x={sendFromEmail:"",replyToEmail:"",notifyEmails:[],emailSubject:"",emailBody:"",isSendLaterEnabled:!1,sendEmailDatetime:void 0,category:"email_share"},k=["emoji","block-quote","image-upload","divider","video-embed"],O=[".csv"];function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function C(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,s=[],l=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return S(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?S(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(e,t,r,n,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void r(e)}s.done?t(l):Promise.resolve(l).then(n,i)}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var j={exports:{}},T={exports:{}};!function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(T),function(e){var t=T.exports.default;function r(){e.exports=r=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var n={},i=Object.prototype,a=i.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},s="function"==typeof Symbol?Symbol:{},l=s.iterator||"@@iterator",u=s.asyncIterator||"@@asyncIterator",c=s.toStringTag||"@@toStringTag";function d(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{d({},"")}catch(e){d=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof m?t:m,a=Object.create(i.prototype),s=new R(n||[]);return o(a,"_invoke",{value:k(e,r,s)}),a}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}n.wrap=f;var p={};function m(){}function y(){}function g(){}var v={};d(v,l,(function(){return this}));var b=Object.getPrototypeOf,_=b&&b(b(j([])));_&&_!==i&&a.call(_,l)&&(v=_);var E=g.prototype=m.prototype=Object.create(v);function w(e){["next","throw","return"].forEach((function(t){d(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,r){function n(i,o,s,l){var u=h(e[i],e,o);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==t(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(e){n("next",e,s,l)}),(function(e){n("throw",e,s,l)})):r.resolve(d).then((function(e){c.value=e,s(c)}),(function(e){return n("throw",e,s,l)}))}l(u.arg)}var i;o(this,"_invoke",{value:function(e,t){function a(){return new r((function(r,i){n(e,t,r,i)}))}return i=i?i.then(a,a):a()}})}function k(e,t,r){var n="suspendedStart";return function(i,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw a;return T()}for(r.method=i,r.arg=a;;){var o=r.delegate;if(o){var s=O(o,r);if(s){if(s===p)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var l=h(e,t,r);if("normal"===l.type){if(n=r.done?"completed":"suspendedYield",l.arg===p)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(n="completed",r.method="throw",r.arg=l.arg)}}}function O(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,O(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var i=h(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,p;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function j(e){if(e){var t=e[l];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(a.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:T}}function T(){return{value:void 0,done:!0}}return y.prototype=g,o(E,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:y,configurable:!0}),y.displayName=d(g,c,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,d(e,c,"GeneratorFunction")),e.prototype=Object.create(E),e},n.awrap=function(e){return{__await:e}},w(x.prototype),d(x.prototype,u,(function(){return this})),n.AsyncIterator=x,n.async=function(e,t,r,i,a){void 0===a&&(a=Promise);var o=new x(f(e,t,r,i),a);return n.isGeneratorFunction(t)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},w(E),d(E,c,"Generator"),d(E,l,(function(){return this})),d(E,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},n.values=j,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(C),!e)for(var t in this)"t"===t.charAt(0)&&a.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n],o=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(s&&l){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),C(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;C(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:j(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},n}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(j);var L=j.exports(),N=L;try{regeneratorRuntime=L}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=L:Function("r","regeneratorRuntime = r")(L)}var M=function(e,t){var r=e.id,n=a.useTranslation().t;return p.default.createElement(i.FormikEditor,{required:!0,addons:k,className:"mb-6","data-cy":"email-body",id:r,label:n("neetoMolecules.shareViaEmail.emailBody"),name:"emailBody",ref:t,uploadEndpoint:"/api/direct_uploads"})},P=e.forwardRef(M),A=function(n){var i=n.types,o=void 0===i?[]:i,s=n.onChange,l=a.useTranslation().t,u=e.useRef(),c=o.join(", "),d=function(){u.current&&u.current.click()};return p.default.createElement(p.default.Fragment,null,p.default.createElement(r.Button,{icon:t.Upload,label:l("neetoMolecules.shareViaEmail.uploadCsv"),size:"small",style:"link",tooltipProps:{content:l("neetoMolecules.shareViaEmail.uploadCsvTooltip")},onClick:d}),p.default.createElement("input",{accept:c,className:"hidden",ref:u,type:"file",onChange:function(e){var t=e.target;t.files&&(s(t.files),u.current.value="",d())}}))},I=["name"],F=function(e){var t=e.name,n=_(e,I),i=C(u.useField(t),3),a=i[0],o=i[1],s=i[2].setValue;return p.default.createElement(r.DatePicker,b({},a,o,{onChange:s},n,{"data-cy":"email-share-date-input"}))};function D(e){return D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},D(e)}function q(e){var t=function(e,t){if("object"!==D(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==D(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===D(t)?t:String(t)}function V(e,t,r){return(t=q(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var B={exports:{}};
714
2
  /* @license
715
3
  Papa Parse
716
4
  v5.4.0
717
5
  https://github.com/mholt/PapaParse
718
6
  License: MIT
719
- */
720
-
721
- (function (module, exports) {
722
- (function(root, factory)
723
- {
724
- /* globals define */
725
- {
726
- // Node. Does not work with strict CommonJS, but
727
- // only CommonJS-like environments that support module.exports,
728
- // like Node.
729
- module.exports = factory();
730
- }
731
- // in strict mode we cannot access arguments.callee, so we need a named reference to
732
- // stringify the factory method for the blob worker
733
- // eslint-disable-next-line func-name
734
- }(commonjsGlobal, function moduleFactory()
735
- {
736
-
737
- var global = (function() {
738
- // alternative method, similar to `Function('return this')()`
739
- // but without using `eval` (which is disabled when
740
- // using Content Security Policy).
741
-
742
- if (typeof self !== 'undefined') { return self; }
743
- if (typeof window !== 'undefined') { return window; }
744
- if (typeof global !== 'undefined') { return global; }
745
-
746
- // When running tests none of the above have been defined
747
- return {};
748
- })();
749
-
750
-
751
- function getWorkerBlob() {
752
- var URL = global.URL || global.webkitURL || null;
753
- var code = moduleFactory.toString();
754
- return Papa.BLOB_URL || (Papa.BLOB_URL = URL.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ", '(', code, ')();'], {type: 'text/javascript'})));
755
- }
756
-
757
- var IS_WORKER = !global.document && !!global.postMessage,
758
- IS_PAPA_WORKER = global.IS_PAPA_WORKER || false;
759
-
760
- var workers = {}, workerIdCounter = 0;
761
-
762
- var Papa = {};
763
-
764
- Papa.parse = CsvToJson;
765
- Papa.unparse = JsonToCsv;
766
-
767
- Papa.RECORD_SEP = String.fromCharCode(30);
768
- Papa.UNIT_SEP = String.fromCharCode(31);
769
- Papa.BYTE_ORDER_MARK = '\ufeff';
770
- Papa.BAD_DELIMITERS = ['\r', '\n', '"', Papa.BYTE_ORDER_MARK];
771
- Papa.WORKERS_SUPPORTED = !IS_WORKER && !!global.Worker;
772
- Papa.NODE_STREAM_INPUT = 1;
773
-
774
- // Configurable chunk sizes for local and remote files, respectively
775
- Papa.LocalChunkSize = 1024 * 1024 * 10; // 10 MB
776
- Papa.RemoteChunkSize = 1024 * 1024 * 5; // 5 MB
777
- Papa.DefaultDelimiter = ','; // Used if not specified and detection fails
778
-
779
- // Exposed for testing and development only
780
- Papa.Parser = Parser;
781
- Papa.ParserHandle = ParserHandle;
782
- Papa.NetworkStreamer = NetworkStreamer;
783
- Papa.FileStreamer = FileStreamer;
784
- Papa.StringStreamer = StringStreamer;
785
- Papa.ReadableStreamStreamer = ReadableStreamStreamer;
786
- if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
787
- Papa.DuplexStreamStreamer = DuplexStreamStreamer;
788
- }
789
-
790
- if (global.jQuery)
791
- {
792
- var $ = global.jQuery;
793
- $.fn.parse = function(options)
794
- {
795
- var config = options.config || {};
796
- var queue = [];
797
-
798
- this.each(function(idx)
799
- {
800
- var supported = $(this).prop('tagName').toUpperCase() === 'INPUT'
801
- && $(this).attr('type').toLowerCase() === 'file'
802
- && global.FileReader;
803
-
804
- if (!supported || !this.files || this.files.length === 0)
805
- return true; // continue to next input element
806
-
807
- for (var i = 0; i < this.files.length; i++)
808
- {
809
- queue.push({
810
- file: this.files[i],
811
- inputElem: this,
812
- instanceConfig: $.extend({}, config)
813
- });
814
- }
815
- });
816
-
817
- parseNextFile(); // begin parsing
818
- return this; // maintains chainability
819
-
820
-
821
- function parseNextFile()
822
- {
823
- if (queue.length === 0)
824
- {
825
- if (isFunction(options.complete))
826
- options.complete();
827
- return;
828
- }
829
-
830
- var f = queue[0];
831
-
832
- if (isFunction(options.before))
833
- {
834
- var returned = options.before(f.file, f.inputElem);
835
-
836
- if (typeof returned === 'object')
837
- {
838
- if (returned.action === 'abort')
839
- {
840
- error('AbortError', f.file, f.inputElem, returned.reason);
841
- return; // Aborts all queued files immediately
842
- }
843
- else if (returned.action === 'skip')
844
- {
845
- fileComplete(); // parse the next file in the queue, if any
846
- return;
847
- }
848
- else if (typeof returned.config === 'object')
849
- f.instanceConfig = $.extend(f.instanceConfig, returned.config);
850
- }
851
- else if (returned === 'skip')
852
- {
853
- fileComplete(); // parse the next file in the queue, if any
854
- return;
855
- }
856
- }
857
-
858
- // Wrap up the user's complete callback, if any, so that ours also gets executed
859
- var userCompleteFunc = f.instanceConfig.complete;
860
- f.instanceConfig.complete = function(results)
861
- {
862
- if (isFunction(userCompleteFunc))
863
- userCompleteFunc(results, f.file, f.inputElem);
864
- fileComplete();
865
- };
866
-
867
- Papa.parse(f.file, f.instanceConfig);
868
- }
869
-
870
- function error(name, file, elem, reason)
871
- {
872
- if (isFunction(options.error))
873
- options.error({name: name}, file, elem, reason);
874
- }
875
-
876
- function fileComplete()
877
- {
878
- queue.splice(0, 1);
879
- parseNextFile();
880
- }
881
- };
882
- }
883
-
884
-
885
- if (IS_PAPA_WORKER)
886
- {
887
- global.onmessage = workerThreadReceivedMessage;
888
- }
889
-
890
-
891
-
892
-
893
- function CsvToJson(_input, _config)
894
- {
895
- _config = _config || {};
896
- var dynamicTyping = _config.dynamicTyping || false;
897
- if (isFunction(dynamicTyping)) {
898
- _config.dynamicTypingFunction = dynamicTyping;
899
- // Will be filled on first row call
900
- dynamicTyping = {};
901
- }
902
- _config.dynamicTyping = dynamicTyping;
903
-
904
- _config.transform = isFunction(_config.transform) ? _config.transform : false;
905
-
906
- if (_config.worker && Papa.WORKERS_SUPPORTED)
907
- {
908
- var w = newWorker();
909
-
910
- w.userStep = _config.step;
911
- w.userChunk = _config.chunk;
912
- w.userComplete = _config.complete;
913
- w.userError = _config.error;
914
-
915
- _config.step = isFunction(_config.step);
916
- _config.chunk = isFunction(_config.chunk);
917
- _config.complete = isFunction(_config.complete);
918
- _config.error = isFunction(_config.error);
919
- delete _config.worker; // prevent infinite loop
920
-
921
- w.postMessage({
922
- input: _input,
923
- config: _config,
924
- workerId: w.id
925
- });
926
-
927
- return;
928
- }
929
-
930
- var streamer = null;
931
- if (_input === Papa.NODE_STREAM_INPUT && typeof PAPA_BROWSER_CONTEXT === 'undefined')
932
- {
933
- // create a node Duplex stream for use
934
- // with .pipe
935
- streamer = new DuplexStreamStreamer(_config);
936
- return streamer.getStream();
937
- }
938
- else if (typeof _input === 'string')
939
- {
940
- _input = stripBom(_input);
941
- if (_config.download)
942
- streamer = new NetworkStreamer(_config);
943
- else
944
- streamer = new StringStreamer(_config);
945
- }
946
- else if (_input.readable === true && isFunction(_input.read) && isFunction(_input.on))
947
- {
948
- streamer = new ReadableStreamStreamer(_config);
949
- }
950
- else if ((global.File && _input instanceof File) || _input instanceof Object) // ...Safari. (see issue #106)
951
- streamer = new FileStreamer(_config);
952
-
953
- return streamer.stream(_input);
954
-
955
- // Strip character from UTF-8 BOM encoded files that cause issue parsing the file
956
- function stripBom(string) {
957
- if (string.charCodeAt(0) === 0xfeff) {
958
- return string.slice(1);
959
- }
960
- return string;
961
- }
962
- }
963
-
964
-
965
-
966
-
967
-
968
-
969
- function JsonToCsv(_input, _config)
970
- {
971
- // Default configuration
972
-
973
- /** whether to surround every datum with quotes */
974
- var _quotes = false;
975
-
976
- /** whether to write headers */
977
- var _writeHeader = true;
978
-
979
- /** delimiting character(s) */
980
- var _delimiter = ',';
981
-
982
- /** newline character(s) */
983
- var _newline = '\r\n';
984
-
985
- /** quote character */
986
- var _quoteChar = '"';
987
-
988
- /** escaped quote character, either "" or <config.escapeChar>" */
989
- var _escapedQuote = _quoteChar + _quoteChar;
990
-
991
- /** whether to skip empty lines */
992
- var _skipEmptyLines = false;
993
-
994
- /** the columns (keys) we expect when we unparse objects */
995
- var _columns = null;
996
-
997
- /** whether to prevent outputting cells that can be parsed as formulae by spreadsheet software (Excel and LibreOffice) */
998
- var _escapeFormulae = false;
999
-
1000
- unpackConfig();
1001
-
1002
- var quoteCharRegex = new RegExp(escapeRegExp(_quoteChar), 'g');
1003
-
1004
- if (typeof _input === 'string')
1005
- _input = JSON.parse(_input);
1006
-
1007
- if (Array.isArray(_input))
1008
- {
1009
- if (!_input.length || Array.isArray(_input[0]))
1010
- return serialize(null, _input, _skipEmptyLines);
1011
- else if (typeof _input[0] === 'object')
1012
- return serialize(_columns || Object.keys(_input[0]), _input, _skipEmptyLines);
1013
- }
1014
- else if (typeof _input === 'object')
1015
- {
1016
- if (typeof _input.data === 'string')
1017
- _input.data = JSON.parse(_input.data);
1018
-
1019
- if (Array.isArray(_input.data))
1020
- {
1021
- if (!_input.fields)
1022
- _input.fields = _input.meta && _input.meta.fields || _columns;
1023
-
1024
- if (!_input.fields)
1025
- _input.fields = Array.isArray(_input.data[0])
1026
- ? _input.fields
1027
- : typeof _input.data[0] === 'object'
1028
- ? Object.keys(_input.data[0])
1029
- : [];
1030
-
1031
- if (!(Array.isArray(_input.data[0])) && typeof _input.data[0] !== 'object')
1032
- _input.data = [_input.data]; // handles input like [1,2,3] or ['asdf']
1033
- }
1034
-
1035
- return serialize(_input.fields || [], _input.data || [], _skipEmptyLines);
1036
- }
1037
-
1038
- // Default (any valid paths should return before this)
1039
- throw new Error('Unable to serialize unrecognized input');
1040
-
1041
-
1042
- function unpackConfig()
1043
- {
1044
- if (typeof _config !== 'object')
1045
- return;
1046
-
1047
- if (typeof _config.delimiter === 'string'
1048
- && !Papa.BAD_DELIMITERS.filter(function(value) { return _config.delimiter.indexOf(value) !== -1; }).length)
1049
- {
1050
- _delimiter = _config.delimiter;
1051
- }
1052
-
1053
- if (typeof _config.quotes === 'boolean'
1054
- || typeof _config.quotes === 'function'
1055
- || Array.isArray(_config.quotes))
1056
- _quotes = _config.quotes;
1057
-
1058
- if (typeof _config.skipEmptyLines === 'boolean'
1059
- || typeof _config.skipEmptyLines === 'string')
1060
- _skipEmptyLines = _config.skipEmptyLines;
1061
-
1062
- if (typeof _config.newline === 'string')
1063
- _newline = _config.newline;
1064
-
1065
- if (typeof _config.quoteChar === 'string')
1066
- _quoteChar = _config.quoteChar;
1067
-
1068
- if (typeof _config.header === 'boolean')
1069
- _writeHeader = _config.header;
1070
-
1071
- if (Array.isArray(_config.columns)) {
1072
-
1073
- if (_config.columns.length === 0) throw new Error('Option columns is empty');
1074
-
1075
- _columns = _config.columns;
1076
- }
1077
-
1078
- if (_config.escapeChar !== undefined) {
1079
- _escapedQuote = _config.escapeChar + _quoteChar;
1080
- }
1081
-
1082
- if (typeof _config.escapeFormulae === 'boolean' || _config.escapeFormulae instanceof RegExp) {
1083
- _escapeFormulae = _config.escapeFormulae instanceof RegExp ? _config.escapeFormulae : /^[=+\-@\t\r].*$/;
1084
- }
1085
- }
1086
-
1087
- /** The double for loop that iterates the data and writes out a CSV string including header row */
1088
- function serialize(fields, data, skipEmptyLines)
1089
- {
1090
- var csv = '';
1091
-
1092
- if (typeof fields === 'string')
1093
- fields = JSON.parse(fields);
1094
- if (typeof data === 'string')
1095
- data = JSON.parse(data);
1096
-
1097
- var hasHeader = Array.isArray(fields) && fields.length > 0;
1098
- var dataKeyedByField = !(Array.isArray(data[0]));
1099
-
1100
- // If there a header row, write it first
1101
- if (hasHeader && _writeHeader)
1102
- {
1103
- for (var i = 0; i < fields.length; i++)
1104
- {
1105
- if (i > 0)
1106
- csv += _delimiter;
1107
- csv += safe(fields[i], i);
1108
- }
1109
- if (data.length > 0)
1110
- csv += _newline;
1111
- }
1112
-
1113
- // Then write out the data
1114
- for (var row = 0; row < data.length; row++)
1115
- {
1116
- var maxCol = hasHeader ? fields.length : data[row].length;
1117
-
1118
- var emptyLine = false;
1119
- var nullLine = hasHeader ? Object.keys(data[row]).length === 0 : data[row].length === 0;
1120
- if (skipEmptyLines && !hasHeader)
1121
- {
1122
- emptyLine = skipEmptyLines === 'greedy' ? data[row].join('').trim() === '' : data[row].length === 1 && data[row][0].length === 0;
1123
- }
1124
- if (skipEmptyLines === 'greedy' && hasHeader) {
1125
- var line = [];
1126
- for (var c = 0; c < maxCol; c++) {
1127
- var cx = dataKeyedByField ? fields[c] : c;
1128
- line.push(data[row][cx]);
1129
- }
1130
- emptyLine = line.join('').trim() === '';
1131
- }
1132
- if (!emptyLine)
1133
- {
1134
- for (var col = 0; col < maxCol; col++)
1135
- {
1136
- if (col > 0 && !nullLine)
1137
- csv += _delimiter;
1138
- var colIdx = hasHeader && dataKeyedByField ? fields[col] : col;
1139
- csv += safe(data[row][colIdx], col);
1140
- }
1141
- if (row < data.length - 1 && (!skipEmptyLines || (maxCol > 0 && !nullLine)))
1142
- {
1143
- csv += _newline;
1144
- }
1145
- }
1146
- }
1147
- return csv;
1148
- }
1149
-
1150
- /** Encloses a value around quotes if needed (makes a value safe for CSV insertion) */
1151
- function safe(str, col)
1152
- {
1153
- if (typeof str === 'undefined' || str === null)
1154
- return '';
1155
-
1156
- if (str.constructor === Date)
1157
- return JSON.stringify(str).slice(1, 25);
1158
-
1159
- var needsQuotes = false;
1160
-
1161
- if (_escapeFormulae && typeof str === "string" && _escapeFormulae.test(str)) {
1162
- str = "'" + str;
1163
- needsQuotes = true;
1164
- }
1165
-
1166
- var escapedQuoteStr = str.toString().replace(quoteCharRegex, _escapedQuote);
1167
-
1168
- needsQuotes = needsQuotes
1169
- || _quotes === true
1170
- || (typeof _quotes === 'function' && _quotes(str, col))
1171
- || (Array.isArray(_quotes) && _quotes[col])
1172
- || hasAny(escapedQuoteStr, Papa.BAD_DELIMITERS)
1173
- || escapedQuoteStr.indexOf(_delimiter) > -1
1174
- || escapedQuoteStr.charAt(0) === ' '
1175
- || escapedQuoteStr.charAt(escapedQuoteStr.length - 1) === ' ';
1176
-
1177
- return needsQuotes ? _quoteChar + escapedQuoteStr + _quoteChar : escapedQuoteStr;
1178
- }
1179
-
1180
- function hasAny(str, substrings)
1181
- {
1182
- for (var i = 0; i < substrings.length; i++)
1183
- if (str.indexOf(substrings[i]) > -1)
1184
- return true;
1185
- return false;
1186
- }
1187
- }
1188
-
1189
- /** ChunkStreamer is the base prototype for various streamer implementations. */
1190
- function ChunkStreamer(config)
1191
- {
1192
- this._handle = null;
1193
- this._finished = false;
1194
- this._completed = false;
1195
- this._halted = false;
1196
- this._input = null;
1197
- this._baseIndex = 0;
1198
- this._partialLine = '';
1199
- this._rowCount = 0;
1200
- this._start = 0;
1201
- this._nextChunk = null;
1202
- this.isFirstChunk = true;
1203
- this._completeResults = {
1204
- data: [],
1205
- errors: [],
1206
- meta: {}
1207
- };
1208
- replaceConfig.call(this, config);
1209
-
1210
- this.parseChunk = function(chunk, isFakeChunk)
1211
- {
1212
- // First chunk pre-processing
1213
- if (this.isFirstChunk && isFunction(this._config.beforeFirstChunk))
1214
- {
1215
- var modifiedChunk = this._config.beforeFirstChunk(chunk);
1216
- if (modifiedChunk !== undefined)
1217
- chunk = modifiedChunk;
1218
- }
1219
- this.isFirstChunk = false;
1220
- this._halted = false;
1221
-
1222
- // Rejoin the line we likely just split in two by chunking the file
1223
- var aggregate = this._partialLine + chunk;
1224
- this._partialLine = '';
1225
-
1226
- var results = this._handle.parse(aggregate, this._baseIndex, !this._finished);
1227
-
1228
- if (this._handle.paused() || this._handle.aborted()) {
1229
- this._halted = true;
1230
- return;
1231
- }
1232
-
1233
- var lastIndex = results.meta.cursor;
1234
-
1235
- if (!this._finished)
1236
- {
1237
- this._partialLine = aggregate.substring(lastIndex - this._baseIndex);
1238
- this._baseIndex = lastIndex;
1239
- }
1240
-
1241
- if (results && results.data)
1242
- this._rowCount += results.data.length;
1243
-
1244
- var finishedIncludingPreview = this._finished || (this._config.preview && this._rowCount >= this._config.preview);
1245
-
1246
- if (IS_PAPA_WORKER)
1247
- {
1248
- global.postMessage({
1249
- results: results,
1250
- workerId: Papa.WORKER_ID,
1251
- finished: finishedIncludingPreview
1252
- });
1253
- }
1254
- else if (isFunction(this._config.chunk) && !isFakeChunk)
1255
- {
1256
- this._config.chunk(results, this._handle);
1257
- if (this._handle.paused() || this._handle.aborted()) {
1258
- this._halted = true;
1259
- return;
1260
- }
1261
- results = undefined;
1262
- this._completeResults = undefined;
1263
- }
1264
-
1265
- if (!this._config.step && !this._config.chunk) {
1266
- this._completeResults.data = this._completeResults.data.concat(results.data);
1267
- this._completeResults.errors = this._completeResults.errors.concat(results.errors);
1268
- this._completeResults.meta = results.meta;
1269
- }
1270
-
1271
- if (!this._completed && finishedIncludingPreview && isFunction(this._config.complete) && (!results || !results.meta.aborted)) {
1272
- this._config.complete(this._completeResults, this._input);
1273
- this._completed = true;
1274
- }
1275
-
1276
- if (!finishedIncludingPreview && (!results || !results.meta.paused))
1277
- this._nextChunk();
1278
-
1279
- return results;
1280
- };
1281
-
1282
- this._sendError = function(error)
1283
- {
1284
- if (isFunction(this._config.error))
1285
- this._config.error(error);
1286
- else if (IS_PAPA_WORKER && this._config.error)
1287
- {
1288
- global.postMessage({
1289
- workerId: Papa.WORKER_ID,
1290
- error: error,
1291
- finished: false
1292
- });
1293
- }
1294
- };
1295
-
1296
- function replaceConfig(config)
1297
- {
1298
- // Deep-copy the config so we can edit it
1299
- var configCopy = copy(config);
1300
- configCopy.chunkSize = parseInt(configCopy.chunkSize); // parseInt VERY important so we don't concatenate strings!
1301
- if (!config.step && !config.chunk)
1302
- configCopy.chunkSize = null; // disable Range header if not streaming; bad values break IIS - see issue #196
1303
- this._handle = new ParserHandle(configCopy);
1304
- this._handle.streamer = this;
1305
- this._config = configCopy; // persist the copy to the caller
1306
- }
1307
- }
1308
-
1309
-
1310
- function NetworkStreamer(config)
1311
- {
1312
- config = config || {};
1313
- if (!config.chunkSize)
1314
- config.chunkSize = Papa.RemoteChunkSize;
1315
- ChunkStreamer.call(this, config);
1316
-
1317
- var xhr;
1318
-
1319
- if (IS_WORKER)
1320
- {
1321
- this._nextChunk = function()
1322
- {
1323
- this._readChunk();
1324
- this._chunkLoaded();
1325
- };
1326
- }
1327
- else
1328
- {
1329
- this._nextChunk = function()
1330
- {
1331
- this._readChunk();
1332
- };
1333
- }
1334
-
1335
- this.stream = function(url)
1336
- {
1337
- this._input = url;
1338
- this._nextChunk(); // Starts streaming
1339
- };
1340
-
1341
- this._readChunk = function()
1342
- {
1343
- if (this._finished)
1344
- {
1345
- this._chunkLoaded();
1346
- return;
1347
- }
1348
-
1349
- xhr = new XMLHttpRequest();
1350
-
1351
- if (this._config.withCredentials)
1352
- {
1353
- xhr.withCredentials = this._config.withCredentials;
1354
- }
1355
-
1356
- if (!IS_WORKER)
1357
- {
1358
- xhr.onload = bindFunction(this._chunkLoaded, this);
1359
- xhr.onerror = bindFunction(this._chunkError, this);
1360
- }
1361
-
1362
- xhr.open(this._config.downloadRequestBody ? 'POST' : 'GET', this._input, !IS_WORKER);
1363
- // Headers can only be set when once the request state is OPENED
1364
- if (this._config.downloadRequestHeaders)
1365
- {
1366
- var headers = this._config.downloadRequestHeaders;
1367
-
1368
- for (var headerName in headers)
1369
- {
1370
- xhr.setRequestHeader(headerName, headers[headerName]);
1371
- }
1372
- }
1373
-
1374
- if (this._config.chunkSize)
1375
- {
1376
- var end = this._start + this._config.chunkSize - 1; // minus one because byte range is inclusive
1377
- xhr.setRequestHeader('Range', 'bytes=' + this._start + '-' + end);
1378
- }
1379
-
1380
- try {
1381
- xhr.send(this._config.downloadRequestBody);
1382
- }
1383
- catch (err) {
1384
- this._chunkError(err.message);
1385
- }
1386
-
1387
- if (IS_WORKER && xhr.status === 0)
1388
- this._chunkError();
1389
- };
1390
-
1391
- this._chunkLoaded = function()
1392
- {
1393
- if (xhr.readyState !== 4)
1394
- return;
1395
-
1396
- if (xhr.status < 200 || xhr.status >= 400)
1397
- {
1398
- this._chunkError();
1399
- return;
1400
- }
1401
-
1402
- // Use chunckSize as it may be a diference on reponse lentgh due to characters with more than 1 byte
1403
- this._start += this._config.chunkSize ? this._config.chunkSize : xhr.responseText.length;
1404
- this._finished = !this._config.chunkSize || this._start >= getFileSize(xhr);
1405
- this.parseChunk(xhr.responseText);
1406
- };
1407
-
1408
- this._chunkError = function(errorMessage)
1409
- {
1410
- var errorText = xhr.statusText || errorMessage;
1411
- this._sendError(new Error(errorText));
1412
- };
1413
-
1414
- function getFileSize(xhr)
1415
- {
1416
- var contentRange = xhr.getResponseHeader('Content-Range');
1417
- if (contentRange === null) { // no content range, then finish!
1418
- return -1;
1419
- }
1420
- return parseInt(contentRange.substring(contentRange.lastIndexOf('/') + 1));
1421
- }
1422
- }
1423
- NetworkStreamer.prototype = Object.create(ChunkStreamer.prototype);
1424
- NetworkStreamer.prototype.constructor = NetworkStreamer;
1425
-
1426
-
1427
- function FileStreamer(config)
1428
- {
1429
- config = config || {};
1430
- if (!config.chunkSize)
1431
- config.chunkSize = Papa.LocalChunkSize;
1432
- ChunkStreamer.call(this, config);
1433
-
1434
- var reader, slice;
1435
-
1436
- // FileReader is better than FileReaderSync (even in worker) - see http://stackoverflow.com/q/24708649/1048862
1437
- // But Firefox is a pill, too - see issue #76: https://github.com/mholt/PapaParse/issues/76
1438
- var usingAsyncReader = typeof FileReader !== 'undefined'; // Safari doesn't consider it a function - see issue #105
1439
-
1440
- this.stream = function(file)
1441
- {
1442
- this._input = file;
1443
- slice = file.slice || file.webkitSlice || file.mozSlice;
1444
-
1445
- if (usingAsyncReader)
1446
- {
1447
- reader = new FileReader(); // Preferred method of reading files, even in workers
1448
- reader.onload = bindFunction(this._chunkLoaded, this);
1449
- reader.onerror = bindFunction(this._chunkError, this);
1450
- }
1451
- else
1452
- reader = new FileReaderSync(); // Hack for running in a web worker in Firefox
1453
-
1454
- this._nextChunk(); // Starts streaming
1455
- };
1456
-
1457
- this._nextChunk = function()
1458
- {
1459
- if (!this._finished && (!this._config.preview || this._rowCount < this._config.preview))
1460
- this._readChunk();
1461
- };
1462
-
1463
- this._readChunk = function()
1464
- {
1465
- var input = this._input;
1466
- if (this._config.chunkSize)
1467
- {
1468
- var end = Math.min(this._start + this._config.chunkSize, this._input.size);
1469
- input = slice.call(input, this._start, end);
1470
- }
1471
- var txt = reader.readAsText(input, this._config.encoding);
1472
- if (!usingAsyncReader)
1473
- this._chunkLoaded({ target: { result: txt } }); // mimic the async signature
1474
- };
1475
-
1476
- this._chunkLoaded = function(event)
1477
- {
1478
- // Very important to increment start each time before handling results
1479
- this._start += this._config.chunkSize;
1480
- this._finished = !this._config.chunkSize || this._start >= this._input.size;
1481
- this.parseChunk(event.target.result);
1482
- };
1483
-
1484
- this._chunkError = function()
1485
- {
1486
- this._sendError(reader.error);
1487
- };
1488
-
1489
- }
1490
- FileStreamer.prototype = Object.create(ChunkStreamer.prototype);
1491
- FileStreamer.prototype.constructor = FileStreamer;
1492
-
1493
-
1494
- function StringStreamer(config)
1495
- {
1496
- config = config || {};
1497
- ChunkStreamer.call(this, config);
1498
-
1499
- var remaining;
1500
- this.stream = function(s)
1501
- {
1502
- remaining = s;
1503
- return this._nextChunk();
1504
- };
1505
- this._nextChunk = function()
1506
- {
1507
- if (this._finished) return;
1508
- var size = this._config.chunkSize;
1509
- var chunk;
1510
- if(size) {
1511
- chunk = remaining.substring(0, size);
1512
- remaining = remaining.substring(size);
1513
- } else {
1514
- chunk = remaining;
1515
- remaining = '';
1516
- }
1517
- this._finished = !remaining;
1518
- return this.parseChunk(chunk);
1519
- };
1520
- }
1521
- StringStreamer.prototype = Object.create(StringStreamer.prototype);
1522
- StringStreamer.prototype.constructor = StringStreamer;
1523
-
1524
-
1525
- function ReadableStreamStreamer(config)
1526
- {
1527
- config = config || {};
1528
-
1529
- ChunkStreamer.call(this, config);
1530
-
1531
- var queue = [];
1532
- var parseOnData = true;
1533
- var streamHasEnded = false;
1534
-
1535
- this.pause = function()
1536
- {
1537
- ChunkStreamer.prototype.pause.apply(this, arguments);
1538
- this._input.pause();
1539
- };
1540
-
1541
- this.resume = function()
1542
- {
1543
- ChunkStreamer.prototype.resume.apply(this, arguments);
1544
- this._input.resume();
1545
- };
1546
-
1547
- this.stream = function(stream)
1548
- {
1549
- this._input = stream;
1550
-
1551
- this._input.on('data', this._streamData);
1552
- this._input.on('end', this._streamEnd);
1553
- this._input.on('error', this._streamError);
1554
- };
1555
-
1556
- this._checkIsFinished = function()
1557
- {
1558
- if (streamHasEnded && queue.length === 1) {
1559
- this._finished = true;
1560
- }
1561
- };
1562
-
1563
- this._nextChunk = function()
1564
- {
1565
- this._checkIsFinished();
1566
- if (queue.length)
1567
- {
1568
- this.parseChunk(queue.shift());
1569
- }
1570
- else
1571
- {
1572
- parseOnData = true;
1573
- }
1574
- };
1575
-
1576
- this._streamData = bindFunction(function(chunk)
1577
- {
1578
- try
1579
- {
1580
- queue.push(typeof chunk === 'string' ? chunk : chunk.toString(this._config.encoding));
1581
-
1582
- if (parseOnData)
1583
- {
1584
- parseOnData = false;
1585
- this._checkIsFinished();
1586
- this.parseChunk(queue.shift());
1587
- }
1588
- }
1589
- catch (error)
1590
- {
1591
- this._streamError(error);
1592
- }
1593
- }, this);
1594
-
1595
- this._streamError = bindFunction(function(error)
1596
- {
1597
- this._streamCleanUp();
1598
- this._sendError(error);
1599
- }, this);
1600
-
1601
- this._streamEnd = bindFunction(function()
1602
- {
1603
- this._streamCleanUp();
1604
- streamHasEnded = true;
1605
- this._streamData('');
1606
- }, this);
1607
-
1608
- this._streamCleanUp = bindFunction(function()
1609
- {
1610
- this._input.removeListener('data', this._streamData);
1611
- this._input.removeListener('end', this._streamEnd);
1612
- this._input.removeListener('error', this._streamError);
1613
- }, this);
1614
- }
1615
- ReadableStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
1616
- ReadableStreamStreamer.prototype.constructor = ReadableStreamStreamer;
1617
-
1618
-
1619
- function DuplexStreamStreamer(_config) {
1620
- var Duplex = require$$0__default["default"].Duplex;
1621
- var config = copy(_config);
1622
- var parseOnWrite = true;
1623
- var writeStreamHasFinished = false;
1624
- var parseCallbackQueue = [];
1625
- var stream = null;
1626
-
1627
- this._onCsvData = function(results)
1628
- {
1629
- var data = results.data;
1630
- if (!stream.push(data) && !this._handle.paused()) {
1631
- // the writeable consumer buffer has filled up
1632
- // so we need to pause until more items
1633
- // can be processed
1634
- this._handle.pause();
1635
- }
1636
- };
1637
-
1638
- this._onCsvComplete = function()
1639
- {
1640
- // node will finish the read stream when
1641
- // null is pushed
1642
- stream.push(null);
1643
- };
1644
-
1645
- config.step = bindFunction(this._onCsvData, this);
1646
- config.complete = bindFunction(this._onCsvComplete, this);
1647
- ChunkStreamer.call(this, config);
1648
-
1649
- this._nextChunk = function()
1650
- {
1651
- if (writeStreamHasFinished && parseCallbackQueue.length === 1) {
1652
- this._finished = true;
1653
- }
1654
- if (parseCallbackQueue.length) {
1655
- parseCallbackQueue.shift()();
1656
- } else {
1657
- parseOnWrite = true;
1658
- }
1659
- };
1660
-
1661
- this._addToParseQueue = function(chunk, callback)
1662
- {
1663
- // add to queue so that we can indicate
1664
- // completion via callback
1665
- // node will automatically pause the incoming stream
1666
- // when too many items have been added without their
1667
- // callback being invoked
1668
- parseCallbackQueue.push(bindFunction(function() {
1669
- this.parseChunk(typeof chunk === 'string' ? chunk : chunk.toString(config.encoding));
1670
- if (isFunction(callback)) {
1671
- return callback();
1672
- }
1673
- }, this));
1674
- if (parseOnWrite) {
1675
- parseOnWrite = false;
1676
- this._nextChunk();
1677
- }
1678
- };
1679
-
1680
- this._onRead = function()
1681
- {
1682
- if (this._handle.paused()) {
1683
- // the writeable consumer can handle more data
1684
- // so resume the chunk parsing
1685
- this._handle.resume();
1686
- }
1687
- };
1688
-
1689
- this._onWrite = function(chunk, encoding, callback)
1690
- {
1691
- this._addToParseQueue(chunk, callback);
1692
- };
1693
-
1694
- this._onWriteComplete = function()
1695
- {
1696
- writeStreamHasFinished = true;
1697
- // have to write empty string
1698
- // so parser knows its done
1699
- this._addToParseQueue('');
1700
- };
1701
-
1702
- this.getStream = function()
1703
- {
1704
- return stream;
1705
- };
1706
- stream = new Duplex({
1707
- readableObjectMode: true,
1708
- decodeStrings: false,
1709
- read: bindFunction(this._onRead, this),
1710
- write: bindFunction(this._onWrite, this)
1711
- });
1712
- stream.once('finish', bindFunction(this._onWriteComplete, this));
1713
- }
1714
- if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
1715
- DuplexStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
1716
- DuplexStreamStreamer.prototype.constructor = DuplexStreamStreamer;
1717
- }
1718
-
1719
-
1720
- // Use one ParserHandle per entire CSV file or string
1721
- function ParserHandle(_config)
1722
- {
1723
- // One goal is to minimize the use of regular expressions...
1724
- var MAX_FLOAT = Math.pow(2, 53);
1725
- var MIN_FLOAT = -MAX_FLOAT;
1726
- var FLOAT = /^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/;
1727
- var ISO_DATE = /^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/;
1728
- var self = this;
1729
- var _stepCounter = 0; // Number of times step was called (number of rows parsed)
1730
- var _rowCounter = 0; // Number of rows that have been parsed so far
1731
- var _input; // The input being parsed
1732
- var _parser; // The core parser being used
1733
- var _paused = false; // Whether we are paused or not
1734
- var _aborted = false; // Whether the parser has aborted or not
1735
- var _delimiterError; // Temporary state between delimiter detection and processing results
1736
- var _fields = []; // Fields are from the header row of the input, if there is one
1737
- var _results = { // The last results returned from the parser
1738
- data: [],
1739
- errors: [],
1740
- meta: {}
1741
- };
1742
-
1743
- if (isFunction(_config.step))
1744
- {
1745
- var userStep = _config.step;
1746
- _config.step = function(results)
1747
- {
1748
- _results = results;
1749
-
1750
- if (needsHeaderRow())
1751
- processResults();
1752
- else // only call user's step function after header row
1753
- {
1754
- processResults();
1755
-
1756
- // It's possbile that this line was empty and there's no row here after all
1757
- if (_results.data.length === 0)
1758
- return;
1759
-
1760
- _stepCounter += results.data.length;
1761
- if (_config.preview && _stepCounter > _config.preview)
1762
- _parser.abort();
1763
- else {
1764
- _results.data = _results.data[0];
1765
- userStep(_results, self);
1766
- }
1767
- }
1768
- };
1769
- }
1770
-
1771
- /**
1772
- * Parses input. Most users won't need, and shouldn't mess with, the baseIndex
1773
- * and ignoreLastRow parameters. They are used by streamers (wrapper functions)
1774
- * when an input comes in multiple chunks, like from a file.
1775
- */
1776
- this.parse = function(input, baseIndex, ignoreLastRow)
1777
- {
1778
- var quoteChar = _config.quoteChar || '"';
1779
- if (!_config.newline)
1780
- _config.newline = guessLineEndings(input, quoteChar);
1781
-
1782
- _delimiterError = false;
1783
- if (!_config.delimiter)
1784
- {
1785
- var delimGuess = guessDelimiter(input, _config.newline, _config.skipEmptyLines, _config.comments, _config.delimitersToGuess);
1786
- if (delimGuess.successful)
1787
- _config.delimiter = delimGuess.bestDelimiter;
1788
- else
1789
- {
1790
- _delimiterError = true; // add error after parsing (otherwise it would be overwritten)
1791
- _config.delimiter = Papa.DefaultDelimiter;
1792
- }
1793
- _results.meta.delimiter = _config.delimiter;
1794
- }
1795
- else if(isFunction(_config.delimiter))
1796
- {
1797
- _config.delimiter = _config.delimiter(input);
1798
- _results.meta.delimiter = _config.delimiter;
1799
- }
1800
-
1801
- var parserConfig = copy(_config);
1802
- if (_config.preview && _config.header)
1803
- parserConfig.preview++; // to compensate for header row
1804
-
1805
- _input = input;
1806
- _parser = new Parser(parserConfig);
1807
- _results = _parser.parse(_input, baseIndex, ignoreLastRow);
1808
- processResults();
1809
- return _paused ? { meta: { paused: true } } : (_results || { meta: { paused: false } });
1810
- };
1811
-
1812
- this.paused = function()
1813
- {
1814
- return _paused;
1815
- };
1816
-
1817
- this.pause = function()
1818
- {
1819
- _paused = true;
1820
- _parser.abort();
1821
-
1822
- // If it is streaming via "chunking", the reader will start appending correctly already so no need to substring,
1823
- // otherwise we can get duplicate content within a row
1824
- _input = isFunction(_config.chunk) ? "" : _input.substring(_parser.getCharIndex());
1825
- };
1826
-
1827
- this.resume = function()
1828
- {
1829
- if(self.streamer._halted) {
1830
- _paused = false;
1831
- self.streamer.parseChunk(_input, true);
1832
- } else {
1833
- // Bugfix: #636 In case the processing hasn't halted yet
1834
- // wait for it to halt in order to resume
1835
- setTimeout(self.resume, 3);
1836
- }
1837
- };
1838
-
1839
- this.aborted = function()
1840
- {
1841
- return _aborted;
1842
- };
1843
-
1844
- this.abort = function()
1845
- {
1846
- _aborted = true;
1847
- _parser.abort();
1848
- _results.meta.aborted = true;
1849
- if (isFunction(_config.complete))
1850
- _config.complete(_results);
1851
- _input = '';
1852
- };
1853
-
1854
- function testEmptyLine(s) {
1855
- return _config.skipEmptyLines === 'greedy' ? s.join('').trim() === '' : s.length === 1 && s[0].length === 0;
1856
- }
1857
-
1858
- function testFloat(s) {
1859
- if (FLOAT.test(s)) {
1860
- var floatValue = parseFloat(s);
1861
- if (floatValue > MIN_FLOAT && floatValue < MAX_FLOAT) {
1862
- return true;
1863
- }
1864
- }
1865
- return false;
1866
- }
1867
-
1868
- function processResults()
1869
- {
1870
- if (_results && _delimiterError)
1871
- {
1872
- addError('Delimiter', 'UndetectableDelimiter', 'Unable to auto-detect delimiting character; defaulted to \'' + Papa.DefaultDelimiter + '\'');
1873
- _delimiterError = false;
1874
- }
1875
-
1876
- if (_config.skipEmptyLines)
1877
- {
1878
- _results.data = _results.data.filter(function(d) {
1879
- return !testEmptyLine(d);
1880
- });
1881
- }
1882
-
1883
- if (needsHeaderRow())
1884
- fillHeaderFields();
1885
-
1886
- return applyHeaderAndDynamicTypingAndTransformation();
1887
- }
1888
-
1889
- function needsHeaderRow()
1890
- {
1891
- return _config.header && _fields.length === 0;
1892
- }
1893
-
1894
- function fillHeaderFields()
1895
- {
1896
- if (!_results)
1897
- return;
1898
-
1899
- function addHeader(header, i)
1900
- {
1901
- if (isFunction(_config.transformHeader))
1902
- header = _config.transformHeader(header, i);
1903
-
1904
- _fields.push(header);
1905
- }
1906
-
1907
- if (Array.isArray(_results.data[0]))
1908
- {
1909
- for (var i = 0; needsHeaderRow() && i < _results.data.length; i++)
1910
- _results.data[i].forEach(addHeader);
1911
-
1912
- _results.data.splice(0, 1);
1913
- }
1914
- // if _results.data[0] is not an array, we are in a step where _results.data is the row.
1915
- else
1916
- _results.data.forEach(addHeader);
1917
- }
1918
-
1919
- function shouldApplyDynamicTyping(field) {
1920
- // Cache function values to avoid calling it for each row
1921
- if (_config.dynamicTypingFunction && _config.dynamicTyping[field] === undefined) {
1922
- _config.dynamicTyping[field] = _config.dynamicTypingFunction(field);
1923
- }
1924
- return (_config.dynamicTyping[field] || _config.dynamicTyping) === true;
1925
- }
1926
-
1927
- function parseDynamic(field, value)
1928
- {
1929
- if (shouldApplyDynamicTyping(field))
1930
- {
1931
- if (value === 'true' || value === 'TRUE')
1932
- return true;
1933
- else if (value === 'false' || value === 'FALSE')
1934
- return false;
1935
- else if (testFloat(value))
1936
- return parseFloat(value);
1937
- else if (ISO_DATE.test(value))
1938
- return new Date(value);
1939
- else
1940
- return (value === '' ? null : value);
1941
- }
1942
- return value;
1943
- }
1944
-
1945
- function applyHeaderAndDynamicTypingAndTransformation()
1946
- {
1947
- if (!_results || (!_config.header && !_config.dynamicTyping && !_config.transform))
1948
- return _results;
1949
-
1950
- function processRow(rowSource, i)
1951
- {
1952
- var row = _config.header ? {} : [];
1953
-
1954
- var j;
1955
- for (j = 0; j < rowSource.length; j++)
1956
- {
1957
- var field = j;
1958
- var value = rowSource[j];
1959
-
1960
- if (_config.header)
1961
- field = j >= _fields.length ? '__parsed_extra' : _fields[j];
1962
-
1963
- if (_config.transform)
1964
- value = _config.transform(value,field);
1965
-
1966
- value = parseDynamic(field, value);
1967
-
1968
- if (field === '__parsed_extra')
1969
- {
1970
- row[field] = row[field] || [];
1971
- row[field].push(value);
1972
- }
1973
- else
1974
- row[field] = value;
1975
- }
1976
-
1977
-
1978
- if (_config.header)
1979
- {
1980
- if (j > _fields.length)
1981
- addError('FieldMismatch', 'TooManyFields', 'Too many fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);
1982
- else if (j < _fields.length)
1983
- addError('FieldMismatch', 'TooFewFields', 'Too few fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);
1984
- }
1985
-
1986
- return row;
1987
- }
1988
-
1989
- var incrementBy = 1;
1990
- if (!_results.data.length || Array.isArray(_results.data[0]))
1991
- {
1992
- _results.data = _results.data.map(processRow);
1993
- incrementBy = _results.data.length;
1994
- }
1995
- else
1996
- _results.data = processRow(_results.data, 0);
1997
-
1998
-
1999
- if (_config.header && _results.meta)
2000
- _results.meta.fields = _fields;
2001
-
2002
- _rowCounter += incrementBy;
2003
- return _results;
2004
- }
2005
-
2006
- function guessDelimiter(input, newline, skipEmptyLines, comments, delimitersToGuess) {
2007
- var bestDelim, bestDelta, fieldCountPrevRow, maxFieldCount;
2008
-
2009
- delimitersToGuess = delimitersToGuess || [',', '\t', '|', ';', Papa.RECORD_SEP, Papa.UNIT_SEP];
2010
-
2011
- for (var i = 0; i < delimitersToGuess.length; i++) {
2012
- var delim = delimitersToGuess[i];
2013
- var delta = 0, avgFieldCount = 0, emptyLinesCount = 0;
2014
- fieldCountPrevRow = undefined;
2015
-
2016
- var preview = new Parser({
2017
- comments: comments,
2018
- delimiter: delim,
2019
- newline: newline,
2020
- preview: 10
2021
- }).parse(input);
2022
-
2023
- for (var j = 0; j < preview.data.length; j++) {
2024
- if (skipEmptyLines && testEmptyLine(preview.data[j])) {
2025
- emptyLinesCount++;
2026
- continue;
2027
- }
2028
- var fieldCount = preview.data[j].length;
2029
- avgFieldCount += fieldCount;
2030
-
2031
- if (typeof fieldCountPrevRow === 'undefined') {
2032
- fieldCountPrevRow = fieldCount;
2033
- continue;
2034
- }
2035
- else if (fieldCount > 0) {
2036
- delta += Math.abs(fieldCount - fieldCountPrevRow);
2037
- fieldCountPrevRow = fieldCount;
2038
- }
2039
- }
2040
-
2041
- if (preview.data.length > 0)
2042
- avgFieldCount /= (preview.data.length - emptyLinesCount);
2043
-
2044
- if ((typeof bestDelta === 'undefined' || delta <= bestDelta)
2045
- && (typeof maxFieldCount === 'undefined' || avgFieldCount > maxFieldCount) && avgFieldCount > 1.99) {
2046
- bestDelta = delta;
2047
- bestDelim = delim;
2048
- maxFieldCount = avgFieldCount;
2049
- }
2050
- }
2051
-
2052
- _config.delimiter = bestDelim;
2053
-
2054
- return {
2055
- successful: !!bestDelim,
2056
- bestDelimiter: bestDelim
2057
- };
2058
- }
2059
-
2060
- function guessLineEndings(input, quoteChar)
2061
- {
2062
- input = input.substring(0, 1024 * 1024); // max length 1 MB
2063
- // Replace all the text inside quotes
2064
- var re = new RegExp(escapeRegExp(quoteChar) + '([^]*?)' + escapeRegExp(quoteChar), 'gm');
2065
- input = input.replace(re, '');
2066
-
2067
- var r = input.split('\r');
2068
-
2069
- var n = input.split('\n');
2070
-
2071
- var nAppearsFirst = (n.length > 1 && n[0].length < r[0].length);
2072
-
2073
- if (r.length === 1 || nAppearsFirst)
2074
- return '\n';
2075
-
2076
- var numWithN = 0;
2077
- for (var i = 0; i < r.length; i++)
2078
- {
2079
- if (r[i][0] === '\n')
2080
- numWithN++;
2081
- }
2082
-
2083
- return numWithN >= r.length / 2 ? '\r\n' : '\r';
2084
- }
2085
-
2086
- function addError(type, code, msg, row)
2087
- {
2088
- var error = {
2089
- type: type,
2090
- code: code,
2091
- message: msg
2092
- };
2093
- if(row !== undefined) {
2094
- error.row = row;
2095
- }
2096
- _results.errors.push(error);
2097
- }
2098
- }
2099
-
2100
- /** https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions */
2101
- function escapeRegExp(string)
2102
- {
2103
- return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
2104
- }
2105
-
2106
- /** The core parser implements speedy and correct CSV parsing */
2107
- function Parser(config)
2108
- {
2109
- // Unpack the config object
2110
- config = config || {};
2111
- var delim = config.delimiter;
2112
- var newline = config.newline;
2113
- var comments = config.comments;
2114
- var step = config.step;
2115
- var preview = config.preview;
2116
- var fastMode = config.fastMode;
2117
- var quoteChar;
2118
- if (config.quoteChar === undefined || config.quoteChar === null) {
2119
- quoteChar = '"';
2120
- } else {
2121
- quoteChar = config.quoteChar;
2122
- }
2123
- var escapeChar = quoteChar;
2124
- if (config.escapeChar !== undefined) {
2125
- escapeChar = config.escapeChar;
2126
- }
2127
-
2128
- // Delimiter must be valid
2129
- if (typeof delim !== 'string'
2130
- || Papa.BAD_DELIMITERS.indexOf(delim) > -1)
2131
- delim = ',';
2132
-
2133
- // Comment character must be valid
2134
- if (comments === delim)
2135
- throw new Error('Comment character same as delimiter');
2136
- else if (comments === true)
2137
- comments = '#';
2138
- else if (typeof comments !== 'string'
2139
- || Papa.BAD_DELIMITERS.indexOf(comments) > -1)
2140
- comments = false;
2141
-
2142
- // Newline must be valid: \r, \n, or \r\n
2143
- if (newline !== '\n' && newline !== '\r' && newline !== '\r\n')
2144
- newline = '\n';
2145
-
2146
- // We're gonna need these at the Parser scope
2147
- var cursor = 0;
2148
- var aborted = false;
2149
-
2150
- this.parse = function(input, baseIndex, ignoreLastRow)
2151
- {
2152
- // For some reason, in Chrome, this speeds things up (!?)
2153
- if (typeof input !== 'string')
2154
- throw new Error('Input must be a string');
2155
-
2156
- // We don't need to compute some of these every time parse() is called,
2157
- // but having them in a more local scope seems to perform better
2158
- var inputLen = input.length,
2159
- delimLen = delim.length,
2160
- newlineLen = newline.length,
2161
- commentsLen = comments.length;
2162
- var stepIsFunction = isFunction(step);
2163
-
2164
- // Establish starting state
2165
- cursor = 0;
2166
- var data = [], errors = [], row = [], lastCursor = 0;
2167
-
2168
- if (!input)
2169
- return returnable();
2170
-
2171
- // Rename headers if there are duplicates
2172
- if (config.header)
2173
- {
2174
- var firstLine = input.split(newline)[0];
2175
- var headers = firstLine.split(delim);
2176
- var separator = '_';
2177
- var headerMap = [];
2178
- var headerCount = {};
2179
- var duplicateHeaders = false;
2180
-
2181
- for (var j in headers) {
2182
- var header = headers[j];
2183
- if (isFunction(config.transformHeader))
2184
- header = config.transformHeader(header, j);
2185
- var headerName = header;
2186
-
2187
- var count = headerCount[header] || 0;
2188
- if (count > 0) {
2189
- duplicateHeaders = true;
2190
- headerName = header + separator + count;
2191
- }
2192
- headerCount[header] = count + 1;
2193
-
2194
- headerMap.push(headerName);
2195
- }
2196
- if (duplicateHeaders) {
2197
- var editedInput = input.split(newline);
2198
- editedInput[0] = headerMap.join(delim);
2199
- input = editedInput.join(newline);
2200
- }
2201
- }
2202
- if (fastMode || (fastMode !== false && input.indexOf(quoteChar) === -1))
2203
- {
2204
- var rows = input.split(newline);
2205
- for (var i = 0; i < rows.length; i++)
2206
- {
2207
- row = rows[i];
2208
- cursor += row.length;
2209
- if (i !== rows.length - 1)
2210
- cursor += newline.length;
2211
- else if (ignoreLastRow)
2212
- return returnable();
2213
- if (comments && row.substring(0, commentsLen) === comments)
2214
- continue;
2215
- if (stepIsFunction)
2216
- {
2217
- data = [];
2218
- pushRow(row.split(delim));
2219
- doStep();
2220
- if (aborted)
2221
- return returnable();
2222
- }
2223
- else
2224
- pushRow(row.split(delim));
2225
- if (preview && i >= preview)
2226
- {
2227
- data = data.slice(0, preview);
2228
- return returnable(true);
2229
- }
2230
- }
2231
- return returnable();
2232
- }
2233
-
2234
- var nextDelim = input.indexOf(delim, cursor);
2235
- var nextNewline = input.indexOf(newline, cursor);
2236
- var quoteCharRegex = new RegExp(escapeRegExp(escapeChar) + escapeRegExp(quoteChar), 'g');
2237
- var quoteSearch = input.indexOf(quoteChar, cursor);
2238
-
2239
- // Parser loop
2240
- for (;;)
2241
- {
2242
- // Field has opening quote
2243
- if (input[cursor] === quoteChar)
2244
- {
2245
- // Start our search for the closing quote where the cursor is
2246
- quoteSearch = cursor;
2247
-
2248
- // Skip the opening quote
2249
- cursor++;
2250
-
2251
- for (;;)
2252
- {
2253
- // Find closing quote
2254
- quoteSearch = input.indexOf(quoteChar, quoteSearch + 1);
2255
-
2256
- //No other quotes are found - no other delimiters
2257
- if (quoteSearch === -1)
2258
- {
2259
- if (!ignoreLastRow) {
2260
- // No closing quote... what a pity
2261
- errors.push({
2262
- type: 'Quotes',
2263
- code: 'MissingQuotes',
2264
- message: 'Quoted field unterminated',
2265
- row: data.length, // row has yet to be inserted
2266
- index: cursor
2267
- });
2268
- }
2269
- return finish();
2270
- }
2271
-
2272
- // Closing quote at EOF
2273
- if (quoteSearch === inputLen - 1)
2274
- {
2275
- var value = input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar);
2276
- return finish(value);
2277
- }
2278
-
2279
- // If this quote is escaped, it's part of the data; skip it
2280
- // If the quote character is the escape character, then check if the next character is the escape character
2281
- if (quoteChar === escapeChar && input[quoteSearch + 1] === escapeChar)
2282
- {
2283
- quoteSearch++;
2284
- continue;
2285
- }
2286
-
2287
- // If the quote character is not the escape character, then check if the previous character was the escape character
2288
- if (quoteChar !== escapeChar && quoteSearch !== 0 && input[quoteSearch - 1] === escapeChar)
2289
- {
2290
- continue;
2291
- }
2292
-
2293
- if(nextDelim !== -1 && nextDelim < (quoteSearch + 1)) {
2294
- nextDelim = input.indexOf(delim, (quoteSearch + 1));
2295
- }
2296
- if(nextNewline !== -1 && nextNewline < (quoteSearch + 1)) {
2297
- nextNewline = input.indexOf(newline, (quoteSearch + 1));
2298
- }
2299
- // Check up to nextDelim or nextNewline, whichever is closest
2300
- var checkUpTo = nextNewline === -1 ? nextDelim : Math.min(nextDelim, nextNewline);
2301
- var spacesBetweenQuoteAndDelimiter = extraSpaces(checkUpTo);
2302
-
2303
- // Closing quote followed by delimiter or 'unnecessary spaces + delimiter'
2304
- if (input.substr(quoteSearch + 1 + spacesBetweenQuoteAndDelimiter, delimLen) === delim)
2305
- {
2306
- row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
2307
- cursor = quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen;
2308
-
2309
- // If char after following delimiter is not quoteChar, we find next quote char position
2310
- if (input[quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen] !== quoteChar)
2311
- {
2312
- quoteSearch = input.indexOf(quoteChar, cursor);
2313
- }
2314
- nextDelim = input.indexOf(delim, cursor);
2315
- nextNewline = input.indexOf(newline, cursor);
2316
- break;
2317
- }
2318
-
2319
- var spacesBetweenQuoteAndNewLine = extraSpaces(nextNewline);
2320
-
2321
- // Closing quote followed by newline or 'unnecessary spaces + newLine'
2322
- if (input.substring(quoteSearch + 1 + spacesBetweenQuoteAndNewLine, quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen) === newline)
2323
- {
2324
- row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
2325
- saveRow(quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen);
2326
- nextDelim = input.indexOf(delim, cursor); // because we may have skipped the nextDelim in the quoted field
2327
- quoteSearch = input.indexOf(quoteChar, cursor); // we search for first quote in next line
2328
-
2329
- if (stepIsFunction)
2330
- {
2331
- doStep();
2332
- if (aborted)
2333
- return returnable();
2334
- }
2335
-
2336
- if (preview && data.length >= preview)
2337
- return returnable(true);
2338
-
2339
- break;
2340
- }
2341
-
2342
-
2343
- // Checks for valid closing quotes are complete (escaped quotes or quote followed by EOF/delimiter/newline) -- assume these quotes are part of an invalid text string
2344
- errors.push({
2345
- type: 'Quotes',
2346
- code: 'InvalidQuotes',
2347
- message: 'Trailing quote on quoted field is malformed',
2348
- row: data.length, // row has yet to be inserted
2349
- index: cursor
2350
- });
2351
-
2352
- quoteSearch++;
2353
- continue;
2354
-
2355
- }
2356
-
2357
- continue;
2358
- }
2359
-
2360
- // Comment found at start of new line
2361
- if (comments && row.length === 0 && input.substring(cursor, cursor + commentsLen) === comments)
2362
- {
2363
- if (nextNewline === -1) // Comment ends at EOF
2364
- return returnable();
2365
- cursor = nextNewline + newlineLen;
2366
- nextNewline = input.indexOf(newline, cursor);
2367
- nextDelim = input.indexOf(delim, cursor);
2368
- continue;
2369
- }
2370
-
2371
- // Next delimiter comes before next newline, so we've reached end of field
2372
- if (nextDelim !== -1 && (nextDelim < nextNewline || nextNewline === -1))
2373
- {
2374
- row.push(input.substring(cursor, nextDelim));
2375
- cursor = nextDelim + delimLen;
2376
- // we look for next delimiter char
2377
- nextDelim = input.indexOf(delim, cursor);
2378
- continue;
2379
- }
2380
-
2381
- // End of row
2382
- if (nextNewline !== -1)
2383
- {
2384
- row.push(input.substring(cursor, nextNewline));
2385
- saveRow(nextNewline + newlineLen);
2386
-
2387
- if (stepIsFunction)
2388
- {
2389
- doStep();
2390
- if (aborted)
2391
- return returnable();
2392
- }
2393
-
2394
- if (preview && data.length >= preview)
2395
- return returnable(true);
2396
-
2397
- continue;
2398
- }
2399
-
2400
- break;
2401
- }
2402
-
2403
-
2404
- return finish();
2405
-
2406
-
2407
- function pushRow(row)
2408
- {
2409
- data.push(row);
2410
- lastCursor = cursor;
2411
- }
2412
-
2413
- /**
2414
- * checks if there are extra spaces after closing quote and given index without any text
2415
- * if Yes, returns the number of spaces
2416
- */
2417
- function extraSpaces(index) {
2418
- var spaceLength = 0;
2419
- if (index !== -1) {
2420
- var textBetweenClosingQuoteAndIndex = input.substring(quoteSearch + 1, index);
2421
- if (textBetweenClosingQuoteAndIndex && textBetweenClosingQuoteAndIndex.trim() === '') {
2422
- spaceLength = textBetweenClosingQuoteAndIndex.length;
2423
- }
2424
- }
2425
- return spaceLength;
2426
- }
2427
-
2428
- /**
2429
- * Appends the remaining input from cursor to the end into
2430
- * row, saves the row, calls step, and returns the results.
2431
- */
2432
- function finish(value)
2433
- {
2434
- if (ignoreLastRow)
2435
- return returnable();
2436
- if (typeof value === 'undefined')
2437
- value = input.substring(cursor);
2438
- row.push(value);
2439
- cursor = inputLen; // important in case parsing is paused
2440
- pushRow(row);
2441
- if (stepIsFunction)
2442
- doStep();
2443
- return returnable();
2444
- }
2445
-
2446
- /**
2447
- * Appends the current row to the results. It sets the cursor
2448
- * to newCursor and finds the nextNewline. The caller should
2449
- * take care to execute user's step function and check for
2450
- * preview and end parsing if necessary.
2451
- */
2452
- function saveRow(newCursor)
2453
- {
2454
- cursor = newCursor;
2455
- pushRow(row);
2456
- row = [];
2457
- nextNewline = input.indexOf(newline, cursor);
2458
- }
2459
-
2460
- /** Returns an object with the results, errors, and meta. */
2461
- function returnable(stopped)
2462
- {
2463
- return {
2464
- data: data,
2465
- errors: errors,
2466
- meta: {
2467
- delimiter: delim,
2468
- linebreak: newline,
2469
- aborted: aborted,
2470
- truncated: !!stopped,
2471
- cursor: lastCursor + (baseIndex || 0)
2472
- }
2473
- };
2474
- }
2475
-
2476
- /** Executes the user's step function and resets data & errors. */
2477
- function doStep()
2478
- {
2479
- step(returnable());
2480
- data = [];
2481
- errors = [];
2482
- }
2483
- };
2484
-
2485
- /** Sets the abort flag */
2486
- this.abort = function()
2487
- {
2488
- aborted = true;
2489
- };
2490
-
2491
- /** Gets the cursor position */
2492
- this.getCharIndex = function()
2493
- {
2494
- return cursor;
2495
- };
2496
- }
2497
-
2498
-
2499
- function newWorker()
2500
- {
2501
- if (!Papa.WORKERS_SUPPORTED)
2502
- return false;
2503
-
2504
- var workerUrl = getWorkerBlob();
2505
- var w = new global.Worker(workerUrl);
2506
- w.onmessage = mainThreadReceivedMessage;
2507
- w.id = workerIdCounter++;
2508
- workers[w.id] = w;
2509
- return w;
2510
- }
2511
-
2512
- /** Callback when main thread receives a message */
2513
- function mainThreadReceivedMessage(e)
2514
- {
2515
- var msg = e.data;
2516
- var worker = workers[msg.workerId];
2517
- var aborted = false;
2518
-
2519
- if (msg.error)
2520
- worker.userError(msg.error, msg.file);
2521
- else if (msg.results && msg.results.data)
2522
- {
2523
- var abort = function() {
2524
- aborted = true;
2525
- completeWorker(msg.workerId, { data: [], errors: [], meta: { aborted: true } });
2526
- };
2527
-
2528
- var handle = {
2529
- abort: abort,
2530
- pause: notImplemented,
2531
- resume: notImplemented
2532
- };
2533
-
2534
- if (isFunction(worker.userStep))
2535
- {
2536
- for (var i = 0; i < msg.results.data.length; i++)
2537
- {
2538
- worker.userStep({
2539
- data: msg.results.data[i],
2540
- errors: msg.results.errors,
2541
- meta: msg.results.meta
2542
- }, handle);
2543
- if (aborted)
2544
- break;
2545
- }
2546
- delete msg.results; // free memory ASAP
2547
- }
2548
- else if (isFunction(worker.userChunk))
2549
- {
2550
- worker.userChunk(msg.results, handle, msg.file);
2551
- delete msg.results;
2552
- }
2553
- }
2554
-
2555
- if (msg.finished && !aborted)
2556
- completeWorker(msg.workerId, msg.results);
2557
- }
2558
-
2559
- function completeWorker(workerId, results) {
2560
- var worker = workers[workerId];
2561
- if (isFunction(worker.userComplete))
2562
- worker.userComplete(results);
2563
- worker.terminate();
2564
- delete workers[workerId];
2565
- }
2566
-
2567
- function notImplemented() {
2568
- throw new Error('Not implemented.');
2569
- }
2570
-
2571
- /** Callback when worker thread receives a message */
2572
- function workerThreadReceivedMessage(e)
2573
- {
2574
- var msg = e.data;
2575
-
2576
- if (typeof Papa.WORKER_ID === 'undefined' && msg)
2577
- Papa.WORKER_ID = msg.workerId;
2578
-
2579
- if (typeof msg.input === 'string')
2580
- {
2581
- global.postMessage({
2582
- workerId: Papa.WORKER_ID,
2583
- results: Papa.parse(msg.input, msg.config),
2584
- finished: true
2585
- });
2586
- }
2587
- else if ((global.File && msg.input instanceof File) || msg.input instanceof Object) // thank you, Safari (see issue #106)
2588
- {
2589
- var results = Papa.parse(msg.input, msg.config);
2590
- if (results)
2591
- global.postMessage({
2592
- workerId: Papa.WORKER_ID,
2593
- results: results,
2594
- finished: true
2595
- });
2596
- }
2597
- }
2598
-
2599
- /** Makes a deep copy of an array or object (mostly) */
2600
- function copy(obj)
2601
- {
2602
- if (typeof obj !== 'object' || obj === null)
2603
- return obj;
2604
- var cpy = Array.isArray(obj) ? [] : {};
2605
- for (var key in obj)
2606
- cpy[key] = copy(obj[key]);
2607
- return cpy;
2608
- }
2609
-
2610
- function bindFunction(f, self)
2611
- {
2612
- return function() { f.apply(self, arguments); };
2613
- }
2614
-
2615
- function isFunction(func)
2616
- {
2617
- return typeof func === 'function';
2618
- }
2619
-
2620
- return Papa;
2621
- }));
2622
- } (papaparse));
2623
-
2624
- var Papa = papaparse.exports;
2625
-
2626
- var isValidEmail = function isValidEmail(email) {
2627
- return yup.string().email().isValidSync(email);
2628
- };
2629
- var isPastDate = function isPastDate(date) {
2630
- return dayjs__default["default"](date).isBefore(dayjs__default["default"]().subtract(1, "days"));
2631
- };
2632
- var createEmailOptions = function createEmailOptions() {
2633
- var emails = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2634
- return emails.map(function (email) {
2635
- return {
2636
- label: email,
2637
- value: email,
2638
- valid: isValidEmail(email)
2639
- };
2640
- });
2641
- };
2642
- var parseCsvEmails = function parseCsvEmails(file) {
2643
- return new Promise(function (resolve) {
2644
- Papa.parse(file, {
2645
- header: true,
2646
- skipEmptyLines: true,
2647
- transformHeader: function transformHeader(h) {
2648
- return h.toLowerCase().replace(/\W/g, "");
2649
- },
2650
- complete: function complete(results) {
2651
- var emails = results.data.map(function (item) {
2652
- return item.email.trim();
2653
- });
2654
- resolve(createEmailOptions(emails));
2655
- }
2656
- });
2657
- });
2658
- };
2659
-
2660
- var Form = function Form(_ref) {
2661
- var children = _ref.children;
2662
- var _useFormikContext = formik.useFormikContext(),
2663
- values = _useFormikContext.values,
2664
- setFieldValue = _useFormikContext.setFieldValue,
2665
- initialValues = _useFormikContext.initialValues;
2666
- var editorRef = React.useRef();
2667
- var _useTranslation = reactI18next.useTranslation(),
2668
- t = _useTranslation.t;
2669
- var handleReset = function handleReset() {
2670
- editorRef.current.editor.commands.setContent(initialValues.emailBody);
2671
- };
2672
- var handleCSVFile = /*#__PURE__*/function () {
2673
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_ref2) {
2674
- var _ref4, file, values;
2675
- return regenerator.wrap(function _callee$(_context) {
2676
- while (1) switch (_context.prev = _context.next) {
2677
- case 0:
2678
- _ref4 = _slicedToArray(_ref2, 1), file = _ref4[0];
2679
- _context.next = 3;
2680
- return parseCsvEmails(file);
2681
- case 3:
2682
- values = _context.sent;
2683
- setFieldValue("notifyEmails", values);
2684
- case 5:
2685
- case "end":
2686
- return _context.stop();
2687
- }
2688
- }, _callee);
2689
- }));
2690
- return function handleCSVFile(_x) {
2691
- return _ref3.apply(this, arguments);
2692
- };
2693
- }();
2694
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
2695
- className: "space-y-4"
2696
- }, /*#__PURE__*/React__default["default"].createElement("div", {
2697
- className: "space-y-2"
2698
- }, /*#__PURE__*/React__default["default"].createElement("div", {
2699
- className: "flex items-center justify-between"
2700
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2701
- lineHeight: "normal",
2702
- style: "h4",
2703
- weight: "semibold"
2704
- }, t("neetoMolecules.shareViaEmail.sendTo")), /*#__PURE__*/React__default["default"].createElement(FilePicker, {
2705
- types: ALLOWED_FILE_PICKER_TYPES,
2706
- onChange: handleCSVFile
2707
- })), /*#__PURE__*/React__default["default"].createElement(formik$1.MultiEmailInput, {
2708
- filterInvalidEmails: true,
2709
- required: true,
2710
- label: "",
2711
- name: "notifyEmails"
2712
- })), /*#__PURE__*/React__default["default"].createElement("div", {
2713
- className: "grid grid-cols-2 gap-6"
2714
- }, /*#__PURE__*/React__default["default"].createElement(formik$1.Input, {
2715
- required: true,
2716
- label: t("neetoMolecules.shareViaEmail.sendFrom"),
2717
- name: "sendFromEmail"
2718
- }), /*#__PURE__*/React__default["default"].createElement(formik$1.Input, {
2719
- required: true,
2720
- label: t("neetoMolecules.shareViaEmail.replyTo"),
2721
- name: "replyToEmail"
2722
- })), /*#__PURE__*/React__default["default"].createElement(formik$1.Input, {
2723
- required: true,
2724
- className: "col-span-1",
2725
- label: t("neetoMolecules.shareViaEmail.subject"),
2726
- name: "emailSubject"
2727
- }), /*#__PURE__*/React__default["default"].createElement(EmailBody$1, {
2728
- id: "emailBody",
2729
- ref: editorRef
2730
- }), /*#__PURE__*/React__default["default"].createElement("div", {
2731
- ref: editorRef
2732
- }), /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement(neetoui.Label, {
2733
- className: "flex items-center gap-2"
2734
- }, /*#__PURE__*/React__default["default"].createElement(formik$1.Switch, {
2735
- "data-testid": "send-later-switch",
2736
- name: "isSendLaterEnabled"
2737
- }), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2738
- component: "span",
2739
- lineHeight: "normal",
2740
- style: "h4",
2741
- weight: "semibold"
2742
- }, t("neetoMolecules.shareViaEmail.sendLater")))), values.isSendLaterEnabled && /*#__PURE__*/React__default["default"].createElement(FormikDatePicker, {
2743
- autoFocus: true,
2744
- showTime: true,
2745
- "data-cy": "email-share-date-input",
2746
- "data-testid": "formik-date-picker",
2747
- disabledDate: isPastDate,
2748
- name: "sendEmailDatetime",
2749
- picker: "date",
2750
- size: "large",
2751
- type: "date"
2752
- })), children && /*#__PURE__*/React__default["default"].createElement("div", {
2753
- className: "py-4 mt-4 border-t neeto-ui-border-gray-300"
2754
- }, /*#__PURE__*/React__default["default"].createElement("h3", {
2755
- className: "mb-4"
2756
- }, t("neetoMolecules.shareViaEmail.additionalOptions")), children), /*#__PURE__*/React__default["default"].createElement("div", {
2757
- className: "mt-6"
2758
- }, /*#__PURE__*/React__default["default"].createElement(formik$1.ActionBlock, {
2759
- cancelButtonProps: {
2760
- label: t("neetoMolecules.shareViaEmail.reset"),
2761
- type: "reset",
2762
- onClick: handleReset
2763
- },
2764
- submitButtonProps: {
2765
- label: t("neetoMolecules.shareViaEmail.sendEmail")
2766
- }
2767
- })));
2768
- };
2769
-
2770
- var _excluded = ["backToUrl", "handleSubmit", "children"];
2771
- var ShareViaEmail = function ShareViaEmail(_ref) {
2772
- var backToUrl = _ref.backToUrl,
2773
- handleSubmit = _ref.handleSubmit,
2774
- children = _ref.children,
2775
- otherProps = _objectWithoutProperties(_ref, _excluded);
2776
- var _useTranslation = reactI18next.useTranslation(),
2777
- t = _useTranslation.t;
2778
- var sendToEmails = function sendToEmails(notifyEmails) {
2779
- return notifyEmails.map(function (email) {
2780
- return email === null || email === void 0 ? void 0 : email.value;
2781
- });
2782
- };
2783
- return /*#__PURE__*/React__default["default"].createElement("div", {
2784
- className: "neeto-ui-bg-gray-100 w-full flex flex-col flex-1"
2785
- }, /*#__PURE__*/React__default["default"].createElement("div", {
2786
- className: "mx-auto flex w-full max-w-7xl flex-col py-10"
2787
- }, /*#__PURE__*/React__default["default"].createElement(formik$1.Form, {
2788
- formProps: {
2789
- noValidate: true
2790
- },
2791
- formikProps: {
2792
- enableReinitialize: true,
2793
- validateOnMount: true,
2794
- initialValues: INITIAL_VALUES,
2795
- validationSchema: SEND_EMAIL_FORM_VALIDATION_SCHEMA,
2796
- onSubmit: handleSubmit
2797
- }
2798
- }, function (_ref2) {
2799
- var values = _ref2.values;
2800
- return /*#__PURE__*/React__default["default"].createElement("div", {
2801
- className: "grid grid-cols-12 gap-8"
2802
- }, /*#__PURE__*/React__default["default"].createElement("div", {
2803
- className: "col-span-5"
2804
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
2805
- className: "mb-4",
2806
- "data-testid": "back-to-url-button",
2807
- icon: neetoIcons.LeftArrow,
2808
- iconPosition: "left",
2809
- label: t("neetoMolecules.shareViaEmail.backToShare"),
2810
- size: "small",
2811
- style: "link",
2812
- to: backToUrl
2813
- }), /*#__PURE__*/React__default["default"].createElement("div", {
2814
- className: "mb-6"
2815
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2816
- className: "mb-0.5",
2817
- lineHeight: "normal",
2818
- style: "h2",
2819
- weight: "semibold"
2820
- }, t("neetoMolecules.shareViaEmail.title")), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2821
- className: "neeto-ui-text-gray-700",
2822
- lineHeight: "normal",
2823
- style: "body2"
2824
- }, t("neetoMolecules.shareViaEmail.description"))), /*#__PURE__*/React__default["default"].createElement(Form, null, children)), /*#__PURE__*/React__default["default"].createElement("div", {
2825
- className: "col-span-7"
2826
- }, /*#__PURE__*/React__default["default"].createElement("div", {
2827
- className: "sticky top-10"
2828
- }, /*#__PURE__*/React__default["default"].createElement(EmailPreview, _extends({
2829
- body: values.emailBody,
2830
- from: values.sendFromEmail,
2831
- subject: values.emailSubject,
2832
- to: sendToEmails(values.notifyEmails)
2833
- }, otherProps)))));
2834
- })));
2835
- };
2836
-
2837
- module.exports = ShareViaEmail;
7
+ */B.exports=function e(){var t="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t?t:{};function r(){var r=t.URL||t.webkitURL||null,n=e.toString();return s.BLOB_URL||(s.BLOB_URL=r.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",n,")();"],{type:"text/javascript"})))}var n=!t.document&&!!t.postMessage,i=t.IS_PAPA_WORKER||!1,a={},o=0,s={};if(s.parse=u,s.unparse=c,s.RECORD_SEP=String.fromCharCode(30),s.UNIT_SEP=String.fromCharCode(31),s.BYTE_ORDER_MARK="\ufeff",s.BAD_DELIMITERS=["\r","\n",'"',s.BYTE_ORDER_MARK],s.WORKERS_SUPPORTED=!n&&!!t.Worker,s.NODE_STREAM_INPUT=1,s.LocalChunkSize=10485760,s.RemoteChunkSize=5242880,s.DefaultDelimiter=",",s.Parser=_,s.ParserHandle=g,s.NetworkStreamer=f,s.FileStreamer=h,s.StringStreamer=p,s.ReadableStreamStreamer=m,"undefined"==typeof PAPA_BROWSER_CONTEXT&&(s.DuplexStreamStreamer=y),t.jQuery){var l=t.jQuery;l.fn.parse=function(e){var r=e.config||{},n=[];return this.each((function(e){if("INPUT"!==l(this).prop("tagName").toUpperCase()||"file"!==l(this).attr("type").toLowerCase()||!t.FileReader||!this.files||0===this.files.length)return!0;for(var i=0;i<this.files.length;i++)n.push({file:this.files[i],inputElem:this,instanceConfig:l.extend({},r)})})),i(),this;function i(){if(0!==n.length){var t=n[0];if(R(e.before)){var r=e.before(t.file,t.inputElem);if("object"==typeof r){if("abort"===r.action)return void a("AbortError",t.file,t.inputElem,r.reason);if("skip"===r.action)return void o();"object"==typeof r.config&&(t.instanceConfig=l.extend(t.instanceConfig,r.config))}else if("skip"===r)return void o()}var i=t.instanceConfig.complete;t.instanceConfig.complete=function(e){R(i)&&i(e,t.file,t.inputElem),o()},s.parse(t.file,t.instanceConfig)}else R(e.complete)&&e.complete()}function a(t,r,n,i){R(e.error)&&e.error({name:t},r,n,i)}function o(){n.splice(0,1),i()}}}function u(e,r){var n=(r=r||{}).dynamicTyping||!1;if(R(n)&&(r.dynamicTypingFunction=n,n={}),r.dynamicTyping=n,r.transform=!!R(r.transform)&&r.transform,r.worker&&s.WORKERS_SUPPORTED){var i=E();return i.userStep=r.step,i.userChunk=r.chunk,i.userComplete=r.complete,i.userError=r.error,r.step=R(r.step),r.chunk=R(r.chunk),r.complete=R(r.complete),r.error=R(r.error),delete r.worker,void i.postMessage({input:e,config:r,workerId:i.id})}var a=null;return e===s.NODE_STREAM_INPUT&&"undefined"==typeof PAPA_BROWSER_CONTEXT?(a=new y(r)).getStream():("string"==typeof e?(e=o(e),a=r.download?new f(r):new p(r)):!0===e.readable&&R(e.read)&&R(e.on)?a=new m(r):(t.File&&e instanceof File||e instanceof Object)&&(a=new h(r)),a.stream(e));function o(e){return 65279===e.charCodeAt(0)?e.slice(1):e}}function c(e,t){var r=!1,n=!0,i=",",a="\r\n",o='"',l=o+o,u=!1,c=null,d=!1;h();var f=new RegExp(b(o),"g");if("string"==typeof e&&(e=JSON.parse(e)),Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return p(null,e,u);if("object"==typeof e[0])return p(c||Object.keys(e[0]),e,u)}else if("object"==typeof e)return"string"==typeof e.data&&(e.data=JSON.parse(e.data)),Array.isArray(e.data)&&(e.fields||(e.fields=e.meta&&e.meta.fields||c),e.fields||(e.fields=Array.isArray(e.data[0])?e.fields:"object"==typeof e.data[0]?Object.keys(e.data[0]):[]),Array.isArray(e.data[0])||"object"==typeof e.data[0]||(e.data=[e.data])),p(e.fields||[],e.data||[],u);throw new Error("Unable to serialize unrecognized input");function h(){if("object"==typeof t){if("string"!=typeof t.delimiter||s.BAD_DELIMITERS.filter((function(e){return-1!==t.delimiter.indexOf(e)})).length||(i=t.delimiter),("boolean"==typeof t.quotes||"function"==typeof t.quotes||Array.isArray(t.quotes))&&(r=t.quotes),"boolean"!=typeof t.skipEmptyLines&&"string"!=typeof t.skipEmptyLines||(u=t.skipEmptyLines),"string"==typeof t.newline&&(a=t.newline),"string"==typeof t.quoteChar&&(o=t.quoteChar),"boolean"==typeof t.header&&(n=t.header),Array.isArray(t.columns)){if(0===t.columns.length)throw new Error("Option columns is empty");c=t.columns}void 0!==t.escapeChar&&(l=t.escapeChar+o),("boolean"==typeof t.escapeFormulae||t.escapeFormulae instanceof RegExp)&&(d=t.escapeFormulae instanceof RegExp?t.escapeFormulae:/^[=+\-@\t\r].*$/)}}function p(e,t,r){var o="";"string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t));var s=Array.isArray(e)&&e.length>0,l=!Array.isArray(t[0]);if(s&&n){for(var u=0;u<e.length;u++)u>0&&(o+=i),o+=m(e[u],u);t.length>0&&(o+=a)}for(var c=0;c<t.length;c++){var d=s?e.length:t[c].length,f=!1,h=s?0===Object.keys(t[c]).length:0===t[c].length;if(r&&!s&&(f="greedy"===r?""===t[c].join("").trim():1===t[c].length&&0===t[c][0].length),"greedy"===r&&s){for(var p=[],y=0;y<d;y++){var g=l?e[y]:y;p.push(t[c][g])}f=""===p.join("").trim()}if(!f){for(var v=0;v<d;v++){v>0&&!h&&(o+=i);var b=s&&l?e[v]:v;o+=m(t[c][b],v)}c<t.length-1&&(!r||d>0&&!h)&&(o+=a)}}return o}function m(e,t){if(null==e)return"";if(e.constructor===Date)return JSON.stringify(e).slice(1,25);var n=!1;d&&"string"==typeof e&&d.test(e)&&(e="'"+e,n=!0);var a=e.toString().replace(f,l);return(n=n||!0===r||"function"==typeof r&&r(e,t)||Array.isArray(r)&&r[t]||y(a,s.BAD_DELIMITERS)||a.indexOf(i)>-1||" "===a.charAt(0)||" "===a.charAt(a.length-1))?o+a+o:a}function y(e,t){for(var r=0;r<t.length;r++)if(e.indexOf(t[r])>-1)return!0;return!1}}function d(e){function r(e){var t=S(e);t.chunkSize=parseInt(t.chunkSize),e.step||e.chunk||(t.chunkSize=null),this._handle=new g(t),this._handle.streamer=this,this._config=t}this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},r.call(this,e),this.parseChunk=function(e,r){if(this.isFirstChunk&&R(this._config.beforeFirstChunk)){var n=this._config.beforeFirstChunk(e);void 0!==n&&(e=n)}this.isFirstChunk=!1,this._halted=!1;var a=this._partialLine+e;this._partialLine="";var o=this._handle.parse(a,this._baseIndex,!this._finished);if(!this._handle.paused()&&!this._handle.aborted()){var l=o.meta.cursor;this._finished||(this._partialLine=a.substring(l-this._baseIndex),this._baseIndex=l),o&&o.data&&(this._rowCount+=o.data.length);var u=this._finished||this._config.preview&&this._rowCount>=this._config.preview;if(i)t.postMessage({results:o,workerId:s.WORKER_ID,finished:u});else if(R(this._config.chunk)&&!r){if(this._config.chunk(o,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);o=void 0,this._completeResults=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(o.data),this._completeResults.errors=this._completeResults.errors.concat(o.errors),this._completeResults.meta=o.meta),this._completed||!u||!R(this._config.complete)||o&&o.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),u||o&&o.meta.paused||this._nextChunk(),o}this._halted=!0},this._sendError=function(e){R(this._config.error)?this._config.error(e):i&&this._config.error&&t.postMessage({workerId:s.WORKER_ID,error:e,finished:!1})}}function f(e){var t;function r(e){var t=e.getResponseHeader("Content-Range");return null===t?-1:parseInt(t.substring(t.lastIndexOf("/")+1))}(e=e||{}).chunkSize||(e.chunkSize=s.RemoteChunkSize),d.call(this,e),this._nextChunk=n?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(t=new XMLHttpRequest,this._config.withCredentials&&(t.withCredentials=this._config.withCredentials),n||(t.onload=C(this._chunkLoaded,this),t.onerror=C(this._chunkError,this)),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!n),this._config.downloadRequestHeaders){var e=this._config.downloadRequestHeaders;for(var r in e)t.setRequestHeader(r,e[r])}if(this._config.chunkSize){var i=this._start+this._config.chunkSize-1;t.setRequestHeader("Range","bytes="+this._start+"-"+i)}try{t.send(this._config.downloadRequestBody)}catch(e){this._chunkError(e.message)}n&&0===t.status&&this._chunkError()}},this._chunkLoaded=function(){4===t.readyState&&(t.status<200||t.status>=400?this._chunkError():(this._start+=this._config.chunkSize?this._config.chunkSize:t.responseText.length,this._finished=!this._config.chunkSize||this._start>=r(t),this.parseChunk(t.responseText)))},this._chunkError=function(e){var r=t.statusText||e;this._sendError(new Error(r))}}function h(e){var t,r;(e=e||{}).chunkSize||(e.chunkSize=s.LocalChunkSize),d.call(this,e);var n="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,r=e.slice||e.webkitSlice||e.mozSlice,n?((t=new FileReader).onload=C(this._chunkLoaded,this),t.onerror=C(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var e=this._input;if(this._config.chunkSize){var i=Math.min(this._start+this._config.chunkSize,this._input.size);e=r.call(e,this._start,i)}var a=t.readAsText(e,this._config.encoding);n||this._chunkLoaded({target:{result:a}})},this._chunkLoaded=function(e){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(t.error)}}function p(e){var t;e=e||{},d.call(this,e),this.stream=function(e){return t=e,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var e,r=this._config.chunkSize;return r?(e=t.substring(0,r),t=t.substring(r)):(e=t,t=""),this._finished=!t,this.parseChunk(e)}}}function m(e){e=e||{},d.call(this,e);var t=[],r=!0,n=!1;this.pause=function(){d.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){d.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){n&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):r=!0},this._streamData=C((function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),r&&(r=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(e){this._streamError(e)}}),this),this._streamError=C((function(e){this._streamCleanUp(),this._sendError(e)}),this),this._streamEnd=C((function(){this._streamCleanUp(),n=!0,this._streamData("")}),this),this._streamCleanUp=C((function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)}),this)}function y(e){var t=v.default.Duplex,r=S(e),n=!0,i=!1,a=[],o=null;this._onCsvData=function(e){var t=e.data;o.push(t)||this._handle.paused()||this._handle.pause()},this._onCsvComplete=function(){o.push(null)},r.step=C(this._onCsvData,this),r.complete=C(this._onCsvComplete,this),d.call(this,r),this._nextChunk=function(){i&&1===a.length&&(this._finished=!0),a.length?a.shift()():n=!0},this._addToParseQueue=function(e,t){a.push(C((function(){if(this.parseChunk("string"==typeof e?e:e.toString(r.encoding)),R(t))return t()}),this)),n&&(n=!1,this._nextChunk())},this._onRead=function(){this._handle.paused()&&this._handle.resume()},this._onWrite=function(e,t,r){this._addToParseQueue(e,r)},this._onWriteComplete=function(){i=!0,this._addToParseQueue("")},this.getStream=function(){return o},(o=new t({readableObjectMode:!0,decodeStrings:!1,read:C(this._onRead,this),write:C(this._onWrite,this)})).once("finish",C(this._onWriteComplete,this))}function g(e){var t,r,n,i=Math.pow(2,53),a=-i,o=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,l=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,u=this,c=0,d=0,f=!1,h=!1,p=[],m={data:[],errors:[],meta:{}};if(R(e.step)){var y=e.step;e.step=function(t){if(m=t,w())E();else{if(E(),0===m.data.length)return;c+=t.data.length,e.preview&&c>e.preview?r.abort():(m.data=m.data[0],y(m,u))}}}function g(t){return"greedy"===e.skipEmptyLines?""===t.join("").trim():1===t.length&&0===t[0].length}function v(e){if(o.test(e)){var t=parseFloat(e);if(t>a&&t<i)return!0}return!1}function E(){return m&&n&&(L("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+s.DefaultDelimiter+"'"),n=!1),e.skipEmptyLines&&(m.data=m.data.filter((function(e){return!g(e)}))),w()&&x(),C()}function w(){return e.header&&0===p.length}function x(){if(m)if(Array.isArray(m.data[0])){for(var t=0;w()&&t<m.data.length;t++)m.data[t].forEach(r);m.data.splice(0,1)}else m.data.forEach(r);function r(t,r){R(e.transformHeader)&&(t=e.transformHeader(t,r)),p.push(t)}}function k(t){return e.dynamicTypingFunction&&void 0===e.dynamicTyping[t]&&(e.dynamicTyping[t]=e.dynamicTypingFunction(t)),!0===(e.dynamicTyping[t]||e.dynamicTyping)}function O(e,t){return k(e)?"true"===t||"TRUE"===t||"false"!==t&&"FALSE"!==t&&(v(t)?parseFloat(t):l.test(t)?new Date(t):""===t?null:t):t}function C(){if(!m||!e.header&&!e.dynamicTyping&&!e.transform)return m;function t(t,r){var n,i=e.header?{}:[];for(n=0;n<t.length;n++){var a=n,o=t[n];e.header&&(a=n>=p.length?"__parsed_extra":p[n]),e.transform&&(o=e.transform(o,a)),o=O(a,o),"__parsed_extra"===a?(i[a]=i[a]||[],i[a].push(o)):i[a]=o}return e.header&&(n>p.length?L("FieldMismatch","TooManyFields","Too many fields: expected "+p.length+" fields but parsed "+n,d+r):n<p.length&&L("FieldMismatch","TooFewFields","Too few fields: expected "+p.length+" fields but parsed "+n,d+r)),i}var r=1;return!m.data.length||Array.isArray(m.data[0])?(m.data=m.data.map(t),r=m.data.length):m.data=t(m.data,0),e.header&&m.meta&&(m.meta.fields=p),d+=r,m}function j(t,r,n,i,a){var o,l,u,c;a=a||[",","\t","|",";",s.RECORD_SEP,s.UNIT_SEP];for(var d=0;d<a.length;d++){var f=a[d],h=0,p=0,m=0;u=void 0;for(var y=new _({comments:i,delimiter:f,newline:r,preview:10}).parse(t),v=0;v<y.data.length;v++)if(n&&g(y.data[v]))m++;else{var b=y.data[v].length;p+=b,void 0!==u?b>0&&(h+=Math.abs(b-u),u=b):u=b}y.data.length>0&&(p/=y.data.length-m),(void 0===l||h<=l)&&(void 0===c||p>c)&&p>1.99&&(l=h,o=f,c=p)}return e.delimiter=o,{successful:!!o,bestDelimiter:o}}function T(e,t){e=e.substring(0,1048576);var r=new RegExp(b(t)+"([^]*?)"+b(t),"gm"),n=(e=e.replace(r,"")).split("\r"),i=e.split("\n"),a=i.length>1&&i[0].length<n[0].length;if(1===n.length||a)return"\n";for(var o=0,s=0;s<n.length;s++)"\n"===n[s][0]&&o++;return o>=n.length/2?"\r\n":"\r"}function L(e,t,r,n){var i={type:e,code:t,message:r};void 0!==n&&(i.row=n),m.errors.push(i)}this.parse=function(i,a,o){var l=e.quoteChar||'"';if(e.newline||(e.newline=T(i,l)),n=!1,e.delimiter)R(e.delimiter)&&(e.delimiter=e.delimiter(i),m.meta.delimiter=e.delimiter);else{var u=j(i,e.newline,e.skipEmptyLines,e.comments,e.delimitersToGuess);u.successful?e.delimiter=u.bestDelimiter:(n=!0,e.delimiter=s.DefaultDelimiter),m.meta.delimiter=e.delimiter}var c=S(e);return e.preview&&e.header&&c.preview++,t=i,r=new _(c),m=r.parse(t,a,o),E(),f?{meta:{paused:!0}}:m||{meta:{paused:!1}}},this.paused=function(){return f},this.pause=function(){f=!0,r.abort(),t=R(e.chunk)?"":t.substring(r.getCharIndex())},this.resume=function(){u.streamer._halted?(f=!1,u.streamer.parseChunk(t,!0)):setTimeout(u.resume,3)},this.aborted=function(){return h},this.abort=function(){h=!0,r.abort(),m.meta.aborted=!0,R(e.complete)&&e.complete(m),t=""}}function b(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _(e){var t,r=(e=e||{}).delimiter,n=e.newline,i=e.comments,a=e.step,o=e.preview,l=e.fastMode,u=t=void 0===e.quoteChar||null===e.quoteChar?'"':e.quoteChar;if(void 0!==e.escapeChar&&(u=e.escapeChar),("string"!=typeof r||s.BAD_DELIMITERS.indexOf(r)>-1)&&(r=","),i===r)throw new Error("Comment character same as delimiter");!0===i?i="#":("string"!=typeof i||s.BAD_DELIMITERS.indexOf(i)>-1)&&(i=!1),"\n"!==n&&"\r"!==n&&"\r\n"!==n&&(n="\n");var c=0,d=!1;this.parse=function(s,f,h){if("string"!=typeof s)throw new Error("Input must be a string");var p=s.length,m=r.length,y=n.length,g=i.length,v=R(a);c=0;var _=[],E=[],w=[],x=0;if(!s)return G();if(e.header){var k=s.split(n)[0].split(r),O="_",S=[],C={},j=!1;for(var T in k){var L=k[T];R(e.transformHeader)&&(L=e.transformHeader(L,T));var N=L,M=C[L]||0;M>0&&(j=!0,N=L+O+M),C[L]=M+1,S.push(N)}if(j){var P=s.split(n);P[0]=S.join(r),s=P.join(n)}}if(l||!1!==l&&-1===s.indexOf(t)){for(var A=s.split(n),I=0;I<A.length;I++){if(w=A[I],c+=w.length,I!==A.length-1)c+=n.length;else if(h)return G();if(!i||w.substring(0,g)!==i){if(v){if(_=[],U(w.split(r)),Q(),d)return G()}else U(w.split(r));if(o&&I>=o)return _=_.slice(0,o),G(!0)}}return G()}for(var F=s.indexOf(r,c),D=s.indexOf(n,c),q=new RegExp(b(u)+b(t),"g"),V=s.indexOf(t,c);;)if(s[c]!==t)if(i&&0===w.length&&s.substring(c,c+g)===i){if(-1===D)return G();c=D+y,D=s.indexOf(n,c),F=s.indexOf(r,c)}else if(-1!==F&&(F<D||-1===D))w.push(s.substring(c,F)),c=F+m,F=s.indexOf(r,c);else{if(-1===D)break;if(w.push(s.substring(c,D)),K(D+y),v&&(Q(),d))return G();if(o&&_.length>=o)return G(!0)}else for(V=c,c++;;){if(-1===(V=s.indexOf(t,V+1)))return h||E.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:_.length,index:c}),W();if(V===p-1)return W(s.substring(c,V).replace(q,t));if(t!==u||s[V+1]!==u){if(t===u||0===V||s[V-1]!==u){-1!==F&&F<V+1&&(F=s.indexOf(r,V+1)),-1!==D&&D<V+1&&(D=s.indexOf(n,V+1));var B=H(-1===D?F:Math.min(F,D));if(s.substr(V+1+B,m)===r){w.push(s.substring(c,V).replace(q,t)),c=V+1+B+m,s[V+1+B+m]!==t&&(V=s.indexOf(t,c)),F=s.indexOf(r,c),D=s.indexOf(n,c);break}var z=H(D);if(s.substring(V+1+z,V+1+z+y)===n){if(w.push(s.substring(c,V).replace(q,t)),K(V+1+z+y),F=s.indexOf(r,c),V=s.indexOf(t,c),v&&(Q(),d))return G();if(o&&_.length>=o)return G(!0);break}E.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:_.length,index:c}),V++}}else V++}return W();function U(e){_.push(e),x=c}function H(e){var t=0;if(-1!==e){var r=s.substring(V+1,e);r&&""===r.trim()&&(t=r.length)}return t}function W(e){return h||(void 0===e&&(e=s.substring(c)),w.push(e),c=p,U(w),v&&Q()),G()}function K(e){c=e,U(w),w=[],D=s.indexOf(n,c)}function G(e){return{data:_,errors:E,meta:{delimiter:r,linebreak:n,aborted:d,truncated:!!e,cursor:x+(f||0)}}}function Q(){a(G()),_=[],E=[]}},this.abort=function(){d=!0},this.getCharIndex=function(){return c}}function E(){if(!s.WORKERS_SUPPORTED)return!1;var e=r(),n=new t.Worker(e);return n.onmessage=w,n.id=o++,a[n.id]=n,n}function w(e){var t=e.data,r=a[t.workerId],n=!1;if(t.error)r.userError(t.error,t.file);else if(t.results&&t.results.data){var i={abort:function(){n=!0,x(t.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:k,resume:k};if(R(r.userStep)){for(var o=0;o<t.results.data.length&&(r.userStep({data:t.results.data[o],errors:t.results.errors,meta:t.results.meta},i),!n);o++);delete t.results}else R(r.userChunk)&&(r.userChunk(t.results,i,t.file),delete t.results)}t.finished&&!n&&x(t.workerId,t.results)}function x(e,t){var r=a[e];R(r.userComplete)&&r.userComplete(t),r.terminate(),delete a[e]}function k(){throw new Error("Not implemented.")}function O(e){var r=e.data;if(void 0===s.WORKER_ID&&r&&(s.WORKER_ID=r.workerId),"string"==typeof r.input)t.postMessage({workerId:s.WORKER_ID,results:s.parse(r.input,r.config),finished:!0});else if(t.File&&r.input instanceof File||r.input instanceof Object){var n=s.parse(r.input,r.config);n&&t.postMessage({workerId:s.WORKER_ID,results:n,finished:!0})}}function S(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var r in e)t[r]=S(e[r]);return t}function C(e,t){return function(){e.apply(t,arguments)}}function R(e){return"function"==typeof e}return i&&(t.onmessage=O),f.prototype=Object.create(d.prototype),f.prototype.constructor=f,h.prototype=Object.create(d.prototype),h.prototype.constructor=h,p.prototype=Object.create(p.prototype),p.prototype.constructor=p,m.prototype=Object.create(d.prototype),m.prototype.constructor=m,"undefined"==typeof PAPA_BROWSER_CONTEXT&&(y.prototype=Object.create(d.prototype),y.prototype.constructor=y),s}();var z=B.exports;function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function H(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?U(Object(r),!0).forEach((function(t){V(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var W=function(e){return l.string().email().isValidSync(e)},K=function(e){return g.default(e).isBefore(g.default().subtract(1,"days"))},G=function(e){return new Promise((function(t){z.parse(e,{header:!0,skipEmptyLines:!0,transformHeader:function(e){return e.toLowerCase().replace(/\W/g,"")},complete:function(e){var r=e.data.map((function(e){return e.email.trim()}));t(function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map((function(e){return{label:e,value:e,valid:W(e)}}))}(r))}})}))},Q=function(e){return H(H({},x),e)},$=function(t){var i=t.children,o=u.useFormikContext(),s=o.values,l=o.setFieldValue,c=o.initialValues,d=e.useRef(),f=a.useTranslation().t,h=function(){var e,t=(e=N.mark((function e(t){var r,n,i;return N.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=C(t,1),n=r[0],e.next=3,G(n);case 3:i=e.sent,l("notifyEmails",i);case 5:case"end":return e.stop()}}),e)})),function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function o(e){R(a,n,i,o,s,"next",e)}function s(e){R(a,n,i,o,s,"throw",e)}o(void 0)}))});return function(e){return t.apply(this,arguments)}}();return p.default.createElement(p.default.Fragment,null,p.default.createElement("div",{className:"space-y-4"},p.default.createElement("div",{className:"space-y-2"},p.default.createElement("div",{className:"flex items-center justify-between"},p.default.createElement(r.Typography,{lineHeight:"normal",style:"h4",weight:"semibold"},f("neetoMolecules.shareViaEmail.sendTo")),p.default.createElement(A,{types:O,onChange:h})),p.default.createElement(n.MultiEmailInput,{filterInvalidEmails:!0,required:!0,label:"",name:"notifyEmails"})),p.default.createElement("div",{className:"grid grid-cols-2 gap-6"},p.default.createElement(n.Input,{required:!0,label:f("neetoMolecules.shareViaEmail.sendFrom"),name:"sendFromEmail"}),p.default.createElement(n.Input,{required:!0,label:f("neetoMolecules.shareViaEmail.replyTo"),name:"replyToEmail"})),p.default.createElement(n.Input,{required:!0,className:"col-span-1",label:f("neetoMolecules.shareViaEmail.subject"),name:"emailSubject"}),p.default.createElement(P,{id:"emailBody",ref:d}),p.default.createElement("div",{ref:d}),p.default.createElement("div",null,p.default.createElement(r.Label,{className:"flex items-center gap-2"},p.default.createElement(n.Switch,{"data-testid":"send-later-switch",name:"isSendLaterEnabled"}),p.default.createElement(r.Typography,{component:"span",lineHeight:"normal",style:"h4",weight:"semibold"},f("neetoMolecules.shareViaEmail.sendLater")))),s.isSendLaterEnabled&&p.default.createElement(F,{autoFocus:!0,showTime:!0,"data-cy":"email-share-date-input","data-testid":"formik-date-picker",disabledDate:K,name:"sendEmailDatetime",picker:"date",size:"large",type:"date"})),i&&p.default.createElement("div",{className:"py-4 mt-4 border-t neeto-ui-border-gray-300"},p.default.createElement("h3",{className:"mb-4"},f("neetoMolecules.shareViaEmail.additionalOptions")),i),p.default.createElement("div",{className:"mt-6"},p.default.createElement(n.ActionBlock,{cancelButtonProps:{label:f("neetoMolecules.shareViaEmail.reset"),type:"reset",onClick:function(){d.current.editor.commands.setContent(c.emailBody)}},submitButtonProps:{label:f("neetoMolecules.shareViaEmail.sendEmail")}})))},J=["backToUrl","handleSubmit","children","description","defaultValues"];module.exports=function(e){var i=e.backToUrl,o=e.handleSubmit,s=e.children,l=e.description,u=e.defaultValues,c=_(e,J),d=a.useTranslation().t;return p.default.createElement("div",{className:"neeto-ui-bg-gray-100 w-full flex flex-col flex-1"},p.default.createElement("div",{className:"mx-auto flex w-full max-w-7xl flex-col py-10"},p.default.createElement(n.Form,{formProps:{noValidate:!0},formikProps:{enableReinitialize:!0,validateOnMount:!0,initialValues:Q(u),validationSchema:w,onSubmit:o}},(function(e){var n,a=e.values;return p.default.createElement("div",{className:"grid grid-cols-12 gap-8"},p.default.createElement("div",{className:"col-span-5"},i&&p.default.createElement(r.Button,{className:"mb-4","data-testid":"back-to-url-button",icon:t.LeftArrow,iconPosition:"left",label:d("neetoMolecules.shareViaEmail.backToShare"),size:"small",style:"link",to:i}),p.default.createElement("div",{className:"mb-6"},p.default.createElement(r.Typography,{className:"mb-0.5",lineHeight:"normal",style:"h2",weight:"semibold"},d("neetoMolecules.shareViaEmail.title")),l&&p.default.createElement(r.Typography,{className:"neeto-ui-text-gray-700",lineHeight:"normal",style:"body2"},l)),p.default.createElement($,null,s)),p.default.createElement("div",{className:"col-span-7"},p.default.createElement("div",{className:"sticky top-10"},p.default.createElement(E,b({body:a.emailBody,from:a.sendFromEmail,subject:a.emailSubject,to:(n=a.notifyEmails,n.map((function(e){return null==e?void 0:e.value})))},c)))))}))))};