(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{345:(e,t,i)=>{Promise.resolve().then(i.bind(i,6311))},6311:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>b});var a=i(4568),s=i(8947),n=i(4752),r=i(7460),c=i(5103),l=i(5755),o=i(6127),d=i(7425),x=i(8898),h=i(2519),m=i(7620),u=i(1205);let p=e=>{let{connected:t,setConnected:i,refetchToken:n}=e,[c,l]=(0,m.useState)(!1),o=!!(0,r.L)({kind:h.UJ.AGENT});return(0,m.useEffect)(()=>{t&&o&&!c&&l(!0),c&&t&&!o&&n()},[o,t,n,c]),(0,a.jsx)(d.P.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex items-center justify-center",children:t&&!1===o?(0,a.jsx)("div",{className:"text-white text-lg font-medium",children:"Connecting to agent"}):(0,a.jsxs)(d.P.button,{whileHover:{scale:1.05},whileTap:{scale:.95},className:"bg-white text-black px-8 py-4 rounded-lg font-medium text-xl flex items-center space-x-3 hover:bg-gray-100 transition-colors",onClick:()=>i(!1),children:[(0,a.jsx)(s.A,{className:"w-5 h-5"}),(0,a.jsx)("span",{children:"End Chat"})]})})},f=e=>{let{isActive:t}=e;return(0,a.jsx)(d.P.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex items-end space-x-1 h-16",children:[...Array(20)].map((e,i)=>(0,a.jsx)(d.P.div,{className:"w-1 bg-[#FF7F61]",animate:{height:t?[8,32,16,24,8]:8},transition:{duration:1.5,repeat:1/0,repeatType:"reverse",delay:.1*i}},i))})},y=()=>{let e="jay.so";return e.includes("localhost")?"http://".concat(e):"https://".concat(e)},j=e=>{let{agentId:t,environment:i,developerId:s}=e,[r,h]=(0,m.useState)(!1),[{data:j,loading:b,error:N},w]=(0,o.Ay)({url:"".concat(y(),"/api/callAgentStartSession"),method:"POST",data:{custom_data:{},agent_id:t,environment:i,developer_id:s},headers:{"x-vercel-protection-bypass":u.env.NEXT_PUBLIC_VERCEL_AUTOMATION_BYPASS_SECRET}},{ssr:!1});return(N&&console.error(N),b)?(0,a.jsx)(v,{}):N?(0,a.jsx)(g,{}):(0,a.jsx)("div",{className:"h-screen w-screen flex items-center justify-center bg-gradient-to-b from-black via-[#1A0D08] to-[#2B150C]",children:(0,a.jsxs)("div",{className:"relative flex flex-col gap-8 items-center justify-center h-64 w-64",children:[(0,a.jsx)("div",{className:"h-16 items-center justify-center",children:(0,a.jsx)(x.N,{mode:"wait",children:r?(0,a.jsx)(c.L,{video:!1,audio:!0,token:null==j?void 0:j.token,serverUrl:null==j?void 0:j.url,onMediaDeviceFailure:e=>{console.error(e),alert("Error acquiring microphone permissions. Please make sure you grant the necessary permissions in your browser and reload the tab")},children:(0,a.jsxs)(d.P.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},className:"flex flex-col items-center justify-center w-full gap-8",children:[(0,a.jsx)(p,{connected:r,setConnected:h,refetchToken:w}),(0,a.jsx)(l.R,{})]})},"livekit-room"):(0,a.jsxs)(d.P.button,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{type:"spring",stiffness:300,damping:30},className:"bg-white text-black px-8 py-4 rounded-lg font-medium text-xl flex items-center space-x-3 hover:bg-gray-100 transition-colors",onClick:()=>h(!0),children:[(0,a.jsx)(n.A,{className:"w-6 h-6"}),(0,a.jsx)("span",{children:"Get Started"})]},"get-started")})}),(0,a.jsx)("div",{children:(0,a.jsx)(f,{isActive:r})})]})})},v=()=>(0,a.jsx)("div",{className:"flex items-center justify-center h-screen w-screen bg-gradient-to-b from-black via-[#1A0D08] to-[#2B150C]",children:(0,a.jsx)(d.P.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},className:"w-16 h-16 border-t-4 border-[#FF7F61] border-solid rounded-full"})}),g=()=>(0,a.jsx)("div",{className:"flex items-center justify-center h-screen w-screen bg-gradient-to-b from-black via-[#1A0D08] to-[#2B150C]",children:(0,a.jsx)(d.P.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"text-white text-2xl font-medium",children:"Oops! Something went wrong. Please try again later."})});function b(){let[e,t]=(0,m.useState)(""),[i,s]=(0,m.useState)(""),[n,r]=(0,m.useState)("");return(0,m.useEffect)(()=>{fetch("/jay/fetch_agent_id").then(e=>e.json()).then(e=>{t(e.AGENT_ID),s(e.ENVIRONMENT),r(e.DEVELOPER_ID)}).catch(e=>console.error("Error fetching config:",e))},[]),(0,a.jsx)("div",{children:e&&(0,a.jsx)(j,{agentId:e,environment:i,developerId:n})})}}},e=>{var t=t=>e(e.s=t);e.O(0,[648,561,587,855,358],()=>t(345)),_N_E=e.O()}]);