kitchen-simulator 1.0.0-alin.8 → 1.0.0-clark.100

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 +3 -3
@@ -4,7 +4,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import { fromJS, List, Map, Record } from 'immutable';
7
- import { EXTERNAL_EVENT_ADD_WALL, EXTERNAL_EVENT_TOGGLE_TO_3D, EXTERNAL_EVENT_TOGGLE_TO_2D, EXTERNAL_EVENT_TOGGLE_TO_ELEVATION, EXTERNAL_EVENT_MOVE_PAN, MODE_IDLE, MODE_2D_PAN, EXTERNAL_EVENT_ADD_ITEM, ARRAY_3D_MODES, MODE_IDLE_3D, MODE_ELEVATION_VIEW, TOP, BOTTOM, LEFT, RIGHT, EXTERNAL_EVENT_NEW_PROJECT } from "../constants";
7
+ import { EXTERNAL_EVENT_ADD_WALL, EXTERNAL_EVENT_TOGGLE_TO_3D, EXTERNAL_EVENT_TOGGLE_TO_2D, EXTERNAL_EVENT_TOGGLE_TO_ELEVATION, EXTERNAL_EVENT_MOVE_PAN, MODE_IDLE, MODE_2D_PAN, EXTERNAL_EVENT_ADD_ITEM, ARRAY_3D_MODES, MODE_IDLE_3D, MODE_ELEVATION_VIEW, TOP, BOTTOM, LEFT, RIGHT, EXTERNAL_EVENT_NEW_PROJECT, EXTERNAL_EVENT_CHANGE_DOORSTYLE, EXTERNAL_EVENT_SET_INITIAL_DATA, EXTERNAL_EVENT_ADD_ROOM_SHAPE, EXTERNAL_EVENT_ZOOM_IN, EXTERNAL_EVENT_ZOOM_OUT, ZOOM_VARIABLE, EXTERNAL_EVENT_UNDO, EXTERNAL_EVENT_REDO, EXTERNAL_EVENT_SET_MOLDING, EXTERNAL_EVENT_PROJECT_SETTING, PROJECT_SETTING_OPTION, EXTERNAL_EVENT_CHANGE_DISTANCE, EXTERNAL_EVENT_SYNC_SCENE, INTERNAL_EVENT_SYNC_SCENE } from "../constants";
8
8
  import { isEmpty } from "./helper";
9
9
  import exporter from "../catalog/utils/exporter";
10
10
  import { render2DItem, render3DItem } from "../catalog/utils/item-loader";
@@ -62,98 +62,619 @@ var loadSVGsByItem = /*#__PURE__*/function () {
62
62
  return _ref.apply(this, arguments);
63
63
  };
64
64
  }();
