{"version":3,"file":"useTimelineEditPreview.mjs","names":[],"sources":["../../../src/hooks/editing/useTimelineEditPreview.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { TimelineEditPreview, TimelineEngine } from '@techsquidtv/canvas-timeline-core';\nimport { useTimelineExternalStore } from '#react/hooks/core/useTimelineExternalStore';\n\nconst editPreviewEvents = ['edit:preview', 'state:settled'] as const;\nconst getTimelineEditPreview = (engine: TimelineEngine) => engine.getEditPreview();\n\n/** Result returned by `useTimelineEditPreview`. */\nexport interface UseTimelineEditPreviewResult {\n  /** Active command-layer edit preview, or null when no preview is active. */\n  preview: TimelineEditPreview | null;\n  /** Whether the current preview can be committed. */\n  valid: boolean;\n  /** Whether an edit preview is currently active. */\n  previewing: boolean;\n}\n\n/**\n * Subscribes to live command-layer edit preview state.\n *\n * This is a focused live hook for preview validity and command state. Compose\n * with `useTimelineEditImpacts` when UI also needs affected-clip consequences.\n *\n * @returns Active edit preview state.\n */\nexport function useTimelineEditPreview(): UseTimelineEditPreviewResult {\n  const preview = useTimelineExternalStore(editPreviewEvents, getTimelineEditPreview);\n\n  return useMemo(\n    () => ({\n      preview,\n      valid: preview?.valid ?? false,\n      previewing: preview !== null,\n    }),\n    [preview]\n  );\n}\n"],"mappings":";;;AAIA,MAAM,oBAAoB,CAAC,gBAAgB,eAAe;AAC1D,MAAM,0BAA0B,WAA2B,OAAO,eAAe;;;;;;;;;AAoBjF,SAAgB,yBAAuD;CACrE,MAAM,UAAU,yBAAyB,mBAAmB,sBAAsB;CAElF,OAAO,eACE;EACL;EACA,OAAO,SAAS,SAAS;EACzB,YAAY,YAAY;CAC1B,IACA,CAAC,OAAO,CACV;AACF"}