1import{ai as is,r as i,cy as g,z as u,j as e,x as T,B as m,S as X,f as ds,a8 as A,au as D,L as H}from"./index-CggIIFzo.js";import{D as Ye}from"./DashboardLayout-B2n0xEJl.js";import{I as os}from"./input-Drr0lrPm.js";import{T as cs}from"./textarea-BJIvlQj2.js";import{R as us}from"./refresh-cw-Djg3HbAe.js";import{T as ee}from"./target-Bq5Kr1dI.js";import{R as ms}from"./radar-DyoQirwI.js";import{C as xs}from"./clipboard-list-H3cwCn6F.js";import{C as De}from"./chevron-down-BCaOraiY.js";import"./progress-pf28ssF7.js";import"./ThemeToggle-CL-3-2JG.js";import"./DashboardV2Shell-nxzUZYx_.js";import"./dialog-BA4B4Nlh.js";import"./index-Bj8o7Yn4.js";import"./search-BuhGhL7b.js";import"./triangle-alert-DRoHRyAt.js";import"./menu-D7P1yxSX.js";import"./settings-2-Cz9APQWa.js";import"./wissensbasis-BzK7G1Di.js";import"./onboardingSession-BeccaTNX.js";import"./user-plus-CAkZBYuk.js";import"./wand-sparkles-C6m3ooR7.js";import"./sliders-horizontal-BM9MD3As.js";import"./chart-column-C9BOi9Hm.js";import"./circle-alert-W59jii8g.js";import"./clock-DdTvvi3r.js";function hs(n){return n.actionable!==!1&&n.status==="open"&&n.evidence_status==="active"}function ps(n,l){return l==="all"||n===l||n==="both"&&(l==="seo"||l==="aeo")}const Je={pending:"Ausstehend",running:"Läuft",completed:"Abgeschlossen",insufficient_data:"Daten unzureichend",failed:"Fehlgeschlagen"},gs={open:"Offen",planned:"Geplant",in_progress:"In Arbeit",reported:"Umsetzung gemeldet",verified:"Umsetzung bestätigt",done:"Umgesetzt",resolved:"Erledigt",later:"Später",monitoring:"Beobachten",dismissed:"Verworfen"},fs={not_measurable:"Noch nicht messbar",improved:"Verbesserung beobachtet",no_clear_change:"Keine klare Veränderung",worsened:"Verschlechterung beobachtet"},Xe={high:"Hohe Sicherheit",medium:"Mittlere Sicherheit",low:"Niedrige Sicherheit",insufficient:"Prüfung erforderlich"},es={critical:"Kritisch",high:"Hoch",medium:"Mittel",low:"Niedrig"},ss={seo:"SEO",aeo:"AEO",both:"Beides",technical:"Technik"},bs=[{id:"empfehlungen",label:"Empfehlungen",hint:"Was als Nächstes",icon:X},{id:"zielthemen",label:"Themen",hint:"Nachfrage & Chancen",icon:ee},{id:"ergebnisse",label:"Ergebnisse",hint:"Umsetzung & Messung",icon:ds}];function _(n){if(!n)return"â";const l=new Date(n);return Number.isNaN(l.getTime())?"â":new Intl.DateTimeFormat("de-DE",{dateStyle:"medium",timeStyle:"short"}).format(l)}function se(n){return n.filter_domain?n.filter_domain:n.action_type==="technical_blocker"||n.module_key==="compliance"?"technical":n.module_key==="seo_radar"||n.module_key==="seitengesundheit"?"seo":n.module_key==="ai_visibility"?"aeo":"both"}function ns(n){const l=n.implementation_plan&&typeof n.implementation_plan=="object"?n.implementation_plan:{};return{title:l.title||n.title,target:l.target||void 0,evidence:l.evidence||n.detected,gap:l.gap||n.summary||n.explanation,action:l.action||n.next_step,help:l.help||"Entwurf oder Aufgabe aus dieser Empfehlung ableiten.",measure:l.measure||"Vergleichbare Folgeperiode nach bestätigter Umsetzung.",verification:l.verification||"Veröffentlichung bestätigen, bevor du spätere Messungen bewertest."}}function E({children:n,tone:l="muted"}){return e.jsx("span",{className:A("inline-flex items-center rounded-full border px-2 py-0.5 text-[11px] font-medium",l==="primary"&&"border-primary/25 bg-primary/10 text-primary dark:text-violet-300",l==="warn"&&"border-amber-500/30 bg-amber-500/10 text-amber-800 dark:text-amber-200",l==="muted"&&"border-border bg-muted/40 text-muted-foreground"),children:n})}function J({item:n,open:l,busy:t,followup:y,onToggle:Z,onFollowupChange:L,onAsk:x,onCreateTask:k,onCreateDraft:B,onSetStatus:c,onFeedback:h,onSaveDraft:v}){var W,N,I,r,O,P,M,V;const[j,S]=i.useState(n.draft_content||"");i.useEffect(()=>S(n.draft_content||""),[n.draft_content]);const p=ns(n),z=n.confidence==="low"||n.confidence==="insufficient",w=n.impact_potential||n.priority,K=se(n),C=["reported","verified","done","resolved"].includes(n.status),Q=n.recommendation_kind==="problem"?"Problem beheben":n.recommendation_kind==="opportunity"?"Wachstumschance":"Prüfung erforderlich",F=/snippet|title|meta/.test(n.action_type||"")?"Titel entwerfen":/comparison|vergleich/.test(n.action_type||"")?"Vergleich entwerfen":/product|spec|katalog/.test(n.action_type||"")?"Produkttext ergänzen":"Entwurf er
1stellen";return e.jsxs("li",{className:A("border-b border-border/70 last:border-b-0",l&&"bg-muted/20"),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("input",{type:"checkbox",className:"mt-5 h-5 w-5 shrink-0 accent-emerald-600","aria-label":`Umsetzung melden: ${n.title}`,checked:C,disabled:t,onChange:()=>c(C?"open":"reported")}),e.jsxs("button",{type:"button","aria-expanded":l,className:"flex w-full items-start gap-3 px-1 py-3.5 text-left transition-colors hover:bg-muted/30 sm:px-2",onClick:Z,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(E,{tone:w==="critical"||w==="high"?"primary":"muted",children:es[w]}),e.jsx(E,{children:ss[K]}),e.jsx(E,{tone:n.recommendation_kind==="opportunity"?"primary":"muted",children:Q}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Xe[n.confidence]})]}),e.jsx("p",{className:"mt-1.5 text-sm font-semibold tracking-tight text-foreground",children:n.title}),e.jsx("p",{className:"mt-1 line-clamp-2 text-[12px] leading-relaxed text-muted-foreground",children:p.gap||n.explanation}),e.jsx("p",{className:"mt-2 text-sm text-foreground",children:n.next_step}),Array.isArray(n.affected_urls)&&n.affected_urls.length>0?e.jsx("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:n.affected_urls.join(" · ")}):null,e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:[gs[n.status]," · ",((W=n.evidence)==null?void 0:W.length)||0," Nachweise · Stand"," ",_(n.data_fresh_at),(N=n.source_metrics)!=null&&N.sampleSize?` · Stichprobe: ${n.source_metrics.sampleSize}`:""]})]}),e.jsx(De,{className:A("mt-1 h-4 w-4 shrink-0 text-muted-foreground transition-transform",l&&"rotate-180")})]})]}),l?e.jsxs("div",{className:"space-y-4 border-t border-border/60 px-1 pb-4 pt-3 sm:px-2",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:[["Was wurde erkannt?",p.gap||p.evidence||n.detected],["Was solltest du ändern?",p.action||n.next_step],["Wie setzt du es um?",p.help||((I=n.recommended_actions)==null?void 0:I[0])||p.action],["Wie prüfen wir das?",p.verification||p.measure]].filter(([,o])=>!!o).map(([o,f])=>e.jsxs("div",{className:"rounded-xl border border-border/70 bg-card px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:o}),e.jsx("p",{className:"mt-1 whitespace-pre-line text-sm leading-relaxed text-foreground",children:f})]},o))}),p.target?e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Ziel: ",e.jsx("span",{className:"text-foreground",children:p.target}),z?` · ${Xe[n.confidence]}`:null]}):null,C?e.jsxs("p",{className:"rounded-xl bg-muted/40 p-3 text-sm text-muted-foreground",children:[fs[n.outcome_status||"not_measurable"],". Abhaken meldet deine Umsetzung; eine bestätigte Veröffentlichung und vergleichbare Folgemessungen sind getrennte Nachweise. Eine spätere Verbesserung belegt keine Ursache.",(r=n.outcome_detail)!=null&&r.note?e.jsx("span",{className:"mt-2 block",children:n.outcome_detail.note}):null,((O=n.outcome_detail)==null?void 0:O.before)!=null&&((P=n.outcome_detail)==null?void 0:P.after)!=null?e.jsxs("span",{className:"mt-1 block",children:[n.outcome_detail.metric,": ",n.outcome_detail.before," â"," ",n.outcome_detail.after]}):null]}):null,(M=n.evidence)!=null&&M.length?e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:n.evidence.map(o=>o.href?e.jsxs(H,{to:o.href,className:"block rounded-xl border border-border bg-muted/30 p-3 text-sm text-foreground hover:bg-muted/60",children:[e.jsxs("span",{className:"font-medium",children:[o.label," â"]}),e.jsx("span",{className:"mt-1 block text-xs text-muted-foreground",children:o.detail}),e.jsx("span",{className:"mt-1 block text-xs text-muted-foreground",children:_(o.measuredAt)})]},o.id):e.jsx("span",{className:"rounded-[10px] border border-border bg-muted/30 px-2.5 py-1 text-[11px] text-muted-foreground",children:o.label},o.id))}):null,n.draft_content?e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",htmlFor:`draft-${n.id}`,children:"Entwurf · vor Veröffentlichung prüfen"}),e.jsx(cs,{id:`draft-${n.id}`,value:j,onChange:o=>S(o.target.value),className:"min-h-48 rounded-xl",disabled:t}),e.jsx(m,{size:"sm",className:"h-8 rounded-[10px] px-3 text-xs",variant:"outline",disabled:t||!j.trim()||j===n.draft_content,onClick:()=>v(j),children:"Entwurf speichern"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Wird nur hier gespeichert, nicht auf deiner Website veröffentlicht."})]}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(m,{size:"sm",className:"h-8 rounded-[10px] px-3 text-xs",disabled:t,onClick:B,children:F}),e.jsx(m,{size:"sm",variant:"outline",className:"h-8 rounded-[10px] px-3 text-xs",disabled:t,onClick:k,children:n.task_improvement_id?"Aufgabe vorhanden":"Als Aufgabe speichern"}),e.jsx(m,{size:"sm",variant:"outline",className:"h-8 rounded-[10px] px-3 text-xs",disabled:t,onClick:()=>c("reported"),children:"Umsetzung melden"}),e.jsx(m,{size:"sm",variant:"ghost",className:"h-8 rounded-[10px] px-3 text-xs",disabled:t,onClick:()=>c("planned"),children:"Geplant"}),e.jsx(m,{size:"sm",variant:"ghost",className:"h-8 rounded-[10px] px-3 text-xs",disabled:t,onClick:()=>c("in_progress"),children:"In Arbeit"}),n.deep_link?e.jsx(m,{asChild:!0,size:"sm",variant:"ghost",className:"h-8 rounded-[10px] px-3 text-xs",children:e.jsxs(H,{to:n.deep_link,children:["Nachweis ansehen",e.jsx(D,{className:"ml-1 h-3.5 w-3.5"})]})}):null]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-border/60 pt-3",children:[e.jsx(os,{value:y,onChange:o=>L(o.target.value),placeholder:"Nachfrage zu diesem Planâ¦",className:"h-8 max-w-sm rounded-[10px] text-sm"}),e.jsx(m,{size:"sm",variant:"secondary",className:"h-8 rounded-[10px] px-3 text-xs",disabled:t||!y.trim(),onClick:x,children:"Fragen"}),e.jsx("button",{type:"button",className:"ml-auto text-[11px] text-muted-foreground hover:text-foreground",disabled:t,onClick:()=>h({feedback:"helpful"}),children:"Hilfreich"}),e.jsx("button",{type:"button",className:"text-[11px] text-muted-foreground hover:text-foreground",disabled:t,onClick:()=>h({dismissReason:"not_relevant"}),children:"Nicht relevant"})]}),(V=n.limitations)!=null&&V.length?e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:n.limitations.slice(0,2).join(" ")}):null]}):null]})}function $s(){var ie,de,oe,ce,ue,me,xe,he,pe,ge,fe,be,je,Ne,ye,ke,ve,we,_e,Ae,Ee,Se,ze,Ce,Te,
1Le,Be,Fe,Ie,Oe,Me,Ue,qe,Ke,We,Pe,Ve,Re,$e,Ge,He,Ze,Qe;const{customerId:n,loading:l}=is(),[t,y]=i.useState(null),[Z,L]=i.useState(!0),[x,k]=i.useState(!1),[B,c]=i.useState(null),[h,v]=i.useState("empfehlungen"),[j,S]=i.useState("all"),[p,z]=i.useState(null),[w,K]=i.useState(""),[C,Q]=i.useState(!1),[F,W]=i.useState([]),[N,I]=i.useState(null),[r,O]=i.useState(null),[P,M]=i.useState(!1),[V,o]=i.useState(!1),f=i.useCallback(async()=>{if(n)try{const s=await g(n,"overview");y(s),k(!!s.analyzing)}catch(s){u.error(s instanceof Error?s.message:"Berater konnte nicht geladen werden.")}finally{L(!1)}},[n]);i.useEffect(()=>{L(!0),y(null),f()},[f]),i.useEffect(()=>{if(!n||!x)return;let s=!1;const a=setInterval(()=>{g(n,"overview").then(d=>{var G;s||(y(d),k(d.analyzing),!d.analyzing&&((G=d.latestAnalysis)==null?void 0:G.status)==="completed"&&u.success("Empfehlungen aktualisiert."))}).catch(()=>{})},4e3);return()=>{s=!0,clearInterval(a)}},[n,x]),i.useEffect(()=>{if(!n||l)return;let s=!1;return g(n,"ensure_fresh").then(a=>{s||(y(a),k(!!a.analyzing),L(!1))}).catch(a=>{s||u.error(a instanceof Error?a.message:"Automatische Aktualisierung konnte nicht gestartet werden.")}),()=>{s=!0}},[n,l]);const U=i.useCallback(async()=>{var s,a;if(n){M(!0);try{const d=await g(n,"topics.list");W(d.topics??[]),!N&&((a=(s=d.topics)==null?void 0:s[0])!=null&&a.id)&&I(d.topics[0].id)}catch(d){u.error(d instanceof Error?d.message:"Zielthemen konnten nicht geladen werden.")}finally{M(!1)}}},[n,N]);i.useEffect(()=>{h==="zielthemen"&&U()},[h,U]),i.useEffect(()=>{!x&&h==="zielthemen"&&U()},[x,h,U]),i.useEffect(()=>{if(!n||!N||h!=="zielthemen")return;let s=!1;return o(!0),g(n,"topics.get",{topicId:N}).then(a=>{s||O(a)}).catch(()=>{s||O(null)}).finally(()=>{s||o(!1)}),()=>{s=!0}},[n,N,h,x,F]);const ne=async()=>{if(n){k(!0);try{const s=await g(n,"analyze");y(s),k(s.analyzing),u.success(s.analyzing?"Themenanalyse gestartet â Fortschritt aktualisiert sich automatisch.":"Themenanalyse ist aktuell."),h==="zielthemen"&&await U()}catch(s){u.error(s instanceof Error?s.message:"Analyse fehlgeschlagen.")}finally{await f()}}},ts=async(s,a)=>{if(n){c(s);try{await g(n,"set_status",{suggestionId:s,status:a}),await f()}catch(d){u.error(d instanceof Error?d.message:"Status konnte nicht geändert werden.")}finally{c(null)}}},te=async s=>{if(n){c(s);try{const a=await g(n,"create_task",{suggestionId:s});u.success(a.existing?"Aufgabe war bereits vorhanden.":"Als Aufgabe in KI verbessern angelegt."),await f()}catch(a){u.error(a instanceof Error?a.message:"Aufgabe konnte nicht erstellt werden.")}finally{c(null)}}},re=async s=>{if(n){c(s);try{await g(n,"create_draft",{suggestionId:s,kind:"knowledge_answer"}),u.success("Entwurf erstellt â bitte vor Veröffentlichung prüfen."),await f(),z(s)}catch(a){u.error(a instanceof Error?a.message:"Entwurf fehlgeschlagen.")}finally{c(null)}}},rs=async(s,a)=>{if(n){c(s);try{await g(n,"save_draft",{suggestionId:s,content:a}),u.success("Entwurf gespeichert."),await f()}catch(d){u.error(d instanceof Error?d.message:"Speichern fehlgeschlagen.")}finally{c(null)}}},as=async s=>{if(!(!n||!w.trim())){c(s);try{const a=await g(n,"ask_followup",{suggestionId:s,question:w.trim()});u.message("Antwort",{description:a.followup.answer}),K("")}catch(a){u.error(a instanceof Error?a.message:"Nachfrage fehlgeschlagen.")}finally{c(null)}}},ls=async(s,a)=>{if(n){c(s);try{await g(n,"feedback",{suggestionId:s,...a}),u.success("Feedback gespeichert"),await f()}catch(d){u.error(d instanceof Error?d.message:"Feedback fehlgeschlagen.")}finally{c(null)}}},q=i.useMemo(()=>((t==null?void 0:t.suggestions)??[]).filter(a=>hs(a)&&ps(se(a),j)),[t==null?void 0:t.suggestions,j]),R=i.useMemo(()=>((t==null?void 0:t.suggestions)??[]).filter(a=>["planned","in_progress","reported","verified","monitoring","done","resolved"].includes(a.status)),[t==null?void 0:t.suggestions]),$=i.useMemo(()=>{const s=R;return{planned:s.filter(a=>a.status==="planned").length,inProgress:s.filter(a=>a.status==="in_progress").length,done:s.filter(a=>["reported","verified","done","resolved"].includes(a.status)).length,monitoring:s.filter(a=>a.status==="monitoring").length}},[R]);if(l||Z)return e.jsx(Ye,{children:e.jsxs("div",{className:"dashboard-home flex min-h-[40vh] items-center justify-center gap-2 text-sm text-muted-foreground",children:[e.jsx(T,{className:"h-4 w-4 animate-spin"}),"ShopFlare Berater wird geladenâ¦"]})});const b=q[0],ae=q.slice(0,3),le=(s,a=1)=>s<=0?"empty":s>=a?"warn":"ok",Y=s=>({open:p===s.id,busy:B===s.id||(t==null?void 0:t.canManage)===!1,followup:p===s.id?w:"",onToggle:()=>z(p===s.id?null:s.id),onFollowupChange:K,onAsk:()=>void as(s.id),onCreateTask:()=>void te(s.id),onCreateDraft:()=>void re(s.id),onSaveDraft:a=>void rs(s.id,a),onSetStatus:a=>void ts(s.id,a),onFeedback:a=>void ls(s.id,a)});return e.jsx(Ye,{children:e.jsxs("div",{className:"dashboard-home space-y-5",children:[e.jsxs("div",{className:"dashboard-page-header flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"dashboard-page-eyebrow",children:"Live-Arbeitsbereich"}),e.jsx("h1",{className:"text-2xl font-bold tracking-tight text-[#1f1f1f] dark:text-foreground",children:"ShopFlare Berater"}),e.jsx("p",{className:"text-muted-foreground",children:"Ergebnisse und nächste Schritte aus deinen aktiven Modulen â mit Nachweis und Entwurf."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"dashboard-cockpit-live",children:x?"Analyse läuft":`Wöchentlich · nächste ${_((ie=t==null?void 0:t.schedule)==null?void 0:ie.next_run_at)}`}),e.jsxs(m,{size:"sm",className:"h-9 shrink-0 rounded-[10px] px-4 text-xs",onClick:()=>void ne(),disabled:x||(t==null?void 0:t.canManage)===!1,children:[x?e.jsx(T,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(us,{className:"mr-1.5 h-3.5 w-3.5"}),x?"Analysiereâ¦":"Neu analysieren"]})]})]}),e.jsx("section",{className:"dashboard-cockpit-kpis","aria-label":"Berater-Kennzahlen",tabIndex:0,children:[{key:"open",module:"Empfehlungen",metric:"Offen",value:(t==null?void 0:t.counts.open)??0,tone:le((t==null?void 0:t.counts.open)??0),onClick:()=>v("empfehlungen")},{key:"high",module:"Priorität",metric:"Hoch / kritisch",value:(t==null?void 0:t.counts.highPriority)??0,tone:le((t==null?void 0:t.counts.highPriority)??0),onClick:()=>{v("empfehlungen"),S("all")}},{key:"quick",module:"Umsetzung",metric:"Schnell umsetzbar",value:(t==null?void 0:t.counts.quickWins)??0,tone:((t==null?void 0:t.counts.quickWins)??0)>0?"ok":"empty",onClick:()=>v("empfehlungen")},{key:"done",module:"Ergebnisse",metric:"Umgesetzt",value:(t==null?void 0:t.counts.done)??0,tone:((t==null?void 0:t.counts.done)??0)>0?"ok":"neutral",onClick:()=>v("ergebnisse")}].map(s=>e.jsxs("button",{type:"button",onClick:s.onClick,className:`dashboard-cockpit-kpi dashboard-cockpit-kpi--${s.tone}`,children:[e.jsxs("span",{className:"dashboard-cockpit-kpi-top",children:[e.jsx("span",{className:"dashboard-cockpit-kpi-module",children:s.module}),e.jsx("span",{className:"dashboard-cockpit-kpi-tone","aria-hidden":!0})]}),e.jsx("span",{className:"dashboard-cockpit-kpi-metric",children:s.metric}),e.jsx("strong",{className:"dashboard-cockpit-kpi-value",children:s.value.toLocaleStr
1ing("de-DE")})]},s.key))}),e.jsx("div",{className:"dashboard-cockpit-pulse-range",role:"tablist","aria-label":"Berater-Bereiche",children:bs.map(s=>{const a=h===s.id;return e.jsx("button",{type:"button",role:"tab","aria-selected":a,className:A("dashboard-cockpit-pulse-range-btn",a&&"is-active"),onClick:()=>v(s.id),children:s.label},s.id)})}),x?e.jsxs("div",{role:"status",className:"flex items-center gap-3 rounded-2xl border border-border bg-card px-4 py-3 text-sm",children:[e.jsx(T,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.jsxs("span",{children:[((oe=(de=t==null?void 0:t.latestAnalysis)==null?void 0:de.data_quality)==null?void 0:oe.phase)||"Analyse wird vorbereitet"," â vorhandene Empfehlungen bleiben verfügbar."]})]}):null,((ue=(ce=t==null?void 0:t.latestAnalysis)==null?void 0:ce.data_quality)==null?void 0:ue.mode)==="unconfigured"?e.jsx("p",{className:"rounded-2xl border border-border bg-card px-4 py-3 text-sm text-muted-foreground",children:"KI-Auswertung noch nicht eingerichtet. Aktuell sind nur gespeicherte Modulbefunde verfügbar."}):null,(he=(xe=(me=t==null?void 0:t.latestAnalysis)==null?void 0:me.data_quality)==null?void 0:xe.failures)!=null&&he.length?e.jsxs("p",{className:"rounded-2xl border border-border bg-card px-4 py-3 text-sm text-muted-foreground",children:["Teilweise Daten verfügbar: ",t.latestAnalysis.data_quality.failures.join(" · "),". Vorhandene Vorschläge wurden nicht als gelöst markiert."]}):null,((pe=t==null?void 0:t.latestAnalysis)==null?void 0:pe.status)==="failed"?e.jsxs("div",{className:"rounded-2xl border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm",children:["Letzte Analyse fehlgeschlagen:"," ",t.latestAnalysis.error_message_safe||"Unbekannter Fehler."]}):null,h==="empfehlungen"?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"space-y-2.5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"Worauf du jetzt schauen solltest"}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["Aktuelle Chancen aus deinen aktiven ShopFlare-Modulen · Stand"," ",_((ge=t==null?void 0:t.latestAnalysis)==null?void 0:ge.completed_at)]})]}),ae.length?e.jsx("div",{className:"grid gap-3 lg:grid-cols-3",children:ae.map((s,a)=>{const d=ns(s),G=a===0?ms:a===1?ee:X;return e.jsxs("button",{type:"button",onClick:()=>z(s.id),className:"dashboard-home-insight-card--dark group w-full rounded-2xl border border-border bg-card p-4 text-left transition-colors",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-[#330066]/10 text-[#330066] dark:bg-violet-500/15 dark:text-violet-200",children:e.jsx(G,{className:"h-4 w-4"})}),e.jsx(D,{className:"h-3.5 w-3.5 text-muted-foreground transition-colors group-hover:text-foreground"})]}),e.jsx("p",{className:"mt-4 text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:a===0?"Die
1se Woche angehen":ss[se(s)]}),e.jsx("p",{className:"mt-1 line-clamp-2 text-sm font-semibold leading-snug text-foreground",children:s.title}),e.jsx("p",{className:"mt-2 line-clamp-2 text-[11px] leading-relaxed text-muted-foreground",children:d.gap||s.next_step}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(E,{tone:s.priority==="critical"||s.priority==="high"?"primary":"muted",children:es[s.impact_potential||s.priority]}),e.jsx(E,{children:s.recommendation_kind==="opportunity"?"Chance":s.recommendation_kind==="problem"?"Problem":"Prüfung"})]})]},s.id)})}):e.jsxs("div",{className:"rounded-2xl border border-dashed border-border bg-card px-5 py-8 text-center",children:[e.jsx(X,{className:"mx-auto h-5 w-5 text-muted-foreground"}),e.jsx("p",{className:"mt-3 text-sm font-medium",children:"Noch keine priorisierte Empfehlung"}),e.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:((je=(be=(fe=t==null?void 0:t.latestAnalysis)==null?void 0:fe.data_quality)==null?void 0:be.missing)==null?void 0:je.join(" "))||"In den verfügbaren Daten wurde noch keine belegte Empfehlung gefunden."}),e.jsx(m,{asChild:!0,variant:"outline",size:"sm",className:"mt-3 h-8 rounded-[10px] px-3 text-xs",children:e.jsx(H,{to:"/dashboard/ai-sichtbarkeit/antworten",children:"KI-Fragen & Antworten prüfen"})})]})]}),e.jsxs("section",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"Alle offenen Empfehlungen"}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:[q.length," von ",(t==null?void 0:t.counts.open)??0," Vorschlägen",b?` · Fokus: ${b.title}`:""]})]}),e.jsx("div",{className:"dashboard-cockpit-pulse-range",children:[["all","Alle"],["seo","SEO"],["aeo","AEO"],["both","Beides"],["technical","Technik"]].map(([s,a])=>e.jsx("button",{type:"button",className:A("dashboard-cockpit-pulse-range-btn",j===s&&"is-active"),onClick:()=>S(s),children:a},s))})]}),e.jsx("div",{className:"overflow-hidden rounded-2xl border border-border bg-card",children:e.jsxs("ul",{className:"divide-y divide-border/70",children:[q.map(s=>e.jsx(J,{item:s,...Y(s)},s.id)),q.length?null:e.jsxs("li",{className:"px-4 py-8 text-center text-[12px] text-muted-foreground",children:["Keine Vorschläge für diesen Filter.",j!=="all"?e.jsx(m,{variant:"ghost",className:"ml-2 h-8 rounded-[10px] px-3 text-xs",onClick:()=>S("all"),children:"Filter zurücksetzen"}):null]})]})}),b?e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(m,{size:"sm",className:"h-8 rounded-[10px] px-3 text-xs",onClick:()=>z(b.id),children:"Plan öffnen"}),e.jsx(m,{size:"sm",variant:"outline",className:"h-8 rounded-[10px] px-3 text-xs",disabled:B===b.id||(t==null?void 0:t.canManage)===!1,onClick:()=>void re(b.id),children:"Entwurf"}),e.jsx(m,{size:"sm",variant:"ghost",className:"h-8 rounded-[10px] px-3 text-xs",disabled:B===b.id||(t==null?void 0:t.canManage)===!1,onClick:()=>void te(b.id),children:"Als Aufgabe"}),b.deep_link?e.jsx(m,{asChild:!0,size:"sm",variant:"ghost",className:"h-8 rounded-[10px] px-3 text-xs",children:e.jsxs(H,{to:b.deep_link,children:["Evidenz",e.jsx(D,{className:"ml-1 h-3.5 w-3.5"})]})}):null]}):null]})]}):null,h==="zielthemen"?e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[260px_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"rounded-2xl border border-border bg-card p-3 shadow-none",children:[e.jsx("p",{className:"px-2 text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",children:"Themen aus deinen Daten"}),P?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-6 text-[12px] text-muted-foreground",children:[e.jsx(T,{className:"h-4 w-4 animate-spin"})," Ladenâ¦"]}):e.jsxs("ul",{className:"mt-2 space-y-0.5",children:[F.map(s=>{const a=N===s.id,d=s.analysisStatus||"pending";return e.jsx("li",{children:e.jsxs("button",{type:"button",className:A("w-full rounded-xl px-2.5 py-2.5 text-left transition-colors",a?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),onClick:()=>I(s.id),children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"line-clamp-2 text-[13px] font-medium",children:s.label}),s.kind==="intent"?e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:"Intent"}):null]}),e.jsxs("span",{className:"mt-1 block text-[11px] text-muted-foreground",children:[s.suggestionCount," Aktionen · SEO ",s.searchGapCount," · AEO"," ",s.aeoGapCount]}),s.suggestionCount===0&&d!=="completed"?e.jsx("span",{className:"mt-0.5 block text-[10px] text-muted-foreground
1/80",children:Je[d]}):null]})},s.id)}),F.length?null:e.jsx("li",{className:"px-2 py-6 text-[12px] leading-relaxed text-muted-foreground",children:"Themen entstehen automatisch aus Katalog, Website, Search Console und überwachten KI-Fragen."})]})]}),e.jsxs("div",{className:"space-y-4 rounded-2xl border border-border bg-card p-4 shadow-none sm:p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"grid h-9 w-9 place-items-center rounded-xl border border-primary/20 bg-primary/10 text-primary",children:e.jsx(ee,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",children:["Thema ·"," ",((Ne=r==null?void 0:r.topic)==null?void 0:Ne.kind)==="intent"?"Intent":"Produkt"," · automatisch"]}),e.jsx("h2",{className:"mt-1 text-base font-semibold tracking-tight",children:((ye=r==null?void 0:r.topic)==null?void 0:ye.label)||"Thema wählen"}),e.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:x||((ke=r==null?void 0:r.analysis)==null?void 0:ke.status)==="running"?"Themenanalyse läuft gegen gespeicherte Search- und AEO-Datenâ¦":(r==null?void 0:r.note)||"Search- und KI-Lücken für dieses Thema â priorisiert für SEO und AEO."}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx(E,{tone:((ve=r==null?void 0:r.analysis)==null?void 0:ve.status)==="failed"?"warn":((we=r==null?void 0:r.analysis)==null?void 0:we.status)==="insufficient_data"?"muted":"primary",children:Je[((_e=r==null?void 0:r.analysis)==null?void 0:_e.status)||((Ae=r==null?void 0:r.topic)==null?void 0:Ae.analysisStatus)||"pending"]}),(Ee=r==null?void 0:r.market)!=null&&Ee.country||(Se=r==null?void 0:r.market)!=null&&Se.language?e.jsxs("span",{children:["Markt ",r.market.country||"â"," ·"," ",r.market.language||"â"]}):null,(ze=r==null?void 0:r.analysis)!=null&&ze.completedAt?e.jsxs("span",{children:["Stand ",_(r.analysis.completedAt)]}):null]})]})]}),V?e.jsxs("div",{className:"flex items-center gap-2 py-8 text-[12px] text-muted-foreground",children:[e.jsx(T,{className:"h-4 w-4 animate-spin"})," Thema wird geladenâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[(Ce=r==null?void 0:r.pages)!=null&&Ce.length?e.jsxs("div",{className:"rounded-xl border border-border/70 bg-muted/20 px-3 py-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Relevante Seiten"}),e.jsx("ul",{className:"mt-2 space-y-1.5",children:r.pages.slice(0,5).map(s=>e.jsx("li",{className:"truncate text-[12px]",children:e.jsx("span",{className:"font-medium",children:s.title||s.url})},s.url))})]}):null,(Te=r==null?void 0:r.prompts)!=null&&Te.length?e.jsxs("div",{className:"rounded-xl border border-border/70 bg-muted/20 px-3 py-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"KI-Erwähnung · gemessene Antworten"}),e.jsx("ul",{className:"mt-2 space-y-1.5",children:r.prompts.slice(0,5).map(s=>e.jsxs("li",{className:"text-[12px]",children:[e.jsx("span",{className:"line-clamp-2 font-medium",children:s.promptText}),e.jsxs("span",{className:"mt-0.5 block tabular-nums text-muted-foreground",children:[s.mentionRate.toFixed(0)," % Erwähnung · ",s.answerCount," ","Antworten"]})]},s.id))})]}):null]}),(Le=r==null?void 0:r.searchQueries)!=null&&Le.length?e.jsxs("div",{className:"rounded-xl border border-border/70 bg-muted/20 px-3 py-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Relevante Suchqueries · 28 Tage"}),e.jsx("ul",{className:"mt-2 space-y-1.5",children:r.searchQueries.slice(0,6).map(s=>e.jsxs("li",{className:"flex justify-between gap-3 text-[12px]",children:[e.jsx("span",{className:"min-w-0 truncate font-medium",children:s.query}),e.jsxs("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:[Math.round(s.impressions)," Imp. · ",Math.round(s.clicks)," Klicks"]})]},s.query))})]}):null,(Be=r==null?void 0:r.competitors)!=null&&Be.length?e.jsxs("div",{className:"rounded-xl border border-border/70 bg-muted/20 px-3 py-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Beobachtete Wettbewerber"}),e.jsx("p",{className:"mt-2 text-[12px] text-muted-foreground",children:r.competitors.join(" · ")}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Ein Wettbewerber in KI-Antworten erklärt nicht, warum ihr fehlt."})]}):null,e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold tracking-tight",children:"Dein Kurzplan"}),e.jsx("div",{className:"mt-2 overflow-hidden rounded-2xl border border-border bg-card",children:e.jsxs("ul",{className:"divide-y divide-border/70",children:[((r==null?void 0:r.suggestions)??[]).slice(0,8).map(s=>e.jsx(J,{item:s,...Y(s)},s.id)),(Fe=r==null?void 0:r.suggestions)!=null&&Fe.length?null:e.jsxs("li",{className:"px-4 py-8 text-[12px] leading-relaxed text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground",children:((Ie=r==null?void 0:r.analysis)==null?void 0:Ie.emptyReason)||(r==null?void 0:r.note)||"Keine belegten Empfehlungen für dieses Thema."}),(Oe=r==null?void 0:r.analysis)!=null&&Oe.emptyNextStep?e.jsx("p",{className:"mt-1",children:r.analysis.emptyNextStep}):null,((Me=r==null?void 0:r.analysis)==null?void 0:Me.status)==="failed"||((Ue=r==null?void 0:r.analysis)==null?void 0:Ue.status)==="insufficient_data"||((qe=r==null?void 0:r.analysis)==null?void 0:qe.status)==="completed"?e.jsx(m,{variant:"outline",size:"sm",className:"mt-3 h-8 rounded-[10px] px-3 text-xs",disabled:x,onClick:()=>void ne(),children:x?e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"})," Analysiereâ¦"]}):"Neu analysieren"}):null]})]})}),(((Ke=r==null?void 0:r.suggestions)==null?void 0:Ke.length)??0)>0&&(((We=r==null?void 0:r.topic)==null?void 0:We.searchGapCount)??0)>0&&(((Pe=r==null?void 0:r.topic)==null?void 0:Pe.aeoGapCount)??0)>0?e.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:"SEO- und AEO-Zähler können dieselbe Aktion mit Domain âBeidesâ jeweils einmal zählen."}):null]})]})]})]}):null,h==="ergebnisse"?e.jsxs("section",{className:"space-y-2.5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"Umsetzung & Messung"}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["Geplant ",$.planned," · In Arbeit ",$.inProgress," · Umgesetzt"," ",$.done," · Beobachten ",$.monitoring]})]}),e.jsx("div",{className:"overflow-hidden rounded-2xl border border-border bg-card",children:e.jsxs("ul",{className:"divide-y divide-border/70",children:[R.map(s=>e.jsx(J,{item:s,...Y(s)},s.id)),R.length?null:e.jsxs("li",{className:"flex flex-col items-center px-4 py-10 text-center",children:[e.jsx(xs,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("p",{className:"mt-3 text-sm font-medium",children:"Noch keine Umsetzungen"}),e.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:"Geplante oder gemeldete Empfehlungen erscheinen hier mit Folgemessung."})]})]})})]}):null,e.jsxs("section",{className:"rounded-2xl border border-border bg-card shadow-none",children:[e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-3 px-4 py-3.5 text-left sm:px-5",onClick:()=>Q(s=>!s),children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold tracking-tight",children:"Datengrundlage"}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Nur gespeicherte Moduldaten â keine neuen Scans aus dem Berater."})]}),e.jsx(De,{className:A("h-4 w-4 text-muted-foreground",C&&"rotate-180")}
1)]}),C?e.jsxs("div",{className:"space-y-4 border-t border-border/80 px-4 py-4 sm:px-5",children:[(Re=(Ve=t==null?void 0:t.latestAnalysis)==null?void 0:Ve.data_quality)!=null&&Re.coverage?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Analyseauswahl: ",t.latestAnalysis.data_quality.coverage.pages," gespeicherte Seiten · ",t.latestAnalysis.data_quality.coverage.questions," aktive Fragen ·"," ",t.latestAnalysis.data_quality.coverage.analyzedAnswers," ausgewertete Antworten im Konto. Begrenzte Auswahl, keine vollständige Website-Prüfung."]}):null,(He=(Ge=($e=t==null?void 0:t.latestAnalysis)==null?void 0:$e.data_quality)==null?void 0:Ge.missing)==null?void 0:He.map(s=>e.jsx("p",{className:"text-sm text-muted-foreground",children:s},s)),e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:["Letzte Analyse: ",_((Ze=t==null?void 0:t.latestAnalysis)==null?void 0:Ze.completed_at)," ·"," ",((Qe=t==null?void 0:t.latestAnalysis)==null?void 0:Qe.suggestion_count)??0," Vorschläge"]}),((t==null?void 0:t.notices)??[]).length?e.jsx("ul",{className:"space-y-1.5",children:((t==null?void 0:t.notices)??[]).map(s=>e.jsxs("li",{className:"rounded-xl border border-dashed border-border/80 px-3 py-2 text-[12px]",children:[e.jsx("span",{className:"font-medium",children:s.title}),e.jsxs("span",{className:"text-muted-foreground",children:[" â ",s.detail]})]},s.id))}):null,e.jsx("ul",{className:"grid gap-2 sm:grid-cols-2",children:((t==null?void 0:t.modules)??[]).map(s=>e.jsxs("li",{className:"rounded-xl border border-border/80 bg-muted/20 px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-[13px] font-medium",children:s.label}),e.jsx(E,{tone:s.hasData?"primary":"muted",children:s.hasData?"Daten":s.connected?"Leer":"Offline"})]}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:s.note||`Zuletzt: ${_(s.lastDataAt)}`})]},s.moduleKey))})]}):null]})]})})}export{$s as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.