1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[212],{5749:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>v});var r=n(5155),o=n(2115),c=n(1392),s=n(2361),a=n(3570);let i=e=>{let{onComplete:t}=e,[n,c]=(0,o.useState)(!0);return((0,o.useEffect)(()=>{let e=setTimeout(()=>{c(!1),t()},2500);return()=>clearTimeout(e)},[t]),n)?(0,r.jsx)("div",{className:"fixed inset-0 flex items-center justify-center z-50 pointer-events-none",children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{className:"absolute top-0 left-0 right-0 h-64 overflow-hidden",children:Array.from({length:20}).map((e,t)=>(0,r.jsx)("div",{className:"absolute animate-fall",style:{left:"".concat(100*Math.random(),"%"),top:"-".concat(20*Math.random(),"px"),animationDuration:"".concat(1+1.5*Math.random(),"s"),animationDelay:"".concat(.5*Math.random(),"s")},children:(0,r.jsx)("div",{className:"w-8 h-8 rounded-full bg-yellow-400 text-yellow-800 flex items-center justify-center text-xs font-bold animate-spin",children:"SOL"})},t))}),(0,r.jsxs)("div",{className:"bg-gradient-to-r from-purple-600 to-pink-500 text-white px-8 py-6 rounded-xl shadow-lg animate-bounce",children:[(0,r.jsx)("h3",{className:"text-2xl font-bold",children:"Tip Sent! \uD83C\uDF89"}),(0,r.jsx)("p",{className:"mt-2",children:"You made someone's day!"})]})]})}):null};var l=n(558),d=n(2873);let u=JSON.parse('{"address":"JQosj8w7CKxUcjQJLTQarcEEFh6tf9rb6k8Lk89ND6w","metadata":{"name":"solana_tip_program","version":"0.1.0","spec":"0.1.0","description":"Created with Anchor"},"instructions":[{"name":"send_tip","discriminator":[231,88,56,242,241,6,31,59],"accounts":[{"name":"tipper","writable":true,"signer":true},{"name":"recipient","writable":true},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[]}]}'),m=new a.PublicKey("JQosj8w7CKxUcjQJLTQarcEEFh6tf9rb6k8Lk89ND6w"),g=e=>{let{recipientAddress:t,onTipComplete:n}=e,{publicKey:g,connected:h}=(0,c.v)(),{connection:p}=(0,s.w)(),{sendTip:f}=function(){let e=(0,d.M)();return{sendTip:async(t,n)=>{if(!e)throw Error("Wallet not connected");let r=new l.NQ(t,e,{commitment:"processed"}),o=new l.BP(u,m,r);try{let r=await o.methods.sendTip().accounts({tipper:e.publicKey,recipient:n,system_program:a.SystemProgram.programId}).rpc();return await t.confirmTransaction(r,"confirmed"),r}catch(e){throw console.error("Error in sendTip:",e),e}}}}(),[v,x]=(0,o.useState)(!1),[b,w]=(0,o.useState)(null),[y,j]=(0,o.useState)(!1),k=async()=>{if(!h||!g){w("Please connect your wallet first.");return}try{let e;x(!0),w("Sending tip...");try{e=new a.PublicKey(t)}catch(e){w("Invalid recipient address."),x(!1);return}let r=await f(p,e);w("Tip sent successfully! Tx: ".concat(r.slice(0,8),"...")),j(!0),n&&n(),setTimeout(()=>{w(null)},3e3)}catch(e){console.error("Error sending tip:",e),w("Error: ".concat(e instanceof Error?e.message:"Unknown error"))}finally{x(!1)}};return(0,r.jsxs)("div",{className:"tip-button",children:[(0,r.jsxs)("button",{onClick:k,disabled:v||!h||!g,className:"flex items-center justify-center gap-2 px-4 py-2 rounded-lg transition duration-300 ".concat(!v&&h&&g?"bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600":"bg-gray-600 cursor-not-allowed"),children:[v?(0,r.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm1-11a1 1 0 10-2 0v2H7a1 1 0 100 2h2v2a1 1 0 102 0v-2h2a1 1 0 100-2h-2V7z",clipRule:"evenodd"})}),(0,r.jsx)("span",{children:v?"Sending...":"Send Tip (0.0002 SOL)"})]}),b&&(0,r.jsx)("div",{className:"mt-2 text-sm p-2 rounded-md ".concat(b.includes("Error")||b.includes("Please connect")||b.includes("Invalid")?"bg-red-900 text-red-200":b.includes("success")?"bg-green-900 text-green-200":"bg-blue-900 text-blue-200"),children:b}),y&&(0,r.jsx)(i,{onComplete:()=>j(!1)})]})};var h=n(4298),p=n(9911);let f=()=>{let e="https://solana-video-chat-signaling.onrender.com:10000";return"https:"!==window.location.protocol||e.startsWith("https://")||e.includes("localhost")?e:e.replace("http://","https://")},v=e=>{let{onPeerConnect:t,onEndChat:n,targetUserId:s}=e,{publicKey:a}=(0,c.v)(),[i,l]=(0,o.useState)(!0),[d,u]=(0,o.useState)(!1),[m,v]=(0,o.useState)(null),[x,b]=(0,o.useState)(""),[w,y]=(0,o.useState)(!1),[j,k]=(0,o.useState)(0),C=(0,o.useRef)(null),N=(0,o.useRef)(null),S=(0,o.useRef)(null),T=(0,o.useRef)(null),E=(0,o.useRef)(null),R=(0,o.useRef)(null),[I,D]=(0,o.useState)(!1),[P,A]=(0,o.useState)(!1),[_,F]=(0,o.useState)(!1);(0,o.useEffect)(()=>(y(!0),()=>{y(!1),R.current&&clearTimeout(R.current)}),[]);let O=async()=>{try{let e=f();console.log("Attempting to connect to signaling server:",e),E.current&&(E.current.disconnect(),E.current.close());let t=(0,h.io)(e,{transports:["polling","websocket"],reconnection:!0,reconnectionAttempts:5,reconnectionDelay:1e3,t
1imeout:2e4,withCredentials:!1,forceNew:!0,autoConnect:!0,path:"/socket.io/",query:{walletAddress:(null==a?void 0:a.toString())||"unknown",clientTime:Date.now(),...s?{targetUserId:s,mode:"direct"}:{mode:"random"}}});t.io.on("error",e=>{console.error("Socket.io transport error:",e),v("Transport error: ".concat(e.message||"Unknown error"))}),t.io.on("reconnect_attempt",()=>{console.log("Socket transport reconnect attempt")}),E.current=t,t.on("connect",()=>{console.log("Connected to signaling server successfully"),l(!1),u(!0),k(0),v(null),s||t.emit("waiting",{walletAddress:(null==a?void 0:a.toString())||"unknown",timestamp:Date.now()})}),z(t)}catch(e){console.error("Error in connectToSignalingServer:",e),v("Failed to establish connection to signaling server: ".concat(e instanceof Error?e.message:String(e)))}},z=e=>{e.on("connect_error",t=>{console.error("Connection error:",t);let n="Failed to connect to signaling server: ".concat(t.message);"timeout"===t.message?n="Connection to server timed out. The server might be down or overloaded.":t.message.includes("CORS")?n="Cross-Origin Request blocked. This might be a browser security setting.":t.message.includes("xhr poll error")&&(n="Network connection issue. Please check your internet connection."),v(n),u(!1),j<5&&(R.current=setTimeout(()=>{k(e=>e+1),e.connect()},2e3))}),e.on("disconnect",t=>{console.log("Disconnected from signaling server:",t),u(!1),("io server disconnect"===t||"transport close"===t||"transport error"===t)&&(console.log("Attempting to reconnect after disconnect"),e.connect())}),e.on("error",e=>{console.error("Socket error:",e),v("Socket error: ".concat(e.message||"Unknown error"))}),e.on("reconnect_attempt",e=>{console.log("Reconnection attempt ".concat(e))}),e.on("reconnect",t=>{console.log("Reconnected after ".concat(t," attempts")),v(null),u(!0),l(!1),e.emit("waiting",{walletAddress:(null==a?void 0:a.toString())||"unknown",timestamp:Date.now()})}),e.on("matched",e=>{let{peer:t,peerWallet:n}=e;console.log("Matched with peer: ".concat(t)),b(n),L(t)}),e.on("offer",async t=>{let{from:n,offer:r}=t;console.log("Received offer from: ".concat(n)),S.current||L(n);try{var o,c,s;await (null===(o=S.current)||void 0===o?void 0:o.setRemoteDescription(new RTCSessionDescription(r)));let t=await (null===(c=S.current)||void 0===c?void 0:c.createAnswer());await (null===(s=S.current)||void 0===s?void 0:s.setLocalDescription(t)),e.emit("answer",{to:n,answer:t})}catch(e){console.error("Error handling received offer:",e),v("Failed to process connection offer. Try refreshing the page.")}}),e.on("answer",async e=>{let{from:t,answer:n}=e;console.log("Received answer from: ".concat(t));try{var r;await (null===(r=S.current)||void 0===r?void 0:r.setRemoteDescription(new RTCSessionDescription(n)))}catch(e){console.error("Error setting remote description from answer:",e),v("Failed to establish peer connection. Try refreshing the page.")}}),e.on("ice-candidate",async e=>{let{from:t,candidate:n}=e;console.log("Received ICE candidate from: ".concat(t));try{var r;await (null===(r=S.current)||void 0===r?void 0:r.addIceCandidate(new RTCIceCandidate(n)))}catch(e){console.error("Error adding ICE candidate:",e)}}),e.on("chat-ended",e=>{let{reason:t}=e;console.log("Chat ended: ".concat(t)),Q(),n()})};(0,o.useEffect)(()=>{if(!w||!a)return;let e=!0;return(async()=>{try{let t=await navigator.mediaDevices.getUserMedia({video:!0,audio:!0});if(!e){t.getTracks().forEach(e=>e.stop());return}T.current=t,C.current&&(C.current.srcObject=t),O()}catch(t){if(!e)return;console.error("Error in startConnection:",t),v(t instanceof Error?t.message:"Couldn't access camera and microphone. Please make sure you have granted the necessary permissions.")}})(),()=>{e=!1,Q()}},[w,a,t,n,s]);let L=e=>{try{console.log("Creating peer connection with:",e);let n=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"},{urls:"stun:stun2.l.google.com:19302"},{urls:"stun:stun3.l.google.com:19302"},{urls:"stun:stun4.l.google.com:19302"},{urls:"turn:openrelay.metered.ca:80",username:"openrelayproject",credential:"openrelayproject"},{urls:"turn:openrelay.metered.ca:443",username:"openrelayproject",credential:"openrelayproject"},{urls:"turn:openrelay.metered.ca:443?transport=tcp",username:"openrelayproject",credential:"openrelayproject"}],iceCandidatePoolSize:10,iceTransportPolicy:"all"});
1S.current=n,T.current&&T.current.getTracks().forEach(e=>{T.current&&n.addTrack(e,T.current)}),n.onicecandidate=t=>{if(t.candidate){var n;console.log("New ICE candidate:",t.candidate.type),null===(n=E.current)||void 0===n||n.emit("ice-candidate",{to:e,candidate:t.candidate})}},n.oniceconnectionstatechange=()=>{switch(console.log("ICE connection state:",n.iceConnectionState),U(),n.iceConnectionState){case"connected":case"completed":console.log("ICE connection established");break;case"disconnected":console.log("ICE connection disconnected - this may be temporary");break;case"failed":console.log("ICE connection failed - attempting restart"),n.restartIce();break;case"closed":console.log("ICE connection closed"),Q()}},n.onconnectionstatechange=()=>{switch(console.log("Connection state changed:",n.connectionState),n.connectionState){case"connected":console.log("Peer connection established"),l(!1),u(!0);break;case"disconnected":console.log("Peer connection disconnected");break;case"failed":console.log("Peer connection failed - attempting to reconnect"),n.restartIce();break;case"closed":console.log("Peer connection closed"),Q()}},n.ontrack=e=>{console.log("Received remote track"),N.current&&e.streams[0]&&(N.current.srcObject=e.streams[0],l(!1),u(!0),t(n,x))},x&&M(e)}catch(e){console.error("Error creating peer connection:",e),v("Failed to create peer connection")}},M=async e=>{try{if(!S.current)return;console.log("Creating and sending offer to:",e);let t=await S.current.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});await S.current.setLocalDescription(t),setTimeout(()=>{S.current&&E.current&&(E.current.emit("offer",{to:e,offer:S.current.localDescription}),console.log("Sent offer after timeout"))},1e3)}catch(e){console.error("Error creating offer:",e),v("Failed to create connection offer")}},Q=()=>{T.current&&T.current.getTracks().forEach(e=>e.stop()),S.current&&(S.current.close(),S.current=null),E.current&&E.current.disconnect(),l(!0),u(!1),b("")},U=()=>{var e;S.current&&(console.log("Connection debug info:"),console.log("- ICE Connection State:",S.current.iceConnectionState),console.log("- ICE Gathering State:",S.current.iceGatheringState),console.log("- Signaling State:",S.current.signalingState),console.log("- Connection State:",S.current.connectionState),console.log("- Remote streams:",S.current.getReceivers().length),console.log("- Socket connected:",null===(e=E.current)||void 0===e?void 0:e.connected))};return(0,o.useEffect)(()=>{if(S.current&&d){let e=setInterval(U,5e3);return()=>clearInterval(e)}},[d]),(0,r.jsxs)("div",{className:"video-chat relative",children:[m&&(0,r.jsxs)("div",{className:"mb-4 p-3 bg-sonic-red/20 border border-sonic-red rounded-lg text-white",children:[(0,r.jsx)("p",{className:"font-bold",children:"Connection Error:"}),(0,r.jsx)("p",{children:m}),j<5?(0,r.jsxs)("div",{className:"mt-2 text-sm",children:["Retrying connection... (",j+1,"/",5,")"]}):(0,r.jsxs)("div",{className:"mt-2 text-sm",children:[(0,r.jsx)("p",{children:"Connection attempts failed. You can try:"}),(0,r.jsxs)("ul",{className:"list-disc pl-5 mt-1",children:[(0,r.jsx)("li",{children:"Refreshing the page"}),(0,r.jsx)("li",{children:"Checking your internet connection"}),(0,r.jsx)("li",{children:"Trying a different browser"}),(0,r.jsx)("li",{children:"Disabling any VPN or proxy services"}),(0,r.jsx)("li",{children:"Trying again later if the server is down"})]}),(0,r.jsx)("button",{onClick:()=>{k(0),v(null),O()},className:"mt-2 px-4 py-2 bg-sonic-blue hover:bg-sonic-blue-dark rounded-lg font-bold",children:"Try Again"})]})]}),(0,r.jsxs)("div",{className:"mb-4 text-center",children:[i&&!m&&(0,r.jsxs)("div",{className:"inline-flex items-center px-4 py-2 bg-sonic-yellow bg-opacity-20 text-sonic-yellow rounded-full",children:[(0,r.jsx)("div",{className:"w-2 h-2 bg-sonic-yellow rounded-full mr-2 animate-pulse"}),"Connecting to server..."]}),d&&!i&&(0,r.jsxs)("div",{className:"inline-flex items-center px-4 py-2 bg-sonic-green bg-opacity-20 text-sonic-green rounded-full",children:[(0,r.jsx)("div",{className:"w-2 h-2 bg-sonic-green rounded-full mr-2 animate-pulse"}),"Connected to peer"]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,r.jsxs)("div",{className:"relative group rounded-xl overflow-hidden shadow-2xl transform transition-all duration-300 hover:scale-[1.02] border-2 border-gray-700",children:[w&&(0,r.jsx)("video",{ref:C,autoPlay:!0,muted:!0,playsInl
1ine:!0,className:"w-full aspect-video object-cover"}),(0,r.jsxs)("div",{className:"absolute bottom-4 left-4 bg-black bg-opacity-60 text-white px-4 py-2 rounded-full backdrop-blur-sm",children:["You ",null==a?void 0:a.toString().slice(0,6),"..."]}),P&&(0,r.jsx)("div",{className:"absolute inset-0 bg-gray-900 flex items-center justify-center",children:(0,r.jsx)("div",{className:"text-white text-2xl",children:"Camera Off"})})]}),(0,r.jsxs)("div",{className:"relative group rounded-xl overflow-hidden shadow-2xl transform transition-all duration-300 hover:scale-[1.02] border-2 border-gray-700",children:[i&&(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"animate-spin rounded-full h-16 w-16 border-t-4 border-b-4 border-sonic-blue mx-auto mb-4"}),(0,r.jsx)("p",{className:"text-white text-lg",children:"Finding someone to chat with..."}),(0,r.jsx)("p",{className:"text-gray-400 text-sm mt-2",children:"This might take a few moments"})]})}),w&&(0,r.jsx)("video",{ref:N,autoPlay:!0,playsInline:!0,className:"w-full aspect-video object-cover"}),d&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"absolute bottom-4 left-4 bg-black bg-opacity-60 text-white px-4 py-2 rounded-full backdrop-blur-sm",children:["Peer ",x.slice(0,6),"..."]}),(0,r.jsx)("div",{className:"absolute bottom-4 right-4",children:(0,r.jsx)(g,{recipientAddress:x})})]})]})]}),(0,r.jsxs)("div",{className:"mt-8 flex justify-center items-center space-x-4",children:[(0,r.jsx)("button",{onClick:()=>{if(T.current){let e=T.current.getAudioTracks()[0];e&&(e.enabled=!e.enabled,D(!I))}},className:"p-4 rounded-full transition-all duration-300 ".concat(I?"bg-sonic-red hover:bg-sonic-red-dark":"bg-sonic-blue hover:bg-sonic-blue-dark"," text-white shadow-lg hover:shadow-xl transform hover:scale-110"),title:I?"Unmute":"Mute",children:I?(0,r.jsx)(p.$j$,{size:24}):(0,r.jsx)(p.i0t,{size:24})}),(0,r.jsx)("button",{onClick:()=>{if(T.current){let e=T.current.getVideoTracks()[0];e&&(e.enabled=!e.enabled,A(!P))}},className:"p-4 rounded-full transition-all duration-300 ".concat(P?"bg-sonic-red hover:bg-sonic-red-dark":"bg-sonic-blue hover:bg-sonic-blue-dark"," text-white shadow-lg hover:shadow-xl transform hover:scale-110"),title:P?"Turn on camera":"Turn off camera",children:P?(0,r.jsx)(p._OX,{size:24}):(0,r.jsx)(p.HiP,{size:24})}),(0,r.jsx)("button",{onClick:()=>{var e;null===(e=E.current)||void 0===e||e.emit("end-chat"),Q(),n()},className:"p-4 rounded-full bg-sonic-red hover:bg-sonic-red-dark text-white shadow-lg hover:shadow-xl transform hover:scale-110 transition-all duration-300",title:"End Chat",children:(0,r.jsx)(p.LRC,{size:24})})]})]})}},7790:()=>{}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.