1import{r as n,j as e}from"./framer-motion-CQxuJa5n.js";import{n as x,s as u,C as c,o as i,B as b}from"./index-CSx7K-7R.js";import{L as p}from"./LiveChatbotPreview-JN7fIiMd.js";import{E as f}from"./external-link-VZCHNZAP.js";import"./recharts-CFjfazL9.js";import"./ChatWidget-3-Z3gEbE.js";import"./message-circle-C_UnzPr5.js";import"./link-PqJR2IMo.js";import"./textarea-BFuIyuCd.js";import"./thumbs-up-XPFwknoP.js";import"./thumbs-down-s7Qw-kQP.js";import"./mic-off-mo8vRT9e.js";import"./send-DOJcdEwD.js";const B=()=>{const{id:a}=x(),[s,l]=n.useState(null),[d,m]=n.useState(!0);n.useEffect(()=>{a&&h()},[a]);const h=async()=>{try{console.log("Fetching chatbot with id:",a);const{data:r,error:o}=await u.rpc("get_public_chatbot",{p_chatbot_id:a});if(o)throw console.error("RPC error:",o),o;if(console.log("RPC result:",r),!r||r.length===0)console.warn("No chatbot found or chatbot is not active/published"),l(null);else{const t=r[0];console.log("Chatbot loaded successfully:",t.name),l({id:t.id,name:t.name,website_url:t.website_url,rules:t.rules,start_message:t.start_message,logo_url:t.logo_url,size:t.bot_size,position:t.bot_position,color:t.color,bot_name:t.bot_name,voice_enabled:t.voice_enabled,response_tone:t.response_tone,response_length:t.response_length,response_personality:t.response_personality})}}catch(r){console.error("Fejl ved hentning af chatbot:",r),l(null)}finally{m(!1)}};return d?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary"})}):s?e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[e.jsx("div",{className:"border-b border-border bg-card sticky top-0 z-10",children:e.jsx("div",{className:"container mx-auto px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-between gap-3 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:s.color},children:s.logo_url?e.jsx("img",{src:s.logo_url,alt:s.name,className:"w-6 h-6 object-contain rounded"}):e.jsx(i,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-base font-bold",children:s.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Test AI Chatbot"})]})]}),e.jsxs(b,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>{const r=s.website_url?.startsWith("http")?s.website_url:`https://${s.website_url}`;window.open(r,"_blank")},children:[e.jsx(f,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Besøg hjemmeside"})]})]})})}),e.jsx("div",{className:"flex-1 container mx-auto px-4 py-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto h-full",children:[e.jsx(c,{className:"h-[calc(100vh-140px)] flex flex-col overflow-hidden",children:e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(p,{chatbotId:s.id,config:{size:"medium",position:"bottom-right",color:s.color,botName:s.bot_name,voiceEnabled:s.voice_enabled,startMessage:s.start_message||void 0,logoUrl:s.logo_url||void 0},alwaysOpen:!0,isPreviewMode:!0})})}),e.jsx("div",{className:"mt-3 text-center",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx(i,{className:"w-4 h-4 inline mr-1"}),"Trænet på data fra"," ",(()=>{const r=s.website_url,o=r?.startsWith("http")?r:r?`https://${r}`:void 0,t=o?new URL(o).hostname:r;return e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline font-medium",children:t})})()]})})]})})]}):e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs(c,{className:"max-w-md p-8 text-center",children:[e.jsx(i,{className:"w-16 h-16 mx-auto mb-4 text-muted-foreground"}),e.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Chatbot ikke tilgængelig"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Denne chatbot eksisterer ikke, er ikke aktiv, eller er blevet slettet."}),e.jsxs("div",{className:"bg-muted p-4 rounded-lg text-left",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:e.jsx("strong",{children:"Mulige årsager:"})}),e.jsxs("ul",{className:"text-sm text-muted-foreground mt-2 space-y-1",children:[e.jsx("li",{children:"⢠Chatbotten er ikke udgivet (is_active = false)"}),e.jsx("li",{children:"⢠Chatbotten er sat på pause"}),e.jsx("li",{children:"⢠Chatbotten er blevet slettet"}),e.jsx("li",{children:"⢠Du har ikke adgang til denne chatbot"})]})]})]})})};export{B 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.