PageSourceSearch

https://medifit-nienburg.de/assets/CampaignPlanner-BNoe5UuE.js

js medifit-nienburg.de collected 2026-10-04 03:33:14 UTC 94,492 bytes, 88 lines download raw bytes

1import{a as i,j as e}from"./trpc-vendor-Bta84Nsh.js";import{t as b,u as Ye}from"./index-_3-B0itT.js";import{t as l,M as Xe,j as Me,aj as ce,n as et,Y as Le,a_ as tt,ap as st,X as ye,g as rt}from"./ui-vendor-NEZNvIbV.js";import"./react-vendor-DpXpH6G7.js";const Oe=[{v:"aktion",l:"🎯 Aktion"},{v:"onboarding",l:"🚀 Onboarding + Startkampagne"},{v:"content",l:"🎬 Content"},{v:"mailing",l:"✉️ Mailing"},{v:"event",l:"📅 Event"},{v:"sonstiges",l:"📌 Sonstiges"}],nt=[{v:"discount",l:"Discount-Fitness"},{v:"premium",l:"Premium-Fitness"},{v:"gesundheit",l:"Gesundheitsstudio"},{v:"kampfsport",l:"Kampfsport / Kampfkunst"},{v:"crossfit",l:"Crossfit / Functional"}],at=[{v:3,l:"3 · Atombombe 💥",d:"Maximaler Preis-Knaller — nur mit Anlass"},{v:2,l:"2 · Sparangebot",d:"Klarer Preisvorteil ohne Verramschen"},{v:1,l:"1 · Ohne Preisfokus",d:"Marke, Qualität, Anlässe"}],$e=[{v:"idee",l:"Idee",cls:"bg-muted text-muted-foreground"},{v:"geplant",l:"Geplant",cls:"bg-blue-500/15 text-blue-600"},{v:"in_arbeit",l:"In Arbeit",cls:"bg-amber-500/15 text-amber-600"},{v:"aktiv",l:"Aktiv",cls:"bg-emerald-500/15 text-emerald-600"},{v:"fertig",l:"Fertig",cls:"bg-muted text-muted-foreground"}],ot=[{v:"low",l:"Niedrig"},{v:"medium",l:"Mittel"},{v:"high",l:"Hoch"},{v:"urgent",l:"Dringend"}],Ve=d=>d?new Date(d).toISOString().slice(0,10):"",Fe=d=>d?new Date(`${d}T00:00:00`).getTime():null,We=d=>d?new Date(d).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}):"—",it=["Hook in die Kamera (Coach/Inhaber) — Sprechtext siehe unten · 15–20 Sek. · 2 Takes","Angebots-Ansage: Was, wie lange, für wen · 15 Sek.","Trainingsfläche mit Betrieb (B-Roll) · 3–4 kurze Schwenks à 5 Sek.","Mitglied-Testimonial · 20 Sek. · Einverständnis abfragen · WICHTIG: Frage IN die Antwort einbauen (Frage wird rausgeschnitten) — statt „5 Jahre“ → „Ich trainiere seit 5 Jahren hier …“ · nicht in die Kamera, leicht seitlich · 2 Anläufe","Team/Empfang — Begrüßungs-Moment · 10 Sek.","Außenansicht + Logo · 5 Sek."],dt="Hochkant 9:16 · neuestes Handy · Fenster vor dir (kein Gegenlicht) · ruhige Hand oder anlehnen · Originaldateien hochladen (nicht per WhatsApp schicken) · kurz & knackig, auf die USPs fokussiert · je nach Studio-Typ die passenden USPs betonen (Fitness = Preis/24-7/Flexibilität · Gesundheit = Betreuung/Prävention · CrossFit = Community/Coaches)",Ge=[{title:"Video-Material screenen (Mediathek: vorhanden / fehlt)",offsetDays:-28,priority:"high"},{title:"Video-Briefing an Studios senden (nach Tims Freigabe)",offsetDays:-28,priority:"high"},{title:"Landingpage bauen (unveröffentlicht)",offsetDays:-28,priority:"high"},{title:"Studio-Videos zurück + gesichtet — sonst nachfassen",offsetDays:-21,priority:"medium"},{title:"Creatives: Haupt- (Deadline ab Tag 1) + Closeout- + Hook-Varianten",offsetDays:-14,priority:"medium"},{title:"E-Mails + WhatsApps erstellt + terminiert (inkl. Closeout-Mails)",offsetDays:-10,priority:"medium"},{title:"Meta-Kampagne aufgesetzt, UTM je Variante (pausiert)",offsetDays:-7,priority:"medium"},{title:"Studio-Team briefen (Chat): Angebot + Verkaufstipps + Einwände",offsetDays:-2,priority:"high"},{title:"Go-Live: Landingpage live + Ads an + Go-Live-Check",offsetDays:0,priority:"urgent"},{title:"Erst-Feedback an Tim: CPL + Hook-Trend",offsetDays:3,priority:"high"},{title:"Feedback 2: Gewinner skalieren, Verlierer pausieren",offsetDays:7,priority:"medium"},{title:"Zwischenfazit: verlängern / anpassen / Folgekampagne",offsetDays:14,priority:"medium"},{title:"Closeout-Phase: Extra-Ads + Retargeting + Closeout-Mails",offsetDays:-5,priority:"high",fromEnd:!0},{title:"End-Auswertung + nächste Kampagne anlegen",offsetDays:0,priority:"high",fromEnd:!0}];function Ue({initial:d,brands:C,users:O,onSave:N,onClose:$,saving:P,defaultTodos:A,defaultVideoBriefing:B}){const[v,K]=i.useState(d?.name??""),[T,F]=i.useState(d?.type??"aktion"),[V,J]=i.useState(d?.status??"geplant"),[I,q]=i.useState(d?.description??""),[L,ve]=i.useState(Ve(d?.startDate)),[m,Se]=i.useState(Ve(d?.endDate)),[W,he]=i.useState(!d?.brandIds?.length),[_,xe]=i.useState(d?.brandIds??[]),[pe,Ae]=i.useState(d?.assignedTo?String(d.assignedTo):"none"),[ie,ue]=i.useState(d?.items?.length?d.items:(A??Ge).map(t=>({...t}))),[Q,ke]=i.useState("brief"),k=d?.briefing??{},[p,G]=i.useState({offer:k.offer??"",limitation:k.limitation??"",audience:k.audience??"",message:k.message??"",hooks:Array.isArray(k.hooks)?k.hooks.join(`
2`):k.hooks??"",cta:k.cta??"",funnelUrl:k.funnelUrl??"",tariffScope:k.tariffScope??"focus",focusTariff:k.focusTariff??"",tariffMatrix:Array.isArray(k.tariffMatrix)?k.tariffMatrix:[]}),Y=k.closeout??{},[z,de]=i.useState({realEnd:Y.realEnd??"",scarcity:Y.scarcity??"datum_stueckzahl",midCloseouts:Array.isArray(Y.midCloseouts)?Y.midCloseouts.join(`
3`):Y.midCloseouts??"",adPhase:Y.adPhase!==!1,creativesDeadline:Y.creativesDeadline!==!1}),[U,fe]=i.useState(k.approval??null),[R,H]=i.useState(k.ownerApproval??null),[X,be]=i.useState(k.ownerApproval?.sentTo??""),[ne,ge]=i.useState(Array.isArray(d?.emailPlan)&&d.emailPlan.length?d.emailPlan:[]),le=d?.videoBriefing??{},ee=B??{},[f,ae]=i.useState({deadline:le.deadline??"",intro:le.intro??ee.intro??"",shots:Array.isArray(le.shots)&&le.shots.length?le.shots.join(`
4`):Array.isArray(ee.shots)&&ee.shots.length?ee.shots.join(`
5`):it.join(`
6`),rules:le.rules??ee.rules??dt,sentAt:le.sentAt??null}),Z=W?void 0:_[0],je=b.contractTypes.list.useQuery({activeOnly:!0,brandId:Z},{enabled:!!Z&&Q==="brief",staleTime:6e4}),Ce=()=>{const t=(je.data??[]).map(n=>({tarif:n.name??"",binding:n.durationMonths?`${n.durationMonths} Monate`:"monatlich kündbar",regular:`${n.price??"—"} €${n.priceLabel?" "+n.priceLabel:" / Monat"}${n.enrollmentFee?` · Aufnahme ${n.enrollmentFee} €`:""}`,action:"",save:""}));if(!t.length){l.error("Für dieses Studio sind keine Tarife hinterlegt (Vertragstypen).");return}G(n=>({...n,tariffMatrix:t,focusTariff:n.focusTariff||t[0].tarif})),l.success(`${t.length} Tarif(e) geladen — jetzt „Im Aktionszeitraum" + Ersparnis eintragen.`)},r=(t,n)=>G(c=>({...c,tariffMatrix:c.tariffMatrix.map((E,se)=>se===t?{...E,...n}:E)})),x=()=>G(t=>({...t,tariffMatrix:[...t.tariffMatrix,{tarif:"",regular:"",action:"",save:"",binding:""}]})),w=t=>G(n=>({...n,tariffMatrix:n.tariffMatrix.filter((c,E)=>E!==t)}));b.campaignPlanner.aiBriefing.useMutation({onSuccess:t=>{G(n=>({...n,audience:t.audience||n.audience,message:t.message||n.message,hooks:(t.hooks??[]).join(`
7`)||n.hooks,cta:t.cta||n.cta})),!ne.length&&(t.emailSubjects??[]).length&&ge(t.emailSubjects.slice(0,3).map((n,c)=>({date:"",time:c===2?"09:00":c===1?"18:00":"10:00",subject:n,audience:"Ehemalige + Leads",status:"offen"}))),(t.videoLines??[]).length&&ae(n=>({...n,intro:n.intro||`${p.offer}
8Sprechtexte:
9– ${t.videoLines.join(`
10– `)}`})),l.success("KI-Briefing erstellt — bitte kurz prüfen und anpassen.")},onError:t=>l.error(t?.message??"KI-Fehler")});const g=b.campaignPlanner.sendVideoBriefing.useMutation({onSuccess:t=>{ae(n=>({...n,sentAt:Date.now()})),l.success(`Video-Briefing an ${t.studios} Studio(s) gesendet (${t.mails} E-Mail(s)${t.whatsapp?`, ${t.whatsapp} WhatsApp`:""}).`)},onError:t=>l.error(t?.message??"Senden fehlgeschlagen")}),D=b.campaignPlanner.videoBriefingStatus.useQuery({id:d?.id??0},{enabled:!!d?.id&&Q==="video",refetchInterval:2e4}),s=()=>{const t=re=>String(re??"").replace(/[&<>]/g,Ee=>({"&":"&amp;","<":"&lt;",">":"&gt;"})[Ee]),n=W?"Alle Studios":(()=>{const re=C.find(Ee=>String(Ee.id)===String(_[0]));return re?.studioName||re?.name||"Studio"})(),c=(p?.offer||"[Angebot hier eintragen]").trim(),E=f.deadline?new Date(f.deadline).toLocaleDateString("de-DE"):"—",se=(f.intro||`Ziel: Leads über Meta-Ads. Kernbotschaft (muss in jedem Video fallen): ${c}. Sprechtexte in eigenen Worten, nicht ablesen. Jeden Text 2–3× aufnehmen.`).trim(),Be=String(f.shots||"").split(`
11`).map(re=>re.trim()).filter(Boolean),Ke=(f.rules||"").trim(),Qe=[{t:"Spot 1 — Das Angebot (Preis-Hook)",set:"Mitten auf der Trainingsfläche, Geräte im Hintergrund.",txt:`„${c}. Fang jetzt an — Link ist unten."`,reg:"Zahl/Angebot am Anfang mit kurzer Pause. Nicht hetzen."},{t:"Spot 2 — Warum wir (USP)",set:"Start am Eingang/Check-in, dann Cut auf die Fläche.",txt:`„Moderne Geräte, faire Preise, du trainierst wann du willst — kein Verkaufsdruck. ${c}."`,reg:"Beim Check-in wirklich einchecken lassen — starker Cut."},{t:"Spot 3 — Der Einwand",set:"Ruhiger Bereich, direkt in die Kamera.",txt:`„‚Keine Zeit fürs Studio?' Früh um sechs offen, abends um zehn auch. ${c} — mehr kann's dich nicht kosten."`,reg:"Letzter Satz mit Lächeln. Das ist der Abbinder."}].map(re=>`<div class="spot"><div class="st">${t(re.t)}</div><div class="set">Setting: ${t(re.set)}</div><div class="txt">${t(re.txt)}</div><div class="reg">Regie: ${t(re.reg)}</div></div>`).join(""),Je=(Be.length?Be:["Hook in die Kamera · 15–20 Sek.","Angebots-Ansage · 15 Sek.","B-Roll Trainingsfläche · 3–4× 5 Sek.","Mitglied-Testimonial · 20 Sek.","Außenansicht + Logo · 5 Sek."]).map(re=>`<li>${t(re)}</li>`).join(""),qe=`<!doctype html><html lang="de"><head><meta charset="utf-8"><title>Video-Briefing · ${t(n)}</title><style>
12      @page{size:A4;margin:14mm}*{box-sizing:border-box;margin:0;padding:0;font-family:'Segoe UI',Arial,sans-serif;color:#14161c}
13      .head{border-bottom:2px solid #14161c;padding-bottom:10px;margin-bottom:12px;display:flex;justify-content:space-between;align-items:flex-end}
14      .head .wm{font-size:15px;font-weight:800}.head .wm span{color:#c99c2d}.head .k{font-size:9px;letter-spacing:2px;text-transform:uppercase;color:#b98f00;font-weight:800}.head h1{font-size:17px;font-weight:900;margin-top:2px}
15      .meta{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:12px}.chip{font-size:10px;border:1px solid #e2ded6;border-radius:20px;padding:3px 10px;color:#33424e}
16      h2{font-size:13px;font-weight:800;margin:14px 0 5px}.box{border:1px solid #e2ded6;border-radius:9px;padding:9px 12px;font-size:11.5px;line-height:1.55;color:#33424e}
17      ul{margin:2px 0 0 0;padding-left:16px}li{font-size:11px;color:#33424e;margin-bottom:2px}
18      .kb{background:#fff7d6;border:1px solid #ecd98a;border-radius:9px;padding:9px 12px;font-size:11.5px;color:#6b5518}
19      .spot{border:1px solid #e2ded6;border-radius:9px;padding:9px 12px;margin-top:7px;page-break-inside:avoid}.spot .st{font-size:12px;font-weight:800}.spot .set{font-size:10px;color:#8a94a0;margin-top:1px}.spot .txt{font-size:12px;font-style:italic;margin-top:5px;padding-left:9px;border-left:2px solid #F0C000}.spot .reg{font-size:10px;color:#8a5a12;margin-top:4px}
20      .foot{margin-top:16px;border-top:1px solid #e2ded6;padding-top:7px;font-size:9px;color:#9aa6ae}
21    </style></head><body>
22      <div class="head"><div><div class="wm">More<span>Members</span></div></div><div style="text-align:right"><div class="k">Video-Briefing</div><h1>${t(v||"Kampagne")}</h1></div></div>
23      <div class="meta"><span class="chip">Studio: <b>${t(n)}</b></span><span class="chip">Deadline: <b>${t(E)}</b></span><span class="chip">Format: <b>9:16 hochkant</b></span><span class="chip"><b>3 Video-Varianten</b></span></div>
24      <h2>Ziel &amp; Kernbotschaft</h2><div class="box">${t(se).replace(/\n/g,"<br>")}</div>
25      <h2>Shotliste</h2><div class="box"><ul>${Je}</ul></div>
26      <h2>3 Video-Varianten (Spots) — je ein eigenes Video</h2>${Qe}
27      <h2>Testimonial (2 Mitglieder)</h2><div class="kb"><b>Wichtig:</b> Die Frage wird rausgeschnitten — die Antwort muss für sich stehen. Sag dem Mitglied: „Bau meine Frage in deine Antwort ein." Beispiel: statt „5 Jahre" → „Ich trainiere seit 5 Jahren hier …". Leicht seitlich, 2 Anläufe, vor/nach der Antwort 2 Sek. Stille.</div>
28      ${Ke?`<h2>Formatregeln</h2><div class="box">${t(Ke)}</div>`:""}
29      <div class="foot">MoreMembers · Video-Briefing · [email protected]</div>
30    </body></html>`,De=window.open("","_blank");if(!De){l.error("Bitte Popups erlauben, dann klappt der PDF-Export.");return}De.document.write(qe),De.document.close(),De.focus(),setTimeout(()=>{try{De.print()}catch{}},400)},a=b.campaignPlanner.setDefaultTodos.useMutation({onSuccess:()=>
30l.success("Als Standard-Vorlage gespeichert — gilt für jede neue Kampagne."),onError:t=>l.error(t?.message??"Fehler")}),{user:o}=Ye(),u=o?.role==="admin",j=b.campaignPlanner.requestApproval.useMutation({onSuccess:()=>{fe({requestedAt:Date.now(),approvedAt:null}),l.success("Freigabe angefordert — Tim bekommt eine E-Mail.")},onError:t=>l.error(t?.message??"Fehler")}),h=b.campaignPlanner.approve.useMutation({onSuccess:()=>{fe(t=>({...t??{},approvedAt:Date.now()})),l.success("Freigegeben — Video-Briefing kann raus.")},onError:t=>l.error(t?.message??"Fehler")}),y=b.campaignPlanner.sendTestToAdmin.useMutation({onSuccess:()=>l.success("Test-Vorschau an Tim gesendet — er bekommt eine E-Mail mit dem Link."),onError:t=>l.error(t?.message??"Fehler")}),S=b.campaignPlanner.sendOwnerConcept.useMutation({onSuccess:t=>{H({sentAt:Date.now(),sentTo:X,status:"pending"}),l.success("Konzept-Link an den Inhaber gesendet.")},onError:t=>l.error(t?.message??"Fehler")}),M=b.campaignPlanner.evaluation.useQuery({id:d?.id??0},{enabled:!!d?.id&&Q==="auswertung"}),[te,me]=i.useState(null),Ne=b.campaignPlanner.aiEvaluation.useMutation({onSuccess:t=>me(t),onError:t=>l.error(t?.message??"KI-Fehler")}),He=t=>xe(n=>n.includes(t)?n.filter(c=>c!==t):[...n,t]),ze=(t,n)=>ue(ie.map((c,E)=>E===t?{...c,...n}:c)),Te=(t,n)=>ge(ne.map((c,E)=>E===t?{...c,...n}:c)),Ie=()=>ie.filter(t=>t.title.trim()).map(t=>({title:t.title.trim(),offsetDays:Number(t.offsetDays)||0,priority:t.priority})),Ze=()=>({name:v.trim(),type:T,status:V,description:I.trim()||null,brandIds:W?null:_,assignedTo:pe==="none"?null:Number(pe),startDate:Fe(L),endDate:Fe(m),items:Ie(),briefing:{offer:p.offer.trim(),limitation:String(p.limitation??"").trim(),audience:p.audience.trim(),message:p.message.trim(),hooks:String(p.hooks).split(`
31`).map(t=>t.trim()).filter(Boolean),cta:p.cta.trim(),funnelUrl:p.funnelUrl.trim(),tariffScope:p.tariffScope,focusTariff:String(p.focusTariff??"").trim(),tariffMatrix:(p.tariffMatrix??[]).filter(t=>(t.tarif??"").trim()),closeout:{realEnd:z.realEnd,scarcity:z.scarcity,midCloseouts:String(z.midCloseouts).split(`
32`).map(t=>t.trim()).filter(Boolean),adPhase:!!z.adPhase,creativesDeadline:!!z.creativesDeadline},...U?{approval:U}:{},...R?{ownerApproval:R}:{}},emailPlan:ne.filter(t=>t.subject.trim()),videoBriefing:{deadline:f.deadline,intro:f.intro,shots:String(f.shots).split(`
33`).map(t=>t.trim()).filter(Boolean),rules:f.rules,...f.sentAt?{sentAt:f.sentAt}:{}}}),_e=()=>{if(!v.trim()){l.error("Bitte einen Namen angeben.");return}N(Ze())},Pe="w-full h-9 rounded-md border border-border bg-background px-2.5 text-sm text-foreground",we="w-full rounded-md border border-border bg-background px-2.5 py-2 text-sm text-foreground resize-none",oe="text-xs font-medium text-foreground";return e.jsx("div",{className:"fixed inset-0 z-[100] bg-black/60 flex items-center justify-center p-4",onClick:$,children:e.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-2xl max-h-[90vh] overflow-auto",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border sticky top-0 bg-card",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:d?"Kampagne bearbeiten":"Neue Kampagne"}),e.jsx("button",{onClick:$,className:"text-muted-foreground hover:text-foreground",children:e.jsx(ye,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"grid md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1 md:col-span-2",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Name *"}),e.jsx("input",{value:v,onChange:t=>K(t.target.value),placeholder:"z.B. Sommer-Aktion 6 Monate",className:"w-full h-9 rounded-md border border-border bg-background px-2.5 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Art"}),e.jsx("select",{value:T,onChange:t=>F(t.target.value),className:"w-full h-9 rounded-md border border-border bg-background px-2 text-sm text-foreground",children:Oe.map(t=>e.jsx("option",{value:t.v,children:t.l},t.v))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Status"}),e.jsx("select",{value:V,onChange:t=>J(t.target.value),className:"w-full h-9 rounded-md border border-border bg-background px-2 text-sm text-foreground",children:$e.map(t=>e.jsx("option",{value:t.v,children:t.l},t.v))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Start"}),e.jsx("input",{type:"date",value:L,onChange:t=>ve(t.target.value),className:"w-full h-9 rounded-md border border-border bg-background px-2.5 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Ende (optional)"}),e.jsx("input",{type:"date",value:m,onChange:t=>Se(t.target.value),className:"w-full h-9 rounded-md border border-border bg-background px-2.5 text-sm"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Studios"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>he(!0),className:`text-xs px-3 py-1.5 rounded-lg border ${W?"bg-primary text-primary-foreground border-primary":"border-border text-foreground"}`,children:"Alle Studios"}),e.jsx("button",{onClick:()=>he(!1),className:`text-xs px-3 py-1.5 rounded-lg border ${W?"border-border text-foreground":"bg-primary text-primary-foreground border-primary"}`,children:"Auswählen"})]}),!W&&e.jsx("div",{className:"grid grid-cols-2 gap-1.5 max-h-32 overflow-auto rounded-md border border-border p-2",children:C.map(t=>e.jsxs("label",{className:"flex items-center gap-2 text-xs text-foreground cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:_.includes(t.id),onChange:()=>He(t.id),className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"truncate",children:[t.studioName??t.name,t.isActive===!1?" 🚧":""]})]},t.id))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Aufgaben zuweisen an"}
33),e.jsxs("select",{value:pe,onChange:t=>Ae(t.target.value),className:"w-full h-9 rounded-md border border-border bg-background px-2 text-sm text-foreground",children:[e.jsx("option",{value:"none",children:"Niemand (nur planen)"}),O.map(t=>e.jsxs("option",{value:String(t.id),children:[t.name??t.email,t.role?` (${t.role})`:""]},t.id))]})]}),e.jsx("div",{className:"flex gap-1 border-b border-border pt-1 flex-wrap",children:[["brief","📝 Briefing"],["todos","✅ To-dos"],["mails","✉️ E-Mail-Plan"],["video","🎬 Video-Briefing"],...d?.id?[["auswertung","📊 Auswertung"]]:[]].map(([t,n])=>e.jsx("button",{onClick:()=>ke(t),className:`text-xs px-3 py-2 font-medium rounded-t-lg border border-b-0 ${Q===t?"bg-primary/10 border-primary/40 text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:n},t))}),Q==="brief"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-[11px] text-muted-foreground bg-muted/30 border border-border rounded-lg px-3 py-2",children:["In der Kampagne steht ",e.jsx("b",{className:"text-foreground",children:"nur das Angebot"}),": Preise, Ersparnis, Countdowns, Studio & Freigabe-Stand. Hooks, Anzeigentexte & Kommunikation entstehen ",e.jsx("b",{className:"text-foreground",children:"später in den Creatives"})," (Aufgaben-Phase) — nicht hier."]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded bg-primary text-primary-foreground text-[11px] font-bold",children:"1"}),e.jsx("span",{className:"text-sm font-bold text-foreground",children:"Das Angebot — glasklar"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"rein technisch, ein Satz"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:oe,children:"Angebot in einem Satz *"}),e.jsx("textarea",{value:p.offer,onChange:t=>G({...p,offer:t.target.value}),rows:2,className:we,placeholder:"z.B. Die ersten 3 Monate für 9,90 € statt regulär — danach läuft der reguläre Tarif weiter."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:oe,children:"Limitierung / Verknappung"}),e.jsx("input",{value:p.limitation,onChange:t=>G({...p,limitation:t.target.value}),className:Pe,placeholder:"z.B. nur für die ersten 100 Anmeldungen"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Zeitraum & Angebots-Ende trägst du unten im Closeout-Block ein."}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded bg-primary text-primary-foreground text-[11px] font-bold",children:"2"}),e.jsx("span",{className:"text-sm font-bold text-foreground",children:"Tarif-Matrix"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"was ändert sich pro Standardtarif"})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-muted/20 p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:Ce,disabled:!Z||je.isLoading,className:"text-[11px] px-2.5 py-1.5 rounded-md border border-primary/50 text-primary font-semibold disabled:opacity-40",children:je.isLoading?"Lädt…":"↧ Tarife aus Studio laden"}),!Z&&e.jsx("span",{className:"text-[10px] text-amber-500",children:"Erst genau EIN Studio wählen, dann laden."}),e.jsxs("div",{className:"ml-auto flex items-center gap-1.5 text-[11px]",children:[e.jsx("span",{className:"text-muted-foreground",children:"Aktion gilt:"}),e.jsxs("select",{value:p.tariffScope,onChange:t=>G({...p,tariffScope:t.target.value}),className:"h-7 rounded border border-border bg-background px-1 text-[11px] text-foreground",children:[e.jsx("option",{value:"focus",children:"1 Tarif im Fokus"}),e.jsx("option",{value:"all",children:"alle Tarife"})]})]})]}),p.tariffScope==="focus"&&p.tariffMatrix.length>0&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:"Fokus-Tarif:"}),e.jsx("select",{value:p.focusTariff,onChange:t=>G({...p,focusTariff:t.target.value}),className:"h-7 rounded border border-border bg-background px-1 text-[11px] text-foreground flex-1",children:p.tariffMatrix.map((t,n)=>e.jsx("option",{value:t.tarif,children:t.tarif||`Tarif ${n+1}`},n))})]}),p.tariffMatrix.length===0?e.jsx("p",{className:"text-[11px] text-muted-foreground",children:'Noch keine Tarife. „Tarife aus Studio laden" klicken oder unten eine Zeile hinzufügen.'}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-[11px] border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-muted-foreground",children:[e.jsx("th",{className:"py-1 pr-1.5 font-semibold",children:"Standardtarif"}),e.jsx("th",{className:"py-1 pr-1.5 font-semibold",children:"Regulär"}),e.jsx("th",{className:"py-1 pr-1.5 font-semibold",children:"Im Aktionszeitraum"}),e.jsx("th",{className:"py-1 pr-1.5 font-semibold",children:"Ersparnis"}),e.jsx("th",{className:"py-1 pr-1.5 font-semibold",children:"Bindung"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:p.tariffMatrix.map((t,n)=>{const c=p.tariffScope==="focus"&&t.tarif===p.focusTariff,E="w-full h-7 rounded border border-border bg-background px-1.5 text-foreground";return e.jsxs("tr",{className:c?"bg-primary/5":"",children:[e.jsx("td",{className:"py-0.5 pr-1",children:e.jsx("input",{value:t.tarif,onChange:se=>r(n,{tarif:se.target.value}),className:E,placeholder:"24 Monate"})}),e.jsx("td",{className:"py-0.5 pr-1",children:e.jsx("input",{value:t.regular,onChange:se=>r(n,{regular:se.target.value}),className:E,placeholder:"39,90 € / Monat"})}),e.jsx("td",{className:"py-0.5 pr-1",children:e.jsx("input",{value:t.action,onChange:se=>r(n,{action:se.target.value}),className:E,placeholder:"3× 9,90 €, danach 34,90 €"})}),e.jsx("td",{className:"py-0.5 pr-1",children:e.jsx("input",{value:t.save,onChange:se=>r(n,{save:se.target.value}),className:E,placeholder:"≈ 105 €"})}),e.jsx("td",{className:"py-0.5 pr-1",children:e.jsx("input",{value:t.binding,onChange:se=>r(n,{binding:se.target.value}),className:E,placeholder:"24 Monate"})}),e.jsx("td",{className:"py-0.5",children:e.jsx("button",{type:"button",onClick:()=>w(n),className:"text-muted-foreground hover:text-red-500 px-1",children:"✕"})})]},n)})})]})}),e.jsx("button",{type:"button",onClick:x,className:"text-[11px] text-primary font-medium",children:"+ Zeile"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:'Der Fokus-Tarif ist hervorgehoben. „Regulär" kommt aus den Studio-Tarifen; „Im Aktionszeitraum" + „Ersparnis" trägst du je Tarif ein.'})]}),e.jsxs("div",{className:"rounded-lg border border-red-500/40 bg-red-500/5 p-3 space-y-2",children:[e.jsx("div",{className:"text-xs font-bold text-red-500",children:"⏳ Closeouts — Pflicht bei jeder Kampagne"}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:oe,children:"Echtes Angebots-Ende (Datum + 
33Uhrzeit)"}),e.jsx("input",{type:"datetime-local",value:z.realEnd,onChange:t=>de({...z,realEnd:t.target.value}),className:Pe})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:oe,children:"Verknappungs-Art"}),e.jsxs("select",{value:z.scarcity,onChange:t=>de({...z,scarcity:t.target.value}),className:Pe,children:[e.jsx("option",{value:"datum_stueckzahl",children:"Datum + Stückzahl (empfohlen — Datum zieht am meisten)"}),e.jsx("option",{value:"datum",children:"Nur Datum"}),e.jsx("option",{value:"stueckzahl",children:"Nur Stückzahl / Plätze"}),e.jsx("option",{value:"slots",children:"Termin-Slots (ohne Preis-Closeout)"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:oe,children:"Künstliche Zwischen-Closeouts (eine pro Zeile, mit Datum)"}),e.jsx("textarea",{value:z.midCloseouts,onChange:t=>de({...z,midCloseouts:t.target.value}),rows:2,className:we,placeholder:`07.09. — Die ersten 20 Plätze sind weg
3411.09. — Nur noch 3 Tage`})]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-foreground cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!!z.adPhase,onChange:t=>de({...z,adPhase:t.target.checked}),className:"w-3.5 h-3.5"}),'Closeout-Phase: letzte 3–5 Tage Extra-Adset + Retargeting („Angebot nur noch bis …")']}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-foreground cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!!z.creativesDeadline,onChange:t=>de({...z,creativesDeadline:t.target.checked}),className:"w-3.5 h-3.5"}),"Haupt-Creatives zeigen die Deadline ab Tag 1 + separate Closeout-Creatives"]})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded bg-primary text-primary-foreground text-[11px] font-bold",children:"3"}),e.jsx("span",{className:"text-sm font-bold text-foreground",children:"Impulse für die Umsetzung"}),e.jsx("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"optional"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:oe,children:"Was betonen? Welche USPs? (Stichpunkte für die Creative-Phase)"}),e.jsx("textarea",{value:I,onChange:t=>q(t.target.value),rows:2,className:we,placeholder:"z.B. USP Betreuung/Prävention betonen, Zielgruppe 40+. — Hooks & Anzeigentexte entstehen später in den Creatives, nicht hier."}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Die USPs stehen auch aus dem Onboarding beim Studio hinterlegt. Hier nur dein Senf/Impulse — die Ausformulierung passiert in den Creatives."})]}),d?.id&&e.jsxs("div",{className:"rounded-lg border border-blue-500/40 bg-blue-500/5 p-3 space-y-2",children:[e.jsx("div",{className:"text-xs font-bold text-blue-500",children:"👀 Test an Tim senden"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Schickt Tim die Konzept-Vorschau (so wie sie später der Inhaber sähe) — nur zum Anschauen, es geht nichts an ein Studio raus. Braucht keine Freigabe. Vorher speichern, damit Tim den aktuellen Stand sieht."}),e.jsxs("button",{onClick:()=>{confirm("Test-Vorschau an Tim senden? (Gespeicherten Stand — vorher speichern.)")&&y.mutate({id:d.id})},disabled:y.isPending,className:"text-xs px-3 py-1.5 rounded-lg bg-blue-600 text-white font-semibold inline-flex items-center gap-1.5",children:[y.isPending?e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"}):"👀"," Test-Vorschau an Tim"]})]}),d?.id&&u&&e.jsxs("div",{className:"rounded-lg border border-emerald-500/40 bg-emerald-500/5 p-3 space-y-2",children:[e.jsx("div",{className:"text-xs font-bold text-emerald-600",children:"📄 Konzept-Freigabe durch den Inhaber"}),R?.status==="approved"?e.jsxs("div",{className:"text-xs text-emerald-600 font-semibold",children:["✅ Vom Inhaber freigegeben am ",new Date(R.decidedAt??Date.now()).toLocaleDateString("de-DE")," — Aufgaben können generiert werden."]}):R?.status==="changes"?e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs text-amber-600 font-semibold",children:"✏️ Inhaber wünscht Änderungen:"}),R.message&&e.jsxs("div",{className:"text-xs text-foreground rounded-md bg-muted/50 px-2.5 py-2",children:["„",R.message,'"']}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Konzept anpassen, speichern und unten erneut senden."})]}):R?.sentAt?e.jsxs("div",{className:"text-xs text-amber-600 font-semibold",children:["⏳ Gesendet an ",R.sentTo," — wartet auf Antwort. Bei Freigabe/Änderung bekommt ihr eine E-Mail."]}):e.jsx("div",{className:"text-[11px] text-muted-foreground",children:'Der Inhaber bekommt eine dunkle Konzept-Seite (Angebot, Zeitplan, was das Studio beisteuert) mit „Passt, freigeben" / „Änderungswünsche". Ohne seine Freigabe entstehen keine Aufgaben. Voraussetzung: Tims interne Freigabe (Video-Tab).'}),R?.status!=="approved"&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("input",{value:X,onChange:t=>be(t.target.value),placeholder:"[email protected]",className:"flex-1 min-w-[180px] h-8 rounded-md border border-border bg-background px-2 text-sm text-foreground"}),e.jsxs("button",{onClick:()=>
34{if(!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(X.trim())){l.error("Bitte gültige Inhaber-E-Mail eintragen.");return}if(!u&&!U?.approvedAt){l.error("Erst Tims interne Freigabe (Video-Tab) — dann ans Studio senden.");return}confirm(`Konzept-Link an ${X.trim()} senden?
35
36Ungespeicherte Änderungen bitte vorher speichern — der Inhaber sieht den gespeicherten Stand.`)&&S.mutate({id:d.id,email:X.trim()})},disabled:S.isPending,className:"text-xs px-3 py-1.5 rounded-lg bg-emerald-600 text-white font-semibold inline-flex items-center gap-1.5",children:[S.isPending?e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"}):"✉️"," ",R?.sentAt?"Erneut senden":"Per E-Mail zur Freigabe senden"]})]})]})]}),Q==="auswertung"&&e.jsx("div",{className:"space-y-3",children:M.isLoading?e.jsx("div",{className:"py-6 text-center text-muted-foreground",children:e.jsx(ce,{className:"w-4 h-4 animate-spin inline"})}):M.data?e.jsxs(e.Fragment,{children:[M.data.warn&&e.jsx("div",{className:"text-xs rounded-lg border border-red-500/40 bg-red-500/10 text-red-500 px-3 py-2 font-semibold",children:M.data.warn}),e.jsx("div",{className:"grid grid-cols-4 gap-2",children:[["Leads",M.data.totals.leads,"text-foreground"],["Termine",M.data.totals.appointments,"text-blue-500"],["Verträge",M.data.totals.contracts,"text-emerald-600"],["Verloren",M.data.totals.badLeads,"text-red-500"]].map(([t,n,c])=>e.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-2.5 text-center",children:[e.jsx("div",{className:`text-xl font-black ${c}`,children:n}),e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-semibold",children:t})]},t))}),e.jsx("div",{className:"rounded-lg border border-border overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-muted/60 text-muted-foreground",children:[e.jsx("th",{className:"text-left px-2.5 py-1.5 font-semibold",children:"Variante (utm_content / Instant-Form)"}),e.jsx("th",{className:"px-2 py-1.5 font-semibold",children:"Leads"}),e.jsx("th",{className:"px-2 py-1.5 font-semibold",children:"Termine"}),e.jsx("th",{className:"px-2 py-1.5 font-semibold",children:"Verträge"}),e.jsx("th",{className:"px-2 py-1.5 font-semibold",children:"Verloren"})]})}),e.jsxs("tbody",{children:[M.data.variants.map((t,n)=>e.jsxs("tr",{className:"border-t border-border text-foreground",children:[e.jsx("td",{className:"px-2.5 py-1.5 truncate max-w-[220px]",children:t.variant}),e.jsx("td",{className:"px-2 py-1.5 text-center",children:t.leads}),e.jsx("td",{className:"px-2 py-1.5 text-center",children:t.appointments}),e.jsx("td",{className:"px-2 py-1.5 text-center font-bold text-emerald-600",children:t.contracts}),e.jsx("td",{className:"px-2 py-1.5 text-center text-red-500",children:t.badLeads})]},n)),!M.data.variants.length&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-2.5 py-3 text-center text-muted-foreground",children:"Noch keine Leads im Kampagnen-Zeitraum. Varianten entstehen über UTM-Parameter (utm_content) bzw. Instant-Form-Namen in den Ads."})})]})]})}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Zeitraum: Kampagnenstart bis Ende + 7 Tage Nachlauf · Studios der Kampagne · Termine = Status Termin/Abschluss · Verloren = verloren/kein Interesse (Lead-Qualität vom Vertrieb)."}),e.jsxs("button",{onClick:()=>Ne.mutate({id:d.id}),disabled:Ne.isPending,className:"text-xs px-3 py-2 rounded-lg bg-violet-500/15 border border-violet-500/50 text-violet-500 font-semibold inline-flex items-center gap-1.5",children:[Ne.isPending?e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"}):"✨"," KI-Fazit + Empfehlungen holen"]}),te&&e.jsxs("div",{className:"rounded-lg border border-violet-500/40 bg-violet-500/5 p-3 space-y-1.5",children:[e.jsx("div",{className:"text-xs font-bold text-violet-500",children:"✨ KI-Fazit"}),e.jsx("p",{className:"text-xs text-foreground",children:te.fazit}),(te.empfehlungen??[]).map((t,n)=>e.jsxs("p",{className:"text-xs text-foreground",children:["→ ",t]},n))]})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keine Daten."})}),Q==="todos"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:oe,children:'Aufgaben dieser Kampagne (werden per „Aufgaben generieren" verteilt)'}),e.jsx("button",{onClick:()=>{const t=Ie();if(!t.length){l.error("Keine To-dos.");return}confirm("Diese Liste als Standard-Vorlage für ALLE neuen Kampagnen speichern?")&&a.mutate({items:t})},className:"text-[10px] text-muted-foreground hover:text-primary border border-border rounded-md px-2 py-1",children:"Als Standard-Vorlage speichern"})]}),e.jsxs("div",{className:"space-y-1.5",children:[ie.map((t,n)=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{value:t.title,onChange:c=>ze(n,{title:c.target.value}),placeholder:"z.B. Reel produzieren",className:"flex-1 h-8 rounded-md border border-border bg-background px-2 text-sm text-foreground"}),e.jsx("input",{type:"number",value:t.offsetDays,onChange:c=>ze(n,{offsetDays:Number(c.target.value)}),className:"w-16 h-8 rounded-md border border-border bg-background px-1.5 text-sm text-foreground",title:"Tage vor(-) / nach(+) Basis"}),e.jsx("button",{onClick:()=>ze(n,{fromEnd:!t.fromEnd}),className:`text-[10px] w-14 h-8 rounded-md border ${t.fromEnd?"border-red-500/50 text-red-500 bg-red-500/5":"border-border text-muted-foreground"}`,title:"Basis umschalten: Tage relativ zum Start oder zum Ende der Kampagne",children:t.fromEnd?"z. Ende":"z. Start"}),e.jsx("select",{value:t.priority,onChange:c=>ze(n,{priority:c.target.value}),className:"h-8 rounded-md border border-border bg-background px-1 text-xs text-foreground",children:ot.map(c=>e.jsx("option",{value:c.v,children:c.l},c.v))}),e.jsx("button",{onClick:()=>ue(ie.filter((c,E)=>E!==n)),className:"text-red-500 px-1",children:e.jsx(ye,{className:"w-3.5 h-3.5"})})]},n)),e.jsxs("button",{onClick:()=>ue([...ie,{title:"",offsetDays:0,priority:"medium"}]),className:"text-xs text-primary inline-flex items-center gap-1",children:[e.jsx(Me,{className:"w-3.5 h-3.5"})," To-do hinzufügen"]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:'„Tage z. Start" = Tage vor (−) oder nach (+) dem Start. Beim Generieren entsteht pro To-do eine Aufgabe mit Studio-Checkliste. Neue Kampagnen starten mit deiner Standard-Vorlage.'})]}),Q==="mails"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:oe,children:"E-Mail-Plan — wann geht welche Mail raus?"}),e.jsxs("div",{className:"space-y-1.5",children:[ne.map((t,n)=>e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("input",{type:"date",value:t.date,onChange:c=>Te(n,{date:c.target.value}),className:"h-8 rounded-md border border-border bg-background px-1.5 text-xs text-foreground"}),e.jsx("input",{type:"time",value:t.time,onChange:c=>Te(n,{time:c.target.value}),className:"h-8 w-20 rounded-md border border-border bg-background px-1.5 text-xs text-foreground"}),e.jsx("input",{value:t.subject,onChange:c=>Te(n,{subject:c.target.value}),placeholder:"Betreff",className:"flex-1 min-w-[140px] h-8 rounded-md border border-border bg-background px-2 text-sm text-foreground"}
36),e.jsx("input",{value:t.audience,onChange:c=>Te(n,{audience:c.target.value}),placeholder:"Zielgruppe",className:"w-32 h-8 rounded-md border border-border bg-background px-2 text-xs text-foreground"}),e.jsxs("select",{value:t.status,onChange:c=>Te(n,{status:c.target.value}),className:"h-8 rounded-md border border-border bg-background px-1 text-xs text-foreground",children:[e.jsx("option",{value:"offen",children:"offen"}),e.jsx("option",{value:"geplant",children:"geplant ✓"}),e.jsx("option",{value:"gesendet",children:"gesendet"})]}),e.jsx("button",{onClick:()=>ge(ne.filter((c,E)=>E!==n)),className:"text-red-500 px-1",children:e.jsx(ye,{className:"w-3.5 h-3.5"})})]},n)),e.jsxs("button",{onClick:()=>ge([...ne,{date:"",time:"10:00",subject:"",audience:"Ehemalige + Leads",status:"offen"}]),className:"text-xs text-primary inline-flex items-center gap-1",children:[e.jsx(Me,{className:"w-3.5 h-3.5"})," Mail hinzufügen"]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:'Der Plan ist die Übersicht für dich + die Kollegin. Die Mails selbst legt ihr wie gewohnt als Newsletter-Kampagne beim Studio an (Datum/Uhrzeit aus dieser Liste) und stellt hier den Status auf „geplant ✓".'})]}),Q==="video"&&e.jsxs("div",{className:"space-y-3",children:[f.sentAt&&e.jsxs("div",{className:"text-[11px] rounded-lg border border-emerald-500/40 bg-emerald-500/10 text-emerald-600 px-3 py-2",children:["✓ Gesendet am ",new Date(f.sentAt).toLocaleDateString("de-DE")," — Stand unten. Erneut senden erzeugt neue Aufgaben."]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:oe,children:"Deadline für die Studios"}),e.jsx("input",{type:"date",value:f.deadline,onChange:t=>ae({...f,deadline:t.target.value}),className:Pe})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:oe,children:"Worum geht's (steht oben im Briefing ans Studio)"}),e.jsx("textarea",{value:f.intro,onChange:t=>ae({...f,intro:t.target.value}),rows:2,className:we,placeholder:"Leer = Angebot aus dem Briefing"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:oe,children:"Shotliste (eine Zeile = ein Clip — Standard-Struktur, bei Bedarf anpassen)"}),e.jsx("textarea",{value:f.shots,onChange:t=>ae({...f,shots:t.target.value}),rows:6,className:we})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:oe,children:"Formatregeln"}),e.jsx("textarea",{value:f.rules,onChange:t=>ae({...f,rules:t.target.value}),rows:2,className:we})]}),e.jsx("button",{type:"button",onClick:s,className:"text-sm px-4 py-2 rounded-lg border border-border text-foreground font-semibold inline-flex items-center gap-1.5 hover:border-primary/50",children:"⬇ Video-Briefing als PDF (3 Varianten)"}),d?.id&&e.jsxs("div",{className:`rounded-lg border px-3 py-2 text-xs flex items-center justify-between gap-2 flex-wrap ${U?.approvedAt?"border-emerald-500/40 bg-emerald-500/10 text-emerald-600":"border-amber-500/40 bg-amber-500/10 text-amber-600"}`,children:[e.jsx("span",{className:"font-semibold",children:U?.approvedAt?`✓ Von Tim freigegeben (${new Date(U.approvedAt).toLocaleDateString("de-DE")})`:U?.requestedAt?"⏳ Wartet auf Tims Freigabe — er hat eine E-Mail bekommen":"🛡 Noch nicht freigegeben — vor dem Senden Freigabe anfordern"}),!U?.approvedAt&&(u?e.jsx("button",{onClick:()=>h.mutate({id:d.id}),disabled:h.isPending,className:"text-xs px-2.5 py-1 rounded-md bg-emerald-600 text-white font-semibold",children:h.isPending?"…":"✓ Jetzt freigeben"}):e.jsx("button",{onClick:()=>j.mutate({id:d.id}),disabled:j.isPending||!!U?.requestedAt,className:"text-xs px-2.5 py-1 rounded-md border border-amber-500/60 text-amber-600 font-semibold",children:j.isPending?"…":U?.requestedAt?"Angefordert":"Freigabe von Tim anfordern"}))]}),d?.id?e.jsxs("button",{onClick:()=>{if(!u&&!U?.approvedAt){l.error("Noch nicht von Tim freigegeben — erst Freigabe anfordern.");return}confirm(`Video-Briefing an ${W?"ALLE aktiven Studios":`${_.length} Studio(s)`} senden?
37
38Jedes Studio bekommt eine Aufgabe + E-Mail (und WhatsApp, falls eingerichtet). Nicht gespeicherte Änderungen bitte vorher speichern.`)&&g.mutate({id:d.id})},disabled:g.isPending||!u&&!U?.approvedAt,className:`text-xs px-3 py-2 rounded-lg font-semibold inline-flex items-center gap-1.5 ${!u&&!U?.approvedAt?"bg-muted text-muted-foreground cursor-not-allowed":"bg-violet-600 text-white"}`,children:[g.isPending?e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"}):"🎬"," Video-Briefing an Studios senden"]}):e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Kampagne zuer
38st speichern — danach kannst du das Video-Briefing hier senden."}),!!D.data?.length&&e.jsxs("div",{className:"rounded-lg border border-border p-2.5 space-y-1",children:[e.jsx("div",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wide",children:"Stand pro Studio"}),D.data.map(t=>e.jsxs("div",{className:"flex items-center justify-between text-xs text-foreground",children:[e.jsx("span",{children:t.name}),e.jsx("span",{className:t.status==="done"?"text-emerald-600 font-semibold":"text-muted-foreground",children:t.status==="done"?"✓ erledigt":t.status==="in_progress"?"in Arbeit":"offen"})]},t.brandId))]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border sticky bottom-0 bg-card",children:[e.jsx("button",{onClick:$,className:"text-sm px-3 py-1.5 rounded-lg border border-border text-foreground",children:"Abbrechen"}),e.jsxs("button",{onClick:_e,disabled:P,className:"text-sm px-4 py-1.5 rounded-lg bg-primary text-primary-foreground font-medium inline-flex items-center gap-1.5",children:[P?e.jsx(ce,{className:"w-4 h-4 animate-spin"}):e.jsx(rt,{className:"w-4 h-4"})," Speichern"]})]})]})})}function lt({brand:d,events:C,saving:O,onClose:N,onSave:$}){const[P,A]=i.useState(C?.length?C.map(v=>({...v})):[{date:"",title:""}]),B=(v,K)=>A(P.map((T,F)=>F===v?{...T,...K}:T));return e.jsx("div",{className:"fixed inset-0 z-[110] bg-black/60 flex items-center justify-center p-4",onClick:N,children:e.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-md",onClick:v=>v.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border",children:[e.jsxs("h3",{className:"font-semibold text-foreground",children:["🏷 Anlässe · ",d.studioName??d.name]}),e.jsx("button",{onClick:N,className:"text-muted-foreground hover:text-foreground",children:e.jsx(ye,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-5 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Eröffnungen, Jubiläen, Umbauten, Kursstarts — erscheinen als Marker im Jahresplan. Liegt ein Anlass näher als 8 Wochen ohne Kampagne, mahnt der Plan. Der KI-Berater richtet Empfehlungen automatisch darauf aus."}),P.map((v,K)=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"date",value:v.date,onChange:T=>B(K,{date:T.target.value}),className:"h-8 rounded-md border border-border bg-background px-1.5 text-xs text-foreground"}),e.jsx("input",{value:v.title,onChange:T=>B(K,{title:T.target.value}),placeholder:"z.B. Eröffnung neuer Bereich",className:"flex-1 h-8 rounded-md border border-border bg-background px-2 text-sm text-foreground"}),e.jsx("button",{onClick:()=>A(P.filter((T,F)=>F!==K)),className:"text-red-500 px-1",children:e.jsx(ye,{className:"w-3.5 h-3.5"})})]},K)),e.jsxs("button",{onClick:()=>A([...P,{date:"",title:""}]),className:"text-xs text-primary inline-flex items-center gap-1",children:[e.jsx(Me,{className:"w-3.5 h-3.5"})," Anlass hinzufügen"]})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border",children:[e.jsx("button",{onClick:N,className:"text-sm px-3 py-1.5 rounded-lg border border-border text-foreground",children:"Abbrechen"}),e.jsx("button",{onClick:()=>$(P.filter(v=>v.date&&v.title.trim()).map(v=>({date:v.date,title:v.title.trim()}))),disabled:O,className:"text-sm px-4 py-1.5 rounded-lg bg-primary text-primary-foreground font-medium",children:"Speichern"})]})]})})}const ct=d=>new Promise((C,O)=>{const N=new FileReader;N.onerror=()=>O(new Error("read")),N.onloadend=()=>C(String(N.result)),N.readAsDataURL(d)});function Re({onText:d,title:C}){const[O,N]=i.useState(!1),[$,P]=i.useState(!1),A=i.useRef(null),B=i.useRef([]),v=b.campaignPlanner.transcribe.useMutation(),K=async()=>{try{const F=await navigator.mediaDevices.getUserMedia({audio:!0}),V=new MediaRecorder(F);B.current=[],V.ondataavailable=J=>{J.data.size&&B.current.push(J.data)},V.onstop=async()=>{F.getTracks().forEach(I=>I.stop());const J=new Blob(B.current,{type:V.mimeType||"audio/webm"});P(!0);try{const I=await ct(J),q=await v.mutateAsync({audioBase64:I,mimeType:J.type||"audio/webm"});q?.transcript?d(q.transcript):l.error("Nichts erkannt — nochmal?")}catch(I){l.error(I?.message??"Transkription fehlgeschlagen")}finally{P(!1)}},V.start(),A.current=V,N(!0)}catch{l.error("Kein Mikrofon-Zugriff")}},T=()=>{try{A.current?.stop()}catch{}N(!1)};return e.jsx("button",{type:"button",onClick:O?T:K,disabled:$,title:C??"Per Sprache diktieren",className:`shrink-0 h-9 w-9 rounded-md border inline-flex items-center justify-center ${O?"border-red-500 bg-red-500/10 text-red-500 animate-pulse":"border-border text-muted-foreground hover:text-foreground"}`,children:$?e.jsx(ce,{className:"w-4 h-4 animate-spin"}):O?"⏹":"🎤"})}function ut({brands:d,categories:C,onClose:O,onUse:N}){const[$,P]=i.useState(""),[A,B]=i.useState(""),[v,K]=i.useState(0),[T,F]=i.useState(""),[V,J]=i.useState(""),[I,q]=i.useState(""),[L,ve]=i.useState(""),[m,Se]=i.useState(""),[W,he]=i.useState(""),[_,xe]=i.useState("auto"),[pe,Ae]=i.useState(!0),[ie,ue]=i.useState(!0),[Q,ke]=i.useState([]),[k,p]=i.useState({}),[G,Y]=i.useState({}),[z,de]=i.useState(null),U=b.campaignPlanner.refineIdea.useMutation({onError:r=>{de(null),l.error(r?.message??"KI-Fehler")}}),fe=r=>{const x=(k[r]??"").trim();if(!x){l.error("Kurz reinschreiben, was anders sein soll.");return}
38de(r),U.mutate({brandId:Number($),recommendation:H[r],instruction:x,category:A||void 0,membershipFocus:W||void 0,periodFrom:L||void 0,periodTo:m||void 0},{onSuccess:w=>{Y(g=>({...g,[r]:H[r]})),X(g=>(g??[]).map((D,s)=>s===r?w.recommendation:D)),p(g=>({...g,[r]:""})),de(null),l.success("Karte neu gerechnet.")}})},R=()=>{if(!L||!m)return 0;const r=(new Date(m).getTime()-new Date(L).getTime())/864e5;return r>=35?2:r>=21?1:0},[H,X]=i.useState(null),[be,ne]=i.useState("3"),[ge,le]=i.useState([]),ee=b.campaignPlanner.aiIdeas.useMutation({onSuccess:r=>{X(r.recommendations??[]),le(r.autoCompetitors??[]),ke(r.midDates??[])},onError:r=>l.error(r?.message??"KI-Fehler")}),f=r=>{P(r);const x=C?.[r];x&&B(x)},ae=()=>{if(!$){l.error("Bitte ein Studio wählen.");return}if(!A){l.error("Bitte die Studio-Kategorie wählen (wird gespeichert).");return}X(null),ee.mutate({brandId:Number($),category:A,level:v||void 0,websiteUrl:T.trim()||void 0,competitors:V.trim()||void 0,goal:I.trim()||void 0,periodFrom:L||void 0,periodTo:m||void 0,membershipFocus:W||void 0,midCloseouts:_==="auto"?R():Number(_),withReferral:pe,withComeback:ie})},Z="w-full h-9 rounded-md border border-border bg-background px-2.5 text-sm text-foreground",je=r=>r===3?"💥 Atombombe":r===2?"Sparangebot":"Ohne Preisfokus",Ce=()=>{if(!H||!H.length)return;const r=Math.min(Number(be)||3,H.length),x=H.slice(0,r),w=d.find(j=>String(j.id)===$),g=w?.studioName??w?.name??"Studio",D=j=>String(j??"").replace(/[&<>]/g,h=>({"&":"&amp;","<":"&lt;",">":"&gt;"})[h]),s=L||m?`${L?new Date(L).toLocaleDateString("de-DE"):""}${m?" – "+new Date(m).toLocaleDateString("de-DE"):""}`:"",a=x.map((j,h)=>{const y=j.offer?.calc,S=y?`
39        <div class="prices">
40          <div class="prow"><span>Regulär</span><b class="reg">${D(y.regularTotal??"—")}</b></div>
41          <div class="prow"><span>Aktionspreis</span><b class="act">${D(y.promoTotal??"—")}</b></div>
42          <div class="prow save"><span>Deine Ersparnis</span><b>${D(y.savings??"—")}${y.savingsPct?" · "+D(y.savingsPct):""}</b></div>
43        </div>`:"",M=j.offer?`<div class="offer"><b>${D(j.offer.headline??"")}</b>${j.offer.details?`<span>${D(j.offer.details)}</span>`:""}</div>`:"";return`<div class="card">
44        <div class=" choose"><span class="box"></span> Angebot ${h+1}</div>
45        <h2>${D(j.name)}</h2>
46        ${M}
47        ${S}
48      </div>`}).join(""),o=`<!doctype html><html lang="de"><head><meta charset="utf-8"><title>Kampagnen-Angebote · ${D(g)}</title>
49      <style>
50        @page{size:A4 portrait;margin:15mm} *{box-sizing:border-box;margin:0;padding:0;font-family:'Segoe UI',Arial,sans-serif;color:#14161c;-webkit-print-color-adjust:exact;print-color-adjust:exact}
51        body{padding:0}
52        .head{border-bottom:3px solid #14161c;padding-bottom:12px;margin-bottom:6px}
53        .head .k{font-size:10px;letter-spacing:2.5px;text-transform:uppercase;color:#7c3aed;font-weight:800}
54        .head h1{font-size:23px;font-weight:800;margin-top:5px}
55        .head .m{font-size:12px;color:#6b7280;margin-top:5px}
56        .ask{background:#fdf6e3;border:1px solid #e9d9a6;border-radius:9px;padding:9px 13px;margin:14px 0;font-size:12px;color:#6b5518}
57        .ask b{color:#4a3d0f}
58        .cards.n1 .card{min-height:0} .cards{display:flex;flex-direction:column;gap:${r===1?"0":r===2?"16px":"13px"}}
59        .card{border:1.5px solid #e2ded6;border-radius:13px;padding:${r===1?"24px":r===2?"18px":"15px"};page-break-inside:avoid}
60        .choose{display:flex;align-items:center;gap:8px;font-size:11px;font-weight:800;letter-spacing:1px;text-transform:uppercase;color:#7c3aed}
61        .box{width:15px;height:15px;border:2px solid #7c3aed;border-radius:4px;display:inline-block}
62        .card h2{font-size:${r===1?"24px":r===2?"19px":"17px"};font-weight:800;margin-top:8px}
63        .offer{background:#f5f3ee;border-radius:9px;padding:11px 13px;margin-top:11px;font-size:12.5px;line-height:1.5}
64        .offer b{font-size:13.5px} .offer span{display:block;color:#5b6470;margin-top:5px;font-size:11.5px}
65        .prices{margin-top:13px;border-top:1px solid #eee}
66        .prow{display:flex;justify-content:space-between;align-items:center;padding:${r===1?"11px 2px":"8px 2px"};border-bottom:1px solid #f0ece3;font-size:${r===1?"15px":"13px"}}
67        .prow span{color:#556069} .prow b{font-weight:800}
68        .prow .reg{color:#8a94a0;text-decoration:line-through;font-weight:600}
69        .prow .act{color:#14161c;font-size:${r===1?"20px":"16px"}}
70        .prow.save{border-bottom:none;background:#eafaf0;border-radius:8px;padding-left:10px;padding-right:10px;margin-top:4px}
71        .prow.save span{color:#16794a;font-weight:700} .prow.save b{color:#16a34a;font-size:${r===1?"18px":"15px"}}
72        .sign{margin-top:22px;border:1px dashed #cfc9bb;border-radius:10px;padding:14px 16px;font-size:12px;color:#33424e}
73        .sign .row{display:flex;justify-content:space-between;margin-top:14px;gap:20px}
74        .sign .fld{flex:1;border-top:1px solid #b9b3a5;padding-top:4px;font-size:10px;color:#8a94a0;text-align:center}
75        .foot{margin-top:16px;border-top:1px solid #e2ded6;padding-top:8px;font-size:9px;color:#9ca3af}
76      </style></head><body>
77      <div class="head"><div class="k">Angebots-Auswahl · MoreMembers</div><h1>${D(g)}${name?" — "+D(name):""}</h1><div class="m">${s?"Aktionszeitraum: "+D(s):"Aktionszeitraum: noch offen"}${A?" · "+D(A):""}</div></div>
78      <div class="ask">Bitte <b>ein Angebot auswählen</b> und unten freigeben. Die Umsetzung &amp; Kommunikation (Anzeigen, Texte) übernehmen wir danach.</div>
79      <div class="cards n${r}">${a}</div>
80      <div class="sign"><b>Freigabe durch den Inhaber</b><br>Ich wähle <b>Angebot Nr. ___</b> und gebe es zur Umsetzung frei.
81        <div class="row"><div class="fld">Ort, Datum</div><div class="fld">Unterschrift</div></div>
82      </div>
83      <div class="foot">MoreMembers · [email protected]</div>
84      </body></html>`,u=window.open("","_blank");if(!u){l.error("Bitte Popups erlauben, dann klappt der PDF-Export.");return}u.document.write(o),u.document.close(),u.focus(),setTimeout(()=>{try{u.print()}catch{}},400)};return e.jsx("div",{className:"fixed inset-0 z-[100] bg-black/60 flex items-center justify-center p-4",onClick:O,children:e.jsxs("div",{className:"bg-card border border-border rounded-xl w-full max-w-4xl max-h-[92vh] overflow-auto",onClick:r=>r.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border sticky top-0 bg-card z-10",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"✨ Kampagnen-Ideen (KI)"}),e.jsx("button",{onClick:O,className:"text-muted-foreground hover:text-foreground",children:e.jsx(ye,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"grid md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Studio *"}),e.jsxs("select",{value:$,onChange:r=>f(r.target.value),className:Z,children:[e.jsx("option",{value:"",children:"— wählen —"}),d.map(r=>e.jsxs("option",{value:String(r.id),children:[r.studioName??r.name,r.isActive===!1?" — 🚧 Onboarding":""]},r.id))]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Kategorie * (wird am Studio gespeichert)"}),e.jsxs("select",{value:A,onChange:r=>B(r.target.value),className:Z,children:[e.jsx("option",{value:"",children:"— wählen —"}),nt.map(r=>e.jsx("option",{value:r.v,children:r.l},r.v))]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Angebots-Stufe"}),e.jsxs("select",{value:String(v),onChange:r=>K(Number(r.target.value)),className:Z,children:[e.jsx("option",{value:"0",children:"3er-Mix (je Stufe eine Empfehlung)"}),at.map(r=>e.jsxs("option",{value:String(r.v),children:[r.l," — ",r.d]},r.v))]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Bestehende Website (optional — wird gelesen)"}),e.jsx("input",{value:T,onChange:r=>F(r.target.value),className:Z,placeholder:"https://studio-xyz.de"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Wettbewerber"}),e.jsxs("div",{className:"h-9 flex items-center rounded-md border border-dashed border-border bg-muted/30 px-2.5 text-[11px] text-muted-foreground",children:["🔎 Wird ",e.jsx("b",{className:"text-foreground mx-1",children:"automatisch"}),' gefunden — im Ergebnis + „Vergleich" je Karte.']})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Ziel / Anlass / Infos (optional — auch per Sprache 🎤)"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{value:I,onChange:r=>q(r.target.value),className:Z,placeholder:"z.B. Vorverkauf neuer Bereich, Eröffnung 15.09."}),e.jsx(Re,{title:"Infos einsprechen",onText:r=>q(x=>(x?x+" ":"")+r)})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Angebots-Zeitraum (von – bis)"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{type:"date",value:L,onChange:r=>ve(r.target.value),className:Z}),e.jsx("input",{type:"date",value:m,onChange:r=>Se(r.target.value),className:Z})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Mitgliedschafts-Fokus (worauf zielt das Angebot?)"}),e.jsxs("select",{value:W,onChange:r=>he(r.target.value),className:Z,children:[e.jsx("option",{value:"",children:"— egal / KI entscheidet —"}),e.jsx("option",{value:"flex",children:"Flex-Mitgliedschaft (mtl. kündbar)"}),e.jsx("option",{value:"12",children:"12-Monats-Abo"}),e.jsx("option",{value:"24",children:"24-Monats-Abo"}),e.jsx("option",{value:"kurs",children:"Kurs / Paket (z.B. 6-Wochen-Kurs, 10er-Karte)"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:'Das Angebot bezieht sich dann auf diese Laufzeit — z.B. beim 24er: „6 Monate für 9,90 €, danach regulär" oder „3 Monate gratis on top".'})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Zwischen-Closeouts (Termine verteilt das System)"}
84),e.jsxs("select",{value:_,onChange:r=>xe(r.target.value),className:Z,children:[e.jsxs("option",{value:"auto",children:["Auto (",R()," bei diesem Zeitraum)"]}),e.jsx("option",{value:"0",children:"0 — keine"}),e.jsx("option",{value:"1",children:"1"}),e.jsx("option",{value:"2",children:"2"}),e.jsx("option",{value:"3",children:"3"})]})]}),e.jsxs("div",{className:"space-y-1.5 pt-5",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs text-foreground cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:pe,onChange:r=>Ae(r.target.checked),className:"w-3.5 h-3.5"}),"+ Weiterempfehlungs-Baustein (Bestand wirbt — Prämie schlägt die KI vor)"]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-foreground cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:ie,onChange:r=>ue(r.target.checked),className:"w-3.5 h-3.5"}),"+ Ehemaligen-Welle (gleiches Angebot, Comeback-Ansprache per Mail)"]})]})]}),e.jsxs("button",{onClick:ae,disabled:ee.isPending,className:"text-sm px-4 py-2 rounded-lg bg-violet-600 text-white font-semibold inline-flex items-center gap-1.5",children:[ee.isPending?e.jsx(ce,{className:"w-4 h-4 animate-spin"}):"✨"," ",ee.isPending?"KI denkt nach (bis ~30 Sek.)…":"3 Empfehlungen holen"]}),H&&H.length>0&&e.jsxs("span",{className:"ml-2 inline-flex items-center gap-2",children:[e.jsxs("select",{value:be,onChange:r=>ne(r.target.value),title:"Wie viele Angebote ins PDF?",className:"h-9 rounded-md border border-border bg-background text-foreground text-sm px-2",children:[e.jsx("option",{value:"3",children:"alle 3 Angebote"}),e.jsx("option",{value:"2",children:"nur Top 2"}),e.jsx("option",{value:"1",children:"nur Top 1"})]}),e.jsx("button",{onClick:Ce,className:"text-sm px-4 py-2 rounded-lg border border-border text-foreground font-semibold inline-flex items-center gap-1.5 hover:border-primary/50",children:"⬇ Als PDF (für Inhaber)"})]}),H&&e.jsx("div",{className:"grid md:grid-cols-3 gap-3 pt-1",children:H.map((r,x)=>e.jsxs("div",{className:`rounded-xl border p-3 space-y-2 flex flex-col ${x===0?"border-red-500/50":"border-border"}`,children:[e.jsxs("div",{className:"text-[10px] font-bold uppercase tracking-wide text-muted-foreground",children:["Empfehlung ",x+1," · ",je(Number(r.level)||0)]}),e.jsx("div",{className:"text-sm font-bold text-foreground leading-tight",children:r.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:r.idea}),r.offer&&e.jsxs("div",{className:"rounded-lg bg-muted/40 border border-border px-2.5 py-2 text-xs text-foreground",children:[e.jsx("b",{children:r.offer.headline}),r.offer.details?e.jsx("span",{className:"block text-muted-foreground mt-0.5",children:r.offer.details}):null]}),r.offer?.calc&&e.jsxs("div",{className:"rounded-lg border border-border overflow-hidden text-[11px]",children:[e.jsxs("div",{className:"grid grid-cols-2 border-b border-border",children:[e.jsx("span",{className:"px-2 py-1 text-muted-foreground",children:"Regulär"}),e.jsx("span",{className:"px-2 py-1 text-right font-semibold text-foreground",children:r.offer.calc.regularTotal})]}),e.jsxs("div",{className:"grid grid-cols-2 border-b border-border",children:[e.jsx("span",{className:"px-2 py-1 text-muted-foreground",children:"Aktion"}),e.jsx("span",{className:"px-2 py-1 text-right font-semibold text-foreground",children:r.offer.calc.promoTotal})]}),e.jsxs("div",{className:"grid grid-cols-2 border-b border-border bg-emerald-500/10",children:[e.jsx("span",{className:"px-2 py-1 font-semibold text-emerald-600",children:"Ersparnis"}),e.jsxs("span",{className:"px-2 py-1 text-right font-bold text-emerald-600",children:[r.offer.calc.savings,r.offer.calc.savingsPct?` (${r.offer.calc.savingsPct})`:""]})]}),r.offer.calc.effectivePerMonth&&e.jsxs("div",{className:"grid grid-cols-2 border-b border-border",children:[e.jsx("span",{className:"px-2 py-1 text-muted-foreground",children:"Effektiv/Monat"}),e.jsx("span",{className:"px-2 py-1 text-right text-foreground",children:r.offer.calc.effectivePerMonth})]}),r.offer.calc.freebieValue&&r.offer.calc.freebieValue!=="—"&&e.jsxs("div",{className:"grid grid-cols-2 border-b border-border",children:[e.jsx("span",{className:"px-2 py-1 text-muted-foreground",children:"Gratis-Anteil (Warenwert)"}),e.jsx("span",{className:"px-2 py-1 text-right text-amber-600 font-semibold",children:r.offer.calc.freebieValue})]}),e.jsxs("div",{className:"px-2 py-1 flex items-center justify-between gap-1",children:[e.jsx("span",{className:"text-muted-foreground truncate",title:r.offer.calc.note,children:r.offer.calc.note}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-bold ${r.offer.calc.basis==="annahme"?"bg-red-500/15 text-red-500":r.offer.calc.basis==="website"?"bg-amber-500/15 text-amber-600":"bg-emerald-500/15 text-emerald-600"}`,children:r.offer.calc.basis==="annahme"?"⚠ Annahme — prüfen!":r.offer.calc.basis==="website"?"Quelle: Website":"Quelle: Tarife"})]})]}),e.jsxs("div",{className:"text-[11px] text-foreground",children:[e.jsx("b",{children:"Warum:"})," ",e.jsx("span",{className:"text-muted-foreground",children:r.reasoning})]}),e.jsxs("div",{className:"text-[11px] text-foreground",children:[e.jsx("b",{children:"Zielgruppe:"})," ",e.jsx("span",{className:"text-muted-foreground",children:r.audie
84nce})]}),r.funnel&&e.jsxs("div",{className:"text-[11px] text-foreground",children:[e.jsx("b",{children:"Werbeart (Funnel):"})," ",e.jsxs("span",{className:"text-muted-foreground",children:[r.funnel.type==="quiz"?"Quiz-Funnel":r.funnel.type==="instant_form"?"Instant-Formular":"Landingpage"," — ",r.funnel.why,r.funnel.testTip?` · Test: ${r.funnel.testTip}`:""]})]}),Array.isArray(r.hooks)&&r.hooks.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:r.hooks.slice(0,5).map((w,g)=>e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground border border-border",children:w},g))}),r.closeout&&e.jsxs("div",{className:"text-[11px] text-foreground",children:[e.jsx("b",{children:"Closeout:"})," ",e.jsxs("span",{className:"text-muted-foreground",children:[r.closeout.scarcity,Array.isArray(r.closeout.midCloseouts)&&r.closeout.midCloseouts.length?` · Zwischen: ${r.closeout.midCloseouts.join(" · ")}`:""]})]}),Array.isArray(r.closeoutMails)&&r.closeoutMails.length>0&&e.jsxs("div",{className:"text-[11px] rounded-md border border-red-500/30 bg-red-500/5 px-2 py-1.5 text-foreground",children:[e.jsx("b",{children:"✉️ Closeout-Mails:"}),e.jsx("ul",{className:"mt-0.5 space-y-0.5",children:r.closeoutMails.slice(0,5).map((w,g)=>e.jsxs("li",{className:"text-muted-foreground",children:["• ",w]},g))})]}),r.differentiation&&e.jsxs("div",{className:"text-[11px] text-foreground",children:[e.jsx("b",{children:"🔎 Vergleich zu anderen Studios:"})," ",e.jsx("span",{className:"text-muted-foreground",children:r.differentiation})]}),r.referral&&(r.referral.praemie||r.referral.mailSubject)&&e.jsxs("div",{className:"text-[11px] rounded-md border border-blue-500/30 bg-blue-500/5 px-2 py-1.5 text-foreground",children:[e.jsx("b",{children:"🤝 Weiterempfehlung (Bestand wirbt):"})," ",e.jsxs("span",{className:"text-muted-foreground",children:[r.referral.praemie,r.referral.mailSubject?` · Mail: „${r.referral.mailSubject}"`:""]})]}),r.comeback&&Array.isArray(r.comeback.subjects)&&r.comeback.subjects.length>0&&e.jsxs("div",{className:"text-[11px] rounded-md border border-amber-500/30 bg-amber-500/5 px-2 py-1.5 text-foreground",children:[e.jsx("b",{children:"↩ Ehemaligen-Welle — für ehemalige Mitglieder:"})," ",e.jsx("span",{className:"text-muted-foreground",children:r.comeback.subjects.join(" · ")})]}),e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsxs("div",{className:"flex items-start gap-1.5",children:[e.jsx("textarea",{value:k[x]??"",onChange:w=>p(g=>({...g,[x]:w.target.value})),rows:2,placeholder:'Was soll anders sein? z.B. "nur 2 Wochen gratis statt 4", "Preis 79 € statt 69 €" — oder per 🎤',className:"flex-1 rounded-md border border-border bg-background px-2 py-1.5 text-[11px] text-foreground resize-none"}),e.jsx(Re,{title:"Anpassung einsprechen",onText:w=>p(g=>({...g,[x]:(g[x]?g[x]+" ":"")+w}))})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>fe(x),disabled:z===x,className:"text-[11px] px-2.5 py-1.5 rounded-md border border-violet-500/50 text-violet-500 font-semibold inline-flex items-center gap-1",children:[z===x?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):"✨"," Neu rechnen"]}),G[x]&&e.jsx("button",{onClick:()=>{X(w=>(w??[]).map((g,D)=>D===x?G[x]:g)),Y(w=>{const g={...w};return delete g[x],g})},className:"text-[10px] text-muted-foreground underline",children:"← vorherige Version"})]})]}),e.jsx("div",{className:"pt-1 mt-auto",children:e.jsx("button",{onClick:()=>N(r,Number($),{periodFrom:L,periodTo:m,membershipFocus:W,midDates:Q,withReferral:pe,withComeback:ie}),className:"w-full text-xs px-3 py-2 rounded-lg bg-primary text-primary-foreground font-semibold",children:"Als Kampagne anlegen →"})})]},x))}),H&&ge.length>0&&e.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-2.5 space-y-1.5",children:[e.jsx("div",{className:"text-[11px] font-semibold text-foreground",children:"🔎 Wettbewerber im Umkreis (automatisch gefunden)"}),Object.entries(ge.reduce((r,x)=>((r[x.type||"Sonstige"]??=[]).push(x),r),{})).map(([r,x])=>e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[e.jsxs("span",{className:"font-semibold text-foreground",children:[r,":"]})," ",x.map((w,g)=>e.jsxs("span",{children:[g>0?" · ":"",e.jsx("a",{href:w.url,target:"_blank",rel:"noreferrer",className:"underline",children:w.name})," ",e.jsx("a",{href:w.adLibraryUrl,target:"_blank",rel:"noreferrer",className:"underline text-violet-500",children:"(Ads)"})]},g))]}
84,r)),e.jsx("div",{className:"text-[9.5px] text-muted-foreground/80",children:'„(Ads)" öffnet die öffentliche Meta-Werbebibliothek — dort siehst du, welche Aktionen die schalten. Die KI hat den Vergleich bereits in „Abgrenzung" jeder Karte eingebaut.'})]}),H&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Die KI schlägt vor — du entscheidest. Preise gegen die echten Tarife prüfen, dann anlegen. Nach dem Anlegen: Closeouts vervollständigen, Freigabe von Tim, dann Aufgaben generieren."})]})]})})}function mt({brands:d,onClose:C,onSaved:O}){const[N,$]=i.useState(""),[P,A]=i.useState(""),[B,v]=i.useState(""),[K,T]=i.useState(""),[F,V]=i.useState(!1),[J,I]=i.useState(""),q=b.campaignPlanner.quickOffer.useMutation({onSuccess:m=>{l.success(m?.assignedToLeonie?"Angebot gespeichert → Aufgabe an Leonie":"Angebot gespeichert (kein Marketing-Lead gefunden — Aufgabe unzugewiesen)"),O(),C()},onError:m=>l.error(m?.message??"Fehler")}),L=N&&P.trim().length>=2&&B.trim().length>=2&&!q.isPending,ve=()=>{L&&q.mutate({brandId:Number(N),name:P.trim(),offer:B.trim(),wunschGoLive:K?Fe(K):null,ownerApproved:F,ownerApprovalNote:F&&J.trim()?J.trim():void 0})};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:C,children:e.jsxs("div",{className:"bg-background rounded-2xl border border-border w-full max-w-md p-5 space-y-4",onClick:m=>m.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Schnelles Angebot"}),e.jsx("button",{onClick:C,className:"text-muted-foreground hover:text-foreground",children:e.jsx(ye,{className:"w-5 h-5"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Nur Studio + Angebot/Preis. Leonie arbeitet die Kampagne aus (Go-Live, Timeline, Assets)."}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Studio *"}),e.jsxs("select",{value:N,onChange:m=>$(m.target.value),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground",children:[e.jsx("option",{value:"",children:"— Studio wählen —"}),(d??[]).map(m=>e.jsx("option",{value:m.id,children:m.name},m.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Kampagnen-Name *"}),e.jsx("input",{value:P,onChange:m=>A(m.target.value),placeholder:"z. B. Herbst-Aktion",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Angebot / Preis *"}),e.jsx("textarea",{value:B,onChange:m=>v(m.target.value),rows:2,placeholder:"z. B. 3 Monate gratis bei 12 Monaten, 29,90 €/Monat",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Wunsch-Go-Live (optional)"}),e.jsx("input",{type:"date",value:K,onChange:m=>T(m.target.value),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground"})]}),e.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[e.jsx("input",{type:"checkbox",checked:F,onChange:m=>V(m.target.checked)}),"Wurde vom Inhaber bereits (mündlich) freigegeben"]}),F&&e.jsx("input",{value:J,onChange:m=>I(m.target.value),placeholder:"z. B. mündlich, Tom, 12.01.",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-xs text-foreground"}),!F&&e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Ohne Haken: Leonie holt die Freigabe des Inhabers noch ein."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[e.jsx("button",{onClick:C,className:"text-sm px-3 py-2 rounded-lg border border-border text-muted-foreground",children:"Abbrechen"}),e.jsx("button",{onClick:ve,disabled:!L,className:"text-sm px-4 py-2 rounded-lg bg-primary text-primary-foreground font-medium disabled:opacity-40",children:q.isPending?"Speichert…":"An Leonie übergeben"})]})]})})}function bt(){const d=b.useUtils(),{data:C=[],isLoading:O}=b.campaignPlanner.list.useQuery(void 0,{staleTime:3e4}),{data:N=[]}=b.brands.list.useQuery(void 0,{staleTime:5*6e4}),{data:$}=b.users.list.useQuery(void 0,{staleTime:5*6e4}),P=$??[],A=()=>
84d.campaignPlanner.list.invalidate(),B=b.campaignPlanner.create.useMutation({onSuccess:()=>{A(),l.success("Kampagne angelegt"),_(null),I(!1)},onError:s=>l.error(s?.message??"Fehler")}),v=b.campaignPlanner.update.useMutation({onSuccess:()=>{A(),l.success("Gespeichert"),_(null)},onError:s=>l.error(s?.message??"Fehler")}),K=b.campaignPlanner.remove.useMutation({onSuccess:()=>{A(),l.success("Gelöscht")},onError:s=>l.error(s?.message??"Fehler")}),T=b.campaignPlanner.generateTasks.useMutation({onSuccess:s=>{A(),V(null),l.success(`${s.created} Aufgabe(n) für ${s.studios} Studio(s) erstellt`)},onError:s=>l.error(s?.message??"Fehler")}),[F,V]=i.useState(null),[J,I]=i.useState(!1),[q,L]=i.useState(!1),[ve,m]=i.useState(!1),[Se,W]=i.useState(null),[he,_]=i.useState(null),[xe,pe]=i.useState("plan"),{data:Ae={}}=b.campaignPlanner.getCategories.useQuery(void 0,{staleTime:6e4}),{data:ie={}}=b.campaignPlanner.getEvents.useQuery(void 0,{staleTime:6e4}),[ue,Q]=i.useState(null),ke=b.campaignPlanner.setEvents.useMutation({onSuccess:()=>{d.campaignPlanner.getEvents.invalidate(),l.success("Anlässe gespeichert")},onError:s=>l.error(s?.message??"Fehler")}),k=s=>ie[String(s)]??[],p=s=>{const a=Date.now();for(const o of k(s)){const u=new Date(o.date+"T00:00:00").getTime();if(u<a||u-a>56*864e5)continue;if(!C.some(h=>{if(!(h.brandIds??[]).includes(s))return!1;const y=h.startDate!=null?Number(h.startDate):null;if(y==null)return!1;const S=h.endDate!=null?Number(h.endDate):y;return y<=u&&S+7*864e5>=u}))return`${o.title} (${new Date(u).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})}) ohne Kampagne!`}return null},G=s=>{if(!s?.length)return null;const a=C.find(o=>o.type==="onboarding"&&o.status!=="fertig"&&(o.brandIds??[]).some(u=>s.includes(u)));return a?a.name:null},Y=s=>N.find(a=>a.id===s)?.studioName??N.find(a=>a.id===s)?.name??`#${s}`,z=s=>$e.find(a=>a.v===s)??$e[1],de=s=>Oe.find(a=>a.v===s)?.l??s,{data:U}=b.campaigns.getConfig.useQuery({},{staleTime:6e4}),{data:fe=null}=b.campaignPlanner.getDefaultTodos.useQuery(void 0,{staleTime:6e4}),{data:R=null}=b.campaignPlanner.getDefaultVideoBriefing.useQuery(void 0,{staleTime:6e4}),{data:H={}}=b.campaignPlanner.progress.useQuery(void 0,{staleTime:3e4,enabled:xe==="plan"}),[X,be]=i.useState(0),ne=12,ge=new Date,le=s=>{const a=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),o=(a.getUTCDay()+6)%7;a.setUTCDate(a.getUTCDate()-o+3);const u=new Date(Date.UTC(a.getUTCFullYear(),0,4));return 1+Math.round(((a.getTime()-u.getTime())/864e5-3+(u.getUTCDay()+6)%7)/7)},ee=(()=>{const s=new Date(ge),a=(s.getDay()+6)%7;return s.setDate(s.getDate()-a+X),s.setHours(0,0,0,0),s})(),f=[];for(let s=0;s<ne;s++){const a=new Date(ee);a.setDate(ee.getDate()+s*7);const o=new Date(a);o.setDate(a.getDate()+7),f.push({label:`KW ${le(a)}`,sub:a.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"}),startMs:a.getTime(),endMs:o.getTime()-1,isMonthStart:a.getDate()<=7})}const ae=864e5,Z=U?.defaultCadenceDays??28,je=s=>{const a=s.campaignCadenceDays!=null?Number(s.campaignCadenceDays):Z,o=s.lastCampaignAt!=null?Number(s.lastCampaignAt):null;if(o==null)return{cls:"bg-muted text-muted-foreground",label:"neu"};const u=o+a*ae;return u<=Date.now()?{cls:"bg-red-500/15 text-red-500",label:`fällig (+${Math.floor((Date.now()-u)/ae)} T.)`}:u-Date.now()<=7*ae?{cls:"bg-amber-500/15 text-amber-600",label:"bald fällig"}:{cls:"bg-emerald-500/15 text-emerald-600",label:"OK"}},Ce=s=>{const a=(()=>{try{return s.onboardingData?JSON.parse(s.onboardingData):{}}catch{return{}}})();return!!(s.studioAddress||s.studioPhone||s.studioOpeningHours||s.onboardingHandedOffAt||["onboarding","setup","freigabe","performance","kampagne"].includes(s.lifecyclePhase)||a&&Object.values(a).some(o=>o&&String(o).trim()))},r=N.filter(s=>!s.deletedAt&&(s.isActive===1||s.isActive===!0||s.onboardingHandedOffAt||Ce(s))),x=(s,a)=>a==="onboarding"?"bg-violet-500/12 border-violet-500/50 text-violet-500":s==="aktiv"?"bg-emerald-500/12 border-emerald-500/50 text-emerald-500":s==="in_arbeit"?"bg-amber-500/12 border-amber-500/50 text-amber-600":s==="geplant"?"bg-blue-500/12 border-blue-500/50 text-blue-500":s==="fertig"?"bg-muted border-border text-muted-foreground line-through":"bg-muted border-border text-muted-foreground",w=(s,a)=>C.filter(o=>{if(!(s==null?!o.brandIds?.length:(o.brandIds??[]).includes(s)))return!1;const j=o.startDate!=null?Number(o.startDate):null;if(j==null)return!1;const h=o.endDate!=null?Number(o.endDate):j;return j<=a.endMs&&h>=a.startMs}),g=(s,a)=>{const o=G(s!=null?[s]:null);o&&!confirm(`⚠️ Für dieses Studio läuft das Onboarding „${o}" — die Startkampagne ist dort schon enthalten.
85
86Trotzdem eine separate Kampagne anlegen?`)||(W({brandIds:s!=null?[s]:[],startDate:a.startMs,status:"idee"}),I(!0))},D=({c:s})=>{const a=H[s.id];return e.jsxs("button",{onClick:()=>_(s),className:`block w-full text-left rounded-md border px-1.5 py-1 mb-1 text-[10px] font-semibold leading-tight ${x(s.status,s.type)}`,title:`${s.name} · ${z(s.status).l}`,children:[e.jsxs("span",{className:"block truncate",children:[s.type==="onboarding"?"🚀 ":s.briefing?.offer?"📝 ":"",s.name]}),e.jsx("span",{className:"block font-normal opacity-80",children:a?.total?`Aufgaben ${a.done}/${a.total}`:s.tasksGeneratedAt?"Aufgaben ✓":"keine Aufgaben"})]})};return e.jsxs("div",{className:`p-3 md:p-6 ${xe==="plan"?"max-w-7xl":"max-w-4xl"} mx-auto space-y-4`,children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-xl font-bold flex items-center gap-2 text-foreground",children:[e.jsx(Xe,{className:"w-5 h-5 text-primary"})," Kampagnen-Planer"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Alle Studios und Kampagnen auf einen Blick — planen, Aufgaben erzeugen, Fortschritt sehen."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>m(!0),className:"text-sm px-3 py-1.5 rounded-lg bg-violet-600 text-white font-medium flex items-center gap-1.5",children:"✨ Kampagnen-Ideen (KI)"}),e.jsxs("button",{onClick:()=>L(!0),className:"text-sm px-3 py-1.5 rounded-lg bg-yellow-500 text-black font-semibold flex items-center gap-1.5",children:[e.jsx(Me,{className:"w-4 h-4"})," Schnelles Angebot"]}),e.jsxs("button",{onClick:()=>{W(null),I(!0)},className:"text-sm px-3 py-1.5 rounded-lg bg-primary text-primary-foreground font-medium flex items-center gap-1.5",children:[e.jsx(Me,{className:"w-4 h-4"})," Neue Kampagne"]})]})]}),e.jsxs("div",{className:"flex gap-1.5",children:[[["plan","📅 Jahresplan"],["list","📋 Kampagnen-Liste"]].map(([s,a])=>e.jsx("button",{onClick:()=>pe(s),className:`text-xs px-3 py-1.5 rounded-lg border font-medium ${xe===s?"bg-primary/10 border-primary/40 text-primary":"border-border text-muted-foreground hover:text-foreground"}`,children:a},s)),e.jsx("a",{href:"/admin/kampagnen",className:"text-xs px-3 py-1.5 rounded-lg border border-border text-muted-foreground hover:text-foreground font-medium",children:"🚦 Takt & Checkliste"})]}),xe==="plan"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-wrap",children:[e.jsx("button",{onClick:()=>be(s=>s-4),className:"px-2 py-1 rounded border border-border hover:text-foreground",children:"◂"}),e.jsxs("span",{className:"font-medium text-foreground",children:[f[0].label," (",f[0].sub,") – ",f[ne-1].label," (",f[ne-1].sub,")"]}),e.jsx("button",{onClick:()=>be(s=>s+4),className:"px-2 py-1 rounded border border-border hover:text-foreground",children:"▸"}),X!==0&&e.jsx("button",{onClick:()=>be(0),className:"px-2 py-1 rounded border border-border hover:text-foreground",children:"Heute"}),e.jsx("span",{className:"ml-auto",children:"Leere Zelle anklicken = neue Kampagne für Studio + Woche"})]}),e.jsx("div",{className:"overflow-x-auto rounded-xl border border-border",children:e.jsxs("table",{className:"w-full text-xs border-collapse min-w-[1100px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-muted/60",children:[e.jsx("th",{className:"text-left px-3 py-2 font-semibold text-muted-foreground uppercase tracking-wide text-[10px] border-b border-border w-44",children:"Studio · Takt"}),f.map((s,a)=>e.jsxs("th",{className:`px-1.5 py-2 font-semibold text-muted-foreground uppercase tracking-wide text-[10px] border-b border-border text-center ${s.isMonthStart?"border-l-2 border-l-border":"border-l border-border"}`,children:[e.jsx("div",{className:"text-foreground",children:s.label}),e.jsx("div",{className:"text-[9px] font-normal opacity-70",children:s.sub})]},a))]})}),e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsxs("td",{className:"px-3 py-2 border-b border-border align-top",children:[e.jsx("div",{className:"font-semibold text-foreground",children:"🌐 Alle Studios"}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Kampagnen ohne Studio-Auswahl"})]}),f.map((s,a)=>e.jsxs("td",{className:`px-1 py-1.5 border-b align-top ${s.isMonthStart?"border-l-2 border-l-border":"border-l border-border"}`,children:[w(null,s).map(o=>e.jsx(D,{c:o},o.id)),e.jsx("button",{onClick:()=>g(null,s),className:"block w-full text-center text-muted-foreground
86/40 hover:text-primary border border-dashed border-border rounded-md py-0.5",children:"+"})]},a))]}),r.map(s=>{const a=je(s),o=p(s.id);return e.jsxs("tr",{children:[e.jsxs("td",{className:"px-3 py-2 border-b border-border align-top",children:[e.jsx("div",{className:"font-semibold text-foreground truncate max-w-[160px]",children:s.studioName??s.name}),e.jsxs("span",{className:`inline-block mt-1 text-[9.5px] font-bold px-2 py-0.5 rounded-full ${a.cls}`,children:["● ",a.label]}),e.jsxs("button",{onClick:()=>Q(s),className:"block mt-1 text-[9.5px] text-muted-foreground hover:text-primary",title:"Anlässe pflegen (Eröffnung, Jubiläum …)",children:["🏷 ",k(s.id).length?`${k(s.id).length} Anlass/Anlässe`:"Anlass hinzufügen"]}),o&&e.jsxs("span",{className:"block mt-1 text-[9px] font-bold text-red-500",children:["⚠ ",o]})]}),f.map((u,j)=>e.jsxs("td",{className:`px-1 py-1.5 border-b align-top ${u.isMonthStart?"border-l-2 border-l-border":"border-l border-border"}`,children:[k(s.id).filter(h=>{const y=new Date(h.date+"T00:00:00").getTime();return y>=u.startMs&&y<=u.endMs}).map((h,y)=>e.jsxs("div",{className:"rounded-md border border-fuchsia-500/50 bg-fuchsia-500/10 text-fuchsia-500 px-1.5 py-0.5 mb-1 text-[9.5px] font-bold truncate",title:`${h.title} · ${h.date}`,children:["🏷 ",new Date(h.date+"T00:00:00").toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})," ",h.title]},`ev-${y}`)),w(s.id,u).map(h=>e.jsx(D,{c:h},h.id)),e.jsx("button",{onClick:()=>g(s.id,u),className:"block w-full text-center text-muted-foreground/40 hover:text-primary border border-dashed border-border rounded-md py-0.5",children:"+"})]},j))]},s.id)})]})]})}),e.jsxs("div",{className:"flex gap-3 text-[10px] text-muted-foreground flex-wrap",children:[e.jsxs("span",{children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-sm bg-emerald-500 mr-1"}),"Aktiv"]}),e.jsxs("span",{children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-sm bg-amber-500 mr-1"}),"In Arbeit"]}),e.jsxs("span",{children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-sm bg-blue-500 mr-1"}),"Geplant"]}),e.jsxs("span",{children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-sm bg-muted-foreground mr-1"}),"Idee / Fertig"]}),e.jsxs("span",{children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-sm bg-violet-500 mr-1"}),"🚀 Onboarding + Startkampagne"]}),e.jsx("span",{className:"ml-2",children:"Ampel = Kampagnen-Takt des Studios · Chip anklicken = Kampagne öffnen · Fortschritt kommt live aus dem Aufgaben-Board"})]})]}),xe==="list"&&(O?e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:e.jsx(ce,{className:"w-5 h-5 animate-spin inline"})}):C.length===0?e.jsx("div",{className:"rounded-xl border border-dashed border-border p-10 text-center text-sm text-muted-foreground",children:"Noch keine Kampagnen geplant. Lege oben die erste an."}):e.jsx("div",{className:"space-y-3",children:C.map(s=>{const a=z(s.status),o=s.brandIds?.length?`${s.brandIds.length} Studio(s)`:"Alle Studios";return e.jsx("div",{className:"rounded-xl border border-border bg-card p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:s.name}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${a.cls}`,children:a.l}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:de(s.type)})]}),e.jsxs("div",{className:"text-[11px] text-muted-foreground mt-0.5 flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(et,{className:"w-3 h-3"})," ",We(s.startDate),s.endDate?` – ${We(s.endDate)}`:""]}),e.jsxs("span",{children:["· ",o]}),e.jsxs("span",{children:["· ",s.items?.length??0," To-do(s)"]}),s.tasksGeneratedAt&&e.jsx("span",{className:"text-emerald-600",children:"· Aufgaben erstellt ✓"})]}),s.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:s.description}),s.brandIds?.length>0&&e.jsx("div",{className:"mt-1 text-[10px] text-muted-foreground truncate",children:s.brandIds.map(u=>Y(u)).join(", ")})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs("button",{onClick:()=>
86{if((s.items?.length??0)===0){l.error("Keine To-dos in dieser Kampagne.");return}V(s)},disabled:T.isPending,className:"text-xs px-2.5 py-1.5 rounded-lg bg-primary/10 text-primary border border-primary/30 inline-flex items-center gap-1 font-medium",title:s.tasksGeneratedAt?"Aufgaben neu erzeugen (offene ersetzen, erledigte behalten)":"Aufgaben aus den To-dos erzeugen",children:[e.jsx(Le,{className:"w-3.5 h-3.5"})," ",s.tasksGeneratedAt?"Aufgaben aktualisieren":"Aufgaben generieren"]}),e.jsx("button",{onClick:()=>_(s),className:"text-muted-foreground hover:text-foreground p-1.5",title:"Kampagne überarbeiten (Angebot, Texte, Zeitraum, To-dos)",children:e.jsx(tt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>{confirm(`Kampagne „${s.name}" löschen?`)&&K.mutate({id:s.id})},className:"text-red-500 hover:text-red-400 p-1.5",title:"Löschen",children:e.jsx(st,{className:"w-4 h-4"})})]})]})},s.id)})})),F&&(()=>{const s=F,a=!s.brandIds?.length,o=a?N.filter(S=>S.active!==!1).length:s.brandIds.length,u=a?"Alle aktiven Studios":s.brandIds.map(S=>Y(S)).join(", "),j=s.items??[],h=j.length*Math.max(1,o),y=S=>S.fromEnd?Number(S.offsetDays)===0?"am Ende":`${Math.abs(Number(S.offsetDays))} Tage vor Ende`:Number(S.offsetDays)===0?"am Start":`${Number(S.offsetDays)>0?"+":""}${Number(S.offsetDays)} Tage`;return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:()=>V(null),children:e.jsxs("div",{className:"bg-card border border-border rounded-2xl max-w-lg w-full max-h-[85vh] overflow-y-auto p-5",onClick:S=>S.stopPropagation(),children:[e.jsx("h3",{className:"text-base font-bold text-foreground mb-1",children:"Vorschau — bevor Aufgaben angelegt werden"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:'Prüfe die Vorlage. Erst mit „Jetzt erstellen" werden die Aufgaben in den Studios angelegt.'}),e.jsxs("div",{className:"rounded-lg bg-muted/40 p-3 text-xs mb-3 space-y-1",children:[e.jsxs("div",{children:[e.jsx("b",{className:"text-foreground",children:"Kampagne:"})," ",s.name]}),e.jsxs("div",{children:[e.jsxs("b",{className:"text-foreground",children:["Studios (",o,"):"]})," ",e.jsx("span",{className:"text-muted-foreground",children:u})]})]}),e.jsxs("div",{className:"text-xs font-semibold text-foreground mb-1.5",children:["To-do-Vorlage (",j.length,") — entsteht je Studio als Aufgabe:"]}),e.jsx("ul",{className:"space-y-1 mb-3",children:j.map((S,M)=>e.jsxs("li",{className:"text-xs flex items-center justify-between gap-2 border-b border-border/40 pb-1",children:[e.jsx("span",{className:"text-foreground truncate",children:S.title||`To-do ${M+1}`}),e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:y(S)})]},M))}),s.tasksGeneratedAt&&e.jsx("p",{className:"text-[11px] text-amber-600 mb-3",children:"Es wurden schon Aufgaben erzeugt — offene werden ersetzt, erledigte bleiben erhalten."}),e.jsxs("div",{className:"rounded-lg bg-primary/5 border border-primary/20 p-2.5 text-[11px] text-muted-foreground mb-4",children:["Es entstehen ca. ",e.jsx("b",{className:"text-foreground",children:h})," Aufgabe(n) (",j.length," × ",o," Studio(s))."]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>V(null),className:"text-xs px-3 py-2 rounded-lg border border-border text-muted-foreground hover:text-foreground",children:"Abbrechen"}),e.jsxs("button",{onClick:()=>T.mutate({id:s.id}),disabled:T.isPending,className:"text-xs px-3 py-2 rounded-lg bg-primary text-primary-foreground font-semibold inline-flex items-center gap-1.5",children:[T.isPending?e.jsx(ce,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Le,{className:"w-3.5 h-3.5"})," Jetzt Aufgaben erstellen"]})]})]})})})(),ue&&e.jsx(lt,{brand:ue,events:k(ue.id),saving:ke.isPending,onClose:()=>Q(null),onSave:s=>{ke.mutate({brandId:ue.id,events:s}),Q(null)}}),ve&&e.jsx(ut,{brands:r,categories:Ae,onClose:()=>m(!1),onUse:(s,a,o)=>{const u=G([a]);if(u&&!confirm(`⚠️ Für dieses Studio läuft das Onboarding „${u}" — die Startkampagne ist dort schon enthalten.
87
88Trotzdem anlegen?`))return;
88const j=864e5,h=o?.periodFrom?new Date(`${o.periodFrom}T00:00:00`).getTime():null,y=[];if(h&&Array.isArray(o?.midDates))for(const te of o.midDates){const me=String(te).match(/(\d{2})\.(\d{2})\./);if(!me)continue;const Ne=new Date(h).getFullYear()+(Number(me[2])<new Date(h).getMonth()+1?1:0);y.push(`${Ne}-${me[2]}-${me[1]}`)}const S=[{title:"Countdown-Grafik-Paket briefen: 3 Grafiken (noch 3/2/1) × Closeouts, Story + Feed",offsetDays:-14,priority:"high"},...y.map((te,me)=>{const Ne=h?Math.round((new Date(`${te}T00:00:00`).getTime()-h)/j):14*(me+1);return{title:`Zwischen-Closeout ${me+1} (${(o.midDates??[])[me]??""}): Mail raus + Ad-Text wechseln + Countdown-Grafiken posten`,offsetDays:Ne,priority:"high"}}),...o?.withReferral?[{title:"Theke briefen: Empfehlungs-Aktion aktiv (Prämie + Ablauf)",offsetDays:0,priority:"medium"}]:[],{title:"Countdown-Grafiken posten: noch 3/2/1 Tage bis Angebots-Ende",offsetDays:-3,priority:"high",fromEnd:!0}],M=[];if(o?.withReferral&&(M.push({date:o?.periodFrom??"",time:"10:00",subject:s.referral?.mailSubject||"Hol deinen Trainingspartner — Aktions-Angebot + Prämie",audience:"Bestand (Weiterempfehlung)",status:"offen"}),y[0]&&M.push({date:y[0],time:"18:00",subject:"Erinnerung: Empfehlungs-Aktion läuft noch",audience:"Bestand (Weiterempfehlung)",status:"offen"})),o?.withComeback){const te=Array.isArray(s.comeback?.subjects)?s.comeback.subjects:[];M.push({date:o?.periodFrom??"",time:"11:00",subject:te[0]||"Wir haben dich vermisst — dein Comeback-Angebot",audience:"Ehemalige",status:"offen"}),M.push({date:y[0]??"",time:"18:00",subject:te[1]||"Nur noch kurz: dein Comeback-Angebot",audience:"Ehemalige",status:"offen"}),M.push({date:o?.periodTo??"",time:"09:00",subject:te[2]||"Letzte Chance — heute endet dein Angebot",audience:"Ehemalige",status:"offen"})}W({items:[...(fe??Ge).map(te=>({...te})),...S],emailPlan:M,brandIds:[a],status:"geplant",type:"aktion",name:s.name??"",description:s.reasoning??"",startDate:o?.periodFrom?new Date(`${o.periodFrom}T00:00:00`).getTime():void 0,endDate:o?.periodTo?new Date(`${o.periodTo}T00:00:00`).getTime():void 0,briefing:{offer:[s.offer?.headline,s.offer?.details,s.offer?.savings?`Ersparnis: ${s.offer.savings}`:""].filter(Boolean).join(" — "),audience:s.audience??"",message:s.idea??"",hooks:Array.isArray(s.hooks)?s.hooks:[],cta:"",funnelUrl:"",...o?.membershipFocus?{membershipFocus:o.membershipFocus}:{},closeout:{realEnd:o?.periodTo?`${o.periodTo}T23:59`:"",scarcity:"datum_stueckzahl",midCloseouts:Array.isArray(s.closeout?.midCloseouts)?s.closeout.midCloseouts:[],adPhase:!0,creativesDeadline:!0}}}),m(!1),I(!0),l.success("Empfehlung übernommen — Termine + Closeout-Datum setzen, speichern, dann Freigabe.")}}),q&&e.jsx(mt,{brands:N,onClose:()=>L(!1),onSaved:()=>A()}),J&&e.jsx(Ue,{initial:Se,brands:N,users:P,defaultTodos:fe,defaultVideoBriefing:R,saving:B.isPending,onClose:()=>{I(!1),W(null)},onSave:s=>{const a=s.type!=="onboarding"?G(s.brandIds):null;a&&!confirm(`⚠️ Onboarding „${a}" läuft für ein gewähltes Studio — Doppel-Aufgaben vermeiden. Trotzdem anlegen?`)||B.mutate(s)}}),he&&e.jsx(Ue,{initial:he,brands:N,users:P,defaultTodos:fe,defaultVideoBriefing:R,saving:v.isPending,onClose:()=>_(null),onSave:s=>v.mutate({id:he.id,...s})})]})}export{bt as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.