@commercetools-frontend-extensions/import-resources-modal 0.0.0-canary-20250912103849 → 0.0.0-canary-20251209161906

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 (40) hide show
  1. package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.dev.js +2208 -53
  2. package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.prod.js +2184 -53
  3. package/dist/commercetools-frontend-extensions-import-resources-modal.esm.js +2193 -51
  4. package/dist/declarations/src/@components/current-step.d.ts +1 -0
  5. package/dist/declarations/src/@components/import-resources-modal-provider/import-resources-modal-provider.d.ts +38 -0
  6. package/dist/declarations/src/@components/import-resources-modal-provider/index.d.ts +2 -0
  7. package/dist/declarations/src/@components/import-resources-modal-provider/reducer.d.ts +86 -0
  8. package/dist/declarations/src/@components/index.d.ts +6 -0
  9. package/dist/declarations/src/@components/instructions/index.d.ts +1 -0
  10. package/dist/declarations/src/@components/instructions/instructions.d.ts +1 -0
  11. package/dist/declarations/src/@components/resource-type-selection/index.d.ts +1 -0
  12. package/dist/declarations/src/@components/resource-type-selection/resource-type-selection.d.ts +1 -0
  13. package/dist/declarations/src/@components/upload/index.d.ts +1 -0
  14. package/dist/declarations/src/@components/upload/upload.d.ts +1 -0
  15. package/dist/declarations/src/@components/upload-result/index.d.ts +1 -0
  16. package/dist/declarations/src/@components/upload-result/upload-results.d.ts +1 -0
  17. package/dist/declarations/src/@hooks/use-import-resources-context.d.ts +2 -1
  18. package/dist/declarations/src/@types/index.d.ts +0 -6
  19. package/package.json +23 -23
  20. package/dist/active-drag-drop-area-3ad5dd22.esm.js +0 -60
  21. package/dist/active-drag-drop-area-94cea372.cjs.prod.js +0 -62
  22. package/dist/active-drag-drop-area-edf9d7a9.cjs.dev.js +0 -62
  23. package/dist/declarations/src/@types/api.d.ts +0 -13
  24. package/dist/declarations/src/@types/file-upload.d.ts +0 -60
  25. package/dist/declarations/src/@types/import-container.d.ts +0 -36
  26. package/dist/declarations/src/@types/import-states.d.ts +0 -9
  27. package/dist/declarations/src/@types/import-summary.d.ts +0 -12
  28. package/dist/declarations/src/@types/shared.d.ts +0 -7
  29. package/dist/disabled-drop-area-6af7f861.cjs.dev.js +0 -105
  30. package/dist/disabled-drop-area-d068b119.esm.js +0 -92
  31. package/dist/disabled-drop-area-d8a66b62.cjs.prod.js +0 -105
  32. package/dist/enabled-drop-area-819e5dd2.cjs.dev.js +0 -79
  33. package/dist/enabled-drop-area-b6fe0252.cjs.prod.js +0 -79
  34. package/dist/enabled-drop-area-d5d394ff.esm.js +0 -77
  35. package/dist/file-dropped-area-0e55c4a0.cjs.prod.js +0 -82
  36. package/dist/file-dropped-area-b64c266f.esm.js +0 -80
  37. package/dist/file-dropped-area-d4d52da4.cjs.dev.js +0 -82
  38. package/dist/index-c0e77d3f.cjs.dev.js +0 -2733
  39. package/dist/index-f14adfdc.esm.js +0 -2699
  40. package/dist/index-f96fadf7.cjs.prod.js +0 -2701
@@ -2,60 +2,2191 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_commercetoolsFrontendExtensionsImportResourcesModal = require('./index-f96fadf7.cjs.prod.js');
6
- require('react');
7
- require('@babel/runtime-corejs3/core-js-stable/object/keys');
8
- require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
9
- require('@babel/runtime-corejs3/core-js-stable/instance/filter');
10
- require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
11
- require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
12
- require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
13
- require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
14
- require('@babel/runtime-corejs3/core-js-stable/object/define-property');
15
- require('@babel/runtime-corejs3/helpers/defineProperty');
16
- require('@babel/runtime-corejs3/helpers/slicedToArray');
17
- require('@commercetools-frontend/application-shell-connectors');
18
- require('@commercetools-frontend/sdk');
19
- require('@commercetools-frontend/constants');
20
- require('@commercetools-frontend/application-shell');
21
- require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
22
- require('@babel/runtime-corejs3/helpers/createClass');
23
- require('@babel/runtime-corejs3/helpers/classCallCheck');
24
- require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
25
- require('@babel/runtime-corejs3/helpers/getPrototypeOf');
26
- require('@babel/runtime-corejs3/helpers/inherits');
27
- require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
28
- require('pluralize');
29
- require('@babel/runtime-corejs3/core-js-stable/array/is-array');
30
- require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
31
- require('@babel/runtime-corejs3/core-js-stable/instance/map');
32
- require('@babel/runtime-corejs3/core-js-stable/instance/slice');
33
- require('@babel/runtime-corejs3/core-js-stable/json/stringify');
34
- require('@babel/runtime-corejs3/core-js-stable/instance/some');
35
- require('@babel/runtime-corejs3/core-js-stable/instance/bind');
36
- require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
37
- require('@babel/runtime-corejs3/core-js-stable/url-search-params');
38
- require('@babel/runtime-corejs3/core-js-stable/object/entries');
39
- require('@babel/runtime-corejs3/core-js-stable/instance/every');
40
- require('@emotion/react/jsx-runtime');
41
- require('react-intl');
42
- require('@commercetools-frontend/application-components');
43
- require('@commercetools-frontend/fullstory');
44
- require('@commercetools-frontend/ui-kit');
45
- require('react-dropzone');
46
- require('@commercetools-frontend/actions-global');
47
- require('@emotion/styled/base');
5
+ var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
6
+ var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
7
+ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
8
+ var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
9
+ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
10
+ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
11
+ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
12
+ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
13
+ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
14
+ var _everyInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/every');
15
+ var reactIntl = require('react-intl');
16
+ var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
17
+ var operations = require('@commercetools-frontend-extensions/operations');
18
+ var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
19
+ var React = require('react');
20
+ var jsxRuntime = require('@emotion/react/jsx-runtime');
21
+ var applicationComponents = require('@commercetools-frontend/application-components');
22
+ var fullstory = require('@commercetools-frontend/fullstory');
23
+ var permissions = require('@commercetools-frontend/permissions');
24
+ var uiKit = require('@commercetools-frontend/ui-kit');
25
+ var actionsGlobal = require('@commercetools-frontend/actions-global');
26
+ var constants = require('@commercetools-frontend/constants');
27
+ var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
28
+ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
29
+ var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
30
+ var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
31
+ var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
32
+ var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
33
+ var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
34
+ var applicationShell = require('@commercetools-frontend/application-shell');
35
+ var sentry = require('@commercetools-frontend/sentry');
36
+ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
37
+ var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
38
+ var _styled = require('@emotion/styled/base');
48
39
  require('@emotion/react');
49
- require('@commercetools-frontend/permissions');
50
- require('@commercetools-frontend/sentry');
51
- require('@babel/runtime-corejs3/core-js-stable/promise');
52
- require('@babel/runtime-corejs3/core-js-stable/instance/includes');
53
- require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
54
- require('@babel/runtime-corejs3/core-js-stable/instance/find');
55
- require('papaparse');
56
- require('@commercetools-frontend/i18n');
40
+ var i18n = require('@commercetools-frontend/i18n');
57
41
 
42
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
58
43
 
44
+ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
45
+ var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
46
+ var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
47
+ var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
48
+ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
49
+ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
50
+ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
51
+ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
52
+ var _everyInstanceProperty__default = /*#__PURE__*/_interopDefault(_everyInstanceProperty);
53
+ var React__default = /*#__PURE__*/_interopDefault(React);
54
+ var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
55
+ var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
56
+ var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
57
+ var _styled__default = /*#__PURE__*/_interopDefault(_styled);
59
58
 
