/**
* @package DPCalendar
* @copyright Digital Peak GmbH. <https://www.digital-peak.com>
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
*/
const e=window.DPCalendar||{};window.DPCalendar=e,Joomla.loadOptions(),e.requestCounter=0,e.modal=(e,t,o,r)=>{import("../vendor/tingle.js/src/tingle.css.min.js?43859213"),import("../vendor/tingle.js/dist/tingle.min.js?43859213").then((()=>{const n=new tingle.modal({footer:!1,stickyFooter:!1,closeMethods:["overlay","button","escape"],cssClass:["dpcalendar-modal"],closeLabel:Joomla.Text._("COM_DPCALENDAR_CLOSE"),onClose:()=>{r&&r(n.modalBox.children[0].querySelector("iframe"))}});t&&document.body.clientWidth>t&&(isNaN(t)||(t+="px"),document.querySelector(".tingle-modal-box").style.width=t),o||(o="80vh"),isNaN(o)||(o+="px");const s=new URL(location.protocol+"//"+location.host+e);s.searchParams.set("tmpl","component"),n.setContent('<iframe style="width:100%; height:'+o+'" src="'+s.toString()+'" frameborder="0" allowfullscreen></iframe>'),n.open()}))},e.print=e=>{document.body.outerHTML=document.querySelector(e).outerHTML,window.addEventListener("afterprint",(()=>{setTimeout((()=>window.location.reload(!0)),2e3)})),window.print()},e.encode=e=>e.replace(/&/g,"&"),e.pad=(e,t)=>{let o=e+"";for(;o.length<t;)o="0"+o;return o},e.formToQueryString=(e,t)=>{if(!e)return"";e instanceof HTMLFormElement||t||(t="input, select");const o=t?e.querySelectorAll(t):e.elements;let r,n=[];for(let e=0;e<o.length;e++)if(r=o[e],r.name&&!r.disabled&&"file"!=r.type&&"reset"!=r.type&&"submit"!=r.type&&"button"!=r.type)if("select-multiple"==r.type)for(let t=o[e].options.length-1;t>=0;t--)r.options[t].selected&&(n[n.length]=encodeURIComponent(r.name)+"="+encodeURIComponent(r.options[t].value));else("checkbox"!=r.type&&"radio"!=r.type||r.checked)&&(n[n.length]=encodeURIComponent(r.name)+"="+encodeURIComponent(r.value));return n.join("&").replace(/%20/g,"+")},e.arrayToQueryString=(t,o)=>{const r=[];let n;for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const s=o?o+"["+n+"]":n,l=t[n];r.push(null!==l&&"object"==typeof l?e.arrayToQueryString(l,s):encodeURIComponent(s)+"="+encodeURIComponent(l))}return r.join("&").replace(/%20/g,"+")},e.currentLocation=t=>!!navigator.geolocation&&(navigator.geolocation.getCurrentPosition((o=>{let r="location.loc";-1==window.location.href.indexOf("administrator")&&(r="locationform.loc"),e.request("task="+r+"&loc="+encodeURIComponent(o.coords.latitude+","+o.coords.longitude),(e=>t(e.data.formatted)))}),(e=>{Joomla.renderMessages({error:[e.message]})})),!0),e.request=(t,o,r,n,s,l)=>{const a=!1!==n?document.querySelector(".dp-loader"):null;a&&a.classList.remove("dp-loader_hidden"),r||(r=""),r+=(r?"&":"")+Joomla.getOptions("csrf.token")+"=1",e.requestCounter++,Joomla.request({url:Joomla.getOptions("system.paths").base+"/index.php?option=com_dpcalendar&"+t,method:null==s?"POST":s,data:r,onSuccess:r=>{e.requestCounter--,a&&a.classList.add("dp-loader_hidden");try{const e=JSON.parse(r);null!=e.messages&&0!==e.messages.length&&document.getElementById("system-message-container")&&Joomla.renderMessages(e.messages),o&&o(e)}catch(e){document.getElementById("system-message-container")&&Joomla.renderMessages({error:[t+"<br>"+e.message]}),l&&l()}},onError:o=>{e.requestCounter--,a&&a.classList.add("dp-loader_hidden");try{l&&l()}catch(e){document.getElementById("system-message-container")&&Joomla.renderMessages({error:[t+"<br>"+e.message]})}if(o.responseText)try{const e=JSON.parse(o.responseText);if(null!=e.messages&&0!==e.messages.length&&document.getElementById("system-message-container")&&Joomla.renderMessages(e.messages),e.error)throw new Error(e.message+(e.trace?"<br>"+e.trace:""))}catch(e){document.getElementById("system-message-container")&&Joomla.renderMessages({error:[t+"<br>"+e.message]})}}})},e.debounce=(e,t,o)=>{let r;return null==t&&(t=500),null==o&&(o=!1),function(){const n=this,s=arguments,l=o&&!r;clearTimeout(r),r=setTimeout((()=>{r=null,o||e.apply(n,s)}),t),l&&e.apply(n,s)}},e.slideToggle=(e,r)=>{if(e)return"none"===window.getComputedStyle(e).display?o(e,r):t(e,r)},document.querySelectorAll(".dp-button-print").forEach((t=>{t.addEventListener("click",(()=>e.print(t.getAttribute("data-selector"))))})),document.querySelectorAll(".dp-button-action[data-href]").forEach((e=>{e.addEventListener("click",(t=>{t.preventDefault();let o=e.getAttribute("data-confirmtext");return o||(o=Joomla.Text._("COM_DPCALENDAR_CONFIRM_DELETE")),!(e.classList.contains("dp-action-delete")&&!confirm(o))&&("new"==e.getAttribute("data-target")?(window.open(e.getAttribute("data-href")),!1):(location.href=e.getAttribute("data-href"),!1))}))})),document.querySelectorAll(".dp-tabs__input").forEach((e=>{e.addEventListener("click",(()=>localStorage.setItem("dp-tabs-"+e.name,e.id))),localStorage.getItem("dp-tabs-"+e.name)==e.id&&(e.checked=!0)}));let t=(e,t)=>{e.style.transitionProperty="height, margin, padding",e.style.transitionDuration="700ms",e.style.boxSizing="border-box",e.style.height=e.offsetHeight+"px",e.offsetHeight,e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,window.setTimeout((()=>{e.style.display="none",e.style.removeProperty("height"),e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property"),t&&t(!1,e)}),710)},o=(e,t)=>{e.style.removeProperty("display");let o=window.getComputedStyle(e).display;"none"===o&&(o="block"),e.style.display=o;let r=e.offsetHeight;e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,e.offsetHeight,e.style.boxSizing="border-box",e.style.transitionProperty="height, margin, padding",e.style.transitionDuration="700ms",e.style.height=r+"px",e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),window.setTimeout((()=>{e.style.removeProperty("height"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property"),t&&t(!0,e)}),710)};