PageSourceSearch

https://agentoai.dk/assets/VoiceAgentLockedAdmin-DQM4Gqzn.js

js agentoai.dk collected 2026-10-02 01:53:35 UTC 63,205 bytes, 5 lines download raw bytes

1import{j as e,r as a}from"./framer-motion-CQxuJa5n.js";import{C as L,f as B,g as z,i as E,M as me,G as Ne,b as xe,s as A,p as J,h as ie,Z as re,j as Ee,B as K,T as ye,U as Oe,v as Ie,d as Ke,w as Me,R as ue,ac as le,D as ne,t as W,E as je,Y as He,I as Fe,y as Ge,n as Be,a as ze,u as qe,x as pe,A as Se,P as Ue}from"./index-CSx7K-7R.js";import{B as P}from"./badge-Yar_qzGV.js";import{T as be,a as we,b as F,c as G}from"./tabs-sn5fbWIA.js";import{C as Je,A as Qe,V as Xe,a as Ye}from"./AgentConfigBadge-A68xrKtN.js";import{f as Ze,e as We,P as es,g as ge,a as ss,u as ts,A as Ce,C as as,b as rs,V as ns,H as is}from"./AgentActiveFeatures-D0ebhPf9.js";import{D as ls,a as cs,b as os,c as ds,d as ms}from"./dialog-RiETlj4q.js";import{C as Ve}from"./circle-check-big-BvOaTfBT.js";import{P as de}from"./phone-DfeYL_-y.js";import{G as xs}from"./globe-B3q7zUSQ.js";import{f as us}from"./format-CUd6TPP6.js";import{d as ps}from"./da-D_Ezdzgg.js";import{T as gs}from"./TestVoiceAgentDialog-CkS2ZWD-.js";import{T as $e}from"./textarea-BFuIyuCd.js";import{S as hs}from"./switch-GLkYldml.js";import{M as Pe}from"./megaphone-DfdBJM1G.js";import{C as U}from"./circle-check-B_lwCfqV.js";import{S as Re}from"./save-DeKktgg2.js";import{C as fs}from"./circle-alert-BTQs6TYB.js";import{S as js}from"./star-CU4ID_rj.js";import{C as vs}from"./clock-x2s7C7KC.js";import{C as Ns}from"./copy-B5YKNs8h.js";import{S as ys}from"./smartphone-Pu_ALQBu.js";import{A as bs}from"./arrow-right-Q4CCUTFT.js";import{I as ws}from"./info-DiVwxUCE.js";import{C as ke}from"./circle-help-Bky_gBt3.js";import{S as oe}from"./scroll-area-THRv4UVm.js";import{S as ks}from"./shopping-cart-BCwNokFb.js";import{M as ve}from"./message-square-CQ8acRkB.js";import{C as _e}from"./circle-x-Bjw_qpIQ.js";import{P as _s}from"./progress-xZI-P8gz.js";import{R as Ss}from"./radio-CEdjniLT.js";import{F as Cs}from"./file-text-CQNieni0.js";import{M as Ts}from"./index-LVhgA_5_.js";import{C as Te}from"./check-BKeeD-3t.js";import{U as As}from"./upload-BiTZNTHj.js";import{M as Ds}from"./mic-off-mo8vRT9e.js";import{S as Ls}from"./send-DOJcdEwD.js";import{L as Es}from"./lock-CwA9FnEu.js";import{E as Ae}from"./external-link-VZCHNZAP.js";import{U as Is}from"./user-DwnLXD35.js";import{F as Ms}from"./file-search-4SQrOMap.js";import{P as Vs}from"./phone-forwarded-Bahxs-rZ.js";import"./recharts-CFjfazL9.js";import"./index-CVOcPLpq.js";import"./index-CwKDC_mg.js";import"./accordion-C7k9loTv.js";import"./index-oMQApiRp.js";import"./chevron-down-DvU9LH4D.js";import"./alert-dialog-DED_7G_3.js";import"./history-BDnWTt5e.js";import"./eye-C7uXpcGF.js";import"./rotate-ccw-Dtzdjl-6.js";import"./trash-2-DxlklYFw.js";import"./table-DcItj2h-.js";import"./key-C6ae3JZp.js";import"./select-BP_Q7Vjk.js";import"./index-BdQq_4o_.js";import"./index-srxnih4L.js";import"./chevron-up-fhR0nOsN.js";import"./collapsible-VrVLN1fc.js";import"./search-CTXuE0h0.js";import"./plus-t8RS0EeL.js";import"./pen-6XJTB8Mj.js";import"./index-CVRrCO-_.js";import"./settings-ClDRCqQC.js";import"./crown-BJhum9o3.js";import"./shopping-bag-GeG4M_PB.js";import"./qr-code-C2UmXzIs.js";import"./mail-CQVr-2Yp.js";import"./link-2-rJ7tgC6B.js";import"./lock-open-COVVdsL_.js";import"./slider-Dw26eWSN.js";import"./settings-2-Dm1YmtG3.js";import"./map-BjrgrOjL.js";import"./calendar-check-DNMgFdaV.js";import"./unlink-B4tCe5HP.js";import"./calendar-x-DuyPE7JQ.js";import"./cpu-BGbpP_L0.js";import"./timer-Cey6-5SR.js";import"./trending-down-BBe4Inf1.js";import"./arrow-up-down-DxwdqO2n.js";import"./volume-2-CRS5fxmT.js";import"./partnerProductionCapabilities-BqMuTa6F.js";import"./danishEliteVoices-CvpClmFE.js";import"./heart-LLvDGX4H.js";import"./agentReadiness-YWq6VjqM.js";import"./en-US-Bs6ECJID.js";import"./lib.modern-BG9eWBZQ.js";import"./alert-DDlZdiu2.js";function $s({snapshot:s,open:g,onOpenChange:v}){if(!s)return null;const k=us(new Date(s.verified_at),"d. MMM yyyy 'kl.' HH:mm",{locale:ps});return e.jsx(ls,{open:g,onOpenChange:v,children:e.jsxs(cs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(os,{children:[e.jsxs(ds,{className:"flex items-center gap-2",children:["Snapshot Konfiguration",e.jsxs(P,{variant:"default",children:["v",s.version]})]}
1),e.jsxs(ms,{children:["Gemt ",k,s.build_version&&` • Build: ${s.build_version}`]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(L,{children:[e.jsx(B,{className:"pb-2",children:e.jsxs(z,{className:"text-sm flex items-center gap-2",children:[e.jsx(Ve,{className:"h-4 w-4 text-accent-foreground"}),"Agent"]})}),e.jsxs(E,{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Navn:"}),e.jsx("span",{className:"font-medium",children:s.agent_name})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Status:"}),e.jsx(P,{variant:s.status==="active"?"default":"secondary",children:s.status})]})]})]}),e.jsxs(L,{children:[e.jsx(B,{className:"pb-2",children:e.jsxs(z,{className:"text-sm flex items-center gap-2",children:[e.jsx(de,{className:"h-4 w-4 text-primary"}),"Twilio"]})}),e.jsx(E,{className:"space-y-2 text-sm",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Telefon:"}),e.jsx("span",{className:"font-mono",children:s.phone_number||"Ikke sat"})]})})]}),e.jsxs(L,{children:[e.jsx(B,{className:"pb-2",children:e.jsxs(z,{className:"text-sm flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4 text-primary"}),"ElevenLabs"]})}),e.jsxs(E,{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Agent ID:"}),e.jsx("span",{className:"font-mono text-xs",children:s.elevenlabs_agent_id||"Ikke sat"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Voice ID:"}),e.jsx("span",{className:"font-mono text-xs",children:s.voice_id||"Default"})]}),s.first_message&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Velkomstbesked:"}),e.jsx("p",{className:"mt-1 p-2 bg-muted rounded text-xs",children:s.first_message})]})]})]}),e.jsxs(L,{children:[e.jsx(B,{className:"pb-2",children:e.jsxs(z,{className:"text-sm flex items-center gap-2",children:[e.jsx(Ne,{className:"h-4 w-4 text-primary"}),"Brain (Custom LLM)"]})}),e.jsx(E,{className:"space-y-2 text-sm",children:e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Custom LLM URL:"}),e.jsx("p",{className:"font-mono text-xs mt-1 break-all bg-muted p-2 rounded",children:s.custom_llm_url||"Ikke sat"})]})})]}),e.jsxs(L,{children:[e.jsx(B,{className:"pb-2",children:e.jsxs(z,{className:"text-sm flex items-center gap-2",children:[e.jsx(xs,{className:"h-4 w-4 text-primary"}),"Viden"]})}),e.jsxs(E,{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Website:"}),e.jsx("span",{className:"text-xs",children:s.website_url||"Ikke sat"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Knowledge Version:"}),e.jsxs("span",{children:["v",s.knowledge_version||1]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Ord scannet:"}),e.jsx("span",{children:s.word_count?.toLocaleString()||0})]})]})]})]})]})})}const De="sales_injection",Le="Aktivt Salgstilbud";function Ps({agentId:s}){const{toast:g}
1=xe(),[v,k]=a.useState(""),[t,d]=a.useState(!1),[l,C]=a.useState(!0),[y,I]=a.useState(!1),[o,r]=a.useState(null),[h,V]=a.useState(null);a.useEffect(()=>{x()},[s]);const x=async()=>{try{const{data:f,error:b}=await A.from("voice_agent_custom_knowledge").select("id, value, created_at, updated_at").eq("agent_id",s).eq("category",De).eq("key",Le).maybeSingle();if(b)throw b;f&&(r(f.id),k(f.value),d(!!f.value),V(new Date(f.updated_at||f.created_at)))}catch(f){console.error("Error loading sales config:",f)}finally{C(!1)}},_=async()=>{if(!v.trim()&&t){g({title:"Manglende indhold",description:"Tilføj et salgsbudskab før du aktiverer",variant:"destructive"});return}I(!0);try{const f={agent_id:s,key:Le,value:t?v.trim():"",category:De,is_sensitive:!1};if(o){const{error:b}=await A.from("voice_agent_custom_knowledge").update(f).eq("id",o);if(b)throw b}else if(v.trim()){const{data:b,error:u}=await A.from("voice_agent_custom_knowledge").insert(f).select().single();if(u)throw u;r(b.id)}V(new Date),Ze(s),A.functions.invoke("sync-content-only",{body:{agentId:s,syncType:"sales_update",source:"dashboard"}}).catch(b=>{console.warn("Non-blocking content sync:",b)}),g({title:t?"✅ Salgsbudskab LIVE!":"✓ Gemt (inaktivt)",description:t?"Agenten vil nu nævne dette ved prisforespørgsler":"Aktiver for at agenten bruger det"})}catch(f){console.error("Error saving sales config:",f),g({title:"Fejl",description:"Kunne ikke gemme salgsbudskab",variant:"destructive"})}finally{I(!1)}},S=async f=>{d(f),v.trim()&&setTimeout(()=>_(),100)};return l?e.jsx(L,{children:e.jsx(E,{className:"flex items-center justify-center py-8",children:e.jsx(J,{className:"w-6 h-6 animate-spin text-muted-foreground"})})}):e.jsxs(L,{className:t?"border-primary/50 bg-primary/5":"",children:[e.jsx(B,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(z,{className:"flex items-center gap-2 text-base",children:[e.jsx(Pe,{className:"w-5 h-5 text-primary"}),"Live Salgs-injection"]}),e.jsx(ie,{children:"Injicér tilbud, kampagner eller mersalg i agentens svar"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t&&e.jsxs(P,{className:"bg-green-500/20 text-green-600 border-green-500/30",children:[e.jsx(re,{className:"w-3 h-3 mr-1"}),"LIVE"]}),e.jsx(hs,{checked:t,onCheckedChange:S,disabled:y})]})]})}),e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Ee,{className:"text-xs text-muted-foreground flex items-center gap-1",children:["Salgsbudskab",t&&e.jsx("span",{className:"text-primary",children:"(synlig for kunder)"})]}),e.jsx($e,{placeholder:"Eksempel: Vi har lige nu 20% rabat på alle kørekort pakker! Tilbuddet gælder til udgangen af måneden. Spørg mig om vores populære intensiv-pakke.",value:v,onChange:f=>k(f.target.value),rows:4,className:t?"border-primary/30":""}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"💡 Agenten vil nævne dette naturligt når kunder spørger om priser, pakker eller tilbud"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:h&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(U,{className:"w-3 h-3 text-green-500"}),"Sidst gemt: ",h.toLocaleTimeString("da-DK")]})}),e.jsxs(K,{onClick:_,disabled:y,size:"sm",children:[y?e.jsx(J,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Re,{className:"w-4 h-4 mr-2"}),"Gem & Synkroniser"]})]}),t&&!v.trim()&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-amber-500/10 border border-amber-500/30 text-amber-600 text-sm",children:[e.jsx(fs,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:"Tilføj et salgsbudskab for at aktivere live injection"})]})]})]})}function Rs({agentId:s}){const[g,v]=a.useState({totalCalls:0,solvedCalls:0,avgDuration:0,estimatedTimeSaved:0,serviceScore:0,escalatedCalls:0,totalDuration:0}),[k,t]=a.useState(!0);a.useEffect(()=>{d();const o=A.channel(`value-metrics-${s}`).on("postgres_changes",{event:"*",schema:"public",table:"voice_calls",filter:`agent_id=eq.${s}`},()=>d()).subscribe();return()=>{A.removeChannel(o)}},[s]);const d=async()=>{try{const{data:o,error:r}=await A.from("voice_calls").select("duration, outcome, confidence_score, status").eq("agent_id",s);if(r)throw r;const h=o||[],V=h.length,x=h.filter(i=>i.outcome==="solved").length,_=h.filter(i=>i.outcome==="transferred_to_human").length,S=h.filter(i=>i.duration).map(i=>i.duration),f=S.reduce((i,M)=>i+M,0),b=S.length>0?f/S.length:0,u=V*3,m=V>0?x/V:0,D=h.filter(i=>i.confidence_score).map(i=>i.confidence_score),N=D.length>0?D.reduce((i,M)=>i+M,0)/D.length:0,w=Math.round(m*50+N*50);v({totalCalls:V,solvedCalls:x,avgDuration:Math.round(b),estimatedTimeSaved:u,serviceScore:w,escalatedCalls:_,totalDuration:f})}catch(o){console.error("Error loading metrics:",o)}finally{t(!1)}},l=o=>{if(o<60)return`${o}s`;const r=Math.floor(o/60),h=o%60;return h>0?`${r}m ${h}s`:`${r}m`},C=o=>
1{if(o<60)return`${o} min`;const r=Math.floor(o/60),h=o%60;return h>0?`${r}t ${h}m`:`${r} timer`},y=o=>o>=80?"text-green-500":o>=60?"text-primary":o>=40?"text-yellow-500":"text-red-500",I=o=>o>=80?"Fremragende":o>=60?"God":o>=40?"Okay":"Kan forbedres";return k?e.jsx(L,{children:e.jsx(E,{className:"flex items-center justify-center py-8",children:e.jsx(J,{className:"w-6 h-6 animate-spin text-muted-foreground"})})}):e.jsxs(L,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(z,{className:"flex items-center gap-2 text-base",children:[e.jsx(ye,{className:"w-5 h-5 text-primary"}),"Værdi & Performance"]}),e.jsx(ie,{children:"Se hvad din agent leverer af værdi"})]}),e.jsxs(P,{variant:"outline",className:`${y(g.serviceScore)} border-current`,children:[e.jsx(js,{className:"w-3 h-3 mr-1"}),g.serviceScore,"% - ",I(g.serviceScore)]})]})}),e.jsxs(E,{children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-1",children:[e.jsx(de,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"text-3xl font-bold",children:g.totalCalls})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Opkald håndteret"})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-1",children:[e.jsx(U,{className:"w-5 h-5 text-green-500"}),e.jsxs("span",{className:"text-3xl font-bold text-green-500",children:[g.totalCalls>0?Math.round(g.solvedCalls/g.totalCalls*100):0,"%"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Løst automatisk"})]}),e.jsxs("div",{className:"bg-primary/10 rounded-lg p-4 text-center border border-primary/20",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-1",children:[e.jsx(vs,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"text-3xl font-bold text-primary",children:C(g.estimatedTimeSaved)})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tid sparet"})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-1",children:[e.jsx(Oe,{className:"w-5 h-5 text-muted-foreground"}),e.jsx("span",{className:"text-3xl font-bold",children:g.escalatedCalls})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Viderestillet"})]})]}),e.jsxs("div",{className:"mt-4 p-3 bg-gradient-to-r from-primary/5 to-primary/10 rounded-lg border border-primary/20",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Total samtaletid:"}),e.jsx("span",{className:"font-medium",children:l(g.totalDuration)})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm mt-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Gns. opkaldslængde:"}),e.jsx("span",{className:"font-medium",children:l(g.avgDuration)})]}),g.totalCalls>0&&e.jsxs("div",{className:"flex items-center justify-between text-sm mt-1 text-primary",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ie,{className:"w-3 h-3"}),"Estimeret besparelse:"]}),e.jsxs("span",{className:"font-medium",children:["~",Math.round(g.estimatedTimeSaved/60*250)," kr/mdr"]})]})]})]})]})}function Os({agentPhoneNumber:s,agentStatus:g}){const{toast:v}=xe(),[k,t]=a.useState(!1),d=()=>{s&&(navigator.clipboard.writeText(s),t(!0),v({title:"Telefonnummer kopieret!"}),setTimeout(()=>t(!1),2e3))},l=g==="active",C=s?s.replace(/(\+45)(\d{2})(\d{2})(\d{2})(\d{2})/,"$1 $2 $3 $4 $5"):"Ikke konfigureret";return e.jsxs(L,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(z,{className:"flex items-center gap-2 text-base",children:[e.jsx(de,{className:"w-5 h-5 text-primary"}),"Telefonnummer & Viderestilling"]}),e.jsx(ie,{children:"Sådan viderestiller du opkald til din AI-agent"})]}),e.jsx(P,{variant:l?"default":"secondary",children:l?"Aktiv":"Inaktiv"})]})}),e.jsxs(E,{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 bg-primary/10 border border-primary/20 rounded-lg",children:[e.jsx(Ee,{className:"text-xs text-primary uppercase font-medium",children:"Agentens telefonnummer"}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx("span",{className:"text-2xl font-mono font-bold text-primary",children:C}),s&&e.jsx(K,{variant:"outline",size:"sm",onClick:d,className:"gap-2",children:k?e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"w-4 h-4 text-green-500"}),"Kopieret"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ns,{className:"w-4 h-4"}),"Kopier"]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Dette er det nummer kunder skal ringe til, eller som du skal viderestille til"})]}),e.jsxs(be,{defaultValue:"manual",className:"w-full",children:[e.jsxs(we,{className:"grid w-full grid-cols-2",children:[e.jsxs(F,{value:"manual",className:"gap-2",children:[e.jsx(ys,{className:"w-4 h-4"}),"Manuel viderestilling"]}),e.jsxs(F,{value:"telco",className:"gap-2",children:[e.jsx(Ke,{className:"w-4 h-4"}),"Via teleselskab"]})]}),e.jsxs(G,{value:"manual",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4 space-y-3",children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[e.jsx("span",{className:"w-6 h-6 rounded-full bg-primary text-primary-foreground flex items-center justify-center text-sm font-bold",children:"1"}),"Aktiver viderestilling på din telefon"]}),e.jsx("p",{className:"text-sm text-muted-foreground pl-8",children:'Gå til dine opkaldsindstillinger og vælg "Viderestil alle opkald" eller "Omstilling"'})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4 space-y-3",children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[e.jsx("span",{className:"w-6 h-6 rounded-full bg-primary text-primary-foreground flex items-center justify-center text-sm font-bold",children:"2"}),"Indtast agentens nummer"]}),e.jsxs("div",{className:"pl-8",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Kopier og indsæt dette nummer som viderestillingsdestination:"}),e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border font-mono",children:[s||"Intet nummer",e.jsx(bs,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-primary font-medium",children:"AI Agent"})]})]})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4 space-y-3",children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[e.jsx("span",{className:"w-6 h-6 rounded-full bg-primary text-primary-foreground flex items-center justify-center text-sm font-bold",children:"3"}),"Test at det virker"]}),e.jsx("p",{className:"text-sm text-muted-foreground pl-8",children:"Ring til dit eget nummer og verificer at opkaldet viderestilles til agenten"})]})]}),e.jsxs(G,{value:"telco",className:"mt-4 space-y-4",children:[e.jsx("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ws,{className:"w-5 h-5 text-blue-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-blue-600",children:"Kontakt dit teleselskab"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"For permanent viderestilling anbefaler vi at kontakte dit teleselskab direkte. De kan opsætte automatisk viderestilling på netværksniveau."})]})]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-medium",children:"Sig dette til teleselskabet:"}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4 space-y-2",children:[e.jsx("p",{className:"text-sm italic",children:'"Jeg ønsker at opsætte viderestilling af alle indgående opkald til følgende nummer:"'}),e.jsx("div",{className:"font-mono text-primary font-bold text-lg",children:C})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4",children:[e.jsx("h5",{className:"font-medium mb-2",children:"Valgmuligheder at overveje:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(U,{className:"w-4 h-4 text-green-500 flex-shrink-0 mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Altid viderestil:"})," Alle opkald går til AI-agenten"]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(U,{className:"w-4 h-4 text-green-500 flex-shrink-0 mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Optaget:"})," Kun når linjen er optaget"]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(U,{className:"w-4 h-4 text-green-500 flex-shrink-0 mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Intet svar:"})," Efter X antal ring"]})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-muted/50 text-sm",children:[e.jsx(ke,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"De fleste teleselskaber k
1an opsætte dette gratis eller for et lille månedligt gebyr"})]})]})]})]})]})}function Ks({agentId:s}){const[g,v]=a.useState(!0),[k,t]=a.useState([]),[d,l]=a.useState([]),[C,y]=a.useState([]);a.useEffect(()=>{I()},[s]);const I=async()=>{try{v(!0);const{data:r,error:h}=await A.from("voice_calls").select("customer_intent, outcome, call_summary").eq("agent_id",s);if(h)throw h;const V=r||[],x={kundeservice:{count:0,solved:0},priser:{count:0,solved:0},salg:{count:0,solved:0},booking:{count:0,solved:0},andet:{count:0,solved:0}},_={},S=[];V.forEach(u=>{const m=(u.customer_intent||"").toLowerCase(),D=u.outcome==="solved";if(m.includes("pris")||m.includes("kost")||m.includes("betaling")?(x.priser.count++,D&&x.priser.solved++):m.includes("book")||m.includes("tid")||m.includes("aftale")?(x.booking.count++,D&&x.booking.solved++):m.includes("køb")||m.includes("bestil")||m.includes("ordre")?(x.salg.count++,D&&x.salg.solved++):m.includes("hjælp")||m.includes("spørgsmål")||m.includes("problem")?(x.kundeservice.count++,D&&x.kundeservice.solved++):m&&(x.andet.count++,D&&x.andet.solved++),u.customer_intent){const N=u.customer_intent;_[N]||(_[N]={count:0,answered:!1}),_[N].count++,D&&(_[N].answered=!0)}u.outcome==="not_solved"&&u.customer_intent&&(S.includes(u.customer_intent)||S.push(u.customer_intent))});const f=[{category:"Kundeservice",count:x.kundeservice.count,solvedCount:x.kundeservice.solved,icon:e.jsx(ke,{className:"w-4 h-4"}),color:"text-blue-500"},{category:"Priser",count:x.priser.count,solvedCount:x.priser.solved,icon:e.jsx(Ie,{className:"w-4 h-4"}),color:"text-green-500"},{category:"Salg",count:x.salg.count,solvedCount:x.salg.solved,icon:e.jsx(ks,{className:"w-4 h-4"}),color:"text-purple-500"},{category:"Booking",count:x.booking.count,solvedCount:x.booking.solved,icon:e.jsx(Me,{className:"w-4 h-4"}),color:"text-amber-500"},{category:"Andet",count:x.andet.count,solvedCount:x.andet.solved,icon:e.jsx(ve,{className:"w-4 h-4"}),color:"text-muted-foreground"}].filter(u=>u.count>0),b=Object.entries(_).map(([u,m])=>({question:u,count:m.count,wasAnswered:m.answered})).sort((u,m)=>m.count-u.count).slice(0,10);t(f),l(b),y(S.slice(0,5))}catch(r){console.error("Error loading insights:",r)}finally{v(!1)}};if(g)return e.jsx(L,{children:e.jsx(E,{className:"flex items-center justify-center py-8",children:e.jsx(J,{className:"w-6 h-6 animate-spin text-muted-foreground"})})});const o=k.reduce((r,h)=>r+h.count,0);return e.jsxs(L,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(z,{className:"flex items-center gap-2 text-base",children:[e.jsx(ye,{className:"w-5 h-5 text-primary"}),"Samtale-indsigt"]}),e.jsx(ie,{children:"Hvad spørger kunderne om, og hvordan klarer agenten sig"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:I,children:e.jsx(ue,{className:"w-4 h-4"})})]})}),e.jsx(E,{className:"space-y-4",children:o===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ve,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"Ingen samtaler at analysere endnu"}),e.jsx("p",{className:"text-sm mt-1",children:"Indsigter vises når agenten tager opkald"})]}):e.jsxs(be,{defaultValue:"categories",className:"w-full",children:[e.jsxs(we,{className:"grid w-full grid-cols-3",children:[e.jsx(F,{value:"categories",children:"Kategorier"}),e.jsx(F,{value:"questions",children:"Spørgsmål"}),e.jsx(F,{value:"gaps",children:"Videnshuller"})]}),e.jsx(G,{value:"categories",className:"mt-4",children:e.jsx("div",{className:"space-y-3",children:k.map(r=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:r.color,children:r.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:r.category}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.count," opkald · ",r.count>0?Math.round(r.solvedCount/r.count*100):0,"% løst"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{variant:"outline",children:r.count}),r.solvedCount===r.count&&r.count>0&&e.jsx(U,{className:"w-4 h-4 text-green-500"})]})]},r.category))})}),e.jsx(G,{value:"questions",className:"mt-4",children:e.jsx(oe,{className:"h-[300px]",children:e.jsx("div",{className:"space-y-2",children:d.length>0?d.map((r,h)=>e.jsxs("div",{className:"flex items-start justify-between p-3 bg-muted/30 rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-sm font-medium line-clamp-2",children:['"',r.question,'"']}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Spurgt ",r.count," ",r.count===1?"gang":"gange"]})]}),r.wasAnswered?e.jsxs(P,{variant:"default",className:"ml-2 shrink-0",children:[e.jsx(U,{className:"w-3 h-3 mr-1"}),"Besvaret"]}):e.jsxs(P,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(le,{className:"w-3 h-3 mr-1"}),"Åben"]})]},h)):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"Ingen spørgsmål registreret endnu"})})})}),e.jsx(G,{value:"gaps",className:"mt-4",children:e.jsx("div",{className:"space-y-3",children:C.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-3 bg-amber-500/10 border border-amber-500/20 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-600",children:[e.jsx(le,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium",children:"Emner der mangler viden"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Overvej at tilføje viden om disse emner for at forbedre agenten"})]}),C.map((r,h)=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded-lg",children:[e.jsxs("span",{className:"text-sm",children:['"',r,'"']}),e.jsxs(P,{variant:"destructive",className:"shrink-0",children:[e.jsx(_e,{className:"w-3 h-3 mr-1"}),"Ikke besvaret"]})]},h))]}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(U,{className:"w-12 h-12 mx-auto mb-4 text-green-500 opacity-50"}),e.jsx("p",{className:"text-muted-foreground",children:"Ingen åbenlyse videnshuller"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Agenten klarer alle emner fint"})]})})})]})})]})}function he({status:s,errorDetail:g}){switch(s){case"saving":return e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground animate-pulse",children:[e.jsx(J,{className:"w-3.5 h-3.5 animate-spin"}),e.jsx("span",{children:"Gemmer lokalt..."})]});case"syncing":return e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground animate-pulse",children:[e.jsx(Ss,{className:"w-3.5 h-3.5 animate-pulse text-primary"}),e.jsx("span",{children:"Synkroniserer til stemme-motor..."})]});case"verifying":return e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground animate-pulse",children:[e.jsx(J,{className:"w-3.5 h-3.5 animate-spin text-primary"}),e.jsx("span",{children:"Verificerer live-konfiguration..."})]});case"verified":return e.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary",children:[e.jsx(U,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"✅ Live og verificeret"})]});case"error":return e.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive",children:[e.jsx(_e,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:g||"Synkronisering fejlede"})]});default:return null}}function Hs({agentId:s,isLocked:g=!0,onSave:v}){const{toast:k}
1=xe(),[t,d]=a.useState(!0),[l,C]=a.useState(!1),[y,I]=a.useState(!1),[o,r]=a.useState(""),[h,V]=a.useState(""),[x,_]=a.useState("idle"),[S,f]=a.useState(),[b,u]=a.useState(0),[m,D]=a.useState(""),[N,w]=a.useState(""),[i,M]=a.useState("da"),[Y,ee]=a.useState(null),[R,n]=a.useState({response_tone:"venlig",response_personality:"professionel",response_style:"kort",silence_duration_ms:300,speech_threshold:.4,max_tokens:120,speed:1.05,filler_behavior:"minimal",interruption_sensitivity:.5,conversation_style:"natural"}),[p,j]=a.useState(""),c=a.useRef(!0);a.useEffect(()=>{T()},[s]),a.useEffect(()=>{const $=JSON.stringify({voice:m,firstMessage:N,language:i,voiceConfig:R,industryPreset:Y});I($!==p)},[m,N,i,R,p,Y]);const T=async()=>{try{const{data:$,error:se}=await A.from("voice_agents").select("name, voice, first_message, system_prompt, response_tone, response_personality, language, industry_preset").eq("id",s).single();if(se)throw se;const H=$;V(H.name||""),r(H.system_prompt||"");const O=We(H.system_prompt),Z=H.voice||"",te=H.first_message||"",ae=H.language||"da",ce={response_tone:H.response_tone||O?.response_tone||"venlig",response_personality:H.response_personality||O?.response_personality||"professionel",response_style:O?.response_style||"kort",silence_duration_ms:O?.silence_duration_ms??300,speech_threshold:O?.speech_threshold??.4,max_tokens:O?.max_tokens??120,speed:O?.speed??1.05,filler_behavior:O?.filler_behavior||"minimal",interruption_sensitivity:O?.interruption_sensitivity??.5,conversation_style:O?.conversation_style||"natural",preset:O?.preset||"custom"};D(Z),w(te),M(ae),n(ce),ee(H.industry_preset||null),j(JSON.stringify({voice:Z,firstMessage:te,language:ae,voiceConfig:ce,industryPreset:H.industry_preset||null})),c.current=!1}catch($){console.error("Error loading agent config:",$),k({title:"Fejl",description:"Kunne ikke hente agentkonfiguration",variant:"destructive"})}finally{d(!1)}},Q=$=>{const se=i;if(M($),c.current)return;const H=ge($),O=h||"vores virksomhed",Z=H.defaultGreeting.replace("{company}",O),te=ge(se),ae=te.defaultGreeting.replace("{company}",O);(!N||N===ae||N===te.defaultGreeting)&&w(Z)},X=async()=>{C(!0),_("saving"),u(15),f(void 0);try{const $=ts(o,R),{error:se}=await A.from("voice_agents").update({voice:m,first_message:N,response_tone:R.response_tone,response_personality:R.response_personality,system_prompt:$,language:i,industry_preset:Y,updated_at:new Date().toISOString()}).eq("id",s);if(se)throw se;try{await A.from("agent_voice_runtime_config").upsert({agent_id:s,voice:m||"marin",speed:R.speed??1.05,vad_silence_ms:R.silence_duration_ms??500,vad_sensitivity:R.speech_threshold??.5,interruptibility:(R.interruption_sensitivity??.5)>0,language:i||"da",updated_at:new Date().toISOString()},{onConflict:"agent_id"})}catch(Z){console.warn("Runtime config sync warning:",Z)}r($),j(JSON.stringify({voice:m,firstMessage:N,language:i,voiceConfig:R,industryPreset:Y})),I(!1),u(30),_("syncing"),u(45);try{await A.functions.invoke("sync-content-only",{body:{agentId:s,syncType:"voice_config_update",source:"dashboard"}})}catch(Z){console.warn("Content sync warning:",Z)}u(60);const{data:H,error:O}=await A.functions.invoke("update-elevenlabs-agent",{body:{agentId:s,updates:{voice:m,first_message:N,...R}}});if(u(80),O)console.error("ElevenLabs sync error:",O),_("error"),f("Live-synk til stemme-motor fejlede"),k({title:"Gemt lokalt",description:"Indstillinger gemt, men live-synk fejlede.",variant:"destructive"});else{_("verifying"),u(90);const Z=H?.read_back_verified===!0,te=H?.critical_synced===!0,ae=H?.issues||[];if(Z||te)_("verified"),u(100),k({title:"Gemt og verificeret! ✅",description:"Stemmeindstillinger er live og klar til nye opkald."}),setTimeout(()=>_("idle"),5e3);else{_("error");const ce=ae.length>0?ae.join(", "):"Ukendt verifikationsfejl";f(`Verifikation: ${ce}`),k({title:"Gemt med advarsler",description:`Synk delvist: ${ce}`,variant:"destructive"})}}v?.()}catch($){console.error("Error saving config:",$),_("error"),f("Kunne ikke gemme konfiguration"),k({title:"Fejl",description:"Kunne ikke gemme konfiguration",variant:"destructive"})}finally{C(!1)}},q=ss(i);return t?e.jsx(L,{children:e.jsx(E,{className:"flex items-center justify-center py-12",children:e.jsx(J,{className:"w-8 h-8 animate-spin text-primary"})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(es,{config:R,onConfigChange:n,language:i,onLanguageChange:Q,voice:m,onVoiceChange:D,industryPreset:Y||void 0,onIndustryPresetChange:ee}),e.jsxs(L,{children:[e.jsxs(B,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-5 h-5 text-primary"}),q.sectionGreeting]}),e.jsx(ie,{children:q.sectionGreetingDesc})]}),e.jsxs(E,{children:[e.jsx($e,{value:N,onChange:$=>w($.target.value),placeholder:ge(i).defaultGreeting.replace("{company}",h||"..."),rows:3,className:"resize-none"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[N.length," ",q.characters]})]})]}),e.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[x!=="idle"&&x!=="verified"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_s,{value:b,className:"h-1.5"}),e.jsx(he,{status:x,errorDetail:S})]}),x==="verified"&&e.jsx(he,{status:x}),x==="error"&&e.jsx(he,{status:x,errorDetail:S}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-2",children:y?e.jsxs(P,{variant:"outline",className:"gap-1 text-warning border-warning",children:[e.jsx(le,{className:"w-3 h-3"}),q.unsavedChanges]}):e.jsxs(P,{variant:"outline",className:"gap-1 text-primary border-primary",children:[e.jsx(U,{className:"w-3 h-3"}),q.saved]})}),e.jsx(K,{onClick:X,disabled:l||!y,children:l?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4 mr-2 animate-spin"}),q.btnSaving]}):e.jsxs(e.Fragment,{children:[e.jsx(Re,{className:"w-4 h-4 mr-2"}),q.btnSave]})})]})]})]})}const Fs={optimize_brain_speed:{label:"Hjerne-hastighed",icon:Ne,color:"text-amber-500"},update_prompt_section:{label:"Prompt optimeret",icon:Cs,color:"text-blue-500"},optimize_voice:{label:"Stemme optimeret",icon:me,color:"text-purple-500"},update_agent:{label:"Agent opdateret",icon:re,color:"text-primary"},update_status:{label:"Status ændret",icon:U,color:"text-green-500"},add:{label:"Viden tilføjet",icon:ne,color:"text-emerald-500"},update:{label:"Viden opdateret",icon:ne,color:"text-blue-500"},delete:{label:"Viden slettet",icon:ne,color:"text-destructive"},bulk_add:{label:"Bulk viden tilføjet",icon:ne,color:"text-emerald-500"},update_handoff:{label:"Viderestilling",icon:re,color:"text-orange-500"},update_booking:{label:"Booking opdateret",icon:re,color:"text-cyan-500"},update_sms:{label:"SMS opdateret",icon:re,color:"text-pink-500"}};function Gs({agentId:s}){const[g,v]=a.useState([]);if(a.useEffect(()=>{(async()=>{const{data:l}=await A.from("knowledge_audit_log").select("id, action_type, payload_after, 
1created_at, actor_role").eq("agent_id",s).order("created_at",{ascending:!1}).limit(15);l&&v(l)})()},[s]),g.length===0)return null;const k=d=>{const l=new Date(d),y=new Date().getTime()-l.getTime(),I=Math.floor(y/6e4);if(I<1)return"Lige nu";if(I<60)return`${I} min siden`;const o=Math.floor(I/60);return o<24?`${o}t siden`:l.toLocaleDateString("da-DK",{day:"numeric",month:"short"})},t=d=>{const l=d.payload_after;if(!l)return"";switch(d.action_type){case"optimize_brain_speed":return l.brain_config?.speed_profile?`→ ${l.brain_config.speed_profile}`:"";case"update_prompt_section":return l.section?`Sektion: ${l.section}`:"";case"optimize_voice":return l.voice?`Stemme: ${l.voice}`:"";case"add":case"update":return l.key?`"${l.key}"`:"";case"update_agent":return Object.keys(l).slice(0,2).join(", ");default:return""}};return e.jsxs(L,{className:"border-border/50 bg-gradient-to-b from-primary/5 to-transparent",children:[e.jsx(B,{className:"py-2.5 px-3",children:e.jsxs(z,{className:"text-xs flex items-center gap-1.5 font-semibold",children:[e.jsx(re,{className:"h-3.5 w-3.5 text-primary"}),"Optimeringshistorik"]})}),e.jsx(E,{className:"px-3 pb-3",children:e.jsx(oe,{className:"max-h-[30vh]",children:e.jsx("div",{className:"space-y-1.5",children:g.map(d=>{const l=Fs[d.action_type]||{label:d.action_type,icon:re,color:"text-muted-foreground"},C=l.icon,y=t(d);return e.jsxs("div",{className:"flex items-start gap-2 py-1.5 border-b border-border/20 last:border-0",children:[e.jsx(C,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 ${l.color}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[11px] font-medium",children:l.label}),e.jsx(P,{variant:"outline",className:"text-[9px] h-4 px-1 border-green-500/30 text-green-600",children:"Live"})]}),y&&e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:y}),e.jsx("p",{className:"text-[10px] text-muted-foreground/60",children:k(d.created_at)})]})]},d.id)})})})})]})}const fe="Hvad skal vi optimere?";function Bs({agentId:s,agentName:g,initialKnowledge:v,onKnowledgeChanged:k}
1){const[t,d]=a.useState([]),[l,C]=a.useState(""),[y,I]=a.useState(!1),[o,r]=a.useState(v||[]),[h,V]=a.useState([]),[x,_]=a.useState("idle"),[S,f]=a.useState(new Set),[b,u]=a.useState(!1),m=a.useRef(null),D=a.useRef(null),N=a.useRef(null);a.useEffect(()=>{v?r(v):(async()=>{const{data:p}=await A.from("voice_agent_custom_knowledge").select("id, key, value").eq("agent_id",s).order("created_at");p&&r(p)})()},[v,s]),a.useEffect(()=>{m.current&&(m.current.scrollTop=m.current.scrollHeight)},[t]);const w=a.useCallback(()=>{if(b){N.current?.stop(),u(!1);return}const n=window.SpeechRecognition||window.webkitSpeechRecognition;if(!n){W.error("Din browser understøtter ikke stemmeinput");return}const p=new n;p.lang="da-DK",p.continuous=!1,p.interimResults=!0,p.onresult=j=>{const c=Array.from(j.results).map(T=>T[0].transcript).join("");C(c)},p.onend=()=>u(!1),p.onerror=j=>{console.error("Speech error:",j.error),u(!1),j.error==="not-allowed"&&W.error("Mikrofon-adgang er blokeret.")},N.current=p,p.start(),u(!0)},[b]),i=a.useCallback(async n=>{if(!n.trim()||y)return;const p={role:"user",content:n};d(j=>[...j,p]),C(""),I(!0);try{const j=t.map(X=>({role:X.role,content:X.content})),{data:c,error:T}=await A.functions.invoke("partner-knowledge-chat",{body:{agent_id:s,message:n,history:j,action:"chat"}});if(T)throw T;if(c?.error)throw new Error(c.error);const Q={role:"assistant",content:c?.assistant_message||c?.message||"Ingen svar.",proposed_actions:c?.proposed_changes?.length>0?c.proposed_changes:c?.proposed_actions};d(X=>[...X,Q]),c?.knowledge_snapshot&&r(c.knowledge_snapshot),c?.gaps_snapshot&&V(c.gaps_snapshot),c?.sync_status&&_(c.sync_status)}catch(j){console.error("Chat error:",j);const c=j?.message||"";let T="Kunne ikke få svar fra AI. Prøv igen.";c.includes("HTTP_429")||c.includes("Rate limit")?T="Rate limit nået – vent lidt og prøv igen.":c.includes("HTTP_401")||c.includes("Unauthorized")?T="Adgang nægtet – prøv at genindlæse siden.":c.includes("HTTP_402")||c.includes("Kreditter")?T="Kreditter opbrugt. Kontakt administrator.":c.includes("HTTP_403")||c.includes("Forbidden")?T="Ingen adgang til denne agent.":c.includes("Agent not found")?T="Agent ikke fundet.":c.includes("HTTP_500")?T=`Server-fejl: ${c.split(":").slice(1).join(":").substring(0,100)}`:c!==""&&(T=`AI fejl: ${c.substring(0,150)}`),W.error(T),d(Q=>[...Q,{role:"assistant",content:`⚠️ ${T}`}])}finally{I(!1)}},[s,t,y]),M=a.useCallback(async(n,p)=>{const j=t[n];if(j?.proposed_actions){f(c=>new Set([...c,...p]));try{const{data:c,error:T}=await A.functions.invoke("partner-knowledge-chat",{body:{agent_id:s,action:"approve",approve_actions:p,proposed_actions:j.proposed_actions}});if(T)throw T;if(c?.error)throw new Error(c.error);const Q=c.results?.filter(X=>X.success).length||0;W.success(`${Q} ændring(er) godkendt og gemt!`),d(X=>X.map((q,$)=>$===n?{...q,actionsHandled:!0}:q)),_("synced"),setTimeout(()=>_("idle"),3e3),k?.()}catch{W.error("Kunne ikke godkende ændringer")}finally{f(c=>{const T=new Set(c);return p.forEach(Q=>T.delete(Q)),T})}}},[s,t,k]),Y=a.useCallback(n=>{d(p=>p.map((j,c)=>c===n?{...j,actionsHandled:!0}:j)),W.info("Ændringer afvist")},[]),ee=a.useCallback(async n=>{const p=n.target.files?.[0];if(p)try{const j=await p.text();if((j.match(/[\x00-\x08\x0E-\x1F]/g)||[]).length/j.length>.1){W.error("Binær fil. Upload venligst TXT, CSV eller MD.");return}const T=j.substring(0,3e4),Q=`Jeg uploader filen "${p.name}" med følgende indhold. Analysér indholdet og foreslå relevante videnpunkter:
2
3---
4${T}
5---`;i(Q)}catch{W.error("Kunne ikke læse filen")}finally{D.current&&(D.current.value="")}},[i]),R=n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),i(l))};return e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-4 h-[calc(100vh-16rem)]",children:[e.jsxs("div",{className:"lg:col-span-3 flex flex-col border rounded-xl bg-card shadow-sm",children:[e.jsxs("div",{className:"p-3 border-b flex items-center justify-between bg-gradient-to-r from-primary/5 to-transparent rounded-t-xl",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(je,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-sm",children:"AI Partner Assistent"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Alt-i-én support for ",g]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[x==="synced"&&e.jsxs(P,{variant:"outline",className:"text-xs gap-1 border-green-500/30 text-green-600",children:[e.jsx(U,{className:"h-3 w-3"})," Synkroniseret"]}),x==="queued"&&e.jsxs(P,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(ue,{className:"h-3 w-3 animate-spin"})," Synkroniserer..."]}
5),h.length>0&&e.jsxs(P,{variant:"destructive",className:"text-xs gap-1",children:[e.jsx(le,{className:"h-3 w-3"})," ",h.length," huller"]})]})]}),e.jsxs(oe,{className:"flex-1 p-4",ref:m,children:[t.length===0&&e.jsxs("div",{className:"space-y-4 py-6 text-center",children:[e.jsx("div",{className:"h-12 w-12 rounded-2xl bg-gradient-to-br from-primary/20 to-primary/5 flex items-center justify-center mx-auto",children:e.jsx(je,{className:"h-6 w-6 text-primary"})}),e.jsx("h3",{className:"font-semibold text-lg",children:"Hej! Jeg er din AI-assistent 👋"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-lg mx-auto",children:fe}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>i(fe),children:fe})]}),e.jsxs("div",{className:"space-y-4",children:[t.map((n,p)=>e.jsx("div",{className:`flex ${n.role==="user"?"justify-end":"justify-start"}`,children:e.jsxs("div",{className:`max-w-[85%] rounded-2xl p-3 ${n.role==="user"?"bg-primary text-primary-foreground rounded-br-md":"bg-muted text-foreground rounded-bl-md"}`,children:[n.role==="assistant"?e.jsx("div",{className:"text-sm prose prose-sm dark:prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&_table]:text-xs [&_th]:p-1 [&_td]:p-1",children:e.jsx(Ts,{children:n.content})}):e.jsx("div",{className:"text-sm whitespace-pre-wrap",children:n.content}),n.proposed_actions&&!n.actionsHandled&&e.jsxs("div",{className:"mt-3 space-y-2 border-t border-border/30 pt-3",children:[e.jsx("p",{className:"text-xs font-semibold opacity-80",children:"🔧 Foreslåede ændringer:"}),n.proposed_actions.map(j=>e.jsxs("div",{className:"bg-background/60 rounded-lg p-2.5 text-xs border border-border/30 flex items-start justify-between gap-2",children:[e.jsx("span",{className:"flex-1",children:j.preview||j.description}),e.jsx("div",{className:"flex gap-1 shrink-0",children:e.jsxs(K,{size:"sm",variant:"default",className:"text-[10px] h-6 px-2 gap-1",disabled:S.has(j.id),onClick:()=>M(p,[j.id]),children:[S.has(j.id)?e.jsx(J,{className:"h-3 w-3 animate-spin"}):e.jsx(Te,{className:"h-3 w-3"}),"Gem"]})})]},j.id)),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(K,{size:"sm",className:"text-xs h-7 gap-1",disabled:S.size>0,onClick:()=>M(p,n.proposed_actions.map(j=>j.id)),children:[S.size>0?e.jsx(J,{className:"h-3 w-3 animate-spin"}):e.jsx(Te,{className:"h-3 w-3"}),"Godkend alle"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"text-xs h-7 gap-1",onClick:()=>Y(p),children:[e.jsx(He,{className:"h-3 w-3"})," Afvis"]})]})]}),n.actionsHandled&&n.proposed_actions&&e.jsxs("div",{className:"mt-2 text-xs opacity-50 flex items-center gap-1",children:[e.jsx(U,{className:"h-3 w-3"})," Gemt i vidensbasen ✅"]})]})},p)),y&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"bg-muted rounded-2xl rounded-bl-md p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-4 w-4 animate-spin text-primary"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Tænker..."})]})})})]})]}),e.jsxs("div",{className:"p-3 border-t flex gap-2 bg-muted/20",children:[e.jsx("input",{type:"file",ref:D,className:"hidden",accept:".txt,.csv,.md,.json,.pdf",onChange:ee}),e.jsx(K,{variant:"outline",size:"icon",className:"shrink-0 h-10 w-10 rounded-xl",onClick:()=>D.current?.click(),title:"Upload fil",children:e.jsx(As,{className:"h-4 w-4"})}),e.jsx(K,{variant:b?"default":"outline",size:"icon",className:`shrink-0 h-10 w-10 rounded-xl ${b?"animate-pulse bg-destructive hover:bg-destructive/90 text-destructive-foreground":""}`,onClick:w,title:b?"Stop":"Tal",children:b?e.jsx(Ds,{className:"h-4 w-4"}):e.jsx(me,{className:"h-4 w-4"})}),e.jsx(Fe,{value:l,onChange:n=>C(n.target.value),onKeyDown:R,placeholder:b?"🎙️ Lytter...":"Hvad skal vi optimere?",disabled:y,className:"flex-1 h-10 rounded-xl"}),e.jsx(K,{onClick:()=>i(l),disabled:y||!l.trim(),size:"icon",className:"shrink-0 h-10 w-10 rounded-xl",children:e.jsx(Ls,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-3 overflow-auto",children:[e.jsxs(L,{className:"border-border/50",children:[e.jsx(B,{className:"py-2.5 px-3",children:e.jsxs(z,{className:"text-xs flex items-center gap-1.5 font-semibold",children:[e.jsx(Ge,{className:"h-3.5 w-3.5 text-primary"}),"Viden (",o.length,")"]})}),e.jsx(E,{className:"px-3 pb-3",children:e.jsx(oe,{className:"max-h-[35vh]",children:o.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ingen viden tilføjet endnu."}):e.jsx("div",{className:"space-y-1.5",children:o.map(n=>e.jsxs("div",{className:"border border-border/40 rounded-lg p-2 hover:border-primary/30 transition-colors",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:n.key}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[n.value.length," tegn"]})]},n.id))})})})]}),h.length>0&&e.jsxs(L,{className:"border-destructive/20",children:[e.jsx(B,{className:"py-2.5 px-3",children:e.jsxs(z,{className:"text-xs flex items-center gap-1.5 font-semibold",children:[e.jsx(le,{className:"h-3.5 w-3.5 text-destructive"}
5),"Huller (",h.length,")"]})}),e.jsx(E,{className:"px-3 pb-3",children:e.jsx(oe,{className:"max-h-[25vh]",children:e.jsx("div",{className:"space-y-1.5",children:h.map(n=>e.jsxs("div",{className:"border border-destructive/20 rounded-lg p-2",children:[e.jsx("p",{className:"text-xs",children:n.gap_text}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[n.frequency_count,"x i opkald"]})]},n.id))})})})]}),e.jsx(Gs,{agentId:s}),e.jsx(L,{className:"border-border/50 bg-primary/5",children:e.jsxs(E,{className:"p-3",children:[e.jsxs("p",{className:"text-xs font-semibold mb-2 flex items-center gap-1.5",children:[e.jsx(ke,{className:"h-3.5 w-3.5 text-primary"}),"Hurtig hjælp"]}),e.jsx("div",{className:"space-y-1",children:["Hvad skal vi optimere?","Optimér min agents tone og adfærd","Find videnshuller og foreslå ny viden","Gør svarene hurtigere uden at miste kvalitet"].map(n=>e.jsxs("button",{onClick:()=>i(n),className:"block w-full text-left text-[11px] text-muted-foreground hover:text-primary transition-colors py-0.5",children:["→ ",n]},n))})]})})]})]})}function zs({agentId:s,agentStatus:g,onTestCall:v}){const[k,t]=a.useState(!0),[d,l]=a.useState(null),[C,y]=a.useState(null),[I,o]=a.useState(null),[r,h]=a.useState(null),V=async()=>{t(!0);try{const x=new Date(Date.now()-864e5).toISOString(),{data:_}=await A.from("voice_brain_logs").select("error_message, latency_ms").eq("agent_id",s).gte("created_at",x).limit(200),S=_||[],f=S.filter(N=>N.error_message).length,b=S.length>0?f/S.length:0,u=S.map(N=>N.latency_ms).filter(Boolean).sort((N,w)=>N-w),m=u.length>0?u[Math.floor(u.length*.95)]:null;h(m?Math.round(m):null),g!=="active"||b>.1?l("error"):b>.03||m&&m>1200?l("degraded"):l("live");const{data:D}=await A.from("voice_calls").select("status, created_at").eq("agent_id",s).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(D){y(D.status==="completed"?"PASS":"FAIL");const N=Date.now()-new Date(D.created_at).getTime();N<6e4?o("lige nu"):N<36e5?o(`${Math.round(N/6e4)} min siden`):o(`${Math.round(N/36e5)}t siden`)}}catch{l("error")}finally{t(!1)}};return a.useEffect(()=>{V()},[s,g]),k?e.jsx(L,{children:e.jsxs(E,{className:"py-4 flex items-center gap-2",children:[e.jsx(J,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Tjekker pipeline…"})]})}):e.jsx(L,{className:`border-2 ${d==="live"?"border-green-500/30":d==="degraded"?"border-yellow-500/30":"border-destructive/30"}`,children:e.jsx(E,{className:"py-4",children:e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[d==="live"&&e.jsx(Ve,{className:"h-6 w-6 text-green-500"}),d==="degraded"&&e.jsx(le,{className:"h-6 w-6 text-yellow-500"}),d==="error"&&e.jsx(_e,{className:"h-6 w-6 text-destructive"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold text-sm",children:[d==="live"&&"Agent er live ✅",d==="degraded"&&"Agent kører med nedsat ydelse ⚠️",d==="error"&&"Agent har problemer ❌"]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[C&&e.jsxs(P,{variant:C==="PASS"?"default":"destructive",className:`text-xs ${C==="PASS"?"bg-green-600":""}`,children:["Seneste test: ",C,I&&` (${I})`]}),r!==null&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["P95: ",r,"ms"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:V,children:[e.jsx(ue,{className:"h-3.5 w-3.5 mr-1.5"}),"Tjek"]}),v&&e.jsx(K,{size:"sm",onClick:v,children:"Test nu"})]})]})})})}function Ta(){const{id:s}=Be(),{user:g}=ze(),v=qe(),{toast:k}
5=xe(),[t,d]=a.useState(null),[l,C]=a.useState(!0),[y,I]=a.useState(null),[o,r]=a.useState(!1),[h,V]=a.useState(!1),[x,_]=a.useState(0),[S,f]=a.useState(!1);a.useEffect(()=>{if(!g){v("/login");return}s&&(b(),m())},[g,s]),a.useEffect(()=>{t&&t.active_snapshot_id&&u(t.active_snapshot_id)},[t]);const b=async()=>{if(s)try{const{data:w,error:i}=await A.from("voice_agents").select("*").eq("id",s).single();if(i){console.error("Error loading agent:",i),k({title:"Fejl",description:`Kunne ikke hente agent: ${i.message}`,variant:"destructive"});return}if(!w.locked_at||!w.active_snapshot_id){v(`/voice-agent/${s}`);return}d(w)}catch(w){console.error("Error loading agent:",w),k({title:"Fejl",description:"Kunne ikke hente agent",variant:"destructive"})}finally{C(!1)}},u=async w=>{try{const{data:i,error:M}=await A.from("voice_agent_config_snapshots").select("*").eq("id",w).single();if(M)throw M;I(i)}catch(i){console.error("Failed to load snapshot:",i)}},m=async()=>{if(s)try{const{count:w,error:i}=await A.from("voice_calls").select("*",{count:"exact",head:!0}).eq("agent_id",s);!i&&w!==null&&_(w)}catch(w){console.error("Error loading calls count:",w)}},D=async()=>{if(!(!t||S)){f(!0);try{const w=async()=>A.functions.invoke("sync-elevenlabs-agent",{body:{agentId:t.id,forceRecreate:!1}});let{data:i,error:M}=await w();if(M)throw M;if(i?.requires_resync||i?.error==="MISMATCH_DELETED"){const $=await w();if(i=$.data,M=$.error,M)throw M}const{data:Y,error:ee}=await A.functions.invoke("update-elevenlabs-agent",{body:{agentId:t.id,updates:{}}});if(ee)throw ee;await A.functions.invoke("sync-content-only",{body:{agentId:t.id,syncType:"manual_refresh",source:"locked_admin_update_button"}});const{data:R,error:n}=await A.functions.invoke("test-voice-agent-setup",{body:{agentId:t.id}});if(n)throw n;const p=R?.checks||{},j=p.has_scraped_content===!0||!t.url,c=p.has_phone_number===!0,T=p.has_brain_token===!0&&p.voice_brain_responds===!0,Q=p.has_elevenlabs_agent_id===!0&&p.elevenlabs_uses_custom_llm===!0,X=Y?.critical_synced===!0,q=j&&c&&T&&Q&&X;k({title:q?"✅ Agent er opdateret og klar":"⚠️ Opdatering udført med advarsler",description:q?"Stemme, hjerne, telefon og viden er verificeret.":R?.message||Y?.issues?.join(", ")||"Åbn Test/Logs for detaljer.",variant:q?"default":"destructive"}),await Promise.all([b(),m()])}catch(w){console.error("Quick reconnect failed:",w),k({title:"Opdatering fejlede",description:w?.message||"Ukendt fejl under opdatering",variant:"destructive"})}finally{f(!1)}}},N=w=>{const i={active:{variant:"default",label:"Online"},draft:{variant:"secondary",label:"Draft"}},M=i[w]||i.draft;return e.jsx(P,{variant:M.variant,children:M.label})};return l?e.jsx(pe,{children:e.jsx("div",{className:"p-6 md:p-8 bg-background min-h-screen",children:e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx(J,{className:"w-12 h-12 animate-spin text-primary mx-auto"}),e.jsx("p",{className:"text-muted-foreground",children:"Henter agent..."})]})})})}):!t||!y?e.jsx(pe,{children:e.jsx("div",{className:"p-6 md:p-8 bg-background min-h-screen",children:e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(L,{children:e.jsxs(E,{className:"flex flex-col items-center justify-center py-12 px-8",children:[e.jsx(ne,{className:"w-12 h-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg text-muted-foreground mb-4",children:"Agent ikke fundet"}),e.jsxs(K,{onClick:()=>v("/voice-dashboard"),children:[e.jsx(Se,{className:"w-4 h-4 mr-2"}),"Tilbage til Dashboard"]})]})})})})}):e.jsxs(pe,{children:[e.jsx("div",{className:"w-full min-h-screen bg-background",children:e.jsx("div",{className:"p-6 md:p-8",children:e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6 flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(K,{variant:"ghost",onClick:()=>
5v("/voice-dashboard"),children:[e.jsx(Se,{className:"w-4 h-4 mr-2"}),"Tilbage"]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold text-foreground",children:t.name}),N(t.status),e.jsxs(P,{variant:"outline",className:"flex items-center gap-1",children:[e.jsx(Es,{className:"h-3 w-3"}),"Låst"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t.url})]})]}),e.jsxs("div",{className:"flex w-full flex-wrap items-center gap-2 md:w-auto md:justify-end",children:[e.jsxs(K,{onClick:D,disabled:S,className:"w-full sm:w-auto",children:[S?e.jsx(J,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(ue,{className:"w-4 h-4 mr-2"}),S?"Opdaterer agent…":"Opdater Agent"]}),e.jsxs(K,{variant:"default",onClick:()=>V(!0),children:[e.jsx(Ae,{className:"w-4 h-4 mr-2"}),"Test"]}),e.jsx(Je,{agentId:t.id,agentName:t.name})]})]}),e.jsx(Qe,{snapshot:y,agentName:t.name,isLocked:!0,onViewConfig:()=>r(!0),onChangeSetup:()=>v(`/voice-agent/${t.id}/setup`)}),e.jsx(zs,{agentId:t.id,agentStatus:t.status,onTestCall:()=>V(!0)}),e.jsx("div",{className:"lg:hidden",children:e.jsx(Ce,{agentId:t.id})}),e.jsx(L,{children:e.jsx(E,{className:"pt-6",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Telefon"}),e.jsx("p",{className:"font-mono text-sm text-foreground",children:y.phone_number||"Ikke konfigureret"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Is,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Stemme"}),e.jsx("p",{className:"text-sm text-foreground",children:y.voice_id||t.voice})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Opkald"}),e.jsx("p",{className:"text-sm font-semibold text-foreground",children:x})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videnbase"}),e.jsxs("p",{className:"text-sm text-foreground",children:["v",y.knowledge_version||1," • ",y.word_count||0," ord"]})]})]})]})})}),e.jsxs(be,{defaultValue:"overview",className:"space-y-4 w-full",children:[e.jsxs(we,{className:"w-full justify-start bg-card border rounded-lg p-1 overflow-x-auto flex-nowrap gap-1 h-auto",children:[e.jsxs(F,{value:"overview",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground rounded-md px-3 py-2 shrink-0 text-xs",children:[e.jsx(ye,{className:"w-3.5 h-3.5 mr-1.5"}),"Overblik"]}),e.jsxs(F,{value:"knowledge",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground rounded-md px-3 py-2 shrink-0 text-xs",children:[e.jsx(ne,{className:"w-3.5 h-3.5 mr-1.5"}),"Viden"]}),e.jsxs(F,{value:"sales",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground rounded-md px-3 py-2 shrink-0 text-xs",children:[e.jsx(Pe,{className:"w-3.5 h-3.5 mr-1.5"}),"Salg"]}),e.jsxs(F,{value:"voice",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground rounded-md px-3 py-2 shrink-0 text-xs",children:[e.jsx(me,{className:"w-3.5 h-3.5 mr-1.5"}),"Stemme"]}),e.jsxs(F,{value:"calendar",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground rounded-md px-3 py-2 shrink-0 text-xs",children:[e.jsx(Me,{className:"w-3.5 h-3.5 mr-1.5"}),"Kalender"]}),e.jsxs(F,{value:"conversations",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground rounded-md px-3 py-2 shrink-0 text-xs",children:[e.jsx(Ms,{className:"w-3.5 h-3.5 mr-1.5"}),"Samtaler"]}),e.jsxs(F,{value:"phone",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground rounded-md px-3 py-2 shrink-0 text-xs",children:[e.jsx(de,{className:"w-3.5 h-3.5 mr-1.5"}),"Telefon"]}),e.jsxs(F,{value:"test",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground rounded-md px-3 py-2 shrink-0 text-xs",children:[e.jsx(Ae,{className:"w-3.5 h-3.5 mr-1.5"}),"Test"]}),e.jsxs(F,{value:"logs",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground rounded-md px-3 py-2 shrink-0 text-xs",children:[e.jsx(Ne,{className:"w-3.5 h-3.5 mr-1.5"}),"Logs"]}),e.jsxs(F,{value:"ai-chat",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground rounded-md px-3 py-2 shrink-0 text-xs",children:[e.jsx(je,{className:"w-3.5 h-3.5 mr-1.5"}),"AI Assistent"]}),e.jsxs(F,{value:"handoff",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground rounded-md px-3 py-2 shrink-0 text-xs",children:[e.jsx(Vs,{className:"w-3.5 h-3.5 mr-1.5"}),"Viderestilling"]})]}),e.jsxs(G,{value:"overview",className:"space-y-4",children:[e.jsx(Rs,{agentId:t.id}),e.jsx(Ks,{agentId:t.id})]}),e.jsx(G,{value:"knowledge",className:"space-y-4",children:e.jsxs(L,{children:[e.jsxs(B,{children:[e.jsx(z,{children:"Tilpas Viden"}),e.jsx(ie,{children:"Tilføj og rediger custom knowledge - priser, åbningstider, FAQ osv. Base KB fra website scanning er låst og versioneret."})]}),e.jsx(E,{children:e.jsx(Xe,{agentId:t.id})})]})}),e.jsx(G,{value:"sales",className:"space-y-4",children:e.jsx(Ps,{agentId:t.id})}),e.jsx(G,{value:"voice",className:"space-y-4",children:e.jsxs(L,{children:[e.jsxs(B,{children:[e.jsx(z,{children:"Stemme
5konfiguration"}),e.jsx(ie,{children:"Tilpas stemme, velkomstbesked og samtaleparametre"})]}),e.jsx(E,{children:e.jsx(Hs,{agentId:t.id,isLocked:!0,onSave:()=>b()})})]})}),e.jsx(G,{value:"calendar",className:"space-y-4",children:e.jsx(as,{agentId:t.id})}),e.jsx(G,{value:"conversations",className:"space-y-4",children:e.jsx(rs,{agentId:t.id})}),e.jsx(G,{value:"phone",className:"space-y-4",children:e.jsx(Os,{agentPhoneNumber:y.phone_number||null,agentStatus:t.status})}),e.jsx(G,{value:"test",className:"space-y-4",children:e.jsx(ns,{agentId:t.id})}),e.jsx(G,{value:"logs",className:"space-y-4",children:e.jsx(Ye,{agentId:t.id})}),e.jsx(G,{value:"ai-chat",className:"space-y-4",children:e.jsx(Bs,{agentId:t.id,agentName:t.name})}),e.jsx(G,{value:"handoff",className:"space-y-4",children:e.jsx(is,{agentId:t.id})})]})]}),e.jsx("div",{className:"hidden lg:block w-[220px] shrink-0 sticky top-6 self-start",children:e.jsx(Ce,{agentId:t.id})})]})})}),e.jsx($s,{snapshot:y,open:o,onOpenChange:r}),e.jsx(gs,{agent:t,open:h,onOpenChange:V})]})}export{Ta 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.