@bigbinary/neeto-molecules 0.0.1

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