function FileUploaded(fileUploadEle,folder){angular.element(fileUploadEle).scope().VariableDataUploaded(fileUploadEle,folder)}quoteCalculator.service("generalService",function(uiService,ajaxService,getQuoteValidationService,restructureService,$sce){this.createStandardTableMethods=function($scope){$scope.refreshPriceOnUpdate=!0,$scope.priceNeedsRefreshing=!1,$scope.toggleRefreshPriceOnUpdate=function(){$scope.refreshPriceOnUpdate=!$scope.refreshPriceOnUpdate,$scope.refreshPriceOnUpdate?$scope.deletePriceRefreshCookie():$scope.setPriceRefreshCookie()},$scope.isInFileMaker=function(){return-1<window.location.search.toLowerCase().indexOf("mode=filemaker")},$scope.isInFileMaker()?$scope.inFileMaker=!0:$scope.inFileMaker=!1,$scope.updateWithoutRefreshSent=function(){$scope.priceNeedsRefreshing=!0,$scope.$$phase||$scope.$digest()},$scope.refreshPrice=function(){$scope.priceNeedsRefreshing=!1,$scope.SendBulkQuoteUpdate($scope.ApiQuote.id,[{field:"PriceNote",oldValue:"",newValue:""}],function(){$scope.priceNeedsRefreshing=!1,$scope.$$phase||$scope.$digest()},[],!0)},$scope.setPriceRefreshFromCookies=function(){var cookie=$scope.getCookie("RefreshPrice");$scope.refreshPriceOnUpdate=!cookie,$scope.$$phase||$scope.$digest()},$scope.setPriceRefreshCookie=function(){$scope.getCookie("RefreshPrice")||$scope.setCookie("RefreshPrice",!0,3650)},$scope.deletePriceRefreshCookie=function(){$scope.eraseCookie("RefreshPrice")},$scope.setCookie=function(name,value,days){var date,expires="";days&&((date=new Date).setTime(date.getTime()+24*days*60*60*1e3),expires="; expires="+date.toUTCString()),document.cookie=name+"="+(value||"")+expires+"; path=/"},$scope.getCookie=function(name){for(var nameEQ=name+"=",ca=document.cookie.split(";"),i=0;i<ca.length;i++){for(var c=ca[i];" "==c.charAt(0);)c=c.substring(1,c.length);if(0==c.indexOf(nameEQ))return c.substring(nameEQ.length,c.length)}return null},$scope.eraseCookie=function(name){document.cookie=name+"=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"},$scope.setPriceRefreshFromCookies(),$scope.refreshFragments=function(){var script,script_id="optimocha_loaded_wc_cart_fragments";document.getElementById(script_id)?jQuery(document.body).trigger("wc_fragment_refresh"):((script=document.createElement("script")).id=script_id,script.src="/wp-content/plugins/woocommerce/assets/js/frontend/cart-fragments.min.js",script.async=!0,document.head.appendChild(script),setTimeout(function(){jQuery(document.body).trigger("wc_fragment_refresh")},100))},$scope.eraseCookie=function(name){document.cookie=name+"=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"},$scope.addToBasket=function(){return $scope.removeAddToBasketNotifications(),new Promise(function(res,rej){var err=$scope.findAddToBasketError();if(err)$scope.showMiniPopup(err);else if(window.scrollTo({top:0,behavior:"smooth"}),$scope.priceLoading=!0,wordpress){let formData=new FormData;formData.append("action","print_prices_add_to_cart"),formData.append("priceNet",$scope.IndexedChoiceData["57-Price Information"].specificationData.PriceNetTotal),formData.append("totalQuantity",$scope.TotalQuantity()),formData.append("bpProductId",localProductId),formData.append("quoteId",$scope.ApiQuote.id),$scope.postFormData("/wp-admin/admin-ajax.php",formData).then(function(variationId){$scope.refreshFragments(),$scope.addToBasketComplete=!0,$scope.addSpecificationToBasket($scope.ApiQuote.id,variationId),$scope.loading=!1,$scope.addToBasketLoading=!1,$scope.priceLoading=!1,$scope.checkForDuplicateQuoteAndAddToBasketComplete()}),$scope.duplicateQuote()}else ajaxService.getRequest("quote/add-to-basket/"+quoteId,null,function(response){var fullSpec=response.internalSpecification,response=response.externalSpecification,response={quoteId:$scope.ApiQuote.id,specification:response,totalQuantity:$scope.TotalQuantity(),unitPrice:$scope.IndexedChoiceData["57-Price Information"].specificationData.PriceNetTotal,productId:$scope.ProductDefault.id,fullSpec:fullSpec,priceNet:$scope.IndexedChoiceData["57-Price Information"].specificationData.PriceNetTotal,priceGross:$scope.IndexedChoiceData["57-Price Information"].specificationData.PriceGrossTotal};if("internal"==$scope.userType)return res(response),console.log("Cannot add to cart on internal site, debug data printed below"),void console.log(response);jQuery.ajax({type:"POST",url:"/index.php?option=com_cddcart&controller=product&view=product&task=printingpriceaddtocart&format=json",data:"quoteId="+response.quoteId+"&itemId="+localProductId+"&totalQuantity="+response.totalQuantity+"&unitPrice="+response.unitPrice+"&productId="+response.productId+"&specification="+JSON.stringify(response.specification)+"&fullSpec="+JSON.stringify(response.fullSpec),success:function(msg){updateBasket(),notifyMe("Success",msg,"success"),location.reload()}}),$scope.$digest()})})},$scope.addToBasketComplete=!1,$scope.newQuoteId=null,$scope.duplicateQuote=function(){ajaxService.get("quote/duplicate/"+$scope.ApiQuote.id,function(response){$scope.newQuoteId=response.id,$scope.checkForDuplicateQuoteAndAddToBasketComplete()}.bind(this),function(){})},$scope.checkForDuplicateQuoteAndAddToBasketComplete=function(){$scope.addToBasketComplete&&$scope.newQuoteId&&($scope.updateQuoteId($scope.newQuoteId),$scope.wordPressNotify("Added to basket",!0),$scope.addToBasketComplete=!1,$scope.newQuoteId=null)},$scope.wordPressNotify=function(notification,viewBasketOption){$scope.removeAddToBasketNotifications();let wrappers=document.getElementsByClassName("woocommerce-notices-wrapper");for(let i=0;i<wrappers.length;i++){let html='<div class="woocommerce-message printprice-add-to-basket-notification" role="alert">';viewBasketOption&&(-1<window.location.host.toLowerCase().indexOf("rollerbannersuk")?html+='<a href="/cart/" class="button wc-forward">View basket</a>':html+='<a href="/basket/" class="button wc-forward">View basket</a>'),html+=notification+"</div>",wrappers[i].innerHTML+=html}},$scope.removeAddToBasketNotifications=function(){let existingAddedToBasketNotification=document.getElementsByClassName("printprice-add-to-basket-notification");for(let i=0;i<existingAddedToBasketNotification.length;i++)existingAddedToBasketNotification[i].remove()},$scope.wordPressWarning=function(notification){let existingAddedToBasketNotification=document.getElementsByClassName("printprice-add-to-basket-warning");for(let i=0;i<existingAddedToBasketNotification.length;i++)existingAddedToBasketNotification[i].remove();let wrappers=document.getElementsByClassName("woocommerce-notices-wrapper");for(let i=0;i<wrappers.length;i++){var html='<div class="woocommerce-warning printprice-add-to-basket-warning" role="alert">';html+=notification+"</div>",wrappers[i].innerHTML+=html}},$scope.updateQuoteId=function(newQuoteId){$scope.quoteId=newQuoteId,quoteId=newQuoteId,$scope.ApiQuote.id=quoteId,$scope.insertAllReadouts(),$scope.finishings&&$scope.finishings.forEach(function(f){f.quoteId=newQuoteId}),$scope.Ncr&&$scope.Ncr.forEach(function(f){f.quoteId=newQuoteId}),$scope.Quantity&&$scope.Quantity.forEach(function(f){f.quoteId=newQuoteId}),$scope.fittings&&$scope.fittings.forEach(function(f){f.quoteId=newQuoteId}),$scope.covers&&$scope.covers.forEach(function(f){f.quoteId=newQuoteId}),$scope.zFold&&($scope.zFold.quoteId=newQuoteId),$scope.$$phase||$scope.$digest()},$scope.addSpecificationToBasket=function(quoteId,variationId){ajaxService.getRequest("quote/add-to-basket/"+quoteId,null,function(response){var key,fullSpec=response.internalSpecification,response={specification:response.externalSpecification,unitPrice:$scope.IndexedChoiceData["57-Price Information"].specificationData.PriceNetTotal,productId:$scope.ProductDefault.id,fullSpec:fullSpec,priceGross:$scope.IndexedChoiceData["57-Price Information"].specificationData.PriceGrossTotal};let formData=new FormData,spec=(formData.append("action","print_prices_add_specification_to_cart"),formData.append("priceNet",$scope.IndexedChoiceData["57-Price Information"].specificationData.PriceNetTotal),formData.append("totalQuantity",$scope.TotalQuantity()),response.specification);for(key in spec)spec.hasOwnProperty(key)&&formData.append(key,spec[key]);formData.append("priceGross",response.priceGross),formData.append("variationId",variationId),$scope.postFormData("/wp-admin/admin-ajax.php",formData).then(function(){$scope.refreshFragments()})})},$scope.createInputElement=function(name,value){let input=document.createElement("INPUT");return input.name=name,input.type="hidden",input.value=value,input},$scope.postFormData=function(_url,_formData){return new Promise(function(resolve,reject){var url=(url=_url).replaceAll(" ","%20"),xhr=new XMLHttpRequest;xhr.open("POST",url,!0),xhr.setRequestHeader("QuoteAccessKey",$scope.quoteAccessKey),xhr.setRequestHeader("QuoteId",$scope.ApiQuote.id),xhr.setRequestHeader("accept","application/json"),xhr.onreadystatechange=function(){if(4!==xhr.readyState||200!==xhr.status&&302!==xhr.status){if(4===xhr.readyState){var error=xhr.responseText;try{error=JSON.parse(error)}catch(e){}reject(error)}}else resolve(xhr.responseText)},xhr.send(_formData)})},$scope.addToBasketFrontEndValidation=function(){if($scope.returnDieCutObjectNoCreate()&&$scope.returnDieCutObjectNoCreate().finishingId){if(!$scope.returnDieCutObjectNoCreate())return"Please enter die cut data";if(!$scope.returnDieCutObjectNoCreate().finishingId)return"Please enter a die cut complexity"}return null},$scope.findAddToBasketError=function(){if($scope.quoteDataSigns){let signIdToUse=null;if("undefined"!=typeof signId?signIdToUse=signId:-1<window.location.search.toLowerCase().indexOf("signid=")&&(signIdToUse=Number($scope.getUrlParameter("signId"))),void 0!==signIdToUse&&signIdToUse){var quantity=$scope.TotalQuantity();if(!quantity||quantity<1)return"Add at least one product to continue"}}quantity=$scope.findSizeOnMaterialError();if(quantity)return quantity;quantity=$scope.findSizeError();if(quantity)return quantity;quantity=$scope.findMinimumSideError();if(quantity)return quantity;quantity=$scope.getPagesInterfaceError();return quantity||!1},$scope.getUrlParameter=function(reference){const urlParams=new URLSearchParams(window.location.search);return urlParams.get(reference)},$scope.findMinimumSideError=function(){var minimumSide=$scope.ProductDefault.minimumSideLengthMm;return!!minimumSide&&($scope.getSmallSideMm()<minimumSide&&"Minimum side length is "+minimumSide+"mm, cannot add to basket")},$scope.findSizeOnMaterialError=function(){if($scope.IndexedSpecificationInterfaces[79].displayed)return!1;if(!$scope.IndexedSpecificationInterfaces[7].displayed)return!1;var materials=$scope.IndexedChoiceData["7-Material"];if(!materials)return!1;if(!materials.length)return!1;let fittingMaterial=!1;for(let i=0;i<materials.length;i++){var material=materials[i];$scope.checkIfFitsOnMaterial(material)&&(fittingMaterial=!0)}return!fittingMaterial&&"This size does not work on any material, please adjust the size and try again"},$scope.findSizeError=function(){return $scope.customSizeError?"Invalid custom size, please adjust and try again":$scope.CustomSizeErrorMin?"Custom size is too small, cannot add to basket":!!$scope.CustomSizeErrorMax&&"Custom size is too large, cannot add to basket"},$scope.warn=function(title,content){$scope.setNotification("warn",title,content)},$scope.alert=function(title,content){$scope.setNotification("alert",title,content)},$scope.success=function(title,content){$scope.setNotification("success",title,content)},$scope.notification=!1,$scope.notificationType=null,$scope.notificationTitle=null,$scope.notificationContent=null,$scope.popupOpen=!1,$scope.customPopup=!1,$scope.popupData=null,$scope.closePopup=function(){$scope.popupOpen=!1,$scope.notification=!1},$scope.closePopupConditional=function(event){"popup"==event.target.classList[0]&&"editVersion"!=$scope.customPopup&&$scope.closePopup()},$scope.setNotification=function(type,title,content){$scope.popupOpen=!0,$scope.notification=!0,$scope.notificationType=type,$scope.notificationTitle=title,$scope.notificationContent=content},$scope.ShowCustomPopup=function(popupName,data){$scope.popupOpen=!0,$scope.customPopup=popupName,$scope.popupData=data},$scope.priceCalculate=function(){$scope.ShowCustomPopup("priceCalculation",null),$scope.PriceBreakdown=null,ajaxService.getRequest("quote/data/price/"+quoteId,null,function(response,httpCode,optionalData){$scope.PriceBreakdown=response,$scope.$$phase||$scope.$digest()})},$scope.newPriceCalculate=function(){$scope.ShowCustomPopup("priceCalculation",null),$scope.PriceBreakdown=null,ajaxService.getRequest("quote/data/new-price/"+quoteId,null,function(response,httpCode,optionalData){$scope.PriceBreakdown=response,$scope.$$phase||$scope.$digest()})},$scope.showSpec=function(){$scope.quoteSpecification=null,$scope.specificationError=!1,$scope.specificationErrorText="",$scope.ShowCustomPopup("specification",null),ajaxService.getRequest("quote/spec/"+quoteId+"/false",null,function(response,httpCode,optionalData){$scope.quoteSpecification=response,$scope.$$phase||$scope.$digest()})},$scope.multiItemSpecifications=[],$scope.getAllSpecifications=function(){$scope.quoteSpecification=null,$scope.specificationError=!1,$scope.specificationErrorText="",$scope.ShowCustomPopup("multispecification",null),ajaxService.getRequest("multi-item-quote/specification/"+quoteId,null,function(response,httpCode,optionalData){$scope.multiItemSpecifications=response,$scope.$$phase||$scope.$digest()})},$scope.toIgnoreSpecificationAttributes=["productPreviewImage","note","$$hashKey","multipleItemQuote"],$scope.getSpecificationAttributes=function(specification){let attrs=[];for(var key in specification)specification.hasOwnProperty(key)&&-1==$scope.toIgnoreSpecificationAttributes.indexOf(key)&&attrs.push(key);return attrs},$scope.specificationAttributeToKey=function(attribute){let name=attribute.replace(/([a-z])([A-Z])/g,"$1 $2");return name.charAt(0).toUpperCase()+name.slice(1)},$scope.formatSpecificationContent=function(content){return content=content.toString().replace(/(?:\r\n|\r|\n)/g,"<br>"),$sce.trustAsHtml(content)},$scope.print=function(){window.open("./API/GET-print.php?quoteId="+$scope.ApiQuote.id,"_blank")},$scope.displayPrintData=function(data){data.quote=$scope.IndexedChoiceData["57-Price Information"],document.getElementById("printParameter").value=JSON.stringify(data),document.getElementById("hiddenPrintParameterForm").submit()},$scope.getPrintData=function(){return new Promise(function(res,rej){let spec,price;$scope.getSpecForPrint().then(function(specResponse){spec=specResponse,$scope.getPriceForPrint().then(function(priceResponse){price=priceResponse,res({spec:spec,price:price})})})})},$scope.getSpecForPrint=function(){return new Promise(function(res,rej){ajaxService.getRequest("quote/spec/"+quoteId+"/true",null,function(response,httpCode,optionalData){res(response)})})},$scope.getPriceForPrint=function(){return new Promise(function(res,rej){ajaxService.getRequest("quote/data/price/"+quoteId,null,function(response,httpCode,optionalData){res(response)})})},$scope.pagesChangedUpdateHandle=null,$scope.pagesCountChanged=function(completed){clearTimeout($scope.pagesChangedUpdateHandle);let pages=2;$scope.IndexedChoiceData["9-Page Count"]&&(pages=$scope.IndexedChoiceData["9-Page Count"].valueId);var pagesUpdate={newValue:pages,oldValue:null,field:"PagesCount"},leavesUpdate={newValue:pages/2,oldValue:null,field:"LeavesCount"};$scope.pagesChangedUpdateHandle=setTimeout($scope.pagesChangedPostTimeout,1e3,$scope.ApiQuote.id,[pagesUpdate,leavesUpdate],completed)},$scope.leavesCountChanged=function(completed){clearTimeout($scope.pagesChangedUpdateHandle);let leaves=1;$scope.IndexedChoiceData["63-Leaves Count"]&&(leaves=$scope.IndexedChoiceData["63-Leaves Count"].valueId);var pagesUpdate={newValue:2*leaves,oldValue:null,field:"PagesCount"},leavesUpdate={newValue:leaves,oldValue:null,field:"LeavesCount"};$scope.pagesChangedUpdateHandle=setTimeout($scope.pagesChangedPostTimeout,1e3,$scope.ApiQuote.id,[pagesUpdate,leavesUpdate],completed)},$scope.pagesChangedPostTimeout=function(quoteId,updateArray,completed){$scope.SendBulkQuoteUpdate(quoteId,updateArray,completed,null)},$scope.getLeaves=function(){return"2"==$scope.IndexedChoiceData["22-Single Double Sided - Print Sides"].valueDisplay?$scope.IndexedChoiceData["9-Page Count"].valueId/2:$scope.IndexedChoiceData["9-Page Count"].valueId},$scope.getThickness=function(){return $scope.getThicknessMm()+"mm"},$scope.getThicknessMm=function(){let error=!1,thickness=0;try{var pages=$scope.IndexedChoiceData["9-Page Count"].valueId,pageThickness=JSON.parse($scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation).thickness;thickness=Math.round(pages/2*pageThickness*100)/100}catch(e){error=!0}return error?"":thickness},$scope.getWeight=function(){let error=!1,weight=0;try{var pages=$scope.IndexedChoiceData["9-Page Count"].valueId,pageWeightGsm=JSON.parse($scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation).weight,areaMm=$scope.getArea();pageWeight=pageWeightGsm*(areaMm/1e6),weight=Math.round(pages/2*pageWeight)}catch(e){error=!0}return error?"":weight+"g"},$scope.getLeavesThickness=function(){let error=!1,thickness=0;try{var leaves=$scope.IndexedChoiceData["63-Leaves Count"].valueId,pageThickness=JSON.parse($scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation).thickness;thickness=Math.round(leaves*pageThickness*100)/100}catch(e){error=!0}return error?"":thickness+"mm"},$scope.getLeavesWeight=function(){let error=!1,weight=0;try{var leaves=$scope.IndexedChoiceData["63-Leaves Count"].valueId,pageWeightGsm=JSON.parse($scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation).weight,areaMm=$scope.getArea();pageWeight=pageWeightGsm*(areaMm/1e6),weight=Math.round(leaves*pageWeight)}catch(e){error=!0}return error?"":weight+"g"},$scope.getArea=function(){let customWidth=$scope.CustomSizeValues.width,customHeight=$scope.CustomSizeValues.height;var customUnit;return!customWidth&&$scope.ApiQuote.customPrintSize&&$scope.ApiQuote.customPrintWidthMm&&(customWidth=$scope.ApiQuote.customPrintWidthMm),!customHeight&&$scope.ApiQuote.customPrintSize&&$scope.ApiQuote.customPrintHeightMm&&(customHeight=$scope.ApiQuote.customPrintHeightMm),customWidth&&customHeight?(customUnit=$scope.CurrentCustomSizeUnit,$scope.ConvertToMm(customWidth,customUnit)*$scope.ConvertToMm(customHeight,customUnit)):JSON.parse($scope.IndexedChoiceData["5-Print Size"].selected.ChoiceFurtherInformation).area},$scope.toggleForceB2=function(event){$scope.IndexedChoiceData["13-Printing Press"].original.valueDisplay?($scope.IndexedChoiceData["13-Printing Press"].original.valueDisplay=!1,$scope.SendQuoteUpdate($scope.ApiQuote.id,"ForceB2",0,!1,"")):($scope.IndexedChoiceData["13-Printing Press"].original.valueDisplay=!0,$scope.SendQuoteUpdate($scope.ApiQuote.id,"ForceB2",0,!0,""))},$scope.checkLaminationAllowedOnMaterialWeight=function(){return $scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation||console.error("No material data available. Please check there are some materials linked to this product/product type, and ensure they are between the minimum and maximum material weight for the product/product type."),!(parseInt(JSON.parse($scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation).weight)<$scope.getValidationValueByReference("lamination-min"))},$scope.checkLaminationAllowedOnMaterial=function(){return $scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation||console.error("No material data available. Please check there are some materials linked to this product/product type, and ensure they are between the minimum and maximum material weight for the product/product type."),"No lamination"!==$scope.IndexedChoiceData["7-Material"].selected.Note},$scope.validateLaminationOnNewMaterial=function(){try{$scope.fData.lamination&&($scope.checkLaminationAllowedOnMaterial()||($scope.fData.lamination.finishingId=138,setTimeout($scope.updateFinishings,200)))}catch(e){console.error(e)}},$scope.checkLaminationAllowedOnCoverMaterialWeight=function(cover){if($scope.ApiQuote.selfCover)return $scope.checkLaminationAllowedOnMaterialWeight();cover=$scope.getCoverMaterial(cover);return!cover||!(parseInt(JSON.parse(cover.ChoiceFurtherInformation).weight)<$scope.getValidationValueByReference("lamination-min"))},$scope.validateCoverLaminationOnChange=function(cover){!$scope.checkLaminationAllowedOnCoverMaterialWeight(cover)&&cover.laminationId&&(cover.laminationId=null,$scope.coverChanged())},$scope.getCoverMaterial=function(cover){let coverMaterialId=cover.materialId,coverMaterials=$scope.IndexedChoiceData["10-Material"];return coverMaterials?coverMaterials.find(function(f){return f.ChoiceValueId==coverMaterialId}):null},$scope.checkLaminationAllowedOnSize=function(){return!($scope.getSmallSideMm()>$scope.getLaminationMaxShortSide())},$scope.getLaminationMaxShortSide=function(){return $scope.IndexedChoiceData["26-Lamination"]&&$scope.IndexedChoiceData["26-Lamination"].original&&$scope.IndexedChoiceData["26-Lamination"].original.validationMinimumValue||1e9},$scope.validateLaminationSize=function(){var selectedLaminationName=$scope.returnLamination($scope.fData.lamination,$scope.IndexedChoiceData["26-Lamination"]),allowed=$scope.checkLaminationAllowedOnSize();console.log(selectedLaminationName),console.log(allowed),"No Lamination"==selectedLaminationName||allowed||setTimeout($scope.disableLamination,300)},$scope.disableLamination=function(){var options=$scope.filterLaminationChoices($scope.IndexedChoiceData["26-Lamination"],!0);$scope.setLaminationType($scope.fData.lamination,$scope.ApiQuote.id,options[0],"Lamination")},$scope.checkScoringAllowedOnMaterialWeight=function(){return!(parseInt(JSON.parse($scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation).weight)<$scope.getValidationValueByReference("scoring-min"))},$scope.checkSpotUVAllowedOnMaterialWeight=function(){return!(parseInt(JSON.parse($scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation).weight)<$scope.getValidationValueByReference("spot-uv-min"))},$scope.checkFoilingAllowedOnMaterialWeight=function(){return!(parseInt(JSON.parse($scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation).weight)<$scope.getValidationValueByReference("foiling-min"))},$scope.validateFoiling=function(){try{$scope.fData.foilOne&&!$scope.checkFoilingAllowedOnMaterialWeight()&&($scope.foilingOff(),$scope.showMiniPopup("Foiling removed, it cannot be applied below "+$scope.getValidationValueByReference("foiling-min")+"gsm material"))}catch(e){}},$scope.finishingValidationRules=[],$scope.setValidationRules=function(validationRules){$scope.finishingValidationRules=validationRules},$scope.getValidationValueByReference=function(reference){var search=$scope.finishingValidationRules.filter(f=>f.reference==reference);return search.length?search[0].value:0},$scope.materialWarningCheck=function(){if(!$scope.IndexedSpecificationInterfaces[7].displayed)return!1;var longside=$scope.getLargeSideMm(),shortside=$scope.getSmallSideMm(),maxDimension=$scope.getMaterialMaxWidth();Math.ceil(shortside/maxDimension);if($scope.ProductDefault.coverHasVariableSpineWidth)if(353<longside||250<shortside)return!($scope.customSizeError="The max size for this product is 353mm x 250mm");return($scope.ApiQuote.largestAvailableUnitLongside||$scope.ApiQuote.largestAvailableUnitShortside)&&(longside>$scope.ApiQuote.largestAvailableUnitLongside||shortside>$scope.ApiQuote.largestAvailableUnitShortside)&&($scope.customSizeError="The max size for this product is "+$scope.ApiQuote.largestAvailableUnitLongside+"mm x "+$scope.ApiQuote.largestAvailableUnitShortside+"mm"),!1},$scope.getSplitCount=function(){if(!$scope.IndexedChoiceData)return 1;if(!$scope.IndexedChoiceData["7-Material"])return 1;if(!$scope.ProductDefault.canBeSplitAcrossSheets&&!$scope.ProductDefault.canBeSplitOnLargeFormat)return 1;try{var shortside=$scope.getSmallSideMm(),longside=$scope.getLargeSideMm(),maxWidth=$scope.getMaterialMaxWidth(),maxLength=$scope.getMaterialMaxLength(),highestMaxMaterialDimension=Math.max(maxWidth,maxLength),lowestMaxMaterialDimension=Math.min(maxWidth,maxLength),pieces=Math.ceil(shortside/lowestMaxMaterialDimension)*Math.ceil(longside/highestMaxMaterialDimension),piecesAlternativeOrientation=Math.ceil(longside/lowestMaxMaterialDimension)*Math.ceil(shortside/highestMaxMaterialDimension);return Math.min(piecesAlternativeOrientation,pieces)}catch(e){return 1}},$scope.getMaterialMaxWidth=function(){return $scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation||($scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation=$scope.IndexedChoiceData["7-Material"].selected.choiceFurtherInformation),parseInt(JSON.parse($scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation).maximumWidth)},$scope.getMaterialMaxLength=function(){return $scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation||($scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation=$scope.IndexedChoiceData["7-Material"].selected.choiceFurtherInformation),parseInt(JSON.parse($scope.IndexedChoiceData["7-Material"].selected.ChoiceFurtherInformation).maximumLength)},$scope.fitsOnVariableDataPrinter=function(){var longside=$scope.getLargeSideMm(),shortside=$scope.getSmallSideMm();return!(480<longside||306<shortside)},$scope.setFullAssembly=function(newValue){$scope.ApiQuote.requiresFullAssembly!=newValue&&($scope.SendBulkQuoteUpdate($scope.ApiQuote.id,[{field:"RequiresFullAssembly",oldValue:null,newValue:newValue}]),$scope.ApiQuote.requiresFullAssembly=newValue)},$scope.setPriceSplitPriority=function(newValue){$scope.ApiQuote.forceCheapestSplitPrintingPrice!=newValue&&($scope.SendBulkQuoteUpdate($scope.ApiQuote.id,[{field:"ForceCheapestSplitPrintingPrice",oldValue:null,newValue:newValue}],function(){}),$scope.ApiQuote.forceCheapestSplitPrintingPrice=newValue)},$scope.boxUpdateTimeoutHandle={},$scope.boxDimensionChanged=function(fieldname,newValue){clearTimeout($scope.boxUpdateTimeoutHandle[fieldname]),$scope.boxUpdateTimeoutHandle[fieldname]=setTimeout($scope.SendBulkQuoteUpdate,800,$scope.ApiQuote.id,[{quoteId:$scope.ApiQuote.id,note:"",oldValue:null,newValue:newValue,quoteFieldName:fieldname}])},$scope.boxDimensionChangedFlatArea=function(){clearTimeout($scope.boxUpdateTimeoutHandle.flatArea);var width=$scope.tempBoxFlatAreaObject.customPrintWidthMm,height=$scope.tempBoxFlatAreaObject.customPrintHeightMm,unit=$scope.tempBoxFlatAreaUnits,width=$scope.ConvertToMm(width,unit),height=$scope.ConvertToMm(height,unit),unit=Math.min(width,height),width=Math.max(width,height),height=($scope.boxFlatAreaError="",707<unit&&($scope.boxFlatAreaError="The maximum short side is 707mm"),unit*width),minimumArea=$scope.ProductDefault.minimumAreaMm2;height<minimumArea&&($scope.boxFlatAreaError="This is too small to be printed (minimum area is "+minimumArea+"mm²)");13e3<width&&($scope.boxFlatAreaError="The maximum long side is 13m"),$scope.boxFlatAreaError||($scope.boxUpdateTimeoutHandle.flatArea=setTimeout($scope.SendBulkQuoteUpdate,800,$scope.ApiQuote.id,[{quoteId:$scope.ApiQuote.id,note:"",oldValue:null,newValue:width,quoteFieldName:"CustomPrintHeightMm"},{quoteId:$scope.ApiQuote.id,note:"",oldValue:null,newValue:unit,quoteFieldName:"CustomPrintWidthMm"}]))},$scope.pillowPackUpdateTimeoutHandle=null,$scope.pillowPackUpdateTimeoutTime=1e3,$scope.pillowPackMostRecentDimension=null,$scope.pillowPackMostRecentValue=null,$scope.SetPillowPackUpdateTimer=function(dimension,value){$scope.pillowPackMostRecentDimension=dimension,$scope.pillowPackMostRecentValue=value,clearTimeout($scope.pillowPackUpdateTimeoutHandle),$scope.pillowPackUpdateTimeoutHandle=setTimeout($scope.updatePillowPack,$scope.pillowPackUpdateTimeoutTime)},$scope.updatePillowPack=function(){$scope.validateBoxDimensions(),clearTimeout($scope.pillowPackUpdateTimeoutHandle),$scope.SendBulkQuoteUpdate($scope.ApiQuote.id,[{quoteId:$scope.ApiQuote.id,note:"",oldValue:null,newValue:$scope.ApiQuote.customPrintDepthMm,quoteFieldName:"CustomPrintDepthMm"},{quoteId:$scope.ApiQuote.id,note:"",oldValue:null,newValue:$scope.ApiQuote.customPrintWidthMm,quoteFieldName:"CustomPrintWidthMm"},{quoteId:$scope.ApiQuote.id,note:"",oldValue:null,newValue:$scope.ApiQuote.customPrintHeightMm,quoteFieldName:"CustomPrintHeightMm"}])},$scope.forceBollardWidthError=!1,$scope.forceBollardHeightError=!1,$scope.validateBollardCover=function(){250<$scope.ApiQuote.customPrintWidthMm&&($scope.ApiQuote.customPrintWidthMm=250,$scope.forceBollardWidthError=!0,setTimeout($scope.clearBollardWidthError,5e3)),1200<$scope.ApiQuote.customPrintHeightMm&&($scope.ApiQuote.customPrintHeightMm=1200,$scope.forceBollardHeightError=!0,setTimeout($scope.clearBollardHeightError,5e3))},$scope.clearBollardWidthError=function(){$scope.forceBollardWidthError=!1,$scope.$$phase||$scope.$digest()},$scope.clearBollardHeightError=function(){$scope.forceBollardHeightError=!1,$scope.$$phase||$scope.$digest()},$scope.selectBollardCoverShape=function(newValue){$scope.ApiQuote.productStyleShapeId!=newValue&&($scope.ApiQuote.productStyleShapeId=newValue,$scope.SendBulkQuoteUpdate($scope.ApiQuote.id,[{quoteId:$scope.ApiQuote.id,note:"",oldValue:null,newValue:newValue,quoteFieldName:"ProductStyleShapeId"},{quoteId:$scope.ApiQuote.id,note:"",oldValue:null,newValue:3==newValue?274:10,quoteFieldName:"MaterialId"}]))},$scope.setPillowPackFlapSize=function(inputWidth){let flap=inputWidth<70?12:inputWidth<80?14:inputWidth<90?16:inputWidth<100?18:20;return flap},$scope.setPillowPackThumbSize=function(inputHeight,inputWidth){let thumbSize=inputWidth<50&&inputHeight<15?0:inputWidth<50?15:inputHeight<15?0:inputHeight<18?15:inputHeight<20?18:20;return thumbSize},$scope.setPillowPackCutWidth=function(area){let cutWidth=54400<area?1.6:area<26400?.9:1;return cutWidth},$scope.setPillowPackFoldWidth=function(area){let foldWidth=54400<area?1.2:area<26400?.6:.75;return foldWidth},$scope.pillowPacksMinimumLength=40,$scope.pillowPacksMinimumWidth=40,$scope.pillowPacksMinimumHeight=15,$scope.pillowPacksErrorTimeoutHandle=null,$scope.pillowPacksErrorLength=!1,$scope.pillowPacksErrorWidth=!1,$scope.pillowPacksErrorHeight=!1,$scope.pillowPacksErrorHeightToWidth=!1,$scope.pillowPackErrorTimeoutLengthSeconds=2.5,$scope.pillowPackSvgHtml="",$scope.validateBoxDimensions=function(){let errorShown=!1;var width=$scope.ApiQuote.customPrintWidthMm,length=$scope.ApiQuote.customPrintDepthMm,height=$scope.ApiQuote.customPrintHeightMm;width<$scope.pillowPacksMinimumWidth&&($scope.ApiQuote.customPrintWidthMm=$scope.pillowPacksMinimumWidth,$scope.pillowPacksErrorWidth=!0,errorShown=!0),length<$scope.pillowPacksMinimumLength&&($scope.ApiQuote.customPrintDepthMm=$scope.pillowPacksMinimumLength,$scope.pillowPacksErrorLength=!0,errorShown=!0),height<$scope.pillowPacksMinimumHeight&&($scope.ApiQuote.customPrintHeightMm=$scope.pillowPacksMinimumHeight,$scope.pillowPacksErrorHeight=!0,errorShown=!0),.44*width<height&&($scope.ApiQuote.customPrintHeightMm=Math.floor(.44*width),$scope.pillowPacksErrorHeightToWidth=!0,errorShown=!0),errorShown&&(clearTimeout($scope.pillowPacksErrorTimeoutHandle),$scope.pillowPacksErrorTimeoutHandle=setTimeout($scope.clearBoxDimensionErrors,4e3*$scope.pillowPackErrorTimeoutLengthSeconds))},$scope.clearBoxDimensionErrors=function(){$scope.pillowPacksErrorLength=!1,$scope.pillowPacksErrorWidth=!1,$scope.pillowPacksErrorHeight=!1,$scope.pillowPacksErrorHeightToWidth=!1,$scope.$$phase||$scope.$digest()},$scope.createPillowPackSvg=function(){let width=$scope.ApiQuote.customPrintWidthMm,length=$scope.ApiQuote.customPrintDepthMm,height=$scope.ApiQuote.customPrintHeightMm;width<$scope.pillowPacksMinimumWidth&&(width=$scope.pillowPacksMinimumWidth),length<$scope.pillowPacksMinimumLength&&(length=$scope.pillowPacksMinimumLength),height<$scope.pillowPacksMinimumHeight&&(height=$scope.pillowPacksMinimumHeight),height>width/2&&(height=width/2);var thumbSize=$scope.setPillowPackThumbSize(height,width),flap=$scope.setPillowPackFlapSize(width),flatWidth=2*width+flap,flatHeight=length+height,viewBoxWidth=flatWidth+10,viewBoxHeight=flatHeight+10,area=flatWidth*flatHeight,cutWidth=$scope.setPillowPackCutWidth(area),area=$scope.setPillowPackFoldWidth(area),x2=5+width/2,x3=5+width,x4=x2+width,x5=x3+width,y2=5+height/2,y3=5+height,y4=5+length,y5=y2+length,y6=y3+length,centerX=.19661*width,edgeX=.11824*width,yUpDown=.31496*height,cx1=5+edgeX,cx2=x2-centerX,cx3=x2+centerX,cx4=x3-edgeX,cx5=x3+edgeX,cx6=x4-centerX,centerX=x4+centerX,edgeX=x5-edgeX,cy1=y2-yUpDown,cy2=y2+yUpDown,cy3=y5-yUpDown,yUpDown=y5+yUpDown,flpx=x5+flap;let flpTy=y2+flap,flpBy=y5-flap;var thirdSize=width/3,flap=(height>thirdSize&&(thirdSize=(height-thirdSize)/2,flpTy=y2+flap+thirdSize,flpBy=y5-flap-thirdSize),x2-thumbSize/2);let tthLy=5;thirdSize=x2+thumbSize/2;let tthRy=5,tthTopy=5+thumbSize/2;var tthcx1=flap,tthcx2=x2-thumbSize/3.63,tthcx3=x2+thumbSize/3.63,tthcx4=thirdSize;let tthcy1=tthTopy,tthcy2=5+thumbSize/3.63;height<20&&width<50&&0<thumbSize&&(tthLy+=1,tthRy+=1,tthTopy+=1,tthcy1+=1,tthcy2+=1);var bthLx=x2-thumbSize/2;let bthLy=y6;var bthRx=x2+thumbSize/2;let bthRy=y6,bthTopy=y6-thumbSize/2;var bthcx1=bthLx,bthcx2=x2-thumbSize/3.63,bthcx3=x2+thumbSize/3.63,bthcx4=bthRx;let bthcy1=bthTopy,bthcy2=y6-thumbSize/3.63;height<20&&width<50&&0<thumbSize&&(bthLy-=1,bthRy-=1,bthTopy-=1,bthcy1-=1,bthcy2-=1);$scope.pillowPackSvgHtml="<svg xmlns:xlink='http://www.w3.org/1999/xlink' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 "+viewBoxWidth+" "+viewBoxHeight+"' class='pillow-pack-svg'>",$scope.pillowPackSvgHtml+="<title>Pillow Pack</title>",$scope.pillowPackSvgHtml+="<defs>",$scope.pillowPackSvgHtml+="<style type='text/css'>",$scope.pillowPackSvgHtml+="text { font-family:  -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Segoe UI Symbol'; font-weight: 400; }",$scope.pillowPackSvgHtml+="</style></defs>",$scope.pillowPackSvgHtml+="<g id='page1' transform='translate(0,0)'>",$scope.pillowPackSvgHtml+="<g id='page1-fold' class='fold' fill='none' stroke='#00adee' stroke-width='"+area+"' stroke-dasharray='4' >",$scope.pillowPackSvgHtml+="<path id='page1-fold-curves-top' d='",$scope.pillowPackSvgHtml+=" M 5 "+y2+"  ",$scope.pillowPackSvgHtml+=" C "+cx1+" "+cy2+" "+cx2+" "+y3+" "+x2+" "+y3+" ",$scope.pillowPackSvgHtml+=" L "+x2+" "+y3,$scope.pillowPackSvgHtml+=" C "+cx3+" "+y3+" "+cx4+" "+cy2+" "+x3+" "+y2,$scope.pillowPackSvgHtml+=" L "+x3+" "+y2,$scope.pillowPackSvgHtml+=" C "+cx5+" "+cy2+" "+cx6+" "+y3+" "+x4+" "+y3,$scope.pillowPackSvgHtml+=" L "+x4+" "+y3+" ",$scope.pillowPackSvgHtml+=" C "+centerX+" "+y3+" "+edgeX+" "+cy2+" "+x5+" "+y2+"'/>",$scope.pillowPackSvgHtml+="<path id='page1-fold-curves-bottom' d='",$scope.pillowPackSvgHtml+=" M 5 "+y5+"  ",$scope.pillowPackSvgHtml+=" C "+cx1+" "+cy3+" "+cx2+" "+y4+" "+x2+" "+y4+" ",$scope.pillowPackSvgHtml+=" L "+x2+" "+y4,$scope.pillowPackSvgHtml+=" C "+cx3+" "+y4+" "+cx4+" "+cy3+" "+x3+" "+y5,$scope.pillowPackSvgHtml+=" L "+x3+" "+y5,$scope.pillowPackSvgHtml+=" C "+cx5+" "+cy3+" "+cx6+" "+y4+" "+x4+" "+y4,$scope.pillowPackSvgHtml+=" L "+x4+" "+y4+" ",$scope.pillowPackSvgHtml+=" C "+centerX+" "+y4+" "+edgeX+" "+cy3+" "+x5+" "+y5+"'/>",$scope.pillowPackSvgHtml+="<path id='page1-fold-glue' d='M "+x5+" "+y2+"    L    "+x5+" "+y5+"'/>",$scope.pillowPackSvgHtml+="<path id='page1-fold-middle' d='M "+x3+" "+y2+"    L    "+x3+" "+y5+"'/>",$scope.pillowPackSvgHtml+="</g>",$scope.pillowPackSvgHtml+="<g id='page1-cut' class='cut' fill='none' stroke='#d41a5a' stroke-width='"+cutWidth+"' >",$scope.pillowPackSvgHtml+="<path id='page1-cut' d='",$scope.pillowPackSvgHtml+=" M 5 "+y2+" ",$scope.pillowPackSvgHtml+=" C "+cx1+" "+cy1+" "+cx2+" 5 "+flap+" "+tthLy,$scope.pillowPackSvgHtml+=" L "+flap+" "+tthLy,$scope.pillowPackSvgHtml+=" C "+tthcx1+" "+tthcy2+" "+tthcx2+" "+tthcy1+" "+x2+" "+tthTopy,$scope.pillowPackSvgHtml+=" L "+x2+" "+tthTopy,$scope.pillowPackSvgHtml+=" C "+tthcx3+" "+tthcy1+" "+tthcx4+" "+tthcy2+" "+thirdSize+" "+tthRy,$scope.pillowPackSvgHtml+=" L "+thirdSize+" "+tthRy,$scope.pillowPackSvgHtml+=" C "+cx3+" 5 "+cx4+" "+cy1+" "+x3+" "+y2,$scope.pillowPackSvgHtml+=" L "+x3+" "+y2,$scope.pillowPackSvgHtml+=" C "+cx5+" "+cy1+" "+cx6+" 5 "+x4+" 5",$scope.pillowPackSvgHtml+=" L "+x4+" 5 ",$scope.pillowPackSvgHtml+=" C "+centerX+" 5 "+edgeX+" "+cy1+" "+x5+" "+y2,$scope.pillowPackSvgHtml+=" L "+flpx+" "+flpTy,$scope.pillowPackSvgHtml+=" L "+flpx+" "+flpBy,$scope.pillowPackSvgHtml+=" L "+x5+" "+y5,$scope.pillowPackSvgHtml+=" C "+edgeX+" "+yUpDown+" "+centerX+" "+y6+" "+x4+" "+y6,$scope.pillowPackSvgHtml+=" L "+x4+" "+y6,$scope.pillowPackSvgHtml+=" C "+cx6+" "+y6+" "+cx5+" "+yUpDown+" "+x3+" "+y5,$scope.pillowPackSvgHtml+=" L "+x3+" "+y5,$scope.pillowPackSvgHtml+=" C "+cx4+" "+yUpDown+" "+cx3+" "+y6+" "+bthRx+" "+bthRy,$scope.pillowPackSvgHtml+=" L "+bthRx+" "+bthRy,$scope.pillowPackSvgHtml+=" C "+bthcx4+" "+bthcy2+" "+bthcx3+" "+bthcy1+" "+x2+" "+bthTopy,$scope.pillowPackSvgHtml+=" L "+x2+" "+bthTopy,$scope.pillowPackSvgHtml+=" C "+bthcx2+" "+bthcy1+" "+bthcx1+" "+bthcy2+" "+bthLx+" "+bthLy,$scope.pillowPackSvgHtml+=" L "+bthLx+" "+bthLy,$scope.pillowPackSvgHtml+=" C "+cx2+" "+y6+" "+cx1+" "+yUpDown+" 5 "+y5,$scope.pillowPackSvgHtml+=" L 5 "+y2+"  Z '/>",$scope.pillowPackSvgHtml+="</g>",$scope.pillowPackSvgHtml+="</g>",$scope.pillowPackSvgHtml+="</svg>",$scope.pillowPackSvgHtml+="<input type='hidden' id='flat-height' name='flat-height' value='"+flatHeight+"' />",$scope.pillowPackSvgHtml+="<input type='hidden' id='flat-width' name='flat-width' value='"+flatWidth+"' />",$scope.displayPillowPackRender()},$scope.downloadPillowPackTemplate=function(){let width=$scope.ApiQuote.customPrintWidthMm,length=$scope.ApiQuote.customPrintDepthMm,height=$scope.ApiQuote.customPrintHeightMm;width<$scope.pillowPacksMinimumWidth&&(width=$scope.pillowPacksMinimumWidth),length<$scope.pillowPacksMinimumLength&&(length=$scope.pillowPacksMinimumLength),height<$scope.pillowPacksMinimumHeight&&(height=$scope.pillowPacksMinimumHeight),window.open("https://printprice.co.uk/php/pillowPackPdfGenerator.php?x="+width+"&y="+height+"&z="+length,"_blank")},$scope.bollardCoverMinimumHeight=0,$scope.bollardCoverMinimumDiameter=0,$scope.downloadBollardCoverTemplate=function(){let diameter=$scope.ApiQuote.customPrintWidthMm,height=$scope.ApiQuote.customPrintHeightMm;var style=1==$scope.ApiQuote.productStyleShapeId?"Triangle":2==$scope.ApiQuote.productStyleShapeId?"Square":"SlipOver";diameter<$scope.bollardCoverMinimumDiameter&&(diameter=$scope.bollardCoverMinimumDiameter),height<$scope.bollardCoverMinimumHeight&&(height=$scope.bollardCoverMinimumHeight),window.open("https://printprice.co.uk/php/bollardCoverPdfGenerator.php?x="+diameter+"&y="+height+"&style="+style,"_blank")},$scope.getPillowPackDisclaimerLength=function(){let length=$scope.ApiQuote.customPrintDepthMm,height=$scope.ApiQuote.customPrintHeightMm;return length<$scope.pillowPacksMinimumLength&&(length=$scope.pillowPacksMinimumLength),height<$scope.pillowPacksMinimumHeight&&(height=$scope.pillowPacksMinimumHeight),Math.abs(length-height)},$scope.getPillowPackDisclaimerWidth=function(){let width=$scope.ApiQuote.customPrintWidthMm,height=$scope.ApiQuote.customPrintHeightMm;return width<$scope.pillowPacksMinimumWidth&&(width=$scope.pillowPacksMinimumWidth),height<$scope.pillowPacksMinimumHeight&&(height=$scope.pillowPacksMinimumHeight),width-height/5},$scope.getPillowPackDisclaimerHeight=function(){let height=$scope.ApiQuote.customPrintHeightMm;return height<$scope.pillowPacksMinimumHeight&&(height=$scope.pillowPacksMinimumHeight),height},$scope.displayPillowPackRender=function(){let eles=document.getElementsByClassName("pillowPackSvgRender");for(let i=0;i<eles.length;i++)eles[i].innerHTML=$scope.pillowPackSvgHtml},$scope.getFlatPanelBollardCoverWidth=function(){var diameter=$scope.ApiQuote.customPrintWidthMm;return 1==$scope.ApiQuote.productStyleShapeId?$scope.getTriangleBollardCoverPanelWidth(diameter):2==$scope.ApiQuote.productStyleShapeId?$scope.getSquareBollardCoverPanelWidth(diameter):3==$scope.ApiQuote.productStyleShapeId?$scope.getSlipOverBollardCoverPanelWidth(diameter):void 0},$scope.getTriangleBollardCoverPanelWidth=function(diameter){return Math.round((diameter+8)/.577)},$scope.getSquareBollardCoverPanelWidth=function(diameter){return diameter+8},$scope.getSlipOverBollardCoverPanelWidth=function(diameter){let panelWidth=diameter<=100?300:diameter<=150?400:diameter<=200?500:600;return panelWidth},$scope.getFlatPanelBollardCoverHeight=function(){return $scope.ApiQuote.customPrintHeightMm},$scope.isString=function(vari){return"string"==typeof vari},$scope.numberToArray=function(number){let array=[];for(let i=0;i<number;i++)array.push(i+1);return array},$scope.orderByChoiceDisplayName=function(arr){return arr.sort(function(a,b){return a.ChoiceDisplayName>b.ChoiceDisplayName?1:a.ChoiceDisplayName<b.ChoiceDisplayName?-1:0})},$scope.boxSleeveOpened=function(){setTimeout($scope.CalculateSize,200),setTimeout($scope.DrawCube,200)},$scope.uploadModels=[],$scope.boxSleevePaperSize="",$scope.boxSleeveValidationString="",$scope.CalculateSize=function(){var heightInput,depthInput,sleeveInput;$scope.ApiQuote&&(heightInput=$scope.ApiQuote.customPrintHeightMm,$scope.ApiQuote.customBoxWidth,depthInput=$scope.ApiQuote.customPrintDepthMm,sleeveInput=$scope.ApiQuote.customPrintWidthMm,heightInput=parseInt(heightInput),depthInput=parseInt(depthInput),sleeveInput=parseInt(sleeveInput),$scope.boxSleevePaperSize=sleeveInput+"mm x "+(2*heightInput+2*depthInput+20)+"mm",$scope.$$phase||$scope.$digest(),$scope.validateBoxSleeve(heightInput,sleeveInput,depthInput))},$scope.validateBoxSleeve=function(height,width,depth){let validationString="",shortside=515,longSide=702;var readoutEle=document.getElementsByClassName("printPressReadout")[0];if(readoutEle&&"digital"==readoutEle.innerHTML&&$scope.ApiQuote.forceCheapestSplitPrintingPrice&&(shortside=310,longSide=440),depth+depth+height+height+20>longSide){let splitCount=Math.ceil((depth+depth+height+height+20)/longSide);width>shortside&&(splitCount=Math.ceil((depth+depth+height+height+20)/shortside)),3==splitCount&&(splitCount=4),validationString="At this size, print will be split into "+splitCount+" parts."}width>longSide&&(validationString="This size is too large. Maximum width 682mm."),width>longSide&&(height>shortside||depth>shortside)&&(validationString="This size is too large."),(height>longSide||depth>longSide)&&(validationString="This size is too large. Maximum height/depth size is 682mm."),(depth+depth+height+height+20<50||width<50)&&(validationString="The minimum flat size is 50mm x 120mm"),depth+depth+height+height+20<120&&width<120&&(validationString="The minimum flat size is 50mm x 120mm"),!$scope.ProductDefault||(readoutEle=$scope.ProductDefault.maximumAreaMm2)<(depth+depth+height+height+20)*width&&readoutEle&&(validationString="The maximum size for this product is "+readoutEle+"mm²"),$scope.boxSleeveValidationString=validationString},$scope.interacted=!1,$scope.pageInteractedWith=function(){return $scope.interacted},$scope.DrawCube=function(){if($scope.pageInteractedWith()){let canvas=document.getElementsByClassName("canvas-container")[0];var width,height,renderer,scene,sleeveInput,cubeHeight,depthInput,materialTransparent,group,camera,heightInput,material1a,widthInput,material2,material3,clock;canvas&&$scope.ApiQuote&&(heightInput=$scope.ApiQuote.customPrintHeightMm,widthInput=$scope.ApiQuote.customBoxWidth,depthInput=$scope.ApiQuote.customPrintDepthMm,sleeveInput=$scope.ApiQuote.customPrintWidthMm,heightInput&&widthInput&&depthInput&&sleeveInput&&(canvas.innerHTML="",width=window.innerWidth,height=window.innerHeight,(renderer=new THREE.WebGLRenderer({antialias:!0})).setSize(width,height),renderer.setPixelRatio(window.devicePixelRatio),document.getElementsByClassName("canvas-container")[0].appendChild(renderer.domElement),scene=new THREE.Scene,heightInput=parseInt(heightInput),widthInput=parseInt(widthInput),depthInput=parseInt(depthInput),sleeveInput=parseInt(sleeveInput),cubeHeight=heightInput/(heightInput=Math.max(heightInput/260,widthInput/180,depthInput/180,sleeveInput/180)),widthInput=widthInput/heightInput,depthInput=depthInput/heightInput,sleeveInput=sleeveInput/heightInput,heightInput=new THREE.MeshBasicMaterial({color:4502973,side:THREE.DoubleSide}),material1a=new THREE.MeshBasicMaterial({color:5098451,side:THREE.DoubleSide}),material2=new THREE.MeshBasicMaterial({color:14277591,side:THREE.DoubleSide}),material3=new THREE.MeshBasicMaterial({color:11382700,side:THREE.DoubleSide}),materialTransparent=new THREE.MeshBasicMaterial({transparent:!0,opacity:0,wireframe:!0,side:THREE.DoubleSide}),widthInput=new THREE.BoxBufferGeometry(widthInput,cubeHeight,depthInput),sleeveInput=new THREE.BoxBufferGeometry(sleeveInput,.5+cubeHeight,.5+depthInput),cubeHeight=[materialTransparent,materialTransparent,heightInput,heightInput,material1a,material1a],(depthInput=new THREE.Mesh(widthInput,[material2,material2,material2,material2,material3,material3])).position.set(0,0,0),(materialTransparent=new THREE.Mesh(sleeveInput,cubeHeight)).position.set(0,0,0),(group=new THREE.Group).add(depthInput),group.add(materialTransparent),scene.add(group),group.castShadow=!0,group.rotation.y=45*Math.PI/180,camera=new THREE.PerspectiveCamera(70,width/height,.1,1e4),heightInput=new THREE.OrbitControls(camera,renderer.domElement),camera.position.set(0,90,300),heightInput.enableZoom=!1,heightInput.enablePan=!1,heightInput.enableRotate=!1,heightInput.update(),scene.add(camera),material1a=new THREE.CubeGeometry(1e4,1e4,1e4),widthInput=new THREE.MeshBasicMaterial({color:1779517,side:THREE.BackSide}),material2=new THREE.Mesh(material1a,widthInput),scene.add(material2),(material3=new THREE.PointLight(16777215)).position.set(0,300,200),scene.add(material3),clock=new THREE.Clock,$scope.latestRenderer=renderer,function render(){var canvas;renderer.dispose(),renderer==$scope.latestRenderer&&(requestAnimationFrame(render),group.rotation.y-=clock.getDelta(),renderer.render(scene,camera),canvas=renderer.domElement,camera.aspect=canvas.clientWidth/canvas.clientHeight,camera.updateProjectionMatrix())}()))}},$scope.latestRenderer=null,$scope.threeLibraryLoaded=!1,$scope.threeLibraryRequested=!1,$scope.initialSizeCalculateIntervalHandle=null,$scope.boxInit=function(){var script;$scope.IndexedSpecificationInterfaces&&$scope.IndexedSpecificationInterfaces[84]&&$scope.IndexedSpecificationInterfaces[84].displayed&&($scope.threeLibraryRequested||((script=document.createElement("script")).onload=function(){$scope.threeLibraryLoaded=!0},script.src="https://printprice.co.uk/libs/threeWithOrbit.min.js",document.head.appendChild(script),$scope.threeLibraryRequested=!0),$scope.threeLibraryLoaded?(clearInterval($scope.initialSizeCalculateIntervalHandle),$scope.CalculateSize(),$scope.DrawCube(),document.getElementsByClassName("boxHeight")[0]&&clearInterval($scope.renderBoxHandle)):setTimeout($scope.boxInit,500))},$scope.renderBoxHandle||($scope.renderBoxHandle=setInterval($scope.boxInit,2e3)),$scope.interfaceTitle=function(interfaceId,defaultTitle){return $scope.IndexedSpecificationInterfaces[interfaceId].interfaceTitle||defaultTitle},$scope.loggedInCheck=function(){return loggedIn},$scope.miniPopupNotifications=[],$scope.getBlankMiniPopupObject=function(){return{text:"",backgroundColor:"green",color:"white"}},$scope.showMiniPopup=function(text,backgroundColor,color){let data=$scope.getBlankMiniPopupObject();data.text=text,color&&(data.color=color),backgroundColor&&(data.backgroundColor=backgroundColor),$scope.miniPopupNotifications.push(data),setTimeout($scope.closeMiniPopup,5e3,data)},$scope.closeMiniPopup=function(miniPopup){for(let i=0;i<$scope.miniPopupNotifications.length;i++)$scope.miniPopupNotifications[i]===miniPopup&&($scope.miniPopupNotifications.splice(i,1),i--);$scope.$$phase||$scope.$digest()},$scope.onLocalHost=function(){return"localhost"==window.location.host},$scope.onTestDomain=function(){return"test.printprice.co.uk"==window.location.host},$scope.localHostDebug=function(){console.log($scope.IndexedChoiceData),console.log($scope.ApiQuoteData)},$scope.getBindingEdgeDisplayTitle=function(){return $scope.getBindingEdgeName()+" edge"},$scope.bindingEdgeOptions=["Top","Bottom","Left","Right"],$scope.getBindingEdgeName=function(){return $scope.ApiQuote.bindingEdge||"Top"},$scope.setBindingEdge=function(option){$scope.ApiQuote.bindingEdge=option,$scope.SendBulkQuoteUpdate($scope.ApiQuote.id,[{field:"BindingEdge",oldValue:null,newValue:option}])},$scope.sizeChanged=function(){$scope.validateMaterials(),$scope.validateLaminationSize()},$scope.materialChanged=function(){$scope.checkForSingleSidedOnlyMaterial($scope.IndexedChoiceData["7-Material"].selected);var materialWeight=$scope.getMaterialWeight($scope.IndexedChoiceData["7-Material"].selected);$scope.validateEmbossingAndDebossingWeight(materialWeight),$scope.validateDieCutting(),$scope.validateLaminationOnNewMaterial()},$scope.checkForSingleSidedOnlyMaterial=function(option){option.ChoiceFurtherInformation||(option.ChoiceFurtherInformation=option.choiceFurtherInformation);try{if(!JSON.parse(option.ChoiceFurtherInformation).singleSidedOnly)return;if("2"!=$scope.IndexedChoiceData["22-Single Double Sided - Print Sides"].valueDisplay)return;if($scope.ApiQuote.blankPages)return;$scope.showMiniPopup("Double sided print is not available on this material"),setTimeout($scope.ChangePrintSides,300,"1")}catch(e){return}},$scope.canBeDoubleSidedOnMaterial=function(){let option=$scope.IndexedChoiceData["7-Material"].selected;option.ChoiceFurtherInformation||(option.ChoiceFurtherInformation=option.choiceFurtherInformation);try{return JSON.parse(option.ChoiceFurtherInformation).singleSidedOnly?!1:!0}catch(e){return!0}},$scope.allowAddToBasket=function(){return!$scope.priceNeedsRefreshing&&("undefined"==typeof joomla||("undefined"==typeof loggedIn||!(joomla&&!loggedIn)))},$scope.testingCompleted=!1,$scope.currentTestCount=0,$scope.totalTests=0,$scope.passedTests=[],$scope.failedTests=[],$scope.testWarnings=[],$scope.getTestCompletePercentage=function(){if(0==$scope.totalTests)return 0;var percentage=($scope.currentTestCount-1)/$scope.totalTests*100;return Math.round(percentage)},$scope.runTests=function(){if("undefined"!=typeof PrintPriceTester){let tester=new PrintPriceTester($scope);tester.runTest("default"),$scope.ShowCustomPopup("tests",null)}else alert("Testing service is unavailable")},$scope.reverseArray=function(array){let newArray=[];return array.forEach(function(item){newArray.push(item)}),newArray.reverse()},$scope.getAjaxService=function(){return ajaxService},$scope.prepUrl=function(url){return url.split(" ").join("%20")},$scope.getOptionsInterfaceTitle=function(){let options=$scope.IndexedChoiceData["93-options"];var search=options.find(function(f){return f.ChoiceValueId==$scope.ApiQuote.quoteOptionId});return search?search.ChoiceDisplayName:"None selected"},$scope.setOptionInterface=function(option){$scope.ApiQuote.quoteOptionId=option.ChoiceValueId,$scope.SendBulkQuoteUpdate($scope.ApiQuote.id,[{field:"QuoteOptionId",oldValue:null,newValue:option.ChoiceValueId}])},$scope.getOptionInterfaceOptions=function(){return $scope.IndexedChoiceData["93-options"]},$scope.getOptionDisplayNameGeneric=function(options,choiceValueId,fallbackText){if(!Array.isArray(options))throw new error("Parameter `options` must be an array of type QuoteChoiceElement");for(let i=0;i<options.length;i++){var option=options[i];if(option.ChoiceValueId==choiceValueId)return option.ChoiceDisplayName}return fallbackText},$scope.getOptionDisplayNameImageGeneric=function(options,choiceValueId,fallback){if(!Array.isArray(options))throw new error("Parameter `options` must be an array of type QuoteChoiceElement");for(let i=0;i<options.length;i++){var option=options[i];if(option.ChoiceValueId==choiceValueId)return option.ChoiceImageFile}return fallback},$scope.getInternalPagesInterfaceTitle=function(){return $scope.ApiQuote.blankPages?"Blank pages":$scope.ApiQuote.commonPages?"Common pages throughout":$scope.ApiQuote.uniquePages?"Unique pages":"please select"},$scope.innerPagesBlank=function(){$scope.ApiQuote.blankPages=!0,$scope.ApiQuote.commonPages=!1,$scope.ApiQuote.uniquePages=!1,$scope.updateInnerPagesState()},$scope.innerPagesCommon=function(){$scope.ApiQuote.blankPages=!1,$scope.ApiQuote.commonPages=!0,$scope.ApiQuote.uniquePages=!1,$scope.updateInnerPagesState()},$scope.innerPagesUnique=function(){$scope.ApiQuote.blankPages=!1,$scope.ApiQuote.commonPages=!1,$scope.ApiQuote.uniquePages=!0,$scope.updateInnerPagesState()},$scope.updateInnerPagesState=function(){$scope.SendBulkQuoteUpdate($scope.ApiQuote.id,[{field:"BlankPages",oldValue:null,newValue:$scope.ApiQuote.blankPages},{field:"CommonPages",oldValue:null,newValue:$scope.ApiQuote.commonPages},{field:"UniquePages",oldValue:null,newValue:$scope.ApiQuote.uniquePages}])},$scope.printableEnvelopeSelected=function(){return!!$scope.getEnvelopes()&&(!!$scope.getSelectedEnvelope()&&(!!$scope.getSelectedEnvelope().choiceLabel&&"Printable"==$scope.getSelectedEnvelope().choiceLabel))},$scope.updateProductStyleTypeId=function(option){$scope.ApiQuote.productStyleTypeId=option.ChoiceValueId,$scope.SendBulkQuoteUpdate($scope.ApiQuote.id,[{field:"ProductStyleTypeId",oldValue:null,newValue:$scope.ApiQuote.productStyleTypeId}])},$scope.Ncr=[],$scope.Ncr1={},$scope.Ncr2={},$scope.Ncr3={},$scope.Ncr4={},$scope.setAllAttributesForNcr=function(attributeName,attributeValue){for(var i=0;i<updateObject.length;i++)$scope.Ncr[i][attributeName]=attributeValue;$scope.UpdateNcr()},$scope.GetNcrObject=function(){var targetUrl="quote/data/ncr/"+quoteId,optionalData={url:targetUrl,productId:productId,quoteId:quoteId,userType:$scope.userType};ajaxService.getRequest(targetUrl,optionalData,function(response,httpCode,optionalData){response=$scope.ParseNcrInput(response);$scope.NcrArrayParse(response),$scope.$$phase||$scope.$digest()})},$scope.NcrArrayParse=function(NcrArray){$scope.Ncr=NcrArray[0],$scope.Ncr1=NcrArray[1],$scope.Ncr2=NcrArray[2],$scope.Ncr3=NcrArray[3],$scope.Ncr4=NcrArray[4]},$scope.UpdateNcr=function(){for(var i=0;i<$scope.Ncr.length;i++)delete $scope.Ncr[i].id,delete $scope.Ncr[i].datetimeAdded;let requestId=$scope.getUpdateId();$scope.priceUpdateSent(),ajaxService.postRequest($scope.Ncr,"quote/data/ncr/",{},function(response){$scope.priceUpdateReceived(requestId)&&(response=$scope.cleanQuoteDataUpdate(response),restructureService.parseQuoteDataArray(response,$scope),$scope.$$phase||$scope.$digest())})},$scope.ParseNcrInput=function(ncr){for(var Ncr1={},Ncr2={},Ncr3={},Ncr4={},i=0;i<ncr.length;i++)1==ncr[i].ncrSheetOrderNumber?Ncr1=ncr[i]:2==ncr[i].ncrSheetOrderNumber?Ncr2=ncr[i]:3==ncr[i].ncrSheetOrderNumber?Ncr3=ncr[i]:4==ncr[i].ncrSheetOrderNumber?Ncr4=ncr[i]:console.error("Unexpected value "+ncr[i].ncrSheetOrderNumber+" in NCR object, index "+i);return[ncr,Ncr1,Ncr2,Ncr3,Ncr4]},$scope.getBlankNcrObject=function(){return{backColourTypeId:8,bindingEdge:"Top edge",displayOrder:null,frontColourTypeId:3,materialId:149,materialOptionId:106,ncrOrder:"",ncrSheetName:null,ncrSheetOrderNumber:null,note:null,perforationOptions:"Top sheet",published:!0,quoteId:$scope.ApiQuote.id,setInBundleCount:1}},$scope.SetNcrCount=function(quantity){let ncr1=$scope.getBlankNcrObject(),ncr2=$scope.getBlankNcrObject(),ncr3=$scope.getBlankNcrObject(),ncr4=$scope.getBlankNcrObject();ncr1.materialOptionId=106,ncr2.materialOptionId=107,ncr3.materialOptionId=108,ncr4.materialOptionId=109;var newNcrArray=[ncr1,ncr2],quantity=(3==quantity?newNcrArray.push(ncr3):4==quantity&&(newNcrArray.push(ncr3),newNcrArray.push(ncr4)),newNcrArray=$scope.NcrIndexSheetOrder(newNcrArray),$scope.ParseNcrInput(newNcrArray));$scope.NcrArrayParse(quantity),$scope.perforatedSheetsChanged($scope.fData.ncrSheetCount.finishingOptionId),$scope.UpdateNcr()},$scope.NcrIndexSheetOrder=function(ncrArray){for(var i=0;i<ncrArray.length;i++)ncrArray[i].ncrSheetOrderNumber=i+1,0==i?ncrArray[i].materialId=149:i==ncrArray.length-1?ncrArray[i].materialId=247:ncrArray[i].materialId=246;return ncrArray},$scope.ReturnOptionColour=function(ncrObject,optionArray){for(var i=0;i<optionArray.length;i++)if(optionArray[i].ChoiceValueId==ncrObject.materialOptionId)return{"background-color":optionArray[i].ChoiceImageFile};return{"background-color":"white"}},$scope.ReturnOptionName=function(ncrObject,optionArray){for(var i=0;i<optionArray.length;i++)if(optionArray[i].ChoiceValueId==ncrObject.materialOptionId)return optionArray[i].ChoiceDisplayName;return"-----"},$scope.ColourSelected=function(optionObject,ncrObject){ncrObject.materialOptionId=optionObject.ChoiceValueId,$scope.UpdateNcr()},$scope.returnNcrPrintColour=function(ncrObj,attrName,optionArray){for(var i=0;i<optionArray.length;i++)if(ncrObj[attrName]==optionArray[i].ChoiceValueId)return optionArray[i].ChoiceDisplayName;return"No print"},$scope.PrintColourSelected=function(optionObject,ncrObject,attr){ncrObject[attr]=optionObject.ChoiceValueId,$scope.UpdateNcr()},$scope.setNcrBinding=function(option){for(var i=0;i<$scope.Ncr.length;i++)$scope.Ncr[i].bindingEdge=option.ChoiceDisplayName;$scope.UpdateNcr()},$scope.setNcrPerforations=function(option){for(var i=0;i<$scope.Ncr.length;i++)$scope.Ncr[i].perforationOptions=option.ChoiceDisplayName;$scope.UpdateNcr()},$scope.getNcrBindingName=function(){return $scope.Ncr&&$scope.Ncr.length?$scope.Ncr[0].bindingEdge:null},$scope.getNcrPerforationName=function(){return $scope.Ncr&&$scope.Ncr.length?$scope.Ncr[0].perforationOptions:null},$scope.digestCycleHookHasRegistered=!1,$scope.$watch(function(){$scope.digestCycleHookHasRegistered||($scope.digestCycleHookHasRegistered=!0,$scope.$$postDigest(function(){$scope.digestCycleHookHasRegistered=!1,$scope.digestCycleHook()}))}),$scope.digestCycleHook=function(){$scope.setStyleDynamicStyling()},$scope.showBlankPrintOptionQuery=function(){return $scope.ProductDefault.showBlankPrintOption},$scope.showBlankPrintOptionOnCoverQuery=function(){return $scope.ProductDefault.showBlankPrintOptionOnCover},$scope.folder={dieCutBlockId:null,displayOrder:null,folderName:null,newDieCut:!1,note:null,numberOfPages:0,openDirection:null,orientationTypeId:0,pocket1Capacity:null,pocket1Height:null,pocket1MediaSlotFinishingId:null,pocket1Placement:null,pocket1ShapeFinishingId:null,pocket1ShapeStyle:null,pocket1Width:null,pocket2Capacity:null,pocket2Height:null,pocket2MediaSlotFinishingId:null,pocket2Placement:null,pocket2ShapeFinishingId:null,pocket2ShapeStyle:null,pocket2Width:null,pocket3Capacity:null,pocket3Height:null,pocket3MediaSlotFinishingId:null,pocket3Placement:null,pocket3ShapeFinishingId:null,pocket3ShapeStyle:null,pocket3Width:null,pocket4Capacity:null,pocket4Height:null,pocket4MediaSlotFinishingId:null,pocket4Placement:null,pocket4ShapeFinishingId:null,pocket4ShapeStyle:null,pocket4Width:null,previewImageFile:null,published:!0,spineSizeMm:0,panelPrintSizeId:0,customPrintHeightMM:null,customPrintWidthMM:null},$scope.getFolder=function(quoteId){setInterval(setSquareImageHeight,500),quoteId||console.error("No quote ID given to get folder function"),ajaxService.getRequest("quote/data/folder/"+quoteId,{},function(response,httpCode,optionalData){$scope.folder.pocket1ShapeStyle||null===$scope.folder.pocket1Width||(0<$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId?($scope.folder.pocket1ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceDisplayName,$scope.folder.Pocket1ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId):($scope.folder.pocket1ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceDisplayName,$scope.folder.Pocket1ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceValueId)),$scope.folder.pocket2ShapeStyle||null===$scope.folder.pocket2Width||(0<$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId?($scope.folder.pocket2ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceDisplayName,$scope.folder.pocket2ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId):($scope.folder.pocket2ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceDisplayName,$scope.folder.pocket2ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceValueId)),$scope.folder.pocket3ShapeStyle||null===$scope.folder.pocket3Width||(0<$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId?($scope.folder.pocket3ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceDisplayName,$scope.folder.pocket3FinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId):($scope.folder.pocket3ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceDisplayName,$scope.folder.pocket3FinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceValueId)),$scope.folder.pocket4ShapeStyle||null===$scope.folder.pocket4Width||(0<$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId?($scope.folder.pocket4ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceDisplayName,$scope.folder.pocket4ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId):($scope.folder.pocket4ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceDisplayName,$scope.folder.pocket4ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceValueId)),$scope.folder=response[0],$scope.folder.orientationTypeId&&($scope.fbCurrentPage="finished",$scope.fbCurrentPageIndex=3,$scope.fbBreadcrumbs=$scope.possibleBreadcrumbs),$scope.refreshBreadCrumbs(),$scope.$digest()})},$scope.saveFolder=function(){$scope.folder.quoteId=$scope.ApiQuote.id;for(var i=0;i<$scope.fbCustomPocketCapacities.length;i++)$scope.fbCustomPocketCapacities[i]&&$scope.setPocketAttribute(i+1,"Capacity",$scope.customPocketCapacities[i]);ajaxService.postRequest([$scope.folder],"quote/data/folder",{},function(response,postData){})},$scope.initialiseFolderBuilderValues=function(){$scope.folder.panelPrintSizeId==$scope.IndexedChoiceData["73-Print Size"]&&($scope.folder.quoteId=$scope.ApiQuote.id,$scope.IndexedChoiceData["73-Print size"]&&0<$scope.IndexedChoiceData["73-Print size"].selected.ChoiceValueId&&($scope.folder.panelPrintSizeId=$scope.IndexedChoiceData["73-Print size"].selected.ChoiceValueId),$scope.IndexedChoiceData["73-Orientation"]&&0<$scope.IndexedChoiceData["73-Orientation"].selected.ChoiceValueId&&($scope.folder.orientationTypeId=$scope.IndexedChoiceData["73-Orientation"].selected.ChoiceValueId),$scope.IndexedChoiceData["73-Folder Pocket Shapes"]&&(0<$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId?(null!==$scope.folder.pocket1Height&&($scope.folder.pocket1ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceDisplayName,$scope.folder.pocket1ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId),null!==$scope.folder.pocket2Height&&($scope.folder.pocket2ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceDisplayName,$scope.folder.pocket2ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId),null!==$scope.folder.pocket3Height&&($scope.folder.pocket3ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceDisplayName,$scope.folder.pocket3ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId),null!==$scope.folder.pocket4Height&&($scope.folder.pocket4ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceDisplayName,$scope.folder.pocket4ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId)):(null!==$scope.folder.pocket1Height&&($scope.folder.pocket1ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceDisplayName,$scope.folder.pocket1ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceValueId),null!==$scope.folder.pocket2Height&&($scope.folder.pocket2ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceDisplayName,$scope.folder.pocket2ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceValueId),null!==$scope.folder.pocket3Height&&($scope.folder.pocket3ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceDisplayName,$scope.folder.pocket3ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceValueId),null!==$scope.folder.pocket4Height&&($scope.folder.pocket4ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceDisplayName,$scope.folder.pocket4ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceValueId))),$scope.refreshBreadCrumbs())},$scope.returnCurrentlySelectedString=function(){var returnString="";return $scope.folder.numberOfPages&&(returnString+=$scope.folder.numberOfPages+" page"),"None"!==$scope.fbReturnSelectedSize().ChoiceDisplayName&&(returnString+=", "+$scope.fbReturnSelectedSize().ChoiceDisplayName),$scope.fbReturnPocketCount()&&(returnString+=", "+$scope.fbReturnPocketCount()+" pockets"),returnString=returnString||"No options selected"},$scope.fbSavedSelectedSize=!1,$scope.fbReturnSelectedSize=function(){if($scope.IndexedChoiceData["73-Print size Group"]){if(48==$scope.IndexedChoiceData["73-Print size Group"].selected.ChoiceValueId)return{ChoiceDisplayName:"Custom",ChoiceValueId:48};if($scope.IndexedChoiceData["73-Print Size"])for(var i=0;i<$scope.IndexedChoiceData["73-Print Size"].length;i++)if($scope.IndexedChoiceData["73-Print Size"][i].ChoiceValueId==$scope.folder.panelPrintSizeId)return $scope.IndexedChoiceData["73-Print Size"][i]}return $scope.fbSavedSelectedSize||{ChoiceDisplayName:"None",ChoiceValueId:0}},$scope.fbSaveSelectedSize=function(option){$scope.fbSavedSelectedSize=option},$scope.breadcrumbClicked=function(crumb,index){$scope.fbCurrentPageIndex=index,$scope.fbCurrentPage=$scope.fbPageList[index],3==index&&$scope.saveFolder()},$scope.fbCurrentPage="folderStyle",$scope.fbPageList=["folderStyle","sizeOptions","pockets","finished"],$scope.fbCurrentPageIndex=0,$scope.refreshBreadCrumbs=function(){$scope.folder.numberOfPages?$scope.possibleBreadcrumbs[0].selectedValueLabel=$scope.folder.numberOfPages+" pages":$scope.possibleBreadcrumbs[0].selectedValueLabel="None",$scope.possibleBreadcrumbs[1].selectedValueLabel=$scope.fbReturnSelectedSize().ChoiceDisplayName,$scope.possibleBreadcrumbs[2].selectedValueLabel=$scope.fbReturnPocketCount()},$scope.pageForward=function(){if($scope.checkNextOk()){if($scope.fbCurrentPageIndex++,$scope.fbCurrentPage=$scope.fbPageList[$scope.fbCurrentPageIndex],$scope.fbCurrentPageIndex>=$scope.fbBreadcrumbs.length){$scope.fbBreadcrumbs=[];for(var possibleBreadCrumbs=$scope.possibleBreadcrumbs,i=0;i<=$scope.fbCurrentPageIndex;i++)possibleBreadCrumbs[i]&&$scope.fbBreadcrumbs.push(possibleBreadCrumbs[i])}$scope.refreshBreadCrumbs(),"finished"==$scope.fbCurrentPage&&($scope.saveFolder(),setTimeout(setSquareImageHeight,10))}},$scope.pageBack=function(){$scope.fbCurrentPageIndex--,$scope.fbCurrentPage=$scope.fbPageList[$scope.fbCurrentPageIndex]},$scope.setFolderAttribute=function(attributeName,attributeValue){$scope.folder[attributeName]=attributeValue,$scope.refreshBreadCrumbs()},$scope.standardiseCapitalisation=function(ApiQuoteDataObjectArray){for(var i=0;i<ApiQuoteDataObjectArray.length;i++)ApiQuoteDataObjectArray[i].ChoiceValueId=ApiQuoteDataObjectArray[i].choiceValueId,ApiQuoteDataObjectArray[i].ChoiceDisplayName=ApiQuoteDataObjectArray[i].choiceDisplayName,delete ApiQuoteDataObjectArray[i].choiceValueId,delete ApiQuoteDataObjectArray[i].choiceDisplayName;return ApiQuoteDataObjectArray},$scope.fbGetChildSizeOptions=function(option){$scope.IndexedChoiceData["73-Print size Group"].selected=option;option="choice/"+$scope.ApiQuote.id+"/"+option.ChoiceValueId+"/PrintSizeId";ajaxService.getRequest(option,{},function(response,httpCode,optionalData){$scope.IndexedChoiceData["73-Print Size"]||($scope.IndexedChoiceData["73-Print Size"]=[]),response=$scope.standardiseCapitalisation(response);var selected=$scope.IndexedChoiceData["73-Print Size"].selected,original=$scope.IndexedChoiceData["73-Print Size"].original,displayed=$scope.IndexedChoiceData["73-Print Size"].displayed;$scope.IndexedChoiceData["73-Print Size"]=response,$scope.IndexedChoiceData["73-Print Size"].selected=selected,$scope.IndexedChoiceData["73-Print Size"].original=original,$scope.IndexedChoiceData["73-Print Size"].displayed=displayed,$scope.$digest()})},$scope.returnFolderSizeName=function(){if($scope.IndexedChoiceData["73-Print Size"]){for(let i=0;i<$scope.IndexedChoiceData["73-Print Size"].length;i++){var option=$scope.IndexedChoiceData["73-Print Size"][i];if(option.ChoiceValueId==$scope.folder.panelPrintSizeId)return option.ChoiceDisplayName}return"None selected"}return"ID "+$scope.folder.panelPrintSizeId},$scope.returnFolderOrientationName=function(){if($scope.IndexedChoiceData["73-Orientation"]){for(let i=0;i<$scope.IndexedChoiceData["73-Orientation"].length;i++){var option=$scope.IndexedChoiceData["73-Orientation"][i];if(option.ChoiceValueId==$scope.folder.orientationTypeId)return option.ChoiceDisplayName}return"None selected"}return"ID "+$scope.folder.orientationTypeId},$scope.returnSelectedMediaSlotNameOnPocketNum=function(pocketNumber){var options=$scope.IndexedChoiceData["73-Folder Pocket Media Slot Options"],selectedId=$scope.folder["pocket"+pocketNumber+"MediaSlotFinishingId"];if(!options||!selectedId)return"None";for(let i=0;i<options.length;i++){var option=options[i];if(selectedId==option.ChoiceValueId)return option.ChoiceDisplayName}},$scope.setPocketCount=function(numberOfPockets){var deleteAttributes=[],createIfNullAttributes=[];0==numberOfPockets?deleteAttributes=["pocket1Capacity","pocket1Height","pocket1MediaSlotFinishingId","pocket1Placement","pocket1ShapeFinishingId","pocket1ShapeStyle","pocket1Width","pocket2Capacity","pocket2Height","pocket2MediaSlotFinishingId","pocket2Placement","pocket2ShapeFinishingId","pocket2ShapeStyle","pocket2Width","pocket3Capacity","pocket3Height","pocket3MediaSlotFinishingId","pocket3Placement","pocket3ShapeFinishingId","pocket3ShapeStyle","pocket3Width","pocket4Capacity","pocket4Height","pocket4MediaSlotFinishingId","pocket4Placement","pocket4ShapeFinishingId","pocket4ShapeStyle","pocket4Width"]:1==numberOfPockets?(deleteAttributes=["pocket2Capacity","pocket2Height","pocket2MediaSlotFinishingId","pocket2Placement","pocket2ShapeFinishingId","pocket2ShapeStyle","pocket2Width","pocket3Capacity","pocket3Height","pocket3MediaSlotFinishingId","pocket3Placement","pocket3ShapeFinishingId","pocket3ShapeStyle","pocket3Width","pocket4Capacity","pocket4Height","pocket4MediaSlotFinishingId","pocket4Placement","pocket4ShapeFinishingId","pocket4ShapeStyle","pocket4Width"],createIfNullAttributes=["pocket1Capacity","pocket1Height","pocket1MediaSlotFinishingId","pocket1Placement","pocket1ShapeFinishingId","pocket1ShapeStyle","pocket1Width"]):2==numberOfPockets?(deleteAttributes=["pocket3Capacity","pocket3Height","pocket3MediaSlotFinishingId","pocket3Placement","pocket3ShapeFinishingId","pocket3ShapeStyle","pocket3Width","pocket4Capacity","pocket4Height","pocket4MediaSlotFinishingId","pocket4Placement","pocket4ShapeFinishingId","pocket4ShapeStyle","pocket4Width"],createIfNullAttributes=["pocket1Capacity","pocket1Height","pocket1MediaSlotFinishingId","pocket1Placement","pocket1ShapeFinishingId","pocket1ShapeStyle","pocket1Width","pocket2Capacity","pocket2Height","pocket2MediaSlotFinishingId","pocket2Placement","pocket2ShapeFinishingId","pocket2ShapeStyle","pocket2Width"]):3==numberOfPockets?(deleteAttributes=["pocket4Capacity","pocket4Height","pocket4MediaSlotFinishingId","pocket4Placement","pocket4ShapeFinishingId","pocket4ShapeStyle","pocket4Width"],createIfNullAttributes=["pocket1Capacity","pocket1Height","pocket1MediaSlotFinishingId","pocket1Placement","pocket1ShapeFinishingId","pocket1ShapeStyle","pocket1Width","pocket2Capacity","pocket2Height","pocket2MediaSlotFinishingId","pocket2Placement","pocket2ShapeFinishingId","pocket2ShapeStyle","pocket2Width","pocket3Capacity","pocket3Height","pocket3MediaSlotFinishingId","pocket3Placement","pocket3ShapeFinishingId","pocket3ShapeStyle","pocket3Width"]):4==numberOfPockets&&(createIfNullAttributes=["pocket1Capacity","pocket1Height","pocket1MediaSlotFinishingId","pocket1Placement","pocket1ShapeFinishingId","pocket1ShapeStyle","pocket1Width","pocket2Capacity","pocket2Height","pocket2MediaSlotFinishingId","pocket2Placement","pocket2ShapeFinishingId","pocket2ShapeStyle","pocket2Width","pocket3Capacity","pocket3Height","pocket3MediaSlotFinishingId","pocket3Placement","pocket3ShapeFinishingId","pocket3ShapeStyle","pocket3Width","pocket4Capacity","pocket4Height","pocket4MediaSlotFinishingId","pocket4Placement","pocket4ShapeFinishingId","pocket4ShapeStyle","pocket4Width"]);for(var i=0;i<deleteAttributes.length;i++)$scope.folder[deleteAttributes[i]]=null;for(i=0;i<createIfNullAttributes.length;i++)null===$scope.folder[createIfNullAttributes[i]]&&($scope.folder[createIfNullAttributes[i]]=0);0<$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId?(null!==$scope.folder.pocket1Height&&($scope.folder.pocket1ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceDisplayName,$scope.folder.pocket1ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId),null!==$scope.folder.pocket2Height&&($scope.folder.pocket2ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceDisplayName,$scope.folder.pocket2ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId),null!==$scope.folder.pocket3Height&&($scope.folder.pocket3ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceDisplayName,$scope.folder.pocket3ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId),null!==$scope.folder.pocket4Height&&($scope.folder.pocket4ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceDisplayName,$scope.folder.pocket4ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"].selected.ChoiceValueId)):(null!==$scope.folder.pocket1Height&&($scope.folder.pocket1ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceDisplayName,$scope.folder.pocket1ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceValueId),null!==$scope.folder.pocket2Height&&($scope.folder.pocket2ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceDisplayName,$scope.folder.pocket2ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceValueId),null!==$scope.folder.pocket3Height&&($scope.folder.pocket3ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceDisplayName,$scope.folder.pocket3ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceValueId),null!==$scope.folder.pocket4Height&&($scope.folder.pocket4ShapeStyle=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceDisplayName,$scope.folder.pocket4ShapeFinishingId=$scope.IndexedChoiceData["73-Folder Pocket Shapes"][0].ChoiceValueId)),$scope.refreshBreadCrumbs()},$scope.fbReturnPocketCount=function(){return null===$scope.folder.pocket1Height?0:null===$scope.folder.pocket2Height?1:null===$scope.folder.pocket3Height?2:null===$scope.folder.pocket4Height?3:4},$scope.editingPocketNumber=1,$scope.setEditPocket=function(number){$scope.editingPocketNumber=number,$scope.spinShapeSelectorToSelected()},$scope.setPocketAttribute=function(pocketNumber,attributeName,newValue){$scope.folder["pocket"+pocketNumber+attributeName]=newValue,$scope.refreshBreadCrumbs()},$scope.returnSelectedPocketShape=function(){var choiceArray=$scope.IndexedChoiceData["73-Folder Pocket Shapes"];if("middle"==$scope.folder["pocket"+$scope.editingPocketNumber+"Placement"]){var shape=$scope.folder["pocket"+$scope.editingPocketNumber+"ShapeStyle"];if("Closed"!=shape&&"Folded Flap"!=shape&&"Curved"!=shape&&"Curvy"!=shape)return"Unavailable as middle pocket"}for(var i=0;i<choiceArray.length;i++)if(choiceArray[i].ChoiceValueId==$scope.folder["pocket"+$scope.editingPocketNumber+"ShapeFinishingId"])return choiceArray[i].ChoiceDisplayName;return"None selected"},$scope.returnPocketShapeByNumber=function(pocketNumber){var choiceArray=$scope.IndexedChoiceData["73-Folder Pocket Shapes"];if("middle"==$scope.folder["pocket"+pocketNumber+"Placement"]){var shape=$scope.folder["pocket"+pocketNumber+"ShapeStyle"];if("Closed"!=shape&&"Folded Flap"!=shape&&"Curved"!=shape&&"Curvy"!=shape)return"Unavailable as middle pocket"}for(var i=0;i<choiceArray.length;i++)if(choiceArray[i].ChoiceValueId==$scope.folder["pocket"+pocketNumber+"ShapeFinishingId"])return choiceArray[i].ChoiceDisplayName;return"None selected"},$scope.returnSelectedMediaSlot=function(){for(var choices=$scope.IndexedChoiceData["73-Folder Pocket Media Slot Options"],i=0;i<choices.length;i++)if(choices[i].ChoiceValueId==$scope.folder["pocket"+$scope.editingPocketNumber+"MediaSlotFinishingId"])return choices[i].ChoiceDisplayName;return"None selected"},$scope.returnSlideSelectorImages=function(){var choices=[];return choices=$scope.IndexedChoiceData?$scope.IndexedChoiceData["73-Folder Pocket Shapes"]:choices},$scope.setFbRight=function(){return $scope.returnSlideSelectorImages()?20*(2*$scope.returnSlideSelectorImages().length-2)+20*$scope.fbCurrentIndex:0},$scope.spinShapeSelectorToSelected=function(){let indexToMoveTo=null;for(let i=0;i<$scope.IndexedChoiceData["73-Folder Pocket Shapes"].length;i++)$scope.IndexedChoiceData["73-Folder Pocket Shapes"][i].ChoiceValueId==$scope.folder["pocket"+$scope.editingPocketNumber+"ShapeFinishingId"]&&(indexToMoveTo=i);null!==indexToMoveTo&&($scope.fbCurrentIndex=indexToMoveTo)},$scope.fbCurrentIndex=0,$scope.fbRight=$scope.setFbRight(),$scope.fbTransition="0.2s ease",$scope.blocked=!1,$scope.blockClickCounter=0,$scope.returnStyleObject=function(){return $scope.fbRight=$scope.setFbRight(),{right:$scope.fbRight+"%",transition:$scope.fbTransition}},$scope.moveFbSliderToIndex=function(index){$scope.fbTransition="0.2s ease";index=$scope.fbCurrentIndex-index;index<0?$scope.fbSlideAlong(!0,index*=-1):$scope.fbSlideAlong(!1,index)},$scope.fbSliderTimeoutHandle=!1,$scope.checkForPossibleSliderReset=function(slideLeft,distanceToMove){var numberOfImageOptions=$scope.returnSlideSelectorImages().length;0!==$scope.fbCurrentIndex&&$scope.fbCurrentIndex%numberOfImageOptions==0&&($scope.fbTransition="0s ease",$scope.fbCurrentIndex=0,$scope.$digest()),$scope.blocked=!1,0<$scope.blockClickCounter&&($scope.fbSliderTimeoutHandle=setTimeout($scope.fbSlideAlong,100,slideLeft,distanceToMove,!0))},$scope.fbSlideAlong=function(slideLeft,distanceToMove,digest){clearTimeout($scope.fbSliderTimeoutHandle),$scope.blocked?$scope.blockClickCounter++:(0<$scope.blockClickCounter&&$scope.blockClickCounter--,$scope.blocked=!0,$scope.fbTransition="0.2s ease",slideLeft?$scope.fbCurrentIndex+=distanceToMove:$scope.fbCurrentIndex-=distanceToMove,digest&&$scope.$digest(),$scope.fbSelectCorrectItem(),setTimeout($scope.checkForPossibleSliderReset,250,slideLeft,distanceToMove))},$scope.fbSelectCorrectItem=function(){var currentIndex=$scope.fbCurrentIndex,numberOfImageOptions=$scope.returnSlideSelectorImages().length,indexToFind=currentIndex,choices=$scope.IndexedChoiceData["73-Folder Pocket Shapes"];currentIndex<0&&(indexToFind=numberOfImageOptions+currentIndex),currentIndex>choices.length-1&&(indexToFind=0),$scope.folder["pocket"+$scope.editingPocketNumber+"ShapeFinishingId"]=choices[indexToFind].ChoiceValueId,$scope.folder["pocket"+$scope.editingPocketNumber+"ShapeStyle"]=choices[indexToFind].ChoiceDisplayName},$scope.fbSliderMoveOneLeft=function(){$scope.fbSlideAlong(!0,1)},$scope.fbSliderMoveOneRight=function(){$scope.fbSlideAlong(!1,1)},$scope.fbClickTriggerHandle=function(slideLeft,distanceToMove){$scope.fbSlideAlong(slideLeft,distanceToMove,!1)},$scope.fbCustomPocketCapacities=[!1,!1,!1,!1],$scope.customPocketCapacities=["","","",""],$scope.checkCustomPocketCapacity=function(){$scope.customPocketCapacities[$scope.editingPocketNumber-1]<0&&($scope.customPocketCapacities[$scope.editingPocketNumber-1]=0)},$scope.generateFolderBuilderPreviewArray=function(){return folderBuilderImageService.generate($scope.folder)},$scope.checkForPocketDisabled=function(){var returnObject={disabled:!1,disabledReason:""};return 116==$scope.folder["pocket"+$scope.editingPocketNumber+"ShapeFinishingId"]&&(returnObject.disabled=!0,returnObject.disabledReason="You cannot have capacity on a folded flap pocket"),returnObject},$scope.disableCheckNarrowWidth=function(){var returnObject={disabled:!1,disabledReason:""};return"short"==$scope.folder["pocket"+$scope.editingPocketNumber+"Height"]&&(returnObject.disabled=!0,returnObject.disabledReason="You cannot have a short and narrow pocket"),$scope.disableCheckInterlockingPocket()&&(returnObject.disabled=!0,returnObject.disabledReason="Interlocking pocket size cannot be customised"),120==$scope.folder["pocket"+$scope.editingPocketNumber+"ShapeStyle"]&&(returnObject.disabled=!0,returnObject.disabledReason="This pocket is only possible in full width"),returnObject=$scope.HandleFoldedFlapSizeDisabling(returnObject,"w-narrow")},$scope.disableCheckShortHeight=function(){var returnObject={disabled:!1,disabledReason:""};return"narrow"==$scope.folder["pocket"+$scope.editingPocketNumber+"Width"]&&(returnObject.disabled=!0,returnObject.disabledReason="You cannot have a short and narrow pocket"),$scope.disableCheckInterlockingPocket()&&(returnObject.disabled=!0,returnObject.disabledReason="Interlocking pocket size cannot be customised"),returnObject=$scope.HandleFoldedFlapSizeDisabling(returnObject,"h-short")},$scope.disableCheckInterlockingPocket=function(){return 115==$scope.folder["pocket"+$scope.editingPocketNumber+"ShapeFinishingId"]},$scope.disableCheckPocketSizeCustomisable=function(identString){var returnObject={disabled:!1,disabledReason:""};return $scope.disableCheckInterlockingPocket()&&(returnObject.disabled=!0,returnObject.disabledReason="Interlocking pocket size cannot be customised"),"w-medium"==identString&&120==$scope.folder["pocket"+$scope.editingPocketNumber+"ShapeFinishingId"]&&(returnObject.disabled=!0,returnObject.disabledReason="This pocket is only possible in full width"),returnObject=$scope.HandleFoldedFlapSizeDisabling(returnObject,identString)},$scope.HandleFoldedFlapSizeDisabling=function(returnObject,ident){return 116==$scope.folder["pocket"+$scope.editingPocketNumber+"ShapeFinishingId"]&&("wide"==$scope.folder["pocket"+$scope.editingPocketNumber+"Width"]&&"h-tall"==ident&&(returnObject.disabled=!0,returnObject.disabledReason="This pocket cannot be full height and width"),"medium"!=$scope.folder["pocket"+$scope.editingPocketNumber+"Width"]&&"narrow"!=$scope.folder["pocket"+$scope.editingPocketNumber+"Width"]||"h-medium"!=ident&&"h-short"!=ident||(returnObject.disabled=!0,returnObject.disabledReason="This pocket must be either full height or full width"),"tall"==$scope.folder["pocket"+$scope.editingPocketNumber+"Height"]&&"w-wide"==ident&&(returnObject.disabled=!0,returnObject.disabledReason="This pocket cannot be full height and width"),"medium"!=$scope.folder["pocket"+$scope.editingPocketNumber+"Height"]&&"short"!=$scope.folder["pocket"+$scope.editingPocketNumber+"Height"]||"w-medium"!=ident&&"w-narrow"!=ident||(returnObject.disabled=!0,returnObject.disabledReason="This pocket must be either full height or full width")),returnObject},$scope.disabledCheckForOtherPocketsOnPanel=function(sideString,editingPocketNumber){var returnObject={disabled:!1,disabledReason:""};function checkForPanel(panelNumber){return editingPocketNumber||$scope.editingPocketNumber,panelNumber!=editingPocketNumber&&$scope.folder["pocket"+panelNumber+"Placement"]==sideString}return(checkForPanel(1)||checkForPanel(2)||checkForPanel(3)||checkForPanel(4))&&(returnObject.disabled=!0,returnObject.disabledReason="There is already a pocket on this panel"),"middle"==sideString&&$scope.folder.numberOfPages<6&&(returnObject.disabled=!0,returnObject.disabledReason="There is no middle panel on this folder"),returnObject},$scope.squareFolderMaterialSizeIds=[321,10,322,11,323,12,324,13,325,14,326,32],$scope.checkForSquareMaterial=function(option){-1<$scope.squareFolderMaterialSizeIds.indexOf(option.ChoiceValueId)&&$scope.setFolderAttribute("orientationTypeId",3)},$scope.selectPocketShape=function(pocketNumber,pocket){$scope.folder["pocket"+pocketNumber+"ShapeStyle"]=pocket.ChoiceDisplayName,$scope.folder["pocket"+pocketNumber+"ShapeFinishingId"]=pocket.ChoiceValueId},$scope.checkPocketShapeSelected=function(pocketNumber,pocket){return $scope.folder["pocket"+pocketNumber+"ShapeFinishingId"]==pocket.ChoiceValueId},$scope.fbValidation={error:!1,errorString:""},$scope.clearFolderValidationErrorAndContinue=function(){return $scope.fbValidation.error=!1,!($scope.fbValidation.errorString="")},$scope.checkNextOk=function(){return"folderStyle"==$scope.fbCurrentPage?$scope.checkNextOkFolderStyle():"sizeOptions"==$scope.fbCurrentPage?$scope.checkNextOkSizeOptions():"pockets"==$scope.fbCurrentPage?$scope.checkNextOkPocket():void 0},$scope.checkNextOkFolderStyle=function(){return 0==$scope.folder.numberOfPages?($scope.fbValidation.error=!0,!($scope.fbValidation.errorString="Please select a number of pages")):$scope.clearFolderValidationErrorAndContinue()},$scope.checkNextOkSizeOptions=function(){return $scope.folder.panelPrintSizeId&&$scope.folder.orientationTypeId?$scope.clearFolderValidationErrorAndContinue():!$scope.folder.panelPrintSizeId&&$scope.folder.orientationTypeId?($scope.fbValidation.error=!0,!($scope.fbValidation.errorString="Please select a size")):$scope.folder.panelPrintSizeId&&!$scope.folder.orientationTypeId?($scope.fbValidation.error=!0,!($scope.fbValidation.errorString="Please select an orientation")):($scope.fbValidation.error=!0,!($scope.fbValidation.errorString="Please select a size and an orientation"))},$scope.checkNextOkPocket=function(){return!1},$scope.downloadStyleTemplate=function(style){var style=style.Note,mediaRoot=$scope.apiRoot.replace("/api/","")+"/Images/";window.open(mediaRoot+style,"_blank").focus()},$scope.filterCoverMaterialOptionOptions=function(options,interfaceId){let selectedMaterialId=$scope.cover.materialId,relevantMaps=$scope.IndexedChoiceData[interfaceId+"-Material Option maps"].filter(function(f){return f.MaterialId==selectedMaterialId}).sort(function(a,b){return a.DisplayOrder>b.DisplayOrder?1:a.DisplayOrder<b.DisplayOrder?-1:0}),choices=[];return relevantMaps.forEach(function(map){choices.push(options.find(function(f){return f.ChoiceValueId==map.MaterialOptionId}))}),choices},$scope.folderSVGclassName="folderSVGWrapper",$scope.folderSVGHeight=250,$scope.folderSVGWidth=250,$scope.folderSVGHTML="",$scope.getFBPanelWidth=function(){return 210},$scope.getFBPanelHeight=function(){return 297},$scope.calculateFolderSVG=function(){$scope.folderSVGHTML="",$scope.drawFolder()},$scope.folderChanged=function(){$scope.calculateFolderSVG(),$scope.setFolderSvg()},$scope.drawFolder=function(){6==$scope.folder.numberOfPages?2==$scope.folder.orientationTypeId?$scope.draw6PageFolderLandscape():$scope.draw6PageFolderPortrait():$scope.draw4PageFolder()},$scope.viewBoxWidth=0,$scope.viewBoxHeight=0,$scope.draw4PageFolder=function(){var folderCoordinates=new FolderCoordinates4Page($scope.getFBPanelWidth(),$scope.getFBPanelHeight());$scope.viewBoxHeight=folderCoordinates.viewBoxHeight,$scope.viewBoxWidth=folderCoordinates.viewBoxWidth;let drawer=new FolderBuilderBackgroundDrawer(4,!0,folderCoordinates),rectanglePocket=($scope.folderSVGHTML+=drawer.drawBackground(),new FolderBuilderRectanglePocket(4,!0,folderCoordinates,"Rectangle")),curvedPocket=new FolderBuilderCurvedPocket(4,!0,folderCoordinates,"Curved");folderCoordinates=new PocketToggles;$scope.folderSVGHTML+=rectanglePocket.drawLeft4PageConditional(folderCoordinates),$scope.folderSVGHTML+=rectanglePocket.drawRight4PageConditional(folderCoordinates),$scope.folderSVGHTML+=curvedPocket.drawLeft4PageConditional(folderCoordinates),$scope.folderSVGHTML+=curvedPocket.drawRight4PageConditional(folderCoordinates)},$scope.draw4PageFolderLandscape=function(){let drawer=new FolderBuilderBackgroundDrawer(4,!0,[3,33],[50,30],[97,33],[97,74],[50,60],[3,74],null,null);$scope.folderSVGHTML+=drawer.drawBackground()},$scope.draw6PageFolderPortrait=function(){let drawer=new FolderBuilderBackgroundDrawer(6,!0,[3,22],[32,15],[68,15],[97,22],[97,93],[68,80],[32,80],[3,93]);$scope.folderSVGHTML+=drawer.drawBackground()},$scope.draw6PageFolderLandscape=function(){let drawer=new FolderBuilderBackgroundDrawer(6,!0,[3,32],[32,35],[68,35],[97,32],[97,68],[68,60],[32,60],[3,68]);$scope.folderSVGHTML+=drawer.drawBackground()},$scope.setFolderSvg=function(){},$scope.setFolderSvg(),$scope.getPagesInterfaceError=function(){if(!$scope.IndexedChoiceData["9-Page Count"])return null;if($scope.IndexedChoiceData["9-Page Count"].valueId/$scope.ProductDefault.pagesMultiplier%1!=0)return"Pages must be a multiple of "+$scope.ProductDefault.pagesMultiplier;var thickness=$scope.getThicknessMm(),longside=$scope.getLargeSideMm(),shortside=$scope.getSmallSideMm();if(13==$scope.ProductDefault.id){if(longside<120&&shortside<120&&4<thickness)return"The maximum thickness is 4mm for brochures smaler than 120mm. Please reduce the number of pages or select a thinner paper.";if(6<thickness)return"The maximum thickness is 6mm. Please reduce the number of pages or select a thinner paper."}return $scope.fData&&$scope.fData.binding&&7==$scope.fData.binding.finishingId&&35<thickness?"The maximum thickness is 35mm. Please reduce the number of pages or select a thinner paper.":null},$scope.isSectionDisplayed=function(productAttribute){return!$scope.product||!$scope.product[productAttribute]},$scope.insertAllReadouts=function(){$scope.insertReadout("quote-id-readout",$scope.ApiQuote.id),$scope.insertReadout("price-net-readout",$scope.IndexedChoiceData["57-Price Information"].specificationData.PriceNetTotal),$scope.insertReadout("vatable-readout",$scope.ApiQuote.vatable?"true":"false"),$scope.insertReadout("update-id-readout",$scope.generateUpdateId())},$scope.insertReadout=function(readoutElementId,value){let readoutElement=document.getElementById(readoutElementId);readoutElement&&(readoutElement.innerHTML=value)},$scope.generateUpdateId=function(){let result="#";var characters="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",charactersLength=characters.length;for(let i=0;i<16;i++)result+=characters.charAt(Math.floor(Math.random()*charactersLength));return result},$scope.unauthorisedApiError=!1,$scope.getZoomViewLink=function(preview){return preview.ChoiceImageFile&&!preview.ChoiceImageFile.includes("admin_uploads")?"/Images/"+preview.ChoiceImageFile:"/"+preview.ChoiceImageFile},$scope.getBackgroundImage=function(preview){return preview.ChoiceImageFile&&!preview.ChoiceImageFile.includes("admin_uploads")?"/Images/"+$scope.prepUrl(preview.ChoiceImageFile):"/"+$scope.prepUrl(preview.ChoiceImageFile)},$scope.getProductSelectorNavigationUrlChild=function(productTypeId,productId){let url="main.php";return $scope.isInFileMaker()?url+="?printPriceProductTypeId="+productTypeId+"&mode=filemaker":url+="?printPriceProductTypeId="+productTypeId,url+="&productId="+productId,url},$scope.getBackgroundImage=function(apiUrl,option){return{"background-image":`url("${apiUrl}/Images/${$scope.prepUrl(option.ChoiceImageFile)}")`}}},this.createGetTypeMethods=function($scope){$scope.GetTypeProductStyles=function(){return Array.isArray($scope.ProductStyles)},$scope.GetTypeShapes=function(){return Array.isArray($scope.IndexedChoiceData["81-Product Shapes"])}}});