kitchen-simulator 1.0.0-clark.55 → 1.0.0-clark.57

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.
package/es/index.js CHANGED
@@ -6,14 +6,8 @@ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
6
  import _inherits from "@babel/runtime/helpers/esm/inherits";
7
7
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
8
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
- import React from 'react';
10
9
  import ReactDOM from 'react-dom';
11
10
  import LiteRenderer from "./LiteRenderer";
12
-
13
- /**
14
- * Keeps LiteRenderer mounted once and updates externalEvent through React state.
15
- * Works with React 16 (no createRoot).
16
- */
17
11
  export function renderKitchenSimulator(container) {
18
12
  var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
19
13
  var setExternalEventFn = null;
@@ -51,7 +45,6 @@ export function renderKitchenSimulator(container) {
51
45
  return {
52
46
  updateExternalEvent: function updateExternalEvent(newExternalEvent) {
53
47
  var _setExternalEventFn;
54
- // Always update — allow same event twice
55
48
  (_setExternalEventFn = setExternalEventFn) === null || _setExternalEventFn === void 0 || _setExternalEventFn(newExternalEvent);
56
49
  },
57
50
  unmount: function unmount() {
@@ -65,53 +65,459 @@ var loadSVGsByItem = /*#__PURE__*/function () {
65
65
  var compareSVGRect = function compareSVGRect(value) {
66
66
  return value.e <= 10 && value.e + value.a * value.SVGWidth + 10 >= value.viewerWidth && value.f <= 80 && value.f + value.d * value.SVGHeight + 10 >= value.viewerHeight ? true : false;
67
67
  };
68
- export function handleExternalEvent(_x2) {
69
- return _handleExternalEvent.apply(this, arguments);
68
+ function loadJSON(_x2, _x3, _x4) {
69
+ return _loadJSON.apply(this, arguments);
70
70
  }
71
- function _handleExternalEvent() {
72
- _handleExternalEvent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(props) {
73
- var evt, state, sLineCnt, element, catalog, outlineSVGData, catalogInstance, elementJs, _evt$payload, moveType, moveValue, value, defaulTitle, _evt$payload2, doorStyle, itemCDS, isAll, _doorStyle, _value, _zoomValue, _value2, _zoomValue2, _evt$payload3, moldingInfo, isGlobal, _t2, _t3;
71
+ /********Parse TempPlaceholder from cabinetPayloadData **************/
72
+ function _loadJSON() {
73
+ _loadJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(path, success, error) {
74
74
  return _regeneratorRuntime.wrap(function (_context2) {
75
75
  while (1) switch (_context2.prev = _context2.next) {
76
+ case 0:
77
+ return _context2.abrupt("return", new Promise(function (resolve, reject) {
78
+ var xhr = new XMLHttpRequest();
79
+ xhr.onreadystatechange = function () {
80
+ if (xhr.readyState === XMLHttpRequest.DONE) {
81
+ if (xhr.status === 200) {
82
+ resolve(JSON.parse(xhr.responseText));
83
+ } else {
84
+ reject(xhr);
85
+ }
86
+ }
87
+ };
88
+ xhr.open('GET', path, true);
89
+ xhr.send();
90
+ }));
91
+ case 1:
92
+ case "end":
93
+ return _context2.stop();
94
+ }
95
+ }, _callee2);
96
+ }));
97
+ return _loadJSON.apply(this, arguments);
98
+ }
99
+ export function parseTempPlaceholdersFromCabinetPayload(_x5) {
100
+ return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
101
+ }
102
+
103
+ /***** Update cabinetPayloadData with updatedTempPlaceholders *****/
104
+ function _parseTempPlaceholdersFromCabinetPayload() {
105
+ _parseTempPlaceholdersFromCabinetPayload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(cabinetPayload) {
106
+ var link, keys, temp, i, _cabinetPayload$struc, el, tempPlaceholdersData, tempData, doorKey, drawerKey, fixedKey, doorPHs, drawerPHs, has_single_door, fixedPHs, _t2, _t3, _t4;
107
+ return _regeneratorRuntime.wrap(function (_context3) {
108
+ while (1) switch (_context3.prev = _context3.next) {
109
+ case 0:
110
+ link = '';
111
+ keys = Object.keys(cabinetPayload.structure_json);
112
+ temp = [];
113
+ i = 0;
114
+ case 1:
115
+ if (!(i < keys.length)) {
116
+ _context3.next = 4;
117
+ break;
118
+ }
119
+ if (!((_cabinetPayload$struc = cabinetPayload.structure_json[keys[i]]) !== null && _cabinetPayload$struc !== void 0 && (_cabinetPayload$struc = _cabinetPayload$struc.toString()) !== null && _cabinetPayload$struc !== void 0 && _cabinetPayload$struc.includes('.gltf'))) {
120
+ _context3.next = 3;
121
+ break;
122
+ }
123
+ link = cabinetPayload.structure_json[keys[i]];
124
+ _t2 = temp;
125
+ _t3 = keys[i];
126
+ _context3.next = 2;
127
+ return loadJSON(link);
128
+ case 2:
129
+ _t4 = _context3.sent;
130
+ _t2.push.call(_t2, {
131
+ name: _t3,
132
+ data: _t4
133
+ });
134
+ case 3:
135
+ i++;
136
+ _context3.next = 1;
137
+ break;
138
+ case 4:
139
+ el = cabinetPayload.structure_json.tempPlaceholders[0].id;
140
+ tempPlaceholdersData = [];
141
+ tempData = {};
142
+ doorKey = 0;
143
+ drawerKey = 0;
144
+ fixedKey = 0;
145
+ doorPHs = 0;
146
+ drawerPHs = 0;
147
+ has_single_door = false;
148
+ fixedPHs = 0;
149
+ temp.forEach(function (t, index) {
150
+ var nodes = t.data.nodes;
151
+ if (nodes === undefined) {
152
+ nodes = [];
153
+ }
154
+ var tempPlaceholders = nodes.filter(function (element) {
155
+ return element.name.startsWith('ph_');
156
+ });
157
+ tempPlaceholders.sort(function (a, b) {
158
+ return a.name > b.name ? 1 : -1;
159
+ });
160
+ if (tempPlaceholders.length > 0) {
161
+ if (t.name === 'base') {
162
+ tempPlaceholders.map(function (element) {
163
+ var sink_match = element.name.match(/\d_(sink_[^LR12]*)(_[LR12])?$/);
164
+ if (sink_match && sink_match.length >= 2) {
165
+ tempData['sink'] = tempData['sink'] || [];
166
+ tempData['sink'].push(element.name);
167
+ var sink_url = process.env.DEV_HTTP + process.env.DEV_PORT + "/uploads/assets/default/".concat(sink_match[1], ".gltf");
168
+ json_data.sink = sink_url;
169
+ } else if (temp.some(function (felement) {
170
+ return felement.name.includes('base_drawer');
171
+ }) && element.name.includes('interior_drawer')) {
172
+ var objCnt = temp.filter(function (felement) {
173
+ return felement.name.includes('base_drawer') && !felement.name.includes('_door');
174
+ }).length;
175
+ var phCnt = tempPlaceholders.filter(function (felement) {
176
+ return felement.name.includes('interior');
177
+ }).length;
178
+ drawerPHs = phCnt;
179
+ if (objCnt === 1 || phCnt % objCnt !== 0) {
180
+ if (tempData['base_drawer_1'] === undefined) {
181
+ tempData['base_drawer_1'] = [];
182
+ }
183
+ tempData['base_drawer_1'].push(element.name);
184
+ drawerKey++;
185
+ } else if (objCnt > 1 && phCnt % objCnt === 0) {
186
+ if (tempData['base_drawer_' + (drawerKey % objCnt + 1)] === undefined) {
187
+ tempData['base_drawer_' + (drawerKey % objCnt + 1)] = [];
188
+ }
189
+ tempData['base_drawer_' + (drawerKey % objCnt + 1)].push(element.name);
190
+ drawerKey++;
191
+ }
192
+ } else if (temp.some(function (felement) {
193
+ return felement.name.includes('base_door');
194
+ }) && !element.name.includes('interior_drawer') && !element.name.includes('drawer') && element.name.includes('door')) {
195
+ var _objCnt = temp.filter(function (felement) {
196
+ return felement.name.includes('base_door');
197
+ }).length;
198
+ var _phCnt = tempPlaceholders.filter(function (felement) {
199
+ return !felement.name.includes('interior') && !felement.name.includes('drawer') && felement.name.includes('door');
200
+ }).length;
201
+ doorPHs = _phCnt;
202
+ if (_objCnt === 1 || _phCnt % _objCnt !== 0) {
203
+ if (tempData['base_door_1'] === undefined) {
204
+ tempData['base_door_1'] = [];
205
+ }
206
+ tempData['base_door_1'].push(element.name);
207
+ doorKey++;
208
+ } else if (_objCnt > 1) {
209
+ if (tempData['base_door_' + (doorKey % _objCnt + 1)] === undefined) {
210
+ tempData['base_door_' + (doorKey % _objCnt + 1)] = [];
211
+ }
212
+ tempData['base_door_' + (doorKey % _objCnt + 1)].push(element.name);
213
+ doorKey++;
214
+ }
215
+ } else if (temp.some(function (felement) {
216
+ return felement.name.includes('base_fixed_drawer_door');
217
+ }) && element.name.includes('_drawer_door_fixed')) {
218
+ var _objCnt2 = temp.filter(function (felement) {
219
+ return felement.name.includes('base_fixed_drawer_door');
220
+ }).length;
221
+ var _phCnt2 = tempPlaceholders.filter(function (felement) {
222
+ return felement.name.includes('_drawer_door_fixed');
223
+ }).length;
224
+ fixedPHs = _phCnt2;
225
+ if (_objCnt2 === 1 || _phCnt2 % _objCnt2 !== 0) {
226
+ if (tempData['base_fixed_drawer_door_1'] === undefined) {
227
+ tempData['base_fixed_drawer_door_1'] = [];
228
+ }
229
+ tempData['base_fixed_drawer_door_1'].push(element.name);
230
+ fixedKey++;
231
+ } else if (_objCnt2 > 1) {
232
+ if (tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] === undefined) {
233
+ tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] = [];
234
+ }
235
+ tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)].push(element.name);
236
+ fixedKey++;
237
+ }
238
+ }
239
+ });
240
+ } else if (t.name.includes('base_drawer') && !t.name.includes('_door')) {
241
+ var objCnt = temp.filter(function (felement) {
242
+ return felement.name.includes('base_drawer') && !felement.name.includes('_door');
243
+ }).length;
244
+ if (objCnt === 1 || drawerPHs % objCnt !== 0) {
245
+ if (tempData['base_drawer_door_1'] === undefined) tempData['base_drawer_door_1'] = [];
246
+ //get drawer door handle placeholders
247
+ var ph_temp = temp.find(function (felement) {
248
+ return felement.name === 'base_drawer_door_1';
249
+ });
250
+ if (ph_temp != undefined) {
251
+ var ph_drawer_door_handle = ph_temp.data.nodes;
252
+ ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
253
+ return element.name.startsWith('ph_') && element.name.includes('handle');
254
+ });
255
+ for (var w = 0; w < drawerPHs; w++) {
256
+ if (!tempData['base_drawer_door_1'].some(function (el) {
257
+ return el === 'base_drawer_door_1/' + tempPlaceholders[0].name;
258
+ })) {
259
+ tempData['base_drawer_door_1'].push('base_drawer_1/' + tempPlaceholders[0].name);
260
+ //add drawer door handle placeholders
261
+ if (tempData['drawer_door_handle_1'] === undefined) tempData['drawer_door_handle_1'] = [];
262
+ if (ph_drawer_door_handle.length > 0) tempData['drawer_door_handle_1'].push('base_drawer_door_1/' + ph_drawer_door_handle[0].name);
263
+ }
264
+ }
265
+ }
266
+ } else if (objCnt > 1 && drawerPHs > 0 && drawerPHs % objCnt === 0) {
267
+ if (tempData['base_drawer_door' + t.name.slice(-2)] === undefined) tempData['base_drawer_door' + t.name.slice(-2)] = [];
268
+ //get drawer door handle placeholders
269
+ var ph_temp = temp.find(function (felement) {
270
+ return felement.name === 'base_drawer_door' + t.name.slice(-2);
271
+ });
272
+ if (ph_temp != undefined) {
273
+ var ph_drawer_door_handle = ph_temp.data.data.nodes;
274
+ ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) {
275
+ return element.name.startsWith('ph_') && element.name.includes('handle');
276
+ });
277
+ tempPlaceholders.forEach(function (element) {
278
+ if (!tempData['base_drawer_door' + t.name.slice(-2)].some(function (el) {
279
+ return el === t.name + '/' + element.name;
280
+ })) {
281
+ tempData['base_drawer_door' + t.name.slice(-2)].push(t.name + '/' + element.name);
282
+ //add drawer door handle placeholders
283
+ if (tempData['drawer_door_handle' + t.name.slice(-2)] === undefined) tempData['drawer_door_handle' + t.name.slice(-2)] = [];
284
+ if (ph_drawer_door_handle.length > 0) tempData['drawer_door_handle' + t.name.slice(-2)].push('base_drawer_door' + t.name.slice(-2) + '/' + ph_drawer_door_handle[0].name);
285
+ }
286
+ });
287
+ }
288
+ }
289
+ } else if (t.name.includes('base_door')) {
290
+ var _objCnt3 = temp.filter(function (felement) {
291
+ return felement.name.includes('base_door');
292
+ }).length;
293
+ tempPlaceholders = tempPlaceholders.filter(function (el) {
294
+ return el.name.includes('handle');
295
+ });
296
+ if (tempPlaceholders.length > 0) if (_objCnt3 === 1 || doorPHs % _objCnt3 !== 0) {
297
+ if (tempData['door_handle_1'] === undefined) {
298
+ tempData['door_handle_1'] = [];
299
+ }
300
+ var _loop = function _loop() {
301
+ var phname = tempPlaceholders[0].name;
302
+ var newph = undefined;
303
+ if (tempData['base_door_1'][_w].isLeftPlaceholder()) {
304
+ newph = tempPlaceholders.find(function (el) {
305
+ return el.name.isRightPlaceholder();
306
+ });
307
+ }
308
+ if (tempData['base_door_1'][_w].isRightPlaceholder()) {
309
+ newph = tempPlaceholders.find(function (el) {
310
+ return el.name.isLeftPlaceholder();
311
+ });
312
+ }
313
+ if (newph != undefined) {
314
+ phname = newph.name;
315
+ }
316
+ if (doorPHs === 1 && tempPlaceholders.find(function (el) {
317
+ return el.name.isLeftPlaceholder();
318
+ }) != undefined && tempPlaceholders.find(function (el) {
319
+ return el.name.isRightPlaceholder();
320
+ }) != undefined) {
321
+ has_single_door = true;
322
+ }
323
+ if (!tempData['door_handle_1'].some(function (el) {
324
+ return el === 'door_handle_1/' + phname;
325
+ })) {
326
+ tempData['door_handle_1'].push('base_door_1/' + phname);
327
+ }
328
+ };
329
+ for (var _w = 0; _w < doorPHs; _w++) {
330
+ _loop();
331
+ }
332
+ } else if (_objCnt3 > 1 && doorPHs > 0 && doorPHs % _objCnt3 === 0) {
333
+ if (tempData['door_handle' + t.name.slice(-2)] === undefined) tempData['door_handle' + t.name.slice(-2)] = [];
334
+ phname = tempPlaceholders[0].name;
335
+ newph = undefined;
336
+ var blAdd = true;
337
+ if (element.is_corner) {
338
+ if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
339
+ newph = tempPlaceholders.find(function (el) {
340
+ return el.name.isLeftPlaceholder();
341
+ });
342
+ } else {
343
+ blAdd = false;
344
+ }
345
+ } else {
346
+ if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
347
+ newph = tempPlaceholders.find(function (el) {
348
+ return el.name.isRightPlaceholder();
349
+ });
350
+ }
351
+ if (tempData['base_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
352
+ newph = tempPlaceholders.find(function (el) {
353
+ return el.name.isLeftPlaceholder();
354
+ });
355
+ }
356
+ }
357
+ if (blAdd) {
358
+ if (newph != undefined) {
359
+ phname = newph.name;
360
+ }
361
+ if (!tempData['door_handle' + t.name.slice(-2)].some(function (el) {
362
+ return el === t.name + '/' + phname;
363
+ })) {
364
+ tempData['door_handle' + t.name.slice(-2)].push(t.name + '/' + phname);
365
+ }
366
+ }
367
+ }
368
+ } else if (t.name.includes('base_fixed_drawer_door')) {
369
+ var _objCnt4 = temp.filter(function (felement) {
370
+ return felement.name.includes('base_fixed_drawer_door');
371
+ }).length;
372
+ tempPlaceholders = tempPlaceholders.filter(function (el) {
373
+ return el.name.includes('handle');
374
+ });
375
+ if (tempPlaceholders.length > 0) if (_objCnt4 === 1 || fixedPHs % _objCnt4 !== 0) {
376
+ if (tempData['fixed_drawer_door_handle_1'] === undefined) tempData['fixed_drawer_door_handle_1'] = [];
377
+ for (var _w2 = 0; _w2 < fixedPHs; _w2++) {
378
+ phname = tempPlaceholders[0].name;
379
+ newph = undefined;
380
+ if (tempData['base_fixed_drawer_door_1'][_w2].isLeftPlaceholder()) {
381
+ newph = tempPlaceholders.find(function (el) {
382
+ return el.name.isRightPlaceholder();
383
+ });
384
+ }
385
+ if (tempData['base_fixed_drawer_door_1'][_w2].isRightPlaceholder()) {
386
+ newph = tempPlaceholders.find(function (el) {
387
+ return el.name.isLeftPlaceholder();
388
+ });
389
+ }
390
+ if (newph != undefined) {
391
+ phname = newph.name;
392
+ }
393
+ if (!tempData['fixed_drawer_door_handle_1'].some(function (el) {
394
+ return el === 'fixed_drawer_door_handle_1/' + phname;
395
+ })) {
396
+ tempData['fixed_drawer_door_handle_1'].push('base_fixed_drawer_door_1/' + phname);
397
+ }
398
+ }
399
+ } else if (_objCnt4 > 1 && fixedPHs > 0 && fixedPHs % _objCnt4 === 0) {
400
+ if (tempData['fixed_drawer_door_handle' + t.name.slice(-2)] === undefined) {
401
+ tempData['fixed_drawer_door_handle' + t.name.slice(-2)] = [];
402
+ }
403
+ phname = tempPlaceholders[0].name;
404
+ newph = undefined;
405
+ if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isLeftPlaceholder()) {
406
+ newph = tempPlaceholders.find(function (el) {
407
+ return el.name.isRightPlaceholder();
408
+ });
409
+ }
410
+ if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isRightPlaceholder()) {
411
+ newph = tempPlaceholders.find(function (el) {
412
+ return el.name.isLeftPlaceholder();
413
+ });
414
+ }
415
+ if (newph != undefined) {
416
+ phname = newph.name;
417
+ }
418
+ if (!tempData['fixed_drawer_door_handle' + t.name.slice(-2)].some(function (el) {
419
+ return el === t.name + '/' + phname;
420
+ })) {
421
+ tempData['fixed_drawer_door_handle' + t.name.slice(-2)].push(t.name + '/' + phname);
422
+ }
423
+ }
424
+ }
425
+ }
426
+ });
427
+ tempPlaceholdersData.push({
428
+ id: parseInt(el, 10),
429
+ placeholders: tempData
430
+ });
431
+ return _context3.abrupt("return", tempPlaceholdersData);
432
+ case 5:
433
+ case "end":
434
+ return _context3.stop();
435
+ }
436
+ }, _callee3);
437
+ }));
438
+ return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
439
+ }
440
+ export function updateCabinetPayload(_x6) {
441
+ return _updateCabinetPayload.apply(this, arguments);
442
+ }
443
+ function _updateCabinetPayload() {
444
+ _updateCabinetPayload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(cabinetPayload) {
445
+ var tempPlaceholders, cabinetPayloadKeys, i;
446
+ return _regeneratorRuntime.wrap(function (_context4) {
447
+ while (1) switch (_context4.prev = _context4.next) {
448
+ case 0:
449
+ tempPlaceholders = [];
450
+ _context4.next = 1;
451
+ return parseTempPlaceholdersFromCabinetPayload(cabinetPayload);
452
+ case 1:
453
+ tempPlaceholders = _context4.sent;
454
+ cabinetPayloadKeys = Object.keys(cabinetPayload);
455
+ for (i = 0; i < cabinetPayloadKeys.length; i++) {
456
+ if (cabinetPayloadKeys[i] === 'structure_json') {
457
+ cabinetPayload[cabinetPayloadKeys[i]]['placeholders'] = tempPlaceholders[0].placeholders;
458
+ cabinetPayload[cabinetPayloadKeys[i]]['tempPlaceholders'] = tempPlaceholders;
459
+ }
460
+ }
461
+ return _context4.abrupt("return", cabinetPayload);
462
+ case 2:
463
+ case "end":
464
+ return _context4.stop();
465
+ }
466
+ }, _callee4);
467
+ }));
468
+ return _updateCabinetPayload.apply(this, arguments);
469
+ }
470
+ export function handleExternalEvent(_x7) {
471
+ return _handleExternalEvent.apply(this, arguments);
472
+ }
473
+ function _handleExternalEvent() {
474
+ _handleExternalEvent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(props) {
475
+ var evt, state, sLineCnt, elementJs, _element, catalog, outlineSVGData, catalogInstance, _evt$payload, moveType, moveValue, value, defaulTitle, _evt$payload2, doorStyle, itemCDS, isAll, _doorStyle, _value, _zoomValue, _value2, _zoomValue2, _evt$payload3, moldingInfo, isGlobal, _t5, _t6;
476
+ return _regeneratorRuntime.wrap(function (_context5) {
477
+ while (1) switch (_context5.prev = _context5.next) {
76
478
  case 0:
77
479
  evt = props.externalEvent;
78
480
  state = props.state.get('KitchenConfigurator');
79
- _t2 = evt === null || evt === void 0 ? void 0 : evt.type;
80
- _context2.next = _t2 === EXTERNAL_EVENT_TOGGLE_TO_3D ? 1 : _t2 === EXTERNAL_EVENT_TOGGLE_TO_2D ? 2 : _t2 === EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 3 : _t2 === EXTERNAL_EVENT_ADD_WALL ? 4 : _t2 === EXTERNAL_EVENT_ADD_ITEM ? 5 : _t2 === EXTERNAL_EVENT_MOVE_PAN ? 9 : _t2 === EXTERNAL_EVENT_NEW_PROJECT ? 15 : _t2 === EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 16 : _t2 === EXTERNAL_EVENT_SET_INITIAL_DATA ? 17 : _t2 === EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 18 : _t2 === EXTERNAL_EVENT_ZOOM_IN ? 19 : _t2 === EXTERNAL_EVENT_ZOOM_OUT ? 22 : _t2 === EXTERNAL_EVENT_UNDO ? 25 : _t2 === EXTERNAL_EVENT_REDO ? 26 : _t2 === EXTERNAL_EVENT_SET_MOLDING ? 27 : 28;
481
+ _t5 = evt === null || evt === void 0 ? void 0 : evt.type;
482
+ _context5.next = _t5 === EXTERNAL_EVENT_TOGGLE_TO_3D ? 1 : _t5 === EXTERNAL_EVENT_TOGGLE_TO_2D ? 2 : _t5 === EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 3 : _t5 === EXTERNAL_EVENT_ADD_WALL ? 4 : _t5 === EXTERNAL_EVENT_ADD_ITEM ? 5 : _t5 === EXTERNAL_EVENT_MOVE_PAN ? 10 : _t5 === EXTERNAL_EVENT_NEW_PROJECT ? 16 : _t5 === EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 17 : _t5 === EXTERNAL_EVENT_SET_INITIAL_DATA ? 18 : _t5 === EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 19 : _t5 === EXTERNAL_EVENT_ZOOM_IN ? 20 : _t5 === EXTERNAL_EVENT_ZOOM_OUT ? 23 : _t5 === EXTERNAL_EVENT_UNDO ? 26 : _t5 === EXTERNAL_EVENT_REDO ? 27 : _t5 === EXTERNAL_EVENT_SET_MOLDING ? 28 : 29;
81
483
  break;
82
484
  case 1:
83
485
  props.projectActions.setMode(MODE_IDLE_3D);
84
- return _context2.abrupt("continue", 28);
486
+ return _context5.abrupt("continue", 29);
85
487
  case 2:
86
488
  props.projectActions.setMode(MODE_IDLE);
87
- return _context2.abrupt("continue", 28);
489
+ return _context5.abrupt("continue", 29);
88
490
  case 3:
89
491
  sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
90
492
  if (sLineCnt > 0) props.projectActions.setMode(MODE_ELEVATION_VIEW);
91
- return _context2.abrupt("continue", 28);
493
+ return _context5.abrupt("continue", 29);
92
494
  case 4:
93
495
  if (state.mode === MODE_IDLE || state.mode === MODE_2D_PAN) props.linesActions.selectToolDrawingLine('wall');else {
94
496
  props.projectActions.setMode(MODE_IDLE);
95
497
  props.linesActions.selectToolDrawingLine('wall');
96
498
  }
97
- return _context2.abrupt("continue", 28);
499
+ return _context5.abrupt("continue", 29);
98
500
  case 5:
99
501
  if (isEmpty(evt === null || evt === void 0 ? void 0 : evt.payload)) {
100
- _context2.next = 8;
502
+ _context5.next = 9;
101
503
  break;
102
504
  }
103
- element = evt.payload;
505
+ _element = evt.payload;
104
506
  catalog = state.getIn(['catalog']).toJS(); // add item to catalog of state
105
- if (!isEmpty(catalog === null || catalog === void 0 ? void 0 : catalog.elements[element.name])) {
106
- _context2.next = 7;
507
+ if (!isEmpty(catalog === null || catalog === void 0 ? void 0 : catalog.elements[_element.name])) {
508
+ _context5.next = 8;
107
509
  break;
108
510
  }
109
- _context2.next = 6;
110
- return loadSVGsByItem(element);
511
+ _context5.next = 6;
512
+ return loadSVGsByItem(_element);
111
513
  case 6:
112
- outlineSVGData = _context2.sent;
514
+ outlineSVGData = _context5.sent;
113
515
  catalogInstance = props.catalog;
114
- elementJs = exporter(_objectSpread(_objectSpread({}, element), {}, {
516
+ _context5.next = 7;
517
+ return updateCabinetPayload(_element);
518
+ case 7:
519
+ elementJs = _context5.sent;
520
+ elementJs = exporter(_objectSpread(_objectSpread({}, elementJs), {}, {
115
521
  outlineSVGData: outlineSVGData,
116
522
  type: 'cabinet',
117
523
  render2DItem: render2DItem,
@@ -121,51 +527,51 @@ function _handleExternalEvent() {
121
527
  catalogInstance.registerElement(elementJs);
122
528
  props.projectActions.addElementToCatalog(elementJs);
123
529
  }
124
- case 7:
530
+ case 8:
125
531
  // start drawing item
126
- ARRAY_3D_MODES.includes(state.mode) ? props.itemsActions.selectToolDrawingItem3D(element.name) : props.itemsActions.selectToolDrawingItem(element.name);
127
- props.projectActions.pushLastSelectedCatalogElementToHistory(element);
532
+ ARRAY_3D_MODES.includes(state.mode) ? props.itemsActions.selectToolDrawingItem3D(_element.name) : props.itemsActions.selectToolDrawingItem(_element.name);
533
+ props.projectActions.pushLastSelectedCatalogElementToHistory(_element);
128
534
  props.projectActions.setIsCabinetDrawing(true);
129
- case 8:
130
- return _context2.abrupt("continue", 28);
131
535
  case 9:
536
+ return _context5.abrupt("continue", 29);
537
+ case 10:
132
538
  _evt$payload = evt.payload, moveType = _evt$payload.moveType, moveValue = _evt$payload.moveValue;
133
539
  value = state.getIn(['viewer2D']).toJS();
134
- _t3 = moveType;
135
- _context2.next = _t3 === TOP ? 10 : _t3 === BOTTOM ? 11 : _t3 === RIGHT ? 12 : _t3 === LEFT ? 13 : 14;
540
+ _t6 = moveType;
541
+ _context5.next = _t6 === TOP ? 11 : _t6 === BOTTOM ? 12 : _t6 === RIGHT ? 13 : _t6 === LEFT ? 14 : 15;
136
542
  break;
137
- case 10:
138
- value.f -= moveValue;
139
- return _context2.abrupt("continue", 14);
140
543
  case 11:
141
- value.f += moveValue;
142
- return _context2.abrupt("continue", 14);
544
+ value.f -= moveValue;
545
+ return _context5.abrupt("continue", 15);
143
546
  case 12:
144
- value.e += moveValue;
145
- return _context2.abrupt("continue", 14);
547
+ value.f += moveValue;
548
+ return _context5.abrupt("continue", 15);
146
549
  case 13:
147
- value.e -= moveValue;
148
- return _context2.abrupt("continue", 14);
550
+ value.e += moveValue;
551
+ return _context5.abrupt("continue", 15);
149
552
  case 14:
150
- if (compareSVGRect(value)) props.viewer2DActions.updateCameraView(value);
151
- return _context2.abrupt("continue", 28);
553
+ value.e -= moveValue;
554
+ return _context5.abrupt("continue", 15);
152
555
  case 15:
556
+ if (compareSVGRect(value)) props.viewer2DActions.updateCameraView(value);
557
+ return _context5.abrupt("continue", 29);
558
+ case 16:
153
559
  defaulTitle = 'Untitle';
154
560
  props.projectActions.newProject();
155
561
  props.projectActions.rename(defaulTitle);
156
- return _context2.abrupt("continue", 28);
157
- case 16:
562
+ return _context5.abrupt("continue", 29);
563
+ case 17:
158
564
  _evt$payload2 = evt.payload, doorStyle = _evt$payload2.doorStyle, itemCDS = _evt$payload2.itemCDS, isAll = _evt$payload2.isAll;
159
565
  props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll);
160
- return _context2.abrupt("continue", 28);
161
- case 17:
566
+ return _context5.abrupt("continue", 29);
567
+ case 18:
162
568
  _doorStyle = evt.payload.doorStyle;
163
569
  props.itemsActions.setInitialDoorStyle(_doorStyle.doorStyle);
164
- return _context2.abrupt("continue", 28);
165
- case 18:
166
- props.projectActions.loadProject(evt.payload);
167
- return _context2.abrupt("continue", 28);
570
+ return _context5.abrupt("continue", 29);
168
571
  case 19:
572
+ props.projectActions.loadProject(evt.payload);
573
+ return _context5.abrupt("continue", 29);
574
+ case 20:
169
575
  _value = state.getIn(['viewer2D']).toJS();
170
576
  _value.a -= 0.1;
171
577
  _value.d -= 0.1;
@@ -173,17 +579,17 @@ function _handleExternalEvent() {
173
579
  _value.f += _value.SVGHeight * 0.1 / 2;
174
580
  _zoomValue = parseInt((_value.a - 0.5) / ZOOM_VARIABLE);
175
581
  if (!(_zoomValue > 404)) {
176
- _context2.next = 20;
582
+ _context5.next = 21;
177
583
  break;
178
584
  }
179
- return _context2.abrupt("return");
180
- case 20:
585
+ return _context5.abrupt("return");
586
+ case 21:
181
587
  if (!(_zoomValue < 35 || Number.isNaN(_zoomValue))) {
182
- _context2.next = 21;
588
+ _context5.next = 22;
183
589
  break;
184
590
  }
185
- return _context2.abrupt("return");
186
- case 21:
591
+ return _context5.abrupt("return");
592
+ case 22:
187
593
  while (!(_value.e <= 10)) {
188
594
  _value.e -= 0.1;
189
595
  }
@@ -197,8 +603,8 @@ function _handleExternalEvent() {
197
603
  _value.f += 0.1;
198
604
  }
199
605
  if (compareSVGRect(_value)) props.viewer2DActions.updateCameraView(_value);
200
- return _context2.abrupt("continue", 28);
201
- case 22:
606
+ return _context5.abrupt("continue", 29);
607
+ case 23:
202
608
  _value2 = state.getIn(['viewer2D']).toJS();
203
609
  _value2.a += 0.1;
204
610
  _value2.d += 0.1;
@@ -206,34 +612,34 @@ function _handleExternalEvent() {
206
612
  _value2.f -= _value2.SVGHeight * 0.1 / 2;
207
613
  _zoomValue2 = parseInt((_value2.a - 0.5) / ZOOM_VARIABLE);
208
614
  if (!(_zoomValue2 > 404)) {
209
- _context2.next = 23;
615
+ _context5.next = 24;
210
616
  break;
211
617
  }
212
- return _context2.abrupt("return");
213
- case 23:
618
+ return _context5.abrupt("return");
619
+ case 24:
214
620
  if (!(_zoomValue2 < 35 || Number.isNaN(_zoomValue2))) {
215
- _context2.next = 24;
621
+ _context5.next = 25;
216
622
  break;
217
623
  }
218
- return _context2.abrupt("return");
219
- case 24:
220
- if (compareSVGRect(_value2)) props.viewer2DActions.updateCameraView(_value2);
221
- return _context2.abrupt("continue", 28);
624
+ return _context5.abrupt("return");
222
625
  case 25:
223
- props.projectActions.undo();
224
- return _context2.abrupt("continue", 28);
626
+ if (compareSVGRect(_value2)) props.viewer2DActions.updateCameraView(_value2);
627
+ return _context5.abrupt("continue", 29);
225
628
  case 26:
226
- props.projectActions.redo();
227
- return _context2.abrupt("continue", 28);
629
+ props.projectActions.undo();
630
+ return _context5.abrupt("continue", 29);
228
631
  case 27:
632
+ props.projectActions.redo();
633
+ return _context5.abrupt("continue", 29);
634
+ case 28:
229
635
  _evt$payload3 = evt.payload, moldingInfo = _evt$payload3.moldingInfo, isGlobal = _evt$payload3.isGlobal;
230
636
  props.itemsActions.setMolding(moldingInfo, isGlobal);
231
- return _context2.abrupt("continue", 28);
232
- case 28:
637
+ return _context5.abrupt("continue", 29);
638
+ case 29:
233
639
  case "end":
234
- return _context2.stop();
640
+ return _context5.stop();
235
641
  }
236
- }, _callee2);
642
+ }, _callee5);
237
643
  }));
238
644
  return _handleExternalEvent.apply(this, arguments);
239
645
  }