const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/charts-tfNpfMZ7.js","assets/vue-core-BWkI2jmS.js","assets/draggable-D_7Hh2Ar.js","assets/diff-DMCXoxCC.js","assets/ElementForm-ZhvFaI_E.js","assets/FormContact-CPZep7NZ.js","assets/FormSuccessScreen-uBnFk0ky.js","assets/index-jlIP7SKV.js","assets/vuetify-CUGCSlJO.js","assets/vuetify-Dp1euv-l.css","assets/index-CTBmGcrN.css","assets/FormSuccessScreen-DQPwCIz6.css","assets/FormShell-YkNv90Bg.js","assets/FormShell-BJA248GX.css","assets/FormContact-7sTDmThY.css","assets/FormBooking-Cy4o_N8B.js","assets/FormBooking-DGDSesJO.css","assets/FormNewsletter-BWBxEEBS.js","assets/FormNewsletter-CoQpdBw4.css","assets/FormDownload-CJyQskcK.js","assets/FormDownload-G0cHorxM.css","assets/ElementForm-D-uN_WST.css"])))=>i.map(i=>d[i]);
import{a6 as Zt,h as y,k as se,l as Ae,a7 as h,v as a,a8 as _a,u as P,a9 as N,aa as t,ab as U,n as e,a2 as dt,a4 as l,ac as xt,ad as Ut,ae as o,Z as n,V as v,F as be,y as Ze,H as rt,a0 as Ft,af as Pe,i as ot,q as Vt,ag as Tt,ah as Nt,o as ft,M as ht,ai as La,E as da,aj as Xt,ak as Dl,L as Wt,P as za,Q as Ka,al as Kt,r as wt,am as Ea,_ as Tl,$ as Ll,an as ua,ao as aa,a3 as El,U as Ml}from"./vue-core-BWkI2jmS.js";import{d as sl}from"./draggable-D_7Hh2Ar.js";import{d as Nl,a as Ul}from"./diff-DMCXoxCC.js";const Bl="modulepreload",Fl=function(r){return"/"+r},ja={},Lt=function($,d,c){let s=Promise.resolve();if(d&&d.length>0){let u=function(_){return Promise.all(_.map(k=>Promise.resolve(k).then(i=>({status:"fulfilled",value:i}),i=>({status:"rejected",reason:i}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),p=(f==null?void 0:f.nonce)||(f==null?void 0:f.getAttribute("nonce"));s=u(d.map(_=>{if(_=Fl(_),_ in ja)return;ja[_]=!0;const k=_.endsWith(".css"),i=k?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${_}"]${i}`))return;const g=document.createElement("link");if(g.rel=k?"stylesheet":Bl,k||(g.as="script"),g.crossOrigin="",g.href=_,p&&g.setAttribute("nonce",p),document.head.appendChild(g),k)return new Promise((x,w)=>{g.addEventListener("load",x),g.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${_}`)))})}))}function m(u){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=u,window.dispatchEvent(f),!f.defaultPrevented)throw u}return s.then(u=>{for(const f of u||[])f.status==="rejected"&&m(f.reason);return $().catch(m)})},ga="/api";function ba(){return localStorage.getItem("basec_access_token")}function il(){return localStorage.getItem("basec_refresh_token")}function rl(r,$){localStorage.setItem("basec_access_token",r),localStorage.setItem("basec_refresh_token",$)}function dl(){localStorage.removeItem("basec_access_token"),localStorage.removeItem("basec_refresh_token")}let ca=null;async function Da(){if(ca)return ca;const r=il();if(!r)return!1;ca=(async()=>{try{const $=await fetch(`${ga}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:r})});if($.status>=400&&$.status<500)return dl(),!1;if(!$.ok)return!1;const d=await $.text();if(!d)return!1;let c;try{c=JSON.parse(d)}catch{return!1}const m=(c==null?void 0:c.data)??c;return!(m!=null&&m.accessToken)||!(m!=null&&m.refreshToken)?!1:(rl(m.accessToken,m.refreshToken),!0)}catch{return!1}})();try{return await ca}finally{ca=null}}async function ma(r,$={}){const{method:d="GET",headers:c={},body:s,skipAuth:m=!1,signal:u}=$,f={...c};if(s&&d!=="GET"&&(f["Content-Type"]="application/json"),!m){const _=ba();_&&(f.Authorization=`Bearer ${_}`)}const p={method:d,headers:f};u&&(p.signal=u),s&&d!=="GET"&&(p.body=JSON.stringify(s));try{let _=await fetch(`${ga}${r}`,p);if(_.status===401&&!m)if(await Da()){const w=ba();w&&(f.Authorization=`Bearer ${w}`,p.headers=f,_=await fetch(`${ga}${r}`,p))}else return{success:!1,error:"Sitzung abgelaufen",status:401};const k=await _.text();let i=null;if(k)try{i=JSON.parse(k)}catch{return{success:!1,error:_.status>=500||_.status===0?"Backend ist gerade nicht erreichbar. Bitte einen Moment warten und erneut versuchen.":"Ungültige Server-Antwort.",status:_.status}}if(!i&&!_.ok)return{success:!1,error:_.status>=500||_.status===0?"Backend ist gerade nicht erreichbar. Bitte einen Moment warten und erneut versuchen.":`Server antwortet nicht (Status ${_.status}).`,status:_.status};if(!_.ok){const x=i&&typeof i=="object"&&"success"in i&&"data"in i?i.data:void 0;return{success:!1,error:(i==null?void 0:i.error)||(i==null?void 0:i.message)||"Ein Fehler ist aufgetreten",status:_.status,data:x}}return{success:!0,data:i&&typeof i=="object"&&"success"in i&&"data"in i?i.data:i,status:_.status,redirectTo:i==null?void 0:i.redirectTo}}catch(_){if(_ instanceof Error&&_.name==="AbortError")throw _;return{success:!1,error:_ instanceof Error?_.message:"Netzwerkfehler",status:0}}}const re={get:(r,$)=>ma(r,{...$,method:"GET"}),post:(r,$,d)=>ma(r,{...d,method:"POST",body:$}),put:(r,$,d)=>ma(r,{...d,method:"PUT",body:$}),patch:(r,$,d)=>ma(r,{...d,method:"PATCH",body:$}),delete:(r,$)=>ma(r,{...$,method:"DELETE"}),upload:async(r,$,d)=>{const c=d!=null&&d.skipAuth?null:ba(),s={};c&&(s.Authorization=`Bearer ${c}`);const m=18e4,u=new AbortController,f=window.setTimeout(()=>u.abort(),m);try{let p=await fetch(`${ga}${r}`,{method:"POST",headers:s,body:$,signal:u.signal});if(p.status===401&&!(d!=null&&d.skipAuth))return await Da()?{success:!1,error:"Sitzung wurde erneuert. Bitte Upload erneut starten.",status:401}:{success:!1,error:"Sitzung abgelaufen",status:401};const _=await p.text();let k=null;if(_)try{k=JSON.parse(_)}catch{return p.status===413?{success:!1,error:"Die Datei ist zu groß für das Server-Limit. Bitte eine kleinere Datei wählen.",status:413}:{success:!1,error:p.status>=500||p.status===0?"Backend ist gerade nicht erreichbar. Bitte einen Moment warten und erneut versuchen.":"Ungültige Server-Antwort.",status:p.status}}return!k&&!p.ok?p.status===413?{success:!1,error:"Die Datei ist zu groß für das Server-Limit. Bitte eine kleinere Datei wählen.",status:413}:{success:!1,error:p.status>=500||p.status===0?"Backend ist gerade nicht erreichbar. Bitte einen Moment warten und erneut versuchen.":`Server antwortet nicht (Status ${p.status}).`,status:p.status}:p.ok?{success:!0,data:k&&typeof k=="object"&&"success"in k&&"data"in k?k.data:k,status:p.status,redirectTo:k==null?void 0:k.redirectTo}:{success:!1,error:(k==null?void 0:k.error)||(k==null?void 0:k.message)||"Ein Fehler ist aufgetreten",status:p.status}}catch(p){return p instanceof DOMException&&p.name==="AbortError"?{success:!1,error:`Upload-Timeout: Server hat nach ${m/1e3}s nicht geantwortet. Bitte erneut versuchen oder Datei verkleinern.`,status:0}:{success:!1,error:p instanceof Error?p.message:"Netzwerkfehler",status:0}}finally{window.clearTimeout(f)}},refreshAccessToken:Da,setTokens:rl,clearTokens:dl,getAccessToken:ba,getRefreshToken:il};function Ol(r){return re.post(`/linkedin/posts/${r}/submit-for-approval`)}function Rl(r,$=!1){return re.post(`/linkedin/posts/${r}/approve`,{moveToScheduled:$})}function Kl(r,$){return re.post(`/linkedin/posts/${r}/reject`,{reason:$})}function ul(){return re.get("/linkedin/connection-status")}function jl(){return re.delete("/linkedin/auth/disconnect")}function qa(r){try{const d=r.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),c=JSON.parse(atob(d));return c.exp?c.exp*1e3:null}catch{return null}}const ea=Zt("auth",()=>{const r=y(null),$=y(re.getAccessToken()),d=y(re.getRefreshToken()),c=y(!1),s=y(null);let m=null,u=0;const f=5;async function p(){if(!r.value||!re.getAccessToken())return;const D=await re.refreshAccessToken();if(!r.value)return;if(D){u=0,$.value=re.getAccessToken(),d.value=re.getRefreshToken(),_();return}const H=re.getAccessToken(),O=H?qa(H):null;O!==null&&O-Date.now()>30*1e3&&u<f?(u++,m=setTimeout(()=>{p()},30*1e3)):(u=0,await I())}function _(){k();const D=re.getAccessToken();if(!D)return;const H=qa(D);if(!H)return;const O=H-Date.now()-120*1e3;if(O<=0){m=setTimeout(()=>{p()},0);return}m=setTimeout(()=>{p()},O)}function k(){m&&(clearTimeout(m),m=null)}let i=null;const g=se(()=>!!$.value&&!!r.value),x=se(()=>r.value?`${r.value.firstName} ${r.value.lastName}`.trim():""),w=se(()=>{var D;return((D=r.value)==null?void 0:D.role)||""});async function b(D){c.value=!0,s.value=null;const H=await re.post("/auth/login",D,{skipAuth:!0});return H.success&&H.data?(r.value=H.data.user,$.value=H.data.accessToken,d.value=H.data.refreshToken,re.setTokens(H.data.accessToken,H.data.refreshToken),u=0,_(),c.value=!1,!0):(s.value=H.error||"Anmeldung fehlgeschlagen",c.value=!1,!1)}async function I(){k();try{const H=re.getRefreshToken();H&&await re.post("/auth/logout",{refreshToken:H},{skipAuth:!0})}catch{}r.value=null,$.value=null,d.value=null,re.clearTokens();const{useUsersCacheStore:D}=await Lt(async()=>{const{useUsersCacheStore:H}=await Promise.resolve().then(()=>ql);return{useUsersCacheStore:H}},void 0);D().clearCache()}async function V(){if(i)return i;i=E();try{return await i}finally{i=null}}async function E(){const D=re.getAccessToken();if(!D)return!1;$.value=D,d.value=re.getRefreshToken(),c.value=!0;try{const H=await re.get("/auth/me");return H.success&&H.data?(r.value=H.data.user,$.value=re.getAccessToken(),d.value=re.getRefreshToken(),u=0,_(),!0):(await I(),!1)}finally{c.value=!1}}function R(){s.value=null}async function M(D){c.value=!0,s.value=null;try{const H=await re.post("/auth/forgot-password",{email:D},{skipAuth:!0});return H.success?!0:(s.value=H.error||"Fehler beim Senden der E-Mail",!1)}finally{c.value=!1}}async function T(D,H){c.value=!0,s.value=null;try{const O=await re.post("/auth/reset-password",{token:D,password:H},{skipAuth:!0});return O.success?!0:(s.value=O.error||"Fehler beim Zurücksetzen des Passworts",!1)}finally{c.value=!1}}return{user:r,accessToken:$,refreshToken:d,loading:c,error:s,isAuthenticated:g,userName:x,userRole:w,login:b,logout:I,checkAuth:V,clearError:R,forgotPassword:M,resetPassword:T}});function Ga(r,$){return`[${r}] ${$}`}const ue={debug(r,$,d){},info(r,$,d){},warn(r,$,d){console.warn(Ga(r,$),d!==void 0?d:"")},error(r,$,d){console.error(Ga(r,$),d!==void 0?d:"")}},Ma=Zt("usersCache",()=>{const r=y(new Map),$=y(!1),d=y(!1);async function c(){if(!($.value||d.value)){d.value=!0;try{const u=await re.get("/admin/users");u.success&&u.data?(r.value=new Map(u.data.map(f=>[f._id,f])),$.value=!0,ue.debug("ADMIN","Users cache loaded",{count:u.data.length})):ue.error("ADMIN","Failed to load users cache",{error:u.error})}finally{d.value=!1}}}function s(u){return u?r.value.get(u)??null:null}function m(){r.value=new Map,$.value=!1}return{users:r,loaded:$,loading:d,fetchOnce:c,getUserById:s,clearCache:m}}),ql=Object.freeze(Object.defineProperty({__proto__:null,useUsersCacheStore:Ma},Symbol.toStringTag,{value:"Module"})),Me=(r,$)=>{const d=r.__vccOpts||r;for(const[c,s]of $)d[c]=s;return d},Gl=[{code:"DE",label:"Deutschland"},{code:"AT",label:"Österreich"},{code:"CH",label:"Schweiz"},{code:"LI",label:"Liechtenstein"},{code:"BE",label:"Belgien"},{code:"CZ",label:"Tschechien"},{code:"DK",label:"Dänemark"},{code:"ES",label:"Spanien"},{code:"FI",label:"Finnland"},{code:"FR",label:"Frankreich"},{code:"HU",label:"Ungarn"},{code:"IE",label:"Irland"},{code:"IT",label:"Italien"},{code:"LU",label:"Luxemburg"},{code:"NL",label:"Niederlande"},{code:"NO",label:"Norwegen"},{code:"PL",label:"Polen"},{code:"PT",label:"Portugal"},{code:"SE",label:"Schweden"},{code:"SI",label:"Slowenien"},{code:"SK",label:"Slowakei"}],o6="DE";Gl.map(r=>r.code);const na={neu:"Neu",kontaktiert:"Kontaktiert",qualifiziert:"Qualifiziert",angebot:"Angebot",verhandlung:"Verhandlung",gewonnen:"Gewonnen",verloren:"Verloren"},Hl=["neu","kontaktiert","qualifiziert","angebot","verhandlung","gewonnen","verloren"],ya={"blog-post":"Blog-Beitrag","landing-page":"Landing Page","case-study":"Case Study",whitepaper:"Whitepaper","social-media":"Social Media",newsletter:"Newsletter"},va={entwurf:"Entwurf","in-review":"In Review",freigegeben:"Freigegeben",veroeffentlicht:"Veroeffentlicht",archiviert:"Archiviert"},cl={"azure-openai":"Azure OpenAI",anthropic:"Anthropic Claude",gemini:"Google Gemini"},Ta={"website-formular":"Website-Formular",hubspot:"HubSpot",manuell:"Manuell",newsletter:"Newsletter","social-media":"Social Media",empfehlung:"Empfehlung",outreach:"Outreach (Research)"},Wl={kalt:"Kalt",warm:"Warm",heiss:"Heiß",gewonnen:"Gewonnen",verloren:"Verloren"},la={regulatory:"Regulierungsdruck",mandate:"Mandatswert",industryFit:"Branchen-Fit",maturity:"Reifegrad",engagement:"Engagement-Index"},xa={regulatory:30,mandate:25,industryFit:20,maturity:15,engagement:10},Zl={class:"login-view"},Jl={class:"login-view__card"},Ql={class:"text-end mb-4"},Yl={class:"text-center mt-8"},Xl=Ae({__name:"LoginView",setup(r){const $=xt(),d=Ut(),c=ea(),s=y(""),m=y(""),u=y(!1),f=y(!1),p=[i=>!!i||"E-Mail ist erforderlich",i=>/.+@.+\..+/.test(i)||"Ungültige E-Mail-Adresse"],_=[i=>!!i||"Passwort ist erforderlich",i=>i.length>=8||"Mindestens 8 Zeichen"];async function k(){if(!f.value)return;if(await c.login({email:s.value,password:m.value})){const g=d.query.redirect||"/admin";$.push(g)}}return(i,g)=>{const x=l("v-alert"),w=l("v-text-field"),b=l("router-link"),I=l("v-btn"),V=l("v-form");return o(),h("div",Zl,[a("div",Jl,[g[8]||(g[8]=_a('<div class="login-view__header" data-v-27e2e8f1><span class="login-view__logo-basec" data-v-27e2e8f1>BASEC</span><span class="login-view__logo-claim" data-v-27e2e8f1>Admin</span></div><h1 class="text-h5 font-weight-bold mb-2 text-center" data-v-27e2e8f1>Anmeldung</h1><p class="text-body-2 text-medium-emphasis text-center mb-8" data-v-27e2e8f1> Melden Sie sich mit Ihren Zugangsdaten an. </p>',3)),P(c).error?(o(),N(x,{key:0,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":g[0]||(g[0]=E=>P(c).clearError())},{default:t(()=>[n(v(P(c).error),1)]),_:1})):U("",!0),e(V,{modelValue:f.value,"onUpdate:modelValue":g[4]||(g[4]=E=>f.value=E),onSubmit:dt(k,["prevent"])},{default:t(()=>[e(w,{modelValue:s.value,"onUpdate:modelValue":g[1]||(g[1]=E=>s.value=E),label:"E-Mail",placeholder:"name@beispiel.de","persistent-placeholder":"",type:"email",rules:p,"prepend-inner-icon":"mdi-email-outline",autocomplete:"email",class:"mb-2"},null,8,["modelValue"]),e(w,{modelValue:m.value,"onUpdate:modelValue":g[2]||(g[2]=E=>m.value=E),label:"Passwort",placeholder:"Passwort eingeben","persistent-placeholder":"",type:u.value?"text":"password",rules:_,"prepend-inner-icon":"mdi-lock-outline","append-inner-icon":u.value?"mdi-eye-off":"mdi-eye",autocomplete:"current-password",class:"mb-4","onClick:appendInner":g[3]||(g[3]=E=>u.value=!u.value)},null,8,["modelValue","type","append-inner-icon"]),a("div",Ql,[e(b,{to:"/admin/passwort-vergessen",class:"text-body-2 text-primary"},{default:t(()=>[...g[5]||(g[5]=[n(" Passwort vergessen? ",-1)])]),_:1})]),e(I,{type:"submit",color:"primary",block:"",size:"large",loading:P(c).loading,disabled:!f.value},{default:t(()=>[...g[6]||(g[6]=[n(" Anmelden ",-1)])]),_:1},8,["loading","disabled"])]),_:1},8,["modelValue"]),a("div",Yl,[e(b,{to:"/",class:"text-body-2 text-primary"},{default:t(()=>[...g[7]||(g[7]=[n(" Zurück zur Website ",-1)])]),_:1})])])])}}}),en=Me(Xl,[["__scopeId","data-v-27e2e8f1"]]),s6=Object.freeze(Object.defineProperty({__proto__:null,default:en},Symbol.toStringTag,{value:"Module"})),tn={class:"forgot-password-view"},an={class:"forgot-password-view__card"},ln={key:1,class:"text-center"},nn={class:"text-center mt-8"},on=Ae({__name:"ForgotPasswordView",setup(r){const $=ea(),d=y(""),c=y(!1),s=y(!1),m=[f=>!!f||"E-Mail ist erforderlich",f=>/.+@.+\..+/.test(f)||"Ungültige E-Mail-Adresse"];async function u(){if(!c.value)return;await $.forgotPassword(d.value)&&(s.value=!0)}return(f,p)=>{const _=l("v-alert"),k=l("v-text-field"),i=l("v-btn"),g=l("v-form"),x=l("v-icon"),w=l("router-link");return o(),h("div",tn,[a("div",an,[p[10]||(p[10]=a("div",{class:"forgot-password-view__header"},[a("span",{class:"forgot-password-view__logo-basec"},"BASEC"),a("span",{class:"forgot-password-view__logo-claim"},"Admin")],-1)),s.value?(o(),h("div",ln,[e(x,{size:"64",color:"primary",class:"mb-4"},{default:t(()=>[...p[6]||(p[6]=[n("mdi-email-check-outline",-1)])]),_:1}),p[7]||(p[7]=a("h1",{class:"text-h5 font-weight-bold mb-2"},"E-Mail gesendet",-1)),p[8]||(p[8]=a("p",{class:"text-body-2 text-medium-emphasis mb-8"}," Wenn ein Account mit dieser E-Mail existiert, haben wir einen Reset-Link gesendet. Bitte prüfen Sie Ihr Postfach. ",-1))])):(o(),h(be,{key:0},[p[4]||(p[4]=a("h1",{class:"text-h5 font-weight-bold mb-2 text-center"},"Passwort vergessen",-1)),p[5]||(p[5]=a("p",{class:"text-body-2 text-medium-emphasis text-center mb-8"}," Geben Sie Ihre E-Mail-Adresse ein. Sie erhalten einen Link zum Zurücksetzen Ihres Passworts. ",-1)),P($).error?(o(),N(_,{key:0,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":p[0]||(p[0]=b=>P($).clearError())},{default:t(()=>[n(v(P($).error),1)]),_:1})):U("",!0),e(g,{modelValue:c.value,"onUpdate:modelValue":p[2]||(p[2]=b=>c.value=b),onSubmit:dt(u,["prevent"])},{default:t(()=>[e(k,{modelValue:d.value,"onUpdate:modelValue":p[1]||(p[1]=b=>d.value=b),label:"E-Mail",placeholder:"name@beispiel.de","persistent-placeholder":"",type:"email",rules:m,"prepend-inner-icon":"mdi-email-outline",autocomplete:"email",class:"mb-4"},null,8,["modelValue"]),e(i,{type:"submit",color:"primary",block:"",size:"large",loading:P($).loading,disabled:!c.value},{default:t(()=>[...p[3]||(p[3]=[n(" Reset-Link senden ",-1)])]),_:1},8,["loading","disabled"])]),_:1},8,["modelValue"])],64)),a("div",nn,[e(w,{to:"/admin/login",class:"text-body-2 text-primary"},{default:t(()=>[...p[9]||(p[9]=[n(" Zurück zur Anmeldung ",-1)])]),_:1})])])])}}}),sn=Me(on,[["__scopeId","data-v-40f5a559"]]),i6=Object.freeze(Object.defineProperty({__proto__:null,default:sn},Symbol.toStringTag,{value:"Module"})),rn={class:"reset-password-view"},dn={class:"reset-password-view__card"},un={key:1,class:"text-center"},cn={class:"text-center mt-8"},mn=Ae({__name:"ResetPasswordView",setup(r){const $=Ut(),d=xt(),c=ea(),s=$.params.token,m=y(""),u=y(""),f=y(!1),p=y(!1),_=y(!1),k=[x=>!!x||"Passwort ist erforderlich",x=>x.length>=8||"Mindestens 8 Zeichen"],i=[x=>!!x||"Passwort-Bestätigung ist erforderlich",x=>x===m.value||"Passwörter stimmen nicht überein"];async function g(){if(!p.value)return;await c.resetPassword(s,m.value)&&(_.value=!0,setTimeout(()=>d.push("/admin/login"),3e3))}return(x,w)=>{const b=l("v-alert"),I=l("v-text-field"),V=l("v-btn"),E=l("v-form"),R=l("v-icon"),M=l("router-link");return o(),h("div",rn,[a("div",dn,[w[13]||(w[13]=a("div",{class:"reset-password-view__header"},[a("span",{class:"reset-password-view__logo-basec"},"BASEC"),a("span",{class:"reset-password-view__logo-claim"},"Admin")],-1)),_.value?(o(),h("div",un,[e(R,{size:"64",color:"success",class:"mb-4"},{default:t(()=>[...w[9]||(w[9]=[n("mdi-check-circle-outline",-1)])]),_:1}),w[10]||(w[10]=a("h1",{class:"text-h5 font-weight-bold mb-2"},"Passwort geändert",-1)),w[11]||(w[11]=a("p",{class:"text-body-2 text-medium-emphasis mb-8"}," Ihr Passwort wurde erfolgreich geändert. Sie werden zur Anmeldung weitergeleitet... ",-1))])):(o(),h(be,{key:0},[w[7]||(w[7]=a("h1",{class:"text-h5 font-weight-bold mb-2 text-center"},"Neues Passwort",-1)),w[8]||(w[8]=a("p",{class:"text-body-2 text-medium-emphasis text-center mb-8"}," Geben Sie Ihr neues Passwort ein. ",-1)),P(s)?U("",!0):(o(),N(b,{key:0,type:"error",variant:"tonal",class:"mb-6"},{default:t(()=>[...w[5]||(w[5]=[n(" Ungültiger Reset-Link. Bitte fordern Sie einen neuen an. ",-1)])]),_:1})),P(c).error?(o(),N(b,{key:1,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":w[0]||(w[0]=T=>P(c).clearError())},{default:t(()=>[n(v(P(c).error),1)]),_:1})):U("",!0),e(E,{modelValue:p.value,"onUpdate:modelValue":w[4]||(w[4]=T=>p.value=T),onSubmit:dt(g,["prevent"])},{default:t(()=>[e(I,{modelValue:m.value,"onUpdate:modelValue":w[1]||(w[1]=T=>m.value=T),label:"Neues Passwort",placeholder:"Mindestens 8 Zeichen","persistent-placeholder":"",type:f.value?"text":"password",rules:k,"prepend-inner-icon":"mdi-lock-outline","append-inner-icon":f.value?"mdi-eye-off":"mdi-eye",autocomplete:"new-password",class:"mb-2","onClick:appendInner":w[2]||(w[2]=T=>f.value=!f.value)},null,8,["modelValue","type","append-inner-icon"]),e(I,{modelValue:u.value,"onUpdate:modelValue":w[3]||(w[3]=T=>u.value=T),label:"Passwort bestätigen",placeholder:"Passwort wiederholen","persistent-placeholder":"",type:f.value?"text":"password",rules:i,"prepend-inner-icon":"mdi-lock-check-outline",autocomplete:"new-password",class:"mb-4"},null,8,["modelValue","type"]),e(V,{type:"submit",color:"primary",block:"",size:"large",loading:P(c).loading,disabled:!p.value||!P(s)},{default:t(()=>[...w[6]||(w[6]=[n(" Passwort speichern ",-1)])]),_:1},8,["loading","disabled"])]),_:1},8,["modelValue"])],64)),a("div",cn,[e(M,{to:"/admin/login",class:"text-body-2 text-primary"},{default:t(()=>[...w[12]||(w[12]=[n(" Zurück zur Anmeldung ",-1)])]),_:1})])])])}}}),vn=Me(mn,[["__scopeId","data-v-b829a1c9"]]),r6=Object.freeze(Object.defineProperty({__proto__:null,default:vn},Symbol.toStringTag,{value:"Module"}));function qe(r,$){const d=`basec_pref_${r}`;let c=$;try{const m=localStorage.getItem(d);m!==null&&(c=JSON.parse(m))}catch{}const s=y(c);return Ze(s,m=>{try{m===void 0?localStorage.removeItem(d):localStorage.setItem(d,JSON.stringify(m))}catch{}},{deep:!0}),s}const pn={class:"admin-layout"},fn={class:"admin-layout__drawer-header"},gn={key:0,class:"admin-layout__logo-full"},bn=["title"],yn={key:1,class:"admin-layout__logo-short"},_n={class:"admin-layout__user d-flex align-center ga-2"},kn={class:"text-body-2 text-medium-emphasis d-none d-sm-inline"},hn={class:"text-body-2 font-weight-bold"},xn=Ae({__name:"AdminLayout",setup(r){const $=xt(),d=Ut(),c=ea(),s=Ma();function m(B){const G=d.path;return B==="/admin"?G==="/admin":G===B||G.startsWith(B+"/")}const u=y(null),f=se(()=>{if(!u.value)return"";const B=u.value.version,G=u.value.commitHash;return G&&G!=="unknown"?`v${B} · ${G}`:`v${B}`}),p=se(()=>{if(!u.value)return"";const{version:B,commitHash:G,buildDate:W,nodeEnv:F}=u.value,L=[`Version: ${B}`,`Env: ${F}`];return G&&G!=="unknown"&&L.push(`Commit: ${G}`),W&&W!=="unknown"&&L.push(`Build: ${W}`),L.join(" · ")});async function _(){try{const B=await re.get("/system/version");B.success&&B.data&&(u.value=B.data)}catch{}}function k(){let B=document.querySelector('meta[name="robots"]');B||(B=document.createElement("meta"),B.setAttribute("name","robots"),document.head.appendChild(B)),B.setAttribute("content","noindex, nofollow")}function i(){for(const B of x)B.items.some(W=>m(W.to))&&!I.value.includes(B.title)&&(I.value=[...I.value,B.title])}rt(()=>{k(),document.body.classList.add("is-admin"),s.fetchOnce(),_(),i()}),Ft(()=>{document.body.classList.remove("is-admin")});const g=[{title:"Dashboard",icon:"mdi-view-dashboard",to:"/admin"}],x=[{title:"Sales",icon:"mdi-handshake",items:[{title:"Pipeline",icon:"mdi-chart-gantt",to:"/admin/pipeline"},{title:"Leads",icon:"mdi-account-group",to:"/admin/leads"},{title:"Companies",icon:"mdi-domain",to:"/admin/companies"},{title:"Research",icon:"mdi-magnify-scan",to:"/admin/sales/research"},{title:"Termine",icon:"mdi-calendar-check",to:"/admin/termine"}]},{title:"Marketing",icon:"mdi-bullhorn",items:[{title:"Email-Kampagnen",icon:"mdi-email-fast",to:"/admin/email-kampagnen"},{title:"E-Mail-Zustellung",icon:"mdi-email-check",to:"/admin/email-sequenzen"},{title:"Segmente",icon:"mdi-filter-variant",to:"/admin/segmente"},{title:"Formulare",icon:"mdi-form-select",to:"/admin/formulare"},{title:"Formular-Stats",icon:"mdi-chart-box-outline",to:"/admin/formular-stats"},{title:"Downloads",icon:"mdi-file-download-outline",to:"/admin/downloads"}]},{title:"Content",icon:"mdi-text-box-multiple",items:[{title:"Inhalte",icon:"mdi-text-box",to:"/admin/content"},{title:"Content Plan",icon:"mdi-calendar-text",to:"/admin/content-plan"},{title:"LinkedIn Posts",icon:"mdi-linkedin",to:"/admin/content-plan/posts"},{title:"Seiten",icon:"mdi-file-document-multiple",to:"/admin/seiten"},{title:"SEO",icon:"mdi-magnify",to:"/admin/seo"},{title:"Bilder",icon:"mdi-image-multiple",to:"/admin/bilder"}]},{title:"Einstellungen",icon:"mdi-cog",items:[{title:"E-Mail-Templates",icon:"mdi-email-outline",to:"/admin/email-templates"},{title:"Knowledge Base",icon:"mdi-book-open-variant",to:"/admin/knowledge-base"},{title:"Prompts & Templates",icon:"mdi-robot",to:"/admin/prompts"},{title:"KI-Einstellungen",icon:"mdi-tune",to:"/admin/ki-einstellungen"},{title:"Benutzer",icon:"mdi-account-multiple",to:"/admin/benutzer"},{title:"System",icon:"mdi-cog-outline",to:"/admin/einstellungen"}]}],w=y(!0),b=qe("admin_drawer_rail",!1),I=qe("admin_menu_groups_v2",[]),V=y(!1),E=window.matchMedia("(max-width: 959px)"),R=y(E.matches);E.addEventListener("change",B=>{R.value=B.matches});const M=se(()=>R.value?V.value:w.value),T=se(()=>!R.value&&b.value),D=se(()=>[...g,...x.flatMap(B=>B.items)]);function H(){R.value?V.value=!V.value:b.value=!b.value}function O(B){R.value?V.value=B:w.value=B}async function S(){await c.logout(),$.push("/admin/login")}return(B,G)=>{const W=l("router-link"),F=l("v-divider"),L=l("v-tooltip"),A=l("v-list-item"),z=l("v-list"),j=l("v-list-group"),J=l("v-navigation-drawer"),Q=l("v-icon"),te=l("v-app-bar-nav-icon"),ve=l("v-app-bar-title"),de=l("v-spacer"),Z=l("v-avatar"),ce=l("v-btn"),oe=l("v-menu"),pe=l("v-app-bar"),_e=l("router-view"),q=l("v-main");return o(),h("div",pn,[e(J,{"model-value":M.value,rail:!R.value&&P(b),temporary:R.value,permanent:!R.value,class:"admin-layout__drawer",color:"surface","onUpdate:modelValue":O},{append:t(()=>[e(F,{class:"mb-2"}),e(z,{density:"comfortable",nav:""},{default:t(()=>[e(A,{"prepend-icon":"mdi-open-in-new",title:"Website öffnen",rounded:"lg",href:"/",target:"_blank",rel:"noopener"})]),_:1})]),default:t(()=>[a("div",fn,[e(W,{to:"/admin",class:"admin-layout__drawer-logo"},{default:t(()=>[!P(b)||R.value?(o(),h("span",gn,[G[3]||(G[3]=a("span",{class:"admin-layout__logo-basec"},"BASEC",-1)),G[4]||(G[4]=a("span",{class:"admin-layout__logo-admin"},"Admin",-1)),f.value?(o(),h("span",{key:0,class:"admin-layout__logo-version",title:p.value},v(f.value),9,bn)):U("",!0)])):(o(),h("span",yn,"B"))]),_:1})]),e(F,{class:"mb-2"}),T.value?(o(),N(z,{key:0,density:"comfortable",nav:""},{default:t(()=>[(o(!0),h(be,null,Pe(D.value,C=>(o(),N(A,{key:C.to,to:C.to,active:m(C.to),"prepend-icon":C.icon,rounded:"lg",class:"admin-layout__menu-item",color:"primary"},{default:t(()=>[e(L,{activator:"parent",location:"end"},{default:t(()=>[n(v(C.title),1)]),_:2},1024)]),_:2},1032,["to","active","prepend-icon"]))),128))]),_:1})):(o(),N(z,{key:1,opened:P(I),"onUpdate:opened":G[2]||(G[2]=C=>ot(I)?I.value=C:null),density:"comfortable",nav:"","open-strategy":"multiple"},{default:t(()=>[(o(),h(be,null,Pe(g,C=>e(A,{key:C.to,to:C.to,active:m(C.to),"prepend-icon":C.icon,title:C.title,rounded:"lg",class:"admin-layout__menu-item",color:"primary",onClick:G[0]||(G[0]=ae=>R.value?V.value=!1:null)},null,8,["to","active","prepend-icon","title"])),64)),(o(),h(be,null,Pe(x,C=>e(j,{key:C.title,value:C.title},{activator:t(({props:ae})=>[e(A,Vt({ref_for:!0},ae,{"prepend-icon":C.icon,title:C.title,rounded:"lg",class:"admin-layout__menu-item admin-layout__menu-item--group text-secondary"}),null,16,["prepend-icon","title"])]),default:t(()=>[(o(!0),h(be,null,Pe(C.items,ae=>(o(),N(A,{key:ae.to,to:ae.to,active:m(ae.to),"prepend-icon":ae.icon,title:ae.title,rounded:"lg",class:"admin-layout__menu-item admin-layout__menu-item--nested",color:"primary",onClick:G[1]||(G[1]=X=>R.value?V.value=!1:null)},null,8,["to","active","prepend-icon","title"]))),128))]),_:2},1032,["value"])),64))]),_:1},8,["opened"]))]),_:1},8,["model-value","rail","temporary","permanent"]),e(pe,{flat:"",class:"admin-layout__appbar",color:"surface"},{default:t(()=>[e(te,{color:"primary","aria-label":"Navigation umschalten",onClick:H},{default:t(()=>[e(Q,{color:"primary"},{default:t(()=>[...G[5]||(G[5]=[n("mdi-menu",-1)])]),_:1}),e(L,{activator:"parent",location:"bottom"},{default:t(()=>[...G[6]||(G[6]=[n("Menü ein-/ausblenden",-1)])]),_:1})]),_:1}),e(ve,{class:"text-body-1 font-weight-medium"},{default:t(()=>[...G[7]||(G[7]=[n(" Basec Admin ",-1)])]),_:1}),e(de),a("div",_n,[a("span",kn,v(P(c).userName||"Administrator"),1),e(oe,{location:"bottom end",transition:"slide-y-transition"},{activator:t(({props:C})=>[e(ce,Vt(C,{icon:"",variant:"text",size:"small","aria-label":"Benutzermenü"}),{default:t(()=>[e(L,{activator:"parent",location:"bottom"},{default:t(()=>[...G[8]||(G[8]=[n("Benutzermenü",-1)])]),_:1}),e(Z,{size:"32",color:"primary"},{default:t(()=>[a("span",hn,v((P(c).userName||"A").charAt(0).toUpperCase()),1)]),_:1})]),_:1},16)]),default:t(()=>[e(z,{density:"comfortable","min-width":"200"},{default:t(()=>[e(A,{"prepend-icon":"mdi-account",title:"Profil",to:"/admin/einstellungen"}),e(F),e(A,{"prepend-icon":"mdi-logout",title:"Abmelden",onClick:S})]),_:1})]),_:1})])]),_:1}),e(q,{class:"admin-layout__main"},{default:t(()=>[e(_e)]),_:1})])}}}),wn=Me(xn,[["__scopeId","data-v-376cb741"]]),d6=Object.freeze(Object.defineProperty({__proto__:null,default:wn},Symbol.toStringTag,{value:"Module"})),oa=Zt("adminKpi",()=>{const r=y(null),$=y(!1),d=y(null),c=y("30d");let s=null;async function m(_){$.value=!0,d.value=null;try{const k=_||c.value,i=new URLSearchParams;i.set("period",k);const g=await re.get(`/email-stats/dashboard-kpis?${i}`);g.success&&g.data?(r.value=g.data,_&&(c.value=_)):(d.value=g.error||"Fehler beim Laden der KPI-Daten",ue.error("ADMIN","Dashboard KPIs konnten nicht geladen werden",g.error))}catch(k){d.value="Netzwerkfehler beim Laden der Dashboard-KPIs",ue.error("ADMIN","Dashboard KPIs Netzwerkfehler",k)}finally{$.value=!1}}function u(_=3e4){f(),s=setInterval(()=>{m()},_)}function f(){s&&(clearInterval(s),s=null)}function p(){r.value=null,$.value=!1,d.value=null,f()}return{kpis:r,loading:$,error:d,period:c,fetchDashboardKpis:m,startPolling:u,stopPolling:f,$reset:p}}),Sn={class:"d-flex align-center justify-space-between mb-2"},$n={key:0,class:"text-h4 font-weight-bold text-primary"},Cn={key:1,class:"text-h4 font-weight-bold text-primary"},Vn={class:"dashboard-kpi-card__chart"},An=Ae({__name:"DashboardKpiActiveLeads",setup(r){const $=Nt(()=>Lt(()=>import("./charts-tfNpfMZ7.js"),__vite__mapDeps([0,1,2,3])).catch(_=>{throw ue.error("ADMIN","ApexCharts konnte nicht geladen werden",_),_})),d=oa(),c=se(()=>{const _=d.kpis;return _?_.activeLeadsTotal??0:0}),s=se(()=>{const _=d.kpis;return _?_.leadEngagementStates??{}:{}}),m=se(()=>Object.values(s.value)),u=se(()=>Object.keys(s.value).map(f));function f(_){return{hot:"Hot",warm:"Warm",cold:"Kalt",stuck:"Stagnierend","single-converter":"Einmal-Konverter","multi-converter":"Mehr-Konverter","power-lead":"Power-Lead",bounced:"Bounced",unsubscribed:"Abgemeldet","awaiting-next-step":"Wartet",active:"Aktiv"}[_]??_}const p=se(()=>({chart:{type:"donut",background:"transparent",toolbar:{show:!1},sparkline:{enabled:!0}},colors:["#CF6679","#C9A063","#748686","#748686","#0AC9D4","#0AC9D4","#E2F54B","#CF6679","#748686","#0AC9D4","#FFFFFF"],labels:u.value,legend:{show:!1},dataLabels:{enabled:!1},tooltip:{theme:"dark",y:{formatter:_=>`${_} Leads`}},plotOptions:{pie:{donut:{size:"70%",labels:{show:!1}}}},stroke:{width:0}}));return(_,k)=>{const i=l("v-skeleton-loader"),g=l("v-icon"),x=l("v-alert"),w=l("v-card-text"),b=l("v-card");return o(),N(b,{rounded:"lg",class:"dashboard-kpi-card"},{default:t(()=>[e(w,{class:"pa-4"},{default:t(()=>[a("div",Sn,[a("div",null,[k[0]||(k[0]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Aktive Leads",-1)),P(d).loading&&!P(d).kpis?(o(),h("div",$n,[e(i,{type:"text",width:"60"})])):(o(),h("div",Cn,v(c.value),1))]),a("div",Vn,[(o(),N(Tt,null,{default:t(()=>[m.value.length>0&&m.value.some(I=>I>0)?(o(),N(P($),{key:0,type:"donut",height:80,width:80,options:p.value,series:m.value},null,8,["options","series"])):(o(),N(g,{key:1,size:"40",color:"primary",opacity:"0.4"},{default:t(()=>[...k[1]||(k[1]=[n("mdi-account-group",-1)])]),_:1}))]),fallback:t(()=>[e(g,{size:"40",color:"primary",opacity:"0.4"},{default:t(()=>[...k[2]||(k[2]=[n("mdi-account-group",-1)])]),_:1})]),_:1}))])]),P(d).error?(o(),N(x,{key:0,type:"error",variant:"tonal",density:"compact",text:P(d).error,class:"mt-2"},null,8,["text"])):U("",!0)]),_:1})]),_:1})}}}),In=Me(An,[["__scopeId","data-v-074686ec"]]),Pn={class:"text-h5 font-weight-bold text-white"},zn={class:"text-h5 font-weight-bold text-primary"},Dn={class:"text-h5 font-weight-bold dashboard-kpi-email-today__gold"},Tn=Ae({__name:"DashboardKpiEmailToday",setup(r){const $=oa(),d=se(()=>{var u;const m=$.kpis;return((u=m==null?void 0:m.emailsToday)==null?void 0:u.sent)??0}),c=se(()=>{var u;const m=$.kpis;return((u=m==null?void 0:m.emailsToday)==null?void 0:u.opened)??0}),s=se(()=>{var u;const m=$.kpis;return((u=m==null?void 0:m.emailsToday)==null?void 0:u.clicked)??0});return(m,u)=>{const f=l("v-skeleton-loader"),p=l("v-col"),_=l("v-divider"),k=l("v-row"),i=l("v-alert"),g=l("v-card-text"),x=l("v-card");return o(),N(x,{rounded:"lg",class:"dashboard-kpi-email-today"},{default:t(()=>[e(g,{class:"pa-4"},{default:t(()=>[u[3]||(u[3]=a("div",{class:"text-caption text-medium-emphasis mb-3"},"E-Mails heute",-1)),e(k,{"no-gutters":""},{default:t(()=>[e(p,{cols:"4",class:"text-center"},{default:t(()=>[P($).loading&&!P($).kpis?(o(),N(f,{key:0,type:"text"})):(o(),h(be,{key:1},[a("div",Pn,v(d.value),1),u[0]||(u[0]=a("div",{class:"text-caption text-medium-emphasis mt-1"},"Gesendet",-1))],64))]),_:1}),e(_,{vertical:"",class:"mx-2"}),e(p,{cols:"4",class:"text-center"},{default:t(()=>[P($).loading&&!P($).kpis?(o(),N(f,{key:0,type:"text"})):(o(),h(be,{key:1},[a("div",zn,v(c.value),1),u[1]||(u[1]=a("div",{class:"text-caption text-medium-emphasis mt-1"},"Geöffnet",-1))],64))]),_:1}),e(_,{vertical:"",class:"mx-2"}),e(p,{cols:"4",class:"text-center"},{default:t(()=>[P($).loading&&!P($).kpis?(o(),N(f,{key:0,type:"text"})):(o(),h(be,{key:1},[a("div",Dn,v(s.value),1),u[2]||(u[2]=a("div",{class:"text-caption text-medium-emphasis mt-1"},"Geklickt",-1))],64))]),_:1})]),_:1}),P($).error?(o(),N(i,{key:0,type:"error",variant:"tonal",density:"compact",text:P($).error,class:"mt-3"},null,8,["text"])):U("",!0)]),_:1})]),_:1})}}}),Ln=Me(Tn,[["__scopeId","data-v-8ea46a55"]]),En={class:"d-flex align-start justify-space-between"},Mn={class:"d-flex align-center ga-2 mb-1"},Nn={class:"text-h6 font-weight-bold text-primary"},Un={class:"d-flex align-center ga-2"},Bn={class:"text-h6 font-weight-bold"},Fn=Ae({__name:"DashboardKpiMeetings",setup(r){const $=oa(),d=se(()=>{var p;const f=$.kpis;return((p=f==null?void 0:f.meetings)==null?void 0:p.thisWeek)??0}),c=se(()=>{var p;const f=$.kpis;return((p=f==null?void 0:f.meetings)==null?void 0:p.thisMonth)??0}),s=se(()=>{var _;const f=$.kpis,p=(_=f==null?void 0:f.meetings)==null?void 0:_.trend;return p==="up"?"up":p==="down"?"down":"neutral"}),m=se(()=>s.value==="up"?"mdi-trending-up":s.value==="down"?"mdi-trending-down":"mdi-trending-neutral"),u=se(()=>s.value==="up"?"success":s.value==="down"?"error":"medium-emphasis");return(f,p)=>{const _=l("v-skeleton-loader"),k=l("v-icon"),i=l("v-alert"),g=l("v-card-text"),x=l("v-card");return o(),N(x,{rounded:"lg",class:"dashboard-kpi-meetings"},{default:t(()=>[e(g,{class:"pa-4"},{default:t(()=>[a("div",En,[a("div",null,[p[4]||(p[4]=a("div",{class:"text-caption text-medium-emphasis mb-2"},"Termine",-1)),P($).loading&&!P($).kpis?(o(),N(_,{key:0,type:"text",width:"80"})):(o(),h(be,{key:1},[a("div",Mn,[e(k,{size:"16",color:"primary"},{default:t(()=>[...p[0]||(p[0]=[n("mdi-calendar-week",-1)])]),_:1}),p[1]||(p[1]=a("span",{class:"text-body-2 text-medium-emphasis"},"Diese Woche:",-1)),a("span",Nn,v(d.value),1)]),a("div",Un,[e(k,{size:"16",color:"secondary"},{default:t(()=>[...p[2]||(p[2]=[n("mdi-calendar-month",-1)])]),_:1}),p[3]||(p[3]=a("span",{class:"text-body-2 text-medium-emphasis"},"Diesen Monat:",-1)),a("span",Bn,v(c.value),1)])],64))]),P($).loading?(o(),N(k,{key:1,size:"32",color:"grey"},{default:t(()=>[...p[5]||(p[5]=[n("mdi-calendar-check",-1)])]),_:1})):(o(),N(k,{key:0,color:u.value,size:"32"},{default:t(()=>[n(v(m.value),1)]),_:1},8,["color"]))]),P($).error?(o(),N(i,{key:0,type:"error",variant:"tonal",density:"compact",text:P($).error,class:"mt-3"},null,8,["text"])):U("",!0)]),_:1})]),_:1})}}}),On=Me(Fn,[["__scopeId","data-v-ba76619b"]]),Rn={key:0,class:"pa-4"},Kn={class:"text-caption text-medium-emphasis mr-2 dashboard-kpi-topic-leaderboard__rank"},jn={class:"text-body-2 font-weight-medium"},qn=Ae({__name:"DashboardKpiTopicLeaderboard",setup(r){const $=oa(),d=se(()=>{const m=$.kpis;if(!m)return[];const u=m.topTopics;return(u==null?void 0:u.slice(0,5))??[]});function c(m){return m==null?"–":`${(m*100).toFixed(1)} %`}function s(m){return m>=.2?"success":m>=.1?"warning":"default"}return(m,u)=>{const f=l("v-icon"),p=l("v-card-title"),_=l("v-divider"),k=l("v-skeleton-loader"),i=l("v-alert"),g=l("v-card-text"),x=l("v-chip"),w=l("v-list-item"),b=l("v-list"),I=l("v-card");return o(),N(I,{rounded:"lg",class:"dashboard-kpi-topic-leaderboard"},{default:t(()=>[e(p,{class:"pa-4 pb-2 d-flex align-center justify-space-between"},{default:t(()=>[u[1]||(u[1]=a("span",{class:"text-body-2 font-weight-semibold"},"Top-5 Topics",-1)),e(f,{size:"18",color:"primary"},{default:t(()=>[...u[0]||(u[0]=[n("mdi-trophy-outline",-1)])]),_:1})]),_:1}),e(_),P($).loading&&!P($).kpis?(o(),h("div",Rn,[(o(),h(be,null,Pe(5,V=>e(k,{key:V,type:"list-item",class:"mb-1"})),64))])):P($).error?(o(),N(i,{key:1,type:"error",variant:"tonal",density:"compact",text:P($).error,class:"ma-4"},null,8,["text"])):d.value.length===0?(o(),N(g,{key:2,class:"pa-4 text-center text-medium-emphasis text-body-2"},{default:t(()=>[...u[2]||(u[2]=[n(" Noch keine Topic-Daten vorhanden. ",-1)])]),_:1})):(o(),N(b,{key:3,density:"compact",class:"pa-0"},{default:t(()=>[(o(!0),h(be,null,Pe(d.value,(V,E)=>(o(),N(w,{key:V.topic,class:"dashboard-kpi-topic-leaderboard__item"},{prepend:t(()=>[a("span",Kn,v(E+1)+". ",1)]),title:t(()=>[a("span",jn,v(V.topic),1)]),append:t(()=>[e(x,{color:s(V.meetingRate),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(c(V.meetingRate)),1)]),_:2},1032,["color"])]),_:2},1024))),128))]),_:1}))]),_:1})}}}),Gn=Me(qn,[["__scopeId","data-v-932ea91a"]]),Hn={class:"d-flex align-center ga-3 mb-2"},Wn={class:"text-caption text-medium-emphasis"},Zn=Ae({__name:"DashboardKpiDeliveryHealth",setup(r){const $=oa(),d=se(()=>{var _;const p=$.kpis;return((_=p==null?void 0:p.deliveryHealth)==null?void 0:_.bounceRate)??0}),c=se(()=>d.value<.02?"good":d.value<.05?"warn":"bad"),s=se(()=>c.value==="good"?"success":c.value==="warn"?"warning":"error"),m=se(()=>c.value==="good"?"mdi-check-circle":c.value==="warn"?"mdi-alert-circle":"mdi-close-circle"),u=se(()=>c.value==="good"?"Gut":c.value==="warn"?"Erhöht":"Kritisch");function f(p){return p==null?"–":`${(p*100).toFixed(2)} %`}return(p,_)=>{const k=l("v-skeleton-loader"),i=l("v-icon"),g=l("v-progress-linear"),x=l("v-alert"),w=l("v-card-text"),b=l("v-card");return o(),N(b,{rounded:"lg",class:"dashboard-kpi-delivery-health"},{default:t(()=>[e(w,{class:"pa-4"},{default:t(()=>[_[1]||(_[1]=a("div",{class:"text-caption text-medium-emphasis mb-3"},"Zustellbarkeit",-1)),P($).loading&&!P($).kpis?(o(),N(k,{key:0,type:"text",width:"100"})):(o(),h(be,{key:1},[a("div",Hn,[e(i,{color:s.value,size:"32"},{default:t(()=>[n(v(m.value),1)]),_:1},8,["color"]),a("div",null,[a("div",{class:ft(["text-h6 font-weight-bold",`text-${s.value}`])},v(u.value),3),a("div",Wn," Bounce-Rate: "+v(f(d.value)),1)])]),e(g,{"model-value":Math.min(d.value*100/5*100,100),color:s.value,rounded:"",height:"6","bg-opacity":"0.2"},null,8,["model-value","color"]),_[0]||(_[0]=a("div",{class:"d-flex justify-space-between text-caption text-medium-emphasis mt-1"},[a("span",null,"0 %"),a("span",null,"2 % Ziel"),a("span",null,"5 %")],-1))],64)),P($).error?(o(),N(x,{key:2,type:"error",variant:"tonal",density:"compact",text:P($).error,class:"mt-3"},null,8,["text"])):U("",!0)]),_:1})]),_:1})}}}),Jn=Me(Zn,[["__scopeId","data-v-257d9a69"]]),Qn={key:0,class:"d-flex align-end justify-space-around",style:{height:"80px"}},Yn={key:1,class:"dashboard-kpi-funnel__chart"},Xn={class:"text-caption text-medium-emphasis dashboard-kpi-funnel__value"},eo={class:"text-caption text-medium-emphasis dashboard-kpi-funnel__label"},to=Ae({__name:"DashboardKpiFunnelAggregate",setup(r){const $=[{label:"Gesendet",key:"sent",color:"#FFFFFF"},{label:"Zugestellt",key:"delivered",color:"#0AC9D4"},{label:"Geöffnet",key:"opened",color:"#0AC9D4"},{label:"Geklickt",key:"clicked",color:"#C9A063"},{label:"Termin",key:"meeting",color:"#E2F54B"}],d=oa(),c=se(()=>{const f=d.kpis;return(f==null?void 0:f.funnelAggregate)??{}}),s=se(()=>{const f=$.map(p=>c.value[p.key]??0);return Math.max(...f,1)});function m(f){const p=c.value[f]??0;return`${Math.max(p/s.value*100,4)}%`}function u(f){return f==null?"0":f>=1e3?`${(f/1e3).toFixed(1)}k`:String(f)}return(f,p)=>{const _=l("v-skeleton-loader"),k=l("v-alert"),i=l("v-card-text"),g=l("v-card");return o(),N(g,{rounded:"lg",class:"dashboard-kpi-funnel"},{default:t(()=>[e(i,{class:"pa-4"},{default:t(()=>[p[0]||(p[0]=a("div",{class:"text-caption text-medium-emphasis mb-3"},"Gesamt-Funnel",-1)),P(d).loading&&!P(d).kpis?(o(),h("div",Qn,[(o(),h(be,null,Pe(5,x=>e(_,{key:x,type:"image",width:"32",height:"60"})),64))])):(o(),h("div",Yn,[(o(),h(be,null,Pe($,x=>a("div",{key:x.key,class:"dashboard-kpi-funnel__step"},[a("div",Xn,v(u(c.value[x.key])),1),a("div",{class:"dashboard-kpi-funnel__bar",style:ht({height:m(x.key),backgroundColor:x.color})},null,4),a("div",eo,v(x.label),1)])),64))])),P(d).error?(o(),N(k,{key:2,type:"error",variant:"tonal",density:"compact",text:P(d).error,class:"mt-3"},null,8,["text"])):U("",!0)]),_:1})]),_:1})}}}),ao=Me(to,[["__scopeId","data-v-3e81d486"]]),lo={class:"d-flex align-center justify-space-between"},no={class:"text-h3 font-weight-bold text-primary"},oo={class:"d-flex align-center justify-space-between"},so={class:"text-h3 font-weight-bold text-secondary"},io={class:"d-flex align-center justify-space-between"},ro={class:"text-h3 font-weight-bold text-warning"},uo={class:"d-flex align-center justify-space-between"},co={class:"text-h3 font-weight-bold text-success"},mo={class:"text-body-2 font-weight-medium"},vo={class:"text-caption text-medium-emphasis"},po={class:"d-flex align-center ga-2"},fo={class:"text-caption font-weight-bold"},go={class:"text-body-2 font-weight-medium"},bo={class:"text-caption text-medium-emphasis"},yo={class:"d-flex align-center ga-2"},_o={key:2,class:"text-body-2 text-medium-emphasis text-center py-4"},ko={class:"d-flex align-center justify-space-between mb-2"},ho={class:"text-body-2 font-weight-medium mb-1"},xo={class:"text-caption text-medium-emphasis"},wo={key:0,class:"mt-2"},So=Ae({__name:"DashboardView",setup(r){const $=oa(),d=xt(),c=y(!0),s=y(!0),m=y(!0),u=y(!0),f=y(null),p=y(null),_=y(null),k=y(null),i=y(0),g=y(0),x=y(0),w=y(0),b=y([]),I=y([]),V=y([]);function E(W){return new Date(W).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}function R(W){return{"blog-post":"primary","landing-page":"secondary","case-study":"info",whitepaper:"warning","social-media":"success",newsletter:"error"}[W]||"default"}function M(W){return{entwurf:"default","in-review":"warning",freigegeben:"info",veroeffentlicht:"success",archiviert:"error"}[W]||"default"}function T(W){return{neu:"default",kontaktiert:"info",qualifiziert:"primary",angebot:"warning",verhandlung:"secondary",gewonnen:"success",verloren:"error"}[W]||"default"}function D(W){return{"azure-openai":"info",anthropic:"secondary",gemini:"success"}[W]||"default"}function H(W){const F=[W.firstName,W.lastName].filter(Boolean);return F.length>0?F.join(" "):W.email}async function O(){var z,j,J,Q;c.value=!0,f.value=null;const[W,F,L,A]=await Promise.all([re.get("/content?limit=1"),re.get("/leads?limit=1"),re.get("/content?limit=1&status=entwurf"),re.get("/content?limit=1&status=veroeffentlicht")]);if(!W.success||!F.success||!L.success||!A.success)f.value="Fehler beim Laden der Statistiken.",ue.error("ADMIN","Dashboard stats loading failed",{content:W.error,leads:F.error,drafts:L.error,published:A.error});else{const te=W.data,ve=F.data,de=L.data,Z=A.data;i.value=((z=te.pagination)==null?void 0:z.total)??0,g.value=((j=ve.pagination)==null?void 0:j.total)??0,x.value=((J=de.pagination)==null?void 0:J.total)??0,w.value=((Q=Z.pagination)==null?void 0:Q.total)??0,ue.debug("ADMIN","Dashboard stats loaded",{content:i.value,leads:g.value})}c.value=!1}async function S(){s.value=!0,p.value=null;const W=await re.get("/content?limit=5&sort=-createdAt");W.success?(b.value=W.data.items??[],ue.debug("ADMIN","Recent content loaded",{count:b.value.length})):(p.value="Fehler beim Laden der Inhalte.",ue.error("ADMIN","Recent content loading failed",W.error)),s.value=!1}async function B(){m.value=!0,_.value=null;const W=await re.get("/leads?limit=5&sort=-createdAt");W.success?(I.value=W.data.items??[],ue.debug("ADMIN","Recent leads loaded",{count:I.value.length})):(_.value="Fehler beim Laden der Leads.",ue.error("ADMIN","Recent leads loading failed",W.error)),m.value=!1}async function G(){u.value=!0,k.value=null;const W=await re.get("/gpt-settings");W.success?(V.value=W.data.items??[],ue.debug("ADMIN","AI providers loaded",{count:V.value.length})):(k.value="Fehler beim Laden der KI-Konfiguration.",ue.error("ADMIN","AI providers loading failed",W.error)),u.value=!1}return rt(()=>{O(),S(),B(),G(),$.fetchDashboardKpis(),$.startPolling()}),Ft(()=>{$.stopPolling()}),(W,F)=>{const L=l("v-alert"),A=l("v-skeleton-loader"),z=l("v-icon"),j=l("v-card-text"),J=l("v-card"),Q=l("v-col"),te=l("v-row"),ve=l("v-btn"),de=l("v-card-title"),Z=l("v-divider"),ce=l("v-chip"),oe=l("v-list-item"),pe=l("v-list"),_e=l("v-avatar"),q=l("v-container");return o(),N(q,{fluid:"",class:"pa-6"},{default:t(()=>[F[20]||(F[20]=a("h1",{class:"text-h4 font-weight-bold mb-6"},"Dashboard",-1)),f.value?(o(),N(L,{key:0,type:"error",variant:"tonal",class:"mb-6",text:f.value},null,8,["text"])):U("",!0),e(te,{class:"mb-6"},{default:t(()=>[e(Q,{cols:"12",sm:"6",lg:"3"},{default:t(()=>[e(J,{class:"dashboard__stat-card",rounded:"lg"},{default:t(()=>[c.value?(o(),N(A,{key:0,type:"list-item-two-line"})):(o(),N(j,{key:1},{default:t(()=>[a("div",lo,[a("div",null,[a("div",no,v(i.value),1),F[3]||(F[3]=a("div",{class:"text-body-2 text-medium-emphasis mt-1"},"Gesamt-Inhalte",-1))]),e(z,{size:"40",color:"primary",opacity:"0.4"},{default:t(()=>[...F[4]||(F[4]=[n("mdi-text-box-multiple",-1)])]),_:1})])]),_:1}))]),_:1})]),_:1}),e(Q,{cols:"12",sm:"6",lg:"3"},{default:t(()=>[e(J,{class:"dashboard__stat-card",rounded:"lg"},{default:t(()=>[c.value?(o(),N(A,{key:0,type:"list-item-two-line"})):(o(),N(j,{key:1},{default:t(()=>[a("div",oo,[a("div",null,[a("div",so,v(g.value),1),F[5]||(F[5]=a("div",{class:"text-body-2 text-medium-emphasis mt-1"},"Gesamt-Leads",-1))]),e(z,{size:"40",color:"secondary",opacity:"0.4"},{default:t(()=>[...F[6]||(F[6]=[n("mdi-account-group",-1)])]),_:1})])]),_:1}))]),_:1})]),_:1}),e(Q,{cols:"12",sm:"6",lg:"3"},{default:t(()=>[e(J,{class:"dashboard__stat-card",rounded:"lg"},{default:t(()=>[c.value?(o(),N(A,{key:0,type:"list-item-two-line"})):(o(),N(j,{key:1},{default:t(()=>[a("div",io,[a("div",null,[a("div",ro,v(x.value),1),F[7]||(F[7]=a("div",{class:"text-body-2 text-medium-emphasis mt-1"},"Entwürfe",-1))]),e(z,{size:"40",color:"warning",opacity:"0.4"},{default:t(()=>[...F[8]||(F[8]=[n("mdi-file-edit-outline",-1)])]),_:1})])]),_:1}))]),_:1})]),_:1}),e(Q,{cols:"12",sm:"6",lg:"3"},{default:t(()=>[e(J,{class:"dashboard__stat-card",rounded:"lg"},{default:t(()=>[c.value?(o(),N(A,{key:0,type:"list-item-two-line"})):(o(),N(j,{key:1},{default:t(()=>[a("div",uo,[a("div",null,[a("div",co,v(w.value),1),F[9]||(F[9]=a("div",{class:"text-body-2 text-medium-emphasis mt-1"},"Veröffentlicht",-1))]),e(z,{size:"40",color:"success",opacity:"0.4"},{default:t(()=>[...F[10]||(F[10]=[n("mdi-check-circle-outline",-1)])]),_:1})])]),_:1}))]),_:1})]),_:1})]),_:1}),e(te,{class:"mb-6"},{default:t(()=>[e(Q,{cols:"12",sm:"6",lg:"4"},{default:t(()=>[e(In)]),_:1}),e(Q,{cols:"12",sm:"6",lg:"4"},{default:t(()=>[e(Ln)]),_:1}),e(Q,{cols:"12",sm:"6",lg:"4"},{default:t(()=>[e(On)]),_:1}),e(Q,{cols:"12",sm:"6",lg:"4"},{default:t(()=>[e(Jn)]),_:1}),e(Q,{cols:"12",sm:"6",lg:"4"},{default:t(()=>[e(ao)]),_:1}),e(Q,{cols:"12",sm:"6",lg:"4"},{default:t(()=>[e(Gn)]),_:1})]),_:1}),e(te,null,{default:t(()=>[e(Q,{cols:"12",lg:"6"},{default:t(()=>[e(J,{rounded:"lg",height:"100%"},{default:t(()=>[e(de,{class:"d-flex align-center justify-space-between pa-4 pb-2"},{default:t(()=>[F[12]||(F[12]=a("span",{class:"text-body-1 font-weight-semibold"},"Neueste Inhalte",-1)),e(ve,{variant:"text",color:"primary",size:"small",onClick:F[0]||(F[0]=C=>P(d).push("/admin/content"))},{default:t(()=>[...F[11]||(F[11]=[n(" Alle anzeigen ",-1)])]),_:1})]),_:1}),e(Z),s.value?(o(),h(be,{key:0},Pe(5,C=>e(A,{key:C,type:"list-item-two-line",class:"px-2"})),64)):p.value?(o(),N(j,{key:1},{default:t(()=>[e(L,{type:"error",variant:"tonal",text:p.value},null,8,["text"])]),_:1})):b.value.length===0?(o(),N(j,{key:2},{default:t(()=>[...F[13]||(F[13]=[a("p",{class:"text-body-2 text-medium-emphasis text-center py-4"}," Noch keine Inhalte vorhanden. ",-1)])]),_:1})):(o(),N(pe,{key:3,density:"comfortable"},{default:t(()=>[(o(!0),h(be,null,Pe(b.value,C=>(o(),N(oe,{key:C._id,to:`/admin/content/${C._id}`,rounded:"0"},{title:t(()=>[a("span",mo,v(C.title),1)]),subtitle:t(()=>[a("span",vo,v(E(C.createdAt)),1)]),append:t(()=>[a("div",po,[e(ce,{color:R(C.type),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(P(ya)[C.type]||C.type),1)]),_:2},1032,["color"]),e(ce,{color:M(C.status),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(P(va)[C.status]||C.status),1)]),_:2},1032,["color"])])]),_:2},1032,["to"]))),128))]),_:1}))]),_:1})]),_:1}),e(Q,{cols:"12",lg:"6"},{default:t(()=>[e(J,{rounded:"lg",height:"100%"},{default:t(()=>[e(de,{class:"d-flex align-center justify-space-between pa-4 pb-2"},{default:t(()=>[F[15]||(F[15]=a("span",{class:"text-body-1 font-weight-semibold"},"Neueste Leads",-1)),e(ve,{variant:"text",color:"primary",size:"small",onClick:F[1]||(F[1]=C=>P(d).push("/admin/leads"))},{default:t(()=>[...F[14]||(F[14]=[n(" Alle anzeigen ",-1)])]),_:1})]),_:1}),e(Z),m.value?(o(),h(be,{key:0},Pe(5,C=>e(A,{key:C,type:"list-item-two-line",class:"px-2"})),64)):_.value?(o(),N(j,{key:1},{default:t(()=>[e(L,{type:"error",variant:"tonal",text:_.value},null,8,["text"])]),_:1})):I.value.length===0?(o(),N(j,{key:2},{default:t(()=>[...F[16]||(F[16]=[a("p",{class:"text-body-2 text-medium-emphasis text-center py-4"}," Noch keine Leads vorhanden. ",-1)])]),_:1})):(o(),N(pe,{key:3,density:"comfortable"},{default:t(()=>[(o(!0),h(be,null,Pe(I.value,C=>(o(),N(oe,{key:C._id,to:`/admin/leads/${C._id}`,rounded:"0"},{prepend:t(()=>[e(_e,{color:"primary",size:"36",class:"mr-2"},{default:t(()=>[a("span",fo,v((C.firstName||C.email).charAt(0).toUpperCase()),1)]),_:2},1024)]),title:t(()=>[a("span",go,v(H(C)),1)]),subtitle:t(()=>[a("span",bo,v(C.email),1)]),append:t(()=>[a("div",yo,[e(ce,{color:T(C.pipeline.stage),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(P(na)[C.pipeline.stage]||C.pipeline.stage),1)]),_:2},1032,["color"])])]),_:2},1032,["to"]))),128))]),_:1}))]),_:1})]),_:1}),e(Q,{cols:"12"},{default:t(()=>[e(J,{rounded:"lg"},{default:t(()=>[e(de,{class:"d-flex align-center justify-space-between pa-4 pb-2"},{default:t(()=>[F[18]||(F[18]=a("span",{class:"text-body-1 font-weight-semibold"},"KI-Status",-1)),e(ve,{variant:"text",color:"primary",size:"small",onClick:F[2]||(F[2]=C=>P(d).push("/admin/ki-einstellungen"))},{default:t(()=>[...F[17]||(F[17]=[n(" Konfigurieren ",-1)])]),_:1})]),_:1}),e(Z),e(j,null,{default:t(()=>[u.value?(o(),N(te,{key:0},{default:t(()=>[(o(),h(be,null,Pe(3,C=>e(Q,{key:C,cols:"12",sm:"4"},{default:t(()=>[e(A,{type:"card"})]),_:1})),64))]),_:1})):k.value?(o(),N(L,{key:1,type:"error",variant:"tonal",text:k.value},null,8,["text"])):V.value.length===0?(o(),h("p",_o," Keine KI-Provider konfiguriert. ")):(o(),N(te,{key:3},{default:t(()=>[(o(!0),h(be,null,Pe(V.value,C=>(o(),N(Q,{key:C._id,cols:"12",sm:"6",lg:"4"},{default:t(()=>[e(J,{variant:"outlined",rounded:"lg",class:ft({"dashboard__ai-card--active":C.isActive})},{default:t(()=>[e(j,{class:"pa-4"},{default:t(()=>[a("div",ko,[e(ce,{color:D(C.provider),size:"small",variant:"tonal"},{default:t(()=>[n(v(P(cl)[C.provider]||C.provider),1)]),_:2},1032,["color"]),e(ce,{color:C.isActive?"success":"default",size:"x-small",variant:"tonal"},{default:t(()=>[n(v(C.isActive?"Aktiv":"Inaktiv"),1)]),_:2},1032,["color"])]),a("div",ho,v(C.name),1),a("div",xo,"Modell: "+v(C.model),1),C.isDefault?(o(),h("div",wo,[e(ce,{color:"secondary",size:"x-small",variant:"tonal"},{default:t(()=>[...F[19]||(F[19]=[n("Standard",-1)])]),_:1})])):U("",!0)]),_:2},1024)]),_:2},1032,["class"])]),_:2},1024))),128))]),_:1}))]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})}}}),$o=Me(So,[["__scopeId","data-v-12ea3329"]]),u6=Object.freeze(Object.defineProperty({__proto__:null,default:$o},Symbol.toStringTag,{value:"Module"})),Jt=Zt("pages",()=>{const r=y([]),$=y(null),d=y(-1),c=y(localStorage.getItem("basec_editor_mode")||"simple"),s=y(!1),m=y(!1),u=y(null),f=y([]),p=y([]),_=y(""),k=y(!1),i=y({}),g=se(()=>!$.value||d.value<0?null:$.value.content[d.value]||null),x=se(()=>$.value?JSON.stringify($.value.content)!==_.value:!1),w=se(()=>{var C;return((C=$.value)==null?void 0:C.content.length)||0});async function b(C){s.value=!0,u.value=null;try{const ae=new URLSearchParams;C!=null&&C.category&&ae.set("category",C.category),C!=null&&C.status&&ae.set("status",C.status),C!=null&&C.search&&ae.set("search",C.search),C!=null&&C.onlyMine&&ae.set("onlyMine","true");const X=ae.toString(),ie=await re.get(`/admin/pages${X?"?"+X:""}`);ie.success&&ie.data?r.value=ie.data:u.value=ie.error||"Fehler beim Laden der Seiten"}finally{s.value=!1}}async function I(C){s.value=!0,u.value=null;try{const ae=await re.get(`/admin/pages/${C}`);ae.success&&ae.data?($.value=ae.data,d.value=ae.data.content.length>0?0:-1,_.value=JSON.stringify(ae.data.content),f.value=[],p.value=[]):u.value=ae.error||"Fehler beim Laden der Seite"}finally{s.value=!1}}async function V(){if($.value){m.value=!0,u.value=null;try{const C=await re.put(`/admin/pages/${$.value._id}`,{title:$.value.title,slug:$.value.slug,path:$.value.path,content:$.value.content,seo:$.value.seo,navigation:$.value.navigation,template:$.value.template,category:$.value.category});if(C.success&&C.data){const{rewrittenPages:ae,...X}=C.data;return $.value=X,_.value=JSON.stringify(X.content),{rewrittenPages:ae}}else u.value=C.error||"Fehler beim Speichern"}finally{m.value=!1}return null}}async function E(C){var ae;if(!$.value)return{success:!1};u.value=null;try{const X=await re.patch(`/admin/pages/${$.value._id}/settings`,C);return X.success?{success:!0,rewrittenPages:(ae=X.data)==null?void 0:ae.rewrittenPages}:{success:!1}}catch{return{success:!1}}}async function R(C){s.value=!0,u.value=null;try{const ae=await re.post("/admin/pages",C);return ae.success&&ae.data?ae.data:(u.value=ae.error||"Fehler beim Erstellen",null)}finally{s.value=!1}}async function M(C){u.value=null;const ae=await re.delete(`/admin/pages/${C}`);return ae.success||(u.value=ae.error||"Fehler beim Löschen"),ae.success}async function T(C,ae){u.value=null;const X=ae??{},ie=await re.post(`/admin/pages/${C}/duplicate`,X);return ie.success&&ie.data?ie.data:(u.value=ie.error||"Fehler beim Duplizieren",null)}async function D(C,ae){var ie;u.value=null;const X=await re.patch(`/admin/pages/${C}/status`,{status:ae});if(X.success&&X.data){const fe=r.value.findIndex(Se=>Se._id===C);return fe>=0&&(r.value[fe].status=ae),((ie=$.value)==null?void 0:ie._id)===C&&($.value=X.data),!0}return u.value=X.error||"Fehler beim Statuswechsel",!1}async function H(C,ae){u.value=null;const X=await re.patch("/admin/pages/bulk/status",{ids:C,status:ae});if(X.success){for(const ie of C){const fe=r.value.findIndex(Se=>Se._id===ie);fe>=0&&(r.value[fe].status=ae)}return!0}return u.value=X.error||"Fehler bei Bulk-Statusänderung",!1}function O(){$.value&&(f.value.push(JSON.parse(JSON.stringify($.value.content))),p.value=[])}function S(C){d.value=C}function B(C,ae){!$.value||!$.value.content[C]||(O(),Object.assign($.value.content[C],ae))}function G(C,ae){if(!$.value)return;O();const[X]=$.value.content.splice(C,1);$.value.content.splice(ae,0,X),$.value.content.forEach((ie,fe)=>{ie.order=fe}),d.value===C&&(d.value=ae)}function W(C,ae){if(!$.value)return;O();const X=C.toUpperCase().replace(/-/g,"_"),ie=$.value.content.filter(ee=>ee.type===C&&ee.name).map(ee=>{const Y=ee.name.match(/_(\d+)$/);return Y?parseInt(Y[1],10):0}),fe=ie.length>0?Math.max(...ie)+1:1,me={name:`${X}_${fe}`,type:C,title:"",content:"",order:ae,settings:{},sectionId:`sec_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,visibility:{desktop:!0,tablet:!0,mobile:!0}};$.value.content.splice(ae,0,me),$.value.content.forEach((ee,Y)=>{ee.order=Y}),d.value=ae}function F(C){!$.value||!$.value.content[C]||(O(),$.value.content.splice(C,1),$.value.content.forEach((ae,X)=>{ae.order=X}),d.value>=$.value.content.length&&(d.value=$.value.content.length-1))}function L(){!$.value||f.value.length===0||(p.value.push(JSON.parse(JSON.stringify($.value.content))),$.value.content=f.value.pop())}function A(){!$.value||p.value.length===0||(f.value.push(JSON.parse(JSON.stringify($.value.content))),$.value.content=p.value.pop())}function z(C){c.value=C,localStorage.setItem("basec_editor_mode",C)}async function j(C,ae,X,ie){if(!$.value)return;const fe=$.value.content[C];if(!fe)return;const Se=fe[ae]||"",me=`${C}.${ae}`;k.value=!0,u.value=null;try{const ee=await re.post("/admin/ai/refine",{pageId:$.value._id,sectionIndex:C,fieldName:ae,originalText:Se,action:X,customInstruction:ie});ee.success&&ee.data?i.value={...i.value,[me]:{originalText:Se,suggestedText:ee.data.suggestedText,provider:ee.data.provider}}:u.value=ee.error||"KI-Verfeinerung fehlgeschlagen"}finally{k.value=!1}}async function J(C,ae){var X;if($.value){k.value=!0,u.value=null;try{const ie=await re.post("/admin/ai/page-refine",{pageId:$.value._id,instruction:C,knowledgeBaseIds:ae});ie.success&&((X=ie.data)!=null&&X.suggestions)?i.value=ie.data.suggestions:u.value=ie.error||"Seitenweite KI-Optimierung fehlgeschlagen"}finally{k.value=!1}}}function Q(C,ae,X){if(!$.value)return;const ie=$.value.content[C];if(!ie)return;O(),ie[ae]=X;const fe=`${C}.${ae}`,{[fe]:Se,...me}=i.value;i.value=me}function te(C){const{[C]:ae,...X}=i.value;i.value=X}function ve(){i.value={}}async function de(C,ae){var ie;u.value=null;const X=await re.post(`/admin/pages/${C}/versions/${ae}/restore`,{});return X.success&&X.data?(((ie=$.value)==null?void 0:ie._id)===C&&($.value=X.data,_.value=JSON.stringify(X.data.content)),X.data):(u.value=X.error||"Fehler beim Wiederherstellen der Version",null)}async function Z(C,ae,X){var fe;u.value=null;const ie=await re.patch(`/admin/pages/${C}/versions/${ae}`,{userLabel:X});if(ie.success){if(((fe=$.value)==null?void 0:fe._id)===C){const Se=$.value.draftVersions.find(me=>me.versionId===ae);Se&&(Se.userLabel=X)}return!0}return u.value=ie.error||"Fehler beim Speichern der Beschreibung",!1}async function ce(C,ae){var ie;u.value=null;const X=await re.delete(`/admin/pages/${C}/versions/${ae}`);return X.success?(((ie=$.value)==null?void 0:ie._id)===C&&($.value.draftVersions=$.value.draftVersions.filter(fe=>fe.versionId!==ae)),!0):(u.value=X.error||"Fehler beim Löschen der Version",!1)}async function oe(C){const ae=await re.get(`/admin/pages/${C}/chat/pending`);return ae.success&&ae.data?ae.data:null}async function pe(C){var ie;u.value=null;const ae=await re.post(`/admin/pages/${C}/chat/apply-pending`,{});if(ae.success&&ae.data)return((ie=$.value)==null?void 0:ie._id)===C&&($.value=ae.data,_.value=JSON.stringify(ae.data.content)),{data:ae.data,status:ae.status};const X=ae.error||"Fehler beim Übernehmen der KI-Änderungen";return u.value=X,{data:null,status:ae.status,error:X}}async function _e(C){u.value=null;const ae=await re.post(`/admin/pages/${C}/chat/discard-pending`,{});return ae.success||(u.value=ae.error||"Fehler beim Verwerfen der KI-Änderungen"),ae.success}async function q(C){var X;u.value=null;const ae=await re.delete(`/admin/pages/${C}/versions`);return ae.success?(((X=$.value)==null?void 0:X._id)===C&&await I(C),!0):(u.value=ae.error||"Fehler beim Löschen aller Versionen",!1)}return{pages:r,currentPage:$,selectedSectionIndex:d,editorMode:c,loading:s,saving:m,error:u,selectedSection:g,isDirty:x,moduleCount:w,aiLoading:k,aiSuggestions:i,fetchPages:b,fetchPage:I,savePage:V,saveSettings:E,createPage:R,deletePage:M,duplicatePage:T,updateStatus:D,bulkUpdateStatus:H,selectSection:S,updateSectionProps:B,moveSection:G,addSection:W,removeSection:F,undo:L,redo:A,setEditorMode:z,refineField:j,refinePageTexts:J,applySuggestion:Q,clearSuggestion:te,clearSuggestions:ve,restoreVersion:de,updateVersionLabel:Z,deleteVersion:ce,deleteAllVersions:q,fetchPendingChanges:oe,applyPendingChanges:pe,discardPendingChanges:_e}}),Co={key:0,class:"user-avatar-chip-empty text-medium-emphasis"},Vo={class:"text-caption font-weight-bold"},Ao=Ae({__name:"UserAvatarChip",props:{userId:{},populated:{default:null},size:{default:28},locked:{type:Boolean,default:!1},lockedBy:{default:null}},setup(r){const $=r,d=Ma(),c=se(()=>{if($.locked&&$.lockedBy&&$.lockedBy.firstName&&$.lockedBy.lastName)return $.lockedBy;if($.populated&&$.populated.firstName&&$.populated.lastName)return $.populated;const u=$.userId;if(u&&typeof u=="object"){const f=u;if(f.firstName&&f.lastName)return f}return typeof u=="string"?d.getUserById(u):null}),s=se(()=>{var p,_;if(!c.value)return"";const u=((p=c.value.firstName)==null?void 0:p[0])??"",f=((_=c.value.lastName)==null?void 0:_[0])??"";return(u+f).toUpperCase()}),m=se(()=>{if($.locked&&c.value)return`Wird gerade von ${`${c.value.firstName} ${c.value.lastName}`} bearbeitet`;if(!c.value)return"Vor Tracking-Feature angelegt";const u=`${c.value.firstName} ${c.value.lastName}`,f=c.value.email??"",p=c.value.isActive;let _=f?`${u} · ${f}`:u;return p===!1&&(_+=" (deaktiviert)"),_});return(u,f)=>{const p=l("v-avatar"),_=l("v-icon"),k=l("v-tooltip");return c.value?(o(),N(k,{key:1,text:m.value,location:"top"},{activator:t(({props:i})=>[a("div",{class:ft(["user-avatar-chip-wrapper",{"user-avatar-chip-wrapper--locked":r.locked}])},[e(p,Vt(i,{size:r.size,color:"primary",class:["user-avatar-chip",{"user-avatar-chip--locked":r.locked}]}),{default:t(()=>[a("span",Vo,v(s.value),1)]),_:1},16,["size","class"]),r.locked?(o(),N(_,{key:0,icon:"mdi-lock",size:"12",class:"lock-overlay"})):U("",!0)],2)]),_:1},8,["text"])):(o(),h("span",Co,"-"))}}}),gt=Me(Ao,[["__scopeId","data-v-84c3b6fb"]]),Io={class:"pa-6"},Po={class:"d-flex align-center justify-space-between mb-6"},zo={class:"d-flex align-center ga-2"},Do={class:"d-flex flex-wrap ga-3 align-center"},To={class:"text-body-2 font-weight-medium"},Lo={class:"text-subtitle-1 font-weight-semibold"},Eo={key:2,class:"pa-4 pt-2"},Mo=["onClick"],No={class:"font-weight-medium"},Uo={class:"text-caption text-medium-emphasis"},Bo={key:0,class:"text-body-2 text-medium-emphasis mb-4"},Fo={class:"text-caption"},Oo=Ae({__name:"PagesListView",setup(r){const $=xt(),d=Jt(),c=ea(),s=y(""),m=qe("pages_filter_category",null),u=qe("pages_filter_status",null),f=qe("pages_only_mine",!1),p=qe("pages_items_per_page",20),_=qe("pages_list_sort",[]),k=qe("pages_view_mode","table"),i=qe("pages_tree_sort","hierarchy");let g;const x=y([]),w=y(null),b=y(!1),I=y(!1),V=se(()=>d.pages.length>0&&x.value.length===d.pages.length),E=se(()=>x.value.length>0&&x.value.length<d.pages.length);function R(){V.value?x.value=[]:x.value=d.pages.map(Te=>Te._id)}function M(Te){const ye=x.value.indexOf(Te);ye>=0?x.value.splice(ye,1):x.value.push(Te)}function T(){!w.value||x.value.length===0||(b.value=!0)}async function D(){if(!w.value)return;I.value=!0;const Te=await d.bulkUpdateStatus(x.value,w.value);I.value=!1,b.value=!1,Te&&(x.value=[],w.value=null)}const H=["BaseCompliance","BaseConsulting","BaseCyber","Branchen","Allgemein","Legal","Blog","Landing Pages"],O=se(()=>{const Te=d.pages.map(ye=>ye.category).filter(Boolean);return[...new Set([...H,...Te])].sort()}),S=[{title:"Alle",value:null},{title:"Published",value:"published"},{title:"Draft",value:"draft"},{title:"In Review",value:"in-review"},{title:"Archiviert",value:"archived"}],B=[{title:"Published",value:"published"},{title:"Draft",value:"draft"},{title:"In Review",value:"in-review"},{title:"Archiviert",value:"archived"}],G=[{title:"Homepage",value:"homepage"},{title:"Service",value:"service"},{title:"Branche",value:"branch"},{title:"Über uns",value:"about"},{title:"Kontakt",value:"contact"},{title:"Blog",value:"blog"},{title:"Blog Post",value:"blog-post"},{title:"Legal",value:"legal"},{title:"Landing Page",value:"landing"},{title:"College",value:"college"}],W=[{title:"",key:"select",sortable:!1,width:"48px"},{title:"Seite",key:"title",sortable:!0},{title:"Pfad",key:"path",sortable:!0},{title:"Kategorie",key:"category",sortable:!0},{title:"Status",key:"status",sortable:!0},{title:"Module",key:"moduleCount",sortable:!0,align:"center"},{title:"Aktualisiert",key:"updatedAt",sortable:!0},{title:"Erstellt",key:"createdBy",sortable:!1,width:80,align:"center"},{title:"Geändert",key:"updatedBy",sortable:!1,width:80,align:"center"},{title:"",key:"actions",sortable:!1,width:56,align:"center"}],F=y(!1),L=y(!1),A=y(null),z=y("copy"),j=y(""),J=y(""),Q=y(!1),te=y(""),ve=y(!1),de=y(""),Z=y("success");function ce(Te){A.value=Te,z.value="copy",oe(),F.value=!0}function oe(){if(!A.value)return;const Te=A.value;z.value==="variant"?(j.value=`${Te.title} - Variante`,J.value=`${Te.slug}-variante`,Q.value=!0,te.value=Te.slug):(j.value=`${Te.title} (Kopie)`,J.value=`${Te.slug}-kopie`,Q.value=!1,te.value="")}Ze(z,()=>oe());async function pe(){if(!A.value)return;L.value=!0;const Te={mode:z.value,title:j.value.trim()||void 0,slug:J.value.trim()||void 0,noindex:Q.value};z.value==="variant"&&(Te.canonical=te.value.trim()||void 0);const ye=await d.duplicatePage(A.value._id,Te);L.value=!1,ye?(F.value=!1,de.value="Seite dupliziert - wirst zum Editor weitergeleitet",Z.value="success",ve.value=!0,$.push({name:"admin-page-edit",params:{id:ye._id}})):(de.value=d.error||"Fehler beim Duplizieren",Z.value="error",ve.value=!0)}const _e=y(!1),q=y({title:"",slug:"",path:"",template:"service",category:"",parentId:null}),C=se(()=>d.pages.map(Te=>({title:`${Te.title} (${Te.path})`,value:Te._id})));function ae(Te){return Te.toLowerCase().replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/ü/g,"ue").replace(/ß/g,"ss").replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function X(Te,ye){if(ye){const Je=d.pages.find(Ke=>Ke._id===ye);if(Je)return`${Je.path}/${Te}`}return`/${Te}`}Ze(()=>q.value.title,Te=>{const ye=ae(Te);q.value.slug=ye,q.value.path=X(ye,q.value.parentId)}),Ze(()=>q.value.slug,Te=>{Te&&(q.value.path=X(Te,q.value.parentId))}),Ze(()=>q.value.parentId,Te=>{q.value.slug&&(q.value.path=X(q.value.slug,Te))});function ie(){d.fetchPages({category:m.value||void 0,status:u.value||void 0,search:s.value||void 0,onlyMine:f.value||void 0})}function fe(Te){clearTimeout(g),g=setTimeout(()=>{s.value=Te,ie()},300)}function Se(Te,ye){$.push({name:"admin-page-edit",params:{id:ye.item._id}})}function me(Te){$.push({name:"admin-page-edit",params:{id:Te}})}async function ee(){const{parentId:Te,...ye}=q.value,Je=await d.createPage({...ye,navigation:Te?{parentId:Te}:void 0});Je&&(_e.value=!1,q.value={title:"",slug:"",path:"",template:"service",category:"",parentId:null},$.push({name:"admin-page-edit",params:{id:Je._id}}))}function Y(Te){return Te?typeof Te=="string"?Te:Te._id??null:null}function K(Te){return!Te||typeof Te=="string"?null:Te.firstName?Te:null}function le(Te){return!Te.lockedBy||!Te.lockHeartbeatAt?!1:Date.now()-new Date(Te.lockHeartbeatAt).getTime()<90*1e3}function ne(Te){switch(Te){case"published":return"success";case"draft":return"warning";case"in-review":return"info";case"archived":return"default";default:return"default"}}function Ce(Te){switch(Te){case"published":return"Published";case"draft":return"Draft";case"in-review":return"In Review";case"archived":return"Archiviert";default:return Te}}function ke(Te){return Te?new Date(Te).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"-"}function xe(Te,ye){const Je=[...Te];ye==="updated-desc"?Je.sort((Ke,$e)=>($e.updatedAt||"").localeCompare(Ke.updatedAt||"")):ye==="updated-asc"?Je.sort((Ke,$e)=>(Ke.updatedAt||"").localeCompare($e.updatedAt||"")):Je.sort((Ke,$e)=>Ke.navOrder-$e.navOrder||Ke.title.localeCompare($e.title));for(const Ke of Je)Ke.children.length>0&&(Ke.children=xe(Ke.children,ye));return Je}const Ne=se(()=>{var lt,ut;const Te=d.pages;if(Te.length===0)return[];const ye=new Map,Je=new Map;for(const Ve of Te){const Le={id:Ve._id,_id:Ve._id,title:Ve.title,path:Ve.path,status:Ve.status,category:Ve.category,moduleCount:Ve.moduleCount,updatedAt:Ve.updatedAt,navOrder:((lt=Ve.navigation)==null?void 0:lt.order)??50,isPage:!0,children:[]};ye.set(Ve._id,Le),Je.set(Ve.path,Le)}const Ke={id:"__group_landing",title:"Landing Pages",path:"/lp",navOrder:-1,isPage:!1,children:[]},$e=[];for(const Ve of Te){const Le=ye.get(Ve._id),Ye=(ut=Ve.navigation)==null?void 0:ut.parentId;if(Ye&&ye.has(Ye))ye.get(Ye).children.push(Le);else if(Ye)$e.push(Le);else if(Ve.path.startsWith("/lp/")||Ve.path.startsWith("/landing/")||Ve.template==="landing"){const ct=Ve.updatedAt||"",Fe=ct?new Date(ct):new Date,Xe=Fe.getFullYear(),mt=String(Fe.getMonth()+1).padStart(2,"0"),nt=`${Xe}/${mt}`;let He=Ke.children.find(St=>St.id===`__lp_${nt}`);He||(He={id:`__lp_${nt}`,title:nt,path:`/lp/${nt}`,navOrder:-(Xe*100+parseInt(mt)),isPage:!1,children:[]},Ke.children.push(He)),He.children.push(Le)}else{const ct=Ve.path.replace(/\/[^/]+$/,"")||"/";ct!==Ve.path&&ct!==""&&Je.has(ct)?Je.get(ct).children.push(Le):$e.push(Le)}}for(const Ve of Ke.children)Ve.isPage||(Ve.title=`${Ve.title} (${Ve.children.length})`);const Ee=Ke.children.reduce((Ve,Le)=>Ve+(Le.isPage?1:Le.children.length),0);return Ee>0&&(Ke.title=`Landing Pages (${Ee})`),Ke.children.length>0&&$e.unshift(Ke),xe($e,i.value)}),Ie=qe("pages_tree_open_ids",[]),Ue=qe("pages_tree_initialized",!1);return Ze(Ne,Te=>{if(Te.length>0&&!Ue.value){const ye=Je=>{const Ke=[];for(const $e of Je)$e.children.length>0&&(Ke.push($e.id),Ke.push(...ye($e.children)));return Ke};Ie.value=ye(Te),Ue.value=!0}},{immediate:!0}),Ze(k,()=>{x.value=[]}),rt(()=>ie()),Ze([m,u,f],()=>ie()),(Te,ye)=>{const Je=l("v-chip"),Ke=l("v-btn"),$e=l("v-text-field"),Ee=l("v-chip-group"),lt=l("v-select"),ut=l("v-spacer"),Ve=l("v-icon"),Le=l("v-btn-toggle"),Ye=l("v-card-text"),ct=l("v-card"),Fe=l("v-checkbox"),Xe=l("v-list-item-title"),mt=l("v-list-item"),nt=l("v-list"),He=l("v-menu"),St=l("v-data-table"),Pt=l("v-card-title"),Dt=l("v-progress-circular"),_t=l("v-treeview"),Re=l("v-card-actions"),ge=l("v-dialog"),at=l("v-autocomplete"),et=l("v-combobox"),it=l("v-radio"),$t=l("v-radio-group"),yt=l("v-snackbar");return o(),h("div",Io,[a("div",Po,[ye[35]||(ye[35]=a("h1",{class:"text-h5 font-weight-bold"},"Seiten",-1)),a("div",zo,[e(Je,{color:P(f)?"primary":"",variant:P(f)?"flat":"outlined","prepend-icon":"mdi-account-filter",onClick:ye[0]||(ye[0]=We=>f.value=!P(f))},{default:t(()=>[...ye[33]||(ye[33]=[n(" Nur meine ",-1)])]),_:1},8,["color","variant"]),P(c).userRole==="admin"?(o(),N(Ke,{key:0,color:"primary","prepend-icon":"mdi-plus",onClick:ye[1]||(ye[1]=We=>_e.value=!0)},{default:t(()=>[...ye[34]||(ye[34]=[n(" Neue Seite ",-1)])]),_:1})):U("",!0)])]),e(ct,{class:"mb-4",variant:"outlined"},{default:t(()=>[e(Ye,null,{default:t(()=>[a("div",Do,[e($e,{"model-value":s.value,placeholder:"Suche nach Titel oder Slug...","prepend-inner-icon":"mdi-magnify",density:"compact",variant:"outlined","hide-details":"",clearable:"",style:{"max-width":"300px"},"onUpdate:modelValue":fe},null,8,["model-value"]),e(Ee,{modelValue:P(m),"onUpdate:modelValue":ye[2]||(ye[2]=We=>ot(m)?m.value=We:null),"selected-class":"text-primary"},{default:t(()=>[(o(!0),h(be,null,Pe(O.value,We=>(o(),N(Je,{key:We,value:We,filter:"",variant:"outlined",size:"small"},{default:t(()=>[n(v(We),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"]),e(lt,{modelValue:P(u),"onUpdate:modelValue":ye[3]||(ye[3]=We=>ot(u)?u.value=We:null),items:S,"item-title":"title","item-value":"value",density:"compact",variant:"outlined","hide-details":"",label:"Status",clearable:"",style:{"max-width":"160px"}},null,8,["modelValue"]),e(ut),e(Le,{modelValue:P(k),"onUpdate:modelValue":ye[4]||(ye[4]=We=>ot(k)?k.value=We:null),mandatory:"",density:"compact",variant:"outlined"},{default:t(()=>[e(Ke,{value:"table",size:"small",color:P(k)==="table"?"primary":void 0},{default:t(()=>[e(Ve,{size:"24"},{default:t(()=>[...ye[36]||(ye[36]=[n("mdi-table",-1)])]),_:1})]),_:1},8,["color"]),e(Ke,{value:"tree",size:"small",color:P(k)==="tree"?"primary":void 0},{default:t(()=>[e(Ve,{size:"24"},{default:t(()=>[...ye[37]||(ye[37]=[n("mdi-file-tree",-1)])]),_:1})]),_:1},8,["color"])]),_:1},8,["modelValue"])])]),_:1})]),_:1}),x.value.length>0?(o(),N(ct,{key:0,class:"mb-4",variant:"tonal",color:"primary"},{default:t(()=>[e(Ye,{class:"d-flex align-center ga-3 py-2"},{default:t(()=>[a("span",To,v(x.value.length)+" Seite(n) ausgewählt ",1),e(lt,{modelValue:w.value,"onUpdate:modelValue":ye[5]||(ye[5]=We=>w.value=We),items:B,"item-title":"title","item-value":"value",density:"compact",variant:"outlined","hide-details":"",label:"Neuer Status",style:{"max-width":"180px"}},null,8,["modelValue"]),e(Ke,{color:"primary",size:"small",variant:"elevated",disabled:!w.value,onClick:T},{default:t(()=>[...ye[38]||(ye[38]=[n(" Status ändern ",-1)])]),_:1},8,["disabled"]),e(Ke,{variant:"text",size:"small",onClick:ye[6]||(ye[6]=We=>{x.value=[],w.value=null})},{default:t(()=>[...ye[39]||(ye[39]=[n(" Auswahl aufheben ",-1)])]),_:1})]),_:1})]),_:1})):U("",!0),P(k)==="table"?(o(),N(ct,{key:1,variant:"outlined"},{default:t(()=>[e(St,{headers:W,items:P(d).pages,loading:P(d).loading,"items-per-page":P(p),"onUpdate:itemsPerPage":ye[9]||(ye[9]=We=>ot(p)?p.value=We:null),"sort-by":P(_),"onUpdate:sortBy":ye[10]||(ye[10]=We=>_.value=We),"item-value":"_id",hover:"",class:"cursor-pointer","onClick:row":Se},{"item.select":t(({item:We})=>[e(Fe,{"model-value":x.value.includes(We._id),"hide-details":"",density:"compact",onClick:ye[7]||(ye[7]=dt(()=>{},["stop"])),"onUpdate:modelValue":Qe=>M(We._id)},null,8,["model-value","onUpdate:modelValue"])]),"header.select":t(()=>[e(Fe,{"model-value":V.value,indeterminate:E.value,"hide-details":"",density:"compact","onUpdate:modelValue":R},null,8,["model-value","indeterminate"])]),"item.status":t(({item:We})=>[e(Je,{color:ne(We.status),size:"small",label:""},{default:t(()=>[n(v(Ce(We.status)),1)]),_:2},1032,["color"])]),"item.updatedAt":t(({item:We})=>[n(v(ke(We.updatedAt)),1)]),"item.createdBy":t(({item:We})=>[e(gt,{"user-id":Y(We.createdBy),populated:K(We.createdBy),locked:le(We),"locked-by":K(We.lockedBy)},null,8,["user-id","populated","locked","locked-by"])]),"item.updatedBy":t(({item:We})=>[e(gt,{"user-id":Y(We.updatedBy),populated:K(We.updatedBy),locked:le(We),"locked-by":K(We.lockedBy)},null,8,["user-id","populated","locked","locked-by"])]),"item.actions":t(({item:We})=>[e(He,null,{activator:t(({props:Qe})=>[e(Ke,Vt({icon:"",size:"small",variant:"text"},Qe,{onClick:ye[8]||(ye[8]=dt(()=>{},["stop"]))}),{default:t(()=>[e(Ve,null,{default:t(()=>[...ye[40]||(ye[40]=[n("mdi-dots-vertical",-1)])]),_:1})]),_:1},16)]),default:t(()=>[e(nt,{density:"compact"},{default:t(()=>[P(c).userRole==="admin"?(o(),N(mt,{key:0,"prepend-icon":"mdi-content-duplicate",onClick:dt(Qe=>ce({_id:We._id,title:We.title,slug:We.slug,path:We.path}),["stop"])},{default:t(()=>[e(Xe,null,{default:t(()=>[...ye[41]||(ye[41]=[n("Duplizieren...",-1)])]),_:1})]),_:1},8,["onClick"])):U("",!0)]),_:2},1024)]),_:2},1024)]),"no-data":t(()=>[...ye[42]||(ye[42]=[a("div",{class:"text-center py-8 text-medium-emphasis"}," Keine Seiten gefunden ",-1)])]),_:1},8,["items","loading","items-per-page","sort-by"])]),_:1})):U("",!0),P(k)==="tree"?(o(),N(ct,{key:2,variant:"outlined"},{default:t(()=>[e(Pt,{class:"d-flex align-center justify-space-between pa-4 pb-0"},{default:t(()=>[a("span",Lo,v(P(d).pages.length)+" Seiten ",1),e(Le,{modelValue:P(i),"onUpdate:modelValue":ye[11]||(ye[11]=We=>ot(i)?i.value=We:null),mandatory:"",density:"compact",variant:"outlined"},{default:t(()=>[e(Ke,{value:"hierarchy",size:"small"},{default:t(()=>[e(Ve,{size:"18",start:""},{default:t(()=>[...ye[43]||(ye[43]=[n("mdi-sort-numeric-ascending",-1)])]),_:1}),ye[44]||(ye[44]=n(" Hierarchie ",-1))]),_:1}),e(Ke,{value:"updated-desc",size:"small"},{default:t(()=>[e(Ve,{size:"18",start:""},{default:t(()=>[...ye[45]||(ye[45]=[n("mdi-sort-clock-descending-outline",-1)])]),_:1}),ye[46]||(ye[46]=n(" Neueste ",-1))]),_:1}),e(Ke,{value:"updated-asc",size:"small"},{default:t(()=>[e(Ve,{size:"18",start:""},{default:t(()=>[...ye[47]||(ye[47]=[n("mdi-sort-clock-ascending-outline",-1)])]),_:1}),ye[48]||(ye[48]=n(" Älteste ",-1))]),_:1})]),_:1},8,["modelValue"])]),_:1}),P(d).loading?(o(),N(Ye,{key:0,class:"text-center py-8"},{default:t(()=>[e(Dt,{indeterminate:"",color:"primary"})]),_:1})):Ne.value.length===0?(o(),N(Ye,{key:1,class:"text-center py-8 text-medium-emphasis"},{default:t(()=>[...ye[49]||(ye[49]=[n(" Keine Seiten gefunden ",-1)])]),_:1})):(o(),h("div",Eo,[e(_t,{opened:P(Ie),"onUpdate:opened":ye[13]||(ye[13]=We=>ot(Ie)?Ie.value=We:null),items:Ne.value,"item-value":"id","item-children":"children","open-on-click":"",activatable:"",density:"compact"},{prepend:t(({item:We})=>[We.isPage&&We._id?(o(),N(Fe,{key:0,"model-value":x.value.includes(We._id),"hide-details":"",density:"compact",class:"mr-1",onClick:ye[12]||(ye[12]=dt(()=>{},["stop"])),"onUpdate:modelValue":Qe=>M(We._id)},null,8,["model-value","onUpdate:modelValue"])):U("",!0)]),title:t(({item:We})=>[a("div",{class:"d-flex align-center ga-2 tree-item",onClick:dt(Qe=>We.isPage&&We._id&&me(We._id),["stop"])},[a("span",No,v(We.title),1),We.status?(o(),N(Je,{key:0,color:ne(We.status),size:"x-small",label:""},{default:t(()=>[n(v(Ce(We.status)),1)]),_:2},1032,["color"])):U("",!0),a("span",Uo,v(We.path),1)],8,Mo)]),_:1},8,["opened","items"])]))]),_:1})):U("",!0),e(ge,{modelValue:b.value,"onUpdate:modelValue":ye[15]||(ye[15]=We=>b.value=We),"max-width":"420"},{default:t(()=>[e(ct,null,{default:t(()=>[e(Pt,null,{default:t(()=>[...ye[50]||(ye[50]=[n("Status ändern?",-1)])]),_:1}),e(Ye,null,{default:t(()=>[n(v(x.value.length)+" Seite(n) werden auf ",1),a("strong",null,v(Ce(w.value||"")),1),ye[51]||(ye[51]=n(" gesetzt. ",-1))]),_:1}),e(Re,null,{default:t(()=>[e(ut),e(Ke,{variant:"text",onClick:ye[14]||(ye[14]=We=>b.value=!1)},{default:t(()=>[...ye[52]||(ye[52]=[n("Abbrechen",-1)])]),_:1}),e(Ke,{color:"primary",loading:I.value,onClick:D},{default:t(()=>[...ye[53]||(ye[53]=[n("Bestätigen",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(ge,{modelValue:_e.value,"onUpdate:modelValue":ye[23]||(ye[23]=We=>_e.value=We),"max-width":"500"},{default:t(()=>[e(ct,null,{default:t(()=>[e(Pt,null,{default:t(()=>[...ye[54]||(ye[54]=[n("Neue Seite erstellen",-1)])]),_:1}),e(Ye,null,{default:t(()=>[e($e,{modelValue:q.value.title,"onUpdate:modelValue":ye[16]||(ye[16]=We=>q.value.title=We),label:"Titel",class:"mb-3"},null,8,["modelValue"]),e($e,{modelValue:q.value.slug,"onUpdate:modelValue":ye[17]||(ye[17]=We=>q.value.slug=We),label:"Slug",class:"mb-3",hint:"Wird automatisch generiert"},null,8,["modelValue"]),e(at,{modelValue:q.value.parentId,"onUpdate:modelValue":ye[18]||(ye[18]=We=>q.value.parentId=We),items:C.value,"item-title":"title","item-value":"value",label:"Übergeordnete Seite",clearable:"",density:"default",class:"mb-3",hint:"Optional - für hierarchische Pfade","persistent-hint":""},null,8,["modelValue","items"]),e($e,{modelValue:q.value.path,"onUpdate:modelValue":ye[19]||(ye[19]=We=>q.value.path=We),label:"Pfad",class:"mb-3",readonly:""},null,8,["modelValue"]),e(lt,{modelValue:q.value.template,"onUpdate:modelValue":ye[20]||(ye[20]=We=>q.value.template=We),items:G,"item-title":"title","item-value":"value",label:"Template",class:"mb-3"},null,8,["modelValue"]),e(et,{modelValue:q.value.category,"onUpdate:modelValue":ye[21]||(ye[21]=We=>q.value.category=We),items:O.value,label:"Kategorie",clearable:"",hint:"Bestehende wählen oder neue Kategorie eintippen"},null,8,["modelValue","items"])]),_:1}),e(Re,null,{default:t(()=>[e(ut),e(Ke,{variant:"text",onClick:ye[22]||(ye[22]=We=>_e.value=!1)},{default:t(()=>[...ye[55]||(ye[55]=[n("Abbrechen",-1)])]),_:1}),e(Ke,{color:"primary",disabled:!q.value.title||!q.value.slug,onClick:ee},{default:t(()=>[...ye[56]||(ye[56]=[n("Erstellen",-1)])]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(ge,{modelValue:F.value,"onUpdate:modelValue":ye[30]||(ye[30]=We=>F.value=We),"max-width":"520"},{default:t(()=>[e(ct,null,{default:t(()=>[e(Pt,null,{default:t(()=>[...ye[57]||(ye[57]=[n("Seite duplizieren",-1)])]),_:1}),e(Ye,null,{default:t(()=>[A.value?(o(),h("p",Bo,[ye[58]||(ye[58]=n(" Quelle: ",-1)),a("strong",null,v(A.value.title),1),a("span",Fo," ("+v(A.value.path)+")",1)])):U("",!0),e($t,{modelValue:z.value,"onUpdate:modelValue":ye[24]||(ye[24]=We=>z.value=We),"hide-details":"",class:"mb-4"},{default:t(()=>[e(it,{value:"copy",label:"Kopie (eigenständig)"},{label:t(()=>[...ye[59]||(ye[59]=[a("div",null,[a("div",{class:"font-weight-medium"},"Kopie (eigenständig)"),a("div",{class:"text-caption text-medium-emphasis"}," Unabhängige Seite ohne Canonical-Verweis. Titel, Hero und Texte sollten angepasst werden. ")],-1)])]),_:1}),e(it,{value:"variant",label:"Variante (mit Canonical auf Original)"},{label:t(()=>[...ye[60]||(ye[60]=[a("div",null,[a("div",{class:"font-weight-medium"},"Variante (mit Canonical auf Original)"),a("div",{class:"text-caption text-medium-emphasis"}," A/B-Test-Variante mit Canonical-Tag auf Original. Per Default noindex gesetzt. ")],-1)])]),_:1})]),_:1},8,["modelValue"]),e($e,{modelValue:j.value,"onUpdate:modelValue":ye[25]||(ye[25]=We=>j.value=We),label:"Titel",density:"compact",variant:"outlined",class:"mb-3"},null,8,["modelValue"]),e($e,{modelValue:J.value,"onUpdate:modelValue":ye[26]||(ye[26]=We=>J.value=We),label:"Slug",density:"compact",variant:"outlined",hint:"Nur Kleinbuchstaben, Ziffern, Bindestriche. Bei Kollision wird ein Suffix angehängt.",class:"mb-3"},null,8,["modelValue"]),e(Fe,{modelValue:Q.value,"onUpdate:modelValue":ye[27]||(ye[27]=We=>Q.value=We),label:"noindex setzen (Seite nicht von Suchmaschinen indexieren)","hide-details":"",density:"compact",class:"mb-3"},null,8,["modelValue"]),z.value==="variant"?(o(),N($e,{key:1,modelValue:te.value,"onUpdate:modelValue":ye[28]||(ye[28]=We=>te.value=We),label:"Canonical (Slug oder absolute URL)",density:"compact",variant:"outlined",hint:"Default: Slug des Originals. Zeigt Suchmaschinen, welche Seite die 'Haupt'-Version ist.","persistent-hint":""},null,8,["modelValue"])):U("",!0)]),_:1}),e(Re,null,{default:t(()=>[e(ut),e(Ke,{variant:"text",onClick:ye[29]||(ye[29]=We=>F.value=!1)},{default:t(()=>[...ye[61]||(ye[61]=[n("Abbrechen",-1)])]),_:1}),e(Ke,{color:"primary",loading:L.value,disabled:!j.value.trim()||!J.value.trim(),onClick:pe},{default:t(()=>[...ye[62]||(ye[62]=[n(" Duplizieren ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(yt,{modelValue:ve.value,"onUpdate:modelValue":ye[32]||(ye[32]=We=>ve.value=We),color:Z.value,timeout:"4000",location:"bottom right"},{actions:t(()=>[e(Ke,{variant:"text",onClick:ye[31]||(ye[31]=We=>ve.value=!1)},{default:t(()=>[...ye[63]||(ye[63]=[n("OK",-1)])]),_:1})]),default:t(()=>[n(v(de.value)+" ",1)]),_:1},8,["modelValue","color"])])}}}),Ro=Me(Oo,[["__scopeId","data-v-568f4e2e"]]),c6=Object.freeze(Object.defineProperty({__proto__:null,default:Ro},Symbol.toStringTag,{value:"Module"})),Ko=30*1e3,jo=1800*1e3,qo={LinkedinContentPlan:"/content-plans",LinkedinPost:"/linkedin/posts",EmailCampaign:"/email-campaigns",EmailSequence:"/email-sequences",EmailTemplate:"/admin/email-templates",Content:"/content",WebsitePage:"/admin/pages"};function sa(r,$){const d=y(!1),c=y(null),s=y(null),m=y(!1),u=y(null),f=y(Date.now());let p=null;const _=qo[r],k=se(()=>c.value!==null);function i(){f.value=Date.now()}function g(){window.addEventListener("mousemove",i),window.addEventListener("keydown",i)}function x(){window.removeEventListener("mousemove",i),window.removeEventListener("keydown",i)}function w(){p&&(clearInterval(p),p=null)}function b(){w(),p=setInterval(async()=>{var T,D;if(!$.value)return;const R=Date.now()-f.value;if(R>jo){ue.info("ADMIN","Hard cut-off ausgeloest - Lock wird freigegeben",{modelType:r,docId:$.value,inactivityMinutes:Math.floor(R/6e4)}),await V();return}const M=await re.post(`${_}/${$.value}/lock/refresh`);if(!M.success){const H=(T=M.data)==null?void 0:T.reason,O=M.status??0;if(O===0||O>=500){ue.warn("ADMIN","Lock-Refresh transienter Fehler - silent retry beim naechsten Tick",{status:O,modelType:r,docId:$.value});return}H==="taken_over"?(m.value=!0,u.value=((D=M.data)==null?void 0:D.takenBy)??null,d.value=!1,ue.warn("ADMIN","Lock von anderem User uebernommen",{takenBy:u.value})):(ue.warn("ADMIN","Lock-Refresh fehlgeschlagen",{reason:H,status:O}),d.value=!1),w(),x()}},Ko)}async function I(){var M;if(!$.value)return;const R=await re.post(`${_}/${$.value}/lock`);if(R.success&&R.data){const T=R.data.lockInfo;d.value=!0,c.value=T.lockedBy,s.value=T.lockedAt?new Date(T.lockedAt):null,m.value=!1,u.value=null,f.value=Date.now(),b(),g(),ue.debug("ADMIN","Lock erworben",{modelType:r,docId:$.value})}else{const T=(M=R.data)==null?void 0:M.lockInfo;d.value=!1,c.value=(T==null?void 0:T.lockedBy)??null,s.value=T!=null&&T.lockedAt?new Date(T.lockedAt):null,ue.info("ADMIN","Lock von anderem User gehalten - Read-Only-Modus",{lockedBy:c.value})}}async function V(){if(!$.value||!d.value){w(),x();return}await re.delete(`${_}/${$.value}/lock`),d.value=!1,c.value=null,s.value=null,w(),x(),ue.debug("ADMIN","Lock freigegeben",{modelType:r,docId:$.value})}async function E(){if(!$.value)return!1;const R=await re.post(`${_}/${$.value}/lock/takeover`);if(R.success&&R.data){const M=R.data.lockInfo;return d.value=!0,c.value=M.lockedBy,s.value=M.lockedAt?new Date(M.lockedAt):null,m.value=!1,u.value=null,f.value=Date.now(),b(),g(),ue.info("ADMIN","Lock vom aktuellen User uebernommen",{modelType:r,docId:$.value}),!0}return ue.error("ADMIN","Lock-Uebernahme fehlgeschlagen",{error:R.error}),!1}return rt(()=>{$.value&&I()}),Ze($,async(R,M)=>{if(M&&M!==R&&d.value){try{await re.delete(`${_}/${M}/lock`)}catch{}d.value=!1,c.value=null,s.value=null,m.value=!1,u.value=null,w(),x()}R&&R!==M&&I()}),La(async()=>{d.value&&await V()}),da(()=>{d.value?V():(w(),x())}),{isLocked:k,isLockedByMe:d,lockedBy:c,lockedAt:s,isLockTakenOver:m,takenOverBy:u,takeOverLock:E,releaseLock:V}}const Go={class:"lock-banner-content"},Ho={class:"d-flex align-center gap-3"},Wo={class:"font-weight-medium"},Zo={class:"text-caption"},Jo={class:"lock-banner-content"},Qo={class:"d-flex align-center gap-3"},Yo={class:"font-weight-medium"},Xo=Ae({inheritAttrs:!1,__name:"LockBanner",props:{isLocked:{type:Boolean},isLockedByMe:{type:Boolean},lockedBy:{},lockedAt:{},isLockTakenOver:{type:Boolean},takenOverBy:{},onTakeOver:{type:Function}},setup(r){const $=r,d=xt(),c=y(!1);function s(u){return u?new Date(u).toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):""}async function m(){c.value=!1,await $.onTakeOver()}return(u,f)=>{const p=l("v-icon"),_=l("v-btn"),k=l("v-alert"),i=l("v-card-title"),g=l("v-card-text"),x=l("v-spacer"),w=l("v-card-actions"),b=l("v-card"),I=l("v-dialog");return o(),h(be,null,[r.isLocked&&!r.isLockedByMe&&!r.isLockTakenOver?(o(),N(k,Vt({key:0},u.$attrs,{type:"warning",prominent:"",class:"lock-banner-alert mb-4"}),{default:t(()=>{var V,E;return[a("div",Go,[a("div",Ho,[e(p,{size:"24"},{default:t(()=>[...f[4]||(f[4]=[n("mdi-lock",-1)])]),_:1}),a("div",null,[a("div",Wo," Wird gerade von "+v((V=r.lockedBy)==null?void 0:V.firstName)+" "+v((E=r.lockedBy)==null?void 0:E.lastName)+" bearbeitet ",1),a("div",Zo," seit "+v(s(r.lockedAt)),1)])]),e(_,{variant:"elevated",color:"warning",onClick:f[0]||(f[0]=R=>c.value=!0)},{default:t(()=>[...f[5]||(f[5]=[n(" Lock übernehmen ",-1)])]),_:1})])]}),_:1},16)):r.isLockTakenOver?(o(),N(k,Vt({key:1},u.$attrs,{type:"error",prominent:"",class:"lock-banner-alert mb-4"}),{default:t(()=>{var V,E;return[a("div",Jo,[a("div",Qo,[e(p,{size:"24"},{default:t(()=>[...f[6]||(f[6]=[n("mdi-lock-alert",-1)])]),_:1}),a("div",null,[a("div",Yo,v((V=r.takenOverBy)==null?void 0:V.firstName)+" "+v((E=r.takenOverBy)==null?void 0:E.lastName)+" hat den Lock übernommen ",1),f[7]||(f[7]=a("div",{class:"text-caption"}," Deine ungespeicherten Änderungen sind verloren. ",-1))])]),e(_,{variant:"elevated",color:"error",onClick:f[1]||(f[1]=R=>P(d).back())},{default:t(()=>[...f[8]||(f[8]=[n(" Zurück zur Liste ",-1)])]),_:1})])]}),_:1},16)):U("",!0),e(I,{modelValue:c.value,"onUpdate:modelValue":f[3]||(f[3]=V=>c.value=V),"max-width":"500"},{default:t(()=>[e(b,null,{default:t(()=>[e(i,{class:"text-h6"},{default:t(()=>[...f[9]||(f[9]=[n(" Lock übernehmen? ",-1)])]),_:1}),e(g,null,{default:t(()=>{var V,E;return[a("p",null,v((V=r.lockedBy)==null?void 0:V.firstName)+" "+v((E=r.lockedBy)==null?void 0:E.lastName)+" bearbeitet dieses Dokument gerade. Wenn du den Lock übernimmst, verliert diese Person ihre Bearbeitungsberechtigung und ungespeicherte Änderungen könnten verloren gehen. ",1),f[10]||(f[10]=a("p",{class:"mt-2 text-medium-emphasis"}," Bitte stelle sicher, dass du dich mit der anderen Person abgestimmt hast, bevor du den Lock übernimmst. ",-1))]}),_:1}),e(w,null,{default:t(()=>[e(x),e(_,{variant:"text",onClick:f[2]||(f[2]=V=>c.value=!1)},{default:t(()=>[...f[11]||(f[11]=[n(" Abbrechen ",-1)])]),_:1}),e(_,{variant:"elevated",color:"warning",onClick:m},{default:t(()=>[...f[12]||(f[12]=[n(" Übernehmen ",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"])],64)}}}),ia=Me(Xo,[["__scopeId","data-v-9bd707d6"]]),es={class:"d-flex align-center ga-2 ml-2 flex-grow-1 overflow-hidden"},ts={key:1,class:"text-body-1 font-weight-medium text-truncate",style:{"max-width":"280px"}},as=Ae({__name:"EditorToolbar",emits:["save","open-settings","toggle-ai-sidebar"],setup(r,{emit:$}){const d=$,c=xt(),s=Jt(),m=se(()=>s.currentPage),u=se(()=>s.isDirty),f=se(()=>s.saving),p=se(()=>s.editorMode),_=se(()=>p.value==="advanced"),k=se(()=>s.currentPage!==null),i=se(()=>s.currentPage!==null),g=se(()=>{if(!m.value)return"grey";switch(m.value.status){case"published":return"success";case"draft":return"warning";case"archived":return"error";default:return"grey"}}),x=se(()=>{if(!m.value)return"";switch(m.value.status){case"published":return"Veröffentlicht";case"draft":return"Entwurf";case"archived":return"Archiviert";default:return m.value.status}});function w(b){b==="advanced"?s.setEditorMode("advanced"):s.setEditorMode("simple")}return(b,I)=>{const V=l("v-btn"),E=l("v-text-field"),R=l("v-chip"),M=l("v-icon"),T=l("v-btn-toggle"),D=l("v-divider"),H=l("v-app-bar");return o(),N(H,{density:"compact",elevation:"1",class:"editor-toolbar"},{default:t(()=>{var O;return[e(V,{icon:"mdi-arrow-left",variant:"text",size:"small",class:"ml-1",title:"Zurück zur Seitenübersicht",onClick:I[0]||(I[0]=S=>P(c).back())}),a("div",es,[_.value&&m.value?(o(),N(E,{key:0,"model-value":m.value.title,density:"compact",variant:"plain","hide-details":"",class:"page-title-field",style:{"max-width":"280px"},"onUpdate:modelValue":I[1]||(I[1]=S=>m.value.title=S)},null,8,["model-value"])):(o(),h("span",ts,v(((O=m.value)==null?void 0:O.title)||"Seite laden..."),1)),m.value?(o(),N(R,{key:2,color:g.value,size:"x-small",label:"",variant:"tonal"},{default:t(()=>[n(v(x.value),1)]),_:1},8,["color"])):U("",!0),u.value?(o(),N(R,{key:3,color:"warning",size:"x-small",label:"",variant:"tonal"},{default:t(()=>[...I[7]||(I[7]=[n(" Ungespeichert ",-1)])]),_:1})):U("",!0)]),e(T,{"model-value":p.value,mandatory:"",density:"compact",variant:"outlined",class:"mx-2","onUpdate:modelValue":w},{default:t(()=>[e(V,{value:"simple",size:"small",title:"Einfacher Modus"},{default:t(()=>[e(M,{size:"small"},{default:t(()=>[...I[8]||(I[8]=[n("mdi-pencil-outline",-1)])]),_:1}),I[9]||(I[9]=a("span",{class:"ml-1 d-none d-sm-inline text-caption"},"Einfach",-1))]),_:1}),e(V,{value:"advanced",size:"small",title:"Erweiterter Modus"},{default:t(()=>[e(M,{size:"small"},{default:t(()=>[...I[10]||(I[10]=[n("mdi-code-tags",-1)])]),_:1}),I[11]||(I[11]=a("span",{class:"ml-1 d-none d-sm-inline text-caption"},"Erweitert",-1))]),_:1})]),_:1},8,["model-value"]),e(D,{vertical:"",class:"mx-1 my-2"}),e(V,{icon:"mdi-undo",variant:"text",size:"small",disabled:!k.value,title:"Rückgängig",onClick:I[2]||(I[2]=S=>P(s).undo())},null,8,["disabled"]),e(V,{icon:"mdi-redo",variant:"text",size:"small",disabled:!i.value,title:"Wiederholen",onClick:I[3]||(I[3]=S=>P(s).redo())},null,8,["disabled"]),e(D,{vertical:"",class:"mx-1 my-2"}),e(V,{icon:"mdi-magnify",variant:"text",size:"small",title:"SEO-Einstellungen",onClick:I[4]||(I[4]=S=>d("open-settings"))}),e(V,{icon:"mdi-auto-fix",variant:"text",size:"small",color:"primary",title:"KI-Assistent",onClick:I[5]||(I[5]=S=>d("toggle-ai-sidebar"))}),Xt(b.$slots,"default",{},void 0,!0),e(V,{icon:"mdi-eye-outline",variant:"text",size:"small",title:"Vorschau"}),e(V,{color:"primary",variant:"flat",size:"small",loading:f.value,disabled:!u.value,"prepend-icon":"mdi-content-save-outline",class:"ml-1 mr-2",onClick:I[6]||(I[6]=S=>d("save"))},{default:t(()=>[...I[12]||(I[12]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled"])]}),_:3})}}}),ls=Me(as,[["__scopeId","data-v-d2791b08"]]),ns=[{type:"hero",label:"Hero Banner",icon:"mdi-image-area",category:"content",schema:{properties:{subtitle:{type:"text",label:"Untertitel",aiEnabled:!0},ctaText:{type:"text",label:"CTA Button Text",aiEnabled:!0},ctaLink:{type:"text",label:"CTA Button Link"},overlay:{type:"boolean",label:"Overlay anzeigen",default:!0}}},defaultProps:{subtitle:"",ctaText:"",ctaLink:"",overlay:!0}},{type:"text",label:"Text-Block",icon:"mdi-text-box-outline",category:"content",schema:{properties:{}},defaultProps:{}},{type:"grid",label:"Feature Grid",icon:"mdi-grid",category:"content",schema:{properties:{columns:{type:"number",label:"Spalten",default:3},cards:{type:"cards",label:"Karten",itemSchema:{properties:{icon:{type:"text",label:"Icon"},title:{type:"text",label:"Titel",aiEnabled:!0},text:{type:"text",label:"Text",aiEnabled:!0}}}}}},defaultProps:{columns:3,cards:[]}},{type:"pricing",label:"Pricing Table",icon:"mdi-currency-eur",category:"content",schema:{properties:{packages:{type:"cards",label:"Pakete",itemSchema:{properties:{name:{type:"text",label:"Name",aiEnabled:!0},description:{type:"text",label:"Untertitel",aiEnabled:!0},price:{type:"text",label:"Preis"},features:{type:"cards",label:"Features",itemSchema:{properties:{text:{type:"text",label:"Feature",aiEnabled:!0}}}},cta:{type:"text",label:"CTA Text",aiEnabled:!0},ctaLink:{type:"text",label:"CTA Link"},highlighted:{type:"boolean",label:"Hervorgehoben",default:!1}}}}}},defaultProps:{packages:[]}},{type:"cta",label:"CTA Banner",icon:"mdi-bullhorn-outline",category:"content",schema:{properties:{subtext:{type:"text",label:"Unterzeile",aiEnabled:!0},buttonText:{type:"text",label:"Button Text",aiEnabled:!0},buttonLink:{type:"text",label:"Button Link"},openFormSlug:{type:"select-async",label:"Formular-Modal öffnen (statt Navigation)",source:"/admin/form-presets?active=true",valueKey:"slug",labelKey:"name"},backgroundColor:{type:"color",label:"Hintergrundfarbe",default:"#0AC9D4"}}},defaultProps:{subtext:"",buttonText:"",buttonLink:"",openFormSlug:"",backgroundColor:"#0AC9D4"}},{type:"logos",label:"Logo-Karussell",icon:"mdi-image-multiple-outline",category:"content",schema:{properties:{logos:{type:"cards",label:"Logos",itemSchema:{properties:{image:{type:"image",label:"Logo"},alt:{type:"text",label:"Alt-Text"}}}}}},defaultProps:{logos:[]}},{type:"stats",label:"Counter Section",icon:"mdi-counter",category:"content",schema:{properties:{counters:{type:"cards",label:"Zähler",itemSchema:{properties:{value:{type:"number",label:"Wert"},suffix:{type:"text",label:"Suffix"},label:{type:"text",label:"Beschriftung",aiEnabled:!0}}}}}},defaultProps:{counters:[]}},{type:"faq",label:"FAQ / Accordion",icon:"mdi-frequently-asked-questions",category:"content",schema:{properties:{items:{type:"cards",label:"FAQ-Einträge",itemSchema:{properties:{question:{type:"text",label:"Frage",aiEnabled:!0},answer:{type:"richtext",label:"Antwort",aiEnabled:!0}}}}}},defaultProps:{items:[]}},{type:"tabs",label:"Tabs",icon:"mdi-tab",category:"content",schema:{properties:{tabs:{type:"cards",label:"Tabs",itemSchema:{properties:{label:{type:"text",label:"Tab-Titel"},content:{type:"richtext",label:"Inhalt",aiEnabled:!0}}}}}},defaultProps:{tabs:[]}},{type:"table",label:"Tabelle",icon:"mdi-table",category:"content",schema:{properties:{headers:{type:"cards",label:"Spaltenköpfe",itemSchema:{properties:{text:{type:"text",label:"Überschrift"}}}},rows:{type:"cards",label:"Zeilen",itemSchema:{properties:{cells:{type:"cards",label:"Zellen",itemSchema:{properties:{text:{type:"text",label:"Inhalt"}}}}}}}}},defaultProps:{headers:[],rows:[]}},{type:"service-cards",label:"Service-Karten",icon:"mdi-card-multiple-outline",category:"content",schema:{properties:{cards:{type:"cards",label:"Karten",itemSchema:{properties:{title:{type:"text",label:"Titel",aiEnabled:!0},description:{type:"text",label:"Beschreibung",aiEnabled:!0},image:{type:"image",label:"Hintergrundbild"},link:{type:"text",label:"Link"}}}}}},defaultProps:{cards:[]}},{type:"glassy-grid",label:"Glassmorphism Grid",icon:"mdi-cards-outline",category:"content",schema:{properties:{description:{type:"richtext",label:"Einleitungstext",aiEnabled:!0},boxes:{type:"cards",label:"Boxen",itemSchema:{properties:{title:{type:"text",label:"Titel",aiEnabled:!0},description:{type:"text",label:"Untertitel",aiEnabled:!0},link:{type:"text",label:"Link"},children:{type:"cards",label:"Einträge",itemSchema:{properties:{title:{type:"text",label:"Eintrag"},link:{type:"text",label:"Link"}}}}}}}}},defaultProps:{description:"",boxes:[]}},{type:"timeline",label:"Timeline",icon:"mdi-timeline-outline",category:"content",schema:{properties:{entries:{type:"cards",label:"Einträge",itemSchema:{properties:{date:{type:"text",label:"Datum"},title:{type:"text",label:"Titel",aiEnabled:!0},description:{type:"richtext",label:"Beschreibung",aiEnabled:!0}}}}}},defaultProps:{entries:[]}}],os=[{type:"columns",label:"Spalten-Layout",icon:"mdi-view-column-outline",category:"layout",schema:{properties:{columnCount:{type:"number",label:"Spaltenanzahl",default:2},columnWidths:{type:"text",label:'Spaltenbreiten (z.B. "6,6" oder "4,8")'},columns:{type:"cards",label:"Spalten",itemSchema:{properties:{content:{type:"richtext",label:"Inhalt",aiEnabled:!0}}}}}},defaultProps:{columnCount:2,columnWidths:"6,6",columns:[]}},{type:"image-text",label:"Bild + Text",icon:"mdi-image-text",category:"layout",schema:{properties:{image:{type:"image",label:"Bild"},imagePosition:{type:"select",label:"Bildposition",default:"left",options:[{value:"left",label:"Links"},{value:"right",label:"Rechts"}]}}},defaultProps:{image:"",imagePosition:"left"}},{type:"spacer",label:"Spacer / Divider",icon:"mdi-arrow-expand-vertical",category:"layout",schema:{properties:{height:{type:"number",label:"Höhe (px)",default:48},showLine:{type:"boolean",label:"Trennlinie anzeigen",default:!1}}},defaultProps:{height:48,showLine:!1}}],ss=[{type:"image",label:"Bild",icon:"mdi-image-outline",category:"media",schema:{properties:{src:{type:"image",label:"Bild"},alt:{type:"text",label:"Alt-Text",aiEnabled:!0},caption:{type:"text",label:"Bildunterschrift",aiEnabled:!0},width:{type:"number",label:"Breite (%)"}}},defaultProps:{src:"",alt:"",caption:"",width:100}},{type:"testimonial",label:"Testimonials",icon:"mdi-format-quote-close",category:"media",schema:{properties:{display:{type:"select",label:"Darstellung",default:"carousel",options:[{value:"carousel",label:"Karussell"},{value:"grid",label:"Grid"}]},testimonials:{type:"cards",label:"Testimonials",itemSchema:{properties:{quote:{type:"richtext",label:"Zitat",aiEnabled:!0},name:{type:"text",label:"Name"},company:{type:"text",label:"Unternehmen"},image:{type:"image",label:"Bild"}}}}}},defaultProps:{display:"carousel",testimonials:[]}},{type:"video",label:"Video Embed",icon:"mdi-video-outline",category:"media",schema:{properties:{url:{type:"text",label:"YouTube-URL"},aspectRatio:{type:"select",label:"Seitenverhältnis",default:"16:9",options:[{value:"16:9",label:"16:9"},{value:"4:3",label:"4:3"}]},caption:{type:"text",label:"Untertitel (optional)"},autoplay:{type:"boolean",label:"Autoplay",default:!1},startTime:{type:"number",label:"Startzeit (Sekunden)",default:0}}},defaultProps:{url:"",caption:"",aspectRatio:"16:9",autoplay:!1,startTime:0}}],is=[{type:"form",label:"Formular",icon:"mdi-form-select",category:"interactive",schema:{properties:{presetSlug:{type:"select-async",label:"Formular-Preset",required:!0,source:"/admin/form-presets?active=true",valueKey:"slug",labelKey:"name"}}},defaultProps:{presetSlug:""}}],rs=[{type:"custom-html",label:"Custom HTML",icon:"mdi-code-tags",category:"advanced",schema:{properties:{code:{type:"code",label:"HTML Code"}}},defaultProps:{code:""}},{type:"external-script",label:"Externes Script (Drittanbieter-Widget)",icon:"mdi-script-text-outline",category:"advanced",schema:{properties:{scriptUrl:{type:"text",label:"Script-URL",required:!0},provider:{type:"text",label:"Anbieter (z.B. Kicktipp)"},minHeight:{type:"number",label:"Reservierte Mindesthöhe (px)",default:600}}},defaultProps:{scriptUrl:"",provider:"",minHeight:600}}],ml=[...ns,...os,...ss,...is,...rs];function ds(){return ml}function Na(r){return ml.find($=>$.type===r)}const us={class:"sidebar-toggle d-flex align-center pa-2 border-b"},cs={key:0,class:"text-caption text-medium-emphasis ml-1"},ms={class:"flex-grow-1 overflow-y-auto"},vs={key:0,class:"pa-2"},ps={key:1,class:"insert-zone px-2 pt-1"},fs={class:"section-item-wrapper"},gs=["onClick"],bs={key:1,class:"flex-grow-1 overflow-hidden"},ys={class:"text-body-2 font-weight-medium text-truncate"},_s={class:"text-caption text-medium-emphasis text-truncate"},ks={key:0,class:"insert-zone px-2"},hs={key:2,class:"pa-4 text-center text-medium-emphasis"},xs=Ae({__name:"ModuleSidebar",props:{collapsed:{type:Boolean}},emits:["toggle","insert-module"],setup(r,{emit:$}){const d=$,c=Jt(),s=y(null),m=se(()=>{var w;return((w=c.currentPage)==null?void 0:w.content)||[]}),u=se(()=>c.selectedSectionIndex),f=se(()=>c.editorMode==="advanced"),p=se({get:()=>m.value,set:w=>{const b=m.value;w.forEach((I,V)=>{const E=b.findIndex(R=>R.sectionId===I.sectionId);E!==V&&c.moveSection(E,V)})}});function _(w){return Na(w)}function k(w){var b;return w.title?w.title.substring(0,30)+(w.title.length>30?"...":""):((b=_(w.type))==null?void 0:b.label)||w.type}function i(w){s.value=w}function g(w){c.removeSection(w),s.value=null}function x(){s.value=null}return(w,b)=>{const I=l("v-btn"),V=l("v-icon"),E=l("v-card-title"),R=l("v-card-text"),M=l("v-spacer"),T=l("v-card-actions"),D=l("v-card"),H=l("v-dialog");return o(),h("div",{class:ft(["module-sidebar h-100 d-flex flex-column overflow-hidden border-e",{"sidebar-collapsed":r.collapsed}])},[a("div",us,[e(I,{icon:r.collapsed?"mdi-chevron-right":"mdi-chevron-left",variant:"text",size:"small",onClick:b[0]||(b[0]=O=>d("toggle"))},null,8,["icon"]),r.collapsed?U("",!0):(o(),h("span",cs,"Module ("+v(m.value.length)+")",1))]),a("div",ms,[f.value&&!r.collapsed&&m.value.length===0?(o(),h("div",vs,[e(I,{variant:"outlined",block:"",size:"small","prepend-icon":"mdi-plus",onClick:b[1]||(b[1]=O=>d("insert-module",0))},{default:t(()=>[...b[6]||(b[6]=[n(" Modul hinzufügen ",-1)])]),_:1})])):U("",!0),f.value&&!r.collapsed&&m.value.length>0?(o(),h("div",ps,[e(I,{variant:"text",size:"x-small",block:"","prepend-icon":"mdi-plus",color:"primary",class:"insert-btn",onClick:b[2]||(b[2]=O=>d("insert-module",0))},{default:t(()=>[r.collapsed?U("",!0):(o(),h(be,{key:0},[n("Hier einfügen")],64))]),_:1})])):U("",!0),e(P(sl),{modelValue:p.value,"onUpdate:modelValue":b[3]||(b[3]=O=>p.value=O),"item-key":"sectionId",handle:".drag-handle","ghost-class":"ghost-section"},{item:t(({element:O,index:S})=>{var B,G;return[a("div",fs,[a("div",{class:ft(["section-item d-flex align-center pa-2 cursor-pointer",{"section-item--active":u.value===S}]),onClick:W=>P(c).selectSection(S)},[f.value&&!r.collapsed?(o(),N(V,{key:0,class:"drag-handle cursor-grab mr-1",size:"small",color:"grey"},{default:t(()=>[...b[7]||(b[7]=[n(" mdi-drag-vertical ",-1)])]),_:1})):U("",!0),e(V,{icon:((B=_(O.type))==null?void 0:B.icon)||"mdi-puzzle-outline",size:"small",color:u.value===S?"primary":"grey",class:ft(r.collapsed?"":"mr-2")},null,8,["icon","color","class"]),r.collapsed?U("",!0):(o(),h("div",bs,[a("div",ys,v(((G=_(O.type))==null?void 0:G.label)||O.type),1),a("div",_s,v(O.name||O.sectionId||"")+v(O.title?" - "+k(O):""),1)])),f.value&&!r.collapsed?(o(),N(I,{key:2,icon:"mdi-delete-outline",size:"x-small",variant:"text",color:"error",class:"ml-1 flex-shrink-0",onClick:dt(W=>i(S),["stop"])},null,8,["onClick"])):U("",!0)],10,gs),f.value&&!r.collapsed?(o(),h("div",ks,[e(I,{variant:"text",size:"x-small",block:"","prepend-icon":"mdi-plus",color:"primary",class:"insert-btn",onClick:W=>d("insert-module",S+1)},{default:t(()=>[...b[8]||(b[8]=[n(" Hier einfügen ",-1)])]),_:1},8,["onClick"])])):U("",!0)])]}),_:1},8,["modelValue"]),m.value.length===0&&!r.collapsed?(o(),h("div",hs,[e(V,{size:"32",class:"mb-2",color:"grey"},{default:t(()=>[...b[9]||(b[9]=[n("mdi-view-module-outline",-1)])]),_:1}),b[11]||(b[11]=a("p",{class:"text-caption"},"Noch keine Module vorhanden.",-1)),e(I,{size:"small",variant:"tonal",color:"primary","prepend-icon":"mdi-plus",class:"mt-2",onClick:b[4]||(b[4]=O=>d("insert-module",0))},{default:t(()=>[...b[10]||(b[10]=[n(" Erstes Modul hinzufügen ",-1)])]),_:1})])):U("",!0)]),e(H,{"model-value":s.value!==null,"max-width":"360","onUpdate:modelValue":x},{default:t(()=>[e(D,null,{default:t(()=>[e(E,null,{default:t(()=>[...b[12]||(b[12]=[n("Modul löschen?",-1)])]),_:1}),e(R,null,{default:t(()=>{var O,S;return[b[13]||(b[13]=n(" Soll das Modul ",-1)),a("strong",null,v(s.value!==null?(S=_((O=m.value[s.value])==null?void 0:O.type))==null?void 0:S.label:""),1),b[14]||(b[14]=n(" wirklich entfernt werden? Diese Aktion kann über Rückgängig widerrufen werden. ",-1))]}),_:1}),e(T,null,{default:t(()=>[e(M),e(I,{variant:"text",onClick:x},{default:t(()=>[...b[15]||(b[15]=[n("Abbrechen",-1)])]),_:1}),e(I,{color:"error",variant:"flat",onClick:b[5]||(b[5]=O=>s.value!==null&&g(s.value))},{default:t(()=>[...b[16]||(b[16]=[n(" Löschen ",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["model-value"])],2)}}}),ws=Me(xs,[["__scopeId","data-v-cbabbe77"]]),Ss={properties:{backgroundColor:{type:"color",label:"Hintergrundfarbe"},backgroundImage:{type:"image",label:"Hintergrundbild"},backgroundImageOpacity:{type:"number",label:"Hintergrundbild Transparenz (0..1)",default:1},backgroundSize:{type:"select",label:"Hintergrundbild Skalierung",options:[{value:"cover",label:"Cover (füllt aus, ggf. Beschnitt)"},{value:"contain",label:"Contain (vollständig sichtbar)"},{value:"auto",label:"Auto (Originalgröße)"}],default:"cover"},paddingTop:{type:"number",label:"Abstand oben (px)"},paddingBottom:{type:"number",label:"Abstand unten (px)"},marginTop:{type:"number",label:"Außenabstand oben (px)"},marginBottom:{type:"number",label:"Außenabstand unten (px)"},textAlign:{type:"select",label:"Textausrichtung",options:[{value:"left",label:"Links"},{value:"center",label:"Zentriert"},{value:"right",label:"Rechts"}]},textColor:{type:"color",label:"Textfarbe"}}},$s={class:"prop-field-text"},wa=Ae({__name:"PropFieldText",props:{modelValue:{},label:{},aiEnabled:{type:Boolean}},emits:["update:modelValue","ai-action"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-btn"),u=l("v-text-field");return o(),h("div",$s,[e(u,{"model-value":r.modelValue,label:r.label,density:"compact",variant:"outlined","hide-details":"auto","onUpdate:modelValue":s[1]||(s[1]=f=>d("update:modelValue",f))},Dl({_:2},[r.aiEnabled?{name:"append-inner",fn:t(()=>[e(m,{icon:"mdi-auto-fix",size:"x-small",variant:"text",color:"primary",density:"compact",title:`KI: ${r.label} generieren`,onClick:s[0]||(s[0]=dt(f=>d("ai-action",r.label),["stop"]))},null,8,["title"])]),key:"0"}:void 0]),1032,["model-value","label"])])}}}),Cs={class:"prop-field-richtext"},Vs={key:0,class:"d-flex justify-end mt-1"},Ha=Ae({__name:"PropFieldRichtext",props:{modelValue:{},label:{},aiEnabled:{type:Boolean}},emits:["update:modelValue","ai-action"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-textarea"),u=l("v-btn");return o(),h("div",Cs,[e(m,{"model-value":r.modelValue,label:r.label,rows:6,density:"compact",variant:"outlined","hide-details":"auto","auto-grow":"","onUpdate:modelValue":s[0]||(s[0]=f=>d("update:modelValue",f))},null,8,["model-value","label"]),r.aiEnabled?(o(),h("div",Vs,[e(u,{"prepend-icon":"mdi-auto-fix",size:"x-small",variant:"tonal",color:"primary",onClick:s[1]||(s[1]=f=>d("ai-action",r.label))},{default:t(()=>[...s[2]||(s[2]=[n(" KI generieren ",-1)])]),_:1})])):U("",!0)])}}}),As={class:"d-flex align-center justify-space-between mb-3"},Is={key:0,class:"d-flex justify-center pa-12"},Ps={key:1,class:"text-center text-medium-emphasis pa-12"},zs=["onClick"],Ds={class:"d-flex justify-center align-center fill-height"},Ts=Ae({__name:"ImagePickerDialog",props:{modelValue:{type:Boolean}},emits:["update:modelValue","select"],setup(r,{emit:$}){const d=r,c=$,s=se({get:()=>d.modelValue,set:O=>c("update:modelValue",O)}),m=y("pool"),u=y(null),f=y([]),p=y(!1),_=y(""),k=se(()=>{const O=_.value.trim().toLowerCase();return O?f.value.filter(S=>{var B,G;return((B=S.filename)==null?void 0:B.toLowerCase().includes(O))||((G=S.tags)==null?void 0:G.some(W=>W.toLowerCase().includes(O)))}):f.value});async function i(){p.value=!0,u.value=null;try{const O=await re.get("/images?limit=100");if(O.success&&O.data){const S=O.data;f.value=Array.isArray(S)?S:S.items??[]}else u.value=O.error||"Fehler beim Laden der Bilder"}catch{u.value="Netzwerkfehler beim Laden der Bilder"}finally{p.value=!1}}function g(O){c("select",O.url),s.value=!1}const x=y([]),w=y(""),b=y(""),I=y("ASPECT_1_1"),V=y(""),E=y(!1),R=[{title:"1:1 (Quadrat)",value:"ASPECT_1_1"},{title:"4:5 (Hochformat)",value:"ASPECT_4_5"},{title:"16:9 (Querformat)",value:"ASPECT_16_9"},{title:"9:16 (Story)",value:"ASPECT_9_16"}],M=[{title:"Kein Stil",value:""},{title:"Realistisch",value:"REALISTIC"},{title:"Design",value:"DESIGN"},{title:"Anime",value:"ANIME"}];async function T(){try{const O=await re.get("/ideogram-presets?isActive=true&limit=100");if(O.success&&O.data){const S=O.data;x.value=Array.isArray(S)?S:S.items??[];const B=x.value.find(G=>G.isDefault);B&&D(B._id)}}catch{}}function D(O){if(w.value=O,!O)return;const S=x.value.find(B=>B._id===O);S&&(b.value=S.prompt||"",I.value=S.aspectRatio||"ASPECT_1_1",V.value=S.style||"")}async function H(){if(b.value.trim()){E.value=!0,u.value=null;try{const O={prompt:b.value,aspectRatio:I.value};V.value&&(O.styleType=V.value),w.value&&(O.preset=w.value);const S=await re.post("/images/generate",O);if(S.success&&S.data){const B=Array.isArray(S.data)?S.data:[S.data];if(B.length===0){u.value="Keine Bilder generiert";return}const G=B[0].url;if(typeof G!="string"||!G.trim()){u.value="Generiertes Bild hat keine gültige URL";return}B.forEach(W=>f.value.unshift(W)),c("select",G),s.value=!1}else u.value=S.error||"Fehler beim Generieren"}catch{u.value="Netzwerkfehler beim Generieren"}finally{E.value=!1}}}return Ze(s,O=>{O&&(u.value=null,i(),T())},{immediate:!0}),(O,S)=>{const B=l("v-icon"),G=l("v-btn"),W=l("v-tab"),F=l("v-tabs"),L=l("v-card-title"),A=l("v-divider"),z=l("v-alert"),j=l("v-text-field"),J=l("v-progress-circular"),Q=l("v-img"),te=l("v-chip"),ve=l("v-col"),de=l("v-row"),Z=l("v-window-item"),ce=l("v-autocomplete"),oe=l("v-textarea"),pe=l("v-select"),_e=l("v-window"),q=l("v-card-text"),C=l("v-spacer"),ae=l("v-card-actions"),X=l("v-card"),ie=l("v-dialog");return o(),N(ie,{modelValue:s.value,"onUpdate:modelValue":S[10]||(S[10]=fe=>s.value=fe),"max-width":"1170",scrollable:""},{default:t(()=>[e(X,{class:"image-picker-dialog"},{default:t(()=>[e(L,{class:"pa-4 pb-0"},{default:t(()=>[a("div",As,[S[12]||(S[12]=a("span",{class:"text-h6"},"Bild auswählen",-1)),e(G,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:S[0]||(S[0]=fe=>s.value=!1)},{default:t(()=>[e(B,null,{default:t(()=>[...S[11]||(S[11]=[n("mdi-close",-1)])]),_:1})]),_:1})]),e(F,{modelValue:m.value,"onUpdate:modelValue":S[1]||(S[1]=fe=>m.value=fe),color:"primary",density:"comfortable"},{default:t(()=>[e(W,{value:"pool","prepend-icon":"mdi-image-multiple-outline"},{default:t(()=>[...S[13]||(S[13]=[n("Bildpool",-1)])]),_:1}),e(W,{value:"generate","prepend-icon":"mdi-creation"},{default:t(()=>[...S[14]||(S[14]=[n("KI generieren",-1)])]),_:1})]),_:1},8,["modelValue"])]),_:1}),e(A),e(q,{class:"pa-4",style:{"min-height":"520px","max-height":"780px"}},{default:t(()=>[u.value?(o(),N(z,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":S[2]||(S[2]=fe=>u.value=null)},{default:t(()=>[n(v(u.value),1)]),_:1})):U("",!0),e(_e,{modelValue:m.value,"onUpdate:modelValue":S[8]||(S[8]=fe=>m.value=fe)},{default:t(()=>[e(Z,{value:"pool"},{default:t(()=>[e(j,{modelValue:_.value,"onUpdate:modelValue":S[3]||(S[3]=fe=>_.value=fe),label:"Suche",placeholder:"Dateiname oder Tag...",variant:"outlined",density:"compact","prepend-inner-icon":"mdi-magnify","hide-details":"",clearable:"",class:"mb-4"},null,8,["modelValue"]),p.value?(o(),h("div",Is,[e(J,{indeterminate:"",color:"primary"})])):k.value.length?(o(),N(de,{key:2,dense:""},{default:t(()=>[(o(!0),h(be,null,Pe(k.value,fe=>(o(),N(ve,{key:fe._id,cols:"6",sm:"4",md:"3"},{default:t(()=>[a("div",{class:"image-picker-dialog__thumb",onClick:Se=>g(fe)},[e(Q,{src:fe.url,alt:fe.filename,"aspect-ratio":"1",cover:""},{placeholder:t(()=>[a("div",Ds,[e(J,{indeterminate:"",color:"primary",size:"20"})])]),_:1},8,["src","alt"]),e(te,{color:fe.source==="ai-generated"?"primary":"default",size:"x-small",variant:"tonal",class:"image-picker-dialog__chip"},{default:t(()=>[n(v(fe.source==="ai-generated"?"KI":"Upload"),1)]),_:2},1032,["color"])],8,zs)]),_:2},1024))),128))]),_:1})):(o(),h("div",Ps,[e(B,{size:"48",color:"medium-emphasis",class:"mb-3"},{default:t(()=>[...S[15]||(S[15]=[n("mdi-image-off-outline",-1)])]),_:1}),S[16]||(S[16]=a("p",{class:"text-body-2"},'Keine Bilder gefunden. Wechsle zum Tab "KI generieren" um ein neues Bild zu erstellen.',-1))]))]),_:1}),e(Z,{value:"generate"},{default:t(()=>[x.value.length?(o(),N(ce,{key:0,"model-value":w.value,items:[{title:"Kein Preset (manueller Prompt)",value:""},...x.value.map(fe=>({title:fe.isDefault?`${fe.name} (Standard)`:fe.name,value:fe._id}))],label:"Preset",variant:"outlined",density:"comfortable",class:"mb-4",hint:"Preset wählen füllt Prompt, Seitenverhältnis und Stil vor - tippen zum Filtern","persistent-hint":"","auto-select-first":"","hide-no-data":"","onUpdate:modelValue":S[4]||(S[4]=fe=>D(fe??""))},null,8,["model-value","items"])):U("",!0),e(oe,{modelValue:b.value,"onUpdate:modelValue":S[5]||(S[5]=fe=>b.value=fe),label:"Bildbeschreibung",placeholder:"z.B. Professionelles Foto einer Cybersecurity-Präsentation...",variant:"outlined",rows:"8","auto-grow":"",class:"mb-4"},null,8,["modelValue"]),e(de,{dense:""},{default:t(()=>[e(ve,{cols:"12",sm:"6"},{default:t(()=>[e(pe,{modelValue:I.value,"onUpdate:modelValue":S[6]||(S[6]=fe=>I.value=fe),label:"Seitenverhältnis",items:R,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(ve,{cols:"12",sm:"6"},{default:t(()=>[e(pe,{modelValue:V.value,"onUpdate:modelValue":S[7]||(S[7]=fe=>V.value=fe),label:"Stil",items:M,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1})]),_:1}),S[17]||(S[17]=a("p",{class:"text-caption text-medium-emphasis mt-2"}," Es werden mehrere Bilder generiert (laut Einstellungen). Das erste Bild wird automatisch übernommen, alle landen im Bildpool. ",-1))]),_:1})]),_:1},8,["modelValue"])]),_:1}),e(A),e(ae,{class:"pa-4"},{default:t(()=>[e(C),e(G,{variant:"text",onClick:S[9]||(S[9]=fe=>s.value=!1)},{default:t(()=>[...S[18]||(S[18]=[n("Abbrechen",-1)])]),_:1}),m.value==="generate"?(o(),N(G,{key:0,color:"primary",variant:"elevated",loading:E.value,disabled:!b.value.trim(),"prepend-icon":"mdi-creation",onClick:H},{default:t(()=>[...S[19]||(S[19]=[n(" Generieren und übernehmen ",-1)])]),_:1},8,["loading","disabled"])):U("",!0)]),_:1})]),_:1})]),_:1},8,["modelValue"])}}}),vl=Me(Ts,[["__scopeId","data-v-e094cdb4"]]),Ls={class:"prop-field-image"},Es={key:0,class:"mt-2"},Ms={class:"d-flex align-center justify-center bg-grey-darken-3 rounded",style:{height:"80px"}},Wa=Ae({__name:"PropFieldImage",props:{modelValue:{},label:{},aiEnabled:{type:Boolean}},emits:["update:modelValue","ai-action"],setup(r,{emit:$}){const d=$,c=y(!1);function s(m){d("update:modelValue",m)}return(m,u)=>{const f=l("v-tooltip"),p=l("v-icon"),_=l("v-btn"),k=l("v-text-field"),i=l("v-img");return o(),h("div",Ls,[e(k,{"model-value":r.modelValue,label:r.label,density:"compact",variant:"outlined","hide-details":"auto",placeholder:"https://... oder Bild auswählen","prepend-inner-icon":"mdi-link","onUpdate:modelValue":u[1]||(u[1]=g=>d("update:modelValue",g))},{"append-inner":t(()=>[e(_,{size:"x-small",variant:"text",icon:"","aria-label":"Bild aus Pool wählen oder generieren",onClick:u[0]||(u[0]=g=>c.value=!0)},{default:t(()=>[e(f,{activator:"parent",location:"bottom"},{default:t(()=>[...u[3]||(u[3]=[n("Aus Bildpool wählen oder KI-generieren",-1)])]),_:1}),e(p,{size:"18"},{default:t(()=>[...u[4]||(u[4]=[n("mdi-image-search-outline",-1)])]),_:1})]),_:1})]),_:1},8,["model-value","label"]),r.modelValue?(o(),h("div",Es,[e(i,{src:r.modelValue,"max-height":"120",cover:"",class:"rounded"},{error:t(()=>[a("div",Ms,[e(p,{color:"grey"},{default:t(()=>[...u[5]||(u[5]=[n("mdi-image-broken",-1)])]),_:1})])]),_:1},8,["src"])])):U("",!0),c.value?(o(),N(vl,{key:1,modelValue:c.value,"onUpdate:modelValue":u[2]||(u[2]=g=>c.value=g),onSelect:s},null,8,["modelValue"])):U("",!0)])}}}),Ns={class:"prop-field-color"},Us={class:"d-flex align-center ga-2"},Bs=["title"],Za=Ae({__name:"PropFieldColor",props:{modelValue:{},label:{},aiEnabled:{type:Boolean}},emits:["update:modelValue","ai-action"],setup(r,{emit:$}){const d=r,c=$,s=y(!1),m=y(d.modelValue||"#000000");Ze(()=>d.modelValue,f=>{m.value=f||"#000000"});function u(f){m.value=f,c("update:modelValue",f)}return(f,p)=>{const _=l("v-color-picker"),k=l("v-card-text"),i=l("v-spacer"),g=l("v-btn"),x=l("v-card-actions"),w=l("v-card"),b=l("v-menu"),I=l("v-text-field");return o(),h("div",Ns,[a("div",Us,[e(b,{modelValue:s.value,"onUpdate:modelValue":p[1]||(p[1]=V=>s.value=V),"close-on-content-click":!1},{activator:t(({props:V})=>[a("div",Vt(V,{class:"color-swatch rounded cursor-pointer",style:[{backgroundColor:r.modelValue||"#000000"},{width:"36px",height:"36px",border:"2px solid rgba(255,255,255,0.2)"}],title:r.label}),null,16,Bs)]),default:t(()=>[e(w,{"min-width":"300"},{default:t(()=>[e(k,{class:"pa-2"},{default:t(()=>[e(_,{"model-value":m.value,mode:"hexa","hide-inputs":"","onUpdate:modelValue":u},null,8,["model-value"])]),_:1}),e(x,null,{default:t(()=>[e(i),e(g,{size:"small",onClick:p[0]||(p[0]=V=>s.value=!1)},{default:t(()=>[...p[3]||(p[3]=[n("Schließen",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(I,{"model-value":r.modelValue,label:r.label,density:"compact",variant:"outlined","hide-details":"","onUpdate:modelValue":p[2]||(p[2]=V=>c("update:modelValue",V))},null,8,["model-value","label"])])])}}}),Fs={class:"prop-field-number"},Ja=Ae({__name:"PropFieldNumber",props:{modelValue:{},label:{},aiEnabled:{type:Boolean}},emits:["update:modelValue","ai-action"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-text-field");return o(),h("div",Fs,[e(m,{"model-value":r.modelValue,label:r.label,type:"number",density:"compact",variant:"outlined","hide-details":"auto","onUpdate:modelValue":s[0]||(s[0]=u=>d("update:modelValue",Number(u)))},null,8,["model-value","label"])])}}}),Os={class:"prop-field-select"},Qa=Ae({__name:"PropFieldSelect",props:{modelValue:{},label:{},options:{},aiEnabled:{type:Boolean}},emits:["update:modelValue","ai-action"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-select");return o(),h("div",Os,[e(m,{"model-value":r.modelValue,label:r.label,items:r.options||[],"item-title":"label","item-value":"value",density:"compact",variant:"outlined","hide-details":"auto","onUpdate:modelValue":s[0]||(s[0]=u=>d("update:modelValue",u))},null,8,["model-value","label","items"])])}}}),Rs={class:"prop-field-select-async"},Ks=3e4,js=Ae({__name:"PropFieldSelectAsync",props:{modelValue:{},label:{},source:{},valueKey:{},labelKey:{},required:{type:Boolean}},emits:["update:modelValue","ai-action"],setup(r,{emit:$}){const d=r,c=$,s=new Map,m=y(!1),u=y(null),f=y([]),p=se(()=>`${d.source}::${d.valueKey||"slug"}::${d.labelKey||"name"}`);async function _(k=!1){const i=p.value,g=s.get(i);if(!k&&g&&Date.now()-g.ts<Ks){f.value=g.options;return}m.value=!0,u.value=null;try{const x=await re.get(d.source);if(x.success&&x.data){const w=Array.isArray(x.data)?x.data:[],b=d.valueKey||"slug",I=d.labelKey||"name",V=w.filter(E=>E&&typeof E=="object").map(E=>({value:String(E[b]??""),title:String(E[I]??E[b]??"")})).filter(E=>E.value);f.value=V,s.set(i,{options:V,ts:Date.now()}),ue.debug("ADMIN","PropFieldSelectAsync: Optionen geladen",{source:d.source,count:V.length})}else u.value=x.error||"Optionen konnten nicht geladen werden.",ue.error("ADMIN","PropFieldSelectAsync Ladefehler",{source:d.source,error:x.error})}catch(x){u.value="Netzwerkfehler beim Laden der Optionen.",ue.error("ADMIN","PropFieldSelectAsync Netzwerkfehler",{err:x})}finally{m.value=!1}}return rt(()=>{_()}),Ze(()=>d.source,()=>_()),(k,i)=>{const g=l("v-icon"),x=l("v-tooltip"),w=l("v-btn"),b=l("v-select");return o(),h("div",Rs,[e(b,{"model-value":r.modelValue,label:r.label,items:f.value,"item-title":"title","item-value":"value",density:"compact",variant:"outlined","hide-details":"auto",loading:m.value,"error-messages":u.value?[u.value]:[],"no-data-text":m.value?"Lade...":"Keine Optionen verfügbar","onUpdate:modelValue":i[1]||(i[1]=I=>c("update:modelValue",I||""))},{"append-inner":t(()=>[e(w,{icon:"mdi-refresh",size:"x-small",variant:"text","aria-label":"Aktualisieren",onClick:i[0]||(i[0]=dt(I=>_(!0),["stop"]))},{default:t(()=>[e(g,{size:"small"},{default:t(()=>[...i[2]||(i[2]=[n("mdi-refresh",-1)])]),_:1}),e(x,{activator:"parent",location:"top"},{default:t(()=>[...i[3]||(i[3]=[n("Aktualisieren",-1)])]),_:1})]),_:1})]),_:1},8,["model-value","label","items","loading","error-messages","no-data-text"])])}}}),qs={class:"prop-field-boolean"},Gs=Ae({__name:"PropFieldBoolean",props:{modelValue:{type:Boolean},label:{},aiEnabled:{type:Boolean}},emits:["update:modelValue","ai-action"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-switch");return o(),h("div",qs,[e(m,{"model-value":r.modelValue,label:r.label,density:"compact",color:"primary","hide-details":"","onUpdate:modelValue":s[0]||(s[0]=u=>d("update:modelValue",!!u))},null,8,["model-value","label"])])}}}),Hs={class:"prop-field-cards"},Ws={class:"d-flex align-center justify-space-between mb-2"},Zs={class:"text-body-2 text-medium-emphasis"},Js={class:"d-flex align-start ga-1 mb-2"},Qs={class:"text-caption text-medium-emphasis flex-grow-1"},Ys={key:0,class:"d-flex flex-column ga-2"},Xs={key:0},ei={key:1},ti={key:2},ai={key:3},li={key:4},ni={key:5},oi={key:6},si={key:7},ii={key:0,class:"text-center text-caption text-medium-emphasis py-3"},ri=Ae({__name:"PropFieldCards",props:{modelValue:{},label:{},itemSchema:{},aiEnabled:{type:Boolean}},emits:["update:modelValue","ai-action"],setup(r,{emit:$}){const d=r,c=$,s=se({get:()=>d.modelValue||[],set:i=>c("update:modelValue",i)});function m(){const i={};if(d.itemSchema)for(const[g,x]of Object.entries(d.itemSchema.properties))i[g]=x.default!==void 0?x.default:"";c("update:modelValue",[...s.value,i])}function u(i){const g=[...s.value];g.splice(i,1),c("update:modelValue",g)}function f(i,g,x){const w=s.value.map((b,I)=>I===i?{...b,[g]:x}:b);c("update:modelValue",w)}function p(i){var g,x;return((x=(g=d.itemSchema)==null?void 0:g.properties[i])==null?void 0:x.type)||"text"}function _(i){var g,x;return((x=(g=d.itemSchema)==null?void 0:g.properties[i])==null?void 0:x.label)||i}function k(i){var g,x;return((x=(g=d.itemSchema)==null?void 0:g.properties[i])==null?void 0:x.options)||[]}return(i,g)=>{const x=l("v-btn"),w=l("v-icon"),b=l("v-text-field"),I=l("v-textarea"),V=l("v-switch"),E=l("v-select"),R=l("v-alert"),M=l("v-card-text"),T=l("v-card");return o(),h("div",Hs,[a("div",Ws,[a("span",Zs,v(r.label),1),e(x,{size:"x-small",variant:"tonal",color:"primary","prepend-icon":"mdi-plus",onClick:m},{default:t(()=>[...g[1]||(g[1]=[n(" Hinzufügen ",-1)])]),_:1})]),e(P(sl),{modelValue:s.value,"onUpdate:modelValue":g[0]||(g[0]=D=>s.value=D),"item-key":"_index",handle:".card-drag-handle","ghost-class":"dragging-ghost"},{item:t(({element:D,index:H})=>[e(T,{class:"mb-2",variant:"outlined",density:"compact"},{default:t(()=>[e(M,{class:"pa-2"},{default:t(()=>[a("div",Js,[e(w,{class:"card-drag-handle cursor-grab mt-1",size:"small",color:"grey"},{default:t(()=>[...g[2]||(g[2]=[n("mdi-drag-vertical",-1)])]),_:1}),a("span",Qs,"Eintrag "+v(H+1),1),e(x,{icon:"mdi-delete-outline",size:"x-small",variant:"text",color:"error",onClick:O=>u(H)},null,8,["onClick"])]),r.itemSchema?(o(),h("div",Ys,[(o(!0),h(be,null,Pe(r.itemSchema.properties,(O,S)=>(o(),h(be,{key:S},[p(String(S))==="text"?(o(),h("div",Xs,[e(b,{"model-value":String(D[S]??""),label:_(String(S)),density:"compact",variant:"outlined","hide-details":"","onUpdate:modelValue":B=>f(H,String(S),B)},null,8,["model-value","label","onUpdate:modelValue"])])):p(String(S))==="richtext"?(o(),h("div",ei,[e(I,{"model-value":String(D[S]??""),label:_(String(S)),density:"compact",variant:"outlined","hide-details":"",rows:3,"onUpdate:modelValue":B=>f(H,String(S),B)},null,8,["model-value","label","onUpdate:modelValue"])])):p(String(S))==="number"?(o(),h("div",ti,[e(b,{"model-value":D[S],label:_(String(S)),type:"number",density:"compact",variant:"outlined","hide-details":"","onUpdate:modelValue":B=>f(H,String(S),Number(B))},null,8,["model-value","label","onUpdate:modelValue"])])):p(String(S))==="boolean"?(o(),h("div",ai,[e(V,{"model-value":!!D[S],label:_(String(S)),density:"compact",color:"primary","hide-details":"","onUpdate:modelValue":B=>f(H,String(S),!!B)},null,8,["model-value","label","onUpdate:modelValue"])])):p(String(S))==="select"?(o(),h("div",li,[e(E,{"model-value":D[S],label:_(String(S)),items:k(String(S)),"item-title":"label","item-value":"value",density:"compact",variant:"outlined","hide-details":"","onUpdate:modelValue":B=>f(H,String(S),B)},null,8,["model-value","label","items","onUpdate:modelValue"])])):p(String(S))==="image"?(o(),h("div",ni,[e(b,{"model-value":String(D[S]??""),label:_(String(S)),density:"compact",variant:"outlined","hide-details":"","prepend-inner-icon":"mdi-link",placeholder:"https://...","onUpdate:modelValue":B=>f(H,String(S),B)},null,8,["model-value","label","onUpdate:modelValue"])])):p(String(S))==="cards"?(o(),h("div",oi,[e(R,{type:"info",density:"compact",variant:"tonal",class:"text-caption"},{default:t(()=>[n(v(_(String(S)))+": verschachtelte Listen bitte direkt bearbeiten. ",1)]),_:2},1024)])):(o(),h("div",si,[e(b,{"model-value":String(D[S]??""),label:_(String(S)),density:"compact",variant:"outlined","hide-details":"","onUpdate:modelValue":B=>f(H,String(S),B)},null,8,["model-value","label","onUpdate:modelValue"])]))],64))),128))])):U("",!0)]),_:2},1024)]),_:2},1024)]),_:1},8,["modelValue"]),s.value.length===0?(o(),h("div",ii," Noch keine Einträge vorhanden. ")):U("",!0)])}}}),di=Me(ri,[["__scopeId","data-v-3b4dae90"]]),ui={class:"prop-field-code"},ci=Ae({__name:"PropFieldCode",props:{modelValue:{},label:{},aiEnabled:{type:Boolean}},emits:["update:modelValue","ai-action"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-textarea");return o(),h("div",ui,[e(m,{"model-value":r.modelValue,label:r.label,rows:10,density:"compact",variant:"outlined","hide-details":"auto",class:"code-textarea",placeholder:"<!-- HTML Code hier eingeben -->","onUpdate:modelValue":s[0]||(s[0]=u=>d("update:modelValue",u))},null,8,["model-value","label"])])}}}),Ya=Me(ci,[["__scopeId","data-v-671cc918"]]),mi={class:"module-editor h-100 overflow-y-auto"},vi={key:0,class:"d-flex flex-column align-center justify-center h-100 text-medium-emphasis pa-6 text-center"},pi={class:"module-editor-header pa-4 border-b d-flex align-center ga-2"},fi={class:"text-body-1 font-weight-medium"},gi={class:"text-caption text-medium-emphasis"},bi={class:"pa-4 d-flex flex-column ga-4"},yi={class:"d-flex flex-column ga-3"},_i={key:0},ki={class:"d-flex flex-column ga-3"},hi={class:"d-flex flex-column ga-3"},xi={class:"d-flex flex-column ga-2"},wi={class:"mt-3"},Si={class:"mt-3"},$i={class:"mt-3"},Ci=Ae({__name:"ModuleEditor",emits:["ai-action"],setup(r,{emit:$}){const d=$,c=Jt(),s=se(()=>c.selectedSection),m=se(()=>c.selectedSectionIndex),u=se(()=>c.editorMode==="advanced"),f=se(()=>s.value&&Na(s.value.type)||null);function p(R,M){if(m.value<0)return;const T=s.value;T&&c.updateSectionProps(m.value,{settings:{...T.settings||{},[R]:M}})}function _(R,M){m.value<0||c.updateSectionProps(m.value,{[R]:M})}function k(R,M){m.value<0||!s.value||c.updateSectionProps(m.value,{visibility:{desktop:!0,tablet:!0,mobile:!0,...s.value.visibility,[R]:M}})}function i(R){m.value<0||c.updateSectionProps(m.value,{cssOverrides:R})}function g(R){m.value<0||c.updateSectionProps(m.value,{customClasses:R})}const x=y("");Ze(()=>c.selectedSectionIndex,()=>{x.value=""});function w(R){if(m.value<0)return;const M=(R||"").trim();if(M===""){x.value="",c.updateSectionProps(m.value,{customId:""});return}if(M.length>64){x.value="Max. 64 Zeichen";return}if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(M)){x.value="Nur a-z, A-Z, 0-9, _ und -; muss mit Buchstabe beginnen";return}x.value="",c.updateSectionProps(m.value,{customId:M})}function b(R,M){if(m.value<0||!s.value)return;const T=s.value.style||{},D=M===""||M===null||typeof M=="number"&&Number.isNaN(M),H={...T};D?delete H[String(R)]:H[String(R)]=M,c.updateSectionProps(m.value,{style:H})}function I(R){return s.value?(s.value.style||{})[R]:void 0}function V(R){s.value&&d("ai-action",{field:R,sectionIndex:m.value,type:s.value.type})}function E(R){var T,D;if(!s.value)return"";const M=s.value.settings;return(M==null?void 0:M[R])??((D=(T=f.value)==null?void 0:T.defaultProps)==null?void 0:D[R])??""}return(R,M)=>{var G,W;const T=l("v-icon"),D=l("v-expansion-panel-text"),H=l("v-expansion-panel"),O=l("v-expansion-panels"),S=l("v-switch"),B=l("v-text-field");return o(),h("div",mi,[s.value?(o(),h(be,{key:1},[a("div",pi,[e(T,{icon:((G=f.value)==null?void 0:G.icon)||"mdi-puzzle-outline",color:"primary"},null,8,["icon"]),a("div",null,[a("div",fi,v(((W=f.value)==null?void 0:W.label)||s.value.type),1),a("div",gi,v(s.value.name||s.value.sectionId),1)])]),a("div",bi,[a("div",null,[M[10]||(M[10]=a("div",{class:"text-caption text-medium-emphasis mb-2 text-uppercase font-weight-bold"},"Basis",-1)),a("div",yi,[e(wa,{"model-value":s.value.title,label:"Überschrift","ai-enabled":!0,"onUpdate:modelValue":M[0]||(M[0]=F=>_("title",F)),onAiAction:V},null,8,["model-value"]),e(Ha,{"model-value":s.value.content,label:"Inhalt","ai-enabled":!0,"onUpdate:modelValue":M[1]||(M[1]=F=>_("content",F)),onAiAction:V},null,8,["model-value"])])]),f.value&&Object.keys(f.value.schema.properties).length>0?(o(),h("div",_i,[M[11]||(M[11]=a("div",{class:"text-caption text-medium-emphasis mb-2 text-uppercase font-weight-bold"},"Einstellungen",-1)),a("div",ki,[(o(!0),h(be,null,Pe(f.value.schema.properties,(F,L)=>(o(),h(be,{key:L},[F.type==="text"?(o(),N(wa,{key:0,"model-value":String(E(String(L))),label:F.label,"ai-enabled":F.aiEnabled,"onUpdate:modelValue":A=>p(String(L),A),onAiAction:V},null,8,["model-value","label","ai-enabled","onUpdate:modelValue"])):F.type==="richtext"?(o(),N(Ha,{key:1,"model-value":String(E(String(L))),label:F.label,"ai-enabled":F.aiEnabled,"onUpdate:modelValue":A=>p(String(L),A),onAiAction:V},null,8,["model-value","label","ai-enabled","onUpdate:modelValue"])):F.type==="image"?(o(),N(Wa,{key:2,"model-value":String(E(String(L))),label:F.label,"onUpdate:modelValue":A=>p(String(L),A),onAiAction:V},null,8,["model-value","label","onUpdate:modelValue"])):F.type==="color"?(o(),N(Za,{key:3,"model-value":String(E(String(L))),label:F.label,"onUpdate:modelValue":A=>p(String(L),A),onAiAction:V},null,8,["model-value","label","onUpdate:modelValue"])):F.type==="number"?(o(),N(Ja,{key:4,"model-value":Number(E(String(L))),label:F.label,"onUpdate:modelValue":A=>p(String(L),A),onAiAction:V},null,8,["model-value","label","onUpdate:modelValue"])):F.type==="select"?(o(),N(Qa,{key:5,"model-value":String(E(String(L))),label:F.label,options:F.options,"onUpdate:modelValue":A=>p(String(L),A),onAiAction:V},null,8,["model-value","label","options","onUpdate:modelValue"])):F.type==="select-async"&&F.source?(o(),N(js,{key:6,"model-value":String(E(String(L))),label:F.label,source:F.source,"value-key":F.valueKey,"label-key":F.labelKey,required:F.required,"onUpdate:modelValue":A=>p(String(L),A)},null,8,["model-value","label","source","value-key","label-key","required","onUpdate:modelValue"])):F.type==="boolean"?(o(),N(Gs,{key:7,"model-value":!!E(String(L)),label:F.label,"onUpdate:modelValue":A=>p(String(L),A),onAiAction:V},null,8,["model-value","label","onUpdate:modelValue"])):F.type==="cards"?(o(),N(di,{key:8,"model-value":E(String(L)),label:F.label,"item-schema":F.itemSchema,"onUpdate:modelValue":A=>p(String(L),A),onAiAction:V},null,8,["model-value","label","item-schema","onUpdate:modelValue"])):F.type==="code"?(o(),N(Ya,{key:9,"model-value":String(E(String(L))),label:F.label,"onUpdate:modelValue":A=>p(String(L),A),onAiAction:V},null,8,["model-value","label","onUpdate:modelValue"])):U("",!0)],64))),128))])])):U("",!0),e(O,{variant:"accordion"},{default:t(()=>[e(H,{title:"Erscheinungsbild"},{default:t(()=>[e(D,null,{default:t(()=>[a("div",hi,[(o(!0),h(be,null,Pe(P(Ss).properties,(F,L)=>(o(),h(be,{key:"style-"+L},[F.type==="image"?(o(),N(Wa,{key:0,"model-value":String(I(String(L))??""),label:F.label,"onUpdate:modelValue":A=>b(L,A)},null,8,["model-value","label","onUpdate:modelValue"])):F.type==="color"?(o(),N(Za,{key:1,"model-value":String(I(String(L))??""),label:F.label,"onUpdate:modelValue":A=>b(L,A)},null,8,["model-value","label","onUpdate:modelValue"])):F.type==="number"?(o(),N(Ja,{key:2,"model-value":typeof I(String(L))=="number"?Number(I(String(L))):null,label:F.label,"onUpdate:modelValue":A=>b(L,A)},null,8,["model-value","label","onUpdate:modelValue"])):F.type==="select"?(o(),N(Qa,{key:3,"model-value":String(I(String(L))??""),label:F.label,options:F.options,"onUpdate:modelValue":A=>b(L,A)},null,8,["model-value","label","options","onUpdate:modelValue"])):U("",!0)],64))),128))])]),_:1})]),_:1})]),_:1}),u.value?(o(),N(O,{key:1,variant:"accordion"},{default:t(()=>[e(H,{title:"Sichtbarkeit & CSS"},{default:t(()=>[e(D,null,{default:t(()=>{var F,L,A;return[a("div",xi,[M[12]||(M[12]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Gerätespezifische Sichtbarkeit",-1)),e(S,{"model-value":((F=s.value.visibility)==null?void 0:F.desktop)!==!1,label:"Desktop",density:"compact",color:"primary","hide-details":"","onUpdate:modelValue":M[2]||(M[2]=z=>k("desktop",!!z))},null,8,["model-value"]),e(S,{"model-value":((L=s.value.visibility)==null?void 0:L.tablet)!==!1,label:"Tablet",density:"compact",color:"primary","hide-details":"","onUpdate:modelValue":M[3]||(M[3]=z=>k("tablet",!!z))},null,8,["model-value"]),e(S,{"model-value":((A=s.value.visibility)==null?void 0:A.mobile)!==!1,label:"Mobil",density:"compact",color:"primary","hide-details":"","onUpdate:modelValue":M[4]||(M[4]=z=>k("mobile",!!z))},null,8,["model-value"]),a("div",wi,[e(B,{"model-value":s.value.customId||"",label:"HTML-id (Anker-Ziel, z.B. tippspiel)",placeholder:"tippspiel","error-messages":x.value?[x.value]:[],hint:"Macht aus der Section <section id='...'>. Nutze für CTA-Links wie #tippspiel. Nur Buchstaben/Zahlen/_/-, max 64.","persistent-hint":"",density:"compact",variant:"outlined","onUpdate:modelValue":M[5]||(M[5]=z=>w(z))},null,8,["model-value","error-messages"])]),a("div",Si,[e(wa,{"model-value":s.value.customClasses||"",label:"Zusätzliche CSS-Klassen","onUpdate:modelValue":M[6]||(M[6]=z=>g(z))},null,8,["model-value"])]),a("div",$i,[e(Ya,{"model-value":s.value.cssOverrides||"",label:"CSS-Overrides (Section-gescoped via CSS-Nesting)","onUpdate:modelValue":M[7]||(M[7]=z=>i(z)),onAiAction:V},null,8,["model-value"])])])]}),_:1})]),_:1})]),_:1})):U("",!0)])],64)):(o(),h("div",vi,[e(T,{size:"48",class:"mb-4",color:"grey"},{default:t(()=>[...M[8]||(M[8]=[n("mdi-cursor-pointer",-1)])]),_:1}),M[9]||(M[9]=a("p",{class:"text-body-1"},"Wähle ein Modul in der Seitenleiste aus, um es zu bearbeiten.",-1))]))])}}}),Vi=Me(Ci,[["__scopeId","data-v-b6bfc0fe"]]),Ai={class:"live-preview"},Ii={class:"live-preview__toolbar d-flex align-center ga-2 pa-2"},Pi=["srcdoc"],zi=Ae({__name:"LivePreview",setup(r){const $=Jt(),d=y("desktop"),c=se(()=>{switch(d.value){case"tablet":return"768px";case"mobile":return"375px";default:return"100%"}});function s(f){return f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function m(f){const p=Na(f.type),_=(p==null?void 0:p.label)||f.type,k=f.title?`<h2 style="margin-bottom: 12px;">${s(f.title)}</h2>`:"",i=f.content?`<div>${f.content}</div>`:"";return`<div style="padding: 24px 32px; border-bottom: 1px solid rgba(255,255,255,0.08);">
    <div style="font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: #0AC9D4; margin-bottom: 8px;">${s(_)}</div>
    ${k}
    ${i}
  </div>`}const u=se(()=>$.currentPage?`<!DOCTYPE html>
<html lang="de">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&family=Montserrat:wght@400;600;700&display=swap" rel="stylesheet">
  <style>
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body {
      background: #000000;
      color: #FFFFFF;
      font-family: 'Lato', sans-serif;
      font-size: 16px;
      line-height: 1.6;
    }
    h1, h2, h3, h4 {
      font-family: 'Montserrat', sans-serif;
      font-weight: 700;
    }
    a { color: #0AC9D4; }
  </style>
</head>
<body>
  <div style="max-width: 1200px; margin: 0 auto;">
    ${($.currentPage.content||[]).map(m).join("")||'<div style="padding: 48px; text-align: center; color: #748686;">Keine Module vorhanden</div>'}
  </div>
</body>
</html>`:"");return(f,p)=>{const _=l("v-tooltip"),k=l("v-btn"),i=l("v-btn-toggle");return o(),h("div",Ai,[a("div",Ii,[e(i,{modelValue:d.value,"onUpdate:modelValue":p[0]||(p[0]=g=>d.value=g),mandatory:"",density:"compact",variant:"outlined"},{default:t(()=>[e(k,{value:"desktop",icon:"mdi-monitor",size:"small","aria-label":"Desktop-Vorschau"},{default:t(()=>[e(_,{activator:"parent",location:"bottom"},{default:t(()=>[...p[1]||(p[1]=[n("Desktop-Vorschau",-1)])]),_:1})]),_:1}),e(k,{value:"tablet",icon:"mdi-tablet",size:"small","aria-label":"Tablet-Vorschau"},{default:t(()=>[e(_,{activator:"parent",location:"bottom"},{default:t(()=>[...p[2]||(p[2]=[n("Tablet-Vorschau",-1)])]),_:1})]),_:1}),e(k,{value:"mobile",icon:"mdi-cellphone",size:"small","aria-label":"Mobile-Vorschau"},{default:t(()=>[e(_,{activator:"parent",location:"bottom"},{default:t(()=>[...p[3]||(p[3]=[n("Mobile-Vorschau",-1)])]),_:1})]),_:1})]),_:1},8,["modelValue"]),p[4]||(p[4]=a("span",{class:"text-caption text-medium-emphasis"},"Vorschau",-1))]),a("div",{class:"live-preview__frame",style:ht({maxWidth:c.value})},[a("iframe",{srcdoc:u.value,frameborder:"0",class:"live-preview__iframe"},null,8,Pi)],4)])}}}),Di=Me(zi,[["__scopeId","data-v-2e4c7d86"]]),Ti={class:"pa-4 pb-2"},Li={key:0,class:"text-center py-8 text-medium-emphasis"},Ei={class:"mb-1 mt-3 text-caption text-medium-emphasis text-uppercase font-weight-bold px-1"},Mi={class:"text-body-2 font-weight-medium"},Ni=Ae({__name:"ModulePickerDialog",props:{modelValue:{type:Boolean},insertAtIndex:{}},emits:["update:modelValue"],setup(r,{emit:$}){const d=r,c=$,s=Jt(),m=y(""),u=se(()=>s.editorMode==="advanced"),f={content:"Inhalt",layout:"Layout",media:"Medien",interactive:"Interaktiv",advanced:"Erweitert"},p=["content","layout","media","interactive","advanced"],_=se(()=>{let x=ds();if(u.value||(x=x.filter(b=>b.type!=="custom-html")),!m.value.trim())return x;const w=m.value.toLowerCase();return x.filter(b=>b.label.toLowerCase().includes(w)||b.type.toLowerCase().includes(w)||b.category.toLowerCase().includes(w))}),k=se(()=>p.map(x=>({category:x,label:f[x],modules:_.value.filter(w=>w.category===x)})).filter(x=>x.modules.length>0));function i(x){s.addSection(x,d.insertAtIndex),g()}function g(){m.value="",c("update:modelValue",!1)}return(x,w)=>{const b=l("v-icon"),I=l("v-spacer"),V=l("v-tooltip"),E=l("v-btn"),R=l("v-card-title"),M=l("v-divider"),T=l("v-text-field"),D=l("v-card"),H=l("v-col"),O=l("v-row"),S=l("v-card-text"),B=l("v-card-actions"),G=l("v-dialog");return o(),N(G,{"model-value":r.modelValue,"max-width":"700",scrollable:"","onUpdate:modelValue":w[1]||(w[1]=W=>c("update:modelValue",W))},{default:t(()=>[e(D,null,{default:t(()=>[e(R,{class:"d-flex align-center ga-2"},{default:t(()=>[e(b,{color:"primary"},{default:t(()=>[...w[2]||(w[2]=[n("mdi-puzzle-plus-outline",-1)])]),_:1}),w[4]||(w[4]=n(" Modul hinzufügen ",-1)),e(I),e(E,{icon:"mdi-close",variant:"text",size:"small","aria-label":"Schließen",onClick:g},{default:t(()=>[e(V,{activator:"parent",location:"bottom"},{default:t(()=>[...w[3]||(w[3]=[n("Schließen",-1)])]),_:1})]),_:1})]),_:1}),e(M),a("div",Ti,[e(T,{modelValue:m.value,"onUpdate:modelValue":w[0]||(w[0]=W=>m.value=W),placeholder:"Modul suchen...","prepend-inner-icon":"mdi-magnify",density:"compact",variant:"outlined","hide-details":"",autofocus:"",clearable:""},null,8,["modelValue"])]),e(S,{class:"overflow-y-auto",style:{"max-height":"500px"}},{default:t(()=>[k.value.length===0?(o(),h("div",Li,[e(b,{size:"40",class:"mb-2",color:"grey"},{default:t(()=>[...w[5]||(w[5]=[n("mdi-magnify-remove-outline",-1)])]),_:1}),a("p",null,'Kein Modul gefunden für "'+v(m.value)+'"',1)])):U("",!0),(o(!0),h(be,null,Pe(k.value,W=>(o(),h(be,{key:W.category},[a("div",Ei,v(W.label),1),e(O,{dense:""},{default:t(()=>[(o(!0),h(be,null,Pe(W.modules,F=>(o(),N(H,{key:F.type,cols:"6",sm:"4",md:"3"},{default:t(()=>[e(D,{class:"module-picker-card text-center pa-3 cursor-pointer h-100",variant:"outlined",ripple:!0,onClick:L=>i(F.type)},{default:t(()=>[e(b,{icon:F.icon,size:"32",color:"primary",class:"mb-2"},null,8,["icon"]),a("div",Mi,v(F.label),1)]),_:2},1032,["onClick"])]),_:2},1024))),128))]),_:2},1024)],64))),128))]),_:1}),e(M),e(B,null,{default:t(()=>[e(I),e(E,{variant:"text",onClick:g},{default:t(()=>[...w[6]||(w[6]=[n("Abbrechen",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["model-value"])}}}),Ui=Me(Ni,[["__scopeId","data-v-a881a4fc"]]),Bi={key:0,class:"pa-4"},Fi={class:"d-flex align-center justify-space-between mb-4"},Oi={class:"d-flex align-center ga-2"},Ri={key:0,class:"text-caption text-medium-emphasis d-flex align-center"},Ki={key:1,class:"text-caption text-success d-flex align-center"},ji={key:2,class:"text-caption text-error d-flex align-center"},qi={class:"text-body-2"},Gi={key:2,class:"structured-data-fields pl-3 mb-4"},Hi={class:"d-flex align-center justify-space-between mb-2"},Wi={class:"text-caption text-medium-emphasis"},Zi={class:"d-flex align-center justify-space-between mb-2"},Ji={class:"text-caption text-medium-emphasis"},Qi={key:1,class:"pa-4 d-flex flex-column align-center justify-center text-medium-emphasis"},Yi=Ae({__name:"PageSettingsDrawer",props:{modelValue:{type:Boolean},isReadOnly:{type:Boolean}},emits:["update:modelValue"],setup(r,{emit:$}){const d=r,c=$,s=Jt(),m=se(()=>s.currentPage),u=se(()=>s.editorMode==="advanced");Ze(()=>d.modelValue,me=>{me&&s.pages.length===0&&s.fetchPages()});const f=y(!1),p=se(()=>{if(!m.value)return[];const me=m.value._id;function ee(K,le=new Set){var ne;if(le.has(K))return le;for(const Ce of s.pages)((ne=Ce.navigation)==null?void 0:ne.parentId)===K&&!le.has(Ce._id)&&(le.add(Ce._id),ee(Ce._id,le));return le}const Y=ee(me);return s.pages.filter(K=>K._id!==me&&!Y.has(K._id)).map(K=>({title:`${K.title} (${K.path})`,value:K._id}))});function _(me,ee){const Y=ee?s.pages.find(K=>K._id===ee):null;return Y?`${Y.path}/${me}`:`/${me}`}function k(me){if(!m.value)return;Se("parentId",me);const ee=_(m.value.slug,me);ee!==m.value.path&&(f.value=!0,T("path",ee))}function i(me){var K;if(!m.value)return;T("slug",me);const ee=(K=m.value.navigation)==null?void 0:K.parentId,Y=_(me,ee);Y!==m.value.path&&T("path",Y)}Ze(f,me=>{me&&setTimeout(()=>{f.value=!1},5e3)});const g=y("idle"),x=y({});let w=null;async function b(){if(d.isReadOnly||Object.keys(x.value).length===0)return;w&&(clearTimeout(w),w=null),g.value="saving";const me={...x.value};x.value={},(await s.saveSettings(me)).success?(g.value="saved",setTimeout(()=>{g.value==="saved"&&(g.value="idle")},2e3)):(g.value="error",setTimeout(()=>{g.value==="error"&&(g.value="idle")},3e3))}function I(){w&&clearTimeout(w),w=setTimeout(b,1e3)}Ze(()=>d.modelValue,me=>{me||b()}),Ft(()=>{w&&clearTimeout(w)});const V=[{title:"Homepage",value:"homepage"},{title:"Service",value:"service"},{title:"Branche",value:"branch"},{title:"Über uns",value:"about"},{title:"Kontakt",value:"contact"},{title:"Blog",value:"blog"},{title:"Blog Post",value:"blog-post"},{title:"Legal",value:"legal"},{title:"Landing Page",value:"landing"},{title:"College",value:"college"}],E=["BaseCompliance","BaseConsulting","BaseCyber","Branchen","Allgemein","Legal","Blog","Landing Pages"],R=se(()=>{const me=s.pages.map(ee=>ee.category).filter(Boolean);return[...new Set([...E,...me])].sort()}),M=[{title:"Entwurf",value:"draft",color:"warning"},{title:"Veröffentlicht",value:"published",color:"success"},{title:"In Review",value:"in-review",color:"info"},{title:"Archiviert",value:"archived",color:"default"}];function T(me,ee){!m.value||d.isReadOnly||(m.value[me]=ee,me!=="status"&&(x.value[me]=ee,I()))}function D(me,ee){if(!m.value||d.isReadOnly)return;m.value.seo||(m.value.seo={});const Y=m.value.seo;ee==null||ee===""||Array.isArray(ee)&&ee.length===0?delete Y[me]:Y[me]=ee,x.value.seo={...Y},I()}function H(me){if(!Array.isArray(me)){D("articleTags",void 0);return}const ee=me.map(K=>String(K??"").trim()).filter(K=>K.length>0),Y=Array.from(new Set(ee));D("articleTags",Y)}const O=[{title:"- Standard (je nach Seitentyp) -",value:""},{title:"Immer (always)",value:"always"},{title:"Stündlich (hourly)",value:"hourly"},{title:"Täglich (daily)",value:"daily"},{title:"Wöchentlich (weekly)",value:"weekly"},{title:"Monatlich (monthly)",value:"monthly"},{title:"Jährlich (yearly)",value:"yearly"},{title:"Nie (never)",value:"never"}];function S(me){if(me===""||me===null||me===void 0){D("priority",void 0);return}const ee=typeof me=="number"?me:parseFloat(String(me));if(Number.isNaN(ee)){D("priority",void 0);return}const Y=Math.max(0,Math.min(1,Math.round(ee*10)/10));D("priority",Y)}function B(me){if(me===""||me===null||me===void 0){D("changefreq",void 0);return}D("changefreq",me)}const G=[{value:"none",title:"- Kein strukturiertes Schema -"},{value:"Service",title:"Service (Leistung)"},{value:"FAQ",title:"FAQ (Fragen und Antworten)"},{value:"Article",title:"Artikel"},{value:"LocalBusiness",title:"Lokales Unternehmen (Standort)"},{value:"Breadcrumb",title:"Breadcrumb (Navigationspfad)"}],W=[{value:"",title:"- Keine Angabe -"},{value:"$",title:"$ (günstig)"},{value:"$$",title:"$$ (mittel)"},{value:"$$$",title:"$$$ (gehoben)"},{value:"$$$$",title:"$$$$ (premium)"}],F=["DE","AT","CH"],L=se(()=>{var Y;const me=(Y=m.value)==null?void 0:Y.seo;return(me==null?void 0:me.structuredData)??null}),A=se(()=>{var me;return((me=L.value)==null?void 0:me.type)??"none"});function z(me){if(!m.value||d.isReadOnly)return;m.value.seo||(m.value.seo={});const ee=m.value.seo;me===null?delete ee.structuredData:ee.structuredData=me,x.value.seo={...ee},I()}function j(me){const ee=me??"none";if(ee==="none"){z(null);return}ee==="Service"?z({type:"Service",areaServed:[...F]}):ee==="FAQ"?z({type:"FAQ",items:[{question:"",answer:""}]}):ee==="Article"?z({type:"Article"}):ee==="LocalBusiness"?z({type:"LocalBusiness"}):ee==="Breadcrumb"&&z({type:"Breadcrumb",items:[{name:"",url:""}]})}function J(me){const ee={type:"Service"},Y=(me.name??"").trim();Y&&(ee.name=Y);const K=(me.description??"").trim();K&&(ee.description=K);const le=(me.serviceType??"").trim();le&&(ee.serviceType=le);const ne=(me.priceRange??"").trim();ne&&(ee.priceRange=ne);const Ce=Array.isArray(me.areaServed)?me.areaServed.map(ke=>String(ke).trim()).filter(Boolean):[];return Ce.length>0&&(ee.areaServed=Ce),ee}function Q(me,ee){const K={...L.value&&L.value.type==="Service"?L.value:{type:"Service"},[me]:ee};z(J(K))}function te(me){const ee={type:"Article"},Y=(me.headline??"").trim();Y&&(ee.headline=Y);const K=(me.datePublished??"").trim();K&&(ee.datePublished=K);const le=(me.dateModified??"").trim();le&&(ee.dateModified=le);const ne=(me.author??"").trim();ne&&(ee.author=ne);const Ce=(me.image??"").trim();return Ce&&(ee.image=Ce),ee}function ve(me,ee){const K={...L.value&&L.value.type==="Article"?L.value:{type:"Article"},[me]:ee};z(te(K))}const de=se(()=>{var me;return((me=L.value)==null?void 0:me.type)!=="FAQ"?[]:L.value.items??[]});function Z(me){return me.map(ee=>({question:(ee.question??"").trim(),answer:(ee.answer??"").trim()})).filter(ee=>ee.question!==""&&ee.answer!=="")}function ce(me){const ee=Z(me),Y=ee.length>0?ee:[{question:"",answer:""}];z({type:"FAQ",items:Y})}function oe(me,ee,Y){const K=de.value.map((le,ne)=>ne===me?{...le,[ee]:Y}:le);ce(K)}function pe(){ce([...de.value,{question:"",answer:""}])}function _e(me){const ee=de.value.filter((Y,K)=>K!==me);ce(ee.length>0?ee:[{question:"",answer:""}])}const q=se(()=>{var me;return((me=L.value)==null?void 0:me.type)!=="Breadcrumb"?[]:L.value.items??[]});function C(me){return me.map(ee=>{const Y=(ee.name??"").trim(),K=(ee.url??"").trim(),le={name:Y};return K&&(le.url=K),le}).filter(ee=>ee.name!=="")}function ae(me){const ee=C(me),Y=ee.length>0?ee:[{name:"",url:""}];z({type:"Breadcrumb",items:Y})}function X(me,ee,Y){const K=q.value.map((le,ne)=>ne===me?{...le,[ee]:Y}:le);ae(K)}function ie(){ae([...q.value,{name:"",url:""}])}function fe(me){const ee=q.value.filter((Y,K)=>K!==me);ae(ee.length>0?ee:[{name:"",url:""}])}function Se(me,ee){!m.value||d.isReadOnly||(m.value.navigation||(m.value.navigation={}),m.value.navigation[me]=ee,x.value.navigation={...m.value.navigation},I())}return(me,ee)=>{const Y=l("v-progress-circular"),K=l("v-icon"),le=l("v-tooltip"),ne=l("v-btn"),Ce=l("v-alert"),ke=l("v-text-field"),xe=l("v-select"),Ne=l("v-combobox"),Ie=l("v-divider"),Ue=l("v-textarea"),Te=l("v-switch"),ye=l("v-card"),Je=l("v-autocomplete"),Ke=l("v-navigation-drawer");return o(),N(Ke,{"model-value":d.modelValue,temporary:"",location:"right",width:"400","onUpdate:modelValue":ee[37]||(ee[37]=$e=>c("update:modelValue",$e))},{default:t(()=>{var $e,Ee,lt,ut,Ve,Le,Ye,ct,Fe,Xe,mt,nt,He,St,Pt,Dt,_t,Re,ge,at,et,it,$t,yt,We;return[m.value?(o(),h("div",Bi,[a("div",Fi,[ee[44]||(ee[44]=a("h3",{class:"text-h6"},"Seiten-Einstellungen",-1)),a("div",Oi,[g.value==="saving"?(o(),h("span",Ri,[e(Y,{size:"12",width:"2",indeterminate:"",class:"mr-1"}),ee[38]||(ee[38]=n(" Speichern... ",-1))])):g.value==="saved"?(o(),h("span",Ki,[e(K,{size:"14",class:"mr-1"},{default:t(()=>[...ee[39]||(ee[39]=[n("mdi-check",-1)])]),_:1}),ee[40]||(ee[40]=n(" Gespeichert ",-1))])):g.value==="error"?(o(),h("span",ji,[e(K,{size:"14",class:"mr-1"},{default:t(()=>[...ee[41]||(ee[41]=[n("mdi-alert",-1)])]),_:1}),ee[42]||(ee[42]=n(" Fehler ",-1))])):U("",!0),e(ne,{icon:"mdi-close",variant:"text",size:"small","aria-label":"Schließen",onClick:ee[0]||(ee[0]=Qe=>c("update:modelValue",!1))},{default:t(()=>[e(le,{activator:"parent",location:"bottom"},{default:t(()=>[...ee[43]||(ee[43]=[n("Schließen",-1)])]),_:1})]),_:1})])]),d.isReadOnly?(o(),N(Ce,{key:0,type:"warning",variant:"tonal",density:"compact",class:"mb-4"},{default:t(()=>[a("div",qi,[e(K,{size:"16",class:"mr-1"},{default:t(()=>[...ee[45]||(ee[45]=[n("mdi-lock",-1)])]),_:1}),ee[46]||(ee[46]=n(" Einstellungen sind im Lesemodus (Seite wird bearbeitet). ",-1))])]),_:1})):U("",!0),ee[54]||(ee[54]=a("div",{class:"text-subtitle-2 text-primary mb-2"},"Allgemein",-1)),e(ke,{"model-value":m.value.title,label:"Titel",density:"compact",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[1]||(ee[1]=Qe=>T("title",Qe))},null,8,["model-value","disabled"]),e(ke,{"model-value":m.value.slug,label:"Slug",density:"compact",readonly:!u.value,disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[2]||(ee[2]=Qe=>i(Qe))},null,8,["model-value","readonly","disabled"]),e(ke,{"model-value":m.value.path,label:"Pfad",density:"compact",readonly:!u.value,disabled:d.isReadOnly,hint:u.value?"Wird bei Parent-Änderung automatisch aktualisiert":"Im Advanced-Modus editierbar","persistent-hint":"",class:"mb-2","onUpdate:modelValue":ee[3]||(ee[3]=Qe=>T("path",Qe))},null,8,["model-value","readonly","disabled","hint"]),e(xe,{"model-value":m.value.template,items:V,"item-title":"title","item-value":"value",label:"Template",density:"compact",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[4]||(ee[4]=Qe=>T("template",Qe))},null,8,["model-value","disabled"]),e(Ne,{"model-value":m.value.category,items:R.value,label:"Kategorie",density:"compact",clearable:"",disabled:d.isReadOnly,hint:"Bestehende wählen oder neue eintippen",class:"mb-2","onUpdate:modelValue":ee[5]||(ee[5]=Qe=>T("category",Qe))},null,8,["model-value","items","disabled"]),e(xe,{"model-value":m.value.status,items:M,"item-title":"title","item-value":"value",label:"Status",density:"compact",disabled:d.isReadOnly,class:"mb-4","onUpdate:modelValue":ee[6]||(ee[6]=Qe=>T("status",Qe))},null,8,["model-value","disabled"]),e(Ie,{class:"mb-4"}),ee[55]||(ee[55]=a("div",{class:"text-subtitle-2 text-primary mb-2"},"SEO",-1)),e(ke,{"model-value":($e=m.value.seo)==null?void 0:$e.title,label:"SEO Titel",density:"compact",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[7]||(ee[7]=Qe=>D("title",Qe))},null,8,["model-value","disabled"]),e(Ue,{"model-value":(Ee=m.value.seo)==null?void 0:Ee.description,label:"Meta Description",density:"compact",rows:"3",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[8]||(ee[8]=Qe=>D("description",Qe))},null,8,["model-value","disabled"]),e(ke,{"model-value":(lt=m.value.seo)==null?void 0:lt.canonical,label:"Canonical URL",density:"compact",disabled:d.isReadOnly,class:"mb-2",hint:"Leer lassen für Standard (Seite zeigt auf sich selbst). Nur befüllen für Custom-Canonical, z.B. Varianten-Seite zeigt aufs Original. Relativer Pfad (/original) oder absolute URL möglich. localhost-URLs werden abgelehnt.","persistent-hint":"","onUpdate:modelValue":ee[9]||(ee[9]=Qe=>D("canonical",Qe))},null,8,["model-value","disabled"]),e(ke,{"model-value":(ut=m.value.seo)==null?void 0:ut.ogImage,label:"OG Image URL",density:"compact",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[10]||(ee[10]=Qe=>D("ogImage",Qe))},null,8,["model-value","disabled"]),e(ke,{"model-value":(Ve=m.value.seo)==null?void 0:Ve.ogTitle,label:"OG Title",density:"compact",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[11]||(ee[11]=Qe=>D("ogTitle",Qe))},null,8,["model-value","disabled"]),e(ke,{"model-value":(Le=m.value.seo)==null?void 0:Le.ogDescription,label:"OG Description",density:"compact",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[12]||(ee[12]=Qe=>D("ogDescription",Qe))},null,8,["model-value","disabled"]),e(ke,{"model-value":(Ye=m.value.seo)==null?void 0:Ye.twitterImage,label:"Twitter Image URL",density:"compact","persistent-hint":"",hint:"Eigenes Bild für Twitter-Card (Fallback: OG-Image)",disabled:d.isReadOnly,class:"mb-4","onUpdate:modelValue":ee[13]||(ee[13]=Qe=>D("twitterImage",Qe))},null,8,["model-value","disabled"]),m.value.template==="blog-post"?(o(),h(be,{key:1},[e(Ie,{class:"mb-3"}),ee[47]||(ee[47]=a("div",{class:"text-caption text-medium-emphasis mb-2"},"Blog-Post Metadaten",-1)),e(ke,{"model-value":(ct=m.value.seo)==null?void 0:ct.datePublished,label:"Veröffentlichungsdatum (ISO)",placeholder:"2026-04-15T10:00:00Z",density:"compact","persistent-hint":"",hint:"ISO-8601 Zeitstempel, z. B. 2026-04-15T10:00:00Z",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[14]||(ee[14]=Qe=>D("datePublished",Qe))},null,8,["model-value","disabled"]),e(ke,{"model-value":(Fe=m.value.seo)==null?void 0:Fe.dateModified,label:"Aktualisiert am (ISO)",placeholder:"2026-04-20T14:30:00Z",density:"compact","persistent-hint":"",hint:"Leer lassen übernimmt das automatische Update-Datum",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[15]||(ee[15]=Qe=>D("dateModified",Qe))},null,8,["model-value","disabled"]),e(ke,{"model-value":(Xe=m.value.seo)==null?void 0:Xe.authorName,label:"Autor",density:"compact",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[16]||(ee[16]=Qe=>D("authorName",Qe))},null,8,["model-value","disabled"]),e(ke,{"model-value":(mt=m.value.seo)==null?void 0:mt.authorUrl,label:"Autor URL (optional)",placeholder:"https://...",density:"compact",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[17]||(ee[17]=Qe=>D("authorUrl",Qe))},null,8,["model-value","disabled"]),e(ke,{"model-value":(nt=m.value.seo)==null?void 0:nt.articleSection,label:"Kategorie / Section",placeholder:"z. B. Cyber-Defense",density:"compact",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[18]||(ee[18]=Qe=>D("articleSection",Qe))},null,8,["model-value","disabled"]),e(Ne,{"model-value":((He=m.value.seo)==null?void 0:He.articleTags)??[],label:"Tags",density:"compact",multiple:"",chips:"","closable-chips":"","persistent-hint":"",hint:"Enter drücken, um neues Tag hinzuzufügen",disabled:d.isReadOnly,class:"mb-4","onUpdate:modelValue":ee[19]||(ee[19]=Qe=>H(Qe))},null,8,["model-value","disabled"])],64)):U("",!0),e(Ie,{class:"mb-4"}),ee[56]||(ee[56]=a("div",{class:"text-subtitle-2 text-primary mb-2"},"Suchmaschinen & Sitemap",-1)),e(ke,{"model-value":(St=m.value.seo)==null?void 0:St.priority,label:"Sitemap-Priorität",type:"number",min:"0",max:"1",step:"0.1",density:"compact",clearable:"","persistent-hint":"",hint:"Relative Wichtigkeit in der Sitemap (0.0–1.0). Leer lassen für den Standard je nach Seitentyp (z. B. 1.0 für Homepage, 0.8 für Service-Seiten).",disabled:d.isReadOnly,class:"mb-3","onUpdate:modelValue":ee[20]||(ee[20]=Qe=>S(Qe))},null,8,["model-value","disabled"]),e(xe,{"model-value":((Pt=m.value.seo)==null?void 0:Pt.changefreq)??"",items:O,"item-title":"title","item-value":"value",label:"Änderungsfrequenz",density:"compact","persistent-hint":"",hint:"Wie oft sich diese Seite typischerweise ändert",disabled:d.isReadOnly,class:"mb-3","onUpdate:modelValue":ee[21]||(ee[21]=Qe=>B(Qe))},null,8,["model-value","disabled"]),e(Te,{"model-value":((Dt=m.value.seo)==null?void 0:Dt.noindex)??!1,label:"Von Suchmaschinen ausschließen (noindex)",density:"compact",color:"primary","persistent-hint":"",hint:'Seite wird nicht in Sitemap aufgenommen und bekommt einen "noindex, nofollow" Meta-Tag für Suchmaschinen.',disabled:d.isReadOnly,class:"mb-4","onUpdate:modelValue":ee[22]||(ee[22]=Qe=>D("noindex",Qe))},null,8,["model-value","disabled"]),e(Ie,{class:"mb-4"}),ee[57]||(ee[57]=a("div",{class:"text-subtitle-2 text-primary mb-2"},"Strukturierte Daten (JSON-LD)",-1)),ee[58]||(ee[58]=a("p",{class:"text-caption text-medium-emphasis mb-3"}," Gibt Suchmaschinen zusätzliche Informationen über die Seite (schema.org). ",-1)),e(xe,{"model-value":A.value,items:G,"item-title":"title","item-value":"value",label:"Schema-Typ",density:"compact",disabled:d.isReadOnly,class:"mb-3","onUpdate:modelValue":ee[23]||(ee[23]=Qe=>j(Qe))},null,8,["model-value","disabled"]),A.value!=="none"?(o(),h("div",Gi,[((_t=L.value)==null?void 0:_t.type)==="Service"?(o(),h(be,{key:0},[e(ke,{"model-value":L.value.name,label:"Name",density:"compact","persistent-hint":"",hint:"Leer lassen übernimmt den Seitentitel",disabled:d.isReadOnly,class:"mb-3","onUpdate:modelValue":ee[24]||(ee[24]=Qe=>Q("name",Qe))},null,8,["model-value","disabled"]),e(Ue,{"model-value":L.value.description,label:"Beschreibung",density:"compact",rows:"2","persistent-hint":"",hint:"Leer lassen übernimmt die Meta-Description",disabled:d.isReadOnly,class:"mb-3","onUpdate:modelValue":ee[25]||(ee[25]=Qe=>Q("description",Qe))},null,8,["model-value","disabled"]),e(ke,{"model-value":L.value.serviceType,label:"Service-Typ",density:"compact","persistent-hint":"",hint:"z. B. ISO 27001 Audit",disabled:d.isReadOnly,class:"mb-3","onUpdate:modelValue":ee[26]||(ee[26]=Qe=>Q("serviceType",Qe))},null,8,["model-value","disabled"]),e(xe,{"model-value":L.value.priceRange??"",items:W,"item-title":"title","item-value":"value",label:"Preiskategorie",density:"compact",disabled:d.isReadOnly,class:"mb-3","onUpdate:modelValue":ee[27]||(ee[27]=Qe=>Q("priceRange",Qe))},null,8,["model-value","disabled"]),e(Ne,{"model-value":L.value.areaServed??[],items:F,label:"Bediengebiet",density:"compact",multiple:"",chips:"","closable-chips":"","persistent-hint":"",hint:"Länder-Codes (z. B. DE, AT, CH) oder Regionen",disabled:d.isReadOnly,class:"mb-3","onUpdate:modelValue":ee[28]||(ee[28]=Qe=>Q("areaServed",Qe))},null,8,["model-value","disabled"])],64)):((Re=L.value)==null?void 0:Re.type)==="FAQ"?(o(),h(be,{key:1},[de.value.length===0?(o(),N(Ce,{key:0,type:"warning",variant:"tonal",density:"compact",class:"mb-3"},{default:t(()=>[...ee[48]||(ee[48]=[n(" Mindestens ein Eintrag nötig. ",-1)])]),_:1})):U("",!0),(o(!0),h(be,null,Pe(de.value,(Qe,At)=>(o(),N(ye,{key:At,variant:"outlined",class:"mb-3 pa-3"},{default:t(()=>[a("div",Hi,[a("span",Wi,"Eintrag "+v(At+1),1),e(ne,{icon:"mdi-delete-outline",variant:"text",size:"x-small",color:"error",disabled:d.isReadOnly,"aria-label":"Eintrag entfernen",onClick:je=>_e(At)},null,8,["disabled","onClick"])]),e(ke,{"model-value":Qe.question,label:"Frage",density:"compact",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":je=>oe(At,"question",je)},null,8,["model-value","disabled","onUpdate:modelValue"]),e(Ue,{"model-value":Qe.answer,label:"Antwort",density:"compact",rows:"2",disabled:d.isReadOnly,"onUpdate:modelValue":je=>oe(At,"answer",je)},null,8,["model-value","disabled","onUpdate:modelValue"])]),_:2},1024))),128)),e(ne,{variant:"outlined",color:"primary",size:"small","prepend-icon":"mdi-plus",disabled:d.isReadOnly,class:"mb-2",onClick:pe},{default:t(()=>[...ee[49]||(ee[49]=[n(" Eintrag hinzufügen ",-1)])]),_:1},8,["disabled"])],64)):((ge=L.value)==null?void 0:ge.type)==="Article"?(o(),h(be,{key:2},[e(ke,{"model-value":L.value.headline,label:"Headline",density:"compact","persistent-hint":"",hint:"Leer lassen übernimmt den Seitentitel",disabled:d.isReadOnly,class:"mb-3","onUpdate:modelValue":ee[29]||(ee[29]=Qe=>ve("headline",Qe))},null,8,["model-value","disabled"]),e(ke,{"model-value":L.value.datePublished,label:"Veröffentlicht am",type:"date",density:"compact",disabled:d.isReadOnly,class:"mb-3","onUpdate:modelValue":ee[30]||(ee[30]=Qe=>ve("datePublished",Qe))},null,8,["model-value","disabled"]),e(ke,{"model-value":L.value.dateModified,label:"Aktualisiert am",type:"date",density:"compact",disabled:d.isReadOnly,class:"mb-3","onUpdate:modelValue":ee[31]||(ee[31]=Qe=>ve("dateModified",Qe))},null,8,["model-value","disabled"])],64)):((at=L.value)==null?void 0:at.type)==="LocalBusiness"?(o(),N(Ce,{key:3,type:"info",variant:"tonal",density:"compact",class:"mb-3"},{default:t(()=>[...ee[50]||(ee[50]=[n(" Nutzt die globalen Organization-Daten aus den Plattform-Einstellungen. Keine zusätzlichen Felder nötig. ",-1)])]),_:1})):((et=L.value)==null?void 0:et.type)==="Breadcrumb"?(o(),h(be,{key:4},[ee[52]||(ee[52]=a("p",{class:"text-caption text-medium-emphasis mb-3"},' Erster Eintrag ist meist "Home", letzter die aktuelle Seite. ',-1)),(o(!0),h(be,null,Pe(q.value,(Qe,At)=>(o(),N(ye,{key:At,variant:"outlined",class:"mb-3 pa-3"},{default:t(()=>[a("div",Zi,[a("span",Ji,"Ebene "+v(At+1),1),e(ne,{icon:"mdi-delete-outline",variant:"text",size:"x-small",color:"error",disabled:d.isReadOnly,"aria-label":"Ebene entfernen",onClick:je=>fe(At)},null,8,["disabled","onClick"])]),e(ke,{"model-value":Qe.name,label:"Name",density:"compact",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":je=>X(At,"name",je)},null,8,["model-value","disabled","onUpdate:modelValue"]),e(ke,{"model-value":Qe.url,label:"URL (optional)",density:"compact","persistent-hint":"",hint:"Leer lassen für die aktuelle Seite",disabled:d.isReadOnly,"onUpdate:modelValue":je=>X(At,"url",je)},null,8,["model-value","disabled","onUpdate:modelValue"])]),_:2},1024))),128)),e(ne,{variant:"outlined",color:"primary",size:"small","prepend-icon":"mdi-plus",disabled:d.isReadOnly,class:"mb-2",onClick:ie},{default:t(()=>[...ee[51]||(ee[51]=[n(" Ebene hinzufügen ",-1)])]),_:1},8,["disabled"])],64)):U("",!0)])):U("",!0),e(Ie,{class:"mb-4"}),ee[59]||(ee[59]=a("div",{class:"text-subtitle-2 text-primary mb-2"},"Navigation",-1)),f.value?(o(),N(Ce,{key:3,type:"info",variant:"tonal",density:"compact",closable:"",class:"mb-3","onClick:close":ee[32]||(ee[32]=Qe=>f.value=!1)},{default:t(()=>[...ee[53]||(ee[53]=[n(" Pfad wurde aktualisiert. Links auf anderen Seiten werden beim Speichern automatisch angepasst. ",-1)])]),_:1})):U("",!0),e(Je,{"model-value":(it=m.value.navigation)==null?void 0:it.parentId,items:p.value,"item-title":"title","item-value":"value",label:"Übergeordnete Seite",clearable:"",density:"compact",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[33]||(ee[33]=Qe=>k(Qe))},null,8,["model-value","items","disabled"]),e(ke,{"model-value":($t=m.value.navigation)==null?void 0:$t.order,label:"Reihenfolge",type:"number",density:"compact",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[34]||(ee[34]=Qe=>Se("order",Number(Qe)))},null,8,["model-value","disabled"]),e(Te,{"model-value":(yt=m.value.navigation)==null?void 0:yt.showInMenu,label:"In Navigation anzeigen",density:"compact",color:"primary",disabled:d.isReadOnly,class:"mb-2","onUpdate:modelValue":ee[35]||(ee[35]=Qe=>Se("showInMenu",Qe))},null,8,["model-value","disabled"]),e(Te,{"model-value":(We=m.value.navigation)==null?void 0:We.showInFooter,label:"Im Footer anzeigen",density:"compact",color:"primary",disabled:d.isReadOnly,"onUpdate:modelValue":ee[36]||(ee[36]=Qe=>Se("showInFooter",Qe))},null,8,["model-value","disabled"])])):(o(),h("div",Qi,[e(K,{size:"40",class:"mb-2",color:"grey"},{default:t(()=>[...ee[60]||(ee[60]=[n("mdi-cog-outline",-1)])]),_:1}),ee[61]||(ee[61]=a("p",{class:"text-body-2 text-center"},"Keine Seite geladen.",-1))]))]}),_:1},8,["model-value"])}}}),Xi={class:"d-flex align-center justify-space-between"},er={class:"d-flex align-center ga-2"},tr={class:"text-caption text-medium-emphasis mt-1"},ar={class:"text-body-2 font-weight-semibold mb-3"},lr={class:"text-caption text-medium-emphasis mb-1"},nr={key:2,class:"d-flex align-center mt-2"},or={key:3,class:"text-caption text-medium-emphasis mt-2"},sr=Ae({__name:"GptSettingsModal",props:{modelValue:{type:Boolean},pageLabel:{},usecases:{},availableConfigs:{},currentSettings:{}},emits:["update:modelValue","save"],setup(r,{emit:$}){const d=r,c=$,s=y({});Ze(()=>d.modelValue,k=>{var g,x,w;if(!k)return;const i={};for(const b of d.usecases){const I=d.currentSettings[b.key],V=I!=null&&I.gptSettingsId?d.availableConfigs.find(E=>E._id===I.gptSettingsId):d.availableConfigs.find(E=>E.isDefault)??d.availableConfigs[0];i[b.key]={gptSettingsId:(I==null?void 0:I.gptSettingsId)||(V==null?void 0:V._id)||"",temperature:((g=I==null?void 0:I.overrides)==null?void 0:g.temperature)??b.defaults.temperature,maxTokens:((x=I==null?void 0:I.overrides)==null?void 0:x.maxTokens)??b.defaults.maxTokens,streaming:((w=I==null?void 0:I.overrides)==null?void 0:w.streaming)??!1}}s.value=i});const m=se(()=>d.availableConfigs.map(k=>({title:`${k.name} (${k.provider})`,value:k._id,subtitle:k.model})));function u(k){var g;const i=(g=s.value[k])==null?void 0:g.gptSettingsId;return d.availableConfigs.find(x=>x._id===i)}function f(){c("update:modelValue",!1)}function p(){const k={};for(const i of d.usecases){const g=s.value[i.key];g!=null&&g.gptSettingsId&&(k[i.key]={gptSettingsId:g.gptSettingsId,overrides:{temperature:g.temperature,maxTokens:g.maxTokens,streaming:g.streaming}})}c("save",k),f()}function _(){const k={},i=d.availableConfigs.find(g=>g.isDefault)??d.availableConfigs[0];for(const g of d.usecases)k[g.key]={gptSettingsId:(i==null?void 0:i._id)||"",temperature:g.defaults.temperature,maxTokens:g.defaults.maxTokens,streaming:!1};s.value=k}return(k,i)=>{const g=l("v-icon"),x=l("v-tooltip"),w=l("v-btn"),b=l("v-card-title"),I=l("v-divider"),V=l("router-link"),E=l("v-alert"),R=l("v-list-item-subtitle"),M=l("v-list-item"),T=l("v-select"),D=l("v-slider"),H=l("v-col"),O=l("v-text-field"),S=l("v-row"),B=l("v-switch"),G=l("v-card-text"),W=l("v-spacer"),F=l("v-card-actions"),L=l("v-card"),A=l("v-dialog");return o(),N(A,{"model-value":r.modelValue,"max-width":"640",scrollable:"","onUpdate:modelValue":i[0]||(i[0]=z=>c("update:modelValue",z))},{default:t(()=>[e(L,{class:"gpt-settings-modal"},{default:t(()=>[e(b,{class:"pa-5 pb-3"},{default:t(()=>[a("div",Xi,[a("div",er,[e(g,{size:"22",color:"primary"},{default:t(()=>[...i[1]||(i[1]=[n("mdi-robot-outline",-1)])]),_:1}),i[2]||(i[2]=a("span",{class:"text-subtitle-1 font-weight-bold"},"KI-Einstellungen",-1))]),e(w,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:f},{default:t(()=>[e(x,{activator:"parent",location:"bottom"},{default:t(()=>[...i[3]||(i[3]=[n("Schließen",-1)])]),_:1}),e(g,null,{default:t(()=>[...i[4]||(i[4]=[n("mdi-close",-1)])]),_:1})]),_:1})]),a("p",tr,v(r.pageLabel),1)]),_:1}),e(I),e(G,{class:"pa-5"},{default:t(()=>[r.availableConfigs.length===0?(o(),N(E,{key:0,type:"info",variant:"tonal",class:"mb-4"},{default:t(()=>[i[6]||(i[6]=n(" Keine KI-Konfigurationen vorhanden. Bitte zuerst unter ",-1)),e(V,{to:"/admin/ki-einstellungen"},{default:t(()=>[...i[5]||(i[5]=[n("KI-Einstellungen",-1)])]),_:1}),i[7]||(i[7]=n(" eine Konfiguration anlegen. ",-1))]),_:1})):U("",!0),(o(!0),h(be,null,Pe(r.usecases,(z,j)=>{var J,Q;return o(),h("div",{key:z.key,class:"gpt-settings-modal__usecase mb-5"},[a("p",ar,v(z.label),1),s.value[z.key]?(o(),N(T,{key:0,modelValue:s.value[z.key].gptSettingsId,"onUpdate:modelValue":te=>s.value[z.key].gptSettingsId=te,items:m.value,label:"KI-Konfiguration",variant:"outlined",density:"compact","hide-details":"",class:"mb-3"},{item:t(({props:te,item:ve})=>[e(M,Vt({ref_for:!0},te),{default:t(()=>[ve.raw.subtitle?(o(),N(R,{key:0},{default:t(()=>[n(v(ve.raw.subtitle),1)]),_:2},1024)):U("",!0)]),_:2},1040)]),_:1},8,["modelValue","onUpdate:modelValue","items"])):U("",!0),s.value[z.key]?(o(),N(S,{key:1,dense:"",class:"mt-1"},{default:t(()=>[e(H,{cols:"8"},{default:t(()=>[a("div",lr,[i[8]||(i[8]=n(" Temperature: ",-1)),a("strong",null,v(s.value[z.key].temperature.toFixed(1)),1)]),e(D,{modelValue:s.value[z.key].temperature,"onUpdate:modelValue":te=>s.value[z.key].temperature=te,min:0,max:2,step:.1,color:"primary","track-color":"rgba(255,255,255,0.1)","hide-details":"",density:"compact"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024),e(H,{cols:"4"},{default:t(()=>[e(O,{modelValue:s.value[z.key].maxTokens,"onUpdate:modelValue":te=>s.value[z.key].maxTokens=te,modelModifiers:{number:!0},label:"Max. Tokens",type:"number",min:100,max:128e3,variant:"outlined",density:"compact","hide-details":""},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024)]),_:2},1024)):U("",!0),s.value[z.key]?(o(),h("div",nr,[e(B,{modelValue:s.value[z.key].streaming,"onUpdate:modelValue":te=>s.value[z.key].streaming=te,label:"Streaming",color:"primary",density:"compact","hide-details":""},null,8,["modelValue","onUpdate:modelValue"])])):U("",!0),u(z.key)?(o(),h("div",or," Modell: "+v((J=u(z.key))==null?void 0:J.model)+" · Provider: "+v((Q=u(z.key))==null?void 0:Q.provider),1)):U("",!0),j<r.usecases.length-1?(o(),N(I,{key:4,class:"mt-4"})):U("",!0)])}),128))]),_:1}),e(I),e(F,{class:"pa-4"},{default:t(()=>[e(w,{variant:"text",size:"small",onClick:_},{default:t(()=>[...i[9]||(i[9]=[n(" Zurücksetzen ",-1)])]),_:1}),e(W),e(w,{variant:"text",onClick:f},{default:t(()=>[...i[10]||(i[10]=[n("Abbrechen",-1)])]),_:1}),e(w,{color:"primary",variant:"elevated",disabled:r.availableConfigs.length===0,onClick:p},{default:t(()=>[...i[11]||(i[11]=[n(" Speichern ",-1)])]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["model-value"])}}}),ir=Me(sr,[["__scopeId","data-v-b3dc33c1"]]);function rr(r,$){const d=y([]),c=y(!1),s=qe(`gpt_${r}`,{});async function m(){c.value=!0;try{const i=await re.get("/gpt-settings?isActive=true");if(i.success&&i.data){const g=i.data;d.value=Array.isArray(g)?g:g.items??[]}}catch{ue.error("ADMIN","Fehler beim Laden der KI-Konfigurationen")}finally{c.value=!1}}function u(){var g;const i=d.value.find(x=>x.isDefault);return(i==null?void 0:i._id)??((g=d.value[0])==null?void 0:g._id)??""}function f(i){const g=s.value[i];if(g!=null&&g.gptSettingsId)return g;const x=u();if(!x)return null;const w=$.find(b=>b.key===i);return{gptSettingsId:x,overrides:(w==null?void 0:w.defaults)??{}}}function p(i,g,x){s.value={...s.value,[i]:{gptSettingsId:g,overrides:x??{}}}}function _(){s.value={}}async function k(){await m()}return rt(()=>{m()}),{availableConfigs:d,settings:s,loading:c,getForUsecase:f,setForUsecase:p,resetAll:_,reload:k}}const ta=Ae({__name:"GptSettingsButton",props:{pageKey:{},pageLabel:{},usecases:{}},setup(r,{expose:$}){const d=r,{availableConfigs:c,settings:s,loading:m,setForUsecase:u,getForUsecase:f,reload:p}=rr(d.pageKey,d.usecases),_=y(!1);async function k(){await p(),_.value=!0}function i(g){for(const[x,w]of Object.entries(g))u(x,w.gptSettingsId,w.overrides)}return $({getForUsecase:f}),(g,x)=>{const w=l("v-icon"),b=l("v-btn"),I=l("v-tooltip");return o(),h("div",null,[e(I,{text:"KI-Einstellungen",location:"bottom"},{activator:t(({props:V})=>[e(b,Vt(V,{icon:"",variant:"text",size:"small",loading:P(m),onClick:k,"aria-label":"KI-Einstellungen"}),{default:t(()=>[e(w,null,{default:t(()=>[...x[1]||(x[1]=[n("mdi-robot-outline",-1)])]),_:1})]),_:1},16,["loading"])]),_:1}),e(ir,{modelValue:_.value,"onUpdate:modelValue":x[0]||(x[0]=V=>_.value=V),"page-label":r.pageLabel,usecases:r.usecases,"available-configs":P(c),"current-settings":P(s),onSave:i},null,8,["modelValue","page-label","usecases","available-configs","current-settings"])])}}}),dr={class:"text-caption text-medium-emphasis d-block mb-2 font-weight-medium"},ur={class:"d-flex flex-column ga-1"},cr=Ae({__name:"PagePromptHints",props:{modelValue:{type:Boolean},disabled:{type:Boolean}},emits:["update:modelValue","select"],setup(r,{emit:$}){const d=r,c=$,s=[{label:"Seite erstellen",hints:["Erstelle eine Service-Seite über [Thema] mit Hero, Vorteilen, FAQ und Kontaktformular","Erstelle eine Landing Page für eine Kampagne zu [Thema] - überzeugend, mit klarem CTA","Baue eine Übersichtsseite die alle unsere Security-Services vorstellt"]},{label:"Kreativ & Design",hints:["Gestalte den Hero-Bereich als Parallax-Scroll mit Glassmorphism-Karten","Erstelle einen vertikalen Prozess-Flow der unsere Beratungsschritte zeigt","Baue eine interaktive Stats-Section mit animierten Countern im Dark Design"]},{label:"Optimierung",hints:["Überarbeite die Texte - kürzer, punchiger, mehr IT-Security-Fachsprache","Verbessere die SEO-Metadaten basierend auf dem Seiteninhalt","Mach die Seite conversion-optimierter - stärkere CTAs, mehr Dringlichkeit"]},{label:"Anpassung",hints:["Tausche die FAQ-Section gegen eine Grid-Section mit Vorteilen","Füge nach dem Hero eine Stats-Section mit Branchenzahlen ein","Entferne die Testimonial-Section und ersetze sie durch eine Custom-Section"]}];function m(u){c("select",u),c("update:modelValue",!1)}return(u,f)=>{const p=l("v-tooltip"),_=l("v-icon"),k=l("v-btn"),i=l("v-chip"),g=l("v-card"),x=l("v-menu");return o(),N(x,{"model-value":d.modelValue,location:"top start","close-on-content-click":!1,"max-width":"480","onUpdate:modelValue":f[0]||(f[0]=w=>c("update:modelValue",w))},{activator:t(({props:w})=>[e(k,Vt(w,{icon:"",variant:"text",size:"small",class:{"text-primary":d.modelValue},"aria-label":"Prompt-Vorlagen"}),{default:t(()=>[e(p,{activator:"parent",location:"bottom"},{default:t(()=>[...f[1]||(f[1]=[n("Prompt-Vorlagen",-1)])]),_:1}),e(_,{size:"20"},{default:t(()=>[...f[2]||(f[2]=[n("mdi-lightbulb-on",-1)])]),_:1})]),_:1},16,["class"])]),default:t(()=>[e(g,{color:"surface-variant",class:"pa-3"},{default:t(()=>[(o(),h(be,null,Pe(s,w=>a("div",{key:w.label,class:"mb-4"},[a("span",dr,v(w.label),1),a("div",ur,[(o(!0),h(be,null,Pe(w.hints,b=>(o(),N(i,{key:b,size:"small",variant:"tonal",color:"primary",disabled:d.disabled,class:"page-prompt-hint-chip",onClick:I=>m(b)},{default:t(()=>[n(v(b),1)]),_:2},1032,["disabled","onClick"]))),128))])])),64))]),_:1})]),_:1},8,["model-value"])}}}),mr=Me(cr,[["__scopeId","data-v-003e910d"]]),vr={key:0,class:"page-chat-chips"},pr=["aria-disabled"],fr={class:"fade-gradient fade-left","aria-hidden":"true"},gr={class:"fade-gradient fade-right","aria-hidden":"true"},br=Ae({__name:"PageChatChips",props:{sections:{},chatIsEmpty:{type:Boolean},disabled:{type:Boolean}},emits:["select"],setup(r,{emit:$}){const d=r,c=$,s=[{id:"list-sections",icon:"mdi-format-list-bulleted",label:"Alle Sections auflisten",prompt:"Zeige mir alle Sections dieser Seite mit Typ, Titel und Status.",category:"start"},{id:"read-hero",icon:"mdi-eye-outline",label:"Hero anschauen",prompt:"Lies die Hero-Section (#0) komplett und zeige mir Titel, Untertitel, CTA und Einstellungen.",category:"start"},{id:"search-text",icon:"mdi-magnify",label:"Text suchen",prompt:"Suche auf der Seite nach dem Text: ",category:"start",requiresInput:!0},{id:"check-seo",icon:"mdi-file-document-check-outline",label:"SEO prüfen",prompt:"Zeige mir den aktuellen SEO-Titel und die Meta-Description dieser Seite und schlage Verbesserungen vor.",category:"start"}],m=[{id:"page-review",icon:"mdi-clipboard-check-outline",label:"Seiten-Review",prompt:"Review die gesamte Seite: SEO, Rechtschreibung, Tonalität und fehlende Elemente. Gib mir konkrete Vorschläge.",category:"global"},{id:"compare-draft",icon:"mdi-compare",label:"Draft vs. Live",prompt:"Zeige mir die Unterschiede zwischen dem aktuellen Draft und der veröffentlichten Version.",category:"global"}];function u(I){return d.sections.find(V=>V.type===I)}function f(){const I=[],V=u("cta"),E=u("hero"),R=u("stats"),M=u("faq"),T=u("pricing"),D=u("glassy-grid"),H=d.sections.some(O=>O.type==="text");return V&&I.push({id:`cta-button-${V.order}`,icon:"mdi-gesture-tap-button",label:"CTA-Button anpassen",prompt:`Ändere den Button-Text der CTA-Section (Section #${V.order}) auf: `,category:"section",sectionOrder:V.order,requiresInput:!0}),E&&I.push({id:`hero-style-${E.order}`,icon:"mdi-palette-outline",label:"Hero-Style ändern",prompt:`Ändere den Hero-Style in Section #${E.order}. Mögliche Werte: tuerkis, gold, dark. Welchen Style soll ich setzen?`,category:"section",sectionOrder:E.order}),R&&I.push({id:`stats-change-${R.order}`,icon:"mdi-counter",label:"Statistik anpassen",prompt:`Ändere in der Stats-Section (#${R.order}) den Wert einer Kennzahl. Welche Kennzahl soll ich auf welchen Wert ändern?`,category:"section",sectionOrder:R.order}),M&&I.push({id:`faq-add-${M.order}`,icon:"mdi-help-circle-outline",label:"FAQ erweitern",prompt:`Füge in der FAQ-Section (#${M.order}) eine neue Frage hinzu. Frage: `,category:"section",sectionOrder:M.order,requiresInput:!0}),T&&I.push({id:`pricing-${T.order}`,icon:"mdi-currency-eur",label:"Preis ändern",prompt:`Ändere in der Pricing-Section (#${T.order}) den Preis eines Pakets. Welches Paket soll auf welchen Preis gesetzt werden?`,category:"section",sectionOrder:T.order,requiresInput:!0}),D&&I.push({id:`glassy-download-${D.order}`,icon:"mdi-download-outline",label:"Download einbauen",prompt:`Baue in die Glassy-Grid Section (#${D.order}) einen Download-Button ein. Für welches Formular (Slug)? `,category:"section",sectionOrder:D.order,requiresInput:!0}),H&&I.push({id:"text-replace",icon:"mdi-find-replace",label:"Wort ersetzen",prompt:"Ersetze auf der gesamten Seite ein Wort durch ein anderes. Welches Wort (ALT) soll durch welches neue Wort (NEU) ersetzt werden?",category:"section",requiresInput:!0}),M||I.push({id:"add-faq",icon:"mdi-help-circle-outline",label:"FAQ hinzufügen",prompt:"Füge am Ende der Seite einen FAQ-Bereich mit 3 Fragen hinzu. Schlage passende Fragen zum Seitenthema vor.",category:"section"}),R||I.push({id:"add-stats",icon:"mdi-chart-box-outline",label:"Statistik hinzufügen",prompt:"Füge eine Statistik-Section mit 3 aussagekräftigen Kennzahlen zum Thema der Seite hinzu.",category:"section"}),I}const p=se(()=>{if(d.chatIsEmpty)return[...s,...f().slice(0,4)];const I=f();return I.length===0?[...s,...m]:[...I,...m]});function _(I){const V=I.prompt.length>80?I.prompt.slice(0,77)+"…":I.prompt,E=I.requiresInput?" (Vorlage zum Anpassen)":"";return`Prompt-Vorschlag: ${I.label}${E}. Einfügen: ${V}`}function k(I){d.disabled||c("select",I.prompt)}const i=y(null),g=y(!1),x=y(!1);function w(){const I=i.value;if(!I){g.value=!1,x.value=!1;return}const{scrollLeft:V,scrollWidth:E,clientWidth:R}=I;x.value=V>2,g.value=V+R<E-2}let b=null;return rt(()=>{Wt(w);const I=i.value;I&&(I.addEventListener("scroll",w,{passive:!0}),typeof ResizeObserver<"u"&&(b=new ResizeObserver(w),b.observe(I))),window.addEventListener("resize",w)}),Ft(()=>{const I=i.value;I&&I.removeEventListener("scroll",w),b&&b.disconnect(),window.removeEventListener("resize",w)}),Ze(p,()=>{Wt(w)}),(I,V)=>{const E=l("v-icon"),R=l("v-chip");return p.value.length?(o(),h("div",vr,[a("div",{ref_key:"scrollRef",ref:i,class:"chips-scroll",role:"toolbar","aria-label":"Prompt-Vorschläge für den KI-Chat","aria-disabled":r.disabled?"true":"false"},[(o(!0),h(be,null,Pe(p.value,M=>(o(),N(R,{key:M.id,size:"small",variant:"outlined",color:"primary",disabled:r.disabled,"aria-label":_(M),tabindex:r.disabled?-1:0,class:"chat-chip",onClick:T=>k(M),onKeydown:[Kt(dt(T=>k(M),["prevent"]),["enter"]),Kt(dt(T=>k(M),["prevent"]),["space"])]},{default:t(()=>[e(E,{size:"16",start:"","aria-hidden":"true"},{default:t(()=>[n(v(M.icon),1)]),_:2},1024),n(" "+v(M.label),1)]),_:2},1032,["disabled","aria-label","tabindex","onClick","onKeydown"]))),128))],8,pr),za(a("div",fr,null,512),[[Ka,x.value]]),za(a("div",gr,null,512),[[Ka,g.value]])])):U("",!0)}}}),yr=Me(br,[["__scopeId","data-v-fea4a6db"]]),_r={class:"diff-panel"},kr={class:"diff-header"},hr={class:"d-flex align-center ga-2"},xr={class:"text-caption text-medium-emphasis mt-1"},wr={key:0},Sr={key:0,class:"mt-2"},$r={class:"diff-body"},Cr={class:"diff-change-header"},Vr={class:"diff-change-index"},Ar={class:"diff-change-label"},Ir={key:0,class:"diff-block"},Pr={key:0,class:"diff-section-info"},zr={class:"diff-section-type"},Dr={key:0,class:"diff-section-title"},Tr={class:"diff-text-compare"},Lr={class:"diff-line diff-line--removed"},Er={class:"diff-line-text"},Mr={class:"diff-line diff-line--added"},Nr={class:"diff-line-text"},Ur={class:"diff-words"},Br={class:"diff-words-content"},Fr={key:0,class:"diff-meta"},Or={key:1,class:"diff-block"},Rr={key:0,class:"diff-section-info"},Kr={class:"diff-section-type"},jr={key:0,class:"diff-section-title"},qr={class:"diff-field-label"},Gr={class:"diff-line diff-line--removed"},Hr={class:"diff-line-text"},Wr={class:"diff-line diff-line--added"},Zr={class:"diff-line-text"},Jr={class:"diff-field-label diff-field-sublabel"},Qr={class:"diff-line diff-line--removed"},Yr={class:"diff-line-text"},Xr={class:"diff-line diff-line--added"},ed={class:"diff-line-text"},td={key:2,class:"diff-block"},ad={class:"diff-added-banner"},ld={key:0,class:"diff-meta-inline"},nd={class:"diff-section-info"},od={key:0,class:"diff-section-title ml-2"},sd={key:0,class:"diff-preview-text"},id={key:1,class:"diff-settings-chips"},rd={key:3,class:"diff-block"},dd={class:"diff-added-banner"},ud={key:0,class:"diff-meta-inline"},cd={class:"diff-section-info"},md={key:0,class:"diff-section-title ml-2"},vd={class:"diff-video-info"},pd={key:0},fd={key:4,class:"diff-block diff-block--warn"},gd={class:"diff-removed-banner"},bd={key:0,class:"diff-meta-inline"},yd={key:0,class:"diff-section-info"},_d={key:0,class:"diff-section-title ml-2"},kd={key:1,class:"diff-preview-text diff-preview-text--struck"},hd={key:5,class:"diff-block"},xd={class:"diff-field-label"},wd={class:"diff-move-compare"},Sd={class:"diff-move-col"},$d={class:"diff-move-order"},Cd={class:"diff-move-type"},Vd={class:"diff-move-title"},Ad={class:"diff-move-col"},Id={class:"diff-move-order"},Pd={class:"diff-move-type"},zd={class:"diff-move-title"},Dd={key:6,class:"diff-block"},Td={class:"diff-field-sublabel"},Ld={class:"diff-line diff-line--removed"},Ed={class:"diff-line-text"},Md={class:"diff-line diff-line--added"},Nd={class:"diff-line-text"},Ud={key:7,class:"diff-block"},Bd={class:"diff-meta"},Fd={class:"diff-footer"},Od={class:"d-flex ga-2"},Rd=Ae({__name:"PageChatDiffPanel",props:{pageId:{},pendingState:{}},emits:["applied","discarded"],setup(r,{emit:$}){const d=r,c=$,s=Jt(),m=y(!1),u=y(!1),f=y(null);function p(O){return O?String(O).replace(/<[^>]*>/g,"").replace(/\s+/g," ").trim():""}function _(O,S){return O?O.length>S?`${O.slice(0,S)}...`:O:""}function k(O){return{replace_content:"Inhalt ersetzen",update_section:"Section aktualisieren",add_section:"Section hinzufügen",add_video_section:"Video einfügen",remove_section:"Section entfernen",move_section:"Section verschieben",update_seo:"SEO aktualisieren"}[O]||O}function i(O){return O?String(O).toUpperCase():""}function g(O,S){return Nl(O||"",S||"").map(G=>({type:G.added?"added":G.removed?"removed":"unchanged",text:G.value}))}function x(O){const S=O.toolResult;return Array.isArray(S.changedFields)?S.changedFields:[]}function w(O){const S=O.toolResult;return typeof(S==null?void 0:S.matchCount)=="number"?S.matchCount:0}function b(O){const S=O.toolResult;return typeof(S==null?void 0:S.videoId)=="string"?S.videoId:""}function I(O,S){if(!O)return"";if(S==="keywords"){const G=O.schema;return typeof(G==null?void 0:G.keywords)=="string"?G.keywords:""}const B=O[S];return typeof B=="boolean"?B?"true":"false":typeof B=="string"?B:""}function V(O){return{title:"SEO-Titel",description:"Meta-Description",keywords:"Keywords",noindex:"noindex (Suchmaschinen ausschließen)"}[O]||O}function E(O){var F,L;const S=((F=O.before)==null?void 0:F.settings)||{},B=((L=O.after)==null?void 0:L.settings)||{},G=new Set([...Object.keys(S),...Object.keys(B)]),W=[];for(const A of G){const z=S[A],j=B[A];JSON.stringify(z)!==JSON.stringify(j)&&W.push({key:A,before:z===void 0?"(nicht gesetzt)":String(typeof z=="object"?JSON.stringify(z):z),after:j===void 0?"(nicht gesetzt)":String(typeof j=="object"?JSON.stringify(j):j)})}return W}function R(O,S){return O.toolName!=="move_section"||typeof O.movedFromOrder!="number"?!1:O.movedFromOrder===S||O.movedToOrder===S}const M=y(null);async function T(){if(!(m.value||u.value)){m.value=!0,f.value=null,M.value=null;try{const O=await s.applyPendingChanges(d.pageId);O.data?c("applied"):(M.value=O.status,f.value=O.error||s.error||"Änderungen konnten nicht übernommen werden")}catch(O){ue.error("ADMIN","Pending-Apply fehlgeschlagen",{err:String(O)}),f.value="Netzwerkfehler beim Übernehmen der Änderungen"}finally{m.value=!1}}}async function D(){if(!(m.value||u.value)){u.value=!0,f.value=null;try{await s.discardPendingChanges(d.pageId)?c("discarded"):f.value=s.error||"Änderungen konnten nicht verworfen werden"}catch(O){ue.error("ADMIN","Pending-Discard fehlgeschlagen",{err:String(O)}),f.value="Netzwerkfehler beim Verwerfen der Änderungen"}finally{u.value=!1}}}const H=se(()=>d.pendingState.changes.length);return(O,S)=>{const B=l("v-icon"),G=l("v-btn"),W=l("v-alert"),F=l("v-chip");return o(),h("div",_r,[a("div",kr,[a("div",hr,[e(B,{size:"18",color:"primary"},{default:t(()=>[...S[1]||(S[1]=[n("mdi-source-branch",-1)])]),_:1}),S[2]||(S[2]=a("span",{class:"text-body-2 font-weight-medium"},"Vorschau der KI-Änderungen",-1))]),a("div",xr,[n(v(H.value)+" Änderung",1),H.value!==1?(o(),h("span",wr,"en")):U("",!0),S[3]||(S[3]=n(" bereit zur Übernahme. Die Seite wurde noch nicht gespeichert. ",-1))])]),f.value?(o(),N(W,{key:0,type:M.value===503?"warning":"error",variant:"tonal",density:"compact",class:"ma-3",closable:"","onClick:close":S[0]||(S[0]=L=>{f.value=null,M.value=null})},{default:t(()=>[a("div",null,v(f.value),1),M.value===409?(o(),h("div",Sr,[e(G,{size:"small",color:"error",variant:"flat",loading:u.value,onClick:D},{default:t(()=>[...S[4]||(S[4]=[n(" Jetzt verwerfen ",-1)])]),_:1},8,["loading"])])):U("",!0)]),_:1},8,["type"])):U("",!0),a("div",$r,[(o(!0),h(be,null,Pe(r.pendingState.changes,(L,A)=>{var z,j,J,Q,te,ve,de,Z,ce,oe,pe,_e,q,C,ae;return o(),h("div",{key:L.id,class:ft(["diff-change",`diff-change--${L.toolName}`])},[a("div",Cr,[a("span",Vr,"#"+v(A+1),1),a("span",Ar,v(k(L.toolName)),1),typeof L.sectionOrder=="number"?(o(),N(F,{key:0,size:"x-small",variant:"tonal",color:"primary",class:"ml-2"},{default:t(()=>[n(" Section "+v(L.sectionOrder),1)]),_:2},1024)):U("",!0)]),L.toolName==="replace_content"?(o(),h("div",Ir,[(z=L.before)!=null&&z.title||(j=L.before)!=null&&j.type?(o(),h("div",Pr,[a("span",zr,v(i((J=L.before)==null?void 0:J.type)),1),(Q=L.before)!=null&&Q.title?(o(),h("span",Dr," - "+v(_(L.before.title,80)),1)):U("",!0)])):U("",!0),a("div",Tr,[a("div",Lr,[S[5]||(S[5]=a("div",{class:"diff-line-label"},"Ersetzt:",-1)),a("div",Er,v(_(p(String(L.toolInput.old??"")),500)),1)]),a("div",Mr,[S[6]||(S[6]=a("div",{class:"diff-line-label"},"Durch:",-1)),a("div",Nr,v(_(p(String(L.toolInput.new??"")),500)),1)]),a("div",Ur,[S[7]||(S[7]=a("div",{class:"diff-line-label"},"Wort-Diff:",-1)),a("div",Br,[(o(!0),h(be,null,Pe(g(p(String(L.toolInput.old??"")),p(String(L.toolInput.new??""))),(X,ie)=>(o(),h("span",{key:ie,class:ft({"diff-seg--added":X.type==="added","diff-seg--removed":X.type==="removed"})},v(X.text),3))),128))])]),w(L)>0?(o(),h("div",Fr,v(w(L))+"x im Content ersetzt ",1)):U("",!0)])])):L.toolName==="update_section"?(o(),h("div",Or,[(te=L.before)!=null&&te.title||(ve=L.before)!=null&&ve.type?(o(),h("div",Rr,[a("span",Kr,v(i((de=L.before)==null?void 0:de.type)),1),(Z=L.before)!=null&&Z.title?(o(),h("span",jr," - "+v(_(L.before.title,80)),1)):U("",!0)])):U("",!0),(o(!0),h(be,null,Pe(x(L),X=>{var ie,fe;return o(),h("div",{key:X,class:"diff-field"},[a("div",qr,v(X),1),X==="title"?(o(),h(be,{key:0},[a("div",Gr,[a("span",Hr,v(((ie=L.before)==null?void 0:ie.title)||"(leer)"),1)]),a("div",Wr,[a("span",Zr,v(((fe=L.after)==null?void 0:fe.title)||"(leer)"),1)])],64)):X==="settings"?(o(!0),h(be,{key:1},Pe(E(L),Se=>(o(),h("div",{key:Se.key,class:"diff-settings-row"},[a("div",Jr,"settings."+v(Se.key),1),a("div",Qr,[a("span",Yr,v(_(Se.before,200)),1)]),a("div",Xr,[a("span",ed,v(_(Se.after,200)),1)])]))),128)):U("",!0)])}),128))])):L.toolName==="add_section"?(o(),h("div",td,[a("div",ad,[e(B,{size:"14",color:"success",class:"mr-1"},{default:t(()=>[...S[8]||(S[8]=[n("mdi-plus-circle",-1)])]),_:1}),S[9]||(S[9]=n(" Neue Section ",-1)),typeof L.toolInput.afterOrder=="number"?(o(),h("span",ld," nach #"+v(L.toolInput.afterOrder),1)):U("",!0)]),a("div",nd,[e(F,{size:"x-small",variant:"tonal",color:"primary"},{default:t(()=>{var X;return[n(v(i((X=L.after)==null?void 0:X.type)),1)]}),_:2},1024),(ce=L.after)!=null&&ce.title?(o(),h("span",od,v(L.after.title),1)):U("",!0)]),p((oe=L.after)==null?void 0:oe.content)?(o(),h("div",sd,v(_(p((pe=L.after)==null?void 0:pe.content),200)),1)):U("",!0),(_e=L.after)!=null&&_e.settings&&Object.keys(L.after.settings).length>0?(o(),h("div",id,[(o(!0),h(be,null,Pe(Object.keys(L.after.settings),X=>(o(),N(F,{key:X,size:"x-small",variant:"outlined"},{default:t(()=>[n(v(X),1)]),_:2},1024))),128))])):U("",!0)])):L.toolName==="add_video_section"?(o(),h("div",rd,[a("div",dd,[e(B,{size:"14",color:"success",class:"mr-1"},{default:t(()=>[...S[10]||(S[10]=[n("mdi-youtube",-1)])]),_:1}),S[11]||(S[11]=n(" Video-Section einfügen ",-1)),typeof L.toolInput.afterOrder=="number"?(o(),h("span",ud," nach #"+v(L.toolInput.afterOrder),1)):U("",!0)]),a("div",cd,[e(F,{size:"x-small",variant:"tonal",color:"primary"},{default:t(()=>[...S[12]||(S[12]=[n("VIDEO",-1)])]),_:1}),(q=L.after)!=null&&q.title?(o(),h("span",md,v(L.after.title),1)):U("",!0)]),a("div",vd,[a("div",null,[S[13]||(S[13]=a("span",{class:"diff-field-sublabel"},"URL:",-1)),a("code",null,v(String(L.toolInput.youtubeUrl??"")),1)]),b(L)?(o(),h("div",pd,[S[14]||(S[14]=a("span",{class:"diff-field-sublabel"},"Video-ID:",-1)),a("code",null,v(b(L)),1)])):U("",!0)])])):L.toolName==="remove_section"?(o(),h("div",fd,[a("div",gd,[e(B,{size:"14",color:"error",class:"mr-1"},{default:t(()=>[...S[15]||(S[15]=[n("mdi-minus-circle",-1)])]),_:1}),S[16]||(S[16]=n(" Section entfernen ",-1)),typeof L.sectionOrder=="number"?(o(),h("span",bd," #"+v(L.sectionOrder),1)):U("",!0)]),L.before?(o(),h("div",yd,[e(F,{size:"x-small",variant:"tonal",color:"error"},{default:t(()=>[n(v(i(L.before.type)),1)]),_:2},1024),L.before.title?(o(),h("span",_d,v(L.before.title),1)):U("",!0)])):U("",!0),p((C=L.before)==null?void 0:C.content)?(o(),h("div",kd,v(_(p((ae=L.before)==null?void 0:ae.content),200)),1)):U("",!0)])):L.toolName==="move_section"?(o(),h("div",hd,[a("div",xd," Section #"+v(L.movedFromOrder)+" → neue Position #"+v(L.movedToOrder),1),a("div",wd,[a("div",Sd,[S[17]||(S[17]=a("div",{class:"diff-move-header"},"Vorher",-1)),(o(!0),h(be,null,Pe(L.orderBefore||[],X=>(o(),h("div",{key:`before-${X.order}`,class:ft(["diff-move-row",{"diff-move-row--moved":R(L,X.order)}])},[a("span",$d,"#"+v(X.order),1),a("span",Cd,v(i(X.type)),1),a("span",Vd,v(_(X.title||"(ohne Titel)",40)),1)],2))),128))]),e(B,{color:"primary",size:"24"},{default:t(()=>[...S[18]||(S[18]=[n("mdi-arrow-right-bold",-1)])]),_:1}),a("div",Ad,[S[19]||(S[19]=a("div",{class:"diff-move-header"},"Nachher",-1)),(o(!0),h(be,null,Pe(L.orderAfter||[],X=>(o(),h("div",{key:`after-${X.order}`,class:ft(["diff-move-row",{"diff-move-row--moved":R(L,X.order)}])},[a("span",Id,"#"+v(X.order),1),a("span",Pd,v(i(X.type)),1),a("span",zd,v(_(X.title||"(ohne Titel)",40)),1)],2))),128))])])])):L.toolName==="update_seo"?(o(),h("div",Dd,[S[20]||(S[20]=a("div",{class:"diff-field-label"},"SEO-Felder",-1)),(o(!0),h(be,null,Pe(x(L),X=>(o(),h("div",{key:X,class:"diff-field"},[a("div",Td,v(V(X)),1),a("div",Ld,[a("span",Ed,v(I(L.seoBefore,X)||"(leer)"),1)]),a("div",Md,[a("span",Nd,v(I(L.seoAfter,X)||"(leer)"),1)])]))),128))])):(o(),h("div",Ud,[a("div",Bd," Änderung via "+v(L.toolName),1)]))],2)}),128))]),a("div",Fd,[S[23]||(S[23]=a("div",{class:"text-caption text-medium-emphasis diff-footer-info"}," Die Live-Version bleibt unverändert - nur der Draft wird aktualisiert. ",-1)),a("div",Od,[e(G,{variant:"text",size:"small",disabled:m.value||u.value,loading:u.value,onClick:D},{default:t(()=>[...S[21]||(S[21]=[n(" Verwerfen ",-1)])]),_:1},8,["disabled","loading"]),e(G,{color:"primary",variant:"flat",size:"small","prepend-icon":"mdi-check",disabled:m.value||u.value,loading:m.value,onClick:T},{default:t(()=>[...S[22]||(S[22]=[n(" Übernehmen ",-1)])]),_:1},8,["disabled","loading"])])])])}}}),Kd=Me(Rd,[["__scopeId","data-v-1f2b7446"]]),jd={class:"page-chat-panel d-flex flex-column",style:{height:"100%"}},qd={class:"d-flex align-center pa-3 ga-2",style:{"border-bottom":"1px solid rgba(var(--v-border-color), var(--v-border-opacity))","flex-shrink":"0"}},Gd={class:"text-body-2"},Hd={class:"d-flex flex-column ga-2"},Wd={class:"text-body-2"},Zd={key:0,class:"d-flex align-center ga-2 flex-wrap"},Jd={class:"text-caption text-medium-emphasis text-truncate",style:{"max-width":"240px"}},Qd={class:"chat-messages flex-grow-1"},Yd={key:0,class:"d-flex justify-center pa-6"},Xd={key:1,class:"d-flex flex-column align-center justify-center",style:{height:"100%",padding:"32px"}},eu={class:"welcome-placeholder text-center pa-8"},tu={key:0,class:"message-bubble message-user"},au={class:"message-text"},lu={key:1,class:"message-time"},nu={key:1,class:"d-flex align-center ga-2 text-medium-emphasis text-body-2"},ou={key:2,class:"tool-calls-block"},su={class:"tool-call-name"},iu={key:0,class:"tool-call-result"},ru={key:3,class:"tool-calls-block"},du={class:"tool-call-name"},uu={key:0,class:"tool-call-result"},cu=["innerHTML"],mu=["innerHTML"],vu={key:1,class:"preamble-block"},pu={class:"preamble-label"},fu=["innerHTML"],gu={key:6,class:"d-flex flex-wrap ga-1 mt-2"},bu={key:7,class:"d-flex flex-wrap ga-1 mt-2"},yu={key:8,class:"d-flex justify-end mt-2"},_u={key:9,class:"message-time"},ku={key:2,class:"pa-3",style:{"flex-shrink":"0"}},hu={class:"chat-input d-flex flex-column ga-2 pa-3",style:{"border-top":"1px solid rgba(var(--v-border-color), var(--v-border-opacity))","flex-shrink":"0"}},xu={class:"d-flex align-center ga-2 plan-first-toggle"},wu={class:"text-caption text-medium-emphasis"},Su={class:"d-flex align-end ga-2"},Xa="basec.pageChat.planFirst",$u=Ae({__name:"PageChatPanel",props:{pageId:{},pageSlug:{},sections:{},isReadOnly:{type:Boolean},lockedBy:{}},emits:["sections-updated","switch-editor","preview-refresh"],setup(r,{expose:$,emit:d}){const c=r,s=d,m=new Set(["replace_content","update_section","add_section","add_video_section","remove_section","move_section","update_seo"]),u=y([]),f=y(""),p=y(!1),_=y(!1),k=y(null),i=y(!1),g=y(!1),x=y(null),w=y([]),b=y(null),I=y(!1),V=y(!0),E=y(null),R=y(null),M=y(new Set),T=Jt();let D=null,H=null;const O=se(()=>{const ee=w.value.filter(K=>K.status==="done").length,Y=w.value.length;return`${ee}/${Y} Aktionen ausgeführt`}),S=se(()=>w.value.some(ee=>ee.status==="running"));function B(ee){return{list_sections:"Sections auflisten",read_section:"Section lesen",search_content:"Inhalt suchen",replace_content:"Inhalt ersetzen",update_section:"Section aktualisieren",add_section:"Section hinzufügen",add_video_section:"Video einfügen",move_section:"Section verschieben",remove_section:"Section entfernen",update_seo:"SEO aktualisieren"}[ee]||ee}function G(ee){if(!ee.result)return"";if(ee.name==="replace_content"){const Y=ee.result;return Y.success?`${Y.matchCount} Treffer ersetzt`:"Nicht gefunden"}if(ee.name==="search_content")return`${ee.result.totalMatches} Treffer`;if(ee.name==="read_section"){const Y=ee.result;return`${Y.type}, ${Y.contentBytes} bytes`}return ee.name==="list_sections"?`${ee.result.sections.length} Sections`:""}function W(ee){return ee?new Intl.DateTimeFormat("de-DE",{hour:"2-digit",minute:"2-digit"}).format(new Date(ee)):""}function F(ee){return String(ee._id||"").startsWith("streaming_")}function L(ee){const Y=[],K=/\[CTA:\s*([^|]+)\|([^\]]+)\]/g;let le;for(;(le=K.exec(ee))!==null;)Y.push({label:le[1].trim(),action:le[2].trim()});return Y}function A(ee){let Y=ee;return Y=Y.replace(/<\/p>\s*<p[^>]*>/gi,`

`),Y=Y.replace(/<p[^>]*>([\s\S]*?)<\/p>/gi,`$1

`),Y=Y.replace(/<br\s*\/?>/gi,`
`),Y=Y.replace(/<h([1-6])[^>]*>([\s\S]*?)<\/h\1>/gi,(K,le,ne)=>"#".repeat(Number(le))+" "+ne.trim()+`

`),Y=Y.replace(/<li[^>]*>([\s\S]*?)<\/li>/gi,`- $1
`),Y=Y.replace(/<\/?(?:ul|ol)[^>]*>/gi,`
`),Y=Y.replace(/<(?:strong|b)[^>]*>([\s\S]*?)<\/(?:strong|b)>/gi,"**$1**"),Y=Y.replace(/<(?:em|i)[^>]*>([\s\S]*?)<\/(?:em|i)>/gi,"*$1*"),Y=Y.replace(/<code[^>]*>([\s\S]*?)<\/code>/gi,"`$1`"),Y=Y.replace(/<blockquote[^>]*>([\s\S]*?)<\/blockquote>/gi,`> $1
`),Y=Y.replace(/<[^>]+>/g,""),Y=Y.replace(/&nbsp;/g," "),Y=Y.replace(/&lt;/g,"<"),Y=Y.replace(/&gt;/g,">"),Y=Y.replace(/&quot;/g,'"'),Y=Y.replace(/&amp;/g,"&"),Y=Y.replace(/\n{3,}/g,`

`),Y.trim()}function z(ee){if(!ee)return"";let K=A(ee).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return K=K.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,"<code>$1</code>").replace(/&quot;([^&]+?)&quot;/g,"<strong><em>&quot;$1&quot;</em></strong>").replace(/"([^"]+?)"/g,'<strong><em>"$1"</em></strong>'),K=K.replace(/^#{3} (.+)$/gm,"<h3>$1</h3>").replace(/^#{2} (.+)$/gm,"<h2>$1</h2>").replace(/^# (.+)$/gm,"<h1>$1</h1>"),K=K.replace(/^[-*] (.+)$/gm,"<li>$1</li>"),K=K.replace(/((<li>.*<\/li>\n?)+)/g,"<ul>$1</ul>"),K=K.replace(/\n{2,}/g,"</p><p>"),K=K.replace(new RegExp("(?<!\\>)\\n(?!\\<)","g"),"<br>"),K}function j(ee,Y){if(!ee)return[];if(!Y||Y.length===0)return[{kind:"text",text:ee}];const K=Y.filter(Ce=>m.has(Ce.name)&&typeof Ce.contentOffset=="number").map(Ce=>({name:Ce.name,offset:Ce.contentOffset})).sort((Ce,ke)=>Ce.offset-ke.offset);if(K.length===0)return[{kind:"text",text:ee}];const le=[];let ne=0;for(const Ce of K){const ke=Math.min(Math.max(Ce.offset,ne),ee.length),xe=ee.slice(ne,ke);if(!xe)continue;const{leading:Ne,preamble:Ie}=J(xe);Ne&&le.push({kind:"text",text:Ne}),Ie&&le.push({kind:"preamble",text:Ie,toolName:Ce.name}),ne=ke}if(ne<ee.length){const Ce=ee.slice(ne);Ce.trim()&&le.push({kind:"text",text:Ce})}return le}function J(ee){const Y=ee.replace(/\s+$/,"");if(!Y)return{leading:ee,preamble:""};const K=Y.lastIndexOf(`

`);if(K!==-1){const ke=Y.slice(K+2).trim();return{leading:ee.slice(0,K+2),preamble:ke}}const ne=Array.from(Y.matchAll(/[.!?](?:\s+|$)/g)).filter(ke=>(ke.index??0)<Y.length-1),Ce=ne[ne.length-1];if(Ce&&typeof Ce.index=="number"){const ke=Ce.index+Ce[0].length;if(ke>0&&ke<Y.length){const xe=ee.slice(0,ke),Ne=ee.slice(ke).trim();return{leading:xe,preamble:Ne}}}return{leading:"",preamble:Y}}async function Q(){await Wt(),x.value&&x.value.scrollIntoView({behavior:"smooth",block:"nearest"})}async function te(){if(c.pageId){_.value=!0,k.value=null;try{const ee=await re.get(`/admin/pages/${c.pageId}/chat`);ee.success&&ee.data?(u.value=ee.data,await Q()):(k.value=ee.error||"Fehler beim Laden des Chatverlaufs",ue.error("ADMIN","Fehler beim Laden des Page-Chats",{error:ee.error}))}catch(ee){k.value="Netzwerkfehler beim Laden des Chatverlaufs",ue.error("ADMIN","Netzwerkfehler beim Laden des Page-Chats",ee)}finally{_.value=!1}}}function ve(ee,Y,K,le){if(Y){const ne=u.value.findIndex(Ce=>Ce._id===Y._id);ne!==-1&&u.value.splice(ne,1)}for(const ne of w.value)ne.status==="running"&&(ne.status="error");if(le==="server_error"){const ne=K?` (${K})`:"";k.value=`Die Verbindung zum KI-Chat ist fehlgeschlagen${ne}. Das Backend könnte gerade neu starten - bitte in 10-15 Sekunden erneut versuchen.`}else le==="network_error"?k.value="Netzwerkfehler beim Senden der Nachricht. Bitte Internetverbindung prüfen und erneut versuchen.":k.value="Der Stream wurde unterbrochen. Bitte erneut versuchen.";b.value=ee}async function de(ee){var ne,Ce;if(!f.value.trim()||p.value||!c.pageId||c.isReadOnly)return;const Y=f.value.trim(),K=ee??(V.value?"plan":"execute");f.value="",p.value=!0,k.value=null,b.value=null;let le=null;try{const ke=re.getAccessToken();if(!ke){k.value="Nicht authentifiziert",p.value=!1;return}const Ne=`/api/admin/pages/${c.pageId}/chat/stream`;D==null||D.abort(),D=new AbortController;const Ie=await fetch(Ne,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ke}`},body:JSON.stringify({message:Y,mode:K}),signal:D.signal});if(!Ie.ok){ue.error("ADMIN","Page-Chat-Stream fehlgeschlagen",{status:Ie.status}),ve(Y,le,Ie.status,"server_error"),p.value=!1;return}const Ue=(ne=Ie.body)==null?void 0:ne.getReader();if(!Ue){ue.error("ADMIN","Page-Chat-Stream: Reader nicht verfügbar"),ve(Y,le,Ie.status,"server_error"),p.value=!1;return}const Te=new TextDecoder;let ye="",Je=!1;for(;!Je;){const{done:Ke,value:$e}=await Ue.read();if(Ke)break;ye+=Te.decode($e,{stream:!0});const Ee=ye.split(`
`);ye=Ee.pop()||"";for(const lt of Ee){const ut=lt.trim();if(!(!ut||!ut.startsWith("data: ")))try{const Ve=JSON.parse(ut.slice(6));switch(Ve.type){case"user_message":u.value.push(Ve.message),w.value=[],await Q();break;case"stream_start":le={_id:`streaming_${Date.now()}`,role:"assistant",content:"",createdAt:new Date().toISOString(),mode:K},u.value.push(le),await Q();break;case"chunk":le&&(le.content+=Ve.content,u.value=[...u.value],H||(H=requestAnimationFrame(()=>{Q(),H=null})));break;case"tool_call":w.value.push({name:Ve.name,input:Ve.input||{},status:"running",contentOffset:(le==null?void 0:le.content.length)??0}),u.value=[...u.value],await Q();break;case"tool_result":{const Le=w.value.findLastIndex(Ye=>Ye.name===Ve.name&&Ye.status==="running");if(Le>=0){const Ye=Ve.result||{},ct=typeof Ve.success=="boolean"?Ve.success:void 0,Fe=!Ye.error&&Ye.success!==!1,Xe=ct!==void 0?ct:Fe;w.value[Le].status=Xe?"done":"error",w.value[Le].result=Ve.result,w.value[Le].success=Xe}u.value=[...u.value],await Q();break}case"preview_refresh":s("preview-refresh");break;case"diff_pending":Ve.state&&(E.value=Ve.state,ue.info("ADMIN","Pending-Diff empfangen",{changeCount:((Ce=E.value.changes)==null?void 0:Ce.length)??0}));break;case"stream_complete":for(const Le of w.value)Le.status==="running"&&(Le.status="error");if(le&&Ve.message){w.value.length>0&&(Ve.message.toolCalls=[...w.value]),Ve.message.mode||(Ve.message.mode=K);const Le=u.value.findIndex(Ye=>Ye._id===le._id);Le>=0&&(u.value[Le]=Ve.message)}s("sections-updated"),ue.info("ADMIN","Page-Chat-Stream abgeschlossen - Sections aktualisiert"),await Q();break;case"error":{ue.error("ADMIN","Page-Chat-Stream-Fehler",{message:Ve.message}),ve(Y,le,null,"stream_aborted"),Ve.message&&(k.value=Ve.message),le=null,Je=!0;break}case"ping":case"done":break}}catch{}}}}catch(ke){if(ke instanceof DOMException&&ke.name==="AbortError"){if(le){const xe=u.value.findIndex(Ne=>Ne._id===(le==null?void 0:le._id));xe!==-1&&u.value.splice(xe,1)}return}ue.warn("ADMIN","Streaming fehlgeschlagen, Fallback auf Standard-API",{error:ke instanceof Error?ke.message:String(ke)});try{const xe=await re.post(`/admin/pages/${c.pageId}/chat`,{message:Y,mode:K});if(xe.success)await te(),s("sections-updated");else{ue.error("ADMIN","Fallback-Chat fehlgeschlagen",{error:xe.error,status:xe.status});const Ne=xe.status??null,Ie=Ne&&Ne>=500?"server_error":"stream_aborted";ve(Y,le,Ne,Ie)}}catch(xe){ue.error("ADMIN","Netzwerkfehler im Fallback-Chat",{error:xe instanceof Error?xe.message:String(xe)}),ve(Y,le,null,"network_error")}}finally{D=null,p.value=!1,await Q()}}async function Z(){if(!b.value||p.value||I.value||c.isReadOnly)return;const ee=b.value;I.value=!0,k.value=null;try{f.value=ee,await de()}finally{I.value=!1}}function ce(ee){if(p.value||I.value||c.isReadOnly||E.value)return;const Y=u.value[ee],K=Y!=null&&Y._id?String(Y._id):null;K&&M.value.has(K)||(R.value=K,f.value="Ja, bitte den oben skizzierten Plan jetzt umsetzen.",de("execute"))}function oe(ee){if(!(p.value||I.value||c.isReadOnly))if(ee.startsWith("message:"))f.value=ee.substring(8),de();else if(ee==="publish")re.patch(`/admin/pages/${c.pageId}/status`,{status:"published"}).then(Y=>{Y.success?s("sections-updated"):(k.value=Y.error||"Fehler beim Publizieren",ue.error("ADMIN","Fehler beim Publizieren der Seite",{error:Y.error}))}).catch(Y=>{k.value="Netzwerkfehler beim Publizieren",ue.error("ADMIN","Netzwerkfehler beim Publizieren",{error:String(Y)})});else if(ee==="preview")c.pageSlug&&window.open(`/${c.pageSlug}?preview=true`,"_blank");else if(ee==="switch-editor")s("switch-editor");else if(ee==="regenerate")f.value="Generiere die komplette Seite neu",de();else if(ee.startsWith("regenerate-section:")){const Y=ee.substring(19);f.value=`Generiere die Section '${Y}' neu`,de()}else ue.warn("ADMIN","Unbekannte CTA-Aktion",{action:ee})}async function pe(){if(!(!c.pageId||!u.value.length||c.isReadOnly)){g.value=!0;try{const ee=await re.delete(`/admin/pages/${c.pageId}/chat`);ee.success?u.value=[]:(k.value=ee.error||"Fehler beim Leeren des Chats",ue.error("ADMIN","Fehler beim Leeren des Page-Chats",{error:ee.error}))}catch(ee){k.value="Netzwerkfehler beim Leeren des Chats",ue.error("ADMIN","Netzwerkfehler beim Leeren des Page-Chats",ee)}finally{g.value=!1}}}function _e(ee){c.isReadOnly||(f.value=ee,i.value=!1,de())}async function q(ee,Y){if(!(!ee._id||F(ee)||c.isReadOnly))try{(await re.delete(`/admin/pages/${c.pageId}/chat/${ee._id}`)).success&&u.value.splice(Y,1)}catch{ue.warn("ADMIN","Nachricht konnte nicht gelöscht werden")}}function C(ee){ee.key==="Enter"&&!ee.shiftKey&&(ee.preventDefault(),c.isReadOnly||de())}function ae(ee){u.value.push({_id:`system_${Date.now()}`,role:"assistant",content:ee,createdAt:new Date().toISOString()})}function X(){E.value=null,R.value&&(M.value.add(R.value),R.value=null),ae("Änderungen übernommen."),s("sections-updated"),s("preview-refresh")}function ie(){E.value=null,R.value=null,ae("Änderungen verworfen."),s("preview-refresh")}function fe(ee){return!!ee._id&&M.value.has(String(ee._id))}async function Se(){if(c.pageId)try{const ee=await T.fetchPendingChanges(c.pageId);ee&&Array.isArray(ee.changes)&&ee.changes.length>0&&(E.value=ee,ue.info("ADMIN","Pending-Diff aus Redis geladen (Reload)",{changeCount:ee.changes.length}))}catch{}}rt(async()=>{try{const ee=localStorage.getItem(Xa);ee!==null&&(V.value=ee==="true")}catch{}await te(),await Se()}),Ze(V,ee=>{try{localStorage.setItem(Xa,ee?"true":"false")}catch{}}),Ze(()=>c.pageId,async(ee,Y)=>{!ee||ee===Y||(E.value=null,R.value=null,M.value=new Set,await te(),await Se())}),Ft(()=>{D==null||D.abort(),H&&(cancelAnimationFrame(H),H=null)});function me(ee){f.value=ee,Wt(()=>{const Y=document.querySelector(".page-chat-panel textarea");Y&&(Y.focus(),Y.selectionStart=Y.selectionEnd=ee.length)})}return $({prefillMessage:me}),(ee,Y)=>{const K=l("v-icon"),le=l("v-spacer"),ne=l("v-tooltip"),Ce=l("v-btn"),ke=l("v-alert"),xe=l("v-progress-circular"),Ne=l("v-chip"),Ie=l("v-expansion-panel-title"),Ue=l("v-expansion-panel-text"),Te=l("v-expansion-panel"),ye=l("v-expansion-panels"),Je=l("v-switch"),Ke=l("v-textarea");return o(),h("div",jd,[a("div",qd,[e(K,{size:"18",color:"primary"},{default:t(()=>[...Y[5]||(Y[5]=[n("mdi-creation",-1)])]),_:1}),Y[8]||(Y[8]=a("span",{class:"text-body-2 font-weight-medium"},"KI-Chat",-1)),e(le),e(mr,{modelValue:i.value,"onUpdate:modelValue":Y[0]||(Y[0]=$e=>i.value=$e),disabled:p.value||c.isReadOnly,onSelect:_e},null,8,["modelValue","disabled"]),u.value.length>0?(o(),N(Ce,{key:0,icon:"",variant:"text",size:"x-small",color:"error",loading:g.value,disabled:c.isReadOnly,"aria-label":"Chat leeren",onClick:pe},{default:t(()=>[e(ne,{activator:"parent",location:"bottom"},{default:t(()=>[...Y[6]||(Y[6]=[n("Chat leeren",-1)])]),_:1}),e(K,{size:"16"},{default:t(()=>[...Y[7]||(Y[7]=[n("mdi-delete-sweep-outline",-1)])]),_:1})]),_:1},8,["loading","disabled"])):U("",!0)]),c.isReadOnly&&c.lockedBy?(o(),N(ke,{key:0,type:"warning",variant:"tonal",density:"compact",class:"ma-3",style:{"flex-shrink":"0"}},{default:t(()=>[a("div",Gd,[e(K,{size:"16",class:"mr-1"},{default:t(()=>[...Y[9]||(Y[9]=[n("mdi-lock",-1)])]),_:1}),a("strong",null,v(c.lockedBy.firstName||c.lockedBy.email||"Anderer Benutzer"),1),Y[10]||(Y[10]=n(" bearbeitet diese Seite gerade. Chat ist im Lesemodus. ",-1))])]),_:1})):U("",!0),k.value?(o(),N(ke,{key:1,type:"error",variant:"tonal",density:"compact",class:"ma-3 chat-error-alert",closable:"","onClick:close":Y[1]||(Y[1]=()=>{k.value=null,b.value=null})},{default:t(()=>[a("div",Hd,[a("div",Wd,v(k.value),1),b.value?(o(),h("div",Zd,[e(Ce,{size:"small",color:"primary",variant:"flat","prepend-icon":"mdi-refresh",loading:I.value||p.value,disabled:p.value||I.value||c.isReadOnly,onClick:Z},{default:t(()=>[...Y[11]||(Y[11]=[n(" Erneut senden ",-1)])]),_:1},8,["loading","disabled"]),a("span",Jd," „"+v(b.value)+"“ ",1)])):U("",!0)])]),_:1})):U("",!0),a("div",Qd,[_.value?(o(),h("div",Yd,[e(xe,{indeterminate:"",color:"primary",size:"24"})])):u.value.length?(o(!0),h(be,{key:2},Pe(u.value,($e,Ee)=>{var lt,ut;return o(),h("div",{key:Ee,class:ft(["message-row",`message-row--${$e.role}`])},[$e.role==="user"?(o(),h("div",tu,[F($e)?U("",!0):(o(),N(Ce,{key:0,icon:"",variant:"text",size:"x-small",class:"message-delete","aria-label":"Nachricht löschen",onClick:dt(Ve=>q($e,Ee),["stop"])},{default:t(()=>[e(ne,{activator:"parent",location:"bottom"},{default:t(()=>[...Y[15]||(Y[15]=[n("Nachricht löschen",-1)])]),_:1}),e(K,{size:"14"},{default:t(()=>[...Y[16]||(Y[16]=[n("mdi-trash-can-outline",-1)])]),_:1})]),_:1},8,["onClick"])),a("div",au,v($e.content),1),$e.createdAt?(o(),h("div",lu,v(W($e.createdAt)),1)):U("",!0)])):(o(),h("div",{key:1,class:ft(["message-bubble message-assistant",{"message-streaming":F($e)}])},[F($e)?U("",!0):(o(),N(Ce,{key:0,icon:"",variant:"text",size:"x-small",class:"message-delete","aria-label":"Nachricht löschen",onClick:dt(Ve=>q($e,Ee),["stop"])},{default:t(()=>[e(ne,{activator:"parent",location:"bottom"},{default:t(()=>[...Y[17]||(Y[17]=[n("Nachricht löschen",-1)])]),_:1}),e(K,{size:"14"},{default:t(()=>[...Y[18]||(Y[18]=[n("mdi-trash-can-outline",-1)])]),_:1})]),_:1},8,["onClick"])),F($e)&&!$e.content&&!w.value.length?(o(),h("div",nu,[e(xe,{indeterminate:"",size:"14",width:"2",color:"primary"}),Y[19]||(Y[19]=a("span",null,"Generiere...",-1))])):U("",!0),F($e)&&w.value.length>0?(o(),h("div",ou,[e(ye,{variant:"accordion",density:"compact"},{default:t(()=>[e(Te,null,{default:t(()=>[e(Ie,{class:"tool-calls-title"},{default:t(()=>[e(K,{size:"16",class:"mr-2"},{default:t(()=>[...Y[20]||(Y[20]=[n("mdi-wrench",-1)])]),_:1}),a("span",null,v(O.value),1),S.value?(o(),N(Ne,{key:0,size:"x-small",color:"primary",class:"ml-2"},{default:t(()=>[e(xe,{indeterminate:"",size:"12",width:"2",class:"mr-1"}),Y[21]||(Y[21]=n(" Arbeitet... ",-1))]),_:1})):U("",!0)]),_:1}),e(Ue,null,{default:t(()=>[(o(!0),h(be,null,Pe(w.value,(Ve,Le)=>(o(),h("div",{key:Le,class:"tool-call-entry"},[e(K,{size:"14",color:Ve.status==="done"?"success":Ve.status==="error"?"error":"primary",class:"mr-1"},{default:t(()=>[n(v(Ve.status==="done"?"mdi-check-circle":Ve.status==="error"?"mdi-alert-circle":"mdi-loading mdi-spin"),1)]),_:2},1032,["color"]),a("span",su,v(B(Ve.name)),1),Ve.status==="done"&&Ve.result?(o(),h("span",iu,v(G(Ve)),1)):U("",!0)]))),128))]),_:1})]),_:1})]),_:1})])):!F($e)&&$e.toolCalls&&$e.toolCalls.length>0?(o(),h("div",ru,[e(ye,{variant:"accordion",density:"compact"},{default:t(()=>[e(Te,null,{default:t(()=>[e(Ie,{class:"tool-calls-title"},{default:t(()=>[e(K,{size:"16",class:"mr-2"},{default:t(()=>[...Y[22]||(Y[22]=[n("mdi-wrench",-1)])]),_:1}),a("span",null,v($e.toolCalls.filter(Ve=>Ve.status==="done").length)+"/"+v($e.toolCalls.length)+" Aktionen ausgeführt",1)]),_:2},1024),e(Ue,null,{default:t(()=>[(o(!0),h(be,null,Pe($e.toolCalls,(Ve,Le)=>(o(),h("div",{key:Le,class:"tool-call-entry"},[e(K,{size:"14",color:Ve.status==="done"?"success":Ve.status==="error"?"error":"grey",class:"mr-1"},{default:t(()=>[n(v(Ve.status==="done"?"mdi-check-circle":Ve.status==="error"?"mdi-alert-circle":"mdi-help-circle"),1)]),_:2},1032,["color"]),a("span",du,v(B(Ve.name)),1),Ve.status==="done"&&Ve.result?(o(),h("span",uu,v(G(Ve)),1)):U("",!0)]))),128))]),_:2},1024)]),_:2},1024)]),_:2},1024)])):U("",!0),$e.content&&F($e)?(o(),h("div",{key:4,class:"message-text streaming-cursor",innerHTML:z($e.content)},null,8,cu)):$e.content?(o(!0),h(be,{key:5},Pe(j($e.content,$e.toolCalls),(Ve,Le)=>(o(),h(be,{key:`seg-${Ee}-${Le}`},[Ve.kind==="text"?(o(),h("div",{key:0,class:"message-text",innerHTML:z(Ve.text)},null,8,mu)):(o(),h("div",vu,[a("div",pu,[e(K,{size:"12",color:"primary",class:"mr-1"},{default:t(()=>[...Y[23]||(Y[23]=[n("mdi-lightbulb-on-outline",-1)])]),_:1}),Y[24]||(Y[24]=n(" Nächster Schritt ",-1))]),a("div",{class:"preamble-text",innerHTML:z(Ve.text)},null,8,fu)]))],64))),128)):U("",!0),!F($e)&&((lt=$e.extractedMarkers)!=null&&lt.ctas)&&$e.extractedMarkers.ctas.length?(o(),h("div",gu,[(o(!0),h(be,null,Pe($e.extractedMarkers.ctas,Ve=>(o(),N(Ne,{key:Ve.action,size:"small",variant:"outlined",color:"primary",disabled:p.value||c.isReadOnly,class:"cta-chip",onClick:Le=>oe(Ve.action)},{default:t(()=>[n(v(Ve.label),1)]),_:2},1032,["disabled","onClick"]))),128))])):!F($e)&&!((ut=$e.extractedMarkers)!=null&&ut.ctas)&&L($e.content).length?(o(),h("div",bu,[(o(!0),h(be,null,Pe(L($e.content),Ve=>(o(),N(Ne,{key:Ve.action,size:"small",variant:"outlined",color:"primary",disabled:p.value||c.isReadOnly,class:"cta-chip",onClick:Le=>oe(Ve.action)},{default:t(()=>[n(v(Ve.label),1)]),_:2},1032,["disabled","onClick"]))),128))])):U("",!0),!F($e)&&$e.mode==="plan"&&!fe($e)?(o(),h("div",yu,[e(Ce,{size:"small",color:"primary",variant:"flat","prepend-icon":"mdi-play-circle-outline",disabled:p.value||I.value||c.isReadOnly||!!E.value,onClick:Ve=>ce(Ee)},{default:t(()=>[...Y[25]||(Y[25]=[n(" Plan umsetzen ",-1)])]),_:1},8,["disabled","onClick"])])):U("",!0),$e.createdAt&&!F($e)?(o(),h("div",_u,v(W($e.createdAt)),1)):U("",!0)],2))],2)}),128)):(o(),h("div",Xd,[a("div",eu,[e(K,{size:"48",color:"primary",class:"mb-4"},{default:t(()=>[...Y[12]||(Y[12]=[n("mdi-creation",-1)])]),_:1}),Y[13]||(Y[13]=a("h3",{class:"text-h6 mb-2"},"Seite mit KI erstellen",-1)),Y[14]||(Y[14]=a("p",{class:"text-body-2 text-medium-emphasis"}," Beschreibe welche Seite du erstellen möchtest, oder nutze einen der Vorschläge. ",-1))])])),a("div",{ref_key:"chatEndRef",ref:x},null,512)]),E.value?(o(),h("div",ku,[e(Kd,{"page-id":c.pageId,"pending-state":E.value,onApplied:X,onDiscarded:ie},null,8,["page-id","pending-state"])])):U("",!0),E.value?U("",!0):(o(),N(yr,{key:3,sections:c.sections||[],"chat-is-empty":u.value.length===0,disabled:p.value||c.isReadOnly,onSelect:me},null,8,["sections","chat-is-empty","disabled"])),a("div",hu,[a("div",xu,[e(Je,{modelValue:V.value,"onUpdate:modelValue":Y[2]||(Y[2]=$e=>V.value=$e),color:"primary",density:"compact","hide-details":"",inset:"",disabled:p.value||c.isReadOnly,label:V.value?"Plan erst":"Direkt umsetzen","aria-label":"Plan-First-Modus umschalten"},null,8,["modelValue","disabled","label"]),a("span",wu,v(V.value?"KI macht erst einen Vorschlag, dann bestätigst du":"KI setzt direkt mit vollen Tools um"),1)]),a("div",Su,[e(Ke,{modelValue:f.value,"onUpdate:modelValue":Y[3]||(Y[3]=$e=>f.value=$e),placeholder:c.isReadOnly?"Chat ist im Lesemodus...":E.value?"Bitte zuerst Änderungen übernehmen oder verwerfen...":"Nachricht eingeben (Enter zum Senden, Shift+Enter für Zeilenumbruch)...",variant:"outlined",density:"compact",rows:"2","auto-grow":"","max-rows":"5","hide-details":"",disabled:p.value||c.isReadOnly||!!E.value,style:{flex:"1"},onKeydown:C},null,8,["modelValue","placeholder","disabled"]),e(Ce,{color:"primary",loading:p.value,disabled:!f.value.trim()||c.isReadOnly||!!E.value,icon:"","aria-label":"Nachricht senden",onClick:Y[4]||(Y[4]=()=>de())},{default:t(()=>[e(ne,{activator:"parent",location:"bottom"},{default:t(()=>[...Y[26]||(Y[26]=[n("Nachricht senden",-1)])]),_:1}),e(K,null,{default:t(()=>[...Y[27]||(Y[27]=[n("mdi-send",-1)])]),_:1})]),_:1},8,["loading","disabled"])])])])}}}),Cu=Me($u,[["__scopeId","data-v-b775f800"]]),Vu={class:"preview-panel d-flex flex-column",style:{height:"100%"}},Au={class:"preview-toolbar d-flex align-center pa-2 ga-2",style:{"border-bottom":"1px solid rgba(var(--v-border-color), var(--v-border-opacity))","flex-shrink":"0"}},Iu={class:"preview-frame flex-grow-1 d-flex justify-center",style:{overflow:"hidden",background:"rgb(var(--v-theme-surface))"}},Pu=["src"],zu={key:1,class:"d-flex align-center justify-center",style:{width:"100%",height:"100%"}},Du={class:"text-center text-medium-emphasis"},Tu=Ae({__name:"PagePreviewPanel",props:{slug:{},hasDraft:{type:Boolean,default:!1}},emits:["section-selected"],setup(r,{expose:$,emit:d}){const c=r,s=y(null),m=y("desktop"),u=y(null),f=y(c.hasDraft?"draft":"published");let p=null;Ze(()=>c.hasDraft,V=>{!V&&f.value==="draft"&&(f.value="published")});function _(V){if(!c.slug)return"";const E=window.location.origin,R=new URLSearchParams;return R.set("preview","true"),V&&R.set("overlay","true"),f.value==="draft"?R.set("draft","1"):f.value==="version"&&u.value&&R.set("version",u.value),`${E}/${c.slug}?${R.toString()}`}const k=se(()=>_(!0)),i=se(()=>{switch(m.value){case"mobile":return"375px";case"tablet":return"768px";case"desktop":return"100%";default:return"100%"}});function g(){c.slug&&window.open(_(!1),"_blank")}function x(V){if(V===null?(u.value=null,f.value=c.hasDraft?"draft":"published"):typeof V=="string"&&V.length>0&&(u.value=V,f.value="version"),s.value){const E=_(!0);p&&cancelAnimationFrame(p),p=requestAnimationFrame(()=>{p=null,s.value&&(s.value.src=E)})}}function w(V){V!==f.value&&(V!=="version"&&(u.value=null),f.value=V)}const b=d;function I(V){var E;V.origin===window.location.origin&&((E=V.data)==null?void 0:E.type)==="section-select"&&b("section-selected",{sectionName:V.data.sectionName,sectionType:V.data.sectionType,sectionId:V.data.sectionId||V.data.sectionName,order:V.data.order,mergedSections:V.data.mergedSections??null})}return rt(()=>{window.addEventListener("message",I)}),Ft(()=>{p&&(cancelAnimationFrame(p),p=null),window.removeEventListener("message",I)}),$({refresh:x}),(V,E)=>{const R=l("v-icon"),M=l("v-tooltip"),T=l("v-btn"),D=l("v-btn-toggle"),H=l("v-chip"),O=l("v-spacer");return o(),h("div",Vu,[a("div",Au,[e(D,{modelValue:m.value,"onUpdate:modelValue":E[0]||(E[0]=S=>m.value=S),mandatory:"",density:"compact",variant:"outlined"},{default:t(()=>[e(T,{value:"mobile",size:"small"},{default:t(()=>[e(R,{size:"16"},{default:t(()=>[...E[3]||(E[3]=[n("mdi-cellphone",-1)])]),_:1}),e(M,{activator:"parent",location:"bottom"},{default:t(()=>[...E[4]||(E[4]=[n("Mobil (375px)",-1)])]),_:1})]),_:1}),e(T,{value:"tablet",size:"small"},{default:t(()=>[e(R,{size:"16"},{default:t(()=>[...E[5]||(E[5]=[n("mdi-tablet",-1)])]),_:1}),e(M,{activator:"parent",location:"bottom"},{default:t(()=>[...E[6]||(E[6]=[n("Tablet (768px)",-1)])]),_:1})]),_:1}),e(T,{value:"desktop",size:"small"},{default:t(()=>[e(R,{size:"16"},{default:t(()=>[...E[7]||(E[7]=[n("mdi-monitor",-1)])]),_:1}),e(M,{activator:"parent",location:"bottom"},{default:t(()=>[...E[8]||(E[8]=[n("Desktop (100%)",-1)])]),_:1})]),_:1})]),_:1},8,["modelValue"]),r.hasDraft&&f.value!=="version"?(o(),N(D,{key:0,"model-value":f.value,mandatory:"",density:"compact",variant:"outlined",class:"ml-2","onUpdate:modelValue":E[1]||(E[1]=S=>S&&w(S))},{default:t(()=>[e(T,{value:"draft",size:"small"},{default:t(()=>[e(R,{start:"",size:"16"},{default:t(()=>[...E[9]||(E[9]=[n("mdi-file-edit",-1)])]),_:1}),E[11]||(E[11]=n(" Draft ",-1)),e(M,{activator:"parent",location:"bottom"},{default:t(()=>[...E[10]||(E[10]=[n("Aktuellen Draft anzeigen",-1)])]),_:1})]),_:1}),e(T,{value:"published",size:"small"},{default:t(()=>[e(R,{start:"",size:"16"},{default:t(()=>[...E[12]||(E[12]=[n("mdi-earth",-1)])]),_:1}),E[14]||(E[14]=n(" Live ",-1)),e(M,{activator:"parent",location:"bottom"},{default:t(()=>[...E[13]||(E[13]=[n("Veröffentlichte Version anzeigen",-1)])]),_:1})]),_:1})]),_:1},8,["model-value"])):U("",!0),f.value==="version"?(o(),N(H,{key:1,size:"small",color:"info",variant:"tonal",class:"ml-2",closable:"","onClick:close":E[2]||(E[2]=S=>x(null))},{default:t(()=>[e(R,{start:"",size:"14"},{default:t(()=>[...E[15]||(E[15]=[n("mdi-history",-1)])]),_:1}),E[16]||(E[16]=n(" Version-Preview ",-1))]),_:1})):U("",!0),e(O),e(T,{icon:"",size:"small",variant:"text",disabled:!k.value,"aria-label":"Vorschau in neuem Tab öffnen",onClick:g},{default:t(()=>[e(R,{size:"16"},{default:t(()=>[...E[17]||(E[17]=[n("mdi-open-in-new",-1)])]),_:1}),e(M,{activator:"parent",location:"bottom"},{default:t(()=>[...E[18]||(E[18]=[n("In neuem Tab öffnen",-1)])]),_:1})]),_:1},8,["disabled"])]),a("div",Iu,[k.value?(o(),h("iframe",{key:0,ref_key:"iframeRef",ref:s,src:k.value,style:ht({width:i.value,height:"100%",border:"none",transition:"width 0.2s ease"})},null,12,Pu)):(o(),h("div",zu,[a("div",Du,[e(R,{size:"48",class:"mb-2"},{default:t(()=>[...E[19]||(E[19]=[n("mdi-eye-off",-1)])]),_:1}),E[20]||(E[20]=a("p",{class:"text-body-2"},"Vorschau verfügbar nach der ersten Generierung",-1))])]))])])}}}),Lu=Me(Tu,[["__scopeId","data-v-3ed37597"]]),Eu={class:"version-history-panel d-flex flex-column",style:{height:"100%"}},Mu={class:"d-flex align-center px-4 py-3",style:{"border-bottom":"1px solid rgba(var(--v-border-color), var(--v-border-opacity))","flex-shrink":"0"}},Nu={key:0,class:"d-flex justify-end px-4 py-2",style:{"border-bottom":"1px solid rgba(var(--v-border-color), var(--v-border-opacity))","flex-shrink":"0"}},Uu={class:"flex-grow-1 overflow-y-auto"},Bu={class:"d-flex align-center"},Fu={key:0,class:"pa-6 text-center text-medium-emphasis text-caption"},Ou={class:"d-flex align-start"},Ru={class:"flex-grow-1",style:{"min-width":"0"}},Ku={class:"d-flex align-center ga-2 mb-1 flex-wrap"},ju={class:"text-caption text-medium-emphasis"},qu=["title"],Gu={key:0,class:"mt-2 d-flex align-center ga-2"},Hu={key:1,class:"mt-1 d-flex align-center ga-1"},Wu={key:0,class:"text-caption font-italic",style:{color:"rgb(var(--v-theme-accent))"}},Zu={key:1,class:"text-caption text-medium-emphasis font-italic"},Ju={class:"d-flex align-center ga-1 mt-2"},Qu={class:"mb-2"},Yu={key:0},Xu={key:0,class:"text-caption text-medium-emphasis"},ec={key:0,class:"text-caption text-medium-emphasis mt-1"},tc=Ae({__name:"PageVersionHistoryPanel",props:{pageId:{},versions:{},loading:{type:Boolean},currentDraftDirty:{type:Boolean},isReadOnly:{type:Boolean},activeVersionId:{}},emits:["preview","restored","refresh"],setup(r,{emit:$}){const d=r,c=$,s=Jt(),m={"ai-chat":{icon:"mdi-robot-outline",color:"primary",label:"KI-Chat"},manual:{icon:"mdi-account-edit-outline",color:"accent",label:"Manuell"},restore:{icon:"mdi-restore",color:"warning",label:"Wiederherstellung"}};function u(A){return m[A]??{icon:"mdi-file-outline",color:"medium-emphasis",label:A}}const f=se(()=>[...d.versions].sort((A,z)=>{const j=new Date(A.timestamp).getTime();return new Date(z.timestamp).getTime()-j}));function p(A){const z=new Date(A),j=z.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),J=z.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"});return`${j}, ${J}`}const _=y(null),k=y(""),i=y(!1);function g(A){_.value=A.versionId,k.value=A.userLabel||""}function x(){_.value=null,k.value=""}async function w(A){if(!i.value){i.value=!0;try{await s.updateVersionLabel(d.pageId,A.versionId,k.value.trim())&&(_.value=null,k.value="")}catch(z){ue.error("ADMIN","updateVersionLabel fehlgeschlagen",z)}finally{i.value=!1}}}const b=y(!1),I=y(null),V=y(!1);function E(A){I.value=A,b.value=!0}async function R(){if(I.value){V.value=!0;try{await s.restoreVersion(d.pageId,I.value.versionId)&&(b.value=!1,I.value=null,c("restored"))}catch(A){ue.error("ADMIN","restoreVersion fehlgeschlagen",A)}finally{V.value=!1}}}const M=y(!1),T=y(null),D=y(!1);function H(A){T.value=A,M.value=!0}async function O(){if(T.value){D.value=!0;try{await s.deleteVersion(d.pageId,T.value.versionId)&&(M.value=!1,T.value=null,c("refresh"))}catch(A){ue.error("ADMIN","deleteVersion fehlgeschlagen",A)}finally{D.value=!1}}}const S=y(!1),B=y(!1);function G(){S.value=!0}async function W(){B.value=!0;try{await s.deleteAllVersions(d.pageId)&&(S.value=!1,c("refresh"))}catch(A){ue.error("ADMIN","deleteAllVersions fehlgeschlagen",A)}finally{B.value=!1}}function F(){c("preview",null)}function L(A){c("preview",A.versionId)}return(A,z)=>{const j=l("v-icon"),J=l("v-spacer"),Q=l("v-tooltip"),te=l("v-btn"),ve=l("v-alert"),de=l("v-chip"),Z=l("v-divider"),ce=l("v-text-field"),oe=l("v-card-title"),pe=l("v-card-text"),_e=l("v-card-actions"),q=l("v-card"),C=l("v-dialog");return o(),h("div",Eu,[a("div",Mu,[e(j,{start:"",size:"20",color:"primary"},{default:t(()=>[...z[8]||(z[8]=[n("mdi-history",-1)])]),_:1}),z[11]||(z[11]=a("span",{class:"text-body-1 font-weight-medium"},"Draft-Versionen",-1)),e(J),e(te,{icon:"",size:"x-small",variant:"text","aria-label":"Versionen neu laden",loading:r.loading,onClick:z[0]||(z[0]=ae=>c("refresh"))},{default:t(()=>[e(Q,{activator:"parent",location:"bottom"},{default:t(()=>[...z[9]||(z[9]=[n("Aktualisieren",-1)])]),_:1}),e(j,{size:"16"},{default:t(()=>[...z[10]||(z[10]=[n("mdi-refresh",-1)])]),_:1})]),_:1},8,["loading"])]),f.value.length>0?(o(),h("div",Nu,[e(te,{size:"x-small",variant:"tonal",color:"error",disabled:r.isReadOnly||B.value,onClick:G},{default:t(()=>[e(j,{start:"",size:"14"},{default:t(()=>[...z[12]||(z[12]=[n("mdi-delete-sweep-outline",-1)])]),_:1}),z[13]||(z[13]=n(" Alle Versionen löschen ",-1))]),_:1},8,["disabled"])])):U("",!0),r.currentDraftDirty?(o(),N(ve,{key:1,type:"warning",variant:"tonal",density:"compact",class:"ma-3",icon:"mdi-alert-outline"},{default:t(()=>[...z[14]||(z[14]=[a("div",{class:"text-caption"},[n(" Du hast ungespeicherte Draft-Änderungen. Wenn du eine Version wiederherstellst, gehen sie verloren – sie werden aber vorher automatisch als "),a("strong",null,"Wiederherstellungs-Snapshot"),n(" gesichert. ")],-1)])]),_:1})):U("",!0),a("div",Uu,[a("div",{class:ft(["version-item px-4 py-3",{active:r.activeVersionId===null}]),role:"button",tabindex:"0",onClick:F,onKeydown:Kt(F,["enter"])},[a("div",Bu,[e(j,{size:"20",color:"primary",class:"mr-3"},{default:t(()=>[...z[15]||(z[15]=[n("mdi-file-edit-outline",-1)])]),_:1}),z[17]||(z[17]=a("div",{class:"flex-grow-1"},[a("div",{class:"text-body-2 font-weight-medium"},"Aktueller Stand"),a("div",{class:"text-caption text-medium-emphasis"}," Neueste Änderungen ")],-1)),e(de,{size:"x-small",variant:"tonal",color:"primary"},{default:t(()=>[...z[16]||(z[16]=[n("Live-Draft",-1)])]),_:1})])],34),e(Z),f.value.length?U("",!0):(o(),h("div",Fu," Noch keine Versionen vorhanden. Jede gespeicherte KI-Änderung oder manuelle Anpassung wird hier als Version abgelegt. ")),(o(!0),h(be,null,Pe(f.value,ae=>(o(),h(be,{key:ae.versionId},[a("div",{class:ft(["version-item px-4 py-3",{active:r.activeVersionId===ae.versionId}])},[a("div",Ou,[e(Q,{location:"top"},{activator:t(({props:X})=>[e(j,Vt({ref_for:!0},X,{size:"20",color:u(ae.source).color,class:"mr-3 mt-1"}),{default:t(()=>[n(v(u(ae.source).icon),1)]),_:2},1040,["color"])]),default:t(()=>[n(" "+v(u(ae.source).label),1)]),_:2},1024),a("div",Ru,[a("div",Ku,[e(de,{size:"x-small",variant:"tonal",color:u(ae.source).color},{default:t(()=>[n(v(u(ae.source).label),1)]),_:2},1032,["color"]),a("span",ju,v(p(ae.timestamp)),1)]),a("div",{class:"text-body-2 text-truncate",title:ae.description},v(ae.description||"Änderung"),9,qu),_.value===ae.versionId?(o(),h("div",Gu,[e(ce,{modelValue:k.value,"onUpdate:modelValue":z[1]||(z[1]=X=>k.value=X),density:"compact",variant:"outlined","hide-details":"",autofocus:"",placeholder:"Eigene Beschreibung (optional)",maxlength:"200",disabled:i.value,onKeydown:[Kt(X=>w(ae),["enter"]),Kt(x,["esc"])]},null,8,["modelValue","disabled","onKeydown"]),e(te,{icon:"",size:"x-small",variant:"text",color:"primary",loading:i.value,"aria-label":"Beschreibung speichern",onClick:X=>w(ae)},{default:t(()=>[e(j,{size:"16"},{default:t(()=>[...z[18]||(z[18]=[n("mdi-check",-1)])]),_:1})]),_:1},8,["loading","onClick"]),e(te,{icon:"",size:"x-small",variant:"text","aria-label":"Abbrechen",disabled:i.value,onClick:x},{default:t(()=>[e(j,{size:"16"},{default:t(()=>[...z[19]||(z[19]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["disabled"])])):(o(),h("div",Hu,[ae.userLabel?(o(),h("span",Wu," „"+v(ae.userLabel)+"“ ",1)):(o(),h("span",Zu," Keine eigene Beschreibung ")),e(te,{icon:"",size:"x-small",variant:"text",class:"ml-1","aria-label":"Eigene Beschreibung bearbeiten",disabled:r.isReadOnly,onClick:X=>g(ae)},{default:t(()=>[e(Q,{activator:"parent",location:"top"},{default:t(()=>[...z[20]||(z[20]=[n("Eigene Beschreibung bearbeiten",-1)])]),_:1}),e(j,{size:"14"},{default:t(()=>[...z[21]||(z[21]=[n("mdi-pencil-outline",-1)])]),_:1})]),_:1},8,["disabled","onClick"])])),a("div",Ju,[e(te,{size:"x-small",variant:"tonal",color:"primary",onClick:X=>L(ae)},{default:t(()=>[e(j,{start:"",size:"14"},{default:t(()=>[...z[22]||(z[22]=[n("mdi-eye-outline",-1)])]),_:1}),z[23]||(z[23]=n(" Vorschau ",-1))]),_:1},8,["onClick"]),e(te,{size:"x-small",variant:"tonal",color:"warning",disabled:r.isReadOnly,onClick:X=>E(ae)},{default:t(()=>[e(j,{start:"",size:"14"},{default:t(()=>[...z[24]||(z[24]=[n("mdi-restore",-1)])]),_:1}),z[25]||(z[25]=n(" Wiederherstellen ",-1))]),_:1},8,["disabled","onClick"]),e(J),e(te,{icon:"",size:"x-small",variant:"text",color:"error","aria-label":"Version löschen",disabled:r.isReadOnly,onClick:X=>H(ae)},{default:t(()=>[e(Q,{activator:"parent",location:"top"},{default:t(()=>[...z[26]||(z[26]=[n("Version löschen",-1)])]),_:1}),e(j,{size:"16"},{default:t(()=>[...z[27]||(z[27]=[n("mdi-delete-outline",-1)])]),_:1})]),_:1},8,["disabled","onClick"])])])])],2),e(Z)],64))),128))]),e(C,{modelValue:b.value,"onUpdate:modelValue":z[3]||(z[3]=ae=>b.value=ae),"max-width":"480",persistent:""},{default:t(()=>[e(q,null,{default:t(()=>[e(oe,{class:"text-body-1 d-flex align-center"},{default:t(()=>[e(j,{start:"",color:"warning"},{default:t(()=>[...z[28]||(z[28]=[n("mdi-restore",-1)])]),_:1}),z[29]||(z[29]=n(" Version wiederherstellen ",-1))]),_:1}),e(pe,{class:"text-body-2"},{default:t(()=>[a("p",Qu,[z[30]||(z[30]=n(" Version vom ",-1)),I.value?(o(),h("strong",Yu,v(p(I.value.timestamp)),1)):U("",!0),z[31]||(z[31]=n(" wiederherstellen? ",-1))]),r.currentDraftDirty?(o(),h("p",Xu," Dein aktueller Draft wird vorher automatisch als Snapshot gesichert, damit du ihn bei Bedarf wiederherstellen kannst. ")):U("",!0)]),_:1}),e(_e,null,{default:t(()=>[e(J),e(te,{variant:"text",disabled:V.value,onClick:z[2]||(z[2]=ae=>b.value=!1)},{default:t(()=>[...z[32]||(z[32]=[n(" Abbrechen ",-1)])]),_:1},8,["disabled"]),e(te,{color:"warning",variant:"elevated",loading:V.value,onClick:R},{default:t(()=>[...z[33]||(z[33]=[n(" Wiederherstellen ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(C,{modelValue:S.value,"onUpdate:modelValue":z[5]||(z[5]=ae=>S.value=ae),"max-width":"480",persistent:""},{default:t(()=>[e(q,null,{default:t(()=>[e(oe,{class:"text-body-1 d-flex align-center"},{default:t(()=>[e(j,{start:"",color:"error"},{default:t(()=>[...z[34]||(z[34]=[n("mdi-delete-sweep-outline",-1)])]),_:1}),z[35]||(z[35]=n(" Alle Versionen löschen ",-1))]),_:1}),e(pe,{class:"text-body-2"},{default:t(()=>[a("p",null,[z[36]||(z[36]=n(" Alle ",-1)),a("strong",null,v(f.value.length),1),z[37]||(z[37]=n(" Versionen werden gelöscht und der ",-1)),z[38]||(z[38]=a("strong",null,"aktuelle Draft verworfen",-1)),z[39]||(z[39]=n(". ",-1))]),z[40]||(z[40]=a("p",{class:"text-caption text-medium-emphasis mt-2"}," Die veröffentlichte Live-Version der Seite bleibt unverändert. Nach dem Zurücksetzen arbeitest du wieder auf dem Live-Stand. Das kann nicht rückgängig gemacht werden. ",-1))]),_:1}),e(_e,null,{default:t(()=>[e(J),e(te,{variant:"text",disabled:B.value,onClick:z[4]||(z[4]=ae=>S.value=!1)},{default:t(()=>[...z[41]||(z[41]=[n(" Abbrechen ",-1)])]),_:1},8,["disabled"]),e(te,{color:"error",variant:"elevated",loading:B.value,onClick:W},{default:t(()=>[...z[42]||(z[42]=[n(" Alle löschen ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(C,{modelValue:M.value,"onUpdate:modelValue":z[7]||(z[7]=ae=>M.value=ae),"max-width":"480",persistent:""},{default:t(()=>[e(q,null,{default:t(()=>[e(oe,{class:"text-body-1 d-flex align-center"},{default:t(()=>[e(j,{start:"",color:"error"},{default:t(()=>[...z[43]||(z[43]=[n("mdi-delete-outline",-1)])]),_:1}),z[44]||(z[44]=n(" Version löschen ",-1))]),_:1}),e(pe,{class:"text-body-2"},{default:t(()=>[z[45]||(z[45]=a("p",null," Diese Version löschen? Das kann nicht rückgängig gemacht werden. ",-1)),T.value?(o(),h("p",ec,v(p(T.value.timestamp))+" – "+v(u(T.value.source).label),1)):U("",!0)]),_:1}),e(_e,null,{default:t(()=>[e(J),e(te,{variant:"text",disabled:D.value,onClick:z[6]||(z[6]=ae=>M.value=!1)},{default:t(()=>[...z[46]||(z[46]=[n(" Abbrechen ",-1)])]),_:1},8,["disabled"]),e(te,{color:"error",variant:"elevated",loading:D.value,onClick:O},{default:t(()=>[...z[47]||(z[47]=[n(" Löschen ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}}),ac=Me(tc,[["__scopeId","data-v-f240b65f"]]),lc={class:"page-editor-view d-flex flex-column",style:{height:"calc(100vh - 64px)",overflow:"hidden"}},nc={class:"editor-header d-flex align-center px-4 py-2",style:{"border-bottom":"1px solid rgba(var(--v-border-color), var(--v-border-opacity))","flex-shrink":"0"}},oc={class:"text-body-1 font-weight-medium ml-2"},sc={key:0,class:"d-flex align-center ga-1 ml-3 text-caption text-medium-emphasis"},ic={key:2,class:"split-view flex-grow-1 d-flex",style:{"min-height":"0",overflow:"hidden"}},rc={class:"editor-grid flex-grow-1 overflow-hidden",style:{"min-height":"0"}},dc={class:"editor-center overflow-hidden d-flex flex-column"},uc={class:"editor-preview overflow-hidden"},cc=Ae({__name:"PageEditorView",setup(r){const $=Ut(),d=xt(),c=Jt();function s(K){return K?typeof K=="string"?K:K._id??null:null}function m(K){return!K||typeof K=="string"?null:K}const u=qe("page_editor_mode","chat"),f=qe("page_editor_split_width",60),p=y(!1),_=y(!1),k=y(!1),i=y(0),g=y(!1),x=y(null),w=y(null),b=y(null),I=[{key:"rephrase",label:"Text umschreiben",defaults:{temperature:.7,maxTokens:4096}},{key:"shorten",label:"Text kürzen",defaults:{temperature:.3,maxTokens:2048}},{key:"expand",label:"Text erweitern",defaults:{temperature:.7,maxTokens:8192}},{key:"enrich",label:"Mit KB anreichern",defaults:{temperature:.5,maxTokens:8192}},{key:"seo",label:"SEO-Optimierung",defaults:{temperature:.2,maxTokens:4096}},{key:"custom",label:"Eigene Anweisung",defaults:{temperature:.7,maxTokens:4096}}],V=se(()=>$.params.id),E=se(()=>{const K=$.params.id;return typeof K=="string"&&K.length>0?K:null}),{isLocked:R,isLockedByMe:M,lockedBy:T,lockedAt:D,isLockTakenOver:H,takenOverBy:O,takeOverLock:S}=sa("WebsitePage",E),B=se(()=>R.value&&!M.value||H.value),G=se(()=>{var le,ne;const K=((le=c.currentPage)==null?void 0:le.path)||"";return K&&K!=="/"?K.replace(/^\//,""):((ne=c.currentPage)==null?void 0:ne.slug)||""}),W=se(()=>{var K;return((K=c.currentPage)==null?void 0:K.status)||"draft"}),F=se(()=>W.value==="published"),L=y(!1),A=se(()=>{var K;return((K=c.currentPage)==null?void 0:K.hasDraft)||!1}),z=se(()=>{var K;return((K=c.currentPage)==null?void 0:K.draftVersions)||[]}),j=se(()=>{const K=c.currentPage;if(!K)return[];const le=Array.isArray(K.draftContent)?K.draftContent:[],ne=Array.isArray(K.content)?K.content:[];return(K.hasDraft&&le.length?le:ne).map((ke,xe)=>({order:typeof ke.order=="number"?ke.order:xe,type:ke.type,title:ke.title}))}),J=y(!1),Q=y(null),te=y(!1),ve=se(()=>A.value?u.value==="editor"?c.isDirty:!0:!1);async function de(){var K;if(B.value){ue.warn("ADMIN","Veroeffentlichen blockiert - kein Lock-Owner");return}L.value=!0;try{F.value&&A.value?await c.updateStatus(V.value,"published"):await c.updateStatus(V.value,F.value?"draft":"published"),Q.value=null,await c.fetchPage(V.value),(K=w.value)==null||K.refresh(null)}finally{L.value=!1}}const Z=y({show:!1,text:"",color:"success"});function ce(K,le="success"){Z.value={show:!0,text:K,color:le}}function oe(K){var le;Q.value=K,(le=w.value)==null||le.refresh(K)}async function pe(){var K;await c.fetchPage(V.value),Q.value=null,(K=w.value)==null||K.refresh(null),ce("Version wiederhergestellt","success")}async function _e(){try{await c.fetchPage(V.value)}catch(K){ue.error("ADMIN","Versionen konnten nicht neu geladen werden",K),ce("Versionen konnten nicht aktualisiert werden","error")}}async function q(){var le;if(B.value){ue.warn("ADMIN","Draft verwerfen blockiert - kein Lock-Owner");return}if(window.confirm("Alle Draft-Änderungen verwerfen und zum Live-Stand zurückkehren?")){te.value=!0;try{await re.post(`/admin/pages/${V.value}/discard-draft`,{}),Q.value=null,await c.fetchPage(V.value),(le=w.value)==null||le.refresh(null)}catch(ne){ue.error("ADMIN","Draft verwerfen fehlgeschlagen",ne)}finally{te.value=!1}}}rt(async()=>{const K=$.params.id;K&&await c.fetchPage(K)}),La((K,le,ne)=>{if(u.value==="editor"&&c.isDirty&&!window.confirm("Es gibt ungespeicherte Änderungen. Möchtest du die Seite wirklich verlassen?")){ne(!1);return}ne()});function C(K){i.value=K,k.value=!0}async function ae(){if(B.value){ue.warn("ADMIN","Speichern blockiert - kein Lock-Owner");return}await c.savePage()}function X(K){}function ie(){var K;Q.value=null,c.fetchPage(V.value),(K=w.value)==null||K.refresh(null)}function fe(K){var le,ne;if(Array.isArray(K.mergedSections)&&K.mergedSections.length>0){const Ce=K.mergedSections.map(function(ke){return`#${ke.order} ${ke.type}`}).join(", ");(le=b.value)==null||le.prefillMessage(`Ich möchte den zusammengefassten Bereich anpassen (enthält Sections ${Ce})
`)}else{const Ce=K.sectionId||K.sectionName||`#${K.order}`;(ne=b.value)==null||ne.prefillMessage(`Ich möchte Section ${Ce} (${K.sectionType}) anpassen
`)}}function Se(){u.value="editor"}function me(K){p.value=!0,document.addEventListener("mousemove",ee),document.addEventListener("mouseup",Y),K.preventDefault()}function ee(K){if(!p.value)return;const le=document.querySelector(".split-view");if(!le)return;const ne=le.getBoundingClientRect(),Ce=(K.clientX-ne.left)/ne.width*100;f.value=Math.max(30,Math.min(75,Ce))}function Y(){p.value=!1,document.removeEventListener("mousemove",ee),document.removeEventListener("mouseup",Y)}return Ft(()=>{document.removeEventListener("mousemove",ee),document.removeEventListener("mouseup",Y)}),(K,le)=>{var Ke,$e;const ne=l("v-tooltip"),Ce=l("v-icon"),ke=l("v-btn"),xe=l("v-spacer"),Ne=l("v-btn-toggle"),Ie=l("v-badge"),Ue=l("v-progress-linear"),Te=l("v-alert"),ye=l("v-navigation-drawer"),Je=l("v-snackbar");return o(),h("div",lc,[a("div",nc,[e(ke,{icon:"",variant:"text",size:"small","aria-label":"Zurück zur Seitenübersicht",onClick:le[0]||(le[0]=Ee=>P(d).push("/admin/seiten"))},{default:t(()=>[e(ne,{activator:"parent",location:"bottom"},{default:t(()=>[...le[11]||(le[11]=[n("Zurück zur Seitenübersicht",-1)])]),_:1}),e(Ce,null,{default:t(()=>[...le[12]||(le[12]=[n("mdi-arrow-left",-1)])]),_:1})]),_:1}),a("span",oc,v(((Ke=P(c).currentPage)==null?void 0:Ke.title)||"Seite"),1),($e=P(c).currentPage)!=null&&$e._id?(o(),h("div",sc,[le[13]||(le[13]=a("span",null,"Erstellt:",-1)),e(gt,{"user-id":s(P(c).currentPage.createdBy),populated:m(P(c).currentPage.createdBy),size:22},null,8,["user-id","populated"]),le[14]||(le[14]=a("span",{class:"mx-1"},"·",-1)),le[15]||(le[15]=a("span",null,"Geändert:",-1)),e(gt,{"user-id":s(P(c).currentPage.updatedBy),populated:m(P(c).currentPage.updatedBy),size:22},null,8,["user-id","populated"])])):U("",!0),e(xe),e(Ne,{modelValue:P(u),"onUpdate:modelValue":le[1]||(le[1]=Ee=>ot(u)?u.value=Ee:null),mandatory:"",density:"compact",class:"mr-2",variant:"outlined"},{default:t(()=>[e(ke,{value:"chat",size:"small"},{default:t(()=>[e(Ce,{start:"",size:"16"},{default:t(()=>[...le[16]||(le[16]=[n("mdi-creation",-1)])]),_:1}),le[17]||(le[17]=n(" KI-Chat ",-1))]),_:1}),e(ke,{value:"editor",size:"small"},{default:t(()=>[e(Ce,{start:"",size:"16"},{default:t(()=>[...le[18]||(le[18]=[n("mdi-pencil",-1)])]),_:1}),le[19]||(le[19]=n(" Editor ",-1))]),_:1})]),_:1},8,["modelValue"]),F.value&&A.value?(o(),N(ke,{key:1,color:"primary",size:"small",variant:"elevated",class:"mr-2",loading:L.value,disabled:B.value,onClick:de},{default:t(()=>[e(ne,{activator:"parent",location:"bottom"},{default:t(()=>[...le[20]||(le[20]=[n(" Draft-Änderungen in die Live-Version übernehmen ",-1)])]),_:1}),e(Ce,{start:"",size:"16"},{default:t(()=>[...le[21]||(le[21]=[n("mdi-publish",-1)])]),_:1}),le[22]||(le[22]=n(" Live schalten ",-1))]),_:1},8,["loading","disabled"])):(o(),N(ke,{key:2,color:F.value?"success":"warning",size:"small",variant:"tonal",class:"mr-2",loading:L.value,disabled:B.value,onClick:de},{default:t(()=>[e(ne,{activator:"parent",location:"bottom"},{default:t(()=>[n(v(F.value?"Klicken um als Entwurf zurückzusetzen":"Klicken um die Seite zu veröffentlichen"),1)]),_:1}),e(Ce,{start:"",size:"16"},{default:t(()=>[n(v(F.value?"mdi-earth":"mdi-pencil-outline"),1)]),_:1}),n(" "+v(F.value?"Veröffentlicht":"Entwurf"),1)]),_:1},8,["color","loading","disabled"])),A.value&&z.value.length>0?(o(),N(ke,{key:3,size:"small",variant:"tonal",color:"info",class:"mr-2",onClick:le[2]||(le[2]=Ee=>J.value=!0)},{default:t(()=>[e(Ce,{start:"",size:"16"},{default:t(()=>[...le[23]||(le[23]=[n("mdi-history",-1)])]),_:1}),le[24]||(le[24]=n(" Änderungen ",-1)),e(Ie,{content:z.value.length,color:"primary",inline:"",class:"ml-1"},null,8,["content"])]),_:1})):U("",!0),A.value?(o(),N(ke,{key:4,icon:"",variant:"text",size:"small",loading:te.value,disabled:B.value,class:"mr-1","aria-label":"Alle Draft-Änderungen verwerfen",onClick:q},{default:t(()=>[e(ne,{activator:"parent",location:"bottom"},{default:t(()=>[...le[25]||(le[25]=[n(" Alle Draft-Änderungen verwerfen und zum Live-Stand zurückkehren ",-1)])]),_:1}),e(Ce,null,{default:t(()=>[...le[26]||(le[26]=[n("mdi-delete-sweep-outline",-1)])]),_:1})]),_:1},8,["loading","disabled"])):U("",!0),e(ke,{icon:"",variant:"text",size:"small",onClick:le[3]||(le[3]=Ee=>g.value=!0)},{default:t(()=>[e(ne,{activator:"parent",location:"bottom"},{default:t(()=>[...le[27]||(le[27]=[n("Seiten-Einstellungen",-1)])]),_:1}),e(Ce,null,{default:t(()=>[...le[28]||(le[28]=[n("mdi-cog",-1)])]),_:1})]),_:1})]),P(c).loading?(o(),N(Ue,{key:0,indeterminate:"",color:"primary",height:"2"})):U("",!0),P(c).error&&!P(c).loading?(o(),N(Te,{key:1,type:"error",variant:"tonal",density:"compact",class:"mx-4 mt-2",closable:""},{default:t(()=>[n(v(P(c).error),1)]),_:1})):U("",!0),e(ia,{class:"mx-4 mt-2","is-locked":P(R),"is-locked-by-me":P(M),"locked-by":P(T),"locked-at":P(D),"is-lock-taken-over":P(H),"taken-over-by":P(O),"on-take-over":P(S)},null,8,["is-locked","is-locked-by-me","locked-by","locked-at","is-lock-taken-over","taken-over-by","on-take-over"]),P(u)==="chat"?(o(),h("div",ic,[e(Cu,{ref_key:"chatPanelRef",ref:b,"page-id":V.value,"page-slug":G.value,sections:j.value,"is-read-only":B.value,"locked-by":P(T),style:ht({width:P(f)+"%",minWidth:"30%",maxWidth:"75%"}),onSectionsUpdated:ie,onSwitchEditor:Se,onPreviewRefresh:le[4]||(le[4]=Ee=>{var lt;return(lt=w.value)==null?void 0:lt.refresh(null)})},null,8,["page-id","page-slug","sections","is-read-only","locked-by","style"]),a("div",{class:"splitter",style:{width:"6px",cursor:"col-resize","flex-shrink":"0",background:"rgba(var(--v-border-color), var(--v-border-opacity))",display:"flex","align-items":"center","justify-content":"center"},onMousedown:me},[e(Ce,{size:"14",color:"medium-emphasis"},{default:t(()=>[...le[29]||(le[29]=[n("mdi-drag-vertical",-1)])]),_:1})],32),e(Lu,{ref_key:"previewRef",ref:w,slug:G.value,"has-draft":A.value,style:ht({width:100-P(f)+"%",minWidth:"25%"}),onSectionSelected:fe},null,8,["slug","has-draft","style"])])):(o(),h(be,{key:3},[e(ls,{onSave:ae,onOpenSettings:le[5]||(le[5]=Ee=>g.value=!0),onToggleAiSidebar:()=>{}},{default:t(()=>[e(ta,{ref_key:"gptSettingsRef",ref:x,"page-key":"page-editor","page-label":"Page-Editor KI-Einstellungen",usecases:I},null,512)]),_:1}),a("div",rc,[e(ws,{collapsed:_.value,onToggle:le[6]||(le[6]=Ee=>_.value=!_.value),onInsertModule:C},null,8,["collapsed"]),a("div",dc,[e(Vi,{onAiAction:X})]),a("div",uc,[e(Di)])]),e(Ui,{modelValue:k.value,"onUpdate:modelValue":le[7]||(le[7]=Ee=>k.value=Ee),"insert-at-index":i.value},null,8,["modelValue","insert-at-index"])],64)),e(Yi,{modelValue:g.value,"onUpdate:modelValue":le[8]||(le[8]=Ee=>g.value=Ee),"is-read-only":B.value},null,8,["modelValue","is-read-only"]),e(ye,{modelValue:J.value,"onUpdate:modelValue":le[9]||(le[9]=Ee=>J.value=Ee),location:"right",temporary:"",width:"460",scrim:!0},{default:t(()=>[e(ac,{"page-id":V.value,versions:z.value,loading:P(c).loading,"current-draft-dirty":ve.value,"is-read-only":B.value,"active-version-id":Q.value,onPreview:oe,onRestored:pe,onRefresh:_e},null,8,["page-id","versions","loading","current-draft-dirty","is-read-only","active-version-id"])]),_:1},8,["modelValue"]),e(Je,{modelValue:Z.value.show,"onUpdate:modelValue":le[10]||(le[10]=Ee=>Z.value.show=Ee),color:Z.value.color,timeout:3e3,location:"bottom"},{default:t(()=>[n(v(Z.value.text),1)]),_:1},8,["modelValue","color"])])}}}),mc=Me(cc,[["__scopeId","data-v-0dae099c"]]),m6=Object.freeze(Object.defineProperty({__proto__:null,default:mc},Symbol.toStringTag,{value:"Module"})),vc=Zt("users",()=>{const r=y([]),$=y(!1),d=y(null);async function c(){$.value=!0,d.value=null;try{const p=await re.get("/admin/users");p.success&&p.data?r.value=p.data:d.value=p.error||"Fehler beim Laden der Benutzer"}finally{$.value=!1}}async function s(p){d.value=null;const _=await re.post("/admin/users",p);return _.success&&_.data?(r.value.unshift(_.data),_.data):(d.value=_.error||"Fehler beim Erstellen",null)}async function m(p,_){d.value=null;const k=await re.put(`/admin/users/${p}`,_);if(k.success&&k.data){const i=r.value.findIndex(g=>g._id===p);return i>=0&&(r.value[i]=k.data),k.data}return d.value=k.error||"Fehler beim Aktualisieren",null}async function u(p){d.value=null;const _=await re.delete(`/admin/users/${p}`);if(_.success){const k=r.value.findIndex(i=>i._id===p);return k>=0&&(r.value[k].isActive=!1),!0}return d.value=_.error||"Fehler beim Deaktivieren",!1}async function f(p){d.value=null;const _=await re.put(`/admin/users/${p}/password`);return _.success?!0:(d.value=_.error||"Fehler beim Passwort-Reset",!1)}return{users:r,loading:$,error:d,fetchUsers:c,createUser:s,updateUser:m,deleteUser:u,resetPassword:f}}),Sa=Ae({__name:"TooltipIconBtn",props:{tooltip:{type:String,required:!0},icon:{type:String,default:""},color:{type:String,default:""},variant:{type:String,default:"text"},size:{type:String,default:"small"},density:{type:String,default:"default"},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},to:{type:[String,Object],default:void 0},href:{type:String,default:""},type:{type:String,default:void 0},location:{type:String,default:"bottom"}},emits:["click"],setup(r){return($,d)=>{const c=l("v-icon"),s=l("v-tooltip"),m=l("v-btn");return o(),N(m,{icon:"",variant:r.variant,size:r.size,color:r.color||void 0,density:r.density,loading:r.loading,disabled:r.disabled,to:r.to,href:r.href||void 0,type:r.type,"aria-label":r.tooltip,onClick:d[0]||(d[0]=u=>$.$emit("click",u))},{default:t(()=>[r.icon?(o(),N(c,{key:0},{default:t(()=>[n(v(r.icon),1)]),_:1})):Xt($.$slots,"default",{key:1}),e(s,{activator:"parent",location:r.location},{default:t(()=>[n(v(r.tooltip),1)]),_:1},8,["location"])]),_:3},8,["variant","size","color","density","loading","disabled","to","href","type","aria-label"])}}}),pc={class:"pa-6"},fc={class:"d-flex align-center justify-space-between mb-6"},gc={class:"d-flex align-center ga-3"},bc={class:"text-body-2 font-weight-bold"},yc={class:"mb-3"},_c=Ae({__name:"UsersView",setup(r){const $=vc(),d=qe("users_items_per_page",20),c=qe("users_sort",[]),s=y(!1),m=y(!1),u=y(!1),f=y(!1),p=y(null),_=y({email:"",firstName:"",lastName:"",role:"editor",password:""}),k=[{title:"Name",key:"name",sortable:!0},{title:"E-Mail",key:"email",sortable:!0},{title:"Rolle",key:"role",sortable:!0},{title:"Status",key:"isActive",sortable:!0},{title:"Erstellt",key:"createdAt",sortable:!0},{title:"Letzter Login",key:"lastLoginAt",sortable:!0},{title:"Aktionen",key:"actions",sortable:!1,align:"end"}],i=se(()=>$.users.map(D=>({...D,name:`${D.firstName} ${D.lastName}`,initials:`${(D.firstName||"?")[0]}${(D.lastName||"?")[0]}`.toUpperCase()})));function g(D){switch(D){case"admin":return"primary";case"editor":return"info";default:return"default"}}function x(D){return D?new Date(D).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}):"-"}function w(D){return D?new Date(D).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"–"}function b(){f.value=!1,p.value=null,_.value={email:"",firstName:"",lastName:"",role:"editor",password:""},s.value=!0}function I(D){f.value=!0,p.value=D._id,_.value={email:D.email,firstName:D.firstName,lastName:D.lastName,role:D.role,password:""},s.value=!0}function V(D){p.value=D,m.value=!0}function E(D){p.value=D,u.value=!0}async function R(){f.value&&p.value?await $.updateUser(p.value,{firstName:_.value.firstName,lastName:_.value.lastName,role:_.value.role}):await $.createUser({email:_.value.email,password:_.value.password,firstName:_.value.firstName,lastName:_.value.lastName,role:_.value.role}),$.error||(s.value=!1)}async function M(){p.value&&(await $.deleteUser(p.value),$.error||(m.value=!1))}async function T(){p.value&&(await $.resetPassword(p.value),$.error||(u.value=!1))}return rt(()=>$.fetchUsers()),(D,H)=>{const O=l("v-btn"),S=l("v-alert"),B=l("v-avatar"),G=l("v-chip"),W=l("v-data-table"),F=l("v-card"),L=l("v-card-title"),A=l("v-text-field"),z=l("v-btn-toggle"),j=l("v-card-text"),J=l("v-spacer"),Q=l("v-card-actions"),te=l("v-dialog");return o(),h("div",pc,[a("div",fc,[H[14]||(H[14]=a("h1",{class:"text-h5 font-weight-bold"},"Benutzer",-1)),e(O,{color:"primary","prepend-icon":"mdi-plus",onClick:b},{default:t(()=>[...H[13]||(H[13]=[n(" Neuer Benutzer ",-1)])]),_:1})]),P($).error?(o(),N(S,{key:0,type:"error",class:"mb-4",closable:""},{default:t(()=>[n(v(P($).error),1)]),_:1})):U("",!0),e(F,{variant:"outlined"},{default:t(()=>[e(W,{headers:k,items:i.value,loading:P($).loading,"sort-by":P(c),"items-per-page":P(d),"onUpdate:itemsPerPage":H[0]||(H[0]=ve=>ot(d)?d.value=ve:null),"item-value":"_id","onUpdate:sortBy":H[1]||(H[1]=ve=>c.value=ve)},{"item.name":t(({item:ve})=>[a("div",gc,[e(B,{size:"32",color:"primary"},{default:t(()=>[a("span",bc,v(ve.initials),1)]),_:2},1024),n(" "+v(ve.name),1)])]),"item.role":t(({item:ve})=>[e(G,{color:g(ve.role),size:"small",label:""},{default:t(()=>[n(v(ve.role),1)]),_:2},1032,["color"])]),"item.isActive":t(({item:ve})=>[e(G,{color:ve.isActive?"success":"error",size:"small",label:""},{default:t(()=>[n(v(ve.isActive?"Aktiv":"Inaktiv"),1)]),_:2},1032,["color"])]),"item.createdAt":t(({item:ve})=>[n(v(x(ve.createdAt)),1)]),"item.lastLoginAt":t(({item:ve})=>[n(v(w(ve.lastLoginAt)),1)]),"item.actions":t(({item:ve})=>[e(Sa,{tooltip:"Benutzer bearbeiten",icon:"mdi-pencil",onClick:dt(de=>I(ve),["stop"])},null,8,["onClick"]),e(Sa,{tooltip:"Passwort zurücksetzen",icon:"mdi-lock-reset",onClick:dt(de=>E(ve._id),["stop"])},null,8,["onClick"]),e(Sa,{tooltip:"Benutzer deaktivieren",icon:"mdi-account-off",color:"error",disabled:!ve.isActive,onClick:dt(de=>V(ve._id),["stop"])},null,8,["disabled","onClick"])]),_:1},8,["items","loading","sort-by","items-per-page"])]),_:1}),e(te,{modelValue:s.value,"onUpdate:modelValue":H[8]||(H[8]=ve=>s.value=ve),"max-width":"500"},{default:t(()=>[e(F,null,{default:t(()=>[e(L,null,{default:t(()=>[n(v(f.value?"Benutzer bearbeiten":"Neuer Benutzer"),1)]),_:1}),e(j,null,{default:t(()=>[e(A,{modelValue:_.value.firstName,"onUpdate:modelValue":H[2]||(H[2]=ve=>_.value.firstName=ve),label:"Vorname",class:"mb-3"},null,8,["modelValue"]),e(A,{modelValue:_.value.lastName,"onUpdate:modelValue":H[3]||(H[3]=ve=>_.value.lastName=ve),label:"Nachname",class:"mb-3"},null,8,["modelValue"]),e(A,{modelValue:_.value.email,"onUpdate:modelValue":H[4]||(H[4]=ve=>_.value.email=ve),label:"E-Mail",type:"email",disabled:f.value,class:"mb-3"},null,8,["modelValue","disabled"]),f.value?U("",!0):(o(),N(A,{key:0,modelValue:_.value.password,"onUpdate:modelValue":H[5]||(H[5]=ve=>_.value.password=ve),label:"Passwort",type:"password",class:"mb-3"},null,8,["modelValue"])),a("div",yc,[H[18]||(H[18]=a("div",{class:"text-body-2 text-medium-emphasis mb-2"},"Rolle",-1)),e(z,{modelValue:_.value.role,"onUpdate:modelValue":H[6]||(H[6]=ve=>_.value.role=ve),mandatory:"",color:"primary",variant:"outlined"},{default:t(()=>[e(O,{value:"admin"},{default:t(()=>[...H[15]||(H[15]=[n("Admin",-1)])]),_:1}),e(O,{value:"editor"},{default:t(()=>[...H[16]||(H[16]=[n("Editor",-1)])]),_:1}),e(O,{value:"viewer"},{default:t(()=>[...H[17]||(H[17]=[n("Viewer",-1)])]),_:1})]),_:1},8,["modelValue"])])]),_:1}),e(Q,null,{default:t(()=>[e(J),e(O,{variant:"text",onClick:H[7]||(H[7]=ve=>s.value=!1)},{default:t(()=>[...H[19]||(H[19]=[n("Abbrechen",-1)])]),_:1}),e(O,{color:"primary",onClick:R},{default:t(()=>[n(v(f.value?"Speichern":"Erstellen"),1)]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(te,{modelValue:m.value,"onUpdate:modelValue":H[10]||(H[10]=ve=>m.value=ve),"max-width":"400"},{default:t(()=>[e(F,null,{default:t(()=>[e(L,null,{default:t(()=>[...H[20]||(H[20]=[n("Benutzer deaktivieren?",-1)])]),_:1}),e(j,null,{default:t(()=>[...H[21]||(H[21]=[n("Der Benutzer wird deaktiviert und kann sich nicht mehr anmelden.",-1)])]),_:1}),e(Q,null,{default:t(()=>[e(J),e(O,{variant:"text",onClick:H[9]||(H[9]=ve=>m.value=!1)},{default:t(()=>[...H[22]||(H[22]=[n("Abbrechen",-1)])]),_:1}),e(O,{color:"error",onClick:M},{default:t(()=>[...H[23]||(H[23]=[n("Deaktivieren",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(te,{modelValue:u.value,"onUpdate:modelValue":H[12]||(H[12]=ve=>u.value=ve),"max-width":"400"},{default:t(()=>[e(F,null,{default:t(()=>[e(L,null,{default:t(()=>[...H[24]||(H[24]=[n("Passwort zurücksetzen",-1)])]),_:1}),e(j,null,{default:t(()=>[...H[25]||(H[25]=[n(" Der Benutzer erhält eine E-Mail mit einem Link zum Zurücksetzen des Passworts. ",-1)])]),_:1}),e(Q,null,{default:t(()=>[e(J),e(O,{variant:"text",onClick:H[11]||(H[11]=ve=>u.value=!1)},{default:t(()=>[...H[26]||(H[26]=[n("Abbrechen",-1)])]),_:1}),e(O,{color:"primary",onClick:T},{default:t(()=>[...H[27]||(H[27]=[n("Reset-Link senden",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}}),v6=Object.freeze(Object.defineProperty({__proto__:null,default:_c},Symbol.toStringTag,{value:"Module"})),kc={class:"d-flex align-center justify-space-between mb-6"},hc={class:"d-flex align-center ga-2"},xc=["onClick"],wc={class:"text-caption text-medium-emphasis"},Sc={class:"d-flex justify-end"},$c=Ae({__name:"ContentListView",setup(r){const $=xt(),d=y(!1),c=y(null),s=y([]),m=y(0),u=y(!1),f=y(!1),p=y(null),_=qe("content_filter_type",""),k=qe("content_filter_status",""),i=y(""),g=qe("content_only_mine",!1);let x=null;const w=y(1),b=qe("content_items_per_page",20),I=qe("content_sort",[]),V=[{title:"Titel",key:"title",sortable:!0},{title:"Typ",key:"type",sortable:!0,width:"160px"},{title:"Status",key:"status",sortable:!0,width:"150px"},{title:"Erstellt",key:"createdAt",sortable:!0,width:"130px"},{title:"Autor",key:"createdBy",sortable:!1,width:80,align:"center"},{title:"Geändert",key:"updatedBy",sortable:!1,width:80,align:"center"},{title:"Aktionen",key:"actions",sortable:!1,width:"120px",align:"end"}],E=[{title:"Alle Typen",value:""},...Object.entries(ya).map(([A,z])=>({title:z,value:A}))],R=[{title:"Alle Status",value:""},...Object.entries(va).map(([A,z])=>({title:z,value:A}))];function M(A){return!A.lockedBy||!A.lockHeartbeatAt?!1:Date.now()-new Date(A.lockHeartbeatAt).getTime()<90*1e3}function T(A){return new Date(A).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}function D(A){return{"blog-post":"primary","landing-page":"secondary","case-study":"info",whitepaper:"warning","social-media":"success",newsletter:"error"}[A]||"default"}function H(A){return{entwurf:"default","in-review":"warning",freigegeben:"info",veroeffentlicht:"success",archiviert:"error"}[A]||"default"}async function O(){var J,Q,te;d.value=!0,c.value=null;const A=b.value>0?b.value:100,z=new URLSearchParams({page:String(w.value),limit:String(A)});_.value&&z.append("type",_.value),k.value&&z.append("status",k.value),i.value.trim()&&z.append("search",i.value.trim()),g.value&&z.append("onlyMine","true"),I.value.length>0&&(z.append("sortBy",I.value[0].key),z.append("sortOrder",I.value[0].order));const j=await re.get(`/content?${z.toString()}`);j.success?(s.value=((J=j.data)==null?void 0:J.items)??[],m.value=((te=(Q=j.data)==null?void 0:Q.pagination)==null?void 0:te.total)??0,ue.debug("ADMIN","Content list loaded",{total:m.value})):(c.value="Fehler beim Laden der Inhalte.",ue.error("ADMIN","Content list loading failed",j.error)),d.value=!1}function S(){x&&clearTimeout(x),x=setTimeout(()=>{w.value=1,O()},400)}function B(){w.value=1,O()}function G(A){w.value=A.page,b.value=A.itemsPerPage,A.sortBy&&(I.value=A.sortBy),O()}async function W(A,z){const j=await re.put(`/content/${A._id}`,{status:z});j.success?(ue.info("ADMIN","Content status changed",{id:A._id,status:z}),O()):ue.error("ADMIN","Content status change failed",{id:A._id,status:z,error:j.error})}function F(A){p.value=A,u.value=!0}async function L(){if(!p.value)return;f.value=!0;const A=await re.delete(`/content/${p.value._id}`);A.success?(ue.info("ADMIN","Content deleted",{id:p.value._id}),u.value=!1,p.value=null,O()):ue.error("ADMIN","Content delete failed",{id:p.value._id,error:A.error}),f.value=!1}return Ze([_,k,g],B),rt(()=>O()),(A,z)=>{const j=l("v-chip"),J=l("v-btn"),Q=l("v-alert"),te=l("v-select"),ve=l("v-col"),de=l("v-text-field"),Z=l("v-row"),ce=l("v-card-text"),oe=l("v-card"),pe=l("v-list-item"),_e=l("v-list"),q=l("v-menu"),C=l("v-tooltip"),ae=l("v-icon"),X=l("v-data-table-server"),ie=l("v-card-title"),fe=l("v-spacer"),Se=l("v-card-actions"),me=l("v-dialog"),ee=l("v-container");return o(),N(ee,{fluid:"",class:"pa-6"},{default:t(()=>[a("div",kc,[z[11]||(z[11]=a("h1",{class:"text-h4 font-weight-bold"},"Content-Verwaltung",-1)),a("div",hc,[e(j,{color:P(g)?"primary":"",variant:P(g)?"flat":"outlined","prepend-icon":"mdi-account-filter",onClick:z[0]||(z[0]=Y=>g.value=!P(g))},{default:t(()=>[...z[9]||(z[9]=[n(" Nur meine ",-1)])]),_:1},8,["color","variant"]),e(J,{color:"primary","prepend-icon":"mdi-plus",onClick:z[1]||(z[1]=Y=>P($).push("/admin/content/new"))},{default:t(()=>[...z[10]||(z[10]=[n(" Neuer Inhalt ",-1)])]),_:1})])]),c.value?(o(),N(Q,{key:0,type:"error",variant:"tonal",class:"mb-4",text:c.value,closable:"","onClick:close":z[2]||(z[2]=Y=>c.value=null)},null,8,["text"])):U("",!0),e(oe,{rounded:"lg",class:"mb-4"},{default:t(()=>[e(ce,{class:"pa-4"},{default:t(()=>[e(Z,{dense:""},{default:t(()=>[e(ve,{cols:"12",sm:"4"},{default:t(()=>[e(te,{modelValue:P(_),"onUpdate:modelValue":z[3]||(z[3]=Y=>ot(_)?_.value=Y:null),items:E,"item-title":"title","item-value":"value",label:"Typ",density:"compact",variant:"outlined","hide-details":""},null,8,["modelValue"])]),_:1}),e(ve,{cols:"12",sm:"4"},{default:t(()=>[e(te,{modelValue:P(k),"onUpdate:modelValue":z[4]||(z[4]=Y=>ot(k)?k.value=Y:null),items:R,"item-title":"title","item-value":"value",label:"Status",density:"compact",variant:"outlined","hide-details":""},null,8,["modelValue"])]),_:1}),e(ve,{cols:"12",sm:"4"},{default:t(()=>[e(de,{modelValue:i.value,"onUpdate:modelValue":z[5]||(z[5]=Y=>i.value=Y),label:"Suche","prepend-inner-icon":"mdi-magnify",density:"compact",variant:"outlined","hide-details":"",clearable:"",onInput:S,"onClick:clear":z[6]||(z[6]=()=>{i.value="",w.value=1,O()})},null,8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1}),e(oe,{rounded:"lg"},{default:t(()=>[e(X,{headers:V,items:s.value,"items-length":m.value,loading:d.value,page:w.value,"items-per-page":P(b),"sort-by":P(I),"items-per-page-text":"Einträge pro Seite","loading-text":"Lade Inhalte...","no-data-text":"Keine Inhalte gefunden.","onUpdate:options":G},{"item.title":t(({item:Y})=>[a("span",{class:"content-list__title",onClick:K=>P($).push(`/admin/content/${Y._id}`)},v(Y.title||"(Kein Titel)"),9,xc)]),"item.type":t(({item:Y})=>[e(j,{color:D(Y.type),size:"small",variant:"tonal"},{default:t(()=>[n(v(P(ya)[Y.type]||Y.type),1)]),_:2},1032,["color"])]),"item.status":t(({item:Y})=>[e(q,null,{activator:t(({props:K})=>[e(j,Vt(K,{color:H(Y.status),size:"small",variant:"tonal","append-icon":"mdi-chevron-down",class:"cursor-pointer"}),{default:t(()=>[n(v(P(va)[Y.status]||Y.status),1)]),_:2},1040,["color"])]),default:t(()=>[e(_e,{density:"compact","min-width":"180"},{default:t(()=>[(o(!0),h(be,null,Pe(P(va),(K,le)=>(o(),N(pe,{key:le,title:K,disabled:Y.status===le,onClick:ne=>W(Y,le)},null,8,["title","disabled","onClick"]))),128))]),_:2},1024)]),_:2},1024)]),"item.createdAt":t(({item:Y})=>[a("span",wc,v(T(Y.createdAt)),1)]),"item.createdBy":t(({item:Y})=>{var K,le,ne;return[e(gt,{"user-id":((K=Y.createdBy)==null?void 0:K._id)??Y.createdBy??null,populated:(le=Y.createdBy)!=null&&le.firstName?Y.createdBy:null,locked:M(Y),"locked-by":(ne=Y.lockedBy)!=null&&ne.firstName?Y.lockedBy:null},null,8,["user-id","populated","locked","locked-by"])]}),"item.updatedBy":t(({item:Y})=>{var K,le,ne;return[e(gt,{"user-id":((K=Y.updatedBy)==null?void 0:K._id)??Y.updatedBy??null,populated:(le=Y.updatedBy)!=null&&le.firstName?Y.updatedBy:null,locked:M(Y),"locked-by":(ne=Y.lockedBy)!=null&&ne.firstName?Y.lockedBy:null},null,8,["user-id","populated","locked","locked-by"])]}),"item.actions":t(({item:Y})=>[a("div",Sc,[e(J,{icon:"",variant:"text",size:"small",color:"primary",to:`/admin/content/${Y._id}`,"aria-label":"Bearbeiten"},{default:t(()=>[e(C,{activator:"parent",location:"bottom"},{default:t(()=>[...z[12]||(z[12]=[n("Bearbeiten",-1)])]),_:1}),e(ae,null,{default:t(()=>[...z[13]||(z[13]=[n("mdi-pencil",-1)])]),_:1})]),_:1},8,["to"]),e(J,{icon:"",variant:"text",size:"small",color:"error","aria-label":"Löschen",onClick:K=>F(Y)},{default:t(()=>[e(C,{activator:"parent",location:"bottom"},{default:t(()=>[...z[14]||(z[14]=[n("Löschen",-1)])]),_:1}),e(ae,null,{default:t(()=>[...z[15]||(z[15]=[n("mdi-delete-outline",-1)])]),_:1})]),_:1},8,["onClick"])])]),_:1},8,["items","items-length","loading","page","items-per-page","sort-by"])]),_:1}),e(me,{modelValue:u.value,"onUpdate:modelValue":z[8]||(z[8]=Y=>u.value=Y),"max-width":"440"},{default:t(()=>[e(oe,{rounded:"lg"},{default:t(()=>[e(ie,{class:"text-body-1 font-weight-semibold pa-6 pb-2"},{default:t(()=>[...z[16]||(z[16]=[n(" Inhalt löschen ",-1)])]),_:1}),e(ce,{class:"pa-6 pt-2"},{default:t(()=>{var Y;return[z[17]||(z[17]=n(" Soll ",-1)),a("strong",null,v(((Y=p.value)==null?void 0:Y.title)||"dieser Inhalt"),1),z[18]||(z[18]=n(" wirklich unwiderruflich gelöscht werden? ",-1))]}),_:1}),e(Se,{class:"pa-6 pt-0"},{default:t(()=>[e(fe),e(J,{variant:"text",disabled:f.value,onClick:z[7]||(z[7]=Y=>u.value=!1)},{default:t(()=>[...z[19]||(z[19]=[n(" Abbrechen ",-1)])]),_:1},8,["disabled"]),e(J,{color:"error",variant:"flat",loading:f.value,onClick:L},{default:t(()=>[...z[20]||(z[20]=[n(" Löschen ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1})}}}),Cc=Me($c,[["__scopeId","data-v-17afde25"]]),p6=Object.freeze(Object.defineProperty({__proto__:null,default:Cc},Symbol.toStringTag,{value:"Module"})),Vc={class:"d-flex align-center ga-4 mb-2"},Ac={class:"text-h4 font-weight-bold"},Ic={key:0,class:"d-flex align-center ga-2 text-caption text-medium-emphasis mb-6"},Pc={key:3,class:"d-flex justify-center py-16"},zc={class:"d-flex align-center justify-space-between mb-2"},Dc={key:0},Tc={key:0,class:"mb-2"},Lc={class:"text-caption"},Ec={key:1,class:"d-flex align-center ga-2 mb-4"},Mc=Ae({__name:"ContentEditView",setup(r){const $=xt(),d=Ut(),c=se(()=>d.params.id==="new"||d.name==="admin-content-new"),s=se(()=>c.value?null:d.params.id),{isLocked:m,isLockedByMe:u,lockedBy:f,lockedAt:p,isLockTakenOver:_,takenOverBy:k,takeOverLock:i}=sa("Content",s),g=se(()=>m.value&&!u.value||_.value),x=y(!1),w=y(!1),b=y(null),I=y(!1),V=y(""),E=y(""),R=y("blog-post"),M=y(""),T=y(""),D=y([]),H=y("entwurf"),O=y(""),S=y(!1),B=y(""),G=y(""),W=y(""),F=y(!1),L=y(""),A=y([]),z=y(null),j=y(null),J=y(null);let Q=!1;const te=y(!1),ve=y(""),de=y(""),Z=y(!1),ce=y(null),oe=y([]),pe=y(!1),_e=Object.entries(ya).map(([le,ne])=>({title:ne,value:le})),q=Object.entries(va).map(([le,ne])=>({title:ne,value:le})),C=se(()=>oe.value.map(le=>({title:`${cl[le.provider]||le.provider} - ${le.name}`,value:le._id})));function ae(le){return le?typeof le=="string"?le:le._id??null:null}function X(le){return!le||typeof le=="string"?null:le.firstName?le:null}function ie(le){return le.toLowerCase().trim().replace(/[äöüß]/g,ne=>({ä:"ae",ö:"oe",ü:"ue",ß:"ss"})[ne]??ne).replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")}function fe(le){return new Date(le).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}Ze(V,le=>{Q||(E.value=ie(le))});async function Se(){var ne,Ce,ke,xe,Ne;if(c.value)return;x.value=!0,b.value=null;const le=await re.get(`/content/${s.value}`);if(!le.success)b.value="Fehler beim Laden des Inhalts.",ue.error("ADMIN","Content load failed",{id:s.value,error:le.error});else{const Ie=le.data;V.value=Ie.title,E.value=Ie.slug,R.value=Ie.type,M.value=Ie.content,T.value=Ie.excerpt,D.value=Ie.tags??[],H.value=Ie.status,O.value=Ie.category??"",B.value=((ne=Ie.seo)==null?void 0:ne.metaTitle)??"",G.value=((Ce=Ie.seo)==null?void 0:Ce.metaDescription)??"",W.value=((ke=Ie.seo)==null?void 0:ke.ogImage)??"",L.value=((xe=Ie.seo)==null?void 0:xe.canonicalUrl)??"",A.value=((Ne=Ie.seo)==null?void 0:Ne.keywords)??[],z.value=Ie.createdAt;const Ue=Ie;j.value=Ue.createdBy??null,J.value=Ue.updatedBy??null,Q=!0,ue.debug("ADMIN","Content loaded",{id:s.value})}x.value=!1}async function me(){if(g.value){ue.warn("ADMIN","Speichern blockiert - kein Lock-Owner");return}w.value=!0,I.value=!1,b.value=null;const le={title:V.value,slug:E.value,type:R.value,content:M.value,excerpt:T.value,tags:D.value,category:O.value,seo:{metaTitle:B.value,metaDescription:G.value,ogImage:W.value,canonicalUrl:L.value,keywords:A.value}};let ne;if(c.value)ne=await re.post("/content",le);else{const Ce={...le,status:H.value};ne=await re.put(`/content/${s.value}`,Ce)}if(!ne.success)b.value="Fehler beim Speichern des Inhalts.",ue.error("ADMIN","Content save failed",{id:s.value,error:ne.error});else{if(I.value=!0,ue.info("ADMIN","Content saved",{id:s.value,isNew:c.value}),c.value){const Ce=ne.data;$.replace(`/admin/content/${Ce._id}`)}setTimeout(()=>{I.value=!1},3e3)}w.value=!1}async function ee(){pe.value=!0;const le=await re.get("/gpt-settings?isActive=true");if(le.success&&(oe.value=le.data.data??[],oe.value.length>0)){const ne=oe.value.find(Ce=>Ce.isDefault)??oe.value[0];de.value=ne._id}pe.value=!1}async function Y(){if(!ve.value.trim()||!de.value)return;Z.value=!0,ce.value=null;const le=await re.post("/content/generate",{topic:ve.value,settingsId:de.value,type:R.value});le.success?(M.value=le.data.content??"",te.value=!1,ve.value=""):(ce.value="KI-Generierung fehlgeschlagen.",ue.error("ADMIN","AI content generation failed",le.error)),Z.value=!1}function K(){if(g.value){ue.warn("ADMIN","KI-Dialog blockiert - kein Lock-Owner");return}ce.value=null,te.value=!0,oe.value.length===0&&ee()}return rt(()=>Se()),(le,ne)=>{const Ce=l("v-tooltip"),ke=l("v-icon"),xe=l("v-btn"),Ne=l("v-alert"),Ie=l("v-progress-circular"),Ue=l("v-text-field"),Te=l("v-select"),ye=l("v-textarea"),Je=l("v-combobox"),Ke=l("v-card-text"),$e=l("v-card"),Ee=l("v-card-title"),lt=l("v-divider"),ut=l("v-expand-transition"),Ve=l("v-col"),Le=l("v-row"),Ye=l("v-skeleton-loader"),ct=l("v-spacer"),Fe=l("v-card-actions"),Xe=l("v-dialog"),mt=l("v-container");return o(),N(mt,{fluid:"",class:"pa-6"},{default:t(()=>[a("div",Vc,[e(xe,{icon:"",variant:"text","aria-label":"Zurück zur Liste",onClick:ne[0]||(ne[0]=nt=>P($).push("/admin/content"))},{default:t(()=>[e(Ce,{activator:"parent",location:"bottom"},{default:t(()=>[...ne[23]||(ne[23]=[n("Zurück zur Liste",-1)])]),_:1}),e(ke,null,{default:t(()=>[...ne[24]||(ne[24]=[n("mdi-arrow-left",-1)])]),_:1})]),_:1}),a("h1",Ac,v(c.value?"Neuer Inhalt":"Inhalt bearbeiten"),1)]),!c.value&&s.value?(o(),h("div",Ic,[ne[25]||(ne[25]=a("span",null,"Erstellt:",-1)),e(gt,{"user-id":ae(j.value),populated:X(j.value),size:24},null,8,["user-id","populated"]),ne[26]||(ne[26]=a("span",{class:"mx-1"},"·",-1)),ne[27]||(ne[27]=a("span",null,"Geändert:",-1)),e(gt,{"user-id":ae(J.value),populated:X(J.value),size:24},null,8,["user-id","populated"])])):U("",!0),b.value?(o(),N(Ne,{key:1,type:"error",variant:"tonal",class:"mb-4",text:b.value,closable:"","onClick:close":ne[1]||(ne[1]=nt=>b.value=null)},null,8,["text"])):U("",!0),I.value?(o(),N(Ne,{key:2,type:"success",variant:"tonal",class:"mb-4",text:"Inhalt erfolgreich gespeichert."})):U("",!0),e(ia,{"is-locked":P(m),"is-locked-by-me":P(u),"locked-by":P(f),"locked-at":P(p),"is-lock-taken-over":P(_),"taken-over-by":P(k),"on-take-over":P(i)},null,8,["is-locked","is-locked-by-me","locked-by","locked-at","is-lock-taken-over","taken-over-by","on-take-over"]),x.value?(o(),h("div",Pc,[e(Ie,{indeterminate:"",color:"primary",size:"48"})])):(o(),N(Le,{key:4},{default:t(()=>[e(Ve,{cols:"12",lg:"8"},{default:t(()=>[e($e,{rounded:"lg",class:"mb-4"},{default:t(()=>[e(Ke,{class:"pa-6"},{default:t(()=>[e(Ue,{modelValue:V.value,"onUpdate:modelValue":ne[2]||(ne[2]=nt=>V.value=nt),label:"Titel",variant:"outlined",class:"mb-4","hide-details":"auto",disabled:g.value},null,8,["modelValue","disabled"]),e(Ue,{modelValue:E.value,"onUpdate:modelValue":ne[3]||(ne[3]=nt=>E.value=nt),label:"URL-Slug",variant:"outlined","prepend-inner-icon":"mdi-link",class:"mb-4","hide-details":"auto",disabled:g.value,onInput:ne[4]||(ne[4]=nt=>ot(Q)?Q.value=!0:Q=!0)},null,8,["modelValue","disabled"]),e(Te,{modelValue:R.value,"onUpdate:modelValue":ne[5]||(ne[5]=nt=>R.value=nt),items:P(_e),"item-title":"title","item-value":"value",label:"Inhaltstyp",variant:"outlined",class:"mb-4","hide-details":"auto",disabled:g.value},null,8,["modelValue","items","disabled"]),a("div",zc,[ne[29]||(ne[29]=a("label",{class:"text-body-2 font-weight-medium"},"Inhalt",-1)),e(xe,{variant:"outlined",color:"primary",size:"small","prepend-icon":"mdi-robot",disabled:g.value,onClick:K},{default:t(()=>[...ne[28]||(ne[28]=[n(" Mit KI generieren ",-1)])]),_:1},8,["disabled"])]),e(ye,{modelValue:M.value,"onUpdate:modelValue":ne[6]||(ne[6]=nt=>M.value=nt),variant:"outlined",rows:"16","auto-grow":"",class:"mb-4","hide-details":"auto",placeholder:"Inhalt hier eingeben oder mit KI generieren...",disabled:g.value},null,8,["modelValue","disabled"]),e(ye,{modelValue:T.value,"onUpdate:modelValue":ne[7]||(ne[7]=nt=>T.value=nt),label:"Zusammenfassung (Excerpt)",variant:"outlined",rows:"3",class:"mb-4","hide-details":"auto",disabled:g.value},null,8,["modelValue","disabled"]),e(Je,{modelValue:D.value,"onUpdate:modelValue":ne[8]||(ne[8]=nt=>D.value=nt),label:"Tags",variant:"outlined",multiple:"",chips:"","closable-chips":"","hide-details":"auto",disabled:g.value},null,8,["modelValue","disabled"])]),_:1})]),_:1}),e($e,{rounded:"lg"},{default:t(()=>[e(Ee,{class:"d-flex align-center justify-space-between pa-4 cursor-pointer",onClick:ne[9]||(ne[9]=nt=>S.value=!S.value)},{default:t(()=>[ne[30]||(ne[30]=a("span",{class:"text-body-1 font-weight-semibold"},"SEO-Einstellungen",-1)),e(ke,null,{default:t(()=>[n(v(S.value?"mdi-chevron-up":"mdi-chevron-down"),1)]),_:1})]),_:1}),e(ut,null,{default:t(()=>[S.value?(o(),h("div",Dc,[e(lt),e(Ke,{class:"pa-6"},{default:t(()=>[e(Ue,{modelValue:B.value,"onUpdate:modelValue":ne[10]||(ne[10]=nt=>B.value=nt),label:"Meta-Titel",variant:"outlined",class:"mb-4","hide-details":"auto",counter:60,disabled:g.value},null,8,["modelValue","disabled"]),e(ye,{modelValue:G.value,"onUpdate:modelValue":ne[11]||(ne[11]=nt=>G.value=nt),label:"Meta-Beschreibung",variant:"outlined",rows:"3",class:"mb-4","hide-details":"auto",counter:160,disabled:g.value},null,8,["modelValue","disabled"]),e(Ue,{modelValue:W.value,"onUpdate:modelValue":ne[13]||(ne[13]=nt=>W.value=nt),label:"OG-Bild URL",variant:"outlined","prepend-inner-icon":"mdi-image-outline",class:"mb-4","hide-details":"auto",disabled:g.value},{"append-inner":t(()=>[e(xe,{size:"x-small",variant:"text",icon:"",disabled:g.value,"aria-label":"Bild aus Pool wählen oder generieren",onClick:ne[12]||(ne[12]=nt=>F.value=!0)},{default:t(()=>[e(Ce,{activator:"parent",location:"bottom"},{default:t(()=>[...ne[31]||(ne[31]=[n("Aus Bildpool wählen oder KI-generieren",-1)])]),_:1}),e(ke,{size:"18"},{default:t(()=>[...ne[32]||(ne[32]=[n("mdi-image-search-outline",-1)])]),_:1})]),_:1},8,["disabled"])]),_:1},8,["modelValue","disabled"]),F.value?(o(),N(vl,{key:0,modelValue:F.value,"onUpdate:modelValue":ne[14]||(ne[14]=nt=>F.value=nt),onSelect:ne[15]||(ne[15]=nt=>W.value=nt)},null,8,["modelValue"])):U("",!0),e(Ue,{modelValue:L.value,"onUpdate:modelValue":ne[16]||(ne[16]=nt=>L.value=nt),label:"Canonical URL",variant:"outlined","prepend-inner-icon":"mdi-link-variant",class:"mb-4","hide-details":"auto",placeholder:"https://basec.de/blog/mein-beitrag",disabled:g.value},null,8,["modelValue","disabled"]),e(Je,{modelValue:A.value,"onUpdate:modelValue":ne[17]||(ne[17]=nt=>A.value=nt),label:"Keywords",variant:"outlined",multiple:"",chips:"","closable-chips":"","hide-details":"auto",disabled:g.value},null,8,["modelValue","disabled"])]),_:1})])):U("",!0)]),_:1})]),_:1})]),_:1}),e(Ve,{cols:"12",lg:"4"},{default:t(()=>[e($e,{rounded:"lg",class:"mb-4"},{default:t(()=>[e(Ee,{class:"text-body-1 font-weight-semibold pa-4 pb-2"},{default:t(()=>[...ne[33]||(ne[33]=[n(" Veröffentlichung ",-1)])]),_:1}),e(lt),e(Ke,{class:"pa-4"},{default:t(()=>[e(Te,{modelValue:H.value,"onUpdate:modelValue":ne[18]||(ne[18]=nt=>H.value=nt),items:P(q),"item-title":"title","item-value":"value",label:"Status",variant:"outlined",density:"compact",class:"mb-4","hide-details":"",disabled:c.value||g.value},null,8,["modelValue","items","disabled"]),z.value?(o(),h("div",Tc,[ne[34]||(ne[34]=a("span",{class:"text-caption text-medium-emphasis"},"Erstellt am: ",-1)),a("span",Lc,v(fe(z.value)),1)])):U("",!0),j.value?(o(),h("div",Ec,[ne[35]||(ne[35]=a("span",{class:"text-caption text-medium-emphasis"},"Erstellt von:",-1)),e(gt,{"user-id":ae(j.value),populated:X(j.value),size:20},null,8,["user-id","populated"])])):U("",!0),e(xe,{color:"primary",block:"",loading:w.value,disabled:g.value,"prepend-icon":"mdi-content-save",onClick:me},{default:t(()=>[n(v(c.value?"Erstellen":"Speichern"),1)]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1})]),_:1})),e(Xe,{modelValue:te.value,"onUpdate:modelValue":ne[22]||(ne[22]=nt=>te.value=nt),"max-width":"540"},{default:t(()=>[e($e,{rounded:"lg"},{default:t(()=>[e(Ee,{class:"text-body-1 font-weight-semibold pa-6 pb-2"},{default:t(()=>[...ne[36]||(ne[36]=[n(" Inhalt mit KI generieren ",-1)])]),_:1}),e(lt),e(Ke,{class:"pa-6"},{default:t(()=>[ce.value?(o(),N(Ne,{key:0,type:"error",variant:"tonal",class:"mb-4",text:ce.value},null,8,["text"])):U("",!0),e(Ue,{modelValue:ve.value,"onUpdate:modelValue":ne[19]||(ne[19]=nt=>ve.value=nt),label:"Thema / Briefing",variant:"outlined",class:"mb-4","hide-details":"auto",placeholder:"z. B. 'Vorteile von KI-gestütztem Content-Marketing'"},null,8,["modelValue"]),!pe.value&&oe.value.length>0?(o(),N(Te,{key:1,modelValue:de.value,"onUpdate:modelValue":ne[20]||(ne[20]=nt=>de.value=nt),items:C.value,"item-title":"title","item-value":"value",label:"KI-Provider",variant:"outlined","hide-details":""},null,8,["modelValue","items"])):pe.value?(o(),N(Ye,{key:2,type:"text"})):(o(),N(Ne,{key:3,type:"warning",variant:"tonal",text:"Kein aktiver KI-Provider konfiguriert."}))]),_:1}),e(Fe,{class:"pa-6 pt-0"},{default:t(()=>[e(ct),e(xe,{variant:"text",disabled:Z.value,onClick:ne[21]||(ne[21]=nt=>te.value=!1)},{default:t(()=>[...ne[37]||(ne[37]=[n("Abbrechen",-1)])]),_:1},8,["disabled"]),e(xe,{color:"primary",variant:"flat",loading:Z.value,disabled:!ve.value.trim()||!de.value,"prepend-icon":"mdi-robot",onClick:Y},{default:t(()=>[...ne[38]||(ne[38]=[n(" Generieren ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1})}}}),Nc=Me(Mc,[["__scopeId","data-v-9d5e1e03"]]),f6=Object.freeze(Object.defineProperty({__proto__:null,default:Nc},Symbol.toStringTag,{value:"Module"})),Uc={class:"d-flex align-center justify-space-between"},Bc={class:"text-body-2 text-medium-emphasis d-block mt-1"},Fc={key:1,class:"d-flex justify-center pa-8"},Oc={key:2,class:"text-center pa-8 text-medium-emphasis"},Rc={class:"d-flex align-center justify-space-between mb-1"},Kc={class:"d-flex align-center ga-2"},jc={class:"text-subtitle-2 font-weight-bold"},qc={class:"d-flex ga-1"},Gc={class:"text-caption text-medium-emphasis"},Hc={key:0,class:"text-caption mt-1"},Wc={class:"text-caption text-medium-emphasis mt-1"},Zc={key:4,class:"d-flex justify-center mt-4"},Jc={class:"d-flex align-center justify-space-between"},Qc={class:"text-h6"},Yc={key:0},Xc={key:0,class:"d-flex justify-center pa-8"},em={key:1},tm={class:"text-caption text-medium-emphasis mb-3"},am={key:0},lm={key:0,class:"kb-version-dialog__diff"},nm={class:"kb-version-dialog__diff-marker"},om={key:1,class:"kb-version-dialog__content-pre"},sm=Ae({__name:"KnowledgeBaseVersionDialog",props:{modelValue:{type:Boolean},entryId:{},entryTitle:{}},emits:["update:modelValue"],setup(r,{emit:$}){const d=r,c=$,s=y([]),m=y(!1),u=y(null),f=y({page:1,limit:10,total:0,totalPages:1}),p=y(!1),_=y(!1),k=y(null),i=y(null),g=y(null),x=se(()=>{var G;if(!k.value)return[];const S=k.value.content||"",B=((G=i.value)==null?void 0:G.content)||g.value||S;return S===B?[]:Ul(S,B)}),w=y(!1),b=y(null),I=y(!1);async function V(){if(d.entryId){m.value=!0,u.value=null;try{const S=await re.get(`/knowledge-base/${d.entryId}/versions?page=${f.value.page}&limit=${f.value.limit}`);S.success&&S.data?(s.value=S.data.versions,f.value={page:S.data.page,limit:S.data.limit,total:S.data.total,totalPages:S.data.totalPages}):u.value=S.error||"Fehler beim Laden der Versionen"}catch{u.value="Netzwerkfehler beim Laden der Versionen"}finally{m.value=!1}}}async function E(S,B){_.value=!0,p.value=!0,g.value=null;try{if(!B){const[G,W]=await Promise.all([re.get(`/knowledge-base/versions/${S._id}`),d.entryId?re.get(`/knowledge-base/${d.entryId}`):null]);G.success&&G.data&&(k.value=G.data,i.value=null),W!=null&&W.success&&W.data&&(g.value=W.data.content)}}catch{u.value="Fehler beim Laden der Diff-Daten",p.value=!1}finally{_.value=!1}}function R(S){b.value=S,w.value=!0}async function M(){if(b.value){I.value=!0;try{const S=await re.post(`/knowledge-base/versions/${b.value._id}/rollback`);S.success?(await V(),w.value=!1,b.value=null):u.value=S.error||"Fehler beim Rollback"}catch{u.value="Netzwerkfehler beim Rollback"}finally{I.value=!1}}}function T(S){return S?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(S)):"-"}function D(S){return{"auto-rebuild":"Rebuild","hook-update":"Hook",manual:"Manuell"}[S]||S}function H(S){return{"auto-rebuild":"primary","hook-update":"info",manual:"success"}[S]||"default"}function O(){c("update:modelValue",!1)}return Ze(()=>d.modelValue,S=>{S&&d.entryId&&(f.value.page=1,V())}),(S,B)=>{const G=l("v-tooltip"),W=l("v-icon"),F=l("v-btn"),L=l("v-card-title"),A=l("v-divider"),z=l("v-alert"),j=l("v-progress-circular"),J=l("v-chip"),Q=l("v-card-text"),te=l("v-card"),ve=l("v-timeline-item"),de=l("v-timeline"),Z=l("v-pagination"),ce=l("v-dialog"),oe=l("v-spacer"),pe=l("v-card-actions");return o(),h(be,null,[e(ce,{"model-value":r.modelValue,"max-width":"800",scrollable:"","onUpdate:modelValue":B[2]||(B[2]=_e=>c("update:modelValue",_e))},{default:t(()=>[e(te,{class:"kb-version-dialog"},{default:t(()=>[e(L,{class:"pa-6 pb-4"},{default:t(()=>[a("div",Uc,[a("div",null,[B[7]||(B[7]=a("span",{class:"text-h6"},"Versionshistorie",-1)),a("span",Bc,v(r.entryTitle),1)]),e(F,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:O},{default:t(()=>[e(G,{activator:"parent",location:"bottom"},{default:t(()=>[...B[8]||(B[8]=[n("Schließen",-1)])]),_:1}),e(W,null,{default:t(()=>[...B[9]||(B[9]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(A),e(Q,{class:"pa-6"},{default:t(()=>[u.value?(o(),N(z,{key:0,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":B[0]||(B[0]=_e=>u.value=null)},{default:t(()=>[n(v(u.value),1)]),_:1})):U("",!0),m.value?(o(),h("div",Fc,[e(j,{indeterminate:"",color:"primary"})])):s.value.length===0?(o(),h("div",Oc," Noch keine Versionen vorhanden. ")):(o(),N(de,{key:3,density:"compact",side:"end"},{default:t(()=>[(o(!0),h(be,null,Pe(s.value,_e=>(o(),N(ve,{key:_e._id,"dot-color":H(_e.sourceType),size:"small"},{default:t(()=>[e(te,{variant:"outlined",class:"kb-version-dialog__version-card"},{default:t(()=>[e(Q,{class:"pa-3"},{default:t(()=>[a("div",Rc,[a("div",Kc,[a("span",jc,"v"+v(_e.version),1),e(J,{color:H(_e.sourceType),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(D(_e.sourceType)),1)]),_:2},1032,["color"]),_e.isRollback?(o(),N(J,{key:0,size:"x-small",color:"warning",variant:"tonal"},{default:t(()=>[n(" Rollback von v"+v(_e.rollbackFromVersion),1)]),_:2},1024)):U("",!0)]),a("div",qc,[e(F,{icon:"",variant:"text",size:"x-small",color:"info","aria-label":"Inhalt anzeigen",onClick:q=>E(_e)},{default:t(()=>[e(G,{activator:"parent",location:"bottom"},{default:t(()=>[...B[10]||(B[10]=[n("Inhalt anzeigen",-1)])]),_:1}),e(W,{size:"16"},{default:t(()=>[...B[11]||(B[11]=[n("mdi-eye-outline",-1)])]),_:1})]),_:1},8,["onClick"]),e(F,{icon:"",variant:"text",size:"x-small",color:"warning","aria-label":"Rollback auf diese Version",onClick:q=>R(_e)},{default:t(()=>[e(G,{activator:"parent",location:"bottom"},{default:t(()=>[...B[12]||(B[12]=[n("Rollback auf diese Version",-1)])]),_:1}),e(W,{size:"16"},{default:t(()=>[...B[13]||(B[13]=[n("mdi-backup-restore",-1)])]),_:1})]),_:1},8,["onClick"])])]),a("div",Gc,v(T(_e.changedAt))+" - "+v(_e.changedByName),1),_e.changeNote?(o(),h("div",Hc,v(_e.changeNote),1)):U("",!0),a("div",Wc,v((_e.tokenCount||0).toLocaleString("de-DE"))+" Token ",1)]),_:2},1024)]),_:2},1024)]),_:2},1032,["dot-color"]))),128))]),_:1})),f.value.totalPages>1?(o(),h("div",Zc,[e(Z,{modelValue:f.value.page,"onUpdate:modelValue":[B[1]||(B[1]=_e=>f.value.page=_e),V],length:f.value.totalPages,"total-visible":5},null,8,["modelValue","length"])])):U("",!0)]),_:1})]),_:1})]),_:1},8,["model-value"]),e(ce,{modelValue:p.value,"onUpdate:modelValue":B[4]||(B[4]=_e=>p.value=_e),"max-width":"900",scrollable:""},{default:t(()=>[e(te,{class:"kb-version-dialog"},{default:t(()=>[e(L,{class:"pa-6 pb-4"},{default:t(()=>{var _e;return[a("div",Jc,[a("span",Qc,[n(" Version "+v((_e=k.value)==null?void 0:_e.version)+" ",1),i.value?(o(),h("span",Yc," vs. Version "+v(i.value.version),1)):U("",!0)]),e(F,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:B[3]||(B[3]=q=>p.value=!1)},{default:t(()=>[e(G,{activator:"parent",location:"bottom"},{default:t(()=>[...B[14]||(B[14]=[n("Schließen",-1)])]),_:1}),e(W,null,{default:t(()=>[...B[15]||(B[15]=[n("mdi-close",-1)])]),_:1})]),_:1})])]}),_:1}),e(A),e(Q,{class:"pa-6"},{default:t(()=>[_.value?(o(),h("div",Xc,[e(j,{indeterminate:"",color:"primary"})])):k.value?(o(),h("div",em,[a("div",tm,[n(v(T(k.value.changedAt))+" - "+v(k.value.changedByName)+" ",1),k.value.changeNote?(o(),h("span",am," - "+v(k.value.changeNote),1)):U("",!0)]),x.value.length>0?(o(),h("div",lm,[(o(!0),h(be,null,Pe(x.value,(_e,q)=>(o(),h("div",{key:q,class:ft(["kb-version-dialog__diff-line",{"kb-version-dialog__diff-line--added":_e.added,"kb-version-dialog__diff-line--removed":_e.removed}])},[a("span",nm,v(_e.added?"+":_e.removed?"-":" "),1),a("span",null,v(_e.value),1)],2))),128))])):(o(),h("pre",om,v(k.value.content),1))])):U("",!0)]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(ce,{modelValue:w.value,"onUpdate:modelValue":B[6]||(B[6]=_e=>w.value=_e),"max-width":"440"},{default:t(()=>[e(te,null,{default:t(()=>[e(L,{class:"pa-6 pb-4 text-subtitle-1"},{default:t(()=>[...B[16]||(B[16]=[n("Rollback durchführen?",-1)])]),_:1}),e(Q,{class:"pa-6 pt-0 text-body-2 text-medium-emphasis"},{default:t(()=>{var _e;return[B[17]||(B[17]=n(" Der KB-Eintrag wird auf ",-1)),a("strong",null,"Version "+v((_e=b.value)==null?void 0:_e.version),1),B[18]||(B[18]=n(" zurückgesetzt. Der aktuelle Stand wird als neue Version gesichert. ",-1))]}),_:1}),e(pe,{class:"pa-4"},{default:t(()=>[e(oe),e(F,{variant:"text",onClick:B[5]||(B[5]=_e=>w.value=!1)},{default:t(()=>[...B[19]||(B[19]=[n("Abbrechen",-1)])]),_:1}),e(F,{color:"warning",variant:"elevated",loading:I.value,onClick:M},{default:t(()=>[...B[20]||(B[20]=[n(" Rollback ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"])],64)}}}),im=Me(sm,[["__scopeId","data-v-f6cff0e3"]]),rm={class:"knowledge-base-view"},dm={class:"knowledge-base-view__header"},um={class:"d-flex ga-2"},cm={class:"text-caption font-weight-medium"},mm={class:"text-h6 font-weight-bold"},vm={class:"text-h6 font-weight-bold"},pm={class:"text-body-2"},fm={class:"d-flex align-center justify-space-between"},gm={class:"text-subtitle-1 font-weight-semibold"},bm={class:"knowledge-base-view__title"},ym={class:"text-body-2 font-weight-medium"},_m={key:0,class:"text-caption text-medium-emphasis d-block"},km={class:"text-body-2 text-medium-emphasis"},hm={class:"text-body-2"},xm={class:"text-body-2 text-medium-emphasis"},wm={class:"d-flex justify-end ga-1"},Sm={key:1,class:"d-flex justify-center pa-4"},$m={class:"d-flex align-center justify-space-between"},Cm={class:"text-h6"},Vm=Ae({__name:"KnowledgeBaseView",setup(r){const $=y([]),d=y({page:1,limit:20,total:0,totalPages:1}),c=y(!1),s=y(null),m=y(null),u=y(!1),f=y(null),p=y(!1),_=y(null),k=y(""),i=qe("kb_filter_entry_type",""),g=y(""),x=qe("kb_filter_active",""),w=qe("knowledge_base_only_mine",!1);let b=null;const I=y(!1),V=y(null),E=y(!1),R=y(null),M=y(!1),T=wt({title:"",entryType:"",sourceUrl:"",category:"",tags:[],content:"",isActive:!0}),D=y(!1),H=y(null),O=y(!1),S=qe("kb_sort",[]),B=qe("kb_items_per_page",20),G=[{title:"Titel",key:"title",sortable:!0},{title:"Typ",key:"entryType",sortable:!0},{title:"Kategorie",key:"category",sortable:!0},{title:"Token",key:"tokenCount",sortable:!0,align:"end"},{title:"Version",key:"version",sortable:!0,align:"center"},{title:"Status",key:"isActive",sortable:!0},{title:"Erstellt",key:"createdBy",sortable:!1,width:80,align:"center"},{title:"Geändert",key:"updatedBy",sortable:!1,width:80,align:"center"},{title:"Aktualisiert",key:"updatedAt",sortable:!0},{title:"Aktionen",key:"actions",sortable:!1,align:"end"}],W=[{title:"Firmenprofil",value:"firmenprofil"},{title:"Themen-Cluster",value:"themen-cluster"},{title:"Manuell",value:"manual"},{title:"Landing Page",value:"landing-page"},{title:"E-Mail",value:"email"},{title:"Seiten",value:"seiten"}],F=[{title:"Alle Typen",value:""},...W],L=[{title:"Alle",value:""},{title:"Aktiv",value:"true"},{title:"Inaktiv",value:"false"}],A=[Y=>!!Y||"Titel ist erforderlich",Y=>Y.length>=3||"Mindestens 3 Zeichen"],z=[Y=>!!Y||"Typ ist erforderlich"],j=[Y=>!!Y||"Inhalt ist erforderlich"],J=se(()=>V.value?"Eintrag bearbeiten":"Neuer Eintrag"),Q=se({get:()=>!!f.value,set:Y=>{Y||(f.value=null)}});function te(Y){return{firmenprofil:"Firmenprofil","themen-cluster":"Themen-Cluster",manual:"Manuell","landing-page":"Landing Page",email:"E-Mail",seiten:"Seiten"}[Y]||Y}function ve(Y){return{firmenprofil:"accent","themen-cluster":"primary",manual:"success","landing-page":"info",email:"warning",seiten:"secondary"}[Y]||"default"}function de(Y){return Y?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(new Date(Y)):"-"}async function Z(){try{const Y=await re.get("/knowledge-base/meta");Y.success&&Y.data&&(m.value=Y.data)}catch{m.value=null}}let ce=null;function oe(){ce&&(clearInterval(ce),ce=null)}function pe(){var K;oe();const Y=((K=m.value)==null?void 0:K.lastFullRebuild)??null;ce=setInterval(async()=>{var ne;await Z();const le=((ne=m.value)==null?void 0:ne.lastFullRebuild)??null;le&&le!==Y&&(oe(),u.value=!1,f.value="Rebuild abgeschlossen.",await C(1))},5e3)}async function _e(){u.value=!0,f.value=null;try{const Y=await re.post("/knowledge-base/rebuild",{});Y.success?(f.value="Rebuild läuft ...",pe()):(f.value=Y.error||"Fehler beim Starten des Rebuilds",u.value=!1)}catch{f.value="Netzwerkfehler beim Starten des Rebuilds",u.value=!1}}function q(Y){_.value=Y._id,k.value=Y.title,p.value=!0}async function C(Y=1){c.value=!0,s.value=null;const K=new URLSearchParams;if(K.set("page",String(Y)),K.set("limit",String(B.value>0?B.value:20)),i.value&&K.set("entryType",i.value),g.value&&K.set("search",g.value),x.value&&K.set("isActive",x.value),w.value&&K.set("onlyMine","true"),S.value.length>0){const le=S.value[0];K.set("sortBy",le.key),K.set("sortOrder",le.order)}try{const le=await re.get(`/knowledge-base?${K.toString()}`);le.success&&le.data?($.value=le.data.items,d.value=le.data.pagination):s.value=le.error||"Fehler beim Laden der Wissensbasis"}catch{s.value="Netzwerkfehler beim Laden der Wissensbasis"}finally{c.value=!1}}Ze(g,()=>{b&&clearTimeout(b),b=setTimeout(()=>{C(1)},300)}),Ze([i,x,w],()=>{C(1)}),Ze(S,()=>{C(1)},{deep:!0}),Ze(B,()=>{C(1)});function ae(){V.value=null,Object.assign(T,{title:"",entryType:"manual",sourceUrl:"",category:"",tags:[],content:"",isActive:!0}),R.value=null,I.value=!0}function X(Y){V.value=Y._id,Object.assign(T,{title:Y.title,entryType:Y.entryType||"manual",sourceUrl:Y.sourceUrl||"",category:Y.category||"",tags:[...Y.tags||[]],content:Y.content,isActive:Y.isActive}),R.value=null,I.value=!0}function ie(){I.value=!1}async function fe(){if(!M.value)return;E.value=!0,R.value=null;const Y={title:T.title,sourceType:"manual",entryType:T.entryType,sourceUrl:T.sourceUrl||void 0,category:T.category||void 0,tags:T.tags,content:T.content,isActive:T.isActive};try{let K;V.value?K=await re.put(`/knowledge-base/${V.value}`,Y):K=await re.post("/knowledge-base",Y),K.success?(await C(d.value.page),ie()):R.value=K.error||"Fehler beim Speichern"}catch{R.value="Netzwerkfehler beim Speichern"}finally{E.value=!1}}async function Se(Y){try{const K=await re.put(`/knowledge-base/${Y._id}`,{isActive:!Y.isActive});K.success?await C(d.value.page):s.value=K.error||"Fehler beim Aktualisieren"}catch{s.value="Netzwerkfehler beim Aktualisieren"}}function me(Y){H.value=Y,D.value=!0}async function ee(){if(H.value){O.value=!0;try{const Y=await re.delete(`/knowledge-base/${H.value._id}`);Y.success?(D.value=!1,await Promise.all([C(d.value.page),Z()]),$.value.length===0&&d.value.page>1&&await C(d.value.page-1)):(s.value=Y.error||"Fehler beim Löschen",D.value=!1)}catch{s.value="Netzwerkfehler beim Löschen",D.value=!1}finally{O.value=!1,H.value=null}}}return rt(()=>{C(),Z()}),da(()=>{oe()}),(Y,K)=>{const le=l("v-btn"),ne=l("v-progress-linear"),Ce=l("v-col"),ke=l("v-row"),xe=l("v-card-text"),Ne=l("v-card"),Ie=l("v-alert"),Ue=l("v-select"),Te=l("v-text-field"),ye=l("v-chip"),Je=l("v-tooltip"),Ke=l("v-icon"),$e=l("v-card-title"),Ee=l("v-data-table"),lt=l("v-divider"),ut=l("v-pagination"),Ve=l("v-combobox"),Le=l("v-textarea"),Ye=l("v-switch"),ct=l("v-form"),Fe=l("v-spacer"),Xe=l("v-card-actions"),mt=l("v-dialog"),nt=l("v-snackbar");return o(),h("div",rm,[a("div",dm,[K[25]||(K[25]=a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"Wissensbasis"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," KB-Einträge verwalten – Basis für KI-gestützte Content-Generierung ")],-1)),a("div",um,[e(le,{color:"accent",variant:"outlined","prepend-icon":"mdi-brain",loading:u.value,onClick:_e},{default:t(()=>[...K[23]||(K[23]=[n(" KB neu generieren ",-1)])]),_:1},8,["loading"]),e(le,{color:"primary","prepend-icon":"mdi-plus",onClick:ae},{default:t(()=>[...K[24]||(K[24]=[n(" Neuer Eintrag ",-1)])]),_:1})])]),m.value?(o(),N(Ne,{key:0,variant:"outlined",class:"knowledge-base-view__dashboard mb-4"},{default:t(()=>[e(xe,{class:"pa-4"},{default:t(()=>[e(ke,{align:"center",dense:""},{default:t(()=>[e(Ce,{cols:"12",md:"6"},{default:t(()=>[K[26]||(K[26]=a("div",{class:"text-caption text-medium-emphasis mb-1"}," Token-Budget ",-1)),e(ne,{"model-value":m.value.totalTokens,max:m.value.tokenBudget,color:m.value.totalTokens>m.value.tokenBudget*.9?"warning":"primary",height:"20",rounded:""},{default:t(()=>[a("span",cm,v(m.value.totalTokens.toLocaleString("de-DE"))+" / "+v(m.value.tokenBudget.toLocaleString("de-DE")),1)]),_:1},8,["model-value","max","color"])]),_:1}),e(Ce,{cols:"6",md:"2",class:"text-center"},{default:t(()=>[K[27]||(K[27]=a("div",{class:"text-caption text-medium-emphasis"},"Version",-1)),a("div",mm,v(m.value.version),1)]),_:1}),e(Ce,{cols:"6",md:"2",class:"text-center"},{default:t(()=>[K[28]||(K[28]=a("div",{class:"text-caption text-medium-emphasis"},"Einträge",-1)),a("div",vm,v(m.value.entryCount),1)]),_:1}),e(Ce,{cols:"12",md:"2",class:"text-center"},{default:t(()=>[K[29]||(K[29]=a("div",{class:"text-caption text-medium-emphasis"},"Letzter Rebuild",-1)),a("div",pm,v(m.value.lastFullRebuild?de(m.value.lastFullRebuild):"Noch nie"),1)]),_:1})]),_:1})]),_:1})]),_:1})):U("",!0),s.value?(o(),N(Ie,{key:1,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":K[0]||(K[0]=He=>s.value=null)},{default:t(()=>[n(v(s.value),1)]),_:1})):U("",!0),e(Ne,{variant:"outlined",class:"knowledge-base-view__filter mb-4"},{default:t(()=>[e(xe,{class:"pa-4"},{default:t(()=>[e(ke,{align:"center",dense:""},{default:t(()=>[e(Ce,{cols:"12",sm:"4",md:"3"},{default:t(()=>[e(Ue,{modelValue:P(i),"onUpdate:modelValue":K[1]||(K[1]=He=>ot(i)?i.value=He:null),label:"Typ",items:F,variant:"outlined",density:"compact","hide-details":"",clearable:""},null,8,["modelValue"])]),_:1}),e(Ce,{cols:"12",sm:"4",md:"2"},{default:t(()=>[e(Ue,{modelValue:P(x),"onUpdate:modelValue":K[2]||(K[2]=He=>ot(x)?x.value=He:null),label:"Status",items:L,variant:"outlined",density:"compact","hide-details":"",clearable:""},null,8,["modelValue"])]),_:1}),e(Ce,{cols:"12",sm:"4",md:"5"},{default:t(()=>[e(Te,{modelValue:g.value,"onUpdate:modelValue":K[3]||(K[3]=He=>g.value=He),label:"Suche","prepend-inner-icon":"mdi-magnify",variant:"outlined",density:"compact","hide-details":"",clearable:"",placeholder:"Titel oder Inhalt..."},null,8,["modelValue"])]),_:1}),e(Ce,{cols:"12",sm:"12",md:"2",class:"d-flex align-center"},{default:t(()=>[e(ye,{color:P(w)?"primary":"",variant:P(w)?"flat":"outlined","prepend-icon":"mdi-account-filter",onClick:K[4]||(K[4]=He=>w.value=!P(w)),class:"mr-2"},{default:t(()=>[...K[30]||(K[30]=[n(" Nur meine ",-1)])]),_:1},8,["color","variant"])]),_:1})]),_:1})]),_:1})]),_:1}),e(Ne,{variant:"outlined",class:"knowledge-base-view__table-card"},{default:t(()=>[e($e,{class:"pa-4 pb-2"},{default:t(()=>[a("div",fm,[a("span",gm,v(d.value.total)+" Einträge gesamt ",1),e(le,{icon:"",variant:"text",size:"small",loading:c.value,"aria-label":"Aktualisieren",onClick:K[5]||(K[5]=He=>C(d.value.page))},{default:t(()=>[e(Je,{activator:"parent",location:"bottom"},{default:t(()=>[...K[31]||(K[31]=[n("Aktualisieren",-1)])]),_:1}),e(Ke,null,{default:t(()=>[...K[32]||(K[32]=[n("mdi-refresh",-1)])]),_:1})]),_:1},8,["loading"])])]),_:1}),e(Ee,{headers:G,items:$.value,loading:c.value,"sort-by":P(S),"loading-text":"Wissensbasis wird geladen...","no-data-text":"Keine Einträge vorhanden","item-value":"_id",class:"knowledge-base-view__table","items-per-page":P(B),"onUpdate:itemsPerPage":K[6]||(K[6]=He=>ot(B)?B.value=He:null),"hide-default-footer":"","onUpdate:sortBy":K[7]||(K[7]=He=>S.value=He)},{"item.title":t(({item:He})=>[a("div",bm,[a("span",ym,v(He.title),1),He.sourceUrl?(o(),h("span",_m,v(He.sourceUrl),1)):U("",!0)])]),"item.entryType":t(({item:He})=>[e(ye,{color:ve(He.entryType),size:"small",variant:"tonal"},{default:t(()=>[n(v(te(He.entryType)),1)]),_:2},1032,["color"]),He.autoGenerated?(o(),N(ye,{key:0,size:"x-small",variant:"outlined",color:"accent",class:"ml-1"},{default:t(()=>[...K[33]||(K[33]=[n(" Auto ",-1)])]),_:1})):U("",!0)]),"item.tokenCount":t(({item:He})=>[a("span",km,v((He.tokenCount||0).toLocaleString("de-DE")),1)]),"item.version":t(({item:He})=>[a("span",hm,"v"+v(He.version||1),1)]),"item.isActive":t(({item:He})=>[e(ye,{color:He.isActive?"success":"default",size:"small",variant:"tonal"},{default:t(()=>[n(v(He.isActive?"Aktiv":"Inaktiv"),1)]),_:2},1032,["color"])]),"item.createdBy":t(({item:He})=>[e(gt,{"user-id":typeof He.createdBy=="object"&&He.createdBy?He.createdBy._id??null:He.createdBy??null,populated:typeof He.createdBy=="object"?He.createdBy:null},null,8,["user-id","populated"])]),"item.updatedBy":t(({item:He})=>[e(gt,{"user-id":typeof He.updatedBy=="object"&&He.updatedBy?He.updatedBy._id??null:He.updatedBy??null,populated:typeof He.updatedBy=="object"?He.updatedBy:null},null,8,["user-id","populated"])]),"item.updatedAt":t(({item:He})=>[a("span",xm,v(de(He.updatedAt)),1)]),"item.actions":t(({item:He})=>[a("div",wm,[e(le,{icon:"",variant:"text",size:"small",color:"info","aria-label":"Versionen",onClick:St=>q(He)},{default:t(()=>[e(Je,{activator:"parent",location:"bottom"},{default:t(()=>[...K[34]||(K[34]=[n("Versionen",-1)])]),_:1}),e(Ke,{size:"18"},{default:t(()=>[...K[35]||(K[35]=[n("mdi-history",-1)])]),_:1})]),_:1},8,["onClick"]),e(le,{icon:"",variant:"text",size:"small",color:He.isActive?"warning":"success","aria-label":He.isActive?"Deaktivieren":"Aktivieren",onClick:St=>Se(He)},{default:t(()=>[e(Je,{activator:"parent",location:"bottom"},{default:t(()=>[n(v(He.isActive?"Deaktivieren":"Aktivieren"),1)]),_:2},1024),e(Ke,{size:"18"},{default:t(()=>[n(v(He.isActive?"mdi-eye-off-outline":"mdi-eye-outline"),1)]),_:2},1024)]),_:2},1032,["color","aria-label","onClick"]),e(le,{icon:"",variant:"text",size:"small",color:"primary","aria-label":"Bearbeiten",onClick:St=>X(He)},{default:t(()=>[e(Je,{activator:"parent",location:"bottom"},{default:t(()=>[...K[36]||(K[36]=[n("Bearbeiten",-1)])]),_:1}),e(Ke,{size:"18"},{default:t(()=>[...K[37]||(K[37]=[n("mdi-pencil-outline",-1)])]),_:1})]),_:1},8,["onClick"]),e(le,{icon:"",variant:"text",size:"small",color:"error","aria-label":"Löschen",onClick:St=>me(He)},{default:t(()=>[e(Je,{activator:"parent",location:"bottom"},{default:t(()=>[...K[38]||(K[38]=[n("Löschen",-1)])]),_:1}),e(Ke,{size:"18"},{default:t(()=>[...K[39]||(K[39]=[n("mdi-trash-can-outline",-1)])]),_:1})]),_:1},8,["onClick"])])]),_:1},8,["items","loading","sort-by","items-per-page"]),d.value.totalPages>1?(o(),N(lt,{key:0})):U("",!0),d.value.totalPages>1?(o(),h("div",Sm,[e(ut,{"model-value":d.value.page,length:d.value.totalPages,"total-visible":7,"onUpdate:modelValue":K[8]||(K[8]=He=>C(He))},null,8,["model-value","length"])])):U("",!0)]),_:1}),e(mt,{modelValue:I.value,"onUpdate:modelValue":K[18]||(K[18]=He=>I.value=He),"max-width":"860",scrollable:""},{default:t(()=>[e(Ne,{class:"knowledge-base-view__dialog"},{default:t(()=>[e($e,{class:"pa-6 pb-4"},{default:t(()=>[a("div",$m,[a("span",Cm,v(J.value),1),e(le,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:ie},{default:t(()=>[e(Je,{activator:"parent",location:"bottom"},{default:t(()=>[...K[40]||(K[40]=[n("Schließen",-1)])]),_:1}),e(Ke,null,{default:t(()=>[...K[41]||(K[41]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(lt),e(xe,{class:"pa-6"},{default:t(()=>[R.value?(o(),N(Ie,{key:0,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":K[9]||(K[9]=He=>R.value=null)},{default:t(()=>[n(v(R.value),1)]),_:1})):U("",!0),e(ct,{modelValue:M.value,"onUpdate:modelValue":K[17]||(K[17]=He=>M.value=He),onSubmit:dt(fe,["prevent"])},{default:t(()=>[e(ke,null,{default:t(()=>[e(Ce,{cols:"12",md:"8"},{default:t(()=>[e(Te,{modelValue:T.title,"onUpdate:modelValue":K[10]||(K[10]=He=>T.title=He),label:"Titel",rules:A,placeholder:"z.B. NIS2-Compliance Grundlagen",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(Ce,{cols:"12",md:"4"},{default:t(()=>[e(Ue,{modelValue:T.entryType,"onUpdate:modelValue":K[11]||(K[11]=He=>T.entryType=He),label:"Typ",items:W,rules:z,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(Ce,{cols:"12",md:"8"},{default:t(()=>[e(Te,{modelValue:T.sourceUrl,"onUpdate:modelValue":K[12]||(K[12]=He=>T.sourceUrl=He),label:"Quell-URL (optional)",placeholder:"https://basec.de/...",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(Ce,{cols:"12",md:"4"},{default:t(()=>[e(Te,{modelValue:T.category,"onUpdate:modelValue":K[13]||(K[13]=He=>T.category=He),label:"Kategorie (optional)",placeholder:"z.B. Compliance",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(Ce,{cols:"12"},{default:t(()=>[e(Ve,{modelValue:T.tags,"onUpdate:modelValue":K[14]||(K[14]=He=>T.tags=He),label:"Tags (optional)",placeholder:"Tag eingeben und Enter drücken",variant:"outlined",density:"comfortable",multiple:"",chips:"","closable-chips":"","hide-no-data":""},null,8,["modelValue"])]),_:1}),e(Ce,{cols:"12"},{default:t(()=>[e(Le,{modelValue:T.content,"onUpdate:modelValue":K[15]||(K[15]=He=>T.content=He),label:"Inhalt",rules:j,placeholder:"Inhalt des KB-Eintrags (Plaintext)...",variant:"outlined",rows:"15","auto-grow":""},null,8,["modelValue"])]),_:1}),e(Ce,{cols:"12"},{default:t(()=>[e(Ye,{modelValue:T.isActive,"onUpdate:modelValue":K[16]||(K[16]=He=>T.isActive=He),label:"Eintrag aktiv (wird für KI-Kontext verwendet)",color:"primary",density:"compact","hide-details":""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1}),e(lt),e(Xe,{class:"pa-4"},{default:t(()=>[e(Fe),e(le,{variant:"text",onClick:ie},{default:t(()=>[...K[42]||(K[42]=[n("Abbrechen",-1)])]),_:1}),e(le,{color:"primary",variant:"elevated",loading:E.value,disabled:!M.value,onClick:fe},{default:t(()=>[...K[43]||(K[43]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(mt,{modelValue:D.value,"onUpdate:modelValue":K[20]||(K[20]=He=>D.value=He),"max-width":"440"},{default:t(()=>[e(Ne,null,{default:t(()=>[e($e,{class:"pa-6 pb-4 text-subtitle-1"},{default:t(()=>[...K[44]||(K[44]=[n("Eintrag löschen?",-1)])]),_:1}),e(xe,{class:"pa-6 pt-0 text-body-2 text-medium-emphasis"},{default:t(()=>{var He;return[a("strong",null,v((He=H.value)==null?void 0:He.title),1),K[45]||(K[45]=n(" wird dauerhaft aus der Wissensbasis gelöscht. Diese Aktion kann nicht rückgängig gemacht werden. ",-1))]}),_:1}),e(Xe,{class:"pa-4"},{default:t(()=>[e(Fe),e(le,{variant:"text",onClick:K[19]||(K[19]=He=>D.value=!1)},{default:t(()=>[...K[46]||(K[46]=[n("Abbrechen",-1)])]),_:1}),e(le,{color:"error",variant:"elevated",loading:O.value,onClick:ee},{default:t(()=>[...K[47]||(K[47]=[n(" Löschen ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(nt,{modelValue:Q.value,"onUpdate:modelValue":K[21]||(K[21]=He=>Q.value=He),timeout:5e3,color:"primary",location:"bottom"},{default:t(()=>[n(v(f.value),1)]),_:1},8,["modelValue"]),e(im,{modelValue:p.value,"onUpdate:modelValue":K[22]||(K[22]=He=>p.value=He),"entry-id":_.value,"entry-title":k.value},null,8,["modelValue","entry-id","entry-title"])])}}}),Am=Me(Vm,[["__scopeId","data-v-984e836d"]]),g6=Object.freeze(Object.defineProperty({__proto__:null,default:Am},Symbol.toStringTag,{value:"Module"})),Im={class:"content-calendar"},Pm={class:"content-calendar__controls mb-4"},zm={class:"d-flex align-center ga-2"},Dm={class:"text-subtitle-1 font-weight-semibold",style:{"min-width":"160px","text-align":"center"}},Tm={class:"d-flex align-center ga-3"},Lm={key:1,class:"d-flex justify-center pa-8"},Em={key:2,class:"content-calendar__grid-wrapper"},Mm={class:"content-calendar__weekdays"},Nm={class:"content-calendar__days"},Um={class:"content-calendar__day-number"},Bm={class:"content-calendar__day-posts"},Fm=["title"],Om={key:0,class:"content-calendar__post-more"},Rm=Ae({__name:"ContentCalendar",setup(r){const $=y([]),d=y(!1),c=y(null),s=y(""),m=y(new Date),u=se(()=>[{title:"Alle Pläne",value:""},...$.value.map(M=>({title:M.name,value:M._id}))]),f=se(()=>m.value.getFullYear()),p=se(()=>m.value.getMonth()),_=se(()=>new Intl.DateTimeFormat("de-DE",{month:"long",year:"numeric"}).format(m.value)),k=["Mo","Di","Mi","Do","Fr","Sa","So"];function i(M){const T=M.toISOString().substring(0,10),D=[];for(const H of $.value)if(!(s.value&&H._id!==s.value))for(const O of H.topics||[])O.suggestedDate===T&&D.push({planId:H._id,planName:H.name,title:O.title,status:O.status,hasPost:!!O.postId||!!O.postText});return D}const g=se(()=>{const M=f.value,T=p.value,D=new Date(M,T,1),H=new Date(M,T+1,0);let O=D.getDay();O=O===0?6:O-1;const S=[];for(let G=O-1;G>=0;G--){const W=new Date(M,T,-G);S.push({date:W,isCurrentMonth:!1,entries:[]})}for(let G=1;G<=H.getDate();G++){const W=new Date(M,T,G);S.push({date:W,isCurrentMonth:!0,entries:i(W)})}const B=42-S.length;for(let G=1;G<=B;G++){const W=new Date(M,T+1,G);S.push({date:W,isCurrentMonth:!1,entries:[]})}return S});function x(){m.value=new Date(f.value,p.value-1,1)}function w(){m.value=new Date(f.value,p.value+1,1)}function b(){m.value=new Date}function I(M){const T=new Date;return M.getDate()===T.getDate()&&M.getMonth()===T.getMonth()&&M.getFullYear()===T.getFullYear()}function V(M){return{suggested:"#748686",accepted:"#0AC9D4",generating:"#C9A063",drafted:"#66BB6A",published:"#66BB6A",skipped:"#CF6679"}[M.status]||"#748686"}function E(M,T=40){return M?M.length>T?M.substring(0,T)+"…":M:""}async function R(){d.value=!0,c.value=null;try{const M=await re.get("/content-plans");M.success&&M.data?$.value=M.data:c.value=M.error||"Fehler beim Laden der Content-Pläne"}catch{c.value="Netzwerkfehler beim Laden der Kalender-Daten"}finally{d.value=!1}}return rt(()=>{R()}),(M,T)=>{const D=l("v-tooltip"),H=l("v-icon"),O=l("v-btn"),S=l("v-select"),B=l("v-alert"),G=l("v-progress-circular");return o(),h("div",Im,[a("div",Pm,[a("div",zm,[e(O,{icon:"",variant:"text",size:"small","aria-label":"Vorheriger Monat",onClick:x},{default:t(()=>[e(D,{activator:"parent",location:"bottom"},{default:t(()=>[...T[2]||(T[2]=[n("Vorheriger Monat",-1)])]),_:1}),e(H,null,{default:t(()=>[...T[3]||(T[3]=[n("mdi-chevron-left",-1)])]),_:1})]),_:1}),a("span",Dm,v(_.value),1),e(O,{icon:"",variant:"text",size:"small","aria-label":"Nächster Monat",onClick:w},{default:t(()=>[e(D,{activator:"parent",location:"bottom"},{default:t(()=>[...T[4]||(T[4]=[n("Nächster Monat",-1)])]),_:1}),e(H,null,{default:t(()=>[...T[5]||(T[5]=[n("mdi-chevron-right",-1)])]),_:1})]),_:1}),e(O,{variant:"outlined",size:"small",onClick:b},{default:t(()=>[...T[6]||(T[6]=[n("Heute",-1)])]),_:1})]),a("div",Tm,[e(S,{modelValue:s.value,"onUpdate:modelValue":T[0]||(T[0]=W=>s.value=W),items:u.value,label:"Plan",variant:"outlined",density:"compact","hide-details":"",style:{"min-width":"180px"}},null,8,["modelValue","items"]),T[7]||(T[7]=_a('<div class="d-flex align-center ga-3 text-caption text-medium-emphasis" data-v-67f775c8><span class="d-flex align-center ga-1" data-v-67f775c8><span class="content-calendar__legend-dot" style="background:#748686;" data-v-67f775c8></span> Vorgeschlagen </span><span class="d-flex align-center ga-1" data-v-67f775c8><span class="content-calendar__legend-dot" style="background:#0AC9D4;" data-v-67f775c8></span> Akzeptiert </span><span class="d-flex align-center ga-1" data-v-67f775c8><span class="content-calendar__legend-dot" style="background:#66BB6A;" data-v-67f775c8></span> Post erstellt </span><span class="d-flex align-center ga-1" data-v-67f775c8><span class="content-calendar__legend-dot" style="background:#CF6679;" data-v-67f775c8></span> Übersprungen </span></div>',1))])]),c.value?(o(),N(B,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":T[1]||(T[1]=W=>c.value=null)},{default:t(()=>[n(v(c.value),1)]),_:1})):U("",!0),d.value?(o(),h("div",Lm,[e(G,{indeterminate:"",color:"primary"})])):(o(),h("div",Em,[a("div",Mm,[(o(),h(be,null,Pe(k,W=>a("div",{key:W,class:"content-calendar__weekday"},v(W),1)),64))]),a("div",Nm,[(o(!0),h(be,null,Pe(g.value,(W,F)=>(o(),h("div",{key:F,class:ft(["content-calendar__day",{"content-calendar__day--other-month":!W.isCurrentMonth,"content-calendar__day--today":I(W.date)}])},[a("div",Um,v(W.date.getDate()),1),a("div",Bm,[(o(!0),h(be,null,Pe(W.entries.slice(0,3),(L,A)=>(o(),h("div",{key:A,class:"content-calendar__post-chip",style:ht({borderLeftColor:V(L)}),title:L.title},v(E(L.title,28)),13,Fm))),128)),W.entries.length>3?(o(),h("div",Om," +"+v(W.entries.length-3)+" weitere ",1)):U("",!0)])],2))),128))])]))])}}}),Km=Me(Rm,[["__scopeId","data-v-67f775c8"]]),jm={class:"content-plan-list-view"},qm={class:"content-plan-list-view__header"},Gm={class:"d-flex align-center ga-2"},Hm={class:"content-plan-list-view__filter mb-6"},Wm={class:"d-flex align-center justify-space-between mb-3"},Zm={class:"text-subtitle-2"},Jm={key:0,class:"text-medium-emphasis"},Qm={key:1,class:"d-flex justify-center pa-4"},Ym={key:2,class:"text-body-2 text-medium-emphasis"},Xm={key:0,class:"d-flex justify-center pa-12"},ev={class:"d-flex align-start justify-space-between gap-2 mb-3"},tv={class:"text-body-1 font-weight-semibold content-plan-list-view__plan-name"},av={class:"d-flex align-center ga-1 text-body-2 text-medium-emphasis mb-2"},lv={class:"d-flex align-center ga-2 mb-4"},nv={class:"d-flex align-center justify-space-between mb-3"},ov={class:"text-caption text-medium-emphasis"},sv={class:"text-body-2 font-weight-medium text-white"},iv={class:"text-body-2 font-weight-medium",style:{color:"#0AC9D4"}},rv={key:0,class:"mb-2"},dv={class:"d-flex align-center justify-space-between mb-1"},uv={key:1,class:"d-flex align-center ga-2 mt-3 pt-3",style:{"border-top":"1px solid rgba(255,255,255,0.08)"}},cv={class:"d-flex align-center justify-space-between"},mv=Ae({__name:"ContentPlanListView",setup(r){const $=[{key:"elaboration",label:"Themen-Generierung",defaults:{temperature:.8,maxTokens:8192}},{key:"chat",label:"Chat / Verfeinerung",defaults:{temperature:.7,maxTokens:4096}}],d=xt(),c=y([]),s=y([]),m=y(!1),u=y(null),f=qe("content_plan_view_mode","list"),p=qe("content_plan_filter_status",""),_=qe("content_plan_only_mine",!1),k=y(!1),i=y(!1),g=y(null),x=y(!1),w=wt({name:"",startDate:"",endDate:"",frequency:"",gptSettingsId:""}),b=y(!1),I=y([]),V=y(!1),E=y(!1),R=y(null),M=[{title:"Alle",value:""},{title:"Entwurf",value:"draft"},{title:"Aktiv",value:"active"},{title:"Abgeschlossen",value:"completed"},{title:"Archiviert",value:"archived"}],T=[{title:"Mehrmals täglich",value:"multiple-daily"},{title:"Jeden Tag",value:"daily"},{title:"Alle 2-3 Tage",value:"every-2-3-days"},{title:"3x pro Woche",value:"3x-weekly"},{title:"2x pro Woche",value:"2x-weekly"},{title:"Wöchentlich",value:"weekly"}],D=se(()=>p.value?c.value.filter(q=>q.status===p.value):c.value),H=se(()=>s.value.map(q=>({title:`${q.name} (${q.provider})`,value:q._id}))),O=[q=>!!q||"Name ist erforderlich",q=>q.length>=3||"Mindestens 3 Zeichen"],S=[q=>!!q||"Startdatum ist erforderlich"],B=[q=>!!q||"Enddatum ist erforderlich"],G=[q=>!!q||"Frequenz ist erforderlich"];function W(q){return{draft:"default",active:"primary",completed:"success",archived:"warning"}[q]||"default"}function F(q){return{draft:"Entwurf",active:"Aktiv",completed:"Abgeschlossen",archived:"Archiviert"}[q]||q}function L(q){return{"multiple-daily":"Mehrmals täglich",daily:"Jeden Tag","every-2-3-days":"Alle 2-3 Tage","3x-weekly":"3x pro Woche","2x-weekly":"2x pro Woche",weekly:"Wöchentlich"}[q]||q}function A(q){return{idle:"default",running:"primary",done:"success",failed:"error"}[q]||"default"}function z(q){return q?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(new Date(q)):"-"}function j(q){return(q.topics||[]).filter(C=>C.status==="accepted").length}function J(q){return!q.lockedBy||!q.lockHeartbeatAt?!1:Date.now()-new Date(q.lockHeartbeatAt).getTime()<90*1e3}async function Q(){m.value=!0,u.value=null;try{const q=new URLSearchParams;_.value&&q.set("onlyMine","true");const C=q.toString(),ae=await re.get(`/content-plans${C?"?"+C:""}`);ae.success&&ae.data?c.value=ae.data:u.value=ae.error||"Fehler beim Laden der Content-Pläne"}catch{u.value="Netzwerkfehler beim Laden der Content-Pläne"}finally{m.value=!1}}async function te(){try{const q=await re.get("/gpt-settings");if(q.success&&q.data){const C=q.data,ae=Array.isArray(C)?C:C.items??[];s.value=ae.filter(X=>X.isActive!==!1)}}catch{}}async function ve(){V.value=!0,R.value=null;try{const q=await re.get("/content-plans/orphaned-posts");q.success&&q.data?I.value=q.data:R.value=q.error||"Fehler beim Laden"}catch{R.value="Netzwerkfehler"}finally{V.value=!1}}async function de(){E.value=!0,R.value=null;try{const q=await re.delete("/content-plans/orphaned-posts");q.success&&q.data?(I.value=[],b.value=!1):R.value=q.error||"Fehler beim Löschen"}catch{R.value="Netzwerkfehler beim Löschen"}finally{E.value=!1}}function Z(){b.value=!b.value}function ce(){var q;Object.assign(w,{name:"",startDate:new Date().toISOString().substring(0,10),endDate:"",frequency:"every-2-3-days",gptSettingsId:((q=s.value[0])==null?void 0:q._id)||""}),g.value=null,k.value=!0}function oe(){k.value=!1}async function pe(){if(!x.value)return;i.value=!0,g.value=null;const q={name:w.name,period:{startDate:w.startDate,endDate:w.endDate},frequency:w.frequency,gptSettingsId:w.gptSettingsId||void 0};try{const C=await re.post("/content-plans",q);C.success&&C.data?(oe(),d.push({name:"admin-content-plan-detail",params:{id:C.data._id}})):g.value=C.error||"Fehler beim Erstellen des Plans"}catch{g.value="Netzwerkfehler beim Erstellen"}finally{i.value=!1}}function _e(q){d.push({name:"admin-content-plan-detail",params:{id:q._id}})}return Ze(_,()=>Q()),rt(()=>{Q(),te(),ve()}),(q,C)=>{const ae=l("v-chip"),X=l("v-tooltip"),ie=l("v-icon"),fe=l("v-btn"),Se=l("v-btn-toggle"),me=l("v-alert"),ee=l("v-chip-group"),Y=l("v-badge"),K=l("v-progress-circular"),le=l("v-list-item-title"),ne=l("v-list-item-subtitle"),Ce=l("v-list-item"),ke=l("v-list"),xe=l("v-card-text"),Ne=l("v-card"),Ie=l("v-progress-linear"),Ue=l("v-col"),Te=l("v-row"),ye=l("v-card-title"),Je=l("v-divider"),Ke=l("v-text-field"),$e=l("v-select"),Ee=l("v-form"),lt=l("v-spacer"),ut=l("v-card-actions"),Ve=l("v-dialog");return o(),h("div",jm,[a("div",qm,[C[19]||(C[19]=a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"Content-Pläne"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," KI-gestützte Inhaltsplanung für LinkedIn und andere Kanäle ")],-1)),a("div",Gm,[e(ta,{"page-key":"content-plan","page-label":"Content-Plan KI-Einstellungen",usecases:$}),e(ae,{color:P(_)?"primary":"",variant:P(_)?"flat":"outlined","prepend-icon":"mdi-account-filter",class:"mr-2",onClick:C[0]||(C[0]=Le=>_.value=!P(_))},{default:t(()=>[...C[13]||(C[13]=[n(" Nur meine ",-1)])]),_:1},8,["color","variant"]),e(Se,{modelValue:P(f),"onUpdate:modelValue":C[1]||(C[1]=Le=>ot(f)?f.value=Le:null),variant:"outlined",density:"compact",mandatory:"",color:"primary"},{default:t(()=>[e(fe,{value:"list",icon:"","aria-label":"Listenansicht"},{default:t(()=>[e(X,{activator:"parent",location:"bottom"},{default:t(()=>[...C[14]||(C[14]=[n("Listenansicht",-1)])]),_:1}),e(ie,{size:"18"},{default:t(()=>[...C[15]||(C[15]=[n("mdi-view-list",-1)])]),_:1})]),_:1}),e(fe,{value:"calendar",icon:"","aria-label":"Kalenderansicht"},{default:t(()=>[e(X,{activator:"parent",location:"bottom"},{default:t(()=>[...C[16]||(C[16]=[n("Kalenderansicht",-1)])]),_:1}),e(ie,{size:"18"},{default:t(()=>[...C[17]||(C[17]=[n("mdi-calendar-month",-1)])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(fe,{color:"primary","prepend-icon":"mdi-plus",onClick:ce},{default:t(()=>[...C[18]||(C[18]=[n(" Neuer Plan ",-1)])]),_:1})])]),u.value?(o(),N(me,{key:0,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":C[2]||(C[2]=Le=>u.value=null)},{default:t(()=>[n(v(u.value),1)]),_:1})):U("",!0),a("div",Hm,[e(ee,{modelValue:P(p),"onUpdate:modelValue":C[3]||(C[3]=Le=>ot(p)?p.value=Le:null),color:"primary","selected-class":"content-plan-list-view__chip--active"},{default:t(()=>[(o(),h(be,null,Pe(M,Le=>e(ae,{key:Le.value,value:Le.value,variant:"outlined",filter:""},{default:t(()=>[n(v(Le.title),1)]),_:2},1032,["value"])),64))]),_:1},8,["modelValue"]),I.value.length?(o(),N(Y,{key:0,content:I.value.length,color:"error","offset-x":"-4","offset-y":"-4"},{default:t(()=>[e(fe,{variant:"text",size:"small",color:b.value?"error":"medium-emphasis","prepend-icon":"mdi-link-variant-off",onClick:Z},{default:t(()=>[...C[20]||(C[20]=[n(" Verwaiste Posts ",-1)])]),_:1},8,["color"])]),_:1},8,["content"])):(o(),N(fe,{key:1,variant:"text",size:"small",color:"medium-emphasis","prepend-icon":"mdi-link-variant-off",onClick:Z},{default:t(()=>[...C[21]||(C[21]=[n(" Verwaiste Posts ",-1)])]),_:1}))]),b.value?(o(),N(Ne,{key:1,variant:"outlined",class:"mb-6",style:{"border-color":"rgba(207, 102, 121, 0.3)"}},{default:t(()=>[e(xe,{class:"pa-4"},{default:t(()=>[a("div",Wm,[a("div",Zm,[C[22]||(C[22]=n(" Verwaiste Posts ",-1)),I.value.length?(o(),h("span",Jm," ("+v(I.value.length)+") ",1)):U("",!0)]),I.value.length?(o(),N(fe,{key:0,color:"error",variant:"tonal",size:"small","prepend-icon":"mdi-delete-sweep",loading:E.value,onClick:de},{default:t(()=>[...C[23]||(C[23]=[n(" Alle löschen ",-1)])]),_:1},8,["loading"])):U("",!0)]),C[24]||(C[24]=a("p",{class:"text-caption text-medium-emphasis mb-3"}," Posts aus früheren Elaboration-Durchläufen, die keinem Topic mehr zugeordnet sind. ",-1)),R.value?(o(),N(me,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-3",closable:"","onClick:close":C[4]||(C[4]=Le=>R.value=null)},{default:t(()=>[n(v(R.value),1)]),_:1})):U("",!0),V.value?(o(),h("div",Qm,[e(K,{indeterminate:"",size:"24",color:"primary"})])):I.value.length?(o(),N(ke,{key:3,density:"compact",class:"bg-transparent pa-0",style:{"max-height":"300px","overflow-y":"auto"}},{default:t(()=>[(o(!0),h(be,null,Pe(I.value,Le=>(o(),N(Ce,{key:Le._id,class:"px-0"},{default:t(()=>[e(le,{class:"text-body-2"},{default:t(()=>[n(v(Le.topicTitle||"(kein Titel)"),1)]),_:2},1024),e(ne,{class:"text-caption"},{default:t(()=>[n(v(Le.status)+" · "+v(z(Le.createdAt)),1)]),_:2},1024)]),_:2},1024))),128))]),_:1})):(o(),h("div",Ym," Keine verwaisten Posts gefunden. "))]),_:1})]),_:1})):U("",!0),P(f)==="list"?(o(),h(be,{key:2},[m.value?(o(),h("div",Xm,[e(K,{indeterminate:"",color:"primary"})])):D.value.length?(o(),N(Te,{key:2},{default:t(()=>[(o(!0),h(be,null,Pe(D.value,Le=>(o(),N(Ue,{key:Le._id,cols:"12",sm:"6",lg:"4"},{default:t(()=>[e(Ne,{class:"content-plan-list-view__plan-card",variant:"outlined",onClick:Ye=>_e(Le)},{default:t(()=>[e(xe,{class:"pa-5"},{default:t(()=>{var Ye,ct,Fe,Xe,mt,nt,He,St,Pt,Dt,_t,Re,ge;return[a("div",ev,[a("h3",tv,v(Le.name),1),e(ae,{color:W(Le.status),size:"x-small",variant:"tonal",class:"flex-shrink-0"},{default:t(()=>[n(v(F(Le.status)),1)]),_:2},1032,["color"])]),a("div",av,[e(ie,{size:"14"},{default:t(()=>[...C[29]||(C[29]=[n("mdi-calendar-range",-1)])]),_:1}),a("span",null,v(z((Ye=Le.period)==null?void 0:Ye.startDate))+" – "+v(z((ct=Le.period)==null?void 0:ct.endDate)),1)]),a("div",lv,[e(ae,{size:"x-small",variant:"outlined",color:"primary"},{default:t(()=>[n(v(L(Le.frequency)),1)]),_:2},1024)]),a("div",nv,[a("div",ov,[a("span",sv,v((Le.topics||[]).length),1),C[30]||(C[30]=n(" Topics gesamt  ·  ",-1)),a("span",iv,v(j(Le)),1),C[31]||(C[31]=n(" akzeptiert ",-1))])]),((Fe=Le.elaboration)==null?void 0:Fe.status)!=="idle"?(o(),h("div",rv,[a("div",dv,[C[32]||(C[32]=a("span",{class:"text-caption text-medium-emphasis"},"Ausarbeitung",-1)),e(ae,{color:A((Xe=Le.elaboration)==null?void 0:Xe.status),size:"x-small",variant:"tonal"},{default:t(()=>{var at,et,it;return[n(v(((at=Le.elaboration)==null?void 0:at.status)==="running"?"Läuft...":((et=Le.elaboration)==null?void 0:et.status)==="done"?"Fertig":((it=Le.elaboration)==null?void 0:it.status)==="failed"?"Fehler":""),1)]}),_:2},1032,["color"])]),((mt=Le.elaboration)==null?void 0:mt.status)==="running"?(o(),N(Ie,{key:0,"model-value":((nt=Le.elaboration)==null?void 0:nt.progress)||0,color:"primary",height:"4",rounded:""},null,8,["model-value"])):((He=Le.elaboration)==null?void 0:He.status)==="done"?(o(),N(Ie,{key:1,"model-value":"100",color:"success",height:"4",rounded:""})):U("",!0)])):U("",!0),Le.createdBy||Le.updatedBy?(o(),h("div",uv,[C[33]||(C[33]=a("span",{class:"text-caption text-medium-emphasis"},"Erstellt:",-1)),e(gt,{"user-id":((St=Le.createdBy)==null?void 0:St._id)??Le.createdBy??null,populated:(Pt=Le.createdBy)!=null&&Pt.firstName?Le.createdBy:null,size:22,locked:J(Le),"locked-by":(Dt=Le.lockedBy)!=null&&Dt.firstName?Le.lockedBy:null},null,8,["user-id","populated","locked","locked-by"]),C[34]||(C[34]=a("span",{class:"text-caption text-medium-emphasis mx-1"},"·",-1)),C[35]||(C[35]=a("span",{class:"text-caption text-medium-emphasis"},"Geändert:",-1)),e(gt,{"user-id":((_t=Le.updatedBy)==null?void 0:_t._id)??Le.updatedBy??null,populated:(Re=Le.updatedBy)!=null&&Re.firstName?Le.updatedBy:null,size:22,locked:J(Le),"locked-by":(ge=Le.lockedBy)!=null&&ge.firstName?Le.lockedBy:null},null,8,["user-id","populated","locked","locked-by"])])):U("",!0)]}),_:2},1024)]),_:2},1032,["onClick"])]),_:2},1024))),128))]),_:1})):(o(),N(Ne,{key:1,variant:"outlined",class:"content-plan-list-view__empty"},{default:t(()=>[e(xe,{class:"text-center pa-12"},{default:t(()=>[e(ie,{size:"64",color:"medium-emphasis",class:"mb-4"},{default:t(()=>[...C[25]||(C[25]=[n("mdi-calendar-text-outline",-1)])]),_:1}),C[27]||(C[27]=a("p",{class:"text-h6 font-weight-medium mb-2"},"Keine Content-Pläne vorhanden",-1)),C[28]||(C[28]=a("p",{class:"text-body-2 text-medium-emphasis mb-6"}," Erstelle deinen ersten Content-Plan, um die KI-gestützte Inhaltsplanung zu starten. ",-1)),e(fe,{color:"primary","prepend-icon":"mdi-plus",onClick:ce},{default:t(()=>[...C[26]||(C[26]=[n(" Ersten Plan erstellen ",-1)])]),_:1})]),_:1})]),_:1}))],64)):(o(),N(Km,{key:3})),e(Ve,{modelValue:k.value,"onUpdate:modelValue":C[12]||(C[12]=Le=>k.value=Le),"max-width":"560",scrollable:""},{default:t(()=>[e(Ne,{class:"content-plan-list-view__dialog"},{default:t(()=>[e(ye,{class:"pa-6 pb-4"},{default:t(()=>[a("div",cv,[C[38]||(C[38]=a("span",{class:"text-h6"},"Neuer Content-Plan",-1)),e(fe,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:oe},{default:t(()=>[e(X,{activator:"parent",location:"bottom"},{default:t(()=>[...C[36]||(C[36]=[n("Schließen",-1)])]),_:1}),e(ie,null,{default:t(()=>[...C[37]||(C[37]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(Je),e(xe,{class:"pa-6"},{default:t(()=>[g.value?(o(),N(me,{key:0,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":C[5]||(C[5]=Le=>g.value=null)},{default:t(()=>[n(v(g.value),1)]),_:1})):U("",!0),e(Ee,{modelValue:x.value,"onUpdate:modelValue":C[11]||(C[11]=Le=>x.value=Le),onSubmit:dt(pe,["prevent"])},{default:t(()=>[e(Te,null,{default:t(()=>[e(Ue,{cols:"12"},{default:t(()=>[e(Ke,{modelValue:w.name,"onUpdate:modelValue":C[6]||(C[6]=Le=>w.name=Le),label:"Plan-Name",rules:O,placeholder:"z.B. LinkedIn Q2 2026",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(Ue,{cols:"12",sm:"6"},{default:t(()=>[e(Ke,{modelValue:w.startDate,"onUpdate:modelValue":C[7]||(C[7]=Le=>w.startDate=Le),label:"Startdatum",type:"date",rules:S,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(Ue,{cols:"12",sm:"6"},{default:t(()=>[e(Ke,{modelValue:w.endDate,"onUpdate:modelValue":C[8]||(C[8]=Le=>w.endDate=Le),label:"Enddatum",type:"date",rules:B,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(Ue,{cols:"12"},{default:t(()=>[e($e,{modelValue:w.frequency,"onUpdate:modelValue":C[9]||(C[9]=Le=>w.frequency=Le),label:"Veröffentlichungsfrequenz",items:T,rules:G,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),H.value.length?(o(),N(Ue,{key:0,cols:"12"},{default:t(()=>[e($e,{modelValue:w.gptSettingsId,"onUpdate:modelValue":C[10]||(C[10]=Le=>w.gptSettingsId=Le),label:"KI-Konfiguration (optional)",items:H.value,variant:"outlined",density:"comfortable",clearable:"",hint:"Wird für die KI-gestützte Topic-Generierung verwendet","persistent-hint":""},null,8,["modelValue","items"])]),_:1})):U("",!0)]),_:1})]),_:1},8,["modelValue"])]),_:1}),e(Je),e(ut,{class:"pa-4"},{default:t(()=>[e(lt),e(fe,{variant:"text",onClick:oe},{default:t(()=>[...C[39]||(C[39]=[n("Abbrechen",-1)])]),_:1}),e(fe,{color:"primary",variant:"elevated",loading:i.value,disabled:!x.value,onClick:pe},{default:t(()=>[...C[40]||(C[40]=[n(" Plan erstellen ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}}),vv=Me(mv,[["__scopeId","data-v-f8d5e367"]]),b6=Object.freeze(Object.defineProperty({__proto__:null,default:vv},Symbol.toStringTag,{value:"Module"})),pl={draft:"Entwurf",pending_approval:"Zur Freigabe",approved:"Freigegeben",rejected:"Abgelehnt",scheduled:"Geplant",publishing:"Wird gepostet",published:"Veröffentlicht",failed:"Fehler"},fl={draft:"default",pending_approval:"warning",approved:"success",rejected:"error",scheduled:"info",publishing:"info",published:"success",failed:"error"},pv=[{value:"",label:"Alle Status"},{value:"draft",label:"Entwurf"},{value:"pending_approval",label:"Zur Freigabe"},{value:"approved",label:"Freigegeben"},{value:"rejected",label:"Abgelehnt"},{value:"scheduled",label:"Geplant"},{value:"publishing",label:"Wird gepostet"},{value:"published",label:"Veröffentlicht"},{value:"failed",label:"Fehler"}],fv={class:"linkedin-post-list-view"},gv={class:"linkedin-post-list-view__header"},bv={class:"d-flex align-center ga-2"},yv={key:1,class:"linkedin-post-list-view__bulk mb-3"},_v={class:"text-body-2 text-medium-emphasis"},kv={class:"d-flex align-center justify-space-between"},hv={class:"text-subtitle-1 font-weight-semibold"},xv={class:"linkedin-post-list-view__preview"},wv={key:0,class:"linkedin-post-list-view__thumbnail"},Sv={class:"linkedin-post-list-view__text"},$v={class:"text-body-2"},Cv={key:0,class:"d-flex flex-wrap ga-1 mt-1"},Vv={key:0,class:"text-caption text-medium-emphasis"},Av={class:"text-body-2 text-medium-emphasis"},Iv={key:1,class:"text-medium-emphasis"},Pv={class:"d-flex justify-end ga-1"},zv=Ae({__name:"LinkedinPostListView",setup(r){const $=[{key:"hashtags",label:"Hashtag-Generierung",defaults:{temperature:.5,maxTokens:1024}},{key:"landingPage",label:"Landing-Page-Generierung",defaults:{temperature:.6,maxTokens:16384}}],d=xt(),c=y([]),s=y([]),m=y(!1),u=y(null),f=qe("linkedin_filter_status",""),p=qe("linkedin_filter_plan",""),_=qe("linkedin_post_only_mine",!1),k=qe("linkedin_filter_date_from",""),i=qe("linkedin_filter_date_to",""),g=qe("linkedin_items_per_page",20),x=qe("linkedin_posts_sort",[]),w=y([]),b=y(!1),I=y(!1),V=y(null),E=pv.map(Q=>({title:Q.label,value:Q.value})),R=se(()=>[{title:"Alle Pläne",value:""},...s.value.map(Q=>({title:Q.name,value:Q._id}))]),M=[{title:"",key:"select",sortable:!1,width:"48px"},{title:"Vorschau",key:"preview",sortable:!1},{title:"Status",key:"status",sortable:!0},{title:"Datum",key:"date",sortable:!0},{title:"Plan",key:"plan",sortable:!0},{title:"Erstellt",key:"createdBy",sortable:!1,width:80,align:"center"},{title:"Geändert",key:"updatedBy",sortable:!1,width:80,align:"center"},{title:"Aktionen",key:"actions",sortable:!1,align:"end"}],T=se(()=>{let Q=c.value;return f.value&&(Q=Q.filter(te=>te.status===f.value)),p.value&&(Q=Q.filter(te=>te.contentPlanId===p.value)),k.value&&(Q=Q.filter(te=>(te.scheduledAt||te.publishedAt||te.createdAt)>=k.value)),i.value&&(Q=Q.filter(te=>(te.scheduledAt||te.publishedAt||te.createdAt)<=i.value+"T23:59:59")),Q});function D(Q){return fl[Q]??"default"}function H(Q){return pl[Q]??Q}function O(Q){return Q?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(Q)):"-"}function S(Q,te=120){return Q?Q.length>te?Q.substring(0,te)+"…":Q:""}function B(Q){return Q.scheduledAt||Q.publishedAt||void 0}function G(Q){const te=w.value.indexOf(Q);te>=0?w.value.splice(te,1):w.value.push(Q)}function W(Q){return!Q.lockedBy||!Q.lockHeartbeatAt?!1:Date.now()-new Date(Q.lockHeartbeatAt).getTime()<90*1e3}async function F(){m.value=!0,u.value=null;try{const Q=new URLSearchParams;_.value&&Q.set("onlyMine","true");const te=Q.toString(),[ve,de]=await Promise.all([re.get(`/linkedin/posts${te?"?"+te:""}`),re.get("/content-plans")]);if(ve.success&&ve.data){const Z=ve.data;c.value=Array.isArray(Z)?Z:Z.items??[]}else u.value=ve.error||"Fehler beim Laden der Posts";if(de.success&&de.data){const Z=de.data;s.value=Array.isArray(Z)?Z:Z.items??[]}}catch{u.value="Netzwerkfehler beim Laden"}finally{m.value=!1}}function L(Q){V.value=Q,I.value=!0}function A(){V.value=null,I.value=!0}async function z(){b.value=!0,I.value=!1,u.value=null;try{const Q=V.value?[V.value._id]:[...w.value];await Promise.all(Q.map(te=>re.delete(`/linkedin/posts/${te}`))),w.value=[],V.value=null,await F()}catch{u.value="Fehler beim Löschen der Posts"}finally{b.value=!1}}function j(Q){d.push({name:"admin-linkedin-post-edit",params:{id:Q._id}})}function J(){d.push({name:"admin-linkedin-post-edit",params:{id:"new"}})}return Ze(_,()=>F()),rt(()=>{F()}),(Q,te)=>{const ve=l("v-chip"),de=l("v-btn"),Z=l("v-alert"),ce=l("v-select"),oe=l("v-col"),pe=l("v-text-field"),_e=l("v-row"),q=l("v-card-text"),C=l("v-card"),ae=l("v-tooltip"),X=l("v-icon"),ie=l("v-card-title"),fe=l("v-checkbox"),Se=l("v-img"),me=l("router-link"),ee=l("v-data-table"),Y=l("v-spacer"),K=l("v-card-actions"),le=l("v-dialog");return o(),h("div",fv,[a("div",gv,[te[12]||(te[12]=a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"LinkedIn Posts"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," Posts verwalten, planen und veröffentlichen ")],-1)),a("div",bv,[e(ta,{"page-key":"linkedin-post","page-label":"LinkedIn-Post KI-Einstellungen",usecases:$}),e(ve,{color:P(_)?"primary":"",variant:P(_)?"flat":"outlined","prepend-icon":"mdi-account-filter",class:"mr-2",onClick:te[0]||(te[0]=ne=>_.value=!P(_))},{default:t(()=>[...te[10]||(te[10]=[n(" Nur meine ",-1)])]),_:1},8,["color","variant"]),e(de,{color:"primary","prepend-icon":"mdi-plus",onClick:J},{default:t(()=>[...te[11]||(te[11]=[n(" Neuer Post ",-1)])]),_:1})])]),u.value?(o(),N(Z,{key:0,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":te[1]||(te[1]=ne=>u.value=null)},{default:t(()=>[n(v(u.value),1)]),_:1})):U("",!0),e(C,{variant:"outlined",class:"linkedin-post-list-view__filter mb-4"},{default:t(()=>[e(q,{class:"pa-4"},{default:t(()=>[e(_e,{align:"center",dense:""},{default:t(()=>[e(oe,{cols:"12",sm:"3"},{default:t(()=>[e(ce,{modelValue:P(f),"onUpdate:modelValue":te[2]||(te[2]=ne=>ot(f)?f.value=ne:null),label:"Status",items:P(E),variant:"outlined",density:"compact","hide-details":"",clearable:""},null,8,["modelValue","items"])]),_:1}),e(oe,{cols:"12",sm:"3"},{default:t(()=>[e(ce,{modelValue:P(p),"onUpdate:modelValue":te[3]||(te[3]=ne=>ot(p)?p.value=ne:null),label:"Content-Plan",items:R.value,variant:"outlined",density:"compact","hide-details":"",clearable:""},null,8,["modelValue","items"])]),_:1}),e(oe,{cols:"12",sm:"3"},{default:t(()=>[e(pe,{modelValue:P(k),"onUpdate:modelValue":te[4]||(te[4]=ne=>ot(k)?k.value=ne:null),label:"Von Datum",type:"date",variant:"outlined",density:"compact","hide-details":""},null,8,["modelValue"])]),_:1}),e(oe,{cols:"12",sm:"3"},{default:t(()=>[e(pe,{modelValue:P(i),"onUpdate:modelValue":te[5]||(te[5]=ne=>ot(i)?i.value=ne:null),label:"Bis Datum",type:"date",variant:"outlined",density:"compact","hide-details":""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1}),w.value.length>0?(o(),h("div",yv,[a("span",_v,v(w.value.length)+" Post(s) ausgewählt ",1),e(de,{color:"error",variant:"outlined",size:"small","prepend-icon":"mdi-trash-can-outline",loading:b.value,onClick:A},{default:t(()=>[...te[13]||(te[13]=[n(" Löschen ",-1)])]),_:1},8,["loading"])])):U("",!0),e(C,{variant:"outlined",class:"linkedin-post-list-view__table-card"},{default:t(()=>[e(ie,{class:"pa-4 pb-2"},{default:t(()=>[a("div",kv,[a("span",hv,v(T.value.length)+" Posts ",1),e(de,{icon:"",variant:"text",size:"small",loading:m.value,"aria-label":"Aktualisieren",onClick:F},{default:t(()=>[e(ae,{activator:"parent",location:"bottom"},{default:t(()=>[...te[14]||(te[14]=[n("Aktualisieren",-1)])]),_:1}),e(X,null,{default:t(()=>[...te[15]||(te[15]=[n("mdi-refresh",-1)])]),_:1})]),_:1},8,["loading"])])]),_:1}),e(ee,{headers:M,items:T.value,loading:m.value,"loading-text":"Posts werden geladen...","no-data-text":"Keine Posts vorhanden","item-value":"_id",class:"linkedin-post-list-view__table","items-per-page":P(g),"onUpdate:itemsPerPage":te[6]||(te[6]=ne=>ot(g)?g.value=ne:null),"sort-by":P(x),"onUpdate:sortBy":te[7]||(te[7]=ne=>x.value=ne)},{"item.select":t(({item:ne})=>[e(fe,{"model-value":w.value.includes(ne._id),"hide-details":"",density:"compact","onUpdate:modelValue":Ce=>G(ne._id)},null,8,["model-value","onUpdate:modelValue"])]),"item.preview":t(({item:ne})=>{var Ce;return[a("div",xv,[ne.imageUrl?(o(),h("div",wv,[e(Se,{src:ne.imageUrl,width:"48",height:"48",cover:"",class:"rounded"},null,8,["src"])])):U("",!0),a("div",Sv,[a("span",$v,v(S(ne.text)),1),(Ce=ne.hashtags)!=null&&Ce.length?(o(),h("div",Cv,[(o(!0),h(be,null,Pe(ne.hashtags.slice(0,3),ke=>(o(),N(ve,{key:ke,size:"x-small",variant:"outlined",color:"primary"},{default:t(()=>[n(" #"+v(ke),1)]),_:2},1024))),128)),ne.hashtags.length>3?(o(),h("span",Vv," +"+v(ne.hashtags.length-3),1)):U("",!0)])):U("",!0)])])]}),"item.status":t(({item:ne})=>[e(ve,{color:D(ne.status),size:"small",variant:"tonal"},{default:t(()=>[n(v(H(ne.status)),1)]),_:2},1032,["color"])]),"item.date":t(({item:ne})=>[a("span",Av,v(O(B(ne))),1)]),"item.plan":t(({item:ne})=>[ne.contentPlan?(o(),N(me,{key:0,to:{name:"admin-content-plan-detail",params:{id:ne.contentPlan._id}},class:"linkedin-post-list-view__plan-link"},{default:t(()=>[n(v(ne.contentPlan.name),1)]),_:2},1032,["to"])):(o(),h("span",Iv,"-"))]),"item.createdBy":t(({item:ne})=>{var Ce,ke,xe;return[e(gt,{"user-id":((Ce=ne.createdBy)==null?void 0:Ce._id)??ne.createdBy??null,populated:(ke=ne.createdBy)!=null&&ke.firstName?ne.createdBy:null,locked:W(ne),"locked-by":(xe=ne.lockedBy)!=null&&xe.firstName?ne.lockedBy:null},null,8,["user-id","populated","locked","locked-by"])]}),"item.updatedBy":t(({item:ne})=>{var Ce,ke,xe;return[e(gt,{"user-id":((Ce=ne.updatedBy)==null?void 0:Ce._id)??ne.updatedBy??null,populated:(ke=ne.updatedBy)!=null&&ke.firstName?ne.updatedBy:null,locked:W(ne),"locked-by":(xe=ne.lockedBy)!=null&&xe.firstName?ne.lockedBy:null},null,8,["user-id","populated","locked","locked-by"])]}),"item.actions":t(({item:ne})=>[a("div",Pv,[e(de,{icon:"",variant:"text",size:"small",color:"primary","aria-label":"Bearbeiten",onClick:Ce=>j(ne)},{default:t(()=>[e(ae,{activator:"parent",location:"bottom"},{default:t(()=>[...te[16]||(te[16]=[n("Bearbeiten",-1)])]),_:1}),e(X,{size:"18"},{default:t(()=>[...te[17]||(te[17]=[n("mdi-pencil-outline",-1)])]),_:1})]),_:1},8,["onClick"]),e(de,{icon:"",variant:"text",size:"small",color:"error","aria-label":"Löschen",onClick:Ce=>L(ne)},{default:t(()=>[e(ae,{activator:"parent",location:"bottom"},{default:t(()=>[...te[18]||(te[18]=[n("Löschen",-1)])]),_:1}),e(X,{size:"18"},{default:t(()=>[...te[19]||(te[19]=[n("mdi-trash-can-outline",-1)])]),_:1})]),_:1},8,["onClick"])])]),_:1},8,["items","loading","items-per-page","sort-by"])]),_:1}),e(le,{modelValue:I.value,"onUpdate:modelValue":te[9]||(te[9]=ne=>I.value=ne),"max-width":"440"},{default:t(()=>[e(C,null,{default:t(()=>[e(ie,{class:"pa-6 pb-4 text-subtitle-1"},{default:t(()=>[n(v(V.value?"Post löschen?":`${w.value.length} Posts löschen?`),1)]),_:1}),e(q,{class:"pa-6 pt-0 text-body-2 text-medium-emphasis"},{default:t(()=>[V.value?(o(),h(be,{key:0},[te[20]||(te[20]=n(" Der Post ",-1)),a("em",null,"„"+v(S(V.value.text,60))+'"',1),te[21]||(te[21]=n(" wird dauerhaft gelöscht. ",-1))],64)):(o(),h(be,{key:1},[n(" Die ausgewählten "+v(w.value.length)+" Posts werden dauerhaft gelöscht. ",1)],64)),te[22]||(te[22]=n(" Diese Aktion kann nicht rückgängig gemacht werden. ",-1))]),_:1}),e(K,{class:"pa-4"},{default:t(()=>[e(Y),e(de,{variant:"text",onClick:te[8]||(te[8]=ne=>I.value=!1)},{default:t(()=>[...te[23]||(te[23]=[n("Abbrechen",-1)])]),_:1}),e(de,{color:"error",variant:"elevated",loading:b.value,onClick:z},{default:t(()=>[...te[24]||(te[24]=[n(" Löschen ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}}),Dv=Me(zv,[["__scopeId","data-v-35032409"]]),y6=Object.freeze(Object.defineProperty({__proto__:null,default:Dv},Symbol.toStringTag,{value:"Module"})),Tv=Ae({__name:"LinkedinConnectionBanner",setup(r,{expose:$}){const d=y(!0),c=y(!1),s=y(!1),m=y(null),u=y("");return rt(async()=>{try{const f=await ul();f.success&&f.data?(c.value=f.data.isConnected,s.value=f.data.dryRun===!0,m.value=f.data.userName,u.value=f.data.message):(c.value=!1,u.value=f.error||"Status konnte nicht ermittelt werden.")}catch{c.value=!1,u.value="Status konnte nicht ermittelt werden."}finally{d.value=!1}}),$({isConnected:c,loading:d,dryRun:s,userName:m}),(f,p)=>{const _=l("v-btn"),k=l("v-alert"),i=l("router-link");return!d.value&&!c.value?(o(),N(k,{key:0,type:"warning",variant:"tonal",closable:"",class:"mb-3",icon:"mdi-linkedin"},{append:t(()=>[e(_,{variant:"text",density:"compact",color:"warning",to:{path:"/admin/einstellungen",hash:"#linkedin"}},{default:t(()=>[...p[0]||(p[0]=[n(" Einstellungen öffnen ",-1)])]),_:1})]),default:t(()=>[p[1]||(p[1]=a("strong",null,"LinkedIn nicht verbunden:",-1)),n(" "+v(u.value)+" ",1)]),_:1})):!d.value&&c.value&&s.value?(o(),N(k,{key:1,type:"info",variant:"tonal",class:"mb-3",icon:"mdi-flask-outline"},{default:t(()=>[a("strong",null,"DRY-RUN aktiv"+v(m.value?` (verbunden als ${m.value})`:"")+":",1),p[3]||(p[3]=n(" Posts werden NICHT auf LinkedIn veröffentlicht. Backend liefert eine Mock-postId zurück. Umschalten unter ",-1)),e(i,{to:"/admin/ki-einstellungen",class:"text-primary"},{default:t(()=>[...p[2]||(p[2]=[n("/admin/ki-einstellungen",-1)])]),_:1}),p[4]||(p[4]=n(" → LinkedIn-Konfiguration → Toggle „Dry-Run-Modus“. ",-1))]),_:1})):U("",!0)}}}),Lv={key:0,class:"d-flex justify-center pa-6"},Ev={key:1,class:"text-center text-medium-emphasis pa-6"},Mv={class:"text-truncate"},Nv={class:"text-medium-emphasis text-truncate"},Uv={key:3,class:"d-flex justify-center mt-4"},el=12,Bv=Ae({__name:"ImagePoolPickerDialog",props:{modelValue:{type:Boolean}},emits:["update:modelValue","select"],setup(r,{emit:$}){const d=r,c=$,s=se({get:()=>d.modelValue,set:b=>c("update:modelValue",b)}),m=y([]),u=y(!1),f=y(""),p=y(1),_=y(0),k=se(()=>Math.max(1,Math.ceil(_.value/el)));let i=null;function g(){i&&clearTimeout(i),i=setTimeout(()=>{p.value=1,x()},300)}async function x(){var b;u.value=!0;try{const I=new URLSearchParams({page:String(p.value),limit:String(el)});f.value&&I.append("q",f.value);const V=await re.get(`/images?${I.toString()}`);V.success&&V.data?(m.value=V.data.items??[],_.value=((b=V.data.pagination)==null?void 0:b.total)??m.value.length):(m.value=[],_.value=0)}catch{m.value=[],_.value=0}finally{u.value=!1}}Ze(s,b=>{b&&m.value.length===0&&x()});function w(b){c("select",{imageId:b._id,imageUrl:b.url}),s.value=!1}return(b,I)=>{const V=l("v-btn"),E=l("v-card-title"),R=l("v-text-field"),M=l("v-progress-circular"),T=l("v-img"),D=l("v-card-text"),H=l("v-card"),O=l("v-col"),S=l("v-row"),B=l("v-pagination"),G=l("v-dialog");return o(),N(G,{modelValue:s.value,"onUpdate:modelValue":I[3]||(I[3]=W=>s.value=W),"max-width":"900",scrollable:""},{default:t(()=>[e(H,null,{default:t(()=>[e(E,{class:"d-flex align-center justify-space-between"},{default:t(()=>[I[4]||(I[4]=a("span",null,"Bild aus Pool wählen",-1)),e(V,{icon:"mdi-close",variant:"text",onClick:I[0]||(I[0]=W=>s.value=!1)})]),_:1}),e(D,null,{default:t(()=>[e(R,{modelValue:f.value,"onUpdate:modelValue":[I[1]||(I[1]=W=>f.value=W),g],label:"Suche (Tags, Title, Caption)",variant:"outlined",density:"compact","prepend-inner-icon":"mdi-magnify",clearable:""},null,8,["modelValue"]),u.value?(o(),h("div",Lv,[e(M,{indeterminate:"",color:"primary"})])):m.value.length===0?(o(),h("div",Ev," Keine Bilder gefunden. ")):(o(),N(S,{key:2},{default:t(()=>[(o(!0),h(be,null,Pe(m.value,W=>(o(),N(O,{key:W._id,cols:"6",sm:"4",md:"3"},{default:t(()=>[e(H,{variant:"outlined",hover:"",class:"image-pool-tile",onClick:F=>w(W)},{default:t(()=>[e(T,{src:W.thumbnailUrl||W.url,"aspect-ratio":"1",cover:""},null,8,["src"]),e(D,{class:"text-caption"},{default:t(()=>[a("div",Mv,v(W.alt||W.title||W.filename),1),a("div",Nv,v((W.tags||[]).slice(0,3).join(", ")),1)]),_:2},1024)]),_:2},1032,["onClick"])]),_:2},1024))),128))]),_:1})),k.value>1?(o(),h("div",Uv,[e(B,{modelValue:p.value,"onUpdate:modelValue":[I[2]||(I[2]=W=>p.value=W),x],length:k.value,density:"compact"},null,8,["modelValue","length"])])):U("",!0)]),_:1})]),_:1})]),_:1},8,["modelValue"])}}}),Fv=Me(Bv,[["__scopeId","data-v-76a21ea8"]]),Ov={class:"linkedin-post-image-section"},Rv={class:"d-flex flex-wrap ga-2 mb-3"},Kv={class:"d-flex align-center justify-space-between"},jv=Ae({__name:"LinkedinPostImageSection",props:{postId:{},planId:{},topicTitle:{},imageId:{},imageUrl:{},imageGenerationSuggestion:{},readonly:{type:Boolean}},emits:["update:imageId","update:imageUrl","post-created","error"],setup(r,{emit:$}){const d=r,c=$,s=y(null),m=y(!1),u=y(!1),f=y(d.imageId??null),p=y(d.imageUrl??""),_=y(d.imageGenerationSuggestion??"");Ze(()=>d.imageId,A=>{f.value=A??null}),Ze(()=>d.imageUrl,A=>{p.value=A??""}),Ze(()=>d.imageGenerationSuggestion,A=>{_.value=A??""});const k=y(!1),i=y(!1),g=y(!1),x=y(!1),w=y(""),b=y("ASPECT_1_1"),I=[{title:"1:1 (Quadrat)",value:"ASPECT_1_1"},{title:"4:5 (Hochformat)",value:"ASPECT_4_5"},{title:"16:9 (Querformat)",value:"ASPECT_16_9"}],V=se(()=>!!d.readonly),E=se(()=>!!(d.postId||d.planId&&d.topicTitle));async function R(){var A,z;if(V.value)return ue.warn("ADMIN","Bild-Zuordnung blockiert - Read-Only"),null;if(!E.value)return c("error","Bild kann nicht gespeichert werden: weder postId noch planId+topicTitle vorhanden."),null;g.value=!0;try{let j=d.postId??null;if(!j&&d.planId&&d.topicTitle){const Q=await re.post(`/content-plans/${d.planId}/topics/ensure-post`,{topicTitle:d.topicTitle});if(!Q.success||!((z=(A=Q.data)==null?void 0:A.post)!=null&&z._id))return c("error",Q.error||"Post konnte nicht angelegt werden."),null;j=Q.data.post._id,c("post-created",{postId:j})}if(!j)return c("error","Kein postId verfügbar."),null;const J=await re.put(`/linkedin/posts/${j}`,{imageId:f.value||void 0,imageUrl:p.value||void 0});return J.success?j:(c("error",J.error||"Bild-Zuordnung fehlgeschlagen."),null)}catch(j){const J=j instanceof Error?j.message:"Netzwerkfehler beim Speichern des Bildes.";return c("error",J),null}finally{g.value=!1}}async function M(A){f.value=A.imageId??null,p.value=A.imageUrl,_.value="",c("update:imageId",f.value),c("update:imageUrl",p.value),await R()}async function T(){!d.postId&&!f.value&&!p.value||(f.value=null,p.value="",c("update:imageId",null),c("update:imageUrl",""),d.postId&&await R())}async function D(A){await M(A)}function H(){var A;(A=s.value)==null||A.click()}function O(A){A.preventDefault(),u.value=!0}function S(){u.value=!1}function B(A){var j,J;A.preventDefault(),u.value=!1;const z=(J=(j=A.dataTransfer)==null?void 0:j.files)==null?void 0:J[0];z&&W(z)}function G(A){var J;const z=A.target,j=(J=z.files)==null?void 0:J[0];j&&W(j),z&&(z.value="")}async function W(A){var z;if(V.value){ue.warn("ADMIN","Bild-Upload blockiert - Read-Only");return}k.value=!0;try{const j=new FormData;j.append("image",A);const J=await re.upload("/images/upload",j);J.success&&((z=J.data)!=null&&z.url)?await M({imageId:null,imageUrl:J.data.url}):c("error",J.error||"Fehler beim Hochladen des Bildes")}catch{c("error","Netzwerkfehler beim Hochladen")}finally{k.value=!1}}async function F(){var A;if(V.value){ue.warn("ADMIN","Bild-Generierung blockiert - Read-Only");return}if(w.value.trim()){i.value=!0,x.value=!1;try{const z=await re.post("/images/generate",{prompt:w.value,aspectRatio:b.value});if(z.success&&z.data){const J=(A=(Array.isArray(z.data)?z.data:[z.data])[0])==null?void 0:A.url;typeof J=="string"&&J.trim()?await M({imageId:null,imageUrl:J}):c("error","Generiertes Bild hat keine gültige URL")}else c("error",z.error||"Fehler beim Generieren des Bildes")}catch{c("error","Netzwerkfehler bei Bild-Generierung")}finally{i.value=!1,w.value=""}}}function L(A){A&&(w.value=A,x.value=!0)}return(A,z)=>{const j=l("v-btn"),J=l("v-alert"),Q=l("v-img"),te=l("v-icon"),ve=l("v-tooltip"),de=l("v-card-title"),Z=l("v-divider"),ce=l("v-textarea"),oe=l("v-select"),pe=l("v-card-text"),_e=l("v-spacer"),q=l("v-card-actions"),C=l("v-card"),ae=l("v-dialog");return o(),h("div",Ov,[_.value&&!p.value?(o(),N(J,{key:0,type:"info",variant:"tonal",density:"compact",class:"mb-3","prepend-icon":"mdi-lightbulb-on"},{append:t(()=>[e(j,{variant:"text",density:"compact",disabled:V.value,onClick:z[0]||(z[0]=X=>L(_.value))},{default:t(()=>[...z[9]||(z[9]=[n(" In KI-Prompt übernehmen ",-1)])]),_:1},8,["disabled"])]),default:t(()=>[z[10]||(z[10]=a("strong",null,"KI-Bild-Vorschlag:",-1)),n(" "+v(_.value)+" ",1)]),_:1})):U("",!0),a("div",Rv,[e(j,{variant:"outlined",size:"small","prepend-icon":"mdi-folder-image",disabled:V.value||g.value,onClick:z[1]||(z[1]=X=>m.value=!0)},{default:t(()=>[...z[11]||(z[11]=[n(" Aus Pool wählen ",-1)])]),_:1},8,["disabled"]),e(j,{variant:"outlined",size:"small","prepend-icon":"mdi-upload",loading:k.value||g.value,disabled:V.value,onClick:H},{default:t(()=>[...z[12]||(z[12]=[n(" Datei auswählen ",-1)])]),_:1},8,["loading","disabled"]),e(j,{variant:"outlined",size:"small",color:"primary","prepend-icon":"mdi-creation",loading:i.value||g.value,disabled:V.value,onClick:z[2]||(z[2]=X=>x.value=!0)},{default:t(()=>[...z[13]||(z[13]=[n(" KI generieren ",-1)])]),_:1},8,["loading","disabled"])]),a("div",{class:ft(["linkedin-post-image-section__upload-zone",{"linkedin-post-image-section__upload-zone--dragover":u.value}]),onDragover:O,onDragleave:S,onDrop:B},[p.value?(o(),h(be,{key:0},[e(Q,{src:p.value,alt:"Bild-Vorschau","max-height":"200",cover:"",class:"rounded mb-2"},null,8,["src"]),e(j,{variant:"text",color:"error",size:"small","prepend-icon":"mdi-trash-can-outline",disabled:V.value,loading:g.value,onClick:T},{default:t(()=>[...z[14]||(z[14]=[n(" Bild entfernen ",-1)])]),_:1},8,["disabled","loading"])],64)):(o(),h(be,{key:1},[e(te,{size:"32",color:"medium-emphasis",class:"mb-2"},{default:t(()=>[...z[15]||(z[15]=[n("mdi-image-plus-outline",-1)])]),_:1}),z[16]||(z[16]=a("p",{class:"text-body-2 text-medium-emphasis mb-0"}," Bild hierher ziehen oder einen der Buttons oben nutzen. ",-1))],64)),a("input",{ref_key:"fileInput",ref:s,type:"file",accept:"image/*",style:{display:"none"},onChange:G},null,544)],34),e(Fv,{modelValue:m.value,"onUpdate:modelValue":z[3]||(z[3]=X=>m.value=X),onSelect:D},null,8,["modelValue"]),e(ae,{modelValue:x.value,"onUpdate:modelValue":z[8]||(z[8]=X=>x.value=X),"max-width":"720"},{default:t(()=>[e(C,{class:"linkedin-post-image-section__card"},{default:t(()=>[e(de,{class:"pa-6 pb-4"},{default:t(()=>[a("div",Kv,[z[19]||(z[19]=a("span",{class:"text-h6"},"KI-Bild generieren",-1)),e(j,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:z[4]||(z[4]=X=>x.value=!1)},{default:t(()=>[e(ve,{activator:"parent",location:"bottom"},{default:t(()=>[...z[17]||(z[17]=[n("Schließen",-1)])]),_:1}),e(te,null,{default:t(()=>[...z[18]||(z[18]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(Z),e(pe,{class:"pa-6"},{default:t(()=>[e(ce,{modelValue:w.value,"onUpdate:modelValue":z[5]||(z[5]=X=>w.value=X),label:"Bild-Beschreibung",placeholder:"z.B. Professionelles Foto eines Cybersecurity-Experten vor Serverraum...",variant:"outlined",rows:"8","auto-grow":"",class:"mb-4"},null,8,["modelValue"]),e(oe,{modelValue:b.value,"onUpdate:modelValue":z[6]||(z[6]=X=>b.value=X),label:"Seitenverhältnis",items:I,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(Z),e(q,{class:"pa-4"},{default:t(()=>[e(_e),e(j,{variant:"text",onClick:z[7]||(z[7]=X=>x.value=!1)},{default:t(()=>[...z[20]||(z[20]=[n("Abbrechen",-1)])]),_:1}),e(j,{color:"primary",variant:"elevated",disabled:!w.value.trim(),"prepend-icon":"mdi-creation",onClick:F},{default:t(()=>[...z[21]||(z[21]=[n(" Generieren ",-1)])]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}}),gl=Me(jv,[["__scopeId","data-v-cbc8f8f6"]]),qv={class:"linkedin-post-editor"},Gv={class:"linkedin-post-editor__nav mb-4"},Hv={class:"linkedin-post-editor__header mb-6"},Wv={class:"text-h5 font-weight-bold"},Zv={key:0,class:"text-body-2 text-medium-emphasis mt-1"},Jv={key:1,class:"d-flex align-center ga-2 text-caption text-medium-emphasis mt-2"},Qv={key:0,class:"d-flex justify-center pa-12"},Yv={class:"linkedin-post-editor__layout"},Xv={class:"linkedin-post-editor__form-col"},ep={class:"d-flex align-center justify-space-between"},tp={class:"text-medium-emphasis"},ap={class:"linkedin-post-editor__preview-col"},lp={class:"d-flex flex-column ga-2"},np={key:0,class:"text-caption text-error"},op={class:"linkedin-post-editor__preview"},sp={class:"d-flex align-center ga-2 mb-3"},ip={class:"linkedin-post-editor__preview-text"},rp={key:0,class:"text-body-2",style:{"white-space":"pre-wrap"}},dp={key:1,class:"text-body-2 text-medium-emphasis"},up={key:0,class:"text-body-2 mt-2",style:{color:"#0AC9D4"}},$a=3e3,cp=Ae({__name:"LinkedinPostEditorView",setup(r){const $=[{key:"hashtags",label:"Hashtag-Generierung",defaults:{temperature:.5,maxTokens:1024}},{key:"landingPage",label:"Landing-Page-Generierung",defaults:{temperature:.6,maxTokens:16384}}],d=Ut(),c=xt(),s=se(()=>d.params.id),m=se(()=>s.value==="new"),u=se(()=>{const ke=d.params.id;return typeof ke=="string"&&ke!=="new"?ke:null}),{isLocked:f,isLockedByMe:p,lockedBy:_,lockedAt:k,isLockTakenOver:i,takenOverBy:g,takeOverLock:x}=sa("LinkedinPost",u),w=se(()=>f.value&&!p.value||i.value),b=y(null),I=y(!1),V=y(null),E=wt({text:"",hashtags:[],imageUrl:"",imageId:"",imageGenerationSuggestion:"",scheduledDate:"",scheduledTime:"09:00"}),R=y(!1),M=y(null),T=y(!1),D=y(null),H=y(!1),O=y(!1),S=y(null);function B(ke){M.value=ke}const G=ea(),W=y(!1),F=y(!1),L=y(!1),A=y(!1),z=y(""),j=y(null),J=se(()=>E.text.length),Q=se(()=>J.value>$a*.9),te=se(()=>J.value>$a),ve=se(()=>{if(!E.scheduledDate)return;const ke=E.scheduledTime||"09:00";return`${E.scheduledDate}T${ke}:00`}),de=se(()=>E.hashtags.map(ke=>ke.startsWith("#")?ke:`#${ke}`).join(" "));function Z(ke){return ke!=null&&ke.createdBy?typeof ke.createdBy=="string"?ke.createdBy:ke.createdBy._id??null:null}const ce=se(()=>{var Ie,Ue;if(!b.value)return!1;const ke=((Ie=G.user)==null?void 0:Ie.role)==="admin",xe=((Ue=G.user)==null?void 0:Ue._id)??null,Ne=!!xe&&Z(b.value)===xe;return ke||!Ne}),oe=se(()=>{var ke;return!!((ke=b.value)!=null&&ke.scheduledAt)}),pe=se(()=>{var xe;const ke=((xe=b.value)==null?void 0:xe.approvalHistory)??[];for(let Ne=ke.length-1;Ne>=0;Ne--)if(ke[Ne].action==="rejected")return ke[Ne].reason??"";return""}),_e=se(()=>{if(w.value||!E.text.trim()||te.value||m.value)return!0;const ke=j.value;return!!(ke&&!ke.loading&&!ke.isConnected)});function q(ke){if(ke instanceof Error)return ke.message;if(typeof ke=="object"&&ke&&"message"in ke)return String(ke.message)}async function C(){var ke;if((ke=b.value)!=null&&ke._id){W.value=!0,M.value=null,S.value=null;try{const xe=await Ol(b.value._id);xe.success&&xe.data?(b.value=xe.data,S.value="Post zur Freigabe eingereicht."):M.value=xe.error||"Einreichen fehlgeschlagen."}catch(xe){M.value=q(xe)??"Einreichen fehlgeschlagen."}finally{W.value=!1}}}async function ae(){var ke;if((ke=b.value)!=null&&ke._id){F.value=!0,M.value=null,S.value=null;try{const xe=oe.value,Ne=await Rl(b.value._id,xe);Ne.success&&Ne.data?(b.value=Ne.data,S.value=xe?"Freigegeben & geplant.":"Freigegeben."):M.value=Ne.error||"Freigabe fehlgeschlagen."}catch(xe){M.value=q(xe)??"Freigabe fehlgeschlagen."}finally{F.value=!1}}}function X(){z.value="",A.value=!0}async function ie(){var ke;if(!(!((ke=b.value)!=null&&ke._id)||z.value.trim().length<3)){L.value=!0,M.value=null,S.value=null;try{const xe=await Kl(b.value._id,z.value.trim());xe.success&&xe.data?(b.value=xe.data,S.value="Post abgelehnt.",A.value=!1):M.value=xe.error||"Ablehnen fehlgeschlagen."}catch(xe){M.value=q(xe)??"Ablehnen fehlgeschlagen."}finally{L.value=!1}}}function fe(ke){return{submitted:"mdi-send-check",approved:"mdi-check-circle",rejected:"mdi-close-circle"}[ke]??"mdi-circle"}function Se(ke){return{submitted:"Zur Freigabe eingereicht",approved:"Freigegeben",rejected:"Abgelehnt"}[ke]??ke}function me(ke){if(!ke)return"Unbekannt";if(typeof ke=="string")return"Ehemaliger Benutzer";const xe=`${ke.firstName??""} ${ke.lastName??""}`.trim();return xe||(ke.email??"Unbekannt")}function ee(ke){return new Date(ke).toLocaleString("de-DE")}async function Y(){if(!m.value){I.value=!0,V.value=null;try{const ke=await re.get(`/linkedin/posts/${s.value}`);ke.success&&ke.data?(b.value=ke.data,K(ke.data)):V.value=ke.error||"Fehler beim Laden des Posts"}catch{V.value="Netzwerkfehler beim Laden"}finally{I.value=!1}}}function K(ke){if(E.text=ke.text||"",E.hashtags=ke.hashtags||[],E.imageUrl=ke.imageUrl||"",E.imageId=ke.imageId||"",E.imageGenerationSuggestion=ke.imageGenerationSuggestion||"",ke.scheduledAt){const xe=new Date(ke.scheduledAt);E.scheduledDate=xe.toISOString().substring(0,10),E.scheduledTime=xe.toTimeString().substring(0,5)}}async function le(ke=!1){if(w.value){ue.warn("ADMIN","Speichern blockiert - kein Lock-Owner");return}ke?(T.value=!0,D.value=null):(R.value=!0,M.value=null),S.value=null;const xe={text:E.text,hashtags:E.hashtags,scheduledAt:ve.value};try{let Ne=s.value;if(m.value){const Ie={...xe,imageUrl:E.imageUrl||void 0,imageId:E.imageId||void 0},Ue=await re.post("/linkedin/posts",Ie);if(!Ue.success||!Ue.data)throw new Error(Ue.error||"Fehler beim Erstellen");Ne=Ue.data._id,b.value=Ue.data}else{const Ie=await re.put(`/linkedin/posts/${s.value}`,xe);if(!Ie.success||!Ie.data)throw new Error(Ie.error||"Fehler beim Speichern");b.value=Ie.data}if(ke){const Ie=await re.post(`/linkedin/posts/${Ne}/publish`);if(!Ie.success)throw new Error(Ie.error||"Fehler beim Veröffentlichen");S.value="Post wurde erfolgreich veröffentlicht."}else S.value=m.value?"Post wurde erstellt.":E.scheduledDate?"Post wurde geplant.":"Post wurde gespeichert.";m.value&&c.replace({name:"admin-linkedin-post-edit",params:{id:Ne}})}catch(Ne){const Ie=Ne instanceof Error?Ne.message:"Unbekannter Fehler";ke?D.value=Ie:M.value=Ie}finally{R.value=!1,T.value=!1}}async function ne(){var ke,xe,Ne;if(w.value){ue.warn("ADMIN","Hashtag-Generierung blockiert - kein Lock-Owner");return}if(!((ke=b.value)!=null&&ke._id)&&m.value){M.value="Bitte zuerst speichern, um Hashtags zu generieren.";return}H.value=!0,M.value=null;try{const Ie=((xe=b.value)==null?void 0:xe._id)||s.value,Ue=await re.post(`/linkedin/posts/${Ie}/generate-hashtags`);Ue.success&&((Ne=Ue.data)!=null&&Ne.hashtags)?E.hashtags=Ue.data.hashtags:M.value=Ue.error||"Fehler beim Generieren der Hashtags"}catch{M.value="Netzwerkfehler bei Hashtag-Generierung"}finally{H.value=!1}}async function Ce(){var ke;if(w.value){ue.warn("ADMIN","Landing-Page-Generierung blockiert - kein Lock-Owner");return}if(!((ke=b.value)!=null&&ke._id)){M.value="Bitte zuerst speichern, um eine Landing Page zu generieren.";return}O.value=!0,M.value=null;try{const xe=await re.post(`/linkedin/posts/${b.value._id}/generate-landing-page`);xe.success?S.value="Landing Page wurde erfolgreich generiert.":M.value=xe.error||"Fehler beim Generieren der Landing Page"}catch{M.value="Netzwerkfehler bei Landing Page-Generierung"}finally{O.value=!1}}return rt(()=>{Y()}),(ke,xe)=>{var _t,Re,ge,at;const Ne=l("v-btn"),Ie=l("v-chip"),Ue=l("v-progress-circular"),Te=l("v-alert"),ye=l("v-card-title"),Je=l("v-textarea"),Ke=l("v-card-text"),$e=l("v-card"),Ee=l("v-combobox"),lt=l("v-text-field"),ut=l("v-col"),Ve=l("v-row"),Le=l("v-icon"),Ye=l("v-list-item-title"),ct=l("v-list-item-subtitle"),Fe=l("v-list-item"),Xe=l("v-list"),mt=l("v-divider"),nt=l("v-spacer"),He=l("v-card-actions"),St=l("v-dialog"),Pt=l("v-avatar"),Dt=l("v-img");return o(),h("div",qv,[a("div",Gv,[e(Ne,{variant:"text","prepend-icon":"mdi-arrow-left",size:"small",onClick:xe[0]||(xe[0]=et=>P(c).push({name:"admin-linkedin-posts"}))},{default:t(()=>[...xe[16]||(xe[16]=[n(" Zurück zur Übersicht ",-1)])]),_:1})]),e(ia,{"is-locked":P(f),"is-locked-by-me":P(p),"locked-by":P(_),"locked-at":P(k),"is-lock-taken-over":P(i),"taken-over-by":P(g),"on-take-over":P(x)},null,8,["is-locked","is-locked-by-me","locked-by","locked-at","is-lock-taken-over","taken-over-by","on-take-over"]),e(Tv,{ref_key:"connectionBannerRef",ref:j},null,512),a("div",Hv,[a("div",null,[a("h1",Wv,v(m.value?"Neuer LinkedIn Post":"Post bearbeiten"),1),b.value?(o(),h("p",Zv,[xe[17]||(xe[17]=n(" Status: ",-1)),e(Ie,{color:P(fl)[b.value.status],size:"x-small",variant:"tonal",class:"ml-1"},{default:t(()=>[n(v(P(pl)[b.value.status]),1)]),_:1},8,["color"])])):U("",!0),b.value&&b.value._id?(o(),h("div",Jv,[xe[18]||(xe[18]=a("span",null,"Erstellt:",-1)),e(gt,{"user-id":((_t=b.value.createdBy)==null?void 0:_t._id)??b.value.createdBy??null,populated:(Re=b.value.createdBy)!=null&&Re.firstName?b.value.createdBy:null,size:24},null,8,["user-id","populated"]),xe[19]||(xe[19]=a("span",{class:"mx-1"},"·",-1)),xe[20]||(xe[20]=a("span",null,"Geändert:",-1)),e(gt,{"user-id":((ge=b.value.updatedBy)==null?void 0:ge._id)??b.value.updatedBy??null,populated:(at=b.value.updatedBy)!=null&&at.firstName?b.value.updatedBy:null,size:24},null,8,["user-id","populated"])])):U("",!0)]),e(ta,{"page-key":"linkedin-post","page-label":"LinkedIn-Post KI-Einstellungen",usecases:$})]),I.value?(o(),h("div",Qv,[e(Ue,{indeterminate:"",color:"primary"})])):U("",!0),V.value?(o(),N(Te,{key:1,type:"error",variant:"tonal",class:"mb-6"},{default:t(()=>[n(v(V.value),1)]),_:1})):U("",!0),I.value?U("",!0):(o(),h(be,{key:2},[S.value?(o(),N(Te,{key:0,type:"success",variant:"tonal",class:"mb-4",closable:"","onClick:close":xe[1]||(xe[1]=et=>S.value=null)},{default:t(()=>[n(v(S.value),1)]),_:1})):U("",!0),M.value?(o(),N(Te,{key:1,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":xe[2]||(xe[2]=et=>M.value=null)},{default:t(()=>[n(v(M.value),1)]),_:1})):U("",!0),D.value?(o(),N(Te,{key:2,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":xe[3]||(xe[3]=et=>D.value=null)},{default:t(()=>[n(v(D.value),1)]),_:1})):U("",!0),a("div",Yv,[a("div",Xv,[e($e,{variant:"outlined",class:"linkedin-post-editor__card mb-4"},{default:t(()=>[e(ye,{class:"pa-4 pb-2 text-subtitle-2"},{default:t(()=>[...xe[21]||(xe[21]=[n("Post-Text",-1)])]),_:1}),e(Ke,{class:"pa-4 pt-0"},{default:t(()=>[e(Je,{modelValue:E.text,"onUpdate:modelValue":xe[4]||(xe[4]=et=>E.text=et),placeholder:"Schreibe deinen LinkedIn Post...",variant:"outlined",rows:"8","auto-grow":"","hide-details":"",error:te.value,disabled:w.value},null,8,["modelValue","error","disabled"]),a("div",{class:ft(["text-caption mt-1 text-right",te.value?"text-error":Q.value?"text-warning":"text-medium-emphasis"])},v(J.value)+" / "+v($a),3)]),_:1})]),_:1}),e($e,{variant:"outlined",class:"linkedin-post-editor__card mb-4"},{default:t(()=>[e(ye,{class:"pa-4 pb-2"},{default:t(()=>[a("div",ep,[xe[23]||(xe[23]=a("span",{class:"text-subtitle-2"},"Hashtags",-1)),e(Ne,{variant:"outlined",size:"x-small",color:"primary","prepend-icon":"mdi-robot-outline",loading:H.value,disabled:w.value,onClick:ne},{default:t(()=>[...xe[22]||(xe[22]=[n(" KI generieren ",-1)])]),_:1},8,["loading","disabled"])])]),_:1}),e(Ke,{class:"pa-4 pt-0"},{default:t(()=>[e(Ee,{modelValue:E.hashtags,"onUpdate:modelValue":xe[5]||(xe[5]=et=>E.hashtags=et),placeholder:"Hashtag eingeben und Enter drücken",variant:"outlined",density:"comfortable",multiple:"",chips:"","closable-chips":"","hide-no-data":"","hide-details":"",disabled:w.value},null,8,["modelValue","disabled"])]),_:1})]),_:1}),e($e,{variant:"outlined",class:"linkedin-post-editor__card mb-4"},{default:t(()=>[e(ye,{class:"pa-4 pb-2"},{default:t(()=>[...xe[24]||(xe[24]=[a("div",{class:"d-flex align-center justify-space-between"},[a("span",{class:"text-subtitle-2"},"Bild")],-1)])]),_:1}),e(Ke,{class:"pa-4 pt-0"},{default:t(()=>[e(gl,{"post-id":m.value?null:s.value,"image-id":E.imageId||null,"image-url":E.imageUrl,"image-generation-suggestion":E.imageGenerationSuggestion,readonly:w.value,"onUpdate:imageId":xe[6]||(xe[6]=et=>E.imageId=et??""),"onUpdate:imageUrl":xe[7]||(xe[7]=et=>E.imageUrl=et),onError:B},null,8,["post-id","image-id","image-url","image-generation-suggestion","readonly"])]),_:1})]),_:1}),e($e,{variant:"outlined",class:"linkedin-post-editor__card mb-4"},{default:t(()=>[e(ye,{class:"pa-4 pb-2 text-subtitle-2"},{default:t(()=>[...xe[25]||(xe[25]=[n("Veröffentlichungszeitpunkt",-1)])]),_:1}),e(Ke,{class:"pa-4 pt-0"},{default:t(()=>[e(Ve,null,{default:t(()=>[e(ut,{cols:"12",sm:"7"},{default:t(()=>[e(lt,{modelValue:E.scheduledDate,"onUpdate:modelValue":xe[8]||(xe[8]=et=>E.scheduledDate=et),label:"Datum",type:"date",variant:"outlined",density:"comfortable","hide-details":"",clearable:"",disabled:w.value},null,8,["modelValue","disabled"])]),_:1}),e(ut,{cols:"12",sm:"5"},{default:t(()=>[e(lt,{modelValue:E.scheduledTime,"onUpdate:modelValue":xe[9]||(xe[9]=et=>E.scheduledTime=et),label:"Uhrzeit",type:"time",variant:"outlined",density:"comfortable","hide-details":"",disabled:w.value||!E.scheduledDate},null,8,["modelValue","disabled"])]),_:1})]),_:1})]),_:1})]),_:1}),e($e,{variant:"outlined",class:"linkedin-post-editor__card mb-4"},{default:t(()=>[e(ye,{class:"pa-4 pb-2 text-subtitle-2"},{default:t(()=>[...xe[26]||(xe[26]=[n("KI-Extras",-1)])]),_:1}),e(Ke,{class:"pa-4 pt-0"},{default:t(()=>[e(Ne,{variant:"outlined",size:"small","prepend-icon":"mdi-web",loading:O.value,disabled:w.value||m.value,onClick:Ce},{default:t(()=>[...xe[27]||(xe[27]=[n(" Landing Page generieren ",-1)])]),_:1},8,["loading","disabled"]),xe[28]||(xe[28]=a("p",{class:"text-caption text-medium-emphasis mt-1"}," Erstellt automatisch eine passende Landing Page zum Post-Inhalt. ",-1))]),_:1})]),_:1}),b.value&&b.value.approvalHistory&&b.value.approvalHistory.length>0?(o(),N($e,{key:0,variant:"outlined",class:"linkedin-post-editor__card mb-4"},{default:t(()=>[e(ye,{class:"pa-4 pb-2 text-subtitle-2"},{default:t(()=>[e(Le,{class:"mr-1",size:"16"},{default:t(()=>[...xe[29]||(xe[29]=[n("mdi-history",-1)])]),_:1}),xe[30]||(xe[30]=n(" Freigabe-Historie ",-1))]),_:1}),e(Xe,{density:"compact",class:"pa-0"},{default:t(()=>[(o(!0),h(be,null,Pe(b.value.approvalHistory,(et,it)=>(o(),N(Fe,{key:it,"prepend-icon":fe(et.action)},{default:t(()=>[e(Ye,{class:"text-body-2"},{default:t(()=>[n(v(Se(et.action))+" ",1),a("span",tp," von "+v(me(et.by))+" - "+v(ee(et.at)),1)]),_:2},1024),et.reason?(o(),N(ct,{key:0,class:"text-caption"},{default:t(()=>[n(v(et.reason),1)]),_:2},1024)):U("",!0)]),_:2},1032,["prepend-icon"]))),128))]),_:1})]),_:1})):U("",!0)]),a("div",ap,[e($e,{variant:"outlined",class:"linkedin-post-editor__card mb-4"},{default:t(()=>[e(Ke,{class:"pa-4"},{default:t(()=>[a("div",lp,[e(Ne,{color:"primary",variant:"elevated","prepend-icon":"mdi-content-save-outline",loading:R.value,disabled:w.value||!E.text.trim()||te.value,block:"",onClick:xe[10]||(xe[10]=et=>le(!1))},{default:t(()=>[...xe[31]||(xe[31]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled"]),e(Ne,{color:"info",variant:"outlined","prepend-icon":"mdi-calendar-clock",loading:R.value,disabled:w.value||!E.text.trim()||!E.scheduledDate||te.value,block:"",onClick:xe[11]||(xe[11]=et=>le(!1))},{default:t(()=>[...xe[32]||(xe[32]=[n(" Planen ",-1)])]),_:1},8,["loading","disabled"]),b.value&&!m.value?(o(),h(be,{key:0},[e(mt,{class:"my-1"}),xe[36]||(xe[36]=a("div",{class:"text-caption text-medium-emphasis"},"Freigabe",-1)),b.value.status==="draft"||b.value.status==="rejected"?(o(),N(Ne,{key:0,color:"warning",variant:"tonal",block:"","prepend-icon":"mdi-send-check",loading:W.value,disabled:w.value||!E.text.trim()||te.value,onClick:C},{default:t(()=>[...xe[33]||(xe[33]=[n(" Zur Freigabe ",-1)])]),_:1},8,["loading","disabled"])):b.value.status==="pending_approval"?(o(),h(be,{key:1},[e(Ne,{color:"success",variant:"elevated",block:"","prepend-icon":"mdi-check-circle",loading:F.value,disabled:!ce.value,onClick:ae},{default:t(()=>[n(" Freigeben"+v(oe.value?" & Planen":""),1)]),_:1},8,["loading","disabled"]),e(Ne,{color:"error",variant:"outlined",block:"","prepend-icon":"mdi-close-circle",disabled:!ce.value,onClick:X},{default:t(()=>[...xe[34]||(xe[34]=[n(" Ablehnen ",-1)])]),_:1},8,["disabled"]),ce.value?U("",!0):(o(),h("div",np," Self-Approval ist nicht erlaubt. Bitte einen Admin um Freigabe. "))],64)):b.value.status==="approved"?(o(),N(Te,{key:2,type:"success",density:"compact",variant:"tonal"},{default:t(()=>[...xe[35]||(xe[35]=[n(" Freigegeben - kann jetzt veröffentlicht oder geplant werden. ",-1)])]),_:1})):U("",!0),b.value.status==="rejected"?(o(),N(Te,{key:3,type:"error",density:"compact",variant:"tonal"},{default:t(()=>[n(" Abgelehnt: "+v(pe.value||"Kein Grund angegeben."),1)]),_:1})):U("",!0),e(mt,{class:"my-1"})],64)):U("",!0),e(Ne,{color:"success",variant:"outlined","prepend-icon":"mdi-linkedin",loading:T.value,disabled:_e.value,block:"",onClick:xe[12]||(xe[12]=et=>le(!0))},{default:t(()=>[...xe[37]||(xe[37]=[n(" Jetzt veröffentlichen ",-1)])]),_:1},8,["loading","disabled"])])]),_:1})]),_:1}),e(St,{modelValue:A.value,"onUpdate:modelValue":xe[15]||(xe[15]=et=>A.value=et),"max-width":"500"},{default:t(()=>[e($e,null,{default:t(()=>[e(ye,null,{default:t(()=>[...xe[38]||(xe[38]=[n("Post ablehnen",-1)])]),_:1}),e(Ke,null,{default:t(()=>[e(Je,{modelValue:z.value,"onUpdate:modelValue":xe[13]||(xe[13]=et=>z.value=et),label:"Grund für die Ablehnung",rows:"3",variant:"outlined",rules:[et=>et.trim().length>=3||"Mindestens 3 Zeichen"],autofocus:""},null,8,["modelValue","rules"])]),_:1}),e(He,null,{default:t(()=>[e(nt),e(Ne,{variant:"text",onClick:xe[14]||(xe[14]=et=>A.value=!1)},{default:t(()=>[...xe[39]||(xe[39]=[n("Abbrechen",-1)])]),_:1}),e(Ne,{color:"error",loading:L.value,disabled:z.value.trim().length<3,onClick:ie},{default:t(()=>[...xe[40]||(xe[40]=[n(" Ablehnen ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e($e,{variant:"outlined",class:"linkedin-post-editor__card"},{default:t(()=>[e(ye,{class:"pa-4 pb-2 text-subtitle-2"},{default:t(()=>[e(Le,{class:"mr-1",size:"16",color:"primary"},{default:t(()=>[...xe[41]||(xe[41]=[n("mdi-linkedin",-1)])]),_:1}),xe[42]||(xe[42]=n(" Vorschau ",-1))]),_:1}),e(Ke,{class:"pa-4 pt-0"},{default:t(()=>[a("div",op,[a("div",sp,[e(Pt,{size:"40",color:"primary"},{default:t(()=>[...xe[43]||(xe[43]=[a("span",{class:"text-body-2 font-weight-bold"},"B",-1)])]),_:1}),xe[44]||(xe[44]=a("div",null,[a("p",{class:"text-body-2 font-weight-semibold mb-0"},"Basec GmbH"),a("p",{class:"text-caption text-medium-emphasis"},"IT-Security Beratung · Gerade eben")],-1))]),a("div",ip,[E.text?(o(),h("p",rp,v(E.text),1)):(o(),h("p",dp," (Post-Text wird hier angezeigt) "))]),de.value?(o(),h("p",up,v(de.value),1)):U("",!0),E.imageUrl?(o(),N(Dt,{key:1,src:E.imageUrl,alt:"LinkedIn Post Bild-Vorschau",class:"mt-3 rounded","max-height":"200",cover:""},null,8,["src"])):U("",!0),e(mt,{class:"my-3"}),xe[45]||(xe[45]=a("div",{class:"d-flex ga-4 text-caption text-medium-emphasis"},[a("span",null,"👍 Gefällt mir"),a("span",null,"💬 Kommentieren"),a("span",null,"🔁 Teilen")],-1))])]),_:1})]),_:1})])])],64))])}}}),mp=Me(cp,[["__scopeId","data-v-4f5d277c"]]),_6=Object.freeze(Object.defineProperty({__proto__:null,default:mp},Symbol.toStringTag,{value:"Module"}));function ka(){function r(u){const f=u.trim();return f.startsWith("message:")?{type:"message",payload:f.slice(8)}:f==="accept-all"?{type:"accept-all",payload:""}:f==="elaborate"?{type:"elaborate",payload:""}:f.startsWith("generate-post:")?{type:"generate-post",payload:f.slice(14)}:f.startsWith("generate-lp:")?{type:"generate-lp",payload:f.slice(12)}:{type:"unknown",payload:f}}function $(u){return u.topics.length>0||u.posts.length>0||u.hashtags.length>0||u.landingPages.length>0||u.ctas.length>0}function d(u){return{suggested:"default",accepted:"success",generating:"primary",skipped:"error",drafted:"info",published:"primary"}[u]??"default"}function c(u){return{suggested:"Vorgeschlagen",accepted:"Akzeptiert",generating:"Wird generiert",skipped:"Verworfen",drafted:"Entworfen",published:"Veröffentlicht"}[u]??u}function s(u,f){return u?u.length<=f?u:u.slice(0,f).trimEnd()+"...":""}function m(u){if(!u)return"-";const f=new Date(u);return isNaN(f.getTime())?u:new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(f)}return{parseCtaAction:r,hasMarkers:$,getTopicStatusColor:d,getTopicStatusLabel:c,truncateText:s,formatDate:m}}const vp={class:"d-flex align-start justify-space-between ga-3"},pp={class:"topic-detail-modal__title text-h6 font-weight-bold"},fp={class:"d-flex align-center flex-wrap ga-2 mt-3"},gp={key:1,class:"topic-detail-modal__date text-caption text-medium-emphasis"},bp={key:0,class:"topic-detail-modal__generating pa-4 text-center mb-4"},yp={class:"topic-detail-modal__content-grid"},_p={class:"topic-detail-modal__left"},kp={class:"topic-detail-modal__section"},hp={key:0,class:"text-body-2 topic-detail-modal__description"},xp={key:1,class:"text-body-2 text-medium-emphasis font-style-italic"},wp={key:0,class:"topic-detail-modal__section topic-detail-modal__post-section mt-5"},Sp={class:"d-flex align-center justify-space-between mb-3"},$p={class:"text-caption text-medium-emphasis"},Cp={class:"topic-detail-modal__post-box"},Vp={class:"text-body-2 topic-detail-modal__post-text"},Ap={key:0,class:"d-flex flex-wrap ga-1 mt-3"},Ip={key:1,class:"topic-detail-modal__section topic-detail-modal__image-section mt-5"},Pp={class:"mt-3"},zp={class:"topic-detail-modal__right"},Dp={key:0,class:"topic-detail-modal__section"},Tp={class:"topic-detail-modal__lp-card mt-3"},Lp={class:"d-flex align-start justify-space-between"},Ep={class:"text-body-2 font-weight-semibold mb-1"},Mp={class:"text-caption text-medium-emphasis"},Np={class:"d-flex ga-2 mt-3"},Up={key:1,class:"topic-detail-modal__section"},Bp={class:"topic-detail-modal__lp-placeholder mt-3"},Fp=Ae({__name:"TopicDetailModal",props:{modelValue:{type:Boolean},topic:{},planId:{},readonly:{type:Boolean},onRefine:{type:Function},onGenerateLp:{type:Function},onStatusChange:{type:Function},onAdoptPost:{type:Function}},emits:["update:modelValue","post-created","image-error"],setup(r,{emit:$}){var B,G,W;const d=r,c=$,{getTopicStatusColor:s,getTopicStatusLabel:m,formatDate:u}=ka(),f=se({get:()=>d.modelValue,set:F=>c("update:modelValue",F)}),p=se(()=>{if(!d.topic)return"";const F=d.topic.scheduledDate||d.topic.suggestedDate||"";return u(F)}),_=se(()=>{var F,L;return((L=(F=d.topic)==null?void 0:F.postText)==null?void 0:L.length)??0}),k=se(()=>{var F;return!!((F=d.topic)!=null&&F.postText)}),i=se(()=>{var F;return!!((F=d.topic)!=null&&F.landingPagePreview)}),g=se(()=>{var F,L;return(L=(F=d.topic)==null?void 0:F.landingPagePreview)!=null&&L.pageId?`/admin/seiten/${d.topic.landingPagePreview.pageId}`:null}),x=se(()=>{var F,L;return(L=(F=d.topic)==null?void 0:F.landingPagePreview)!=null&&L.slug?`/${d.topic.landingPagePreview.slug}?preview=true`:null}),w=se(()=>{var L;const F=(L=d.topic)==null?void 0:L.postId;return F?typeof F=="string"?F:typeof F=="object"&&F._id?String(F._id):null:null}),b=se(()=>{var L;const F=(L=d.topic)==null?void 0:L.postId;return!F||typeof F=="string"?null:F}),I=y(w.value),V=y(((B=b.value)==null?void 0:B.imageId)??null),E=y(((G=b.value)==null?void 0:G.imageUrl)??""),R=y(((W=b.value)==null?void 0:W.imageGenerationSuggestion)??"");Ze(()=>d.topic,()=>{var F,L,A;I.value=w.value,V.value=((F=b.value)==null?void 0:F.imageId)??null,E.value=((L=b.value)==null?void 0:L.imageUrl)??"",R.value=((A=b.value)==null?void 0:A.imageGenerationSuggestion)??""});function M(F){var L;I.value=F.postId,(L=d.topic)!=null&&L.title&&c("post-created",{topicTitle:d.topic.title,postId:F.postId})}function T(F){c("image-error",F)}function D(){f.value=!1}function H(){var F;d.topic&&((F=d.onRefine)==null||F.call(d,d.topic.title),D())}function O(){var F;d.topic&&((F=d.onStatusChange)==null||F.call(d,d.topic.title,"skipped"),D())}function S(){var F;d.topic&&((F=d.onAdoptPost)==null||F.call(d,d.topic),D())}return(F,L)=>{const A=l("v-tooltip"),z=l("v-icon"),j=l("v-btn"),J=l("v-chip"),Q=l("v-card-title"),te=l("v-divider"),ve=l("v-progress-circular"),de=l("v-card-text"),Z=l("v-spacer"),ce=l("v-card-actions"),oe=l("v-card"),pe=l("v-dialog");return o(),N(pe,{"model-value":f.value,"max-width":"1280",scrollable:"","content-class":"topic-detail-dialog","onUpdate:modelValue":L[3]||(L[3]=_e=>c("update:modelValue",_e))},{default:t(()=>[r.topic?(o(),N(oe,{key:0,class:"topic-detail-modal"},{default:t(()=>[e(Q,{class:"topic-detail-modal__header pa-5 pb-4"},{default:t(()=>[a("div",vp,[a("h2",pp,v(r.topic.title),1),e(j,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:D},{default:t(()=>[e(A,{activator:"parent",location:"bottom"},{default:t(()=>[...L[4]||(L[4]=[n("Schließen",-1)])]),_:1}),e(z,null,{default:t(()=>[...L[5]||(L[5]=[n("mdi-close",-1)])]),_:1})]),_:1})]),a("div",fp,[e(J,{color:P(s)(r.topic.status),size:"small",variant:"tonal"},{default:t(()=>[n(v(P(m)(r.topic.status)),1)]),_:1},8,["color"]),r.topic.category?(o(),N(J,{key:0,size:"small",variant:"outlined",color:"default"},{default:t(()=>[n(v(r.topic.category),1)]),_:1})):U("",!0),p.value?(o(),h("span",gp,[e(z,{size:"14",class:"mr-1"},{default:t(()=>[...L[6]||(L[6]=[n("mdi-calendar-outline",-1)])]),_:1}),n(" "+v(p.value),1)])):U("",!0)])]),_:1}),e(te),e(de,{class:"topic-detail-modal__body pa-5"},{default:t(()=>[r.topic.status==="generating"?(o(),h("div",bp,[e(ve,{indeterminate:"",size:"32",width:"3",color:"primary",class:"mb-3"}),L[7]||(L[7]=a("p",{class:"text-body-2 text-medium-emphasis"}," Post wird generiert... ",-1))])):U("",!0),a("div",yp,[a("div",_p,[a("div",kp,[r.topic.description?(o(),h("p",hp,v(r.topic.description),1)):(o(),h("p",xp," Keine Beschreibung vorhanden. "))]),k.value?(o(),h("div",wp,[a("div",Sp,[L[8]||(L[8]=a("span",{class:"topic-detail-modal__section-label text-caption font-weight-semibold text-uppercase"}," Post-Entwurf ",-1)),a("span",$p,v(_.value)+" / 3.000 ",1)]),a("div",Cp,[a("p",Vp,v(r.topic.postText),1)]),r.topic.hashtags&&r.topic.hashtags.length?(o(),h("div",Ap,[(o(!0),h(be,null,Pe(r.topic.hashtags,_e=>(o(),N(J,{key:_e,size:"x-small",variant:"tonal",color:"default"},{default:t(()=>[n(v(_e),1)]),_:2},1024))),128))])):U("",!0)])):U("",!0),k.value?(o(),h("div",Ip,[L[9]||(L[9]=a("span",{class:"topic-detail-modal__section-label text-caption font-weight-semibold text-uppercase"}," Bild ",-1)),a("div",Pp,[e(gl,{"post-id":I.value,"plan-id":d.planId??null,"topic-title":r.topic.title,"image-id":V.value,"image-url":E.value,"image-generation-suggestion":R.value,readonly:!!d.readonly,"onUpdate:imageId":L[0]||(L[0]=_e=>V.value=_e),"onUpdate:imageUrl":L[1]||(L[1]=_e=>E.value=_e),onPostCreated:M,onError:T},null,8,["post-id","plan-id","topic-title","image-id","image-url","image-generation-suggestion","readonly"])])])):U("",!0)]),a("div",zp,[i.value?(o(),h("div",Dp,[L[13]||(L[13]=a("span",{class:"topic-detail-modal__section-label topic-detail-modal__section-label--lp text-caption font-weight-semibold text-uppercase"}," Landing Page ",-1)),a("div",Tp,[a("div",Lp,[a("div",null,[a("p",Ep,v(r.topic.landingPagePreview.title),1),a("p",Mp," /"+v(r.topic.landingPagePreview.slug),1)]),e(J,{size:"x-small",variant:"tonal",color:"warning",class:"ml-2"},{default:t(()=>[...L[10]||(L[10]=[n("Entwurf",-1)])]),_:1})]),a("div",Np,[g.value?(o(),N(j,{key:0,href:g.value,size:"small",variant:"outlined",color:"primary","prepend-icon":"mdi-pencil-outline"},{default:t(()=>[...L[11]||(L[11]=[n(" Im Editor öffnen ",-1)])]),_:1},8,["href"])):U("",!0),x.value?(o(),N(j,{key:1,href:x.value,target:"_blank",rel:"noopener noreferrer",size:"small",variant:"text",color:"default","prepend-icon":"mdi-open-in-new"},{default:t(()=>[...L[12]||(L[12]=[n(" Vorschau ",-1)])]),_:1},8,["href"])):U("",!0)])])])):k.value?(o(),h("div",Up,[L[17]||(L[17]=a("span",{class:"topic-detail-modal__section-label topic-detail-modal__section-label--lp text-caption font-weight-semibold text-uppercase"}," Landing Page ",-1)),a("div",Bp,[e(z,{size:"32",color:"medium-emphasis",class:"mb-2"},{default:t(()=>[...L[14]||(L[14]=[n("mdi-file-document-outline",-1)])]),_:1}),L[16]||(L[16]=a("p",{class:"text-body-2 text-medium-emphasis mb-3"}," Noch keine Landing Page erstellt. ",-1)),e(j,{size:"small",variant:"outlined",color:"primary","prepend-icon":"mdi-plus",onClick:L[2]||(L[2]=()=>{var _e;return(_e=d.onGenerateLp)==null?void 0:_e.call(d,r.topic.title)})},{default:t(()=>[...L[15]||(L[15]=[n(" Landing Page generieren ",-1)])]),_:1})])])):U("",!0)])])]),_:1}),e(te),r.topic.status!=="generating"?(o(),N(ce,{key:0,class:"topic-detail-modal__footer pa-4"},{default:t(()=>[e(j,{variant:"text",size:"small","prepend-icon":"mdi-chat-outline",onClick:H},{default:t(()=>[...L[18]||(L[18]=[n(" Im Chat verfeinern ",-1)])]),_:1}),e(Z),e(j,{color:"error",variant:"tonal",size:"small","prepend-icon":"mdi-close-circle-outline",onClick:O},{default:t(()=>[...L[19]||(L[19]=[n(" Verwerfen ",-1)])]),_:1}),w.value?(o(),N(j,{key:0,variant:"outlined",size:"small","prepend-icon":"mdi-pencil-box-outline",class:"ml-2",to:{name:"admin-linkedin-post-edit",params:{id:w.value}}},{default:t(()=>[...L[20]||(L[20]=[n(" Im Editor öffnen ",-1)])]),_:1},8,["to"])):U("",!0),k.value?(o(),N(j,{key:1,color:"primary",variant:"elevated",size:"small","prepend-icon":"mdi-check",class:"ml-2",onClick:S},{default:t(()=>[...L[21]||(L[21]=[n(" Post übernehmen ",-1)])]),_:1})):U("",!0)]),_:1})):(o(),N(ce,{key:1,class:"topic-detail-modal__footer pa-4"},{default:t(()=>[e(Z),e(j,{variant:"text",size:"small",onClick:D},{default:t(()=>[...L[22]||(L[22]=[n(" Schließen ",-1)])]),_:1})]),_:1}))]),_:1})):U("",!0)]),_:1},8,["model-value"])}}}),Op=Me(Fp,[["__scopeId","data-v-648e2271"]]),Rp={class:"content-plan-header mb-3"},Kp={class:"text-h5 font-weight-bold"},jp={class:"text-body-2 text-medium-emphasis mt-1"},qp={key:0,class:"d-flex align-center ga-2 text-caption text-medium-emphasis mt-2"},Gp=Ae({__name:"ContentPlanHeader",props:{plan:{},frequencyLabel:{},formatDate:{type:Function}},emits:["edit"],setup(r,{emit:$}){const d=[{key:"elaboration",label:"Themen-Generierung",defaults:{temperature:.8,maxTokens:8192}},{key:"chat",label:"Chat / Verfeinerung",defaults:{temperature:.7,maxTokens:4096}}],c=$;return(s,m)=>{var _,k,i,g,x,w;const u=l("v-tooltip"),f=l("v-icon"),p=l("v-btn");return o(),h("div",Rp,[a("div",null,[a("h1",Kp,v(r.plan.name),1),a("p",jp,[n(v(r.formatDate((_=r.plan.period)==null?void 0:_.startDate))+" – "+v(r.formatDate((k=r.plan.period)==null?void 0:k.endDate))+"  ·  "+v(r.frequencyLabel)+" ",1),e(p,{icon:"",variant:"text",size:"x-small",class:"ml-1","aria-label":"Plan bearbeiten",onClick:m[0]||(m[0]=b=>c("edit"))},{default:t(()=>[e(u,{activator:"parent",location:"bottom"},{default:t(()=>[...m[1]||(m[1]=[n("Plan bearbeiten",-1)])]),_:1}),e(f,{size:"14"},{default:t(()=>[...m[2]||(m[2]=[n("mdi-pencil",-1)])]),_:1})]),_:1})]),r.plan._id?(o(),h("div",qp,[m[3]||(m[3]=a("span",null,"Erstellt:",-1)),e(gt,{"user-id":((i=r.plan.createdBy)==null?void 0:i._id)??r.plan.createdBy??null,populated:(g=r.plan.createdBy)!=null&&g.firstName?r.plan.createdBy:null,size:24},null,8,["user-id","populated"]),m[4]||(m[4]=a("span",{class:"mx-1"},"·",-1)),m[5]||(m[5]=a("span",null,"Geändert:",-1)),e(gt,{"user-id":((x=r.plan.updatedBy)==null?void 0:x._id)??r.plan.updatedBy??null,populated:(w=r.plan.updatedBy)!=null&&w.firstName?r.plan.updatedBy:null,size:24},null,8,["user-id","populated"])])):U("",!0)]),e(ta,{"page-key":"content-plan","page-label":"Content-Plan KI-Einstellungen",usecases:d})])}}}),Hp=Me(Gp,[["__scopeId","data-v-2059af2c"]]),Wp={class:"d-flex align-center text-subtitle-1 font-weight-semibold"},Zp={class:"text-caption d-block mb-2"},Jp={class:"d-flex flex-wrap ga-2"},Qp={class:"content-plan-chat-panel__messages"},Yp={key:0,class:"d-flex justify-center pa-6"},Xp={key:1,class:"text-center pa-6 text-body-2 text-medium-emphasis"},ef={class:"content-plan-chat-panel__message-bubble"},tf=["innerHTML"],af={key:1,class:"content-plan-chat-panel__inline-cards mt-3"},lf={class:"d-flex align-start justify-space-between ga-2"},nf={style:{flex:"1","min-width":"0"}},of={class:"text-body-2 font-weight-semibold mb-1"},sf={class:"d-flex align-center flex-wrap ga-1"},rf={key:0,class:"text-caption text-medium-emphasis"},df={key:1,class:"text-caption text-medium-emphasis"},uf={key:0,class:"text-caption text-medium-emphasis mt-1"},cf={class:"d-flex ga-1 flex-shrink-0 align-center"},mf={key:2,class:"content-plan-chat-panel__inline-cards mt-3"},vf={class:"d-flex align-start justify-space-between ga-2"},pf={style:{flex:"1","min-width":"0"}},ff={class:"text-body-2 font-weight-semibold mb-1"},gf={class:"d-flex align-center ga-1"},bf={class:"text-caption text-medium-emphasis"},yf={key:0,class:"text-caption text-medium-emphasis"},_f={class:"d-flex ga-1 flex-shrink-0 align-center"},kf={key:3,class:"content-plan-chat-panel__cta-chips mt-3"},hf=["innerHTML"],xf={key:2,class:"content-plan-chat-panel__message-text"},wf={key:3,class:"content-plan-chat-panel__message-time"},Sf={class:"content-plan-chat-panel__input pa-3"},$f=Ae({__name:"ContentPlanChatPanel",props:{messages:{},loading:{type:Boolean},sending:{type:Boolean},clearing:{type:Boolean},error:{},promptHintGroups:{},hasMarkers:{type:Function},getTopicCurrentStatus:{type:Function},renderMarkdown:{type:Function},stripMarkers:{type:Function},updatingTopics:{type:Boolean}},emits:["send","usePromptHint","clearChat","clearError","deleteMessage","ctaClick","topicAction"],setup(r,{expose:$,emit:d}){const{formatDate:c,truncateText:s}=ka(),m=r,u=d,f=y(""),p=y(!1),_=y(null);function k(b){return b?new Intl.DateTimeFormat("de-DE",{hour:"2-digit",minute:"2-digit"}).format(new Date(b)):""}function i(b){b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),g())}function g(){if(!f.value.trim()||m.sending)return;const b=f.value.trim();f.value="",u("send",b),Wt(()=>{_.value&&_.value.scrollIntoView({behavior:"smooth"})})}function x(b){f.value=b,p.value=!1,u("usePromptHint",b),f.value=""}function w(){_.value&&_.value.scrollIntoView({behavior:"smooth"})}return $({scrollToBottom:w}),(b,I)=>{const V=l("v-icon"),E=l("v-tooltip"),R=l("v-btn"),M=l("v-chip"),T=l("v-card"),D=l("v-menu"),H=l("v-card-title"),O=l("v-divider"),S=l("v-alert"),B=l("v-progress-circular"),G=l("v-textarea");return o(),N(T,{variant:"outlined",class:"content-plan-chat-panel h-100"},{default:t(()=>[e(H,{class:"pa-4 pb-3 d-flex align-center justify-space-between"},{default:t(()=>[a("div",Wp,[e(V,{class:"mr-2",size:"18"},{default:t(()=>[...I[4]||(I[4]=[n("mdi-chat-outline",-1)])]),_:1}),I[7]||(I[7]=n(" KI-Chat ",-1)),e(D,{modelValue:p.value,"onUpdate:modelValue":I[0]||(I[0]=W=>p.value=W),location:"bottom start","close-on-content-click":!1},{activator:t(({props:W})=>[e(R,Vt(W,{icon:"",variant:"text",size:"small",class:["ml-1 content-plan-chat-panel__prompt-btn",{"content-plan-chat-panel__prompt-btn--active":p.value}],"aria-label":"Prompt-Vorlagen"}),{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[...I[5]||(I[5]=[n("Prompt-Vorlagen",-1)])]),_:1}),e(V,{size:"20"},{default:t(()=>[...I[6]||(I[6]=[n("mdi-lightbulb-on",-1)])]),_:1})]),_:1},16,["class"])]),default:t(()=>[e(T,{class:"content-plan-chat-panel__prompt-hints pa-3",color:"surface-variant"},{default:t(()=>[(o(!0),h(be,null,Pe(r.promptHintGroups,W=>(o(),h("div",{key:W.label,class:"mb-4"},[a("span",Zp,v(W.label),1),a("div",Jp,[(o(!0),h(be,null,Pe(W.hints,F=>(o(),N(M,{key:F,size:"small",variant:"tonal",color:"primary",class:"content-plan-chat-panel__prompt-chip",disabled:r.sending,onClick:L=>x(F)},{default:t(()=>[n(v(F),1)]),_:2},1032,["disabled","onClick"]))),128))])]))),128))]),_:1})]),_:1},8,["modelValue"])]),r.messages.length>0?(o(),N(R,{key:0,icon:"",variant:"text",size:"x-small",color:"error",loading:r.clearing,"aria-label":"Chat leeren",onClick:I[1]||(I[1]=W=>u("clearChat"))},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[...I[8]||(I[8]=[n("Chat leeren",-1)])]),_:1}),e(V,{size:"16"},{default:t(()=>[...I[9]||(I[9]=[n("mdi-delete-sweep-outline",-1)])]),_:1})]),_:1},8,["loading"])):U("",!0)]),_:1}),e(O),r.error?(o(),N(S,{key:0,type:"error",variant:"tonal",density:"compact",class:"ma-3",closable:"","onClick:close":I[2]||(I[2]=W=>u("clearError"))},{default:t(()=>[n(v(r.error),1)]),_:1})):U("",!0),a("div",Qp,[r.loading?(o(),h("div",Yp,[e(B,{indeterminate:"",color:"primary",size:"24"})])):r.messages.length?(o(!0),h(be,{key:2},Pe(r.messages,(W,F)=>(o(),h("div",{key:F,class:ft(["content-plan-chat-panel__message",[`content-plan-chat-panel__message--${W.role}`,{"content-plan-chat-panel__message--streaming":String(W._id||"").startsWith("streaming_")}]])},[a("div",ef,[e(R,{icon:"",variant:"text",size:"x-small",class:"content-plan-chat-panel__message-delete","aria-label":"Nachricht löschen",onClick:dt(L=>u("deleteMessage",{msg:W,index:F}),["stop"])},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[...I[10]||(I[10]=[n("Nachricht löschen",-1)])]),_:1}),e(V,{size:"14"},{default:t(()=>[...I[11]||(I[11]=[n("mdi-trash-can-outline",-1)])]),_:1})]),_:1},8,["onClick"]),W.role==="assistant"&&W.extractedMarkers&&r.hasMarkers(W.extractedMarkers)?(o(),h(be,{key:0},[W.extractedMarkers.cleanContent?(o(),h("div",{key:0,class:"content-plan-chat-panel__message-text",innerHTML:r.renderMarkdown(W.extractedMarkers.cleanContent)},null,8,tf)):U("",!0),W.extractedMarkers.topics&&W.extractedMarkers.topics.length?(o(),h("div",af,[(o(!0),h(be,null,Pe(W.extractedMarkers.topics,(L,A)=>(o(),h("div",{key:A,class:ft(["content-plan-chat-panel__topic-card--inline",{"content-plan-chat-panel__topic-card--drafted":r.getTopicCurrentStatus(L.title)==="drafted","content-plan-chat-panel__topic-card--accepted":r.getTopicCurrentStatus(L.title)==="accepted","content-plan-chat-panel__topic-card--skipped":r.getTopicCurrentStatus(L.title)==="skipped","content-plan-chat-panel__topic-card--generating":r.getTopicCurrentStatus(L.title)==="generating"}])},[a("div",lf,[a("div",nf,[a("p",of,v(L.title),1),a("div",sf,[L.category?(o(),h("span",rf,v(L.category),1)):U("",!0),L.suggestedDate?(o(),h("span",df,"· "+v(P(c)(L.suggestedDate)),1)):U("",!0)]),L.description?(o(),h("p",uf,v(P(s)(L.description,120)),1)):U("",!0)]),a("div",cf,[r.getTopicCurrentStatus(L.title)==="generating"?(o(),N(B,{key:0,indeterminate:"",size:"14",width:"2",color:"primary"})):r.getTopicCurrentStatus(L.title)==="drafted"?(o(),h(be,{key:1},[e(R,{icon:"",variant:"text",size:"x-small",color:"success","aria-label":"Akzeptieren",loading:r.updatingTopics,onClick:z=>u("topicAction",{type:"accept",topicTitle:L.title})},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[...I[12]||(I[12]=[n("Akzeptieren",-1)])]),_:1}),e(V,{size:"14"},{default:t(()=>[...I[13]||(I[13]=[n("mdi-check",-1)])]),_:1})]),_:1},8,["loading","onClick"]),e(R,{icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Verwerfen",loading:r.updatingTopics,onClick:z=>u("topicAction",{type:"skip",topicTitle:L.title})},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[...I[14]||(I[14]=[n("Verwerfen",-1)])]),_:1}),e(V,{size:"14"},{default:t(()=>[...I[15]||(I[15]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["loading","onClick"])],64)):r.getTopicCurrentStatus(L.title)==="accepted"?(o(),N(R,{key:2,icon:"",variant:"text",size:"x-small",color:"success","aria-label":"Akzeptiert – klicken zum Zurücksetzen",onClick:z=>u("topicAction",{type:"undo",topicTitle:L.title})},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[...I[16]||(I[16]=[n("Akzeptiert – klicken zum Zurücksetzen",-1)])]),_:1}),e(V,{size:"16"},{default:t(()=>[...I[17]||(I[17]=[n("mdi-check-circle",-1)])]),_:1})]),_:1},8,["onClick"])):r.getTopicCurrentStatus(L.title)==="skipped"?(o(),N(R,{key:3,icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Verworfen – klicken zum Zurücksetzen",onClick:z=>u("topicAction",{type:"undo",topicTitle:L.title})},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[...I[18]||(I[18]=[n("Verworfen – klicken zum Zurücksetzen",-1)])]),_:1}),e(V,{size:"16"},{default:t(()=>[...I[19]||(I[19]=[n("mdi-close-circle",-1)])]),_:1})]),_:1},8,["onClick"])):(o(),h(be,{key:4},[e(R,{icon:"",variant:"text",size:"x-small",color:"success","aria-label":"Akzeptieren",loading:r.updatingTopics,onClick:z=>u("topicAction",{type:"accept",topicTitle:L.title})},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[...I[20]||(I[20]=[n("Akzeptieren",-1)])]),_:1}),e(V,{size:"14"},{default:t(()=>[...I[21]||(I[21]=[n("mdi-check",-1)])]),_:1})]),_:1},8,["loading","onClick"]),e(R,{icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Verwerfen",loading:r.updatingTopics,onClick:z=>u("topicAction",{type:"skip",topicTitle:L.title})},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[...I[22]||(I[22]=[n("Verwerfen",-1)])]),_:1}),e(V,{size:"14"},{default:t(()=>[...I[23]||(I[23]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["loading","onClick"])],64))])])],2))),128))])):U("",!0),W.extractedMarkers.posts&&W.extractedMarkers.posts.length?(o(),h("div",mf,[(o(!0),h(be,null,Pe(W.extractedMarkers.posts,(L,A)=>(o(),h("div",{key:A,class:ft(["content-plan-chat-panel__post-card--inline",{"content-plan-chat-panel__post-card--accepted":r.getTopicCurrentStatus(L.topicTitle)==="accepted","content-plan-chat-panel__post-card--skipped":r.getTopicCurrentStatus(L.topicTitle)==="skipped"}])},[a("div",vf,[a("div",pf,[a("p",ff,v(L.topicTitle),1),a("div",gf,[a("span",bf,v(L.text.length)+" / 3.000 Zeichen",1),L.text.length>0?(o(),h("span",yf," · "+v(P(s)(L.text,80)),1)):U("",!0)])]),a("div",_f,[r.getTopicCurrentStatus(L.topicTitle)==="accepted"?(o(),N(R,{key:0,icon:"",variant:"text",size:"x-small",color:"success","aria-label":"Akzeptiert – klicken zum Zurücksetzen",onClick:z=>u("topicAction",{type:"undo",topicTitle:L.topicTitle})},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[...I[24]||(I[24]=[n("Akzeptiert – klicken zum Zurücksetzen",-1)])]),_:1}),e(V,{size:"14"},{default:t(()=>[...I[25]||(I[25]=[n("mdi-check-circle",-1)])]),_:1})]),_:1},8,["onClick"])):r.getTopicCurrentStatus(L.topicTitle)==="skipped"?(o(),N(R,{key:1,icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Verworfen – klicken zum Zurücksetzen",onClick:z=>u("topicAction",{type:"undo",topicTitle:L.topicTitle})},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[...I[26]||(I[26]=[n("Verworfen – klicken zum Zurücksetzen",-1)])]),_:1}),e(V,{size:"14"},{default:t(()=>[...I[27]||(I[27]=[n("mdi-close-circle",-1)])]),_:1})]),_:1},8,["onClick"])):(o(),h(be,{key:2},[e(R,{icon:"",variant:"text",size:"x-small",color:"success","aria-label":"Akzeptieren",loading:r.updatingTopics,onClick:z=>u("topicAction",{type:"accept",topicTitle:L.topicTitle})},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[...I[28]||(I[28]=[n("Akzeptieren",-1)])]),_:1}),e(V,{size:"14"},{default:t(()=>[...I[29]||(I[29]=[n("mdi-check",-1)])]),_:1})]),_:1},8,["loading","onClick"]),e(R,{icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Verwerfen",loading:r.updatingTopics,onClick:z=>u("topicAction",{type:"skip",topicTitle:L.topicTitle})},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[...I[30]||(I[30]=[n("Verwerfen",-1)])]),_:1}),e(V,{size:"14"},{default:t(()=>[...I[31]||(I[31]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["loading","onClick"])],64))])])],2))),128))])):U("",!0),W.extractedMarkers.ctas&&W.extractedMarkers.ctas.length?(o(),h("div",kf,[(o(!0),h(be,null,Pe(W.extractedMarkers.ctas,(L,A)=>(o(),N(M,{key:A,size:"small",variant:"outlined",color:"primary",class:"content-plan-chat-panel__cta-chip",disabled:r.sending,onClick:z=>u("ctaClick",L.action)},{default:t(()=>[n(v(L.label),1)]),_:2},1032,["disabled","onClick"]))),128))])):U("",!0)],64)):W.role==="assistant"?(o(),h("div",{key:1,class:"content-plan-chat-panel__message-text",innerHTML:r.renderMarkdown(r.stripMarkers(W.content))},null,8,hf)):(o(),h("div",xf,v(W.content),1)),W.createdAt?(o(),h("div",wf,v(k(W.createdAt)),1)):U("",!0)])],2))),128)):(o(),h("div",Xp," Noch keine Nachrichten. Beschreibe deinen Content-Plan und die KI schlägt Topics vor. ")),a("div",{ref_key:"chatEndRef",ref:_},null,512)]),e(O),a("div",Sf,[e(G,{modelValue:f.value,"onUpdate:modelValue":I[3]||(I[3]=W=>f.value=W),placeholder:"Nachricht eingeben (Enter zum Senden, Shift+Enter für Zeilenumbruch)...",variant:"outlined",density:"compact",rows:"2","auto-grow":"","max-rows":"5","hide-details":"",disabled:r.sending,onKeydown:i},null,8,["modelValue","disabled"]),e(R,{color:"primary",loading:r.sending,disabled:!f.value.trim(),icon:"",class:"ml-2","aria-label":"Nachricht senden",onClick:g},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[...I[32]||(I[32]=[n("Nachricht senden",-1)])]),_:1}),e(V,null,{default:t(()=>[...I[33]||(I[33]=[n("mdi-send",-1)])]),_:1})]),_:1},8,["loading","disabled"])])]),_:1})}}}),Cf=Me($f,[["__scopeId","data-v-7078c0fc"]]),Vf={class:"pa-4 pb-3 d-flex align-center justify-space-between"},Af={class:"text-subtitle-1 font-weight-semibold"},If={key:0,class:"d-flex align-center ga-2"},Pf={class:"text-caption text-medium-emphasis"},zf={key:2,class:"pa-4 pb-2"},Df={class:"d-flex align-center justify-space-between mb-1"},Tf={class:"text-caption text-medium-emphasis"},Lf={key:3,class:"pa-4 pb-2"},Ef={class:"d-flex align-center justify-space-between mb-1"},Mf={class:"text-caption text-medium-emphasis"},Nf={class:"d-flex align-center ga-3"},Uf={class:"text-caption text-primary"},Bf=Ae({__name:"ContentPlanTabsPanel",props:{plan:{},activeTab:{},topicsCount:{},postsCount:{},lpCount:{},topicError:{},elaborationError:{},elaborationSuccess:{type:Boolean},elaborationRunning:{type:Boolean},generatingLpForTopic:{},generatingTopicsCount:{},elaborating:{type:Boolean}},emits:["update:activeTab","update:elaborationSuccess","clearTopicError","clearElaborationError","startElaboration","showResetDialog"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-icon"),u=l("v-progress-circular"),f=l("v-btn"),p=l("v-tab"),_=l("v-tabs"),k=l("v-divider"),i=l("v-alert"),g=l("v-snackbar"),x=l("v-progress-linear"),w=l("v-tabs-window-item"),b=l("v-tabs-window"),I=l("v-card");return o(),N(I,{variant:"outlined",class:"content-plan-tabs-panel__card"},{default:t(()=>{var V,E,R,M,T,D,H,O;return[a("div",Vf,[a("span",Af,[e(m,{class:"mr-2",size:"18"},{default:t(()=>[...s[7]||(s[7]=[n("mdi-format-list-bulleted",-1)])]),_:1}),s[8]||(s[8]=n(" Inhalte ",-1))]),r.elaborationRunning||r.generatingTopicsCount>0?(o(),h("div",If,[e(u,{indeterminate:"",size:"16",width:"2",color:"primary"}),a("span",Pf," Generiere "+v(((V=r.plan.elaboration)==null?void 0:V.completed)??0)+"/"+v(((E=r.plan.elaboration)==null?void 0:E.total)??"?")+"... ",1)])):((R=r.plan.elaboration)==null?void 0:R.status)==="failed"?(o(),N(f,{key:1,color:"error",size:"small",variant:"tonal","prepend-icon":"mdi-refresh",loading:r.elaborating,onClick:s[0]||(s[0]=S=>d("startElaboration"))},{default:t(()=>[...s[9]||(s[9]=[n(" Erneut generieren ",-1)])]),_:1},8,["loading"])):U("",!0)]),e(_,{"model-value":r.activeTab,density:"compact",color:"primary",class:"px-2","onUpdate:modelValue":s[1]||(s[1]=S=>d("update:activeTab",S))},{default:t(()=>[e(p,{value:0},{default:t(()=>[n("Topics ("+v(r.topicsCount)+")",1)]),_:1}),e(p,{value:1},{default:t(()=>[n("Posts ("+v(r.postsCount)+")",1)]),_:1}),e(p,{value:2},{default:t(()=>[n("Landing Pages ("+v(r.lpCount)+")",1)]),_:1})]),_:1},8,["model-value"]),e(k),r.topicError?(o(),N(i,{key:0,type:"error",variant:"tonal",density:"compact",class:"ma-3",closable:"","onClick:close":s[2]||(s[2]=S=>d("clearTopicError"))},{default:t(()=>[n(v(r.topicError),1)]),_:1})):U("",!0),r.elaborationError?(o(),N(i,{key:1,type:"error",variant:"tonal",density:"compact",class:"ma-3",closable:"","onClick:close":s[3]||(s[3]=S=>d("clearElaborationError"))},{default:t(()=>[n(v(r.elaborationError),1)]),_:1})):U("",!0),e(g,{"model-value":r.elaborationSuccess,color:"success",location:"top end",timeout:4e3,"onUpdate:modelValue":s[5]||(s[5]=S=>d("update:elaborationSuccess",S))},{actions:t(()=>[e(f,{variant:"text",onClick:s[4]||(s[4]=S=>d("update:elaborationSuccess",!1))},{default:t(()=>[e(m,null,{default:t(()=>[...s[10]||(s[10]=[n("mdi-close",-1)])]),_:1})]),_:1})]),default:t(()=>[s[11]||(s[11]=n(" Ausarbeitung abgeschlossen! Posts wurden erstellt. ",-1))]),_:1},8,["model-value"]),r.generatingLpForTopic?(o(),h("div",zf,[a("div",Df,[a("span",Tf," Landing Page wird generiert: "+v(r.generatingLpForTopic),1)]),e(x,{indeterminate:"",color:"info",height:"6",rounded:"",striped:""})])):U("",!0),r.elaborationRunning?(o(),h("div",Lf,[a("div",Ef,[a("span",Mf,v(((M=r.plan.elaboration)==null?void 0:M.message)||"Ausarbeitung läuft..."),1),a("div",Nf,[a("span",Uf,v((T=r.plan.elaboration)!=null&&T.total?Math.round((((D=r.plan.elaboration)==null?void 0:D.completed)??0)/r.plan.elaboration.total*100):0)+"% ",1),e(f,{size:"x-small",variant:"text",color:"error",icon:"mdi-close-circle-outline",onClick:s[6]||(s[6]=S=>d("showResetDialog"))})])]),e(x,{"model-value":(H=r.plan.elaboration)!=null&&H.total?(((O=r.plan.elaboration)==null?void 0:O.completed)??0)/r.plan.elaboration.total*100:0,color:"primary",height:"6",rounded:"",striped:""},null,8,["model-value"])])):U("",!0),e(b,{"model-value":r.activeTab},{default:t(()=>[e(w,{value:0},{default:t(()=>[Xt(c.$slots,"topics",{},void 0,!0)]),_:3}),e(w,{value:1},{default:t(()=>[Xt(c.$slots,"posts",{},void 0,!0)]),_:3}),e(w,{value:2},{default:t(()=>[Xt(c.$slots,"landingPages",{},void 0,!0)]),_:3})]),_:3},8,["model-value"])]}),_:3})}}}),Ff=Me(Bf,[["__scopeId","data-v-dfb4335c"]]),Of={key:0,class:"text-center pa-8 text-body-2 text-medium-emphasis"},Rf={key:1,class:"content-plan-topics-list"},Kf={key:0,class:"pa-4 pb-2"},jf={class:"text-caption text-medium-emphasis text-uppercase mb-2"},qf={class:"content-plan-topic-info"},Gf={class:"d-flex align-center ga-2 mb-0"},Hf={class:"text-body-2 font-weight-medium mb-0"},Wf={key:0,class:"text-caption text-medium-emphasis"},Zf={key:1,class:"pa-4 pb-2"},Jf={class:"text-caption text-medium-emphasis text-uppercase mb-2"},Qf=["onClick"],Yf={class:"content-plan-topic-info"},Xf={class:"d-flex align-center ga-1 mb-0"},eg={class:"text-body-2 font-weight-medium mb-0"},tg={key:0,class:"content-plan-status-dot content-plan-status-dot--gold",title:"Post-Entwurf vorhanden"},ag={key:0,class:"text-caption text-medium-emphasis"},lg={key:2,class:"pa-4 pb-2"},ng={class:"text-caption text-medium-emphasis text-uppercase mb-2"},og=["onClick"],sg={class:"content-plan-topic-info"},ig={class:"d-flex align-center ga-1 mb-1"},rg={class:"text-body-2 font-weight-medium mb-0"},dg={key:0,class:"content-plan-status-dot content-plan-status-dot--gold",title:"Post-Entwurf vorhanden"},ug={key:1,class:"content-plan-status-dot content-plan-status-dot--green",title:"Landing Page vorhanden"},cg={class:"d-flex align-center ga-1"},mg={key:0,class:"text-caption text-medium-emphasis"},vg={key:3,class:"pa-4 pt-2 pb-2"},pg={class:"text-caption text-medium-emphasis text-uppercase mb-2"},fg=["onClick"],gg={class:"content-plan-topic-info"},bg={class:"d-flex align-center ga-1 mb-0"},yg={class:"text-body-2 font-weight-medium mb-0"},_g={key:0,class:"content-plan-status-dot content-plan-status-dot--gold",title:"Post-Entwurf vorhanden"},kg={key:1,class:"content-plan-status-dot content-plan-status-dot--green",title:"Landing Page vorhanden"},hg={key:0,class:"text-caption text-medium-emphasis"},xg={key:4,class:"pa-4 pt-2"},wg={class:"d-flex align-center justify-space-between mb-2"},Sg={class:"text-caption text-medium-emphasis text-uppercase mb-0"},$g=["onClick"],Cg={class:"content-plan-topic-info"},Vg={class:"text-body-2 font-weight-medium mb-0"},Ag=Ae({__name:"ContentPlanTopicsTab",props:{generatingTopics:{},draftedTopics:{},acceptedTopics:{},suggestedTopics:{},skippedTopics:{},updatingTopics:{type:Boolean},formatDate:{type:Function},getTopicStatusColor:{type:Function},getTopicStatusLabel:{type:Function}},emits:["openTopic","updateTopicStatus","confirmUndo","generatePost","generateLp","acceptAll","deleteSkipped"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-icon"),u=l("v-progress-circular"),f=l("v-tooltip"),p=l("v-btn"),_=l("v-chip");return r.generatingTopics.length===0&&r.draftedTopics.length===0&&r.acceptedTopics.length===0&&r.suggestedTopics.length===0&&r.skippedTopics.length===0?(o(),h("div",Of,[e(m,{size:"40",color:"medium-emphasis",class:"mb-3"},{default:t(()=>[...s[3]||(s[3]=[n("mdi-lightbulb-outline",-1)])]),_:1}),s[4]||(s[4]=a("p",null,"Noch keine Topics vorhanden.",-1)),s[5]||(s[5]=a("p",null,"Beschreibe im Chat deinen Content-Plan und die KI schlägt Topics vor.",-1))])):(o(),h("div",Rf,[r.generatingTopics.length?(o(),h("div",Kf,[a("p",jf," Wird generiert ("+v(r.generatingTopics.length)+") ",1),(o(!0),h(be,null,Pe(r.generatingTopics,k=>(o(),h("div",{key:(k._id||k.title)+"-generating",class:"content-plan-topic-item content-plan-topic-item--generating"},[a("div",qf,[a("div",Gf,[e(u,{indeterminate:"",size:"14",width:"2",color:"primary"}),a("p",Hf,v(k.title),1)]),k.suggestedDate?(o(),h("span",Wf,v(r.formatDate(k.suggestedDate)),1)):U("",!0)])]))),128))])):U("",!0),r.draftedTopics.length?(o(),h("div",Zf,[a("p",Jf," Entwürfe ("+v(r.draftedTopics.length)+") ",1),(o(!0),h(be,null,Pe(r.draftedTopics,k=>(o(),h("div",{key:(k._id||k.title)+"-drafted",class:"content-plan-topic-item content-plan-topic-item--drafted",onClick:i=>d("openTopic",k)},[a("div",Yf,[a("div",Xf,[a("p",eg,v(k.title),1),k.postText?(o(),h("span",tg)):U("",!0)]),k.scheduledDate||k.suggestedDate?(o(),h("span",ag,v(r.formatDate(k.scheduledDate||k.suggestedDate||"")),1)):U("",!0)]),a("div",{class:"content-plan-topic-actions",onClick:s[0]||(s[0]=dt(()=>{},["stop"]))},[e(p,{icon:"",variant:"text",size:"x-small",color:"success","aria-label":"Akzeptieren",loading:r.updatingTopics,onClick:i=>d("updateTopicStatus",{topic:k,status:"accepted"})},{default:t(()=>[e(f,{activator:"parent",location:"bottom"},{default:t(()=>[...s[6]||(s[6]=[n("Akzeptieren",-1)])]),_:1}),e(m,{size:"16"},{default:t(()=>[...s[7]||(s[7]=[n("mdi-check",-1)])]),_:1})]),_:1},8,["loading","onClick"]),e(p,{icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Verwerfen",loading:r.updatingTopics,onClick:i=>d("updateTopicStatus",{topic:k,status:"skipped"})},{default:t(()=>[e(f,{activator:"parent",location:"bottom"},{default:t(()=>[...s[8]||(s[8]=[n("Verwerfen",-1)])]),_:1}),e(m,{size:"16"},{default:t(()=>[...s[9]||(s[9]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["loading","onClick"])])],8,Qf))),128))])):U("",!0),r.suggestedTopics.length?(o(),h("div",lg,[a("p",ng," Vorgeschlagen ("+v(r.suggestedTopics.length)+") ",1),(o(!0),h(be,null,Pe(r.suggestedTopics,k=>(o(),h("div",{key:k._id||k.title,class:"content-plan-topic-item",onClick:i=>d("openTopic",k)},[a("div",sg,[a("div",ig,[a("p",rg,v(k.title),1),k.postText?(o(),h("span",dg)):U("",!0),k.landingPagePreview?(o(),h("span",ug)):U("",!0)]),a("div",cg,[e(_,{color:r.getTopicStatusColor(k.status),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(r.getTopicStatusLabel(k.status)),1)]),_:2},1032,["color"]),k.scheduledDate||k.suggestedDate?(o(),h("span",mg," · "+v(r.formatDate(k.scheduledDate||k.suggestedDate||"")),1)):U("",!0)])]),a("div",{class:"content-plan-topic-actions",onClick:s[1]||(s[1]=dt(()=>{},["stop"]))},[e(p,{icon:"",variant:"text",size:"x-small",color:"success","aria-label":"Akzeptieren",loading:r.updatingTopics,onClick:i=>d("updateTopicStatus",{topic:k,status:"accepted"})},{default:t(()=>[e(f,{activator:"parent",location:"bottom"},{default:t(()=>[...s[10]||(s[10]=[n("Akzeptieren",-1)])]),_:1}),e(m,{size:"16"},{default:t(()=>[...s[11]||(s[11]=[n("mdi-check",-1)])]),_:1})]),_:1},8,["loading","onClick"]),e(p,{icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Verwerfen",loading:r.updatingTopics,onClick:i=>d("updateTopicStatus",{topic:k,status:"skipped"})},{default:t(()=>[e(f,{activator:"parent",location:"bottom"},{default:t(()=>[...s[12]||(s[12]=[n("Verwerfen",-1)])]),_:1}),e(m,{size:"16"},{default:t(()=>[...s[13]||(s[13]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["loading","onClick"])])],8,og))),128))])):U("",!0),r.acceptedTopics.length?(o(),h("div",vg,[a("p",pg," Akzeptiert ("+v(r.acceptedTopics.length)+") ",1),(o(!0),h(be,null,Pe(r.acceptedTopics,k=>(o(),h("div",{key:(k._id||k.title)+"-accepted",class:"content-plan-topic-item content-plan-topic-item--accepted",onClick:i=>d("openTopic",k)},[a("div",gg,[a("div",bg,[a("p",yg,v(k.title),1),k.postText?(o(),h("span",_g)):U("",!0),k.landingPagePreview?(o(),h("span",kg)):U("",!0)]),k.scheduledDate||k.suggestedDate?(o(),h("span",hg,v(r.formatDate(k.scheduledDate||k.suggestedDate||"")),1)):U("",!0)]),e(p,{icon:"",variant:"text",size:"x-small",color:"success","aria-label":"Akzeptiert – klicken zum Zurücksetzen",onClick:dt(i=>d("confirmUndo",k.title),["stop"])},{default:t(()=>[e(f,{activator:"parent",location:"bottom"},{default:t(()=>[...s[14]||(s[14]=[n("Akzeptiert – klicken zum Zurücksetzen",-1)])]),_:1}),e(m,{size:"16"},{default:t(()=>[...s[15]||(s[15]=[n("mdi-check-circle",-1)])]),_:1})]),_:1},8,["onClick"])],8,fg))),128))])):U("",!0),r.skippedTopics.length?(o(),h("div",xg,[a("div",wg,[a("p",Sg," Verworfen ("+v(r.skippedTopics.length)+") ",1),e(p,{variant:"text",size:"x-small",color:"error",loading:r.updatingTopics,onClick:s[2]||(s[2]=k=>d("deleteSkipped"))},{default:t(()=>[...s[16]||(s[16]=[n(" Alle entfernen ",-1)])]),_:1},8,["loading"])]),(o(!0),h(be,null,Pe(r.skippedTopics,k=>(o(),h("div",{key:(k._id||k.title)+"-skipped",class:"content-plan-topic-item content-plan-topic-item--skipped",onClick:i=>d("openTopic",k)},[a("div",Cg,[a("p",Vg,v(k.title),1)]),e(p,{icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Verworfen – klicken zum Zurücksetzen",onClick:dt(i=>d("confirmUndo",k.title),["stop"])},{default:t(()=>[e(f,{activator:"parent",location:"bottom"},{default:t(()=>[...s[17]||(s[17]=[n("Verworfen – klicken zum Zurücksetzen",-1)])]),_:1}),e(m,{size:"16"},{default:t(()=>[...s[18]||(s[18]=[n("mdi-close-circle",-1)])]),_:1})]),_:1},8,["onClick"])],8,$g))),128))])):U("",!0)]))}}}),Ig=Me(Ag,[["__scopeId","data-v-42c7846d"]]),Pg={key:0,class:"text-center pa-8 text-body-2 text-medium-emphasis"},zg={key:1,class:"content-plan-topics-list pa-4"},Dg=["onClick"],Tg={class:"d-flex align-start ga-3"},Lg={class:"content-plan-post-item__thumb"},Eg=["title"],Mg={key:2,class:"content-plan-post-item__thumb-placeholder",title:"Kein Bild und kein Vorschlag"},Ng={class:"flex-grow-1",style:{"min-width":"0"}},Ug={class:"d-flex align-start justify-space-between ga-2 mb-1"},Bg={class:"text-body-2 font-weight-semibold mb-0"},Fg={class:"d-flex align-center ga-2 flex-shrink-0"},Og={class:"text-caption text-medium-emphasis"},Rg={key:0,class:"text-caption text-medium-emphasis content-plan-post-item__preview"},Kg={key:1,class:"d-flex flex-wrap ga-1 mt-1"},jg={key:0,class:"text-caption text-medium-emphasis"},qg=Ae({__name:"ContentPlanPostsTab",props:{topicsWithPosts:{},truncateText:{type:Function}},emits:["openTopic"],setup(r,{emit:$}){const d=$,{getTopicStatusColor:c,getTopicStatusLabel:s}=ka();function m(p){const _=p.postId;return!_||typeof _=="string"?null:_}function u(p){var k;const _=m(p);return(k=_==null?void 0:_.imageUrl)!=null&&k.trim()?_.imageUrl:null}function f(p){var k;const _=m(p);return(k=_==null?void 0:_.imageGenerationSuggestion)!=null&&k.trim()?_.imageGenerationSuggestion:null}return(p,_)=>{const k=l("v-icon"),i=l("v-img"),g=l("v-chip");return r.topicsWithPosts.length===0?(o(),h("div",Pg,[e(k,{size:"40",color:"medium-emphasis",class:"mb-3"},{default:t(()=>[..._[0]||(_[0]=[n("mdi-pencil-outline",-1)])]),_:1}),_[1]||(_[1]=a("p",null,"Noch keine Post-Entwürfe vorhanden.",-1)),_[2]||(_[2]=a("p",null,"Akzeptiere Topics und starte die Ausarbeitung oder fordere Posts im Chat an.",-1))])):(o(),h("div",zg,[(o(!0),h(be,null,Pe(r.topicsWithPosts,x=>{var w;return o(),h("div",{key:(x._id||x.title)+"-post",class:"content-plan-post-item mb-3",onClick:b=>d("openTopic",x)},[a("div",Tg,[a("div",Lg,[u(x)?(o(),N(i,{key:0,src:u(x),cover:"",width:"56",height:"56",class:"rounded",alt:"Post-Bild"},null,8,["src"])):f(x)?(o(),h("div",{key:1,class:"content-plan-post-item__thumb-placeholder content-plan-post-item__thumb-placeholder--suggestion",title:"KI-Vorschlag: "+f(x)},[e(k,{size:"24"},{default:t(()=>[..._[3]||(_[3]=[n("mdi-lightbulb-on-outline",-1)])]),_:1})],8,Eg)):(o(),h("div",Mg,[e(k,{size:"24"},{default:t(()=>[..._[4]||(_[4]=[n("mdi-image-off-outline",-1)])]),_:1})]))]),a("div",Ng,[a("div",Ug,[a("p",Bg,v(x.title),1),a("div",Fg,[e(g,{color:P(c)(x.status),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(P(s)(x.status)),1)]),_:2},1032,["color"]),a("span",Og,v(((w=x.postText)==null?void 0:w.length)??0)+" / 3.000 ",1)])]),x.postText?(o(),h("p",Rg,v(r.truncateText(x.postText,100)),1)):U("",!0),x.hashtags&&x.hashtags.length?(o(),h("div",Kg,[(o(!0),h(be,null,Pe(x.hashtags.slice(0,3),b=>(o(),N(g,{key:b,size:"x-small",variant:"tonal",color:"default"},{default:t(()=>[n(v(b),1)]),_:2},1024))),128)),x.hashtags.length>3?(o(),h("span",jg,"+"+v(x.hashtags.length-3),1)):U("",!0)])):U("",!0)])])],8,Dg)}),128))]))}}}),Gg=Me(qg,[["__scopeId","data-v-e1fa064d"]]),Hg={key:0,class:"text-center pa-8 text-body-2 text-medium-emphasis"},Wg={key:1,class:"content-plan-topics-list pa-4"},Zg=["onClick"],Jg={class:"text-body-2 font-weight-semibold mb-1"},Qg=Ae({__name:"ContentPlanLandingPagesTab",props:{topicsWithLandingPage:{}},emits:["openTopic"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-icon");return r.topicsWithLandingPage.length===0?(o(),h("div",Hg,[e(m,{size:"40",color:"medium-emphasis",class:"mb-3"},{default:t(()=>[...s[0]||(s[0]=[n("mdi-file-document-outline",-1)])]),_:1}),s[1]||(s[1]=a("p",null,"Noch keine Landing Pages vorhanden.",-1)),s[2]||(s[2]=a("p",null,"Fordere Landing Pages für akzeptierte Topics im Chat an.",-1))])):(o(),h("div",Wg,[(o(!0),h(be,null,Pe(r.topicsWithLandingPage,u=>(o(),h("div",{key:(u._id||u.title)+"-lp",class:"content-plan-lp-item mb-3",onClick:f=>d("openTopic",u)},[a("p",Jg,v(u.title),1),s[3]||(s[3]=a("p",{class:"text-caption text-medium-emphasis"},"Landing Page erstellt",-1))],8,Zg))),128))]))}}}),Yg=Me(Qg,[["__scopeId","data-v-a7d1990f"]]),Xg={class:"d-flex align-center justify-space-between"},e1=Ae({__name:"ContentPlanEditDialog",props:{modelValue:{type:Boolean},initialValues:{},saving:{type:Boolean},error:{},frequencyOptions:{}},emits:["update:modelValue","save","clearError"],setup(r,{emit:$}){const d=r,c=$,s=y(!1),m=y({name:"",startDate:"",endDate:"",frequency:""});Ze(()=>d.modelValue,f=>{f&&(m.value={...d.initialValues})});function u(){s.value&&c("save",{...m.value})}return(f,p)=>{const _=l("v-tooltip"),k=l("v-icon"),i=l("v-btn"),g=l("v-card-title"),x=l("v-divider"),w=l("v-alert"),b=l("v-text-field"),I=l("v-col"),V=l("v-select"),E=l("v-row"),R=l("v-form"),M=l("v-card-text"),T=l("v-spacer"),D=l("v-card-actions"),H=l("v-card"),O=l("v-dialog");return o(),N(O,{"model-value":r.modelValue,"max-width":"520",scrollable:"","onUpdate:modelValue":p[8]||(p[8]=S=>c("update:modelValue",S))},{default:t(()=>[e(H,null,{default:t(()=>[e(g,{class:"pa-6 pb-4"},{default:t(()=>[a("div",Xg,[p[11]||(p[11]=a("span",{class:"text-h6"},"Plan bearbeiten",-1)),e(i,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:p[0]||(p[0]=S=>c("update:modelValue",!1))},{default:t(()=>[e(_,{activator:"parent",location:"bottom"},{default:t(()=>[...p[9]||(p[9]=[n("Schließen",-1)])]),_:1}),e(k,null,{default:t(()=>[...p[10]||(p[10]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(x),e(M,{class:"pa-6"},{default:t(()=>[r.error?(o(),N(w,{key:0,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":p[1]||(p[1]=S=>c("clearError"))},{default:t(()=>[n(v(r.error),1)]),_:1})):U("",!0),e(R,{modelValue:s.value,"onUpdate:modelValue":p[6]||(p[6]=S=>s.value=S),onSubmit:dt(u,["prevent"])},{default:t(()=>[e(E,null,{default:t(()=>[e(I,{cols:"12"},{default:t(()=>[e(b,{modelValue:m.value.name,"onUpdate:modelValue":p[2]||(p[2]=S=>m.value.name=S),label:"Plan-Name",rules:[S=>!!S||"Name ist erforderlich",S=>S.length>=3||"Mindestens 3 Zeichen"],variant:"outlined",density:"comfortable"},null,8,["modelValue","rules"])]),_:1}),e(I,{cols:"12",sm:"6"},{default:t(()=>[e(b,{modelValue:m.value.startDate,"onUpdate:modelValue":p[3]||(p[3]=S=>m.value.startDate=S),label:"Startdatum",type:"date",rules:[S=>!!S||"Startdatum ist erforderlich"],variant:"outlined",density:"comfortable"},null,8,["modelValue","rules"])]),_:1}),e(I,{cols:"12",sm:"6"},{default:t(()=>[e(b,{modelValue:m.value.endDate,"onUpdate:modelValue":p[4]||(p[4]=S=>m.value.endDate=S),label:"Enddatum",type:"date",rules:[S=>!!S||"Enddatum ist erforderlich"],variant:"outlined",density:"comfortable"},null,8,["modelValue","rules"])]),_:1}),e(I,{cols:"12"},{default:t(()=>[e(V,{modelValue:m.value.frequency,"onUpdate:modelValue":p[5]||(p[5]=S=>m.value.frequency=S),label:"Veröffentlichungsfrequenz",items:r.frequencyOptions,rules:[S=>!!S||"Frequenz ist erforderlich"],variant:"outlined",density:"comfortable"},null,8,["modelValue","items","rules"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1}),e(x),e(D,{class:"pa-4"},{default:t(()=>[e(T),e(i,{variant:"text",onClick:p[7]||(p[7]=S=>c("update:modelValue",!1))},{default:t(()=>[...p[12]||(p[12]=[n("Abbrechen",-1)])]),_:1}),e(i,{color:"primary",variant:"elevated",loading:r.saving,disabled:!s.value,onClick:u},{default:t(()=>[...p[13]||(p[13]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["model-value"])}}}),t1=Ae({__name:"ContentPlanResetDialog",props:{modelValue:{type:Boolean},resetting:{type:Boolean}},emits:["update:modelValue","confirm"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-card-title"),u=l("v-card-text"),f=l("v-spacer"),p=l("v-btn"),_=l("v-card-actions"),k=l("v-card"),i=l("v-dialog");return o(),N(i,{"model-value":r.modelValue,"max-width":"400","onUpdate:modelValue":s[2]||(s[2]=g=>d("update:modelValue",g))},{default:t(()=>[e(k,{class:"content-plan-reset-dialog"},{default:t(()=>[e(m,{class:"text-subtitle-1 font-weight-semibold pa-4 pb-2"},{default:t(()=>[...s[3]||(s[3]=[n(" Generierung abbrechen? ",-1)])]),_:1}),e(u,{class:"text-body-2 pa-4 pt-0"},{default:t(()=>[...s[4]||(s[4]=[n(" Die laufende Generierung wird abgebrochen. Bereits erstellte Posts bleiben erhalten, noch nicht generierte Topics werden zurückgesetzt. ",-1)])]),_:1}),e(_,{class:"pa-4 pt-0"},{default:t(()=>[e(f),e(p,{variant:"text",size:"small",onClick:s[0]||(s[0]=g=>d("update:modelValue",!1))},{default:t(()=>[...s[5]||(s[5]=[n("Schließen",-1)])]),_:1}),e(p,{color:"error",variant:"tonal",size:"small",loading:r.resetting,onClick:s[1]||(s[1]=g=>d("confirm"))},{default:t(()=>[...s[6]||(s[6]=[n(" Abbrechen ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["model-value"])}}}),a1=Me(t1,[["__scopeId","data-v-3b1c2cb4"]]),l1=Ae({__name:"ContentPlanUndoDialog",props:{topicTitle:{},updatingTopics:{type:Boolean}},emits:["confirm","cancel"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-card-title"),u=l("v-card-text"),f=l("v-spacer"),p=l("v-btn"),_=l("v-card-actions"),k=l("v-card"),i=l("v-dialog");return o(),N(i,{"model-value":!!r.topicTitle,"max-width":"360","onUpdate:modelValue":s[2]||(s[2]=g=>d("cancel"))},{default:t(()=>[e(k,{class:"content-plan-undo-dialog"},{default:t(()=>[e(m,{class:"text-subtitle-1 font-weight-semibold pa-4 pb-2"},{default:t(()=>[...s[3]||(s[3]=[n(" Status zurücksetzen? ",-1)])]),_:1}),e(u,{class:"text-body-2 pa-4 pt-0"},{default:t(()=>[a("strong",null,v(r.topicTitle),1),s[4]||(s[4]=n(" wird wieder als ",-1)),s[5]||(s[5]=a("em",null,"Vorgeschlagen",-1)),s[6]||(s[6]=n(" eingestuft. ",-1))]),_:1}),e(_,{class:"pa-4 pt-0"},{default:t(()=>[e(f),e(p,{variant:"text",size:"small",onClick:s[0]||(s[0]=g=>d("cancel"))},{default:t(()=>[...s[7]||(s[7]=[n("Abbrechen",-1)])]),_:1}),e(p,{color:"primary",variant:"tonal",size:"small",loading:r.updatingTopics,onClick:s[1]||(s[1]=g=>d("confirm"))},{default:t(()=>[...s[8]||(s[8]=[n(" Zurücksetzen ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["model-value"])}}}),n1=Me(l1,[["__scopeId","data-v-1d9603b8"]]);function o1(r,$,d,c){const s=y([]),m=y(!1),u=y(!1),f=y(!1),p=y(null);let _=null,k=null;async function i(){await Wt(),c&&c()}async function g(){m.value=!0,p.value=null;try{const V=await re.get(`/content-plans/${r.value}/chat`);V.success&&V.data?(s.value=V.data,await i()):p.value=V.error||"Fehler beim Laden des Chatverlaufs"}catch{p.value="Netzwerkfehler beim Laden des Chatverlaufs"}finally{m.value=!1}}async function x(V){var E;if(!(!V.trim()||u.value)){u.value=!0,p.value=null;try{const R=re.getAccessToken();if(!R){p.value="Nicht authentifiziert",u.value=!1;return}const T=`/api/content-plans/${r.value}/chat/stream`;_=new AbortController;const D=await fetch(T,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${R}`},body:JSON.stringify({message:V}),signal:_.signal});if(!D.ok){p.value=`Fehler: ${D.status}`,u.value=!1;return}const H=(E=D.body)==null?void 0:E.getReader();if(!H){p.value="Streaming nicht verfügbar",u.value=!1;return}const O=new TextDecoder;let S="",B=null;for(;;){const{done:G,value:W}=await H.read();if(G)break;S+=O.decode(W,{stream:!0});const F=S.split(`
`);S=F.pop()||"";for(const L of F){const A=L.trim();if(!(!A||!A.startsWith("data: ")))try{const z=JSON.parse(A.slice(6));switch(z.type){case"user_message":s.value.push(z.message),await i();break;case"stream_start":B={_id:`streaming_${Date.now()}`,role:"assistant",content:"",createdAt:new Date().toISOString()},s.value.push(B),await i();break;case"chunk":if(B){B.content+=z.content;const j=$(B.content);j&&(B.extractedMarkers=j),s.value=[...s.value],k||(k=requestAnimationFrame(()=>{i(),k=null}))}break;case"stream_complete":if(B&&z.message){const j=s.value.findIndex(J=>J._id===B._id);j>=0&&(s.value[j]=z.message)}d&&await d(),await i();break;case"error":p.value=z.message||"Streaming-Fehler";break;case"ping":case"done":break}}catch{}}}}catch(R){if(R instanceof DOMException&&R.name==="AbortError")return;ue.warn("ADMIN","Streaming fehlgeschlagen, Fallback auf Standard-API");try{const M=await re.post(`/content-plans/${r.value}/chat`,{message:V});M.success&&M.data?(await g(),d&&await d()):p.value=M.error||"Fehler beim Senden der Nachricht"}catch{p.value="Netzwerkfehler beim Senden"}}finally{_=null,u.value=!1,await i()}}}async function w(V,E){if(!V._id){s.value.splice(E,1);return}try{const R=await re.delete(`/content-plans/${r.value}/chat/${V._id}`);R.success?s.value.splice(E,1):p.value=R.error||"Fehler beim Löschen der Nachricht"}catch{p.value="Netzwerkfehler beim Löschen"}}async function b(){if(!(!r.value||!s.value.length)){f.value=!0;try{const V=await re.delete(`/content-plans/${r.value}/chat`);V.success?s.value=[]:p.value=V.error||"Fehler beim Leeren des Chats"}catch{p.value="Netzwerkfehler beim Leeren des Chats"}finally{f.value=!1}}}function I(){_==null||_.abort(),_=null,k!==null&&(cancelAnimationFrame(k),k=null)}return{chatMessages:s,loadingChat:m,sendingMessage:u,clearingChat:f,chatError:p,loadChat:g,sendMessage:x,deleteMessage:w,clearChat:b,cleanup:I}}function s1(r){function $(s){return s?s.replace(/\[TOPIC:[^\]]*\]/g,"").replace(/\[POST_START:[^\]]*\][\s\S]*?\[POST_END\]/g,"").replace(/\[POST_END\]/g,"").replace(/\[HASHTAGS:[^\]]*\]/g,"").replace(/\[LANDING_PAGE:[^\]]*\]/g,"").replace(/\[CTA:[^\]]*\]/g,"").replace(/\n{3,}/g,`

`).trim():""}function d(s){if(!s)return null;const m=[],u=[],f=[],p=[],_=[],k=/\[TOPIC:\s*([^|]+)\|([^|]*)\|([^|]*)\|([^\]]*)\]/g;let i;for(;(i=k.exec(s))!==null;)m.push({title:i[1].trim(),category:i[2].trim(),suggestedDate:i[3].trim(),description:i[4].trim()});const g=/\[POST_START:\s*([^\]]+)\]([\s\S]*?)\[POST_END\]/g;for(;(i=g.exec(s))!==null;)u.push({topicTitle:i[1].trim(),text:i[2].trim()});const x=s.match(/\[HASHTAGS:\s*([^\]]+)\]/);x&&x[1].split(/\s+/).forEach(V=>{const E=V.trim();E&&f.push(E.startsWith("#")?E:`#${E}`)});const w=/\[CTA:\s*([^|]+)\|([^\]]+)\]/g;for(;(i=w.exec(s))!==null;)p.push({label:i[1].trim(),action:i[2].trim()});const b=/\[LANDING_PAGE:\s*([^|]+)\|([^|]*)\|([^|]*)\|([^\]]*)\]/g;for(;(i=b.exec(s))!==null;)_.push({title:i[1].trim(),headline:i[2].trim(),subtitle:i[3].trim(),ctaText:i[4].trim()});if(m.length===0&&u.length===0&&p.length===0)return null;const I=s.replace(/\[TOPIC:[^\]]*\]/g,"").replace(/\[POST_START:[^\]]*\][\s\S]*?\[POST_END\]/g,"").replace(/\[HASHTAGS:[^\]]*\]/g,"").replace(/\[LANDING_PAGE:[^\]]*\]/g,"").replace(/\[CTA:[^\]]*\]/g,"").replace(/\n{3,}/g,`

`).trim();return{topics:m,posts:u,hashtags:f,landingPages:_,ctas:p,cleanContent:I}}function c(s){var u;const m=(u=r.value)==null?void 0:u.topics.find(f=>f.title===s);return(m==null?void 0:m.status)||"suggested"}return{parseMarkersClient:d,stripMarkers:$,getTopicCurrentStatus:c}}function i1(r,$,d=60){const c=qe(r,d),s=y(!1);function m(p){if(!s.value)return;const _=document.querySelector($);if(!_)return;const k=_.getBoundingClientRect(),g=(("touches"in p?p.touches[0].clientX:p.clientX)-k.left)/k.width*100;c.value=Math.max(30,Math.min(75,g))}function u(){s.value=!1,document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",u),document.removeEventListener("touchmove",m),document.removeEventListener("touchend",u)}function f(p){s.value=!0,document.addEventListener("mousemove",m),document.addEventListener("mouseup",u),document.addEventListener("touchmove",m),document.addEventListener("touchend",u),p.preventDefault()}return Ft(()=>{u()}),{chatPanelWidth:c,isResizing:s,startResize:f}}function bl(){function r($){if(!$)return"";let d=$.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return d=d.replace(/(^\|.+\|$\n?){2,}/gm,c=>{const s=c.trim().split(`
`).filter(Boolean);if(s.length<2)return c;const m=k=>k.split("|").slice(1,-1).map(i=>i.trim()),u=m(s[0]),p=/^\|[\s:]*-{2,}[\s:]*(\|[\s:]*-{2,}[\s:]*)+\|$/.test(s[1])?2:1;let _="<table><thead><tr>";u.forEach(k=>{_+=`<th>${k}</th>`}),_+="</tr></thead><tbody>";for(let k=p;k<s.length;k++){const i=m(s[k]);i.length===0||i.every(g=>/^-+$/.test(g))||(_+="<tr>",i.forEach(g=>{_+=`<td>${g}</td>`}),_+="</tr>")}return _+="</tbody></table>",_}),d=d.replace(/^-{3,}$/gm,"<hr>"),d=d.replace(/^\*{3,}$/gm,"<hr>"),d=d.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,"<code>$1</code>"),d=d.replace(/^#{4} (.+)$/gm,"<h4>$1</h4>").replace(/^#{3} (.+)$/gm,"<h3>$1</h3>").replace(/^#{2} (.+)$/gm,"<h2>$1</h2>").replace(/^# (.+)$/gm,"<h1>$1</h1>"),d=d.replace(/^(\d+)\. (.+)$/gm,"<li data-ol>$2</li>"),d=d.replace(/((<li data-ol>.*<\/li>\n?)+)/g,"<ol>$1</ol>"),d=d.replace(/ data-ol/g,""),d=d.replace(/^- (.+)$/gm,"<li>$1</li>"),d=d.replace(/((<li>.*<\/li>\n?)+)/g,c=>c.includes("<ol>")?c:`<ul>${c}</ul>`),d=d.replace(/\n{2,}/g,"</p><p>"),d=d.replace(new RegExp("(?<!\\>)\\n(?!\\<)","g"),"<br>"),d}return{renderMarkdown:r}}const r1={class:"content-plan-detail-view"},d1={class:"content-plan-detail-view__nav mb-2"},u1={key:0,class:"d-flex justify-center pa-12"},c1={class:"content-plan-detail-view__resize-indicator"},m1=Ae({__name:"ContentPlanDetailView",setup(r){const $=Ut(),d=xt(),c=se(()=>$.params.id),s=se(()=>{const ze=$.params.id;return typeof ze=="string"&&ze!=="new"?ze:null}),{isLocked:m,isLockedByMe:u,lockedBy:f,lockedAt:p,isLockTakenOver:_,takenOverBy:k,takeOverLock:i}=sa("LinkedinContentPlan",s),g=se(()=>m.value&&!u.value||_.value),{hasMarkers:x,getTopicStatusColor:w,getTopicStatusLabel:b,truncateText:I,formatDate:V,parseCtaAction:E}=ka(),{renderMarkdown:R}=bl(),M=y(null),{parseMarkersClient:T,stripMarkers:D,getTopicCurrentStatus:H}=s1(M),{chatPanelWidth:O,isResizing:S,startResize:B}=i1("content_plan_split_width",".content-plan-detail-view__split"),G=y(!1),W=y(null),F=y(!1),L=y(null),A=y(!1),z=y(null),j=y(!1),J=y(!1),Q=y(!1),te=y(null),ve=y(0),de=y(null),Z=y(!1),ce=y(null),oe=y(!1),pe=y(!1),_e=y(null),q=wt({name:"",startDate:"",endDate:"",frequency:""});let C=null;const ae=[{label:"Planung & Termine",hints:["Verteile die Posts Mo-Fr, alle 2-3 Tage, variabel","Erstelle einen Redaktionsplan mit saisonalen Hooks (Messen, Gesetzesfristen, Branchenevents)","Analysiere unsere bestehenden Topics und schlage Lücken vor - welche Themen fehlen noch?"]},{label:"Content-Serien & Recherche",hints:["Ich möchte eine Content-Serie über NIS2 erstellen - recherchiere rechtliche Deadlines in 2026, wie können wir eine Story aufbauen?",'Erstelle einen Listicle-Post: "5 Fehler die Geschäftsführer bei NIS2 machen"',"Schreibe einen Post im Storytelling-Format - Problem, Wendepunkt, Lösung"]},{label:"Ergänzung & Perspektiven",hints:["Bitte 3 weitere Posts erstellen als Ergänzung, mit Insights aus der Perspektive eines Kunden",'Bitte 5 weitere Posts als anonymisierte Case Studies mit dem Hinweis: "Diese Referenz wird aufgrund von Vertraulichkeitsvereinbarungen ohne Markennamen dargestellt."',"Schreibe die nächsten Posts aus der Perspektive unseres CTO - technisch, aber verständlich","Mache die Posts kontroverser - stelle gängige Branchenmeinungen infrage"]},{label:"Optimierung",hints:["Die Posts sind zu lang - kürze alle auf max. 1500 Zeichen, punchiger","Füge zu jedem Post einen starken Hook in den ersten 2 Zeilen hinzu"]}],X=[{title:"Mehrmals täglich",value:"multiple-daily"},{title:"Jeden Tag",value:"daily"},{title:"Alle 2-3 Tage",value:"every-2-3-days"},{title:"3x pro Woche",value:"3x-weekly"},{title:"2x pro Woche",value:"2x-weekly"},{title:"Wöchentlich",value:"weekly"}],ie=y(null);function fe(){var ze;(ze=ie.value)==null||ze.scrollToBottom()}async function Se(){var ze,Be;await Ve(),(Be=(ze=M.value)==null?void 0:ze.topics)!=null&&Be.some(bt=>bt.status==="suggested"||bt.status==="generating")&&Ye()}const{chatMessages:me,loadingChat:ee,sendingMessage:Y,clearingChat:K,chatError:le,loadChat:ne,sendMessage:Ce,deleteMessage:ke,clearChat:xe,cleanup:Ne}=o1(c,T,Se,fe);function Ie(ze){if(g.value){ue.warn("ADMIN","Nachricht senden blockiert - kein Lock-Owner");return}Ce(ze)}const Ue=se(()=>{var ze;return(((ze=M.value)==null?void 0:ze.topics)||[]).filter(Be=>Be.status==="accepted")}),Te=se(()=>{var ze;return(((ze=M.value)==null?void 0:ze.topics)||[]).filter(Be=>Be.status==="suggested")}),ye=se(()=>{var ze;return(((ze=M.value)==null?void 0:ze.topics)||[]).filter(Be=>Be.status==="generating")}),Je=se(()=>{var ze;return(((ze=M.value)==null?void 0:ze.topics)||[]).filter(Be=>Be.status==="drafted")}),Ke=se(()=>{var ze;return(((ze=M.value)==null?void 0:ze.topics)||[]).filter(Be=>!!Be.postText)}),$e=se(()=>{var ze;return(((ze=M.value)==null?void 0:ze.topics)||[]).filter(Be=>Be.status==="skipped")}),Ee=se(()=>{var ze;return(((ze=M.value)==null?void 0:ze.topics)||[]).filter(Be=>!!Be.landingPagePreview)}),lt=se(()=>M.value?{"multiple-daily":"Mehrmals täglich",daily:"Jeden Tag","every-2-3-days":"Alle 2-3 Tage","3x-weekly":"3x pro Woche","2x-weekly":"2x pro Woche",weekly:"Wöchentlich"}[M.value.frequency]||M.value.frequency:""),ut=se(()=>{var ze,Be;return((Be=(ze=M.value)==null?void 0:ze.elaboration)==null?void 0:Be.status)==="running"});async function Ve(){var ze,Be;G.value=!0,W.value=null;try{const bt=await re.get(`/content-plans/${c.value}`);bt.success&&bt.data?(M.value=bt.data,(((ze=bt.data.elaboration)==null?void 0:ze.status)==="running"||(Be=bt.data.topics)!=null&&Be.some(pt=>pt.status==="generating"))&&Ye()):W.value=bt.error||"Fehler beim Laden des Plans"}catch{W.value="Netzwerkfehler beim Laden des Plans"}finally{G.value=!1}}async function Le(){var ze,Be,bt;try{const pt=await re.get(`/content-plans/${c.value}`);pt.success&&pt.data&&(M.value=pt.data,((ze=pt.data.elaboration)==null?void 0:ze.status)==="running"||(Be=pt.data.topics)!=null&&Be.some(Gt=>Gt.status==="generating")||(ct(),((bt=pt.data.elaboration)==null?void 0:bt.status)==="completed"&&(j.value=!0)))}catch{}}function Ye(){C||(C=setInterval(Le,3e3))}function ct(){C&&(clearInterval(C),C=null)}async function Fe(ze,Be){if(g.value){ue.warn("ADMIN","Topic-Status-Update blockiert - kein Lock-Owner");return}if(!M.value)return;const bt=M.value.topics.findIndex(pt=>pt.title===ze.title);if(bt!==-1){F.value=!0,L.value=null;try{const pt=await re.put(`/content-plans/${c.value}/topics`,{updates:[{index:bt,status:Be}]});pt.success&&pt.data?M.value=pt.data:L.value=pt.error||"Fehler beim Aktualisieren der Topics"}catch{L.value="Netzwerkfehler beim Aktualisieren"}finally{F.value=!1}}}async function Xe(){if(g.value){ue.warn("ADMIN","Alle Topics akzeptieren blockiert - kein Lock-Owner");return}if(!M.value)return;const ze=M.value.topics.map((Be,bt)=>({index:bt,status:"accepted"})).filter((Be,bt)=>M.value.topics[bt].status==="suggested");if(ze.length!==0){F.value=!0,L.value=null;try{const Be=await re.put(`/content-plans/${c.value}/topics`,{updates:ze});Be.success&&Be.data?(M.value=Be.data,ue.info("ADMIN","Alle Topics akzeptiert")):L.value=Be.error||"Fehler beim Akzeptieren aller Topics"}catch{L.value="Netzwerkfehler beim Akzeptieren aller Topics",ue.error("ADMIN","Fehler bei acceptAllTopics")}finally{F.value=!1}}}async function mt(){if(g.value){ue.warn("ADMIN","Verworfene Topics löschen blockiert - kein Lock-Owner");return}if(M.value){F.value=!0,L.value=null;try{const ze=await re.delete(`/content-plans/${c.value}/topics/skipped`);ze.success&&ze.data?M.value=ze.data:L.value=ze.error||"Fehler beim Entfernen verworfener Topics"}catch{L.value="Netzwerkfehler beim Entfernen verworfener Topics"}finally{F.value=!1}}}function nt(ze){de.value=ze,Z.value=!0}function He(ze){Z.value=!1,Ie(`Überarbeite das Topic '${ze}'`)}function St(ze){Z.value=!1,it(ze)}function Pt(ze,Be){de.value&&(Fe({title:ze},Be),Z.value=!1)}async function Dt(ze){await Ve()}function _t(ze){L.value=ze}async function Re(ze){if(g.value){ue.warn("ADMIN","Post übernehmen blockiert - kein Lock-Owner");return}if(!(!ze.postText||!M.value)){Z.value=!1;try{const Be={contentPlanId:M.value._id,topicTitle:ze.title,text:ze.postText,hashtags:ze.hashtags||[],status:"draft"},bt=await re.post("/linkedin/posts",Be);bt.success?await Ve():L.value=bt.error||"Fehler beim Erstellen des Posts"}catch{L.value="Netzwerkfehler beim Erstellen des Posts"}}}async function ge(){if(g.value){ue.warn("ADMIN","Ausarbeitung starten blockiert - kein Lock-Owner");return}A.value=!0,z.value=null,j.value=!1;try{const ze=await re.post(`/content-plans/${c.value}/elaborate`);ze.success||ze.status===202?(await Ve(),Ye()):z.value=ze.error||"Fehler beim Starten der Ausarbeitung"}catch{z.value="Netzwerkfehler beim Starten der Ausarbeitung"}finally{A.value=!1}}async function at(){if(g.value){ue.warn("ADMIN","Ausarbeitung zurücksetzen blockiert - kein Lock-Owner");return}Q.value=!0;try{const ze=await re.post(`/content-plans/${c.value}/elaboration/reset`);ze.success?(J.value=!1,ct(),await Ve()):z.value=ze.error||"Fehler beim Zurücksetzen"}catch{z.value="Netzwerkfehler beim Zurücksetzen"}finally{Q.value=!1}}async function et(ze){if(g.value){ue.warn("ADMIN","Post generieren blockiert - kein Lock-Owner");return}if(M.value){F.value=!0,L.value=null;try{const Be=await re.post(`/content-plans/${c.value}/topics/generate-post`,{topicTitle:ze});Be.success&&Be.data?(M.value=Be.data,ue.info("ADMIN","Post generiert",{topicTitle:ze})):L.value=Be.error||"Fehler beim Generieren des Posts"}catch{L.value="Netzwerkfehler beim Generieren des Posts"}finally{F.value=!1}}}async function it(ze){if(g.value){ue.warn("ADMIN","Landing-Page generieren blockiert - kein Lock-Owner");return}if(M.value){te.value=ze,L.value=null;try{const Be=await re.post(`/content-plans/${c.value}/topics/generate-lp`,{topicTitle:ze});Be.success&&Be.data?(M.value=Be.data,ue.info("ADMIN","Landing Page generiert",{topicTitle:ze})):L.value=Be.error||"Fehler beim Generieren der Landing Page"}catch{L.value="Netzwerkfehler beim Generieren der Landing Page"}finally{te.value=null}}}function $t(ze){const Be=E(ze);switch(Be.type){case"message":Ie(Be.payload);break;case"accept-all":Xe();break;case"elaborate":ge();break;case"generate-post":et(Be.payload);break;case"generate-lp":it(Be.payload);break;default:ue.warn("ADMIN","Unbekannte CTA-Aktion",{action:ze})}}function yt(ze){ze.type==="accept"?Fe({title:ze.topicTitle},"accepted"):ze.type==="skip"?Fe({title:ze.topicTitle},"skipped"):ze.type==="undo"&&(ce.value=ze.topicTitle)}function We(){var ze,Be;M.value&&(Object.assign(q,{name:M.value.name,startDate:((ze=M.value.period)==null?void 0:ze.startDate)||"",endDate:((Be=M.value.period)==null?void 0:Be.endDate)||"",frequency:M.value.frequency}),_e.value=null,oe.value=!0)}async function Qe(ze){if(g.value){ue.warn("ADMIN","Plan speichern blockiert - kein Lock-Owner");return}if(M.value){pe.value=!0,_e.value=null;try{const Be=await re.put(`/content-plans/${c.value}`,{name:ze.name,period:{startDate:ze.startDate,endDate:ze.endDate},frequency:ze.frequency});Be.success&&Be.data?(M.value=Be.data,oe.value=!1):_e.value=Be.error||"Fehler beim Speichern"}catch{_e.value="Netzwerkfehler beim Speichern"}finally{pe.value=!1}}}function At(ze){ce.value=ze}async function je(){ce.value&&(await Fe({title:ce.value},"suggested"),ce.value=null)}function he(){ce.value=null}return rt(async()=>{await Ve(),await ne()}),Ft(()=>{ct(),Ne()}),(ze,Be)=>{const bt=l("v-btn"),pt=l("v-progress-circular"),It=l("v-alert"),Gt=l("v-icon");return o(),h("div",r1,[a("div",d1,[e(bt,{variant:"text","prepend-icon":"mdi-arrow-left",size:"small",onClick:Be[0]||(Be[0]=vt=>P(d).push({name:"admin-content-plan"}))},{default:t(()=>[...Be[16]||(Be[16]=[n(" Zurück zur Übersicht ",-1)])]),_:1})]),G.value&&!M.value?(o(),h("div",u1,[e(pt,{indeterminate:"",color:"primary"})])):U("",!0),W.value?(o(),N(It,{key:1,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":Be[1]||(Be[1]=vt=>W.value=null)},{default:t(()=>[n(v(W.value),1)]),_:1})):U("",!0),e(ia,{"is-locked":P(m),"is-locked-by-me":P(u),"locked-by":P(f),"locked-at":P(p),"is-lock-taken-over":P(_),"taken-over-by":P(k),"on-take-over":P(i)},null,8,["is-locked","is-locked-by-me","locked-by","locked-at","is-lock-taken-over","taken-over-by","on-take-over"]),M.value?(o(),h(be,{key:2},[e(Hp,{plan:M.value,"frequency-label":lt.value,"format-date":P(V),onEdit:We},null,8,["plan","frequency-label","format-date"]),a("div",{class:ft(["content-plan-detail-view__split",{"content-plan-detail-view__split--resizing":P(S)}])},[a("div",{class:"content-plan-detail-view__chat-panel",style:ht({width:P(O)+"%"})},[e(Cf,{ref_key:"chatPanelRef",ref:ie,messages:P(me),loading:P(ee),sending:P(Y),clearing:P(K),error:P(le),"prompt-hint-groups":ae,"has-markers":P(x),"get-topic-current-status":P(H),"render-markdown":P(R),"strip-markers":P(D),"updating-topics":F.value,onSend:Ie,onUsePromptHint:Ie,onClearChat:P(xe),onClearError:Be[2]||(Be[2]=vt=>le.value=null),onDeleteMessage:Be[3]||(Be[3]=vt=>P(ke)(vt.msg,vt.index)),onCtaClick:$t,onTopicAction:yt},null,8,["messages","loading","sending","clearing","error","has-markers","get-topic-current-status","render-markdown","strip-markers","updating-topics","onClearChat"])],4),a("div",{class:"content-plan-detail-view__resize-handle",onMousedown:Be[4]||(Be[4]=(...vt)=>P(B)&&P(B)(...vt)),onTouchstart:Be[5]||(Be[5]=(...vt)=>P(B)&&P(B)(...vt))},[a("div",c1,[e(Gt,{size:"16",color:"grey"},{default:t(()=>[...Be[17]||(Be[17]=[n("mdi-drag-vertical",-1)])]),_:1})])],32),a("div",{class:"content-plan-detail-view__topics-panel",style:ht({width:100-P(O)+"%"})},[e(Ff,{plan:M.value,"active-tab":ve.value,"topics-count":(M.value.topics||[]).length,"posts-count":Ke.value.length,"lp-count":Ee.value.length,"topic-error":L.value,"elaboration-error":z.value,"elaboration-success":j.value,"elaboration-running":ut.value,elaborating:A.value,"generating-lp-for-topic":te.value,"generating-topics-count":ye.value.length,"onUpdate:activeTab":Be[7]||(Be[7]=vt=>ve.value=vt),"onUpdate:elaborationSuccess":Be[8]||(Be[8]=vt=>j.value=vt),onClearTopicError:Be[9]||(Be[9]=vt=>L.value=null),onClearElaborationError:Be[10]||(Be[10]=vt=>z.value=null),onStartElaboration:ge,onShowResetDialog:Be[11]||(Be[11]=vt=>J.value=!0)},{topics:t(()=>[e(Ig,{"generating-topics":ye.value,"drafted-topics":Je.value,"accepted-topics":Ue.value,"suggested-topics":Te.value,"skipped-topics":$e.value,"updating-topics":F.value,"format-date":P(V),"get-topic-status-color":P(w),"get-topic-status-label":P(b),onOpenTopic:nt,onUpdateTopicStatus:Be[6]||(Be[6]=vt=>Fe(vt.topic,vt.status)),onConfirmUndo:At,onGeneratePost:et,onGenerateLp:it,onAcceptAll:Xe,onDeleteSkipped:mt},null,8,["generating-topics","drafted-topics","accepted-topics","suggested-topics","skipped-topics","updating-topics","format-date","get-topic-status-color","get-topic-status-label"])]),posts:t(()=>[e(Gg,{"topics-with-posts":Ke.value,"truncate-text":P(I),onOpenTopic:nt},null,8,["topics-with-posts","truncate-text"])]),landingPages:t(()=>[e(Yg,{"topics-with-landing-page":Ee.value,onOpenTopic:nt},null,8,["topics-with-landing-page"])]),_:1},8,["plan","active-tab","topics-count","posts-count","lp-count","topic-error","elaboration-error","elaboration-success","elaboration-running","elaborating","generating-lp-for-topic","generating-topics-count"])],4)],2)],64)):U("",!0),e(n1,{"topic-title":ce.value,"updating-topics":F.value,onConfirm:je,onCancel:he},null,8,["topic-title","updating-topics"]),e(a1,{modelValue:J.value,"onUpdate:modelValue":Be[12]||(Be[12]=vt=>J.value=vt),resetting:Q.value,onConfirm:at},null,8,["modelValue","resetting"]),e(e1,{modelValue:oe.value,"onUpdate:modelValue":Be[13]||(Be[13]=vt=>oe.value=vt),"initial-values":q,saving:pe.value,error:_e.value,"frequency-options":X,onSave:Qe,onClearError:Be[14]||(Be[14]=vt=>_e.value=null)},null,8,["modelValue","initial-values","saving","error"]),e(Op,{modelValue:Z.value,"onUpdate:modelValue":Be[15]||(Be[15]=vt=>Z.value=vt),topic:de.value,"plan-id":c.value,readonly:g.value,"on-refine":He,"on-generate-lp":St,"on-status-change":Pt,"on-adopt-post":Re,onPostCreated:Dt,onImageError:_t},null,8,["modelValue","topic","plan-id","readonly"])])}}}),v1=Me(m1,[["__scopeId","data-v-de8e37de"]]),k6=Object.freeze(Object.defineProperty({__proto__:null,default:v1},Symbol.toStringTag,{value:"Module"})),p1={class:"d-flex align-center justify-space-between mb-6"},f1={class:"d-flex ga-2"},g1={key:0},b1={class:"text-caption text-medium-emphasis mb-1"},y1={key:3,class:"leads-list__drill-chips mb-4"},_1={class:"text-body-2 font-weight-medium"},k1={class:"leads-list__name"},h1={class:"text-caption font-weight-bold"},x1={class:"text-body-2 font-weight-medium"},w1={class:"text-body-2 text-medium-emphasis"},S1={class:"text-body-2"},$1={class:"text-caption text-medium-emphasis"},C1={class:"text-body-2 mb-4"},V1={key:1,class:"text-body-2 text-medium-emphasis"},A1={class:"text-body-2 mb-4"},I1={class:"text-body-2 mb-4"},P1=Ae({__name:"LeadsListView",setup(r){const $=xt(),d=Ut();function c(je){return typeof je=="string"?je:Array.isArray(je)&&typeof je[0]=="string"?je[0]:""}const s=y(""),m=y(""),u=y(""),f=y("");function p(){const je=d.query,he=c(je.formType),ze=["contact","newsletter","gated-content","booking"];s.value=ze.includes(he)?he:"",m.value=c(je.presetSlug),u.value=c(je.submittedFrom),f.value=c(je.submittedTo)}p();const _=se(()=>!!s.value||!!m.value||!!u.value||!!f.value),k={contact:"Kontakt",newsletter:"Newsletter","gated-content":"Download",booking:"Termin"};function i(je){if(!je)return"";const he=new Date(je);return Number.isNaN(he.getTime())?je:he.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}function g(je){const{[je]:he,...ze}=d.query;$.replace({query:ze})}const x=y(!1),w=y(null),b=y([]),I=y(0),V=qe("leads_filter_stage",""),E=qe("leads_filter_source",""),R=y(""),M=qe("leads_show_archived",!1),T=qe("leads_only_mine",!1);let D=null;const H=qe("leads_show_advanced_filters",!1),O=qe("leads_filter_score_min",0),S=qe("leads_filter_score_max",100),B=qe("leads_filter_tags",[]),G=qe("leads_filter_engagement",""),W=qe("leads_filter_created_from",""),F=qe("leads_filter_created_to",""),L=qe("leads_filter_source_scope","all"),A=[{label:"Alle",value:"all",tooltip:"Alle Leads ungefiltert"},{label:"Plattform",value:"platform",tooltip:"Echte Leads aus Formular/Newsletter plus HubSpot-Importe mit Plattform-Konvertierung"},{label:"HubSpot",value:"hubspot",tooltip:"HubSpot-/Gmail-Importe ohne Plattform-Formular-Aktivitaet"}],z=y([O.value,S.value]),j=[{label:"Alle",value:""},{label:"Hot",value:"hot"},{label:"Warm",value:"warm"},{label:"Cold",value:"cold"},{label:"Stuck",value:"stuck"},{label:"Einmal konvertiert",value:"single-converter"},{label:"Mehrfach konvertiert",value:"multi-converter"},{label:"Power-Lead",value:"power-lead"},{label:"Bounced",value:"bounced"},{label:"Abgemeldet",value:"unsubscribed"},{label:"Wartet",value:"awaiting-next-step"},{label:"Aktiv",value:"active"}],J=y(1),Q=qe("leads_items_per_page",20),te=qe("leads_sort_by",[{key:"createdAt",order:"desc"}]),ve={name:"lastName",email:"email",company:"company",source:"source.type",stage:"pipeline.stage",score:"scoring.total",createdAt:"createdAt"},de=[{title:"",key:"select",sortable:!1,width:"48px"},{title:"Name",key:"name",sortable:!0},{title:"E-Mail",key:"email",sortable:!0},{title:"Unternehmen",key:"company",sortable:!0},{title:"Quelle",key:"source",sortable:!0,width:"160px"},{title:"Pipeline",key:"stage",sortable:!0},{title:"Score",key:"score",sortable:!0,width:"80px",align:"center"},{title:"Erstellt",key:"createdAt",sortable:!0,width:"120px"},{title:"Angelegt",key:"createdBy",sortable:!1,width:80,align:"center"},{title:"Geändert",key:"updatedBy",sortable:!1,width:80,align:"center"}],Z=[{title:"Alle Phasen",value:""},...Object.entries(na).map(([je,he])=>({title:he,value:je}))],ce=[{title:"Alle Quellen",value:""},...Object.entries(Ta).map(([je,he])=>({title:he,value:je}))],oe=y([]),pe=se(()=>b.value.length>0&&oe.value.length===b.value.length),_e=se(()=>oe.value.length>0&&oe.value.length<b.value.length);function q(){pe.value?oe.value=[]:oe.value=b.value.map(je=>je._id)}function C(je){const he=oe.value.indexOf(je);he>=0?oe.value.splice(he,1):oe.value.push(je)}const ae=y(!1),X=y(null),ie=y(!1),fe=y("archive");function Se(){fe.value="archive",ie.value=!0}function me(){fe.value="restore",ie.value=!0}async function ee(){ae.value=!0;const je=fe.value==="archive"?"/leads/bulk/archive":"/leads/bulk/restore",he=await re.post(je,{leadIds:oe.value});if(he.success&&he.data){const ze=he.data.archived??he.data.restored??0,Be=fe.value==="archive"?"archiviert":"wiederhergestellt";X.value=`${ze} Lead(s) ${Be}.`,oe.value=[],await _t()}else X.value=he.error||"Fehler bei Bulk-Aktion.";ae.value=!1,ie.value=!1,setTimeout(()=>{X.value=null},5e3)}const Y=y(!1),K=y("assign"),le=y(""),ne=y([]),Ce=y(0),ke=y(!1);async function xe(){const je=await re.get("/email-sequences?limit=100&status=active");if(je.success&&je.data){const he=je.data;ne.value=he.items??[]}}function Ne(je){K.value=je,le.value="",Ce.value=0,je==="assign"&&xe(),Y.value=!0}async function Ie(je=!1){if(ae.value=!0,K.value==="remove"){const he=await re.post("/leads/bulk/sequence/remove",{leadIds:oe.value});he.success&&he.data?(X.value=`Sequenz bei ${he.data.removed} Lead(s) entfernt.`,oe.value=[],await _t()):X.value=he.error||"Fehler beim Entfernen der Sequenz.",Y.value=!1}else{const he=await re.post("/leads/bulk/sequence",{leadIds:oe.value,sequenceId:le.value,force:je});if(he.success&&he.data){if(he.data.conflicts&&he.data.conflicts>0&&!je){Ce.value=he.data.conflicts,Y.value=!1,ke.value=!0,ae.value=!1;return}X.value=`${he.data.assigned??0} Lead(s) zugewiesen, ${he.data.skipped??0} übersprungen, ${he.data.errors??0} Fehler.`,oe.value=[],ke.value=!1,Y.value=!1,await _t()}else X.value=he.error||"Fehler bei Sequenz-Zuweisung."}ae.value=!1,setTimeout(()=>{X.value=null},5e3)}const Ue=y(!1),Te=y("add"),ye=y(""),Je=y(!1);function Ke(je){Te.value=je,ye.value="",Ue.value=!0}async function $e(){if(!ye.value.trim())return;Je.value=!0;const je=await re.post("/leads/bulk/tag",{leadIds:oe.value,operation:Te.value,tag:ye.value.trim()});if(je.success&&je.data){const he=Te.value==="add"?"hinzugefügt":"entfernt";X.value=`Tag "${ye.value.trim()}" bei ${je.data.modifiedCount} Lead(s) ${he}.`,oe.value=[],await _t()}else X.value=je.error||"Fehler bei Tag-Aktion.",ue.error("ADMIN","Bulk Tag fehlgeschlagen",je.error);Je.value=!1,Ue.value=!1,setTimeout(()=>{X.value=null},5e3)}const Ee=y(!1),lt=y(""),ut=y(""),Ve=y(!1),Le=Object.entries({neu:"Neu",kontaktiert:"Kontaktiert",qualifiziert:"Qualifiziert",angebot:"Angebot",verhandlung:"Verhandlung",gewonnen:"Gewonnen",verloren:"Verloren"}).map(([je,he])=>({title:he,value:je}));function Ye(){lt.value="",ut.value="",Ee.value=!0}async function ct(){if(!lt.value)return;Ve.value=!0;const je={leadIds:oe.value,stage:lt.value};ut.value.trim()&&(je.note=ut.value.trim());const he=await re.post("/leads/bulk/stage",je);he.success&&he.data?(X.value=`${he.data.modifiedCount} Lead(s) auf Stage "${lt.value}" gesetzt.`,oe.value=[],await _t()):(X.value=he.error||"Fehler beim Stage-Wechsel.",ue.error("ADMIN","Bulk Stage fehlgeschlagen",he.error)),Ve.value=!1,Ee.value=!1,setTimeout(()=>{X.value=null},5e3)}const Fe=y(!1);function Xe(){const je=Q.value>0?Q.value:100,he=new URLSearchParams({page:String(J.value),limit:String(je)});if(V.value&&he.append("stage",V.value),E.value&&he.append("source",E.value),R.value.trim()&&he.append("search",R.value.trim()),M.value||he.append("isActive","true"),T.value&&he.append("onlyMine","true"),O.value>0&&he.append("scoreMin",String(O.value)),S.value<100&&he.append("scoreMax",String(S.value)),B.value.length>0&&he.append("tags",B.value.join(",")),G.value&&he.append("engagementState",G.value),W.value&&he.append("createdFrom",`${W.value}T00:00:00.000Z`),F.value&&he.append("createdTo",`${F.value}T23:59:59.999Z`),s.value&&he.append("formType",s.value),m.value&&he.append("presetSlug",m.value),u.value&&he.append("submittedFrom",u.value),f.value&&he.append("submittedTo",f.value),L.value!=="all"&&he.append("sourceScope",L.value),te.value.length>0){const ze=te.value[0],Be=ve[ze.key]||"updatedAt";he.append("sortBy",Be),he.append("sortOrder",ze.order)}return he}async function mt(){Fe.value=!0;try{const je=Xe(),he=re.getAccessToken(),ze={};he&&(ze.Authorization=`Bearer ${he}`);const Be=await fetch(`/api/leads/export.csv?${je.toString()}`,{method:"GET",headers:ze});if(!Be.ok){X.value="CSV-Export fehlgeschlagen.",ue.error("ADMIN","CSV-Export fehlgeschlagen",{status:Be.status});return}const bt=await Be.blob(),pt=window.URL.createObjectURL(bt),It=document.createElement("a");It.href=pt,It.download=`leads-${new Date().toISOString().slice(0,10)}.csv`,document.body.appendChild(It),It.click(),document.body.removeChild(It),window.URL.revokeObjectURL(pt),ue.info("ADMIN","CSV-Export gestartet")}catch(je){X.value="Fehler beim CSV-Export.",ue.error("ADMIN","CSV-Export Fehler",je)}finally{Fe.value=!1,setTimeout(()=>{X.value=null},5e3)}}function nt(je){const he=[je.firstName,je.lastName].filter(Boolean);return he.length>0?he.join(" "):"–"}function He(je){return new Date(je).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}function St(je){return{neu:"default",kontaktiert:"info",qualifiziert:"primary",angebot:"warning",verhandlung:"secondary",gewonnen:"success",verloren:"error"}[je]||"default"}function Pt(je){return{"website-formular":"primary",hubspot:"warning",manuell:"default",newsletter:"info","social-media":"success",empfehlung:"secondary",outreach:"error"}[je]||"default"}function Dt(je){return je>=70?"success":je>=40?"warning":"error"}async function _t(){var Be,bt,pt;x.value=!0,w.value=null;const je=Q.value>0?Q.value:100,he=new URLSearchParams({page:String(J.value),limit:String(je)});if(V.value&&he.append("stage",V.value),E.value&&he.append("source",E.value),R.value.trim()&&he.append("search",R.value.trim()),M.value||he.append("isActive","true"),T.value&&he.append("onlyMine","true"),O.value>0&&he.append("scoreMin",String(O.value)),S.value<100&&he.append("scoreMax",String(S.value)),B.value.length>0&&he.append("tags",B.value.join(",")),G.value&&he.append("engagementState",G.value),W.value&&he.append("createdFrom",`${W.value}T00:00:00.000Z`),F.value&&he.append("createdTo",`${F.value}T23:59:59.999Z`),s.value&&he.append("formType",s.value),m.value&&he.append("presetSlug",m.value),u.value&&he.append("submittedFrom",u.value),f.value&&he.append("submittedTo",f.value),L.value!=="all"&&he.append("sourceScope",L.value),te.value.length>0){const It=te.value[0],Gt=ve[It.key]||"updatedAt";he.append("sortBy",Gt),he.append("sortOrder",It.order)}const ze=await re.get(`/leads?${he.toString()}`);ze.success?(b.value=((Be=ze.data)==null?void 0:Be.items)??[],I.value=((pt=(bt=ze.data)==null?void 0:bt.pagination)==null?void 0:pt.total)??0,ue.debug("ADMIN","Leads list loaded",{total:I.value})):(w.value="Fehler beim Laden der Leads.",ue.error("ADMIN","Leads list loading failed",ze.error)),x.value=!1}function Re(){D&&clearTimeout(D),D=setTimeout(()=>{J.value=1,_t()},400)}function ge(){J.value=1,oe.value=[],_t()}function at(je){J.value=je.page,Q.value=je.itemsPerPage,je.sortBy&&(te.value=je.sortBy),oe.value=[],_t()}function et(je,he){$.push(`/admin/leads/${he.item._id}`)}const it=y(!1),$t=y(!1),yt=y(null);async function We(){it.value=!0,yt.value=null;const je=await re.post("/hubspot/sync",{});if(je.success&&je.data){const he=je.data;yt.value=`Export abgeschlossen: ${he.synced??0} nach HubSpot synchronisiert, ${he.errors??0} Fehler`,ue.info("ADMIN","HubSpot sync completed",je.data),await _t()}else yt.value=je.error||"HubSpot-Sync fehlgeschlagen.",ue.error("ADMIN","HubSpot sync failed",je.error);it.value=!1,setTimeout(()=>{yt.value=null},8e3)}async function Qe(){$t.value=!0,yt.value=null;const je=await re.post("/hubspot/import",{});if(je.success&&je.data){const he=je.data,ze=he.mode==="delta"?"Delta-Import":"Voll-Import";yt.value=`${ze} abgeschlossen: ${he.synced??0} Contacts aus HubSpot importiert, ${he.errors??0} Fehler`,ue.info("ADMIN","HubSpot import completed",je.data),await _t()}else yt.value=je.error||"HubSpot-Import fehlgeschlagen.",ue.error("ADMIN","HubSpot import failed",je.error);$t.value=!1,setTimeout(()=>{yt.value=null},8e3)}Ze([V,E,M,T,G,W,F,L],ge);let At=null;return Ze(z,([je,he])=>{O.value=je,S.value=he,At&&clearTimeout(At),At=setTimeout(()=>{J.value=1,oe.value=[],_t()},400)}),Ze(B,()=>{J.value=1,oe.value=[],_t()},{deep:!0}),Ze(()=>d.query,()=>{p(),J.value=1,oe.value=[],_t()}),(je,he)=>{const ze=l("v-btn"),Be=l("v-alert"),bt=l("v-select"),pt=l("v-col"),It=l("v-text-field"),Gt=l("v-switch"),vt=l("v-chip"),De=l("v-row"),we=l("v-divider"),tt=l("v-range-slider"),kt=l("v-combobox"),zt=l("v-tooltip"),Et=l("v-chip-group"),Ot=l("v-expand-transition"),Bt=l("v-card-text"),Oe=l("v-card"),Ct=l("v-checkbox"),Rt=l("v-avatar"),qt=l("v-data-table-server"),Qt=l("v-card-title"),Yt=l("v-spacer"),Ht=l("v-card-actions"),st=l("v-dialog"),ra=l("v-textarea"),fa=l("v-container");return o(),N(fa,{fluid:"",class:"pa-6"},{default:t(()=>[a("div",p1,[he[45]||(he[45]=a("h1",{class:"text-h4 font-weight-bold"},"Lead-Verwaltung",-1)),a("div",f1,[e(ze,{variant:"outlined",color:"warning","prepend-icon":"mdi-download",loading:$t.value,disabled:it.value,onClick:Qe},{default:t(()=>[...he[43]||(he[43]=[n(" HubSpot Import ",-1)])]),_:1},8,["loading","disabled"]),e(ze,{variant:"outlined",color:"warning","prepend-icon":"mdi-upload",loading:it.value,disabled:$t.value,onClick:We},{default:t(()=>[...he[44]||(he[44]=[n(" HubSpot Export ",-1)])]),_:1},8,["loading","disabled"])])]),yt.value?(o(),N(Be,{key:0,type:yt.value.includes("fehlgeschlagen")?"error":"success",variant:"tonal",class:"mb-4",text:yt.value,closable:"","onClick:close":he[0]||(he[0]=Ge=>yt.value=null)},null,8,["type","text"])):U("",!0),X.value?(o(),N(Be,{key:1,type:X.value.includes("Fehler")?"error":"success",variant:"tonal",class:"mb-4",text:X.value,closable:"","onClick:close":he[1]||(he[1]=Ge=>X.value=null)},null,8,["type","text"])):U("",!0),w.value?(o(),N(Be,{key:2,type:"error",variant:"tonal",class:"mb-4",text:w.value,closable:"","onClick:close":he[2]||(he[2]=Ge=>w.value=null)},null,8,["text"])):U("",!0),e(Oe,{rounded:"lg",class:"mb-4"},{default:t(()=>[e(Bt,{class:"pa-4"},{default:t(()=>[e(De,{dense:""},{default:t(()=>[e(pt,{cols:"12",sm:"3"},{default:t(()=>[e(bt,{modelValue:P(V),"onUpdate:modelValue":he[3]||(he[3]=Ge=>ot(V)?V.value=Ge:null),items:Z,"item-title":"title","item-value":"value",label:"Pipeline-Phase",density:"compact",variant:"outlined","hide-details":""},null,8,["modelValue"])]),_:1}),e(pt,{cols:"12",sm:"3"},{default:t(()=>[e(bt,{modelValue:P(E),"onUpdate:modelValue":he[4]||(he[4]=Ge=>ot(E)?E.value=Ge:null),items:ce,"item-title":"title","item-value":"value",label:"Quelle",density:"compact",variant:"outlined","hide-details":""},null,8,["modelValue"])]),_:1}),e(pt,{cols:"12",sm:"3"},{default:t(()=>[e(It,{modelValue:R.value,"onUpdate:modelValue":he[5]||(he[5]=Ge=>R.value=Ge),label:"Suche (Name, E-Mail)","prepend-inner-icon":"mdi-magnify",density:"compact",variant:"outlined","hide-details":"",clearable:"",onInput:Re,"onClick:clear":he[6]||(he[6]=()=>{R.value="",J.value=1,_t()})},null,8,["modelValue"])]),_:1}),e(pt,{cols:"12",sm:"3",class:"d-flex align-center ga-3 flex-wrap"},{default:t(()=>[e(Gt,{modelValue:P(M),"onUpdate:modelValue":he[7]||(he[7]=Ge=>ot(M)?M.value=Ge:null),label:"Archivierte anzeigen",density:"compact","hide-details":"",color:"primary"},null,8,["modelValue"]),e(vt,{color:P(T)?"primary":"",variant:P(T)?"flat":"outlined","prepend-icon":"mdi-account-filter",onClick:he[8]||(he[8]=Ge=>T.value=!P(T))},{default:t(()=>[...he[46]||(he[46]=[n(" Nur meine ",-1)])]),_:1},8,["color","variant"]),e(vt,{color:P(H)?"primary":"",variant:P(H)?"flat":"outlined","prepend-icon":"mdi-filter-plus",onClick:he[9]||(he[9]=Ge=>H.value=!P(H))},{default:t(()=>[...he[47]||(he[47]=[n(" Erweitert ",-1)])]),_:1},8,["color","variant"])]),_:1})]),_:1}),e(Ot,null,{default:t(()=>[P(H)?(o(),h("div",g1,[e(we,{class:"my-3"}),e(De,{dense:""},{default:t(()=>[e(pt,{cols:"12",sm:"6",md:"4"},{default:t(()=>[a("div",b1," Score: "+v(z.value[0])+" – "+v(z.value[1]),1),e(tt,{modelValue:z.value,"onUpdate:modelValue":he[10]||(he[10]=Ge=>z.value=Ge),min:0,max:100,step:5,color:"primary",density:"compact","hide-details":"","thumb-label":""},null,8,["modelValue"])]),_:1}),e(pt,{cols:"12",sm:"6",md:"4"},{default:t(()=>[e(kt,{modelValue:P(B),"onUpdate:modelValue":he[11]||(he[11]=Ge=>ot(B)?B.value=Ge:null),label:"Tags (OR-Match)","prepend-inner-icon":"mdi-tag-multiple",density:"compact",variant:"outlined",multiple:"",chips:"","closable-chips":"","hide-details":"",clearable:""},null,8,["modelValue"])]),_:1}),e(pt,{cols:"12",md:"4"},{default:t(()=>[e(bt,{modelValue:P(G),"onUpdate:modelValue":he[12]||(he[12]=Ge=>ot(G)?G.value=Ge:null),items:j,"item-title":"label","item-value":"value",label:"Engagement-Status",density:"compact",variant:"outlined","hide-details":"",clearable:""},null,8,["modelValue"])]),_:1}),e(pt,{cols:"12",md:"4"},{default:t(()=>[he[48]||(he[48]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Lead-Quelle (Scope)",-1)),e(Et,{modelValue:P(L),"onUpdate:modelValue":he[13]||(he[13]=Ge=>ot(L)?L.value=Ge:null),mandatory:"","selected-class":"text-primary"},{default:t(()=>[(o(),h(be,null,Pe(A,Ge=>e(vt,{key:Ge.value,value:Ge.value,variant:"outlined",size:"small"},{default:t(()=>[n(v(Ge.label)+" ",1),e(zt,{activator:"parent",location:"bottom","max-width":"280"},{default:t(()=>[n(v(Ge.tooltip),1)]),_:2},1024)]),_:2},1032,["value"])),64))]),_:1},8,["modelValue"])]),_:1}),e(pt,{cols:"12",sm:"6"},{default:t(()=>[e(It,{modelValue:P(W),"onUpdate:modelValue":he[14]||(he[14]=Ge=>ot(W)?W.value=Ge:null),label:"Erstellt ab",type:"date",density:"compact",variant:"outlined","hide-details":"",clearable:""},null,8,["modelValue"])]),_:1}),e(pt,{cols:"12",sm:"6"},{default:t(()=>[e(It,{modelValue:P(F),"onUpdate:modelValue":he[15]||(he[15]=Ge=>ot(F)?F.value=Ge:null),label:"Erstellt bis",type:"date",density:"compact",variant:"outlined","hide-details":"",clearable:""},null,8,["modelValue"])]),_:1})]),_:1})])):U("",!0)]),_:1})]),_:1})]),_:1}),_.value?(o(),h("div",y1,[he[49]||(he[49]=a("span",{class:"text-caption text-medium-emphasis mr-2"},"Drill-Down:",-1)),s.value?(o(),N(vt,{key:0,closable:"",size:"small",variant:"tonal",color:"primary","onClick:close":he[16]||(he[16]=Ge=>g("formType"))},{default:t(()=>[n(" Formular: "+v(k[s.value]),1)]),_:1})):U("",!0),m.value?(o(),N(vt,{key:1,closable:"",size:"small",variant:"tonal",color:"primary","onClick:close":he[17]||(he[17]=Ge=>g("presetSlug"))},{default:t(()=>[n(" Preset: "+v(m.value),1)]),_:1})):U("",!0),u.value?(o(),N(vt,{key:2,closable:"",size:"small",variant:"tonal",color:"primary","onClick:close":he[18]||(he[18]=Ge=>g("submittedFrom"))},{default:t(()=>[n(" Einreichung ab: "+v(i(u.value)),1)]),_:1})):U("",!0),f.value?(o(),N(vt,{key:3,closable:"",size:"small",variant:"tonal",color:"primary","onClick:close":he[19]||(he[19]=Ge=>g("submittedTo"))},{default:t(()=>[n(" Einreichung bis: "+v(i(f.value)),1)]),_:1})):U("",!0)])):U("",!0),oe.value.length>0?(o(),N(Oe,{key:4,class:"mb-4",variant:"tonal",color:"primary"},{default:t(()=>[e(Bt,{class:"d-flex align-center flex-wrap ga-3 py-2"},{default:t(()=>[a("span",_1,v(oe.value.length)+" Lead(s) ausgewählt ",1),e(ze,{color:"primary",size:"small",variant:"elevated","prepend-icon":"mdi-email-multiple",onClick:he[20]||(he[20]=Ge=>Ne("assign"))},{default:t(()=>[...he[50]||(he[50]=[n(" Sequenz zuweisen ",-1)])]),_:1}),e(ze,{size:"small",variant:"outlined","prepend-icon":"mdi-email-off",onClick:he[21]||(he[21]=Ge=>Ne("remove"))},{default:t(()=>[...he[51]||(he[51]=[n(" Sequenz entfernen ",-1)])]),_:1}),e(ze,{size:"small",variant:"outlined",color:"primary","prepend-icon":"mdi-tag-plus",onClick:he[22]||(he[22]=Ge=>Ke("add"))},{default:t(()=>[...he[52]||(he[52]=[n(" Tag hinzufügen ",-1)])]),_:1}),e(ze,{size:"small",variant:"outlined","prepend-icon":"mdi-tag-minus",onClick:he[23]||(he[23]=Ge=>Ke("remove"))},{default:t(()=>[...he[53]||(he[53]=[n(" Tag entfernen ",-1)])]),_:1}),e(ze,{size:"small",variant:"outlined",color:"secondary","prepend-icon":"mdi-swap-horizontal",onClick:Ye},{default:t(()=>[...he[54]||(he[54]=[n(" Stage ändern ",-1)])]),_:1}),e(ze,{size:"small",variant:"outlined","prepend-icon":"mdi-download",loading:Fe.value,onClick:mt},{default:t(()=>[...he[55]||(he[55]=[n(" CSV exportieren ",-1)])]),_:1},8,["loading"]),P(M)?U("",!0):(o(),N(ze,{key:0,size:"small",variant:"outlined",color:"error","prepend-icon":"mdi-archive",onClick:Se},{default:t(()=>[...he[56]||(he[56]=[n(" Archivieren ",-1)])]),_:1})),P(M)?(o(),N(ze,{key:1,size:"small",variant:"outlined",color:"success","prepend-icon":"mdi-archive-arrow-up",onClick:me},{default:t(()=>[...he[57]||(he[57]=[n(" Wiederherstellen ",-1)])]),_:1})):U("",!0),e(ze,{variant:"text",size:"small",onClick:he[24]||(he[24]=Ge=>oe.value=[])},{default:t(()=>[...he[58]||(he[58]=[n(" Auswahl aufheben ",-1)])]),_:1})]),_:1})]),_:1})):U("",!0),e(Oe,{rounded:"lg"},{default:t(()=>[e(qt,{headers:de,items:b.value,"items-length":I.value,loading:x.value,page:J.value,"items-per-page":P(Q),"sort-by":P(te),"items-per-page-text":"Einträge pro Seite","loading-text":"Lade Leads...","no-data-text":"Keine Leads gefunden.",hover:"","onUpdate:options":at,"onClick:row":et},{"header.select":t(()=>[e(Ct,{"model-value":pe.value,indeterminate:_e.value,"hide-details":"",density:"compact","onUpdate:modelValue":q},null,8,["model-value","indeterminate"])]),"item.select":t(({item:Ge})=>[e(Ct,{"model-value":oe.value.includes(Ge._id),"hide-details":"",density:"compact",onClick:he[25]||(he[25]=dt(()=>{},["stop"])),"onUpdate:modelValue":Oa=>C(Ge._id)},null,8,["model-value","onUpdate:modelValue"])]),"item.name":t(({item:Ge})=>[a("div",k1,[e(Rt,{color:"primary",size:"32",class:"mr-3"},{default:t(()=>[a("span",h1,v((Ge.firstName||Ge.email).charAt(0).toUpperCase()),1)]),_:2},1024),a("div",null,[a("span",x1,v(nt(Ge)),1),Ge.isActive?U("",!0):(o(),N(vt,{key:0,size:"x-small",color:"default",variant:"tonal",class:"ml-2"},{default:t(()=>[...he[59]||(he[59]=[n(" Archiviert ",-1)])]),_:1}))])])]),"item.email":t(({item:Ge})=>[a("span",w1,v(Ge.email),1)]),"item.company":t(({item:Ge})=>[a("span",S1,v(Ge.company||"–"),1)]),"item.source":t(({item:Ge})=>[e(vt,{color:Pt(Ge.source.type),size:"small",variant:"tonal"},{default:t(()=>[n(v(P(Ta)[Ge.source.type]||Ge.source.type),1)]),_:2},1032,["color"])]),"item.stage":t(({item:Ge})=>[e(vt,{color:St(Ge.pipeline.stage),size:"small",variant:"tonal"},{default:t(()=>[n(v(P(na)[Ge.pipeline.stage]||Ge.pipeline.stage),1)]),_:2},1032,["color"])]),"item.score":t(({item:Ge})=>[e(vt,{color:Dt(Ge.scoring.total),size:"small",variant:"tonal"},{default:t(()=>[n(v(Ge.scoring.total),1)]),_:2},1032,["color"])]),"item.createdAt":t(({item:Ge})=>[a("span",$1,v(He(Ge.createdAt)),1)]),"item.createdBy":t(({item:Ge})=>[e(gt,{"user-id":typeof Ge.createdBy=="object"&&Ge.createdBy?Ge.createdBy._id??null:Ge.createdBy??null,populated:typeof Ge.createdBy=="object"&&Ge.createdBy?Ge.createdBy:null},null,8,["user-id","populated"])]),"item.updatedBy":t(({item:Ge})=>[e(gt,{"user-id":typeof Ge.updatedBy=="object"&&Ge.updatedBy?Ge.updatedBy._id??null:Ge.updatedBy??null,populated:typeof Ge.updatedBy=="object"&&Ge.updatedBy?Ge.updatedBy:null},null,8,["user-id","populated"])]),_:1},8,["items","items-length","loading","page","items-per-page","sort-by"])]),_:1}),e(st,{modelValue:ie.value,"onUpdate:modelValue":he[27]||(he[27]=Ge=>ie.value=Ge),"max-width":"420"},{default:t(()=>[e(Oe,null,{default:t(()=>[e(Qt,null,{default:t(()=>[n(v(fe.value==="archive"?"Leads archivieren?":"Leads wiederherstellen?"),1)]),_:1}),e(Bt,null,{default:t(()=>[fe.value==="archive"?(o(),h(be,{key:0},[n(v(oe.value.length)+" Lead(s) werden archiviert. Aktive E-Mail-Sequenzen werden dabei abgebrochen. ",1)],64)):(o(),h(be,{key:1},[n(v(oe.value.length)+" Lead(s) werden wiederhergestellt und sind wieder aktiv. ",1)],64))]),_:1}),e(Ht,null,{default:t(()=>[e(Yt),e(ze,{variant:"text",onClick:he[26]||(he[26]=Ge=>ie.value=!1)},{default:t(()=>[...he[60]||(he[60]=[n("Abbrechen",-1)])]),_:1}),e(ze,{color:fe.value==="archive"?"error":"success",loading:ae.value,onClick:ee},{default:t(()=>[n(v(fe.value==="archive"?"Archivieren":"Wiederherstellen"),1)]),_:1},8,["color","loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(st,{modelValue:Y.value,"onUpdate:modelValue":he[31]||(he[31]=Ge=>Y.value=Ge),"max-width":"480"},{default:t(()=>[e(Oe,null,{default:t(()=>[e(Qt,null,{default:t(()=>[n(v(K.value==="assign"?"Sequenz zuweisen":"Sequenz entfernen"),1)]),_:1}),e(Bt,null,{default:t(()=>[a("p",C1,v(oe.value.length)+" Lead(s) ausgewählt. ",1),K.value==="assign"?(o(),N(bt,{key:0,modelValue:le.value,"onUpdate:modelValue":he[28]||(he[28]=Ge=>le.value=Ge),items:ne.value,"item-title":"name","item-value":"_id",label:"E-Mail-Sequenz",variant:"outlined",density:"comfortable","hide-details":"","no-data-text":"Keine aktiven Sequenzen vorhanden."},null,8,["modelValue","items"])):(o(),h("p",V1," Aktive E-Mail-Sequenzen werden bei den ausgewählten Leads abgebrochen. "))]),_:1}),e(Ht,null,{default:t(()=>[e(Yt),e(ze,{variant:"text",onClick:he[29]||(he[29]=Ge=>Y.value=!1)},{default:t(()=>[...he[61]||(he[61]=[n("Abbrechen",-1)])]),_:1}),e(ze,{color:"primary",loading:ae.value,disabled:K.value==="assign"&&!le.value,onClick:he[30]||(he[30]=Ge=>Ie(!1))},{default:t(()=>[n(v(K.value==="assign"?"Zuweisen":"Entfernen"),1)]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(st,{modelValue:ke.value,"onUpdate:modelValue":he[35]||(he[35]=Ge=>ke.value=Ge),"max-width":"480"},{default:t(()=>[e(Oe,null,{default:t(()=>[e(Qt,null,{default:t(()=>[...he[62]||(he[62]=[n("Bestehende Sequenzen",-1)])]),_:1}),e(Bt,null,{default:t(()=>[n(v(Ce.value)+" Lead(s) sind bereits in einer aktiven Sequenz. Bestehende Sequenz abbrechen und neue starten? ",1)]),_:1}),e(Ht,null,{default:t(()=>[e(Yt),e(ze,{variant:"text",onClick:he[32]||(he[32]=Ge=>ke.value=!1)},{default:t(()=>[...he[63]||(he[63]=[n("Abbrechen",-1)])]),_:1}),e(ze,{variant:"outlined",onClick:he[33]||(he[33]=()=>{ke.value=!1,Y.value=!1})},{default:t(()=>[...he[64]||(he[64]=[n(" Nur freie zuweisen ",-1)])]),_:1}),e(ze,{color:"warning",loading:ae.value,onClick:he[34]||(he[34]=Ge=>Ie(!0))},{default:t(()=>[...he[65]||(he[65]=[n(" Alle zuweisen (überschreiben) ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(st,{modelValue:Ue.value,"onUpdate:modelValue":he[38]||(he[38]=Ge=>Ue.value=Ge),"max-width":"440"},{default:t(()=>[e(Oe,null,{default:t(()=>[e(Qt,null,{default:t(()=>[n(v(Te.value==="add"?"Tag hinzufügen":"Tag entfernen"),1)]),_:1}),e(Bt,null,{default:t(()=>[a("p",A1,v(oe.value.length)+" Lead(s) ausgewählt.",1),e(It,{modelValue:ye.value,"onUpdate:modelValue":he[36]||(he[36]=Ge=>ye.value=Ge),label:"Tag","prepend-inner-icon":"mdi-tag",variant:"outlined",density:"comfortable","hide-details":"",autofocus:"",onKeyup:Kt($e,["enter"])},null,8,["modelValue"])]),_:1}),e(Ht,null,{default:t(()=>[e(Yt),e(ze,{variant:"text",onClick:he[37]||(he[37]=Ge=>Ue.value=!1)},{default:t(()=>[...he[66]||(he[66]=[n("Abbrechen",-1)])]),_:1}),e(ze,{color:"primary",loading:Je.value,disabled:!ye.value.trim(),onClick:$e},{default:t(()=>[n(v(Te.value==="add"?"Hinzufügen":"Entfernen"),1)]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(st,{modelValue:Ee.value,"onUpdate:modelValue":he[42]||(he[42]=Ge=>Ee.value=Ge),"max-width":"440"},{default:t(()=>[e(Oe,null,{default:t(()=>[e(Qt,null,{default:t(()=>[...he[67]||(he[67]=[n("Stage ändern",-1)])]),_:1}),e(Bt,null,{default:t(()=>[a("p",I1,v(oe.value.length)+" Lead(s) ausgewählt.",1),e(bt,{modelValue:lt.value,"onUpdate:modelValue":he[39]||(he[39]=Ge=>lt.value=Ge),items:P(Le),"item-title":"title","item-value":"value",label:"Neue Stage",variant:"outlined",density:"comfortable","hide-details":"",class:"mb-3"},null,8,["modelValue","items"]),e(ra,{modelValue:ut.value,"onUpdate:modelValue":he[40]||(he[40]=Ge=>ut.value=Ge),label:"Notiz (optional)",variant:"outlined",density:"comfortable",rows:"2","hide-details":""},null,8,["modelValue"])]),_:1}),e(Ht,null,{default:t(()=>[e(Yt),e(ze,{variant:"text",onClick:he[41]||(he[41]=Ge=>Ee.value=!1)},{default:t(()=>[...he[68]||(he[68]=[n("Abbrechen",-1)])]),_:1}),e(ze,{color:"primary",loading:Ve.value,disabled:!lt.value,onClick:ct},{default:t(()=>[...he[69]||(he[69]=[n(" Übernehmen ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1})}}}),z1=Me(P1,[["__scopeId","data-v-632edbdf"]]),h6=Object.freeze(Object.defineProperty({__proto__:null,default:z1},Symbol.toStringTag,{value:"Module"}));function yl(){const r=y(0),$=y(null);let d=null;function c(){d&&(clearInterval(d),d=null),$.value=null,r.value=0}function s(u,f){c(),$.value=u,r.value=f,d=setInterval(()=>{r.value--,r.value<=0&&c()},1e3)}async function m(){if(!$.value)return!1;const u=$.value;try{const f=await re.delete(`/admin/direct-mail/${u}`);return f.success?(ue.info("ADMIN","Direkt-Mail-Sendung abgebrochen",{jobId:u}),c(),!0):(ue.warn("ADMIN","Direkt-Mail-Cancel fehlgeschlagen",{jobId:u,error:f.error}),c(),!1)}catch(f){return ue.error("ADMIN","Direkt-Mail-Cancel: Netzwerkfehler",{error:f instanceof Error?f.message:"Unbekannt"}),c(),!1}}return Ft(c),{countdown:r,jobId:$,start:s,cancel:m,cleanup:c}}const D1={class:"lead-funnel-progress"},T1={class:"d-flex align-center justify-space-between mb-2"},L1={key:0,class:"text-caption text-medium-emphasis"},E1={class:"text-caption font-weight-medium ml-auto"},M1={class:"text-caption text-medium-emphasis mt-1"},N1=Ae({__name:"LeadFunnelProgress",props:{currentStep:{},totalSteps:{},sequenceName:{}},setup(r){const $=r,d=se(()=>$.totalSteps?Math.round($.currentStep/$.totalSteps*100):0),c=se(()=>d.value>=80?"success":d.value>=50?"primary":"info");return(s,m)=>{const u=l("v-progress-linear");return o(),h("div",D1,[a("div",T1,[r.sequenceName?(o(),h("span",L1,v(r.sequenceName),1)):U("",!0),a("span",E1," Schritt "+v(r.currentStep)+" von "+v(r.totalSteps),1)]),e(u,{"model-value":d.value,color:c.value,rounded:"",height:"8","bg-opacity":"0.2"},null,8,["model-value","color"]),a("div",M1,v(d.value)+" % abgeschlossen ",1)])}}}),U1=Me(N1,[["__scopeId","data-v-bedfe663"]]),B1={class:"lead-email-timeline"},F1={key:0,class:"text-body-2 text-medium-emphasis text-center py-4"},O1={class:"d-flex align-center justify-space-between flex-wrap ga-1"},R1={class:"text-body-2 font-weight-medium"},K1={class:"text-caption text-medium-emphasis"},j1={key:0,class:"text-caption text-medium-emphasis mt-1"},q1={key:1,class:"mt-1"},G1={key:2,class:"text-caption text-medium-emphasis mt-1"},H1={key:2,class:"text-center mt-2"},tl=10,W1=Ae({__name:"LeadEmailTimeline",props:{events:{}},setup(r){const $=r,d=y(tl),c=se(()=>$.events.slice(0,d.value)),s=se(()=>$.events.length>d.value);function m(){d.value=Math.min(d.value+tl,$.events.length)}function u(k){return{"email-sent":"mdi-email-send","email-opened":"mdi-email-open","email-clicked":"mdi-cursor-default-click",meeting:"mdi-calendar-check","email-bounced":"mdi-email-alert"}[k]??"mdi-information-outline"}function f(k){return{"email-sent":"info","email-opened":"primary","email-clicked":"warning",meeting:"success","email-bounced":"error"}[k]??"default"}function p(k){return{"email-sent":"E-Mail gesendet","email-opened":"E-Mail geöffnet","email-clicked":"Link geklickt",meeting:"Termin gebucht","email-bounced":"E-Mail bounced"}[k]??k}function _(k){return k?new Date(k).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"–"}return(k,i)=>{const g=l("v-icon"),x=l("v-chip"),w=l("v-timeline-item"),b=l("v-timeline"),I=l("v-btn");return o(),h("div",B1,[r.events.length===0?(o(),h("div",F1," Noch keine Aktivitäten aufgezeichnet. ")):(o(),N(b,{key:1,density:"compact",side:"end","truncate-line":"both"},{default:t(()=>[(o(!0),h(be,null,Pe(c.value,(V,E)=>(o(),N(w,{key:E,"dot-color":f(V.type),size:"x-small"},{icon:t(()=>[e(g,{icon:u(V.type),size:"14"},null,8,["icon"])]),default:t(()=>[a("div",O1,[a("span",R1,v(p(V.type)),1),a("span",K1,v(_(V.timestamp)),1)]),V.subject?(o(),h("div",j1,v(V.subject),1)):U("",!0),V.topic?(o(),h("div",q1,[e(x,{size:"x-small",color:"primary",variant:"tonal"},{default:t(()=>[n(v(V.topic),1)]),_:2},1024)])):U("",!0),V.details&&!V.subject?(o(),h("div",G1,v(V.details),1)):U("",!0)]),_:2},1032,["dot-color"]))),128))]),_:1})),s.value?(o(),h("div",H1,[e(I,{variant:"text",color:"primary",size:"small","prepend-icon":"mdi-chevron-down",onClick:m},{default:t(()=>[n(" Mehr laden ("+v(r.events.length-d.value)+" weitere) ",1)]),_:1})])):U("",!0)])}}}),Z1=Me(W1,[["__scopeId","data-v-aeec31b9"]]),J1={class:"lead-meetings-list"},Q1={key:0,class:"text-body-2 text-medium-emphasis text-center py-4"},Y1={class:"d-flex align-center justify-space-between flex-wrap ga-2"},X1={class:"d-flex align-center ga-2 flex-wrap"},eb={class:"text-caption text-medium-emphasis"},tb=Ae({__name:"LeadMeetingsList",props:{meetings:{}},setup(r){function $(s){return{scheduled:"Geplant",completed:"Abgehalten","no-show":"Nicht erschienen",cancelled:"Abgesagt"}[s]??s}function d(s){return{scheduled:"info",completed:"success","no-show":"warning",cancelled:"error"}[s]??"default"}function c(s){return s?new Date(s).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"–"}return(s,m)=>{const u=l("v-chip"),f=l("v-icon"),p=l("v-card-text"),_=l("v-card");return o(),h("div",J1,[r.meetings.length===0?(o(),h("div",Q1," Noch keine Termine vorhanden. ")):U("",!0),(o(!0),h(be,null,Pe(r.meetings,k=>(o(),N(_,{key:k._id,variant:"outlined",rounded:"lg",class:"lead-meetings-list__item mb-2"},{default:t(()=>[e(p,{class:"pa-3"},{default:t(()=>[a("div",Y1,[a("div",X1,[k.topic?(o(),N(u,{key:0,color:"primary",size:"x-small",variant:"tonal"},{default:t(()=>[n(v(k.topic),1)]),_:2},1024)):U("",!0),e(u,{color:d(k.status),size:"x-small",variant:"tonal"},{default:t(()=>[n(v($(k.status)),1)]),_:2},1032,["color"])]),a("span",eb,[e(f,{size:"12",class:"mr-1"},{default:t(()=>[...m[0]||(m[0]=[n("mdi-calendar-clock",-1)])]),_:1}),n(" "+v(c(k.scheduledAt)),1)])])]),_:2},1024)]),_:2},1024))),128))])}}}),ab=Me(tb,[["__scopeId","data-v-fd67869b"]]),lb=Ae({__name:"LeadEngagementBadge",props:{state:{}},setup(r){function $(s){return{hot:"Hot",warm:"Warm",cold:"Kalt",stuck:"Stagnierend","single-converter":"Einmal-Konverter","multi-converter":"Mehr-Konverter","power-lead":"Power-Lead",bounced:"Bounced",unsubscribed:"Abgemeldet","awaiting-next-step":"Wartet auf nächsten Schritt",active:"Aktiv"}[s]??s}function d(s){return{hot:"error",warm:"warning",cold:"info",stuck:"grey","single-converter":"success","multi-converter":"primary","power-lead":"warning",bounced:"error",unsubscribed:"grey","awaiting-next-step":"info",active:"default"}[s]??"default"}function c(s){return{hot:"mdi-fire",warm:"mdi-thermometer",cold:"mdi-snowflake",stuck:"mdi-timer-sand","single-converter":"mdi-check-circle","multi-converter":"mdi-check-circle-multiple","power-lead":"mdi-lightning-bolt",bounced:"mdi-email-alert",unsubscribed:"mdi-email-remove","awaiting-next-step":"mdi-clock-outline",active:"mdi-play-circle-outline"}[s]??"mdi-help-circle-outline"}return(s,m)=>{const u=l("v-chip");return o(),N(u,{color:d(r.state),size:"small",variant:"tonal","prepend-icon":c(r.state)},{default:t(()=>[n(v($(r.state)),1)]),_:1},8,["color","prepend-icon"])}}}),nb={class:"text-body-1 font-weight-semibold"},ob={key:1,class:"mb-4"},sb={key:2,class:"mb-4"},ib={class:"text-caption text-medium-emphasis mb-2 d-flex align-center ga-2"},rb={class:"text-caption text-medium-emphasis mb-2 d-flex align-center ga-2"},db={key:4,class:"py-4"},ub=Ae({__name:"LeadEmailActivity",props:{leadId:{},engagementState:{},sequenceInfo:{},emailLogs:{}},setup(r){const $=r,d=y([]),c=y([]),s=y(!1),m=y(!1),u=y(null),f=y(null);Ze(()=>$.emailLogs,i=>{i&&(d.value=i)},{immediate:!0}),Ze(()=>$.leadId,(i,g)=>{i&&i!==g&&k()});const p=se(()=>{const i=[];for(const g of d.value)g.sentAt&&i.push({type:"email-sent",timestamp:g.sentAt,subject:g.subject,topic:g.topic}),g.openedAt&&i.push({type:"email-opened",timestamp:g.openedAt,subject:g.subject,topic:g.topic}),g.clickedAt&&i.push({type:"email-clicked",timestamp:g.clickedAt,subject:g.subject,topic:g.topic}),g.status==="bounced"&&g.bouncedAt&&i.push({type:"email-bounced",timestamp:g.bouncedAt,subject:g.subject});for(const g of c.value)g.scheduledAt&&i.push({type:"meeting",timestamp:g.scheduledAt,topic:g.topic,details:`Termin: ${g.topic??""}`});return i.sort((g,x)=>new Date(x.timestamp).getTime()-new Date(g.timestamp).getTime())});async function _(){s.value=!0,u.value=null;try{const i=await re.get(`/email-logs?leadId=${$.leadId}&limit=100`);i.success&&i.data?(d.value=i.data.items??[],ue.debug("ADMIN","Lead E-Mail-Logs geladen",{leadId:$.leadId,count:d.value.length})):(u.value=i.error??"Fehler beim Laden der E-Mail-Aktivitäten.",ue.error("ADMIN","Lead E-Mail-Logs Ladefehler",{leadId:$.leadId,error:i.error}))}catch{u.value="Netzwerkfehler beim Laden der E-Mail-Aktivitäten.",ue.error("ADMIN","Netzwerkfehler beim Laden der E-Mail-Aktivitäten",{leadId:$.leadId})}finally{s.value=!1}}async function k(){m.value=!0,f.value=null;try{const i=await re.get(`/meetings?leadId=${$.leadId}`);i.success&&i.data?(c.value=i.data.items??[],ue.debug("ADMIN","Lead Termine geladen",{leadId:$.leadId,count:c.value.length})):(f.value=i.error??"Fehler beim Laden der Termine.",ue.warn("ADMIN","Lead Termine Ladefehler",{leadId:$.leadId,error:i.error}))}catch{f.value="Netzwerkfehler beim Laden der Termine.",ue.error("ADMIN","Netzwerkfehler beim Laden der Termine",{leadId:$.leadId})}finally{m.value=!1}}return rt(async()=>{$.emailLogs===void 0?await Promise.all([_(),k()]):await k()}),(i,g)=>{const x=l("v-chip"),w=l("v-card-title"),b=l("v-divider"),I=l("v-alert"),V=l("v-icon"),E=l("v-skeleton-loader"),R=l("v-card-text"),M=l("v-card");return o(),N(M,{rounded:"lg",class:"lead-email-activity"},{default:t(()=>[e(w,{class:"pa-4 pb-2 d-flex align-center justify-space-between"},{default:t(()=>[a("span",nb,[g[0]||(g[0]=n(" E-Mail-Aktivität ",-1)),e(x,{class:"ml-2",size:"x-small",color:"primary",variant:"tonal"},{default:t(()=>[n(v(d.value.length),1)]),_:1})]),r.engagementState?(o(),N(lb,{key:0,state:r.engagementState},null,8,["state"])):U("",!0)]),_:1}),e(b),e(R,{class:"pa-4"},{default:t(()=>[u.value?(o(),N(I,{key:0,type:"error",variant:"tonal",density:"compact",text:u.value,class:"mb-4"},null,8,["text"])):U("",!0),r.sequenceInfo&&r.sequenceInfo.totalSteps?(o(),h("div",ob,[g[1]||(g[1]=a("div",{class:"text-caption text-medium-emphasis mb-2"},"Sequenz-Fortschritt",-1)),e(U1,{"current-step":r.sequenceInfo.currentStep??0,"total-steps":r.sequenceInfo.totalSteps,"sequence-name":r.sequenceInfo.sequenceName},null,8,["current-step","total-steps","sequence-name"])])):U("",!0),c.value.length>0?(o(),h("div",sb,[a("div",ib,[e(V,{size:"14"},{default:t(()=>[...g[2]||(g[2]=[n("mdi-calendar-check",-1)])]),_:1}),g[3]||(g[3]=n(" Termine ",-1)),e(x,{size:"x-small",color:"success",variant:"tonal"},{default:t(()=>[n(v(c.value.length),1)]),_:1})]),m.value?(o(),N(E,{key:0,type:"list-item"})):f.value?(o(),N(I,{key:1,type:"warning",variant:"tonal",density:"compact",text:f.value},null,8,["text"])):(o(),N(ab,{key:2,meetings:c.value},null,8,["meetings"]))])):U("",!0),c.value.length>0?(o(),N(b,{key:3,class:"mb-4"})):U("",!0),a("div",rb,[e(V,{size:"14"},{default:t(()=>[...g[4]||(g[4]=[n("mdi-timeline-clock",-1)])]),_:1}),g[5]||(g[5]=n(" Aktivitäts-Verlauf ",-1))]),s.value?(o(),h("div",db,[(o(),h(be,null,Pe(5,T=>e(E,{key:T,type:"list-item-two-line",class:"mb-1"})),64))])):(o(),N(Z1,{key:5,events:p.value},null,8,["events"]))]),_:1})]),_:1})}}}),cb=Me(ub,[["__scopeId","data-v-aee19977"]]),mb=Ae({__name:"LeadReplyMarkerToggle",props:{lead:{}},emits:["updated"],setup(r,{emit:$}){var w,b;const d=r,c=$,s=y(((w=d.lead.replyMarker)==null?void 0:w.received)??!1),m=y(((b=d.lead.replyMarker)==null?void 0:b.note)??""),u=y(!1),f=y(null),p=y(!1),_=y(!1);Ze(()=>d.lead.replyMarker,I=>{s.value=(I==null?void 0:I.received)??!1,m.value=(I==null?void 0:I.note)??""},{deep:!0});function k(I){var V;!I&&((V=d.lead.replyMarker)!=null&&V.received)?_.value=!0:s.value=I}function i(){s.value=!1,_.value=!1}function g(){var I;s.value=((I=d.lead.replyMarker)==null?void 0:I.received)??!1,_.value=!1}async function x(){u.value=!0,f.value=null,p.value=!1;try{const I=await re.put(`/leads/${d.lead._id}/reply-marker`,{received:s.value,note:m.value});I.success?(p.value=!0,ue.info("ADMIN","Reply-Marker gespeichert",{leadId:d.lead._id,received:s.value}),c("updated"),setTimeout(()=>{p.value=!1},3e3)):(f.value=I.error||"Reply-Marker konnte nicht gespeichert werden.",ue.error("ADMIN","Reply-Marker speichern fehlgeschlagen",{error:I.error}))}catch(I){f.value="Netzwerkfehler beim Speichern des Reply-Markers.",ue.error("ADMIN","Reply-Marker speichern: Netzwerkfehler",{error:I instanceof Error?I.message:"Unbekannt"})}finally{u.value=!1}}return(I,V)=>{const E=l("v-alert"),R=l("v-switch"),M=l("v-textarea"),T=l("v-btn"),D=l("v-card-title"),H=l("v-card-text"),O=l("v-card-actions"),S=l("v-card"),B=l("v-dialog");return o(),h("div",null,[f.value?(o(),N(E,{key:0,type:"error",variant:"tonal",class:"mb-3",text:f.value,density:"compact",closable:"","onClick:close":V[0]||(V[0]=G=>f.value=null)},null,8,["text"])):U("",!0),p.value?(o(),N(E,{key:1,type:"success",variant:"tonal",class:"mb-3",text:"Reply-Marker gespeichert.",density:"compact"})):U("",!0),e(R,{"model-value":s.value,color:"success",label:"Reply erhalten","hide-details":"",class:"mb-3",disabled:u.value,"onUpdate:modelValue":V[1]||(V[1]=G=>k(G))},null,8,["model-value","disabled"]),e(M,{modelValue:m.value,"onUpdate:modelValue":V[2]||(V[2]=G=>m.value=G),label:"Notiz (optional)",variant:"outlined",density:"comfortable",rows:3,maxlength:500,counter:"",disabled:u.value,class:"mb-3"},null,8,["modelValue","disabled"]),e(T,{color:"primary",variant:"flat",size:"small",loading:u.value,onClick:x},{default:t(()=>[...V[4]||(V[4]=[n(" Speichern ",-1)])]),_:1},8,["loading"]),e(B,{modelValue:_.value,"onUpdate:modelValue":V[3]||(V[3]=G=>_.value=G),"max-width":"420"},{default:t(()=>[e(S,{rounded:"lg"},{default:t(()=>[e(D,{class:"pa-4 pb-2 text-body-1 font-weight-semibold"},{default:t(()=>[...V[5]||(V[5]=[n(" Reply-Marker zurücksetzen? ",-1)])]),_:1}),e(H,{class:"pa-4 pt-2"},{default:t(()=>[...V[6]||(V[6]=[n(" Soll der Reply-Marker wirklich zurückgesetzt werden? Diese Aktion kann den Intent-Auto-Trigger beeinflussen. ",-1)])]),_:1}),e(O,{class:"pa-4 pt-0 d-flex justify-end ga-2"},{default:t(()=>[e(T,{variant:"text",onClick:g},{default:t(()=>[...V[7]||(V[7]=[n("Abbrechen",-1)])]),_:1}),e(T,{color:"error",variant:"flat",onClick:i},{default:t(()=>[...V[8]||(V[8]=[n("Zurücksetzen",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}}),vb={key:0,class:"text-caption text-error mt-1"},Ua=Ae({__name:"MailjetSenderSelect",props:{modelValue:{},label:{}},emits:["update:modelValue"],setup(r,{emit:$}){const d=$,c=y([]),s=y(!1),m=y(null);async function u(){s.value=!0,m.value=null;try{const f=await re.get("/admin/mailjet/senders");f.success&&f.data?c.value=f.data:(m.value=f.error||"Sender konnten nicht geladen werden.",ue.warn("ADMIN","Mailjet-Sender laden fehlgeschlagen",{error:f.error}))}catch(f){m.value="Netzwerkfehler beim Laden der Sender.",ue.warn("ADMIN","Mailjet-Sender laden: unerwartete Exception",{error:f instanceof Error?f.message:"Unbekannt"})}finally{s.value=!1}}return rt(u),(f,p)=>{const _=l("v-select");return o(),h("div",null,[e(_,{"model-value":r.modelValue,items:c.value.map(k=>({title:`${k.name} <${k.email}>${k.isDefault?" (Default)":""}`,value:k.email})),label:r.label||"Mailjet-Versender",loading:s.value,"no-data-text":m.value||"Keine Sender verfügbar",variant:"outlined",density:"comfortable",clearable:"","onUpdate:modelValue":p[0]||(p[0]=k=>d("update:modelValue",k??""))},null,8,["model-value","items","label","loading","no-data-text"]),m.value?(o(),h("div",vb,v(m.value)+" - bitte Sender in Mailjet anlegen und verifizieren. ",1)):U("",!0)])}}}),pb={class:"mt-2"},fb={class:"text-body-2 mb-1"},gb={class:"text-body-2 mb-1"},bb={key:0,class:"text-body-2 mb-3"},yb={class:"d-flex flex-wrap ga-2"},_b=Ae({__name:"DirectMailSequenceWarning",props:{sequenceWarning:{},loading:{type:Boolean}},emits:["pause-and-send","send-anyway"],setup(r,{emit:$}){const d=$;function c(s){return s?new Date(s).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"–"}return(s,m)=>{const u=l("v-btn"),f=l("v-alert");return o(),N(f,{type:"warning",variant:"tonal",class:"mb-4",icon:"mdi-alert-circle-outline"},{title:t(()=>[...m[2]||(m[2]=[a("span",{class:"text-subtitle-2 font-weight-semibold"},"Lead ist in aktiver Sequenz",-1)])]),default:t(()=>[a("div",pb,[a("div",fb,[m[3]||(m[3]=a("strong",null,"Sequenz:",-1)),n(" "+v(r.sequenceWarning.sequenceName),1)]),a("div",gb,[m[4]||(m[4]=a("strong",null,"Fortschritt:",-1)),n(" Schritt "+v(r.sequenceWarning.currentStep)+" von "+v(r.sequenceWarning.totalSteps),1)]),r.sequenceWarning.nextSendAt?(o(),h("div",bb,[m[5]||(m[5]=a("strong",null,"Nächster Versand:",-1)),n(" "+v(c(r.sequenceWarning.nextSendAt)),1)])):U("",!0),m[8]||(m[8]=a("div",{class:"text-body-2 text-medium-emphasis mb-3"}," Diese Direkt-Mail wird unabhängig von der Sequenz gesendet. Bitte wählen Sie, wie verfahren werden soll. ",-1)),a("div",yb,[e(u,{size:"small",color:"warning",variant:"flat","prepend-icon":"mdi-pause",loading:r.loading,onClick:m[0]||(m[0]=p=>d("pause-and-send"))},{default:t(()=>[...m[6]||(m[6]=[n(" Sequenz pausieren und senden ",-1)])]),_:1},8,["loading"]),e(u,{size:"small",color:"warning",variant:"outlined","prepend-icon":"mdi-send-outline",loading:r.loading,onClick:m[1]||(m[1]=p=>d("send-anyway"))},{default:t(()=>[...m[7]||(m[7]=[n(" Trotzdem senden ",-1)])]),_:1},8,["loading"])])])]),_:1})}}}),kb={class:"text-subtitle-1 font-weight-semibold"},hb={class:"d-flex align-center ga-2 mb-4 pa-3 rounded bg-surface-variant"},xb={class:"text-body-2 font-weight-medium"},wb={class:"text-caption text-medium-emphasis"},Sb={class:"mb-4"},$b={class:"d-flex justify-end"},_l=Ae({__name:"DirectMailComposer",props:{modelValue:{type:Boolean},lead:{},prefillSubject:{},prefillBody:{}},emits:["update:modelValue","sent"],setup(r,{emit:$}){const d=r,c=$,s=y(""),m=y(""),u=y(""),f=y(!1),p=y(!1),_=y(null),k=y(null),i=y(!1);Ze(()=>d.modelValue,E=>{var R;E&&(s.value=d.lead.assignedSender||"",m.value=d.prefillSubject||"",u.value=d.prefillBody||"",_.value=null,k.value=null,((R=d.lead.emailSequence)==null?void 0:R.status)==="active"&&(k.value={sequenceName:String(d.lead.activeSequenceName??"Aktive Sequenz"),currentStep:d.lead.emailSequence.currentStep,totalSteps:0,nextSendAt:null}))},{immediate:!1});function g(){c("update:modelValue",!1)}async function x(){p.value=!0,_.value=null;try{const E=await re.post("/admin/direct-mail/draft",{leadId:d.lead._id});E.success&&E.data?(m.value=E.data.subject,u.value=E.data.body,ue.info("ADMIN","KI-Vorschlag fuer Direkt-Mail generiert",{leadId:d.lead._id})):(_.value=E.error||"KI-Vorschlag konnte nicht generiert werden.",ue.warn("ADMIN","KI-Vorschlag fuer Direkt-Mail fehlgeschlagen",{error:E.error}))}catch(E){_.value="Netzwerkfehler beim Generieren des KI-Vorschlags.",ue.error("ADMIN","KI-Vorschlag Direkt-Mail: Netzwerkfehler",{error:E instanceof Error?E.message:"Unbekannt"})}finally{p.value=!1}}async function w(E=!1){f.value=!0,_.value=null;try{const R={sender:s.value,subject:m.value,body:u.value};E&&(R.confirmedDespiteSequence=!0);const M=await re.post(`/admin/direct-mail/leads/${d.lead._id}/send`,R);if(M.success&&M.data)ue.info("ADMIN","Direkt-Mail in Warteschlange",{jobId:M.data.jobId,leadId:d.lead._id}),c("sent",{jobId:M.data.jobId,scheduledFor:M.data.scheduledFor,emailLogId:M.data.emailLogId}),g();else if(M.status===409){const T=M.data;if(T!=null&&T.sequenceWarning){const D=T.sequenceWarning;k.value=D,ue.warn("ADMIN","Sequenz-Konflikt beim Direkt-Mail-Senden",{leadId:d.lead._id})}else _.value=M.error||"Lead ist in aktiver Sequenz."}else _.value=M.error||"Fehler beim Senden der Mail.",ue.error("ADMIN","Direkt-Mail senden fehlgeschlagen",{error:M.error})}catch(R){_.value="Netzwerkfehler beim Senden der Mail.",ue.error("ADMIN","Direkt-Mail senden: Netzwerkfehler",{error:R instanceof Error?R.message:"Unbekannt"})}finally{f.value=!1,i.value=!1}}async function b(){await w(!1)}async function I(){i.value=!0,_.value=null;try{const E=await re.post(`/leads/${d.lead._id}/sequence/pause`);if(!E.success){_.value=E.error||"Sequenz konnte nicht pausiert werden.",ue.warn("ADMIN","Sequenz-Pause fehlgeschlagen vor Direkt-Mail",{error:E.error}),i.value=!1;return}ue.info("ADMIN","Sequenz pausiert vor Direkt-Mail",{leadId:d.lead._id}),await w(!0)}catch(E){_.value="Netzwerkfehler beim Pausieren der Sequenz.",ue.error("ADMIN","Sequenz-Pause Netzwerkfehler",{error:E instanceof Error?E.message:"Unbekannt"}),i.value=!1}}async function V(){i.value=!0,await w(!0)}return(E,R)=>{const M=l("v-icon"),T=l("v-tooltip"),D=l("v-btn"),H=l("v-card-title"),O=l("v-divider"),S=l("v-alert"),B=l("v-text-field"),G=l("v-textarea"),W=l("v-card-text"),F=l("v-card-actions"),L=l("v-card"),A=l("v-dialog");return o(),N(A,{"model-value":r.modelValue,"max-width":"800",scrollable:"","onUpdate:modelValue":R[4]||(R[4]=z=>c("update:modelValue",z))},{default:t(()=>[e(L,{rounded:"lg"},{default:t(()=>[e(H,{class:"pa-4 pb-2 d-flex align-center justify-space-between"},{default:t(()=>[a("span",kb,[e(M,{class:"mr-2",size:"20"},{default:t(()=>[...R[5]||(R[5]=[n("mdi-email-edit-outline",-1)])]),_:1}),R[6]||(R[6]=n(" Direkt-Mail senden ",-1))]),e(D,{icon:"",variant:"text",size:"small","aria-label":"Schliessen",onClick:g},{default:t(()=>[e(T,{activator:"parent",location:"bottom"},{default:t(()=>[...R[7]||(R[7]=[n("Schliessen",-1)])]),_:1}),e(M,null,{default:t(()=>[...R[8]||(R[8]=[n("mdi-close",-1)])]),_:1})]),_:1})]),_:1}),e(O),e(W,{class:"pa-4"},{default:t(()=>[_.value?(o(),N(S,{key:0,type:"error",variant:"tonal",class:"mb-4",text:_.value,closable:"","onClick:close":R[0]||(R[0]=z=>_.value=null)},null,8,["text"])):U("",!0),k.value?(o(),N(_b,{key:1,"sequence-warning":k.value,loading:i.value,onPauseAndSend:I,onSendAnyway:V},null,8,["sequence-warning","loading"])):U("",!0),R[11]||(R[11]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"An",-1)),a("div",hb,[e(M,{size:"16"},{default:t(()=>[...R[9]||(R[9]=[n("mdi-account-outline",-1)])]),_:1}),a("span",xb,v(r.lead.firstName)+" "+v(r.lead.lastName),1),a("span",wb,"<"+v(r.lead.email)+">",1)]),a("div",Sb,[e(Ua,{modelValue:s.value,"onUpdate:modelValue":R[1]||(R[1]=z=>s.value=z),label:"Absender"},null,8,["modelValue"])]),e(B,{modelValue:m.value,"onUpdate:modelValue":R[2]||(R[2]=z=>m.value=z),label:"Betreff",variant:"outlined",density:"comfortable",class:"mb-4",disabled:f.value},null,8,["modelValue","disabled"]),e(G,{modelValue:u.value,"onUpdate:modelValue":R[3]||(R[3]=z=>u.value=z),label:"Nachricht",variant:"outlined",rows:10,"min-rows":10,"auto-grow":"",class:"mb-4",disabled:f.value},null,8,["modelValue","disabled"]),a("div",$b,[e(D,{size:"small",variant:"outlined",color:"primary","prepend-icon":"mdi-auto-fix",loading:p.value,disabled:f.value,onClick:x},{default:t(()=>[...R[10]||(R[10]=[n(" KI-Vorschlag generieren ",-1)])]),_:1},8,["loading","disabled"])])]),_:1}),e(O),e(F,{class:"pa-4 d-flex justify-space-between"},{default:t(()=>[e(D,{variant:"text",disabled:f.value,onClick:g},{default:t(()=>[...R[12]||(R[12]=[n(" Abbrechen ",-1)])]),_:1},8,["disabled"]),e(D,{color:"primary",variant:"flat","prepend-icon":"mdi-send-outline",loading:f.value,disabled:!s.value||!m.value.trim()||!u.value.trim()||p.value,onClick:b},{default:t(()=>[...R[13]||(R[13]=[n(" Senden ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["model-value"])}}}),Cb=Ae({__name:"LeadDirectMailButton",props:{lead:{},prefillSubject:{},prefillBody:{}},emits:["sent"],setup(r,{emit:$}){const d=$,c=y(!1);function s(m){c.value=!1,d("sent",m)}return(m,u)=>{const f=l("v-btn");return o(),h("div",null,[e(f,{color:"primary",variant:"outlined",size:"small","prepend-icon":"mdi-email-edit-outline",onClick:u[0]||(u[0]=p=>c.value=!0)},{default:t(()=>[...u[2]||(u[2]=[n(" Direkt-Mail schreiben ",-1)])]),_:1}),e(_l,{modelValue:c.value,"onUpdate:modelValue":u[1]||(u[1]=p=>c.value=p),lead:r.lead,"prefill-subject":r.prefillSubject,"prefill-body":r.prefillBody,onSent:s},null,8,["modelValue","lead","prefill-subject","prefill-body"])])}}}),Vb={key:0,class:"d-flex align-center ga-2"},Ab={key:1,class:"d-flex align-center ga-3"},Ib={class:"text-body-2"},kl=Ae({__name:"DirectMailUndoToast",props:{countdown:{},jobId:{}},emits:["cancel"],setup(r,{emit:$}){const d=r,c=$,s=y(!1);let m=null;const u=y(!1);Ze(()=>d.jobId,p=>{p&&d.countdown>0&&(s.value=!1,u.value=!0)}),Ze(()=>d.countdown,p=>{p<=0&&!s.value&&(u.value=!1)});function f(){c("cancel"),s.value=!0,u.value=!0,m&&clearTimeout(m),m=setTimeout(()=>{u.value=!1,s.value=!1},3e3)}return(p,_)=>{const k=l("v-icon"),i=l("v-btn"),g=l("v-snackbar");return o(),N(g,{modelValue:u.value,"onUpdate:modelValue":_[0]||(_[0]=x=>u.value=x),timeout:-1,location:"bottom right",color:"surface",elevation:"4",rounded:"lg",class:"direct-mail-undo-toast"},{default:t(()=>[s.value?(o(),h("div",Vb,[e(k,{color:"success",size:"20"},{default:t(()=>[..._[1]||(_[1]=[n("mdi-check-circle-outline",-1)])]),_:1}),_[2]||(_[2]=a("span",{class:"text-body-2"},"Sendung abgebrochen",-1))])):(o(),h("div",Ab,[e(k,{color:"primary",size:"20"},{default:t(()=>[..._[3]||(_[3]=[n("mdi-email-fast-outline",-1)])]),_:1}),a("span",Ib,[_[4]||(_[4]=n("Mail wird in ",-1)),a("strong",null,v(r.countdown)+"s",1),_[5]||(_[5]=n(" gesendet",-1))]),e(i,{size:"x-small",color:"primary",variant:"outlined","prepend-icon":"mdi-undo",onClick:f},{default:t(()=>[..._[6]||(_[6]=[n(" Rückgängig ",-1)])]),_:1})]))]),_:1},8,["modelValue"])}}}),Pb={class:"d-flex align-center ga-4 mb-2"},zb={key:0,class:"d-flex align-center ga-2 text-caption text-medium-emphasis mb-4 ml-14"},Db={key:2,class:"d-flex justify-center py-16"},Tb={key:0,class:"text-medium-emphasis ml-2"},Lb={class:"d-flex align-center justify-center mb-4"},Eb={class:"d-flex flex-wrap justify-center ga-2 mb-4"},Mb={class:"text-caption"},Nb={class:"font-weight-medium"},Ub={class:"text-medium-emphasis ml-2"},Bb={key:0,class:"text-caption text-medium-emphasis"},Fb={class:"d-flex align-center justify-center mb-4"},Ob={key:0,class:"text-body-2 text-medium-emphasis text-center py-4"},Rb={class:"d-flex align-center justify-space-between"},Kb={class:"text-body-2 font-weight-medium"},jb={class:"text-caption text-medium-emphasis"},qb={key:0,class:"text-caption text-medium-emphasis mt-1"},Gb={class:"text-body-2"},Hb={class:"d-flex flex-wrap ga-2"},Wb={class:"d-flex align-center ga-2"},Zb={class:"d-flex align-center justify-space-between mb-3"},Jb={class:"mb-3"},Qb={class:"d-flex justify-space-between text-caption mb-1"},Yb={class:"font-weight-medium"},Xb={class:"mb-3"},ey={class:"d-flex justify-space-between text-caption mb-1"},ty={class:"font-weight-medium"},ay={key:0,class:"text-caption text-medium-emphasis mt-2"},ly={class:"text-caption text-medium-emphasis"},ny={class:"text-caption text-medium-emphasis"},oy={class:"text-caption text-medium-emphasis"},sy={class:"text-subtitle-1 font-weight-semibold"},iy={class:"d-flex flex-wrap ga-2 mb-4"},ry={class:"text-caption text-medium-emphasis align-self-center"},dy={class:"d-flex flex-wrap ga-4 text-caption text-medium-emphasis mb-4"},uy={key:0},cy={key:1},my={key:2},vy=["innerHTML"],py=Ae({__name:"LeadDetailView",setup(r){const $=xt(),d=Ut(),c=se(()=>d.params.id),{countdown:s,jobId:m,start:u,cancel:f}=yl();function p(Se){const me=new Date(Se.scheduledFor).getTime()-Date.now(),ee=Math.max(1,Math.round(me/1e3));u(Se.jobId,ee)}const _=y(!0),k=y(null),i=y(null),g=y(!1),x=y(!1),w=y(null),b=y(!1),I=y([]),V=y(!1),E=y(""),R=y(!1),M=y(null),T=y(null),D=y([]),H=y(!1),O=y(!1),S=y(null),B=qe("lead_detail_email_sort",[]),G=[{title:"Betreff",key:"subject",sortable:!0},{title:"Status",key:"status",sortable:!0},{title:"Gesendet",key:"sentAt",sortable:!0},{title:"Geöffnet",key:"openedAt",sortable:!0},{title:"Geklickt",key:"clickedAt",sortable:!0}];function W(Se){return Se?new Date(Se).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"–"}function F(Se){return Se?new Date(Se).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}):"–"}function L(Se){return{neu:"default",kontaktiert:"info",qualifiziert:"primary",angebot:"warning",verhandlung:"secondary",gewonnen:"success",verloren:"error"}[Se]||"default"}function A(Se){return{"email-open":"mdi-email-open-outline","email-click":"mdi-cursor-default-click-outline","page-visit":"mdi-eye-outline","form-submit":"mdi-form-select",download:"mdi-download-outline",meeting:"mdi-calendar-check-outline"}[Se]||"mdi-information-outline"}function z(Se){return{"email-open":"E-Mail geöffnet","email-click":"Link geklickt","page-visit":"Seite besucht","form-submit":"Formular ausgefüllt",download:"Download",meeting:"Meeting"}[Se]||Se}function j(Se){return Se>=70?"success":Se>=40?"warning":"error"}async function J(){_.value=!0,k.value=null;const Se=await re.get(`/leads/${c.value}`);Se.success?(i.value=Se.data,ue.debug("ADMIN","Lead loaded",{id:c.value})):(k.value="Fehler beim Laden des Leads.",ue.error("ADMIN","Lead load failed",{id:c.value,error:Se.error})),_.value=!1}async function Q(Se){if(!i.value||i.value.pipeline.stage===Se)return;g.value=!0;const me=await re.put(`/leads/${c.value}`,{pipeline:{stage:Se}});me.success?(i.value=me.data,ue.info("ADMIN","Lead stage changed",{id:c.value,stage:Se})):ue.error("ADMIN","Lead stage change failed",{id:c.value,stage:Se,error:me.error}),g.value=!1}async function te(){x.value=!0,w.value=null,b.value=!1;const Se=await re.post(`/hubspot/sync/${c.value}`);Se.success?(b.value=!0,ue.info("ADMIN","HubSpot sync triggered",{id:c.value}),await J(),setTimeout(()=>{b.value=!1},3e3)):(w.value="HubSpot-Synchronisation fehlgeschlagen.",ue.error("ADMIN","HubSpot sync failed",{id:c.value,error:Se.error})),x.value=!1}function ve(Se){return{queued:"In Warteschlange","queued-delayed":"Wird gesendet...","cancelled-by-user":"Abgebrochen",sent:"Gesendet",delivered:"Zugestellt",opened:"Geöffnet",clicked:"Geklickt",bounced:"Bounced",failed:"Fehlgeschlagen"}[Se]||Se}function de(Se){return{queued:"default","queued-delayed":"info","cancelled-by-user":"default",sent:"info",delivered:"primary",opened:"success",clicked:"success",bounced:"error",failed:"error"}[Se]||"default"}function Z(){if(!i.value)return!1;const Se=i.value.activeSequence;return!!Se&&Se.status==="active"}function ce(){if(!i.value)return!1;const Se=i.value.activeSequence;return!!Se&&Se.status==="paused"}function oe(){if(!i.value)return"";const Se=i.value.activeSequence;if(!Se)return"";const me=I.value.find(ee=>ee._id===Se.sequenceId);return(me==null?void 0:me.name)??Se.sequenceId??""}function pe(){if(!i.value)return"";const Se=i.value.activeSequence;return(Se==null?void 0:Se.status)??""}function _e(){if(!i.value)return{current:0,total:0};const Se=i.value.activeSequence;return{current:(Se==null?void 0:Se.currentStep)??0,total:(Se==null?void 0:Se.totalSteps)??0}}async function q(){V.value=!0;try{const Se=await re.get("/email-sequences?status=active");Se.success&&Se.data&&(I.value=Se.data.items??[])}catch{ue.warn("ADMIN","Aktive Sequenzen konnten nicht geladen werden")}finally{V.value=!1}}async function C(){H.value=!0;try{const Se=await re.get(`/email-logs?leadId=${c.value}&limit=100`);Se.success&&Se.data?D.value=Se.data.items??[]:ue.warn("ADMIN","E-Mail-Logs konnten nicht geladen werden",{error:Se.error})}catch{ue.warn("ADMIN","Netzwerkfehler beim Laden der E-Mail-Logs")}finally{H.value=!1}}async function ae(){if(!E.value)return;R.value=!0,M.value=null,T.value=null;const Se=await re.post(`/leads/${c.value}/sequence/start`,{sequenceId:E.value});Se.success?(T.value="Sequenz erfolgreich gestartet.",ue.info("ADMIN","Sequenz gestartet",{leadId:c.value}),await J(),setTimeout(()=>{T.value=null},3e3)):(M.value=Se.error||"Fehler beim Starten der Sequenz.",ue.error("ADMIN","Sequenz-Start fehlgeschlagen",{error:Se.error})),R.value=!1}async function X(Se){R.value=!0,M.value=null,T.value=null;const me={pause:"pausiert",resume:"fortgesetzt",cancel:"abgebrochen"},ee=await re.post(`/leads/${c.value}/sequence/${Se}`);ee.success?(T.value=`Sequenz erfolgreich ${me[Se]}.`,ue.info("ADMIN",`Sequenz ${Se}`,{leadId:c.value}),await J(),setTimeout(()=>{T.value=null},3e3)):(M.value=ee.error||"Fehler beim Ausführen der Aktion.",ue.error("ADMIN",`Sequenz-Aktion ${Se} fehlgeschlagen`,{error:ee.error})),R.value=!1}function ie(Se){S.value=Se,O.value=!0}function fe(Se,me){ie(me.item)}return rt(async()=>{await J(),await Promise.all([q(),C()])}),(Se,me)=>{const ee=l("v-tooltip"),Y=l("v-icon"),K=l("v-btn"),le=l("v-alert"),ne=l("v-progress-circular"),Ce=l("v-card-title"),ke=l("v-divider"),xe=l("v-list-item"),Ne=l("router-link"),Ie=l("v-chip"),Ue=l("v-list"),Te=l("v-card-text"),ye=l("v-card"),Je=l("v-col"),Ke=l("v-timeline-item"),$e=l("v-timeline"),Ee=l("v-select"),lt=l("v-progress-linear"),ut=l("v-data-table"),Ve=l("v-row"),Le=l("v-dialog"),Ye=l("v-container");return o(),N(Ye,{fluid:"",class:"pa-6"},{default:t(()=>{var ct,Fe;return[a("div",Pb,[e(K,{icon:"",variant:"text",onClick:me[0]||(me[0]=Xe=>P($).push("/admin/leads")),"aria-label":"Zurück zur Liste"},{default:t(()=>[e(ee,{activator:"parent",location:"bottom"},{default:t(()=>[...me[8]||(me[8]=[n("Zurück zur Liste",-1)])]),_:1}),e(Y,null,{default:t(()=>[...me[9]||(me[9]=[n("mdi-arrow-left",-1)])]),_:1})]),_:1}),me[10]||(me[10]=a("h1",{class:"text-h4 font-weight-bold"},"Lead-Detail",-1))]),i.value&&i.value._id?(o(),h("div",zb,[me[11]||(me[11]=a("span",null,"Erstellt:",-1)),e(gt,{"user-id":((ct=i.value.createdBy)==null?void 0:ct._id)??i.value.createdBy,populated:typeof i.value.createdBy=="object"?i.value.createdBy:null,size:24},null,8,["user-id","populated"]),me[12]||(me[12]=a("span",{class:"mx-2"},"·",-1)),me[13]||(me[13]=a("span",null,"Geändert:",-1)),e(gt,{"user-id":((Fe=i.value.updatedBy)==null?void 0:Fe._id)??i.value.updatedBy,populated:typeof i.value.updatedBy=="object"?i.value.updatedBy:null,size:24},null,8,["user-id","populated"])])):U("",!0),k.value?(o(),N(le,{key:1,type:"error",variant:"tonal",class:"mb-6",text:k.value},null,8,["text"])):U("",!0),_.value?(o(),h("div",Db,[e(ne,{indeterminate:"",color:"primary",size:"48"})])):i.value?(o(),N(Ve,{key:3},{default:t(()=>[e(Je,{cols:"12",lg:"6"},{default:t(()=>[e(ye,{rounded:"lg",class:"mb-4"},{default:t(()=>[e(Ce,{class:"pa-4 pb-2 text-body-1 font-weight-semibold"},{default:t(()=>[...me[14]||(me[14]=[n(" Kontaktdaten ",-1)])]),_:1}),e(ke),e(Ue,{density:"comfortable"},{default:t(()=>[e(xe,{"prepend-icon":"mdi-account-outline",subtitle:i.value.firstName&&i.value.lastName?`${i.value.firstName} ${i.value.lastName}`:"–",title:"Name"},null,8,["subtitle"]),e(xe,{"prepend-icon":"mdi-email-outline",subtitle:i.value.email,title:"E-Mail"},null,8,["subtitle"]),e(xe,{"prepend-icon":"mdi-phone-outline",subtitle:i.value.phone||"–",title:"Telefon"},null,8,["subtitle"]),e(xe,{"prepend-icon":"mdi-office-building-outline",title:"Unternehmen"},{subtitle:t(()=>[i.value.companyId&&typeof i.value.companyId=="object"?(o(),h(be,{key:0},[e(Ne,{to:`/admin/companies/${i.value.companyId._id}`,class:"text-primary text-decoration-none"},{default:t(()=>[n(v(i.value.companyId.name),1)]),_:1},8,["to"]),i.value.companyId.industry?(o(),h("span",Tb," ("+v(i.value.companyId.industry)+") ",1)):U("",!0)],64)):(o(),h(be,{key:1},[n(v(i.value.company||"–"),1)],64))]),_:1}),e(xe,{"prepend-icon":"mdi-briefcase-outline",subtitle:i.value.position||"–",title:"Position"},null,8,["subtitle"]),e(xe,{"prepend-icon":"mdi-tag-outline",title:"Quelle"},{subtitle:t(()=>[e(Ie,{color:"primary",size:"x-small",variant:"tonal",class:"mt-1"},{default:t(()=>[n(v(P(Ta)[i.value.source.type]||i.value.source.type),1)]),_:1})]),_:1}),e(xe,{"prepend-icon":"mdi-calendar-outline",subtitle:F(i.value.createdAt),title:"Erstellt am"},null,8,["subtitle"])]),_:1}),e(ke),e(Te,{class:"pa-4"},{default:t(()=>[me[15]||(me[15]=a("div",{class:"text-caption text-medium-emphasis mb-2"},"Direkt-Mail",-1)),e(Cb,{lead:i.value,class:"mb-4",onSent:p},null,8,["lead"]),e(ke,{class:"mb-4"}),me[16]||(me[16]=a("div",{class:"text-caption text-medium-emphasis mb-2"},"Reply-Marker",-1)),e(mb,{lead:i.value,onUpdated:J},null,8,["lead"])]),_:1})]),_:1})]),_:1}),e(Je,{cols:"12",lg:"6"},{default:t(()=>[e(ye,{rounded:"lg",class:"mb-4"},{default:t(()=>[e(Ce,{class:"pa-4 pb-2 text-body-1 font-weight-semibold"},{default:t(()=>[...me[17]||(me[17]=[n(" Pipeline ",-1)])]),_:1}),e(ke),e(Te,{class:"pa-4"},{default:t(()=>[a("div",Lb,[e(Ie,{color:L(i.value.pipeline.stage),size:"large",variant:"flat",class:"text-body-1 font-weight-bold px-6"},{default:t(()=>[n(v(P(na)[i.value.pipeline.stage]||i.value.pipeline.stage),1)]),_:1},8,["color"])]),me[18]||(me[18]=a("div",{class:"text-caption text-medium-emphasis text-center mb-2"},"Phase wechseln:",-1)),a("div",Eb,[(o(!0),h(be,null,Pe(P(Hl),Xe=>(o(),N(K,{key:Xe,color:L(Xe),variant:i.value.pipeline.stage===Xe?"flat":"outlined",size:"x-small",loading:g.value&&i.value.pipeline.stage!==Xe,disabled:g.value,onClick:mt=>Q(Xe)},{default:t(()=>[n(v(P(na)[Xe]),1)]),_:2},1032,["color","variant","loading","disabled","onClick"]))),128))]),me[19]||(me[19]=a("div",{class:"text-caption text-medium-emphasis mb-2"},"Verlauf:",-1)),e($e,{density:"compact",side:"end","truncate-line":"both"},{default:t(()=>[(o(!0),h(be,null,Pe([...i.value.pipeline.history??[]].reverse().slice(0,5),(Xe,mt)=>(o(),N(Ke,{key:mt,"dot-color":L(Xe.stage),size:"x-small"},{default:t(()=>[a("div",Mb,[a("span",Nb,v(P(na)[Xe.stage]||Xe.stage),1),a("span",Ub,v(F(Xe.changedAt)),1)]),Xe.note?(o(),h("div",Bb,v(Xe.note),1)):U("",!0)]),_:2},1032,["dot-color"]))),128))]),_:1})]),_:1})]),_:1})]),_:1}),e(Je,{cols:"12",md:"6"},{default:t(()=>[e(ye,{rounded:"lg",class:"mb-4"},{default:t(()=>[e(Ce,{class:"pa-4 pb-2 text-body-1 font-weight-semibold"},{default:t(()=>[...me[20]||(me[20]=[n("Scoring",-1)])]),_:1}),e(ke),e(Te,{class:"pa-4"},{default:t(()=>[a("div",Fb,[e(Ie,{color:j(i.value.scoring.total),size:"x-large",variant:"flat",class:"text-h5 font-weight-bold px-6"},{default:t(()=>[n(v(i.value.scoring.total),1)]),_:1},8,["color"])]),e(Ue,{density:"compact"},{default:t(()=>[e(xe,{title:"Engagement",subtitle:`${i.value.scoring.engagement} Punkte`,"prepend-icon":"mdi-lightning-bolt-outline"},null,8,["subtitle"]),e(xe,{title:"Profil",subtitle:`${i.value.scoring.profile} Punkte`,"prepend-icon":"mdi-account-star-outline"},null,8,["subtitle"]),i.value.scoring.lastCalculatedAt?(o(),N(xe,{key:0,title:"Zuletzt berechnet",subtitle:F(i.value.scoring.lastCalculatedAt),"prepend-icon":"mdi-clock-outline"},null,8,["subtitle"])):U("",!0)]),_:1})]),_:1})]),_:1})]),_:1}),e(Je,{cols:"12",md:"6"},{default:t(()=>[e(ye,{rounded:"lg",class:"mb-4"},{default:t(()=>[e(Ce,{class:"pa-4 pb-2 text-body-1 font-weight-semibold"},{default:t(()=>[...me[21]||(me[21]=[n("HubSpot",-1)])]),_:1}),e(ke),e(Te,{class:"pa-4"},{default:t(()=>[w.value?(o(),N(le,{key:0,type:"error",variant:"tonal",class:"mb-3",text:w.value},null,8,["text"])):U("",!0),b.value?(o(),N(le,{key:1,type:"success",variant:"tonal",class:"mb-3",text:"Synchronisation erfolgreich."})):U("",!0),e(Ue,{density:"compact",class:"mb-4"},{default:t(()=>{var Xe,mt,nt,He;return[e(xe,{title:"HubSpot-ID",subtitle:((Xe=i.value.hubspot)==null?void 0:Xe.id)||"Nicht verknüpft","prepend-icon":"mdi-identifier"},null,8,["subtitle"]),e(xe,{title:"Erstellt in HubSpot",subtitle:W(((mt=i.value.hubspot)==null?void 0:mt.createdAt)??null),"prepend-icon":"mdi-calendar-plus-outline"},null,8,["subtitle"]),e(xe,{title:"Zuletzt geändert in HubSpot",subtitle:W(((nt=i.value.hubspot)==null?void 0:nt.lastModifiedAt)??null),"prepend-icon":"mdi-calendar-edit-outline"},null,8,["subtitle"]),e(xe,{title:"Letzte Synchronisation",subtitle:W(((He=i.value.hubspot)==null?void 0:He.syncedAt)??null),"prepend-icon":"mdi-sync"},null,8,["subtitle"])]}),_:1}),e(K,{color:"primary",variant:"outlined",block:"","prepend-icon":"mdi-sync",loading:x.value,onClick:te},{default:t(()=>[...me[22]||(me[22]=[n(" Jetzt synchronisieren ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1}),e(Je,{cols:"12"},{default:t(()=>[e(ye,{rounded:"lg"},{default:t(()=>[e(Ce,{class:"pa-4 pb-2 text-body-1 font-weight-semibold"},{default:t(()=>[me[23]||(me[23]=n(" Interaktions-Historie ",-1)),e(Ie,{class:"ml-2",size:"x-small",color:"primary",variant:"tonal"},{default:t(()=>{var Xe;return[n(v(((Xe=i.value.interactions)==null?void 0:Xe.length)??0),1)]}),_:1})]),_:1}),e(ke),e(Te,{class:"pa-4"},{default:t(()=>[!i.value.interactions||i.value.interactions.length===0?(o(),h("p",Ob," Noch keine Interaktionen aufgezeichnet. ")):(o(),N($e,{key:1,density:"compact",side:"end","truncate-line":"both"},{default:t(()=>[(o(!0),h(be,null,Pe([...i.value.interactions].reverse(),(Xe,mt)=>(o(),N(Ke,{key:mt,"dot-color":"primary",size:"x-small"},{icon:t(()=>[e(Y,{icon:A(Xe.type),size:"14"},null,8,["icon"])]),default:t(()=>[a("div",Rb,[a("span",Kb,v(z(Xe.type)),1),a("span",jb,v(W(Xe.timestamp)),1)]),Xe.details?(o(),h("div",qb,v(Xe.details),1)):U("",!0)]),_:2},1024))),128))]),_:1}))]),_:1})]),_:1})]),_:1}),e(Je,{cols:"12",md:"6"},{default:t(()=>[e(ye,{rounded:"lg",class:"mb-4"},{default:t(()=>[e(Ce,{class:"pa-4 pb-2 text-body-1 font-weight-semibold"},{default:t(()=>[...me[24]||(me[24]=[n("E-Mail-Sequenz",-1)])]),_:1}),e(ke),e(Te,{class:"pa-4"},{default:t(()=>[M.value?(o(),N(le,{key:0,type:"error",variant:"tonal",class:"mb-3",text:M.value},null,8,["text"])):U("",!0),T.value?(o(),N(le,{key:1,type:"success",variant:"tonal",class:"mb-3",text:T.value},null,8,["text"])):U("",!0),oe()?(o(),h(be,{key:2},[e(Ue,{density:"compact",class:"mb-3"},{default:t(()=>[e(xe,{"prepend-icon":"mdi-email-fast-outline",title:"Sequenz"},{subtitle:t(()=>[a("span",Gb,v(oe()),1)]),append:t(()=>[e(Ie,{color:de(pe()),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(ve(pe())),1)]),_:1},8,["color"])]),_:1}),e(xe,{"prepend-icon":"mdi-counter",title:"Fortschritt"},{subtitle:t(()=>[n(" Schritt "+v(_e().current)+" von "+v(_e().total),1)]),_:1})]),_:1}),a("div",Hb,[Z()?(o(),N(K,{key:0,size:"small",color:"warning",variant:"outlined","prepend-icon":"mdi-pause",loading:R.value,onClick:me[1]||(me[1]=Xe=>X("pause"))},{default:t(()=>[...me[25]||(me[25]=[n(" Pausieren ",-1)])]),_:1},8,["loading"])):U("",!0),ce()?(o(),N(K,{key:1,size:"small",color:"success",variant:"outlined","prepend-icon":"mdi-play",loading:R.value,onClick:me[2]||(me[2]=Xe=>X("resume"))},{default:t(()=>[...me[26]||(me[26]=[n(" Fortsetzen ",-1)])]),_:1},8,["loading"])):U("",!0),e(K,{size:"small",color:"error",variant:"outlined","prepend-icon":"mdi-stop",loading:R.value,onClick:me[3]||(me[3]=Xe=>X("cancel"))},{default:t(()=>[...me[27]||(me[27]=[n(" Abbrechen ",-1)])]),_:1},8,["loading"])])],64)):(o(),h(be,{key:3},[me[29]||(me[29]=a("p",{class:"text-body-2 text-medium-emphasis mb-3"},"Keine aktive Sequenz zugewiesen.",-1)),a("div",Wb,[e(Ee,{modelValue:E.value,"onUpdate:modelValue":me[4]||(me[4]=Xe=>E.value=Xe),label:"Sequenz auswählen",items:I.value.map(Xe=>({title:Xe.name,value:Xe._id})),loading:V.value,variant:"outlined",density:"compact","hide-details":"","no-data-text":"Keine aktiven Sequenzen vorhanden",class:"flex-grow-1"},null,8,["modelValue","items","loading"]),e(K,{color:"primary",size:"small",disabled:!E.value,loading:R.value,onClick:ae},{default:t(()=>[...me[28]||(me[28]=[n(" Starten ",-1)])]),_:1},8,["disabled","loading"])])],64))]),_:1})]),_:1})]),_:1}),e(Je,{cols:"12",md:"6"},{default:t(()=>[e(ye,{rounded:"lg",class:"mb-4"},{default:t(()=>[e(Ce,{class:"pa-4 pb-2 text-body-1 font-weight-semibold"},{default:t(()=>[...me[30]||(me[30]=[n("Score-Aufteilung",-1)])]),_:1}),e(ke),e(Te,{class:"pa-4"},{default:t(()=>[a("div",Zb,[me[31]||(me[31]=a("span",{class:"text-body-2"},"Gesamt-Score",-1)),e(Ie,{color:j(i.value.scoring.total),size:"small",variant:"flat",class:"font-weight-bold"},{default:t(()=>[n(v(i.value.scoring.total)+" / 100 ",1)]),_:1},8,["color"])]),e(lt,{"model-value":i.value.scoring.total,color:j(i.value.scoring.total),rounded:"",height:"10",class:"mb-4"},null,8,["model-value","color"]),a("div",Jb,[a("div",Qb,[me[32]||(me[32]=a("span",null,"Engagement",-1)),a("span",Yb,v(i.value.scoring.engagement)+" / 50",1)]),e(lt,{"model-value":i.value.scoring.engagement/50*100,color:"primary",rounded:"",height:"6"},null,8,["model-value"])]),a("div",Xb,[a("div",ey,[me[33]||(me[33]=a("span",null,"Profil",-1)),a("span",ty,v(i.value.scoring.profile)+" / 50",1)]),e(lt,{"model-value":i.value.scoring.profile/50*100,color:"info",rounded:"",height:"6"},null,8,["model-value"])]),i.value.scoring.lastCalculatedAt?(o(),h("div",ay," Zuletzt berechnet: "+v(F(i.value.scoring.lastCalculatedAt)),1)):U("",!0)]),_:1})]),_:1})]),_:1}),e(Je,{cols:"12"},{default:t(()=>[e(cb,{"lead-id":c.value,"engagement-state":i.value.engagementState,"email-logs":D.value,"sequence-info":oe()?{sequenceName:oe(),currentStep:_e().current,totalSteps:_e().total,status:pe()}:void 0,class:"mb-4"},null,8,["lead-id","engagement-state","email-logs","sequence-info"])]),_:1}),e(Je,{cols:"12"},{default:t(()=>[e(ye,{rounded:"lg"},{default:t(()=>[e(Ce,{class:"pa-4 pb-2 text-body-1 font-weight-semibold"},{default:t(()=>[me[34]||(me[34]=n(" E-Mail-Historie ",-1)),e(Ie,{class:"ml-2",size:"x-small",color:"primary",variant:"tonal"},{default:t(()=>[n(v(D.value.length),1)]),_:1})]),_:1}),e(ke),e(ut,{headers:G,items:D.value,loading:H.value,"sort-by":P(B),"loading-text":"E-Mails werden geladen...","no-data-text":"Keine E-Mails versendet","item-value":"_id","items-per-page":-1,"hide-default-footer":"",hover:"","onUpdate:sortBy":me[5]||(me[5]=Xe=>B.value=Xe),"onClick:row":fe},{"item.status":t(({item:Xe})=>[e(Ie,{color:de(Xe.status),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(ve(Xe.status)),1)]),_:2},1032,["color"])]),"item.sentAt":t(({item:Xe})=>[a("span",ly,v(W(Xe.sentAt)),1)]),"item.openedAt":t(({item:Xe})=>[a("span",ny,v(W(Xe.openedAt)),1)]),"item.clickedAt":t(({item:Xe})=>[a("span",oy,v(W(Xe.clickedAt)),1)]),_:1},8,["items","loading","sort-by"])]),_:1})]),_:1})]),_:1})):U("",!0),e(kl,{countdown:P(s),"job-id":P(m),onCancel:P(f)},null,8,["countdown","job-id","onCancel"]),e(Le,{modelValue:O.value,"onUpdate:modelValue":me[7]||(me[7]=Xe=>O.value=Xe),"max-width":"640",scrollable:""},{default:t(()=>[S.value?(o(),N(ye,{key:0},{default:t(()=>[e(Ce,{class:"pa-4 pb-2 d-flex align-center justify-space-between"},{default:t(()=>[a("span",sy,v(S.value.subject),1),e(K,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:me[6]||(me[6]=Xe=>O.value=!1)},{default:t(()=>[e(ee,{activator:"parent",location:"bottom"},{default:t(()=>[...me[35]||(me[35]=[n("Schließen",-1)])]),_:1}),e(Y,null,{default:t(()=>[...me[36]||(me[36]=[n("mdi-close",-1)])]),_:1})]),_:1})]),_:1}),e(ke),e(Te,{class:"pa-4"},{default:t(()=>[a("div",iy,[e(Ie,{color:de(S.value.status),size:"small",variant:"tonal"},{default:t(()=>[n(v(ve(S.value.status)),1)]),_:1},8,["color"]),a("span",ry,"An: "+v(S.value.to),1)]),a("div",dy,[S.value.sentAt?(o(),h("span",uy,"Gesendet: "+v(W(S.value.sentAt)),1)):U("",!0),S.value.openedAt?(o(),h("span",cy,"Geöffnet: "+v(W(S.value.openedAt)),1)):U("",!0),S.value.clickedAt?(o(),h("span",my,"Geklickt: "+v(W(S.value.clickedAt)),1)):U("",!0)]),e(ke,{class:"mb-4"}),a("div",{class:"email-log-body",innerHTML:S.value.body},null,8,vy)]),_:1})]),_:1})):U("",!0)]),_:1},8,["modelValue"])]}),_:1})}}}),x6=Object.freeze(Object.defineProperty({__proto__:null,default:py},Symbol.toStringTag,{value:"Module"})),fy=Ae({__name:"ResearchInputCard",props:{modelValue:{},loading:{type:Boolean}},emits:["update:modelValue","analyze"],setup(r,{emit:$}){const d=r,c=$,s=()=>d.modelValue.trim().length>=3&&!d.loading;return(m,u)=>{const f=l("v-icon"),p=l("v-card-title"),_=l("v-card-subtitle"),k=l("v-textarea"),i=l("v-btn"),g=l("v-card-text"),x=l("v-card");return o(),N(x,{rounded:"lg",class:"mb-4"},{default:t(()=>[e(p,{class:"pa-4 pb-2 text-body-1 font-weight-semibold d-flex align-center"},{default:t(()=>[e(f,{class:"mr-2",color:"primary"},{default:t(()=>[...u[2]||(u[2]=[n("mdi-robot-outline",-1)])]),_:1}),u[3]||(u[3]=n(" KI-Kontaktdaten-Analyse ",-1))]),_:1}),e(_,{class:"pb-0"},{default:t(()=>[...u[4]||(u[4]=[n(" Kontaktdaten einfügen (z.B. E-Mail-Signatur, Visitenkarte, Notizen) und die KI füllt alle Felder automatisch aus. ",-1)])]),_:1}),e(g,{class:"pa-4"},{default:t(()=>[e(k,{"model-value":r.modelValue,label:"Kontaktdaten einfügen...",variant:"outlined",rows:"6","auto-grow":"","onUpdate:modelValue":u[0]||(u[0]=w=>c("update:modelValue",w))},null,8,["model-value"]),e(i,{color:"primary","prepend-icon":"mdi-robot",disabled:!s(),loading:r.loading,onClick:u[1]||(u[1]=w=>c("analyze"))},{default:t(()=>[...u[5]||(u[5]=[n(" KI-Analyse starten ",-1)])]),_:1},8,["disabled","loading"])]),_:1})]),_:1})}}}),gy=Ae({__name:"ResearchPersonForm",props:{modelValue:{}},emits:["update:modelValue"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-card-title"),u=l("v-divider"),f=l("v-select"),p=l("v-col"),_=l("v-text-field"),k=l("v-row"),i=l("v-card-text"),g=l("v-card");return o(),N(g,{rounded:"lg",class:"h-100"},{default:t(()=>[e(m,{class:"pa-4 pb-2 text-body-1 font-weight-semibold"},{default:t(()=>[...s[6]||(s[6]=[n("Person",-1)])]),_:1}),e(u),e(i,{class:"pa-4"},{default:t(()=>[e(k,{dense:""},{default:t(()=>[e(p,{cols:"12",md:"3"},{default:t(()=>[e(f,{"model-value":r.modelValue.salutation,items:["","Herr","Frau","Divers"],label:"Anrede",variant:"outlined",density:"comfortable","onUpdate:modelValue":s[0]||(s[0]=x=>d("update:modelValue",{...r.modelValue,salutation:x??""}))},null,8,["model-value"])]),_:1}),e(p,{cols:"12",md:"4"},{default:t(()=>[e(_,{"model-value":r.modelValue.firstName,label:"Vorname",variant:"outlined",density:"comfortable","onUpdate:modelValue":s[1]||(s[1]=x=>d("update:modelValue",{...r.modelValue,firstName:x}))},null,8,["model-value"])]),_:1}),e(p,{cols:"12",md:"5"},{default:t(()=>[e(_,{"model-value":r.modelValue.lastName,label:"Nachname",variant:"outlined",density:"comfortable","onUpdate:modelValue":s[2]||(s[2]=x=>d("update:modelValue",{...r.modelValue,lastName:x}))},null,8,["model-value"])]),_:1}),e(p,{cols:"12"},{default:t(()=>[e(_,{"model-value":r.modelValue.email,label:"E-Mail *",variant:"outlined",density:"comfortable",type:"email","onUpdate:modelValue":s[3]||(s[3]=x=>d("update:modelValue",{...r.modelValue,email:x}))},null,8,["model-value"])]),_:1}),e(p,{cols:"12",md:"6"},{default:t(()=>[e(_,{"model-value":r.modelValue.phone,label:"Telefon",variant:"outlined",density:"comfortable","onUpdate:modelValue":s[4]||(s[4]=x=>d("update:modelValue",{...r.modelValue,phone:x}))},null,8,["model-value"])]),_:1}),e(p,{cols:"12",md:"6"},{default:t(()=>[e(_,{"model-value":r.modelValue.position,label:"Position",variant:"outlined",density:"comfortable","onUpdate:modelValue":s[5]||(s[5]=x=>d("update:modelValue",{...r.modelValue,position:x}))},null,8,["model-value"])]),_:1})]),_:1})]),_:1})]),_:1})}}}),by={class:"d-flex flex-wrap ga-4"},hl=Ae({__name:"CompanyRegulatoryFlags",props:{modelValue:{}},emits:["update:modelValue"],setup(r,{emit:$}){const d=r,c=$;function s(m,u){c("update:modelValue",{...d.modelValue,[m]:u})}return(m,u)=>{const f=l("v-checkbox");return o(),h("div",by,[e(f,{"model-value":r.modelValue.nis2,label:"NIS2-relevant",density:"comfortable","hide-details":"","onUpdate:modelValue":u[0]||(u[0]=p=>s("nis2",!!p))},null,8,["model-value"]),e(f,{"model-value":r.modelValue.dora,label:"DORA-relevant",density:"comfortable","hide-details":"","onUpdate:modelValue":u[1]||(u[1]=p=>s("dora",!!p))},null,8,["model-value"]),e(f,{"model-value":r.modelValue.kritis,label:"KRITIS-Betreiber",density:"comfortable","hide-details":"","onUpdate:modelValue":u[2]||(u[2]=p=>s("kritis",!!p))},null,8,["model-value"])])}}}),yy={class:"d-flex align-center justify-space-between"},_y={key:0},ky={key:1},hy={key:2},xy=Ae({__name:"ResearchCompanyForm",props:{modelValue:{},matchInfo:{},useMatch:{type:Boolean}},emits:["update:modelValue","update:useMatch"],setup(r,{emit:$}){const d=r,c=$;function s(m){if(m===""||m===null){c("update:modelValue",{...d.modelValue,size:null});return}const u=parseInt(m,10);c("update:modelValue",{...d.modelValue,size:Number.isFinite(u)?u:null})}return(m,u)=>{const f=l("v-card-title"),p=l("v-divider"),_=l("v-switch"),k=l("v-alert"),i=l("v-text-field"),g=l("v-col"),x=l("v-textarea"),w=l("v-row"),b=l("v-card-text"),I=l("v-card");return o(),N(I,{rounded:"lg",class:"h-100"},{default:t(()=>{var V;return[e(f,{class:"pa-4 pb-2 text-body-1 font-weight-semibold"},{default:t(()=>[...u[7]||(u[7]=[n("Firma",-1)])]),_:1}),e(p),(V=r.matchInfo)!=null&&V.match?(o(),N(k,{key:0,color:r.useMatch?"success":"warning",variant:"tonal",density:"compact",class:"ma-4 mb-2"},{default:t(()=>[a("div",yy,[a("div",null,[u[8]||(u[8]=a("strong",null,"Vorhandene Company gefunden:",-1)),n(" "+v(r.matchInfo.match.name)+" ",1),r.matchInfo.match.industry?(o(),h("span",_y," - "+v(r.matchInfo.match.industry),1)):U("",!0),r.matchInfo.match.size?(o(),h("span",ky," ("+v(r.matchInfo.match.size)+" MA)",1)):U("",!0),r.matchInfo.match.location?(o(),h("span",hy," - "+v(r.matchInfo.match.location),1)):U("",!0)]),e(_,{"model-value":r.useMatch,color:"success",density:"compact","hide-details":"",label:r.useMatch?"Verlinken":"Neue anlegen","onUpdate:modelValue":u[0]||(u[0]=E=>c("update:useMatch",!!E))},null,8,["model-value","label"])])]),_:1},8,["color"])):U("",!0),e(b,{class:"pa-4"},{default:t(()=>[e(w,{dense:""},{default:t(()=>[e(g,{cols:"12",md:"8"},{default:t(()=>[e(i,{"model-value":r.modelValue.name,label:"Firmenname *",variant:"outlined",density:"comfortable",disabled:r.useMatch,"onUpdate:modelValue":u[1]||(u[1]=E=>c("update:modelValue",{...r.modelValue,name:E}))},null,8,["model-value","disabled"])]),_:1}),e(g,{cols:"12",md:"4"},{default:t(()=>[e(i,{"model-value":r.modelValue.industry,label:"Branche",variant:"outlined",density:"comfortable",disabled:r.useMatch,"onUpdate:modelValue":u[2]||(u[2]=E=>c("update:modelValue",{...r.modelValue,industry:E}))},null,8,["model-value","disabled"])]),_:1}),e(g,{cols:"12",md:"4"},{default:t(()=>[e(i,{"model-value":r.modelValue.size===null?"":String(r.modelValue.size),label:"Mitarbeiter",type:"number",variant:"outlined",density:"comfortable",disabled:r.useMatch,"onUpdate:modelValue":s},null,8,["model-value","disabled"])]),_:1}),e(g,{cols:"12",md:"4"},{default:t(()=>[e(i,{"model-value":r.modelValue.location,label:"Standort",variant:"outlined",density:"comfortable",disabled:r.useMatch,"onUpdate:modelValue":u[3]||(u[3]=E=>c("update:modelValue",{...r.modelValue,location:E}))},null,8,["model-value","disabled"])]),_:1}),e(g,{cols:"12",md:"4"},{default:t(()=>[e(i,{"model-value":r.modelValue.website,label:"Website",variant:"outlined",density:"comfortable",disabled:r.useMatch,"onUpdate:modelValue":u[4]||(u[4]=E=>c("update:modelValue",{...r.modelValue,website:E}))},null,8,["model-value","disabled"])]),_:1}),e(g,{cols:"12"},{default:t(()=>[e(x,{"model-value":r.modelValue.description,label:"Beschreibung",variant:"outlined",rows:"2","auto-grow":"",disabled:r.useMatch,"onUpdate:modelValue":u[5]||(u[5]=E=>c("update:modelValue",{...r.modelValue,description:E}))},null,8,["model-value","disabled"])]),_:1}),e(g,{cols:"12"},{default:t(()=>[e(hl,{"model-value":r.modelValue.regulatory,"onUpdate:modelValue":u[6]||(u[6]=E=>c("update:modelValue",{...r.modelValue,regulatory:E}))},null,8,["model-value"])]),_:1})]),_:1})]),_:1})]}),_:1})}}}),wy={class:"text-caption",style:{"white-space":"pre-wrap"}},Sy=Ae({__name:"LeadResearchView",setup(r){const $=xt(),d=y(""),c=y(!1),s=y(!1),m=y(null),u=y(!1),f=y({salutation:"",firstName:"",lastName:"",email:"",phone:"",position:""}),p=y({name:"",industry:"",size:null,location:"",website:"",description:"",regulatory:{nis2:!1,dora:!1,kritis:!1}}),_=y(null),k=y(!1),i=y(""),g=y(""),x=y(!1),w=y(null),b=y(null),I=se(()=>!!f.value.email.trim());async function V(){var T,D;try{const H=await re.get("/platform-settings");H.success&&((D=(T=H.data)==null?void 0:T.outreach)!=null&&D.defaultSenderEmail)&&(g.value=H.data.outreach.defaultSenderEmail,i.value=g.value)}catch(H){ue.warn("ADMIN","Default-Sender konnte nicht geladen werden",{error:H})}}async function E(){c.value=!0,m.value=null,u.value=!1;try{const T=await re.post("/admin/lead-research/analyze",{rawText:d.value});T.success&&T.data?(f.value=T.data.output.person,p.value=T.data.output.company,s.value=!0,await R()):(m.value=T.error||"KI-Analyse fehlgeschlagen.",f.value={salutation:"",firstName:"",lastName:"",email:"",phone:"",position:""},p.value={name:"",industry:"",size:null,location:"",website:"",description:"",regulatory:{nis2:!1,dora:!1,kritis:!1}},s.value=!0,u.value=!!d.value.trim(),ue.warn("ADMIN","Lead-Research analyze fehlgeschlagen",{error:T.error}))}catch(T){m.value="Netzwerkfehler bei der KI-Analyse. Bitte erneut versuchen.",ue.error("ADMIN","Lead-Research analyze: unerwartete Exception",{error:T instanceof Error?T.message:"Unbekannt"})}finally{c.value=!1}}async function R(){if(!p.value.name.trim())return;const T=await re.post("/admin/companies/match",{name:p.value.name});T.success&&T.data&&(_.value=T.data,k.value=!!T.data.match)}async function M(){var T;x.value=!0,w.value=null,b.value=null;try{const D={person:f.value,company:p.value,useExistingCompanyId:k.value&&((T=_.value)!=null&&T.match)?_.value.match._id:null,assignedSender:i.value},H=await re.post("/admin/lead-research/create",D);if(H.success&&H.data)ue.info("ADMIN","Outreach-Lead angelegt",{leadId:H.data.lead._id}),$.push(`/admin/leads/${H.data.lead._id}`);else{w.value=H.error||"Speichern fehlgeschlagen.";const O=H.existingLeadId;O&&(b.value=O)}}catch(D){w.value="Netzwerkfehler beim Speichern. Bitte erneut versuchen.",ue.error("ADMIN","Lead-Research save: unerwartete Exception",{error:D instanceof Error?D.message:"Unbekannt"})}finally{x.value=!1}}return rt(V),(T,D)=>{const H=l("v-alert"),O=l("v-expansion-panel-text"),S=l("v-expansion-panel"),B=l("v-expansion-panels"),G=l("v-col"),W=l("v-btn"),F=l("v-row"),L=l("v-container");return o(),N(L,{fluid:"",class:"pa-6"},{default:t(()=>[D[10]||(D[10]=a("h1",{class:"text-h4 font-weight-bold mb-2"},"Sales-Research (KI-gestützt)",-1)),D[11]||(D[11]=a("p",{class:"text-body-2 text-medium-emphasis mb-6"},' Kontaktdaten oder Signatur einfügen, KI extrahiert Person + Firma. Lead wird mit Quelle "Outreach" angelegt. ',-1)),e(fy,{modelValue:d.value,"onUpdate:modelValue":D[0]||(D[0]=A=>d.value=A),loading:c.value,onAnalyze:E},null,8,["modelValue","loading"]),m.value?(o(),N(H,{key:0,type:"error",variant:"tonal",class:"mb-4",text:m.value},null,8,["text"])):U("",!0),u.value?(o(),N(B,{key:1,class:"mb-4"},{default:t(()=>[e(S,{title:"Eingesandter Text (zum Vergleich für die manuelle Eingabe)"},{default:t(()=>[e(O,null,{default:t(()=>[a("pre",wy,v(d.value),1)]),_:1})]),_:1})]),_:1})):U("",!0),s.value?(o(),N(F,{key:2},{default:t(()=>[e(G,{cols:"12",md:"6"},{default:t(()=>[e(gy,{modelValue:f.value,"onUpdate:modelValue":D[1]||(D[1]=A=>f.value=A)},null,8,["modelValue"])]),_:1}),e(G,{cols:"12",md:"6"},{default:t(()=>[e(xy,{modelValue:p.value,"onUpdate:modelValue":D[2]||(D[2]=A=>p.value=A),"match-info":_.value,"use-match":k.value,"onUpdate:useMatch":D[3]||(D[3]=A=>k.value=A)},null,8,["modelValue","match-info","use-match"])]),_:1}),e(G,{cols:"12",md:"6"},{default:t(()=>[e(Ua,{modelValue:i.value,"onUpdate:modelValue":D[4]||(D[4]=A=>i.value=A),label:"Mailjet-Versender für spätere Outreach-Mails"},null,8,["modelValue"])]),_:1}),e(G,{cols:"12"},{default:t(()=>[w.value?(o(),N(H,{key:0,type:"error",variant:"tonal",class:"mb-3"},{default:t(()=>[n(v(w.value)+" ",1),b.value?(o(),N(W,{key:0,size:"small",variant:"text",class:"ml-2",onClick:D[5]||(D[5]=A=>P($).push(`/admin/leads/${b.value}`))},{default:t(()=>[...D[6]||(D[6]=[n(" Bestehenden Lead öffnen ",-1)])]),_:1})):U("",!0)]),_:1})):U("",!0),s.value&&!f.value.email.trim()?(o(),N(H,{key:1,type:"warning",variant:"tonal",density:"compact",class:"mb-3"},{default:t(()=>[...D[7]||(D[7]=[n(" E-Mail-Adresse ist Pflicht, um einen Lead anzulegen. ",-1)])]),_:1})):U("",!0),s.value&&!k.value&&!p.value.name.trim()?(o(),N(H,{key:2,type:"info",variant:"tonal",density:"compact",class:"mb-3"},{default:t(()=>[...D[8]||(D[8]=[n(" Kein Firmenname angegeben - Lead wird ohne Firmenzuordnung angelegt. ",-1)])]),_:1})):U("",!0),e(W,{color:"primary","prepend-icon":"mdi-account-plus",loading:x.value,disabled:!I.value,onClick:M},{default:t(()=>[...D[9]||(D[9]=[n(" Lead anlegen ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})):U("",!0)]),_:1})}}}),w6=Object.freeze(Object.defineProperty({__proto__:null,default:Sy},Symbol.toStringTag,{value:"Module"})),$y=Ae({__name:"CompanyListView",setup(r){const $=xt(),d=y([]),c=y(0),s=y(!1),m=y(null),u=y(""),f=y(1),p=y(50),_=y([{key:"name",order:"asc"}]),k=[{title:"Name",key:"name",sortable:!0},{title:"Branche",key:"industry",sortable:!0},{title:"Mitarbeiter",key:"size",sortable:!0,align:"end"},{title:"Standort",key:"location",sortable:!0},{title:"Quelle",key:"source",sortable:!0},{title:"Erstellt",key:"createdAt",sortable:!0}];async function i(){s.value=!0;try{const I=_.value[0]??{key:"name",order:"asc"},V=new URLSearchParams({search:u.value,page:String(f.value),limit:String(p.value),sortBy:I.key,sortOrder:I.order}),E=await re.get(`/admin/companies?${V}`);E.success&&E.data?(d.value=E.data.items,c.value=E.data.total,m.value=null):(m.value=E.error||"Companies konnten nicht geladen werden.",ue.error("ADMIN","Companies-Liste laden fehlgeschlagen",{error:E.error}))}catch(I){m.value="Netzwerkfehler beim Laden der Companies.",ue.error("ADMIN","Companies-Liste: unerwartete Exception",{error:I instanceof Error?I.message:"Unbekannt"})}finally{s.value=!1}}Ze([f,p,_],i);let g=null;Ze(u,()=>{g&&clearTimeout(g),g=setTimeout(()=>{f.value=1,i()},300)});function x(I,V){$.push(`/admin/companies/${V.item._id}`)}const w=I=>typeof I=="number"?String(I):"-",b=I=>new Date(I).toLocaleDateString("de-DE");return rt(i),(I,V)=>{const E=l("v-text-field"),R=l("v-card-text"),M=l("v-card"),T=l("v-alert"),D=l("v-chip"),H=l("v-data-table-server"),O=l("v-container");return o(),N(O,{fluid:"",class:"pa-6"},{default:t(()=>[V[2]||(V[2]=a("div",{class:"d-flex align-center mb-4"},[a("h1",{class:"text-h4 font-weight-bold"},"Companies")],-1)),e(M,{rounded:"lg",class:"mb-4"},{default:t(()=>[e(R,{class:"d-flex align-center ga-3"},{default:t(()=>[e(E,{modelValue:u.value,"onUpdate:modelValue":V[0]||(V[0]=S=>u.value=S),"prepend-inner-icon":"mdi-magnify",label:"Suche (Name, Branche, Standort)",density:"comfortable",variant:"outlined","hide-details":"",clearable:""},null,8,["modelValue"])]),_:1})]),_:1}),m.value?(o(),N(T,{key:0,type:"error",variant:"tonal",class:"mb-4",text:m.value},null,8,["text"])):U("",!0),e(M,{rounded:"lg"},{default:t(()=>[e(H,{items:d.value,"items-length":c.value,headers:k,loading:s.value,"items-per-page":p.value,page:f.value,"sort-by":_.value,"item-value":"_id",hover:"","onUpdate:options":V[1]||(V[1]=S=>{f.value=S.page,p.value=S.itemsPerPage,_.value=S.sortBy}),"onClick:row":x},{"item.size":t(({item:S})=>[n(v(w(S.size)),1)]),"item.createdAt":t(({item:S})=>[n(v(b(S.createdAt)),1)]),"item.source":t(({item:S})=>[e(D,{size:"x-small",variant:"tonal"},{default:t(()=>[n(v(S.source),1)]),_:2},1024)]),_:1},8,["items","items-length","loading","items-per-page","page","sort-by"])]),_:1})]),_:1})}}}),S6=Object.freeze(Object.defineProperty({__proto__:null,default:$y},Symbol.toStringTag,{value:"Module"})),Cy={class:"d-flex justify-end mt-2"},Vy=Ae({__name:"CompanyForm",props:{modelValue:{},saving:{type:Boolean}},emits:["save"],setup(r,{emit:$}){const d=r,c=$,s=y({...d.modelValue});Ze(()=>d.modelValue,f=>{s.value={...f}},{deep:!0});function m(f){if(f===""||f===null){s.value.size=null;return}const p=parseInt(f,10);s.value.size=Number.isFinite(p)?p:null}function u(){c("save",{name:s.value.name,industry:s.value.industry,size:s.value.size,location:s.value.location,website:s.value.website,description:s.value.description,regulatory:s.value.regulatory})}return(f,p)=>{const _=l("v-text-field"),k=l("v-col"),i=l("v-textarea"),g=l("v-row"),x=l("v-btn"),w=l("v-card-text"),b=l("v-card");return o(),N(b,{rounded:"lg"},{default:t(()=>[e(w,{class:"pa-4"},{default:t(()=>[e(g,null,{default:t(()=>[e(k,{cols:"12",md:"8"},{default:t(()=>[e(_,{modelValue:s.value.name,"onUpdate:modelValue":p[0]||(p[0]=I=>s.value.name=I),label:"Firmenname *",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(k,{cols:"12",md:"4"},{default:t(()=>[e(_,{modelValue:s.value.industry,"onUpdate:modelValue":p[1]||(p[1]=I=>s.value.industry=I),label:"Branche",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(k,{cols:"12",md:"4"},{default:t(()=>[e(_,{"model-value":s.value.size===null?"":String(s.value.size),label:"Mitarbeiter",type:"number",min:"0",variant:"outlined",density:"comfortable","onUpdate:modelValue":m},null,8,["model-value"])]),_:1}),e(k,{cols:"12",md:"4"},{default:t(()=>[e(_,{modelValue:s.value.location,"onUpdate:modelValue":p[2]||(p[2]=I=>s.value.location=I),label:"Standort",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(k,{cols:"12",md:"4"},{default:t(()=>[e(_,{modelValue:s.value.website,"onUpdate:modelValue":p[3]||(p[3]=I=>s.value.website=I),label:"Website",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(k,{cols:"12"},{default:t(()=>[e(i,{modelValue:s.value.description,"onUpdate:modelValue":p[4]||(p[4]=I=>s.value.description=I),label:"Beschreibung",variant:"outlined",rows:"3","auto-grow":""},null,8,["modelValue"])]),_:1}),e(k,{cols:"12"},{default:t(()=>[e(hl,{modelValue:s.value.regulatory,"onUpdate:modelValue":p[5]||(p[5]=I=>s.value.regulatory=I)},null,8,["modelValue"])]),_:1})]),_:1}),a("div",Cy,[e(x,{color:"primary",loading:r.saving,onClick:u},{default:t(()=>[...p[6]||(p[6]=[n("Speichern",-1)])]),_:1},8,["loading"])])]),_:1})]),_:1})}}});function Ay(r){const $=y(null),d=y(null),c=y(!1),s=y(null);let m=null,u=null;function f(){m!==null&&(window.clearInterval(m),m=null),u!==null&&(window.clearTimeout(u),u=null)}async function p(){if(!$.value)return;const i=await re.get(`/admin/companies/${r}/enrichment-status/${$.value}`);!i.success||!i.data||(d.value=i.data,(i.data.status==="completed"||i.data.status==="failed")&&(c.value=!1,i.data.status==="failed"&&(s.value=i.data.error||"Anreicherung fehlgeschlagen"),f(),ue.info("ADMIN","Enrichment-Polling beendet",{jobId:$.value,status:i.data.status})))}async function _(i=90){s.value=null,c.value=!0,d.value=null;try{const g=await re.post(`/admin/companies/${r}/enrich`);if(!g.success||!g.data){g.status===409?s.value="Es läuft bereits eine Anreicherung für diese Company. Bitte kurz warten.":s.value=g.error||"Anreicherung konnte nicht gestartet werden",c.value=!1;return}$.value=g.data.jobId,ue.info("ADMIN","Enrichment-Job gestartet",{companyId:r,jobId:g.data.jobId}),p(),m=window.setInterval(()=>{p()},2e3),u=window.setTimeout(()=>{c.value&&(ue.warn("ADMIN","Enrichment-Timeout überschritten",{companyId:r,timeoutSec:i}),s.value=`Zeitlimit von ${i}s überschritten. Die Anreicherung läuft im Hintergrund weiter.`,c.value=!1,f())},i*1e3)}catch(g){s.value=g instanceof Error?g.message:"Unbekannter Fehler beim Starten der Anreicherung",c.value=!1,ue.error("ADMIN","Enrichment-Start Exception",{companyId:r,error:g})}}function k(){f(),$.value=null,d.value=null,c.value=!1,s.value=null}return Ft(f),{jobId:$,status:d,isRunning:c,error:s,start:_,reset:k}}const Iy={class:"d-flex align-center ga-1 mb-1"},Py={key:1,class:"text-caption text-medium-emphasis ml-1"},zy={class:"d-flex flex-wrap ga-4"},Dy={class:"d-flex flex-wrap ga-1"},Ty=Ae({__name:"EnrichmentPreviewCard",props:{company:{},proposed:{}},emits:["apply","discard"],setup(r,{emit:$}){const d=r,c=$,s=y({industry:"",size:null,location:"",website:"",description:"",regulatory:{nis2:!1,dora:!1,kritis:!1},sources:[]});Ze(()=>d.proposed,i=>{var g,x,w;s.value={industry:i.industry??"",size:i.size??null,location:i.location??"",website:i.website??"",description:i.description??"",regulatory:{nis2:((g=i.regulatory)==null?void 0:g.nis2)??!1,dora:((x=i.regulatory)==null?void 0:x.dora)??!1,kritis:((w=i.regulatory)==null?void 0:w.kritis)??!1},sources:i.sources?[...i.sources]:[]}},{immediate:!0});function m(i){return String(d.company[i]??"")!==String(s.value[i]??"")}function u(){return String(d.company.size??"")!==String(s.value.size??"")}function f(){return s.value.regulatory?s.value.regulatory.nis2!==d.company.regulatory.nis2||s.value.regulatory.dora!==d.company.regulatory.dora||s.value.regulatory.kritis!==d.company.regulatory.kritis:!1}function p(i){if(i==null||String(i)===""){s.value.size=null;return}const g=parseInt(String(i),10);s.value.size=Number.isFinite(g)?g:null}function _(){c("apply",{...s.value})}function k(){c("discard")}return(i,g)=>{const x=l("v-icon"),w=l("v-card-title"),b=l("v-card-subtitle"),I=l("v-divider"),V=l("v-text-field"),E=l("v-col"),R=l("v-textarea"),M=l("v-checkbox"),T=l("v-chip"),D=l("v-row"),H=l("v-card-text"),O=l("v-spacer"),S=l("v-btn"),B=l("v-card-actions"),G=l("v-card");return o(),N(G,{variant:"outlined",class:"mt-4 enrichment-preview-card"},{default:t(()=>[e(w,{class:"d-flex align-center ga-2 pa-4 pb-2"},{default:t(()=>[e(x,{color:"primary",size:"20"},{default:t(()=>[...g[7]||(g[7]=[n("mdi-creation",-1)])]),_:1}),g[8]||(g[8]=a("span",null,"KI-Anreicherungsvorschlag",-1))]),_:1}),e(b,{class:"px-4 pb-3"},{default:t(()=>[...g[9]||(g[9]=[n(' Felder können vor dem Übernehmen bearbeitet werden. Änderungen werden erst beim Klick auf "Übernehmen" gespeichert. ',-1)])]),_:1}),e(I),e(H,{class:"pa-4"},{default:t(()=>[e(D,{dense:""},{default:t(()=>[e(E,{cols:"12",md:"6"},{default:t(()=>[e(V,{modelValue:s.value.industry,"onUpdate:modelValue":g[0]||(g[0]=W=>s.value.industry=W),label:"Branche",variant:"outlined",density:"comfortable","prepend-inner-icon":m("industry")?"mdi-circle-medium":void 0,hint:m("industry")?`Bisher: ${r.company.industry||"(leer)"}`:"","persistent-hint":""},null,8,["modelValue","prepend-inner-icon","hint"])]),_:1}),e(E,{cols:"12",md:"6"},{default:t(()=>[e(V,{"model-value":s.value.size===null?"":String(s.value.size),label:"Mitarbeiter",type:"number",min:"0",variant:"outlined",density:"comfortable","prepend-inner-icon":u()?"mdi-circle-medium":void 0,hint:u()?`Bisher: ${r.company.size??"(leer)"}`:"","persistent-hint":"","onUpdate:modelValue":p},null,8,["model-value","prepend-inner-icon","hint"])]),_:1}),e(E,{cols:"12",md:"6"},{default:t(()=>[e(V,{modelValue:s.value.location,"onUpdate:modelValue":g[1]||(g[1]=W=>s.value.location=W),label:"Standort",variant:"outlined",density:"comfortable","prepend-inner-icon":m("location")?"mdi-circle-medium":void 0,hint:m("location")?`Bisher: ${r.company.location||"(leer)"}`:"","persistent-hint":""},null,8,["modelValue","prepend-inner-icon","hint"])]),_:1}),e(E,{cols:"12",md:"6"},{default:t(()=>[e(V,{modelValue:s.value.website,"onUpdate:modelValue":g[2]||(g[2]=W=>s.value.website=W),label:"Website",variant:"outlined",density:"comfortable","prepend-inner-icon":m("website")?"mdi-circle-medium":void 0,hint:m("website")?`Bisher: ${r.company.website||"(leer)"}`:"","persistent-hint":""},null,8,["modelValue","prepend-inner-icon","hint"])]),_:1}),e(E,{cols:"12"},{default:t(()=>[e(R,{modelValue:s.value.description,"onUpdate:modelValue":g[3]||(g[3]=W=>s.value.description=W),label:"Beschreibung",variant:"outlined",density:"comfortable",rows:"3","auto-grow":"","prepend-inner-icon":m("description")?"mdi-circle-medium":void 0,hint:m("description")?`Bisher: ${r.company.description||"(leer)"}`:"","persistent-hint":""},null,8,["modelValue","prepend-inner-icon","hint"])]),_:1}),e(E,{cols:"12"},{default:t(()=>[a("div",Iy,[g[11]||(g[11]=a("span",{class:"text-caption text-medium-emphasis"},"Regulatorik",-1)),f()?(o(),N(x,{key:0,size:"14",color:"primary"},{default:t(()=>[...g[10]||(g[10]=[n("mdi-circle-medium",-1)])]),_:1})):U("",!0),f()?(o(),h("span",Py," (Bisher: NIS2="+v(r.company.regulatory.nis2)+", DORA="+v(r.company.regulatory.dora)+", KRITIS="+v(r.company.regulatory.kritis)+") ",1)):U("",!0)]),a("div",zy,[e(M,{modelValue:s.value.regulatory.nis2,"onUpdate:modelValue":g[4]||(g[4]=W=>s.value.regulatory.nis2=W),label:"NIS2-relevant",density:"comfortable","hide-details":""},null,8,["modelValue"]),e(M,{modelValue:s.value.regulatory.dora,"onUpdate:modelValue":g[5]||(g[5]=W=>s.value.regulatory.dora=W),label:"DORA-relevant",density:"comfortable","hide-details":""},null,8,["modelValue"]),e(M,{modelValue:s.value.regulatory.kritis,"onUpdate:modelValue":g[6]||(g[6]=W=>s.value.regulatory.kritis=W),label:"KRITIS-Betreiber",density:"comfortable","hide-details":""},null,8,["modelValue"])])]),_:1}),r.proposed.sources&&r.proposed.sources.length>0?(o(),N(E,{key:0,cols:"12"},{default:t(()=>[g[12]||(g[12]=a("div",{class:"text-caption text-medium-emphasis mb-2"},"Quellen aus Web-Recherche:",-1)),a("div",Dy,[(o(!0),h(be,null,Pe(r.proposed.sources,(W,F)=>(o(),N(T,{key:F,href:W,target:"_blank",rel:"noopener noreferrer",size:"small",variant:"outlined","prepend-icon":"mdi-link-variant",class:"mb-1"},{default:t(()=>[n(v(W.replace(/^https?:\/\//,"").substring(0,50)),1)]),_:2},1032,["href"]))),128))])]),_:1})):U("",!0)]),_:1})]),_:1}),e(I),e(B,{class:"pa-4"},{default:t(()=>[e(O),e(S,{variant:"text",onClick:k},{default:t(()=>[...g[13]||(g[13]=[n("Verwerfen",-1)])]),_:1}),e(S,{color:"primary",variant:"flat","prepend-icon":"mdi-check",onClick:_},{default:t(()=>[...g[14]||(g[14]=[n(" Übernehmen ",-1)])]),_:1})]),_:1})]),_:1})}}}),Ly=Me(Ty,[["__scopeId","data-v-2a7c85e3"]]),Ey={class:"mb-3"},My={class:"d-flex flex-wrap ga-2"},Ny={class:"mb-3"},Uy={key:3,class:"mb-3"},By={class:"text-body-2 pa-3 rounded",style:{background:"rgba(255,255,255,0.05)","white-space":"pre-wrap"}},Fy=Ae({__name:"CompanyEnrichmentSection",props:{company:{}},emits:["updated"],setup(r,{emit:$}){const d=r,c=$,s=Ay(d.company._id),m=y(90),u=y(!1),f=y(null);async function p(){var b,I,V;const w=await re.get("/platform-settings");if(w.success&&w.data){const E=(I=(b=w.data.current)==null?void 0:b.companyEnrichment)==null?void 0:I.timeoutSec,R=(V=w.data.companyEnrichment)==null?void 0:V.timeoutSec,M=E??R;typeof M=="number"&&(m.value=M)}}rt(()=>{p()});async function _(){f.value=null,await s.start(m.value)}async function k(w){u.value=!0,f.value=null;const b=await re.put(`/admin/companies/${d.company._id}`,w);b.success?(s.reset(),c("updated"),ue.info("ADMIN","Enrichment-Vorschlag übernommen",{id:d.company._id})):(f.value=b.error??"Fehler beim Übernehmen der Anreicherung.",ue.error("ADMIN","Enrichment-Apply fehlgeschlagen",{id:d.company._id,error:b.error})),u.value=!1}function i(){s.reset(),f.value=null}function g(w){switch(w){case"research":return"primary";case"manual":return"secondary";case"migration":return"default";default:return"default"}}function x(w){switch(w){case"research":return"Research";case"manual":return"Manuell";case"migration":return"Migration";default:return w}}return(w,b)=>{const I=l("v-btn"),V=l("v-card-title"),E=l("v-divider"),R=l("v-progress-circular"),M=l("v-alert"),T=l("v-chip"),D=l("v-card-text"),H=l("v-card");return o(),N(H,{rounded:"lg"},{default:t(()=>[e(V,{class:"d-flex align-center justify-space-between pa-4 pb-2"},{default:t(()=>[b[3]||(b[3]=a("span",null,"Datenanreicherung",-1)),e(I,{"prepend-icon":"mdi-creation",color:"primary",variant:"tonal",size:"small",loading:P(s).isRunning.value,disabled:P(s).isRunning.value,onClick:_},{default:t(()=>[...b[2]||(b[2]=[n(" Stammdaten neu anreichern ",-1)])]),_:1},8,["loading","disabled"])]),_:1}),e(E),e(D,{class:"pa-4"},{default:t(()=>{var O,S;return[P(s).isRunning.value?(o(),N(M,{key:0,type:"info",variant:"tonal",density:"compact",class:"mb-3"},{prepend:t(()=>[e(R,{indeterminate:"",size:"18",width:"2",class:"mr-2"})]),default:t(()=>{var B;return[n(" KI-Anreicherung läuft - "+v(((B=P(s).status.value)==null?void 0:B.currentStep)||"Initialisierung..."),1)]}),_:1})):U("",!0),P(s).error.value?(o(),N(M,{key:1,type:"error",variant:"tonal",density:"compact",closable:"",class:"mb-3","onClick:close":b[0]||(b[0]=B=>P(s).reset())},{default:t(()=>[n(v(P(s).error.value),1)]),_:1})):U("",!0),f.value?(o(),N(M,{key:2,type:"error",variant:"tonal",density:"compact",closable:"",class:"mb-3","onClick:close":b[1]||(b[1]=B=>f.value=null)},{default:t(()=>[n(v(f.value),1)]),_:1})):U("",!0),a("div",Ey,[b[7]||(b[7]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Regulatorik",-1)),a("div",My,[e(T,{size:"small",color:r.company.regulatory.nis2?"error":void 0,variant:r.company.regulatory.nis2?"tonal":"outlined"},{default:t(()=>[...b[4]||(b[4]=[n(" NIS2 ",-1)])]),_:1},8,["color","variant"]),e(T,{size:"small",color:r.company.regulatory.dora?"warning":void 0,variant:r.company.regulatory.dora?"tonal":"outlined"},{default:t(()=>[...b[5]||(b[5]=[n(" DORA ",-1)])]),_:1},8,["color","variant"]),e(T,{size:"small",color:r.company.regulatory.kritis?"info":void 0,variant:r.company.regulatory.kritis?"tonal":"outlined"},{default:t(()=>[...b[6]||(b[6]=[n(" KRITIS ",-1)])]),_:1},8,["color","variant"])])]),a("div",Ny,[b[8]||(b[8]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Datenquelle",-1)),e(T,{size:"small",color:g(r.company.source),variant:"tonal"},{default:t(()=>[n(v(x(r.company.source)),1)]),_:1},8,["color"])]),r.company.description?(o(),h("div",Uy,[b[9]||(b[9]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"KI-Beschreibung",-1)),a("div",By,v(r.company.description),1)])):U("",!0),((O=P(s).status.value)==null?void 0:O.status)==="completed"&&((S=P(s).status.value)!=null&&S.proposed)?(o(),N(Ly,{key:4,company:r.company,proposed:P(s).status.value.proposed,class:ft({"opacity-50":u.value}),onApply:k,onDiscard:i},null,8,["company","proposed","class"])):U("",!0)]}),_:1})]),_:1})}}}),Oy=Ae({__name:"CompanyLeadsList",props:{leads:{}},setup(r){const $=xt();function d(s,m){$.push(`/admin/leads/${m.item._id}`)}const c=[{title:"Name",key:"name"},{title:"E-Mail",key:"email"},{title:"Position",key:"position"},{title:"Stage",key:"pipeline.stage"},{title:"Score",key:"scoring.total",align:"end"},{title:"Quelle",key:"source.type"}];return(s,m)=>{const u=l("v-chip"),f=l("v-card-title"),p=l("v-divider"),_=l("v-data-table"),k=l("v-card");return o(),N(k,{rounded:"lg"},{default:t(()=>[e(f,{class:"pa-4 pb-2 d-flex align-center"},{default:t(()=>[m[0]||(m[0]=n(" Verknüpfte Leads ",-1)),e(u,{size:"x-small",variant:"tonal",color:"primary",class:"ml-2"},{default:t(()=>[n(v(r.leads.length),1)]),_:1})]),_:1}),e(p),e(_,{items:r.leads,headers:c,"items-per-page":100,"hide-default-footer":"","no-data-text":"Keine Leads verknüpft",hover:"","onClick:row":d},{"item.name":t(({item:i})=>[n(v(i.firstName)+" "+v(i.lastName),1)]),"item.source.type":t(({item:i})=>[e(u,{size:"x-small",variant:"tonal"},{default:t(()=>[n(v(i.source.type),1)]),_:2},1024)]),_:1},8,["items"])]),_:1})}}}),Ry={class:"pa-4"},Ky=Ae({__name:"CompanyOverviewTab",props:{company:{},leads:{}},emits:["updated"],setup(r,{emit:$}){const d=r,c=$,s=y(!1),m=y(null);async function u(f){s.value=!0,m.value=null;try{const p=await re.put(`/admin/companies/${d.company._id}`,f);p.success?c("updated"):(m.value=p.error??"Speichern fehlgeschlagen.",ue.error("ADMIN","Company speichern fehlgeschlagen",{id:d.company._id,error:p.error}))}catch(p){m.value="Netzwerkfehler beim Speichern.",ue.error("ADMIN","Company speichern: Exception",{id:d.company._id,error:p instanceof Error?p.message:"Unbekannt"})}finally{s.value=!1}}return(f,p)=>{const _=l("v-alert");return o(),h("div",Ry,[m.value?(o(),N(_,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",text:m.value},null,8,["text"])):U("",!0),e(Vy,{"model-value":d.company,saving:s.value,class:"mb-4",onSave:u},null,8,["model-value","saving"]),e(Fy,{company:d.company,class:"mb-4",onUpdated:p[0]||(p[0]=k=>c("updated"))},null,8,["company"]),e(Oy,{leads:d.leads},null,8,["leads"])])}}}),jy={class:"position-relative",style:{display:"inline-block"}},qy={class:"text-h3 font-weight-bold"},Gy=Ae({__name:"CompanyScoringTotal",props:{total:{},isStale:{type:Boolean}},setup(r){function $(d){return d>=75?"success":d>=50?"warning":"error"}return(d,c)=>{const s=l("v-progress-circular"),m=l("v-chip"),u=l("v-card");return o(),N(u,{rounded:"lg",class:"text-center pa-6"},{default:t(()=>[a("div",jy,[e(s,{"model-value":r.total,color:$(r.total),size:160,width:14},{default:t(()=>[a("span",qy,v(r.total),1)]),_:1},8,["model-value","color"])]),c[1]||(c[1]=a("div",{class:"text-body-2 text-medium-emphasis mt-2"},"Gesamt-Score",-1)),r.isStale?(o(),N(m,{key:0,color:"warning",size:"small",variant:"tonal","prepend-icon":"mdi-alert-circle-outline",class:"mt-3"},{default:t(()=>[...c[0]||(c[0]=[n(" Stammdaten geändert seit Scoring ",-1)])]),_:1})):U("",!0)]),_:1})}}}),Hy={class:"mb-4"},Wy={class:"d-flex align-center justify-space-between mb-1"},Zy={class:"text-body-1 font-weight-semibold"},Jy={class:"text-caption text-medium-emphasis"},Qy={class:"text-body-2 text-medium-emphasis ma-0"},Yy=Ae({__name:"CompanyScoringFactor",props:{name:{},weight:{},score:{},reasoning:{}},setup(r){function $(d){return d>=75?"success":d>=50?"warning":"error"}return(d,c)=>{const s=l("v-progress-linear");return o(),h("div",Hy,[a("div",Wy,[a("span",Zy,[n(v(r.name)+" ",1),a("span",Jy,"("+v(r.weight)+" %)",1)]),a("span",{class:ft(["text-h6 font-weight-bold",`text-${$(r.score)}`])},v(r.score),3)]),e(s,{"model-value":r.score,color:$(r.score),rounded:"",height:"8",class:"mb-2"},null,8,["model-value","color"]),a("p",Qy,v(r.reasoning||"Keine Begründung verfügbar"),1)])}}}),Xy={class:"text-body-2 mb-2"},e_={key:0,class:"text-body-2 mb-3"},t_=Ae({__name:"CompanyScoringActions",props:{lastCalculatedAt:{},calculatedBy:{},loading:{type:Boolean}},emits:["recalculate"],setup(r,{emit:$}){const d=$;function c(s){return s?new Date(s).toLocaleString("de-DE"):"-"}return(s,m)=>{const u=l("v-btn"),f=l("v-card");return o(),N(f,{rounded:"lg",class:"pa-4"},{default:t(()=>[a("div",Xy,[m[1]||(m[1]=a("strong",null,"Zuletzt berechnet:",-1)),n(" "+v(c(r.lastCalculatedAt)),1)]),r.calculatedBy?(o(),h("div",e_,[m[2]||(m[2]=a("strong",null,"Berechnet von:",-1)),n(" "+v(r.calculatedBy==="manual"?"manuell":r.calculatedBy==="auto-on-create"?"automatisch beim Anlegen":r.calculatedBy),1)])):U("",!0),e(u,{color:"primary","prepend-icon":"mdi-refresh",loading:r.loading,block:"",onClick:m[0]||(m[0]=p=>d("recalculate"))},{default:t(()=>[n(v(r.lastCalculatedAt?"Neu berechnen":"Jetzt berechnen"),1)]),_:1},8,["loading"])]),_:1})}}});function Ba(r,$,d){const c=y(!1),s=y(null);async function m(){try{const u=await re.get(`/admin/companies/${r()}/${$}`);u.success&&u.data&&(c.value=u.data.isStale,s.value=u.data.reason)}catch(u){ue.warn("ADMIN",`${d} laden fehlgeschlagen`,{error:u instanceof Error?u.message:"Unbekannt"})}}return Ze(r,m,{immediate:!0}),{isStale:c,reason:s,refresh:m}}function a_(r){return Ba(r,"stale-status","Stale-Status")}const l_=Ae({__name:"CompanyScoringTab",props:{company:{}},emits:["updated"],setup(r,{emit:$}){const d=r,c=$,s=y(d.company.scoring),m=y(!1),u=y(null);Ze(()=>d.company.scoring,i=>{s.value=i??null});const{isStale:f,refresh:p}=a_(()=>d.company._id);async function _(){m.value=!0,u.value=null;try{const i=await re.post(`/admin/companies/${d.company._id}/score`);i.success&&i.data?(s.value=i.data.scoring,c("updated"),await p()):(u.value=i.error||"Scoring fehlgeschlagen.",ue.error("ADMIN","Scoring fehlgeschlagen",{error:i.error}))}catch(i){u.value="Netzwerkfehler beim Scoring.",ue.error("ADMIN","Scoring Exception",{error:i instanceof Error?i.message:"Unbekannt"})}finally{m.value=!1}}const k=se(()=>s.value?[{key:"regulatory",name:la.regulatory,...s.value.factors.regulatory,weight:s.value.weightsSnapshot.regulatory},{key:"mandate",name:la.mandate,...s.value.factors.mandate,weight:s.value.weightsSnapshot.mandate},{key:"industryFit",name:la.industryFit,...s.value.factors.industryFit,weight:s.value.weightsSnapshot.industryFit},{key:"maturity",name:la.maturity,...s.value.factors.maturity,weight:s.value.weightsSnapshot.maturity},{key:"engagement",name:la.engagement,...s.value.factors.engagement,weight:s.value.weightsSnapshot.engagement}]:[]);return(i,g)=>{const x=l("v-alert"),w=l("v-col"),b=l("v-card"),I=l("v-row"),V=l("v-icon"),E=l("v-btn");return o(),h(be,null,[u.value?(o(),N(x,{key:0,type:"error",variant:"tonal",class:"mb-4",text:u.value},null,8,["text"])):U("",!0),s.value?(o(),N(I,{key:1},{default:t(()=>[e(w,{cols:"12",md:"4"},{default:t(()=>[e(Gy,{total:s.value.total,"is-stale":P(f)},null,8,["total","is-stale"])]),_:1}),e(w,{cols:"12",md:"8"},{default:t(()=>[e(t_,{"last-calculated-at":s.value.lastCalculatedAt,"calculated-by":s.value.calculatedBy,loading:m.value,onRecalculate:_},null,8,["last-calculated-at","calculated-by","loading"])]),_:1}),e(w,{cols:"12"},{default:t(()=>[e(b,{rounded:"lg",class:"pa-6"},{default:t(()=>[g[0]||(g[0]=a("h3",{class:"text-h6 font-weight-semibold mb-4"},"Faktoren",-1)),(o(!0),h(be,null,Pe(k.value,R=>(o(),N(Yy,{key:R.key,name:R.name,weight:R.weight,score:R.score,reasoning:R.reasoning},null,8,["name","weight","score","reasoning"]))),128))]),_:1})]),_:1})]),_:1})):(o(),N(b,{key:2,rounded:"lg",class:"pa-12 text-center"},{default:t(()=>[e(V,{size:"48",color:"medium-emphasis"},{default:t(()=>[...g[1]||(g[1]=[n("mdi-chart-arc",-1)])]),_:1}),g[3]||(g[3]=a("h3",{class:"text-h6 mt-4 mb-2"},"Noch nicht gescort",-1)),g[4]||(g[4]=a("p",{class:"text-body-2 text-medium-emphasis mb-6"},' Diese Company wurde noch nicht von der KI bewertet. Klicke auf "Jetzt berechnen", um ein Multi-Faktor-Scoring zu erstellen. ',-1)),e(E,{color:"primary","prepend-icon":"mdi-chart-arc",loading:m.value,onClick:_},{default:t(()=>[...g[2]||(g[2]=[n(" Jetzt berechnen ",-1)])]),_:1},8,["loading"])]),_:1}))],64)}}}),n_={class:"text-h6 font-weight-bold"},o_={class:"text-caption text-medium-emphasis"},s_=Ae({__name:"CompanyEngagementSummary",props:{aggregate:{}},setup(r){const $=r,d=se(()=>$.aggregate===null||$.aggregate.leadCount===0);function c(m){if(!m)return"keine Aktivität";const u=new Date(m),p=new Date().getTime()-u.getTime(),_=Math.floor(p/(1e3*60*60*24));return _===0?"heute":_===1?"vor 1 Tag":_<30?`vor ${_} Tagen`:u.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}const s=se(()=>$.aggregate?[{key:"leadCount",label:"Anzahl Leads",value:$.aggregate.leadCount,icon:"mdi-account-group"},{key:"totalOpens",label:"E-Mail-Opens",value:$.aggregate.totalOpens,icon:"mdi-email-open-outline"},{key:"totalClicks",label:"Klicks",value:$.aggregate.totalClicks,icon:"mdi-cursor-default-click-outline"},{key:"totalMeetings",label:"Meetings",value:$.aggregate.totalMeetings,icon:"mdi-calendar-check-outline"},{key:"lastActivityAt",label:"Letzte Aktivität",value:c($.aggregate.lastActivityAt),icon:"mdi-clock-outline"}]:[]);return(m,u)=>{const f=l("v-icon"),p=l("v-card"),_=l("v-col"),k=l("v-row");return o(),h("div",null,[d.value?(o(),N(p,{key:0,variant:"tonal",color:"medium-emphasis",class:"pa-6 text-center",rounded:"lg"},{default:t(()=>[e(f,{size:"40",color:"medium-emphasis",class:"mb-2"},{default:t(()=>[...u[0]||(u[0]=[n("mdi-account-group-outline",-1)])]),_:1}),u[1]||(u[1]=a("p",{class:"text-body-2 text-medium-emphasis ma-0"},"Noch keine Leads verknüpft",-1))]),_:1})):(o(),N(k,{key:1,dense:""},{default:t(()=>[(o(!0),h(be,null,Pe(s.value,i=>(o(),N(_,{key:i.key,cols:"12",sm:"6",md:"4",lg:"2"},{default:t(()=>[e(p,{rounded:"lg",variant:"tonal",class:"pa-4 text-center",height:"100%"},{default:t(()=>[e(f,{size:"28",color:"primary",class:"mb-2"},{default:t(()=>[n(v(i.icon),1)]),_:2},1024),a("div",n_,v(i.value),1),a("div",o_,v(i.label),1)]),_:2},1024)]),_:2},1024))),128))]),_:1}))])}}});function i_(r){return Ba(r,"outreach-stale-status","Outreach-Stale-Status")}const r_={class:"d-flex align-center justify-space-between mb-4 flex-wrap ga-2"},d_={class:"d-flex align-center ga-2"},u_={key:0,class:"text-caption text-medium-emphasis"},c_={class:"text-body-2",style:{"white-space":"pre-wrap","font-family":"inherit"}},m_=Ae({__name:"CompanyOutreachStrategy",props:{company:{}},emits:["updated"],setup(r,{emit:$}){const d=r,c=$,s=y(!1),m=y(null),{isStale:u,refresh:f}=i_(()=>d.company._id),p=se(()=>d.company.outreachStrategy!==null),_=se(()=>{var g;const i=(g=d.company.outreachStrategy)==null?void 0:g.lastCalculatedAt;return i?new Date(i).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):null});async function k(){s.value=!0,m.value=null;try{const i=await re.post(`/admin/companies/${d.company._id}/outreach-strategy`,{});i.success?(ue.info("ADMIN","Outreach-Strategie generiert",{companyId:d.company._id}),await f(),c("updated")):(m.value=i.error??"Strategie konnte nicht generiert werden.",ue.error("ADMIN","Outreach-Strategie Fehler",{error:i.error}))}catch(i){m.value="Fehler beim Generieren der Outreach-Strategie. Bitte erneut versuchen.",ue.error("ADMIN","Outreach-Strategie Ausnahme",{error:i instanceof Error?i.message:"Unbekannt"})}finally{s.value=!1}}return(i,g)=>{const x=l("v-alert"),w=l("v-chip"),b=l("v-icon"),I=l("v-btn"),V=l("v-card"),E=l("v-card-title"),R=l("v-list-item-title"),M=l("v-list-item"),T=l("v-list"),D=l("v-card-text");return o(),h("div",null,[m.value?(o(),N(x,{key:0,type:"error",variant:"tonal",closable:"",class:"mb-4","onClick:close":g[0]||(g[0]=H=>m.value=null)},{default:t(()=>[n(v(m.value),1)]),_:1})):U("",!0),p.value&&P(u)?(o(),N(w,{key:1,color:"warning",variant:"tonal",size:"small","prepend-icon":"mdi-alert-circle-outline",class:"mb-4"},{default:t(()=>[...g[1]||(g[1]=[n(" Stammdaten geändert - Strategie veraltet ",-1)])]),_:1})):U("",!0),p.value?(o(),h(be,{key:3},[a("div",r_,[g[7]||(g[7]=a("h3",{class:"text-h6 font-weight-semibold"},"Outreach-Strategie",-1)),a("div",d_,[_.value?(o(),h("span",u_," Zuletzt generiert: "+v(_.value),1)):U("",!0),e(I,{color:"primary",variant:"outlined",size:"small","prepend-icon":"mdi-refresh",loading:s.value,onClick:k},{default:t(()=>[...g[6]||(g[6]=[n(" Neu generieren ",-1)])]),_:1},8,["loading"])])]),e(V,{variant:"tonal",color:"surface-variant",class:"mb-4",rounded:"lg"},{default:t(()=>[e(E,{class:"text-body-1 font-weight-semibold pa-4 pb-2"},{default:t(()=>[e(b,{class:"mr-2",size:"20"},{default:t(()=>[...g[8]||(g[8]=[n("mdi-format-list-bulleted",-1)])]),_:1}),g[9]||(g[9]=n(" Talking Points ",-1))]),_:1}),e(T,{density:"compact",class:"pt-0"},{default:t(()=>[(o(!0),h(be,null,Pe(r.company.outreachStrategy.talkingPoints,(H,O)=>(o(),N(M,{key:O,"prepend-icon":"mdi-circle-small"},{default:t(()=>[e(R,{class:"text-body-2 text-wrap"},{default:t(()=>[n(v(H),1)]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1}),e(V,{variant:"tonal",color:"surface-variant",class:"mb-3",rounded:"lg"},{default:t(()=>[e(E,{class:"text-body-2 font-weight-medium pa-3 pb-1"},{default:t(()=>[e(b,{class:"mr-2",size:"18"},{default:t(()=>[...g[10]||(g[10]=[n("mdi-email-outline",-1)])]),_:1}),g[11]||(g[11]=n(" Betreff ",-1))]),_:1}),e(D,{class:"text-body-2 pt-1"},{default:t(()=>[n(v(r.company.outreachStrategy.coldMail.subject),1)]),_:1})]),_:1}),e(V,{variant:"tonal",color:"surface-variant",rounded:"lg"},{default:t(()=>[e(E,{class:"text-body-2 font-weight-medium pa-3 pb-1"},{default:t(()=>[e(b,{class:"mr-2",size:"18"},{default:t(()=>[...g[12]||(g[12]=[n("mdi-text-long",-1)])]),_:1}),g[13]||(g[13]=n(" Mail-Text ",-1))]),_:1}),e(D,null,{default:t(()=>[a("pre",c_,v(r.company.outreachStrategy.coldMail.body),1)]),_:1})]),_:1})],64)):(o(),N(V,{key:2,variant:"tonal",color:"medium-emphasis",class:"pa-6 text-center",rounded:"lg"},{default:t(()=>[e(b,{size:"48",color:"primary",class:"mb-3"},{default:t(()=>[...g[2]||(g[2]=[n("mdi-robot-outline",-1)])]),_:1}),g[4]||(g[4]=a("h3",{class:"text-h6 font-weight-semibold mb-2"},"Noch keine Outreach-Strategie generiert",-1)),g[5]||(g[5]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Lass dir KI-generierte Talking Points und einen Cold-Mail-Vorschlag erstellen, basierend auf Unternehmensdaten und dem aktuellen Scoring. ",-1)),e(I,{color:"primary",variant:"elevated","prepend-icon":"mdi-auto-fix",loading:s.value,onClick:k},{default:t(()=>[...g[3]||(g[3]=[n(" Strategie generieren ",-1)])]),_:1},8,["loading"])]),_:1}))])}}}),xl={hot:"Hot",warm:"Warm",cold:"Cold",stuck:"Stuck"},wl={hot:"warning",warm:"secondary",cold:"info",stuck:"error"};function v_(r){return r?xl[r]??r:"-"}function p_(r){return r?wl[r]??"default":"default"}const f_={class:"pa-4"},g_=["onClick"],b_={class:"font-weight-medium"},y_={key:0,class:"text-caption text-medium-emphasis"},__={class:"text-body-2"},k_={key:1,class:"text-medium-emphasis text-body-2"},h_={class:"text-body-2"},x_=Ae({__name:"CompanyOutreachTab",props:{company:{},leads:{},engagementAggregate:{}},emits:["company-updated"],setup(r,{emit:$}){const d=r,c=$,s=xt(),m=y(!1),u=y(null),{countdown:f,jobId:p,start:_,cancel:k}=yl(),i=se(()=>{var R;return((R=d.company.outreachStrategy)==null?void 0:R.coldMail.subject)??""}),g=se(()=>{var R;return((R=d.company.outreachStrategy)==null?void 0:R.coldMail.body)??""}),x=[{title:"Name",key:"name"},{title:"E-Mail",key:"email"},{title:"Status",key:"engagementState"},{title:"Pipeline-Phase",key:"stage"},{title:"Aktion",key:"action"}];function w(R){return[R.firstName,R.lastName].filter(Boolean).join(" ")||R.email}function b(R){return na[R]??R}function I(R){ue.debug("ADMIN","Lead Navigation aus Outreach-Tab",{leadId:R._id}),s.push(`/admin/leads/${R._id}`)}function V(R){u.value=R,m.value=!0,ue.debug("ADMIN","Direkt-Mail-Composer geoeffnet",{leadId:R._id})}function E(R){const M=Math.max(1,Math.round((new Date(R.scheduledFor).getTime()-Date.now())/1e3));_(R.jobId,M)}return(R,M)=>{const T=l("v-icon"),D=l("v-card"),H=l("v-chip"),O=l("v-btn"),S=l("v-table");return o(),h("div",f_,[e(m_,{company:r.company,class:"mb-6",onUpdated:M[0]||(M[0]=B=>c("company-updated"))},null,8,["company"]),e(s_,{aggregate:r.engagementAggregate,class:"mb-6"},null,8,["aggregate"]),M[6]||(M[6]=a("h3",{class:"text-h6 font-weight-semibold mb-3"},"Verknüpfte Leads",-1)),r.leads.length===0?(o(),N(D,{key:0,variant:"tonal",color:"medium-emphasis",class:"pa-6 text-center",rounded:"lg"},{default:t(()=>[e(T,{size:"40",color:"medium-emphasis",class:"mb-2"},{default:t(()=>[...M[3]||(M[3]=[n("mdi-account-outline",-1)])]),_:1}),M[4]||(M[4]=a("p",{class:"text-body-2 text-medium-emphasis ma-0"},"Keine Leads verknüpft",-1))]),_:1})):(o(),N(S,{key:1,density:"comfortable",hover:""},{default:t(()=>[a("thead",null,[a("tr",null,[(o(),h(be,null,Pe(x,B=>a("th",{key:B.key,class:"text-left"},v(B.title),1)),64))])]),a("tbody",null,[(o(!0),h(be,null,Pe(r.leads,B=>(o(),h("tr",{key:B._id,style:{cursor:"pointer"},onClick:G=>I(B)},[a("td",null,[a("div",b_,v(w(B)),1),B.position?(o(),h("div",y_,v(B.position),1)):U("",!0)]),a("td",__,v(B.email),1),a("td",null,[B.engagementState?(o(),N(H,{key:0,color:P(p_)(B.engagementState),size:"small",variant:"tonal"},{default:t(()=>[n(v(P(v_)(B.engagementState)),1)]),_:2},1032,["color"])):(o(),h("span",k_,"-"))]),a("td",h_,v(b(B.pipeline.stage)),1),a("td",{onClick:M[1]||(M[1]=dt(()=>{},["stop"]))},[e(O,{color:"primary",variant:"tonal",size:"small","prepend-icon":"mdi-email-fast-outline",onClick:G=>V(B)},{default:t(()=>[...M[5]||(M[5]=[n(" Direkt-Mail ",-1)])]),_:1},8,["onClick"])])],8,g_))),128))])]),_:1})),u.value?(o(),N(_l,{key:2,modelValue:m.value,"onUpdate:modelValue":M[2]||(M[2]=B=>m.value=B),lead:u.value,"prefill-subject":i.value,"prefill-body":g.value,onSent:E},null,8,["modelValue","lead","prefill-subject","prefill-body"])):U("",!0),e(kl,{countdown:P(f),"job-id":P(p),onCancel:P(k)},null,8,["countdown","job-id","onCancel"])])}}});function w_(r){return Ba(r,"intent-stale-status","Intent-Stale-Status")}const S_={class:"d-flex align-center justify-space-between mb-4 flex-wrap ga-2"},$_={class:"d-flex align-center ga-2 flex-wrap"},C_={key:0,class:"text-caption text-medium-emphasis"},V_={class:"d-flex align-center justify-space-between mb-2"},A_={class:"text-h5 font-weight-bold"},I_={class:"text-body-2"},P_=Ae({__name:"CompanyIntentStatus",props:{company:{}},emits:["updated"],setup(r,{emit:$}){const d=r,c=$,s=y(!1),m=y(null),{isStale:u,refresh:f}=w_(()=>d.company._id),p=se(()=>d.company.intent!==null),_=x=>({kalt:"grey",warm:"warning",heiss:"error",gewonnen:"success",verloren:"grey-darken-2"})[x]??"grey",k=se(()=>{var w;const x=(w=d.company.intent)==null?void 0:w.lastCalculatedAt;return x?new Date(x).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):null}),i=se(()=>{var b;const x=(b=d.company.intent)==null?void 0:b.calculatedBy;return x?{manual:"Manuell","auto-reply":"Auto (Reply)","auto-engagement":"Auto (Engagement)"}[x]??x:null});async function g(){s.value=!0,m.value=null;try{const x=await re.post(`/admin/companies/${d.company._id}/intent`,{});x.success?(ue.info("ADMIN","Intent berechnet",{companyId:d.company._id}),await f(),c("updated")):(m.value=x.error??"Intent konnte nicht berechnet werden.",ue.error("ADMIN","Intent-Berechnung Fehler",{error:x.error}))}catch(x){m.value="Fehler beim Berechnen des Intents. Bitte erneut versuchen.",ue.error("ADMIN","Intent-Berechnung Ausnahme",{error:x instanceof Error?x.message:"Unbekannt"})}finally{s.value=!1}}return(x,w)=>{const b=l("v-alert"),I=l("v-chip"),V=l("v-icon"),E=l("v-btn"),R=l("v-card"),M=l("v-col"),T=l("v-progress-linear"),D=l("v-row"),H=l("v-card-title"),O=l("v-card-text");return o(),h("div",null,[m.value?(o(),N(b,{key:0,type:"error",variant:"tonal",closable:"",class:"mb-4","onClick:close":w[0]||(w[0]=S=>m.value=null)},{default:t(()=>[n(v(m.value),1)]),_:1})):U("",!0),p.value&&P(u)?(o(),N(I,{key:1,color:"warning",variant:"tonal",size:"small","prepend-icon":"mdi-alert-circle-outline",class:"mb-4"},{default:t(()=>[...w[1]||(w[1]=[n(" Stammdaten geändert - Intent veraltet ",-1)])]),_:1})):U("",!0),p.value?(o(),h(be,{key:3},[a("div",S_,[w[7]||(w[7]=a("h3",{class:"text-h6 font-weight-semibold"},"Intent-Klassifikation",-1)),a("div",$_,[k.value?(o(),h("span",C_," Zuletzt berechnet: "+v(k.value),1)):U("",!0),i.value?(o(),N(I,{key:1,size:"x-small",variant:"outlined",color:"medium-emphasis"},{default:t(()=>[n(v(i.value),1)]),_:1})):U("",!0),e(E,{color:"primary",variant:"outlined",size:"small","prepend-icon":"mdi-refresh",loading:s.value,onClick:g},{default:t(()=>[...w[6]||(w[6]=[n(" Neu berechnen ",-1)])]),_:1},8,["loading"])])]),e(D,{dense:"",class:"mb-4"},{default:t(()=>[e(M,{cols:"12",sm:"4"},{default:t(()=>[e(R,{variant:"tonal",color:_(r.company.intent.status),rounded:"lg",class:"pa-4 text-center"},{default:t(()=>[e(I,{color:_(r.company.intent.status),variant:"elevated",size:"large",class:"mb-2"},{default:t(()=>[n(v(P(Wl)[r.company.intent.status]),1)]),_:1},8,["color"]),w[8]||(w[8]=a("div",{class:"text-caption text-medium-emphasis mt-1"},"Status",-1))]),_:1},8,["color"])]),_:1}),e(M,{cols:"12",sm:"8"},{default:t(()=>[e(R,{variant:"tonal",color:"surface-variant",rounded:"lg",class:"pa-4"},{default:t(()=>[a("div",V_,[w[9]||(w[9]=a("span",{class:"text-body-2 font-weight-medium"},"Intent-Score",-1)),a("span",A_,v(r.company.intent.score),1)]),e(T,{"model-value":r.company.intent.score,color:_(r.company.intent.status),"bg-color":"surface-variant",height:"8",rounded:""},null,8,["model-value","color"]),w[10]||(w[10]=a("div",{class:"d-flex justify-space-between mt-1"},[a("span",{class:"text-caption text-medium-emphasis"},"0"),a("span",{class:"text-caption text-medium-emphasis"},"100")],-1))]),_:1})]),_:1})]),_:1}),e(R,{variant:"tonal",color:"surface-variant",class:"mb-3",rounded:"lg"},{default:t(()=>[e(H,{class:"text-body-2 font-weight-medium pa-3 pb-1"},{default:t(()=>[e(V,{class:"mr-2",size:"18"},{default:t(()=>[...w[11]||(w[11]=[n("mdi-comment-text-outline",-1)])]),_:1}),w[12]||(w[12]=n(" Begründung ",-1))]),_:1}),e(O,{class:"text-body-2 pt-1"},{default:t(()=>[n(v(r.company.intent.reasoning),1)]),_:1})]),_:1}),e(b,{type:"info",variant:"tonal",icon:"mdi-lightbulb-outline"},{default:t(()=>[w[13]||(w[13]=a("div",{class:"text-body-2 font-weight-medium mb-1"},"Empfehlung",-1)),a("div",I_,v(r.company.intent.recommendation),1)]),_:1})],64)):(o(),N(R,{key:2,variant:"tonal",color:"medium-emphasis",class:"pa-6 text-center",rounded:"lg"},{default:t(()=>[e(V,{size:"48",color:"primary",class:"mb-3"},{default:t(()=>[...w[2]||(w[2]=[n("mdi-brain",-1)])]),_:1}),w[4]||(w[4]=a("h3",{class:"text-h6 font-weight-semibold mb-2"},"Noch kein Intent berechnet",-1)),w[5]||(w[5]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Lass die KI den aktuellen Lead-Intent auf Basis von Engagement, Replies und Pipeline-Verlauf klassifizieren. ",-1)),e(E,{color:"primary",variant:"elevated","prepend-icon":"mdi-auto-fix",loading:s.value,onClick:g},{default:t(()=>[...w[3]||(w[3]=[n(" Intent berechnen ",-1)])]),_:1},8,["loading"])]),_:1}))])}}}),z_={class:"d-flex align-center justify-space-between mb-3 flex-wrap ga-2"},D_={key:2,class:"d-flex flex-wrap ga-2"},T_=Ae({__name:"CompanyIntentAutoTriggers",setup(r){const $=y(null),d=y(!1),c=y(null),s=[{key:"replyMarker",label:"Reply-Marker"},{key:"mailjetClick",label:"Mailjet-Klick"},{key:"meetingBooked",label:"Meeting-Buchung"},{key:"pipelineStageChange",label:"Pipeline-Stage-Wechsel"}];function m(f){var p,_,k;return((k=(_=(p=$.value)==null?void 0:p.intent)==null?void 0:_.autoTriggers)==null?void 0:k[f])??!0}async function u(){d.value=!0,c.value=null;try{const f=await re.get("/platform-settings");f.success&&f.data?$.value=f.data:(c.value=f.error??"Einstellungen konnten nicht geladen werden.",ue.error("ADMIN","Platform-Settings laden fehlgeschlagen",{error:f.error}))}catch(f){c.value="Fehler beim Laden der Einstellungen.",ue.error("ADMIN","Platform-Settings Ausnahme",{error:f instanceof Error?f.message:"Unbekannt"})}finally{d.value=!1}}return rt(u),(f,p)=>{const _=l("v-btn"),k=l("v-skeleton-loader"),i=l("v-alert"),g=l("v-chip");return o(),h("div",null,[a("div",z_,[p[1]||(p[1]=a("h3",{class:"text-body-1 font-weight-semibold"},"Auto-Trigger",-1)),e(_,{variant:"text",color:"primary",size:"small","append-icon":"mdi-arrow-right",to:"/admin/ki-einstellungen"},{default:t(()=>[...p[0]||(p[0]=[n(" Auto-Trigger ändern - KI-Einstellungen ",-1)])]),_:1})]),d.value?(o(),N(k,{key:0,type:"chip, chip, chip, chip"})):c.value?(o(),N(i,{key:1,type:"error",variant:"tonal",density:"compact"},{default:t(()=>[n(v(c.value),1)]),_:1})):(o(),h("div",D_,[(o(),h(be,null,Pe(s,x=>e(g,{key:x.key,color:m(x.key)?"success":"default",variant:"tonal",size:"small","prepend-icon":m(x.key)?"mdi-check-circle":"mdi-close-circle"},{default:t(()=>[n(v(x.label),1)]),_:2},1032,["color","prepend-icon"])),64))])),p[2]||(p[2]=a("p",{class:"text-caption text-medium-emphasis mt-2"}," Auto-Trigger bestimmen, bei welchen Ereignissen der Intent automatisch neu berechnet wird. ",-1))])}}}),L_={class:"pa-4"},E_={class:"text-h5 font-weight-bold"},M_={class:"text-body-2"},N_=Ae({__name:"CompanyIntentTab",props:{company:{},leads:{},engagementAggregate:{}},emits:["company-updated"],setup(r,{emit:$}){const d=r,c=$,s={hot:"mdi-fire",warm:"mdi-thermometer",cold:"mdi-snowflake",stuck:"mdi-alert-circle-outline"},m=se(()=>{const p={};for(const _ of d.leads){const k=_.engagementState??"unknown";p[k]=(p[k]??0)+1}return Object.entries(p).map(([_,k])=>({state:_,label:xl[_]??_,color:wl[_]??"default",icon:s[_]??"mdi-help-circle-outline",count:k}))}),u=se(()=>d.leads.length===0),f=se(()=>d.leads.some(p=>p.engagementState!==void 0&&p.engagementState!==null));return(p,_)=>{const k=l("v-icon"),i=l("v-card"),g=l("v-col"),x=l("v-row"),w=l("v-divider");return o(),h("div",L_,[e(P_,{company:r.company,class:"mb-6",onUpdated:_[0]||(_[0]=b=>c("company-updated"))},null,8,["company"]),_[5]||(_[5]=a("h3",{class:"text-h6 font-weight-semibold mb-4"},"Engagement-Verteilung",-1)),u.value?(o(),N(i,{key:0,variant:"tonal",color:"medium-emphasis",class:"pa-6 text-center mb-6",rounded:"lg"},{default:t(()=>[e(k,{size:"40",color:"medium-emphasis",class:"mb-2"},{default:t(()=>[..._[1]||(_[1]=[n("mdi-chart-pie-outline",-1)])]),_:1}),_[2]||(_[2]=a("p",{class:"text-body-2 text-medium-emphasis ma-0"},"Noch keine Leads verknüpft",-1))]),_:1})):f.value?(o(),N(x,{key:2,dense:"",class:"mb-6"},{default:t(()=>[(o(!0),h(be,null,Pe(m.value,b=>(o(),N(g,{key:b.state,cols:"6",sm:"4",md:"3"},{default:t(()=>[e(i,{rounded:"lg",variant:"tonal",color:b.color,class:"pa-4 text-center"},{default:t(()=>[e(k,{size:"32",class:"mb-2"},{default:t(()=>[n(v(b.icon),1)]),_:2},1024),a("div",E_,v(b.count),1),a("div",M_,v(b.label),1)]),_:2},1032,["color"])]),_:2},1024))),128))]),_:1})):(o(),N(i,{key:1,variant:"tonal",color:"medium-emphasis",class:"pa-6 text-center mb-6",rounded:"lg"},{default:t(()=>[e(k,{size:"40",color:"medium-emphasis",class:"mb-2"},{default:t(()=>[..._[3]||(_[3]=[n("mdi-chart-pie-outline",-1)])]),_:1}),_[4]||(_[4]=a("p",{class:"text-body-2 text-medium-emphasis ma-0"},"Kein Engagement-Status für die verknüpften Leads verfügbar",-1))]),_:1})),e(w,{class:"mb-4"}),e(T_)])}}}),U_={class:"d-flex align-center ga-3 mb-4"},B_={class:"text-h4 font-weight-bold"},F_={key:1,class:"d-flex justify-center py-16"},O_=Ae({__name:"CompanyDetailView",setup(r){const $=xt(),d=Ut(),c=se(()=>d.params.id),s=y(!0),m=y(null),u=y(null),f=y([]),p=y(null),_=y(!1),k=y(!1),g=y(["overview","scoring","outreach","intent"].includes(d.query.tab)?d.query.tab:"overview");Ze(g,b=>{$.replace({query:{...d.query,tab:b}})});async function x(){s.value=!0,m.value=null;try{const b=await re.get(`/admin/companies/${c.value}`);b.success&&b.data?(u.value=b.data.company,f.value=b.data.leads,p.value=b.data.engagementAggregate??null):(m.value="Company konnte nicht geladen werden.",ue.error("ADMIN","Company laden fehlgeschlagen",{id:c.value,error:b.error}))}catch(b){m.value="Netzwerkfehler beim Laden der Company.",ue.error("ADMIN","Company laden: unerwartete Exception",{id:c.value,error:b instanceof Error?b.message:"Unbekannt"})}finally{s.value=!1}}async function w(){k.value=!0;try{const b=await re.delete(`/admin/companies/${c.value}`);if(b.success){$.push("/admin/companies");return}ue.error("ADMIN","Company löschen fehlgeschlagen",{error:b.error}),m.value=b.error||"Löschen fehlgeschlagen.",_.value=!1}catch(b){m.value="Netzwerkfehler beim Löschen.",ue.error("ADMIN","Company löschen: unerwartete Exception",{error:b instanceof Error?b.message:"Unbekannt"}),_.value=!1}finally{k.value=!1}}return rt(x),(b,I)=>{const V=l("v-icon"),E=l("v-btn"),R=l("v-spacer"),M=l("v-alert"),T=l("v-progress-circular"),D=l("v-tab"),H=l("v-tabs"),O=l("v-tabs-window-item"),S=l("v-tabs-window"),B=l("v-card-title"),G=l("v-card-text"),W=l("v-card-actions"),F=l("v-card"),L=l("v-dialog"),A=l("v-container");return o(),N(A,{fluid:"",class:"pa-6"},{default:t(()=>{var z;return[a("div",U_,[e(E,{icon:"",variant:"text","aria-label":"Zurück",onClick:I[0]||(I[0]=j=>P($).push("/admin/companies"))},{default:t(()=>[e(V,null,{default:t(()=>[...I[6]||(I[6]=[n("mdi-arrow-left",-1)])]),_:1})]),_:1}),a("h1",B_,v(((z=u.value)==null?void 0:z.name)||"Company"),1),e(R),e(E,{color:"error",variant:"outlined","prepend-icon":"mdi-delete",onClick:I[1]||(I[1]=j=>_.value=!0)},{default:t(()=>[...I[7]||(I[7]=[n("Löschen",-1)])]),_:1})]),m.value?(o(),N(M,{key:0,type:"error",variant:"tonal",class:"mb-4",text:m.value},null,8,["text"])):U("",!0),s.value?(o(),h("div",F_,[e(T,{indeterminate:"",color:"primary",size:"48"})])):u.value?(o(),h(be,{key:2},[e(H,{modelValue:g.value,"onUpdate:modelValue":I[2]||(I[2]=j=>g.value=j),color:"primary",class:"mb-4"},{default:t(()=>[e(D,{value:"overview","prepend-icon":"mdi-information-outline"},{default:t(()=>[...I[8]||(I[8]=[n("Übersicht",-1)])]),_:1}),e(D,{value:"scoring","prepend-icon":"mdi-chart-arc"},{default:t(()=>[...I[9]||(I[9]=[n("Scoring",-1)])]),_:1}),e(D,{value:"outreach","prepend-icon":"mdi-email-fast-outline"},{default:t(()=>[...I[10]||(I[10]=[n("Outreach",-1)])]),_:1}),e(D,{value:"intent","prepend-icon":"mdi-target-account"},{default:t(()=>[...I[11]||(I[11]=[n("Intent",-1)])]),_:1})]),_:1},8,["modelValue"]),e(S,{modelValue:g.value,"onUpdate:modelValue":I[3]||(I[3]=j=>g.value=j)},{default:t(()=>[e(O,{value:"overview"},{default:t(()=>[e(Ky,{company:u.value,leads:f.value,onUpdated:x},null,8,["company","leads"])]),_:1}),e(O,{value:"scoring"},{default:t(()=>[e(l_,{company:u.value,onUpdated:x},null,8,["company"])]),_:1}),e(O,{value:"outreach"},{default:t(()=>[e(x_,{company:u.value,leads:f.value,"engagement-aggregate":p.value,onCompanyUpdated:x},null,8,["company","leads","engagement-aggregate"])]),_:1}),e(O,{value:"intent"},{default:t(()=>[e(N_,{company:u.value,leads:f.value,"engagement-aggregate":p.value,onCompanyUpdated:x},null,8,["company","leads","engagement-aggregate"])]),_:1})]),_:1},8,["modelValue"])],64)):U("",!0),e(L,{modelValue:_.value,"onUpdate:modelValue":I[5]||(I[5]=j=>_.value=j),"max-width":"480"},{default:t(()=>[e(F,null,{default:t(()=>[e(B,null,{default:t(()=>[...I[12]||(I[12]=[n("Company löschen?",-1)])]),_:1}),e(G,null,{default:t(()=>{var j;return[n(v((j=u.value)==null?void 0:j.name)+" wird endgültig gelöscht. Companies mit verknüpften Leads können nicht gelöscht werden. ",1)]}),_:1}),e(W,null,{default:t(()=>[e(R),e(E,{variant:"text",onClick:I[4]||(I[4]=j=>_.value=!1)},{default:t(()=>[...I[13]||(I[13]=[n("Abbrechen",-1)])]),_:1}),e(E,{color:"error",variant:"flat",loading:k.value,onClick:w},{default:t(()=>[...I[14]||(I[14]=[n("Löschen",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]}),_:1})}}}),$6=Object.freeze(Object.defineProperty({__proto__:null,default:O_},Symbol.toStringTag,{value:"Module"})),R_=Zt("deliveryDashboard",()=>{const r=y(null),$=y([]),d=y(!1),c=y(null);let s=null;async function m(){d.value=!0,c.value=null;try{const _=await re.get("/email-stats/live-delivery");_.success&&_.data?(r.value=_.data,Array.isArray(_.data.feed)&&($.value=_.data.feed)):(c.value=_.error||"Fehler beim Laden der Zustellungs-Daten",ue.error("ADMIN","Live-Delivery konnte nicht geladen werden",_.error))}catch(_){c.value="Netzwerkfehler beim Laden der Zustellungs-Daten",ue.error("ADMIN","Live-Delivery Netzwerkfehler",_)}finally{d.value=!1}}function u(_=3e4){f(),s=setInterval(()=>{m()},_)}function f(){s&&(clearInterval(s),s=null)}function p(){r.value=null,$.value=[],d.value=!1,c.value=null,f()}return{sequenceStats:r,liveDeliveryFeed:$,loading:d,error:c,fetchSequenceStats:m,startPolling:u,stopPolling:f,$reset:p}}),K_={class:"email-sequence-list-view"},j_={class:"email-sequence-list-view__header"},q_={class:"d-flex align-center ga-2"},G_={class:"text-h6 font-weight-bold text-success"},H_={class:"text-h6 font-weight-bold text-primary"},W_={class:"text-h6 font-weight-bold text-primary"},Z_={class:"text-h6 font-weight-bold text-warning"},J_={class:"email-sequence-list-view__filter mb-4"},Q_={class:"d-flex align-center justify-space-between"},Y_={class:"text-subtitle-1 font-weight-semibold"},X_={class:"email-sequence-list-view__name"},ek={class:"text-body-2 font-weight-medium"},tk={key:0,class:"text-caption text-medium-emphasis d-block"},ak={class:"text-body-2 text-medium-emphasis"},lk={class:"text-body-2 text-medium-emphasis"},nk={class:"text-caption text-medium-emphasis"},ok={class:"text-body-2 text-medium-emphasis"},sk={class:"py-16 text-center"},ik={key:1,class:"d-flex justify-center pa-4"},rk=Ae({__name:"EmailSequenceListView",setup(r){const $=xt(),d=R_(),c=se(()=>{const z=d.sequenceStats;return(z==null?void 0:z.activeSequences)??0}),s=se(()=>{const z=d.sequenceStats;return(z==null?void 0:z.mailsToday)??0}),m=se(()=>{const z=d.sequenceStats,j=z==null?void 0:z.avgOpenRate;return j==null?"–":`${(j*100).toFixed(1)} %`}),u=se(()=>{const z=d.sequenceStats,j=z==null?void 0:z.avgMeetingRate;return j==null?"–":`${(j*100).toFixed(1)} %`}),f=se(()=>{const z=d.sequenceStats,j=(z==null?void 0:z.avgBounceRate)??0;return j<.02?"good":j<.05?"warn":"bad"}),p=se(()=>f.value==="good"?"success":f.value==="warn"?"warning":"error"),_=se(()=>f.value==="good"?"Gut":f.value==="warn"?"Erhöht":"Kritisch"),k=y([]),i=y({page:1,limit:20,total:0,totalPages:1}),g=y(!1),x=y(null),w=qe("email_seq_filter_status",""),b=qe("email_sequences_sort",[]),I=qe("email_sequences_per_page",20),V=qe("email_seq_only_mine",!1),E=[{title:"Name",key:"name",sortable:!0},{title:"Trigger",key:"trigger.type",sortable:!0},{title:"Status",key:"status",sortable:!0},{title:"Öffnungsrate",key:"stats.avgOpenRate",sortable:!0,align:"end"},{title:"Klickrate",key:"stats.avgClickRate",sortable:!0,align:"end"},{title:"Fortschritt",key:"progress",sortable:!1},{title:"Erstellt",key:"createdAt",sortable:!0},{title:"Erstellt von",key:"createdBy",sortable:!1,width:80,align:"center"},{title:"Geändert von",key:"updatedBy",sortable:!1,width:80,align:"center"}],R=[{label:"Alle",value:""},{label:"Aktiv",value:"active"},{label:"Entwurf",value:"draft"},{label:"Pausiert",value:"paused"},{label:"Archiviert",value:"archived"}];function M(z){return{"form-submit":"Formular","tag-added":"Tag","stage-changed":"Phase",manual:"Manuell","score-reached":"Score"}[z]||z}function T(z){return{"form-submit":"primary","tag-added":"info","stage-changed":"warning",manual:"default","score-reached":"success"}[z]||"default"}function D(z){return{active:"Aktiv",draft:"Entwurf",paused:"Pausiert",archived:"Archiviert"}[z]||z}function H(z){return{active:"success",draft:"default",paused:"warning",archived:"grey"}[z]||"default"}function O(z){return z==null?"–":`${(z*100).toFixed(1)} %`}function S(z){return z?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(new Date(z)):"–"}async function B(z=1){g.value=!0,x.value=null;const j=new URLSearchParams;if(j.set("page",String(z)),j.set("limit","20"),w.value&&j.set("status",w.value),V.value&&j.set("onlyMine","true"),b.value.length>0){const J=b.value[0];j.set("sortBy",J.key),j.set("sortOrder",J.order)}try{const J=await re.get(`/email-sequences?${j.toString()}`);J.success&&J.data?(k.value=J.data.items,i.value=J.data.pagination,ue.debug("ADMIN","E-Mail-Sequenzen geladen",{total:J.data.pagination.total})):(x.value=J.error||"Fehler beim Laden der E-Mail-Sequenzen",ue.error("ADMIN","E-Mail-Sequenzen Ladefehler",{error:J.error}))}catch{x.value="Netzwerkfehler beim Laden der E-Mail-Sequenzen",ue.error("ADMIN","Netzwerkfehler beim Laden der E-Mail-Sequenzen")}finally{g.value=!1}}Ze(w,()=>{B(1)}),Ze(b,()=>{B(1)},{deep:!0}),Ze(V,()=>{B(1)});function G(z){return z?typeof z=="object"?z._id:z:null}function W(z){return z&&typeof z=="object"?z:null}function F(z){return!z.lockedBy||!z.lockHeartbeatAt?!1:Date.now()-new Date(z.lockHeartbeatAt).getTime()<90*1e3}function L(z){$.push({name:"admin-email-sequence-editor",params:{id:z._id}})}function A(z,j){L(j.item)}return rt(()=>{B(),d.fetchSequenceStats(),d.startPolling()}),Ft(()=>{d.stopPolling()}),(z,j)=>{const J=l("v-chip"),Q=l("v-card-text"),te=l("v-card"),ve=l("v-col"),de=l("v-row"),Z=l("v-alert"),ce=l("v-chip-group"),oe=l("v-tooltip"),pe=l("v-icon"),_e=l("v-btn"),q=l("v-card-title"),C=l("v-progress-linear"),ae=l("v-data-table"),X=l("v-divider"),ie=l("v-pagination");return o(),h("div",K_,[a("div",j_,[j[8]||(j[8]=a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"E-Mail-Zustellung"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," Versandstatus und Monitoring aktiver E-Mail-Kampagnen ")],-1)),a("div",q_,[e(J,{color:P(V)?"primary":"",variant:P(V)?"flat":"outlined","prepend-icon":"mdi-account-filter",onClick:j[0]||(j[0]=fe=>V.value=!P(V))},{default:t(()=>[...j[7]||(j[7]=[n(" Nur meine ",-1)])]),_:1},8,["color","variant"])])]),e(de,{class:"mb-4",dense:""},{default:t(()=>[e(ve,{cols:"6",sm:"4",md:"2half"},{default:t(()=>[e(te,{variant:"tonal",rounded:"lg",class:"email-sequence-list-view__kpi-card"},{default:t(()=>[e(Q,{class:"pa-3 text-center"},{default:t(()=>[a("div",G_,v(c.value),1),j[9]||(j[9]=a("div",{class:"text-caption text-medium-emphasis"},"Aktive Sequenzen",-1))]),_:1})]),_:1})]),_:1}),e(ve,{cols:"6",sm:"4",md:"2half"},{default:t(()=>[e(te,{variant:"tonal",rounded:"lg",class:"email-sequence-list-view__kpi-card"},{default:t(()=>[e(Q,{class:"pa-3 text-center"},{default:t(()=>[a("div",H_,v(s.value),1),j[10]||(j[10]=a("div",{class:"text-caption text-medium-emphasis"},"Mails heute",-1))]),_:1})]),_:1})]),_:1}),e(ve,{cols:"6",sm:"4",md:"2half"},{default:t(()=>[e(te,{variant:"tonal",rounded:"lg",class:"email-sequence-list-view__kpi-card"},{default:t(()=>[e(Q,{class:"pa-3 text-center"},{default:t(()=>[a("div",W_,v(m.value),1),j[11]||(j[11]=a("div",{class:"text-caption text-medium-emphasis"},"Ø Öffnungsrate",-1))]),_:1})]),_:1})]),_:1}),e(ve,{cols:"6",sm:"4",md:"2half"},{default:t(()=>[e(te,{variant:"tonal",rounded:"lg",class:"email-sequence-list-view__kpi-card"},{default:t(()=>[e(Q,{class:"pa-3 text-center"},{default:t(()=>[a("div",Z_,v(u.value),1),j[12]||(j[12]=a("div",{class:"text-caption text-medium-emphasis"},"Ø Meeting-Rate",-1))]),_:1})]),_:1})]),_:1}),e(ve,{cols:"6",sm:"4",md:"2half"},{default:t(()=>[e(te,{variant:"tonal",rounded:"lg",class:"email-sequence-list-view__kpi-card"},{default:t(()=>[e(Q,{class:"pa-3 text-center"},{default:t(()=>[a("div",{class:ft(["text-h6 font-weight-bold",`text-${p.value}`])},v(_.value),3),j[13]||(j[13]=a("div",{class:"text-caption text-medium-emphasis"},"Bounce-Health",-1))]),_:1})]),_:1})]),_:1})]),_:1}),x.value?(o(),N(Z,{key:0,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":j[1]||(j[1]=fe=>x.value=null)},{default:t(()=>[n(v(x.value),1)]),_:1})):U("",!0),a("div",J_,[e(ce,{modelValue:P(w),"onUpdate:modelValue":j[2]||(j[2]=fe=>ot(w)?w.value=fe:null),mandatory:"","selected-class":"text-primary"},{default:t(()=>[(o(),h(be,null,Pe(R,fe=>e(J,{key:fe.value,value:fe.value,variant:"outlined",size:"small"},{default:t(()=>[n(v(fe.label),1)]),_:2},1032,["value"])),64))]),_:1},8,["modelValue"])]),e(te,{variant:"outlined",class:"email-sequence-list-view__table-card"},{default:t(()=>[e(q,{class:"pa-4 pb-2"},{default:t(()=>[a("div",Q_,[a("span",Y_,v(i.value.total)+" Sequenzen gesamt ",1),e(_e,{icon:"",variant:"text",size:"small",loading:g.value,"aria-label":"Aktualisieren",onClick:j[3]||(j[3]=fe=>B(i.value.page))},{default:t(()=>[e(oe,{activator:"parent",location:"bottom"},{default:t(()=>[...j[14]||(j[14]=[n("Aktualisieren",-1)])]),_:1}),e(pe,null,{default:t(()=>[...j[15]||(j[15]=[n("mdi-refresh",-1)])]),_:1})]),_:1},8,["loading"])])]),_:1}),e(ae,{headers:E,items:k.value,loading:g.value,"loading-text":"E-Mail-Sequenzen werden geladen...","no-data-text":"Keine E-Mail-Sequenzen gefunden","item-value":"_id",class:"email-sequence-list-view__table","items-per-page":P(I),"onUpdate:itemsPerPage":j[4]||(j[4]=fe=>ot(I)?I.value=fe:null),"sort-by":P(b),"onUpdate:sortBy":j[5]||(j[5]=fe=>b.value=fe),hover:"","onClick:row":A},{"item.name":t(({item:fe})=>[a("div",X_,[a("span",ek,v(fe.name),1),fe.description?(o(),h("span",tk,v(fe.description),1)):U("",!0)])]),"item.trigger.type":t(({item:fe})=>[e(J,{color:T(fe.trigger.type),size:"small",variant:"tonal"},{default:t(()=>[n(v(M(fe.trigger.type)),1)]),_:2},1032,["color"])]),"item.status":t(({item:fe})=>[e(J,{color:H(fe.status),size:"small",variant:"tonal"},{default:t(()=>[n(v(D(fe.status)),1)]),_:2},1032,["color"])]),"item.stats.avgOpenRate":t(({item:fe})=>[a("span",ak,v(O(fe.stats.avgOpenRate)),1)]),"item.stats.avgClickRate":t(({item:fe})=>[a("span",lk,v(O(fe.stats.avgClickRate)),1)]),"item.progress":t(({item:fe})=>{var Se,me,ee;return[a("div",nk,v(((Se=fe.stats)==null?void 0:Se.totalCompleted)||0)+" / "+v(((me=fe.stats)==null?void 0:me.totalEnrolled)||0),1),(ee=fe.stats)!=null&&ee.totalEnrolled?(o(),N(C,{key:0,"model-value":fe.stats.totalCompleted/fe.stats.totalEnrolled*100,color:"primary",height:"4",rounded:"",class:"mt-1"},null,8,["model-value"])):U("",!0)]}),"item.createdAt":t(({item:fe})=>[a("span",ok,v(S(fe.createdAt)),1)]),"item.createdBy":t(({item:fe})=>[e(gt,{"user-id":G(fe.createdBy),populated:W(fe.createdBy),locked:F(fe),"locked-by":W(fe.lockedBy)},null,8,["user-id","populated","locked","locked-by"])]),"item.updatedBy":t(({item:fe})=>[e(gt,{"user-id":G(fe.updatedBy),populated:W(fe.updatedBy),locked:F(fe),"locked-by":W(fe.lockedBy)},null,8,["user-id","populated","locked","locked-by"])]),"no-data":t(()=>[a("div",sk,[e(pe,{size:"64",color:"grey-darken-1",class:"mb-4"},{default:t(()=>[...j[16]||(j[16]=[n("mdi-email-outline",-1)])]),_:1}),j[17]||(j[17]=a("p",{class:"text-h6 text-medium-emphasis mb-2"},"Keine E-Mail-Sequenzen gefunden",-1)),j[18]||(j[18]=a("p",{class:"text-body-2 text-medium-emphasis"}," Es sind noch keine E-Mail-Sequenzen vorhanden. ",-1))])]),_:1},8,["items","loading","items-per-page","sort-by"]),i.value.totalPages>1?(o(),N(X,{key:0})):U("",!0),i.value.totalPages>1?(o(),h("div",ik,[e(ie,{"model-value":i.value.page,length:i.value.totalPages,"total-visible":7,"onUpdate:modelValue":j[6]||(j[6]=fe=>B(fe))},null,8,["model-value","length"])])):U("",!0)]),_:1})])}}}),dk=Me(rk,[["__scopeId","data-v-de363f99"]]),C6=Object.freeze(Object.defineProperty({__proto__:null,default:dk},Symbol.toStringTag,{value:"Module"})),uk={class:"email-sequence-editor"},ck={class:"email-sequence-editor__header"},mk={class:"d-flex align-center ga-3"},vk={class:"text-h5 font-weight-bold"},pk={key:0,class:"d-flex align-center ga-2 text-caption text-medium-emphasis mt-1 mb-1"},fk={key:1,class:"d-flex align-center ga-2 mt-1"},gk={class:"d-flex align-center ga-2"},bk={key:3,class:"d-flex justify-center py-16"},yk={class:"text-h5 font-weight-bold mb-1"},_k={class:"text-body-2 text-medium-emphasis mb-3"},kk={class:"d-flex align-center ga-3 flex-wrap"},hk={class:"d-flex align-center ga-2"},xk={class:"d-flex align-center ga-2"},wk={class:"text-body-2 font-weight-bold mr-3",style:{color:"#0AC9D4","min-width":"24px"}},Sk={class:"text-body-1 font-weight-bold text-white"},$k={class:"text-body-1 font-weight-bold text-white"},Ck={class:"text-body-1 font-weight-bold text-white"},Vk={class:"mb-3"},Ak={class:"d-flex justify-space-between text-caption mb-1"},Ik={class:"font-weight-medium"},Pk={class:"d-flex justify-space-between text-caption mb-1"},zk={class:"font-weight-medium"},Dk={class:"text-caption text-medium-emphasis"},Tk={class:"mb-1"},Lk={class:"d-flex flex-wrap ga-2"},Ek={key:0,class:"text-caption text-medium-emphasis pa-4"},Mk={class:"d-flex align-center justify-space-between mb-2"},Nk={class:"text-body-2 font-weight-semibold"},Uk={style:{color:"#0AC9D4"}},Bk={class:"text-caption text-medium-emphasis"},Fk={class:"text-caption mt-1"},Ok={class:"text-caption mt-1"},Rk=Ae({__name:"EmailSequenceEditorView",setup(r){const $=xt(),d=Ut(),c=se(()=>d.params.id),s=se(()=>c.value==="new"),m=se(()=>{const oe=d.params.id;return typeof oe=="string"&&oe!=="new"?oe:null}),{isLocked:u,isLockedByMe:f,lockedBy:p,lockedAt:_,isLockTakenOver:k,takenOverBy:i,takeOverLock:g}=sa("EmailSequence",m),x=se(()=>u.value&&!f.value||k.value),w=y(!0),b=y(null),I=y(!1),V=y(null),E=y(null),R=y("draft"),M=y(0),T=y([]),D=y(null),H=[{title:"Formular-Einreichung",value:"form-submit"},{title:"Tag hinzugefügt",value:"tag-added"},{title:"Phase geändert",value:"stage-changed"},{title:"Manuell",value:"manual"},{title:"Score erreicht",value:"score-reached"}],O=[{title:"Entwurf",value:"draft",color:"default"},{title:"Aktiv",value:"active",color:"success"},{title:"Pausiert",value:"paused",color:"warning"},{title:"Archiviert",value:"archived",color:"grey"}],S=se(()=>{var oe;return s.value?"Neue E-Mail-Sequenz":`Zustellung: ${((oe=E.value)==null?void 0:oe.name)??""}`}),B=se(()=>{var pe;return(((pe=E.value)==null?void 0:pe.steps)||[]).map((_e,q)=>{const C=T.value.filter(Se=>Se.stepIndex===q),ae=C.length,X=C.filter(Se=>Se.status!=="queued"&&Se.status!=="failed").length,ie=C.filter(Se=>!!Se.openedAt).length,fe=C.filter(Se=>!!Se.clickedAt).length;return{step:q+1,subject:_e.subject||`Schritt ${q+1}`,sent:ae,delivered:X,opened:ie,clicked:fe,openRate:X?Math.round(ie/X*100):0,clickRate:X?Math.round(fe/X*100):0}})});function G(oe){return{active:"success",draft:"default",paused:"warning",archived:"grey"}[oe]||"default"}function W(oe){var pe;return((pe=O.find(_e=>_e.value===oe))==null?void 0:pe.title)??oe}function F(){var pe,_e,q;const oe=(_e=(pe=E.value)==null?void 0:pe.trigger)==null?void 0:_e.type;return((q=H.find(C=>C.value===oe))==null?void 0:q.title)??(oe||"–")}function L(){var pe,_e;const oe=(_e=(pe=E.value)==null?void 0:pe.trigger)==null?void 0:_e.type;return oe==="manual"?"default":oe==="form-submit"?"primary":oe==="tag-added"?"info":oe==="stage-changed"?"warning":oe==="score-reached"?"success":"default"}function A(oe){return oe==null?"–":`${(oe*100).toFixed(1)} %`}function z(oe){return oe?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(new Date(oe)):"–"}function j(oe){return{queued:"default",sent:"info",delivered:"primary",opened:"success",clicked:"warning",bounced:"error",failed:"error"}[oe]||"default"}function J(oe){return{queued:"Warteschlange",sent:"Gesendet",delivered:"Zugestellt",opened:"Geöffnet",clicked:"Geklickt",bounced:"Zurückgewiesen",failed:"Fehlgeschlagen"}[oe]||oe}function Q(oe){return oe?typeof oe=="object"?oe._id:oe:null}function te(oe){return oe&&typeof oe=="object"?oe:null}async function ve(){if(s.value){w.value=!1;return}w.value=!0,b.value=null;try{const oe=await re.get(`/email-sequences/${c.value}`);oe.success&&oe.data?(E.value=oe.data,R.value=oe.data.status,ue.debug("ADMIN","Sequenz geladen",{id:c.value})):(b.value=oe.error||"Fehler beim Laden der Sequenz",ue.error("ADMIN","Sequenz-Ladefehler",{error:oe.error}))}catch{b.value="Netzwerkfehler beim Laden der Sequenz",ue.error("ADMIN","Netzwerkfehler beim Laden der Sequenz")}finally{w.value=!1}}async function de(){try{const oe=await re.get(`/email-logs?sequenceId=${d.params.id}`);if(oe.success&&oe.data){const pe=oe.data;T.value=Array.isArray(pe)?pe:pe.items||[]}}catch{}}async function Z(){try{const oe=await re.get("/email-campaigns");if(oe.success&&oe.data){const pe=Array.isArray(oe.data)?oe.data:[];D.value=pe.find(_e=>_e.sequenceId===d.params.id)||null}}catch{}}async function ce(oe){if(x.value){ue.warn("ADMIN","Status-Änderung blockiert - kein Lock-Owner");return}if(!s.value){I.value=!0,V.value=null;try{const pe=await re.patch(`/email-sequences/${c.value}/status`,{status:oe});pe.success&&pe.data?(E.value=pe.data,R.value=pe.data.status,ue.info("ADMIN","Sequenz-Status geändert",{id:c.value,status:oe})):V.value=pe.error||"Fehler beim Statuswechsel"}catch{V.value="Netzwerkfehler beim Statuswechsel"}finally{I.value=!1}}}return rt(async()=>{await ve(),de(),Z()}),(oe,pe)=>{const _e=l("v-tooltip"),q=l("v-icon"),C=l("v-btn"),ae=l("router-link"),X=l("v-chip"),ie=l("v-alert"),fe=l("v-progress-circular"),Se=l("v-tab"),me=l("v-tabs"),ee=l("v-card-title"),Y=l("v-divider"),K=l("v-card-text"),le=l("v-card"),ne=l("v-list-item-title"),Ce=l("v-list-item-subtitle"),ke=l("v-list-item"),xe=l("v-list"),Ne=l("v-col"),Ie=l("v-progress-linear"),Ue=l("v-row"),Te=l("v-data-table");return o(),h("div",uk,[a("div",ck,[a("div",mk,[e(C,{icon:"",variant:"text","aria-label":"Zurück zur Liste",onClick:pe[0]||(pe[0]=ye=>P($).push({name:"admin-email-sequences"}))},{default:t(()=>[e(_e,{activator:"parent",location:"bottom"},{default:t(()=>[...pe[4]||(pe[4]=[n("Zurück zur Liste",-1)])]),_:1}),e(q,null,{default:t(()=>[...pe[5]||(pe[5]=[n("mdi-arrow-left",-1)])]),_:1})]),_:1}),a("div",null,[a("h1",vk,v(S.value),1),E.value&&E.value._id?(o(),h("div",pk,[pe[6]||(pe[6]=a("span",null,"Erstellt:",-1)),e(gt,{"user-id":Q(E.value.createdBy),populated:te(E.value.createdBy),size:24},null,8,["user-id","populated"]),pe[7]||(pe[7]=a("span",{class:"mx-1"},"·",-1)),pe[8]||(pe[8]=a("span",null,"Geändert:",-1)),e(gt,{"user-id":Q(E.value.updatedBy),populated:te(E.value.updatedBy),size:24},null,8,["user-id","populated"])])):U("",!0),D.value?(o(),h("div",fk,[e(q,{size:"14",color:"primary"},{default:t(()=>[...pe[9]||(pe[9]=[n("mdi-link-variant",-1)])]),_:1}),e(ae,{to:`/admin/email-kampagnen/${D.value._id}`,class:"text-caption text-primary text-decoration-none"},{default:t(()=>[n(" Kampagne: "+v(D.value.name),1)]),_:1},8,["to"])])):U("",!0)])]),a("div",gk,[!s.value&&E.value?(o(),N(X,{key:0,color:G(R.value),variant:"tonal",size:"small"},{default:t(()=>[n(v(W(R.value)),1)]),_:1},8,["color"])):U("",!0)])]),e(ia,{"is-locked":P(u),"is-locked-by-me":P(f),"locked-by":P(p),"locked-at":P(_),"is-lock-taken-over":P(k),"taken-over-by":P(i),"on-take-over":P(g)},null,8,["is-locked","is-locked-by-me","locked-by","locked-at","is-lock-taken-over","taken-over-by","on-take-over"]),b.value?(o(),N(ie,{key:0,type:"error",variant:"tonal",class:"mb-6",text:b.value},null,8,["text"])):U("",!0),V.value?(o(),N(ie,{key:1,type:"error",variant:"tonal",class:"mb-4",closable:"",text:V.value,"onClick:close":pe[1]||(pe[1]=ye=>V.value=null)},null,8,["text"])):U("",!0),s.value?(o(),N(ie,{key:2,type:"info",variant:"tonal",class:"mb-6"},{append:t(()=>[e(C,{variant:"text",size:"small",onClick:pe[2]||(pe[2]=ye=>P($).push({name:"admin-email-sequences"}))},{default:t(()=>[...pe[10]||(pe[10]=[n(" Zur Liste ",-1)])]),_:1})]),default:t(()=>[pe[11]||(pe[11]=n(" Bitte erstelle zuerst eine neue Sequenz über die Sequenz-Liste. ",-1))]),_:1})):U("",!0),w.value?(o(),h("div",bk,[e(fe,{indeterminate:"",color:"primary",size:"48"})])):!s.value&&E.value?(o(),h(be,{key:4},[e(me,{modelValue:M.value,"onUpdate:modelValue":pe[3]||(pe[3]=ye=>M.value=ye),color:"primary",density:"compact",class:"mb-4"},{default:t(()=>[e(Se,{value:0},{default:t(()=>[...pe[12]||(pe[12]=[n("Übersicht",-1)])]),_:1}),e(Se,{value:1},{default:t(()=>[n("Leads ("+v(T.value.length)+")",1)]),_:1}),e(Se,{value:2},{default:t(()=>[...pe[13]||(pe[13]=[n("Tracking",-1)])]),_:1})]),_:1},8,["modelValue"]),M.value===0?(o(),N(Ue,{key:0},{default:t(()=>[e(Ne,{cols:"12",lg:"8"},{default:t(()=>[e(le,{variant:"outlined",class:"email-sequence-editor__card mb-4"},{default:t(()=>[e(ee,{class:"pa-4 pb-2 text-body-1 font-weight-semibold"},{default:t(()=>[...pe[14]||(pe[14]=[n("Metadaten",-1)])]),_:1}),e(Y),e(K,{class:"pa-4"},{default:t(()=>[a("h2",yk,v(E.value.name),1),a("p",_k,v(E.value.description||"Keine Beschreibung"),1),a("div",kk,[a("div",hk,[pe[15]||(pe[15]=a("span",{class:"text-caption text-medium-emphasis"},"Trigger:",-1)),e(X,{color:L(),size:"small"},{default:t(()=>[n(v(F()),1)]),_:1},8,["color"])]),a("div",xk,[pe[16]||(pe[16]=a("span",{class:"text-caption text-medium-emphasis"},"Status:",-1)),e(X,{color:G(R.value),size:"small",variant:"tonal"},{default:t(()=>[n(v(W(R.value)),1)]),_:1},8,["color"])])])]),_:1})]),_:1}),e(le,{variant:"outlined",class:"email-sequence-editor__card mb-4"},{default:t(()=>[e(ee,{class:"text-subtitle-1 font-weight-semibold pa-4 d-flex align-center justify-space-between"},{default:t(()=>{var ye,Je;return[a("span",null,"E-Mail-Schritte ("+v(((Je=(ye=E.value)==null?void 0:ye.steps)==null?void 0:Je.length)||0)+")",1)]}),_:1}),e(Y),e(xe,{density:"compact",class:"bg-transparent"},{default:t(()=>{var ye,Je,Ke;return[(o(!0),h(be,null,Pe(((ye=E.value)==null?void 0:ye.steps)||[],($e,Ee)=>(o(),N(ke,{key:Ee},{prepend:t(()=>[a("div",wk,v(Ee+1),1)]),default:t(()=>[e(ne,{class:"text-body-2"},{default:t(()=>[n(v($e.subject||"Kein Betreff"),1)]),_:2},1024),e(Ce,{class:"text-caption"},{default:t(()=>[n(v($e.delayDays===0?"Sofort":`Nach ${$e.delayDays} Tag${$e.delayDays!==1?"en":""}`),1)]),_:2},1024)]),_:2},1024))),128)),(Ke=(Je=E.value)==null?void 0:Je.steps)!=null&&Ke.length?U("",!0):(o(),N(ke,{key:0},{default:t(()=>[e(ne,{class:"text-caption text-medium-emphasis"},{default:t(()=>[...pe[17]||(pe[17]=[n(" Keine Schritte vorhanden ",-1)])]),_:1})]),_:1}))]}),_:1})]),_:1})]),_:1}),e(Ne,{cols:"12",lg:"4"},{default:t(()=>[e(le,{variant:"outlined",class:"email-sequence-editor__card"},{default:t(()=>[e(ee,{class:"pa-4 pb-2 text-body-1 font-weight-semibold"},{default:t(()=>[...pe[18]||(pe[18]=[n("Statistiken",-1)])]),_:1}),e(Y),e(K,{class:"pa-4"},{default:t(()=>[e(xe,{density:"compact"},{default:t(()=>[e(ke,{"prepend-icon":"mdi-account-multiple-outline"},{title:t(()=>[...pe[19]||(pe[19]=[n("Eingeschrieben",-1)])]),subtitle:t(()=>[a("span",Sk,v(E.value.stats.totalEnrolled??0),1)]),_:1}),e(ke,{"prepend-icon":"mdi-check-circle-outline"},{title:t(()=>[...pe[20]||(pe[20]=[n("Abgeschlossen",-1)])]),subtitle:t(()=>[a("span",$k,v(E.value.stats.totalCompleted??0),1)]),_:1}),e(ke,{"prepend-icon":"mdi-email-off-outline"},{title:t(()=>[...pe[21]||(pe[21]=[n("Abgemeldet",-1)])]),subtitle:t(()=>[a("span",Ck,v(E.value.stats.totalUnsubscribed??0),1)]),_:1})]),_:1}),e(Y,{class:"my-3"}),a("div",Vk,[a("div",Ak,[pe[22]||(pe[22]=a("span",null,"Ø Öffnungsrate",-1)),a("span",Ik,v(A(E.value.stats.avgOpenRate)),1)]),e(Ie,{"model-value":(E.value.stats.avgOpenRate??0)*100,color:"primary",rounded:"",height:"6"},null,8,["model-value"])]),a("div",null,[a("div",Pk,[pe[23]||(pe[23]=a("span",null,"Ø Klickrate",-1)),a("span",zk,v(A(E.value.stats.avgClickRate)),1)]),e(Ie,{"model-value":(E.value.stats.avgClickRate??0)*100,color:"info",rounded:"",height:"6"},null,8,["model-value"])]),e(Y,{class:"my-3"}),a("div",Dk,[a("div",Tk,"Erstellt: "+v(z(E.value.createdAt)),1),a("div",null,"Geändert: "+v(z(E.value.updatedAt)),1)]),e(Y,{class:"my-3"}),pe[24]||(pe[24]=a("div",{class:"text-caption text-medium-emphasis mb-2"},"Status ändern:",-1)),a("div",Lk,[(o(),h(be,null,Pe(O,ye=>e(C,{key:ye.value,color:ye.color,variant:R.value===ye.value?"flat":"outlined",size:"x-small",disabled:I.value||x.value,onClick:Je=>ce(ye.value)},{default:t(()=>[n(v(ye.title),1)]),_:2},1032,["color","variant","disabled","onClick"])),64))])]),_:1})]),_:1})]),_:1})]),_:1})):U("",!0),M.value===1?(o(),N(le,{key:1,variant:"outlined",class:"email-sequence-editor__card"},{default:t(()=>[e(ee,{class:"pa-4 pb-2 text-body-1 font-weight-semibold"},{default:t(()=>[...pe[25]||(pe[25]=[n("Eingeschriebene Leads",-1)])]),_:1}),e(Y),e(Te,{headers:[{title:"Empfänger",key:"to"},{title:"Schritt",key:"stepIndex"},{title:"Status",key:"status"},{title:"Gesendet",key:"sentAt"}],items:T.value,density:"compact",class:"bg-transparent"},{"item.stepIndex":t(({item:ye})=>{var Je,Ke;return[n(v((ye.stepIndex||0)+1)+" / "+v(((Ke=(Je=E.value)==null?void 0:Je.steps)==null?void 0:Ke.length)||"?"),1)]}),"item.status":t(({item:ye})=>[e(X,{color:j(ye.status),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(J(ye.status)),1)]),_:2},1032,["color"])]),"item.sentAt":t(({item:ye})=>[n(v(ye.sentAt?z(ye.sentAt):"-"),1)]),"no-data":t(()=>[...pe[26]||(pe[26]=[a("div",{class:"text-caption text-medium-emphasis pa-4 text-center"}," Keine Leads eingeschrieben ",-1)])]),_:1},8,["items"])]),_:1})):U("",!0),M.value===2?(o(),h(be,{key:2},[B.value.length===0?(o(),h("div",Ek," Keine Schritte vorhanden ")):U("",!0),(o(!0),h(be,null,Pe(B.value,ye=>(o(),N(le,{key:ye.step,variant:"outlined",class:"email-sequence-editor__card mb-3 pa-4"},{default:t(()=>[a("div",Mk,[a("div",Nk,[a("span",Uk,v(ye.step)+".",1),n(" "+v(ye.subject),1)]),a("div",Bk,v(ye.sent)+" gesendet",1)]),e(Ue,{dense:""},{default:t(()=>[e(Ne,{cols:"6"},{default:t(()=>[pe[27]||(pe[27]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Öffnungsrate",-1)),e(Ie,{"model-value":ye.openRate,color:"success",height:"6",rounded:""},null,8,["model-value"]),a("div",Fk,v(ye.openRate)+"% ("+v(ye.opened)+"/"+v(ye.delivered)+")",1)]),_:2},1024),e(Ne,{cols:"6"},{default:t(()=>[pe[28]||(pe[28]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Klickrate",-1)),e(Ie,{"model-value":ye.clickRate,color:"warning",height:"6",rounded:""},null,8,["model-value"]),a("div",Ok,v(ye.clickRate)+"% ("+v(ye.clicked)+"/"+v(ye.delivered)+")",1)]),_:2},1024)]),_:2},1024)]),_:2},1024))),128))],64)):U("",!0)],64)):U("",!0)])}}}),Kk=Me(Rk,[["__scopeId","data-v-c938e834"]]),V6=Object.freeze(Object.defineProperty({__proto__:null,default:Kk},Symbol.toStringTag,{value:"Module"})),jk={class:"email-campaign-calendar"},qk={class:"email-campaign-calendar__controls mb-4"},Gk={class:"d-flex align-center ga-2"},Hk={class:"text-subtitle-1 font-weight-semibold",style:{"min-width":"160px","text-align":"center"}},Wk={class:"d-flex align-center ga-3"},Zk={key:1,class:"d-flex justify-center pa-8"},Jk={key:2,class:"email-campaign-calendar__grid-wrapper"},Qk={class:"email-campaign-calendar__weekdays"},Yk={class:"email-campaign-calendar__days"},Xk={class:"email-campaign-calendar__day-number"},eh={class:"email-campaign-calendar__day-entries"},th=["title"],ah={key:0,class:"email-campaign-calendar__entry-more"},lh=Ae({__name:"EmailCampaignCalendar",setup(r){const $=y([]),d=y(!1),c=y(null),s=y(""),m=y(new Date),u=se(()=>[{title:"Alle Kampagnen",value:""},...$.value.map(M=>({title:M.name,value:M._id}))]),f=se(()=>m.value.getFullYear()),p=se(()=>m.value.getMonth()),_=se(()=>new Intl.DateTimeFormat("de-DE",{month:"long",year:"numeric"}).format(m.value)),k=["Mo","Di","Mi","Do","Fr","Sa","So"];function i(M){const T=M.toISOString().substring(0,10),D=[];for(const H of $.value)if(!(s.value&&H._id!==s.value))for(const O of H.ideas||[])O.suggestedDate===T&&D.push({campaignId:H._id,campaignName:H.name,title:O.title,status:O.status});return D}const g=se(()=>{const M=f.value,T=p.value,D=new Date(M,T,1),H=new Date(M,T+1,0);let O=D.getDay();O=O===0?6:O-1;const S=[];for(let G=O-1;G>=0;G--){const W=new Date(M,T,-G);S.push({date:W,isCurrentMonth:!1,entries:[]})}for(let G=1;G<=H.getDate();G++){const W=new Date(M,T,G);S.push({date:W,isCurrentMonth:!0,entries:i(W)})}const B=42-S.length;for(let G=1;G<=B;G++){const W=new Date(M,T+1,G);S.push({date:W,isCurrentMonth:!1,entries:[]})}return S});function x(){m.value=new Date(f.value,p.value-1,1)}function w(){m.value=new Date(f.value,p.value+1,1)}function b(){m.value=new Date}function I(M){const T=new Date;return M.getDate()===T.getDate()&&M.getMonth()===T.getMonth()&&M.getFullYear()===T.getFullYear()}function V(M){return{suggested:"#748686",accepted:"#0AC9D4",generating:"#C9A063",drafted:"#66BB6A",sent:"#66BB6A",skipped:"#CF6679"}[M.status]||"#748686"}function E(M,T=28){return M?M.length>T?M.substring(0,T)+"…":M:""}async function R(){d.value=!0,c.value=null;try{const M=await re.get("/email-campaigns");M.success&&M.data?$.value=M.data:c.value=M.error||"Fehler beim Laden der Email-Kampagnen"}catch{c.value="Netzwerkfehler beim Laden der Kalender-Daten"}finally{d.value=!1}}return rt(()=>{R()}),(M,T)=>{const D=l("v-tooltip"),H=l("v-icon"),O=l("v-btn"),S=l("v-select"),B=l("v-alert"),G=l("v-progress-circular");return o(),h("div",jk,[a("div",qk,[a("div",Gk,[e(O,{icon:"",variant:"text",size:"small","aria-label":"Vorheriger Monat",onClick:x},{default:t(()=>[e(D,{activator:"parent",location:"bottom"},{default:t(()=>[...T[2]||(T[2]=[n("Vorheriger Monat",-1)])]),_:1}),e(H,null,{default:t(()=>[...T[3]||(T[3]=[n("mdi-chevron-left",-1)])]),_:1})]),_:1}),a("span",Hk,v(_.value),1),e(O,{icon:"",variant:"text",size:"small","aria-label":"Nächster Monat",onClick:w},{default:t(()=>[e(D,{activator:"parent",location:"bottom"},{default:t(()=>[...T[4]||(T[4]=[n("Nächster Monat",-1)])]),_:1}),e(H,null,{default:t(()=>[...T[5]||(T[5]=[n("mdi-chevron-right",-1)])]),_:1})]),_:1}),e(O,{variant:"outlined",size:"small",onClick:b},{default:t(()=>[...T[6]||(T[6]=[n("Heute",-1)])]),_:1})]),a("div",Wk,[e(S,{modelValue:s.value,"onUpdate:modelValue":T[0]||(T[0]=W=>s.value=W),items:u.value,label:"Kampagne",variant:"outlined",density:"compact","hide-details":"",style:{"min-width":"200px"}},null,8,["modelValue","items"]),T[7]||(T[7]=_a('<div class="d-flex align-center ga-3 text-caption text-medium-emphasis" data-v-928cadb3><span class="d-flex align-center ga-1" data-v-928cadb3><span class="email-campaign-calendar__legend-dot" style="background:#748686;" data-v-928cadb3></span> Vorgeschlagen </span><span class="d-flex align-center ga-1" data-v-928cadb3><span class="email-campaign-calendar__legend-dot" style="background:#0AC9D4;" data-v-928cadb3></span> Akzeptiert </span><span class="d-flex align-center ga-1" data-v-928cadb3><span class="email-campaign-calendar__legend-dot" style="background:#66BB6A;" data-v-928cadb3></span> Entwurf </span><span class="d-flex align-center ga-1" data-v-928cadb3><span class="email-campaign-calendar__legend-dot" style="background:#CF6679;" data-v-928cadb3></span> Übersprungen </span></div>',1))])]),c.value?(o(),N(B,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":T[1]||(T[1]=W=>c.value=null)},{default:t(()=>[n(v(c.value),1)]),_:1})):U("",!0),d.value?(o(),h("div",Zk,[e(G,{indeterminate:"",color:"primary"})])):(o(),h("div",Jk,[a("div",Qk,[(o(),h(be,null,Pe(k,W=>a("div",{key:W,class:"email-campaign-calendar__weekday"},v(W),1)),64))]),a("div",Yk,[(o(!0),h(be,null,Pe(g.value,(W,F)=>(o(),h("div",{key:F,class:ft(["email-campaign-calendar__day",{"email-campaign-calendar__day--other-month":!W.isCurrentMonth,"email-campaign-calendar__day--today":I(W.date)}])},[a("div",Xk,v(W.date.getDate()),1),a("div",eh,[(o(!0),h(be,null,Pe(W.entries.slice(0,3),(L,A)=>(o(),h("div",{key:A,class:"email-campaign-calendar__entry-chip",style:ht({borderLeftColor:V(L)}),title:L.title},v(E(L.title)),13,th))),128)),W.entries.length>3?(o(),h("div",ah," +"+v(W.entries.length-3)+" weitere ",1)):U("",!0)])],2))),128))])]))])}}}),nh=Me(lh,[["__scopeId","data-v-928cadb3"]]),pa=[{key:"tags",label:"Tags",type:"array",operators:["in","not_in"]},{key:"pipeline.stage",label:"Pipeline-Stage",type:"enum",operators:["in","not_in"],options:["neu","kontaktiert","qualifiziert","angebot","verhandlung","gewonnen","verloren"]},{key:"scoring.total",label:"Score (Gesamt)",type:"number",operators:["gt","gte","lt","lte","eq"]},{key:"scoring.engagement",label:"Score (Engagement)",type:"number",operators:["gt","gte","lt","lte","eq"]},{key:"scoring.profile",label:"Score (Profil)",type:"number",operators:["gt","gte","lt","lte","eq"]},{key:"engagementState",label:"Engagement-Status",type:"enum",operators:["in","not_in"],options:["hot","warm","cold","stuck","single-converter","multi-converter","power-lead","bounced","unsubscribed","awaiting-next-step","active"]},{key:"deliverability.status",label:"Zustellbarkeit",type:"enum",operators:["in","not_in"],options:["deliverable","undeliverable","soft-bouncing"]},{key:"source.type",label:"Quelle (Typ)",type:"enum",operators:["in","not_in"],options:["website-formular","hubspot","manuell","newsletter","social-media","empfehlung","outreach"]},{key:"source.page",label:"Quelle (Seite)",type:"string",operators:["eq","contains"]},{key:"source.utm.campaign",label:"UTM Campaign",type:"string",operators:["eq","contains","in","not_in","exists"]},{key:"source.utm.source",label:"UTM Source",type:"string",operators:["eq","contains","in","not_in","exists"]},{key:"source.utm.medium",label:"UTM Medium",type:"string",operators:["eq","contains","in","not_in","exists"]},{key:"interactions.type",label:"Interaktion (Typ)",type:"enum",operators:["in","not_in"],options:["email-open","email-click","page-visit","form-submit","download","meeting","email-sent","email-bounced"]},{key:"interactions.metadata.presetSlug",label:"Formular/Download (Preset-Slug)",type:"string",operators:["eq","contains","in","not_in","exists"]},{key:"consentMarketing.givenAt",label:"Marketing-Einwilligung",type:"boolean",operators:["exists"]},{key:"company",label:"Firma",type:"string",operators:["eq","contains","exists"]},{key:"position",label:"Position",type:"string",operators:["eq","contains","exists"]}],Fa={in:"enthält",not_in:"enthält nicht",eq:"ist gleich",gt:"größer als",gte:"größer oder gleich",lt:"kleiner als",lte:"kleiner oder gleich",contains:"enthält Text",exists:"ist vorhanden"},oh={class:"segment-picker"},sh={class:"d-flex align-start justify-space-between mb-2"},ih={class:"text-body-2 font-weight-medium"},rh={key:0,class:"text-caption text-medium-emphasis mt-1"},dh={class:"text-right"},uh={class:"text-h5 font-weight-bold",style:{color:"rgb(var(--v-theme-primary))"}},ch={class:"d-flex flex-wrap ga-1 mt-2"},mh={key:0,class:"text-caption text-medium-emphasis d-flex align-center px-1"},vh={key:0,class:"text-caption text-medium-emphasis d-flex align-center px-1"},ph=Ae({__name:"SegmentPicker",props:{modelValue:{},rules:{}},emits:["update:modelValue"],setup(r,{emit:$}){const d=r,c=$,s=y([]),m=y(!1),u=y(null),f=se(()=>s.value.map(x=>({title:`${x.name}${x.estimatedSize?` (ca. ${x.estimatedSize} Leads)`:""}`,value:x._id}))),p=se(()=>d.modelValue?s.value.find(x=>x._id===d.modelValue)??null:null);function _(x){var w;return((w=pa.find(b=>b.key===x))==null?void 0:w.label)??x}function k(x){return Fa[x]??x}function i(x){return x==="tags"?"primary":x==="pipeline.stage"?"#C9A063":""}async function g(){m.value=!0,u.value=null;try{const x=await re.get("/admin/segments");x.success&&x.data?s.value=x.data.filter(w=>w.isActive):u.value=x.error||"Fehler beim Laden der Segmente"}catch{u.value="Netzwerkfehler beim Laden der Segmente"}finally{m.value=!1}}return rt(()=>{g()}),(x,w)=>{const b=l("v-alert"),I=l("v-select"),V=l("v-chip"),E=l("v-card-text"),R=l("v-card");return o(),h("div",oh,[u.value?(o(),N(b,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-3"},{default:t(()=>[n(v(u.value),1)]),_:1})):U("",!0),e(I,{"model-value":r.modelValue,items:f.value,label:"Segment auswählen",variant:"outlined",density:"comfortable",loading:m.value,rules:r.rules,clearable:"",hint:"Leads werden beim Versand dynamisch nach den Segment-Filtern ermittelt","persistent-hint":"","onUpdate:modelValue":w[0]||(w[0]=M=>c("update:modelValue",M))},null,8,["model-value","items","loading","rules"]),p.value?(o(),N(R,{key:1,variant:"outlined",class:"segment-picker__preview mt-3"},{default:t(()=>[e(E,{class:"pa-4"},{default:t(()=>[a("div",sh,[a("div",null,[a("div",ih,v(p.value.name),1),p.value.description?(o(),h("div",rh,v(p.value.description),1)):U("",!0)]),a("div",dh,[a("div",uh,v(p.value.estimatedSize),1),w[1]||(w[1]=a("div",{class:"text-caption text-medium-emphasis"},"Leads",-1))])]),a("div",ch,[(o(!0),h(be,null,Pe(p.value.filterGroups,(M,T)=>(o(),h(be,{key:T},[T>0?(o(),h("span",mh,"UND")):U("",!0),(o(!0),h(be,null,Pe(M.conditions,(D,H)=>(o(),h(be,{key:`${T}-${H}`},[H>0?(o(),h("span",vh,"ODER")):U("",!0),e(V,{size:"x-small",color:i(D.field),variant:"tonal"},{default:t(()=>[n(v(_(D.field))+" "+v(k(D.operator))+" ",1),D.operator!=="exists"?(o(),h(be,{key:0},[n(v(Array.isArray(D.value)?D.value.join(", "):String(D.value??"")),1)],64)):U("",!0)]),_:2},1032,["color"])],64))),128))],64))),128))])]),_:1})]),_:1})):U("",!0),e(b,{type:"info",variant:"tonal",density:"compact",class:"mt-3",icon:"mdi-information-outline"},{default:t(()=>[...w[2]||(w[2]=[a("span",{style:{color:"#C9A063"}},"Hinweis:",-1),n(" Die Empfängeranzahl wird beim Aktivieren der Kampagne live ermittelt und kann sich bis dahin ändern. ",-1)])]),_:1})])}}}),Sl=Me(ph,[["__scopeId","data-v-b3f80a9d"]]),fh={class:"email-campaign-list-view"},gh={class:"email-campaign-list-view__header"},bh={class:"d-flex align-center ga-2"},yh={class:"email-campaign-list-view__filter mb-6"},_h={key:0,class:"d-flex justify-center pa-12"},kh={class:"d-flex align-start justify-space-between gap-2 mb-3"},hh={class:"text-body-1 font-weight-semibold email-campaign-list-view__plan-name"},xh={class:"d-flex align-center ga-1 text-body-2 text-medium-emphasis mb-2"},wh={key:0},Sh={key:1},$h={class:"d-flex align-center ga-2 mb-4"},Ch={class:"d-flex align-center justify-space-between mb-3"},Vh={class:"text-caption text-medium-emphasis"},Ah={class:"text-body-2 font-weight-medium text-white"},Ih={class:"text-body-2 font-weight-medium text-primary"},Ph={class:"text-body-2 font-weight-medium",style:{color:"#C9A063"}},zh={class:"text-body-2 font-weight-medium text-success"},Dh={key:0,class:"d-flex align-center ga-3 mb-3 pa-2 rounded",style:{"background-color":"rgba(255,255,255,0.03)"}},Th={class:"text-caption text-medium-emphasis d-flex align-center ga-1"},Lh={class:"text-body-2 font-weight-medium text-white"},Eh={class:"text-caption text-medium-emphasis d-flex align-center ga-1"},Mh={class:"text-body-2 font-weight-medium text-primary"},Nh={class:"text-caption text-medium-emphasis d-flex align-center ga-1"},Uh={class:"text-body-2 font-weight-medium",style:{color:"#C9A063"}},Bh={key:1,class:"mb-2"},Fh={class:"d-flex align-center justify-space-between mb-1"},Oh={class:"d-flex align-center ga-2 mt-3 pt-2",style:{"border-top":"1px solid rgba(255,255,255,0.06)"}},Rh={class:"d-flex align-center justify-space-between"},Kh=Ae({__name:"EmailCampaignListView",setup(r){const $=[{key:"elaboration",label:"E-Mail-Generierung",defaults:{temperature:.8,maxTokens:8192}},{key:"chat",label:"Chat / Verfeinerung",defaults:{temperature:.7,maxTokens:4096}}],d=xt(),c=y([]),s=y([]),m=y(!1),u=y(null),f=qe("email_campaign_view_mode","list"),p=qe("email_campaign_filter_status",""),_=qe("email_campaign_only_mine",!1),k=y(!1),i=y(!1),g=y(null),x=y(!1),w=wt({name:"",campaignType:"scheduled",startDate:"",endDate:"",frequency:"",audienceType:"",segmentId:null,gptSettingsId:""}),b=[{title:"Newsletter / Zeitraum",value:"scheduled"},{title:"Evergreen / Drip",value:"evergreen"}],I=[{title:"Alle",value:""},{title:"Entwurf",value:"draft"},{title:"Elaboration",value:"elaboration"},{title:"Aktiv",value:"active"},{title:"Sendet",value:"sending"},{title:"Pausiert",value:"paused"},{title:"Abgeschlossen",value:"completed"},{title:"Archiviert",value:"archived"}],V=[{title:"Jeden Tag",value:"daily"},{title:"Alle 2-3 Tage",value:"every-2-3-days"},{title:"2x pro Woche",value:"2x-weekly"},{title:"Wöchentlich",value:"weekly"},{title:"Alle 2 Wochen",value:"biweekly"},{title:"Monatlich",value:"monthly"}],E=[{title:"Alle Leads",value:"all-leads"},{title:"Nach Tag",value:"tag"},{title:"Nach Stage",value:"stage"},{title:"Segment",value:"segment"}],R=se(()=>p.value?c.value.filter(q=>q.status===p.value):c.value),M=se(()=>s.value.map(q=>({title:`${q.name} (${q.provider})`,value:q._id}))),T=[q=>!!q||"Name ist erforderlich",q=>q.length>=3||"Mindestens 3 Zeichen"],D=[q=>!!q||"Startdatum ist erforderlich"],H=[q=>w.campaignType==="evergreen"||!!q||"Enddatum ist erforderlich"],O=[q=>!!q||"Frequenz ist erforderlich"],S=[q=>!!q||"Zielgruppe ist erforderlich"];function B(q){return{draft:"default",elaboration:"info",active:"primary",sending:"warning",paused:"secondary",completed:"success",archived:"default"}[q]||"default"}function G(q){return{draft:"Entwurf",elaboration:"Elaboration",active:"Aktiv",sending:"Sendet",paused:"Pausiert",completed:"Abgeschlossen",archived:"Archiviert"}[q]||q}function W(q){return{daily:"Jeden Tag","every-2-3-days":"Alle 2-3 Tage","2x-weekly":"2x pro Woche",weekly:"Wöchentlich",biweekly:"Alle 2 Wochen",monthly:"Monatlich"}[q]||q}function F(q){var ae,X;return{"all-leads":"Alle Leads",tag:"Nach Tag",stage:"Nach Stage",segment:"Segment"}[(ae=q.audience)==null?void 0:ae.type]||((X=q.audience)==null?void 0:X.type)||"-"}function L(q){return{idle:"default",running:"primary",completed:"success",failed:"error"}[q]||"default"}function A(q){return q?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(new Date(q)):"-"}function z(q){return(q.ideas||[]).filter(C=>C.status!=="suggested"&&C.status!=="skipped").length}function j(q){return(q.ideas||[]).filter(C=>C.status==="approved").length}function J(q){return(q.ideas||[]).filter(C=>C.status==="drafted").length}async function Q(){m.value=!0,u.value=null;try{const q=new URLSearchParams;_.value&&q.set("onlyMine","true");const C=q.toString()?`?${q.toString()}`:"",ae=await re.get(`/email-campaigns${C}`);ae.success&&ae.data?(c.value=ae.data,ue.debug("ADMIN","Email-Kampagnen geladen",{count:ae.data.length,onlyMine:_.value})):(u.value=ae.error||"Fehler beim Laden der Email-Kampagnen",ue.error("ADMIN","Email-Kampagnen Ladefehler",{error:ae.error}))}catch{u.value="Netzwerkfehler beim Laden der Email-Kampagnen",ue.error("ADMIN","Netzwerkfehler beim Laden der Email-Kampagnen")}finally{m.value=!1}}async function te(){try{const q=await re.get("/gpt-settings");if(q.success&&q.data){const C=q.data,ae=Array.isArray(C)?C:C.items??[];s.value=ae.filter(X=>X.isActive!==!1)}}catch{}}function ve(){var q;Object.assign(w,{name:"",campaignType:"scheduled",startDate:new Date().toISOString().substring(0,10),endDate:"",frequency:"weekly",audienceType:"all-leads",segmentId:null,gptSettingsId:((q=s.value[0])==null?void 0:q._id)||""}),g.value=null,k.value=!0}function de(){k.value=!1}async function Z(){if(!x.value)return;i.value=!0,g.value=null;const q={startDate:w.startDate};w.endDate&&(q.endDate=w.endDate);const C={name:w.name,campaignType:w.campaignType,period:q,frequency:w.frequency,audience:{type:w.audienceType,config:w.audienceType==="segment"&&w.segmentId?{segmentId:w.segmentId}:{}},gptSettingsId:w.gptSettingsId||void 0};try{const ae=await re.post("/email-campaigns",C);ae.success&&ae.data?(de(),d.push({name:"admin-email-campaign-detail",params:{id:ae.data._id}})):g.value=ae.error||"Fehler beim Erstellen der Kampagne"}catch{g.value="Netzwerkfehler beim Erstellen"}finally{i.value=!1}}function ce(q){return q?typeof q=="object"?q._id:q:null}function oe(q){return q&&typeof q=="object"?q:null}function pe(q){return!q.lockedBy||!q.lockHeartbeatAt?!1:Date.now()-new Date(q.lockHeartbeatAt).getTime()<90*1e3}Ze(_,()=>{Q()});function _e(q){d.push({name:"admin-email-campaign-detail",params:{id:q._id}})}return rt(()=>{Q(),te()}),(q,C)=>{const ae=l("v-chip"),X=l("v-tooltip"),ie=l("v-icon"),fe=l("v-btn"),Se=l("v-btn-toggle"),me=l("v-alert"),ee=l("v-chip-group"),Y=l("v-progress-circular"),K=l("v-card-text"),le=l("v-card"),ne=l("v-progress-linear"),Ce=l("v-col"),ke=l("v-row"),xe=l("v-card-title"),Ne=l("v-divider"),Ie=l("v-text-field"),Ue=l("v-select"),Te=l("v-form"),ye=l("v-spacer"),Je=l("v-card-actions"),Ke=l("v-dialog");return o(),h("div",fh,[a("div",gh,[C[21]||(C[21]=a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"Email-Kampagnen"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," KI-gestützte Email-Kampagnen für gezielte Lead-Kommunikation ")],-1)),a("div",bh,[e(ae,{color:P(_)?"primary":"",variant:P(_)?"flat":"outlined","prepend-icon":"mdi-account-filter",class:"mr-2",onClick:C[0]||(C[0]=$e=>_.value=!P(_))},{default:t(()=>[...C[15]||(C[15]=[n(" Nur meine ",-1)])]),_:1},8,["color","variant"]),e(ta,{"page-key":"email-campaign","page-label":"Email-Kampagnen KI-Einstellungen",usecases:$}),e(Se,{modelValue:P(f),"onUpdate:modelValue":C[1]||(C[1]=$e=>ot(f)?f.value=$e:null),variant:"outlined",density:"compact",mandatory:"",color:"primary"},{default:t(()=>[e(fe,{value:"list",icon:"","aria-label":"Listenansicht"},{default:t(()=>[e(X,{activator:"parent",location:"bottom"},{default:t(()=>[...C[16]||(C[16]=[n("Listenansicht",-1)])]),_:1}),e(ie,{size:"18"},{default:t(()=>[...C[17]||(C[17]=[n("mdi-view-list",-1)])]),_:1})]),_:1}),e(fe,{value:"calendar",icon:"","aria-label":"Kalenderansicht"},{default:t(()=>[e(X,{activator:"parent",location:"bottom"},{default:t(()=>[...C[18]||(C[18]=[n("Kalenderansicht",-1)])]),_:1}),e(ie,{size:"18"},{default:t(()=>[...C[19]||(C[19]=[n("mdi-calendar-month",-1)])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(fe,{color:"primary","prepend-icon":"mdi-plus",onClick:ve},{default:t(()=>[...C[20]||(C[20]=[n(" Neue Kampagne ",-1)])]),_:1})])]),u.value?(o(),N(me,{key:0,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":C[2]||(C[2]=$e=>u.value=null)},{default:t(()=>[n(v(u.value),1)]),_:1})):U("",!0),a("div",yh,[e(ee,{modelValue:P(p),"onUpdate:modelValue":C[3]||(C[3]=$e=>ot(p)?p.value=$e:null),color:"primary","selected-class":"email-campaign-list-view__chip--active"},{default:t(()=>[(o(),h(be,null,Pe(I,$e=>e(ae,{key:$e.value,value:$e.value,variant:"outlined",filter:""},{default:t(()=>[n(v($e.title),1)]),_:2},1032,["value"])),64))]),_:1},8,["modelValue"])]),P(f)==="list"?(o(),h(be,{key:1},[m.value?(o(),h("div",_h,[e(Y,{indeterminate:"",color:"primary"})])):R.value.length?(o(),N(ke,{key:2},{default:t(()=>[(o(!0),h(be,null,Pe(R.value,$e=>(o(),N(Ce,{key:$e._id,cols:"12",sm:"6",lg:"4"},{default:t(()=>[e(le,{class:"email-campaign-list-view__plan-card",variant:"outlined",onClick:Ee=>_e($e)},{default:t(()=>[e(K,{class:"pa-5"},{default:t(()=>{var Ee,lt,ut,Ve,Le;return[a("div",kh,[a("h3",hh,v($e.name),1),e(ae,{color:B($e.status),size:"x-small",variant:"tonal",class:"flex-shrink-0"},{default:t(()=>[n(v(G($e.status)),1)]),_:2},1032,["color"])]),a("div",xh,[e(ie,{size:"14"},{default:t(()=>[...C[26]||(C[26]=[n("mdi-calendar-range",-1)])]),_:1}),(Ee=$e.period)!=null&&Ee.endDate?(o(),h("span",wh,v(A((lt=$e.period)==null?void 0:lt.startDate))+" – "+v(A((ut=$e.period)==null?void 0:ut.endDate)),1)):(o(),h("span",Sh,"Ab "+v(A((Ve=$e.period)==null?void 0:Ve.startDate))+" · Fortlaufend",1))]),a("div",$h,[e(ae,{size:"x-small",variant:"outlined",color:"primary"},{default:t(()=>[n(v(W($e.frequency)),1)]),_:2},1024),e(ae,{size:"x-small",variant:"tonal",color:"secondary","prepend-icon":"mdi-account-group"},{default:t(()=>[n(v(F($e)),1)]),_:2},1024)]),a("div",Ch,[a("div",Vh,[a("span",Ah,v(($e.ideas||[]).length),1),C[31]||(C[31]=n(" Ideen  ·  ",-1)),a("span",Ih,v(z($e)),1),C[32]||(C[32]=n(" in Arbeit ",-1)),J($e)>0?(o(),h(be,{key:0},[C[27]||(C[27]=n("  ·  ",-1)),a("span",Ph,v(J($e)),1),C[28]||(C[28]=n(" Entwürfe ",-1))],64)):U("",!0),j($e)>0?(o(),h(be,{key:1},[C[29]||(C[29]=n("  ·  ",-1)),a("span",zh,v(j($e)),1),C[30]||(C[30]=n(" freigegeben ",-1))],64)):U("",!0)])]),$e.stats&&$e.stats.totalSent>0?(o(),h("div",Dh,[a("div",Th,[e(ie,{size:"14",color:"medium-emphasis"},{default:t(()=>[...C[33]||(C[33]=[n("mdi-email-send-outline",-1)])]),_:1}),a("span",Lh,v($e.stats.totalSent),1)]),a("div",Eh,[e(ie,{size:"14",color:"primary"},{default:t(()=>[...C[34]||(C[34]=[n("mdi-email-open-outline",-1)])]),_:1}),a("span",Mh,v($e.stats.totalOpened),1)]),a("div",Nh,[e(ie,{size:"14",color:"#C9A063"},{default:t(()=>[...C[35]||(C[35]=[n("mdi-cursor-default-click-outline",-1)])]),_:1}),a("span",Uh,v($e.stats.totalClicked),1)])])):U("",!0),(Le=$e.elaboration)!=null&&Le.status&&$e.elaboration.status!=="idle"?(o(),h("div",Bh,[a("div",Fh,[C[36]||(C[36]=a("span",{class:"text-caption text-medium-emphasis"},"E-Mail-Generierung",-1)),e(ae,{color:L($e.elaboration.status),size:"x-small",variant:"tonal"},{default:t(()=>[n(v($e.elaboration.status==="running"?"Läuft...":$e.elaboration.status==="completed"?"Fertig":$e.elaboration.status==="failed"?"Fehler":""),1)]),_:2},1032,["color"])]),$e.elaboration.status==="running"?(o(),N(ne,{key:0,"model-value":$e.elaboration.progress||0,color:"primary",height:"4",rounded:""},null,8,["model-value"])):$e.elaboration.status==="completed"?(o(),N(ne,{key:1,"model-value":"100",color:"success",height:"4",rounded:""})):U("",!0)])):U("",!0),a("div",Oh,[e(gt,{"user-id":ce($e.createdBy),populated:oe($e.createdBy),size:22,locked:pe($e),"locked-by":oe($e.lockedBy)},null,8,["user-id","populated","locked","locked-by"]),e(gt,{"user-id":ce($e.updatedBy),populated:oe($e.updatedBy),size:22,locked:pe($e),"locked-by":oe($e.lockedBy)},null,8,["user-id","populated","locked","locked-by"])])]}),_:2},1024)]),_:2},1032,["onClick"])]),_:2},1024))),128))]),_:1})):(o(),N(le,{key:1,variant:"outlined",class:"email-campaign-list-view__empty"},{default:t(()=>[e(K,{class:"text-center pa-12"},{default:t(()=>[e(ie,{size:"64",color:"medium-emphasis",class:"mb-4"},{default:t(()=>[...C[22]||(C[22]=[n("mdi-email-outline",-1)])]),_:1}),C[24]||(C[24]=a("p",{class:"text-h6 font-weight-medium mb-2"},"Keine Email-Kampagnen vorhanden",-1)),C[25]||(C[25]=a("p",{class:"text-body-2 text-medium-emphasis mb-6"}," Erstelle deine erste Email-Kampagne, um die KI-gestützte Lead-Kommunikation zu starten. ",-1)),e(fe,{color:"primary","prepend-icon":"mdi-plus",onClick:ve},{default:t(()=>[...C[23]||(C[23]=[n(" Erste Kampagne erstellen ",-1)])]),_:1})]),_:1})]),_:1}))],64)):(o(),N(nh,{key:2})),e(Ke,{modelValue:k.value,"onUpdate:modelValue":C[14]||(C[14]=$e=>k.value=$e),"max-width":"560",scrollable:""},{default:t(()=>[e(le,{class:"email-campaign-list-view__dialog"},{default:t(()=>[e(xe,{class:"pa-6 pb-4"},{default:t(()=>[a("div",Rh,[C[39]||(C[39]=a("span",{class:"text-h6"},"Neue Email-Kampagne",-1)),e(fe,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:de},{default:t(()=>[e(X,{activator:"parent",location:"bottom"},{default:t(()=>[...C[37]||(C[37]=[n("Schließen",-1)])]),_:1}),e(ie,null,{default:t(()=>[...C[38]||(C[38]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(Ne),e(K,{class:"pa-6"},{default:t(()=>[g.value?(o(),N(me,{key:0,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":C[4]||(C[4]=$e=>g.value=null)},{default:t(()=>[n(v(g.value),1)]),_:1})):U("",!0),e(Te,{modelValue:x.value,"onUpdate:modelValue":C[13]||(C[13]=$e=>x.value=$e),onSubmit:dt(Z,["prevent"])},{default:t(()=>[e(ke,null,{default:t(()=>[e(Ce,{cols:"12"},{default:t(()=>[e(Ie,{modelValue:w.name,"onUpdate:modelValue":C[5]||(C[5]=$e=>w.name=$e),label:"Kampagnen-Name",rules:T,placeholder:"z.B. Onboarding-Sequenz Q2 2026",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(Ce,{cols:"12"},{default:t(()=>[e(Ue,{modelValue:w.campaignType,"onUpdate:modelValue":C[6]||(C[6]=$e=>w.campaignType=$e),label:"Kampagnen-Typ",items:b,variant:"outlined",density:"comfortable",hint:"Newsletter: fester Zeitraum, alle Leads gleichzeitig. Evergreen: jeder Lead startet bei Mail 1.","persistent-hint":""},null,8,["modelValue"])]),_:1}),e(Ce,{cols:"12",sm:w.campaignType==="evergreen"?12:6},{default:t(()=>[e(Ie,{modelValue:w.startDate,"onUpdate:modelValue":C[7]||(C[7]=$e=>w.startDate=$e),label:w.campaignType==="evergreen"?"Startdatum (ab wann aktiv)":"Startdatum",type:"date",rules:D,variant:"outlined",density:"comfortable"},null,8,["modelValue","label"])]),_:1},8,["sm"]),w.campaignType==="scheduled"?(o(),N(Ce,{key:0,cols:"12",sm:"6"},{default:t(()=>[e(Ie,{modelValue:w.endDate,"onUpdate:modelValue":C[8]||(C[8]=$e=>w.endDate=$e),label:"Enddatum",type:"date",rules:H,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1})):U("",!0),e(Ce,{cols:"12",sm:"6"},{default:t(()=>[e(Ue,{modelValue:w.frequency,"onUpdate:modelValue":C[9]||(C[9]=$e=>w.frequency=$e),label:w.campaignType==="evergreen"?"Abstand zwischen E-Mails":"Versandfrequenz",items:V,rules:O,variant:"outlined",density:"comfortable"},null,8,["modelValue","label"])]),_:1}),e(Ce,{cols:"12",sm:"6"},{default:t(()=>[e(Ue,{modelValue:w.audienceType,"onUpdate:modelValue":C[10]||(C[10]=$e=>w.audienceType=$e),label:"Zielgruppe",items:E,rules:S,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),w.audienceType==="segment"?(o(),N(Ce,{key:1,cols:"12"},{default:t(()=>[e(Sl,{modelValue:w.segmentId,"onUpdate:modelValue":C[11]||(C[11]=$e=>w.segmentId=$e),rules:[$e=>!!$e||"Segment ist erforderlich"]},null,8,["modelValue","rules"])]),_:1})):U("",!0),M.value.length?(o(),N(Ce,{key:2,cols:"12"},{default:t(()=>[e(Ue,{modelValue:w.gptSettingsId,"onUpdate:modelValue":C[12]||(C[12]=$e=>w.gptSettingsId=$e),label:"KI-Konfiguration (optional)",items:M.value,variant:"outlined",density:"comfortable",clearable:"",hint:"Wird für die KI-gestützte E-Mail-Generierung verwendet","persistent-hint":""},null,8,["modelValue","items"])]),_:1})):U("",!0)]),_:1})]),_:1},8,["modelValue"])]),_:1}),e(Ne),e(Je,{class:"pa-4"},{default:t(()=>[e(ye),e(fe,{variant:"text",onClick:de},{default:t(()=>[...C[40]||(C[40]=[n("Abbrechen",-1)])]),_:1}),e(fe,{color:"primary",variant:"elevated",loading:i.value,disabled:!x.value,onClick:Z},{default:t(()=>[...C[41]||(C[41]=[n(" Kampagne erstellen ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}}),jh=Me(Kh,[["__scopeId","data-v-a28eee5c"]]),A6=Object.freeze(Object.defineProperty({__proto__:null,default:jh},Symbol.toStringTag,{value:"Module"})),qh=/^\[EMAIL_IDEA:\s*(.+)\]$/,Gh=/^\[SUBJECT:\s*(.+)\]$/,Hh=/^\[PREHEADER:\s*(.+)\]$/,Wh=/^\[EMAIL_START:\s*(.+)\]$/,Zh=/^\[EMAIL_END\]$/,Jh=/^\[CTA:\s*(.+)\]$/;function al(r,$){const d=r.split("|").map(s=>s.trim());if(d.length<=$)return d;const c=d.slice(0,$-1);return c.push(d.slice($-1).join(" | ")),c}function $l(){function r(p){const _={ideas:[],emails:[],subjects:[],preheaders:[],ctas:[],cleanContent:""},k=p.split(`
`),i=[];let g=!1,x="",w=[],b="";for(const I of k){const V=I.trim();if(Zh.test(V)){g&&_.emails.push({ideaTitle:x,content:w.join(`
`).trim()}),g=!1,x="",w=[];continue}const E=V.match(Wh);if(E){g&&_.emails.push({ideaTitle:x,content:w.join(`
`).trim()}),g=!0,x=E[1].trim(),w=[];continue}if(g){w.push(I);continue}const R=V.match(qh);if(R){const H=al(R[1],4),O=H[0]||"";b=O,_.ideas.push({title:O,category:H[1]||"",suggestedDate:H[2]||"",description:H[3]||""});continue}const M=V.match(Gh);if(M){_.subjects.push({ideaTitle:b,subject:M[1].trim()});continue}const T=V.match(Hh);if(T){_.preheaders.push({ideaTitle:b,preheader:T[1].trim()});continue}const D=V.match(Jh);if(D){const H=al(D[1],2);_.ctas.push({label:H[0]||"",action:H[1]||""});continue}i.push(I)}return g&&w.length&&_.emails.push({ideaTitle:x,content:w.join(`
`).trim()}),_.cleanContent=i.join(`
`).replace(/\n{3,}/g,`

`).trim(),_}function $(p){return p.startsWith("accept-all")?{type:"accept-all",payload:""}:p.startsWith("elaborate")?{type:"elaborate",payload:""}:p.startsWith("generate-lp:")?{type:"generate-lp",payload:p.replace("generate-lp:","").trim()}:p.startsWith("message:")?{type:"message",payload:p.replace("message:","").trim()}:{type:"message",payload:p}}function d(p){return p?p.ideas.length>0||p.emails.length>0||p.subjects.length>0||p.ctas.length>0:!1}function c(p){return{suggested:"default",accepted:"primary",generating:"warning",drafted:"success",approved:"primary",sent:"info",skipped:"error"}[p]||"default"}function s(p){return{suggested:"Vorgeschlagen",accepted:"Akzeptiert",generating:"Wird generiert",drafted:"Entwurf",approved:"Freigegeben",sent:"Gesendet",skipped:"Übersprungen"}[p]||p}function m(p){return{education:"Wissensvermittlung","case-study":"Fallstudie",cta:"Call-to-Action",onboarding:"Onboarding",reminder:"Erinnerung"}[p]||p}function u(p,_=60){return p?p.length>_?p.substring(0,_)+"...":p:""}function f(p){if(!p)return"-";const _=new Date(p);return isNaN(_.getTime())?p:new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(_)}return{parseEmailMarkersClient:r,parseCtaAction:$,hasMarkers:d,getIdeaStatusColor:c,getIdeaStatusLabel:s,getIdeaCategoryLabel:m,truncateText:u,formatDate:f}}function Qh(r,$,d){const c=y([]),s=y(!1),m=y(!1),u=y(null);let f=null,p=!0;function _(){const b=document.querySelector(".email-campaign-detail-view__chat-messages");b&&(b.scrollTop=b.scrollHeight)}async function k(){s.value=!0;try{const b=await re.get(`/email-campaigns/${r.value}/chat`);if(!p)return;b.success&&b.data&&(c.value=b.data,Wt(()=>_()))}catch(b){if(!p)return;ue.error("ADMIN","Failed to load email campaign chat",b)}finally{p&&(s.value=!1)}}async function i(b){var E;if(!b.trim()||m.value)return;m.value=!0,u.value=null;const I=re.getAccessToken();if(!I){u.value="Nicht authentifiziert",m.value=!1;return}const V="/api";try{f=new AbortController;const R=await fetch(`${V}/email-campaigns/${r.value}/chat/stream`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`},body:JSON.stringify({message:b}),signal:f.signal});if(!p)return;if(!R.ok){u.value=`Chat-Fehler: HTTP ${R.status}`;return}const M=(E=R.body)==null?void 0:E.getReader();if(!M)throw new Error("Stream nicht verfügbar");const T=new TextDecoder;let D="",H=null;for(;;){const{done:O,value:S}=await M.read();if(!p)return;if(O)break;D+=T.decode(S,{stream:!0});const B=D.split(`
`);D=B.pop()||"";for(const G of B)if(G.startsWith("data: ")){if(!p)return;try{const W=JSON.parse(G.slice(6));switch(W.type){case"ping":break;case"user_message":if(!p)return;c.value.push(W.message),_();break;case"stream_start":if(!p)return;H={_id:"streaming",role:"assistant",content:""},c.value.push(H),_();break;case"chunk":if(!p)return;if(H){H.content+=W.content;const F=$(H.content);F.ideas.length>0&&(H.extractedMarkers=F),c.value=[...c.value],Wt(()=>_())}break;case"stream_complete":{if(!p)return;const F=c.value.findIndex(L=>L._id==="streaming");if(F!==-1&&W.message&&(c.value[F]=W.message),p&&d&&await d(),!p)return;_();break}case"done":break;case"error":if(!p)return;u.value=W.message||"Chat-Fehler aufgetreten";break;default:break}}catch{}}}}catch(R){if(!p)return;R.name!=="AbortError"&&(u.value="Chat-Verbindungsfehler",ue.error("ADMIN","Email campaign chat stream error",R))}finally{p&&(m.value=!1),f=null}}async function g(b,I){if(!b._id||b._id==="streaming"){c.value.splice(I,1);return}try{const V=await re.delete(`/email-campaigns/${r.value}/chat/${b._id}`);if(!p)return;V.success?c.value.splice(I,1):u.value=V.error||"Fehler beim Löschen der Nachricht"}catch{if(!p)return;u.value="Netzwerkfehler beim Löschen"}}async function x(){try{const b=await re.delete(`/email-campaigns/${r.value}/chat`);if(!p)return;b.success?c.value=[]:u.value=b.error||"Fehler beim Leeren des Chats"}catch{if(!p)return;u.value="Netzwerkfehler"}}function w(){f==null||f.abort(),f=null}return Ft(()=>{p=!1,w()}),{chatMessages:c,loadingChat:s,sendingMessage:m,chatError:u,loadChat:k,sendMessage:i,deleteMessage:g,clearChat:x,cleanup:w}}function Yh(r,$,d=60){const c=qe(r,d),s=y(!1);let m=null,u=null;function f(_){s.value=!0,_.preventDefault(),m=k=>{const i=document.querySelector($);if(!i)return;const g=i.getBoundingClientRect(),x=(k.clientX-g.left)/g.width*100;c.value=Math.min(75,Math.max(30,x))},u=()=>{s.value=!1,m&&document.removeEventListener("mousemove",m),u&&document.removeEventListener("mouseup",u),m=null,u=null},document.addEventListener("mousemove",m),document.addEventListener("mouseup",u)}function p(){s.value=!1,m&&document.removeEventListener("mousemove",m),u&&document.removeEventListener("mouseup",u),m=null,u=null}return Ft(()=>{p()}),{chatPanelWidth:c,isResizing:s,startResize:f}}const Xh={class:"email-preview"},ex={key:0,class:"mb-2"},tx={class:"text-body-2 font-weight-semibold"},ax={key:0,class:"text-caption text-medium-emphasis"},lx={class:"d-flex align-center ga-2 mb-2"},nx=["srcdoc"],ox=Ae({__name:"EmailPreview",props:{html:{},subject:{},preheader:{}},setup(r){const $=r,d=y("desktop");return(c,s)=>{const m=l("v-icon"),u=l("v-btn"),f=l("v-btn-toggle");return o(),h("div",Xh,[$.subject?(o(),h("div",ex,[a("div",tx,v($.subject),1),$.preheader?(o(),h("div",ax,v($.preheader),1)):U("",!0)])):U("",!0),a("div",lx,[e(f,{modelValue:d.value,"onUpdate:modelValue":s[0]||(s[0]=p=>d.value=p),mandatory:"",variant:"outlined",density:"compact",color:"primary"},{default:t(()=>[e(u,{value:"desktop",size:"small"},{default:t(()=>[e(m,{size:"16"},{default:t(()=>[...s[1]||(s[1]=[n("mdi-monitor",-1)])]),_:1})]),_:1}),e(u,{value:"mobile",size:"small"},{default:t(()=>[e(m,{size:"16"},{default:t(()=>[...s[2]||(s[2]=[n("mdi-cellphone",-1)])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),a("div",{class:"email-preview__frame",style:ht({maxWidth:d.value==="mobile"?"375px":"600px"})},[a("iframe",{srcdoc:$.html,frameborder:"0",class:"email-preview__iframe",sandbox:""},null,8,nx)],4)])}}}),sx=Me(ox,[["__scopeId","data-v-2ff3056a"]]),ix={class:"text-h6"},rx={class:"mb-4"},dx={class:"mb-4"},ux={class:"text-body-2"},cx={key:0,class:"mb-4"},mx={class:"text-body-2"},vx={key:1,class:"mb-4"},px={class:"text-body-2"},fx={key:0,class:"mb-4"},gx={class:"text-caption text-medium-emphasis mb-1"},bx={class:"text-body-2 text-primary"},yx={key:1,class:"mb-4"},_x={class:"text-caption text-medium-emphasis mb-1"},kx={class:"text-body-2"},hx={key:3,class:"text-center text-medium-emphasis pa-12"},xx={class:"text-caption text-medium-emphasis mb-2"},wx=Ae({__name:"EmailIdeaDetailModal",props:{modelValue:{type:Boolean},idea:{},campaignId:{},isReadOnly:{type:Boolean},onRefine:{type:Function},onGenerateEmail:{type:Function},onStatusChange:{type:Function}},emits:["update:modelValue","campaign-updated"],setup(r,{emit:$}){var G;const d=r,c=$,{getIdeaCategoryLabel:s,formatDate:m}=$l(),u=ea(),f=y(((G=u.user)==null?void 0:G.email)??""),p=y(""),_=y(""),k=y(""),i=y(!1),g=y(null),x=y([]),w=y([]),b=y(!1),I=se(()=>{var W;return(W=d.idea)!=null&&W.emailSections?d.idea.emailSections.map((F,L)=>({section:F,index:L})).filter(({section:F})=>F.type==="cta"):[]}),V=se(()=>[{value:"",title:"- eigene URL eintragen -"},...w.value.filter(W=>W.isActive).map(W=>({value:`preset:${W.slug}`,title:`${W.name} (${W.kind})`}))]);async function E(){if(!(w.value.length>0||b.value)){b.value=!0;try{const W=await re.get("/admin/form-presets?active=true");W.success&&W.data&&(w.value=W.data)}catch(W){ue.warn("ADMIN","Failed to load form presets for CTA editor",W)}finally{b.value=!1}}}Ze(()=>{var W,F,L;return[d.modelValue,(W=d.idea)==null?void 0:W._idx,(L=(F=d.idea)==null?void 0:F.emailSections)==null?void 0:L.length]},()=>{x.value=I.value.map(({section:W,index:F})=>{const L=W.settings??{};return{sectionIndex:F,ctaText:typeof L.ctaText=="string"?L.ctaText:"",ctaLink:typeof L.ctaLink=="string"?L.ctaLink:"",saving:!1,feedback:null}}),d.modelValue&&I.value.length>0&&E()},{immediate:!0});function R(W){return W.startsWith("preset:")?W:""}function M(W,F){F&&(x.value[W].ctaLink=F)}async function T(W){if(!d.idea||d.idea._idx===void 0||!d.campaignId||d.isReadOnly)return;const F=x.value[W];if(!(!F||F.saving)){F.saving=!0,F.feedback=null;try{const L=await re.put(`/email-campaigns/${d.campaignId}/ideas/${d.idea._idx}/cta`,{sectionIndex:F.sectionIndex,ctaText:F.ctaText,ctaLink:F.ctaLink});L.success&&L.data?(F.feedback={type:"success",text:"CTA gespeichert. Vorschau aktualisiert."},c("campaign-updated",L.data),ue.info("ADMIN","CTA-Section gespeichert",{campaignId:d.campaignId,ideaIdx:d.idea._idx,sectionIndex:F.sectionIndex})):F.feedback={type:"error",text:L.error||"CTA konnte nicht gespeichert werden."}}catch(L){F.feedback={type:"error",text:"Netzwerkfehler beim Speichern der CTA."},ue.error("ADMIN","Failed to save CTA section",L)}finally{F.saving=!1}}}function D(){c("update:modelValue",!1)}function H(){var W;!d.idea||d.idea._idx===void 0||((W=d.onStatusChange)==null||W.call(d,d.idea._idx,"accepted"),D())}function O(){var W;d.idea&&((W=d.onGenerateEmail)==null||W.call(d,d.idea.title),D())}function S(){var W,F;(W=d.idea)!=null&&W.title&&((F=d.onRefine)==null||F.call(d,d.idea.title),D())}async function B(){if(!d.idea||!d.campaignId||!f.value||i.value)return;i.value=!0,g.value=null;const W={};p.value.trim()&&(W.firstName=p.value.trim()),_.value.trim()&&(W.lastName=_.value.trim()),k.value.trim()&&(W.company=k.value.trim());try{const F=await re.post(`/email-campaigns/${d.campaignId}/ideas/send-test`,{ideaTitle:d.idea.title,recipientEmail:f.value,testData:W});F.success?(g.value={type:"success",text:`Test-E-Mail an ${f.value} gesendet.`},ue.info("ADMIN","Test-E-Mail gesendet",{campaignId:d.campaignId,ideaTitle:d.idea.title})):g.value={type:"error",text:F.error||"Test-E-Mail konnte nicht gesendet werden."}}catch(F){g.value={type:"error",text:"Netzwerkfehler beim Senden der Test-E-Mail."},ue.error("ADMIN","Failed to send test email",F)}finally{i.value=!1}}return(W,F)=>{const L=l("v-tooltip"),A=l("v-icon"),z=l("v-btn"),j=l("v-card-title"),J=l("v-divider"),Q=l("v-chip"),te=l("router-link"),ve=l("v-col"),de=l("v-expansion-panel-title"),Z=l("v-text-field"),ce=l("v-select"),oe=l("v-alert"),pe=l("v-expansion-panel-text"),_e=l("v-expansion-panel"),q=l("v-expansion-panels"),C=l("v-row"),ae=l("v-card-text"),X=l("v-spacer"),ie=l("v-card-actions"),fe=l("v-card"),Se=l("v-dialog");return o(),N(Se,{"model-value":r.modelValue,"max-width":"900",scrollable:"","onUpdate:modelValue":F[5]||(F[5]=me=>c("update:modelValue",me))},{default:t(()=>[r.idea?(o(),N(fe,{key:0},{default:t(()=>[e(j,{class:"pa-6 pb-4 d-flex align-center justify-space-between"},{default:t(()=>[a("span",ix,v(r.idea.title),1),e(z,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:D},{default:t(()=>[e(L,{activator:"parent",location:"bottom"},{default:t(()=>[...F[6]||(F[6]=[n("Schließen",-1)])]),_:1}),e(A,null,{default:t(()=>[...F[7]||(F[7]=[n("mdi-close",-1)])]),_:1})]),_:1})]),_:1}),e(J),e(ae,{class:"pa-6"},{default:t(()=>[e(C,null,{default:t(()=>[e(ve,{cols:"12",md:"4"},{default:t(()=>[a("div",rx,[F[8]||(F[8]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Kategorie",-1)),e(Q,{size:"small",variant:"tonal",color:"primary"},{default:t(()=>[n(v(P(s)(r.idea.category)),1)]),_:1})]),a("div",dx,[F[9]||(F[9]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Datum",-1)),a("div",ux,v(P(m)(r.idea.suggestedDate)),1)]),r.idea.description?(o(),h("div",cx,[F[10]||(F[10]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Beschreibung",-1)),a("div",mx,v(r.idea.description),1)])):U("",!0),r.idea.landingPagePreview?(o(),h("div",vx,[F[12]||(F[12]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Landing Page",-1)),a("div",px,v(r.idea.landingPagePreview.title),1),e(te,{to:`/admin/seiten/${r.idea.landingPagePreview.pageId}`,class:"text-caption text-primary"},{default:t(()=>[...F[11]||(F[11]=[n(" Im Editor öffnen ",-1)])]),_:1},8,["to"])])):U("",!0)]),_:1}),e(ve,{cols:"12",md:"8"},{default:t(()=>[r.idea.emailSubject?(o(),h("div",fx,[a("div",gx,"Betreff ("+v(r.idea.emailSubject.length)+"/60)",1),a("div",bx,v(r.idea.emailSubject),1)])):U("",!0),r.idea.emailPreheader?(o(),h("div",yx,[a("div",_x,"Preheader ("+v(r.idea.emailPreheader.length)+"/100)",1),a("div",kx,v(r.idea.emailPreheader),1)])):U("",!0),r.idea.emailHtml?(o(),N(sx,{key:2,html:r.idea.emailHtml,subject:r.idea.emailSubject,preheader:r.idea.emailPreheader},null,8,["html","subject","preheader"])):(o(),h("div",hx,[e(A,{size:"48",class:"mb-4"},{default:t(()=>[...F[13]||(F[13]=[n("mdi-email-outline",-1)])]),_:1}),F[14]||(F[14]=a("p",null,"Noch keine E-Mail generiert.",-1))])),I.value.length>0&&r.campaignId&&r.idea._idx!==void 0?(o(),N(q,{key:4,variant:"accordion",class:"mt-4"},{default:t(()=>[e(_e,null,{default:t(()=>[e(de,null,{default:t(()=>[e(A,{size:"18",class:"mr-2"},{default:t(()=>[...F[15]||(F[15]=[n("mdi-link-variant",-1)])]),_:1}),n(" CTA bearbeiten ("+v(I.value.length)+") ",1)]),_:1}),e(pe,null,{default:t(()=>[F[17]||(F[17]=a("p",{class:"text-caption text-medium-emphasis mb-3"}," Wenn die KI den falschen Preset oder Text gewählt hat, hier korrigieren. Speichern rendert die E-Mail neu. ",-1)),(o(!0),h(be,null,Pe(x.value,(me,ee)=>(o(),h("div",{key:me.sectionIndex,class:"mb-4 pa-3 rounded",style:{backgroundColor:"rgba(255,255,255,0.03)"}},[a("div",xx," CTA #"+v(ee+1)+" (Section "+v(me.sectionIndex+1)+") ",1),e(Z,{modelValue:me.ctaText,"onUpdate:modelValue":Y=>me.ctaText=Y,label:"Button-Text",placeholder:"Hier direkt Termin buchen",variant:"outlined",density:"compact",class:"mb-2",disabled:d.isReadOnly},null,8,["modelValue","onUpdate:modelValue","disabled"]),e(ce,{"model-value":R(me.ctaLink),items:V.value,loading:b.value,label:"Preset auswählen",variant:"outlined",density:"compact",class:"mb-2",disabled:d.isReadOnly,"onUpdate:modelValue":Y=>M(ee,Y)},null,8,["model-value","items","loading","disabled","onUpdate:modelValue"]),e(Z,{modelValue:me.ctaLink,"onUpdate:modelValue":Y=>me.ctaLink=Y,label:"Link / Preset",placeholder:"preset:termin-erstgespraech oder https://...",variant:"outlined",density:"compact",hint:"Format: preset:<slug> oder vollständige URL","persistent-hint":"",class:"mb-3",disabled:d.isReadOnly},null,8,["modelValue","onUpdate:modelValue","disabled"]),me.feedback?(o(),N(oe,{key:0,type:me.feedback.type,variant:"tonal",density:"compact",class:"mb-2",closable:"","onClick:close":Y=>me.feedback=null},{default:t(()=>[n(v(me.feedback.text),1)]),_:2},1032,["type","onClick:close"])):U("",!0),e(z,{color:"primary",variant:"elevated",size:"small","prepend-icon":"mdi-content-save",loading:me.saving,disabled:d.isReadOnly||me.saving,onClick:Y=>T(ee)},{default:t(()=>[...F[16]||(F[16]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled","onClick"])]))),128))]),_:1})]),_:1})]),_:1})):U("",!0),r.idea.emailHtml&&r.campaignId?(o(),N(q,{key:5,variant:"accordion",class:"mt-4"},{default:t(()=>[e(_e,null,{default:t(()=>[e(de,null,{default:t(()=>[e(A,{size:"18",class:"mr-2"},{default:t(()=>[...F[18]||(F[18]=[n("mdi-email-fast-outline",-1)])]),_:1}),F[19]||(F[19]=n(" Test-E-Mail senden ",-1))]),_:1}),e(pe,null,{default:t(()=>[F[21]||(F[21]=a("p",{class:"text-caption text-medium-emphasis mb-3"},[n(" Sendet die E-Mail an die angegebene Adresse. Die Felder unten ersetzen Platzhalter wie "),a("code",null,"{{firstName}}"),n(" oder "),a("code",null,"{{lastName}}"),n(" im E-Mail-Inhalt. Leere Felder werden mit Default-Werten (Max Mustermann, Muster GmbH) gefüllt. ")],-1)),e(Z,{modelValue:f.value,"onUpdate:modelValue":F[0]||(F[0]=me=>f.value=me),label:"Empfänger-E-Mail",type:"email",variant:"outlined",density:"compact",class:"mb-2",required:""},null,8,["modelValue"]),e(C,{dense:""},{default:t(()=>[e(ve,{cols:"6"},{default:t(()=>[e(Z,{modelValue:p.value,"onUpdate:modelValue":F[1]||(F[1]=me=>p.value=me),label:"firstName",placeholder:"Max",variant:"outlined",density:"compact"},null,8,["modelValue"])]),_:1}),e(ve,{cols:"6"},{default:t(()=>[e(Z,{modelValue:_.value,"onUpdate:modelValue":F[2]||(F[2]=me=>_.value=me),label:"lastName",placeholder:"Mustermann",variant:"outlined",density:"compact"},null,8,["modelValue"])]),_:1})]),_:1}),e(Z,{modelValue:k.value,"onUpdate:modelValue":F[3]||(F[3]=me=>k.value=me),label:"company",placeholder:"Muster GmbH",variant:"outlined",density:"compact",class:"mb-2"},null,8,["modelValue"]),g.value?(o(),N(oe,{key:0,type:g.value.type,variant:"tonal",density:"compact",class:"mb-2",closable:"","onClick:close":F[4]||(F[4]=me=>g.value=null)},{default:t(()=>[n(v(g.value.text),1)]),_:1},8,["type"])):U("",!0),e(z,{color:"primary",variant:"elevated",size:"small","prepend-icon":"mdi-email-fast-outline",loading:i.value,disabled:!f.value||i.value,onClick:B},{default:t(()=>[...F[20]||(F[20]=[n(" Test-E-Mail senden ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1})):U("",!0)]),_:1})]),_:1})]),_:1}),e(J),e(ie,{class:"pa-4"},{default:t(()=>[r.idea.status==="suggested"?(o(),N(z,{key:0,color:"primary",variant:"tonal",size:"small","prepend-icon":"mdi-check",disabled:d.isReadOnly,onClick:H},{default:t(()=>[...F[22]||(F[22]=[n(" Akzeptieren ",-1)])]),_:1},8,["disabled"])):U("",!0),r.idea.status!=="skipped"&&r.idea.status!=="sent"&&r.idea.status!=="generating"?(o(),N(z,{key:1,color:"warning",variant:"tonal",size:"small","prepend-icon":r.idea.emailHtml?"mdi-refresh":"mdi-creation",disabled:d.isReadOnly,onClick:O},{default:t(()=>[n(v(r.idea.emailHtml?"Vorschau neu generieren":"E-Mail generieren"),1)]),_:1},8,["prepend-icon","disabled"])):U("",!0),r.idea.status==="generating"?(o(),N(z,{key:2,color:"warning",variant:"tonal",size:"small",loading:"",disabled:""},{default:t(()=>[...F[23]||(F[23]=[n(" E-Mail wird generiert... ",-1)])]),_:1})):U("",!0),e(X),e(z,{variant:"text",size:"small","prepend-icon":"mdi-chat-outline",onClick:S},{default:t(()=>[...F[24]||(F[24]=[n(" Im Chat verfeinern ",-1)])]),_:1})]),_:1})]),_:1})):U("",!0)]),_:1},8,["model-value"])}}}),Sx={class:"email-campaign-header mb-3"},$x={class:"email-campaign-header__info"},Cx={class:"text-h5 font-weight-bold"},Vx={key:0,class:"d-flex align-center ga-2 text-caption text-medium-emphasis mb-1 mt-1"},Ax={class:"text-body-2 text-medium-emphasis mt-1"},Ix={key:2},Px={class:"email-campaign-header__actions"},zx=Ae({__name:"EmailCampaignHeader",props:{campaign:{},frequencyLabel:{},statusColor:{},statusLabel:{},formatDate:{type:Function},isReadOnly:{type:Boolean}},emits:["edit","activate","pause","resume","cancel","delete"],setup(r,{emit:$}){const d=r,c=$;function s(g){return g?typeof g=="object"?g._id:g:null}function m(g){return g&&typeof g=="object"?g:null}const u=se(()=>(d.campaign.ideas||[]).some(g=>(g.status==="drafted"||g.status==="approved")&&!!g.emailHtml)),f=se(()=>d.campaign.status==="draft"),p=se(()=>d.campaign.status==="sending"),_=se(()=>d.campaign.status==="paused"),k=se(()=>d.isReadOnly||!u.value),i=se(()=>d.isReadOnly?"Bearbeitung nur für Lock-Inhaber möglich":u.value?"":"Mindestens eine fertige E-Mail nötig");return(g,x)=>{var H,O,S,B;const w=l("v-tooltip"),b=l("v-icon"),I=l("v-btn"),V=l("v-chip"),E=l("v-list-item-title"),R=l("v-list-item-subtitle"),M=l("v-list-item"),T=l("v-list"),D=l("v-menu");return o(),h("div",Sx,[a("div",$x,[a("h1",Cx,v(r.campaign.name),1),r.campaign._id?(o(),h("div",Vx,[x[6]||(x[6]=a("span",null,"Erstellt:",-1)),e(gt,{"user-id":s(r.campaign.createdBy),populated:m(r.campaign.createdBy),size:24},null,8,["user-id","populated"]),x[7]||(x[7]=a("span",{class:"mx-1"},"·",-1)),x[8]||(x[8]=a("span",null,"Geändert:",-1)),e(gt,{"user-id":s(r.campaign.updatedBy),populated:m(r.campaign.updatedBy),size:24},null,8,["user-id","populated"])])):U("",!0),a("p",Ax,[(H=r.campaign.period)!=null&&H.endDate?(o(),h(be,{key:0},[n(v(r.formatDate((O=r.campaign.period)==null?void 0:O.startDate))+" – "+v(r.formatDate((S=r.campaign.period)==null?void 0:S.endDate)),1)],64)):(o(),h(be,{key:1},[n("Ab "+v(r.formatDate((B=r.campaign.period)==null?void 0:B.startDate))+" · Fortlaufend",1)],64)),r.frequencyLabel?(o(),h("span",Ix," ·  "+v(r.frequencyLabel),1)):U("",!0),e(I,{icon:"",variant:"text",size:"x-small",class:"ml-1","aria-label":"Kampagne bearbeiten",onClick:x[0]||(x[0]=G=>c("edit"))},{default:t(()=>[e(w,{activator:"parent",location:"bottom"},{default:t(()=>[...x[9]||(x[9]=[n("Kampagne bearbeiten",-1)])]),_:1}),e(b,{size:"14"},{default:t(()=>[...x[10]||(x[10]=[n("mdi-pencil",-1)])]),_:1})]),_:1})])]),a("div",Px,[e(V,{color:r.statusColor,size:"small",variant:"tonal"},{default:t(()=>[n(v(r.statusLabel),1)]),_:1},8,["color"]),f.value?(o(),N(I,{key:0,color:"primary",variant:"elevated",size:"small","prepend-icon":"mdi-play",disabled:k.value,onClick:x[1]||(x[1]=G=>c("activate"))},{default:t(()=>[x[11]||(x[11]=n(" Aktivieren ",-1)),i.value?(o(),N(w,{key:0,activator:"parent",location:"bottom"},{default:t(()=>[n(v(i.value),1)]),_:1})):U("",!0)]),_:1},8,["disabled"])):U("",!0),p.value?(o(),N(I,{key:1,color:"warning",variant:"elevated",size:"small","prepend-icon":"mdi-pause",disabled:r.isReadOnly,onClick:x[2]||(x[2]=G=>c("pause"))},{default:t(()=>[...x[12]||(x[12]=[n(" Pausieren ",-1)])]),_:1},8,["disabled"])):U("",!0),_.value?(o(),N(I,{key:2,color:"success",variant:"elevated",size:"small","prepend-icon":"mdi-play",disabled:r.isReadOnly,onClick:x[3]||(x[3]=G=>c("resume"))},{default:t(()=>[...x[13]||(x[13]=[n(" Fortsetzen ",-1)])]),_:1},8,["disabled"])):U("",!0),p.value||_.value?(o(),N(I,{key:3,color:"error",variant:"outlined",size:"small","prepend-icon":"mdi-stop",disabled:r.isReadOnly,onClick:x[4]||(x[4]=G=>c("cancel"))},{default:t(()=>[...x[14]||(x[14]=[n(" Beenden ",-1)])]),_:1},8,["disabled"])):U("",!0),e(D,{location:"bottom end"},{activator:t(({props:G})=>[e(I,Vt(G,{icon:"",variant:"text",size:"small","aria-label":"Weitere Aktionen"}),{default:t(()=>[e(b,null,{default:t(()=>[...x[15]||(x[15]=[n("mdi-dots-vertical",-1)])]),_:1})]),_:1},16)]),default:t(()=>[e(T,{density:"compact","min-width":"220"},{default:t(()=>[e(M,{"prepend-icon":"mdi-delete","base-color":"error",onClick:x[5]||(x[5]=G=>c("delete"))},{default:t(()=>[e(E,null,{default:t(()=>[...x[16]||(x[16]=[n("Kampagne löschen",-1)])]),_:1}),e(R,null,{default:t(()=>[...x[17]||(x[17]=[n("Unwiderruflich, inkl. Sequence + Chat",-1)])]),_:1})]),_:1})]),_:1})]),_:1})])])}}}),Dx=Me(zx,[["__scopeId","data-v-a1e83f61"]]),Tx={class:"d-flex align-center"},Lx={class:"email-campaign-detail-view__chat-messages pa-4"},Ex={key:0,class:"text-center text-medium-emphasis pa-8"},Mx={class:"d-flex align-center justify-space-between"},Nx={class:"text-caption text-medium-emphasis mb-1"},Ux=["innerHTML"],Bx={key:1,class:"mt-3"},Fx={class:"d-flex align-start justify-space-between ga-2"},Ox={style:{flex:"1","min-width":"0"}},Rx={class:"text-body-2 font-weight-semibold mb-1"},Kx={class:"d-flex align-center flex-wrap ga-1"},jx={key:0,class:"text-caption text-medium-emphasis"},qx={key:1,class:"text-caption text-medium-emphasis"},Gx={key:0,class:"text-caption text-medium-emphasis mt-1"},Hx={class:"d-flex ga-1 flex-shrink-0 align-center"},Wx={key:2,class:"d-flex flex-wrap ga-2 mt-3"},Zx=["innerHTML"],Jx={key:2,class:"text-body-2"},Qx={key:1,class:"d-flex align-center ga-2 text-caption text-medium-emphasis"},Yx={class:"pa-3 d-flex ga-2 align-end"},Xx={class:"text-caption font-weight-semibold text-medium-emphasis mb-1"},e2=Ae({__name:"EmailCampaignChatPanel",props:{messages:{},sending:{type:Boolean},hasMarkers:{type:Function},getIdeaCurrentStatus:{type:Function},getIdeaIndexByTitle:{type:Function},renderMarkdown:{type:Function},formatDate:{type:Function},getIdeaCategoryLabel:{type:Function},truncateText:{type:Function}},emits:["send","clearChat","deleteMessage","ctaClick","updateIdeaStatus","confirmUndo"],setup(r,{emit:$}){const d=r,c=[{group:"Kampagnen-Planung",items:["Erstelle 10 E-Mail-Ideen zum Thema NIS2 für Geschäftsführer im Mittelstand","Plane eine 8-teilige Onboarding-Serie für neue Newsletter-Abonnenten","Erstelle eine Drip-Kampagne mit steigendem Engagement-Level"]},{group:"Content-Optimierung",items:["Überarbeite die Betreffzeilen für höhere Öffnungsraten","Erstelle A/B-Varianten für die ersten 3 E-Mails","Füge Case-Study-E-Mails nach den Education-Mails ein"]},{group:"E-Mail-Vorschau",items:["Schreibe die erste E-Mail komplett aus","Generiere Subject und Preheader für alle Ideas","Erstelle einen Call-to-Action-Block für die letzte E-Mail"]}],s=$,m=y(""),u=y(!1);function f(k){k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),p())}function p(){const k=m.value.trim();!k||d.sending||(s("send",k),m.value="")}function _(k){m.value=k,u.value=!1,s("send",k),m.value=""}return(k,i)=>{const g=l("v-icon"),x=l("v-tooltip"),w=l("v-btn"),b=l("v-card-title"),I=l("v-divider"),V=l("v-progress-circular"),E=l("v-textarea"),R=l("v-card-text"),M=l("v-card"),T=l("v-menu");return o(),N(M,{variant:"outlined",class:"email-campaign-chat-panel__card"},{default:t(()=>[e(b,{class:"pa-4 pb-3 text-subtitle-1 font-weight-semibold d-flex align-center justify-space-between"},{default:t(()=>[a("div",Tx,[e(g,{class:"mr-2",size:"18"},{default:t(()=>[...i[3]||(i[3]=[n("mdi-chat-outline",-1)])]),_:1}),i[4]||(i[4]=n(" KI-Chat ",-1))]),r.messages.length?(o(),N(w,{key:0,icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Chat leeren",onClick:i[0]||(i[0]=D=>s("clearChat"))},{default:t(()=>[e(x,{activator:"parent",location:"bottom"},{default:t(()=>[...i[5]||(i[5]=[n("Chat leeren",-1)])]),_:1}),e(g,{size:"16"},{default:t(()=>[...i[6]||(i[6]=[n("mdi-delete-sweep",-1)])]),_:1})]),_:1})):U("",!0)]),_:1}),e(I),a("div",Lx,[r.messages.length?U("",!0):(o(),h("div",Ex," Starte den Chat, um E-Mail-Ideen zu generieren. ")),(o(!0),h(be,null,Pe(r.messages,(D,H)=>(o(),h("div",{key:D._id||D.createdAt,class:ft(["email-campaign-detail-view__message mb-4",{"email-campaign-detail-view__message--user":D.role==="user"}])},[a("div",Mx,[a("div",Nx,v(D.role==="user"?"Du":"KI-Assistent"),1),D._id&&D._id!=="streaming"?(o(),N(w,{key:0,icon:"",variant:"text",size:"x-small",class:"email-campaign-detail-view__message-delete","aria-label":"Nachricht löschen",onClick:dt(O=>s("deleteMessage",{msg:D,index:H}),["stop"])},{default:t(()=>[e(x,{activator:"parent",location:"bottom"},{default:t(()=>[...i[7]||(i[7]=[n("Nachricht löschen",-1)])]),_:1}),e(g,{size:"14"},{default:t(()=>[...i[8]||(i[8]=[n("mdi-trash-can-outline",-1)])]),_:1})]),_:1},8,["onClick"])):U("",!0)]),D.role==="assistant"&&D.extractedMarkers&&r.hasMarkers(D.extractedMarkers)?(o(),h(be,{key:0},[D.extractedMarkers.cleanContent?(o(),h("div",{key:0,class:"text-body-2",innerHTML:r.renderMarkdown(D.extractedMarkers.cleanContent)},null,8,Ux)):U("",!0),D.extractedMarkers.ideas&&D.extractedMarkers.ideas.length?(o(),h("div",Bx,[(o(!0),h(be,null,Pe(D.extractedMarkers.ideas,(O,S)=>(o(),h("div",{key:S,class:ft(["email-campaign-detail-view__idea-card--inline",{"email-campaign-detail-view__idea-card--drafted":r.getIdeaCurrentStatus(O.title)==="drafted","email-campaign-detail-view__idea-card--accepted":r.getIdeaCurrentStatus(O.title)==="accepted","email-campaign-detail-view__idea-card--skipped":r.getIdeaCurrentStatus(O.title)==="skipped"}])},[a("div",Fx,[a("div",Ox,[a("p",Rx,v(O.title),1),a("div",Kx,[O.category?(o(),h("span",jx,v(r.getIdeaCategoryLabel(O.category)),1)):U("",!0),O.suggestedDate?(o(),h("span",qx,"· "+v(r.formatDate(O.suggestedDate)),1)):U("",!0)]),O.description?(o(),h("p",Gx,v(r.truncateText(O.description,120)),1)):U("",!0)]),a("div",Hx,[r.getIdeaCurrentStatus(O.title)==="generating"?(o(),N(V,{key:0,indeterminate:"",size:"14",width:"2",color:"primary"})):r.getIdeaCurrentStatus(O.title)==="accepted"||r.getIdeaCurrentStatus(O.title)==="drafted"?(o(),h(be,{key:1},[e(w,{icon:"",variant:"text",size:"x-small",color:"success","aria-label":"Status zurücksetzen",onClick:dt(B=>s("confirmUndo",{title:O.title,index:r.getIdeaIndexByTitle(O.title)}),["stop"])},{default:t(()=>[e(x,{activator:"parent",location:"bottom"},{default:t(()=>[...i[9]||(i[9]=[n("Status zurücksetzen",-1)])]),_:1}),e(g,{size:"16"},{default:t(()=>[...i[10]||(i[10]=[n("mdi-check-circle",-1)])]),_:1})]),_:1},8,["onClick"]),e(w,{icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Verwerfen",onClick:dt(B=>s("updateIdeaStatus",{index:r.getIdeaIndexByTitle(O.title),status:"skipped"}),["stop"])},{default:t(()=>[e(x,{activator:"parent",location:"bottom"},{default:t(()=>[...i[11]||(i[11]=[n("Verwerfen",-1)])]),_:1}),e(g,{size:"14"},{default:t(()=>[...i[12]||(i[12]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["onClick"])],64)):r.getIdeaCurrentStatus(O.title)==="skipped"?(o(),N(w,{key:2,icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Status zurücksetzen",onClick:dt(B=>s("confirmUndo",{title:O.title,index:r.getIdeaIndexByTitle(O.title)}),["stop"])},{default:t(()=>[e(x,{activator:"parent",location:"bottom"},{default:t(()=>[...i[13]||(i[13]=[n("Status zurücksetzen",-1)])]),_:1}),e(g,{size:"16"},{default:t(()=>[...i[14]||(i[14]=[n("mdi-close-circle",-1)])]),_:1})]),_:1},8,["onClick"])):(o(),h(be,{key:3},[e(w,{icon:"",variant:"text",size:"x-small",color:"success","aria-label":"Akzeptieren",onClick:dt(B=>s("updateIdeaStatus",{index:r.getIdeaIndexByTitle(O.title),status:"accepted"}),["stop"])},{default:t(()=>[e(x,{activator:"parent",location:"bottom"},{default:t(()=>[...i[15]||(i[15]=[n("Akzeptieren",-1)])]),_:1}),e(g,{size:"14"},{default:t(()=>[...i[16]||(i[16]=[n("mdi-check",-1)])]),_:1})]),_:1},8,["onClick"]),e(w,{icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Verwerfen",onClick:dt(B=>s("updateIdeaStatus",{index:r.getIdeaIndexByTitle(O.title),status:"skipped"}),["stop"])},{default:t(()=>[e(x,{activator:"parent",location:"bottom"},{default:t(()=>[...i[17]||(i[17]=[n("Verwerfen",-1)])]),_:1}),e(g,{size:"14"},{default:t(()=>[...i[18]||(i[18]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["onClick"])],64))])])],2))),128))])):U("",!0),D.extractedMarkers.ctas&&D.extractedMarkers.ctas.length?(o(),h("div",Wx,[(o(!0),h(be,null,Pe(D.extractedMarkers.ctas,O=>(o(),N(w,{key:O.label,size:"x-small",color:"primary",variant:"tonal",onClick:S=>s("ctaClick",O.action)},{default:t(()=>[n(v(O.label),1)]),_:2},1032,["onClick"]))),128))])):U("",!0)],64)):D.role==="assistant"?(o(),h("div",{key:1,class:"text-body-2",innerHTML:r.renderMarkdown(D.content)},null,8,Zx)):(o(),h("div",Jx,v(D.content),1))],2))),128)),r.sending?(o(),h("div",Qx,[e(V,{indeterminate:"",size:"12",width:"2",color:"primary"}),i[19]||(i[19]=n(" KI antwortet... ",-1))])):U("",!0)]),e(I),a("div",Yx,[e(E,{modelValue:m.value,"onUpdate:modelValue":i[1]||(i[1]=D=>m.value=D),placeholder:"Nachricht eingeben...",variant:"outlined",density:"compact",rows:"2","auto-grow":"","hide-details":"",disabled:r.sending,onKeydown:f},null,8,["modelValue","disabled"]),e(T,{modelValue:u.value,"onUpdate:modelValue":i[2]||(i[2]=D=>u.value=D),"close-on-content-click":!1,location:"top"},{activator:t(({props:D})=>[e(w,Vt({icon:"",variant:"text",size:"small"},D,{class:"mb-1","aria-label":"Prompt-Vorschläge"}),{default:t(()=>[e(x,{activator:"parent",location:"bottom"},{default:t(()=>[...i[20]||(i[20]=[n("Prompt-Vorschläge",-1)])]),_:1}),e(g,{size:"20"},{default:t(()=>[...i[21]||(i[21]=[n("mdi-lightbulb-outline",-1)])]),_:1})]),_:1},16)]),default:t(()=>[e(M,{"max-width":"400","max-height":"400",class:"overflow-y-auto"},{default:t(()=>[e(R,{class:"pa-3"},{default:t(()=>[(o(),h(be,null,Pe(c,D=>a("div",{key:D.group,class:"mb-3"},[a("div",Xx,v(D.group),1),(o(!0),h(be,null,Pe(D.items,H=>(o(),N(w,{key:H,variant:"text",size:"small",class:"text-body-2 text-left mb-1",block:"",onClick:O=>_(H)},{default:t(()=>[n(v(H),1)]),_:2},1032,["onClick"]))),128))])),64))]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(w,{icon:"",color:"primary",loading:r.sending,disabled:!m.value.trim(),"aria-label":"Nachricht senden",onClick:p},{default:t(()=>[e(x,{activator:"parent",location:"bottom"},{default:t(()=>[...i[22]||(i[22]=[n("Nachricht senden",-1)])]),_:1}),e(g,null,{default:t(()=>[...i[23]||(i[23]=[n("mdi-send",-1)])]),_:1})]),_:1},8,["loading","disabled"])])]),_:1})}}}),t2=Me(e2,[["__scopeId","data-v-4cfe0113"]]),a2={class:"pa-4 pb-2 d-flex align-center justify-space-between"},l2={class:"text-subtitle-1 font-weight-semibold d-flex align-center"},n2={key:0,class:"d-flex align-center ga-2"},o2={class:"text-caption text-medium-emphasis"},s2=Ae({__name:"EmailCampaignTabsPanel",props:{activeTab:{},elaboration:{},ideasCount:{},draftedCount:{},lpCount:{}},emits:["update:activeTab"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-icon"),u=l("v-progress-circular"),f=l("v-tab"),p=l("v-tabs"),_=l("v-divider"),k=l("v-tabs-window-item"),i=l("v-tabs-window"),g=l("v-card");return o(),N(g,{variant:"outlined",class:"email-campaign-tabs-panel__card"},{default:t(()=>{var x,w,b;return[a("div",a2,[a("span",l2,[e(m,{class:"mr-2",size:"18"},{default:t(()=>[...s[1]||(s[1]=[n("mdi-view-list",-1)])]),_:1}),s[2]||(s[2]=n(" Inhalte ",-1))]),((x=r.elaboration)==null?void 0:x.status)==="running"?(o(),h("div",n2,[e(u,{indeterminate:"",size:"16",width:"2",color:"primary"}),a("span",o2,v(((w=r.elaboration)==null?void 0:w.completed)??0)+"/"+v(((b=r.elaboration)==null?void 0:b.total)??"?")+" wird generiert... ",1)])):U("",!0)]),e(p,{"model-value":r.activeTab,density:"compact",color:"primary",class:"px-2","onUpdate:modelValue":s[0]||(s[0]=I=>d("update:activeTab",I))},{default:t(()=>[e(f,{value:0},{default:t(()=>[n("Ideen ("+v(r.ideasCount)+")",1)]),_:1}),e(f,{value:1},{default:t(()=>[n("Vorschau ("+v(r.draftedCount)+")",1)]),_:1}),e(f,{value:2},{default:t(()=>[n("Landing Pages ("+v(r.lpCount)+")",1)]),_:1}),e(f,{value:3},{default:t(()=>[...s[3]||(s[3]=[n("Statistiken",-1)])]),_:1}),e(f,{value:4},{default:t(()=>[...s[4]||(s[4]=[n("Zustellungs-Log",-1)])]),_:1})]),_:1},8,["model-value"]),e(_),e(i,{"model-value":r.activeTab,class:"email-campaign-tabs-panel__tabs-window"},{default:t(()=>[e(k,{value:0},{default:t(()=>[Xt(c.$slots,"ideas",{},void 0,!0)]),_:3}),e(k,{value:1},{default:t(()=>[Xt(c.$slots,"emails",{},void 0,!0)]),_:3}),e(k,{value:2},{default:t(()=>[Xt(c.$slots,"landingPages",{},void 0,!0)]),_:3}),e(k,{value:3},{default:t(()=>[Xt(c.$slots,"stats",{},void 0,!0)]),_:3}),e(k,{value:4},{default:t(()=>[Xt(c.$slots,"deliveryLog",{},void 0,!0)]),_:3})]),_:3},8,["model-value"])]}),_:3})}}}),i2=Me(s2,[["__scopeId","data-v-9b28ddbc"]]),r2={class:"pa-4"},d2={key:0,class:"text-center text-medium-emphasis pa-8"},u2={key:1,class:"mb-4"},c2={class:"email-campaign-detail-view__accepted-header mb-2 d-flex align-center justify-space-between ga-2"},m2={class:"text-caption text-medium-emphasis"},v2=["onClick"],p2={class:"d-flex align-center justify-space-between mb-1"},f2={class:"d-flex align-center"},g2={class:"text-body-2 font-weight-semibold"},b2={key:0,class:"email-campaign-detail-view__dot email-campaign-detail-view__dot--green",title:"E-Mail generiert"},y2={key:1,class:"email-campaign-detail-view__dot email-campaign-detail-view__dot--gold",title:"Betreff vorhanden"},_2={class:"text-caption text-medium-emphasis mb-1"},k2={key:0},h2={key:0,class:"text-caption mb-2"},x2={key:1,class:"text-caption email-campaign-detail-view__subject mb-1"},w2={key:2,class:"text-caption text-medium-emphasis mb-1"},S2={key:2,class:"mb-4"},$2={class:"text-caption text-medium-emphasis mb-2 d-flex align-center justify-space-between"},C2=["onClick"],V2={class:"d-flex align-center justify-space-between mb-1"},A2={class:"d-flex align-center"},I2={class:"text-body-2 font-weight-semibold"},P2={key:0,class:"email-campaign-detail-view__dot email-campaign-detail-view__dot--green",title:"E-Mail generiert"},z2={key:1,class:"email-campaign-detail-view__dot email-campaign-detail-view__dot--gold",title:"Betreff vorhanden"},D2={class:"text-caption text-medium-emphasis mb-1"},T2={key:0},L2={key:0,class:"text-caption mb-2"},E2={key:1,class:"text-caption email-campaign-detail-view__subject mb-1"},M2={key:2,class:"text-caption text-medium-emphasis mb-1"},N2=["srcdoc"],U2={key:3,class:"mb-4"},B2={class:"text-caption text-medium-emphasis mb-2"},F2=["onClick"],O2={class:"d-flex align-center justify-space-between mb-1"},R2={class:"d-flex align-center"},K2={class:"text-body-2 font-weight-semibold"},j2={key:0,class:"email-campaign-detail-view__dot email-campaign-detail-view__dot--green",title:"E-Mail generiert"},q2={key:1,class:"email-campaign-detail-view__dot email-campaign-detail-view__dot--gold",title:"Betreff vorhanden"},G2={class:"text-caption text-medium-emphasis mb-1"},H2={key:0},W2={key:0,class:"text-caption email-campaign-detail-view__subject mb-1"},Z2={key:1,class:"text-caption text-medium-emphasis mb-1"},J2=["srcdoc"],Q2={key:4,class:"mb-4"},Y2={class:"text-caption text-medium-emphasis mb-2"},X2=["onClick"],ew={class:"d-flex align-center justify-space-between mb-1"},tw={class:"d-flex align-center"},aw={class:"text-body-2 font-weight-semibold"},lw={key:0,class:"email-campaign-detail-view__dot email-campaign-detail-view__dot--green",title:"E-Mail freigegeben"},nw={class:"text-caption text-medium-emphasis mb-1"},ow={key:0},sw={key:0,class:"text-caption email-campaign-detail-view__subject mb-1"},iw={key:1,class:"text-caption text-medium-emphasis mb-1"},rw={key:5,class:"mb-4"},dw={class:"text-caption text-medium-emphasis mb-2 d-flex align-center"},uw={class:"d-flex align-center justify-space-between mb-1"},cw={class:"text-body-2 font-weight-semibold"},mw={class:"text-caption text-medium-emphasis"},vw={key:0},pw={key:6},fw={class:"text-caption text-medium-emphasis mb-2 d-flex align-center justify-space-between"},gw={class:"d-flex align-center justify-space-between mb-1"},bw={class:"text-body-2 text-medium-emphasis"},yw={class:"d-flex align-center ga-1"},_w={class:"text-caption text-medium-emphasis"},kw={key:0},hw={class:"d-flex ga-2 mt-2"},xw=Ae({__name:"EmailCampaignIdeasTab",props:{acceptedIdeas:{},suggestedIdeas:{},draftedIdeas:{},approvedIdeas:{},generatingIdeas:{},skippedIdeas:{},totalIdeasCount:{},canElaborate:{type:Boolean},elaborating:{type:Boolean},generatingLpTitles:{},isReadOnly:{type:Boolean},getIdeaStatusColor:{type:Function},getIdeaStatusLabel:{type:Function},getIdeaCategoryLabel:{type:Function},formatDate:{type:Function}},emits:["openIdea","updateIdeaStatus","confirmUndo","acceptAll","startElaboration","deleteSkipped"],setup(r,{emit:$}){const d=r,c=$,s=p=>(d.generatingLpTitles??[]).includes(p),m=se(()=>d.acceptedIdeas.filter(p=>!p.emailHtml).length),u=se(()=>m.value>0?`${m.value} E-Mails generieren`:"Neu generieren"),f=se(()=>!!d.isReadOnly);return(p,_)=>{const k=l("v-btn"),i=l("v-tooltip"),g=l("v-progress-circular"),x=l("v-chip"),w=l("v-icon");return o(),h("div",r2,[r.totalIdeasCount?U("",!0):(o(),h("div",d2," Nutze den Chat, um E-Mail-Ideen zu generieren. ")),r.acceptedIdeas.length?(o(),h("div",u2,[a("div",c2,[a("span",m2,"Akzeptiert ("+v(r.acceptedIdeas.length)+")",1),r.canElaborate?(o(),N(k,{key:0,size:"small",color:"primary",variant:"elevated","prepend-icon":"mdi-creation",loading:r.elaborating,disabled:f.value,onClick:_[0]||(_[0]=b=>c("startElaboration"))},{default:t(()=>[n(v(u.value),1)]),_:1},8,["loading","disabled"])):U("",!0)]),(o(!0),h(be,null,Pe(r.acceptedIdeas,b=>(o(),h("div",{key:b._idx,class:"email-campaign-detail-view__idea-card mb-3 pa-3 rounded",style:{cursor:"pointer"},onClick:I=>c("openIdea",b)},[a("div",p2,[a("div",f2,[a("span",g2,v(b.title),1),b.emailHtml?(o(),h("span",b2)):b.emailSubject?(o(),h("span",y2)):U("",!0)]),a("div",{class:"d-flex align-center ga-1",onClick:_[1]||(_[1]=dt(()=>{},["stop"]))},[s(b.title)?(o(),N(g,{key:0,indeterminate:"",size:"16",width:"2",color:"primary",class:"mr-1","aria-label":"Landing-Page wird generiert..."},{default:t(()=>[e(i,{activator:"parent",location:"bottom"},{default:t(()=>[..._[9]||(_[9]=[n(" Landing-Page wird generiert... ",-1)])]),_:1})]),_:1})):U("",!0),e(x,{color:r.getIdeaStatusColor(b.status),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(r.getIdeaStatusLabel(b.status)),1)]),_:2},1032,["color"]),b.emailHtml?(o(),N(k,{key:1,icon:"",variant:"text",size:"x-small",color:"primary","aria-label":"Als Entwurf markieren",disabled:d.isReadOnly,onClick:I=>c("updateIdeaStatus",{index:b._idx,status:"drafted"})},{default:t(()=>[e(i,{activator:"parent",location:"bottom"},{default:t(()=>[..._[10]||(_[10]=[n("Als Entwurf markieren (versandbereit)",-1)])]),_:1}),e(w,{size:"16"},{default:t(()=>[..._[11]||(_[11]=[n("mdi-check-circle-outline",-1)])]),_:1})]),_:1},8,["disabled","onClick"])):U("",!0),e(k,{icon:"",variant:"text",size:"x-small","aria-label":"Status zurücksetzen",disabled:d.isReadOnly,onClick:I=>c("confirmUndo",{title:b.title,index:b._idx})},{default:t(()=>[e(i,{activator:"parent",location:"bottom"},{default:t(()=>[..._[12]||(_[12]=[n("Status zurücksetzen (zu vorgeschlagen)",-1)])]),_:1}),e(w,{size:"16"},{default:t(()=>[..._[13]||(_[13]=[n("mdi-restore",-1)])]),_:1})]),_:1},8,["disabled","onClick"]),e(k,{icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Verwerfen",disabled:d.isReadOnly,onClick:I=>c("updateIdeaStatus",{index:b._idx,status:"skipped"})},{default:t(()=>[e(i,{activator:"parent",location:"bottom"},{default:t(()=>[..._[14]||(_[14]=[n("Verwerfen",-1)])]),_:1}),e(w,{size:"14"},{default:t(()=>[..._[15]||(_[15]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["disabled","onClick"])])]),a("div",_2,[n(v(r.getIdeaCategoryLabel(b.category))+" ",1),b.suggestedDate?(o(),h("span",k2," ·  "+v(r.formatDate(b.suggestedDate)),1)):U("",!0)]),b.description?(o(),h("div",h2,v(b.description),1)):U("",!0),b.emailSubject?(o(),h("div",x2," Betreff: "+v(b.emailSubject),1)):U("",!0),b.emailPreheader?(o(),h("div",w2,v(b.emailPreheader),1)):U("",!0)],8,v2))),128))])):U("",!0),r.suggestedIdeas.length?(o(),h("div",S2,[a("div",$2,[a("span",null,"Vorgeschlagen ("+v(r.suggestedIdeas.length)+")",1),e(k,{size:"x-small",color:"primary",variant:"text",disabled:d.isReadOnly,onClick:_[2]||(_[2]=b=>c("acceptAll"))},{default:t(()=>[..._[16]||(_[16]=[n(" Alle akzeptieren ",-1)])]),_:1},8,["disabled"])]),(o(!0),h(be,null,Pe(r.suggestedIdeas,b=>{var I;return o(),h("div",{key:b._idx,class:"email-campaign-detail-view__idea-card mb-3 pa-3 rounded",style:{cursor:"pointer"},onClick:V=>c("openIdea",b)},[a("div",V2,[a("div",A2,[a("span",I2,v(b.title),1),b.emailHtml?(o(),h("span",P2)):b.emailSubject?(o(),h("span",z2)):U("",!0)]),a("div",{class:"d-flex align-center ga-1",onClick:_[3]||(_[3]=dt(()=>{},["stop"]))},[e(x,{color:r.getIdeaStatusColor(b.status),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(r.getIdeaStatusLabel(b.status)),1)]),_:2},1032,["color"]),e(k,{icon:"",variant:"text",size:"x-small",color:"success","aria-label":"Akzeptieren",disabled:d.isReadOnly,onClick:V=>c("updateIdeaStatus",{index:b._idx,status:"accepted"})},{default:t(()=>[e(i,{activator:"parent",location:"bottom"},{default:t(()=>[..._[17]||(_[17]=[n("Akzeptieren",-1)])]),_:1}),e(w,{size:"14"},{default:t(()=>[..._[18]||(_[18]=[n("mdi-check",-1)])]),_:1})]),_:1},8,["disabled","onClick"]),e(k,{icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Überspringen",disabled:d.isReadOnly,onClick:V=>c("updateIdeaStatus",{index:b._idx,status:"skipped"})},{default:t(()=>[e(i,{activator:"parent",location:"bottom"},{default:t(()=>[..._[19]||(_[19]=[n("Überspringen",-1)])]),_:1}),e(w,{size:"14"},{default:t(()=>[..._[20]||(_[20]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["disabled","onClick"])])]),a("div",D2,[n(v(r.getIdeaCategoryLabel(b.category))+" ",1),b.suggestedDate?(o(),h("span",T2," ·  "+v(r.formatDate(b.suggestedDate)),1)):U("",!0)]),b.description?(o(),h("div",L2,v(b.description),1)):U("",!0),b.emailSubject?(o(),h("div",E2," Betreff: "+v(b.emailSubject),1)):U("",!0),b.emailPreheader?(o(),h("div",M2,v(b.emailPreheader),1)):U("",!0),b.emailHtml?(o(),h("div",{key:3,class:"mt-2 email-campaign-detail-view__mini-preview",onClick:_[4]||(_[4]=dt(()=>{},["stop"]))},[(o(),h("iframe",{key:`mini-${b._idx}-${((I=b.emailHtml)==null?void 0:I.length)||0}`,srcdoc:b.emailHtml,frameborder:"0",sandbox:"",class:"email-campaign-detail-view__mini-iframe",title:"E-Mail-Vorschau"},null,8,N2))])):U("",!0)],8,C2)}),128))])):U("",!0),r.draftedIdeas.length?(o(),h("div",U2,[a("div",B2," Entwürfe ("+v(r.draftedIdeas.length)+") ",1),(o(!0),h(be,null,Pe(r.draftedIdeas,b=>{var I;return o(),h("div",{key:b._idx,class:"email-campaign-detail-view__idea-card mb-3 pa-3 rounded",style:{cursor:"pointer"},onClick:V=>c("openIdea",b)},[a("div",O2,[a("div",R2,[a("span",K2,v(b.title),1),b.emailHtml?(o(),h("span",j2)):b.emailSubject?(o(),h("span",q2)):U("",!0)]),a("div",{class:"d-flex align-center ga-1",onClick:_[5]||(_[5]=dt(()=>{},["stop"]))},[s(b.title)?(o(),N(g,{key:0,indeterminate:"",size:"16",width:"2",color:"primary",class:"mr-1","aria-label":"Landing-Page wird generiert..."},{default:t(()=>[e(i,{activator:"parent",location:"bottom"},{default:t(()=>[..._[21]||(_[21]=[n(" Landing-Page wird generiert... ",-1)])]),_:1})]),_:1})):U("",!0),e(x,{color:r.getIdeaStatusColor(b.status),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(r.getIdeaStatusLabel(b.status)),1)]),_:2},1032,["color"]),e(k,{icon:"",variant:"text",size:"x-small",color:"success","aria-label":"E-Mail freigeben",disabled:d.isReadOnly,onClick:V=>c("updateIdeaStatus",{index:b._idx,status:"approved"})},{default:t(()=>[e(i,{activator:"parent",location:"bottom"},{default:t(()=>[..._[22]||(_[22]=[n("E-Mail freigeben",-1)])]),_:1}),e(w,{size:"16"},{default:t(()=>[..._[23]||(_[23]=[n("mdi-check-all",-1)])]),_:1})]),_:1},8,["disabled","onClick"]),e(k,{icon:"",variant:"text",size:"x-small",color:"warning","aria-label":"Status zurücksetzen",disabled:d.isReadOnly,onClick:V=>c("confirmUndo",{title:b.title,index:b._idx})},{default:t(()=>[e(i,{activator:"parent",location:"bottom"},{default:t(()=>[..._[24]||(_[24]=[n("Status zurücksetzen",-1)])]),_:1}),e(w,{size:"16"},{default:t(()=>[..._[25]||(_[25]=[n("mdi-undo",-1)])]),_:1})]),_:1},8,["disabled","onClick"]),e(k,{icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Verwerfen",disabled:d.isReadOnly,onClick:V=>c("updateIdeaStatus",{index:b._idx,status:"skipped"})},{default:t(()=>[e(i,{activator:"parent",location:"bottom"},{default:t(()=>[..._[26]||(_[26]=[n("Verwerfen",-1)])]),_:1}),e(w,{size:"14"},{default:t(()=>[..._[27]||(_[27]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["disabled","onClick"])])]),a("div",G2,[n(v(r.getIdeaCategoryLabel(b.category))+" ",1),b.suggestedDate?(o(),h("span",H2," ·  "+v(r.formatDate(b.suggestedDate)),1)):U("",!0)]),b.emailSubject?(o(),h("div",W2," Betreff: "+v(b.emailSubject),1)):U("",!0),b.emailPreheader?(o(),h("div",Z2,v(b.emailPreheader),1)):U("",!0),b.emailHtml?(o(),h("div",{key:2,class:"mt-2 email-campaign-detail-view__mini-preview",onClick:_[6]||(_[6]=dt(()=>{},["stop"]))},[(o(),h("iframe",{key:`mini-${b._idx}-${((I=b.emailHtml)==null?void 0:I.length)||0}`,srcdoc:b.emailHtml,frameborder:"0",sandbox:"",class:"email-campaign-detail-view__mini-iframe",title:"E-Mail-Vorschau"},null,8,J2))])):U("",!0)],8,F2)}),128))])):U("",!0),r.approvedIdeas.length?(o(),h("div",Q2,[a("div",Y2," Freigegeben ("+v(r.approvedIdeas.length)+") ",1),(o(!0),h(be,null,Pe(r.approvedIdeas,b=>(o(),h("div",{key:b._idx,class:"email-campaign-detail-view__idea-card mb-3 pa-3 rounded",style:{cursor:"pointer"},onClick:I=>c("openIdea",b)},[a("div",ew,[a("div",tw,[a("span",aw,v(b.title),1),b.emailHtml?(o(),h("span",lw)):U("",!0)]),a("div",{class:"d-flex align-center ga-1",onClick:_[7]||(_[7]=dt(()=>{},["stop"]))},[e(x,{color:r.getIdeaStatusColor(b.status),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(r.getIdeaStatusLabel(b.status)),1)]),_:2},1032,["color"]),e(k,{icon:"",variant:"text",size:"x-small",color:"warning","aria-label":"Freigabe zurücknehmen",disabled:d.isReadOnly,onClick:I=>c("updateIdeaStatus",{index:b._idx,status:"drafted"})},{default:t(()=>[e(i,{activator:"parent",location:"bottom"},{default:t(()=>[..._[28]||(_[28]=[n("Freigabe zurücknehmen",-1)])]),_:1}),e(w,{size:"16"},{default:t(()=>[..._[29]||(_[29]=[n("mdi-undo",-1)])]),_:1})]),_:1},8,["disabled","onClick"]),e(k,{icon:"",variant:"text",size:"x-small",color:"error","aria-label":"Verwerfen",disabled:d.isReadOnly,onClick:I=>c("updateIdeaStatus",{index:b._idx,status:"skipped"})},{default:t(()=>[e(i,{activator:"parent",location:"bottom"},{default:t(()=>[..._[30]||(_[30]=[n("Verwerfen",-1)])]),_:1}),e(w,{size:"14"},{default:t(()=>[..._[31]||(_[31]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["disabled","onClick"])])]),a("div",nw,[n(v(r.getIdeaCategoryLabel(b.category))+" ",1),b.suggestedDate?(o(),h("span",ow," ·  "+v(r.formatDate(b.suggestedDate)),1)):U("",!0)]),b.emailSubject?(o(),h("div",sw," Betreff: "+v(b.emailSubject),1)):U("",!0),b.emailPreheader?(o(),h("div",iw,v(b.emailPreheader),1)):U("",!0)],8,X2))),128))])):U("",!0),r.generatingIdeas.length?(o(),h("div",rw,[a("div",dw,[e(g,{indeterminate:"",size:"12",width:"2",class:"mr-2"}),n(" Wird generiert ("+v(r.generatingIdeas.length)+") ",1)]),(o(!0),h(be,null,Pe(r.generatingIdeas,b=>(o(),h("div",{key:b._idx,class:"email-campaign-detail-view__idea-card mb-3 pa-3 rounded"},[a("div",uw,[a("span",cw,v(b.title),1),e(x,{color:r.getIdeaStatusColor(b.status),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(r.getIdeaStatusLabel(b.status)),1)]),_:2},1032,["color"])]),a("div",mw,[n(v(r.getIdeaCategoryLabel(b.category))+" ",1),b.suggestedDate?(o(),h("span",vw," ·  "+v(r.formatDate(b.suggestedDate)),1)):U("",!0)])]))),128))])):U("",!0),r.skippedIdeas.length?(o(),h("div",pw,[a("div",fw,[a("span",null,"Übersprungen ("+v(r.skippedIdeas.length)+")",1),e(k,{size:"x-small",color:"error",variant:"text",disabled:d.isReadOnly,onClick:_[8]||(_[8]=b=>c("deleteSkipped"))},{default:t(()=>[..._[32]||(_[32]=[n(" Entfernen ",-1)])]),_:1},8,["disabled"])]),(o(!0),h(be,null,Pe(r.skippedIdeas,b=>(o(),h("div",{key:b._idx,class:"email-campaign-detail-view__idea-card email-campaign-detail-view__idea-card--skipped mb-3 pa-3 rounded"},[a("div",gw,[a("span",bw,v(b.title),1),a("div",yw,[e(x,{color:r.getIdeaStatusColor(b.status),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(r.getIdeaStatusLabel(b.status)),1)]),_:2},1032,["color"]),e(w,{size:"16",color:"error"},{default:t(()=>[..._[33]||(_[33]=[n("mdi-close-circle",-1)])]),_:1})])]),a("div",_w,[n(v(r.getIdeaCategoryLabel(b.category))+" ",1),b.suggestedDate?(o(),h("span",kw," ·  "+v(r.formatDate(b.suggestedDate)),1)):U("",!0)]),a("div",hw,[e(k,{size:"x-small",color:"primary",variant:"text",disabled:d.isReadOnly,onClick:I=>c("updateIdeaStatus",{index:b._idx,status:"suggested"})},{default:t(()=>[..._[34]||(_[34]=[n(" Wiederherstellen ",-1)])]),_:1},8,["disabled","onClick"])])]))),128))])):U("",!0)])}}}),ww=Me(xw,[["__scopeId","data-v-da7e8d29"]]),Sw={class:"pa-4"},$w={key:0,class:"text-center text-medium-emphasis pa-8"},Cw={class:"d-flex align-center justify-space-between mb-1"},Vw=["onClick"],Aw={class:"d-flex ga-1"},Iw={key:0,class:"text-caption text-medium-emphasis mb-1"},Pw={key:1,class:"text-caption text-medium-emphasis mb-3"},zw={key:2,class:"email-campaign-emails-tab__preview-frame"},Dw=["srcdoc"],Tw={key:3,class:"text-caption text-medium-emphasis"},Lw=Ae({__name:"EmailCampaignEmailsTab",props:{draftedIdeas:{},sendingTest:{},regeneratingTitle:{},isReadOnly:{type:Boolean}},emits:["openIdea","regenerateEmail","sendTest"],setup(r,{emit:$}){const d=r,c=$;return(s,m)=>{const u=l("v-tooltip"),f=l("v-icon"),p=l("v-btn"),_=l("v-divider");return o(),h("div",Sw,[r.draftedIdeas.length?U("",!0):(o(),h("div",$w," Noch keine E-Mails generiert. Akzeptiere Ideen und starte die Generierung. ")),(o(!0),h(be,null,Pe(r.draftedIdeas,(k,i)=>{var g;return o(),h("div",{key:i,class:"mb-6"},[a("div",Cw,[a("div",{class:"text-body-2 font-weight-semibold email-campaign-emails-tab__title",onClick:x=>c("openIdea",k)},v(k.title),9,Vw),a("div",Aw,[e(p,{icon:"",variant:"text",size:"x-small","aria-label":"Vorschau neu generieren",loading:d.regeneratingTitle===k.title,disabled:k.status==="sent"||d.isReadOnly,onClick:x=>c("regenerateEmail",k.title)},{default:t(()=>[e(u,{activator:"parent",location:"bottom"},{default:t(()=>[...m[0]||(m[0]=[n("Vorschau neu generieren",-1)])]),_:1}),e(f,{size:"16"},{default:t(()=>[...m[1]||(m[1]=[n("mdi-refresh",-1)])]),_:1})]),_:1},8,["loading","disabled","onClick"]),e(p,{icon:"",variant:"text",size:"x-small",color:"primary","aria-label":"Test-E-Mail senden",loading:d.sendingTest===k.title,disabled:k.status==="sent"||d.isReadOnly,onClick:x=>c("sendTest",k.title)},{default:t(()=>[e(u,{activator:"parent",location:"bottom"},{default:t(()=>[...m[2]||(m[2]=[n("Test-E-Mail senden",-1)])]),_:1}),e(f,{size:"16"},{default:t(()=>[...m[3]||(m[3]=[n("mdi-email-fast-outline",-1)])]),_:1})]),_:1},8,["loading","disabled","onClick"])])]),k.emailSubject?(o(),h("div",Iw," Betreff: "+v(k.emailSubject),1)):U("",!0),k.emailPreheader?(o(),h("div",Pw," Preheader: "+v(k.emailPreheader),1)):U("",!0),k.emailHtml?(o(),h("div",zw,[(o(),h("iframe",{key:`${k._idx}-${((g=k.emailHtml)==null?void 0:g.length)||0}`,srcdoc:k.emailHtml,frameborder:"0",sandbox:"allow-same-origin",scrolling:"auto",class:"email-campaign-emails-tab__iframe",title:"E-Mail-Vorschau"},null,8,Dw))])):(o(),h("div",Tw," Kein HTML verfügbar ")),i<r.draftedIdeas.length-1?(o(),N(_,{key:4,class:"mt-4"})):U("",!0)])}),128))])}}}),Ew=Me(Lw,[["__scopeId","data-v-f1015faf"]]),Mw={class:"pa-4"},Nw={key:0,class:"text-center text-medium-emphasis pa-8"},Uw={class:"text-body-2 font-weight-semibold"},Bw={class:"text-caption text-medium-emphasis mt-1"},Fw={class:"text-caption text-medium-emphasis"},Ow=Ae({__name:"EmailCampaignLandingPagesTab",props:{topicsWithLandingPage:{}},setup(r){return($,d)=>(o(),h("div",Mw,[r.topicsWithLandingPage.length?U("",!0):(o(),h("div",Nw," Keine Landing Pages generiert. ")),(o(!0),h(be,null,Pe(r.topicsWithLandingPage,c=>{var s,m;return o(),h("div",{key:c.title,class:"mb-3 pa-3 rounded email-campaign-detail-view__landing-card"},[a("div",Uw,v((s=c.landingPagePreview)==null?void 0:s.title),1),a("div",Bw,v((m=c.landingPagePreview)==null?void 0:m.slug),1),a("div",Fw," Idee: "+v(c.title),1)])}),128))]))}}),Rw=Me(Ow,[["__scopeId","data-v-a2f221e5"]]),Kw={class:"d-flex align-center justify-space-between"},jw=Ae({__name:"EmailCampaignEditDialog",props:{modelValue:{type:Boolean},campaign:{},saving:{type:Boolean}},emits:["update:modelValue","save"],setup(r,{emit:$}){const d=r,c=$,s=y(!1),m=wt({name:"",startDate:"",endDate:"",frequency:"",audienceType:"",segmentId:null}),u=[{title:"Jeden Tag",value:"daily"},{title:"Alle 2-3 Tage",value:"every-2-3-days"},{title:"2x pro Woche",value:"2x-weekly"},{title:"Wöchentlich",value:"weekly"},{title:"Alle 2 Wochen",value:"biweekly"},{title:"Monatlich",value:"monthly"}],f=[{title:"Alle Leads",value:"all-leads"},{title:"Nach Tag",value:"tag"},{title:"Nach Stage",value:"stage"},{title:"Segment",value:"segment"}];Ze(()=>d.modelValue,_=>{var k,i,g,x,w;_&&d.campaign&&Object.assign(m,{name:d.campaign.name,startDate:((k=d.campaign.period)==null?void 0:k.startDate)||"",endDate:((i=d.campaign.period)==null?void 0:i.endDate)||"",frequency:d.campaign.frequency,audienceType:((g=d.campaign.audience)==null?void 0:g.type)||"all-leads",segmentId:((w=(x=d.campaign.audience)==null?void 0:x.config)==null?void 0:w.segmentId)||null})}),Ze(()=>m.audienceType,_=>{_!=="segment"&&(m.segmentId=null)});function p(){s.value&&c("save",{...m})}return(_,k)=>{const i=l("v-tooltip"),g=l("v-icon"),x=l("v-btn"),w=l("v-card-title"),b=l("v-divider"),I=l("v-text-field"),V=l("v-col"),E=l("v-select"),R=l("v-row"),M=l("v-form"),T=l("v-card-text"),D=l("v-spacer"),H=l("v-card-actions"),O=l("v-card"),S=l("v-dialog");return o(),N(S,{"model-value":r.modelValue,"max-width":"520",scrollable:"","onUpdate:modelValue":k[9]||(k[9]=B=>c("update:modelValue",B))},{default:t(()=>[e(O,null,{default:t(()=>[e(w,{class:"pa-6 pb-4"},{default:t(()=>[a("div",Kw,[k[12]||(k[12]=a("span",{class:"text-h6"},"Kampagne bearbeiten",-1)),e(x,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:k[0]||(k[0]=B=>c("update:modelValue",!1))},{default:t(()=>[e(i,{activator:"parent",location:"bottom"},{default:t(()=>[...k[10]||(k[10]=[n("Schließen",-1)])]),_:1}),e(g,null,{default:t(()=>[...k[11]||(k[11]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(b),e(T,{class:"pa-6"},{default:t(()=>[e(M,{modelValue:s.value,"onUpdate:modelValue":k[7]||(k[7]=B=>s.value=B),onSubmit:dt(p,["prevent"])},{default:t(()=>[e(R,null,{default:t(()=>{var B,G;return[e(V,{cols:"12"},{default:t(()=>[e(I,{modelValue:m.name,"onUpdate:modelValue":k[1]||(k[1]=W=>m.name=W),label:"Kampagnen-Name",rules:[W=>!!W||"Name ist erforderlich",W=>W.length>=3||"Mindestens 3 Zeichen"],variant:"outlined",density:"comfortable"},null,8,["modelValue","rules"])]),_:1}),e(V,{cols:"12",sm:((B=r.campaign)==null?void 0:B.campaignType)==="evergreen"?12:6},{default:t(()=>{var W;return[e(I,{modelValue:m.startDate,"onUpdate:modelValue":k[2]||(k[2]=F=>m.startDate=F),label:((W=r.campaign)==null?void 0:W.campaignType)==="evergreen"?"Startdatum (ab wann aktiv)":"Startdatum",type:"date",rules:[F=>!!F||"Startdatum ist erforderlich"],variant:"outlined",density:"comfortable"},null,8,["modelValue","label","rules"])]}),_:1},8,["sm"]),((G=r.campaign)==null?void 0:G.campaignType)!=="evergreen"?(o(),N(V,{key:0,cols:"12",sm:"6"},{default:t(()=>[e(I,{modelValue:m.endDate,"onUpdate:modelValue":k[3]||(k[3]=W=>m.endDate=W),label:"Enddatum",type:"date",rules:[W=>{var F;return((F=r.campaign)==null?void 0:F.campaignType)==="evergreen"||!!W||"Enddatum ist erforderlich"}],variant:"outlined",density:"comfortable"},null,8,["modelValue","rules"])]),_:1})):U("",!0),e(V,{cols:"12",sm:"6"},{default:t(()=>{var W;return[e(E,{modelValue:m.frequency,"onUpdate:modelValue":k[4]||(k[4]=F=>m.frequency=F),label:((W=r.campaign)==null?void 0:W.campaignType)==="evergreen"?"Abstand zwischen E-Mails":"Versandfrequenz",items:u,rules:[F=>!!F||"Frequenz ist erforderlich"],variant:"outlined",density:"comfortable"},null,8,["modelValue","label","rules"])]}),_:1}),e(V,{cols:"12",sm:"6"},{default:t(()=>[e(E,{modelValue:m.audienceType,"onUpdate:modelValue":k[5]||(k[5]=W=>m.audienceType=W),label:"Zielgruppe",items:f,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),m.audienceType==="segment"?(o(),N(V,{key:1,cols:"12"},{default:t(()=>[e(Sl,{modelValue:m.segmentId,"onUpdate:modelValue":k[6]||(k[6]=W=>m.segmentId=W),rules:[W=>!!W||"Segment ist erforderlich"]},null,8,["modelValue","rules"])]),_:1})):U("",!0)]}),_:1})]),_:1},8,["modelValue"])]),_:1}),e(b),e(H,{class:"pa-4"},{default:t(()=>[e(D),e(x,{variant:"text",onClick:k[8]||(k[8]=B=>c("update:modelValue",!1))},{default:t(()=>[...k[13]||(k[13]=[n("Abbrechen",-1)])]),_:1}),e(x,{color:"primary",variant:"elevated",loading:r.saving,disabled:!s.value,onClick:p},{default:t(()=>[...k[14]||(k[14]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["model-value"])}}}),qw=Ae({__name:"EmailCampaignUndoDialog",props:{undoIdea:{},targetStatus:{}},emits:["confirm","cancel"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-card-title"),u=l("v-card-text"),f=l("v-spacer"),p=l("v-btn"),_=l("v-card-actions"),k=l("v-card"),i=l("v-dialog");return o(),N(i,{"model-value":!!r.undoIdea,"max-width":"360","onUpdate:modelValue":s[2]||(s[2]=g=>d("cancel"))},{default:t(()=>[e(k,null,{default:t(()=>[e(m,{class:"text-subtitle-1 font-weight-semibold pa-4 pb-2"},{default:t(()=>[...s[3]||(s[3]=[n(" Status zurücksetzen? ",-1)])]),_:1}),e(u,{class:"text-body-2 pa-4 pt-0"},{default:t(()=>{var g;return[a("strong",null,v((g=r.undoIdea)==null?void 0:g.title),1),s[4]||(s[4]=n(" wird wieder als ",-1)),a("em",null,v(r.targetStatus),1),s[5]||(s[5]=n(" eingestuft. ",-1))]}),_:1}),e(_,{class:"pa-4 pt-0"},{default:t(()=>[e(f),e(p,{variant:"text",size:"small",onClick:s[0]||(s[0]=g=>d("cancel"))},{default:t(()=>[...s[6]||(s[6]=[n("Abbrechen",-1)])]),_:1}),e(p,{color:"primary",variant:"tonal",size:"small",onClick:s[1]||(s[1]=g=>d("confirm"))},{default:t(()=>[...s[7]||(s[7]=[n(" Zurücksetzen ",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["model-value"])}}}),Gw={class:"d-flex align-center justify-space-between"},Hw={key:0,class:"d-flex flex-column align-center pa-6 ga-3"},Ww={class:"preview-stats mb-4"},Zw={class:"preview-stats__row"},Jw={class:"text-body-2"},Qw={key:0},Yw={class:"text-caption text-medium-emphasis"},Xw={class:"preview-stats__row"},e0={class:"text-body-2"},t0={key:0},a0={key:1,class:"text-caption text-medium-emphasis"},l0={key:0},n0=Ae({__name:"EmailCampaignActivateDialog",props:{modelValue:{type:Boolean},campaignId:{}},emits:["update:modelValue","confirm"],setup(r,{emit:$}){const d=r,c=$,s=y(!1),m=y(null),u=y(null),f={"all-leads":"Alle Leads",tag:"Nach Tag",stage:"Nach Stage",segment:"Segment"};async function p(){if(d.campaignId){s.value=!0,m.value=null,u.value=null;try{const i=await re.get(`/email-campaigns/${d.campaignId}/audience-preview`);i.success&&i.data?u.value=i.data:m.value=i.error||"Empfänger-Vorschau konnte nicht geladen werden."}catch(i){m.value="Netzwerkfehler beim Laden der Empfänger-Vorschau.",ue.error("ADMIN","Failed to load audience preview",i)}finally{s.value=!1}}}Ze(()=>d.modelValue,i=>{i&&p()});function _(){c("update:modelValue",!1)}function k(){s.value||!u.value||!u.value.canActivate||c("confirm")}return(i,g)=>{const x=l("v-tooltip"),w=l("v-icon"),b=l("v-btn"),I=l("v-card-title"),V=l("v-divider"),E=l("v-progress-circular"),R=l("v-alert"),M=l("v-card-text"),T=l("v-spacer"),D=l("v-card-actions"),H=l("v-card"),O=l("v-dialog");return o(),N(O,{"model-value":r.modelValue,"max-width":"600","onUpdate:modelValue":g[0]||(g[0]=S=>c("update:modelValue",S))},{default:t(()=>[e(H,null,{default:t(()=>[e(I,{class:"pa-6 pb-4"},{default:t(()=>[a("div",Gw,[g[3]||(g[3]=a("span",{class:"text-h6"},"Kampagne aktivieren",-1)),e(b,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:_},{default:t(()=>[e(x,{activator:"parent",location:"bottom"},{default:t(()=>[...g[1]||(g[1]=[n("Schließen",-1)])]),_:1}),e(w,null,{default:t(()=>[...g[2]||(g[2]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(V),e(M,{class:"pa-6"},{default:t(()=>[s.value?(o(),h("div",Hw,[e(E,{indeterminate:"",color:"primary"}),g[4]||(g[4]=a("span",{class:"text-body-2 text-medium-emphasis"}," Empfänger-Vorschau wird geladen ... ",-1))])):m.value?(o(),N(R,{key:1,type:"error",variant:"tonal",density:"compact"},{default:t(()=>[n(v(m.value),1)]),_:1})):u.value?(o(),h(be,{key:2},[g[12]||(g[12]=a("p",{class:"text-body-2 mb-4"}," Beim Aktivieren werden alle eingeschriebenen Leads in die Versand-Queue aufgenommen und nach Kampagnen-Frequenz angeschrieben. ",-1)),a("div",Ww,[a("div",Zw,[e(w,{size:"20",color:"primary"},{default:t(()=>[...g[5]||(g[5]=[n("mdi-account-group-outline",-1)])]),_:1}),a("span",Jw,[a("strong",null,v(u.value.estimatedRecipients),1),g[6]||(g[6]=n(" Lead",-1)),u.value.estimatedRecipients!==1?(o(),h("span",Qw,"s")):U("",!0),g[7]||(g[7]=n(" erreicht ",-1)),a("span",Yw," ("+v(f[u.value.audienceType]||u.value.audienceType)+") ",1)])]),a("div",Xw,[e(w,{size:"20",color:"primary"},{default:t(()=>[...g[8]||(g[8]=[n("mdi-email-check-outline",-1)])]),_:1}),a("span",e0,[a("strong",null,v(u.value.approvedCount+u.value.draftedCount),1),g[9]||(g[9]=n(" versandbereite E-Mail",-1)),u.value.approvedCount+u.value.draftedCount!==1?(o(),h("span",t0,"s")):U("",!0),u.value.approvedCount>0&&u.value.draftedCount>0?(o(),h("span",a0," ("+v(u.value.approvedCount)+" freigegeben, "+v(u.value.draftedCount)+" im Entwurf) ",1)):U("",!0)])])]),u.value.acceptedWithoutEmailCount>0?(o(),N(R,{key:0,type:"warning",variant:"tonal",density:"compact",class:"mb-3"},{default:t(()=>[n(v(u.value.acceptedWithoutEmailCount)+" akzeptierte Idee",1),u.value.acceptedWithoutEmailCount!==1?(o(),h("span",l0,"n")):U("",!0),g[10]||(g[10]=n(" haben noch keine E-Mail und werden NICHT versendet. ",-1))]),_:1})):U("",!0),u.value.canActivate?U("",!0):(o(),N(R,{key:1,type:"error",variant:"tonal",density:"compact"},{default:t(()=>[...g[11]||(g[11]=[n(" Aktivierung nicht möglich – keine versandbereiten E-Mails vorhanden. Bitte mindestens eine Idee akzeptieren und die E-Mail generieren lassen. ",-1)])]),_:1}))],64)):U("",!0)]),_:1}),e(V),e(D,{class:"pa-4"},{default:t(()=>[e(T),e(b,{variant:"text",onClick:_},{default:t(()=>[...g[13]||(g[13]=[n("Abbrechen",-1)])]),_:1}),e(b,{color:"primary",variant:"elevated","prepend-icon":"mdi-play",disabled:s.value||!u.value||!u.value.canActivate,onClick:k},{default:t(()=>[...g[14]||(g[14]=[n(" Aktivieren ",-1)])]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["model-value"])}}}),o0=Me(n0,[["__scopeId","data-v-ce0bac1b"]]),s0={key:0,class:"mb-2"},i0=Ae({__name:"EmailCampaignCancelDialog",props:{modelValue:{type:Boolean},campaignName:{}},emits:["update:modelValue","confirm"],setup(r,{emit:$}){const d=$;function c(){d("update:modelValue",!1)}return(s,m)=>{const u=l("v-card-title"),f=l("v-card-text"),p=l("v-spacer"),_=l("v-btn"),k=l("v-card-actions"),i=l("v-card"),g=l("v-dialog");return o(),N(g,{"model-value":r.modelValue,"max-width":"440","onUpdate:modelValue":m[1]||(m[1]=x=>d("update:modelValue",x))},{default:t(()=>[e(i,null,{default:t(()=>[e(u,{class:"text-subtitle-1 font-weight-semibold pa-4 pb-2"},{default:t(()=>[...m[2]||(m[2]=[n(" Kampagne beenden? ",-1)])]),_:1}),e(f,{class:"text-body-2 pa-4 pt-0"},{default:t(()=>[r.campaignName?(o(),h("p",s0,[a("strong",null,v(r.campaignName),1),m[3]||(m[3]=n(" wird beendet und archiviert. ",-1))])):U("",!0),m[4]||(m[4]=a("p",{class:"mb-0"}," Alle ausstehenden Versand-Jobs werden abgebrochen. Bereits versendete E-Mails bleiben unverändert. Diese Aktion kann nicht rückgängig gemacht werden. ",-1))]),_:1}),e(k,{class:"pa-4 pt-0"},{default:t(()=>[e(p),e(_,{variant:"text",size:"small",onClick:c},{default:t(()=>[...m[5]||(m[5]=[n("Abbrechen",-1)])]),_:1}),e(_,{color:"error",variant:"elevated",size:"small",onClick:m[0]||(m[0]=x=>d("confirm"))},{default:t(()=>[...m[6]||(m[6]=[n(" Beenden ",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["model-value"])}}}),r0=6e4,Cl=Zt("emailCampaignStats",()=>{const r=y(null),$=y(!1),d=y(null),c=y("all-time");let s=null,m=null;async function u(i,g){m&&m.abort();const x=new AbortController;m=x,$.value=!0,d.value=null;try{const w=new URLSearchParams;w.set("period",(g==null?void 0:g.period)??c.value),g!=null&&g.forceRefresh&&w.set("forceRefresh","true");const b=await re.get(`/email-stats/campaigns/${i}?${w}`,{signal:x.signal});if(x.signal.aborted)return;b.success&&b.data?r.value=b.data:d.value=b.error||"Fehler beim Laden der Statistiken"}catch(w){if((w==null?void 0:w.name)==="AbortError"||x.signal.aborted)return;d.value="Netzwerkfehler"}finally{m===x&&($.value=!1,m=null)}}async function f(i,g){c.value!==g&&(c.value=g,await u(i,{period:g}))}function p(i,g=r0){_(),s=setInterval(()=>{u(i)},g)}function _(){s&&(clearInterval(s),s=null),m&&(m.abort(),m=null)}function k(){r.value=null,$.value=!1,d.value=null,c.value="all-time",_()}return{stats:r,loading:$,error:d,period:c,fetchStats:u,setPeriod:f,startPolling:p,stopPolling:_,$reset:k}}),d0={class:"email-campaign-stats-tab pa-3"},u0={key:2,class:"d-flex flex-column align-center justify-center pa-12 text-center"},c0={key:0,class:"d-flex align-center justify-end mb-2"},m0={class:"text-subtitle-2 font-weight-semibold mb-2"},v0={class:"text-subtitle-2 font-weight-semibold mb-2"},p0={class:"text-subtitle-2 font-weight-semibold mb-2"},f0={class:"text-subtitle-2 font-weight-semibold mb-2"},g0={class:"text-subtitle-2 font-weight-semibold mb-2"},b0={class:"text-subtitle-2 font-weight-semibold mb-2"},y0={class:"text-subtitle-2 font-weight-semibold mb-2"},_0={class:"text-subtitle-2 font-weight-semibold mb-2"},k0=Ae({__name:"EmailCampaignStatsTab",props:{campaignId:{}},setup(r){const $=Nt(()=>Lt(()=>Promise.resolve().then(()=>YD),void 0)),d=Nt(()=>Lt(()=>Promise.resolve().then(()=>lT),void 0)),c=Nt(()=>Lt(()=>Promise.resolve().then(()=>uT),void 0)),s=Nt(()=>Lt(()=>Promise.resolve().then(()=>bT),void 0)),m=Nt(()=>Lt(()=>Promise.resolve().then(()=>wT),void 0)),u=Nt(()=>Lt(()=>Promise.resolve().then(()=>AT),void 0)),f=Nt(()=>Lt(()=>Promise.resolve().then(()=>TT),void 0)),p=Nt(()=>Lt(()=>Promise.resolve().then(()=>GT),void 0)),_=Nt(()=>Lt(()=>Promise.resolve().then(()=>t6),void 0)),k=r,i=Cl(),{stats:g,loading:x,error:w}=Ea(i),b=se(()=>g.value??null),I=se(()=>b.value?{totalSent:b.value.sent??0,deliveryRate:b.value.deliveryRate??0,openRate:b.value.openRate??0,clickRate:b.value.clickRate??0,meetingRate:b.value.meetingRate??0,unsubscribeRate:b.value.unsubscribeRate??0,deltaSent:null,deltaDeliveryRate:null,deltaOpenRate:null,deltaClickRate:null,deltaMeetingRate:null,deltaUnsubscribeRate:null}:null),V=se(()=>b.value?{sent:b.value.sent??0,delivered:b.value.delivered??0,opened:b.value.opened??0,clicked:b.value.clicked??0,meetings:b.value.meetings??0}:null),E=se(()=>{var L;return((L=b.value)==null?void 0:L.timeSeries)??null}),R=se(()=>{var L;return((L=b.value)==null?void 0:L.ideaPerformance)??null}),M=se(()=>{var L;return((L=b.value)==null?void 0:L.topicPerformance)??null}),T=se(()=>{var L;return((L=b.value)==null?void 0:L.leadStates)??null}),D=se(()=>{var L;return((L=b.value)==null?void 0:L.sendHeatmap)??null}),H=se(()=>{var L;return((L=b.value)==null?void 0:L.cohortsBySignupWeek)??null}),O=se(()=>{var L;return((L=b.value)==null?void 0:L.cohortsByUtmSource)??null}),S=se(()=>{var L;return((L=b.value)==null?void 0:L.cohortsByLeadSourceType)??null}),B=se(()=>{var L;return((L=b.value)==null?void 0:L.cohortsByLandingPage)??null}),G=se(()=>{var L;return((L=b.value)==null?void 0:L.leadsInCampaign)??[]}),W=se(()=>!x.value&&!w.value&&!b.value);async function F(L=!1){ue.info("ADMIN","Loading campaign stats",{campaignId:k.campaignId}),await i.fetchStats(k.campaignId,{forceRefresh:L})}return Ze(()=>k.campaignId,(L,A)=>{L&&(A&&A!==L&&i.stopPolling(),i.startPolling(L),i.fetchStats(L))},{immediate:!0}),da(()=>{i.stopPolling()}),(L,A)=>{const z=l("v-skeleton-loader"),j=l("v-btn"),J=l("v-alert"),Q=l("v-icon"),te=l("v-progress-circular"),ve=l("v-card"),de=l("v-col"),Z=l("v-row");return o(),h("div",d0,[P(x)&&!b.value?(o(),h(be,{key:0},[e(z,{type:"card",class:"mb-3"}),e(z,{type:"image",class:"mb-3"}),e(z,{type:"table-tbody"})],64)):P(w)?(o(),N(J,{key:1,type:"error",variant:"tonal",class:"mb-3"},{append:t(()=>[e(j,{variant:"text",size:"small",onClick:A[0]||(A[0]=ce=>F(!0))},{default:t(()=>[...A[1]||(A[1]=[n(" Erneut versuchen ",-1)])]),_:1})]),default:t(()=>[n(v(P(w))+" ",1)]),_:1})):W.value?(o(),h("div",u0,[e(Q,{size:"64",color:"medium-emphasis"},{default:t(()=>[...A[2]||(A[2]=[n("mdi-chart-timeline-variant",-1)])]),_:1}),A[3]||(A[3]=a("p",{class:"mt-4 text-h6 text-medium-emphasis"},"Noch keine Statistiken verfügbar",-1)),A[4]||(A[4]=a("p",{class:"text-body-2 text-medium-emphasis"}," Daten erscheinen nach dem ersten Versand ",-1))])):(o(),h(be,{key:3},[P(x)?(o(),h("div",c0,[e(te,{indeterminate:"",size:"14",width:"2",color:"primary",class:"mr-2"}),A[5]||(A[5]=a("span",{class:"text-caption text-medium-emphasis"},"Wird aktualisiert…",-1))])):U("",!0),(o(),N(Tt,null,{fallback:t(()=>[e(z,{type:"card",class:"mb-4"})]),default:t(()=>[e(P($),{stats:I.value,class:"mb-4"},null,8,["stats"])]),_:1})),e(Z,{class:"mb-4"},{default:t(()=>[e(de,{cols:"12",md:"5"},{default:t(()=>[e(ve,{variant:"outlined",class:"email-campaign-stats-tab__card pa-3"},{default:t(()=>[a("div",m0,[e(Q,{size:"16",class:"mr-1"},{default:t(()=>[...A[6]||(A[6]=[n("mdi-filter-variant",-1)])]),_:1}),A[7]||(A[7]=n(" Engagement-Funnel ",-1))]),(o(),N(Tt,null,{fallback:t(()=>[e(z,{type:"image",height:"300"})]),default:t(()=>[e(P(d),{data:V.value},null,8,["data"])]),_:1}))]),_:1})]),_:1}),e(de,{cols:"12",md:"7"},{default:t(()=>[e(ve,{variant:"outlined",class:"email-campaign-stats-tab__card pa-3"},{default:t(()=>[a("div",v0,[e(Q,{size:"16",class:"mr-1"},{default:t(()=>[...A[8]||(A[8]=[n("mdi-chart-area-spline",-1)])]),_:1}),A[9]||(A[9]=n(" Zeitreihe ",-1))]),(o(),N(Tt,null,{fallback:t(()=>[e(z,{type:"image",height:"280"})]),default:t(()=>[e(P(c),{"time-series":E.value,"campaign-id":r.campaignId},null,8,["time-series","campaign-id"])]),_:1}))]),_:1})]),_:1})]),_:1}),e(Z,{class:"mb-4"},{default:t(()=>[e(de,{cols:"12",md:"7"},{default:t(()=>[e(ve,{variant:"outlined",class:"email-campaign-stats-tab__card pa-3"},{default:t(()=>[a("div",p0,[e(Q,{size:"16",class:"mr-1"},{default:t(()=>[...A[10]||(A[10]=[n("mdi-email-multiple-outline",-1)])]),_:1}),A[11]||(A[11]=n(" Per-Idea-Performance ",-1))]),(o(),N(Tt,null,{fallback:t(()=>[e(z,{type:"table-tbody"})]),default:t(()=>[e(P(s),{"idea-performance":R.value},null,8,["idea-performance"])]),_:1}))]),_:1})]),_:1}),e(de,{cols:"12",md:"5"},{default:t(()=>[e(ve,{variant:"outlined",class:"email-campaign-stats-tab__card pa-3"},{default:t(()=>[a("div",f0,[e(Q,{size:"16",class:"mr-1"},{default:t(()=>[...A[12]||(A[12]=[n("mdi-podium-gold",-1)])]),_:1}),A[13]||(A[13]=n(" Topic-Leaderboard ",-1))]),(o(),N(Tt,null,{fallback:t(()=>[e(z,{type:"table-tbody"})]),default:t(()=>[e(P(m),{"topic-performance":M.value},null,8,["topic-performance"])]),_:1}))]),_:1})]),_:1})]),_:1}),e(Z,{class:"mb-4"},{default:t(()=>[e(de,{cols:"12",md:"5"},{default:t(()=>[e(ve,{variant:"outlined",class:"email-campaign-stats-tab__card pa-3"},{default:t(()=>[a("div",g0,[e(Q,{size:"16",class:"mr-1"},{default:t(()=>[...A[14]||(A[14]=[n("mdi-account-multiple-outline",-1)])]),_:1}),A[15]||(A[15]=n(" Lead-Engagement-States ",-1))]),(o(),N(Tt,null,{fallback:t(()=>[e(z,{type:"image",height:"300"})]),default:t(()=>[e(P(u),{"lead-states":T.value},null,8,["lead-states"])]),_:1}))]),_:1})]),_:1}),e(de,{cols:"12",md:"7"},{default:t(()=>[e(ve,{variant:"outlined",class:"email-campaign-stats-tab__card pa-3"},{default:t(()=>[a("div",b0,[e(Q,{size:"16",class:"mr-1"},{default:t(()=>[...A[16]||(A[16]=[n("mdi-calendar-clock",-1)])]),_:1}),A[17]||(A[17]=n(" Sende-Heatmap ",-1))]),(o(),N(Tt,null,{fallback:t(()=>[e(z,{type:"image",height:"260"})]),default:t(()=>[e(P(f),{"send-heatmap":D.value},null,8,["send-heatmap"])]),_:1}))]),_:1})]),_:1})]),_:1}),e(ve,{variant:"outlined",class:"email-campaign-stats-tab__card pa-3 mb-4"},{default:t(()=>[a("div",y0,[e(Q,{size:"16",class:"mr-1"},{default:t(()=>[...A[18]||(A[18]=[n("mdi-table-multiple",-1)])]),_:1}),A[19]||(A[19]=n(" Kohorten-Analyse ",-1))]),(o(),N(Tt,null,{fallback:t(()=>[e(z,{type:"table-tbody"})]),default:t(()=>[e(P(p),{"cohorts-by-signup-week":H.value,"cohorts-by-utm-source":O.value,"cohorts-by-lead-source-type":S.value,"cohorts-by-landing-page":B.value},null,8,["cohorts-by-signup-week","cohorts-by-utm-source","cohorts-by-lead-source-type","cohorts-by-landing-page"])]),_:1}))]),_:1}),e(ve,{variant:"outlined",class:"email-campaign-stats-tab__card pa-3 mb-4"},{default:t(()=>[a("div",_0,[e(Q,{size:"16",class:"mr-1"},{default:t(()=>[...A[20]||(A[20]=[n("mdi-account-group-outline",-1)])]),_:1}),A[21]||(A[21]=n(" Leads in dieser Kampagne ",-1))]),(o(),N(Tt,null,{fallback:t(()=>[e(z,{type:"table-tbody"})]),default:t(()=>[e(P(_),{leads:G.value},null,8,["leads"])]),_:1}))]),_:1})],64))])}}}),h0=Me(k0,[["__scopeId","data-v-ee143cda"]]),x0={class:"email-campaign-delivery-log-tab pa-3"},w0={class:"d-flex align-center flex-wrap ga-2 mb-3"},S0={class:"text-caption"},$0={class:"text-body-2",style:{"max-width":"240px",display:"block",overflow:"hidden","text-overflow":"ellipsis","white-space":"nowrap"}},C0={key:1,class:"text-medium-emphasis"},V0={class:"text-caption"},A0={class:"text-caption text-medium-emphasis"},I0={class:"d-flex flex-column align-center justify-center pa-8 text-center"},P0=Ae({__name:"EmailCampaignDeliveryLogTab",props:{campaignId:{}},setup(r){const $=r,d=y(!1),c=y(null),s=y([]),m=y(0),u=y(1),f=y(20),p=y(""),_=y(""),k=[{title:"Alle",value:""},{title:"Warteschlange",value:"queued"},{title:"Gesendet",value:"sent"},{title:"Zugestellt",value:"delivered"},{title:"Geöffnet",value:"opened"},{title:"Geklickt",value:"clicked"},{title:"Bounced",value:"bounced"},{title:"Abgemeldet",value:"unsubscribed"},{title:"Fehlgeschlagen",value:"failed"}],i={queued:"default",sent:"info",delivered:"primary",opened:"primary",clicked:"warning",bounced:"error",unsubscribed:"secondary",failed:"error"},g={queued:"Warteschlange",sent:"Gesendet",delivered:"Zugestellt",opened:"Geöffnet",clicked:"Geklickt",bounced:"Bounced",unsubscribed:"Abgemeldet",failed:"Fehlgeschlagen"},x=[{title:"Empfänger",key:"to",sortable:!0},{title:"Betreff",key:"subject",sortable:!0},{title:"Status",key:"status",sortable:!0,width:"150px"},{title:"Topic",key:"topic",sortable:!0,width:"140px"},{title:"Schritt",key:"stepIndex",sortable:!0,width:"90px"},{title:"Gesendet",key:"sentAt",sortable:!0,width:"160px"}],w=se(()=>{const R=[...new Set(s.value.map(M=>M.topic).filter(Boolean))];return[{title:"Alle Topics",value:""},...R.map(M=>({title:M,value:M}))]});async function b(){d.value=!0,c.value=null;try{const R=new URLSearchParams({campaignId:$.campaignId,page:String(u.value),limit:String(f.value)});p.value&&R.set("status",p.value),_.value&&R.set("topic",_.value);const M=await re.get(`/email-logs?${R}`);M.success&&M.data?(s.value=M.data.items??[],m.value=M.data.total??0):(c.value=M.error||"Fehler beim Laden der Zustellungs-Logs",ue.error("ADMIN","Failed to load email logs",{error:M.error}))}catch(R){c.value="Netzwerkfehler beim Laden der Logs",ue.error("ADMIN","Network error loading email logs",R)}finally{d.value=!1}}function I(R){return R?new Date(R).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}):"–"}function V(R){return g[R]??R}function E(R){return i[R]??"default"}return Ze([p,_],()=>{u.value=1,b()}),Ze(u,()=>{b()}),rt(()=>{b()}),(R,M)=>{const T=l("v-select"),D=l("v-spacer"),H=l("v-btn"),O=l("v-alert"),S=l("v-chip"),B=l("v-icon"),G=l("v-data-table-server");return o(),h("div",x0,[a("div",w0,[e(T,{modelValue:p.value,"onUpdate:modelValue":M[0]||(M[0]=W=>p.value=W),items:k,"item-title":"title","item-value":"value",label:"Status",density:"compact",variant:"outlined","hide-details":"",style:{"max-width":"180px"}},null,8,["modelValue"]),e(T,{modelValue:_.value,"onUpdate:modelValue":M[1]||(M[1]=W=>_.value=W),items:w.value,"item-title":"title","item-value":"value",label:"Topic",density:"compact",variant:"outlined","hide-details":"",style:{"max-width":"200px"}},null,8,["modelValue","items"]),e(D),e(H,{variant:"text",density:"compact","prepend-icon":"mdi-refresh",loading:d.value,onClick:b},{default:t(()=>[...M[5]||(M[5]=[n(" Aktualisieren ",-1)])]),_:1},8,["loading"])]),c.value?(o(),N(O,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-3",closable:"","onClick:close":M[2]||(M[2]=W=>c.value=null)},{default:t(()=>[n(v(c.value),1)]),_:1})):U("",!0),e(G,{headers:x,items:s.value,"items-length":m.value,loading:d.value,page:u.value,"items-per-page":f.value,density:"compact",class:"email-campaign-delivery-log-tab__table",hover:"","onUpdate:page":M[3]||(M[3]=W=>u.value=W),"onUpdate:itemsPerPage":M[4]||(M[4]=W=>f.value=W)},{"item.to":t(({item:W})=>[a("span",S0,v(W.to),1)]),"item.subject":t(({item:W})=>[a("span",$0,v(W.subject||"–"),1)]),"item.status":t(({item:W})=>[e(S,{color:E(W.status),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(V(W.status)),1)]),_:2},1032,["color"])]),"item.topic":t(({item:W})=>[W.topic?(o(),N(S,{key:0,color:"primary",size:"x-small",variant:"tonal"},{default:t(()=>[n(v(W.topic),1)]),_:2},1024)):(o(),h("span",C0,"–"))]),"item.stepIndex":t(({item:W})=>[a("span",V0,"#"+v(W.stepIndex+1),1)]),"item.sentAt":t(({item:W})=>[a("span",A0,v(I(W.sentAt)),1)]),"no-data":t(()=>[a("div",I0,[e(B,{size:"48",color:"medium-emphasis"},{default:t(()=>[...M[6]||(M[6]=[n("mdi-email-off-outline",-1)])]),_:1}),M[7]||(M[7]=a("p",{class:"mt-2 text-medium-emphasis"},"Keine Einträge gefunden",-1))])]),_:1},8,["items","items-length","loading","page","items-per-page"])])}}}),z0=Me(P0,[["__scopeId","data-v-8b8ba3a8"]]),D0={class:"mb-2"},T0={key:1,class:"d-flex justify-center pa-12"},L0={key:2,class:"pa-8 text-center"},E0={key:0,class:"d-flex align-center justify-end mb-2 ga-2"},M0={class:"email-campaign-detail-view__split"},N0={class:"mb-3"},U0=Ae({__name:"EmailCampaignDetailView",setup(r){const{parseEmailMarkersClient:$,parseCtaAction:d,hasMarkers:c,getIdeaStatusColor:s,getIdeaStatusLabel:m,getIdeaCategoryLabel:u,formatDate:f,truncateText:p}=$l(),_=Ut(),k=xt(),i=ea(),g=se(()=>_.params.id),x=se(()=>{const De=_.params.id;return typeof De=="string"&&De!=="new"?De:null}),{isLocked:w,isLockedByMe:b,lockedBy:I,lockedAt:V,isLockTakenOver:E,takenOverBy:R,takeOverLock:M}=sa("EmailCampaign",x),T=se(()=>w.value&&!b.value||E.value),D=y(null),H=y(!1),O=y(null),S=y(!1),B=y(!1),G=y(!1),W=y(0),F=y(!1),L=y(null),A=y(null),z=y(!1),j=y(!1),J=y(!1),Q=y(!1),te=y(!1),ve=y(null),de=y(!1),Z=y(null),ce=y(!1),oe=y(new Set),pe=se(()=>Array.from(oe.value));let _e=null;function q(){var kt;if(!F.value||!L.value)return;const De=((kt=D.value)==null?void 0:kt.ideas)??[],we=De.findIndex(zt=>{var Et;return zt.title===((Et=L.value)==null?void 0:Et.title)});if(we===-1){F.value=!1,L.value=null;return}const tt=De[we];L.value={...tt,_idx:we}}const{chatMessages:C,sendingMessage:ae,loadChat:X,sendMessage:ie,deleteMessage:fe,clearChat:Se,cleanup:me}=Qh(g,$,async()=>{var De,we;await lt(),(we=(De=D.value)==null?void 0:De.ideas)!=null&&we.some(tt=>(tt.status==="suggested"||tt.status==="accepted"||tt.status==="generating")&&!tt.emailHtml)&&Ve()}),{chatPanelWidth:ee,isResizing:Y,startResize:K}=Yh("email_campaign_split_width",".email-campaign-detail-view__split",60),le=se(()=>{var we,tt;return{daily:"Jeden Tag","every-2-3-days":"Alle 2-3 Tage","2x-weekly":"2x pro Woche",weekly:"Wöchentlich",biweekly:"Alle 2 Wochen",monthly:"Monatlich"}[((we=D.value)==null?void 0:we.frequency)||""]||((tt=D.value)==null?void 0:tt.frequency)||""}),ne=se(()=>{var we;return{draft:"default",elaboration:"info",active:"primary",sending:"warning",paused:"secondary",completed:"success",archived:"default"}[((we=D.value)==null?void 0:we.status)||""]||"default"}),Ce=se(()=>{var we,tt;return{draft:"Entwurf",elaboration:"Elaboration",active:"Aktiv",sending:"Sendet",paused:"Pausiert",completed:"Abgeschlossen",archived:"Archiviert"}[((we=D.value)==null?void 0:we.status)||""]||((tt=D.value)==null?void 0:tt.status)||""}),ke=se(()=>{var De;return(((De=D.value)==null?void 0:De.ideas)||[]).map((we,tt)=>({...we,_idx:tt})).filter(we=>we.status==="drafted")}),xe=se(()=>{var De;return(((De=D.value)==null?void 0:De.ideas)||[]).map((we,tt)=>({...we,_idx:tt})).filter(we=>we.status==="approved")}),Ne=se(()=>{var De;return(((De=D.value)==null?void 0:De.ideas)||[]).map((we,tt)=>({...we,_idx:tt})).filter(we=>!!we.emailHtml&&we.status!=="generating"&&we.status!=="skipped")}),Ie=se(()=>{var De;return(((De=D.value)==null?void 0:De.ideas)||[]).filter(we=>!!we.landingPagePreview)}),Ue=se(()=>{var De;return!D.value||((De=D.value.elaboration)==null?void 0:De.status)==="running"?!1:D.value.ideas.some(we=>we.status==="accepted")}),Te=se(()=>{var De;return(((De=D.value)==null?void 0:De.ideas)||[]).map((we,tt)=>({...we,_idx:tt})).filter(we=>we.status==="suggested")}),ye=se(()=>{var De;return(((De=D.value)==null?void 0:De.ideas)||[]).map((we,tt)=>({...we,_idx:tt})).filter(we=>we.status==="accepted")}),Je=se(()=>{var De;return(((De=D.value)==null?void 0:De.ideas)||[]).map((we,tt)=>({...we,_idx:tt})).filter(we=>we.status==="generating")}),Ke=se(()=>{var De;return(((De=D.value)==null?void 0:De.ideas)||[]).map((we,tt)=>({...we,_idx:tt})).filter(we=>we.status==="skipped")}),$e=se(()=>A.value?"Vorgeschlagen":"");async function Ee(){var De;H.value=!0,O.value=null,S.value=!1;try{const we=await re.get(`/email-campaigns/${g.value}`);we.success&&we.data?D.value=we.data:we.status===404||(De=we.error)!=null&&De.toLowerCase().includes("nicht gefunden")?S.value=!0:O.value=we.error||"Kampagne konnte nicht geladen werden"}catch(we){O.value="Fehler beim Laden der Kampagne",ue.error("ADMIN","Failed to load email campaign",we)}finally{H.value=!1}}async function lt(){try{const De=await re.get(`/email-campaigns/${g.value}`);De.success&&De.data&&(D.value=De.data,q())}catch(De){ue.warn("ADMIN","Failed to refresh email campaign",De)}}async function ut(){if(T.value){ue.warn("ADMIN","Elaboration blockiert - kein Lock-Owner");return}B.value=!0,O.value=null;try{await re.post(`/email-campaigns/${g.value}/elaborate`),Ve()}catch(De){O.value="Elaboration konnte nicht gestartet werden",ue.error("ADMIN","Failed to start email elaboration",De)}finally{B.value=!1}}function Ve(){Le(),_e=setInterval(async()=>{var tt,kt,zt,Et,Ot,Bt;await lt();const De=(kt=(tt=D.value)==null?void 0:tt.ideas)==null?void 0:kt.some(Oe=>Oe.status==="generating"||(Oe.status==="suggested"||Oe.status==="accepted")&&!Oe.emailHtml),we=((Et=(zt=D.value)==null?void 0:zt.elaboration)==null?void 0:Et.status)==="running";!De&&!we&&(Le(),((Bt=(Ot=D.value)==null?void 0:Ot.elaboration)==null?void 0:Bt.status)==="completed"&&(G.value=!0))},3e3)}function Le(){_e!==null&&(clearInterval(_e),_e=null)}function Ye(){var De;return!D.value||((De=D.value.elaboration)==null?void 0:De.status)==="running"?!1:D.value.ideas.some(we=>we.status==="accepted"&&!we.emailHtml)}async function ct(De,we){var Bt,Oe,Ct,Rt,qt,Qt,Yt,Ht,st,ra,fa;if(T.value){ue.warn("ADMIN","Idea-Status-Update blockiert - kein Lock-Owner");return}if(De<0){O.value="Idee nicht mehr in der Kampagne vorhanden";return}const tt=(Oe=(Bt=D.value)==null?void 0:Bt.ideas[De])==null?void 0:Oe.title,kt=!!((Rt=(Ct=D.value)==null?void 0:Ct.ideas[De])!=null&&Rt.emailHtml),zt=!!((Qt=(qt=D.value)==null?void 0:qt.ideas[De])!=null&&Qt.landingPagePreview),Et=((Ht=(Yt=D.value)==null?void 0:Yt.ideas[De])==null?void 0:Ht.generateLandingPage)===!0,Ot=(ra=(st=D.value)==null?void 0:st.ideas[De])==null?void 0:ra.status;try{const Ge=await re.put(`/email-campaigns/${g.value}/ideas`,{ideas:[{index:De,status:we}]});if(Ge.success&&Ge.data){const Oa=((fa=D.value)==null?void 0:fa.status)==="sending";D.value=Ge.data,q(),we==="accepted"&&tt&&kt&&!zt&&Et&&ge(tt).catch(ha=>{ue.warn("ADMIN","Auto-LP-Generierung fehlgeschlagen",ha)}),we==="accepted"&&Ye()&&ut().catch(ha=>{ue.warn("ADMIN","Auto-Elaboration fehlgeschlagen",ha)});const Ra=["drafted","approved"],Pl=Ot?Ra.includes(Ot):!1,zl=Ra.includes(we);Oa&&!Pl&&zl&&kt&&(ve.value="Idee wurde automatisch in die laufende Sequence aufgenommen.")}else O.value=Ge.error||"Fehler beim Aktualisieren"}catch(Ge){O.value="Fehler beim Aktualisieren der Idee",ue.error("ADMIN","Failed to update idea status",Ge)}}async function Fe(){if(T.value){ue.warn("ADMIN","Alle-akzeptieren blockiert - kein Lock-Owner");return}if(!D.value)return;const De=D.value.ideas.filter(tt=>tt.status==="suggested"&&tt.emailHtml&&!tt.landingPagePreview&&tt.generateLandingPage).map(tt=>tt.title),we=D.value.ideas.map((tt,kt)=>({index:kt,status:tt.status})).filter(tt=>tt.status==="suggested").map(tt=>({index:tt.index,status:"accepted"}));if(we.length)try{const tt=await re.put(`/email-campaigns/${g.value}/ideas`,{ideas:we});if(tt.success&&tt.data){D.value=tt.data,q();for(const kt of De)ge(kt).catch(zt=>{ue.warn("ADMIN","Auto-LP-Generierung fehlgeschlagen",zt)});Ye()&&ut().catch(kt=>{ue.warn("ADMIN","Auto-Elaboration fehlgeschlagen",kt)})}}catch(tt){O.value="Fehler beim Akzeptieren der Ideen",ue.error("ADMIN","Failed to accept all ideas",tt)}}async function Xe(){if(T.value){ue.warn("ADMIN","Übersprungene-löschen blockiert - kein Lock-Owner");return}if(D.value)try{const De=await re.delete(`/email-campaigns/${g.value}/ideas/skipped`);De.success&&De.data?(D.value=De.data,q()):O.value=De.error||"Fehler beim Entfernen"}catch{O.value="Netzwerkfehler beim Entfernen übersprungener Ideas"}}function mt(De,we){A.value={title:De,index:we}}async function nt(){var we,tt;if(T.value){ue.warn("ADMIN","Undo blockiert - kein Lock-Owner");return}if(!A.value)return;if(((tt=(we=D.value)==null?void 0:we.ideas[A.value.index])==null?void 0:tt.status)==="sent"){O.value="Bereits gesendete E-Mails können nicht rückgängig gemacht werden.",A.value=null;return}await ct(A.value.index,"suggested"),A.value=null}function He(){A.value=null}const St=y(null);async function Pt(De){if(!T.value&&D.value){St.value=De;try{const we=await re.post(`/email-campaigns/${g.value}/ideas/generate-email`,{ideaTitle:De});we.success&&we.data?(D.value=we.data,q(),ue.info("ADMIN","E-Mail generiert",{ideaTitle:De})):O.value=we.error||"E-Mail-Generierung fehlgeschlagen"}catch(we){O.value="Fehler bei der E-Mail-Generierung",ue.error("ADMIN","Failed to generate email for idea",we)}finally{St.value=null}}}const Dt=y(null),_t=y(!1);async function Re(De){var tt;if(T.value||!D.value)return;const we=((tt=i.user)==null?void 0:tt.email)||"";if(!we){O.value="Keine E-Mail-Adresse im Benutzerprofil hinterlegt";return}Dt.value=De;try{const kt=await re.post(`/email-campaigns/${g.value}/ideas/send-test`,{ideaTitle:De,recipientEmail:we});kt.success?_t.value=!0:O.value=kt.error||"Test-E-Mail konnte nicht gesendet werden"}catch(kt){O.value="Fehler beim Senden der Test-E-Mail",ue.error("ADMIN","Failed to send test email",kt)}finally{Dt.value=null}}async function ge(De){if(!(T.value||oe.value.has(De))&&D.value){oe.value.add(De);try{const we=await re.post(`/email-campaigns/${g.value}/ideas/generate-lp`,{ideaTitle:De});we.success&&we.data?(D.value=we.data,q(),ue.info("ADMIN","Landing Page generiert",{ideaTitle:De})):O.value=we.error||"LP-Generierung fehlgeschlagen"}catch(we){O.value="Fehler bei der LP-Generierung",ue.error("ADMIN","Failed to generate LP for idea",we)}finally{oe.value.delete(De)}}}async function at(De){const we=d(De);switch(we.type){case"accept-all":await Fe();break;case"elaborate":await ut();break;case"generate-lp":await ge(we.payload);break;case"message":await ie(we.payload);break;default:ue.debug("ADMIN","Unknown CTA action",{action:we.type})}}function et(De){var tt;const we=(tt=D.value)==null?void 0:tt.ideas.find(kt=>kt.title.toLowerCase()===De.toLowerCase());return(we==null?void 0:we.status)||"suggested"}function it(De){var we;return((we=D.value)==null?void 0:we.ideas.findIndex(tt=>tt.title.toLowerCase()===De.toLowerCase()))??-1}const{renderMarkdown:$t}=bl();function yt(De){L.value=De,F.value=!0}async function We(De){var tt,kt;if(T.value){ue.warn("ADMIN","Speichern blockiert - kein Lock-Owner");return}if(!D.value)return;j.value=!0;const we=De.audienceType==="segment"&&De.segmentId?{segmentId:De.segmentId}:De.audienceType===((tt=D.value.audience)==null?void 0:tt.type)?((kt=D.value.audience)==null?void 0:kt.config)||{}:{};try{const zt=await re.put(`/email-campaigns/${g.value}`,{name:De.name,period:{startDate:De.startDate,endDate:De.endDate},frequency:De.frequency,audience:{type:De.audienceType,config:we}});zt.success&&zt.data?(D.value=zt.data,q(),z.value=!1):O.value=zt.error||"Fehler beim Speichern"}catch{O.value="Netzwerkfehler beim Speichern"}finally{j.value=!1}}async function Qe(){if(T.value){ue.warn("ADMIN","Extend blockiert - kein Lock-Owner");return}de.value=!0,Z.value=null;try{const De=await re.post(`/email-campaigns/${g.value}/extend-sequence`);De.success?(ce.value=!0,await lt(),ue.info("ADMIN","Sequence extended",{campaignId:g.value})):(Z.value=De.error||"Fehler beim Erweitern der Sequenz",ue.error("ADMIN","Failed to extend sequence",{error:De.error}))}catch(De){Z.value="Netzwerkfehler beim Erweitern der Sequenz",ue.error("ADMIN","Network error extending sequence",De)}finally{de.value=!1}}function At(){if(T.value){ue.warn("ADMIN","Aktivieren blockiert - kein Lock-Owner");return}J.value=!0}async function je(){if(!(T.value||te.value)){te.value=!0,O.value=null;try{const De=await re.post(`/email-campaigns/${g.value}/activate`);De.success?(J.value=!1,ve.value="Kampagne aktiviert.",await Ee(),ue.info("ADMIN","Campaign activated",{campaignId:g.value})):O.value=De.error||"Aktivierung fehlgeschlagen"}catch(De){O.value="Netzwerkfehler beim Aktivieren der Kampagne",ue.error("ADMIN","Failed to activate campaign",De)}finally{te.value=!1}}}async function he(){if(!(T.value||te.value)){te.value=!0,O.value=null;try{const De=await re.post(`/email-campaigns/${g.value}/pause`);De.success?(ve.value="Kampagne pausiert.",await Ee(),ue.info("ADMIN","Campaign paused",{campaignId:g.value})):O.value=De.error||"Pausieren fehlgeschlagen"}catch(De){O.value="Netzwerkfehler beim Pausieren der Kampagne",ue.error("ADMIN","Failed to pause campaign",De)}finally{te.value=!1}}}async function ze(){if(!(T.value||te.value)){te.value=!0,O.value=null;try{const De=await re.post(`/email-campaigns/${g.value}/resume`);De.success?(ve.value="Kampagne fortgesetzt.",await Ee(),ue.info("ADMIN","Campaign resumed",{campaignId:g.value})):O.value=De.error||"Fortsetzen fehlgeschlagen"}catch(De){O.value="Netzwerkfehler beim Fortsetzen der Kampagne",ue.error("ADMIN","Failed to resume campaign",De)}finally{te.value=!1}}}function Be(){T.value||te.value||(Q.value=!0)}async function bt(){if(!(T.value||te.value)){te.value=!0,O.value=null;try{const De=await re.post(`/email-campaigns/${g.value}/cancel`);De.success?(ve.value="Kampagne beendet.",Q.value=!1,await Ee(),ue.info("ADMIN","Campaign cancelled",{campaignId:g.value})):O.value=De.error||"Beenden fehlgeschlagen"}catch(De){O.value="Netzwerkfehler beim Beenden der Kampagne",ue.error("ADMIN","Failed to cancel campaign",De)}finally{te.value=!1}}}const pt=y(!1),It=y("");function Gt(){te.value||(It.value="",pt.value=!0)}async function vt(){if(!te.value&&It.value.trim().toLowerCase()==="löschen"){te.value=!0,O.value=null;try{const De=await re.delete(`/email-campaigns/${g.value}`);De.success?(ue.info("ADMIN","Campaign deleted",{campaignId:g.value}),k.push({name:"admin-email-campaigns"})):(O.value=De.error||"Löschen fehlgeschlagen",te.value=!1)}catch(De){O.value="Netzwerkfehler beim Löschen der Kampagne",ue.error("ADMIN","Failed to delete campaign",De),te.value=!1}}}return rt(async()=>{var De,we;ue.info("ADMIN","Email campaign detail view mounted",{campaignId:g.value}),await Ee(),await X(),((we=(De=D.value)==null?void 0:De.elaboration)==null?void 0:we.status)==="running"&&Ve()}),Ft(()=>{Le(),me()}),(De,we)=>{var Ht;const tt=l("v-btn"),kt=l("v-alert"),zt=l("v-progress-circular"),Et=l("v-icon"),Ot=l("v-snackbar"),Bt=l("v-card-title"),Oe=l("v-text-field"),Ct=l("v-card-text"),Rt=l("v-spacer"),qt=l("v-card-actions"),Qt=l("v-card"),Yt=l("v-dialog");return o(),h("div",{class:ft(["email-campaign-detail-view",{"email-campaign-detail-view--resizing":P(Y)}])},[a("div",D0,[e(tt,{variant:"text","prepend-icon":"mdi-arrow-left",size:"small",onClick:we[0]||(we[0]=st=>P(k).push({name:"admin-email-campaigns"}))},{default:t(()=>[...we[27]||(we[27]=[n(" Zurück zur Übersicht ",-1)])]),_:1})]),O.value?(o(),N(kt,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-3",style:{"max-height":"40px","min-height":"40px",overflow:"hidden"},closable:"","onClick:close":we[1]||(we[1]=st=>O.value=null)},{default:t(()=>[n(v(O.value),1)]),_:1})):U("",!0),e(ia,{"is-locked":P(w),"is-locked-by-me":P(b),"locked-by":P(I),"locked-at":P(V),"is-lock-taken-over":P(E),"taken-over-by":P(R),"on-take-over":P(M)},null,8,["is-locked","is-locked-by-me","locked-by","locked-at","is-lock-taken-over","taken-over-by","on-take-over"]),H.value&&!D.value?(o(),h("div",T0,[e(zt,{indeterminate:"",color:"primary"})])):S.value?(o(),h("div",L0,[e(Et,{size:"64",class:"mb-4"},{default:t(()=>[...we[28]||(we[28]=[n("mdi-email-off-outline",-1)])]),_:1}),we[30]||(we[30]=a("h2",{class:"text-h5 mb-2"},"Kampagne nicht gefunden",-1)),we[31]||(we[31]=a("p",{class:"text-body-2 mb-4"}," Die angeforderte Kampagne existiert nicht oder wurde gelöscht. ",-1)),e(tt,{color:"primary",to:{name:"admin-email-campaigns"}},{default:t(()=>[...we[29]||(we[29]=[n(" Zur Kampagnenübersicht ",-1)])]),_:1})])):U("",!0),D.value?(o(),h(be,{key:3},[e(Dx,{campaign:D.value,"frequency-label":le.value,"status-color":ne.value,"status-label":Ce.value,"format-date":P(f),"is-read-only":T.value,onEdit:we[2]||(we[2]=st=>z.value=!0),onActivate:At,onPause:he,onResume:ze,onCancel:Be,onDelete:Gt},null,8,["campaign","frequency-label","status-color","status-label","format-date","is-read-only"]),D.value.campaignType==="evergreen"&&D.value.status==="sending"?(o(),h("div",E0,[Z.value?(o(),N(kt,{key:0,type:"error",variant:"tonal",density:"compact",class:"py-1 px-3 flex-grow-1",closable:"","onClick:close":we[3]||(we[3]=st=>Z.value=null)},{default:t(()=>[n(v(Z.value),1)]),_:1})):U("",!0),e(tt,{color:"primary",variant:"tonal",size:"small","prepend-icon":"mdi-plus-circle-outline",loading:de.value,disabled:T.value,onClick:Qe},{default:t(()=>[...we[32]||(we[32]=[n(" Sequenz erweitern ",-1)])]),_:1},8,["loading","disabled"])])):U("",!0),a("div",M0,[a("div",{class:"email-campaign-detail-view__chat-panel",style:ht({width:P(ee)+"%"})},[e(t2,{messages:P(C),sending:P(ae),"has-markers":P(c),"get-idea-current-status":et,"get-idea-index-by-title":it,"render-markdown":P($t),"format-date":P(f),"get-idea-category-label":P(u),"truncate-text":P(p),onSend:P(ie),onClearChat:P(Se),onDeleteMessage:we[4]||(we[4]=st=>P(fe)(st.msg,st.index)),onCtaClick:at,onUpdateIdeaStatus:we[5]||(we[5]=st=>ct(st.index,st.status)),onConfirmUndo:we[6]||(we[6]=st=>mt(st.title,st.index))},null,8,["messages","sending","has-markers","render-markdown","format-date","get-idea-category-label","truncate-text","onSend","onClearChat"])],4),a("div",{class:"email-campaign-detail-view__divider",onMousedown:we[7]||(we[7]=(...st)=>P(K)&&P(K)(...st))},null,32),a("div",{class:"email-campaign-detail-view__topics-panel",style:ht({width:100-P(ee)+"%"})},[e(i2,{"active-tab":W.value,elaboration:D.value.elaboration,"ideas-count":D.value.ideas.length,"drafted-count":Ne.value.length,"lp-count":Ie.value.length,"onUpdate:activeTab":we[10]||(we[10]=st=>W.value=st)},{ideas:t(()=>[e(ww,{"accepted-ideas":ye.value,"suggested-ideas":Te.value,"drafted-ideas":ke.value,"approved-ideas":xe.value,"generating-ideas":Je.value,"skipped-ideas":Ke.value,"total-ideas-count":D.value.ideas.length,"can-elaborate":Ue.value,elaborating:B.value,"generating-lp-titles":pe.value,"is-read-only":T.value,"get-idea-status-color":P(s),"get-idea-status-label":P(m),"get-idea-category-label":P(u),"format-date":P(f),onOpenIdea:yt,onUpdateIdeaStatus:we[8]||(we[8]=st=>ct(st.index,st.status)),onConfirmUndo:we[9]||(we[9]=st=>mt(st.title,st.index)),onAcceptAll:Fe,onStartElaboration:ut,onDeleteSkipped:Xe},null,8,["accepted-ideas","suggested-ideas","drafted-ideas","approved-ideas","generating-ideas","skipped-ideas","total-ideas-count","can-elaborate","elaborating","generating-lp-titles","is-read-only","get-idea-status-color","get-idea-status-label","get-idea-category-label","format-date"])]),emails:t(()=>[e(Ew,{"drafted-ideas":Ne.value,"sending-test":Dt.value,"regenerating-title":St.value,"is-read-only":T.value,onOpenIdea:yt,onRegenerateEmail:Pt,onSendTest:Re},null,8,["drafted-ideas","sending-test","regenerating-title","is-read-only"])]),landingPages:t(()=>[e(Rw,{"topics-with-landing-page":Ie.value},null,8,["topics-with-landing-page"])]),stats:t(()=>[e(h0,{"campaign-id":g.value},null,8,["campaign-id"])]),deliveryLog:t(()=>[e(z0,{"campaign-id":g.value},null,8,["campaign-id"])]),_:1},8,["active-tab","elaboration","ideas-count","drafted-count","lp-count"])],4)])],64)):U("",!0),e(Ot,{modelValue:G.value,"onUpdate:modelValue":we[12]||(we[12]=st=>G.value=st),color:"success",location:"top end",timeout:4e3},{actions:t(()=>[e(tt,{variant:"text",onClick:we[11]||(we[11]=st=>G.value=!1)},{default:t(()=>[e(Et,null,{default:t(()=>[...we[33]||(we[33]=[n("mdi-close",-1)])]),_:1})]),_:1})]),default:t(()=>[we[34]||(we[34]=n(" E-Mail-Generierung abgeschlossen! ",-1))]),_:1},8,["modelValue"]),e(Ot,{modelValue:_t.value,"onUpdate:modelValue":we[14]||(we[14]=st=>_t.value=st),color:"success",location:"top end",timeout:4e3},{actions:t(()=>[e(tt,{variant:"text",onClick:we[13]||(we[13]=st=>_t.value=!1)},{default:t(()=>[e(Et,null,{default:t(()=>[...we[35]||(we[35]=[n("mdi-close",-1)])]),_:1})]),_:1})]),default:t(()=>[we[36]||(we[36]=n(" Test-E-Mail erfolgreich gesendet! ",-1))]),_:1},8,["modelValue"]),e(Ot,{modelValue:ce.value,"onUpdate:modelValue":we[16]||(we[16]=st=>ce.value=st),color:"success",location:"top end",timeout:4e3},{actions:t(()=>[e(tt,{variant:"text",onClick:we[15]||(we[15]=st=>ce.value=!1)},{default:t(()=>[e(Et,null,{default:t(()=>[...we[37]||(we[37]=[n("mdi-close",-1)])]),_:1})]),_:1})]),default:t(()=>[we[38]||(we[38]=n(" Sequenz erfolgreich erweitert! ",-1))]),_:1},8,["modelValue"]),e(wx,{modelValue:F.value,"onUpdate:modelValue":we[17]||(we[17]=st=>F.value=st),idea:L.value,"campaign-id":g.value,"is-read-only":T.value,"on-generate-email":Pt,"on-status-change":ct,"on-refine":st=>{F.value=!1,P(ie)(`Überarbeite die E-Mail '${st}'`)},onCampaignUpdated:we[18]||(we[18]=st=>{D.value=st})},null,8,["modelValue","idea","campaign-id","is-read-only","on-refine"]),e(jw,{modelValue:z.value,"onUpdate:modelValue":we[19]||(we[19]=st=>z.value=st),campaign:D.value,saving:j.value,onSave:We},null,8,["modelValue","campaign","saving"]),e(o0,{modelValue:J.value,"onUpdate:modelValue":we[20]||(we[20]=st=>J.value=st),"campaign-id":g.value,onConfirm:je},null,8,["modelValue","campaign-id"]),e(i0,{modelValue:Q.value,"onUpdate:modelValue":we[21]||(we[21]=st=>Q.value=st),"campaign-name":(Ht=D.value)==null?void 0:Ht.name,onConfirm:bt},null,8,["modelValue","campaign-name"]),e(Yt,{modelValue:pt.value,"onUpdate:modelValue":we[24]||(we[24]=st=>pt.value=st),"max-width":"500",persistent:""},{default:t(()=>[e(Qt,null,{default:t(()=>[e(Bt,{class:"text-error d-flex align-center ga-2"},{default:t(()=>[e(Et,{color:"error"},{default:t(()=>[...we[39]||(we[39]=[n("mdi-alert",-1)])]),_:1}),we[40]||(we[40]=n(" Kampagne löschen ",-1))]),_:1}),e(Ct,null,{default:t(()=>{var st;return[a("p",N0,[we[41]||(we[41]=n(" Du löschst die Kampagne ",-1)),a("strong",null,v((st=D.value)==null?void 0:st.name),1),we[42]||(we[42]=n(" unwiderruflich. ",-1))]),we[43]||(we[43]=a("p",{class:"mb-3 text-body-2"}," Mitgelöscht werden: alle Ideen, generierten E-Mail-Inhalte, die zugehörige Sequence inklusive Steps sowie die gesamte Chat-Historie. Bestehende Versand-Logs (EmailLog) bleiben für Audit-Zwecke erhalten. ",-1)),we[44]||(we[44]=a("p",{class:"mb-2 text-body-2"},[n(" Zur Bestätigung tippe "),a("code",null,"löschen"),n(" in das Feld: ")],-1)),e(Oe,{modelValue:It.value,"onUpdate:modelValue":we[22]||(we[22]=ra=>It.value=ra),placeholder:"löschen",density:"comfortable",variant:"outlined",autofocus:"","hide-details":""},null,8,["modelValue"])]}),_:1}),e(qt,null,{default:t(()=>[e(Rt),e(tt,{variant:"text",disabled:te.value,onClick:we[23]||(we[23]=st=>pt.value=!1)},{default:t(()=>[...we[45]||(we[45]=[n(" Abbrechen ",-1)])]),_:1},8,["disabled"]),e(tt,{color:"error",variant:"elevated",loading:te.value,disabled:It.value.trim().toLowerCase()!=="löschen",onClick:vt},{default:t(()=>[...we[46]||(we[46]=[n(" Endgültig löschen ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(Ot,{"model-value":!!ve.value,color:"success",location:"top end",timeout:4e3,"onUpdate:modelValue":we[26]||(we[26]=st=>ve.value=null)},{actions:t(()=>[e(tt,{variant:"text",onClick:we[25]||(we[25]=st=>ve.value=null)},{default:t(()=>[e(Et,null,{default:t(()=>[...we[47]||(we[47]=[n("mdi-close",-1)])]),_:1})]),_:1})]),default:t(()=>[n(v(ve.value)+" ",1)]),_:1},8,["model-value"]),e(qw,{"undo-idea":A.value,"target-status":$e.value,onConfirm:nt,onCancel:He},null,8,["undo-idea","target-status"])],2)}}}),B0=Me(U0,[["__scopeId","data-v-b47f3413"]]),I6=Object.freeze(Object.defineProperty({__proto__:null,default:B0},Symbol.toStringTag,{value:"Module"})),F0={class:"segment-list-view"},O0={class:"segment-list-view__header"},R0={key:3,class:"segment-list-view__list"},K0={class:"d-flex align-start justify-space-between gap-4"},j0={class:"flex-grow-1"},q0={class:"d-flex align-center ga-2 mb-1"},G0={class:"text-body-1 font-weight-bold"},H0={key:0,class:"text-body-2 text-medium-emphasis mb-3"},W0={class:"d-flex flex-wrap ga-1 mt-2"},Z0={key:0,class:"text-caption text-medium-emphasis d-flex align-center px-1 font-weight-bold",style:{color:"#C9A063"}},J0={key:0,class:"text-caption text-medium-emphasis d-flex align-center px-1"},Q0={class:"text-caption text-medium-emphasis mt-3"},Y0={class:"text-right flex-shrink-0"},X0={class:"text-h4 font-weight-bold",style:{color:"rgb(var(--v-theme-primary))"}},eS={class:"d-flex align-center justify-space-between"},tS={class:"text-body-1"},aS=Ae({__name:"SegmentListView",setup(r){xt();const $=y([]),d=y(!1),c=y(null),s=y(!1),m=y(null),u=y(""),f=y(!1),p=y(null);function _(I){var V;return((V=pa.find(E=>E.key===I))==null?void 0:V.label)??I}function k(I){return Fa[I]??I}function i(I){return I?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(new Date(I)):"-"}async function g(){d.value=!0,c.value=null;try{const I=await re.get("/admin/segments");I.success&&I.data?$.value=I.data:c.value=I.error||"Fehler beim Laden der Segmente"}catch{c.value="Netzwerkfehler beim Laden der Segmente"}finally{d.value=!1}}function x(I){m.value=I._id,u.value=I.name,p.value=null,s.value=!0}function w(){s.value=!1,m.value=null,p.value=null}async function b(){if(m.value){f.value=!0,p.value=null;try{const I=await re.delete(`/admin/segments/${m.value}`);I.success?(w(),await g()):p.value=I.error||"Fehler beim Löschen des Segments"}catch{p.value="Netzwerkfehler beim Löschen"}finally{f.value=!1}}}return rt(()=>{g()}),(I,V)=>{const E=l("v-btn"),R=l("v-progress-linear"),M=l("v-alert"),T=l("v-icon"),D=l("v-card-text"),H=l("v-card"),O=l("v-chip"),S=l("v-divider"),B=l("v-spacer"),G=l("v-card-actions"),W=l("v-card-title"),F=l("v-dialog");return o(),h("div",F0,[a("div",O0,[V[3]||(V[3]=a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"Segmente"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," Gespeicherte Filter-Kombinationen für gezielte Kampagnen-Zielgruppen ")],-1)),e(E,{color:"primary","prepend-icon":"mdi-plus",to:{name:"admin-segment-neu"}},{default:t(()=>[...V[2]||(V[2]=[n(" Neues Segment ",-1)])]),_:1})]),d.value?(o(),N(R,{key:0,indeterminate:"",color:"primary",class:"mb-4"})):U("",!0),c.value?(o(),N(M,{key:1,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":V[0]||(V[0]=L=>c.value=null)},{default:t(()=>[n(v(c.value),1)]),_:1})):U("",!0),!d.value&&!$.value.length?(o(),N(H,{key:2,variant:"outlined",class:"segment-list-view__empty"},{default:t(()=>[e(D,{class:"text-center pa-12"},{default:t(()=>[e(T,{size:"64",color:"medium-emphasis",class:"mb-4"},{default:t(()=>[...V[4]||(V[4]=[n("mdi-filter-variant",-1)])]),_:1}),V[6]||(V[6]=a("p",{class:"text-h6 font-weight-medium mb-2"},"Keine Segmente vorhanden",-1)),V[7]||(V[7]=a("p",{class:"text-body-2 text-medium-emphasis mb-6"}," Erstelle dein erstes Segment, um Leads gezielt für Kampagnen zu filtern. ",-1)),e(E,{color:"primary","prepend-icon":"mdi-plus",to:{name:"admin-segment-neu"}},{default:t(()=>[...V[5]||(V[5]=[n(" Erstes Segment erstellen ",-1)])]),_:1})]),_:1})]),_:1})):U("",!0),!d.value&&$.value.length?(o(),h("div",R0,[(o(!0),h(be,null,Pe($.value,L=>(o(),N(H,{key:L._id,variant:"outlined",class:"segment-list-view__card mb-3"},{default:t(()=>[e(D,{class:"pa-5"},{default:t(()=>[a("div",K0,[a("div",j0,[a("div",q0,[a("span",G0,v(L.name),1),L.isActive?U("",!0):(o(),N(O,{key:0,size:"x-small",color:"default",variant:"tonal"},{default:t(()=>[...V[8]||(V[8]=[n(" Inaktiv ",-1)])]),_:1}))]),L.description?(o(),h("p",H0,v(L.description),1)):U("",!0),a("div",W0,[(o(!0),h(be,null,Pe(L.filterGroups,(A,z)=>(o(),h(be,{key:z},[z>0?(o(),h("span",Z0," UND ")):U("",!0),(o(!0),h(be,null,Pe(A.conditions,(j,J)=>(o(),h(be,{key:`${z}-${J}`},[J>0?(o(),h("span",J0," ODER ")):U("",!0),e(O,{size:"x-small",color:j.field==="tags"?"primary":j.field==="pipeline.stage"?void 0:"",style:ht(j.field==="pipeline.stage"?"color: #C9A063; border-color: #C9A063":""),variant:"tonal"},{default:t(()=>[n(v(_(j.field))+" "+v(k(j.operator))+" ",1),j.operator!=="exists"?(o(),h(be,{key:0},[n(v(Array.isArray(j.value)?j.value.join(", "):String(j.value??"")),1)],64)):U("",!0)]),_:2},1032,["color","style"])],64))),128))],64))),128))]),a("div",Q0," Zuletzt geändert: "+v(i(L.updatedAt)),1)]),a("div",Y0,[a("div",X0,v(L.estimatedSize),1),V[9]||(V[9]=a("div",{class:"text-caption text-medium-emphasis"},"Leads",-1))])])]),_:2},1024),e(S),e(G,{class:"px-5 py-3"},{default:t(()=>[e(E,{variant:"text",color:"primary",size:"small","prepend-icon":"mdi-pencil",to:{name:"admin-segment-edit",params:{id:L._id}}},{default:t(()=>[...V[10]||(V[10]=[n(" Bearbeiten ",-1)])]),_:1},8,["to"]),e(B),e(E,{variant:"text",color:"error",size:"small","prepend-icon":"mdi-delete-outline",onClick:A=>x(L)},{default:t(()=>[...V[11]||(V[11]=[n(" Löschen ",-1)])]),_:1},8,["onClick"])]),_:2},1024)]),_:2},1024))),128))])):U("",!0),e(F,{modelValue:s.value,"onUpdate:modelValue":V[1]||(V[1]=L=>s.value=L),"max-width":"440"},{default:t(()=>[e(H,null,{default:t(()=>[e(W,{class:"pa-6 pb-4"},{default:t(()=>[a("div",eS,[V[13]||(V[13]=a("span",{class:"text-h6"},"Segment löschen",-1)),e(E,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:w},{default:t(()=>[e(T,null,{default:t(()=>[...V[12]||(V[12]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(S),e(D,{class:"pa-6"},{default:t(()=>[p.value?(o(),N(M,{key:0,type:"error",variant:"tonal",class:"mb-4"},{default:t(()=>[n(v(p.value),1)]),_:1})):U("",!0),a("p",tS,[V[14]||(V[14]=n(" Soll das Segment ",-1)),a("strong",null,v(u.value),1),V[15]||(V[15]=n(" wirklich gelöscht werden? ",-1))]),V[16]||(V[16]=a("p",{class:"text-body-2 text-medium-emphasis mt-2"}," Kampagnen, die dieses Segment verwenden, sind danach nicht mehr vollständig konfiguriert. ",-1))]),_:1}),e(S),e(G,{class:"pa-4"},{default:t(()=>[e(B),e(E,{variant:"text",onClick:w},{default:t(()=>[...V[17]||(V[17]=[n("Abbrechen",-1)])]),_:1}),e(E,{color:"error",variant:"elevated",loading:f.value,onClick:b},{default:t(()=>[...V[18]||(V[18]=[n(" Löschen ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}}),lS=Me(aS,[["__scopeId","data-v-8db25776"]]),P6=Object.freeze(Object.defineProperty({__proto__:null,default:lS},Symbol.toStringTag,{value:"Module"})),nS={class:"segment-builder"},oS={key:0,class:"segment-builder__and-divider"},sS={class:"d-flex align-center justify-space-between mb-3"},iS={class:"text-body-2 text-medium-emphasis font-weight-medium"},rS={key:0,class:"segment-builder__or-divider"},dS={class:"segment-builder__condition-row d-flex align-center ga-2"},uS={key:1,class:"segment-builder__value-input text-caption text-medium-emphasis d-flex align-center px-2"},cS=Ae({__name:"SegmentBuilder",props:{modelValue:{}},emits:["update:modelValue"],setup(r,{emit:$}){const d=r,c=$;function s(V){return pa.find(E=>E.key===V)??null}function m(V){const E=s(V);return E?E.operators.map(R=>({title:Fa[R],value:R})):[]}function u(){return pa.map(V=>({title:V.label,value:V.key}))}function f(V){c("update:modelValue",V)}function p(){const V={conditions:[{field:"",operator:"eq",value:null}]};f([...d.modelValue,V])}function _(V){const E=d.modelValue.filter((R,M)=>M!==V);f(E)}function k(V){const E={field:"",operator:"eq",value:null},R=d.modelValue.map((M,T)=>T===V?{...M,conditions:[...M.conditions,E]}:M);f(R)}function i(V,E){const R=d.modelValue.map((M,T)=>{if(T!==V)return M;const D=M.conditions.filter((H,O)=>O!==E);return{...M,conditions:D}});f(R)}function g(V,E,R){const M=d.modelValue.map((T,D)=>{if(D!==V)return T;const H=T.conditions.map((O,S)=>{if(S!==E)return O;const B=s(R),G=(B==null?void 0:B.operators[0])??"eq";return{field:R,operator:G,value:null}});return{...T,conditions:H}});f(M)}function x(V,E,R){const M=d.modelValue.map((T,D)=>{if(D!==V)return T;const H=T.conditions.map((O,S)=>{if(S!==E)return O;const B=R==="exists"||O.operator==="exists"?null:O.value;return{...O,operator:R,value:B}});return{...T,conditions:H}});f(M)}function w(V,E,R){const M=d.modelValue.map((T,D)=>{if(D!==V)return T;const H=T.conditions.map((O,S)=>S!==E?O:{...O,value:R});return{...T,conditions:H}});f(M)}const b=se(()=>d.modelValue),I=[{title:"Ja",value:!0},{title:"Nein",value:!1}];return(V,E)=>{const R=l("v-tooltip"),M=l("v-icon"),T=l("v-btn"),D=l("v-select"),H=l("v-combobox"),O=l("v-text-field"),S=l("v-card-text"),B=l("v-card");return o(),h("div",nS,[(o(!0),h(be,null,Pe(b.value,(G,W)=>(o(),h("div",{key:W,class:"segment-builder__group-wrapper"},[W>0?(o(),h("div",oS,[...E[0]||(E[0]=[a("span",{class:"segment-builder__and-label"},"UND",-1)])])):U("",!0),e(B,{class:"segment-builder__group",variant:"outlined",style:{"border-left":"3px solid rgb(var(--v-theme-primary))"}},{default:t(()=>[e(S,{class:"pa-4"},{default:t(()=>[a("div",sS,[a("span",iS," Gruppe "+v(W+1),1),b.value.length>1?(o(),N(T,{key:0,icon:"",size:"x-small",variant:"text",color:"error","aria-label":"Gruppe entfernen",onClick:F=>_(W)},{default:t(()=>[e(R,{activator:"parent",location:"top"},{default:t(()=>[...E[1]||(E[1]=[n("Gruppe entfernen",-1)])]),_:1}),e(M,{size:"16"},{default:t(()=>[...E[2]||(E[2]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["onClick"])):U("",!0)]),(o(!0),h(be,null,Pe(G.conditions,(F,L)=>{var A,z,j,J,Q;return o(),h("div",{key:L,class:"segment-builder__condition-wrapper"},[L>0?(o(),h("div",rS,[...E[3]||(E[3]=[a("span",{class:"text-caption text-medium-emphasis"},"ODER",-1)])])):U("",!0),a("div",dS,[e(D,{"model-value":F.field,items:u(),label:"Feld",variant:"outlined",density:"compact","hide-details":"",class:"segment-builder__field-select","onUpdate:modelValue":te=>g(W,L,te)},null,8,["model-value","items","onUpdate:modelValue"]),e(D,{"model-value":F.operator,items:m(F.field),label:"Operator",variant:"outlined",density:"compact","hide-details":"",class:"segment-builder__operator-select",disabled:!F.field,"onUpdate:modelValue":te=>x(W,L,te)},null,8,["model-value","items","disabled","onUpdate:modelValue"]),F.field&&F.operator!=="exists"?(o(),h(be,{key:0},[((A=s(F.field))==null?void 0:A.type)==="boolean"?(o(),N(D,{key:0,"model-value":F.value,items:I,label:"Wert",variant:"outlined",density:"compact","hide-details":"",class:"segment-builder__value-input","onUpdate:modelValue":te=>w(W,L,te)},null,8,["model-value","onUpdate:modelValue"])):((z=s(F.field))==null?void 0:z.type)==="enum"?(o(),N(H,{key:1,"model-value":F.value??[],items:((j=s(F.field))==null?void 0:j.options)??[],label:"Wert(e)",variant:"outlined",density:"compact","hide-details":"",multiple:"",chips:"","closable-chips":"",class:"segment-builder__value-input","onUpdate:modelValue":te=>w(W,L,te)},null,8,["model-value","items","onUpdate:modelValue"])):((J=s(F.field))==null?void 0:J.type)==="array"?(o(),N(H,{key:2,"model-value":F.value??[],label:"Wert(e)",variant:"outlined",density:"compact","hide-details":"",multiple:"",chips:"","closable-chips":"",class:"segment-builder__value-input","onUpdate:modelValue":te=>w(W,L,te)},null,8,["model-value","onUpdate:modelValue"])):((Q=s(F.field))==null?void 0:Q.type)==="number"?(o(),N(O,{key:3,"model-value":F.value,label:"Wert",type:"number",variant:"outlined",density:"compact","hide-details":"",class:"segment-builder__value-input","onUpdate:modelValue":te=>w(W,L,te===""?null:Number(te))},null,8,["model-value","onUpdate:modelValue"])):(o(),N(O,{key:4,"model-value":F.value,label:"Wert",variant:"outlined",density:"compact","hide-details":"",class:"segment-builder__value-input","onUpdate:modelValue":te=>w(W,L,te)},null,8,["model-value","onUpdate:modelValue"]))],64)):F.operator==="exists"?(o(),h("div",uS," (kein Wert benötigt) ")):U("",!0),e(T,{icon:"",size:"x-small",variant:"text",color:"error","aria-label":"Bedingung entfernen",disabled:G.conditions.length===1,onClick:te=>i(W,L)},{default:t(()=>[e(R,{activator:"parent",location:"top"},{default:t(()=>[...E[4]||(E[4]=[n("Bedingung entfernen",-1)])]),_:1}),e(M,{size:"16"},{default:t(()=>[...E[5]||(E[5]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["disabled","onClick"])])])}),128)),e(T,{variant:"text",color:"primary",size:"small","prepend-icon":"mdi-plus",class:"mt-3",onClick:F=>k(W)},{default:t(()=>[...E[6]||(E[6]=[n(" Bedingung hinzufügen ",-1)])]),_:1},8,["onClick"])]),_:2},1024)]),_:2},1024)]))),128)),e(T,{variant:"outlined",color:"primary",size:"small","prepend-icon":"mdi-plus",class:"segment-builder__add-group mt-4",onClick:p},{default:t(()=>[...E[7]||(E[7]=[n(" Neue Gruppe hinzufügen (UND) ",-1)])]),_:1})])}}}),mS=Me(cS,[["__scopeId","data-v-8115983c"]]),vS={class:"segment-edit-view"},pS={class:"segment-edit-view__header"},fS={class:"d-flex align-center ga-3"},gS={class:"text-h5 font-weight-bold"},bS={key:0,class:"d-flex justify-center pa-12"},yS={class:"d-flex align-center justify-space-between"},_S={class:"text-right"},kS={class:"text-h4 font-weight-bold",style:{color:"rgb(var(--v-theme-primary))"}},hS={key:2,class:"text-body-2 text-medium-emphasis"},xS=Ae({__name:"SegmentEditView",setup(r){const $=xt(),d=Ut(),c=se(()=>{const O=d.params.id;return typeof O=="string"?O:null}),s=se(()=>!c.value),m=y(!1),u=y(null),f=y(!1),p=y(null),_=y(!1),k=y(null),i=wt({name:"",description:"",filterGroups:[]}),g=y(null),x=y(!1);let w=null;const b=[O=>!!O||"Name ist erforderlich",O=>O.length>=2||"Mindestens 2 Zeichen"],I=se(()=>s.value?"Neues Segment":"Segment bearbeiten");function V(O){if(!O.field||O.field.length===0)return!1;const S=pa.find(B=>B.key===O.field);if(!S||!S.operators.includes(O.operator))return!1;if(O.value===void 0||O.value===null){if(O.operator!=="exists")return!1}else if(Array.isArray(O.value)&&O.value.length===0||O.operator==="contains"&&(typeof O.value!="string"||O.value.length>200)||S.type==="number"&&(typeof O.value!="number"||isNaN(O.value)))return!1;return!0}function E(O){const S=[];for(const B of O){if(!Array.isArray(B.conditions))continue;const G=B.conditions.filter(V);G.length>0&&S.push({...B,conditions:G})}return S}async function R(){const O=E(i.filterGroups);if(O.length===0){g.value=null;return}x.value=!0;try{const S=await re.post("/admin/segments/count",{filterGroups:O});S.success&&S.data?g.value=S.data.count:g.value=null}catch{g.value=null}finally{x.value=!1}}function M(){w&&clearTimeout(w),w=setTimeout(()=>{R()},500)}Ze(()=>i.filterGroups,()=>{M()},{deep:!0});async function T(){var O;if(c.value){m.value=!0,u.value=null;try{const S=await re.get(`/admin/segments/${c.value}`);if(S.success&&S.data){const B=S.data;i.name=B.name,i.description=B.description??"",i.filterGroups=B.filterGroups??[],await Wt(),(O=k.value)==null||O.validate()}else u.value=S.error||"Fehler beim Laden des Segments"}catch{u.value="Netzwerkfehler beim Laden des Segments"}finally{m.value=!1}}}async function D(){if(!_.value)return;f.value=!0,p.value=null;const O={name:i.name,description:i.description||void 0,filterGroups:i.filterGroups};try{let S;s.value?S=await re.post("/admin/segments",O):S=await re.put(`/admin/segments/${c.value}`,O),S.success?$.push({name:"admin-segmente"}):p.value=S.error||"Fehler beim Speichern des Segments"}catch{p.value="Netzwerkfehler beim Speichern"}finally{f.value=!1}}function H(){$.push({name:"admin-segmente"})}return Ft(()=>{w&&(clearTimeout(w),w=null)}),rt(()=>{s.value?i.filterGroups=[{conditions:[{field:"",operator:"eq",value:null}]}]:T()}),(O,S)=>{const B=l("v-tooltip"),G=l("v-icon"),W=l("v-btn"),F=l("v-progress-circular"),L=l("v-alert"),A=l("v-text-field"),z=l("v-textarea"),j=l("v-card-text"),J=l("v-card"),Q=l("v-form"),te=l("v-divider"),ve=l("v-spacer"),de=l("v-card-actions");return o(),h("div",vS,[a("div",pS,[a("div",fS,[e(W,{icon:"",variant:"text",size:"small","aria-label":"Zurück",to:{name:"admin-segmente"}},{default:t(()=>[e(B,{activator:"parent",location:"right"},{default:t(()=>[...S[6]||(S[6]=[n("Zurück zur Übersicht",-1)])]),_:1}),e(G,null,{default:t(()=>[...S[7]||(S[7]=[n("mdi-arrow-left",-1)])]),_:1})]),_:1}),a("div",null,[a("h1",gS,v(I.value),1),S[8]||(S[8]=a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," Filter-Kombinationen für gezielte Kampagnen-Zielgruppen ",-1))])])]),m.value?(o(),h("div",bS,[e(F,{indeterminate:"",color:"primary"})])):U("",!0),u.value?(o(),N(L,{key:1,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":S[0]||(S[0]=Z=>u.value=null)},{default:t(()=>[n(v(u.value),1)]),_:1})):U("",!0),m.value?U("",!0):(o(),N(J,{key:2,variant:"outlined",class:"segment-edit-view__card"},{default:t(()=>[e(j,{class:"pa-6"},{default:t(()=>[p.value?(o(),N(L,{key:0,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":S[1]||(S[1]=Z=>p.value=null)},{default:t(()=>[n(v(p.value),1)]),_:1})):U("",!0),e(Q,{ref_key:"formRef",ref:k,modelValue:_.value,"onUpdate:modelValue":S[5]||(S[5]=Z=>_.value=Z),onSubmit:dt(D,["prevent"])},{default:t(()=>[e(A,{modelValue:i.name,"onUpdate:modelValue":S[2]||(S[2]=Z=>i.name=Z),label:"Name des Segments",rules:b,placeholder:"z.B. Hot Leads aus Website-Formularen",variant:"outlined",density:"comfortable",class:"mb-4"},null,8,["modelValue"]),e(z,{modelValue:i.description,"onUpdate:modelValue":S[3]||(S[3]=Z=>i.description=Z),label:"Beschreibung (optional)",placeholder:"Wofür wird dieses Segment verwendet?",variant:"outlined",density:"comfortable",rows:"2","auto-grow":"",class:"mb-6"},null,8,["modelValue"]),S[11]||(S[11]=a("div",{class:"segment-edit-view__builder-label text-body-2 font-weight-medium mb-3"}," Filter-Bedingungen ",-1)),S[12]||(S[12]=a("p",{class:"text-caption text-medium-emphasis mb-4"}," Bedingungen innerhalb einer Gruppe sind ODER-verknüpft. Gruppen sind untereinander UND-verknüpft. ",-1)),e(mS,{modelValue:i.filterGroups,"onUpdate:modelValue":S[4]||(S[4]=Z=>i.filterGroups=Z)},null,8,["modelValue"]),e(J,{variant:"outlined",class:"segment-edit-view__count-card mt-6"},{default:t(()=>[e(j,{class:"pa-4"},{default:t(()=>[a("div",yS,[S[10]||(S[10]=a("span",{class:"text-body-2 text-medium-emphasis"},"Passende Leads (Vorschau)",-1)),a("div",_S,[x.value?(o(),N(F,{key:0,indeterminate:"",color:"primary",size:"24"})):g.value!==null?(o(),h(be,{key:1},[a("span",kS,v(g.value),1),S[9]||(S[9]=a("span",{class:"text-body-2 text-medium-emphasis ml-1"},"passende Leads",-1))],64)):(o(),h("span",hS," Bedingungen definieren, um Leads zu zählen "))])])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1}),e(te),e(de,{class:"pa-4"},{default:t(()=>[e(W,{variant:"text",onClick:H},{default:t(()=>[...S[13]||(S[13]=[n("Abbrechen",-1)])]),_:1}),e(ve),e(W,{color:"primary",variant:"elevated",loading:f.value,disabled:!_.value,onClick:D},{default:t(()=>[n(v(s.value?"Segment erstellen":"Speichern"),1)]),_:1},8,["loading","disabled"])]),_:1})]),_:1}))])}}}),wS=Me(xS,[["__scopeId","data-v-b3571dbd"]]),z6=Object.freeze(Object.defineProperty({__proto__:null,default:wS},Symbol.toStringTag,{value:"Module"})),Vl=Ae({__name:"MeetingStatusChip",props:{status:{}},setup(r){const $=r;function d(s){return{scheduled:"info",completed:"success","no-show":"warning",cancelled:"error"}[s]||"default"}function c(s){return{scheduled:"Geplant",completed:"Abgeschlossen","no-show":"No-Show",cancelled:"Abgesagt"}[s]||s}return(s,m)=>{const u=l("v-chip");return o(),N(u,{color:d($.status),size:"small",variant:"tonal"},{default:t(()=>[n(v(c($.status)),1)]),_:1},8,["color"])}}}),SS={class:"note-item__header"},$S={class:"note-item__meta"},CS={class:"text-medium-emphasis"},VS={key:0,class:"text-medium-emphasis"},AS={key:0,class:"note-item__actions"},IS={key:1,class:"note-item__confirm"},PS={key:0,class:"note-item__text"},zS={key:1,class:"note-item__edit"},DS={class:"d-flex justify-end ga-2 mt-2"},TS=Ae({__name:"MeetingNoteItem",props:{note:{},updating:{type:Boolean},deleting:{type:Boolean},disabled:{type:Boolean,default:!1}},emits:["update","delete"],setup(r,{emit:$}){const d=r,c=$,s=y(!1),m=y(""),u=y(!1),f=se(()=>{const I=d.note.createdBy;if(!I||typeof I=="string")return"System";const V=[I.firstName,I.lastName].filter(E=>typeof E=="string"&&E.trim().length>0).join(" ").trim();return V||(I.email?I.email:"System")}),p=se(()=>_(d.note.createdAt));function _(I){const V=new Date(I),E=Date.now()-V.getTime(),R=Math.floor(E/6e4);if(R<1)return"gerade eben";if(R<60)return`vor ${R} Min`;const M=Math.floor(R/60);if(M<24)return`vor ${M} Std`;const T=Math.floor(M/24);return T<30?`vor ${T} ${T===1?"Tag":"Tagen"}`:V.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}function k(){d.disabled||(m.value=d.note.text,s.value=!0)}function i(){s.value=!1,m.value=""}function g(){if(d.disabled)return;const I=m.value.trim();if(I){if(I===d.note.text){i();return}c("update",d.note._id,I),s.value=!1}}function x(){d.disabled||(u.value=!0)}function w(){u.value=!1}function b(){d.disabled||(u.value=!1,c("delete",d.note._id))}return(I,V)=>{const E=l("v-tooltip"),R=l("v-icon"),M=l("v-btn"),T=l("v-textarea"),D=l("v-card-text"),H=l("v-card");return o(),N(H,{variant:"tonal",class:"note-item",density:"compact"},{default:t(()=>[e(D,{class:"pa-3"},{default:t(()=>[a("div",SS,[a("div",$S,[a("strong",null,v(f.value),1),a("span",CS," · "+v(p.value),1),r.note.updatedAt?(o(),h("span",VS," · bearbeitet")):U("",!0)]),!s.value&&!u.value?(o(),h("div",AS,[e(M,{icon:"",size:"x-small",variant:"text","aria-label":"Bearbeiten",disabled:r.disabled||r.updating||r.deleting,onClick:k},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[n(v(r.disabled?"Erst Termin-Änderungen speichern oder abbrechen":"Bearbeiten"),1)]),_:1}),e(R,{size:"16"},{default:t(()=>[...V[1]||(V[1]=[n("mdi-pencil",-1)])]),_:1})]),_:1},8,["disabled"]),e(M,{icon:"",size:"x-small",variant:"text",color:"error","aria-label":"Löschen",disabled:r.disabled||r.updating||r.deleting,onClick:x},{default:t(()=>[e(E,{activator:"parent",location:"bottom"},{default:t(()=>[n(v(r.disabled?"Erst Termin-Änderungen speichern oder abbrechen":"Löschen"),1)]),_:1}),e(R,{size:"16"},{default:t(()=>[...V[2]||(V[2]=[n("mdi-delete-outline",-1)])]),_:1})]),_:1},8,["disabled"])])):u.value?(o(),h("div",IS,[V[5]||(V[5]=a("span",{class:"note-item__confirm-text"},"Wirklich löschen?",-1)),e(M,{size:"x-small",variant:"text",disabled:r.deleting,onClick:w},{default:t(()=>[...V[3]||(V[3]=[n(" Abbrechen ",-1)])]),_:1},8,["disabled"]),e(M,{size:"x-small",color:"error",loading:r.deleting,disabled:r.disabled,onClick:b},{default:t(()=>[...V[4]||(V[4]=[n(" Löschen ",-1)])]),_:1},8,["loading","disabled"])])):U("",!0)]),s.value?(o(),h("div",zS,[e(T,{modelValue:m.value,"onUpdate:modelValue":V[0]||(V[0]=O=>m.value=O),rows:"2","auto-grow":"","hide-details":"",variant:"outlined",density:"compact",disabled:r.disabled||r.updating,autofocus:"",onKeydown:[Kt(dt(g,["ctrl"]),["enter"]),Kt(dt(g,["meta"]),["enter"]),Kt(i,["esc"])]},null,8,["modelValue","disabled","onKeydown"]),a("div",DS,[e(M,{size:"x-small",variant:"text",disabled:r.updating,onClick:i},{default:t(()=>[...V[6]||(V[6]=[n(" Abbrechen ",-1)])]),_:1},8,["disabled"]),e(M,{size:"x-small",color:"primary",loading:r.updating,disabled:r.disabled||!m.value.trim(),onClick:g},{default:t(()=>[...V[7]||(V[7]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled"])])])):(o(),h("div",PS,v(r.note.text),1))]),_:1})]),_:1})}}}),LS=Me(TS,[["__scopeId","data-v-47faebdf"]]),ES={class:"d-flex align-center justify-space-between w-100"},MS={class:"d-flex align-center ga-3"},NS={class:"d-flex align-center ga-2"},US={class:"meeting-detail-modal__section"},BS={class:"meeting-detail-modal__info-row"},FS={class:"text-body-2 font-weight-medium"},OS={key:0,class:"meeting-detail-modal__info-row"},RS={class:"text-body-2 text-medium-emphasis"},KS={key:1,class:"meeting-detail-modal__info-row"},jS={class:"text-body-2 text-medium-emphasis"},qS={key:0,class:"meeting-edit-lead-section"},GS={key:1,class:"text-medium-emphasis text-body-2"},HS={class:"meeting-detail-modal__section"},WS={class:"meeting-detail-modal__detail-item"},ZS={class:"text-body-2"},JS={class:"meeting-detail-modal__detail-item"},QS={class:"text-body-2"},YS={class:"meeting-detail-modal__detail-item"},XS={class:"text-body-2"},e$={class:"meeting-detail-modal__detail-item"},t$={class:"text-body-2"},a$={class:"meeting-detail-modal__detail-item"},l$={class:"text-body-2"},n$={class:"mt-4"},o$={class:"meeting-notes"},s$={class:"meeting-notes__title"},i$={class:"meeting-notes__input mt-3"},r$={class:"d-flex justify-end mt-2"},d$={class:"meeting-notes__log mt-4"},u$={key:0,class:"meeting-notes__empty"},c$={key:1,class:"meeting-notes__items"},m$={key:2,class:"mt-4"},v$={class:"meeting-detail-modal__section"},p$={class:"d-flex flex-wrap ga-2"},f$=Ae({__name:"MeetingDetailModal",props:{meeting:{},modelValue:{type:Boolean}},emits:["update:modelValue","statusUpdated","noteAdded","noteUpdated","noteDeleted","meetingUpdated","leadUpdated"],setup(r,{emit:$}){const d=r,c=$,s=y(!1),m=y(null),u=y(""),f=y(!1),p=y(null),_=y(null),k=y(null),i=y(!1),g=y(!1),x=y(null),w=y(null),b=wt({firstName:"",lastName:"",email:"",company:"",topic:"",scheduledAt:"",durationMinutes:30,status:"scheduled"}),I=[{title:"NIS2",value:"nis2"},{title:"DORA",value:"dora"},{title:"Pentesting",value:"pentesting"},{title:"ISMS",value:"isms"},{title:"Incident Response",value:"incident-response"},{title:"Cloud Security",value:"cloud-security"},{title:"Compliance",value:"compliance"},{title:"Awareness",value:"awareness"},{title:"Allgemein",value:"allgemein"}],V=[{title:"Geplant",value:"scheduled"},{title:"Abgeschlossen",value:"completed"},{title:"No-Show",value:"no-show"},{title:"Abgesagt",value:"cancelled"}];function E(q){return q?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(q)||"Ungültige E-Mail-Adresse":"E-Mail ist erforderlich"}const R=se({get:()=>d.modelValue,set:q=>c("update:modelValue",q)}),M=se(()=>{var q;return(q=d.meeting)!=null&&q.leadId?typeof d.meeting.leadId=="object"?`${d.meeting.leadId.firstName} ${d.meeting.leadId.lastName}`:String(d.meeting.leadId):"Unbekannter Lead"}),T=se(()=>{var q;return!((q=d.meeting)!=null&&q.leadId)||typeof d.meeting.leadId!="object"?"":d.meeting.leadId.email}),D=se(()=>{var q;return!((q=d.meeting)!=null&&q.leadId)||typeof d.meeting.leadId!="object"?"":d.meeting.leadId.company||""}),H=se(()=>{var q;return(q=d.meeting)!=null&&q.leadId?typeof d.meeting.leadId=="object"?d.meeting.leadId._id:d.meeting.leadId:null}),O=se(()=>{var q;return((q=d.meeting)==null?void 0:q.notesLog)??[]}),S=se(()=>[...O.value].sort((q,C)=>new Date(C.createdAt).getTime()-new Date(q.createdAt).getTime()));function B(q){return{nis2:"NIS2",dora:"DORA",pentesting:"Pentesting",isms:"ISMS","incident-response":"Incident Response","cloud-security":"Cloud Security",compliance:"Compliance",awareness:"Awareness",allgemein:"Allgemein"}[q]||q}function G(q){return q?{"form-cta":"Buchungsformular",manual:"Manuell eingetragen",hubspot:"HubSpot",website:"Website"}[q]||q:"Unbekannt"}function W(q){return q?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(q)):"–"}const F=se(()=>{var q;return(q=d.meeting)!=null&&q.leadId&&typeof d.meeting.leadId=="object"?d.meeting.leadId:null});function L(q){if(!q)return"";const C=new Date(q),ae=C.getTimezoneOffset()*6e4;return new Date(C.getTime()-ae).toISOString().substring(0,16)}function A(){if(!d.meeting)return;const q=F.value;b.firstName=(q==null?void 0:q.firstName)??"",b.lastName=(q==null?void 0:q.lastName)??"",b.email=(q==null?void 0:q.email)??"",b.company=(q==null?void 0:q.company)??"",b.topic=d.meeting.topic??"",b.scheduledAt=L(d.meeting.scheduledAt),b.durationMinutes=d.meeting.durationMinutes??30,b.status=d.meeting.status??"scheduled"}function z(){d.meeting&&(A(),x.value=null,i.value=!0,Wt(()=>{const q=w.value;if(!q)return;const C=q.$el,ae=C==null?void 0:C.querySelector("input");ae==null||ae.focus()}))}function j(){A(),i.value=!1,x.value=null}const J=se(()=>{if(!i.value||!d.meeting)return!1;const q=F.value;return b.firstName!==((q==null?void 0:q.firstName)??"")||b.lastName!==((q==null?void 0:q.lastName)??"")||b.email!==((q==null?void 0:q.email)??"")||b.company!==((q==null?void 0:q.company)??"")||b.topic!==(d.meeting.topic??"")||b.scheduledAt!==L(d.meeting.scheduledAt)||b.durationMinutes!==(d.meeting.durationMinutes??30)||b.status!==(d.meeting.status??"scheduled")});function Q(){J.value&&!window.confirm("Es gibt ungespeicherte Änderungen. Wirklich verwerfen?")||(j(),R.value=!1)}function te(q){return typeof q!="number"||Number.isNaN(q)?"Dauer muss eine Zahl sein":q>=5||"Mindestens 5 Minuten"}function ve(q){return typeof q!="number"||Number.isNaN(q)?"Dauer muss eine Zahl sein":q<=480||"Maximal 480 Minuten"}async function de(){if(d.meeting){g.value=!0,x.value=null;try{const q=F.value,C={};q&&(b.firstName!==(q.firstName??"")&&(C.firstName=b.firstName),b.lastName!==(q.lastName??"")&&(C.lastName=b.lastName),b.email!==(q.email??"")&&(C.email=b.email),b.company!==(q.company??"")&&(C.company=b.company));const ae={};b.topic!==(d.meeting.topic??"")&&(ae.topic=b.topic);const X=L(d.meeting.scheduledAt);b.scheduledAt!==X&&b.scheduledAt&&(ae.scheduledAt=new Date(b.scheduledAt).toISOString()),b.durationMinutes!==(d.meeting.durationMinutes??30)&&(ae.durationMinutes=b.durationMinutes);const ie=b.status!==(d.meeting.status??"scheduled");if(C.email!==void 0){const fe=E(b.email);if(typeof fe=="string"){x.value=fe,g.value=!1;return}}if(Object.keys(C).length>0&&q){const fe=await re.put(`/leads/${q._id}`,C);if(!fe.success||!fe.data){x.value=fe.error??"Lead-Update fehlgeschlagen",g.value=!1,ue.error("ADMIN","Lead-Update im Termin-Modal fehlgeschlagen",{error:fe.error});return}c("leadUpdated",q._id,fe.data.lead)}if(Object.keys(ae).length>0){const fe=await re.patch(`/meetings/${d.meeting._id}`,ae);if(!fe.success||!fe.data){x.value=fe.error??"Termin-Update fehlgeschlagen",g.value=!1,ue.error("ADMIN","Termin-Update fehlgeschlagen",{error:fe.error});return}c("meetingUpdated",d.meeting._id,fe.data.meeting)}if(ie){const fe=await re.patch(`/meetings/${d.meeting._id}/status`,{status:b.status});if(!fe.success){x.value=fe.error??"Status-Update fehlgeschlagen",g.value=!1,ue.error("ADMIN","Status-Update im Edit-Modus fehlgeschlagen",{error:fe.error});return}c("statusUpdated",d.meeting._id,b.status)}i.value=!1,ue.info("ADMIN","Termin bearbeitet",{meetingId:d.meeting._id})}catch(q){x.value="Netzwerkfehler beim Speichern",ue.error("ADMIN","Netzwerkfehler beim Speichern des Termins",q)}finally{g.value=!1}}}async function Z(q){if(d.meeting){s.value=!0,m.value=null;try{const C=await re.patch(`/meetings/${d.meeting._id}/status`,{status:q});C.success?(c("statusUpdated",d.meeting._id,q),ue.info("ADMIN","Meeting-Status aktualisiert",{id:d.meeting._id,status:q})):(m.value=C.error||"Status-Update fehlgeschlagen",ue.error("ADMIN","Meeting-Status-Update fehlgeschlagen",{error:C.error}))}catch(C){m.value="Netzwerkfehler beim Status-Update",ue.error("ADMIN","Netzwerkfehler beim Meeting-Status-Update",C)}finally{s.value=!1}}}async function ce(){if(!d.meeting||i.value)return;const q=u.value.trim();if(q){f.value=!0,k.value=null;try{const C=await re.post(`/meetings/${d.meeting._id}/notes`,{text:q});C.success&&C.data?(c("noteAdded",d.meeting._id,C.data.note),u.value="",ue.info("ADMIN","Notiz hinzugefügt",{meetingId:d.meeting._id})):(k.value=C.error??"Notiz konnte nicht hinzugefügt werden",ue.error("ADMIN","Notiz hinzufügen fehlgeschlagen",{error:C.error}))}catch(C){k.value="Netzwerkfehler beim Hinzufügen der Notiz",ue.error("ADMIN","Netzwerkfehler beim Hinzufügen der Notiz",C)}finally{f.value=!1}}}async function oe(q,C){if(d.meeting&&!i.value){p.value=q,k.value=null;try{const ae=await re.patch(`/meetings/${d.meeting._id}/notes/${q}`,{text:C});ae.success&&ae.data?(c("noteUpdated",d.meeting._id,ae.data.note),ue.info("ADMIN","Notiz aktualisiert",{meetingId:d.meeting._id,noteId:q})):(k.value=ae.error??"Notiz konnte nicht aktualisiert werden",ue.error("ADMIN","Notiz aktualisieren fehlgeschlagen",{error:ae.error}))}catch(ae){k.value="Netzwerkfehler beim Aktualisieren der Notiz",ue.error("ADMIN","Netzwerkfehler beim Aktualisieren der Notiz",ae)}finally{p.value=null}}}async function pe(q){if(d.meeting){_.value=q,k.value=null;try{const C=await re.delete(`/meetings/${d.meeting._id}/notes/${q}`);C.success?(c("noteDeleted",d.meeting._id,q),ue.info("ADMIN","Notiz gelöscht",{meetingId:d.meeting._id,noteId:q})):(k.value=C.error??"Notiz konnte nicht gelöscht werden",ue.error("ADMIN","Notiz löschen fehlgeschlagen",{error:C.error}))}catch(C){k.value="Netzwerkfehler beim Löschen der Notiz",ue.error("ADMIN","Netzwerkfehler beim Löschen der Notiz",C)}finally{_.value=null}}}function _e(){m.value=null,k.value=null,u.value="",i.value=!1,x.value=null}return(q,C)=>{const ae=l("v-icon"),X=l("v-btn"),ie=l("v-card-title"),fe=l("v-divider"),Se=l("v-alert"),me=l("router-link"),ee=l("v-text-field"),Y=l("v-col"),K=l("v-row"),le=l("v-select"),ne=l("v-textarea"),Ce=l("v-card-text"),ke=l("v-spacer"),xe=l("v-card-actions"),Ne=l("v-card"),Ie=l("v-dialog");return o(),N(Ie,{modelValue:R.value,"onUpdate:modelValue":[C[16]||(C[16]=Ue=>R.value=Ue),_e],"max-width":"680",scrollable:"",persistent:i.value&&J.value},{default:t(()=>[r.meeting?(o(),N(Ne,{key:0,class:"meeting-detail-modal"},{default:t(()=>[e(ie,{class:"meeting-detail-modal__header"},{default:t(()=>[a("div",ES,[a("div",MS,[e(ae,{color:"primary"},{default:t(()=>[...C[17]||(C[17]=[n("mdi-calendar-check",-1)])]),_:1}),C[18]||(C[18]=a("span",null,"Termin-Details",-1))]),a("div",NS,[i.value?U("",!0):(o(),N(X,{key:0,variant:"text",size:"small","prepend-icon":"mdi-pencil",onClick:z},{default:t(()=>[...C[19]||(C[19]=[n(" Bearbeiten ",-1)])]),_:1})),e(Vl,{status:r.meeting.status},null,8,["status"]),e(X,{icon:"mdi-close",variant:"text",size:"small",density:"comfortable","aria-label":"Schließen",onClick:Q})])])]),_:1}),e(fe),e(Ce,{class:"pa-6"},{default:t(()=>[m.value?(o(),N(Se,{key:0,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":C[0]||(C[0]=Ue=>m.value=null)},{default:t(()=>[n(v(m.value),1)]),_:1})):U("",!0),a("div",US,[C[24]||(C[24]=a("p",{class:"meeting-detail-modal__section-label"},"Lead",-1)),i.value?(o(),h(be,{key:1},[F.value?(o(),h("div",qS,[e(K,{dense:""},{default:t(()=>[e(Y,{cols:"6"},{default:t(()=>[e(ee,{ref_key:"firstNameInputRef",ref:w,modelValue:b.firstName,"onUpdate:modelValue":C[2]||(C[2]=Ue=>b.firstName=Ue),label:"Vorname",density:"compact",variant:"outlined","hide-details":"",disabled:g.value},null,8,["modelValue","disabled"])]),_:1}),e(Y,{cols:"6"},{default:t(()=>[e(ee,{modelValue:b.lastName,"onUpdate:modelValue":C[3]||(C[3]=Ue=>b.lastName=Ue),label:"Nachname",density:"compact",variant:"outlined","hide-details":"",disabled:g.value},null,8,["modelValue","disabled"])]),_:1}),e(Y,{cols:"12"},{default:t(()=>[e(ee,{modelValue:b.email,"onUpdate:modelValue":C[4]||(C[4]=Ue=>b.email=Ue),label:"E-Mail",type:"email",density:"compact",variant:"outlined",rules:[E],disabled:g.value},null,8,["modelValue","rules","disabled"])]),_:1}),e(Y,{cols:"12"},{default:t(()=>[e(ee,{modelValue:b.company,"onUpdate:modelValue":C[5]||(C[5]=Ue=>b.company=Ue),label:"Firma",density:"compact",variant:"outlined","hide-details":"",disabled:g.value},null,8,["modelValue","disabled"])]),_:1})]),_:1})])):(o(),h("div",GS," Lead-Daten nicht verfügbar. Bitte Modal schließen und erneut öffnen. "))],64)):(o(),h(be,{key:0},[a("div",BS,[e(ae,{size:"16",color:"primary"},{default:t(()=>[...C[20]||(C[20]=[n("mdi-account-outline",-1)])]),_:1}),a("span",FS,v(M.value),1),H.value?(o(),N(me,{key:0,to:{name:"admin-lead-detail",params:{id:H.value}},class:"meeting-detail-modal__link text-caption",onClick:C[1]||(C[1]=Ue=>R.value=!1)},{default:t(()=>[...C[21]||(C[21]=[n(" Zum Lead ",-1)])]),_:1},8,["to"])):U("",!0)]),T.value?(o(),h("div",OS,[e(ae,{size:"16",color:"primary"},{default:t(()=>[...C[22]||(C[22]=[n("mdi-email-outline",-1)])]),_:1}),a("span",RS,v(T.value),1)])):U("",!0),D.value?(o(),h("div",KS,[e(ae,{size:"16",color:"primary"},{default:t(()=>[...C[23]||(C[23]=[n("mdi-domain",-1)])]),_:1}),a("span",jS,v(D.value),1)])):U("",!0)],64))]),e(fe,{class:"my-4"}),a("div",HS,[C[30]||(C[30]=a("p",{class:"meeting-detail-modal__section-label"},"Termin-Details",-1)),i.value?(o(),N(K,{key:1,dense:""},{default:t(()=>[e(Y,{cols:"12"},{default:t(()=>[e(le,{modelValue:b.topic,"onUpdate:modelValue":C[6]||(C[6]=Ue=>b.topic=Ue),items:I,"item-title":"title","item-value":"value",label:"Thema",density:"compact",variant:"outlined","hide-details":"",disabled:g.value},null,8,["modelValue","disabled"])]),_:1}),e(Y,{cols:"8"},{default:t(()=>[e(ee,{modelValue:b.scheduledAt,"onUpdate:modelValue":C[7]||(C[7]=Ue=>b.scheduledAt=Ue),label:"Wunschtermin",type:"datetime-local",density:"compact",variant:"outlined","hide-details":"",disabled:g.value},null,8,["modelValue","disabled"])]),_:1}),e(Y,{cols:"4"},{default:t(()=>[e(ee,{modelValue:b.durationMinutes,"onUpdate:modelValue":C[8]||(C[8]=Ue=>b.durationMinutes=Ue),modelModifiers:{number:!0},label:"Dauer (Min)",type:"number",min:"5",max:"480",density:"compact",variant:"outlined",rules:[te,ve],disabled:g.value},null,8,["modelValue","rules","disabled"])]),_:1}),e(Y,{cols:"12"},{default:t(()=>[e(le,{modelValue:b.status,"onUpdate:modelValue":C[9]||(C[9]=Ue=>b.status=Ue),items:V,"item-title":"title","item-value":"value",label:"Status",density:"compact",variant:"outlined","hide-details":"",disabled:g.value},null,8,["modelValue","disabled"])]),_:1})]),_:1})):(o(),N(K,{key:0,dense:""},{default:t(()=>[e(Y,{cols:"12",sm:"6"},{default:t(()=>[a("div",WS,[C[25]||(C[25]=a("span",{class:"meeting-detail-modal__detail-key"},"Thema",-1)),a("span",ZS,v(B(r.meeting.topic)),1)])]),_:1}),e(Y,{cols:"12",sm:"6"},{default:t(()=>[a("div",JS,[C[26]||(C[26]=a("span",{class:"meeting-detail-modal__detail-key"},"Quelle",-1)),a("span",QS,v(G(r.meeting.bookingSource)),1)])]),_:1}),r.meeting.scheduledAt?(o(),N(Y,{key:0,cols:"12",sm:"6"},{default:t(()=>[a("div",YS,[C[27]||(C[27]=a("span",{class:"meeting-detail-modal__detail-key"},"Wunschtermin",-1)),a("span",XS,v(W(r.meeting.scheduledAt)),1)])]),_:1})):U("",!0),r.meeting.durationMinutes?(o(),N(Y,{key:1,cols:"12",sm:"6"},{default:t(()=>[a("div",e$,[C[28]||(C[28]=a("span",{class:"meeting-detail-modal__detail-key"},"Dauer",-1)),a("span",t$,v(r.meeting.durationMinutes)+" Min.",1)])]),_:1})):U("",!0),e(Y,{cols:"12",sm:"6"},{default:t(()=>[a("div",a$,[C[29]||(C[29]=a("span",{class:"meeting-detail-modal__detail-key"},"Erstellt",-1)),a("span",l$,v(W(r.meeting.createdAt)),1)])]),_:1})]),_:1}))]),a("div",n$,[e(fe,{class:"mb-4"}),a("section",o$,[a("h3",s$,[e(ae,{size:"20",color:"primary",class:"mr-2"},{default:t(()=>[...C[31]||(C[31]=[n("mdi-note-text-outline",-1)])]),_:1}),a("span",null,"Notizen ("+v(O.value.length)+")",1)]),i.value?(o(),N(Se,{key:0,type:"info",variant:"tonal",density:"compact",class:"mt-3"},{default:t(()=>[...C[32]||(C[32]=[n(" Notizen können nach dem Speichern oder Abbrechen der Termin-Änderungen wieder bearbeitet werden. ",-1)])]),_:1})):U("",!0),a("div",i$,[e(ne,{modelValue:u.value,"onUpdate:modelValue":C[10]||(C[10]=Ue=>u.value=Ue),placeholder:"Notiz hinzufügen...",rows:"2","auto-grow":"","hide-details":"",variant:"outlined",density:"compact",disabled:f.value||i.value,onKeydown:[Kt(dt(ce,["ctrl"]),["enter"]),Kt(dt(ce,["meta"]),["enter"])]},null,8,["modelValue","disabled","onKeydown"]),a("div",r$,[e(X,{color:"primary",size:"small",loading:f.value,disabled:!u.value.trim()||i.value,onClick:ce},{default:t(()=>[...C[33]||(C[33]=[n(" Notiz hinzufügen ",-1)])]),_:1},8,["loading","disabled"])])]),k.value?(o(),N(Se,{key:1,type:"error",variant:"tonal",density:"compact",class:"mt-3",closable:"","onClick:close":C[11]||(C[11]=Ue=>k.value=null)},{default:t(()=>[n(v(k.value),1)]),_:1})):U("",!0),a("div",d$,[O.value.length===0?(o(),h("div",u$," Noch keine Notizen vorhanden ")):(o(),h("div",c$,[(o(!0),h(be,null,Pe(S.value,Ue=>(o(),N(LS,{key:Ue._id,note:Ue,updating:p.value===Ue._id,deleting:_.value===Ue._id,disabled:i.value,onUpdate:oe,onDelete:pe},null,8,["note","updating","deleting","disabled"]))),128))]))])])]),i.value&&x.value?(o(),N(Se,{key:1,type:"error",density:"compact",variant:"tonal",closable:"",class:"mt-4 mb-0","onClick:close":C[12]||(C[12]=Ue=>x.value=null)},{default:t(()=>[n(v(x.value),1)]),_:1})):U("",!0),r.meeting.status==="scheduled"&&!i.value?(o(),h("div",m$,[e(fe,{class:"mb-4"}),a("div",v$,[C[37]||(C[37]=a("p",{class:"meeting-detail-modal__section-label"},"Status aktualisieren",-1)),a("div",p$,[e(X,{size:"small",color:"success",variant:"tonal",loading:s.value,"prepend-icon":"mdi-check-circle-outline",onClick:C[13]||(C[13]=Ue=>Z("completed"))},{default:t(()=>[...C[34]||(C[34]=[n(" Abgeschlossen ",-1)])]),_:1},8,["loading"]),e(X,{size:"small",color:"warning",variant:"tonal",loading:s.value,"prepend-icon":"mdi-account-off-outline",onClick:C[14]||(C[14]=Ue=>Z("no-show"))},{default:t(()=>[...C[35]||(C[35]=[n(" No-Show ",-1)])]),_:1},8,["loading"]),e(X,{size:"small",color:"error",variant:"tonal",loading:s.value,"prepend-icon":"mdi-close-circle-outline",onClick:C[15]||(C[15]=Ue=>Z("cancelled"))},{default:t(()=>[...C[36]||(C[36]=[n(" Abgesagt ",-1)])]),_:1},8,["loading"])])])])):U("",!0)]),_:1}),e(fe),i.value?(o(),N(xe,{key:0,class:"pa-4"},{default:t(()=>[e(ke),e(X,{variant:"text",disabled:g.value,onClick:j},{default:t(()=>[...C[38]||(C[38]=[n(" Abbrechen ",-1)])]),_:1},8,["disabled"]),e(X,{color:"primary",loading:g.value,onClick:de},{default:t(()=>[...C[39]||(C[39]=[n(" Speichern ",-1)])]),_:1},8,["loading"])]),_:1})):(o(),N(xe,{key:1,class:"pa-4"},{default:t(()=>[e(ke),e(X,{variant:"text",onClick:Q},{default:t(()=>[...C[40]||(C[40]=[n(" Schließen ",-1)])]),_:1})]),_:1}))]),_:1})):U("",!0)]),_:1},8,["modelValue","persistent"])}}}),g$=Me(f$,[["__scopeId","data-v-8f5c8995"]]),b$={class:"meeting-calendar"},y$={class:"meeting-calendar__controls mb-4"},_$={class:"d-flex align-center ga-2"},k$={class:"text-subtitle-1 font-weight-semibold",style:{"min-width":"160px","text-align":"center"}},h$={class:"d-flex align-center ga-3"},x$={key:1,class:"d-flex justify-center pa-8"},w$={key:2,class:"meeting-calendar__grid-wrapper"},S$={class:"meeting-calendar__weekdays"},$$={class:"meeting-calendar__days"},C$={class:"meeting-calendar__day-number"},V$={class:"meeting-calendar__day-events"},A$=["title","onClick"],I$={key:0,class:"meeting-calendar__event-more"},P$=Ae({__name:"MeetingCalendar",emits:["eventClick"],setup(r,{expose:$,emit:d}){const c=d,s=y([]),m=y(!1),u=y(null),f=y(""),p=y(new Date),_=[{title:"Alle Status",value:""},{title:"Geplant",value:"scheduled"},{title:"Abgeschlossen",value:"completed"},{title:"No-Show",value:"no-show"},{title:"Abgesagt",value:"cancelled"}],k={scheduled:"#0AC9D4",completed:"#66BB6A","no-show":"#CF6679",cancelled:"#748686"},i={nis2:"NIS2",dora:"DORA",pentesting:"Pentesting",isms:"ISMS","incident-response":"Incident Response","cloud-security":"Cloud Security",compliance:"Compliance",awareness:"Awareness",allgemein:"Allgemein"},g=se(()=>p.value.getFullYear()),x=se(()=>p.value.getMonth()),w=se(()=>new Intl.DateTimeFormat("de-DE",{month:"long",year:"numeric"}).format(p.value)),b=["Mo","Di","Mi","Do","Fr","Sa","So"];function I(F){const L=F.getFullYear(),A=String(F.getMonth()+1).padStart(2,"0"),z=String(F.getDate()).padStart(2,"0");return`${L}-${A}-${z}`}function V(F){const L=s.value.filter(A=>!A.scheduledAt||f.value&&A.status!==f.value?!1:I(new Date(A.scheduledAt))===F);return L.sort((A,z)=>{const j=A.scheduledAt?new Date(A.scheduledAt).getTime():0,J=z.scheduledAt?new Date(z.scheduledAt).getTime():0;return j-J}),L}const E=se(()=>{const F=g.value,L=x.value,A=new Date(F,L,1),z=new Date(F,L+1,0);let j=A.getDay();j=j===0?6:j-1;const J=[];for(let te=j-1;te>=0;te--){const ve=new Date(F,L,-te),de=I(ve);J.push({date:ve,dateStr:de,isCurrentMonth:!1,entries:V(de)})}for(let te=1;te<=z.getDate();te++){const ve=new Date(F,L,te),de=I(ve);J.push({date:ve,dateStr:de,isCurrentMonth:!0,entries:V(de)})}const Q=42-J.length;for(let te=1;te<=Q;te++){const ve=new Date(F,L+1,te),de=I(ve);J.push({date:ve,dateStr:de,isCurrentMonth:!1,entries:V(de)})}return J});function R(){p.value=new Date(g.value,x.value-1,1)}function M(){p.value=new Date(g.value,x.value+1,1)}function T(){p.value=new Date}function D(F){const L=new Date;return F.getDate()===L.getDate()&&F.getMonth()===L.getMonth()&&F.getFullYear()===L.getFullYear()}function H(F){return k[F]||"#748686"}function O(F){const L=F.leadId;if(L&&typeof L=="object"){const A=`${L.firstName??""} ${L.lastName??""}`.trim();if(A)return A;if(L.email)return L.email}return i[F.topic]||F.topic||"Termin"}function S(F){return F.scheduledAt?`${new Date(F.scheduledAt).toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})} · ${O(F)}`:O(F)}function B(F,L=28){return F?F.length>L?F.substring(0,L)+"…":F:""}function G(F){c("eventClick",F)}async function W(){m.value=!0,u.value=null;try{const F=await re.get("/meetings?page=1&limit=100&sortBy=scheduledAt&sortOrder=asc");F.success&&F.data?(s.value=F.data.items,ue.debug("ADMIN","Kalender: Termine geladen",{total:F.data.items.length})):(u.value=F.error||"Fehler beim Laden der Termine",ue.error("ADMIN","Kalender: Ladefehler",{error:F.error}))}catch{u.value="Netzwerkfehler beim Laden der Kalender-Daten",ue.error("ADMIN","Kalender: Netzwerkfehler")}finally{m.value=!1}}return $({reload:W}),rt(()=>{W()}),(F,L)=>{const A=l("v-tooltip"),z=l("v-icon"),j=l("v-btn"),J=l("v-select"),Q=l("v-alert"),te=l("v-progress-circular");return o(),h("div",b$,[a("div",y$,[a("div",_$,[e(j,{icon:"",variant:"text",size:"small","aria-label":"Vorheriger Monat",onClick:R},{default:t(()=>[e(A,{activator:"parent",location:"bottom"},{default:t(()=>[...L[2]||(L[2]=[n("Vorheriger Monat",-1)])]),_:1}),e(z,null,{default:t(()=>[...L[3]||(L[3]=[n("mdi-chevron-left",-1)])]),_:1})]),_:1}),a("span",k$,v(w.value),1),e(j,{icon:"",variant:"text",size:"small","aria-label":"Nächster Monat",onClick:M},{default:t(()=>[e(A,{activator:"parent",location:"bottom"},{default:t(()=>[...L[4]||(L[4]=[n("Nächster Monat",-1)])]),_:1}),e(z,null,{default:t(()=>[...L[5]||(L[5]=[n("mdi-chevron-right",-1)])]),_:1})]),_:1}),e(j,{variant:"outlined",size:"small",onClick:T},{default:t(()=>[...L[6]||(L[6]=[n("Heute",-1)])]),_:1})]),a("div",h$,[e(J,{modelValue:f.value,"onUpdate:modelValue":L[0]||(L[0]=ve=>f.value=ve),items:_,label:"Status",variant:"outlined",density:"compact","hide-details":"",style:{"min-width":"180px"}},null,8,["modelValue"]),L[7]||(L[7]=_a('<div class="d-flex align-center ga-3 text-caption text-medium-emphasis" data-v-fd4425a3><span class="d-flex align-center ga-1" data-v-fd4425a3><span class="meeting-calendar__legend-dot" style="background:#0AC9D4;" data-v-fd4425a3></span> Geplant </span><span class="d-flex align-center ga-1" data-v-fd4425a3><span class="meeting-calendar__legend-dot" style="background:#66BB6A;" data-v-fd4425a3></span> Abgeschlossen </span><span class="d-flex align-center ga-1" data-v-fd4425a3><span class="meeting-calendar__legend-dot" style="background:#CF6679;" data-v-fd4425a3></span> No-Show </span><span class="d-flex align-center ga-1" data-v-fd4425a3><span class="meeting-calendar__legend-dot" style="background:#748686;" data-v-fd4425a3></span> Abgesagt </span></div>',1))])]),u.value?(o(),N(Q,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":L[1]||(L[1]=ve=>u.value=null)},{default:t(()=>[n(v(u.value),1)]),_:1})):U("",!0),m.value?(o(),h("div",x$,[e(te,{indeterminate:"",color:"primary"})])):(o(),h("div",w$,[a("div",S$,[(o(),h(be,null,Pe(b,ve=>a("div",{key:ve,class:"meeting-calendar__weekday"},v(ve),1)),64))]),a("div",$$,[(o(!0),h(be,null,Pe(E.value,(ve,de)=>(o(),h("div",{key:de,class:ft(["meeting-calendar__day",{"meeting-calendar__day--other-month":!ve.isCurrentMonth,"meeting-calendar__day--today":D(ve.date)}])},[a("div",C$,v(ve.date.getDate()),1),a("div",V$,[(o(!0),h(be,null,Pe(ve.entries.slice(0,3),(Z,ce)=>(o(),h("div",{key:ce,class:"meeting-calendar__event-chip",style:ht({borderLeftColor:H(Z.status)}),title:S(Z),onClick:oe=>G(Z)},v(B(S(Z),28)),13,A$))),128)),ve.entries.length>3?(o(),h("div",I$," +"+v(ve.entries.length-3)+" weitere ",1)):U("",!0)])],2))),128))])]))])}}}),z$=Me(P$,[["__scopeId","data-v-fd4425a3"]]),D$={class:"meeting-list-view"},T$={class:"meeting-list-view__header"},L$={class:"d-flex align-center ga-3"},E$={class:"meeting-list-view__filter mb-4"},M$={class:"d-flex align-center justify-space-between"},N$={class:"text-subtitle-1 font-weight-semibold"},U$={class:"meeting-list-view__lead"},B$={class:"text-body-2 font-weight-medium"},F$={key:0,class:"text-caption text-medium-emphasis d-block"},O$={class:"text-body-2 text-medium-emphasis"},R$={class:"text-body-2 text-medium-emphasis"},K$={class:"text-body-2 text-medium-emphasis"},j$={class:"py-16 text-center"},q$={key:1,class:"d-flex justify-center pa-4"},G$={class:"d-flex align-center ga-2"},H$=Ae({__name:"MeetingListView",setup(r){const $=y([]),d=y({page:1,limit:20,total:0,totalPages:1}),c=y(!1),s=y(null),m=y(null),u=y(!1),f=y(null);let p=null;function _(){p&&clearTimeout(p),p=setTimeout(()=>{_(),p=null},100)}const k=y(!1),i=wt({leadEmail:"",topic:"",scheduledAt:"",notes:""}),g=y(!1),x=y(null),w=qe("meetings_filter_status",""),b=qe("meetings_filter_topic",""),I=qe("meetings_sort",[]),V=qe("meetings_per_page",20),E=qe("meetings_view_mode","list"),R=[{title:"Lead",key:"leadId",sortable:!1},{title:"Thema",key:"topic",sortable:!0},{title:"Status",key:"status",sortable:!0},{title:"Quelle",key:"bookingSource",sortable:!0},{title:"Wunschtermin",key:"scheduledAt",sortable:!0},{title:"Erstellt",key:"createdAt",sortable:!0},{title:"",key:"actions",sortable:!1,width:60}],M=[{label:"Alle",value:""},{label:"Geplant",value:"scheduled"},{label:"Abgeschlossen",value:"completed"},{label:"No-Show",value:"no-show"},{label:"Abgesagt",value:"cancelled"}],T=[{title:"NIS2",value:"nis2"},{title:"DORA",value:"dora"},{title:"Pentesting",value:"pentesting"},{title:"ISMS",value:"isms"},{title:"Incident Response",value:"incident-response"},{title:"Cloud Security",value:"cloud-security"},{title:"Compliance",value:"compliance"},{title:"Awareness",value:"awareness"},{title:"Allgemein",value:"allgemein"}];function D(de){return de?typeof de=="object"?`${de.firstName} ${de.lastName}`:String(de):"Unbekannt"}function H(de){return!de||typeof de!="object"?"":de.email}function O(de){const Z=T.find(ce=>ce.value===de);return Z?Z.title:de}function S(de){return de?{"form-cta":"Buchungsformular",manual:"Manuell",hubspot:"HubSpot",website:"Website"}[de]||de:"–"}function B(de){return de?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(de)):"–"}async function G(de=1){c.value=!0,s.value=null;const Z=new URLSearchParams;if(Z.set("page",String(de)),Z.set("limit",String(V.value)),w.value&&Z.set("status",w.value),b.value&&Z.set("topic",b.value),I.value.length>0){const ce=I.value[0];Z.set("sortBy",ce.key),Z.set("sortOrder",ce.order)}try{const ce=await re.get(`/meetings?${Z.toString()}`);ce.success&&ce.data?($.value=ce.data.items,d.value=ce.data.pagination,ue.debug("ADMIN","Termine geladen",{total:ce.data.pagination.total})):(s.value=ce.error||"Fehler beim Laden der Termine",ue.error("ADMIN","Termine Ladefehler",{error:ce.error}))}catch{s.value="Netzwerkfehler beim Laden der Termine",ue.error("ADMIN","Netzwerkfehler beim Laden der Termine")}finally{c.value=!1}}function W(de){m.value=de,u.value=!0}function F(de,Z){W(Z.item)}function L(de){W(de)}function A(de,Z){var oe;const ce=$.value.findIndex(pe=>pe._id===de);ce!==-1&&($.value[ce]={...$.value[ce],status:Z}),((oe=m.value)==null?void 0:oe._id)===de&&(m.value={...m.value,status:Z}),_()}function z(de,Z){var oe;const ce=$.value.findIndex(pe=>pe._id===de);if(ce!==-1){const pe=$.value[ce].notesLog??[];$.value[ce]={...$.value[ce],notesLog:[...pe,Z]}}if(((oe=m.value)==null?void 0:oe._id)===de){const pe=m.value.notesLog??[];m.value={...m.value,notesLog:[...pe,Z]}}}function j(de,Z){var pe;const ce=_e=>_e.map(q=>q._id===Z._id?Z:q),oe=$.value.findIndex(_e=>_e._id===de);oe!==-1&&($.value[oe]={...$.value[oe],notesLog:ce($.value[oe].notesLog??[])}),((pe=m.value)==null?void 0:pe._id)===de&&(m.value={...m.value,notesLog:ce(m.value.notesLog??[])})}function J(de,Z){var oe;const ce=$.value.findIndex(pe=>pe._id===de);ce!==-1&&($.value[ce]={...$.value[ce],...Z}),((oe=m.value)==null?void 0:oe._id)===de&&(m.value={...m.value,...Z}),_()}function Q(de,Z){var ce;$.value=$.value.map(oe=>oe.leadId&&typeof oe.leadId=="object"&&oe.leadId._id===de?{...oe,leadId:{...oe.leadId,...Z}}:oe),(ce=m.value)!=null&&ce.leadId&&typeof m.value.leadId=="object"&&m.value.leadId._id===de&&(m.value={...m.value,leadId:{...m.value.leadId,...Z}}),_()}function te(de,Z){var pe;const ce=_e=>_e.filter(q=>q._id!==Z),oe=$.value.findIndex(_e=>_e._id===de);oe!==-1&&($.value[oe]={...$.value[oe],notesLog:ce($.value[oe].notesLog??[])}),((pe=m.value)==null?void 0:pe._id)===de&&(m.value={...m.value,notesLog:ce(m.value.notesLog??[])})}async function ve(){g.value=!0,x.value=null;try{const de=i.notes.trim(),Z=await re.post("/meetings",{leadIdOrEmail:i.leadEmail,topic:i.topic,scheduledAt:i.scheduledAt||void 0,notes:de||void 0,bookingSource:"manual"});if(Z.success&&Z.data){const ce=Z.data.meeting._id;if(de&&ce)try{await re.post(`/meetings/${ce}/notes`,{text:de})}catch(oe){ue.warn("ADMIN","Termin erstellt, aber Notiz konnte nicht als Log-Eintrag angelegt werden",{meetingId:ce,error:oe})}k.value=!1,i.leadEmail="",i.topic="",i.scheduledAt="",i.notes="",ue.info("ADMIN","Termin manuell eingetragen"),await G(1)}else x.value=Z.error||"Termin konnte nicht eingetragen werden",ue.error("ADMIN","Manueller Termineintrag fehlgeschlagen",{error:Z.error})}catch(de){x.value="Netzwerkfehler",ue.error("ADMIN","Netzwerkfehler beim manuellen Termineintrag",de)}finally{g.value=!1}}return Ze([w,b],()=>{G(1)}),Ze(I,()=>{G(1)},{deep:!0}),rt(()=>{G()}),da(()=>{p&&(clearTimeout(p),p=null)}),(de,Z)=>{const ce=l("v-tooltip"),oe=l("v-icon"),pe=l("v-btn"),_e=l("v-btn-toggle"),q=l("v-alert"),C=l("v-chip"),ae=l("v-chip-group"),X=l("v-select"),ie=l("v-card-title"),fe=l("v-data-table"),Se=l("v-divider"),me=l("v-pagination"),ee=l("v-card"),Y=l("v-text-field"),K=l("v-col"),le=l("v-textarea"),ne=l("v-row"),Ce=l("v-card-text"),ke=l("v-spacer"),xe=l("v-card-actions"),Ne=l("v-dialog");return o(),h("div",D$,[a("div",T$,[Z[22]||(Z[22]=a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"Termine"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," Termin-Management und Übersicht aller Buchungen ")],-1)),a("div",L$,[e(_e,{modelValue:P(E),"onUpdate:modelValue":Z[0]||(Z[0]=Ie=>ot(E)?E.value=Ie:null),variant:"outlined",density:"compact",mandatory:"",color:"primary"},{default:t(()=>[e(pe,{value:"list",icon:"","aria-label":"Listenansicht"},{default:t(()=>[e(ce,{activator:"parent",location:"bottom"},{default:t(()=>[...Z[17]||(Z[17]=[n("Listenansicht",-1)])]),_:1}),e(oe,{size:"18"},{default:t(()=>[...Z[18]||(Z[18]=[n("mdi-view-list",-1)])]),_:1})]),_:1}),e(pe,{value:"calendar",icon:"","aria-label":"Kalenderansicht"},{default:t(()=>[e(ce,{activator:"parent",location:"bottom"},{default:t(()=>[...Z[19]||(Z[19]=[n("Kalenderansicht",-1)])]),_:1}),e(oe,{size:"18"},{default:t(()=>[...Z[20]||(Z[20]=[n("mdi-calendar-month",-1)])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(pe,{color:"primary","prepend-icon":"mdi-calendar-plus",onClick:Z[1]||(Z[1]=Ie=>k.value=!0)},{default:t(()=>[...Z[21]||(Z[21]=[n(" Termin manuell eintragen ",-1)])]),_:1})])]),s.value?(o(),N(q,{key:0,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":Z[2]||(Z[2]=Ie=>s.value=null)},{default:t(()=>[n(v(s.value),1)]),_:1})):U("",!0),P(E)==="calendar"?(o(),N(z$,{key:1,ref_key:"calendarRef",ref:f,onEventClick:L},null,512)):(o(),h(be,{key:2},[a("div",E$,[e(ae,{modelValue:P(w),"onUpdate:modelValue":Z[3]||(Z[3]=Ie=>ot(w)?w.value=Ie:null),mandatory:"","selected-class":"text-primary"},{default:t(()=>[(o(),h(be,null,Pe(M,Ie=>e(C,{key:Ie.value,value:Ie.value,variant:"outlined",size:"small"},{default:t(()=>[n(v(Ie.label),1)]),_:2},1032,["value"])),64))]),_:1},8,["modelValue"]),e(X,{modelValue:P(b),"onUpdate:modelValue":Z[4]||(Z[4]=Ie=>ot(b)?b.value=Ie:null),items:[{title:"Alle Themen",value:""},...T],"item-title":"title","item-value":"value",density:"compact",variant:"outlined","hide-details":"",class:"meeting-list-view__topic-select",clearable:""},null,8,["modelValue","items"])]),e(ee,{variant:"outlined",class:"meeting-list-view__table-card"},{default:t(()=>[e(ie,{class:"pa-4 pb-2"},{default:t(()=>[a("div",M$,[a("span",N$,v(d.value.total)+" Termine gesamt ",1),e(pe,{icon:"",variant:"text",size:"small",loading:c.value,"aria-label":"Aktualisieren",onClick:Z[5]||(Z[5]=Ie=>G(d.value.page))},{default:t(()=>[e(ce,{activator:"parent",location:"bottom"},{default:t(()=>[...Z[23]||(Z[23]=[n("Aktualisieren",-1)])]),_:1}),e(oe,null,{default:t(()=>[...Z[24]||(Z[24]=[n("mdi-refresh",-1)])]),_:1})]),_:1},8,["loading"])])]),_:1}),e(fe,{headers:R,items:$.value,loading:c.value,"loading-text":"Termine werden geladen...","no-data-text":"Keine Termine gefunden","item-value":"_id",class:"meeting-list-view__table","items-per-page":P(V),"onUpdate:itemsPerPage":Z[6]||(Z[6]=Ie=>ot(V)?V.value=Ie:null),"sort-by":P(I),"onUpdate:sortBy":Z[7]||(Z[7]=Ie=>I.value=Ie),hover:"","onClick:row":F},{"item.leadId":t(({item:Ie})=>[a("div",U$,[a("span",B$,v(D(Ie.leadId)),1),H(Ie.leadId)?(o(),h("span",F$,v(H(Ie.leadId)),1)):U("",!0)])]),"item.topic":t(({item:Ie})=>[e(C,{size:"small",variant:"tonal",color:"primary"},{default:t(()=>[n(v(O(Ie.topic)),1)]),_:2},1024)]),"item.status":t(({item:Ie})=>[e(Vl,{status:Ie.status},null,8,["status"])]),"item.bookingSource":t(({item:Ie})=>[a("span",O$,v(S(Ie.bookingSource)),1)]),"item.scheduledAt":t(({item:Ie})=>[a("span",R$,v(B(Ie.scheduledAt)),1)]),"item.createdAt":t(({item:Ie})=>[a("span",K$,v(B(Ie.createdAt)),1)]),"item.actions":t(({item:Ie})=>[e(pe,{icon:"",size:"small",variant:"text",onClick:dt(Ue=>W(Ie),["stop"])},{default:t(()=>[e(ce,{activator:"parent",location:"bottom"},{default:t(()=>[...Z[25]||(Z[25]=[n("Details",-1)])]),_:1}),e(oe,{size:"18"},{default:t(()=>[...Z[26]||(Z[26]=[n("mdi-eye-outline",-1)])]),_:1})]),_:1},8,["onClick"])]),"no-data":t(()=>[a("div",j$,[e(oe,{size:"64",color:"grey-darken-1",class:"mb-4"},{default:t(()=>[...Z[27]||(Z[27]=[n("mdi-calendar-blank-outline",-1)])]),_:1}),Z[28]||(Z[28]=a("p",{class:"text-h6 text-medium-emphasis mb-2"},"Keine Termine gefunden",-1)),Z[29]||(Z[29]=a("p",{class:"text-body-2 text-medium-emphasis"}," Es sind noch keine Termine vorhanden oder der Filter liefert keine Ergebnisse. ",-1))])]),_:1},8,["items","loading","items-per-page","sort-by"]),d.value.totalPages>1?(o(),N(Se,{key:0})):U("",!0),d.value.totalPages>1?(o(),h("div",q$,[e(me,{"model-value":d.value.page,length:d.value.totalPages,"total-visible":7,"onUpdate:modelValue":Z[8]||(Z[8]=Ie=>G(Ie))},null,8,["model-value","length"])])):U("",!0)]),_:1})],64)),e(g$,{modelValue:u.value,"onUpdate:modelValue":Z[9]||(Z[9]=Ie=>u.value=Ie),meeting:m.value,onStatusUpdated:A,onNoteAdded:z,onNoteUpdated:j,onNoteDeleted:te,onMeetingUpdated:J,onLeadUpdated:Q},null,8,["modelValue","meeting"]),e(Ne,{modelValue:k.value,"onUpdate:modelValue":Z[16]||(Z[16]=Ie=>k.value=Ie),"max-width":"520"},{default:t(()=>[e(ee,{class:"meeting-list-view__manual-card"},{default:t(()=>[e(ie,{class:"pa-6 pb-4"},{default:t(()=>[a("div",G$,[e(oe,{color:"primary"},{default:t(()=>[...Z[30]||(Z[30]=[n("mdi-calendar-plus",-1)])]),_:1}),Z[31]||(Z[31]=a("span",null,"Termin manuell eintragen",-1))])]),_:1}),e(Se),e(Ce,{class:"pa-6"},{default:t(()=>[x.value?(o(),N(q,{key:0,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":Z[10]||(Z[10]=Ie=>x.value=null)},{default:t(()=>[n(v(x.value),1)]),_:1})):U("",!0),e(ne,null,{default:t(()=>[e(K,{cols:"12"},{default:t(()=>[e(Y,{modelValue:i.leadEmail,"onUpdate:modelValue":Z[11]||(Z[11]=Ie=>i.leadEmail=Ie),label:"Lead E-Mail *",type:"email",disabled:g.value,density:"compact",variant:"outlined"},null,8,["modelValue","disabled"])]),_:1}),e(K,{cols:"12"},{default:t(()=>[e(X,{modelValue:i.topic,"onUpdate:modelValue":Z[12]||(Z[12]=Ie=>i.topic=Ie),items:T,"item-title":"title","item-value":"value",label:"Thema *",disabled:g.value,density:"compact",variant:"outlined"},null,8,["modelValue","disabled"])]),_:1}),e(K,{cols:"12"},{default:t(()=>[e(Y,{modelValue:i.scheduledAt,"onUpdate:modelValue":Z[13]||(Z[13]=Ie=>i.scheduledAt=Ie),label:"Wunschtermin",type:"datetime-local",disabled:g.value,density:"compact",variant:"outlined"},null,8,["modelValue","disabled"])]),_:1}),e(K,{cols:"12"},{default:t(()=>[e(le,{modelValue:i.notes,"onUpdate:modelValue":Z[14]||(Z[14]=Ie=>i.notes=Ie),label:"Interne Notizen",rows:"3",disabled:g.value,density:"compact",variant:"outlined"},null,8,["modelValue","disabled"])]),_:1})]),_:1})]),_:1}),e(Se),e(xe,{class:"pa-4"},{default:t(()=>[e(ke),e(pe,{variant:"text",disabled:g.value,onClick:Z[15]||(Z[15]=Ie=>k.value=!1)},{default:t(()=>[...Z[32]||(Z[32]=[n(" Abbrechen ",-1)])]),_:1},8,["disabled"]),e(pe,{color:"primary",loading:g.value,disabled:!i.leadEmail||!i.topic,onClick:ve},{default:t(()=>[...Z[33]||(Z[33]=[n(" Eintragen ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}}),W$=Me(H$,[["__scopeId","data-v-2df73689"]]),D6=Object.freeze(Object.defineProperty({__proto__:null,default:W$},Symbol.toStringTag,{value:"Module"})),Z$={class:"prompt-templates-view"},J$={class:"prompt-templates-view__header"},Q$={class:"d-flex align-center ga-2"},Y$={class:"d-flex align-center justify-space-between"},X$={class:"text-subtitle-1 font-weight-semibold"},e4={key:0,class:"text-body-2"},t4={key:1,class:"text-body-2 text-medium-emphasis"},a4={class:"text-body-2 text-medium-emphasis"},l4={class:"d-flex justify-end ga-1"},n4={class:"d-flex align-center justify-space-between"},o4={class:"text-h6"},s4={class:"prompt-templates-view__variables mt-4"},i4={class:"d-flex align-center justify-space-between mb-3"},r4={class:"text-subtitle-2 font-weight-semibold"},d4={key:0,class:"text-body-2 text-medium-emphasis pa-4 text-center",style:{border:"1px dashed rgba(255,255,255,0.15)","border-radius":"8px"}},u4={class:"d-flex align-center justify-space-between"},c4={key:0,class:"mb-4"},m4={class:"text-body-2",style:{"white-space":"pre-wrap","line-height":"1.7"}},v4=Ae({__name:"PromptTemplatesView",setup(r){const $=[{key:"preview",label:"Template-Vorschau",defaults:{temperature:.7,maxTokens:4096}}],d=y([]),c=y(!1),s=y(null),m=qe("prompts_filter_category",""),u=qe("prompts_filter_ki_config",""),f=qe("prompts_items_per_page",20),p=qe("prompt_templates_sort",[]),_=y(""),k=qe("prompt_templates_only_mine",!1),i=y([]),g=y(!1),x=y(null),w=y(!1),b=y(null),I=y(!1),V=wt({name:"",description:"",category:"",gptSettingsId:"",systemPrompt:"",userPromptTemplate:"",variables:[]}),E=y(!1),R=y(null),M=y(null),T=y(!1),D=y(null),H=y({}),O=y(!1),S=y(null),B=y(null),G=[{title:"Content-Generierung",value:"content-generation"},{title:"Content-Optimierung",value:"content-optimization"},{title:"Lead-Scoring",value:"lead-scoring"},{title:"E-Mail-Generierung",value:"email-generation"},{title:"SEO-Optimierung",value:"seo-optimization"},{title:"Zusammenfassung",value:"zusammenfassung"},{title:"Lead-Research",value:"lead-research"},{title:"Company-Scoring",value:"company-scoring"},{title:"Outreach-Strategie",value:"outreach-strategy"},{title:"Intent-Klassifikation",value:"intent-classification"},{title:"Direkt-Mail-Entwurf",value:"direct-mail-draft"}],W=se(()=>i.value.filter(Y=>Y.isActive).map(Y=>({title:`${Y.name} (${Y.provider})`,value:Y._id}))),F=[{title:"Name",key:"name",sortable:!0},{title:"Kategorie",key:"category",sortable:!0},{title:"KI-Konfiguration",key:"gptSettingsId",sortable:!1},{title:"Version",key:"version",sortable:!0},{title:"Aktiv",key:"isActive",sortable:!0},{title:"Erstellt",key:"createdBy",sortable:!1,width:80,align:"center"},{title:"Geändert",key:"updatedBy",sortable:!1,width:80,align:"center"},{title:"Aktionen",key:"actions",sortable:!1,align:"end"}],L=[Y=>!!Y||"Name ist erforderlich",Y=>Y.length>=3||"Mindestens 3 Zeichen"],A=[Y=>!!Y||"Kategorie ist erforderlich"],z=[Y=>!!Y||"System-Prompt ist erforderlich"],j=[Y=>!!Y||"User-Prompt-Template ist erforderlich"],J=se(()=>d.value.filter(Y=>{if(m.value&&Y.category!==m.value||u.value&&Y.gptSettingsId!==u.value)return!1;if(_.value){const K=_.value.toLowerCase();if(!Y.name.toLowerCase().includes(K)&&!Y.description.toLowerCase().includes(K))return!1}return!0})),Q=se(()=>x.value?"Template bearbeiten":"Neues Template");function te(Y){return{"content-generation":"Content-Generierung","content-optimization":"Content-Optimierung","lead-scoring":"Lead-Scoring","email-generation":"E-Mail-Generierung","seo-optimization":"SEO-Optimierung",zusammenfassung:"Zusammenfassung","lead-research":"Lead-Research","company-scoring":"Company-Scoring","outreach-strategy":"Outreach-Strategie","intent-classification":"Intent-Klassifikation","direct-mail-draft":"Direkt-Mail-Entwurf"}[Y]||Y}function ve(Y){return{"content-generation":"primary","content-optimization":"info","lead-scoring":"warning","email-generation":"secondary","seo-optimization":"success",zusammenfassung:"default","lead-research":"info","company-scoring":"warning","outreach-strategy":"primary","intent-classification":"warning","direct-mail-draft":"secondary"}[Y]||"default"}function de(Y){return Y.gptSettings&&typeof Y.gptSettings=="object"?Y.gptSettings.name:""}async function Z(){c.value=!0,s.value=null;try{const Y=new URLSearchParams;k.value&&Y.set("onlyMine","true");const K=Y.toString()?`/prompts?${Y.toString()}`:"/prompts",le=await re.get(K);if(le.success&&le.data){const ne=le.data;d.value=Array.isArray(ne)?ne:ne.items??[]}else s.value=le.error||"Fehler beim Laden der Prompt-Templates"}catch{s.value="Netzwerkfehler beim Laden der Prompt-Templates"}finally{c.value=!1}}function ce(){x.value=null,Object.assign(V,{name:"",description:"",category:"",gptSettingsId:"",systemPrompt:"",userPromptTemplate:"",variables:[]}),b.value=null,g.value=!0}function oe(Y){x.value=Y._id,Object.assign(V,{name:Y.name,description:Y.description,category:Y.category,gptSettingsId:Y.gptSettingsId||"",systemPrompt:Y.systemPrompt,userPromptTemplate:Y.userPromptTemplate,variables:Y.variables.map(K=>({...K}))}),b.value=null,g.value=!0}function pe(){g.value=!1}function _e(){V.variables.push({name:"",description:"",required:!0,defaultValue:""})}function q(Y){V.variables.splice(Y,1)}async function C(){if(!I.value)return;w.value=!0,b.value=null;const Y={name:V.name,description:V.description,category:V.category,gptSettingsId:V.gptSettingsId||void 0,systemPrompt:V.systemPrompt,userPromptTemplate:V.userPromptTemplate,variables:V.variables};try{let K;x.value?K=await re.put(`/prompts/${x.value}`,Y):K=await re.post("/prompts",Y),K.success?(await Z(),pe()):b.value=K.error||"Fehler beim Speichern"}catch{b.value="Netzwerkfehler beim Speichern"}finally{w.value=!1}}async function ae(Y){try{const K=await re.put(`/prompts/${Y._id}`,{isActive:!Y.isActive});K.success?await Z():s.value=K.error||"Fehler beim Aktualisieren"}catch{s.value="Netzwerkfehler beim Aktualisieren"}}function X(Y){R.value=Y._id,E.value=!0}async function ie(){if(R.value){M.value=R.value,E.value=!1;try{const Y=await re.delete(`/prompts/${R.value}`);Y.success?await Z():s.value=Y.error||"Fehler beim Löschen"}catch{s.value="Netzwerkfehler beim Löschen"}finally{M.value=null,R.value=null}}}function fe(Y){D.value=Y._id,S.value=null,B.value=null;const K={};Y.variables.forEach(le=>{K[le.name]=le.defaultValue||""}),H.value=K,T.value=!0}function Se(){T.value=!1}async function me(){if(D.value){O.value=!0,S.value=null,B.value=null;try{const Y=await re.post(`/prompts/${D.value}/preview`,{variables:H.value});Y.success&&Y.data?S.value=Y.data.content:B.value=Y.error||"Fehler beim Generieren der Vorschau"}catch{B.value="Netzwerkfehler beim Generieren der Vorschau"}finally{O.value=!1}}}async function ee(){try{const Y=await re.get("/gpt-settings");if(Y.success&&Y.data){const K=Y.data;i.value=Array.isArray(K)?K:K.items??[]}}catch{}}return Ze(k,()=>{Z()}),rt(()=>{Z(),ee()}),(Y,K)=>{const le=l("v-btn"),ne=l("v-alert"),Ce=l("v-select"),ke=l("v-col"),xe=l("v-text-field"),Ne=l("v-chip"),Ie=l("v-row"),Ue=l("v-card-text"),Te=l("v-card"),ye=l("v-tooltip"),Je=l("v-icon"),Ke=l("v-card-title"),$e=l("v-switch"),Ee=l("v-data-table"),lt=l("v-divider"),ut=l("v-textarea"),Ve=l("v-form"),Le=l("v-spacer"),Ye=l("v-card-actions"),ct=l("v-dialog");return o(),h("div",Z$,[a("div",J$,[K[20]||(K[20]=a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"Prompts & Templates"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," KI-Prompt-Templates für Content-Generierung und andere Aufgaben verwalten ")],-1)),a("div",Q$,[e(ta,{"page-key":"prompt-templates","page-label":"Prompt-Templates KI-Einstellungen",usecases:$}),e(le,{color:"primary","prepend-icon":"mdi-plus",onClick:ce},{default:t(()=>[...K[19]||(K[19]=[n(" Neues Template ",-1)])]),_:1})])]),s.value?(o(),N(ne,{key:0,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":K[0]||(K[0]=Fe=>s.value=null)},{default:t(()=>[n(v(s.value),1)]),_:1})):U("",!0),e(Te,{variant:"outlined",class:"prompt-templates-view__filter mb-4"},{default:t(()=>[e(Ue,{class:"pa-4"},{default:t(()=>[e(Ie,{align:"center",dense:""},{default:t(()=>[e(ke,{cols:"12",sm:"4",md:"3"},{default:t(()=>[e(Ce,{modelValue:P(m),"onUpdate:modelValue":K[1]||(K[1]=Fe=>ot(m)?m.value=Fe:null),label:"Kategorie",items:[{title:"Alle Kategorien",value:""},...G],variant:"outlined",density:"compact","hide-details":"",clearable:""},null,8,["modelValue","items"])]),_:1}),e(ke,{cols:"12",sm:"4",md:"3"},{default:t(()=>[e(Ce,{modelValue:P(u),"onUpdate:modelValue":K[2]||(K[2]=Fe=>ot(u)?u.value=Fe:null),label:"KI-Konfiguration",items:[{title:"Alle Konfigurationen",value:""},...W.value],variant:"outlined",density:"compact","hide-details":"",clearable:""},null,8,["modelValue","items"])]),_:1}),e(ke,{cols:"12",sm:"4",md:"4"},{default:t(()=>[e(xe,{modelValue:_.value,"onUpdate:modelValue":K[3]||(K[3]=Fe=>_.value=Fe),label:"Suche","prepend-inner-icon":"mdi-magnify",variant:"outlined",density:"compact","hide-details":"",clearable:"",placeholder:"Name oder Beschreibung..."},null,8,["modelValue"])]),_:1}),e(ke,{cols:"12",sm:"12",md:"2",class:"d-flex align-center"},{default:t(()=>[e(Ne,{color:P(k)?"primary":"",variant:P(k)?"flat":"outlined","prepend-icon":"mdi-account-filter",onClick:K[4]||(K[4]=Fe=>k.value=!P(k)),class:"mr-2"},{default:t(()=>[...K[21]||(K[21]=[n(" Nur meine ",-1)])]),_:1},8,["color","variant"])]),_:1})]),_:1})]),_:1})]),_:1}),e(Te,{variant:"outlined",class:"prompt-templates-view__table-card"},{default:t(()=>[e(Ke,{class:"pa-4 pb-2"},{default:t(()=>[a("div",Y$,[a("span",X$,v(J.value.length)+" Templates ",1),e(le,{icon:"",variant:"text",size:"small",loading:c.value,"aria-label":"Aktualisieren",onClick:Z},{default:t(()=>[e(ye,{activator:"parent",location:"bottom"},{default:t(()=>[...K[22]||(K[22]=[n("Aktualisieren",-1)])]),_:1}),e(Je,null,{default:t(()=>[...K[23]||(K[23]=[n("mdi-refresh",-1)])]),_:1})]),_:1},8,["loading"])])]),_:1}),e(Ee,{headers:F,items:J.value,loading:c.value,"items-per-page":P(f),"onUpdate:itemsPerPage":K[5]||(K[5]=Fe=>ot(f)?f.value=Fe:null),"sort-by":P(p),"onUpdate:sortBy":K[6]||(K[6]=Fe=>p.value=Fe),"loading-text":"Templates werden geladen...","no-data-text":"Keine Prompt-Templates vorhanden","item-value":"_id",class:"prompt-templates-view__table"},{"item.category":t(({item:Fe})=>[e(Ne,{color:ve(Fe.category),size:"small",variant:"tonal"},{default:t(()=>[n(v(te(Fe.category)),1)]),_:2},1032,["color"])]),"item.gptSettingsId":t(({item:Fe})=>[de(Fe)?(o(),h("span",e4,v(de(Fe)),1)):(o(),h("span",t4,"--"))]),"item.version":t(({item:Fe})=>[a("span",a4,"v"+v(Fe.version),1)]),"item.isActive":t(({item:Fe})=>[e($e,{"model-value":Fe.isActive,color:"primary",density:"compact","hide-details":"","onUpdate:modelValue":Xe=>ae(Fe)},null,8,["model-value","onUpdate:modelValue"])]),"item.createdBy":t(({item:Fe})=>[e(gt,{"user-id":typeof Fe.createdBy=="object"&&Fe.createdBy?Fe.createdBy._id??null:Fe.createdBy??null,populated:typeof Fe.createdBy=="object"?Fe.createdBy:null},null,8,["user-id","populated"])]),"item.updatedBy":t(({item:Fe})=>[e(gt,{"user-id":typeof Fe.updatedBy=="object"&&Fe.updatedBy?Fe.updatedBy._id??null:Fe.updatedBy??null,populated:typeof Fe.updatedBy=="object"?Fe.updatedBy:null},null,8,["user-id","populated"])]),"item.actions":t(({item:Fe})=>[a("div",l4,[e(le,{icon:"",variant:"text",size:"small",color:"secondary","aria-label":"Vorschau",onClick:Xe=>fe(Fe)},{default:t(()=>[e(ye,{activator:"parent",location:"bottom"},{default:t(()=>[...K[24]||(K[24]=[n("Vorschau",-1)])]),_:1}),e(Je,{size:"18"},{default:t(()=>[...K[25]||(K[25]=[n("mdi-eye-outline",-1)])]),_:1})]),_:1},8,["onClick"]),e(le,{icon:"",variant:"text",size:"small",color:"primary","aria-label":"Bearbeiten",onClick:Xe=>oe(Fe)},{default:t(()=>[e(ye,{activator:"parent",location:"bottom"},{default:t(()=>[...K[26]||(K[26]=[n("Bearbeiten",-1)])]),_:1}),e(Je,{size:"18"},{default:t(()=>[...K[27]||(K[27]=[n("mdi-pencil-outline",-1)])]),_:1})]),_:1},8,["onClick"]),e(le,{icon:"",variant:"text",size:"small",color:"error",loading:M.value===Fe._id,"aria-label":"Löschen",onClick:Xe=>X(Fe)},{default:t(()=>[e(ye,{activator:"parent",location:"bottom"},{default:t(()=>[...K[28]||(K[28]=[n("Löschen",-1)])]),_:1}),e(Je,{size:"18"},{default:t(()=>[...K[29]||(K[29]=[n("mdi-trash-can-outline",-1)])]),_:1})]),_:1},8,["loading","onClick"])])]),_:1},8,["items","loading","items-per-page","sort-by"])]),_:1}),e(ct,{modelValue:g.value,"onUpdate:modelValue":K[15]||(K[15]=Fe=>g.value=Fe),"max-width":"860",scrollable:""},{default:t(()=>[e(Te,{class:"prompt-templates-view__dialog"},{default:t(()=>[e(Ke,{class:"pa-6 pb-4"},{default:t(()=>[a("div",n4,[a("span",o4,v(Q.value),1),e(le,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:pe},{default:t(()=>[e(ye,{activator:"parent",location:"bottom"},{default:t(()=>[...K[30]||(K[30]=[n("Schließen",-1)])]),_:1}),e(Je,null,{default:t(()=>[...K[31]||(K[31]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(lt),e(Ue,{class:"pa-6"},{default:t(()=>[b.value?(o(),N(ne,{key:0,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":K[7]||(K[7]=Fe=>b.value=null)},{default:t(()=>[n(v(b.value),1)]),_:1})):U("",!0),e(Ve,{modelValue:I.value,"onUpdate:modelValue":K[14]||(K[14]=Fe=>I.value=Fe),onSubmit:dt(C,["prevent"])},{default:t(()=>[e(Ie,null,{default:t(()=>[e(ke,{cols:"12",md:"6"},{default:t(()=>[e(xe,{modelValue:V.name,"onUpdate:modelValue":K[8]||(K[8]=Fe=>V.name=Fe),label:"Name",rules:L,placeholder:"z.B. Blog-Artikel Generator",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(ke,{cols:"12",md:"6"},{default:t(()=>[e(xe,{modelValue:V.description,"onUpdate:modelValue":K[9]||(K[9]=Fe=>V.description=Fe),label:"Beschreibung",placeholder:"Kurze Beschreibung des Templates",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(ke,{cols:"12",md:"6"},{default:t(()=>[e(Ce,{modelValue:V.category,"onUpdate:modelValue":K[10]||(K[10]=Fe=>V.category=Fe),label:"Kategorie",items:G,rules:A,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(ke,{cols:"12",md:"6"},{default:t(()=>[e(Ce,{modelValue:V.gptSettingsId,"onUpdate:modelValue":K[11]||(K[11]=Fe=>V.gptSettingsId=Fe),label:"KI-Konfiguration (optional)",items:W.value,variant:"outlined",density:"comfortable",clearable:"",hint:"Aus KI-Einstellungen. Kann bei Generierung noch gewechselt werden.","persistent-hint":""},null,8,["modelValue","items"])]),_:1}),e(ke,{cols:"12"},{default:t(()=>[e(ut,{modelValue:V.systemPrompt,"onUpdate:modelValue":K[12]||(K[12]=Fe=>V.systemPrompt=Fe),label:"System-Prompt",rules:z,placeholder:"Systemanweisung für das KI-Modell...",variant:"outlined",rows:"5","auto-grow":""},null,8,["modelValue"])]),_:1}),e(ke,{cols:"12"},{default:t(()=>[e(ut,{modelValue:V.userPromptTemplate,"onUpdate:modelValue":K[13]||(K[13]=Fe=>V.userPromptTemplate=Fe),label:"User-Prompt-Template",rules:j,placeholder:"Template für die Benutzeranfrage. Variablen als {{variablenname}} einfügen.",variant:"outlined",rows:"5","auto-grow":""},null,8,["modelValue"]),K[32]||(K[32]=a("div",{class:"text-caption text-medium-emphasis mt-1"},[n(" Variablen werden als "),a("code",{class:"prompt-templates-view__code"},"{{variablenname}}"),n(" definiert und weiter unten konfiguriert. ")],-1))]),_:1})]),_:1}),a("div",s4,[a("div",i4,[a("span",r4," Variablen ("+v(V.variables.length)+") ",1),e(le,{variant:"outlined",size:"small",color:"primary","prepend-icon":"mdi-plus",onClick:_e},{default:t(()=>[...K[33]||(K[33]=[n(" Variable hinzufügen ",-1)])]),_:1})]),V.variables.length===0?(o(),h("div",d4,' Keine Variablen definiert. Klicke auf "Variable hinzufügen". ')):U("",!0),(o(!0),h(be,null,Pe(V.variables,(Fe,Xe)=>(o(),h("div",{key:Xe,class:"prompt-templates-view__variable-row"},[e(Ie,{align:"center",dense:""},{default:t(()=>[e(ke,{cols:"12",sm:"3"},{default:t(()=>[e(xe,{modelValue:Fe.name,"onUpdate:modelValue":mt=>Fe.name=mt,label:"Name",placeholder:"variablenname",variant:"outlined",density:"compact","hide-details":""},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024),e(ke,{cols:"12",sm:"4"},{default:t(()=>[e(xe,{modelValue:Fe.description,"onUpdate:modelValue":mt=>Fe.description=mt,label:"Beschreibung",placeholder:"Was beschreibt diese Variable?",variant:"outlined",density:"compact","hide-details":""},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024),e(ke,{cols:"12",sm:"3"},{default:t(()=>[e(xe,{modelValue:Fe.defaultValue,"onUpdate:modelValue":mt=>Fe.defaultValue=mt,label:"Standardwert",placeholder:"Optional",variant:"outlined",density:"compact","hide-details":""},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024),e(ke,{cols:"6",sm:"1"},{default:t(()=>[e($e,{modelValue:Fe.required,"onUpdate:modelValue":mt=>Fe.required=mt,label:"Pflicht",color:"primary",density:"compact","hide-details":""},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024),e(ke,{cols:"6",sm:"1",class:"d-flex justify-end"},{default:t(()=>[e(le,{icon:"",variant:"text",size:"small",color:"error","aria-label":"Variable entfernen",onClick:mt=>q(Xe)},{default:t(()=>[e(ye,{activator:"parent",location:"bottom"},{default:t(()=>[...K[34]||(K[34]=[n("Variable entfernen",-1)])]),_:1}),e(Je,{size:"18"},{default:t(()=>[...K[35]||(K[35]=[n("mdi-close",-1)])]),_:1})]),_:1},8,["onClick"])]),_:2},1024)]),_:2},1024)]))),128))])]),_:1},8,["modelValue"])]),_:1}),e(lt),e(Ye,{class:"pa-4"},{default:t(()=>[e(Le),e(le,{variant:"text",onClick:pe},{default:t(()=>[...K[36]||(K[36]=[n("Abbrechen",-1)])]),_:1}),e(le,{color:"primary",variant:"elevated",loading:w.value,disabled:!I.value,onClick:C},{default:t(()=>[...K[37]||(K[37]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(ct,{modelValue:T.value,"onUpdate:modelValue":K[16]||(K[16]=Fe=>T.value=Fe),"max-width":"720",scrollable:""},{default:t(()=>[e(Te,{class:"prompt-templates-view__dialog"},{default:t(()=>[e(Ke,{class:"pa-6 pb-4"},{default:t(()=>[a("div",u4,[K[40]||(K[40]=a("span",{class:"text-h6"},"Template-Vorschau",-1)),e(le,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:Se},{default:t(()=>[e(ye,{activator:"parent",location:"bottom"},{default:t(()=>[...K[38]||(K[38]=[n("Schließen",-1)])]),_:1}),e(Je,null,{default:t(()=>[...K[39]||(K[39]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(lt),e(Ue,{class:"pa-6"},{default:t(()=>[Object.keys(H.value).length>0?(o(),h("div",c4,[K[41]||(K[41]=a("div",{class:"text-subtitle-2 font-weight-semibold mb-3"},"Variablen-Werte",-1)),e(Ie,{dense:""},{default:t(()=>[(o(!0),h(be,null,Pe(H.value,(Fe,Xe)=>(o(),N(ke,{key:Xe,cols:"12",sm:"6"},{default:t(()=>[e(xe,{modelValue:H.value[Xe],"onUpdate:modelValue":mt=>H.value[Xe]=mt,label:String(Xe),variant:"outlined",density:"compact"},null,8,["modelValue","onUpdate:modelValue","label"])]),_:2},1024))),128))]),_:1})])):U("",!0),e(le,{color:"primary",variant:"elevated",loading:O.value,"prepend-icon":"mdi-play-outline",class:"mb-4",onClick:me},{default:t(()=>[...K[42]||(K[42]=[n(" Vorschau generieren ",-1)])]),_:1},8,["loading"]),B.value?(o(),N(ne,{key:1,type:"error",variant:"tonal",class:"mb-4"},{default:t(()=>[n(v(B.value),1)]),_:1})):U("",!0),S.value?(o(),N(Te,{key:2,variant:"tonal",color:"success"},{default:t(()=>[e(Ue,{class:"pa-4"},{default:t(()=>[K[43]||(K[43]=a("div",{class:"text-body-2 font-weight-semibold mb-2"},"KI-Vorschau:",-1)),a("p",m4,v(S.value),1)]),_:1})]),_:1})):U("",!0)]),_:1}),e(lt),e(Ye,{class:"pa-4"},{default:t(()=>[e(Le),e(le,{variant:"text",onClick:Se},{default:t(()=>[...K[44]||(K[44]=[n("Schließen",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(ct,{modelValue:E.value,"onUpdate:modelValue":K[18]||(K[18]=Fe=>E.value=Fe),"max-width":"440"},{default:t(()=>[e(Te,null,{default:t(()=>[e(Ke,{class:"pa-6 pb-4 text-subtitle-1"},{default:t(()=>[...K[45]||(K[45]=[n("Template löschen?",-1)])]),_:1}),e(Ue,{class:"pa-6 pt-0 text-body-2 text-medium-emphasis"},{default:t(()=>[...K[46]||(K[46]=[n(" Diese Aktion kann nicht rückgängig gemacht werden. Das Prompt-Template wird dauerhaft gelöscht. ",-1)])]),_:1}),e(Ye,{class:"pa-4"},{default:t(()=>[e(Le),e(le,{variant:"text",onClick:K[17]||(K[17]=Fe=>E.value=!1)},{default:t(()=>[...K[47]||(K[47]=[n("Abbrechen",-1)])]),_:1}),e(le,{color:"error",variant:"elevated",onClick:ie},{default:t(()=>[...K[48]||(K[48]=[n("Löschen",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}}),p4=Me(v4,[["__scopeId","data-v-221b63ec"]]),T6=Object.freeze(Object.defineProperty({__proto__:null,default:p4},Symbol.toStringTag,{value:"Module"})),f4=[{key:"anthropic",label:"Anthropic Claude",icon:"mdi-robot-outline",color:"#0AC9D4"},{key:"azure-openai",label:"Azure OpenAI",icon:"mdi-microsoft-azure",color:"#0089D6"},{key:"gemini",label:"Google Gemini",icon:"mdi-google",color:"#EA4335"}],g4=[{title:"Name",key:"name",sortable:!0},{title:"Provider",key:"provider",sortable:!0},{title:"Modell",key:"model",sortable:!0},{title:"Temperature",key:"temperature",sortable:!0},{title:"Aktiv",key:"isActive",sortable:!1},{title:"Default",key:"isDefault",sortable:!1},{title:"Aktionen",key:"actions",sortable:!1,align:"end"}],b4=[{title:"Anthropic Claude",value:"anthropic"},{title:"Azure OpenAI",value:"azure-openai"},{title:"Google Gemini",value:"gemini"}],Ca={anthropic:[{title:"Claude Opus 4.6",value:"claude-opus-4-6",subtitle:"Intelligentestes Modell, Agenten & Coding"},{title:"Claude Sonnet 4.6",value:"claude-sonnet-4-6",subtitle:"Beste Balance aus Geschwindigkeit & Intelligenz"},{title:"Claude Haiku 4.5",value:"claude-haiku-4-5-20251001",subtitle:"Schnellstes Modell, Near-Frontier"},{title:"Claude Sonnet 4",value:"claude-sonnet-4-20250514",subtitle:"Bewährt, schnell & leistungsstark"},{title:"Claude Opus 4",value:"claude-opus-4-20250514",subtitle:"Vorgänger, komplexe Aufgaben"}],"azure-openai":[{title:"GPT-5.4",value:"gpt-5.4",subtitle:"Flaggschiff, komplexes Reasoning & Coding"},{title:"GPT-5 Mini",value:"gpt-5-mini",subtitle:"Near-Frontier, kosteneffizient"},{title:"GPT-4.1",value:"gpt-4.1",subtitle:"Coding & Instruction-Following"},{title:"GPT-4.1 Mini",value:"gpt-4.1-mini",subtitle:"Schnell & effizient"},{title:"GPT-4.1 Nano",value:"gpt-4.1-nano",subtitle:"Leichtestes Modell, Budget"},{title:"GPT-4o",value:"gpt-4o",subtitle:"Multimodal, bewährt"},{title:"GPT-4o Mini",value:"gpt-4o-mini",subtitle:"Multimodal, kostengünstig"},{title:"o3",value:"o3",subtitle:"Stärkstes Reasoning-Modell"},{title:"o4-mini",value:"o4-mini",subtitle:"Schnelles Reasoning, kostengünstig"},{title:"o3-mini",value:"o3-mini",subtitle:"Kompaktes Reasoning-Modell"}],gemini:[{title:"Gemini 2.5 Pro",value:"gemini-2.5-pro",subtitle:"Stärkstes Modell, Deep Reasoning & Coding"},{title:"Gemini 2.5 Flash",value:"gemini-2.5-flash",subtitle:"Bestes Preis-Leistungs-Verhältnis"},{title:"Gemini 2.5 Flash Lite",value:"gemini-2.5-flash-lite",subtitle:"Schnellstes & günstigstes Gemini"},{title:"Gemini 3.1 Pro Preview",value:"gemini-3.1-pro-preview",subtitle:"Neuestes Modell, Preview"},{title:"Gemini 3 Flash Preview",value:"gemini-3-flash-preview",subtitle:"Frontier-Leistung, Preview"}]};function y4(){const r=y([]),$=y(!1),d=y(null),c=y(!1),s=y(null),m=y(!1),u=y(null),f=y(null),p=y(null),_=y(!1),k=y(null),i=y(null),g=y(!1),x=y(!1),w=y(null),b=wt({name:"",description:"",provider:"",model:"",systemPrompt:"",temperature:.7,maxTokens:4096,additionalInstructions:""}),I=se(()=>b.provider?Ca[b.provider]??[]:[]),V=se(()=>s.value?"KI-Konfiguration bearbeiten":"Neue KI-Konfiguration");Ze(()=>b.provider,(Q,te)=>{Q&&te&&Q!==te&&((Ca[Q]??[]).some(de=>de.value===b.model)||(b.model=""))}),Ze(()=>b.model,Q=>{if(!Q)return;const ve=(Ca[b.provider]??[]).find(de=>de.value===Q);ve&&(b.name=ve.title)});const E=[Q=>!!Q||"Name ist erforderlich",Q=>Q.length>=3||"Mindestens 3 Zeichen"],R=[Q=>!!Q||"Provider ist erforderlich"],M=[Q=>!!Q||"Modell ist erforderlich"];function T(Q){return r.value.find(te=>te.provider===Q&&te.isDefault)}function D(Q){return r.value.some(te=>te.provider===Q&&te.isActive)}function H(Q){return{anthropic:"Anthropic","azure-openai":"Azure OpenAI",gemini:"Gemini"}[Q]||Q}function O(Q){return{anthropic:"primary","azure-openai":"info",gemini:"error"}[Q]||"default"}async function S(){$.value=!0,d.value=null;try{const Q=await re.get("/gpt-settings");if(Q.success&&Q.data){const te=Q.data;r.value=Array.isArray(te)?te:te.items??[]}else d.value=Q.error||"Fehler beim Laden der KI-Einstellungen"}catch{d.value="Netzwerkfehler beim Laden der KI-Einstellungen"}finally{$.value=!1}}function B(){s.value=null,Object.assign(b,{name:"",description:"",provider:"",model:"",systemPrompt:"",temperature:.7,maxTokens:4096,additionalInstructions:""}),u.value=null,k.value=null,i.value=null,c.value=!0}function G(Q){s.value=Q._id,Object.assign(b,{name:Q.name,description:Q.description,provider:Q.provider,model:Q.model,systemPrompt:Q.systemPrompt,temperature:Q.temperature,maxTokens:Q.maxTokens,additionalInstructions:Q.additionalInstructions}),u.value=null,k.value=null,i.value=null,c.value=!0}function W(){c.value=!1}async function F(){if(!g.value)return;m.value=!0,u.value=null;const Q={name:b.name,description:b.description,provider:b.provider,model:b.model,systemPrompt:b.systemPrompt,temperature:b.temperature,maxTokens:b.maxTokens,additionalInstructions:b.additionalInstructions};try{let te;s.value?te=await re.put(`/gpt-settings/${s.value}`,Q):te=await re.post("/gpt-settings",Q),te.success?(await S(),W()):u.value=te.error||"Fehler beim Speichern"}catch{u.value="Netzwerkfehler beim Speichern"}finally{m.value=!1}}async function L(Q){try{const te=await re.put(`/gpt-settings/${Q._id}`,{isActive:!Q.isActive});te.success?await S():d.value=te.error||"Fehler beim Aktualisieren"}catch{d.value="Netzwerkfehler beim Aktualisieren"}}async function A(Q){p.value=Q._id;try{const te=await re.put(`/gpt-settings/${Q._id}/default`,{});te.success?await S():d.value=te.error||"Fehler beim Setzen des Standards"}catch{d.value="Netzwerkfehler"}finally{p.value=null}}function z(Q){w.value=Q._id,x.value=!0}async function j(){if(w.value){f.value=w.value,x.value=!1;try{const Q=await re.delete(`/gpt-settings/${w.value}`);Q.success?await S():d.value=Q.error||"Fehler beim Löschen"}catch{d.value="Netzwerkfehler beim Löschen"}finally{f.value=null,w.value=null}}}async function J(){if(s.value){_.value=!0,k.value=null,i.value=null;try{const Q=await re.post(`/gpt-settings/${s.value}/test`);Q.success&&Q.data?k.value=Q.data:i.value=Q.error||"Fehler beim Testen der Konfiguration"}catch{i.value="Netzwerkfehler beim Testen"}finally{_.value=!1}}}return{settings:r,loading:$,error:d,dialogOpen:c,editingId:s,saving:m,saveError:u,deletingId:f,settingDefaultId:p,testLoading:_,testResult:k,testError:i,formValid:g,deleteDialogOpen:x,deleteTargetId:w,form:b,availableModels:I,dialogTitle:V,nameRules:E,providerRules:R,modelRules:M,getProviderSettings:T,isProviderConfigured:D,getProviderLabel:H,getProviderColor:O,loadSettings:S,openCreateDialog:B,openEditDialog:G,closeDialog:W,saveSettings:F,toggleActive:L,setDefault:A,confirmDelete:z,executeDelete:j,testSetting:J}}function _4(){const r=y([]),$=y(!1);async function d(){$.value=!0;try{const c=await re.get("/knowledge-base/for-context");c.success&&c.data&&(r.value=Array.isArray(c.data)?c.data.map(s=>({_id:s._id,title:s.title,category:s.entryType||""})):[])}catch{}finally{$.value=!1}}return{knowledgeBases:r,kbLoading:$,loadKnowledgeBases:d}}function k4(){const r=y(null),$=y(!1),d=y(null),c=y(!1),s=y(!1),m=wt({systemPrompt:"",selectedKnowledgeBaseIds:[],gptSettingsId:""});async function u(){$.value=!0,d.value=null;try{const E=await re.get("/admin/pages/config");E.success&&E.data?(r.value=E.data,m.systemPrompt=E.data.systemPrompt||"",m.selectedKnowledgeBaseIds=E.data.selectedKnowledgeBaseIds||[],m.gptSettingsId=E.data.gptSettingsId||""):d.value=E.error||"Fehler beim Laden der Seiten-Konfiguration"}catch{d.value="Netzwerkfehler beim Laden"}finally{$.value=!1}}async function f(){c.value=!0,d.value=null,s.value=!1;try{const E=await re.put("/admin/pages/config",{systemPrompt:m.systemPrompt,selectedKnowledgeBaseIds:m.selectedKnowledgeBaseIds,gptSettingsId:m.gptSettingsId||void 0});E.success?s.value=!0:d.value=E.error||"Fehler beim Speichern"}catch{d.value="Netzwerkfehler beim Speichern"}finally{c.value=!1}}const p=se(()=>r.value?m.systemPrompt!==(r.value.systemPrompt??"")||JSON.stringify(m.selectedKnowledgeBaseIds)!==JSON.stringify(r.value.selectedKnowledgeBaseIds??[])||(m.gptSettingsId||"")!==(r.value.gptSettingsId??""):!1),_=y(null),k=y(!1),i=y(null),g=y(!1),x=y(!1),w=wt({systemPrompt:"",promptEmailDraft:"",selectedKnowledgeBaseIds:[],gptSettingsId:""});async function b(){k.value=!0,i.value=null;try{const E=await re.get("/email-campaigns/config");E.success&&E.data?(_.value=E.data,w.systemPrompt=E.data.systemPrompt||"",w.promptEmailDraft=E.data.promptEmailDraft||"",w.selectedKnowledgeBaseIds=E.data.selectedKnowledgeBaseIds||[],w.gptSettingsId=E.data.gptSettingsId||""):i.value=E.error||"Fehler beim Laden der E-Mail-Konfiguration"}catch{i.value="Netzwerkfehler beim Laden"}finally{k.value=!1}}async function I(){g.value=!0,i.value=null,x.value=!1;try{const E=await re.put("/email-campaigns/config",{systemPrompt:w.systemPrompt,promptEmailDraft:w.promptEmailDraft,selectedKnowledgeBaseIds:w.selectedKnowledgeBaseIds,gptSettingsId:w.gptSettingsId||void 0});E.success?x.value=!0:i.value=E.error||"Fehler beim Speichern"}catch{i.value="Netzwerkfehler beim Speichern"}finally{g.value=!1}}const V=se(()=>_.value?w.systemPrompt!==(_.value.systemPrompt??"")||w.promptEmailDraft!==(_.value.promptEmailDraft??"")||JSON.stringify(w.selectedKnowledgeBaseIds)!==JSON.stringify(_.value.selectedKnowledgeBaseIds??[])||(w.gptSettingsId||"")!==(_.value.gptSettingsId??""):!1);return{pageConfig:r,pageConfigLoading:$,pageConfigError:d,pageConfigSaving:c,pageConfigSuccess:s,pageConfigForm:m,pageConfigDirty:p,loadPageConfig:u,savePageConfig:f,emailConfig:_,emailConfigLoading:k,emailConfigError:i,emailConfigSaving:g,emailConfigSuccess:x,emailConfigForm:w,emailConfigDirty:V,loadEmailConfig:b,saveEmailConfig:I}}function h4(r){const $=y(null),d=y(!1),c=y(null),s=y(!1),m=y(!1),u=y(!1),f=y(!1),p=wt({industry:"",targetAudience:"",brandVoice:"",coreTopics:[],defaultPostTime:"09:00",promptContentPlan:"",promptPostDraft:"",promptHashtags:"",promptLandingPage:"",promptImageTags:"",promptImageGeneration:"",selectedKnowledgeBaseIds:[],dryRun:!1});async function _(){var w;d.value=!0,c.value=null;try{const b=await re.get("/linkedin/config");b.success&&b.data?($.value=b.data,Object.assign(p,{industry:b.data.industry||"",targetAudience:b.data.targetAudience||"",brandVoice:b.data.brandVoice||"",coreTopics:b.data.topics||[],defaultPostTime:b.data.defaultPostTime||"09:00",promptContentPlan:b.data.promptContentPlan||"",promptPostDraft:b.data.promptPostDraft||"",promptHashtags:b.data.promptHashtags||"",promptLandingPage:b.data.promptLandingPage||"",promptImageTags:b.data.promptImageTags||"",promptImageGeneration:b.data.promptImageGeneration||"",selectedKnowledgeBaseIds:b.data.selectedKnowledgeBaseIds||[],dryRun:((w=b.data.approval)==null?void 0:w.dryRun)??!1})):c.value=b.error||"Fehler beim Laden der LinkedIn-Konfiguration",await r()}catch{c.value="Netzwerkfehler beim Laden"}finally{d.value=!1}}async function k(){s.value=!0,c.value=null,m.value=!1;try{const w=await re.put("/linkedin/config",{industry:p.industry,targetAudience:p.targetAudience,brandVoice:p.brandVoice,topics:p.coreTopics,defaultPostTime:p.defaultPostTime,promptContentPlan:p.promptContentPlan,promptPostDraft:p.promptPostDraft,promptHashtags:p.promptHashtags,promptLandingPage:p.promptLandingPage,promptImageTags:p.promptImageTags,promptImageGeneration:p.promptImageGeneration,selectedKnowledgeBaseIds:p.selectedKnowledgeBaseIds,approval:{dryRun:p.dryRun}});w.success?(m.value=!0,$.value&&($.value={...$.value,industry:p.industry,targetAudience:p.targetAudience,brandVoice:p.brandVoice,topics:[...p.coreTopics],defaultPostTime:p.defaultPostTime,promptContentPlan:p.promptContentPlan,promptPostDraft:p.promptPostDraft,promptHashtags:p.promptHashtags,promptLandingPage:p.promptLandingPage,promptImageTags:p.promptImageTags,promptImageGeneration:p.promptImageGeneration,selectedKnowledgeBaseIds:[...p.selectedKnowledgeBaseIds],approval:{...$.value.approval??{},dryRun:p.dryRun}})):c.value=w.error||"Fehler beim Speichern"}catch{c.value="Netzwerkfehler beim Speichern"}finally{s.value=!1}}async function i(){var w;u.value=!0;try{const b=await re.get("/linkedin/auth/url");b.success&&((w=b.data)!=null&&w.url)?window.open(b.data.url,"_blank","noopener,noreferrer"):c.value=b.error||"Fehler beim Abrufen der OAuth-URL"}catch{c.value="Netzwerkfehler bei OAuth"}finally{u.value=!1}}async function g(){f.value=!0;try{const w=await re.delete("/linkedin/auth/disconnect");w.success?(m.value=!0,await _()):c.value=w.error||"Trennen fehlgeschlagen."}catch{c.value="Netzwerkfehler beim Trennen."}finally{f.value=!1}}const x=se(()=>{var w;return $.value?p.industry!==($.value.industry??"")||p.targetAudience!==($.value.targetAudience??"")||p.brandVoice!==($.value.brandVoice??"")||JSON.stringify(p.coreTopics)!==JSON.stringify($.value.topics??[])||p.defaultPostTime!==($.value.defaultPostTime??"09:00")||p.promptContentPlan!==($.value.promptContentPlan??"")||p.promptPostDraft!==($.value.promptPostDraft??"")||p.promptHashtags!==($.value.promptHashtags??"")||p.promptLandingPage!==($.value.promptLandingPage??"")||p.promptImageTags!==($.value.promptImageTags??"")||p.promptImageGeneration!==($.value.promptImageGeneration??"")||JSON.stringify(p.selectedKnowledgeBaseIds)!==JSON.stringify($.value.selectedKnowledgeBaseIds??[])||p.dryRun!==(((w=$.value.approval)==null?void 0:w.dryRun)??!1):!1});return{linkedinConfig:$,linkedinLoading:d,linkedinError:c,linkedinSaving:s,linkedinSuccess:m,oauthLoading:u,linkedinDisconnecting:f,linkedinForm:p,linkedinDirty:x,loadLinkedinConfig:_,saveLinkedinConfig:k,openOAuth:i,disconnectLinkedinAccount:g}}function x4(){const r=y(null),$=y(!1),d=y(null),c=y(!1),s=y(!1),m=wt({systemPrompt:"",userPromptTemplate:"",gptSettingsId:""}),u=se(()=>r.value?m.systemPrompt!==(r.value.systemPrompt??"")||m.userPromptTemplate!==(r.value.userPromptTemplate??"")||(m.gptSettingsId||"")!==(r.value.gptSettingsId??""):!1),f=y(""),p=y(!1),_=y(null),k=y(!1),i=y(!1);async function g(){var ce;$.value=!0,d.value=null;try{const[oe,pe]=await Promise.all([re.get("/prompts?category=lead-research&isActive=true&limit=10"),re.get("/platform-settings")]);if(oe.success&&oe.data){const _e=oe.data.items??[],q=_e.find(C=>C.isDefault)??_e[0]??null;r.value=q,q&&(m.systemPrompt=q.systemPrompt??"",m.userPromptTemplate=q.userPromptTemplate??"",m.gptSettingsId=q.gptSettingsId??"")}else d.value=oe.error||"Fehler beim Laden des Lead-Research-Prompts";pe.success&&pe.data&&(f.value=((ce=pe.data.outreach)==null?void 0:ce.defaultSenderEmail)??"")}catch{d.value="Netzwerkfehler beim Laden der Lead-Research-Konfiguration"}finally{$.value=!1}}async function x(){var ce;if((ce=r.value)!=null&&ce._id){c.value=!0,d.value=null,s.value=!1;try{const oe=await re.put(`/prompts/${r.value._id}`,{systemPrompt:m.systemPrompt,userPromptTemplate:m.userPromptTemplate,gptSettingsId:m.gptSettingsId||void 0});oe.success?s.value=!0:d.value=oe.error||"Fehler beim Speichern"}catch{d.value="Netzwerkfehler beim Speichern"}finally{c.value=!1}}}async function w(){k.value=!0,_.value=null,i.value=!1;try{const ce=await re.put("/platform-settings/outreach",{defaultSenderEmail:f.value});ce.success?i.value=!0:_.value=ce.error||"Fehler beim Speichern"}catch{_.value="Netzwerkfehler beim Speichern des Versenders"}finally{k.value=!1}}const b=y(null),I=y(!1),V=y(null),E=y(!1),R=y(!1),M=wt({systemPrompt:"",userPromptTemplate:"",gptSettingsId:""}),T=wt({...xa}),D=wt({...xa}),H=y(!1),O=y(null),S=y(!1),B=y(!1),G=y(!1),W=y(!1),F=y(null),L=y(!1),A=se(()=>T.regulatory+T.mandate+T.industryFit+T.maturity+T.engagement),z=se(()=>T.regulatory!==D.regulatory||T.mandate!==D.mandate||T.industryFit!==D.industryFit||T.maturity!==D.maturity||T.engagement!==D.engagement),j=se(()=>B.value!==G.value),J=se(()=>b.value?M.systemPrompt!==(b.value.systemPrompt??"")||M.userPromptTemplate!==(b.value.userPromptTemplate??"")||(M.gptSettingsId||"")!==(b.value.gptSettingsId??""):!1),Q=se(()=>J.value||z.value||j.value);async function te(){var ce,oe;I.value=!0,V.value=null;try{const[pe,_e]=await Promise.all([re.get("/prompts?category=company-scoring&isActive=true&limit=10"),re.get("/platform-settings")]);if(pe.success&&pe.data){const q=pe.data.items??[],C=q.find(ae=>ae.isDefault)??q[0]??null;b.value=C,C&&(M.systemPrompt=C.systemPrompt??"",M.userPromptTemplate=C.userPromptTemplate??"",M.gptSettingsId=C.gptSettingsId??"")}else V.value=pe.error||"Fehler beim Laden des Company-Scoring-Prompts";if(_e.success&&_e.data){const q=((ce=_e.data.scoring)==null?void 0:ce.weights)??{...xa};Object.assign(T,q),Object.assign(D,q);const C=((oe=_e.data.scoring)==null?void 0:oe.autoOnCreate)??!1;B.value=C,G.value=C}}catch{V.value="Netzwerkfehler beim Laden der Company-Scoring-Konfiguration"}finally{I.value=!1}}async function ve(){var ce;if((ce=b.value)!=null&&ce._id){E.value=!0,V.value=null,R.value=!1;try{const oe=await re.put(`/prompts/${b.value._id}`,{systemPrompt:M.systemPrompt,userPromptTemplate:M.userPromptTemplate,gptSettingsId:M.gptSettingsId||void 0});oe.success?(R.value=!0,b.value&&(b.value={...b.value,systemPrompt:M.systemPrompt,userPromptTemplate:M.userPromptTemplate,gptSettingsId:M.gptSettingsId||void 0})):V.value=oe.error||"Fehler beim Speichern des Prompts"}catch{V.value="Netzwerkfehler beim Speichern des Prompts"}finally{E.value=!1}}}async function de(){if(A.value===100){H.value=!0,O.value=null,S.value=!1;try{const ce=await re.put("/platform-settings/scoring",{weights:{...T},autoOnCreate:B.value});ce.success?(S.value=!0,Object.assign(D,T),G.value=B.value):O.value=ce.error||"Fehler beim Speichern der Gewichtungen"}catch{O.value="Netzwerkfehler beim Speichern der Gewichtungen"}finally{H.value=!1}}}async function Z(){W.value=!0,F.value=null,L.value=!1;try{const ce=await re.put("/platform-settings/scoring",{weights:{...T},autoOnCreate:B.value});ce.success?(L.value=!0,G.value=B.value,Object.assign(D,T)):F.value=ce.error||"Fehler beim Speichern"}catch{F.value="Netzwerkfehler beim Speichern"}finally{W.value=!1}}return{leadResearchPrompt:r,leadResearchLoading:$,leadResearchError:d,leadResearchSaving:c,leadResearchSuccess:s,leadResearchForm:m,leadResearchDirty:u,loadLeadResearchConfig:g,saveLeadResearchConfig:x,defaultSender:f,senderLoading:p,senderError:_,senderSaving:k,senderSuccess:i,saveDefaultSender:w,companyScoringPrompt:b,companyScoringLoading:I,companyScoringError:V,companyScoringPromptSaving:E,companyScoringPromptSuccess:R,companyScoringForm:M,companyScoringPromptDirty:J,companyScoringDirty:Q,scoringWeights:T,weightsSum:A,weightsDirty:z,weightsSaving:H,weightsError:O,weightsSuccess:S,autoOnCreate:B,autoOnCreateDirty:j,autoOnCreateSaving:W,autoOnCreateError:F,autoOnCreateSuccess:L,loadCompanyScoringConfig:te,saveCompanyScoringPrompt:ve,saveScoringWeights:de,saveAutoOnCreate:Z}}function w4(){const r=y(null),$=y(!1),d=y(null),c=y(!1),s=y(!1),m=wt({gptSettingsId:"",systemPrompt:"",userPromptTemplate:""}),u=se(()=>r.value?m.systemPrompt!==(r.value.systemPrompt??"")||m.userPromptTemplate!==(r.value.userPromptTemplate??"")||(m.gptSettingsId||"")!==(r.value.gptSettingsId??""):!1),f=se(()=>u.value);async function p(){$.value=!0,d.value=null;try{const q=await re.get("/prompts?category=outreach-strategy&isActive=true&limit=10");if(q.success&&q.data){const C=q.data.items??[],ae=C.find(X=>X.isDefault)??C[0]??null;r.value=ae,ae&&(m.systemPrompt=ae.systemPrompt??"",m.userPromptTemplate=ae.userPromptTemplate??"",m.gptSettingsId=ae.gptSettingsId??"")}else d.value=q.error||"Fehler beim Laden des Outreach-Prompts"}catch{d.value="Netzwerkfehler beim Laden"}finally{$.value=!1}}async function _(){var q;if((q=r.value)!=null&&q._id){c.value=!0,d.value=null,s.value=!1;try{const C=await re.put(`/prompts/${r.value._id}`,{systemPrompt:m.systemPrompt,userPromptTemplate:m.userPromptTemplate,gptSettingsId:m.gptSettingsId||void 0});C.success?(s.value=!0,r.value={...r.value,systemPrompt:m.systemPrompt,userPromptTemplate:m.userPromptTemplate,gptSettingsId:m.gptSettingsId||void 0}):d.value=C.error||"Fehler beim Speichern"}catch{d.value="Netzwerkfehler beim Speichern"}finally{c.value=!1}}}const k=y(null),i=y(!1),g=y(null),x=y(!1),w=y(!1),b=wt({gptSettingsId:"",systemPrompt:"",userPromptTemplate:""}),I=wt({replyMarker:!0,mailjetClick:!0,meetingBooked:!0,pipelineStageChange:!0}),V=wt({replyMarker:!0,mailjetClick:!0,meetingBooked:!0,pipelineStageChange:!0}),E=y(!1),R=y(null),M=y(!1),T=se(()=>k.value?b.systemPrompt!==(k.value.systemPrompt??"")||b.userPromptTemplate!==(k.value.userPromptTemplate??"")||(b.gptSettingsId||"")!==(k.value.gptSettingsId??""):!1),D=se(()=>I.replyMarker!==V.replyMarker||I.mailjetClick!==V.mailjetClick||I.meetingBooked!==V.meetingBooked||I.pipelineStageChange!==V.pipelineStageChange),H=se(()=>T.value||D.value);async function O(){var q;i.value=!0,g.value=null;try{const[C,ae]=await Promise.all([re.get("/prompts?category=intent-classification&isActive=true&limit=10"),re.get("/platform-settings")]);if(C.success&&C.data){const X=C.data.items??[],ie=X.find(fe=>fe.isDefault)??X[0]??null;k.value=ie,ie&&(b.systemPrompt=ie.systemPrompt??"",b.userPromptTemplate=ie.userPromptTemplate??"",b.gptSettingsId=ie.gptSettingsId??"")}else g.value=C.error||"Fehler beim Laden des Intent-Prompts";if(ae.success&&ae.data){const X=(q=ae.data.intent)==null?void 0:q.autoTriggers;X&&(Object.assign(I,X),Object.assign(V,X))}}catch{g.value="Netzwerkfehler beim Laden"}finally{i.value=!1}}async function S(){var q;if((q=k.value)!=null&&q._id){x.value=!0,g.value=null,w.value=!1;try{const C=await re.put(`/prompts/${k.value._id}`,{systemPrompt:b.systemPrompt,userPromptTemplate:b.userPromptTemplate,gptSettingsId:b.gptSettingsId||void 0});C.success?(w.value=!0,k.value={...k.value,systemPrompt:b.systemPrompt,userPromptTemplate:b.userPromptTemplate,gptSettingsId:b.gptSettingsId||void 0}):g.value=C.error||"Fehler beim Speichern"}catch{g.value="Netzwerkfehler beim Speichern"}finally{x.value=!1}}}async function B(){E.value=!0,R.value=null,M.value=!1;try{const q=await re.put("/platform-settings/intent",{autoTriggers:{...I}});q.success?(M.value=!0,Object.assign(V,I)):R.value=q.error||"Fehler beim Speichern"}catch{R.value="Netzwerkfehler beim Speichern"}finally{E.value=!1}}const G=y(null),W=y(!1),F=y(null),L=y(!1),A=y(!1),z=wt({gptSettingsId:"",systemPrompt:"",userPromptTemplate:""}),j=y(30),J=y(30),Q=y(!1),te=y(null),ve=y(!1),de=se(()=>G.value?z.systemPrompt!==(G.value.systemPrompt??"")||z.userPromptTemplate!==(G.value.userPromptTemplate??"")||(z.gptSettingsId||"")!==(G.value.gptSettingsId??""):!1),Z=se(()=>j.value!==J.value),ce=se(()=>de.value||Z.value);async function oe(){var q;W.value=!0,F.value=null;try{const[C,ae]=await Promise.all([re.get("/prompts?category=direct-mail-draft&isActive=true&limit=10"),re.get("/platform-settings")]);if(C.success&&C.data){const X=C.data.items??[],ie=X.find(fe=>fe.isDefault)??X[0]??null;G.value=ie,ie&&(z.systemPrompt=ie.systemPrompt??"",z.userPromptTemplate=ie.userPromptTemplate??"",z.gptSettingsId=ie.gptSettingsId??"")}else F.value=C.error||"Fehler beim Laden des Direct-Mail-Prompts";if(ae.success&&ae.data){const X=((q=ae.data.directMail)==null?void 0:q.undoDelaySec)??30;j.value=X,J.value=X}}catch{F.value="Netzwerkfehler beim Laden"}finally{W.value=!1}}async function pe(){var q;if((q=G.value)!=null&&q._id){L.value=!0,F.value=null,A.value=!1;try{const C=await re.put(`/prompts/${G.value._id}`,{systemPrompt:z.systemPrompt,userPromptTemplate:z.userPromptTemplate,gptSettingsId:z.gptSettingsId||void 0});C.success?(A.value=!0,G.value={...G.value,systemPrompt:z.systemPrompt,userPromptTemplate:z.userPromptTemplate,gptSettingsId:z.gptSettingsId||void 0}):F.value=C.error||"Fehler beim Speichern"}catch{F.value="Netzwerkfehler beim Speichern"}finally{L.value=!1}}}async function _e(){Q.value=!0,te.value=null,ve.value=!1;try{const q=await re.put("/platform-settings/direct-mail",{undoDelaySec:j.value});q.success?(ve.value=!0,J.value=j.value):te.value=q.error||"Fehler beim Speichern"}catch{te.value="Netzwerkfehler beim Speichern"}finally{Q.value=!1}}return{outreachPrompt:r,outreachLoading:$,outreachError:d,outreachPromptSaving:c,outreachPromptSuccess:s,outreachForm:m,outreachPromptDirty:u,outreachDirty:f,loadOutreachConfig:p,saveOutreachPrompt:_,intentPrompt:k,intentLoading:i,intentError:g,intentPromptSaving:x,intentPromptSuccess:w,intentForm:b,intentAutoTriggers:I,intentAutoTriggersSaving:E,intentAutoTriggersError:R,intentAutoTriggersSuccess:M,intentPromptDirty:T,autoTriggersDirty:D,intentDirty:H,loadIntentConfig:O,saveIntentPrompt:S,saveIntentAutoTriggers:B,directMailPrompt:G,directMailLoading:W,directMailError:F,directMailPromptSaving:L,directMailPromptSuccess:A,directMailForm:z,directMailPromptDirty:de,directMailDirty:ce,undoDelaySec:j,undoDelaySecDirty:Z,undoDelaySecSaving:Q,undoDelaySecError:te,undoDelaySecSuccess:ve,loadDirectMailConfig:oe,saveDirectMailPrompt:pe,saveUndoDelaySec:_e}}function S4(){const r=_4(),$=k4(),d=h4(r.loadKnowledgeBases),c=x4(),s=w4();return{...$,...d,...r,...c,...s}}const $4={class:"ki-settings-header"},C4=Ae({__name:"KiSettingsHeader",emits:["create"],setup(r){return($,d)=>{const c=l("v-btn");return o(),h("div",$4,[d[2]||(d[2]=a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"KI-Einstellungen"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," Multi-Provider KI-Konfigurationen und LinkedIn-Integration verwalten ")],-1)),e(c,{color:"primary","prepend-icon":"mdi-plus",onClick:d[0]||(d[0]=s=>$.$emit("create"))},{default:t(()=>[...d[1]||(d[1]=[n(" Neue Konfiguration ",-1)])]),_:1})])}}}),V4=Me(C4,[["__scopeId","data-v-e1c1e4ea"]]),A4={class:"ki-settings-view__providers mb-6"},I4={class:"d-flex align-center justify-space-between mb-3"},P4={class:"d-flex align-center ga-3"},z4={class:"text-body-1 font-weight-semibold"},D4={key:0,class:"text-body-2 text-medium-emphasis mb-4"},T4={class:"text-primary"},L4={key:1,class:"text-body-2 text-medium-emphasis mb-4"},E4=Ae({__name:"KiSettingsProviderCards",props:{settings:{}},emits:["create"],setup(r){const $=r;function d(s){return $.settings.find(m=>m.provider===s&&m.isDefault)}function c(s){return $.settings.some(m=>m.provider===s&&m.isActive)}return(s,m)=>{const u=l("v-icon"),f=l("v-chip"),p=l("v-btn"),_=l("v-card-text"),k=l("v-card"),i=l("v-col"),g=l("v-row");return o(),h("section",A4,[m[4]||(m[4]=a("h2",{class:"text-subtitle-1 font-weight-semibold mb-3"},"Provider-Status",-1)),e(g,null,{default:t(()=>[(o(!0),h(be,null,Pe(P(f4),x=>(o(),N(i,{key:x.key,cols:"12",md:"4"},{default:t(()=>[e(k,{class:"ki-settings-view__provider-card",variant:"outlined"},{default:t(()=>[e(_,{class:"pa-5"},{default:t(()=>{var w;return[a("div",I4,[a("div",P4,[e(u,{color:x.color,size:"28"},{default:t(()=>[n(v(x.icon),1)]),_:2},1032,["color"]),a("span",z4,v(x.label),1)]),e(f,{color:c(x.key)?"success":"error",size:"x-small",variant:"tonal"},{default:t(()=>[e(u,{start:"",size:"8"},{default:t(()=>[...m[1]||(m[1]=[n("mdi-circle",-1)])]),_:1}),n(" "+v(c(x.key)?"Konfiguriert":"Nicht konfiguriert"),1)]),_:2},1032,["color"])]),d(x.key)?(o(),h("div",D4,[m[2]||(m[2]=n(" Standard-Modell: ",-1)),a("strong",T4,v((w=d(x.key))==null?void 0:w.model),1)])):(o(),h("div",L4," Kein Standard-Modell konfiguriert ")),e(p,{variant:"outlined",size:"small",color:"primary",onClick:m[0]||(m[0]=b=>s.$emit("create"))},{default:t(()=>[...m[3]||(m[3]=[n(" Konfigurieren ",-1)])]),_:1})]}),_:2},1024)]),_:2},1024)]),_:2},1024))),128))]),_:1})])}}}),M4=Me(E4,[["__scopeId","data-v-52971b8c"]]),N4={class:"d-flex align-center justify-space-between"},U4={class:"text-body-2"},B4={class:"d-flex justify-end ga-1"},F4=Ae({__name:"KiSettingsTable",props:{items:{},loading:{type:Boolean},itemsPerPage:{},deletingId:{},settingDefaultId:{},getProviderLabel:{type:Function},getProviderColor:{type:Function}},emits:["update:itemsPerPage","refresh","edit","toggleActive","setDefault","delete"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-icon"),u=l("v-btn"),f=l("v-card-title"),p=l("v-chip"),_=l("v-switch"),k=l("v-data-table"),i=l("v-card");return o(),N(i,{variant:"outlined",class:"ki-settings-view__table-card"},{default:t(()=>[e(f,{class:"pa-4 pb-2"},{default:t(()=>[a("div",N4,[s[3]||(s[3]=a("span",{class:"text-subtitle-1 font-weight-semibold"},"Alle Konfigurationen",-1)),e(u,{icon:"",variant:"text",size:"small",loading:r.loading,"aria-label":"Aktualisieren",onClick:s[0]||(s[0]=g=>d("refresh"))},{default:t(()=>[e(m,null,{default:t(()=>[...s[2]||(s[2]=[n("mdi-refresh",-1)])]),_:1})]),_:1},8,["loading"])])]),_:1}),e(k,{headers:P(g4),items:r.items,loading:r.loading,"items-per-page":r.itemsPerPage,"loading-text":"Konfigurationen werden geladen...","no-data-text":"Keine KI-Konfigurationen vorhanden","item-value":"_id",class:"ki-settings-view__table","onUpdate:itemsPerPage":s[1]||(s[1]=g=>d("update:itemsPerPage",g))},{"item.provider":t(({item:g})=>[e(p,{color:r.getProviderColor(g.provider),size:"small",variant:"tonal"},{default:t(()=>[n(v(r.getProviderLabel(g.provider)),1)]),_:2},1032,["color"])]),"item.temperature":t(({item:g})=>[a("span",U4,v(g.temperature.toFixed(1)),1)]),"item.isActive":t(({item:g})=>[e(_,{"model-value":g.isActive,color:"primary",density:"compact","hide-details":"","onUpdate:modelValue":x=>d("toggleActive",g)},null,8,["model-value","onUpdate:modelValue"])]),"item.isDefault":t(({item:g})=>[g.isDefault?(o(),N(u,{key:0,icon:"",variant:"text",size:"small",color:"warning","aria-label":"Standard-Konfiguration"},{default:t(()=>[e(m,null,{default:t(()=>[...s[4]||(s[4]=[n("mdi-star",-1)])]),_:1})]),_:1})):(o(),N(u,{key:1,icon:"",variant:"text",size:"small",color:"default",loading:r.settingDefaultId===g._id,"aria-label":"Als Standard setzen",onClick:x=>d("setDefault",g)},{default:t(()=>[e(m,null,{default:t(()=>[...s[5]||(s[5]=[n("mdi-star-outline",-1)])]),_:1})]),_:1},8,["loading","onClick"]))]),"item.actions":t(({item:g})=>[a("div",B4,[e(u,{icon:"",variant:"text",size:"small",color:"primary","aria-label":"Bearbeiten",onClick:x=>d("edit",g)},{default:t(()=>[e(m,{size:"18"},{default:t(()=>[...s[6]||(s[6]=[n("mdi-pencil-outline",-1)])]),_:1})]),_:1},8,["onClick"]),e(u,{icon:"",variant:"text",size:"small",color:"error",loading:r.deletingId===g._id,"aria-label":"Löschen",onClick:x=>d("delete",g)},{default:t(()=>[e(m,{size:"18"},{default:t(()=>[...s[7]||(s[7]=[n("mdi-trash-can-outline",-1)])]),_:1})]),_:1},8,["loading","onClick"])])]),_:1},8,["headers","items","loading","items-per-page"])]),_:1})}}}),O4=Me(F4,[["__scopeId","data-v-109e5be4"]]),R4={class:"d-flex align-center justify-space-between"},K4={class:"text-h6"},j4={class:"text-body-2 text-medium-emphasis mb-1"},q4={class:"d-flex align-center justify-space-between mb-3"},G4={class:"text-body-2",style:{"white-space":"pre-wrap"}},H4={class:"d-flex ga-4 mt-3 text-caption text-medium-emphasis"},W4=Ae({__name:"KiSettingsCreateEditDialog",props:{modelValue:{type:Boolean},editingId:{},form:{},formValid:{type:[Boolean,null]},saving:{type:Boolean},saveError:{},testLoading:{type:Boolean},testResult:{},testError:{},availableModels:{},dialogTitle:{},nameRules:{},providerRules:{},modelRules:{}},emits:["update:modelValue","update:formValid","save","test","clearSaveError"],setup(r,{emit:$}){const d=$;function c(){d("update:modelValue",!1)}return(s,m)=>{const u=l("v-icon"),f=l("v-btn"),p=l("v-card-title"),_=l("v-divider"),k=l("v-alert"),i=l("v-text-field"),g=l("v-col"),x=l("v-select"),w=l("v-list-item-subtitle"),b=l("v-list-item"),I=l("v-textarea"),V=l("v-slider"),E=l("v-row"),R=l("v-card-text"),M=l("v-card"),T=l("v-form"),D=l("v-spacer"),H=l("v-card-actions"),O=l("v-dialog");return o(),N(O,{"model-value":r.modelValue,"max-width":"760",scrollable:"","onUpdate:modelValue":m[13]||(m[13]=S=>d("update:modelValue",S))},{default:t(()=>[e(M,{class:"ki-settings-view__dialog"},{default:t(()=>[e(p,{class:"pa-6 pb-4"},{default:t(()=>[a("div",R4,[a("span",K4,v(r.dialogTitle),1),e(f,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:c},{default:t(()=>[e(u,null,{default:t(()=>[...m[14]||(m[14]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(_),e(R,{class:"pa-6"},{default:t(()=>[r.saveError?(o(),N(k,{key:0,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":m[0]||(m[0]=S=>d("clearSaveError"))},{default:t(()=>[n(v(r.saveError),1)]),_:1})):U("",!0),e(T,{"model-value":r.formValid,onSubmit:m[10]||(m[10]=dt(S=>d("save"),["prevent"])),"onUpdate:modelValue":m[11]||(m[11]=S=>d("update:formValid",S))},{default:t(()=>[e(E,null,{default:t(()=>[e(g,{cols:"12",md:"6"},{default:t(()=>[e(i,{modelValue:r.form.name,"onUpdate:modelValue":m[1]||(m[1]=S=>r.form.name=S),label:"Name",rules:r.nameRules,placeholder:"z.B. Blog Content Generator",variant:"outlined",density:"comfortable"},null,8,["modelValue","rules"])]),_:1}),e(g,{cols:"12",md:"6"},{default:t(()=>[e(x,{modelValue:r.form.provider,"onUpdate:modelValue":m[2]||(m[2]=S=>r.form.provider=S),label:"Provider",items:P(b4),rules:r.providerRules,variant:"outlined",density:"comfortable"},null,8,["modelValue","items","rules"])]),_:1}),e(g,{cols:"12",md:"6"},{default:t(()=>[e(x,{modelValue:r.form.model,"onUpdate:modelValue":m[3]||(m[3]=S=>r.form.model=S),label:"Modell",items:r.availableModels,rules:r.modelRules,disabled:!r.form.provider,hint:r.form.provider?"":"Bitte zuerst einen Provider wählen","persistent-hint":!r.form.provider,variant:"outlined",density:"comfortable"},{item:t(({props:S,item:B})=>[e(b,Tl(Ll(S)),{default:t(()=>[B.raw.subtitle?(o(),N(w,{key:0},{default:t(()=>[n(v(B.raw.subtitle),1)]),_:2},1024)):U("",!0)]),_:2},1040)]),_:1},8,["modelValue","items","rules","disabled","hint","persistent-hint"])]),_:1}),e(g,{cols:"12",md:"6"},{default:t(()=>[e(i,{modelValue:r.form.description,"onUpdate:modelValue":m[4]||(m[4]=S=>r.form.description=S),label:"Beschreibung (optional)",placeholder:"Kurze Beschreibung der Konfiguration",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(g,{cols:"12"},{default:t(()=>[e(I,{modelValue:r.form.systemPrompt,"onUpdate:modelValue":m[5]||(m[5]=S=>r.form.systemPrompt=S),label:"System-Prompt",placeholder:"Systemanweisung für das KI-Modell...",variant:"outlined",rows:"4","auto-grow":""},null,8,["modelValue"])]),_:1}),e(g,{cols:"12",md:"8"},{default:t(()=>[a("div",j4,[m[15]||(m[15]=n(" Temperature: ",-1)),a("strong",null,v(r.form.temperature.toFixed(1)),1)]),e(V,{modelValue:r.form.temperature,"onUpdate:modelValue":m[6]||(m[6]=S=>r.form.temperature=S),min:0,max:2,step:.1,color:"primary","track-color":"rgba(255,255,255,0.1)","thumb-label":"","hide-details":""},null,8,["modelValue"]),m[16]||(m[16]=a("div",{class:"d-flex justify-space-between text-caption text-medium-emphasis mt-1"},[a("span",null,"Präzise (0)"),a("span",null,"Ausgewogen (1)"),a("span",null,"Kreativ (2)")],-1))]),_:1}),e(g,{cols:"12",md:"4"},{default:t(()=>[e(i,{modelValue:r.form.maxTokens,"onUpdate:modelValue":m[7]||(m[7]=S=>r.form.maxTokens=S),modelModifiers:{number:!0},label:"Max. Tokens",type:"number",min:100,max:128e3,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(g,{cols:"12"},{default:t(()=>[e(I,{modelValue:r.form.additionalInstructions,"onUpdate:modelValue":m[8]||(m[8]=S=>r.form.additionalInstructions=S),label:"Zusätzliche Anweisungen (optional)",placeholder:"Weitere Anweisungen, die dem System-Prompt hinzugefügt werden...",variant:"outlined",rows:"3","auto-grow":""},null,8,["modelValue"])]),_:1})]),_:1}),r.editingId?(o(),h(be,{key:0},[e(_,{class:"my-4"}),a("div",q4,[m[18]||(m[18]=a("span",{class:"text-subtitle-2 font-weight-semibold"},"Konfiguration testen",-1)),e(f,{variant:"outlined",color:"primary",size:"small",loading:r.testLoading,"prepend-icon":"mdi-play-outline",onClick:m[9]||(m[9]=S=>d("test"))},{default:t(()=>[...m[17]||(m[17]=[n(" Testen ",-1)])]),_:1},8,["loading"])]),r.testError?(o(),N(k,{key:0,type:"error",variant:"tonal",class:"mb-3"},{default:t(()=>[n(v(r.testError),1)]),_:1})):U("",!0),r.testResult?(o(),N(M,{key:1,variant:"tonal",color:"success",class:"ki-settings-view__test-result"},{default:t(()=>[e(R,{class:"pa-4"},{default:t(()=>[m[19]||(m[19]=a("div",{class:"text-body-2 font-weight-semibold mb-2"},"KI-Antwort:",-1)),a("p",G4,v(r.testResult.content),1),a("div",H4,[a("span",null,"Modell: "+v(r.testResult.model),1),a("span",null,"Tokens: "+v(r.testResult.tokensUsed),1),a("span",null,"Dauer: "+v(r.testResult.durationMs)+"ms",1)])]),_:1})]),_:1})):U("",!0)],64)):U("",!0)]),_:1},8,["model-value"])]),_:1}),e(_),e(H,{class:"pa-4"},{default:t(()=>[e(D),e(f,{variant:"text",onClick:c},{default:t(()=>[...m[20]||(m[20]=[n(" Abbrechen ",-1)])]),_:1}),e(f,{color:"primary",variant:"elevated",loading:r.saving,disabled:!r.formValid,onClick:m[12]||(m[12]=S=>d("save"))},{default:t(()=>[...m[21]||(m[21]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["model-value"])}}}),Z4=Me(W4,[["__scopeId","data-v-8ae6a342"]]),J4=Ae({__name:"KiSettingsDeleteDialog",props:{modelValue:{type:Boolean}},emits:["update:modelValue","confirm"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-card-title"),u=l("v-card-text"),f=l("v-spacer"),p=l("v-btn"),_=l("v-card-actions"),k=l("v-card"),i=l("v-dialog");return o(),N(i,{"model-value":r.modelValue,"max-width":"440","onUpdate:modelValue":s[2]||(s[2]=g=>d("update:modelValue",g))},{default:t(()=>[e(k,null,{default:t(()=>[e(m,{class:"pa-6 pb-4 text-subtitle-1"},{default:t(()=>[...s[3]||(s[3]=[n("Konfiguration löschen?",-1)])]),_:1}),e(u,{class:"pa-6 pt-0 text-body-2 text-medium-emphasis"},{default:t(()=>[...s[4]||(s[4]=[n(" Diese Aktion kann nicht rückgängig gemacht werden. Die KI-Konfiguration wird dauerhaft gelöscht. ",-1)])]),_:1}),e(_,{class:"pa-4"},{default:t(()=>[e(f),e(p,{variant:"text",onClick:s[0]||(s[0]=g=>d("update:modelValue",!1))},{default:t(()=>[...s[5]||(s[5]=[n("Abbrechen",-1)])]),_:1}),e(p,{color:"error",variant:"elevated",onClick:s[1]||(s[1]=g=>d("confirm"))},{default:t(()=>[...s[6]||(s[6]=[n("Löschen",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["model-value"])}}}),Q4={key:0,class:"d-flex justify-center pa-6"},Y4={class:"d-flex justify-end mt-4"},X4=Ae({__name:"KiSettingsPageConfigPanel",props:{pageConfigLoading:{type:Boolean},pageConfigError:{},pageConfigSuccess:{type:Boolean},pageConfigSaving:{type:Boolean},pageConfigForm:{},knowledgeBases:{},kbLoading:{type:Boolean},settings:{}},emits:["clearError","clearSuccess","save"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-progress-circular"),u=l("v-alert"),f=l("v-autocomplete"),p=l("v-col"),_=l("v-row"),k=l("v-select"),i=l("v-textarea"),g=l("v-btn");return r.pageConfigLoading?(o(),h("div",Q4,[e(m,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:1},[r.pageConfigError?(o(),N(u,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":s[0]||(s[0]=x=>d("clearError"))},{default:t(()=>[n(v(r.pageConfigError),1)]),_:1})):U("",!0),r.pageConfigSuccess?(o(),N(u,{key:1,type:"success",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":s[1]||(s[1]=x=>d("clearSuccess"))},{default:t(()=>[...s[6]||(s[6]=[n(" Seiten-Konfiguration gespeichert. ",-1)])]),_:1})):U("",!0),s[8]||(s[8]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Konfiguration für den KI-Chat im Seiten-Editor. Der System-Prompt steuert wie die KI Seiten erstellt und bearbeitet. ",-1)),s[9]||(s[9]=a("p",{class:"text-subtitle-2 font-weight-semibold mb-3"},"Knowledge Base Auswahl",-1)),e(_,null,{default:t(()=>[e(p,{cols:"12"},{default:t(()=>[e(f,{modelValue:r.pageConfigForm.selectedKnowledgeBaseIds,"onUpdate:modelValue":s[2]||(s[2]=x=>r.pageConfigForm.selectedKnowledgeBaseIds=x),items:r.knowledgeBases,"item-title":"title","item-value":"_id",label:"Aktive Knowledge Bases für Seiten-Generierung",variant:"outlined",multiple:"",chips:"","closable-chips":"",loading:r.kbLoading,hint:"Diese KB-Einträge werden als Kontext für den Seiten-KI-Chat verwendet","persistent-hint":""},null,8,["modelValue","items","loading"])]),_:1})]),_:1}),s[10]||(s[10]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"GPT-Einstellungen",-1)),e(_,null,{default:t(()=>[e(p,{cols:"12",md:"6"},{default:t(()=>[e(k,{modelValue:r.pageConfigForm.gptSettingsId,"onUpdate:modelValue":s[3]||(s[3]=x=>r.pageConfigForm.gptSettingsId=x),items:[{title:"Standard (System-Default)",value:""},...r.settings.map(x=>({title:x.name,value:x._id}))],label:"GPT-Konfiguration",variant:"outlined",density:"comfortable",hint:"Provider, Model und Temperature für den Seiten-Chat","persistent-hint":""},null,8,["modelValue","items"])]),_:1})]),_:1}),s[11]||(s[11]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"System-Prompt",-1)),e(_,null,{default:t(()=>[e(p,{cols:"12"},{default:t(()=>[e(i,{modelValue:r.pageConfigForm.systemPrompt,"onUpdate:modelValue":s[4]||(s[4]=x=>r.pageConfigForm.systemPrompt=x),label:"System-Prompt für Seiten-KI-Chat",variant:"outlined",rows:"20","no-resize":"",class:"prompt-textarea",hint:"Steuert wie die KI Seiten erstellt, bearbeitet und welche Marker sie verwendet","persistent-hint":""},null,8,["modelValue"])]),_:1})]),_:1}),a("div",Y4,[e(g,{color:"primary",variant:"elevated",loading:r.pageConfigSaving,"prepend-icon":"mdi-content-save-outline",onClick:s[5]||(s[5]=x=>d("save"))},{default:t(()=>[...s[7]||(s[7]=[n(" Speichern ",-1)])]),_:1},8,["loading"])])],64))}}}),eC=Me(X4,[["__scopeId","data-v-50f28307"]]),tC={key:0,class:"d-flex justify-center pa-6"},aC={class:"d-flex justify-end mt-4"},lC=Ae({__name:"KiSettingsEmailConfigPanel",props:{emailConfigLoading:{type:Boolean},emailConfigError:{},emailConfigSuccess:{type:Boolean},emailConfigSaving:{type:Boolean},emailConfigForm:{},knowledgeBases:{},kbLoading:{type:Boolean},settings:{}},emits:["clearError","clearSuccess","save"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-progress-circular"),u=l("v-alert"),f=l("v-autocomplete"),p=l("v-col"),_=l("v-row"),k=l("v-select"),i=l("v-textarea"),g=l("v-btn");return r.emailConfigLoading?(o(),h("div",tC,[e(m,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:1},[r.emailConfigError?(o(),N(u,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":s[0]||(s[0]=x=>d("clearError"))},{default:t(()=>[n(v(r.emailConfigError),1)]),_:1})):U("",!0),r.emailConfigSuccess?(o(),N(u,{key:1,type:"success",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":s[1]||(s[1]=x=>d("clearSuccess"))},{default:t(()=>[...s[7]||(s[7]=[n(" E-Mail-Konfiguration gespeichert. ",-1)])]),_:1})):U("",!0),s[9]||(s[9]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Konfiguration für den KI-Chat in E-Mail-Kampagnen. Der System-Prompt steuert wie die KI E-Mails erstellt und bearbeitet. ",-1)),s[10]||(s[10]=a("p",{class:"text-subtitle-2 font-weight-semibold mb-3"},"Knowledge Base Auswahl",-1)),e(_,null,{default:t(()=>[e(p,{cols:"12"},{default:t(()=>[e(f,{modelValue:r.emailConfigForm.selectedKnowledgeBaseIds,"onUpdate:modelValue":s[2]||(s[2]=x=>r.emailConfigForm.selectedKnowledgeBaseIds=x),items:r.knowledgeBases,"item-title":"title","item-value":"_id",label:"Aktive Knowledge Bases für E-Mail-Generierung",variant:"outlined",multiple:"",chips:"","closable-chips":"",loading:r.kbLoading,hint:"Diese KB-Einträge werden als Kontext für den E-Mail-KI-Chat verwendet","persistent-hint":""},null,8,["modelValue","items","loading"])]),_:1})]),_:1}),s[11]||(s[11]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"GPT-Einstellungen",-1)),e(_,null,{default:t(()=>[e(p,{cols:"12",md:"6"},{default:t(()=>[e(k,{modelValue:r.emailConfigForm.gptSettingsId,"onUpdate:modelValue":s[3]||(s[3]=x=>r.emailConfigForm.gptSettingsId=x),items:[{title:"Standard (System-Default)",value:""},...r.settings.map(x=>({title:x.name,value:x._id}))],label:"GPT-Konfiguration",variant:"outlined",density:"comfortable",hint:"Provider, Model und Temperature für den E-Mail-Chat","persistent-hint":""},null,8,["modelValue","items"])]),_:1})]),_:1}),s[12]||(s[12]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"System-Prompt (Chat)",-1)),e(_,null,{default:t(()=>[e(p,{cols:"12"},{default:t(()=>[e(i,{modelValue:r.emailConfigForm.systemPrompt,"onUpdate:modelValue":s[4]||(s[4]=x=>r.emailConfigForm.systemPrompt=x),label:"System-Prompt für E-Mail-KI-Chat",variant:"outlined",rows:"20","no-resize":"",class:"prompt-textarea",hint:"Steuert wie die KI im Chat E-Mail-Ideen erstellt und welche Marker sie verwendet","persistent-hint":""},null,8,["modelValue"])]),_:1})]),_:1}),s[13]||(s[13]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"Email-Draft-Prompt (Vorschau)",-1)),e(_,null,{default:t(()=>[e(p,{cols:"12"},{default:t(()=>[e(i,{modelValue:r.emailConfigForm.promptEmailDraft,"onUpdate:modelValue":s[5]||(s[5]=x=>r.emailConfigForm.promptEmailDraft=x),label:"Prompt für die E-Mail-Vorschau-Generierung",variant:"outlined",rows:"20","no-resize":"",class:"prompt-textarea",hint:"Steuert wie die KI aus einer Idee eine vollständige E-Mail mit Sections (Header, Text, CTA, Stats, Quote, List) generiert","persistent-hint":""},null,8,["modelValue"])]),_:1})]),_:1}),a("div",aC,[e(g,{color:"primary",variant:"elevated",loading:r.emailConfigSaving,"prepend-icon":"mdi-content-save-outline",onClick:s[6]||(s[6]=x=>d("save"))},{default:t(()=>[...s[8]||(s[8]=[n(" Speichern ",-1)])]),_:1},8,["loading"])])],64))}}}),nC=Me(lC,[["__scopeId","data-v-e941275b"]]),oC={key:0,class:"d-flex justify-center pa-6"},sC={class:"d-flex align-center justify-space-between mb-6 pa-4 ki-settings-view__linkedin-oauth"},iC={key:0,class:"text-caption text-success mb-0"},rC={key:1,class:"text-caption text-medium-emphasis mb-0"},dC={class:"d-flex ga-2"},uC={class:"d-flex align-center justify-space-between mb-6 pa-4 ki-settings-view__linkedin-dryrun"},cC={class:"flex-grow-1"},mC={class:"text-body-2 font-weight-semibold mb-1"},vC={class:"d-flex justify-end mt-4"},pC=Ae({__name:"KiSettingsLinkedinConfigPanel",props:{linkedinConfig:{},linkedinLoading:{type:Boolean},linkedinError:{},linkedinSuccess:{type:Boolean},linkedinSaving:{type:Boolean},oauthLoading:{type:Boolean},linkedinDisconnecting:{type:Boolean},linkedinForm:{},knowledgeBases:{},kbLoading:{type:Boolean}},emits:["clearError","clearSuccess","save","openOAuth","disconnect"],setup(r,{emit:$}){const d=$,c=y(!1);function s(){d("disconnect"),c.value=!1}return(m,u)=>{var O,S,B,G,W,F,L,A;const f=l("v-progress-circular"),p=l("v-alert"),_=l("v-icon"),k=l("v-btn"),i=l("v-card-title"),g=l("v-card-text"),x=l("v-spacer"),w=l("v-card-actions"),b=l("v-card"),I=l("v-dialog"),V=l("v-switch"),E=l("v-text-field"),R=l("v-col"),M=l("v-combobox"),T=l("v-row"),D=l("v-autocomplete"),H=l("v-textarea");return r.linkedinLoading?(o(),h("div",oC,[e(f,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:1},[r.linkedinError?(o(),N(p,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":u[0]||(u[0]=z=>d("clearError"))},{default:t(()=>[n(v(r.linkedinError),1)]),_:1})):U("",!0),r.linkedinSuccess?(o(),N(p,{key:1,type:"success",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":u[1]||(u[1]=z=>d("clearSuccess"))},{default:t(()=>[...u[20]||(u[20]=[n(" LinkedIn-Konfiguration gespeichert. ",-1)])]),_:1})):U("",!0),a("div",sC,[a("div",null,[u[22]||(u[22]=a("p",{class:"text-body-2 font-weight-semibold mb-1"},"LinkedIn-Verbindung",-1)),(S=(O=r.linkedinConfig)==null?void 0:O.linkedin)!=null&&S.isConnected?(o(),h("p",iC,[e(_,{size:"14",class:"mr-1"},{default:t(()=>[...u[21]||(u[21]=[n("mdi-check-circle",-1)])]),_:1}),n(" Verbunden"+v((G=(B=r.linkedinConfig)==null?void 0:B.linkedin)!=null&&G.userName?` (${r.linkedinConfig.linkedin.userName})`:""),1)])):(o(),h("p",rC," Noch nicht mit LinkedIn verbunden. "))]),a("div",dC,[(F=(W=r.linkedinConfig)==null?void 0:W.linkedin)!=null&&F.isConnected?(o(),N(k,{key:0,color:"error",variant:"outlined","prepend-icon":"mdi-link-variant-off",loading:r.linkedinDisconnecting,onClick:u[2]||(u[2]=z=>c.value=!0)},{default:t(()=>[...u[23]||(u[23]=[n(" Trennen ",-1)])]),_:1},8,["loading"])):U("",!0),e(k,{color:(A=(L=r.linkedinConfig)==null?void 0:L.linkedin)!=null&&A.isConnected?"default":"primary",variant:"outlined","prepend-icon":"mdi-linkedin",loading:r.oauthLoading,onClick:u[3]||(u[3]=z=>d("openOAuth"))},{default:t(()=>{var z,j;return[n(v((j=(z=r.linkedinConfig)==null?void 0:z.linkedin)!=null&&j.isConnected?"Neu verbinden":"Mit LinkedIn verbinden"),1)]}),_:1},8,["color","loading"])])]),e(I,{modelValue:c.value,"onUpdate:modelValue":u[5]||(u[5]=z=>c.value=z),"max-width":"500",persistent:""},{default:t(()=>[e(b,null,{default:t(()=>[e(i,{class:"d-flex align-center ga-2"},{default:t(()=>[e(_,{color:"error"},{default:t(()=>[...u[24]||(u[24]=[n("mdi-link-variant-off",-1)])]),_:1}),u[25]||(u[25]=n(" LinkedIn-Verbindung trennen? ",-1))]),_:1}),e(g,null,{default:t(()=>[...u[26]||(u[26]=[a("p",{class:"mb-2"},[n(" Die OAuth-Tokens werden gelöscht. Geplante Posts können danach "),a("strong",null,"nicht mehr veröffentlicht"),n(" werden, bis du dich neu verbindest. ")],-1),a("p",{class:"text-caption text-medium-emphasis"}," Bereits veröffentlichte Posts bleiben auf LinkedIn unverändert. ",-1)])]),_:1}),e(w,null,{default:t(()=>[e(x),e(k,{variant:"text",disabled:r.linkedinDisconnecting,onClick:u[4]||(u[4]=z=>c.value=!1)},{default:t(()=>[...u[27]||(u[27]=[n(" Abbrechen ",-1)])]),_:1},8,["disabled"]),e(k,{color:"error",variant:"elevated",loading:r.linkedinDisconnecting,onClick:s},{default:t(()=>[...u[28]||(u[28]=[n(" Verbindung trennen ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),a("div",uC,[a("div",cC,[a("p",mC,[e(_,{size:"18",class:"mr-1"},{default:t(()=>[...u[29]||(u[29]=[n("mdi-flask-outline",-1)])]),_:1}),u[30]||(u[30]=n(" Dry-Run-Modus (Test ohne Live-Posting) ",-1))]),u[31]||(u[31]=a("p",{class:"text-caption text-medium-emphasis"},[n(" Wenn aktiv, werden Posts NICHT auf LinkedIn veröffentlicht. Backend liefert eine Mock-Post-ID zurück. "),a("strong",{class:"text-warning"},"In Production deaktiviert lassen.")],-1))]),e(V,{modelValue:r.linkedinForm.dryRun,"onUpdate:modelValue":u[6]||(u[6]=z=>r.linkedinForm.dryRun=z),color:"warning",density:"compact","hide-details":"",inset:""},null,8,["modelValue"])]),e(T,null,{default:t(()=>[e(R,{cols:"12",md:"6"},{default:t(()=>[e(E,{modelValue:r.linkedinForm.industry,"onUpdate:modelValue":u[7]||(u[7]=z=>r.linkedinForm.industry=z),label:"Branche",placeholder:"z.B. IT-Security",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(R,{cols:"12",md:"6"},{default:t(()=>[e(E,{modelValue:r.linkedinForm.targetAudience,"onUpdate:modelValue":u[8]||(u[8]=z=>r.linkedinForm.targetAudience=z),label:"Zielgruppe",placeholder:"z.B. CISOs, IT-Leiter",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(R,{cols:"12",md:"8"},{default:t(()=>[e(E,{modelValue:r.linkedinForm.brandVoice,"onUpdate:modelValue":u[9]||(u[9]=z=>r.linkedinForm.brandVoice=z),label:"Brand Voice",placeholder:"z.B. Professionell, kompetent, vertrauenswürdig",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(R,{cols:"12",md:"4"},{default:t(()=>[e(E,{modelValue:r.linkedinForm.defaultPostTime,"onUpdate:modelValue":u[10]||(u[10]=z=>r.linkedinForm.defaultPostTime=z),label:"Standard-Postzeit",type:"time",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(R,{cols:"12"},{default:t(()=>[e(M,{modelValue:r.linkedinForm.coreTopics,"onUpdate:modelValue":u[11]||(u[11]=z=>r.linkedinForm.coreTopics=z),label:"Kernthemen",placeholder:"Thema eingeben und Enter drücken",variant:"outlined",density:"comfortable",multiple:"",chips:"","closable-chips":"","hide-no-data":""},null,8,["modelValue"])]),_:1})]),_:1}),u[33]||(u[33]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"Knowledge Base Auswahl",-1)),e(T,null,{default:t(()=>[e(R,{cols:"12"},{default:t(()=>[e(D,{modelValue:r.linkedinForm.selectedKnowledgeBaseIds,"onUpdate:modelValue":u[12]||(u[12]=z=>r.linkedinForm.selectedKnowledgeBaseIds=z),items:r.knowledgeBases,"item-title":"title","item-value":"_id",label:"Aktive Knowledge Bases für Content-Generierung",variant:"outlined",multiple:"",chips:"","closable-chips":"",loading:r.kbLoading,hint:"Diese KB-Einträge werden als Kontext für alle KI-Aufrufe verwendet","persistent-hint":""},null,8,["modelValue","items","loading"])]),_:1})]),_:1}),u[34]||(u[34]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"Prompts",-1)),e(T,null,{default:t(()=>[e(R,{cols:"12",md:"6"},{default:t(()=>[e(H,{modelValue:r.linkedinForm.promptContentPlan,"onUpdate:modelValue":u[13]||(u[13]=z=>r.linkedinForm.promptContentPlan=z),label:"Content Plan Prompt",variant:"outlined",rows:"20","no-resize":"",class:"prompt-textarea"},null,8,["modelValue"])]),_:1}),e(R,{cols:"12",md:"6"},{default:t(()=>[e(H,{modelValue:r.linkedinForm.promptPostDraft,"onUpdate:modelValue":u[14]||(u[14]=z=>r.linkedinForm.promptPostDraft=z),label:"Post-Entwurf Prompt",variant:"outlined",rows:"20","no-resize":"",class:"prompt-textarea"},null,8,["modelValue"])]),_:1}),e(R,{cols:"12",md:"6"},{default:t(()=>[e(H,{modelValue:r.linkedinForm.promptHashtags,"onUpdate:modelValue":u[15]||(u[15]=z=>r.linkedinForm.promptHashtags=z),label:"Hashtag Prompt",variant:"outlined",rows:"20","no-resize":"",class:"prompt-textarea"},null,8,["modelValue"])]),_:1}),e(R,{cols:"12",md:"6"},{default:t(()=>[e(H,{modelValue:r.linkedinForm.promptLandingPage,"onUpdate:modelValue":u[16]||(u[16]=z=>r.linkedinForm.promptLandingPage=z),label:"Landing Page Prompt",variant:"outlined",rows:"20","no-resize":"",class:"prompt-textarea"},null,8,["modelValue"])]),_:1}),e(R,{cols:"12",md:"6"},{default:t(()=>[e(H,{modelValue:r.linkedinForm.promptImageTags,"onUpdate:modelValue":u[17]||(u[17]=z=>r.linkedinForm.promptImageTags=z),label:"Bild-Tag-Extraktion Prompt",variant:"outlined",rows:"20","no-resize":"",class:"prompt-textarea","persistent-hint":"",hint:"System-Prompt für die KI, die aus einem Post-Text 5-10 ideale Bild-Tags ableitet (Pool-Matching)."},null,8,["modelValue"])]),_:1}),e(R,{cols:"12",md:"6"},{default:t(()=>[e(H,{modelValue:r.linkedinForm.promptImageGeneration,"onUpdate:modelValue":u[18]||(u[18]=z=>r.linkedinForm.promptImageGeneration=z),label:"Bild-Generierung-Prompt",variant:"outlined",rows:"20","no-resize":"",class:"prompt-textarea","persistent-hint":"",hint:"System-Prompt für die KI, die einen Ideogram-Prompt vorschlägt, wenn kein Pool-Bild passt."},null,8,["modelValue"])]),_:1})]),_:1}),a("div",vC,[e(k,{color:"primary",variant:"elevated",loading:r.linkedinSaving,"prepend-icon":"mdi-content-save-outline",onClick:u[19]||(u[19]=z=>d("save"))},{default:t(()=>[...u[32]||(u[32]=[n(" Speichern ",-1)])]),_:1},8,["loading"])])],64))}}}),fC=Me(pC,[["__scopeId","data-v-358f1e4b"]]),gC={key:0,class:"d-flex justify-center pa-6"},bC={class:"d-flex justify-end mt-4"},yC=Ae({__name:"KiSettingsLeadResearchPanel",props:{loading:{type:Boolean},error:{},success:{type:Boolean},saving:{type:Boolean},promptForm:{},hasPrompt:{type:Boolean},senderLoading:{type:Boolean},senderError:{},senderSuccess:{type:Boolean},senderSaving:{type:Boolean},defaultSender:{},settings:{}},emits:["clearError","clearSuccess","save","clearSenderError","clearSenderSuccess","saveSender","updateDefaultSender","update:promptForm"],setup(r,{emit:$}){const d=r,c=$;function s(m,u){c("update:promptForm",{...d.promptForm,[m]:u})}return(m,u)=>{const f=l("v-progress-circular"),p=l("v-alert"),_=l("v-divider"),k=l("v-select"),i=l("v-col"),g=l("v-row"),x=l("v-textarea"),w=l("v-btn");return r.loading?(o(),h("div",gC,[e(f,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:1},[u[15]||(u[15]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Konfiguration für die KI-gestützte Lead-Recherche. Der System-Prompt und das User-Prompt-Template steuern, wie die KI Firmen- und Kontaktdaten aus Freitext-Eingaben extrahiert. ",-1)),r.error?(o(),N(p,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":u[0]||(u[0]=b=>c("clearError"))},{default:t(()=>[n(v(r.error),1)]),_:1})):U("",!0),r.success?(o(),N(p,{key:1,type:"success",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":u[1]||(u[1]=b=>c("clearSuccess"))},{default:t(()=>[...u[10]||(u[10]=[n(" Lead-Research-Konfiguration gespeichert. ",-1)])]),_:1})):U("",!0),!r.hasPrompt&&!r.error?(o(),N(p,{key:2,type:"warning",variant:"tonal",density:"compact",class:"mb-4"},{default:t(()=>[...u[11]||(u[11]=[n(" Kein aktiver Lead-Research-Prompt gefunden. Bitte unter ",-1),a("strong",null,"/admin/prompts",-1),n(" einen Prompt mit der Kategorie ",-1),a("strong",null,"lead-research",-1),n(" anlegen und als Standard markieren. ",-1)])]),_:1})):U("",!0),u[16]||(u[16]=a("p",{class:"text-subtitle-1 font-weight-semibold mb-1"},"Prompt-Konfiguration",-1)),e(_,{class:"mb-4"}),u[17]||(u[17]=a("p",{class:"text-subtitle-2 font-weight-semibold mb-3"},"GPT-Einstellungen",-1)),e(g,null,{default:t(()=>[e(i,{cols:"12",md:"6"},{default:t(()=>[e(k,{"model-value":r.promptForm.gptSettingsId,items:[{title:"Standard (System-Default)",value:""},...r.settings.map(b=>({title:b.name,value:b._id}))],label:"GPT-Konfiguration",variant:"outlined",density:"comfortable",hint:"Provider, Model und Temperature für die Lead-Extraktion","persistent-hint":"","onUpdate:modelValue":u[2]||(u[2]=b=>s("gptSettingsId",b??""))},null,8,["model-value","items"])]),_:1})]),_:1}),u[18]||(u[18]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"System-Prompt",-1)),e(g,null,{default:t(()=>[e(i,{cols:"12"},{default:t(()=>[e(x,{"model-value":r.promptForm.systemPrompt,label:"System-Prompt für Lead-Research",variant:"outlined",rows:"10","no-resize":"",class:"prompt-textarea",hint:"Definiert die Rolle der KI und das gewünschte Ausgabeformat (JSON)","persistent-hint":"","onUpdate:modelValue":u[3]||(u[3]=b=>s("systemPrompt",b??""))},null,8,["model-value"])]),_:1})]),_:1}),u[19]||(u[19]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"User-Prompt-Template",-1)),e(g,null,{default:t(()=>[e(i,{cols:"12"},{default:t(()=>[e(x,{"model-value":r.promptForm.userPromptTemplate,label:"User-Prompt-Template (Variable: {{rawText}} wird durch den Eingabetext ersetzt)",variant:"outlined",rows:"10","no-resize":"",class:"prompt-textarea",hint:"Template für den User-Teil. Variablen werden beim Aufruf ersetzt.","persistent-hint":"","onUpdate:modelValue":u[4]||(u[4]=b=>s("userPromptTemplate",b??""))},null,8,["model-value"])]),_:1})]),_:1}),a("div",bC,[e(w,{color:"primary",variant:"elevated",loading:r.saving,disabled:!r.hasPrompt,"prepend-icon":"mdi-content-save-outline",onClick:u[5]||(u[5]=b=>c("save"))},{default:t(()=>[...u[12]||(u[12]=[n(" Prompt speichern ",-1)])]),_:1},8,["loading","disabled"])]),u[20]||(u[20]=a("p",{class:"text-subtitle-1 font-weight-semibold mt-6 mb-1"},"Mailjet-Versender",-1)),e(_,{class:"mb-4"}),u[21]||(u[21]=a("p",{class:"text-subtitle-2 font-weight-semibold mb-1"},"Standard-Versender für Outreach-Leads",-1)),u[22]||(u[22]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Diese E-Mail-Adresse wird im Lead-Research-Tool als vorausgewählter Absender für Outreach-Mails verwendet. Die Adresse muss in Mailjet als aktiver Sender verifiziert sein. ",-1)),r.senderError?(o(),N(p,{key:3,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":u[6]||(u[6]=b=>c("clearSenderError"))},{default:t(()=>[n(v(r.senderError),1)]),_:1})):U("",!0),r.senderSuccess?(o(),N(p,{key:4,type:"success",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":u[7]||(u[7]=b=>c("clearSenderSuccess"))},{default:t(()=>[...u[13]||(u[13]=[n(" Standard-Versender gespeichert. ",-1)])]),_:1})):U("",!0),e(g,{align:"center"},{default:t(()=>[e(i,{cols:"12",md:"6"},{default:t(()=>[e(Ua,{"model-value":r.defaultSender,label:"Standard Mailjet-Versender","onUpdate:modelValue":u[8]||(u[8]=b=>c("updateDefaultSender",b))},null,8,["model-value"])]),_:1}),e(i,{cols:"12",md:"6",class:"d-flex align-start"},{default:t(()=>[e(w,{color:"primary",variant:"elevated",loading:r.senderSaving,"prepend-icon":"mdi-email-check-outline",onClick:u[9]||(u[9]=b=>c("saveSender"))},{default:t(()=>[...u[14]||(u[14]=[n(" Versender speichern ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})],64))}}}),_C=Me(yC,[["__scopeId","data-v-7bd1e9c8"]]),kC={key:0,class:"d-flex justify-center pa-6"},hC={class:"d-flex justify-end mt-4"},xC={class:"d-flex justify-end mt-2"},wC=Ae({__name:"KiSettingsCompanyScoringPanel",props:{loading:{type:Boolean},error:{},promptSuccess:{type:Boolean},promptSaving:{type:Boolean},promptForm:{},hasPrompt:{type:Boolean},settings:{},scoringWeights:{},weightsSum:{},weightsDirty:{type:Boolean},weightsSaving:{type:Boolean},weightsError:{},weightsSuccess:{type:Boolean},autoOnCreate:{type:Boolean},autoOnCreateDirty:{type:Boolean},autoOnCreateSaving:{type:Boolean},autoOnCreateError:{},autoOnCreateSuccess:{type:Boolean}},emits:["clearError","clearPromptSuccess","savePrompt","clearWeightsError","clearWeightsSuccess","saveWeights","clearAutoOnCreateError","clearAutoOnCreateSuccess","saveAutoOnCreate","update:promptForm","update:scoringWeights","update:autoOnCreate"],setup(r,{emit:$}){const d=r,c=$;function s(f,p){c("update:promptForm",{...d.promptForm,[f]:p})}function m(f,p){const _=typeof p=="number"?p:parseInt(String(p),10),k=isNaN(_)?0:Math.max(0,Math.min(100,_));c("update:scoringWeights",{...d.scoringWeights,[f]:k})}const u=Object.keys(la).map(f=>({key:f,label:la[f]}));return(f,p)=>{const _=l("v-progress-circular"),k=l("v-alert"),i=l("v-divider"),g=l("v-select"),x=l("v-col"),w=l("v-row"),b=l("v-textarea"),I=l("v-btn"),V=l("v-text-field"),E=l("v-icon"),R=l("v-chip"),M=l("v-switch");return r.loading?(o(),h("div",kC,[e(_,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:1},[p[21]||(p[21]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Konfiguration für die KI-gestützte Multi-Faktor-Bewertung von Unternehmen. Der System-Prompt und das User-Prompt-Template steuern, wie die KI die 5 Scoring-Faktoren bewertet. Die Gewichtungen bestimmen den gewichteten Gesamt-Score. ",-1)),r.error?(o(),N(k,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":p[0]||(p[0]=T=>c("clearError"))},{default:t(()=>[n(v(r.error),1)]),_:1})):U("",!0),!r.hasPrompt&&!r.error?(o(),N(k,{key:1,type:"warning",variant:"tonal",density:"compact",class:"mb-4"},{default:t(()=>[...p[13]||(p[13]=[n(" Kein aktiver Company-Scoring-Prompt gefunden. Bitte unter ",-1),a("strong",null,"/admin/prompts",-1),n(" einen Prompt mit der Kategorie ",-1),a("strong",null,"company-scoring",-1),n(" anlegen und als Standard markieren. ",-1)])]),_:1})):U("",!0),p[22]||(p[22]=a("p",{class:"text-subtitle-1 font-weight-semibold mb-1"},"Prompt-Konfiguration",-1)),e(i,{class:"mb-4"}),r.promptSuccess?(o(),N(k,{key:2,type:"success",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":p[1]||(p[1]=T=>c("clearPromptSuccess"))},{default:t(()=>[...p[14]||(p[14]=[n(" Prompt gespeichert. ",-1)])]),_:1})):U("",!0),p[23]||(p[23]=a("p",{class:"text-subtitle-2 font-weight-semibold mb-3"},"GPT-Einstellungen",-1)),e(w,null,{default:t(()=>[e(x,{cols:"12",md:"6"},{default:t(()=>[e(g,{"model-value":r.promptForm.gptSettingsId,items:[{title:"Standard (System-Default)",value:""},...r.settings.map(T=>({title:T.name,value:T._id}))],label:"GPT-Konfiguration",variant:"outlined",density:"comfortable",hint:"Provider, Model und Temperature für das Company-Scoring","persistent-hint":"","onUpdate:modelValue":p[2]||(p[2]=T=>s("gptSettingsId",T??""))},null,8,["model-value","items"])]),_:1})]),_:1}),p[24]||(p[24]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"System-Prompt",-1)),e(w,null,{default:t(()=>[e(x,{cols:"12"},{default:t(()=>[e(b,{"model-value":r.promptForm.systemPrompt,label:"System-Prompt für Company-Scoring",variant:"outlined",rows:"10","no-resize":"",class:"prompt-textarea",hint:"Definiert die Rolle der KI und das gewünschte Ausgabeformat (JSON mit 5 Faktoren)","persistent-hint":"","onUpdate:modelValue":p[3]||(p[3]=T=>s("systemPrompt",T??""))},null,8,["model-value"])]),_:1})]),_:1}),p[25]||(p[25]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"User-Prompt-Template",-1)),e(w,null,{default:t(()=>[e(x,{cols:"12"},{default:t(()=>[e(b,{"model-value":r.promptForm.userPromptTemplate,label:"User-Prompt-Template",variant:"outlined",rows:"10","no-resize":"",class:"prompt-textarea",hint:"Variablen: {{stammdaten}} und {{engagement}} werden im Prompt ersetzt","persistent-hint":"","onUpdate:modelValue":p[4]||(p[4]=T=>s("userPromptTemplate",T??""))},null,8,["model-value"])]),_:1})]),_:1}),a("div",hC,[e(I,{color:"primary",variant:"elevated",loading:r.promptSaving,disabled:!r.hasPrompt,"prepend-icon":"mdi-content-save-outline",onClick:p[5]||(p[5]=T=>c("savePrompt"))},{default:t(()=>[...p[15]||(p[15]=[n(" Prompt speichern ",-1)])]),_:1},8,["loading","disabled"])]),e(i,{class:"my-6"}),p[26]||(p[26]=a("p",{class:"text-subtitle-1 font-weight-semibold mb-1"},"Faktor-Gewichtungen",-1)),e(i,{class:"mb-4"}),p[27]||(p[27]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Die Gewichtungen bestimmen den Anteil jedes Faktors am Gesamt-Score. Die Summe aller Gewichtungen muss genau 100 ergeben. ",-1)),r.weightsError?(o(),N(k,{key:3,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":p[6]||(p[6]=T=>c("clearWeightsError"))},{default:t(()=>[n(v(r.weightsError),1)]),_:1})):U("",!0),r.weightsSuccess?(o(),N(k,{key:4,type:"success",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":p[7]||(p[7]=T=>c("clearWeightsSuccess"))},{default:t(()=>[...p[16]||(p[16]=[n(" Gewichtungen gespeichert. ",-1)])]),_:1})):U("",!0),e(w,{align:"center"},{default:t(()=>[(o(!0),h(be,null,Pe(P(u),T=>(o(),N(x,{key:T.key,cols:"12",sm:"6",md:"4"},{default:t(()=>[e(V,{"model-value":r.scoringWeights[T.key],label:T.label,type:"number",variant:"outlined",density:"comfortable",min:"0",max:"100",suffix:"%","onUpdate:modelValue":D=>m(T.key,D)},null,8,["model-value","label","onUpdate:modelValue"])]),_:2},1024))),128)),e(x,{cols:"12",sm:"6",md:"4",class:"d-flex align-center"},{default:t(()=>[e(R,{color:r.weightsSum===100?"success":"error",variant:"tonal",size:"large",class:"font-weight-semibold"},{default:t(()=>[e(E,{start:"",size:"16"},{default:t(()=>[n(v(r.weightsSum===100?"mdi-check-circle-outline":"mdi-alert-circle-outline"),1)]),_:1}),n(" "+v(r.weightsSum===100?"Summe: 100":`Summe: ${r.weightsSum} (muss 100 sein)`),1)]),_:1},8,["color"])]),_:1})]),_:1}),a("div",xC,[e(I,{color:"primary",variant:"elevated",loading:r.weightsSaving,disabled:r.weightsSum!==100,"prepend-icon":"mdi-weight-kilogram",onClick:p[8]||(p[8]=T=>c("saveWeights"))},{default:t(()=>[...p[17]||(p[17]=[n(" Gewichtungen speichern ",-1)])]),_:1},8,["loading","disabled"])]),e(i,{class:"my-6"}),p[28]||(p[28]=a("p",{class:"text-subtitle-1 font-weight-semibold mb-1"},"Automatisches Scoring",-1)),e(i,{class:"mb-4"}),r.autoOnCreateError?(o(),N(k,{key:5,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":p[9]||(p[9]=T=>c("clearAutoOnCreateError"))},{default:t(()=>[n(v(r.autoOnCreateError),1)]),_:1})):U("",!0),r.autoOnCreateSuccess?(o(),N(k,{key:6,type:"success",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":p[10]||(p[10]=T=>c("clearAutoOnCreateSuccess"))},{default:t(()=>[...p[18]||(p[18]=[n(" Auto-Scoring-Einstellung gespeichert. ",-1)])]),_:1})):U("",!0),e(w,{align:"center"},{default:t(()=>[e(x,{cols:"12",md:"8"},{default:t(()=>[e(M,{"model-value":r.autoOnCreate,label:"Beim Anlegen via Research-Tool automatisch scoren",color:"primary","hide-details":"","onUpdate:modelValue":p[11]||(p[11]=T=>c("update:autoOnCreate",!!T))},null,8,["model-value"]),p[19]||(p[19]=a("p",{class:"text-body-2 text-medium-emphasis mt-1 ml-14"}," Wenn aktiv, wird nach dem Anlegen einer neuen Company über das Lead-Research-Tool automatisch ein Scoring-Job gestartet. ",-1))]),_:1}),e(x,{cols:"12",md:"4",class:"d-flex justify-end"},{default:t(()=>[e(I,{color:"primary",variant:"elevated",loading:r.autoOnCreateSaving,"prepend-icon":"mdi-cog-outline",onClick:p[12]||(p[12]=T=>c("saveAutoOnCreate"))},{default:t(()=>[...p[20]||(p[20]=[n(" Einstellung speichern ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})],64))}}}),SC=Me(wC,[["__scopeId","data-v-8b7216a5"]]),$C={key:0,class:"d-flex justify-center pa-6"},CC={class:"d-flex justify-end mt-4"},VC=Ae({__name:"KiSettingsOutreachPanel",props:{loading:{type:Boolean},error:{},promptSuccess:{type:Boolean},promptSaving:{type:Boolean},promptForm:{},hasPrompt:{type:Boolean},settings:{}},emits:["clearError","clearPromptSuccess","savePrompt","update:promptForm"],setup(r,{emit:$}){const d=r,c=$;function s(m,u){c("update:promptForm",{...d.promptForm,[m]:u})}return(m,u)=>{const f=l("v-progress-circular"),p=l("v-alert"),_=l("v-divider"),k=l("v-select"),i=l("v-col"),g=l("v-row"),x=l("v-textarea"),w=l("v-btn");return r.loading?(o(),h("div",$C,[e(f,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:1},[u[9]||(u[9]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Konfiguration für die KI-gestützte Outreach-Strategie pro Company. Der Prompt steuert die Generierung von Talking Points (3–5 Argumente) sowie einem Cold-Mail-Vorschlag (Betreff + Text). ",-1)),r.error?(o(),N(p,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":u[0]||(u[0]=b=>c("clearError"))},{default:t(()=>[n(v(r.error),1)]),_:1})):U("",!0),!r.hasPrompt&&!r.error?(o(),N(p,{key:1,type:"warning",variant:"tonal",density:"compact",class:"mb-4"},{default:t(()=>[...u[6]||(u[6]=[n(" Kein aktiver Outreach-Strategy-Prompt gefunden. Bitte unter ",-1),a("strong",null,"/admin/prompts",-1),n(" einen Prompt mit der Kategorie ",-1),a("strong",null,"outreach-strategy",-1),n(" anlegen und als Standard markieren. ",-1)])]),_:1})):U("",!0),u[10]||(u[10]=a("p",{class:"text-subtitle-1 font-weight-semibold mb-1"},"Prompt-Konfiguration",-1)),e(_,{class:"mb-4"}),r.promptSuccess?(o(),N(p,{key:2,type:"success",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":u[1]||(u[1]=b=>c("clearPromptSuccess"))},{default:t(()=>[...u[7]||(u[7]=[n(" Prompt gespeichert. ",-1)])]),_:1})):U("",!0),u[11]||(u[11]=a("p",{class:"text-subtitle-2 font-weight-semibold mb-3"},"GPT-Einstellungen",-1)),e(g,null,{default:t(()=>[e(i,{cols:"12",md:"6"},{default:t(()=>[e(k,{"model-value":r.promptForm.gptSettingsId,items:[{title:"Standard (System-Default)",value:""},...r.settings.map(b=>({title:b.name,value:b._id}))],label:"GPT-Konfiguration",variant:"outlined",density:"comfortable",hint:"Provider, Model und Temperature für die Outreach-Strategie","persistent-hint":"","onUpdate:modelValue":u[2]||(u[2]=b=>s("gptSettingsId",b??""))},null,8,["model-value","items"])]),_:1})]),_:1}),u[12]||(u[12]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"System-Prompt",-1)),e(g,null,{default:t(()=>[e(i,{cols:"12"},{default:t(()=>[e(x,{"model-value":r.promptForm.systemPrompt,label:"System-Prompt für Outreach-Strategie",variant:"outlined",rows:"10","no-resize":"",class:"prompt-textarea",hint:"Definiert die Rolle der KI und das gewünschte Ausgabeformat (Talking Points + Cold-Mail JSON)","persistent-hint":"","onUpdate:modelValue":u[3]||(u[3]=b=>s("systemPrompt",b??""))},null,8,["model-value"])]),_:1})]),_:1}),u[13]||(u[13]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"User-Prompt-Template",-1)),e(g,null,{default:t(()=>[e(i,{cols:"12"},{default:t(()=>[e(x,{"model-value":r.promptForm.userPromptTemplate,label:"User-Prompt-Template",variant:"outlined",rows:"10","no-resize":"",class:"prompt-textarea",hint:"Variablen: {{stammdaten}}, {{scoring}} werden im Prompt ersetzt","persistent-hint":"","onUpdate:modelValue":u[4]||(u[4]=b=>s("userPromptTemplate",b??""))},null,8,["model-value"])]),_:1})]),_:1}),a("div",CC,[e(w,{color:"primary",variant:"elevated",loading:r.promptSaving,disabled:!r.hasPrompt,"prepend-icon":"mdi-content-save-outline",onClick:u[5]||(u[5]=b=>c("savePrompt"))},{default:t(()=>[...u[8]||(u[8]=[n(" Prompt speichern ",-1)])]),_:1},8,["loading","disabled"])])],64))}}}),AC=Me(VC,[["__scopeId","data-v-c730154b"]]),IC={key:0,class:"d-flex justify-center pa-6"},PC={class:"d-flex justify-end mt-4"},zC={class:"d-flex justify-end mt-4"},DC=Ae({__name:"KiSettingsIntentPanel",props:{loading:{type:Boolean},error:{},promptSuccess:{type:Boolean},promptSaving:{type:Boolean},promptForm:{},hasPrompt:{type:Boolean},settings:{},autoTriggers:{},autoTriggersSaving:{type:Boolean},autoTriggersError:{},autoTriggersSuccess:{type:Boolean}},emits:["clearError","clearPromptSuccess","savePrompt","clearAutoTriggersError","clearAutoTriggersSuccess","saveAutoTriggers","update:promptForm","update:autoTriggers"],setup(r,{emit:$}){const d=r,c=$;function s(u,f){c("update:promptForm",{...d.promptForm,[u]:f})}function m(u,f){c("update:autoTriggers",{...d.autoTriggers,[u]:f})}return(u,f)=>{const p=l("v-progress-circular"),_=l("v-alert"),k=l("v-divider"),i=l("v-select"),g=l("v-col"),x=l("v-row"),w=l("v-textarea"),b=l("v-btn"),I=l("v-switch");return r.loading?(o(),h("div",IC,[e(p,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:1},[f[18]||(f[18]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Konfiguration für die KI-gestützte Intent-Klassifikation pro Company. Der Prompt steuert die Bewertung des Engagement-Status (kalt / warm / heiß / gewonnen / verloren) inkl. Score und Handlungsempfehlung. Die Auto-Trigger bestimmen, wann eine Neuberechnung automatisch angestoßen wird. ",-1)),r.error?(o(),N(_,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":f[0]||(f[0]=V=>c("clearError"))},{default:t(()=>[n(v(r.error),1)]),_:1})):U("",!0),!r.hasPrompt&&!r.error?(o(),N(_,{key:1,type:"warning",variant:"tonal",density:"compact",class:"mb-4"},{default:t(()=>[...f[13]||(f[13]=[n(" Kein aktiver Intent-Klassifikations-Prompt gefunden. Bitte unter ",-1),a("strong",null,"/admin/prompts",-1),n(" einen Prompt mit der Kategorie ",-1),a("strong",null,"intent-classification",-1),n(" anlegen und als Standard markieren. ",-1)])]),_:1})):U("",!0),f[19]||(f[19]=a("p",{class:"text-subtitle-1 font-weight-semibold mb-1"},"Prompt-Konfiguration",-1)),e(k,{class:"mb-4"}),r.promptSuccess?(o(),N(_,{key:2,type:"success",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":f[1]||(f[1]=V=>c("clearPromptSuccess"))},{default:t(()=>[...f[14]||(f[14]=[n(" Prompt gespeichert. ",-1)])]),_:1})):U("",!0),f[20]||(f[20]=a("p",{class:"text-subtitle-2 font-weight-semibold mb-3"},"GPT-Einstellungen",-1)),e(x,null,{default:t(()=>[e(g,{cols:"12",md:"6"},{default:t(()=>[e(i,{"model-value":r.promptForm.gptSettingsId,items:[{title:"Standard (System-Default)",value:""},...r.settings.map(V=>({title:V.name,value:V._id}))],label:"GPT-Konfiguration",variant:"outlined",density:"comfortable",hint:"Provider, Model und Temperature für die Intent-Klassifikation","persistent-hint":"","onUpdate:modelValue":f[2]||(f[2]=V=>s("gptSettingsId",V??""))},null,8,["model-value","items"])]),_:1})]),_:1}),f[21]||(f[21]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"System-Prompt",-1)),e(x,null,{default:t(()=>[e(g,{cols:"12"},{default:t(()=>[e(w,{"model-value":r.promptForm.systemPrompt,label:"System-Prompt für Intent-Klassifikation",variant:"outlined",rows:"10","no-resize":"",class:"prompt-textarea",hint:"Definiert die Rolle der KI und das gewünschte Ausgabeformat (status, score, reasoning, recommendation)","persistent-hint":"","onUpdate:modelValue":f[3]||(f[3]=V=>s("systemPrompt",V??""))},null,8,["model-value"])]),_:1})]),_:1}),f[22]||(f[22]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"User-Prompt-Template",-1)),e(x,null,{default:t(()=>[e(g,{cols:"12"},{default:t(()=>[e(w,{"model-value":r.promptForm.userPromptTemplate,label:"User-Prompt-Template",variant:"outlined",rows:"10","no-resize":"",class:"prompt-textarea",hint:"Variablen: {{engagement}}, {{replyMarker}}, {{stageHistory}} werden im Prompt ersetzt","persistent-hint":"","onUpdate:modelValue":f[4]||(f[4]=V=>s("userPromptTemplate",V??""))},null,8,["model-value"])]),_:1})]),_:1}),a("div",PC,[e(b,{color:"primary",variant:"elevated",loading:r.promptSaving,disabled:!r.hasPrompt,"prepend-icon":"mdi-content-save-outline",onClick:f[5]||(f[5]=V=>c("savePrompt"))},{default:t(()=>[...f[15]||(f[15]=[n(" Prompt speichern ",-1)])]),_:1},8,["loading","disabled"])]),e(k,{class:"my-6"}),f[23]||(f[23]=a("p",{class:"text-subtitle-1 font-weight-semibold mb-1"},"Auto-Trigger",-1)),e(k,{class:"mb-4"}),f[24]||(f[24]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Bestimmt, bei welchen Ereignissen die Intent-Klassifikation automatisch neu berechnet wird. ",-1)),r.autoTriggersError?(o(),N(_,{key:3,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":f[6]||(f[6]=V=>c("clearAutoTriggersError"))},{default:t(()=>[n(v(r.autoTriggersError),1)]),_:1})):U("",!0),r.autoTriggersSuccess?(o(),N(_,{key:4,type:"success",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":f[7]||(f[7]=V=>c("clearAutoTriggersSuccess"))},{default:t(()=>[...f[16]||(f[16]=[n(" Auto-Trigger-Einstellungen gespeichert. ",-1)])]),_:1})):U("",!0),e(x,null,{default:t(()=>[e(g,{cols:"12",md:"6"},{default:t(()=>[e(I,{"model-value":r.autoTriggers.replyMarker,label:"Reply-Marker (manuell gesetzt)",color:"primary","hide-details":"",class:"mb-2","onUpdate:modelValue":f[8]||(f[8]=V=>m("replyMarker",!!V))},null,8,["model-value"]),e(I,{"model-value":r.autoTriggers.mailjetClick,label:"Mailjet-Klick (Link-Tracking)",color:"primary","hide-details":"",class:"mb-2","onUpdate:modelValue":f[9]||(f[9]=V=>m("mailjetClick",!!V))},null,8,["model-value"]),e(I,{"model-value":r.autoTriggers.meetingBooked,label:"Meeting-Buchung",color:"primary","hide-details":"",class:"mb-2","onUpdate:modelValue":f[10]||(f[10]=V=>m("meetingBooked",!!V))},null,8,["model-value"]),e(I,{"model-value":r.autoTriggers.pipelineStageChange,label:"Pipeline-Stage-Wechsel",color:"primary","hide-details":"","onUpdate:modelValue":f[11]||(f[11]=V=>m("pipelineStageChange",!!V))},null,8,["model-value"])]),_:1})]),_:1}),a("div",zC,[e(b,{color:"primary",variant:"elevated",loading:r.autoTriggersSaving,"prepend-icon":"mdi-cog-outline",onClick:f[12]||(f[12]=V=>c("saveAutoTriggers"))},{default:t(()=>[...f[17]||(f[17]=[n(" Auto-Trigger speichern ",-1)])]),_:1},8,["loading"])])],64))}}}),TC=Me(DC,[["__scopeId","data-v-84d84cac"]]),LC={key:0,class:"d-flex justify-center pa-6"},EC={class:"d-flex justify-end mt-4"},MC=Ae({__name:"KiSettingsDirectMailPanel",props:{loading:{type:Boolean},error:{},promptSuccess:{type:Boolean},promptSaving:{type:Boolean},promptForm:{},hasPrompt:{type:Boolean},settings:{},undoDelaySec:{},undoDelaySecSaving:{type:Boolean},undoDelaySecError:{},undoDelaySecSuccess:{type:Boolean}},emits:["clearError","clearPromptSuccess","savePrompt","clearUndoDelayError","clearUndoDelaySuccess","saveUndoDelay","update:promptForm","update:undoDelaySec"],setup(r,{emit:$}){const d=r,c=$;function s(u,f){c("update:promptForm",{...d.promptForm,[u]:f})}function m(u){const f=typeof u=="number"?u:parseInt(String(u),10),p=isNaN(f)?30:Math.max(5,Math.min(300,f));c("update:undoDelaySec",p)}return(u,f)=>{const p=l("v-progress-circular"),_=l("v-alert"),k=l("v-divider"),i=l("v-select"),g=l("v-col"),x=l("v-row"),w=l("v-textarea"),b=l("v-btn"),I=l("v-text-field");return r.loading?(o(),h("div",LC,[e(p,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:1},[f[15]||(f[15]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Konfiguration für den KI-gestützten Direkt-Outreach-Mail-Composer. Der Prompt steuert die Generierung eines personalisierten Mailentwurfs (Betreff + Text) auf Basis von Lead- und Company-Daten. Das Undo-Fenster bestimmt, wie lange nach dem Absenden noch abgebrochen werden kann. ",-1)),r.error?(o(),N(_,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":f[0]||(f[0]=V=>c("clearError"))},{default:t(()=>[n(v(r.error),1)]),_:1})):U("",!0),!r.hasPrompt&&!r.error?(o(),N(_,{key:1,type:"warning",variant:"tonal",density:"compact",class:"mb-4"},{default:t(()=>[...f[10]||(f[10]=[n(" Kein aktiver Direct-Mail-Draft-Prompt gefunden. Bitte unter ",-1),a("strong",null,"/admin/prompts",-1),n(" einen Prompt mit der Kategorie ",-1),a("strong",null,"direct-mail-draft",-1),n(" anlegen und als Standard markieren. ",-1)])]),_:1})):U("",!0),f[16]||(f[16]=a("p",{class:"text-subtitle-1 font-weight-semibold mb-1"},"Prompt-Konfiguration",-1)),e(k,{class:"mb-4"}),r.promptSuccess?(o(),N(_,{key:2,type:"success",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":f[1]||(f[1]=V=>c("clearPromptSuccess"))},{default:t(()=>[...f[11]||(f[11]=[n(" Prompt gespeichert. ",-1)])]),_:1})):U("",!0),f[17]||(f[17]=a("p",{class:"text-subtitle-2 font-weight-semibold mb-3"},"GPT-Einstellungen",-1)),e(x,null,{default:t(()=>[e(g,{cols:"12",md:"6"},{default:t(()=>[e(i,{"model-value":r.promptForm.gptSettingsId,items:[{title:"Standard (System-Default)",value:""},...r.settings.map(V=>({title:V.name,value:V._id}))],label:"GPT-Konfiguration",variant:"outlined",density:"comfortable",hint:"Provider, Model und Temperature für den Direct-Mail-Entwurf","persistent-hint":"","onUpdate:modelValue":f[2]||(f[2]=V=>s("gptSettingsId",V??""))},null,8,["model-value","items"])]),_:1})]),_:1}),f[18]||(f[18]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"System-Prompt",-1)),e(x,null,{default:t(()=>[e(g,{cols:"12"},{default:t(()=>[e(w,{"model-value":r.promptForm.systemPrompt,label:"System-Prompt für Direct-Mail-Draft",variant:"outlined",rows:"10","no-resize":"",class:"prompt-textarea",hint:"Definiert die Rolle der KI und das gewünschte Ausgabeformat (subject + body JSON)","persistent-hint":"","onUpdate:modelValue":f[3]||(f[3]=V=>s("systemPrompt",V??""))},null,8,["model-value"])]),_:1})]),_:1}),f[19]||(f[19]=a("p",{class:"text-subtitle-2 font-weight-semibold mt-4 mb-3"},"User-Prompt-Template",-1)),e(x,null,{default:t(()=>[e(g,{cols:"12"},{default:t(()=>[e(w,{"model-value":r.promptForm.userPromptTemplate,label:"User-Prompt-Template",variant:"outlined",rows:"10","no-resize":"",class:"prompt-textarea",hint:"Variablen: {{lead}}, {{company}}, {{outreachStrategy}} werden im Prompt ersetzt","persistent-hint":"","onUpdate:modelValue":f[4]||(f[4]=V=>s("userPromptTemplate",V??""))},null,8,["model-value"])]),_:1})]),_:1}),a("div",EC,[e(b,{color:"primary",variant:"elevated",loading:r.promptSaving,disabled:!r.hasPrompt,"prepend-icon":"mdi-content-save-outline",onClick:f[5]||(f[5]=V=>c("savePrompt"))},{default:t(()=>[...f[12]||(f[12]=[n(" Prompt speichern ",-1)])]),_:1},8,["loading","disabled"])]),e(k,{class:"my-6"}),f[20]||(f[20]=a("p",{class:"text-subtitle-1 font-weight-semibold mb-1"},"Undo-Verzögerung",-1)),e(k,{class:"mb-4"}),f[21]||(f[21]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Zeitfenster (in Sekunden) nach dem Absenden, in dem der Versand noch abgebrochen werden kann. Mindestwert: 5 Sekunden, Maximalwert: 300 Sekunden. ",-1)),r.undoDelaySecError?(o(),N(_,{key:3,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":f[6]||(f[6]=V=>c("clearUndoDelayError"))},{default:t(()=>[n(v(r.undoDelaySecError),1)]),_:1})):U("",!0),r.undoDelaySecSuccess?(o(),N(_,{key:4,type:"success",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":f[7]||(f[7]=V=>c("clearUndoDelaySuccess"))},{default:t(()=>[...f[13]||(f[13]=[n(" Undo-Verzögerung gespeichert. ",-1)])]),_:1})):U("",!0),e(x,{align:"center"},{default:t(()=>[e(g,{cols:"12",sm:"4",md:"3"},{default:t(()=>[e(I,{"model-value":r.undoDelaySec,label:"Undo-Fenster",type:"number",variant:"outlined",density:"comfortable",min:"5",max:"300",suffix:"Sek",hint:"Standard: 30 Sekunden","persistent-hint":"","onUpdate:modelValue":f[8]||(f[8]=V=>m(V))},null,8,["model-value"])]),_:1}),e(g,{cols:"12",sm:"8",md:"9",class:"d-flex justify-end"},{default:t(()=>[e(b,{color:"primary",variant:"elevated",loading:r.undoDelaySecSaving,"prepend-icon":"mdi-timer-outline",onClick:f[9]||(f[9]=V=>c("saveUndoDelay"))},{default:t(()=>[...f[14]||(f[14]=[n(" Verzögerung speichern ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})],64))}}}),NC=Me(MC,[["__scopeId","data-v-ad02f6ae"]]),UC={key:0,class:"d-flex justify-center pa-4"},BC={class:"d-flex justify-end mt-4"},FC={class:"d-flex align-center justify-space-between"},OC={class:"d-flex align-center ga-2"},RC={key:0,class:"d-flex flex-column align-center justify-center",style:{height:"100%",opacity:"0.5"}},KC={key:0,class:"d-flex justify-end"},jC={class:"text-body-2",style:{"white-space":"pre-wrap"}},qC={key:1},GC={class:"text-body-2",style:{"white-space":"pre-wrap"}},HC={key:0,class:"mt-3"},WC={class:"d-flex align-center justify-space-between mb-1"},ZC={class:"text-body-2 font-weight-semibold"},JC={class:"d-flex ga-2"},QC={key:0,class:"text-caption text-medium-emphasis mb-1"},YC={class:"text-caption",style:{opacity:"0.7","max-height":"60px",overflow:"hidden"}},XC={class:"d-flex ga-2 mt-2"},e8={key:1,class:"d-flex align-center ga-2 mt-2"},t8={class:"pa-4 flex-shrink-0"},a8={class:"d-flex ga-2"},l8=Ae({__name:"IdeogramPresetChat",props:{knowledgeBases:{},kbLoading:{type:Boolean},settings:{}},emits:["presetAdopted"],setup(r,{emit:$}){const d=$,c=y(!1),s=y(null),m=y(!1),u=y(!1),f=wt({systemPrompt:"",selectedKnowledgeBaseIds:[],gptSettingsId:"",numImages:4}),p=[1,2,3,4,5,6,7,8].map(T=>({title:`${T} ${T===1?"Bild":"Bilder"}`,value:T})),_=y(!1),k=y([]),i=y(""),g=y(!1),x=y(null);let w=null;Ze(_,T=>{T||w==null||w.abort()}),Ft(()=>{w==null||w.abort()});async function b(){c.value=!0,s.value=null;try{const T=await re.get("/ideogram-presets/config");if(T.success&&T.data){const D=T.data;f.systemPrompt=D.systemPrompt||"",f.selectedKnowledgeBaseIds=D.selectedKnowledgeBaseIds||[],f.gptSettingsId=D.gptSettingsId||"",f.numImages=typeof D.numImages=="number"?D.numImages:4}else s.value=T.error||"Fehler beim Laden der Ideogram-Konfiguration"}catch{s.value="Netzwerkfehler beim Laden"}finally{c.value=!1}}async function I(){m.value=!0,s.value=null,u.value=!1;try{const T=await re.put("/ideogram-presets/config",{systemPrompt:f.systemPrompt,selectedKnowledgeBaseIds:f.selectedKnowledgeBaseIds,gptSettingsId:f.gptSettingsId||void 0,numImages:f.numImages});T.success?u.value=!0:s.value=T.error||"Fehler beim Speichern"}catch{s.value="Netzwerkfehler beim Speichern"}finally{m.value=!1}}function V(T){const D=T.indexOf("<!--PRESETS_START-->"),H=T.indexOf("<!--PRESETS_END-->");if(D<0||H<0||H<=D)return null;const O=T.substring(D+20,H).trim();try{const S=JSON.parse(O);return Array.isArray(S)?S:null}catch{return null}}function E(){Wt(()=>{var T;(T=x.value)==null||T.scrollIntoView({behavior:"smooth"})})}async function R(){var S;const T=i.value.trim();if(!T||g.value)return;i.value="",g.value=!0,k.value.push({role:"user",content:T}),E();const D=k.value.slice(0,-1).map(B=>({role:B.role,content:B.content})),H=re.getAccessToken();if(!H){k.value.push({role:"assistant",content:"Nicht authentifiziert. Bitte erneut anmelden."}),g.value=!1;return}const O={role:"assistant",content:"",presets:void 0};k.value.push(O),E();try{const B="/api";w=new AbortController;const G=await fetch(`${B}/ideogram-presets/chat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${H}`},body:JSON.stringify({message:T,chatHistory:D}),signal:w.signal});if(!G.ok){O.content=`Fehler: ${G.status}`,g.value=!1;return}const W=(S=G.body)==null?void 0:S.getReader();if(!W){O.content="Streaming nicht verfügbar",g.value=!1;return}const F=new TextDecoder;let L="";for(;;){const{done:A,value:z}=await W.read();if(A)break;L+=F.decode(z,{stream:!0});const j=L.split(`
`);L=j.pop()||"";for(const J of j){const Q=J.trim();if(!(!Q||!Q.startsWith("data: ")))try{const te=JSON.parse(Q.slice(6));switch(te.type){case"chunk":if(te.content){O.content+=te.content;const ve=V(O.content);ve&&(O.presets=ve),k.value=[...k.value],E()}break;case"stream_complete":if(te.message){O.content=te.message.content;const ve=V(O.content);ve&&(O.presets=ve),k.value=[...k.value]}break;case"error":O.content+=`

**Fehler:** ${te.message||"Unbekannter Fehler"}`,k.value=[...k.value];break}}catch{}}}}catch(B){if(B instanceof DOMException&&B.name==="AbortError")return;O.content="Netzwerkfehler beim Streaming"}finally{g.value=!1,E()}}async function M(T){try{const D=await re.post("/ideogram-presets",{name:T.name||"KI-Preset",description:T.description||"",prompt:T.prompt||"",aspectRatio:T.aspectRatio||"ASPECT_1_1",style:T.style||""});D.success?(T._saved=!0,k.value=[...k.value],d("presetAdopted")):s.value=D.error||"Fehler beim Speichern des Presets"}catch{s.value="Netzwerkfehler beim Speichern des Presets"}}return b(),(T,D)=>{const H=l("v-divider"),O=l("v-progress-circular"),S=l("v-alert"),B=l("v-autocomplete"),G=l("v-col"),W=l("v-select"),F=l("v-row"),L=l("v-textarea"),A=l("v-btn"),z=l("v-icon"),j=l("v-tooltip"),J=l("v-card-title"),Q=l("v-card"),te=l("v-chip"),ve=l("v-card-text"),de=l("v-text-field"),Z=l("v-dialog");return o(),h(be,null,[e(H,{class:"my-6"}),D[24]||(D[24]=a("p",{class:"text-subtitle-2 font-weight-semibold mb-3"},"KI-Konfiguration für Preset-Generierung",-1)),c.value?(o(),h("div",UC,[e(O,{indeterminate:"",color:"primary",size:"24"})])):(o(),h(be,{key:1},[s.value?(o(),N(S,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":D[0]||(D[0]=ce=>s.value=null)},{default:t(()=>[n(v(s.value),1)]),_:1})):U("",!0),u.value?(o(),N(S,{key:1,type:"success",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":D[1]||(D[1]=ce=>u.value=!1)},{default:t(()=>[...D[9]||(D[9]=[n(" Konfiguration gespeichert. ",-1)])]),_:1})):U("",!0),e(F,{dense:""},{default:t(()=>[e(G,{cols:"12"},{default:t(()=>[e(B,{modelValue:f.selectedKnowledgeBaseIds,"onUpdate:modelValue":D[2]||(D[2]=ce=>f.selectedKnowledgeBaseIds=ce),items:r.knowledgeBases,"item-title":"title","item-value":"_id",label:"Aktive Knowledge Bases für Preset-Generierung",variant:"outlined",multiple:"",chips:"","closable-chips":"",loading:r.kbLoading,hint:"Diese KB-Einträge werden als Kontext für die Preset-Generierung verwendet","persistent-hint":""},null,8,["modelValue","items","loading"])]),_:1}),e(G,{cols:"12",md:"6"},{default:t(()=>[e(W,{modelValue:f.gptSettingsId,"onUpdate:modelValue":D[3]||(D[3]=ce=>f.gptSettingsId=ce),items:[{title:"Standard (System-Default)",value:""},...r.settings.map(ce=>({title:ce.name,value:ce._id}))],label:"GPT-Konfiguration",variant:"outlined",density:"comfortable",hint:"Provider, Model und Temperature für die Preset-Generierung","persistent-hint":""},null,8,["modelValue","items"])]),_:1}),e(G,{cols:"12",md:"6"},{default:t(()=>[e(W,{modelValue:f.numImages,"onUpdate:modelValue":D[4]||(D[4]=ce=>f.numImages=ce),modelModifiers:{number:!0},items:P(p),label:"Bilder pro Generierung",variant:"outlined",density:"comfortable",hint:"Anzahl der Bilder, die Ideogram pro Generierung liefert (1-8)","persistent-hint":""},null,8,["modelValue","items"])]),_:1})]),_:1}),e(L,{modelValue:f.systemPrompt,"onUpdate:modelValue":D[5]||(D[5]=ce=>f.systemPrompt=ce),label:"System-Prompt",variant:"outlined",rows:"4","auto-grow":"",class:"mt-4",hint:"Instruktionen für die KI zur Preset-Generierung. Die KI soll Presets zwischen <!--PRESETS_START--> und <!--PRESETS_END--> Markern als JSON-Array ausgeben.","persistent-hint":""},null,8,["modelValue"]),a("div",BC,[e(A,{color:"primary",variant:"elevated",loading:m.value,"prepend-icon":"mdi-content-save-outline",onClick:I},{default:t(()=>[...D[10]||(D[10]=[n(" Konfiguration speichern ",-1)])]),_:1},8,["loading"])])],64)),e(Z,{modelValue:_.value,"onUpdate:modelValue":D[8]||(D[8]=ce=>_.value=ce),"max-width":"800",scrollable:""},{activator:t(({props:ce})=>[e(A,Vt(ce,{size:"small",variant:"tonal","prepend-icon":"mdi-robot",color:"primary",class:"mt-4"}),{default:t(()=>[...D[11]||(D[11]=[n(" Mit KI generieren ",-1)])]),_:1},16)]),default:t(()=>[e(Q,{class:"d-flex flex-column",style:{height:"80vh"}},{default:t(()=>[e(J,{class:"pa-4 pb-3 flex-shrink-0"},{default:t(()=>[a("div",FC,[a("div",OC,[e(z,{size:"20"},{default:t(()=>[...D[12]||(D[12]=[n("mdi-robot",-1)])]),_:1}),D[13]||(D[13]=a("span",{class:"text-h6"},"Presets mit KI generieren",-1))]),e(A,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:D[6]||(D[6]=ce=>_.value=!1)},{default:t(()=>[e(j,{activator:"parent",location:"bottom"},{default:t(()=>[...D[14]||(D[14]=[n("Schließen",-1)])]),_:1}),e(z,null,{default:t(()=>[...D[15]||(D[15]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(H),e(ve,{class:"flex-grow-1 overflow-y-auto pa-4",style:{"min-height":"0"}},{default:t(()=>[k.value.length?U("",!0):(o(),h("div",RC,[e(z,{size:"48",class:"mb-3"},{default:t(()=>[...D[16]||(D[16]=[n("mdi-image-auto-adjust",-1)])]),_:1}),D[17]||(D[17]=a("p",{class:"text-body-1"},"Beschreibe, welche Art von Bild-Presets du brauchst.",-1)),D[18]||(D[18]=a("p",{class:"text-body-2 text-medium-emphasis"},'z.B. "Erstelle Presets für LinkedIn Posts zum Thema IT-Security"',-1))])),(o(!0),h(be,null,Pe(k.value,(ce,oe)=>(o(),h("div",{key:oe,class:"mb-4"},[ce.role==="user"?(o(),h("div",KC,[e(Q,{variant:"tonal",color:"primary",class:"pa-3",style:{"max-width":"80%"}},{default:t(()=>[a("p",jC,v(ce.content),1)]),_:2},1024)])):(o(),h("div",qC,[e(Q,{variant:"outlined",class:"pa-3",style:{"max-width":"90%"}},{default:t(()=>[a("p",GC,v(ce.content.replace(/<!--PRESETS_START-->[\s\S]*?<!--PRESETS_END-->/g,"").trim()),1),ce.presets&&ce.presets.length?(o(),h("div",HC,[(o(!0),h(be,null,Pe(ce.presets,(pe,_e)=>(o(),N(Q,{key:_e,variant:"outlined",class:"mb-2 pa-3",style:{"border-color":"rgba(10, 201, 212, 0.3)"}},{default:t(()=>[a("div",WC,[a("span",ZC,v(pe.name),1),a("div",JC,[pe.aspectRatio?(o(),N(te,{key:0,size:"x-small",variant:"outlined"},{default:t(()=>[n(v(pe.aspectRatio),1)]),_:2},1024)):U("",!0),pe.style?(o(),N(te,{key:1,size:"x-small",variant:"outlined"},{default:t(()=>[n(v(pe.style),1)]),_:2},1024)):U("",!0)])]),pe.description?(o(),h("p",QC,v(pe.description),1)):U("",!0),a("p",YC,v(pe.prompt),1),a("div",XC,[pe._saved?(o(),N(te,{key:1,color:"success",size:"small",variant:"tonal","prepend-icon":"mdi-check-circle"},{default:t(()=>[...D[20]||(D[20]=[n(" Gespeichert ",-1)])]),_:1})):(o(),N(A,{key:0,size:"small",variant:"tonal",color:"success","prepend-icon":"mdi-check",onClick:q=>M(pe)},{default:t(()=>[...D[19]||(D[19]=[n(" Übernehmen ",-1)])]),_:1},8,["onClick"]))])]),_:2},1024))),128))])):U("",!0)]),_:2},1024)]))]))),128)),g.value?(o(),h("div",e8,[e(O,{indeterminate:"",size:"16",width:"2",color:"primary"}),D[21]||(D[21]=a("span",{class:"text-caption text-medium-emphasis"},"KI generiert...",-1))])):U("",!0),a("div",{ref_key:"chatEndRef",ref:x},null,512)]),_:1}),e(H),a("div",t8,[a("div",a8,[e(de,{modelValue:i.value,"onUpdate:modelValue":D[7]||(D[7]=ce=>i.value=ce),placeholder:"Beschreibe die gewünschten Presets...",variant:"outlined",density:"comfortable","hide-details":"",disabled:g.value,onKeyup:Kt(R,["enter"])},null,8,["modelValue","disabled"]),e(A,{icon:"",color:"primary",variant:"tonal",loading:g.value,disabled:!i.value.trim(),"aria-label":"Nachricht senden",onClick:R},{default:t(()=>[e(j,{activator:"parent",location:"bottom"},{default:t(()=>[...D[22]||(D[22]=[n("Nachricht senden",-1)])]),_:1}),e(z,null,{default:t(()=>[...D[23]||(D[23]=[n("mdi-send",-1)])]),_:1})]),_:1},8,["loading","disabled"])])])]),_:1})]),_:1},8,["modelValue"])],64)}}}),n8={key:1,class:"d-flex justify-center pa-6"},o8={class:"d-flex align-center justify-space-between mb-4"},s8={class:"d-flex ga-2"},i8={key:0,class:"text-body-2 text-medium-emphasis text-center py-4"},r8={class:"d-flex align-center justify-space-between"},d8={style:{flex:"1","min-width":"0"}},u8={class:"d-flex align-center ga-2 mb-1"},c8={class:"text-body-2 font-weight-semibold"},m8={class:"d-flex ga-1 mt-1 align-center flex-wrap"},v8={key:0,class:"text-caption text-medium-emphasis mt-1",style:{"max-width":"400px",overflow:"hidden","text-overflow":"ellipsis","white-space":"nowrap"}},p8={class:"d-flex ga-1 flex-shrink-0"},f8=Ae({__name:"KiSettingsIdeogramSection",props:{ideogramPresets:{},ideogramLoading:{type:Boolean},ideogramError:{},ideogramConfigured:{type:Boolean},deletingIdeogramPresetId:{},settingIdeogramDefaultId:{},knowledgeBases:{},kbLoading:{type:Boolean},settings:{}},emits:["clearError","create","edit","delete","toggleActive","setDefault","presetAdopted"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-alert"),u=l("v-progress-circular"),f=l("v-btn"),p=l("v-chip"),_=l("v-tooltip"),k=l("v-icon"),i=l("v-card-text"),g=l("v-card");return o(),h(be,null,[r.ideogramError?(o(),N(m,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":s[0]||(s[0]=x=>d("clearError"))},{default:t(()=>[n(v(r.ideogramError),1)]),_:1})):U("",!0),r.ideogramLoading?(o(),h("div",n8,[e(u,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:2},[a("div",o8,[s[4]||(s[4]=a("p",{class:"text-body-2 text-medium-emphasis"}," Stil-Presets für KI-Bildgenerierung. Werden im Image Pool, LinkedIn-Posts und bei der Ausarbeitung verwendet. ",-1)),a("div",s8,[e(f,{size:"small",variant:"outlined","prepend-icon":"mdi-plus",color:"primary",onClick:s[1]||(s[1]=x=>d("create"))},{default:t(()=>[...s[3]||(s[3]=[n(" Neues Preset ",-1)])]),_:1})])]),r.ideogramPresets.length?U("",!0):(o(),h("div",i8," Noch keine Presets konfiguriert. ")),(o(!0),h(be,null,Pe(r.ideogramPresets,x=>(o(),N(g,{key:x._id,variant:"outlined",class:"ki-settings-view__preset-card mb-2"},{default:t(()=>[e(i,{class:"pa-3"},{default:t(()=>{var w,b;return[a("div",r8,[a("div",d8,[a("div",u8,[a("span",c8,v(x.name),1),x.isDefault?(o(),N(p,{key:0,color:"secondary",size:"x-small",variant:"tonal"},{default:t(()=>[...s[5]||(s[5]=[n("Standard",-1)])]),_:1})):U("",!0),e(p,{color:x.isActive?"success":"default",size:"x-small",variant:"tonal"},{default:t(()=>[n(v(x.isActive?"Aktiv":"Inaktiv"),1)]),_:2},1032,["color"])]),a("div",m8,[e(p,{size:"x-small",variant:"outlined"},{default:t(()=>[n(v(x.aspectRatio),1)]),_:2},1024),x.style?(o(),N(p,{key:0,size:"x-small",variant:"outlined"},{default:t(()=>[n(v(x.style),1)]),_:2},1024)):U("",!0),x.createdBy?(o(),N(gt,{key:1,"user-id":((w=x.createdBy)==null?void 0:w._id)??x.createdBy,populated:typeof x.createdBy=="object"?x.createdBy:null,size:20},null,8,["user-id","populated"])):U("",!0),x.updatedBy?(o(),N(gt,{key:2,"user-id":((b=x.updatedBy)==null?void 0:b._id)??x.updatedBy,populated:typeof x.updatedBy=="object"?x.updatedBy:null,size:20},null,8,["user-id","populated"])):U("",!0)]),x.prompt?(o(),h("p",v8,v(x.prompt),1)):U("",!0)]),a("div",p8,[x.isDefault?(o(),N(f,{key:1,icon:"",variant:"text",size:"x-small",color:"warning","aria-label":"Standard-Preset"},{default:t(()=>[e(_,{activator:"parent",location:"bottom"},{default:t(()=>[...s[8]||(s[8]=[n("Standard-Preset",-1)])]),_:1}),e(k,{size:"16"},{default:t(()=>[...s[9]||(s[9]=[n("mdi-star",-1)])]),_:1})]),_:1})):(o(),N(f,{key:0,icon:"",variant:"text",size:"x-small",color:"default",loading:r.settingIdeogramDefaultId===x._id,"aria-label":"Als Standard setzen",onClick:I=>d("setDefault",x)},{default:t(()=>[e(_,{activator:"parent",location:"bottom"},{default:t(()=>[...s[6]||(s[6]=[n("Als Standard setzen",-1)])]),_:1}),e(k,{size:"16"},{default:t(()=>[...s[7]||(s[7]=[n("mdi-star-outline",-1)])]),_:1})]),_:1},8,["loading","onClick"])),e(f,{icon:"",variant:"text",size:"x-small",color:"primary","aria-label":"Bearbeiten",onClick:I=>d("edit",x)},{default:t(()=>[e(_,{activator:"parent",location:"bottom"},{default:t(()=>[...s[10]||(s[10]=[n("Bearbeiten",-1)])]),_:1}),e(k,{size:"16"},{default:t(()=>[...s[11]||(s[11]=[n("mdi-pencil-outline",-1)])]),_:1})]),_:1},8,["onClick"]),e(f,{icon:"",variant:"text",size:"x-small",color:"error",loading:r.deletingIdeogramPresetId===x._id,"aria-label":"Löschen",onClick:I=>d("delete",x)},{default:t(()=>[e(_,{activator:"parent",location:"bottom"},{default:t(()=>[...s[12]||(s[12]=[n("Löschen",-1)])]),_:1}),e(k,{size:"16"},{default:t(()=>[...s[13]||(s[13]=[n("mdi-trash-can-outline",-1)])]),_:1})]),_:1},8,["loading","onClick"])])])]}),_:2},1024)]),_:2},1024))),128)),e(l8,{"knowledge-bases":r.knowledgeBases,"kb-loading":r.kbLoading,settings:r.settings,onPresetAdopted:s[2]||(s[2]=x=>d("presetAdopted"))},null,8,["knowledge-bases","kb-loading","settings"])],64))],64)}}}),g8=Me(f8,[["__scopeId","data-v-c942466d"]]),b8={class:"d-flex align-center justify-space-between"},y8={class:"text-h6"},_8=Ae({__name:"KiSettingsIdeogramPresetDialog",props:{modelValue:{type:Boolean},editingIdeogramPreset:{},ideogramSaving:{type:Boolean},ideogramForm:{}},emits:["update:modelValue","save"],setup(r,{emit:$}){const d=[{title:"1:1",value:"ASPECT_1_1"},{title:"4:5",value:"ASPECT_4_5"},{title:"16:9",value:"ASPECT_16_9"},{title:"9:16",value:"ASPECT_9_16"},{title:"3:2",value:"ASPECT_3_2"},{title:"2:3",value:"ASPECT_2_3"}],c=$;return(s,m)=>{const u=l("v-tooltip"),f=l("v-icon"),p=l("v-btn"),_=l("v-card-title"),k=l("v-divider"),i=l("v-text-field"),g=l("v-col"),x=l("v-textarea"),w=l("v-select"),b=l("v-row"),I=l("v-card-text"),V=l("v-spacer"),E=l("v-card-actions"),R=l("v-card"),M=l("v-dialog");return o(),N(M,{"model-value":r.modelValue,"max-width":"560","onUpdate:modelValue":m[8]||(m[8]=T=>c("update:modelValue",T))},{default:t(()=>[e(R,{class:"ki-settings-view__dialog"},{default:t(()=>[e(_,{class:"pa-6 pb-4"},{default:t(()=>[a("div",b8,[a("span",y8,v(r.editingIdeogramPreset?"Preset bearbeiten":"Neues Preset"),1),e(p,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:m[0]||(m[0]=T=>c("update:modelValue",!1))},{default:t(()=>[e(u,{activator:"parent",location:"bottom"},{default:t(()=>[...m[9]||(m[9]=[n("Schließen",-1)])]),_:1}),e(f,null,{default:t(()=>[...m[10]||(m[10]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(k),e(I,{class:"pa-6"},{default:t(()=>[e(b,null,{default:t(()=>[e(g,{cols:"12"},{default:t(()=>[e(i,{modelValue:r.ideogramForm.name,"onUpdate:modelValue":m[1]||(m[1]=T=>r.ideogramForm.name=T),label:"Name",placeholder:"z.B. LinkedIn Professional",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(g,{cols:"12"},{default:t(()=>[e(i,{modelValue:r.ideogramForm.description,"onUpdate:modelValue":m[2]||(m[2]=T=>r.ideogramForm.description=T),label:"Beschreibung (optional)",placeholder:"Kurze Beschreibung des Presets",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(g,{cols:"12"},{default:t(()=>[e(x,{modelValue:r.ideogramForm.prompt,"onUpdate:modelValue":m[3]||(m[3]=T=>r.ideogramForm.prompt=T),label:"Basis-Prompt",placeholder:"Beschreibung des Bildstils, z.B. 'Modern tech style, clean lines, professional blue tones'",variant:"outlined",rows:"3","auto-grow":""},null,8,["modelValue"])]),_:1}),e(g,{cols:"12",sm:"6"},{default:t(()=>[e(w,{modelValue:r.ideogramForm.aspectRatio,"onUpdate:modelValue":m[4]||(m[4]=T=>r.ideogramForm.aspectRatio=T),label:"Seitenverhältnis",items:d,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(g,{cols:"12",sm:"6"},{default:t(()=>[e(i,{modelValue:r.ideogramForm.style,"onUpdate:modelValue":m[5]||(m[5]=T=>r.ideogramForm.style=T),label:"Stil (optional)",placeholder:"z.B. REALISTIC, DESIGN",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(k),e(E,{class:"pa-4"},{default:t(()=>[e(V),e(p,{variant:"text",onClick:m[6]||(m[6]=T=>c("update:modelValue",!1))},{default:t(()=>[...m[11]||(m[11]=[n("Abbrechen",-1)])]),_:1}),e(p,{color:"primary",variant:"elevated",loading:r.ideogramSaving,disabled:!r.ideogramForm.name.trim()||!r.ideogramForm.prompt.trim(),onClick:m[7]||(m[7]=T=>c("save"))},{default:t(()=>[...m[12]||(m[12]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["model-value"])}}}),k8=Me(_8,[["__scopeId","data-v-c838a55e"]]),h8=Ae({__name:"KiSettingsIdeogramDeleteDialog",props:{modelValue:{type:Boolean}},emits:["update:modelValue","confirm"],setup(r,{emit:$}){const d=$;return(c,s)=>{const m=l("v-card-title"),u=l("v-card-text"),f=l("v-spacer"),p=l("v-btn"),_=l("v-card-actions"),k=l("v-card"),i=l("v-dialog");return o(),N(i,{"model-value":r.modelValue,"max-width":"440","onUpdate:modelValue":s[2]||(s[2]=g=>d("update:modelValue",g))},{default:t(()=>[e(k,null,{default:t(()=>[e(m,{class:"pa-6 pb-4 text-subtitle-1"},{default:t(()=>[...s[3]||(s[3]=[n("Preset löschen?",-1)])]),_:1}),e(u,{class:"pa-6 pt-0 text-body-2 text-medium-emphasis"},{default:t(()=>[...s[4]||(s[4]=[n(" Diese Aktion kann nicht rückgängig gemacht werden. Das Ideogram-Preset wird dauerhaft gelöscht. ",-1)])]),_:1}),e(_,{class:"pa-4"},{default:t(()=>[e(f),e(p,{variant:"text",onClick:s[0]||(s[0]=g=>d("update:modelValue",!1))},{default:t(()=>[...s[5]||(s[5]=[n("Abbrechen",-1)])]),_:1}),e(p,{color:"error",variant:"elevated",onClick:s[1]||(s[1]=g=>d("confirm"))},{default:t(()=>[...s[6]||(s[6]=[n("Löschen",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["model-value"])}}}),x8=Zt("tokenUsage",()=>{const r=y(null),$=y([]),d=y([]),c=y([]),s=y(!1),m=y(!1),u=y(!1),f=y(null);function p(I){const V=new URLSearchParams;return V.set("startDate",I.startDate),V.set("endDate",I.endDate),V.toString()}async function _(I){s.value=!0,f.value=null;try{const V=await re.get(`/admin/token-usage/stats?${p(I)}`);V.success&&V.data?r.value=V.data:(f.value=V.error||"Fehler beim Laden der Kosten-Statistiken",ue.error("ADMIN","Token-Usage stats fetch failed",{error:V.error}))}catch(V){const E=V instanceof Error?V.message:"Netzwerkfehler";f.value=E,ue.error("ADMIN","Token-Usage stats exception",{message:E})}finally{s.value=!1}}async function k(I){try{const V=await re.get(`/admin/token-usage/daily-costs?${p(I)}`);V.success&&Array.isArray(V.data)?$.value=V.data:(f.value=V.error||"Fehler beim Laden der Tageskosten",ue.error("ADMIN","Token-Usage daily-costs fetch failed",{error:V.error}))}catch(V){const E=V instanceof Error?V.message:"Netzwerkfehler";f.value=E,ue.error("ADMIN","Token-Usage daily-costs exception",{message:E})}}async function i(I){try{const V=await re.get(`/admin/token-usage/model-breakdown?${p(I)}`);V.success&&Array.isArray(V.data)?d.value=V.data:f.value=V.error||"Fehler beim Laden der Modell-Aufschlüsselung"}catch(V){const E=V instanceof Error?V.message:"Netzwerkfehler";f.value=E,ue.error("ADMIN","Token-Usage model-breakdown exception",{message:E})}}async function g(){m.value=!0;try{const I=await re.get("/admin/token-usage/pricings");I.success&&Array.isArray(I.data)?c.value=I.data:(f.value=I.error||"Fehler beim Laden der Token-Preise",ue.error("ADMIN","Token-Pricing fetch failed",{error:I.error}))}catch(I){const V=I instanceof Error?I.message:"Netzwerkfehler";f.value=V}finally{m.value=!1}}async function x(I){u.value=!0,f.value=null;try{const V=await re.put("/admin/token-usage/pricings",I);return V.success?(await g(),!0):(f.value=V.error||"Fehler beim Speichern des Preises",!1)}catch(V){const E=V instanceof Error?V.message:"Netzwerkfehler";return f.value=E,!1}finally{u.value=!1}}async function w(I){f.value=null;try{const V=await re.delete(`/admin/token-usage/pricings/${I}`);return V.success?(await g(),!0):(f.value=V.error||"Fehler beim Löschen des Preises",!1)}catch(V){const E=V instanceof Error?V.message:"Netzwerkfehler";return f.value=E,!1}}function b(){r.value=null,$.value=[],d.value=[],c.value=[],s.value=!1,m.value=!1,u.value=!1,f.value=null}return{stats:r,dailyCosts:$,modelBreakdown:d,pricings:c,loading:s,loadingPricings:m,savingPricing:u,error:f,fetchStats:_,fetchDailyCosts:k,fetchModelBreakdown:i,fetchPricings:g,upsertPricing:x,deletePricing:w,$reset:b}}),Mt={primary:"#0AC9D4",accent:"#C9A063",highlight:"#E2F54B",error:"#CF6679",subtitle:"#748686",surface:"#1a1a1a",background:"#000000",text:"#FFFFFF"};function jt(){const r=se(()=>({chart:{background:Mt.background,foreColor:Mt.text,fontFamily:"Lato, Arial, sans-serif",toolbar:{show:!1}},theme:{mode:"dark"},colors:[Mt.primary,Mt.accent,Mt.highlight,Mt.error,Mt.subtitle],grid:{borderColor:"rgba(255,255,255,0.1)"},tooltip:{theme:"dark"},xaxis:{labels:{style:{colors:Mt.subtitle}}},yaxis:{labels:{style:{colors:Mt.subtitle}}}}));function $(d){return{sent:Mt.text,delivered:Mt.primary,opened:Mt.primary,clicked:Mt.accent,meeting:Mt.highlight,bounced:Mt.error,unsubscribed:Mt.subtitle}[d]||Mt.primary}return{baseOptions:r,getMetricColor:$,BASEC_COLORS:Mt}}const w8={class:"d-flex align-center mb-1"},S8={class:"d-flex align-center mb-1"},$8={class:"d-flex align-center mb-1"},C8={class:"d-flex align-center mb-1"},V8={class:"text-caption text-medium-emphasis mt-1"},A8={key:2,class:"text-medium-emphasis text-body-2"},I8={key:0,class:"text-caption ml-2"},P8={key:0,class:"d-flex flex-column align-center justify-center pa-8 text-center"},z8={class:"d-flex justify-end mb-3"},D8=Ae({__name:"KiSettingsCostControl",setup(r){const $=Nt(()=>Lt(()=>import("./charts-tfNpfMZ7.js"),__vite__mapDeps([0,1,2,3]))),d=x8(),{stats:c,dailyCosts:s,pricings:m,loading:u,loadingPricings:f,savingPricing:p,error:_}=Ea(d),{baseOptions:k,BASEC_COLORS:i}=jt(),g=y("30");function x(q){return q.toISOString().slice(0,10)}function w(q){const C=new Date,ae=new Date;return ae.setDate(C.getDate()-(parseInt(q,10)-1)),{startDate:x(ae),endDate:x(C)}}async function b(){const q=w(g.value);await Promise.all([d.fetchStats(q),d.fetchDailyCosts(q)])}Ze(g,()=>{b()});const I=se(()=>{let q=0;return s.value.map(C=>(q+=C.cost,{date:C.date,value:Number(q.toFixed(4))}))}),V=se(()=>I.value.length===0?0:I.value[I.value.length-1].value??0),E=se(()=>{const q=new Date,C=new Date(q.getFullYear(),q.getMonth()+1,0),ae=Math.max(0,Math.ceil((C.getTime()-q.getTime())/(1e3*60*60*24))),X=q.getMonth(),ie=q.getFullYear(),Se=s.value.filter(ne=>{const Ce=new Date(ne.date);return Ce.getMonth()===X&&Ce.getFullYear()===ie}).reduce((ne,Ce)=>ne+Ce.cost,0),me=q.getUTCDate(),ee=me>0?Se/me:0,Y=Number((Se+ee*ae).toFixed(2)),K=[];let le=V.value;for(let ne=1;ne<=ae;ne++){const Ce=new Date(q);Ce.setDate(q.getDate()+ne),le+=ee,K.push({date:x(Ce),value:Number(le.toFixed(4))})}return{points:K,total:Y,daysRemaining:ae}}),R=se(()=>{const q=I.value.map(ae=>ae.date),C=E.value.points.map(ae=>ae.date);return[...q,...C]}),M=se(()=>{const q=I.value.map(fe=>fe.value),C=q.length,ae=E.value.points.length,X=[...q,...Array(ae).fill(null)],ie=Array(Math.max(0,C-1)).fill(null);C>0&&ie.push(q[C-1]);for(const fe of E.value.points)ie.push(fe.value);return[{name:"Tatsächlich",data:X},{name:"Prognose",data:ie}]}),T=se(()=>({...k.value,chart:{...k.value.chart,type:"area",animations:{enabled:!0,easing:"easeinout",speed:400}},colors:[i.primary,i.accent],stroke:{curve:"smooth",width:[3,2],dashArray:[0,6]},fill:{type:"gradient",gradient:{shadeIntensity:1,opacityFrom:.35,opacityTo:.02,stops:[0,95,100]}},markers:{size:0,hover:{size:4}},xaxis:{categories:R.value,labels:{style:{colors:i.subtitle,fontSize:"11px"},formatter:q=>{if(!q)return"";const C=new Date(q);return Number.isNaN(C.getTime())?q:C.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})}},tickAmount:7},yaxis:{labels:{style:{colors:i.subtitle},formatter:q=>`$${q.toFixed(2)}`},min:0},legend:{show:!0,position:"top",labels:{colors:i.text}},tooltip:{theme:"dark",shared:!0,y:{formatter:q=>q==null?"-":`$${q.toFixed(2)}`}}}));function D(q){return q==null?"-":`$${q.toFixed(2)}`}function H(q){return q==null?"-":q.toLocaleString("de-DE")}const O=[{label:"Anthropic",value:"anthropic"},{label:"Azure OpenAI",value:"azure"},{label:"Google Gemini",value:"gemini"}],S=[{title:"Provider",key:"provider",sortable:!0},{title:"Modell",key:"displayName",sortable:!0},{title:"Input / 1M USD",key:"inputPricePerMillionUSD",align:"end"},{title:"Output / 1M USD",key:"outputPricePerMillionUSD",align:"end"},{title:"Cached Input / 1M",key:"cachedInputPricePerMillionUSD",align:"end"},{title:"Cache Write / 1M",key:"cacheWritePricePerMillionUSD",align:"end"},{title:"Aktiv",key:"isActive",align:"center"},{title:"Aktionen",key:"actions",sortable:!1,align:"end"}];function B(q){var C;return((C=O.find(ae=>ae.value===q))==null?void 0:C.label)??q}const G=y(!1),W=y(null),F=y(!1),L=y(null),A=wt({provider:"anthropic",modelName:"",displayName:"",inputPricePerMillionUSD:null,outputPricePerMillionUSD:null,cachedInputPricePerMillionUSD:null,cacheWritePricePerMillionUSD:null,isActive:!0});function z(){W.value=null,L.value=null,A.provider="anthropic",A.modelName="",A.displayName="",A.inputPricePerMillionUSD=null,A.outputPricePerMillionUSD=null,A.cachedInputPricePerMillionUSD=null,A.cacheWritePricePerMillionUSD=null,A.isActive=!0}function j(){z(),G.value=!0}function J(q){W.value=q._id??null,L.value=null,A.provider=q.provider,A.modelName=q.modelName,A.displayName=q.displayName,A.inputPricePerMillionUSD=q.inputPricePerMillionUSD,A.outputPricePerMillionUSD=q.outputPricePerMillionUSD,A.cachedInputPricePerMillionUSD=q.cachedInputPricePerMillionUSD??null,A.cacheWritePricePerMillionUSD=q.cacheWritePricePerMillionUSD??null,A.isActive=q.isActive,G.value=!0}async function Q(){if(!F.value)return;if(A.inputPricePerMillionUSD===null||A.outputPricePerMillionUSD===null){L.value="Input- und Output-Preis sind erforderlich";return}const q={provider:A.provider,modelName:A.modelName.trim(),displayName:A.displayName.trim(),inputPricePerMillionUSD:A.inputPricePerMillionUSD,outputPricePerMillionUSD:A.outputPricePerMillionUSD,cachedInputPricePerMillionUSD:A.cachedInputPricePerMillionUSD??void 0,cacheWritePricePerMillionUSD:A.cacheWritePricePerMillionUSD??void 0,isActive:A.isActive};W.value&&(q._id=W.value),await d.upsertPricing(q)?(G.value=!1,z(),ue.info("ADMIN","Token-Pricing gespeichert",{provider:q.provider,modelName:q.modelName})):L.value=_.value||"Fehler beim Speichern"}const te=y(!1),ve=y(null),de=y("");function Z(q){q._id&&(ve.value=q._id,de.value=`${B(q.provider)} / ${q.displayName}`,te.value=!0)}async function ce(){if(!ve.value)return;const q=ve.value;te.value=!1,ve.value=null,await d.deletePricing(q)}const oe=q=>q!=null&&String(q).trim().length>0||"Pflichtfeld",pe=q=>{if(q==null||q==="")return"Pflichtfeld";const C=Number(q);return Number.isNaN(C)?"Ungültige Zahl":C<0?"Muss >= 0 sein":!0},_e=q=>{if(q==null||q==="")return!0;const C=Number(q);return Number.isNaN(C)?"Ungültige Zahl":C<0?"Muss >= 0 sein":!0};return rt(async()=>{await Promise.all([b(),d.fetchPricings()])}),(q,C)=>{const ae=l("v-icon"),X=l("v-spacer"),ie=l("v-btn"),fe=l("v-btn-toggle"),Se=l("v-card-title"),me=l("v-alert"),ee=l("v-skeleton-loader"),Y=l("v-card"),K=l("v-col"),le=l("v-row"),ne=l("v-card-subtitle"),Ce=l("v-card-text"),ke=l("v-chip"),xe=l("v-expansion-panel-title"),Ne=l("v-tooltip"),Ie=l("v-data-table"),Ue=l("v-expansion-panel-text"),Te=l("v-expansion-panel"),ye=l("v-expansion-panels"),Je=l("v-select"),Ke=l("v-text-field"),$e=l("v-checkbox"),Ee=l("v-form"),lt=l("v-card-actions"),ut=l("v-dialog");return o(),N(Y,{variant:"outlined",class:"ki-cost-control mb-6"},{default:t(()=>[e(Se,{class:"d-flex align-center flex-wrap ga-2"},{default:t(()=>[e(ae,{class:"mr-2",color:"primary"},{default:t(()=>[...C[16]||(C[16]=[n("mdi-chart-box-outline",-1)])]),_:1}),C[20]||(C[20]=a("span",null,"Kostenkontrolle",-1)),e(X),e(fe,{modelValue:g.value,"onUpdate:modelValue":C[0]||(C[0]=Ve=>g.value=Ve),density:"compact",variant:"outlined",color:"primary",mandatory:""},{default:t(()=>[e(ie,{value:"7",size:"small"},{default:t(()=>[...C[17]||(C[17]=[n("7 Tage",-1)])]),_:1}),e(ie,{value:"30",size:"small"},{default:t(()=>[...C[18]||(C[18]=[n("30 Tage",-1)])]),_:1}),e(ie,{value:"90",size:"small"},{default:t(()=>[...C[19]||(C[19]=[n("90 Tage",-1)])]),_:1})]),_:1},8,["modelValue"])]),_:1}),e(Ce,null,{default:t(()=>[P(_)?(o(),N(me,{key:0,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":C[1]||(C[1]=Ve=>_.value=null)},{default:t(()=>[n(v(P(_)),1)]),_:1})):U("",!0),e(le,{dense:"",class:"ki-cost-control__kpis"},{default:t(()=>[e(K,{cols:"12",sm:"6",md:"3"},{default:t(()=>[e(Y,{variant:"outlined",class:"ki-cost-control__kpi-card pa-3 h-100 d-flex flex-column"},{default:t(()=>{var Ve;return[a("div",w8,[e(ae,{color:"primary",size:"18",class:"mr-1"},{default:t(()=>[...C[21]||(C[21]=[n("mdi-currency-usd",-1)])]),_:1}),C[22]||(C[22]=a("span",{class:"text-caption text-medium-emphasis"},"Gesamtkosten",-1))]),a("div",{class:"text-h5 font-weight-bold ki-cost-control__kpi-value",style:ht({color:P(i).primary})},[P(u)&&!P(c)?(o(),N(ee,{key:0,type:"text"})):(o(),h(be,{key:1},[n(v(D((Ve=P(c))==null?void 0:Ve.totalCost)),1)],64))],4)]}),_:1})]),_:1}),e(K,{cols:"12",sm:"6",md:"3"},{default:t(()=>[e(Y,{variant:"outlined",class:"ki-cost-control__kpi-card pa-3 h-100 d-flex flex-column"},{default:t(()=>{var Ve;return[a("div",S8,[e(ae,{color:"primary",size:"18",class:"mr-1"},{default:t(()=>[...C[23]||(C[23]=[n("mdi-counter",-1)])]),_:1}),C[24]||(C[24]=a("span",{class:"text-caption text-medium-emphasis"},"Gesamt-Tokens",-1))]),a("div",{class:"text-h5 font-weight-bold ki-cost-control__kpi-value",style:ht({color:P(i).primary})},[P(u)&&!P(c)?(o(),N(ee,{key:0,type:"text"})):(o(),h(be,{key:1},[n(v(H((Ve=P(c))==null?void 0:Ve.totalTokens)),1)],64))],4)]}),_:1})]),_:1}),e(K,{cols:"12",sm:"6",md:"3"},{default:t(()=>[e(Y,{variant:"outlined",class:"ki-cost-control__kpi-card pa-3 h-100 d-flex flex-column"},{default:t(()=>{var Ve;return[a("div",$8,[e(ae,{color:P(i).accent,size:"18",class:"mr-1"},{default:t(()=>[...C[25]||(C[25]=[n("mdi-message-processing-outline",-1)])]),_:1},8,["color"]),C[26]||(C[26]=a("span",{class:"text-caption text-medium-emphasis"},"Requests",-1))]),a("div",{class:"text-h5 font-weight-bold ki-cost-control__kpi-value",style:ht({color:P(i).accent})},[P(u)&&!P(c)?(o(),N(ee,{key:0,type:"text"})):(o(),h(be,{key:1},[n(v(H((Ve=P(c))==null?void 0:Ve.totalRequests)),1)],64))],4)]}),_:1})]),_:1}),e(K,{cols:"12",sm:"6",md:"3"},{default:t(()=>[e(Y,{variant:"outlined",class:"ki-cost-control__kpi-card pa-3 h-100 d-flex flex-column"},{default:t(()=>{var Ve;return[a("div",C8,[e(ae,{color:P(i).highlight,size:"18",class:"mr-1"},{default:t(()=>[...C[27]||(C[27]=[n("mdi-star-outline",-1)])]),_:1},8,["color"]),C[28]||(C[28]=a("span",{class:"text-caption text-medium-emphasis"},"Top-Modell",-1))]),a("div",{class:"text-subtitle-1 font-weight-bold ki-cost-control__kpi-value",style:ht({color:P(i).highlight})},[P(u)&&!P(c)?(o(),N(ee,{key:0,type:"text"})):(Ve=P(c))!=null&&Ve.topModel?(o(),h(be,{key:1},[a("div",null,v(P(c).topModel.modelName),1),a("div",V8,v(B(P(c).topModel.provider))+" · "+v(D(P(c).topModel.cost)),1)],64)):(o(),h("span",A8,"Keine Daten"))],4)]}),_:1})]),_:1})]),_:1}),e(Y,{variant:"flat",class:"mt-4 ki-cost-control__chart-card"},{default:t(()=>[e(Se,{class:"text-subtitle-1 font-weight-semibold"},{default:t(()=>[...C[29]||(C[29]=[n(" Kostenprognose ",-1)])]),_:1}),e(ne,null,{default:t(()=>[C[30]||(C[30]=n(" Tatsächlich: ",-1)),a("strong",null,v(D(V.value)),1),C[31]||(C[31]=n("  |  Prognose Monatsende: ",-1)),a("strong",null,v(D(E.value.total)),1),E.value.daysRemaining>0?(o(),h("span",I8," (noch "+v(E.value.daysRemaining)+" Tage) ",1)):U("",!0)]),_:1}),e(Ce,null,{default:t(()=>[P(s).length===0&&!P(u)?(o(),h("div",P8,[e(ae,{size:"48",color:"medium-emphasis"},{default:t(()=>[...C[32]||(C[32]=[n("mdi-chart-timeline-variant",-1)])]),_:1}),C[33]||(C[33]=a("p",{class:"mt-2 text-medium-emphasis"},"Noch keine Kostendaten für den gewählten Zeitraum",-1))])):(o(),N(Tt,{key:1},{fallback:t(()=>[e(ee,{type:"image",height:"300"})]),default:t(()=>[e(P($),{type:"area",options:T.value,series:M.value,height:"300"},null,8,["options","series"])]),_:1}))]),_:1})]),_:1}),e(ye,{class:"mt-4 ki-cost-control__pricing-panels",variant:"accordion"},{default:t(()=>[e(Te,null,{default:t(()=>[e(xe,{class:"text-subtitle-1 font-weight-semibold"},{default:t(()=>[e(ae,{class:"mr-2",size:"20"},{default:t(()=>[...C[34]||(C[34]=[n("mdi-tag-outline",-1)])]),_:1}),C[35]||(C[35]=n(" Token-Preise pflegen ",-1)),e(ke,{size:"x-small",variant:"tonal",class:"ml-3"},{default:t(()=>[n(v(P(m).length),1)]),_:1})]),_:1}),e(Ue,null,{default:t(()=>[a("div",z8,[e(ie,{color:"primary",variant:"tonal","prepend-icon":"mdi-plus",size:"small",onClick:j},{default:t(()=>[...C[36]||(C[36]=[n(" Neuer Preis ",-1)])]),_:1})]),e(Ie,{headers:S,items:P(m),loading:P(f),density:"compact",class:"ki-cost-control__pricing-table","items-per-page":25},{"item.provider":t(({item:Ve})=>[e(ke,{size:"x-small",variant:"tonal"},{default:t(()=>[n(v(B(Ve.provider)),1)]),_:2},1024)]),"item.inputPricePerMillionUSD":t(({item:Ve})=>[n(v(D(Ve.inputPricePerMillionUSD)),1)]),"item.outputPricePerMillionUSD":t(({item:Ve})=>[n(v(D(Ve.outputPricePerMillionUSD)),1)]),"item.cachedInputPricePerMillionUSD":t(({item:Ve})=>[n(v(Ve.cachedInputPricePerMillionUSD!=null?D(Ve.cachedInputPricePerMillionUSD):"-"),1)]),"item.cacheWritePricePerMillionUSD":t(({item:Ve})=>[n(v(Ve.cacheWritePricePerMillionUSD!=null?D(Ve.cacheWritePricePerMillionUSD):"-"),1)]),"item.isActive":t(({item:Ve})=>[e(ae,{color:Ve.isActive?"success":"default",size:"18"},{default:t(()=>[n(v(Ve.isActive?"mdi-check-circle":"mdi-close-circle-outline"),1)]),_:2},1032,["color"])]),"item.actions":t(({item:Ve})=>[e(Ne,{text:"Bearbeiten",location:"top"},{activator:t(({props:Le})=>[e(ie,Vt(Le,{icon:"mdi-pencil-outline",size:"x-small",variant:"text",onClick:Ye=>J(Ve)}),null,16,["onClick"])]),_:2},1024),e(Ne,{text:"Löschen",location:"top"},{activator:t(({props:Le})=>[e(ie,Vt(Le,{icon:"mdi-delete-outline",size:"x-small",variant:"text",color:"error",onClick:Ye=>Z(Ve)}),null,16,["onClick"])]),_:2},1024)]),"no-data":t(()=>[...C[37]||(C[37]=[a("div",{class:"text-center text-medium-emphasis py-4"}," Noch keine Token-Preise hinterlegt ",-1)])]),_:2},1032,["items","loading"])]),_:1})]),_:1})]),_:1})]),_:1}),e(ut,{modelValue:G.value,"onUpdate:modelValue":C[13]||(C[13]=Ve=>G.value=Ve),"max-width":"640",persistent:""},{default:t(()=>[e(Y,null,{default:t(()=>[e(Se,{class:"text-h6"},{default:t(()=>[n(v(W.value?"Token-Preis bearbeiten":"Neuer Token-Preis"),1)]),_:1}),e(Ce,null,{default:t(()=>[L.value?(o(),N(me,{key:0,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":C[2]||(C[2]=Ve=>L.value=null)},{default:t(()=>[n(v(L.value),1)]),_:1})):U("",!0),e(Ee,{modelValue:F.value,"onUpdate:modelValue":C[11]||(C[11]=Ve=>F.value=Ve)},{default:t(()=>[e(le,{dense:""},{default:t(()=>[e(K,{cols:"12",sm:"6"},{default:t(()=>[e(Je,{modelValue:A.provider,"onUpdate:modelValue":C[3]||(C[3]=Ve=>A.provider=Ve),items:O,"item-title":"label","item-value":"value",label:"Provider",rules:[oe],density:"comfortable",variant:"outlined"},null,8,["modelValue","rules"])]),_:1}),e(K,{cols:"12",sm:"6"},{default:t(()=>[e(Ke,{modelValue:A.modelName,"onUpdate:modelValue":C[4]||(C[4]=Ve=>A.modelName=Ve),label:"Model Name (technisch)",placeholder:"z.B. claude-3-5-sonnet-20241022",rules:[oe],density:"comfortable",variant:"outlined"},null,8,["modelValue","rules"])]),_:1}),e(K,{cols:"12"},{default:t(()=>[e(Ke,{modelValue:A.displayName,"onUpdate:modelValue":C[5]||(C[5]=Ve=>A.displayName=Ve),label:"Display Name",placeholder:"z.B. Claude 3.5 Sonnet",rules:[oe],density:"comfortable",variant:"outlined"},null,8,["modelValue","rules"])]),_:1}),e(K,{cols:"12",sm:"6"},{default:t(()=>[e(Ke,{modelValue:A.inputPricePerMillionUSD,"onUpdate:modelValue":C[6]||(C[6]=Ve=>A.inputPricePerMillionUSD=Ve),modelModifiers:{number:!0},label:"Input / 1M USD",type:"number",step:"0.01",min:"0",rules:[pe],density:"comfortable",variant:"outlined",prefix:"$"},null,8,["modelValue","rules"])]),_:1}),e(K,{cols:"12",sm:"6"},{default:t(()=>[e(Ke,{modelValue:A.outputPricePerMillionUSD,"onUpdate:modelValue":C[7]||(C[7]=Ve=>A.outputPricePerMillionUSD=Ve),modelModifiers:{number:!0},label:"Output / 1M USD",type:"number",step:"0.01",min:"0",rules:[pe],density:"comfortable",variant:"outlined",prefix:"$"},null,8,["modelValue","rules"])]),_:1}),e(K,{cols:"12",sm:"6"},{default:t(()=>[e(Ke,{modelValue:A.cachedInputPricePerMillionUSD,"onUpdate:modelValue":C[8]||(C[8]=Ve=>A.cachedInputPricePerMillionUSD=Ve),modelModifiers:{number:!0},label:"Cached Input / 1M (optional)",type:"number",step:"0.01",min:"0",rules:[_e],density:"comfortable",variant:"outlined",prefix:"$",clearable:""},null,8,["modelValue","rules"])]),_:1}),e(K,{cols:"12",sm:"6"},{default:t(()=>[e(Ke,{modelValue:A.cacheWritePricePerMillionUSD,"onUpdate:modelValue":C[9]||(C[9]=Ve=>A.cacheWritePricePerMillionUSD=Ve),modelModifiers:{number:!0},label:"Cache Write / 1M (optional)",type:"number",step:"0.01",min:"0",rules:[_e],density:"comfortable",variant:"outlined",prefix:"$",clearable:""},null,8,["modelValue","rules"])]),_:1}),e(K,{cols:"12"},{default:t(()=>[e($e,{modelValue:A.isActive,"onUpdate:modelValue":C[10]||(C[10]=Ve=>A.isActive=Ve),label:"Aktiv (wird für Kostenberechnung verwendet)",density:"comfortable","hide-details":""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1}),e(lt,null,{default:t(()=>[e(X),e(ie,{variant:"text",onClick:C[12]||(C[12]=Ve=>G.value=!1)},{default:t(()=>[...C[38]||(C[38]=[n("Abbrechen",-1)])]),_:1}),e(ie,{color:"primary",variant:"tonal",loading:P(p),disabled:!F.value,onClick:Q},{default:t(()=>[...C[39]||(C[39]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(ut,{modelValue:te.value,"onUpdate:modelValue":C[15]||(C[15]=Ve=>te.value=Ve),"max-width":"480"},{default:t(()=>[e(Y,null,{default:t(()=>[e(Se,{class:"text-h6"},{default:t(()=>[...C[40]||(C[40]=[n("Token-Preis löschen",-1)])]),_:1}),e(Ce,null,{default:t(()=>[C[41]||(C[41]=n(" Soll der Token-Preis ",-1)),a("strong",null,v(de.value),1),C[42]||(C[42]=n(" wirklich gelöscht werden? Diese Aktion kann nicht rückgängig gemacht werden. ",-1))]),_:1}),e(lt,null,{default:t(()=>[e(X),e(ie,{variant:"text",onClick:C[14]||(C[14]=Ve=>te.value=!1)},{default:t(()=>[...C[43]||(C[43]=[n("Abbrechen",-1)])]),_:1}),e(ie,{color:"error",variant:"tonal",onClick:ce},{default:t(()=>[...C[44]||(C[44]=[n("Löschen",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1})}}}),T8=Me(D8,[["__scopeId","data-v-425beb21"]]),L8={class:"ki-settings-view"},E8={class:"d-flex align-center ga-2"},M8=Ae({__name:"KiSettingsView",setup(r){const $=qe("ki_settings_items_per_page",20),d=qe("ki_settings_open_panel",null),c=y4(),s=S4(),m=y([]),u=y(!1),f=y(null),p=y(!1),_=y(!1),k=y(!1),i=y(null),g=y(null),x=y(!1),w=y(null),b=y(null),I=wt({name:"",description:"",prompt:"",aspectRatio:"ASPECT_1_1",style:""});async function V(){u.value=!0,f.value=null;try{const[L,A]=await Promise.all([re.get("/ideogram-presets"),re.get("/ideogram-presets/status")]);if(L.success&&L.data){const z=L.data;m.value=Array.isArray(z)?z:z.items??[]}A.success&&A.data&&(_.value=A.data.configured)}catch{f.value="Netzwerkfehler beim Laden der Ideogram-Presets"}finally{u.value=!1}}function E(){i.value=null,Object.assign(I,{name:"",description:"",prompt:"",aspectRatio:"ASPECT_1_1",style:""}),k.value=!0}function R(L){i.value=L._id,Object.assign(I,{name:L.name,description:L.description||"",prompt:L.prompt,aspectRatio:L.aspectRatio,style:L.style||""}),k.value=!0}async function M(){p.value=!0;try{const L={...I};let A;i.value?A=await re.put(`/ideogram-presets/${i.value}`,L):A=await re.post("/ideogram-presets",L),A.success?(await V(),k.value=!1):f.value=A.error||"Fehler beim Speichern"}catch{f.value="Netzwerkfehler beim Speichern"}finally{p.value=!1}}async function T(L){try{const A=await re.put(`/ideogram-presets/${L._id}`,{isActive:!L.isActive});A.success?await V():f.value=A.error||"Fehler beim Aktualisieren"}catch{f.value="Netzwerkfehler"}}async function D(L){b.value=L._id;try{const A=await re.put(`/ideogram-presets/${L._id}/default`,{});A.success?await V():f.value=A.error||"Fehler beim Setzen des Standards"}catch{f.value="Netzwerkfehler"}finally{b.value=null}}function H(L){w.value=L._id,x.value=!0}async function O(){if(w.value){g.value=w.value,x.value=!1;try{const L=await re.delete(`/ideogram-presets/${w.value}`);L.success?await V():f.value=L.error||"Fehler beim Löschen"}catch{f.value="Netzwerkfehler beim Löschen"}finally{g.value=null,w.value=null}}}const S=Ut(),B=xt(),G=wt({show:!1,color:"success",message:"",timeout:6e3}),W={oauth_denied:{color:"warning",message:"LinkedIn-Berechtigung verweigert oder Login abgebrochen. Bitte erneut versuchen."},invalid_callback:{color:"error",message:"Ungültiger OAuth-Callback (code oder state fehlt)."},invalid_state:{color:"error",message:'OAuth-State ungültig oder abgelaufen. Bitte erneut „Mit LinkedIn verbinden" klicken.'},callback_failed:{color:"error",message:"OAuth-Callback fehlgeschlagen. Bitte Logs prüfen und erneut versuchen."}};function F(){const L=typeof S.query.success=="string"?S.query.success:null,A=typeof S.query.error=="string"?S.query.error:null;if(L==="connected")G.color="success",G.message="LinkedIn-Verbindung erfolgreich hergestellt.",G.show=!0;else if(A){const z=W[A]??{color:"error",message:`OAuth-Fehler: ${A}`};G.color=z.color,G.message=z.message,G.show=!0}if(L||A){const z={...S.query};delete z.success,delete z.error,B.replace({path:S.path,query:z,hash:S.hash})}}return rt(()=>{c.loadSettings(),s.loadPageConfig(),s.loadEmailConfig(),s.loadLinkedinConfig(),s.loadLeadResearchConfig(),s.loadCompanyScoringConfig(),s.loadOutreachConfig(),s.loadIntentConfig(),s.loadDirectMailConfig(),V(),F()}),La((L,A,z)=>{if((s.pageConfigDirty.value||s.emailConfigDirty.value||s.linkedinDirty.value||s.leadResearchDirty.value||s.companyScoringDirty.value||s.outreachDirty.value||s.intentDirty.value||s.directMailDirty.value)&&!window.confirm("Du hast ungespeicherte Änderungen. Wirklich verlassen?"))return z(!1);z()}),(L,A)=>{const z=l("v-alert"),j=l("v-icon"),J=l("v-expansion-panel-title"),Q=l("v-expansion-panel-text"),te=l("v-expansion-panel"),ve=l("v-chip"),de=l("v-expansion-panels"),Z=l("v-btn"),ce=l("v-snackbar");return o(),h("div",L8,[e(V4,{onCreate:P(c).openCreateDialog},null,8,["onCreate"]),P(c).error.value?(o(),N(z,{key:0,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":A[0]||(A[0]=oe=>P(c).error.value=null)},{default:t(()=>[n(v(P(c).error.value),1)]),_:1})):U("",!0),e(T8,{class:"mb-6"}),e(de,{modelValue:P(d),"onUpdate:modelValue":A[39]||(A[39]=oe=>ot(d)?d.value=oe:null),variant:"accordion",class:"mb-6 ki-settings-view__panels"},{default:t(()=>[e(te,null,{default:t(()=>[e(J,{class:"text-subtitle-1 font-weight-semibold"},{default:t(()=>[e(j,{class:"mr-2",size:"20"},{default:t(()=>[...A[48]||(A[48]=[n("mdi-robot-outline",-1)])]),_:1}),A[49]||(A[49]=n(" GPT-Konfigurationen ",-1))]),_:1}),e(Q,{class:"pa-0"},{default:t(()=>[e(M4,{settings:P(c).settings.value,onCreate:P(c).openCreateDialog},null,8,["settings","onCreate"]),e(O4,{items:P(c).settings.value,loading:P(c).loading.value,"items-per-page":P($),"deleting-id":P(c).deletingId.value,"setting-default-id":P(c).settingDefaultId.value,"get-provider-label":P(c).getProviderLabel,"get-provider-color":P(c).getProviderColor,"onUpdate:itemsPerPage":A[1]||(A[1]=oe=>$.value=oe),onRefresh:P(c).loadSettings,onEdit:P(c).openEditDialog,onToggleActive:P(c).toggleActive,onSetDefault:P(c).setDefault,onDelete:P(c).confirmDelete},null,8,["items","loading","items-per-page","deleting-id","setting-default-id","get-provider-label","get-provider-color","onRefresh","onEdit","onToggleActive","onSetDefault","onDelete"])]),_:1})]),_:1}),e(te,null,{default:t(()=>[e(J,{class:"text-subtitle-1 font-weight-semibold"},{default:t(()=>[e(j,{class:"mr-2",size:"20"},{default:t(()=>[...A[50]||(A[50]=[n("mdi-file-document-edit-outline",-1)])]),_:1}),A[51]||(A[51]=n(" Seiten-Konfiguration ",-1))]),_:1}),e(Q,null,{default:t(()=>[e(eC,{"page-config-loading":P(s).pageConfigLoading.value,"page-config-error":P(s).pageConfigError.value,"page-config-success":P(s).pageConfigSuccess.value,"page-config-saving":P(s).pageConfigSaving.value,"page-config-form":P(s).pageConfigForm,"knowledge-bases":P(s).knowledgeBases.value,"kb-loading":P(s).kbLoading.value,settings:P(c).settings.value,onClearError:A[2]||(A[2]=oe=>P(s).pageConfigError.value=null),onClearSuccess:A[3]||(A[3]=oe=>P(s).pageConfigSuccess.value=!1),onSave:P(s).savePageConfig},null,8,["page-config-loading","page-config-error","page-config-success","page-config-saving","page-config-form","knowledge-bases","kb-loading","settings","onSave"])]),_:1})]),_:1}),e(te,null,{default:t(()=>[e(J,{class:"text-subtitle-1 font-weight-semibold"},{default:t(()=>[e(j,{class:"mr-2",size:"20"},{default:t(()=>[...A[52]||(A[52]=[n("mdi-email-outline",-1)])]),_:1}),A[53]||(A[53]=n(" E-Mail-Konfiguration ",-1))]),_:1}),e(Q,null,{default:t(()=>[e(nC,{"email-config-loading":P(s).emailConfigLoading.value,"email-config-error":P(s).emailConfigError.value,"email-config-success":P(s).emailConfigSuccess.value,"email-config-saving":P(s).emailConfigSaving.value,"email-config-form":P(s).emailConfigForm,"knowledge-bases":P(s).knowledgeBases.value,"kb-loading":P(s).kbLoading.value,settings:P(c).settings.value,onClearError:A[4]||(A[4]=oe=>P(s).emailConfigError.value=null),onClearSuccess:A[5]||(A[5]=oe=>P(s).emailConfigSuccess.value=!1),onSave:P(s).saveEmailConfig},null,8,["email-config-loading","email-config-error","email-config-success","email-config-saving","email-config-form","knowledge-bases","kb-loading","settings","onSave"])]),_:1})]),_:1}),e(te,null,{default:t(()=>[e(J,{class:"text-subtitle-1 font-weight-semibold"},{default:t(()=>{var oe;return[e(j,{class:"mr-2",size:"20"},{default:t(()=>[...A[54]||(A[54]=[n("mdi-linkedin",-1)])]),_:1}),A[56]||(A[56]=n(" LinkedIn-Konfiguration ",-1)),(oe=P(s).linkedinConfig.value)!=null&&oe.isConnected?(o(),N(ve,{key:0,color:"success",size:"x-small",variant:"tonal",class:"ml-3"},{default:t(()=>[...A[55]||(A[55]=[n(" Verbunden ",-1)])]),_:1})):U("",!0)]}),_:1}),e(Q,null,{default:t(()=>[e(fC,{"linkedin-config":P(s).linkedinConfig.value,"linkedin-loading":P(s).linkedinLoading.value,"linkedin-error":P(s).linkedinError.value,"linkedin-success":P(s).linkedinSuccess.value,"linkedin-saving":P(s).linkedinSaving.value,"oauth-loading":P(s).oauthLoading.value,"linkedin-disconnecting":P(s).linkedinDisconnecting.value,"linkedin-form":P(s).linkedinForm,"knowledge-bases":P(s).knowledgeBases.value,"kb-loading":P(s).kbLoading.value,onClearError:A[6]||(A[6]=oe=>P(s).linkedinError.value=null),onClearSuccess:A[7]||(A[7]=oe=>P(s).linkedinSuccess.value=!1),onSave:P(s).saveLinkedinConfig,onOpenOAuth:P(s).openOAuth,onDisconnect:P(s).disconnectLinkedinAccount},null,8,["linkedin-config","linkedin-loading","linkedin-error","linkedin-success","linkedin-saving","oauth-loading","linkedin-disconnecting","linkedin-form","knowledge-bases","kb-loading","onSave","onOpenOAuth","onDisconnect"])]),_:1})]),_:1}),e(te,null,{default:t(()=>[e(J,{class:"text-subtitle-1 font-weight-semibold"},{default:t(()=>[e(j,{class:"mr-2",size:"20"},{default:t(()=>[...A[57]||(A[57]=[n("mdi-magnify-scan",-1)])]),_:1}),A[58]||(A[58]=n(" Lead-Research (KI-Extraktion für Outreach) ",-1))]),_:1}),e(Q,null,{default:t(()=>{var oe;return[e(_C,{loading:P(s).leadResearchLoading.value,error:P(s).leadResearchError.value,success:P(s).leadResearchSuccess.value,saving:P(s).leadResearchSaving.value,"prompt-form":P(s).leadResearchForm,"has-prompt":!!((oe=P(s).leadResearchPrompt.value)!=null&&oe._id),"sender-loading":P(s).senderLoading.value,"sender-error":P(s).senderError.value,"sender-success":P(s).senderSuccess.value,"sender-saving":P(s).senderSaving.value,"default-sender":P(s).defaultSender.value,settings:P(c).settings.value,onClearError:A[8]||(A[8]=pe=>P(s).leadResearchError.value=null),onClearSuccess:A[9]||(A[9]=pe=>P(s).leadResearchSuccess.value=!1),onSave:P(s).saveLeadResearchConfig,onClearSenderError:A[10]||(A[10]=pe=>P(s).senderError.value=null),onClearSenderSuccess:A[11]||(A[11]=pe=>P(s).senderSuccess.value=!1),onSaveSender:P(s).saveDefaultSender,onUpdateDefaultSender:A[12]||(A[12]=pe=>P(s).defaultSender.value=pe),"onUpdate:promptForm":A[13]||(A[13]=pe=>Object.assign(P(s).leadResearchForm,pe))},null,8,["loading","error","success","saving","prompt-form","has-prompt","sender-loading","sender-error","sender-success","sender-saving","default-sender","settings","onSave","onSaveSender"])]}),_:1})]),_:1}),e(te,{value:"company-scoring"},{default:t(()=>[e(J,{class:"text-subtitle-1 font-weight-semibold"},{default:t(()=>[e(j,{class:"mr-2",size:"20"},{default:t(()=>[...A[59]||(A[59]=[n("mdi-chart-bar",-1)])]),_:1}),A[60]||(A[60]=n(" Company-Scoring (KI-Multi-Faktor-Bewertung) ",-1))]),_:1}),e(Q,null,{default:t(()=>{var oe;return[e(SC,{loading:P(s).companyScoringLoading.value,error:P(s).companyScoringError.value,"prompt-success":P(s).companyScoringPromptSuccess.value,"prompt-saving":P(s).companyScoringPromptSaving.value,"prompt-form":P(s).companyScoringForm,"has-prompt":!!((oe=P(s).companyScoringPrompt.value)!=null&&oe._id),settings:P(c).settings.value,"scoring-weights":P(s).scoringWeights,"weights-sum":P(s).weightsSum.value,"weights-dirty":P(s).weightsDirty.value,"weights-saving":P(s).weightsSaving.value,"weights-error":P(s).weightsError.value,"weights-success":P(s).weightsSuccess.value,"auto-on-create":P(s).autoOnCreate.value,"auto-on-create-dirty":P(s).autoOnCreateDirty.value,"auto-on-create-saving":P(s).autoOnCreateSaving.value,"auto-on-create-error":P(s).autoOnCreateError.value,"auto-on-create-success":P(s).autoOnCreateSuccess.value,onClearError:A[14]||(A[14]=pe=>P(s).companyScoringError.value=null),onClearPromptSuccess:A[15]||(A[15]=pe=>P(s).companyScoringPromptSuccess.value=!1),onSavePrompt:P(s).saveCompanyScoringPrompt,onClearWeightsError:A[16]||(A[16]=pe=>P(s).weightsError.value=null),onClearWeightsSuccess:A[17]||(A[17]=pe=>P(s).weightsSuccess.value=!1),onSaveWeights:P(s).saveScoringWeights,onClearAutoOnCreateError:A[18]||(A[18]=pe=>P(s).autoOnCreateError.value=null),onClearAutoOnCreateSuccess:A[19]||(A[19]=pe=>P(s).autoOnCreateSuccess.value=!1),onSaveAutoOnCreate:P(s).saveAutoOnCreate,"onUpdate:promptForm":A[20]||(A[20]=pe=>Object.assign(P(s).companyScoringForm,pe)),"onUpdate:scoringWeights":A[21]||(A[21]=pe=>Object.assign(P(s).scoringWeights,pe)),"onUpdate:autoOnCreate":A[22]||(A[22]=pe=>P(s).autoOnCreate.value=pe)},null,8,["loading","error","prompt-success","prompt-saving","prompt-form","has-prompt","settings","scoring-weights","weights-sum","weights-dirty","weights-saving","weights-error","weights-success","auto-on-create","auto-on-create-dirty","auto-on-create-saving","auto-on-create-error","auto-on-create-success","onSavePrompt","onSaveWeights","onSaveAutoOnCreate"])]}),_:1})]),_:1}),e(te,null,{default:t(()=>[e(J,{class:"text-subtitle-1 font-weight-semibold"},{default:t(()=>[e(j,{class:"mr-2",size:"20"},{default:t(()=>[...A[61]||(A[61]=[n("mdi-bullhorn-outline",-1)])]),_:1}),A[62]||(A[62]=n(" Outreach-Strategie (KI-Talking-Points + Cold-Mail) ",-1))]),_:1}),e(Q,null,{default:t(()=>{var oe;return[e(AC,{loading:P(s).outreachLoading.value,error:P(s).outreachError.value,"prompt-success":P(s).outreachPromptSuccess.value,"prompt-saving":P(s).outreachPromptSaving.value,"prompt-form":P(s).outreachForm,"has-prompt":!!((oe=P(s).outreachPrompt.value)!=null&&oe._id),settings:P(c).settings.value,onClearError:A[23]||(A[23]=pe=>P(s).outreachError.value=null),onClearPromptSuccess:A[24]||(A[24]=pe=>P(s).outreachPromptSuccess.value=!1),onSavePrompt:P(s).saveOutreachPrompt,"onUpdate:promptForm":A[25]||(A[25]=pe=>Object.assign(P(s).outreachForm,pe))},null,8,["loading","error","prompt-success","prompt-saving","prompt-form","has-prompt","settings","onSavePrompt"])]}),_:1})]),_:1}),e(te,null,{default:t(()=>[e(J,{class:"text-subtitle-1 font-weight-semibold"},{default:t(()=>[e(j,{class:"mr-2",size:"20"},{default:t(()=>[...A[63]||(A[63]=[n("mdi-head-cog-outline",-1)])]),_:1}),A[64]||(A[64]=n(" Intent-Klassifikation (KI-Engagement-Status) ",-1))]),_:1}),e(Q,null,{default:t(()=>{var oe;return[e(TC,{loading:P(s).intentLoading.value,error:P(s).intentError.value,"prompt-success":P(s).intentPromptSuccess.value,"prompt-saving":P(s).intentPromptSaving.value,"prompt-form":P(s).intentForm,"has-prompt":!!((oe=P(s).intentPrompt.value)!=null&&oe._id),settings:P(c).settings.value,"auto-triggers":P(s).intentAutoTriggers,"auto-triggers-saving":P(s).intentAutoTriggersSaving.value,"auto-triggers-error":P(s).intentAutoTriggersError.value,"auto-triggers-success":P(s).intentAutoTriggersSuccess.value,onClearError:A[26]||(A[26]=pe=>P(s).intentError.value=null),onClearPromptSuccess:A[27]||(A[27]=pe=>P(s).intentPromptSuccess.value=!1),onSavePrompt:P(s).saveIntentPrompt,onClearAutoTriggersError:A[28]||(A[28]=pe=>P(s).intentAutoTriggersError.value=null),onClearAutoTriggersSuccess:A[29]||(A[29]=pe=>P(s).intentAutoTriggersSuccess.value=!1),onSaveAutoTriggers:P(s).saveIntentAutoTriggers,"onUpdate:promptForm":A[30]||(A[30]=pe=>Object.assign(P(s).intentForm,pe)),"onUpdate:autoTriggers":A[31]||(A[31]=pe=>Object.assign(P(s).intentAutoTriggers,pe))},null,8,["loading","error","prompt-success","prompt-saving","prompt-form","has-prompt","settings","auto-triggers","auto-triggers-saving","auto-triggers-error","auto-triggers-success","onSavePrompt","onSaveAutoTriggers"])]}),_:1})]),_:1}),e(te,null,{default:t(()=>[e(J,{class:"text-subtitle-1 font-weight-semibold"},{default:t(()=>[e(j,{class:"mr-2",size:"20"},{default:t(()=>[...A[65]||(A[65]=[n("mdi-send-outline",-1)])]),_:1}),A[66]||(A[66]=n(" Direkt-Outreach-Mail (KI-Composer + Undo-Fenster) ",-1))]),_:1}),e(Q,null,{default:t(()=>{var oe;return[e(NC,{loading:P(s).directMailLoading.value,error:P(s).directMailError.value,"prompt-success":P(s).directMailPromptSuccess.value,"prompt-saving":P(s).directMailPromptSaving.value,"prompt-form":P(s).directMailForm,"has-prompt":!!((oe=P(s).directMailPrompt.value)!=null&&oe._id),settings:P(c).settings.value,"undo-delay-sec":P(s).undoDelaySec.value,"undo-delay-sec-saving":P(s).undoDelaySecSaving.value,"undo-delay-sec-error":P(s).undoDelaySecError.value,"undo-delay-sec-success":P(s).undoDelaySecSuccess.value,onClearError:A[32]||(A[32]=pe=>P(s).directMailError.value=null),onClearPromptSuccess:A[33]||(A[33]=pe=>P(s).directMailPromptSuccess.value=!1),onSavePrompt:P(s).saveDirectMailPrompt,onClearUndoDelayError:A[34]||(A[34]=pe=>P(s).undoDelaySecError.value=null),onClearUndoDelaySuccess:A[35]||(A[35]=pe=>P(s).undoDelaySecSuccess.value=!1),onSaveUndoDelay:P(s).saveUndoDelaySec,"onUpdate:promptForm":A[36]||(A[36]=pe=>Object.assign(P(s).directMailForm,pe)),"onUpdate:undoDelaySec":A[37]||(A[37]=pe=>P(s).undoDelaySec.value=pe)},null,8,["loading","error","prompt-success","prompt-saving","prompt-form","has-prompt","settings","undo-delay-sec","undo-delay-sec-saving","undo-delay-sec-error","undo-delay-sec-success","onSavePrompt","onSaveUndoDelay"])]}),_:1})]),_:1}),e(te,null,{default:t(()=>[e(J,{class:"text-subtitle-1 font-weight-semibold"},{default:t(()=>[e(j,{class:"mr-2",size:"20"},{default:t(()=>[...A[67]||(A[67]=[n("mdi-image-auto-adjust",-1)])]),_:1}),A[68]||(A[68]=n(" Ideogram Bild-Generierung ",-1)),e(ve,{color:_.value?"success":"default",size:"x-small",variant:"tonal",class:"ml-3"},{default:t(()=>[n(v(_.value?"Konfiguriert":"Nicht konfiguriert"),1)]),_:1},8,["color"])]),_:1}),e(Q,null,{default:t(()=>[e(g8,{"ideogram-presets":m.value,"ideogram-loading":u.value,"ideogram-error":f.value,"ideogram-configured":_.value,"deleting-ideogram-preset-id":g.value,"setting-ideogram-default-id":b.value,"knowledge-bases":P(s).knowledgeBases.value,"kb-loading":P(s).kbLoading.value,settings:P(c).settings.value,onClearError:A[38]||(A[38]=oe=>f.value=null),onCreate:E,onEdit:R,onDelete:H,onToggleActive:T,onSetDefault:D,onPresetAdopted:V},null,8,["ideogram-presets","ideogram-loading","ideogram-error","ideogram-configured","deleting-ideogram-preset-id","setting-ideogram-default-id","knowledge-bases","kb-loading","settings"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(Z4,{modelValue:P(c).dialogOpen.value,"onUpdate:modelValue":A[40]||(A[40]=oe=>P(c).dialogOpen.value=oe),"editing-id":P(c).editingId.value,form:P(c).form,"form-valid":P(c).formValid.value,saving:P(c).saving.value,"save-error":P(c).saveError.value,"test-loading":P(c).testLoading.value,"test-result":P(c).testResult.value,"test-error":P(c).testError.value,"available-models":P(c).availableModels.value,"dialog-title":P(c).dialogTitle.value,"name-rules":P(c).nameRules,"provider-rules":P(c).providerRules,"model-rules":P(c).modelRules,"onUpdate:formValid":A[41]||(A[41]=oe=>P(c).formValid.value=oe),onSave:P(c).saveSettings,onTest:P(c).testSetting,onClearSaveError:A[42]||(A[42]=oe=>P(c).saveError.value=null)},null,8,["modelValue","editing-id","form","form-valid","saving","save-error","test-loading","test-result","test-error","available-models","dialog-title","name-rules","provider-rules","model-rules","onSave","onTest"]),e(k8,{modelValue:k.value,"onUpdate:modelValue":A[43]||(A[43]=oe=>k.value=oe),"editing-ideogram-preset":i.value,"ideogram-saving":p.value,"ideogram-form":I,onSave:M},null,8,["modelValue","editing-ideogram-preset","ideogram-saving","ideogram-form"]),e(h8,{modelValue:x.value,"onUpdate:modelValue":A[44]||(A[44]=oe=>x.value=oe),onConfirm:O},null,8,["modelValue"]),e(J4,{modelValue:P(c).deleteDialogOpen.value,"onUpdate:modelValue":A[45]||(A[45]=oe=>P(c).deleteDialogOpen.value=oe),onConfirm:P(c).executeDelete},null,8,["modelValue","onConfirm"]),e(ce,{modelValue:G.show,"onUpdate:modelValue":A[47]||(A[47]=oe=>G.show=oe),color:G.color,timeout:G.timeout,location:"top"},{actions:t(()=>[e(Z,{variant:"text",onClick:A[46]||(A[46]=oe=>G.show=!1)},{default:t(()=>[...A[69]||(A[69]=[n("Schließen",-1)])]),_:1})]),default:t(()=>[a("div",E8,[e(j,{icon:G.color==="success"?"mdi-check-circle":"mdi-alert-circle"},null,8,["icon"]),a("span",null,v(G.message),1)])]),_:1},8,["modelValue","color","timeout"])])}}}),N8=Me(M8,[["__scopeId","data-v-d81d1a70"]]),L6=Object.freeze(Object.defineProperty({__proto__:null,default:N8},Symbol.toStringTag,{value:"Module"})),U8={class:"d-flex ga-2 mb-6"},B8={key:1,class:"d-flex justify-center py-16"},F8={class:"seo-metric-card__value"},O8={class:"seo-metric-card__value"},R8={class:"seo-metric-card__value"},K8={class:"seo-metric-card__value"},j8={class:"seo-chart-wrapper"},q8=["viewBox"],G8=["x1","x2","y1","y2"],H8=["points"],W8=["points"],Z8=["x","y"],J8={class:"text-caption font-weight-medium"},Va=800,Aa=200,Q8=Ae({__name:"SeoOverview",setup(r){Ut();const $=y(!1),d=y(null),c=y(!1),s=y(null),m=qe("seo_queries_per_page",10),u=qe("seo_pages_per_page",10),f=qe("seo_overview_queries_sort",[]),p=qe("seo_overview_pages_sort",[]),_={top:16,right:48,bottom:32,left:48},k=[{title:"Suchanfrage",key:"query",sortable:!0},{title:"Klicks",key:"clicks",sortable:!0},{title:"Impressionen",key:"impressions",sortable:!0},{title:"CTR",key:"ctr",sortable:!0},{title:"Ø Position",key:"position",sortable:!0}],i=[{title:"Seite",key:"page",sortable:!0},{title:"Klicks",key:"clicks",sortable:!0},{title:"Impressionen",key:"impressions",sortable:!0},{title:"CTR",key:"ctr",sortable:!0},{title:"Ø Position",key:"position",sortable:!0}],g=Va-_.left-_.right,x=Aa-_.top-_.bottom;function w(D,H,O){return!D||D.length===0?"":D.map((S,B)=>{const G=_.left+B/(D.length-1)*g,W=Number(S[H])||0,F=_.top+x-W/O*x;return`${G},${F}`}).join(" ")}const b=se(()=>{var O;const D=((O=s.value)==null?void 0:O.dailyData)??[],H=Math.max(...D.map(S=>S.clicks),1);return w(D,"clicks",H)}),I=se(()=>{var O;const D=((O=s.value)==null?void 0:O.dailyData)??[],H=Math.max(...D.map(S=>S.impressions),1);return w(D,"impressions",H)}),V=se(()=>{var O;const D=((O=s.value)==null?void 0:O.dailyData)??[];if(D.length===0)return[];const H=Math.max(1,Math.floor(D.length/6));return D.filter((S,B)=>B%H===0||B===D.length-1).map((S,B,G)=>{const W=D.indexOf(S),F=_.left+W/(D.length-1)*g;return{label:S.date.slice(5),x:F}})});function E(D){return(D*100).toFixed(1)+"%"}function R(D){return D.toFixed(1)}function M(D){try{return new URL(D).pathname||D}catch{return D}}async function T(){var O;$.value=!0,d.value=null;const D=await re.get("/seo/gsc/status");if(!D.success){d.value="Fehler beim Prüfen der GSC-Konfiguration.",ue.error("ADMIN","GSC status check failed",{error:D.error}),$.value=!1;return}if(c.value=((O=D.data)==null?void 0:O.configured)??!1,!c.value){$.value=!1;return}const H=await re.get("/seo/gsc/dashboard");H.success?s.value=H.data??null:(d.value="Fehler beim Laden der GSC-Daten.",ue.error("ADMIN","GSC dashboard load failed",{error:H.error})),$.value=!1}return rt(()=>T()),(D,H)=>{const O=l("v-btn"),S=l("v-alert"),B=l("v-progress-circular"),G=l("v-card-text"),W=l("v-card"),F=l("v-col"),L=l("v-row"),A=l("v-card-title"),z=l("v-divider"),j=l("v-data-table"),J=l("v-container");return o(),N(J,{fluid:"",class:"pa-6"},{default:t(()=>[H[18]||(H[18]=a("h1",{class:"text-h4 font-weight-bold mb-4"},"SEO",-1)),a("div",U8,[e(O,{variant:D.$route.name==="admin-seo"?"tonal":"text",to:{name:"admin-seo"},size:"small",color:"primary"},{default:t(()=>[...H[5]||(H[5]=[n("Dashboard",-1)])]),_:1},8,["variant"]),e(O,{variant:D.$route.name==="admin-seo-rank-tracker"?"tonal":"text",to:{name:"admin-seo-rank-tracker"},size:"small",color:"primary"},{default:t(()=>[...H[6]||(H[6]=[n("Rank Tracker",-1)])]),_:1},8,["variant"]),e(O,{variant:D.$route.name==="admin-seo-keyword-discovery"?"tonal":"text",to:{name:"admin-seo-keyword-discovery"},size:"small",color:"primary"},{default:t(()=>[...H[7]||(H[7]=[n("Keyword Discovery",-1)])]),_:1},8,["variant"]),e(O,{variant:D.$route.name==="admin-seo-todos"?"tonal":"text",to:{name:"admin-seo-todos"},size:"small",color:"primary"},{default:t(()=>[...H[8]||(H[8]=[n("SEO Todos",-1)])]),_:1},8,["variant"])]),d.value?(o(),N(S,{key:0,type:"error",variant:"tonal",class:"mb-4",text:d.value,closable:"","onClick:close":H[0]||(H[0]=Q=>d.value=null)},null,8,["text"])):U("",!0),$.value?(o(),h("div",B8,[e(B,{indeterminate:"",color:"primary",size:"48"})])):(o(),h(be,{key:2},[c.value?s.value?(o(),h(be,{key:1},[e(L,{class:"mb-6"},{default:t(()=>[e(F,{cols:"12",sm:"6",md:"3"},{default:t(()=>[e(W,{rounded:"lg",class:"seo-metric-card"},{default:t(()=>[e(G,{class:"pa-5"},{default:t(()=>[a("div",F8,v(s.value.summary.clicks.toLocaleString("de-DE")),1),H[10]||(H[10]=a("div",{class:"seo-metric-card__label"},"Klicks (28 Tage)",-1))]),_:1})]),_:1})]),_:1}),e(F,{cols:"12",sm:"6",md:"3"},{default:t(()=>[e(W,{rounded:"lg",class:"seo-metric-card"},{default:t(()=>[e(G,{class:"pa-5"},{default:t(()=>[a("div",O8,v(s.value.summary.impressions.toLocaleString("de-DE")),1),H[11]||(H[11]=a("div",{class:"seo-metric-card__label"},"Impressionen (28 Tage)",-1))]),_:1})]),_:1})]),_:1}),e(F,{cols:"12",sm:"6",md:"3"},{default:t(()=>[e(W,{rounded:"lg",class:"seo-metric-card"},{default:t(()=>[e(G,{class:"pa-5"},{default:t(()=>[a("div",R8,v(E(s.value.summary.ctr)),1),H[12]||(H[12]=a("div",{class:"seo-metric-card__label"},"Ø CTR",-1))]),_:1})]),_:1})]),_:1}),e(F,{cols:"12",sm:"6",md:"3"},{default:t(()=>[e(W,{rounded:"lg",class:"seo-metric-card"},{default:t(()=>[e(G,{class:"pa-5"},{default:t(()=>[a("div",K8,v(R(s.value.summary.position)),1),H[13]||(H[13]=a("div",{class:"seo-metric-card__label"},"Ø Position",-1))]),_:1})]),_:1})]),_:1})]),_:1}),e(W,{rounded:"lg",class:"mb-6"},{default:t(()=>[e(A,{class:"text-body-1 font-weight-semibold pa-4 pb-2"},{default:t(()=>[...H[14]||(H[14]=[n("Performance (28 Tage)",-1)])]),_:1}),e(z),e(G,{class:"pa-4"},{default:t(()=>[H[15]||(H[15]=a("div",{class:"seo-chart-legend d-flex ga-4 mb-2"},[a("div",{class:"d-flex align-center ga-1"},[a("span",{class:"seo-chart-legend__dot",style:{background:"#0AC9D4"}}),a("span",{class:"text-caption"},"Klicks")]),a("div",{class:"d-flex align-center ga-1"},[a("span",{class:"seo-chart-legend__dot",style:{background:"#C9A063",opacity:"0.7"}}),a("span",{class:"text-caption"},"Impressionen")])],-1)),a("div",j8,[(o(),h("svg",{viewBox:`0 0 ${Va} ${Aa}`,class:"seo-chart",preserveAspectRatio:"xMidYMid meet"},[(o(),h(be,null,Pe(4,Q=>a("line",{key:Q,x1:_.left,x2:Va-_.right,y1:_.top+x/4*(Q-1),y2:_.top+x/4*(Q-1),stroke:"rgba(255,255,255,0.06)","stroke-width":"1"},null,8,G8)),64)),I.value?(o(),h("polyline",{key:0,points:I.value,fill:"none",stroke:"#C9A063","stroke-width":"2",opacity:"0.5"},null,8,H8)):U("",!0),b.value?(o(),h("polyline",{key:1,points:b.value,fill:"none",stroke:"#0AC9D4","stroke-width":"2"},null,8,W8)):U("",!0),(o(!0),h(be,null,Pe(V.value,Q=>(o(),h("text",{key:Q.label,x:Q.x,y:Aa-4,"text-anchor":"middle","font-size":"10",fill:"rgba(255,255,255,0.4)"},v(Q.label),9,Z8))),128))],8,q8))])]),_:1})]),_:1}),e(W,{rounded:"lg",class:"mb-6"},{default:t(()=>[e(A,{class:"text-body-1 font-weight-semibold pa-4 pb-2"},{default:t(()=>[...H[16]||(H[16]=[n("Top Suchanfragen",-1)])]),_:1}),e(z),e(j,{"items-per-page":P(m),"onUpdate:itemsPerPage":H[1]||(H[1]=Q=>ot(m)?m.value=Q:null),headers:k,items:s.value.topQueries,density:"compact","sort-by":P(f),"onUpdate:sortBy":H[2]||(H[2]=Q=>f.value=Q)},{"item.ctr":t(({item:Q})=>[n(v(E(Q.ctr)),1)]),"item.position":t(({item:Q})=>[n(v(R(Q.position)),1)]),_:1},8,["items-per-page","items","sort-by"])]),_:1}),e(W,{rounded:"lg"},{default:t(()=>[e(A,{class:"text-body-1 font-weight-semibold pa-4 pb-2"},{default:t(()=>[...H[17]||(H[17]=[n("Top Seiten",-1)])]),_:1}),e(z),e(j,{"items-per-page":P(u),"onUpdate:itemsPerPage":H[3]||(H[3]=Q=>ot(u)?u.value=Q:null),headers:i,items:s.value.topPages,density:"compact","sort-by":P(p),"onUpdate:sortBy":H[4]||(H[4]=Q=>p.value=Q)},{"item.page":t(({item:Q})=>[a("span",J8,v(M(Q.page)),1)]),"item.ctr":t(({item:Q})=>[n(v(E(Q.ctr)),1)]),"item.position":t(({item:Q})=>[n(v(R(Q.position)),1)]),_:1},8,["items-per-page","items","sort-by"])]),_:1})],64)):U("",!0):(o(),N(S,{key:0,type:"info",variant:"tonal",class:"mb-6",title:"Google Search Console nicht verbunden"},{text:t(()=>[...H[9]||(H[9]=[a("p",{class:"mb-2"},"Um SEO-Daten zu sehen, muss die Google Search Console verbunden werden.",-1),a("ol",{class:"pl-4"},[a("li",null,[n("Google Search Console-Konto einrichten unter "),a("strong",null,"search.google.com/search-console")]),a("li",null,"Service-Account-Schlüssel in den KI-Einstellungen hinterlegen"),a("li",null,"Service-Account als Nutzer in der GSC-Property berechtigen")],-1)])]),_:1}))],64))]),_:1})}}}),Y8=Me(Q8,[["__scopeId","data-v-a23a4560"]]),E6=Object.freeze(Object.defineProperty({__proto__:null,default:Y8},Symbol.toStringTag,{value:"Module"})),X8={class:"d-flex ga-2 mb-6"},e3={key:1,class:"d-flex justify-center py-16"},t3={class:"seo-metric-card__value"},a3={class:"seo-metric-card__value seo-metric-card__value--success"},l3={class:"seo-metric-card__value seo-metric-card__value--error"},n3={class:"seo-metric-card__value"},o3={class:"d-flex ga-3 mb-4 flex-wrap align-center"},s3={class:"font-weight-medium"},i3={class:"d-flex align-center ga-1"},r3={class:"d-flex ga-1 flex-wrap"},d3={key:0,class:"d-flex justify-center py-8"},u3={class:"text-caption text-medium-emphasis"},c3={key:0,class:"d-flex justify-center py-8"},m3={class:"seo-history-chart-wrapper mb-4"},v3=["viewBox"],p3=["points"],ll=600,nl=160,f3=Ae({__name:"SeoRankTracker",setup(r){Ut();const $=y(!1),d=y(null),c=y([]),s=y({total:0,improved:0,declined:0,avgPosition:0}),m=y(""),u=qe("seo_rank_keywords_per_page",25),f=qe("seo_rank_candidates_per_page",15),p=qe("seo_rank_history_per_page",10),_=qe("seo_rank_keywords_sort",[]),k=qe("seo_rank_candidates_sort",[]),i=qe("seo_rank_history_sort",[]),g=y(!1),x=y(""),w=y(""),b=y([]),I=y(!1),V=y(null),E=y(!1),R=y([]),M=y([]),T=y(!1),D=y(!1),H=y(null),O=y([]),S=y(!1),B=y(!1),G=[{title:"Keyword",key:"keyword",sortable:!0},{title:"Position",key:"position",sortable:!0},{title:"Klicks",key:"clicks",sortable:!0},{title:"Impressionen",key:"impressions",sortable:!0},{title:"CTR",key:"ctr",sortable:!0},{title:"Trend",key:"trend",sortable:!0},{title:"Tags",key:"tags",sortable:!1},{title:"",key:"actions",sortable:!1,width:"80px"}],W=[{title:"Datum",key:"date",sortable:!0},{title:"Position",key:"position",sortable:!0},{title:"Klicks",key:"clicks",sortable:!0},{title:"Impressionen",key:"impressions",sortable:!0}],F=[{title:"",key:"select",sortable:!1,width:"48px"},{title:"Keyword",key:"keyword",sortable:!0},{title:"Klicks",key:"clicks",sortable:!0},{title:"Impressionen",key:"impressions",sortable:!0},{title:"Ø Position",key:"position",sortable:!0}],L=se(()=>{if(!m.value.trim())return c.value;const ae=m.value.toLowerCase();return c.value.filter(X=>X.keyword.toLowerCase().includes(ae))}),A={top:16,right:24,bottom:28,left:32};function z(){const ae=O.value.filter(me=>me.position!==null);if(ae.length<2)return"";const X=ll-A.left-A.right,ie=nl-A.top-A.bottom,fe=ae.map(me=>me.position),Se=Math.max(...fe,1);return ae.map((me,ee)=>{const Y=A.left+ee/(ae.length-1)*X,K=A.top+me.position/Se*ie;return`${Y},${K}`}).join(" ")}function j(ae){return(ae*100).toFixed(1)+"%"}function J(ae){return ae===null?"-":ae.toFixed(1)}function Q(ae){return ae===null||ae===0?"mdi-minus":ae<0?"mdi-arrow-up":"mdi-arrow-down"}function te(ae){return ae===null||ae===0?"0":Math.abs(ae).toString()}function ve(ae){return ae!==null&&ae<0}async function de(){var ie,fe,Se;$.value=!0,d.value=null;const[ae,X]=await Promise.all([re.get("/seo/keywords/rankings"),re.get("/seo/keywords/summary")]);ae.success?c.value=((ie=ae.data)==null?void 0:ie.keywords)??[]:(d.value="Fehler beim Laden der Keywords.",ue.error("ADMIN","Keyword rankings load failed",{error:ae.error})),X.success&&X.data&&(s.value={total:X.data.activeKeywords,improved:((fe=X.data.trends)==null?void 0:fe.improved)??0,declined:((Se=X.data.trends)==null?void 0:Se.declined)??0,avgPosition:X.data.avgPosition}),$.value=!1}async function Z(){if(!x.value.trim())return;I.value=!0,V.value=null;const ae=await re.post("/seo/keywords",{keyword:x.value.trim(),targetUrl:w.value.trim()||void 0,tags:b.value});ae.success?(g.value=!1,x.value="",w.value="",b.value=[],await de()):(V.value=ae.error||"Fehler beim Hinzufügen des Keywords.",ue.error("ADMIN","Keyword add failed",{error:ae.error})),I.value=!1}async function ce(ae){const X=await re.delete(`/seo/keywords/${ae}`);X.success?await de():(d.value="Fehler beim Löschen des Keywords.",ue.error("ADMIN","Keyword delete failed",{id:ae,error:X.error}))}async function oe(){var X;E.value=!0,T.value=!0,M.value=[];const ae=await re.get("/seo/keywords/gsc-candidates");ae.success?R.value=((X=ae.data)==null?void 0:X.candidates)??[]:(R.value=[],ue.error("ADMIN","GSC candidates load failed",{error:ae.error})),T.value=!1}async function pe(){if(M.value.length===0)return;T.value=!0;const ae=await re.post("/seo/keywords/import",{keywords:M.value});ae.success?(E.value=!1,await de(),ue.info("ADMIN","GSC keywords imported",{count:M.value.length})):(d.value="Fehler beim Importieren der Keywords.",ue.error("ADMIN","GSC import failed",{error:ae.error})),T.value=!1}async function _e(){B.value=!0;const ae=await re.post("/seo/keywords/check");ae.success?await de():(d.value="Fehler beim Aktualisieren der Rankings.",ue.error("ADMIN","Rankings check failed",{error:ae.error})),B.value=!1}async function q(ae){var ie;H.value=ae,D.value=!0,S.value=!0,O.value=[];const X=await re.get(`/seo/keywords/${ae._id}/history`);X.success?O.value=((ie=X.data)==null?void 0:ie.history)??[]:ue.error("ADMIN","Keyword history load failed",{id:ae._id,error:X.error}),S.value=!1}function C(ae,X){q(X.item)}return rt(()=>de()),(ae,X)=>{const ie=l("v-btn"),fe=l("v-alert"),Se=l("v-progress-circular"),me=l("v-card-text"),ee=l("v-card"),Y=l("v-col"),K=l("v-row"),le=l("v-text-field"),ne=l("v-spacer"),Ce=l("v-tooltip"),ke=l("v-icon"),xe=l("v-chip"),Ne=l("v-data-table"),Ie=l("v-card-title"),Ue=l("v-divider"),Te=l("v-combobox"),ye=l("v-card-actions"),Je=l("v-dialog"),Ke=l("v-checkbox"),$e=l("v-container");return o(),N($e,{fluid:"",class:"pa-6"},{default:t(()=>[X[42]||(X[42]=a("h1",{class:"text-h4 font-weight-bold mb-4"},"SEO",-1)),a("div",X8,[e(ie,{variant:ae.$route.name==="admin-seo"?"tonal":"text",to:{name:"admin-seo"},size:"small",color:"primary"},{default:t(()=>[...X[19]||(X[19]=[n("Dashboard",-1)])]),_:1},8,["variant"]),e(ie,{variant:ae.$route.name==="admin-seo-rank-tracker"?"tonal":"text",to:{name:"admin-seo-rank-tracker"},size:"small",color:"primary"},{default:t(()=>[...X[20]||(X[20]=[n("Rank Tracker",-1)])]),_:1},8,["variant"]),e(ie,{variant:ae.$route.name==="admin-seo-keyword-discovery"?"tonal":"text",to:{name:"admin-seo-keyword-discovery"},size:"small",color:"primary"},{default:t(()=>[...X[21]||(X[21]=[n("Keyword Discovery",-1)])]),_:1},8,["variant"]),e(ie,{variant:ae.$route.name==="admin-seo-todos"?"tonal":"text",to:{name:"admin-seo-todos"},size:"small",color:"primary"},{default:t(()=>[...X[22]||(X[22]=[n("SEO Todos",-1)])]),_:1},8,["variant"])]),d.value?(o(),N(fe,{key:0,type:"error",variant:"tonal",class:"mb-4",text:d.value,closable:"","onClick:close":X[0]||(X[0]=Ee=>d.value=null)},null,8,["text"])):U("",!0),$.value?(o(),h("div",e3,[e(Se,{indeterminate:"",color:"primary",size:"48"})])):(o(),h(be,{key:2},[e(K,{class:"mb-6"},{default:t(()=>[e(Y,{cols:"12",sm:"6",md:"3"},{default:t(()=>[e(ee,{rounded:"lg",class:"seo-metric-card"},{default:t(()=>[e(me,{class:"pa-5"},{default:t(()=>[a("div",t3,v(s.value.total),1),X[23]||(X[23]=a("div",{class:"seo-metric-card__label"},"Aktive Keywords",-1))]),_:1})]),_:1})]),_:1}),e(Y,{cols:"12",sm:"6",md:"3"},{default:t(()=>[e(ee,{rounded:"lg",class:"seo-metric-card"},{default:t(()=>[e(me,{class:"pa-5"},{default:t(()=>[a("div",a3,v(s.value.improved),1),X[24]||(X[24]=a("div",{class:"seo-metric-card__label"},"Verbessert",-1))]),_:1})]),_:1})]),_:1}),e(Y,{cols:"12",sm:"6",md:"3"},{default:t(()=>[e(ee,{rounded:"lg",class:"seo-metric-card"},{default:t(()=>[e(me,{class:"pa-5"},{default:t(()=>[a("div",l3,v(s.value.declined),1),X[25]||(X[25]=a("div",{class:"seo-metric-card__label"},"Verschlechtert",-1))]),_:1})]),_:1})]),_:1}),e(Y,{cols:"12",sm:"6",md:"3"},{default:t(()=>[e(ee,{rounded:"lg",class:"seo-metric-card"},{default:t(()=>[e(me,{class:"pa-5"},{default:t(()=>[a("div",n3,v(s.value.avgPosition>0?s.value.avgPosition.toFixed(1):"-"),1),X[26]||(X[26]=a("div",{class:"seo-metric-card__label"},"Ø Position",-1))]),_:1})]),_:1})]),_:1})]),_:1}),a("div",o3,[e(le,{modelValue:m.value,"onUpdate:modelValue":X[1]||(X[1]=Ee=>m.value=Ee),placeholder:"Keyword suchen...",variant:"outlined",density:"compact","prepend-inner-icon":"mdi-magnify","hide-details":"",style:{"max-width":"300px"}},null,8,["modelValue"]),e(ne),e(ie,{color:"primary",variant:"tonal","prepend-icon":"mdi-plus",onClick:X[2]||(X[2]=Ee=>g.value=!0)},{default:t(()=>[...X[27]||(X[27]=[n(" Keyword ",-1)])]),_:1}),e(ie,{variant:"outlined","prepend-icon":"mdi-google",onClick:oe},{default:t(()=>[...X[28]||(X[28]=[n(" GSC Import ",-1)])]),_:1}),e(ie,{variant:"outlined",loading:B.value,icon:"mdi-refresh","aria-label":"Rankings prüfen",onClick:_e},{default:t(()=>[e(Ce,{activator:"parent",location:"bottom"},{default:t(()=>[...X[29]||(X[29]=[n("Rankings prüfen",-1)])]),_:1})]),_:1},8,["loading"])]),e(ee,{rounded:"lg"},{default:t(()=>[e(Ne,{"items-per-page":P(u),"onUpdate:itemsPerPage":X[3]||(X[3]=Ee=>ot(u)?u.value=Ee:null),headers:G,items:L.value,density:"comfortable",hover:"","sort-by":P(_),"onUpdate:sortBy":X[4]||(X[4]=Ee=>_.value=Ee),"onClick:row":C},{"item.position":t(({item:Ee})=>[a("span",s3,v(J(Ee.position)),1)]),"item.ctr":t(({item:Ee})=>[n(v(j(Ee.ctr)),1)]),"item.trend":t(({item:Ee})=>[a("div",i3,[e(ke,{size:"16",color:ve(Ee.trend)?"success":Ee.trend!==null&&Ee.trend>0?"error":"grey"},{default:t(()=>[n(v(Q(Ee.trend)),1)]),_:2},1032,["color"]),a("span",{class:ft(["text-caption font-weight-medium",ve(Ee.trend)?"text-success":Ee.trend!==null&&Ee.trend>0?"text-error":"text-disabled"])},v(te(Ee.trend)),3)])]),"item.tags":t(({item:Ee})=>[a("div",r3,[(o(!0),h(be,null,Pe(Ee.tags,lt=>(o(),N(xe,{key:lt,size:"x-small",variant:"outlined"},{default:t(()=>[n(v(lt),1)]),_:2},1024))),128))])]),"item.actions":t(({item:Ee})=>[e(ie,{icon:"",size:"small",variant:"text",color:"error","aria-label":"Keyword löschen",onClick:dt(lt=>ce(Ee._id),["stop"])},{default:t(()=>[e(Ce,{activator:"parent",location:"bottom"},{default:t(()=>[...X[30]||(X[30]=[n("Keyword löschen",-1)])]),_:1}),e(ke,{size:"16"},{default:t(()=>[...X[31]||(X[31]=[n("mdi-delete-outline",-1)])]),_:1})]),_:1},8,["onClick"])]),"no-data":t(()=>[...X[32]||(X[32]=[a("div",{class:"text-center pa-8 text-medium-emphasis"}," Noch keine Keywords hinzugefügt. ",-1)])]),_:1},8,["items-per-page","items","sort-by"])]),_:1})],64)),e(Je,{modelValue:g.value,"onUpdate:modelValue":X[9]||(X[9]=Ee=>g.value=Ee),"max-width":"480"},{default:t(()=>[e(ee,{rounded:"lg"},{default:t(()=>[e(Ie,{class:"text-body-1 font-weight-semibold pa-6 pb-2"},{default:t(()=>[...X[33]||(X[33]=[n("Keyword hinzufügen",-1)])]),_:1}),e(Ue),e(me,{class:"pa-6"},{default:t(()=>[V.value?(o(),N(fe,{key:0,type:"error",variant:"tonal",class:"mb-4",text:V.value},null,8,["text"])):U("",!0),e(le,{modelValue:x.value,"onUpdate:modelValue":X[5]||(X[5]=Ee=>x.value=Ee),label:"Keyword *",variant:"outlined",class:"mb-4","hide-details":"auto",placeholder:"z. B. NIS2 Beratung"},null,8,["modelValue"]),e(le,{modelValue:w.value,"onUpdate:modelValue":X[6]||(X[6]=Ee=>w.value=Ee),label:"Ziel-URL",variant:"outlined",class:"mb-4","hide-details":"auto",placeholder:"https://basec.de/nis2","prepend-inner-icon":"mdi-link"},null,8,["modelValue"]),e(Te,{modelValue:b.value,"onUpdate:modelValue":X[7]||(X[7]=Ee=>b.value=Ee),label:"Tags",variant:"outlined",multiple:"",chips:"","closable-chips":"","hide-details":"auto"},null,8,["modelValue"])]),_:1}),e(ye,{class:"pa-6 pt-0"},{default:t(()=>[e(ne),e(ie,{variant:"text",disabled:I.value,onClick:X[8]||(X[8]=Ee=>g.value=!1)},{default:t(()=>[...X[34]||(X[34]=[n("Abbrechen",-1)])]),_:1},8,["disabled"]),e(ie,{color:"primary",variant:"flat",loading:I.value,disabled:!x.value.trim(),onClick:Z},{default:t(()=>[...X[35]||(X[35]=[n(" Hinzufügen ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(Je,{modelValue:E.value,"onUpdate:modelValue":X[14]||(X[14]=Ee=>E.value=Ee),"max-width":"700"},{default:t(()=>[e(ee,{rounded:"lg"},{default:t(()=>[e(Ie,{class:"text-body-1 font-weight-semibold pa-6 pb-2"},{default:t(()=>[...X[36]||(X[36]=[n("Keywords aus GSC importieren",-1)])]),_:1}),e(Ue),e(me,{class:"pa-4"},{default:t(()=>[T.value?(o(),h("div",d3,[e(Se,{indeterminate:"",color:"primary"})])):(o(),N(Ne,{key:1,"items-per-page":P(f),"onUpdate:itemsPerPage":X[11]||(X[11]=Ee=>ot(f)?f.value=Ee:null),headers:F,items:R.value,density:"compact","sort-by":P(k),"onUpdate:sortBy":X[12]||(X[12]=Ee=>k.value=Ee)},{"item.select":t(({item:Ee})=>[e(Ke,{modelValue:M.value,"onUpdate:modelValue":X[10]||(X[10]=lt=>M.value=lt),value:Ee.keyword,"hide-details":"",density:"compact"},null,8,["modelValue","value"])]),"item.position":t(({item:Ee})=>[n(v(J(Ee.position)),1)]),"no-data":t(()=>[...X[37]||(X[37]=[a("div",{class:"text-center pa-6 text-medium-emphasis"},"Keine Import-Kandidaten gefunden.",-1)])]),_:1},8,["items-per-page","items","sort-by"]))]),_:1}),e(ye,{class:"pa-6 pt-0"},{default:t(()=>[a("span",u3,v(M.value.length)+" ausgewählt",1),e(ne),e(ie,{variant:"text",disabled:T.value,onClick:X[13]||(X[13]=Ee=>E.value=!1)},{default:t(()=>[...X[38]||(X[38]=[n("Abbrechen",-1)])]),_:1},8,["disabled"]),e(ie,{color:"primary",variant:"flat",loading:T.value,disabled:M.value.length===0,onClick:pe},{default:t(()=>[...X[39]||(X[39]=[n(" Importieren ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(Je,{modelValue:D.value,"onUpdate:modelValue":X[18]||(X[18]=Ee=>D.value=Ee),"max-width":"700"},{default:t(()=>[e(ee,{rounded:"lg"},{default:t(()=>[e(Ie,{class:"text-body-1 font-weight-semibold pa-6 pb-2"},{default:t(()=>{var Ee;return[n(" Ranking-Verlauf: "+v((Ee=H.value)==null?void 0:Ee.keyword),1)]}),_:1}),e(Ue),e(me,{class:"pa-4"},{default:t(()=>[S.value?(o(),h("div",c3,[e(Se,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:1},[a("div",m3,[(o(),h("svg",{viewBox:`0 0 ${ll} ${nl}`,class:"seo-history-chart",preserveAspectRatio:"xMidYMid meet"},[z()?(o(),h("polyline",{key:0,points:z(),fill:"none",stroke:"#0AC9D4","stroke-width":"2"},null,8,p3)):U("",!0)],8,v3))]),e(Ne,{"items-per-page":P(p),"onUpdate:itemsPerPage":X[15]||(X[15]=Ee=>ot(p)?p.value=Ee:null),headers:W,items:O.value,density:"compact","sort-by":P(i),"onUpdate:sortBy":X[16]||(X[16]=Ee=>i.value=Ee)},{"item.position":t(({item:Ee})=>[n(v(J(Ee.position)),1)]),"no-data":t(()=>[...X[40]||(X[40]=[a("div",{class:"text-center pa-4 text-medium-emphasis"},"Keine historischen Daten vorhanden.",-1)])]),_:1},8,["items-per-page","items","sort-by"])],64))]),_:1}),e(ye,{class:"pa-6 pt-0"},{default:t(()=>[e(ne),e(ie,{variant:"flat",color:"primary",onClick:X[17]||(X[17]=Ee=>D.value=!1)},{default:t(()=>[...X[41]||(X[41]=[n("Schließen",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1})}}}),g3=Me(f3,[["__scopeId","data-v-72ad656f"]]),M6=Object.freeze(Object.defineProperty({__proto__:null,default:g3},Symbol.toStringTag,{value:"Module"})),b3={class:"d-flex align-center justify-space-between mb-4"},y3={class:"d-flex ga-2 mb-6"},_3={class:"d-flex ga-6 mb-4"},k3={key:2,class:"d-flex justify-end"},h3={key:0,class:"d-flex justify-center pa-6"},x3={key:2,class:"pa-6 text-center text-medium-emphasis text-caption"},w3=Ae({__name:"SeoKeywordDiscovery",setup(r){const $=[{key:"keywordDiscovery",label:"Keyword-Entdeckung",defaults:{temperature:.6,maxTokens:8192}}];Ut();const d=[{id:"nis2",name:"NIS2"},{id:"pentest",name:"Penetrationstest"},{id:"tisax",name:"TISAX"},{id:"iso27001",name:"ISO 27001"},{id:"ciso",name:"CISO as a Service"},{id:"cloud",name:"Cloud Security"},{id:"awareness",name:"Security Awareness"},{id:"incident",name:"Incident Response"}],c=qe("seo_discovery_topics",[]),s=qe("seo_discovery_trending",!0),m=qe("seo_discovery_content_gaps",!0),u=y(!1),f=y(null),p=y(null),_=y([]),k=y([]),i=y(!1),g=y(!1),x=y([]),w=y(!1),b=y(!1),I=y(!1);function V(S){return S>=80?"#66BB6A":S>=50?"#0AC9D4":"#C9A063"}function E(S){return new Date(S).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}function R(){var S;i.value?_.value=(((S=p.value)==null?void 0:S.trending)??[]).map(B=>B.keyword):_.value=[]}function M(){var S;g.value?k.value=(((S=p.value)==null?void 0:S.contentGaps)??[]).map(B=>B.keyword):k.value=[]}async function T(){if(c.value.length===0)return;u.value=!0,f.value=null,p.value=null,_.value=[],k.value=[],i.value=!1,g.value=!1;const S=await re.post("/seo/discovery",{topics:c.value,includeTrending:s.value,includeContentGaps:m.value});S.success?(p.value=S.data??null,await H()):(f.value=S.error||"Fehler beim Starten der Analyse.",ue.error("ADMIN","SEO discovery failed",{error:S.error})),u.value=!1}async function D(){const S=[..._.value,...k.value];if(S.length===0)return;b.value=!0,I.value=!1;const B=await re.post("/seo/discovery/add-to-todos",{keywords:S});B.success?(I.value=!0,_.value=[],k.value=[],i.value=!1,g.value=!1,ue.info("ADMIN","Keywords added to todos",{count:S.length}),setTimeout(()=>{I.value=!1},3e3)):(f.value=B.error||"Fehler beim Übernehmen der Keywords.",ue.error("ADMIN","Add to todos failed",{error:B.error})),b.value=!1}async function H(){var B;w.value=!0;const S=await re.get("/seo/discovery/history");S.success&&(x.value=(((B=S.data)==null?void 0:B.history)??[]).slice(0,10)),w.value=!1}async function O(S){const B=await re.delete(`/seo/discovery/${S}`);B.success?x.value=x.value.filter(G=>G._id!==S):ue.error("ADMIN","Discovery history delete failed",{id:S,error:B.error})}return rt(()=>H()),(S,B)=>{const G=l("v-btn"),W=l("v-alert"),F=l("v-card-title"),L=l("v-divider"),A=l("v-chip"),z=l("v-chip-group"),j=l("v-checkbox"),J=l("v-card-text"),Q=l("v-card"),te=l("v-icon"),ve=l("v-spacer"),de=l("v-list-item-title"),Z=l("v-list-item-subtitle"),ce=l("v-list-item"),oe=l("v-list"),pe=l("v-col"),_e=l("v-progress-circular"),q=l("v-tooltip"),C=l("v-row"),ae=l("v-container");return o(),N(ae,{fluid:"",class:"pa-6"},{default:t(()=>[a("div",b3,[B[8]||(B[8]=a("h1",{class:"text-h4 font-weight-bold"},"SEO",-1)),e(ta,{"page-key":"seo-discovery","page-label":"Keyword-Discovery KI-Einstellungen",usecases:$})]),a("div",y3,[e(G,{variant:S.$route.name==="admin-seo"?"tonal":"text",to:{name:"admin-seo"},size:"small",color:"primary"},{default:t(()=>[...B[9]||(B[9]=[n("Dashboard",-1)])]),_:1},8,["variant"]),e(G,{variant:S.$route.name==="admin-seo-rank-tracker"?"tonal":"text",to:{name:"admin-seo-rank-tracker"},size:"small",color:"primary"},{default:t(()=>[...B[10]||(B[10]=[n("Rank Tracker",-1)])]),_:1},8,["variant"]),e(G,{variant:S.$route.name==="admin-seo-keyword-discovery"?"tonal":"text",to:{name:"admin-seo-keyword-discovery"},size:"small",color:"primary"},{default:t(()=>[...B[11]||(B[11]=[n("Keyword Discovery",-1)])]),_:1},8,["variant"]),e(G,{variant:S.$route.name==="admin-seo-todos"?"tonal":"text",to:{name:"admin-seo-todos"},size:"small",color:"primary"},{default:t(()=>[...B[12]||(B[12]=[n("SEO Todos",-1)])]),_:1},8,["variant"])]),f.value?(o(),N(W,{key:0,type:"error",variant:"tonal",class:"mb-4",text:f.value,closable:"","onClick:close":B[0]||(B[0]=X=>f.value=null)},null,8,["text"])):U("",!0),I.value?(o(),N(W,{key:1,type:"success",variant:"tonal",class:"mb-4",text:"Keywords erfolgreich als SEO Todos übernommen."})):U("",!0),e(C,null,{default:t(()=>[e(pe,{cols:"12",md:"8"},{default:t(()=>[e(Q,{rounded:"lg",class:"mb-6"},{default:t(()=>[e(F,{class:"text-body-1 font-weight-semibold pa-4 pb-2"},{default:t(()=>[...B[13]||(B[13]=[n("Themenauswahl",-1)])]),_:1}),e(L),e(J,{class:"pa-4"},{default:t(()=>[B[15]||(B[15]=a("p",{class:"text-body-2 text-medium-emphasis mb-3"},"Wähle mindestens ein Thema für die KI-Analyse:",-1)),e(z,{modelValue:P(c),"onUpdate:modelValue":B[1]||(B[1]=X=>ot(c)?c.value=X:null),multiple:"",filter:"",column:""},{default:t(()=>[(o(),h(be,null,Pe(d,X=>e(A,{key:X.id,value:X.id,variant:"outlined",color:"primary",filter:""},{default:t(()=>[n(v(X.name),1)]),_:2},1032,["value"])),64))]),_:1},8,["modelValue"]),e(L,{class:"my-4"}),a("div",_3,[e(j,{modelValue:P(s),"onUpdate:modelValue":B[2]||(B[2]=X=>ot(s)?s.value=X:null),label:"Trending Keywords",color:"primary","hide-details":"",density:"compact"},null,8,["modelValue"]),e(j,{modelValue:P(m),"onUpdate:modelValue":B[3]||(B[3]=X=>ot(m)?m.value=X:null),label:"Content-Gap Analyse",color:"primary","hide-details":"",density:"compact"},null,8,["modelValue"])]),e(G,{color:"primary",variant:"flat",loading:u.value,disabled:P(c).length===0,"prepend-icon":"mdi-magnify-scan",onClick:T},{default:t(()=>[...B[14]||(B[14]=[n(" Discovery starten ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1}),p.value&&p.value.trending.length>0?(o(),N(Q,{key:0,rounded:"lg",class:"mb-4"},{default:t(()=>[e(F,{class:"text-body-1 font-weight-semibold pa-4 pb-2 d-flex align-center"},{default:t(()=>[e(te,{size:"18",class:"mr-2",color:"primary"},{default:t(()=>[...B[16]||(B[16]=[n("mdi-trending-up",-1)])]),_:1}),B[17]||(B[17]=n(" Trending Keywords ",-1)),e(ve),e(j,{modelValue:i.value,"onUpdate:modelValue":[B[4]||(B[4]=X=>i.value=X),R],label:"Alle","hide-details":"",density:"compact",color:"primary"},null,8,["modelValue"])]),_:1}),e(L),e(oe,{density:"compact"},{default:t(()=>[(o(!0),h(be,null,Pe(p.value.trending,X=>(o(),N(ce,{key:X.keyword,class:"discovery-item"},{prepend:t(()=>[e(j,{modelValue:_.value,"onUpdate:modelValue":B[5]||(B[5]=ie=>_.value=ie),value:X.keyword,"hide-details":"",density:"compact",color:"primary"},null,8,["modelValue","value"])]),append:t(()=>[e(A,{size:"x-small",style:ht({backgroundColor:V(X.relevance),color:"#000"})},{default:t(()=>[n(v(X.relevance),1)]),_:2},1032,["style"])]),default:t(()=>[e(de,{class:"font-weight-medium"},{default:t(()=>[n(v(X.keyword),1)]),_:2},1024),e(Z,{class:"text-caption mt-1"},{default:t(()=>[n(v(X.reason),1)]),_:2},1024),e(Z,{class:"text-caption text-medium-emphasis"},{default:t(()=>[n(v(X.recommendation),1)]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})):U("",!0),p.value&&p.value.contentGaps.length>0?(o(),N(Q,{key:1,rounded:"lg",class:"mb-4"},{default:t(()=>[e(F,{class:"text-body-1 font-weight-semibold pa-4 pb-2 d-flex align-center"},{default:t(()=>[e(te,{size:"18",class:"mr-2",color:"accent"},{default:t(()=>[...B[18]||(B[18]=[n("mdi-puzzle-outline",-1)])]),_:1}),B[19]||(B[19]=n(" Content-Gaps ",-1)),e(ve),e(j,{modelValue:g.value,"onUpdate:modelValue":[B[6]||(B[6]=X=>g.value=X),M],label:"Alle","hide-details":"",density:"compact",color:"primary"},null,8,["modelValue"])]),_:1}),e(L),e(oe,{density:"compact"},{default:t(()=>[(o(!0),h(be,null,Pe(p.value.contentGaps,X=>(o(),N(ce,{key:X.keyword,class:"discovery-item"},{prepend:t(()=>[e(j,{modelValue:k.value,"onUpdate:modelValue":B[7]||(B[7]=ie=>k.value=ie),value:X.keyword,"hide-details":"",density:"compact",color:"primary"},null,8,["modelValue","value"])]),append:t(()=>[e(A,{size:"x-small",style:ht({backgroundColor:V(X.relevance),color:"#000"})},{default:t(()=>[n(v(X.relevance),1)]),_:2},1032,["style"])]),default:t(()=>[e(de,{class:"font-weight-medium"},{default:t(()=>[n(v(X.keyword),1)]),_:2},1024),e(Z,{class:"text-caption mt-1"},{default:t(()=>[n(v(X.reason),1)]),_:2},1024),e(Z,{class:"text-caption text-medium-emphasis"},{default:t(()=>[n(v(X.recommendation),1)]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})):U("",!0),p.value?(o(),h("div",k3,[e(G,{color:"primary",variant:"flat",loading:b.value,disabled:_.value.length===0&&k.value.length===0,"prepend-icon":"mdi-check-all",onClick:D},{default:t(()=>[n(" Als SEO Todos übernehmen ("+v(_.value.length+k.value.length)+") ",1)]),_:1},8,["loading","disabled"])])):U("",!0)]),_:1}),e(pe,{cols:"12",md:"4"},{default:t(()=>[e(Q,{rounded:"lg"},{default:t(()=>[e(F,{class:"text-body-1 font-weight-semibold pa-4 pb-2"},{default:t(()=>[...B[20]||(B[20]=[n("Letzte Analysen",-1)])]),_:1}),e(L),w.value?(o(),h("div",h3,[e(_e,{indeterminate:"",color:"primary",size:"32"})])):x.value.length>0?(o(),N(oe,{key:1,density:"compact"},{default:t(()=>[(o(!0),h(be,null,Pe(x.value,X=>(o(),N(ce,{key:X._id,class:"py-2"},{append:t(()=>[e(G,{icon:"",size:"x-small",variant:"text",color:"error","aria-label":"Verlaufseintrag löschen",onClick:ie=>O(X._id)},{default:t(()=>[e(q,{activator:"parent",location:"bottom"},{default:t(()=>[...B[21]||(B[21]=[n("Verlaufseintrag löschen",-1)])]),_:1}),e(te,{size:"14"},{default:t(()=>[...B[22]||(B[22]=[n("mdi-delete-outline",-1)])]),_:1})]),_:1},8,["onClick"])]),default:t(()=>[e(de,{class:"text-body-2"},{default:t(()=>[n(v(E(X.createdAt)),1)]),_:2},1024),e(Z,{class:"text-caption"},{default:t(()=>[n(v(X.topics.join(", "))+" · "+v(X.keywordCount)+" Keywords ",1)]),_:2},1024)]),_:2},1024))),128))]),_:1})):(o(),h("div",x3," Noch keine Analysen durchgeführt. "))]),_:1})]),_:1})]),_:1})]),_:1})}}}),S3=Me(w3,[["__scopeId","data-v-57e4c4bf"]]),N6=Object.freeze(Object.defineProperty({__proto__:null,default:S3},Symbol.toStringTag,{value:"Module"})),$3={class:"d-flex align-center justify-space-between mb-4"},C3={class:"d-flex ga-2 mb-6"},V3={class:"seo-stat-card__value"},A3={class:"seo-stat-card__value",style:{color:"#0AC9D4"}},I3={class:"seo-stat-card__value",style:{color:"#C9A063"}},P3={class:"seo-stat-card__value",style:{color:"#66BB6A"}},z3={class:"d-flex align-center flex-wrap ga-3 mb-4"},D3={class:"d-flex ga-1 flex-wrap"},T3={class:"d-flex ga-1 flex-wrap"},L3={key:1,class:"d-flex justify-center py-16"},E3={key:2,class:"text-center pa-12 text-medium-emphasis"},M3={class:"d-flex align-center ga-3 flex-wrap",style:{"min-width":"0"}},N3={class:"font-weight-semibold text-body-2"},U3={class:"text-caption text-medium-emphasis d-none d-sm-inline"},B3={class:"d-flex ga-2 mb-3 flex-wrap"},F3={class:"text-body-2 text-medium-emphasis mb-4"},O3={key:0,class:"mb-4"},R3={class:"d-flex align-center ga-3 pt-2"},K3=Ae({__name:"SeoTodos",setup(r){const $=[{key:"todoGeneration",label:"SEO-Aufgaben generieren",defaults:{temperature:.5,maxTokens:4096}}];Ut();const d={"low-hanging-fruit":"#66BB6A","quick-wins":"#0AC9D4",ctr:"#C9A063",trending:"#AB47BC","keyword-discovery":"#748686"},c=[{title:"Offen",value:"pending"},{title:"In Arbeit",value:"in_progress"},{title:"Erledigt",value:"completed"},{title:"Ignoriert",value:"dismissed"}],s=[{label:"Alle",value:""},{label:"Offen",value:"pending"},{label:"In Arbeit",value:"in_progress"},{label:"Erledigt",value:"completed"}],m=[{label:"Alle",value:""},{label:"Low Hanging Fruit",value:"low-hanging-fruit"},{label:"Quick Wins",value:"quick-wins"},{label:"CTR",value:"ctr"},{label:"Trending",value:"trending"},{label:"Discovery",value:"keyword-discovery"}],u=y(!1),f=y(!1),p=y(null),_=y([]),k=y({total:0,pending:0,in_progress:0,completed:0}),i=qe("seo_todos_filter_status",""),g=qe("seo_todos_filter_type",""),x=se(()=>_.value.filter(O=>!(i.value&&O.status!==i.value||g.value&&O.opportunityType!==g.value)));function w(O){return d[O]??"#748686"}function b(O){const S=m.find(B=>B.value===O);return S?S.label:O}function I(O){return O==="high"?"error":O==="medium"?"warning":"default"}function V(O){return O==="high"?"Hoch":O==="medium"?"Mittel":"Niedrig"}function E(O){return O===null?"-":O.toFixed(1)}async function R(){var W,F,L,A;u.value=!0,p.value=null;const O={};i.value&&(O.status=i.value),g.value&&(O.type=g.value);const S=new URLSearchParams(O).toString(),[B,G]=await Promise.all([re.get(`/seo/todos${S?"?"+S:""}`),re.get("/seo/todos/stats")]);B.success?_.value=((W=B.data)==null?void 0:W.items)??[]:(p.value="Fehler beim Laden der SEO Todos.",ue.error("ADMIN","SEO todos load failed",{error:B.error})),G.success&&G.data&&(k.value={total:G.data.total,pending:((F=G.data.byStatus)==null?void 0:F.pending)??0,in_progress:((L=G.data.byStatus)==null?void 0:L.in_progress)??0,completed:((A=G.data.byStatus)==null?void 0:A.completed)??0}),u.value=!1}async function M(O,S){const B=await re.patch(`/seo/todos/${O._id}/status`,{status:S});B.success?(O.status=S,await R()):(p.value="Fehler beim Ändern des Status.",ue.error("ADMIN","Todo status change failed",{id:O._id,error:B.error}))}async function T(O,S){const B=S.status==="completed"?"pending":"completed";(await re.patch(`/seo/todos/${O._id}/tasks/${S._id}`,{status:B})).success?S.status=B:ue.error("ADMIN","Todo task toggle failed",{todoId:O._id,taskId:S._id})}async function D(O){const S=await re.delete(`/seo/todos/${O}`);S.success?(_.value=_.value.filter(B=>B._id!==O),await R()):(p.value="Fehler beim Löschen des Todos.",ue.error("ADMIN","Todo delete failed",{id:O,error:S.error}))}async function H(){f.value=!0;const O=await re.post("/seo/todos/analyze");O.success?await R():(p.value=O.error||"Fehler beim Starten der KI-Analyse.",ue.error("ADMIN","SEO analysis failed",{error:O.error})),f.value=!1}return rt(()=>R()),(O,S)=>{const B=l("v-btn"),G=l("v-alert"),W=l("v-card-text"),F=l("v-card"),L=l("v-col"),A=l("v-row"),z=l("v-chip"),j=l("v-divider"),J=l("v-spacer"),Q=l("v-progress-circular"),te=l("v-icon"),ve=l("v-expansion-panel-title"),de=l("v-checkbox"),Z=l("v-select"),ce=l("v-tooltip"),oe=l("v-expansion-panel-text"),pe=l("v-expansion-panel"),_e=l("v-expansion-panels"),q=l("v-container");return o(),N(q,{fluid:"",class:"pa-6"},{default:t(()=>[a("div",$3,[S[1]||(S[1]=a("h1",{class:"text-h4 font-weight-bold"},"SEO",-1)),e(ta,{"page-key":"seo-todos","page-label":"SEO-Todos KI-Einstellungen",usecases:$})]),a("div",C3,[e(B,{variant:O.$route.name==="admin-seo"?"tonal":"text",to:{name:"admin-seo"},size:"small",color:"primary"},{default:t(()=>[...S[2]||(S[2]=[n("Dashboard",-1)])]),_:1},8,["variant"]),e(B,{variant:O.$route.name==="admin-seo-rank-tracker"?"tonal":"text",to:{name:"admin-seo-rank-tracker"},size:"small",color:"primary"},{default:t(()=>[...S[3]||(S[3]=[n("Rank Tracker",-1)])]),_:1},8,["variant"]),e(B,{variant:O.$route.name==="admin-seo-keyword-discovery"?"tonal":"text",to:{name:"admin-seo-keyword-discovery"},size:"small",color:"primary"},{default:t(()=>[...S[4]||(S[4]=[n("Keyword Discovery",-1)])]),_:1},8,["variant"]),e(B,{variant:O.$route.name==="admin-seo-todos"?"tonal":"text",to:{name:"admin-seo-todos"},size:"small",color:"primary"},{default:t(()=>[...S[5]||(S[5]=[n("SEO Todos",-1)])]),_:1},8,["variant"])]),p.value?(o(),N(G,{key:0,type:"error",variant:"tonal",class:"mb-4",text:p.value,closable:"","onClick:close":S[0]||(S[0]=C=>p.value=null)},null,8,["text"])):U("",!0),e(A,{class:"mb-6"},{default:t(()=>[e(L,{cols:"6",sm:"3"},{default:t(()=>[e(F,{rounded:"lg",class:"seo-stat-card"},{default:t(()=>[e(W,{class:"pa-4"},{default:t(()=>[a("div",V3,v(k.value.total),1),S[6]||(S[6]=a("div",{class:"seo-stat-card__label"},"Gesamt",-1))]),_:1})]),_:1})]),_:1}),e(L,{cols:"6",sm:"3"},{default:t(()=>[e(F,{rounded:"lg",class:"seo-stat-card"},{default:t(()=>[e(W,{class:"pa-4"},{default:t(()=>[a("div",A3,v(k.value.pending),1),S[7]||(S[7]=a("div",{class:"seo-stat-card__label"},"Offen",-1))]),_:1})]),_:1})]),_:1}),e(L,{cols:"6",sm:"3"},{default:t(()=>[e(F,{rounded:"lg",class:"seo-stat-card"},{default:t(()=>[e(W,{class:"pa-4"},{default:t(()=>[a("div",I3,v(k.value.in_progress),1),S[8]||(S[8]=a("div",{class:"seo-stat-card__label"},"In Arbeit",-1))]),_:1})]),_:1})]),_:1}),e(L,{cols:"6",sm:"3"},{default:t(()=>[e(F,{rounded:"lg",class:"seo-stat-card"},{default:t(()=>[e(W,{class:"pa-4"},{default:t(()=>[a("div",P3,v(k.value.completed),1),S[9]||(S[9]=a("div",{class:"seo-stat-card__label"},"Erledigt",-1))]),_:1})]),_:1})]),_:1})]),_:1}),a("div",z3,[a("div",D3,[(o(),h(be,null,Pe(s,C=>e(z,{key:C.value,variant:P(i)===C.value?"flat":"outlined",color:P(i)===C.value?"primary":"default",size:"small",onClick:ae=>{i.value=C.value,R()}},{default:t(()=>[n(v(C.label),1)]),_:2},1032,["variant","color","onClick"])),64))]),e(j,{vertical:"",class:"mx-1",style:{height:"24px"}}),a("div",T3,[(o(),h(be,null,Pe(m,C=>e(z,{key:C.value,variant:P(g)===C.value?"flat":"outlined",color:P(g)===C.value?"primary":"default",size:"small",onClick:ae=>{g.value=C.value,R()}},{default:t(()=>[n(v(C.label),1)]),_:2},1032,["variant","color","onClick"])),64))]),e(J),e(B,{color:"primary",variant:"tonal",loading:f.value,"prepend-icon":"mdi-robot",onClick:H},{default:t(()=>[...S[10]||(S[10]=[n(" KI-Analyse starten ",-1)])]),_:1},8,["loading"])]),u.value?(o(),h("div",L3,[e(Q,{indeterminate:"",color:"primary",size:"48"})])):x.value.length===0?(o(),h("div",E3,[e(te,{size:"48",class:"mb-3"},{default:t(()=>[...S[11]||(S[11]=[n("mdi-check-circle-outline",-1)])]),_:1}),S[12]||(S[12]=a("p",null,"Keine SEO Todos gefunden.",-1))])):(o(),N(_e,{key:3,variant:"accordion"},{default:t(()=>[(o(!0),h(be,null,Pe(x.value,C=>(o(),N(pe,{key:C._id,rounded:"lg",class:"mb-2 seo-todo-panel"},{default:t(()=>[e(ve,null,{default:t(()=>[a("div",M3,[e(z,{size:"x-small",style:ht({backgroundColor:w(C.opportunityType),color:"#000",fontWeight:600})},{default:t(()=>[n(v(b(C.opportunityType)),1)]),_:2},1032,["style"]),a("span",N3,v(C.keyword),1),a("span",U3," Pos. "+v(E(C.position))+" · "+v(C.impressions.toLocaleString("de-DE"))+" Impressionen ",1),e(z,{size:"x-small",variant:"outlined",color:"primary"},{default:t(()=>[n(v(C.potential),1)]),_:2},1024)])]),_:2},1024),e(oe,null,{default:t(()=>[a("div",B3,[e(z,{size:"x-small",color:I(C.priority),variant:"tonal"},{default:t(()=>[n(v(V(C.priority)),1)]),_:2},1032,["color"]),e(z,{size:"x-small",variant:"outlined"},{default:t(()=>[n(v(C.category),1)]),_:2},1024)]),a("p",F3,v(C.reasoning),1),C.tasks&&C.tasks.length>0?(o(),h("div",O3,[S[13]||(S[13]=a("p",{class:"text-caption font-weight-semibold text-uppercase letter-spacing mb-2",style:{"letter-spacing":"0.08em"}},"Aufgaben",-1)),(o(!0),h(be,null,Pe(C.tasks,ae=>(o(),h("div",{key:ae._id,class:"d-flex align-center ga-2 seo-todo-task"},[e(de,{"model-value":ae.status==="completed","hide-details":"",density:"compact",color:"primary","onUpdate:modelValue":X=>T(C,ae)},null,8,["model-value","onUpdate:modelValue"]),a("span",{class:ft(["text-body-2",ae.status==="completed"?"text-decoration-line-through text-medium-emphasis":""])},v(ae.description),3)]))),128))])):U("",!0),a("div",R3,[e(Z,{"model-value":C.status,items:c,"item-title":"title","item-value":"value",variant:"outlined",density:"compact","hide-details":"",style:{"max-width":"180px"},"onUpdate:modelValue":ae=>M(C,ae)},null,8,["model-value","onUpdate:modelValue"]),e(J),e(B,{icon:"",size:"small",variant:"text",color:"error","aria-label":"Aufgabe löschen",onClick:ae=>D(C._id)},{default:t(()=>[e(ce,{activator:"parent",location:"bottom"},{default:t(()=>[...S[14]||(S[14]=[n("Aufgabe löschen",-1)])]),_:1}),e(te,{size:"16"},{default:t(()=>[...S[15]||(S[15]=[n("mdi-delete-outline",-1)])]),_:1})]),_:1},8,["onClick"])])]),_:2},1024)]),_:2},1024))),128))]),_:1}))]),_:1})}}}),j3=Me(K3,[["__scopeId","data-v-47ec96b3"]]),U6=Object.freeze(Object.defineProperty({__proto__:null,default:j3},Symbol.toStringTag,{value:"Module"}));function q3(r,$){const d=y(1),c=se(()=>Math.max(1,P($))),s=se(()=>Math.max(1,Math.ceil(r.value.length/c.value))),m=se(()=>{const f=(d.value-1)*c.value;return r.value.slice(f,f+c.value)});return Ze([r,c],()=>{d.value>s.value&&(d.value=1)}),{page:d,totalPages:s,pagedItems:m,resetToFirstPage:()=>{d.value=1}}}const G3={class:"image-pool-view"},H3={class:"image-pool-view__header"},W3={class:"d-flex align-center ga-2"},Z3={key:2,class:"d-flex justify-center pa-12"},J3={key:3,class:"image-pool-view__empty"},Q3={class:"d-flex justify-center ga-2"},Y3=["onClick"],X3={class:"d-flex justify-center align-center fill-height"},eV={class:"image-pool-view__image-info"},tV={key:0,class:"d-flex align-center ga-1 mt-1"},aV=["onClick"],lV={class:"text-body-2 font-weight-medium"},nV={key:0,class:"text-caption text-medium-emphasis text-truncate",style:{"max-width":"300px"}},oV={class:"text-body-2 text-medium-emphasis"},sV={class:"text-body-2 text-medium-emphasis"},iV={class:"d-flex flex-wrap ga-1"},rV={key:6,class:"image-pool-view__pagination d-flex flex-column align-center mt-6 ga-3"},dV={class:"d-flex align-center ga-3 flex-wrap justify-center"},uV={class:"d-flex align-center ga-2"},cV={class:"text-caption text-medium-emphasis"},mV={class:"d-flex align-center justify-space-between"},vV={key:0,class:"d-flex align-center ga-2",style:{"min-width":"0"}},pV={class:"text-subtitle-1 font-weight-semibold text-truncate"},fV={key:1,class:"d-flex align-center ga-2 flex-grow-1",style:{"min-width":"0"}},gV={class:"text-medium-emphasis text-body-2"},bV={class:"d-flex flex-wrap ga-3 mb-4 text-body-2 text-medium-emphasis"},yV={key:0},_V={key:1},kV={class:"mb-4"},hV={class:"d-flex align-center ga-3"},xV={key:0,class:"text-caption text-success"},wV={class:"d-flex align-center justify-space-between"},SV={class:"text-caption text-medium-emphasis"},$V={class:"d-flex align-center justify-space-between"},CV=Ae({__name:"ImagePoolView",setup(r){const $=y([]),d=y(!1),c=y(null),s=y(null),m=y(null),u=y(!1),f=qe("image_pool_view_mode","large"),p=y(null),_=y(null),k=qe("images_filter_source",""),i=qe("images_filter_tag",""),g=y(""),x=qe("image_pool_only_mine",!1),w=y(!1),b=y(null),I=y([]),V=y(!1),E=y(""),R=y(""),M=y(!1),T=y(null),D=y(!1),H=y(""),O=y(!1),S=y(null),B=y(null),G=y(!1),W=y(!1),F=y(!1),L=y(!1),A=y(null),z=y(""),j=y([]),J=y(!1),Q=y(null),te=y(!1),ve=y(""),de=y("ASPECT_1_1"),Z=y(""),ce=y(!1),oe=y(null),pe=y([]),_e=y(""),q=y(null),C=[{title:"Alle",value:""},{title:"Hochgeladen",value:"upload"},{title:"KI-generiert",value:"ai-generated"},{title:"WordPress-Import",value:"wordpress-import"},{title:"URL",value:"url"}],ae=[{title:"1:1 (Quadrat)",value:"ASPECT_1_1"},{title:"4:5 (Hochformat)",value:"ASPECT_4_5"},{title:"16:9 (Querformat)",value:"ASPECT_16_9"},{title:"9:16 (Story)",value:"ASPECT_9_16"}],X=[{title:"Kein Stil",value:""},{title:"Realistisch",value:"REALISTIC"},{title:"Design",value:"DESIGN"},{title:"Anime",value:"ANIME"}],ie=se(()=>{const Re=new Set;return $.value.forEach(ge=>{var at;return(at=ge.tags)==null?void 0:at.forEach(et=>Re.add(et))}),Array.from(Re).sort()}),fe=se(()=>{let Re=$.value;if(k.value&&(Re=Re.filter(ge=>ge.source===k.value)),i.value&&(Re=Re.filter(ge=>{var at;return(at=ge.tags)==null?void 0:at.includes(i.value)})),g.value.trim()){const ge=g.value.trim().toLowerCase();Re=Re.filter(at=>{var et,it;return((et=at.tags)==null?void 0:et.some($t=>$t.toLowerCase().includes(ge)))||((it=at.filename)==null?void 0:it.toLowerCase().includes(ge))})}return Re});async function Se(){d.value=!0,c.value=null;try{const Re=new URLSearchParams({limit:"100"});x.value&&Re.set("onlyMine","true");const ge=`/images?${Re.toString()}`,at=await re.get(ge);if(at.success&&at.data){const et=at.data;$.value=Array.isArray(et)?et:et.items??[]}else c.value=at.error||"Fehler beim Laden der Bilder"}catch{c.value="Netzwerkfehler beim Laden der Bilder"}finally{d.value=!1}}Ze(x,()=>{Se()});function me(Re){b.value=Re,I.value=[...Re.tags||[]],E.value=Re.alt||"",R.value=Re.title||"",D.value=!1,S.value=null,B.value=null,T.value=null,w.value=!0}function ee(){w.value=!1,b.value=null,B.value=null,S.value=null,T.value=null}function Y(){if(!b.value)return;const Re=b.value.filename,ge=Re.lastIndexOf(".");H.value=ge>=0?Re.substring(0,ge):Re,S.value=null,B.value=null,D.value=!0}function K(){D.value=!1}async function le(){if(b.value){if(!H.value.trim()){S.value="Dateiname darf nicht leer sein";return}O.value=!0,S.value=null;try{const Re=await re.put(`/images/${b.value._id}`,{filename:H.value.trim()});if(Re.success&&Re.data){const ge=Re.data.referencesUpdated;b.value=Re.data;const at=$.value.findIndex(et=>et._id===b.value._id);at>=0&&($.value[at]=Re.data),D.value=!1,B.value=ge&&ge>0?`Dateiname geändert. ${ge} Referenz(en) aktualisiert.`:"Dateiname geändert."}else S.value=Re.error||"Fehler beim Umbenennen"}catch{S.value="Netzwerkfehler beim Umbenennen"}finally{O.value=!1}}}async function ne(){if(b.value){V.value=!0;try{const Re=await re.put(`/images/${b.value._id}`,{tags:I.value});if(Re.success&&Re.data){const ge=$.value.findIndex(at=>at._id===b.value._id);ge>=0&&($.value[ge]=Re.data),b.value=Re.data}else c.value=Re.error||"Fehler beim Speichern der Tags"}catch{c.value="Netzwerkfehler beim Speichern"}finally{V.value=!1}}}async function Ce(){if(!b.value)return;const Re=b.value._id;M.value=!0,T.value=null;try{const ge=await re.put(`/images/${Re}`,{alt:E.value.trim(),title:R.value.trim()});if(ge.success&&ge.data){b.value=ge.data;const at=$.value.findIndex(et=>et._id===Re);at>=0&&($.value[at]=ge.data),T.value="ALT und TITLE gespeichert."}else T.value=null,c.value=ge.error||"Fehler beim Speichern der SEO-Tags"}catch{c.value="Netzwerkfehler beim Speichern der SEO-Tags"}finally{M.value=!1}}function ke(){G.value=!0}async function xe(){if(b.value){W.value=!0,G.value=!1;try{const Re=await re.delete(`/images/${b.value._id}`);Re.success?($.value=$.value.filter(ge=>ge._id!==b.value._id),ee()):c.value=Re.error||"Fehler beim Löschen"}catch{c.value="Netzwerkfehler beim Löschen"}finally{W.value=!1}}}function Ne(){z.value&&(URL.revokeObjectURL(z.value),z.value="")}function Ie(){Ne(),A.value=null,j.value=[],Q.value=null,F.value=!0}function Ue(Re){Re.preventDefault(),L.value=!0}function Te(Re){var at,et;Re.preventDefault(),L.value=!1;const ge=(et=(at=Re.dataTransfer)==null?void 0:at.files)==null?void 0:et[0];ge&&Je(ge)}function ye(Re){var et;const at=(et=Re.target.files)==null?void 0:et[0];at&&Je(at)}function Je(Re){Ne(),A.value=Re,z.value=URL.createObjectURL(Re)}async function Ke(){if(A.value){J.value=!0,Q.value=null;try{const Re=new FormData;Re.append("image",A.value),j.value.length&&Re.append("tags",j.value.join(","));const ge=await re.upload("/images/upload",Re);ge.success&&ge.data?($.value.unshift(ge.data),F.value=!1,Ne(),m.value="Bild erfolgreich hochgeladen."):Q.value=ge.error||"Fehler beim Hochladen"}catch{Q.value="Netzwerkfehler beim Hochladen"}finally{J.value=!1}}}async function $e(){q.value=null;try{const Re=await re.get("/ideogram-presets?isActive=true&limit=100");if(Re.success&&Re.data){const ge=Re.data;pe.value=Array.isArray(ge)?ge:ge.items??[]}else q.value=Re.error||"Presets konnten nicht geladen werden"}catch{q.value="Netzwerkfehler beim Laden der Presets"}}function Ee(){ve.value="",de.value="ASPECT_1_1",Z.value="",oe.value=null,_e.value="";const Re=pe.value.find(ge=>ge.isDefault);Re&&lt(Re._id),te.value=!0}function lt(Re){if(_e.value=Re,!Re)return;const ge=pe.value.find(at=>at._id===Re);ge&&(ve.value=ge.prompt||"",de.value=ge.aspectRatio||"ASPECT_1_1",Z.value=ge.style||"")}async function ut(){if(ve.value.trim()){ce.value=!0,oe.value=null;try{const Re={prompt:ve.value,aspectRatio:de.value};Z.value&&(Re.styleType=Z.value),_e.value&&(Re.preset=_e.value);const ge=await re.post("/images/generate",Re);if(ge.success&&ge.data){const at=Array.isArray(ge.data)?ge.data:[ge.data];at.forEach(et=>$.value.unshift(et)),te.value=!1,m.value=at.length===1?"Bild erfolgreich generiert.":`${at.length} Bilder erfolgreich generiert.`}else oe.value=ge.error||"Fehler beim Generieren"}catch{oe.value="Netzwerkfehler beim Generieren"}finally{ce.value=!1}}}function Ve(Re){p.value===Re?_.value==="asc"?_.value="desc":_.value==="desc"&&(p.value=null,_.value=null):(p.value=Re,_.value="asc")}function Le(Re){return p.value!==Re?"mdi-unfold-more-horizontal":_.value==="asc"?"mdi-arrow-up":"mdi-arrow-down"}const Ye=se(()=>{const Re=[...fe.value];if(!p.value||!_.value)return Re;const ge=p.value,at=_.value==="asc"?1:-1;return Re.sort((et,it)=>{let $t="",yt="";return ge==="filename"?($t=et.filename.toLowerCase(),yt=it.filename.toLowerCase()):ge==="source"?($t=et.source,yt=it.source):ge==="fileSize"?($t=et.fileSize??0,yt=it.fileSize??0):ge==="createdAt"?($t=et.createdAt,yt=it.createdAt):ge==="tags"&&($t=(et.tags??[]).join(","),yt=(it.tags??[]).join(",")),$t<yt?-at:$t>yt?at:0})}),ct=[10,25,50,100],Fe=qe("image_pool_page_size",25),{page:Xe,totalPages:mt,pagedItems:nt,resetToFirstPage:He}=q3(Ye,Fe);Ze([k,i,g,x,f,Fe],()=>{He()});function St(Re){return Re?Re<1024?`${Re} B`:Re<1024*1024?`${(Re/1024).toFixed(0)} KB`:`${(Re/(1024*1024)).toFixed(1)} MB`:"-"}async function Pt(Re,ge){ge&&ge.stopPropagation();try{await navigator.clipboard.writeText(Re),u.value=!0}catch{c.value="URL konnte nicht kopiert werden"}}function Dt(Re){return Re?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(new Date(Re)):"-"}function _t(Re){switch(Re){case"ai-generated":return"KI-generiert";case"wordpress-import":return"WordPress-Import";case"url":return"URL";case"upload":default:return"Hochgeladen"}}return rt(()=>{Se(),$e()}),da(()=>{Ne()}),Ze(F,Re=>{Re||Ne()}),(Re,ge)=>{const at=l("v-icon"),et=l("v-tooltip"),it=l("v-btn"),$t=l("v-btn-toggle"),yt=l("v-alert"),We=l("v-select"),Qe=l("v-col"),At=l("v-text-field"),je=l("v-chip"),he=l("v-row"),ze=l("v-card-text"),Be=l("v-card"),bt=l("v-progress-circular"),pt=l("v-img"),It=l("v-table"),Gt=l("v-pagination"),vt=l("v-card-title"),De=l("v-divider"),we=l("v-combobox"),tt=l("v-spacer"),kt=l("v-card-actions"),zt=l("v-dialog"),Et=l("v-snackbar"),Ot=l("v-autocomplete"),Bt=l("v-textarea");return o(),h("div",G3,[a("div",H3,[ge[48]||(ge[48]=a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"Bilderpool"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," Bilder hochladen oder mit KI generieren ")],-1)),a("div",W3,[e($t,{modelValue:P(f),"onUpdate:modelValue":ge[0]||(ge[0]=Oe=>ot(f)?f.value=Oe:null),mandatory:"",density:"compact",variant:"outlined",class:"mr-2"},{default:t(()=>[e(it,{value:"large",size:"small"},{default:t(()=>[e(at,{size:"18"},{default:t(()=>[...ge[40]||(ge[40]=[n("mdi-view-grid",-1)])]),_:1}),e(et,{activator:"parent",location:"bottom"},{default:t(()=>[...ge[41]||(ge[41]=[n("Große Ansicht",-1)])]),_:1})]),_:1}),e(it,{value:"compact",size:"small"},{default:t(()=>[e(at,{size:"18"},{default:t(()=>[...ge[42]||(ge[42]=[n("mdi-view-module",-1)])]),_:1}),e(et,{activator:"parent",location:"bottom"},{default:t(()=>[...ge[43]||(ge[43]=[n("Kompakte Ansicht",-1)])]),_:1})]),_:1}),e(it,{value:"table",size:"small"},{default:t(()=>[e(at,{size:"18"},{default:t(()=>[...ge[44]||(ge[44]=[n("mdi-view-list",-1)])]),_:1}),e(et,{activator:"parent",location:"bottom"},{default:t(()=>[...ge[45]||(ge[45]=[n("Tabellenansicht",-1)])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(it,{variant:"outlined","prepend-icon":"mdi-upload",onClick:Ie},{default:t(()=>[...ge[46]||(ge[46]=[n(" Hochladen ",-1)])]),_:1}),e(it,{color:"primary","prepend-icon":"mdi-creation",onClick:Ee},{default:t(()=>[...ge[47]||(ge[47]=[n(" KI generieren ",-1)])]),_:1})])]),m.value?(o(),N(yt,{key:0,type:"success",variant:"tonal",class:"mb-4",closable:"","onClick:close":ge[1]||(ge[1]=Oe=>m.value=null)},{default:t(()=>[n(v(m.value),1)]),_:1})):U("",!0),c.value?(o(),N(yt,{key:1,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":ge[2]||(ge[2]=Oe=>c.value=null)},{default:t(()=>[n(v(c.value),1)]),_:1})):U("",!0),e(Be,{variant:"outlined",class:"image-pool-view__filter mb-4"},{default:t(()=>[e(ze,{class:"pa-4"},{default:t(()=>[e(he,{align:"center",dense:""},{default:t(()=>[e(Qe,{cols:"12",sm:"4",md:"3"},{default:t(()=>[e(We,{modelValue:P(k),"onUpdate:modelValue":ge[3]||(ge[3]=Oe=>ot(k)?k.value=Oe:null),label:"Quelle",items:C,variant:"outlined",density:"compact","hide-details":"",clearable:""},null,8,["modelValue"])]),_:1}),e(Qe,{cols:"12",sm:"4",md:"3"},{default:t(()=>[e(We,{modelValue:P(i),"onUpdate:modelValue":ge[4]||(ge[4]=Oe=>ot(i)?i.value=Oe:null),label:"Tag filtern",items:ie.value,variant:"outlined",density:"compact","hide-details":"",clearable:""},null,8,["modelValue","items"])]),_:1}),e(Qe,{cols:"12",sm:"4",md:"4"},{default:t(()=>[e(At,{modelValue:g.value,"onUpdate:modelValue":ge[5]||(ge[5]=Oe=>g.value=Oe),label:"Suche","prepend-inner-icon":"mdi-magnify",variant:"outlined",density:"compact","hide-details":"",clearable:"",placeholder:"Dateiname oder Tag..."},null,8,["modelValue"])]),_:1}),e(Qe,{cols:"12",sm:"12",md:"2",class:"d-flex align-center"},{default:t(()=>[e(je,{color:P(x)?"primary":"",variant:P(x)?"flat":"outlined","prepend-icon":"mdi-account-filter",onClick:ge[6]||(ge[6]=Oe=>x.value=!P(x)),class:"mr-2"},{default:t(()=>[...ge[49]||(ge[49]=[n(" Nur meine ",-1)])]),_:1},8,["color","variant"])]),_:1})]),_:1})]),_:1})]),_:1}),d.value?(o(),h("div",Z3,[e(bt,{indeterminate:"",color:"primary"})])):fe.value.length?P(f)!=="table"?(o(),N(he,{key:4},{default:t(()=>[(o(!0),h(be,null,Pe(P(nt),Oe=>(o(),N(Qe,{key:Oe._id,cols:P(f)==="compact"?4:6,sm:P(f)==="compact"?3:4,md:P(f)==="compact"?2:3,lg:P(f)==="compact"?"auto":2,class:ft({"image-pool-view__col-compact":P(f)==="compact"})},{default:t(()=>{var Ct,Rt;return[a("div",{class:"image-pool-view__image-card",onClick:qt=>me(Oe)},[e(pt,{src:Oe.url,alt:Oe.alt||Oe.filename,title:Oe.title||"","aspect-ratio":"1",cover:"",class:"image-pool-view__thumbnail"},{placeholder:t(()=>[a("div",X3,[e(bt,{indeterminate:"",color:"primary",size:"24"})])]),_:1},8,["src","alt","title"]),e(it,{icon:"",size:"x-small",variant:"flat",color:"primary",class:"image-pool-view__copy-btn",onClick:qt=>Pt(Oe.url,qt)},{default:t(()=>[e(at,{size:"14"},{default:t(()=>[...ge[55]||(ge[55]=[n("mdi-content-copy",-1)])]),_:1}),e(et,{activator:"parent",location:"top"},{default:t(()=>[...ge[56]||(ge[56]=[n("URL kopieren",-1)])]),_:1})]),_:1},8,["onClick"]),a("div",eV,[e(je,{color:Oe.source==="ai-generated"?"primary":"default",size:"x-small",variant:"tonal"},{default:t(()=>[n(v(_t(Oe.source)),1)]),_:2},1032,["color"]),P(f)==="large"?(o(),h(be,{key:0},[Oe.createdBy||Oe.updatedBy?(o(),h("div",tV,[Oe.createdBy?(o(),N(gt,{key:0,"user-id":((Ct=Oe.createdBy)==null?void 0:Ct._id)??Oe.createdBy,populated:typeof Oe.createdBy=="object"?Oe.createdBy:null,size:20},null,8,["user-id","populated"])):U("",!0),Oe.updatedBy?(o(),N(gt,{key:1,"user-id":((Rt=Oe.updatedBy)==null?void 0:Rt._id)??Oe.updatedBy,populated:typeof Oe.updatedBy=="object"?Oe.updatedBy:null,size:20},null,8,["user-id","populated"])):U("",!0)])):U("",!0)],64)):U("",!0)])],8,Y3)]}),_:2},1032,["cols","sm","md","lg","class"]))),128))]),_:1})):(o(),N(Be,{key:5,variant:"outlined",class:"image-pool-view__table-card"},{default:t(()=>[e(It,{density:"comfortable",hover:""},{default:t(()=>[a("thead",null,[a("tr",null,[ge[62]||(ge[62]=a("th",{style:{width:"52px"}},null,-1)),a("th",{class:"image-pool-view__sortable-header",onClick:ge[7]||(ge[7]=Oe=>Ve("filename"))},[ge[57]||(ge[57]=n(" Dateiname ",-1)),e(at,{size:"14",class:"ml-1"},{default:t(()=>[n(v(Le("filename")),1)]),_:1})]),a("th",{class:"image-pool-view__sortable-header",onClick:ge[8]||(ge[8]=Oe=>Ve("source"))},[ge[58]||(ge[58]=n(" Quelle ",-1)),e(at,{size:"14",class:"ml-1"},{default:t(()=>[n(v(Le("source")),1)]),_:1})]),a("th",{class:"image-pool-view__sortable-header",onClick:ge[9]||(ge[9]=Oe=>Ve("fileSize"))},[ge[59]||(ge[59]=n(" Größe ",-1)),e(at,{size:"14",class:"ml-1"},{default:t(()=>[n(v(Le("fileSize")),1)]),_:1})]),a("th",{class:"image-pool-view__sortable-header",onClick:ge[10]||(ge[10]=Oe=>Ve("createdAt"))},[ge[60]||(ge[60]=n(" Datum ",-1)),e(at,{size:"14",class:"ml-1"},{default:t(()=>[n(v(Le("createdAt")),1)]),_:1})]),a("th",{class:"image-pool-view__sortable-header",onClick:ge[11]||(ge[11]=Oe=>Ve("tags"))},[ge[61]||(ge[61]=n(" Tags ",-1)),e(at,{size:"14",class:"ml-1"},{default:t(()=>[n(v(Le("tags")),1)]),_:1})]),ge[63]||(ge[63]=a("th",{style:{width:"44px"}},null,-1))])]),a("tbody",null,[(o(!0),h(be,null,Pe(P(nt),Oe=>(o(),h("tr",{key:Oe._id,class:"image-pool-view__table-row",onClick:Ct=>me(Oe)},[a("td",null,[e(pt,{src:Oe.url,alt:Oe.alt||Oe.filename,title:Oe.title||"",width:"36",height:"36",cover:"",class:"rounded"},null,8,["src","alt","title"])]),a("td",null,[a("div",lV,v(Oe.filename),1),Oe.alt?(o(),h("div",nV,v(Oe.alt),1)):U("",!0)]),a("td",null,[e(je,{color:Oe.source==="ai-generated"?"primary":"default",size:"x-small",variant:"tonal"},{default:t(()=>[n(v(_t(Oe.source)),1)]),_:2},1032,["color"])]),a("td",oV,v(St(Oe.fileSize)),1),a("td",sV,v(Dt(Oe.createdAt)),1),a("td",null,[a("div",iV,[(o(!0),h(be,null,Pe((Oe.tags||[]).slice(0,3),Ct=>(o(),N(je,{key:Ct,size:"x-small",variant:"outlined"},{default:t(()=>[n(v(Ct),1)]),_:2},1024))),128)),(Oe.tags||[]).length>3?(o(),N(je,{key:0,size:"x-small",variant:"text"},{default:t(()=>[n(" +"+v(Oe.tags.length-3),1)]),_:2},1024)):U("",!0)])]),a("td",null,[e(it,{icon:"",size:"x-small",variant:"text",onClick:Ct=>Pt(Oe.url,Ct)},{default:t(()=>[e(at,{size:"14"},{default:t(()=>[...ge[64]||(ge[64]=[n("mdi-content-copy",-1)])]),_:1}),e(et,{activator:"parent",location:"top"},{default:t(()=>[...ge[65]||(ge[65]=[n("URL kopieren",-1)])]),_:1})]),_:1},8,["onClick"])])],8,aV))),128))])]),_:1})]),_:1})):(o(),h("div",J3,[e(Be,{variant:"outlined"},{default:t(()=>[e(ze,{class:"text-center pa-12"},{default:t(()=>[e(at,{size:"64",color:"medium-emphasis",class:"mb-4"},{default:t(()=>[...ge[50]||(ge[50]=[n("mdi-image-off-outline",-1)])]),_:1}),ge[53]||(ge[53]=a("p",{class:"text-h6 font-weight-medium mb-2"},"Keine Bilder vorhanden",-1)),ge[54]||(ge[54]=a("p",{class:"text-body-2 text-medium-emphasis mb-6"}," Lade Bilder hoch oder generiere sie mit der KI. ",-1)),a("div",Q3,[e(it,{variant:"outlined","prepend-icon":"mdi-upload",onClick:Ie},{default:t(()=>[...ge[51]||(ge[51]=[n("Hochladen",-1)])]),_:1}),e(it,{color:"primary","prepend-icon":"mdi-creation",onClick:Ee},{default:t(()=>[...ge[52]||(ge[52]=[n("KI generieren",-1)])]),_:1})])]),_:1})]),_:1})])),!d.value&&fe.value.length>0?(o(),h("div",rV,[P(mt)>1?(o(),N(Gt,{key:0,modelValue:P(Xe),"onUpdate:modelValue":ge[12]||(ge[12]=Oe=>ot(Xe)?Xe.value=Oe:null),length:P(mt),"total-visible":7,rounded:"circle",density:"comfortable"},null,8,["modelValue","length"])):U("",!0),a("div",dV,[a("div",uV,[ge[66]||(ge[66]=a("span",{class:"text-caption text-medium-emphasis"},"Pro Seite",-1)),e(We,{modelValue:P(Fe),"onUpdate:modelValue":ge[13]||(ge[13]=Oe=>ot(Fe)?Fe.value=Oe:null),items:ct,variant:"outlined",density:"compact","hide-details":"",style:{"min-width":"88px","max-width":"100px"}},null,8,["modelValue"])]),a("span",cV,[P(mt)>1?(o(),h(be,{key:0},[n("Seite "+v(P(Xe))+" von "+v(P(mt))+" · ",1)],64)):U("",!0),n(v(fe.value.length)+" Bilder gesamt ",1)])])])):U("",!0),e(zt,{modelValue:w.value,"onUpdate:modelValue":ge[20]||(ge[20]=Oe=>w.value=Oe),"max-width":"640",scrollable:"",persistent:D.value||M.value||V.value},{default:t(()=>[b.value?(o(),N(Be,{key:0,class:"image-pool-view__dialog"},{default:t(()=>[e(vt,{class:"pa-5 pb-3"},{default:t(()=>[a("div",mV,[D.value?(o(),h("div",fV,[e(At,{modelValue:H.value,"onUpdate:modelValue":ge[14]||(ge[14]=Oe=>H.value=Oe),variant:"outlined",density:"compact","hide-details":"auto","error-messages":S.value||void 0,autofocus:"",class:"flex-grow-1",onKeyup:Kt(le,["enter"]),onKeydown:Kt(dt(K,["stop"]),["escape"])},{"append-inner":t(()=>[a("span",gV,v(b.value.filename.lastIndexOf(".")>=0?b.value.filename.substring(b.value.filename.lastIndexOf(".")):""),1)]),_:1},8,["modelValue","error-messages","onKeydown"]),e(it,{icon:"",variant:"text",size:"x-small",color:"primary",loading:O.value,onClick:le},{default:t(()=>[e(at,{size:"16"},{default:t(()=>[...ge[69]||(ge[69]=[n("mdi-check",-1)])]),_:1})]),_:1},8,["loading"]),e(it,{icon:"",variant:"text",size:"x-small",onClick:K},{default:t(()=>[e(at,{size:"16"},{default:t(()=>[...ge[70]||(ge[70]=[n("mdi-close",-1)])]),_:1})]),_:1})])):(o(),h("div",vV,[a("span",pV,v(b.value.filename),1),e(it,{icon:"",variant:"text",size:"x-small",onClick:Y,"aria-label":"Umbenennen"},{default:t(()=>[e(at,{size:"16"},{default:t(()=>[...ge[67]||(ge[67]=[n("mdi-pencil-outline",-1)])]),_:1}),e(et,{activator:"parent",location:"bottom"},{default:t(()=>[...ge[68]||(ge[68]=[n("Umbenennen",-1)])]),_:1})]),_:1})])),e(it,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:ee},{default:t(()=>[e(et,{activator:"parent",location:"bottom"},{default:t(()=>[...ge[71]||(ge[71]=[n("Schließen",-1)])]),_:1}),e(at,null,{default:t(()=>[...ge[72]||(ge[72]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(De),B.value?(o(),N(yt,{key:0,type:"success",variant:"tonal",density:"compact",class:"mx-5 mt-3",closable:"","onClick:close":ge[15]||(ge[15]=Oe=>B.value=null)},{default:t(()=>[n(v(B.value),1)]),_:1})):U("",!0),e(ze,{class:"pa-5"},{default:t(()=>{var Oe;return[e(pt,{src:b.value.url,alt:b.value.alt||b.value.filename,title:b.value.title||"","max-height":"300",contain:"",class:"rounded mb-4 image-pool-view__detail-img"},null,8,["src","alt","title"]),a("div",bV,[a("span",null,[e(at,{size:"14",class:"mr-1"},{default:t(()=>[...ge[73]||(ge[73]=[n("mdi-calendar",-1)])]),_:1}),n(" "+v(Dt(b.value.createdAt)),1)]),a("span",null,[e(at,{size:"14",class:"mr-1"},{default:t(()=>[...ge[74]||(ge[74]=[n("mdi-tag-outline",-1)])]),_:1}),n(" "+v(_t(b.value.source)),1)]),b.value.width&&b.value.height?(o(),h("span",yV,[e(at,{size:"14",class:"mr-1"},{default:t(()=>[...ge[75]||(ge[75]=[n("mdi-aspect-ratio",-1)])]),_:1}),n(" "+v(b.value.width)+" × "+v(b.value.height),1)])):U("",!0),(Oe=b.value.usedIn)!=null&&Oe.length?(o(),h("span",_V,[e(at,{size:"14",class:"mr-1"},{default:t(()=>[...ge[76]||(ge[76]=[n("mdi-link-variant",-1)])]),_:1}),n(" "+v(b.value.usedIn.length)+" Verwendungen ",1)])):U("",!0)]),a("div",kV,[e(At,{modelValue:E.value,"onUpdate:modelValue":ge[16]||(ge[16]=Ct=>E.value=Ct),label:"ALT-Tag (SEO)",placeholder:"Beschreibt den Bildinhalt fuer Google und Screenreader",variant:"outlined",density:"comfortable",counter:"250",maxlength:"250","hide-details":"auto",class:"mb-3"},null,8,["modelValue"]),e(At,{modelValue:R.value,"onUpdate:modelValue":ge[17]||(ge[17]=Ct=>R.value=Ct),label:"TITLE-Tag (SEO)",placeholder:"Ergaenzender Kontext, wird als Tooltip angezeigt",variant:"outlined",density:"comfortable",counter:"250",maxlength:"250","hide-details":"auto",class:"mb-3"},null,8,["modelValue"]),a("div",hV,[e(it,{color:"primary",variant:"outlined",size:"small",loading:M.value,"prepend-icon":"mdi-content-save-outline",onClick:Ce},{default:t(()=>[...ge[77]||(ge[77]=[n(" SEO-Tags speichern ",-1)])]),_:1},8,["loading"]),T.value?(o(),h("span",xV,v(T.value),1)):U("",!0)])]),e(we,{modelValue:I.value,"onUpdate:modelValue":ge[18]||(ge[18]=Ct=>I.value=Ct),label:"Tags",placeholder:"Tag eingeben und Enter drücken",variant:"outlined",density:"comfortable",multiple:"",chips:"","closable-chips":"","hide-no-data":"",class:"mb-2"},null,8,["modelValue"]),e(it,{color:"primary",variant:"outlined",size:"small",loading:V.value,"prepend-icon":"mdi-content-save-outline",onClick:ne},{default:t(()=>[...ge[78]||(ge[78]=[n(" Tags speichern ",-1)])]),_:1},8,["loading"])]}),_:1}),e(De),e(kt,{class:"pa-4"},{default:t(()=>[e(it,{color:"error",variant:"outlined",size:"small","prepend-icon":"mdi-trash-can-outline",onClick:ke},{default:t(()=>[...ge[79]||(ge[79]=[n(" Löschen ",-1)])]),_:1}),e(tt),e(it,{variant:"outlined",size:"small","prepend-icon":"mdi-content-copy",onClick:ge[19]||(ge[19]=Oe=>Pt(b.value.url))},{default:t(()=>[...ge[80]||(ge[80]=[n(" URL kopieren ",-1)])]),_:1}),e(it,{variant:"text",onClick:ee},{default:t(()=>[...ge[81]||(ge[81]=[n("Schließen",-1)])]),_:1})]),_:1})]),_:1})):U("",!0)]),_:1},8,["modelValue","persistent"]),e(zt,{modelValue:G.value,"onUpdate:modelValue":ge[22]||(ge[22]=Oe=>G.value=Oe),"max-width":"400"},{default:t(()=>[e(Be,null,{default:t(()=>[e(vt,{class:"pa-6 pb-4 text-subtitle-1"},{default:t(()=>[...ge[82]||(ge[82]=[n("Bild löschen?",-1)])]),_:1}),e(ze,{class:"pa-6 pt-0 text-body-2 text-medium-emphasis"},{default:t(()=>[...ge[83]||(ge[83]=[n(" Das Bild wird dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden. ",-1)])]),_:1}),e(kt,{class:"pa-4"},{default:t(()=>[e(tt),e(it,{variant:"text",onClick:ge[21]||(ge[21]=Oe=>G.value=!1)},{default:t(()=>[...ge[84]||(ge[84]=[n("Abbrechen",-1)])]),_:1}),e(it,{color:"error",variant:"elevated",loading:W.value,onClick:xe},{default:t(()=>[...ge[85]||(ge[85]=[n("Löschen",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(zt,{modelValue:F.value,"onUpdate:modelValue":ge[29]||(ge[29]=Oe=>F.value=Oe),"max-width":"480"},{default:t(()=>[e(Be,{class:"image-pool-view__dialog"},{default:t(()=>[e(vt,{class:"pa-5 pb-3"},{default:t(()=>[a("div",wV,[ge[88]||(ge[88]=a("span",{class:"text-h6"},"Bild hochladen",-1)),e(it,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:ge[23]||(ge[23]=Oe=>F.value=!1)},{default:t(()=>[e(et,{activator:"parent",location:"bottom"},{default:t(()=>[...ge[86]||(ge[86]=[n("Schließen",-1)])]),_:1}),e(at,null,{default:t(()=>[...ge[87]||(ge[87]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(De),e(ze,{class:"pa-5"},{default:t(()=>{var Oe,Ct;return[Q.value?(o(),N(yt,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":ge[24]||(ge[24]=Rt=>Q.value=null)},{default:t(()=>[n(v(Q.value),1)]),_:1})):U("",!0),a("div",{class:ft(["image-pool-view__upload-zone mb-4",{"image-pool-view__upload-zone--dragover":L.value}]),onDragover:Ue,onDragleave:ge[26]||(ge[26]=Rt=>L.value=!1),onDrop:Te},[z.value?(o(),h(be,{key:0},[e(pt,{src:z.value,alt:((Oe=A.value)==null?void 0:Oe.name)||"","max-height":"200",contain:"",class:"rounded mb-2"},null,8,["src","alt"]),a("p",SV,v((Ct=A.value)==null?void 0:Ct.name),1)],64)):(o(),h(be,{key:1},[e(at,{size:"40",color:"medium-emphasis",class:"mb-2"},{default:t(()=>[...ge[89]||(ge[89]=[n("mdi-image-plus-outline",-1)])]),_:1}),ge[91]||(ge[91]=a("p",{class:"text-body-2 text-medium-emphasis mb-2"},"Bild hierher ziehen oder",-1)),e(it,{variant:"outlined",size:"small","prepend-icon":"mdi-upload",onClick:ge[25]||(ge[25]=Rt=>{var qt;return(qt=s.value)==null?void 0:qt.click()})},{default:t(()=>[...ge[90]||(ge[90]=[n(" Datei auswählen ",-1)])]),_:1}),a("input",{ref_key:"uploadInput",ref:s,type:"file",accept:"image/*",style:{display:"none"},onChange:ye},null,544)],64))],34),e(we,{modelValue:j.value,"onUpdate:modelValue":ge[27]||(ge[27]=Rt=>j.value=Rt),label:"Tags (optional)",placeholder:"Tag eingeben und Enter drücken",variant:"outlined",density:"comfortable",multiple:"",chips:"","closable-chips":"","hide-no-data":""},null,8,["modelValue"])]}),_:1}),e(De),e(kt,{class:"pa-4"},{default:t(()=>[e(tt),e(it,{variant:"text",onClick:ge[28]||(ge[28]=Oe=>F.value=!1)},{default:t(()=>[...ge[92]||(ge[92]=[n("Abbrechen",-1)])]),_:1}),e(it,{color:"primary",variant:"elevated",loading:J.value,disabled:!A.value,"prepend-icon":"mdi-upload",onClick:Ke},{default:t(()=>[...ge[93]||(ge[93]=[n(" Hochladen ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(Et,{modelValue:u.value,"onUpdate:modelValue":ge[30]||(ge[30]=Oe=>u.value=Oe),timeout:2e3,color:"success",location:"bottom"},{default:t(()=>[...ge[94]||(ge[94]=[n(" URL in die Zwischenablage kopiert ",-1)])]),_:1},8,["modelValue"]),e(zt,{modelValue:te.value,"onUpdate:modelValue":ge[39]||(ge[39]=Oe=>te.value=Oe),"max-width":"720"},{default:t(()=>[e(Be,{class:"image-pool-view__dialog"},{default:t(()=>[e(vt,{class:"pa-5 pb-3"},{default:t(()=>[a("div",$V,[ge[97]||(ge[97]=a("span",{class:"text-h6"},"KI-Bild generieren",-1)),e(it,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:ge[31]||(ge[31]=Oe=>te.value=!1)},{default:t(()=>[e(et,{activator:"parent",location:"bottom"},{default:t(()=>[...ge[95]||(ge[95]=[n("Schließen",-1)])]),_:1}),e(at,null,{default:t(()=>[...ge[96]||(ge[96]=[n("mdi-close",-1)])]),_:1})]),_:1})])]),_:1}),e(De),e(ze,{class:"pa-5"},{default:t(()=>[oe.value?(o(),N(yt,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":ge[32]||(ge[32]=Oe=>oe.value=null)},{default:t(()=>[n(v(oe.value),1)]),_:1})):U("",!0),q.value?(o(),N(yt,{key:1,type:"warning",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":ge[33]||(ge[33]=Oe=>q.value=null)},{default:t(()=>[n(v(q.value),1)]),_:1})):U("",!0),pe.value.length?(o(),N(Ot,{key:2,"model-value":_e.value,items:[{title:"Kein Preset (manueller Prompt)",value:""},...pe.value.map(Oe=>({title:Oe.isDefault?`${Oe.name} (Standard)`:Oe.name,value:Oe._id}))],label:"Preset",variant:"outlined",density:"comfortable",class:"mb-4",hint:"Preset wählen füllt Prompt, Seitenverhältnis und Stil vor - tippen zum Filtern","persistent-hint":"","auto-select-first":"","hide-no-data":"","onUpdate:modelValue":ge[34]||(ge[34]=Oe=>lt(Oe??""))},null,8,["model-value","items"])):U("",!0),e(Bt,{modelValue:ve.value,"onUpdate:modelValue":ge[35]||(ge[35]=Oe=>ve.value=Oe),label:"Bildbeschreibung",placeholder:"z.B. Professionelles Foto einer Cybersecurity-Präsentation...",variant:"outlined",rows:"8","auto-grow":"",class:"mb-4"},null,8,["modelValue"]),e(he,null,{default:t(()=>[e(Qe,{cols:"12",sm:"6"},{default:t(()=>[e(We,{modelValue:de.value,"onUpdate:modelValue":ge[36]||(ge[36]=Oe=>de.value=Oe),label:"Seitenverhältnis",items:ae,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(Qe,{cols:"12",sm:"6"},{default:t(()=>[e(We,{modelValue:Z.value,"onUpdate:modelValue":ge[37]||(ge[37]=Oe=>Z.value=Oe),label:"Stil",items:X,variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),e(De),e(kt,{class:"pa-4"},{default:t(()=>[e(tt),e(it,{variant:"text",onClick:ge[38]||(ge[38]=Oe=>te.value=!1)},{default:t(()=>[...ge[98]||(ge[98]=[n("Abbrechen",-1)])]),_:1}),e(it,{color:"primary",variant:"elevated",loading:ce.value,disabled:!ve.value.trim(),"prepend-icon":"mdi-creation",onClick:ut},{default:t(()=>[...ge[99]||(ge[99]=[n(" Generieren ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}}),VV=Me(CV,[["__scopeId","data-v-906746eb"]]),B6=Object.freeze(Object.defineProperty({__proto__:null,default:VV},Symbol.toStringTag,{value:"Module"})),AV={class:"text-h6 font-weight-bold"},IV={key:0,class:"pa-3"},PV={key:0,class:"d-flex justify-center align-center",style:{height:"100%"}},zV={key:1,class:"d-flex justify-center align-center pa-8",style:{height:"100%"}},DV={class:"template-editor__editor"},TV={class:"pa-4"},LV={key:1,class:"mb-3"},EV=["textContent"],MV=["disabled"],NV={class:"template-editor__preview"},UV={class:"pa-4"},BV={key:0,class:"text-caption text-medium-emphasis"},FV=["textContent"],OV={class:"template-editor__preview-frame"},RV=["srcdoc"],KV=Ae({__name:"EmailTemplateEditDialog",props:aa({templateKey:{},isLocked:{type:Boolean,default:!1},isLockedByMe:{type:Boolean,default:!0},lockedBy:{default:null},lockedAt:{default:null},isLockTakenOver:{type:Boolean,default:!1},takenOverBy:{default:null},onTakeOver:{type:Function,default:void 0}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:aa(["saved"],["update:modelValue"]),setup(r,{emit:$}){const d=r,c=se(()=>d.isLocked&&!d.isLockedByMe||d.isLockTakenOver),s=["password-reset","password-changed","user-invite","contact-confirmation","admin-lead-notification"],m=se(()=>{var J;return!!((J=x.value)!=null&&J.isSystemTemplate&&x.value.templateKey&&s.includes(x.value.templateKey))}),u=$,f=ua(r,"modelValue"),p=ea(),_=y(!1),k=y(!1),i=y(!1),g=y(null),x=y(null),w=y(""),b=y(""),I=y(!0),V=y({}),E=y(null);let R="";const M=y({show:!1,text:"",color:"success"}),T=window.matchMedia("(max-width: 959px)"),D=y(T.matches);T.addEventListener("change",J=>{D.value=J.matches});const H=se(()=>x.value?JSON.stringify({subject:w.value,htmlContent:b.value,isActive:I.value})!==R:!1),O=y(""),S=y([]),B=y(!1);let G=null;async function W(){if(!(!d.templateKey||!x.value)){B.value=!0;try{const J=await re.post(`/admin/email-templates/${d.templateKey}/preview`,{testData:V.value,subject:w.value,htmlContent:b.value,layoutStyle:x.value.layoutStyle??"light"});J.success&&J.data?(O.value=J.data.html,S.value=J.data.unreplacedVariables):ue.error("ADMIN","Preview-Fehler",{error:J.error})}catch{ue.error("ADMIN","Netzwerkfehler beim Laden der Preview")}finally{B.value=!1}}}function F(){G&&clearTimeout(G),G=setTimeout(()=>{W()},400)}Ze([b,w,V],()=>{F()},{deep:!0});function L(J){const Q=E.value;if(!Q)return;const te=Q.selectionStart,ve=Q.selectionEnd,de=`{{${J}}}`;b.value=b.value.slice(0,te)+de+b.value.slice(ve),requestAnimationFrame(()=>{Q.focus(),Q.setSelectionRange(te+de.length,te+de.length)})}async function A(){if(d.templateKey){_.value=!0,g.value=null;try{const J=await re.get(`/admin/email-templates/${d.templateKey}`);if(J.success&&J.data){x.value=J.data,w.value=J.data.subject,b.value=J.data.htmlContent,I.value=J.data.isActive;const Q={};for(const te of J.data.variables)Q[te.name]=te.example||te.defaultValue||"";V.value=Q,R=JSON.stringify({subject:J.data.subject,htmlContent:J.data.htmlContent,isActive:J.data.isActive}),ue.debug("ADMIN","E-Mail-Template geladen",{key:d.templateKey}),W()}else g.value=J.error||"Fehler beim Laden des Templates",ue.error("ADMIN","E-Mail-Template Ladefehler",{key:d.templateKey,error:J.error})}catch{g.value="Netzwerkfehler beim Laden des Templates",ue.error("ADMIN","Netzwerkfehler beim Laden des E-Mail-Templates",{key:d.templateKey})}finally{_.value=!1}}}async function z(){if(x.value){if(c.value){ue.warn("ADMIN","Save blockiert - Read-Only-Modus durch Lock");return}k.value=!0;try{const J=await re.put(`/admin/email-templates/${x.value.templateKey}`,{subject:w.value,htmlContent:b.value,isActive:I.value});J.success?(R=JSON.stringify({subject:w.value,htmlContent:b.value,isActive:I.value}),M.value={show:!0,text:"Template gespeichert",color:"success"},ue.info("ADMIN","E-Mail-Template gespeichert",{key:x.value.templateKey}),u("saved")):(M.value={show:!0,text:J.error||"Fehler beim Speichern",color:"error"},ue.error("ADMIN","E-Mail-Template Speicherfehler",{error:J.error}))}catch{M.value={show:!0,text:"Netzwerkfehler beim Speichern",color:"error"},ue.error("ADMIN","Netzwerkfehler beim Speichern des E-Mail-Templates")}finally{k.value=!1}}}async function j(){var J;if(x.value){i.value=!0;try{const Q=await re.post(`/admin/email-templates/${x.value.templateKey}/send-test`,{testData:V.value,recipientEmail:((J=p.user)==null?void 0:J.email)||""});Q.success?(M.value={show:!0,text:"Test-E-Mail gesendet",color:"success"},ue.info("ADMIN","Test-E-Mail gesendet",{key:x.value.templateKey})):(M.value={show:!0,text:Q.error||"Fehler beim Senden der Test-E-Mail",color:"error"},ue.error("ADMIN","Test-E-Mail Sendefehler",{error:Q.error}))}catch{M.value={show:!0,text:"Netzwerkfehler beim Senden der Test-E-Mail",color:"error"},ue.error("ADMIN","Netzwerkfehler beim Senden der Test-E-Mail")}finally{i.value=!1}}}return Ze(f,J=>{J&&(x.value=null,g.value=null,A())}),(J,Q)=>{const te=l("v-icon"),ve=l("v-spacer"),de=l("v-tooltip"),Z=l("v-btn"),ce=l("v-card-title"),oe=l("v-divider"),pe=l("v-progress-circular"),_e=l("v-alert"),q=l("v-text-field"),C=l("v-chip"),ae=l("v-switch"),X=l("v-expansion-panel-title"),ie=l("v-expansion-panel-text"),fe=l("v-expansion-panel"),Se=l("v-expansion-panels"),me=l("v-card-text"),ee=l("v-card-actions"),Y=l("v-snackbar"),K=l("v-card"),le=l("v-dialog");return o(),N(le,{modelValue:f.value,"onUpdate:modelValue":Q[6]||(Q[6]=ne=>f.value=ne),fullscreen:D.value,"max-width":D.value?void 0:1200,scrollable:""},{default:t(()=>[e(K,{rounded:"lg",class:"template-editor"},{default:t(()=>[e(ce,{class:"d-flex align-center pa-4 pb-2"},{default:t(()=>{var ne;return[e(te,{class:"mr-2",size:"24"},{default:t(()=>[...Q[7]||(Q[7]=[n("mdi-email-edit-outline",-1)])]),_:1}),a("span",AV,v(((ne=x.value)==null?void 0:ne.name)||"Template bearbeiten"),1),e(ve),e(Z,{icon:"",variant:"text",size:"small","aria-label":"Dialog schließen",onClick:Q[0]||(Q[0]=Ce=>f.value=!1)},{default:t(()=>[e(de,{activator:"parent",location:"bottom"},{default:t(()=>[...Q[8]||(Q[8]=[n("Schließen",-1)])]),_:1}),e(te,null,{default:t(()=>[...Q[9]||(Q[9]=[n("mdi-close",-1)])]),_:1})]),_:1})]}),_:1}),e(oe),r.isLocked&&!r.isLockedByMe||r.isLockTakenOver?(o(),h("div",IV,[e(ia,{"is-locked":r.isLocked,"is-locked-by-me":r.isLockedByMe,"locked-by":r.lockedBy,"locked-at":r.lockedAt,"is-lock-taken-over":r.isLockTakenOver,"taken-over-by":r.takenOverBy,"on-take-over":r.onTakeOver??(async()=>!1)},null,8,["is-locked","is-locked-by-me","locked-by","locked-at","is-lock-taken-over","taken-over-by","on-take-over"])])):U("",!0),e(me,{class:"pa-0",style:ht({height:D.value?"calc(100vh - 140px)":"70vh"})},{default:t(()=>[_.value?(o(),h("div",PV,[e(pe,{indeterminate:"",color:"primary"})])):g.value?(o(),h("div",zV,[e(_e,{type:"error",variant:"tonal"},{default:t(()=>[n(v(g.value),1)]),_:1})])):x.value?(o(),h("div",{key:2,class:ft(["template-editor__layout",{"template-editor__layout--stacked":D.value}])},[a("div",DV,[a("div",TV,[x.value.description?(o(),N(_e,{key:0,type:"info",variant:"tonal",density:"compact",class:"mb-4"},{default:t(()=>[n(v(x.value.description),1)]),_:1})):U("",!0),e(q,{modelValue:w.value,"onUpdate:modelValue":Q[1]||(Q[1]=ne=>w.value=ne),label:"Betreff",variant:"outlined",density:"comfortable",class:"mb-4",disabled:c.value},null,8,["modelValue","disabled"]),x.value.variables.length>0?(o(),h("div",LV,[Q[10]||(Q[10]=a("span",{class:"text-caption text-medium-emphasis d-block mb-1"}," Variable einfügen (Klick setzt Cursor-Position): ",-1)),(o(!0),h(be,null,Pe(x.value.variables,ne=>(o(),N(C,{key:ne.name,size:"small",variant:"outlined",color:"primary",class:"mr-1 mb-1",style:{cursor:"pointer"},title:ne.description,onClick:Ce=>L(ne.name)},{default:t(()=>[a("span",{textContent:v("{{"+ne.name+"}}")},null,8,EV)]),_:2},1032,["title","onClick"]))),128))])):U("",!0),Q[11]||(Q[11]=a("label",{class:"text-caption text-medium-emphasis d-block mb-1"}," HTML-Inhalt ",-1)),za(a("textarea",{ref_key:"htmlEditorRef",ref:E,"onUpdate:modelValue":Q[2]||(Q[2]=ne=>b.value=ne),class:"template-editor__textarea",spellcheck:"false","aria-label":"HTML-Inhalt",disabled:c.value},null,8,MV),[[El,b.value]]),e(ae,{modelValue:I.value,"onUpdate:modelValue":Q[3]||(Q[3]=ne=>I.value=ne),label:m.value?"Template aktiv (geschützt)":"Template aktiv",color:"primary",density:"compact",class:"mt-3","hide-details":!m.value,messages:m.value?"Geschütztes System-Template - kann nicht deaktiviert werden (DSGVO/Auth-relevant)":void 0,disabled:c.value||m.value},null,8,["modelValue","label","hide-details","messages","disabled"])])]),a("div",NV,[a("div",UV,[e(Se,{variant:"accordion",class:"mb-4"},{default:t(()=>[e(fe,null,{default:t(()=>[e(X,null,{default:t(()=>[e(te,{size:"18",class:"mr-2"},{default:t(()=>[...Q[12]||(Q[12]=[n("mdi-test-tube",-1)])]),_:1}),Q[13]||(Q[13]=n(" Test-Daten für Vorschau ",-1))]),_:1}),e(ie,null,{default:t(()=>[(o(!0),h(be,null,Pe(x.value.variables,ne=>(o(),N(q,{key:ne.name,modelValue:V.value[ne.name],"onUpdate:modelValue":Ce=>V.value[ne.name]=Ce,label:ne.name,placeholder:ne.example||ne.defaultValue||"",hint:ne.description,"persistent-hint":"",variant:"outlined",density:"compact",class:"mb-2"},null,8,["modelValue","onUpdate:modelValue","label","placeholder","hint"]))),128)),x.value.variables.length===0?(o(),h("p",BV," Dieses Template hat keine Variablen. ")):U("",!0)]),_:1})]),_:1})]),_:1}),S.value.length>0?(o(),N(_e,{key:0,type:"warning",variant:"tonal",density:"compact",class:"mb-3"},{default:t(()=>[Q[14]||(Q[14]=n(" Nicht ersetzte Variablen: ",-1)),(o(!0),h(be,null,Pe(S.value,ne=>(o(),N(C,{key:ne,size:"x-small",class:"ml-1"},{default:t(()=>[a("span",{textContent:v("{{"+ne+"}}")},null,8,FV)]),_:2},1024))),128))]),_:1})):U("",!0),Q[15]||(Q[15]=a("span",{class:"text-caption text-medium-emphasis d-block mb-2"}," Live-Vorschau ",-1)),a("div",OV,[a("iframe",{srcdoc:O.value,class:"template-editor__iframe",sandbox:"allow-same-origin",title:"E-Mail-Vorschau"},null,8,RV)])])])],2)):U("",!0)]),_:1},8,["style"]),e(oe),e(ee,{class:"pa-4"},{default:t(()=>{var ne;return[(ne=x.value)!=null&&ne.isSystemTemplate?(o(),N(C,{key:0,size:"small",color:"info",variant:"tonal"},{default:t(()=>[...Q[16]||(Q[16]=[n(" System-Template ",-1)])]),_:1})):U("",!0),e(ve),e(Z,{variant:"text",onClick:Q[4]||(Q[4]=Ce=>f.value=!1)},{default:t(()=>[...Q[17]||(Q[17]=[n("Abbrechen",-1)])]),_:1}),e(Z,{variant:"outlined",loading:i.value,disabled:!x.value||_.value,onClick:j},{default:t(()=>[e(te,{start:""},{default:t(()=>[...Q[18]||(Q[18]=[n("mdi-email-fast-outline",-1)])]),_:1}),Q[19]||(Q[19]=n(" Test-E-Mail ",-1))]),_:1},8,["loading","disabled"]),e(Z,{color:"primary",variant:"elevated",loading:k.value,disabled:!H.value||c.value,onClick:z},{default:t(()=>[...Q[20]||(Q[20]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled"])]}),_:1}),e(Y,{modelValue:M.value.show,"onUpdate:modelValue":Q[5]||(Q[5]=ne=>M.value.show=ne),color:M.value.color,timeout:"4000",location:"bottom right"},{default:t(()=>[n(v(M.value.text),1)]),_:1},8,["modelValue","color"])]),_:1})]),_:1},8,["modelValue","fullscreen","max-width"])}}}),jV=Me(KV,[["__scopeId","data-v-46e1e8a6"]]),qV={class:"email-templates-view"},GV={class:"text-h5 font-weight-bold"},HV={class:"text-h5 font-weight-bold"},WV={class:"text-body-2 font-weight-medium"},ZV={class:"text-caption text-medium-emphasis"},JV={class:"d-flex align-center justify-space-between"},QV={class:"text-subtitle-1 font-weight-semibold"},YV={class:"email-templates-view__name"},XV={class:"text-body-2 font-weight-medium"},eA={class:"text-caption text-medium-emphasis d-block"},tA={class:"email-templates-view__subject text-body-2"},aA={class:"email-templates-view__vars"},lA={key:1,class:"text-caption text-medium-emphasis"},nA={class:"text-body-2 text-medium-emphasis"},oA={class:"py-16 text-center"},sA=Ae({__name:"EmailTemplatesView",setup(r){const $=y(!1),d=y(null),c=y([]),s=y({total:0,active:0,lastUpdated:null}),m=y(!1),u=y(""),f=y(null),p=se(()=>{var B;return((B=f.value)==null?void 0:B._id)??null}),{isLocked:_,isLockedByMe:k,lockedBy:i,lockedAt:g,isLockTakenOver:x,takenOverBy:w,takeOverLock:b}=sa("EmailTemplate",p),I=qe("admin_email_templates_search",""),V=qe("admin_email_templates_per_page",10),E=qe("admin_email_templates_sort",[]),R=[{title:"Name",key:"name",sortable:!0},{title:"Betreff",key:"subject",sortable:!0},{title:"Variablen",key:"variables",sortable:!1},{title:"Status",key:"isActive",sortable:!0},{title:"Aktualisiert",key:"updatedAt",sortable:!0},{title:"Erstellt",key:"createdBy",sortable:!1,width:80,align:"center"},{title:"Geändert",key:"updatedBy",sortable:!1,width:80,align:"center"},{title:"",key:"actions",sortable:!1,align:"end"}];function M(B){return B?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(B)):"–"}function T(B){return B?typeof B=="object"?B._id:B:null}function D(B){return B&&typeof B=="object"?B:null}function H(B){return!B.lockedBy||!B.lockHeartbeatAt?!1:Date.now()-new Date(B.lockHeartbeatAt).getTime()<90*1e3}function O(B){f.value=B,u.value=B.templateKey,m.value=!0}Ze(m,B=>{B||(f.value=null)});async function S(){$.value=!0,d.value=null;try{const B=await re.get("/admin/email-templates");B.success&&B.data?(c.value=B.data.templates,s.value=B.data.stats,ue.debug("ADMIN","E-Mail-Templates geladen",{total:B.data.stats.total})):(d.value=B.error||"Fehler beim Laden der E-Mail-Templates",ue.error("ADMIN","E-Mail-Templates Ladefehler",{error:B.error}))}catch{d.value="Netzwerkfehler beim Laden der E-Mail-Templates",ue.error("ADMIN","Netzwerkfehler beim Laden der E-Mail-Templates")}finally{$.value=!1}}return rt(()=>{S()}),(B,G)=>{const W=l("v-alert"),F=l("v-icon"),L=l("v-card-text"),A=l("v-card"),z=l("v-col"),j=l("v-row"),J=l("v-text-field"),Q=l("v-tooltip"),te=l("v-btn"),ve=l("v-card-title"),de=l("v-chip"),Z=l("v-data-table");return o(),h("div",qV,[G[17]||(G[17]=a("div",{class:"email-templates-view__header"},[a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"E-Mail-Templates"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," System-E-Mail-Vorlagen verwalten und anpassen ")])],-1)),d.value?(o(),N(W,{key:0,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":G[0]||(G[0]=ce=>d.value=null)},{default:t(()=>[n(v(d.value),1)]),_:1})):U("",!0),e(j,{class:"mb-6"},{default:t(()=>[e(z,{cols:"12",sm:"4"},{default:t(()=>[e(A,{variant:"outlined",rounded:"lg"},{default:t(()=>[e(L,{class:"d-flex align-center ga-3"},{default:t(()=>[e(F,{color:"primary",size:"28"},{default:t(()=>[...G[5]||(G[5]=[n("mdi-email-multiple",-1)])]),_:1}),a("div",null,[a("div",GV,v(s.value.total),1),G[6]||(G[6]=a("div",{class:"text-caption text-medium-emphasis"},"Gesamt",-1))])]),_:1})]),_:1})]),_:1}),e(z,{cols:"12",sm:"4"},{default:t(()=>[e(A,{variant:"outlined",rounded:"lg"},{default:t(()=>[e(L,{class:"d-flex align-center ga-3"},{default:t(()=>[e(F,{color:"success",size:"28"},{default:t(()=>[...G[7]||(G[7]=[n("mdi-check-circle",-1)])]),_:1}),a("div",null,[a("div",HV,v(s.value.active),1),G[8]||(G[8]=a("div",{class:"text-caption text-medium-emphasis"},"Aktiv",-1))])]),_:1})]),_:1})]),_:1}),e(z,{cols:"12",sm:"4"},{default:t(()=>[e(A,{variant:"outlined",rounded:"lg"},{default:t(()=>[e(L,{class:"d-flex align-center ga-3"},{default:t(()=>{var ce;return[e(F,{color:"info",size:"28"},{default:t(()=>[...G[9]||(G[9]=[n("mdi-clock-outline",-1)])]),_:1}),a("div",null,[a("div",WV,v(((ce=s.value.lastUpdated)==null?void 0:ce.user)||"-"),1),a("div",ZV,v(s.value.lastUpdated?M(s.value.lastUpdated.date):"Noch keine Änderung"),1)])]}),_:1})]),_:1})]),_:1})]),_:1}),e(J,{modelValue:P(I),"onUpdate:modelValue":G[1]||(G[1]=ce=>ot(I)?I.value=ce:null),"prepend-inner-icon":"mdi-magnify",label:"Templates durchsuchen...",variant:"outlined",density:"compact",clearable:"","hide-details":"",class:"mb-4 email-templates-view__search"},null,8,["modelValue"]),e(A,{variant:"outlined",rounded:"lg",class:"email-templates-view__table-card"},{default:t(()=>[e(ve,{class:"pa-4 pb-2"},{default:t(()=>[a("div",JV,[a("span",QV,v(c.value.length)+" Templates gesamt ",1),e(te,{icon:"",variant:"text",size:"small",loading:$.value,"aria-label":"Aktualisieren",onClick:S},{default:t(()=>[e(Q,{activator:"parent",location:"bottom"},{default:t(()=>[...G[10]||(G[10]=[n("Aktualisieren",-1)])]),_:1}),e(F,null,{default:t(()=>[...G[11]||(G[11]=[n("mdi-refresh",-1)])]),_:1})]),_:1},8,["loading"])])]),_:1}),e(Z,{headers:R,items:c.value,search:P(I),"items-per-page":P(V),"sort-by":P(E),loading:$.value,"loading-text":"E-Mail-Templates werden geladen...","no-data-text":"Keine E-Mail-Templates vorhanden","item-value":"templateKey",class:"email-templates-view__table","onUpdate:itemsPerPage":G[2]||(G[2]=ce=>V.value=ce),"onUpdate:sortBy":G[3]||(G[3]=ce=>E.value=ce)},{"item.name":t(({item:ce})=>[a("div",YV,[a("span",XV,v(ce.name),1),a("span",eA,v(ce.templateKey),1)])]),"item.subject":t(({item:ce})=>[a("span",tA,v(ce.subject),1)]),"item.variables":t(({item:ce})=>[a("div",aA,[(o(!0),h(be,null,Pe(ce.variables.slice(0,3),oe=>(o(),N(de,{key:oe.name,size:"x-small",class:"mr-1 mb-1",variant:"outlined"},{default:t(()=>[n(v(oe.name),1)]),_:2},1024))),128)),ce.variables.length>3?(o(),N(de,{key:0,size:"x-small",variant:"tonal"},{default:t(()=>[n(" +"+v(ce.variables.length-3),1)]),_:2},1024)):U("",!0),ce.variables.length===0?(o(),h("span",lA," Keine ")):U("",!0)])]),"item.isActive":t(({item:ce})=>[e(de,{color:ce.isActive?"success":"default",size:"small",variant:"tonal"},{default:t(()=>[n(v(ce.isActive?"Aktiv":"Inaktiv"),1)]),_:2},1032,["color"])]),"item.updatedAt":t(({item:ce})=>[a("span",nA,v(M(ce.updatedAt)),1)]),"item.createdBy":t(({item:ce})=>[e(gt,{"user-id":T(ce.createdBy),populated:D(ce.createdBy),locked:H(ce),"locked-by":D(ce.lockedBy)},null,8,["user-id","populated","locked","locked-by"])]),"item.updatedBy":t(({item:ce})=>[e(gt,{"user-id":T(ce.updatedBy),populated:D(ce.updatedBy),locked:H(ce),"locked-by":D(ce.lockedBy)},null,8,["user-id","populated","locked","locked-by"])]),"item.actions":t(({item:ce})=>[e(te,{icon:"",variant:"text",size:"small","aria-label":"Template bearbeiten",onClick:oe=>O(ce)},{default:t(()=>[e(Q,{activator:"parent",location:"bottom"},{default:t(()=>[...G[12]||(G[12]=[n("Template bearbeiten",-1)])]),_:1}),e(F,null,{default:t(()=>[...G[13]||(G[13]=[n("mdi-pencil",-1)])]),_:1})]),_:1},8,["onClick"])]),"no-data":t(()=>[a("div",oA,[e(F,{size:"64",color:"grey-darken-1",class:"mb-4"},{default:t(()=>[...G[14]||(G[14]=[n("mdi-email-outline",-1)])]),_:1}),G[15]||(G[15]=a("p",{class:"text-h6 text-medium-emphasis mb-2"},"Keine E-Mail-Templates vorhanden",-1)),G[16]||(G[16]=a("p",{class:"text-body-2 text-medium-emphasis"}," E-Mail-Templates werden vom System beim Start angelegt. ",-1))])]),_:1},8,["items","search","items-per-page","sort-by","loading"])]),_:1}),e(jV,{modelValue:m.value,"onUpdate:modelValue":G[4]||(G[4]=ce=>m.value=ce),"template-key":u.value,"is-locked":P(_),"is-locked-by-me":P(k),"locked-by":P(i),"locked-at":P(g),"is-lock-taken-over":P(x),"taken-over-by":P(w),"on-take-over":P(b),onSaved:S},null,8,["modelValue","template-key","is-locked","is-locked-by-me","locked-by","locked-at","is-lock-taken-over","taken-over-by","on-take-over"])])}}}),iA=Me(sA,[["__scopeId","data-v-6d514c20"]]),F6=Object.freeze(Object.defineProperty({__proto__:null,default:iA},Symbol.toStringTag,{value:"Module"})),rA={key:0,class:"d-flex justify-center pa-6"},dA={key:1,class:"text-center text-medium-emphasis pa-6"},uA={class:"text-truncate"},cA={key:0,class:"text-medium-emphasis"},mA={key:3,class:"d-flex justify-center mt-4"},Ia=12,vA=Ae({__name:"GatedContentFilePickerDialog",props:{modelValue:{type:Boolean}},emits:["update:modelValue","select"],setup(r,{emit:$}){const d=r,c=$,s=se({get:()=>d.modelValue,set:V=>c("update:modelValue",V)}),m=y([]),u=y(!1),f=y(""),p=y(1);function _(){p.value=1}async function k(){u.value=!0;try{const V=await re.get("/admin/gated-content");V.success&&Array.isArray(V.data)?m.value=V.data.filter(E=>E.file&&E.file.filename&&E.file.mimeType):m.value=[]}catch{m.value=[]}finally{u.value=!1}}const i=se(()=>{var E;const V=((E=f.value)==null?void 0:E.trim().toLowerCase())??"";return V?m.value.filter(R=>{var D;const M=(R.title||"").toLowerCase(),T=(((D=R.file)==null?void 0:D.filename)||"").toLowerCase();return M.includes(V)||T.includes(V)}):m.value}),g=se(()=>Math.max(1,Math.ceil(i.value.length/Ia))),x=se(()=>{const V=(p.value-1)*Ia;return i.value.slice(V,V+Ia)});Ze(i,()=>{p.value>g.value&&(p.value=1)}),Ze(s,V=>{V&&(p.value=1,f.value="",k())});function w(V){return V==="application/zip"?"mdi-folder-zip-outline":"mdi-file-pdf-box"}function b(V){if(!V||V<=0)return"0 KB";const E=V/1024;return E<1024?`${E.toFixed(0)} KB`:`${(E/1024).toFixed(1)} MB`}function I(V){V.file&&(c("select",{gatedContentId:V._id,filename:V.file.filename,mimeType:V.file.mimeType,sizeBytes:V.file.sizeBytes}),s.value=!1)}return(V,E)=>{const R=l("v-btn"),M=l("v-card-title"),T=l("v-text-field"),D=l("v-progress-circular"),H=l("v-img"),O=l("v-avatar"),S=l("v-icon"),B=l("v-list-item-title"),G=l("v-chip"),W=l("v-list-item-subtitle"),F=l("v-list-item"),L=l("v-list"),A=l("v-pagination"),z=l("v-card-text"),j=l("v-card"),J=l("v-dialog");return o(),N(J,{modelValue:s.value,"onUpdate:modelValue":E[3]||(E[3]=Q=>s.value=Q),"max-width":"900",scrollable:""},{default:t(()=>[e(j,null,{default:t(()=>[e(M,{class:"d-flex align-center justify-space-between"},{default:t(()=>[E[4]||(E[4]=a("span",null,"Bestehenden Download wählen",-1)),e(R,{icon:"mdi-close",variant:"text",onClick:E[0]||(E[0]=Q=>s.value=!1)})]),_:1}),e(z,null,{default:t(()=>[e(T,{modelValue:f.value,"onUpdate:modelValue":[E[1]||(E[1]=Q=>f.value=Q),_],label:"Suche (Titel, Dateiname)",variant:"outlined",density:"compact","prepend-inner-icon":"mdi-magnify",clearable:""},null,8,["modelValue"]),u.value?(o(),h("div",rA,[e(D,{indeterminate:"",color:"primary"})])):i.value.length===0?(o(),h("div",dA," Keine Downloads gefunden. ")):(o(),N(L,{key:2,lines:"two",density:"comfortable",class:"pa-0"},{default:t(()=>[(o(!0),h(be,null,Pe(x.value,Q=>(o(),N(F,{key:Q._id,class:"gated-content-picker__item mb-2",rounded:"lg",border:"",onClick:te=>I(Q)},{prepend:t(()=>[Q.previewImage?(o(),N(O,{key:0,rounded:"lg",size:"56",class:"mr-2"},{default:t(()=>[e(H,{src:Q.previewImage,cover:""},null,8,["src"])]),_:2},1024)):(o(),N(O,{key:1,rounded:"lg",size:"56",color:"surface-variant",class:"mr-2"},{default:t(()=>[e(S,{size:"28"},{default:t(()=>{var te;return[n(v(w((te=Q.file)==null?void 0:te.mimeType)),1)]}),_:2},1024)]),_:2},1024))]),default:t(()=>[e(B,{class:"font-weight-medium"},{default:t(()=>{var te;return[n(v(Q.title||((te=Q.file)==null?void 0:te.filename)||"(ohne Titel)"),1)]}),_:2},1024),e(W,{class:"d-flex align-center ga-2 flex-wrap"},{default:t(()=>{var te,ve;return[e(S,{size:"14"},{default:t(()=>{var de;return[n(v(w((de=Q.file)==null?void 0:de.mimeType)),1)]}),_:2},1024),a("span",uA,v(((te=Q.file)==null?void 0:te.filename)||"-"),1),(ve=Q.file)!=null&&ve.sizeBytes?(o(),h("span",cA," · "+v(b(Q.file.sizeBytes)),1)):U("",!0),Q.isActive?U("",!0):(o(),N(G,{key:1,size:"x-small",variant:"tonal",color:"warning"},{default:t(()=>[...E[5]||(E[5]=[n(" inaktiv ",-1)])]),_:1}))]}),_:2},1024)]),_:2},1032,["onClick"]))),128))]),_:1})),g.value>1?(o(),h("div",mA,[e(A,{modelValue:p.value,"onUpdate:modelValue":E[2]||(E[2]=Q=>p.value=Q),length:g.value,density:"compact"},null,8,["modelValue","length"])])):U("",!0)]),_:1})]),_:1})]),_:1},8,["modelValue"])}}}),pA=Me(vA,[["__scopeId","data-v-4205607c"]]),fA={class:"text-h6 font-weight-bold"},gA={key:0,class:"d-flex justify-center py-12"},bA={key:1,class:"text-body-2 text-medium-emphasis mb-1 d-flex align-center ga-1"},yA={class:"d-flex align-center ga-2"},_A={class:"flex-grow-1"},kA={class:"text-body-2 font-weight-medium"},hA={class:"text-caption text-medium-emphasis"},xA={key:4,class:"gated-content-dialog__or-divider mb-3"},wA={key:0,class:"d-flex justify-center py-8"},SA={class:"mb-6"},$A={class:"mb-3"},CA={class:"d-flex justify-space-between text-caption text-medium-emphasis mb-1"},VA={class:"mb-3"},AA={class:"d-flex justify-space-between text-caption text-medium-emphasis mb-1"},IA={class:"d-flex justify-space-between text-caption text-medium-emphasis mb-1"},PA=Ae({__name:"GatedContentDialog",props:aa({contentId:{}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:aa(["saved"],["update:modelValue"]),setup(r,{emit:$}){const d=r,c=$,s=ua(r,"modelValue"),m=se(()=>!!d.contentId),u=y(!1),f=y(!1),p=y(!1),_=y(null),k=y("general"),i=wt({title:"",slug:"",description:"",emailTemplateKey:"",isActive:!0,formFields:{requirePhone:!1,requireCompany:!1,customConsentText:""}}),g=y(null),x=y(null),w=y(null),b=y(null),I=y(null),V=y(!1),E=y(null),R=y(null),M=y([]),T=y({stats:{views:0,submissions:0,downloads:0},downloads:[]}),D=qe("gated_content_downloads_sort",[]),H=qe("gated_content_downloads_per_page",10),O=[{title:"Name",key:"leadId",sortable:!0},{title:"Datum",key:"downloadedAt",sortable:!0},{title:"Quelle",key:"source",sortable:!0}],S=se(()=>T.value.stats.views?Math.round(T.value.stats.submissions/T.value.stats.views*100):0),B=se(()=>T.value.stats.views?T.value.stats.submissions/T.value.stats.views*100:0),G=se(()=>T.value.stats.views?T.value.stats.downloads/T.value.stats.views*100:0);function W(X){return X==="application/zip"?"mdi-folder-zip-outline":"mdi-file-pdf-box"}const F=se(()=>W(I.value)),L=se(()=>{const X=C(g.value);return X?X.type==="application/zip"||X.name.toLowerCase().endsWith(".zip")?"mdi-folder-zip-outline":"mdi-file-pdf-box":F.value});function A(X){return X?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(X)):"-"}function z(X){if(!X.leadId)return"-";const ie=[X.leadId.firstName,X.leadId.lastName].filter(Boolean);return ie.length?ie.join(" "):"-"}function j(X){var ie,fe;return((fe=(ie=X.source)==null?void 0:ie.utm)==null?void 0:fe.source)||"-"}function J(){i.title="",i.slug="",i.description="",i.emailTemplateKey="",i.isActive=!0,i.formFields.requirePhone=!1,i.formFields.requireCompany=!1,i.formFields.customConsentText="",g.value=null,x.value=null,w.value=null,b.value=null,I.value=null,E.value=null,R.value=null,V.value=!1,_.value=null,k.value="general",T.value={stats:{views:0,submissions:0,downloads:0},downloads:[]}}function Q(){E.value=null,R.value=null}function te(X){E.value=X.gatedContentId,R.value={filename:X.filename,mimeType:X.mimeType,sizeBytes:X.sizeBytes},g.value=null}function ve(X){if(!X||X<=0)return"0 KB";const ie=X/1024;return ie<1024?`${ie.toFixed(0)} KB`:`${(ie/1024).toFixed(1)} MB`}function de(X){return X==="application/zip"?"mdi-folder-zip-outline":"mdi-file-pdf-box"}const Z=se(()=>!!C(g.value)),ce=se(()=>!!E.value),oe=se(()=>u.value?!0:m.value?!1:!Z.value&&!ce.value);Ze(()=>i.title,X=>{m.value||(i.slug=X.toLowerCase().replace(/[äÄ]/g,"ae").replace(/[öÖ]/g,"oe").replace(/[üÜ]/g,"ue").replace(/ß/g,"ss").replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))});async function pe(){if(!d.contentId){J();return}u.value=!0;try{const X=await re.get(`/admin/gated-content/${d.contentId}`);if(X.success&&X.data){const ie=X.data;i.title=ie.title||"",i.slug=ie.slug||"",i.description=ie.description||"",i.emailTemplateKey=ie.emailTemplateKey||"",i.isActive=ie.isActive!==!1;const fe=ie.formFields;i.formFields.requirePhone=!!(fe!=null&&fe.requirePhone),i.formFields.requireCompany=!!(fe!=null&&fe.requireCompany),i.formFields.customConsentText=(fe==null?void 0:fe.customConsentText)||"",g.value=null,x.value=null,w.value=ie.previewImage||null;const Se=ie.file;b.value=(Se==null?void 0:Se.filename)||null,I.value=(Se==null?void 0:Se.mimeType)||null,_.value=null,k.value="general"}else _.value=X.error||"Fehler beim Laden des Inhalts"}catch{_.value="Netzwerkfehler beim Laden"}finally{u.value=!1}}async function _e(){if(d.contentId){p.value=!0;try{const X=await re.get(`/admin/gated-content/${d.contentId}/stats`);X.success&&X.data&&(T.value=X.data)}catch{}finally{p.value=!1}}}async function q(){try{const X=await re.get("/admin/email-templates");if(X.success&&X.data){const ie=X.data;Array.isArray(ie)?M.value=ie:ie&&"templates"in ie&&Array.isArray(ie.templates)&&(M.value=ie.templates)}}catch{}}function C(X){return X?Array.isArray(X)?X.length>0?X[0]:null:X:null}async function ae(){if(!i.title.trim()||!i.slug.trim()){_.value="Titel und Slug sind Pflichtfelder.";return}if(!m.value&&!C(g.value)&&!E.value){_.value="Bitte eine PDF- oder ZIP-Datei auswählen oder einen bestehenden Download als Quelle wählen.";return}f.value=!0,_.value=null;try{if(m.value){const X=await re.put(`/admin/gated-content/${d.contentId}`,{title:i.title,slug:i.slug,description:i.description,emailTemplateKey:i.emailTemplateKey,isActive:i.isActive,formFields:{requirePhone:i.formFields.requirePhone,requireCompany:i.formFields.requireCompany,customConsentText:i.formFields.customConsentText}});if(!X.success){_.value=X.error||"Fehler beim Speichern";return}const ie=C(g.value);if(ie){const Se=new FormData;Se.append("file",ie);const me=await re.upload(`/admin/gated-content/${d.contentId}/file`,Se);if(!me.success){_.value=me.error||"Fehler beim Hochladen der Datei";return}}const fe=C(x.value);if(fe){const Se=new FormData;Se.append("file",fe);const me=await re.upload(`/admin/gated-content/${d.contentId}/preview`,Se);if(!me.success){_.value=me.error||"Fehler beim Hochladen des Vorschaubilds";return}}}else{const X=new FormData,ie=C(g.value),fe=!ie&&!!E.value,Se={title:i.title,slug:i.slug,description:i.description,emailTemplateKey:i.emailTemplateKey,isActive:i.isActive,formFields:{requirePhone:i.formFields.requirePhone,requireCompany:i.formFields.requireCompany,customConsentText:i.formFields.customConsentText}};fe&&(Se.copyFromGatedContentId=E.value),X.append("metadata",JSON.stringify(Se)),ie&&X.append("file",ie);const me=C(x.value);me&&X.append("preview",me);const ee=await re.upload("/admin/gated-content",X);if(!ee.success){_.value=ee.error||"Fehler beim Erstellen";return}}c("saved"),s.value=!1}catch{_.value="Netzwerkfehler beim Speichern"}finally{f.value=!1}}return Ze(s,X=>{X&&(pe(),q())}),Ze(k,X=>{X==="stats"&&m.value&&_e()}),(X,ie)=>{const fe=l("v-icon"),Se=l("v-spacer"),me=l("v-tooltip"),ee=l("v-btn"),Y=l("v-card-title"),K=l("v-divider"),le=l("v-progress-circular"),ne=l("v-tab"),Ce=l("v-tabs"),ke=l("v-alert"),xe=l("v-text-field"),Ne=l("v-textarea"),Ie=l("v-file-input"),Ue=l("v-img"),Te=l("v-select"),ye=l("v-switch"),Je=l("v-tabs-window-item"),Ke=l("v-progress-linear"),$e=l("v-data-table"),Ee=l("v-tabs-window"),lt=l("v-card-text"),ut=l("v-card-actions"),Ve=l("v-card"),Le=l("v-dialog");return o(),N(Le,{modelValue:s.value,"onUpdate:modelValue":ie[19]||(ie[19]=Ye=>s.value=Ye),"max-width":"900",scrollable:""},{default:t(()=>[e(Ve,{rounded:"lg",class:"gated-content-dialog"},{default:t(()=>[e(Y,{class:"d-flex align-center pa-4 pb-2"},{default:t(()=>[e(fe,{class:"mr-2",size:"24"},{default:t(()=>[...ie[20]||(ie[20]=[n("mdi-file-download-outline",-1)])]),_:1}),a("span",fA,v(m.value?"Download bearbeiten":"Neuer Download"),1),e(Se),e(ee,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:ie[0]||(ie[0]=Ye=>s.value=!1)},{default:t(()=>[e(me,{activator:"parent",location:"bottom"},{default:t(()=>[...ie[21]||(ie[21]=[n("Schließen",-1)])]),_:1}),e(fe,null,{default:t(()=>[...ie[22]||(ie[22]=[n("mdi-close",-1)])]),_:1})]),_:1})]),_:1}),e(K),e(lt,{class:"pa-0",style:{"max-height":"70vh"}},{default:t(()=>[u.value?(o(),h("div",gA,[e(le,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:1},[e(Ce,{modelValue:k.value,"onUpdate:modelValue":ie[1]||(ie[1]=Ye=>k.value=Ye),class:"gated-content-dialog__tabs"},{default:t(()=>[e(ne,{value:"general"},{default:t(()=>[...ie[23]||(ie[23]=[n("Allgemein",-1)])]),_:1}),e(ne,{value:"form"},{default:t(()=>[...ie[24]||(ie[24]=[n("Formular",-1)])]),_:1}),m.value?(o(),N(ne,{key:0,value:"stats"},{default:t(()=>[...ie[25]||(ie[25]=[n("Statistiken",-1)])]),_:1})):U("",!0)]),_:1},8,["modelValue"]),e(K),e(Ee,{modelValue:k.value,"onUpdate:modelValue":ie[16]||(ie[16]=Ye=>k.value=Ye)},{default:t(()=>[e(Je,{value:"general",class:"pa-4"},{default:t(()=>[_.value?(o(),N(ke,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":ie[2]||(ie[2]=Ye=>_.value=null)},{default:t(()=>[n(v(_.value),1)]),_:1})):U("",!0),e(xe,{modelValue:i.title,"onUpdate:modelValue":ie[3]||(ie[3]=Ye=>i.title=Ye),label:"Titel *",variant:"outlined",class:"mb-3"},null,8,["modelValue"]),e(xe,{modelValue:i.slug,"onUpdate:modelValue":ie[4]||(ie[4]=Ye=>i.slug=Ye),label:"Slug *",hint:"URL-Pfad: /download/mein-slug","persistent-hint":"",variant:"outlined",class:"mb-3"},null,8,["modelValue"]),e(Ne,{modelValue:i.description,"onUpdate:modelValue":ie[5]||(ie[5]=Ye=>i.description=Ye),label:"Beschreibung",rows:"3",variant:"outlined",class:"mb-3"},null,8,["modelValue"]),m.value&&b.value&&!C(g.value)?(o(),h("div",bA,[e(fe,{size:"18"},{default:t(()=>[n(v(F.value),1)]),_:1}),a("span",null,"Aktuelle Datei: "+v(b.value),1)])):U("",!0),!m.value&&ce.value&&R.value?(o(),N(ke,{key:2,type:"info",variant:"tonal",density:"compact",class:"mb-3"},{default:t(()=>[a("div",yA,[e(fe,{size:"20"},{default:t(()=>[n(v(de(R.value.mimeType)),1)]),_:1}),a("div",_A,[a("div",kA," Datei wird kopiert aus: "+v(R.value.filename),1),a("div",hA,v(ve(R.value.sizeBytes)),1)]),e(ee,{icon:"mdi-close",size:"small",variant:"text","aria-label":"Auswahl entfernen",onClick:Q})])]),_:1})):U("",!0),m.value||!ce.value?(o(),N(Ie,{key:3,modelValue:g.value,"onUpdate:modelValue":ie[6]||(ie[6]=Ye=>g.value=Ye),label:m.value?"Datei (PDF oder ZIP) *":"Datei hochladen (PDF oder ZIP)",accept:"application/pdf,application/zip,.pdf,.zip","prepend-icon":"","prepend-inner-icon":L.value,variant:"outlined",hint:m.value?"Leer lassen um bestehende Datei beizubehalten (PDF oder ZIP, max. 100 MB)":"PDF oder ZIP, max. 100 MB","persistent-hint":"",class:"mb-3"},null,8,["modelValue","label","prepend-inner-icon","hint"])):U("",!0),!m.value&&!ce.value&&!Z.value?(o(),h("div",xA,[e(K),ie[26]||(ie[26]=a("span",{class:"gated-content-dialog__or-label text-caption text-medium-emphasis"},"ODER",-1))])):U("",!0),!m.value&&!ce.value&&!Z.value?(o(),N(ee,{key:5,variant:"outlined","prepend-icon":"mdi-content-copy",block:"",class:"mb-3",onClick:ie[7]||(ie[7]=Ye=>V.value=!0)},{default:t(()=>[...ie[27]||(ie[27]=[n(" Aus bestehendem Download kopieren ",-1)])]),_:1})):U("",!0),m.value&&w.value&&!C(x.value)?(o(),N(Ue,{key:6,src:w.value,"max-height":"120","max-width":"200",rounded:"lg",class:"mb-2 border"},null,8,["src"])):U("",!0),e(Ie,{modelValue:x.value,"onUpdate:modelValue":ie[8]||(ie[8]=Ye=>x.value=Ye),label:"Vorschaubild",accept:"image/*","prepend-icon":"","prepend-inner-icon":"mdi-image",variant:"outlined",hint:m.value?"Leer lassen um bestehendes Bild beizubehalten":"Optional. Wird als Vorschau auf der Karte angezeigt.","persistent-hint":"",class:"mb-3"},null,8,["modelValue","hint"]),e(Te,{modelValue:i.emailTemplateKey,"onUpdate:modelValue":ie[9]||(ie[9]=Ye=>i.emailTemplateKey=Ye),items:M.value,"item-title":"name","item-value":"templateKey",label:"E-Mail-Template",variant:"outlined",hint:"Template für die Download-Link E-Mail","persistent-hint":"",clearable:"",class:"mb-3"},null,8,["modelValue","items"]),e(ye,{modelValue:i.isActive,"onUpdate:modelValue":ie[10]||(ie[10]=Ye=>i.isActive=Ye),label:"Aktiv (öffentlich zugänglich)",color:"primary","hide-details":""},null,8,["modelValue"])]),_:1}),e(Je,{value:"form",class:"pa-4"},{default:t(()=>[ie[29]||(ie[29]=a("p",{class:"text-body-2 text-medium-emphasis mb-2"}," Konfiguriere welche Felder im Lead-Formular angezeigt werden. ",-1)),e(ke,{type:"info",variant:"tonal",density:"compact",class:"mb-4",icon:"mdi-auto-fix"},{default:t(()=>[...ie[28]||(ie[28]=[n(" Beim Speichern wird automatisch ein passendes Download-Formular-Preset erzeugt und bei späteren Änderungen synchron gehalten. ",-1)])]),_:1}),e(ye,{modelValue:i.formFields.requirePhone,"onUpdate:modelValue":ie[11]||(ie[11]=Ye=>i.formFields.requirePhone=Ye),label:"Telefon-Feld anzeigen und als Pflichtfeld markieren",color:"primary",hint:"Besucher müssen ihre Telefonnummer angeben.","persistent-hint":"",class:"mb-4"},null,8,["modelValue"]),e(ye,{modelValue:i.formFields.requireCompany,"onUpdate:modelValue":ie[12]||(ie[12]=Ye=>i.formFields.requireCompany=Ye),label:"Unternehmen-Feld anzeigen und als Pflichtfeld markieren",color:"primary",hint:"Besucher müssen ihr Unternehmen angeben.","persistent-hint":"",class:"mb-4"},null,8,["modelValue"]),e(Ne,{modelValue:i.formFields.customConsentText,"onUpdate:modelValue":ie[13]||(ie[13]=Ye=>i.formFields.customConsentText=Ye),label:"Eigener Datenschutz-Hinweistext",rows:"3",variant:"outlined",hint:"Leer lassen für Standard-Text. Überschreibt den Standard-Datenschutz-Text im Formular.","persistent-hint":""},null,8,["modelValue"])]),_:1}),m.value?(o(),N(Je,{key:0,value:"stats",class:"pa-4"},{default:t(()=>[p.value?(o(),h("div",wA,[e(le,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:1},[a("div",SA,[ie[33]||(ie[33]=a("h4",{class:"text-subtitle-1 font-weight-bold mb-4"},"Conversion-Funnel",-1)),a("div",$A,[a("div",CA,[ie[30]||(ie[30]=a("span",null,"Seitenaufrufe",-1)),a("span",null,v(T.value.stats.views),1)]),e(Ke,{"model-value":100,color:"primary",height:"8",rounded:""})]),a("div",VA,[a("div",AA,[ie[31]||(ie[31]=a("span",null,"Leads (Formular ausgefüllt)",-1)),a("span",null,v(T.value.stats.submissions)+" ("+v(S.value)+"%)",1)]),e(Ke,{"model-value":B.value,color:"success",height:"8",rounded:""},null,8,["model-value"])]),a("div",null,[a("div",IA,[ie[32]||(ie[32]=a("span",null,"Downloads",-1)),a("span",null,v(T.value.stats.downloads),1)]),e(Ke,{"model-value":G.value,color:"info",height:"8",rounded:""},null,8,["model-value"])])]),a("div",null,[ie[35]||(ie[35]=a("h4",{class:"text-subtitle-1 font-weight-bold mb-3"},"Download-Verlauf",-1)),e($e,{headers:O,items:T.value.downloads,"items-per-page":P(H),"onUpdate:itemsPerPage":ie[14]||(ie[14]=Ye=>ot(H)?H.value=Ye:null),"sort-by":P(D),density:"compact","onUpdate:sortBy":ie[15]||(ie[15]=Ye=>D.value=Ye)},{"item.leadId":t(({item:Ye})=>[n(v(z(Ye)),1)]),"item.downloadedAt":t(({item:Ye})=>[n(v(A(Ye.downloadedAt)),1)]),"item.source":t(({item:Ye})=>[n(v(j(Ye)),1)]),"no-data":t(()=>[...ie[34]||(ie[34]=[a("span",{class:"text-caption text-medium-emphasis"},"Noch keine Downloads vorhanden.",-1)])]),_:1},8,["items","items-per-page","sort-by"])])],64))]),_:1})):U("",!0)]),_:1},8,["modelValue"])],64))]),_:1}),e(K),e(ut,{class:"pa-4"},{default:t(()=>[e(Se),e(ee,{variant:"text",onClick:ie[17]||(ie[17]=Ye=>s.value=!1)},{default:t(()=>[...ie[36]||(ie[36]=[n("Abbrechen",-1)])]),_:1}),e(ee,{color:"primary",variant:"flat",loading:f.value,disabled:oe.value,onClick:ae},{default:t(()=>[n(v(m.value?"Speichern":"Erstellen"),1)]),_:1},8,["loading","disabled"])]),_:1})]),_:1}),e(pA,{modelValue:V.value,"onUpdate:modelValue":ie[18]||(ie[18]=Ye=>V.value=Ye),onSelect:te},null,8,["modelValue"])]),_:1},8,["modelValue"])}}}),zA=Me(PA,[["__scopeId","data-v-84fff0d1"]]),DA={class:"gated-content-list-view"},TA={class:"gated-content-list-view__header"},LA={class:"d-flex align-center ga-2"},EA={key:1,class:"d-flex justify-center py-12"},MA={key:1,class:"d-flex align-center justify-center bg-grey-darken-4 gated-content-list-view__placeholder"},NA={class:"d-flex align-center ga-2 mb-2 flex-wrap"},UA={class:"text-body-1 font-weight-bold"},BA={class:"text-caption text-medium-emphasis mb-2"},FA={key:0,class:"text-caption text-medium-emphasis mb-2 d-flex align-center ga-1"},OA=["title"],RA={key:0,class:"text-medium-emphasis"},KA={class:"text-caption text-medium-emphasis mb-2"},jA={key:0},qA={class:"text-caption text-medium-emphasis"},GA={class:"d-flex align-center ga-2 mt-2 pt-2",style:{"border-top":"1px solid rgba(255,255,255,0.06)"}},HA={class:"text-caption text-medium-emphasis ml-1"},WA=["title"],ZA={class:"text-caption"},JA={class:"d-flex flex-column"},QA={class:"text-body-2"},YA={class:"text-caption text-medium-emphasis"},XA={class:"text-caption"},eI={key:0},tI={key:1},aI=Ae({__name:"GatedContentListView",setup(r){const $=y(!1),d=y(null),c=y([]),s=y(""),m=qe("gated_content_only_mine",!1),u=y(!1),f=y(null),p=y("magnets"),_=y(!1),k=y(null),i=y("delete"),g=y(!1),x=y(null),w=se(()=>{if(!s.value)return c.value;const z=s.value.toLowerCase();return c.value.filter(j=>j.title.toLowerCase().includes(z)||j.slug.toLowerCase().includes(z))}),b=se(()=>c.value.filter(z=>{var j;return(j=z.file)==null?void 0:j.filename})),I=se(()=>{if(!s.value)return b.value;const z=s.value.toLowerCase();return b.value.filter(j=>{var J;return j.title.toLowerCase().includes(z)||j.slug.toLowerCase().includes(z)||(((J=j.file)==null?void 0:J.filename)??"").toLowerCase().includes(z)})}),V=[{title:"Typ",key:"file.mimeType",sortable:!0,width:70},{title:"Dateiname",key:"file.filename",sortable:!0},{title:"Größe",key:"file.sizeBytes",sortable:!0,align:"end",width:110},{title:"Lead-Magnet",key:"title",sortable:!0},{title:"Status",key:"isActive",sortable:!0,width:110},{title:"Erstellt",key:"createdAt",sortable:!0,width:130}];function E(z){return z?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(new Date(z)):"-"}function R(z){var J;return(J=z.stats)!=null&&J.views?` (${Math.round((z.stats.submissions||0)/z.stats.views*100)}% Conversion)`:""}function M(z){var j;return((j=z.file)==null?void 0:j.mimeType)==="application/zip"?"mdi-folder-zip-outline":"mdi-file-pdf-box"}function T(z){return z==="application/zip"?"ZIP":z==="application/pdf"?"PDF":""}function D(z){if(!z||z<=0)return"";const j=z/1024;return j<1024?`${j.toFixed(0)} KB`:`${(j/1024).toFixed(1)} MB`}function H(){f.value=null,u.value=!0}function O(z){f.value=z._id,u.value=!0}function S(z,j){const J=j==null?void 0:j.item;J&&typeof J._id=="string"&&O(J)}function B(z){var j,J;return(((j=z.stats)==null?void 0:j.submissions)||0)>0||(((J=z.stats)==null?void 0:J.downloads)||0)>0}function G(z){k.value=z,i.value=B(z)?"archive":"delete",x.value=null,_.value=!0}async function W(){if(k.value){g.value=!0,x.value=null;try{const z=i.value==="delete"?`/admin/gated-content/${k.value._id}/permanent`:`/admin/gated-content/${k.value._id}`,j=await re.delete(z);j.success?(_.value=!1,k.value=null,await F()):x.value=j.error||"Fehler"}catch{x.value="Netzwerkfehler"}finally{g.value=!1}}}async function F(){$.value=!0,d.value=null;try{const z=new URLSearchParams;m.value&&z.set("onlyMine","true");const j=z.toString()?`?${z.toString()}`:"",J=await re.get(`/admin/gated-content${j}`);if(J.success&&J.data){const Q=J.data;c.value=Array.isArray(Q)?Q:[],ue.debug("ADMIN","Gated Content geladen",{count:c.value.length,onlyMine:m.value})}else d.value=J.error||"Fehler beim Laden der Downloads",ue.error("ADMIN","Gated Content Ladefehler",{error:J.error})}catch{d.value="Netzwerkfehler beim Laden der Downloads",ue.error("ADMIN","Netzwerkfehler beim Laden der Downloads")}finally{$.value=!1}}function L(z){return z?typeof z=="object"?z._id:z:null}function A(z){return z&&typeof z=="object"?z:null}return Ze(m,()=>{F()}),rt(()=>{F()}),(z,j)=>{const J=l("v-chip"),Q=l("v-btn"),te=l("v-alert"),ve=l("v-text-field"),de=l("v-tab"),Z=l("v-tabs"),ce=l("v-progress-circular"),oe=l("v-img"),pe=l("v-icon"),_e=l("v-card-text"),q=l("v-divider"),C=l("v-spacer"),ae=l("v-tooltip"),X=l("v-card-actions"),ie=l("v-card"),fe=l("v-col"),Se=l("v-row"),me=l("v-window-item"),ee=l("v-data-table"),Y=l("v-window"),K=l("v-card-title"),le=l("v-dialog");return o(),h("div",DA,[a("div",TA,[j[10]||(j[10]=a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"Downloads / Content-Bibliothek"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," Gated Content verwalten – PDFs oder ZIPs mit Lead-Formular ")],-1)),a("div",LA,[e(J,{color:P(m)?"primary":"",variant:P(m)?"flat":"outlined","prepend-icon":"mdi-account-filter",class:"mr-2",onClick:j[0]||(j[0]=ne=>m.value=!P(m))},{default:t(()=>[...j[8]||(j[8]=[n(" Nur meine ",-1)])]),_:1},8,["color","variant"]),e(Q,{color:"primary","prepend-icon":"mdi-plus",onClick:H},{default:t(()=>[...j[9]||(j[9]=[n(" Neuer Download ",-1)])]),_:1})])]),d.value?(o(),N(te,{key:0,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":j[1]||(j[1]=ne=>d.value=null)},{default:t(()=>[n(v(d.value),1)]),_:1})):U("",!0),e(ve,{modelValue:s.value,"onUpdate:modelValue":j[2]||(j[2]=ne=>s.value=ne),"prepend-inner-icon":"mdi-magnify",label:"Suchen...",variant:"outlined",density:"compact",clearable:"","hide-details":"",class:"mb-6",style:{"max-width":"400px"}},null,8,["modelValue"]),e(Z,{modelValue:p.value,"onUpdate:modelValue":j[3]||(j[3]=ne=>p.value=ne),color:"primary",class:"mb-4",density:"comfortable"},{default:t(()=>[e(de,{value:"magnets","prepend-icon":"mdi-card-text-outline"},{default:t(()=>[...j[11]||(j[11]=[n(" Lead-Magnete ",-1)])]),_:1}),e(de,{value:"files","prepend-icon":"mdi-file-multiple-outline"},{default:t(()=>[j[12]||(j[12]=n(" Dateien ",-1)),b.value.length>0?(o(),N(J,{key:0,size:"x-small",class:"ml-2",variant:"tonal"},{default:t(()=>[n(v(b.value.length),1)]),_:1})):U("",!0)]),_:1})]),_:1},8,["modelValue"]),$.value?(o(),h("div",EA,[e(ce,{indeterminate:"",color:"primary"})])):(o(),N(Y,{key:2,modelValue:p.value,"onUpdate:modelValue":j[4]||(j[4]=ne=>p.value=ne)},{default:t(()=>[e(me,{value:"magnets"},{default:t(()=>[w.value.length===0?(o(),N(te,{key:0,type:"info",variant:"tonal",class:"mb-4"},{default:t(()=>[n(v(s.value?"Keine Ergebnisse gefunden.":"Noch keine Downloads angelegt."),1)]),_:1})):(o(),N(Se,{key:1},{default:t(()=>[(o(!0),h(be,null,Pe(w.value,ne=>(o(),N(fe,{key:ne._id,cols:"12",sm:"6",md:"4"},{default:t(()=>[e(ie,{rounded:"lg",class:"fill-height d-flex flex-column gated-content-list-view__card"},{default:t(()=>[ne.previewImage?(o(),N(oe,{key:0,src:ne.previewImage,height:"160",cover:"",class:"bg-grey-darken-4"},null,8,["src"])):(o(),h("div",MA,[e(pe,{size:"48",color:"primary"},{default:t(()=>[n(v(M(ne)),1)]),_:2},1024)])),e(_e,{class:"flex-grow-1"},{default:t(()=>{var Ce,ke,xe,Ne,Ie;return[a("div",NA,[a("span",UA,v(ne.title),1),e(J,{color:ne.isActive?"success":"default",size:"x-small",variant:"tonal"},{default:t(()=>[n(v(ne.isActive?"Aktiv":"Inaktiv"),1)]),_:2},1032,["color"])]),a("div",BA," /download/"+v(ne.slug),1),(Ce=ne.file)!=null&&Ce.filename?(o(),h("div",FA,[e(pe,{size:"14"},{default:t(()=>[n(v(M(ne)),1)]),_:2},1024),a("span",{class:"text-truncate",title:ne.file.filename},v(ne.file.filename),9,OA),D(ne.file.sizeBytes)?(o(),h("span",RA," · "+v(D(ne.file.sizeBytes)),1)):U("",!0)])):U("",!0),a("div",KA,[n(v(((ke=ne.stats)==null?void 0:ke.views)||0)+" Views · "+v(((xe=ne.stats)==null?void 0:xe.submissions)||0)+" Leads · "+v(((Ne=ne.stats)==null?void 0:Ne.downloads)||0)+" Downloads ",1),((Ie=ne.stats)==null?void 0:Ie.views)>0?(o(),h("span",jA,v(R(ne)),1)):U("",!0)]),a("div",qA," Erstellt: "+v(E(ne.createdAt)),1),a("div",GA,[e(gt,{"user-id":L(ne.createdBy),populated:A(ne.createdBy),size:22},null,8,["user-id","populated"]),e(gt,{"user-id":L(ne.updatedBy),populated:A(ne.updatedBy),size:22},null,8,["user-id","populated"])])]}),_:2},1024),e(q),e(X,null,{default:t(()=>[e(Q,{variant:"text",size:"small",onClick:Ce=>O(ne)},{default:t(()=>[e(pe,{start:""},{default:t(()=>[...j[13]||(j[13]=[n("mdi-pencil",-1)])]),_:1}),j[14]||(j[14]=n(" Bearbeiten ",-1))]),_:1},8,["onClick"]),e(C),e(Q,{variant:"text",size:"small",color:ne.isEmbedded?"grey":"error",icon:"",disabled:ne.isEmbedded,"aria-label":ne.isEmbedded?"In Benutzung":B(ne)?"Archivieren":"Löschen",onClick:Ce=>G(ne)},{default:t(()=>[e(ae,{activator:"parent",location:"bottom"},{default:t(()=>[n(v(ne.isEmbedded?"In Benutzung (eingebettet)":B(ne)?"Archivieren":"Löschen"),1)]),_:2},1024),e(pe,null,{default:t(()=>[n(v(ne.isEmbedded?"mdi-lock-outline":B(ne)?"mdi-archive-outline":"mdi-delete-outline"),1)]),_:2},1024)]),_:2},1032,["color","disabled","aria-label","onClick"])]),_:2},1024)]),_:2},1024)]),_:2},1024))),128))]),_:1}))]),_:1}),e(me,{value:"files"},{default:t(()=>[I.value.length===0?(o(),N(te,{key:0,type:"info",variant:"tonal",class:"mb-4"},{default:t(()=>[n(v(s.value?"Keine Dateien gefunden.":"Noch keine Dateien hochgeladen."),1)]),_:1})):(o(),N(ee,{key:1,headers:V,items:I.value,"item-key":"_id",density:"comfortable",class:"gated-content-list-view__files-table",hover:"","onClick:row":S},{"item.file.mimeType":t(({item:ne})=>{var Ce,ke;return[e(pe,{color:((Ce=ne.file)==null?void 0:Ce.mimeType)==="application/zip"?"amber":"red-lighten-2"},{default:t(()=>[n(v(M(ne)),1)]),_:2},1032,["color"]),a("span",HA,v(T((ke=ne.file)==null?void 0:ke.mimeType)),1)]}),"item.file.filename":t(({item:ne})=>{var Ce,ke;return[a("span",{class:"text-truncate",title:(Ce=ne.file)==null?void 0:Ce.filename},v((ke=ne.file)==null?void 0:ke.filename),9,WA)]}),"item.file.sizeBytes":t(({item:ne})=>{var Ce;return[a("span",ZA,v(D((Ce=ne.file)==null?void 0:Ce.sizeBytes)),1)]}),"item.title":t(({item:ne})=>[a("div",JA,[a("span",QA,v(ne.title),1),a("span",YA,"/download/"+v(ne.slug),1)])]),"item.isActive":t(({item:ne})=>[e(J,{color:ne.isActive?"success":"default",size:"x-small",variant:"tonal"},{default:t(()=>[n(v(ne.isActive?"Aktiv":"Inaktiv"),1)]),_:2},1032,["color"])]),"item.createdAt":t(({item:ne})=>[a("span",XA,v(E(ne.createdAt)),1)]),_:2},1032,["items"]))]),_:1})]),_:1},8,["modelValue"])),e(zA,{modelValue:u.value,"onUpdate:modelValue":j[5]||(j[5]=ne=>u.value=ne),"content-id":f.value,onSaved:F},null,8,["modelValue","content-id"]),e(le,{modelValue:_.value,"onUpdate:modelValue":j[7]||(j[7]=ne=>_.value=ne),"max-width":"400"},{default:t(()=>[e(ie,{rounded:"lg",class:"gated-content-list-view__dialog"},{default:t(()=>[e(K,{class:"pa-5 pb-3 text-subtitle-1 font-weight-bold"},{default:t(()=>[n(v(i.value==="archive"?"Download archivieren?":"Download löschen?"),1)]),_:1}),e(_e,{class:"pa-5 pt-0 text-body-2 text-medium-emphasis"},{default:t(()=>{var ne,Ce;return[i.value==="archive"?(o(),h("p",eI," „"+v((ne=k.value)==null?void 0:ne.title)+'" hat bereits Leads oder Downloads und wird archiviert (deaktiviert). Die Daten bleiben erhalten. ',1)):(o(),h("p",tI," „"+v((Ce=k.value)==null?void 0:Ce.title)+'" wird endgültig gelöscht inkl. Datei und Vorschaubild. Diese Aktion kann nicht rückgängig gemacht werden. ',1)),x.value?(o(),N(te,{key:2,type:"error",variant:"tonal",density:"compact",class:"mt-3"},{default:t(()=>[n(v(x.value),1)]),_:1})):U("",!0)]}),_:1}),e(X,{class:"pa-4"},{default:t(()=>[e(C),e(Q,{variant:"text",onClick:j[6]||(j[6]=ne=>_.value=!1)},{default:t(()=>[...j[15]||(j[15]=[n("Abbrechen",-1)])]),_:1}),e(Q,{color:"error",variant:"flat",loading:g.value,onClick:W},{default:t(()=>[n(v(i.value==="archive"?"Archivieren":"Endgültig löschen"),1)]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}}),lI=Me(aI,[["__scopeId","data-v-51d31cc2"]]),O6=Object.freeze(Object.defineProperty({__proto__:null,default:lI},Symbol.toStringTag,{value:"Module"})),Al=Zt("formPresets",()=>{const r=y([]),$=y(!1),d=y(!1),c=y(null);async function s(f=!1){if($.value&&!f||d.value)return r.value;d.value=!0,c.value=null;try{const p=await re.get("/admin/form-presets");if(p.success&&p.data){const _=p.data;r.value=Array.isArray(_)?_:[],$.value=!0,ue.debug("ADMIN","Form-Presets geladen",{count:r.value.length})}else c.value=p.error||"Fehler beim Laden der Formular-Presets",ue.error("ADMIN","Form-Presets Ladefehler",{error:p.error})}catch(p){c.value="Netzwerkfehler beim Laden der Formular-Presets",ue.error("ADMIN","Form-Presets Netzwerkfehler",{err:p})}finally{d.value=!1}return r.value}function m(){$.value=!1}function u(){r.value=[],$.value=!1,c.value=null}return{items:r,loaded:$,loading:d,lastError:c,fetchAll:s,invalidate:m,reset:u}}),nI={class:"text-h6 font-weight-bold"},oI={key:0,class:"d-flex justify-center py-12"},sI={key:0,class:"pa-5"},iI={class:"text-body-1 font-weight-bold"},rI={class:"d-flex align-center ga-2 mb-4"},dI={class:"form-preset-dialog__preview-frame"},uI={key:1,class:"form-preset-dialog__preview-placeholder"},cI=Ae({__name:"FormPresetDialog",props:aa({presetId:{},initialKind:{}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:aa(["saved"],["update:modelValue"]),setup(r,{emit:$}){const d=r,c=$,s=ua(r,"modelValue"),m=Al(),u=se(()=>!!d.presetId),f=y(!1),p=y(!1),_=y(null),k=y(2),i=wt({slug:"",name:"",kind:"contact",title:"",subtitle:"",buttonLabel:"",successMessage:"",consentText:"",options:{requirePhone:!1,requireCompany:!1,showMessage:!0,showAddress:!1,requireAddress:!1,topicWhitelist:[],defaultTopic:"",defaultDurationMinutes:30,variant:"inline",showFirstName:!0,showLastName:!1,gatedContentId:"",showTrackingConsent:!1,trackingConsentText:"Ich bin einverstanden, dass Basec misst, ob ich E-Mails öffne und Links anklicke. Jederzeit widerrufbar."},tracking:{leadSourceTag:"",utmMedium:"",utmCampaign:""},autoTags:[],isActive:!0}),g=y(!1),x=y([]);function w(B){return B.toLowerCase().replace(/[äÄ]/g,"ae").replace(/[öÖ]/g,"oe").replace(/[üÜ]/g,"ue").replace(/ß/g,"ss").replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,80)}function b(B){switch(B){case"contact":i.title||(i.title="Kontakt aufnehmen"),i.buttonLabel||(i.buttonLabel="Nachricht senden"),i.successMessage||(i.successMessage="Vielen Dank. Wir melden uns zeitnah."),i.consentText||(i.consentText="Mit dem Absenden akzeptierst du unsere Datenschutzerklärung."),i.options.showMessage=!0;break;case"booking":i.title||(i.title="Termin buchen"),i.buttonLabel||(i.buttonLabel="Termin sichern"),i.successMessage||(i.successMessage="Termin gebucht. Bestätigung per Mail."),i.options.defaultDurationMinutes||(i.options.defaultDurationMinutes=30);break;case"newsletter":i.title||(i.title="Newsletter abonnieren"),i.buttonLabel||(i.buttonLabel="Abonnieren"),i.successMessage||(i.successMessage="Bestätigungs-Mail unterwegs. Bitte Double-Opt-In bestätigen."),i.options.variant||(i.options.variant="inline");break;case"download":i.title||(i.title="Jetzt herunterladen"),i.buttonLabel||(i.buttonLabel="Download anfordern"),i.successMessage||(i.successMessage="Download-Link per E-Mail versandt.");break}}function I(){i.slug="",i.name="",i.kind=d.initialKind||"contact",i.title="",i.subtitle="",i.buttonLabel="",i.successMessage="",i.consentText="",i.options.requirePhone=!1,i.options.requireCompany=!1,i.options.showMessage=!0,i.options.showAddress=!1,i.options.requireAddress=!1,i.options.topicWhitelist=[],i.options.defaultTopic="",i.options.defaultDurationMinutes=30,i.options.variant="inline",i.options.showFirstName=!0,i.options.showLastName=!1,i.options.gatedContentId="",i.options.showTrackingConsent=!1,i.options.trackingConsentText="Ich bin einverstanden, dass Basec misst, ob ich E-Mails öffne und Links anklicke. Jederzeit widerrufbar.",i.tracking.leadSourceTag="",i.tracking.utmMedium="",i.tracking.utmCampaign="",i.autoTags=[],i.isActive=!0,g.value=!1,_.value=null,b(i.kind)}Ze(()=>i.name,B=>{u.value||g.value||(i.slug=w(B))});function V(B){g.value=!0,i.slug=w(B)}async function E(){var B,G,W,F,L,A,z,j,J,Q,te,ve,de,Z,ce,oe,pe;if(d.presetId){f.value=!0,_.value=null;try{const _e=await re.get(`/admin/form-presets/${d.presetId}`);if(_e.success&&_e.data){const q=_e.data;i.slug=q.slug||"",i.name=q.name||"",i.kind=q.kind,i.title=q.title||"",i.subtitle=q.subtitle||"",i.buttonLabel=q.buttonLabel||"",i.successMessage=q.successMessage||"",i.consentText=q.consentText||"",i.options.requirePhone=!!((B=q.options)!=null&&B.requirePhone),i.options.requireCompany=!!((G=q.options)!=null&&G.requireCompany),i.options.showMessage=((W=q.options)==null?void 0:W.showMessage)!==!1,i.options.showAddress=!!((F=q.options)!=null&&F.showAddress),i.options.requireAddress=!!((L=q.options)!=null&&L.requireAddress),i.options.topicWhitelist=Array.isArray((A=q.options)==null?void 0:A.topicWhitelist)?[...q.options.topicWhitelist]:[],i.options.defaultTopic=((z=q.options)==null?void 0:z.defaultTopic)||"",i.options.defaultDurationMinutes=((j=q.options)==null?void 0:j.defaultDurationMinutes)??30,i.options.variant=((J=q.options)==null?void 0:J.variant)||"inline",i.options.showFirstName=((Q=q.options)==null?void 0:Q.showFirstName)!==!1,i.options.showLastName=!!((te=q.options)!=null&&te.showLastName),i.options.gatedContentId=((ve=q.options)==null?void 0:ve.gatedContentId)||"",i.options.showTrackingConsent=((de=q.options)==null?void 0:de.showTrackingConsent)===!0,typeof((Z=q.options)==null?void 0:Z.trackingConsentText)=="string"&&(i.options.trackingConsentText=q.options.trackingConsentText),i.tracking.leadSourceTag=((ce=q.tracking)==null?void 0:ce.leadSourceTag)||"",i.tracking.utmMedium=((oe=q.tracking)==null?void 0:oe.utmMedium)||"",i.tracking.utmCampaign=((pe=q.tracking)==null?void 0:pe.utmCampaign)||"",i.autoTags=Array.isArray(q.autoTags)?[...q.autoTags]:[],i.isActive=q.isActive!==!1,g.value=!0}else _.value=_e.error||"Fehler beim Laden des Presets.",ue.error("ADMIN","Form-Preset Ladefehler",{error:_e.error})}catch{_.value="Netzwerkfehler beim Laden."}finally{f.value=!1}}}async function R(){try{const B=await re.get("/admin/gated-content");if(B.success&&B.data){const G=Array.isArray(B.data)?B.data:[];x.value=G.map(W=>({_id:W._id,title:W.title,slug:W.slug}))}}catch{}}function M(){return i.name.trim()?i.slug.trim()?/^[a-z0-9-]+$/.test(i.slug)?i.title.trim()?i.buttonLabel.trim()?i.successMessage.trim()?i.kind==="download"&&!i.options.gatedContentId?"Für ein Download-Preset muss ein Gated Content ausgewählt werden.":null:"Erfolgsmeldung ist ein Pflichtfeld.":"Button-Label ist ein Pflichtfeld.":"Titel ist ein Pflichtfeld.":"Slug darf nur Kleinbuchstaben, Zahlen und Bindestriche enthalten.":"Slug ist ein Pflichtfeld.":"Name ist ein Pflichtfeld."}async function T(){const B=M();if(B){_.value=B;return}p.value=!0,_.value=null;const G={};switch(i.kind){case"contact":G.requirePhone=i.options.requirePhone,G.requireCompany=i.options.requireCompany,G.showMessage=i.options.showMessage,G.showAddress=i.options.showAddress,G.requireAddress=i.options.requireAddress;break;case"booking":i.options.topicWhitelist.length>0&&(G.topicWhitelist=i.options.topicWhitelist),i.options.defaultTopic&&(G.defaultTopic=i.options.defaultTopic),i.options.defaultDurationMinutes&&(G.defaultDurationMinutes=i.options.defaultDurationMinutes);break;case"newsletter":G.variant=i.options.variant,G.showFirstName=i.options.showFirstName,G.showLastName=i.options.showLastName;break;case"download":G.gatedContentId=i.options.gatedContentId,G.requirePhone=i.options.requirePhone,G.requireCompany=i.options.requireCompany;break}G.showTrackingConsent=i.options.showTrackingConsent,i.options.showTrackingConsent&&i.options.trackingConsentText&&(G.trackingConsentText=i.options.trackingConsentText);const W={};i.tracking.leadSourceTag&&(W.leadSourceTag=i.tracking.leadSourceTag),i.tracking.utmMedium&&(W.utmMedium=i.tracking.utmMedium),i.tracking.utmCampaign&&(W.utmCampaign=i.tracking.utmCampaign);const F=i.autoTags.map(A=>typeof A=="string"?A.trim().toLowerCase():"").filter(A=>A.length>0),L={slug:i.slug,name:i.name,kind:i.kind,title:i.title,subtitle:i.subtitle||void 0,buttonLabel:i.buttonLabel,successMessage:i.successMessage,consentText:i.consentText||void 0,options:G,tracking:W,autoTags:F,isActive:i.isActive};try{const A=u.value?await re.patch(`/admin/form-presets/${d.presetId}`,L):await re.post("/admin/form-presets",L);A.success?(m.invalidate(),c("saved"),s.value=!1):_.value=A.error||"Fehler beim Speichern."}catch{_.value="Netzwerkfehler beim Speichern."}finally{p.value=!1}}const D=se(()=>({sectionId:"preview",type:"form",name:"Preview",title:i.title,content:i.subtitle||"",settings:{presetSlug:i.slug||"preview"}})),H=se(()=>{const B={};switch(i.kind){case"contact":B.requirePhone=i.options.requirePhone,B.requireCompany=i.options.requireCompany,B.showMessage=i.options.showMessage,B.showAddress=i.options.showAddress,B.requireAddress=i.options.requireAddress;break;case"booking":i.options.topicWhitelist.length>0&&(B.topicWhitelist=i.options.topicWhitelist),i.options.defaultTopic&&(B.defaultTopic=i.options.defaultTopic),i.options.defaultDurationMinutes&&(B.defaultDurationMinutes=i.options.defaultDurationMinutes);break;case"newsletter":B.variant=i.options.variant,B.showFirstName=i.options.showFirstName,B.showLastName=i.options.showLastName;break;case"download":B.gatedContentId=i.options.gatedContentId,B.requirePhone=i.options.requirePhone,B.requireCompany=i.options.requireCompany;break}return B.showTrackingConsent=i.options.showTrackingConsent,i.options.showTrackingConsent&&i.options.trackingConsentText&&(B.trackingConsentText=i.options.trackingConsentText),{slug:i.slug||"preview",kind:i.kind,title:i.title,subtitle:i.subtitle||void 0,buttonLabel:i.buttonLabel,successMessage:i.successMessage,consentText:i.consentText||void 0,options:B,tracking:{leadSourceTag:i.tracking.leadSourceTag||void 0}}}),O=y(null);async function S(){try{const B=await Lt(()=>import("./ElementForm-ZhvFaI_E.js"),__vite__mapDeps([4,5,1,6,7,8,9,2,3,10,11,12,13,14,15,16,17,18,19,20,21]));O.value=B.default}catch{O.value=null}}return Ze(()=>s.value,B=>{B&&(I(),d.initialKind&&(i.kind=d.initialKind,b(i.kind)),d.presetId&&E(),R(),k.value=u.value||d.initialKind?2:1)},{immediate:!1}),Ze(()=>i.kind,B=>{b(B)}),Ze(()=>i.options.requireAddress,B=>{B&&(i.options.showAddress=!0)}),Ze(()=>i.options.showAddress,B=>{B||(i.options.requireAddress=!1)}),rt(()=>{S()}),(B,G)=>{const W=l("v-icon"),F=l("v-spacer"),L=l("v-tooltip"),A=l("v-btn"),z=l("v-card-title"),j=l("v-divider"),J=l("v-progress-circular"),Q=l("v-card-text"),te=l("v-card"),ve=l("v-col"),de=l("v-row"),Z=l("v-alert"),ce=l("v-chip"),oe=l("v-text-field"),pe=l("v-textarea"),_e=l("v-switch"),q=l("v-combobox"),C=l("v-select"),ae=l("v-card-actions"),X=l("v-dialog");return o(),N(X,{modelValue:s.value,"onUpdate:modelValue":G[31]||(G[31]=ie=>s.value=ie),"max-width":"1200",scrollable:""},{default:t(()=>[e(te,{rounded:"lg",class:"form-preset-dialog"},{default:t(()=>[e(z,{class:"d-flex align-center pa-4 pb-2"},{default:t(()=>[e(W,{class:"mr-2",size:"24",color:"primary"},{default:t(()=>[...G[32]||(G[32]=[n("mdi-form-select",-1)])]),_:1}),a("span",nI,v(u.value?"Preset bearbeiten":"Neues Formular-Preset"),1),e(F),e(A,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:G[0]||(G[0]=ie=>s.value=!1)},{default:t(()=>[e(L,{activator:"parent",location:"bottom"},{default:t(()=>[...G[33]||(G[33]=[n("Schließen",-1)])]),_:1}),e(W,null,{default:t(()=>[...G[34]||(G[34]=[n("mdi-close",-1)])]),_:1})]),_:1})]),_:1}),e(j),e(Q,{class:"pa-0",style:{"max-height":"75vh"}},{default:t(()=>[f.value?(o(),h("div",oI,[e(J,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:1},[k.value===1?(o(),h("div",sI,[G[35]||(G[35]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Welche Art von Formular soll erstellt werden? ",-1)),e(de,null,{default:t(()=>[(o(),h(be,null,Pe(["contact","booking","newsletter","download"],ie=>e(ve,{key:ie,cols:"12",sm:"6"},{default:t(()=>[e(te,{rounded:"lg",variant:"outlined",class:ft(["form-preset-dialog__kind-card",{"form-preset-dialog__kind-card--active":i.kind===ie}]),onClick:fe=>{i.kind=ie,k.value=2}},{default:t(()=>[e(Q,{class:"d-flex align-center ga-3"},{default:t(()=>[e(W,{icon:ie==="contact"?"mdi-email-outline":ie==="booking"?"mdi-calendar-check":ie==="newsletter"?"mdi-email-newsletter":"mdi-file-download-outline",size:"28",color:"primary"},null,8,["icon"]),a("div",null,[a("div",iI,v(ie==="contact"?"Kontakt":ie==="booking"?"Termin":ie==="newsletter"?"Newsletter":"Download"),1)])]),_:2},1024)]),_:2},1032,["class","onClick"])]),_:2},1024)),64))]),_:1})])):(o(),N(de,{key:1,"no-gutters":""},{default:t(()=>[e(ve,{cols:"12",md:"7",class:"pa-5 form-preset-dialog__form-col"},{default:t(()=>[_.value?(o(),N(Z,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":G[1]||(G[1]=ie=>_.value=null)},{default:t(()=>[n(v(_.value),1)]),_:1})):U("",!0),a("div",rI,[e(ce,{color:"primary",size:"small",variant:"tonal"},{default:t(()=>[n(v(i.kind==="contact"?"Kontakt":i.kind==="booking"?"Termin":i.kind==="newsletter"?"Newsletter":"Download"),1)]),_:1}),u.value?U("",!0):(o(),N(A,{key:0,size:"x-small",variant:"text",onClick:G[2]||(G[2]=ie=>k.value=1)},{default:t(()=>[...G[36]||(G[36]=[n(" Typ ändern ",-1)])]),_:1}))]),G[37]||(G[37]=a("div",{class:"text-caption text-medium-emphasis mb-2 text-uppercase font-weight-bold"}," Grunddaten ",-1)),e(oe,{modelValue:i.name,"onUpdate:modelValue":G[3]||(G[3]=ie=>i.name=ie),label:"Name (intern) *",variant:"outlined",density:"compact",hint:"Interner Name, nur für die Verwaltung","persistent-hint":"",class:"mb-3"},null,8,["modelValue"]),e(oe,{"model-value":i.slug,label:"Slug *",variant:"outlined",density:"compact",hint:"URL-Identifier, nur Kleinbuchstaben, Zahlen und Bindestriche","persistent-hint":"",class:"mb-3","onUpdate:modelValue":V},null,8,["model-value"]),e(j,{class:"my-4"}),G[38]||(G[38]=a("div",{class:"text-caption text-medium-emphasis mb-2 text-uppercase font-weight-bold"}," Darstellung ",-1)),e(oe,{modelValue:i.title,"onUpdate:modelValue":G[4]||(G[4]=ie=>i.title=ie),label:"Titel (öffentlich) *",variant:"outlined",density:"compact",class:"mb-3"},null,8,["modelValue"]),e(oe,{modelValue:i.subtitle,"onUpdate:modelValue":G[5]||(G[5]=ie=>i.subtitle=ie),label:"Untertitel",variant:"outlined",density:"compact",class:"mb-3"},null,8,["modelValue"]),e(oe,{modelValue:i.buttonLabel,"onUpdate:modelValue":G[6]||(G[6]=ie=>i.buttonLabel=ie),label:"Button-Label *",variant:"outlined",density:"compact",class:"mb-3"},null,8,["modelValue"]),e(pe,{modelValue:i.successMessage,"onUpdate:modelValue":G[7]||(G[7]=ie=>i.successMessage=ie),label:"Erfolgsmeldung *",variant:"outlined",rows:"2",density:"compact",class:"mb-3"},null,8,["modelValue"]),e(pe,{modelValue:i.consentText,"onUpdate:modelValue":G[8]||(G[8]=ie=>i.consentText=ie),label:"Datenschutz-Hinweis",variant:"outlined",rows:"2",density:"compact",hint:"Wird neben der Einwilligungs-Checkbox angezeigt","persistent-hint":"",class:"mb-3"},null,8,["modelValue"]),e(j,{class:"my-4"}),G[39]||(G[39]=a("div",{class:"text-caption text-medium-emphasis mb-2 text-uppercase font-weight-bold"}," Einstellungen ",-1)),i.kind==="contact"?(o(),h(be,{key:1},[e(_e,{modelValue:i.options.requirePhone,"onUpdate:modelValue":G[9]||(G[9]=ie=>i.options.requirePhone=ie),label:"Telefon-Feld als Pflichtfeld",color:"primary",density:"compact","hide-details":"",class:"mb-2"},null,8,["modelValue"]),e(_e,{modelValue:i.options.requireCompany,"onUpdate:modelValue":G[10]||(G[10]=ie=>i.options.requireCompany=ie),label:"Unternehmen-Feld als Pflichtfeld",color:"primary",density:"compact","hide-details":"",class:"mb-2"},null,8,["modelValue"]),e(_e,{modelValue:i.options.showMessage,"onUpdate:modelValue":G[11]||(G[11]=ie=>i.options.showMessage=ie),label:"Nachricht-Feld anzeigen",color:"primary",density:"compact","hide-details":"",class:"mb-2"},null,8,["modelValue"]),e(_e,{modelValue:i.options.showAddress,"onUpdate:modelValue":G[12]||(G[12]=ie=>i.options.showAddress=ie),label:"Adresse: Felder anzeigen",color:"primary",density:"compact","hide-details":"",class:"mb-2"},null,8,["modelValue"]),e(_e,{modelValue:i.options.requireAddress,"onUpdate:modelValue":G[13]||(G[13]=ie=>i.options.requireAddress=ie),label:"Adresse: Pflichtfelder",color:"primary",density:"compact","hide-details":"",class:"mb-2"},null,8,["modelValue"])],64)):U("",!0),i.kind==="booking"?(o(),h(be,{key:2},[e(q,{modelValue:i.options.topicWhitelist,"onUpdate:modelValue":G[14]||(G[14]=ie=>i.options.topicWhitelist=ie),label:"Themen-Whitelist",variant:"outlined",density:"compact",multiple:"",chips:"",clearable:"",hint:"Enter zum Hinzufügen. Leer lassen = alle Themen erlaubt.","persistent-hint":"",class:"mb-3"},null,8,["modelValue"]),e(oe,{modelValue:i.options.defaultTopic,"onUpdate:modelValue":G[15]||(G[15]=ie=>i.options.defaultTopic=ie),label:"Standard-Thema",variant:"outlined",density:"compact",class:"mb-3"},null,8,["modelValue"]),e(oe,{modelValue:i.options.defaultDurationMinutes,"onUpdate:modelValue":G[16]||(G[16]=ie=>i.options.defaultDurationMinutes=ie),modelModifiers:{number:!0},label:"Standard-Dauer (Minuten)",type:"number",variant:"outlined",density:"compact",class:"mb-3"},null,8,["modelValue"])],64)):U("",!0),i.kind==="newsletter"?(o(),h(be,{key:3},[e(C,{modelValue:i.options.variant,"onUpdate:modelValue":G[17]||(G[17]=ie=>i.options.variant=ie),items:[{value:"inline",title:"Inline (kompakt, nur E-Mail)"},{value:"standalone",title:"Standalone (volle Breite)"}],label:"Variante",variant:"outlined",density:"compact",class:"mb-3"},null,8,["modelValue"]),e(_e,{modelValue:i.options.showFirstName,"onUpdate:modelValue":G[18]||(G[18]=ie=>i.options.showFirstName=ie),label:"Vorname-Feld anzeigen",color:"primary",density:"compact","hide-details":"",class:"mb-2"},null,8,["modelValue"]),e(_e,{modelValue:i.options.showLastName,"onUpdate:modelValue":G[19]||(G[19]=ie=>i.options.showLastName=ie),label:"Nachname-Feld anzeigen",color:"primary",density:"compact","hide-details":"",class:"mb-2"},null,8,["modelValue"])],64)):U("",!0),i.kind==="download"?(o(),h(be,{key:4},[e(C,{modelValue:i.options.gatedContentId,"onUpdate:modelValue":G[20]||(G[20]=ie=>i.options.gatedContentId=ie),items:x.value,"item-title":"title","item-value":"_id",label:"Gated Content *",variant:"outlined",density:"compact",hint:"Welcher Download wird angeboten?","persistent-hint":"",class:"mb-3"},null,8,["modelValue","items"]),e(_e,{modelValue:i.options.requirePhone,"onUpdate:modelValue":G[21]||(G[21]=ie=>i.options.requirePhone=ie),label:"Telefon-Feld als Pflichtfeld",color:"primary",density:"compact","hide-details":"",class:"mb-2"},null,8,["modelValue"]),e(_e,{modelValue:i.options.requireCompany,"onUpdate:modelValue":G[22]||(G[22]=ie=>i.options.requireCompany=ie),label:"Unternehmen-Feld als Pflichtfeld",color:"primary",density:"compact","hide-details":"",class:"mb-2"},null,8,["modelValue"])],64)):U("",!0),e(j,{class:"my-4"}),G[40]||(G[40]=a("div",{class:"text-caption text-medium-emphasis mb-2 text-uppercase font-weight-bold"}," E-Mail-Tracking-Consent ",-1)),e(_e,{modelValue:i.options.showTrackingConsent,"onUpdate:modelValue":G[23]||(G[23]=ie=>i.options.showTrackingConsent=ie),label:"E-Mail-Tracking-Consent anzeigen (optionaler zweiter Haken)",color:"primary",density:"compact","hide-details":"",class:"mb-2"},null,8,["modelValue"]),i.options.showTrackingConsent?(o(),N(pe,{key:5,modelValue:i.options.trackingConsentText,"onUpdate:modelValue":G[24]||(G[24]=ie=>i.options.trackingConsentText=ie),label:"Text für Tracking-Consent-Checkbox",variant:"outlined",rows:"3",density:"compact",hint:"Markdown-Links [Label](/pfad) werden als Link gerendert","persistent-hint":"",class:"mt-3 mb-3"},null,8,["modelValue"])):U("",!0),e(j,{class:"my-4"}),G[41]||(G[41]=a("div",{class:"text-caption text-medium-emphasis mb-2 text-uppercase font-weight-bold"}," Tracking ",-1)),e(oe,{modelValue:i.tracking.leadSourceTag,"onUpdate:modelValue":G[25]||(G[25]=ie=>i.tracking.leadSourceTag=ie),label:"Lead-Source-Tag",variant:"outlined",density:"compact",hint:"Wird in Lead.source.utm.campaign gespeichert","persistent-hint":"",class:"mb-3"},null,8,["modelValue"]),e(oe,{modelValue:i.tracking.utmMedium,"onUpdate:modelValue":G[26]||(G[26]=ie=>i.tracking.utmMedium=ie),label:"UTM Medium",variant:"outlined",density:"compact",class:"mb-3"},null,8,["modelValue"]),e(oe,{modelValue:i.tracking.utmCampaign,"onUpdate:modelValue":G[27]||(G[27]=ie=>i.tracking.utmCampaign=ie),label:"UTM Campaign",variant:"outlined",density:"compact",class:"mb-3"},null,8,["modelValue"]),e(j,{class:"my-4"}),G[42]||(G[42]=a("div",{class:"text-caption text-medium-emphasis mb-2 text-uppercase font-weight-bold"}," Auto-Tags ",-1)),e(q,{modelValue:i.autoTags,"onUpdate:modelValue":G[28]||(G[28]=ie=>i.autoTags=ie),label:"Tags automatisch setzen",variant:"outlined",density:"compact",multiple:"",chips:"","closable-chips":"",clearable:"",hint:"Jedes Form-Submit legt diese Tags am Lead an (dedupliziert). Enter zum Hinzufügen. Beispiel: dora, download.","persistent-hint":"",class:"mb-3"},null,8,["modelValue"]),e(j,{class:"my-4"}),e(_e,{modelValue:i.isActive,"onUpdate:modelValue":G[29]||(G[29]=ie=>i.isActive=ie),label:"Aktiv (öffentlich verwendbar)",color:"primary","hide-details":""},null,8,["modelValue"])]),_:1}),e(ve,{cols:"12",md:"5",class:"form-preset-dialog__preview-col pa-5"},{default:t(()=>[G[45]||(G[45]=a("div",{class:"text-caption text-medium-emphasis mb-3 text-uppercase font-weight-bold"}," Live-Vorschau ",-1)),a("div",dI,[O.value?(o(),N(Ml(O.value),{key:0,section:D.value,"preset-override":H.value,"preview-mode":!0},null,8,["section","preset-override"])):(o(),h("div",uI,[e(W,{size:"48",color:"grey-darken-1"},{default:t(()=>[...G[43]||(G[43]=[n("mdi-eye-off-outline",-1)])]),_:1}),G[44]||(G[44]=a("p",{class:"text-body-2 text-medium-emphasis mt-3"}," Vorschau wird aktualisiert, sobald das Preset gespeichert ist. ",-1))]))])]),_:1})]),_:1}))],64))]),_:1}),e(j),e(ae,{class:"pa-4"},{default:t(()=>[e(F),e(A,{variant:"text",onClick:G[30]||(G[30]=ie=>s.value=!1)},{default:t(()=>[...G[46]||(G[46]=[n("Abbrechen",-1)])]),_:1}),e(A,{color:"primary",variant:"flat",loading:p.value,disabled:f.value||k.value===1,onClick:T},{default:t(()=>[n(v(u.value?"Speichern":"Erstellen"),1)]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"])}}}),mI=Me(cI,[["__scopeId","data-v-39a27c4f"]]),vI={class:"form-presets-list-view"},pI={class:"form-presets-list-view__header"},fI={class:"d-flex align-center ga-2"},gI={class:"form-presets-list-view__filters mb-6"},bI={key:1,class:"d-flex justify-center py-12"},yI={class:"d-flex flex-column"},_I={class:"text-body-2 font-weight-medium"},kI={class:"text-caption text-medium-emphasis"},hI={class:"text-body-2"},xI={class:"d-flex align-center ga-2"},wI={class:"text-caption text-medium-emphasis"},SI={class:"d-flex justify-end ga-1"},$I={class:"text-body-1 font-weight-bold mb-1"},CI={class:"text-caption text-medium-emphasis"},VI=Ae({__name:"FormPresetsListView",setup(r){const $=xt(),d=Al(),c=y(!1),s=y(null),m=qe("form_presets_search",""),u=qe("form_presets_kind_filter","all"),f=qe("form_presets_only_active",!1),p=y(!1),_=y(null),k=y(null),i=y(!1),g=y(!1),x=y(null),w=y(!1),b=y(null),I={contact:{label:"Kontakt",color:"primary",icon:"mdi-email-outline",description:"Allgemeines Kontaktformular mit optionalem Nachrichten-Feld."},booking:{label:"Termin",color:"accent",icon:"mdi-calendar-check",description:"Terminbuchung mit Themen-Auswahl und Kalender."},newsletter:{label:"Newsletter",color:"info",icon:"mdi-email-newsletter",description:"Newsletter-Anmeldung mit Double-Opt-In."},download:{label:"Download",color:"success",icon:"mdi-file-download-outline",description:"Gated Content - Lead gegen Download-Link tauschen."}};function V(j){var J;return((J=I[j])==null?void 0:J.label)??j}function E(j){var J;return((J=I[j])==null?void 0:J.color)??"default"}const R=se(()=>{let j=d.items;f.value&&(j=j.filter(Q=>Q.isActive)),u.value&&u.value!=="all"&&(j=j.filter(Q=>Q.kind===u.value));const J=(m.value||"").toLowerCase().trim();return J&&(j=j.filter(Q=>Q.name.toLowerCase().includes(J)||Q.slug.toLowerCase().includes(J)||Q.title.toLowerCase().includes(J))),j});function M(j){return j?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(new Date(j)):"-"}function T(j){return j?typeof j=="object"?j._id:j:null}function D(j){return j&&typeof j=="object"?j:null}function H(){i.value=!0}function O(j){i.value=!1,_.value=null,k.value=j,p.value=!0}function S(j){_.value=j._id,k.value=j.kind,p.value=!0}async function B(j){c.value=!0,s.value=null;try{const J=await re.post(`/admin/form-presets/${j._id}/duplicate`);J.success?await z(!0):s.value=J.error||"Fehler beim Duplizieren."}catch{s.value="Netzwerkfehler beim Duplizieren."}finally{c.value=!1}}function G(j){x.value=j,b.value=null,g.value=!0}async function W(){if(x.value){w.value=!0,b.value=null;try{const j=await re.delete(`/admin/form-presets/${x.value._id}`);j.success?(g.value=!1,x.value=null,await z(!0)):b.value=j.error||"Fehler beim Löschen."}catch{b.value="Netzwerkfehler beim Löschen."}finally{w.value=!1}}}function F(j){return!j.isSystem&&(j.usageCount??0)===0}function L(j){const J=j.kind==="download"?"gated-content":j.kind;$.push({path:"/admin/leads",query:{presetSlug:j.slug,formType:J}}),ue.info("ADMIN","Drill-Down zu Leads aus Formular-Presets",{slug:j.slug,kind:j.kind})}function A(j){return j.isSystem?"System-Preset kann nicht gelöscht werden":(j.usageCount??0)>0?`Wird aktuell auf ${j.usageCount} Seite(n) verwendet`:""}async function z(j=!1){c.value=!0,s.value=null;try{await d.fetchAll(j),d.lastError&&(s.value=d.lastError,ue.error("ADMIN","Form-Presets konnten nicht geladen werden",{error:d.lastError}))}finally{c.value=!1}}return rt(()=>{z()}),(j,J)=>{const Q=l("v-btn"),te=l("v-alert"),ve=l("v-text-field"),de=l("v-select"),Z=l("v-switch"),ce=l("v-progress-circular"),oe=l("v-chip"),pe=l("v-tooltip"),_e=l("v-icon"),q=l("v-data-table"),C=l("v-card"),ae=l("v-spacer"),X=l("v-card-title"),ie=l("v-divider"),fe=l("v-card-text"),Se=l("v-col"),me=l("v-row"),ee=l("v-dialog"),Y=l("v-card-actions");return o(),h("div",vI,[a("div",pI,[J[11]||(J[11]=a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"Formulare"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," Formular-Presets verwalten - wiederverwendbare Formulare für Seiten und KI-Generierung ")],-1)),a("div",fI,[e(Q,{color:"primary","prepend-icon":"mdi-plus",onClick:H},{default:t(()=>[...J[10]||(J[10]=[n(" Neues Preset ",-1)])]),_:1})])]),s.value?(o(),N(te,{key:0,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":J[0]||(J[0]=K=>s.value=null)},{default:t(()=>[n(v(s.value),1)]),_:1})):U("",!0),a("div",gI,[e(ve,{modelValue:P(m),"onUpdate:modelValue":J[1]||(J[1]=K=>ot(m)?m.value=K:null),"prepend-inner-icon":"mdi-magnify",label:"Nach Name, Slug oder Titel suchen...",variant:"outlined",density:"compact",clearable:"","hide-details":"",style:{"min-width":"280px",flex:"1 1 280px"}},null,8,["modelValue"]),e(de,{modelValue:P(u),"onUpdate:modelValue":J[2]||(J[2]=K=>ot(u)?u.value=K:null),label:"Typ",items:[{value:"all",title:"Alle Typen"},{value:"contact",title:"Kontakt"},{value:"booking",title:"Termin"},{value:"newsletter",title:"Newsletter"},{value:"download",title:"Download"}],variant:"outlined",density:"compact","hide-details":"",style:{"min-width":"180px"}},null,8,["modelValue"]),e(Z,{modelValue:P(f),"onUpdate:modelValue":J[3]||(J[3]=K=>ot(f)?f.value=K:null),color:"primary",label:"Nur aktive","hide-details":"",density:"compact"},null,8,["modelValue"])]),c.value&&P(d).items.length===0?(o(),h("div",bI,[e(ce,{indeterminate:"",color:"primary"})])):R.value.length===0?(o(),N(te,{key:2,type:"info",variant:"tonal",class:"mb-4"},{default:t(()=>[n(v(P(d).items.length===0?'Noch keine Formular-Presets angelegt. Klicke auf "+ Neues Preset".':"Keine Ergebnisse für die aktuellen Filter."),1)]),_:1})):(o(),N(C,{key:3,rounded:"lg",class:"form-presets-list-view__card"},{default:t(()=>[e(q,{headers:[{title:"Name",key:"name",sortable:!0},{title:"Typ",key:"kind",sortable:!0,width:"120px"},{title:"Status",key:"isActive",sortable:!0,width:"110px"},{title:"Herkunft",key:"isSystem",sortable:!0,width:"110px"},{title:"Verwendung",key:"usageCount",sortable:!0,width:"110px"},{title:"Views",key:"stats.views",sortable:!0,width:"100px",align:"end"},{title:"Einreichungen",key:"stats.submissions",sortable:!0,width:"130px",align:"end"},{title:"Erstellt",key:"createdAt",sortable:!0,width:"160px"},{title:"",key:"actions",sortable:!1,width:"140px",align:"end"}],items:R.value,density:"comfortable","items-per-page":25,"item-value":"_id"},{"item.name":t(({item:K})=>[a("div",yI,[a("span",_I,v(K.name),1),a("span",kI,v(K.slug),1)])]),"item.kind":t(({item:K})=>[e(oe,{color:E(K.kind),size:"small",variant:"tonal"},{default:t(()=>[n(v(V(K.kind)),1)]),_:2},1032,["color"])]),"item.isActive":t(({item:K})=>[e(oe,{color:K.isActive?"success":"default",size:"x-small",variant:"tonal"},{default:t(()=>[n(v(K.isActive?"Aktiv":"Inaktiv"),1)]),_:2},1032,["color"])]),"item.isSystem":t(({item:K})=>[e(oe,{size:"x-small",variant:K.isSystem?"outlined":"tonal",color:K.isSystem?"accent":"default"},{default:t(()=>[n(v(K.isSystem?"System":"Eigen"),1)]),_:2},1032,["variant","color"])]),"item.usageCount":t(({item:K})=>[a("span",hI,v(K.usageCount||0),1)]),"item.stats.views":t(({item:K})=>[e(pe,{location:"top",text:"Kumulative Aufrufe"},{activator:t(({props:le})=>{var ne;return[a("span",Vt(le,{class:"text-body-2 text-medium-emphasis"}),v((((ne=K.stats)==null?void 0:ne.views)??0).toLocaleString("de-DE")),17)]}),_:2},1024)]),"item.stats.submissions":t(({item:K})=>{var le;return[e(Q,{variant:"text",size:"small",density:"compact",class:"text-body-2 font-weight-medium text-primary px-1",disabled:(((le=K.stats)==null?void 0:le.submissions)??0)===0,onClick:dt(ne=>L(K),["stop"])},{default:t(()=>{var ne;return[n(v((((ne=K.stats)==null?void 0:ne.submissions)??0).toLocaleString("de-DE"))+" ",1),e(pe,{activator:"parent",location:"top"},{default:t(()=>[...J[12]||(J[12]=[n(" Leads für dieses Formular anzeigen ",-1)])]),_:1})]}),_:2},1032,["disabled","onClick"])]}),"item.createdAt":t(({item:K})=>[a("div",xI,[a("span",wI,v(M(K.createdAt)),1),e(gt,{"user-id":T(K.createdBy),populated:D(K.createdBy),size:20},null,8,["user-id","populated"])])]),"item.actions":t(({item:K})=>[a("div",SI,[e(Q,{icon:"mdi-pencil",size:"small",variant:"text","aria-label":"Bearbeiten",onClick:le=>S(K)},{default:t(()=>[e(_e,null,{default:t(()=>[...J[13]||(J[13]=[n("mdi-pencil",-1)])]),_:1}),e(pe,{activator:"parent",location:"bottom"},{default:t(()=>[...J[14]||(J[14]=[n("Bearbeiten",-1)])]),_:1})]),_:1},8,["onClick"]),e(Q,{size:"small",variant:"text","aria-label":"Duplizieren",onClick:le=>B(K)},{default:t(()=>[e(_e,null,{default:t(()=>[...J[15]||(J[15]=[n("mdi-content-copy",-1)])]),_:1}),e(pe,{activator:"parent",location:"bottom"},{default:t(()=>[...J[16]||(J[16]=[n("Duplizieren",-1)])]),_:1})]),_:1},8,["onClick"]),e(Q,{size:"small",variant:"text",color:"error",disabled:!F(K),"aria-label":"Löschen",onClick:le=>G(K)},{default:t(()=>[e(_e,null,{default:t(()=>[...J[17]||(J[17]=[n("mdi-delete-outline",-1)])]),_:1}),e(pe,{activator:"parent",location:"bottom"},{default:t(()=>[n(v(F(K)?"Löschen":A(K)),1)]),_:2},1024)]),_:2},1032,["disabled","onClick"])])]),"no-data":t(()=>[...J[18]||(J[18]=[a("span",{class:"text-caption text-medium-emphasis"},"Keine Presets vorhanden.",-1)])]),_:1},8,["items"])]),_:1})),e(ee,{modelValue:i.value,"onUpdate:modelValue":J[5]||(J[5]=K=>i.value=K),"max-width":"720"},{default:t(()=>[e(C,{rounded:"lg",class:"form-presets-list-view__dialog"},{default:t(()=>[e(X,{class:"pa-5 pb-2 d-flex align-center"},{default:t(()=>[e(_e,{class:"mr-2",color:"primary"},{default:t(()=>[...J[19]||(J[19]=[n("mdi-form-select",-1)])]),_:1}),J[21]||(J[21]=a("span",{class:"text-h6 font-weight-bold"},"Formular-Typ wählen",-1)),e(ae),e(Q,{icon:"",variant:"text",size:"small",onClick:J[4]||(J[4]=K=>i.value=!1)},{default:t(()=>[e(_e,null,{default:t(()=>[...J[20]||(J[20]=[n("mdi-close",-1)])]),_:1})]),_:1})]),_:1}),e(ie),e(fe,{class:"pa-5"},{default:t(()=>[J[22]||(J[22]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Welche Art von Formular soll erstellt werden? ",-1)),e(me,null,{default:t(()=>[(o(),h(be,null,Pe(I,(K,le)=>e(Se,{key:le,cols:"12",sm:"6"},{default:t(()=>[e(C,{rounded:"lg",variant:"outlined",class:"form-presets-list-view__kind-card",onClick:ne=>O(le)},{default:t(()=>[e(fe,{class:"d-flex align-start ga-3"},{default:t(()=>[e(_e,{icon:K.icon,size:"32",color:K.color},null,8,["icon","color"]),a("div",null,[a("div",$I,v(K.label),1),a("div",CI,v(K.description),1)])]),_:2},1024)]),_:2},1032,["onClick"])]),_:2},1024)),64))]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]),e(mI,{modelValue:p.value,"onUpdate:modelValue":J[6]||(J[6]=K=>p.value=K),"preset-id":_.value,"initial-kind":k.value,onSaved:J[7]||(J[7]=K=>z(!0))},null,8,["modelValue","preset-id","initial-kind"]),e(ee,{modelValue:g.value,"onUpdate:modelValue":J[9]||(J[9]=K=>g.value=K),"max-width":"440"},{default:t(()=>[e(C,{rounded:"lg",class:"form-presets-list-view__dialog"},{default:t(()=>[e(X,{class:"pa-5 pb-3 text-subtitle-1 font-weight-bold"},{default:t(()=>[...J[23]||(J[23]=[n(" Preset löschen? ",-1)])]),_:1}),e(fe,{class:"pa-5 pt-0 text-body-2 text-medium-emphasis"},{default:t(()=>{var K;return[a("p",null," „"+v((K=x.value)==null?void 0:K.name)+'" wird unwiderruflich gelöscht. ',1),b.value?(o(),N(te,{key:0,type:"error",variant:"tonal",density:"compact",class:"mt-3"},{default:t(()=>[n(v(b.value),1)]),_:1})):U("",!0)]}),_:1}),e(Y,{class:"pa-4"},{default:t(()=>[e(ae),e(Q,{variant:"text",onClick:J[8]||(J[8]=K=>g.value=!1)},{default:t(()=>[...J[24]||(J[24]=[n("Abbrechen",-1)])]),_:1}),e(Q,{color:"error",variant:"flat",loading:w.value,onClick:W},{default:t(()=>[...J[25]||(J[25]=[n(" Löschen ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"])])}}}),AI=Me(VI,[["__scopeId","data-v-7ed8dc40"]]),R6=Object.freeze(Object.defineProperty({__proto__:null,default:AI},Symbol.toStringTag,{value:"Module"})),II=Zt("formStats",()=>{const r=y("30d"),$=y(null),d=y(null),c=y(null),s=y(null),m=y(null),u=y(!1),f=y(!1),p=y(!1),_=y(!1),k=y(null),i=y(null),g=y(null),x=y(null);async function w(M){const T=M??r.value;u.value=!0,k.value=null;try{const D=new URLSearchParams({period:T}),H=await re.get(`/form-stats/overview?${D.toString()}`);H.success&&H.data?(d.value=H.data,ue.debug("ADMIN","Form-Stats Overview geladen",{period:T})):(k.value=H.error||"Fehler beim Laden der Formular-Statistiken",ue.error("ADMIN","Form-Stats Overview Ladefehler",{error:H.error}))}catch(D){k.value="Netzwerkfehler beim Laden der Formular-Statistiken",ue.error("ADMIN","Form-Stats Overview Netzwerkfehler",D)}finally{u.value=!1}}async function b(M,T){const D=M??r.value,H=T!==void 0?T:$.value;f.value=!0,i.value=null;try{const O=new URLSearchParams({period:D});H&&O.set("formType",H);const S=await re.get(`/form-stats/timeseries?${O.toString()}`);S.success&&S.data?(c.value=S.data,ue.debug("ADMIN","Form-Stats Zeitreihe geladen",{period:D,formType:H})):(i.value=S.error||"Fehler beim Laden der Zeitreihe",ue.error("ADMIN","Form-Stats Zeitreihe Ladefehler",{error:S.error}))}catch(O){i.value="Netzwerkfehler beim Laden der Zeitreihe",ue.error("ADMIN","Form-Stats Zeitreihe Netzwerkfehler",O)}finally{f.value=!1}}async function I(M){const T=M??r.value;p.value=!0,g.value=null;try{const D=new URLSearchParams({period:T}),H=await re.get(`/form-stats/sources?${D.toString()}`);H.success&&H.data?(s.value=H.data,ue.debug("ADMIN","Form-Stats Quellen geladen",{period:T})):(g.value=H.error||"Fehler beim Laden der Quellen-Daten",ue.error("ADMIN","Form-Stats Quellen Ladefehler",{error:H.error}))}catch(D){g.value="Netzwerkfehler beim Laden der Quellen-Daten",ue.error("ADMIN","Form-Stats Quellen Netzwerkfehler",D)}finally{p.value=!1}}async function V(M){const T=M??r.value;_.value=!0,x.value=null;try{const D=new URLSearchParams({period:T}),H=await re.get(`/form-stats/by-preset?${D.toString()}`);H.success&&H.data?(m.value=H.data,ue.debug("ADMIN","Form-Stats nach Preset geladen",{period:T})):(x.value=H.error||"Fehler beim Laden der Preset-Daten",ue.error("ADMIN","Form-Stats By-Preset Ladefehler",{error:H.error}))}catch(D){x.value="Netzwerkfehler beim Laden der Preset-Daten",ue.error("ADMIN","Form-Stats By-Preset Netzwerkfehler",D)}finally{_.value=!1}}async function E(M){const T=M??r.value;M&&(r.value=M),await Promise.all([w(T),b(T,$.value),I(T),V(T)])}function R(){d.value=null,c.value=null,s.value=null,m.value=null,k.value=null,i.value=null,g.value=null,x.value=null}return{period:r,timeSeriesTypeFilter:$,overview:d,timeSeries:c,sources:s,byPreset:m,loadingOverview:u,loadingTimeSeries:f,loadingSources:p,loadingByPreset:_,errorOverview:k,errorTimeSeries:i,errorSources:g,errorByPreset:x,fetchOverview:w,fetchTimeSeries:b,fetchSources:I,fetchByPreset:V,fetchAll:E,$reset:R}}),PI={class:"d-flex align-center justify-space-between flex-wrap ga-2"},zI={class:"mb-4"},DI={key:2,class:"d-flex flex-column align-center justify-center pa-12 text-center","aria-label":"Keine Zeitreihendaten verfügbar"},TI=Ae({__name:"FormStatsTimeSeriesCard",props:{timeSeries:{},period:{},activeFilter:{},loading:{type:Boolean},error:{}},emits:["filter-change","retry","clear-error"],setup(r,{emit:$}){const d=Nt(()=>Lt(()=>import("./charts-tfNpfMZ7.js"),__vite__mapDeps([0,1,2,3]))),{baseOptions:c,BASEC_COLORS:s}=jt(),m=r,u=$,f=[{label:"Alle",value:"all"},{label:"Kontakt",value:"contact"},{label:"Newsletter",value:"newsletter"},{label:"Download",value:"gated-content"},{label:"Buchung",value:"booking"}],p=se(()=>{var x;return(((x=m.timeSeries)==null?void 0:x.buckets)??[]).map(w=>{const b=new Date(w.bucket);return m.period==="24h"?b.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):b.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})})}),_=se(()=>{var w;const g=((w=m.timeSeries)==null?void 0:w.buckets)??[],x=m.activeFilter;return x!=="all"?[{name:{contact:"Kontakt",newsletter:"Newsletter","gated-content":"Download",booking:"Buchung"}[x]??x,data:g.map(I=>I.byType[x]??0)}]:[{name:"Kontakt",color:s.primary,data:g.map(b=>b.byType.contact??0)},{name:"Newsletter",color:s.accent,data:g.map(b=>b.byType.newsletter??0)},{name:"Download",color:s.highlight,data:g.map(b=>b.byType["gated-content"]??0)},{name:"Buchung",color:s.error,data:g.map(b=>b.byType.booking??0)}]}),k=se(()=>({...c.value,chart:{...c.value.chart,type:"area",stacked:m.activeFilter==="all",animations:{enabled:!0,easing:"easeinout",speed:400}},stroke:{curve:"smooth",width:2},fill:{type:"gradient",gradient:{shadeIntensity:1,opacityFrom:.4,opacityTo:.05,stops:[0,95,100]}},xaxis:{categories:p.value,labels:{style:{colors:"#748686",fontSize:"11px"}},tickAmount:6},yaxis:{labels:{style:{colors:"#748686"},formatter:g=>Math.round(g).toString()},min:0},legend:{show:!0,labels:{colors:"#FFFFFF"}},tooltip:{theme:"dark",x:{format:"dd.MM.yyyy"}}})),i=se(()=>{var g;return!((g=m.timeSeries)!=null&&g.buckets)||m.timeSeries.buckets.length===0});return(g,x)=>{const w=l("v-icon"),b=l("v-tooltip"),I=l("v-btn"),V=l("v-card-title"),E=l("v-chip"),R=l("v-chip-group"),M=l("v-alert"),T=l("v-skeleton-loader"),D=l("v-card-text"),H=l("v-card");return o(),N(H,{variant:"outlined",rounded:"lg",class:"form-stats-timeseries-card"},{default:t(()=>[e(V,{class:"pa-4 pb-2"},{default:t(()=>[a("div",PI,[x[6]||(x[6]=a("span",{class:"text-subtitle-1 font-weight-semibold"},"Einreichungen im Zeitverlauf",-1)),e(I,{icon:"",variant:"text",size:"small",loading:r.loading,"aria-label":"Zeitreihe aktualisieren",onClick:x[0]||(x[0]=O=>u("retry"))},{default:t(()=>[e(w,null,{default:t(()=>[...x[4]||(x[4]=[n("mdi-refresh",-1)])]),_:1}),e(b,{activator:"parent",location:"bottom"},{default:t(()=>[...x[5]||(x[5]=[n("Aktualisieren",-1)])]),_:1})]),_:1},8,["loading"])])]),_:1}),e(D,{class:"pa-4 pt-2"},{default:t(()=>[a("div",zI,[e(R,{"model-value":r.activeFilter,mandatory:"","selected-class":"text-primary","onUpdate:modelValue":x[1]||(x[1]=O=>u("filter-change",O))},{default:t(()=>[(o(),h(be,null,Pe(f,O=>e(E,{key:O.value,value:O.value,variant:"outlined",size:"small"},{default:t(()=>[n(v(O.label),1)]),_:2},1032,["value"])),64))]),_:1},8,["model-value"])]),r.error?(o(),N(M,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":x[3]||(x[3]=O=>u("clear-error"))},{append:t(()=>[e(I,{variant:"text",size:"small",onClick:x[2]||(x[2]=O=>u("retry"))},{default:t(()=>[...x[7]||(x[7]=[n("Wiederholen",-1)])]),_:1})]),default:t(()=>[n(v(r.error)+" ",1)]),_:1})):U("",!0),r.loading&&!r.timeSeries?(o(),N(T,{key:1,type:"image",height:"280"})):i.value&&!r.loading?(o(),h("div",DI,[e(w,{size:"48",color:"medium-emphasis"},{default:t(()=>[...x[8]||(x[8]=[n("mdi-chart-timeline-variant",-1)])]),_:1}),x[9]||(x[9]=a("p",{class:"mt-3 text-medium-emphasis"},"Keine Formular-Daten im Zeitraum.",-1))])):r.loading?U("",!0):(o(),N(Tt,{key:3},{fallback:t(()=>[e(T,{type:"image",height:"280"})]),default:t(()=>[e(P(d),{type:"area",options:k.value,series:_.value,height:"280","aria-label":"Einreichungen im Zeitverlauf"},null,8,["options","series"])]),_:1}))]),_:1})]),_:1})}}}),LI=Me(TI,[["__scopeId","data-v-b401ef56"]]),EI={class:"d-flex align-center justify-space-between"},MI={key:1,class:"d-flex justify-center pa-8"},NI={key:2,class:"d-flex flex-column align-center justify-center pa-8 text-center","aria-label":"Keine UTM-Quelldaten verfügbar"},UI={key:0,class:"pa-4"},BI={key:1,class:"d-flex flex-column align-center justify-center pa-8 text-center"},FI={class:"text-end"},OI={class:"text-body-2 font-weight-medium text-primary"},ol=8,RI=10,KI=Ae({__name:"FormStatsSourcesCard",props:{sources:{},loading:{type:Boolean},error:{}},emits:["retry","clear-error"],setup(r,{emit:$}){const d=Nt(()=>Lt(()=>import("./charts-tfNpfMZ7.js"),__vite__mapDeps([0,1,2,3]))),{BASEC_COLORS:c}=jt(),s=r,m=$,u=se(()=>{var V;const x=((V=s.sources)==null?void 0:V.byUtmSource)??[],w=x.slice(0,ol),I=x.slice(ol).reduce((E,R)=>E+R.submissions,0);return I>0?[...w,{key:"Andere",submissions:I}]:w}),f=se(()=>u.value.map(x=>x.submissions)),p=se(()=>u.value.map(x=>x.key||"(direkt)")),_=se(()=>f.value.length===0||f.value.every(x=>x===0)),k=se(()=>({chart:{type:"donut",background:"transparent",toolbar:{show:!1}},colors:[c.primary,c.accent,c.highlight,c.error,c.subtitle,"#6A8EA0","#A06A8E","#8EA06A","#748686"],labels:p.value,legend:{show:!0,labels:{colors:"#FFFFFF"},fontSize:"12px"},dataLabels:{enabled:!1},tooltip:{theme:"dark",y:{formatter:x=>`${x} Einreichungen`}},plotOptions:{pie:{donut:{size:"65%"}}},stroke:{width:1,colors:["#000000"]}})),i=se(()=>{var x;return(((x=s.sources)==null?void 0:x.byLandingPage)??[]).slice(0,RI)});function g(x,w=50){return x.length<=w?x:`...${x.slice(-(w-3))}`}return(x,w)=>{const b=l("v-icon"),I=l("v-tooltip"),V=l("v-btn"),E=l("v-card-title"),R=l("v-alert"),M=l("v-progress-circular"),T=l("v-skeleton-loader"),D=l("v-card-text"),H=l("v-card"),O=l("v-col"),S=l("v-table"),B=l("v-row");return o(),N(B,{dense:""},{default:t(()=>[e(O,{cols:"12",lg:"6"},{default:t(()=>[e(H,{variant:"outlined",rounded:"lg",class:"form-stats-sources-card",style:{"min-height":"320px"}},{default:t(()=>[e(E,{class:"pa-4 pb-2"},{default:t(()=>[a("div",EI,[w[5]||(w[5]=a("span",{class:"text-subtitle-1 font-weight-semibold"},"Einreichungen nach Quelle",-1)),e(V,{icon:"",variant:"text",size:"small",loading:r.loading,"aria-label":"Quellen aktualisieren",onClick:w[0]||(w[0]=G=>m("retry"))},{default:t(()=>[e(b,null,{default:t(()=>[...w[3]||(w[3]=[n("mdi-refresh",-1)])]),_:1}),e(I,{activator:"parent",location:"bottom"},{default:t(()=>[...w[4]||(w[4]=[n("Aktualisieren",-1)])]),_:1})]),_:1},8,["loading"])])]),_:1}),e(D,{class:"pa-4 pt-2"},{default:t(()=>[r.error?(o(),N(R,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":w[2]||(w[2]=G=>m("clear-error"))},{append:t(()=>[e(V,{variant:"text",size:"small",onClick:w[1]||(w[1]=G=>m("retry"))},{default:t(()=>[...w[6]||(w[6]=[n("Wiederholen",-1)])]),_:1})]),default:t(()=>[n(v(r.error)+" ",1)]),_:1})):U("",!0),r.loading&&!r.sources?(o(),h("div",MI,[e(M,{indeterminate:"",color:"primary"})])):_.value&&!r.loading?(o(),h("div",NI,[e(b,{size:"40",color:"medium-emphasis"},{default:t(()=>[...w[7]||(w[7]=[n("mdi-source-branch",-1)])]),_:1}),w[8]||(w[8]=a("p",{class:"mt-3 text-medium-emphasis text-body-2"},"Keine Quelldaten verfügbar.",-1))])):r.loading?U("",!0):(o(),N(Tt,{key:3},{fallback:t(()=>[e(T,{type:"image",height:"260"})]),default:t(()=>[e(P(d),{type:"donut",options:k.value,series:f.value,height:"260","aria-label":"Einreichungen nach UTM-Quelle"},null,8,["options","series"])]),_:1}))]),_:1})]),_:1})]),_:1}),e(O,{cols:"12",lg:"6"},{default:t(()=>[e(H,{variant:"outlined",rounded:"lg",class:"form-stats-sources-card",style:{"min-height":"320px"}},{default:t(()=>[e(E,{class:"pa-4 pb-2"},{default:t(()=>[...w[9]||(w[9]=[a("span",{class:"text-subtitle-1 font-weight-semibold"},"Top-Landing-Pages",-1)])]),_:1}),e(D,{class:"pa-0"},{default:t(()=>[r.loading&&!r.sources?(o(),h("div",UI,[(o(),h(be,null,Pe(5,G=>e(T,{key:G,type:"list-item",class:"mb-1"})),64))])):i.value.length===0&&!r.loading?(o(),h("div",BI,[e(b,{size:"40",color:"medium-emphasis"},{default:t(()=>[...w[10]||(w[10]=[n("mdi-web",-1)])]),_:1}),w[11]||(w[11]=a("p",{class:"mt-3 text-medium-emphasis text-body-2"},"Keine Landing-Page-Daten.",-1))])):(o(),N(S,{key:2,density:"compact",class:"form-stats-sources-card__landing-table"},{default:t(()=>[w[12]||(w[12]=a("thead",null,[a("tr",null,[a("th",{class:"text-caption text-medium-emphasis"},"Seite"),a("th",{class:"text-caption text-medium-emphasis text-end",style:{width:"120px"}},"Einreichungen")])],-1)),a("tbody",null,[(o(!0),h(be,null,Pe(i.value,(G,W)=>(o(),h("tr",{key:W,class:"form-stats-sources-card__landing-row"},[a("td",null,[e(I,{location:"top",text:G.page,disabled:G.page.length<=50},{activator:t(({props:F})=>[a("span",Vt({ref_for:!0},F,{class:"text-body-2 text-medium-emphasis"}),v(g(G.page)),17)]),_:2},1032,["text","disabled"])]),a("td",FI,[a("span",OI,v(G.submissions.toLocaleString("de-DE")),1)])]))),128))])]),_:1}))]),_:1})]),_:1})]),_:1})]),_:1})}}}),jI=Me(KI,[["__scopeId","data-v-37079711"]]),qI={class:"form-stats-view"},GI={class:"form-stats-view__header"},HI={class:"d-flex align-center ga-3 flex-wrap"},WI={key:1,class:"d-flex align-center ga-2"},ZI={class:"text-h5 font-weight-bold text-primary"},JI={class:"d-flex align-center ga-1 mb-1"},QI={key:1,class:"text-h5 font-weight-bold"},YI={key:1,class:"text-h5 font-weight-bold text-accent"},XI={class:"text-body-1 font-weight-bold text-truncate"},eP={class:"text-caption text-medium-emphasis mt-1"},tP={key:2,class:"text-body-2 text-medium-emphasis"},aP={class:"mb-6"},lP={class:"d-flex align-center justify-space-between"},nP=["onClick"],oP={class:"d-flex flex-column"},sP={class:"text-body-2 font-weight-medium"},iP={class:"text-caption text-medium-emphasis"},rP={class:"text-body-2"},dP={class:"text-body-2 font-weight-medium text-primary"},uP={class:"text-body-2 text-medium-emphasis"},cP={class:"text-body-2"},mP={class:"text-caption text-medium-emphasis"},vP={key:1,class:"text-caption text-medium-emphasis"},pP={class:"py-12 text-center"},fP=Ae({__name:"FormStatsView",setup(r){const $=xt(),d=II(),c=qe("form_stats_period","30d"),s=[{label:"24h",value:"24h"},{label:"7d",value:"7d"},{label:"30d",value:"30d"},{label:"90d",value:"90d"}],m=y("all"),u=y([{key:"submissionsInPeriod",order:"desc"}]),f=se(()=>{var M;return((M=d.overview)==null?void 0:M.totalSubmissions)??0}),p=se(()=>{var M;return((M=d.overview)==null?void 0:M.totalViewsCumulative)??0}),_=se(()=>{var T;return((((T=d.overview)==null?void 0:T.overallConversionRate)??0)*100).toFixed(1)}),k=se(()=>{var M,T,D;return((D=(T=(M=d.overview)==null?void 0:M.trends)==null?void 0:T.submissions)==null?void 0:D.delta)??0}),i=se(()=>k.value>=0),g=se(()=>{var M,T;return((T=(M=d.overview)==null?void 0:M.byPreset)==null?void 0:T[0])??null}),x=[{title:"Formular",key:"title",sortable:!0},{title:"Views (gesamt)",key:"viewsCumulative",sortable:!0,align:"end",width:"130px"},{title:"Einreichungen (Zeitraum)",key:"submissionsInPeriod",sortable:!0,align:"end",width:"200px"},{title:"Einreichungen (gesamt)",key:"submissionsCumulative",sortable:!0,align:"end",width:"180px"},{title:"Conversion",key:"conversionRate",sortable:!0,align:"end",width:"120px"},{title:"Letzte Einreichung",key:"lastSubmissionAt",sortable:!0,width:"160px"},{title:"Top-Quelle",key:"topUtmSource",sortable:!1,width:"120px"}];function w(M){return`${(M*100).toFixed(1)} %`}function b(M){return M?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(new Date(M)):"–"}function I(M){return{contact:"Kontakt",newsletter:"Newsletter","gated-content":"Download",booking:"Buchung"}[M]??M}function V(M){return{contact:"primary",newsletter:"info","gated-content":"success",booking:"accent"}[M]??"default"}function E(M,T){const D=new URLSearchParams;D.set("presetSlug",M);const H=T==="download"?"gated-content":T;D.set("formType",H);const O=new Date,S=new Date(O);c.value==="24h"?S.setHours(S.getHours()-24):c.value==="7d"?S.setDate(S.getDate()-7):c.value==="30d"?S.setDate(S.getDate()-30):c.value==="90d"&&S.setDate(S.getDate()-90),D.set("submittedFrom",S.toISOString()),D.set("submittedTo",O.toISOString()),$.push(`/admin/leads?${D.toString()}`),ue.info("ADMIN","Drill-Down zu Leads",{slug:M,kind:T,period:c.value})}async function R(M){m.value=M;const T=M==="all"?null:M;d.timeSeriesTypeFilter=T,await d.fetchTimeSeries(c.value,T)}return rt(async()=>{d.period=c.value,await d.fetchAll(c.value)}),Ze(c,async M=>{M!==d.period&&await d.fetchAll(M)}),(M,T)=>{const D=l("v-chip"),H=l("v-chip-group"),O=l("v-progress-circular"),S=l("v-btn"),B=l("v-alert"),G=l("v-skeleton-loader"),W=l("v-icon"),F=l("v-card-text"),L=l("v-card"),A=l("v-col"),z=l("v-tooltip"),j=l("v-row"),J=l("v-card-title"),Q=l("v-data-table");return o(),h("div",qI,[a("div",GI,[T[11]||(T[11]=a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"Formular-Performance"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"}," Kontakt, Newsletter, Downloads, Buchungen ")],-1)),a("div",HI,[e(H,{modelValue:P(c),"onUpdate:modelValue":T[0]||(T[0]=te=>ot(c)?c.value=te:null),mandatory:"","selected-class":"text-primary"},{default:t(()=>[(o(),h(be,null,Pe(s,te=>e(D,{key:te.value,value:te.value,variant:"outlined",size:"small"},{default:t(()=>[n(v(te.label),1)]),_:2},1032,["value"])),64))]),_:1},8,["modelValue"]),P(d).loadingOverview||P(d).loadingTimeSeries||P(d).loadingSources||P(d).loadingByPreset?(o(),N(O,{key:0,indeterminate:"",color:"primary",size:"20",width:"2"})):U("",!0)])]),P(d).errorOverview&&!P(d).overview?(o(),N(B,{key:0,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":T[2]||(T[2]=te=>P(d).errorOverview=null)},{append:t(()=>[e(S,{variant:"text",size:"small",onClick:T[1]||(T[1]=te=>P(d).fetchAll(P(c)))},{default:t(()=>[...T[12]||(T[12]=[n("Erneut versuchen",-1)])]),_:1})]),default:t(()=>[n(v(P(d).errorOverview)+" ",1)]),_:1})):U("",!0),e(j,{class:"mb-6",dense:""},{default:t(()=>[e(A,{cols:"12",sm:"6",lg:"3"},{default:t(()=>[e(L,{variant:"tonal",rounded:"lg",class:"form-stats-view__kpi-card","aria-label":"Einreichungen im Zeitraum"},{default:t(()=>[e(F,{class:"pa-4"},{default:t(()=>[T[13]||(T[13]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Einreichungen (Zeitraum)",-1)),P(d).loadingOverview&&!P(d).overview?(o(),N(G,{key:0,type:"text",width:"80"})):(o(),h("div",WI,[a("span",ZI,v(f.value.toLocaleString("de-DE")),1),P(d).overview?(o(),h("div",{key:0,class:ft(["d-flex align-center text-caption",i.value?"text-success":"text-error"])},[e(W,{size:"14"},{default:t(()=>[n(v(i.value?"mdi-trending-up":"mdi-trending-down"),1)]),_:1}),a("span",null,v(Math.abs(k.value)),1)],2)):U("",!0)])),T[14]||(T[14]=a("div",{class:"text-caption text-medium-emphasis mt-1"},"vs. Vorperiode",-1))]),_:1})]),_:1})]),_:1}),e(A,{cols:"12",sm:"6",lg:"3"},{default:t(()=>[e(L,{variant:"tonal",rounded:"lg",class:"form-stats-view__kpi-card","aria-label":"Gesamtaufrufe kumulativ"},{default:t(()=>[e(F,{class:"pa-4"},{default:t(()=>[a("div",JI,[T[17]||(T[17]=a("span",{class:"text-caption text-medium-emphasis"},"Views (gesamt kumulativ)",-1)),e(z,{location:"top","max-width":"260"},{activator:t(({props:te})=>[e(W,Vt(te,{size:"14",color:"medium-emphasis"}),{default:t(()=>[...T[15]||(T[15]=[n("mdi-information-outline",-1)])]),_:1},16)]),default:t(()=>[T[16]||(T[16]=n(" Kumulative Preset-Aufrufe, nicht zeitbegrenzt ",-1))]),_:1})]),P(d).loadingOverview&&!P(d).overview?(o(),N(G,{key:0,type:"text",width:"80"})):(o(),h("div",QI,v(p.value.toLocaleString("de-DE")),1))]),_:1})]),_:1})]),_:1}),e(A,{cols:"12",sm:"6",lg:"3"},{default:t(()=>[e(L,{variant:"tonal",rounded:"lg",class:"form-stats-view__kpi-card","aria-label":"Gesamt-Conversion-Rate"},{default:t(()=>[e(F,{class:"pa-4"},{default:t(()=>[T[18]||(T[18]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Conversion-Rate",-1)),P(d).loadingOverview&&!P(d).overview?(o(),N(G,{key:0,type:"text",width:"80"})):(o(),h("div",YI,v(_.value)+" % ",1)),T[19]||(T[19]=a("div",{class:"text-caption text-medium-emphasis mt-1"},"Einreichungen / Views",-1))]),_:1})]),_:1})]),_:1}),e(A,{cols:"12",sm:"6",lg:"3"},{default:t(()=>[e(L,{variant:"tonal",rounded:"lg",class:"form-stats-view__kpi-card","aria-label":"Top-Formular nach Einreichungen"},{default:t(()=>[e(F,{class:"pa-4"},{default:t(()=>[T[20]||(T[20]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Top-Formular",-1)),P(d).loadingOverview&&!P(d).overview?(o(),N(G,{key:0,type:"text",width:"160"})):g.value?(o(),h(be,{key:1},[a("div",XI,v(g.value.title),1),a("div",eP,v(g.value.submissions.toLocaleString("de-DE"))+" Einreichungen ",1)],64)):(o(),h("div",tP,"Keine Daten"))]),_:1})]),_:1})]),_:1})]),_:1}),a("div",aP,[e(LI,{"time-series":P(d).timeSeries,period:P(c),"active-filter":m.value,loading:P(d).loadingTimeSeries,error:P(d).errorTimeSeries,onFilterChange:R,onRetry:T[3]||(T[3]=te=>P(d).fetchTimeSeries(P(c),m.value==="all"?null:m.value)),onClearError:T[4]||(T[4]=te=>P(d).errorTimeSeries=null)},null,8,["time-series","period","active-filter","loading","error"])]),e(L,{variant:"outlined",rounded:"lg",class:"form-stats-view__section-card mb-6"},{default:t(()=>[e(J,{class:"pa-4 pb-2"},{default:t(()=>[a("div",lP,[T[23]||(T[23]=a("span",{class:"text-subtitle-1 font-weight-semibold"},"Formular-Übersicht",-1)),e(S,{icon:"",variant:"text",size:"small",loading:P(d).loadingByPreset,"aria-label":"Formular-Tabelle aktualisieren",onClick:T[5]||(T[5]=te=>P(d).fetchByPreset(P(c)))},{default:t(()=>[e(W,null,{default:t(()=>[...T[21]||(T[21]=[n("mdi-refresh",-1)])]),_:1}),e(z,{activator:"parent",location:"bottom"},{default:t(()=>[...T[22]||(T[22]=[n("Aktualisieren",-1)])]),_:1})]),_:1},8,["loading"])])]),_:1}),e(F,{class:"pa-0"},{default:t(()=>{var te;return[P(d).errorByPreset?(o(),N(B,{key:0,type:"error",variant:"tonal",density:"compact",class:"ma-4",closable:"","onClick:close":T[7]||(T[7]=ve=>P(d).errorByPreset=null)},{append:t(()=>[e(S,{variant:"text",size:"small",onClick:T[6]||(T[6]=ve=>P(d).fetchByPreset(P(c)))},{default:t(()=>[...T[24]||(T[24]=[n("Wiederholen",-1)])]),_:1})]),default:t(()=>[n(v(P(d).errorByPreset)+" ",1)]),_:1})):U("",!0),e(Q,{headers:x,items:((te=P(d).byPreset)==null?void 0:te.items)??[],loading:P(d).loadingByPreset,"loading-text":"Formular-Daten werden geladen...","no-data-text":"Keine Formular-Daten im Zeitraum.","item-value":"slug",class:"form-stats-view__table",density:"comfortable","items-per-page":25,"sort-by":u.value,"onUpdate:sortBy":T[8]||(T[8]=ve=>u.value=ve),hover:""},{"item.title":t(({item:ve})=>[a("div",{class:"d-flex align-center ga-2 form-stats-view__table-row",onClick:de=>E(ve.slug,ve.kind)},[e(D,{color:V(ve.kind),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(I(ve.kind)),1)]),_:2},1032,["color"]),a("div",oP,[a("span",sP,v(ve.title),1),a("span",iP,v(ve.slug),1)])],8,nP)]),"item.viewsCumulative":t(({item:ve})=>[a("span",rP,v(ve.viewsCumulative.toLocaleString("de-DE")),1)]),"item.submissionsInPeriod":t(({item:ve})=>[a("span",dP,v(ve.submissionsInPeriod.toLocaleString("de-DE")),1)]),"item.submissionsCumulative":t(({item:ve})=>[a("span",uP,v(ve.submissionsCumulative.toLocaleString("de-DE")),1)]),"item.conversionRate":t(({item:ve})=>[a("span",cP,v(w(ve.conversionRate)),1)]),"item.lastSubmissionAt":t(({item:ve})=>[a("span",mP,v(b(ve.lastSubmissionAt)),1)]),"item.topUtmSource":t(({item:ve})=>[ve.topUtmSource?(o(),N(D,{key:0,size:"x-small",variant:"outlined"},{default:t(()=>[n(v(ve.topUtmSource),1)]),_:2},1024)):(o(),h("span",vP,"–"))]),"no-data":t(()=>[a("div",pP,[e(W,{size:"48",color:"grey-darken-1",class:"mb-3"},{default:t(()=>[...T[25]||(T[25]=[n("mdi-chart-box-outline",-1)])]),_:1}),T[26]||(T[26]=a("p",{class:"text-body-2 text-medium-emphasis"},"Keine Formular-Daten im Zeitraum.",-1))])]),_:1},8,["items","loading","sort-by"])]}),_:1})]),_:1}),e(jI,{sources:P(d).sources,loading:P(d).loadingSources,error:P(d).errorSources,onRetry:T[9]||(T[9]=te=>P(d).fetchSources(P(c))),onClearError:T[10]||(T[10]=te=>P(d).errorSources=null)},null,8,["sources","loading","error"])])}}}),gP=Me(fP,[["__scopeId","data-v-d3347336"]]),K6=Object.freeze(Object.defineProperty({__proto__:null,default:gP},Symbol.toStringTag,{value:"Module"})),Il=Zt("pipelineStats",()=>{const r=y("30d"),$=qe("pipeline_source_scope","platform"),d=y(30),c=y(null),s=y(null),m=y(null),u=y([]),f=y([]),p=y(!1),_=y(!1),k=y(!1),i=y(!1),g=y(!1),x=y(null),w=y(null),b=y(null),I=y(null),V=y(null);async function E(L){const A=L??r.value;p.value=!0,x.value=null;try{const z=new URLSearchParams({period:A});z.set("sourceScope",$.value);const j=await re.get(`/pipeline-stats/overview?${z.toString()}`);j.success&&j.data?(c.value=j.data,ue.debug("ADMIN","Pipeline Overview geladen",{period:A,sourceScope:$.value})):(x.value=j.error||"Fehler beim Laden der Pipeline-Statistiken",ue.error("ADMIN","Pipeline Overview Ladefehler",{error:j.error}))}catch(z){x.value="Netzwerkfehler beim Laden der Pipeline-Statistiken",ue.error("ADMIN","Pipeline Overview Netzwerkfehler",z)}finally{p.value=!1}}async function R(){_.value=!0,w.value=null;try{const L=new URLSearchParams;L.set("sourceScope",$.value);const A=await re.get(`/pipeline-stats/score-histogram?${L.toString()}`);A.success&&A.data?(s.value=A.data,ue.debug("ADMIN","Score-Histogramm geladen",{sourceScope:$.value})):(w.value=A.error||"Fehler beim Laden des Score-Histogramms",ue.error("ADMIN","Score-Histogramm Ladefehler",{error:A.error}))}catch(L){w.value="Netzwerkfehler beim Laden des Score-Histogramms",ue.error("ADMIN","Score-Histogramm Netzwerkfehler",L)}finally{_.value=!1}}async function M(L){const A=L??r.value,z=A==="24h"||A==="all-time"?"30d":A;k.value=!0,b.value=null;try{const j=new URLSearchParams({period:z});j.set("sourceScope",$.value);const J=await re.get(`/pipeline-stats/engagement-trend?${j.toString()}`);J.success&&J.data?(m.value=J.data,ue.debug("ADMIN","Engagement-Trend geladen",{period:z,sourceScope:$.value})):(b.value=J.error||"Fehler beim Laden der Engagement-Daten",ue.error("ADMIN","Engagement-Trend Ladefehler",{error:J.error}))}catch(j){b.value="Netzwerkfehler beim Laden der Engagement-Daten",ue.error("ADMIN","Engagement-Trend Netzwerkfehler",j)}finally{k.value=!1}}async function T(L=20){i.value=!0,I.value=null;try{const A=new URLSearchParams({limit:String(L)});A.set("sourceScope",$.value);const z=await re.get(`/pipeline-stats/hot-leads?${A.toString()}`);z.success&&z.data?(u.value=z.data,ue.debug("ADMIN","Hot Leads geladen",{count:z.data.length,sourceScope:$.value})):(I.value=z.error||"Fehler beim Laden der Hot Leads",ue.error("ADMIN","Hot Leads Ladefehler",{error:z.error}))}catch(A){I.value="Netzwerkfehler beim Laden der Hot Leads",ue.error("ADMIN","Hot Leads Netzwerkfehler",A)}finally{i.value=!1}}async function D(L){const A=L??d.value;g.value=!0,V.value=null;try{const z=new URLSearchParams({daysSinceActivity:String(A)});z.set("sourceScope",$.value);const j=await re.get(`/pipeline-stats/stuck-leads?${z.toString()}`);j.success&&j.data?(f.value=j.data,ue.debug("ADMIN","Stuck Leads geladen",{count:j.data.length,daysSince:A,sourceScope:$.value})):(V.value=j.error||"Fehler beim Laden der inaktiven Leads",ue.error("ADMIN","Stuck Leads Ladefehler",{error:j.error}))}catch(z){V.value="Netzwerkfehler beim Laden der inaktiven Leads",ue.error("ADMIN","Stuck Leads Netzwerkfehler",z)}finally{g.value=!1}}async function H(L){const A=L??r.value;L&&(r.value=L),await Promise.all([E(A),R(),M(A),T(20),D(d.value)])}async function O(L,A){try{const z=await re.patch(`/leads/${L}/stage`,{stage:A});return z.success?(ue.info("ADMIN","Lead Stage gewechselt",{leadId:L,newStage:A}),!0):(ue.error("ADMIN","Lead Stage-Wechsel fehlgeschlagen",{leadId:L,newStage:A,error:z.error}),!1)}catch(z){return ue.error("ADMIN","Lead Stage-Wechsel Netzwerkfehler",z),!1}}async function S(){await Promise.all([E(r.value),T(),D(d.value)])}function B(L){r.value=L}function G(L){d.value=L}async function W(L){$.value=L,await H(r.value)}function F(){c.value=null,s.value=null,m.value=null,u.value=[],f.value=[],x.value=null,w.value=null,b.value=null,I.value=null,V.value=null,$.value="platform"}return{period:r,sourceScope:$,stuckDaysThreshold:d,overview:c,scoreHistogram:s,engagementTrend:m,hotLeads:u,stuckLeads:f,loadingOverview:p,loadingHistogram:_,loadingEngagement:k,loadingHotLeads:i,loadingStuckLeads:g,errorOverview:x,errorHistogram:w,errorEngagement:b,errorHotLeads:I,errorStuckLeads:V,fetchOverview:E,fetchHistogram:R,fetchEngagement:M,fetchHotLeads:T,fetchStuckLeads:D,fetchAll:H,moveLeadStage:O,handleStageChange:S,setPeriod:B,setStuckDays:G,setSourceScope:W,$reset:F}}),bP={class:"pipeline-kanban"},yP={class:"pipeline-kanban__board"},_P=["onDragover","onDragleave","onDrop"],kP={class:"pipeline-kanban__col-header"},hP={class:"text-caption font-weight-bold text-uppercase"},xP=["onDragstart","onClick"],wP={class:"d-flex align-start justify-space-between ga-1 mb-1"},SP={class:"text-body-2 font-weight-medium pipeline-kanban__name"},$P={class:"d-flex align-center ga-1 flex-shrink-0"},CP={key:0,class:"text-caption text-medium-emphasis mb-1 text-truncate"},VP={class:"d-flex align-center ga-1 flex-wrap"},AP={key:1,class:"text-caption text-medium-emphasis"},IP={key:0,class:"pipeline-kanban__empty"},PP=Ae({__name:"PipelineKanban",props:{stuckLeadIds:{default:()=>[]}},emits:["lead-click","stage-changed"],setup(r,{expose:$,emit:d}){const c=[{key:"neu",label:"Neu",color:"#0AC9D4"},{key:"kontaktiert",label:"Kontaktiert",color:"#5b8bff"},{key:"qualifiziert",label:"Qualifiziert",color:"#E2F54B"},{key:"angebot",label:"Angebot",color:"#C9A063"},{key:"verhandlung",label:"Verhandlung",color:"#ff9800"},{key:"gewonnen",label:"Gewonnen",color:"#66BB6A"},{key:"verloren",label:"Verloren",color:"#CF6679"}],s={hot:"Hot",warm:"Warm",cold:"Cold",stuck:"Stuck","single-converter":"1x Conv.","multi-converter":"Multi Conv.","power-lead":"Power",bounced:"Bounced",unsubscribed:"Abgem.","awaiting-next-step":"Wartet",active:"Aktiv"},m={hot:"warning",warm:"secondary",cold:"default",stuck:"error","single-converter":"primary","multi-converter":"primary","power-lead":"success",bounced:"error",unsubscribed:"default","awaiting-next-step":"default",active:"primary"},u=r,f=se(()=>new Set(u.stuckLeadIds)),p=d,_=Il(),k=y({neu:[],kontaktiert:[],qualifiziert:[],angebot:[],verhandlung:[],gewonnen:[],verloren:[]}),i=y(!1),g=y(null),x=y(null),w=y(null),b=y(null),I=y(!1),V=y(!1),E=y(""),R=y("success");async function M(){i.value=!0,g.value=null;try{const F=_.sourceScope,L=await Promise.allSettled(c.map(z=>{const j=new URLSearchParams({stage:z.key,isActive:"true",limit:"50",sortBy:"scoring.total",sortOrder:"desc",sourceScope:F});return re.get(`/leads?${j.toString()}`)})),A={neu:[],kontaktiert:[],qualifiziert:[],angebot:[],verhandlung:[],gewonnen:[],verloren:[]};L.forEach((z,j)=>{const J=c[j].key;if(z.status==="fulfilled"&&z.value.success&&z.value.data){const Q=z.value.data;A[J]=(Q.items??[]).map(te=>{var de,Z;let ve=null;if(te.lastInteractionAt){const ce=Date.now()-new Date(te.lastInteractionAt).getTime();ve=Math.floor(ce/(1e3*60*60*24))}return{_id:te._id,email:te.email,firstName:te.firstName??"",lastName:te.lastName??"",company:te.company??"",scoringTotal:((de=te.scoring)==null?void 0:de.total)??0,engagementState:te.engagementState??"",sourceType:((Z=te.source)==null?void 0:Z.type)??"",lastActivityDays:ve}})}}),k.value=A,ue.debug("ADMIN","Kanban Leads geladen",{sourceScope:F})}catch(F){g.value="Fehler beim Laden der Kanban-Leads",ue.error("ADMIN","Kanban Leads Ladefehler",F)}finally{i.value=!1}}function T(F){const L=[F.firstName,F.lastName].filter(Boolean);return L.length>0?L.join(" "):F.email}function D(F){return F>=70?"success":F>=40?"warning":"error"}function H(F,L="success"){E.value=F,R.value=L,V.value=!0}function O(F,L,A){x.value=L,w.value=A,F.dataTransfer&&(F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/plain",L))}function S(){x.value=null,w.value=null,b.value=null}function B(F,L){F.preventDefault(),b.value=L,F.dataTransfer&&(F.dataTransfer.dropEffect="move")}function G(F){b.value===F&&(b.value=null)}async function W(F,L){var Q;if(F.preventDefault(),b.value=null,I.value){x.value=null,w.value=null;return}const A=x.value,z=w.value;if(x.value=null,w.value=null,!A||!z||z===L)return;const j=k.value[z].findIndex(te=>te._id===A);if(j===-1)return;const J=k.value[z][j];I.value=!0,k.value[z].splice(j,1),k.value[L].unshift(J);try{if(await _.moveLeadStage(A,L)){const ve=((Q=c.find(de=>de.key===L))==null?void 0:Q.label)??L;H(`Lead in "${ve}" verschoben`),p("stage-changed")}else{const ve=k.value[L].findIndex(de=>de._id===A);ve!==-1&&(k.value[L].splice(ve,1),k.value[z].splice(j,0,J)),H("Fehler beim Verschieben des Leads","error"),ue.error("ADMIN","Kanban Stage-Wechsel Rollback",{leadId:A})}}finally{I.value=!1}}return Ze(()=>_.sourceScope,F=>{M()}),$({load:M}),(F,L)=>{const A=l("v-btn"),z=l("v-alert"),j=l("v-chip"),J=l("v-skeleton-loader"),Q=l("v-tooltip"),te=l("v-icon"),ve=l("v-snackbar");return o(),h("div",bP,[g.value?(o(),N(z,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-3",closable:"","onClick:close":L[0]||(L[0]=de=>g.value=null)},{append:t(()=>[e(A,{variant:"text",size:"small",onClick:M},{default:t(()=>[...L[2]||(L[2]=[n("Wiederholen",-1)])]),_:1})]),default:t(()=>[n(v(g.value)+" ",1)]),_:1})):U("",!0),a("div",yP,[(o(),h(be,null,Pe(c,de=>a("div",{key:de.key,class:ft(["pipeline-kanban__col",{"pipeline-kanban__col--dragover":b.value===de.key}]),onDragover:dt(Z=>B(Z,de.key),["prevent"]),onDragleave:Z=>G(de.key),onDrop:dt(Z=>W(Z,de.key),["prevent"])},[a("div",kP,[a("span",{class:"pipeline-kanban__stage-dot",style:ht({background:de.color})},null,4),a("span",hP,v(de.label),1),e(j,{size:"x-small",variant:"tonal",class:"ml-auto"},{default:t(()=>[n(v(k.value[de.key].length.toLocaleString("de-DE")),1)]),_:2},1024)]),i.value&&k.value[de.key].length===0?(o(),h(be,{key:0},Pe(3,Z=>e(J,{key:Z,type:"card",class:"mb-2",height:"88"})),64)):(o(),h(be,{key:1},[(o(!0),h(be,null,Pe(k.value[de.key],Z=>(o(),h("div",{key:Z._id,draggable:"true",class:ft(["pipeline-kanban__card",{"pipeline-kanban__card--dragging":x.value===Z._id}]),style:ht({borderLeftColor:de.color}),onDragstart:ce=>O(ce,Z._id,de.key),onDragend:S,onClick:ce=>p("lead-click",Z._id)},[a("div",wP,[a("span",SP,v(T(Z)),1),a("div",$P,[f.value.has(Z._id)?(o(),N(te,{key:0,color:"warning",size:"16",class:"pipeline-kanban__stuck-marker"},{default:t(()=>[L[4]||(L[4]=n(" mdi-alert-circle-outline ",-1)),e(Q,{activator:"parent",location:"top","max-width":"260"},{default:t(()=>[...L[3]||(L[3]=[n(" Inaktiv: Sequenz läuft, aber keine Reaktion seit der gewählten Schwelle. ",-1)])]),_:1})]),_:1})):U("",!0),e(j,{color:D(Z.scoringTotal),size:"x-small",variant:"tonal"},{default:t(()=>[n(v(Z.scoringTotal),1)]),_:2},1032,["color"])])]),Z.company?(o(),h("div",CP,v(Z.company),1)):U("",!0),a("div",VP,[Z.engagementState?(o(),N(j,{key:0,size:"x-small",color:m[Z.engagementState],variant:"tonal"},{default:t(()=>[n(v(s[Z.engagementState]??Z.engagementState),1)]),_:2},1032,["color"])):U("",!0),Z.lastActivityDays!==null?(o(),h("span",AP," vor "+v(Z.lastActivityDays)+" T. ",1)):U("",!0)])],46,xP))),128)),k.value[de.key].length===0?(o(),h("div",IP," Keine Leads in dieser Phase ")):U("",!0)],64))],42,_P)),64))]),e(ve,{modelValue:V.value,"onUpdate:modelValue":L[1]||(L[1]=de=>V.value=de),color:R.value,timeout:3e3,location:"bottom right"},{default:t(()=>[n(v(E.value),1)]),_:1},8,["modelValue","color"])])}}}),zP=Me(PP,[["__scopeId","data-v-ee30a417"]]),DP={class:"pipeline-view"},TP={class:"pipeline-view__header"},LP={class:"d-flex align-end ga-4 flex-wrap pipeline-view__header-controls"},EP={class:"pipeline-view__filter-group"},MP={class:"pipeline-view__filter-group"},NP={class:"d-flex align-center ga-1 mb-1"},UP={key:1,class:"text-h5 font-weight-bold text-primary"},BP={key:1},FP={class:"text-h5 font-weight-bold"},OP={key:0,class:"text-caption text-medium-emphasis mt-1"},RP={class:"d-flex align-center justify-space-between mb-1"},KP={key:1},jP={class:"text-h5 font-weight-bold text-accent"},qP={class:"text-caption text-medium-emphasis mt-1"},GP={class:"d-flex align-center justify-space-between mb-1"},HP={key:1,class:"text-h5 font-weight-bold text-success"},WP={class:"d-flex align-center justify-space-between"},ZP={class:"d-flex align-center justify-space-between"},JP={class:"d-flex ga-6 mt-3"},QP={class:"text-caption text-medium-emphasis"},YP={class:"font-weight-bold text-primary"},XP={class:"text-caption text-medium-emphasis"},ez={class:"font-weight-bold text-primary"},tz={class:"text-caption text-medium-emphasis"},az={class:"font-weight-bold"},lz={key:3,class:"py-12 text-center"},nz={class:"d-flex align-center justify-space-between"},oz={key:1,class:"d-flex flex-column align-center justify-center",style:{height:"300px"}},sz={class:"text-caption text-medium-emphasis mb-2"},iz={key:1,class:"d-flex flex-column align-center justify-center",style:{height:"300px"}},rz={key:3,class:"py-12 text-center"},dz={class:"d-flex align-center justify-space-between"},uz={class:"d-flex align-center ga-2"},cz={class:"d-flex align-center ga-2"},mz={class:"text-caption font-weight-bold"},vz={class:"text-body-2 font-weight-medium"},pz={class:"text-caption text-medium-emphasis"},fz={class:"text-body-2"},gz={class:"text-caption text-medium-emphasis"},bz={class:"text-caption text-medium-emphasis"},yz={class:"py-12 text-center"},_z={class:"d-flex align-center justify-space-between flex-wrap ga-2"},kz={class:"d-flex align-center ga-2"},hz={class:"d-flex align-center ga-2"},xz={class:"d-flex align-center ga-2"},wz={class:"text-caption font-weight-bold"},Sz={class:"text-body-2 font-weight-medium"},$z={class:"text-caption text-medium-emphasis"},Cz={class:"text-body-2"},Vz={class:"text-body-2"},Az={class:"text-caption text-medium-emphasis ml-1"},Iz={key:1,class:"text-caption text-medium-emphasis"},Pz={class:"py-12 text-center"},zz={class:"text-body-2 text-medium-emphasis"},Dz=Ae({__name:"PipelineView",setup(r){const $=Nt(()=>Lt(()=>import("./charts-tfNpfMZ7.js"),__vite__mapDeps([0,1,2,3]))),d=xt(),c=Il(),{BASEC_COLORS:s,baseOptions:m}=jt(),u=y(null),f=qe("pipeline_period","30d"),p=[{label:"24h",value:"24h"},{label:"7d",value:"7d"},{label:"30d",value:"30d"},{label:"90d",value:"90d"},{label:"All-time",value:"all-time"}],_=[{label:"Plattform",value:"platform",tooltip:"Echte Leads aus Formular/Newsletter plus HubSpot-Importe mit Plattform-Konvertierung"},{label:"HubSpot",value:"hubspot",tooltip:"HubSpot-/Gmail-Importe ohne Plattform-Formular-Aktivitaet"},{label:"Alle",value:"all",tooltip:"Alle Leads ungefiltert"}];async function k(de){await c.setSourceScope(de)}const i=se(()=>{switch(f.value){case"24h":return"24h";case"7d":return"7d";case"30d":return"30d";case"90d":return"90d";case"all-time":return"Seit Start";default:return""}}),g=se(()=>c.stuckLeads.map(de=>de._id)),x=se(()=>{var oe;const de=(oe=c.overview)==null?void 0:oe.stageConversionRates;if(!de||de.length===0)return null;const Z=de.find(pe=>pe.fromStage==="neu"&&pe.toStage==="gewonnen");if(Z)return Z.rate;const ce=de.reduce((pe,_e)=>pe*_e.rate,1);return ce>0?ce:null}),w=se(()=>{var Z,ce;const de=(Z=c.overview)==null?void 0:Z.stageConversionRates;return!de||de.length===0?0:((ce=de[0])==null?void 0:ce.baseCount)??0}),b=se(()=>{var de;return{...m.value,chart:{...m.value.chart,type:"bar",animations:{enabled:!0,easing:"easeinout",speed:400}},plotOptions:{bar:{horizontal:!1,borderRadius:4,columnWidth:"70%"}},colors:[s.primary],xaxis:{categories:((de=c.scoreHistogram)==null?void 0:de.buckets.map(Z=>Z.range))??[],labels:{style:{colors:s.subtitle,fontSize:"11px"}}},yaxis:{labels:{style:{colors:s.subtitle},formatter:Z=>String(Math.round(Z))}},dataLabels:{enabled:!1},tooltip:{theme:"dark",y:{formatter:Z=>`${Z} Leads`}}}}),I=se(()=>{var de;return[{name:"Leads",data:((de=c.scoreHistogram)==null?void 0:de.buckets.map(Z=>Z.count))??[]}]}),V={hot:"#E2F54B",warm:"#C9A063",cold:"#748686",stuck:"#CF6679","single-converter":"#0AC9D4","multi-converter":"#5b8bff","power-lead":"#66BB6A",bounced:"#CF6679",unsubscribed:"#748686","awaiting-next-step":"#9E9E9E",active:"#0AC9D4"},E={hot:"Hot",warm:"Warm",cold:"Cold",stuck:"Stuck","single-converter":"Einmal konvertiert","multi-converter":"Mehrfach konvertiert","power-lead":"Power-Lead",bounced:"Bounced",unsubscribed:"Abgemeldet","awaiting-next-step":"Wartet auf naechsten Schritt",active:"Aktiv"},R=se(()=>{var _e;const de=((_e=c.engagementTrend)==null?void 0:_e.currentStates)??{},Z=Object.entries(de).filter(([,q])=>q>0).sort((q,C)=>C[1]-q[1]),ce=Z.slice(0,8),pe=Z.slice(8).reduce((q,[,C])=>q+C,0);return pe>0&&ce.push(["andere",pe]),ce}),M=se(()=>R.value.map(([,de])=>de)),T=se(()=>({chart:{background:s.background,foreColor:s.text,fontFamily:"Lato, Arial, sans-serif",toolbar:{show:!1}},theme:{mode:"dark"},labels:R.value.map(([de])=>E[de]??de),colors:R.value.map(([de])=>V[de]??s.primary),legend:{position:"bottom",labels:{colors:s.text},fontSize:"12px",fontFamily:"Lato, Arial, sans-serif"},dataLabels:{enabled:!1},tooltip:{theme:"dark",y:{formatter:de=>de.toLocaleString("de-DE")}},plotOptions:{pie:{donut:{size:"65%",labels:{show:!0,total:{show:!0,label:"Gesamt",color:s.text,formatter:de=>de.globals.seriesTotals.reduce((Z,ce)=>Z+ce,0).toLocaleString("de-DE")}}}}},stroke:{width:1,colors:["#000000"]}})),D=se(()=>{const de=f.value;return de==="7d"?"Aktivitäten letzte 7 Tage":de==="90d"?"Aktivitäten letzte 90 Tage":"Aktivitäten letzte 30 Tage"}),H=se(()=>{var de;return{...m.value,chart:{...m.value.chart,type:"area",stacked:!0,animations:{enabled:!0,easing:"easeinout",speed:400}},colors:[s.primary,s.accent,s.highlight,s.error],xaxis:{categories:((de=c.engagementTrend)==null?void 0:de.timeseries.map(Z=>new Date(Z.bucket).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})))??[],labels:{style:{colors:s.subtitle,fontSize:"11px"}}},yaxis:{labels:{style:{colors:s.subtitle},formatter:Z=>String(Math.round(Z))}},dataLabels:{enabled:!1},stroke:{curve:"smooth",width:2},fill:{type:"gradient",gradient:{opacityFrom:.4,opacityTo:.05}},legend:{position:"top",labels:{colors:s.text}},tooltip:{theme:"dark",shared:!0}}}),O=se(()=>{var Z;const de=((Z=c.engagementTrend)==null?void 0:Z.timeseries)??[];return[{name:"Neue Leads",data:de.map(ce=>ce.newLeads)},{name:"Formular-Einreichungen",data:de.map(ce=>ce.formSubmits)},{name:"E-Mail-Oeffnungen",data:de.map(ce=>ce.emailOpens)},{name:"E-Mail-Klicks",data:de.map(ce=>ce.emailClicks)}]}),S=[{label:"14 Tage",value:14},{label:"30 Tage",value:30},{label:"60 Tage",value:60},{label:"90 Tage",value:90}];async function B(de){c.setStuckDays(de),await c.fetchStuckLeads(de)}function G(de){return de?new Intl.DateTimeFormat("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}).format(new Date(de)):"Noch keine"}function W(de){const Z=[de.firstName,de.lastName].filter(Boolean);return Z.length>0?Z.join(" "):de.email}function F(de){return de>=70?"success":de>=40?"warning":"error"}const L={neu:"Neu",kontaktiert:"Kontaktiert",qualifiziert:"Qualifiziert",angebot:"Angebot",verhandlung:"Verhandlung",gewonnen:"Gewonnen",verloren:"Verloren"},A={neu:"primary",kontaktiert:"info",qualifiziert:"warning",angebot:"secondary",verhandlung:"warning",gewonnen:"success",verloren:"error"},z=[{title:"Name",key:"name",sortable:!1},{title:"Unternehmen",key:"company",sortable:!1},{title:"Score",key:"score",sortable:!1,width:"80px",align:"center"},{title:"Stage",key:"stage",sortable:!1,width:"130px"},{title:"Letzte Aktivitaet",key:"lastInteraction",sortable:!1,width:"160px"},{title:"Erstellt",key:"createdAt",sortable:!1,width:"120px"}],j=[{title:"Name",key:"name",sortable:!1},{title:"Unternehmen",key:"company",sortable:!1},{title:"Score",key:"score",sortable:!1,width:"80px",align:"center"},{title:"Stage",key:"stage",sortable:!1,width:"130px"},{title:"Inaktiv seit",key:"daysSince",sortable:!1,width:"120px"},{title:"Sequenz",key:"sequence",sortable:!1}];function J(de){d.push(`/admin/leads/${de}`)}function Q(de,Z){J(Z.item._id)}function te(de,Z){J(Z.item._id)}const ve=se(()=>c.loadingOverview||c.loadingHistogram||c.loadingEngagement||c.loadingHotLeads||c.loadingStuckLeads);return rt(async()=>{var de;c.period=f.value,await Promise.all([c.fetchAll(f.value),(de=u.value)==null?void 0:de.load()])}),Ze(f,async de=>{await c.fetchAll(de)}),(de,Z)=>{const ce=l("v-tooltip"),oe=l("v-chip"),pe=l("v-chip-group"),_e=l("v-icon"),q=l("v-progress-circular"),C=l("v-btn"),ae=l("v-alert"),X=l("v-skeleton-loader"),ie=l("v-card-text"),fe=l("v-card"),Se=l("v-col"),me=l("v-row"),ee=l("v-card-title"),Y=l("v-avatar"),K=l("v-data-table");return o(),h("div",DP,[a("div",TP,[Z[22]||(Z[22]=a("div",null,[a("h1",{class:"text-h5 font-weight-bold"},"Sales-Pipeline"),a("p",{class:"text-body-2 text-medium-emphasis mt-1"},"Leads, Conversions, Forecast")],-1)),a("div",LP,[a("div",EP,[Z[18]||(Z[18]=a("div",{class:"d-flex align-center ga-1 mb-1"},[a("span",{class:"text-caption text-medium-emphasis"},"Quelle")],-1)),e(pe,{"model-value":P(c).sourceScope,mandatory:"","selected-class":"text-primary","onUpdate:modelValue":Z[0]||(Z[0]=le=>k(le))},{default:t(()=>[(o(),h(be,null,Pe(_,le=>e(oe,{key:le.value,value:le.value,variant:"outlined",size:"small"},{default:t(()=>[n(v(le.label)+" ",1),e(ce,{activator:"parent",location:"bottom","max-width":"280"},{default:t(()=>[n(v(le.tooltip),1)]),_:2},1024)]),_:2},1032,["value"])),64))]),_:1},8,["model-value"])]),a("div",MP,[a("div",NP,[Z[21]||(Z[21]=a("span",{class:"text-caption text-medium-emphasis"},"Zeitraum",-1)),e(ce,{location:"bottom","max-width":"360"},{activator:t(({props:le})=>[e(_e,Vt(le,{size:"14",color:"medium-emphasis"}),{default:t(()=>[...Z[19]||(Z[19]=[n("mdi-information-outline",-1)])]),_:1},16)]),default:t(()=>[Z[20]||(Z[20]=n(" Der Zeitraum bezieht sich auf Velocity, Conversion-Rate, Forecast und die Aktivitaeten-Zeitreihe. Bestands-KPIs (Aktive Leads, Kanban, Score-Verteilung, Hot/Inaktive Leads) zeigen immer den aktuellen Stand. ",-1))]),_:1})]),e(pe,{modelValue:P(f),"onUpdate:modelValue":Z[1]||(Z[1]=le=>ot(f)?f.value=le:null),mandatory:"","selected-class":"text-primary"},{default:t(()=>[(o(),h(be,null,Pe(p,le=>e(oe,{key:le.value,value:le.value,variant:"outlined",size:"small"},{default:t(()=>[n(v(le.label),1)]),_:2},1032,["value"])),64))]),_:1},8,["modelValue"])]),ve.value?(o(),N(q,{key:0,indeterminate:"",color:"primary",size:"20",width:"2",class:"mb-1"})):U("",!0)])]),P(c).errorOverview&&!P(c).overview?(o(),N(ae,{key:0,type:"error",variant:"tonal",class:"mb-6",closable:"","onClick:close":Z[3]||(Z[3]=le=>P(c).errorOverview=null)},{append:t(()=>[e(C,{variant:"text",size:"small",onClick:Z[2]||(Z[2]=le=>P(c).fetchAll(P(f)))},{default:t(()=>[...Z[23]||(Z[23]=[n(" Erneut versuchen ",-1)])]),_:1})]),default:t(()=>[n(v(P(c).errorOverview)+" ",1)]),_:1})):U("",!0),e(me,{class:"mb-6",dense:""},{default:t(()=>[e(Se,{cols:"12",sm:"6",lg:"3"},{default:t(()=>[e(fe,{variant:"tonal",rounded:"lg",class:"pipeline-view__kpi-card"},{default:t(()=>[e(ie,{class:"pa-4"},{default:t(()=>{var le;return[Z[24]||(Z[24]=a("div",{class:"text-caption text-medium-emphasis mb-1"},"Aktive Leads gesamt",-1)),P(c).loadingOverview&&!P(c).overview?(o(),N(X,{key:0,type:"text",width:"80"})):(o(),h("div",UP,v((((le=P(c).overview)==null?void 0:le.totalActiveLeads)??0).toLocaleString("de-DE")),1))]}),_:1})]),_:1})]),_:1}),e(Se,{cols:"12",sm:"6",lg:"3"},{default:t(()=>[e(fe,{variant:"tonal",rounded:"lg",class:"pipeline-view__kpi-card"},{default:t(()=>[e(ie,{class:"pa-4"},{default:t(()=>{var le,ne;return[Z[25]||(Z[25]=a("div",{class:"d-flex align-center justify-space-between mb-1"},[a("div",{class:"text-caption text-medium-emphasis"},"Ø Velocity (bis Gewonnen)")],-1)),P(c).loadingOverview&&!P(c).overview?(o(),N(X,{key:0,type:"text",width:"80"})):(o(),h("div",BP,[a("span",FP,v(((le=P(c).overview)==null?void 0:le.avgVelocityDays)!=null?`${P(c).overview.avgVelocityDays} Tage`:"–"),1),((ne=P(c).overview)==null?void 0:ne.medianVelocityDays)!=null?(o(),h("div",OP," Median: "+v(P(c).overview.medianVelocityDays)+" Tage ",1)):U("",!0)]))]}),_:1})]),_:1})]),_:1}),e(Se,{cols:"12",sm:"6",lg:"3"},{default:t(()=>[e(fe,{variant:"tonal",rounded:"lg",class:"pipeline-view__kpi-card"},{default:t(()=>[e(ie,{class:"pa-4"},{default:t(()=>[a("div",RP,[Z[26]||(Z[26]=a("div",{class:"text-caption text-medium-emphasis"},"Conversion-Rate Neu → Gewonnen",-1)),i.value?(o(),N(oe,{key:0,size:"x-small",variant:"tonal",color:"primary",class:"pipeline-view__period-badge"},{default:t(()=>[n(v(i.value),1)]),_:1})):U("",!0)]),P(c).loadingOverview&&!P(c).overview?(o(),N(X,{key:0,type:"text",width:"80"})):(o(),h("div",KP,[a("span",jP,v(x.value!=null?`${(x.value*100).toFixed(1)} %`:"–"),1),a("div",qP," Basis: "+v(w.value.toLocaleString("de-DE"))+" Leads ",1)]))]),_:1})]),_:1})]),_:1}),e(Se,{cols:"12",sm:"6",lg:"3"},{default:t(()=>[e(fe,{variant:"tonal",rounded:"lg",class:"pipeline-view__kpi-card"},{default:t(()=>[e(ie,{class:"pa-4"},{default:t(()=>{var le;return[a("div",GP,[Z[27]||(Z[27]=a("div",{class:"text-caption text-medium-emphasis"},"Forecast Gewonnen",-1)),i.value?(o(),N(oe,{key:0,size:"x-small",variant:"tonal",color:"primary",class:"pipeline-view__period-badge"},{default:t(()=>[n(v(i.value),1)]),_:1})):U("",!0)]),P(c).loadingOverview&&!P(c).overview?(o(),N(X,{key:0,type:"text",width:"80"})):(o(),h("div",HP,v((((le=P(c).overview)==null?void 0:le.forecastWon)??0).toLocaleString("de-DE")),1))]}),_:1})]),_:1})]),_:1})]),_:1}),e(fe,{variant:"outlined",rounded:"lg",class:"pipeline-view__section-card mb-6"},{default:t(()=>[e(ee,{class:"pa-4 pb-2"},{default:t(()=>[a("div",WP,[Z[30]||(Z[30]=a("span",{class:"text-subtitle-1 font-weight-semibold"},"Pipeline-Board",-1)),e(C,{icon:"",variant:"text",size:"small","aria-label":"Kanban aktualisieren",onClick:Z[4]||(Z[4]=le=>{var ne;return(ne=u.value)==null?void 0:ne.load()})},{default:t(()=>[e(_e,null,{default:t(()=>[...Z[28]||(Z[28]=[n("mdi-refresh",-1)])]),_:1}),e(ce,{activator:"parent",location:"bottom"},{default:t(()=>[...Z[29]||(Z[29]=[n("Aktualisieren",-1)])]),_:1})]),_:1})])]),_:1}),e(ie,{class:"pa-3"},{default:t(()=>[e(zP,{ref_key:"kanbanRef",ref:u,"stuck-lead-ids":g.value,onLeadClick:J,onStageChanged:P(c).handleStageChange},null,8,["stuck-lead-ids","onStageChanged"])]),_:1})]),_:1}),e(fe,{variant:"outlined",rounded:"lg",class:"pipeline-view__section-card mb-6"},{default:t(()=>[e(ee,{class:"pa-4 pb-2"},{default:t(()=>[a("div",ZP,[Z[33]||(Z[33]=a("span",{class:"text-subtitle-1 font-weight-semibold"},"Score-Verteilung",-1)),e(C,{icon:"",variant:"text",size:"small",loading:P(c).loadingHistogram,"aria-label":"Histogramm aktualisieren",onClick:Z[5]||(Z[5]=le=>P(c).fetchHistogram())},{default:t(()=>[e(_e,null,{default:t(()=>[...Z[31]||(Z[31]=[n("mdi-refresh",-1)])]),_:1}),e(ce,{activator:"parent",location:"bottom"},{default:t(()=>[...Z[32]||(Z[32]=[n("Aktualisieren",-1)])]),_:1})]),_:1},8,["loading"])])]),_:1}),e(ie,{class:"pa-4"},{default:t(()=>[P(c).errorHistogram?(o(),N(ae,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":Z[7]||(Z[7]=le=>P(c).errorHistogram=null)},{append:t(()=>[e(C,{variant:"text",size:"small",onClick:Z[6]||(Z[6]=le=>P(c).fetchHistogram())},{default:t(()=>[...Z[34]||(Z[34]=[n("Wiederholen",-1)])]),_:1})]),default:t(()=>[n(v(P(c).errorHistogram)+" ",1)]),_:1})):U("",!0),P(c).loadingHistogram&&!P(c).scoreHistogram?(o(),N(X,{key:1,type:"image",height:"240"})):P(c).scoreHistogram?(o(),h(be,{key:2},[(o(),N(Tt,null,{fallback:t(()=>[e(X,{type:"image",height:"240"})]),default:t(()=>[e(P($),{type:"bar",options:b.value,series:I.value,height:"240"},null,8,["options","series"])]),_:1})),a("div",JP,[a("div",QP,[Z[35]||(Z[35]=n(" Median Score: ",-1)),a("span",YP,v(P(c).scoreHistogram.median),1)]),a("div",XP,[Z[36]||(Z[36]=n(" Durchschnitt: ",-1)),a("span",ez,v(P(c).scoreHistogram.avg.toFixed(1)),1)]),a("div",tz,[Z[37]||(Z[37]=n(" Leads gesamt: ",-1)),a("span",az,v(P(c).scoreHistogram.totalLeads.toLocaleString("de-DE")),1)])])],64)):(o(),h("div",lz,[e(_e,{size:"48",color:"medium-emphasis",class:"mb-3"},{default:t(()=>[...Z[38]||(Z[38]=[n("mdi-chart-bar",-1)])]),_:1}),Z[39]||(Z[39]=a("p",{class:"text-body-2 text-medium-emphasis"},"Keine Score-Daten vorhanden.",-1))]))]),_:1})]),_:1}),e(fe,{variant:"outlined",rounded:"lg",class:"pipeline-view__section-card mb-6"},{default:t(()=>[e(ee,{class:"pa-4 pb-2"},{default:t(()=>[a("div",nz,[Z[42]||(Z[42]=a("span",{class:"text-subtitle-1 font-weight-semibold"},"Engagement",-1)),e(C,{icon:"",variant:"text",size:"small",loading:P(c).loadingEngagement,"aria-label":"Engagement aktualisieren",onClick:Z[8]||(Z[8]=le=>P(c).fetchEngagement(P(f)))},{default:t(()=>[e(_e,null,{default:t(()=>[...Z[40]||(Z[40]=[n("mdi-refresh",-1)])]),_:1}),e(ce,{activator:"parent",location:"bottom"},{default:t(()=>[...Z[41]||(Z[41]=[n("Aktualisieren",-1)])]),_:1})]),_:1},8,["loading"])])]),_:1}),e(ie,{class:"pa-4"},{default:t(()=>[P(c).errorEngagement?(o(),N(ae,{key:0,type:"error",variant:"tonal",density:"compact",class:"mb-4",closable:"","onClick:close":Z[10]||(Z[10]=le=>P(c).errorEngagement=null)},{append:t(()=>[e(C,{variant:"text",size:"small",onClick:Z[9]||(Z[9]=le=>P(c).fetchEngagement(P(f)))},{default:t(()=>[...Z[43]||(Z[43]=[n("Wiederholen",-1)])]),_:1})]),default:t(()=>[n(v(P(c).errorEngagement)+" ",1)]),_:1})):U("",!0),P(c).loadingEngagement&&!P(c).engagementTrend?(o(),N(X,{key:1,type:"image",height:"320"})):P(c).engagementTrend?(o(),N(me,{key:2},{default:t(()=>[e(Se,{cols:"12",md:"5"},{default:t(()=>[Z[46]||(Z[46]=a("div",{class:"text-caption text-medium-emphasis mb-2"},"Aktuelle Engagement-States",-1)),M.value.length>0?(o(),N(Tt,{key:0},{fallback:t(()=>[e(X,{type:"image",height:"300"})]),default:t(()=>[e(P($),{type:"donut",options:T.value,series:M.value,height:"300"},null,8,["options","series"])]),_:1})):(o(),h("div",oz,[e(_e,{size:"48",color:"medium-emphasis"},{default:t(()=>[...Z[44]||(Z[44]=[n("mdi-chart-donut",-1)])]),_:1}),Z[45]||(Z[45]=a("p",{class:"mt-2 text-medium-emphasis text-body-2"},"Keine Daten vorhanden",-1))]))]),_:1}),e(Se,{cols:"12",md:"7"},{default:t(()=>[a("div",sz,v(D.value),1),O.value[0].data.length>0?(o(),N(Tt,{key:0},{fallback:t(()=>[e(X,{type:"image",height:"300"})]),default:t(()=>[e(P($),{type:"area",options:H.value,series:O.value,height:"300"},null,8,["options","series"])]),_:1})):(o(),h("div",iz,[e(_e,{size:"48",color:"medium-emphasis"},{default:t(()=>[...Z[47]||(Z[47]=[n("mdi-chart-timeline-variant",-1)])]),_:1}),Z[48]||(Z[48]=a("p",{class:"mt-2 text-medium-emphasis text-body-2"},"Keine Zeitreihendaten vorhanden",-1))]))]),_:1})]),_:1})):(o(),h("div",rz,[e(_e,{size:"48",color:"medium-emphasis",class:"mb-3"},{default:t(()=>[...Z[49]||(Z[49]=[n("mdi-chart-scatter-plot",-1)])]),_:1}),Z[50]||(Z[50]=a("p",{class:"text-body-2 text-medium-emphasis"},"Keine Engagement-Daten vorhanden.",-1))]))]),_:1})]),_:1}),e(fe,{variant:"outlined",rounded:"lg",class:"pipeline-view__section-card mb-6"},{default:t(()=>[e(ee,{class:"pa-4 pb-2"},{default:t(()=>[a("div",dz,[a("div",uz,[e(_e,{color:"warning",size:"18"},{default:t(()=>[...Z[51]||(Z[51]=[n("mdi-fire",-1)])]),_:1}),Z[52]||(Z[52]=a("span",{class:"text-subtitle-1 font-weight-semibold"},"Hot Leads",-1))]),e(C,{icon:"",variant:"text",size:"small",loading:P(c).loadingHotLeads,"aria-label":"Hot Leads aktualisieren",onClick:Z[11]||(Z[11]=le=>P(c).fetchHotLeads(20))},{default:t(()=>[e(_e,null,{default:t(()=>[...Z[53]||(Z[53]=[n("mdi-refresh",-1)])]),_:1}),e(ce,{activator:"parent",location:"bottom"},{default:t(()=>[...Z[54]||(Z[54]=[n("Aktualisieren",-1)])]),_:1})]),_:1},8,["loading"])])]),_:1}),e(ie,{class:"pa-0"},{default:t(()=>[P(c).errorHotLeads?(o(),N(ae,{key:0,type:"error",variant:"tonal",density:"compact",class:"ma-4",closable:"","onClick:close":Z[13]||(Z[13]=le=>P(c).errorHotLeads=null)},{append:t(()=>[e(C,{variant:"text",size:"small",onClick:Z[12]||(Z[12]=le=>P(c).fetchHotLeads(20))},{default:t(()=>[...Z[55]||(Z[55]=[n("Wiederholen",-1)])]),_:1})]),default:t(()=>[n(v(P(c).errorHotLeads)+" ",1)]),_:1})):U("",!0),e(K,{headers:z,items:P(c).hotLeads,loading:P(c).loadingHotLeads,"loading-text":"Hot Leads werden geladen...","no-data-text":"Keine Hot Leads vorhanden.","item-value":"_id",class:"pipeline-view__table",density:"comfortable","items-per-page":20,hover:"","onClick:row":Q},{"item.name":t(({item:le})=>[a("div",cz,[e(Y,{color:"primary",size:"28"},{default:t(()=>[a("span",mz,v((le.firstName||le.email).charAt(0).toUpperCase()),1)]),_:2},1024),a("div",null,[a("div",vz,v(W(le)),1),a("div",pz,v(le.email),1)])])]),"item.company":t(({item:le})=>[a("span",fz,v(le.company||"–"),1)]),"item.score":t(({item:le})=>[e(oe,{color:F(le.scoringTotal),size:"small",variant:"tonal"},{default:t(()=>[n(v(le.scoringTotal),1)]),_:2},1032,["color"])]),"item.stage":t(({item:le})=>[e(oe,{color:A[le.pipelineStage]??"default",size:"small",variant:"tonal"},{default:t(()=>[n(v(L[le.pipelineStage]??le.pipelineStage),1)]),_:2},1032,["color"])]),"item.lastInteraction":t(({item:le})=>[a("span",gz,v(G(le.lastInteractionAt)),1)]),"item.createdAt":t(({item:le})=>[a("span",bz,v(G(le.createdAt)),1)]),"no-data":t(()=>[a("div",yz,[e(_e,{size:"48",color:"grey-darken-1",class:"mb-3"},{default:t(()=>[...Z[56]||(Z[56]=[n("mdi-fire-off",-1)])]),_:1}),Z[57]||(Z[57]=a("p",{class:"text-body-2 text-medium-emphasis"},"Keine Hot Leads vorhanden.",-1))])]),_:1},8,["items","loading"])]),_:1})]),_:1}),e(fe,{variant:"outlined",rounded:"lg",class:"pipeline-view__section-card mb-6"},{default:t(()=>[e(ee,{class:"pa-4 pb-2"},{default:t(()=>[a("div",_z,[a("div",kz,[e(_e,{color:"error",size:"18"},{default:t(()=>[...Z[58]||(Z[58]=[n("mdi-alert-circle-outline",-1)])]),_:1}),Z[61]||(Z[61]=a("span",{class:"text-subtitle-1 font-weight-semibold"},"Inaktive Leads",-1)),e(ce,{location:"bottom","max-width":"320"},{activator:t(({props:le})=>[e(_e,Vt(le,{size:"16",color:"medium-emphasis"}),{default:t(()=>[...Z[59]||(Z[59]=[n("mdi-information-outline",-1)])]),_:1},16)]),default:t(()=>[Z[60]||(Z[60]=n(" Leads mit aktiver E-Mail-Sequenz, die seit mindestens X Tagen nicht reagiert haben (kein Open, Click, Form-Submit, Download oder Meeting). Die Schwelle rechts filtert ausschließlich diese Tabelle - nicht das Kanban oben. ",-1))]),_:1})]),a("div",hz,[Z[64]||(Z[64]=a("span",{class:"text-caption text-medium-emphasis"},"Stillstand-Schwelle:",-1)),e(pe,{modelValue:P(c).stuckDaysThreshold,"onUpdate:modelValue":Z[14]||(Z[14]=le=>P(c).stuckDaysThreshold=le),mandatory:"","selected-class":"text-error"},{default:t(()=>[(o(),h(be,null,Pe(S,le=>e(oe,{key:le.value,value:le.value,variant:"outlined",size:"small",onClick:ne=>B(le.value)},{default:t(()=>[n(v(le.label),1)]),_:2},1032,["value","onClick"])),64))]),_:1},8,["modelValue"]),e(C,{icon:"",variant:"text",size:"small",loading:P(c).loadingStuckLeads,"aria-label":"Inaktive Leads aktualisieren",onClick:Z[15]||(Z[15]=le=>P(c).fetchStuckLeads(P(c).stuckDaysThreshold))},{default:t(()=>[e(_e,null,{default:t(()=>[...Z[62]||(Z[62]=[n("mdi-refresh",-1)])]),_:1}),e(ce,{activator:"parent",location:"bottom"},{default:t(()=>[...Z[63]||(Z[63]=[n("Aktualisieren",-1)])]),_:1})]),_:1},8,["loading"])])])]),_:1}),e(ie,{class:"pa-0"},{default:t(()=>[P(c).errorStuckLeads?(o(),N(ae,{key:0,type:"error",variant:"tonal",density:"compact",class:"ma-4",closable:"","onClick:close":Z[17]||(Z[17]=le=>P(c).errorStuckLeads=null)},{append:t(()=>[e(C,{variant:"text",size:"small",onClick:Z[16]||(Z[16]=le=>P(c).fetchStuckLeads(P(c).stuckDaysThreshold))},{default:t(()=>[...Z[65]||(Z[65]=[n("Wiederholen",-1)])]),_:1})]),default:t(()=>[n(v(P(c).errorStuckLeads)+" ",1)]),_:1})):U("",!0),e(K,{headers:j,items:P(c).stuckLeads,loading:P(c).loadingStuckLeads,"loading-text":"Inaktive Leads werden geladen...","no-data-text":"Keine inaktiven Leads in diesem Zeitraum.","item-value":"_id",class:"pipeline-view__table",density:"comfortable","items-per-page":20,hover:"","onClick:row":te},{"item.name":t(({item:le})=>[a("div",xz,[e(Y,{color:"error",size:"28"},{default:t(()=>[a("span",wz,v((le.firstName||le.email).charAt(0).toUpperCase()),1)]),_:2},1024),a("div",null,[a("div",Sz,v(W(le)),1),a("div",$z,v(le.email),1)])])]),"item.company":t(({item:le})=>[a("span",Cz,v(le.company||"–"),1)]),"item.score":t(({item:le})=>[e(oe,{color:F(le.scoringTotal),size:"small",variant:"tonal"},{default:t(()=>[n(v(le.scoringTotal),1)]),_:2},1032,["color"])]),"item.stage":t(({item:le})=>[e(oe,{color:A[le.pipelineStage]??"default",size:"small",variant:"tonal"},{default:t(()=>[n(v(L[le.pipelineStage]??le.pipelineStage),1)]),_:2},1032,["color"])]),"item.daysSince":t(({item:le})=>[e(oe,{color:le.daysSinceLastActivity>=60?"error":"warning",size:"small",variant:"tonal"},{default:t(()=>[n(v(le.daysSinceLastActivity)+" Tage ",1)]),_:2},1032,["color"])]),"item.sequence":t(({item:le})=>[le.sequenceName?(o(),h(be,{key:0},[a("span",Vz,v(le.sequenceName),1),a("span",Az,"(Schritt "+v(le.currentSequenceStep)+")",1)],64)):(o(),h("span",Iz,"Keine Sequenz"))]),"no-data":t(()=>[a("div",Pz,[e(_e,{size:"48",color:"grey-darken-1",class:"mb-3"},{default:t(()=>[...Z[66]||(Z[66]=[n("mdi-check-circle-outline",-1)])]),_:1}),a("p",zz," Keine Leads laenger als "+v(P(c).stuckDaysThreshold)+" Tage inaktiv. ",1)])]),_:1},8,["items","loading"])]),_:1})]),_:1})])}}}),Tz=Me(Dz,[["__scopeId","data-v-7ba8c4d6"]]),j6=Object.freeze(Object.defineProperty({__proto__:null,default:Tz},Symbol.toStringTag,{value:"Module"})),Pa={ai:{requestTimeoutSec:120},hubspot:{rateLimitDelaySec:.15,batchPageSize:50,maxPages:1e3,lastImportAt:null},linkedin:{rateLimitDelaySec:2,tokenRefreshBufferSec:300,lockWaitSec:2},scraping:{wpRateLimitSec:.5,wpMaxRetries:3,wpRetryBaseDelaySec:1,imageRateLimitSec:.3,imageMaxSizeMB:10},email:{maxRetries:3,retryDelaySec:5},leadScoring:{decayHalfLifeDays:90},dataRetention:{auditLogDays:365,seoDiscoveryDays:180,seoKeywordHistoryDays:90},newsletterPopup:{enabled:!1,scrollPercentage:60,scrollEnabled:!0,timeDelaySec:120,timeDelayEnabled:!0,showOnBlogOnly:!0,dismissDurationDays:14},companyEnrichment:{timeoutSec:90,maxIterations:8,maxToolUses:{web_search:5,web_fetch:3}}},Lz={ai:{requestTimeoutSec:{min:5,max:600}},hubspot:{rateLimitDelaySec:{min:.05,max:10},batchPageSize:{min:10,max:200},maxPages:{min:100,max:1e4}},linkedin:{rateLimitDelaySec:{min:.5,max:30},tokenRefreshBufferSec:{min:60,max:1800},lockWaitSec:{min:1,max:30}},scraping:{wpRateLimitSec:{min:.1,max:10},wpMaxRetries:{min:1,max:10},wpRetryBaseDelaySec:{min:.5,max:30},imageRateLimitSec:{min:.1,max:10},imageMaxSizeMB:{min:1,max:100}},email:{maxRetries:{min:1,max:10},retryDelaySec:{min:1,max:300}},leadScoring:{decayHalfLifeDays:{min:7,max:365}},dataRetention:{auditLogDays:{min:30,max:3650},seoDiscoveryDays:{min:7,max:730},seoKeywordHistoryDays:{min:7,max:730}},newsletterPopup:{scrollPercentage:{min:10,max:100},timeDelaySec:{min:10,max:600},dismissDurationDays:{min:1,max:365}},companyEnrichment:{timeoutSec:{min:30,max:300},maxIterations:{min:1,max:20},web_search:{min:1,max:20},web_fetch:{min:0,max:10}}},Ez={key:0,class:"d-flex justify-center py-8"},Mz={class:"d-flex align-center ga-2"},Nz={class:"text-body-1 font-weight-medium"},Uz={class:"text-caption text-medium-emphasis ml-1"},Bz={class:"d-flex justify-end mt-2"},Fz=Ae({__name:"TimeoutSettingsDialog",props:{modelValue:{type:Boolean,default:!1},modelModifiers:{}},emits:["update:modelValue"],setup(r){const $=ua(r,"modelValue"),d=y(!1),c=y(!1),s=y(null),m=y(null),u=y(structuredClone(Pa)),f=y(structuredClone(Pa));let p="";const _=y(0),k=[{key:"ai",title:"KI-Provider",icon:"mdi-robot",fields:[{key:"requestTimeoutSec",label:"KI Request Timeout",suffix:"Sek.",hint:"Max. Wartezeit auf eine KI-Antwort"}]},{key:"hubspot",title:"HubSpot",icon:"mdi-hubspot",fields:[{key:"rateLimitDelaySec",label:"Rate Limit Pause",suffix:"Sek.",hint:"Pause zwischen HubSpot API-Calls"},{key:"batchPageSize",label:"Batch-Größe",suffix:"Stück",hint:"Contacts pro Seite beim Import"},{key:"maxPages",label:"Max. Seiten",suffix:"Stück",hint:"Sicherheitslimit für Seitenanzahl beim Import"}]},{key:"linkedin",title:"LinkedIn",icon:"mdi-linkedin",fields:[{key:"rateLimitDelaySec",label:"Rate Limit Pause",suffix:"Sek.",hint:"Pause zwischen Post-Elaborationen"},{key:"tokenRefreshBufferSec",label:"Token-Refresh Puffer",suffix:"Sek.",hint:"Token wird so viele Sekunden vor Ablauf erneuert"},{key:"lockWaitSec",label:"Lock Wait",suffix:"Sek.",hint:"Wartezeit bei parallelem Token-Refresh"}]},{key:"scraping",title:"Scraping",icon:"mdi-web",fields:[{key:"wpRateLimitSec",label:"WordPress Rate Limit",suffix:"Sek.",hint:"Pause zwischen WordPress API-Requests"},{key:"wpMaxRetries",label:"WordPress Max. Retries",suffix:"Stück",hint:"Maximale Wiederholungsversuche"},{key:"wpRetryBaseDelaySec",label:"WordPress Retry Basis-Delay",suffix:"Sek.",hint:"Basis für exponentiellen Backoff"},{key:"imageRateLimitSec",label:"Bild-Download Rate Limit",suffix:"Sek.",hint:"Pause zwischen Bild-Downloads"},{key:"imageMaxSizeMB",label:"Max. Bildgröße",suffix:"MB",hint:"Maximale Dateigröße pro Bild"}]},{key:"email",title:"E-Mail / Queue",icon:"mdi-email-outline",fields:[{key:"maxRetries",label:"Max. Wiederholungen",suffix:"Stück",hint:"Job-Wiederholungsversuche bei Fehler"},{key:"retryDelaySec",label:"Retry-Pause",suffix:"Sek.",hint:"Pause zwischen Wiederholungsversuchen"}]},{key:"leadScoring",title:"Lead Scoring",icon:"mdi-trending-up",fields:[{key:"decayHalfLifeDays",label:"Score-Verfall Halbwertszeit",suffix:"Tage",hint:"Nach dieser Zeit halbiert sich der Engagement-Score"}]},{key:"dataRetention",title:"Datenhaltung",icon:"mdi-database-clock",alert:"Änderungen an der Datenhaltung werden beim nächsten Backend-Neustart wirksam.",fields:[{key:"auditLogDays",label:"Audit-Log Aufbewahrung",suffix:"Tage",hint:"Danach werden Audit-Logs automatisch gelöscht"},{key:"seoDiscoveryDays",label:"SEO Discovery Aufbewahrung",suffix:"Tage",hint:"Aufbewahrung der SEO-Discovery-Daten"},{key:"seoKeywordHistoryDays",label:"SEO Keyword History",suffix:"Tage",hint:"Aufbewahrung der Keyword-Ranking-Historie"}]},{key:"newsletterPopup",title:"Newsletter-Popup",icon:"mdi-newspaper-variant-outline",fields:[{key:"enabled",label:"Popup aktiviert",suffix:"",hint:"Newsletter-Popup global aktivieren",fieldType:"toggle"},{key:"scrollEnabled",label:"Scroll-Trigger aktiviert",suffix:"",hint:"Popup nach Scroll-Tiefe anzeigen",fieldType:"toggle"},{key:"scrollPercentage",label:"Scroll-Schwellenwert",suffix:"%",hint:"Popup erscheint nach X% Scroll-Tiefe"},{key:"timeDelayEnabled",label:"Zeit-Trigger aktiviert",suffix:"",hint:"Popup nach Zeitverzögerung anzeigen",fieldType:"toggle"},{key:"timeDelaySec",label:"Zeitverzögerung",suffix:"Sek.",hint:"Popup erscheint nach X Sekunden"},{key:"showOnBlogOnly",label:"Nur auf Blog-Seiten",suffix:"",hint:"Popup nur auf /blog/* anzeigen",fieldType:"toggle"},{key:"dismissDurationDays",label:"Dismiss-Dauer",suffix:"Tage",hint:"Nach Wegklicken X Tage nicht mehr anzeigen"}]},{key:"companyEnrichment",title:"Company-Anreicherung (KI-Web-Recherche)",icon:"mdi-creation",alert:"Plan D: Anthropic Tool-Use-Agent (web_search + web_fetch). Höhere Werte = bessere Recherche, aber mehr Tokens und längere Wartezeit.",fields:[{key:"timeoutSec",label:"Frontend-Timeout",suffix:"Sek.",hint:"Max. Wartezeit im Frontend (Job läuft Backend-seitig weiter)"},{key:"maxIterations",label:"Max. KI-Iterationen",suffix:"Stück",hint:"Max. Anzahl KI-Roundtrips pro Anreicherungs-Job"},{key:"web_search",label:"web_search Max-Uses",suffix:"Stück",hint:"Max. Anzahl Web-Suchanfragen pro Job"},{key:"web_fetch",label:"web_fetch Max-Uses",suffix:"Stück",hint:"Max. Anzahl URL-Abrufe pro Job"}]}];function i(T,D){return T==="companyEnrichment"&&(D==="web_search"||D==="web_fetch")}function g(T,D){var O;if(i(T,D)){const S=u.value.companyEnrichment;return(O=S==null?void 0:S.maxToolUses)==null?void 0:O[D]}const H=u.value[T];return H==null?void 0:H[D]}function x(T,D,H){if(i(T,D)){const S=typeof H=="string"?parseFloat(H):NaN;if(isNaN(S))return;const B=u.value.companyEnrichment??{timeoutSec:90,maxIterations:8,maxToolUses:{web_search:5,web_fetch:3}};u.value={...u.value,companyEnrichment:{...B,maxToolUses:{...B.maxToolUses,[D]:S}}},_.value++;return}if(typeof H=="boolean"){const S=u.value[T];u.value={...u.value,[T]:{...S,[D]:H}},_.value++;return}const O=parseFloat(H);if(!isNaN(O)){const S=u.value[T];u.value={...u.value,[T]:{...S,[D]:O}},_.value++}}function w(T,D){var O;if(i(T,D)){const S=f.value.companyEnrichment;return((O=S==null?void 0:S.maxToolUses)==null?void 0:O[D])??0}const H=f.value[T];return(H==null?void 0:H[D])??0}function b(T,D){var B;const H=(B=Lz[T])==null?void 0:B[D];if(!H)return[];const{min:O,max:S}=H;return[G=>G===""||G===void 0||!isNaN(Number(G))&&Number(G)>=O&&Number(G)<=S||`Wert muss zwischen ${O} und ${S} liegen`]}function I(){if(JSON.stringify(u.value)===p)return[];const D=[],H=JSON.parse(p);for(const O of k){const S=JSON.stringify(u.value[O.key]),B=JSON.stringify(H[O.key]);S!==B&&D.push(O.key)}return D}const V=se(()=>(_.value,p!==""&&JSON.stringify(u.value)!==p));async function E(){d.value=!0,s.value=null;const T=await re.get("/platform-settings");T.success&&T.data?(u.value=structuredClone(T.data.current),f.value=structuredClone(T.data.defaults),p=JSON.stringify(u.value),_.value=0):s.value=T.error||"Fehler beim Laden der Einstellungen.",d.value=!1}async function R(){const T=I();if(T.length===0){$.value=!1;return}c.value=!0,s.value=null,m.value=null;const D=[];for(const H of T){const O=await re.put(`/platform-settings/${H}`,u.value[H]);O.success||D.push(`${H}: ${O.error}`)}D.length>0?s.value=D.join(". "):(m.value="Einstellungen gespeichert.",p=JSON.stringify(u.value),_.value=0,setTimeout(()=>{m.value=null},3e3)),c.value=!1}async function M(T){const D=await re.delete(`/platform-settings/${T}`);D.success?(u.value[T]=structuredClone(Pa[T]),p=JSON.stringify(u.value)):s.value=D.error||"Fehler beim Zurücksetzen."}return Ze($,T=>{T&&(E(),m.value=null,s.value=null)}),(T,D)=>{const H=l("v-icon"),O=l("v-spacer"),S=l("v-tooltip"),B=l("v-btn"),G=l("v-card-title"),W=l("v-divider"),F=l("v-progress-circular"),L=l("v-alert"),A=l("v-expansion-panel-title"),z=l("v-switch"),j=l("v-text-field"),J=l("v-col"),Q=l("v-row"),te=l("v-expansion-panel-text"),ve=l("v-expansion-panel"),de=l("v-expansion-panels"),Z=l("v-card-text"),ce=l("v-card-actions"),oe=l("v-card"),pe=l("v-dialog");return o(),N(pe,{modelValue:$.value,"onUpdate:modelValue":D[3]||(D[3]=_e=>$.value=_e),"max-width":"700",scrollable:""},{default:t(()=>[e(oe,{rounded:"lg"},{default:t(()=>[e(G,{class:"d-flex align-center pa-4 pb-2"},{default:t(()=>[e(H,{class:"mr-2",size:"24"},{default:t(()=>[...D[4]||(D[4]=[n("mdi-timer-cog-outline",-1)])]),_:1}),D[7]||(D[7]=a("span",{class:"text-h6 font-weight-bold"},"Timeouts & Limits",-1)),e(O),e(B,{icon:"",variant:"text",size:"small","aria-label":"Schließen",onClick:D[0]||(D[0]=_e=>$.value=!1)},{default:t(()=>[e(S,{activator:"parent",location:"bottom"},{default:t(()=>[...D[5]||(D[5]=[n("Schließen",-1)])]),_:1}),e(H,null,{default:t(()=>[...D[6]||(D[6]=[n("mdi-close",-1)])]),_:1})]),_:1})]),_:1}),e(W),e(Z,{class:"pa-4",style:{"max-height":"70vh","overflow-y":"auto"}},{default:t(()=>[d.value?(o(),h("div",Ez,[e(F,{indeterminate:"",color:"primary"})])):U("",!0),s.value?(o(),N(L,{key:1,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":D[1]||(D[1]=_e=>s.value=null)},{default:t(()=>[n(v(s.value),1)]),_:1})):U("",!0),m.value?(o(),N(L,{key:2,type:"success",variant:"tonal",class:"mb-4"},{default:t(()=>[n(v(m.value),1)]),_:1})):U("",!0),d.value?U("",!0):(o(),N(de,{key:3,variant:"accordion"},{default:t(()=>[(o(),h(be,null,Pe(k,_e=>e(ve,{key:_e.key},{default:t(()=>[e(A,null,{default:t(()=>[a("div",Mz,[e(H,{size:"20",color:"primary"},{default:t(()=>[n(v(_e.icon),1)]),_:2},1024),a("span",Nz,v(_e.title),1),a("span",Uz,"("+v(_e.fields.length)+")",1)])]),_:2},1024),e(te,null,{default:t(()=>[_e.alert?(o(),N(L,{key:0,type:"info",variant:"tonal",density:"compact",class:"mb-4"},{default:t(()=>[n(v(_e.alert),1)]),_:2},1024)):U("",!0),e(Q,{dense:""},{default:t(()=>[(o(!0),h(be,null,Pe(_e.fields,q=>(o(),N(J,{key:q.key,cols:"12",sm:q.fieldType==="toggle"?12:6},{default:t(()=>[q.fieldType==="toggle"?(o(),N(z,{key:0,"model-value":g(_e.key,q.key),"onUpdate:modelValue":C=>x(_e.key,q.key,C??!1),label:q.label,hint:q.hint,"persistent-hint":"",color:"primary",density:"comfortable",class:"mb-2"},null,8,["model-value","onUpdate:modelValue","label","hint"])):(o(),N(j,{key:1,"model-value":g(_e.key,q.key),label:q.label,suffix:q.suffix,placeholder:String(w(_e.key,q.key)),hint:q.hint,rules:b(_e.key,q.key),type:"number",variant:"outlined",density:"comfortable","persistent-hint":"","persistent-placeholder":"","onUpdate:modelValue":C=>x(_e.key,q.key,String(C))},null,8,["model-value","label","suffix","placeholder","hint","rules","onUpdate:modelValue"]))]),_:2},1032,["sm"]))),128))]),_:2},1024),a("div",Bz,[e(B,{variant:"text",size:"small",color:"warning","prepend-icon":"mdi-restore",onClick:q=>M(_e.key)},{default:t(()=>[...D[8]||(D[8]=[n(" Auf Defaults zurücksetzen ",-1)])]),_:1},8,["onClick"])])]),_:2},1024)]),_:2},1024)),64))]),_:1}))]),_:1}),e(W),e(ce,{class:"pa-4"},{default:t(()=>[e(O),e(B,{variant:"text",onClick:D[2]||(D[2]=_e=>$.value=!1)},{default:t(()=>[...D[9]||(D[9]=[n("Abbrechen",-1)])]),_:1}),e(B,{color:"primary",variant:"flat",loading:c.value,disabled:!V.value||d.value,onClick:R},{default:t(()=>[...D[10]||(D[10]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"])}}}),Oz={class:"d-flex align-center ga-2"},Rz={class:"text-body-1 font-weight-semibold env-label"},Kz={key:0,class:"d-flex align-center"},jz={class:"ml-3"},qz={class:"text-body-2 font-weight-medium"},Gz={key:0,class:"text-caption text-medium-emphasis"},Hz={key:1,class:"text-caption text-medium-emphasis"},Wz={key:1,class:"deployment-checklist"},Zz={class:"d-flex align-center mb-3"},Jz={class:"ml-3"},Qz={class:"text-body-2 font-weight-bold"},Yz={key:0,class:"text-caption text-medium-emphasis"},Xz={class:"checklist-steps"},eD={class:"log-container"},tD={key:3,class:"text-caption text-medium-emphasis mt-2"},aD=Ae({__name:"DeploymentStatusCard",setup(r){const $=y(!1),d=y(null),c=y("");let s=null;const m=se(()=>c.value==="staging"||c.value==="production"?c.value:null),u=se(()=>{var R;switch((R=d.value)==null?void 0:R.status){case"idle":return"success";case"building":return"warning";case"error":return"error";default:return"grey"}}),f=se(()=>{var R;switch((R=d.value)==null?void 0:R.status){case"idle":return"mdi-check-circle";case"building":return"mdi-progress-wrench";case"error":return"mdi-alert-circle";default:return"mdi-help-circle"}}),p=se(()=>{var R;switch((R=d.value)==null?void 0:R.status){case"idle":return"Kein Deployment aktiv";case"building":return"Deployment läuft...";case"error":return"Build-Fehler";case"not_available":return"Nicht verfügbar";default:return"Wird geladen..."}}),_=se(()=>{var T,D;const R=(T=d.value)==null?void 0:T.deploymentSteps;return!R||R.length===0?!1:R.filter(H=>H.completed).length>=2||((D=d.value)==null?void 0:D.status)==="building"}),k=se(()=>{var M;const R=(M=d.value)==null?void 0:M.deploymentSteps;return R?R.every(T=>T.completed):!1});function i(R){var T,D;const M=(T=d.value)==null?void 0:T.deploymentSteps;return!M||((D=d.value)==null?void 0:D.status)!=="building"?!1:M.findIndex(H=>!H.completed)===R}function g(R,M){return R.completed?"success":i(M)?"warning":"grey-lighten-1"}function x(R,M){return R.completed?"mdi-check-circle":i(M)?"mdi-progress-clock":"mdi-circle-outline"}function w(R){return new Date(R).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}const b=se(()=>{var R;return((R=d.value)==null?void 0:R.status)==="building"?1e4:3e4});function I(){s&&clearInterval(s),s=setInterval(E,b.value)}async function V(){try{const R=await re.get("/system/version");R.success&&R.data&&(c.value=R.data.nodeEnv)}catch{c.value=""}}async function E(){const R=m.value;if(!R){d.value=null;return}$.value=!0;try{const M=await re.get(`/deployment-status/${R}`);M.success&&M.data&&(d.value=M.data)}catch{d.value={environment:R,status:"not_available",lastCheck:new Date().toISOString(),recentLogs:[]}}finally{$.value=!1}}return Ze(b,()=>I()),rt(async()=>{await V(),m.value&&(E(),I())}),da(()=>{s&&clearInterval(s)}),(R,M)=>{const T=l("v-icon"),D=l("v-chip"),H=l("v-tooltip"),O=l("v-btn"),S=l("v-card-title"),B=l("v-divider"),G=l("v-avatar"),W=l("v-alert"),F=l("v-expansion-panel-title"),L=l("v-expansion-panel-text"),A=l("v-expansion-panel"),z=l("v-expansion-panels"),j=l("v-card-text"),J=l("v-card");return o(),N(J,{rounded:"lg",class:"deployment-card"},{default:t(()=>[e(S,{class:"d-flex justify-space-between align-center pa-4 pb-2"},{default:t(()=>{var Q;return[a("div",Oz,[e(T,{size:"20"},{default:t(()=>[...M[0]||(M[0]=[n("mdi-rocket-launch",-1)])]),_:1}),a("span",Rz,v(c.value||"..."),1),(Q=d.value)!=null&&Q.commit?(o(),N(D,{key:0,size:"x-small",variant:"tonal",color:"primary"},{default:t(()=>[n(v(d.value.commit),1)]),_:1})):U("",!0)]),e(O,{icon:"",variant:"text",size:"x-small",loading:$.value,"aria-label":"Status aktualisieren",onClick:E},{default:t(()=>[e(H,{activator:"parent",location:"bottom"},{default:t(()=>[...M[1]||(M[1]=[n("Status aktualisieren",-1)])]),_:1}),e(T,{size:"18"},{default:t(()=>[...M[2]||(M[2]=[n("mdi-refresh",-1)])]),_:1})]),_:1},8,["loading"])]}),_:1}),e(B),e(j,{class:"pa-4"},{default:t(()=>{var Q,te,ve,de,Z,ce,oe,pe,_e,q;return[_.value?U("",!0):(o(),h("div",Kz,[e(G,{color:u.value,size:"40"},{default:t(()=>[e(T,{color:"white",size:"22"},{default:t(()=>[n(v(f.value),1)]),_:1})]),_:1},8,["color"]),a("div",jz,[a("div",qz,v(p.value),1),(Q=d.value)!=null&&Q.pollInterval&&((te=d.value)==null?void 0:te.status)==="idle"?(o(),h("div",Gz," Polling alle "+v(d.value.pollInterval)+"s ",1)):U("",!0),(ve=d.value)!=null&&ve.lastBuildReason?(o(),h("div",Hz,v(d.value.lastBuildReason),1)):U("",!0)])])),_.value?(o(),h("div",Wz,[a("div",Zz,[e(G,{color:u.value,size:"36",class:ft({"pulse-animation":((de=d.value)==null?void 0:de.status)==="building"})},{default:t(()=>[e(T,{color:"white",size:"20"},{default:t(()=>[n(v(f.value),1)]),_:1})]),_:1},8,["color","class"]),a("div",Jz,[a("div",Qz,v(k.value?"Deployment abgeschlossen":"Deployment läuft..."),1),(Z=d.value)!=null&&Z.lastBuildReason?(o(),h("div",Yz,v(d.value.lastBuildReason),1)):U("",!0)])]),a("div",Xz,[(o(!0),h(be,null,Pe((ce=d.value)==null?void 0:ce.deploymentSteps,(C,ae)=>(o(),h("div",{key:ae,class:ft(["d-flex align-center checklist-step",{"checklist-step--active":i(ae)}])},[e(T,{color:g(C,ae),size:"18",class:ft(["mr-2 flex-shrink-0",{"pulse-animation":i(ae)}])},{default:t(()=>[n(v(x(C,ae)),1)]),_:2},1032,["color","class"]),a("span",{class:ft(["text-caption",{"font-weight-bold":i(ae),"text-disabled":!C.completed&&!i(ae)}])},v(C.label),3)],2))),128))]),(oe=d.value)!=null&&oe.deploymentLoop?(o(),N(W,{key:0,type:"warning",density:"compact",variant:"tonal",class:"mt-3"},{default:t(()=>[...M[3]||(M[3]=[n(" Deployment-Loop erkannt! Vorheriger Build nicht abgeschlossen. ",-1)])]),_:1})):U("",!0)])):U("",!0),(_e=(pe=d.value)==null?void 0:pe.recentLogs)!=null&&_e.length?(o(),N(z,{key:2,variant:"accordion",flat:"",class:"mt-3"},{default:t(()=>[e(A,null,{default:t(()=>[e(F,{class:"text-caption pa-2"},{default:t(()=>[n(" Logs ("+v(d.value.recentLogs.length)+") ",1)]),_:1}),e(L,null,{default:t(()=>[a("div",eD,[(o(!0),h(be,null,Pe(d.value.recentLogs,(C,ae)=>(o(),h("pre",{key:ae,class:"log-line"},v(C),1))),128))])]),_:1})]),_:1})]),_:1})):U("",!0),(q=d.value)!=null&&q.lastCheck?(o(),h("div",tD,v(w(d.value.lastCheck)),1)):U("",!0)]}),_:1})]),_:1})}}}),lD=Me(aD,[["__scopeId","data-v-26a99baf"]]),nD={class:"d-flex align-center ga-2"},oD={key:0,class:"d-flex justify-center py-8"},sD={class:"d-flex justify-end align-center ga-2 mt-4"},iD=Ae({__name:"SeoOrganizationSettingsCard",props:{expanded:{type:Boolean,default:!1},expandedModifiers:{}},emits:aa(["error","success"],["update:expanded"]),setup(r,{emit:$}){const d=ua(r,"expanded"),c=$,s=y(!1),m=y(!1),u=y(!1),f=y(""),p=y(""),_=y(""),k=y(""),i=y([]),g=y(null),x=y(null);let w="";const b=S=>!S||S.startsWith("https://")||S.startsWith("http://")||"URL muss mit https:// beginnen";function I(){const S={},B=f.value.trim();B&&(S.logoUrl=B);const G=p.value.trim();G&&(S.phone=G);const W=_.value.trim();W&&(S.email=W);const F=k.value.trim();F&&(S.description=F);const L=i.value.map(A=>String(A).trim()).filter(Boolean);return L.length>0&&(S.sameAs=L),typeof g.value=="number"&&!Number.isNaN(g.value)&&(S.geoLatitude=g.value),typeof x.value=="number"&&!Number.isNaN(x.value)&&(S.geoLongitude=x.value),S}function V(S){f.value=(S==null?void 0:S.logoUrl)??"",p.value=(S==null?void 0:S.phone)??"",_.value=(S==null?void 0:S.email)??"",k.value=(S==null?void 0:S.description)??"",i.value=Array.isArray(S==null?void 0:S.sameAs)?[...S.sameAs]:[],g.value=typeof(S==null?void 0:S.geoLatitude)=="number"?S.geoLatitude:null,x.value=typeof(S==null?void 0:S.geoLongitude)=="number"?S.geoLongitude:null,w=JSON.stringify(I())}const E=y(!1);function R(){E.value=JSON.stringify(I())!==w}Ze([f,p,_,k,i,g,x],R,{deep:!0});async function M(){var B;s.value=!0;const S=await re.get("/platform-settings");S.success&&S.data?(V((B=S.data.current.seo)==null?void 0:B.organization),E.value=!1,u.value=!0):c("error",S.error||"Fehler beim Laden der Organisation-Einstellungen."),s.value=!1}async function T(){m.value=!0;const S=I(),B=await re.put("/platform-settings/seo/organization",S);B.success?(w=JSON.stringify(I()),E.value=!1,c("success","Organisation-Daten gespeichert.")):c("error",B.error||"Fehler beim Speichern der Organisation-Daten."),m.value=!1}async function D(){u.value=!1,await M()}function H(S){if(S===""||S===null||S===void 0){g.value=null;return}const B=parseFloat(S);if(Number.isNaN(B)){g.value=null;return}g.value=Math.max(-90,Math.min(90,Math.round(B*1e4)/1e4))}function O(S){if(S===""||S===null||S===void 0){x.value=null;return}const B=parseFloat(S);if(Number.isNaN(B)){x.value=null;return}x.value=Math.max(-180,Math.min(180,Math.round(B*1e4)/1e4))}return rt(()=>{d.value&&!u.value&&M()}),Ze(d,S=>{S&&!u.value&&M()}),(S,B)=>{const G=l("v-icon"),W=l("v-card-title"),F=l("v-divider"),L=l("v-alert"),A=l("v-progress-circular"),z=l("v-text-field"),j=l("v-col"),J=l("v-combobox"),Q=l("v-textarea"),te=l("v-row"),ve=l("v-btn"),de=l("v-tooltip"),Z=l("v-card-text"),ce=l("v-card");return o(),N(ce,{rounded:"lg",class:"settings-card"},{default:t(()=>[e(W,{class:"settings-card__title",onClick:B[0]||(B[0]=oe=>d.value=!d.value)},{default:t(()=>[a("div",nD,[e(G,{size:"20"},{default:t(()=>[...B[8]||(B[8]=[n("mdi-domain",-1)])]),_:1}),B[9]||(B[9]=n(" Organisation für Strukturierte Daten (JSON-LD) ",-1))]),e(G,{size:"20"},{default:t(()=>[n(v(d.value?"mdi-chevron-up":"mdi-chevron-down"),1)]),_:1})]),_:1}),d.value?(o(),h(be,{key:0},[e(F),e(Z,{class:"pa-4"},{default:t(()=>[e(L,{type:"info",variant:"tonal",density:"compact",class:"mb-4"},{default:t(()=>[...B[10]||(B[10]=[n(" Firmenname und Anschrift werden aus den Allgemein-Einstellungen übernommen. ",-1)])]),_:1}),s.value?(o(),h("div",oD,[e(A,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:1},[e(te,{dense:""},{default:t(()=>[e(j,{cols:"12",md:"6"},{default:t(()=>[e(z,{modelValue:f.value,"onUpdate:modelValue":B[1]||(B[1]=oe=>f.value=oe),label:"Logo-URL",variant:"outlined",density:"comfortable","persistent-hint":"",hint:"Absolute URL zum Firmenlogo, z. B. /images/logo-basec.svg"},null,8,["modelValue"])]),_:1}),e(j,{cols:"12",md:"6"},{default:t(()=>[e(z,{modelValue:p.value,"onUpdate:modelValue":B[2]||(B[2]=oe=>p.value=oe),label:"Telefon",variant:"outlined",density:"comfortable","persistent-hint":"",hint:"Format: +49-..."},null,8,["modelValue"])]),_:1}),e(j,{cols:"12",md:"6"},{default:t(()=>[e(z,{modelValue:_.value,"onUpdate:modelValue":B[3]||(B[3]=oe=>_.value=oe),label:"E-Mail",type:"email",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(j,{cols:"12",md:"6"},{default:t(()=>[e(J,{modelValue:i.value,"onUpdate:modelValue":B[4]||(B[4]=oe=>i.value=oe),label:"Social Profiles",variant:"outlined",density:"comfortable",multiple:"",chips:"","closable-chips":"","persistent-hint":"",hint:"LinkedIn, XING, Twitter URLs (müssen mit https:// beginnen)",rules:[b]},null,8,["modelValue","rules"])]),_:1}),e(j,{cols:"12"},{default:t(()=>[e(Q,{modelValue:k.value,"onUpdate:modelValue":B[5]||(B[5]=oe=>k.value=oe),label:"Kurzbeschreibung",variant:"outlined",density:"comfortable",rows:"3"},null,8,["modelValue"])]),_:1}),e(j,{cols:"12",md:"6"},{default:t(()=>[e(z,{"model-value":g.value,label:"Breitengrad",type:"number",step:"0.0001",min:"-90",max:"90",variant:"outlined",density:"comfortable","persistent-hint":"",hint:"Bereich -90 bis 90, bis zu 4 Nachkommastellen (optional)","onUpdate:modelValue":B[6]||(B[6]=oe=>H(String(oe??"")))},null,8,["model-value"])]),_:1}),e(j,{cols:"12",md:"6"},{default:t(()=>[e(z,{"model-value":x.value,label:"Längengrad",type:"number",step:"0.0001",min:"-180",max:"180",variant:"outlined",density:"comfortable","persistent-hint":"",hint:"Bereich -180 bis 180, bis zu 4 Nachkommastellen (optional)","onUpdate:modelValue":B[7]||(B[7]=oe=>O(String(oe??"")))},null,8,["model-value"])]),_:1})]),_:1}),a("div",sD,[e(de,{text:"Daten neu laden",location:"top"},{activator:t(({props:oe})=>[e(ve,Vt(oe,{icon:"mdi-refresh",variant:"text",size:"small",loading:s.value,disabled:m.value,"aria-label":"Daten neu laden",onClick:D}),null,16,["loading","disabled"])]),_:1}),e(ve,{color:"primary",variant:"flat",loading:m.value,disabled:!E.value||s.value,onClick:T},{default:t(()=>[...B[11]||(B[11]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled"])])],64))]),_:1})],64)):U("",!0)]),_:1})}}}),rD=Me(iD,[["__scopeId","data-v-25835fe8"]]),dD={class:"d-flex align-center ga-2"},uD={key:0,class:"d-flex justify-center py-8"},cD={class:"d-flex justify-end align-center ga-2 mt-4"},mD=Ae({__name:"PlatformSettingsCompanyCard",props:{expanded:{type:Boolean,default:!1},expandedModifiers:{}},emits:aa(["error","success"],["update:expanded"]),setup(r,{emit:$}){const d=ua(r,"expanded"),c=$,s=y(!1),m=y(!1),u=y(!1),f=y(""),p=y(""),_=y(""),k=y(""),i=y(""),g=y(""),x=y("DE"),w=y(""),b=y(""),I=y(""),V=y(""),E=y(null),R=y(null),M=y([]),T=y([]),D=y([]);let H="";function O(){return{companyName:f.value.trim(),companyLegalName:p.value.trim(),companyDescription:_.value.trim(),companyStreet:k.value.trim(),companyPostalCode:i.value.trim(),companyCity:g.value.trim(),companyCountry:x.value.trim()||"DE",companyPhone:w.value.trim(),companyEmail:b.value.trim(),companyLogoUrl:I.value.trim(),companyFoundingDate:V.value.trim(),companyGeoLatitude:typeof E.value=="number"&&!Number.isNaN(E.value)?E.value:null,companyGeoLongitude:typeof R.value=="number"&&!Number.isNaN(R.value)?R.value:null,companySameAs:M.value.map(j=>String(j).trim()).filter(Boolean),companyOpeningHours:T.value.map(j=>String(j).trim()).filter(Boolean),companyAreaServed:D.value.map(j=>String(j).trim()).filter(Boolean)}}function S(j){const J=j;f.value=J.companyName??"",p.value=J.companyLegalName??"",_.value=J.companyDescription??"",k.value=J.companyStreet??"",i.value=J.companyPostalCode??"",g.value=J.companyCity??"",x.value=J.companyCountry??"DE",w.value=J.companyPhone??"",b.value=J.companyEmail??"",I.value=J.companyLogoUrl??"",V.value=J.companyFoundingDate??"",E.value=typeof J.companyGeoLatitude=="number"?J.companyGeoLatitude:null,R.value=typeof J.companyGeoLongitude=="number"?J.companyGeoLongitude:null,M.value=Array.isArray(J.companySameAs)?[...J.companySameAs]:[],T.value=Array.isArray(J.companyOpeningHours)?[...J.companyOpeningHours]:[],D.value=Array.isArray(J.companyAreaServed)?[...J.companyAreaServed]:["DE"],H=JSON.stringify(O())}const B=y(!1);function G(){B.value=JSON.stringify(O())!==H}Ze([f,p,_,k,i,g,x,w,b,I,V,E,R,M,T,D],G,{deep:!0});async function W(){s.value=!0;const j=await re.get("/platform-settings");j.success&&j.data?(S(j.data.current),B.value=!1,u.value=!0):c("error",j.error||"Fehler beim Laden der Firmen-Einstellungen."),s.value=!1}async function F(){m.value=!0;const j=O(),J=await re.put("/platform-settings/company",j);J.success?(H=JSON.stringify(O()),B.value=!1,c("success","Firmen-Daten gespeichert.")):c("error",J.error||"Fehler beim Speichern der Firmen-Daten."),m.value=!1}async function L(){u.value=!1,await W()}function A(j){if(j===""||j===null||j===void 0){E.value=null;return}const J=parseFloat(j);if(Number.isNaN(J)){E.value=null;return}E.value=Math.max(-90,Math.min(90,Math.round(J*1e5)/1e5))}function z(j){if(j===""||j===null||j===void 0){R.value=null;return}const J=parseFloat(j);if(Number.isNaN(J)){R.value=null;return}R.value=Math.max(-180,Math.min(180,Math.round(J*1e5)/1e5))}return rt(()=>{d.value&&!u.value&&W()}),Ze(d,j=>{j&&!u.value&&W()}),(j,J)=>{const Q=l("v-icon"),te=l("v-card-title"),ve=l("v-divider"),de=l("v-alert"),Z=l("v-progress-circular"),ce=l("v-text-field"),oe=l("v-col"),pe=l("v-textarea"),_e=l("v-row"),q=l("v-combobox"),C=l("v-btn"),ae=l("v-tooltip"),X=l("v-card-text"),ie=l("v-card");return o(),N(ie,{rounded:"lg",class:"settings-card"},{default:t(()=>[e(te,{class:"settings-card__title",onClick:J[0]||(J[0]=fe=>d.value=!d.value)},{default:t(()=>[a("div",dD,[e(Q,{size:"20"},{default:t(()=>[...J[17]||(J[17]=[n("mdi-office-building-outline",-1)])]),_:1}),J[18]||(J[18]=n(" Unternehmen (SEO / Organization) ",-1))]),e(Q,{size:"20"},{default:t(()=>[n(v(d.value?"mdi-chevron-up":"mdi-chevron-down"),1)]),_:1})]),_:1}),d.value?(o(),h(be,{key:0},[e(ve),e(X,{class:"pa-4"},{default:t(()=>[e(de,{type:"info",variant:"tonal",density:"compact",class:"mb-4"},{default:t(()=>[...J[19]||(J[19]=[n(" Diese Daten werden im globalen Organization-/LocalBusiness-JSON-LD eingebettet und vom öffentlichen Endpoint ",-1),a("code",null,"/api/settings/public",-1),n(" ausgeliefert. ",-1)])]),_:1}),s.value?(o(),h("div",uD,[e(Z,{indeterminate:"",color:"primary"})])):(o(),h(be,{key:1},[J[21]||(J[21]=a("div",{class:"text-subtitle-2 mb-2"},"Firmenname & Adresse",-1)),e(_e,{dense:""},{default:t(()=>[e(oe,{cols:"12",md:"6"},{default:t(()=>[e(ce,{modelValue:f.value,"onUpdate:modelValue":J[1]||(J[1]=fe=>f.value=fe),label:"Firmenname (Handelsname)",variant:"outlined",density:"comfortable","persistent-hint":"",hint:"Wird als Organization.name verwendet, z. B. Basec GmbH"},null,8,["modelValue"])]),_:1}),e(oe,{cols:"12",md:"6"},{default:t(()=>[e(ce,{modelValue:p.value,"onUpdate:modelValue":J[2]||(J[2]=fe=>p.value=fe),label:"Firmenname (rechtlich)",variant:"outlined",density:"comfortable","persistent-hint":"",hint:"Falls vom Handelsnamen abweichend, sonst leer lassen"},null,8,["modelValue"])]),_:1}),e(oe,{cols:"12"},{default:t(()=>[e(pe,{modelValue:_.value,"onUpdate:modelValue":J[3]||(J[3]=fe=>_.value=fe),label:"Firmenbeschreibung (SEO)",variant:"outlined",density:"comfortable",rows:"2","auto-grow":"",counter:"300",maxlength:"300","persistent-hint":"",hint:"Kurzbeschreibung für SEO/Schema, max 300 Zeichen"},null,8,["modelValue"])]),_:1}),e(oe,{cols:"12",md:"8"},{default:t(()=>[e(ce,{modelValue:k.value,"onUpdate:modelValue":J[4]||(J[4]=fe=>k.value=fe),label:"Straße + Hausnummer",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(oe,{cols:"6",md:"2"},{default:t(()=>[e(ce,{modelValue:i.value,"onUpdate:modelValue":J[5]||(J[5]=fe=>i.value=fe),label:"PLZ",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(oe,{cols:"6",md:"2"},{default:t(()=>[e(ce,{modelValue:x.value,"onUpdate:modelValue":J[6]||(J[6]=fe=>x.value=fe),label:"Land",variant:"outlined",density:"comfortable","persistent-hint":"",hint:"ISO-Land-Code (DE, AT, CH)"},null,8,["modelValue"])]),_:1}),e(oe,{cols:"12",md:"6"},{default:t(()=>[e(ce,{modelValue:g.value,"onUpdate:modelValue":J[7]||(J[7]=fe=>g.value=fe),label:"Stadt",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(oe,{cols:"12",md:"6"},{default:t(()=>[e(ce,{modelValue:V.value,"onUpdate:modelValue":J[8]||(J[8]=fe=>V.value=fe),label:"Gründungsdatum (ISO)",placeholder:"2023-01-15",variant:"outlined",density:"comfortable","persistent-hint":"",hint:"ISO-Datum YYYY-MM-DD, z. B. 2015-03-01"},null,8,["modelValue"])]),_:1})]),_:1}),e(ve,{class:"my-4"}),J[22]||(J[22]=a("div",{class:"text-subtitle-2 mb-2"},"Kontakt & Logo",-1)),e(_e,{dense:""},{default:t(()=>[e(oe,{cols:"12",md:"6"},{default:t(()=>[e(ce,{modelValue:w.value,"onUpdate:modelValue":J[9]||(J[9]=fe=>w.value=fe),label:"Telefon",variant:"outlined",density:"comfortable","persistent-hint":"",hint:"Format: +49-..."},null,8,["modelValue"])]),_:1}),e(oe,{cols:"12",md:"6"},{default:t(()=>[e(ce,{modelValue:b.value,"onUpdate:modelValue":J[10]||(J[10]=fe=>b.value=fe),label:"E-Mail",type:"email",variant:"outlined",density:"comfortable"},null,8,["modelValue"])]),_:1}),e(oe,{cols:"12"},{default:t(()=>[e(ce,{modelValue:I.value,"onUpdate:modelValue":J[11]||(J[11]=fe=>I.value=fe),label:"Logo-URL",variant:"outlined",density:"comfortable","persistent-hint":"",hint:"Absolute URL oder absoluter Pfad, z. B. /images/basec-logo.png"},null,8,["modelValue"])]),_:1})]),_:1}),e(ve,{class:"my-4"}),J[23]||(J[23]=a("div",{class:"text-subtitle-2 mb-2"},"Geo-Koordinaten (für LocalBusiness)",-1)),e(_e,{dense:""},{default:t(()=>[e(oe,{cols:"12",md:"6"},{default:t(()=>[e(ce,{"model-value":E.value,label:"Breitengrad (Latitude)",type:"number",step:"0.00001",min:"-90",max:"90",variant:"outlined",density:"comfortable","persistent-hint":"",hint:"Bereich -90 bis 90, bis zu 5 Nachkommastellen (optional)","onUpdate:modelValue":J[12]||(J[12]=fe=>A(String(fe??"")))},null,8,["model-value"])]),_:1}),e(oe,{cols:"12",md:"6"},{default:t(()=>[e(ce,{"model-value":R.value,label:"Längengrad (Longitude)",type:"number",step:"0.00001",min:"-180",max:"180",variant:"outlined",density:"comfortable","persistent-hint":"",hint:"Bereich -180 bis 180, bis zu 5 Nachkommastellen (optional)","onUpdate:modelValue":J[13]||(J[13]=fe=>z(String(fe??"")))},null,8,["model-value"])]),_:1})]),_:1}),e(ve,{class:"my-4"}),J[24]||(J[24]=a("div",{class:"text-subtitle-2 mb-2"},"Social Profiles & Betrieb",-1)),e(_e,{dense:""},{default:t(()=>[e(oe,{cols:"12"},{default:t(()=>[e(q,{modelValue:M.value,"onUpdate:modelValue":J[14]||(J[14]=fe=>M.value=fe),label:"Social Profiles (URLs)",variant:"outlined",density:"comfortable",multiple:"",chips:"","closable-chips":"","persistent-hint":"",hint:"LinkedIn, Instagram, X/Twitter - vollständige https://-URLs"},null,8,["modelValue"])]),_:1}),e(oe,{cols:"12",md:"6"},{default:t(()=>[e(q,{modelValue:T.value,"onUpdate:modelValue":J[15]||(J[15]=fe=>T.value=fe),label:"Öffnungszeiten",variant:"outlined",density:"comfortable",multiple:"",chips:"","closable-chips":"","persistent-hint":"",hint:"Format schema.org: 'Mo-Fr 09:00-18:00'"},null,8,["modelValue"])]),_:1}),e(oe,{cols:"12",md:"6"},{default:t(()=>[e(q,{modelValue:D.value,"onUpdate:modelValue":J[16]||(J[16]=fe=>D.value=fe),label:"Einsatzgebiet",variant:"outlined",density:"comfortable",multiple:"",chips:"","closable-chips":"","persistent-hint":"",hint:"ISO-Land-Codes (DE, EU, AT, CH)"},null,8,["modelValue"])]),_:1})]),_:1}),a("div",cD,[e(ae,{text:"Daten neu laden",location:"top"},{activator:t(({props:fe})=>[e(C,Vt(fe,{icon:"mdi-refresh",variant:"text",size:"small",loading:s.value,disabled:m.value,"aria-label":"Daten neu laden",onClick:L}),null,16,["loading","disabled"])]),_:1}),e(C,{color:"primary",variant:"flat",loading:m.value,disabled:!B.value||s.value,onClick:F},{default:t(()=>[...J[20]||(J[20]=[n(" Speichern ",-1)])]),_:1},8,["loading","disabled"])])],64))]),_:1})],64)):U("",!0)]),_:1})}}}),vD=Me(mD,[["__scopeId","data-v-9594682f"]]),pD={id:"linkedin",class:"d-flex align-center justify-space-between mb-2"},fD={class:"d-flex align-center ga-3"},gD={key:0,class:"text-caption text-medium-emphasis"},bD={key:1},yD={key:0,class:"text-caption text-success"},_D={key:1,class:"text-caption text-warning"},kD={class:"d-flex ga-2 mt-2"},hD=Ae({__name:"SettingsLinkedinSection",emits:["disconnect-success","disconnect-error"],setup(r,{emit:$}){const d=$,c=xt(),s=y(null),m=y(!1),u=y(!1),f=y(!1);async function p(){m.value=!0;const i=await ul();i.success&&i.data?s.value=i.data:s.value={hasCredentials:!1,isConnected:!1,dryRun:!1,tokenStatus:null,expiresAt:null,userId:null,userName:null,message:i.error||"Status konnte nicht geladen werden."},m.value=!1}function _(){c.push({name:"admin-ki-einstellungen"})}async function k(){f.value=!0;try{const i=await jl();i.success?(await p(),d("disconnect-success")):d("disconnect-error",i.error||"Trennen fehlgeschlagen.")}catch(i){d("disconnect-error",i instanceof Error?i.message:"Trennen fehlgeschlagen.")}finally{f.value=!1,u.value=!1}}return rt(p),(i,g)=>{var D;const x=l("v-icon"),w=l("v-chip"),b=l("v-btn"),I=l("v-card-title"),V=l("v-card-text"),E=l("v-spacer"),R=l("v-card-actions"),M=l("v-card"),T=l("v-dialog");return o(),h(be,null,[a("div",pD,[a("div",fD,[e(x,{size:"24",color:"primary"},{default:t(()=>[...g[3]||(g[3]=[n("mdi-linkedin",-1)])]),_:1}),a("div",null,[g[4]||(g[4]=a("div",{class:"text-body-2 font-weight-medium"},"LinkedIn",-1)),m.value?(o(),h("div",gD," Lade Status... ")):s.value?(o(),h("div",bD,[s.value.isConnected?(o(),h("div",yD," Verbunden"+v(s.value.userName?` (${s.value.userName})`:""),1)):(o(),h("div",_D,v(s.value.message),1))])):U("",!0)])]),s.value&&!m.value?(o(),N(w,{key:0,color:s.value.isConnected?"success":"warning",size:"small",variant:"tonal"},{default:t(()=>[n(v(s.value.isConnected?"Aktiv":"Inaktiv"),1)]),_:1},8,["color"])):U("",!0)]),a("div",kD,[e(b,{variant:"text",size:"small",color:"primary","prepend-icon":"mdi-refresh",loading:m.value,onClick:p},{default:t(()=>[...g[5]||(g[5]=[n(" Status aktualisieren ",-1)])]),_:1},8,["loading"]),e(b,{variant:"outlined",size:"small",color:"primary","prepend-icon":"mdi-cog-outline",onClick:_},{default:t(()=>[...g[6]||(g[6]=[n(" Konfigurieren ",-1)])]),_:1}),(D=s.value)!=null&&D.isConnected?(o(),N(b,{key:0,variant:"outlined",size:"small",color:"error","prepend-icon":"mdi-link-variant-off",onClick:g[0]||(g[0]=H=>u.value=!0)},{default:t(()=>[...g[7]||(g[7]=[n(" Trennen ",-1)])]),_:1})):U("",!0)]),e(T,{modelValue:u.value,"onUpdate:modelValue":g[2]||(g[2]=H=>u.value=H),"max-width":"500",persistent:""},{default:t(()=>[e(M,null,{default:t(()=>[e(I,{class:"d-flex align-center ga-2"},{default:t(()=>[e(x,{color:"error"},{default:t(()=>[...g[8]||(g[8]=[n("mdi-link-variant-off",-1)])]),_:1}),g[9]||(g[9]=n(" LinkedIn-Verbindung trennen? ",-1))]),_:1}),e(V,null,{default:t(()=>[...g[10]||(g[10]=[a("p",{class:"mb-2"},[n(" Die OAuth-Tokens werden gelöscht. Geplante Posts können danach "),a("strong",null,"nicht mehr veröffentlicht"),n(" werden, bis du dich neu verbindest. ")],-1),a("p",{class:"text-caption text-medium-emphasis"}," Bereits veröffentlichte Posts bleiben auf LinkedIn unverändert. ",-1)])]),_:1}),e(R,null,{default:t(()=>[e(E),e(b,{variant:"text",disabled:f.value,onClick:g[1]||(g[1]=H=>u.value=!1)},{default:t(()=>[...g[11]||(g[11]=[n(" Abbrechen ",-1)])]),_:1},8,["disabled"]),e(b,{color:"error",variant:"elevated",loading:f.value,onClick:k},{default:t(()=>[...g[12]||(g[12]=[n(" Verbindung trennen ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"])],64)}}}),xD={class:"d-flex align-center ga-2"},wD={class:"d-flex align-center justify-space-between mb-2"},SD={class:"d-flex align-center ga-3"},$D={key:0,class:"text-caption text-medium-emphasis"},CD={key:1},VD={key:0,class:"text-caption text-success"},AD={key:1,class:"text-caption text-warning"},ID={key:2,class:"text-caption text-medium-emphasis"},PD={class:"d-flex align-center justify-space-between mb-2"},zD={class:"d-flex align-center ga-3"},DD={key:0,class:"text-caption text-medium-emphasis"},TD={key:1},LD={key:0,class:"text-caption text-success"},ED={key:1,class:"text-caption text-medium-emphasis"},MD={class:"d-flex align-center ga-2"},ND={class:"d-flex align-center ga-4"},UD={class:"text-h6 font-weight-bold"},BD={class:"text-body-1 font-weight-medium"},FD={class:"text-body-2 text-medium-emphasis"},OD={class:"d-flex align-center ga-2"},RD={class:"d-flex align-center ga-2"},KD={class:"d-flex align-center ga-2"},jD={class:"d-flex align-center ga-2"},qD=Ae({__name:"SettingsView",setup(r){const $=ea(),d=y(null),c=y(null),s=qe("settings_profile",!0),m=qe("settings_password",!0),u=qe("settings_integrations",!0),f=qe("settings_ui",!0),p=qe("settings_timeouts",!0),_=qe("deployment_expanded",!1),k=qe("settings_seo_organization",!1),i=qe("settings_company",!1),g=y(!1),x=y({currentPassword:"",newPassword:"",confirmPassword:""}),w=y(!1),b=y(!1),I=y(!1),V=y(!1),E=[L=>!!L||"Pflichtfeld",L=>L.length>=8||"Mindestens 8 Zeichen"],R=[L=>!!L||"Pflichtfeld",L=>L===x.value.newPassword||"Passwörter stimmen nicht überein"];async function M(){if(!V.value)return;g.value=!0,d.value=null,c.value=null;const L=await re.put("/auth/change-password",{currentPassword:x.value.currentPassword,newPassword:x.value.newPassword});L.success?(c.value="Passwort erfolgreich geändert.",x.value={currentPassword:"",newPassword:"",confirmPassword:""}):d.value=L.error||"Fehler beim Ändern des Passworts.",g.value=!1}const T=y(null),D=y(!1);async function H(){D.value=!0;const L=await re.get("/hubspot/status");L.success&&L.data?T.value=L.data:T.value={status:"error",message:L.error||"Status konnte nicht geladen werden."},D.value=!1}const O=y(null),S=y(!1);async function B(){S.value=!0;const L=await re.get("/ideogram-presets/status");L.success&&L.data?O.value=L.data:O.value={configured:!1,provider:"ideogram"},S.value=!1}function G(){c.value="LinkedIn-Verbindung getrennt."}function W(L){d.value=L}function F(){const L=Object.keys(localStorage).filter(A=>A.startsWith("basec_pref_"));L.forEach(A=>localStorage.removeItem(A)),c.value=`${L.length} gespeicherte Einstellungen zurückgesetzt. Seite wird neu geladen...`,setTimeout(()=>window.location.reload(),1500)}return rt(()=>{H(),B()}),(L,A)=>{const z=l("v-alert"),j=l("v-icon"),J=l("v-card-title"),Q=l("v-divider"),te=l("v-chip"),ve=l("v-btn"),de=l("v-card-text"),Z=l("v-card"),ce=l("v-col"),oe=l("v-avatar"),pe=l("v-text-field"),_e=l("v-form"),q=l("v-row"),C=l("v-container");return o(),N(C,{fluid:"",class:"pa-6"},{default:t(()=>[A[45]||(A[45]=a("h1",{class:"text-h4 font-weight-bold mb-6"},"Einstellungen",-1)),d.value?(o(),N(z,{key:0,type:"error",variant:"tonal",class:"mb-4",closable:"","onClick:close":A[0]||(A[0]=ae=>d.value=null)},{default:t(()=>[n(v(d.value),1)]),_:1})):U("",!0),c.value?(o(),N(z,{key:1,type:"success",variant:"tonal",class:"mb-4",closable:"","onClick:close":A[1]||(A[1]=ae=>c.value=null)},{default:t(()=>[n(v(c.value),1)]),_:1})):U("",!0),e(q,null,{default:t(()=>[e(ce,{cols:"12",md:"6"},{default:t(()=>[e(Z,{rounded:"lg",class:"settings-card"},{default:t(()=>[e(J,{class:"settings-card__title",onClick:A[2]||(A[2]=ae=>u.value=!P(u))},{default:t(()=>[a("div",xD,[e(j,{size:"20"},{default:t(()=>[...A[22]||(A[22]=[n("mdi-connection",-1)])]),_:1}),A[23]||(A[23]=n(" Integrationen ",-1))]),e(j,{size:"20"},{default:t(()=>[n(v(P(u)?"mdi-chevron-up":"mdi-chevron-down"),1)]),_:1})]),_:1}),P(u)?(o(),h(be,{key:0},[e(Q),e(de,{class:"pa-4"},{default:t(()=>[a("div",wD,[a("div",SD,[e(j,{size:"24",color:"warning"},{default:t(()=>[...A[24]||(A[24]=[n("mdi-hubspot",-1)])]),_:1}),a("div",null,[A[25]||(A[25]=a("div",{class:"text-body-2 font-weight-medium"},"HubSpot CRM",-1)),D.value?(o(),h("div",$D,"Lade Status...")):T.value?(o(),h("div",CD,[T.value.status==="connected"?(o(),h("div",VD," Verbunden (Portal "+v(T.value.portalId)+") ",1)):T.value.status==="error"?(o(),h("div",AD,v(T.value.message||"Verbindung fehlgeschlagen"),1)):(o(),h("div",ID," Nicht konfiguriert "))])):U("",!0)])]),T.value&&!D.value?(o(),N(te,{key:0,color:T.value.status==="connected"?"success":T.value.status==="error"?"warning":"default",size:"small",variant:"tonal"},{default:t(()=>[n(v(T.value.status==="connected"?"Aktiv":T.value.status==="error"?"Fehler":"Inaktiv"),1)]),_:1},8,["color"])):U("",!0)]),e(ve,{variant:"text",size:"small",color:"primary","prepend-icon":"mdi-refresh",loading:D.value,class:"mt-2",onClick:H},{default:t(()=>[...A[26]||(A[26]=[n(" Status aktualisieren ",-1)])]),_:1},8,["loading"]),e(Q,{class:"my-4"}),a("div",PD,[a("div",zD,[e(j,{size:"24",color:"primary"},{default:t(()=>[...A[27]||(A[27]=[n("mdi-image-auto-adjust",-1)])]),_:1}),a("div",null,[A[28]||(A[28]=a("div",{class:"text-body-2 font-weight-medium"},"Ideogram",-1)),S.value?(o(),h("div",DD,"Lade Status...")):O.value?(o(),h("div",TD,[O.value.configured?(o(),h("div",LD," API-Key konfiguriert ")):(o(),h("div",ED," Nicht konfiguriert (IDEOGRAM_API_KEY fehlt) "))])):U("",!0)])]),O.value&&!S.value?(o(),N(te,{key:0,color:O.value.configured?"success":"default",size:"small",variant:"tonal"},{default:t(()=>[n(v(O.value.configured?"Aktiv":"Inaktiv"),1)]),_:1},8,["color"])):U("",!0)]),e(ve,{variant:"text",size:"small",color:"primary","prepend-icon":"mdi-refresh",loading:S.value,class:"mt-2",onClick:B},{default:t(()=>[...A[29]||(A[29]=[n(" Status aktualisieren ",-1)])]),_:1},8,["loading"]),e(Q,{class:"my-4"}),e(hD,{onDisconnectSuccess:G,onDisconnectError:W})]),_:1})],64)):U("",!0)]),_:1})]),_:1}),e(ce,{cols:"12",md:"6"},{default:t(()=>[e(Z,{rounded:"lg",class:"settings-card"},{default:t(()=>[e(J,{class:"settings-card__title",onClick:A[3]||(A[3]=ae=>s.value=!P(s))},{default:t(()=>[a("div",MD,[e(j,{size:"20"},{default:t(()=>[...A[30]||(A[30]=[n("mdi-account-circle",-1)])]),_:1}),A[31]||(A[31]=n(" Profil ",-1))]),e(j,{size:"20"},{default:t(()=>[n(v(P(s)?"mdi-chevron-up":"mdi-chevron-down"),1)]),_:1})]),_:1}),P(s)?(o(),h(be,{key:0},[e(Q),e(de,{class:"pa-4"},{default:t(()=>{var ae;return[a("div",ND,[e(oe,{size:"56",color:"primary"},{default:t(()=>[a("span",UD,v((P($).userName||"A").charAt(0).toUpperCase()),1)]),_:1}),a("div",null,[a("div",BD,v(P($).userName||"Administrator"),1),a("div",FD,v((ae=P($).user)==null?void 0:ae.email),1),e(te,{size:"x-small",color:"primary",variant:"tonal",class:"mt-1"},{default:t(()=>[n(v(P($).userRole),1)]),_:1})])])]}),_:1})],64)):U("",!0)]),_:1})]),_:1}),e(ce,{cols:"12",md:"6"},{default:t(()=>[e(Z,{rounded:"lg",class:"settings-card"},{default:t(()=>[e(J,{class:"settings-card__title",onClick:A[4]||(A[4]=ae=>f.value=!P(f))},{default:t(()=>[a("div",OD,[e(j,{size:"20"},{default:t(()=>[...A[32]||(A[32]=[n("mdi-palette-outline",-1)])]),_:1}),A[33]||(A[33]=n(" Oberfläche ",-1))]),e(j,{size:"20"},{default:t(()=>[n(v(P(f)?"mdi-chevron-up":"mdi-chevron-down"),1)]),_:1})]),_:1}),P(f)?(o(),h(be,{key:0},[e(Q),e(de,{class:"pa-4"},{default:t(()=>[A[35]||(A[35]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," Filter, Sidebar-Zustand und Tabelleneinstellungen werden automatisch im Browser gespeichert. ",-1)),e(ve,{variant:"outlined",color:"warning","prepend-icon":"mdi-restore",onClick:F},{default:t(()=>[...A[34]||(A[34]=[n(" Alle Einstellungen zurücksetzen ",-1)])]),_:1})]),_:1})],64)):U("",!0)]),_:1})]),_:1}),e(ce,{cols:"12",md:"6"},{default:t(()=>[e(Z,{rounded:"lg",class:"settings-card"},{default:t(()=>[e(J,{class:"settings-card__title",onClick:A[5]||(A[5]=ae=>m.value=!P(m))},{default:t(()=>[a("div",RD,[e(j,{size:"20"},{default:t(()=>[...A[36]||(A[36]=[n("mdi-lock-outline",-1)])]),_:1}),A[37]||(A[37]=n(" Passwort ändern ",-1))]),e(j,{size:"20"},{default:t(()=>[n(v(P(m)?"mdi-chevron-up":"mdi-chevron-down"),1)]),_:1})]),_:1}),P(m)?(o(),h(be,{key:0},[e(Q),e(de,{class:"pa-4"},{default:t(()=>[e(_e,{modelValue:V.value,"onUpdate:modelValue":A[11]||(A[11]=ae=>V.value=ae),onSubmit:dt(M,["prevent"])},{default:t(()=>[e(pe,{modelValue:x.value.currentPassword,"onUpdate:modelValue":A[6]||(A[6]=ae=>x.value.currentPassword=ae),label:"Aktuelles Passwort",type:w.value?"text":"password","append-inner-icon":w.value?"mdi-eye-off":"mdi-eye",rules:E,variant:"outlined",density:"comfortable",class:"mb-2","onClick:appendInner":A[7]||(A[7]=ae=>w.value=!w.value)},null,8,["modelValue","type","append-inner-icon"]),e(pe,{modelValue:x.value.newPassword,"onUpdate:modelValue":A[8]||(A[8]=ae=>x.value.newPassword=ae),label:"Neues Passwort",type:b.value?"text":"password","append-inner-icon":b.value?"mdi-eye-off":"mdi-eye",rules:E,variant:"outlined",density:"comfortable",class:"mb-2","onClick:appendInner":A[9]||(A[9]=ae=>b.value=!b.value)},null,8,["modelValue","type","append-inner-icon"]),e(pe,{modelValue:x.value.confirmPassword,"onUpdate:modelValue":A[10]||(A[10]=ae=>x.value.confirmPassword=ae),label:"Neues Passwort bestätigen",type:"password",rules:R,variant:"outlined",density:"comfortable",class:"mb-4"},null,8,["modelValue"]),e(ve,{type:"submit",color:"primary",loading:g.value,disabled:!V.value},{default:t(()=>[...A[38]||(A[38]=[n(" Passwort ändern ",-1)])]),_:1},8,["loading","disabled"])]),_:1},8,["modelValue"])]),_:1})],64)):U("",!0)]),_:1})]),_:1}),e(ce,{cols:"12",md:"6"},{default:t(()=>[e(Z,{rounded:"lg",class:"settings-card"},{default:t(()=>[e(J,{class:"settings-card__title",onClick:A[12]||(A[12]=ae=>p.value=!P(p))},{default:t(()=>[a("div",KD,[e(j,{size:"20"},{default:t(()=>[...A[39]||(A[39]=[n("mdi-timer-cog-outline",-1)])]),_:1}),A[40]||(A[40]=n(" Timeouts & Limits ",-1))]),e(j,{size:"20"},{default:t(()=>[n(v(P(p)?"mdi-chevron-up":"mdi-chevron-down"),1)]),_:1})]),_:1}),P(p)?(o(),h(be,{key:0},[e(Q),e(de,{class:"pa-4"},{default:t(()=>[A[42]||(A[42]=a("p",{class:"text-body-2 text-medium-emphasis mb-4"}," KI-Provider, HubSpot, LinkedIn, Scraping und Datenhaltung. ",-1)),e(ve,{variant:"outlined",color:"primary","prepend-icon":"mdi-timer-cog-outline",onClick:A[13]||(A[13]=ae=>I.value=!0)},{default:t(()=>[...A[41]||(A[41]=[n(" Konfigurieren ",-1)])]),_:1})]),_:1})],64)):U("",!0)]),_:1})]),_:1}),e(ce,{cols:"12",md:"6"},{default:t(()=>[e(Z,{rounded:"lg",class:"settings-card"},{default:t(()=>[e(J,{class:"settings-card__title",onClick:A[14]||(A[14]=ae=>_.value=!P(_))},{default:t(()=>[a("div",jD,[e(j,{size:"20"},{default:t(()=>[...A[43]||(A[43]=[n("mdi-rocket-launch",-1)])]),_:1}),A[44]||(A[44]=n(" Deployment ",-1))]),e(j,{size:"20"},{default:t(()=>[n(v(P(_)?"mdi-chevron-up":"mdi-chevron-down"),1)]),_:1})]),_:1}),P(_)?(o(),h(be,{key:0},[e(Q),e(de,{class:"pa-4"},{default:t(()=>[e(lD)]),_:1})],64)):U("",!0)]),_:1})]),_:1}),e(ce,{cols:"12"},{default:t(()=>[e(vD,{expanded:P(i),"onUpdate:expanded":A[15]||(A[15]=ae=>ot(i)?i.value=ae:null),onError:A[16]||(A[16]=ae=>d.value=ae),onSuccess:A[17]||(A[17]=ae=>c.value=ae)},null,8,["expanded"])]),_:1}),e(ce,{cols:"12"},{default:t(()=>[e(rD,{expanded:P(k),"onUpdate:expanded":A[18]||(A[18]=ae=>ot(k)?k.value=ae:null),onError:A[19]||(A[19]=ae=>d.value=ae),onSuccess:A[20]||(A[20]=ae=>c.value=ae)},null,8,["expanded"])]),_:1})]),_:1}),e(Fz,{modelValue:I.value,"onUpdate:modelValue":A[21]||(A[21]=ae=>I.value=ae)},null,8,["modelValue"])]),_:1})}}}),GD=Me(qD,[["__scopeId","data-v-051c4989"]]),q6=Object.freeze(Object.defineProperty({__proto__:null,default:GD},Symbol.toStringTag,{value:"Module"})),HD={class:"d-flex align-center mb-1"},WD={class:"text-caption text-medium-emphasis"},ZD={class:"mt-auto pt-1 stats-kpi-bar__delta"},JD=Ae({__name:"StatsKpiBar",props:{stats:{}},setup(r){const $=r,{getMetricColor:d}=jt();function c(p){return p==null?"–":(p*100).toFixed(1)+"%"}function s(p){return p==null?"–":p.toLocaleString("de-DE")}function m(p){return p==null?"":`${p>=0?"+":""}${(p*100).toFixed(1)}%`}function u(p,_=!1){return p==null?"default":_?p>0?"error":p<0?"success":"default":p>0?"success":p<0?"error":"default"}const f=se(()=>{var p,_,k,i,g,x,w,b,I,V,E,R,M,T,D,H,O,S;return[{key:"sent",icon:"mdi-send",label:"Gesendet",value:s((p=$.stats)==null?void 0:p.totalSent),color:d("sent"),delta:m((_=$.stats)==null?void 0:_.deltaSent),deltaColorVal:u((k=$.stats)==null?void 0:k.deltaSent)},{key:"delivery",icon:"mdi-check-circle-outline",label:"Delivery-Rate",value:c((i=$.stats)==null?void 0:i.deliveryRate),color:d("delivered"),delta:m((g=$.stats)==null?void 0:g.deltaDeliveryRate),deltaColorVal:u((x=$.stats)==null?void 0:x.deltaDeliveryRate)},{key:"open",icon:"mdi-email-open-outline",label:"Open-Rate",value:c((w=$.stats)==null?void 0:w.openRate),color:d("opened"),delta:m((b=$.stats)==null?void 0:b.deltaOpenRate),deltaColorVal:u((I=$.stats)==null?void 0:I.deltaOpenRate)},{key:"click",icon:"mdi-cursor-default-click-outline",label:"Click-Rate",value:c((V=$.stats)==null?void 0:V.clickRate),color:d("clicked"),delta:m((E=$.stats)==null?void 0:E.deltaClickRate),deltaColorVal:u((R=$.stats)==null?void 0:R.deltaClickRate)},{key:"meeting",icon:"mdi-calendar-check-outline",label:"Meeting-Rate",value:c((M=$.stats)==null?void 0:M.meetingRate),color:d("meeting"),delta:m((T=$.stats)==null?void 0:T.deltaMeetingRate),deltaColorVal:u((D=$.stats)==null?void 0:D.deltaMeetingRate)},{key:"unsub",icon:"mdi-cancel",label:"Unsub-Rate",value:c((H=$.stats)==null?void 0:H.unsubscribeRate),color:d("unsubscribed"),delta:m((O=$.stats)==null?void 0:O.deltaUnsubscribeRate),deltaColorVal:u((S=$.stats)==null?void 0:S.deltaUnsubscribeRate,!0)}]});return(p,_)=>{const k=l("v-icon"),i=l("v-chip"),g=l("v-card"),x=l("v-col"),w=l("v-row");return o(),N(w,{dense:"",class:"stats-kpi-bar"},{default:t(()=>[(o(!0),h(be,null,Pe(f.value,b=>(o(),N(x,{key:b.key,cols:"6",sm:"4",md:"2"},{default:t(()=>[e(g,{variant:"outlined",class:"stats-kpi-bar__card pa-3 h-100 d-flex flex-column"},{default:t(()=>[a("div",HD,[e(k,{color:b.color,size:"16",class:"mr-1"},{default:t(()=>[n(v(b.icon),1)]),_:2},1032,["color"]),a("span",WD,v(b.label),1)]),a("div",{class:"text-h6 font-weight-bold stats-kpi-bar__value",style:ht({color:b.color})},v(b.value),5),a("div",ZD,[b.delta?(o(),N(i,{key:0,color:b.deltaColorVal,size:"x-small",variant:"tonal",density:"compact"},{default:t(()=>[n(v(b.delta),1)]),_:2},1032,["color"])):U("",!0)])]),_:2},1024)]),_:2},1024))),128))]),_:1})}}}),QD=Me(JD,[["__scopeId","data-v-aa83c8a4"]]),YD=Object.freeze(Object.defineProperty({__proto__:null,default:QD},Symbol.toStringTag,{value:"Module"})),XD={class:"stats-engagement-funnel"},eT={key:0,class:"d-flex flex-column align-center justify-center pa-8 text-center"},tT=Ae({__name:"StatsEngagementFunnel",props:{data:{}},setup(r){const $=Nt(()=>Lt(()=>import("./charts-tfNpfMZ7.js"),__vite__mapDeps([0,1,2,3]))),d=r,{baseOptions:c,getMetricColor:s}=jt(),m=se(()=>!d.data||!d.data.sent),u=se(()=>{var p,_,k,i,g;return[{name:"Funnel",data:[{x:"Gesendet",y:((p=d.data)==null?void 0:p.sent)??0},{x:"Zugestellt",y:((_=d.data)==null?void 0:_.delivered)??0},{x:"Geöffnet",y:((k=d.data)==null?void 0:k.opened)??0},{x:"Geklickt",y:((i=d.data)==null?void 0:i.clicked)??0},{x:"Meeting",y:((g=d.data)==null?void 0:g.meetings)??0}]}]}),f=se(()=>({...c.value,chart:{...c.value.chart,type:"bar"},plotOptions:{bar:{isFunnel:!0}},colors:[s("sent"),s("delivered"),s("opened"),s("clicked"),s("meeting")],dataLabels:{enabled:!0,formatter:(p,_)=>{var g,x;const k=(x=(g=_==null?void 0:_.w)==null?void 0:g.globals)==null?void 0:x.labels,i=(_==null?void 0:_.dataPointIndex)??0;return(k==null?void 0:k[i])??""},style:{colors:["#fff"],fontSize:"12px",fontFamily:"Lato, Arial, sans-serif"},dropShadow:{enabled:!1}},xaxis:{categories:["Gesendet","Zugestellt","Geöffnet","Geklickt","Meeting"],labels:{style:{colors:"#748686"}}},legend:{show:!1},tooltip:{theme:"dark",y:{formatter:p=>p.toLocaleString("de-DE")}}}));return(p,_)=>{const k=l("v-icon"),i=l("v-skeleton-loader");return o(),h("div",XD,[m.value?(o(),h("div",eT,[e(k,{size:"48",color:"medium-emphasis"},{default:t(()=>[..._[0]||(_[0]=[n("mdi-chart-timeline-variant",-1)])]),_:1}),_[1]||(_[1]=a("p",{class:"mt-2 text-medium-emphasis"},"Noch keine Statistiken verfügbar",-1)),_[2]||(_[2]=a("p",{class:"text-caption text-medium-emphasis"},"Daten erscheinen nach dem ersten Versand",-1))])):(o(),N(Tt,{key:1},{fallback:t(()=>[e(i,{type:"image",height:"300"})]),default:t(()=>[e(P($),{type:"bar",options:f.value,series:u.value,height:"300"},null,8,["options","series"])]),_:1}))])}}}),aT=Me(tT,[["__scopeId","data-v-eae6f67f"]]),lT=Object.freeze(Object.defineProperty({__proto__:null,default:aT},Symbol.toStringTag,{value:"Module"})),nT={class:"stats-time-series-chart"},oT={class:"d-flex align-center justify-space-between flex-wrap ga-2 mb-3 px-1"},sT={class:"d-flex ga-1"},iT={key:0,class:"d-flex flex-column align-center justify-center pa-8 text-center"},rT=Ae({__name:"StatsTimeSeriesChart",props:{timeSeries:{},campaignId:{}},setup(r){const $=Nt(()=>Lt(()=>import("./charts-tfNpfMZ7.js"),__vite__mapDeps([0,1,2,3]))),d=r,{baseOptions:c,getMetricColor:s}=jt(),m=Cl(),{period:u}=Ea(m),f=y(["opened","clicked","meetings"]),p=[{label:"24h",value:"24h"},{label:"7d",value:"7d"},{label:"30d",value:"30d"},{label:"90d",value:"90d"}],_=["24h","7d","30d","90d"];function k(E){return typeof E=="string"&&_.includes(E)}async function i(E){k(E)&&(ue.info("ADMIN","Stats period changed",{campaignId:d.campaignId,period:E}),await m.setPeriod(d.campaignId,E))}const g=[{label:"Geöffnet",value:"opened",color:s("opened")},{label:"Geklickt",value:"clicked",color:s("clicked")},{label:"Meetings",value:"meetings",color:s("meeting")}],x=se(()=>!d.timeSeries||d.timeSeries.length===0),w=se(()=>(d.timeSeries||[]).map(E=>{const R=new Date(E.bucket);return u.value==="24h"?R.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):R.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})})),b=se(()=>{const E={opened:{label:"Geöffnet",color:s("opened")},clicked:{label:"Geklickt",color:s("clicked")},meetings:{label:"Meetings",color:s("meeting")}};return f.value.map(R=>({name:E[R].label,color:E[R].color,data:(d.timeSeries||[]).map(M=>M[R]??0)}))}),I=se(()=>({...c.value,chart:{...c.value.chart,type:"area",animations:{enabled:!0,easing:"easeinout",speed:400}},stroke:{curve:"smooth",width:2},fill:{type:"gradient",gradient:{shadeIntensity:1,opacityFrom:.4,opacityTo:.05,stops:[0,95,100]}},xaxis:{categories:w.value,labels:{style:{colors:"#748686",fontSize:"11px"}},tickAmount:6},yaxis:{labels:{style:{colors:"#748686"},formatter:E=>Math.round(E).toString()},min:0},legend:{show:!0,labels:{colors:"#FFFFFF"}},tooltip:{theme:"dark",x:{format:"dd.MM.yyyy"}},colors:f.value.map(E=>({opened:s("opened"),clicked:s("clicked"),meetings:s("meeting")})[E])}));function V(E){const R=f.value.indexOf(E);R>=0?f.value.length>1&&f.value.splice(R,1):f.value.push(E)}return(E,R)=>{const M=l("v-btn"),T=l("v-btn-toggle"),D=l("v-chip"),H=l("v-icon"),O=l("v-skeleton-loader");return o(),h("div",nT,[a("div",oT,[e(T,{"model-value":P(u),density:"compact",color:"primary",variant:"outlined","onUpdate:modelValue":i},{default:t(()=>[(o(),h(be,null,Pe(p,S=>e(M,{key:S.value,value:S.value,size:"small"},{default:t(()=>[n(v(S.label),1)]),_:2},1032,["value"])),64))]),_:1},8,["model-value"]),a("div",sT,[(o(),h(be,null,Pe(g,S=>e(D,{key:S.value,color:f.value.includes(S.value)?S.color:"default",variant:f.value.includes(S.value)?"tonal":"outlined",size:"small",class:"cursor-pointer",onClick:B=>V(S.value)},{default:t(()=>[n(v(S.label),1)]),_:2},1032,["color","variant","onClick"])),64))])]),x.value?(o(),h("div",iT,[e(H,{size:"48",color:"medium-emphasis"},{default:t(()=>[...R[0]||(R[0]=[n("mdi-chart-timeline-variant",-1)])]),_:1}),R[1]||(R[1]=a("p",{class:"mt-2 text-medium-emphasis"},"Noch keine Zeitreihendaten verfügbar",-1))])):(o(),N(Tt,{key:1},{fallback:t(()=>[e(O,{type:"image",height:"280"})]),default:t(()=>[e(P($),{type:"area",options:I.value,series:b.value,height:"280"},null,8,["options","series"])]),_:1}))])}}}),dT=Me(rT,[["__scopeId","data-v-dcce1ab0"]]),uT=Object.freeze(Object.defineProperty({__proto__:null,default:dT},Symbol.toStringTag,{value:"Module"})),cT={class:"stats-idea-performance-table"},mT={key:0,class:"d-flex flex-column align-center justify-center pa-8 text-center"},vT={class:"text-caption font-weight-bold"},pT={class:"text-body-2",style:{"max-width":"260px",display:"block",overflow:"hidden","text-overflow":"ellipsis","white-space":"nowrap"}},fT=Ae({__name:"StatsIdeaPerformanceTable",props:{ideaPerformance:{}},setup(r){const $=r,{getMetricColor:d}=jt(),c=[{title:"Idea #",key:"ideaIndex",sortable:!0,width:"80px"},{title:"Betreff",key:"subject",sortable:!0},{title:"Topic",key:"topic",sortable:!0,width:"140px"},{title:"Gesendet",key:"sent",sortable:!0,width:"110px"},{title:"Open-Rate",key:"openRate",sortable:!0,width:"120px"},{title:"Click-Rate",key:"clickRate",sortable:!0,width:"120px"},{title:"Meeting-Rate",key:"meetingRate",sortable:!0,width:"130px"}],s=se(()=>$.ideaPerformance??[]),m=se(()=>s.value.length===0);function u(f){return(f*100).toFixed(1)+"%"}return(f,p)=>{const _=l("v-icon"),k=l("v-chip"),i=l("v-data-table");return o(),h("div",cT,[m.value?(o(),h("div",mT,[e(_,{size:"48",color:"medium-emphasis"},{default:t(()=>[...p[0]||(p[0]=[n("mdi-table-off",-1)])]),_:1}),p[1]||(p[1]=a("p",{class:"mt-2 text-medium-emphasis"},"Keine Idea-Performance-Daten verfügbar",-1))])):(o(),N(i,{key:1,headers:c,items:s.value,"items-per-page":10,density:"compact",class:"stats-idea-performance-table__table",hover:""},{"item.ideaIndex":t(({item:g})=>[a("span",vT," #"+v(g.ideaIndex+1),1)]),"item.subject":t(({item:g})=>[a("span",pT,v(g.subject||"–"),1)]),"item.topic":t(({item:g})=>[e(k,{size:"x-small",variant:"tonal",color:"primary"},{default:t(()=>[n(v(g.topic||"–"),1)]),_:2},1024)]),"item.openRate":t(({item:g})=>[a("span",{style:ht({color:P(d)("opened")})},v(u(g.openRate)),5)]),"item.clickRate":t(({item:g})=>[a("span",{style:ht({color:P(d)("clicked")})},v(u(g.clickRate)),5)]),"item.meetingRate":t(({item:g})=>[a("span",{style:ht({color:P(d)("meeting")})},v(u(g.meetingRate)),5)]),_:1},8,["items"]))])}}}),gT=Me(fT,[["__scopeId","data-v-6f067af8"]]),bT=Object.freeze(Object.defineProperty({__proto__:null,default:gT},Symbol.toStringTag,{value:"Module"})),yT={class:"stats-topic-leaderboard"},_T={key:0,class:"d-flex flex-column align-center justify-center pa-8 text-center"},kT={key:1,class:"text-caption text-medium-emphasis"},hT=Ae({__name:"StatsTopicLeaderboard",props:{topicPerformance:{}},setup(r){const $=r,{getMetricColor:d}=jt(),c=[{title:"#",key:"rank",sortable:!1,width:"52px"},{title:"Topic",key:"topic",sortable:!0},{title:"Gesendet",key:"sent",sortable:!0,width:"110px"},{title:"Open-Rate",key:"openRate",sortable:!0,width:"120px"},{title:"Click-Rate",key:"clickRate",sortable:!0,width:"120px"},{title:"Meeting-Rate",key:"meetingRate",sortable:!0,width:"130px"}],s=se(()=>[...$.topicPerformance??[]].sort((_,k)=>k.meetingRate-_.meetingRate)),m=se(()=>s.value.length===0);function u(_){return(_*100).toFixed(1)+"%"}const f={0:"#C9A063",1:"#9E9E9E",2:"#CD7F32"},p={0:"mdi-medal",1:"mdi-medal",2:"mdi-medal"};return(_,k)=>{const i=l("v-icon"),g=l("v-chip"),x=l("v-data-table");return o(),h("div",yT,[m.value?(o(),h("div",_T,[e(i,{size:"48",color:"medium-emphasis"},{default:t(()=>[...k[0]||(k[0]=[n("mdi-podium-gold",-1)])]),_:1}),k[1]||(k[1]=a("p",{class:"mt-2 text-medium-emphasis"},"Keine Topic-Daten verfügbar",-1))])):(o(),N(x,{key:1,headers:c,items:s.value,"items-per-page":10,density:"compact",class:"stats-topic-leaderboard__table",hover:""},{"item.rank":t(({index:w})=>[w<=2?(o(),N(i,{key:0,color:f[w],size:"18"},{default:t(()=>[n(v(p[w]),1)]),_:2},1032,["color"])):(o(),h("span",kT,v(w+1),1))]),"item.topic":t(({item:w})=>[e(g,{size:"x-small",variant:"tonal",color:"primary"},{default:t(()=>[n(v(w.topic||"–"),1)]),_:2},1024)]),"item.openRate":t(({item:w})=>[a("span",{style:ht({color:P(d)("opened")})},v(u(w.openRate)),5)]),"item.clickRate":t(({item:w})=>[a("span",{style:ht({color:P(d)("clicked")})},v(u(w.clickRate)),5)]),"item.meetingRate":t(({item:w})=>[a("span",{style:ht({color:P(d)("meeting")}),class:"font-weight-bold"},v(u(w.meetingRate)),5)]),_:1},8,["items"]))])}}}),xT=Me(hT,[["__scopeId","data-v-77082308"]]),wT=Object.freeze(Object.defineProperty({__proto__:null,default:xT},Symbol.toStringTag,{value:"Module"})),ST={class:"stats-lead-states-pie"},$T={key:0,class:"d-flex flex-column align-center justify-center pa-8 text-center"},CT=Ae({__name:"StatsLeadStatesPie",props:{leadStates:{}},setup(r){const $=Nt(()=>Lt(()=>import("./charts-tfNpfMZ7.js"),__vite__mapDeps([0,1,2,3]))),d=r,{BASEC_COLORS:c}=jt(),s={hot:"#E2F54B",warm:"#C9A063",cold:"#748686",stuck:"#CF6679","single-converter":"#0AC9D4","multi-converter":"#0AC9D4","power-lead":"#E2F54B",bounced:"#CF6679",unsubscribed:"#748686","awaiting-next-step":"#9E9E9E",active:"#0AC9D4"},m={hot:"Hot",warm:"Warm",cold:"Cold",stuck:"Stuck","single-converter":"Einmal konvertiert","multi-converter":"Mehrfach konvertiert","power-lead":"Power-Lead",bounced:"Bounced",unsubscribed:"Abgemeldet","awaiting-next-step":"Wartet auf nächsten Schritt",active:"Aktiv"},u=se(()=>d.leadStates?Object.entries(d.leadStates).filter(([,k])=>(k??0)>0).map(([k,i])=>({state:k,count:i??0})):[]),f=se(()=>u.value.length===0),p=se(()=>u.value.map(k=>k.count)),_=se(()=>({chart:{background:c.background,foreColor:c.text,fontFamily:"Lato, Arial, sans-serif",toolbar:{show:!1}},theme:{mode:"dark"},labels:u.value.map(k=>m[k.state]??k.state),colors:u.value.map(k=>s[k.state]??c.primary),legend:{position:"bottom",labels:{colors:c.text},fontSize:"12px",fontFamily:"Lato, Arial, sans-serif"},dataLabels:{enabled:!0,formatter:k=>k.toFixed(1)+"%",style:{colors:["#fff"],fontSize:"11px"},dropShadow:{enabled:!1}},tooltip:{theme:"dark",y:{formatter:k=>k.toLocaleString("de-DE")}},plotOptions:{pie:{donut:{size:"65%",labels:{show:!0,total:{show:!0,label:"Gesamt",color:c.text,formatter:k=>k.globals.seriesTotals.reduce((i,g)=>i+g,0).toLocaleString("de-DE")}}}}}}));return(k,i)=>{const g=l("v-icon"),x=l("v-skeleton-loader");return o(),h("div",ST,[f.value?(o(),h("div",$T,[e(g,{size:"48",color:"medium-emphasis"},{default:t(()=>[...i[0]||(i[0]=[n("mdi-chart-donut",-1)])]),_:1}),i[1]||(i[1]=a("p",{class:"mt-2 text-medium-emphasis"},"Keine Engagement-State-Daten verfügbar",-1))])):(o(),N(Tt,{key:1},{fallback:t(()=>[e(x,{type:"image",height:"300"})]),default:t(()=>[e(P($),{type:"donut",options:_.value,series:p.value,height:"300"},null,8,["options","series"])]),_:1}))])}}}),VT=Me(CT,[["__scopeId","data-v-829fa6c1"]]),AT=Object.freeze(Object.defineProperty({__proto__:null,default:VT},Symbol.toStringTag,{value:"Module"})),IT={class:"stats-send-heatmap"},PT={key:0,class:"d-flex flex-column align-center justify-center pa-8 text-center"},zT=Ae({__name:"StatsSendHeatmap",props:{sendHeatmap:{}},setup(r){const $=Nt(()=>Lt(()=>import("./charts-tfNpfMZ7.js"),__vite__mapDeps([0,1,2,3]))),d=r,{BASEC_COLORS:c}=jt(),s=["So","Mo","Di","Mi","Do","Fr","Sa"],m=Array.from({length:24},(_,k)=>`${k}:00`),u=se(()=>!d.sendHeatmap||d.sendHeatmap.length===0),f=se(()=>{const _={};for(let k=0;k<7;k++){_[k]={};for(let i=0;i<24;i++)_[k][i]=0}return(d.sendHeatmap??[]).forEach(k=>{_[k.dayOfWeek]&&(_[k.dayOfWeek][k.hourOfDay]=(_[k.dayOfWeek][k.hourOfDay]??0)+k.sent)}),s.map((k,i)=>({name:k,data:m.map((g,x)=>({x:g,y:_[i][x]??0}))}))}),p=se(()=>({chart:{background:c.background,foreColor:c.text,fontFamily:"Lato, Arial, sans-serif",toolbar:{show:!1},type:"heatmap"},theme:{mode:"dark"},dataLabels:{enabled:!1},colors:[c.primary],plotOptions:{heatmap:{colorScale:{ranges:[{from:0,to:0,color:"#1a1a1a",name:"0"},{from:1,to:5,color:"#0a4a4d",name:"1-5"},{from:6,to:20,color:"#067a80",name:"6-20"},{from:21,to:50,color:"#0ac9d4",name:"21-50"},{from:51,to:99999,color:"#E2F54B",name:"50+"}]}}},xaxis:{labels:{style:{colors:"#748686",fontSize:"10px"},rotate:-45},tickAmount:8},yaxis:{labels:{style:{colors:"#748686",fontSize:"11px"}}},tooltip:{theme:"dark",y:{formatter:_=>`${_} gesendet`}},legend:{show:!1},grid:{borderColor:"rgba(255,255,255,0.05)"}}));return(_,k)=>{const i=l("v-icon"),g=l("v-skeleton-loader");return o(),h("div",IT,[k[2]||(k[2]=a("div",{class:"text-caption text-medium-emphasis mb-2 px-1"}," Sendezeiten nach UTC – Wochentag × Stunde ",-1)),u.value?(o(),h("div",PT,[e(i,{size:"48",color:"medium-emphasis"},{default:t(()=>[...k[0]||(k[0]=[n("mdi-grid",-1)])]),_:1}),k[1]||(k[1]=a("p",{class:"mt-2 text-medium-emphasis"},"Keine Heatmap-Daten verfügbar",-1))])):(o(),N(Tt,{key:1},{fallback:t(()=>[e(g,{type:"image",height:"260"})]),default:t(()=>[e(P($),{type:"heatmap",options:p.value,series:f.value,height:"260"},null,8,["options","series"])]),_:1}))])}}}),DT=Me(zT,[["__scopeId","data-v-c8531a62"]]),TT=Object.freeze(Object.defineProperty({__proto__:null,default:DT},Symbol.toStringTag,{value:"Module"})),LT={class:"stats-cohort-table"},ET={class:"d-flex align-center gap-3 mb-3 px-1"},MT={key:0,class:"d-flex flex-column align-center justify-center pa-8 text-center"},NT={class:"mt-2 text-medium-emphasis"},UT={class:"text-body-2 font-weight-medium"},BT={class:"text-body-2"},FT={class:"text-body-2"},OT={class:"text-body-2"},RT={class:"text-body-2"},KT={class:"text-body-2"},jT=Ae({__name:"StatsCohortTable",props:{cohortsBySignupWeek:{},cohortsByUtmSource:{},cohortsByLeadSourceType:{},cohortsByLandingPage:{}},setup(r){const $=r,{getMetricColor:d}=jt(),c=y("signupWeek"),s=[{label:"Signup-Woche",value:"signupWeek"},{label:"UTM-Source",value:"utmSource"},{label:"Lead-Quelle",value:"sourceType"},{label:"Landing-Page",value:"landingPage"}],m=se(()=>{var i;return((i=s.find(g=>g.value===c.value))==null?void 0:i.label)??""}),u=se(()=>{switch(c.value){case"signupWeek":return $.cohortsBySignupWeek??[];case"utmSource":return $.cohortsByUtmSource??[];case"sourceType":return $.cohortsByLeadSourceType??[];case"landingPage":return $.cohortsByLandingPage??[];default:return[]}}),f=se(()=>u.value.length===0),p=se(()=>[{title:m.value,key:"key",sortable:!0},{title:"Leads",key:"leadsCount",sortable:!0,width:"80px"},{title:"Gesendet",key:"sent",sortable:!0,width:"90px"},{title:"Geöffnet",key:"opened",sortable:!0,width:"90px"},{title:"Geklickt",key:"clicked",sortable:!0,width:"90px"},{title:"Open-Rate",key:"openRate",sortable:!0,width:"105px"},{title:"Click-Rate",key:"clickRate",sortable:!0,width:"105px"},{title:"Meetings",key:"meetings",sortable:!0,width:"90px"},{title:"Meeting-Rate",key:"meetingRate",sortable:!0,width:"120px"}]);function _(i){return i==null||Number.isNaN(i)?"–":(i*100).toFixed(1)+"%"}function k(i){return i==null||Number.isNaN(i)?"–":i.toLocaleString("de-DE")}return(i,g)=>{const x=l("v-select"),w=l("v-icon"),b=l("v-data-table");return o(),h("div",LT,[a("div",ET,[g[1]||(g[1]=a("span",{class:"text-caption text-medium-emphasis"},"Dimension:",-1)),e(x,{modelValue:c.value,"onUpdate:modelValue":g[0]||(g[0]=I=>c.value=I),items:s,"item-title":"label","item-value":"value",density:"compact",variant:"outlined","hide-details":"",style:{"max-width":"220px"}},null,8,["modelValue"])]),f.value?(o(),h("div",MT,[e(w,{size:"48",color:"medium-emphasis"},{default:t(()=>[...g[2]||(g[2]=[n("mdi-table-off",-1)])]),_:1}),a("p",NT,'Keine Kohorten-Daten für "'+v(m.value)+'"',1)])):(o(),N(b,{key:1,headers:p.value,items:u.value,"items-per-page":10,density:"compact",class:"stats-cohort-table__table",hover:""},{"item.key":t(({item:I})=>[a("span",UT,v(I.key||"–"),1)]),"item.leadsCount":t(({item:I})=>[a("span",BT,v(k(I.leadsCount)),1)]),"item.sent":t(({item:I})=>[a("span",FT,v(k(I.sent)),1)]),"item.opened":t(({item:I})=>[a("span",OT,v(k(I.opened)),1)]),"item.clicked":t(({item:I})=>[a("span",RT,v(k(I.clicked)),1)]),"item.openRate":t(({item:I})=>[a("span",{style:ht({color:P(d)("opened")})},v(_(I.openRate)),5)]),"item.clickRate":t(({item:I})=>[a("span",{style:ht({color:P(d)("clicked")})},v(_(I.clickRate)),5)]),"item.meetings":t(({item:I})=>[a("span",KT,v(k(I.meetings)),1)]),"item.meetingRate":t(({item:I})=>[a("span",{style:ht({color:P(d)("meeting")}),class:"font-weight-bold"},v(_(I.meetingRate)),5)]),_:1},8,["headers","items"]))])}}}),qT=Me(jT,[["__scopeId","data-v-836ea9c8"]]),GT=Object.freeze(Object.defineProperty({__proto__:null,default:qT},Symbol.toStringTag,{value:"Module"})),HT={class:"stats-leads-in-campaign-table"},WT={key:0,class:"d-flex flex-column align-center justify-center pa-8 text-center"},ZT={class:"text-body-2"},JT={class:"text-caption text-medium-emphasis"},QT={class:"text-caption"},YT={class:"text-caption text-medium-emphasis"},XT=Ae({__name:"StatsLeadsInCampaignTable",props:{leads:{}},setup(r){const $=r,d=xt(),{BASEC_COLORS:c}=jt(),s=[{title:"Name",key:"name",sortable:!0},{title:"E-Mail",key:"email",sortable:!0},{title:"Status",key:"engagementState",sortable:!0,width:"160px"},{title:"Schritt",key:"step",sortable:!1,width:"100px"},{title:"Letzte Aktivität",key:"lastActivity",sortable:!0,width:"180px"},{title:"",key:"actions",sortable:!1,width:"60px"}],m={hot:c.highlight,warm:c.accent,cold:c.subtitle,stuck:c.error,"single-converter":c.primary,"multi-converter":c.primary,"power-lead":c.highlight,bounced:c.error,unsubscribed:c.subtitle,"awaiting-next-step":c.subtitle,active:c.primary,completed:c.primary,paused:c.accent,awaiting:c.subtitle},u={hot:"Hot",warm:"Warm",cold:"Cold",stuck:"Stuck","single-converter":"1x konvertiert","multi-converter":"Multi-Converter","power-lead":"Power-Lead",bounced:"Bounced",unsubscribed:"Abgemeldet","awaiting-next-step":"Wartet",active:"Aktiv",completed:"Abgeschlossen",paused:"Pausiert",awaiting:"Wartet"},f=se(()=>$.leads??[]),p=se(()=>f.value.length===0);function _(w){return w?m[w]??c.primary:c.subtitle}function k(w){return w?u[w]??w:"–"}function i(w){var E,R;const b=((E=w.firstName)==null?void 0:E.trim())??"",I=((R=w.lastName)==null?void 0:R.trim())??"",V=`${b} ${I}`.trim();return V.length>0?V:"–"}function g(w){if(!w)return"–";const b=new Date(w);return Number.isNaN(b.getTime())?"–":b.toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}function x(w){d.push({name:"admin-lead-detail",params:{id:w}})}return(w,b)=>{const I=l("v-icon"),V=l("v-chip"),E=l("v-btn"),R=l("v-data-table");return o(),h("div",HT,[p.value?(o(),h("div",WT,[e(I,{size:"48",color:"medium-emphasis"},{default:t(()=>[...b[0]||(b[0]=[n("mdi-account-group-outline",-1)])]),_:1}),b[1]||(b[1]=a("p",{class:"mt-2 text-medium-emphasis"},"Noch keine Leads in dieser Kampagne",-1))])):(o(),N(R,{key:1,headers:s,items:f.value,"items-per-page":15,density:"compact",class:"stats-leads-in-campaign-table__table",hover:""},{"item.name":t(({item:M})=>[a("span",ZT,v(i(M)),1)]),"item.email":t(({item:M})=>[a("span",JT,v(M.email),1)]),"item.engagementState":t(({item:M})=>[e(V,{size:"x-small",color:_(M.engagementState),variant:"tonal"},{default:t(()=>[n(v(k(M.engagementState)),1)]),_:2},1032,["color"])]),"item.step":t(({item:M})=>[a("span",QT,v(M.currentStep)+"/"+v(M.totalSteps),1)]),"item.lastActivity":t(({item:M})=>[a("span",YT,v(g(M.lastActivity)),1)]),"item.actions":t(({item:M})=>[e(E,{icon:"",variant:"text",size:"x-small",onClick:dt(T=>x(M.leadId),["stop"])},{default:t(()=>[e(I,{size:"16"},{default:t(()=>[...b[2]||(b[2]=[n("mdi-open-in-new",-1)])]),_:1})]),_:1},8,["onClick"])]),_:1},8,["items"]))])}}}),e6=Me(XT,[["__scopeId","data-v-71870c1b"]]),t6=Object.freeze(Object.defineProperty({__proto__:null,default:e6},Symbol.toStringTag,{value:"Module"}));export{d6 as A,U6 as B,p6 as C,u6 as D,C6 as E,o6 as F,F6 as G,O6 as H,B6 as I,R6 as J,g6 as K,ue as L,D6 as M,K6 as N,j6 as O,c6 as P,q6 as Q,r6 as R,P6 as S,v6 as U,Lt as _,re as a,Me as b,Gl as c,s6 as d,i6 as e,m6 as f,f6 as g,b6 as h,y6 as i,_6 as j,k6 as k,h6 as l,x6 as m,w6 as n,S6 as o,$6 as p,V6 as q,A6 as r,I6 as s,z6 as t,ea as u,T6 as v,L6 as w,E6 as x,M6 as y,N6 as z};