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