{"version":3,"file":"useTimelineVisibleClips.mjs","names":[],"sources":["../../../src/hooks/clips/useTimelineVisibleClips.ts"],"sourcesContent":["import { useTimelineEngine } from '#react/hooks/core/useTimelineEngine';\nimport { useTimelineGeometryRevision } from '#react/hooks/core/useTimelineGeometryRevision';\nimport type {\n  VisibleTimelineClip,\n  VisibleTimelineClipOptions,\n} from '@techsquidtv/canvas-timeline-core';\nimport { useMemo } from 'react';\n/**\n * Options accepted by `useTimelineVisibleClips`.\n *\n * @remarks\n *\n * Use viewport dimensions and `overscanPixels` to trade precision for render\n * stability while scrolling. Pass renderer-aligned geometry when custom DOM or\n * canvas layers must line up with `CanvasRenderer`.\n *\n * @see {@link https://canvastimeline.com/demos/react-dom-timeline | React DOM timeline demo}\n */\nexport type UseTimelineVisibleClipsOptions = VisibleTimelineClipOptions;\n\n/**\n * Returns viewport-intersecting timeline clips with clipped time/source ranges.\n *\n * @remarks\n *\n * This is the preferred hook for custom DOM clip renderers and custom canvas\n * layers that only need visible or near-visible clips. Each returned entry\n * includes the visible viewport rectangle plus clipped timeline/source ranges,\n * so thumbnail, waveform, and annotation renderers can avoid work for hidden\n * portions of long clips.\n *\n * @param options - Viewport, overscan, and optional renderer-aligned geometry settings.\n * @returns Visible clip entries in track order.\n *\n * @example\n * ```tsx\n * import { useTimelineVisibleClips } from '@techsquidtv/canvas-timeline-react';\n *\n * export function VisibleClipList() {\n *   const visibleClips = useTimelineVisibleClips({ overscanPixels: 160 });\n *\n *   return (\n *     <ul>\n *       {visibleClips.map((entry) => (\n *         <li key={entry.clip.id}>{entry.clip.label ?? entry.clip.id}</li>\n *       ))}\n *     </ul>\n *   );\n * }\n * ```\n *\n * @see {@link useTimelineClipRects}\n * @see {@link https://canvastimeline.com/docs/renderer-customization | Canvas renderer customization}\n */\nexport function useTimelineVisibleClips(\n  options: UseTimelineVisibleClipsOptions = {}\n): VisibleTimelineClip<string>[] {\n  const engine = useTimelineEngine();\n  const revision = useTimelineGeometryRevision();\n  const {\n    collapsedTrackHeight,\n    edgeThreshold,\n    overscanPixels,\n    rulerHeight,\n    touchEdgeThreshold,\n    trackHeight,\n    viewportHeight,\n    viewportWidth,\n  } = options;\n\n  return useMemo(() => {\n    void revision;\n    return engine.geometry.getVisibleTimelineClips({\n      collapsedTrackHeight,\n      edgeThreshold,\n      overscanPixels,\n      rulerHeight,\n      touchEdgeThreshold,\n      trackHeight,\n      viewportHeight,\n      viewportWidth,\n    });\n  }, [\n    collapsedTrackHeight,\n    edgeThreshold,\n    engine,\n    overscanPixels,\n    revision,\n    rulerHeight,\n    touchEdgeThreshold,\n    trackHeight,\n    viewportHeight,\n    viewportWidth,\n  ]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,wBACd,UAA0C,CAAC,GACZ;CAC/B,MAAM,SAAS,kBAAkB;CACjC,MAAM,WAAW,4BAA4B;CAC7C,MAAM,EACJ,sBACA,eACA,gBACA,aACA,oBACA,aACA,gBACA,kBACE;CAEJ,OAAO,cAAc;EAEnB,OAAO,OAAO,SAAS,wBAAwB;GAC7C;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC;CACH,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH"}