PageSourceSearch

https://agentoai.dk/assets/SalesChatbot-BXxq7oEG.js

js agentoai.dk collected 2026-10-02 01:55:29 UTC 8,451 bytes, 3 lines download raw bytes

1import{r as t,j as e}from"./framer-motion-CQxuJa5n.js";import{B as i,C as O,c as K,E as Q,Y as W,o as T,p as B,I as d,d as Y,t as D}from"./index-CSx7K-7R.js";import{B as G}from"./badge-Yar_qzGV.js";import{S as X}from"./scroll-area-THRv4UVm.js";import{l as Z}from"./logDemoAttempt-DHwYjiNd.js";import{M as q}from"./message-circle-C_UnzPr5.js";import{M as ee}from"./minimize-2-CnaVaSse.js";import{M as se}from"./maximize-2-COb4vDPT.js";import{U as E}from"./user-DwnLXD35.js";import{M as ae}from"./mail-CQVr-2Yp.js";import{P as te}from"./phone-DfeYL_-y.js";import{S as re}from"./send-DOJcdEwD.js";import"./recharts-CFjfazL9.js";import"./index-CwKDC_mg.js";import"./index-BdQq_4o_.js";const ne="https://lhplkrosdckrjrfeaoan.supabase.co/functions/v1/website-sales-chat",le=["Hvad koster en AI Voice Agent?","Kan I hjælpe min branche?","Hvordan kommer jeg i gang?","Book en gratis demo"];function we(){const[g,C]=t.useState(!1),[m,R]=t.useState(!1),[o,h]=t.useState([{role:"assistant",content:"Hej! 👋 Jeg er AgentoAI - din guide til AI Voice Agents. Jeg kan svare på alt om vores løsninger, priser og brancher. Hvad kan jeg hjælpe dig med i dag?"}]),[p,I]=t.useState(""),[c,A]=t.useState(!1),[a,u]=t.useState({}),[L,j]=t.useState(!1),[U]=t.useState(()=>crypto.randomUUID()),x=t.useRef(null),b=t.useRef(null);t.useEffect(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},[o]),t.useEffect(()=>{g&&b.current&&b.current.focus()},[g]);const z=async s=>{const f={role:"user",content:s};h(n=>[...n,f]),A(!0),I("");let v="";try{const n=await fetch(ne,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer sb_publishable_VaRxlTJflLmIKI_3fWbMkA_ON9YaoZt"},body:JSON.stringify({messages:[...o,f],visitor_info:a,session_id:U})});if(!n.ok||!n.body)throw new Error("Stream failed");const N=n.body.getReader(),J=new TextDecoder;let l="";for(h(w=>[...w,{role:"assistant",content:""}]);;){const{done:w,value:V}=await N.read();if(w)break;l+=J.decode(V,{stream:!0});let k;for(;(k=l.indexOf(`
2`))!==-1;){let r=l.slice(0,k);if(l=l.slice(k+1),r.endsWith("\r")&&(r=r.slice(0,-1)),r.startsWith(":")||r.trim()===""||!r.startsWith("data: "))continue;const M=r.slice(6).trim();if(M==="[DONE]")break;try{const _=JSON.parse(M).choices?.[0]?.delta?.content;_&&(v+=_,h(F=>{const S=[...F];return S[S.length-1]={role:"assistant",content:v},S}))}catch{l=r+`
3`+l;break}}}const y=v.toLowerCase();(y.includes("email")||y.includes("kontakt")||y.includes("tilbud"))&&!a.email&&setTimeout(()=>j(!0),1500)}catch(n){console.error("Chat error:",n),D.error("Kunne ikke sende besked. Prøv igen."),h(N=>N.slice(0,-1))}finally{A(!1)}},H=s=>{s.preventDefault(),!(!p.trim()||c)&&z(p.trim())},P=s=>{z(s)},$=s=>{s.preventDefault(),j(!1),(a.email||a.phone)&&(Z({source:"sales_chatbot_contact",demo_type:"chat",name:a.name||"Forside chat",email:a.email||void 0,phone:a.phone||void 0,company_name:a.company||void 0,callback_wanted:!!a.phone,notes:a.phone?"SalesChatbot — telefon efterladt (callback)":"SalesChatbot — kontaktinfo efterladt",force:!0}),D.success("Tak! Nu kan vi følge op på din henvendelse."))};return g?e.jsxs(O,{className:`fixed z-50 shadow-2xl border-primary/20 transition-all duration-300 ${m?"inset-4 md:inset-8":"bottom-6 right-6 w-[380px] h-[600px] md:w-[420px] md:h-[650px]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b bg-gradient-to-r from-primary/10 to-primary/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:K,alt:"Agento",className:"h-8 w-8"}),e.jsx("span",{className:"absolute bottom-0 right-0 h-2.5 w-2.5 bg-green-500 rounded-full border-2 border-background"})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:["AgentoAI",e.jsxs(G,{variant:"secondary",className:"text-xs",children:[e.jsx(Q,{className:"h-3 w-3 mr-1"}),"Online"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Din AI salgsassistent"})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(i,{variant:"ghost",size:"icon",onClick:()=>R(!m),className:"h-8 w-8",children:m?e.jsx(ee,{className:"h-4 w-4"}):e.jsx(se,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"icon",onClick:()=>C(!1),className:"h-8 w-8",children:e.jsx(W,{className:"h-4 w-4"})})]})]}),e.jsx(X,{className:`flex-1 p-4 ${m?"h-[calc(100%-180px)]":"h-[400px] md:h-[450px]"}`,ref:x,children:e.jsxs("div",{className:"space-y-4",children:[o.map((s,f)=>e.jsxs("div",{className:`flex gap-3 ${s.role==="user"?"justify-end":"justify-start"}`,children:[s.role==="assistant"&&e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(T,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:`max-w-[80%] rounded-2xl px-4 py-2.5 ${s.role==="user"?"bg-primary text-primary-foreground rounded-br-md":"bg-muted rounded-bl-md"}`,children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:s.content})}),s.role==="user"&&e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary flex items-center justify-center flex-shrink-0",children:e.jsx(E,{className:"h-4 w-4 text-primary-foreground"})})]},f)),c&&o[o.length-1]?.role==="user"&&e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(T,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"bg-muted rounded-2xl rounded-bl-md px-4 py-3",children:e.jsx(B,{className:"h-4 w-4 animate-spin"})})]}),o.length===1&&!c&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Populære spørgsmål:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:le.map(s=>e.jsx(i,{variant:"outline",size:"sm",onClick:()=>P(s),className:"text-xs h-auto py-1.5",children:s},s))})]}),L&&e.jsx(O,{className:"p-4 bg-primary/5 border-primary/20",children:e.jsxs("form",{onSubmit:$,className:"space-y-3",children:[e.jsx("p",{className:"text-sm font-medium",children:"Få et personligt tilbud:"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(E,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(d,{placeholder:"Dit navn",className:"pl-10 h-9",value:a.name||"",onChange:s=>u({...a,name:s.target.value})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(ae,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(d,{type:"email",placeholder:"Email",className:"pl-10 h-9",value:a.email||"",onChange:s=>u({...a,email:s.target.value})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(d,{type:"tel",placeholder:"Telefon",className:"pl-10 h-9",value:a.p
3hone||"",onChange:s=>u({...a,phone:s.target.value})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Y,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(d,{placeholder:"Virksomhed",className:"pl-10 h-9",value:a.company||"",onChange:s=>u({...a,company:s.target.value})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(i,{type:"submit",size:"sm",className:"flex-1",children:"Gem & fortsæt"}),e.jsx(i,{type:"button",variant:"ghost",size:"sm",onClick:()=>j(!1),children:"Senere"})]})]})})]})}),e.jsxs("form",{onSubmit:H,className:"p-4 border-t",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{ref:b,value:p,onChange:s=>I(s.target.value),placeholder:"Skriv din besked...",disabled:c,className:"flex-1"}),e.jsx(i,{type:"submit",disabled:c||!p.trim(),size:"icon",children:c?e.jsx(B,{className:"h-4 w-4 animate-spin"}):e.jsx(re,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground text-center mt-2",children:["Drevet af AgentoAI • ",e.jsx("a",{href:"/privatlivspolitik",className:"underline",children:"Privatlivspolitik"})]})]})]}):e.jsx(i,{onClick:()=>C(!0),"data-chatbot-trigger":!0,className:"fixed bottom-6 right-6 z-50 h-16 w-16 rounded-full shadow-2xl bg-primary hover:bg-primary/90 animate-bounce",size:"icon",children:e.jsxs("div",{className:"relative",children:[e.jsx(q,{className:"h-7 w-7"}),e.jsx("span",{className:"absolute -top-1 -right-1 h-3 w-3 bg-green-500 rounded-full animate-pulse"})]})})}export{we 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.