(()=>{"use strict";var e={3008:(e,t,s)=>{e.exports=s.p+"images/5a9b103dc314a4c73396.png"},20611:(e,t,s)=>{e.exports=s.p+"images/a84c2cd630adcb2fb844.png"},31728:(e,t,s)=>{e.exports=s.p+"images/0615efa9ac4d4acf62b9.png"},45934:(e,t,s)=>{e.exports=s.p+"images/890f12fd1d84b35d3027.png"},57971:(e,t,s)=>{e.exports=s.p+"images/ca96080890acb13f1452.png"},62408:(e,t,s)=>{e.exports=s.p+"images/5bf5ce672a831fe493f0.png"},67133:(e,t,s)=>{e.exports=s.p+"images/2ebcbbf6c232bb00f2a6.png"},70654:(e,t,s)=>{e.exports=s.p+"images/e7566180fedbca0ab884.png"},72400:(e,t,s)=>{e.exports=s.p+"images/b46f607e557fa86ce5de.png"},72673:(e,t,s)=>{e.exports=s.p+"images/cb601ecb4902055371fa.png"},82542:(e,t,s)=>{e.exports=s.p+"images/4cd0bf4f6c3826be20e9.png"},86439:(e,t,s)=>{e.exports=s.p+"images/cf8cd32effce8f14064b.png"},88951:(e,t,s)=>{e.exports=s.p+"images/4c951c42399a4da74eb2.png"},94939:(e,t,s)=>{e.exports=s.p+"images/f4b9fc927a6cbb785fb7.png"},99323:(e,t,s)=>{e.exports=s.p+"images/de8424720353369deee7.png"}},t={};function s(o){var n=t[o];if(void 0!==n)return n.exports;var r=t[o]={exports:{}};return e[o](r,r.exports,s),r.exports}s.m=e,s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.p="/",s.b="undefined"!=typeof document&&document.baseURI||self.location.href;class o{constructor(e,t){this._inputSelector=e.inputSelector,this._inputErrorClass=e.inputErrorClass,this._errorClass=e.errorClass,this._submitButtonSelector=e.submitButtonSelector,this._inactiveButtonClass=e.inactiveButtonClass,this._formElement=t,this._inputList=Array.from(this._formElement.querySelectorAll(`${this._inputSelector}:not([type="radio"])`)),this._buttonElement=this._formElement.querySelector(this._submitButtonSelector),this._showErrorsAnimationClasses=["translate-x-5","opacity-0"],this._showErrorsTransitionsClasses=["transition-all","duration-300"],Array.from(this._formElement.querySelectorAll(".form__input-error")).map(e=>e.classList.add(...this._showErrorsAnimationClasses,...this._showErrorsTransitionsClasses))}_animateErrMessage(e){e.classList.add(...this._showErrorsAnimationClasses),requestAnimationFrame(()=>{e.classList.add(...this._showErrorsTransitionsClasses),e.classList.remove(...this._showErrorsAnimationClasses);const t=()=>{e.removeEventListener("transitionend",t),e.classList.remove(...this._showErrorsTransitionsClasses)};e.addEventListener("transitionend",t),setTimeout(t,350)})}_showInputError(e,t){const s=this._formElement.querySelector(`.${e.id}-error`);e.classList.add(this._inputErrorClass),s.textContent=t,s.classList.add(this._errorClass),this._animateErrMessage(s)}_hideInputError(e){const t=this._formElement.querySelector(`.${e.id}-error`);e.classList.remove(this._inputErrorClass),t.classList.remove(this._errorClass),t.classList.add(...this._showErrorsAnimationClasses),t.textContent=""}_checkInputValidity(e){e.validity.valid?this._hideInputError(e):this._showInputError(e,e.validationMessage)}_hasInvalidInput(e){return e.some(e=>!e.validity.valid)}_toggleButtonState(e,t){this._hasInvalidInput(e)?(t.classList.add(this._inactiveButtonClass),t.setAttribute("disabled",!0)):(t.classList.remove(this._inactiveButtonClass),t.removeAttribute("disabled"))}_showErrors(e,t){e.forEach(e=>{this._checkInputValidity(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(e=>{this._hideInputError(e)})}showErrors(){this._inputList.forEach(e=>{this._checkInputValidity(e)})}_setEventListeners(){this._inputList.forEach(e=>{let t=null;e.addEventListener("input",()=>{t&&clearTimeout(t),t=setTimeout(()=>{this._checkInputValidity(e)},400)})})}_setStepEventListeners(e){e.forEach(e=>{const t=e.inputs,s=e.button;console.log(`123 ${s}`),t.forEach(e=>{e.addEventListener("input",()=>{this._checkInputValidity(e),this._toggleButtonState(t,s)})})})}checkStep(e){const t=this._sets[e].inputs,s=this._sets[e].button;return!this._hasInvalidInput(t)||(this._showErrors(t,s),this._toggleButtonState(t,s),!1)}enableStepValidation(){this._sets=[];const e=this._formElement.querySelector(".first-step"),t=e.querySelector(".first-step-button"),s=Array.from(e.querySelectorAll(this._inputSelector));this._sets.push({inputs:s,button:t});const o=this._formElement.querySelector(".second-step"),n=o.querySelector(".second-step-button"),r=Array.from(o.querySelectorAll(this._inputSelector));this._sets.push({inputs:r,button:n}),this._setStepEventListeners(this._sets)}enableValidation(){this._formElement.addEventListener("submit",e=>{e.preventDefault()}),this._setEventListeners()}}class n{constructor({baseUrl:e,headers:t}){this._baseUrl=e,this._headers=t}_isResponseOk(e){return e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`)}getDataRequest(e){return fetch(`https://${this._baseUrl}/data/${e}`,{headers:this._headers}).then(e=>this._isResponseOk(e))}getCustomRequest(e){return fetch(`https://${this._baseUrl}/custom/${e}`,{headers:this._headers}).then(e=>this._isResponseOk(e))}getSharedTable(e){return fetch(`https://${this._baseUrl}/${e}`,{headers:this._headers}).then(e=>this._isResponseOk(e))}getReviewRequest(e){return fetch(`https://${this._baseUrl}/reviews/${e}`,{headers:this._headers}).then(e=>this._isResponseOk(e))}sendForm(e,t){return fetch(`https://${this._baseUrl}/forms/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),isBase64Encoded:!1}).then(e=>(console.log(e),this._isResponseOk(e)))}}class r{constructor({formSubmitHandler:e,formCleanError:t,checherValidation:s},o,n){this._formSubmitHandler=e,this._formCleanError=t,this._formElement=o,this._inputSelector=n,this._checker=s}_getInputValues(){return this._inputList=this._formElement.querySelectorAll(this._inputSelector),this._formValues={},this._inputList.forEach(e=>{"checkbox"===e.type?(this._formValues[e.name]||(this._formValues[e.name]=[]),e.checked&&this._formValues[e.name].push(e.value)):"radio"===e.type?e.checked&&(this._formValues[e.name]=e.value):this._formValues[e.name]=e.value}),localStorage.getItem("clientId")&&(this._formValues.clientId=localStorage.getItem("clientId")),this._formValues.page=window.location.pathname,console.log("Поля формы на отправку",this._formValues),this._formValues}cleanAll(){this._formElement.reset(),this._formCleanError()}setEventListeners(){this._formElement.addEventListener("submit",e=>{e.preventDefault(),this._checker()&&this._formSubmitHandler(this._getInputValues())})}}function i(e,t,s,o,n){switch(e){case"default":default:t.textContent=s;break;case"loading":t.textContent=o;break;case"sended":t.textContent=n}}const a={inputSelector:".form__input",submitButtonSelector:".form__submit-button",inactiveButtonClass:"form__submit-button_disabled",inputErrorClass:"form__input_type_error",errorClass:"form__input-error_visible"};class l{constructor(e,t){this._modal=document.querySelector(e),this._buttonClose=this._modal.querySelector(".popup-button-close"),this._closeButtonSelector=".popup-button-close",this._openedClass="popup_opened",this._handleEscButton=e=>{"Escape"===e.key&&this.close()},this._handleOverlayClick=e=>{e.target.classList.contains("popup_opened")&&this.close()},this._isOpened=!1}open(){this._modal.classList.add(this._openedClass),this._isOpened=!0,this._isEscHandleEnabled&&document.addEventListener("keydown",this._handleEscButton),this._isOverlayEnabled&&this._modal.addEventListener("mousedown",this._handleOverlayClick),this._isBodyFixWhenOpen&&document.querySelector("body").classList.add("body-fixed")}close(){this._modal.classList.remove(this._openedClass),this._isOpened=!1,this._isEscHandleEnabled&&document.removeEventListener("keydown",this._handleEscButton),this._isOverlayEnabled&&this._modal.removeEventListener("mousedown",this._handleOverlayClick),this._isBodyFixWhenOpen&&document.querySelector("body").classList.remove("body-fixed")}setEventListeners({overlay:e=!0,esc:t=!0,bodyfix:s=!0}={}){this._isOverlayEnabled=e,this._isEscHandleEnabled=t,this._isBodyFixWhenOpen=s,this._buttonClose.addEventListener("mousedown",()=>{this.close()})}}class c extends l{constructor({handleClose:e,formConfig:t,headingSelector:s,commentSelector:l,buttonCloseSelector:c},h){super(h),c&&(this._buttonClose=this._modal.querySelector(c)),this._formInstance=function(e){const{formSelector:t,formId:s,handleCloseCallback:l,handleSuccessSendedCallback:c,buttonText:h="Оставить заявку",loadingText:u="Отправляем...",successText:p="Отправлено успешно!",newFormConfig:d,isStepValidation:m=!1,dataTransformCallback:_}=e,b=d||a;console.log("configForm",b);const f=document.querySelector(t);if(!f)return void console.warn(`Форма ${t} не найдена`);const E=f.querySelector(b.submitButtonSelector),S=new n({baseUrl:"api.termoblok.ru",headers:{Accept:"application/json","Content-Type":"application/json;charset=utf-8"}}),g=new o(b,f);m?g.enableStepValidation():g.enableValidation();const v=new r({formSubmitHandler:e=>{let t=e;_&&(t=_(e)),i("loading",E,h,u,p),S.sendForm(s,t).then(t=>{i("sended",E,h,u,p),c?.(t,e)}).catch(e=>console.log(e)).finally(()=>{f.reset(),setTimeout(()=>{i("default",E,h,u,p)},900),l&&l()})},formCleanError:()=>{},checherValidation:e=>!g.hasInvalidInput()||(g.showErrors(),!1)},f,b.inputSelector);return v.setEventListeners(),{form:f,formValidator:g,formStatic:v}}({...t,formSelector:`${h} form`,handleCloseCallback:()=>{this.close()}}),this._formElement=this._formInstance.form,this._formValidator=this._formInstance.formValidator,this._heading=this._modal.querySelector(s),this._comment=this._modal.querySelector(l),e&&(this._handleCloseFunc=e),this._step=0}increaseStep(){this._step=1}decreaseStep(){this._step=0}open(e,t){this._heading&&(this._heading.textContent=e||"Отправить заявку"),this._comment&&(this._comment.textContent=t||""),super.open()}close(){super.close(),this._handleCloseFunc&&this._handleCloseFunc(),this._formElement.reset(),this._formValidator.cleanAllErrors()}setEventListeners(e){super.setEventListeners(e)}setSubmitHandler(e){this._formInstance.formStatic.setSubmitHandler(e)}validate(){return this._formValidator.hasInvalidInput()}}function h(e){const{popupSelector:t,buttonOpenSelector:s,formConfig:o,popupConfig:n={}}=e,r=new c({...n,formConfig:{...o,formSelector:`${t} form`}},t),i=document.querySelector(s);return i?(i.addEventListener("click",e=>{e.preventDefault(),r.open(n.heading,n.comment)}),r.setEventListeners({overlay:!1,esc:!1}),r):(console.warn(`Кнопка ${s} не найдена`),r.setEventListeners({overlay:!1,esc:!1}),r)}s.p,new URL(s(72400),s.b),new URL(s(82542),s.b),new URL(s(57971),s.b),new URL(s(86439),s.b),new URL(s(70654),s.b),new URL(s(99323),s.b),new URL(s(88951),s.b),new URL(s(45934),s.b),new URL(s(67133),s.b),new URL(s(62408),s.b),new URL(s(94939),s.b),new URL(s(20611),s.b),new URL(s(72673),s.b),new URL(s(31728),s.b),new URL(s(3008),s.b);const u=h({popupSelector:".popup-raschet",buttonOpenSelector:".popup-raschet-button",formConfig:{formId:"big-form",loadingText:"Отправляем заявку с формы 2 степа...",newFormConfig:{inputSelector:".raschet-bem__input",submitButtonSelector:".raschet-bem__submit-button",inactiveButtonClass:"raschet-bem__submit-button_disabled",inputErrorClass:"raschet-bem__input_type_error",errorClass:"raschet-bem__input-error_visible"},isStepValidation:!0},popupConfig:{buttonCloseSelector:".popup__button-close",handleClose:()=>{console.log('Попап "в 2 шага" закрыт')}}}),p=document.querySelector(".form-back-button"),d=document.querySelector(".form-next-step"),m=document.querySelector(".popup-absolute");p.addEventListener("mousedown",e=>{m.classList.remove("popup__form-fio_opened"),u.decreaseStep(),console.log(u._step)}),d.addEventListener("mousedown",()=>{u._formValidator.checkStep(0)&&(m.classList.add("popup__form-fio_opened"),u.increaseStep(),console.log(u._step))});const _=h({popupSelector:".popup-callback",buttonOpenSelector:".popup-callback-button",formConfig:{formId:"small-form",loadingText:"Отправляем заявку в термоблок 2...",newFormConfig:{inputSelector:".raschet-bem__input",submitButtonSelector:".button-bem_submit",inactiveButtonClass:"popup__button-save_disabled",inputErrorClass:"raschet-bem__input_type_error",errorClass:"raschet-bem__input-error_visible"}},popupConfig:{buttonCloseSelector:".popup__button-close",heading:"Заказать обратный звонок ПФФ",comment:"Мы перезвоним в течение 15 минут",headingSelector:".raschet-bem__title",commentSelector:"#comment-free-input",handleClose:()=>{console.log('Попап "Перезвоните мне" закрыт')}}});document.querySelector(".mainmodels__raschet_ti")?.addEventListener("mousedown",()=>{u.open()}),document.querySelector(".mainmodels__raschet_p")?.addEventListener("mousedown",()=>{_.open()})})();