lua-ai-chat 0.0.3 → 0.0.4

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import {memo,useCallback,createContext,useState,useRef,useEffect,useContext}from'react';import {Logo,MapPin,Button,CreditCard,Dialog,DialogTitle,DialogContent,XIcon,Carousel,CarouselContent,CarouselItem,CarouselPrevious,CarouselNext,IconButton,ArrowUp,Camera,Tooltip,TooltipTrigger,Paperclip,TooltipContent,TooltipArrow,VideoCamera,Microphone}from'@lua-ai-global/luaniverse';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {VisuallyHidden}from'@radix-ui/react-visually-hidden';import St from'react-markdown';import {Highlight,themes}from'prism-react-renderer';import {MapContainer,TileLayer,Marker,Popup}from'react-leaflet';function $l({onAudioRecorded:t,onClose:e,inputMessage:a}){let[l,r]=useState(false),[s,d]=useState(0),[u,n]=useState([]),[p,f]=useState(null),[o,i]=useState(null),h=useRef(null),c=useRef(null),v=useRef([]),g=useRef(null),C=useRef(null),x=useRef(null),N=useRef(null),m=useRef(false),w=useRef(false),U=useRef(null);useEffect(()=>{if(!l||!p)return;let P=setInterval(()=>{let k=Math.floor((Date.now()-p)/1e3);d(k);},1e3);return ()=>clearInterval(P)},[l,p]),useEffect(()=>((async()=>{if(!(m.current||w.current))try{m.current=!0;let k=await navigator.mediaDevices.getUserMedia({audio:!0});h.current=k,g.current=new AudioContext,C.current=g.current.createAnalyser(),C.current.fftSize=256,g.current.createMediaStreamSource(k).connect(C.current),x.current=new Uint8Array(C.current.frequencyBinCount);let q=()=>{if(!C.current||!x.current)return;C.current.getByteFrequencyData(x.current);let Wt=Array.from(x.current).map(Xt=>Xt/255);n(Wt),N.current=requestAnimationFrame(q);};q(),_t();}catch(k){console.error("Error accessing microphone:",k),e();}finally{m.current=false;}})(),()=>{B();}),[]);let B=()=>{if(!w.current)try{if(w.current=!0,l&&c.current&&(c.current.stop(),r(!1),f(null)),h.current){let P=h.current.getAudioTracks(),k=h.current.getVideoTracks();P.forEach(A=>{A.stop(),A.enabled=!1;}),k.forEach(A=>{A.stop(),A.enabled=!1;});}N.current&&cancelAnimationFrame(N.current),g.current&&g.current.close(),h.current=null,c.current=null,v.current=[],g.current=null,C.current=null,x.current=null,N.current=null;}finally{w.current=false;}},_t=()=>{if(!h.current)return;let k=["audio/webm","audio/mp4","audio/ogg","audio/wav"].find(q=>MediaRecorder.isTypeSupported(q));if(!k){console.error("No supported MIME type found for MediaRecorder"),e();return}U.current=k;let A=new MediaRecorder(h.current,{mimeType:k});c.current=A,v.current=[],A.ondataavailable=q=>{q.data.size>0&&v.current.push(q.data);},A.start(),r(true),f(Date.now()),d(0);},jt=async()=>{if(!c.current||!h.current)return;r(false),i(s),f(null),c.current.stop(),await new Promise(k=>{c.current&&(c.current.onstop=()=>k());});let P=new Blob(v.current,{type:U.current||"audio/webm"});t(P,a),B(),e();},mt=P=>{let k=Math.floor(P/60),A=P%60;return `${k.toString().padStart(2,"0")}:${A.toString().padStart(2,"0")}`};return jsxs("div",{className:"audio-recorder-container lua:bg-gray-100 lua:rounded-lg lua:p-2 lua:flex lua:items-center lua:gap-4",children:[jsx(IconButton,{variant:"muted",onClick:async()=>{B(),e();},className:"audio-recorder-close-button lua:flex-shrink-0",children:jsx(XIcon,{className:"audio-recorder-close-icon",color:"#00000099"})}),jsxs("div",{className:"audio-recorder-status lua:flex lua:items-center lua:gap-2",children:[jsx("div",{className:`audio-recorder-indicator lua:w-3 lua:h-3 lua:rounded-full ${l?"lua:bg-red-500 lua:animate-pulse":"lua:bg-gray-400"}`}),jsx("span",{className:"audio-recorder-time lua:text-gray-700 lua:text-sm",children:mt(l?s:o||0)})]}),jsx("div",{className:"audio-recorder-visualizer lua:flex-1","data-testid":"audio-visualizer-bar",children:u.length>0&&jsx("div",{className:"audio-recorder-bars lua:h-8 lua:flex lua:items-center lua:w-full lua:gap-px sm:lua:gap-0.5 md:lua:gap-1",children:u.slice(0,50).map((P,k)=>jsx("div",{className:"audio-recorder-bar lua:flex-1 lua:bg-blue-500",style:{height:`${P*100}%`}},k))})}),jsx(IconButton,{onClick:jt,className:"audio-recorder-send-button lua:flex-shrink-0 lua:mr-1","data-testid":"send-audio-button",children:jsx(ArrowUp,{className:"audio-recorder-send-icon",color:"white"})})]})}function aa(t){let e=Math.floor(t/60),a=t%60;return `${e.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`}function Xl({videoRef:t,isRecording:e,recordingTime:a,loading:l,onStartRecording:r,onStopRecording:s,onClose:d,open:u}){return jsx(Dialog,{open:u,onOpenChange:d,children:jsxs(DialogContent,{className:"lua:w-full lua:max-w-2xl lua:p-2.5",showClose:false,children:[jsx(VisuallyHidden,{children:jsx(DialogTitle,{})}),jsxs("div",{className:"lua:relative lua:aspect-[4/3] lua:bg-black lua:rounded-xl lua:overflow-hidden lua:mb-8",children:[jsx("video",{ref:t,autoPlay:true,playsInline:true,muted:true,className:"lua:absolute lua:inset-0 lua:w-full lua:h-full lua:object-cover",style:{backgroundColor:"black"}}),e&&jsxs("div",{className:"lua:absolute lua:top-4 lua:left-4 lua:flex lua:items-center lua:gap-2 lua:bg-black lua:bg-opacity-50 lua:px-3 lua:py-1 lua:rounded-full",children:[jsx("div",{className:"lua:w-2 lua:h-2 lua:rounded-full lua:bg-red-500 lua:animate-pulse"}),jsx("span",{className:"lua:text-sm lua:font-medium lua:text-white",children:aa(a)})]})]}),jsx("div",{className:"lua:flex lua:justify-center lua:items-center lua:gap-5 lua:mb-2.5",children:e?jsx(IconButton,{"data-testid":"stop-recording-button",onClick:s,disabled:l,variant:"secondary",children:jsx(XIcon,{color:"#000000"})}):jsxs("svg",{onClick:r,"data-testid":"start-recording-button",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"cursor-pointer",children:[jsx("rect",{x:"2",y:"2",width:"36",height:"36",rx:"18",stroke:"#FF0342",strokeWidth:"4"}),jsx("rect",{x:"6",y:"6",width:"28",height:"28",rx:"14",fill:"#FF0342"})]})})]})})}function vt({url:t,alt:e,open:a,onClose:l}){return jsxs(Dialog,{open:a,onOpenChange:l,children:[jsx(VisuallyHidden,{children:jsx(DialogTitle,{})}),jsx(DialogContent,{className:"lua:w-full lua:fixed lua:inset-0 lua:h-full lua:max-w-none lua:p-0 lua:bg-transparent lua:shadow-none lua:translate-x-0 lua:translate-y-0 lua:m-0 lua:rounded-none",showClose:false,children:jsxs("div",{className:"lua:relative lua:w-full lua:h-full",children:[jsx("button",{onClick:l,className:"lua:cursor-pointer lua:absolute lua:top-4 lua:left-4 lua:z-10 lua:p-2 lua:bg-black/50 lua:rounded-full lua:hover:bg-black/70 lua:transition-colors",children:jsx(XIcon,{color:"white",className:"lua:w-6 lua:h-6"})}),jsx("div",{className:"lua:w-full lua:h-full lua:flex lua:items-center lua:justify-center",children:jsx("img",{src:t,alt:e,className:"sm:lua:aspect-[16/9] lua:object-contain lua:rounded-none sm:lua:rounded-lg"})})]})})]})}function yt({images:t,initialIndex:e=0,open:a,onClose:l}){let[r,s]=useState(),[d,u]=useState(0);return useEffect(()=>{if(!r)return;e>0&&e<t.length&&(r.scrollTo(e),u(e));let n=()=>{u(r.selectedScrollSnap());};return r.on("select",n),n(),()=>{r?.off("select",n);}},[r,e,t.length]),jsxs(Dialog,{open:a,onOpenChange:l,children:[jsx(VisuallyHidden,{children:jsx(DialogTitle,{})}),jsx(DialogContent,{className:"lua:w-full lua:m-0",showClose:false,children:jsxs("div",{className:"lua:relative lua:w-full lua:h-full",children:[jsx("button",{onClick:l,className:"lua:cursor-pointer lua:absolute lua:top-4 lua:left-4 lua:z-10 lua:p-2 lua:bg-black/50 lua:rounded-full lua:hover:bg-black/70 lua:transition-colors",children:jsx(XIcon,{color:"white",className:"lua:w-6 lua:h-6"})}),t.length>1&&jsxs("div",{className:"lua:absolute lua:top-4 lua:right-4 lua:z-10 lua:px-3 lua:py-1 lua:bg-black/50 lua:rounded-full lua:text-white lua:text-sm",children:[d+1," / ",t.length]}),jsx("div",{className:"lua:w-full lua:h-full lua:flex lua:items-center lua:justify-center lua:px-16",children:jsxs(Carousel,{setApi:s,className:"lua:w-full lua:max-w-5xl",opts:{align:"center",loop:t.length>1},children:[jsx(CarouselContent,{children:t.map((n,p)=>jsx(CarouselItem,{className:"lua:flex lua:items-center lua:justify-center",children:jsx("img",{src:n.src,alt:n.alt||`Image ${p+1}`,className:"lua:max-w-full lua:max-h-screen lua:object-contain lua:rounded-none sm:lua:rounded-lg",draggable:false})},p))}),t.length>1&&jsxs(Fragment,{children:[jsx(CarouselPrevious,{className:"lua:left-4 lua:bg-black/50 lua:border-none lua:text-white lua:hover:bg-black/70 lua:hover:text-white-white/70"}),jsx(CarouselNext,{className:"lua:right-4 lua:bg-black/50 lua:border-none lua:text-white lua:hover:bg-black/70 lua:hover:text-white-white/70"})]})]})})]})})]})}function ir({videoRef:t,canvasRef:e,onCapture:a,onClose:l,open:r}){return jsxs(Dialog,{open:r,onOpenChange:l,children:[jsx(VisuallyHidden,{children:jsx(DialogTitle,{})}),jsxs(DialogContent,{className:"lua:w-full lua:max-w-2xl lua:p-2.5",showClose:false,children:[jsxs("div",{className:"lua:relative lua:aspect-[16/9] lua:bg-black lua:rounded-xl lua:overflow-hidden",children:[jsx("video",{ref:t,autoPlay:true,playsInline:true,muted:true,className:"lua:absolute lua:inset-0 lua:w-full lua:h-full lua:object-cover",style:{backgroundColor:"black"}}),jsx("canvas",{ref:e,className:"lua:hidden"})]}),jsxs("div",{className:"lua:flex lua:justify-center lua:items-center lua:gap-5 lua:mb-2.5 lua:mt-6",children:[jsx(IconButton,{onClick:a,"data-testid":"capture-button",children:jsx(Camera,{color:"#FFFFFF"})}),jsx(IconButton,{onClick:l,variant:"secondary",children:jsx(XIcon,{color:"#000000"})})]})]})]})}function cr({locationError:t,currentLocation:e,loading:a,onShare:l,onClose:r}){return jsx("div",{className:"lua:fixed lua:inset-0 lua:bg-black lua:bg-opacity-75 lua:flex lua:items-center lua:justify-center lua:z-50",children:jsxs("div",{className:"lua:bg-white lua:rounded-lg lua:p-4 lua:max-w-2xl lua:w-full lua:mx-4",children:[jsxs("div",{className:"lua:flex lua:justify-between lua:items-center lua:mb-4",children:[jsx("h3",{className:"lua:text-lg lua:font-semibold",children:"Share Location"}),jsx("button",{onClick:r,className:"lua:text-gray-500 lua:hover:text-gray-700",children:jsx("svg",{className:"lua:w-6 lua:h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t?jsx("div",{className:"lua:bg-red-50 lua:text-red-500 lua:p-4 lua:rounded-lg lua:mb-4",children:t}):e?jsx(Fragment,{children:jsxs("div",{className:"lua:mb-4",children:[jsx("div",{className:"lua:text-sm lua:text-gray-500 lua:mb-2",children:"Current Location:"}),jsx("div",{className:"lua:text-gray-700 lua:mb-2",children:e.address}),jsxs("div",{className:"lua:text-sm lua:text-gray-500",children:[e.latitude.toFixed(6),","," ",e.longitude.toFixed(6)]})]})}):jsx("div",{className:"lua:flex lua:justify-center lua:items-center lua:h-48",children:jsx("div",{className:"lua:animate-spin lua:rounded-full lua:h-8 lua:w-8 lua:border-b-2 lua:border-blue-500"})}),jsx("div",{className:"lua:flex lua:justify-center",children:e&&jsxs("button",{onClick:l,disabled:a,className:`lua:px-4 lua:py-2 lua:rounded-full ${a?"lua:bg-blue-300 lua:cursor-not-allowed":"lua:bg-blue-500 lua:hover:bg-blue-600"} lua:text-white lua:flex lua:items-center lua:gap-2`,children:[jsx("svg",{className:"lua:w-5 lua:h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"})}),a?"Sharing...":"Share Location"]})})]})})}function Ct({children:t,language:e=""}){let[a,l]=useState(false),r=typeof t=="string"?t:String(t),s=e||"javascript";return jsxs("div",{className:"lua:relative lua:my-4 lua:rounded-lg lua:overflow-hidden lua:mx-4 lua:sm:mx-5 lua:grid",children:[jsxs("div",{className:"lua:flex lua:items-center lua:justify-between lua:bg-gray-800 lua:text-gray-200 lua:px-4 lua:py-2",children:[jsx("span",{className:"lua:text-xs lua:font-mono",children:s}),jsx("button",{onClick:()=>{navigator.clipboard.writeText(r),l(true),setTimeout(()=>l(false),2e3);},className:"lua:text-xs lua:bg-gray-700 lua:hover:bg-gray-600 lua:rounded lua:px-2 lua:py-1 lua:transition-colors","aria-label":"Copy code",children:a?"Copied!":"Copy"})]}),jsx(Highlight,{theme:themes.vsDark,code:r,language:s,children:({className:u,style:n,tokens:p,getLineProps:f,getTokenProps:o})=>jsx("pre",{className:`${u} lua:p-4 lua:overflow-x-auto`,style:n,children:p.map((i,h)=>jsx("div",{...f({line:i}),children:i.map((c,v)=>jsx("span",{...o({token:c})},v))},h))})})]})}var L={p:"lua:mb-2 lua:last:mb-0 lua:mx-4 lua:sm:mx-5 lua-paragraph-markdown",h1:"lua:text-2xl lua:font-bold lua:mb-2 lua:mx-4 lua:sm:mx-5",h2:"lua:text-xl lua:font-semibold lua:mb-2 lua:text-gray-700 lua:mx-4 lua:sm:mx-5",h3:"lua:text-lg lua:font-medium lua:mb-2 lua:mx-4 lua:sm:mx-5",h4:"lua:mx-4 lua:sm:mx-5",ul:"lua:list-disc lua:pl-6 lua:mb-4",ol:"lua:list-decimal lua:pl-6 lua:mb-4 lua:mx-4 lua:sm:mx-5",li:"lua:mb-1 lua:mx-4 lua:sm:mx-5",a:"lua:text-blue-500 lua:hover:underline",blockquote:"lua:border-l-4 lua:border-gray-200 lua:pl-4 lua:italic lua:my-4",pre:"lua:contents lua:bg-gray-100 lua:rounded lua:px-1 lua:text-gray-700 lua:mx-4 lua:sm:mx-5",code:"lua:bg-gray-100 lua:rounded lua:px-1 lua:mx-4 lua:sm:mx-5",img:"lua:max-w-full lua:h-auto lua:rounded-lg lua:mb-2",table:"lua:min-w-full lua:border lua:border-gray-200 lua:my-4",th:"lua:bg-gray-100 lua:border lua:border-gray-200 lua:px-4 lua:py-2",td:"lua:border lua:border-gray-200 lua:px-4 lua:py-2"};var Ra=t=>({code({children:e,className:a,...l}){let r=a?.replace("language-","")||"";return typeof e=="string"&&!e.includes(`
1
+ import {Logo,MapPin,Button,CreditCard,Dialog,DialogTitle,DialogContent,XIcon,Carousel,CarouselContent,CarouselItem,CarouselPrevious,CarouselNext,IconButton,ArrowUp,Camera,Tooltip,TooltipTrigger,Paperclip,TooltipContent,TooltipArrow,VideoCamera,Microphone}from'luaniverse';import {memo,useCallback,createContext,useState,useRef,useEffect,useContext}from'react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {VisuallyHidden}from'@radix-ui/react-visually-hidden';import St from'react-markdown';import {Highlight,themes}from'prism-react-renderer';import {MapContainer,TileLayer,Marker,Popup}from'react-leaflet';function $l({onAudioRecorded:t,onClose:e,inputMessage:a}){let[l,r]=useState(false),[s,d]=useState(0),[u,n]=useState([]),[p,f]=useState(null),[o,i]=useState(null),h=useRef(null),c=useRef(null),v=useRef([]),g=useRef(null),C=useRef(null),x=useRef(null),N=useRef(null),m=useRef(false),w=useRef(false),U=useRef(null);useEffect(()=>{if(!l||!p)return;let P=setInterval(()=>{let k=Math.floor((Date.now()-p)/1e3);d(k);},1e3);return ()=>clearInterval(P)},[l,p]),useEffect(()=>((async()=>{if(!(m.current||w.current))try{m.current=!0;let k=await navigator.mediaDevices.getUserMedia({audio:!0});h.current=k,g.current=new AudioContext,C.current=g.current.createAnalyser(),C.current.fftSize=256,g.current.createMediaStreamSource(k).connect(C.current),x.current=new Uint8Array(C.current.frequencyBinCount);let q=()=>{if(!C.current||!x.current)return;C.current.getByteFrequencyData(x.current);let Wt=Array.from(x.current).map(Xt=>Xt/255);n(Wt),N.current=requestAnimationFrame(q);};q(),_t();}catch(k){console.error("Error accessing microphone:",k),e();}finally{m.current=false;}})(),()=>{B();}),[]);let B=()=>{if(!w.current)try{if(w.current=!0,l&&c.current&&(c.current.stop(),r(!1),f(null)),h.current){let P=h.current.getAudioTracks(),k=h.current.getVideoTracks();P.forEach(A=>{A.stop(),A.enabled=!1;}),k.forEach(A=>{A.stop(),A.enabled=!1;});}N.current&&cancelAnimationFrame(N.current),g.current&&g.current.close(),h.current=null,c.current=null,v.current=[],g.current=null,C.current=null,x.current=null,N.current=null;}finally{w.current=false;}},_t=()=>{if(!h.current)return;let k=["audio/webm","audio/mp4","audio/ogg","audio/wav"].find(q=>MediaRecorder.isTypeSupported(q));if(!k){console.error("No supported MIME type found for MediaRecorder"),e();return}U.current=k;let A=new MediaRecorder(h.current,{mimeType:k});c.current=A,v.current=[],A.ondataavailable=q=>{q.data.size>0&&v.current.push(q.data);},A.start(),r(true),f(Date.now()),d(0);},jt=async()=>{if(!c.current||!h.current)return;r(false),i(s),f(null),c.current.stop(),await new Promise(k=>{c.current&&(c.current.onstop=()=>k());});let P=new Blob(v.current,{type:U.current||"audio/webm"});t(P,a),B(),e();},mt=P=>{let k=Math.floor(P/60),A=P%60;return `${k.toString().padStart(2,"0")}:${A.toString().padStart(2,"0")}`};return jsxs("div",{className:"audio-recorder-container lua:bg-gray-100 lua:rounded-lg lua:p-2 lua:flex lua:items-center lua:gap-4",children:[jsx(IconButton,{variant:"muted",onClick:async()=>{B(),e();},className:"audio-recorder-close-button lua:flex-shrink-0",children:jsx(XIcon,{className:"audio-recorder-close-icon",color:"#00000099"})}),jsxs("div",{className:"audio-recorder-status lua:flex lua:items-center lua:gap-2",children:[jsx("div",{className:`audio-recorder-indicator lua:w-3 lua:h-3 lua:rounded-full ${l?"lua:bg-red-500 lua:animate-pulse":"lua:bg-gray-400"}`}),jsx("span",{className:"audio-recorder-time lua:text-gray-700 lua:text-sm",children:mt(l?s:o||0)})]}),jsx("div",{className:"audio-recorder-visualizer lua:flex-1","data-testid":"audio-visualizer-bar",children:u.length>0&&jsx("div",{className:"audio-recorder-bars lua:h-8 lua:flex lua:items-center lua:w-full lua:gap-px sm:lua:gap-0.5 md:lua:gap-1",children:u.slice(0,50).map((P,k)=>jsx("div",{className:"audio-recorder-bar lua:flex-1 lua:bg-blue-500",style:{height:`${P*100}%`}},k))})}),jsx(IconButton,{onClick:jt,className:"audio-recorder-send-button lua:flex-shrink-0 lua:mr-1","data-testid":"send-audio-button",children:jsx(ArrowUp,{className:"audio-recorder-send-icon",color:"white"})})]})}function aa(t){let e=Math.floor(t/60),a=t%60;return `${e.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`}function Xl({videoRef:t,isRecording:e,recordingTime:a,loading:l,onStartRecording:r,onStopRecording:s,onClose:d,open:u}){return jsx(Dialog,{open:u,onOpenChange:d,children:jsxs(DialogContent,{className:"lua:w-full lua:max-w-2xl lua:p-2.5",showClose:false,children:[jsx(VisuallyHidden,{children:jsx(DialogTitle,{})}),jsxs("div",{className:"lua:relative lua:aspect-[4/3] lua:bg-black lua:rounded-xl lua:overflow-hidden lua:mb-8",children:[jsx("video",{ref:t,autoPlay:true,playsInline:true,muted:true,className:"lua:absolute lua:inset-0 lua:w-full lua:h-full lua:object-cover",style:{backgroundColor:"black"}}),e&&jsxs("div",{className:"lua:absolute lua:top-4 lua:left-4 lua:flex lua:items-center lua:gap-2 lua:bg-black lua:bg-opacity-50 lua:px-3 lua:py-1 lua:rounded-full",children:[jsx("div",{className:"lua:w-2 lua:h-2 lua:rounded-full lua:bg-red-500 lua:animate-pulse"}),jsx("span",{className:"lua:text-sm lua:font-medium lua:text-white",children:aa(a)})]})]}),jsx("div",{className:"lua:flex lua:justify-center lua:items-center lua:gap-5 lua:mb-2.5",children:e?jsx(IconButton,{"data-testid":"stop-recording-button",onClick:s,disabled:l,variant:"secondary",children:jsx(XIcon,{color:"#000000"})}):jsxs("svg",{onClick:r,"data-testid":"start-recording-button",width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"cursor-pointer",children:[jsx("rect",{x:"2",y:"2",width:"36",height:"36",rx:"18",stroke:"#FF0342",strokeWidth:"4"}),jsx("rect",{x:"6",y:"6",width:"28",height:"28",rx:"14",fill:"#FF0342"})]})})]})})}function vt({url:t,alt:e,open:a,onClose:l}){return jsxs(Dialog,{open:a,onOpenChange:l,children:[jsx(VisuallyHidden,{children:jsx(DialogTitle,{})}),jsx(DialogContent,{className:"lua:w-full lua:fixed lua:inset-0 lua:h-full lua:max-w-none lua:p-0 lua:bg-transparent lua:shadow-none lua:translate-x-0 lua:translate-y-0 lua:m-0 lua:rounded-none",showClose:false,children:jsxs("div",{className:"lua:relative lua:w-full lua:h-full",children:[jsx("button",{onClick:l,className:"lua:cursor-pointer lua:absolute lua:top-4 lua:left-4 lua:z-10 lua:p-2 lua:bg-black/50 lua:rounded-full lua:hover:bg-black/70 lua:transition-colors",children:jsx(XIcon,{color:"white",className:"lua:w-6 lua:h-6"})}),jsx("div",{className:"lua:w-full lua:h-full lua:flex lua:items-center lua:justify-center",children:jsx("img",{src:t,alt:e,className:"sm:lua:aspect-[16/9] lua:object-contain lua:rounded-none sm:lua:rounded-lg"})})]})})]})}function yt({images:t,initialIndex:e=0,open:a,onClose:l}){let[r,s]=useState(),[d,u]=useState(0);return useEffect(()=>{if(!r)return;e>0&&e<t.length&&(r.scrollTo(e),u(e));let n=()=>{u(r.selectedScrollSnap());};return r.on("select",n),n(),()=>{r?.off("select",n);}},[r,e,t.length]),jsxs(Dialog,{open:a,onOpenChange:l,children:[jsx(VisuallyHidden,{children:jsx(DialogTitle,{})}),jsx(DialogContent,{className:"lua:w-full lua:m-0",showClose:false,children:jsxs("div",{className:"lua:relative lua:w-full lua:h-full",children:[jsx("button",{onClick:l,className:"lua:cursor-pointer lua:absolute lua:top-4 lua:left-4 lua:z-10 lua:p-2 lua:bg-black/50 lua:rounded-full lua:hover:bg-black/70 lua:transition-colors",children:jsx(XIcon,{color:"white",className:"lua:w-6 lua:h-6"})}),t.length>1&&jsxs("div",{className:"lua:absolute lua:top-4 lua:right-4 lua:z-10 lua:px-3 lua:py-1 lua:bg-black/50 lua:rounded-full lua:text-white lua:text-sm",children:[d+1," / ",t.length]}),jsx("div",{className:"lua:w-full lua:h-full lua:flex lua:items-center lua:justify-center lua:px-16",children:jsxs(Carousel,{setApi:s,className:"lua:w-full lua:max-w-5xl",opts:{align:"center",loop:t.length>1},children:[jsx(CarouselContent,{children:t.map((n,p)=>jsx(CarouselItem,{className:"lua:flex lua:items-center lua:justify-center",children:jsx("img",{src:n.src,alt:n.alt||`Image ${p+1}`,className:"lua:max-w-full lua:max-h-screen lua:object-contain lua:rounded-none sm:lua:rounded-lg",draggable:false})},p))}),t.length>1&&jsxs(Fragment,{children:[jsx(CarouselPrevious,{className:"lua:left-4 lua:bg-black/50 lua:border-none lua:text-white lua:hover:bg-black/70 lua:hover:text-white-white/70"}),jsx(CarouselNext,{className:"lua:right-4 lua:bg-black/50 lua:border-none lua:text-white lua:hover:bg-black/70 lua:hover:text-white-white/70"})]})]})})]})})]})}function ir({videoRef:t,canvasRef:e,onCapture:a,onClose:l,open:r}){return jsxs(Dialog,{open:r,onOpenChange:l,children:[jsx(VisuallyHidden,{children:jsx(DialogTitle,{})}),jsxs(DialogContent,{className:"lua:w-full lua:max-w-2xl lua:p-2.5",showClose:false,children:[jsxs("div",{className:"lua:relative lua:aspect-[16/9] lua:bg-black lua:rounded-xl lua:overflow-hidden",children:[jsx("video",{ref:t,autoPlay:true,playsInline:true,muted:true,className:"lua:absolute lua:inset-0 lua:w-full lua:h-full lua:object-cover",style:{backgroundColor:"black"}}),jsx("canvas",{ref:e,className:"lua:hidden"})]}),jsxs("div",{className:"lua:flex lua:justify-center lua:items-center lua:gap-5 lua:mb-2.5 lua:mt-6",children:[jsx(IconButton,{onClick:a,"data-testid":"capture-button",children:jsx(Camera,{color:"#FFFFFF"})}),jsx(IconButton,{onClick:l,variant:"secondary",children:jsx(XIcon,{color:"#000000"})})]})]})]})}function cr({locationError:t,currentLocation:e,loading:a,onShare:l,onClose:r}){return jsx("div",{className:"lua:fixed lua:inset-0 lua:bg-black lua:bg-opacity-75 lua:flex lua:items-center lua:justify-center lua:z-50",children:jsxs("div",{className:"lua:bg-white lua:rounded-lg lua:p-4 lua:max-w-2xl lua:w-full lua:mx-4",children:[jsxs("div",{className:"lua:flex lua:justify-between lua:items-center lua:mb-4",children:[jsx("h3",{className:"lua:text-lg lua:font-semibold",children:"Share Location"}),jsx("button",{onClick:r,className:"lua:text-gray-500 lua:hover:text-gray-700",children:jsx("svg",{className:"lua:w-6 lua:h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t?jsx("div",{className:"lua:bg-red-50 lua:text-red-500 lua:p-4 lua:rounded-lg lua:mb-4",children:t}):e?jsx(Fragment,{children:jsxs("div",{className:"lua:mb-4",children:[jsx("div",{className:"lua:text-sm lua:text-gray-500 lua:mb-2",children:"Current Location:"}),jsx("div",{className:"lua:text-gray-700 lua:mb-2",children:e.address}),jsxs("div",{className:"lua:text-sm lua:text-gray-500",children:[e.latitude.toFixed(6),","," ",e.longitude.toFixed(6)]})]})}):jsx("div",{className:"lua:flex lua:justify-center lua:items-center lua:h-48",children:jsx("div",{className:"lua:animate-spin lua:rounded-full lua:h-8 lua:w-8 lua:border-b-2 lua:border-blue-500"})}),jsx("div",{className:"lua:flex lua:justify-center",children:e&&jsxs("button",{onClick:l,disabled:a,className:`lua:px-4 lua:py-2 lua:rounded-full ${a?"lua:bg-blue-300 lua:cursor-not-allowed":"lua:bg-blue-500 lua:hover:bg-blue-600"} lua:text-white lua:flex lua:items-center lua:gap-2`,children:[jsx("svg",{className:"lua:w-5 lua:h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"})}),a?"Sharing...":"Share Location"]})})]})})}function Ct({children:t,language:e=""}){let[a,l]=useState(false),r=typeof t=="string"?t:String(t),s=e||"javascript";return jsxs("div",{className:"lua:relative lua:my-4 lua:rounded-lg lua:overflow-hidden lua:mx-4 lua:sm:mx-5 lua:grid",children:[jsxs("div",{className:"lua:flex lua:items-center lua:justify-between lua:bg-gray-800 lua:text-gray-200 lua:px-4 lua:py-2",children:[jsx("span",{className:"lua:text-xs lua:font-mono",children:s}),jsx("button",{onClick:()=>{navigator.clipboard.writeText(r),l(true),setTimeout(()=>l(false),2e3);},className:"lua:text-xs lua:bg-gray-700 lua:hover:bg-gray-600 lua:rounded lua:px-2 lua:py-1 lua:transition-colors","aria-label":"Copy code",children:a?"Copied!":"Copy"})]}),jsx(Highlight,{theme:themes.vsDark,code:r,language:s,children:({className:u,style:n,tokens:p,getLineProps:f,getTokenProps:o})=>jsx("pre",{className:`${u} lua:p-4 lua:overflow-x-auto`,style:n,children:p.map((i,h)=>jsx("div",{...f({line:i}),children:i.map((c,v)=>jsx("span",{...o({token:c})},v))},h))})})]})}var L={p:"lua:mb-2 lua:last:mb-0 lua:mx-4 lua:sm:mx-5 lua-paragraph-markdown",h1:"lua:text-2xl lua:font-bold lua:mb-2 lua:mx-4 lua:sm:mx-5",h2:"lua:text-xl lua:font-semibold lua:mb-2 lua:text-gray-700 lua:mx-4 lua:sm:mx-5",h3:"lua:text-lg lua:font-medium lua:mb-2 lua:mx-4 lua:sm:mx-5",h4:"lua:mx-4 lua:sm:mx-5",ul:"lua:list-disc lua:pl-6 lua:mb-4",ol:"lua:list-decimal lua:pl-6 lua:mb-4 lua:mx-4 lua:sm:mx-5",li:"lua:mb-1 lua:mx-4 lua:sm:mx-5",a:"lua:text-blue-500 lua:hover:underline",blockquote:"lua:border-l-4 lua:border-gray-200 lua:pl-4 lua:italic lua:my-4",pre:"lua:contents lua:bg-gray-100 lua:rounded lua:px-1 lua:text-gray-700 lua:mx-4 lua:sm:mx-5",code:"lua:bg-gray-100 lua:rounded lua:px-1 lua:mx-4 lua:sm:mx-5",img:"lua:max-w-full lua:h-auto lua:rounded-lg lua:mb-2",table:"lua:min-w-full lua:border lua:border-gray-200 lua:my-4",th:"lua:bg-gray-100 lua:border lua:border-gray-200 lua:px-4 lua:py-2",td:"lua:border lua:border-gray-200 lua:px-4 lua:py-2"};var Ra=t=>({code({children:e,className:a,...l}){let r=a?.replace("language-","")||"";return typeof e=="string"&&!e.includes(`
2
2
  `)?jsx("code",{className:L.code,...l,children:e}):jsx(Ct,{language:r,className:a,children:e})},p({children:e,...a}){return jsx("p",{className:L.p,...a,children:e})},h1({children:e,...a}){return jsx("h1",{className:L.h1,...a,children:e})},h2({children:e,...a}){return jsx("h2",{className:L.h2,...a,children:e})},h3({children:e,...a}){return jsx("h3",{className:L.h3,...a,children:e})},h4({children:e,...a}){return jsx("h4",{className:L.h4,...a,children:e})},img({src:e,alt:a}){return jsx("img",{src:e,alt:a,className:"lua:w-full lua:h-48 lua:object-cover lua:rounded-lg lua:mb-3"})},ul({children:e,...a}){return jsx("ul",{className:L.ul,...a,children:e})},ol({children:e,...a}){return jsx("ol",{className:L.ol,...a,children:e})},li({children:e,...a}){return jsx("li",{className:`${L.li} cursor-pointer hover:bg-gray-50 rounded px-2 -mx-2 transition-colors`,onClick:()=>t(e),...a,children:e})},a({href:e,children:a,...l}){return jsx("a",{href:e,className:L.a,target:"_blank",rel:"noopener noreferrer",...l,children:a})},blockquote({children:e,...a}){return jsx("blockquote",{className:L.blockquote,...a,children:e})},pre({children:e}){return jsx(Fragment,{children:e})},table({children:e,...a}){return jsx("table",{className:L.table,...a,children:e})},th({children:e,...a}){return jsx("th",{className:L.th,...a,children:e})},td({children:e,...a}){return jsx("td",{className:L.td,...a,children:e})}}),be=Ra;function Ua(t){let e=new URL(t,"http://lua"),a=decodeURIComponent(e.pathname),l={};for(let[r,s]of e.searchParams.entries())l[r]=decodeURIComponent(s);return {pathname:a,queryParams:l}}var we=Ua;function Da(t){let e=t.match(/\[navigate\]\(([^)]+)\)/);return e?e[1]:null}var Nt=Da;var Fa=memo(function({block:e,onCardClick:a,onListItemClick:l,onNavigate:r}){let s=e.content.match(/^#\s+(.+)$/m),d=e.content.match(/!\[.*?]\((.*)\)/),u=s?s[1]:"",n=d?d[1]:null,p=Nt(e.content),f=e.content.replace(/^#\s+.+$/m,"").replace(/!\[.*?]\(.*?\)/g,"").replace(/\[.*?]\(.*?\)/g,"").trim(),o=be(l);return jsxs("div",{onClick:()=>{if(r&&p){let h=we(p);r(h.pathname,{...h.queryParams&&{query:h.queryParams}});}else a(e.content);},className:"chat-list-item group",children:[jsx("div",{className:"lua:absolute lua:inset-0 lua:bg-blue-500 lua:opacity-0 group-hover:lua:opacity-5 lua:rounded-lg lua:transition-opacity lua:duration-200"}),jsxs("div",{className:"chat-list-item-content",children:[n?jsx("div",{className:"chat-list-item-image-wrapper",children:jsx("img",{className:"chat-list-item-image",src:n,alt:u})}):null,jsxs("div",{className:"content-container",children:[jsx("h1",{className:"lua:text-base lua:leading-6 lua:font-semibold lua:text-gray-900 lua:mb-0",children:u}),jsx("div",{className:"lua:text-sm lua:leading-6 lua:font-normal lua:text-gray-600",children:jsx(St,{components:o,children:f})})]})]})]})}),re=Fa;var Ba=memo(function({group:e,onCardClick:a,onListItemClick:l,onNavigate:r}){return jsx("div",{className:"lua:w-full",children:jsx("div",{className:"chat-list-item-container",children:e.map((s,d)=>jsx(re,{block:s,onCardClick:a,onListItemClick:l,onNavigate:r},d))})})}),kt=Ba;function Oa(t){return {icon:()=>null}}function Ne({documents:t}){return t.map(e=>{let l=Oa(new File([],"",{type:e.mimeType})).icon;return jsx("a",{"data-testid":"chat-file-message",href:e.url,target:"_blank",rel:"noopener noreferrer",className:"chat-file-message lua:mx-4 lua:sm:mx-5",children:jsx("div",{className:"lua:flex lua:flex-col lua:gap-8",children:jsxs("div",{className:"chat-file-card lua:flex lua:items-center lua:justify-start lua:p-3 lua:border lua:border-gray-200 lua:rounded-lg lua:bg-white lua:w-80",children:[jsx(l,{className:"lua:w-12 lua:h-12 lua:text-gray-500"}),jsxs("div",{className:"lua:flex lua:flex-col lua:gap-1 lua:pl-2",children:[e.fileName||"File",jsx("span",{className:"lua:text-gray-500 lua:text-sm",children:e.mimeType})]})]})})},e.url)})}function $a(t){let e=[],a=t.split(`
3
3
  `).filter(l=>l.trim()!=="");for(let l of a){let r=/\[([^\]]+)\]\(([^)]+)\)\s+filename:([^\s]+)\s+mime:([^\s]+)/g,s;for(;(s=r.exec(l))!==null;){let[,d,u,n,p]=s;e.push({fileName:d.trim(),url:u.trim(),filename:n.trim(),mimeType:p.trim()});}}return e}var De=$a;function Lt({message:t}){return jsx("div",{className:"chat-audio-message lua:flex lua:flex-col lua:mx-4 lua:sm:mx-5","data-testid":"audio-preview",children:jsx("div",{className:"chat-audio-container audio-playback-container lua:relative",children:jsxs("div",{className:"chat-audio-controls lua:flex lua:items-center lua:gap-2 lua:min-w-full",children:[jsx("audio",{src:t.url,controls:true,className:"chat-audio-player lua:h-8",style:{backgroundColor:"transparent",border:"none"}}),t.isUploading&&jsx("div",{className:"chat-audio-upload-overlay lua:absolute lua:inset-0 lua:bg-black lua:bg-opacity-50 lua:rounded-lg lua:flex lua:items-center lua:justify-center",children:jsx("div",{className:"lua:text-white lua:text-sm",children:"Uploading..."})})]})})})}function Ee({url:t}){return jsxs(Button,{onClick:a=>{if(a.preventDefault(),/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)){window.open(t,"_blank","noopener,noreferrer");return}let r=500,s=600,d=window.screen.width/2-r/2,u=window.screen.height/2-s/2,n=window.open(t,"Payment",`width=${r},height=${s},left=${d},top=${u},toolbar=no,menubar=no,scrollbars=yes,resizable=yes`);(!n||n.closed||typeof n.closed>"u")&&window.open(t,"_blank","noopener,noreferrer");},className:"chat-payment-button lua:rounded-xl",children:[jsx(CreditCard,{size:16}),jsx("span",{children:"Open payment"})]})}var ja=t=>t.split(`
4
4
  `).filter(a=>a.trim()).filter(a=>a.trim().startsWith("-")).map(a=>({text:a.trim().substring(1).trim(),onClick:a.trim().substring(1).trim()})),Se=ja;var Wa=t=>{let e=/!\[(.*?)\]\((.*)\)/g,a=[],l;for(;(l=e.exec(t))!==null;)l[1]&&l[2]&&a.push({alt:l[1],src:l[2]});return a},Fe=Wa;var Xa=t=>{let e=/\[.*?\]\((.*?)\)/g,a=[],l;for(;(l=e.exec(t))!==null;)l[1]&&a.push(l[1]);return a},He=Xa;function Be(t){let e=t.match(/!\[([^\]]+)\]\(([^)]+)\)/);if(!e)return null;let[,a,l]=e;return {text:a,url:l}}var Ga=t=>{let e=/\[.*?\]\((.*?)\)/,a=t.match(e);return a?a[1]:null},Oe=Ga;var $e=t=>typeof t=="string"?t:Array.isArray(t)?t.map($e).join(""):typeof t=="object"&&t!==null&&"props"in t?$e(t.props.children):"",Pt=$e;function Ka(t){return t.replace(/([^\n]):::/g,`$1