@crystaldesign/diva-web-planner-react 25.1.0-beta.40 → 25.1.0-beta.42

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.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see 3596.diva-web-planner-react.umd.min.js.LICENSE.txt */
2
- "use strict";(self.webpackChunkCrystaldesignDivaWebPlannerReact=self.webpackChunkCrystaldesignDivaWebPlannerReact||[]).push([[3596],{33596:(e,t,i)=>{i.r(t),i.d(t,{default:()=>g});var r=i(84658),l=i(12952),n=i(13125),s=i(43860),a=i(80248),c=i(50747),d=i.n(c),o=i(37537),h=i(15549),u=i(1446),f=i(69821),g=function(){return(0,s.Z)((function ShelfPlanner(e,t){if((0,n.Z)(this,ShelfPlanner),(0,a.Z)(this,"article",void 0),(0,a.Z)(this,"grids",[]),(0,a.Z)(this,"isVisible",void 0),(0,a.Z)(this,"showOnRule",void 0),(0,a.Z)(this,"showAfterOPT",void 0),(0,a.Z)(this,"data",void 0),(0,a.Z)(this,"freeArticlesPossible",{}),(0,a.Z)(this,"freeArticlesPlanned",{}),(0,a.Z)(this,"gridAllowedOnCells",void 0),(0,a.Z)(this,"gridAllowedOntoArticles",void 0),(0,a.Z)(this,"takePlaceOnOtherGrids",void 0),(0,a.Z)(this,"disableCellsByElement",void 0),(0,a.Z)(this,"montageOptions",[]),this.article=t,this.disableCellsByElement=e.DisableCells,this.data=e,this.showAfterOPT=e.ShowAfterOPT,this.showOnRule=e.ShowOnRule?o.ZP.getRuleByFormula(e.ShowOnRule,t.catalogCodex,t.CatalogData.multiselectOptions):void 0,this.gridAllowedOnCells=e.GridAllowedOnCells,this.gridAllowedOntoArticles=e.GridAllowedOntoArticles,this.takePlaceOnOtherGrids=e.TakePlaceOnOtherGrids,this.initFreeArticles(),e.ShelfPlanner&&e.ShelfPlanner.length>0){for(var i=0;i<e.ShelfPlanner.length;i++)this.creatNewGrid(i),this.updateDisabledCells();this.montageOptions=(0,l.Z)(new Set(this.grids.reduce((function(e,t){return e=e.concat(t.montageOptionsList)}),[])))}}),[{key:"initFreeArticles",value:function initFreeArticles(){if(this.data.ShelfPlanner)for(var e=0;e<this.data.ShelfPlanner.length;e++){var t=this.data.ShelfPlanner[e];if(t.initAccArr)for(var i=0;i<t.initAccArr.length;i++){var r=t.initAccArr[i];r.noPrice&&(void 0===this.freeArticlesPossible[r.Codex]&&(this.freeArticlesPossible[r.Codex]=0),this.freeArticlesPossible[r.Codex]+=r.Quantity)}}}},{key:"IsVisible",get:function get(){return this.isVisible}},{key:"setIsVisible",value:(x=(0,r.Z)(d().mark((function _callee(e){return d().wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:if(this.isVisible==e){t.next=12;break}if(!e){t.next=10;break}if(this.isVisible=e,this.article.shelfPlanData){t.next=8;break}return t.next=6,this.onConfigChanged();case 6:return t.next=8,this.initAccList();case 8:t.next=12;break;case 10:return t.next=12,this.deleteAllAcc();case 12:this.isVisible=e;case 13:case"end":return t.stop()}}),_callee,this)}))),function setIsVisible(e){return x.apply(this,arguments)})},{key:"onConfigChanged",value:(k=(0,r.Z)(d().mark((function _callee2(){var e,t,i,r,l,n;return d().wrap((function _callee2$(s){for(;;)switch(s.prev=s.next){case 0:for(e=!1,t=[],i=0;i<this.grids.length;i++)t.push(this.grids[i].onConfigChanged());r=0;case 4:if(!(r<t.length)){s.next=11;break}if(!t[r].length){s.next=8;break}return s.next=8,this.grids[r].deleteAllAccOfGrid();case 8:r++,s.next=4;break;case 11:l=0;case 12:if(!(l<t.length)){s.next=23;break}if(t[l].length){s.next=15;break}return s.abrupt("continue",20);case 15:if(n=this.grids[l],t[l].includes("heightGridRule")&&(this.creatNewGrid(l),e=!0),!t[l].includes("heightGridRule")&&!t[l].includes("disableGridRule")||n.DisabledByRule){s.next=20;break}return s.next=20,this.initAccList(l);case 20:l++,s.next=12;break;case 23:e&&this.updateDisabledCells();case 24:case"end":return s.stop()}}),_callee2,this)}))),function onConfigChanged(){return k.apply(this,arguments)})},{key:"creatNewGrid",value:function creatNewGrid(e){this.grids[e]=new u.Z(e,this.article,this.data)}},{key:"initAccList",value:(A=(0,r.Z)(d().mark((function _callee3(e){var t,i,r,l,n,s,a,c,o,u,f,g;return d().wrap((function _callee3$(d){for(;;)switch(d.prev=d.next){case 0:t=this.activeGrids,i=0;case 2:if(!(i<t.length)){d.next=36;break}if(r=t[i],void 0===e||r.ShelfIndex===e){d.next=6;break}return d.abrupt("continue",33);case 6:if(r.InitAccArr){d.next=8;break}return d.abrupt("continue",33);case 8:l=0;case 9:if(!(l<r.InitAccArr.length)){d.next=33;break}n=r.InitAccArr[l],s=0;case 12:if(!(s<n.initRH.length)){d.next=30;break}return r.ActAccessoire=n.Codex,d.next=16,h.Z.addAccessorieOnShelfPlanner(this.article.set,r.ShelfIndex,n.initRH[s],r.basketId,{noMove:n.noMove,noDelete:n.noDelete,byInit:!0});case 16:if(!n.replaceFromParent){d.next=26;break}if(!(c=this.getShelfParentShelfId())||null===(a=this.article.accessoireParentArticle)||void 0===a||!a.shelfPlanner){d.next=26;break}if(!((o=this.article.accessoireParentArticle.shelfPlanner.getAccessorireByCodex(c,n.Codex))&&o.length>0)){d.next=26;break}if(f=o[0],void 0===(g=null===(u=f.shelfPlanner)||void 0===u?void 0:u.getRHOnParentArticle())||void 0===f.relatedToShelfGrid){d.next=26;break}return d.next=26,h.Z.deleteAccessorieOnShelfPlanner(this.article.set,f.relatedToShelfGrid,g,this.article.accessoireParentArticle.basketId);case 26:r.ActAccessoire=void 0;case 27:s++,d.next=12;break;case 30:l++,d.next=9;break;case 33:i++,d.next=2;break;case 36:case"end":return d.stop()}}),_callee3,this)}))),function initAccList(e){return A.apply(this,arguments)})},{key:"getAccessorireByCodex",value:function getAccessorireByCodex(e,t){var i=this.grids.find((function(t){return t.ShelfId==e})),r=[];if(i)for(var l in i.Accessoires)i.Accessoires[l].articleCodex==t&&r.push(i.Accessoires[l]);return r}},{key:"triggerVisibility",value:(v=(0,r.Z)(d().mark((function _callee4(e){var t,i,r,l,n,s,a;return d().wrap((function _callee4$(c){for(;;)switch(c.prev=c.next){case 0:t=[],i=[],r=0;case 3:if(!(r<this.grids.length)){c.next=13;break}if((l=this.grids[r]).VisitOption){c.next=7;break}return c.abrupt("continue",10);case 7:if(!i.includes(l.VisitOption)&&!t.includes(l.VisitOption)){c.next=9;break}return c.abrupt("continue",10);case 9:e&&(l.gridGroup==e||l.alternativeGridGroups.includes(e))?(i.push(l.VisitOption),t.includes(l.VisitOption)&&t.splice(t.indexOf(l.VisitOption),1)):t.push(l.VisitOption);case 10:r++,c.next=3;break;case 13:n=0;case 14:if(!(n<[].concat(i,t).length)){c.next=23;break}if(s=[].concat(i,t)[n],!(a=this.article.getArticleOptionState("OPT"+s))){c.next=20;break}return c.next=20,f.Z.updateOption(this.article,a.optionCodex,i.includes(s)?"OPVMIT":"OPVOHNE");case 20:n++,c.next=14;break;case 23:case"end":return c.stop()}}),_callee4,this)}))),function triggerVisibility(e){return v.apply(this,arguments)})},{key:"deleteAllAcc",value:(g=(0,r.Z)(d().mark((function _callee5(){var e;return d().wrap((function _callee5$(t){for(;;)switch(t.prev=t.next){case 0:this.article.shelfPlanData=void 0,e=0;case 2:if(!(e<this.grids.length)){t.next=8;break}return t.next=5,this.grids[e].deleteAllAccOfGrid();case 5:e++,t.next=2;break;case 8:case"end":return t.stop()}}),_callee5,this)}))),function deleteAllAcc(){return g.apply(this,arguments)})},{key:"GridAllowedOnCells",get:function get(){return this.gridAllowedOnCells}},{key:"GridAllowedOntoArticles",get:function get(){return this.gridAllowedOntoArticles}},{key:"TakePlaceOnOtherGrids",get:function get(){return this.takePlaceOnOtherGrids}},{key:"tryFitOnShelfOfGrid",value:function tryFitOnShelfOfGrid(e,t,i){var r=i.shelfHeight,l=this.grids[e];if(!r||isNaN(r))return alert("Der artikel: "+i.name+" hat keine RH hinterlegt! Der Metatag 'HEIGHTGRIDUSED' ist: "+i.shelfHeight),!1;var n=!1,s=this.doesTakePlaceOnOtherGrids(i)?this.activeGrids:[l];if(l.checkAccessoireInGridRules(i))return{type:"notAllowedByMaxQuantityReached",size:r};for(var a=0;a<s.length;a++)if(!1===(n=s[a].tryFitOnShelf(i,t,i.shelfPlanner))||"doesNotFit"===n.type||n.type.startsWith("notAllowed")||void 0===n.index)return n;return n}},{key:"getFreeSpacesOfAccessoireOfGrids",value:function getFreeSpacesOfAccessoireOfGrids(e,t){for(var i=this.grids,r={},l=0;l<i.length;l++){var n=i[l];n.DisabledByRule||(r[n.GridName]={freeCells:n.getFreeSpacesOfAccessoire(t),idx:l})}return r}},{key:"getPlannedSpacesOfGrids",value:function getPlannedSpacesOfGrids(){for(var e=this.grids,t={},i=0;i<e.length;i++){var r=e[i];r.DisabledByRule||(t[r.GridName]={accessories:r.getPlannedSpaces(),idx:i})}return t}},{key:"deleteAccessoireOfCellInGrid",value:(c=(0,r.Z)(d().mark((function _callee6(e,t){var i,r,l,n,s;return d().wrap((function _callee6$(a){for(;;)switch(a.prev=a.next){case 0:if(i=this.grids[e],r=i.Cells[t].InUse,(n=i.Cells.find((function(e){return e.OnBoard==r})))?(l=n.InUse,n.Article):(l=t,s=i.Cells[t].Article),!s){a.next=8;break}return this.checkForNewFreeAccessoire(s,e),a.next=8,this.handleDeleteTakePlaceOnOtherGrids(e,l,s);case 8:return a.next=10,i.deleteAccessoireInCells(l);case 10:return a.abrupt("return",a.sent);case 11:case"end":return a.stop()}}),_callee6,this)}))),function deleteAccessoireOfCellInGrid(e,t){return c.apply(this,arguments)})},{key:"checkForNewFreeAccessoire",value:function checkForNewFreeAccessoire(e,t){if(void 0!==this.freeArticlesPossible[e.articleCodex]&&e.noPrice){this.freeArticlesPlanned[e.articleCodex]-=e.quantity;var i=this.grids[t];for(var r in i.Accessoires)i.Accessoires[r].articleCodex!=e.articleCodex||i.Accessoires[r].noPrice||(i.Accessoires[r].noPrice=!0,this.freeArticlesPlanned[i.Accessoires[r].articleCodex]+=e.quantity)}}},{key:"handleDeleteTakePlaceOnOtherGrids",value:(i=(0,r.Z)(d().mark((function _callee7(e,t,i){var r,l,n,s,a,c,o;return d().wrap((function _callee7$(d){for(;;)switch(d.prev=d.next){case 0:if(i.shelfHeight){d.next=2;break}return d.abrupt("return");case 2:if(i.shelfHeightAbove)for(r=0;r<i.shelfHeightAbove;r++)(null==(n=this.grids[e].Cells[t+i.shelfHeight+r])||null===(l=n.Article)||void 0===l?void 0:l.basketId)===i.basketId&&n.ClearInUse();if(i.shelfHeightBelow)for(s=0;s<i.shelfHeightBelow;s++)(null==(c=this.grids[e].Cells[t-(s+1)])||null===(a=c.Article)||void 0===a?void 0:a.basketId)===i.basketId&&c.ClearInUse();if(!this.doesTakePlaceOnOtherGrids(i)){d.next=14;break}o=0;case 6:if(!(o<this.grids.length)){d.next=14;break}if(o!==e){d.next=9;break}return d.abrupt("continue",11);case 9:return d.next=11,this.grids[o].deleteAccessoireInCells(t);case 11:o++,d.next=6;break;case 14:case"end":return d.stop()}}),_callee7,this)}))),function handleDeleteTakePlaceOnOtherGrids(e,t,r){return i.apply(this,arguments)})},{key:"addAccessoireInCellInGrid",value:(t=(0,r.Z)(d().mark((function _callee8(e,t,i,r,l){var n,s,a;return d().wrap((function _callee8$(c){for(;;)switch(c.prev=c.next){case 0:n=this.doesTakePlaceOnOtherGrids(e)?this.activeGrids:[this.grids[t]],s=0;case 2:if(!(s<n.length)){c.next=11;break}if(!(a=n[s]).DisabledByRule){c.next=6;break}return c.abrupt("continue",8);case 6:return c.next=8,n[s].addAccessoireInCells(i,e,r,a.ShelfIndex!==t||(null==l?void 0:l.noMove),a.ShelfIndex!==t||(null==l?void 0:l.noDelete),a.ShelfIndex!==t||void 0);case 8:s++,c.next=2;break;case 11:this.checkForFreeAccessoire(e);case 12:case"end":return c.stop()}}),_callee8,this)}))),function addAccessoireInCellInGrid(e,i,r,l,n){return t.apply(this,arguments)})},{key:"checkForFreeAccessoire",value:function checkForFreeAccessoire(e){void 0!==this.freeArticlesPossible[e.articleCodex]&&(void 0===this.freeArticlesPlanned[e.articleCodex]||this.freeArticlesPossible[e.articleCodex]>this.freeArticlesPlanned[e.articleCodex])&&(e.noPrice=!0,void 0===this.freeArticlesPlanned[e.articleCodex]&&(this.freeArticlesPlanned[e.articleCodex]=0),this.freeArticlesPlanned[e.articleCodex]+=e.quantity)}},{key:"doesTakePlaceOnOtherGrids",value:function doesTakePlaceOnOtherGrids(e){var t,i=null===(t=e.shelfPlanner)||void 0===t?void 0:t.takePlaceOnOtherGrids;if(i)for(var r=0;r<i.length;r++)if(i[r].onParent==this.article.articleCodex)return!0;return!1}},{key:"accessoires",get:function get(){for(var e={},t=this.activeGrids,i=0;i<t.length;i++)for(var r in t[i].Accessoires)e[r]=t[i].Accessoires[r];return Object.keys(e).length>0?e:void 0}},{key:"DisableCellsByElement",get:function get(){return this.disableCellsByElement}},{key:"getActAccessoireOfGrid",value:function getActAccessoireOfGrid(e){return this.grids[e].ActAccessoire}},{key:"setActAccessoireOfGrid",value:function setActAccessoireOfGrid(e,t){for(var i=!1,r=this.GridsOrGroupById(e),l=0;l<r.length;l++){var n=r[l];t&&n.getArticleRelationsById(e).includes(t)?n.ActAccessoire!==t&&(n.ActAccessoire=t,i=!0):n.ActAccessoire=void 0}return i}},{key:"generateShelfPlandata",value:function generateShelfPlandata(){for(var e,t=[],i=this.activeGrids,r=0;r<i.length;r++){for(var l=[],n=i[r],s=0;s<n.Cells.length;s++){var a,c,d=n.Cells[s];if(l.push({inUse:d.InUse,noDelete:d.NoDelete,noMove:d.NoMove,onBoard:d.OnBoard}),n.ShelfIndex!=r&&(l[s].gridIndex=n.ShelfIndex),d.InUse==s)l[s].usedArticleData={Codex:null===(a=d.Article)||void 0===a?void 0:a.articleCodex,BasketID:null===(c=d.Article)||void 0===c?void 0:c.basketId}}t.push(l)}return{ShelfPlanner2:t,DoorPlannerData:null===(e=this.article.doorPlanner)||void 0===e?void 0:e.getMovedData(this.article.basketId)}}},{key:"getShelfPlannerAccessoires3DValues",value:function getShelfPlannerAccessoires3DValues(e){for(var t=this.activeGrids,i=0;i<t.length;i++)for(var r=t[i],l=0;l<r.Cells.length;l++){var n=r.Cells[l];if(n.InUse==l&&n.Article&&n.Article.model3DName&&!n.OnlyPlaceHolder){var s,a=n.Index;"vertikal"==r.Direction&&1!=this.article.CatalogData.useShelfPlannerRTV&&(a=r.Cells.length-1-n.Index),e.push({basketId:null===(s=n.Article)||void 0===s?void 0:s.basketId,gridId:r.ShelfIndex,gridName:r.GridName,model:n.Article.model3DName,parentBasketId:this.article.basketId,parentElementId:this.getShelfElementId(),rh:a}),n.Article.shelfPlanner&&(e=e.concat(n.Article.shelfPlanner.getShelfPlannerAccessoires3DValues([])))}}return e}},{key:"getShelfElementId",value:function getShelfElementId(){var e;if(null!==(e=this.article.accessoireParentArticle)&&void 0!==e&&e.shelfPlanner&&void 0!==this.article.relatedToShelfGrid&&this.grids.length>0){var t=this.getRHOnParentArticle();return this.article.accessoireParentArticle.shelfPlanner.getShelfElementId()+"."+this.article.relatedToShelfGrid+"."+t}return this.article.elementId.toString()}},{key:"getRHOnParentArticle",value:function getRHOnParentArticle(){var e,t=this;if(void 0!==this.article.relatedToShelfGrid)return null===(e=this.article.accessoireParentArticle)||void 0===e||null===(e=e.shelfPlanner)||void 0===e||null===(e=e.grids[this.article.relatedToShelfGrid].Cells.find((function(e){var i;return(null===(i=e.Article)||void 0===i?void 0:i.basketId)==t.article.basketId})))||void 0===e?void 0:e.InUse}},{key:"getShelfPlannerItems",value:function getShelfPlannerItems(e){for(var t=[],i=this.article.CatalogData,r=this.GridsOrGroupById(e),l=0;l<r.length;l++){var n=r[l].getArticleRelationsById(e);if(null!=n&&n.length)for(var s=function _loop(){var e=n[a];if(i.checkIfArticleCodexExists(e)){var r=i.getCatalogArticleByArticleCodex(e);if(!r||t.find((function(e){return e.articleCodex===r.articleCodex})))return 1;t.push({articleCodex:r.articleCodex,configStepKeys:[],image:r.image?i.getCatImageURL(r.image,""):void 0,name:r.name,price:i.dontShowBasePrice?0:Number(r.articlePrice),width:r.width,height:r.height,depth:r.depth,cellSize:r.shelfHeight,metaData:r.metaDataView,contentItemId:r.contentItemId,groupContentItemId:r.groupContentItemId,partlistcodexes:r.possiblePartlistCodexes})}},a=0;a<n.length;a++)s()}return{accessoires:t,grids:r}}},{key:"getShelfParentShelfId",value:function getShelfParentShelfId(){var e;if(void 0!==this.article.relatedToShelfGrid)return null===(e=this.article.accessoireParentArticle)||void 0===e||null===(e=e.shelfPlanner)||void 0===e||null===(e=e.grids[this.article.relatedToShelfGrid])||void 0===e?void 0:e.ShelfId}},{key:"updateOnDockingChanged",value:function updateOnDockingChanged(e){("AVL"==e&&"RH_OVER_AVL"==this.disableCellsByElement||"AVR"==e&&"RH_OVER_AVR"==this.disableCellsByElement)&&this.updateDisabledCells()}},{key:"updateDisabledCells",value:function updateDisabledCells(){this.updateDisabledCellsOnDockedElements(),this.checkOnDockedHeight()}},{key:"updateDisabledCellsOnDockedElements",value:function updateDisabledCellsOnDockedElements(){var e,t,i=this.activeGrids;null===(e=this.article.dockedOnAV("AVL"))||void 0===e||null===(e=e.shelfPlanner)||void 0===e||e.disableCellsByDockedShelfs(i[0].Cells.length,"AVR"),null===(t=this.article.dockedOnAV("AVR"))||void 0===t||null===(t=t.shelfPlanner)||void 0===t||t.disableCellsByDockedShelfs(i[0].Cells.length,"AVL")}},{key:"checkOnDockedHeight",value:function checkOnDockedHeight(){var e=this.article.dockedOnAV("AVR"),t=this.article.dockedOnAV("AVL");null!=e&&e.shelfPlanner&&e.shelfPlanner.grids.length>0&&this.disableCellsByDockedShelfs(e.shelfPlanner.grids[0].Cells.length,"AVR"),null!=t&&t.shelfPlanner&&t.shelfPlanner.grids.length>0&&this.disableCellsByDockedShelfs(t.shelfPlanner.grids[0].Cells.length,"AVL")}},{key:"disableCellsByDockedShelfs",value:(e=(0,r.Z)(d().mark((function _callee9(e,t){var i,r,l,n,s,a;return d().wrap((function _callee9$(c){for(;;)switch(c.prev=c.next){case 0:if(!("AVR"==t&&"RH_OVER_AVR"==this.disableCellsByElement||"AVL"==t&&"RH_OVER_AVL"==this.disableCellsByElement)){c.next=19;break}i=this.activeGrids,r=0;case 3:if(!(r<i.length)){c.next=19;break}l=i[r],n=e;case 6:if(!(n<l.Cells.length)){c.next=15;break}if((s=l.Cells[n]).InUse!=n){c.next=11;break}return c.next=11,h.Z.deleteAccessorieOnShelfPlanner(this.article.set,l.ShelfIndex,s.InUse,l.basketId);case 11:s.IsDisabled=!0;case 12:n++,c.next=6;break;case 15:for(a=0;a<e&&a<l.Cells.length;a++)l.Cells[a].IsDisabled=!1;case 16:r++,c.next=3;break;case 19:case"end":return c.stop()}}),_callee9,this)}))),function disableCellsByDockedShelfs(t,i){return e.apply(this,arguments)})},{key:"getGridByGridName",value:function getGridByGridName(e){return this.grids.find((function(t){return t.GridName==e}))}},{key:"getGridByIndex",value:function getGridByIndex(e){return this.grids.find((function(t){return t.ShelfIndex==e}))}},{key:"GridsOrGroupById",value:function GridsOrGroupById(e){return this.activeGrids.filter((function(t){return t.ShelfId==e||t.group==e||t.alternativeGridGroups.includes(e)}))}},{key:"getSelectedAccessoireById",value:function getSelectedAccessoireById(e){var t;return null===(t=this.GridsOrGroupById(e).find((function(t){if(t.ActAccessoire&&t.getArticleRelationsById(e).includes(t.ActAccessoire))return t})))||void 0===t?void 0:t.ActAccessoire}},{key:"getCellIndexOfBasketId",value:function getCellIndexOfBasketId(e,t){var i;return null===(i=this.getGridByIndex(e))||void 0===i?void 0:i.getIndexOfBasketId(t)}},{key:"allGrids",get:function get(){return this.grids}},{key:"activeGrids",get:function get(){return this.grids.filter((function(e){return!e.DisabledByRule}))}},{key:"allMontageOptions",get:function get(){return this.montageOptions}},{key:"getRelatedToGridIdByArticleCodex",value:function getRelatedToGridIdByArticleCodex(e,t){var i=this.grids[t].getGridIdByArticleCodex(e);if(i)return i;for(var r=0;r<this.grids.length;r++){var l=this.grids[r].getGridIdByArticleCodex(e);if(l)return l}}}]);var e,t,i,c,g,v,A,k,x}()}}]);
2
+ "use strict";(self.webpackChunkCrystaldesignDivaWebPlannerReact=self.webpackChunkCrystaldesignDivaWebPlannerReact||[]).push([[3596],{33596:(e,t,i)=>{i.r(t),i.d(t,{default:()=>g});var r=i(84658),l=i(12952),n=i(13125),s=i(43860),a=i(80248),c=i(50747),d=i.n(c),o=i(37537),h=i(15549),u=i(1446),f=i(69821),g=function(){return(0,s.Z)((function ShelfPlanner(e,t){if((0,n.Z)(this,ShelfPlanner),(0,a.Z)(this,"article",void 0),(0,a.Z)(this,"grids",[]),(0,a.Z)(this,"isVisible",void 0),(0,a.Z)(this,"showOnRule",void 0),(0,a.Z)(this,"showAfterOPT",void 0),(0,a.Z)(this,"data",void 0),(0,a.Z)(this,"freeArticlesPossible",{}),(0,a.Z)(this,"freeArticlesPlanned",{}),(0,a.Z)(this,"gridAllowedOnCells",void 0),(0,a.Z)(this,"gridAllowedOntoArticles",void 0),(0,a.Z)(this,"takePlaceOnOtherGrids",void 0),(0,a.Z)(this,"disableCellsByElement",void 0),(0,a.Z)(this,"montageOptions",[]),this.article=t,this.disableCellsByElement=e.DisableCells,this.data=e,this.showAfterOPT=e.ShowAfterOPT,this.showOnRule=e.ShowOnRule?o.ZP.getRuleByFormula(e.ShowOnRule,t.catalogCodex,t.CatalogData.multiselectOptions):void 0,this.gridAllowedOnCells=e.GridAllowedOnCells,this.gridAllowedOntoArticles=e.GridAllowedOntoArticles,this.takePlaceOnOtherGrids=e.TakePlaceOnOtherGrids,this.initFreeArticles(),e.ShelfPlanner&&e.ShelfPlanner.length>0){for(var i=0;i<e.ShelfPlanner.length;i++)this.creatNewGrid(i),this.updateDisabledCells();this.montageOptions=(0,l.Z)(new Set(this.grids.reduce((function(e,t){return e=e.concat(t.montageOptionsList)}),[])))}}),[{key:"initFreeArticles",value:function initFreeArticles(){if(this.data.ShelfPlanner)for(var e=0;e<this.data.ShelfPlanner.length;e++){var t=this.data.ShelfPlanner[e];if(t.initAccArr)for(var i=0;i<t.initAccArr.length;i++){var r=t.initAccArr[i];r.noPrice&&(void 0===this.freeArticlesPossible[r.Codex]&&(this.freeArticlesPossible[r.Codex]=0),this.freeArticlesPossible[r.Codex]+=r.Quantity)}}}},{key:"IsVisible",get:function get(){return this.isVisible}},{key:"setIsVisible",value:(x=(0,r.Z)(d().mark((function _callee(e){return d().wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:if(this.isVisible==e){t.next=12;break}if(!e){t.next=10;break}if(this.isVisible=e,this.article.shelfPlanData){t.next=8;break}return t.next=6,this.onConfigChanged();case 6:return t.next=8,this.initAccList();case 8:t.next=12;break;case 10:return t.next=12,this.deleteAllAcc();case 12:this.isVisible=e;case 13:case"end":return t.stop()}}),_callee,this)}))),function setIsVisible(e){return x.apply(this,arguments)})},{key:"onConfigChanged",value:(k=(0,r.Z)(d().mark((function _callee2(){var e,t,i,r,l,n;return d().wrap((function _callee2$(s){for(;;)switch(s.prev=s.next){case 0:for(e=!1,t=[],i=0;i<this.grids.length;i++)t.push(this.grids[i].onConfigChanged());r=0;case 4:if(!(r<t.length)){s.next=11;break}if(!t[r].length){s.next=8;break}return s.next=8,this.grids[r].deleteAllAccOfGrid();case 8:r++,s.next=4;break;case 11:l=0;case 12:if(!(l<t.length)){s.next=23;break}if(t[l].length){s.next=15;break}return s.abrupt("continue",20);case 15:if(n=this.grids[l],t[l].includes("heightGridRule")&&(this.creatNewGrid(l),e=!0),!t[l].includes("heightGridRule")&&!t[l].includes("disableGridRule")||n.DisabledByRule){s.next=20;break}return s.next=20,this.initAccList(l);case 20:l++,s.next=12;break;case 23:e&&this.updateDisabledCells();case 24:case"end":return s.stop()}}),_callee2,this)}))),function onConfigChanged(){return k.apply(this,arguments)})},{key:"creatNewGrid",value:function creatNewGrid(e){this.grids[e]=new u.Z(e,this.article,this.data)}},{key:"initAccList",value:(A=(0,r.Z)(d().mark((function _callee3(e){var t,i,r,l,n,s,a,c,o,u,f,g;return d().wrap((function _callee3$(d){for(;;)switch(d.prev=d.next){case 0:t=this.activeGrids,i=0;case 2:if(!(i<t.length)){d.next=36;break}if(r=t[i],void 0===e||r.ShelfIndex===e){d.next=6;break}return d.abrupt("continue",33);case 6:if(r.InitAccArr){d.next=8;break}return d.abrupt("continue",33);case 8:l=0;case 9:if(!(l<r.InitAccArr.length)){d.next=33;break}n=r.InitAccArr[l],s=0;case 12:if(!(s<n.initRH.length)){d.next=30;break}return r.ActAccessoire=n.Codex,d.next=16,h.Z.addAccessorieOnShelfPlanner(this.article.set,r.ShelfIndex,n.initRH[s],r.basketId,{noMove:n.noMove,noDelete:n.noDelete,byInit:!0});case 16:if(!n.replaceFromParent){d.next=26;break}if(!(c=this.getShelfParentShelfId())||null===(a=this.article.accessoireParentArticle)||void 0===a||!a.shelfPlanner){d.next=26;break}if(!((o=this.article.accessoireParentArticle.shelfPlanner.getAccessorireByCodex(c,n.Codex))&&o.length>0)){d.next=26;break}if(f=o[0],void 0===(g=null===(u=f.shelfPlanner)||void 0===u?void 0:u.getRHOnParentArticle())||void 0===f.relatedToShelfGrid){d.next=26;break}return d.next=26,h.Z.deleteAccessorieOnShelfPlanner(this.article.set,f.relatedToShelfGrid,g,this.article.accessoireParentArticle.basketId);case 26:r.ActAccessoire=void 0;case 27:s++,d.next=12;break;case 30:l++,d.next=9;break;case 33:i++,d.next=2;break;case 36:case"end":return d.stop()}}),_callee3,this)}))),function initAccList(e){return A.apply(this,arguments)})},{key:"getAccessorireByCodex",value:function getAccessorireByCodex(e,t){var i=this.grids.find((function(t){return t.ShelfId==e})),r=[];if(i)for(var l in i.Accessoires)i.Accessoires[l].articleCodex==t&&r.push(i.Accessoires[l]);return r}},{key:"triggerVisibility",value:(v=(0,r.Z)(d().mark((function _callee4(e){var t,i,r,l,n,s,a;return d().wrap((function _callee4$(c){for(;;)switch(c.prev=c.next){case 0:t=[],i=[],r=0;case 3:if(!(r<this.grids.length)){c.next=13;break}if((l=this.grids[r]).VisitOption){c.next=7;break}return c.abrupt("continue",10);case 7:if(!i.includes(l.VisitOption)&&!t.includes(l.VisitOption)){c.next=9;break}return c.abrupt("continue",10);case 9:e&&(l.gridGroup==e||l.alternativeGridGroups.includes(e))?(i.push(l.VisitOption),t.includes(l.VisitOption)&&t.splice(t.indexOf(l.VisitOption),1)):t.push(l.VisitOption);case 10:r++,c.next=3;break;case 13:n=0;case 14:if(!(n<[].concat(i,t).length)){c.next=23;break}if(s=[].concat(i,t)[n],!(a=this.article.getArticleOptionState("OPT"+s))){c.next=20;break}return c.next=20,f.Z.updateOption(this.article,a.optionCodex,i.includes(s)?"OPVMIT":"OPVOHNE");case 20:n++,c.next=14;break;case 23:case"end":return c.stop()}}),_callee4,this)}))),function triggerVisibility(e){return v.apply(this,arguments)})},{key:"deleteAllAcc",value:(g=(0,r.Z)(d().mark((function _callee5(){var e;return d().wrap((function _callee5$(t){for(;;)switch(t.prev=t.next){case 0:this.article.shelfPlanData=void 0,e=0;case 2:if(!(e<this.grids.length)){t.next=8;break}return t.next=5,this.grids[e].deleteAllAccOfGrid();case 5:e++,t.next=2;break;case 8:case"end":return t.stop()}}),_callee5,this)}))),function deleteAllAcc(){return g.apply(this,arguments)})},{key:"GridAllowedOnCells",get:function get(){return this.gridAllowedOnCells}},{key:"GridAllowedOntoArticles",get:function get(){return this.gridAllowedOntoArticles}},{key:"TakePlaceOnOtherGrids",get:function get(){return this.takePlaceOnOtherGrids}},{key:"tryFitOnShelfOfGrid",value:function tryFitOnShelfOfGrid(e,t,i){var r=i.shelfHeight,l=this.grids[e];if(!r||isNaN(r))return alert("Der artikel: "+i.name+" hat keine RH hinterlegt! Der Metatag 'HEIGHTGRIDUSED' ist: "+i.shelfHeight),!1;var n=!1,s=this.doesTakePlaceOnOtherGrids(i)?this.activeGrids:[l];if(l.checkAccessoireInGridRules(i))return{type:"notAllowedByMaxQuantityReached",size:r};for(var a=0;a<s.length;a++)if(!1===(n=s[a].tryFitOnShelf(i,t,i.shelfPlanner))||"doesNotFit"===n.type||n.type.startsWith("notAllowed")||void 0===n.index)return n;return n}},{key:"getFreeSpacesOfAccessoireOfGrids",value:function getFreeSpacesOfAccessoireOfGrids(e,t){for(var i=this.grids,r={},l=0;l<i.length;l++){var n=i[l];n.DisabledByRule||(r[n.GridName]={freeCells:n.getFreeSpacesOfAccessoire(t),idx:l})}return r}},{key:"getPlannedSpacesOfGrids",value:function getPlannedSpacesOfGrids(){for(var e=this.grids,t={},i=0;i<e.length;i++){var r=e[i];r.DisabledByRule||(t[r.GridName]={accessories:r.getPlannedSpaces(),idx:i})}return t}},{key:"deleteAccessoireOfCellInGrid",value:(c=(0,r.Z)(d().mark((function _callee6(e,t){var i,r,l,n,s;return d().wrap((function _callee6$(a){for(;;)switch(a.prev=a.next){case 0:if(i=this.grids[e],r=i.Cells[t].InUse,(n=i.Cells.find((function(e){return e.OnBoard==r})))?(l=n.InUse,n.Article):(l=t,s=i.Cells[t].Article),!s){a.next=8;break}return this.checkForNewFreeAccessoire(s,e),a.next=8,this.handleDeleteTakePlaceOnOtherGrids(e,l,s);case 8:return a.next=10,i.deleteAccessoireInCells(l);case 10:return a.abrupt("return",a.sent);case 11:case"end":return a.stop()}}),_callee6,this)}))),function deleteAccessoireOfCellInGrid(e,t){return c.apply(this,arguments)})},{key:"checkForNewFreeAccessoire",value:function checkForNewFreeAccessoire(e,t){if(void 0!==this.freeArticlesPossible[e.articleCodex]&&e.noPrice){this.freeArticlesPlanned[e.articleCodex]-=e.quantity;var i=this.grids[t];for(var r in i.Accessoires)i.Accessoires[r].articleCodex!=e.articleCodex||i.Accessoires[r].noPrice||(i.Accessoires[r].noPrice=!0,this.freeArticlesPlanned[i.Accessoires[r].articleCodex]+=e.quantity)}}},{key:"handleDeleteTakePlaceOnOtherGrids",value:(i=(0,r.Z)(d().mark((function _callee7(e,t,i){var r,l,n,s,a,c,o;return d().wrap((function _callee7$(d){for(;;)switch(d.prev=d.next){case 0:if(i.shelfHeight){d.next=2;break}return d.abrupt("return");case 2:if(i.shelfHeightAbove)for(r=0;r<i.shelfHeightAbove;r++)(null==(n=this.grids[e].Cells[t+i.shelfHeight+r])||null===(l=n.Article)||void 0===l?void 0:l.basketId)===i.basketId&&n.ClearInUse();if(i.shelfHeightBelow)for(s=0;s<i.shelfHeightBelow;s++)(null==(c=this.grids[e].Cells[t-(s+1)])||null===(a=c.Article)||void 0===a?void 0:a.basketId)===i.basketId&&c.ClearInUse();if(!this.doesTakePlaceOnOtherGrids(i)){d.next=14;break}o=0;case 6:if(!(o<this.grids.length)){d.next=14;break}if(o!==e){d.next=9;break}return d.abrupt("continue",11);case 9:return d.next=11,this.grids[o].deleteAccessoireInCells(t);case 11:o++,d.next=6;break;case 14:case"end":return d.stop()}}),_callee7,this)}))),function handleDeleteTakePlaceOnOtherGrids(e,t,r){return i.apply(this,arguments)})},{key:"addAccessoireInCellInGrid",value:(t=(0,r.Z)(d().mark((function _callee8(e,t,i,r,l){var n,s,a;return d().wrap((function _callee8$(c){for(;;)switch(c.prev=c.next){case 0:n=this.doesTakePlaceOnOtherGrids(e)?this.activeGrids:[this.grids[t]],s=0;case 2:if(!(s<n.length)){c.next=11;break}if(!(a=n[s]).DisabledByRule){c.next=6;break}return c.abrupt("continue",8);case 6:return c.next=8,n[s].addAccessoireInCells(i,e,r,a.ShelfIndex!==t||(null==l?void 0:l.noMove),a.ShelfIndex!==t||(null==l?void 0:l.noDelete),a.ShelfIndex!==t||void 0);case 8:s++,c.next=2;break;case 11:this.checkForFreeAccessoire(e);case 12:case"end":return c.stop()}}),_callee8,this)}))),function addAccessoireInCellInGrid(e,i,r,l,n){return t.apply(this,arguments)})},{key:"checkForFreeAccessoire",value:function checkForFreeAccessoire(e){void 0!==this.freeArticlesPossible[e.articleCodex]&&(void 0===this.freeArticlesPlanned[e.articleCodex]||this.freeArticlesPossible[e.articleCodex]>this.freeArticlesPlanned[e.articleCodex])&&(e.noPrice=!0,void 0===this.freeArticlesPlanned[e.articleCodex]&&(this.freeArticlesPlanned[e.articleCodex]=0),this.freeArticlesPlanned[e.articleCodex]+=e.quantity)}},{key:"doesTakePlaceOnOtherGrids",value:function doesTakePlaceOnOtherGrids(e){var t,i=null===(t=e.shelfPlanner)||void 0===t?void 0:t.takePlaceOnOtherGrids;if(i)for(var r=0;r<i.length;r++)if(i[r].onParent==this.article.articleCodex)return!0;return!1}},{key:"accessoires",get:function get(){for(var e={},t=this.activeGrids,i=0;i<t.length;i++)for(var r in t[i].Accessoires)e[r]=t[i].Accessoires[r];return Object.keys(e).length>0?e:void 0}},{key:"DisableCellsByElement",get:function get(){return this.disableCellsByElement}},{key:"getActAccessoireOfGrid",value:function getActAccessoireOfGrid(e){return this.grids[e].ActAccessoire}},{key:"setActAccessoireOfGrid",value:function setActAccessoireOfGrid(e,t){for(var i=!1,r=this.GridsOrGroupById(e),l=0;l<r.length;l++){var n=r[l];t&&n.getArticleRelationsById(e).includes(t)?n.ActAccessoire!==t&&(n.ActAccessoire=t,i=!0):n.ActAccessoire=void 0}return i}},{key:"generateShelfPlandata",value:function generateShelfPlandata(){for(var e,t=[],i=this.activeGrids,r=0;r<i.length;r++){for(var l=[],n=i[r],s=0;s<n.Cells.length;s++){var a,c,d=n.Cells[s];if(l.push({inUse:d.InUse,noDelete:d.NoDelete,noMove:d.NoMove,onBoard:d.OnBoard}),n.ShelfIndex!=r&&(l[s].gridIndex=n.ShelfIndex),d.InUse==s)l[s].usedArticleData={Codex:null===(a=d.Article)||void 0===a?void 0:a.articleCodex,BasketID:null===(c=d.Article)||void 0===c?void 0:c.basketId}}t.push(l)}return{ShelfPlanner2:t,DoorPlannerData:null===(e=this.article.doorPlanner)||void 0===e?void 0:e.getMovedData(this.article.basketId)}}},{key:"getShelfPlannerAccessoires3DValues",value:function getShelfPlannerAccessoires3DValues(e){for(var t=this.activeGrids,i=0;i<t.length;i++)for(var r=t[i],l=0;l<r.Cells.length;l++){var n=r.Cells[l];if(n.InUse==l&&n.Article&&n.Article.model3DName&&!n.OnlyPlaceHolder){var s,a=n.Index;"vertikal"==r.Direction&&1!=this.article.CatalogData.useShelfPlannerRTV&&(a=r.Cells.length-1-n.Index),e.push({basketId:null===(s=n.Article)||void 0===s?void 0:s.basketId,gridId:r.ShelfIndex,gridName:r.GridName,model:n.Article.model3DName,parentBasketId:this.article.basketId,parentElementId:this.getShelfElementId(),rh:a}),n.Article.shelfPlanner&&(e=e.concat(n.Article.shelfPlanner.getShelfPlannerAccessoires3DValues([])))}}return e}},{key:"getShelfElementId",value:function getShelfElementId(){var e;if(null!==(e=this.article.accessoireParentArticle)&&void 0!==e&&e.shelfPlanner&&void 0!==this.article.relatedToShelfGrid&&this.grids.length>0){var t=this.getRHOnParentArticle();return this.article.accessoireParentArticle.shelfPlanner.getShelfElementId()+"."+this.article.relatedToShelfGrid+"."+t}return this.article.elementId.toString()}},{key:"getRHOnParentArticle",value:function getRHOnParentArticle(){var e,t=this;if(void 0!==this.article.relatedToShelfGrid)return null===(e=this.article.accessoireParentArticle)||void 0===e||null===(e=e.shelfPlanner)||void 0===e||null===(e=e.grids[this.article.relatedToShelfGrid].Cells.find((function(e){var i;return(null===(i=e.Article)||void 0===i?void 0:i.basketId)==t.article.basketId})))||void 0===e?void 0:e.InUse}},{key:"getShelfPlannerItems",value:function getShelfPlannerItems(e){for(var t=[],i=this.article.CatalogData,r=this.GridsOrGroupById(e),l=0;l<r.length;l++){var n=r[l].getArticleRelationsById(e);if(null!=n&&n.length)for(var s=function _loop(){var e=n[a];if(i.checkIfArticleCodexExists(e)){var r=i.getCatalogArticleByArticleCodex(e);if(!r||t.find((function(e){return e.articleCodex===r.articleCodex})))return 1;t.push({articleCodex:r.articleCodex,configStepKeys:[],image:r.image?i.getCatImageURL(r.image,""):void 0,name:r.name,price:i.dontShowBasePrice?0:Number(r.articlePrice),width:r.width,height:r.height,depth:r.depth,cellSize:r.shelfHeight,metaData:r.metaDataView,contentItemId:r.contentItemId,groupContentItemId:r.groupContentItemId,partlistcodexes:r.possiblePartlistCodexes})}},a=0;a<n.length;a++)s()}return{accessoires:t,grids:r}}},{key:"getShelfParentShelfId",value:function getShelfParentShelfId(){var e;if(void 0!==this.article.relatedToShelfGrid)return null===(e=this.article.accessoireParentArticle)||void 0===e||null===(e=e.shelfPlanner)||void 0===e||null===(e=e.grids[this.article.relatedToShelfGrid])||void 0===e?void 0:e.ShelfId}},{key:"updateOnDockingChanged",value:function updateOnDockingChanged(e){("AVL"==e&&"RH_OVER_AVL"==this.disableCellsByElement||"AVR"==e&&"RH_OVER_AVR"==this.disableCellsByElement)&&this.updateDisabledCells()}},{key:"updateDisabledCells",value:function updateDisabledCells(){this.updateDisabledCellsOnDockedElements(),this.checkOnDockedHeight()}},{key:"updateDisabledCellsOnDockedElements",value:function updateDisabledCellsOnDockedElements(){var e,t,i=this.activeGrids;null===(e=this.article.dockedOnAV("AVL"))||void 0===e||null===(e=e.shelfPlanner)||void 0===e||e.disableCellsByDockedShelfs(i[0].Cells.length,"AVR"),null===(t=this.article.dockedOnAV("AVR"))||void 0===t||null===(t=t.shelfPlanner)||void 0===t||t.disableCellsByDockedShelfs(i[0].Cells.length,"AVL")}},{key:"checkOnDockedHeight",value:function checkOnDockedHeight(){var e=this.article.dockedOnAV("AVR"),t=this.article.dockedOnAV("AVL");null!=e&&e.shelfPlanner&&e.shelfPlanner.activeGrids.length>0&&this.disableCellsByDockedShelfs(e.shelfPlanner.activeGrids[0].Cells.length,"AVR"),null!=t&&t.shelfPlanner&&t.shelfPlanner.activeGrids.length>0&&this.disableCellsByDockedShelfs(t.shelfPlanner.activeGrids[0].Cells.length,"AVL")}},{key:"disableCellsByDockedShelfs",value:(e=(0,r.Z)(d().mark((function _callee9(e,t){var i,r,l,n,s,a;return d().wrap((function _callee9$(c){for(;;)switch(c.prev=c.next){case 0:if(!("AVR"==t&&"RH_OVER_AVR"==this.disableCellsByElement||"AVL"==t&&"RH_OVER_AVL"==this.disableCellsByElement)){c.next=19;break}i=this.activeGrids,r=0;case 3:if(!(r<i.length)){c.next=19;break}l=i[r],n=e;case 6:if(!(n<l.Cells.length)){c.next=15;break}if((s=l.Cells[n]).InUse!=n){c.next=11;break}return c.next=11,h.Z.deleteAccessorieOnShelfPlanner(this.article.set,l.ShelfIndex,s.InUse,l.basketId);case 11:s.IsDisabled=!0;case 12:n++,c.next=6;break;case 15:for(a=0;a<e&&a<l.Cells.length;a++)l.Cells[a].IsDisabled=!1;case 16:r++,c.next=3;break;case 19:case"end":return c.stop()}}),_callee9,this)}))),function disableCellsByDockedShelfs(t,i){return e.apply(this,arguments)})},{key:"getGridByGridName",value:function getGridByGridName(e){return this.grids.find((function(t){return t.GridName==e}))}},{key:"getGridByIndex",value:function getGridByIndex(e){return this.grids.find((function(t){return t.ShelfIndex==e}))}},{key:"GridsOrGroupById",value:function GridsOrGroupById(e){return this.activeGrids.filter((function(t){return t.ShelfId==e||t.group==e||t.alternativeGridGroups.includes(e)}))}},{key:"getSelectedAccessoireById",value:function getSelectedAccessoireById(e){var t;return null===(t=this.GridsOrGroupById(e).find((function(t){if(t.ActAccessoire&&t.getArticleRelationsById(e).includes(t.ActAccessoire))return t})))||void 0===t?void 0:t.ActAccessoire}},{key:"getCellIndexOfBasketId",value:function getCellIndexOfBasketId(e,t){var i;return null===(i=this.getGridByIndex(e))||void 0===i?void 0:i.getIndexOfBasketId(t)}},{key:"allGrids",get:function get(){return this.grids}},{key:"activeGrids",get:function get(){return this.grids.filter((function(e){return!e.DisabledByRule}))}},{key:"allMontageOptions",get:function get(){return this.montageOptions}},{key:"getRelatedToGridIdByArticleCodex",value:function getRelatedToGridIdByArticleCodex(e,t){var i=this.grids[t].getGridIdByArticleCodex(e);if(i)return i;for(var r=0;r<this.grids.length;r++){var l=this.grids[r].getGridIdByArticleCodex(e);if(l)return l}}}]);var e,t,i,c,g,v,A,k,x}()}}]);