// π‘ [μμ ] νλ‘κ·Έλ¨ μ€ν μ κΈ°λ³ΈμΌλ‘ 1λ¨κ³κ° μ‘΄μ¬νλλ‘ μ΄κΈ°κ° μ€μ let currentScript = [{ credit: "μΆμ² μ λ ₯\n@username", idiom: "β ν΅μ¬ νν", meaning: "; λ»μ μ λ ₯νμΈμ", en: "", ko: "", pron: "", prompt_top: "stand-up comedian, highly detailed", prompt_bottom: "audience reacting, cinematic lighting" }]; let assetStates = {}; let currentPreviewTurn = 0; // π¨ μνΌ μλ§ νμ΄ν¬κ·ΈλνΌ κΈλ‘λ² μ€μ (λ³ν ν¨κ³Ό ν¬ν¨) let styleConfig = { english: { font: 'SUIT', size: 80, baseColor: '#FFFFFF', bgColor: '#000000', bgOpacity: 0.85, highlights: { 1: { color: '#FFF200', desc: 'μ£Όμ (λ Έλ)' }, 2: { color: '#00E5FF', desc: 'ν¨ν΄(μμ)' }, 3: { color: '#FF3B30', desc: 'μ£Όμ(λΉ¨κ°)' }, 4: { color: '#4CD964', desc: 'μ΄ν(μ΄λ‘)' }, 5: { color: '#FF2D55', desc: 'λμμ€(νν¬)' } } }, korean: { font: 'SeoulNamsanM', size: 55, color: '#FFFFFF', outlineColor: '#000000', outlineWidth: 3 }, pronunciation: { font: 'SchoolSafeDictation', size: 65, color: '#FF3B30', outlineColor: '#000000', outlineWidth: 2 } }; // β¨ [μμ§] λ³ν κ°μ κΈ°λ° λ©ν° μ€νμΌ μλ§ λ³ν ν¨μ function parseAsteriskToHTML(text) { if (!text) return ""; let html = text; html = html.replace(/\*{5}(.*?)\*{5}/g, `$1`); html = html.replace(/\*{4}(.*?)\*{4}/g, `$1`); html = html.replace(/\*{3}(.*?)\*{3}/g, `$1`); html = html.replace(/\*{2}(.*?)\*{2}/g, `$1`); html = html.replace(/\*(.*?)\*/g, `$1`); return html; } // [ν¨λ 1] AI λλ³Έ μμ± μμ§ async function generateScript() { const topic = document.getElementById('topicInput').value; if(!topic) { alert("μ£Όμ λ₯Ό μ λ ₯ν΄μ£ΌμΈμ."); return; } const btn = event.currentTarget; btn.innerHTML = ' μμ± μ€...'; btn.disabled = true; try { const response = await fetch('/api/studio/generate-script', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ topic: topic }) }); if (!response.ok) throw new Error(`μλ² μ€λ₯: ${response.status}`); const data = await response.json(); currentScript = data.dialogue.map((turn) => ({ credit: turn.credit || "μ§λ―Έ μΉ΄\n@jimmycarr", idiom: turn.idiom || "β ν΅μ¬ νν", meaning: turn.meaning || "; λ»μ μ λ ₯νμΈμ", en: turn.en || "", ko: turn.ko || "", pron: turn.ko_pron || turn.pron || "", prompt_top: turn.image_prompt_top || turn.image_prompt || "stand-up comedian, highly detailed", prompt_bottom: turn.image_prompt_bottom || "audience reacting, cinematic lighting" })); renderScriptPanel(); renderAssetPanel(); } catch (error) { console.error("λλ³Έ μμ± μλ¬:", error); // π‘ [μμ ] AI μμ± μ€ν¨ μ(Mock λ°μ΄ν°) κΈ°λ³Έ 4λ¨κ³ κΈ°νμ λ§μΆ° μΆλ ₯ currentScript = [ { credit: "μ§λ―Έ μΉ΄\n@jimmycarr", idiom: "β test the water(s)", meaning: "; λΆμκΈ°λ₯Ό μ΄νΌλ€ / λ°μμ λ 보λ€", en: "I'll just, I'll *test the water* first.", ko: "κ·Έλ₯ λΆμκΈ° ν λ² λ³Όκ²", pron: "μμμ μ€, μμν μ€λ μλ΄ νΌμ€λ", prompt_top: "stand-up comedian holding a microphone", prompt_bottom: "crowd of people smiling" }, { credit: "μ§λ―Έ μΉ΄\n@jimmycarr", idiom: "β make a move", meaning: "; νλμ μ·¨νλ€ / λ€κ°κ°λ€", en: "Before I actually **make a move**, you know?", ko: "본격μ μΌλ‘ νλνκΈ° μ μ λ§μ΄μΌ.", pron: "λΉν¬ μμ΄ μ‘μΈμΌλ¦¬ λ©μ΄μ»€ 무λΈ, μ λ Έ?", prompt_top: "man looking thoughtful, cinematic lighting", prompt_bottom: "close up of a person's eyes" }, { credit: "μ§λ―Έ μΉ΄\n@jimmycarr", idiom: "β play it safe", meaning: "; μμ νκ² κ°λ€ / 무리νμ§ μλ€", en: "It's always better to ***play it safe***.", ko: "μΈμ λ μμ νκ² κ°λ κ² λ«μ§.", pron: "μ΄μΈ μ¬μ¨μ΄μ¦ λ² λ¬ ν¬ νλ μ΄ μ μΈμ΄ν.", prompt_top: "a cautious person, dark background", prompt_bottom: "audience nodding in agreement" }, { credit: "μ§λ―Έ μΉ΄\n@jimmycarr", idiom: "β go all in", meaning: "; μ¬μΈνλ€ / λ€ κ±Έλ€", en: "Then I'll just ****go all in****.", ko: "κ·Έλ¬κ³ λμ μΉ λ€ κ±Έμ΄λ²λ¦΄ κ±°μΌ.", pron: "λ΄ μμμ μ€ κ³ μ¬ μΈ.", prompt_top: "casino chips, aggressive lighting", prompt_bottom: "people cheering loudly" } ]; renderScriptPanel(); renderAssetPanel(); } finally { btn.innerHTML = ' AI μμ±'; btn.disabled = false; } } // [ν¨λ 1] λλ³Έ μλν° UI λ λλ§ function renderScriptPanel() { const container = document.getElementById('scriptContainer'); container.innerHTML = ""; currentScript.forEach((turn, idx) => { // π‘ [μμ ] μΉ΄λ μ°μΈ‘ μλ¨μ X(μμ ) λ²νΌ μΆκ° const html = `