{
  "version": 3,
  "sources": ["/cdn/shop/t/4/assets/ebs-drawer-promo.js"],
  "sourcesContent": ["/* EBS Drawer Promo - gestione link pubblici, drawer nativo e copia codice */\n(function () {\n  'use strict';\n  const ebs_hash = '#promo-vantaggi';\n  if (window.Shopify?.designMode) document.documentElement.classList.add('ebs-promo-editor');\n\n\n  const ebs_copy_timers = new WeakMap();\n\n  function ebs_show_copy_tooltip(ebs_status, ebs_message, ebs_success = false) {\n    if (!ebs_status) return;\n\n    const ebs_previous_timer = ebs_copy_timers.get(ebs_status);\n\n    if (ebs_previous_timer) {\n      clearTimeout(ebs_previous_timer);\n    }\n\n    ebs_status.textContent = ebs_message;\n    ebs_status.classList.add('is-visible');\n    const ebs_button = ebs_status.closest('.ebs-drawer-promo-card-action-wrap')?.querySelector('.ebs-drawer-promo-copy');\n    if (ebs_button) ebs_button.classList.toggle('is-copied', ebs_success);\n\n    const ebs_timer = setTimeout(() => {\n      ebs_status.classList.remove('is-visible');\n      if (ebs_button) ebs_button.classList.remove('is-copied');\n      ebs_copy_timers.delete(ebs_status);\n    }, 3000);\n\n    ebs_copy_timers.set(ebs_status, ebs_timer);\n  }\n\n\n  async function ebs_copy_text(ebs_text) {\n    if (navigator.clipboard && window.isSecureContext) {\n      await navigator.clipboard.writeText(ebs_text);\n      return;\n    }\n  \n    // Fallback per contesti in cui Clipboard API non \u00E8 disponibile\n    const ebs_input = document.createElement('textarea');\n  \n    ebs_input.value = ebs_text;\n    ebs_input.setAttribute('readonly', '');\n    ebs_input.style.position = 'fixed';\n    ebs_input.style.left = '-9999px';\n  \n    document.body.appendChild(ebs_input);\n    ebs_input.select();\n  \n    try {\n      if (!document.execCommand('copy')) {\n        throw new Error('Clipboard copy failed');\n      }\n    } finally {\n      ebs_input.remove();\n    }\n  }\n\n  function ebs_drawer() { return document.querySelector('drawer-element'); }\n  function ebs_ready() { return !!document.querySelector('#ebs-drawer-promo-content'); }\n  function ebs_open(ebs_source) {\n    const ebs_element = ebs_drawer();\n    if (!ebs_element || !ebs_ready() || typeof ebs_element.open !== 'function') return false;\n    const ebs_viewport = document.querySelector('.layout--viewport');\n    if (ebs_viewport && ebs_viewport.getAttribute('data-drawer-view') === 'ebs-promo' &&\n        ['opening', 'opened'].includes(ebs_viewport.getAttribute('data-drawer-status'))) return true;\n    // Il drawer nativo cambia vista immediatamente sullo stesso lato,\n    // mentre chiude prima un drawer attivo su un altro lato.\n    ebs_element.open('left', 'ebs-promo', ebs_source || document.activeElement);\n    return true;\n  }\n\n\n  // Chiude gli eventuali menu Bootstrap prima di aprire il drawer promo.\n  function ebs_open_after_menus(ebs_source) {\n    const ebs_modals = [...document.querySelectorAll('.ebs-mm.modal.show')];\n\n    if (!ebs_modals.length || !window.bootstrap?.Modal) {\n      return ebs_open(ebs_source);\n    }\n\n    let ebs_pending = ebs_modals.length;\n\n    const ebs_finish = () => {\n      ebs_pending -= 1;\n\n      if (ebs_pending === 0) {\n        const ebs_safe_trigger = document.querySelector(\n          '.announcement--root .ebs-drawer-promo-trigger'\n        );\n\n        ebs_open(ebs_safe_trigger || document.body);\n      }\n    };\n\n    ebs_modals.forEach((ebs_modal) => {\n      ebs_modal.addEventListener('hidden.bs.modal', ebs_finish, { once: true });\n      window.bootstrap.Modal.getOrCreateInstance(ebs_modal).hide();\n    });\n\n    return true;\n  }\n\n\n  function ebs_clear_hash() {\n    if (location.hash === ebs_hash) {\n      history.replaceState(history.state, '', location.pathname + location.search);\n    }\n  }\n  document.addEventListener('click', function (ebs_event) {\n    // Nel Theme Editor i clic sulla card devono selezionare il blocco, non navigare.\n    if (window.Shopify && window.Shopify.designMode && ebs_event.target.closest('.ebs-drawer-promo-card')) {\n      const ebs_link = ebs_event.target.closest('a');\n      if (ebs_link) ebs_event.preventDefault();\n      return;\n    }\n    const ebs_anchor = ebs_event.target.closest('a[href]');\n    if (ebs_anchor) {\n      const ebs_url = new URL(ebs_anchor.href, location.href);\n      if (ebs_url.hash === ebs_hash && (ebs_url.pathname === location.pathname || ebs_url.pathname === \"/\") && ebs_url.origin === location.origin && (ebs_url.search === location.search || !ebs_url.search)) {\n        if (ebs_ready()) {\n          ebs_event.preventDefault();\n          // Nei menu, blocca l'eventuale navigazione o apertura di altri sottomenu.\n          ebs_event.stopPropagation();\n          ebs_open_after_menus(ebs_anchor);\n          ebs_clear_hash();\n        }\n        return;\n      }\n    }\n\n\n\n    const ebs_copy = ebs_event.target.closest('.ebs-drawer-promo-copy');\n\n    if (!ebs_copy || ebs_copy.disabled) return;\n\n    ebs_event.preventDefault();\n    ebs_event.stopPropagation();\n\n    const ebs_code = ebs_copy.dataset.ebsCode;\n    const ebs_status = ebs_copy.parentElement.querySelector(\n      '.ebs-drawer-promo-card-copy-status'\n    );\n\n    if (!ebs_code) return;\n\n    (async () => {\n      try {\n        await ebs_copy_text(ebs_code);\n    \n        ebs_show_copy_tooltip(\n          ebs_status,\n          'Codice copiato!',\n          true\n        );\n    \n      } catch (ebs_error) {\n        console.error('EBS Drawer Promo: errore copia codice', ebs_error);\n    \n        ebs_show_copy_tooltip(\n          ebs_status,\n          'Impossibile copiare il codice',\n          false\n        );\n      }\n    })();\n\n\n\n  }, true);\n\n  function ebs_initial_hash() {\n    if (location.hash === ebs_hash && ebs_open(document.querySelector('.ebs-drawer-promo-trigger'))) ebs_clear_hash();\n  }\n  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', ebs_initial_hash);\n  else ebs_initial_hash();\n  window.addEventListener('hashchange', ebs_initial_hash);\n  // Ricollega i trigger nativi quando l'editor sostituisce le section.\n  document.addEventListener('shopify:section:load', function () {\n    const ebs_element = ebs_drawer();\n    if (ebs_element && typeof ebs_element.loadTriggers === 'function') ebs_element.loadTriggers();\n  });\n  document.addEventListener('shopify:section:select', function (ebs_event) {\n    if (ebs_event.target.classList.contains('ebs-drawer-promo-config-section')) ebs_open(ebs_event.target);\n  });\n  document.addEventListener('shopify:block:select', function (ebs_event) {\n    if (ebs_event.target.closest('.ebs-drawer-promo-card')) ebs_open(ebs_event.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