{"version":3,"file":"useTimelineClipDropFeedback.mjs","names":[],"sources":["../../../src/hooks/clips/useTimelineClipDropFeedback.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { TimelineClipDropFeedback, TimelineEngine } from '@techsquidtv/canvas-timeline-core';\nimport { useTimelineExternalStore } from '#react/hooks/core/useTimelineExternalStore';\n\nconst clipDropFeedbackEvents = ['clip:drop-feedback'] as const;\nconst getTimelineClipDropFeedback = (engine: TimelineEngine) => engine.getClipDropFeedback();\n\n/**\n * Result returned by `useTimelineClipDropFeedback`.\n *\n * @remarks\n *\n * The fields are intentionally transient and mirror the current pointer drag\n * state. Use them for status text, track row highlighting, or custom invalid\n * target feedback while {@link useTimelineClipDrag} or `Timeline.ClipInteractionLayer`\n * owns the actual drag operation.\n *\n * @see {@link useTimelineClipDrag}\n * @see {@link https://canvastimeline.com/docs/tracks-and-clips | Tracks and clips}\n */\nexport interface UseTimelineClipDropFeedbackResult {\n  /** Current transient clip drop feedback. */\n  feedback: TimelineClipDropFeedback;\n  /** Clip currently being dragged, or null when no clip body drag is active. */\n  activeClipId: string | null;\n  /** Track that contained the dragged clip at drag start. */\n  sourceTrackId: string | null;\n  /** Track currently under the pointer, including invalid targets. */\n  hoveredTrackId: string | null;\n  /** Last valid track receiving the preview. */\n  activeTargetTrackId: string | null;\n  /** Whether the hovered track is valid for the dragged clip. */\n  valid: boolean;\n  /** Whether any drop feedback is active. */\n  hasFeedback: boolean;\n}\n\n/**\n * Subscribes to live cross-track clip drop feedback.\n *\n * @remarks\n *\n * This is a focused live interaction hook intended for custom drag affordances.\n * It subscribes to `clip:drop-feedback` instead of the broad provider snapshot,\n * so components can react while the pointer crosses tracks without turning the\n * entire editor shell into drag-time React state.\n *\n * @returns Current clip drag feedback and convenience fields for custom UI.\n *\n * @example\n * ```tsx\n * import { useTimelineClipDropFeedback } from '@techsquidtv/canvas-timeline-react';\n *\n * export function DropStatus() {\n *   const feedback = useTimelineClipDropFeedback();\n *\n *   if (!feedback.hasFeedback) {\n *     return null;\n *   }\n *\n *   return (\n *     <p role=\"status\">\n *       {feedback.valid ? 'Drop to move clip' : `Cannot drop here: ${feedback.feedback.reason}`}\n *     </p>\n *   );\n * }\n * ```\n *\n * @see {@link useTimelineClipDrag}\n * @see {@link https://canvastimeline.com/docs/react-hooks | React editor hooks}\n */\nexport function useTimelineClipDropFeedback(): UseTimelineClipDropFeedbackResult {\n  const feedback = useTimelineExternalStore(clipDropFeedbackEvents, getTimelineClipDropFeedback);\n\n  return useMemo(\n    () => ({\n      feedback,\n      activeClipId: feedback.activeClipId,\n      sourceTrackId: feedback.sourceTrackId,\n      hoveredTrackId: feedback.hoveredTrackId,\n      activeTargetTrackId: feedback.activeTargetTrackId,\n      valid: feedback.valid,\n      hasFeedback:\n        feedback.activeClipId !== null ||\n        feedback.sourceTrackId !== null ||\n        feedback.hoveredTrackId !== null ||\n        feedback.activeTargetTrackId !== null,\n    }),\n    [feedback]\n  );\n}\n"],"mappings":";;;AAIA,MAAM,yBAAyB,CAAC,oBAAoB;AACpD,MAAM,+BAA+B,WAA2B,OAAO,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkE3F,SAAgB,8BAAiE;CAC/E,MAAM,WAAW,yBAAyB,wBAAwB,2BAA2B;CAE7F,OAAO,eACE;EACL;EACA,cAAc,SAAS;EACvB,eAAe,SAAS;EACxB,gBAAgB,SAAS;EACzB,qBAAqB,SAAS;EAC9B,OAAO,SAAS;EAChB,aACE,SAAS,iBAAiB,QAC1B,SAAS,kBAAkB,QAC3B,SAAS,mBAAmB,QAC5B,SAAS,wBAAwB;CACrC,IACA,CAAC,QAAQ,CACX;AACF"}