+ {/* Header */}
+
+
+
+
+
+ YouTube Studio
+
+ {step > 0 && (
+
+ )}
+
+
Generate viral titles, AI thumbnails, descriptions and publish directly to YouTube
+
+
+
+ {/* ===== STEP 0: Input Mode Selection ===== */}
+ {step === 0 && (
+
+ {/* Mode A: Video Analysis */}
+
+
+
+
+
+
+
Analyze Video
+
AI suggests viral titles from your content
+
+
+
+
{ setVideoFile(f); setMode('video'); handlePreUpload(f); }}
+ file={videoFile}
+ onClear={() => { setVideoFile(null); setPreprocessSessionId(null); }}
+ icon={Video}
+ />
+
+ {isPreprocessing && (
+
+
+ Pre-processing video (Whisper transcription starting)...
+
+ )}
+ {preprocessSessionId && !isPreprocessing && (
+
+
+ Video uploaded — transcription running in background
+
+ )}
+
+
+
+
+ {/* Mode B: Manual Title */}
+
+
+
+
+
+
+
Write Your Own
+
Skip analysis, enter your title directly
+
+
+
+
+
setManualTitle(e.target.value)}
+ placeholder="Enter your YouTube title..."
+ className="input-field text-sm mb-4"
+ maxLength={70}
+ />
+
{manualTitle.length}/70 characters
+
+
+
+
+
+ )}
+
+ {/* ===== STEP 1: Title Selection ===== */}
+ {step === 1 && (
+
+ {/* Left: Chat / Controls */}
+
+ {mode === 'manual' ? (
+
+
Your Title
+
setManualTitle(e.target.value)}
+ className="input-field text-sm"
+ maxLength={70}
+ />
+
{manualTitle.length}/70 characters
+
+
+ ) : (
+
+
+
+ Title Refinement Chat
+
+
+ {/* Chat messages */}
+
+ {chatHistory.map((msg, i) => (
+
+ ))}
+
+
+
+ {/* Chat input */}
+
+ setChatInput(e.target.value)}
+ onKeyDown={(e) => e.key === 'Enter' && !e.shiftKey && handleRefine()}
+ placeholder="Make them more clickbait..."
+ className="input-field text-xs flex-1"
+ disabled={isRefining}
+ />
+
+
+
+ )}
+
+ {mode !== 'manual' && selectedTitle && (
+
+ )}
+
+
+ {/* Right: Title Cards */}
+
+ {selectedTitle && (
+
+
+ Selected: {selectedTitle}
+
+ )}
+
+ {titles.length > 0 && (
+
+ {titles.map((title, i) => {
+ const rec = recommended.find(r => r.index === i);
+ const recRank = recommended.findIndex(r => r.index === i);
+ return (
+
+ );
+ })}
+
+ )}
+
+ {isRefining && (
+
+
+ Refining titles...
+
+ )}
+
+
+ )}
+
+ {/* ===== STEP 2: Thumbnail Generation ===== */}
+ {step === 2 && (
+
+ {/* Left: Controls */}
+
+
+
Selected Title
+
+ {selectedTitle || manualTitle}
+
+
+
+
+
+
+
Face Image (optional)
+ setFaceImage(null)}
+ icon={Upload}
+ />
+
+
+
+
Background Image (optional)
+ setBgImage(null)}
+ icon={Image}
+ />
+
+
+
+
Extra Instructions (optional)
+
+
+
+
Number of Thumbnails
+
+ {[1, 2, 3, 4].map(n => (
+
+ ))}
+
+
+
+
+
+
+
+ {/* Right: Generated Thumbnails */}
+
+ {generatedThumbnails.length > 0 ? (
+
+
Generated Thumbnails — click to select for publishing
+
+ {generatedThumbnails.map((url, i) => (
+
setSelectedThumbnail(url)}
+ className={`glass-panel overflow-hidden group relative cursor-pointer transition-all ${selectedThumbnail === url ? 'ring-2 ring-primary ring-offset-2 ring-offset-background' : ''
+ }`}
+ >
+
})
+
+
+
+
+
+ Thumbnail {i + 1}
+ {selectedThumbnail === url && (
+ Selected
+ )}
+
+
+
+
+ ))}
+
+
+ {/* Regenerate */}
+
+
+ {/* Proceed to Description */}
+ {selectedThumbnail && (
+
+ )}
+
+ ) : isGenerating ? (
+
+
+
+
Generating thumbnails...
+
This may take a minute per thumbnail
+
+
+ ) : (
+
+
+
+
+
+
Your thumbnails will appear here
+
Configure options and click Generate
+
+
+ )}
+
+
+ )}
+
+ {/* ===== STEP 3: YouTube Description ===== */}
+ {step === 3 && (
+
+ {/* Left: Context & Controls */}
+
+
+
+ {/* Selected Thumbnail Preview */}
+ {selectedThumbnail && (
+
+
})
+
+ Selected Thumbnail
+
+
+ )}
+
+ {/* Title */}
+
+
Video Title
+
+ {selectedTitle || manualTitle}
+
+
+
+ {/* Generate Description Button */}
+ {mode === 'video' && (
+
+
+
+
+ AI Description
+
+ with chapters
+
+
+ Generate a YouTube description with chapter timestamps from your video transcript.
+
+
+
+ )}
+
+ {/* Next: Publish */}
+ {description && (
+
+ )}
+
+
+ {/* Right: Editable Description */}
+
+
+
+
+
+ YouTube Description
+
+ {description.length}/5000
+
+
+
+
+
+ )}
+
+ {/* ===== STEP 4: Publish to YouTube ===== */}
+ {step === 4 && (
+
+ {/* Left: Summary & Publish */}
+
+
+
+ {/* Selected Thumbnail Preview */}
+ {selectedThumbnail && (
+
+
})
+
+ Selected Thumbnail
+
+
+ )}
+
+ {/* Editable Title */}
+
+
Video Title
+ selectedTitle ? setSelectedTitle(e.target.value) : setManualTitle(e.target.value)}
+ className="input-field text-sm"
+ maxLength={100}
+ />
+
+
+ {/* Publish Button */}
+ {(!uploadPostKey || !uploadUserId) ? (
+
+
+
+
Upload-Post Not Configured
+
+
+ To publish directly to YouTube, configure your Upload-Post API key and connect a profile in Settings.
+
+
+
+ ) : (
+
+ )}
+
+ {/* Publish Result */}
+ {publishResult && (
+
+ {publishResult.success ? (
+
+
+
+
Published successfully!
+
Your video is being uploaded to YouTube asynchronously.
+
+
+ ) : (
+
+
+
+
Publish failed
+
{publishResult.error}
+
+
+ )}
+
+ )}
+
+
+ {/* Right: Description Preview (read-only feel, still editable) */}
+
+
+
+
+
+ YouTube Description
+
+
+
+
+
+
+
+ )}
+