(()=>{"use strict";var t={11535:(t,e,s)=>{t.exports=s.p+"images/cf8cd32effce8f14064b.png"},57100:(t,e,s)=>{t.exports=s.p+"images/e7566180fedbca0ab884.png"},72500:(t,e,s)=>{t.exports=s.p+"images/de8424720353369deee7.png"},37476:(t,e,s)=>{t.exports=s.p+"images/4c951c42399a4da74eb2.png"},44774:(t,e,s)=>{t.exports=s.p+"images/890f12fd1d84b35d3027.png"},88128:(t,e,s)=>{t.exports=s.p+"images/2ebcbbf6c232bb00f2a6.png"},84906:(t,e,s)=>{t.exports=s.p+"images/5bf5ce672a831fe493f0.png"},66120:(t,e,s)=>{t.exports=s.p+"images/f4b9fc927a6cbb785fb7.png"},69331:(t,e,s)=>{t.exports=s.p+"images/a84c2cd630adcb2fb844.png"},93427:(t,e,s)=>{t.exports=s.p+"images/cb601ecb4902055371fa.png"},33298:(t,e,s)=>{t.exports=s.p+"images/0615efa9ac4d4acf62b9.png"},82916:(t,e,s)=>{t.exports=s.p+"images/5a9b103dc314a4c73396.png"},92517:(t,e,s)=>{t.exports=s.p+"images/4cd0bf4f6c3826be20e9.png"},94701:(t,e,s)=>{t.exports=s.p+"images/ca96080890acb13f1452.png"},66735:(t,e,s)=>{t.exports=s.p+"images/b46f607e557fa86ce5de.png"}},e={};function s(r){var o=e[r];if(void 0!==o)return o.exports;var n=e[r]={exports:{}};return t[r](n,n.exports,s),n.exports}s.m=t,s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.p="/",s.b=document.baseURI||self.location.href,(()=>{function t(t,e,s,r){e.textContent=t?r:s}new URL(s(66735),s.b),new URL(s(92517),s.b),new URL(s(94701),s.b),new URL(s(11535),s.b),new URL(s(57100),s.b),new URL(s(72500),s.b),new URL(s(37476),s.b),new URL(s(44774),s.b),new URL(s(88128),s.b),new URL(s(84906),s.b),new URL(s(66120),s.b),new URL(s(69331),s.b),new URL(s(93427),s.b),new URL(s(33298),s.b),new URL(s(82916),s.b);const e=new class{constructor({baseUrl:t,headers:e}){this._baseUrl=t,this._headers=e}_isResponseOk(t){return t.ok?t.json():Promise.reject(`Ошибка: ${t.status}`)}getInitialCards(){return fetch("https://api.termoblok.ru/data/blogCards",{headers:this._headers}).then((t=>this._isResponseOk(t)))}getNews(){return fetch("https://api.termoblok.ru/news",{headers:this._headers}).then((t=>this._isResponseOk(t)))}getInitiatPartners(){return fetch("https://api.termoblok.ru/data/partners",{headers:this._headers}).then((t=>this._isResponseOk(t)))}sendCallForm(t){return fetch(`${this._baseUrl}/forms/small-form`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),isBase64Encoded:!1}).then((t=>(console.log(t),this._isResponseOk(t))))}sendBigForm(t){return fetch(`${this._baseUrl}/forms/big-form`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then((t=>this._isResponseOk(t)))}}({baseUrl:"https://api.termoblok.ru",headers:{Accept:"*/*","Content-Type":"text/plain"}}),r=document.forms.formCallBack,o=r.querySelector(".button-bem_submit"),n=new class{constructor(t,e){this._inputSelector=t.inputSelector,this._inputErrorClass=t.inputErrorClass,this._errorClass=t.errorClass,this._submitButtonSelector=t.submitButtonSelector,this._inactiveButtonClass=t.inactiveButtonClass,this._formElement=e,this._inputList=Array.from(this._formElement.querySelectorAll(this._inputSelector)),this._buttonElement=this._formElement.querySelector(this._submitButtonSelector)}_showInputError(t,e){const s=this._formElement.querySelector(`.${t.id}-error`);t.classList.add(this._inputErrorClass),s.textContent=e,s.classList.add(this._errorClass)}_hideInputError(t){const e=this._formElement.querySelector(`.${t.id}-error`);t.classList.remove(this._inputErrorClass),e.classList.remove(this._errorClass),e.textContent=""}_checkInputValidity(t){t.validity.valid?this._hideInputError(t):this._showInputError(t,t.validationMessage)}_hasInvalidInput(t){return t.some((t=>!t.validity.valid))}_toggleButtonState(t,e){this._hasInvalidInput(t)?(e.classList.add(this._inactiveButtonClass),e.setAttribute("disabled",!0)):(e.classList.remove(this._inactiveButtonClass),e.removeAttribute("disabled"))}_showErrors(t,e){t.forEach((s=>{this._checkInputValidity(s),this._toggleButtonState(t,e)}))}toggleButtonState(){this._toggleButtonState(this._inputList,this._buttonElement)}hasInvalidInput(){return this._hasInvalidInput(this._inputList)}disableSaveButton(){this._buttonElement.classList.add(this._inactiveButtonClass),this._buttonElement.setAttribute("disabled",!0)}cleanAllErrors(){this._inputList.forEach((t=>{this._hideInputError(t)}))}showErrors(){this._inputList.forEach((t=>{this._checkInputValidity(t),this.toggleButtonState(this._inputList,this._buttonElement)}))}showErrorsForStep(t){}_setEventListeners(){this._inputList.forEach((t=>{t.addEventListener("input",(()=>{this._checkInputValidity(t),this.toggleButtonState()}))}))}_setStepEventListeners(t){t.forEach((t=>{const e=t.inputs,s=t.button;console.log(`123 ${s}`),e.forEach((t=>{t.addEventListener("input",(()=>{this._checkInputValidity(t),this._toggleButtonState(e,s)}))}))}))}enableValidation(){this._formElement.addEventListener("submit",(t=>{t.preventDefault()})),this._setEventListeners()}checkStep(t){const e=this._sets[t].inputs,s=this._sets[t].button;return!this._hasInvalidInput(e)||(this._showErrors(e,s),this._toggleButtonState(e,s),!1)}enableStepValidation(){this._sets=[];const t=this._formElement.querySelector(".first-step"),e=t.querySelector(".first-step-button"),s=Array.from(t.querySelectorAll(this._inputSelector));this._sets.push({inputs:s,button:e});const r=this._formElement.querySelector(".second-step"),o=r.querySelector(".second-step-button"),n=Array.from(r.querySelectorAll(this._inputSelector));this._sets.push({inputs:n,button:o}),this._setStepEventListeners(this._sets)}}({inputSelector:".raschet-bem__input",submitButtonSelector:".button-bem",inactiveButtonClass:"popup__button-save_disabled",inputErrorClass:"raschet-bem__input_type_error",errorClass:"raschet-bem__input-error_visible"},r),i=new class extends class{constructor(t){this._modal=document.querySelector(t),this._handleEscButton=t=>{"Escape"===t.key&&this.close()},this._handleOverlayClick=t=>{t.target.classList.contains("popup_opened")&&this.close()}}open(){document.querySelector("body").classList.add("body-fixed"),this._modal.classList.add("popup_opened"),document.addEventListener("keydown",this._handleEscButton),this._modal.addEventListener("mousedown",this._handleOverlayClick)}close(){this._modal.classList.remove("popup_opened"),document.removeEventListener("keydown",this._handleEscButton),this._modal.removeEventListener("mousedown",this._handleOverlayClick),document.querySelector("body").classList.remove("body-fixed")}setEventListeners(){this._modal.querySelector(".popup__button-close").addEventListener("mousedown",(()=>{this.close()}))}}{constructor({formSubmitHandler:t,formCleanError:e,checherValidation:s},r,o,n){super(r),this._formSubmitHandler=t,this._formCleanError=e,this._formElement=this._modal.querySelector(o),this._heading=this._modal.querySelector(".raschet-bem__title"),this._comment=this._modal.querySelector("#comment-free-input"),this._inputSelector=n,this._checker=s}_getInputValues(){return this._inputList=this._formElement.querySelectorAll(this._inputSelector),this._formValues={},this._inputList.forEach((t=>{this._formValues[t.name]=t.value})),console.log(this._formValues),this._formValues}open(t,e){this._heading.textContent=t||"Заявка в свободной форме",this._comment.textContent=e||"",super.open()}close(){super.close(),this._formElement.reset(),this._formCleanError()}setEventListeners(){super.setEventListeners(),this._formElement.addEventListener("submit",(t=>{t.preventDefault(),this._checker()&&this._formSubmitHandler(this._getInputValues())}))}}({formSubmitHandler:s=>{t(!0,o,"Отправить","Отправка..."),e.sendCallForm(s).then((t=>{console.log(t),i.close()})).catch((t=>console.log(t))).finally((()=>{n.disableSaveButton(),t(!1,o,"Отправить","Отправка...")}))},formCleanError:()=>{n.cleanAllErrors()},checherValidation:t=>!n.hasInvalidInput()||(n.showErrors(),!1)},".popup-callback",".popup__form",".raschet-bem__input");i.setEventListeners(),n.enableValidation(),document.querySelector(".promivka-popup-callback")?.addEventListener("mousedown",(()=>{i.open("Заявка на сервис")})),document.querySelector(".shareparts-popup-callback")?.addEventListener("mousedown",(()=>{i.open("Заявка на комплектующие","Здравствуйте, просьба отправить прайс на комплектующие.")}));const a=document.forms.formChoice,l=document.querySelector(".service-grid__plast-table"),c=document.querySelector(".service-grid__seals-table");a?.addEventListener("change",(()=>{"plast"===a.elements.radio.value?(l.style.display="block",c.style.display="none"):(l.style.display="none",c.style.display="block")}))})()})();