@bigbinary/neeto-molecules 3.15.43 → 3.15.45

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 (426) hide show
  1. package/dist/AuditLogs.js +539 -0
  2. package/dist/AuditLogs.js.map +1 -0
  3. package/dist/BoardView.js +394 -0
  4. package/dist/BoardView.js.map +1 -0
  5. package/dist/Breadcrumbs.js +46 -0
  6. package/dist/Breadcrumbs.js.map +1 -0
  7. package/dist/BrowserPreview.js +50 -0
  8. package/dist/BrowserPreview.js.map +1 -0
  9. package/dist/BrowserSupport.js +348 -0
  10. package/dist/BrowserSupport.js.map +1 -0
  11. package/dist/Builder.js +786 -0
  12. package/dist/Builder.js.map +1 -0
  13. package/dist/ButtonGroup.js +36 -0
  14. package/dist/ButtonGroup.js.map +1 -0
  15. package/dist/CalendarView.js +356 -0
  16. package/dist/CalendarView.js.map +1 -0
  17. package/dist/CardLayout.js +49 -0
  18. package/dist/CardLayout.js.map +1 -0
  19. package/dist/Chevron-DfSoxXBs.js +246 -0
  20. package/dist/Chevron-DfSoxXBs.js.map +1 -0
  21. package/dist/Codeblock.js +58 -0
  22. package/dist/Codeblock.js.map +1 -0
  23. package/dist/Columns.js +21 -0
  24. package/dist/Columns.js.map +1 -0
  25. package/dist/ConfigurePageSidebar.js +97 -0
  26. package/dist/ConfigurePageSidebar.js.map +1 -0
  27. package/dist/ConfirmationModal.js +110 -0
  28. package/dist/ConfirmationModal.js.map +1 -0
  29. package/dist/Container.js +38 -0
  30. package/dist/Container.js.map +1 -0
  31. package/dist/CopyToClipboardButton.js +82 -0
  32. package/dist/CopyToClipboardButton.js.map +1 -0
  33. package/dist/Currency.js +917 -0
  34. package/dist/Currency.js.map +1 -0
  35. package/dist/DateFormat.js +45 -0
  36. package/dist/DateFormat.js.map +1 -0
  37. package/dist/DateRangeFilter.js +178 -0
  38. package/dist/DateRangeFilter.js.map +1 -0
  39. package/dist/DeleteArchiveModal.js +98 -0
  40. package/dist/DeleteArchiveModal.js.map +1 -0
  41. package/dist/DeviceIncompatibilityMessage.js +95 -0
  42. package/dist/DeviceIncompatibilityMessage.js.map +1 -0
  43. package/dist/DocumentEditor.js +183 -0
  44. package/dist/DocumentEditor.js.map +1 -0
  45. package/dist/DownloadMobileAppCallout.js +40 -0
  46. package/dist/DownloadMobileAppCallout.js.map +1 -0
  47. package/dist/DynamicVariables.js +115 -0
  48. package/dist/DynamicVariables.js.map +1 -0
  49. package/dist/EmailForm.js +567 -0
  50. package/dist/EmailForm.js.map +1 -0
  51. package/dist/EmailPreview.js +140 -0
  52. package/dist/EmailPreview.js.map +1 -0
  53. package/dist/EmojiPicker.js +112 -0
  54. package/dist/EmojiPicker.js.map +1 -0
  55. package/dist/EmojiReactions.js +82 -0
  56. package/dist/EmojiReactions.js.map +1 -0
  57. package/dist/Engagements.js +292 -0
  58. package/dist/Engagements.js.map +1 -0
  59. package/dist/ErrorPage.js +1811 -0
  60. package/dist/ErrorPage.js.map +1 -0
  61. package/dist/FileUpload.js +595 -0
  62. package/dist/FileUpload.js.map +1 -0
  63. package/dist/FinderModal.js +280 -0
  64. package/dist/FinderModal.js.map +1 -0
  65. package/dist/FloatingActionMenu.js +854 -0
  66. package/dist/FloatingActionMenu.js.map +1 -0
  67. package/dist/GoogleFontPicker.js +581 -0
  68. package/dist/GoogleFontPicker.js.map +1 -0
  69. package/dist/Header.js +126 -0
  70. package/dist/Header.js.map +1 -0
  71. package/dist/HelpPopover.js +83 -0
  72. package/dist/HelpPopover.js.map +1 -0
  73. package/dist/IconPicker.js +1159 -0
  74. package/dist/IconPicker.js.map +1 -0
  75. package/dist/ImageWithFallback.js +49 -0
  76. package/dist/ImageWithFallback.js.map +1 -0
  77. package/dist/InlineInput.js +230 -0
  78. package/dist/InlineInput.js.map +1 -0
  79. package/dist/Insights.js +358 -0
  80. package/dist/Insights.js.map +1 -0
  81. package/dist/IntegrationCard.js +227 -0
  82. package/dist/IntegrationCard.js.map +1 -0
  83. package/dist/IpRestriction.js +3617 -0
  84. package/dist/IpRestriction.js.map +1 -0
  85. package/dist/KeyboardShortcuts.js +284 -0
  86. package/dist/KeyboardShortcuts.js.map +1 -0
  87. package/dist/LoginPage.js +184 -0
  88. package/dist/LoginPage.js.map +1 -0
  89. package/dist/MadeWith.js +41 -0
  90. package/dist/MadeWith.js.map +1 -0
  91. package/dist/MenuBar.js +1326 -0
  92. package/dist/MenuBar.js.map +1 -0
  93. package/dist/Metadata.js +218 -0
  94. package/dist/Metadata.js.map +1 -0
  95. package/dist/MobilePreviewHeader.js +25 -0
  96. package/dist/MobilePreviewHeader.js.map +1 -0
  97. package/dist/MoreDropdown.js +163 -0
  98. package/dist/MoreDropdown.js.map +1 -0
  99. package/dist/NavigationHeader.js +264 -0
  100. package/dist/NavigationHeader.js.map +1 -0
  101. package/dist/NeetoWidget.js +2867 -0
  102. package/dist/NeetoWidget.js.map +1 -0
  103. package/dist/Onboarding.js +246 -0
  104. package/dist/Onboarding.js.map +1 -0
  105. package/dist/OptionFields.js +717 -0
  106. package/dist/OptionFields.js.map +1 -0
  107. package/dist/PageLoader.js +40 -0
  108. package/dist/PageLoader.js.map +1 -0
  109. package/dist/PhoneNumber.js +75 -0
  110. package/dist/PhoneNumber.js.map +1 -0
  111. package/dist/ProductEmbed.js +884 -0
  112. package/dist/ProductEmbed.js.map +1 -0
  113. package/dist/PublishBlock.js +447 -0
  114. package/dist/PublishBlock.js.map +1 -0
  115. package/dist/PublishYourItem.js +58 -0
  116. package/dist/PublishYourItem.js.map +1 -0
  117. package/dist/Rename.js +366 -0
  118. package/dist/Rename.js.map +1 -0
  119. package/dist/ResponsiveDevicePicker.js +63 -0
  120. package/dist/ResponsiveDevicePicker.js.map +1 -0
  121. package/dist/Schedule.js +926 -0
  122. package/dist/Schedule.js.map +1 -0
  123. package/dist/Scrollable.js +42 -0
  124. package/dist/Scrollable.js.map +1 -0
  125. package/dist/Search.js +110 -0
  126. package/dist/Search.js.map +1 -0
  127. package/dist/SendToFields.js +2221 -0
  128. package/dist/SendToFields.js.map +1 -0
  129. package/dist/SessionEnvironment.js +431 -0
  130. package/dist/SessionEnvironment.js.map +1 -0
  131. package/dist/Settings.js +250 -0
  132. package/dist/Settings.js.map +1 -0
  133. package/dist/ShareRecordingPane.js +216 -0
  134. package/dist/ShareRecordingPane.js.map +1 -0
  135. package/dist/ShareViaEmail.js +416 -0
  136. package/dist/ShareViaEmail.js.map +1 -0
  137. package/dist/ShareViaLink.js +1556 -0
  138. package/dist/ShareViaLink.js.map +1 -0
  139. package/dist/Sidebar.js +294 -0
  140. package/dist/Sidebar.js.map +1 -0
  141. package/dist/StatusDropdown.js +109 -0
  142. package/dist/StatusDropdown.js.map +1 -0
  143. package/dist/StickyRibbonsContainer.js +131 -0
  144. package/dist/StickyRibbonsContainer.js.map +1 -0
  145. package/dist/SubHeader.js +209 -0
  146. package/dist/SubHeader.js.map +1 -0
  147. package/dist/SubscriptionNotificationsContainer.js +77 -0
  148. package/dist/SubscriptionNotificationsContainer.js.map +1 -0
  149. package/dist/SuffixedInput.js +111 -0
  150. package/dist/SuffixedInput.js.map +1 -0
  151. package/dist/TableWrapper.js +27 -0
  152. package/dist/TableWrapper.js.map +1 -0
  153. package/dist/Taxonomy.js +496 -0
  154. package/dist/Taxonomy.js.map +1 -0
  155. package/dist/TimeFormat.js +14 -0
  156. package/dist/TimeFormat.js.map +1 -0
  157. package/dist/TimezoneMismatchModal.js +138 -0
  158. package/dist/TimezoneMismatchModal.js.map +1 -0
  159. package/dist/ToggleFeatureCard.js +211 -0
  160. package/dist/ToggleFeatureCard.js.map +1 -0
  161. package/dist/_commonjsHelpers-BFTU3MAI.js +8 -0
  162. package/dist/_commonjsHelpers-BFTU3MAI.js.map +1 -0
  163. package/dist/cjs/AuditLogs.js +541 -0
  164. package/dist/cjs/AuditLogs.js.map +1 -0
  165. package/dist/cjs/BoardView.js +396 -0
  166. package/dist/cjs/BoardView.js.map +1 -0
  167. package/dist/cjs/Breadcrumbs.js +48 -0
  168. package/dist/cjs/Breadcrumbs.js.map +1 -0
  169. package/dist/cjs/BrowserPreview.js +52 -0
  170. package/dist/cjs/BrowserPreview.js.map +1 -0
  171. package/dist/cjs/BrowserSupport.js +350 -0
  172. package/dist/cjs/BrowserSupport.js.map +1 -0
  173. package/dist/cjs/Builder.js +794 -0
  174. package/dist/cjs/Builder.js.map +1 -0
  175. package/dist/cjs/ButtonGroup.js +38 -0
  176. package/dist/cjs/ButtonGroup.js.map +1 -0
  177. package/dist/cjs/CalendarView.js +358 -0
  178. package/dist/cjs/CalendarView.js.map +1 -0
  179. package/dist/cjs/CardLayout.js +51 -0
  180. package/dist/cjs/CardLayout.js.map +1 -0
  181. package/dist/cjs/Chevron-DJbXy_CD.js +256 -0
  182. package/dist/cjs/Chevron-DJbXy_CD.js.map +1 -0
  183. package/dist/cjs/Codeblock.js +60 -0
  184. package/dist/cjs/Codeblock.js.map +1 -0
  185. package/dist/cjs/Columns.js +35 -0
  186. package/dist/cjs/Columns.js.map +1 -0
  187. package/dist/cjs/ConfigurePageSidebar.js +99 -0
  188. package/dist/cjs/ConfigurePageSidebar.js.map +1 -0
  189. package/dist/cjs/ConfirmationModal.js +131 -0
  190. package/dist/cjs/ConfirmationModal.js.map +1 -0
  191. package/dist/cjs/Container.js +40 -0
  192. package/dist/cjs/Container.js.map +1 -0
  193. package/dist/cjs/CopyToClipboardButton.js +84 -0
  194. package/dist/cjs/CopyToClipboardButton.js.map +1 -0
  195. package/dist/cjs/Currency.js +920 -0
  196. package/dist/cjs/Currency.js.map +1 -0
  197. package/dist/cjs/DateFormat.js +47 -0
  198. package/dist/cjs/DateFormat.js.map +1 -0
  199. package/dist/cjs/DateRangeFilter.js +180 -0
  200. package/dist/cjs/DateRangeFilter.js.map +1 -0
  201. package/dist/cjs/DeleteArchiveModal.js +100 -0
  202. package/dist/cjs/DeleteArchiveModal.js.map +1 -0
  203. package/dist/cjs/DeviceIncompatibilityMessage.js +115 -0
  204. package/dist/cjs/DeviceIncompatibilityMessage.js.map +1 -0
  205. package/dist/cjs/DocumentEditor.js +185 -0
  206. package/dist/cjs/DocumentEditor.js.map +1 -0
  207. package/dist/cjs/DownloadMobileAppCallout.js +42 -0
  208. package/dist/cjs/DownloadMobileAppCallout.js.map +1 -0
  209. package/dist/cjs/DynamicVariables.js +117 -0
  210. package/dist/cjs/DynamicVariables.js.map +1 -0
  211. package/dist/cjs/EmailForm.js +593 -0
  212. package/dist/cjs/EmailForm.js.map +1 -0
  213. package/dist/cjs/EmailPreview.js +142 -0
  214. package/dist/cjs/EmailPreview.js.map +1 -0
  215. package/dist/cjs/EmojiPicker.js +114 -0
  216. package/dist/cjs/EmojiPicker.js.map +1 -0
  217. package/dist/cjs/EmojiReactions.js +84 -0
  218. package/dist/cjs/EmojiReactions.js.map +1 -0
  219. package/dist/cjs/Engagements.js +294 -0
  220. package/dist/cjs/Engagements.js.map +1 -0
  221. package/dist/cjs/ErrorPage.js +1831 -0
  222. package/dist/cjs/ErrorPage.js.map +1 -0
  223. package/dist/cjs/FileUpload.js +598 -0
  224. package/dist/cjs/FileUpload.js.map +1 -0
  225. package/dist/cjs/FinderModal.js +282 -0
  226. package/dist/cjs/FinderModal.js.map +1 -0
  227. package/dist/cjs/FloatingActionMenu.js +875 -0
  228. package/dist/cjs/FloatingActionMenu.js.map +1 -0
  229. package/dist/cjs/GoogleFontPicker.js +583 -0
  230. package/dist/cjs/GoogleFontPicker.js.map +1 -0
  231. package/dist/cjs/Header.js +128 -0
  232. package/dist/cjs/Header.js.map +1 -0
  233. package/dist/cjs/HelpPopover.js +85 -0
  234. package/dist/cjs/HelpPopover.js.map +1 -0
  235. package/dist/cjs/IconPicker.js +1161 -0
  236. package/dist/cjs/IconPicker.js.map +1 -0
  237. package/dist/cjs/ImageWithFallback.js +51 -0
  238. package/dist/cjs/ImageWithFallback.js.map +1 -0
  239. package/dist/cjs/InlineInput.js +233 -0
  240. package/dist/cjs/InlineInput.js.map +1 -0
  241. package/dist/cjs/Insights.js +360 -0
  242. package/dist/cjs/Insights.js.map +1 -0
  243. package/dist/cjs/IntegrationCard.js +229 -0
  244. package/dist/cjs/IntegrationCard.js.map +1 -0
  245. package/dist/cjs/IpRestriction.js +3638 -0
  246. package/dist/cjs/IpRestriction.js.map +1 -0
  247. package/dist/cjs/KeyboardShortcuts.js +286 -0
  248. package/dist/cjs/KeyboardShortcuts.js.map +1 -0
  249. package/dist/cjs/LoginPage.js +205 -0
  250. package/dist/cjs/LoginPage.js.map +1 -0
  251. package/dist/cjs/MadeWith.js +43 -0
  252. package/dist/cjs/MadeWith.js.map +1 -0
  253. package/dist/cjs/MenuBar.js +1328 -0
  254. package/dist/cjs/MenuBar.js.map +1 -0
  255. package/dist/cjs/Metadata.js +220 -0
  256. package/dist/cjs/Metadata.js.map +1 -0
  257. package/dist/cjs/MobilePreviewHeader.js +27 -0
  258. package/dist/cjs/MobilePreviewHeader.js.map +1 -0
  259. package/dist/cjs/MoreDropdown.js +165 -0
  260. package/dist/cjs/MoreDropdown.js.map +1 -0
  261. package/dist/cjs/NavigationHeader.js +266 -0
  262. package/dist/cjs/NavigationHeader.js.map +1 -0
  263. package/dist/cjs/NeetoWidget.js +2888 -0
  264. package/dist/cjs/NeetoWidget.js.map +1 -0
  265. package/dist/cjs/Onboarding.js +248 -0
  266. package/dist/cjs/Onboarding.js.map +1 -0
  267. package/dist/cjs/OptionFields.js +719 -0
  268. package/dist/cjs/OptionFields.js.map +1 -0
  269. package/dist/cjs/PageLoader.js +42 -0
  270. package/dist/cjs/PageLoader.js.map +1 -0
  271. package/dist/cjs/PhoneNumber.js +80 -0
  272. package/dist/cjs/PhoneNumber.js.map +1 -0
  273. package/dist/cjs/ProductEmbed.js +886 -0
  274. package/dist/cjs/ProductEmbed.js.map +1 -0
  275. package/dist/cjs/PublishBlock.js +449 -0
  276. package/dist/cjs/PublishBlock.js.map +1 -0
  277. package/dist/cjs/PublishYourItem.js +60 -0
  278. package/dist/cjs/PublishYourItem.js.map +1 -0
  279. package/dist/cjs/Rename.js +368 -0
  280. package/dist/cjs/Rename.js.map +1 -0
  281. package/dist/cjs/ResponsiveDevicePicker.js +65 -0
  282. package/dist/cjs/ResponsiveDevicePicker.js.map +1 -0
  283. package/dist/cjs/Schedule.js +947 -0
  284. package/dist/cjs/Schedule.js.map +1 -0
  285. package/dist/cjs/Scrollable.js +44 -0
  286. package/dist/cjs/Scrollable.js.map +1 -0
  287. package/dist/cjs/Search.js +112 -0
  288. package/dist/cjs/Search.js.map +1 -0
  289. package/dist/cjs/SendToFields.js +2223 -0
  290. package/dist/cjs/SendToFields.js.map +1 -0
  291. package/dist/cjs/SessionEnvironment.js +433 -0
  292. package/dist/cjs/SessionEnvironment.js.map +1 -0
  293. package/dist/cjs/Settings.js +252 -0
  294. package/dist/cjs/Settings.js.map +1 -0
  295. package/dist/cjs/ShareRecordingPane.js +218 -0
  296. package/dist/cjs/ShareRecordingPane.js.map +1 -0
  297. package/dist/cjs/ShareViaEmail.js +437 -0
  298. package/dist/cjs/ShareViaEmail.js.map +1 -0
  299. package/dist/cjs/ShareViaLink.js +1577 -0
  300. package/dist/cjs/ShareViaLink.js.map +1 -0
  301. package/dist/cjs/Sidebar.js +315 -0
  302. package/dist/cjs/Sidebar.js.map +1 -0
  303. package/dist/cjs/StatusDropdown.js +111 -0
  304. package/dist/cjs/StatusDropdown.js.map +1 -0
  305. package/dist/cjs/StickyRibbonsContainer.js +133 -0
  306. package/dist/cjs/StickyRibbonsContainer.js.map +1 -0
  307. package/dist/cjs/SubHeader.js +211 -0
  308. package/dist/cjs/SubHeader.js.map +1 -0
  309. package/dist/cjs/SubscriptionNotificationsContainer.js +79 -0
  310. package/dist/cjs/SubscriptionNotificationsContainer.js.map +1 -0
  311. package/dist/cjs/SuffixedInput.js +113 -0
  312. package/dist/cjs/SuffixedInput.js.map +1 -0
  313. package/dist/cjs/TableWrapper.js +29 -0
  314. package/dist/cjs/TableWrapper.js.map +1 -0
  315. package/dist/cjs/Taxonomy.js +517 -0
  316. package/dist/cjs/Taxonomy.js.map +1 -0
  317. package/dist/cjs/TimeFormat.js +16 -0
  318. package/dist/cjs/TimeFormat.js.map +1 -0
  319. package/dist/cjs/TimezoneMismatchModal.js +140 -0
  320. package/dist/cjs/TimezoneMismatchModal.js.map +1 -0
  321. package/dist/cjs/ToggleFeatureCard.js +213 -0
  322. package/dist/cjs/ToggleFeatureCard.js.map +1 -0
  323. package/dist/cjs/_commonjsHelpers-BJu3ubxk.js +11 -0
  324. package/dist/cjs/_commonjsHelpers-BJu3ubxk.js.map +1 -0
  325. package/dist/cjs/index-JY2zVpnv.js +1189 -0
  326. package/dist/cjs/index-JY2zVpnv.js.map +1 -0
  327. package/dist/cjs/inject-css-vQvjPR2x.js +6 -0
  328. package/dist/cjs/inject-css-vQvjPR2x.js.map +1 -0
  329. package/dist/cjs/phone-number-BN-c0rfv.js +320 -0
  330. package/dist/cjs/phone-number-BN-c0rfv.js.map +1 -0
  331. package/dist/cjs/platform-BUcCb8Jx.js +1254 -0
  332. package/dist/cjs/platform-BUcCb8Jx.js.map +1 -0
  333. package/dist/cjs/useColumns-BP8c4PV-.js +282 -0
  334. package/dist/cjs/useColumns-BP8c4PV-.js.map +1 -0
  335. package/dist/index-DAYCJu79.js +1187 -0
  336. package/dist/index-DAYCJu79.js.map +1 -0
  337. package/dist/inject-css-DmrvuTKK.js +4 -0
  338. package/dist/inject-css-DmrvuTKK.js.map +1 -0
  339. package/dist/phone-number-CXCBroLh.js +295 -0
  340. package/dist/phone-number-CXCBroLh.js.map +1 -0
  341. package/dist/platform-F44zJ4Xh.js +1252 -0
  342. package/dist/platform-F44zJ4Xh.js.map +1 -0
  343. package/dist/styles/page-loader.css +1 -0
  344. package/dist/styles/page-loader.js +3 -0
  345. package/dist/useColumns-Db5uic1-.js +274 -0
  346. package/dist/useColumns-Db5uic1-.js.map +1 -0
  347. package/package.json +5 -5
  348. package/types/AuditLogs.d.ts +22 -0
  349. package/types/BoardView.d.ts +149 -0
  350. package/types/Breadcrumbs.d.ts +30 -0
  351. package/types/BrowserPreview.d.ts +30 -0
  352. package/types/BrowserSupport.d.ts +110 -0
  353. package/types/Builder.d.ts +99 -0
  354. package/types/ButtonGroup.d.ts +45 -0
  355. package/types/CalendarView.d.ts +98 -0
  356. package/types/CardLayout.d.ts +34 -0
  357. package/types/Codeblock.d.ts +37 -0
  358. package/types/Columns.d.ts +168 -0
  359. package/types/ConfigurePageSidebar.d.ts +45 -0
  360. package/types/ConfirmationModal.d.ts +65 -0
  361. package/types/Container.d.ts +38 -0
  362. package/types/CopyToClipboardButton.d.ts +28 -0
  363. package/types/Currency.d.ts +50 -0
  364. package/types/DateFormat.d.ts +15 -0
  365. package/types/DateRangeFilter.d.ts +56 -0
  366. package/types/DeleteArchiveModal.d.ts +65 -0
  367. package/types/DeviceIncompatibilityMessage.d.ts +19 -0
  368. package/types/DocumentEditor.d.ts +61 -0
  369. package/types/DownloadMobileAppCallout.d.ts +35 -0
  370. package/types/DynamicVariables.d.ts +48 -0
  371. package/types/EmailForm.d.ts +165 -0
  372. package/types/EmailFormProvider.d.ts +48 -0
  373. package/types/EmailPreview.d.ts +43 -0
  374. package/types/EmojiPicker.d.ts +35 -0
  375. package/types/EmojiReactions.d.ts +62 -0
  376. package/types/Engagements.d.ts +131 -0
  377. package/types/ErrorPage.d.ts +22 -0
  378. package/types/FileUpload.d.ts +89 -0
  379. package/types/FinderModal.d.ts +66 -0
  380. package/types/FloatingActionMenu.d.ts +59 -0
  381. package/types/GoogleFontPicker.d.ts +68 -0
  382. package/types/Header.d.ts +37 -0
  383. package/types/HelpPopover.d.ts +45 -0
  384. package/types/IconPicker.d.ts +45 -0
  385. package/types/ImageWithFallback.d.ts +24 -0
  386. package/types/InlineInput.d.ts +87 -0
  387. package/types/Insights.d.ts +112 -0
  388. package/types/IntegrationCard.d.ts +60 -0
  389. package/types/IpRestriction.d.ts +25 -0
  390. package/types/KeyboardShortcuts.d.ts +149 -0
  391. package/types/LoginPage.d.ts +45 -0
  392. package/types/MadeWith.d.ts +18 -0
  393. package/types/MenuBar.d.ts +127 -0
  394. package/types/Metadata.d.ts +109 -0
  395. package/types/MobilePreviewHeader.d.ts +19 -0
  396. package/types/MoreDropdown.d.ts +52 -0
  397. package/types/NavigationHeader.d.ts +180 -0
  398. package/types/NeetoWidget.d.ts +43 -0
  399. package/types/Onboarding.d.ts +70 -0
  400. package/types/OptionFields.d.ts +70 -0
  401. package/types/PageLoader.d.ts +40 -0
  402. package/types/PhoneNumber.d.ts +112 -0
  403. package/types/ProductEmbed.d.ts +93 -0
  404. package/types/PublishBlock.d.ts +148 -0
  405. package/types/Rename.d.ts +73 -0
  406. package/types/ResponsiveDevicePicker.d.ts +32 -0
  407. package/types/Schedule.d.ts +146 -0
  408. package/types/Scrollable.d.ts +30 -0
  409. package/types/Search.d.ts +22 -0
  410. package/types/SendToFields.d.ts +67 -0
  411. package/types/SessionEnvironment.d.ts +170 -0
  412. package/types/Settings.d.ts +108 -0
  413. package/types/ShareRecordingPane.d.ts +85 -0
  414. package/types/ShareViaEmail.d.ts +99 -0
  415. package/types/ShareViaLink.d.ts +183 -0
  416. package/types/Sidebar.d.ts +51 -0
  417. package/types/StatusDropdown.d.ts +74 -0
  418. package/types/StickyRibbonsContainer.d.ts +28 -0
  419. package/types/SubHeader.d.ts +105 -0
  420. package/types/SubscriptionNotificationsContainer.d.ts +26 -0
  421. package/types/SuffixedInput.d.ts +45 -0
  422. package/types/TableWrapper.d.ts +40 -0
  423. package/types/Taxonomy.d.ts +59 -0
  424. package/types/TimeFormat.d.ts +13 -0
  425. package/types/TimezoneMismatchModal.d.ts +41 -0
  426. package/types/ToggleFeatureCard.d.ts +38 -0
