const uiGlobal=function(){function findParent(element,value,referrence){while(element.parentNode){element=element.parentNode;if(element[referrence]===value){return element}}return null}function renderCheapestServerPrice(arr){const element=document.getElementById("cheapest-server-price");const prices=arr.map((item=>item.price));let minPrice=Math.min(...prices);minPrice=minPrice%1!==0?minPrice.toFixed(2):minPrice;if(element){element.textContent=minPrice}}const renderTableHeader=(servers,containerUI,componentsArr,hasGPU=false,discountedCustomGPU=false)=>{const tableColumnsToDisplay=[...componentsArr];if(containerUI.parentElement.classList.value==="table-configuration-header"){tableColumnsToDisplay.unshift("showMore")}tableColumnsToDisplay.push("Price");if(hasGPU){tableColumnsToDisplay.splice(2,0,"GPU")}if(discountedCustomGPU){tableColumnsToDisplay.splice(2,0,"GPU")}let tableCellHtml="";let dataCenterHtml="";tableColumnsToDisplay.forEach((item=>{let optionHTML="";let columnTitle="";let extraInfo="";let selectComponentType="";switch(item){case"showMore":selectComponentType="showMore";break;case"CPU":columnTitle="Processor(s)";selectComponentType="cpu";break;case"GPU":columnTitle=item;selectComponentType="gpu";break;case"IPv":columnTitle="IPv";break;case"FlashMedia":columnTitle="Streaming Solution";break;case"OpSoft":columnTitle="Optional Software";break;case"OS":columnTitle="OS";selectComponentType="os";break;case"RAM":columnTitle="Memory";selectComponentType="ram";extraInfo="GB";break;case"HDD":columnTitle="Storage";selectComponentType="hdd";break;case"PortSpeed":columnTitle="Transfer";selectComponentType="traffic";break;case"Location":columnTitle="Data Center";selectComponentType="location";break;case"Price":columnTitle="Monthly";selectComponentType="price";break}if(servers){if(selectComponentType!=="price"){let selectValue=servers.map((item=>item[selectComponentType])).filter((item=>item)).sort(((a,b)=>{const stringSort=["cpu","gpu","hdd","os","location"].includes(selectComponentType);const numberSort=["ram","price","traffic"].includes(selectComponentType);if(numberSort&&selectComponentType==="traffic"){if(a.includes("Gbps")){a=parseInt(a.split(" ")[0])*1e3}else{a=parseInt(a.split(" ")[0])}if(b.includes("Gbps")){b=parseInt(b.split(" ")[0])*1e3}else{b=parseInt(b.split(" ")[0])}}if(a&&b){return numberSort?a-b:b.localeCompare(a)}}));selectValue=selectValue.filter(((item,index)=>selectValue.indexOf(item)===index));selectValue.forEach((selectValueItem=>{optionHTML+=``}))}else{optionHTML=`\n \n \n \n \n \n \n \n `}}tableCellHtml+=`\n \n
${columnTitle}
\n ${servers&&selectComponentType!=="showMore"?`\n \n `:""}\n \n `}));if(containerUI){containerUI.innerHTML=tableCellHtml}};function renderInstantsTable(serversArray,table,showGPU=false,showDiscountedCustomGPU=false){let tableBodyHtml="";if(window.location.pathname.includes("/deals/")){serversArray.sort(((a,b)=>b.discount.split(":")[1].split("}")[0]-a.discount.split(":")[1].split("}")[0]))}else{serversArray.sort(((a,b)=>a.price-b.price))}const newServersArray=dataModelGlobal.groupDuplicates(serversArray,showGPU);let firstItems=[];let arrayOfLengths=[];for(const property in newServersArray){arrayOfLengths.push(newServersArray[property].length);firstItems.push(newServersArray[property][0])}firstItems.forEach(((item,index)=>{const{cpu:cpu,gpu:gpu,ram:ram,hdd:hdd,os:os,traffic:traffic,location:location,type:type,name:name}=item;const discount=item&&JSON.parse(item.discount)&&JSON.parse(item.discount).percent;const initialPrice=item.price;let discountPrice=initialPrice/100*discount;let calculatedPrice=discount?initialPrice-discountPrice:initialPrice;calculatedPrice=calculatedPrice.toFixed(2);let currency="€";if(item.location.includes("US")){currency="$"}const initialPriceHTML=initialPrice.toFixed(2);const monthlyHtml=`\n ${discount?`\n ${currency}${initialPriceHTML}\n `:""}\n \n ${currency}${calculatedPrice}\n\n ${discount?`(-${discount}%)`:""}\n `;tableBodyHtml+=`\n \n ${arrayOfLengths[index]>1?`\n \n `:``}\n ${cpu}\n ${showGPU?gpu?`${gpu}`:"":""}\n ${showDiscountedCustomGPU?gpu?`${gpu}`:"":""}\n ${ram} GB\n ${hdd}\n ${os}\n ${traffic}\n ${location}\n ${monthlyHtml}\n \n \n \n \n INSTANT\n \n \n \n `}));const placeholderHtml=`\n \n \n

Servers not found

\n \n \n `;if(table){table.innerHTML=firstItems.length?tableBodyHtml:placeholderHtml}}let allPricesArray=[];function renderCustomTable(serversArray,table,componentsArr,extraData=undefined){const pathname=window.location.pathname;let tableBodyHtml="";serversArray.forEach((item=>{let totalPrice=0;let customParams="";const serverInitialData=item.data;const plan=item.type;let components=utilGlobal.getServerDefaultComponents(serverInitialData,componentsArr);const hddAvailable=["D102","D103","D104","D104a","D105","D156","D157","D158"].includes(plan)?2:1;if(extraData){if(extraData.tableType==="unmetered"&&extraData.portSpeed){components.PortSpeed=serverInitialData.PortSpeed.filter(((item,index)=>item.Value===extraData.portSpeed))[0];if(!components.PortSpeed){return}customParams+=`&preselectBandwidth=${components.PortSpeed.Value}`}if(extraData.tableType==="operatingSystem"&&extraData.os){components.OS=serverInitialData.OS.filter((item=>{if(extraData.os==="windows"&&extraData.osType){return item.Value===extraData.osType}if(extraData.os==="linux"){return!item.Value.toLowerCase().includes("windows")}}))[0];if(!components.OS){return}customParams+=`&preselectOperatingSystem=${components.OS.id}`}if(extraData.tableType==="Red5"){components.FlashMedia=serverInitialData.FlashMedia.filter((item=>{if(item.Value.includes("Red5")){return item}}))[0];if(!components.FlashMedia){return}}if(extraData.tableType==="FlashMedia"&&extraData.FlashMedia){components.FlashMedia=serverInitialData.FlashMedia.filter((item=>item.Value.toLowerCase().includes(extraData.FlashMedia)))[0];if(!components.FlashMedia){return}}if(extraData.tableType==="OpSoft"&&extraData.OpSoft){components.OpSoft=serverInitialData.OpSoft.filter((item=>item.Value.toLowerCase().includes(extraData.OpSoft)))[0];if(!components.OpSoft){return}}}if(plan==="M350"){components.PortSpeed=serverInitialData.PortSpeed[2];customParams+="&preselectBandwidth=300"}if(components.FlashMedia){customParams+=`&preselectStreaming=${components.FlashMedia.id}`}if(components.OpSoft){customParams+=`&preselectOpSoft=${components.OpSoft.id}`}const pageURL=["/artificial-intelligence/","/machine-learning/","/dedicated/gpu/pricing/","/transcoding/","/h100/","/rtx30/","/l40s/","/amd-instinct/"];if(pageURL.includes(window.location.pathname)){const pathName=window.location.pathname;const preselectGPUs={"/dedicated/gpu/pricing/":{D103:"NVIDIA GeForce GTX 1080 Ti 3584 CUDA Cores",D104:"NVIDIA Quadro RTX 5000 3072 CUDA Cores",D104a:"4 x NVIDIA CMP-170HX Mining GPU 164MH/s",D105:"NVIDIA Ampere A40 10752 CUDA Cores"},"/artificial-intelligence/":{D104a:"NVIDIA Tesla V100 32GB 5120 CUDA Cores",D104:"NVIDIA Ampere A40 10752 CUDA Cores",D105:"NVIDIA Ampere A100 40GB 6912 CUDA Cores"},"/machine-learning/":{D104a:"NVIDIA Tesla V100 32GB 5120 CUDA Cores",D104:"NVIDIA Ampere A40 10752 CUDA Cores",D105:"NVIDIA Ampere A100 40GB 6912 CUDA Cores"},"/transcoding/":{D103:"NVIDIA TESLA P4 / QUADRO P5000 2560 CUDA Transcoding Cores",D104:"NVIDIA Quadro RTX 5000 3072 CUDA Cores",D105:"NVIDIA RTX A6000 10752 CUDA Cores"},"/h100/":{D105:"4 x NVIDIA Ampere A100 40GB 6912 CUDA Cores"},"/rtx30/":{D104:"NVIDIA GeForce RTX 3070 5888 CUDA Cores",D105:"NVIDIA GeForce RTX 3080 8704 CUDA Cores"},"/l40s/":{D105:"NVIDIA L40S 18176 CUDA Cores"},"/amd-instinct/":{D105:"AMD Instinct MI210"}};const currObj=Object.entries(preselectGPUs).filter((val=>val[0]===pathName))[0][1];let demoArray=[];Object.entries(currObj).forEach((demo=>{let obj={};if(demo[0].includes("D104a")){obj["D104"]=demo[1]}else{obj[demo[0]]=demo[1]}demoArray.push(obj)}));if(["D103","D104","D104a","D105"].includes(item.type)){components.GPU=serverInitialData.GPU.find((value=>{if(value.Value===currObj[item.type]){return value}}));customParams+=`&preselectGPU=${components.GPU.id}`}}const linkHref=utilGlobal.changeOrderLink(plan,undefined,customParams.length?customParams:"");if(Object.keys(components).length){let allPrices={CPU:components.CPU.FixedPrice,RAM:components.RAM.FixedPrice,HDD:components.HDD.PerValuePrice*hddAvailable,PortSpeed:components.PortSpeed.FixedPrice,FixedPrice:serverInitialData.FixedPrice};const operatingSystemPrice=dataModelGlobal.calculateOS(serverInitialData,serverInitialData.DefaultConfig);Object.assign(allPrices,components.GPU?{GPU:components.GPU.FixedPrice}:undefined,components.OS?{OS:operatingSystemPrice}:undefined,components.OpSoft?{OpSoft:components.OpSoft.FixedPrice}:undefined,components.FlashMedia?{FlashMedia:components.FlashMedia.FixedPrice}:undefined,components.IPv?{IPv:components.IPv.FixedPrice}:undefined);allPrices=Object.values(allPrices).filter((item=>item));totalPrice=utilGlobal.calculateServerPrice(allPrices);allPricesArray.push(totalPrice)}const isGbps=components.PortSpeed.Value>=1e3;const formattedPortSpeed=isGbps?`${components.PortSpeed.Value/1e3} Gbps`:`${components.PortSpeed.Value} Mbps`;tableBodyHtml+=`\n \n \n table icon\n \n
\n\n \n ${components.CPU.Value>1?`${components.CPU.Value} x`:""} ${components.CPU.SubItem}\n \n \n \n ${components.GPU?`\n \n table icon\n \n
\n \n \n ${components.GPU.Value}\n \n \n `:""}\n \n ${components.OS?`\n \n table icon\n \n
\n \n \n ${components.OS.Value}\n \n \n `:""}\n \n ${components.IPv?`\n \n table icon\n \n
\n \n \n ${components.IPv.Value} x ${components.IPv.SubItem}\n \n \n `:""}\n \n ${components.OpSoft?`\n \n table icon\n \n
\n \n \n ${components.OpSoft.Value}\n \n \n `:""}\n \n ${components.FlashMedia?`\n \n table icon\n \n
\n \n \n ${components.FlashMedia.Value}\n \n \n `:""}\n\n \n ram icon\n\n
\n\n ${components.RAM.Value} GB\n \n\n \n storage icon\n \n
\n\n \n ${hddAvailable===1?"":`${hddAvailable} x`} ${components.HDD.SubItem}\n \n \n\n \n port speed icon\n \n
\n\n ${formattedPortSpeed}\n \n\n \n $ ${totalPrice.toFixed(2)}\n \n\n \n \n \n\n CONFIGURE\n \n \n \n `}));const placeholderHtml=`\n \n \n

Servers not found

\n \n \n `;if(table){table.innerHTML=serversArray.length?tableBodyHtml:placeholderHtml}const cheapestPrice=document.getElementById("cheapest-server-price");if(cheapestPrice){cheapestPrice.innerText=Math.min(...allPricesArray)}}function initRenderInstantsTable(data){const tables=document.querySelectorAll(".table-configuration-container[data-instants-type]");const serverContainer=document.querySelectorAll("#servers-container");const loader=document.querySelectorAll(".loading-placeholder");const allServersContainer=document.getElementById("all-servers-container");if(allServersContainer){serverContainer[0].style.display="flex";loader[0].style.display="none"}tables.forEach((item=>{const{instantsType:instantsType}=item.dataset;const servers=data[instantsType];const hasGPU=instantsType==="with-gpu"||instantsType==="custom-gpu"||instantsType==="entry-level-gpu"||instantsType==="nvmeGPU";const hasDiscountedCustomGPU=instantsType==="discounted-custom-gpu";const componentsArr=["CPU","RAM","HDD","OS","PortSpeed","Location"];const tableContainer=document.querySelector(`.table-configuration-container[data-instants-type="${instantsType}"] .table-configuration-body`);const selectContainer=document.querySelector(`.table-configuration-container[data-instants-type="${instantsType}"] .table-configuration-header .table-select-container`);uiGlobal.renderTableHeader(servers,selectContainer,componentsArr,hasGPU,hasDiscountedCustomGPU);uiGlobal.renderInstantsTable(servers,tableContainer,hasGPU,hasDiscountedCustomGPU)}))}function initRenderCustomTable(data,tableID,componentsArr,extraData=undefined){const tableHeaderCustom=document.querySelector(`${tableID} .table-configuration-header`);const tableBodyCustom=document.querySelector(`${tableID} .table-configuration-body`);uiGlobal.renderTableHeader(undefined,tableHeaderCustom,componentsArr);uiGlobal.renderCustomTable(data,tableBodyCustom,componentsArr,extraData)}function renderLanguageOptions(){const languageContainer=document.getElementById("language-selector-container");let html="";if(languageContainer){dataModelGlobal.languagesData.forEach((item=>{html+=`\n \n `}));languageContainer.innerHTML=html}}function toggleLoader(action){const loader=document.querySelector(".loader");const footer=document.getElementById("main-footer");const prevElement=loader&&loader.previousElementSibling;if(loader&&footer&&prevElement){switch(action){case"show":prevElement.classList.add("d-none");prevElement.classList.remove("d-flex");prevElement.classList.remove("mx-auto");loader.classList.remove("d-none");footer.classList.remove("mt-auto");break;case"hide":prevElement.classList.add("d-flex");prevElement.classList.remove("d-none");prevElement.classList.add("mx-auto");loader.classList.add("d-none");footer.classList.add("mt-auto");break}}}const globalSwal=window.Swal?Swal.mixin({customClass:{confirmButton:"btn btn-success",cancelButton:"btn btn-danger",denyButton:"btn btn-secondary"},buttonsStyling:false,reverseButtons:true}):undefined;const globalToast=window.Swal?Swal.mixin({toast:true,showConfirmButton:false,timer:4500,timerProgressBar:false}):undefined;function showGlobalSwalError(text,reload){toggleLoader("show");if(reload){globalSwal.fire({title:text,icon:"error",showConfirmButton:false,showCancelButton:false,showCloseButton:false,allowOutsideClick:true,footer:'Go Back to the previous order step'})}else{globalSwal.fire({title:text,icon:"error",showConfirmButton:false,showCancelButton:false,showCloseButton:false,allowOutsideClick:true})}}function showGlobalSwalSuccess(text){toggleLoader("show");globalSwal.fire({title:text,icon:"success",showConfirmButton:true,showCancelButton:false,showCloseButton:false,allowOutsideClick:true})}return{renderTableHeader:renderTableHeader,renderInstantsTable:renderInstantsTable,renderCustomTable:renderCustomTable,initRenderInstantsTable:initRenderInstantsTable,initRenderCustomTable:initRenderCustomTable,renderLanguageOptions:renderLanguageOptions,toggleLoader:toggleLoader,globalSwal:globalSwal,globalToast:globalToast,showGlobalSwalError:showGlobalSwalError,showGlobalSwalSuccess:showGlobalSwalSuccess,renderCheapestServerPrice:renderCheapestServerPrice,findParent:findParent}}();