function ReCaptchaShareMailingResponse(){document.querySelectorAll('[data-recaptcha="onsuccess"]').forEach(function(n){n.removeAttribute("disabled")})}var CDUtils=CDUtils||{},TraficRestrictionsConfig=TraficRestrictionsConfig||{},CDTraficResctrictionsUtils=CDTraficResctrictionsUtils||{},TraficRestrictionsTrainBatch;class TraficRestrictionsFormRegion{constructor(n){this.form=null;this._krajElement=null;this._krajSelectHK=null;this._krajSelector='[data-traficrestrictionsregion="region"]';this._tratElement=null;this._tratSelectHK=null;this._tratSelector='[data-traficrestrictionsregion="track"]';this._calendarSelector='[data-traficrestrictionsregion="calendar"]';this._calendarElement=null;this._submitSelector='[data-traficrestrictionsregion="submit"]';this._submitElement=null;this._wrapperSelector='[data-traficrestrictionsregion="wrapper"]';this._wrapperElement=null;this.form=n;this.init()}init(){var n=this;this._krajElement=document.querySelector(this._krajSelector);this._tratElement=document.querySelector(this._tratSelector);this._krajSelectHK=new SelectHK(this._krajElement);this._tratSelectHK=new SelectHK(this._tratElement);this._calendarElement=document.querySelector(this._calendarSelector);this._calendar=new DatePickerV3(this._calendarElement);this._calendar.init();this._submitElement=document.querySelector(this._submitSelector);this._wrapperElement=document.querySelector(this._wrapperSelector);this._krajElement.addEventListener("change",function(){n.RefreshForm()});this._calendar.calendar.events.on("change",function(){n.RefreshForm()});n.form.addEventListener("submit",function(t){return t.preventDefault(),n.LoadData(),!1});n.LoadData()}CreateHeading(n){var t=document.createElement("h2");return t.className="h1",t.textContent=n,t}ShowData(n){var y=this,i=0,p=50,t=[],f,h,w,c,r,l,a,v,e,o,s,u,b;if(n.Mimo!=null&&n.Mimo.length!=undefined&&(t=t.concat(n.Mimo)),n.Vyluky!=null&&n.Vyluky.length!=undefined&&(t=t.concat(n.Vyluky)),this._wrapperElement.innerHTML="",f=document.createElement("div"),f.setAttribute("id","PagesWrapperTRRegion"),this._wrapperElement.append(f),t.length==0){h=new TraficRestrictionsNoDataHelper;h.SetIcon();w=h.CreateElement();this._wrapperElement.append(w);return}for(c=0;c<Math.ceil(t.length/p);c++)for(r=document.createElement("div"),r.className="pagitm",f.append(r),l=!1,a=!1,v=0;v<p;v++)t[i]!=undefined&&(l||t[i].Type!="mimo"||(r.append(y.CreateHeading(CDTraficResctrictionsUtils.Get("headingMimo"))),l=!0),a||t[i].Type!="vyluka"||(r.append(y.CreateHeading(CDTraficResctrictionsUtils.Get("headingVyluky"))),a=!0),t[i].Type=="mimo"?(e=new TraficRestrictionsMimoHelper(t[i]),o=e.CreateElement(),r.append(o)):t[i].Type=="vyluka"&&(e=new TraficRestrictionsVylukaHelper(t[i]),o=e.CreateElement(),r.append(o))),i++;s=document.createElement("div");s.className="pagination-wrap";this._wrapperElement.append(s);u=document.createElement("ul");u.setAttribute("data-cdpagination","");u.setAttribute("data-cdpagination-smooth","#PagesWrapperTRRegion");u.setAttribute("data-cdpagination-pagelimit","1");u.setAttribute("data-cdpagination-target","#PagesWrapperTRRegion .pagitm");s.append(u);b=$("[data-cdpagination]").CDPagination()}LoadData(){var n=this,t=moment(n._calendar.calendar._currentDate),i={kraj:n._krajElement.value,trat:n._tratElement.value,date:t.locale("cs").format("DD.MM.YYYY")};$.ajax({url:TraficRestrictionsConfig.LoadDataRegionUrl,method:"POST",data:i,cache:!1,beforeSend:function(){},success:function(t){n.ShowData(t)},error:function(){}})}RefreshForm(){var n=this,t;n._tratElement.querySelectorAll("option").forEach(n=>n.remove());t=moment(n._calendar.calendar._currentDate);$.ajax({url:TraficRestrictionsConfig.RefreshFormUrl,method:"POST",data:{kraj:n._krajElement.value,date:t.locale("cs").format("DD.MM.YYYY")},cache:!1,beforeSend:function(){},success:function(t){if(t.Trate!=undefined){var i=document.createElement("option");i.setAttribute("value",0);i.textContent="Všechny tratě";n._tratElement.append(i);$.each(t.Trate,function(t,i){var r=document.createElement("option");r.setAttribute("value",i.Id);r.textContent=i.CisloNazev;n._tratElement.append(r)});n._tratSelectHK.destroy();n._tratSelectHK=new SelectHK(n._tratElement)}},error:function(){}})}static register(n){[...document.querySelectorAll(n)].forEach(n=>{new TraficRestrictionsFormRegion(n)})}}$(document).ready(function(){TraficRestrictionsFormRegion.register('[data-traficrestrictionsregion="form"]')});var CDUtils=CDUtils||{},TraficRestrictionsConfig=TraficRestrictionsConfig||{},CDTraficResctrictionsUtils=CDTraficResctrictionsUtils||{};class TraficRestrictionsFormTrain{constructor(n){this._calendarSelector='[data-traficrestrictionstrain="calendar"]';this._calendarElement=null;this._submitSelector='[data-traficrestrictionstrain="submit"]';this._submitElement=null;this._trainSelector='[data-traficrestrictionstrain="train"]';this._trainElement=null;this._wrapperSelector='[data-traficrestrictionstrain="wrapper"]';this._wrapperElement=null;this.form=n;this.init()}init(){var n=this;this._calendarElement=document.querySelector(this._calendarSelector);this._calendar=new DatePickerV3(this._calendarElement);this._calendar.init();this._submitElement=document.querySelector(this._submitSelector);this._wrapperElement=document.querySelector(this._wrapperSelector);this._trainElement=document.querySelector(this._trainSelector);n.form.addEventListener("submit",function(t){return t.preventDefault(),n.LoadData(),!1});this._trainElement.value!=""&&n.LoadData()}CreateHeading(n){var t=document.createElement("h2");return t.className="h1",t.textContent=n,t}ShowData(n){var u=this,t=0,i,r;if(this._wrapperElement.innerHTML="",n.Empty===!0){i=new TraficRestrictionsInfoBoxHelper;i.SetIcon();r=i.CreateElement();this._wrapperElement.append(r);return}if(n.Trains.length==0){i=new TraficRestrictionsNoDataHelper;i.SetTrainName(u._trainElement.value);r=i.CreateElement();this._wrapperElement.append(r);return}n.Trains.forEach(function(n){var r=document.createElement("div"),o,f,e;u._wrapperElement.append(r);r.append(u.CreateHeading(n.Name));var i=[];for(n.Mimo!=null&&n.Mimo.length!=undefined&&(i=i.concat(n.Mimo)),n.Vyluky!=null&&n.Vyluky.length!=undefined&&(i=i.concat(n.Vyluky)),o=0;o<i.length;o++)i[t]!=undefined&&(i[t].Type=="mimo"?(f=new TraficRestrictionsMimoHelper(i[t]),e=f.CreateElement(),r.append(e)):i[t].Type=="vyluka"&&(f=new TraficRestrictionsVylukaHelper(i[t]),e=f.CreateElement(),r.append(e))),t++})}LoadData(){var n=this,t=moment(n._calendar.calendar._currentDate),i={train:n._trainElement.value,date:t.locale("cs").format("DD.MM.YYYY")};$.ajax({url:TraficRestrictionsConfig.LoadDataTrainUrl,method:"POST",data:i,cache:!1,beforeSend:function(){},success:function(t){n.ShowData(t)},error:function(){}})}static register(n){[...document.querySelectorAll(n)].forEach(n=>{new TraficRestrictionsFormTrain(n)})}}$(document).ready(function(){TraficRestrictionsFormTrain.register('[data-traficrestrictionstrain="form"]')});CDTraficResctrictionsUtils=CDTraficResctrictionsUtils||{};class TraficRestrictionsInfoBoxHelper{constructor(){this._icon=null;this._trainName=null}SetIcon(){var n=document.createElement("span");n.className="icon icon-info";this._icon=n}CreateElement(){var n=this,t,i;return n._element=document.createElement("div"),n._element.className="uncommon-events",t=document.createElement("div"),t.className="info-box ",n._element.append(t),i=document.createElement("p"),t.append(i),i.innerText=CDTraficResctrictionsUtils.Get("trainEmpty"),n._icon!=null&&t.prepend(n._icon),n._element}}CDTraficResctrictionsUtils=CDTraficResctrictionsUtils||{};class TraficRestrictionsMimoHelper{constructor(n){this.data=n}CreateElement(){var n=this,i,t,u,r,f,e;return n._element=document.createElement("a"),n._element.className="restrictions-link",n._element.setAttribute("href",n.data.Href),i=document.createElement("div"),i.className="restrictions-info",n._element.append(i),t=document.createElement("div"),t.className="restrictions-info__content",i.append(t),u=document.createElement("div"),u.className="restrictions-info__icons",i.append(u),n.data.Useky.forEach(function(n){var i=document.createElement("h3");i.className="restrictions-info__header";i.innerHTML=n;t.append(i)}),r=document.createElement("p"),r.className="restrictions-info__text",r.innerHTML=CDTraficResctrictionsUtils.Get("mimoPricina")+n.data.Pricina,t.append(r),n.data.Active||(f=document.createElement("span"),f.className="green-text",f.innerHTML=CDTraficResctrictionsUtils.Get("mimoEnd"),r.prepend(f)),e=document.createElement("p"),e.className="restrictions-info__text",e.innerHTML=CDTraficResctrictionsUtils.Get("mimoOd")+n.data.Od+" / "+CDTraficResctrictionsUtils.Get("mimoDo")+n.data.Do,t.append(e),n.data.Icons.forEach(function(n){var t=document.createElement("span");t.className=n.Ikona;t.setAttribute("title",n.Type);u.append(t)}),n._element}}CDTraficResctrictionsUtils=CDTraficResctrictionsUtils||{};class TraficRestrictionsNoDataHelper{constructor(){this._icon=null;this._trainName=null}SetIcon(){var n=document.createElement("span");n.className="icon-smile uncommon-event-icon";this._icon=n}SetTrainName(n){var t=document.createElement("strong");t.textContent=n+": ";this._trainName=t}CreateElement(){var n=this,i,t;return n._element=document.createElement("div"),n._element.className="uncommon-events",i=document.createElement("div"),i.className="uncommon-event-done "+(n._icon!=null?"uncommon-event-done--with-icon":""),n._element.append(i),t=document.createElement("p"),i.append(t),t.innerText=CDTraficResctrictionsUtils.Get("noData"),n._icon!=null&&t.prepend(n._icon),n._trainName!=null&&t.prepend(n._trainName),n._element}}CDUtils=CDUtils||{};CDTraficResctrictionsUtils={Repository:[],Get:function(n){try{return this.Repository[CDUtils.Lang][n]}catch(t){return""}}};CDTraficResctrictionsUtils.Repository.cs={headingMimo:"Neplánované mimořádnosti",headingVyluky:"Plánované výluky",mimoPricina:"Mimořádnost: ",mimoEnd:"UKONČENO: ",mimoOd:"Počátek: ",mimoDo:"Plánovaný konec: ",noData:"Bez omezení provozu",vylukaOd:"Výluka, počátek od ",vylukaDo:"Plánovaný konec: ",trainEmpty:"Zadejte číslo vlaku "};var CDUtils=CDUtils||{},TraficRestrictionsConfig=TraficRestrictionsConfig||{},CDTraficResctrictionsUtils=CDTraficResctrictionsUtils||{};class TraficRestrictionsShareMailForm{constructor(n){this.form=n;this.btns=this.form.querySelectorAll('[type="submit"]');this.validForm=$(n).isValidForm();this.StatusContainer=this.form.querySelector(this.form.dataset.sharemailformStatuscontainer);this.modal=this.form.closest(".modal");this.init()}init(){var n=this;n.form.addEventListener("submit",function(t){return t.preventDefault(),n.SendMail(),!1})}DisableBtns(){var n=this;n.btns.forEach(function(n){n.setAttribute("disabled","disabled")});n.form.classList.add("is-loader-freeze")}EnableBtns(){var n=this;n.btns.forEach(function(n){n.removeAttribute("disabled")});n.form.classList.remove("is-loader-freeze")}ShowError(n){alert(n)}SendMail(){var i=this.validForm.getIsValidByClassSelector(),n,t;i&&(n=this,t=$(n.form).serialize(),$.ajax({url:n.form.action,method:"POST",data:t,cache:!1,beforeSend:function(){n.DisableBtns()},success:function(t){n.EnableBtns();t.Status===!0?location.reload():n.ShowError(t.Error)},error:function(){n.EnableBtns();n.ShowError("Nastala chyba při odesílání e-mailu.")}}))}static register(n){[...document.querySelectorAll(n)].forEach(n=>{new TraficRestrictionsShareMailForm(n)})}}$(document).ready(function(){TraficRestrictionsShareMailForm.register("[data-sharemailform]")});TraficRestrictionsConfig=TraficRestrictionsConfig||{};TraficRestrictionsTrainBatch={Init:function(){var n={trains:[]},t=document.querySelectorAll("[data-traficrestrictionstrainbatch]");t.length!=0&&(t.forEach(function(t){var i=t.dataset.traficrestrictionstrainbatch;n.trains.indexOf(i)==-1&&n.trains.push(i)}),$.ajax({type:"POST",url:TraficRestrictionsConfig.LoadTrainsBatchUrl,data:JSON.stringify(n),contentType:"application/json",beforeSend:function(){},success:function(n){n.Trains!=undefined&&n.Trains.length>0&&n.Trains.forEach(function(n){var t=document.querySelectorAll('[data-traficrestrictionstrainbatch="'+n.Train+'"]');t.forEach(function(t){var i=document.createElement("span");i.className="number";i.textContent=n.Count;t.append(i)})})}}))}};$(function(){TraficRestrictionsTrainBatch.Init()});class TraficRestrictionsVylukaHeaderChange{constructor(n){this.item=n;this.Init()}Init(){var n=this;n.item.querySelectorAll('[data-trvhc-bind="next"]').forEach(function(t){t.addEventListener("click",function(){n.ClearAll();n.Show(t.closest(".trvhc-item").nextElementSibling)})});n.item.querySelectorAll('[data-trvhc-bind="prev"]').forEach(function(t){t.addEventListener("click",function(){n.ClearAll();n.Show(t.closest(".trvhc-item").previousElementSibling)})})}ClearAll(){var n=this;n.item.querySelectorAll(".trvhc-item").forEach(function(n){n.classList.remove("show")})}Show(n){n.classList.add("show")}static register(n){[...document.querySelectorAll(n)].forEach(n=>{new TraficRestrictionsVylukaHeaderChange(n)})}}$(document).ready(function(){TraficRestrictionsVylukaHeaderChange.register("[data-trvhc]")});CDTraficResctrictionsUtils=CDTraficResctrictionsUtils||{};class TraficRestrictionsVylukaHelper{constructor(n){this.data=n}CreateElement(){var n=this,i,t,u,f,r,e;return n._element=document.createElement("a"),n._element.className="restrictions-link",n._element.setAttribute("href",n.data.Href),i=document.createElement("div"),i.className="restrictions-info",n._element.append(i),t=document.createElement("div"),t.className="restrictions-info__content",i.append(t),u=document.createElement("div"),u.className="restrictions-info__icons",i.append(u),n.data.Useky.forEach(function(n){var i=document.createElement("h3");i.className="restrictions-info__header";i.innerHTML=n;t.append(i)}),f=document.createElement("p"),f.className="restrictions-info__text",f.innerHTML=CDTraficResctrictionsUtils.Get("vylukaOd")+n.data.Od+" / "+CDTraficResctrictionsUtils.Get("vylukaDo")+n.data.Do,t.append(f),n.data.Icon!=undefined&&(r=document.createElement("p"),r.className="restrictions-info__text restrictions-info__text--red",r.innerHTML=n.data.Icon.Type,t.append(r),e=document.createElement("span"),e.className=n.data.Icon.Ikona,r.prepend(e)),n.data.Icons.forEach(function(n){var t=document.createElement("span");t.className=n.Ikona;t.setAttribute("title",n.Type);u.append(t)}),n._element}}