`;
const element = createGeneratedSection(html);
dom.generated?.appendChild(element);
attachSectionControls(element);
selectSection(element);
ensureInstagramScript();
}
function ensureInstagramScript() {
if (window.instgrm?.Embeds) {
window.instgrm.Embeds.process();
return;
}
if (instagramScriptLoaded) return;
instagramScriptLoaded = true;
const script = document.createElement("script");
script.src = "https://www.instagram.com/embed.js";
script.async = true;
script.onload = () => window.instgrm?.Embeds?.process();
document.body.appendChild(script);
}
function buildMediaGuidanceLines() {
if (!state.mediaLibrary.length) return [];
const lines = ["מדיה זמינה לשימוש (תמונה/וידאו):"];
state.mediaLibrary.forEach((item, index) => {
const label = item.label || `מדיה ${index + 1}`;
const type = (item.type || "").toLowerCase().startsWith("video/") ? "וידאו" : "תמונה";
lines.push(`- ${label} [${type}] ${item.url}`);
});
lines.push(
"אם יש וידאו השתמשו בו בדיוק כמו תמונה (לדוגמה כרקע/hero), אל תוסיפו בלוק נוסף רק בגלל שהוא וידאו. שמרו על יחס מקור וללא עיוות פיקסלים."
);
lines.push("אם שם המדיה מכיל 'reference' או 'רפרנס' מדובר בהשראה בלבד.");
return lines;
}
function buildStructuredPrompt() {
const title = dom.fieldTitle?.value.trim() || "";
const subtitle = dom.fieldSubtitle?.value.trim() || "";
const paragraph = dom.fieldParagraph?.value.trim() || "";
const notes = dom.fieldNotes?.value.trim() || "";
if (!title && !subtitle && !paragraph && !notes) {
alert("הכניסו לפחות פריט תוכן אחד");
return "";
}
const lines = [
"שמור על RTL, על צבעי טסוף ועל מרווחי כרטיס אסתטיים.",
"חזרי רק HTML תקין. אין להחזיר Markdown או טקסט חופשי.",
"אסור להשתמש ב-