<script type="module">
  (function() {
    
    function initTwikoo() {
      const el = document.getElementById('twikoo_container');
      if (!el) return;
      
      function load_twikoo() {
        utils.css('<%- url_for('/css/comments/twikoo.css') %>?v=<%- stellar_info('version') %>');
        utils.js('<%- theme.comments.twikoo.js %>', {defer: true}).then(function () {
          const path = el.getAttribute('comment_id') ?? decodeURI(window.location.pathname);
          twikoo.init(Object.assign(<%- JSON.stringify(theme.comments.twikoo) %>, {
            el: '#twikoo_container',
            path: path,
          }));
        });
      }
      
      util.viewportLazyload(el, load_twikoo);
    }
    
    // Initialize on page load
    initTwikoo();
  })();
</script>
