(()=>{"use strict";var t={456:(t,e,s)=>{s.d(e,{A:()=>n});var o=s(446);class n{constructor(t){this._modal=document.querySelector(t),this._handleEscButton=t=>{t.key===o.aL&&this.close()},this._handleOverlayClick=t=>{t.target.classList.contains("popup_opened")&&this.close()},this._modal.querySelector(".popup__button-close").innerHTML=''}open(){this._modal.classList.add("popup_opened"),console.log("222"),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)}setEventListeners(){this._modal.querySelector(".popup__button-close").addEventListener("mousedown",(()=>{this.close()}))}}},446:(t,e,s)=>{s.d(e,{aL:()=>o});const o="Escape"},966:(t,e,s)=>{function o(t,e,s,o){e.textContent=t?o:s}function n(t,e){return e.filter((e=>e.id===t))[0]}function i(t,e){return t.some((t=>e.includes(t)))}function r(t,e){return console.log(t,e),!t.some((t=>!e.includes(t)))}function l(t,e){return e.filter((e=>r(t,e.tags)))}function a(t,e){return e.filter((e=>r(t,e.tagsForPtoPage)))}function u(){let t=window.innerWidth;return window.addEventListener("resize",(function(){var e;setTimeout((e=window.innerWidth,void(t=e)),1500)})),t}function c(){let t=window.innerWidth;return window.addEventListener("resize",(function(){var e;e=window.innerWidth,t=e})),t}function h(t,e){let s=null;return function(...o){s||(s=setTimeout((()=>{t(...o),clearTimeout(s),s=null}),e))}}s.r(e),s.d(e,{articlesMapper:()=>l,articlesMapperForPtoPage:()=>a,getItemByUniqueId:()=>n,isFullInclude:()=>r,isIntersection:()=>i,renderLoading:()=>o,throttle:()=>h,useWindowSize:()=>u,useWindowSizeTest:()=>c})},130:(t,e,s)=>{s.d(e,{b:()=>r}),s(456);const o=document.querySelector(".feedback-button"),n=document.querySelector(".feedback-form"),i=n.querySelector(".form-close-button");function r(){n.classList.add("hidden")}o.addEventListener("click",(()=>{n.classList.remove("hidden"),console.log("333")})),i.addEventListener("click",(()=>{r()}))}},e={};function s(o){var n=e[o];if(void 0!==n)return n.exports;var i=e[o]={exports:{}};return t[o](i,i.exports,s),i.exports}s.d=(t,e)=>{for(var o in e)s.o(e,o)&&!s.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t=s(130);s(456).A,s(446);const{renderLoading:e}=s(966),o={inputSelector:".form__input",submitButtonSelector:".form__submit-button",inactiveButtonClass:"form__submit-button_disabled",inputErrorClass:"form__input_type_error",errorClass:"form__input-error_visible"},n=new class{constructor({baseUrl:t,headers:e}){this._baseUrl=t,this._headers=e}_isResponseOk(t){return t.ok?t.json():Promise.reject(`Ошибка: ${t.status}`)}getInitialNews(){return fetch("https://functions.yandexcloud.net/d4e9aq1evmfdb0cc7uo4?base=news",{headers:this._headers}).then((t=>this._isResponseOk(t)))}sendCallForm(t){return fetch(`${this._baseUrl}`,{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}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then((t=>this._isResponseOk(t)))}}({baseUrl:"https://functions.yandexcloud.net/d4et5mddo52k0fjps5hf",headers:{Accept:"application/json","Content-Type":"application/json;charset=utf-8"}}),i=document.forms.upFooterForm,r=i.querySelector(o.submitButtonSelector),l=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 o=this._formElement.querySelector(".second-step"),n=o.querySelector(".second-step-button"),i=Array.from(o.querySelectorAll(this._inputSelector));this._sets.push({inputs:i,button:n}),this._setStepEventListeners(this._sets)}}(o,i);l.enableValidation();const a=new class{constructor({formSubmitHandler:t,formCleanError:e,checherValidation:s},o,n){this._formSubmitHandler=t,this._formCleanError=e,this._formElement=o,this._inputSelector=n,this._absolutePopup=this._formElement.querySelector(".popup-absolute"),this._checker=s}_getInputValues(){return this._inputList=this._formElement.querySelectorAll(this._inputSelector),this._formValues={},this._inputList.forEach((t=>{if(t.dataset.alias){if("moshnost"===t.name)return this._formValues[t.dataset.alias]=t.value;if("rashod"===t.name)return this._formValues[t.dataset.alias]=t.value;this._formValues[t.dataset.alias]=t.value}else"uzel"===t.name?this._formValues["Оборудование"]=Array.from(this._formElement.elements.uzel).filter((t=>t.checked)).map((t=>t.dataset.aliasob)):this._formValues[t.name]=t.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(),this._absolutePopup.classList.contains("popup__form-fio_opened")&&(console.log("Открыто!"),this._absolutePopup.classList.remove("popup__form-fio_opened"))}setEventListeners(){this._formElement.addEventListener("submit",(t=>{t.preventDefault(),this._checker()&&this._formSubmitHandler(this._getInputValues())}))}}({formSubmitHandler:s=>{e(!0,r,"Оставить заявку","Отправляем..."),n.sendBigForm(s).then((t=>{console.log(t),a.cleanAll()})).catch((t=>console.log(t))).finally((()=>{l.disableSaveButton(),i.reset(),e(!1,r,"Оставить заявку","Отправляем..."),(0,t.b)()}))},formCleanError:()=>{},checherValidation:t=>!l.hasInvalidInput()||(l.showErrors(),!1)},i,o.inputSelector);a.setEventListeners()})()})();