// @ts-check
(()=>{
  'use strict';
  const App=window.IUS_TEMPLATE,{utils}=App;
  function dialogBehaviour(){
    utils.$$('[data-dialog-close]').forEach(b=>b.addEventListener('click',()=>utils.closeDialog(utils.$('[data-details-dialog]'))));
    utils.$$('dialog').forEach(dialog=>dialog.addEventListener('click',e=>{if(e.target===dialog)utils.closeDialog(dialog)}));
    document.addEventListener('keydown',e=>{if(e.key!=='Escape')return;const open=utils.$$('dialog[open]').at(-1);if(open)utils.closeDialog(open);const dash=utils.$('[data-dashboard].is-inspecting');if(dash){dash.classList.remove('is-inspecting');document.body.classList.remove('dashboard-inspecting')}});
  }
  function contact(){const email=App.data.siteConfig.brand.email;utils.$$('[data-contact-link]').forEach(a=>{a.href=`mailto:${email}`;a.textContent=email});utils.$('[data-copy-email]')?.addEventListener('click',async()=>{await utils.copy(email);const b=utils.$('[data-copy-email]');b.textContent=App.modules.i18n.t('contact.copied');setTimeout(()=>b.textContent=App.modules.i18n.t('contact.copy'),1500)})}
  function staticDetails(){utils.$$('[data-year]').forEach(el=>el.textContent=String(new Date().getFullYear()))}
  function init(){
    App.modules.theme.init();App.modules.i18n.init();App.modules.uiDemo.init();App.modules.lightbox.init();App.modules.projects.init();App.modules.comments.init();App.modules.posts.init();App.modules.forms.init();App.modules.company.init();App.modules.socials.init();App.modules.motion.init();dialogBehaviour();contact();staticDetails();
    document.dispatchEvent(new CustomEvent('ius:ready'));
  }
  if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init,{once:true});else init();
})();
