UNPKG

kitchen-simulator

Version:

It is a kitchen simulator (self-contained micro-frontend).

658 lines (657 loc) 33.5 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.handleExternalEvent = handleExternalEvent; exports.parseTempPlaceholdersFromCabinetPayload = parseTempPlaceholdersFromCabinetPayload; exports.updateCabinetPayload = updateCabinetPayload; var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); var _immutable = require("immutable"); var _constants = require("../constants"); var _helper = require("./helper"); var _exporter = _interopRequireDefault(require("../catalog/utils/exporter")); var _itemLoader = require("../catalog/utils/item-loader"); var _catalog = _interopRequireDefault(require("../catalog/catalog")); var _models = require("../models"); function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } 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) { (0, _defineProperty2["default"])(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; } var loadSVGsByItem = /*#__PURE__*/function () { var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(item) { var _parsed$xml$viewBox, _parsed$xml$viewBox2, response, svgText, loader, parsed, _t; return _regenerator["default"].wrap(function (_context) { while (1) switch (_context.prev = _context.next) { case 0: if (item.outline) { _context.next = 1; break; } return _context.abrupt("return", null); case 1: _context.prev = 1; _context.next = 2; return fetch(item.outline, { cache: 'no-store' }); case 2: response = _context.sent; _context.next = 3; return response.text(); case 3: svgText = _context.sent; loader = new SVGLoader(); parsed = loader.parse(svgText); if (!(0, _helper.isEmpty)(parsed.paths)) { _context.next = 4; break; } return _context.abrupt("return", null); case 4: return _context.abrupt("return", { paths: parsed.paths, svgWidth: parseFloat(parsed.xml.getAttribute('width')) || ((_parsed$xml$viewBox = parsed.xml.viewBox) === null || _parsed$xml$viewBox === void 0 || (_parsed$xml$viewBox = _parsed$xml$viewBox.animVal) === null || _parsed$xml$viewBox === void 0 ? void 0 : _parsed$xml$viewBox.width) || 0, svgHeight: parseFloat(parsed.xml.getAttribute('height')) || ((_parsed$xml$viewBox2 = parsed.xml.viewBox) === null || _parsed$xml$viewBox2 === void 0 || (_parsed$xml$viewBox2 = _parsed$xml$viewBox2.animVal) === null || _parsed$xml$viewBox2 === void 0 ? void 0 : _parsed$xml$viewBox2.height) || 0, reverse: !parseFloat(parsed.xml.getAttribute('height')) }); case 5: _context.prev = 5; _t = _context["catch"](1); console.error('Failed to load SVG:', item.outline, _t); return _context.abrupt("return", null); case 6: case "end": return _context.stop(); } }, _callee, null, [[1, 5]]); })); return function loadSVGsByItem(_x) { return _ref.apply(this, arguments); }; }(); var compareSVGRect = function compareSVGRect(value) { 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; }; function loadJSON(_x2, _x3, _x4) { return _loadJSON.apply(this, arguments); } /********Parse TempPlaceholder from cabinetPayloadData **************/ function _loadJSON() { _loadJSON = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(path, success, error) { return _regenerator["default"].wrap(function (_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: return _context2.abrupt("return", new Promise(function (resolve, reject) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if (xhr.readyState === XMLHttpRequest.DONE) { if (xhr.status === 200) { resolve(JSON.parse(xhr.responseText)); } else { reject(xhr); } } }; xhr.open('GET', path, true); xhr.send(); })); case 1: case "end": return _context2.stop(); } }, _callee2); })); return _loadJSON.apply(this, arguments); } function parseTempPlaceholdersFromCabinetPayload(_x5) { return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments); } /***** Update cabinetPayloadData with updatedTempPlaceholders *****/ function _parseTempPlaceholdersFromCabinetPayload() { _parseTempPlaceholdersFromCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(cabinetPayload) { var link, keys, temp, i, _cabinetPayload$struc, el, tempPlaceholdersData, tempData, doorKey, drawerKey, fixedKey, doorPHs, drawerPHs, has_single_door, fixedPHs, _t2, _t3, _t4; return _regenerator["default"].wrap(function (_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: link = ''; keys = Object.keys(cabinetPayload.structure_json); temp = []; i = 0; case 1: if (!(i < keys.length)) { _context3.next = 4; break; } 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'))) { _context3.next = 3; break; } link = cabinetPayload.structure_json[keys[i]]; _t2 = temp; _t3 = keys[i]; _context3.next = 2; return loadJSON(link); case 2: _t4 = _context3.sent; _t2.push.call(_t2, { name: _t3, data: _t4 }); case 3: i++; _context3.next = 1; break; case 4: el = cabinetPayload.structure_json.tempPlaceholders[0].id; tempPlaceholdersData = []; tempData = {}; doorKey = 0; drawerKey = 0; fixedKey = 0; doorPHs = 0; drawerPHs = 0; has_single_door = false; fixedPHs = 0; temp.forEach(function (t, index) { var nodes = t.data.nodes; if (nodes === undefined) { nodes = []; } var tempPlaceholders = nodes.filter(function (element) { return element.name.startsWith('ph_'); }); tempPlaceholders.sort(function (a, b) { return a.name > b.name ? 1 : -1; }); if (tempPlaceholders.length > 0) { if (t.name === 'base') { tempPlaceholders.map(function (element) { var sink_match = element.name.match(/\d_(sink_[^LR12]*)(_[LR12])?$/); if (sink_match && sink_match.length >= 2) { tempData['sink'] = tempData['sink'] || []; tempData['sink'].push(element.name); var sink_url = process.env.DEV_HTTP + process.env.DEV_PORT + "/uploads/assets/default/".concat(sink_match[1], ".gltf"); json_data.sink = sink_url; } else if (temp.some(function (felement) { return felement.name.includes('base_drawer'); }) && element.name.includes('interior_drawer')) { var objCnt = temp.filter(function (felement) { return felement.name.includes('base_drawer') && !felement.name.includes('_door'); }).length; var phCnt = tempPlaceholders.filter(function (felement) { return felement.name.includes('interior'); }).length; drawerPHs = phCnt; if (objCnt === 1 || phCnt % objCnt !== 0) { if (tempData['base_drawer_1'] === undefined) { tempData['base_drawer_1'] = []; } tempData['base_drawer_1'].push(element.name); drawerKey++; } else if (objCnt > 1 && phCnt % objCnt === 0) { if (tempData['base_drawer_' + (drawerKey % objCnt + 1)] === undefined) { tempData['base_drawer_' + (drawerKey % objCnt + 1)] = []; } tempData['base_drawer_' + (drawerKey % objCnt + 1)].push(element.name); drawerKey++; } } else if (temp.some(function (felement) { return felement.name.includes('base_door'); }) && !element.name.includes('interior_drawer') && !element.name.includes('drawer') && element.name.includes('door')) { var _objCnt = temp.filter(function (felement) { return felement.name.includes('base_door'); }).length; var _phCnt = tempPlaceholders.filter(function (felement) { return !felement.name.includes('interior') && !felement.name.includes('drawer') && felement.name.includes('door'); }).length; doorPHs = _phCnt; if (_objCnt === 1 || _phCnt % _objCnt !== 0) { if (tempData['base_door_1'] === undefined) { tempData['base_door_1'] = []; } tempData['base_door_1'].push(element.name); doorKey++; } else if (_objCnt > 1) { if (tempData['base_door_' + (doorKey % _objCnt + 1)] === undefined) { tempData['base_door_' + (doorKey % _objCnt + 1)] = []; } tempData['base_door_' + (doorKey % _objCnt + 1)].push(element.name); doorKey++; } } else if (temp.some(function (felement) { return felement.name.includes('base_fixed_drawer_door'); }) && element.name.includes('_drawer_door_fixed')) { var _objCnt2 = temp.filter(function (felement) { return felement.name.includes('base_fixed_drawer_door'); }).length; var _phCnt2 = tempPlaceholders.filter(function (felement) { return felement.name.includes('_drawer_door_fixed'); }).length; fixedPHs = _phCnt2; if (_objCnt2 === 1 || _phCnt2 % _objCnt2 !== 0) { if (tempData['base_fixed_drawer_door_1'] === undefined) { tempData['base_fixed_drawer_door_1'] = []; } tempData['base_fixed_drawer_door_1'].push(element.name); fixedKey++; } else if (_objCnt2 > 1) { if (tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] === undefined) { tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)] = []; } tempData['base_fixed_drawer_door_' + (fixedKey % _objCnt2 + 1)].push(element.name); fixedKey++; } } }); } else if (t.name.includes('base_drawer') && !t.name.includes('_door')) { var objCnt = temp.filter(function (felement) { return felement.name.includes('base_drawer') && !felement.name.includes('_door'); }).length; if (objCnt === 1 || drawerPHs % objCnt !== 0) { if (tempData['base_drawer_door_1'] === undefined) tempData['base_drawer_door_1'] = []; //get drawer door handle placeholders var ph_temp = temp.find(function (felement) { return felement.name === 'base_drawer_door_1'; }); if (ph_temp != undefined) { var ph_drawer_door_handle = ph_temp.data.nodes; ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) { return element.name.startsWith('ph_') && element.name.includes('handle'); }); for (var w = 0; w < drawerPHs; w++) { if (!tempData['base_drawer_door_1'].some(function (el) { return el === 'base_drawer_door_1/' + tempPlaceholders[0].name; })) { tempData['base_drawer_door_1'].push('base_drawer_1/' + tempPlaceholders[0].name); //add drawer door handle placeholders if (tempData['drawer_door_handle_1'] === undefined) tempData['drawer_door_handle_1'] = []; if (ph_drawer_door_handle.length > 0) tempData['drawer_door_handle_1'].push('base_drawer_door_1/' + ph_drawer_door_handle[0].name); } } } } else if (objCnt > 1 && drawerPHs > 0 && drawerPHs % objCnt === 0) { if (tempData['base_drawer_door' + t.name.slice(-2)] === undefined) tempData['base_drawer_door' + t.name.slice(-2)] = []; //get drawer door handle placeholders var ph_temp = temp.find(function (felement) { return felement.name === 'base_drawer_door' + t.name.slice(-2); }); if (ph_temp != undefined) { var ph_drawer_door_handle = ph_temp.data.data.nodes; ph_drawer_door_handle = ph_drawer_door_handle.filter(function (element) { return element.name.startsWith('ph_') && element.name.includes('handle'); }); tempPlaceholders.forEach(function (element) { if (!tempData['base_drawer_door' + t.name.slice(-2)].some(function (el) { return el === t.name + '/' + element.name; })) { tempData['base_drawer_door' + t.name.slice(-2)].push(t.name + '/' + element.name); //add drawer door handle placeholders if (tempData['drawer_door_handle' + t.name.slice(-2)] === undefined) tempData['drawer_door_handle' + t.name.slice(-2)] = []; 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); } }); } } } else if (t.name.includes('base_door')) { var _objCnt3 = temp.filter(function (felement) { return felement.name.includes('base_door'); }).length; tempPlaceholders = tempPlaceholders.filter(function (el) { return el.name.includes('handle'); }); if (tempPlaceholders.length > 0) if (_objCnt3 === 1 || doorPHs % _objCnt3 !== 0) { if (tempData['door_handle_1'] === undefined) { tempData['door_handle_1'] = []; } var _loop = function _loop() { var phname = tempPlaceholders[0].name; var newph = undefined; if (tempData['base_door_1'][_w].isLeftPlaceholder()) { newph = tempPlaceholders.find(function (el) { return el.name.isRightPlaceholder(); }); } if (tempData['base_door_1'][_w].isRightPlaceholder()) { newph = tempPlaceholders.find(function (el) { return el.name.isLeftPlaceholder(); }); } if (newph != undefined) { phname = newph.name; } if (doorPHs === 1 && tempPlaceholders.find(function (el) { return el.name.isLeftPlaceholder(); }) != undefined && tempPlaceholders.find(function (el) { return el.name.isRightPlaceholder(); }) != undefined) { has_single_door = true; } if (!tempData['door_handle_1'].some(function (el) { return el === 'door_handle_1/' + phname; })) { tempData['door_handle_1'].push('base_door_1/' + phname); } }; for (var _w = 0; _w < doorPHs; _w++) { _loop(); } } else if (_objCnt3 > 1 && doorPHs > 0 && doorPHs % _objCnt3 === 0) { if (tempData['door_handle' + t.name.slice(-2)] === undefined) tempData['door_handle' + t.name.slice(-2)] = []; phname = tempPlaceholders[0].name; newph = undefined; var blAdd = true; if (element.is_corner) { if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) { newph = tempPlaceholders.find(function (el) { return el.name.isLeftPlaceholder(); }); } else { blAdd = false; } } else { if (tempData['base_door' + t.name.slice(-2)][0].isLeftPlaceholder()) { newph = tempPlaceholders.find(function (el) { return el.name.isRightPlaceholder(); }); } if (tempData['base_door' + t.name.slice(-2)][0].isRightPlaceholder()) { newph = tempPlaceholders.find(function (el) { return el.name.isLeftPlaceholder(); }); } } if (blAdd) { if (newph != undefined) { phname = newph.name; } if (!tempData['door_handle' + t.name.slice(-2)].some(function (el) { return el === t.name + '/' + phname; })) { tempData['door_handle' + t.name.slice(-2)].push(t.name + '/' + phname); } } } } else if (t.name.includes('base_fixed_drawer_door')) { var _objCnt4 = temp.filter(function (felement) { return felement.name.includes('base_fixed_drawer_door'); }).length; tempPlaceholders = tempPlaceholders.filter(function (el) { return el.name.includes('handle'); }); if (tempPlaceholders.length > 0) if (_objCnt4 === 1 || fixedPHs % _objCnt4 !== 0) { if (tempData['fixed_drawer_door_handle_1'] === undefined) tempData['fixed_drawer_door_handle_1'] = []; for (var _w2 = 0; _w2 < fixedPHs; _w2++) { phname = tempPlaceholders[0].name; newph = undefined; if (tempData['base_fixed_drawer_door_1'][_w2].isLeftPlaceholder()) { newph = tempPlaceholders.find(function (el) { return el.name.isRightPlaceholder(); }); } if (tempData['base_fixed_drawer_door_1'][_w2].isRightPlaceholder()) { newph = tempPlaceholders.find(function (el) { return el.name.isLeftPlaceholder(); }); } if (newph != undefined) { phname = newph.name; } if (!tempData['fixed_drawer_door_handle_1'].some(function (el) { return el === 'fixed_drawer_door_handle_1/' + phname; })) { tempData['fixed_drawer_door_handle_1'].push('base_fixed_drawer_door_1/' + phname); } } } else if (_objCnt4 > 1 && fixedPHs > 0 && fixedPHs % _objCnt4 === 0) { if (tempData['fixed_drawer_door_handle' + t.name.slice(-2)] === undefined) { tempData['fixed_drawer_door_handle' + t.name.slice(-2)] = []; } phname = tempPlaceholders[0].name; newph = undefined; if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isLeftPlaceholder()) { newph = tempPlaceholders.find(function (el) { return el.name.isRightPlaceholder(); }); } if (tempData['base_fixed_drawer_door' + t.name.slice(-2)][0].isRightPlaceholder()) { newph = tempPlaceholders.find(function (el) { return el.name.isLeftPlaceholder(); }); } if (newph != undefined) { phname = newph.name; } if (!tempData['fixed_drawer_door_handle' + t.name.slice(-2)].some(function (el) { return el === t.name + '/' + phname; })) { tempData['fixed_drawer_door_handle' + t.name.slice(-2)].push(t.name + '/' + phname); } } } } }); tempPlaceholdersData.push({ id: parseInt(el, 10), placeholders: tempData }); return _context3.abrupt("return", tempPlaceholdersData); case 5: case "end": return _context3.stop(); } }, _callee3); })); return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments); } function updateCabinetPayload(_x6) { return _updateCabinetPayload.apply(this, arguments); } function _updateCabinetPayload() { _updateCabinetPayload = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(cabinetPayload) { var tempPlaceholders, cabinetPayloadKeys, i; return _regenerator["default"].wrap(function (_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: tempPlaceholders = []; _context4.next = 1; return parseTempPlaceholdersFromCabinetPayload(cabinetPayload); case 1: tempPlaceholders = _context4.sent; cabinetPayloadKeys = Object.keys(cabinetPayload); for (i = 0; i < cabinetPayloadKeys.length; i++) { if (cabinetPayloadKeys[i] === 'structure_json') { cabinetPayload[cabinetPayloadKeys[i]]['placeholders'] = tempPlaceholders[0].placeholders; cabinetPayload[cabinetPayloadKeys[i]]['tempPlaceholders'] = tempPlaceholders; } } return _context4.abrupt("return", cabinetPayload); case 2: case "end": return _context4.stop(); } }, _callee4); })); return _updateCabinetPayload.apply(this, arguments); } function handleExternalEvent(_x7) { return _handleExternalEvent.apply(this, arguments); } function _handleExternalEvent() { _handleExternalEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(props) { 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; return _regenerator["default"].wrap(function (_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: evt = props.externalEvent; state = props.state.get('KitchenConfigurator'); _t5 = evt === null || evt === void 0 ? void 0 : evt.type; _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 : 29; break; case 1: props.projectActions.setMode(_constants.MODE_IDLE_3D); return _context5.abrupt("continue", 29); case 2: props.projectActions.setMode(_constants.MODE_IDLE); return _context5.abrupt("continue", 29); case 3: sLineCnt = state.getIn(['scene', 'layers', 'layer-1', 'selected', 'lines']).size; if (sLineCnt > 0) props.projectActions.setMode(_constants.MODE_ELEVATION_VIEW); return _context5.abrupt("continue", 29); case 4: if (state.mode === _constants.MODE_IDLE || state.mode === _constants.MODE_2D_PAN) props.linesActions.selectToolDrawingLine('wall');else { props.projectActions.setMode(_constants.MODE_IDLE); props.linesActions.selectToolDrawingLine('wall'); } return _context5.abrupt("continue", 29); case 5: if ((0, _helper.isEmpty)(evt === null || evt === void 0 ? void 0 : evt.payload)) { _context5.next = 9; break; } _element = evt.payload; catalog = state.getIn(['catalog']).toJS(); // add item to catalog of state _element = _objectSpread(_objectSpread({}, _element), {}, { cds: { itemID: _element.itemID } }); if (!(0, _helper.isEmpty)(catalog === null || catalog === void 0 ? void 0 : catalog.elements[_element.name])) { _context5.next = 8; break; } _context5.next = 6; return loadSVGsByItem(_element); case 6: outlineSVGData = _context5.sent; catalogInstance = props.catalog; _context5.next = 7; return updateCabinetPayload(_element); case 7: elementJs = _context5.sent; elementJs = (0, _exporter["default"])(_objectSpread(_objectSpread({}, elementJs), {}, { outlineSVGData: outlineSVGData, type: 'cabinet', render2DItem: _itemLoader.render2DItem, render3DItem: _itemLoader.render3DItem })); if (catalogInstance !== null && catalogInstance !== void 0 && catalogInstance.validateElement(elementJs)) { catalogInstance.registerElement(elementJs); props.projectActions.addElementToCatalog(elementJs); } case 8: // start drawing item _constants.ARRAY_3D_MODES.includes(state.mode) ? props.itemsActions.selectToolDrawingItem3D(_element.name) : props.itemsActions.selectToolDrawingItem(_element.name); props.projectActions.pushLastSelectedCatalogElementToHistory(_element); props.projectActions.setIsCabinetDrawing(true); case 9: return _context5.abrupt("continue", 29); case 10: _evt$payload = evt.payload, moveType = _evt$payload.moveType, moveValue = _evt$payload.moveValue; value = state.getIn(['viewer2D']).toJS(); _t6 = moveType; _context5.next = _t6 === _constants.TOP ? 11 : _t6 === _constants.BOTTOM ? 12 : _t6 === _constants.RIGHT ? 13 : _t6 === _constants.LEFT ? 14 : 15; break; case 11: value.f -= moveValue; return _context5.abrupt("continue", 15); case 12: value.f += moveValue; return _context5.abrupt("continue", 15); case 13: value.e += moveValue; return _context5.abrupt("continue", 15); case 14: value.e -= moveValue; return _context5.abrupt("continue", 15); case 15: if (compareSVGRect(value)) props.viewer2DActions.updateCameraView(value); return _context5.abrupt("continue", 29); case 16: defaulTitle = 'Untitle'; props.projectActions.newProject(); props.projectActions.rename(defaulTitle); return _context5.abrupt("continue", 29); case 17: _evt$payload2 = evt.payload, doorStyle = _evt$payload2.doorStyle, itemCDS = _evt$payload2.itemCDS, isAll = _evt$payload2.isAll; props.itemsActions.setDoorStyle(doorStyle, itemCDS, isAll); return _context5.abrupt("continue", 29); case 18: _doorStyle = evt.payload.doorStyle; props.itemsActions.setInitialDoorStyle(_doorStyle.doorStyle); return _context5.abrupt("continue", 29); case 19: props.projectActions.loadProject(evt.payload); return _context5.abrupt("continue", 29); case 20: _value = state.getIn(['viewer2D']).toJS(); _value.a -= 0.1; _value.d -= 0.1; _value.e += _value.SVGWidth * 0.1 / 2; _value.f += _value.SVGHeight * 0.1 / 2; _zoomValue = parseInt((_value.a - 0.5) / _constants.ZOOM_VARIABLE); if (!(_zoomValue > 404)) { _context5.next = 21; break; } return _context5.abrupt("return"); case 21: if (!(_zoomValue < 35 || Number.isNaN(_zoomValue))) { _context5.next = 22; break; } return _context5.abrupt("return"); case 22: while (!(_value.e <= 10)) { _value.e -= 0.1; } while (!(_value.e + _value.a * _value.SVGWidth + 10 >= _value.viewerWidth)) { _value.e += 0.1; } while (!(_value.f <= 80)) { _value.f -= 0.1; } while (!(_value.f + _value.a * _value.SVGHeight + 10 >= _value.viewerHeight)) { _value.f += 0.1; } if (compareSVGRect(_value)) props.viewer2DActions.updateCameraView(_value); return _context5.abrupt("continue", 29); case 23: _value2 = state.getIn(['viewer2D']).toJS(); _value2.a += 0.1; _value2.d += 0.1; _value2.e -= _value2.SVGWidth * 0.1 / 2; _value2.f -= _value2.SVGHeight * 0.1 / 2; _zoomValue2 = parseInt((_value2.a - 0.5) / _constants.ZOOM_VARIABLE); if (!(_zoomValue2 > 404)) { _context5.next = 24; break; } return _context5.abrupt("return"); case 24: if (!(_zoomValue2 < 35 || Number.isNaN(_zoomValue2))) { _context5.next = 25; break; } return _context5.abrupt("return"); case 25: if (compareSVGRect(_value2)) props.viewer2DActions.updateCameraView(_value2); return _context5.abrupt("continue", 29); case 26: props.projectActions.undo(); return _context5.abrupt("continue", 29); case 27: props.projectActions.redo(); return _context5.abrupt("continue", 29); case 28: _evt$payload3 = evt.payload, moldingInfo = _evt$payload3.moldingInfo, isGlobal = _evt$payload3.isGlobal; props.itemsActions.setMolding(moldingInfo, isGlobal); return _context5.abrupt("continue", 29); case 29: case "end": return _context5.stop(); } }, _callee5); })); return _handleExternalEvent.apply(this, arguments); }