60
- exports["default"] = dist_commercetoolsFrontendExtensionsImportResourcesModal.ImportResourcesModal;
61
- exports.useImportPermission = dist_commercetoolsFrontendExtensionsImportResourcesModal.useImportPermission;
59
+ let CurrentStep$1 = /*#__PURE__*/function (CurrentStep) {
60
+ CurrentStep["Upload"] = "upload";
61
+ CurrentStep["Uploading"] = "uploading";
62
+ CurrentStep["UploadResult"] = "upload-result";
63
+ CurrentStep["ImportConfirmationModal"] = "import-confirmation-modal";
64
+ return CurrentStep;
65
+ }({});
66
+
67
+ function ownKeys$a(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
68
+ function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$a(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$a(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
69
+
70
+ // TODO: make this resource type specific
71
+
72
+ function reducer(state, action) {
73
+ if (action.type === 'setCurrentStep') return _objectSpread$a(_objectSpread$a({}, state), {}, {
74
+ currentStep: action.currentStep,
75
+ progress: 0
76
+ });
77
+ if (action.type === 'setUploadFileResponse') return _objectSpread$a(_objectSpread$a({}, state), {}, {
78
+ uploadFileResponse: action.uploadFileResponse
79
+ });
80
+ if (action.type === 'setResourceType') return _objectSpread$a(_objectSpread$a({}, state), {}, {
81
+ resourceType: action.resourceType
82
+ });
83
+ if (action.type === 'setContainerKey') return _objectSpread$a(_objectSpread$a({}, state), {}, {
84
+ containerKey: action.containerKey
85
+ });
86
+ if (action.type === 'cancelImport') return _objectSpread$a(_objectSpread$a({}, state), {}, {
87
+ currentStep: CurrentStep$1.Upload,
88
+ containerKey: undefined,
89
+ jobId: undefined,
90
+ fileUploadErrors: [],
91
+ uploadFileResponse: undefined,
92
+ droppedFile: undefined,
93
+ dropAreaState: 'disabled',
94
+ progress: 0,
95
+ totalResourceCount: undefined,
96
+ validationProcessed: undefined,
97
+ isValidating: false
98
+ });
99
+ if (action.type === 'uploadNewFile') return _objectSpread$a(_objectSpread$a({}, state), {}, {
100
+ currentStep: CurrentStep$1.Upload,
101
+ containerKey: undefined,
102
+ jobId: undefined,
103
+ fileUploadErrors: [],
104
+ uploadFileResponse: undefined,
105
+ droppedFile: undefined,
106
+ dropAreaState: 'ready-for-drop',
107
+ progress: 0,
108
+ totalResourceCount: undefined,
109
+ validationProcessed: undefined,
110
+ isValidating: false
111
+ });
112
+ if (action.type === 'setDroppedFile') {
113
+ return _objectSpread$a(_objectSpread$a({}, state), {}, {
114
+ droppedFile: action.droppedFile
115
+ });
116
+ }
117
+ if (action.type === 'setFileUploadErrors') {
118
+ return _objectSpread$a(_objectSpread$a({}, state), {}, {
119
+ fileUploadErrors: action.fileUploadErrors
120
+ });
121
+ }
122
+ if (action.type === 'setAbortController') {
123
+ return _objectSpread$a(_objectSpread$a({}, state), {}, {
124
+ abortController: action.abortController
125
+ });
126
+ }
127
+ if (action.type === 'setProgress') {
128
+ return _objectSpread$a(_objectSpread$a({}, state), {}, {
129
+ progress: action.progress
130
+ });
131
+ }
132
+ if (action.type === 'setUploadSettings') {
133
+ return _objectSpread$a(_objectSpread$a({}, state), {}, {
134
+ settings: _objectSpread$a(_objectSpread$a({}, state.settings), action.settings)
135
+ });
136
+ }
137
+ if (action.type === 'setJobId') {
138
+ return _objectSpread$a(_objectSpread$a({}, state), {}, {
139
+ jobId: action.jobId
140
+ });
141
+ }
142
+ if (action.type === 'setTotalResourceCount') {
143
+ return _objectSpread$a(_objectSpread$a({}, state), {}, {
144
+ totalResourceCount: action.totalResourceCount
145
+ });
146
+ }
147
+ if (action.type === 'setValidationProgress') {
148
+ return _objectSpread$a(_objectSpread$a({}, state), {}, {
149
+ validationProcessed: action.validationProcessed,
150
+ isValidating: action.isValidating
151
+ });
152
+ }
153
+ throw new Error(getUnknownActionError(action));
154
+ }
155
+ function getUnknownActionError(actionType) {
156
+ return `Unkown type: ${actionType}`;
157
+ }
158
+ const initialState = {
159
+ currentStep: CurrentStep$1.Upload,
160
+ abortController: new AbortController(),
161
+ dropAreaState: 'disabled',
162
+ uploadFileResponse: undefined,
163
+ fileUploadErrors: [],
164
+ resourceType: 'category',
165
+ containerKey: undefined,
166
+ jobId: undefined,
167
+ progress: 0,
168
+ settings: {
169
+ decimalSeparator: '.'
170
+ },
171
+ totalResourceCount: undefined,
172
+ validationProcessed: undefined,
173
+ isValidating: false
174
+ };
175
+ const initialActions = {
176
+ setCurrentStep(_currentStep) {
177
+ /**/
178
+ },
179
+ cancelImport() {
180
+ /**/
181
+ },
182
+ uploadNewFile() {
183
+ /**/
184
+ },
185
+ setUploadFileResponse(_uploadFileResponse) {
186
+ /**/
187
+ },
188
+ setResourceType(_nextResourceType) {
189
+ /**/
190
+ },
191
+ setDroppedFile(_nextDroppedFile) {
192
+ /**/
193
+ },
194
+ setFileUploadErrors(_fileUploadErrors) {
195
+ /**/
196
+ },
197
+ setContainerKey(_containerKey) {
198
+ /**/
199
+ },
200
+ setAbortController(_abortController) {
201
+ /**/
202
+ },
203
+ setUploadSettings(_settings) {
204
+ /**/
205
+ },
206
+ setProgress(_progress) {
207
+ /**/
208
+ },
209
+ setJobId(_jobId) {
210
+ /**/
211
+ },
212
+ setTotalResourceCount(_totalResourceCount) {
213
+ /**/
214
+ },
215
+ setValidationProgress(_params) {
216
+ /**/
217
+ }
218
+ };
219
+
220
+ function ownKeys$9(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
221
+ function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$9(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$9(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
222
+ const ImportResourcesContext = /*#__PURE__*/React__default["default"].createContext({
223
+ state: initialState,
224
+ resourceTypes: [],
225
+ onClose: () => {},
226
+ onStartImportSuccess: () => {},
227
+ actions: initialActions
228
+ });
229
+ const ImportResourcesProvider = props => {
230
+ const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
231
+ projectKey: context.project?.key
232
+ })),
233
+ projectKey = _useApplicationContex.projectKey;
234
+ const _React$useReducer = React__default["default"].useReducer(reducer, _objectSpread$9(_objectSpread$9({}, initialState), {}, {
235
+ resourceType: props.resourceTypes[0]
236
+ })),
237
+ _React$useReducer2 = _slicedToArray(_React$useReducer, 2),
238
+ state = _React$useReducer2[0],
239
+ dispatch = _React$useReducer2[1];
240
+ const setCurrentStep = currentStep => dispatch({
241
+ type: 'setCurrentStep',
242
+ currentStep
243
+ });
244
+ const setUploadFileResponse = uploadFileResponse => dispatch({
245
+ type: 'setUploadFileResponse',
246
+ uploadFileResponse: uploadFileResponse
247
+ });
248
+ const setResourceType = resourceType => dispatch({
249
+ type: 'setResourceType',
250
+ resourceType: resourceType
251
+ });
252
+ const setContainerKey = containerKey => dispatch({
253
+ type: 'setContainerKey',
254
+ containerKey
255
+ });
256
+ const cancelImport = () => dispatch({
257
+ type: 'cancelImport'
258
+ });
259
+ const uploadNewFile = () => dispatch({
260
+ type: 'uploadNewFile'
261
+ });
262
+ const setDroppedFile = droppedFile => dispatch({
263
+ type: 'setDroppedFile',
264
+ droppedFile: droppedFile
265
+ });
266
+ const setAbortController = abortController => dispatch({
267
+ type: 'setAbortController',
268
+ abortController: abortController
269
+ });
270
+ const setFileUploadErrors = fileUploadErrors => dispatch({
271
+ type: 'setFileUploadErrors',
272
+ fileUploadErrors: fileUploadErrors
273
+ });
274
+ const setProgress = progress => dispatch({
275
+ type: 'setProgress',
276
+ progress
277
+ });
278
+ const setUploadSettings = nextSettings => {
279
+ dispatch({
280
+ type: 'setUploadSettings',
281
+ settings: nextSettings
282
+ });
283
+ };
284
+ const setJobId = jobId => dispatch({
285
+ type: 'setJobId',
286
+ jobId
287
+ });
288
+ const setTotalResourceCount = totalResourceCount => dispatch({
289
+ type: 'setTotalResourceCount',
290
+ totalResourceCount
291
+ });
292
+ const setValidationProgress = _ref => {
293
+ let processed = _ref.processed,
294
+ isValidating = _ref.isValidating;
295
+ return dispatch({
296
+ type: 'setValidationProgress',
297
+ validationProcessed: processed,
298
+ isValidating
299
+ });
300
+ };
301
+ const handleClose = function () {
302
+ let _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
303
+ shouldDeleteImportContainer = _ref2.shouldDeleteImportContainer;
304
+ if (state.abortController) state.abortController.abort();
305
+ if (typeof props.onClose === 'function') props.onClose();
306
+ // Removes the associated import container when the import is closed
307
+ if (shouldDeleteImportContainer && projectKey && state.containerKey) operations.deleteImportContainer({
308
+ projectKey,
309
+ importContainerKey: state.containerKey
310
+ });
311
+ };
312
+ const handleStartImportSuccess = () => {
313
+ if (typeof props.onStartImportSuccess === 'function') props.onStartImportSuccess();
314
+ };
315
+ return jsxRuntime.jsx(ImportResourcesContext.Provider, {
316
+ value: {
317
+ state,
318
+ resourceTypes: props.resourceTypes,
319
+ onClose: handleClose,
320
+ onStartImportSuccess: handleStartImportSuccess,
321
+ actions: {
322
+ setCurrentStep,
323
+ cancelImport,
324
+ uploadNewFile,
325
+ setUploadFileResponse,
326
+ setResourceType,
327
+ setDroppedFile,
328
+ setContainerKey,
329
+ setJobId,
330
+ setAbortController,
331
+ setFileUploadErrors,
332
+ setProgress,
333
+ setUploadSettings,
334
+ setTotalResourceCount,
335
+ setValidationProgress
336
+ }
337
+ },
338
+ children: props.children
339
+ });
340
+ };
341
+
342
+ function getDropArea(_ref) {
343
+ let dropAreaState = _ref.dropAreaState,
344
+ resourceType = _ref.resourceType,
345
+ isFileDropped = _ref.isFileDropped,
346
+ fileName = _ref.fileName,
347
+ messages = _ref.messages;
348
+ if (dropAreaState === 'file-dropped') {
349
+ return jsxRuntime.jsx(operations.FileDroppedArea, {
350
+ fileName: fileName,
351
+ chooseFileLabel: messages.chooseFile
352
+ });
353
+ }
354
+ if (dropAreaState === 'disabled' || !resourceType) {
355
+ return jsxRuntime.jsx(operations.DisabledDropArea, {});
356
+ }
357
+ if (dropAreaState === 'ready-for-drop') {
358
+ return jsxRuntime.jsx(operations.EnabledDropArea, {
359
+ dragAndDropText: messages.dragAndDropCSV,
360
+ orText: messages.or,
361
+ browseFileText: messages.browseButton
362
+ });
363
+ }
364
+ if (dropAreaState === 'active-drag') {
365
+ return jsxRuntime.jsx(operations.ActiveDragDropArea, {
366
+ isFileDropped: isFileDropped,
367
+ fileName: fileName,
368
+ chooseFileLabel: messages.chooseFile,
369
+ dragAndDropText: messages.dragAndDropCSV,
370
+ orText: messages.or,
371
+ browseFileText: messages.browseButton
372
+ });
373
+ }
374
+ return fallbackDropArea();
375
+ }
376
+ function fallbackDropArea(_dropAreaState) {
377
+ return jsxRuntime.jsx(operations.DisabledDropArea, {});
378
+ }
379
+ function getDropAreaState(flags) {
380
+ if (flags.isDragActive) {
381
+ return 'active-drag';
382
+ }
383
+ if (flags.hasResourceType) {
384
+ return 'disabled';
385
+ }
386
+ if (flags.isReady) {
387
+ return 'file-dropped';
388
+ }
389
+ return 'ready-for-drop';
390
+ }
391
+
392
+ var messages$6 = reactIntl.defineMessages({
393
+ dragAndDropCSV: {
394
+ id: 'ImportResourcesModal.dragAndDropCSV',
395
+ description: 'The message telling the user to drag and drop CSV file in the file drop area',
396
+ defaultMessage: 'Drag and drop CSV'
397
+ },
398
+ or: {
399
+ id: 'ImportResourcesModal.or',
400
+ description: 'The word "or" in the drag and drop message',
401
+ defaultMessage: 'or'
402
+ },
403
+ browseButton: {
404
+ id: 'ImportResourcesModal.browseFile',
405
+ defaultMessage: 'Browse file'
406
+ },
407
+ uploadFile: {
408
+ id: 'ImportResourcesModal.uploadFile',
409
+ description: 'Label for a button on the file upload page, shown on active drop area state',
410
+ defaultMessage: 'Upload file'
411
+ },
412
+ chooseFile: {
413
+ id: 'ImportResourcesModal.chooseFile',
414
+ description: 'Label for a button on the file upload page, shown on ready to upload state',
415
+ defaultMessage: 'Choose file'
416
+ },
417
+ fileUploadFailed: {
418
+ id: 'ImportResourcesModal.fileUploadFailed',
419
+ description: 'A title on the file upload page, shown on file upload error state',
420
+ defaultMessage: 'File upload failed'
421
+ },
422
+ fileFormatNotSupported: {
423
+ id: 'ImportResourcesModal.fileFormatNotSupported',
424
+ description: 'Error message displayed when a user drags and drops a non-CSV file',
425
+ defaultMessage: 'Invalid file format: The file is not in CSV format and cannot be processed.'
426
+ },
427
+ tooManyFilesError: {
428
+ id: 'ImportResourcesModal.tooManyFilesError',
429
+ description: 'Error message displayed when a user drags and drops multiple files at once',
430
+ defaultMessage: 'Multiple files detected: You can only drag and drop one file at a time.'
431
+ },
432
+ genericError: {
433
+ id: 'ImportResourcesModal.genericError',
434
+ description: 'Default error message for unexpected file upload issues (for unhandled cases)',
435
+ defaultMessage: 'Error occurred: Please try uploading the file again or contact our support team for assistance.'
436
+ },
437
+ dataType: {
438
+ id: 'ImportResourcesModal.dataType',
439
+ description: 'Label for the data type selection dropdown',
440
+ defaultMessage: 'Data type'
441
+ },
442
+ instructions: {
443
+ id: 'ImportResourcesModal.instructions',
444
+ description: 'Label for the instructions section',
445
+ defaultMessage: 'Instructions'
446
+ },
447
+ prerequisitesOfImportingData: {
448
+ id: 'ImportResourcesModal.infoBox.prerequisitesOfImportingData',
449
+ description: 'A message to guide users to check the prerequisites of importing data',
450
+ defaultMessage: 'Prerequisites of importing data'
451
+ },
452
+ keysForEveryResource: {
453
+ id: 'ImportResourcesModal.infoBox.keysForEveryResource',
454
+ description: 'A message to guide users to provide keys for every resource they import',
455
+ defaultMessage: 'You must provide keys for every resource you import, including embedded resources such as Prices and Assets. Please consult with your admins to assign keys through <link>the HTTP API</link>.'
456
+ },
457
+ publishProducts: {
458
+ id: 'ImportResourcesModal.settings.publishProducts',
459
+ description: 'Label for the publish products checkbox',
460
+ defaultMessage: 'Publish all products in the file'
461
+ },
462
+ separatorTitle: {
463
+ id: 'ImportResourcesModal.uploadSeparator.separatorTitle',
464
+ description: 'Title for the separator selection',
465
+ defaultMessage: 'Separator'
466
+ },
467
+ decimalsSeparatorDescription: {
468
+ id: 'ImportResourcesModal.uploadSeparator.decimalsSeparatorDescription',
469
+ description: 'Description for the decimals separator selection',
470
+ defaultMessage: 'Select the decimals separator that match your CSV file. The column separator is automatically detected.'
471
+ },
472
+ decimalSeparatorPoint: {
473
+ id: 'ImportResourcesModal.uploadSeparator.decimalSeparatorPoint',
474
+ description: 'Label for point decimal separator option',
475
+ defaultMessage: 'point (.)'
476
+ },
477
+ decimalSeparatorComma: {
478
+ id: 'ImportResourcesModal.uploadSeparator.decimalSeparatorComma',
479
+ description: 'Label for comma decimal separator option',
480
+ defaultMessage: 'comma (,)'
481
+ },
482
+ decimals: {
483
+ id: 'ImportResourcesModal.uploadSeparator.decimals',
484
+ description: 'Label for decimal separator select',
485
+ defaultMessage: 'Decimals'
486
+ }
487
+ });
488
+
489
+ function _callSuper$1(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
490
+ function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
491
+ let UnexpectedResourceTypeError = /*#__PURE__*/function (_Error) {
492
+ function UnexpectedResourceTypeError(resourceType) {
493
+ var _this;
494
+ _classCallCheck(this, UnexpectedResourceTypeError);
495
+ _this = _callSuper$1(this, UnexpectedResourceTypeError, [`Unexpected resource type "${resourceType}"`]);
496
+ _this.name = 'UnexpectedResourceTypeError';
497
+ return _this;
498
+ }
499
+ _inherits(UnexpectedResourceTypeError, _Error);
500
+ return _createClass(UnexpectedResourceTypeError);
501
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
502
+
503
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
504
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
505
+ let MissingImportResourceProviderError = /*#__PURE__*/function (_Error) {
506
+ function MissingImportResourceProviderError() {
507
+ var _this;
508
+ _classCallCheck(this, MissingImportResourceProviderError);
509
+ _this = _callSuper(this, MissingImportResourceProviderError, ['useImportResourcesContext must be used within ImportResourcesProvider']);
510
+ _this.name = 'MissingImportResourceProviderError';
511
+ return _this;
512
+ }
513
+ _inherits(MissingImportResourceProviderError, _Error);
514
+ return _createClass(MissingImportResourceProviderError);
515
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
516
+
517
+ function useImportResourcesContext() {
518
+ const context = React.useContext(ImportResourcesContext);
519
+ if (!context) {
520
+ throw new MissingImportResourceProviderError();
521
+ }
522
+ return context;
523
+ }
524
+
525
+ var messages$5 = reactIntl.defineMessages({
526
+ fileSizeExceededTitle: {
527
+ id: 'ImportResourcesModal.sizeExceededTitle',
528
+ defaultMessage: 'File size exceeded'
529
+ },
530
+ fileSizeExceededDescription: {
531
+ id: 'ImportResourcesModal.sizeExceededDescription',
532
+ description: 'Error description when the file size exceeds the allowable limit',
533
+ defaultMessage: 'The file exceeds the maximum allowed size of {fileSizeLimit} MB'
534
+ },
535
+ rowLimitExceededTitle: {
536
+ id: 'ImportResourcesModal.rowLimitExceededTitle',
537
+ defaultMessage: 'Row limit exceeded'
538
+ },
539
+ rowLimitExceededDescription: {
540
+ id: 'ImportResourcesModal.rowLimitExceededDescription',
541
+ description: 'Error description when the file contains more rows than the allowable maximum',
542
+ defaultMessage: 'The file contains more than the allowable maximum of {rowLimit} rows'
543
+ },
544
+ wrongSeparatorTitle: {
545
+ id: 'ImportResourcesModal.wrongSeparatorTitle',
546
+ defaultMessage: 'Wrong separator'
547
+ },
548
+ wrongSeparatorDescription: {
549
+ id: 'ImportResourcesModal.wrongSeparatorDescription',
550
+ description: 'Message within the drop area when a CSV file uses an unexpected separator',
551
+ defaultMessage: 'The file is using an unsupported separator. Please use one of the allowed separators: {delimiterList}.'
552
+ },
553
+ dropAreaNotEnoughRowsTitle: {
554
+ id: 'ImportResourcesModal.dropAreaNotEnoughRowsTitle',
555
+ description: 'Error title shown when the uploaded CSV file does not contain a header and at least one row of data',
556
+ defaultMessage: 'Invalid CSV file'
557
+ },
558
+ dropAreaNotEnoughRowsDescription: {
559
+ id: 'ImportResourcesModal.dropAreaNotEnoughRowsDescription',
560
+ description: 'Error description shown when the uploaded CSV file does not contain a header and at least one row of data',
561
+ defaultMessage: 'Make sure the file contains a header and at least one row of data'
562
+ },
563
+ unexpectedError: {
564
+ id: 'ImportResourcesModal.unexpectedError',
565
+ description: 'Generic notification message when file upload fails',
566
+ defaultMessage: 'An unexpected error occurred during the file upload. Please try again, or contact support if this error occurs again.'
567
+ },
568
+ missingRequiredField: {
569
+ id: 'ImportResourcesModal.missingRequiredField',
570
+ description: 'Error message displayed when a required field is missing',
571
+ defaultMessage: 'Missing required field'
572
+ },
573
+ missingKeyError: {
574
+ id: 'ImportResourcesModal.missingKeyError',
575
+ description: 'Error message displayed when the uploaded file is missing the key field',
576
+ defaultMessage: "The 'key' field is missing or incomplete in some rows. Please ensure every row has a 'key' value."
577
+ },
578
+ missingRequiredKeys: {
579
+ id: 'ImportResourcesModal.missingRequiredKeys',
580
+ description: 'Error message displayed when the uploaded file is missing required keys',
581
+ defaultMessage: 'Make sure the file contains required keys for the elements including {fieldNames}'
582
+ }
583
+ });
584
+
585
+ const IMPORTABLE_RESOURCES = {
586
+ CATEGORY: 'category',
587
+ PRODUCT: 'product',
588
+ INVENTORY: 'inventory',
589
+ DISCOUNT_CODE: 'discount-code',
590
+ CUSTOMER: 'customer',
591
+ ORDER: 'order',
592
+ PRODUCT_TYPE: 'product-type',
593
+ BUSINESS_UNIT: 'business-unit'
594
+ };
595
+
596
+ var sharedMessages = reactIntl.defineMessages({
597
+ [`modalTitle.${IMPORTABLE_RESOURCES.CATEGORY}`]: {
598
+ id: 'ImportResourcesModal.modalTitle.category',
599
+ description: 'Label for the categories modal title',
600
+ defaultMessage: 'Import categories by CSV'
601
+ },
602
+ [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT}`]: {
603
+ id: 'ImportResourcesModal.modalTitle.product',
604
+ description: 'Label for the products modal title',
605
+ defaultMessage: 'Import products by CSV'
606
+ },
607
+ [`modalTitle.${IMPORTABLE_RESOURCES.INVENTORY}`]: {
608
+ id: 'ImportResourcesModal.modalTitle.inventoryEntry',
609
+ description: 'Label for the inventories modal title',
610
+ defaultMessage: 'Import inventories by CSV'
611
+ },
612
+ [`modalTitle.${IMPORTABLE_RESOURCES.DISCOUNT_CODE}`]: {
613
+ id: 'ImportResourcesModal.modalTitle.discountCode',
614
+ description: 'Label for the inventories modal title',
615
+ defaultMessage: 'Import discount codes by CSV'
616
+ },
617
+ [`modalTitle.${IMPORTABLE_RESOURCES.BUSINESS_UNIT}`]: {
618
+ id: 'ImportResourcesModal.modalTitle.businessUnit',
619
+ description: 'Label for the business units modal title',
620
+ defaultMessage: 'Import business units by CSV'
621
+ },
622
+ [`modalTitle.${IMPORTABLE_RESOURCES.CUSTOMER}`]: {
623
+ id: 'ImportResourcesModal.modalTitle.customer',
624
+ description: 'Label for the customers modal title',
625
+ defaultMessage: 'Import customers by CSV'
626
+ },
627
+ [`modalTitle.${IMPORTABLE_RESOURCES.ORDER}`]: {
628
+ id: 'ImportResourcesModal.modalTitle.order',
629
+ description: 'Label for the order modal title',
630
+ defaultMessage: 'Import orders by CSV'
631
+ },
632
+ [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT_TYPE}`]: {
633
+ id: 'ImportResourcesModal.modalTitle.productType',
634
+ description: 'Label for the product type modal title',
635
+ defaultMessage: 'Import product types by CSV'
636
+ },
637
+ uploadButton: {
638
+ id: 'ImportResourcesModal.uploadButton',
639
+ description: 'Label for the upload button',
640
+ defaultMessage: 'Upload and preview'
641
+ },
642
+ cancel: {
643
+ id: 'ImportResourcesModal.cancel',
644
+ description: 'Label for the cancel button',
645
+ defaultMessage: 'Cancel'
646
+ },
647
+ close: {
648
+ id: 'ImportResourcesModal.close',
649
+ description: 'Label for the close button',
650
+ defaultMessage: 'Close'
651
+ },
652
+ listConjunctionOr: {
653
+ id: 'ImportResourcesModal.listConjunctionOr',
654
+ description: 'Label for the list conjunction or',
655
+ defaultMessage: 'or'
656
+ },
657
+ delimiterComma: {
658
+ id: 'ImportResourcesModal.delimiterComma',
659
+ description: 'Label for the delimiter name comma',
660
+ defaultMessage: 'comma'
661
+ },
662
+ delimiterSemicolon: {
663
+ id: 'ImportResourcesModal.delimiterSemicolon',
664
+ description: 'Label for the delimiter name semicolon',
665
+ defaultMessage: 'semicolon'
666
+ },
667
+ delimiterPipe: {
668
+ id: 'ImportResourcesModal.delimiterPipe',
669
+ description: 'Label for the delimiter name pipe',
670
+ defaultMessage: 'pipe'
671
+ },
672
+ delimiterTab: {
673
+ id: 'ImportResourcesModal.delimiterTab',
674
+ description: 'Label for the delimiter name tab',
675
+ defaultMessage: 'tab'
676
+ },
677
+ // Resource types
678
+ product: {
679
+ id: 'ImportResourcesModal.product',
680
+ description: 'Label for the product resource type',
681
+ defaultMessage: 'Product'
682
+ },
683
+ products: {
684
+ id: 'ImportResourcesModal.products',
685
+ description: 'Label for the products resource type',
686
+ defaultMessage: 'Products'
687
+ },
688
+ inventory: {
689
+ id: 'ImportResourcesModal.inventory',
690
+ description: 'Label for the inventory entry resource type',
691
+ defaultMessage: 'Inventory'
692
+ },
693
+ inventories: {
694
+ id: 'ImportResourcesModal.inventories',
695
+ description: 'Label for the inventories entry resource type',
696
+ defaultMessage: 'Inventories'
697
+ },
698
+ category: {
699
+ id: 'ImportResourcesModal.category',
700
+ description: 'Label for the category resource type',
701
+ defaultMessage: 'Category'
702
+ },
703
+ categories: {
704
+ id: 'ImportResourcesModal.categories',
705
+ description: 'Label for the categories resource type',
706
+ defaultMessage: 'Categories'
707
+ },
708
+ 'custom-object': {
709
+ id: 'ImportResourcesModal.custom-object',
710
+ description: 'Label for the custom-object resource type',
711
+ defaultMessage: 'Custom object'
712
+ },
713
+ 'custom-objects': {
714
+ id: 'ImportResourcesModal.custom-objects',
715
+ description: 'Label for the custom-objects resource type',
716
+ defaultMessage: 'Custom objects'
717
+ },
718
+ customer: {
719
+ id: 'ImportResourcesModal.customer',
720
+ description: 'Label for the customer resource type',
721
+ defaultMessage: 'Customer'
722
+ },
723
+ customers: {
724
+ id: 'ImportResourcesModal.customers',
725
+ description: 'Label for the customers resource type',
726
+ defaultMessage: 'Customers'
727
+ },
728
+ order: {
729
+ id: 'ImportResourcesModal.order',
730
+ description: 'Label for the order resource type',
731
+ defaultMessage: 'Order'
732
+ },
733
+ orders: {
734
+ id: 'ImportResourcesModal.orders',
735
+ description: 'Label for the orders resource type',
736
+ defaultMessage: 'Orders'
737
+ },
738
+ 'order-patch': {
739
+ id: 'ImportResourcesModal.order-patch',
740
+ description: 'Label for the order-patch resource type',
741
+ defaultMessage: 'Order patch'
742
+ },
743
+ 'order-patches': {
744
+ id: 'ImportResourcesModal.order-patches',
745
+ description: 'Label for the order-patches resource type',
746
+ defaultMessage: 'Order patches'
747
+ },
748
+ price: {
749
+ id: 'ImportResourcesModal.price',
750
+ description: 'Label for the price resource type',
751
+ defaultMessage: 'Price'
752
+ },
753
+ prices: {
754
+ id: 'ImportResourcesModal.prices',
755
+ description: 'Label for the prices resource type',
756
+ defaultMessage: 'Prices'
757
+ },
758
+ 'product-draft': {
759
+ id: 'ImportResourcesModal.product-draft',
760
+ description: 'Label for the product-draft resource type',
761
+ defaultMessage: 'Product draft'
762
+ },
763
+ 'product-drafts': {
764
+ id: 'ImportResourcesModal.product-drafts',
765
+ description: 'Label for the product-drafts resource type',
766
+ defaultMessage: 'Product drafts'
767
+ },
768
+ 'product-type': {
769
+ id: 'ImportResourcesModal.product-type',
770
+ description: 'Label for the product-type resource type',
771
+ defaultMessage: 'Product type'
772
+ },
773
+ 'product-types': {
774
+ id: 'ImportResourcesModal.product-types',
775
+ description: 'Label for the product-types resource type',
776
+ defaultMessage: 'Product types'
777
+ },
778
+ 'product-variant': {
779
+ id: 'ImportResourcesModal.product-variant',
780
+ description: 'Label for the product-variant resource type',
781
+ defaultMessage: 'Product variant'
782
+ },
783
+ 'product-variants': {
784
+ id: 'ImportResourcesModal.product-variants',
785
+ description: 'Label for the product-variants resource type',
786
+ defaultMessage: 'Product variants'
787
+ },
788
+ 'product-variant-patch': {
789
+ id: 'ImportResourcesModal.product-variant-patch',
790
+ description: 'Label for the product-variant-patch resource type',
791
+ defaultMessage: 'Product variant patch'
792
+ },
793
+ 'product-variant-patches': {
794
+ id: 'ImportResourcesModal.product-variant-patches',
795
+ description: 'Label for the product-variant-patches resource type',
796
+ defaultMessage: 'Product variant patches'
797
+ },
798
+ 'standalone-price': {
799
+ id: 'ImportResourcesModal.standalone-price',
800
+ description: 'Label for the standalone-price resource type',
801
+ defaultMessage: 'Standalone price'
802
+ },
803
+ 'standalone-prices': {
804
+ id: 'ImportResourcesModal.standalone-prices',
805
+ description: 'Label for the standalone-prices resource type',
806
+ defaultMessage: 'Standalone prices'
807
+ },
808
+ type: {
809
+ id: 'ImportResourcesModal.type',
810
+ description: 'Label for the type resource type',
811
+ defaultMessage: 'Type'
812
+ },
813
+ types: {
814
+ id: 'ImportResourcesModal.types',
815
+ description: 'Label for the types resource type',
816
+ defaultMessage: 'Types'
817
+ },
818
+ 'discount-code': {
819
+ id: 'ImportResourcesModal.discount-code',
820
+ description: 'Label for the discount-code resource type',
821
+ defaultMessage: 'Discount code'
822
+ },
823
+ 'discount-codes': {
824
+ id: 'ImportResourcesModal.discount-codes',
825
+ description: 'Label for the discount-codes resource type',
826
+ defaultMessage: 'Discount codes'
827
+ },
828
+ 'business-unit': {
829
+ id: 'ImportResourcesModal.business-unit',
830
+ description: 'Label for the business-unit resource type',
831
+ defaultMessage: 'Business unit'
832
+ },
833
+ 'business-units': {
834
+ id: 'ImportResourcesModal.business-units',
835
+ description: 'Label for the business-units resource type',
836
+ defaultMessage: 'Business units'
837
+ },
838
+ unknownResourceType: {
839
+ id: 'ImportResourcesModal.unknown-resource-type',
840
+ description: 'Label for the unknown resource type',
841
+ defaultMessage: 'Unknown resource type'
842
+ }
843
+ //
844
+ });
845
+
846
+ const formatAllowedDelimitersForMessageDisplay = intl => {
847
+ const localizedOr = intl.formatMessage(sharedMessages.listConjunctionOr);
848
+ const descriptions = _mapInstanceProperty__default["default"](operations.COLUMN_DELIMITERS).call(operations.COLUMN_DELIMITERS, delimiter => {
849
+ let nameDescriptor;
850
+ switch (delimiter) {
851
+ case ',':
852
+ nameDescriptor = sharedMessages.delimiterComma;
853
+ break;
854
+ case ';':
855
+ nameDescriptor = sharedMessages.delimiterSemicolon;
856
+ break;
857
+ case '|':
858
+ nameDescriptor = sharedMessages.delimiterPipe;
859
+ break;
860
+ case '\t':
861
+ nameDescriptor = sharedMessages.delimiterTab;
862
+ break;
863
+ default:
864
+ nameDescriptor = undefined;
865
+ }
866
+ const name = nameDescriptor ? intl.formatMessage(nameDescriptor) : delimiter;
867
+ return delimiter === '\t' ? name : `${name} (${delimiter})`;
868
+ });
869
+ if (descriptions.length === 1) {
870
+ return descriptions[0];
871
+ }
872
+ const lastDescription = descriptions.pop();
873
+ return `${descriptions.join(', ')} ${localizedOr} ${lastDescription}`;
874
+ };
875
+
876
+ function resourceTypeToMessage(resourceType) {
877
+ const resourceTypeMap = {
878
+ category: sharedMessages.category,
879
+ product: sharedMessages.product,
880
+ 'product-type': sharedMessages['product-type'],
881
+ order: sharedMessages.order,
882
+ customer: sharedMessages.customer,
883
+ 'discount-code': sharedMessages['discount-code'],
884
+ inventory: sharedMessages.inventory,
885
+ 'inventory-entry': sharedMessages.inventory,
886
+ 'order-patch': sharedMessages['order-patch'],
887
+ price: sharedMessages.price,
888
+ 'product-draft': sharedMessages['product-draft'],
889
+ 'product-variant': sharedMessages['product-variant'],
890
+ 'product-variant-patch': sharedMessages['product-variant-patch'],
891
+ 'standalone-price': sharedMessages['standalone-price'],
892
+ 'custom-object': sharedMessages['custom-object'],
893
+ 'business-unit': sharedMessages['business-unit'],
894
+ type: sharedMessages.type
895
+ };
896
+ const message = resourceTypeMap[resourceType];
897
+ if (!message) {
898
+ console.warn(new UnexpectedResourceTypeError(resourceType));
899
+ return sharedMessages.unknownResourceType;
900
+ }
901
+ return message;
902
+ }
903
+ function resourceTypeToPluralMessage(resourceType) {
904
+ const resourceTypePluralMap = {
905
+ category: sharedMessages.categories,
906
+ 'custom-object': sharedMessages['custom-objects'],
907
+ product: sharedMessages.products,
908
+ 'product-type': sharedMessages['product-types'],
909
+ order: sharedMessages.orders,
910
+ customer: sharedMessages.customers,
911
+ 'discount-code': sharedMessages['discount-codes'],
912
+ inventory: sharedMessages.inventories,
913
+ 'inventory-entry': sharedMessages.inventories,
914
+ 'order-patch': sharedMessages['order-patches'],
915
+ price: sharedMessages.prices,
916
+ 'product-draft': sharedMessages['product-drafts'],
917
+ 'product-variant': sharedMessages['product-variants'],
918
+ 'product-variant-patch': sharedMessages['product-variant-patches'],
919
+ 'standalone-price': sharedMessages['standalone-prices'],
920
+ 'business-unit': sharedMessages['business-units']
921
+ };
922
+ const message = resourceTypePluralMap[resourceType];
923
+ if (!message) {
924
+ console.warn(new UnexpectedResourceTypeError(resourceType));
925
+ return sharedMessages.unknownResourceType;
926
+ }
927
+ return message;
928
+ }
929
+
930
+ const INITIAL_COLUMN_DISPLAY_COUNT = 8;
931
+
932
+ const PERMISSIONS = {
933
+ // Categories
934
+ ManageCategories: 'ManageCategories',
935
+ ViewCategories: 'ViewCategories',
936
+ // Products
937
+ ManageProducts: 'ManageProducts',
938
+ ViewProducts: 'ViewProducts',
939
+ // ProductTypes
940
+ ManageProductTypes: 'ManageProductTypes',
941
+ ViewProductTypes: 'ViewProductTypes',
942
+ // DiscountCodes
943
+ ManageDiscountCodes: 'ManageDiscountCodes',
944
+ ViewDiscountCodes: 'ViewDiscountCodes',
945
+ // Customers
946
+ ManageCustomers: 'ManageCustomers',
947
+ ViewCustomers: 'ViewCustomers',
948
+ // Orders
949
+ ManageOrders: 'ManageOrders',
950
+ ViewOrders: 'ViewOrders',
951
+ // KeyValueDocuments
952
+ ManageKeyValueDocuments: 'ManageKeyValueDocuments',
953
+ ViewKeyValueDocuments: 'ViewKeyValueDocuments',
954
+ // BusinessUnits
955
+ ManageBusinessUnits: 'ManageBusinessUnits',
956
+ ViewBusinessUnits: 'ViewBusinessUnits'
957
+ };
958
+
959
+ function ownKeys$8(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
960
+ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$8(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$8(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
961
+ const FILE_IMPORT_JOB_FLOW = 'fileImportJobFlow';
962
+ const DEFAULT_SHORT_LIVED_FLAGS = {
963
+ [FILE_IMPORT_JOB_FLOW]: false
964
+ };
965
+ const DEFAULT_LONG_LIVED_FLAGS = {};
966
+ _objectSpread$8(_objectSpread$8({}, DEFAULT_SHORT_LIVED_FLAGS), DEFAULT_LONG_LIVED_FLAGS);
967
+
968
+ function ownKeys$7(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
969
+ function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$7(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$7(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
970
+ const useUpload = () => {
971
+ const intl = reactIntl.useIntl();
972
+ const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
973
+ projectKey: context.project?.key
974
+ })),
975
+ projectKey = _useApplicationContex.projectKey;
976
+ const _useImportResourcesCo = useImportResourcesContext(),
977
+ state = _useImportResourcesCo.state,
978
+ actions = _useImportResourcesCo.actions;
979
+ const showNotification = actionsGlobal.useShowNotification();
980
+ const isFileImportJobFlowEnabled = applicationShell.useFeatureToggle(FILE_IMPORT_JOB_FLOW);
981
+ const _useFileUpload = operations.useFileUpload({
982
+ projectKey: projectKey,
983
+ useJobBasedFlow: isFileImportJobFlowEnabled
984
+ }),
985
+ upload = _useFileUpload.upload;
986
+ const isFileValid = async file => {
987
+ const errors = [];
988
+ const maxFileSizeMB = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_FILE_SIZE_MB : operations.IMPORT_LEGACY_MAX_FILE_SIZE_MB;
989
+ const maxItemCount = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_ITEM_COUNT : operations.IMPORT_LEGACY_MAX_ROW_COUNT;
990
+ const isDelimiterValid = await operations.validateDelimiter(file, operations.COLUMN_DELIMITERS);
991
+ if (!isDelimiterValid) errors.push({
992
+ title: intl.formatMessage(messages$5.wrongSeparatorTitle),
993
+ description: intl.formatMessage(messages$5.wrongSeparatorDescription, {
994
+ delimiterList: formatAllowedDelimitersForMessageDisplay(intl)
995
+ })
996
+ });
997
+ const rowCount = await operations.getRowCount(file);
998
+ if (rowCount < 1) errors.push({
999
+ title: intl.formatMessage(messages$5.dropAreaNotEnoughRowsTitle),
1000
+ description: intl.formatMessage(messages$5.dropAreaNotEnoughRowsDescription)
1001
+ });
1002
+ if (state.resourceType && file.size > operations.toBytes(maxFileSizeMB)) errors.push({
1003
+ title: intl.formatMessage(messages$5.fileSizeExceededTitle),
1004
+ description: intl.formatMessage(messages$5.fileSizeExceededDescription, {
1005
+ fileSizeLimit: intl.formatNumber(maxFileSizeMB)
1006
+ })
1007
+ });
1008
+ if (state.resourceType && rowCount > maxItemCount) errors.push({
1009
+ title: intl.formatMessage(messages$5.rowLimitExceededTitle),
1010
+ description: intl.formatMessage(messages$5.rowLimitExceededDescription, {
1011
+ rowLimit: intl.formatNumber(maxItemCount)
1012
+ })
1013
+ });
1014
+ if (errors.length > 0) {
1015
+ actions.setFileUploadErrors(errors);
1016
+ actions.setCurrentStep(CurrentStep$1.UploadResult);
1017
+ return false;
1018
+ }
1019
+ if (isFileImportJobFlowEnabled) {
1020
+ const resourceCount = await operations.countUniqueResourcesInCsv(file);
1021
+ actions.setTotalResourceCount(resourceCount);
1022
+ }
1023
+ return true;
1024
+ };
1025
+ const handleUploadError = error => {
1026
+ if (operations.isAbortError(error)) {
1027
+ actions.cancelImport();
1028
+ return;
1029
+ }
1030
+ if (error instanceof operations.HttpError) {
1031
+ actions.setValidationProgress({
1032
+ processed: 0,
1033
+ isValidating: false
1034
+ });
1035
+ if (error.errorData?.code === 'MISSING_KEY_ERROR') {
1036
+ actions.setFileUploadErrors([{
1037
+ title: intl.formatMessage(messages$5.missingRequiredField),
1038
+ description: intl.formatMessage(messages$5.missingKeyError)
1039
+ }]);
1040
+ actions.setCurrentStep(CurrentStep$1.UploadResult);
1041
+ } else if (error.errorData?.code === 'MissingCsvFieldIdentifier') {
1042
+ const MissingCsvFieldIdentifierError = error.errorData;
1043
+ const fieldNames = operations.formatKeys(MissingCsvFieldIdentifierError.rowValue);
1044
+ actions.setFileUploadErrors([{
1045
+ title: intl.formatMessage(messages$5.missingRequiredField),
1046
+ description: intl.formatMessage(messages$5.missingRequiredKeys, {
1047
+ fieldNames
1048
+ })
1049
+ }]);
1050
+ actions.setCurrentStep(CurrentStep$1.UploadResult);
1051
+ } else if (error.errorData?.invalid > 0) {
1052
+ actions.setUploadFileResponse(error.errorData);
1053
+ actions.setCurrentStep(CurrentStep$1.UploadResult);
1054
+ } else {
1055
+ actions.cancelImport();
1056
+ showNotification({
1057
+ kind: 'error',
1058
+ domain: constants.DOMAINS.PAGE,
1059
+ text: intl.formatMessage(messages$5.unexpectedError)
1060
+ });
1061
+ }
1062
+ } else {
1063
+ actions.cancelImport();
1064
+ showNotification({
1065
+ kind: 'error',
1066
+ domain: constants.DOMAINS.PAGE,
1067
+ text: operations.isError(error) ? error.toString() : String(error)
1068
+ });
1069
+ sentry.reportErrorToSentry(new Error('Upload File Error: An unexpected issue occurred while uploading the file'), {
1070
+ extra: {
1071
+ error,
1072
+ resourceType: state.resourceType,
1073
+ fileSizeInBytes: state.droppedFile?.size
1074
+ }
1075
+ });
1076
+ }
1077
+ };
1078
+ const handleUploadAndValidation = async () => {
1079
+ if (!state.droppedFile || !state.resourceType) return;
1080
+ const canUpload = await isFileValid(state.droppedFile);
1081
+ if (!canUpload) return;
1082
+ const abortController = new AbortController();
1083
+ actions.setAbortController(abortController);
1084
+ actions.setCurrentStep(CurrentStep$1.Uploading);
1085
+ const shouldApplyPublishSettings = state.resourceType === 'product';
1086
+ const uploadSettings = _objectSpread$7({
1087
+ format: 'CSV',
1088
+ decimalSeparator: state.settings?.decimalSeparator
1089
+ }, shouldApplyPublishSettings ? {
1090
+ resourceType: state.resourceType === 'product' ? 'product-draft' : state.resourceType,
1091
+ options: {
1092
+ publishAllChanges: state.settings?.publish ?? false
1093
+ }
1094
+ } : {});
1095
+ await upload({
1096
+ file: state.droppedFile,
1097
+ resourceType: state.resourceType,
1098
+ settings: uploadSettings,
1099
+ abortSignal: abortController.signal,
1100
+ onSuccess: result => {
1101
+ actions.setValidationProgress({
1102
+ processed: 0,
1103
+ isValidating: false
1104
+ });
1105
+ actions.setContainerKey(result.containerKey);
1106
+ if (result.jobId) {
1107
+ actions.setJobId(result.jobId);
1108
+ }
1109
+ const fileUploadResponse = {
1110
+ results: result.summary.results,
1111
+ invalid: result.summary.invalid,
1112
+ valid: result.summary.valid,
1113
+ fileName: state.droppedFile?.name || '',
1114
+ itemsCount: result.summary.total,
1115
+ rowsCount: result.summary.total,
1116
+ columnsCount: result.summary.fieldsCount,
1117
+ fields: result.summary.fields,
1118
+ ignoredFields: result.summary.ignoredFields
1119
+ };
1120
+ actions.setUploadFileResponse(fileUploadResponse);
1121
+ actions.setCurrentStep(CurrentStep$1.UploadResult);
1122
+ },
1123
+ onProgress: progress => {
1124
+ actions.setProgress(progress);
1125
+ },
1126
+ onValidationProgress: job => {
1127
+ const processed = job.summary?.total ?? 0;
1128
+ actions.setValidationProgress({
1129
+ processed,
1130
+ isValidating: true
1131
+ });
1132
+ },
1133
+ onError: handleUploadError
1134
+ });
1135
+ };
1136
+ return {
1137
+ handleUploadAndValidation
1138
+ };
1139
+ };
1140
+
1141
+ const useImportPermission = () => {
1142
+ const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
1143
+ actionRights: applicationContext.actionRights?.products
1144
+ })),
1145
+ actionRights = _useApplicationContex.actionRights;
1146
+ const canManageProducts = permissions.useIsAuthorized({
1147
+ demandedPermissions: [PERMISSIONS.ManageProducts]
1148
+ });
1149
+ const canManageCustomers = permissions.useIsAuthorized({
1150
+ demandedPermissions: [PERMISSIONS.ManageCustomers]
1151
+ });
1152
+ const canManageOrders = permissions.useIsAuthorized({
1153
+ demandedPermissions: [PERMISSIONS.ManageOrders]
1154
+ });
1155
+ const canManageKeyValueDocuments = permissions.useIsAuthorized({
1156
+ demandedPermissions: [PERMISSIONS.ManageKeyValueDocuments]
1157
+ });
1158
+ const canMAnageCategories = permissions.useIsAuthorized({
1159
+ demandedPermissions: [PERMISSIONS.ManageCategories]
1160
+ });
1161
+ const canManageDiscountCodes = permissions.useIsAuthorized({
1162
+ demandedPermissions: [PERMISSIONS.ManageDiscountCodes]
1163
+ });
1164
+ const canManageBusinessUnits = permissions.useIsAuthorized({
1165
+ demandedPermissions: [PERMISSIONS.ManageBusinessUnits]
1166
+ });
1167
+ const canImportProducts = React.useMemo(() => {
1168
+ if (!actionRights) return false;
1169
+ const canAddPrices = actionRights.canAddPrices,
1170
+ canAddProducts = actionRights.canAddProducts,
1171
+ canEditAttributesAll = actionRights['canEditAttributes:all'],
1172
+ canEditPrices = actionRights.canEditPrices;
1173
+ return canManageProducts && canAddPrices && canAddProducts && canEditAttributesAll && canEditPrices;
1174
+ }, [canManageProducts, actionRights]);
1175
+ const canManageCustomObjects = React.useMemo(() => {
1176
+ return canManageProducts || canManageCustomers || canManageOrders || canManageKeyValueDocuments;
1177
+ }, [canManageCustomers, canManageOrders, canManageProducts, canManageKeyValueDocuments]);
1178
+ return {
1179
+ canImportProducts,
1180
+ canImportCategories: canMAnageCategories,
1181
+ canImportDiscountCodes: canManageDiscountCodes,
1182
+ canImportBusinessUnits: canManageBusinessUnits,
1183
+ canImportInventories: canManageProducts,
1184
+ canImportProductTypes: canManageProducts,
1185
+ canImportCustomObjects: canManageCustomObjects
1186
+ };
1187
+ };
1188
+
1189
+ const FileDropArea = () => {
1190
+ const intl = reactIntl.useIntl();
1191
+ const _useImportResourcesCo = useImportResourcesContext(),
1192
+ state = _useImportResourcesCo.state,
1193
+ actions = _useImportResourcesCo.actions;
1194
+ const isResourceTypeSelected = Boolean(state.resourceType);
1195
+ const showNotification = actionsGlobal.useShowNotification();
1196
+ const onDrop = React__default["default"].useCallback(_ref => {
1197
+ let _ref2 = _slicedToArray(_ref, 1),
1198
+ file = _ref2[0];
1199
+ if (!file) return;
1200
+ operations.assertResourceType(state.resourceType);
1201
+ actions.setDroppedFile(file);
1202
+ }, [state.resourceType, actions]);
1203
+ const handleDropRejected = React__default["default"].useCallback(errorType => {
1204
+ const errorMessageMap = {
1205
+ 'too-many-files': messages$6.tooManyFilesError,
1206
+ 'invalid-type': messages$6.fileFormatNotSupported,
1207
+ generic: messages$6.genericError
1208
+ };
1209
+ showNotification({
1210
+ kind: 'error',
1211
+ domain: constants.DOMAINS.PAGE,
1212
+ text: intl.formatMessage(errorMessageMap[errorType])
1213
+ });
1214
+ }, [intl, showNotification]);
1215
+ const getState = React__default["default"].useCallback(isDragActive => getDropAreaState({
1216
+ isReady: Boolean(state.droppedFile),
1217
+ hasResourceType: !state.resourceType,
1218
+ isDragActive
1219
+ }), [state.resourceType, state.droppedFile]);
1220
+ return jsxRuntime.jsx(operations.FileDropArea, {
1221
+ onDrop: onDrop,
1222
+ onDropRejected: handleDropRejected,
1223
+ disabled: !isResourceTypeSelected,
1224
+ accept: {
1225
+ 'text/csv': ['.csv']
1226
+ },
1227
+ getDropAreaState: getState,
1228
+ children: dropAreaState => getDropArea({
1229
+ dropAreaState,
1230
+ resourceType: 'category',
1231
+ isFileDropped: Boolean(state.droppedFile),
1232
+ fileName: state.droppedFile?.name,
1233
+ messages: {
1234
+ chooseFile: intl.formatMessage(messages$6.chooseFile),
1235
+ dragAndDropCSV: intl.formatMessage(messages$6.dragAndDropCSV),
1236
+ or: intl.formatMessage(messages$6.or),
1237
+ browseButton: intl.formatMessage(messages$6.browseButton)
1238
+ }
1239
+ })
1240
+ });
1241
+ };
1242
+
1243
+ const Upload = () => {
1244
+ const _useImportResourcesCo = useImportResourcesContext(),
1245
+ state = _useImportResourcesCo.state,
1246
+ onClose = _useImportResourcesCo.onClose,
1247
+ resourceTypes = _useImportResourcesCo.resourceTypes,
1248
+ actions = _useImportResourcesCo.actions;
1249
+ const intl = reactIntl.useIntl();
1250
+ const _useUpload = useUpload(),
1251
+ handleUploadAndValidation = _useUpload.handleUploadAndValidation;
1252
+ const isMultipleResourceTypes = resourceTypes.length > 1;
1253
+ const canPublishProducts = permissions.useIsAuthorized({
1254
+ demandedPermissions: ['ManageProducts'],
1255
+ demandedActionRights: [{
1256
+ group: 'products',
1257
+ name: 'PublishProducts'
1258
+ }]
1259
+ });
1260
+ return jsxRuntime.jsx(applicationComponents.FormDialog, {
1261
+ size: 16,
1262
+ isOpen: true,
1263
+ title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
1264
+ labelPrimary: intl.formatMessage(sharedMessages.uploadButton),
1265
+ onPrimaryButtonClick: handleUploadAndValidation,
1266
+ isPrimaryButtonDisabled: !Boolean(state.droppedFile),
1267
+ onSecondaryButtonClick: () => onClose({
1268
+ shouldDeleteImportContainer: true
1269
+ }),
1270
+ onClose: () => onClose({
1271
+ shouldDeleteImportContainer: true
1272
+ }),
1273
+ dataAttributesPrimaryButton: {
1274
+ 'data-tracking-target': `${state.resourceType}_import-upload_and_preview_button`
1275
+ },
1276
+ children: jsxRuntime.jsx(fullstory.Masking.Unmask, {
1277
+ children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1278
+ scale: "l",
1279
+ children: [isMultipleResourceTypes ? jsxRuntime.jsxs(uiKit.Grid, {
1280
+ gridRowGap: uiKit.designTokens.spacingL,
1281
+ gridTemplateColumns: `calc(${uiKit.designTokens.constraint3} + ${uiKit.designTokens.spacingL}) auto`,
1282
+ children: [jsxRuntime.jsx(uiKit.Grid.Item, {
1283
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
1284
+ isBold: true,
1285
+ intlMessage: messages$6.dataType
1286
+ })
1287
+ }), jsxRuntime.jsx(uiKit.Grid.Item, {
1288
+ children: jsxRuntime.jsx(ResourceTypeSelection, {})
1289
+ }), jsxRuntime.jsx(uiKit.Grid.Item, {
1290
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
1291
+ isBold: true,
1292
+ intlMessage: messages$6.instructions
1293
+ })
1294
+ }), jsxRuntime.jsx(uiKit.Grid.Item, {
1295
+ children: jsxRuntime.jsx(Instructions, {})
1296
+ })]
1297
+ }) : jsxRuntime.jsx(jsxRuntime.Fragment, {
1298
+ children: jsxRuntime.jsx(Instructions, {})
1299
+ }), jsxRuntime.jsx(operations.InfoBox, {
1300
+ title: intl.formatMessage(messages$6.prerequisitesOfImportingData),
1301
+ description: intl.formatMessage(messages$6.keysForEveryResource, {
1302
+ link: msg => jsxRuntime.jsx(uiKit.Link, {
1303
+ tone: "secondary",
1304
+ isExternal: true,
1305
+ to: operations.CT_API_DOCS_URL,
1306
+ children: msg
1307
+ }, "link")
1308
+ })
1309
+ }), jsxRuntime.jsx(operations.UploadSeparator, {
1310
+ value: state.settings?.decimalSeparator,
1311
+ onChange: decimalSeparator => {
1312
+ actions.setUploadSettings({
1313
+ decimalSeparator
1314
+ });
1315
+ },
1316
+ separatorTitle: intl.formatMessage(messages$6.separatorTitle),
1317
+ decimalsSeparatorDescription: intl.formatMessage(messages$6.decimalsSeparatorDescription),
1318
+ decimalSeparatorPointLabel: intl.formatMessage(messages$6.decimalSeparatorPoint),
1319
+ decimalSeparatorCommaLabel: intl.formatMessage(messages$6.decimalSeparatorComma),
1320
+ decimalsLabel: intl.formatMessage(messages$6.decimals)
1321
+ }), jsxRuntime.jsx(fullstory.Masking.Mask, {
1322
+ children: jsxRuntime.jsx(FileDropArea, {})
1323
+ }), jsxRuntime.jsx(operations.UploadSettings, {
1324
+ resourceType: state.resourceType,
1325
+ isPublishChecked: state.settings?.publish,
1326
+ onPublishChange: checked => {
1327
+ actions.setUploadSettings({
1328
+ publish: checked
1329
+ });
1330
+ },
1331
+ publishProductsLabel: intl.formatMessage(messages$6.publishProducts),
1332
+ dataTrackingTarget: "product_import-publish_checkbox",
1333
+ canPublishProducts: canPublishProducts
1334
+ })]
1335
+ })
1336
+ })
1337
+ });
1338
+ };
1339
+
1340
+ var messages$4 = reactIntl.defineMessages({
1341
+ row: {
1342
+ id: 'ImportResourcesModal.row',
1343
+ description: 'In Upload file error modal - "Row" column',
1344
+ defaultMessage: 'Row'
1345
+ },
1346
+ errorType: {
1347
+ id: 'ImportResourcesModal.errorType',
1348
+ description: 'In Upload file error modal - "Error type" column',
1349
+ defaultMessage: 'Error type'
1350
+ },
1351
+ details: {
1352
+ id: 'ImportResourcesModal.details',
1353
+ description: 'In Upload file error modal - "Details" column',
1354
+ defaultMessage: 'Details'
1355
+ },
1356
+ uploadErrorDescription: {
1357
+ id: 'ImportResourcesModal.uploadErrorDescription',
1358
+ description: 'Title when errors detected while uploading file',
1359
+ defaultMessage: 'There {errorsCount, plural, one {is <b>{errorsCount}</b> error} other {are <b>{errorsCount}</b> errors}} detected while uploading the file <b>{fileName}</b>.'
1360
+ },
1361
+ supportedValuesDocumentation: {
1362
+ id: 'ImportResourcesModal.supportedValuesDocumentation',
1363
+ description: 'Link to the documentation for supported values',
1364
+ defaultMessage: '<documentationLink>View the documentation</documentationLink> for supported values.'
1365
+ },
1366
+ uploadNewFile: {
1367
+ id: 'ImportResourcesModal.uploadNewFile',
1368
+ description: 'Upload new file button',
1369
+ defaultMessage: 'Upload new file'
1370
+ }
1371
+ });
1372
+
1373
+ function ownKeys$6(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
1374
+ function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$6(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$6(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1375
+ const fileLevelColumns = [{
1376
+ key: 'errorType',
1377
+ label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages$4.errorType)),
1378
+ width: 'max-content'
1379
+ }, {
1380
+ key: 'details',
1381
+ label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages$4.details))
1382
+ }];
1383
+ const rowLevelColumns = [{
1384
+ key: 'row',
1385
+ label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages$4.row)),
1386
+ width: 'max-content'
1387
+ }, {
1388
+ key: 'errorType',
1389
+ label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages$4.errorType)),
1390
+ width: 'max-content'
1391
+ }, {
1392
+ key: 'details',
1393
+ label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$6({}, messages$4.details))
1394
+ }];
1395
+ const FileLevelErrorTable = _ref => {
1396
+ let rows = _ref.rows;
1397
+ const pagination = uiKit.usePaginationState({
1398
+ perPage: 10
1399
+ });
1400
+ const startIndex = (pagination.page.value - 1) * pagination.perPage.value;
1401
+ const endIndex = startIndex + pagination.perPage.value;
1402
+ const currentPageRows = _sliceInstanceProperty__default["default"](rows).call(rows, startIndex, endIndex);
1403
+ const shouldShowPagination = rows.length > pagination.perPage.value;
1404
+ return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1405
+ scale: "l",
1406
+ children: [jsxRuntime.jsx(uiKit.DataTable, {
1407
+ verticalCellAlignment: "center",
1408
+ isCondensed: true,
1409
+ rows: currentPageRows,
1410
+ columns: fileLevelColumns,
1411
+ itemRenderer: fileLevelItemRenderer
1412
+ }), shouldShowPagination && jsxRuntime.jsx(uiKit.PageNavigator, {
1413
+ onPageChange: pagination.page.onChange,
1414
+ page: pagination.page.value,
1415
+ totalPages: Math.ceil(rows.length / pagination.perPage.value)
1416
+ })]
1417
+ });
1418
+ };
1419
+ const RowLevelErrorTable = _ref2 => {
1420
+ let rows = _ref2.rows;
1421
+ const pagination = uiKit.usePaginationState({
1422
+ perPage: 10
1423
+ });
1424
+ const startIndex = (pagination.page.value - 1) * pagination.perPage.value;
1425
+ const endIndex = startIndex + pagination.perPage.value;
1426
+ const currentPageRows = _sliceInstanceProperty__default["default"](rows).call(rows, startIndex, endIndex);
1427
+ const shouldShowPagination = rows.length > pagination.perPage.value;
1428
+ return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1429
+ scale: "l",
1430
+ children: [jsxRuntime.jsx(uiKit.DataTable, {
1431
+ verticalCellAlignment: "center",
1432
+ isCondensed: true,
1433
+ rows: currentPageRows,
1434
+ columns: rowLevelColumns,
1435
+ itemRenderer: rowLevelItemRenderer
1436
+ }), shouldShowPagination && jsxRuntime.jsx(uiKit.PageNavigator, {
1437
+ onPageChange: pagination.page.onChange,
1438
+ page: pagination.page.value,
1439
+ totalPages: Math.ceil(rows.length / pagination.perPage.value)
1440
+ })]
1441
+ });
1442
+ };
1443
+ const UploadErrorTable = props => {
1444
+ if (props.variant === 'row-level') {
1445
+ return jsxRuntime.jsx(RowLevelErrorTable, {
1446
+ rows: props.rows
1447
+ });
1448
+ }
1449
+ return jsxRuntime.jsx(FileLevelErrorTable, {
1450
+ rows: props.rows
1451
+ });
1452
+ };
1453
+ function fileLevelItemRenderer(item, column) {
1454
+ switch (column.key) {
1455
+ case 'errorType':
1456
+ return jsxRuntime.jsx(uiKit.Stamp, {
1457
+ isCondensed: true,
1458
+ label: item.title,
1459
+ tone: "critical"
1460
+ });
1461
+ case 'details':
1462
+ return jsxRuntime.jsx(uiKit.Text.Body, {
1463
+ children: item.description
1464
+ });
1465
+ default:
1466
+ throw new operations.UnexpectedColumnError(column.key);
1467
+ }
1468
+ }
1469
+ function rowLevelItemRenderer(item, column) {
1470
+ switch (column.key) {
1471
+ case 'row':
1472
+ return item.row;
1473
+ case 'errorType':
1474
+ return jsxRuntime.jsx(uiKit.Stamp, {
1475
+ isCondensed: true,
1476
+ label: operations.formatErrorCode(item.code),
1477
+ tone: "critical"
1478
+ });
1479
+ case 'details':
1480
+ return jsxRuntime.jsxs(uiKit.Spacings.Inline, {
1481
+ scale: "xs",
1482
+ children: [jsxRuntime.jsx(uiKit.Text.Body, {
1483
+ tone: "information",
1484
+ children: item.field
1485
+ }), jsxRuntime.jsx(uiKit.Text.Body, {
1486
+ children: operations.extractErrorDescriptionFromValidationMessage(item.validationMessage)
1487
+ })]
1488
+ });
1489
+ default:
1490
+ throw new operations.UnexpectedColumnError(column.key);
1491
+ }
1492
+ }
1493
+
1494
+ function ownKeys$5(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
1495
+ function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$5(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$5(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1496
+ const UploadErrorsModal = () => {
1497
+ const intl = reactIntl.useIntl();
1498
+ const _useImportResourcesCo = useImportResourcesContext(),
1499
+ state = _useImportResourcesCo.state,
1500
+ actions = _useImportResourcesCo.actions,
1501
+ onClose = _useImportResourcesCo.onClose;
1502
+ const isRowLevelErrors = (state.uploadFileResponse?.invalid ?? 0) > 0 && (state.uploadFileResponse?.results?.length ?? 0) > 0;
1503
+ const isFileLevelErrors = state.fileUploadErrors.length > 0;
1504
+ const errorsCount = isRowLevelErrors ? operations.getFileUploadErrorsCount(state.uploadFileResponse?.results) : state.fileUploadErrors.length;
1505
+ const documentationLink = operations.RESOURCE_TYPE_DOCUMENTATION_LINKS[state.resourceType];
1506
+ return jsxRuntime.jsx(applicationComponents.InfoDialog, {
1507
+ size: 16,
1508
+ isOpen: true,
1509
+ title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
1510
+ onClose: () => onClose(),
1511
+ children: jsxRuntime.jsx(fullstory.Masking.Unmask, {
1512
+ children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1513
+ scale: "l",
1514
+ children: [jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1515
+ scale: "xs",
1516
+ children: [jsxRuntime.jsx(fullstory.Masking.Mask, {
1517
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
1518
+ intlMessage: _objectSpread$5(_objectSpread$5({}, messages$4.uploadErrorDescription), {}, {
1519
+ values: {
1520
+ fileName: state.droppedFile?.name,
1521
+ errorsCount: intl.formatNumber(errorsCount),
1522
+ b: getBold$2
1523
+ }
1524
+ })
1525
+ })
1526
+ }), isRowLevelErrors && jsxRuntime.jsx(uiKit.Text.Body, {
1527
+ intlMessage: _objectSpread$5(_objectSpread$5({}, messages$4.supportedValuesDocumentation), {}, {
1528
+ values: {
1529
+ documentationLink: msg => jsxRuntime.jsx(uiKit.Link, {
1530
+ tone: "secondary",
1531
+ isExternal: true,
1532
+ to: documentationLink,
1533
+ children: msg
1534
+ }, "documentationLink")
1535
+ }
1536
+ })
1537
+ })]
1538
+ }), isRowLevelErrors && jsxRuntime.jsx(UploadErrorTable, {
1539
+ variant: "row-level",
1540
+ rows: operations.mapUploadFileErrorsResponseToUploadFileErrorRows(state.uploadFileResponse?.results)
1541
+ }), isFileLevelErrors && jsxRuntime.jsx(UploadErrorTable, {
1542
+ variant: "file-level",
1543
+ rows: operations.mapFileUploadErrorsToUploadFileErrorRows(state.fileUploadErrors)
1544
+ }), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
1545
+ scale: "m",
1546
+ justifyContent: "flex-end",
1547
+ children: [jsxRuntime.jsx(uiKit.SecondaryButton, {
1548
+ label: intl.formatMessage(sharedMessages.close),
1549
+ onClick: () => onClose()
1550
+ }), jsxRuntime.jsx(uiKit.PrimaryButton, {
1551
+ iconLeft: jsxRuntime.jsx(uiKit.ImportIcon, {}),
1552
+ label: intl.formatMessage(messages$4.uploadNewFile),
1553
+ onClick: () => actions.uploadNewFile()
1554
+ })]
1555
+ })]
1556
+ })
1557
+ })
1558
+ });
1559
+ };
1560
+ function getBold$2(msg) {
1561
+ return jsxRuntime.jsx(uiKit.Text.Body, {
1562
+ as: "span",
1563
+ isBold: true,
1564
+ children: msg
1565
+ }, crypto.randomUUID());
1566
+ }
1567
+
1568
+ var messages$3 = reactIntl.defineMessages({
1569
+ startImportButton: {
1570
+ id: 'ImportResourcesModal.startImportButton',
1571
+ description: 'Label for the modal Start import button',
1572
+ defaultMessage: 'Start import'
1573
+ },
1574
+ importNotificationSuccessMessage: {
1575
+ id: 'ImportResourcesModal.successMessage',
1576
+ description: 'Notification success message',
1577
+ defaultMessage: '<b>Your import has started.</b><newline></newline> <logsLink>Go to Import logs</logsLink> to view the progress.'
1578
+ },
1579
+ importNotificationPrepareMessage: {
1580
+ id: 'ImportResourcesModal.prepareMessage',
1581
+ description: 'Notification for preparing import',
1582
+ defaultMessage: '<b>Prepare import</b><newline></newline>Once preparation is complete, you can track the import progress <logsLink>in the Import logs</logsLink>.'
1583
+ },
1584
+ previewOfYourImport: {
1585
+ id: 'ImportResourcesModal.previewOfYourImport',
1586
+ description: 'Label for modal path',
1587
+ defaultMessage: "Here's a preview of your import"
1588
+ },
1589
+ itemsToBeImported: {
1590
+ id: 'ImportResourcesModal.itemsToBeImported',
1591
+ description: 'This message indicates the number of items that are ready to be imported into the project.',
1592
+ defaultMessage: '{itemCount, plural, one {<b>1</b> {resourceType} to be imported{publish, select, true { and published} other {}}} other {<b>{itemCount}</b> {resourceTypePlural} to be imported{publish, select, true { and published} other {}}}}'
1593
+ },
1594
+ columnsToBeImported: {
1595
+ id: 'ImportResourcesModal.columnsToBeImported',
1596
+ description: 'This message indicates the number of columns that are ready to be imported into the system.',
1597
+ defaultMessage: '<b>{columnCount}</b> columns to be imported'
1598
+ },
1599
+ columnsToBeIgnored: {
1600
+ id: 'ImportResourcesModal.columnsToBeIgnored',
1601
+ description: "This message indicates the number of columns that will be deliberately skipped during the import because they can't be imported",
1602
+ defaultMessage: "We will intentionally ignore <b>{columnCount}</b> columns as they can't be imported"
1603
+ },
1604
+ showMore: {
1605
+ id: 'ImportResourcesModal.showMore',
1606
+ description: 'A button label for expanding the import preview to show more details.',
1607
+ defaultMessage: 'Show more'
1608
+ },
1609
+ showLess: {
1610
+ id: 'ImportResourcesModal.showLess',
1611
+ description: 'A button label for collapsing the import preview to show fewer details.',
1612
+ defaultMessage: 'Show less'
1613
+ },
1614
+ continue: {
1615
+ id: 'ImportResourcesModal.continue',
1616
+ description: 'Confirmation dialog continue button',
1617
+ defaultMessage: 'Continue'
1618
+ },
1619
+ confirmationBodyText: {
1620
+ id: 'ImportResourcesModal.confirmationBodyText',
1621
+ description: 'Confirmation dialog text',
1622
+ defaultMessage: 'You are about to import {count, plural, one {<bold>1</bold> row} other {<bold>{count}</bold> rows}} in the project: <bold>{projectName}</bold>.'
1623
+ },
1624
+ confirmationBodyNote: {
1625
+ id: 'ImportResourcesModal.confirmationBodyNote',
1626
+ description: 'Confirmation dialog text',
1627
+ defaultMessage: 'Please be aware that existing values with the same keys will be overwritten by the data included in the CSV.'
1628
+ },
1629
+ confirmationBodyQuestion: {
1630
+ id: 'ImportResourcesModal.confirmationBodyQuestion',
1631
+ description: 'Confirmation question',
1632
+ defaultMessage: 'Proceed with the import?'
1633
+ }
1634
+ });
1635
+
1636
+ function ownKeys$4(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
1637
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$4(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$4(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1638
+ const AlignedContainer = /*#__PURE__*/_styled__default["default"]("div", {
1639
+ target: "e1amawj91"
1640
+ } )({
1641
+ name: "1x0d6yz",
1642
+ styles: "padding-top:5px"
1643
+ } );
1644
+ const ModifiedTagList = /*#__PURE__*/_styled__default["default"](uiKit.TagList, {
1645
+ target: "e1amawj90"
1646
+ } )({
1647
+ name: "u9abxe",
1648
+ styles: ">div{margin:8px 8px 0 0;}"
1649
+ } );
1650
+ const ColumnList = props => {
1651
+ var _context;
1652
+ const _React$useState = React__default["default"].useState(false),
1653
+ _React$useState2 = _slicedToArray(_React$useState, 2),
1654
+ isExpanded = _React$useState2[0],
1655
+ setIsExpanded = _React$useState2[1];
1656
+ const shouldShowExpandButton = props.columns.length > INITIAL_COLUMN_DISPLAY_COUNT;
1657
+ const finalColumns = isExpanded ? props.columns : _sliceInstanceProperty__default["default"](_context = props.columns).call(_context, 0, INITIAL_COLUMN_DISPLAY_COUNT);
1658
+ return jsxRuntime.jsxs(ModifiedTagList, {
1659
+ children: [_mapInstanceProperty__default["default"](finalColumns).call(finalColumns, (column, index) => jsxRuntime.jsx(uiKit.Stamp, {
1660
+ label: column,
1661
+ tone: "secondary"
1662
+ }, index)), shouldShowExpandButton && jsxRuntime.jsx(AlignedContainer, {
1663
+ children: jsxRuntime.jsx(uiKit.Link, {
1664
+ to: "",
1665
+ tone: "secondary",
1666
+ onClick: e => {
1667
+ e.preventDefault();
1668
+ setIsExpanded(!isExpanded);
1669
+ },
1670
+ children: isExpanded ? jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$4({}, messages$3.showLess)) : jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$4({}, messages$3.showMore))
1671
+ })
1672
+ })]
1673
+ });
1674
+ };
1675
+
1676
+ function ownKeys$3(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
1677
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$3(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$3(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1678
+ function UploadPreviewModal() {
1679
+ const _useImportResourcesCo = useImportResourcesContext(),
1680
+ state = _useImportResourcesCo.state;
1681
+ const intl = reactIntl.useIntl();
1682
+ const _useImportResourcesCo2 = useImportResourcesContext(),
1683
+ actions = _useImportResourcesCo2.actions,
1684
+ onClose = _useImportResourcesCo2.onClose;
1685
+ if (!state.resourceType || !state.uploadFileResponse) return null;
1686
+ const resourceTypeMessage = resourceTypeToMessage(state.resourceType);
1687
+ const resourceType = intl.formatMessage(resourceTypeMessage).toLowerCase();
1688
+ const resourceTypePluralMessage = resourceTypeToPluralMessage(state.resourceType);
1689
+ const resourceTypePlural = intl.formatMessage(resourceTypePluralMessage).toLowerCase();
1690
+ const ignoredFields = state.uploadFileResponse.ignoredFields;
1691
+ const validatedFields = operations.getValidatedColumns(state.uploadFileResponse.fields, ignoredFields);
1692
+ return jsxRuntime.jsx(applicationComponents.FormDialog, {
1693
+ size: 16,
1694
+ isOpen: true,
1695
+ title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
1696
+ labelPrimary: intl.formatMessage(messages$3.continue),
1697
+ onSecondaryButtonClick: () => onClose({
1698
+ shouldDeleteImportContainer: true
1699
+ }),
1700
+ onPrimaryButtonClick: () => {
1701
+ actions.setCurrentStep(CurrentStep$1.ImportConfirmationModal);
1702
+ },
1703
+ onClose: () => onClose({
1704
+ shouldDeleteImportContainer: true
1705
+ }),
1706
+ children: jsxRuntime.jsx(fullstory.Masking.Unmask, {
1707
+ children: jsxRuntime.jsx(applicationComponents.PageContentNarrow, {
1708
+ children: jsxRuntime.jsx(uiKit.Spacings.Stack, {
1709
+ scale: "xxxl",
1710
+ children: jsxRuntime.jsx(uiKit.Spacings.Stack, {
1711
+ scale: "xl",
1712
+ children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1713
+ scale: "m",
1714
+ children: [jsxRuntime.jsx("div", {}), jsxRuntime.jsx(uiKit.Text.Body, {
1715
+ intlMessage: messages$3.previewOfYourImport
1716
+ }), jsxRuntime.jsx(uiKit.Card, {
1717
+ insetScale: "xl",
1718
+ children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1719
+ scale: "s",
1720
+ children: [jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1721
+ scale: "xs",
1722
+ children: [jsxRuntime.jsxs(uiKit.Spacings.Inline, {
1723
+ alignItems: "center",
1724
+ children: [jsxRuntime.jsx(uiKit.CheckBoldIcon, {
1725
+ color: "success"
1726
+ }), jsxRuntime.jsx(uiKit.Text.Body, {
1727
+ intlMessage: _objectSpread$3(_objectSpread$3({}, messages$3.itemsToBeImported), {}, {
1728
+ values: {
1729
+ resourceType,
1730
+ resourceTypePlural,
1731
+ itemCount: intl.formatNumber(state.uploadFileResponse.itemsCount),
1732
+ publish: state.resourceType === 'product' && state.settings?.publish,
1733
+ b: getBold$1
1734
+ }
1735
+ })
1736
+ })]
1737
+ }), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
1738
+ alignItems: "center",
1739
+ children: [jsxRuntime.jsx(uiKit.CheckBoldIcon, {
1740
+ color: "success"
1741
+ }), jsxRuntime.jsx(uiKit.Text.Body, {
1742
+ intlMessage: _objectSpread$3(_objectSpread$3({}, messages$3.columnsToBeImported), {}, {
1743
+ values: {
1744
+ columnCount: intl.formatNumber(validatedFields.length),
1745
+ b: getBold$1
1746
+ }
1747
+ })
1748
+ })]
1749
+ })]
1750
+ }), jsxRuntime.jsx(ColumnList, {
1751
+ columns: validatedFields
1752
+ })]
1753
+ })
1754
+ }), ignoredFields.length > 0 && jsxRuntime.jsx(uiKit.Card, {
1755
+ insetScale: "xl",
1756
+ children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1757
+ scale: "s",
1758
+ children: [jsxRuntime.jsxs(uiKit.Spacings.Inline, {
1759
+ alignItems: "center",
1760
+ children: [jsxRuntime.jsx(uiKit.EyeCrossedIcon, {
1761
+ color: "neutral60"
1762
+ }), jsxRuntime.jsx(uiKit.Text.Body, {
1763
+ intlMessage: _objectSpread$3(_objectSpread$3({}, messages$3.columnsToBeIgnored), {}, {
1764
+ values: {
1765
+ columnCount: intl.formatNumber(ignoredFields.length),
1766
+ b: getBold$1
1767
+ }
1768
+ })
1769
+ })]
1770
+ }), jsxRuntime.jsx(ColumnList, {
1771
+ columns: ignoredFields
1772
+ })]
1773
+ })
1774
+ })]
1775
+ })
1776
+ })
1777
+ })
1778
+ })
1779
+ })
1780
+ });
1781
+ }
1782
+ function getBold$1(msg) {
1783
+ return jsxRuntime.jsx(uiKit.Text.Body, {
1784
+ as: "span",
1785
+ isBold: true,
1786
+ children: msg
1787
+ }, crypto.randomUUID());
1788
+ }
1789
+
1790
+ function ownKeys$2(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
1791
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$2(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1792
+ const getNewLine = () => jsxRuntime.jsx("br", {}, "break");
1793
+ const getImportLogsLink = (msg, projectKey) => jsxRuntime.jsx(uiKit.Link, {
1794
+ to: `/${projectKey}/operations/import/logs`,
1795
+ children: msg
1796
+ }, "link");
1797
+ var _ref2 = {
1798
+ name: "1vs9i7r",
1799
+ styles: "width:360px"
1800
+ } ;
1801
+ const ImportRunningTextNotification = props => jsxRuntime.jsx("div", {
1802
+ css: _ref2,
1803
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
1804
+ intlMessage: _objectSpread$2(_objectSpread$2({}, messages$3.importNotificationSuccessMessage), {}, {
1805
+ values: {
1806
+ newline: getNewLine,
1807
+ logsLink: msg => getImportLogsLink(msg, props.projectKey),
1808
+ b: getBold
1809
+ }
1810
+ })
1811
+ })
1812
+ });
1813
+ var _ref = {
1814
+ name: "1vs9i7r",
1815
+ styles: "width:360px"
1816
+ } ;
1817
+ const ImportPreparingTextNotification = props => jsxRuntime.jsx("div", {
1818
+ css: _ref,
1819
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
1820
+ intlMessage: _objectSpread$2(_objectSpread$2({}, messages$3.importNotificationPrepareMessage), {}, {
1821
+ values: {
1822
+ newline: getNewLine,
1823
+ logsLink: msg => getImportLogsLink(msg, props.projectKey),
1824
+ b: getBold
1825
+ }
1826
+ })
1827
+ })
1828
+ });
1829
+ const ImportConfirmationModal = () => {
1830
+ const intl = reactIntl.useIntl();
1831
+ const _useImportResourcesCo = useImportResourcesContext(),
1832
+ state = _useImportResourcesCo.state,
1833
+ onStartImportSuccess = _useImportResourcesCo.onStartImportSuccess,
1834
+ onClose = _useImportResourcesCo.onClose;
1835
+ const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
1836
+ projectKey: context.project?.key,
1837
+ projectName: context.project?.name
1838
+ })),
1839
+ projectKey = _useApplicationContex.projectKey,
1840
+ projectName = _useApplicationContex.projectName;
1841
+ const showNotification = actionsGlobal.useShowNotification();
1842
+ return jsxRuntime.jsx(applicationComponents.ConfirmationDialog, {
1843
+ title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
1844
+ labelPrimary: intl.formatMessage(messages$3.startImportButton),
1845
+ isOpen: true,
1846
+ onClose: () => onClose({
1847
+ shouldDeleteImportContainer: true
1848
+ }),
1849
+ onCancel: () => onClose({
1850
+ shouldDeleteImportContainer: true
1851
+ }),
1852
+ dataAttributesPrimaryButton: {
1853
+ 'data-test-id': 'confirmation-dialog-confirm'
1854
+ },
1855
+ dataAttributesSecondaryButton: {
1856
+ 'data-test-id': 'confirmation-dialog-cancel',
1857
+ 'data-tracking-target': `${state.resourceType}_import-start_import_button`
1858
+ },
1859
+ onConfirm: async () => {
1860
+ try {
1861
+ const canConfirm = projectKey && state.containerKey && state.droppedFile?.name && state.resourceType;
1862
+ if (!canConfirm) return;
1863
+ onClose();
1864
+ showNotification({
1865
+ kind: 'info',
1866
+ domain: constants.DOMAINS.SIDE,
1867
+ // @ts-ignore
1868
+ text: jsxRuntime.jsx(ImportPreparingTextNotification, {
1869
+ projectKey: projectKey
1870
+ })
1871
+ }, {
1872
+ dismissAfter: 5000
1873
+ });
1874
+ const isJobBasedFlow = !!state.jobId;
1875
+ if (isJobBasedFlow) {
1876
+ await operations.processFileImportJob({
1877
+ projectKey,
1878
+ resourceType: state.resourceType,
1879
+ importContainerKey: state.containerKey,
1880
+ jobId: state.jobId
1881
+ });
1882
+ } else {
1883
+ await operations.processUploadedFile({
1884
+ projectKey,
1885
+ importContainerKey: state.containerKey,
1886
+ resourceType: state.resourceType
1887
+ });
1888
+ }
1889
+ onStartImportSuccess();
1890
+ showNotification({
1891
+ kind: 'info',
1892
+ domain: constants.DOMAINS.SIDE,
1893
+ // @ts-ignore
1894
+ text: jsxRuntime.jsx(ImportRunningTextNotification, {
1895
+ projectKey: projectKey
1896
+ })
1897
+ }, {
1898
+ dismissAfter: 5000
1899
+ });
1900
+ } catch (error) {
1901
+ onClose({
1902
+ shouldDeleteImportContainer: true
1903
+ });
1904
+ showNotification({
1905
+ kind: 'error',
1906
+ domain: constants.DOMAINS.PAGE,
1907
+ text: operations.isError(error) ? error.toString() : String(error)
1908
+ });
1909
+ }
1910
+ },
1911
+ size: 16,
1912
+ children: jsxRuntime.jsx(fullstory.Masking.Unmask, {
1913
+ children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1914
+ scale: "xl",
1915
+ children: [jsxRuntime.jsxs("div", {
1916
+ children: [jsxRuntime.jsx(uiKit.Text.Body, {
1917
+ intlMessage: _objectSpread$2(_objectSpread$2({}, messages$3.confirmationBodyText), {}, {
1918
+ values: {
1919
+ projectName: projectName,
1920
+ count: intl.formatNumber(state?.uploadFileResponse?.rowsCount || 0),
1921
+ bold: getBold
1922
+ }
1923
+ })
1924
+ }), jsxRuntime.jsx(uiKit.Text.Body, {
1925
+ intlMessage: messages$3.confirmationBodyNote
1926
+ })]
1927
+ }), jsxRuntime.jsx(uiKit.Text.Body, {
1928
+ intlMessage: messages$3.confirmationBodyQuestion
1929
+ })]
1930
+ })
1931
+ })
1932
+ });
1933
+ };
1934
+ function getBold(msg) {
1935
+ return jsxRuntime.jsx(uiKit.Text.Body, {
1936
+ as: "span",
1937
+ isBold: true,
1938
+ children: msg
1939
+ }, crypto.randomUUID());
1940
+ }
1941
+
1942
+ const UploadResult = () => {
1943
+ const _useImportResourcesCo = useImportResourcesContext(),
1944
+ state = _useImportResourcesCo.state;
1945
+ const hasFileLevelErrors = state.fileUploadErrors.length > 0;
1946
+ const hasRowLevelErrors = (state.uploadFileResponse?.invalid ?? 0) > 0 && (state.uploadFileResponse?.results?.length ?? 0) > 0;
1947
+ if (hasFileLevelErrors || hasRowLevelErrors) {
1948
+ return jsxRuntime.jsx(UploadErrorsModal, {});
1949
+ }
1950
+ return jsxRuntime.jsx(UploadPreviewModal, {});
1951
+ };
1952
+
1953
+ var messages$2 = reactIntl.defineMessages({
1954
+ validatingResources: {
1955
+ id: 'ImportResourcesModal.Uploading.validatingResources',
1956
+ defaultMessage: 'Validating {processed} / {total} {resourceType}'
1957
+ }
1958
+ });
1959
+
1960
+ const Uploading = () => {
1961
+ const intl = reactIntl.useIntl();
1962
+ const _useImportResourcesCo = useImportResourcesContext(),
1963
+ state = _useImportResourcesCo.state,
1964
+ actions = _useImportResourcesCo.actions,
1965
+ onClose = _useImportResourcesCo.onClose;
1966
+ if (!state.droppedFile?.name) return null;
1967
+ const showValidationProgress = state.isValidating && state.validationProcessed && state.validationProcessed > 0 && state.totalResourceCount && state.resourceType;
1968
+ const statusMessage = showValidationProgress ? intl.formatMessage(messages$2.validatingResources, {
1969
+ processed: intl.formatNumber(state.validationProcessed),
1970
+ total: intl.formatNumber(state.totalResourceCount),
1971
+ resourceType: intl.formatMessage(resourceTypeToPluralMessage(state.resourceType))
1972
+ }) : undefined;
1973
+ return jsxRuntime.jsx(operations.UploadingModal, {
1974
+ isOpen: true,
1975
+ title: intl.formatMessage(sharedMessages[`modalTitle.${state.resourceType}`]),
1976
+ fileName: state.droppedFile.name,
1977
+ fileSize: state.droppedFile.size,
1978
+ progress: state.progress,
1979
+ cancelLabel: intl.formatMessage(sharedMessages.cancel),
1980
+ onCancel: () => {
1981
+ actions.setCurrentStep(CurrentStep$1.Upload);
1982
+ state.abortController.abort();
1983
+ },
1984
+ onClose: () => onClose({
1985
+ shouldDeleteImportContainer: true
1986
+ }),
1987
+ statusMessage: statusMessage
1988
+ });
1989
+ };
1990
+
1991
+ const CurrentStep = () => {
1992
+ const _useImportResourcesCo = useImportResourcesContext(),
1993
+ state = _useImportResourcesCo.state;
1994
+ const steps = {
1995
+ upload: jsxRuntime.jsx(Upload, {}),
1996
+ uploading: jsxRuntime.jsx(Uploading, {}),
1997
+ 'upload-result': jsxRuntime.jsx(UploadResult, {}),
1998
+ 'import-confirmation-modal': jsxRuntime.jsx(ImportConfirmationModal, {})
1999
+ };
2000
+ return steps[state.currentStep] || null;
2001
+ };
2002
+
2003
+ var messages$1 = reactIntl.defineMessages({
2004
+ products: {
2005
+ id: 'ImportResourcesModal.radio.products',
2006
+ description: 'Label for the products radio button',
2007
+ defaultMessage: 'Products (including variants, assets, prices and images)'
2008
+ },
2009
+ inventories: {
2010
+ id: 'ImportResourcesModal.radio.inventories',
2011
+ description: 'Label for the inventories radio button',
2012
+ defaultMessage: 'Inventories'
2013
+ },
2014
+ categories: {
2015
+ id: 'ImportResourcesModal.radio.categories',
2016
+ description: 'Label for the categories radio button',
2017
+ defaultMessage: 'Categories'
2018
+ }
2019
+ });
2020
+
2021
+ const resourceTypeToDisplayName = resourceType => {
2022
+ switch (resourceType) {
2023
+ case IMPORTABLE_RESOURCES.PRODUCT:
2024
+ return messages$1.products;
2025
+ case IMPORTABLE_RESOURCES.INVENTORY:
2026
+ return messages$1.inventories;
2027
+ case IMPORTABLE_RESOURCES.CATEGORY:
2028
+ return messages$1.categories;
2029
+ default:
2030
+ throw new operations.UnexpectedResourceTypeError(resourceType);
2031
+ }
2032
+ };
2033
+ const ResourceTypeSelection = () => {
2034
+ const _useImportResourcesCo = useImportResourcesContext(),
2035
+ state = _useImportResourcesCo.state,
2036
+ actions = _useImportResourcesCo.actions,
2037
+ resourceTypes = _useImportResourcesCo.resourceTypes;
2038
+ return jsxRuntime.jsx(uiKit.RadioInput.Group, {
2039
+ value: state.resourceType,
2040
+ onChange: e => {
2041
+ actions.setResourceType(e.target.value);
2042
+ },
2043
+ direction: "stack",
2044
+ directionProps: {
2045
+ scale: 's'
2046
+ },
2047
+ children: _mapInstanceProperty__default["default"](resourceTypes).call(resourceTypes, resourceType => jsxRuntime.jsx(uiKit.RadioInput.Option, {
2048
+ value: resourceType,
2049
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
2050
+ intlMessage: resourceTypeToDisplayName(resourceType)
2051
+ })
2052
+ }, resourceType))
2053
+ });
2054
+ };
2055
+
2056
+ var messages = reactIntl.defineMessages({
2057
+ fileUploadInstructions: {
2058
+ id: 'ImportResourcesModal.fileUploadInstructions',
2059
+ description: 'Label for the modal category description',
2060
+ defaultMessage: 'Maximum file size is {fileSize} MB with a limit of {rowLimit} rows. Download <csvTemplateLink>the CSV template</csvTemplateLink> or refer to <documentationLink>the documentation</documentationLink>.'
2061
+ }
2062
+ });
2063
+
2064
+ function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
2065
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
2066
+ const Instructions = () => {
2067
+ const intl = reactIntl.useIntl();
2068
+ const _useImportResourcesCo = useImportResourcesContext(),
2069
+ state = _useImportResourcesCo.state;
2070
+ const isFileImportJobFlowEnabled = applicationShell.useFeatureToggle(FILE_IMPORT_JOB_FLOW);
2071
+ const templateLink = operations.RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS[state.resourceType];
2072
+ const documentationLink = operations.RESOURCE_TYPE_DOCUMENTATION_LINKS[state.resourceType];
2073
+ const maxFileSize = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_FILE_SIZE_MB : operations.IMPORT_LEGACY_MAX_FILE_SIZE_MB;
2074
+ const maxItemCount = isFileImportJobFlowEnabled ? operations.IMPORT_MAX_ITEM_COUNT : operations.IMPORT_LEGACY_MAX_ROW_COUNT;
2075
+ return jsxRuntime.jsx(uiKit.Text.Body, {
2076
+ intlMessage: _objectSpread$1(_objectSpread$1({}, messages.fileUploadInstructions), {}, {
2077
+ values: {
2078
+ fileSize: intl.formatNumber(maxFileSize),
2079
+ rowLimit: intl.formatNumber(maxItemCount),
2080
+ csvTemplateLink: msg => jsxRuntime.jsx(uiKit.Link, {
2081
+ tone: "secondary",
2082
+ isExternal: true,
2083
+ to: templateLink,
2084
+ children: msg
2085
+ }, "csvTemplateLink"),
2086
+ documentationLink: msg => jsxRuntime.jsx(uiKit.Link, {
2087
+ tone: "secondary",
2088
+ isExternal: true,
2089
+ to: documentationLink,
2090
+ children: msg
2091
+ }, "documentationLink")
2092
+ }
2093
+ })
2094
+ });
2095
+ };
2096
+
2097
+ const getChunkImport = locale => {
2098
+ const intlLocale = i18n.mapLocaleToIntlLocale(locale);
2099
+ switch (intlLocale) {
2100
+ case 'de':
2101
+ return Promise.resolve().then(function () { return require('./de-3cd0305d.cjs.prod.js'); });
2102
+ case 'es':
2103
+ return Promise.resolve().then(function () { return require('./es-030fcde4.cjs.prod.js'); });
2104
+ case 'fr-FR':
2105
+ return Promise.resolve().then(function () { return require('./fr-FR-c66b401e.cjs.prod.js'); });
2106
+ case 'ja':
2107
+ return Promise.resolve().then(function () { return require('./ja-37632763.cjs.prod.js'); });
2108
+ case 'pt-BR':
2109
+ return Promise.resolve().then(function () { return require('./pt-BR-36893abd.cjs.prod.js'); });
2110
+ default:
2111
+ return Promise.resolve().then(function () { return require('./en-7d070d59.cjs.prod.js'); });
2112
+ }
2113
+ };
2114
+ const loadMessages = async locale => {
2115
+ try {
2116
+ const chunkImport = await getChunkImport(locale);
2117
+ return i18n.parseChunkImport(chunkImport);
2118
+ } catch (error) {
2119
+ // eslint-disable-next-line no-console
2120
+ console.warn(`Something went wrong while loading the import-resources-modal messages for ${locale}`, error);
2121
+ sentry.reportErrorToSentry(new Error(`Something went wrong while loading the import-resources-modal messages for ${locale}`), {
2122
+ extra: error
2123
+ });
2124
+ return {};
2125
+ }
2126
+ };
2127
+
2128
+ const useAsyncIntlMessages = (locale, loader) => {
2129
+ const _useState = React.useState({
2130
+ isLoading: true,
2131
+ messages: undefined,
2132
+ error: undefined
2133
+ }),
2134
+ _useState2 = _slicedToArray(_useState, 2),
2135
+ state = _useState2[0],
2136
+ setState = _useState2[1];
2137
+ React.useEffect(() => {
2138
+ let _isUnmounting = false;
2139
+ async function load() {
2140
+ try {
2141
+ if (!_isUnmounting) {
2142
+ const messages = await loader(locale);
2143
+ setState({
2144
+ isLoading: false,
2145
+ messages
2146
+ });
2147
+ }
2148
+ } catch (error) {
2149
+ setState({
2150
+ isLoading: false,
2151
+ error
2152
+ });
2153
+ }
2154
+ }
2155
+ if (locale) load();
2156
+ return () => {
2157
+ _isUnmounting = true;
2158
+ };
2159
+ }, [locale, loader]);
2160
+ return state;
2161
+ };
2162
+
2163
+ function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
2164
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
2165
+ const ImportResourcesModal = props => {
2166
+ var _context;
2167
+ const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
2168
+ locale: context.user && context.user.locale
2169
+ })),
2170
+ locale = _useApplicationContex.locale;
2171
+ const messages = useAsyncIntlMessages(locale, loadMessages);
2172
+ if (!props.isOpen || messages.isLoading) return null;
2173
+ if (!props.resourceTypes?.length) {
2174
+ console.error('No resource types provided for import resources modal');
2175
+ return null;
2176
+ }
2177
+ if (!_everyInstanceProperty__default["default"](_context = props.resourceTypes).call(_context, operations.isResourceType)) {
2178
+ console.error('Invalid resource types provided for import resources modal');
2179
+ return null;
2180
+ }
2181
+ return jsxRuntime.jsx(reactIntl.IntlProvider, {
2182
+ locale: locale,
2183
+ messages: messages.messages,
2184
+ children: jsxRuntime.jsx(ImportResourcesProvider, _objectSpread(_objectSpread({}, props), {}, {
2185
+ children: jsxRuntime.jsx(CurrentStep, {})
2186
+ }))
2187
+ });
2188
+ };
2189
+ ImportResourcesModal.displayName = 'ImportResourcesModal';
2190
+
2191
+ exports["default"] = ImportResourcesModal;
2192
+ exports.useImportPermission = useImportPermission;