kitchen-simulator 1.0.0-alin.9 → 1.0.0-clark.101

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