PageSourceSearch

https://platform.unago.ai/assets/ChatbotEmbedPage-DRcWiNjt.js

js unago.ai collected 2026-10-05 13:13:06 UTC 4,029 bytes, 1 lines download raw bytes

1import{o as m}from"./rolldown-runtime-ChpBd9eV.js";import{a as f,n as x}from"./vendor-react-DcWoBPJp.js";import{p as g}from"./chunk-QUQL4437-DKXSrjJr.js";import{n as h,t as u}from"./VoiceChatPanel-Bc4aUBIR.js";var i=m(f(),1);async function v(t,r){const a=await fetch("/chatbot/init",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":t},body:JSON.stringify({metadata:r||{}})});if(!a.ok){const o=await a.text();throw new Error(`Init failed (${a.status}): ${o}`)}return a.json()}function p(t,r){const[a,o]=(0,i.useState)({loading:!1,error:null,sessionToken:null,conversationId:null,mode:"text",welcomeMessage:"Hello! How can I help you today?",suggestedPrompts:[],branding:{displayName:"Assistant",primaryColor:"#6366f1"},voiceConfig:{}}),d=(0,i.useCallback)(async()=>{if(!t){o(s=>({...s,error:"No API key provided."}));return}o(s=>({...s,loading:!0,error:null}));try{const s=await v(t,r);o(n=>({...n,loading:!1,sessionToken:s.sessionToken,conversationId:s.conversationId,mode:s.mode||"text",welcomeMessage:s.welcomeMessage||n.welcomeMessage,suggestedPrompts:s.suggestedPrompts||[],branding:s.branding||n.branding,voiceConfig:{...n.voiceConfig,...s.voiceConfig,avatarId:s.avatarConfig?.avatarId||s.voiceConfig?.avatarId||n.voiceConfig.avatarId,avatarProvider:s.avatarConfig?.provider||n.voiceConfig.avatarProvider,avatarShape:s.avatarConfig?.avatarShape||n.voiceConfig.avatarShape}}))}catch(s){const n=s instanceof Error?s.message:"Failed to initialize chatbot session.";o(l=>({...l,loading:!1,error:n}))}},[t,r]);return(0,i.useEffect)(()=>{d()},[d]),a}var e=x();function b(){return(0,e.jsx)("div",{className:"flex items-center justify-center h-screen bg-white dark:bg-gray-900",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-indigo-500 mx-auto mb-3"}),(0,e.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Connecting..."})]})})}function c({message:t}){return(0,e.jsx)("div",{className:"flex items-center justify-center h-screen bg-white dark:bg-gray-900",children:(0,e.jsxs)("div",{className:"text-center px-6",children:[(0,e.jsx)("div",{className:"text-red-500 text-4xl mb-3","aria-hidden":"true",children:"!"}),(0,e.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:t})]})})}function y({welcomeMessage:t,branding:r}){return(0,e.jsxs)("div",{className:"flex flex-col h-screen bg-white dark:bg-gray-900",children:[(0,e.jsx)("div",{className:"flex items-center px-4 py-3 text-white flex-shrink-0",style:{backgroundColor:r.primaryColor||"#6366f1"},children:(0,e.jsx)("span",{className:"font-semibold text-sm",children:r.displayName||"Assistant"})}),(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center px-6",children:(0,e.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400 text-center",children:t})}),(0,e.jsxs)("div",{className:"text-center py-2 text-xs text-gray-400 flex-shrink-0",children:["Powered by ",(0,e.jsx)("a",{href:"https://hyperionwave.com",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"UnaGo"})]})]})}function j(t){return t?`chatbot-${t}`:`chatbot-${Date.now()}`}function I(){const[t]=g(),r=t.get("apiKey"),a=p(r);return r?a.loading?(0,e.jsx)(b,{}):a.error?(0,e.jsx)(c,{message:a.error}):a.sessionToken?a.mode==="voice_avatar"?(0,e.jsx)("div",{className:"h-screen w-screen",children:(0,e.jsx)(h,{sessionToken:a.sessionToken,roomName:j(a.conversationId),voiceId:a.voiceConfig.voiceId,faceId:a.voiceConfig.avatarId,avatarProvider:a.voiceConfig.avatarProvider,avatarShape:a.voiceConfig.avatarShape,className:"h-full w-full rounded-none"})}):a.mode==="voice"?(0,e.jsx)("div",{className:"h-screen w-screen",children:(0,e.jsx)(u,{sessionToken:a.sessionToken,className:"h-full w-full rounded-none"})}):(0,e.jsx)(y,{welcomeMessage:a.welcomeMessage,branding:a.branding}):(0,e.jsx)(c,{message:"Failed to establish session."}):(0,e.jsx)(c,{message:"Missing apiKey query parameter."})}export{I as ChatbotEmbedPage};

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.