{
  "version": 3,
  "sources": ["../src/modules/events.js"],
  "sourcesContent": ["// zelvior-runtime/events -- standalone event helpers.\n// Zero dependency on core zelvior.js by design: importing this module never\n// pulls in the rest of the runtime. ESM source of truth; bundled by build.mjs.\n\nvar hasRaf = typeof window !== 'undefined' && typeof window.requestAnimationFrame === 'function';\nvar hasRic = typeof window !== 'undefined' && typeof window.requestIdleCallback === 'function';\nvar IDLE_SHIM = { timeRemaining: function () { return 8; }, didTimeout: false };\n\n// Feature-detected {passive:true} support. Old Safari (<10) and IE throw a\n// TypeError if addEventListener's 3rd argument is an object at all, so this\n// must probe with a real (immediately-removed) listener rather than assume.\nvar _passiveSupported = null;\nfunction detectPassive() {\n  if (_passiveSupported !== null) return _passiveSupported;\n  _passiveSupported = false;\n  try {\n    var opts = Object.defineProperty({}, 'passive', {\n      get: function () { _passiveSupported = true; return true; }\n    });\n    window.addEventListener('__zelvior_passive_test__', null, opts);\n    window.removeEventListener('__zelvior_passive_test__', null, opts);\n  } catch (e) { _passiveSupported = false; }\n  return _passiveSupported;\n}\n\n/**\n * Feature-detected addEventListener options for a passive listener.\n * Falls back to `false` (bubble phase, non-passive) on browsers that don't\n * support the object form at all, so callers can always spread this in\n * safely: el.addEventListener('scroll', fn, passiveOpts())\n */\nexport function passiveOpts(capture) {\n  if (!detectPassive()) return !!capture;\n  return { passive: true, capture: !!capture };\n}\n\n/**\n * Coalesce rapid calls to at most once per animation frame. Useful for\n * scroll/resize/pointermove handlers where only the latest call in a frame\n * matters. Falls back to a 16ms setTimeout on browsers without rAF.\n * Returns the throttled function; call `.cancel()` on it to drop any\n * pending invocation (e.g. on cleanup).\n */\nexport function throttleRaf(fn) {\n  var scheduled = false;\n  var lastArgs = null;\n  var id = 0;\n  function flush() {\n    scheduled = false;\n    var args = lastArgs;\n    lastArgs = null;\n    fn.apply(null, args || []);\n  }\n  function throttled() {\n    lastArgs = arguments;\n    if (scheduled) return;\n    scheduled = true;\n    id = hasRaf ? requestAnimationFrame(flush) : setTimeout(flush, 16);\n  }\n  throttled.cancel = function () {\n    if (!scheduled) return;\n    if (hasRaf) cancelAnimationFrame(id); else clearTimeout(id);\n    scheduled = false;\n    lastArgs = null;\n  };\n  return throttled;\n}\n\n/**\n * Classic trailing-edge debounce: fn runs `wait` ms after the last call.\n * Distinct from throttleRaf -- this is for \"settled\" events (search-as-you-\n * type, resize-end), not per-frame coalescing.\n * Returns the debounced function; call `.cancel()` to drop a pending call.\n */\nexport function debounce(fn, wait) {\n  var t = 0;\n  function debounced() {\n    var args = arguments;\n    clearTimeout(t);\n    t = setTimeout(function () { fn.apply(null, args); }, wait);\n  }\n  debounced.cancel = function () { clearTimeout(t); };\n  return debounced;\n}\n\n/** requestAnimationFrame with a setTimeout(16) fallback. Returns a cancel function. */\nexport function onFrame(fn) {\n  var id = hasRaf ? requestAnimationFrame(fn) : setTimeout(fn, 16);\n  return function cancel() { hasRaf ? cancelAnimationFrame(id) : clearTimeout(id); };\n}\n\n/** requestIdleCallback with a setTimeout(1) fallback. Returns a cancel function. */\nexport function onIdle(fn, opts) {\n  var id = hasRic\n    ? requestIdleCallback(fn, opts || { timeout: 200 })\n    : setTimeout(function () { fn(IDLE_SHIM); }, 1);\n  return function cancel() { hasRic ? cancelIdleCallback(id) : clearTimeout(id); };\n}\n\n/**\n * Event delegation: one listener on `root` instead of one per matching\n * descendant. Real overhead reduction for lists/tables where attaching a\n * listener to every row/cell would mean hundreds of listeners.\n * `handler` is called as handler(event, matchedElement).\n * Returns an unsubscribe function.\n */\nexport function delegate(root, selector, type, handler, opts) {\n  function onEvent(e) {\n    var el = e.target;\n    while (el && el !== root) {\n      if (el.matches && el.matches(selector)) { handler(e, el); return; }\n      el = el.parentNode;\n    }\n  }\n  root.addEventListener(type, onEvent, opts);\n  return function unsubscribe() { root.removeEventListener(type, onEvent, opts); };\n}\n"],
  "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,aAAAC,EAAA,YAAAC,EAAA,WA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ACd,EAAI,WAAW,UAAY,CAAEL,EAAG,MAAM,KAAMK,CAAI,CAAG,EAAGE,CAAI,CAC5D,CACA,OAAAC,EAAU,OAAS,UAAY,CAAE,aAAa,CAAC,CAAG,EAC3CA,CACT,CAGO,SAASrB,EAAQa,EAAI,CAC1B,IAAIG,EAAKX,EAAS,sBAAsBQ,CAAE,EAAI,WAAWA,EAAI,EAAE,EAC/D,OAAO,UAAkB,CAAER,EAAS,qBAAqBW,CAAE,EAAI,aAAaA,CAAE,CAAG,CACnF,CAGO,SAASf,EAAOY,EAAIH,EAAM,CAC/B,IAAIM,EAAKV,EACL,oBAAoBO,EAAIH,GAAQ,CAAE,QAAS,GAAI,CAAC,EAChD,WAAW,UAAY,CAAEG,EAAGN,CAAS,CAAG,EAAG,CAAC,EAChD,OAAO,UAAkB,CAAED,EAAS,mBAAmBU,CAAE,EAAI,aAAaA,CAAE,CAAG,CACjF,CASO,SAASjB,EAASuB,EAAMC,EAAUC,EAAMC,EAASf,EAAM,CAC5D,SAASgB,EAAQf,EAAG,CAElB,QADIgB,EAAKhB,EAAE,OACJgB,GAAMA,IAAOL,GAAM,CACxB,GAAIK,EAAG,SAAWA,EAAG,QAAQJ,CAAQ,EAAG,CAAEE,EAAQd,EAAGgB,CAAE,EAAG,MAAQ,CAClEA,EAAKA,EAAG,UACV,CACF,CACA,OAAAL,EAAK,iBAAiBE,EAAME,EAAShB,CAAI,EAClC,UAAuB,CAAEY,EAAK,oBAAoBE,EAAME,EAAShB,CAAI,CAAG,CACjF",
  "names": ["events_exports", "__export", "debounce", "delegate", "onFrame", "onIdle", "passiveOpts", "throttleRaf", "__toCommonJS", "hasRaf", "hasRic", "IDLE_SHIM", "_passiveSupported", "detectPassive", "opts", "e", "capture", "fn", "scheduled", "lastArgs", "id", "flush", "args", "throttled", "wait", "debounced", "root", "selector", "type", "handler", "onEvent", "el"]
}
