@interlacejs/editor 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3405 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +582 -0
- package/dist/index.d.ts +582 -0
- package/dist/index.js +3380 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/components/interlace-editor.tsx","../src/tokens.ts","../src/hooks/use-authoring-store.ts","../src/components/content-type-editor.tsx","../src/components/content-type-editor-mount.ts","../src/components/inspector-panel.tsx","../src/components/content-type-picker.tsx","../src/components/placement-editor.tsx","../src/components/keyframe-timeline.tsx","../src/components/preview-modal.tsx","../src/components/video-source-input.tsx","../src/components/content-type-editor-slot.tsx"],"sourcesContent":["// Top-level host component\nexport {\n DEFAULT_EDITOR_STRINGS,\n InterlaceEditor,\n} from \"./components/interlace-editor\";\nexport type {\n EditorStrings,\n EditorTheme,\n InterlaceEditorProps,\n} from \"./components/interlace-editor\";\n\n// Authoring-time video source step\nexport {\n DEFAULT_VIDEO_SOURCE_INPUT_STRINGS,\n VideoSourceInput,\n} from \"./components/video-source-input\";\nexport type {\n VideoSourceInputProps,\n VideoSourceInputStrings,\n VideoSourceValue,\n} from \"./components/video-source-input\";\n\n// Authoring surface building blocks\nexport { ContentTypeEditor } from \"./components/content-type-editor\";\nexport type { ContentTypeEditorProps } from \"./components/content-type-editor\";\nexport { ContentTypeEditorSlot } from \"./components/content-type-editor-slot\";\nexport type { ContentTypeEditorSlotProps } from \"./components/content-type-editor-slot\";\nexport { ContentTypePicker } from \"./components/content-type-picker\";\nexport type { ContentTypePickerProps } from \"./components/content-type-picker\";\nexport {\n clampPlacement,\n PLACEMENT_MIN_SIZE,\n PlacementEditor,\n PlacementInputs,\n} from \"./components/placement-editor\";\nexport type {\n PlacementEditorProps,\n PlacementInputsProps,\n} from \"./components/placement-editor\";\n\n// Keyframe timeline + inspector\nexport {\n DEFAULT_INSPECTOR_PANEL_STRINGS,\n InspectorPanel,\n} from \"./components/inspector-panel\";\nexport type {\n InspectorPanelEntry,\n InspectorPanelProps,\n InspectorPanelStrings,\n} from \"./components/inspector-panel\";\nexport {\n DEFAULT_KEYFRAME_TIMELINE_STRINGS,\n KeyframeTimeline,\n} from \"./components/keyframe-timeline\";\nexport type {\n KeyframeTimelineEntry,\n KeyframeTimelineProps,\n KeyframeTimelineStrings,\n} from \"./components/keyframe-timeline\";\n\n// Authoring store\nexport { useAuthoringStore } from \"./hooks/use-authoring-store\";\nexport type {\n AuthoringStore,\n AuthoringStoreState,\n InteractiveMediaItem,\n LoadDocumentResult,\n} from \"./hooks/use-authoring-store\";\n","import {\n ContentInstance,\n ContentRecord,\n ContentState,\n ContentType,\n ContentTypeRegistry,\n DEFAULT_STRINGS,\n Hook,\n Placement,\n SerializedInteractiveMediaDocument,\n type Strings as CoreStrings,\n} from \"@interlacejs/core\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { COLORS, FONTS, RADIUS, SHADOWS, SPACE, TYPE } from \"../tokens\";\nimport type { InteractiveMediaItem } from \"../hooks/use-authoring-store\";\nimport { useAuthoringStore } from \"../hooks/use-authoring-store\";\nimport { ContentTypeEditor } from \"./content-type-editor\";\nimport { InspectorPanel } from \"./inspector-panel\";\nimport { KeyframeTimeline } from \"./keyframe-timeline\";\nimport { PlacementEditor } from \"./placement-editor\";\nimport type { PreviewModalStrings } from \"./preview-modal\";\nimport { PreviewModal } from \"./preview-modal\";\nimport type { VideoSourceInputStrings } from \"./video-source-input\";\nimport { VideoSourceInput } from \"./video-source-input\";\n\n/**\n * Editor-local strings layered on top of the core `Strings`. Hosts pass\n * `strings?: Partial<EditorStrings>` and may override any subset of the\n * fields; the rest fall back to the defaults exported alongside.\n */\nexport interface EditorStrings extends CoreStrings {\n /** Heading for the video source step when no document is loaded. */\n videoSourceInputTitle: string;\n /** Title for the preview surface. */\n previewTitle: string;\n /** Label for the button that opens the preview modal. */\n previewLabel: string;\n /** Label for the button that re-opens the video source step on an existing document. */\n replaceVideoLabel: string;\n /** Label for the button that aborts a replace and returns to the authoring surface. */\n replaceCancelLabel: string;\n /** Label for the button that triggers `onSave`. */\n saveLabel: string;\n /** Shown when no item is selected for placement editing. */\n noItemSelectedLabel: string;\n /**\n * Heading for the placement editor section.\n *\n * @deprecated Unused since the placement editor became a video-frame\n * overlay (there is no separate placement section to head). Retained\n * for backward compatibility with hosts passing\n * `strings.placementLabel`. Will be removed in a future major.\n */\n placementLabel: string;\n /** Heading for the timeline area. */\n timelineHeading: string;\n /**\n * Heading for the add-content area.\n *\n * @deprecated Unused since the content type picker moved into the\n * Hook details panel. Retained for backward compatibility with hosts\n * passing `strings.addContentHeading`. Will be removed in a future\n * major.\n */\n addContentHeading: string;\n /** Heading for the Hook section (shown when a hook is selected). */\n hookHeading: string;\n /** Heading for the inline content editor subsection of the Hook section. */\n contentEditorHeading: string;\n /**\n * Label for the button that opens the content editor slot.\n *\n * @deprecated Unused since the slot opens on entry selection. Retained\n * for backward compatibility with hosts passing `strings.editContentLabel`\n * at the 1.0 API freeze. Will be removed in a future major.\n */\n editContentLabel: string;\n /** Shown when a host-supplied onError fires during a load failure. */\n loadErrorTitle: string;\n /** Shown when the video element has not yet reported a duration. */\n durationUnknownLabel: string;\n /**\n * String overrides forwarded to the embedded `VideoSourceInput`. The\n * first screen of the drop-in component is otherwise unreachable to a\n * host passing `strings`. Any field omitted falls back to\n * `DEFAULT_VIDEO_SOURCE_INPUT_STRINGS` in `VideoSourceInput`.\n */\n videoSource?: Partial<VideoSourceInputStrings>;\n /**\n * String overrides forwarded to the preview modal. Any field omitted\n * falls back to `DEFAULT_PREVIEW_MODAL_STRINGS` in `PreviewModal`.\n */\n previewModal?: Partial<PreviewModalStrings>;\n}\n\n/**\n * Defaults are derived from core's `DEFAULT_STRINGS` so a host that\n * overrides the core base gets matching inheritance automatically. The\n * editor-specific fields are filled in alongside.\n */\nexport const DEFAULT_EDITOR_STRINGS: EditorStrings = {\n ...DEFAULT_STRINGS,\n videoSourceInputTitle: \"Add a video\",\n previewTitle: \"Preview\",\n previewLabel: \"Preview\",\n replaceVideoLabel: \"Replace video\",\n replaceCancelLabel: \"Cancel replace\",\n saveLabel: \"Save\",\n noItemSelectedLabel: \"Select an item to edit its placement.\",\n placementLabel: \"Placement\",\n timelineHeading: \"Hooks\",\n addContentHeading: \"Add content\",\n hookHeading: \"Hook\",\n contentEditorHeading: \"Content\",\n editContentLabel: \"Edit content\",\n loadErrorTitle: \"Could not load the document\",\n durationUnknownLabel: \"Duration unknown\",\n};\n\n/**\n * Optional theme overrides. Hosts that want to recolor the editor without\n * shipping a CSS file can pass a `theme`; the editor applies these via\n * inline `style` on its root wrapper and on the save button. Anything not\n * provided falls back to a neutral default.\n */\nexport interface EditorTheme {\n accentColor?: string;\n backgroundColor?: string;\n surfaceColor?: string;\n borderColor?: string;\n textColor?: string;\n mutedTextColor?: string;\n}\n\nexport interface InterlaceEditorProps {\n /** Registry of content types available for authoring. */\n contentTypeRegistry: ContentTypeRegistry;\n /**\n * Optional serialized document. Omit for a brand-new document (the\n * editor shows the video source step first). Provide to edit an\n * existing document; the editor calls `deserialize()` + `validate()`\n * on mount and surfaces any warnings via `onError`.\n */\n document?: SerializedInteractiveMediaDocument;\n /**\n * Host-supplied upload callback. Called by the video source step when\n * the user selects a file. The resolved URL is written into the\n * document; the host owns persistence.\n */\n onUpload: (file: File) => Promise<string>;\n /**\n * Receives `authoringStore.serialize()`'s output on save. The host\n * owns persistence — the editor never persists on its own.\n */\n onSave: (doc: SerializedInteractiveMediaDocument) => void;\n /** Optional string overrides. */\n strings?: Partial<EditorStrings>;\n /** Optional theme overrides. */\n theme?: EditorTheme;\n /** Optional error callback for upload, load, and runtime failures. */\n onError?: (error: Error) => void;\n /**\n * Host-level adapter type. Defaults to `\"native\"`. **Not** persisted\n * into the core serialized document; the host must re-supply this on\n * reload. The editor does not pass it to `serialize()`.\n */\n adapterType?: string;\n}\n\nconst DEFAULT_PLACEMENT: Placement = { x: 50, y: 50, width: 20, height: 20 };\n\nfunction makeDefaultData(contentTypeId: string): unknown {\n if (contentTypeId === \"quiz\" || contentTypeId === \"quiz-editor\") {\n // Canonical multi-question shape from creation (the single supported\n // quiz format).\n return {\n questions: [\n {\n id: \"q-0\",\n text: \"\",\n options: [\n { id: \"opt-0\", text: \"\" },\n { id: \"opt-1\", text: \"\" },\n ],\n correctOptionId: \"opt-0\",\n },\n ],\n };\n }\n return {};\n}\n\nfunction makeHook(\n hookType: \"blocking\" | \"non-blocking\",\n atTime: number,\n videoDuration: number,\n): Hook {\n if (hookType === \"blocking\") {\n return {\n type: \"blocking\",\n timestamp: Math.max(0, atTime),\n placement: DEFAULT_PLACEMENT,\n };\n }\n // Origin-first (unifying with `clampTimeUpdates`): the playhead is\n // bounded inside the video so the created range never extends past\n // its end — a playhead exactly at the duration previously produced\n // `end = duration + 1`.\n const start = Math.max(0, Math.min(atTime, videoDuration - 1));\n // The default 10s range is clamped to the video duration, matching\n // every other path that mutates hook times (drag, edges, keyboard).\n // The 1s minimum range wins over the duration bound when the bounds\n // conflict — a 0-length range is worse than a sub-second overflow,\n // and the timeline's own end-edge clamp floors at `start + 1` the\n // same way.\n const end = Math.min(start + 10, Math.max(videoDuration, start + 1));\n return {\n type: \"non-blocking\",\n start,\n end,\n placement: DEFAULT_PLACEMENT,\n revealBehavior: \"click\",\n };\n}\n\nfunction buildContentInstance(\n id: string,\n title: string,\n contentType: ContentType,\n hook: Hook,\n data: unknown,\n): ContentInstance {\n const record: ContentRecord = {\n id,\n title,\n contentTypeId: contentType.getId(),\n data,\n state: \"pending\" as ContentState,\n hook,\n };\n return new ContentInstance(record, contentType);\n}\n\nfunction rebuildContentInstance(\n content: ContentInstance,\n contentType: ContentType,\n overrides: { title?: string; data?: unknown; hook?: Hook },\n): ContentInstance {\n const record: ContentRecord = {\n id: content.getId(),\n title: overrides.title ?? content.getTitle(),\n contentTypeId: content.getContentTypeId(),\n data: overrides.data !== undefined ? overrides.data : content.getData(),\n state: content.getState(),\n // The hook override is load-bearing: core's `serialize` reads the\n // hook from the instance's record (`content.getHook()`), NOT from\n // the store wrapper's parallel `hook` field. Every time/placement\n // edit must be rebuilt into the record or `Save` persists the old\n // hook.\n hook: overrides.hook ?? content.getHook(),\n };\n return new ContentInstance(record, contentType);\n}\n\n/**\n * A hook created at the playhead but not yet given a content type.\n * Pending hooks live only in editor-local state (never in the store —\n * `ContentInstance` requires a registered type), so `Save` does not\n * serialize them. Choosing a content type in Hook details materializes\n * the pending hook into the store.\n */\ninterface PendingHook {\n id: string;\n title: string;\n hook: Hook;\n}\n\n/**\n * Clamps manual time edits to the video bounds with the same policies\n * as the timeline's drag paths: blocking timestamps stay inside\n * `[0, duration]`; non-blocking ranges keep `start < end` with at\n * least a 1s span and both ends inside the video.\n */\nfunction clampTimeUpdates(\n hook: Hook,\n updates: { timestamp?: number; start?: number; end?: number },\n videoDuration: number,\n): { timestamp?: number; start?: number; end?: number } {\n if (hook.type === \"blocking\") {\n const t = updates.timestamp ?? hook.timestamp;\n return { timestamp: Math.max(0, Math.min(t, videoDuration)) };\n }\n const start = updates.start ?? hook.start;\n const end = updates.end ?? hook.end;\n // Origin-first ordering (mirroring `clampPlacement`): bound the start\n // against the video first, then the end against both the start and\n // the video. Without the duration bound on `start`, manual inputs\n // could produce ranges entirely beyond the video (duration 60, start\n // 100, end 110) — a state no timeline drag path can produce.\n const nextStart = Math.max(0, Math.min(start, videoDuration - 1));\n const nextEnd = Math.max(nextStart + 1, Math.min(end, videoDuration));\n return { start: nextStart, end: nextEnd };\n}\n\n/**\n * Toolbar below the video frame showing the current duration, an\n * optional selection hint, a button to replace the video (re-opens the\n * source step in replace mode), and a button that opens the preview\n * modal. This toolbar must stay OUTSIDE the video's positioning\n * context: the placement overlay (Phase 3) maps its percentages against\n * the `position: relative` wrapper that hugs exactly the `<video>`\n * element, and an in-flow toolbar inside that wrapper would offset\n * every rectangle by the toolbar's height.\n */\nfunction EditorVideoToolbar({\n duration,\n strings,\n onReplaceVideo,\n onOpenPreview,\n theme,\n hint,\n}: {\n duration: number | undefined;\n strings: EditorStrings;\n onReplaceVideo: () => void;\n onOpenPreview: () => void;\n theme?: EditorTheme;\n /** Shown next to the duration when no item is selected. */\n hint?: string;\n}) {\n return (\n <div\n data-testid=\"interlace-editor-video-toolbar\"\n style={{\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n padding: `${SPACE[2]}px 0`,\n fontSize: TYPE.sm,\n color: theme?.mutedTextColor ?? COLORS.textMuted,\n }}\n >\n <span\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 8,\n }}\n >\n <span data-testid=\"interlace-editor-video-duration\">\n {duration === undefined || !Number.isFinite(duration)\n ? strings.durationUnknownLabel\n : `${duration.toFixed(1)}s`}\n </span>\n {hint ? (\n <span data-testid=\"interlace-editor-selection-hint\">{hint}</span>\n ) : null}\n </span>\n <div style={{ display: \"flex\", gap: 8 }}>\n <button\n type=\"button\"\n onClick={onReplaceVideo}\n data-testid=\"interlace-editor-replace-video\"\n style={{\n padding: `${SPACE[1]}px ${SPACE[3]}px`,\n backgroundColor: \"transparent\",\n border: `1px solid ${COLORS.borderStrong}`,\n borderRadius: RADIUS.sm,\n cursor: \"pointer\",\n fontSize: TYPE.sm,\n color: COLORS.text,\n transition: \"background-color 150ms ease, border-color 150ms ease\",\n }}\n >\n {strings.replaceVideoLabel}\n </button>\n <button\n type=\"button\"\n onClick={onOpenPreview}\n data-testid=\"interlace-editor-open-preview\"\n style={{\n padding: `${SPACE[1]}px ${SPACE[3]}px`,\n backgroundColor: theme?.accentColor ?? COLORS.accent,\n color: COLORS.white,\n border: \"none\",\n borderRadius: RADIUS.sm,\n cursor: \"pointer\",\n fontSize: TYPE.sm,\n fontWeight: 600,\n transition: \"background-color 150ms ease\",\n }}\n >\n {strings.previewLabel}\n </button>\n </div>\n </div>\n );\n}\n\n/**\n * InterlaceEditor - the top-level component a host app actually renders\n * to author an interactive video document. Mirrors `InteractiveVideoPlayer`\n * on the player side: it is the single drop-in surface for the editor.\n *\n * The component composes:\n * - `VideoSourceInput` (shown first when the document has no video source)\n * - An authoring-time video surface (a `<video>` element) used by the\n * placement editor (Phase 3) and the timeline playhead (Phase 4)\n * - `PreviewModal` for the gated \"what students will see\" surface\n * (replaces the prior always-on preview). The modal mounts\n * `InteractiveVideoPlayer` + a fresh `NativeVideoAdapter` over its\n * own `<video>`, so the student view and the authoring view are\n * decoupled.\n * - `KeyframeTimeline` for keyframe-style hook CRUD\n * - `PlacementEditor` for the selected item's placement\n * - `InspectorPanel` (Hook details) plus the inline `ContentTypeEditor`\n * for editing the selected hook; new hooks are added at the playhead\n * and re-typed from Hook details\n *\n * Behavior:\n * - Video duration is captured from the preview `<video>`'s\n * `loadedmetadata` and pushed into the store so the serialized\n * document is not stale.\n * - A \"Replace video\" button re-opens the source step in replace mode.\n * - A \"Preview\" button opens the modal; opening the modal pauses the\n * authoring video so the two surfaces do not play in parallel.\n * - `adapterType` is a host-level prop (default `\"native\"`); it is not\n * written into the serialized document.\n */\nexport function InterlaceEditor({\n contentTypeRegistry,\n document,\n onUpload,\n onSave,\n strings: stringsOverride,\n theme,\n onError,\n}: InterlaceEditorProps) {\n const strings = { ...DEFAULT_EDITOR_STRINGS, ...stringsOverride };\n const {\n state,\n addItem,\n removeItem,\n updateItem,\n loadDocument,\n serialize,\n setVideoMetadata,\n } = useAuthoringStore(\n document?.video?.src ?? \"\",\n document?.video?.duration ?? 0,\n );\n\n const [selectedItemId, setSelectedItemId] = useState<string | null>(null);\n /**\n * A hook created at the playhead that has no content type yet. Lives\n * only in editor-local state — it appears in the timeline and Hook\n * details, but `Save` does not serialize it. Choosing a content type\n * in Hook details materializes it into the store.\n */\n const [pendingHook, setPendingHook] = useState<PendingHook | null>(null);\n const [replaceMode, setReplaceMode] = useState(false);\n const [previewOpen, setPreviewOpen] = useState(false);\n /** Authoring-video playhead position in seconds (drives the timeline). */\n const [currentTime, setCurrentTime] = useState(0);\n /** Whether the authoring video is currently playing (drives the timeline's play button). */\n const [isPlaying, setIsPlaying] = useState(false);\n const nextIdRef = useRef(1);\n const registryRef = useRef(contentTypeRegistry);\n registryRef.current = contentTypeRegistry;\n const loadedInitialDocRef = useRef<SerializedInteractiveMediaDocument | null>(\n null,\n );\n const videoRef = useRef<HTMLVideoElement | null>(null);\n /**\n * Last reported duration for the *current* `videoSrc`. When the load\n * effect overwrites a freshly observed duration with the document's\n * stale value (cached video fires `loadedmetadata` before the load\n * commits), a follow-up effect re-pushes this value.\n */\n const lastDurationForSrcRef = useRef<{\n src: string;\n duration: number;\n } | null>(null);\n /**\n * Pending seek target. Set when `handleSelectEntry`'s `video.currentTime`\n * setter throws (the video has not loaded metadata yet) and consumed by\n * `handlePreviewLoadedMetadata` once the video is ready. Without this,\n * selecting a hook before the preview's `<video>` has metadata silently\n * does nothing, and the user has to click again after `loadedmetadata`\n * fires.\n */\n const pendingSeekRef = useRef<number | null>(null);\n\n // Load the initial document once per document identity. The effect is\n // keyed on the document only (not the registry) so a consumer that\n // recreates the registry on every render does not reload and wipe\n // in-progress edits.\n useEffect(() => {\n if (!document) {\n // Clear the pending hook only on an actual transition out of a\n // document. The effect re-runs on unrelated identity churn (e.g.\n // a host-inlined `onError` callback), and must not destroy a\n // draft on those runs.\n if (loadedInitialDocRef.current !== null) {\n loadedInitialDocRef.current = null;\n setPendingHook(null);\n }\n return;\n }\n if (loadedInitialDocRef.current === document) return;\n loadedInitialDocRef.current = document;\n // Loading a different document starts a new authoring session; a\n // pending hook from the old one is dropped.\n setPendingHook(null);\n const { validationErrors, warnings } = loadDocument(\n document,\n registryRef.current,\n );\n if (validationErrors.length > 0) {\n onError?.(\n new Error(`${strings.loadErrorTitle}: ${validationErrors.join(\"; \")}`),\n );\n }\n // Warnings are *not* cosmetic: `deserialize` skips items that produce\n // them (unrecognized content type, invalid hook, version mismatch\n // without `migrate`). The store ends up pruned, and a later Save\n // persists the pruned document. Surface them through `onError` so the\n // host can decide what to do (re-register, migrate, refuse to save).\n for (const warning of warnings) {\n onError?.(new Error(warning));\n }\n }, [document, loadDocument, onError, strings.loadErrorTitle]);\n\n // Repair: if the document load commits *after* the preview video\n // already reported metadata, re-push the observed duration. Without\n // this, a cached video that fires `loadedmetadata` before the load\n // effect's setState commits would have its real duration overwritten\n // by the document's stale value and `loadedmetadata` would never\n // re-fire (the `<video>`'s `key` is unchanged, no remount).\n useEffect(() => {\n const last = lastDurationForSrcRef.current;\n if (!last) return;\n if (last.src !== state.videoSrc) return;\n if (Math.abs(last.duration - state.videoDuration) < 0.001) return;\n setVideoMetadata(last.src, last.duration);\n }, [state.videoSrc, state.videoDuration, setVideoMetadata]);\n\n const hasVideo = Boolean(state.videoSrc);\n const showSourceStep = !hasVideo || replaceMode;\n\n const selectedStoreItem = useMemo(\n () =>\n state.items.find((item) => item.content.getId() === selectedItemId) ??\n null,\n [state.items, selectedItemId],\n );\n const isPendingSelected =\n !selectedStoreItem &&\n pendingHook != null &&\n pendingHook.id === selectedItemId;\n /** The selected hook's time data — store item or pending, unified. */\n const selectedHook: Hook | null = isPendingSelected\n ? (pendingHook?.hook ?? null)\n : (selectedStoreItem?.hook ?? null);\n const selectedTitle: string | null = isPendingSelected\n ? (pendingHook?.title ?? null)\n : (selectedStoreItem?.content.getTitle() ?? null);\n /**\n * `null` for a pending hook (content type not yet chosen) — the\n * Hook details panel shows the picker in that case, and the inline\n * content editor is hidden.\n */\n const selectedContentTypeId: string | null = isPendingSelected\n ? null\n : (selectedStoreItem?.content.getContentTypeId() ?? null);\n const selectedContent = selectedStoreItem?.content ?? null;\n\n const selectedData = useMemo(\n () => (selectedContent ? selectedContent.getData() : null),\n [selectedContent],\n );\n\n const registeredTypeIds = useMemo(\n () => contentTypeRegistry.getAll().map((ct) => ct.getId()),\n [contentTypeRegistry],\n );\n\n const timelineEntries = useMemo(() => {\n const fromStore = state.items.map((item) => {\n const hook = item.hook;\n if (hook.type === \"blocking\") {\n return {\n id: item.content.getId(),\n title: item.content.getTitle(),\n hookType: \"blocking\" as const,\n timestamp: hook.timestamp,\n };\n }\n return {\n id: item.content.getId(),\n title: item.content.getTitle(),\n hookType: \"non-blocking\" as const,\n start: hook.start,\n end: hook.end,\n };\n });\n // The pending hook (created at the playhead, content type not yet\n // chosen) is a first-class timeline entry — it just is not part of\n // the store until it is materialized.\n if (!pendingHook) return fromStore;\n const hook = pendingHook.hook;\n return [\n ...fromStore,\n hook.type === \"blocking\"\n ? {\n id: pendingHook.id,\n title: pendingHook.title,\n hookType: \"blocking\" as const,\n timestamp: hook.timestamp,\n }\n : {\n id: pendingHook.id,\n title: pendingHook.title,\n hookType: \"non-blocking\" as const,\n start: hook.start,\n end: hook.end,\n },\n ];\n }, [state.items, pendingHook]);\n\n /**\n * The serialized document fed to the preview modal. Memoized on the\n * specific state slices that affect its content so a parent\n * re-render that does not change the document does not restart the\n * player's controller.\n */\n const previewDocument = useMemo<SerializedInteractiveMediaDocument>(() => {\n if (!state.videoSrc) {\n return { video: { src: \"\" }, items: [] };\n }\n return {\n video: {\n src: state.videoSrc,\n duration: state.videoDuration,\n },\n items: state.items.map((item) => ({\n id: item.content.getId(),\n title: item.content.getTitle(),\n hook: item.hook,\n content: {\n contentTypeId: item.content.getContentTypeId(),\n version: item.content.getContentTypeVersion(),\n data: item.content.getData(),\n },\n })),\n };\n // The memo is intentionally keyed on the document's content\n // slices only. `state.items` is a new array reference on every\n // store update; the controller will restart when items change,\n // which is the correct semantic (the document did change).\n }, [state.videoSrc, state.videoDuration, state.items]);\n\n const handleSelectEntry = useCallback(\n (id: string) => {\n setSelectedItemId(id);\n // Seek the shared authoring video to the hook's anchor time so\n // the preview and placement overlay show the frame the hook is\n // attached to. Pending hooks (no content type yet) are seekable\n // too — their times live in editor-local state.\n const item = state.items.find((it) => it.content.getId() === id);\n const hook = item\n ? item.content.getHook()\n : pendingHook?.id === id\n ? pendingHook.hook\n : null;\n if (!hook) return;\n const target = hook.type === \"blocking\" ? hook.timestamp : hook.start;\n if (!Number.isFinite(target)) return;\n const video = videoRef.current;\n if (video) {\n try {\n video.currentTime = Math.max(0, target);\n } catch {\n // The video has not loaded metadata yet. Defer the seek\n // until `loadedmetadata` fires; the consuming handler is\n // `handlePreviewLoadedMetadata` below.\n pendingSeekRef.current = Math.max(0, target);\n }\n } else {\n // No live video element (e.g. source step shown). Defer until\n // the <video> mounts; same consumer.\n pendingSeekRef.current = Math.max(0, target);\n }\n // Keep the timeline playhead in sync immediately; the video's own\n // `timeupdate` confirms once the seek lands.\n setCurrentTime(Math.max(0, target));\n },\n [state.items, pendingHook, setCurrentTime],\n );\n\n /** Clicking the timeline track background deselects the hook. */\n const handleDeselect = useCallback(() => {\n setSelectedItemId(null);\n }, []);\n\n const handleAddEntry = useCallback(\n (hookType: \"blocking\" | \"non-blocking\") => {\n const id = `pending-${nextIdRef.current++}`;\n // The keyframe metaphor: new hooks land at the current playhead,\n // clamped to the video's duration. They start WITHOUT a content\n // type — Hook details picks one and materializes the hook into\n // the store. Until then the hook is editor-local only and `Save`\n // does not serialize it.\n const hook = makeHook(hookType, currentTime, state.videoDuration);\n setPendingHook({ id, title: \"New hook\", hook });\n setSelectedItemId(id);\n },\n [currentTime, state.videoDuration],\n );\n\n const handleDeleteEntry = useCallback(\n (id: string) => {\n if (pendingHook?.id === id) {\n setPendingHook(null);\n setSelectedItemId((prev) => (prev === id ? null : prev));\n return;\n }\n removeItem(id);\n setSelectedItemId((prev) => (prev === id ? null : prev));\n },\n [pendingHook, removeItem],\n );\n\n const handleUpdateEntry = useCallback(\n (\n id: string,\n updates: {\n title?: string;\n timestamp?: number;\n start?: number;\n end?: number;\n },\n ) => {\n if (pendingHook?.id === id) {\n // Pending hook: times and title live in editor-local state.\n setPendingHook((prev) => {\n if (!prev || prev.id !== id) return prev;\n const hook = prev.hook;\n const nextHook =\n hook.type === \"blocking\"\n ? { ...hook, timestamp: updates.timestamp ?? hook.timestamp }\n : {\n ...hook,\n start: updates.start ?? hook.start,\n end: updates.end ?? hook.end,\n };\n return {\n ...prev,\n title:\n typeof updates.title === \"string\" ? updates.title : prev.title,\n hook: nextHook,\n };\n });\n return;\n }\n const current = state.items.find((item) => item.content.getId() === id);\n if (!current) return;\n const contentType = contentTypeRegistry.get(\n current.content.getContentTypeId(),\n );\n if (!contentType) return;\n const title =\n typeof updates.title === \"string\"\n ? updates.title\n : current.content.getTitle();\n let hook = current.hook;\n if (hook.type === \"blocking\") {\n hook = { ...hook, timestamp: updates.timestamp ?? hook.timestamp };\n } else {\n hook = {\n ...hook,\n start: updates.start ?? hook.start,\n end: updates.end ?? hook.end,\n };\n }\n updateItem(id, {\n content: rebuildContentInstance(current.content, contentType, {\n title,\n hook,\n }),\n hook,\n });\n },\n [pendingHook, state.items, contentTypeRegistry, updateItem],\n );\n\n const handlePlacementChange = useCallback(\n (nextPlacement: Placement) => {\n if (!selectedItemId) return;\n if (pendingHook?.id === selectedItemId) {\n setPendingHook((prev) =>\n prev && prev.id === selectedItemId\n ? { ...prev, hook: { ...prev.hook, placement: nextPlacement } }\n : prev,\n );\n return;\n }\n const current = state.items.find(\n (item) => item.content.getId() === selectedItemId,\n );\n if (!current) return;\n const contentType = contentTypeRegistry.get(\n current.content.getContentTypeId(),\n );\n if (!contentType) return;\n const nextHook = { ...current.hook, placement: nextPlacement };\n updateItem(selectedItemId, {\n content: rebuildContentInstance(current.content, contentType, {\n hook: nextHook,\n }),\n hook: nextHook,\n });\n },\n [selectedItemId, pendingHook, state.items, contentTypeRegistry, updateItem],\n );\n\n /** Content editor onChange for a materialized (typed) hook. */\n const handleContentChange = useCallback(\n (newData: unknown) => {\n if (!selectedItemId) return;\n const current = state.items.find(\n (item) => item.content.getId() === selectedItemId,\n );\n if (!current) return;\n const contentType = contentTypeRegistry.get(\n current.content.getContentTypeId(),\n );\n if (!contentType) return;\n const updatedContent = rebuildContentInstance(\n current.content,\n contentType,\n { data: newData },\n );\n const updatedItem: InteractiveMediaItem = {\n content: updatedContent,\n hook: current.hook,\n };\n updateItem(selectedItemId, updatedItem);\n },\n [selectedItemId, state.items, contentTypeRegistry, updateItem],\n );\n\n /**\n * Materializes a pending hook into the store once its content type\n * is chosen in Hook details (a clean store id is generated and\n * selected so the inline content editor appears immediately), or\n * re-types an existing hook: the authored data is reset to the new\n * type's default shape (data shapes differ per type) while the\n * hook's time, placement, and title are preserved. Selecting the\n * current type is a no-op.\n */\n const handleContentTypeSelect = useCallback(\n (typeId: string) => {\n if (!selectedItemId) return;\n const contentType = contentTypeRegistry.get(typeId);\n if (!contentType) return;\n if (pendingHook?.id === selectedItemId) {\n const id = `hook-${nextIdRef.current++}`;\n const item = buildContentInstance(\n id,\n pendingHook.title,\n contentType,\n pendingHook.hook,\n makeDefaultData(contentType.getId()),\n );\n addItem({ content: item, hook: pendingHook.hook });\n setPendingHook(null);\n setSelectedItemId(id);\n return;\n }\n const current = state.items.find(\n (item) => item.content.getId() === selectedItemId,\n );\n if (!current) return;\n if (current.content.getContentTypeId() === typeId) return;\n const rebuilt = buildContentInstance(\n current.content.getId(),\n current.content.getTitle(),\n contentType,\n current.hook,\n makeDefaultData(contentType.getId()),\n );\n updateItem(selectedItemId, { content: rebuilt, hook: current.hook });\n },\n [\n pendingHook,\n selectedItemId,\n contentTypeRegistry,\n addItem,\n state.items,\n updateItem,\n ],\n );\n\n /** Manual time edits from Hook details (clamped, pending-aware). */\n const handleTimeChange = useCallback(\n (updates: { timestamp?: number; start?: number; end?: number }) => {\n if (!selectedItemId) return;\n const isPending = pendingHook?.id === selectedItemId;\n const hook = isPending\n ? pendingHook?.hook\n : state.items.find((it) => it.content.getId() === selectedItemId)?.hook;\n if (!hook) return;\n const clamped = clampTimeUpdates(hook, updates, state.videoDuration);\n if (isPending) {\n setPendingHook((prev) =>\n prev && prev.id === selectedItemId\n ? { ...prev, hook: { ...prev.hook, ...clamped } as Hook }\n : prev,\n );\n return;\n }\n handleUpdateEntry(selectedItemId, clamped);\n },\n [\n selectedItemId,\n pendingHook,\n state.items,\n state.videoDuration,\n handleUpdateEntry,\n ],\n );\n\n const handleVideoSourceChange = useCallback(\n (next: { src: string; duration?: number }) => {\n // Same-URL replace: the `<video>`'s `key` is unchanged so\n // `loadedmetadata` will not re-fire. Preserve any duration the\n // preview element already reported, otherwise the document is\n // silently reset to duration 0.\n const preserveDuration =\n next.src === state.videoSrc ? state.videoDuration : 0;\n const duration = next.duration ?? preserveDuration;\n setVideoMetadata(next.src, duration);\n setReplaceMode(false);\n // A video replace changes the timeline the pending hook's anchor\n // times reference — drop it, matching the document-load path\n // (both start a new authoring session for hook times). Also\n // close any open preview so the user lands on a clean surface.\n setPendingHook(null);\n setPreviewOpen(false);\n },\n [setVideoMetadata, setPendingHook, state.videoSrc, state.videoDuration],\n );\n\n const handleReplaceVideo = useCallback(() => {\n setReplaceMode(true);\n }, []);\n\n const handleCancelReplace = useCallback(() => {\n setReplaceMode(false);\n }, []);\n\n /** Mirrors the authoring video's playhead into the timeline. */\n const handleTimeUpdate = useCallback(\n (e: React.SyntheticEvent<HTMLVideoElement>) => {\n setCurrentTime(e.currentTarget.currentTime);\n },\n [],\n );\n\n /**\n * Timeline-initiated seek (playhead drag, ruler click, keyboard).\n * Sets the video's time when it can, defers through the pending-seek\n * mechanism when it cannot, and always keeps the playhead responsive\n * immediately so the strip does not lag behind the pointer.\n */\n const handleTimelineSeek = useCallback((time: number) => {\n const t = Math.max(0, time);\n const video = videoRef.current;\n if (video) {\n try {\n video.currentTime = t;\n } catch {\n // Video not ready; the pending-seek mechanism applies it once\n // metadata loads.\n pendingSeekRef.current = t;\n }\n } else {\n pendingSeekRef.current = t;\n }\n setCurrentTime(t);\n }, []);\n\n /** Play/pause for the authoring video (drives the timeline button). */\n const handleTogglePlay = useCallback(() => {\n const video = videoRef.current;\n if (!video) return;\n if (video.paused) {\n try {\n const p = video.play() as unknown as Promise<void> | undefined;\n p?.catch?.(() => {\n // Autoplay policy or engine restriction; the button state\n // corrects on the next play/pause event.\n });\n } catch {\n // jsdom and some engines throw synchronously.\n }\n } else {\n try {\n video.pause();\n } catch {\n // ignore\n }\n }\n }, []);\n\n const handleOpenPreview = useCallback(() => {\n setPreviewOpen(true);\n }, []);\n\n const handleClosePreview = useCallback(() => {\n setPreviewOpen(false);\n }, []);\n\n // When the preview modal opens, pause the authoring video so the\n // student view (in the modal) and the authoring surface do not\n // play in parallel. When the modal closes, leave the authoring\n // video paused — the user can press play to resume.\n useEffect(() => {\n if (previewOpen && videoRef.current) {\n try {\n videoRef.current.pause();\n } catch {\n // The video may not be ready yet; ignore.\n }\n }\n }, [previewOpen]);\n\n const handlePreviewLoadedMetadata = useCallback(\n (duration: number) => {\n // Track the last reported duration per src so the load-effect\n // repair pass can re-push it after the document commits its\n // potentially-stale value.\n if (state.videoSrc) {\n lastDurationForSrcRef.current = {\n src: state.videoSrc,\n duration,\n };\n }\n // Push the actual video duration into the store so the serialized\n // document is not stale.\n setVideoMetadata(state.videoSrc, duration);\n // Consume any pending seek that was deferred because the\n // <video> was not ready when `handleSelectEntry` fired. Now that\n // metadata is loaded, the setter is safe to call.\n const pending = pendingSeekRef.current;\n if (pending != null && videoRef.current) {\n try {\n videoRef.current.currentTime = pending;\n } catch {\n // Defensive: if the setter still throws, leave the ref alone\n // so the next metadata event (e.g. after a remount) can\n // re-attempt.\n }\n pendingSeekRef.current = null;\n }\n },\n [state.videoSrc, setVideoMetadata],\n );\n\n const handleSave = useCallback(() => {\n onSave(serialize());\n }, [onSave, serialize]);\n\n // Styling derived from the optional theme prop.\n const rootStyle: React.CSSProperties = {\n backgroundColor: theme?.backgroundColor ?? COLORS.surface,\n color: theme?.textColor ?? COLORS.text,\n borderColor: theme?.borderColor ?? COLORS.border,\n };\n const saveButtonStyle: React.CSSProperties = {\n backgroundColor: theme?.accentColor ?? COLORS.accent,\n color: COLORS.white,\n };\n const surfaceStyle: React.CSSProperties = {\n backgroundColor: theme?.surfaceColor ?? COLORS.surfaceRaised,\n borderColor: theme?.borderColor ?? COLORS.border,\n };\n\n if (showSourceStep) {\n return (\n <div\n className=\"interlace-editor\"\n style={{\n ...rootStyle,\n padding: 16,\n borderRadius: 8,\n border: \"1px solid\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n marginBottom: 16,\n }}\n >\n <h2\n style={{\n margin: 0,\n fontFamily: FONTS.display,\n fontSize: TYPE.lg,\n fontWeight: 600,\n }}\n >\n {strings.videoSourceInputTitle}\n </h2>\n {replaceMode ? (\n <button\n type=\"button\"\n onClick={handleCancelReplace}\n data-testid=\"interlace-editor-cancel-replace\"\n style={{\n padding: `${SPACE[1]}px ${SPACE[3]}px`,\n backgroundColor: COLORS.surface,\n border: `1px solid ${COLORS.borderStrong}`,\n borderRadius: RADIUS.sm,\n cursor: \"pointer\",\n fontSize: TYPE.sm,\n color: COLORS.text,\n transition: \"background-color 150ms ease\",\n }}\n >\n {strings.replaceCancelLabel}\n </button>\n ) : null}\n </div>\n <VideoSourceInput\n value={{\n src: state.videoSrc || undefined,\n duration: state.videoDuration || undefined,\n }}\n onChange={handleVideoSourceChange}\n onUpload={onUpload}\n onError={onError}\n strings={strings.videoSource}\n />\n </div>\n );\n }\n\n return (\n <div\n className=\"interlace-editor\"\n style={{\n ...rootStyle,\n padding: 16,\n borderRadius: 8,\n border: \"1px solid\",\n }}\n >\n <header\n style={{\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n marginBottom: 16,\n }}\n >\n <h2\n style={{\n margin: 0,\n fontFamily: FONTS.display,\n fontSize: TYPE.lg,\n fontWeight: 600,\n }}\n >\n {strings.previewTitle}\n </h2>\n <button\n type=\"button\"\n onClick={handleSave}\n data-testid=\"interlace-editor-save\"\n style={{\n ...saveButtonStyle,\n padding: `${SPACE[2]}px ${SPACE[4]}px`,\n border: \"none\",\n borderRadius: RADIUS.sm,\n cursor: \"pointer\",\n fontSize: TYPE.md,\n fontWeight: 600,\n boxShadow: SHADOWS.sm,\n transition: \"background-color 150ms ease\",\n }}\n >\n {strings.saveLabel}\n </button>\n </header>\n\n {/*\n The positioning context for the placement overlay must wrap\n exactly the video: an in-flow toolbar inside this wrapper would\n offset every rectangle by the toolbar's height (Gate 3\n Material #2). The toolbar therefore sits below the frame.\n */}\n <section\n className=\"interlace-editor-video\"\n style={{\n width: \"100%\",\n maxWidth: 720,\n margin: \"0 auto\",\n }}\n >\n <div\n data-testid=\"interlace-editor-video\"\n style={{ position: \"relative\" }}\n >\n <video\n ref={videoRef}\n key={state.videoSrc}\n src={state.videoSrc}\n controls\n preload=\"metadata\"\n onLoadedMetadata={(e) =>\n handlePreviewLoadedMetadata(e.currentTarget.duration)\n }\n onTimeUpdate={handleTimeUpdate}\n onPlay={() => setIsPlaying(true)}\n onPause={() => setIsPlaying(false)}\n data-testid=\"interlace-editor-preview-video\"\n style={{\n width: \"100%\",\n height: \"auto\",\n display: \"block\",\n backgroundColor: \"#000\",\n }}\n />\n {selectedHook ? (\n <PlacementEditor\n placement={selectedHook.placement}\n onPlacementChange={handlePlacementChange}\n />\n ) : null}\n </div>\n <EditorVideoToolbar\n duration={state.videoDuration || undefined}\n strings={strings}\n onReplaceVideo={handleReplaceVideo}\n onOpenPreview={handleOpenPreview}\n theme={theme}\n hint={selectedHook ? undefined : strings.noItemSelectedLabel}\n />\n </section>\n\n <PreviewModal\n isOpen={previewOpen}\n videoSrc={state.videoSrc}\n document={previewDocument}\n contentTypeRegistry={contentTypeRegistry}\n onClose={handleClosePreview}\n onError={onError}\n strings={strings.previewModal}\n />\n\n <section\n className=\"interlace-editor-timeline\"\n style={{\n ...surfaceStyle,\n marginTop: 16,\n padding: 16,\n borderRadius: 8,\n border: \"1px solid\",\n }}\n >\n <h3\n style={{\n marginTop: 0,\n fontFamily: FONTS.display,\n fontSize: TYPE.md,\n fontWeight: 600,\n }}\n >\n {strings.timelineHeading}\n </h3>\n <KeyframeTimeline\n entries={timelineEntries}\n selectedId={selectedItemId ?? undefined}\n videoDuration={state.videoDuration || 0}\n currentTime={currentTime}\n isPlaying={isPlaying}\n onSeek={handleTimelineSeek}\n onTogglePlay={handleTogglePlay}\n onSelectEntry={handleSelectEntry}\n onUpdateEntry={handleUpdateEntry}\n onDeleteEntry={handleDeleteEntry}\n onAddEntry={handleAddEntry}\n onDeselect={handleDeselect}\n />\n </section>\n\n {selectedItemId && selectedHook ? (\n <section\n className=\"interlace-editor-hook\"\n data-testid=\"interlace-editor-hook\"\n style={{\n ...surfaceStyle,\n marginTop: 16,\n padding: 16,\n borderRadius: 8,\n border: \"1px solid\",\n }}\n >\n <h3\n style={{\n marginTop: 0,\n fontFamily: FONTS.display,\n fontSize: TYPE.md,\n fontWeight: 600,\n }}\n >\n {strings.hookHeading}\n </h3>\n {/* Hook details: title, type, time/timespan, manual placement\n inputs, content type selection. */}\n <InspectorPanel\n entry={{\n id: selectedItemId,\n title: selectedTitle ?? \"\",\n hookType: selectedHook.type,\n timestamp:\n selectedHook.type === \"blocking\"\n ? selectedHook.timestamp\n : undefined,\n start:\n selectedHook.type === \"non-blocking\"\n ? selectedHook.start\n : undefined,\n end:\n selectedHook.type === \"non-blocking\"\n ? selectedHook.end\n : undefined,\n videoDuration: state.videoDuration || 0,\n contentTypeId: selectedContentTypeId,\n registeredTypes: registeredTypeIds,\n }}\n onTitleChange={(title) =>\n handleUpdateEntry(selectedItemId, { title })\n }\n onTimeChange={handleTimeChange}\n onContentTypeSelect={handleContentTypeSelect}\n placement={selectedHook.placement}\n onPlacementChange={handlePlacementChange}\n onDelete={() => handleDeleteEntry(selectedItemId)}\n />\n {/* Content editor: shown once the hook has a content type. A\n newly created hook (pending) hides it until the type is\n chosen in Hook details. */}\n {selectedContentTypeId ? (\n <div style={{ marginTop: 12 }}>\n <h4\n style={{\n margin: `0 0 ${SPACE[1]}px 0`,\n fontSize: TYPE.sm,\n color: theme?.mutedTextColor ?? COLORS.textMuted,\n fontWeight: 600,\n }}\n >\n {strings.contentEditorHeading}\n </h4>\n <ContentTypeEditor\n contentTypeId={selectedContentTypeId}\n registry={contentTypeRegistry}\n data={selectedData}\n onChange={handleContentChange}\n />\n </div>\n ) : null}\n </section>\n ) : null}\n </div>\n );\n}\n","/**\n * Interlace design tokens.\n *\n * These values mirror the demo app's CSS custom properties so the library\n * surfaces feel like a single system. They are duplicated per package to\n * avoid adding runtime cross-package dependencies.\n */\n\nexport const COLORS = {\n accent: \"#0066cc\",\n accentHover: \"#0052a3\",\n accentLight: \"rgba(0, 102, 204, 0.15)\",\n accentLighter: \"rgba(0, 102, 204, 0.08)\",\n text: \"#0f172a\",\n textMuted: \"#64748b\",\n border: \"#e2e8f0\",\n borderStrong: \"#cbd5e1\",\n surface: \"#ffffff\",\n surfaceRaised: \"#f8fafc\",\n ground: \"#f6f7f9\",\n errorBg: \"#fef2f2\",\n errorText: \"#b91c1c\",\n errorBorder: \"#fecaca\",\n white: \"#ffffff\",\n black: \"#000000\",\n} as const;\n\nexport const FONTS = {\n display: 'Georgia, \"Times New Roman\", Times, serif',\n body: 'system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif',\n} as const;\n\nexport const SPACE = {\n 1: 4,\n 2: 8,\n 3: 12,\n 4: 16,\n 5: 24,\n} as const;\n\nexport const RADIUS = {\n sm: 4,\n md: 8,\n lg: 12,\n} as const;\n\nexport const SHADOWS = {\n sm: \"0 1px 2px 0 rgba(15, 23, 42, 0.04)\",\n md: \"0 4px 12px -2px rgba(15, 23, 42, 0.08)\",\n} as const;\n\nexport const TYPE = {\n xs: 12,\n sm: 13,\n base: 15,\n md: 16,\n lg: 20,\n xl: 24,\n} as const;\n","import type { SerializedInteractiveMediaDocument } from \"@interlacejs/core\";\nimport {\n ContentInstance,\n ContentTypeRegistry,\n Hook,\n serialize as coreSerialize,\n deserialize,\n} from \"@interlacejs/core\";\nimport { useCallback, useState } from \"react\";\n\n/**\n * A single interactive media entry being authored: its content instance\n * plus the hook describing when/where it appears.\n */\nexport interface InteractiveMediaItem {\n content: ContentInstance;\n hook: Hook;\n}\n\nexport interface AuthoringStoreState {\n items: InteractiveMediaItem[];\n videoSrc: string;\n videoDuration: number;\n}\n\nexport interface LoadDocumentResult {\n validationErrors: string[];\n warnings: string[];\n}\n\nexport interface AuthoringStore {\n state: AuthoringStoreState;\n addItem: (item: InteractiveMediaItem) => void;\n removeItem: (id: string) => void;\n updateItem: (id: string, item: InteractiveMediaItem) => void;\n /**\n * Serializes the current items into a document via core's `serialize`.\n * The legacy `adapterType` argument is accepted (and ignored) so existing\n * callers do not break; the new core serializer does not produce it.\n */\n serialize: (adapterType?: unknown) => SerializedInteractiveMediaDocument;\n loadDocument: (\n doc: SerializedInteractiveMediaDocument,\n registry: ContentTypeRegistry,\n ) => LoadDocumentResult;\n setVideoMetadata: (src: string, duration: number) => void;\n}\n\n/**\n * Authoring store for managing interactive content creation.\n * Handles document state, serialization, and item management.\n */\nexport function useAuthoringStore(\n initialVideoSrc: string,\n initialDuration: number,\n): AuthoringStore {\n const [state, setState] = useState<AuthoringStoreState>({\n items: [],\n videoSrc: initialVideoSrc,\n videoDuration: initialDuration,\n });\n\n const addItem = useCallback((item: InteractiveMediaItem) => {\n setState((prev) => ({\n ...prev,\n items: [...prev.items, item],\n }));\n }, []);\n\n const removeItem = useCallback((id: string) => {\n setState((prev) => ({\n ...prev,\n items: prev.items.filter((item) => item.content.getId() !== id),\n }));\n }, []);\n\n const updateItem = useCallback(\n (id: string, newItem: InteractiveMediaItem) => {\n setState((prev) => ({\n ...prev,\n items: prev.items.map((item) =>\n item.content.getId() === id ? newItem : item,\n ),\n }));\n },\n [],\n );\n\n const doSerialize = useCallback(\n () =>\n coreSerialize(\n state.items.map((item) => item.content),\n state.videoSrc,\n state.videoDuration,\n ),\n [state],\n );\n\n const loadDocument = useCallback(\n (\n doc: SerializedInteractiveMediaDocument,\n registry: ContentTypeRegistry,\n ): LoadDocumentResult => {\n const { items, videoSrc, videoDuration, validationErrors, warnings } =\n deserialize(doc, registry);\n setState({\n items: items.map((content) => ({ content, hook: content.getHook() })),\n videoSrc,\n videoDuration,\n });\n return { validationErrors, warnings };\n },\n [],\n );\n\n const setVideoMetadata = useCallback((src: string, duration: number) => {\n setState((prev) => ({\n ...prev,\n videoSrc: src,\n videoDuration: duration,\n }));\n }, []);\n\n return {\n state,\n addItem,\n removeItem,\n updateItem,\n serialize: doSerialize,\n loadDocument,\n setVideoMetadata,\n };\n}\n","import React, { useRef } from \"react\";\nimport { ContentTypeRegistry } from \"@interlacejs/core\";\nimport { useContentTypeEditorMount } from \"./content-type-editor-mount\";\n\nexport interface ContentTypeEditorProps<TData = unknown> {\n /** The content type to mount, or `null` while the hook has no content type yet. */\n contentTypeId: string | null;\n registry: ContentTypeRegistry;\n data: TData;\n onChange: (newData: TData) => void;\n}\n\n/**\n * ContentTypeEditor - the inline, chrome-free surface that mounts a\n * content type's own editing interface (`renderEditor` /\n * `updateEditor` / `unmount` via the shared\n * `useContentTypeEditorMount` lifecycle).\n *\n * Renders nothing while `contentTypeId` is null (a newly created hook\n * without a content type yet) or when the type is not registered —\n * callers label the subsection and decide visibility.\n */\nexport function ContentTypeEditor<TData = unknown>({\n contentTypeId,\n registry,\n data,\n onChange,\n}: ContentTypeEditorProps<TData>) {\n const containerRef = useRef<HTMLDivElement>(null);\n\n useContentTypeEditorMount<TData>({\n containerRef,\n active: contentTypeId != null,\n contentTypeId,\n registry,\n data,\n onChange,\n });\n\n const contentType = contentTypeId ? registry.get(contentTypeId) : undefined;\n if (!contentTypeId || !contentType) return null;\n\n return (\n <div\n ref={containerRef}\n className=\"content-type-editor\"\n data-testid=\"content-type-editor\"\n style={{ minHeight: 60 }}\n />\n );\n}\n","import type React from \"react\";\nimport { useEffect, useRef } from \"react\";\nimport { ContentType, ContentTypeRegistry } from \"@interlacejs/core\";\n\ninterface MountedSession<TData> {\n container: HTMLDivElement;\n contentType: ContentType<TData>;\n}\n\nexport interface UseContentTypeEditorMountOptions<TData = unknown> {\n /** The div the content type renders into. Owned by the calling component. */\n containerRef: React.RefObject<HTMLDivElement | null>;\n /** Whether the editing session is active (slot: `isOpen`; inline editor: has a content type). */\n active: boolean;\n contentTypeId: string | null;\n registry: ContentTypeRegistry;\n data: TData;\n onChange: (newData: TData) => void;\n}\n\n/**\n * Shared mount lifecycle for content-type editors (the modal\n * `ContentTypeEditorSlot` and the inline `ContentTypeEditor` both use\n * it).\n *\n * The content type renders into `containerRef` via\n * `renderEditor` / `updateEditor` / `unmount`. On data changes it\n * prefers `updateEditor` (cheap) and falls back to unmount + re-render.\n *\n * A single `mountedSessionRef` captures the live `{ container,\n * contentType }` whenever an effect mounts a session. Every teardown\n * path (deactivation, type switch, component unmount) consumes it, so\n * the contract's `unmount?.(container)` is always called for the\n * session that was mounted — even when the live `contentType` is\n * already undefined by the time the teardown effect runs (e.g. a\n * nulled `contentTypeId`).\n */\nexport function useContentTypeEditorMount<TData = unknown>({\n containerRef,\n active,\n contentTypeId,\n registry,\n data,\n onChange,\n}: UseContentTypeEditorMountOptions<TData>): void {\n const mountedSessionRef = useRef<MountedSession<TData> | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n const contentType = contentTypeId\n ? (registry.get(contentTypeId) as ContentType<TData> | undefined)\n : undefined;\n\n useEffect(() => {\n const session = mountedSessionRef.current;\n\n // Session ended: deactivated, or the content type is no longer\n // available (nulled id / unregistered). Tear down using the\n // captured contentType, not the live prop (which may already be\n // undefined).\n if (session && (!active || !contentType)) {\n session.contentType.unmount?.(session.container);\n mountedSessionRef.current = null;\n return;\n }\n\n const container = containerRef.current;\n if (!container) return;\n\n if (!active || !contentType) return;\n\n // Type switch: tear down the previous session before mounting the\n // new one.\n if (session && session.contentType !== contentType) {\n session.contentType.unmount?.(session.container);\n mountedSessionRef.current = null;\n }\n\n const currentSession = mountedSessionRef.current;\n const isNewSession =\n !currentSession || currentSession.contentType !== contentType;\n if (isNewSession) {\n container.innerHTML = \"\";\n contentType.renderEditor(container, data, onChangeRef.current);\n mountedSessionRef.current = { container, contentType };\n } else if (contentType.updateEditor) {\n contentType.updateEditor(container, data, onChangeRef.current);\n } else {\n contentType.unmount?.(container);\n container.innerHTML = \"\";\n contentType.renderEditor(container, data, onChangeRef.current);\n mountedSessionRef.current = { container, contentType };\n }\n }, [active, contentTypeId, contentType, data, containerRef]);\n\n // Tear down on component unmount (not just deactivation).\n useEffect(() => {\n return () => {\n const session = mountedSessionRef.current;\n if (session) {\n session.contentType.unmount?.(session.container);\n mountedSessionRef.current = null;\n }\n };\n }, []);\n}\n","import {\n DEFAULT_STRINGS,\n type Placement,\n type Strings,\n} from \"@interlacejs/core\";\nimport React, { useCallback, useRef } from \"react\";\nimport { COLORS, FONTS, RADIUS, SPACE, TYPE } from \"../tokens\";\nimport { ContentTypePicker } from \"./content-type-picker\";\nimport { PlacementInputs } from \"./placement-editor\";\n\n/**\n * Localized strings consumed by `InspectorPanel`. Extends the core\n * `Strings` so a host passing a single translation table covers every\n * editor surface.\n */\nexport interface InspectorPanelStrings extends Strings {\n /** Heading for the panel. */\n inspectorHeading: string;\n /** Label above the title input. */\n titleLabel: string;\n /** Label for the delete button. */\n deleteLabel: string;\n /** Label for the read-only hook-type row. */\n hookTypeLabel: string;\n /** Rendered value for a blocking hook's type row. */\n blockingTypeLabel: string;\n /** Rendered value for a non-blocking hook's type row. */\n nonBlockingTypeLabel: string;\n /** Label above the blocking hook's timestamp input. */\n timestampLabel: string;\n /** Label above a non-blocking hook's start input. */\n startLabel: string;\n /** Label above a non-blocking hook's end input. */\n endLabel: string;\n /** Label above the placement inputs. */\n placementLabel: string;\n /** Label above the content type row. */\n contentTypeLabel: string;\n}\n\nexport const DEFAULT_INSPECTOR_PANEL_STRINGS: InspectorPanelStrings = {\n ...DEFAULT_STRINGS,\n inspectorHeading: \"Hook details\",\n titleLabel: \"Title\",\n deleteLabel: \"Delete\",\n hookTypeLabel: \"Type\",\n blockingTypeLabel: \"Blocking\",\n nonBlockingTypeLabel: \"Non-blocking\",\n timestampLabel: \"Timestamp (s)\",\n startLabel: \"Start (s)\",\n endLabel: \"End (s)\",\n placementLabel: \"Placement\",\n contentTypeLabel: \"Content type\",\n};\n\nexport interface InspectorPanelEntry {\n id: string;\n title: string;\n hookType: \"blocking\" | \"non-blocking\";\n /** Anchor time for a blocking hook (seconds). */\n timestamp?: number;\n /** Range start for a non-blocking hook (seconds). */\n start?: number;\n /** Range end for a non-blocking hook (seconds). */\n end?: number;\n /** Total video duration (bounds for the time inputs). */\n videoDuration: number;\n /**\n * The hook's resolved content type id, or `null` while the hook is\n * pending (newly created, content type not yet chosen).\n */\n contentTypeId: string | null;\n /** Registered content type ids (drives the picker for pending hooks). */\n registeredTypes: string[];\n}\n\nexport interface InspectorPanelProps {\n entry: InspectorPanelEntry;\n onTitleChange: (title: string) => void;\n onTimeChange: (updates: {\n timestamp?: number;\n start?: number;\n end?: number;\n }) => void;\n /** Called when a pending hook's content type is chosen (materializes it). */\n onContentTypeSelect: (contentTypeId: string) => void;\n placement?: Placement;\n onPlacementChange?: (placement: Placement) => void;\n onDelete: () => void;\n strings?: Partial<InspectorPanelStrings>;\n}\n\nconst INPUT_STYLE: React.CSSProperties = {\n width: \"70px\",\n padding: `${SPACE[1]}px ${SPACE[2]}px`,\n border: `1px solid ${COLORS.borderStrong}`,\n borderRadius: RADIUS.sm,\n fontSize: TYPE.sm,\n color: COLORS.text,\n};\n\n/**\n * InspectorPanel - the \"Hook details\" panel for the currently selected\n * hook. Shows the title input, the read-only hook type, editable\n * time/timespan inputs, the manual placement inputs, the content type\n * (a picker for pending hooks; read-only for hooks that already have\n * one — switching an existing hook's type would discard its authored\n * data), and the delete action.\n *\n * The content *editing* surface itself lives in the inline\n * `ContentTypeEditor`, rendered by `InterlaceEditor` directly under\n * this panel when the hook has a content type.\n */\nexport const InspectorPanel: React.FC<InspectorPanelProps> = ({\n entry,\n onTitleChange,\n onTimeChange,\n onContentTypeSelect,\n placement,\n onPlacementChange,\n onDelete,\n strings: stringsOverride,\n}) => {\n const strings = { ...DEFAULT_INSPECTOR_PANEL_STRINGS, ...stringsOverride };\n // Latest props for the handlers (stable callbacks, render-time sync —\n // the PlacementEditor pattern).\n const onChangeRef = useRef(onTitleChange);\n onChangeRef.current = onTitleChange;\n const onDeleteRef = useRef(onDelete);\n onDeleteRef.current = onDelete;\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLDivElement>) => {\n // Delete via keyboard, mirroring the button affordance. The\n // inputs handle their own keys; this only fires when the panel\n // (not an input) has focus.\n if (e.key === \"Delete\" || e.key === \"Backspace\") {\n if ((e.target as HTMLElement).tagName === \"INPUT\") return;\n e.preventDefault();\n onDeleteRef.current();\n }\n },\n [],\n );\n\n const isBlocking = entry.hookType === \"blocking\";\n\n return (\n <div\n className=\"inspector-panel\"\n data-testid=\"inspector-panel\"\n tabIndex={0}\n onKeyDown={handleKeyDown}\n style={{\n border: `1px solid ${COLORS.border}`,\n borderRadius: RADIUS.md,\n backgroundColor: COLORS.surfaceRaised,\n padding: SPACE[3],\n display: \"flex\",\n flexDirection: \"column\",\n gap: SPACE[2],\n fontSize: TYPE.sm,\n }}\n >\n <h4\n style={{\n margin: 0,\n fontFamily: FONTS.display,\n fontSize: TYPE.md,\n fontWeight: 600,\n color: COLORS.text,\n }}\n >\n {strings.inspectorHeading}\n </h4>\n <label style={{ display: \"flex\", flexDirection: \"column\", gap: 4 }}>\n {strings.titleLabel}\n <input\n type=\"text\"\n data-testid=\"inspector-panel-title\"\n value={entry.title}\n onChange={(e) => onTitleChange(e.target.value)}\n aria-label={strings.titleLabel}\n style={{\n padding: `${SPACE[2]}px ${SPACE[2]}px`,\n border: `1px solid ${COLORS.borderStrong}`,\n borderRadius: RADIUS.sm,\n fontSize: TYPE.sm,\n color: COLORS.text,\n }}\n />\n </label>\n <div style={{ display: \"flex\", gap: 16, color: COLORS.textMuted }}>\n <span>\n {strings.hookTypeLabel}:{\" \"}\n <strong data-testid=\"inspector-panel-type\">\n {isBlocking ? strings.blockingTypeLabel : strings.nonBlockingTypeLabel}\n </strong>\n </span>\n </div>\n\n {/* Time / timespan inputs (clamped by the parent's onTimeChange) */}\n <div style={{ display: \"flex\", gap: 12, alignItems: \"flex-end\" }}>\n {isBlocking ? (\n <label>\n {strings.timestampLabel}\n <input\n type=\"number\"\n data-testid=\"inspector-panel-timestamp\"\n value={(entry.timestamp ?? 0).toFixed(1)}\n onChange={(e) =>\n onTimeChange({ timestamp: parseFloat(e.target.value) || 0 })\n }\n style={INPUT_STYLE}\n />\n </label>\n ) : (\n <>\n <label>\n {strings.startLabel}\n <input\n type=\"number\"\n data-testid=\"inspector-panel-start\"\n value={(entry.start ?? 0).toFixed(1)}\n onChange={(e) =>\n onTimeChange({ start: parseFloat(e.target.value) || 0 })\n }\n style={INPUT_STYLE}\n />\n </label>\n <label>\n {strings.endLabel}\n <input\n type=\"number\"\n data-testid=\"inspector-panel-end\"\n value={(entry.end ?? 0).toFixed(1)}\n onChange={(e) =>\n onTimeChange({ end: parseFloat(e.target.value) || 0 })\n }\n style={INPUT_STYLE}\n />\n </label>\n </>\n )}\n </div>\n\n {/* Manual placement inputs */}\n {placement && onPlacementChange ? (\n <div>\n <div\n style={{\n color: COLORS.textMuted,\n marginBottom: SPACE[1],\n fontWeight: 600,\n }}\n >\n {strings.placementLabel}\n </div>\n <PlacementInputs\n placement={placement}\n onPlacementChange={onPlacementChange}\n />\n </div>\n ) : null}\n\n {/* Content type: picker for pending hooks and for re-typing\n typed hooks (re-typing resets the content data to the new\n type's default shape). */}\n <div>\n <div\n style={{\n color: COLORS.textMuted,\n marginBottom: SPACE[1],\n fontWeight: 600,\n }}\n >\n {strings.contentTypeLabel}\n </div>\n <ContentTypePicker\n registeredTypes={entry.registeredTypes}\n selectedType={entry.contentTypeId ?? null}\n onSelect={onContentTypeSelect}\n />\n </div>\n\n <div style={{ display: \"flex\", justifyContent: \"flex-end\" }}>\n <button\n type=\"button\"\n onClick={onDelete}\n data-testid=\"inspector-panel-delete\"\n style={{\n padding: `${SPACE[1]}px ${SPACE[3]}px`,\n backgroundColor: COLORS.errorBg,\n border: `1px solid ${COLORS.errorBorder}`,\n borderRadius: RADIUS.sm,\n color: COLORS.errorText,\n cursor: \"pointer\",\n fontSize: TYPE.sm,\n fontWeight: 600,\n transition: \"background-color 150ms ease\",\n }}\n >\n {strings.deleteLabel}\n </button>\n </div>\n </div>\n );\n};\n","import React, { useState } from \"react\";\nimport { COLORS, RADIUS, SHADOWS, SPACE, TYPE } from \"../tokens\";\n\nexport interface ContentTypePickerProps {\n registeredTypes: string[];\n selectedType: string | null;\n onSelect: (typeId: string) => void;\n}\n\n/**\n * ContentTypePicker - dropdown for selecting content type when creating new content.\n */\nexport const ContentTypePicker: React.FC<ContentTypePickerProps> = ({\n registeredTypes,\n selectedType,\n onSelect,\n}) => {\n const [isOpen, setIsOpen] = useState(false);\n\n return (\n <div style={{ position: \"relative\" }}>\n <button\n onClick={() => setIsOpen(!isOpen)}\n style={{\n width: \"100%\",\n padding: `${SPACE[2]}px ${SPACE[3]}px`,\n backgroundColor: COLORS.surface,\n border: `1px solid ${COLORS.borderStrong}`,\n borderRadius: `${RADIUS.sm}px`,\n cursor: \"pointer\",\n textAlign: \"left\",\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n fontSize: TYPE.base,\n color: COLORS.text,\n transition: \"border-color 150ms ease, background-color 150ms ease\",\n }}\n >\n <span>{selectedType || \"Select content type...\"}</span>\n <span>{isOpen ? \"▼\" : \"▶\"}</span>\n </button>\n\n {isOpen && (\n <div\n style={{\n position: \"absolute\",\n top: \"100%\",\n left: 0,\n right: 0,\n backgroundColor: COLORS.surface,\n border: `1px solid ${COLORS.borderStrong}`,\n borderTop: \"none\",\n borderRadius: `0 0 ${RADIUS.sm}px ${RADIUS.sm}px`,\n maxHeight: \"200px\",\n overflowY: \"auto\",\n zIndex: 10,\n boxShadow: SHADOWS.md,\n }}\n >\n {registeredTypes.map((typeId) => (\n <div\n key={typeId}\n onClick={() => {\n onSelect(typeId);\n setIsOpen(false);\n }}\n style={{\n padding: `${SPACE[2]}px ${SPACE[3]}px`,\n cursor: \"pointer\",\n backgroundColor:\n selectedType === typeId ? COLORS.accentLighter : COLORS.surface,\n borderBottom: `1px solid ${COLORS.border}`,\n color: selectedType === typeId ? COLORS.accent : COLORS.text,\n fontSize: TYPE.base,\n transition: \"background-color 150ms ease\",\n }}\n >\n {typeId}\n </div>\n ))}\n </div>\n )}\n </div>\n );\n};\n","import { Placement } from \"@interlacejs/core\";\nimport React, { useCallback, useEffect, useRef } from \"react\";\nimport { COLORS, RADIUS, SHADOWS, SPACE, TYPE } from \"../tokens\";\n\n/**\n * PlacementEditor - an overlay for positioning a hook's placement\n * rectangle on the video frame. Must be stacked (via a `position:\n * relative` container) directly on top of a `<video>` element; the\n * overlay maps placement percentages against its *own* rendered box,\n * which equals the video frame when the container hugs the video.\n *\n * Interaction model:\n * - Drag the rectangle to move it (pointer capture keeps the drag\n * alive when the pointer leaves the frame, so the bounds clamps\n * are reachable by overshooting past the video edge).\n * - Drag any of the 8 handles (4 corners + 4 edges) to resize. The\n * opposite edge stays anchored on west/north handles.\n * - Arrow keys on the focused rectangle nudge by 1% (5% with Shift).\n * - The X/Y/W/H numerical inputs clamp through the same policy as\n * the pointer paths.\n *\n * Clamping policy (`clampPlacement`): move keeps the rectangle fully\n * inside the frame; resize keeps the origin anchored and enforces a\n * minimum size so a hook can never be resized into invisibility.\n */\n\nexport interface PlacementEditorProps {\n placement: Placement;\n onPlacementChange: (placement: Placement) => void;\n}\n\n/** Minimum rectangle size in percent of the frame, per axis. */\nexport const PLACEMENT_MIN_SIZE = 1;\n\ntype DragIntent = \"move\" | \"resize\";\ntype HandleId = \"nw\" | \"n\" | \"ne\" | \"e\" | \"se\" | \"s\" | \"sw\" | \"w\";\n\nfunction clampValue(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(value, max));\n}\n\n/**\n * Centralized bounds policy for every placement change path (drag,\n * handles, keyboard nudge, numerical inputs).\n *\n * - \"move\": the rectangle must stay fully inside the frame —\n * `x ∈ [0, 100 − width]`, `y ∈ [0, 100 − height]`.\n * - \"resize\": the origin stays anchored —\n * `width ∈ [MIN, 100 − x]`, `height ∈ [MIN, 100 − y]`. An\n * out-of-range origin (possible from a loaded document with bad\n * data) is repaired first so both the bounds and the minimum size\n * can hold simultaneously.\n */\nexport function clampPlacement(next: Placement, intent: DragIntent): Placement {\n if (intent === \"move\") {\n const width = Math.max(PLACEMENT_MIN_SIZE, next.width);\n const height = Math.max(PLACEMENT_MIN_SIZE, next.height);\n return {\n ...next,\n width,\n height,\n x: clampValue(next.x, 0, 100 - width),\n y: clampValue(next.y, 0, 100 - height),\n };\n }\n const x = clampValue(next.x, 0, 100 - PLACEMENT_MIN_SIZE);\n const y = clampValue(next.y, 0, 100 - PLACEMENT_MIN_SIZE);\n return {\n ...next,\n x,\n y,\n width: clampValue(next.width, PLACEMENT_MIN_SIZE, 100 - x),\n height: clampValue(next.height, PLACEMENT_MIN_SIZE, 100 - y),\n };\n}\n\n/**\n * Raw (unclamped) resize candidate for one handle. West/north handles\n * keep the opposite edge anchored; the pre-guard prevents negative\n * sizes before `clampPlacement`'s resize policy runs.\n */\nfunction resizeCandidate(\n handle: HandleId,\n start: Placement,\n px: number,\n py: number,\n): Placement {\n const right = start.x + start.width;\n const bottom = start.y + start.height;\n const anchorX = Math.min(px, right - PLACEMENT_MIN_SIZE);\n const anchorY = Math.min(py, bottom - PLACEMENT_MIN_SIZE);\n switch (handle) {\n case \"e\":\n return { ...start, width: px - start.x };\n case \"w\":\n return { ...start, x: anchorX, width: right - anchorX };\n case \"s\":\n return { ...start, height: py - start.y };\n case \"n\":\n return { ...start, y: anchorY, height: bottom - anchorY };\n case \"se\":\n return { ...start, width: px - start.x, height: py - start.y };\n case \"ne\":\n return {\n ...start,\n width: px - start.x,\n y: anchorY,\n height: bottom - anchorY,\n };\n case \"sw\":\n return {\n ...start,\n x: anchorX,\n width: right - anchorX,\n height: py - start.y,\n };\n case \"nw\":\n return {\n ...start,\n x: anchorX,\n width: right - anchorX,\n y: anchorY,\n height: bottom - anchorY,\n };\n }\n}\n\nconst HANDLE_SIZE = 10; // px\n\ninterface HandleDef {\n id: HandleId;\n label: string;\n cursor: string;\n style: React.CSSProperties;\n}\n\nconst HANDLE_DEFS: HandleDef[] = [\n {\n id: \"nw\",\n label: \"Resize north-west\",\n cursor: \"nwse-resize\",\n style: { top: -HANDLE_SIZE / 2, left: -HANDLE_SIZE / 2 },\n },\n {\n id: \"n\",\n label: \"Resize north\",\n cursor: \"ns-resize\",\n style: { top: -HANDLE_SIZE / 2, left: \"50%\", marginLeft: -HANDLE_SIZE / 2 },\n },\n {\n id: \"ne\",\n label: \"Resize north-east\",\n cursor: \"nesw-resize\",\n style: { top: -HANDLE_SIZE / 2, right: -HANDLE_SIZE / 2 },\n },\n {\n id: \"e\",\n label: \"Resize east\",\n cursor: \"ew-resize\",\n style: {\n top: \"50%\",\n right: -HANDLE_SIZE / 2,\n marginTop: -HANDLE_SIZE / 2,\n },\n },\n {\n id: \"se\",\n label: \"Resize south-east\",\n cursor: \"nwse-resize\",\n style: { bottom: -HANDLE_SIZE / 2, right: -HANDLE_SIZE / 2 },\n },\n {\n id: \"s\",\n label: \"Resize south\",\n cursor: \"ns-resize\",\n style: {\n bottom: -HANDLE_SIZE / 2,\n left: \"50%\",\n marginLeft: -HANDLE_SIZE / 2,\n },\n },\n {\n id: \"sw\",\n label: \"Resize south-west\",\n cursor: \"nesw-resize\",\n style: { bottom: -HANDLE_SIZE / 2, left: -HANDLE_SIZE / 2 },\n },\n {\n id: \"w\",\n label: \"Resize west\",\n cursor: \"ew-resize\",\n style: {\n top: \"50%\",\n left: -HANDLE_SIZE / 2,\n marginTop: -HANDLE_SIZE / 2,\n },\n },\n];\n\ninterface DragState {\n cleanup: () => void;\n}\n\n/**\n * PlacementEditor overlay. See the interface doc for the interaction\n * model. All %↔pixel conversion happens against this component's own\n * frame layer (`getBoundingClientRect`), which equals the video frame\n * when the parent stacks it over the video with `position: relative`.\n */\nexport const PlacementEditor: React.FC<PlacementEditorProps> = ({\n placement,\n onPlacementChange,\n}) => {\n const frameRef = useRef<HTMLDivElement | null>(null);\n const dragRef = useRef<DragState | null>(null);\n // Latest props, read from the native pointer listeners (which would\n // otherwise close over stale values).\n const placementRef = useRef(placement);\n placementRef.current = placement;\n const onPlacementChangeRef = useRef(onPlacementChange);\n onPlacementChangeRef.current = onPlacementChange;\n\n // Ensure a drag in progress is cleaned up if the component unmounts\n // mid-drag (e.g. the parent removes the selected item or the\n // editor is torn down). Without this, the target and window\n // listeners would leak and dragRef.current would stay set, blocking\n // future drags on a remounted instance.\n useEffect(() => {\n return () => {\n dragRef.current?.cleanup();\n };\n }, []);\n\n const beginDrag = useCallback(\n (e: React.PointerEvent<HTMLElement>, handle: HandleId | \"move\") => {\n // Reject non-primary buttons. jsdom has no PointerEvent\n // constructor, so fireEvent falls back to a generic event where\n // `button` is undefined — only reject when a real number says\n // it is not the primary button.\n if (typeof e.button === \"number\" && e.button !== 0) return;\n if (dragRef.current) return; // one drag at a time\n const frame = frameRef.current;\n const target = e.currentTarget;\n if (!frame) return;\n const frameRect = frame.getBoundingClientRect();\n if (frameRect.width <= 0 || frameRect.height <= 0) return;\n\n e.preventDefault();\n e.stopPropagation();\n\n const start = placementRef.current;\n const startPointerPct = {\n x: ((e.clientX - frameRect.left) / frameRect.width) * 100,\n y: ((e.clientY - frameRect.top) / frameRect.height) * 100,\n };\n const intent: DragIntent = handle === \"move\" ? \"move\" : \"resize\";\n\n const onMove = (ev: PointerEvent) => {\n const px = ((ev.clientX - frameRect.left) / frameRect.width) * 100;\n const py = ((ev.clientY - frameRect.top) / frameRect.height) * 100;\n let candidate: Placement;\n if (handle === \"move\") {\n candidate = {\n ...start,\n x: start.x + (px - startPointerPct.x),\n y: start.y + (py - startPointerPct.y),\n };\n } else {\n candidate = resizeCandidate(handle, start, px, py);\n }\n onPlacementChangeRef.current(clampPlacement(candidate, intent));\n };\n\n const cleanup = () => {\n target.removeEventListener(\"pointermove\", onMove);\n target.removeEventListener(\"pointerup\", onUp);\n target.removeEventListener(\"pointercancel\", onUp);\n // Window-level fallbacks (added in beginDrag below) — they\n // catch the release when the pointer is over an element that\n // did not receive the captured events, or when capture itself\n // is unsupported.\n window.removeEventListener(\"pointerup\", onUp);\n window.removeEventListener(\"pointercancel\", onUp);\n try {\n target.releasePointerCapture?.(pointerId);\n } catch {\n // Capture may already be released (e.g. pointercancel);\n // nothing to do — the drag is over either way.\n }\n dragRef.current = null;\n };\n const onUp = () => {\n cleanup();\n };\n\n const pointerId = e.pointerId;\n try {\n // Pointer capture retargets all subsequent pointer events to\n // `target`, so the drag survives the pointer leaving the\n // frame — required for the bounds clamps to be reachable by\n // overshooting past the video edge.\n target.setPointerCapture?.(pointerId);\n } catch {\n // jsdom and some engines do not implement pointer capture;\n // the native listeners below still work for in-frame drags.\n }\n target.addEventListener(\"pointermove\", onMove);\n target.addEventListener(\"pointerup\", onUp);\n target.addEventListener(\"pointercancel\", onUp);\n // Window-level fallbacks: if pointer capture is unavailable\n // and the pointer is released off-target, `pointerup` never\n // reaches `target`, so the target listeners alone would leave\n // the drag stuck. The window listeners guarantee cleanup runs.\n window.addEventListener(\"pointerup\", onUp);\n window.addEventListener(\"pointercancel\", onUp);\n dragRef.current = { cleanup };\n },\n [],\n );\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLDivElement>) => {\n const step = e.shiftKey ? 5 : 1;\n let next: Placement | null = null;\n switch (e.key) {\n case \"ArrowLeft\":\n next = { ...placementRef.current, x: placementRef.current.x - step };\n break;\n case \"ArrowRight\":\n next = { ...placementRef.current, x: placementRef.current.x + step };\n break;\n case \"ArrowUp\":\n next = { ...placementRef.current, y: placementRef.current.y - step };\n break;\n case \"ArrowDown\":\n next = { ...placementRef.current, y: placementRef.current.y + step };\n break;\n default:\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n onPlacementChangeRef.current(clampPlacement(next, \"move\"));\n },\n [],\n );\n\n return (\n <div\n ref={frameRef}\n className=\"placement-editor\"\n data-testid=\"placement-editor\"\n style={{\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n }}\n >\n <div\n tabIndex={0}\n role=\"application\"\n aria-label={`Placement: x ${placement.x.toFixed(0)}%, y ${placement.y.toFixed(0)}%, width ${placement.width.toFixed(0)}%, height ${placement.height.toFixed(0)}%. Arrow keys nudge.`}\n data-testid=\"placement-editor-rect\"\n onPointerDown={(e) => beginDrag(e, \"move\")}\n onKeyDown={handleKeyDown}\n style={{\n position: \"absolute\",\n left: `${placement.x}%`,\n top: `${placement.y}%`,\n width: `${placement.width}%`,\n height: `${placement.height}%`,\n backgroundColor: COLORS.accentLight,\n border: `2px solid ${COLORS.accent}`,\n borderRadius: `${RADIUS.sm}px`,\n boxSizing: \"border-box\",\n cursor: \"move\",\n pointerEvents: \"auto\",\n touchAction: \"none\",\n transition: \"box-shadow 150ms ease\",\n boxShadow: SHADOWS.sm,\n }}\n >\n {HANDLE_DEFS.map((handle) => (\n <div\n key={handle.id}\n role=\"separator\"\n aria-label={handle.label}\n aria-orientation=\"horizontal\"\n data-testid={`placement-editor-handle-${handle.id}`}\n onPointerDown={(e) => beginDrag(e, handle.id)}\n style={{\n position: \"absolute\",\n width: HANDLE_SIZE,\n height: HANDLE_SIZE,\n backgroundColor: COLORS.surface,\n border: `2px solid ${COLORS.accent}`,\n borderRadius: `${RADIUS.sm}px`,\n boxSizing: \"border-box\",\n cursor: handle.cursor,\n pointerEvents: \"auto\",\n touchAction: \"none\",\n ...handle.style,\n }}\n />\n ))}\n </div>\n </div>\n );\n};\n\nexport interface PlacementInputsProps {\n placement: Placement;\n onPlacementChange: (placement: Placement) => void;\n}\n\nconst PLACEMENT_INPUT_STYLE: React.CSSProperties = {\n width: \"60px\",\n padding: `${SPACE[1]}px`,\n border: `1px solid ${COLORS.borderStrong}`,\n borderRadius: RADIUS.sm,\n fontSize: TYPE.sm,\n color: COLORS.text,\n};\n\n/**\n * PlacementInputs - numerical X/Y/W/H editor for a placement. Lives\n * separately from `PlacementEditor` so the overlay frame does not have\n * to host a control panel that would otherwise occlude the video's\n * native controls. Hosts render this in their own toolbar (the\n * editor's `InterlaceEditor` puts it in a row below the video toolbar;\n * standalone hosts compose it however they like).\n *\n * X/Y edits use the \"move\" policy (position clamped so the rect stays\n * inside the frame). W/H edits use the \"resize\" policy (size clamped,\n * with the 1% minimum).\n */\nexport const PlacementInputs: React.FC<PlacementInputsProps> = ({\n placement,\n onPlacementChange,\n}) => {\n // Latest props, read from the native event handlers (which would\n // otherwise close over stale values).\n const placementRef = useRef(placement);\n placementRef.current = placement;\n const onChangeRef = useRef(onPlacementChange);\n onChangeRef.current = onPlacementChange;\n\n const commit = useCallback(\n (partial: Partial<Placement>, intent: DragIntent) => {\n onChangeRef.current(\n clampPlacement({ ...placementRef.current, ...partial }, intent),\n );\n },\n [],\n );\n\n return (\n <div\n data-testid=\"placement-editor-inputs\"\n style={{\n display: \"flex\",\n gap: SPACE[2],\n padding: `${SPACE[2]}px 0`,\n fontSize: TYPE.xs,\n alignItems: \"center\",\n flexWrap: \"wrap\",\n color: COLORS.textMuted,\n }}\n >\n <label>\n X:{\" \"}\n <input\n type=\"number\"\n data-testid=\"placement-editor-input-x\"\n value={placement.x.toFixed(1)}\n onChange={(e) =>\n commit({ x: parseFloat(e.target.value) || 0 }, \"move\")\n }\n style={PLACEMENT_INPUT_STYLE}\n />\n </label>\n <label>\n Y:{\" \"}\n <input\n type=\"number\"\n data-testid=\"placement-editor-input-y\"\n value={placement.y.toFixed(1)}\n onChange={(e) =>\n commit({ y: parseFloat(e.target.value) || 0 }, \"move\")\n }\n style={PLACEMENT_INPUT_STYLE}\n />\n </label>\n <label>\n W:{\" \"}\n <input\n type=\"number\"\n data-testid=\"placement-editor-input-w\"\n value={placement.width.toFixed(1)}\n onChange={(e) =>\n commit({ width: parseFloat(e.target.value) || 0 }, \"resize\")\n }\n style={PLACEMENT_INPUT_STYLE}\n />\n </label>\n <label>\n H:{\" \"}\n <input\n type=\"number\"\n data-testid=\"placement-editor-input-h\"\n value={placement.height.toFixed(1)}\n onChange={(e) =>\n commit({ height: parseFloat(e.target.value) || 0 }, \"resize\")\n }\n style={PLACEMENT_INPUT_STYLE}\n />\n </label>\n </div>\n );\n};\n","import { DEFAULT_STRINGS, type Strings } from \"@interlacejs/core\";\nimport React, {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { COLORS, RADIUS, SHADOWS, SPACE, TYPE } from \"../tokens\";\n\n/**\n * Localized strings consumed by `KeyframeTimeline`. Extends the core\n * `Strings` so a host passing a single translation table covers every\n * editor surface.\n */\nexport interface KeyframeTimelineStrings extends Strings {\n /** Label for the \"add blocking hook at playhead\" button. */\n addBlockingLabel: string;\n /** Label for the \"add non-blocking hook at playhead\" button. */\n addNonBlockingLabel: string;\n /** Label for the zoom-in button. */\n zoomInLabel: string;\n /** Label for the zoom-out button. */\n zoomOutLabel: string;\n /** Label for the play button. */\n playLabel: string;\n /** Label for the pause button. */\n pauseLabel: string;\n /** Accessible label for the playhead slider. */\n playheadLabel: string;\n /** Shown in the track when there are no hooks. */\n emptyLabel: string;\n /** Accessible label for the ruler strip. */\n rulerLabel: string;\n /** Accessible label for the keyframe track. */\n trackLabel: string;\n /** Accessible label prefix for a blocking keyframe (composed with the title + time). */\n blockingKeyframeLabel: string;\n /** Accessible label prefix for a non-blocking range bar. */\n nonBlockingRangeLabel: string;\n}\n\nexport const DEFAULT_KEYFRAME_TIMELINE_STRINGS: KeyframeTimelineStrings = {\n ...DEFAULT_STRINGS,\n addBlockingLabel: \"+ Blocking at playhead\",\n addNonBlockingLabel: \"+ Non-blocking at playhead\",\n zoomInLabel: \"Zoom in\",\n zoomOutLabel: \"Zoom out\",\n playLabel: \"Play\",\n pauseLabel: \"Pause\",\n playheadLabel: \"Playhead\",\n emptyLabel: \"No hooks yet. Add one at the playhead to get started.\",\n rulerLabel: \"Timeline ruler\",\n trackLabel: \"Hook track\",\n blockingKeyframeLabel: \"blocking at\",\n nonBlockingRangeLabel: \"non-blocking from\",\n};\n\nexport interface KeyframeTimelineEntry {\n id: string;\n title: string;\n hookType: \"blocking\" | \"non-blocking\";\n timestamp?: number;\n start?: number;\n end?: number;\n}\n\nexport interface KeyframeTimelineProps {\n entries: KeyframeTimelineEntry[];\n selectedId?: string;\n /** Total video duration in seconds; the strip's time axis. */\n videoDuration: number;\n /** Current playhead position in seconds. */\n currentTime: number;\n /** Whether the authoring video is currently playing (drives the play/pause button). */\n isPlaying: boolean;\n onSeek: (time: number) => void;\n onTogglePlay: () => void;\n onSelectEntry: (id: string) => void;\n onUpdateEntry: (\n id: string,\n updates: { timestamp?: number; start?: number; end?: number },\n ) => void;\n onDeleteEntry: (id: string) => void;\n onAddEntry: (hookType: \"blocking\" | \"non-blocking\") => void;\n /** Called when the user clicks the track background (not a keyframe, range, or the ruler). */\n onDeselect?: () => void;\n strings?: Partial<KeyframeTimelineStrings>;\n}\n\nconst MIN_ZOOM = 2; // px per second\nconst MAX_ZOOM = 100;\nconst DEFAULT_ZOOM = 8;\nconst MIN_RANGE = 1; // seconds\n\nconst LANE_HEIGHT = 28; // px per lane row\nconst MIN_LANE_HEIGHT = 14; // px minimum per lane when lanes stack\nconst TRACK_PADDING = 6; // 3px top + 3px bottom padding around the lanes\nconst TRACK_HEIGHT_BUDGET = 96; // fixed track height so the chrome stays short\nconst RULER_HEIGHT = 24; // px height of the ruler strip\nconst KEYFRAME_WIDTH_PX = 14; // rendered diamond width\nconst RANGE_MIN_WIDTH_PX = 12; // rendered minimum range width\n\ninterface DragState {\n cleanup: () => void;\n}\n\nfunction clampValue(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(value, max));\n}\n\n/** Snap to integer seconds unless the user holds Shift (bypass). */\nfunction snapTime(time: number, bypass: boolean): number {\n return bypass ? time : Math.round(time);\n}\n\n/** Smallest ruler tick interval (seconds) whose pixel width is readable. */\nfunction tickInterval(zoom: number): number {\n for (const candidate of [1, 2, 5, 10, 15, 30, 60, 120, 300, 600]) {\n if (candidate * zoom >= 56) return candidate;\n }\n return 600;\n}\n\nfunction formatTick(seconds: number): string {\n if (seconds < 60) return `${seconds}s`;\n const m = Math.floor(seconds / 60);\n const s = seconds % 60;\n return s === 0 ? `${m}m` : `${m}m ${s}s`;\n}\n\nfunction anchorOf(entry: KeyframeTimelineEntry): number {\n return entry.hookType === \"blocking\"\n ? (entry.timestamp ?? 0)\n : (entry.start ?? 0);\n}\n\n/**\n * The time extent an entry occupies on the strip: ranges span their\n * start→end; blocking keyframes occupy their rendered diamond width\n * (expressed in seconds at the current zoom), so two keyframes stack\n * exactly when their rendered shapes would overlap.\n */\nfunction extentOf(entry: KeyframeTimelineEntry, zoom: number): number {\n if (entry.hookType === \"blocking\") {\n return KEYFRAME_WIDTH_PX / zoom;\n }\n const span = (entry.end ?? 0) - (entry.start ?? 0);\n return Math.max(RANGE_MIN_WIDTH_PX / zoom, span);\n}\n\n/**\n * KeyframeTimeline - a horizontal, zoomable video-editor timeline.\n *\n * Visual grammar:\n * - Blocking hooks render as point keyframes (diamonds) at their timestamp.\n * - Non-blocking hooks render as range bars spanning start → end; the body\n * drags to move (duration preserved), the edges drag to resize one side.\n * - A playhead line tracks `currentTime`; dragging it (or clicking the\n * ruler) seeks via `onSeek`.\n *\n * Interaction:\n * - Drag survives the pointer leaving the strip (pointer capture +\n * window-level fallbacks — the PlacementEditor pattern).\n * - Drag snapping is to integer seconds; hold Shift to bypass.\n * - Zoom via the +/- buttons or ctrl+wheel (native non-passive listener,\n * since React's synthetic onWheel cannot preventDefault).\n * - Keyboard: the playhead is a slider (arrow keys ±1s, ±5s with Shift);\n * a selected keyframe nudges with the same keys through `onUpdateEntry`.\n *\n * Adding a hook happens at the current playhead (`onAddEntry`), which is\n * the keyframe metaphor: the playhead is the insertion point.\n */\nexport const KeyframeTimeline: React.FC<KeyframeTimelineProps> = ({\n entries,\n selectedId,\n videoDuration,\n currentTime,\n isPlaying,\n onSeek,\n onTogglePlay,\n onSelectEntry,\n onUpdateEntry,\n onAddEntry,\n onDeselect,\n strings: stringsOverride,\n}) => {\n const strings = { ...DEFAULT_KEYFRAME_TIMELINE_STRINGS, ...stringsOverride };\n const [zoom, setZoom] = useState(DEFAULT_ZOOM);\n const dragRef = useRef<DragState | null>(null);\n const scrollRef = useRef<HTMLDivElement | null>(null);\n const stripRef = useRef<HTMLDivElement | null>(null);\n // Once the user manually zooms (slider or wheel), the full-duration\n // auto-fit stops re-asserting itself (even across video reloads).\n const userZoomedRef = useRef(false);\n // Latest props for the native drag listeners.\n const propsRef = useRef({ zoom, videoDuration, currentTime });\n propsRef.current = { zoom, videoDuration, currentTime };\n\n // Default zoom = the full video duration: on mount and whenever the video\n // duration changes (video reload), compute the zoom that fits the entire\n // duration into the visible strip width. A ResizeObserver keeps the fit\n // honest when the host resizes, but a manual zoom wins from then on.\n useLayoutEffect(() => {\n const el = scrollRef.current;\n if (!el) return;\n const measureAndFit = () => {\n const width = el.clientWidth;\n if (width <= 0 || videoDuration <= 0) return;\n if (!userZoomedRef.current) {\n setZoom(clampValue(width / videoDuration, MIN_ZOOM, MAX_ZOOM));\n }\n };\n measureAndFit();\n if (typeof ResizeObserver !== \"undefined\") {\n const observer = new ResizeObserver(() => measureAndFit());\n observer.observe(el);\n return () => observer.disconnect();\n }\n return undefined;\n }, [videoDuration]);\n\n const stripWidth = Math.max(videoDuration * zoom, 320);\n const pxToTime = useCallback(\n (clientX: number, stripRect: { left: number }) =>\n (clientX - stripRect.left) / propsRef.current.zoom,\n [],\n );\n\n const beginDrag = useCallback(\n (\n e: React.PointerEvent<HTMLElement>,\n onMoveDrag: (ev: PointerEvent, stripRect: DOMRect) => void,\n ) => {\n if (typeof e.button === \"number\" && e.button !== 0) return;\n if (dragRef.current) return; // one drag at a time\n const strip = stripRef.current;\n const target = e.currentTarget;\n if (!strip) return;\n const stripRect = strip.getBoundingClientRect();\n if (stripRect.width <= 0) return;\n\n e.preventDefault();\n e.stopPropagation();\n\n const onMove = (ev: PointerEvent) => onMoveDrag(ev, stripRect);\n const cleanup = () => {\n target.removeEventListener(\"pointermove\", onMove);\n target.removeEventListener(\"pointerup\", onUp);\n target.removeEventListener(\"pointercancel\", onUp);\n window.removeEventListener(\"pointerup\", onUp);\n window.removeEventListener(\"pointercancel\", onUp);\n try {\n target.releasePointerCapture?.(e.pointerId);\n } catch {\n // Capture may already be released; the drag is over anyway.\n }\n dragRef.current = null;\n };\n const onUp = () => {\n cleanup();\n };\n\n try {\n target.setPointerCapture?.(e.pointerId);\n } catch {\n // Engines without capture still work via the window fallbacks.\n }\n target.addEventListener(\"pointermove\", onMove);\n target.addEventListener(\"pointerup\", onUp);\n target.addEventListener(\"pointercancel\", onUp);\n window.addEventListener(\"pointerup\", onUp);\n window.addEventListener(\"pointercancel\", onUp);\n dragRef.current = { cleanup };\n },\n [],\n );\n\n // Tear down an in-flight drag on unmount.\n useEffect(() => {\n return () => {\n dragRef.current?.cleanup();\n };\n }, []);\n\n const beginPlayheadDrag = useCallback(\n (e: React.PointerEvent<HTMLElement>) => {\n beginDrag(e, (ev, stripRect) => {\n const t = pxToTime(ev.clientX, stripRect);\n onSeek(\n snapTime(\n clampValue(t, 0, propsRef.current.videoDuration),\n ev.shiftKey,\n ),\n );\n });\n },\n [beginDrag, onSeek, pxToTime],\n );\n\n const beginKeyframeDrag = useCallback(\n (id: string, startTime: number) => (e: React.PointerEvent<HTMLElement>) => {\n const startX = e.clientX;\n beginDrag(e, (ev) => {\n const dt = (ev.clientX - startX) / propsRef.current.zoom;\n const t = snapTime(\n clampValue(startTime + dt, 0, propsRef.current.videoDuration),\n ev.shiftKey,\n );\n onUpdateEntry(id, { timestamp: t });\n });\n },\n [beginDrag, onUpdateEntry],\n );\n\n const beginRangeDrag = useCallback(\n (\n id: string,\n edge: \"body\" | \"start\" | \"end\",\n startStart: number,\n startEnd: number,\n ) =>\n (e: React.PointerEvent<HTMLElement>) => {\n const startX = e.clientX;\n const duration = startEnd - startStart;\n beginDrag(e, (ev) => {\n const dt = (ev.clientX - startX) / propsRef.current.zoom;\n if (edge === \"body\") {\n const nextStart = snapTime(\n clampValue(\n startStart + dt,\n 0,\n propsRef.current.videoDuration - duration,\n ),\n ev.shiftKey,\n );\n onUpdateEntry(id, {\n start: nextStart,\n end: nextStart + duration,\n });\n } else if (edge === \"start\") {\n const nextStart = snapTime(\n clampValue(startStart + dt, 0, startEnd - MIN_RANGE),\n ev.shiftKey,\n );\n onUpdateEntry(id, { start: nextStart });\n } else {\n const nextEnd = snapTime(\n clampValue(\n startEnd + dt,\n startStart + MIN_RANGE,\n propsRef.current.videoDuration,\n ),\n ev.shiftKey,\n );\n onUpdateEntry(id, { end: nextEnd });\n }\n });\n },\n [beginDrag, onUpdateEntry],\n );\n\n // Wheel zoom on the timeline body: wheel up = zoom in, wheel down = zoom\n // out. React's synthetic onWheel is passive at the root since React 17,\n // so preventDefault requires a native non-passive listener. ctrl/meta+wheel\n // is accepted as the same gesture (backwards compatible with the prior\n // ctrl+wheel behavior).\n useEffect(() => {\n const el = scrollRef.current;\n if (!el) return;\n const onWheel = (e: WheelEvent) => {\n e.preventDefault();\n userZoomedRef.current = true;\n setZoom((z) =>\n clampValue(e.deltaY < 0 ? z * 1.2 : z / 1.2, MIN_ZOOM, MAX_ZOOM),\n );\n };\n el.addEventListener(\"wheel\", onWheel, { passive: false });\n return () => el.removeEventListener(\"wheel\", onWheel);\n }, []);\n\n const handleZoom = useCallback((direction: 1 | -1) => {\n userZoomedRef.current = true;\n setZoom((z) =>\n clampValue(direction > 0 ? z * 1.5 : z / 1.5, MIN_ZOOM, MAX_ZOOM),\n );\n }, []);\n\n const handleKeyframeKeyDown = useCallback(\n (entry: KeyframeTimelineEntry) => (e: React.KeyboardEvent<HTMLElement>) => {\n const step = e.shiftKey ? 5 : 1;\n let updates: { timestamp?: number; start?: number; end?: number } | null =\n null;\n // Round the nudge base so keyboard nudges re-align to the\n // seconds grid even after a Shift-bypass drag left a float.\n if (entry.hookType === \"blocking\") {\n const base = Math.round(entry.timestamp ?? 0);\n if (e.key === \"ArrowLeft\")\n updates = {\n timestamp: clampValue(\n base - step,\n 0,\n propsRef.current.videoDuration,\n ),\n };\n if (e.key === \"ArrowRight\")\n updates = {\n timestamp: clampValue(\n base + step,\n 0,\n propsRef.current.videoDuration,\n ),\n };\n } else {\n const s = Math.round(entry.start ?? 0);\n const en = Math.round(entry.end ?? 0);\n const dur = en - s;\n if (e.key === \"ArrowLeft\") {\n const next = clampValue(\n s - step,\n 0,\n propsRef.current.videoDuration - dur,\n );\n updates = { start: next, end: next + dur };\n }\n if (e.key === \"ArrowRight\") {\n const next = clampValue(\n s + step,\n 0,\n propsRef.current.videoDuration - dur,\n );\n updates = { start: next, end: next + dur };\n }\n }\n if (!updates) return;\n e.preventDefault();\n e.stopPropagation();\n onUpdateEntry(entry.id, updates);\n },\n [onUpdateEntry],\n );\n\n const handlePlayheadKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n const step = e.shiftKey ? 5 : 1;\n let t: number | null = null;\n if (e.key === \"ArrowLeft\")\n t = clampValue(\n propsRef.current.currentTime - step,\n 0,\n propsRef.current.videoDuration,\n );\n if (e.key === \"ArrowRight\")\n t = clampValue(\n propsRef.current.currentTime + step,\n 0,\n propsRef.current.videoDuration,\n );\n if (t == null) return;\n e.preventDefault();\n e.stopPropagation();\n onSeek(t);\n },\n [onSeek],\n );\n\n const handleRulerSeek = useCallback(\n (e: React.PointerEvent<HTMLElement>) => {\n if (typeof e.button === \"number\" && e.button !== 0) return;\n const strip = stripRef.current;\n if (!strip) return;\n const stripRect = strip.getBoundingClientRect();\n if (stripRect.width <= 0) return;\n const t = (e.clientX - stripRect.left) / propsRef.current.zoom;\n onSeek(\n snapTime(clampValue(t, 0, propsRef.current.videoDuration), e.shiftKey),\n );\n },\n [onSeek],\n );\n\n /**\n * Greedy interval packing: entries sorted by anchor time, each\n * placed in the first lane whose last occupant ends at or before\n * its start. Overlapping entries stack into successive lanes; the\n * track height grows to fit them. The playhead still spans the\n * full track.\n */\n const layout = useMemo(() => {\n const sorted = [...entries].sort((a, b) => anchorOf(a) - anchorOf(b));\n const laneEnds: number[] = [];\n const lanes = new Map<string, number>();\n for (const entry of sorted) {\n const start = anchorOf(entry);\n const end = start + extentOf(entry, zoom);\n let lane = laneEnds.findIndex((laneEnd) => laneEnd <= start);\n if (lane === -1) {\n lane = laneEnds.length;\n laneEnds.push(end);\n } else {\n laneEnds[lane] = end;\n }\n lanes.set(entry.id, lane);\n }\n return { lanes, laneCount: Math.max(laneEnds.length, 1) };\n }, [entries, zoom]);\n\n const interval = tickInterval(zoom);\n const ticks: number[] = [];\n for (let t = 0; t <= videoDuration; t += interval) {\n ticks.push(Math.round(t * 100) / 100);\n }\n const playheadPx = currentTime * zoom;\n\n // Adaptive lane height: as lanes stack, the rows compress so the track\n // never grows past the fixed height budget (no vertical scrolling; the\n // chrome stays short). Small lane counts keep the base 28px row.\n const laneHeight = clampValue(\n Math.floor(\n (TRACK_HEIGHT_BUDGET - TRACK_PADDING) / Math.max(1, layout.laneCount),\n ),\n MIN_LANE_HEIGHT,\n LANE_HEIGHT,\n );\n const trackHeight = Math.max(\n 48,\n layout.laneCount * laneHeight + TRACK_PADDING,\n );\n\n return (\n <div\n className=\"keyframe-timeline\"\n data-testid=\"keyframe-timeline\"\n style={{\n border: `1px solid ${COLORS.border}`,\n borderRadius: RADIUS.md,\n backgroundColor: COLORS.surfaceRaised,\n padding: SPACE[2],\n display: \"flex\",\n flexDirection: \"column\",\n gap: SPACE[2],\n }}\n >\n {/* Controls row */}\n <div\n data-testid=\"keyframe-timeline-controls\"\n style={{\n display: \"flex\",\n gap: SPACE[2],\n alignItems: \"center\",\n flexWrap: \"wrap\",\n }}\n >\n <button\n type=\"button\"\n onClick={onTogglePlay}\n data-testid=\"keyframe-timeline-play\"\n aria-label={isPlaying ? strings.pauseLabel : strings.playLabel}\n style={{\n padding: `${SPACE[1]}px ${SPACE[3]}px`,\n backgroundColor: COLORS.accent,\n color: COLORS.white,\n border: \"none\",\n borderRadius: RADIUS.sm,\n cursor: \"pointer\",\n fontSize: TYPE.sm,\n fontWeight: 600,\n transition: \"background-color 150ms ease\",\n }}\n >\n {isPlaying ? strings.pauseLabel : strings.playLabel}\n </button>\n <button\n type=\"button\"\n onClick={() => onAddEntry(\"blocking\")}\n data-testid=\"keyframe-timeline-add-blocking\"\n style={{\n padding: `${SPACE[1]}px ${SPACE[3]}px`,\n backgroundColor: COLORS.accent,\n color: COLORS.white,\n border: \"none\",\n borderRadius: RADIUS.sm,\n cursor: \"pointer\",\n fontSize: TYPE.sm,\n fontWeight: 600,\n transition: \"background-color 150ms ease\",\n }}\n >\n {strings.addBlockingLabel}\n </button>\n <button\n type=\"button\"\n onClick={() => onAddEntry(\"non-blocking\")}\n data-testid=\"keyframe-timeline-add-non-blocking\"\n style={{\n padding: `${SPACE[1]}px ${SPACE[3]}px`,\n backgroundColor: COLORS.accent,\n color: COLORS.white,\n border: \"none\",\n borderRadius: RADIUS.sm,\n cursor: \"pointer\",\n fontSize: TYPE.sm,\n fontWeight: 600,\n transition: \"background-color 150ms ease\",\n }}\n >\n {strings.addNonBlockingLabel}\n </button>\n <div style={{ flex: 1 }} />\n <button\n type=\"button\"\n onClick={() => handleZoom(-1)}\n data-testid=\"keyframe-timeline-zoom-out\"\n aria-label={strings.zoomOutLabel}\n style={{\n padding: `${SPACE[1]}px 10px`,\n backgroundColor: COLORS.surface,\n border: `1px solid ${COLORS.borderStrong}`,\n borderRadius: RADIUS.sm,\n cursor: \"pointer\",\n fontSize: TYPE.sm,\n color: COLORS.text,\n transition: \"background-color 150ms ease\",\n }}\n >\n −\n </button>\n <button\n type=\"button\"\n onClick={() => handleZoom(1)}\n data-testid=\"keyframe-timeline-zoom-in\"\n aria-label={strings.zoomInLabel}\n style={{\n padding: `${SPACE[1]}px 10px`,\n backgroundColor: COLORS.surface,\n border: `1px solid ${COLORS.borderStrong}`,\n borderRadius: RADIUS.sm,\n cursor: \"pointer\",\n fontSize: TYPE.sm,\n color: COLORS.text,\n transition: \"background-color 150ms ease\",\n }}\n >\n +\n </button>\n </div>\n\n {/* Scrollable strip: ruler + track + playhead. Horizontal overflow\n is allowed for zoomed-in scoping; vertical overflow is\n eliminated (the lanes compress instead of scrolling). */}\n <div\n ref={scrollRef}\n data-testid=\"keyframe-timeline-scroll\"\n style={{\n overflowX: \"auto\",\n overflowY: \"hidden\",\n position: \"relative\",\n maxHeight: RULER_HEIGHT + TRACK_HEIGHT_BUDGET,\n }}\n >\n <div\n ref={stripRef}\n data-testid=\"keyframe-timeline-strip\"\n style={{ position: \"relative\", width: stripWidth, minWidth: \"100%\" }}\n >\n {/* Ruler */}\n <div\n role=\"slider\"\n aria-label={strings.rulerLabel}\n aria-valuemin={0}\n aria-valuemax={Math.round(videoDuration)}\n aria-valuenow={Math.round(currentTime)}\n tabIndex={0}\n data-testid=\"keyframe-timeline-ruler\"\n onPointerDown={(e) => {\n handleRulerSeek(e);\n beginPlayheadDrag(e);\n }}\n onKeyDown={handlePlayheadKeyDown}\n style={{\n position: \"relative\",\n height: 24,\n backgroundColor: COLORS.surfaceRaised,\n borderBottom: `1px solid ${COLORS.border}`,\n cursor: \"pointer\",\n userSelect: \"none\",\n touchAction: \"none\",\n }}\n >\n {ticks.map((t) => (\n <div\n key={t}\n data-testid={`keyframe-timeline-tick-${t}`}\n style={{\n position: \"absolute\",\n left: t * zoom,\n top: 0,\n bottom: 0,\n borderLeft: `1px solid ${COLORS.borderStrong}`,\n paddingLeft: SPACE[1],\n fontSize: TYPE.xs,\n color: COLORS.textMuted,\n lineHeight: \"24px\",\n whiteSpace: \"nowrap\",\n }}\n >\n {formatTick(t)}\n </div>\n ))}\n </div>\n\n {/* Track */}\n <div\n role=\"listbox\"\n aria-label={strings.trackLabel}\n data-testid=\"keyframe-timeline-track\"\n onPointerDown={(e) => {\n // Clicking the empty track background (not a keyframe,\n // range, or the ruler) deselects the selected hook.\n if (e.target !== e.currentTarget) return;\n onDeselect?.();\n }}\n style={{\n position: \"relative\",\n height: trackHeight,\n }}\n >\n {entries.length === 0 ? (\n <p\n data-testid=\"keyframe-timeline-empty\"\n style={{\n margin: 0,\n padding: \"14px 12px\",\n color: COLORS.textMuted,\n fontSize: TYPE.sm,\n }}\n >\n {strings.emptyLabel}\n </p>\n ) : (\n entries.map((entry) => {\n const selected = entry.id === selectedId;\n const accent = COLORS.accent;\n // Lane assignment from the greedy interval packing:\n // overlapping entries stack into successive rows.\n const lane = layout.lanes.get(entry.id) ?? 0;\n const laneTop = 3 + lane * laneHeight;\n if (entry.hookType === \"blocking\") {\n const px = (entry.timestamp ?? 0) * zoom;\n return (\n <button\n key={entry.id}\n type=\"button\"\n data-testid=\"timeline-keyframe\"\n data-content-id={entry.id}\n aria-label={`${entry.title} — ${strings.blockingKeyframeLabel} ${formatTick(Math.round(entry.timestamp ?? 0))}`}\n onClick={() => onSelectEntry(entry.id)}\n onKeyDown={handleKeyframeKeyDown(entry)}\n style={{\n position: \"absolute\",\n left: px - 7,\n top: laneTop + 5,\n width: 14,\n height: 14,\n transform: \"rotate(45deg)\",\n backgroundColor: selected ? accent : COLORS.surface,\n border: `2px solid ${accent}`,\n borderRadius: 2,\n cursor: \"grab\",\n padding: 0,\n touchAction: \"none\",\n boxShadow: selected ? SHADOWS.sm : \"none\",\n }}\n onPointerDown={beginKeyframeDrag(\n entry.id,\n entry.timestamp ?? 0,\n )}\n >\n <span\n style={{\n position: \"absolute\",\n left: 16,\n top: -2,\n transform: \"rotate(-45deg)\",\n fontSize: TYPE.xs,\n color: selected ? COLORS.accent : COLORS.text,\n whiteSpace: \"nowrap\",\n fontWeight: selected ? 700 : 400,\n }}\n >\n {entry.title}\n </span>\n </button>\n );\n }\n const startPx = (entry.start ?? 0) * zoom;\n const widthPx = Math.max(\n ((entry.end ?? 0) - (entry.start ?? 0)) * zoom,\n 12,\n );\n return (\n <div\n key={entry.id}\n data-testid=\"timeline-range\"\n data-content-id={entry.id}\n style={{\n position: \"absolute\",\n left: startPx,\n width: widthPx,\n top: laneTop,\n height: laneHeight - 4,\n backgroundColor: selected\n ? COLORS.accentLight\n : COLORS.accentLighter,\n border: `2px solid ${COLORS.accent}`,\n borderRadius: RADIUS.sm,\n boxSizing: \"border-box\",\n display: \"flex\",\n alignItems: \"center\",\n overflow: \"hidden\",\n touchAction: \"none\",\n }}\n >\n {/* start edge */}\n <div\n role=\"separator\"\n aria-label={`${entry.title} — resize start`}\n data-testid=\"timeline-range-start\"\n onPointerDown={beginRangeDrag(\n entry.id,\n \"start\",\n entry.start ?? 0,\n entry.end ?? 0,\n )}\n style={{\n width: 8,\n alignSelf: \"stretch\",\n cursor: \"ew-resize\",\n backgroundColor: COLORS.accent,\n touchAction: \"none\",\n }}\n />\n <button\n type=\"button\"\n data-testid=\"timeline-keyframe\"\n data-content-id={entry.id}\n aria-label={`${entry.title} — ${strings.nonBlockingRangeLabel} ${formatTick(Math.round(entry.start ?? 0))} to ${formatTick(Math.round(entry.end ?? 0))}`}\n onClick={() => onSelectEntry(entry.id)}\n onKeyDown={handleKeyframeKeyDown(entry)}\n onPointerDown={beginRangeDrag(\n entry.id,\n \"body\",\n entry.start ?? 0,\n entry.end ?? 0,\n )}\n style={{\n flex: 1,\n alignSelf: \"stretch\",\n backgroundColor: \"transparent\",\n border: \"none\",\n cursor: \"grab\",\n fontSize: TYPE.xs,\n color: COLORS.text,\n padding: `0 ${SPACE[1]}px`,\n textAlign: \"left\",\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n fontWeight: selected ? 700 : 400,\n touchAction: \"none\",\n }}\n >\n {entry.title}\n </button>\n {/* end edge */}\n <div\n role=\"separator\"\n aria-label={`${entry.title} — resize end`}\n data-testid=\"timeline-range-end\"\n onPointerDown={beginRangeDrag(\n entry.id,\n \"end\",\n entry.start ?? 0,\n entry.end ?? 0,\n )}\n style={{\n width: 8,\n alignSelf: \"stretch\",\n cursor: \"ew-resize\",\n backgroundColor: COLORS.accent,\n touchAction: \"none\",\n }}\n />\n </div>\n );\n })\n )}\n </div>\n\n {/* Playhead */}\n <div\n data-testid=\"keyframe-timeline-playhead\"\n style={{\n position: \"absolute\",\n left: playheadPx,\n top: 0,\n bottom: 0,\n width: 0,\n borderLeft: `2px solid ${COLORS.accent}`,\n pointerEvents: \"none\",\n }}\n >\n <div\n role=\"slider\"\n aria-label={strings.playheadLabel}\n aria-valuemin={0}\n aria-valuemax={Math.round(videoDuration)}\n aria-valuenow={Math.round(currentTime)}\n aria-valuetext={`${currentTime.toFixed(1)}s`}\n tabIndex={0}\n data-testid=\"keyframe-timeline-playhead-handle\"\n onPointerDown={beginPlayheadDrag}\n onKeyDown={handlePlayheadKeyDown}\n style={{\n position: \"absolute\",\n left: -7,\n top: 0,\n width: 12,\n height: 14,\n backgroundColor: COLORS.accent,\n borderRadius: \"2px 2px 4px 4px\",\n cursor: \"ew-resize\",\n pointerEvents: \"auto\",\n touchAction: \"none\",\n }}\n />\n </div>\n </div>\n </div>\n </div>\n );\n};\n","import {\n ContentTypeRegistry,\n DEFAULT_STRINGS,\n type SerializedInteractiveMediaDocument,\n type Strings,\n type VideoAdapter,\n} from \"@interlacejs/core\";\nimport { InteractiveVideoPlayer } from \"@interlacejs/player\";\nimport { NativeVideoAdapter } from \"@interlacejs/native-adapter\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { COLORS, FONTS, RADIUS, SPACE, TYPE } from \"../tokens\";\n\n/**\n * Localized strings consumed by `PreviewModal`. Extends the core\n * `Strings` so a host passing a single translation table covers every\n * editor surface. The fields below are the ones specific to the\n * preview modal; everything else (cancel, close, content error, …)\n * is inherited from `Strings`.\n */\nexport interface PreviewModalStrings extends Strings {\n /** Heading shown at the top of the modal. */\n title: string;\n /** Shown while the player is initializing. */\n loadingLabel: string;\n}\n\n/**\n * Defaults are derived from core's `DEFAULT_STRINGS` so a host that\n * overrides the core base gets matching inheritance automatically.\n */\nexport const DEFAULT_PREVIEW_MODAL_STRINGS: PreviewModalStrings = {\n ...DEFAULT_STRINGS,\n title: \"Preview\",\n loadingLabel: \"Loading player…\",\n};\n\nexport interface PreviewModalProps {\n /** Whether the modal is open. The internal `<video>` only mounts when open, so audio stops on close. */\n isOpen: boolean;\n videoSrc: string;\n document: SerializedInteractiveMediaDocument;\n contentTypeRegistry: ContentTypeRegistry;\n onClose: () => void;\n strings?: Partial<PreviewModalStrings>;\n onError?: (error: Error) => void;\n}\n\n/**\n * PreviewModal - the \"what students will see\" surface for the editor.\n *\n * The modal mounts a fresh `<video>` element on open and wraps it in a\n * `NativeVideoAdapter`. The adapter is passed to the player's\n * `InteractiveVideoPlayer` for play / pause / seek control. The player's\n * overlay layer is positioned on top of the video via CSS — the\n * adapter's `mountOverlay` is not used (the player renders its own\n * overlay as a sibling of the video).\n *\n * The `<video>` and the adapter are created in a `useEffect` on `isOpen`,\n * and the adapter's `destroy()` is called on close. This guarantees the\n * modal's audio stops when the user closes it.\n *\n * `onError` and `onClose` are held in refs so a host-inlined callback\n * does not destroy and recreate the adapter (and thus the player's\n * controller) on every parent re-render while the modal is open.\n */\nexport function PreviewModal({\n isOpen,\n videoSrc,\n document,\n contentTypeRegistry,\n onClose,\n strings: stringsOverride,\n onError,\n}: PreviewModalProps) {\n const strings = { ...DEFAULT_PREVIEW_MODAL_STRINGS, ...stringsOverride };\n const videoRef = useRef<HTMLVideoElement | null>(null);\n const closeButtonRef = useRef<HTMLButtonElement | null>(null);\n const previouslyFocusedRef = useRef<HTMLElement | null>(null);\n // Hold callbacks in refs so a host-inlined callback does not\n // destroy and recreate the adapter (and thus the player's\n // controller) on every parent re-render.\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n const onCloseRef = useRef(onClose);\n onCloseRef.current = onClose;\n const [adapter, setAdapter] = useState<VideoAdapter | null>(null);\n /**\n * Aspect ratio of the modal's video frame, derived from the\n * underlying video's intrinsic dimensions. `null` until metadata\n * loads; the container falls back to 16:9 in that case. Using the\n * intrinsic ratio prevents distortion of non-16:9 sources (4:3,\n * portrait, etc.) and keeps the player's anchor alignment honest\n * (the % placement system maps to the container box, which is\n * only the video frame when the container hugs the video's\n * aspect).\n */\n const [aspectRatio, setAspectRatio] = useState<number | null>(null);\n\n // Construct the adapter after the <video> mounts; destroy on close.\n useEffect(() => {\n if (!isOpen) {\n setAdapter(null);\n return;\n }\n const video = videoRef.current;\n if (!video) {\n // Unreachable: the <video> renders iff isOpen, and React commits\n // refs before running passive effects. The check satisfies\n // TypeScript's non-null requirement on the ref.\n return;\n }\n let native: NativeVideoAdapter | null = null;\n try {\n native = new NativeVideoAdapter(video);\n setAdapter(native);\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n onErrorRef.current?.(error);\n setAdapter(null);\n return;\n }\n return () => {\n try {\n native?.destroy();\n } catch {\n // destroy() can throw if the wrapper was already detached;\n // ignore — the DOM is going away anyway.\n }\n setAdapter(null);\n };\n }, [isOpen, videoSrc]);\n\n // Focus management: move focus to the close button on open, restore\n // the previously-focused element on close. The player's own\n // BlockingOverlay traps focus once it appears; this just sets the\n // initial focus when the modal opens.\n useEffect(() => {\n if (!isOpen) return;\n previouslyFocusedRef.current =\n (globalThis.document?.activeElement as HTMLElement | null) ?? null;\n closeButtonRef.current?.focus();\n return () => {\n const prev = previouslyFocusedRef.current;\n if (prev && typeof prev.focus === \"function\") {\n prev.focus();\n }\n };\n }, [isOpen]);\n\n // Close on Escape, like a native modal.\n useEffect(() => {\n if (!isOpen) return;\n const handleKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") onCloseRef.current();\n };\n window.addEventListener(\"keydown\", handleKey);\n return () => window.removeEventListener(\"keydown\", handleKey);\n }, [isOpen]);\n\n const handleBackdropClick = useCallback(\n (e: React.MouseEvent<HTMLDivElement>) => {\n // Only close when the user clicks the backdrop, not the modal\n // content.\n if (e.target === e.currentTarget) onCloseRef.current();\n },\n [],\n );\n\n const handleLoadedMetadata = useCallback(\n (e: React.SyntheticEvent<HTMLVideoElement>) => {\n const v = e.currentTarget;\n if (v.videoWidth > 0 && v.videoHeight > 0) {\n setAspectRatio(v.videoWidth / v.videoHeight);\n }\n },\n [],\n );\n\n if (!isOpen) return null;\n\n const containerAspectRatio = aspectRatio ?? 16 / 9;\n\n return (\n <div\n className=\"preview-modal-backdrop\"\n data-testid=\"preview-modal-backdrop\"\n role=\"presentation\"\n onClick={handleBackdropClick}\n style={{\n position: \"fixed\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n backgroundColor: \"rgba(0, 0, 0, 0.7)\",\n zIndex: 1000,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n className=\"preview-modal\"\n data-testid=\"preview-modal\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={strings.title}\n onClick={handleBackdropClick}\n style={{\n position: \"relative\",\n backgroundColor: COLORS.black,\n borderRadius: RADIUS.lg,\n padding: SPACE[4],\n maxWidth: \"90vw\",\n maxHeight: \"90vh\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: SPACE[2],\n boxShadow: \"0 16px 48px rgba(0, 0, 0, 0.35)\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n color: COLORS.white,\n }}\n >\n <h3\n style={{\n margin: 0,\n fontFamily: FONTS.display,\n fontSize: TYPE.md,\n fontWeight: 600,\n }}\n >\n {strings.title}\n </h3>\n <button\n ref={closeButtonRef}\n type=\"button\"\n onClick={onClose}\n data-testid=\"preview-modal-close\"\n aria-label={strings.closeLabel}\n style={{\n padding: `${SPACE[1]}px ${SPACE[3]}px`,\n backgroundColor: \"transparent\",\n border: `1px solid ${COLORS.borderStrong}`,\n color: COLORS.white,\n borderRadius: RADIUS.sm,\n cursor: \"pointer\",\n fontSize: TYPE.sm,\n transition: \"background-color 150ms ease, border-color 150ms ease\",\n }}\n >\n {strings.closeLabel}\n </button>\n </div>\n <div\n className=\"preview-modal-content\"\n data-testid=\"preview-modal-content\"\n style={{\n position: \"relative\",\n width: \"min(80vw, 960px)\",\n aspectRatio: String(containerAspectRatio),\n backgroundColor: \"#000\",\n }}\n >\n <div\n className=\"preview-modal-video-container\"\n data-testid=\"preview-modal-video-container\"\n style={{ width: \"100%\", height: \"100%\" }}\n >\n <video\n ref={videoRef}\n src={videoSrc}\n controls\n preload=\"metadata\"\n onLoadedMetadata={handleLoadedMetadata}\n data-testid=\"preview-modal-video\"\n style={{\n width: \"100%\",\n height: \"100%\",\n display: \"block\",\n }}\n />\n </div>\n {adapter ? (\n <div\n className=\"preview-modal-player-container\"\n data-testid=\"preview-modal-player-container\"\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n height: \"100%\",\n pointerEvents: \"none\",\n }}\n >\n <InteractiveVideoPlayer\n adapter={adapter}\n document={document}\n registry={contentTypeRegistry}\n onError={onErrorRef.current}\n />\n </div>\n ) : (\n <div\n data-testid=\"preview-modal-loading\"\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n color: COLORS.textMuted,\n fontSize: TYPE.sm,\n }}\n >\n {strings.loadingLabel}\n </div>\n )}\n </div>\n </div>\n </div>\n );\n}\n","import { DEFAULT_STRINGS, type Strings } from \"@interlacejs/core\";\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { COLORS, RADIUS, SPACE, TYPE } from \"../tokens\";\n\n/**\n * The current video source value held by `VideoSourceInput`. `duration` is\n * optional because the editor usually learns it from the host's `<video>`\n * element after the URL resolves; the component only writes `src` directly.\n */\nexport interface VideoSourceValue {\n src?: string;\n duration?: number;\n}\n\n/**\n * Localized strings consumed by `VideoSourceInput`. Extends the core\n * `Strings` so a host passing a single translation table covers every\n * editor surface. The fields below are the ones specific to the\n * video-source step; everything else (cancel, close, content error, …)\n * is inherited from `Strings`.\n */\nexport interface VideoSourceInputStrings extends Strings {\n /** Heading for the file upload row. */\n uploadLabel: string;\n /** Label for the trigger button that opens the native file picker. */\n uploadButtonLabel: string;\n /** Shown next to the button while a file is being uploaded. */\n uploadingLabel: string;\n /** Inline error text shown when the upload promise rejects. */\n uploadFailedLabel: string;\n /** Label for the button that re-opens the file picker after a failure. */\n retryLabel: string;\n /** Label for the \"direct URL\" text input. */\n urlLabel: string;\n /** Placeholder for the URL text input. */\n urlPlaceholder: string;\n /** Label for the button that commits the URL draft. */\n applyUrlLabel: string;\n /** Shown when no video source has been chosen yet. */\n noVideoSelectedLabel: string;\n /** Shown above a known video URL. */\n currentSourceLabel: string;\n}\n\n/**\n * Defaults are derived from core's `DEFAULT_STRINGS` so a host that\n * overrides the core base gets matching inheritance automatically; the\n * video-source-specific fields are filled in alongside.\n */\nexport const DEFAULT_VIDEO_SOURCE_INPUT_STRINGS: VideoSourceInputStrings = {\n ...DEFAULT_STRINGS,\n uploadLabel: \"Upload a video file\",\n uploadButtonLabel: \"Choose file\",\n uploadingLabel: \"Uploading…\",\n uploadFailedLabel: \"Upload failed.\",\n retryLabel: \"Retry\",\n urlLabel: \"…or paste a video URL\",\n urlPlaceholder: \"https://example.com/video.mp4\",\n applyUrlLabel: \"Use URL\",\n noVideoSelectedLabel: \"No video selected yet.\",\n currentSourceLabel: \"Current source\",\n};\n\nexport interface VideoSourceInputProps {\n /**\n * The current video source, if any. When `value.src` is set, the\n * component displays the existing source above the inputs and treats the\n * URL draft as a *replacement* candidate. When it is absent, the\n * component behaves as the very first step of a new document.\n */\n value?: VideoSourceValue;\n /**\n * Called when a usable video URL is ready, whether the user pasted it\n * directly or an upload promise resolved. The component awaits the\n * upload promise itself; the host is only ever handed a URL.\n */\n onChange: (next: { src: string; duration?: number }) => void;\n /**\n * Host-supplied upload callback. The component awaits this promise; the\n * resolved string is written into the document. A rejection is surfaced\n * via the inline error state and (optionally) `onError` — it does not\n * crash the authoring flow.\n */\n onUpload: (file: File) => Promise<string>;\n /** Optional callback for upload promise rejections. */\n onError?: (error: Error) => void;\n /** Optional string overrides. */\n strings?: Partial<VideoSourceInputStrings>;\n /** Disables both the URL and file controls. */\n disabled?: boolean;\n}\n\ntype UploadState =\n | { kind: \"idle\" }\n | { kind: \"uploading\"; fileName: string }\n | { kind: \"error\"; message: string };\n\n/**\n * VideoSourceInput - the first step of a new document's authoring flow.\n * Accepts either a direct URL or a file. When a file is provided, the\n * host's `onUpload` callback is invoked and the component awaits the\n * resolved URL before calling `onChange`. Loading and failure states are\n * surfaced inline without crashing the surrounding authoring flow.\n *\n * Token discipline: every file selection bumps an internal counter; if a\n * later selection starts (or the component unmounts) before the previous\n * upload resolves, the stale result is dropped. This prevents a slow\n * upload from overwriting the URL of a fast one chosen after it, and\n * prevents a late resolution from committing into a torn-down tree.\n */\nexport function VideoSourceInput({\n value,\n onChange,\n onUpload,\n onError,\n strings: stringsOverride,\n disabled = false,\n}: VideoSourceInputProps) {\n const strings = { ...DEFAULT_VIDEO_SOURCE_INPUT_STRINGS, ...stringsOverride };\n const [urlDraft, setUrlDraft] = useState(value?.src ?? \"\");\n const [uploadState, setUploadState] = useState<UploadState>({ kind: \"idle\" });\n const fileInputRef = useRef<HTMLInputElement>(null);\n const uploadTokenRef = useRef(0);\n\n // Keep the URL draft in sync when the upstream value changes (e.g. a\n // document load). The draft is *not* marked dirty — a late upload\n // resolution that calls `onChange` will still overwrite what the user\n // is currently typing. Callers that want to preserve the user's\n // in-flight draft across value changes should not pass a new\n // `value.src` while a upload is in progress.\n useEffect(() => {\n setUrlDraft(value?.src ?? \"\");\n }, [value?.src]);\n\n // Token discipline also covers unmount: bump the counter so any\n // in-flight upload that resolves after the component is gone is\n // dropped instead of committing into a torn-down tree.\n useEffect(() => {\n return () => {\n uploadTokenRef.current += 1;\n };\n }, []);\n\n const handleApplyUrl = useCallback(() => {\n const trimmed = urlDraft.trim();\n if (!trimmed) return;\n onChange({ src: trimmed });\n }, [urlDraft, onChange]);\n\n const handleFileSelected = useCallback(\n async (event: React.ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n // Always reset the input so re-selecting the same file re-fires onChange.\n event.target.value = \"\";\n if (!file) return;\n\n const token = ++uploadTokenRef.current;\n setUploadState({ kind: \"uploading\", fileName: file.name });\n let url: string;\n try {\n url = await onUpload(file);\n } catch (err) {\n if (token !== uploadTokenRef.current) return;\n const error = err instanceof Error ? err : new Error(String(err));\n setUploadState({ kind: \"error\", message: error.message });\n onError?.(error);\n return;\n }\n // Resolution is the only path that calls onChange. A throw from\n // the host's onChange handler is the host's problem and is not\n // surfaced as an upload failure.\n if (token !== uploadTokenRef.current) return;\n setUploadState({ kind: \"idle\" });\n onChange({ src: url });\n },\n [onUpload, onChange, onError],\n );\n\n const handleRetryUpload = useCallback(() => {\n setUploadState({ kind: \"idle\" });\n fileInputRef.current?.click();\n }, []);\n\n const isUploading = uploadState.kind === \"uploading\";\n const hasError = uploadState.kind === \"error\";\n const isDisabled = disabled || isUploading;\n const applyDisabled = isDisabled || urlDraft.trim().length === 0;\n\n return (\n <div\n className=\"video-source-input\"\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: `${SPACE[4]}px`,\n padding: `${SPACE[4]}px`,\n border: `1px solid ${COLORS.border}`,\n borderRadius: `${RADIUS.md}px`,\n backgroundColor: COLORS.surfaceRaised,\n }}\n >\n {value?.src ? (\n <div\n style={{\n padding: `${SPACE[3]}px ${SPACE[4]}px`,\n backgroundColor: COLORS.surface,\n border: `1px solid ${COLORS.border}`,\n borderRadius: `${RADIUS.sm}px`,\n fontSize: TYPE.sm,\n color: COLORS.text,\n }}\n >\n <span style={{ color: COLORS.textMuted }}>\n {strings.currentSourceLabel}:\n </span>{\" \"}\n <code data-testid=\"video-source-input-current-src\">{value.src}</code>\n </div>\n ) : (\n <p\n data-testid=\"video-source-input-empty\"\n style={{ margin: 0, color: COLORS.textMuted }}\n >\n {strings.noVideoSelectedLabel}\n </p>\n )}\n\n <div>\n <h4\n style={{\n margin: `0 0 ${SPACE[2]}px 0`,\n fontSize: TYPE.md,\n fontWeight: 600,\n color: COLORS.text,\n }}\n >\n {strings.uploadLabel}\n </h4>\n <input\n ref={fileInputRef}\n type=\"file\"\n accept=\"video/*\"\n onChange={handleFileSelected}\n disabled={isDisabled}\n data-testid=\"video-source-input-file\"\n style={{ display: \"none\" }}\n />\n <button\n type=\"button\"\n onClick={() => fileInputRef.current?.click()}\n disabled={isDisabled}\n data-testid=\"video-source-input-file-button\"\n style={{\n padding: `${SPACE[2]}px ${SPACE[4]}px`,\n backgroundColor: isDisabled ? COLORS.borderStrong : COLORS.accent,\n color: COLORS.white,\n border: \"none\",\n borderRadius: `${RADIUS.sm}px`,\n cursor: isDisabled ? \"not-allowed\" : \"pointer\",\n fontSize: TYPE.md,\n fontWeight: 600,\n transition: \"background-color 150ms ease\",\n }}\n >\n {isUploading\n ? `${strings.uploadingLabel} (${uploadState.fileName})`\n : strings.uploadButtonLabel}\n </button>\n {isUploading ? (\n <span\n data-testid=\"video-source-input-uploading\"\n style={{ marginLeft: `${SPACE[2]}px`, color: COLORS.textMuted, fontSize: TYPE.sm }}\n aria-live=\"polite\"\n >\n {strings.uploadingLabel}\n </span>\n ) : null}\n {hasError ? (\n <div\n data-testid=\"video-source-input-error\"\n role=\"alert\"\n style={{\n marginTop: `${SPACE[2]}px`,\n color: COLORS.errorText,\n backgroundColor: COLORS.errorBg,\n padding: `${SPACE[2]}px`,\n borderRadius: `${RADIUS.sm}px`,\n border: `1px solid ${COLORS.errorBorder}`,\n fontSize: TYPE.sm,\n }}\n >\n <strong>{strings.uploadFailedLabel}</strong>{\" \"}\n <span>{uploadState.message}</span>\n <button\n type=\"button\"\n onClick={handleRetryUpload}\n data-testid=\"video-source-input-retry\"\n style={{\n marginLeft: `${SPACE[2]}px`,\n padding: `${SPACE[1]}px ${SPACE[2]}px`,\n backgroundColor: COLORS.surface,\n border: `1px solid ${COLORS.errorBorder}`,\n color: COLORS.errorText,\n borderRadius: `${RADIUS.sm}px`,\n cursor: \"pointer\",\n fontSize: TYPE.xs,\n fontWeight: 600,\n }}\n >\n {strings.retryLabel}\n </button>\n </div>\n ) : null}\n </div>\n\n <div>\n <label\n style={{\n display: \"block\",\n fontSize: TYPE.md,\n fontWeight: 600,\n marginBottom: `${SPACE[1]}px`,\n color: COLORS.text,\n }}\n >\n {strings.urlLabel}\n </label>\n <div style={{ display: \"flex\", gap: \"8px\" }}>\n <input\n type=\"url\"\n value={urlDraft}\n onChange={(e) => setUrlDraft(e.target.value)}\n placeholder={strings.urlPlaceholder}\n disabled={isDisabled}\n data-testid=\"video-source-input-url\"\n style={{\n flex: 1,\n padding: `${SPACE[2]}px ${SPACE[3]}px`,\n border: `1px solid ${COLORS.borderStrong}`,\n borderRadius: `${RADIUS.sm}px`,\n fontSize: TYPE.md,\n color: COLORS.text,\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && !applyDisabled) {\n e.preventDefault();\n handleApplyUrl();\n }\n }}\n />\n <button\n type=\"button\"\n onClick={handleApplyUrl}\n disabled={applyDisabled}\n data-testid=\"video-source-input-apply\"\n style={{\n padding: `${SPACE[2]}px ${SPACE[4]}px`,\n backgroundColor: applyDisabled ? COLORS.borderStrong : COLORS.accent,\n color: COLORS.white,\n border: \"none\",\n borderRadius: `${RADIUS.sm}px`,\n cursor: applyDisabled ? \"not-allowed\" : \"pointer\",\n fontSize: TYPE.md,\n fontWeight: 600,\n transition: \"background-color 150ms ease\",\n }}\n >\n {strings.applyUrlLabel}\n </button>\n </div>\n </div>\n </div>\n );\n}\n","import React, { useRef } from \"react\";\nimport { ContentTypeRegistry } from \"@interlacejs/core\";\nimport { COLORS, FONTS, RADIUS, SHADOWS, SPACE, TYPE } from \"../tokens\";\nimport { useContentTypeEditorMount } from \"./content-type-editor-mount\";\n\nexport interface ContentTypeEditorSlotProps<TData = unknown> {\n contentTypeId: string | null;\n isOpen: boolean;\n onClose: () => void;\n onSave?: (data: TData) => void;\n registry: ContentTypeRegistry;\n data: TData;\n onChange: (newData: TData) => void;\n}\n\n/**\n * ContentTypeEditorSlot - modal that mounts the content type's own\n * editing interface via `renderEditor` / `updateEditor` / `unmount`.\n *\n * @deprecated The editor's own composition no longer opens this modal —\n * the content editor renders inline under the timeline\n * (`ContentTypeEditor`). Retained for hosts composing their own modal\n * UX. Will be reconsidered at the next major.\n */\nexport function ContentTypeEditorSlot<TData = unknown>({\n contentTypeId,\n isOpen,\n onClose,\n onSave,\n registry,\n data,\n onChange,\n}: ContentTypeEditorSlotProps<TData>) {\n const containerRef = useRef<HTMLDivElement>(null);\n\n useContentTypeEditorMount<TData>({\n containerRef,\n active: isOpen,\n contentTypeId,\n registry,\n data,\n onChange,\n });\n\n const contentType = contentTypeId ? registry.get(contentTypeId) : undefined;\n\n if (!isOpen || !contentTypeId) {\n return null;\n }\n\n return (\n <div\n className=\"content-type-editor-slot\"\n style={{\n position: \"fixed\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n backgroundColor: \"rgba(15, 23, 42, 0.5)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n zIndex: 999,\n }}\n >\n <div\n className=\"content-type-editor-container\"\n style={{\n backgroundColor: COLORS.surface,\n borderRadius: `${RADIUS.lg}px`,\n padding: `${SPACE[5]}px`,\n maxWidth: \"600px\",\n width: \"90%\",\n maxHeight: \"80vh\",\n overflowY: \"auto\",\n boxShadow: SHADOWS.md,\n }}\n >\n <h2\n className=\"content-type-editor-title\"\n style={{\n marginTop: 0,\n fontFamily: FONTS.display,\n fontSize: TYPE.lg,\n fontWeight: 600,\n }}\n >\n Edit {contentTypeId}\n </h2>\n\n <div\n className=\"content-type-editor-body\"\n style={{ margin: \"16px 0\", minHeight: \"100px\" }}\n >\n {contentType ? (\n <div ref={containerRef} />\n ) : (\n <p style={{ color: COLORS.textMuted }}>\n Content type "{contentTypeId}" is not registered\n </p>\n )}\n </div>\n\n <div\n className=\"content-type-editor-footer\"\n style={{\n display: \"flex\",\n gap: `${SPACE[2]}px`,\n justifyContent: \"flex-end\",\n marginTop: `${SPACE[5]}px`,\n }}\n >\n <button\n className=\"content-type-editor-cancel-button\"\n onClick={onClose}\n style={{\n padding: `${SPACE[2]}px ${SPACE[4]}px`,\n backgroundColor: COLORS.surfaceRaised,\n border: `1px solid ${COLORS.borderStrong}`,\n borderRadius: `${RADIUS.sm}px`,\n cursor: \"pointer\",\n fontSize: TYPE.md,\n color: COLORS.text,\n transition: \"background-color 150ms ease\",\n }}\n >\n Cancel\n </button>\n <button\n className=\"content-type-editor-save-button\"\n onClick={() => {\n onSave?.(data);\n onClose();\n }}\n style={{\n padding: `${SPACE[2]}px ${SPACE[4]}px`,\n backgroundColor: COLORS.accent,\n color: COLORS.white,\n border: \"none\",\n borderRadius: `${RADIUS.sm}px`,\n cursor: \"pointer\",\n fontSize: TYPE.md,\n fontWeight: 600,\n transition: \"background-color 150ms ease\",\n }}\n >\n Save\n </button>\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAWO;AACP,IAAAC,iBAAkE;;;ACJ3D,IAAM,SAAS;AAAA,EACpB,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,aAAa;AAAA,EACb,eAAe;AAAA,EACf,MAAM;AAAA,EACN,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,SAAS;AAAA,EACT,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,WAAW;AAAA,EACX,aAAa;AAAA,EACb,OAAO;AAAA,EACP,OAAO;AACT;AAEO,IAAM,QAAQ;AAAA,EACnB,SAAS;AAAA,EACT,MAAM;AACR;AAEO,IAAM,QAAQ;AAAA,EACnB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAA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AO,UAAU,GAAG;AAAA;AAAA,kBACjB;AAAA,kBAAc;AAAA,mBACpC;AAAA;AAAA,YAEJ;AAAA,YAEA;AAAA,cAAC;AAAA;AAAA,gBACC,WAAU;AAAA,gBACV,OAAO;AAAA,kBACL,SAAS;AAAA,kBACT,KAAK,GAAG,MAAM,CAAC,CAAC;AAAA,kBAChB,gBAAgB;AAAA,kBAChB,WAAW,GAAG,MAAM,CAAC,CAAC;AAAA,gBACxB;AAAA,gBAEA;AAAA;AAAA,oBAAC;AAAA;AAAA,sBACC,WAAU;AAAA,sBACV,SAAS;AAAA,sBACT,OAAO;AAAA,wBACL,SAAS,GAAG,MAAM,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC;AAAA,wBAClC,iBAAiB,OAAO;AAAA,wBACxB,QAAQ,aAAa,OAAO,YAAY;AAAA,wBACxC,cAAc,GAAG,OAAO,EAAE;AAAA,wBAC1B,QAAQ;AAAA,wBACR,UAAU,KAAK;AAAA,wBACf,OAAO,OAAO;AAAA,wBACd,YAAY;AAAA,sBACd;AAAA,sBACD;AAAA;AAAA,kBAED;AAAA,kBACA;AAAA,oBAAC;AAAA;AAAA,sBACC,WAAU;AAAA,sBACV,SAAS,MAAM;AACb,iCAAS,IAAI;AACb,gCAAQ;AAAA,sBACV;AAAA,sBACA,OAAO;AAAA,wBACL,SAAS,GAAG,MAAM,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC;AAAA,wBAClC,iBAAiB,OAAO;AAAA,wBACxB,OAAO,OAAO;AAAA,wBACd,QAAQ;AAAA,wBACR,cAAc,GAAG,OAAO,EAAE;AAAA,wBAC1B,QAAQ;AAAA,wBACR,UAAU,KAAK;AAAA,wBACf,YAAY;AAAA,wBACZ,YAAY;AAAA,sBACd;AAAA,sBACD;AAAA;AAAA,kBAED;AAAA;AAAA;AAAA,YACF;AAAA;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;","names":["import_core","import_react","coreSerialize","import_react","import_react","import_core","import_react","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_jsx_runtime","import_core","import_react","import_jsx_runtime","clampValue","import_core","import_react","import_jsx_runtime","import_core","import_react","import_jsx_runtime","import_jsx_runtime","hook","import_react","import_jsx_runtime"]}
|