@crystaldesign/web-planner-logic 25.13.0-beta.41 → 25.13.0-beta.43

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 (34) hide show
  1. package/build/cjs/{DivaBoxPlanner-69472708.js → DivaBoxPlanner-a7a2bcb9.js} +568 -504
  2. package/build/cjs/{DivaStandardPlanner-2acdae3b.js → DivaStandardPlanner-30ad0b92.js} +2 -2
  3. package/build/cjs/{DoorPlanner-947f5506.js → DoorPlanner-13625bb7.js} +1 -1
  4. package/build/cjs/{Host3DSignalR-bc47c003.js → Host3DSignalR-91921736.js} +1 -1
  5. package/build/cjs/{LiviqueWWSHandler-57f23ad5.js → LiviqueWWSHandler-fcd38ba9.js} +1 -1
  6. package/build/cjs/{PfisterWWSHandler-300877cd.js → PfisterWWSHandler-4707db89.js} +1 -1
  7. package/build/cjs/{PlannerHandler2D-c7c60612.js → PlannerHandler2D-eda6acbb.js} +1 -1
  8. package/build/cjs/{SeriousBasketHandler-1896f91b.js → SeriousBasketHandler-f1cd3ad9.js} +1 -1
  9. package/build/cjs/{ShelfPlanner-9f377509.js → ShelfPlanner-98a1e49a.js} +1 -1
  10. package/build/cjs/{StandardWWSHandler-a5fef3eb.js → StandardWWSHandler-28018691.js} +1 -1
  11. package/build/cjs/{index-1b02c00c.js → index-1c5aa2c3.js} +10 -10
  12. package/build/cjs/index.js +1 -1
  13. package/build/esm/{DivaBoxPlanner-6e6c1465.js → DivaBoxPlanner-e4a3c8dd.js} +568 -504
  14. package/build/esm/{DivaStandardPlanner-ca7db49c.js → DivaStandardPlanner-c2c8606b.js} +2 -2
  15. package/build/esm/{DoorPlanner-90ba2b13.js → DoorPlanner-e1456c31.js} +1 -1
  16. package/build/esm/{Host3DSignalR-d3a48e24.js → Host3DSignalR-9d0f0ffe.js} +1 -1
  17. package/build/esm/{LiviqueWWSHandler-5ec5254c.js → LiviqueWWSHandler-cdd66c4d.js} +1 -1
  18. package/build/esm/{PfisterWWSHandler-dd0d8dd0.js → PfisterWWSHandler-4f6681e6.js} +1 -1
  19. package/build/esm/{PlannerHandler2D-79196c59.js → PlannerHandler2D-f28b33b6.js} +1 -1
  20. package/build/esm/{SeriousBasketHandler-6feb3b3a.js → SeriousBasketHandler-7ca42dbb.js} +1 -1
  21. package/build/esm/{ShelfPlanner-aaca549e.js → ShelfPlanner-6dadb2ac.js} +1 -1
  22. package/build/esm/{StandardWWSHandler-57d91252.js → StandardWWSHandler-48e56aed.js} +1 -1
  23. package/build/esm/{index-dcce5e3a.js → index-9aa6880b.js} +10 -10
  24. package/build/esm/index.js +1 -1
  25. package/build/types/web-planner-logic/src/logic/Planner/BoxPlanner/BoxPlannerGrid.d.ts +2 -2
  26. package/build/types/web-planner-logic/src/logic/Planner/BoxPlanner/BoxPlannerGrid.d.ts.map +1 -1
  27. package/build/types/web-planner-logic/src/logic/Planner/BoxPlanner/ConstructionRulesHandler.d.ts.map +1 -1
  28. package/build/types/web-planner-logic/src/logic/Planner/BoxPlanner/DivaBoxPlanner.d.ts.map +1 -1
  29. package/build/types/web-planner-logic/src/model/Catalog/CatalogData.d.ts.map +1 -1
  30. package/build/types/web-planner-logic/src/model/Planner/BoxPlannerData.d.ts +2 -1
  31. package/build/types/web-planner-logic/src/model/Planner/BoxPlannerData.d.ts.map +1 -1
  32. package/build/types/web-planner-logic/src/model/Planner/PlannerInteractionData.d.ts +1 -2
  33. package/build/types/web-planner-logic/src/model/Planner/PlannerInteractionData.d.ts.map +1 -1
  34. package/package.json +2 -2
@@ -5,10 +5,10 @@ var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
5
5
  var _createClass = require('@babel/runtime/helpers/createClass');
6
6
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
7
7
  var _regeneratorRuntime = require('@babel/runtime/regenerator');
8
- var index = require('./index-1b02c00c.js');
8
+ var index = require('./index-1c5aa2c3.js');
9
9
  var DivaUtils = require('@crystaldesign/diva-utils');
10
10
  var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
11
- var PlannerHandler2D = require('./PlannerHandler2D-c7c60612.js');
11
+ var PlannerHandler2D = require('./PlannerHandler2D-eda6acbb.js');
12
12
  require('@babel/runtime/helpers/slicedToArray');
13
13
  require('@babel/runtime/helpers/objectWithoutProperties');
14
14
  require('axios');