@@ -0,0 +1,2221 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
+ import { memo, useState, useRef } from 'react';
5
+ import { useFormikContext } from 'formik';
6
+ import Upload from '@bigbinary/neeto-icons/Upload';
7
+ import Button from '@bigbinary/neetoui/Button';
8
+ import Toastr from '@bigbinary/neetoui/Toastr';
9
+ import MultiEmailInput from '@bigbinary/neetoui/formik/MultiEmailInput';
10
+ import { Trans, useTranslation } from 'react-i18next';
11
+ import classnames from 'classnames';
12
+ import Typography from '@bigbinary/neetoui/Typography';
13
+ import Pane from '@bigbinary/neetoui/Pane';
14
+ import { useDropzone } from 'react-dropzone';
15
+ import withT from '@bigbinary/neeto-commons-frontend/react-utils/withT';
16
+ import Download from '@bigbinary/neeto-icons/Download';
17
+ import Callout from '@bigbinary/neetoui/Callout';
18
+ import { jsxs, jsx } from 'react/jsx-runtime';
19
+ import { t } from 'i18next';
20
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-BFTU3MAI.js';
21
+ import require$$0 from 'stream';
22
+ import { prop } from 'ramda';
23
+ import { string } from 'yup';
24
+
25
+ var CSV_FILE_SIZE_IN_KB = 32;
26
+ var ONE_KILOBYTE_IN_BYTES = 1024;
27
+ var DOWNLOAD_SAMPLE_EMAIL_CSV_FILE = "https://d2v7kzglnr2dnh.cloudfront.net/others/sample-bulk-email.csv";
28
+
29
+ var Requirements = withT(function (_ref) {
30
+ var t = _ref.t,
31
+ fileSize = _ref.fileSize;
32
+ return /*#__PURE__*/jsxs(Callout, {
33
+ className: "flex flex-col items-center py-6",
34
+ style: "info",
35
+ children: [/*#__PURE__*/jsxs("ul", {
36
+ className: "list-outside list-disc space-y-1 font-normal leading-normal",
37
+ children: [fileSize && /*#__PURE__*/jsx("li", {
38
+ children: t("neetoMolecules.shareViaLink.requirements.fileTypeAndSize", {
39
+ limit: fileSize
40
+ })
41
+ }), /*#__PURE__*/jsx("li", {
42
+ children: /*#__PURE__*/jsx(Trans, {
43
+ components: {
44
+ strong: /*#__PURE__*/jsx("strong", {
45
+ className: "font-semibold"
46
+ })
47
+ },
48
+ i18nKey: "neetoMolecules.shareViaLink.requirements.shouldContainColumns"
49
+ })
50
+ })]
51
+ }), /*#__PURE__*/jsx(Button, {
52
+ href: DOWNLOAD_SAMPLE_EMAIL_CSV_FILE,
53
+ icon: Download,
54
+ iconPosition: "left",
55
+ label: t("neetoMolecules.shareViaLink.bulkUploadPane.downloadSampleCSV"),
56
+ style: "link"
57
+ })]
58
+ });
59
+ });
60
+ var Requirements$1 = /*#__PURE__*/memo(Requirements);
61
+
62
+ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
63
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
64
+ var BulkUploadPane = function BulkUploadPane(_ref) {
65
+ var _fileRejections$;
66
+ var isOpen = _ref.isOpen,
67
+ fileSize = _ref.fileSize,
68
+ onClose = _ref.onClose,
69
+ handleFileSubmit = _ref.handleFileSubmit;
70
+ var _useDropzone = useDropzone({
71
+ accept: {
72
+ "text/csv": []
73
+ },
74
+ maxFiles: 1,
75
+ maxSize: fileSize * ONE_KILOBYTE_IN_BYTES,
76
+ onDrop: function onDrop(files) {
77
+ return files[0] && handleFileSubmit(files[0]);
78
+ }
79
+ }),
80
+ getRootProps = _useDropzone.getRootProps,
81
+ getInputProps = _useDropzone.getInputProps,
82
+ isDragActive = _useDropzone.isDragActive,
83
+ fileRejections = _useDropzone.fileRejections;
84
+ var errors = (_fileRejections$ = fileRejections[0]) === null || _fileRejections$ === void 0 ? void 0 : _fileRejections$.errors.map(function (_ref2) {
85
+ var message = _ref2.message,
86
+ code = _ref2.code;
87
+ return /*#__PURE__*/jsx(Typography, {
88
+ className: "neeto-ui-text-error-500 items",
89
+ "data-cy": "file-input-error-message",
90
+ style: "body3",
91
+ children: message
92
+ }, code);
93
+ });
94
+ var _useTranslation = useTranslation(),
95
+ t = _useTranslation.t;
96
+ return /*#__PURE__*/jsx(Pane, {
97
+ isOpen: isOpen,
98
+ onClose: onClose,
99
+ "data-testid": "bulk-upload-pane",
100
+ children: /*#__PURE__*/jsxs("div", {
101
+ tabIndex: 0,
102
+ children: [/*#__PURE__*/jsx(Pane.Header, {
103
+ children: /*#__PURE__*/jsx(Typography, {
104
+ "data-testid": "bulk-upload-header",
105
+ style: "h2",
106
+ weight: "semibold",
107
+ children: t("neetoMolecules.shareViaLink.bulkUpload")
108
+ })
109
+ }), /*#__PURE__*/jsx(Pane.Body, {
110
+ children: /*#__PURE__*/jsxs("div", {
111
+ className: "w-full space-y-4",
112
+ children: [/*#__PURE__*/jsx(Requirements$1, {
113
+ fileSize: fileSize
114
+ }), /*#__PURE__*/jsxs("div", _objectSpread$1(_objectSpread$1({}, getRootProps({
115
+ className: classnames("flex flex-col p-2 border neeto-ui-border-primary-500 border-dashed neeto-ui-rounded-md transition duration-500 ease-in-out hover:neeto-ui-bg-gray-100 cursor-pointer items-center", {
116
+ "neeto-ui-border-gray-100": isDragActive,
117
+ "neeto-ui-border-error neeto-ui-bg-pastel-red hover:neeto-ui-bg-pastel-red": fileRejections.length
118
+ })
119
+ })), {}, {
120
+ children: [/*#__PURE__*/jsxs("div", {
121
+ className: "flex flex-col items-center space-y-3 p-4",
122
+ children: [/*#__PURE__*/jsx(Upload, {
123
+ className: "neeto-ui-text-primary-500",
124
+ size: 32
125
+ }), /*#__PURE__*/jsx("input", _objectSpread$1(_objectSpread$1({}, getInputProps()), {}, {
126
+ "data-cy": "csv-upload-input",
127
+ "data-testid": "csv-upload-input"
128
+ })), isDragActive ? /*#__PURE__*/jsx(Typography, {
129
+ style: "body2",
130
+ children: t("neetoMolecules.shareViaLink.bulkUploadPane.dropFileHere")
131
+ }) : /*#__PURE__*/jsxs("div", {
132
+ className: "flex flex-col items-center space-y-1",
133
+ children: [/*#__PURE__*/jsx("div", {
134
+ className: "flex w-full items-center justify-center gap-x-1",
135
+ children: /*#__PURE__*/jsx(Trans, {
136
+ i18nKey: "neetoMolecules.shareViaLink.bulkUploadPane.dragNDrop",
137
+ components: {
138
+ Button: /*#__PURE__*/jsx(Button, {
139
+ style: "link"
140
+ })
141
+ }
142
+ })
143
+ }), /*#__PURE__*/jsxs(Typography, {
144
+ className: "neeto-ui-text-gray-700",
145
+ style: "body3",
146
+ children: [/*#__PURE__*/jsx(Trans, {
147
+ i18nKey: "neetoMolecules.shareViaLink.bulkUploadPane.supportedFormat",
148
+ values: {
149
+ fileType: "csv"
150
+ },
151
+ components: {
152
+ code: /*#__PURE__*/jsx("code", {
153
+ className: "neeto-ui-typography neeto-ui-text-body3 neeto-ui-bg-white m-0 border-l-0 p-0"
154
+ })
155
+ }
156
+ }), " ", fileSize && t("neetoMolecules.shareViaLink.bulkUploadPane.supportedSize", {
157
+ fileSize: fileSize
158
+ })]
159
+ })]
160
+ })]
161
+ }), errors]
162
+ }))]
163
+ })
164
+ }), /*#__PURE__*/jsx(Pane.Footer, {
165
+ className: "flex items-center space-x-2",
166
+ children: /*#__PURE__*/jsx(Button, {
167
+ "data-cy": "bulk-upload-cancel-button",
168
+ "data-testid": "bulk-upload-cancel-button",
169
+ label: t("neetoMolecules.common.actions.cancel"),
170
+ style: "text",
171
+ type: "reset",
172
+ onClick: onClose
173
+ })
174
+ })]
175
+ })
176
+ });
177
+ };
178
+
179
+ var papaparse = {exports: {}};
180
+
181
+ /* @license
182
+ Papa Parse
183
+ v5.4.1
184
+ https://github.com/mholt/PapaParse
185
+ License: MIT
186
+ */
187
+
188
+ (function (module, exports) {
189
+ (function(root, factory)
190
+ {
191
+ /* globals define */
192
+ {
193
+ // Node. Does not work with strict CommonJS, but
194
+ // only CommonJS-like environments that support module.exports,
195
+ // like Node.
196
+ module.exports = factory();
197
+ }
198
+ // in strict mode we cannot access arguments.callee, so we need a named reference to
199
+ // stringify the factory method for the blob worker
200
+ // eslint-disable-next-line func-name
201
+ }(commonjsGlobal, function moduleFactory()
202
+ {
203
+
204
+ var global = (function() {
205
+ // alternative method, similar to `Function('return this')()`
206
+ // but without using `eval` (which is disabled when
207
+ // using Content Security Policy).
208
+
209
+ if (typeof self !== 'undefined') { return self; }
210
+ if (typeof window !== 'undefined') { return window; }
211
+ if (typeof global !== 'undefined') { return global; }
212
+
213
+ // When running tests none of the above have been defined
214
+ return {};
215
+ })();
216
+
217
+
218
+ function getWorkerBlob() {
219
+ var URL = global.URL || global.webkitURL || null;
220
+ var code = moduleFactory.toString();
221
+ 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'})));
222
+ }
223
+
224
+ var IS_WORKER = !global.document && !!global.postMessage,
225
+ IS_PAPA_WORKER = global.IS_PAPA_WORKER || false;
226
+
227
+ var workers = {}, workerIdCounter = 0;
228
+
229
+ var Papa = {};
230
+
231
+ Papa.parse = CsvToJson;
232
+ Papa.unparse = JsonToCsv;
233
+
234
+ Papa.RECORD_SEP = String.fromCharCode(30);
235
+ Papa.UNIT_SEP = String.fromCharCode(31);
236
+ Papa.BYTE_ORDER_MARK = '\ufeff';
237
+ Papa.BAD_DELIMITERS = ['\r', '\n', '"', Papa.BYTE_ORDER_MARK];
238
+ Papa.WORKERS_SUPPORTED = !IS_WORKER && !!global.Worker;
239
+ Papa.NODE_STREAM_INPUT = 1;
240
+
241
+ // Configurable chunk sizes for local and remote files, respectively
242
+ Papa.LocalChunkSize = 1024 * 1024 * 10; // 10 MB
243
+ Papa.RemoteChunkSize = 1024 * 1024 * 5; // 5 MB
244
+ Papa.DefaultDelimiter = ','; // Used if not specified and detection fails
245
+
246
+ // Exposed for testing and development only
247
+ Papa.Parser = Parser;
248
+ Papa.ParserHandle = ParserHandle;
249
+ Papa.NetworkStreamer = NetworkStreamer;
250
+ Papa.FileStreamer = FileStreamer;
251
+ Papa.StringStreamer = StringStreamer;
252
+ Papa.ReadableStreamStreamer = ReadableStreamStreamer;
253
+ if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
254
+ Papa.DuplexStreamStreamer = DuplexStreamStreamer;
255
+ }
256
+
257
+ if (global.jQuery)
258
+ {
259
+ var $ = global.jQuery;
260
+ $.fn.parse = function(options)
261
+ {
262
+ var config = options.config || {};
263
+ var queue = [];
264
+
265
+ this.each(function(idx)
266
+ {
267
+ var supported = $(this).prop('tagName').toUpperCase() === 'INPUT'
268
+ && $(this).attr('type').toLowerCase() === 'file'
269
+ && global.FileReader;
270
+
271
+ if (!supported || !this.files || this.files.length === 0)
272
+ return true; // continue to next input element
273
+
274
+ for (var i = 0; i < this.files.length; i++)
275
+ {
276
+ queue.push({
277
+ file: this.files[i],
278
+ inputElem: this,
279
+ instanceConfig: $.extend({}, config)
280
+ });
281
+ }
282
+ });
283
+
284
+ parseNextFile(); // begin parsing
285
+ return this; // maintains chainability
286
+
287
+
288
+ function parseNextFile()
289
+ {
290
+ if (queue.length === 0)
291
+ {
292
+ if (isFunction(options.complete))
293
+ options.complete();
294
+ return;
295
+ }
296
+
297
+ var f = queue[0];
298
+
299
+ if (isFunction(options.before))
300
+ {
301
+ var returned = options.before(f.file, f.inputElem);
302
+
303
+ if (typeof returned === 'object')
304
+ {
305
+ if (returned.action === 'abort')
306
+ {
307
+ error('AbortError', f.file, f.inputElem, returned.reason);
308
+ return; // Aborts all queued files immediately
309
+ }
310
+ else if (returned.action === 'skip')
311
+ {
312
+ fileComplete(); // parse the next file in the queue, if any
313
+ return;
314
+ }
315
+ else if (typeof returned.config === 'object')
316
+ f.instanceConfig = $.extend(f.instanceConfig, returned.config);
317
+ }
318
+ else if (returned === 'skip')
319
+ {
320
+ fileComplete(); // parse the next file in the queue, if any
321
+ return;
322
+ }
323
+ }
324
+
325
+ // Wrap up the user's complete callback, if any, so that ours also gets executed
326
+ var userCompleteFunc = f.instanceConfig.complete;
327
+ f.instanceConfig.complete = function(results)
328
+ {
329
+ if (isFunction(userCompleteFunc))
330
+ userCompleteFunc(results, f.file, f.inputElem);
331
+ fileComplete();
332
+ };
333
+
334
+ Papa.parse(f.file, f.instanceConfig);
335
+ }
336
+
337
+ function error(name, file, elem, reason)
338
+ {
339
+ if (isFunction(options.error))
340
+ options.error({name: name}, file, elem, reason);
341
+ }
342
+
343
+ function fileComplete()
344
+ {
345
+ queue.splice(0, 1);
346
+ parseNextFile();
347
+ }
348
+ };
349
+ }
350
+
351
+
352
+ if (IS_PAPA_WORKER)
353
+ {
354
+ global.onmessage = workerThreadReceivedMessage;
355
+ }
356
+
357
+
358
+
359
+
360
+ function CsvToJson(_input, _config)
361
+ {
362
+ _config = _config || {};
363
+ var dynamicTyping = _config.dynamicTyping || false;
364
+ if (isFunction(dynamicTyping)) {
365
+ _config.dynamicTypingFunction = dynamicTyping;
366
+ // Will be filled on first row call
367
+ dynamicTyping = {};
368
+ }
369
+ _config.dynamicTyping = dynamicTyping;
370
+
371
+ _config.transform = isFunction(_config.transform) ? _config.transform : false;
372
+
373
+ if (_config.worker && Papa.WORKERS_SUPPORTED)
374
+ {
375
+ var w = newWorker();
376
+
377
+ w.userStep = _config.step;
378
+ w.userChunk = _config.chunk;
379
+ w.userComplete = _config.complete;
380
+ w.userError = _config.error;
381
+
382
+ _config.step = isFunction(_config.step);
383
+ _config.chunk = isFunction(_config.chunk);
384
+ _config.complete = isFunction(_config.complete);
385
+ _config.error = isFunction(_config.error);
386
+ delete _config.worker; // prevent infinite loop
387
+
388
+ w.postMessage({
389
+ input: _input,
390
+ config: _config,
391
+ workerId: w.id
392
+ });
393
+
394
+ return;
395
+ }
396
+
397
+ var streamer = null;
398
+ if (_input === Papa.NODE_STREAM_INPUT && typeof PAPA_BROWSER_CONTEXT === 'undefined')
399
+ {
400
+ // create a node Duplex stream for use
401
+ // with .pipe
402
+ streamer = new DuplexStreamStreamer(_config);
403
+ return streamer.getStream();
404
+ }
405
+ else if (typeof _input === 'string')
406
+ {
407
+ _input = stripBom(_input);
408
+ if (_config.download)
409
+ streamer = new NetworkStreamer(_config);
410
+ else
411
+ streamer = new StringStreamer(_config);
412
+ }
413
+ else if (_input.readable === true && isFunction(_input.read) && isFunction(_input.on))
414
+ {
415
+ streamer = new ReadableStreamStreamer(_config);
416
+ }
417
+ else if ((global.File && _input instanceof File) || _input instanceof Object) // ...Safari. (see issue #106)
418
+ streamer = new FileStreamer(_config);
419
+
420
+ return streamer.stream(_input);
421
+
422
+ // Strip character from UTF-8 BOM encoded files that cause issue parsing the file
423
+ function stripBom(string) {
424
+ if (string.charCodeAt(0) === 0xfeff) {
425
+ return string.slice(1);
426
+ }
427
+ return string;
428
+ }
429
+ }
430
+
431
+
432
+
433
+
434
+
435
+
436
+ function JsonToCsv(_input, _config)
437
+ {
438
+ // Default configuration
439
+
440
+ /** whether to surround every datum with quotes */
441
+ var _quotes = false;
442
+
443
+ /** whether to write headers */
444
+ var _writeHeader = true;
445
+
446
+ /** delimiting character(s) */
447
+ var _delimiter = ',';
448
+
449
+ /** newline character(s) */
450
+ var _newline = '\r\n';
451
+
452
+ /** quote character */
453
+ var _quoteChar = '"';
454
+
455
+ /** escaped quote character, either "" or <config.escapeChar>" */
456
+ var _escapedQuote = _quoteChar + _quoteChar;
457
+
458
+ /** whether to skip empty lines */
459
+ var _skipEmptyLines = false;
460
+
461
+ /** the columns (keys) we expect when we unparse objects */
462
+ var _columns = null;
463
+
464
+ /** whether to prevent outputting cells that can be parsed as formulae by spreadsheet software (Excel and LibreOffice) */
465
+ var _escapeFormulae = false;
466
+
467
+ unpackConfig();
468
+
469
+ var quoteCharRegex = new RegExp(escapeRegExp(_quoteChar), 'g');
470
+
471
+ if (typeof _input === 'string')
472
+ _input = JSON.parse(_input);
473
+
474
+ if (Array.isArray(_input))
475
+ {
476
+ if (!_input.length || Array.isArray(_input[0]))
477
+ return serialize(null, _input, _skipEmptyLines);
478
+ else if (typeof _input[0] === 'object')
479
+ return serialize(_columns || Object.keys(_input[0]), _input, _skipEmptyLines);
480
+ }
481
+ else if (typeof _input === 'object')
482
+ {
483
+ if (typeof _input.data === 'string')
484
+ _input.data = JSON.parse(_input.data);
485
+
486
+ if (Array.isArray(_input.data))
487
+ {
488
+ if (!_input.fields)
489
+ _input.fields = _input.meta && _input.meta.fields || _columns;
490
+
491
+ if (!_input.fields)
492
+ _input.fields = Array.isArray(_input.data[0])
493
+ ? _input.fields
494
+ : typeof _input.data[0] === 'object'
495
+ ? Object.keys(_input.data[0])
496
+ : [];
497
+
498
+ if (!(Array.isArray(_input.data[0])) && typeof _input.data[0] !== 'object')
499
+ _input.data = [_input.data]; // handles input like [1,2,3] or ['asdf']
500
+ }
501
+
502
+ return serialize(_input.fields || [], _input.data || [], _skipEmptyLines);
503
+ }
504
+
505
+ // Default (any valid paths should return before this)
506
+ throw new Error('Unable to serialize unrecognized input');
507
+
508
+
509
+ function unpackConfig()
510
+ {
511
+ if (typeof _config !== 'object')
512
+ return;
513
+
514
+ if (typeof _config.delimiter === 'string'
515
+ && !Papa.BAD_DELIMITERS.filter(function(value) { return _config.delimiter.indexOf(value) !== -1; }).length)
516
+ {
517
+ _delimiter = _config.delimiter;
518
+ }
519
+
520
+ if (typeof _config.quotes === 'boolean'
521
+ || typeof _config.quotes === 'function'
522
+ || Array.isArray(_config.quotes))
523
+ _quotes = _config.quotes;
524
+
525
+ if (typeof _config.skipEmptyLines === 'boolean'
526
+ || typeof _config.skipEmptyLines === 'string')
527
+ _skipEmptyLines = _config.skipEmptyLines;
528
+
529
+ if (typeof _config.newline === 'string')
530
+ _newline = _config.newline;
531
+
532
+ if (typeof _config.quoteChar === 'string')
533
+ _quoteChar = _config.quoteChar;
534
+
535
+ if (typeof _config.header === 'boolean')
536
+ _writeHeader = _config.header;
537
+
538
+ if (Array.isArray(_config.columns)) {
539
+
540
+ if (_config.columns.length === 0) throw new Error('Option columns is empty');
541
+
542
+ _columns = _config.columns;
543
+ }
544
+
545
+ if (_config.escapeChar !== undefined) {
546
+ _escapedQuote = _config.escapeChar + _quoteChar;
547
+ }
548
+
549
+ if (typeof _config.escapeFormulae === 'boolean' || _config.escapeFormulae instanceof RegExp) {
550
+ _escapeFormulae = _config.escapeFormulae instanceof RegExp ? _config.escapeFormulae : /^[=+\-@\t\r].*$/;
551
+ }
552
+ }
553
+
554
+ /** The double for loop that iterates the data and writes out a CSV string including header row */
555
+ function serialize(fields, data, skipEmptyLines)
556
+ {
557
+ var csv = '';
558
+
559
+ if (typeof fields === 'string')
560
+ fields = JSON.parse(fields);
561
+ if (typeof data === 'string')
562
+ data = JSON.parse(data);
563
+
564
+ var hasHeader = Array.isArray(fields) && fields.length > 0;
565
+ var dataKeyedByField = !(Array.isArray(data[0]));
566
+
567
+ // If there a header row, write it first
568
+ if (hasHeader && _writeHeader)
569
+ {
570
+ for (var i = 0; i < fields.length; i++)
571
+ {
572
+ if (i > 0)
573
+ csv += _delimiter;
574
+ csv += safe(fields[i], i);
575
+ }
576
+ if (data.length > 0)
577
+ csv += _newline;
578
+ }
579
+
580
+ // Then write out the data
581
+ for (var row = 0; row < data.length; row++)
582
+ {
583
+ var maxCol = hasHeader ? fields.length : data[row].length;
584
+
585
+ var emptyLine = false;
586
+ var nullLine = hasHeader ? Object.keys(data[row]).length === 0 : data[row].length === 0;
587
+ if (skipEmptyLines && !hasHeader)
588
+ {
589
+ emptyLine = skipEmptyLines === 'greedy' ? data[row].join('').trim() === '' : data[row].length === 1 && data[row][0].length === 0;
590
+ }
591
+ if (skipEmptyLines === 'greedy' && hasHeader) {
592
+ var line = [];
593
+ for (var c = 0; c < maxCol; c++) {
594
+ var cx = dataKeyedByField ? fields[c] : c;
595
+ line.push(data[row][cx]);
596
+ }
597
+ emptyLine = line.join('').trim() === '';
598
+ }
599
+ if (!emptyLine)
600
+ {
601
+ for (var col = 0; col < maxCol; col++)
602
+ {
603
+ if (col > 0 && !nullLine)
604
+ csv += _delimiter;
605
+ var colIdx = hasHeader && dataKeyedByField ? fields[col] : col;
606
+ csv += safe(data[row][colIdx], col);
607
+ }
608
+ if (row < data.length - 1 && (!skipEmptyLines || (maxCol > 0 && !nullLine)))
609
+ {
610
+ csv += _newline;
611
+ }
612
+ }
613
+ }
614
+ return csv;
615
+ }
616
+
617
+ /** Encloses a value around quotes if needed (makes a value safe for CSV insertion) */
618
+ function safe(str, col)
619
+ {
620
+ if (typeof str === 'undefined' || str === null)
621
+ return '';
622
+
623
+ if (str.constructor === Date)
624
+ return JSON.stringify(str).slice(1, 25);
625
+
626
+ var needsQuotes = false;
627
+
628
+ if (_escapeFormulae && typeof str === "string" && _escapeFormulae.test(str)) {
629
+ str = "'" + str;
630
+ needsQuotes = true;
631
+ }
632
+
633
+ var escapedQuoteStr = str.toString().replace(quoteCharRegex, _escapedQuote);
634
+
635
+ needsQuotes = needsQuotes
636
+ || _quotes === true
637
+ || (typeof _quotes === 'function' && _quotes(str, col))
638
+ || (Array.isArray(_quotes) && _quotes[col])
639
+ || hasAny(escapedQuoteStr, Papa.BAD_DELIMITERS)
640
+ || escapedQuoteStr.indexOf(_delimiter) > -1
641
+ || escapedQuoteStr.charAt(0) === ' '
642
+ || escapedQuoteStr.charAt(escapedQuoteStr.length - 1) === ' ';
643
+
644
+ return needsQuotes ? _quoteChar + escapedQuoteStr + _quoteChar : escapedQuoteStr;
645
+ }
646
+
647
+ function hasAny(str, substrings)
648
+ {
649
+ for (var i = 0; i < substrings.length; i++)
650
+ if (str.indexOf(substrings[i]) > -1)
651
+ return true;
652
+ return false;
653
+ }
654
+ }
655
+
656
+ /** ChunkStreamer is the base prototype for various streamer implementations. */
657
+ function ChunkStreamer(config)
658
+ {
659
+ this._handle = null;
660
+ this._finished = false;
661
+ this._completed = false;
662
+ this._halted = false;
663
+ this._input = null;
664
+ this._baseIndex = 0;
665
+ this._partialLine = '';
666
+ this._rowCount = 0;
667
+ this._start = 0;
668
+ this._nextChunk = null;
669
+ this.isFirstChunk = true;
670
+ this._completeResults = {
671
+ data: [],
672
+ errors: [],
673
+ meta: {}
674
+ };
675
+ replaceConfig.call(this, config);
676
+
677
+ this.parseChunk = function(chunk, isFakeChunk)
678
+ {
679
+ // First chunk pre-processing
680
+ if (this.isFirstChunk && isFunction(this._config.beforeFirstChunk))
681
+ {
682
+ var modifiedChunk = this._config.beforeFirstChunk(chunk);
683
+ if (modifiedChunk !== undefined)
684
+ chunk = modifiedChunk;
685
+ }
686
+ this.isFirstChunk = false;
687
+ this._halted = false;
688
+
689
+ // Rejoin the line we likely just split in two by chunking the file
690
+ var aggregate = this._partialLine + chunk;
691
+ this._partialLine = '';
692
+
693
+ var results = this._handle.parse(aggregate, this._baseIndex, !this._finished);
694
+
695
+ if (this._handle.paused() || this._handle.aborted()) {
696
+ this._halted = true;
697
+ return;
698
+ }
699
+
700
+ var lastIndex = results.meta.cursor;
701
+
702
+ if (!this._finished)
703
+ {
704
+ this._partialLine = aggregate.substring(lastIndex - this._baseIndex);
705
+ this._baseIndex = lastIndex;
706
+ }
707
+
708
+ if (results && results.data)
709
+ this._rowCount += results.data.length;
710
+
711
+ var finishedIncludingPreview = this._finished || (this._config.preview && this._rowCount >= this._config.preview);
712
+
713
+ if (IS_PAPA_WORKER)
714
+ {
715
+ global.postMessage({
716
+ results: results,
717
+ workerId: Papa.WORKER_ID,
718
+ finished: finishedIncludingPreview
719
+ });
720
+ }
721
+ else if (isFunction(this._config.chunk) && !isFakeChunk)
722
+ {
723
+ this._config.chunk(results, this._handle);
724
+ if (this._handle.paused() || this._handle.aborted()) {
725
+ this._halted = true;
726
+ return;
727
+ }
728
+ results = undefined;
729
+ this._completeResults = undefined;
730
+ }
731
+
732
+ if (!this._config.step && !this._config.chunk) {
733
+ this._completeResults.data = this._completeResults.data.concat(results.data);
734
+ this._completeResults.errors = this._completeResults.errors.concat(results.errors);
735
+ this._completeResults.meta = results.meta;
736
+ }
737
+
738
+ if (!this._completed && finishedIncludingPreview && isFunction(this._config.complete) && (!results || !results.meta.aborted)) {
739
+ this._config.complete(this._completeResults, this._input);
740
+ this._completed = true;
741
+ }
742
+
743
+ if (!finishedIncludingPreview && (!results || !results.meta.paused))
744
+ this._nextChunk();
745
+
746
+ return results;
747
+ };
748
+
749
+ this._sendError = function(error)
750
+ {
751
+ if (isFunction(this._config.error))
752
+ this._config.error(error);
753
+ else if (IS_PAPA_WORKER && this._config.error)
754
+ {
755
+ global.postMessage({
756
+ workerId: Papa.WORKER_ID,
757
+ error: error,
758
+ finished: false
759
+ });
760
+ }
761
+ };
762
+
763
+ function replaceConfig(config)
764
+ {
765
+ // Deep-copy the config so we can edit it
766
+ var configCopy = copy(config);
767
+ configCopy.chunkSize = parseInt(configCopy.chunkSize); // parseInt VERY important so we don't concatenate strings!
768
+ if (!config.step && !config.chunk)
769
+ configCopy.chunkSize = null; // disable Range header if not streaming; bad values break IIS - see issue #196
770
+ this._handle = new ParserHandle(configCopy);
771
+ this._handle.streamer = this;
772
+ this._config = configCopy; // persist the copy to the caller
773
+ }
774
+ }
775
+
776
+
777
+ function NetworkStreamer(config)
778
+ {
779
+ config = config || {};
780
+ if (!config.chunkSize)
781
+ config.chunkSize = Papa.RemoteChunkSize;
782
+ ChunkStreamer.call(this, config);
783
+
784
+ var xhr;
785
+
786
+ if (IS_WORKER)
787
+ {
788
+ this._nextChunk = function()
789
+ {
790
+ this._readChunk();
791
+ this._chunkLoaded();
792
+ };
793
+ }
794
+ else
795
+ {
796
+ this._nextChunk = function()
797
+ {
798
+ this._readChunk();
799
+ };
800
+ }
801
+
802
+ this.stream = function(url)
803
+ {
804
+ this._input = url;
805
+ this._nextChunk(); // Starts streaming
806
+ };
807
+
808
+ this._readChunk = function()
809
+ {
810
+ if (this._finished)
811
+ {
812
+ this._chunkLoaded();
813
+ return;
814
+ }
815
+
816
+ xhr = new XMLHttpRequest();
817
+
818
+ if (this._config.withCredentials)
819
+ {
820
+ xhr.withCredentials = this._config.withCredentials;
821
+ }
822
+
823
+ if (!IS_WORKER)
824
+ {
825
+ xhr.onload = bindFunction(this._chunkLoaded, this);
826
+ xhr.onerror = bindFunction(this._chunkError, this);
827
+ }
828
+
829
+ xhr.open(this._config.downloadRequestBody ? 'POST' : 'GET', this._input, !IS_WORKER);
830
+ // Headers can only be set when once the request state is OPENED
831
+ if (this._config.downloadRequestHeaders)
832
+ {
833
+ var headers = this._config.downloadRequestHeaders;
834
+
835
+ for (var headerName in headers)
836
+ {
837
+ xhr.setRequestHeader(headerName, headers[headerName]);
838
+ }
839
+ }
840
+
841
+ if (this._config.chunkSize)
842
+ {
843
+ var end = this._start + this._config.chunkSize - 1; // minus one because byte range is inclusive
844
+ xhr.setRequestHeader('Range', 'bytes=' + this._start + '-' + end);
845
+ }
846
+
847
+ try {
848
+ xhr.send(this._config.downloadRequestBody);
849
+ }
850
+ catch (err) {
851
+ this._chunkError(err.message);
852
+ }
853
+
854
+ if (IS_WORKER && xhr.status === 0)
855
+ this._chunkError();
856
+ };
857
+
858
+ this._chunkLoaded = function()
859
+ {
860
+ if (xhr.readyState !== 4)
861
+ return;
862
+
863
+ if (xhr.status < 200 || xhr.status >= 400)
864
+ {
865
+ this._chunkError();
866
+ return;
867
+ }
868
+
869
+ // Use chunckSize as it may be a diference on reponse lentgh due to characters with more than 1 byte
870
+ this._start += this._config.chunkSize ? this._config.chunkSize : xhr.responseText.length;
871
+ this._finished = !this._config.chunkSize || this._start >= getFileSize(xhr);
872
+ this.parseChunk(xhr.responseText);
873
+ };
874
+
875
+ this._chunkError = function(errorMessage)
876
+ {
877
+ var errorText = xhr.statusText || errorMessage;
878
+ this._sendError(new Error(errorText));
879
+ };
880
+
881
+ function getFileSize(xhr)
882
+ {
883
+ var contentRange = xhr.getResponseHeader('Content-Range');
884
+ if (contentRange === null) { // no content range, then finish!
885
+ return -1;
886
+ }
887
+ return parseInt(contentRange.substring(contentRange.lastIndexOf('/') + 1));
888
+ }
889
+ }
890
+ NetworkStreamer.prototype = Object.create(ChunkStreamer.prototype);
891
+ NetworkStreamer.prototype.constructor = NetworkStreamer;
892
+
893
+
894
+ function FileStreamer(config)
895
+ {
896
+ config = config || {};
897
+ if (!config.chunkSize)
898
+ config.chunkSize = Papa.LocalChunkSize;
899
+ ChunkStreamer.call(this, config);
900
+
901
+ var reader, slice;
902
+
903
+ // FileReader is better than FileReaderSync (even in worker) - see http://stackoverflow.com/q/24708649/1048862
904
+ // But Firefox is a pill, too - see issue #76: https://github.com/mholt/PapaParse/issues/76
905
+ var usingAsyncReader = typeof FileReader !== 'undefined'; // Safari doesn't consider it a function - see issue #105
906
+
907
+ this.stream = function(file)
908
+ {
909
+ this._input = file;
910
+ slice = file.slice || file.webkitSlice || file.mozSlice;
911
+
912
+ if (usingAsyncReader)
913
+ {
914
+ reader = new FileReader(); // Preferred method of reading files, even in workers
915
+ reader.onload = bindFunction(this._chunkLoaded, this);
916
+ reader.onerror = bindFunction(this._chunkError, this);
917
+ }
918
+ else
919
+ reader = new FileReaderSync(); // Hack for running in a web worker in Firefox
920
+
921
+ this._nextChunk(); // Starts streaming
922
+ };
923
+
924
+ this._nextChunk = function()
925
+ {
926
+ if (!this._finished && (!this._config.preview || this._rowCount < this._config.preview))
927
+ this._readChunk();
928
+ };
929
+
930
+ this._readChunk = function()
931
+ {
932
+ var input = this._input;
933
+ if (this._config.chunkSize)
934
+ {
935
+ var end = Math.min(this._start + this._config.chunkSize, this._input.size);
936
+ input = slice.call(input, this._start, end);
937
+ }
938
+ var txt = reader.readAsText(input, this._config.encoding);
939
+ if (!usingAsyncReader)
940
+ this._chunkLoaded({ target: { result: txt } }); // mimic the async signature
941
+ };
942
+
943
+ this._chunkLoaded = function(event)
944
+ {
945
+ // Very important to increment start each time before handling results
946
+ this._start += this._config.chunkSize;
947
+ this._finished = !this._config.chunkSize || this._start >= this._input.size;
948
+ this.parseChunk(event.target.result);
949
+ };
950
+
951
+ this._chunkError = function()
952
+ {
953
+ this._sendError(reader.error);
954
+ };
955
+
956
+ }
957
+ FileStreamer.prototype = Object.create(ChunkStreamer.prototype);
958
+ FileStreamer.prototype.constructor = FileStreamer;
959
+
960
+
961
+ function StringStreamer(config)
962
+ {
963
+ config = config || {};
964
+ ChunkStreamer.call(this, config);
965
+
966
+ var remaining;
967
+ this.stream = function(s)
968
+ {
969
+ remaining = s;
970
+ return this._nextChunk();
971
+ };
972
+ this._nextChunk = function()
973
+ {
974
+ if (this._finished) return;
975
+ var size = this._config.chunkSize;
976
+ var chunk;
977
+ if(size) {
978
+ chunk = remaining.substring(0, size);
979
+ remaining = remaining.substring(size);
980
+ } else {
981
+ chunk = remaining;
982
+ remaining = '';
983
+ }
984
+ this._finished = !remaining;
985
+ return this.parseChunk(chunk);
986
+ };
987
+ }
988
+ StringStreamer.prototype = Object.create(StringStreamer.prototype);
989
+ StringStreamer.prototype.constructor = StringStreamer;
990
+
991
+
992
+ function ReadableStreamStreamer(config)
993
+ {
994
+ config = config || {};
995
+
996
+ ChunkStreamer.call(this, config);
997
+
998
+ var queue = [];
999
+ var parseOnData = true;
1000
+ var streamHasEnded = false;
1001
+
1002
+ this.pause = function()
1003
+ {
1004
+ ChunkStreamer.prototype.pause.apply(this, arguments);
1005
+ this._input.pause();
1006
+ };
1007
+
1008
+ this.resume = function()
1009
+ {
1010
+ ChunkStreamer.prototype.resume.apply(this, arguments);
1011
+ this._input.resume();
1012
+ };
1013
+
1014
+ this.stream = function(stream)
1015
+ {
1016
+ this._input = stream;
1017
+
1018
+ this._input.on('data', this._streamData);
1019
+ this._input.on('end', this._streamEnd);
1020
+ this._input.on('error', this._streamError);
1021
+ };
1022
+
1023
+ this._checkIsFinished = function()
1024
+ {
1025
+ if (streamHasEnded && queue.length === 1) {
1026
+ this._finished = true;
1027
+ }
1028
+ };
1029
+
1030
+ this._nextChunk = function()
1031
+ {
1032
+ this._checkIsFinished();
1033
+ if (queue.length)
1034
+ {
1035
+ this.parseChunk(queue.shift());
1036
+ }
1037
+ else
1038
+ {
1039
+ parseOnData = true;
1040
+ }
1041
+ };
1042
+
1043
+ this._streamData = bindFunction(function(chunk)
1044
+ {
1045
+ try
1046
+ {
1047
+ queue.push(typeof chunk === 'string' ? chunk : chunk.toString(this._config.encoding));
1048
+
1049
+ if (parseOnData)
1050
+ {
1051
+ parseOnData = false;
1052
+ this._checkIsFinished();
1053
+ this.parseChunk(queue.shift());
1054
+ }
1055
+ }
1056
+ catch (error)
1057
+ {
1058
+ this._streamError(error);
1059
+ }
1060
+ }, this);
1061
+
1062
+ this._streamError = bindFunction(function(error)
1063
+ {
1064
+ this._streamCleanUp();
1065
+ this._sendError(error);
1066
+ }, this);
1067
+
1068
+ this._streamEnd = bindFunction(function()
1069
+ {
1070
+ this._streamCleanUp();
1071
+ streamHasEnded = true;
1072
+ this._streamData('');
1073
+ }, this);
1074
+
1075
+ this._streamCleanUp = bindFunction(function()
1076
+ {
1077
+ this._input.removeListener('data', this._streamData);
1078
+ this._input.removeListener('end', this._streamEnd);
1079
+ this._input.removeListener('error', this._streamError);
1080
+ }, this);
1081
+ }
1082
+ ReadableStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
1083
+ ReadableStreamStreamer.prototype.constructor = ReadableStreamStreamer;
1084
+
1085
+
1086
+ function DuplexStreamStreamer(_config) {
1087
+ var Duplex = require$$0.Duplex;
1088
+ var config = copy(_config);
1089
+ var parseOnWrite = true;
1090
+ var writeStreamHasFinished = false;
1091
+ var parseCallbackQueue = [];
1092
+ var stream = null;
1093
+
1094
+ this._onCsvData = function(results)
1095
+ {
1096
+ var data = results.data;
1097
+ if (!stream.push(data) && !this._handle.paused()) {
1098
+ // the writeable consumer buffer has filled up
1099
+ // so we need to pause until more items
1100
+ // can be processed
1101
+ this._handle.pause();
1102
+ }
1103
+ };
1104
+
1105
+ this._onCsvComplete = function()
1106
+ {
1107
+ // node will finish the read stream when
1108
+ // null is pushed
1109
+ stream.push(null);
1110
+ };
1111
+
1112
+ config.step = bindFunction(this._onCsvData, this);
1113
+ config.complete = bindFunction(this._onCsvComplete, this);
1114
+ ChunkStreamer.call(this, config);
1115
+
1116
+ this._nextChunk = function()
1117
+ {
1118
+ if (writeStreamHasFinished && parseCallbackQueue.length === 1) {
1119
+ this._finished = true;
1120
+ }
1121
+ if (parseCallbackQueue.length) {
1122
+ parseCallbackQueue.shift()();
1123
+ } else {
1124
+ parseOnWrite = true;
1125
+ }
1126
+ };
1127
+
1128
+ this._addToParseQueue = function(chunk, callback)
1129
+ {
1130
+ // add to queue so that we can indicate
1131
+ // completion via callback
1132
+ // node will automatically pause the incoming stream
1133
+ // when too many items have been added without their
1134
+ // callback being invoked
1135
+ parseCallbackQueue.push(bindFunction(function() {
1136
+ this.parseChunk(typeof chunk === 'string' ? chunk : chunk.toString(config.encoding));
1137
+ if (isFunction(callback)) {
1138
+ return callback();
1139
+ }
1140
+ }, this));
1141
+ if (parseOnWrite) {
1142
+ parseOnWrite = false;
1143
+ this._nextChunk();
1144
+ }
1145
+ };
1146
+
1147
+ this._onRead = function()
1148
+ {
1149
+ if (this._handle.paused()) {
1150
+ // the writeable consumer can handle more data
1151
+ // so resume the chunk parsing
1152
+ this._handle.resume();
1153
+ }
1154
+ };
1155
+
1156
+ this._onWrite = function(chunk, encoding, callback)
1157
+ {
1158
+ this._addToParseQueue(chunk, callback);
1159
+ };
1160
+
1161
+ this._onWriteComplete = function()
1162
+ {
1163
+ writeStreamHasFinished = true;
1164
+ // have to write empty string
1165
+ // so parser knows its done
1166
+ this._addToParseQueue('');
1167
+ };
1168
+
1169
+ this.getStream = function()
1170
+ {
1171
+ return stream;
1172
+ };
1173
+ stream = new Duplex({
1174
+ readableObjectMode: true,
1175
+ decodeStrings: false,
1176
+ read: bindFunction(this._onRead, this),
1177
+ write: bindFunction(this._onWrite, this)
1178
+ });
1179
+ stream.once('finish', bindFunction(this._onWriteComplete, this));
1180
+ }
1181
+ if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
1182
+ DuplexStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
1183
+ DuplexStreamStreamer.prototype.constructor = DuplexStreamStreamer;
1184
+ }
1185
+
1186
+
1187
+ // Use one ParserHandle per entire CSV file or string
1188
+ function ParserHandle(_config)
1189
+ {
1190
+ // One goal is to minimize the use of regular expressions...
1191
+ var MAX_FLOAT = Math.pow(2, 53);
1192
+ var MIN_FLOAT = -MAX_FLOAT;
1193
+ var FLOAT = /^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/;
1194
+ 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)))$/;
1195
+ var self = this;
1196
+ var _stepCounter = 0; // Number of times step was called (number of rows parsed)
1197
+ var _rowCounter = 0; // Number of rows that have been parsed so far
1198
+ var _input; // The input being parsed
1199
+ var _parser; // The core parser being used
1200
+ var _paused = false; // Whether we are paused or not
1201
+ var _aborted = false; // Whether the parser has aborted or not
1202
+ var _delimiterError; // Temporary state between delimiter detection and processing results
1203
+ var _fields = []; // Fields are from the header row of the input, if there is one
1204
+ var _results = { // The last results returned from the parser
1205
+ data: [],
1206
+ errors: [],
1207
+ meta: {}
1208
+ };
1209
+
1210
+ if (isFunction(_config.step))
1211
+ {
1212
+ var userStep = _config.step;
1213
+ _config.step = function(results)
1214
+ {
1215
+ _results = results;
1216
+
1217
+ if (needsHeaderRow())
1218
+ processResults();
1219
+ else // only call user's step function after header row
1220
+ {
1221
+ processResults();
1222
+
1223
+ // It's possbile that this line was empty and there's no row here after all
1224
+ if (_results.data.length === 0)
1225
+ return;
1226
+
1227
+ _stepCounter += results.data.length;
1228
+ if (_config.preview && _stepCounter > _config.preview)
1229
+ _parser.abort();
1230
+ else {
1231
+ _results.data = _results.data[0];
1232
+ userStep(_results, self);
1233
+ }
1234
+ }
1235
+ };
1236
+ }
1237
+
1238
+ /**
1239
+ * Parses input. Most users won't need, and shouldn't mess with, the baseIndex
1240
+ * and ignoreLastRow parameters. They are used by streamers (wrapper functions)
1241
+ * when an input comes in multiple chunks, like from a file.
1242
+ */
1243
+ this.parse = function(input, baseIndex, ignoreLastRow)
1244
+ {
1245
+ var quoteChar = _config.quoteChar || '"';
1246
+ if (!_config.newline)
1247
+ _config.newline = guessLineEndings(input, quoteChar);
1248
+
1249
+ _delimiterError = false;
1250
+ if (!_config.delimiter)
1251
+ {
1252
+ var delimGuess = guessDelimiter(input, _config.newline, _config.skipEmptyLines, _config.comments, _config.delimitersToGuess);
1253
+ if (delimGuess.successful)
1254
+ _config.delimiter = delimGuess.bestDelimiter;
1255
+ else
1256
+ {
1257
+ _delimiterError = true; // add error after parsing (otherwise it would be overwritten)
1258
+ _config.delimiter = Papa.DefaultDelimiter;
1259
+ }
1260
+ _results.meta.delimiter = _config.delimiter;
1261
+ }
1262
+ else if(isFunction(_config.delimiter))
1263
+ {
1264
+ _config.delimiter = _config.delimiter(input);
1265
+ _results.meta.delimiter = _config.delimiter;
1266
+ }
1267
+
1268
+ var parserConfig = copy(_config);
1269
+ if (_config.preview && _config.header)
1270
+ parserConfig.preview++; // to compensate for header row
1271
+
1272
+ _input = input;
1273
+ _parser = new Parser(parserConfig);
1274
+ _results = _parser.parse(_input, baseIndex, ignoreLastRow);
1275
+ processResults();
1276
+ return _paused ? { meta: { paused: true } } : (_results || { meta: { paused: false } });
1277
+ };
1278
+
1279
+ this.paused = function()
1280
+ {
1281
+ return _paused;
1282
+ };
1283
+
1284
+ this.pause = function()
1285
+ {
1286
+ _paused = true;
1287
+ _parser.abort();
1288
+
1289
+ // If it is streaming via "chunking", the reader will start appending correctly already so no need to substring,
1290
+ // otherwise we can get duplicate content within a row
1291
+ _input = isFunction(_config.chunk) ? "" : _input.substring(_parser.getCharIndex());
1292
+ };
1293
+
1294
+ this.resume = function()
1295
+ {
1296
+ if(self.streamer._halted) {
1297
+ _paused = false;
1298
+ self.streamer.parseChunk(_input, true);
1299
+ } else {
1300
+ // Bugfix: #636 In case the processing hasn't halted yet
1301
+ // wait for it to halt in order to resume
1302
+ setTimeout(self.resume, 3);
1303
+ }
1304
+ };
1305
+
1306
+ this.aborted = function()
1307
+ {
1308
+ return _aborted;
1309
+ };
1310
+
1311
+ this.abort = function()
1312
+ {
1313
+ _aborted = true;
1314
+ _parser.abort();
1315
+ _results.meta.aborted = true;
1316
+ if (isFunction(_config.complete))
1317
+ _config.complete(_results);
1318
+ _input = '';
1319
+ };
1320
+
1321
+ function testEmptyLine(s) {
1322
+ return _config.skipEmptyLines === 'greedy' ? s.join('').trim() === '' : s.length === 1 && s[0].length === 0;
1323
+ }
1324
+
1325
+ function testFloat(s) {
1326
+ if (FLOAT.test(s)) {
1327
+ var floatValue = parseFloat(s);
1328
+ if (floatValue > MIN_FLOAT && floatValue < MAX_FLOAT) {
1329
+ return true;
1330
+ }
1331
+ }
1332
+ return false;
1333
+ }
1334
+
1335
+ function processResults()
1336
+ {
1337
+ if (_results && _delimiterError)
1338
+ {
1339
+ addError('Delimiter', 'UndetectableDelimiter', 'Unable to auto-detect delimiting character; defaulted to \'' + Papa.DefaultDelimiter + '\'');
1340
+ _delimiterError = false;
1341
+ }
1342
+
1343
+ if (_config.skipEmptyLines)
1344
+ {
1345
+ _results.data = _results.data.filter(function(d) {
1346
+ return !testEmptyLine(d);
1347
+ });
1348
+ }
1349
+
1350
+ if (needsHeaderRow())
1351
+ fillHeaderFields();
1352
+
1353
+ return applyHeaderAndDynamicTypingAndTransformation();
1354
+ }
1355
+
1356
+ function needsHeaderRow()
1357
+ {
1358
+ return _config.header && _fields.length === 0;
1359
+ }
1360
+
1361
+ function fillHeaderFields()
1362
+ {
1363
+ if (!_results)
1364
+ return;
1365
+
1366
+ function addHeader(header, i)
1367
+ {
1368
+ if (isFunction(_config.transformHeader))
1369
+ header = _config.transformHeader(header, i);
1370
+
1371
+ _fields.push(header);
1372
+ }
1373
+
1374
+ if (Array.isArray(_results.data[0]))
1375
+ {
1376
+ for (var i = 0; needsHeaderRow() && i < _results.data.length; i++)
1377
+ _results.data[i].forEach(addHeader);
1378
+
1379
+ _results.data.splice(0, 1);
1380
+ }
1381
+ // if _results.data[0] is not an array, we are in a step where _results.data is the row.
1382
+ else
1383
+ _results.data.forEach(addHeader);
1384
+ }
1385
+
1386
+ function shouldApplyDynamicTyping(field) {
1387
+ // Cache function values to avoid calling it for each row
1388
+ if (_config.dynamicTypingFunction && _config.dynamicTyping[field] === undefined) {
1389
+ _config.dynamicTyping[field] = _config.dynamicTypingFunction(field);
1390
+ }
1391
+ return (_config.dynamicTyping[field] || _config.dynamicTyping) === true;
1392
+ }
1393
+
1394
+ function parseDynamic(field, value)
1395
+ {
1396
+ if (shouldApplyDynamicTyping(field))
1397
+ {
1398
+ if (value === 'true' || value === 'TRUE')
1399
+ return true;
1400
+ else if (value === 'false' || value === 'FALSE')
1401
+ return false;
1402
+ else if (testFloat(value))
1403
+ return parseFloat(value);
1404
+ else if (ISO_DATE.test(value))
1405
+ return new Date(value);
1406
+ else
1407
+ return (value === '' ? null : value);
1408
+ }
1409
+ return value;
1410
+ }
1411
+
1412
+ function applyHeaderAndDynamicTypingAndTransformation()
1413
+ {
1414
+ if (!_results || (!_config.header && !_config.dynamicTyping && !_config.transform))
1415
+ return _results;
1416
+
1417
+ function processRow(rowSource, i)
1418
+ {
1419
+ var row = _config.header ? {} : [];
1420
+
1421
+ var j;
1422
+ for (j = 0; j < rowSource.length; j++)
1423
+ {
1424
+ var field = j;
1425
+ var value = rowSource[j];
1426
+
1427
+ if (_config.header)
1428
+ field = j >= _fields.length ? '__parsed_extra' : _fields[j];
1429
+
1430
+ if (_config.transform)
1431
+ value = _config.transform(value,field);
1432
+
1433
+ value = parseDynamic(field, value);
1434
+
1435
+ if (field === '__parsed_extra')
1436
+ {
1437
+ row[field] = row[field] || [];
1438
+ row[field].push(value);
1439
+ }
1440
+ else
1441
+ row[field] = value;
1442
+ }
1443
+
1444
+
1445
+ if (_config.header)
1446
+ {
1447
+ if (j > _fields.length)
1448
+ addError('FieldMismatch', 'TooManyFields', 'Too many fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);
1449
+ else if (j < _fields.length)
1450
+ addError('FieldMismatch', 'TooFewFields', 'Too few fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);
1451
+ }
1452
+
1453
+ return row;
1454
+ }
1455
+
1456
+ var incrementBy = 1;
1457
+ if (!_results.data.length || Array.isArray(_results.data[0]))
1458
+ {
1459
+ _results.data = _results.data.map(processRow);
1460
+ incrementBy = _results.data.length;
1461
+ }
1462
+ else
1463
+ _results.data = processRow(_results.data, 0);
1464
+
1465
+
1466
+ if (_config.header && _results.meta)
1467
+ _results.meta.fields = _fields;
1468
+
1469
+ _rowCounter += incrementBy;
1470
+ return _results;
1471
+ }
1472
+
1473
+ function guessDelimiter(input, newline, skipEmptyLines, comments, delimitersToGuess) {
1474
+ var bestDelim, bestDelta, fieldCountPrevRow, maxFieldCount;
1475
+
1476
+ delimitersToGuess = delimitersToGuess || [',', '\t', '|', ';', Papa.RECORD_SEP, Papa.UNIT_SEP];
1477
+
1478
+ for (var i = 0; i < delimitersToGuess.length; i++) {
1479
+ var delim = delimitersToGuess[i];
1480
+ var delta = 0, avgFieldCount = 0, emptyLinesCount = 0;
1481
+ fieldCountPrevRow = undefined;
1482
+
1483
+ var preview = new Parser({
1484
+ comments: comments,
1485
+ delimiter: delim,
1486
+ newline: newline,
1487
+ preview: 10
1488
+ }).parse(input);
1489
+
1490
+ for (var j = 0; j < preview.data.length; j++) {
1491
+ if (skipEmptyLines && testEmptyLine(preview.data[j])) {
1492
+ emptyLinesCount++;
1493
+ continue;
1494
+ }
1495
+ var fieldCount = preview.data[j].length;
1496
+ avgFieldCount += fieldCount;
1497
+
1498
+ if (typeof fieldCountPrevRow === 'undefined') {
1499
+ fieldCountPrevRow = fieldCount;
1500
+ continue;
1501
+ }
1502
+ else if (fieldCount > 0) {
1503
+ delta += Math.abs(fieldCount - fieldCountPrevRow);
1504
+ fieldCountPrevRow = fieldCount;
1505
+ }
1506
+ }
1507
+
1508
+ if (preview.data.length > 0)
1509
+ avgFieldCount /= (preview.data.length - emptyLinesCount);
1510
+
1511
+ if ((typeof bestDelta === 'undefined' || delta <= bestDelta)
1512
+ && (typeof maxFieldCount === 'undefined' || avgFieldCount > maxFieldCount) && avgFieldCount > 1.99) {
1513
+ bestDelta = delta;
1514
+ bestDelim = delim;
1515
+ maxFieldCount = avgFieldCount;
1516
+ }
1517
+ }
1518
+
1519
+ _config.delimiter = bestDelim;
1520
+
1521
+ return {
1522
+ successful: !!bestDelim,
1523
+ bestDelimiter: bestDelim
1524
+ };
1525
+ }
1526
+
1527
+ function guessLineEndings(input, quoteChar)
1528
+ {
1529
+ input = input.substring(0, 1024 * 1024); // max length 1 MB
1530
+ // Replace all the text inside quotes
1531
+ var re = new RegExp(escapeRegExp(quoteChar) + '([^]*?)' + escapeRegExp(quoteChar), 'gm');
1532
+ input = input.replace(re, '');
1533
+
1534
+ var r = input.split('\r');
1535
+
1536
+ var n = input.split('\n');
1537
+
1538
+ var nAppearsFirst = (n.length > 1 && n[0].length < r[0].length);
1539
+
1540
+ if (r.length === 1 || nAppearsFirst)
1541
+ return '\n';
1542
+
1543
+ var numWithN = 0;
1544
+ for (var i = 0; i < r.length; i++)
1545
+ {
1546
+ if (r[i][0] === '\n')
1547
+ numWithN++;
1548
+ }
1549
+
1550
+ return numWithN >= r.length / 2 ? '\r\n' : '\r';
1551
+ }
1552
+
1553
+ function addError(type, code, msg, row)
1554
+ {
1555
+ var error = {
1556
+ type: type,
1557
+ code: code,
1558
+ message: msg
1559
+ };
1560
+ if(row !== undefined) {
1561
+ error.row = row;
1562
+ }
1563
+ _results.errors.push(error);
1564
+ }
1565
+ }
1566
+
1567
+ /** https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions */
1568
+ function escapeRegExp(string)
1569
+ {
1570
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
1571
+ }
1572
+
1573
+ /** The core parser implements speedy and correct CSV parsing */
1574
+ function Parser(config)
1575
+ {
1576
+ // Unpack the config object
1577
+ config = config || {};
1578
+ var delim = config.delimiter;
1579
+ var newline = config.newline;
1580
+ var comments = config.comments;
1581
+ var step = config.step;
1582
+ var preview = config.preview;
1583
+ var fastMode = config.fastMode;
1584
+ var quoteChar;
1585
+ if (config.quoteChar === undefined || config.quoteChar === null) {
1586
+ quoteChar = '"';
1587
+ } else {
1588
+ quoteChar = config.quoteChar;
1589
+ }
1590
+ var escapeChar = quoteChar;
1591
+ if (config.escapeChar !== undefined) {
1592
+ escapeChar = config.escapeChar;
1593
+ }
1594
+
1595
+ // Delimiter must be valid
1596
+ if (typeof delim !== 'string'
1597
+ || Papa.BAD_DELIMITERS.indexOf(delim) > -1)
1598
+ delim = ',';
1599
+
1600
+ // Comment character must be valid
1601
+ if (comments === delim)
1602
+ throw new Error('Comment character same as delimiter');
1603
+ else if (comments === true)
1604
+ comments = '#';
1605
+ else if (typeof comments !== 'string'
1606
+ || Papa.BAD_DELIMITERS.indexOf(comments) > -1)
1607
+ comments = false;
1608
+
1609
+ // Newline must be valid: \r, \n, or \r\n
1610
+ if (newline !== '\n' && newline !== '\r' && newline !== '\r\n')
1611
+ newline = '\n';
1612
+
1613
+ // We're gonna need these at the Parser scope
1614
+ var cursor = 0;
1615
+ var aborted = false;
1616
+
1617
+ this.parse = function(input, baseIndex, ignoreLastRow)
1618
+ {
1619
+ // For some reason, in Chrome, this speeds things up (!?)
1620
+ if (typeof input !== 'string')
1621
+ throw new Error('Input must be a string');
1622
+
1623
+ // We don't need to compute some of these every time parse() is called,
1624
+ // but having them in a more local scope seems to perform better
1625
+ var inputLen = input.length,
1626
+ delimLen = delim.length,
1627
+ newlineLen = newline.length,
1628
+ commentsLen = comments.length;
1629
+ var stepIsFunction = isFunction(step);
1630
+
1631
+ // Establish starting state
1632
+ cursor = 0;
1633
+ var data = [], errors = [], row = [], lastCursor = 0;
1634
+
1635
+ if (!input)
1636
+ return returnable();
1637
+
1638
+ // Rename headers if there are duplicates
1639
+ if (config.header && !baseIndex)
1640
+ {
1641
+ var firstLine = input.split(newline)[0];
1642
+ var headers = firstLine.split(delim);
1643
+ var separator = '_';
1644
+ var headerMap = [];
1645
+ var headerCount = {};
1646
+ var duplicateHeaders = false;
1647
+
1648
+ for (var j in headers) {
1649
+ var header = headers[j];
1650
+ if (isFunction(config.transformHeader))
1651
+ header = config.transformHeader(header, j);
1652
+ var headerName = header;
1653
+
1654
+ var count = headerCount[header] || 0;
1655
+ if (count > 0) {
1656
+ duplicateHeaders = true;
1657
+ headerName = header + separator + count;
1658
+ }
1659
+ headerCount[header] = count + 1;
1660
+ // In case it already exists, we add more separtors
1661
+ while (headerMap.includes(headerName)) {
1662
+ headerName = headerName + separator + count;
1663
+ }
1664
+ headerMap.push(headerName);
1665
+ }
1666
+ if (duplicateHeaders) {
1667
+ var editedInput = input.split(newline);
1668
+ editedInput[0] = headerMap.join(delim);
1669
+ input = editedInput.join(newline);
1670
+ }
1671
+ }
1672
+ if (fastMode || (fastMode !== false && input.indexOf(quoteChar) === -1))
1673
+ {
1674
+ var rows = input.split(newline);
1675
+ for (var i = 0; i < rows.length; i++)
1676
+ {
1677
+ row = rows[i];
1678
+ cursor += row.length;
1679
+ if (i !== rows.length - 1)
1680
+ cursor += newline.length;
1681
+ else if (ignoreLastRow)
1682
+ return returnable();
1683
+ if (comments && row.substring(0, commentsLen) === comments)
1684
+ continue;
1685
+ if (stepIsFunction)
1686
+ {
1687
+ data = [];
1688
+ pushRow(row.split(delim));
1689
+ doStep();
1690
+ if (aborted)
1691
+ return returnable();
1692
+ }
1693
+ else
1694
+ pushRow(row.split(delim));
1695
+ if (preview && i >= preview)
1696
+ {
1697
+ data = data.slice(0, preview);
1698
+ return returnable(true);
1699
+ }
1700
+ }
1701
+ return returnable();
1702
+ }
1703
+
1704
+ var nextDelim = input.indexOf(delim, cursor);
1705
+ var nextNewline = input.indexOf(newline, cursor);
1706
+ var quoteCharRegex = new RegExp(escapeRegExp(escapeChar) + escapeRegExp(quoteChar), 'g');
1707
+ var quoteSearch = input.indexOf(quoteChar, cursor);
1708
+
1709
+ // Parser loop
1710
+ for (;;)
1711
+ {
1712
+ // Field has opening quote
1713
+ if (input[cursor] === quoteChar)
1714
+ {
1715
+ // Start our search for the closing quote where the cursor is
1716
+ quoteSearch = cursor;
1717
+
1718
+ // Skip the opening quote
1719
+ cursor++;
1720
+
1721
+ for (;;)
1722
+ {
1723
+ // Find closing quote
1724
+ quoteSearch = input.indexOf(quoteChar, quoteSearch + 1);
1725
+
1726
+ //No other quotes are found - no other delimiters
1727
+ if (quoteSearch === -1)
1728
+ {
1729
+ if (!ignoreLastRow) {
1730
+ // No closing quote... what a pity
1731
+ errors.push({
1732
+ type: 'Quotes',
1733
+ code: 'MissingQuotes',
1734
+ message: 'Quoted field unterminated',
1735
+ row: data.length, // row has yet to be inserted
1736
+ index: cursor
1737
+ });
1738
+ }
1739
+ return finish();
1740
+ }
1741
+
1742
+ // Closing quote at EOF
1743
+ if (quoteSearch === inputLen - 1)
1744
+ {
1745
+ var value = input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar);
1746
+ return finish(value);
1747
+ }
1748
+
1749
+ // If this quote is escaped, it's part of the data; skip it
1750
+ // If the quote character is the escape character, then check if the next character is the escape character
1751
+ if (quoteChar === escapeChar && input[quoteSearch + 1] === escapeChar)
1752
+ {
1753
+ quoteSearch++;
1754
+ continue;
1755
+ }
1756
+
1757
+ // If the quote character is not the escape character, then check if the previous character was the escape character
1758
+ if (quoteChar !== escapeChar && quoteSearch !== 0 && input[quoteSearch - 1] === escapeChar)
1759
+ {
1760
+ continue;
1761
+ }
1762
+
1763
+ if(nextDelim !== -1 && nextDelim < (quoteSearch + 1)) {
1764
+ nextDelim = input.indexOf(delim, (quoteSearch + 1));
1765
+ }
1766
+ if(nextNewline !== -1 && nextNewline < (quoteSearch + 1)) {
1767
+ nextNewline = input.indexOf(newline, (quoteSearch + 1));
1768
+ }
1769
+ // Check up to nextDelim or nextNewline, whichever is closest
1770
+ var checkUpTo = nextNewline === -1 ? nextDelim : Math.min(nextDelim, nextNewline);
1771
+ var spacesBetweenQuoteAndDelimiter = extraSpaces(checkUpTo);
1772
+
1773
+ // Closing quote followed by delimiter or 'unnecessary spaces + delimiter'
1774
+ if (input.substr(quoteSearch + 1 + spacesBetweenQuoteAndDelimiter, delimLen) === delim)
1775
+ {
1776
+ row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
1777
+ cursor = quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen;
1778
+
1779
+ // If char after following delimiter is not quoteChar, we find next quote char position
1780
+ if (input[quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen] !== quoteChar)
1781
+ {
1782
+ quoteSearch = input.indexOf(quoteChar, cursor);
1783
+ }
1784
+ nextDelim = input.indexOf(delim, cursor);
1785
+ nextNewline = input.indexOf(newline, cursor);
1786
+ break;
1787
+ }
1788
+
1789
+ var spacesBetweenQuoteAndNewLine = extraSpaces(nextNewline);
1790
+
1791
+ // Closing quote followed by newline or 'unnecessary spaces + newLine'
1792
+ if (input.substring(quoteSearch + 1 + spacesBetweenQuoteAndNewLine, quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen) === newline)
1793
+ {
1794
+ row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
1795
+ saveRow(quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen);
1796
+ nextDelim = input.indexOf(delim, cursor); // because we may have skipped the nextDelim in the quoted field
1797
+ quoteSearch = input.indexOf(quoteChar, cursor); // we search for first quote in next line
1798
+
1799
+ if (stepIsFunction)
1800
+ {
1801
+ doStep();
1802
+ if (aborted)
1803
+ return returnable();
1804
+ }
1805
+
1806
+ if (preview && data.length >= preview)
1807
+ return returnable(true);
1808
+
1809
+ break;
1810
+ }
1811
+
1812
+
1813
+ // 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
1814
+ errors.push({
1815
+ type: 'Quotes',
1816
+ code: 'InvalidQuotes',
1817
+ message: 'Trailing quote on quoted field is malformed',
1818
+ row: data.length, // row has yet to be inserted
1819
+ index: cursor
1820
+ });
1821
+
1822
+ quoteSearch++;
1823
+ continue;
1824
+
1825
+ }
1826
+
1827
+ continue;
1828
+ }
1829
+
1830
+ // Comment found at start of new line
1831
+ if (comments && row.length === 0 && input.substring(cursor, cursor + commentsLen) === comments)
1832
+ {
1833
+ if (nextNewline === -1) // Comment ends at EOF
1834
+ return returnable();
1835
+ cursor = nextNewline + newlineLen;
1836
+ nextNewline = input.indexOf(newline, cursor);
1837
+ nextDelim = input.indexOf(delim, cursor);
1838
+ continue;
1839
+ }
1840
+
1841
+ // Next delimiter comes before next newline, so we've reached end of field
1842
+ if (nextDelim !== -1 && (nextDelim < nextNewline || nextNewline === -1))
1843
+ {
1844
+ row.push(input.substring(cursor, nextDelim));
1845
+ cursor = nextDelim + delimLen;
1846
+ // we look for next delimiter char
1847
+ nextDelim = input.indexOf(delim, cursor);
1848
+ continue;
1849
+ }
1850
+
1851
+ // End of row
1852
+ if (nextNewline !== -1)
1853
+ {
1854
+ row.push(input.substring(cursor, nextNewline));
1855
+ saveRow(nextNewline + newlineLen);
1856
+
1857
+ if (stepIsFunction)
1858
+ {
1859
+ doStep();
1860
+ if (aborted)
1861
+ return returnable();
1862
+ }
1863
+
1864
+ if (preview && data.length >= preview)
1865
+ return returnable(true);
1866
+
1867
+ continue;
1868
+ }
1869
+
1870
+ break;
1871
+ }
1872
+
1873
+
1874
+ return finish();
1875
+
1876
+
1877
+ function pushRow(row)
1878
+ {
1879
+ data.push(row);
1880
+ lastCursor = cursor;
1881
+ }
1882
+
1883
+ /**
1884
+ * checks if there are extra spaces after closing quote and given index without any text
1885
+ * if Yes, returns the number of spaces
1886
+ */
1887
+ function extraSpaces(index) {
1888
+ var spaceLength = 0;
1889
+ if (index !== -1) {
1890
+ var textBetweenClosingQuoteAndIndex = input.substring(quoteSearch + 1, index);
1891
+ if (textBetweenClosingQuoteAndIndex && textBetweenClosingQuoteAndIndex.trim() === '') {
1892
+ spaceLength = textBetweenClosingQuoteAndIndex.length;
1893
+ }
1894
+ }
1895
+ return spaceLength;
1896
+ }
1897
+
1898
+ /**
1899
+ * Appends the remaining input from cursor to the end into
1900
+ * row, saves the row, calls step, and returns the results.
1901
+ */
1902
+ function finish(value)
1903
+ {
1904
+ if (ignoreLastRow)
1905
+ return returnable();
1906
+ if (typeof value === 'undefined')
1907
+ value = input.substring(cursor);
1908
+ row.push(value);
1909
+ cursor = inputLen; // important in case parsing is paused
1910
+ pushRow(row);
1911
+ if (stepIsFunction)
1912
+ doStep();
1913
+ return returnable();
1914
+ }
1915
+
1916
+ /**
1917
+ * Appends the current row to the results. It sets the cursor
1918
+ * to newCursor and finds the nextNewline. The caller should
1919
+ * take care to execute user's step function and check for
1920
+ * preview and end parsing if necessary.
1921
+ */
1922
+ function saveRow(newCursor)
1923
+ {
1924
+ cursor = newCursor;
1925
+ pushRow(row);
1926
+ row = [];
1927
+ nextNewline = input.indexOf(newline, cursor);
1928
+ }
1929
+
1930
+ /** Returns an object with the results, errors, and meta. */
1931
+ function returnable(stopped)
1932
+ {
1933
+ return {
1934
+ data: data,
1935
+ errors: errors,
1936
+ meta: {
1937
+ delimiter: delim,
1938
+ linebreak: newline,
1939
+ aborted: aborted,
1940
+ truncated: !!stopped,
1941
+ cursor: lastCursor + (baseIndex || 0)
1942
+ }
1943
+ };
1944
+ }
1945
+
1946
+ /** Executes the user's step function and resets data & errors. */
1947
+ function doStep()
1948
+ {
1949
+ step(returnable());
1950
+ data = [];
1951
+ errors = [];
1952
+ }
1953
+ };
1954
+
1955
+ /** Sets the abort flag */
1956
+ this.abort = function()
1957
+ {
1958
+ aborted = true;
1959
+ };
1960
+
1961
+ /** Gets the cursor position */
1962
+ this.getCharIndex = function()
1963
+ {
1964
+ return cursor;
1965
+ };
1966
+ }
1967
+
1968
+
1969
+ function newWorker()
1970
+ {
1971
+ if (!Papa.WORKERS_SUPPORTED)
1972
+ return false;
1973
+
1974
+ var workerUrl = getWorkerBlob();
1975
+ var w = new global.Worker(workerUrl);
1976
+ w.onmessage = mainThreadReceivedMessage;
1977
+ w.id = workerIdCounter++;
1978
+ workers[w.id] = w;
1979
+ return w;
1980
+ }
1981
+
1982
+ /** Callback when main thread receives a message */
1983
+ function mainThreadReceivedMessage(e)
1984
+ {
1985
+ var msg = e.data;
1986
+ var worker = workers[msg.workerId];
1987
+ var aborted = false;
1988
+
1989
+ if (msg.error)
1990
+ worker.userError(msg.error, msg.file);
1991
+ else if (msg.results && msg.results.data)
1992
+ {
1993
+ var abort = function() {
1994
+ aborted = true;
1995
+ completeWorker(msg.workerId, { data: [], errors: [], meta: { aborted: true } });
1996
+ };
1997
+
1998
+ var handle = {
1999
+ abort: abort,
2000
+ pause: notImplemented,
2001
+ resume: notImplemented
2002
+ };
2003
+
2004
+ if (isFunction(worker.userStep))
2005
+ {
2006
+ for (var i = 0; i < msg.results.data.length; i++)
2007
+ {
2008
+ worker.userStep({
2009
+ data: msg.results.data[i],
2010
+ errors: msg.results.errors,
2011
+ meta: msg.results.meta
2012
+ }, handle);
2013
+ if (aborted)
2014
+ break;
2015
+ }
2016
+ delete msg.results; // free memory ASAP
2017
+ }
2018
+ else if (isFunction(worker.userChunk))
2019
+ {
2020
+ worker.userChunk(msg.results, handle, msg.file);
2021
+ delete msg.results;
2022
+ }
2023
+ }
2024
+
2025
+ if (msg.finished && !aborted)
2026
+ completeWorker(msg.workerId, msg.results);
2027
+ }
2028
+
2029
+ function completeWorker(workerId, results) {
2030
+ var worker = workers[workerId];
2031
+ if (isFunction(worker.userComplete))
2032
+ worker.userComplete(results);
2033
+ worker.terminate();
2034
+ delete workers[workerId];
2035
+ }
2036
+
2037
+ function notImplemented() {
2038
+ throw new Error('Not implemented.');
2039
+ }
2040
+
2041
+ /** Callback when worker thread receives a message */
2042
+ function workerThreadReceivedMessage(e)
2043
+ {
2044
+ var msg = e.data;
2045
+
2046
+ if (typeof Papa.WORKER_ID === 'undefined' && msg)
2047
+ Papa.WORKER_ID = msg.workerId;
2048
+
2049
+ if (typeof msg.input === 'string')
2050
+ {
2051
+ global.postMessage({
2052
+ workerId: Papa.WORKER_ID,
2053
+ results: Papa.parse(msg.input, msg.config),
2054
+ finished: true
2055
+ });
2056
+ }
2057
+ else if ((global.File && msg.input instanceof File) || msg.input instanceof Object) // thank you, Safari (see issue #106)
2058
+ {
2059
+ var results = Papa.parse(msg.input, msg.config);
2060
+ if (results)
2061
+ global.postMessage({
2062
+ workerId: Papa.WORKER_ID,
2063
+ results: results,
2064
+ finished: true
2065
+ });
2066
+ }
2067
+ }
2068
+
2069
+ /** Makes a deep copy of an array or object (mostly) */
2070
+ function copy(obj)
2071
+ {
2072
+ if (typeof obj !== 'object' || obj === null)
2073
+ return obj;
2074
+ var cpy = Array.isArray(obj) ? [] : {};
2075
+ for (var key in obj)
2076
+ cpy[key] = copy(obj[key]);
2077
+ return cpy;
2078
+ }
2079
+
2080
+ function bindFunction(f, self)
2081
+ {
2082
+ return function() { f.apply(self, arguments); };
2083
+ }
2084
+
2085
+ function isFunction(func)
2086
+ {
2087
+ return typeof func === 'function';
2088
+ }
2089
+
2090
+ return Papa;
2091
+ }));
2092
+ } (papaparse));
2093
+
2094
+ var papaparseExports = papaparse.exports;
2095
+ var Papa = /*@__PURE__*/getDefaultExportFromCjs(papaparseExports);
2096
+
2097
+ var isValidEmail = function isValidEmail(email) {
2098
+ return string().email().isValidSync(email);
2099
+ };
2100
+ var createEmailOptions = function createEmailOptions() {
2101
+ var emails = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2102
+ return emails.map(function (email) {
2103
+ return {
2104
+ label: email,
2105
+ value: email,
2106
+ valid: isValidEmail(email)
2107
+ };
2108
+ });
2109
+ };
2110
+ var parseCsvEmails = function parseCsvEmails(file, onSuccess) {
2111
+ Papa.parse(file, {
2112
+ header: true,
2113
+ skipEmptyLines: true,
2114
+ transformHeader: function transformHeader(h) {
2115
+ return h.toLowerCase().replace(/\W/g, "");
2116
+ },
2117
+ complete: function complete(results) {
2118
+ var _results$meta$fields;
2119
+ var isEmailFieldPresent = (_results$meta$fields = results.meta.fields) === null || _results$meta$fields === void 0 ? void 0 : _results$meta$fields.includes("email");
2120
+ if (isEmailFieldPresent) {
2121
+ var emails = results.data.filter(prop("email")).map(function (item) {
2122
+ return item.email.trim();
2123
+ });
2124
+ onSuccess(createEmailOptions(emails));
2125
+ } else {
2126
+ Toastr.error(t("neetoMolecules.sendToFields.errors.invalidCsv"));
2127
+ }
2128
+ }
2129
+ });
2130
+ };
2131
+
2132
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2133
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2134
+ var SendToFields = function SendToFields(_ref) {
2135
+ var emailInputProps = _ref.emailInputProps,
2136
+ ccInputProps = _ref.ccInputProps,
2137
+ bccInputProps = _ref.bccInputProps,
2138
+ _ref$showUploadCsvBut = _ref.showUploadCsvButton,
2139
+ showUploadCsvButton = _ref$showUploadCsvBut === void 0 ? false : _ref$showUploadCsvBut,
2140
+ _ref$showCcBccButton = _ref.showCcBccButton,
2141
+ showCcBccButton = _ref$showCcBccButton === void 0 ? false : _ref$showCcBccButton,
2142
+ _ref$showCcField = _ref.showCcField,
2143
+ showCcField = _ref$showCcField === void 0 ? false : _ref$showCcField,
2144
+ _ref$showBccField = _ref.showBccField,
2145
+ showBccField = _ref$showBccField === void 0 ? false : _ref$showBccField,
2146
+ _ref$showSendToField = _ref.showSendToField,
2147
+ showSendToField = _ref$showSendToField === void 0 ? true : _ref$showSendToField;
2148
+ var _useState = useState(false),
2149
+ _useState2 = _slicedToArray(_useState, 2),
2150
+ isBulkUploadPaneOpen = _useState2[0],
2151
+ setIsBulkUploadPaneOpen = _useState2[1];
2152
+ var sendToFieldRef = useRef();
2153
+ var _useFormikContext = useFormikContext(),
2154
+ _useFormikContext$val = _useFormikContext.values,
2155
+ showCopyEmails = _useFormikContext$val.showCopyEmails,
2156
+ existingSendToEmails = _useFormikContext$val[emailInputProps.name || "sendTo"],
2157
+ setFieldValue = _useFormikContext.setFieldValue;
2158
+ var _useTranslation = useTranslation(),
2159
+ t = _useTranslation.t;
2160
+ var handleCSVFile = function handleCSVFile(file) {
2161
+ try {
2162
+ var _sendToFieldRef$curre;
2163
+ var onSuccess = function onSuccess(values) {
2164
+ return setFieldValue(emailInputProps.name || "sendTo", [].concat(_toConsumableArray(existingSendToEmails), _toConsumableArray(values)));
2165
+ };
2166
+ parseCsvEmails(file, onSuccess);
2167
+ setIsBulkUploadPaneOpen(false);
2168
+ (_sendToFieldRef$curre = sendToFieldRef.current) === null || _sendToFieldRef$curre === void 0 || _sendToFieldRef$curre.focus();
2169
+ } catch (error) {
2170
+ Toastr.error(error);
2171
+ }
2172
+ };
2173
+ var handelCcBccButtonClick = function handelCcBccButtonClick(e) {
2174
+ e.stopPropagation();
2175
+ setFieldValue("showCopyEmails", !showCopyEmails);
2176
+ };
2177
+ return /*#__PURE__*/jsxs("div", {
2178
+ className: "relative w-full flex-col gap-2",
2179
+ "data-testid": "send-to-text-field",
2180
+ children: [showUploadCsvButton && /*#__PURE__*/jsx(Button, {
2181
+ className: "absolute right-1 top-0",
2182
+ "data-testid": "bulk-upload-button",
2183
+ icon: Upload,
2184
+ label: t("neetoMolecules.shareViaLink.bulkUpload"),
2185
+ size: "small",
2186
+ style: "link",
2187
+ onClick: function onClick() {
2188
+ return setIsBulkUploadPaneOpen(true);
2189
+ }
2190
+ }), showSendToField && /*#__PURE__*/jsx(MultiEmailInput, _objectSpread(_objectSpread({
2191
+ name: "sendTo",
2192
+ ref: sendToFieldRef
2193
+ }, emailInputProps), {}, {
2194
+ suffix: showCcBccButton && /*#__PURE__*/jsx(Button, {
2195
+ "data-cy": "cc-bcc-button",
2196
+ "data-testid": "cc-bcc-button",
2197
+ label: t("neetoMolecules.emailForm.labels.ccBcc"),
2198
+ size: "small",
2199
+ style: "link",
2200
+ onClick: handelCcBccButtonClick
2201
+ })
2202
+ })), (showCopyEmails || showCcField || showBccField) && /*#__PURE__*/jsxs("div", {
2203
+ className: "mt-5 flex w-full flex-col gap-6",
2204
+ children: [(showCopyEmails || showCcField) && /*#__PURE__*/jsx(MultiEmailInput, _objectSpread({
2205
+ name: "sendToBcc"
2206
+ }, ccInputProps)), (showCopyEmails || showBccField) && /*#__PURE__*/jsx(MultiEmailInput, _objectSpread({
2207
+ name: "sendToCc"
2208
+ }, bccInputProps))]
2209
+ }), /*#__PURE__*/jsx(BulkUploadPane, {
2210
+ fileSize: CSV_FILE_SIZE_IN_KB,
2211
+ handleFileSubmit: handleCSVFile,
2212
+ isOpen: isBulkUploadPaneOpen,
2213
+ onClose: function onClose() {
2214
+ return setIsBulkUploadPaneOpen(false);
2215
+ }
2216
+ })]
2217
+ });
2218
+ };
2219
+
2220
+ export { SendToFields as default };
2221
+ //# sourceMappingURL=SendToFields.js.map