{"version":3,"file":"useTimelinePlayback.mjs","names":[],"sources":["../../../src/hooks/playback/useTimelinePlayback.ts"],"sourcesContent":["import type { TimelineCommandResult, PlaybackOptions } from '@techsquidtv/canvas-timeline-core';\nimport type { RationalTime } from '@techsquidtv/canvas-timeline-utils';\nimport { useTimelineEngine } from '#react/hooks/core/useTimelineEngine';\nimport { useTimelineSelector } from '#react/hooks/core/useTimelineSelector';\nimport { createTimelinePlaybackCommands } from '#react/hooks/playback/createTimelinePlaybackCommands';\nimport { useMemo } from 'react';\n/** Result returned by `useTimelinePlayback`. */\nexport interface UseTimelinePlaybackResult {\n  /** Whether the timeline is currently playing. */\n  playing: boolean;\n  /** Current playback speed multiplier. */\n  playbackRate: number;\n  /** Current in point, when set. */\n  inPoint: RationalTime | undefined;\n  /** Current out point, when set. */\n  outPoint: RationalTime | undefined;\n  /** Starts timeline playback. */\n  play: (options?: PlaybackOptions) => TimelineCommandResult;\n  /** Pauses timeline playback. */\n  pause: () => TimelineCommandResult;\n  /** Starts playback when paused, or pauses playback when playing. */\n  togglePlayback: () => TimelineCommandResult;\n  /** Sets the playback speed multiplier. */\n  setPlaybackRate: (rate: number) => TimelineCommandResult;\n  /** Moves the playhead to an absolute time. */\n  setPlayheadTime: (time: RationalTime) => TimelineCommandResult;\n  /** Advances the playhead by a number of seconds. */\n  stepForward: (amountSeconds?: number) => TimelineCommandResult;\n  /** Moves the playhead backward by a number of seconds. */\n  stepBackward: (amountSeconds?: number) => TimelineCommandResult;\n  /** Sets the in point to a supplied time or the current playhead. */\n  setInPoint: (time?: RationalTime) => TimelineCommandResult;\n  /** Sets the out point to a supplied time or the current playhead. */\n  setOutPoint: (time?: RationalTime) => TimelineCommandResult;\n  /** Clears both in and out points. */\n  clearInOutPoints: () => TimelineCommandResult;\n}\n\n/**\n * Provides canonical transport, playhead command, and in/out range commands.\n *\n * Compose this with `useTimelinePlayheadTime` when a component also needs a live\n * clock readout.\n *\n * @returns Playback state and transport commands for headless timeline controls.\n */\nexport function useTimelinePlayback(): UseTimelinePlaybackResult {\n  const engine = useTimelineEngine();\n  const state = useTimelineSelector((state) => ({\n    inPoint: state.inPoint,\n    outPoint: state.outPoint,\n    playbackRate: state.playbackRate ?? 1,\n    playing: state.playing ?? false,\n  }));\n  const commands = useMemo(() => createTimelinePlaybackCommands(engine), [engine]);\n  return useMemo(() => ({ ...state, ...commands }), [state, commands]);\n}\n"],"mappings":";;;;;;;;;;;;;AA8CA,SAAgB,sBAAiD;CAC/D,MAAM,SAAS,kBAAkB;CACjC,MAAM,QAAQ,qBAAqB,WAAW;EAC5C,SAAS,MAAM;EACf,UAAU,MAAM;EAChB,cAAc,MAAM,gBAAgB;EACpC,SAAS,MAAM,WAAW;CAC5B,EAAE;CACF,MAAM,WAAW,cAAc,+BAA+B,MAAM,GAAG,CAAC,MAAM,CAAC;CAC/E,OAAO,eAAe;EAAE,GAAG;EAAO,GAAG;CAAS,IAAI,CAAC,OAAO,QAAQ,CAAC;AACrE"}