@voxket-ai/voxket-live 1.1.56 → 1.1.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -201,7 +201,7 @@ Please add this import to your app:
201
201
  %cimport '@voxket-ai/voxket-live/style.css';
202
202
 
203
203
  %cOr in your HTML:
204
- %c<link rel="stylesheet" href="node_modules/@voxket-ai/voxket-live/dist/index.css">`,"color: #f59e0b; font-size: 14px; font-weight: bold;","color: #fbbf24; font-size: 12px;","color: #22c55e; font-size: 12px; font-family: monospace; background: #1e293b; padding: 4px 8px; border-radius: 4px;","color: #fbbf24; font-size: 12px;","color: #22c55e; font-size: 11px; font-family: monospace; background: #1e293b; padding: 4px 8px; border-radius: 4px;"))}Ve.create(mm);Ve.create(eu);Ve.create(xT);Ve.create(Cm);function KA({theme:e,mode:t,loadingText:n,sessionState:i}){const r=wn(e),s=()=>{if(i==="connected")return"Connecting to agent...";if(n)return n;switch(t){case"voice":return"Connecting to voice agent...";case"chat":return"Starting chat session...";default:return"Connecting..."}};return m.jsxs("div",{className:"flex flex-col items-center justify-center h-full w-full p-8",children:[m.jsxs("div",{className:"text-center",children:[m.jsx("h3",{className:`text-lg font-semibold mb-2 ${r.text.accent}`,children:s()}),m.jsx("p",{className:`text-sm ${r.text.muted}`,children:"Please wait a moment..."})]}),m.jsxs("div",{className:"flex space-x-1 mt-4",children:[m.jsx("div",{className:"w-2 h-2 rounded-full animate-bounce bg-blue-500",style:{animationDelay:"0ms"}}),m.jsx("div",{className:"w-2 h-2 rounded-full animate-bounce bg-blue-500",style:{animationDelay:"150ms"}}),m.jsx("div",{className:"w-2 h-2 rounded-full animate-bounce bg-blue-500",style:{animationDelay:"300ms"}})]})]})}Ve.create(KA);function eh({theme:e}){const t=e==="light";return m.jsxs("div",{className:`absolute bottom-0 font-bold left-0 right-0 z-20 flex-shrink-0 text-center py-1 px-2 text-[10px] ${t?"text-gray-400 bg-white/80":"text-white/40 bg-black/40"}`,style:{lineHeight:"1.2",backdropFilter:"blur(4px)"},children:[m.jsx("span",{children:"Powered by "}),m.jsx("a",{href:"https://voxket.ai",target:"_blank",rel:"noopener noreferrer",className:`hover:underline font-bold ${t?"text-gray-500":"text-white/50"}`,children:"voxket.ai"}),m.jsx("span",{className:"mx-1",children:"·"}),m.jsx("span",{children:"AI can make mistakes"})]})}function wx({children:e,theme:t,displayType:n="widget",onClose:i,popupPosition:r="bottom-right",onExpand:s,width:o,height:a}){const c=wn(t),l=o||"350px",u=a||"500px";if(n==="fullscreen")return m.jsx("div",{className:"fixed inset-0 z-[9999] bg-black/40 bg-opacity-30 backdrop-blur-sm flex items-center justify-center p-8",onClick:d=>{d.target===d.currentTarget&&i&&i()},children:m.jsxs("div",{className:"w-full h-full max-w-7xl max-h-[95vh] rounded-2xl relative bg-transparent flex flex-col",onClick:d=>{d.stopPropagation()},children:[i&&m.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),i()},className:`absolute top-4 cursor-pointer right-4 z-[10000] w-12 h-12 rounded-full flex items-center justify-center transition-all duration-200 shadow-lg border backdrop-blur-sm ${t==="light"?"bg-white bg-opacity-90 text-gray-900 hover:bg-gray-100 border-gray-300":"bg-gray-900 bg-opacity-90 text-white hover:bg-gray-800 border-gray-700"}`,title:"Exit Fullscreen",type:"button",children:m.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:m.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),m.jsxs("div",{id:"voice-card",className:`voxket-widget-root theme-${t} ${c.card} w-full h-full flex flex-col rounded-xl shadow-2xl relative overflow-hidden`,"data-theme":t,style:{minHeight:"600px",height:"100%",contain:"layout style paint",overscrollBehavior:"contain",backgroundColor:t==="midnight"?"#161a25":void 0},children:[m.jsx("div",{className:c.cardTopGradient}),m.jsx("div",{className:c.cardPurpleBlur}),m.jsx("div",{className:c.cardPinkBlur}),m.jsx("div",{className:"relative z-10 flex flex-col h-full",style:{flex:"1 1 auto"},children:e}),m.jsx(eh,{theme:t}),m.jsx("div",{className:c.cardPulse1}),m.jsx("div",{className:c.cardPulse2,style:{animationDelay:"1s"}})]})]})});if(n==="popup"){const d={"top-left":"top-4 left-4","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-right":"bottom-4 right-4"};return m.jsx("div",{className:"fixed rounded-2xl inset-0 z-[9999] pointer-events-none",children:m.jsxs("div",{className:`fixed rounded-2xl ${d[r]} pointer-events-auto`,children:[i&&m.jsx("button",{onClick:i,className:`absolute -top-2 -right-2 z-10 w-8 h-8 rounded-full flex items-center justify-center transition-all duration-200 text-sm shadow-lg border ${t==="light"?"bg-white bg-opacity-90 text-gray-900 hover:bg-gray-100 border-gray-300":"bg-gray-900 bg-opacity-90 text-white hover:bg-gray-800 border-gray-700"}`,children:"×"}),m.jsxs("div",{id:"voice-card",className:`voxket-widget-root voxket-popup-mode theme-${t} ${c.card} rounded-2xl flex flex-col relative overflow-hidden`,"data-theme":t,"data-display-type":"popup",style:{width:l,height:u,minWidth:l,maxWidth:l,minHeight:u,maxHeight:u,contain:"layout style paint",overscrollBehavior:"contain",backgroundColor:t==="midnight"?"#161a25":void 0,display:"flex",flexDirection:"column"},children:[m.jsx("div",{className:c.cardTopGradient}),m.jsx("div",{className:c.cardPurpleBlur}),m.jsx("div",{className:c.cardPinkBlur}),m.jsx("div",{className:"relative z-10 flex flex-col w-full min-h-0 overflow-hidden voxket-popup-content",style:{display:"flex",flexDirection:"column",flex:"1 1 auto"},children:e}),m.jsx(eh,{theme:t}),m.jsx("div",{className:c.cardPulse1}),m.jsx("div",{className:c.cardPulse2,style:{animationDelay:"1s"}})]})]})})}return m.jsxs("div",{id:"voice-card",className:`voxket-widget-root theme-${t} ${c.card} relative overflow-hidden w-full h-full`,"data-theme":t,style:{height:"100%",maxHeight:"100%",contain:"layout style paint",overscrollBehavior:"contain",backgroundColor:t==="midnight"?"#161a25":void 0},children:[m.jsx("div",{className:c.cardTopGradient}),m.jsx("div",{className:c.cardPurpleBlur}),m.jsx("div",{className:c.cardPinkBlur}),m.jsx("div",{className:"relative z-10 flex flex-col h-full w-full",style:{flex:"1 1 auto"},children:e}),m.jsx(eh,{theme:t}),m.jsx("div",{className:c.cardPulse1}),m.jsx("div",{className:c.cardPulse2,style:{animationDelay:"1s"}})]})}function vq(e){if(typeof window>"u")return null;D.useEffect(()=>{HA()},[]);const{agentId:t,participantName:n,baseUrl:i,appSecret:r,appId:s,authToken:o,prompts:a,statusMessage:c,welcomeTitle:l,welcomeSubTitle:u,className:d,width:h,height:f,loadingText:g,suportsChatInput:p=!0,suportsVideoInput:x=!0,suportsScreenShare:v=!0,theme:E="vox",onSessionStart:w,onSessionEnd:k,enableSessionLogging:y=!0,onSessionLogsUpdate:S,onSessionMetricsUpdate:I,modalities:T=["voice"],displayType:_="widget",popupPosition:b="bottom-right",popupTriggerText:R="Open Chat",onPopupToggle:P,voxketClient:L,onDisplayTypeChange:F,participantMetadata:V,popupModalityMode:Y="all",popupTriggerLogoUrl:se}=e,[G,q]=D.useState(!1),[C,H]=D.useState(null),[J,A]=D.useState(()=>{try{if(L)return!!L.getCurrentSession()}catch(be){const N=new oe("Error checking existing session","UNKNOWN_ERROR",be);ce.error(N)}return!1}),[ee,te]=D.useState(!1),[ae,ie]=D.useState(t||""),[X,fe]=D.useState(n||"User"),[re,Be]=D.useState(()=>{try{if(L)return L.getCurrentSession()}catch(be){const N=new oe("Error getting current session","UNKNOWN_ERROR",be);ce.error(N)}return null}),[ne,$]=D.useState(()=>{var be,N;try{if(L){const j=L.getCurrentSession();if((be=j==null?void 0:j.activeModalities)!=null&&be.includes("chat"))return"chat";if((N=j==null?void 0:j.activeModalities)!=null&&N.includes("voice"))return"voice"}}catch(j){const pe=new oe("Error determining current mode","UNKNOWN_ERROR",j);ce.error(pe)}return"welcome"}),[Re,Ke]=D.useState(!1),[ge,Te]=D.useState(!1),[_e,Fe]=D.useState(()=>T.length===1?T[0]:null),[Ue,zt]=D.useState(!1);D.useEffect(()=>{},[_]);const Pt=D.useRef(null);if(!Pt.current)try{if(L)Pt.current=L;else if(!o&&(!s||!r)){const be="Missing required props: Either provide 'authToken' or both 'appId' and 'appSecret'",N=new oe(be,"UNKNOWN_ERROR");ce.error(N),H(new Error(be)),q(!0)}else if(i){const be={...o?{authToken:o}:{appId:s,appSecret:r},baseUrl:i,agentId:ae,participantName:X||"User",modalities:T,participantMetadata:V};Pt.current=new Oa(be)}else{const be="Missing required prop: baseUrl",N=new oe(be,"UNKNOWN_ERROR");ce.error(N),H(new Error(be)),q(!0)}}catch(be){const N=new oe("Failed to create VoxketClient","UNKNOWN_ERROR",be);ce.error(N),H(be),q(!0)}const ve=Pt.current;D.useEffect(()=>{const be=Pt.current;return()=>{be&&!L&&be.disconnect().catch(N=>{const j=new oe("Error during widget cleanup disconnect","UNKNOWN_ERROR",N);ce.error(j)})}},[L]);const At=D.useMemo(()=>_==="popup"&&_e?[_e]:T,[_,_e,T]),ut=D.useMemo(()=>{try{return ve?ve.getRoom()||new Hi:new Hi}catch(be){const N=new oe("Error getting room from client","UNKNOWN_ERROR",be);return ce.error(N),new Hi}},[ve,J,ne]);D.useEffect(()=>{if(ut){const be=()=>{},N=(j,pe,Ne)=>{};return ut.on(U.Connected,be),ut.on(U.Disconnected,be),ut.on(U.TrackSubscribed,N),()=>{ut.off(U.Connected,be),ut.off(U.Disconnected,be),ut.off(U.TrackSubscribed,N)}}},[ut,re==null?void 0:re.id]),D.useEffect(()=>{(ne==="voice"||ne==="chat")&&!re&&!J&&!ee&&ve&&!ve.connected&&($("welcome"),te(!1))},[ne,re,J,ee,ve]);const{sessionMetrics:K,sessionLogs:de,logEvent:Oe}=jT({room:ut,onSessionStart:w,onSessionEnd:k,enableConsoleLogging:y,enableLocalStorage:y,voxketSessionId:re==null?void 0:re.id});D.useEffect(()=>{S&&S(de)},[de,S]),D.useEffect(()=>{I&&K&&I(K)},[K,I]),D.useEffect(()=>{if(!ve)return;const be=(N,j)=>{(N==="connecting"||N==="connected")&&(ee||te(!0)),N==="active"&&(te(!1),A(!0)),(N==="disconnected"||N==="error")&&(te(!1),A(!1),Be(null),$("welcome"))};return ve.on("session.state.changed",be),()=>{ve.off("session.state.changed",be)}},[ve,ee]),D.useEffect(()=>{if(!ve)return;const be=()=>{const N=ve.connected,j=ve.getCurrentSession();!N&&J&&!ee&&(te(!1),A(!1),Be(null),$("welcome")),N&&j&&ee&&(te(!1),A(!0),Be(j))};return ve.on("connectionStateChanged",be),ve.on("sessionEnded",()=>{te(!1),A(!1),Be(null),$("welcome")}),()=>{ve.off("connectionStateChanged",be),ve.off("sessionEnded",()=>{})}},[ve,ne,ee,J]);const it=!!(!!(ve!=null&&ve.connected)&&J&&re);D.useEffect(()=>{const be=j=>{te(!1),A(!1),Be(null),$("welcome")},N=j=>{const pe=new oe("Media devices error","UNKNOWN_ERROR",j);ce.error(pe)};return ut.on(U.MediaDevicesError,N),ut.on(U.Disconnected,be),()=>{ut.off(U.Disconnected,be),ut.off(U.MediaDevicesError,N)}},[ut,ne,J,re==null?void 0:re.id,ee]);const fn=async()=>{try{if(!ve){const N=new oe("VoxketClient not initialized","UNKNOWN_ERROR");ce.error(N),H(new Error("VoxketClient not initialized")),q(!0);return}te(!0),$("voice"),Oe("USER_STARTED_VOICE_SESSION",{agentId:ae,participantName:X});const be=await ve.startSession(ae,{participantName:X||"User",modalities:["voice"],participantMetadata:ve.getParticipantMetadata()||V});Be(be),A(!0),te(!1),w&&w(be.id)}catch(be){const N=new oe("Failed to start voice session","UNKNOWN_ERROR",be);ce.error(N),te(!1),A(!1),$("welcome")}},Xn=async()=>{try{if(!ve){const N=new oe("VoxketClient not initialized","UNKNOWN_ERROR");ce.error(N),H(new Error("VoxketClient not initialized")),q(!0);return}te(!0),$("chat"),Oe("USER_STARTED_CHAT_SESSION",{agentId:ae,participantName:X});const be=await ve.startSession(ae,{participantName:X||"User",modalities:["chat"],participantMetadata:ve.getParticipantMetadata()||V});Be(be),A(!0),te(!1),w&&w(be.id)}catch(be){const N=new oe("Failed to start chat session","UNKNOWN_ERROR",be);ce.error(N),te(!1),A(!1),$("welcome")}},pn=()=>{$("welcome"),te(!1),F&&F(e.displayType||"widget"),re&&J?(A(!1),Be(null),ve&&ve.disconnect().catch(be=>{const N=new oe("Widget: Error during disconnect","UNKNOWN_ERROR",be);ce.error(N)})):ve&&ve.connected&&ve.disconnect().catch(be=>{const N=new oe("Widget: Error during force disconnect","UNKNOWN_ERROR",be);ce.error(N)}),_==="popup"&&!Re&&Ke(!0)},Un=()=>{const be=!Re;Ke(be),P&&P(be),!be&&!(re&&J)&&($("welcome"),A(!1),Be(null))},Ii=()=>{e.onDisplayTypeChange&&e.onDisplayTypeChange("widget")},nn=()=>{if(e.onDisplayTypeChange)e.onDisplayTypeChange("fullscreen");else{const be=document.getElementById("voice-card")||document.querySelector(".voxket-widget-container");be&&be.requestFullscreen&&be.requestFullscreen().catch(N=>{})}};D.useEffect(()=>{var be,N;if(L&&ve){const j=ve.getCurrentSession();ve.connected,j&&(Be(j),A(!0),te(!1),(be=j.activeModalities)!=null&&be.includes("chat")?$("chat"):(N=j.activeModalities)!=null&&N.includes("voice")&&$("voice"))}},[L,ve]),D.useEffect(()=>()=>{!L&&ve&&ve.disconnect()},[ve,L]);let jn="w-96",rn="h-[25rem]",os={};if(h&&(h.startsWith("w-")?jn=h:(os.width=h,jn="")),f&&(f.startsWith("h-")?rn=f:(os.height=f,rn="")),_==="popup"&&!Re)return m.jsxs(m.Fragment,{children:[m.jsx(UT,{onClick:()=>{if(it){!_e&&(re!=null&&re.activeModalities)&&(re.activeModalities.includes("chat")?Fe("chat"):re.activeModalities.includes("voice")&&Fe("voice")),Te(!1),Ke(!0),P&&P(!0);return}if(Y!=="all"){Fe(Y),Te(!1),Ke(!0),P&&P(!0);return}if(T.length===1){Fe(T[0]),Te(!1),Ke(!0),P&&P(!0);return}Te(be=>!be),Fe(null),zt(!1)},position:b,ariaLabel:R,size:64,isRunning:it,logoUrl:se,theme:E}),ge&&Y==="all"&&(()=>{const j={};b==="bottom-right"?(j.bottom=88,j.right=16):b==="bottom-left"?(j.bottom=88,j.left=16):b==="top-right"?(j.top=88,j.right=16):(j.top=88,j.left=16);const pe="absolute w-0 h-0 border-8",Ne=E==="light",Rt=Ne?"border-t-white":"border-t-black",_t=Ne?"border-b-white":"border-b-black",we=b.startsWith("bottom")?m.jsx("div",{className:`${pe} border-transparent ${Rt}`,style:{bottom:-16,right:b.endsWith("right")?16:void 0,left:b.endsWith("left")?16:void 0}}):m.jsx("div",{className:`${pe} border-transparent ${_t}`,style:{top:-16,right:b.endsWith("right")?16:void 0,left:b.endsWith("left")?16:void 0}}),xe=Ne?"bg-white text-gray-900 border-[2px] border-indigo-200/60 shadow-2xl shadow-indigo-200/30":"bg-black text-white shadow-2xl",De=Ne?"bg-indigo-50 hover:bg-indigo-100 text-indigo-700 border border-indigo-200/50":"bg-white/10 hover:bg-white/20 text-white",Gt=Ne?"text-gray-500":"text-white/70";return m.jsx("div",{className:`fixed z-[51] rounded-2xl ${xe}`,style:{...j,padding:"10px"},children:m.jsxs("div",{className:"relative ",children:[we,m.jsx("div",{className:`text-xs uppercase tracking-wide mb-2 ${Gt}`,children:"Choose modality"}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("button",{type:"button",onClick:()=>{Fe("voice"),Te(!1),Ke(!0),P&&P(!0)},className:`px-3 py-2 rounded-md text-sm transition-colors ${De}`,title:"Voice",children:"Voice"}),m.jsx("button",{type:"button",onClick:()=>{Fe("chat"),Te(!1),Ke(!0),P&&P(!0)},className:`px-3 py-2 rounded-md text-sm transition-colors ${De}`,title:"Chat",children:"Chat"})]})]})})})()]});if(G||!ve){const be=(C==null?void 0:C.message)||"VoxketWidget encountered an error. Please check your configuration.";return m.jsx("div",{className:`voxket-widget-root theme-${E} flex items-center justify-center p-8 ${d||""}`,style:{width:h||"400px",height:f||"500px",border:"1px solid #ff4444",borderRadius:"8px",background:"#fff5f5",color:"#cc0000"},children:m.jsxs("div",{className:"text-center",children:[m.jsx("div",{className:"text-4xl mb-4",children:"⚠️"}),m.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Widget Error"}),m.jsx("p",{className:"text-sm mb-4",children:be}),m.jsx("button",{onClick:()=>{q(!1),H(null),window.location.reload()},className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors",children:"Retry"})]})})}let as=`voxket-widget-root theme-${E}`,cs={scrollMargin:0,scrollPadding:0,contain:"layout style paint"};_==="widget"?(as+=` flex min-h-fit ${jn} ${rn} ${d}`,cs={...cs,...os}):(as=`${d||""}`,cs={});const go=m.jsx("div",{className:"h-full w-full flex flex-col overflow-hidden z-10",children:m.jsxs(qs,{mode:"wait",children:[ne==="welcome"&&!ee&&m.jsx(Ve.div,{initial:{opacity:0,y:0},animate:{opacity:1,y:0},exit:{opacity:0,y:40},transition:{duration:.3,ease:"easeInOut"},className:"h-screen w-full",style:{height:"100%"},children:m.jsx(Cm,{agentId:ae,participantName:X||"",onAgentIdChange:ie,onParticipantNameChange:fe,onStartCall:fn,onStartChat:Xn,disabled:J||ee,prompts:a,statusMessage:c,title:l,subTitle:u,theme:E,modalities:At})},"welcome"),ee&&(ne==="voice"||ne==="chat")&&m.jsx(Ve.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.3,ease:"easeInOut"},className:"h-screen w-full",style:{height:"100%"},children:m.jsx(KA,{theme:E,mode:ne,loadingText:g,sessionState:re==null?void 0:re.state})},`loading-${ne}`),ne==="voice"&&!ee&&J&&ve&&m.jsxs(Wp.Provider,{value:ut,children:[m.jsx(tB,{},`audio-${(re==null?void 0:re.id)||"no-session"}`),m.jsx(QL,{label:"Start Audio"},`start-audio-${(re==null?void 0:re.id)||"no-session"}`),m.jsx(Ve.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"},className:"h-screen w-full",style:{height:"100%"},children:m.jsx(mm,{loadingText:g,participantName:X||"User",sessionStarted:J,disabled:!1,theme:E,client:ve,displayType:_,onBack:_==="popup"?Un:pn})},"voice-session")]}),ne==="chat"&&!ee&&J&&ve&&m.jsx(Ve.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"},className:"h-screen w-full",style:{height:"100%"},children:m.jsx(eu,{client:ve,theme:E,displayType:_,onBack:_==="popup"?Un:pn,onEndChat:pn,disabled:!1})},"chat-view")]})});return _==="fullscreen"||_==="popup"?m.jsx(wx,{theme:E,displayType:_,popupPosition:b,onClose:_==="fullscreen"?Ii:Un,width:h,height:f,children:go}):m.jsx("div",{className:as,style:cs,children:m.jsx(wx,{theme:E,displayType:_,popupPosition:b,onExpand:nn,children:go})})}function Hc(e){return m.jsx(fq,{fallback:m.jsx(gG,{}),children:m.jsx(vq,{...e})})}function xq({logs:e,onClear:t,onExport:n}){const[i,r]=O.useState(!1),[s,o]=O.useState(""),a=e.filter(c=>!s||c.event.toLowerCase().includes(s.toLowerCase()));return i?m.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:m.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-4xl w-full max-h-[80vh] flex flex-col m-4",children:[m.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[m.jsxs("h2",{className:"text-lg font-semibold",children:["Session Logs (",e.length,")"]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("input",{type:"text",placeholder:"Filter events...",value:s,onChange:c=>o(c.target.value),className:"px-3 py-1 border rounded text-sm"}),m.jsx("button",{onClick:t,className:"px-3 py-1 bg-red-600 text-white rounded text-sm hover:bg-red-700",children:"Clear"}),m.jsx("button",{onClick:n,className:"px-3 py-1 bg-green-600 text-white rounded text-sm hover:bg-green-700",children:"Export"}),m.jsx("button",{onClick:()=>r(!1),className:"px-3 py-1 bg-gray-600 text-white rounded text-sm hover:bg-gray-700",children:"Close"})]})]}),m.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.length===0?m.jsx("p",{className:"text-gray-500 text-center py-8",children:"No logs found"}):m.jsx("div",{className:"space-y-2",children:a.map((c,l)=>m.jsxs("div",{className:"border rounded p-3 text-sm",children:[m.jsxs("div",{className:"flex items-center justify-between mb-1",children:[m.jsx("span",{className:"font-semibold text-blue-600",children:c.event}),m.jsx("span",{className:"text-gray-500 text-xs",children:new Date(c.timestamp).toLocaleTimeString()})]}),c.sessionId&&m.jsxs("div",{className:"text-xs text-gray-600 mb-1",children:["Session: ",c.sessionId]}),c.data&&m.jsx("div",{className:"bg-gray-50 p-2 rounded text-xs",children:m.jsx("pre",{className:"whitespace-pre-wrap overflow-auto",children:JSON.stringify(c.data,null,2)})})]},l))})})]})}):m.jsxs("button",{onClick:()=>r(!0),className:"fixed bottom-4 right-4 bg-blue-600 text-white px-4 py-2 rounded-lg shadow-lg hover:bg-blue-700 transition-colors text-sm z-50",children:["Session Logs (",e.length,")"]})}function kq({metrics:e}){return e?m.jsxs("div",{className:"bg-gray-100 p-4 rounded-lg",children:[m.jsx("h3",{className:"font-semibold mb-2",children:"Current Session"}),m.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Session ID:"}),m.jsx("div",{className:"font-mono text-xs",children:e.sessionId})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Start Time:"}),m.jsx("div",{children:new Date(e.startTime).toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Messages:"}),m.jsx("div",{children:e.totalMessages})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Participants:"}),m.jsx("div",{children:e.participantCount})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Connection Issues:"}),m.jsx("div",{children:e.connectionIssues})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Duration:"}),m.jsxs("div",{children:[Math.round((Date.now()-new Date(e.startTime).getTime())/1e3),"s"]})]})]})]}):null}function ss(){const{currentSession:e,sessionState:t,sessionMetrics:n,createSession:i,endSession:r}=_i(),s=O.useCallback(async(a,c)=>await i(a,c),[i]),o=O.useCallback(async()=>await r(),[r]);return{session:e,state:t,metrics:n,isActive:e!==null&&t!=="disconnected",isConnecting:t==="connecting",isConnected:t==="connected"||t==="active",start:s,stop:o}}function WA(){const{sessionMetrics:e,currentSession:t}=_i();return{metrics:e,sessionId:t==null?void 0:t.id,duration:e==null?void 0:e.duration,participantCount:e==null?void 0:e.participantCount,messageCount:e==null?void 0:e.messageCount,audioQuality:e==null?void 0:e.audioQuality,networkStats:e==null?void 0:e.networkStats}}function qA(){const{setMicrophoneEnabled:e,client:t}=_i(),[n,i]=O.useState(!1),[r,s]=O.useState(!1),o=O.useCallback(async()=>{if(!r){s(!0);try{const l=!n;await e(l),i(l)}catch(l){console.error("Failed to toggle microphone:",l)}finally{s(!1)}}},[n,r,e]),a=O.useCallback(async()=>{if(!(n||r)){s(!0);try{await e(!0),i(!0)}catch(l){console.error("Failed to enable microphone:",l)}finally{s(!1)}}},[n,r,e]),c=O.useCallback(async()=>{if(!(!n||r)){s(!0);try{await e(!1),i(!1)}catch(l){console.error("Failed to disable microphone:",l)}finally{s(!1)}}},[n,r,e]);return{isEnabled:n,isLoading:r,toggle:o,enable:a,disable:c}}function QA(){const{setCameraEnabled:e}=_i(),[t,n]=O.useState(!1),[i,r]=O.useState(!1),s=O.useCallback(async()=>{if(!i){r(!0);try{const c=!t;await e(c),n(c)}catch(c){console.error("Failed to toggle camera:",c)}finally{r(!1)}}},[t,i,e]),o=O.useCallback(async()=>{if(!(t||i)){r(!0);try{await e(!0),n(!0)}catch(c){console.error("Failed to enable camera:",c)}finally{r(!1)}}},[t,i,e]),a=O.useCallback(async()=>{if(!(!t||i)){r(!0);try{await e(!1),n(!1)}catch(c){console.error("Failed to disable camera:",c)}finally{r(!1)}}},[t,i,e]);return{isEnabled:t,isLoading:i,toggle:s,enable:o,disable:a}}function YA(){const{startScreenShare:e,stopScreenShare:t}=_i(),[n,i]=O.useState(!1),[r,s]=O.useState(!1),o=O.useCallback(async()=>{if(!(n||r)){s(!0);try{await e(),i(!0)}catch(l){console.error("Failed to start screen share:",l)}finally{s(!1)}}},[n,r,e]),a=O.useCallback(async()=>{if(!(!n||r)){s(!0);try{await t(),i(!1)}catch(l){console.error("Failed to stop screen share:",l)}finally{s(!1)}}},[n,r,t]),c=O.useCallback(async()=>{n?await a():await o()},[n,o,a]);return{isSharing:n,isLoading:r,start:o,stop:a,toggle:c}}function Sq(){const{client:e}=_i(),[t,n]=O.useState({tracks:[],layout:{type:"grid",showLocalVideo:!0,aspectRatio:"16:9"},isRecording:!1}),i=O.useMemo(()=>t.tracks.find(p=>p.isLocal),[t.tracks]),r=O.useMemo(()=>t.tracks.filter(p=>!p.isLocal),[t.tracks]),s=O.useCallback(async()=>{try{i!=null&&i.isEnabled?await(e==null?void 0:e.disableCamera()):await(e==null?void 0:e.enableCamera())}catch(p){throw console.error("Failed to toggle camera:",p),p}},[e,i]),o=O.useCallback(async()=>{try{t.tracks.find(x=>x.isScreenShare)?await(e==null?void 0:e.stopScreenShare()):await(e==null?void 0:e.startScreenShare())}catch(p){throw console.error("Failed to toggle screen share:",p),p}},[e,t.tracks]),a=O.useCallback(p=>{n(x=>({...x,layout:p}))},[]),c=O.useCallback(p=>{n(x=>({...x,pinnedTrack:p}))},[]),l=O.useCallback(()=>{n(p=>({...p,pinnedTrack:void 0}))},[]),u=O.useCallback(async()=>{try{await(e==null?void 0:e.startRecording()),n(p=>({...p,isRecording:!0}))}catch(p){throw console.error("Failed to start recording:",p),p}},[e]),d=O.useCallback(async()=>{try{await(e==null?void 0:e.stopRecording()),n(p=>({...p,isRecording:!1}))}catch(p){throw console.error("Failed to stop recording:",p),p}},[e]),h=O.useCallback(p=>t.tracks.find(x=>x.id===p),[t.tracks]),f=O.useCallback(p=>t.tracks.filter(x=>x.participantId===p),[t.tracks]),g=O.useCallback(p=>p.isEnabled&&t.tracks.includes(p),[t.tracks]);return O.useEffect(()=>{if(!e)return;const p=E=>{n(w=>({...w,tracks:[...w.tracks.filter(k=>k.id!==E.id),E]}))},x=E=>{n(w=>{var k;return{...w,tracks:w.tracks.filter(y=>y.id!==E),pinnedTrack:((k=w.pinnedTrack)==null?void 0:k.id)===E?void 0:w.pinnedTrack}})},v=E=>{n(w=>({...w,tracks:w.tracks.map(k=>k.id===E.id?E:k)}))};return e.on("videoTrackAdded",p),e.on("videoTrackRemoved",x),e.on("videoTrackUpdated",v),()=>{e.off("videoTrackAdded",p),e.off("videoTrackRemoved",x),e.off("videoTrackUpdated",v)}},[e]),{tracks:t.tracks,localTrack:i,remoteTraracks:r,pinnedTrack:t.pinnedTrack,layout:t.layout,isRecording:t.isRecording,toggleCamera:s,toggleScreenShare:o,setLayout:a,pinTrack:c,unpinTrack:l,startRecording:u,stopRecording:d,getTrackById:h,getTracksByParticipant:f,isTrackActive:g}}function xu(){const{chatMessages:e,sendChatMessage:t,currentSession:n}=_i(),[i,r]=O.useState(!1),s=O.useCallback(async l=>{if(!(!l.trim()||i||!n)){r(!0);try{await t(l.trim())}catch(u){throw console.error("Failed to send chat message:",u),u}finally{r(!1)}}},[t,i,n]),{userMessages:o,agentMessages:a,allMessages:c}=O.useMemo(()=>{const l=e.filter(d=>d.sender.type==="participant"),u=e.filter(d=>d.sender.type==="agent");return{userMessages:l,agentMessages:u,allMessages:e}},[e]);return{messages:c,userMessages:o,agentMessages:a,messageCount:c.length,isSending:i,canSend:!!n&&!i,send:s}}function Eq(){const{send:e,isSending:t,canSend:n}=xu(),[i,r]=O.useState(""),s=O.useCallback(async()=>{if(!(!i.trim()||!n))try{await e(i),r("")}catch(a){throw a}},[i,e,n]),o=O.useCallback(a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),s())},[s]);return{value:i,setValue:r,send:s,handleKeyPress:o,isSending:t,canSend:n&&i.trim().length>0}}function Km(){const{isConnected:e,isConnecting:t,connectionError:n,connect:i,disconnect:r}=_i(),s=O.useCallback(async()=>{if(!(e||t))try{await i()}catch(a){throw console.error("Failed to connect:",a),a}},[i,e,t]),o=O.useCallback(async()=>{if(e)try{await r()}catch(a){throw console.error("Failed to disconnect:",a),a}},[r,e]);return{isConnected:e,isConnecting:t,isDisconnected:!e&&!t,error:n,hasError:!!n,connect:s,disconnect:o}}function JA(){const{participants:e}=_i();return{participants:e,count:e.length,localParticipant:e.find(t=>t.isLocal),remoteParticipants:e.filter(t=>!t.isLocal)}}const XA=O.createContext({}),Da=()=>O.useContext(XA);function ZA({children:e,...t}){return m.jsx(XA.Provider,{value:t,children:e})}function Kc({name:e,children:t,fallback:n,className:i}){return m.jsx("div",{className:`voxket-slot voxket-slot--${e} ${i||""}`,children:t||n})}function $A(e,t={}){return Object.assign(e,t)}function eR({showMicrophoneControl:e=!0,showCameraControl:t=!0,showScreenShareControl:n=!0,showSessionActions:i=!0,customControls:r,className:s=""}){const o=ss(),a=qA(),c=QA(),l=YA(),u=Da(),d=["voxket-session-controls",`voxket-session-controls--${u.variant||"default"}`,`voxket-session-controls--${u.size||"md"}`,o.isActive?"voxket-session-controls--active":"voxket-session-controls--inactive",s].filter(Boolean).join(" ");return!o.isActive&&!i?m.jsx("div",{className:d,children:m.jsx("div",{className:"voxket-controls-inactive",children:m.jsx("p",{children:"Controls available during active session"})})}):m.jsxs("div",{className:d,children:[i&&m.jsx("div",{className:"voxket-session-actions",children:o.isActive?m.jsx("button",{onClick:o.stop,className:"voxket-button voxket-button--danger",children:"End Session"}):m.jsx(wq,{})}),o.isActive&&m.jsxs("div",{className:"voxket-media-controls",children:[e&&m.jsxs("button",{onClick:a.toggle,disabled:a.isLoading,className:`voxket-button voxket-button--media ${a.isEnabled?"voxket-button--active":""}`,title:a.isEnabled?"Mute microphone":"Unmute microphone",children:[m.jsx("span",{className:"voxket-icon",children:"🎤"}),a.isLoading?"Loading...":a.isEnabled?"Mute":"Unmute"]}),t&&m.jsxs("button",{onClick:c.toggle,disabled:c.isLoading,className:`voxket-button voxket-button--media ${c.isEnabled?"voxket-button--active":""}`,title:c.isEnabled?"Stop camera":"Start camera",children:[m.jsx("span",{className:"voxket-icon",children:"📹"}),c.isLoading?"Loading...":c.isEnabled?"Stop Video":"Start Video"]}),n&&m.jsxs("button",{onClick:l.toggle,disabled:l.isLoading,className:`voxket-button voxket-button--media ${l.isSharing?"voxket-button--active":""}`,title:l.isSharing?"Stop screen share":"Start screen share",children:[m.jsx("span",{className:"voxket-icon",children:"🖥️"}),l.isLoading?"Loading...":l.isSharing?"Stop Share":"Share Screen"]})]}),r&&m.jsx("div",{className:"voxket-custom-controls",children:r})]})}function wq(){ss();const[e,t]=O.useState(!1),n=async()=>{t(!0);try{console.log("Start session - agentId needed")}catch(i){console.error("Failed to start session:",i)}finally{t(!1)}};return m.jsx("button",{onClick:n,disabled:e,className:"voxket-button voxket-button--primary",children:e?"Starting...":"Start Session"})}function Wm({showConnectionStatus:e=!0,showSessionInfo:t=!0,showAgentInfo:n=!0,className:i=""}){const r=ss(),s=Km(),o=Da(),a=["voxket-session-header",`voxket-session-header--${o.variant||"default"}`,`voxket-session-header--${o.size||"md"}`,i].filter(Boolean).join(" ");return m.jsxs("div",{className:a,children:[e&&m.jsxs("div",{className:"voxket-connection-status",children:[m.jsx("div",{className:`voxket-status-indicator ${s.isConnected?"connected":"disconnected"}`}),m.jsx("span",{className:"voxket-status-text",children:s.isConnecting?"Connecting...":s.isConnected?"Connected":"Disconnected"})]}),t&&r.session&&m.jsxs("div",{className:"voxket-session-info",children:[m.jsxs("div",{className:"voxket-session-id",children:["Session: ",r.session.id.slice(-8)]}),m.jsxs("div",{className:"voxket-session-state",children:["State: ",r.state]})]}),n&&r.session&&m.jsxs("div",{className:"voxket-agent-info",children:[m.jsxs("div",{className:"voxket-agent-id",children:["Agent: ",r.session.agentId]}),m.jsxs("div",{className:"voxket-modalities",children:["Modalities: ",r.session.activeModalities.join(", ")]})]}),s.error&&m.jsxs("div",{className:"voxket-error-message",children:["Error: ",s.error.message]})]})}function qm({showChat:e=!0,showTranscriptions:t=!1,customContent:n,className:i=""}){const r=ss(),s=xu(),o=Da(),a=["voxket-session-content",`voxket-session-content--${o.variant||"default"}`,`voxket-session-content--${o.size||"md"}`,i].filter(Boolean).join(" ");return r.isActive?m.jsx("div",{className:a,children:n||m.jsxs(m.Fragment,{children:[e&&m.jsxs("div",{className:"voxket-chat-container",children:[m.jsxs("div",{className:"voxket-chat-messages",children:[s.messages.map(c=>m.jsxs("div",{className:`voxket-message voxket-message--${c.sender.type}`,children:[m.jsxs("div",{className:"voxket-message-header",children:[m.jsx("span",{className:"voxket-message-sender",children:c.sender.name}),m.jsx("span",{className:"voxket-message-time",children:c.timestamp.toLocaleTimeString()})]}),m.jsx("div",{className:"voxket-message-content",children:c.content})]},c.id)),s.messages.length===0&&m.jsx("div",{className:"voxket-empty-messages",children:m.jsx("p",{children:"No messages yet. Start the conversation!"})})]}),m.jsx(Cq,{})]}),t&&m.jsx("div",{className:"voxket-transcriptions",children:m.jsx("div",{className:"voxket-transcription-placeholder",children:m.jsx("p",{children:"Voice transcriptions will appear here"})})})]})}):m.jsx("div",{className:a,children:m.jsx("div",{className:"voxket-inactive-state",children:m.jsxs("div",{className:"voxket-inactive-message",children:[m.jsx("h3",{children:"Start a conversation"}),m.jsx("p",{children:"Begin a session to start chatting with the AI agent"})]})})})}function Cq(){const e=xu(),[t,n]=O.useState(""),i=async()=>{if(!(!t.trim()||!e.canSend))try{await e.send(t),n("")}catch(s){console.error("Failed to send message:",s)}},r=s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),i())};return m.jsxs("div",{className:"voxket-chat-input",children:[m.jsx("input",{type:"text",value:t,onChange:s=>n(s.target.value),onKeyPress:r,placeholder:"Type your message...",disabled:!e.canSend,className:"voxket-input"}),m.jsx("button",{onClick:i,disabled:!e.canSend||!t.trim(),className:"voxket-send-button",children:e.isSending?"Sending...":"Send"})]})}function Qm({showMetrics:e=!0,showParticipants:t=!0,showStatus:n=!0,customFooter:i,className:r=""}){const s=ss(),o=WA(),a=JA(),c=Da(),l=["voxket-session-footer",`voxket-session-footer--${c.variant||"default"}`,`voxket-session-footer--${c.size||"md"}`,r].filter(Boolean).join(" ");return s.isActive?m.jsx("div",{className:l,children:i||m.jsxs(m.Fragment,{children:[n&&m.jsxs("div",{className:"voxket-session-status",children:[m.jsx("div",{className:"voxket-status-indicator voxket-status-indicator--active"}),m.jsx("span",{className:"voxket-status-text",children:"Session Active"})]}),e&&o.metrics&&m.jsxs("div",{className:"voxket-session-metrics",children:[m.jsxs("div",{className:"voxket-metric",children:[m.jsx("span",{className:"voxket-metric-label",children:"Duration:"}),m.jsx("span",{className:"voxket-metric-value",children:Tq(o.duration||0)})]}),m.jsxs("div",{className:"voxket-metric",children:[m.jsx("span",{className:"voxket-metric-label",children:"Messages:"}),m.jsx("span",{className:"voxket-metric-value",children:o.metrics.messageCount})]})]}),t&&m.jsxs("div",{className:"voxket-participants-info",children:[m.jsxs("span",{className:"voxket-participants-count",children:[a.count," participant",a.count!==1?"s":""]}),a.remoteParticipants.length>0&&m.jsx("div",{className:"voxket-participant-list",children:a.remoteParticipants.map(u=>m.jsx("span",{className:"voxket-participant-name",children:u.name},u.id))})]})]})}):m.jsx("div",{className:l,children:m.jsx("div",{className:"voxket-footer-inactive",children:m.jsx("span",{className:"voxket-status-text",children:"Ready to start session"})})})}function Tq(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),i=Math.floor(n/60);return i>0?`${i}:${(n%60).toString().padStart(2,"0")}:${(t%60).toString().padStart(2,"0")}`:`${n}:${(t%60).toString().padStart(2,"0")}`}function Aq({agentId:e,sessionConfig:t,autoStart:n=!1,onSessionStart:i,onSessionEnd:r,variant:s="default",size:o="md",theme:a,className:c="",children:l}){var f;const u=ss(),d=Km();O.useEffect(()=>{n&&e&&d.isConnected&&!u.isActive&&u.start(e,t).catch(console.error)},[n,e,d.isConnected,u.isActive]),O.useEffect(()=>{var g;(g=u.session)!=null&&g.id&&i&&i(u.session.id)},[(f=u.session)==null?void 0:f.id,i]),O.useEffect(()=>()=>{u.isActive&&r&&u.stop().then(r).catch(console.error)},[]);const h=["voxket-session",`voxket-session--${s}`,`voxket-session--${o}`,u.isActive?"voxket-session--active":"voxket-session--inactive",c].filter(Boolean).join(" ");return m.jsx(ZA,{variant:s,size:o,theme:a,className:c,children:m.jsx("div",{className:h,children:l||m.jsxs(m.Fragment,{children:[m.jsx(Kc,{name:"header",fallback:m.jsx(Wm,{})}),m.jsx(Kc,{name:"content",fallback:m.jsx(qm,{})}),m.jsx(Kc,{name:"footer",fallback:m.jsx(Qm,{})})]})})})}const tR=$A(Aq,{Header:Wm,Content:qm,Footer:Qm,Controls:eR}),Kr={name:"default",colors:{primary:"#3B82F6",secondary:"#6B7280",accent:"#8B5CF6",background:"#FFFFFF",surface:"#F9FAFB",text:{primary:"#111827",secondary:"#6B7280",muted:"#9CA3AF",inverse:"#FFFFFF"},status:{success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6"},border:"#E5E7EB",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1)"},typography:{fontFamily:"system-ui, -apple-system, sans-serif",fontSize:{xs:"0.75rem",sm:"0.875rem",md:"1rem",lg:"1.125rem",xl:"1.25rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700},lineHeight:{tight:1.25,normal:1.5,relaxed:1.75}},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},borderRadius:{none:"0",sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1)"}},Of={...Kr,name:"dark",colors:{primary:"#60A5FA",secondary:"#9CA3AF",accent:"#A78BFA",background:"#111827",surface:"#1F2937",text:{primary:"#F9FAFB",secondary:"#D1D5DB",muted:"#9CA3AF",inverse:"#111827"},status:{success:"#34D399",warning:"#FBBF24",error:"#F87171",info:"#60A5FA"},border:"#374151",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.3)"}},Df={...Kr,name:"enterprise",colors:{primary:"#1E40AF",secondary:"#64748B",accent:"#7C3AED",background:"#FFFFFF",surface:"#F8FAFC",text:{primary:"#0F172A",secondary:"#475569",muted:"#94A3B8",inverse:"#FFFFFF"},status:{success:"#059669",warning:"#D97706",error:"#DC2626",info:"#1E40AF"},border:"#CBD5E1",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1)"},borderRadius:{none:"0",sm:"0.125rem",md:"0.25rem",lg:"0.375rem",full:"9999px"}},nR=O.createContext(null),iR=()=>{const e=O.useContext(nR);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e};function Rq({theme:e="default",themes:t={},children:n,cssVariables:i=!0,className:r=""}){const[s,o]=O.useState(()=>{const h={default:Kr,dark:Of,enterprise:Df,...t};return typeof e=="string"?h[e]||Kr:e}),[a,c]=O.useState(()=>({default:Kr,dark:Of,enterprise:Df,...t})),l=h=>{if(typeof h=="string"){const f=a[h];f&&o(f)}else o(h)},u=h=>{c(f=>({...f,[h.name]:h}))};O.useEffect(()=>{if(i&&typeof document<"u"){const h=document.documentElement;Object.entries(rR(s)).forEach(([f,g])=>{h.style.setProperty(`--voxket-${f}`,g)})}},[s,i]);const d={theme:s,setTheme:l,themes:a,registerTheme:u};return m.jsx(nR.Provider,{value:d,children:m.jsx("div",{className:`voxket-theme voxket-theme--${s.name} ${r}`,children:n})})}function rR(e){const t={},n=(i,r="")=>{for(const[s,o]of Object.entries(i)){const a=r?`${r}-${s}`:s;typeof o=="object"&&o!==null&&!Array.isArray(o)?n(o,a):t[a]=String(o)}};return n(e),t}function _q(e=Kr,t){return{...e,...t,colors:{...e.colors,...t.colors},typography:{...e.typography,...t.typography},spacing:{...e.spacing,...t.spacing},borderRadius:{...e.borderRadius,...t.borderRadius},shadows:{...e.shadows,...t.shadows}}}function Iq(e){var n;const{theme:t}=iR();return((n=t.components)==null?void 0:n[e])||{}}const Nq=Hm("voice-modality","voice",{onActivate:async e=>{const t=e.config;t.enableTranscription&&Mq(e),t.enableVoiceActivation&&Pq(e,t),console.log("Voice modality activated",t)},onDeactivate:async e=>{console.log("Voice modality deactivated")},onMessage:async(e,t)=>{t.type==="audio"&&Oq(e,t)}});function Mq(e,t){e.on("participant.speaking.started",n=>{console.log("Transcription: Started for",n.name)}),e.on("participant.speaking.stopped",n=>{console.log("Transcription: Stopped for",n.name)})}function Pq(e,t){const n=t.silenceThreshold||-50;console.log("Voice activation setup with threshold:",n)}function Oq(e,t){console.log("Playing audio response:",t.content)}const Dq=Hm("chat-modality","chat",{onActivate:async e=>{const t=e.config;t.enableRichText&&Lq(),t.enableFileUpload&&Bq(e),t.enableCustomComponents&&Fq(),console.log("Chat modality activated",t)},onDeactivate:async e=>{console.log("Chat modality deactivated")},onMessage:async(e,t)=>{const n=e.config;t.type==="ui_component"?Uq(e,t):t.type==="text"&&n.enableRichText&&jq(e,t)}});function Lq(e){console.log("Rich text support enabled")}function Bq(e){console.log("File upload enabled"),e.on("chat.file.uploaded",t=>{console.log("File uploaded:",t.name)})}function Fq(e){console.log("Custom components enabled");const t=new Map;t.set("quick-actions",Vq),t.set("form",zq),t.set("card",Gq),t.set("chart",Hq)}function Uq(e,t){const{componentType:n,props:i}=t.metadata;console.log("Rendering custom component:",n,i),e.emit("chat.component.render",{type:n,props:i,timestamp:new Date})}function jq(e,t){console.log("Processing rich text message:",t.content)}function Vq(e){return{type:"quick-actions",actions:e.actions||[],layout:e.layout||"horizontal"}}function zq(e){return{type:"form",fields:e.fields||[],submitAction:e.submitAction,validation:e.validation}}function Gq(e){return{type:"card",title:e.title,content:e.content,actions:e.actions,variant:e.variant||"default"}}function Hq(e){return{type:"chart",chartType:e.chartType||"line",data:e.data,options:e.options}}function Wc({track:e,participantName:t,showControls:n=!0,showName:i=!0,showMuteIndicator:r=!0,isPinned:s=!1,className:o="",onClick:a,onPin:c,onUnpin:l}){const u=O.useRef(null),[d,h]=O.useState(!1);O.useEffect(()=>{if(!u.current||!e.isEnabled)return;const x=u.current;return x.srcObject=null,()=>{x.srcObject&&(x.srcObject=null)}},[e]);const f=()=>{a==null||a(e)},g=x=>{x.stopPropagation(),s?l==null||l(e):c==null||c(e)},p=["voxket-video-tile",e.isLocal?"voxket-video-tile--local":"voxket-video-tile--remote",e.isScreenShare?"voxket-video-tile--screen-share":"voxket-video-tile--camera",s?"voxket-video-tile--pinned":"",e.isEnabled?"":"voxket-video-tile--disabled",d?"voxket-video-tile--hovered":"",o].filter(Boolean).join(" ");return m.jsxs("div",{className:p,onClick:f,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{aspectRatio:e.dimensions?`${e.dimensions.width} / ${e.dimensions.height}`:"16 / 9"},children:[m.jsx("video",{ref:u,className:"voxket-video-element",autoPlay:!0,playsInline:!0,muted:e.isLocal}),!e.isEnabled&&m.jsxs("div",{className:"voxket-video-placeholder",children:[m.jsx("div",{className:"voxket-video-placeholder-icon",children:e.isScreenShare?"🖥️":"📹"}),m.jsx("p",{className:"voxket-video-placeholder-text",children:e.isScreenShare?"Screen sharing paused":"Camera off"})]}),m.jsxs("div",{className:"voxket-video-overlay",children:[i&&t&&m.jsxs("div",{className:"voxket-video-name",children:[t,e.isLocal&&" (You)"]}),r&&!e.isEnabled&&m.jsx("div",{className:"voxket-video-mute-indicator",children:"🔇"}),n&&(d||s)&&m.jsxs("div",{className:"voxket-video-controls",children:[m.jsx("button",{className:`voxket-video-control-btn ${s?"voxket-video-control-btn--active":""}`,onClick:g,title:s?"Unpin video":"Pin video",children:"📌"}),e.isScreenShare&&m.jsx("div",{className:"voxket-video-indicator",children:"🖥️"}),e.source&&m.jsx("div",{className:"voxket-video-source",children:e.source})]})]}),!e.isEnabled&&m.jsx("div",{className:"voxket-video-loading",children:m.jsx("div",{className:"voxket-spinner"})})]})}function Kq({tracks:e,layout:t,className:n="",onLayoutChange:i,onTrackClick:r,maxVisibleTracks:s=9,showPagination:o=!0}){const[a,c]=O.useState(0),[l,u]=O.useState(null),d=O.useMemo(()=>{let E=[...e];t.type==="speaker"&&l&&(E=[l,...e.filter(y=>y.id!==l.id)]);const w=a*s,k=w+s;return E.slice(w,k)},[e,t,l,a,s]),h=Math.ceil(e.length/s),f=O.useMemo(()=>{const E=d.length;switch(t.type){case"grid":const w=Math.ceil(Math.sqrt(E)),k=Math.ceil(E/w);return{display:"grid",gridTemplateColumns:`repeat(${w}, 1fr)`,gridTemplateRows:`repeat(${k}, 1fr)`,gap:"8px"};case"speaker":return{display:"flex",flexDirection:"column",gap:"8px"};case"sidebar":return{display:"flex",gap:"8px"};case"gallery":return{display:"flex",flexWrap:"wrap",gap:"8px",justifyContent:"center"};default:return{}}},[t.type,d.length]),g=E=>{u(E)},p=()=>{u(null)},x=E=>{i==null||i({...t,type:E})},v=["voxket-video-grid",`voxket-video-grid--${t.type}`,`voxket-video-grid--${d.length}-tracks`,n].filter(Boolean).join(" ");return e.length===0?m.jsx("div",{className:"voxket-video-grid-empty",children:m.jsxs("div",{className:"voxket-video-grid-empty-content",children:[m.jsx("div",{className:"voxket-video-grid-empty-icon",children:"📹"}),m.jsx("p",{children:"No video tracks available"})]})}):m.jsxs("div",{className:v,children:[m.jsxs("div",{className:"voxket-video-grid-controls",children:[m.jsx("div",{className:"voxket-video-layout-controls",children:["grid","speaker","sidebar","gallery"].map(E=>m.jsx("button",{className:`voxket-layout-btn ${t.type===E?"voxket-layout-btn--active":""}`,onClick:()=>x(E),title:`Switch to ${E} layout`,children:Wq(E)},E))}),m.jsxs("div",{className:"voxket-video-count",children:[e.length," participant",e.length!==1?"s":""]})]}),m.jsx("div",{className:"voxket-video-grid-content",style:f,children:t.type==="speaker"&&l?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"voxket-video-speaker-main",children:m.jsx(Wc,{track:l,participantName:`Participant ${l.participantId}`,isPinned:!0,onClick:r,onUnpin:p})}),m.jsx("div",{className:"voxket-video-speaker-sidebar",children:d.filter(E=>E.id!==l.id).map(E=>m.jsx(Wc,{track:E,participantName:`Participant ${E.participantId}`,showControls:!1,onClick:r,onPin:g},E.id))})]}):d.map(E=>m.jsx(Wc,{track:E,participantName:`Participant ${E.participantId}`,isPinned:(l==null?void 0:l.id)===E.id,onClick:r,onPin:g,onUnpin:p},E.id))}),o&&h>1&&m.jsxs("div",{className:"voxket-video-pagination",children:[m.jsx("button",{className:"voxket-pagination-btn",onClick:()=>c(Math.max(0,a-1)),disabled:a===0,children:"←"}),m.jsxs("span",{className:"voxket-pagination-info",children:["Page ",a+1," of ",h]}),m.jsx("button",{className:"voxket-pagination-btn",onClick:()=>c(Math.min(h-1,a+1)),disabled:a===h-1,children:"→"})]})]})}function Wq(e){switch(e){case"grid":return"⊞";case"speaker":return"🎤";case"sidebar":return"⫸";case"gallery":return"⊡";case"picture-in-picture":return"⧉";default:return"⊞"}}function qq({localTrack:e,onToggleCamera:t,onToggleScreenShare:n,onLayoutChange:i,showLayoutControls:r=!0,showCameraControls:s=!0,showScreenShareControls:o=!0,className:a=""}){const c=["voxket-video-controls",a].filter(Boolean).join(" "),l=u=>{i==null||i({type:u,showLocalVideo:!0,aspectRatio:"16:9"})};return m.jsxs("div",{className:c,children:[s&&m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Camera"}),m.jsxs("button",{className:`voxket-control-btn ${e!=null&&e.isEnabled?"voxket-control-btn--active":""}`,onClick:t,title:e!=null&&e.isEnabled?"Turn off camera":"Turn on camera",children:[m.jsx("span",{className:"voxket-control-icon",children:e!=null&&e.isEnabled?"📹":"📷"}),m.jsx("span",{className:"voxket-control-label",children:e!=null&&e.isEnabled?"Camera On":"Camera Off"})]}),(e==null?void 0:e.dimensions)&&m.jsxs("div",{className:"voxket-video-info",children:[e.dimensions.width," × ",e.dimensions.height]})]}),o&&m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Screen Share"}),m.jsxs("button",{className:`voxket-control-btn ${e!=null&&e.isScreenShare?"voxket-control-btn--active":""}`,onClick:n,title:e!=null&&e.isScreenShare?"Stop screen sharing":"Start screen sharing",children:[m.jsx("span",{className:"voxket-control-icon",children:e!=null&&e.isScreenShare?"🛑":"🖥️"}),m.jsx("span",{className:"voxket-control-label",children:e!=null&&e.isScreenShare?"Stop Sharing":"Share Screen"})]})]}),r&&m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Layout"}),m.jsx("div",{className:"voxket-layout-buttons",children:[{type:"grid",icon:"⊞",label:"Grid"},{type:"speaker",icon:"🎤",label:"Speaker"},{type:"sidebar",icon:"⫸",label:"Sidebar"},{type:"gallery",icon:"⊡",label:"Gallery"}].map(({type:u,icon:d,label:h})=>m.jsxs("button",{className:"voxket-layout-control-btn",onClick:()=>l(u),title:`Switch to ${h} layout`,children:[m.jsx("span",{className:"voxket-control-icon",children:d}),m.jsx("span",{className:"voxket-control-label",children:h})]},u))})]}),m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Video Settings"}),m.jsxs("div",{className:"voxket-video-settings",children:[m.jsxs("div",{className:"voxket-setting-group",children:[m.jsx("label",{className:"voxket-setting-label",children:"Quality"}),m.jsxs("select",{className:"voxket-setting-select",children:[m.jsx("option",{value:"high",children:"High (720p)"}),m.jsx("option",{value:"medium",children:"Medium (480p)"}),m.jsx("option",{value:"low",children:"Low (240p)"})]})]}),m.jsxs("div",{className:"voxket-setting-group",children:[m.jsx("label",{className:"voxket-setting-label",children:"Frame Rate"}),m.jsxs("select",{className:"voxket-setting-select",children:[m.jsx("option",{value:"30",children:"30 fps"}),m.jsx("option",{value:"15",children:"15 fps"}),m.jsx("option",{value:"10",children:"10 fps"})]})]}),m.jsxs("div",{className:"voxket-setting-group",children:[m.jsx("label",{className:"voxket-setting-label",children:"Bandwidth"}),m.jsxs("select",{className:"voxket-setting-select",children:[m.jsx("option",{value:"unlimited",children:"Unlimited"}),m.jsx("option",{value:"1000",children:"1 Mbps"}),m.jsx("option",{value:"500",children:"500 Kbps"}),m.jsx("option",{value:"250",children:"250 Kbps"})]})]})]})]}),m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Statistics"}),m.jsxs("div",{className:"voxket-video-stats",children:[m.jsxs("div",{className:"voxket-stat-item",children:[m.jsx("span",{className:"voxket-stat-label",children:"Resolution:"}),m.jsx("span",{className:"voxket-stat-value",children:e!=null&&e.dimensions?`${e.dimensions.width}×${e.dimensions.height}`:"N/A"})]}),m.jsxs("div",{className:"voxket-stat-item",children:[m.jsx("span",{className:"voxket-stat-label",children:"Source:"}),m.jsx("span",{className:"voxket-stat-value",children:(e==null?void 0:e.source)||"None"})]}),m.jsxs("div",{className:"voxket-stat-item",children:[m.jsx("span",{className:"voxket-stat-label",children:"Status:"}),m.jsx("span",{className:`voxket-stat-value ${e!=null&&e.isEnabled?"voxket-stat-value--active":"voxket-stat-value--inactive"}`,children:e!=null&&e.isEnabled?"Active":"Inactive"})]})]})]})]})}const sR=({handler:e,loadData:t,data:n,client:i,addLocalMessage:r})=>{const[s,o]=D.useState(null),[a,c]=D.useState(!0),[l,u]=D.useState(!1),[d]=D.useState(Date.now()),[h,f]=D.useState("pending");D.useEffect(()=>{(async()=>{try{if(c(!0),n&&typeof n=="object"){const E={title:n.title||"Untitled Assignment",description:n.description||"No description provided",estimated_time_of_completion:n.estimated_time_of_completion||"Unknown"};o(E),console.log("📋 AssignmentView: Assignment loaded from RPC data:",E)}}catch(E){console.error("📋 AssignmentView: Error loading assignment:",E),o({title:"Assignment Loading Error",description:"There was an error loading the assignment details. Please try again.",estimated_time_of_completion:"Unknown"})}finally{c(!1)}})()},[n,t]);const g=({message:v,assignment:E})=>{const w=v.toLowerCase().includes("declined"),k=w?"bg-red-50 border-red-200":"bg-green-50 border-green-200",y=w?"text-red-700":"text-green-700",S=w?"❌":"🎉";return m.jsxs("div",{className:`max-w-sm mx-auto ${k} border rounded-lg shadow p-3 flex flex-col items-center`,children:[m.jsx("div",{className:"text-2xl mb-2",children:S}),m.jsx("div",{className:`${y} font-semibold text-sm mb-1`,children:v}),m.jsx("div",{className:"text-xs text-gray-600 text-center mb-1",children:E.title}),m.jsx("div",{className:"text-xs text-gray-500",children:"Thank you for your response!"})]})},p=async()=>{if(!(!s||!e)){u(!0);try{const v={message:"accepted"};console.log("📋 AssignmentView: Assignment accepted:",v),e.didSuccess(v),f("accepted")}catch(v){console.error("📋 AssignmentView: Error accepting assignment:",v),e.didFail({error:"Failed to accept assignment"}),f("error")}finally{u(!1)}}},x=async()=>{if(!(!s||!e)){u(!0);try{const v={message:"declined"};console.log("📋 AssignmentView: Assignment declined:",v),e.didSuccess(v),f("declined")}catch(v){console.error("📋 AssignmentView: Error declining assignment:",v),e.didFail({error:"Failed to decline assignment"}),f("error")}finally{u(!1)}}};return a?m.jsx("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg p-3",children:m.jsxs("div",{className:"flex items-center justify-center py-4",children:[m.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}),m.jsx("span",{className:"ml-2 text-xs text-gray-600",children:"Loading assignment..."})]})}):s?h==="accepted"||h==="declined"||h==="error"?m.jsx(g,{message:h==="accepted"?"Assignment accepted!":h==="declined"?"Assignment declined":"Assignment error occurred",assignment:s}):m.jsxs("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg overflow-hidden",children:[m.jsx("div",{className:"bg-gradient-to-r from-blue-600 to-purple-600 text-white p-3",children:m.jsx("div",{className:"flex items-center justify-between",children:m.jsx("h3",{className:"text-xs font-semibold text-white truncate",children:s.title})})}),m.jsxs("div",{className:"p-3 text-black",children:[m.jsx("div",{className:"bg-gray-50 rounded p-2 mb-3",children:m.jsx("p",{className:"text-xs text-black leading-snug",children:s.description})}),m.jsx("div",{className:"mb-3 text-black",children:m.jsxs("div",{className:"flex items-center text-xs text-gray-600",children:[m.jsx("span",{className:"text-xs mr-1",children:"📅"}),m.jsxs("span",{children:["Est: ",s.estimated_time_of_completion]})]})}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("button",{onClick:p,disabled:l,className:"flex-1 bg-green-600 text-white py-2 px-3 rounded text-xs font-medium hover:bg-green-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:l?m.jsxs("span",{className:"flex items-center justify-center",children:[m.jsx("div",{className:"animate-spin rounded-full h-2 w-2 border-b-2 border-white mr-1"}),m.jsx("span",{className:"text-xs",children:"Processing..."})]}):"Accept"}),m.jsx("button",{onClick:x,disabled:l,className:"flex-1 bg-red-600 text-white py-2 px-3 rounded text-xs font-medium hover:bg-red-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Decline"})]})]})]}):m.jsx("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg p-3",children:m.jsxs("div",{className:"text-center py-4",children:[m.jsx("div",{className:"text-red-600 text-sm font-semibold mb-2",children:"⚠️ Assignment Error"}),m.jsx("p",{className:"text-xs text-gray-600 mb-3",children:"Failed to load assignment details."})]})})};function Qq(){const[e,t]=D.useState(null),[n,i]=D.useState([]);D.useEffect(()=>{const a=new Oa({appId:"your-app-id",appSecret:"your-app-secret",baseUrl:"https://your-voxket-api.com",agentId:"your-agent-id",participantName:"User",modalities:["chat"]});return t(a),a.on("rpc.method.called",c=>{console.log("RPC Method Called:",c)}),a.on("rpc.interaction.completed",c=>{console.log("RPC Interaction Completed:",c)}),()=>{a.disconnect()}},[]);const r=async()=>{if(e)try{await e.registerFrontendRPC("give_assignment",sR,"embedded");const a=e.getRegisteredRpcMethods();i(a),console.log("✅ Assignment RPC registered successfully")}catch(a){console.error("❌ Failed to register assignment RPC:",a)}},s=async()=>{if(!e)return;const a=({handler:c,timeout:l})=>{const[u,d]=D.useState(""),h=[{id:"pro",name:"Pro Plan",price:"$29/month"},{id:"enterprise",name:"Enterprise Plan",price:"$99/month"},{id:"basic",name:"Basic Plan",price:"$9/month"}],f=p=>{d(p)},g=()=>{const p=h.find(x=>x.id===u);c==null||c.didSuccess({selectedProduct:u,productName:p==null?void 0:p.name,price:p==null?void 0:p.price,timestamp:new Date().toISOString()})};return m.jsxs("div",{className:"p-6 bg-white rounded-lg",children:[m.jsx("h3",{className:"text-xl font-bold mb-4",children:"Choose Your Plan"}),m.jsx("p",{className:"text-gray-600 mb-4",children:"Select the plan that best fits your needs:"}),m.jsx("div",{className:"space-y-3 mb-6",children:h.map(p=>m.jsx("div",{onClick:()=>f(p.id),className:`p-4 border rounded-lg cursor-pointer transition-all ${u===p.id?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"}`,children:m.jsxs("div",{className:"flex justify-between items-center",children:[m.jsxs("div",{children:[m.jsx("h4",{className:"font-medium",children:p.name}),m.jsx("p",{className:"text-gray-600 text-sm",children:p.price})]}),m.jsx("div",{className:`w-4 h-4 rounded-full ${u===p.id?"bg-blue-500":"border-2 border-gray-300"}`})]})},p.id))}),m.jsxs("div",{className:"flex justify-end space-x-3",children:[m.jsx("button",{onClick:()=>c==null?void 0:c.dismissView(),className:"px-4 py-2 border border-gray-300 text-gray-700 rounded hover:bg-gray-50",children:"Cancel"}),m.jsx("button",{onClick:g,disabled:!u,className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",children:"Select Plan"})]}),l&&m.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:["Time remaining: ",l," seconds"]})]})};try{await e.registerFrontendRPC("recommend_product",a,"modal");const c=e.getRegisteredRpcMethods();i(c),console.log("✅ Product Recommendation RPC registered successfully")}catch(c){console.error("❌ Failed to register product recommendation RPC:",c)}},o=async()=>{if(!e)return;const a=({handler:c})=>{const[l,u]=D.useState(0),[d,h]=D.useState(""),f=()=>{c==null||c.didSuccess({rating:l,comment:d,timestamp:new Date().toISOString()})};return m.jsxs("div",{className:"p-4 bg-white rounded-lg",children:[m.jsx("h3",{className:"text-lg font-semibold mb-3",children:"How was your experience?"}),m.jsxs("div",{className:"mb-4",children:[m.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Rate your experience:"}),m.jsx("div",{className:"flex space-x-1",children:[1,2,3,4,5].map(g=>m.jsx("button",{onClick:()=>u(g),className:`text-2xl ${g<=l?"text-yellow-400":"text-gray-300"}`,children:"⭐"},g))})]}),m.jsxs("div",{className:"mb-4",children:[m.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Additional comments:"}),m.jsx("textarea",{value:d,onChange:g=>h(g.target.value),className:"w-full p-2 border border-gray-300 rounded text-sm",rows:3,placeholder:"Tell us more about your experience..."})]}),m.jsxs("div",{className:"flex justify-end space-x-2",children:[m.jsx("button",{onClick:()=>c==null?void 0:c.dismissView(),className:"px-3 py-1 text-sm border border-gray-300 text-gray-700 rounded hover:bg-gray-50",children:"Skip"}),m.jsx("button",{onClick:f,disabled:l===0,className:"px-3 py-1 text-sm bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",children:"Submit"})]})]})};try{await e.registerFrontendRPC("collect_feedback",a,"embedded");const c=e.getRegisteredRpcMethods();i(c),console.log("✅ Feedback RPC registered successfully")}catch(c){console.error("❌ Failed to register feedback RPC:",c)}};return m.jsxs("div",{className:"p-6",children:[m.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Frontend RPC Examples"}),m.jsxs("div",{className:"space-y-4 mb-6",children:[m.jsxs("div",{children:[m.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Register RPC Methods"}),m.jsxs("div",{className:"space-x-2",children:[m.jsx("button",{onClick:r,className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Register Assignment RPC"}),m.jsx("button",{onClick:s,className:"px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600",children:"Register Product Recommendation RPC"}),m.jsx("button",{onClick:o,className:"px-4 py-2 bg-purple-500 text-white rounded hover:bg-purple-600",children:"Register Feedback RPC"})]})]}),m.jsxs("div",{children:[m.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Registered Methods"}),n.length>0?m.jsx("ul",{className:"list-disc list-inside space-y-1",children:n.map(a=>m.jsx("li",{className:"text-gray-700",children:m.jsx("code",{className:"bg-gray-100 px-2 py-1 rounded",children:a})},a))}):m.jsx("p",{className:"text-gray-500",children:"No methods registered yet"})]})]}),m.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[m.jsx("h3",{className:"text-lg font-semibold mb-2",children:"How it works"}),m.jsxs("ol",{className:"list-decimal list-inside space-y-2 text-sm text-gray-700",children:[m.jsxs("li",{children:["Register RPC methods with React components using ",m.jsx("code",{children:"client.registerFrontendRPC()"})]}),m.jsx("li",{children:"When the agent calls an RPC method, the corresponding component will be displayed"}),m.jsx("li",{children:"Users interact with the component, and the response is sent back to the agent"}),m.jsx("li",{children:"Components can be displayed in different modes: embedded, modal, or fullscreen"}),m.jsx("li",{children:"Each component has a timeout and can handle success/failure scenarios"})]})]}),m.jsxs("div",{className:"mt-6 bg-blue-50 p-4 rounded-lg",children:[m.jsx("h3",{className:"text-lg font-semibold mb-2 text-blue-800",children:"Agent Side"}),m.jsx("p",{className:"text-sm text-blue-700 mb-2",children:"On the agent side, you can call these RPC methods like this:"}),m.jsx("pre",{className:"bg-white p-3 rounded text-xs text-gray-800 overflow-x-auto",children:`// Agent calls RPC method
204
+ %c<link rel="stylesheet" href="node_modules/@voxket-ai/voxket-live/dist/index.css">`,"color: #f59e0b; font-size: 14px; font-weight: bold;","color: #fbbf24; font-size: 12px;","color: #22c55e; font-size: 12px; font-family: monospace; background: #1e293b; padding: 4px 8px; border-radius: 4px;","color: #fbbf24; font-size: 12px;","color: #22c55e; font-size: 11px; font-family: monospace; background: #1e293b; padding: 4px 8px; border-radius: 4px;"))}Ve.create(mm);Ve.create(eu);Ve.create(xT);Ve.create(Cm);function KA({theme:e,mode:t,loadingText:n,sessionState:i}){const r=wn(e),s=()=>{if(i==="connected")return"Connecting to agent...";if(n)return n;switch(t){case"voice":return"Connecting to voice agent...";case"chat":return"Starting chat session...";default:return"Connecting..."}};return m.jsxs("div",{className:"flex flex-col items-center justify-center h-full w-full p-8",children:[m.jsxs("div",{className:"text-center",children:[m.jsx("h3",{className:`text-lg font-semibold mb-2 ${r.text.accent}`,children:s()}),m.jsx("p",{className:`text-sm ${r.text.muted}`,children:"Please wait a moment..."})]}),m.jsxs("div",{className:"flex space-x-1 mt-4",children:[m.jsx("div",{className:"w-2 h-2 rounded-full animate-bounce bg-blue-500",style:{animationDelay:"0ms"}}),m.jsx("div",{className:"w-2 h-2 rounded-full animate-bounce bg-blue-500",style:{animationDelay:"150ms"}}),m.jsx("div",{className:"w-2 h-2 rounded-full animate-bounce bg-blue-500",style:{animationDelay:"300ms"}})]})]})}Ve.create(KA);function eh({theme:e}){const t=e==="light";return m.jsxs("div",{className:`font-bold left-0 right-0 flex-shrink-0 text-center py-1 px-2 text-[10px] mt-auto ${t?"text-gray-400 bg-white/80":"text-white/40 bg-black/40"}`,style:{lineHeight:"1.2",backdropFilter:"blur(4px)"},children:[m.jsx("span",{children:"Powered by "}),m.jsx("a",{href:"https://voxket.ai",target:"_blank",rel:"noopener noreferrer",className:`hover:underline font-bold ${t?"text-gray-500":"text-white/50"}`,children:"voxket.ai"}),m.jsx("span",{className:"mx-1",children:"·"}),m.jsx("span",{children:"AI can make mistakes"})]})}function wx({children:e,theme:t,displayType:n="widget",onClose:i,popupPosition:r="bottom-right",onExpand:s,width:o,height:a}){const c=wn(t),l=o||"350px",u=a||"500px";if(n==="fullscreen")return m.jsx("div",{className:"fixed inset-0 z-[9999] bg-black/40 bg-opacity-30 backdrop-blur-sm flex items-center justify-center p-8",onClick:d=>{d.target===d.currentTarget&&i&&i()},children:m.jsxs("div",{className:"w-full h-full max-w-7xl max-h-[95vh] rounded-2xl relative bg-transparent flex flex-col",onClick:d=>{d.stopPropagation()},children:[i&&m.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),i()},className:`absolute top-4 cursor-pointer right-4 z-[10000] w-12 h-12 rounded-full flex items-center justify-center transition-all duration-200 shadow-lg border backdrop-blur-sm ${t==="light"?"bg-white bg-opacity-90 text-gray-900 hover:bg-gray-100 border-gray-300":"bg-gray-900 bg-opacity-90 text-white hover:bg-gray-800 border-gray-700"}`,title:"Exit Fullscreen",type:"button",children:m.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:m.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),m.jsxs("div",{id:"voice-card",className:`voxket-widget-root theme-${t} ${c.card} w-full h-full flex flex-col rounded-xl shadow-2xl relative overflow-hidden`,"data-theme":t,style:{minHeight:"600px",height:"100%",contain:"layout style paint",overscrollBehavior:"contain",backgroundColor:t==="midnight"?"#161a25":void 0},children:[m.jsx("div",{className:c.cardTopGradient}),m.jsx("div",{className:c.cardPurpleBlur}),m.jsx("div",{className:c.cardPinkBlur}),m.jsxs("div",{className:"relative z-10 flex flex-col h-full",style:{flex:"1 1 auto"},children:[e,m.jsx(eh,{theme:t})]}),m.jsx("div",{className:c.cardPulse1}),m.jsx("div",{className:c.cardPulse2,style:{animationDelay:"1s"}})]})]})});if(n==="popup"){const d={"top-left":"top-4 left-4","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-right":"bottom-4 right-4"};return m.jsx("div",{className:"fixed rounded-2xl inset-0 z-[9999] pointer-events-none",children:m.jsxs("div",{className:`fixed rounded-2xl ${d[r]} pointer-events-auto`,children:[i&&m.jsx("button",{onClick:i,className:`absolute -top-2 -right-2 z-10 w-8 h-8 rounded-full flex items-center justify-center transition-all duration-200 text-sm shadow-lg border ${t==="light"?"bg-white bg-opacity-90 text-gray-900 hover:bg-gray-100 border-gray-300":"bg-gray-900 bg-opacity-90 text-white hover:bg-gray-800 border-gray-700"}`,children:"×"}),m.jsxs("div",{id:"voice-card",className:`voxket-widget-root voxket-popup-mode theme-${t} ${c.card} rounded-2xl flex flex-col relative overflow-hidden`,"data-theme":t,"data-display-type":"popup",style:{width:l,height:u,minWidth:l,maxWidth:l,minHeight:u,maxHeight:u,contain:"layout style paint",overscrollBehavior:"contain",backgroundColor:t==="midnight"?"#161a25":void 0,display:"flex",flexDirection:"column"},children:[m.jsx("div",{className:c.cardTopGradient}),m.jsx("div",{className:c.cardPurpleBlur}),m.jsx("div",{className:c.cardPinkBlur}),m.jsxs("div",{className:"relative z-10 flex flex-col w-full min-h-0 overflow-hidden voxket-popup-content",style:{display:"flex",flexDirection:"column",flex:"1 1 auto"},children:[e,m.jsx(eh,{theme:t})]}),m.jsx("div",{className:c.cardPulse1}),m.jsx("div",{className:c.cardPulse2,style:{animationDelay:"1s"}})]})]})})}return m.jsxs("div",{id:"voice-card",className:`voxket-widget-root theme-${t} ${c.card} relative overflow-hidden w-full h-full`,"data-theme":t,style:{height:"100%",maxHeight:"100%",contain:"layout style paint",overscrollBehavior:"contain",backgroundColor:t==="midnight"?"#161a25":void 0},children:[m.jsx("div",{className:c.cardTopGradient}),m.jsx("div",{className:c.cardPurpleBlur}),m.jsx("div",{className:c.cardPinkBlur}),m.jsxs("div",{className:"relative z-10 flex flex-col h-full w-full",style:{flex:"1 1 auto"},children:[e,m.jsx(eh,{theme:t})]}),m.jsx("div",{className:c.cardPulse1}),m.jsx("div",{className:c.cardPulse2,style:{animationDelay:"1s"}})]})}function vq(e){if(typeof window>"u")return null;D.useEffect(()=>{HA()},[]);const{agentId:t,participantName:n,baseUrl:i,appSecret:r,appId:s,authToken:o,prompts:a,statusMessage:c,welcomeTitle:l,welcomeSubTitle:u,className:d,width:h,height:f,loadingText:g,suportsChatInput:p=!0,suportsVideoInput:x=!0,suportsScreenShare:v=!0,theme:E="vox",onSessionStart:w,onSessionEnd:k,enableSessionLogging:y=!0,onSessionLogsUpdate:S,onSessionMetricsUpdate:I,modalities:T=["voice"],displayType:_="widget",popupPosition:b="bottom-right",popupTriggerText:R="Open Chat",onPopupToggle:P,voxketClient:L,onDisplayTypeChange:F,participantMetadata:V,popupModalityMode:Y="all",popupTriggerLogoUrl:se}=e,[G,q]=D.useState(!1),[C,H]=D.useState(null),[J,A]=D.useState(()=>{try{if(L)return!!L.getCurrentSession()}catch(be){const N=new oe("Error checking existing session","UNKNOWN_ERROR",be);ce.error(N)}return!1}),[ee,te]=D.useState(!1),[ae,ie]=D.useState(t||""),[X,fe]=D.useState(n||"User"),[re,Be]=D.useState(()=>{try{if(L)return L.getCurrentSession()}catch(be){const N=new oe("Error getting current session","UNKNOWN_ERROR",be);ce.error(N)}return null}),[ne,$]=D.useState(()=>{var be,N;try{if(L){const j=L.getCurrentSession();if((be=j==null?void 0:j.activeModalities)!=null&&be.includes("chat"))return"chat";if((N=j==null?void 0:j.activeModalities)!=null&&N.includes("voice"))return"voice"}}catch(j){const pe=new oe("Error determining current mode","UNKNOWN_ERROR",j);ce.error(pe)}return"welcome"}),[Re,Ke]=D.useState(!1),[ge,Te]=D.useState(!1),[_e,Fe]=D.useState(()=>T.length===1?T[0]:null),[Ue,zt]=D.useState(!1);D.useEffect(()=>{},[_]);const Pt=D.useRef(null);if(!Pt.current)try{if(L)Pt.current=L;else if(!o&&(!s||!r)){const be="Missing required props: Either provide 'authToken' or both 'appId' and 'appSecret'",N=new oe(be,"UNKNOWN_ERROR");ce.error(N),H(new Error(be)),q(!0)}else if(i){const be={...o?{authToken:o}:{appId:s,appSecret:r},baseUrl:i,agentId:ae,participantName:X||"User",modalities:T,participantMetadata:V};Pt.current=new Oa(be)}else{const be="Missing required prop: baseUrl",N=new oe(be,"UNKNOWN_ERROR");ce.error(N),H(new Error(be)),q(!0)}}catch(be){const N=new oe("Failed to create VoxketClient","UNKNOWN_ERROR",be);ce.error(N),H(be),q(!0)}const ve=Pt.current;D.useEffect(()=>{const be=Pt.current;return()=>{be&&!L&&be.disconnect().catch(N=>{const j=new oe("Error during widget cleanup disconnect","UNKNOWN_ERROR",N);ce.error(j)})}},[L]);const At=D.useMemo(()=>_==="popup"&&_e?[_e]:T,[_,_e,T]),ut=D.useMemo(()=>{try{return ve?ve.getRoom()||new Hi:new Hi}catch(be){const N=new oe("Error getting room from client","UNKNOWN_ERROR",be);return ce.error(N),new Hi}},[ve,J,ne]);D.useEffect(()=>{if(ut){const be=()=>{},N=(j,pe,Ne)=>{};return ut.on(U.Connected,be),ut.on(U.Disconnected,be),ut.on(U.TrackSubscribed,N),()=>{ut.off(U.Connected,be),ut.off(U.Disconnected,be),ut.off(U.TrackSubscribed,N)}}},[ut,re==null?void 0:re.id]),D.useEffect(()=>{(ne==="voice"||ne==="chat")&&!re&&!J&&!ee&&ve&&!ve.connected&&($("welcome"),te(!1))},[ne,re,J,ee,ve]);const{sessionMetrics:K,sessionLogs:de,logEvent:Oe}=jT({room:ut,onSessionStart:w,onSessionEnd:k,enableConsoleLogging:y,enableLocalStorage:y,voxketSessionId:re==null?void 0:re.id});D.useEffect(()=>{S&&S(de)},[de,S]),D.useEffect(()=>{I&&K&&I(K)},[K,I]),D.useEffect(()=>{if(!ve)return;const be=(N,j)=>{(N==="connecting"||N==="connected")&&(ee||te(!0)),N==="active"&&(te(!1),A(!0)),(N==="disconnected"||N==="error")&&(te(!1),A(!1),Be(null),$("welcome"))};return ve.on("session.state.changed",be),()=>{ve.off("session.state.changed",be)}},[ve,ee]),D.useEffect(()=>{if(!ve)return;const be=()=>{const N=ve.connected,j=ve.getCurrentSession();!N&&J&&!ee&&(te(!1),A(!1),Be(null),$("welcome")),N&&j&&ee&&(te(!1),A(!0),Be(j))};return ve.on("connectionStateChanged",be),ve.on("sessionEnded",()=>{te(!1),A(!1),Be(null),$("welcome")}),()=>{ve.off("connectionStateChanged",be),ve.off("sessionEnded",()=>{})}},[ve,ne,ee,J]);const it=!!(!!(ve!=null&&ve.connected)&&J&&re);D.useEffect(()=>{const be=j=>{te(!1),A(!1),Be(null),$("welcome")},N=j=>{const pe=new oe("Media devices error","UNKNOWN_ERROR",j);ce.error(pe)};return ut.on(U.MediaDevicesError,N),ut.on(U.Disconnected,be),()=>{ut.off(U.Disconnected,be),ut.off(U.MediaDevicesError,N)}},[ut,ne,J,re==null?void 0:re.id,ee]);const fn=async()=>{try{if(!ve){const N=new oe("VoxketClient not initialized","UNKNOWN_ERROR");ce.error(N),H(new Error("VoxketClient not initialized")),q(!0);return}te(!0),$("voice"),Oe("USER_STARTED_VOICE_SESSION",{agentId:ae,participantName:X});const be=await ve.startSession(ae,{participantName:X||"User",modalities:["voice"],participantMetadata:ve.getParticipantMetadata()||V});Be(be),A(!0),te(!1),w&&w(be.id)}catch(be){const N=new oe("Failed to start voice session","UNKNOWN_ERROR",be);ce.error(N),te(!1),A(!1),$("welcome")}},Xn=async()=>{try{if(!ve){const N=new oe("VoxketClient not initialized","UNKNOWN_ERROR");ce.error(N),H(new Error("VoxketClient not initialized")),q(!0);return}te(!0),$("chat"),Oe("USER_STARTED_CHAT_SESSION",{agentId:ae,participantName:X});const be=await ve.startSession(ae,{participantName:X||"User",modalities:["chat"],participantMetadata:ve.getParticipantMetadata()||V});Be(be),A(!0),te(!1),w&&w(be.id)}catch(be){const N=new oe("Failed to start chat session","UNKNOWN_ERROR",be);ce.error(N),te(!1),A(!1),$("welcome")}},pn=()=>{$("welcome"),te(!1),F&&F(e.displayType||"widget"),re&&J?(A(!1),Be(null),ve&&ve.disconnect().catch(be=>{const N=new oe("Widget: Error during disconnect","UNKNOWN_ERROR",be);ce.error(N)})):ve&&ve.connected&&ve.disconnect().catch(be=>{const N=new oe("Widget: Error during force disconnect","UNKNOWN_ERROR",be);ce.error(N)}),_==="popup"&&!Re&&Ke(!0)},Un=()=>{const be=!Re;Ke(be),P&&P(be),!be&&!(re&&J)&&($("welcome"),A(!1),Be(null))},Ii=()=>{e.onDisplayTypeChange&&e.onDisplayTypeChange("widget")},nn=()=>{if(e.onDisplayTypeChange)e.onDisplayTypeChange("fullscreen");else{const be=document.getElementById("voice-card")||document.querySelector(".voxket-widget-container");be&&be.requestFullscreen&&be.requestFullscreen().catch(N=>{})}};D.useEffect(()=>{var be,N;if(L&&ve){const j=ve.getCurrentSession();ve.connected,j&&(Be(j),A(!0),te(!1),(be=j.activeModalities)!=null&&be.includes("chat")?$("chat"):(N=j.activeModalities)!=null&&N.includes("voice")&&$("voice"))}},[L,ve]),D.useEffect(()=>()=>{!L&&ve&&ve.disconnect()},[ve,L]);let jn="w-96",rn="h-[25rem]",os={};if(h&&(h.startsWith("w-")?jn=h:(os.width=h,jn="")),f&&(f.startsWith("h-")?rn=f:(os.height=f,rn="")),_==="popup"&&!Re)return m.jsxs(m.Fragment,{children:[m.jsx(UT,{onClick:()=>{if(it){!_e&&(re!=null&&re.activeModalities)&&(re.activeModalities.includes("chat")?Fe("chat"):re.activeModalities.includes("voice")&&Fe("voice")),Te(!1),Ke(!0),P&&P(!0);return}if(Y!=="all"){Fe(Y),Te(!1),Ke(!0),P&&P(!0);return}if(T.length===1){Fe(T[0]),Te(!1),Ke(!0),P&&P(!0);return}Te(be=>!be),Fe(null),zt(!1)},position:b,ariaLabel:R,size:64,isRunning:it,logoUrl:se,theme:E}),ge&&Y==="all"&&(()=>{const j={};b==="bottom-right"?(j.bottom=88,j.right=16):b==="bottom-left"?(j.bottom=88,j.left=16):b==="top-right"?(j.top=88,j.right=16):(j.top=88,j.left=16);const pe="absolute w-0 h-0 border-8",Ne=E==="light",Rt=Ne?"border-t-white":"border-t-black",_t=Ne?"border-b-white":"border-b-black",we=b.startsWith("bottom")?m.jsx("div",{className:`${pe} border-transparent ${Rt}`,style:{bottom:-16,right:b.endsWith("right")?16:void 0,left:b.endsWith("left")?16:void 0}}):m.jsx("div",{className:`${pe} border-transparent ${_t}`,style:{top:-16,right:b.endsWith("right")?16:void 0,left:b.endsWith("left")?16:void 0}}),xe=Ne?"bg-white text-gray-900 border-[2px] border-indigo-200/60 shadow-2xl shadow-indigo-200/30":"bg-black text-white shadow-2xl",De=Ne?"bg-indigo-50 hover:bg-indigo-100 text-indigo-700 border border-indigo-200/50":"bg-white/10 hover:bg-white/20 text-white",Gt=Ne?"text-gray-500":"text-white/70";return m.jsx("div",{className:`fixed z-[51] rounded-2xl ${xe}`,style:{...j,padding:"10px"},children:m.jsxs("div",{className:"relative ",children:[we,m.jsx("div",{className:`text-xs uppercase tracking-wide mb-2 ${Gt}`,children:"Choose modality"}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("button",{type:"button",onClick:()=>{Fe("voice"),Te(!1),Ke(!0),P&&P(!0)},className:`px-3 py-2 rounded-md text-sm transition-colors ${De}`,title:"Voice",children:"Voice"}),m.jsx("button",{type:"button",onClick:()=>{Fe("chat"),Te(!1),Ke(!0),P&&P(!0)},className:`px-3 py-2 rounded-md text-sm transition-colors ${De}`,title:"Chat",children:"Chat"})]})]})})})()]});if(G||!ve){const be=(C==null?void 0:C.message)||"VoxketWidget encountered an error. Please check your configuration.";return m.jsx("div",{className:`voxket-widget-root theme-${E} flex items-center justify-center p-8 ${d||""}`,style:{width:h||"400px",height:f||"500px",border:"1px solid #ff4444",borderRadius:"8px",background:"#fff5f5",color:"#cc0000"},children:m.jsxs("div",{className:"text-center",children:[m.jsx("div",{className:"text-4xl mb-4",children:"⚠️"}),m.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Widget Error"}),m.jsx("p",{className:"text-sm mb-4",children:be}),m.jsx("button",{onClick:()=>{q(!1),H(null),window.location.reload()},className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors",children:"Retry"})]})})}let as=`voxket-widget-root theme-${E}`,cs={scrollMargin:0,scrollPadding:0,contain:"layout style paint"};_==="widget"?(as+=` flex min-h-fit ${jn} ${rn} ${d}`,cs={...cs,...os}):(as=`${d||""}`,cs={});const go=m.jsx("div",{className:"h-full w-full flex flex-col overflow-hidden z-10",children:m.jsxs(qs,{mode:"wait",children:[ne==="welcome"&&!ee&&m.jsx(Ve.div,{initial:{opacity:0,y:0},animate:{opacity:1,y:0},exit:{opacity:0,y:40},transition:{duration:.3,ease:"easeInOut"},className:"h-screen w-full",style:{height:"100%"},children:m.jsx(Cm,{agentId:ae,participantName:X||"",onAgentIdChange:ie,onParticipantNameChange:fe,onStartCall:fn,onStartChat:Xn,disabled:J||ee,prompts:a,statusMessage:c,title:l,subTitle:u,theme:E,modalities:At})},"welcome"),ee&&(ne==="voice"||ne==="chat")&&m.jsx(Ve.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.3,ease:"easeInOut"},className:"h-screen w-full",style:{height:"100%"},children:m.jsx(KA,{theme:E,mode:ne,loadingText:g,sessionState:re==null?void 0:re.state})},`loading-${ne}`),ne==="voice"&&!ee&&J&&ve&&m.jsxs(Wp.Provider,{value:ut,children:[m.jsx(tB,{},`audio-${(re==null?void 0:re.id)||"no-session"}`),m.jsx(QL,{label:"Start Audio"},`start-audio-${(re==null?void 0:re.id)||"no-session"}`),m.jsx(Ve.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"},className:"h-screen w-full",style:{height:"100%"},children:m.jsx(mm,{loadingText:g,participantName:X||"User",sessionStarted:J,disabled:!1,theme:E,client:ve,displayType:_,onBack:_==="popup"?Un:pn})},"voice-session")]}),ne==="chat"&&!ee&&J&&ve&&m.jsx(Ve.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"},className:"h-screen w-full",style:{height:"100%"},children:m.jsx(eu,{client:ve,theme:E,displayType:_,onBack:_==="popup"?Un:pn,onEndChat:pn,disabled:!1})},"chat-view")]})});return _==="fullscreen"||_==="popup"?m.jsx(wx,{theme:E,displayType:_,popupPosition:b,onClose:_==="fullscreen"?Ii:Un,width:h,height:f,children:go}):m.jsx("div",{className:as,style:cs,children:m.jsx(wx,{theme:E,displayType:_,popupPosition:b,onExpand:nn,children:go})})}function Hc(e){return m.jsx(fq,{fallback:m.jsx(gG,{}),children:m.jsx(vq,{...e})})}function xq({logs:e,onClear:t,onExport:n}){const[i,r]=O.useState(!1),[s,o]=O.useState(""),a=e.filter(c=>!s||c.event.toLowerCase().includes(s.toLowerCase()));return i?m.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:m.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-4xl w-full max-h-[80vh] flex flex-col m-4",children:[m.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[m.jsxs("h2",{className:"text-lg font-semibold",children:["Session Logs (",e.length,")"]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("input",{type:"text",placeholder:"Filter events...",value:s,onChange:c=>o(c.target.value),className:"px-3 py-1 border rounded text-sm"}),m.jsx("button",{onClick:t,className:"px-3 py-1 bg-red-600 text-white rounded text-sm hover:bg-red-700",children:"Clear"}),m.jsx("button",{onClick:n,className:"px-3 py-1 bg-green-600 text-white rounded text-sm hover:bg-green-700",children:"Export"}),m.jsx("button",{onClick:()=>r(!1),className:"px-3 py-1 bg-gray-600 text-white rounded text-sm hover:bg-gray-700",children:"Close"})]})]}),m.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.length===0?m.jsx("p",{className:"text-gray-500 text-center py-8",children:"No logs found"}):m.jsx("div",{className:"space-y-2",children:a.map((c,l)=>m.jsxs("div",{className:"border rounded p-3 text-sm",children:[m.jsxs("div",{className:"flex items-center justify-between mb-1",children:[m.jsx("span",{className:"font-semibold text-blue-600",children:c.event}),m.jsx("span",{className:"text-gray-500 text-xs",children:new Date(c.timestamp).toLocaleTimeString()})]}),c.sessionId&&m.jsxs("div",{className:"text-xs text-gray-600 mb-1",children:["Session: ",c.sessionId]}),c.data&&m.jsx("div",{className:"bg-gray-50 p-2 rounded text-xs",children:m.jsx("pre",{className:"whitespace-pre-wrap overflow-auto",children:JSON.stringify(c.data,null,2)})})]},l))})})]})}):m.jsxs("button",{onClick:()=>r(!0),className:"fixed bottom-4 right-4 bg-blue-600 text-white px-4 py-2 rounded-lg shadow-lg hover:bg-blue-700 transition-colors text-sm z-50",children:["Session Logs (",e.length,")"]})}function kq({metrics:e}){return e?m.jsxs("div",{className:"bg-gray-100 p-4 rounded-lg",children:[m.jsx("h3",{className:"font-semibold mb-2",children:"Current Session"}),m.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Session ID:"}),m.jsx("div",{className:"font-mono text-xs",children:e.sessionId})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Start Time:"}),m.jsx("div",{children:new Date(e.startTime).toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Messages:"}),m.jsx("div",{children:e.totalMessages})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Participants:"}),m.jsx("div",{children:e.participantCount})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Connection Issues:"}),m.jsx("div",{children:e.connectionIssues})]}),m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-600",children:"Duration:"}),m.jsxs("div",{children:[Math.round((Date.now()-new Date(e.startTime).getTime())/1e3),"s"]})]})]})]}):null}function ss(){const{currentSession:e,sessionState:t,sessionMetrics:n,createSession:i,endSession:r}=_i(),s=O.useCallback(async(a,c)=>await i(a,c),[i]),o=O.useCallback(async()=>await r(),[r]);return{session:e,state:t,metrics:n,isActive:e!==null&&t!=="disconnected",isConnecting:t==="connecting",isConnected:t==="connected"||t==="active",start:s,stop:o}}function WA(){const{sessionMetrics:e,currentSession:t}=_i();return{metrics:e,sessionId:t==null?void 0:t.id,duration:e==null?void 0:e.duration,participantCount:e==null?void 0:e.participantCount,messageCount:e==null?void 0:e.messageCount,audioQuality:e==null?void 0:e.audioQuality,networkStats:e==null?void 0:e.networkStats}}function qA(){const{setMicrophoneEnabled:e,client:t}=_i(),[n,i]=O.useState(!1),[r,s]=O.useState(!1),o=O.useCallback(async()=>{if(!r){s(!0);try{const l=!n;await e(l),i(l)}catch(l){console.error("Failed to toggle microphone:",l)}finally{s(!1)}}},[n,r,e]),a=O.useCallback(async()=>{if(!(n||r)){s(!0);try{await e(!0),i(!0)}catch(l){console.error("Failed to enable microphone:",l)}finally{s(!1)}}},[n,r,e]),c=O.useCallback(async()=>{if(!(!n||r)){s(!0);try{await e(!1),i(!1)}catch(l){console.error("Failed to disable microphone:",l)}finally{s(!1)}}},[n,r,e]);return{isEnabled:n,isLoading:r,toggle:o,enable:a,disable:c}}function QA(){const{setCameraEnabled:e}=_i(),[t,n]=O.useState(!1),[i,r]=O.useState(!1),s=O.useCallback(async()=>{if(!i){r(!0);try{const c=!t;await e(c),n(c)}catch(c){console.error("Failed to toggle camera:",c)}finally{r(!1)}}},[t,i,e]),o=O.useCallback(async()=>{if(!(t||i)){r(!0);try{await e(!0),n(!0)}catch(c){console.error("Failed to enable camera:",c)}finally{r(!1)}}},[t,i,e]),a=O.useCallback(async()=>{if(!(!t||i)){r(!0);try{await e(!1),n(!1)}catch(c){console.error("Failed to disable camera:",c)}finally{r(!1)}}},[t,i,e]);return{isEnabled:t,isLoading:i,toggle:s,enable:o,disable:a}}function YA(){const{startScreenShare:e,stopScreenShare:t}=_i(),[n,i]=O.useState(!1),[r,s]=O.useState(!1),o=O.useCallback(async()=>{if(!(n||r)){s(!0);try{await e(),i(!0)}catch(l){console.error("Failed to start screen share:",l)}finally{s(!1)}}},[n,r,e]),a=O.useCallback(async()=>{if(!(!n||r)){s(!0);try{await t(),i(!1)}catch(l){console.error("Failed to stop screen share:",l)}finally{s(!1)}}},[n,r,t]),c=O.useCallback(async()=>{n?await a():await o()},[n,o,a]);return{isSharing:n,isLoading:r,start:o,stop:a,toggle:c}}function Sq(){const{client:e}=_i(),[t,n]=O.useState({tracks:[],layout:{type:"grid",showLocalVideo:!0,aspectRatio:"16:9"},isRecording:!1}),i=O.useMemo(()=>t.tracks.find(p=>p.isLocal),[t.tracks]),r=O.useMemo(()=>t.tracks.filter(p=>!p.isLocal),[t.tracks]),s=O.useCallback(async()=>{try{i!=null&&i.isEnabled?await(e==null?void 0:e.disableCamera()):await(e==null?void 0:e.enableCamera())}catch(p){throw console.error("Failed to toggle camera:",p),p}},[e,i]),o=O.useCallback(async()=>{try{t.tracks.find(x=>x.isScreenShare)?await(e==null?void 0:e.stopScreenShare()):await(e==null?void 0:e.startScreenShare())}catch(p){throw console.error("Failed to toggle screen share:",p),p}},[e,t.tracks]),a=O.useCallback(p=>{n(x=>({...x,layout:p}))},[]),c=O.useCallback(p=>{n(x=>({...x,pinnedTrack:p}))},[]),l=O.useCallback(()=>{n(p=>({...p,pinnedTrack:void 0}))},[]),u=O.useCallback(async()=>{try{await(e==null?void 0:e.startRecording()),n(p=>({...p,isRecording:!0}))}catch(p){throw console.error("Failed to start recording:",p),p}},[e]),d=O.useCallback(async()=>{try{await(e==null?void 0:e.stopRecording()),n(p=>({...p,isRecording:!1}))}catch(p){throw console.error("Failed to stop recording:",p),p}},[e]),h=O.useCallback(p=>t.tracks.find(x=>x.id===p),[t.tracks]),f=O.useCallback(p=>t.tracks.filter(x=>x.participantId===p),[t.tracks]),g=O.useCallback(p=>p.isEnabled&&t.tracks.includes(p),[t.tracks]);return O.useEffect(()=>{if(!e)return;const p=E=>{n(w=>({...w,tracks:[...w.tracks.filter(k=>k.id!==E.id),E]}))},x=E=>{n(w=>{var k;return{...w,tracks:w.tracks.filter(y=>y.id!==E),pinnedTrack:((k=w.pinnedTrack)==null?void 0:k.id)===E?void 0:w.pinnedTrack}})},v=E=>{n(w=>({...w,tracks:w.tracks.map(k=>k.id===E.id?E:k)}))};return e.on("videoTrackAdded",p),e.on("videoTrackRemoved",x),e.on("videoTrackUpdated",v),()=>{e.off("videoTrackAdded",p),e.off("videoTrackRemoved",x),e.off("videoTrackUpdated",v)}},[e]),{tracks:t.tracks,localTrack:i,remoteTraracks:r,pinnedTrack:t.pinnedTrack,layout:t.layout,isRecording:t.isRecording,toggleCamera:s,toggleScreenShare:o,setLayout:a,pinTrack:c,unpinTrack:l,startRecording:u,stopRecording:d,getTrackById:h,getTracksByParticipant:f,isTrackActive:g}}function xu(){const{chatMessages:e,sendChatMessage:t,currentSession:n}=_i(),[i,r]=O.useState(!1),s=O.useCallback(async l=>{if(!(!l.trim()||i||!n)){r(!0);try{await t(l.trim())}catch(u){throw console.error("Failed to send chat message:",u),u}finally{r(!1)}}},[t,i,n]),{userMessages:o,agentMessages:a,allMessages:c}=O.useMemo(()=>{const l=e.filter(d=>d.sender.type==="participant"),u=e.filter(d=>d.sender.type==="agent");return{userMessages:l,agentMessages:u,allMessages:e}},[e]);return{messages:c,userMessages:o,agentMessages:a,messageCount:c.length,isSending:i,canSend:!!n&&!i,send:s}}function Eq(){const{send:e,isSending:t,canSend:n}=xu(),[i,r]=O.useState(""),s=O.useCallback(async()=>{if(!(!i.trim()||!n))try{await e(i),r("")}catch(a){throw a}},[i,e,n]),o=O.useCallback(a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),s())},[s]);return{value:i,setValue:r,send:s,handleKeyPress:o,isSending:t,canSend:n&&i.trim().length>0}}function Km(){const{isConnected:e,isConnecting:t,connectionError:n,connect:i,disconnect:r}=_i(),s=O.useCallback(async()=>{if(!(e||t))try{await i()}catch(a){throw console.error("Failed to connect:",a),a}},[i,e,t]),o=O.useCallback(async()=>{if(e)try{await r()}catch(a){throw console.error("Failed to disconnect:",a),a}},[r,e]);return{isConnected:e,isConnecting:t,isDisconnected:!e&&!t,error:n,hasError:!!n,connect:s,disconnect:o}}function JA(){const{participants:e}=_i();return{participants:e,count:e.length,localParticipant:e.find(t=>t.isLocal),remoteParticipants:e.filter(t=>!t.isLocal)}}const XA=O.createContext({}),Da=()=>O.useContext(XA);function ZA({children:e,...t}){return m.jsx(XA.Provider,{value:t,children:e})}function Kc({name:e,children:t,fallback:n,className:i}){return m.jsx("div",{className:`voxket-slot voxket-slot--${e} ${i||""}`,children:t||n})}function $A(e,t={}){return Object.assign(e,t)}function eR({showMicrophoneControl:e=!0,showCameraControl:t=!0,showScreenShareControl:n=!0,showSessionActions:i=!0,customControls:r,className:s=""}){const o=ss(),a=qA(),c=QA(),l=YA(),u=Da(),d=["voxket-session-controls",`voxket-session-controls--${u.variant||"default"}`,`voxket-session-controls--${u.size||"md"}`,o.isActive?"voxket-session-controls--active":"voxket-session-controls--inactive",s].filter(Boolean).join(" ");return!o.isActive&&!i?m.jsx("div",{className:d,children:m.jsx("div",{className:"voxket-controls-inactive",children:m.jsx("p",{children:"Controls available during active session"})})}):m.jsxs("div",{className:d,children:[i&&m.jsx("div",{className:"voxket-session-actions",children:o.isActive?m.jsx("button",{onClick:o.stop,className:"voxket-button voxket-button--danger",children:"End Session"}):m.jsx(wq,{})}),o.isActive&&m.jsxs("div",{className:"voxket-media-controls",children:[e&&m.jsxs("button",{onClick:a.toggle,disabled:a.isLoading,className:`voxket-button voxket-button--media ${a.isEnabled?"voxket-button--active":""}`,title:a.isEnabled?"Mute microphone":"Unmute microphone",children:[m.jsx("span",{className:"voxket-icon",children:"🎤"}),a.isLoading?"Loading...":a.isEnabled?"Mute":"Unmute"]}),t&&m.jsxs("button",{onClick:c.toggle,disabled:c.isLoading,className:`voxket-button voxket-button--media ${c.isEnabled?"voxket-button--active":""}`,title:c.isEnabled?"Stop camera":"Start camera",children:[m.jsx("span",{className:"voxket-icon",children:"📹"}),c.isLoading?"Loading...":c.isEnabled?"Stop Video":"Start Video"]}),n&&m.jsxs("button",{onClick:l.toggle,disabled:l.isLoading,className:`voxket-button voxket-button--media ${l.isSharing?"voxket-button--active":""}`,title:l.isSharing?"Stop screen share":"Start screen share",children:[m.jsx("span",{className:"voxket-icon",children:"🖥️"}),l.isLoading?"Loading...":l.isSharing?"Stop Share":"Share Screen"]})]}),r&&m.jsx("div",{className:"voxket-custom-controls",children:r})]})}function wq(){ss();const[e,t]=O.useState(!1),n=async()=>{t(!0);try{console.log("Start session - agentId needed")}catch(i){console.error("Failed to start session:",i)}finally{t(!1)}};return m.jsx("button",{onClick:n,disabled:e,className:"voxket-button voxket-button--primary",children:e?"Starting...":"Start Session"})}function Wm({showConnectionStatus:e=!0,showSessionInfo:t=!0,showAgentInfo:n=!0,className:i=""}){const r=ss(),s=Km(),o=Da(),a=["voxket-session-header",`voxket-session-header--${o.variant||"default"}`,`voxket-session-header--${o.size||"md"}`,i].filter(Boolean).join(" ");return m.jsxs("div",{className:a,children:[e&&m.jsxs("div",{className:"voxket-connection-status",children:[m.jsx("div",{className:`voxket-status-indicator ${s.isConnected?"connected":"disconnected"}`}),m.jsx("span",{className:"voxket-status-text",children:s.isConnecting?"Connecting...":s.isConnected?"Connected":"Disconnected"})]}),t&&r.session&&m.jsxs("div",{className:"voxket-session-info",children:[m.jsxs("div",{className:"voxket-session-id",children:["Session: ",r.session.id.slice(-8)]}),m.jsxs("div",{className:"voxket-session-state",children:["State: ",r.state]})]}),n&&r.session&&m.jsxs("div",{className:"voxket-agent-info",children:[m.jsxs("div",{className:"voxket-agent-id",children:["Agent: ",r.session.agentId]}),m.jsxs("div",{className:"voxket-modalities",children:["Modalities: ",r.session.activeModalities.join(", ")]})]}),s.error&&m.jsxs("div",{className:"voxket-error-message",children:["Error: ",s.error.message]})]})}function qm({showChat:e=!0,showTranscriptions:t=!1,customContent:n,className:i=""}){const r=ss(),s=xu(),o=Da(),a=["voxket-session-content",`voxket-session-content--${o.variant||"default"}`,`voxket-session-content--${o.size||"md"}`,i].filter(Boolean).join(" ");return r.isActive?m.jsx("div",{className:a,children:n||m.jsxs(m.Fragment,{children:[e&&m.jsxs("div",{className:"voxket-chat-container",children:[m.jsxs("div",{className:"voxket-chat-messages",children:[s.messages.map(c=>m.jsxs("div",{className:`voxket-message voxket-message--${c.sender.type}`,children:[m.jsxs("div",{className:"voxket-message-header",children:[m.jsx("span",{className:"voxket-message-sender",children:c.sender.name}),m.jsx("span",{className:"voxket-message-time",children:c.timestamp.toLocaleTimeString()})]}),m.jsx("div",{className:"voxket-message-content",children:c.content})]},c.id)),s.messages.length===0&&m.jsx("div",{className:"voxket-empty-messages",children:m.jsx("p",{children:"No messages yet. Start the conversation!"})})]}),m.jsx(Cq,{})]}),t&&m.jsx("div",{className:"voxket-transcriptions",children:m.jsx("div",{className:"voxket-transcription-placeholder",children:m.jsx("p",{children:"Voice transcriptions will appear here"})})})]})}):m.jsx("div",{className:a,children:m.jsx("div",{className:"voxket-inactive-state",children:m.jsxs("div",{className:"voxket-inactive-message",children:[m.jsx("h3",{children:"Start a conversation"}),m.jsx("p",{children:"Begin a session to start chatting with the AI agent"})]})})})}function Cq(){const e=xu(),[t,n]=O.useState(""),i=async()=>{if(!(!t.trim()||!e.canSend))try{await e.send(t),n("")}catch(s){console.error("Failed to send message:",s)}},r=s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),i())};return m.jsxs("div",{className:"voxket-chat-input",children:[m.jsx("input",{type:"text",value:t,onChange:s=>n(s.target.value),onKeyPress:r,placeholder:"Type your message...",disabled:!e.canSend,className:"voxket-input"}),m.jsx("button",{onClick:i,disabled:!e.canSend||!t.trim(),className:"voxket-send-button",children:e.isSending?"Sending...":"Send"})]})}function Qm({showMetrics:e=!0,showParticipants:t=!0,showStatus:n=!0,customFooter:i,className:r=""}){const s=ss(),o=WA(),a=JA(),c=Da(),l=["voxket-session-footer",`voxket-session-footer--${c.variant||"default"}`,`voxket-session-footer--${c.size||"md"}`,r].filter(Boolean).join(" ");return s.isActive?m.jsx("div",{className:l,children:i||m.jsxs(m.Fragment,{children:[n&&m.jsxs("div",{className:"voxket-session-status",children:[m.jsx("div",{className:"voxket-status-indicator voxket-status-indicator--active"}),m.jsx("span",{className:"voxket-status-text",children:"Session Active"})]}),e&&o.metrics&&m.jsxs("div",{className:"voxket-session-metrics",children:[m.jsxs("div",{className:"voxket-metric",children:[m.jsx("span",{className:"voxket-metric-label",children:"Duration:"}),m.jsx("span",{className:"voxket-metric-value",children:Tq(o.duration||0)})]}),m.jsxs("div",{className:"voxket-metric",children:[m.jsx("span",{className:"voxket-metric-label",children:"Messages:"}),m.jsx("span",{className:"voxket-metric-value",children:o.metrics.messageCount})]})]}),t&&m.jsxs("div",{className:"voxket-participants-info",children:[m.jsxs("span",{className:"voxket-participants-count",children:[a.count," participant",a.count!==1?"s":""]}),a.remoteParticipants.length>0&&m.jsx("div",{className:"voxket-participant-list",children:a.remoteParticipants.map(u=>m.jsx("span",{className:"voxket-participant-name",children:u.name},u.id))})]})]})}):m.jsx("div",{className:l,children:m.jsx("div",{className:"voxket-footer-inactive",children:m.jsx("span",{className:"voxket-status-text",children:"Ready to start session"})})})}function Tq(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),i=Math.floor(n/60);return i>0?`${i}:${(n%60).toString().padStart(2,"0")}:${(t%60).toString().padStart(2,"0")}`:`${n}:${(t%60).toString().padStart(2,"0")}`}function Aq({agentId:e,sessionConfig:t,autoStart:n=!1,onSessionStart:i,onSessionEnd:r,variant:s="default",size:o="md",theme:a,className:c="",children:l}){var f;const u=ss(),d=Km();O.useEffect(()=>{n&&e&&d.isConnected&&!u.isActive&&u.start(e,t).catch(console.error)},[n,e,d.isConnected,u.isActive]),O.useEffect(()=>{var g;(g=u.session)!=null&&g.id&&i&&i(u.session.id)},[(f=u.session)==null?void 0:f.id,i]),O.useEffect(()=>()=>{u.isActive&&r&&u.stop().then(r).catch(console.error)},[]);const h=["voxket-session",`voxket-session--${s}`,`voxket-session--${o}`,u.isActive?"voxket-session--active":"voxket-session--inactive",c].filter(Boolean).join(" ");return m.jsx(ZA,{variant:s,size:o,theme:a,className:c,children:m.jsx("div",{className:h,children:l||m.jsxs(m.Fragment,{children:[m.jsx(Kc,{name:"header",fallback:m.jsx(Wm,{})}),m.jsx(Kc,{name:"content",fallback:m.jsx(qm,{})}),m.jsx(Kc,{name:"footer",fallback:m.jsx(Qm,{})})]})})})}const tR=$A(Aq,{Header:Wm,Content:qm,Footer:Qm,Controls:eR}),Kr={name:"default",colors:{primary:"#3B82F6",secondary:"#6B7280",accent:"#8B5CF6",background:"#FFFFFF",surface:"#F9FAFB",text:{primary:"#111827",secondary:"#6B7280",muted:"#9CA3AF",inverse:"#FFFFFF"},status:{success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6"},border:"#E5E7EB",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1)"},typography:{fontFamily:"system-ui, -apple-system, sans-serif",fontSize:{xs:"0.75rem",sm:"0.875rem",md:"1rem",lg:"1.125rem",xl:"1.25rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700},lineHeight:{tight:1.25,normal:1.5,relaxed:1.75}},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},borderRadius:{none:"0",sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1)"}},Of={...Kr,name:"dark",colors:{primary:"#60A5FA",secondary:"#9CA3AF",accent:"#A78BFA",background:"#111827",surface:"#1F2937",text:{primary:"#F9FAFB",secondary:"#D1D5DB",muted:"#9CA3AF",inverse:"#111827"},status:{success:"#34D399",warning:"#FBBF24",error:"#F87171",info:"#60A5FA"},border:"#374151",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.3)"}},Df={...Kr,name:"enterprise",colors:{primary:"#1E40AF",secondary:"#64748B",accent:"#7C3AED",background:"#FFFFFF",surface:"#F8FAFC",text:{primary:"#0F172A",secondary:"#475569",muted:"#94A3B8",inverse:"#FFFFFF"},status:{success:"#059669",warning:"#D97706",error:"#DC2626",info:"#1E40AF"},border:"#CBD5E1",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1)"},borderRadius:{none:"0",sm:"0.125rem",md:"0.25rem",lg:"0.375rem",full:"9999px"}},nR=O.createContext(null),iR=()=>{const e=O.useContext(nR);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e};function Rq({theme:e="default",themes:t={},children:n,cssVariables:i=!0,className:r=""}){const[s,o]=O.useState(()=>{const h={default:Kr,dark:Of,enterprise:Df,...t};return typeof e=="string"?h[e]||Kr:e}),[a,c]=O.useState(()=>({default:Kr,dark:Of,enterprise:Df,...t})),l=h=>{if(typeof h=="string"){const f=a[h];f&&o(f)}else o(h)},u=h=>{c(f=>({...f,[h.name]:h}))};O.useEffect(()=>{if(i&&typeof document<"u"){const h=document.documentElement;Object.entries(rR(s)).forEach(([f,g])=>{h.style.setProperty(`--voxket-${f}`,g)})}},[s,i]);const d={theme:s,setTheme:l,themes:a,registerTheme:u};return m.jsx(nR.Provider,{value:d,children:m.jsx("div",{className:`voxket-theme voxket-theme--${s.name} ${r}`,children:n})})}function rR(e){const t={},n=(i,r="")=>{for(const[s,o]of Object.entries(i)){const a=r?`${r}-${s}`:s;typeof o=="object"&&o!==null&&!Array.isArray(o)?n(o,a):t[a]=String(o)}};return n(e),t}function _q(e=Kr,t){return{...e,...t,colors:{...e.colors,...t.colors},typography:{...e.typography,...t.typography},spacing:{...e.spacing,...t.spacing},borderRadius:{...e.borderRadius,...t.borderRadius},shadows:{...e.shadows,...t.shadows}}}function Iq(e){var n;const{theme:t}=iR();return((n=t.components)==null?void 0:n[e])||{}}const Nq=Hm("voice-modality","voice",{onActivate:async e=>{const t=e.config;t.enableTranscription&&Mq(e),t.enableVoiceActivation&&Pq(e,t),console.log("Voice modality activated",t)},onDeactivate:async e=>{console.log("Voice modality deactivated")},onMessage:async(e,t)=>{t.type==="audio"&&Oq(e,t)}});function Mq(e,t){e.on("participant.speaking.started",n=>{console.log("Transcription: Started for",n.name)}),e.on("participant.speaking.stopped",n=>{console.log("Transcription: Stopped for",n.name)})}function Pq(e,t){const n=t.silenceThreshold||-50;console.log("Voice activation setup with threshold:",n)}function Oq(e,t){console.log("Playing audio response:",t.content)}const Dq=Hm("chat-modality","chat",{onActivate:async e=>{const t=e.config;t.enableRichText&&Lq(),t.enableFileUpload&&Bq(e),t.enableCustomComponents&&Fq(),console.log("Chat modality activated",t)},onDeactivate:async e=>{console.log("Chat modality deactivated")},onMessage:async(e,t)=>{const n=e.config;t.type==="ui_component"?Uq(e,t):t.type==="text"&&n.enableRichText&&jq(e,t)}});function Lq(e){console.log("Rich text support enabled")}function Bq(e){console.log("File upload enabled"),e.on("chat.file.uploaded",t=>{console.log("File uploaded:",t.name)})}function Fq(e){console.log("Custom components enabled");const t=new Map;t.set("quick-actions",Vq),t.set("form",zq),t.set("card",Gq),t.set("chart",Hq)}function Uq(e,t){const{componentType:n,props:i}=t.metadata;console.log("Rendering custom component:",n,i),e.emit("chat.component.render",{type:n,props:i,timestamp:new Date})}function jq(e,t){console.log("Processing rich text message:",t.content)}function Vq(e){return{type:"quick-actions",actions:e.actions||[],layout:e.layout||"horizontal"}}function zq(e){return{type:"form",fields:e.fields||[],submitAction:e.submitAction,validation:e.validation}}function Gq(e){return{type:"card",title:e.title,content:e.content,actions:e.actions,variant:e.variant||"default"}}function Hq(e){return{type:"chart",chartType:e.chartType||"line",data:e.data,options:e.options}}function Wc({track:e,participantName:t,showControls:n=!0,showName:i=!0,showMuteIndicator:r=!0,isPinned:s=!1,className:o="",onClick:a,onPin:c,onUnpin:l}){const u=O.useRef(null),[d,h]=O.useState(!1);O.useEffect(()=>{if(!u.current||!e.isEnabled)return;const x=u.current;return x.srcObject=null,()=>{x.srcObject&&(x.srcObject=null)}},[e]);const f=()=>{a==null||a(e)},g=x=>{x.stopPropagation(),s?l==null||l(e):c==null||c(e)},p=["voxket-video-tile",e.isLocal?"voxket-video-tile--local":"voxket-video-tile--remote",e.isScreenShare?"voxket-video-tile--screen-share":"voxket-video-tile--camera",s?"voxket-video-tile--pinned":"",e.isEnabled?"":"voxket-video-tile--disabled",d?"voxket-video-tile--hovered":"",o].filter(Boolean).join(" ");return m.jsxs("div",{className:p,onClick:f,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{aspectRatio:e.dimensions?`${e.dimensions.width} / ${e.dimensions.height}`:"16 / 9"},children:[m.jsx("video",{ref:u,className:"voxket-video-element",autoPlay:!0,playsInline:!0,muted:e.isLocal}),!e.isEnabled&&m.jsxs("div",{className:"voxket-video-placeholder",children:[m.jsx("div",{className:"voxket-video-placeholder-icon",children:e.isScreenShare?"🖥️":"📹"}),m.jsx("p",{className:"voxket-video-placeholder-text",children:e.isScreenShare?"Screen sharing paused":"Camera off"})]}),m.jsxs("div",{className:"voxket-video-overlay",children:[i&&t&&m.jsxs("div",{className:"voxket-video-name",children:[t,e.isLocal&&" (You)"]}),r&&!e.isEnabled&&m.jsx("div",{className:"voxket-video-mute-indicator",children:"🔇"}),n&&(d||s)&&m.jsxs("div",{className:"voxket-video-controls",children:[m.jsx("button",{className:`voxket-video-control-btn ${s?"voxket-video-control-btn--active":""}`,onClick:g,title:s?"Unpin video":"Pin video",children:"📌"}),e.isScreenShare&&m.jsx("div",{className:"voxket-video-indicator",children:"🖥️"}),e.source&&m.jsx("div",{className:"voxket-video-source",children:e.source})]})]}),!e.isEnabled&&m.jsx("div",{className:"voxket-video-loading",children:m.jsx("div",{className:"voxket-spinner"})})]})}function Kq({tracks:e,layout:t,className:n="",onLayoutChange:i,onTrackClick:r,maxVisibleTracks:s=9,showPagination:o=!0}){const[a,c]=O.useState(0),[l,u]=O.useState(null),d=O.useMemo(()=>{let E=[...e];t.type==="speaker"&&l&&(E=[l,...e.filter(y=>y.id!==l.id)]);const w=a*s,k=w+s;return E.slice(w,k)},[e,t,l,a,s]),h=Math.ceil(e.length/s),f=O.useMemo(()=>{const E=d.length;switch(t.type){case"grid":const w=Math.ceil(Math.sqrt(E)),k=Math.ceil(E/w);return{display:"grid",gridTemplateColumns:`repeat(${w}, 1fr)`,gridTemplateRows:`repeat(${k}, 1fr)`,gap:"8px"};case"speaker":return{display:"flex",flexDirection:"column",gap:"8px"};case"sidebar":return{display:"flex",gap:"8px"};case"gallery":return{display:"flex",flexWrap:"wrap",gap:"8px",justifyContent:"center"};default:return{}}},[t.type,d.length]),g=E=>{u(E)},p=()=>{u(null)},x=E=>{i==null||i({...t,type:E})},v=["voxket-video-grid",`voxket-video-grid--${t.type}`,`voxket-video-grid--${d.length}-tracks`,n].filter(Boolean).join(" ");return e.length===0?m.jsx("div",{className:"voxket-video-grid-empty",children:m.jsxs("div",{className:"voxket-video-grid-empty-content",children:[m.jsx("div",{className:"voxket-video-grid-empty-icon",children:"📹"}),m.jsx("p",{children:"No video tracks available"})]})}):m.jsxs("div",{className:v,children:[m.jsxs("div",{className:"voxket-video-grid-controls",children:[m.jsx("div",{className:"voxket-video-layout-controls",children:["grid","speaker","sidebar","gallery"].map(E=>m.jsx("button",{className:`voxket-layout-btn ${t.type===E?"voxket-layout-btn--active":""}`,onClick:()=>x(E),title:`Switch to ${E} layout`,children:Wq(E)},E))}),m.jsxs("div",{className:"voxket-video-count",children:[e.length," participant",e.length!==1?"s":""]})]}),m.jsx("div",{className:"voxket-video-grid-content",style:f,children:t.type==="speaker"&&l?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"voxket-video-speaker-main",children:m.jsx(Wc,{track:l,participantName:`Participant ${l.participantId}`,isPinned:!0,onClick:r,onUnpin:p})}),m.jsx("div",{className:"voxket-video-speaker-sidebar",children:d.filter(E=>E.id!==l.id).map(E=>m.jsx(Wc,{track:E,participantName:`Participant ${E.participantId}`,showControls:!1,onClick:r,onPin:g},E.id))})]}):d.map(E=>m.jsx(Wc,{track:E,participantName:`Participant ${E.participantId}`,isPinned:(l==null?void 0:l.id)===E.id,onClick:r,onPin:g,onUnpin:p},E.id))}),o&&h>1&&m.jsxs("div",{className:"voxket-video-pagination",children:[m.jsx("button",{className:"voxket-pagination-btn",onClick:()=>c(Math.max(0,a-1)),disabled:a===0,children:"←"}),m.jsxs("span",{className:"voxket-pagination-info",children:["Page ",a+1," of ",h]}),m.jsx("button",{className:"voxket-pagination-btn",onClick:()=>c(Math.min(h-1,a+1)),disabled:a===h-1,children:"→"})]})]})}function Wq(e){switch(e){case"grid":return"⊞";case"speaker":return"🎤";case"sidebar":return"⫸";case"gallery":return"⊡";case"picture-in-picture":return"⧉";default:return"⊞"}}function qq({localTrack:e,onToggleCamera:t,onToggleScreenShare:n,onLayoutChange:i,showLayoutControls:r=!0,showCameraControls:s=!0,showScreenShareControls:o=!0,className:a=""}){const c=["voxket-video-controls",a].filter(Boolean).join(" "),l=u=>{i==null||i({type:u,showLocalVideo:!0,aspectRatio:"16:9"})};return m.jsxs("div",{className:c,children:[s&&m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Camera"}),m.jsxs("button",{className:`voxket-control-btn ${e!=null&&e.isEnabled?"voxket-control-btn--active":""}`,onClick:t,title:e!=null&&e.isEnabled?"Turn off camera":"Turn on camera",children:[m.jsx("span",{className:"voxket-control-icon",children:e!=null&&e.isEnabled?"📹":"📷"}),m.jsx("span",{className:"voxket-control-label",children:e!=null&&e.isEnabled?"Camera On":"Camera Off"})]}),(e==null?void 0:e.dimensions)&&m.jsxs("div",{className:"voxket-video-info",children:[e.dimensions.width," × ",e.dimensions.height]})]}),o&&m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Screen Share"}),m.jsxs("button",{className:`voxket-control-btn ${e!=null&&e.isScreenShare?"voxket-control-btn--active":""}`,onClick:n,title:e!=null&&e.isScreenShare?"Stop screen sharing":"Start screen sharing",children:[m.jsx("span",{className:"voxket-control-icon",children:e!=null&&e.isScreenShare?"🛑":"🖥️"}),m.jsx("span",{className:"voxket-control-label",children:e!=null&&e.isScreenShare?"Stop Sharing":"Share Screen"})]})]}),r&&m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Layout"}),m.jsx("div",{className:"voxket-layout-buttons",children:[{type:"grid",icon:"⊞",label:"Grid"},{type:"speaker",icon:"🎤",label:"Speaker"},{type:"sidebar",icon:"⫸",label:"Sidebar"},{type:"gallery",icon:"⊡",label:"Gallery"}].map(({type:u,icon:d,label:h})=>m.jsxs("button",{className:"voxket-layout-control-btn",onClick:()=>l(u),title:`Switch to ${h} layout`,children:[m.jsx("span",{className:"voxket-control-icon",children:d}),m.jsx("span",{className:"voxket-control-label",children:h})]},u))})]}),m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Video Settings"}),m.jsxs("div",{className:"voxket-video-settings",children:[m.jsxs("div",{className:"voxket-setting-group",children:[m.jsx("label",{className:"voxket-setting-label",children:"Quality"}),m.jsxs("select",{className:"voxket-setting-select",children:[m.jsx("option",{value:"high",children:"High (720p)"}),m.jsx("option",{value:"medium",children:"Medium (480p)"}),m.jsx("option",{value:"low",children:"Low (240p)"})]})]}),m.jsxs("div",{className:"voxket-setting-group",children:[m.jsx("label",{className:"voxket-setting-label",children:"Frame Rate"}),m.jsxs("select",{className:"voxket-setting-select",children:[m.jsx("option",{value:"30",children:"30 fps"}),m.jsx("option",{value:"15",children:"15 fps"}),m.jsx("option",{value:"10",children:"10 fps"})]})]}),m.jsxs("div",{className:"voxket-setting-group",children:[m.jsx("label",{className:"voxket-setting-label",children:"Bandwidth"}),m.jsxs("select",{className:"voxket-setting-select",children:[m.jsx("option",{value:"unlimited",children:"Unlimited"}),m.jsx("option",{value:"1000",children:"1 Mbps"}),m.jsx("option",{value:"500",children:"500 Kbps"}),m.jsx("option",{value:"250",children:"250 Kbps"})]})]})]})]}),m.jsxs("div",{className:"voxket-video-controls-section",children:[m.jsx("h4",{className:"voxket-video-controls-title",children:"Statistics"}),m.jsxs("div",{className:"voxket-video-stats",children:[m.jsxs("div",{className:"voxket-stat-item",children:[m.jsx("span",{className:"voxket-stat-label",children:"Resolution:"}),m.jsx("span",{className:"voxket-stat-value",children:e!=null&&e.dimensions?`${e.dimensions.width}×${e.dimensions.height}`:"N/A"})]}),m.jsxs("div",{className:"voxket-stat-item",children:[m.jsx("span",{className:"voxket-stat-label",children:"Source:"}),m.jsx("span",{className:"voxket-stat-value",children:(e==null?void 0:e.source)||"None"})]}),m.jsxs("div",{className:"voxket-stat-item",children:[m.jsx("span",{className:"voxket-stat-label",children:"Status:"}),m.jsx("span",{className:`voxket-stat-value ${e!=null&&e.isEnabled?"voxket-stat-value--active":"voxket-stat-value--inactive"}`,children:e!=null&&e.isEnabled?"Active":"Inactive"})]})]})]})]})}const sR=({handler:e,loadData:t,data:n,client:i,addLocalMessage:r})=>{const[s,o]=D.useState(null),[a,c]=D.useState(!0),[l,u]=D.useState(!1),[d]=D.useState(Date.now()),[h,f]=D.useState("pending");D.useEffect(()=>{(async()=>{try{if(c(!0),n&&typeof n=="object"){const E={title:n.title||"Untitled Assignment",description:n.description||"No description provided",estimated_time_of_completion:n.estimated_time_of_completion||"Unknown"};o(E),console.log("📋 AssignmentView: Assignment loaded from RPC data:",E)}}catch(E){console.error("📋 AssignmentView: Error loading assignment:",E),o({title:"Assignment Loading Error",description:"There was an error loading the assignment details. Please try again.",estimated_time_of_completion:"Unknown"})}finally{c(!1)}})()},[n,t]);const g=({message:v,assignment:E})=>{const w=v.toLowerCase().includes("declined"),k=w?"bg-red-50 border-red-200":"bg-green-50 border-green-200",y=w?"text-red-700":"text-green-700",S=w?"❌":"🎉";return m.jsxs("div",{className:`max-w-sm mx-auto ${k} border rounded-lg shadow p-3 flex flex-col items-center`,children:[m.jsx("div",{className:"text-2xl mb-2",children:S}),m.jsx("div",{className:`${y} font-semibold text-sm mb-1`,children:v}),m.jsx("div",{className:"text-xs text-gray-600 text-center mb-1",children:E.title}),m.jsx("div",{className:"text-xs text-gray-500",children:"Thank you for your response!"})]})},p=async()=>{if(!(!s||!e)){u(!0);try{const v={message:"accepted"};console.log("📋 AssignmentView: Assignment accepted:",v),e.didSuccess(v),f("accepted")}catch(v){console.error("📋 AssignmentView: Error accepting assignment:",v),e.didFail({error:"Failed to accept assignment"}),f("error")}finally{u(!1)}}},x=async()=>{if(!(!s||!e)){u(!0);try{const v={message:"declined"};console.log("📋 AssignmentView: Assignment declined:",v),e.didSuccess(v),f("declined")}catch(v){console.error("📋 AssignmentView: Error declining assignment:",v),e.didFail({error:"Failed to decline assignment"}),f("error")}finally{u(!1)}}};return a?m.jsx("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg p-3",children:m.jsxs("div",{className:"flex items-center justify-center py-4",children:[m.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}),m.jsx("span",{className:"ml-2 text-xs text-gray-600",children:"Loading assignment..."})]})}):s?h==="accepted"||h==="declined"||h==="error"?m.jsx(g,{message:h==="accepted"?"Assignment accepted!":h==="declined"?"Assignment declined":"Assignment error occurred",assignment:s}):m.jsxs("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg overflow-hidden",children:[m.jsx("div",{className:"bg-gradient-to-r from-blue-600 to-purple-600 text-white p-3",children:m.jsx("div",{className:"flex items-center justify-between",children:m.jsx("h3",{className:"text-xs font-semibold text-white truncate",children:s.title})})}),m.jsxs("div",{className:"p-3 text-black",children:[m.jsx("div",{className:"bg-gray-50 rounded p-2 mb-3",children:m.jsx("p",{className:"text-xs text-black leading-snug",children:s.description})}),m.jsx("div",{className:"mb-3 text-black",children:m.jsxs("div",{className:"flex items-center text-xs text-gray-600",children:[m.jsx("span",{className:"text-xs mr-1",children:"📅"}),m.jsxs("span",{children:["Est: ",s.estimated_time_of_completion]})]})}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("button",{onClick:p,disabled:l,className:"flex-1 bg-green-600 text-white py-2 px-3 rounded text-xs font-medium hover:bg-green-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:l?m.jsxs("span",{className:"flex items-center justify-center",children:[m.jsx("div",{className:"animate-spin rounded-full h-2 w-2 border-b-2 border-white mr-1"}),m.jsx("span",{className:"text-xs",children:"Processing..."})]}):"Accept"}),m.jsx("button",{onClick:x,disabled:l,className:"flex-1 bg-red-600 text-white py-2 px-3 rounded text-xs font-medium hover:bg-red-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Decline"})]})]})]}):m.jsx("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg p-3",children:m.jsxs("div",{className:"text-center py-4",children:[m.jsx("div",{className:"text-red-600 text-sm font-semibold mb-2",children:"⚠️ Assignment Error"}),m.jsx("p",{className:"text-xs text-gray-600 mb-3",children:"Failed to load assignment details."})]})})};function Qq(){const[e,t]=D.useState(null),[n,i]=D.useState([]);D.useEffect(()=>{const a=new Oa({appId:"your-app-id",appSecret:"your-app-secret",baseUrl:"https://your-voxket-api.com",agentId:"your-agent-id",participantName:"User",modalities:["chat"]});return t(a),a.on("rpc.method.called",c=>{console.log("RPC Method Called:",c)}),a.on("rpc.interaction.completed",c=>{console.log("RPC Interaction Completed:",c)}),()=>{a.disconnect()}},[]);const r=async()=>{if(e)try{await e.registerFrontendRPC("give_assignment",sR,"embedded");const a=e.getRegisteredRpcMethods();i(a),console.log("✅ Assignment RPC registered successfully")}catch(a){console.error("❌ Failed to register assignment RPC:",a)}},s=async()=>{if(!e)return;const a=({handler:c,timeout:l})=>{const[u,d]=D.useState(""),h=[{id:"pro",name:"Pro Plan",price:"$29/month"},{id:"enterprise",name:"Enterprise Plan",price:"$99/month"},{id:"basic",name:"Basic Plan",price:"$9/month"}],f=p=>{d(p)},g=()=>{const p=h.find(x=>x.id===u);c==null||c.didSuccess({selectedProduct:u,productName:p==null?void 0:p.name,price:p==null?void 0:p.price,timestamp:new Date().toISOString()})};return m.jsxs("div",{className:"p-6 bg-white rounded-lg",children:[m.jsx("h3",{className:"text-xl font-bold mb-4",children:"Choose Your Plan"}),m.jsx("p",{className:"text-gray-600 mb-4",children:"Select the plan that best fits your needs:"}),m.jsx("div",{className:"space-y-3 mb-6",children:h.map(p=>m.jsx("div",{onClick:()=>f(p.id),className:`p-4 border rounded-lg cursor-pointer transition-all ${u===p.id?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"}`,children:m.jsxs("div",{className:"flex justify-between items-center",children:[m.jsxs("div",{children:[m.jsx("h4",{className:"font-medium",children:p.name}),m.jsx("p",{className:"text-gray-600 text-sm",children:p.price})]}),m.jsx("div",{className:`w-4 h-4 rounded-full ${u===p.id?"bg-blue-500":"border-2 border-gray-300"}`})]})},p.id))}),m.jsxs("div",{className:"flex justify-end space-x-3",children:[m.jsx("button",{onClick:()=>c==null?void 0:c.dismissView(),className:"px-4 py-2 border border-gray-300 text-gray-700 rounded hover:bg-gray-50",children:"Cancel"}),m.jsx("button",{onClick:g,disabled:!u,className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",children:"Select Plan"})]}),l&&m.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:["Time remaining: ",l," seconds"]})]})};try{await e.registerFrontendRPC("recommend_product",a,"modal");const c=e.getRegisteredRpcMethods();i(c),console.log("✅ Product Recommendation RPC registered successfully")}catch(c){console.error("❌ Failed to register product recommendation RPC:",c)}},o=async()=>{if(!e)return;const a=({handler:c})=>{const[l,u]=D.useState(0),[d,h]=D.useState(""),f=()=>{c==null||c.didSuccess({rating:l,comment:d,timestamp:new Date().toISOString()})};return m.jsxs("div",{className:"p-4 bg-white rounded-lg",children:[m.jsx("h3",{className:"text-lg font-semibold mb-3",children:"How was your experience?"}),m.jsxs("div",{className:"mb-4",children:[m.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Rate your experience:"}),m.jsx("div",{className:"flex space-x-1",children:[1,2,3,4,5].map(g=>m.jsx("button",{onClick:()=>u(g),className:`text-2xl ${g<=l?"text-yellow-400":"text-gray-300"}`,children:"⭐"},g))})]}),m.jsxs("div",{className:"mb-4",children:[m.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Additional comments:"}),m.jsx("textarea",{value:d,onChange:g=>h(g.target.value),className:"w-full p-2 border border-gray-300 rounded text-sm",rows:3,placeholder:"Tell us more about your experience..."})]}),m.jsxs("div",{className:"flex justify-end space-x-2",children:[m.jsx("button",{onClick:()=>c==null?void 0:c.dismissView(),className:"px-3 py-1 text-sm border border-gray-300 text-gray-700 rounded hover:bg-gray-50",children:"Skip"}),m.jsx("button",{onClick:f,disabled:l===0,className:"px-3 py-1 text-sm bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",children:"Submit"})]})]})};try{await e.registerFrontendRPC("collect_feedback",a,"embedded");const c=e.getRegisteredRpcMethods();i(c),console.log("✅ Feedback RPC registered successfully")}catch(c){console.error("❌ Failed to register feedback RPC:",c)}};return m.jsxs("div",{className:"p-6",children:[m.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Frontend RPC Examples"}),m.jsxs("div",{className:"space-y-4 mb-6",children:[m.jsxs("div",{children:[m.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Register RPC Methods"}),m.jsxs("div",{className:"space-x-2",children:[m.jsx("button",{onClick:r,className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Register Assignment RPC"}),m.jsx("button",{onClick:s,className:"px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600",children:"Register Product Recommendation RPC"}),m.jsx("button",{onClick:o,className:"px-4 py-2 bg-purple-500 text-white rounded hover:bg-purple-600",children:"Register Feedback RPC"})]})]}),m.jsxs("div",{children:[m.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Registered Methods"}),n.length>0?m.jsx("ul",{className:"list-disc list-inside space-y-1",children:n.map(a=>m.jsx("li",{className:"text-gray-700",children:m.jsx("code",{className:"bg-gray-100 px-2 py-1 rounded",children:a})},a))}):m.jsx("p",{className:"text-gray-500",children:"No methods registered yet"})]})]}),m.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[m.jsx("h3",{className:"text-lg font-semibold mb-2",children:"How it works"}),m.jsxs("ol",{className:"list-decimal list-inside space-y-2 text-sm text-gray-700",children:[m.jsxs("li",{children:["Register RPC methods with React components using ",m.jsx("code",{children:"client.registerFrontendRPC()"})]}),m.jsx("li",{children:"When the agent calls an RPC method, the corresponding component will be displayed"}),m.jsx("li",{children:"Users interact with the component, and the response is sent back to the agent"}),m.jsx("li",{children:"Components can be displayed in different modes: embedded, modal, or fullscreen"}),m.jsx("li",{children:"Each component has a timeout and can handle success/failure scenarios"})]})]}),m.jsxs("div",{className:"mt-6 bg-blue-50 p-4 rounded-lg",children:[m.jsx("h3",{className:"text-lg font-semibold mb-2 text-blue-800",children:"Agent Side"}),m.jsx("p",{className:"text-sm text-blue-700 mb-2",children:"On the agent side, you can call these RPC methods like this:"}),m.jsx("pre",{className:"bg-white p-3 rounded text-xs text-gray-800 overflow-x-auto",children:`// Agent calls RPC method
205
205
  const response = await participant.performRpc({
206
206
  method: 'give_assignment',
207
207
  data: JSON.stringify({
@@ -212,7 +212,7 @@ const response = await participant.performRpc({
212
212
  })
213
213
  });
214
214
 
215
- console.log('User response:', response);`})]})]})}const Yq={async checkAvailableRpcs(e){const t=e.getRegisteredRpcMethods();return console.log("🔍 Agent: Available RPC methods:",t),t},async triggerAssignment(e,t){const n={title:"Complete Q4 Sales Analysis Report",description:"Please analyze the Q4 sales data and create a comprehensive report with insights, trends, and recommendations for the upcoming quarter. Include visualizations and executive summary.",estimated_time_of_completion:"2-3 hours"};try{console.log("🤖 Agent: Triggering give_assignment RPC with data:",n);const i=await e.localParticipant.performRpc(t,"give_assignment",JSON.stringify(n),{responseTimeout:12e4}),r=JSON.parse(i);return console.log("✅ Agent: Received user response:",r),await this.processAssignmentResponse(r),r}catch(i){throw console.error("❌ Agent: RPC failed:",i),i}},async processAssignmentResponse(e){console.log("🧠 Agent: Processing assignment response...");const t=e.status,n=e.assignmentId,i=e.timeSpent;return t==="accepted"?(console.log("🎉 Agent: User accepted the assignment!"),console.log(`� Assignment ID: ${n}`),console.log(`⏱️ Time to respond: ${i}ms`),console.log("💬 Agent: Sending follow-up:","Great! I've recorded that you've accepted the assignment. You'll receive the detailed requirements and access to the data shortly. Let me know if you need any clarification!")):t==="declined"?(console.log("❌ Agent: User declined the assignment"),console.log("💬 Agent: Sending follow-up:","No problem! Is there anything specific about this assignment that doesn't work for you? I can suggest alternatives or modify the requirements.")):t==="completed"&&(console.log("✅ Agent: User completed the assignment"),console.log("💬 Agent: Sending follow-up:","Excellent work! Could you please share the completed report? I'm excited to review your analysis and insights.")),{status:t,assignmentId:n,timeSpent:i,processed:!0,followupAction:t==="accepted"?"send_requirements":t==="declined"?"offer_alternatives":"request_deliverables"}},getAssignmentExamples(){return{marketing:{title:"Create Social Media Campaign",description:"Design and plan a social media campaign for our new product launch. Include content calendar, post designs, and engagement strategy.",estimated_time_of_completion:"4-5 hours"},technical:{title:"API Integration Documentation",description:"Create comprehensive documentation for our new API endpoints, including examples, error codes, and best practices for developers.",estimated_time_of_completion:"6-8 hours"},research:{title:"Market Research Analysis",description:"Research and analyze competitor pricing strategies in our target market. Provide recommendations for our pricing model.",estimated_time_of_completion:"3-4 hours"},quick:{title:"Customer Feedback Summary",description:"Review this week's customer feedback and create a summary of key themes and actionable insights.",estimated_time_of_completion:"30-45 minutes"}}}};pq();typeof document<"u"&&setTimeout(()=>{const e=document.createElement("div");e.className="flex",e.style.cssText="position:absolute;visibility:hidden;pointer-events:none;",document.body.appendChild(e);const t=window.getComputedStyle(e).display==="flex";document.body.removeChild(e),t?console.log("✅ Voxket SDK: CSS styles loaded successfully"):console.warn(`%c⚠️ Voxket SDK: CSS styles not loaded!
215
+ console.log('User response:', response);`})]})]})}const Yq={async checkAvailableRpcs(e){const t=e.getRegisteredRpcMethods();return console.log("🔍 Agent: Available RPC methods:",t),t},async triggerAssignment(e,t){const n={title:"Complete Q4 Sales Analysis Report",description:"Please analyze the Q4 sales data and create a comprehensive report with insights, trends, and recommendations for the upcoming quarter. Include visualizations and executive summary.",estimated_time_of_completion:"2-3 hours"};try{console.log("🤖 Agent: Triggering give_assignment RPC with data:",n);const i=await e.localParticipant.performRpc(t,"give_assignment",JSON.stringify(n),{responseTimeout:12e4}),r=JSON.parse(i);return console.log("✅ Agent: Received user response:",r),await this.processAssignmentResponse(r),r}catch(i){throw console.error("❌ Agent: RPC failed:",i),i}},async processAssignmentResponse(e){console.log("🧠 Agent: Processing assignment response...");const t=e.status,n=e.assignmentId,i=e.timeSpent;return t==="accepted"?(console.log("🎉 Agent: User accepted the assignment!"),console.log(`� Assignment ID: ${n}`),console.log(`⏱️ Time to respond: ${i}ms`),console.log("💬 Agent: Sending follow-up:","Great! I've recorded that you've accepted the assignment. You'll receive the detailed requirements and access to the data shortly. Let me know if you need any clarification!")):t==="declined"?(console.log("❌ Agent: User declined the assignment"),console.log("💬 Agent: Sending follow-up:","No problem! Is there anything specific about this assignment that doesn't work for you? I can suggest alternatives or modify the requirements.")):t==="completed"&&(console.log("✅ Agent: User completed the assignment"),console.log("💬 Agent: Sending follow-up:","Excellent work! Could you please share the completed report? I'm excited to review your analysis and insights.")),{status:t,assignmentId:n,timeSpent:i,processed:!0,followupAction:t==="accepted"?"send_requirements":t==="declined"?"offer_alternatives":"request_deliverables"}},getAssignmentExamples(){return{marketing:{title:"Create Social Media Campaign",description:"Design and plan a social media campaign for our new product launch. Include content calendar, post designs, and engagement strategy.",estimated_time_of_completion:"4-5 hours"},technical:{title:"API Integration Documentation",description:"Create comprehensive documentation for our new API endpoints, including examples, error codes, and best practices for developers.",estimated_time_of_completion:"6-8 hours"},research:{title:"Market Research Analysis",description:"Research and analyze competitor pricing strategies in our target market. Provide recommendations for our pricing model.",estimated_time_of_completion:"3-4 hours"},quick:{title:"Customer Feedback Summary",description:"Review this week's customer feedback and create a summary of key themes and actionable insights.",estimated_time_of_completion:"30-45 minutes"}}}};pq();typeof document<"u"&&setTimeout(()=>{const e=document.createElement("div");e.className="flex",e.style.cssText="position:absolute;visibility:hidden;pointer-events:none;",document.body.appendChild(e);const t=window.getComputedStyle(e).display==="flex";document.body.removeChild(e),t||console.warn(`%c⚠️ Voxket SDK: CSS styles not loaded!
216
216
 
217
217
  %cThe widget will not display correctly.
218
218
  Please add this import to your app:
package/dist/index.js CHANGED
@@ -64272,7 +64272,7 @@ function nh({ theme: e }) {
64272
64272
  return /* @__PURE__ */ D(
64273
64273
  "div",
64274
64274
  {
64275
- className: `absolute bottom-0 font-bold left-0 right-0 z-20 flex-shrink-0 text-center py-1 px-2 text-[10px] ${t ? "text-gray-400 bg-white/80" : "text-white/40 bg-black/40"}`,
64275
+ className: `font-bold left-0 right-0 flex-shrink-0 text-center py-1 px-2 text-[10px] mt-auto ${t ? "text-gray-400 bg-white/80" : "text-white/40 bg-black/40"}`,
64276
64276
  style: { lineHeight: "1.2", backdropFilter: "blur(4px)" },
64277
64277
  children: [
64278
64278
  /* @__PURE__ */ v("span", { children: "Powered by " }),
@@ -64347,8 +64347,10 @@ function Ck({
64347
64347
  /* @__PURE__ */ v("div", { className: c.cardTopGradient }),
64348
64348
  /* @__PURE__ */ v("div", { className: c.cardPurpleBlur }),
64349
64349
  /* @__PURE__ */ v("div", { className: c.cardPinkBlur }),
64350
- /* @__PURE__ */ v("div", { className: "relative z-10 flex flex-col h-full", style: { flex: "1 1 auto" }, children: e }),
64351
- /* @__PURE__ */ v(nh, { theme: t }),
64350
+ /* @__PURE__ */ D("div", { className: "relative z-10 flex flex-col h-full", style: { flex: "1 1 auto" }, children: [
64351
+ e,
64352
+ /* @__PURE__ */ v(nh, { theme: t })
64353
+ ] }),
64352
64354
  /* @__PURE__ */ v("div", { className: c.cardPulse1 }),
64353
64355
  /* @__PURE__ */ v("div", { className: c.cardPulse2, style: { animationDelay: "1s" } })
64354
64356
  ]
@@ -64400,15 +64402,17 @@ function Ck({
64400
64402
  /* @__PURE__ */ v("div", { className: c.cardTopGradient }),
64401
64403
  /* @__PURE__ */ v("div", { className: c.cardPurpleBlur }),
64402
64404
  /* @__PURE__ */ v("div", { className: c.cardPinkBlur }),
64403
- /* @__PURE__ */ v(
64405
+ /* @__PURE__ */ D(
64404
64406
  "div",
64405
64407
  {
64406
64408
  className: "relative z-10 flex flex-col w-full min-h-0 overflow-hidden voxket-popup-content",
64407
64409
  style: { display: "flex", flexDirection: "column", flex: "1 1 auto" },
64408
- children: e
64410
+ children: [
64411
+ e,
64412
+ /* @__PURE__ */ v(nh, { theme: t })
64413
+ ]
64409
64414
  }
64410
64415
  ),
64411
- /* @__PURE__ */ v(nh, { theme: t }),
64412
64416
  /* @__PURE__ */ v("div", { className: c.cardPulse1 }),
64413
64417
  /* @__PURE__ */ v("div", { className: c.cardPulse2, style: { animationDelay: "1s" } })
64414
64418
  ]
@@ -64433,8 +64437,10 @@ function Ck({
64433
64437
  /* @__PURE__ */ v("div", { className: c.cardTopGradient }),
64434
64438
  /* @__PURE__ */ v("div", { className: c.cardPurpleBlur }),
64435
64439
  /* @__PURE__ */ v("div", { className: c.cardPinkBlur }),
64436
- /* @__PURE__ */ v("div", { className: "relative z-10 flex flex-col h-full w-full", style: { flex: "1 1 auto" }, children: e }),
64437
- /* @__PURE__ */ v(nh, { theme: t }),
64440
+ /* @__PURE__ */ D("div", { className: "relative z-10 flex flex-col h-full w-full", style: { flex: "1 1 auto" }, children: [
64441
+ e,
64442
+ /* @__PURE__ */ v(nh, { theme: t })
64443
+ ] }),
64438
64444
  /* @__PURE__ */ v("div", { className: c.cardPulse1 }),
64439
64445
  /* @__PURE__ */ v("div", { className: c.cardPulse2, style: { animationDelay: "1s" } })
64440
64446
  ]
@@ -66776,7 +66782,7 @@ typeof document < "u" && setTimeout(() => {
66776
66782
  const e = document.createElement("div");
66777
66783
  e.className = "flex", e.style.cssText = "position:absolute;visibility:hidden;pointer-events:none;", document.body.appendChild(e);
66778
66784
  const t = window.getComputedStyle(e).display === "flex";
66779
- document.body.removeChild(e), t ? console.log("✅ Voxket SDK: CSS styles loaded successfully") : console.warn(
66785
+ document.body.removeChild(e), t || console.warn(
66780
66786
  `%c⚠️ Voxket SDK: CSS styles not loaded!
66781
66787
 
66782
66788
  %cThe widget will not display correctly.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voxket-ai/voxket-live",
3
- "version": "1.1.56",
3
+ "version": "1.1.58",
4
4
  "description": "A React widget for embedding Voxket-powered audio/video/chat experiences.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",