@@ -1834,6 +1834,7 @@ var ConstructionRulesHandler = /*#__PURE__*/function () {
1834
1834
  * Elements without bottom plate are "Garderobe" or "Offenes Fach ohne Boden"
1835
1835
  */
1836
1836
  _defineProperty__default["default"](this, "getElementHasBottomPlate", function (curElement, optionHandler) {
1837
+ if (!curElement) return false;
1837
1838
  if (_this.constructionRules.knotInfo.elementsWithGroundPlate) {
1838
1839
  for (var i = 0; i < _this.constructionRules.knotInfo.elementsWithGroundPlate.length; i++) {
1839
1840
  var onOPT = _this.constructionRules.knotInfo.elementsWithGroundPlate[i].onOPT;
@@ -1850,6 +1851,7 @@ var ConstructionRulesHandler = /*#__PURE__*/function () {
1850
1851
  * @param optionHandler
1851
1852
  */
1852
1853
  _defineProperty__default["default"](this, "getElementIsCornerElement", function (curElement, optionHandler) {
1854
+ if (!curElement) return false;
1853
1855
  return _this.constructionRules.hasCORNER && _this.arrayContainsValue(_this.constructionRules.knotInfo.cornerElements.onOPVs, _this.getOptionVal(curElement.getElementId(), _this.constructionRules.knotInfo.cornerElements.onOPT, optionHandler));
1854
1856
  });
1855
1857
  _defineProperty__default["default"](this, "getElementIsGarderobeElement", function (curElement, optionHandler) {
@@ -1869,9 +1871,7 @@ var ConstructionRulesHandler = /*#__PURE__*/function () {
1869
1871
  if (boxPlannerGrid.getElementHasTopElement(curElement.getElementId())) {
1870
1872
  var allTopElements = boxPlannerGrid.getTopElements(curElement.getElementId());
1871
1873
  var oneTrueFound = false;
1872
- for (var i = 0; i < allTopElements.length; i++) {
1873
- if (_this.getElementHasBottomPlate(allTopElements[i], optionHandler)) oneTrueFound = true;
1874
- }
1874
+ if (_this.getElementHasBottomPlate(allTopElements[0], optionHandler)) oneTrueFound = true;
1875
1875
  return oneTrueFound;
1876
1876
  }
1877
1877
  return true;
@@ -2057,7 +2057,7 @@ var ConstructionRulesHandler = /*#__PURE__*/function () {
2057
2057
  }
2058
2058
  }
2059
2059
  if (cellsInGrid.endColIndex < colCount - 1) {
2060
- var rightElement = boxPlannerGrid.getPlannerElementAtGridPos(cellsInGrid.endColIndex + 1, 0, false);
2060
+ var rightElement = boxPlannerGrid.getPlannerElementAtGridPos(cellsInGrid.endColIndex, 0, false);
2061
2061
  if (rightElement) {
2062
2062
  var _cornerVal = this.getOptionVal(rightElement.getElementId(), 'OPTELEMENT', optionHandler);
2063
2063
  if (_cornerVal == 'OPVECK_I') {
@@ -2072,7 +2072,7 @@ var ConstructionRulesHandler = /*#__PURE__*/function () {
2072
2072
  }
2073
2073
  if (this.constructionRules.avoidOptionLastCol) {
2074
2074
  var elementType = this.getOptionVal(allElementIds[i], this.constructionRules.avoidOptionLastCol.onOPT, optionHandler);
2075
- if (this.arrayContainsValue(this.constructionRules.avoidOptionLastCol.onOPVs, elementType) && cellsInGrid.endColIndex == colCount - 1) {
2075
+ if (this.arrayContainsValue(this.constructionRules.avoidOptionLastCol.onOPVs, elementType) && cellsInGrid.endColIndex - 1 == colCount - 1) {
2076
2076
  this.setOptionValue(allElementIds[i], this.constructionRules.avoidOptionLastCol.onOPT, this.constructionRules.avoidOptionLastCol.defaultOpv, optionHandler);
2077
2077
  }
2078
2078
  }
@@ -2445,35 +2445,17 @@ var ConstructionRulesHandler = /*#__PURE__*/function () {
2445
2445
  var bottomElemts = boxPlannerGrid.getBottomElements(curElement.ElementId);
2446
2446
  var topRightElemt = !fromBackside ? boxPlannerGrid.getTopRightElement(curElement.ElementId) : boxPlannerGrid.getTopLeftElement(curElement.ElementId);
2447
2447
  if (rightElemts.length > 0) {
2448
- if (rightElemts.length > 1) {
2449
- LOG$2.error(new DivaUtils.DivaError('BoxPlannerError - only one OPTNACHBAR_RECHTS allowed', {
2450
- code: 'WC_0012'
2451
- }));
2452
- } else {
2453
- this.setOptionValue(curElement.ElementId, 'OPTNACHBAR_RECHTS', this.getOptionVal(rightElemts[0].ElementId, 'OPTELEMENT', optionHandler), optionHandler);
2454
- }
2448
+ this.setOptionValue(curElement.ElementId, 'OPTNACHBAR_RECHTS', this.getOptionVal(rightElemts[0].ElementId, 'OPTELEMENT', optionHandler), optionHandler);
2455
2449
  } else {
2456
2450
  this.setOptionDoHide(curElement.ElementId, 'OPTNACHBAR_RECHTS', optionHandler);
2457
2451
  }
2458
2452
  if (leftElemts.length > 0) {
2459
- if (leftElemts.length > 1) {
2460
- LOG$2.error(new DivaUtils.DivaError('BoxPlannerError - only one OPTNACHBAR_LINKS allowed', {
2461
- code: 'WC_0012'
2462
- }));
2463
- } else {
2464
- this.setOptionValue(curElement.ElementId, 'OPTNACHBAR_LINKS', this.getOptionVal(leftElemts[0].ElementId, 'OPTELEMENT', optionHandler), optionHandler);
2465
- }
2453
+ this.setOptionValue(curElement.ElementId, 'OPTNACHBAR_LINKS', this.getOptionVal(leftElemts[0].ElementId, 'OPTELEMENT', optionHandler), optionHandler);
2466
2454
  } else {
2467
2455
  this.setOptionDoHide(curElement.ElementId, 'OPTNACHBAR_LINKS', optionHandler);
2468
2456
  }
2469
2457
  if (topElemts.length > 0) {
2470
- if (topElemts.length > 1) {
2471
- LOG$2.error(new DivaUtils.DivaError('BoxPlannerError - only one OPTNACHBAR_OBEN allowed', {
2472
- code: 'WC_0012'
2473
- }));
2474
- } else {
2475
- this.setOptionValue(curElement.ElementId, 'OPTNACHBAR_OBEN', this.getOptionVal(topElemts[0].ElementId, 'OPTELEMENT', optionHandler), optionHandler);
2476
- }
2458
+ this.setOptionValue(curElement.ElementId, 'OPTNACHBAR_OBEN', this.getOptionVal(topElemts[0].ElementId, 'OPTELEMENT', optionHandler), optionHandler);
2477
2459
  } else {
2478
2460
  this.setOptionDoHide(curElement.ElementId, 'OPTNACHBAR_OBEN', optionHandler);
2479
2461
  }
@@ -2484,13 +2466,7 @@ var ConstructionRulesHandler = /*#__PURE__*/function () {
2484
2466
  }
2485
2467
  if (this.constructionRules.hasNeighbors && this.constructionRules.hasNeighbors.indexOf('OPTNACHBAR_UNTEN') >= 0) {
2486
2468
  if (bottomElemts.length > 0) {
2487
- if (bottomElemts.length > 1) {
2488
- LOG$2.error(new DivaUtils.DivaError('BoxPlannerError - only one OPTNACHBAR_UNTEN allowed', {
2489
- code: 'WC_0012'
2490
- }));
2491
- } else {
2492
- this.setOptionValue(curElement.ElementId, 'OPTNACHBAR_UNTEN', this.getOptionVal(bottomElemts[0].ElementId, 'OPTELEMENT', optionHandler), optionHandler);
2493
- }
2469
+ this.setOptionValue(curElement.ElementId, 'OPTNACHBAR_UNTEN', this.getOptionVal(bottomElemts[0].ElementId, 'OPTELEMENT', optionHandler), optionHandler);
2494
2470
  } else {
2495
2471
  this.setOptionDoHide(curElement.ElementId, 'OPTNACHBAR_UNTEN', optionHandler);
2496
2472
  }
@@ -2544,7 +2520,7 @@ var ConstructionRulesHandler = /*#__PURE__*/function () {
2544
2520
  }
2545
2521
  }
2546
2522
  }
2547
- if (this.getElementHasBottomPlate(backElement, optionHandler)) {
2523
+ if (backElement && this.getElementHasBottomPlate(backElement, optionHandler)) {
2548
2524
  //Set the opposite element has rahmen unten vorne
2549
2525
  this.setOptionDoShow(frontElement, 'OPTOPP_RAHMEN_U_V', optionHandler);
2550
2526
  } else {
@@ -2640,26 +2616,34 @@ var ConstructionRulesHandler = /*#__PURE__*/function () {
2640
2616
  /*
2641
2617
  * This function corrects the elements in one row when the top element is wider then the bottom one.
2642
2618
  * Goal is to make all the bottom ones also atleast as wide as the top one because no element can overhang - omlin setup
2643
- */
2619
+ */
2644
2620
  }, {
2645
2621
  key: "correctOverHangingElement",
2646
- value: function correctOverHangingElement(boxPlannerGrid, optionHandler, changedOPTs) {
2622
+ value: function correctOverHangingElement(changedElementId, boxPlannerGrid, optionHandler, changedOPTs) {
2647
2623
  var _this2 = this;
2648
2624
  if (!changedOPTs) return;
2649
2625
  var _loop = function _loop() {
2650
- var elements = boxPlannerGrid.getAllElementsInColumn(columndIdx, false, false); // from bottom to top
2626
+ var elements = boxPlannerGrid.getAllElementsInColumn(columndIdx, false, false); // from bottom to top
2651
2627
  var lastElement = null;
2652
- elements.forEach(function (element) {
2628
+ var changedElementIdx = elements.findIndex(function (e) {
2629
+ return e.ElementId == changedElementId;
2630
+ });
2631
+ elements.forEach(function (element, idx) {
2653
2632
  var _lastElement$Width, _element$Width, _lastElement$Depth, _element$Depth;
2654
2633
  if (!lastElement) {
2655
2634
  lastElement = element;
2656
2635
  return;
2657
2636
  }
2658
2637
  if (((_lastElement$Width = lastElement.Width) !== null && _lastElement$Width !== void 0 ? _lastElement$Width : 0) > ((_element$Width = element.Width) !== null && _element$Width !== void 0 ? _element$Width : 0)) {
2659
- var t = Object.entries(changedOPTs); // should be the new wider width that causes the overhanging
2638
+ // is either the above wider opt or the one under and smaller
2639
+ var t = Object.entries(changedOPTs);
2660
2640
  var opt = t[0][0];
2661
2641
  var opv = t[0][1];
2662
- _this2.setOptionValue(element.ElementId, opt, opv, optionHandler);
2642
+ if (idx < changedElementIdx) {
2643
+ _this2.setOptionValue(element.ElementId, opt, opv, optionHandler);
2644
+ } else {
2645
+ _this2.setOptionValue(element.ElementId, opt, opv, optionHandler);
2646
+ }
2663
2647
  }
2664
2648
  if (((_lastElement$Depth = lastElement.Depth) !== null && _lastElement$Depth !== void 0 ? _lastElement$Depth : 0) > ((_element$Depth = element.Depth) !== null && _element$Depth !== void 0 ? _element$Depth : 0)) {
2665
2649
  var _t = Object.entries(changedOPTs); // should be the new wider width that causes the overhanging
@@ -3140,6 +3124,7 @@ var ConstructionRulesHandler = /*#__PURE__*/function () {
3140
3124
  key: "updateOptionLogicBoxPlanner",
3141
3125
  value: function () {
3142
3126
  var _updateOptionLogicBoxPlanner = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(boxPlannerGrid, changedOPTs, targetElements, forceResetCornerElements) {
3127
+ var _targetElements;
3143
3128
  var startTime, resultMessage, optionHandler, allElements, i, _iterator, _step, coverPlateRule, j, doChangeRetailArticleNumbers;
3144
3129
  return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
3145
3130
  while (1) switch (_context.prev = _context.next) {
@@ -3216,7 +3201,7 @@ var ConstructionRulesHandler = /*#__PURE__*/function () {
3216
3201
  }
3217
3202
  this.correctLadder(boxPlannerGrid, optionHandler);
3218
3203
  this.correctOptionsInfluencedByDimensions(boxPlannerGrid, optionHandler);
3219
- this.correctOverHangingElement(boxPlannerGrid, optionHandler, changedOPTs);
3204
+ this.correctOverHangingElement((_targetElements = targetElements) === null || _targetElements === void 0 ? void 0 : _targetElements[0], boxPlannerGrid, optionHandler, changedOPTs);
3220
3205
  this.partlistHelper.calculateKnots(boxPlannerGrid, optionHandler);
3221
3206
  this.partlistHelper.calculateRahmen(boxPlannerGrid, optionHandler);
3222
3207
  for (i = 0; i < boxPlannerGrid.getColumnCount(); i++) {
@@ -3293,21 +3278,26 @@ var ConstructionRulesHandler = /*#__PURE__*/function () {
3293
3278
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
3294
3279
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3295
3280
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
3281
+ 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; }
3282
+ 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__default["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; }
3296
3283
  var LOG$1 = DivaUtils__default["default"].initLog('Planner', 'BOX-PLANNER_GRID');
3297
3284
  var BoxPlannerGrid = /*#__PURE__*/function () {
3298
3285
  function BoxPlannerGrid(gridSetupParams, getValueOfOptionOfArticle) {
3299
3286
  _classCallCheck__default["default"](this, BoxPlannerGrid);
3300
3287
  _defineProperty__default["default"](this, "plannerElements", void 0);
3301
- _defineProperty__default["default"](this, "frontGrid", void 0);
3302
- //first entry is width, second height
3303
- _defineProperty__default["default"](this, "backGrid", void 0);
3304
- //if cell is empty it is undefined
3288
+ _defineProperty__default["default"](this, "generalPlanningState", void 0);
3289
+ // [0] == frontgrid, and [1] == backgrid
3305
3290
  _defineProperty__default["default"](this, "hasActiveBackside", void 0);
3306
3291
  _defineProperty__default["default"](this, "getValueOfOptionOfArticle", void 0);
3307
3292
  _defineProperty__default["default"](this, "gridSetupParams", void 0);
3308
3293
  this.plannerElements = new Map();
3309
- this.frontGrid = new Array();
3310
- this.backGrid = new Array();
3294
+
3295
+ // the old logic
3296
+ this.generalPlanningState = {
3297
+ grids: [{
3298
+ matrix: [[]]
3299
+ }]
3300
+ };
3311
3301
  this.gridSetupParams = gridSetupParams;
3312
3302
  this.getValueOfOptionOfArticle = getValueOfOptionOfArticle;
3313
3303
  this.hasActiveBackside = false;
@@ -3326,50 +3316,57 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3326
3316
  if (this.gridSetupParams.forceSingleCellPerElement) {
3327
3317
  var cell = {
3328
3318
  //isEmpty: false,
3329
- plannerElementId: newElement.ElementId,
3330
- width: this.gridSetupParams.forceFixCellRasterSize ? this.gridSetupParams.fixCellRasterWidth : newElement.getWidth(),
3331
- height: this.gridSetupParams.forceFixCellRasterSize ? this.gridSetupParams.fixCellRasterHeight : newElement.getHeight(),
3319
+ plannedElement: {
3320
+ elementId: newElement.ElementId,
3321
+ basketId: newElement.getBasketId(),
3322
+ size: {
3323
+ width: this.gridSetupParams.forceFixCellRasterSize ? this.gridSetupParams.fixCellRasterWidth : newElement.getWidth(),
3324
+ height: this.gridSetupParams.forceFixCellRasterSize ? this.gridSetupParams.fixCellRasterHeight : newElement.getHeight(),
3325
+ depth: newElement.getDepth()
3326
+ },
3327
+ articleCodex: newElement.ArticleCodex,
3328
+ area: {
3329
+ fromX: startColIndex,
3330
+ toX: startColIndex + 1,
3331
+ fromY: startRowIndex,
3332
+ toY: startRowIndex + 1
3333
+ }
3334
+ },
3332
3335
  index: new index.Vector2(startColIndex, startRowIndex)
3333
3336
  };
3334
- return {
3335
- cells: [cell],
3336
- startColIndex: startColIndex,
3337
- endColIndex: startColIndex,
3338
- startRowIndex: startRowIndex,
3339
- endRowIndex: startRowIndex,
3340
- backside: backside,
3341
- colCount: 1,
3342
- rowCount: 1
3343
- };
3337
+ return [cell];
3344
3338
  }
3345
3339
  if (!this.gridSetupParams.forceFixCellRasterSize) {
3346
3340
  LOG$1.error(new DivaUtils.DivaError('Box planner with params forceSingleCellPerElement is false and forceFixCellRasterSize is false are not allowed'));
3347
3341
  }
3348
3342
  var colCount = Math.round(newElement.getWidth() / this.gridSetupParams.fixCellRasterWidth);
3349
- var rowCount = Math.round(newElement.getHeight() / this.gridSetupParams.fixCellRasterWidth);
3343
+ var rowCount = Math.round(newElement.getHeight() / this.gridSetupParams.fixCellRasterHeight);
3350
3344
  var cells = [];
3351
3345
  for (var i = 0; i < colCount; i++) {
3352
3346
  for (var j = 0; j < rowCount; j++) {
3353
3347
  var _cell = {
3354
- // isEmpty: false,
3355
- plannerElementId: newElement.ElementId,
3356
- width: this.gridSetupParams.fixCellRasterWidth,
3357
- height: this.gridSetupParams.fixCellRasterHeight,
3348
+ plannedElement: {
3349
+ basketId: newElement.getBasketId(),
3350
+ elementId: newElement.getElementId(),
3351
+ articleCodex: newElement.ArticleCodex,
3352
+ size: {
3353
+ width: newElement.getWidth(),
3354
+ depth: newElement.getDepth(),
3355
+ height: newElement.getHeight()
3356
+ },
3357
+ area: {
3358
+ fromX: startColIndex,
3359
+ toX: startColIndex + newElement.getWidth() / this.gridSetupParams.fixCellRasterWidth,
3360
+ fromY: startRowIndex,
3361
+ toY: startRowIndex + newElement.getHeight() / this.gridSetupParams.fixCellRasterHeight
3362
+ }
3363
+ },
3358
3364
  index: new index.Vector2(startColIndex + i, startRowIndex + j)
3359
3365
  };
3360
3366
  cells.push(_cell);
3361
3367
  }
3362
3368
  }
3363
- return {
3364
- cells: cells,
3365
- startColIndex: startColIndex,
3366
- endColIndex: startColIndex + colCount - 1,
3367
- startRowIndex: startRowIndex,
3368
- endRowIndex: startRowIndex + rowCount - 1,
3369
- backside: backside,
3370
- colCount: colCount,
3371
- rowCount: rowCount
3372
- };
3369
+ return cells;
3373
3370
  }
3374
3371
  }, {
3375
3372
  key: "createEmptyCells",
@@ -3415,7 +3412,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3415
3412
  key: "getAllUsedCellsInGrid",
3416
3413
  value: function getAllUsedCellsInGrid(backside) {
3417
3414
  var allCellsInGrid = new Array();
3418
- var curGrid = backside ? this.backGrid : this.frontGrid;
3415
+ var curGrid = backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3419
3416
  for (var i = 0; i < curGrid.length; i++) {
3420
3417
  for (var j = 0; j < curGrid[i].length; j++) {
3421
3418
  if (curGrid[i][j] != undefined) allCellsInGrid.push(curGrid[i][j]);
@@ -3430,8 +3427,10 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3430
3427
  }, {
3431
3428
  key: "getGridColumnWidth",
3432
3429
  value: function getGridColumnWidth(columnIndex) {
3433
- for (var i = 0; i < this.frontGrid[columnIndex].length; i++) {
3434
- if (this.frontGrid[columnIndex][i]) return this.frontGrid[columnIndex][i].width;
3430
+ var frontGrid = this.generalPlanningState.grids[0].matrix;
3431
+ for (var i = 0; i < frontGrid[columnIndex].length; i++) {
3432
+ var _plannedElement$size$, _plannedElement;
3433
+ if (frontGrid[columnIndex][i]) return (_plannedElement$size$ = (_plannedElement = frontGrid[columnIndex][i].plannedElement) === null || _plannedElement === void 0 ? void 0 : _plannedElement.size.width) !== null && _plannedElement$size$ !== void 0 ? _plannedElement$size$ : 0;
3435
3434
  }
3436
3435
  return 0;
3437
3436
  }
@@ -3446,11 +3445,12 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3446
3445
  value: function getGridColumnHeight(columnIdex) {
3447
3446
  var height = 0;
3448
3447
  var firstElementFound = false;
3449
- if (this.frontGrid.length > columnIdex) {
3450
- var allCellsInCol = this.frontGrid[columnIdex];
3448
+ var frontGrid = this.generalPlanningState.grids[0].matrix;
3449
+ if (frontGrid.length > columnIdex) {
3450
+ var allCellsInCol = frontGrid[columnIdex];
3451
3451
  for (var i = allCellsInCol.length; i >= 0; i--) {
3452
3452
  if (!firstElementFound && allCellsInCol[i]) firstElementFound = true;
3453
- if (firstElementFound) height += allCellsInCol[i] == undefined ? 0 : allCellsInCol[i].height;
3453
+ if (firstElementFound) height += allCellsInCol[i] == undefined ? 0 : allCellsInCol[i].plannedElement.size.height;
3454
3454
  }
3455
3455
  }
3456
3456
  return height;
@@ -3463,31 +3463,16 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3463
3463
  key: "deleteElementByIdFromGrid",
3464
3464
  value: function deleteElementByIdFromGrid(elementIdTodelete) {
3465
3465
  var gridCellsToDelete = this.getCellsInGridByElementId(elementIdTodelete);
3466
- var curGrid = gridCellsToDelete.backside ? this.backGrid : this.frontGrid;
3466
+ var curGrid = gridCellsToDelete.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3467
3467
  var rowCountToDelete = 1 + (gridCellsToDelete.endRowIndex - gridCellsToDelete.startRowIndex);
3468
- var doDeleteCol = false;
3469
- var startColToDelete = gridCellsToDelete.startColIndex;
3470
- var colCountToDelete = 1 + (gridCellsToDelete.startColIndex - gridCellsToDelete.endColIndex);
3471
3468
 
3472
3469
  //check if we need to delete all cols
3473
- if (this.getRowCount(gridCellsToDelete.startColIndex, gridCellsToDelete.backside) == rowCountToDelete) {
3474
- doDeleteCol = true;
3475
- }
3476
- var allUsedCellCurGrid = this.getAllUsedCellsInGrid(gridCellsToDelete.backside);
3477
- curGrid = new Array();
3478
- for (var i = 0; i < allUsedCellCurGrid.length; i++) {
3479
- var curCellFrontGrid = allUsedCellCurGrid[i];
3480
- if (curCellFrontGrid.plannerElementId != elementIdTodelete) {
3481
- if (doDeleteCol && curCellFrontGrid.index.x > startColToDelete) {
3482
- curCellFrontGrid.index.x -= colCountToDelete;
3483
- }
3484
- if (!curGrid[curCellFrontGrid.index.x]) {
3485
- curGrid[curCellFrontGrid.index.x] = [];
3486
- }
3487
- curGrid[curCellFrontGrid.index.x][curCellFrontGrid.index.y] = curCellFrontGrid;
3488
- }
3489
- }
3490
- if (gridCellsToDelete.backside) this.backGrid = curGrid;else this.frontGrid = curGrid;
3470
+ if (this.getRowCount(gridCellsToDelete.startColIndex, gridCellsToDelete.backside) == rowCountToDelete) ;
3471
+ gridCellsToDelete.cells.reverse().forEach(function (cell) {
3472
+ curGrid[cell.index.x].splice(cell.index.y, 1);
3473
+ if (curGrid[cell.index.x].length == 0) curGrid.splice(cell.index.x, 1);
3474
+ });
3475
+ if (gridCellsToDelete.backside) this.generalPlanningState.grids[1].matrix = curGrid;else this.generalPlanningState.grids[0].matrix = curGrid;
3491
3476
  }
3492
3477
 
3493
3478
  /**
@@ -3500,11 +3485,14 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3500
3485
  }, {
3501
3486
  key: "getPlannerElementAtGridPos",
3502
3487
  value: function getPlannerElementAtGridPos(curXPos, curYPos, fromBackmodul) {
3503
- var curElementGrid = fromBackmodul ? this.backGrid : this.frontGrid;
3488
+ var curElementGrid = fromBackmodul ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3504
3489
  if (curElementGrid[curXPos] && curElementGrid[curXPos][curYPos]) {
3490
+ var _cell$plannedElement;
3505
3491
  var cell = curElementGrid[curXPos][curYPos];
3506
3492
  if (cell == undefined) return undefined;
3507
- return this.plannerElements.get(cell.plannerElementId);
3493
+ var elementId = (_cell$plannedElement = cell.plannedElement) === null || _cell$plannedElement === void 0 ? void 0 : _cell$plannedElement.elementId;
3494
+ if (!elementId) return undefined;
3495
+ return this.plannerElements.get(elementId);
3508
3496
  }
3509
3497
  return undefined;
3510
3498
  }
@@ -3518,82 +3506,53 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3518
3506
  }, {
3519
3507
  key: "getCellsInGridByElementId",
3520
3508
  value: function getCellsInGridByElementId(elementId) {
3521
- var firstCell = undefined;
3509
+ var _this$generalPlanning, _cells$0$plannedEleme, _area$fromX, _area$toX, _area$fromY, _area$toY;
3522
3510
  var onBacksideFound = false;
3523
- for (var i = 0; i < this.frontGrid.length; i++) {
3524
- for (var j = 0; j < this.frontGrid[i].length; j++) {
3525
- var cell = this.frontGrid[i][j];
3526
- if (cell && cell.plannerElementId == elementId) {
3527
- firstCell = cell;
3528
- onBacksideFound = false;
3529
- }
3530
- }
3531
- }
3532
- if (firstCell == undefined) {
3533
- for (var i = 0; i < this.backGrid.length; i++) {
3534
- for (var j = 0; j < this.backGrid[i].length; j++) {
3535
- var _cell2 = this.backGrid[i][j];
3536
- if (_cell2 && _cell2.plannerElementId == elementId) {
3537
- firstCell = _cell2;
3538
- onBacksideFound = true;
3539
- }
3511
+ var frontGrid = this.generalPlanningState.grids[0].matrix;
3512
+ var backGrid = (_this$generalPlanning = this.generalPlanningState.grids[1]) === null || _this$generalPlanning === void 0 ? void 0 : _this$generalPlanning.matrix;
3513
+ var cells = [];
3514
+ frontGrid.forEach(function (x) {
3515
+ return x.forEach(function (y) {
3516
+ var _y$plannedElement;
3517
+ if (((_y$plannedElement = y.plannedElement) === null || _y$plannedElement === void 0 ? void 0 : _y$plannedElement.elementId) == elementId) cells.push(y);
3518
+ });
3519
+ });
3520
+ backGrid === null || backGrid === void 0 || backGrid.forEach(function (x) {
3521
+ return x.forEach(function (y) {
3522
+ var _y$plannedElement2;
3523
+ if (((_y$plannedElement2 = y.plannedElement) === null || _y$plannedElement2 === void 0 ? void 0 : _y$plannedElement2.elementId) == elementId) {
3524
+ cells.push(y);
3525
+ onBacksideFound = true;
3540
3526
  }
3541
- }
3542
- }
3543
- if (firstCell == undefined) return {
3544
- cells: [],
3545
- backside: false,
3546
- startColIndex: -1,
3547
- endColIndex: -1,
3548
- startRowIndex: -1,
3549
- endRowIndex: -1,
3527
+ });
3528
+ });
3529
+ if (cells.length == 0) return {
3530
+ cells: cells,
3531
+ backside: onBacksideFound,
3532
+ startColIndex: 0,
3533
+ endColIndex: 0,
3534
+ startRowIndex: 0,
3535
+ endRowIndex: 0,
3550
3536
  colCount: 0,
3551
3537
  rowCount: 0
3552
3538
  };
3553
- if (this.gridSetupParams.forceSingleCellPerElement) return {
3554
- cells: [firstCell],
3555
- backside: onBacksideFound,
3556
- startColIndex: firstCell.index.x,
3557
- endColIndex: firstCell.index.x,
3558
- startRowIndex: firstCell.index.y,
3559
- endRowIndex: firstCell.index.y,
3560
- colCount: 1,
3561
- rowCount: 1
3562
- };
3563
- //Now find the other cells that have the same element
3564
-
3565
- var curGrid = onBacksideFound ? this.backGrid : this.frontGrid;
3566
- var cells = [firstCell];
3567
- var startColIndex = Infinity;
3568
- var endColIndex = -Infinity;
3569
- var startRowIndex = Infinity;
3570
- var endRowIndex = -Infinity;
3571
- for (var i = firstCell.index.x; i < curGrid.length; i++) {
3572
- for (var j = firstCell.index.y + 1; j < curGrid.length; j++) {
3573
- var nextCell = curGrid[i][j];
3574
- if (nextCell && nextCell.plannerElementId == elementId) {
3575
- if (i < startColIndex) startColIndex = i;
3576
- if (i > endColIndex) endColIndex = i;
3577
- if (j < startRowIndex) startRowIndex = j;
3578
- if (j > endColIndex) endRowIndex = j;
3579
- cells.push(nextCell); //also this cell has the same element
3580
- //TODO
3581
- } else {
3582
- break;
3583
- }
3584
- }
3585
- }
3539
+ var area = (_cells$0$plannedEleme = cells[0].plannedElement) === null || _cells$0$plannedEleme === void 0 ? void 0 : _cells$0$plannedEleme.area;
3586
3540
  return {
3587
3541
  cells: cells,
3588
3542
  backside: onBacksideFound,
3589
- startColIndex: startColIndex,
3590
- endColIndex: endColIndex,
3591
- startRowIndex: startRowIndex,
3592
- endRowIndex: endRowIndex,
3593
- colCount: endColIndex - startColIndex + 1,
3594
- rowCount: endRowIndex - startRowIndex + 1
3543
+ startColIndex: (_area$fromX = area === null || area === void 0 ? void 0 : area.fromX) !== null && _area$fromX !== void 0 ? _area$fromX : 0,
3544
+ endColIndex: (_area$toX = area === null || area === void 0 ? void 0 : area.toX) !== null && _area$toX !== void 0 ? _area$toX : 0,
3545
+ startRowIndex: (_area$fromY = area === null || area === void 0 ? void 0 : area.fromY) !== null && _area$fromY !== void 0 ? _area$fromY : 0,
3546
+ endRowIndex: (_area$toY = area === null || area === void 0 ? void 0 : area.toY) !== null && _area$toY !== void 0 ? _area$toY : 0,
3547
+ colCount: area ? area.toX - area.toX : 0,
3548
+ rowCount: area ? area.toY - area.fromY : 0
3595
3549
  };
3596
3550
  }
3551
+ }, {
3552
+ key: "GridSetupParams",
3553
+ set: function set(gridSetupParams) {
3554
+ this.gridSetupParams = gridSetupParams;
3555
+ }
3597
3556
 
3598
3557
  /**
3599
3558
  * This function returns all elementIds that are inside the grid
@@ -3610,11 +3569,12 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3610
3569
  var allElements = [];
3611
3570
  for (var i = 0; i < grid.length; i++) {
3612
3571
  for (var j = 0; j < grid[i].length; j++) {
3572
+ var _cell$plannedElement2;
3613
3573
  var cell = grid[i][j];
3614
3574
  if (cell == undefined) continue;
3615
- if (allElementIds.indexOf(cell.plannerElementId) == -1) {
3616
- allElementIds.push(cell.plannerElementId);
3617
- allElements.push(this.plannerElements.get(cell.plannerElementId));
3575
+ if ((_cell$plannedElement2 = cell.plannedElement) !== null && _cell$plannedElement2 !== void 0 && _cell$plannedElement2.elementId && allElementIds.indexOf(cell.plannedElement.elementId) == -1) {
3576
+ allElementIds.push(cell.plannedElement.elementId);
3577
+ allElements.push(this.plannerElements.get(cell.plannedElement.elementId));
3618
3578
  }
3619
3579
  }
3620
3580
  }
@@ -3623,17 +3583,17 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3623
3583
  }, {
3624
3584
  key: "getAllElementsInFrontGrid",
3625
3585
  value: function getAllElementsInFrontGrid() {
3626
- return this._getAllElementsInGrid(this.frontGrid);
3586
+ return this._getAllElementsInGrid(this.generalPlanningState.grids[0].matrix);
3627
3587
  }
3628
3588
  }, {
3629
3589
  key: "getAllElementsInBackGrid",
3630
3590
  value: function getAllElementsInBackGrid() {
3631
- return this._getAllElementsInGrid(this.backGrid);
3591
+ return this._getAllElementsInGrid(this.generalPlanningState.grids[1].matrix);
3632
3592
  }
3633
3593
  }, {
3634
3594
  key: "getAllElementsInBacksideModuleGrid",
3635
3595
  value: function getAllElementsInBacksideModuleGrid() {
3636
- return this._getAllElementsInGrid(this.backGrid).map(function (element) {
3596
+ return this._getAllElementsInGrid(this.generalPlanningState.grids[1].matrix).map(function (element) {
3637
3597
  return element.ElementId;
3638
3598
  });
3639
3599
  }
@@ -3648,24 +3608,31 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3648
3608
  }, {
3649
3609
  key: "getAllElementsInGridSortedbyGridPos",
3650
3610
  value: function getAllElementsInGridSortedbyGridPos() {
3611
+ var _this$generalPlanning2, _this$generalPlanning3;
3651
3612
  var returnElements = [];
3652
3613
  var allCheckedElementIds = [];
3653
- for (var i = 0; i < this.frontGrid.length; i++) {
3654
- for (var j = 0; j < this.frontGrid[i].length; j++) {
3655
- var cell = this.frontGrid[i][j];
3656
- if (cell && allCheckedElementIds.indexOf(cell.plannerElementId) == -1) {
3657
- var element = this.getElementById(cell.plannerElementId);
3658
- allCheckedElementIds.push(cell.plannerElementId);
3614
+ var frontGrid = this.generalPlanningState.grids[0].matrix;
3615
+ var backGrid = (_this$generalPlanning2 = (_this$generalPlanning3 = this.generalPlanningState.grids[1]) === null || _this$generalPlanning3 === void 0 ? void 0 : _this$generalPlanning3.matrix) !== null && _this$generalPlanning2 !== void 0 ? _this$generalPlanning2 : 0;
3616
+ for (var i = 0; i < frontGrid.length; i++) {
3617
+ for (var j = 0; j < frontGrid[i].length; j++) {
3618
+ var _cell$plannedElement3;
3619
+ var cell = frontGrid[i][j];
3620
+ var elementId = (_cell$plannedElement3 = cell.plannedElement) === null || _cell$plannedElement3 === void 0 ? void 0 : _cell$plannedElement3.elementId;
3621
+ if (cell && elementId && allCheckedElementIds.indexOf(elementId) == -1) {
3622
+ var element = this.getElementById(elementId);
3623
+ allCheckedElementIds.push(elementId);
3659
3624
  returnElements.push(element);
3660
3625
  }
3661
3626
  }
3662
3627
  }
3663
- for (var i = 0; i < this.backGrid.length; i++) {
3664
- for (var j = 0; j < this.backGrid[i].length; j++) {
3665
- var _cell3 = this.backGrid[i][j];
3666
- if (_cell3 && allCheckedElementIds.indexOf(_cell3.plannerElementId) == -1) {
3667
- var _element = this.getElementById(_cell3.plannerElementId);
3668
- allCheckedElementIds.push(_cell3.plannerElementId);
3628
+ for (var i = 0; i < backGrid.length; i++) {
3629
+ for (var j = 0; j < backGrid[i].length; j++) {
3630
+ var _cell2$plannedElement;
3631
+ var _cell2 = backGrid[i][j];
3632
+ var _elementId = (_cell2$plannedElement = _cell2.plannedElement) === null || _cell2$plannedElement === void 0 ? void 0 : _cell2$plannedElement.elementId;
3633
+ if (_cell2 && _elementId && allCheckedElementIds.indexOf(_elementId) == -1) {
3634
+ var _element = this.getElementById(_elementId);
3635
+ allCheckedElementIds.push(_elementId);
3669
3636
  returnElements.push(_element);
3670
3637
  }
3671
3638
  }
@@ -3697,9 +3664,9 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3697
3664
  }, {
3698
3665
  key: "getElementIsInLastCol",
3699
3666
  value: function getElementIsInLastCol(elementId, fromBackmodul) {
3700
- var curElementGrid = fromBackmodul ? this.backGrid : this.frontGrid;
3667
+ var curElementGrid = fromBackmodul ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3701
3668
  var result = this.getCellsInGridByElementId(elementId);
3702
- return result.endColIndex + 1 == curElementGrid.length;
3669
+ return result.endColIndex == curElementGrid.length;
3703
3670
  }
3704
3671
 
3705
3672
  /**
@@ -3710,10 +3677,10 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3710
3677
  key: "getElementHasTopElement",
3711
3678
  value: function getElementHasTopElement(elementId) {
3712
3679
  var result = this.getCellsInGridByElementId(elementId);
3713
- var curGrid = result.backside ? this.backGrid : this.frontGrid;
3714
- for (var i = result.startColIndex; i <= result.endColIndex; i++) {
3680
+ var curGrid = result.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3681
+ for (var i = result.startColIndex; i < result.endColIndex; i++) {
3715
3682
  //Check if in one of the top cells is another element
3716
- if (curGrid[i].length > result.endRowIndex + 1 && curGrid[i][result.endRowIndex + 1]) {
3683
+ if (curGrid[i].length > result.endRowIndex && curGrid[i][result.endRowIndex]) {
3717
3684
  return true;
3718
3685
  }
3719
3686
  }
@@ -3727,19 +3694,18 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3727
3694
  }, {
3728
3695
  key: "getTopElements",
3729
3696
  value: function getTopElements(elementId) {
3697
+ var _curGrid$plannedEleme;
3730
3698
  var result = this.getCellsInGridByElementId(elementId);
3731
- var curGrid = result.backside ? this.backGrid : this.frontGrid;
3699
+ var curGrid = result.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3732
3700
  var neighborPlannerElements = [];
3733
- var neighborElementIds = [];
3734
- for (var i = result.startColIndex; i <= result.endColIndex; i++) {
3735
- if (curGrid[i].length > result.endRowIndex + 1 && curGrid[i][result.endRowIndex + 1]) {
3736
- var neighborCell = curGrid[i][result.endRowIndex + 1];
3737
- if (!neighborCell) continue;
3738
- if (neighborElementIds.indexOf(neighborCell.plannerElementId) == -1) {
3739
- neighborElementIds.push(neighborCell.plannerElementId);
3740
- neighborPlannerElements.push(this.plannerElements.get(neighborCell.plannerElementId));
3741
- }
3742
- }
3701
+ var plannedElement = result.cells[0].plannedElement;
3702
+ if (!plannedElement) return neighborPlannerElements;
3703
+ var topElement = (_curGrid$plannedEleme = curGrid[plannedElement.area.fromX]) === null || _curGrid$plannedEleme === void 0 ? void 0 : _curGrid$plannedEleme[plannedElement.area.toY];
3704
+ while (topElement) {
3705
+ var element = topElement.plannedElement;
3706
+ if (!element) break;
3707
+ neighborPlannerElements.push(this.plannerElements.get(element.elementId));
3708
+ topElement = curGrid[element.area.fromX][element.area.toY];
3743
3709
  }
3744
3710
  return neighborPlannerElements;
3745
3711
  }
@@ -3752,10 +3718,10 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3752
3718
  key: "getTopRightElement",
3753
3719
  value: function getTopRightElement(elementId) {
3754
3720
  var result = this.getCellsInGridByElementId(elementId);
3755
- var curGrid = result.backside ? this.backGrid : this.frontGrid;
3756
- if (curGrid.length > result.endColIndex + 1 && curGrid[result.endColIndex + 1].length > result.endRowIndex + 1 && curGrid[result.endColIndex + 1][result.endRowIndex + 1]) {
3757
- var cell = curGrid[result.endColIndex + 1][result.endRowIndex + 1];
3758
- return this.plannerElements.get(cell.plannerElementId);
3721
+ var curGrid = result.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3722
+ if (curGrid.length > result.endColIndex && curGrid[result.endColIndex].length > result.endRowIndex && curGrid[result.endColIndex][result.endRowIndex]) {
3723
+ var cell = curGrid[result.endColIndex][result.endRowIndex];
3724
+ return this.plannerElements.get(cell.plannedElement.elementId);
3759
3725
  }
3760
3726
  return undefined;
3761
3727
  }
@@ -3768,10 +3734,10 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3768
3734
  key: "getTopLeftElement",
3769
3735
  value: function getTopLeftElement(elementId) {
3770
3736
  var result = this.getCellsInGridByElementId(elementId);
3771
- var curGrid = result.backside ? this.backGrid : this.frontGrid;
3772
- if (result.startColIndex > 0 && curGrid[result.startColIndex - 1].length > 0 && curGrid[result.startColIndex - 1][result.endRowIndex + 1]) {
3773
- var cell = curGrid[result.startColIndex - 1][result.endRowIndex + 1];
3774
- return this.plannerElements.get(cell.plannerElementId);
3737
+ var curGrid = result.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3738
+ if (result.startColIndex > 0 && curGrid[result.startColIndex - 1].length > 0 && curGrid[result.startColIndex - 1][result.endRowIndex]) {
3739
+ var cell = curGrid[result.startColIndex - 1][result.endRowIndex];
3740
+ return this.plannerElements.get(cell.plannedElement.elementId);
3775
3741
  }
3776
3742
  return undefined;
3777
3743
  }
@@ -3799,22 +3765,21 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3799
3765
  }, {
3800
3766
  key: "getBottomElements",
3801
3767
  value: function getBottomElements(elementId) {
3768
+ var _curGrid$plannedEleme2;
3802
3769
  var result = this.getCellsInGridByElementId(elementId);
3803
- var curGrid = result.backside ? this.backGrid : this.frontGrid;
3804
- var bottomElements = [];
3805
- var bottomElementIds = [];
3806
- if (result.startRowIndex - 1 >= 0) {
3807
- for (var i = result.startColIndex; i <= result.endColIndex; i++) {
3808
- var cell = curGrid[i][result.startRowIndex - 1];
3809
- if (cell) {
3810
- if (bottomElementIds.indexOf(cell.plannerElementId) == -1) {
3811
- bottomElementIds.push(cell.plannerElementId);
3812
- bottomElements.push(this.plannerElements.get(cell.plannerElementId));
3813
- }
3814
- }
3815
- }
3770
+ var curGrid = result.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3771
+ var neighborPlannerElements = [];
3772
+ var plannedElement = result.cells[0].plannedElement;
3773
+ if (!plannedElement) return neighborPlannerElements;
3774
+ var topElement = (_curGrid$plannedEleme2 = curGrid[plannedElement.area.fromX]) === null || _curGrid$plannedEleme2 === void 0 ? void 0 : _curGrid$plannedEleme2[plannedElement.area.fromY - 1];
3775
+ while (topElement) {
3776
+ var _curGrid$element$area;
3777
+ var element = topElement.plannedElement;
3778
+ if (!element) break;
3779
+ neighborPlannerElements.push(this.plannerElements.get(element.elementId));
3780
+ topElement = (_curGrid$element$area = curGrid[element.area.fromX]) === null || _curGrid$element$area === void 0 ? void 0 : _curGrid$element$area[element.area.fromY - 1];
3816
3781
  }
3817
- return bottomElements;
3782
+ return neighborPlannerElements;
3818
3783
  }
3819
3784
 
3820
3785
  /**
@@ -3825,9 +3790,9 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3825
3790
  key: "getElementHasRightElement",
3826
3791
  value: function getElementHasRightElement(elementId) {
3827
3792
  var result = this.getCellsInGridByElementId(elementId);
3828
- var curGrid = result.backside ? this.backGrid : this.frontGrid;
3829
- if (curGrid.length > result.endColIndex + 1 && curGrid[result.endColIndex + 1].length > result.startRowIndex) {
3830
- var cell = curGrid[result.endColIndex + 1][result.startRowIndex];
3793
+ var curGrid = result.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3794
+ if (curGrid.length > result.endColIndex && curGrid[result.endColIndex].length > result.startRowIndex) {
3795
+ var cell = curGrid[result.endColIndex][result.startRowIndex];
3831
3796
  if (cell) return true;
3832
3797
  }
3833
3798
  return false;
@@ -3844,18 +3809,18 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3844
3809
  key: "getRightElements",
3845
3810
  value: function getRightElements(elementId) {
3846
3811
  var result = this.getCellsInGridByElementId(elementId);
3847
- var curGrid = result.backside ? this.backGrid : this.frontGrid;
3812
+ var curGrid = result.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3848
3813
  var rightElements = [];
3849
3814
  var rightElementIds = [];
3850
- if (curGrid.length > result.endColIndex + 1) {
3851
- for (var i = result.startRowIndex; i <= result.endRowIndex; i++) {
3852
- var cell = curGrid[result.endColIndex + 1][i];
3853
- if (cell) {
3854
- if (rightElementIds.indexOf(cell.plannerElementId) == -1) {
3855
- rightElementIds.push(cell.plannerElementId);
3856
- rightElements.push(this.plannerElements.get(cell.plannerElementId));
3857
- }
3858
- }
3815
+ var element = result.cells[0].plannedElement;
3816
+ if (!element) return rightElements;
3817
+ for (var y = element.area.fromY; y < element.area.toY; y++) {
3818
+ var _curGrid$element$area2, _cell$plannedElement4;
3819
+ var cell = (_curGrid$element$area2 = curGrid[element.area.toX]) === null || _curGrid$element$area2 === void 0 ? void 0 : _curGrid$element$area2[y];
3820
+ var _elementId2 = cell === null || cell === void 0 || (_cell$plannedElement4 = cell.plannedElement) === null || _cell$plannedElement4 === void 0 ? void 0 : _cell$plannedElement4.elementId;
3821
+ if (cell && _elementId2 && rightElementIds.indexOf(_elementId2) == -1) {
3822
+ rightElementIds.push(_elementId2);
3823
+ rightElements.push(this.plannerElements.get(_elementId2));
3859
3824
  }
3860
3825
  }
3861
3826
  return rightElements;
@@ -3869,7 +3834,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3869
3834
  key: "getElementHasLeftElement",
3870
3835
  value: function getElementHasLeftElement(elementId) {
3871
3836
  var result = this.getCellsInGridByElementId(elementId);
3872
- var curGrid = result.backside ? this.backGrid : this.frontGrid;
3837
+ var curGrid = result.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3873
3838
  if (result.startColIndex > 0 && curGrid[result.startColIndex - 1][result.startRowIndex]) {
3874
3839
  return true;
3875
3840
  }
@@ -3887,21 +3852,21 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3887
3852
  key: "getLeftElements",
3888
3853
  value: function getLeftElements(elementId) {
3889
3854
  var result = this.getCellsInGridByElementId(elementId);
3890
- var curGrid = result.backside ? this.backGrid : this.frontGrid;
3891
- var leftElements = [];
3892
- var leftElementIds = [];
3893
- if (result.startColIndex - 1 >= 0) {
3894
- for (var i = result.startRowIndex; i <= result.endRowIndex; i++) {
3895
- var cell = curGrid[result.startColIndex - 1][i];
3896
- if (cell) {
3897
- if (leftElementIds.indexOf(cell.plannerElementId) == -1) {
3898
- leftElementIds.push(cell.plannerElementId);
3899
- leftElements.push(this.plannerElements.get(cell.plannerElementId));
3900
- }
3901
- }
3855
+ var curGrid = result.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3856
+ var rightElements = [];
3857
+ var rightElementIds = [];
3858
+ var element = result.cells[0].plannedElement;
3859
+ if (!element) return rightElements;
3860
+ for (var y = element.area.fromY; y < element.area.toY; y++) {
3861
+ var _curGrid, _cell$plannedElement5;
3862
+ var cell = (_curGrid = curGrid[element.area.fromX - 1]) === null || _curGrid === void 0 ? void 0 : _curGrid[y];
3863
+ var _elementId3 = cell === null || cell === void 0 || (_cell$plannedElement5 = cell.plannedElement) === null || _cell$plannedElement5 === void 0 ? void 0 : _cell$plannedElement5.elementId;
3864
+ if (cell && _elementId3 && rightElementIds.indexOf(_elementId3) == -1) {
3865
+ rightElementIds.push(_elementId3);
3866
+ rightElements.push(this.plannerElements.get(_elementId3));
3902
3867
  }
3903
3868
  }
3904
- return leftElements;
3869
+ return rightElements;
3905
3870
  }
3906
3871
 
3907
3872
  /*
@@ -3913,24 +3878,28 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3913
3878
  key: "getAllElementsInColumn",
3914
3879
  value: function getAllElementsInColumn(index, fromBackmodul) {
3915
3880
  var orderBottomDown = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
3916
- var curGrid = fromBackmodul ? this.backGrid : this.frontGrid;
3881
+ var curGrid = fromBackmodul ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3917
3882
  var allElements = [];
3918
3883
  var allElementIds = [];
3919
3884
  if (!curGrid[index]) return allElements;
3920
3885
  if (orderBottomDown) {
3921
3886
  for (var i = 0; i < curGrid[index].length; i++) {
3887
+ var _cell$plannedElement6;
3922
3888
  var cell = curGrid[index][i];
3923
- if (cell && allElementIds.indexOf(cell.plannerElementId) == -1) {
3924
- allElementIds.push(cell.plannerElementId);
3925
- allElements.push(this.plannerElements.get(cell.plannerElementId));
3889
+ var elementId = cell === null || cell === void 0 || (_cell$plannedElement6 = cell.plannedElement) === null || _cell$plannedElement6 === void 0 ? void 0 : _cell$plannedElement6.elementId;
3890
+ if (elementId && cell && allElementIds.indexOf(elementId) == -1) {
3891
+ allElementIds.push(elementId);
3892
+ allElements.push(this.plannerElements.get(elementId));
3926
3893
  }
3927
3894
  }
3928
3895
  } else {
3929
3896
  for (var i = curGrid[index].length - 1; i >= 0; i--) {
3930
- var _cell4 = curGrid[index][i];
3931
- if (_cell4 && allElementIds.indexOf(_cell4.plannerElementId) == -1) {
3932
- allElementIds.push(_cell4.plannerElementId);
3933
- allElements.push(this.plannerElements.get(_cell4.plannerElementId));
3897
+ var _cell3$plannedElement;
3898
+ var _cell3 = curGrid[index][i];
3899
+ var _elementId4 = _cell3 === null || _cell3 === void 0 || (_cell3$plannedElement = _cell3.plannedElement) === null || _cell3$plannedElement === void 0 ? void 0 : _cell3$plannedElement.elementId;
3900
+ if (_cell3 && _elementId4 && allElementIds.indexOf(_elementId4) == -1) {
3901
+ allElementIds.push(_elementId4);
3902
+ allElements.push(this.plannerElements.get(_elementId4));
3934
3903
  }
3935
3904
  }
3936
3905
  }
@@ -3943,7 +3912,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3943
3912
  }, {
3944
3913
  key: "getColumnCount",
3945
3914
  value: function getColumnCount() {
3946
- return this.frontGrid.length;
3915
+ return this.generalPlanningState.grids[0].matrix.length;
3947
3916
  }
3948
3917
 
3949
3918
  /**
@@ -3953,7 +3922,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3953
3922
  }, {
3954
3923
  key: "getRowCount",
3955
3924
  value: function getRowCount(colIndex, fromBackmodul) {
3956
- return fromBackmodul ? this.backGrid[colIndex].length : this.frontGrid[colIndex].length;
3925
+ return fromBackmodul ? this.generalPlanningState.grids[1].matrix[colIndex].length : this.generalPlanningState.grids[0].matrix[colIndex].length;
3957
3926
  }
3958
3927
 
3959
3928
  /*
@@ -3964,15 +3933,17 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3964
3933
  }, {
3965
3934
  key: "getAllElementsInRow",
3966
3935
  value: function getAllElementsInRow(index, fromBackmodul) {
3967
- var curGrid = fromBackmodul ? this.backGrid : this.frontGrid;
3936
+ var curGrid = fromBackmodul ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3968
3937
  var allElements = [];
3969
3938
  var allElementIds = [];
3970
3939
  for (var i = 0; i < curGrid.length; i++) {
3971
3940
  if (curGrid[i].length > index) {
3941
+ var _cell$plannedElement7;
3972
3942
  var cell = curGrid[i][index];
3973
- if (cell && allElementIds.indexOf(cell.plannerElementId) == -1) {
3974
- allElementIds.push(cell.plannerElementId);
3975
- allElements.push(this.plannerElements.get(cell.plannerElementId));
3943
+ var elementId = cell === null || cell === void 0 || (_cell$plannedElement7 = cell.plannedElement) === null || _cell$plannedElement7 === void 0 ? void 0 : _cell$plannedElement7.elementId;
3944
+ if (cell && elementId && allElementIds.indexOf(elementId) == -1) {
3945
+ allElementIds.push(elementId);
3946
+ allElements.push(this.plannerElements.get(elementId));
3976
3947
  }
3977
3948
  }
3978
3949
  }
@@ -3986,7 +3957,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
3986
3957
  }, {
3987
3958
  key: "getSizeOfHighesRow",
3988
3959
  value: function getSizeOfHighesRow(fromBackmodul) {
3989
- var curGrid = fromBackmodul ? this.backGrid : this.frontGrid;
3960
+ var curGrid = fromBackmodul ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
3990
3961
  var highestRow = 0;
3991
3962
  for (var i = 0; i < curGrid.length; i++) {
3992
3963
  for (var j = curGrid[i].length; j >= 0; j--) {
@@ -4015,69 +3986,38 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4015
3986
  }, {
4016
3987
  key: "getNeighborElements",
4017
3988
  value: function getNeighborElements(elementId, dir) {
4018
- var cellPos = this.getCellsInGridByElementId(elementId);
4019
- var curGrid = cellPos.backside ? this.backGrid : this.frontGrid;
3989
+ var _curGrid$area$toX, _rightNeighbour$plann, _curGrid2, _leftNeightbour$plann, _curGrid$area$fromX, _topNeighbour$planned, _curGrid$area$fromX2, _downNeighbour$planne;
3990
+ var res = this.getCellsInGridByElementId(elementId);
3991
+ var curGrid = res.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
4020
3992
  var result = [];
4021
- var resultPlannerIds = [];
3993
+ var plannedElement = res.cells[0].plannedElement;
3994
+ if (!plannedElement) return result;
4022
3995
  switch (dir) {
4023
- case 'TOP':
4024
- for (var i = cellPos.startColIndex; i <= cellPos.endColIndex; i++) {
4025
- var neighborX = i;
4026
- var neighborY = cellPos.endRowIndex + 1;
4027
- if (curGrid[neighborX].length > neighborY) {
4028
- var neighborCell = curGrid[neighborX][neighborY];
4029
- if (neighborCell && resultPlannerIds.indexOf(neighborCell.plannerElementId) == -1) {
4030
- resultPlannerIds.push(neighborCell.plannerElementId);
4031
- result.push(this.plannerElements.get(neighborCell.plannerElementId));
4032
- }
4033
- }
4034
- }
4035
- break;
4036
- case 'DOWN':
4037
- for (var i = cellPos.startColIndex; i <= cellPos.endColIndex; i++) {
4038
- var _neighborX = i;
4039
- var _neighborY = cellPos.startRowIndex - 1;
4040
- if (_neighborY >= 0) {
4041
- var _neighborCell = curGrid[_neighborX][_neighborY];
4042
- if (_neighborCell && resultPlannerIds.indexOf(_neighborCell.plannerElementId) == -1) {
4043
- resultPlannerIds.push(_neighborCell.plannerElementId);
4044
- result.push(this.plannerElements.get(_neighborCell.plannerElementId));
4045
- }
4046
- }
4047
- }
3996
+ case 'RIGHT':
3997
+ var rightNeighbour = (_curGrid$area$toX = curGrid[plannedElement.area.toX]) === null || _curGrid$area$toX === void 0 ? void 0 : _curGrid$area$toX[plannedElement.area.fromY];
3998
+ var rElementId = rightNeighbour === null || rightNeighbour === void 0 || (_rightNeighbour$plann = rightNeighbour.plannedElement) === null || _rightNeighbour$plann === void 0 ? void 0 : _rightNeighbour$plann.elementId;
3999
+ if (rElementId) result.push(this.plannerElements.get(rElementId));
4048
4000
  break;
4049
4001
  case 'LEFT':
4050
- for (var i = cellPos.startRowIndex; i <= cellPos.endRowIndex; i++) {
4051
- var _neighborX2 = cellPos.startColIndex - 1;
4052
- var _neighborY2 = i;
4053
- if (_neighborX2 >= 0) {
4054
- var _neighborCell2 = curGrid[_neighborX2][_neighborY2];
4055
- if (_neighborCell2 && resultPlannerIds.indexOf(_neighborCell2.plannerElementId) == -1) {
4056
- resultPlannerIds.push(_neighborCell2.plannerElementId);
4057
- result.push(this.plannerElements.get(_neighborCell2.plannerElementId));
4058
- }
4059
- }
4060
- }
4002
+ var leftNeightbour = (_curGrid2 = curGrid[plannedElement.area.fromX - 1]) === null || _curGrid2 === void 0 ? void 0 : _curGrid2[plannedElement.area.fromY];
4003
+ var lElementId = leftNeightbour === null || leftNeightbour === void 0 || (_leftNeightbour$plann = leftNeightbour.plannedElement) === null || _leftNeightbour$plann === void 0 ? void 0 : _leftNeightbour$plann.elementId;
4004
+ if (lElementId) result.push(this.plannerElements.get(lElementId));
4061
4005
  break;
4062
- case 'RIGHT':
4063
- for (var i = cellPos.startRowIndex; i <= cellPos.endRowIndex; i++) {
4064
- var _neighborX3 = cellPos.startColIndex + 1;
4065
- var _neighborY3 = i;
4066
- if (curGrid.length > _neighborX3) {
4067
- var _neighborCell3 = curGrid[_neighborX3][_neighborY3];
4068
- if (_neighborCell3 && resultPlannerIds.indexOf(_neighborCell3.plannerElementId) == -1) {
4069
- resultPlannerIds.push(_neighborCell3.plannerElementId);
4070
- result.push(this.plannerElements.get(_neighborCell3.plannerElementId));
4071
- }
4072
- }
4073
- }
4006
+ case 'TOP':
4007
+ var topNeighbour = (_curGrid$area$fromX = curGrid[plannedElement.area.fromX]) === null || _curGrid$area$fromX === void 0 ? void 0 : _curGrid$area$fromX[plannedElement.area.toY];
4008
+ var tElementId = topNeighbour === null || topNeighbour === void 0 || (_topNeighbour$planned = topNeighbour.plannedElement) === null || _topNeighbour$planned === void 0 ? void 0 : _topNeighbour$planned.elementId;
4009
+ if (tElementId) result.push(this.plannerElements.get(tElementId));
4010
+ break;
4011
+ case 'DOWN':
4012
+ var downNeighbour = (_curGrid$area$fromX2 = curGrid[plannedElement.area.fromX]) === null || _curGrid$area$fromX2 === void 0 ? void 0 : _curGrid$area$fromX2[plannedElement.area.fromY - 1];
4013
+ var dElementId = downNeighbour === null || downNeighbour === void 0 || (_downNeighbour$planne = downNeighbour.plannedElement) === null || _downNeighbour$planne === void 0 ? void 0 : _downNeighbour$planne.elementId;
4014
+ if (dElementId) result.push(this.plannerElements.get(dElementId));
4074
4015
  break;
4075
4016
  case 'BACK':
4076
4017
  if (this.hasActiveBackside) {
4077
- var plannerElement = this.getPlannerElementAtGridPos(cellPos.startColIndex, cellPos.startRowIndex, true);
4018
+ var plannerElement = this.getPlannerElementAtGridPos(res.startColIndex, res.startRowIndex, true);
4078
4019
  if (plannerElement != undefined) result = [plannerElement];
4079
4020
  }
4080
- break;
4081
4021
  }
4082
4022
  return result;
4083
4023
  }
@@ -4133,13 +4073,16 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4133
4073
  var depth = 0;
4134
4074
  var height = 0;
4135
4075
  var checkedElementIds = [];
4136
- for (var i = 0; i < this.frontGrid.length; i++) {
4076
+ var frontGrid = this.generalPlanningState.grids[0].matrix;
4077
+ for (var i = 0; i < frontGrid.length; i++) {
4137
4078
  var curHeight = 0;
4138
- for (var j = 0; j < this.frontGrid[i].length; j++) {
4139
- var cell = this.frontGrid[i][j];
4140
- if (cell && checkedElementIds.indexOf(cell.plannerElementId) == -1) {
4141
- curHeight += this.plannerElements.get(cell.plannerElementId).getHeight();
4142
- if (i == 0 && j == 0) depth = this.plannerElements.get(cell.plannerElementId).getDepth();
4079
+ for (var j = 0; j < frontGrid[i].length; j++) {
4080
+ var _cell4;
4081
+ var cell = frontGrid[i][j];
4082
+ var elementId = (_cell4 = cell) === null || _cell4 === void 0 || (_cell4 = _cell4.plannedElement) === null || _cell4 === void 0 ? void 0 : _cell4.elementId;
4083
+ if (elementId && cell && checkedElementIds.indexOf(elementId) == -1) {
4084
+ curHeight += this.plannerElements.get(elementId).getHeight();
4085
+ if (i == 0 && j == 0) depth = this.plannerElements.get(elementId).getDepth();
4143
4086
  }
4144
4087
  }
4145
4088
  if (curHeight > height) height = curHeight;
@@ -4166,7 +4109,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4166
4109
  var result = [];
4167
4110
  var lastHeight = -1;
4168
4111
  for (var idx = 0; idx < this.getColumnCount(); idx++) {
4169
- var row = this.frontGrid[idx];
4112
+ var row = this.generalPlanningState.grids[0].matrix[idx];
4170
4113
  var height = row.reduce(function (added, column) {
4171
4114
  return column.height + added;
4172
4115
  }, 0);
@@ -4211,38 +4154,51 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4211
4154
  /**
4212
4155
  * Get all the Elements need to fill up for the copy of Element x fxe:
4213
4156
  *
4214
- * [4] ->
4215
- * [3]
4216
- * [2]
4157
+ * [4] ->
4158
+ * [3]
4159
+ * [2]
4217
4160
  * [0][1]
4218
4161
  *
4219
- * returns element 4, 3 and 2 because those are needed to copy in order
4162
+ * returns element 4, 3 and 2 because those are needed to copy in order
4220
4163
  * for the copy of element 4 to not float
4221
4164
  */
4222
4165
  }, {
4223
4166
  key: "getAllElementsToFillUp",
4224
4167
  value: function getAllElementsToFillUp(elementId, dir) {
4168
+ var _this = this;
4225
4169
  var curPos = this.getCellsInGridByElementId(elementId);
4226
- if (curPos.startRowIndex == 0) return {
4227
- elements: [],
4228
- backside: false
4229
- };
4230
- var d = dir == 'RIGHT' ? +1 : -1;
4170
+
4231
4171
  //columns and rows are swapped don't ask me why
4172
+ var element = curPos.cells[0].plannedElement;
4232
4173
  var index = {
4233
4174
  x: curPos.startColIndex,
4234
4175
  y: curPos.startRowIndex
4235
4176
  };
4236
- var curGrid = curPos.backside ? this.backGrid : this.frontGrid;
4177
+ var curGrid = curPos.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
4237
4178
  var plannerIdsToFill = [];
4238
4179
  var existingPlannerIds = [];
4239
- for (var colIdx = 0; colIdx <= index.y; colIdx++) {
4240
- var _curGrid$index$x$colI, _curGrid;
4241
- var elementToCopy = (_curGrid$index$x$colI = curGrid[index.x][colIdx]) === null || _curGrid$index$x$colI === void 0 ? void 0 : _curGrid$index$x$colI.plannerElementId;
4242
- var neighbour = (_curGrid = curGrid[index.x + d]) === null || _curGrid === void 0 ? void 0 : _curGrid[colIdx];
4243
- if (!neighbour && elementToCopy) plannerIdsToFill.push(elementToCopy);else if (elementToCopy) existingPlannerIds.push(elementToCopy);
4180
+ var _loop = function _loop(_y) {
4181
+ var _curGrid$index$x$_y;
4182
+ var elementToCopy = (_curGrid$index$x$_y = curGrid[index.x][_y]) === null || _curGrid$index$x$_y === void 0 ? void 0 : _curGrid$index$x$_y.plannedElement;
4183
+ if (!elementToCopy) {
4184
+ y = _y;
4185
+ return 1;
4186
+ } // break
4187
+ var length = element.area.toX - element.area.fromX;
4188
+ var d = dir == 'RIGHT' ? +length : -length;
4189
+ var isPlanned = curGrid.every(function (x, idx) {
4190
+ var _x$_y;
4191
+ return idx < element.area.fromX + d || idx >= element.area.toX + d || ((_x$_y = x[_y]) === null || _x$_y === void 0 ? void 0 : _x$_y.plannedElement);
4192
+ });
4193
+ var neighbour = _this.getNeighborElements(elementToCopy.elementId, dir);
4194
+ if (neighbour.length == 0 && !isPlanned && elementToCopy) plannerIdsToFill.push(elementToCopy.elementId);else if (elementToCopy) existingPlannerIds.push(elementToCopy.elementId);
4195
+ _y = elementToCopy.area.toY;
4196
+ y = _y;
4197
+ };
4198
+ for (var y = 0; y <= index.y;) {
4199
+ if (_loop(y)) break;
4244
4200
  }
4245
- // if there is nothing to fill we copy everyting
4201
+ // if there is nothing to fill we copy everyting
4246
4202
  return {
4247
4203
  elements: plannerIdsToFill.length == 0 ? existingPlannerIds : plannerIdsToFill,
4248
4204
  backside: curPos.backside
@@ -4265,13 +4221,15 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4265
4221
  elements: [],
4266
4222
  backside: false
4267
4223
  };
4268
- var curGrid = curPos.backside ? this.backGrid : this.frontGrid;
4224
+ var curGrid = curPos.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
4269
4225
  var resultPlannerIds = [];
4270
4226
  for (var i = curPos.startColIndex; i <= curPos.endColIndex; i++) {
4271
4227
  for (var j = curPos.startRowIndex--; j >= 0; j--) {
4228
+ var _neighborCell$planned;
4272
4229
  var neighborCell = curGrid[i][j];
4273
- if (neighborCell && resultPlannerIds.indexOf(neighborCell.plannerElementId) == -1) {
4274
- resultPlannerIds.push(neighborCell.plannerElementId);
4230
+ var _elementId5 = neighborCell === null || neighborCell === void 0 || (_neighborCell$planned = neighborCell.plannedElement) === null || _neighborCell$planned === void 0 ? void 0 : _neighborCell$planned.elementId;
4231
+ if (neighborCell && _elementId5 && resultPlannerIds.indexOf(_elementId5) == -1) {
4232
+ resultPlannerIds.push(_elementId5);
4275
4233
  }
4276
4234
  }
4277
4235
  }
@@ -4308,25 +4266,29 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4308
4266
  }, {
4309
4267
  key: "prepareGridForColCopy",
4310
4268
  value: function prepareGridForColCopy(elementId, relativeCopyIndex) {
4311
- var _this$frontGrid;
4269
+ var _this$generalPlanning4, _this$generalPlanning5, _frontGrid;
4312
4270
  if (relativeCopyIndex.y > 0) return;
4313
4271
  var elementToCopyPos = this.getCellsInGridByElementId(elementId);
4314
4272
  var copyDirectionIsRight = relativeCopyIndex.x > 0;
4315
- // We add the relativeCopyIndex only if positive otherwise the whole grid get's
4273
+ // We add the relativeCopyIndex only if positive otherwise the whole grid get's
4316
4274
  // shifted to the right bexause can`t got negative
4275
+ var element = elementToCopyPos.cells[0].plannedElement;
4317
4276
  var absoluteCopyIndex = {
4318
- x: elementToCopyPos.cells[0].index.x + relativeCopyIndex.x,
4319
- y: elementToCopyPos.cells[0].index.y + relativeCopyIndex.y
4277
+ x: element.area.toX - 1 + relativeCopyIndex.x,
4278
+ y: element.area.fromY + relativeCopyIndex.y
4320
4279
  };
4280
+ if (relativeCopyIndex.x < 0) absoluteCopyIndex.x = elementToCopyPos.cells[0].plannedElement.area.fromX;
4321
4281
 
4322
4282
  // check if the side we copy to is already blocked
4323
4283
  // if blocked and we copy to the left the grid get's shifted so the copy
4324
4284
  // get's the index of the copied
4325
-
4326
- var isBlocked = (_this$frontGrid = this.frontGrid[elementToCopyPos.cells[0].index.x + relativeCopyIndex.x]) === null || _this$frontGrid === void 0 ? void 0 : _this$frontGrid[elementToCopyPos.cells[0].index.y];
4285
+ var frontGrid = this.generalPlanningState.grids[0].matrix;
4286
+ var backGrid = (_this$generalPlanning4 = (_this$generalPlanning5 = this.generalPlanningState.grids[1]) === null || _this$generalPlanning5 === void 0 ? void 0 : _this$generalPlanning5.matrix) !== null && _this$generalPlanning4 !== void 0 ? _this$generalPlanning4 : 0;
4287
+ var widthCopyArea = element.area.toX - element.area.fromX;
4288
+ var isBlocked = (_frontGrid = frontGrid[elementToCopyPos.cells[0].index.x + relativeCopyIndex.x]) === null || _frontGrid === void 0 ? void 0 : _frontGrid[elementToCopyPos.cells[0].index.y];
4327
4289
  if (absoluteCopyIndex.x == -1 || isBlocked && !copyDirectionIsRight) absoluteCopyIndex.x -= relativeCopyIndex.x;
4328
4290
 
4329
- // new copy logic fill up like this:
4291
+ // new copy logic fill up like this:
4330
4292
  // [][] -> | [][][]
4331
4293
  // [][] | [][][]
4332
4294
  // [][][] | [][][]
@@ -4334,42 +4296,48 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4334
4296
  // [][] -> | [][][]
4335
4297
  // [][] | [][][]
4336
4298
  // [][][] | [][][][]
4337
-
4299
+ this.getGeneralPlanningState();
4338
4300
  function moveGrid(plannedCells) {
4339
4301
  var grid = new Array();
4340
- var rightNeighbourOfCopy = plannedCells.find(function (c) {
4341
- return c.index.x == (copyDirectionIsRight ? absoluteCopyIndex.x : absoluteCopyIndex.x + 1) && c.index.y == absoluteCopyIndex.y;
4302
+ var rightNeighbour = plannedCells.filter(function (c) {
4303
+ return c.index.x == element.area.toX;
4304
+ });
4305
+ var rightNeighbourOfCopy = rightNeighbour.find(function (c) {
4306
+ return c.index.y == absoluteCopyIndex.y;
4307
+ });
4308
+ var leftNeighbour = plannedCells.filter(function (c) {
4309
+ return c.index.x == element.area.fromX - 1;
4342
4310
  });
4343
- var leftNeighbourOfCopy = plannedCells.find(function (c) {
4344
- return c.index.x == (!copyDirectionIsRight ? absoluteCopyIndex.x : absoluteCopyIndex.x - 1) && c.index.y == absoluteCopyIndex.y;
4311
+ var leftNeighbourOfCopy = leftNeighbour.find(function (neighbour) {
4312
+ return neighbour.index.y == absoluteCopyIndex.y;
4345
4313
  });
4346
4314
  plannedCells.forEach(function (cell) {
4347
- // if i planned to -1 or absolute corrected 0 all the others get moved
4348
- // if we the copied element does not have a neighbour we can just fill
4349
-
4350
- //if (copyDirectionIsRight && cell.index.x >= absoluteCopyIndex) {}
4351
- if (cell.index.x >= absoluteCopyIndex.x && (copyDirectionIsRight && rightNeighbourOfCopy || !copyDirectionIsRight && leftNeighbourOfCopy || absoluteCopyIndex.x == -1)) cell.index.x += 1;
4352
- if (!grid[cell.index.x]) {
4353
- grid[cell.index.x] = [];
4354
- }
4355
- if (!grid[cell.index.x][cell.index.y]) {
4356
- grid[cell.index.x][cell.index.y] = cell;
4357
- }
4315
+ // if we can't fill up (need to move the grid)
4316
+ if (cell.index.x >= absoluteCopyIndex.x && (copyDirectionIsRight && (rightNeighbourOfCopy || rightNeighbour.length == 0) || !copyDirectionIsRight && (leftNeighbourOfCopy || leftNeighbour.length == 0) || absoluteCopyIndex.x == -1)) {
4317
+ cell.index.x += widthCopyArea;
4318
+ cell.plannedElement.area.fromX += widthCopyArea;
4319
+ cell.plannedElement.area.toX += widthCopyArea;
4320
+ }
4321
+ if (!grid[cell.index.x]) grid[cell.index.x] = [];
4322
+ grid[cell.index.x][cell.index.y] = cell;
4358
4323
  });
4359
4324
  return grid;
4360
4325
  }
4361
- this.frontGrid = moveGrid(this.getAllUsedCellsInGrid(false));
4362
- if (!this.frontGrid[absoluteCopyIndex.x]) this.frontGrid[absoluteCopyIndex.x] = [];
4326
+ frontGrid = moveGrid(this.getAllUsedCellsInGrid(false));
4327
+ for (var x = 0; x < widthCopyArea; x++) if (!frontGrid[absoluteCopyIndex.x + x]) frontGrid[absoluteCopyIndex.x + x] = [];
4328
+ this.generalPlanningState.grids[0].matrix = frontGrid;
4363
4329
  if (this.hasActiveBackside) {
4364
- this.backGrid = moveGrid(this.getAllUsedCellsInGrid(true));
4365
- //Init empty cols
4366
- if (!this.backGrid[absoluteCopyIndex.x]) this.backGrid[absoluteCopyIndex.y] = [];
4330
+ backGrid = moveGrid(this.getAllUsedCellsInGrid(true));
4331
+ for (var _x2 = 0; _x2 < widthCopyArea; _x2++) if (!backGrid[absoluteCopyIndex.x + _x2]) backGrid[absoluteCopyIndex.x + _x2] = [];
4332
+ this.generalPlanningState.grids[1].matrix = backGrid;
4367
4333
  }
4368
4334
  }
4369
4335
  }, {
4370
4336
  key: "prepareGridForBackSideCopy",
4371
4337
  value: function prepareGridForBackSideCopy() {
4372
- this.backGrid = new Array();
4338
+ this.generalPlanningState.grids[1] = {
4339
+ matrix: [[]]
4340
+ };
4373
4341
  this.hasActiveBackside = true;
4374
4342
  }
4375
4343
 
@@ -4383,11 +4351,10 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4383
4351
  }, {
4384
4352
  key: "addElementAtGridPos",
4385
4353
  value: function addElementAtGridPos(newElement, col, row, fromBackmodul) {
4386
- var curGrid = fromBackmodul ? this.backGrid : this.frontGrid;
4387
- var result = this.createNewCells(newElement, col, row, fromBackmodul);
4388
- for (var i = 0; i < result.cells.length; i++) {
4389
- var cell = result.cells[i];
4390
- // Prüfen, ob das innere Array existiert, sonst erstellen
4354
+ var curGrid = fromBackmodul ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
4355
+ var cells = this.createNewCells(newElement, col, row, fromBackmodul);
4356
+ for (var i = 0; i < cells.length; i++) {
4357
+ var cell = cells[i];
4391
4358
  if (!curGrid[cell.index.x]) {
4392
4359
  curGrid[cell.index.x] = [];
4393
4360
  }
@@ -4407,16 +4374,20 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4407
4374
  key: "addElementAsCopy",
4408
4375
  value: function addElementAsCopy(copiedElementId, newElement, copyIndex) {
4409
4376
  var curPos = this.getCellsInGridByElementId(copiedElementId);
4377
+ var area = curPos.cells[0].plannedElement.area;
4410
4378
  var cellIndex = {
4411
- x: curPos.endColIndex + copyIndex.x,
4412
- y: curPos.endRowIndex + copyIndex.y
4379
+ x: area.fromX,
4380
+ y: area.fromY
4413
4381
  };
4382
+ if (copyIndex.x > 0) cellIndex.x = area.toX - 1 + copyIndex.x;else if (copyIndex.x < 0) cellIndex.x = area.fromX - (area.toX - area.fromX);else if (copyIndex.y > 0) cellIndex.y = area.toY - 1 + copyIndex.y;
4414
4383
  var backsideForCopy = copyIndex.z == -1 || curPos.backside == true;
4415
- var newCellInfos = this.createNewCells(newElement, cellIndex.x, cellIndex.y, backsideForCopy);
4416
- var curGrid = backsideForCopy ? this.backGrid : this.frontGrid;
4417
- for (var i = 0; i < newCellInfos.cells.length; i++) {
4418
- if (!curGrid[newCellInfos.cells[i].index.x]) curGrid[newCellInfos.cells[i].index.x] = [];
4419
- curGrid[newCellInfos.cells[i].index.x][newCellInfos.cells[i].index.y] = newCellInfos.cells[i];
4384
+ if (cellIndex.x < 0) cellIndex.x = 0; // can't plan to negative space see prepareGridForColCopy
4385
+
4386
+ var cells = this.createNewCells(newElement, cellIndex.x, cellIndex.y, backsideForCopy);
4387
+ var curGrid = backsideForCopy ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
4388
+ for (var i = 0; i < cells.length; i++) {
4389
+ if (!curGrid[cells[i].index.x]) curGrid[cells[i].index.x] = [];
4390
+ curGrid[cells[i].index.x][cells[i].index.y] = cells[i];
4420
4391
  }
4421
4392
  this.plannerElements.set(newElement.getElementId(), newElement);
4422
4393
  }
@@ -4443,12 +4414,75 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4443
4414
  }, {
4444
4415
  key: "updateGridElementDimensions",
4445
4416
  value: function updateGridElementDimensions(elementId, elementData) {
4417
+ var _this2 = this;
4446
4418
  if (!elementData) return;
4447
4419
  var res = this.getCellsInGridByElementId(elementId);
4420
+ var scpe = this.gridSetupParams.forceSingleCellPerElement;
4448
4421
  res.cells.forEach(function (cell) {
4449
- cell.width = elementData.width;
4450
- cell.height = elementData.height;
4422
+ if (!cell.plannedElement) return;
4423
+ cell.plannedElement.size.width = elementData.width;
4424
+ cell.plannedElement.size.height = elementData.height;
4425
+ cell.plannedElement.area = {
4426
+ fromX: cell.index.x,
4427
+ toX: !scpe ? cell.index.x + elementData.width / _this2.gridSetupParams.fixCellRasterWidth : cell.index.x + 1,
4428
+ fromY: cell.index.y,
4429
+ toY: !scpe ? cell.index.y + elementData.height / _this2.gridSetupParams.fixCellRasterHeight : cell.index.y + 1
4430
+ };
4431
+ });
4432
+ if (scpe) return;
4433
+ var newGrid = new Array();
4434
+ var plannedCells = this.getAllUsedCellsInGrid(false);
4435
+ plannedCells.forEach(function (cell) {
4436
+ var area = cell.plannedElement.area;
4437
+ if (newGrid.find(function (x) {
4438
+ return x.find(function (y) {
4439
+ var _y$plannedElement3, _cell$plannedElement8;
4440
+ return ((_y$plannedElement3 = y.plannedElement) === null || _y$plannedElement3 === void 0 ? void 0 : _y$plannedElement3.elementId) == ((_cell$plannedElement8 = cell.plannedElement) === null || _cell$plannedElement8 === void 0 ? void 0 : _cell$plannedElement8.elementId);
4441
+ });
4442
+ })) return;
4443
+ for (var x = area.fromX; x < area.toX; x++) {
4444
+ var _loop2 = function _loop2(y) {
4445
+ if (!newGrid[x]) newGrid[x] = [];
4446
+ if (y < area.fromY) {
4447
+ if (newGrid[x][y]) return 0; // continue
4448
+ var el = _this2.generalPlanningState.grids[0].matrix.findLast(function (_x) {
4449
+ return _x[y].plannedElement;
4450
+ });
4451
+ newGrid[x][y] = {
4452
+ index: {
4453
+ x: x,
4454
+ y: y
4455
+ },
4456
+ plannedElement: el && el.length > 0 ? el[0].plannedElement : undefined
4457
+ };
4458
+ return 0; // continue
4459
+ }
4460
+
4461
+ // if the element got smaller we need to move it to the neighbour
4462
+ //newGrid[x][y] = { ...cell, index: { x, y: y } };
4463
+ newGrid[x][y] = _objectSpread(_objectSpread({}, cell), {}, {
4464
+ index: {
4465
+ x: x,
4466
+ y: y
4467
+ },
4468
+ plannedElement: _objectSpread(_objectSpread({}, cell.plannedElement), {}, {
4469
+ area: {
4470
+ fromX: x,
4471
+ toX: x + (cell.plannedElement.area.toX - cell.plannedElement.area.fromX),
4472
+ fromY: y,
4473
+ toY: y + (cell.plannedElement.area.toY - cell.plannedElement.area.fromY)
4474
+ }
4475
+ })
4476
+ });
4477
+ },
4478
+ _ret;
4479
+ for (var y = 0; y < area.toY; y++) {
4480
+ _ret = _loop2(y);
4481
+ if (_ret === 0) continue;
4482
+ }
4483
+ }
4451
4484
  });
4485
+ if (res.backside) this.generalPlanningState.grids[1].matrix = newGrid;else this.generalPlanningState.grids[0].matrix = newGrid;
4452
4486
  }
4453
4487
 
4454
4488
  /**
@@ -4458,6 +4492,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4458
4492
  }, {
4459
4493
  key: "updateWorldPosOfElements",
4460
4494
  value: function updateWorldPosOfElements() {
4495
+ var _this$generalPlanning6, _this$generalPlanning7;
4461
4496
  //First remove all docking Point relation information
4462
4497
  var _iterator = _createForOfIteratorHelper(this.plannerElements.values()),
4463
4498
  _step;
@@ -4475,14 +4510,18 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4475
4510
  //First remove all docking Point relation information
4476
4511
 
4477
4512
  var allCheckedElementIds = [];
4478
- for (var i = 0; i < this.frontGrid.length; i++) {
4479
- for (var j = 0; j < this.frontGrid[i].length; j++) {
4480
- var cell = this.frontGrid[i][j];
4481
- if (allCheckedElementIds.indexOf(cell.plannerElementId) == -1) {
4482
- var element = this.plannerElements.get(cell.plannerElementId);
4483
- allCheckedElementIds.push(cell.plannerElementId);
4484
- var topNeighbors = this.getNeighborElements(cell.plannerElementId, 'TOP');
4485
- var rightNeighbors = this.getNeighborElements(cell.plannerElementId, 'RIGHT');
4513
+ var frontGrid = this.generalPlanningState.grids[0].matrix;
4514
+ var backGrid = (_this$generalPlanning6 = (_this$generalPlanning7 = this.generalPlanningState.grids[1]) === null || _this$generalPlanning7 === void 0 ? void 0 : _this$generalPlanning7.matrix) !== null && _this$generalPlanning6 !== void 0 ? _this$generalPlanning6 : [];
4515
+ for (var x = 0; x < frontGrid.length; x++) {
4516
+ for (var y = 0; y < frontGrid[x].length; y++) {
4517
+ var _cell$plannedElement9;
4518
+ var cell = frontGrid[x][y];
4519
+ var elementId = cell === null || cell === void 0 || (_cell$plannedElement9 = cell.plannedElement) === null || _cell$plannedElement9 === void 0 ? void 0 : _cell$plannedElement9.elementId;
4520
+ if (elementId && allCheckedElementIds.indexOf(elementId) == -1) {
4521
+ var element = this.plannerElements.get(elementId);
4522
+ allCheckedElementIds.push(elementId);
4523
+ var topNeighbors = this.getNeighborElements(elementId, 'TOP');
4524
+ var rightNeighbors = this.getNeighborElements(elementId, 'RIGHT');
4486
4525
  for (var n = 0; n < topNeighbors.length; n++) {
4487
4526
  PlannerHandler2D.dockingPointHandlerInst.tryDockElement(element, 'AVO', [topNeighbors[n]]);
4488
4527
  }
@@ -4494,20 +4533,22 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4494
4533
  }
4495
4534
  }
4496
4535
  }
4497
- for (var i = 0; i < this.backGrid.length; i++) {
4498
- for (var j = 0; j < this.backGrid[i].length; j++) {
4499
- var _cell5 = this.backGrid[i][j];
4500
- if (allCheckedElementIds.indexOf(_cell5.plannerElementId) == -1) {
4501
- var _element2 = this.plannerElements.get(_cell5.plannerElementId);
4502
- allCheckedElementIds.push(_cell5.plannerElementId);
4503
- var cellFrontGrid = this.frontGrid[i][j];
4504
- var elementFrontGrid = this.plannerElements.get(cellFrontGrid.plannerElementId);
4536
+ for (var i = 0; i < backGrid.length; i++) {
4537
+ for (var j = 0; j < backGrid[i].length; j++) {
4538
+ var _cell5$plannedElement;
4539
+ var _cell5 = backGrid[i][j];
4540
+ var _elementId6 = _cell5 === null || _cell5 === void 0 || (_cell5$plannedElement = _cell5.plannedElement) === null || _cell5$plannedElement === void 0 ? void 0 : _cell5$plannedElement.elementId;
4541
+ if (_elementId6 && allCheckedElementIds.indexOf(_elementId6) == -1) {
4542
+ var _element2 = this.plannerElements.get(_elementId6);
4543
+ allCheckedElementIds.push(_elementId6);
4544
+ var frontCell = frontGrid[i][j];
4545
+ var elementFrontGrid = this.plannerElements.get(frontCell.plannedElement.elementId);
4505
4546
  if (elementFrontGrid) {
4506
4547
  var targetDPFrontGrid = elementFrontGrid === null || elementFrontGrid === void 0 ? void 0 : elementFrontGrid.getDockingPointById('AVO_AVO_2_IL');
4507
4548
  if (!targetDPFrontGrid) LOG$1.error(new DivaUtils.DivaError('Error Loading DockingPoint AVO_2 for plannerElement'));else if (_element2) PlannerHandler2D.dockingPointHandlerInst.tryDockElementToDP(_element2, elementFrontGrid, targetDPFrontGrid);
4508
4549
  }
4509
- var _topNeighbors = this.getNeighborElements(_cell5.plannerElementId, 'TOP');
4510
- var _rightNeighbors = this.getNeighborElements(_cell5.plannerElementId, 'RIGHT');
4550
+ var _topNeighbors = this.getNeighborElements(_elementId6, 'TOP');
4551
+ var _rightNeighbors = this.getNeighborElements(_elementId6, 'RIGHT');
4511
4552
  for (var n = 0; n < _topNeighbors.length; n++) {
4512
4553
  PlannerHandler2D.dockingPointHandlerInst.tryDockElement(_element2, 'AVO', [_topNeighbors[n]]);
4513
4554
  }
@@ -4541,10 +4582,10 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4541
4582
  _iterator2.f();
4542
4583
  }
4543
4584
  this.plannerElements.clear();
4544
- this.frontGrid = new Array();
4585
+ this.generalPlanningState.grids[0].matrix = [];
4545
4586
  if (this.hasActiveBackside) {
4546
4587
  this.hasActiveBackside = false;
4547
- this.backGrid = new Array();
4588
+ this.generalPlanningState.grids[1].matrix = [];
4548
4589
  }
4549
4590
  }
4550
4591
 
@@ -4570,7 +4611,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4570
4611
  _iterator3.f();
4571
4612
  }
4572
4613
  allElements = [];
4573
- this.backGrid = new Array();
4614
+ this.generalPlanningState.grids[1].matrix = [];
4574
4615
  }
4575
4616
  }, {
4576
4617
  key: "getPlannerHasActiveBackside",
@@ -4585,26 +4626,31 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4585
4626
  }, {
4586
4627
  key: "getBoundingBox",
4587
4628
  value: function getBoundingBox() {
4629
+ var _frontGrid$;
4630
+ var frontGrid = this.generalPlanningState.grids[0].matrix;
4631
+ var element = frontGrid === null || frontGrid === void 0 || (_frontGrid$ = frontGrid[0]) === null || _frontGrid$ === void 0 || (_frontGrid$ = _frontGrid$[0]) === null || _frontGrid$ === void 0 ? void 0 : _frontGrid$.plannedElement;
4588
4632
  var height = 0;
4589
4633
  var minX = 0;
4590
4634
  var maxX = 0;
4591
4635
  var curX = 0;
4592
4636
  var minZ = 0;
4593
- var curZ = this.plannerElements.get(this.frontGrid[0][0].plannerElementId).getDepth();
4637
+ var curZ = element ? element.size.depth : 0;
4594
4638
  var maxZ = 0;
4595
4639
  var curDir;
4596
4640
  curDir = 'RIGHT';
4597
4641
  var allCheckedElementIds = [];
4598
- for (var i = 0; i < this.frontGrid.length; i++) {
4599
- var groundCell = this.frontGrid[i][0];
4642
+ for (var i = 0; i < frontGrid.length; i++) {
4643
+ var _groundCell$plannedEl;
4644
+ var groundCell = frontGrid[i][0];
4600
4645
  if (!groundCell) break; //if on the lowest position the cell is empty, the grid ist finished - no wholes are allowed
4601
4646
 
4602
- if (allCheckedElementIds.indexOf(groundCell.plannerElementId) == -1) {
4603
- allCheckedElementIds.push(groundCell.plannerElementId);
4604
- var groundElement = this.plannerElements.get(groundCell.plannerElementId);
4647
+ var elementId = (_groundCell$plannedEl = groundCell.plannedElement) === null || _groundCell$plannedEl === void 0 ? void 0 : _groundCell$plannedEl.elementId;
4648
+ if (elementId && allCheckedElementIds.indexOf(elementId) == -1) {
4649
+ allCheckedElementIds.push(elementId);
4650
+ var groundElement = this.plannerElements.get(elementId);
4605
4651
  if (!groundElement) continue;
4606
4652
  //Check if the col has a corner.
4607
- var elementOption = this.getValueOfOptionOfArticle(groundCell.plannerElementId, 'OPTELEMENT');
4653
+ var elementOption = this.getValueOfOptionOfArticle(elementId, 'OPTELEMENT');
4608
4654
  if (curDir == 'RIGHT') {
4609
4655
  curX += groundElement.getWidth();
4610
4656
  } else if (curDir == 'FRONT') {
@@ -4673,7 +4719,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4673
4719
  var _curGrid$x;
4674
4720
  return ((_curGrid$x = curGrid[x]) === null || _curGrid$x === void 0 ? void 0 : _curGrid$x[y]) === undefined;
4675
4721
  };
4676
- var curGrid = elementCells.backside ? this.backGrid : this.frontGrid;
4722
+ var curGrid = elementCells.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
4677
4723
  var _iterator4 = _createForOfIteratorHelper(this.plannerElements.keys()),
4678
4724
  _step4;
4679
4725
  try {
@@ -4692,7 +4738,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4692
4738
 
4693
4739
  //Now we found a possible place
4694
4740
 
4695
- var locationInformation = this.createLocationInformation(element, elementCells.backside, this.createEmptyCells(otherElementCells.startColIndex, otherElementCells.endRowIndex + 1, otherElementCells.startColIndex, otherElementCells.endRowIndex + 1, element.getWidth(), element.getHeight()), otherElementCells.startColIndex, otherElementCells.endRowIndex + 1, 1, 1);
4741
+ var locationInformation = this.createLocationInformation(element, elementCells.backside, this.createEmptyCells(otherElementCells.cells[0].plannedElement.area.fromX, otherElementCells.cells[0].plannedElement.area.toX, otherElementCells.cells[0].plannedElement.area.fromY, otherElementCells.cells[0].plannedElement.area.toY + 1, element.getWidth(), element.getHeight()), otherElementCells.cells[0].plannedElement.area.fromX, otherElementCells.cells[0].plannedElement.area.toX, 1, 1);
4696
4742
  allFreeMoveLocations.push(locationInformation);
4697
4743
  }
4698
4744
  } else {
@@ -4701,7 +4747,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4701
4747
  var _otherElementCells = this.getCellsInGridByElementId(otherElementId);
4702
4748
  var freeStartTopColIndex = -1;
4703
4749
  var freeEndTopColIndex = -1;
4704
- var topRow = _otherElementCells.endRowIndex + 1;
4750
+ var topRow = _otherElementCells.cells[0].plannedElement.area.toY + 1;
4705
4751
  for (var x = _otherElementCells.startColIndex; x <= _otherElementCells.startColIndex + _otherElementCells.colCount - 1; x++) {
4706
4752
  var freeSpaceFound = false;
4707
4753
  if (isEmptyCell(x, topRow)) {
@@ -4774,7 +4820,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4774
4820
  }
4775
4821
 
4776
4822
  // Determine the grid to work with (front or back) based on the element's location
4777
- var curGrid = elementCells.backside ? this.backGrid : this.frontGrid;
4823
+ var curGrid = elementCells.backside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
4778
4824
 
4779
4825
  // Get the boundaries of the element in the grid
4780
4826
  var startColIndex = elementCells.startColIndex;
@@ -4833,9 +4879,9 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4833
4879
  var targetRowIndex = endRowIndex + 1;
4834
4880
  var _copyPossible = false;
4835
4881
  // Iterate through columns within the element's width
4836
- for (var _x = endColIndex; _x >= startColIndex; _x--) {
4837
- if (isValidCell(_x, targetRowIndex)) {
4838
- copyStartColIndex = _x;
4882
+ for (var _x3 = endColIndex; _x3 >= startColIndex; _x3--) {
4883
+ if (isValidCell(_x3, targetRowIndex)) {
4884
+ copyStartColIndex = _x3;
4839
4885
  _copyPossible = true;
4840
4886
  }
4841
4887
  }
@@ -4849,29 +4895,29 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4849
4895
  case 'RIGHT':
4850
4896
  {
4851
4897
  // Target column to the left of the element
4852
- var _targetColIndex = endColIndex + 1;
4898
+ var _targetColIndex = endColIndex;
4853
4899
  var _copyPossible2 = false;
4854
4900
  // Iterate through rows within the element's height
4855
- for (var _y = startRowIndex; _y <= endRowIndex; _y++) {
4856
- if (isValidCell(_targetColIndex, _y)) {
4857
- copyStartRowIndex = _y;
4901
+ for (var _y2 = startRowIndex; _y2 <= endRowIndex; _y2++) {
4902
+ if (isValidCell(_targetColIndex, _y2)) {
4903
+ copyStartRowIndex = _y2;
4858
4904
  _copyPossible2 = true;
4859
4905
  break;
4860
4906
  }
4861
4907
  }
4862
4908
  if (!_copyPossible2) return undefined;
4863
4909
  _copyPossible2 = false;
4864
- for (var _x2 = endColIndex + 1; _x2 <= endColIndex + elementCells.colCount; _x2++) {
4865
- if (isValidCell(_x2, copyStartRowIndex) && (copyStartRowIndex == 0 || !isValidCell(_x2, copyStartRowIndex - 1))) {
4910
+ for (var _x4 = endColIndex; _x4 <= endColIndex + elementCells.colCount; _x4++) {
4911
+ if (isValidCell(_x4, copyStartRowIndex) && (copyStartRowIndex == 0 || !isValidCell(_x4, copyStartRowIndex - 1))) {
4866
4912
  //check also for overhang
4867
- copyEndColIndex = _x2;
4913
+ copyEndColIndex = _x4;
4868
4914
  _copyPossible2 = true;
4869
4915
  } else {
4870
4916
  break; //when you find one situation where it is not valid skip outside.
4871
4917
  }
4872
4918
  }
4873
4919
  if (!_copyPossible2) return undefined;
4874
- copyStartColIndex = endColIndex + 1;
4920
+ copyStartColIndex = endColIndex;
4875
4921
  copyEndRowIndex = endRowIndex;
4876
4922
  freeCells = this.createEmptyCells(copyStartColIndex, copyStartRowIndex, copyEndColIndex, copyEndRowIndex, element.getWidth(), element.getHeight());
4877
4923
  break;
@@ -4888,7 +4934,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4888
4934
  }, {
4889
4935
  key: "createLocationInformation",
4890
4936
  value: function createLocationInformation(element, fromBackside, cells, cellsStartColIndex, cellsStartRowIndex, cellsColCount, cellsRowCount) {
4891
- var curGrid = fromBackside ? this.backGrid : this.frontGrid;
4937
+ var curGrid = fromBackside ? this.generalPlanningState.grids[1].matrix : this.generalPlanningState.grids[0].matrix;
4892
4938
  var elementLocation = {
4893
4939
  cells: cells,
4894
4940
  widthPerCell: this.gridSetupParams.forceFixCellRasterSize ? this.gridSetupParams.fixCellRasterWidth : element.getWidth(),
@@ -4904,14 +4950,16 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4904
4950
  } else {
4905
4951
  var distToOriginX = 0;
4906
4952
  for (var i = 0; i < cellsStartColIndex; i++) {
4907
- distToOriginX += curGrid[i][0].width;
4953
+ var _plannedElement$size$2, _plannedElement2;
4954
+ distToOriginX += (_plannedElement$size$2 = (_plannedElement2 = curGrid[i][0].plannedElement) === null || _plannedElement2 === void 0 ? void 0 : _plannedElement2.size.width) !== null && _plannedElement$size$2 !== void 0 ? _plannedElement$size$2 : 0;
4908
4955
  }
4909
4956
  if (cellsStartColIndex < 0) {
4910
4957
  distToOriginX = -element.getWidth();
4911
4958
  }
4912
4959
  var distToOriginY = 0;
4913
4960
  for (var i = 0; i < cellsStartRowIndex; i++) {
4914
- distToOriginY += curGrid[cellsStartColIndex][i].height;
4961
+ var _plannedElement$size$3, _plannedElement3;
4962
+ distToOriginY += (_plannedElement$size$3 = (_plannedElement3 = curGrid[cellsStartColIndex][i].plannedElement) === null || _plannedElement3 === void 0 ? void 0 : _plannedElement3.size.width) !== null && _plannedElement$size$3 !== void 0 ? _plannedElement$size$3 : 0;
4915
4963
  }
4916
4964
  elementLocation.startIndexWorldPos = new index.Vector2(distToOriginX, distToOriginY);
4917
4965
  }
@@ -4927,7 +4975,8 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4927
4975
  for (var i = 0; i < allElements.length; i++) {
4928
4976
  var element = allElements[i];
4929
4977
  var elementCells = this.getCellsInGridByElementId(element.getElementId());
4930
- var elementLocation = this.createLocationInformation(element, elementCells.backside, elementCells.cells, elementCells.startColIndex, elementCells.startRowIndex, elementCells.colCount, elementCells.rowCount);
4978
+ var area = elementCells.cells[0].plannedElement.area;
4979
+ var elementLocation = this.createLocationInformation(element, elementCells.backside, elementCells.cells, area.fromX, area.toX, area.fromY, area.toY);
4931
4980
  var planningLeftLocation = this.getFreePlanningLocation(element.getElementId(), 'LEFT');
4932
4981
  var planningRightLocation = this.getFreePlanningLocation(element.getElementId(), 'RIGHT');
4933
4982
  var planningTopLocation = this.getFreePlanningLocation(element.getElementId(), 'TOP');
@@ -4954,9 +5003,11 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4954
5003
  }, {
4955
5004
  key: "getGeneralPlanningState",
4956
5005
  value: function getGeneralPlanningState(selectedElementId) {
4957
- var matrix = [];
4958
- var selectedElement = undefined;
4959
- var plannedElements = Array.from(this.plannerElements.values()).map(function (p) {
5006
+ return this.generalPlanningState;
5007
+ /*
5008
+ let matrix: Cell[][] = [];
5009
+ let selectedElement: SelectedElement | undefined = undefined;
5010
+ const plannedElements: PlannedElement[] = Array.from(this.plannerElements.values()).map((p) => {
4960
5011
  return {
4961
5012
  basketId: p.getBasketId(),
4962
5013
  elementId: p.getElementId(),
@@ -4964,67 +5015,67 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
4964
5015
  size: {
4965
5016
  width: p.getWidth(),
4966
5017
  height: p.getHeight(),
4967
- depth: p.getDepth()
5018
+ depth: p.getDepth(),
4968
5019
  },
4969
5020
  area: {
4970
5021
  fromX: undefined,
4971
5022
  toX: undefined,
4972
5023
  fromY: undefined,
4973
- toY: undefined
4974
- }
5024
+ toY: undefined,
5025
+ } as any,
4975
5026
  };
4976
5027
  });
4977
- for (var i = 0; i < this.frontGrid.length; i++) {
5028
+ let frontGrid = this.generalPlanningState.grids[0].matrix;
5029
+ let index = { x: 0, y: 0 };
5030
+ for (let i = 0; i < frontGrid.length; i++) {
4978
5031
  matrix.push([]);
4979
- var frontGridRow = this.frontGrid[i];
4980
- var _loop = function _loop() {
4981
- var cell = frontGridRow[j];
4982
- if (cell) {
4983
- var plannedElement = plannedElements.find(function (p) {
4984
- return p.elementId === cell.plannerElementId;
4985
- });
4986
- if (plannedElement) {
4987
- if (plannedElement.area.fromX === undefined || plannedElement.area.fromX > cell.index.x) plannedElement.area.fromX = cell.index.x;
4988
- if (plannedElement.area.toX === undefined || plannedElement.area.toX < cell.index.x) plannedElement.area.toX = cell.index.x;
4989
- if (plannedElement.area.fromY === undefined || plannedElement.area.fromY > cell.index.y) plannedElement.area.fromY = cell.index.y;
4990
- if (plannedElement.area.toY === undefined || plannedElement.area.toY < cell.index.y) plannedElement.area.toY = cell.index.y;
5032
+ const frontGridRow = frontGrid[i];
5033
+ for (let j = 0; j < frontGridRow.length; j++) {
5034
+ const cell = frontGridRow[j];
5035
+ let elementId = cell.plannedElement?.elementId;
5036
+ if (elementId && cell) {
5037
+ const plannedElement = plannedElements.find((p) => p.elementId === elementId);
5038
+ let matrixIndex = 0;
5039
+ for (let idx = cell.index.x - 1; idx >= 0; idx--)
5040
+ matrixIndex += frontGridRow[idx]!.plannedElement!.size.width / 19.2;
5041
+ if (plannedElement) {
5042
+
5043
+ plannedElement.area.fromX = matrixIndex;
5044
+ plannedElement.area.toX = matrixIndex + cell.plannedElement!.size.width / 19.2;
5045
+ plannedElement.area.fromY = cell.index.y;
5046
+ plannedElement.area.toY = cell.index.y + cell.plannedElement!.size.height / 19.2;
5047
+ for (let x = plannedElement.area.fromX; x < plannedElement.area.toX; x++) {
5048
+ for (let y = plannedElement.area.fromY; y < plannedElement.area.toY; y++) {
5049
+ if (!matrix[x]) matrix[x] = [];
5050
+ matrix[x][y] = { index: { x, y }, plannedElement };
5051
+ }
5052
+ }
5053
+ continue;
4991
5054
  }
4992
- matrix[i].push({
4993
- index: cell.index,
4994
- plannedElement: plannedElement
4995
- });
5055
+ matrix[matrixIndex].push({ index: index, plannedElement });
4996
5056
  }
4997
- };
4998
- for (var j = 0; j < frontGridRow.length; j++) {
4999
- _loop();
5000
5057
  }
5001
5058
  }
5002
-
5003
- // Fill matrix rows to equal length
5004
- var maxLength = Math.max.apply(Math, _toConsumableArray__default["default"](matrix.map(function (row) {
5005
- return row.length;
5006
- })));
5007
- matrix.forEach(function (row) {
5059
+ // Fill matrix rows to equal length
5060
+ const maxLength = Math.max(...matrix.map((row) => row.length));
5061
+ matrix.forEach((row) => {
5008
5062
  while (row.length < maxLength) {
5009
- var _row$;
5010
- var lastCell = row[row.length - 1];
5011
- var newY = lastCell ? lastCell.index.y + 1 : 0;
5063
+ const lastCell = row[row.length - 1];
5064
+ const newY = lastCell ? lastCell.index.y + 1 : 0;
5012
5065
  row.push({
5013
- index: new index.Vector2(((_row$ = row[0]) === null || _row$ === void 0 ? void 0 : _row$.index.x) || 0, newY),
5014
- plannedElement: undefined
5066
+ index: new Vector2(row[0]?.index.x || 0, newY),
5067
+ plannedElement: undefined,
5015
5068
  });
5016
5069
  }
5017
5070
  });
5018
- var selectedPlannedElement = selectedElementId ? plannedElements.find(function (p) {
5019
- return p.elementId === selectedElementId;
5020
- }) : undefined;
5071
+ let selectedPlannedElement = selectedElementId ? plannedElements.find((p) => p.elementId === selectedElementId) : undefined;
5021
5072
  if (selectedPlannedElement) {
5022
5073
  //add the free let planningLeftLocation = this.getFreePlanningLocation(element.getElementId(), 'LEFT');
5023
- var planningLeftLocation = this.getFreePlanningLocation(selectedPlannedElement.elementId, 'LEFT');
5024
- var planningRightLocation = this.getFreePlanningLocation(selectedPlannedElement.elementId, 'RIGHT');
5025
- var planningTopLocation = this.getFreePlanningLocation(selectedPlannedElement.elementId, 'TOP');
5026
- var fixedPositionRules = [];
5027
- if (planningLeftLocation) {
5074
+ let planningLeftLocation = this.getFreePlanningLocation(selectedPlannedElement.elementId, 'LEFT');
5075
+ let planningRightLocation = this.getFreePlanningLocation(selectedPlannedElement.elementId, 'RIGHT');
5076
+ let planningTopLocation = this.getFreePlanningLocation(selectedPlannedElement.elementId, 'TOP');
5077
+ let fixedPositionRules: FixedPositonRule[] = [];
5078
+ if (planningLeftLocation) {
5028
5079
  this.addFreeCellsToMatrix(matrix, planningLeftLocation.cells, fixedPositionRules);
5029
5080
  }
5030
5081
  if (planningRightLocation) {
@@ -5033,27 +5084,28 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
5033
5084
  if (planningTopLocation) {
5034
5085
  this.addFreeCellsToMatrix(matrix, planningTopLocation.cells, fixedPositionRules);
5035
5086
  }
5036
- selectedElement = {
5087
+ selectedElement = {
5037
5088
  articleCodex: selectedPlannedElement.articleCodex,
5038
5089
  size: selectedPlannedElement.size,
5039
5090
  gridSpace: {
5040
5091
  rows: selectedPlannedElement.area.toY - selectedPlannedElement.area.fromY + 1,
5041
- colums: selectedPlannedElement.area.toX - selectedPlannedElement.area.fromX + 1
5092
+ colums: selectedPlannedElement.area.toX - selectedPlannedElement.area.fromX + 1,
5042
5093
  },
5043
5094
  rules: fixedPositionRules,
5044
- elementId: selectedElementId
5095
+ elementId: selectedElementId!,
5045
5096
  };
5046
5097
  }
5047
5098
  return {
5048
- grids: [{
5049
- index: 0,
5050
- // boxplanner usecase grid index always 0
5051
- rowSizes: this.getRowSizes(matrix, selectedElement),
5052
- columnSizes: this.getColumnSizes(matrix, selectedElement),
5053
- matrix: matrix
5054
- }],
5055
- selectedElement: selectedElement
5056
- };
5099
+ grids: [
5100
+ {
5101
+ index: 0, // boxplanner usecase grid index always 0
5102
+ rowSizes: this.getRowSizes(matrix, selectedElement),
5103
+ columnSizes: this.getColumnSizes(matrix, selectedElement),
5104
+ matrix,
5105
+ },
5106
+ ],
5107
+ selectedElement,
5108
+ }; */
5057
5109
  }
5058
5110
  }, {
5059
5111
  key: "getRowSizes",
@@ -5062,7 +5114,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
5062
5114
  //system 4 useacse
5063
5115
  var totalColCount = matrix[0].length;
5064
5116
  var colSizes = Array(totalColCount).fill(-1);
5065
- var _loop2 = function _loop2(i) {
5117
+ var _loop3 = function _loop3(i) {
5066
5118
  var _matrix$find;
5067
5119
  var cell = (_matrix$find = matrix.find(function (row) {
5068
5120
  var _row$i$plannedElement, _row$i$plannedElement2;
@@ -5076,7 +5128,7 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
5076
5128
  if (colSizes[i] === -1) return 1; // break
5077
5129
  };
5078
5130
  for (var i = 0; i < totalColCount; i++) {
5079
- if (_loop2(i)) break;
5131
+ if (_loop3(i)) break;
5080
5132
  }
5081
5133
  if (colSizes.includes(-1)) LOG$1.error(new Error('Column sizes are not set'));
5082
5134
  return colSizes;
@@ -5139,9 +5191,9 @@ var BoxPlannerGrid = /*#__PURE__*/function () {
5139
5191
  });
5140
5192
  if (!column) {
5141
5193
  matrix.map(function (row) {
5142
- var _row$2;
5194
+ var _row$;
5143
5195
  return row.push({
5144
- index: new index.Vector2(((_row$2 = row[0]) === null || _row$2 === void 0 ? void 0 : _row$2.index.x) || 0, y),
5196
+ index: new index.Vector2(((_row$ = row[0]) === null || _row$ === void 0 ? void 0 : _row$.index.x) || 0, y),
5145
5197
  plannedElement: undefined
5146
5198
  });
5147
5199
  });
@@ -5348,7 +5400,7 @@ var DivaBoxPlanner = /*#__PURE__*/function () {
5348
5400
  key: "addPlannerElement",
5349
5401
  value: (function () {
5350
5402
  var _addPlannerElement = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(basketID, params) {
5351
- var plannerElement, data;
5403
+ var plannerElement, data, constructionRules, _constructionRules$co, _constructionRules$co2;
5352
5404
  return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
5353
5405
  while (1) switch (_context2.prev = _context2.next) {
5354
5406
  case 0:
@@ -5367,7 +5419,19 @@ var DivaBoxPlanner = /*#__PURE__*/function () {
5367
5419
  return PlannerHandler2D.handler2D.loadSVG(plannerElement, this.set);
5368
5420
  case 9:
5369
5421
  if (!this.constructionRulesHandler.getConstructionRulesLoaded()) {
5370
- this.constructionRulesHandler.setConstructionRules(this.set.getConstructionRuleOfElementId(plannerElement.ElementId));
5422
+ constructionRules = this.set.getConstructionRuleOfElementId(plannerElement.ElementId);
5423
+ if (constructionRules) {
5424
+ this.boxPlannerGrid.GridSetupParams = {
5425
+ fixCellRasterHeight: 19.2,
5426
+ fixCellRasterWidth: 19.2,
5427
+ forceFixCellRasterSize: (_constructionRules$co = constructionRules.constructionRules.forceFixCellRasterSize) !== null && _constructionRules$co !== void 0 ? _constructionRules$co : true,
5428
+ forceSingleCellPerElement: (_constructionRules$co2 = constructionRules.constructionRules.forceSingleCellPerElement) !== null && _constructionRules$co2 !== void 0 ? _constructionRules$co2 : true,
5429
+ hasMaxGridRasterHeight: constructionRules.constructionRules.hasMaxGridRasterHeight,
5430
+ maxGridRasterHeight: constructionRules.constructionRules.maxGridRasterHeight,
5431
+ hasMaxGridRasterWidth: constructionRules.constructionRules.hasMaxGridRasterWidth,
5432
+ maxGridRasterWidth: constructionRules.constructionRules.maxGridRasterWidth
5433
+ }, this.constructionRulesHandler.setConstructionRules(constructionRules);
5434
+ }
5371
5435
  }
5372
5436
  this.boxPlannerGrid.addElementAtGridPos(plannerElement, params.boxCol, params.boxRow, params.backside != undefined ? params.backside : false);
5373
5437
  if (!params.boxUpdateWholePlanning) {
@@ -5561,7 +5625,7 @@ var DivaBoxPlanner = /*#__PURE__*/function () {
5561
5625
  result.backside;
5562
5626
  } else {
5563
5627
  var _result = this.boxPlannerGrid.getAllElementsToFillUp(elementId, copyInfo.copyIndex.x > 0 ? 'RIGHT' : 'LEFT');
5564
- allElementsToCopy = allElementsToCopy.concat(_result.elements);
5628
+ allElementsToCopy = _result.elements;
5565
5629
  _result.backside;
5566
5630
  }
5567
5631
  }