65
- export function handleExternalEvent(_x2, _x3) {
66
- return _handleExternalEvent.apply(this, arguments);
65
+ var compareSVGRect = function compareSVGRect(value) {
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
+ };
68
+ function loadJSON(_x2, _x3, _x4) {
69
+ return _loadJSON.apply(this, arguments);
67
70
  }
68
- function _handleExternalEvent() {
69
- _handleExternalEvent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(evt, props) {
70
- var state, sLineCnt, element, catalog, outlineSVGData, catalogInstance, elementJs, _evt$payload, moveType, moveValue, value, defaulTitle, _t2, _t3;
71
+ /********Parse TempPlaceholder from cabinetPayloadData **************/
72
+ function _loadJSON() {
73
+ _loadJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(path, success, error) {
71
74
  return _regeneratorRuntime.wrap(function (_context2) {
72
75
  while (1) switch (_context2.prev = _context2.next) {
73
76
  case 0:
74
- state = props.state;
75
- _t2 = evt === null || evt === void 0 ? void 0 : evt.type;
76
- _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 : 16;
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, 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;
476
+ return _regeneratorRuntime.wrap(function (_context5) {
477
+ while (1) switch (_context5.prev = _context5.next) {
478
+ case 0:
479
+ console.log('***external event****', props.externalEvent);
480
+ evt = props.externalEvent;
481
+ state = props.state.get('KitchenConfigurator');
482
+ _t5 = evt === null || evt === void 0 ? void 0 : evt.type;
483
+ _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 : _t5 === EXTERNAL_EVENT_PROJECT_SETTING ? 29 : _t5 === EXTERNAL_EVENT_CHANGE_DISTANCE ? 30 : _t5 === EXTERNAL_EVENT_SYNC_SCENE ? 31 : 32;
77
484
  break;
78
485
  case 1:
79
486
  props.projectActions.setMode(MODE_IDLE_3D);
80
- return _context2.abrupt("continue", 16);
487
+ return _context5.abrupt("continue", 32);
81
488
  case 2:
82
489
  props.projectActions.setMode(MODE_IDLE);
83
- return _context2.abrupt("continue", 16);
490
+ return _context5.abrupt("continue", 32);
84
491
  case 3:
85
- sLineCnt = state.getIn(['KitchenConfigurator', 'scene', 'layers', 'layer-1', 'selected', 'lines']).size;
492
+ sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size;
86
493
  if (sLineCnt > 0) props.projectActions.setMode(MODE_ELEVATION_VIEW);
87
- return _context2.abrupt("continue", 16);
494
+ return _context5.abrupt("continue", 32);
88
495
  case 4:
89
496
  if (state.mode === MODE_IDLE || state.mode === MODE_2D_PAN) props.linesActions.selectToolDrawingLine('wall');else {
90
497
  props.projectActions.setMode(MODE_IDLE);
91
498
  props.linesActions.selectToolDrawingLine('wall');
92
499
  }
93
- return _context2.abrupt("continue", 16);
500
+ return _context5.abrupt("continue", 32);
94
501
  case 5:
95
502
  if (isEmpty(evt === null || evt === void 0 ? void 0 : evt.payload)) {
96
- _context2.next = 8;
503
+ _context5.next = 9;
97
504
  break;
98
505
  }
99
- element = evt.payload;
100
- catalog = state.getIn(['KitchenConfigurator', 'catalog']).toJS(); // add item to catalog of state
101
- if (!isEmpty(catalog === null || catalog === void 0 ? void 0 : catalog.elements[element.name])) {
102
- _context2.next = 7;
506
+ _element = evt.payload;
507
+ catalog = state.getIn(['catalog']).toJS(); // add item to catalog of state
508
+ updatedStructureJson = _objectSpread(_objectSpread({}, _element.structure_json), _element.structure_json.tempPlaceholders[0].structure);
509
+ _element = _objectSpread(_objectSpread({}, _element), {}, {
510
+ cds: {
511
+ data: [_objectSpread({}, _element.customer_property)],
512
+ itemID: _element.itemID
513
+ }
514
+ });
515
+ _element.structure_json = updatedStructureJson;
516
+ if (!isEmpty(catalog === null || catalog === void 0 ? void 0 : catalog.elements[_element.name])) {
517
+ _context5.next = 8;
103
518
  break;
104
519
  }
105
- _context2.next = 6;
106
- return loadSVGsByItem(element);
520
+ _context5.next = 6;
521
+ return loadSVGsByItem(_element);
107
522
  case 6:
108
- outlineSVGData = _context2.sent;
523
+ outlineSVGData = _context5.sent;
109
524
  catalogInstance = props.catalog;
110
- elementJs = exporter(_objectSpread(_objectSpread({}, element), {}, {
525
+ _context5.next = 7;
526
+ return updateCabinetPayload(_element);
527
+ case 7:
528
+ elementJs = _context5.sent;
529
+ elementJs = exporter(_objectSpread(_objectSpread({}, elementJs), {}, {
111
530
  outlineSVGData: outlineSVGData,
112
531
  type: 'cabinet',
113
532
  render2DItem: render2DItem,
114
533
  render3DItem: render3DItem
115
534
  }));
116
535
  if (catalogInstance !== null && catalogInstance !== void 0 && catalogInstance.validateElement(elementJs)) {
536
+ catalogInstance.registerElement(elementJs);
117
537
  props.projectActions.addElementToCatalog(elementJs);
118
538
  }
119
- case 7:
539
+ case 8:
120
540
  // start drawing item
121
- ARRAY_3D_MODES.includes(state.mode) ? props.itemsActions.selectToolDrawingItem3D(element.name) : props.itemsActions.selectToolDrawingItem(element.name);
122
- props.projectActions.pushLastSelectedCatalogElementToHistory(element);
541
+ ARRAY_3D_MODES.includes(state.mode) ? props.itemsActions.selectToolDrawingItem3D(_element.name) : props.itemsActions.selectToolDrawingItem(_element.name);
542
+ props.projectActions.pushLastSelectedCatalogElementToHistory(_element);
123
543
  props.projectActions.setIsCabinetDrawing(true);
124
- case 8:
125
- return _context2.abrupt("continue", 16);
126
544
  case 9:
545
+ return _context5.abrupt("continue", 32);
546
+ case 10:
127
547
  _evt$payload = evt.payload, moveType = _evt$payload.moveType, moveValue = _evt$payload.moveValue;
128
- value = state.getIn(['KitchenConfigurator', 'viewer2D']).toJS();
129
- _t3 = moveType;
130
- _context2.next = _t3 === TOP ? 10 : _t3 === BOTTOM ? 11 : _t3 === RIGHT ? 12 : _t3 === LEFT ? 13 : 14;
548
+ value = state.getIn(['viewer2D']).toJS();
549
+ _t6 = moveType;
550
+ _context5.next = _t6 === TOP ? 11 : _t6 === BOTTOM ? 12 : _t6 === RIGHT ? 13 : _t6 === LEFT ? 14 : 15;
131
551
  break;
132
- case 10:
133
- value.f -= moveValue;
134
- return _context2.abrupt("continue", 14);
135
552
  case 11:
136
- value.f += moveValue;
137
- return _context2.abrupt("continue", 14);
553
+ value.f -= moveValue;
554
+ return _context5.abrupt("continue", 15);
138
555
  case 12:
139
- value.e += moveValue;
140
- return _context2.abrupt("continue", 14);
556
+ value.f += moveValue;
557
+ return _context5.abrupt("continue", 15);
141
558
  case 13:
142
- value.e -= moveValue;
143
- return _context2.abrupt("continue", 14);
559
+ value.e += moveValue;
560
+ return _context5.abrupt("continue", 15);
144
561
  case 14:
145
- 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);
146
- return _context2.abrupt("continue", 16);
562
+ value.e -= moveValue;
563
+ return _context5.abrupt("continue", 15);
147
564
  case 15:
565
+ if (compareSVGRect(value)) props.viewer2DActions.updateCameraView(value);
566
+ return _context5.abrupt("continue", 32);
567
+ case 16:
148
568
  defaulTitle = 'Untitle';
149
569
  props.projectActions.newProject();
150
570
  props.projectActions.rename(defaulTitle);
151
- return _context2.abrupt("continue", 16);
152
- case 16:
571
+ return _context5.abrupt("continue", 32);
572
+ case 17:
573
+ _evt$payload2 = evt.payload, doorStyle = _evt$payload2.doorStyle, itemCDS = _evt$payload2.itemCDS, isAll = _evt$payload2.isAll;
574
+ props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll);
575
+ return _context5.abrupt("continue", 32);
576
+ case 18:
577
+ _doorStyle = evt.payload.doorStyle;
578
+ props.itemsActions.setInitialDoorStyle(_doorStyle.doorStyle);
579
+ return _context5.abrupt("continue", 32);
580
+ case 19:
581
+ props.projectActions.loadProject(evt.payload);
582
+ return _context5.abrupt("continue", 32);
583
+ case 20:
584
+ _value = state.getIn(['viewer2D']).toJS();
585
+ _value.a -= 0.1;
586
+ _value.d -= 0.1;
587
+ _value.e += _value.SVGWidth * 0.1 / 2;
588
+ _value.f += _value.SVGHeight * 0.1 / 2;
589
+ _zoomValue = parseInt((_value.a - 0.5) / ZOOM_VARIABLE);
590
+ if (!(_zoomValue > 404)) {
591
+ _context5.next = 21;
592
+ break;
593
+ }
594
+ return _context5.abrupt("return");
595
+ case 21:
596
+ if (!(_zoomValue < 35 || Number.isNaN(_zoomValue))) {
597
+ _context5.next = 22;
598
+ break;
599
+ }
600
+ return _context5.abrupt("return");
601
+ case 22:
602
+ while (!(_value.e <= 10)) {
603
+ _value.e -= 0.1;
604
+ }
605
+ while (!(_value.e + _value.a * _value.SVGWidth + 10 >= _value.viewerWidth)) {
606
+ _value.e += 0.1;
607
+ }
608
+ while (!(_value.f <= 80)) {
609
+ _value.f -= 0.1;
610
+ }
611
+ while (!(_value.f + _value.a * _value.SVGHeight + 10 >= _value.viewerHeight)) {
612
+ _value.f += 0.1;
613
+ }
614
+ if (compareSVGRect(_value)) props.viewer2DActions.updateCameraView(_value);
615
+ return _context5.abrupt("continue", 32);
616
+ case 23:
617
+ _value2 = state.getIn(['viewer2D']).toJS();
618
+ _value2.a += 0.1;
619
+ _value2.d += 0.1;
620
+ _value2.e -= _value2.SVGWidth * 0.1 / 2;
621
+ _value2.f -= _value2.SVGHeight * 0.1 / 2;
622
+ _zoomValue2 = parseInt((_value2.a - 0.5) / ZOOM_VARIABLE);
623
+ if (!(_zoomValue2 > 404)) {
624
+ _context5.next = 24;
625
+ break;
626
+ }
627
+ return _context5.abrupt("return");
628
+ case 24:
629
+ if (!(_zoomValue2 < 35 || Number.isNaN(_zoomValue2))) {
630
+ _context5.next = 25;
631
+ break;
632
+ }
633
+ return _context5.abrupt("return");
634
+ case 25:
635
+ if (compareSVGRect(_value2)) props.viewer2DActions.updateCameraView(_value2);
636
+ return _context5.abrupt("continue", 32);
637
+ case 26:
638
+ props.projectActions.undo();
639
+ return _context5.abrupt("continue", 32);
640
+ case 27:
641
+ props.projectActions.redo();
642
+ return _context5.abrupt("continue", 32);
643
+ case 28:
644
+ _evt$payload3 = evt.payload, moldingInfo = _evt$payload3.moldingInfo, isGlobal = _evt$payload3.isGlobal;
645
+ props.itemsActions.setMolding(moldingInfo, isGlobal);
646
+ return _context5.abrupt("continue", 32);
647
+ case 29:
648
+ _evt$payload4 = evt.payload, option = _evt$payload4.option, _value3 = _evt$payload4.value;
649
+ if (option === PROJECT_SETTING_OPTION.UPDATE_CEIL_HEIGHT) {
650
+ props.viewer2DActions.updateCeilHeight(_value3);
651
+ props.viewer3DActions.update3DCeilHeight(_value3);
652
+ } else if (option === PROJECT_SETTING_OPTION.CHANGE_WALL_LENGTH_MEASURE) {
653
+ props.viewer2DActions.changeWallLengthMeasure(_value3);
654
+ } else if (option === PROJECT_SETTING_OPTION.CHANGE_BASE_CABINET_MEASURE) {
655
+ props.viewer2DActions.changeBaseCabinetMeasure(_value3);
656
+ } else if (option === PROJECT_SETTING_OPTION.CHANGE_WALL_CABINET_MEASURE) {
657
+ props.viewer2DActions.changeWallCabinetMeasure(_value3);
658
+ } else if (option === PROJECT_SETTING_OPTION.CHANGE_WINDOW_DOOR_MEASURE) {
659
+ props.viewer2DActions.changeWindowDoorMeasure(_value3);
660
+ }
661
+ return _context5.abrupt("continue", 32);
662
+ case 30:
663
+ distancePayload = evt.payload;
664
+ props.itemsActions.changeDistance(distancePayload);
665
+ case 31:
666
+ // send scene object from 3DTool to HostApp using internalEvent
667
+ (_props$onInternalEven = props.onInternalEvent) === null || _props$onInternalEven === void 0 || _props$onInternalEven.call(props, {
668
+ type: INTERNAL_EVENT_SYNC_SCENE,
669
+ value: {
670
+ scene: state.scene.toJS()
671
+ }
672
+ });
673
+ case 32:
153
674
  case "end":
154
- return _context2.stop();
675
+ return _context5.stop();
155
676
  }
156
- }, _callee2);
677
+ }, _callee5);
157
678
  }));
158
679
  return _handleExternalEvent.apply(this, arguments);
159
680
  }