lua-ai-chat 0.0.15 → 0.0.16
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/README.md +23 -0
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {LogoSpinner,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 Ot from'react-markdown';import {Highlight,themes}from'prism-react-renderer';import el from'dompurify';import {MapContainer,TileLayer,Marker,Popup}from'react-leaflet';function jl({onAudioRecorded:t,onClose:e,inputMessage:a}){let[l,r]=useState(false),[o,u]=useState(0),[c,i]=useState([]),[m,p]=useState(null),[n,s]=useState(null),g=useRef(null),x=useRef(null),d=useRef([]),v=useRef(null),h=useRef(null),N=useRef(null),w=useRef(null),f=useRef(false),y=useRef(false),U=useRef(null);useEffect(()=>{if(!l||!m)return;let P=setInterval(()=>{let k=Math.floor((Date.now()-m)/1e3);u(k);},1e3);return ()=>clearInterval(P)},[l,m]),useEffect(()=>((async()=>{if(!(f.current||y.current))try{f.current=!0;let k=await navigator.mediaDevices.getUserMedia({audio:!0});g.current=k,v.current=new AudioContext,h.current=v.current.createAnalyser(),h.current.fftSize=256,v.current.createMediaStreamSource(k).connect(h.current),N.current=new Uint8Array(h.current.frequencyBinCount);let _=()=>{if(!h.current||!N.current)return;h.current.getByteFrequencyData(N.current);let Kt=Array.from(N.current).map(Qt=>Qt/255);i(Kt),w.current=requestAnimationFrame(_);};_(),Xt();}catch(k){console.error("Error accessing microphone:",k),e();}finally{f.current=false;}})(),()=>{O();}),[]);let O=()=>{if(!y.current)try{if(y.current=!0,l&&x.current&&(x.current.stop(),r(!1),p(null)),g.current){let P=g.current.getAudioTracks(),k=g.current.getVideoTracks();P.forEach(A=>{A.stop(),A.enabled=!1;}),k.forEach(A=>{A.stop(),A.enabled=!1;});}w.current&&cancelAnimationFrame(w.current),v.current&&v.current.close(),g.current=null,x.current=null,d.current=[],v.current=null,h.current=null,N.current=null,w.current=null;}finally{y.current=false;}},Xt=()=>{if(!g.current)return;let k=["audio/webm","audio/mp4","audio/ogg","audio/wav"].find(_=>MediaRecorder.isTypeSupported(_));if(!k){console.error("No supported MIME type found for MediaRecorder"),e();return}U.current=k;let A=new MediaRecorder(g.current,{mimeType:k});x.current=A,d.current=[],A.ondataavailable=_=>{_.data.size>0&&d.current.push(_.data);},A.start(),r(true),p(Date.now()),u(0);},Gt=async()=>{if(!x.current||!g.current)return;r(false),s(o),p(null),x.current.stop(),await new Promise(k=>{x.current&&(x.current.onstop=()=>k());});let P=new Blob(d.current,{type:U.current||"audio/webm"});t(P,a),O(),e();},pt=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()=>{O(),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:pt(l?o:n||0)})]}),jsx("div",{className:"audio-recorder-visualizer lua:flex-1","data-testid":"audio-visualizer-bar",children:c.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 lua:md:gap-1",children:c.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:Gt,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 oa(t){let e=Math.floor(t/60),a=t%60;return `${e.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`}function Yl({videoRef:t,isRecording:e,recordingTime:a,loading:l,onStartRecording:r,onStopRecording:o,onClose:u,open:c}){return jsx(Dialog,{open:c,onOpenChange:u,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:oa(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:o,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 xt({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 bt({images:t,initialIndex:e=0,open:a,onClose:l}){let[r,o]=useState(),[u,c]=useState(0);return useEffect(()=>{if(!r)return;e>0&&e<t.length&&(r.scrollTo(e),c(e));let i=()=>{c(r.selectedScrollSnap());};return r.on("select",i),i(),()=>{r?.off("select",i);}},[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:[u+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:o,className:"lua:w-full lua:max-w-5xl",opts:{align:"center",loop:t.length>1},children:[jsx(CarouselContent,{children:t.map((i,m)=>jsx(CarouselItem,{className:"lua:flex lua:items-center lua:justify-center",children:jsx("img",{src:i.src,alt:i.alt||`Image ${m+1}`,className:"lua:max-w-full lua:max-h-screen lua:object-contain lua:rounded-none sm:lua:rounded-lg",draggable:false})},m))}),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 pr({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 hr({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 Ra(t){let e=[],a=t.split(`
|
|
2
|
-
`).filter(l=>l.trim()!=="");for(let l of a){let r=/\[([^\]]+)\]\(([^)]+)\)\s+filename:([^\s]+)\s+mime:([^\s]+)/g,o;for(;(o=r.exec(l))!==null;){let[,u,c,i,m]=o;e.push({fileName:u.trim(),url:c.trim(),filename:i.trim(),mediaType:m.trim()});}}return e}var Ie=Ra;function
|
|
3
|
-
`)?jsx("code",{className:T.code,...l,children:e}):jsx(
|
|
1
|
+
import {LogoSpinner,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 Ot from'react-markdown';import {Highlight,themes}from'prism-react-renderer';import el from'dompurify';import {MapContainer,TileLayer,Marker,Popup}from'react-leaflet';function jl({onAudioRecorded:t,onClose:e,inputMessage:a}){let[l,r]=useState(false),[o,u]=useState(0),[c,i]=useState([]),[m,g]=useState(null),[n,s]=useState(null),p=useRef(null),y=useRef(null),d=useRef([]),v=useRef(null),h=useRef(null),k=useRef(null),w=useRef(null),f=useRef(false),x=useRef(false),U=useRef(null);useEffect(()=>{if(!l||!m)return;let P=setInterval(()=>{let N=Math.floor((Date.now()-m)/1e3);u(N);},1e3);return ()=>clearInterval(P)},[l,m]),useEffect(()=>((async()=>{if(!(f.current||x.current))try{f.current=!0;let N=await navigator.mediaDevices.getUserMedia({audio:!0});p.current=N,v.current=new AudioContext,h.current=v.current.createAnalyser(),h.current.fftSize=256,v.current.createMediaStreamSource(N).connect(h.current),k.current=new Uint8Array(h.current.frequencyBinCount);let _=()=>{if(!h.current||!k.current)return;h.current.getByteFrequencyData(k.current);let Kt=Array.from(k.current).map(Qt=>Qt/255);i(Kt),w.current=requestAnimationFrame(_);};_(),Xt();}catch(N){console.error("Error accessing microphone:",N),e();}finally{f.current=false;}})(),()=>{O();}),[]);let O=()=>{if(!x.current)try{if(x.current=!0,l&&y.current&&(y.current.stop(),r(!1),g(null)),p.current){let P=p.current.getAudioTracks(),N=p.current.getVideoTracks();P.forEach(A=>{A.stop(),A.enabled=!1;}),N.forEach(A=>{A.stop(),A.enabled=!1;});}w.current&&cancelAnimationFrame(w.current),v.current&&v.current.close(),p.current=null,y.current=null,d.current=[],v.current=null,h.current=null,k.current=null,w.current=null;}finally{x.current=false;}},Xt=()=>{if(!p.current)return;let N=["audio/webm","audio/mp4","audio/ogg","audio/wav"].find(_=>MediaRecorder.isTypeSupported(_));if(!N){console.error("No supported MIME type found for MediaRecorder"),e();return}U.current=N;let A=new MediaRecorder(p.current,{mimeType:N});y.current=A,d.current=[],A.ondataavailable=_=>{_.data.size>0&&d.current.push(_.data);},A.start(),r(true),g(Date.now()),u(0);},Gt=async()=>{if(!y.current||!p.current)return;r(false),s(o),g(null),y.current.stop(),await new Promise(N=>{y.current&&(y.current.onstop=()=>N());});let P=new Blob(d.current,{type:U.current||"audio/webm"});t(P,a),O(),e();},gt=P=>{let N=Math.floor(P/60),A=P%60;return `${N.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()=>{O(),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:gt(l?o:n||0)})]}),jsx("div",{className:"audio-recorder-visualizer lua:flex-1","data-testid":"audio-visualizer-bar",children:c.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 lua:md:gap-1",children:c.slice(0,50).map((P,N)=>jsx("div",{className:"audio-recorder-bar lua:flex-1 lua:bg-blue-500",style:{height:`${P*100}%`}},N))})}),jsx(IconButton,{onClick:Gt,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 oa(t){let e=Math.floor(t/60),a=t%60;return `${e.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`}function Yl({videoRef:t,isRecording:e,recordingTime:a,loading:l,onStartRecording:r,onStopRecording:o,onClose:u,open:c}){return jsx(Dialog,{open:c,onOpenChange:u,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:oa(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:o,disabled:l,variant:"secondary",children:jsx(XIcon,{className:"lua:text-gray-900 lua:dark:text-gray-100"})}):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 yt({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 bt({images:t,initialIndex:e=0,open:a,onClose:l}){let[r,o]=useState(),[u,c]=useState(0);return useEffect(()=>{if(!r)return;e>0&&e<t.length&&(r.scrollTo(e),c(e));let i=()=>{c(r.selectedScrollSnap());};return r.on("select",i),i(),()=>{r?.off("select",i);}},[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:[u+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:o,className:"lua:w-full lua:max-w-5xl",opts:{align:"center",loop:t.length>1},children:[jsx(CarouselContent,{children:t.map((i,m)=>jsx(CarouselItem,{className:"lua:flex lua:items-center lua:justify-center",children:jsx("img",{src:i.src,alt:i.alt||`Image ${m+1}`,className:"lua:max-w-full lua:max-h-screen lua:object-contain lua:rounded-none sm:lua:rounded-lg",draggable:false})},m))}),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 gr({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,{className:"lua:text-white"})}),jsx(IconButton,{onClick:l,variant:"secondary",children:jsx(XIcon,{className:"lua:text-gray-900 lua:dark:text-gray-100"})})]})]})]})}function hr({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:dark:bg-gray-800 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 lua:text-gray-900 lua:dark:text-gray-50",children:"Share Location"}),jsx("button",{onClick:r,className:"lua:text-gray-500 lua:dark:text-gray-400 lua:hover:text-gray-700 lua:dark:hover:text-gray-200",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:dark:bg-red-900/30 lua:text-red-500 lua:dark:text-red-400 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:dark:text-gray-400 lua:mb-2",children:"Current Location:"}),jsx("div",{className:"lua:text-gray-700 lua:dark:text-gray-200 lua:mb-2",children:e.address}),jsxs("div",{className:"lua:text-sm lua:text-gray-500 lua:dark:text-gray-400",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:dark:bg-blue-800 lua:cursor-not-allowed":"lua:bg-blue-500 lua:hover:bg-blue-600 lua:dark:bg-blue-600 lua:dark:hover:bg-blue-700"} 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 Ra(t){let e=[],a=t.split(`
|
|
2
|
+
`).filter(l=>l.trim()!=="");for(let l of a){let r=/\[([^\]]+)\]\(([^)]+)\)\s+filename:([^\s]+)\s+mime:([^\s]+)/g,o;for(;(o=r.exec(l))!==null;){let[,u,c,i,m]=o;e.push({fileName:u.trim(),url:c.trim(),filename:i.trim(),mediaType:m.trim()});}}return e}var Ie=Ra;function kt({children:t,language:e=""}){let[a,l]=useState(false),r=typeof t=="string"?t:String(t),o=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:o}),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:o,children:({className:c,style:i,tokens:m,getLineProps:g,getTokenProps:n})=>jsx("pre",{className:`${c} lua:p-4 lua:overflow-x-auto`,style:i,children:m.map((s,p)=>jsx("div",{...g({line:s}),children:s.map((y,d)=>jsx("span",{...n({token:y})},d))},p))})})]})}var T={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:dark:text-gray-200 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:dark:text-blue-400 lua:hover:underline",blockquote:"lua:border-l-4 lua:border-gray-200 lua:dark:border-gray-600 lua:pl-4 lua:italic lua:my-4",pre:"lua:contents lua:bg-gray-100 lua:dark:bg-gray-800 lua:rounded lua:px-1 lua:text-gray-700 lua:dark:text-gray-200 lua:mx-4 lua:sm:mx-5",code:"lua:bg-gray-100 lua:dark:bg-gray-800 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:dark:border-gray-700 lua:my-4",th:"lua:bg-gray-100 lua:dark:bg-gray-800 lua:border lua:border-gray-200 lua:dark:border-gray-700 lua:px-4 lua:py-2",td:"lua:border lua:border-gray-200 lua:dark:border-gray-700 lua:px-4 lua:py-2"};var Ea=t=>({code({children:e,className:a,...l}){let r=a?.replace("language-","")||"";return typeof e=="string"&&!e.includes(`
|
|
3
|
+
`)?jsx("code",{className:T.code,...l,children:e}):jsx(kt,{language:r,className:a,children:e})},p({children:e,...a}){return jsx("p",{className:T.p,...a,children:e})},h1({children:e,...a}){return jsx("h1",{className:T.h1,...a,children:e})},h2({children:e,...a}){return jsx("h2",{className:T.h2,...a,children:e})},h3({children:e,...a}){return jsx("h3",{className:T.h3,...a,children:e})},h4({children:e,...a}){return jsx("h4",{className:T.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:T.ul,...a,children:e})},ol({children:e,...a}){return jsx("ol",{className:T.ol,...a,children:e})},li({children:e,...a}){return jsx("li",{className:`${T.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:T.a,target:"_blank",rel:"noopener noreferrer",...l,children:a})},blockquote({children:e,...a}){return jsx("blockquote",{className:T.blockquote,...a,children:e})},pre({children:e}){return jsx(Fragment,{children:e})},table({children:e,...a}){return jsx("table",{className:T.table,...a,children:e})},th({children:e,...a}){return jsx("th",{className:T.th,...a,children:e})},td({children:e,...a}){return jsx("td",{className:T.td,...a,children:e})}}),be=Ea;function Ha(t){let e=new URL(t,"http://lua"),a=decodeURIComponent(e.pathname),l={};for(let[r,o]of e.searchParams.entries())l[r]=decodeURIComponent(o);return {pathname:a,queryParams:l}}var we=Ha;function Fa(t){let e=t.match(/\[navigate\]\(([^)]+)\)/);return e?e[1]:null}var Nt=Fa;var za=memo(function({block:e,onCardClick:a,onListItemClick:l,onNavigate:r}){let o=e.content.match(/^#\s+(.+)$/m),u=e.content.match(/!\[.*?]\((.*)\)/),c=o?o[1]:"",i=u?u[1]:null,m=Nt(e.content),g=e.content.replace(/^#\s+.+$/m,"").replace(/!\[.*?]\(.*?\)/g,"").replace(/\[.*?]\(.*?\)/g,"").trim(),n=be(l);return jsxs("div",{onClick:()=>{if(r&&m){let p=we(m);r(p.pathname,{...p.queryParams&&{query:p.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:dark:group-hover:lua:opacity-10 lua:rounded-lg lua:transition-opacity lua:duration-200"}),jsxs("div",{className:"chat-list-item-content",children:[i?jsx("div",{className:"chat-list-item-image-wrapper",children:jsx("img",{className:"chat-list-item-image",src:i,alt:c})}):null,jsxs("div",{className:"content-container",children:[jsx("h1",{className:"lua:text-base lua:leading-6 lua:font-semibold lua:text-gray-900 lua:dark:text-gray-50 lua:mb-0",children:c}),jsx("div",{className:"lua:text-sm lua:leading-6 lua:font-normal lua:text-gray-600 lua:dark:text-gray-300",children:jsx(Ot,{components:n,children:g})})]})]})]})}),oe=za;var Va=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((o,u)=>jsx(oe,{block:o,onCardClick:a,onListItemClick:l,onNavigate:r},u))})})}),Mt=Va;function _a(t){return {icon:()=>null}}function ke({documents:t}){return t.map(e=>{let l=_a(new File([],"",{type:e.mediaType})).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:dark:border-gray-700 lua:rounded-lg lua:bg-white lua:dark:bg-gray-800 lua:w-80",children:[jsx(l,{className:"lua:w-12 lua:h-12 lua:text-gray-500 lua:dark:text-gray-400"}),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:dark:text-gray-400 lua:text-sm",children:e.mediaType})]})]})})},e.url)})}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,o=600,u=window.screen.width/2-r/2,c=window.screen.height/2-o/2,i=window.open(t,"Payment",`width=${r},height=${o},left=${u},top=${c},toolbar=no,menubar=no,scrollbars=yes,resizable=yes`);(!i||i.closed||typeof i.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 Ga=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=Ga;var Ka=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},He=Ka;var Qa=t=>{let e=/\[.*?\]\((.*?)\)/g,a=[],l;for(;(l=e.exec(t))!==null;)l[1]&&a.push(l[1]);return a},Fe=Qa;function Oe(t){let e=t.match(/!\[([^\]]+)\]\(([^)]+)\)/);if(!e)return null;let[,a,l]=e;return {text:a,url:l}}var Za=t=>{let e=/\[.*?\]\((.*?)\)/,a=t.match(e);return a?a[1]:null},Be=Za;var ze=t=>typeof t=="string"?t:Array.isArray(t)?t.map(ze).join(""):typeof t=="object"&&t!==null&&"props"in t?ze(t.props.children):"",At=ze;function Ja(t){return t.replace(/([^\n]):::/g,`$1
|
|
5
5
|
:::`)}var Ya=t=>{t=t.replace(/\\n/g,`
|
|
6
|
-
`);let e=[],a="",l="",r="",o="",u="",c="",i="",m="",
|
|
7
|
-
`);for(let w=0;w<
|
|
6
|
+
`);let e=[],a="",l="",r="",o="",u="",c="",i="",m="",g=false,n=false,s=false,p=false,y=false,d=false,v=false,k=Ja(t).split(`
|
|
7
|
+
`);for(let w=0;w<k.length;w++){let f=k[w];if(f.trim()==="::: list-item"||f.trim()===":::list-item"){a.trim()&&(e.push({type:"text",content:a.trim()}),a=""),g=true;continue}if(f.trim()==="::: payment"||f.trim()===":::payment"){a.trim()&&(e.push({type:"text",content:a.trim()}),a=""),n=true;continue}if(f.trim()==="::: actions"||f.trim()===":::actions"){a.trim()&&(e.push({type:"text",content:a.trim()}),a=""),s=true;continue}if(f.trim()==="::: images"||f.trim()===":::images"){a.trim()&&(e.push({type:"text",content:a.trim()}),a=""),p=true;continue}if(f.trim()==="::: links"||f.trim()===":::links"){a.trim()&&(e.push({type:"text",content:a.trim()}),a=""),y=true;continue}if(f.trim()==="::: navigate"||f.trim()===":::navigate"){a.trim()&&(e.push({type:"text",content:a.trim()}),a=""),d=true;continue}if(f.trim()==="::: documents"||f.trim()===":::documents"){a.trim()&&(e.push({type:"text",content:a.trim()}),a=""),v=true;continue}if(f.trim()===":::"&&g){e.push({type:"list-item",content:l.trim(),isComplete:true}),l="",g=false;continue}if(f.trim()===":::"&&n){e.push({type:"payment",content:r.trim(),isComplete:true}),r="",n=false;continue}if(f.trim()===":::"&&s){e.push({type:"actions",content:o.trim(),isComplete:true}),o="",s=false;continue}if(f.trim()===":::"&&p){e.push({type:"images",content:u.trim(),isComplete:true}),u="",p=false;continue}if(f.trim()===":::"&&y){e.push({type:"links",content:c.trim(),isComplete:true}),c="",y=false;continue}if(f.trim()===":::"&&d){e.push({type:"navigate",content:i.trim(),isComplete:true}),i="",d=false;continue}if(f.trim()===":::"&&v){e.push({type:"documents",content:m.trim(),isComplete:true}),m="",v=false;continue}g?l+=f+`
|
|
8
8
|
`:n?r+=f+`
|
|
9
9
|
`:s?o+=f+`
|
|
10
|
-
`:
|
|
11
|
-
`:
|
|
10
|
+
`:p?u+=f+`
|
|
11
|
+
`:y?c+=f+`
|
|
12
12
|
`:d?i+=f+`
|
|
13
13
|
`:v?m+=f+`
|
|
14
14
|
`:a+=f+`
|
|
15
|
-
`;}return p?e.push({type:"list-item",content:l.trim(),isComplete:false}):n?e.push({type:"payment",content:r.trim(),isComplete:false}):s?e.push({type:"actions",content:o.trim(),isComplete:false}):g?e.push({type:"images",content:u.trim(),isComplete:false}):x?e.push({type:"links",content:c.trim(),isComplete:false}):d?e.push({type:"navigate",content:i.trim(),isComplete:false}):v?e.push({type:"documents",content:m.trim(),isComplete:false}):a.trim()&&e.push({type:"text",content:a.trim()}),e},Rt=Ya;function tl(t){let e=new Set(["br","hr","img","input","meta","link"]),a=[],l=/<\/?([a-z][a-z0-9]*)[^>]*>/gi,r=l.exec(t);for(;r!==null;){let o=r[0],u=r[1].toLowerCase();if(e.has(u)||o.endsWith("/>")){r=l.exec(t);continue}if(o.startsWith("</")){if(a.length===0||a.pop()!==u)return false}else a.push(u);r=l.exec(t);}return a.length===0}function It(t){let e=new Set(["br","hr","img","input","meta","link"]),a=/<\/?([a-z][a-z0-9]*)[^>]*>/gi,r=0,o=[],u;for(a.lastIndex=0;(u=a.exec(t))!==null;){let m=u[0],p=u[1].toLowerCase(),s=u.index+m.length;if(e.has(p)||m.endsWith("/>")){o.length===0&&(r=s);continue}m.startsWith("</")?o.length>0&&o[o.length-1]===p&&(o.pop(),o.length===0&&(r=s)):o.push(p);}let c=t.substring(0,r),i=r<t.length||o.length>0;return {completeHtml:c,hasIncompleteContent:i}}function Ut(t){return /^\s*<[a-z]+[\s>]/i.test(t.trim())?{isHtml:true,isComplete:tl(t)}:{isHtml:false,isComplete:false}}function $e(t){if(typeof window>"u")return "";let e={ALLOWED_TAGS:["div","b","ol","ul","li","a","br"],ALLOWED_ATTR:["style","href","target","rel"],ALLOW_DATA_ATTR:false,ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|data):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i};return el.sanitize(t,e)}function Me({images:t}){let[e,a]=useState(false),[l,r]=useState(0),o=useRef(null),[u,c]=useState(false),[i,m]=useState(0),[p,n]=useState(0),[s,g]=useState(0),x=useCallback(y=>{o.current&&(c(true),m(y.pageX-o.current.offsetLeft),n(o.current.scrollLeft),g(0),y.preventDefault());},[]),d=useCallback(y=>{if(!u||!o.current)return;y.preventDefault();let U=y.pageX-o.current.offsetLeft,O=(U-i)*2;o.current.scrollLeft=p-O,g(Math.abs(U-i));},[u,i,p]),v=useCallback(()=>{c(false);},[]),h=useCallback(()=>{c(false);},[]),N=useCallback((y,U)=>{if(s>5){U.preventDefault();return}r(y),a(true);},[s]);return jsxs("div",{"data-testid":"image-carousel-message",className:"chat-image-carousel-message lua:w-full",children:[jsx("div",{ref:o,className:"chat-image-carousel markdown-image-carousel",style:{cursor:u?"grabbing":"grab"},onMouseDown:x,onMouseMove:d,onMouseUp:v,onMouseLeave:h,onDragStart:y=>{y.preventDefault(),y.stopPropagation();},onDragOver:y=>{y.preventDefault(),y.stopPropagation();},children:t.map((y,U)=>jsx("div",{className:"chat-carousel-image-item markdown-image-item",onClick:O=>N(U,O),children:jsx("img",{src:y.src,alt:y.alt,draggable:false,style:{userSelect:"none"}})},y.src))}),jsx(bt,{images:t,initialIndex:l,open:e,onClose:()=>a(false)})]})}function _e({message:t}){let[e,a]=useState(false);return t.url?jsxs("div",{"data-testid":"image-message",className:"chat-image-message lua:flex lua:flex-col lua:w-3/5 lua:mx-4 lua:sm:mx-5",children:[jsxs("div",{className:"chat-image-container lua:relative",children:[jsx("img",{src:t.url,alt:t.content,className:"chat-image lua:rounded-lg lua:w-full lua:cursor-pointer",onClick:()=>a(true)}),t.isUploading&&jsx("div",{className:"chat-image-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:jsxs("div",{className:"lua:text-white lua:text-sm",children:["Uploading..."," ",t.uploadProgress?Math.round(t.uploadProgress):0,"%"]})})]}),!t.isUploading&&t.content.length>0&&jsx("div",{className:"chat-image-caption lua:w-full lua:bg-gray-100 lua:text-gray-800 lua:rounded-2xl lua:px-4 lua:p-3 lua:mt-8",children:t.content}),jsx(xt,{url:t.url,alt:t.content,open:e,onClose:()=>a(false)})]}):null}function qe({url:t,luaApiUrl:e,authToken:a,disablePreviewOnLinks:l}){let[r,o]=useState(null),[u,c]=useState(true),[i,m]=useState(null);return useEffect(()=>{t&&e&&!l&&(async()=>{try{c(!0),m(null);let n=a;if(!n)throw new Error("No auth token available");let s=await fetch(`${e}/chat/url-metadata?url=${encodeURIComponent(t)}`,{headers:{Authorization:`Bearer ${n}`}});if(!s.ok)throw new Error(`Failed to fetch preview: ${s.status}`);let g=await s.json();o(g);}catch(n){console.error("Error fetching link preview:",n),m(n instanceof Error?n.message:"Failed to load preview");}finally{c(false);}})();},[t,e]),l?jsx("div",{className:"lua:mb-5 lua:mx-[-30px]",children:jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:jsx(Button,{variant:"muted",children:t})})}):u?jsxs("div",{className:"lua:animate-pulse",children:[jsx("div",{className:"lua:bg-gray-300 lua:h-4 lua:w-3/4 lua:mb-2 lua:rounded"}),jsx("div",{className:"lua:bg-gray-300 lua:h-3 lua:w-1/2 lua:rounded"})]}):i||!r?jsx("div",{className:"lua:mb-5 lua:mx-[-30px]",children:jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:jsx(Button,{variant:"muted",children:t})})}):jsxs("a",{href:r.url||t,target:"_blank",rel:"noopener noreferrer",className:"lua:block lua:border lua:border-gray-200 lua:rounded-lg lua:p-3 lua:hover:bg-gray-50 lua:transition-colors lua:no-underline lua:max-w-sm",children:[r.image&&jsx("img",{src:r.image,alt:r.title,className:"lua:w-full lua:h-32 lua:object-cover lua:rounded lua:mb-2",onError:p=>{p.currentTarget.style.display="none";}}),jsx("div",{className:"lua:text-sm lua:font-medium lua:text-gray-900 lua:mb-1 lua:line-clamp-2",children:r.title}),r.description&&jsx("div",{className:"lua:text-xs lua:text-gray-600 lua:line-clamp-2",children:r.description}),jsx("div",{className:"lua:text-xs lua:text-gray-400 lua:mt-1 lua:truncate",children:new URL(r.url||t).hostname})]})}function Le({links:t,luaApiUrl:e,authToken:a,disablePreviewOnLinks:l}){return jsx("div",{"data-testid":"link-list-message",className:"chat-link-list-message lua:w-full",children:jsx("div",{className:"chat-links-container lua:space-y-2 lua:mx-4 lua:sm:mx-5",children:t.map(r=>jsx(qe,{url:r,luaApiUrl:e,authToken:a,disablePreviewOnLinks:l},r))})})}function Xe({location:t}){let e=[t.latitude,t.longitude];return jsx("div",{className:"lua:w-full lua:h-48 lua:rounded-lg lua:overflow-hidden lua:border lua:border-gray-200",children:jsxs(MapContainer,{center:e,zoom:15,scrollWheelZoom:false,className:"lua:w-full lua:h-full",children:[jsx(TileLayer,{attribution:'\xA9 <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),jsx(Marker,{position:e,children:t.address&&jsx(Popup,{children:jsx("div",{children:t.address})})})]})})}function Ge({location:t}){return jsx("div",{className:"lua:w-full lua:h-full lua:bg-gray-200 lua:rounded-lg lua:flex lua:items-center lua:justify-center lua:flex-col",children:t.address&&jsx(Xe,{location:t})})}function Ke({location:t}){return jsx("div",{className:"lua:w-full lua:h-60 lua:rounded-lg","data-testid":"location-preview",children:jsx(Ge,{location:t})})}function Qe({message:t}){return jsx("div",{"data-testid":"location-message",className:"chat-location-message lua:flex lua:flex-col lua:w-11/12 sm:lua:w-3/5 lua:bg-gray-100 lua:text-gray-800 lua:rounded-2xl lua:p-3 lua:mx-4 lua:sm:mx-5",children:jsxs("div",{className:"chat-location-preview-container location-preview-container lua:relative",children:[t.location&&jsx(Ke,{location:t.location}),t.isUploading&&jsx("div",{className:"chat-location-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:"Sharing location..."})}),jsxs("div",{className:"chat-location-info lua:flex lua:items-center lua:gap-2 lua:mt-3",children:[jsx(MapPin,{fill:"black"}),jsx("div",{className:"lua:flex-1",children:jsx("div",{className:"lua:text-sm",children:t.content})})]})]})})}function Ze({url:t,onNavigate:e}){let[a,l]=useState(false);return useEffect(()=>{if(e&&!a){l(true);let r=we(t);e(r.pathname,{...r.queryParams&&{query:r.queryParams}});}},[a,e]),null}function et({message:t}){return jsxs("div",{"data-testid":"video-message",className:"chat-video-message lua:flex lua:flex-col lua:w-3/5 lua:mx-4 lua:sm:mx-5",children:[jsxs("div",{className:"chat-video-container lua:relative",children:[jsx("video",{src:t.url,controls:true,className:"chat-video lua:rounded-lg lua:w-full"}),t.isUploading&&jsx("div",{className:"chat-video-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:jsxs("div",{className:"lua:text-white lua:text-sm",children:["Uploading..."," ",t.uploadProgress?Math.round(t.uploadProgress):0,"%"]})})]}),!t.isUploading&&t.content&&jsx("div",{className:"chat-video-caption lua:w-full lua:bg-gray-100 lua:text-gray-800 lua:rounded-2xl lua:px-4 lua:p-3 lua:mt-8",children:t.content})]})}function fl(t){return new Date(t).toLocaleTimeString()}function hl(t){return {icon:()=>null}}var xn=memo(function({message:e,onSelect:a,luaApiUrl:l,authToken:r,disablePreviewOnLinks:o=false,onNavigate:u}){let c=useCallback(p=>{let n=p.match(/^#\s+(.+)$/m),s=p.match(/^##\s+(.+)$/m),g=n?n[1]:"",x=s?s[1]:"",d=`${g}. ${x}`;a&&a(d);},[a]),i=useCallback(p=>{if(!a)return;let n=At(p).trim();a(n);},[a]),m=useCallback(()=>{if(e.type==="location")return jsx(Qe,{message:e});if(e.mediaType?.startsWith("video"))return e.url?jsx(et,{message:{url:e.url,content:e.content||"",isUploading:e.isUploading,uploadProgress:e.uploadProgress}}):null;if(e.mediaType?.startsWith("image"))return e.url?jsx(_e,{message:{url:e.url,content:e.content||"",isUploading:e.isUploading,uploadProgress:e.uploadProgress}}):null;if(e.mediaType?.startsWith("audio"))return jsx(Lt,{message:e});if(e.type==="file"&&e.mediaType){let x=hl(new File([],"",{type:e.mediaType})).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:jsxs("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(x,{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:["File",jsx("span",{className:"lua:text-gray-500 lua:text-sm",children:e.mediaType})]})]}),e.content&&jsx("div",{className:"chat-file-content lua:bg-gray-100 lua:rounded-2xl lua:px-4 lua:py-2 lua:w-80",children:jsx("div",{className:"lua:text-sm lua:text-gray-900",children:e.content})})]})})}if(e.role==="user")return e.content;if(e.content==="...")return null;let p=Ut(e.content);if(p.isHtml){if(p.isComplete){let d=$e(e.content);return jsx("div",{className:"chat-html-content lua:prose lua:prose-sm lua:max-w-none lua:mx-4 lua:sm:mx-5",dangerouslySetInnerHTML:{__html:d}})}let{completeHtml:g,hasIncompleteContent:x}=It(e.content);if(g){let d=$e(g);return jsxs("div",{className:"lua:mx-4 lua:sm:mx-5",children:[jsx("div",{className:"chat-html-content lua:prose lua:prose-sm lua:max-w-none",dangerouslySetInnerHTML:{__html:d}}),x&&jsx("div",{className:"lua:flex lua:items-center lua:gap-2 lua:text-gray-500 lua:mt-2",children:jsx(LogoSpinner,{size:14})})]})}return jsx("div",{className:"lua:flex lua:items-center lua:gap-2 lua:text-gray-500 lua:mx-4 lua:sm:mx-5",children:jsx("div",{className:"lua:animate-pulse",children:"\u25CF\u25CF\u25CF"})})}let n=Rt(e.content),s=be(i);return jsx("div",{className:"chat-markdown-content lua:prose lua:prose-sm lua:max-w-none",children:jsx("div",{className:"lua:flex lua:flex-wrap lua:gap-4",children:(()=>{if(n.filter(d=>d.type==="list-item").length>1){let d=[],v=[];return n.forEach(h=>{h.type==="list-item"?v.push(h):(v.length>0&&(d.push(v),v=[]),d.push([h]));}),v.length>0&&d.push(v),d.map((h,N)=>h.length>1&&h[0].type==="list-item"?jsx(Mt,{group:h,onCardClick:c,onListItemClick:i,onNavigate:u},N):h.map((w,f)=>{if(w.type==="list-item")return jsx(oe,{block:w,onCardClick:c,onListItemClick:i,onNavigate:u},f);if(w.type==="actions")return Se(w.content).length>0&&w.isComplete,null;if(w.type==="images"){let y=He(w.content);if(y.length>0)return jsx(Me,{images:y},f)}if(w.type==="links"){let y=Fe(w.content);return y.length>0&&w.isComplete?jsx(Le,{links:y,luaApiUrl:l||"",authToken:r||"",disablePreviewOnLinks:o},f):null}if(w.type==="navigate"){let y=Oe(w.content);return y&&w.isComplete?jsx(Ze,{text:y.text,url:y.url,onNavigate:u},f):null}if(w.type==="documents"){let y=Ie(w.content);return jsx(Ne,{documents:y},f)}if(w.type==="payment"){let y=Be(w.content);return y?jsx("div",{className:"chat-payment-message lua:w-full lua:mx-4 lua:sm:mx-5",children:jsx(Ee,{url:y})},f):null}return jsx("div",{className:"chat-markdown-block lua:w-full",children:jsx(Ot,{components:s,children:w.content})},f)}))}return n.map((d,v)=>{if(d.type==="list-item")return jsx(oe,{block:d,onCardClick:c,onListItemClick:i,onNavigate:u},v);if(d.type==="actions")return Se(d.content).length>0&&d.isComplete,null;if(d.type==="images"){let h=He(d.content);if(h.length>0)return jsx(Me,{images:h},v)}if(d.type==="navigate"){let h=Oe(d.content);return h&&d.isComplete?jsx(Ze,{text:h.text,url:h.url,onNavigate:u},v):null}if(d.type==="documents"){let h=Ie(d.content);return jsx(Ne,{documents:h},v)}if(d.type==="links"){let h=Fe(d.content);return h.length>0&&d.isComplete?jsx(Le,{links:h,luaApiUrl:l||"",authToken:r||"",disablePreviewOnLinks:o},v):null}if(d.type==="payment"){let h=Be(d.content);return h?jsx("div",{className:"chat-payment-message lua:w-full lua:mx-4 lua:sm:mx-5 lua:mb-5",children:jsx(Ee,{url:h})},v):null}return jsx("div",{className:"chat-markdown-block lua:w-full",children:jsx(Ot,{components:s,children:d.content})},v)})})()})})},[e,c,i]);return jsxs("div",{className:`chat-message-container lua:flex lua:flex-col ${e.role==="user"?"lua:items-end":"lua:items-start"} lua:gap-1`,children:[jsxs("div",{className:`lua:flex ${e.role==="user"?"lua:justify-end":"lua:justify-start"} lua:items-start lua:gap-2 lua:w-full`,children:[!["file","image","video","tool","location"].includes(e.type||"")&&e.content!=="..."&&jsx("div",{className:`chat-message-bubble ${e.role==="user"?"chat-message-bubble-user lua:max-w-full lua:md:max-w-3/5 lua:bg-gray-100 lua:text-gray-800 lua:rounded-2xl lua:px-4 lua:py-3 lua:mx-4 lua:sm:mx-5 lua:whitespace-pre-wrap":"chat-message-bubble-agent lua:w-full lua:bg-white lua:text-gray-800 lua:rounded-lg lua:py-3 lua:rounded-bl-none"}`,style:{wordBreak:"break-word"},children:m()}),["file","image","video","location"].includes(e.type||"")&&m()]}),jsx("div",{className:`lua-message-timestamp lua:text-xs lua:text-gray-400 lua:px-1 ${e.role==="user"?"lua:mr-4 sm:lua:mr-5":"lua:ml-4 sm:lua:ml-5"}`,children:fl(e.createdAt)})]})});var at=createContext(void 0),lt=createContext(void 0),rt=createContext(void 0),ot=createContext(void 0),nt=createContext(void 0);function Nn({children:t}){let[e,a]=useState([]),[l,r]=useState(""),[o,u]=useState(null),[c,i]=useState(false),[m]=useState(new Map),p=useCallback(s=>{if(!m.has(s)){let g=URL.createObjectURL(s);m.set(s,g);}return m.get(s)},[m]),n=useCallback(s=>{let g=m.get(s);g&&(URL.revokeObjectURL(g),m.delete(s));},[m]);return useEffect(()=>()=>{e.forEach(s=>{s.url&&s.url.startsWith("blob:")&&URL.revokeObjectURL(s.url);}),m.forEach(s=>URL.revokeObjectURL(s));},[e,m]),jsx(at.Provider,{value:{messages:e,setMessages:a},children:jsx(lt.Provider,{value:{inputMessage:l,setInputMessage:r},children:jsx(rt.Provider,{value:{loadingMessage:o,setLoadingMessage:u},children:jsx(ot.Provider,{value:{hasUnreadMessages:c,setHasUnreadMessages:i},children:jsx(nt.Provider,{value:{getFileUrl:p,removeFileUrl:n},children:t})})})})})}function kn(){let t=useContext(at);if(t===void 0)throw new Error("useMessages must be used within a ChatProvider");return t}function zt(){let t=useContext(lt);if(t===void 0)throw new Error("useInput must be used within a ChatProvider");return t}function Mn(){let t=useContext(rt);if(t===void 0)throw new Error("useLoadingMessage must be used within a ChatProvider");return t}function Tn(){let t=useContext(nt);if(t===void 0)throw new Error("useFileUrls must be used within a ChatProvider");return t}function Ln(){let t=useContext(ot);if(t===void 0)throw new Error("useUnreadMessages must be used within a ChatProvider");return t}function z(){let t=useContext(at),e=useContext(lt),a=useContext(rt),l=useContext(ot),r=useContext(nt);if(t===void 0||e===void 0||a===void 0||l===void 0||r===void 0)throw new Error("useChat must be used within a ChatProvider");return {...t,...e,...a,...l,...r}}function Un(){let{loadingMessage:t}=z();return t?jsxs("div",{className:"chat-loading-message lua:flex lua:items-center lua:gap-2 lua:mx-4 lua:sm:mx-5",children:[jsx(Logo,{size:24,className:"chat-loading-logo lua:w-6 lua:h-6 lua:rounded-full lua:flex-shrink-0 lua:animate-spin",style:{animationDuration:"3s"}}),jsx("div",{className:"chat-loading-text lua:text-sm lua:opacity-40",children:t||"Lua is typing..."})]}):null}function Vt({buttons:t,onClick:e}){return jsx("div",{className:"chat-action-message lua:w-full",children:jsx("div",{className:"chat-action-buttons lua:flex lua:gap-2 lua:flex-wrap lua:mx-4 lua:sm:mx-5",children:t.map((a,l)=>jsx(Button,{variant:"tertiary",className:"chat-action-button lua:font-normal lua:rounded-lg lua:py-2 lua:h-auto",onClick:()=>e(a.text),children:a.text},l))})})}var _t=t=>{let e="::: actions",l=t.indexOf(e);if(l===-1)return [];let r=t.indexOf(":::",l+e.length);return r===-1?[]:t.slice(l+e.length,r).trim().replace(/\\n/g,`
|
|
15
|
+
`;}return g?e.push({type:"list-item",content:l.trim(),isComplete:false}):n?e.push({type:"payment",content:r.trim(),isComplete:false}):s?e.push({type:"actions",content:o.trim(),isComplete:false}):p?e.push({type:"images",content:u.trim(),isComplete:false}):y?e.push({type:"links",content:c.trim(),isComplete:false}):d?e.push({type:"navigate",content:i.trim(),isComplete:false}):v?e.push({type:"documents",content:m.trim(),isComplete:false}):a.trim()&&e.push({type:"text",content:a.trim()}),e},Rt=Ya;function tl(t){let e=new Set(["br","hr","img","input","meta","link"]),a=[],l=/<\/?([a-z][a-z0-9]*)[^>]*>/gi,r=l.exec(t);for(;r!==null;){let o=r[0],u=r[1].toLowerCase();if(e.has(u)||o.endsWith("/>")){r=l.exec(t);continue}if(o.startsWith("</")){if(a.length===0||a.pop()!==u)return false}else a.push(u);r=l.exec(t);}return a.length===0}function It(t){let e=new Set(["br","hr","img","input","meta","link"]),a=/<\/?([a-z][a-z0-9]*)[^>]*>/gi,r=0,o=[],u;for(a.lastIndex=0;(u=a.exec(t))!==null;){let m=u[0],g=u[1].toLowerCase(),s=u.index+m.length;if(e.has(g)||m.endsWith("/>")){o.length===0&&(r=s);continue}m.startsWith("</")?o.length>0&&o[o.length-1]===g&&(o.pop(),o.length===0&&(r=s)):o.push(g);}let c=t.substring(0,r),i=r<t.length||o.length>0;return {completeHtml:c,hasIncompleteContent:i}}function Ut(t){return /^\s*<[a-z]+[\s>]/i.test(t.trim())?{isHtml:true,isComplete:tl(t)}:{isHtml:false,isComplete:false}}function $e(t){if(typeof window>"u")return "";let e={ALLOWED_TAGS:["div","b","ol","ul","li","a","br"],ALLOWED_ATTR:["style","href","target","rel"],ALLOW_DATA_ATTR:false,ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|data):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i};return el.sanitize(t,e)}function Me({images:t}){let[e,a]=useState(false),[l,r]=useState(0),o=useRef(null),[u,c]=useState(false),[i,m]=useState(0),[g,n]=useState(0),[s,p]=useState(0),y=useCallback(x=>{o.current&&(c(true),m(x.pageX-o.current.offsetLeft),n(o.current.scrollLeft),p(0),x.preventDefault());},[]),d=useCallback(x=>{if(!u||!o.current)return;x.preventDefault();let U=x.pageX-o.current.offsetLeft,O=(U-i)*2;o.current.scrollLeft=g-O,p(Math.abs(U-i));},[u,i,g]),v=useCallback(()=>{c(false);},[]),h=useCallback(()=>{c(false);},[]),k=useCallback((x,U)=>{if(s>5){U.preventDefault();return}r(x),a(true);},[s]);return jsxs("div",{"data-testid":"image-carousel-message",className:"chat-image-carousel-message lua:w-full",children:[jsx("div",{ref:o,className:"chat-image-carousel markdown-image-carousel",style:{cursor:u?"grabbing":"grab"},onMouseDown:y,onMouseMove:d,onMouseUp:v,onMouseLeave:h,onDragStart:x=>{x.preventDefault(),x.stopPropagation();},onDragOver:x=>{x.preventDefault(),x.stopPropagation();},children:t.map((x,U)=>jsx("div",{className:"chat-carousel-image-item markdown-image-item",onClick:O=>k(U,O),children:jsx("img",{src:x.src,alt:x.alt,draggable:false,style:{userSelect:"none"}})},x.src))}),jsx(bt,{images:t,initialIndex:l,open:e,onClose:()=>a(false)})]})}function _e({message:t}){let[e,a]=useState(false);return t.url?jsxs("div",{"data-testid":"image-message",className:"chat-image-message lua:flex lua:flex-col lua:w-3/5 lua:mx-4 lua:sm:mx-5",children:[jsxs("div",{className:"chat-image-container lua:relative",children:[jsx("img",{src:t.url,alt:t.content,className:"chat-image lua:rounded-lg lua:w-full lua:cursor-pointer",onClick:()=>a(true)}),t.isUploading&&jsx("div",{className:"chat-image-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:jsxs("div",{className:"lua:text-white lua:text-sm",children:["Uploading..."," ",t.uploadProgress?Math.round(t.uploadProgress):0,"%"]})})]}),!t.isUploading&&t.content.length>0&&jsx("div",{className:"chat-image-caption lua:w-full lua:bg-gray-100 lua:dark:bg-gray-800 lua:text-gray-800 lua:dark:text-gray-100 lua:rounded-2xl lua:px-4 lua:p-3 lua:mt-8",children:t.content}),jsx(yt,{url:t.url,alt:t.content,open:e,onClose:()=>a(false)})]}):null}function qe({url:t,luaApiUrl:e,authToken:a,disablePreviewOnLinks:l}){let[r,o]=useState(null),[u,c]=useState(true),[i,m]=useState(null);return useEffect(()=>{t&&e&&!l&&(async()=>{try{c(!0),m(null);let n=a;if(!n)throw new Error("No auth token available");let s=await fetch(`${e}/chat/url-metadata?url=${encodeURIComponent(t)}`,{headers:{Authorization:`Bearer ${n}`}});if(!s.ok)throw new Error(`Failed to fetch preview: ${s.status}`);let p=await s.json();o(p);}catch(n){console.error("Error fetching link preview:",n),m(n instanceof Error?n.message:"Failed to load preview");}finally{c(false);}})();},[t,e]),l?jsx("div",{className:"lua:mb-5 lua:mx-[-30px]",children:jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:jsx(Button,{variant:"muted",children:t})})}):u?jsxs("div",{className:"lua:animate-pulse",children:[jsx("div",{className:"lua:bg-gray-300 lua:dark:bg-gray-600 lua:h-4 lua:w-3/4 lua:mb-2 lua:rounded"}),jsx("div",{className:"lua:bg-gray-300 lua:dark:bg-gray-600 lua:h-3 lua:w-1/2 lua:rounded"})]}):i||!r?jsx("div",{className:"lua:mb-5 lua:mx-[-30px]",children:jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:jsx(Button,{variant:"muted",children:t})})}):jsxs("a",{href:r.url||t,target:"_blank",rel:"noopener noreferrer",className:"lua:block lua:border lua:border-gray-200 lua:dark:border-gray-700 lua:rounded-lg lua:p-3 lua:hover:bg-gray-50 lua:dark:hover:bg-gray-800 lua:transition-colors lua:no-underline lua:max-w-sm",children:[r.image&&jsx("img",{src:r.image,alt:r.title,className:"lua:w-full lua:h-32 lua:object-cover lua:rounded lua:mb-2",onError:g=>{g.currentTarget.style.display="none";}}),jsx("div",{className:"lua:text-sm lua:font-medium lua:text-gray-900 lua:dark:text-gray-50 lua:mb-1 lua:line-clamp-2",children:r.title}),r.description&&jsx("div",{className:"lua:text-xs lua:text-gray-600 lua:dark:text-gray-300 lua:line-clamp-2",children:r.description}),jsx("div",{className:"lua:text-xs lua:text-gray-400 lua:dark:text-gray-500 lua:mt-1 lua:truncate",children:new URL(r.url||t).hostname})]})}function Le({links:t,luaApiUrl:e,authToken:a,disablePreviewOnLinks:l}){return jsx("div",{"data-testid":"link-list-message",className:"chat-link-list-message lua:w-full",children:jsx("div",{className:"chat-links-container lua:space-y-2 lua:mx-4 lua:sm:mx-5",children:t.map(r=>jsx(qe,{url:r,luaApiUrl:e,authToken:a,disablePreviewOnLinks:l},r))})})}function Xe({location:t}){let e=[t.latitude,t.longitude];return jsx("div",{className:"lua:w-full lua:h-48 lua:rounded-lg lua:overflow-hidden lua:border lua:border-gray-200",children:jsxs(MapContainer,{center:e,zoom:15,scrollWheelZoom:false,className:"lua:w-full lua:h-full",children:[jsx(TileLayer,{attribution:'\xA9 <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),jsx(Marker,{position:e,children:t.address&&jsx(Popup,{children:jsx("div",{children:t.address})})})]})})}function Ge({location:t}){return jsx("div",{className:"lua:w-full lua:h-full lua:bg-gray-200 lua:rounded-lg lua:flex lua:items-center lua:justify-center lua:flex-col",children:t.address&&jsx(Xe,{location:t})})}function Ke({location:t}){return jsx("div",{className:"lua:w-full lua:h-60 lua:rounded-lg","data-testid":"location-preview",children:jsx(Ge,{location:t})})}function Qe({message:t}){return jsx("div",{"data-testid":"location-message",className:"chat-location-message lua:flex lua:flex-col lua:w-11/12 sm:lua:w-3/5 lua:bg-gray-100 lua:dark:bg-gray-800 lua:text-gray-800 lua:dark:text-gray-100 lua:rounded-2xl lua:p-3 lua:mx-4 lua:sm:mx-5",children:jsxs("div",{className:"chat-location-preview-container location-preview-container lua:relative",children:[t.location&&jsx(Ke,{location:t.location}),t.isUploading&&jsx("div",{className:"chat-location-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:"Sharing location..."})}),jsxs("div",{className:"chat-location-info lua:flex lua:items-center lua:gap-2 lua:mt-3",children:[jsx(MapPin,{className:"lua:fill-gray-800 lua:dark:fill-gray-100"}),jsx("div",{className:"lua:flex-1",children:jsx("div",{className:"lua:text-sm",children:t.content})})]})]})})}function Ze({url:t,onNavigate:e}){let[a,l]=useState(false);return useEffect(()=>{if(e&&!a){l(true);let r=we(t);e(r.pathname,{...r.queryParams&&{query:r.queryParams}});}},[a,e]),null}function et({message:t}){return jsxs("div",{"data-testid":"video-message",className:"chat-video-message lua:flex lua:flex-col lua:w-3/5 lua:mx-4 lua:sm:mx-5",children:[jsxs("div",{className:"chat-video-container lua:relative",children:[jsx("video",{src:t.url,controls:true,className:"chat-video lua:rounded-lg lua:w-full"}),t.isUploading&&jsx("div",{className:"chat-video-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:jsxs("div",{className:"lua:text-white lua:text-sm",children:["Uploading..."," ",t.uploadProgress?Math.round(t.uploadProgress):0,"%"]})})]}),!t.isUploading&&t.content&&jsx("div",{className:"chat-video-caption lua:w-full lua:bg-gray-100 lua:dark:bg-gray-800 lua:text-gray-800 lua:dark:text-gray-100 lua:rounded-2xl lua:px-4 lua:p-3 lua:mt-8",children:t.content})]})}function fl(t){return new Date(t).toLocaleTimeString()}function hl(t){return {icon:()=>null}}var yn=memo(function({message:e,onSelect:a,luaApiUrl:l,authToken:r,disablePreviewOnLinks:o=false,onNavigate:u}){let c=useCallback(g=>{let n=g.match(/^#\s+(.+)$/m),s=g.match(/^##\s+(.+)$/m),p=n?n[1]:"",y=s?s[1]:"",d=`${p}. ${y}`;a&&a(d);},[a]),i=useCallback(g=>{if(!a)return;let n=At(g).trim();a(n);},[a]),m=useCallback(()=>{if(e.type==="location")return jsx(Qe,{message:e});if(e.mediaType?.startsWith("video"))return e.url?jsx(et,{message:{url:e.url,content:e.content||"",isUploading:e.isUploading,uploadProgress:e.uploadProgress}}):null;if(e.mediaType?.startsWith("image"))return e.url?jsx(_e,{message:{url:e.url,content:e.content||"",isUploading:e.isUploading,uploadProgress:e.uploadProgress}}):null;if(e.mediaType?.startsWith("audio"))return jsx(Lt,{message:e});if(e.type==="file"&&e.mediaType){let y=hl(new File([],"",{type:e.mediaType})).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:jsxs("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:dark:border-gray-700 lua:rounded-lg lua:bg-white lua:dark:bg-gray-800 lua:w-80",children:[jsx(y,{className:"lua:w-12 lua:h-12 lua:text-gray-500 lua:dark:text-gray-400"}),jsxs("div",{className:"lua:flex lua:flex-col lua:gap-1 lua:pl-2",children:["File",jsx("span",{className:"lua:text-gray-500 lua:dark:text-gray-400 lua:text-sm",children:e.mediaType})]})]}),e.content&&jsx("div",{className:"chat-file-content lua:bg-gray-100 lua:dark:bg-gray-800 lua:rounded-2xl lua:px-4 lua:py-2 lua:w-80",children:jsx("div",{className:"lua:text-sm lua:text-gray-900 lua:dark:text-gray-100",children:e.content})})]})})}if(e.role==="user")return e.content;if(e.content==="...")return null;let g=Ut(e.content);if(g.isHtml){if(g.isComplete){let d=$e(e.content);return jsx("div",{className:"chat-html-content lua:prose lua:prose-sm lua:max-w-none lua:mx-4 lua:sm:mx-5",dangerouslySetInnerHTML:{__html:d}})}let{completeHtml:p,hasIncompleteContent:y}=It(e.content);if(p){let d=$e(p);return jsxs("div",{className:"lua:mx-4 lua:sm:mx-5",children:[jsx("div",{className:"chat-html-content lua:prose lua:prose-sm lua:max-w-none",dangerouslySetInnerHTML:{__html:d}}),y&&jsx("div",{className:"lua:flex lua:items-center lua:gap-2 lua:text-gray-500 lua:dark:text-gray-400 lua:mt-2",children:jsx(LogoSpinner,{size:14})})]})}return jsx("div",{className:"lua:flex lua:items-center lua:gap-2 lua:text-gray-500 lua:dark:text-gray-400 lua:mx-4 lua:sm:mx-5",children:jsx("div",{className:"lua:animate-pulse",children:"\u25CF\u25CF\u25CF"})})}let n=Rt(e.content),s=be(i);return jsx("div",{className:"chat-markdown-content lua:prose lua:prose-sm lua:max-w-none",children:jsx("div",{className:"lua:flex lua:flex-wrap lua:gap-4",children:(()=>{if(n.filter(d=>d.type==="list-item").length>1){let d=[],v=[];return n.forEach(h=>{h.type==="list-item"?v.push(h):(v.length>0&&(d.push(v),v=[]),d.push([h]));}),v.length>0&&d.push(v),d.map((h,k)=>h.length>1&&h[0].type==="list-item"?jsx(Mt,{group:h,onCardClick:c,onListItemClick:i,onNavigate:u},k):h.map((w,f)=>{if(w.type==="list-item")return jsx(oe,{block:w,onCardClick:c,onListItemClick:i,onNavigate:u},f);if(w.type==="actions")return Se(w.content).length>0&&w.isComplete,null;if(w.type==="images"){let x=He(w.content);if(x.length>0)return jsx(Me,{images:x},f)}if(w.type==="links"){let x=Fe(w.content);return x.length>0&&w.isComplete?jsx(Le,{links:x,luaApiUrl:l||"",authToken:r||"",disablePreviewOnLinks:o},f):null}if(w.type==="navigate"){let x=Oe(w.content);return x&&w.isComplete?jsx(Ze,{text:x.text,url:x.url,onNavigate:u},f):null}if(w.type==="documents"){let x=Ie(w.content);return jsx(ke,{documents:x},f)}if(w.type==="payment"){let x=Be(w.content);return x?jsx("div",{className:"chat-payment-message lua:w-full lua:mx-4 lua:sm:mx-5",children:jsx(Ee,{url:x})},f):null}return jsx("div",{className:"chat-markdown-block lua:w-full",children:jsx(Ot,{components:s,children:w.content})},f)}))}return n.map((d,v)=>{if(d.type==="list-item")return jsx(oe,{block:d,onCardClick:c,onListItemClick:i,onNavigate:u},v);if(d.type==="actions")return Se(d.content).length>0&&d.isComplete,null;if(d.type==="images"){let h=He(d.content);if(h.length>0)return jsx(Me,{images:h},v)}if(d.type==="navigate"){let h=Oe(d.content);return h&&d.isComplete?jsx(Ze,{text:h.text,url:h.url,onNavigate:u},v):null}if(d.type==="documents"){let h=Ie(d.content);return jsx(ke,{documents:h},v)}if(d.type==="links"){let h=Fe(d.content);return h.length>0&&d.isComplete?jsx(Le,{links:h,luaApiUrl:l||"",authToken:r||"",disablePreviewOnLinks:o},v):null}if(d.type==="payment"){let h=Be(d.content);return h?jsx("div",{className:"chat-payment-message lua:w-full lua:mx-4 lua:sm:mx-5 lua:mb-5",children:jsx(Ee,{url:h})},v):null}return jsx("div",{className:"chat-markdown-block lua:w-full",children:jsx(Ot,{components:s,children:d.content})},v)})})()})})},[e,c,i]);return jsxs("div",{className:`chat-message-container lua:flex lua:flex-col ${e.role==="user"?"lua:items-end":"lua:items-start"} lua:gap-1`,children:[jsxs("div",{className:`lua:flex ${e.role==="user"?"lua:justify-end":"lua:justify-start"} lua:items-start lua:gap-2 lua:w-full`,children:[!["file","image","video","tool","location"].includes(e.type||"")&&e.content!=="..."&&jsx("div",{className:`chat-message-bubble ${e.role==="user"?"chat-message-bubble-user lua:max-w-full lua:md:max-w-3/5 lua:bg-gray-100 lua:dark:bg-gray-700 lua:text-gray-800 lua:dark:text-gray-100 lua:rounded-2xl lua:px-4 lua:py-3 lua:mx-4 lua:sm:mx-5 lua:whitespace-pre-wrap":"chat-message-bubble-agent lua:w-full lua:bg-white lua:dark:bg-gray-800 lua:text-gray-800 lua:dark:text-gray-100 lua:rounded-lg lua:py-3 lua:rounded-bl-none"}`,style:{wordBreak:"break-word"},children:m()}),["file","image","video","location"].includes(e.type||"")&&m()]}),jsx("div",{className:`lua-message-timestamp lua:text-xs lua:text-gray-400 lua:dark:text-gray-500 lua:px-1 ${e.role==="user"?"lua:mr-4 sm:lua:mr-5":"lua:ml-4 sm:lua:ml-5"}`,children:fl(e.createdAt)})]})});var at=createContext(void 0),lt=createContext(void 0),rt=createContext(void 0),ot=createContext(void 0),nt=createContext(void 0);function kn({children:t}){let[e,a]=useState([]),[l,r]=useState(""),[o,u]=useState(null),[c,i]=useState(false),[m]=useState(new Map),g=useCallback(s=>{if(!m.has(s)){let p=URL.createObjectURL(s);m.set(s,p);}return m.get(s)},[m]),n=useCallback(s=>{let p=m.get(s);p&&(URL.revokeObjectURL(p),m.delete(s));},[m]);return useEffect(()=>()=>{e.forEach(s=>{s.url&&s.url.startsWith("blob:")&&URL.revokeObjectURL(s.url);}),m.forEach(s=>URL.revokeObjectURL(s));},[e,m]),jsx(at.Provider,{value:{messages:e,setMessages:a},children:jsx(lt.Provider,{value:{inputMessage:l,setInputMessage:r},children:jsx(rt.Provider,{value:{loadingMessage:o,setLoadingMessage:u},children:jsx(ot.Provider,{value:{hasUnreadMessages:c,setHasUnreadMessages:i},children:jsx(nt.Provider,{value:{getFileUrl:g,removeFileUrl:n},children:t})})})})})}function Nn(){let t=useContext(at);if(t===void 0)throw new Error("useMessages must be used within a ChatProvider");return t}function zt(){let t=useContext(lt);if(t===void 0)throw new Error("useInput must be used within a ChatProvider");return t}function Mn(){let t=useContext(rt);if(t===void 0)throw new Error("useLoadingMessage must be used within a ChatProvider");return t}function Tn(){let t=useContext(nt);if(t===void 0)throw new Error("useFileUrls must be used within a ChatProvider");return t}function Ln(){let t=useContext(ot);if(t===void 0)throw new Error("useUnreadMessages must be used within a ChatProvider");return t}function z(){let t=useContext(at),e=useContext(lt),a=useContext(rt),l=useContext(ot),r=useContext(nt);if(t===void 0||e===void 0||a===void 0||l===void 0||r===void 0)throw new Error("useChat must be used within a ChatProvider");return {...t,...e,...a,...l,...r}}function Un(){let{loadingMessage:t}=z();return t?jsxs("div",{className:"chat-loading-message lua:flex lua:items-center lua:gap-2 lua:mx-4 lua:sm:mx-5",children:[jsx(Logo,{size:24,className:"chat-loading-logo lua:w-6 lua:h-6 lua:rounded-full lua:flex-shrink-0 lua:animate-spin",style:{animationDuration:"3s"}}),jsx("div",{className:"chat-loading-text lua:text-sm lua:opacity-40",children:t||"Lua is typing..."})]}):null}function Vt({buttons:t,onClick:e}){return jsx("div",{className:"chat-action-message lua:w-full",children:jsx("div",{className:"chat-action-buttons lua:flex lua:gap-2 lua:flex-wrap lua:mx-4 lua:sm:mx-5",children:t.map((a,l)=>jsx(Button,{variant:"tertiary",className:"chat-action-button lua:font-normal lua:rounded-lg lua:py-2 lua:h-auto",onClick:()=>e(a.text),children:a.text},l))})})}var _t=t=>{let e="::: actions",l=t.indexOf(e);if(l===-1)return [];let r=t.indexOf(":::",l+e.length);return r===-1?[]:t.slice(l+e.length,r).trim().replace(/\\n/g,`
|
|
16
16
|
`).split(`
|
|
17
|
-
`).map(p=>p.trim()).filter(p=>p&&p.startsWith("-")).map(p=>({text:p.replace(/^-[\s]?/,"").trim(),onClick:p.replace(/^-[\s]?/,"").trim()}))};function Vn({onSelect:t}){let{messages:e}=z();if(e.length===0)return null;let a=e[e.length-1],l=_t(a.content);return l.length===0?null:jsx(Vt,{buttons:l,onClick:t})}var di=memo(function({onSend:e,disabled:a=false,onFilePaste:l}){let{inputMessage:r,setInputMessage:o}=zt(),[u,c]=useState(false),i=useRef(null);useEffect(()=>{let n=()=>{c(window.matchMedia("(max-width: 768px)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));};return n(),window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n);}},[]),useEffect(()=>{let n=i.current;n&&(a||(n.style.height="auto",n.style.height=`${n.scrollHeight}px`));},[r]);let m=n=>{if(n.key==="Enter"){if(u||n.shiftKey||n.metaKey||n.ctrlKey)return;n.preventDefault(),e();}},p=useCallback(n=>{let{items:s}=n.clipboardData;if(!s||!l)return;let g=[];for(let x=0;x<s.length;x++){let d=s[x];if(d.kind==="file"){let v=d.getAsFile();v&&g.push(v);}}g.length>0&&(n.preventDefault(),l(g));},[l]);return jsxs("div",{className:"lua:flex lua:gap-3 lua:py-2 lua:px-3 lua:items-start",children:[jsx(Logo,{size:32,className:"lua:w-8 lua:h-8 lua:rounded-full lua:flex-shrink-0 lua:m-1"}),jsx("div",{className:"lua:flex-1 lua:flex",children:jsx("textarea",{ref:i,disabled:a,value:r,onChange:n=>o(n.target.value),onKeyDown:m,onPaste:p,placeholder:a?"This conversation's chat window has already been closed":"Reply to user",className:`lua:w-full lua:pl-0 lua:pr-4 lua:py-2 lua:resize-none lua:overflow-y-auto lua:border-none lua:focus:outline-none lua:focus:ring-0 lua:text-gray-700 lua:min-h-10 lua:max-h-48 lua:bg-white${a?" lua:cursor-not-allowed lua:h-14":""}`,rows:1})})]})});function Al(){return localStorage.getItem("authToken")}async function Z(t,e,a){let l=Al();if(!l)throw new Error("No auth token found");return new Promise((r,o)=>{let u=new XMLHttpRequest,c=new FormData;c.append("file",t),u.upload.addEventListener("progress",i=>{if(i.lengthComputable&&a){let m=i.loaded/i.total*100;a(m);}}),u.addEventListener("load",()=>{if(u.status>=200&&u.status<300)try{let i=JSON.parse(u.responseText);r(i);}catch{o(new Error("Failed to parse response"));}else o(new Error(`Failed to upload file: ${u.status}`));}),u.addEventListener("error",()=>{o(new Error("Network error occurred"));}),u.open("POST",`${e}/upload`),u.setRequestHeader("Authorization",`Bearer ${l}`),u.send(c);})}function Dl(t){let e=t.type,a="File";return e.startsWith("image/")?a="Image":e.startsWith("video/")?a="Video":e.startsWith("audio/")&&(a="Audio"),{icon:()=>null,label:a}}function ct({file:t,onRemove:e,cdnUrl:a,initialUrl:l,onUploadComplete:r}){let o=Dl(t),u=o.icon,[c,i]=useState(false),[m,p]=useState(0),[n,s]=useState(l||null),g=useRef(false);return useEffect(()=>{if(n||g.current)return;(async()=>{i(true),g.current=true;try{let{fileId:d}=await Z(t,a,h=>{p(h);}),v=`${a}/${d}`;s(v),i(!1),r&&r(t,v);}catch(d){console.error("Upload failed for file:",t.name,d),i(false),g.current=false;}})();},[t,a,r,n]),jsxs("div",{className:"lua:flex lua:items-center lua:gap-4 lua:p-3 lua:bg-white lua:border lua:border-gray-200 lua:rounded-lg",children:[jsx("div",{className:"lua:flex-shrink-0",children:c?jsxs("div",{className:"lua:w-8 lua:h-8 lua:flex lua:flex-col lua:items-center lua:justify-center",children:[jsx("div",{className:"lua:w-6 lua:h-6 lua:border-2 lua:border-t-blue-500 lua:border-r-transparent lua:border-b-transparent lua:border-l-transparent lua:rounded-full lua:animate-spin"}),jsxs("div",{className:"lua:mt-1 lua:text-xs lua:text-gray-600 lua:font-medium",children:[Math.round(m),"%"]})]}):jsx(u,{className:"lua:w-8 lua:h-8 lua:text-gray-600"})}),jsxs("div",{className:"lua:flex-grow lua:min-w-0",children:[jsx("p",{className:"lua:text-sm lua:font-medium lua:text-gray-900 lua:truncate",children:t.name}),jsx("p",{className:"lua:text-xs lua:text-gray-500",children:o.label})]}),jsx("button",{onClick:e,className:"lua:flex-shrink-0 lua:w-6 lua:h-6 lua:flex lua:items-center lua:justify-center lua:rounded-full lua:bg-black lua:text-white lua:hover:bg-gray-800 lua:transition-colors",children:jsx(XIcon,{className:"lua:w-4 lua:h-4"})})]})}function dt({file:t,onRemove:e,cdnUrl:a,initialUrl:l,onUploadComplete:r}){let{getFileUrl:o}=z(),[u,c]=useState(false),[i,m]=useState(0),[p,n]=useState(l||null),[s,g]=useState(false);useEffect(()=>{if(l||s)return;(async()=>{c(true),g(true);try{let{fileId:v}=await Z(t,a,N=>{m(N);}),h=`${a}/${v}`;n(h),c(!1),r&&r(t,h);}catch(v){console.error("Upload failed:",v),c(false);}})();},[t,l,a,s,r]);let x=p||(u?void 0:o(t));return jsxs("div",{className:"lua:relative lua:flex-shrink-0",children:[u?jsxs("div",{className:"lua:w-32 lua:h-32 lua:bg-gray-100 lua:rounded-lg lua:flex lua:flex-col lua:items-center lua:justify-center",children:[jsx("div",{className:"lua:w-8 lua:h-8 lua:border-2 lua:border-t-blue-500 lua:border-r-transparent lua:border-b-transparent lua:border-l-transparent lua:rounded-full lua:animate-spin"}),jsxs("div",{className:"lua:mt-2 lua:text-xs lua:text-gray-600 lua:font-medium",children:[Math.round(i),"%"]})]}):x?jsx("img",{"data-testid":"image-thumbnail",src:x,alt:t.name,className:"lua:w-32 lua:h-32 lua:object-cover lua:rounded-lg"}):jsx("div",{className:"lua:w-32 lua:h-32 lua:bg-gray-200 lua:rounded-lg lua:flex lua:items-center lua:justify-center",children:jsx("span",{className:"lua:text-gray-500",children:"No preview"})}),jsxs("div",{className:"lua:absolute lua:bottom-1 lua:left-1 lua:px-1.5 lua:py-0.5 lua:rounded lua:bg-black/50 lua:text-white lua:text-xs",children:[Math.floor(t.size/1024/1024),"MB"]}),jsx("button",{onClick:()=>e(),className:"lua:absolute lua:top-1 lua:right-1 lua:w-6 lua:h-6 lua:flex lua:items-center lua:justify-center lua:rounded-full lua:bg-black lua:text-white lua:hover:bg-gray-800 lua:transition-colors",children:jsx("span",{className:"lua:text-sm",children:"\xD7"})})]})}function mt({file:t,onRemove:e,cdnUrl:a,initialUrl:l,thumbnailUrl:r,onUploadComplete:o}){let{getFileUrl:u}=z(),[c,i]=useState(false),[m,p]=useState(0),[n,s]=useState(l||null),[g,x]=useState(false),[d,v]=useState(r||null);return useEffect(()=>{if(!r&&!d){let h=u(t),N=document.createElement("video");N.src=h;let w=()=>{try{N.currentTime=0,setTimeout(()=>{let f=document.createElement("canvas");f.width=N.videoWidth,f.height=N.videoHeight;let y=f.getContext("2d");if(!y){console.error("Could not get canvas context");return}y.drawImage(N,0,0);let U=f.toDataURL("image/jpeg",.8);v(U);},100);}catch(f){console.error("Error generating thumbnail:",f);}finally{URL.revokeObjectURL(h),N.removeEventListener("canplay",w);}};N.addEventListener("canplay",w),N.load();}},[t,r,d]),useEffect(()=>{if(l||g)return;(async()=>{i(true),x(true);try{let{fileId:N}=await Z(t,a,f=>{p(f);}),w=`${a}/${N}`;s(w),i(!1),o&&o(t,w);}catch(N){console.error("Upload failed:",N),i(false);}})();},[t,l,a,g,o]),jsxs("div",{className:"lua:relative lua:flex-shrink-0",children:[c?jsxs("div",{className:"lua:w-32 lua:h-32 lua:bg-gray-100 lua:rounded-lg lua:flex lua:flex-col lua:items-center lua:justify-center",children:[jsx("div",{className:"lua:w-8 lua:h-8 lua:border-2 lua:border-t-blue-500 lua:border-r-transparent lua:border-b-transparent lua:border-l-transparent lua:rounded-full lua:animate-spin"}),jsxs("div",{className:"lua:mt-2 lua:text-xs lua:text-gray-600 lua:font-medium",children:[Math.round(m),"%"]})]}):jsxs("div",{className:"lua:relative",children:[jsx("img",{"data-testid":"video-thumbnail",src:d||n||"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",alt:t.name,className:"lua:w-32 lua:h-32 lua:object-cover lua:rounded-lg lua:bg-gray-100"}),jsx("div",{className:"lua:absolute lua:inset-0 lua:flex lua:items-center lua:justify-center",children:jsx("div",{className:"lua:w-10 lua:h-10 lua:rounded-full lua:bg-black/50 lua:flex lua:items-center lua:justify-center",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M5 3L19 12L5 21V3Z",fill:"white"})})})})]}),jsxs("div",{className:"lua:absolute lua:bottom-1 lua:left-1 lua:px-1.5 lua:py-0.5 lua:rounded lua:bg-black/50 lua:text-white lua:text-xs",children:[Math.floor(t.size/1024/1024),"MB"]}),jsx("button",{onClick:()=>e(),className:"lua:absolute lua:top-1 lua:right-1 lua:w-6 lua:h-6 lua:flex lua:items-center lua:justify-center lua:rounded-full lua:bg-black lua:text-white lua:hover:bg-gray-800 lua:transition-colors",children:jsx("span",{className:"lua:text-sm",children:"\xD7"})})]})}function jt(t){let e=t.type,a="other",l="File";return e.startsWith("image/")?(a="image",l="Image"):e.startsWith("video/")?(a="video",l="Video"):e.startsWith("audio/")&&(a="audio",l="Audio"),{category:a,icon:()=>null,label:l}}function Ei({files:t,onRemove:e,cdnUrl:a,fileMetadata:l=[],onFileUploadComplete:r}){let[o,u]=useState({});return useEffect(()=>{t.forEach((c,i)=>{let m=jt(c),p=l.find(n=>n.file===c);if(m.category==="video"&&!o[i]&&!p){let n=URL.createObjectURL(c),s=document.createElement("video");s.src=n;let g=()=>{try{s.currentTime=0,setTimeout(()=>{let x=document.createElement("canvas");x.width=s.videoWidth,x.height=s.videoHeight;let d=x.getContext("2d");if(!d){console.error("Could not get canvas context");return}d.drawImage(s,0,0);let v=x.toDataURL("image/jpeg",.8);u(h=>({...h,[i]:v}));},100);}catch(x){console.error("Error generating thumbnail:",x);}finally{URL.revokeObjectURL(n),s.removeEventListener("canplay",g);}};s.addEventListener("canplay",g),s.load();}});},[t,l]),t.length===0?null:jsx("div",{className:"lua:px-4 lua:py-2 lua:border-b lua:border-gray-200",children:jsx("div",{className:"lua:flex lua:gap-2 lua:overflow-x-auto scrollbar-hide",children:t.map((c,i)=>{let m=jt(c),p=l.find(n=>n.file===c);return t.length>1?jsx("div",{className:"lua:flex-shrink-0 lua:w-64",children:jsx(ct,{file:c,onRemove:()=>e(i),cdnUrl:a,onUploadComplete:(n,s)=>{r&&r(n,s);}})},i):m.category==="image"?jsx(dt,{file:c,onRemove:()=>e(i),cdnUrl:a,initialUrl:p?.url,onUploadComplete:(n,s)=>{r&&r(n,s);}},c.name):m.category==="video"?jsx(mt,{file:c,onRemove:()=>e(i),cdnUrl:a,initialUrl:p?.url,thumbnailUrl:o[i],onUploadComplete:(n,s)=>{r&&r(n,s);}},c.name):jsx("div",{className:"lua:flex-shrink-0 lua:w-64",children:jsx(ct,{file:c,onRemove:()=>e(i),cdnUrl:a,onUploadComplete:(n,s)=>{r&&r(n,s);}})},i)})})})}var ee={CHAT:{TOOLBAR_ACTION:{FILE_UPLOAD:"file_upload",CAMERA:"camera",VIDEO:"video",AUDIO:"audio",LOCATION:"location"},MESSAGE_SENT:"message_sent"}};function te(t){console.log("Analytics event:",t);}function Oi({loading:t,onFileClick:e,onCameraClick:a,onVideoClick:l,onAudioClick:r,onLocationClick:o,onSendClick:u}){return jsxs("div",{className:"lua:flex lua:items-center lua:justify-between lua:border-t lua:border-gray-200 lua:bg-gray-50 lua:px-3 lua:py-2",children:[jsxs("div",{className:"lua:flex lua:items-center lua:gap-2",children:[jsxs(Tooltip,{children:[jsx(TooltipTrigger,{asChild:true,children:jsx(IconButton,{className:"lua:rounded-lg",variant:"muted",onClick:()=>{te(ee.CHAT.TOOLBAR_ACTION.FILE_UPLOAD),e();},disabled:t,"data-testid":"file-upload-button",children:jsx(Paperclip,{color:"#00000099"})})}),jsxs(TooltipContent,{children:[jsx(TooltipArrow,{}),jsx("p",{children:"Attach files"})]})]}),jsx("div",{className:"lua:w-px lua:h-5 lua:bg-gray-200"}),jsxs(Tooltip,{children:[jsx(TooltipTrigger,{asChild:true,children:jsx(IconButton,{className:"lua:rounded-lg",variant:"muted",onClick:()=>{te(ee.CHAT.TOOLBAR_ACTION.CAMERA),a();},disabled:t,"data-testid":"camera-button",children:jsx(Camera,{color:"#00000099"})})}),jsxs(TooltipContent,{children:[jsx(TooltipArrow,{}),jsx("p",{children:"Take a picture"})]})]}),jsxs(Tooltip,{children:[jsx(TooltipTrigger,{asChild:true,children:jsx(IconButton,{className:"lua:rounded-lg",variant:"muted",onClick:()=>{te(ee.CHAT.TOOLBAR_ACTION.VIDEO),l();},disabled:t,"data-testid":"video-button",children:jsx(VideoCamera,{color:"#00000099"})})}),jsxs(TooltipContent,{children:[jsx(TooltipArrow,{}),jsx("p",{children:"Record video"})]})]}),jsxs(Tooltip,{children:[jsx(TooltipTrigger,{asChild:true,children:jsx(IconButton,{className:"lua:rounded-lg",variant:"muted",onClick:()=>{te(ee.CHAT.TOOLBAR_ACTION.AUDIO),r();},disabled:t,"data-testid":"audio-button",children:jsx(Microphone,{color:"#00000099"})})}),jsxs(TooltipContent,{children:[jsx(TooltipArrow,{}),jsx("p",{children:"Record voice message"})]})]}),jsx("div",{className:"lua:w-px lua:h-5 lua:bg-gray-200"}),jsxs(Tooltip,{children:[jsx(TooltipTrigger,{asChild:true,children:jsx(IconButton,{className:"lua:rounded-lg",variant:"muted",onClick:()=>{te(ee.CHAT.TOOLBAR_ACTION.LOCATION),o();},disabled:t,"data-testid":"location-button",children:jsx(MapPin,{color:"#00000099"})})}),jsxs(TooltipContent,{children:[jsx(TooltipArrow,{}),jsx("p",{children:"Share location"})]})]})]}),jsx(IconButton,{className:"lua:rounded-full",onClick:()=>{te(ee.CHAT.MESSAGE_SENT),u();},disabled:t,"data-testid":"send-button",children:jsx(ArrowUp,{color:"#FFFFFF"})})]})}
|
|
18
|
-
export{Vt as ActionMessage,Lt as AudioPreview,jl as AudioRecorder,
|
|
17
|
+
`).map(g=>g.trim()).filter(g=>g&&g.startsWith("-")).map(g=>({text:g.replace(/^-[\s]?/,"").trim(),onClick:g.replace(/^-[\s]?/,"").trim()}))};function Vn({onSelect:t}){let{messages:e}=z();if(e.length===0)return null;let a=e[e.length-1],l=_t(a.content);return l.length===0?null:jsx(Vt,{buttons:l,onClick:t})}var di=memo(function({onSend:e,disabled:a=false,onFilePaste:l}){let{inputMessage:r,setInputMessage:o}=zt(),[u,c]=useState(false),i=useRef(null);useEffect(()=>{let n=()=>{c(window.matchMedia("(max-width: 768px)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));};return n(),window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n);}},[]),useEffect(()=>{let n=i.current;n&&(a||(n.style.height="auto",n.style.height=`${n.scrollHeight}px`));},[r]);let m=n=>{if(n.key==="Enter"){if(u||n.shiftKey||n.metaKey||n.ctrlKey)return;n.preventDefault(),e();}},g=useCallback(n=>{let{items:s}=n.clipboardData;if(!s||!l)return;let p=[];for(let y=0;y<s.length;y++){let d=s[y];if(d.kind==="file"){let v=d.getAsFile();v&&p.push(v);}}p.length>0&&(n.preventDefault(),l(p));},[l]);return jsxs("div",{className:"lua:flex lua:gap-3 lua:py-2 lua:px-3 lua:items-start",children:[jsx(Logo,{size:32,className:"lua:w-8 lua:h-8 lua:rounded-full lua:flex-shrink-0 lua:m-1"}),jsx("div",{className:"lua:flex-1 lua:flex",children:jsx("textarea",{ref:i,disabled:a,value:r,onChange:n=>o(n.target.value),onKeyDown:m,onPaste:g,placeholder:a?"This conversation's chat window has already been closed":"Reply to user",className:`lua:w-full lua:pl-0 lua:pr-4 lua:py-2 lua:resize-none lua:overflow-y-auto lua:border-none lua:focus:outline-none lua:focus:ring-0 lua:text-gray-700 lua:dark:text-gray-200 lua:placeholder:text-gray-400 lua:dark:placeholder:text-gray-500 lua:min-h-10 lua:max-h-48 lua:bg-transparent${a?" lua:cursor-not-allowed lua:h-14":""}`,rows:1})})]})});function Al(){return localStorage.getItem("authToken")}async function Z(t,e,a){let l=Al();if(!l)throw new Error("No auth token found");return new Promise((r,o)=>{let u=new XMLHttpRequest,c=new FormData;c.append("file",t),u.upload.addEventListener("progress",i=>{if(i.lengthComputable&&a){let m=i.loaded/i.total*100;a(m);}}),u.addEventListener("load",()=>{if(u.status>=200&&u.status<300)try{let i=JSON.parse(u.responseText);r(i);}catch{o(new Error("Failed to parse response"));}else o(new Error(`Failed to upload file: ${u.status}`));}),u.addEventListener("error",()=>{o(new Error("Network error occurred"));}),u.open("POST",`${e}/upload`),u.setRequestHeader("Authorization",`Bearer ${l}`),u.send(c);})}function Dl(t){let e=t.type,a="File";return e.startsWith("image/")?a="Image":e.startsWith("video/")?a="Video":e.startsWith("audio/")&&(a="Audio"),{icon:()=>null,label:a}}function ct({file:t,onRemove:e,cdnUrl:a,initialUrl:l,onUploadComplete:r}){let o=Dl(t),u=o.icon,[c,i]=useState(false),[m,g]=useState(0),[n,s]=useState(l||null),p=useRef(false);return useEffect(()=>{if(n||p.current)return;(async()=>{i(true),p.current=true;try{let{fileId:d}=await Z(t,a,h=>{g(h);}),v=`${a}/${d}`;s(v),i(!1),r&&r(t,v);}catch(d){console.error("Upload failed for file:",t.name,d),i(false),p.current=false;}})();},[t,a,r,n]),jsxs("div",{className:"lua:flex lua:items-center lua:gap-4 lua:p-3 lua:bg-white lua:dark:bg-gray-800 lua:border lua:border-gray-200 lua:dark:border-gray-700 lua:rounded-lg",children:[jsx("div",{className:"lua:flex-shrink-0",children:c?jsxs("div",{className:"lua:w-8 lua:h-8 lua:flex lua:flex-col lua:items-center lua:justify-center",children:[jsx("div",{className:"lua:w-6 lua:h-6 lua:border-2 lua:border-t-blue-500 lua:border-r-transparent lua:border-b-transparent lua:border-l-transparent lua:rounded-full lua:animate-spin"}),jsxs("div",{className:"lua:mt-1 lua:text-xs lua:text-gray-600 lua:dark:text-gray-300 lua:font-medium",children:[Math.round(m),"%"]})]}):jsx(u,{className:"lua:w-8 lua:h-8 lua:text-gray-600 lua:dark:text-gray-400"})}),jsxs("div",{className:"lua:flex-grow lua:min-w-0",children:[jsx("p",{className:"lua:text-sm lua:font-medium lua:text-gray-900 lua:dark:text-gray-100 lua:truncate",children:t.name}),jsx("p",{className:"lua:text-xs lua:text-gray-500 lua:dark:text-gray-400",children:o.label})]}),jsx("button",{onClick:e,className:"lua:flex-shrink-0 lua:w-6 lua:h-6 lua:flex lua:items-center lua:justify-center lua:rounded-full lua:bg-gray-800 lua:dark:bg-gray-700 lua:text-white lua:hover:bg-gray-700 lua:dark:hover:bg-gray-600 lua:transition-colors",children:jsx(XIcon,{className:"lua:w-4 lua:h-4"})})]})}function dt({file:t,onRemove:e,cdnUrl:a,initialUrl:l,onUploadComplete:r}){let{getFileUrl:o}=z(),[u,c]=useState(false),[i,m]=useState(0),[g,n]=useState(l||null),[s,p]=useState(false);useEffect(()=>{if(l||s)return;(async()=>{c(true),p(true);try{let{fileId:v}=await Z(t,a,k=>{m(k);}),h=`${a}/${v}`;n(h),c(!1),r&&r(t,h);}catch(v){console.error("Upload failed:",v),c(false);}})();},[t,l,a,s,r]);let y=g||(u?void 0:o(t));return jsxs("div",{className:"lua:relative lua:flex-shrink-0",children:[u?jsxs("div",{className:"lua:w-32 lua:h-32 lua:bg-gray-100 lua:dark:bg-gray-800 lua:rounded-lg lua:flex lua:flex-col lua:items-center lua:justify-center",children:[jsx("div",{className:"lua:w-8 lua:h-8 lua:border-2 lua:border-t-blue-500 lua:border-r-transparent lua:border-b-transparent lua:border-l-transparent lua:rounded-full lua:animate-spin"}),jsxs("div",{className:"lua:mt-2 lua:text-xs lua:text-gray-600 lua:dark:text-gray-300 lua:font-medium",children:[Math.round(i),"%"]})]}):y?jsx("img",{"data-testid":"image-thumbnail",src:y,alt:t.name,className:"lua:w-32 lua:h-32 lua:object-cover lua:rounded-lg"}):jsx("div",{className:"lua:w-32 lua:h-32 lua:bg-gray-200 lua:dark:bg-gray-700 lua:rounded-lg lua:flex lua:items-center lua:justify-center",children:jsx("span",{className:"lua:text-gray-500 lua:dark:text-gray-400",children:"No preview"})}),jsxs("div",{className:"lua:absolute lua:bottom-1 lua:left-1 lua:px-1.5 lua:py-0.5 lua:rounded lua:bg-black/50 lua:text-white lua:text-xs",children:[Math.floor(t.size/1024/1024),"MB"]}),jsx("button",{onClick:()=>e(),className:"lua:absolute lua:top-1 lua:right-1 lua:w-6 lua:h-6 lua:flex lua:items-center lua:justify-center lua:rounded-full lua:bg-gray-800 lua:dark:bg-gray-700 lua:text-white lua:hover:bg-gray-700 lua:dark:hover:bg-gray-600 lua:transition-colors",children:jsx("span",{className:"lua:text-sm",children:"\xD7"})})]})}function mt({file:t,onRemove:e,cdnUrl:a,initialUrl:l,thumbnailUrl:r,onUploadComplete:o}){let{getFileUrl:u}=z(),[c,i]=useState(false),[m,g]=useState(0),[n,s]=useState(l||null),[p,y]=useState(false),[d,v]=useState(r||null);return useEffect(()=>{if(!r&&!d){let h=u(t),k=document.createElement("video");k.src=h;let w=()=>{try{k.currentTime=0,setTimeout(()=>{let f=document.createElement("canvas");f.width=k.videoWidth,f.height=k.videoHeight;let x=f.getContext("2d");if(!x){console.error("Could not get canvas context");return}x.drawImage(k,0,0);let U=f.toDataURL("image/jpeg",.8);v(U);},100);}catch(f){console.error("Error generating thumbnail:",f);}finally{URL.revokeObjectURL(h),k.removeEventListener("canplay",w);}};k.addEventListener("canplay",w),k.load();}},[t,r,d]),useEffect(()=>{if(l||p)return;(async()=>{i(true),y(true);try{let{fileId:k}=await Z(t,a,f=>{g(f);}),w=`${a}/${k}`;s(w),i(!1),o&&o(t,w);}catch(k){console.error("Upload failed:",k),i(false);}})();},[t,l,a,p,o]),jsxs("div",{className:"lua:relative lua:flex-shrink-0",children:[c?jsxs("div",{className:"lua:w-32 lua:h-32 lua:bg-gray-100 lua:dark:bg-gray-800 lua:rounded-lg lua:flex lua:flex-col lua:items-center lua:justify-center",children:[jsx("div",{className:"lua:w-8 lua:h-8 lua:border-2 lua:border-t-blue-500 lua:border-r-transparent lua:border-b-transparent lua:border-l-transparent lua:rounded-full lua:animate-spin"}),jsxs("div",{className:"lua:mt-2 lua:text-xs lua:text-gray-600 lua:dark:text-gray-300 lua:font-medium",children:[Math.round(m),"%"]})]}):jsxs("div",{className:"lua:relative",children:[jsx("img",{"data-testid":"video-thumbnail",src:d||n||"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",alt:t.name,className:"lua:w-32 lua:h-32 lua:object-cover lua:rounded-lg lua:bg-gray-100 lua:dark:bg-gray-800"}),jsx("div",{className:"lua:absolute lua:inset-0 lua:flex lua:items-center lua:justify-center",children:jsx("div",{className:"lua:w-10 lua:h-10 lua:rounded-full lua:bg-black/50 lua:flex lua:items-center lua:justify-center",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M5 3L19 12L5 21V3Z",fill:"white"})})})})]}),jsxs("div",{className:"lua:absolute lua:bottom-1 lua:left-1 lua:px-1.5 lua:py-0.5 lua:rounded lua:bg-black/50 lua:text-white lua:text-xs",children:[Math.floor(t.size/1024/1024),"MB"]}),jsx("button",{onClick:()=>e(),className:"lua:absolute lua:top-1 lua:right-1 lua:w-6 lua:h-6 lua:flex lua:items-center lua:justify-center lua:rounded-full lua:bg-gray-800 lua:dark:bg-gray-700 lua:text-white lua:hover:bg-gray-700 lua:dark:hover:bg-gray-600 lua:transition-colors",children:jsx("span",{className:"lua:text-sm",children:"\xD7"})})]})}function jt(t){let e=t.type,a="other",l="File";return e.startsWith("image/")?(a="image",l="Image"):e.startsWith("video/")?(a="video",l="Video"):e.startsWith("audio/")&&(a="audio",l="Audio"),{category:a,icon:()=>null,label:l}}function Ei({files:t,onRemove:e,cdnUrl:a,fileMetadata:l=[],onFileUploadComplete:r}){let[o,u]=useState({});return useEffect(()=>{t.forEach((c,i)=>{let m=jt(c),g=l.find(n=>n.file===c);if(m.category==="video"&&!o[i]&&!g){let n=URL.createObjectURL(c),s=document.createElement("video");s.src=n;let p=()=>{try{s.currentTime=0,setTimeout(()=>{let y=document.createElement("canvas");y.width=s.videoWidth,y.height=s.videoHeight;let d=y.getContext("2d");if(!d){console.error("Could not get canvas context");return}d.drawImage(s,0,0);let v=y.toDataURL("image/jpeg",.8);u(h=>({...h,[i]:v}));},100);}catch(y){console.error("Error generating thumbnail:",y);}finally{URL.revokeObjectURL(n),s.removeEventListener("canplay",p);}};s.addEventListener("canplay",p),s.load();}});},[t,l]),t.length===0?null:jsx("div",{className:"lua:px-4 lua:py-2 lua:border-b lua:border-gray-200",children:jsx("div",{className:"lua:flex lua:gap-2 lua:overflow-x-auto scrollbar-hide",children:t.map((c,i)=>{let m=jt(c),g=l.find(n=>n.file===c);return t.length>1?jsx("div",{className:"lua:flex-shrink-0 lua:w-64",children:jsx(ct,{file:c,onRemove:()=>e(i),cdnUrl:a,onUploadComplete:(n,s)=>{r&&r(n,s);}})},i):m.category==="image"?jsx(dt,{file:c,onRemove:()=>e(i),cdnUrl:a,initialUrl:g?.url,onUploadComplete:(n,s)=>{r&&r(n,s);}},c.name):m.category==="video"?jsx(mt,{file:c,onRemove:()=>e(i),cdnUrl:a,initialUrl:g?.url,thumbnailUrl:o[i],onUploadComplete:(n,s)=>{r&&r(n,s);}},c.name):jsx("div",{className:"lua:flex-shrink-0 lua:w-64",children:jsx(ct,{file:c,onRemove:()=>e(i),cdnUrl:a,onUploadComplete:(n,s)=>{r&&r(n,s);}})},i)})})})}var ee={CHAT:{TOOLBAR_ACTION:{FILE_UPLOAD:"file_upload",CAMERA:"camera",VIDEO:"video",AUDIO:"audio",LOCATION:"location"},MESSAGE_SENT:"message_sent"}};function te(t){console.log("Analytics event:",t);}function Oi({loading:t,onFileClick:e,onCameraClick:a,onVideoClick:l,onAudioClick:r,onLocationClick:o,onSendClick:u}){return jsxs("div",{className:"lua:flex lua:items-center lua:justify-between lua:border-t lua:border-gray-200 lua:dark:border-gray-700 lua:bg-gray-50 lua:dark:bg-gray-800 lua:px-3 lua:py-2",children:[jsxs("div",{className:"lua:flex lua:items-center lua:gap-2",children:[jsxs(Tooltip,{children:[jsx(TooltipTrigger,{asChild:true,children:jsx(IconButton,{className:"lua:rounded-lg",variant:"muted",onClick:()=>{te(ee.CHAT.TOOLBAR_ACTION.FILE_UPLOAD),e();},disabled:t,"data-testid":"file-upload-button",children:jsx(Paperclip,{className:"lua:text-gray-600 lua:dark:text-gray-300"})})}),jsxs(TooltipContent,{children:[jsx(TooltipArrow,{}),jsx("p",{children:"Attach files"})]})]}),jsx("div",{className:"lua:w-px lua:h-5 lua:bg-gray-200 lua:dark:bg-gray-600"}),jsxs(Tooltip,{children:[jsx(TooltipTrigger,{asChild:true,children:jsx(IconButton,{className:"lua:rounded-lg",variant:"muted",onClick:()=>{te(ee.CHAT.TOOLBAR_ACTION.CAMERA),a();},disabled:t,"data-testid":"camera-button",children:jsx(Camera,{className:"lua:text-gray-600 lua:dark:text-gray-300"})})}),jsxs(TooltipContent,{children:[jsx(TooltipArrow,{}),jsx("p",{children:"Take a picture"})]})]}),jsxs(Tooltip,{children:[jsx(TooltipTrigger,{asChild:true,children:jsx(IconButton,{className:"lua:rounded-lg",variant:"muted",onClick:()=>{te(ee.CHAT.TOOLBAR_ACTION.VIDEO),l();},disabled:t,"data-testid":"video-button",children:jsx(VideoCamera,{className:"lua:text-gray-600 lua:dark:text-gray-300"})})}),jsxs(TooltipContent,{children:[jsx(TooltipArrow,{}),jsx("p",{children:"Record video"})]})]}),jsxs(Tooltip,{children:[jsx(TooltipTrigger,{asChild:true,children:jsx(IconButton,{className:"lua:rounded-lg",variant:"muted",onClick:()=>{te(ee.CHAT.TOOLBAR_ACTION.AUDIO),r();},disabled:t,"data-testid":"audio-button",children:jsx(Microphone,{className:"lua:text-gray-600 lua:dark:text-gray-300"})})}),jsxs(TooltipContent,{children:[jsx(TooltipArrow,{}),jsx("p",{children:"Record voice message"})]})]}),jsx("div",{className:"lua:w-px lua:h-5 lua:bg-gray-200 lua:dark:bg-gray-600"}),jsxs(Tooltip,{children:[jsx(TooltipTrigger,{asChild:true,children:jsx(IconButton,{className:"lua:rounded-lg",variant:"muted",onClick:()=>{te(ee.CHAT.TOOLBAR_ACTION.LOCATION),o();},disabled:t,"data-testid":"location-button",children:jsx(MapPin,{className:"lua:text-gray-600 lua:dark:text-gray-300"})})}),jsxs(TooltipContent,{children:[jsx(TooltipArrow,{}),jsx("p",{children:"Share location"})]})]})]}),jsx(IconButton,{onClick:()=>{te(ee.CHAT.MESSAGE_SENT),u();},disabled:t,"data-testid":"send-button",variant:"default",children:jsx(ArrowUp,{})})]})}
|
|
18
|
+
export{Vt as ActionMessage,Lt as AudioPreview,jl as AudioRecorder,gr as CameraDialog,bt as CarouselImageDialog,Vn as ChatActions,di as ChatInput,yn as ChatMessage,kn as ChatProvider,kt as CodeBlock,Ei as FilePreview,ct as FilePreviewCard,yt as ImageDialog,Un as LoadingMessage,hr as LocationDialog,Ee as PaymentPreview,Oi as Toolbar,Yl as VideoDialog,T as markdownStyles,_t as parseActions,Z as uploadFile,z as useChat,Tn as useFileUrls,zt as useInput,Mn as useLoadingMessage,Nn as useMessages,Ln as useUnreadMessages};//# sourceMappingURL=index.mjs.map
|
|
19
19
|
//# sourceMappingURL=index.mjs.map
|