// Müşteri bazlı Marka Kiti — logo/renkler/fontlar/sosyal hesaplar/notlar/dosyalar/brief geçmişi const BKIcons = window.Icons; const { relativeDate: bkRel } = window.PMStore; const SOCIAL_PLATFORMS = ['Instagram', 'Facebook', 'LinkedIn', 'X / Twitter', 'TikTok', 'YouTube', 'Web Sitesi', 'Diğer']; function bkUid() { return Math.random().toString(36).slice(2, 10); } function bkSaveFile(id, dataUrl) { try { localStorage.setItem('nav_att_' + id, dataUrl); } catch (e) {} } function bkGetFile(id) { try { return localStorage.getItem('nav_att_' + id); } catch (e) { return null; } } function bkDelFile(id) { try { localStorage.removeItem('nav_att_' + id); } catch (e) {} } function bkFmtSize(bytes) { if (!bytes) return ''; if (bytes < 1024) return bytes + ' B'; if (bytes < 1024 * 1024) return Math.round(bytes / 1024) + ' KB'; return (bytes / (1024 * 1024)).toFixed(1) + ' MB'; } function BrandKitModal({ project, onUpdateBrandKit, onAddFile, onRemoveFile, onClose }) { const bk = project.brandKit || { colors: [], fonts: [], socials: [], notes: '', files: [] }; const [newColor, setNewColor] = React.useState('#ff601f'); const [newFont, setNewFont] = React.useState(''); const [socPlat, setSocPlat] = React.useState(SOCIAL_PLATFORMS[0]); const [socHandle, setSocHandle] = React.useState(''); const [notes, setNotes] = React.useState(bk.notes || ''); const [dragOver, setDragOver] = React.useState(false); const notesTimer = React.useRef(null); const patch = (p) => onUpdateBrandKit(project.id, p); const addColor = () => { if (!newColor) return; patch({ colors: [...(bk.colors || []), newColor] }); }; const removeColor = (i) => patch({ colors: (bk.colors || []).filter((_, idx) => idx !== i) }); const addFont = () => { const v = newFont.trim(); if (!v) return; patch({ fonts: [...(bk.fonts || []), v] }); setNewFont(''); }; const removeFont = (i) => patch({ fonts: (bk.fonts || []).filter((_, idx) => idx !== i) }); const addSocial = () => { const v = socHandle.trim(); if (!v) return; patch({ socials: [...(bk.socials || []), { platform: socPlat, handle: v }] }); setSocHandle(''); }; const removeSocial = (i) => patch({ socials: (bk.socials || []).filter((_, idx) => idx !== i) }); const onNotesChange = (v) => { setNotes(v); clearTimeout(notesTimer.current); notesTimer.current = setTimeout(() => patch({ notes: v }), 500); }; const handleFiles = (files) => { Array.from(files).forEach(file => { if (file.size > 4 * 1024 * 1024) { alert(`"${file.name}" 4MB sınırını aşıyor.`); return; } const id = bkUid(); const reader = new FileReader(); reader.onload = (e) => { bkSaveFile(id, e.target.result); onAddFile(project.id, { id, name: file.name, type: file.type, size: file.size }); }; reader.readAsDataURL(file); }); }; const removeFile = (fileId) => { bkDelFile(fileId); onRemoveFile(project.id, fileId); }; const briefHistory = project.briefHistory || []; return (