@usechat/react-native 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +196 -196
- package/dist/index.mjs +288 -288
- package/package.json +4 -7
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
var Me={isInitialized:!1,projectId:null,error:null},
|
|
2
|
+
var Me={isInitialized:!1,projectId:null,error:null},Is=M=>{Me={isInitialized:!0,projectId:M,error:null}},Oe=M=>{Me={isInitialized:!1,projectId:null,error:M}};var tn=()=>({...Me}),qe=()=>{if(Me.error)throw new Error(`UseChat SDK initialization failed: ${Me.error}
|
|
3
3
|
|
|
4
4
|
Please call initChat() with a valid project ID before using any UseChat components or hooks.
|
|
5
5
|
|
|
@@ -11,294 +11,294 @@ Please call initChat() with a valid project ID before using any UseChat componen
|
|
|
11
11
|
|
|
12
12
|
Example:
|
|
13
13
|
import { initChat } from '@usechat/react-native';
|
|
14
|
-
await initChat({ projectId: 'your-project-id' });`)},
|
|
15
|
-
<
|
|
16
|
-
<
|
|
14
|
+
await initChat({ projectId: 'your-project-id' });`)},on=()=>(qe(),Me.projectId),sn=()=>Me.isInitialized&&!Me.error;var nn=async M=>{let{projectId:S,apiUrl:R="http://localhost:3000/api/chat/init",debug:C=!1}=M;if(!S){let T="Project ID is required";throw Oe(T),new Error(T)}try{C&&console.log(`[UseChat SDK] Validating projectId: ${S}`);let T=await fetch(R,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:S})});if(C&&console.log(`[Chat SDK] Response status: ${T.status}, ok: ${T.ok}`),!T.ok){let P=`HTTP ${T.status}: ${T.statusText}`;try{let B=await T.json();P=B.error||B.message||P}catch{try{let j=await T.text();j&&(P=`Server error: ${j}`)}catch{P=`Failed to initialize chat (HTTP ${T.status})`}}throw Oe(P),new Error(P)}let A;try{let P=await T.text();if(C&&console.log(`[Chat SDK] Response text: ${P}`),!P){let B="Server returned empty response";throw Oe(B),new Error(B)}A=JSON.parse(P)}catch(P){C&&console.error("[Chat SDK] JSON parse error:",P);let B="Server returned invalid JSON response";throw Oe(B),new Error(B)}if(!A||typeof A!="object"){let P="Server returned invalid response format";throw Oe(P),new Error(P)}let I=A;return C&&console.log(`[UseChat SDK] Successfully initialized with projectId: ${S}`),Is(S),I}catch(T){C&&console.error("[Chat SDK] Init error:",T);let A;throw T instanceof TypeError&&T.message.includes("fetch")?A="Network error: Unable to connect to server. Please check your internet connection.":T instanceof Error?A=T.message:A="Failed to initialize chat: Unknown error",A.includes("Project ID is required")||Oe(A),new Error(A)}};import As,{useState as Vo,useRef as zs,useCallback as $e}from"react";import{View as Fe,StyleSheet as Tn}from"react-native";import{createContext as rn,useContext as an}from"react";import{StyleSheet as ln}from"react-native";import{KeyboardProvider as Mn,KeyboardAvoidingView as Cn}from"react-native-keyboard-controller";var vs=rn(null),Rn=({children:M,config:S={}})=>{let R={keyboardBehavior:"padding",keyboardVerticalOffset:60,enableReactionDetails:!0,enableMessageActions:!0,enableScrollToBottom:!0,enableTypingIndicator:!0,...S};return<vs.Provider value={{config:R}}>
|
|
15
|
+
<Mn>
|
|
16
|
+
<Cn behavior={R.keyboardBehavior}style={[Sn.keyboardContainer]}keyboardVerticalOffset={R.keyboardVerticalOffset}>
|
|
17
17
|
{}
|
|
18
18
|
{M}
|
|
19
|
-
</
|
|
20
|
-
</
|
|
21
|
-
</
|
|
22
|
-
{N||<
|
|
19
|
+
</Cn>
|
|
20
|
+
</Mn>
|
|
21
|
+
</vs.Provider>},Ao=Rn,Tt=()=>{let M=an(vs);if(!M)throw new Error("useChatConfig must be used within a ChatProvider");return M.config},Sn=ln.create({container:{flex:1},keyboardContainer:{flex:1,overflow:"hidden"}});import{useState as zo,useCallback as wt}from"react";var It=(M={})=>{let{uploader:S,maxAttachments:R=10,maxFileSize:C=10*1024*1024,allowedTypes:T=["image/*","application/pdf","text/*"],onAttachmentAdd:A,onAttachmentRemove:I,onAttachmentUpload:P}=M,[B,j]=zo([]),[v,V]=zo(!1),[D,z]=zo(0),L=wt(N=>{if(B.length>=R){console.warn(`Maximum ${R} attachments allowed`);return}if(N.data?.size&&N.data.size>C){console.warn(`File size exceeds ${C/(1024*1024)}MB limit`);return}if(N.data?.type&&!T.some(ie=>ie.endsWith("/*")?N.data.type.startsWith(ie.slice(0,-1)):N.data.type===ie)){console.warn(`File type ${N.data.type} not allowed`);return}let E={...N,id:N.id||`att_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,uploadStatus:"pending",uploadProgress:0};j(J=>[...J,E]),A&&A(E)},[B.length,R,C,T,A]),k=wt(N=>{j(E=>E.filter(J=>J.id!==N)),I&&I(N)},[I]),O=wt(()=>{j([])},[]),H=wt(async N=>{try{let E;switch(N){case"image":E={type:"image",data:{uri:"mock-image-uri",width:800,height:600,fileName:"image.jpg",fileSize:1024*1024}};break;case"document":E={type:"document",data:{uri:"mock-document-uri",name:"document.pdf",size:2048*1024,mimeType:"application/pdf"}};break;case"location":E={type:"location",data:{coordinates:{latitude:0,longitude:0},address:"Mock Address",timestamp:Date.now()}};break;case"contact":E={type:"contact",data:{id:"contact-1",name:"John Doe",phoneNumbers:["+1234567890"],emails:["john@example.com"]}};break;default:throw new Error(`Unsupported attachment type: ${N}`)}let J={id:`att_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,type:N,data:E.data,fileName:E.data.fileName||E.data.name,fileSize:E.data.fileSize||E.data.size,mimeType:E.data.mimeType,uploadStatus:"pending",uploadProgress:0};L(J)}catch(E){console.error("Error opening picker:",E)}},[L]),F=wt(async()=>{if(!S)return console.warn("No uploader provided, skipping upload"),B;if(B.length===0)return[];V(!0),z(0);try{let N=B.map(async(Y,X)=>{try{j(Z=>Z.map(W=>W.id===Y.id?{...W,uploadStatus:"uploading",uploadProgress:0}:W));let le=setInterval(()=>{j(Z=>Z.map(W=>W.id===Y.id?{...W,uploadProgress:Math.min((W.uploadProgress??0)+10,90)}:W))},100),me=await S.upload(Y.data);clearInterval(le);let ne={...Y,uploadStatus:"completed",uploadProgress:100,data:{...Y.data,url:me.url,metadata:me.metadata}};return j(Z=>Z.map(W=>W.id===Y.id?ne:W)),ne}catch(le){return console.error(`Error uploading attachment ${Y.id}:`,le),j(me=>me.map(ne=>ne.id===Y.id?{...ne,uploadStatus:"failed",uploadProgress:0}:ne)),{...Y,uploadStatus:"failed",uploadProgress:0}}}),E=await Promise.all(N),ie=E.filter(Y=>Y.uploadStatus==="completed").length/E.length*100;return z(ie),P&&P(E),E}catch(N){return console.error("Error uploading attachments:",N),B}finally{V(!1)}},[B,S,P]);return{attachments:B,openPicker:H,addAttachment:L,removeAttachment:k,clearAttachments:O,uploadAttachments:F,isUploading:v,uploadProgress:D}};import{useState as Bo,useCallback as He}from"react";var Ps=(M={})=>{let{onSend:S,onFocus:R,initialValue:C="",maxLength:T=1e3}=M,[A,I]=Bo(C),[P,B]=Bo(40),[j,v]=Bo(!1),V=He(F=>{F.length<=T&&I(F)},[T]),D=He(F=>{if(!A.trim()&&(!F||F.length===0))return;let N=A.trim();S&&S(N,F),I(""),B(40)},[A,S]),z=He(()=>{v(!0),R&&R()},[R]),L=He(()=>{v(!1)},[]),k=He(F=>{B(Math.max(40,Math.min(F,120)))},[]),O=He(()=>{I(""),B(40)},[]),H=He(F=>{I(F)},[]);return{message:A,composerHeight:P,isFocused:j,handleTextChange:V,handleSend:D,handleFocus:z,handleBlur:L,handleContentSizeChange:k,clearMessage:O,setMessage:H}};var wn=({messages:M,components:S={},renderProps:R={},onMessageSend:C,onReactionAdd:T,onReactionRemove:A,onMessageDelete:I,onActionPress:P,attachmentUploader:B,maxAttachments:j=10,maxFileSize:v=10*1024*1024,allowedFileTypes:V=["image/*","application/pdf","text/*"],enableReactionDetails:D,enableMessageActions:z=!0,enableScrollToBottom:L,enableTypingIndicator:k,isTyping:O=!1,typingUserName:H,isLoading:F=!1,loadingComponent:N})=>{let E=Tt(),[J,ie]=Vo(!1),Y=S.MessageList||Ie,X=S.MessageInput||we,le=D??E.enableReactionDetails??!0,me=z??E.enableMessageActions??!0,ne=L??E.enableScrollToBottom??!0,Z=k??E.enableTypingIndicator??!0,[W,ce]=Vo(null),ye=zs(null),[he,re]=Vo(M||[]),ge=zs((M||[]).length+1);As.useEffect(()=>{M&&(re(M),ge.current=M.length+1)},[M]),As.useEffect(()=>{if(W&&ye.current){let U=setTimeout(()=>{ye.current?.focus()},150);return()=>clearTimeout(U)}},[W]);let xe=It({uploader:B,maxAttachments:j,maxFileSize:v,allowedTypes:V}),ee=Ps({onSend:(U,$)=>{if(W){let G={id:W.id,text:W.text,senderName:W.senderName,senderId:W.senderId,isMe:W.isMe,timestamp:W.timestamp,type:W.type==="image"?"image":"text",imageData:W.imageData};if($&&$.length>0){let K=$[0],te={id:ge.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:G,attachments:$,type:K.type==="image"?"image":"text",...K.type==="image"&&K.data&&{imageData:{uri:K.data.uri||"",width:K.data.width||300,height:K.data.height||200,fileName:K.fileName||"image.jpg",fileSize:K.fileSize||0}}};re(fe=>[...fe,te]),C&&C(te)}else{let K={id:ge.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:G};re(te=>[...te,K]),C&&C(K)}ce(null)}else if($&&$.length>0){let G=$[0],K={id:ge.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",attachments:$,type:G.type==="image"?"image":"text",...G.type==="image"&&G.data&&{imageData:{uri:G.data.uri||"",width:G.data.width||300,height:G.data.height||200,fileName:G.fileName||"image.jpg",fileSize:G.fileSize||0}}};re(te=>[...te,K]),C&&C(K)}else{let G={id:ge.current++,text:U.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent"};re(K=>[...K,G]),C&&C(G)}xe.clearAttachments()},onFocus:()=>{}}),Te=$e((U,$)=>{console.log("\u{1F525} Chat - addReaction called with messageId:",U,"and emoji:",$),re(G=>G.map(K=>K.id===U?K.reactions?.find(fe=>fe.emoji===$)?{...K,reactions:K.reactions?.map(fe=>fe.emoji===$?{...fe,count:fe.count+1,users:[...fe.users,"currentUser"]}:fe)}:{...K,reactions:[...K.reactions||[],{emoji:$,count:1,users:["currentUser"]}]}:K)),T&&T(U,$)},[T]),vo=$e((U,$)=>{re(G=>G.map(K=>K.id===U?{...K,reactions:K.reactions?.map(te=>te.emoji===$?{...te,count:Math.max(0,te.count-1),users:te.users.filter(fe=>fe!=="currentUser")}:te).filter(te=>te.count>0)}:K)),A&&A(U,$)},[A]),Po=$e(U=>{re($=>$.map(G=>G.id===U?{...G,deleted:!0,text:"",reactions:void 0}:G)),I&&I(U)},[I]),oe=$e(()=>{ce(null)},[]),de=$e(U=>{ce(U),setTimeout(()=>{ye.current?.focus()},100)},[]),St=$e(U=>{if(J)return;let{layout:$}=U.nativeEvent;$.height<=0||ie(!0)},[J]);if(F)return<Fe style={Ne.container}>
|
|
22
|
+
{N||<Fe style={Ne.loadingContainer}>
|
|
23
23
|
{}
|
|
24
|
-
</
|
|
25
|
-
</
|
|
26
|
-
<
|
|
27
|
-
<
|
|
28
|
-
</
|
|
29
|
-
</
|
|
30
|
-
<
|
|
31
|
-
<Y messages={he}isTyping={
|
|
24
|
+
</Fe>}
|
|
25
|
+
</Fe>;if(!J)return<Fe style={Ne.container}>
|
|
26
|
+
<Fe style={Ne.chatContainer}onLayout={St}>
|
|
27
|
+
<Fe style={Ne.loadingContainer}>{N}</Fe>
|
|
28
|
+
</Fe>
|
|
29
|
+
</Fe>;let ws=R.renderInput;return<Fe style={Ne.container}>
|
|
30
|
+
<Fe style={Ne.fill}>
|
|
31
|
+
<Y messages={he}isTyping={Z?O:!1}typingUserName={H}showScrollToBottom={ne}isReplyActive={!!W}enableMessageActions={me}enableReactionDetails={le}onReactionAdd={Te}onReactionRemove={vo}onMessageDelete={Po}onReplyMessage={de}onActionPress={(U,$)=>{U==="reply"?de($):P?.(U,$)}}/>
|
|
32
32
|
|
|
33
|
-
{
|
|
33
|
+
{ws?ws({value:ee.message,onChangeText:ee.handleTextChange,onSend:ee.handleSend,onFocus:ee.handleFocus,height:ee.composerHeight,onContentSizeChange:ee.handleContentSizeChange,replyToMessage:W,onCancelReply:oe,attachments:xe.attachments,onAttachmentAdd:xe.addAttachment,onAttachmentRemove:xe.removeAttachment,onAttachmentUpload:xe.uploadAttachments}):<X ref={ye}value={ee.message}onChangeText={ee.handleTextChange}onSend={ee.handleSend}onFocus={ee.handleFocus}height={ee.composerHeight}onContentSizeChange={ee.handleContentSizeChange}replyToMessage={W}onCancelReply={oe}onAttachmentSend={(U,$)=>{let G=U.type==="image",K={id:ge.current++,text:$?.trim()||"",isMe:!0,timestamp:new Date().toISOString(),status:"sent",type:G?"image":"text",...G&&U.data&&{imageData:{uri:U.data.uri||"",width:U.data.width||300,height:U.data.height||200,fileName:U.data.fileName||U.data.name||"image.jpg",fileSize:U.data.fileSize||U.data.size||0}}};re(te=>[...te,K]),C&&C(K),ee.handleTextChange("")}}/>}
|
|
34
34
|
|
|
35
35
|
{}
|
|
36
|
-
</
|
|
36
|
+
</Fe>
|
|
37
37
|
|
|
38
38
|
{}
|
|
39
|
-
</
|
|
39
|
+
</Fe>},Ne=Tn.create({container:{flex:1},chatContainer:{flex:1,overflow:"hidden"},fill:{flex:1},loadingContainer:{flex:1,justifyContent:"center",alignItems:"center"}}),Do=wn;import{View as Pe,Text as Lo,TouchableOpacity as Ut}from"react-native";import{ArrowLeft as Bn,Info as Vn,Phone as Dn,Video as Ln}from"lucide-react-native";import{useContext as An}from"react";import{createContext as In,useMemo as vn}from"react";var vt={colors:{primary:"#3B82F6",secondary:"#34B7F1",background:"#FFFFFF",surface:"#F7F8FA",surfaceSecondary:"#F3F4F6",text:"#111827",textSecondary:"#6B7280",textMuted:"#9CA3AF",border:"#E5E7EB",borderLight:"#F3F4F6",success:"#10B981",error:"#EF4444",warning:"#F59E0B",unread:"#EBF8FF",online:"#10B981",messageBubble:{sent:"#3B82F6",received:"#E5E7EB",sentText:"#FFFFFF",receivedText:"#111827"},gray:{50:"#F9FAFB",100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",400:"#9CA3AF",500:"#6B7280",600:"#4B5563",700:"#374151",800:"#1F2937",900:"#111827"},blue:{50:"#EBF8FF",500:"#3B82F6",600:"#2563EB"},green:{500:"#10B981"}},spacing:{xs:4,sm:8,md:12,lg:16,xl:24,xxl:32},borderRadius:{sm:4,md:8,lg:12,xl:16,full:9999},typography:{fontFamily:"System",fontSize:{xs:12,sm:14,base:16,lg:18,xl:20,xxl:24},fontWeight:{normal:"400",medium:"500",semibold:"600",bold:"700"},lineHeight:{tight:16,normal:20,relaxed:24}}};var ko=In(vt),Pn=(M,S)=>({colors:{...M.colors,...S.colors},spacing:{...M.spacing,...S.spacing},borderRadius:{...M.borderRadius,...S.borderRadius},typography:{...M.typography,...S.typography}}),Bs=({children:M,theme:S})=>{let R=vn(()=>S?Pn(vt,S):vt,[S]);return<ko.Provider value={R}>{M}</ko.Provider>};var q=()=>{let M=An(ko);if(!M)throw new Error("useTheme must be used within a ThemeProvider");return M};var En=({name:M="George Alan",isOnline:S=!0,onBack:R=()=>{},onVideoCall:C=()=>{},onVoiceCall:T=()=>{},onInfo:A=()=>{}})=>{let I=q();return<Pe style={{flexDirection:"row",alignItems:"center",justifyContent:"space-between",borderBottomWidth:1,borderBottomColor:I.colors.borderLight,backgroundColor:I.colors.background,paddingHorizontal:I.spacing.lg,paddingVertical:I.spacing.md,zIndex:50}}>
|
|
40
40
|
<Pe style={{flex:1,flexDirection:"row",alignItems:"center"}}>
|
|
41
|
-
<
|
|
42
|
-
<
|
|
43
|
-
</
|
|
41
|
+
<Ut onPress={R}style={{marginRight:I.spacing.md}}>
|
|
42
|
+
<Bn size={24}color={I.colors.gray[700]}/>
|
|
43
|
+
</Ut>
|
|
44
44
|
|
|
45
45
|
<Pe style={{flex:1,flexDirection:"row",alignItems:"center"}}>
|
|
46
46
|
{}
|
|
47
47
|
<Pe style={{position:"relative",marginRight:I.spacing.md}}>
|
|
48
48
|
<Pe style={{height:40,width:40,alignItems:"center",justifyContent:"center",borderRadius:I.borderRadius.full,backgroundColor:I.colors.gray[200]}}>
|
|
49
|
-
<
|
|
49
|
+
<Lo style={{fontSize:I.typography.fontSize.base,color:I.colors.text}}>
|
|
50
50
|
👤
|
|
51
|
-
</
|
|
51
|
+
</Lo>
|
|
52
52
|
</Pe>
|
|
53
53
|
{S&&<Pe style={{position:"absolute",bottom:-2,right:-2,height:12,width:12,borderRadius:I.borderRadius.full,borderWidth:1,borderColor:I.colors.background,backgroundColor:I.colors.online}}/>}
|
|
54
54
|
</Pe>
|
|
55
55
|
|
|
56
56
|
<Pe style={{flex:1}}>
|
|
57
|
-
<
|
|
57
|
+
<Lo style={{fontSize:I.typography.fontSize.lg,fontWeight:I.typography.fontWeight.semibold,color:I.colors.text}}>
|
|
58
58
|
{M}
|
|
59
|
-
</
|
|
60
|
-
<
|
|
59
|
+
</Lo>
|
|
60
|
+
<Lo style={{fontSize:I.typography.fontSize.sm,color:I.colors.textSecondary}}>
|
|
61
61
|
{S?"Online":"Offline"}
|
|
62
|
-
</
|
|
62
|
+
</Lo>
|
|
63
63
|
</Pe>
|
|
64
64
|
</Pe>
|
|
65
65
|
</Pe>
|
|
66
66
|
|
|
67
67
|
<Pe style={{flexDirection:"row",alignItems:"center",gap:I.spacing.lg}}>
|
|
68
68
|
{}
|
|
69
|
-
{
|
|
70
|
-
<
|
|
71
|
-
</
|
|
72
|
-
{T&&<
|
|
73
|
-
<
|
|
74
|
-
</
|
|
75
|
-
{A&&<
|
|
76
|
-
<
|
|
77
|
-
</
|
|
69
|
+
{C&&<Ut onPress={C}>
|
|
70
|
+
<Ln size={24}color={I.colors.gray[700]}/>
|
|
71
|
+
</Ut>}
|
|
72
|
+
{T&&<Ut onPress={T}>
|
|
73
|
+
<Dn size={24}color={I.colors.gray[700]}/>
|
|
74
|
+
</Ut>}
|
|
75
|
+
{A&&<Ut onPress={A}>
|
|
76
|
+
<Vn size={24}color={I.colors.gray[700]}/>
|
|
77
|
+
</Ut>}
|
|
78
78
|
</Pe>
|
|
79
|
-
</Pe>},
|
|
80
|
-
|
|
79
|
+
</Pe>},Kt=En;import{useRef as Xn}from"react";import{View as Bt,Text as Be,Pressable as Qn,TouchableOpacity as Zn}from"react-native";import Pt from"dayjs";import jn from"dayjs/plugin/isToday";import On from"dayjs/plugin/isYesterday";Pt.extend(jn);Pt.extend(On);var Hn=M=>{let S=Pt(M);return S.isToday()?"Today":S.isYesterday()?"Yesterday":S.format("ddd D MMMM")},Fn=M=>Pt(M).format("YYYY-MM-DD"),Vs=M=>{if(M.length===0)return[];let S=[],R=null;return M.forEach((C,T)=>{let A=Fn(C.timestamp);if(R!==A){let P=Hn(C.timestamp),B={id:`date-${A}`,listItemType:"date-separator",date:A,displayDate:P};S.push(B),R=A}let I={...C,listItemType:"message"};S.push(I)}),S},Eo=M=>Pt(M).format("HH:mm");import{View as Oo,Text as $t,Image as Nn}from"react-native";var Wn=({replyTo:M,isMyMessage:S})=>{let R=q(),C=(j,v=50)=>j.length<=v?j:j.substring(0,v)+"...",T=S?"rgba(255, 255, 255, 0.3)":R.colors.primary,A=S?"rgba(255, 255, 255, 0.8)":R.colors.primary,I=S?"rgba(255, 255, 255, 0.7)":R.colors.textSecondary,P=S?"rgba(255, 255, 255, 0.1)":R.colors.surfaceSecondary,B=M.type==="image"&&M.imageData;return<Oo style={{marginBottom:R.spacing.sm,borderRadius:R.borderRadius.md,padding:R.spacing.sm,backgroundColor:P,borderLeftWidth:4,borderLeftColor:T}}>
|
|
80
|
+
<$t style={{fontSize:R.typography.fontSize.xs,fontWeight:R.typography.fontWeight.medium,color:A,marginBottom:R.spacing.xs}}>
|
|
81
81
|
{M.isMe?"You":M.senderName||"Sender"}
|
|
82
|
-
|
|
82
|
+
</$t>
|
|
83
83
|
|
|
84
|
-
{
|
|
85
|
-
<
|
|
86
|
-
<
|
|
87
|
-
|
|
84
|
+
{B?<Oo style={{flexDirection:"row",alignItems:"center"}}>
|
|
85
|
+
<Nn source={{uri:M.imageData.uri}}style={{width:40,height:40,borderRadius:R.borderRadius.sm,marginRight:R.spacing.sm}}resizeMode="cover"/>
|
|
86
|
+
<Oo style={{flex:1}}>
|
|
87
|
+
<$t style={{fontSize:R.typography.fontSize.xs,color:I,fontStyle:"italic",marginBottom:R.spacing.xs}}>
|
|
88
88
|
📷 Image
|
|
89
|
-
|
|
90
|
-
{M.text&&M.text.trim()
|
|
91
|
-
{
|
|
92
|
-
|
|
93
|
-
</
|
|
94
|
-
</
|
|
95
|
-
{
|
|
96
|
-
|
|
97
|
-
</
|
|
98
|
-
|
|
89
|
+
</$t>
|
|
90
|
+
{M.text&&M.text.trim()&&<$t style={{fontSize:R.typography.fontSize.sm,color:I,lineHeight:R.typography.lineHeight.tight}}>
|
|
91
|
+
{C(M.text,30)}
|
|
92
|
+
</$t>}
|
|
93
|
+
</Oo>
|
|
94
|
+
</Oo>:<$t style={{fontSize:R.typography.fontSize.sm,color:I,lineHeight:R.typography.lineHeight.tight}}>
|
|
95
|
+
{C(M.text)}
|
|
96
|
+
</$t>}
|
|
97
|
+
</Oo>},Ye=Wn;import{useState as Ds,useCallback as At}from"react";import{View as Yt,Image as Ls,Pressable as Es,Modal as Un,Dimensions as Kn,StyleSheet as qn,Text as $n}from"react-native";var{width:Ho,height:js}=Kn.get("window"),Yn=({imageData:M,isMe:S,onImagePress:R,onLongPress:C})=>{let T=q(),[A,I]=Ds(!1),[P,B]=Ds(!1),v=At(()=>{let O=Ho*.6,H=300;if(!M.width||!M.height)return{width:O,height:H};let F=M.width/M.height,N=O,E=N/F;return E>H&&(E=H,N=E*F),{width:Math.round(N),height:Math.round(E)}},[M.width,M.height])(),V=At(()=>{R?R():I(!0)},[R]),D=At(()=>{console.error("Failed to load image:",M.uri),B(!0)},[M.uri]),z=At(()=>{I(!1)},[]),k=At(()=>{if(!M.width||!M.height)return{width:Ho,height:js*.8};let O=M.width/M.height,H=Ho*.9,F=js*.8,N=H,E=N/O;return E>F&&(E=F,N=E*O),{width:Math.round(N),height:Math.round(E)}},[M.width,M.height])();return P?<Yt style={[Ae.errorContainer,{width:v.width,height:v.height,backgroundColor:S?T.colors.messageBubble.sent:T.colors.messageBubble.received,borderRadius:T.borderRadius.lg}]}>
|
|
98
|
+
<$n style={[Ae.errorText,{color:S?T.colors.messageBubble.sentText:T.colors.messageBubble.receivedText,fontSize:T.typography.fontSize.sm}]}>
|
|
99
99
|
Failed to load image
|
|
100
|
-
|
|
101
|
-
</
|
|
102
|
-
<
|
|
103
|
-
<
|
|
104
|
-
<
|
|
100
|
+
</$n>
|
|
101
|
+
</Yt>:<>
|
|
102
|
+
<Es onPress={V}onLongPress={C}delayLongPress={500}>
|
|
103
|
+
<Yt style={[Ae.imageContainer,{borderRadius:T.borderRadius.lg,overflow:"hidden"}]}>
|
|
104
|
+
<Ls source={{uri:M.uri}}style={[Ae.image,{width:v.width,height:v.height}]}resizeMode='cover'onError={D}/>
|
|
105
105
|
|
|
106
106
|
{}
|
|
107
|
-
<
|
|
108
|
-
</
|
|
109
|
-
</
|
|
107
|
+
<Yt style={Ae.imageOverlay}/>
|
|
108
|
+
</Yt>
|
|
109
|
+
</Es>
|
|
110
110
|
|
|
111
111
|
{}
|
|
112
|
-
<
|
|
113
|
-
<
|
|
114
|
-
<
|
|
115
|
-
<
|
|
116
|
-
</
|
|
117
|
-
</
|
|
118
|
-
</
|
|
119
|
-
</>},Ae=
|
|
120
|
-
<
|
|
121
|
-
<
|
|
122
|
-
<
|
|
123
|
-
|
|
112
|
+
<Un visible={A}transparent animationType='fade'onRequestClose={z}>
|
|
113
|
+
<Es style={Ae.modalContainer}onPress={z}>
|
|
114
|
+
<Yt style={Ae.modalContent}>
|
|
115
|
+
<Ls source={{uri:M.uri}}style={[Ae.modalImage,{width:k.width,height:k.height,borderRadius:T.borderRadius.lg}]}resizeMode='contain'/>
|
|
116
|
+
</Yt>
|
|
117
|
+
</Es>
|
|
118
|
+
</Un>
|
|
119
|
+
</>},Ae=qn.create({imageContainer:{position:"relative"},image:{backgroundColor:"#f0f0f0"},imageOverlay:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"transparent"},errorContainer:{justifyContent:"center",alignItems:"center",borderWidth:1,borderColor:"#e0e0e0"},errorText:{textAlign:"center",fontWeight:"500"},modalContainer:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.9)",justifyContent:"center",alignItems:"center"},modalContent:{justifyContent:"center",alignItems:"center"},modalImage:{backgroundColor:"transparent"}}),Gt=Yn;import{View as _t,Text as Os,StyleSheet as Gn}from"react-native";import{Trash2 as _n}from"lucide-react-native";var Jn=({isMe:M,timestamp:S,senderName:R})=>{let C=q();return<_t style={[Ge.container,{alignSelf:M?"flex-end":"flex-start",maxWidth:"80%"}]}>
|
|
120
|
+
<_t style={[Ge.messageBubble,{backgroundColor:C.colors.gray[100],borderColor:C.colors.gray[200]}]}>
|
|
121
|
+
<_t style={Ge.content}>
|
|
122
|
+
<_n size={16}color={C.colors.gray[500]}/>
|
|
123
|
+
<Os style={[Ge.deletedText,{color:C.colors.gray[500]}]}>
|
|
124
124
|
This message was deleted
|
|
125
|
-
|
|
126
|
-
</
|
|
127
|
-
</
|
|
128
|
-
<
|
|
129
|
-
|
|
125
|
+
</Os>
|
|
126
|
+
</_t>
|
|
127
|
+
</_t>
|
|
128
|
+
<_t style={[Ge.metadata,{alignSelf:M?"flex-end":"flex-start"}]}>
|
|
129
|
+
<Os style={[Ge.timestamp,{color:C.colors.gray[400]}]}>
|
|
130
130
|
{S}
|
|
131
|
-
|
|
132
|
-
</
|
|
133
|
-
</
|
|
134
|
-
<
|
|
135
|
-
{M.replyTo&&<
|
|
131
|
+
</Os>
|
|
132
|
+
</_t>
|
|
133
|
+
</_t>},Ge=Gn.create({container:{marginVertical:4,marginHorizontal:15},messageBubble:{borderRadius:18,paddingHorizontal:16,paddingVertical:12,borderWidth:1,borderStyle:"dashed"},content:{flexDirection:"row",alignItems:"center",justifyContent:"center"},deletedText:{fontSize:14,fontStyle:"italic",marginLeft:8},metadata:{marginTop:4,paddingHorizontal:4},timestamp:{fontSize:11}}),Jt=Jn;var er=({message:M,onLongPress:S,onReactionPress:R})=>{let C=q(),T=Xn(null),A=()=>{T.current?T.current.measureInWindow((B,j,v,V)=>{let D={x:Math.round(B),y:Math.round(j),width:Math.round(v),height:Math.round(V)};S?.(M,D)}):S?.(M)},I=()=>{M.reactions&&M.reactions.length>0&&R?.(M)},P=M.type==="image"&&M.imageData;return M.deleted?<Jt isMe={M.isMe}timestamp={Eo(M.timestamp)}senderName={M.senderName}/>:<Bt style={{marginBottom:C.spacing.md,alignItems:M.isMe?"flex-end":"flex-start",marginHorizontal:C.spacing.sm}}>
|
|
134
|
+
<Qn ref={T}onLongPress={A}delayLongPress={500}style={{maxWidth:P?"75%":"80%",borderRadius:P?C.borderRadius.lg:C.borderRadius.xl,borderBottomRightRadius:M.isMe?4:P?C.borderRadius.lg:C.borderRadius.xl,borderBottomLeftRadius:M.isMe?P?C.borderRadius.lg:C.borderRadius.xl:4,paddingHorizontal:P?0:C.spacing.lg,paddingVertical:P?0:C.spacing.md,backgroundColor:P?"transparent":M.isMe?C.colors.messageBubble.sent:C.colors.messageBubble.received,overflow:"hidden"}}>
|
|
135
|
+
{M.replyTo&&<Ye replyTo={M.replyTo}isMyMessage={M.isMe}/>}
|
|
136
136
|
|
|
137
|
-
{P?<
|
|
137
|
+
{P?<Gt imageData={M.imageData}isMe={M.isMe}onLongPress={A}/>:<Be style={{fontSize:C.typography.fontSize.base,color:M.isMe?C.colors.messageBubble.sentText:C.colors.messageBubble.receivedText}}>
|
|
138
138
|
{M.text}
|
|
139
139
|
</Be>}
|
|
140
140
|
|
|
141
141
|
{}
|
|
142
|
-
{P&&M.text&&M.text.trim()&&<
|
|
143
|
-
<Be style={{fontSize:
|
|
142
|
+
{P&&M.text&&M.text.trim()&&<Bt style={{paddingHorizontal:C.spacing.lg,paddingVertical:C.spacing.md,backgroundColor:M.isMe?C.colors.messageBubble.sent:C.colors.messageBubble.received,borderRadius:C.borderRadius.lg,marginTop:C.spacing.xs}}>
|
|
143
|
+
<Be style={{fontSize:C.typography.fontSize.base,color:M.isMe?C.colors.messageBubble.sentText:C.colors.messageBubble.receivedText}}>
|
|
144
144
|
{M.text}
|
|
145
145
|
</Be>
|
|
146
|
-
</
|
|
147
|
-
</
|
|
146
|
+
</Bt>}
|
|
147
|
+
</Qn>
|
|
148
148
|
|
|
149
149
|
{}
|
|
150
|
-
{M.reactions&&M.reactions.length>0&&<
|
|
151
|
-
{M.reactions.map((
|
|
152
|
-
<Be style={{fontSize:
|
|
153
|
-
{
|
|
150
|
+
{M.reactions&&M.reactions.length>0&&<Zn onPress={I}style={{marginTop:C.spacing.xs,flexDirection:"row",alignItems:"center",backgroundColor:C.colors.background,borderRadius:C.borderRadius.full,justifyContent:M.isMe?"flex-end":"flex-start"}}>
|
|
151
|
+
{M.reactions.map((B,j)=><Bt key={`${B.emoji}-${j}`}style={{flexDirection:"row",alignItems:"center",padding:C.spacing.xs}}>
|
|
152
|
+
<Be style={{fontSize:C.typography.fontSize.sm}}>
|
|
153
|
+
{B.emoji}
|
|
154
154
|
</Be>
|
|
155
|
-
{
|
|
156
|
-
{
|
|
155
|
+
{B.count>1&&<Be style={{fontSize:C.typography.fontSize.xs,color:C.colors.textSecondary,marginLeft:C.spacing.xs,fontWeight:C.typography.fontWeight.medium}}>
|
|
156
|
+
{B.count}
|
|
157
157
|
</Be>}
|
|
158
|
-
</
|
|
159
|
-
</
|
|
158
|
+
</Bt>)}
|
|
159
|
+
</Zn>}
|
|
160
160
|
|
|
161
|
-
<
|
|
162
|
-
<Be style={{fontSize:
|
|
163
|
-
{
|
|
161
|
+
<Bt style={{marginHorizontal:C.spacing.sm,marginTop:C.spacing.xs,flexDirection:"row",alignItems:"center",justifyContent:M.isMe?"flex-end":"flex-start"}}>
|
|
162
|
+
<Be style={{fontSize:C.typography.fontSize.xs,color:C.colors.textSecondary}}>
|
|
163
|
+
{Eo(M.timestamp)}
|
|
164
164
|
</Be>
|
|
165
|
-
{M.isMe&&M.status&&<
|
|
166
|
-
{M.status==="sent"&&<Be style={{fontSize:
|
|
165
|
+
{M.isMe&&M.status&&<Bt style={{marginLeft:C.spacing.xs}}>
|
|
166
|
+
{M.status==="sent"&&<Be style={{fontSize:C.typography.fontSize.xs,color:C.colors.gray[400]}}>
|
|
167
167
|
✓
|
|
168
168
|
</Be>}
|
|
169
|
-
{M.status==="delivered"&&<Be style={{fontSize:
|
|
169
|
+
{M.status==="delivered"&&<Be style={{fontSize:C.typography.fontSize.xs,color:C.colors.gray[400]}}>
|
|
170
170
|
✓✓
|
|
171
171
|
</Be>}
|
|
172
|
-
{M.status==="read"&&<Be style={{fontSize:
|
|
172
|
+
{M.status==="read"&&<Be style={{fontSize:C.typography.fontSize.xs,color:C.colors.primary}}>
|
|
173
173
|
✓✓
|
|
174
174
|
</Be>}
|
|
175
|
-
</
|
|
176
|
-
</
|
|
177
|
-
</
|
|
175
|
+
</Bt>}
|
|
176
|
+
</Bt>
|
|
177
|
+
</Bt>},Xt=er;import{View as Ce,Text as _e,TouchableOpacity as Mr,Image as Cr}from"react-native";import{X as Rr}from"lucide-react-native";var Sr=({replyToMessage:M,onCancel:S})=>{let R=q(),C=(I,P=50)=>I.length<=P?I:I.substring(0,P)+"...",T=!!M.replyTo,A=M.type==="image"&&M.imageData;return<Ce style={{borderBottomWidth:1,borderBottomColor:R.colors.border,backgroundColor:R.colors.surface,paddingHorizontal:R.spacing.lg,paddingVertical:R.spacing.md}}>
|
|
178
178
|
<Ce style={{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}>
|
|
179
|
-
<Ce style={{flex:1,marginRight:
|
|
180
|
-
<Ce style={{flexDirection:"row",alignItems:"center",marginBottom:
|
|
181
|
-
<Ce style={{width:4,backgroundColor:
|
|
179
|
+
<Ce style={{flex:1,marginRight:R.spacing.md}}>
|
|
180
|
+
<Ce style={{flexDirection:"row",alignItems:"center",marginBottom:R.spacing.xs}}>
|
|
181
|
+
<Ce style={{width:4,backgroundColor:R.colors.primary,borderRadius:R.borderRadius.full,marginRight:R.spacing.md,height:T?48:32}}/>
|
|
182
182
|
<Ce style={{flex:1}}>
|
|
183
|
-
<
|
|
183
|
+
<_e style={{fontSize:R.typography.fontSize.xs,fontWeight:R.typography.fontWeight.medium,color:R.colors.primary,marginBottom:R.spacing.xs}}>
|
|
184
184
|
Replying to {M.isMe?"yourself":M.senderName||"sender"}
|
|
185
185
|
{T&&" (reply thread)"}
|
|
186
|
-
</
|
|
186
|
+
</_e>
|
|
187
187
|
|
|
188
188
|
{}
|
|
189
|
-
{T&&<Ce style={{marginBottom:
|
|
190
|
-
<
|
|
189
|
+
{T&&<Ce style={{marginBottom:R.spacing.sm,padding:R.spacing.sm,backgroundColor:R.colors.surfaceSecondary,borderRadius:R.borderRadius.md,borderLeftWidth:2,borderLeftColor:R.colors.gray[300]}}>
|
|
190
|
+
<_e style={{fontSize:R.typography.fontSize.xs,color:R.colors.textSecondary,marginBottom:R.spacing.xs}}>
|
|
191
191
|
Originally replying to: {M.replyTo.isMe?"yourself":M.replyTo.senderName||"sender"}
|
|
192
|
-
</
|
|
193
|
-
<
|
|
194
|
-
{
|
|
195
|
-
</
|
|
192
|
+
</_e>
|
|
193
|
+
<_e style={{fontSize:R.typography.fontSize.xs,color:R.colors.textSecondary,lineHeight:R.typography.lineHeight.tight}}>
|
|
194
|
+
{C(M.replyTo.text,40)}
|
|
195
|
+
</_e>
|
|
196
196
|
</Ce>}
|
|
197
197
|
|
|
198
198
|
{A?<Ce style={{flexDirection:"row",alignItems:"center"}}>
|
|
199
|
-
<
|
|
199
|
+
<Cr source={{uri:M.imageData.uri}}style={{width:32,height:32,borderRadius:R.borderRadius.sm,marginRight:R.spacing.sm}}resizeMode="cover"/>
|
|
200
200
|
<Ce style={{flex:1}}>
|
|
201
|
-
<
|
|
201
|
+
<_e style={{fontSize:R.typography.fontSize.xs,color:R.colors.gray[600],fontStyle:"italic",marginBottom:R.spacing.xs}}>
|
|
202
202
|
📷 Image
|
|
203
|
-
</
|
|
204
|
-
{M.text&&M.text.trim()&&<
|
|
205
|
-
{
|
|
206
|
-
</
|
|
203
|
+
</_e>
|
|
204
|
+
{M.text&&M.text.trim()&&<_e style={{fontSize:R.typography.fontSize.sm,color:R.colors.gray[700],lineHeight:R.typography.lineHeight.tight}}>
|
|
205
|
+
{C(M.text,40)}
|
|
206
|
+
</_e>}
|
|
207
207
|
</Ce>
|
|
208
|
-
</Ce>:<
|
|
209
|
-
{
|
|
210
|
-
</
|
|
208
|
+
</Ce>:<_e style={{fontSize:R.typography.fontSize.sm,color:R.colors.gray[700],lineHeight:R.typography.lineHeight.tight}}>
|
|
209
|
+
{C(M.text)}
|
|
210
|
+
</_e>}
|
|
211
211
|
</Ce>
|
|
212
212
|
</Ce>
|
|
213
213
|
</Ce>
|
|
214
214
|
|
|
215
|
-
<
|
|
216
|
-
<
|
|
217
|
-
</
|
|
215
|
+
<Mr onPress={S}style={{height:32,width:32,alignItems:"center",justifyContent:"center",borderRadius:R.borderRadius.full,backgroundColor:R.colors.gray[200]}}hitSlop={{top:8,bottom:8,left:8,right:8}}>
|
|
216
|
+
<Rr size={16}color={R.colors.textSecondary}/>
|
|
217
|
+
</Mr>
|
|
218
218
|
</Ce>
|
|
219
|
-
</Ce>},
|
|
220
|
-
<
|
|
221
|
-
{
|
|
222
|
-
</
|
|
223
|
-
{M.replyTo&&<
|
|
219
|
+
</Ce>},Vt=Sr;import{useRef as Ve,useState as Hs,useEffect as Wo}from"react";import{View as Dt,Text as Ze,TouchableOpacity as Qe,StyleSheet as Fo,Pressable as Pr,ScrollView as Ar,Dimensions as zr,Animated as ue,Image as Br}from"react-native";import{Reply as Vr,Copy as Dr,Plus as Lr,Trash2 as Er}from"lucide-react-native";import{useState as Tr,useEffect as wr}from"react";import Ir from"rn-emoji-keyboard";var vr=({visible:M,onClose:S,onEmojiSelected:R})=>{let[C,T]=Tr(!1);wr(()=>{T(!!M)},[M]);let A=P=>{console.log("Selected emoji:",P),R(P.emoji),T(!1),S()},I=()=>{T(!1),S()};return M?<Ir onEmojiSelected={A}open={C}onClose={I}enableSearchBar/>:null},Je=vr;var Or=({visible:M,onPress:S,children:R})=>M?<Dt style={se.overlay}>
|
|
220
|
+
<Qe style={se.backdrop}onPress={S}activeOpacity={1}/>
|
|
221
|
+
{R}
|
|
222
|
+
</Dt>:null,{width:Xe,height:No}=zr.get("window"),Hr=({message:M,positions:S,messagePosition:R,containerRef:C,containerOffset:T,setContainerOffset:A})=>{let I=q(),P=Ve(new ue.Value(R.y)).current,B=Ve(new ue.Value(0)).current,j=Ve(!1),v=M.type==="image"&&M.imageData;return Wo(()=>{j.current=!1,C.current&&C.current.measureInWindow((V,D,z,L)=>{A({x:V,y:D});let k=R.y-D,O=S.messagePreviewTop-D;P.setValue(k),B.setValue(0),requestAnimationFrame(()=>{ue.parallel([ue.timing(P,{toValue:O,duration:250,useNativeDriver:!1}),ue.timing(B,{toValue:1,duration:250,useNativeDriver:!1})]).start(()=>{j.current=!0})})})},[S.messagePreviewTop,R.y,C]),<ue.View style={{position:"absolute",top:P,left:R.x,width:R.width,height:M.replyTo?R.height+10:R.height,zIndex:1e3,opacity:B,maxWidth:v?"75%":"80%",borderRadius:v?I.borderRadius.lg:I.borderRadius.xl,paddingHorizontal:v?0:I.spacing.lg,paddingVertical:v?0:I.spacing.md,backgroundColor:v?"transparent":M.isMe?I.colors.messageBubble.sent:I.colors.messageBubble.received,overflow:"hidden"}}>
|
|
223
|
+
{M.replyTo&&<Ye replyTo={M.replyTo}isMyMessage={M.isMe}/>}
|
|
224
224
|
|
|
225
|
-
{v?<
|
|
226
|
-
<
|
|
225
|
+
{v?<Dt>
|
|
226
|
+
<Br source={{uri:M.imageData.uri}}style={{width:R.width,height:R.height,borderRadius:I.borderRadius.lg}}resizeMode='cover'/>
|
|
227
227
|
{}
|
|
228
|
-
{M.text&&M.text.trim()&&<
|
|
229
|
-
<
|
|
228
|
+
{M.text&&M.text.trim()&&<Dt style={{paddingHorizontal:I.spacing.lg,paddingVertical:I.spacing.md,backgroundColor:M.isMe?I.colors.messageBubble.sent:I.colors.messageBubble.received,borderRadius:I.borderRadius.lg,marginTop:I.spacing.xs}}>
|
|
229
|
+
<Ze style={{fontSize:I.typography.fontSize.base,color:M.isMe?I.colors.messageBubble.sentText:I.colors.messageBubble.receivedText}}>
|
|
230
230
|
{M.text}
|
|
231
|
-
</
|
|
232
|
-
</
|
|
233
|
-
</
|
|
231
|
+
</Ze>
|
|
232
|
+
</Dt>}
|
|
233
|
+
</Dt>:<Ze style={{fontSize:I.typography.fontSize.base,color:M.isMe?I.colors.messageBubble.sentText:I.colors.messageBubble.receivedText}}>
|
|
234
234
|
{M.text}
|
|
235
|
-
</
|
|
236
|
-
</ue.View>},
|
|
235
|
+
</Ze>}
|
|
236
|
+
</ue.View>},Fr=({visible:M,onClose:S,isMyMessage:R,selectedMessage:C,messagePosition:T,onActionPress:A,onEmojiReact:I})=>{let[P,B]=Hs(!1),j=Ve(null),[v,V]=Hs({x:0,y:0}),D=Ve(new ue.Value(0)).current,z=Ve(new ue.Value(0)).current,L=Ve(!1),k=Ve(!1),O=X=>{A(X),S()},H=X=>{I?.(X),S()},F=()=>{B(!0)},N=()=>{B(!1)},E=X=>{I?.(X),B(!1),S()},J=["\u2764\uFE0F","\u{1F602}","\u{1F62E}","\u{1F622}","\u{1F621}","\u{1F44D}"],Y=(()=>{if(!T)return{emojiBar:{top:No/2-200,left:Xe/2-160},actionMenu:{top:No/2+50,left:Xe/2-100}};let X=320,le=60,me=200,ne=160,Z=20,W=8,ce,ye,he,re,ge,xe=No/2,ee=le+W+T.height+W+ne,Te=xe-ee/2;return ye=Te,ge=Te+le+W,re=Te+le+W+T.height+W,ce=T.x,he=T.x,ce+X>Xe-Z&&(ce=Xe-X-Z),ce<Z&&(ce=Z),he+me>Xe-Z&&(he=Xe-me-Z),he<Z&&(he=Z),{emojiBar:{top:ye,left:ce},actionMenu:{top:re,left:he},messagePreviewTop:ge,isNearAverageHeight:!0,isNearTop:!0,isEdgeCase:!0}})();return Wo(()=>{M&&T&&!k.current&&(D.setValue(0),z.setValue(0),setTimeout(()=>{ue.sequence([ue.timing(D,{toValue:1,duration:200,useNativeDriver:!1}),ue.timing(z,{toValue:1,duration:200,useNativeDriver:!1})]).start(()=>{k.current=!0})},50))},[M,T,D,z]),Wo(()=>{M||(L.current=!1,k.current=!1,D.setValue(0),z.setValue(0))},[M,D,z]),M?<>
|
|
237
237
|
{}
|
|
238
|
-
<
|
|
239
|
-
<
|
|
240
|
-
</
|
|
238
|
+
<Or visible={!0}onPress={S}>
|
|
239
|
+
<Pr style={se.overlayPressable}onPress={S}/>
|
|
240
|
+
</Or>
|
|
241
241
|
|
|
242
|
-
<
|
|
242
|
+
<Dt ref={j}style={{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"}}>
|
|
243
243
|
{}
|
|
244
|
-
</
|
|
244
|
+
</Dt>
|
|
245
245
|
|
|
246
246
|
{}
|
|
247
|
-
{T&&
|
|
247
|
+
{T&&C&&<Hr message={C}positions={Y}messagePosition={T}containerRef={j}containerOffset={v}setContainerOffset={V}/>}
|
|
248
248
|
|
|
249
249
|
{}
|
|
250
|
-
<ue.View style={[
|
|
251
|
-
|
|
252
|
-
{J.map((X,le)=><
|
|
253
|
-
<
|
|
254
|
-
</
|
|
255
|
-
<
|
|
256
|
-
<
|
|
257
|
-
</
|
|
258
|
-
|
|
250
|
+
<ue.View style={[se.emojiBar,{position:"absolute",top:Y.emojiBar.top-(v.y||0),left:Y.emojiBar.left,opacity:D,pointerEvents:"auto"}]}>
|
|
251
|
+
<Ar horizontal showsHorizontalScrollIndicator={!1}contentContainerStyle={se.emojiContainer}>
|
|
252
|
+
{J.map((X,le)=><Qe key={le}style={se.emojiButton}onPress={()=>H(X)}>
|
|
253
|
+
<Ze style={se.emojiText}>{X}</Ze>
|
|
254
|
+
</Qe>)}
|
|
255
|
+
<Qe style={se.addEmojiButton}onPress={F}>
|
|
256
|
+
<Lr size={20}color='#666'/>
|
|
257
|
+
</Qe>
|
|
258
|
+
</Ar>
|
|
259
259
|
</ue.View>
|
|
260
260
|
|
|
261
261
|
{}
|
|
262
|
-
<ue.View style={[
|
|
263
|
-
<
|
|
262
|
+
<ue.View style={[se.actionMenu,{position:"absolute",top:Y.actionMenu.top-(v.y||0)+(C?.replyTo?10:0),left:Y.actionMenu.left,opacity:z,pointerEvents:"auto"}]}>
|
|
263
|
+
<Dt style={se.actionItems}>
|
|
264
264
|
{}
|
|
265
|
-
<
|
|
266
|
-
<
|
|
267
|
-
<
|
|
268
|
-
</
|
|
265
|
+
<Qe style={se.actionRow}onPress={()=>O("reply")}>
|
|
266
|
+
<Vr size={18}color='#333'/>
|
|
267
|
+
<Ze style={se.actionLabel}>Reply</Ze>
|
|
268
|
+
</Qe>
|
|
269
269
|
|
|
270
270
|
{}
|
|
271
|
-
<
|
|
272
|
-
<
|
|
273
|
-
<
|
|
274
|
-
</
|
|
271
|
+
<Qe style={se.actionRow}onPress={()=>O("copy")}>
|
|
272
|
+
<Dr size={18}color='#333'/>
|
|
273
|
+
<Ze style={se.actionLabel}>Copy</Ze>
|
|
274
|
+
</Qe>
|
|
275
275
|
|
|
276
276
|
{}
|
|
277
|
-
{
|
|
278
|
-
<
|
|
279
|
-
<
|
|
277
|
+
{R&&<Qe style={se.actionRow}onPress={()=>O("delete")}>
|
|
278
|
+
<Er size={18}color='#ff4444'/>
|
|
279
|
+
<Ze style={[se.actionLabel,{color:"#ff4444"}]}>
|
|
280
280
|
Delete
|
|
281
|
-
</
|
|
282
|
-
</
|
|
283
|
-
</
|
|
281
|
+
</Ze>
|
|
282
|
+
</Qe>}
|
|
283
|
+
</Dt>
|
|
284
284
|
</ue.View>
|
|
285
285
|
|
|
286
286
|
{}
|
|
287
|
-
<
|
|
288
|
-
</>:null},
|
|
289
|
-
|
|
287
|
+
<Je visible={P}onClose={N}onEmojiSelected={E}/>
|
|
288
|
+
</>:null},se=Fo.create({spotlightOverlay:{position:"absolute",top:0,left:0,right:0,bottom:0},overlayPressable:{flex:1,backgroundColor:"transparent"},emojiBar:{backgroundColor:"white",borderRadius:25,paddingHorizontal:12,paddingVertical:8,shadowColor:"#000",shadowOffset:{width:0,height:4},shadowOpacity:.25,shadowRadius:12,elevation:12,zIndex:1001,maxWidth:320},emojiContainer:{flexDirection:"row",alignItems:"center",paddingHorizontal:4},emojiButton:{width:36,height:36,borderRadius:18,backgroundColor:"#f8f9fa",justifyContent:"center",alignItems:"center",marginHorizontal:3},emojiText:{fontSize:18},addEmojiButton:{width:36,height:36,borderRadius:18,backgroundColor:"#f8f9fa",justifyContent:"center",alignItems:"center",marginHorizontal:3},actionMenu:{backgroundColor:"white",borderRadius:12,shadowColor:"#000",shadowOffset:{width:0,height:4},shadowOpacity:.25,shadowRadius:12,elevation:12,zIndex:1001,minWidth:160,maxWidth:200},actionItems:{paddingVertical:4},actionRow:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:16,minHeight:44},actionLabel:{fontSize:15,color:"#333",marginLeft:12,fontWeight:"500"},hiddenEmojiInput:{position:"absolute",left:-9999,opacity:0,height:0,width:0},overlay:{...Fo.absoluteFillObject,zIndex:1e3},backdrop:{...Fo.absoluteFillObject,backgroundColor:"rgba(0, 0, 0, 0.8)"}}),Qt=Fr;import{useRef as Nr,useEffect as Wr,useState as Ur}from"react";import{View as De,Text as Re,TouchableOpacity as Fs,ScrollView as Kr,StyleSheet as qr}from"react-native";import $r from"react-native-actions-sheet";var Yr=({visible:M,onClose:S,reactions:R,messageText:C,onAddReaction:T,onRemoveReaction:A})=>{let I=Nr(null),[P,B]=Ur(!1);Wr(()=>{M?I.current?.show():I.current?.hide()},[M]);let v=(()=>{let H=[];return R.forEach(F=>{let N=[{id:"1",name:"You",avatar:"\u{1F464}"},{id:"2",name:"Anna",avatar:"\u{1F469}"},{id:"3",name:"Young Beetle",avatar:"\u{1F697}"},{id:"4",name:"Lele",avatar:"\u{1F3AD}"},{id:"5",name:"Needle",avatar:"\u{1F3E0}"}];for(let E=0;E<Math.min(F.count,N.length);E++)H.push({id:`${F.emoji}-${E}`,name:N[E].name,avatar:N[E].avatar,emoji:F.emoji,timestamp:new Date().toISOString()})}),H})(),V=R.reduce((H,F)=>H+F.count,0),D=H=>{console.log("Remove reaction called with:",H),console.log("onRemoveReaction prop exists:",!!A),console.log("User is current user:",H.name==="You"),H.name==="You"&&A?(console.log("Calling onRemoveReaction with emoji:",H.emoji),A(H.emoji)):console.log("Not calling onRemoveReaction because:",{isCurrentUser:H.name==="You",hasCallback:!!A})},z=()=>{I.current?.hide(),S(),setTimeout(()=>{B(!0)},300)},L=()=>{B(!1)},k=H=>{console.log("Selected emoji from picker:",H),T?.(H),B(!1),S()},O=()=>{I.current?.hide(),S()};return<>
|
|
289
|
+
<$r ref={I}onClose={O}containerStyle={_.container}headerAlwaysVisible={!0}gestureEnabled={!0}closeOnTouchBackdrop={!0}>
|
|
290
290
|
{}
|
|
291
291
|
<De style={_.header}>
|
|
292
|
-
<Re style={_.title}>{
|
|
293
|
-
<
|
|
292
|
+
<Re style={_.title}>{V} reactions</Re>
|
|
293
|
+
<Fs onPress={O}style={_.closeButton}>
|
|
294
294
|
<Re style={_.closeText}>✕</Re>
|
|
295
|
-
</
|
|
295
|
+
</Fs>
|
|
296
296
|
</De>
|
|
297
297
|
|
|
298
298
|
{}
|
|
299
299
|
<De style={_.messagePreview}>
|
|
300
300
|
<Re style={_.messageText}numberOfLines={2}>
|
|
301
|
-
{
|
|
301
|
+
{C}
|
|
302
302
|
</Re>
|
|
303
303
|
</De>
|
|
304
304
|
|
|
@@ -306,15 +306,15 @@ await initChat({ projectId: 'your-project-id' });`)},Vn=()=>(Ye(),Me.projectId),
|
|
|
306
306
|
<De style={_.reactionButtons}>
|
|
307
307
|
{}
|
|
308
308
|
|
|
309
|
-
{
|
|
309
|
+
{R.map((H,F)=><De key={F}style={_.reactionButton}>
|
|
310
310
|
<Re style={_.reactionEmoji}>{H.emoji}</Re>
|
|
311
311
|
<Re style={_.reactionCount}>{H.count}</Re>
|
|
312
312
|
</De>)}
|
|
313
313
|
</De>
|
|
314
314
|
|
|
315
315
|
{}
|
|
316
|
-
<
|
|
317
|
-
{v.map(H=>{let F=H.name==="You",N=F?
|
|
316
|
+
<Kr style={_.userReactionsList}showsVerticalScrollIndicator={!1}>
|
|
317
|
+
{v.map(H=>{let F=H.name==="You",N=F?Fs:De;return<N key={H.id}style={[_.userReactionItem,F&&_.tappableUserReactionItem]}onPress={F?()=>D(H):void 0}activeOpacity={F?.7:1}>
|
|
318
318
|
<De style={_.userInfo}>
|
|
319
319
|
<Re style={_.userAvatar}>{H.avatar}</Re>
|
|
320
320
|
<De style={_.userDetails}>
|
|
@@ -326,135 +326,135 @@ await initChat({ projectId: 'your-project-id' });`)},Vn=()=>(Ye(),Me.projectId),
|
|
|
326
326
|
<Re style={_.emojiText}>{H.emoji}</Re>
|
|
327
327
|
</De>
|
|
328
328
|
</N>})}
|
|
329
|
-
</
|
|
330
|
-
|
|
329
|
+
</Kr>
|
|
330
|
+
</$r>
|
|
331
331
|
|
|
332
332
|
{}
|
|
333
|
-
<
|
|
334
|
-
</>},_=
|
|
335
|
-
<
|
|
333
|
+
<Je visible={P}onClose={L}onEmojiSelected={k}/>
|
|
334
|
+
</>},_=qr.create({container:{backgroundColor:"white",borderTopLeftRadius:20,borderTopRightRadius:20,paddingTop:20,paddingBottom:40,maxHeight:"70%"},header:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:20,paddingBottom:15,borderBottomWidth:1,borderBottomColor:"#f0f0f0"},title:{fontSize:18,fontWeight:"600",color:"#333"},closeButton:{padding:5},closeText:{fontSize:18,color:"#666",fontWeight:"500"},messagePreview:{paddingHorizontal:20,paddingVertical:15,borderBottomWidth:1,borderBottomColor:"#f0f0f0"},messageText:{fontSize:14,color:"#666",lineHeight:20},reactionButtons:{flexDirection:"row",paddingHorizontal:20,paddingVertical:15,gap:10},addReactionButton:{flexDirection:"row",alignItems:"center",backgroundColor:"#f8f9fa",borderWidth:1,borderColor:"#e9ecef",borderRadius:20,paddingHorizontal:12,paddingVertical:8},addReactionIcon:{fontSize:16,marginRight:4},addReactionText:{fontSize:14,color:"#666",fontWeight:"500"},reactionButton:{flexDirection:"row",alignItems:"center",backgroundColor:"#28a745",borderRadius:20,paddingHorizontal:12,paddingVertical:8},reactionEmoji:{fontSize:16,marginRight:4},reactionCount:{fontSize:14,color:"white",fontWeight:"600"},userReactionsList:{paddingHorizontal:20,paddingTop:10},userReactionItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,borderBottomWidth:1,borderBottomColor:"#f8f9fa"},tappableUserReactionItem:{backgroundColor:"#f8f9fa",borderRadius:8,paddingHorizontal:8,marginVertical:2},userInfo:{flexDirection:"row",alignItems:"center",flex:1},userAvatar:{fontSize:24,marginRight:12},userDetails:{flex:1},userName:{fontSize:16,fontWeight:"500",color:"#333"},removeText:{fontSize:12,color:"#dc3545",marginTop:2,fontWeight:"500"},userReactionEmoji:{backgroundColor:"#f8f9fa",borderRadius:16,paddingHorizontal:8,paddingVertical:4},emojiText:{fontSize:16}}),Zt=Yr;import Gr,{forwardRef as _r,useImperativeHandle as Jr}from"react";import{View as Mo,Text as Ns,TouchableOpacity as Ws}from"react-native";import Xr from"react-native-actions-sheet";import{X as Qr}from"lucide-react-native";var We=_r(({onOptionSelect:M,options:S},R)=>{let C=Gr.useRef(null);Jr(R,()=>({show:()=>C.current?.show(),hide:()=>C.current?.hide()}));let T=A=>{M(A),C.current?.hide()};return<Xr ref={C}headerAlwaysVisible gestureEnabled={!0}statusBarTranslucent drawUnderStatusBar={!1}containerStyle={{borderTopLeftRadius:20,borderTopRightRadius:20}}>
|
|
335
|
+
<Mo style={{padding:20,width:"100%"}}>
|
|
336
336
|
|
|
337
337
|
{}
|
|
338
|
-
<
|
|
339
|
-
<
|
|
338
|
+
<Mo style={{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:20}}>
|
|
339
|
+
<Ns style={{fontSize:18,fontWeight:"600",color:"#1F2937"}}>
|
|
340
340
|
Share Content
|
|
341
|
-
</
|
|
342
|
-
<
|
|
343
|
-
<
|
|
344
|
-
</
|
|
345
|
-
</
|
|
341
|
+
</Ns>
|
|
342
|
+
<Ws onPress={()=>C.current?.hide()}>
|
|
343
|
+
<Qr size={24}color="#6B7280"/>
|
|
344
|
+
</Ws>
|
|
345
|
+
</Mo>
|
|
346
346
|
|
|
347
347
|
{}
|
|
348
|
-
<
|
|
349
|
-
{S.map(A=>{let I=A.icon;return<
|
|
350
|
-
<
|
|
348
|
+
<Mo style={{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",paddingBottom:20}}>
|
|
349
|
+
{S.map(A=>{let I=A.icon;return<Ws key={A.id}style={{width:"30%",aspectRatio:1,marginBottom:20,alignItems:"center",justifyContent:"center"}}onPress={()=>T(A.id)}>
|
|
350
|
+
<Mo style={{width:60,height:60,borderRadius:30,backgroundColor:"#F3F4F6",alignItems:"center",justifyContent:"center",marginBottom:8}}>
|
|
351
351
|
<I size={24}color={A.color}/>
|
|
352
|
-
</
|
|
353
|
-
<
|
|
352
|
+
</Mo>
|
|
353
|
+
<Ns style={{fontSize:12,color:"#6B7280",textAlign:"center",fontWeight:"500"}}>
|
|
354
354
|
{A.label}
|
|
355
|
-
</
|
|
356
|
-
</
|
|
357
|
-
</
|
|
358
|
-
</
|
|
359
|
-
</
|
|
360
|
-
<
|
|
361
|
-
<
|
|
362
|
-
<ke.View style={[
|
|
363
|
-
<ke.View style={[
|
|
364
|
-
<ke.View style={[
|
|
365
|
-
</
|
|
366
|
-
</
|
|
367
|
-
</
|
|
368
|
-
{({pressed:P})=><
|
|
369
|
-
<
|
|
370
|
-
</
|
|
371
|
-
</
|
|
372
|
-
<
|
|
373
|
-
<
|
|
355
|
+
</Ns>
|
|
356
|
+
</Ws>})}
|
|
357
|
+
</Mo>
|
|
358
|
+
</Mo>
|
|
359
|
+
</Xr>});We.displayName="AttachmentMenu";import{useEffect as Zr,useRef as ea}from"react";import{View as Uo,StyleSheet as ta,Animated as ke}from"react-native";var oa=({isVisible:M})=>{let S=ea(new ke.Value(0)).current;return Zr(()=>{if(!M){S.setValue(0);return}let R=ke.loop(ke.sequence([ke.timing(S,{toValue:1,duration:1200,useNativeDriver:!0}),ke.timing(S,{toValue:0,duration:1200,useNativeDriver:!0})]));return R.start(),()=>{R.stop()}},[M,S]),M?<Uo style={et.container}>
|
|
360
|
+
<Uo style={et.bubble}>
|
|
361
|
+
<Uo style={et.dotsContainer}>
|
|
362
|
+
<ke.View style={[et.dot,{opacity:S.interpolate({inputRange:[0,.5,1],outputRange:[.3,1,.3]}),transform:[{translateY:S.interpolate({inputRange:[0,.5,1],outputRange:[0,-4,0]})}]}]}/>
|
|
363
|
+
<ke.View style={[et.dot,{opacity:S.interpolate({inputRange:[.33,.83,1.33],outputRange:[.3,1,.3]}),transform:[{translateY:S.interpolate({inputRange:[.33,.83,1.33],outputRange:[0,-4,0]})}]}]}/>
|
|
364
|
+
<ke.View style={[et.dot,{opacity:S.interpolate({inputRange:[.66,1.16,1.66],outputRange:[.3,1,.3]}),transform:[{translateY:S.interpolate({inputRange:[.66,1.16,1.66],outputRange:[0,-4,0]})}]}]}/>
|
|
365
|
+
</Uo>
|
|
366
|
+
</Uo>
|
|
367
|
+
</Uo>:null},et=ta.create({container:{paddingHorizontal:15,paddingVertical:5},bubble:{backgroundColor:"#fff",borderRadius:18,paddingHorizontal:12,paddingVertical:8,alignSelf:"flex-start",maxWidth:"80%"},senderNameContainer:{marginBottom:4},senderName:{fontSize:12,color:"#666",fontWeight:"500"},dotsContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center"},dot:{width:6,height:6,borderRadius:3,backgroundColor:"#999",marginHorizontal:3}}),Mt=oa;import Ko from"react";import{Pressable as Ma,Animated as qo}from"react-native";import{ChevronDown as Ca}from"lucide-react-native";var Ra=({visible:M,onPress:S,isReplyActive:R=!1})=>{let C=q(),T=Ko.useRef(new qo.Value(0)).current,[A,I]=Ko.useState(!1);return Ko.useEffect(()=>{qo.timing(T,{toValue:M?1:0,duration:200,useNativeDriver:!0}).start(()=>{I(M)})},[M,T]),!M&&!A?null:<Ma onPress={S}hitSlop={{top:10,bottom:10,left:10,right:10}}>
|
|
368
|
+
{({pressed:P})=><qo.View style={[{position:"absolute",bottom:40,right:C.spacing.lg,zIndex:9999,width:32,height:32,backgroundColor:C.colors.background,borderRadius:C.borderRadius.xl,justifyContent:"center",alignItems:"center",shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.25,shadowRadius:3.84,elevation:5,opacity:T,transform:P?[{scale:.95}]:[]}]}>
|
|
369
|
+
<Ca size={20}color={C.colors.text}/>
|
|
370
|
+
</qo.View>}
|
|
371
|
+
</Ma>},Co=Ra;import{View as Us,Text as Sa}from"react-native";var Ta=({displayDate:M})=>{let S=q();return<Us style={{marginVertical:S.spacing.lg,alignItems:"center"}}>
|
|
372
|
+
<Us style={{borderRadius:S.borderRadius.full,backgroundColor:S.colors.surfaceSecondary,paddingHorizontal:S.spacing.md,paddingVertical:S.spacing.xs}}>
|
|
373
|
+
<Sa style={{fontSize:S.typography.fontSize.xs,color:S.colors.textSecondary,fontWeight:S.typography.fontWeight.medium}}>
|
|
374
374
|
{M}
|
|
375
|
-
</
|
|
376
|
-
</
|
|
377
|
-
</Xs>},Ao=Ka;import Bo,{forwardRef as si,useRef as ni,useImperativeHandle as ri,useCallback as ai}from"react";import{View as Ms,TextInput as Mi,TouchableOpacity as Mn,Platform as Cn}from"react-native";import{Plus as Ci,Send as Ri,Mic as Si}from"lucide-react-native";import{useRef as $a,useCallback as Le}from"react";import{Alert as re}from"react-native";import{Camera as Ya,Image as Ga,MapPin as _a,User as Ja,FileText as Xa,BarChart3 as Qa,Calendar as Za}from"lucide-react-native";import*as Ee from"expo-image-picker";import*as Qs from"expo-document-picker";import*as je from"expo-location";import*as Zs from"expo-contacts";import*as Tt from"expo-image-manipulator";var qa={maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"},Qo=async(M,S={})=>{try{let C={...qa,...S};console.log("Starting image compression...",{uri:M,options:C});let R=await Tt.manipulateAsync(M,[],{});console.log("Original image info:",{width:R.width,height:R.height,uri:R.uri});let T=[];if(C.maxWidth||C.maxHeight){let{width:v,height:B}=R,V=v,D=B;if(C.maxWidth&&v>C.maxWidth){let k=C.maxWidth/v;V=C.maxWidth,D=B*k}if(C.maxHeight&&D>C.maxHeight){let k=C.maxHeight/D;D=C.maxHeight,V=V*k}(V!==v||D!==B)&&(T.push({resize:{width:Math.round(V),height:Math.round(D)}}),console.log("Resizing image:",{from:{width:v,height:B},to:{width:Math.round(V),height:Math.round(D)}}))}let A={compress:C.quality,format:C.format==="png"?Tt.SaveFormat.PNG:Tt.SaveFormat.JPEG};console.log("Applying compression with options:",A);let I=await Tt.manipulateAsync(M,T,A);console.log("Image compression completed:",{originalUri:M,compressedUri:I.uri,finalDimensions:{width:I.width,height:I.height}});let P=Date.now(),z=C.format==="png"?"png":"jpg",j=`compressed_image_${P}.${z}`;return{uri:I.uri,width:I.width,height:I.height,fileName:j}}catch(C){console.error("Error compressing image:",C);let R=C instanceof Error?C.message:"Unknown error";throw new Error(`Failed to compress image: ${R}`)}},Zo=(M,S)=>M>3e3||S>3e3?{maxWidth:1920,maxHeight:1920,quality:.7,format:"jpeg"}:M>1920||S>1920?{maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"}:{quality:.9,format:"jpeg"};var ei=[{id:"photo",label:"Photo",icon:Ga,color:"#3B82F6"},{id:"camera",label:"Camera",icon:Ya,color:"#6B7280"},{id:"location",label:"Location",icon:_a,color:"#10B981"},{id:"contact",label:"Contact",icon:Ja,color:"#6B7280"},{id:"document",label:"Document",icon:Xa,color:"#3B82F6"},{id:"poll",label:"Poll",icon:Qa,color:"#F59E0B"},{id:"event",label:"Event",icon:Za,color:"#EF4444"}],zo=M=>{let S=$a(null),C=Le(async()=>{console.log("Photo selection initiated");try{console.log("Requesting photo library permissions...");let{status:v}=await Ee.requestMediaLibraryPermissionsAsync();if(console.log("Photo library permission status:",v),v!=="granted"){re.alert("Permission needed","Please grant photo library access to select images.");return}console.log("Waiting for UI to stabilize..."),await new Promise(V=>setTimeout(()=>V(void 0),300)),console.log("Launching image picker...");let B=await Ee.launchImageLibraryAsync({mediaTypes:"images",allowsEditing:!0,aspect:[4,3],quality:.8,allowsMultipleSelection:!1});if(console.log("Image picker result:",B),!B.canceled&&B.assets&&B.assets.length>0){let V=B.assets[0];console.log("Photo selected successfully:",V.uri);try{console.log("Starting image compression...");let D=Zo(V.width||1920,V.height||1920),k=await Qo(V.uri,D);console.log("Image compression completed:",k),M?.({type:"image",data:{...k,originalFileSize:V.fileSize}})}catch(D){console.error("Image compression failed:",D),re.alert("Compression Error","Failed to compress image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:V.uri,width:V.width,height:V.height,fileSize:V.fileSize,fileName:V.fileName||"image.jpg"}})}}else console.log("Photo selection was canceled by user")}catch(v){console.error("Error in photo selection process:",v),re.alert("Photo Selection Error","Failed to open photo library. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),R=Le(async()=>{console.log("Camera capture initiated");try{console.log("Requesting camera permissions...");let{status:v}=await Ee.requestCameraPermissionsAsync();if(console.log("Camera permission status:",v),v!=="granted"){re.alert("Permission needed","Please grant camera access to take photos.");return}console.log("Waiting for UI to stabilize..."),await new Promise(V=>setTimeout(()=>V(void 0),300)),console.log("Launching camera...");let B=await Ee.launchCameraAsync({allowsEditing:!0,aspect:[4,3],quality:.8,mediaTypes:"images"});if(console.log("Camera result:",B),!B.canceled&&B.assets&&B.assets.length>0){let V=B.assets[0];console.log("Photo captured successfully:",V.uri);try{console.log("Starting camera image compression...");let D=Zo(V.width||1920,V.height||1920),k=await Qo(V.uri,D);console.log("Camera image compression completed:",k),M?.({type:"image",data:{...k,originalFileSize:V.fileSize}})}catch(D){console.error("Camera image compression failed:",D),re.alert("Compression Error","Failed to compress captured image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:V.uri,width:V.width,height:V.height,fileSize:V.fileSize,fileName:V.fileName||"camera_photo.jpg"}})}}else console.log("Camera capture was canceled by user")}catch(v){console.error("Error in camera capture process:",v),re.alert("Camera Error","Failed to open camera. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),T=Le(async()=>{console.log("Location sharing initiated");try{console.log("Requesting location permissions...");let{status:v}=await je.requestForegroundPermissionsAsync();if(console.log("Location permission status:",v),v!=="granted"){re.alert("Permission needed","Please grant location access to share your location.");return}console.log("Getting current location...");let B=await je.getCurrentPositionAsync({accuracy:je.Accuracy.High});console.log("Getting address from coordinates...");let V=await je.reverseGeocodeAsync({latitude:B.coords.latitude,longitude:B.coords.longitude}),D={coordinates:{latitude:B.coords.latitude,longitude:B.coords.longitude},address:V[0]||null,timestamp:B.timestamp};console.log("Location shared successfully:",D.coordinates),M?.({type:"location",data:D})}catch(v){console.error("Error in location sharing process:",v),re.alert("Location Error","Failed to get your location. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),A=Le(async()=>{try{let{status:v}=await Zs.requestPermissionsAsync();if(v!=="granted"){re.alert("Permission needed","Please grant contacts access to share contacts.");return}re.alert("Contact Sharing","Contact selection feature is coming soon! This would open a contact picker.",[{text:"OK",onPress:()=>console.log("Contact sharing acknowledged")}])}catch(v){console.error("Error accessing contacts:",v),re.alert("Error","Failed to access contacts. Please try again.")}finally{S.current?.hide()}},[]),I=Le(async()=>{console.log("Document selection initiated");try{console.log("Waiting for UI to stabilize..."),await new Promise(B=>setTimeout(()=>B(void 0),300)),console.log("Launching document picker...");let v=await Qs.getDocumentAsync({type:"*/*",copyToCacheDirectory:!0,multiple:!1});if(console.log("Document picker result:",v),!v.canceled&&v.assets&&v.assets.length>0){let B=v.assets[0];console.log("Document selected successfully:",B.name),M?.({type:"document",data:{uri:B.uri,name:B.name,size:B.size,mimeType:B.mimeType}})}else console.log("Document selection was canceled by user")}catch(v){console.error("Error in document selection process:",v),re.alert("Document Selection Error","Failed to open document picker. Please try again.",[{text:"OK"}])}},[M]),P=Le(()=>{re.alert("Create Poll","Poll creation feature is coming soon! This would open a poll creation interface.",[{text:"OK",onPress:()=>console.log("Poll creation acknowledged")}])},[]),z=Le(()=>{re.alert("Create Event","Event creation feature is coming soon! This would open an event creation interface.",[{text:"OK",onPress:()=>console.log("Event creation acknowledged")}])},[]),j=Le(async v=>{console.log(`Selected attachment option: ${v}`);try{switch(v){case"photo":await C();break;case"camera":await R();break;case"location":await T();break;case"contact":await A();break;case"document":await I();break;case"poll":P();break;case"event":z();break;default:console.warn(`Unknown attachment option: ${v}`)}}catch(B){console.error(`Error handling ${v}:`,B),re.alert("Error",`Failed to handle ${v}. Please try again.`)}},[C,R,T,A,I,P,z]);return{menuRef:S,handleOptionSelect:j,options:ei}};import Oe,{useRef as ti,useCallback as pe,createContext as oi,useContext as qd}from"react";var Ht=(M={})=>{let{initialValue:S="",initialHeight:C=50,onValueChange:R,onHeightChange:T,onSend:A,onAttachmentSend:I,onReplyCancel:P,onFocus:z,onBlur:j,maxHeight:v=100,minHeight:B=50,maxLength:V=1e3,placeholder:D="Type a message..."}=M,k=ti(null),[L,O]=Oe.useState(S),[H,F]=Oe.useState(C),[N,E]=Oe.useState(!1),[J,ie]=Oe.useState(null),[Y,X]=Oe.useState([]),le=Oe.useMemo(()=>({value:L,height:H,isFocused:N,replyToMessage:J,attachments:Y}),[L,H,N,J,Y]),me=pe(te=>{O(te),R?.(te)},[R]),se=pe(te=>{let de=Math.max(B,Math.min(v,te));F(de),T?.(de)},[B,v,T]),Q=pe(()=>{E(!0),z?.()},[z]),W=pe(()=>{E(!1),j?.()},[j]),ce=pe(te=>{let{height:de}=te.nativeEvent.contentSize,vt=Math.max(B,Math.min(v,de+16));se(vt)},[B,v,se]),ye=pe(()=>{A&&(L||Y.length>0)&&(A(L,Y,J),O(S),X([]),ie(null),F(C))},[A,L,Y,J,S,C]),he=pe(te=>{I?(I(te,L),L&&O(S)):X(de=>[...de,{...te,id:Date.now().toString()}])},[I,L,S]),ne=pe(te=>{X(de=>[...de,te])},[]),ge=pe(te=>{X(de=>de.filter(vt=>vt.id!==te))},[]),xe=pe(()=>{X([])},[]),Z=pe(()=>{ie(null),P?.()},[P]),Te=pe(()=>{k.current?.focus()},[]),ko=Oe.useMemo(()=>({setValue:me,setHeight:se,setFocus:E,setReplyToMessage:ie,addAttachment:ne,removeAttachment:ge,clearAttachments:xe,sendMessage:ye,cancelReply:Z,focusInput:Te,handleAttachmentSelected:he,handleContentSizeChange:ce,handleFocus:Q,handleBlur:W}),[me,se,E,ie,ne,ge,xe,ye,Z,Te,he,ce,Q,W]),Lo=Oe.useMemo(()=>({textInputRef:k}),[]);return{state:le,actions:ko,refs:Lo}},Yd=oi(null);var we=si(({value:M,onChangeText:S,onSend:C,onFocus:R,height:T,onContentSizeChange:A,replyToMessage:I,onCancelReply:P,onAttachmentSend:z},j)=>{let v=q(),B=ni(null);ri(j,()=>({focus:()=>{B.current?.focus()}}));let{state:V,actions:D}=Ht({initialValue:M,initialHeight:T,onValueChange:S,onHeightChange:A,onSend:C,onAttachmentSend:z,onReplyCancel:P,onFocus:R});Bo.useEffect(()=>{M!==V.value&&D.setValue(M)},[M,V.value,D]),Bo.useEffect(()=>{T!==V.height&&D.setHeight(T)},[T,V.height,D]),Bo.useEffect(()=>{I!==V.replyToMessage&&D.setReplyToMessage(I||null)},[I,V.replyToMessage,D]),Bo.useEffect(()=>{if(I&&B.current){let O=setTimeout(()=>{B.current?.focus()},100);return()=>clearTimeout(O)}},[I]);let k=ai(O=>{if(console.log("Attachment selected:",O),z)z(O,M.trim()||void 0),M.trim()&&S("");else switch(O.type){case"image":console.log("Image attachment ready to send:",{uri:O.data.uri,dimensions:{width:O.data.width,height:O.data.height},fileName:O.data.fileName});break;case"document":console.log("Document attachment ready to send:",{name:O.data.name,size:O.data.size});break;case"location":console.log("Location attachment ready to send:",O.data.coordinates);break;case"contact":console.log("Contact attachment ready to send:",O.data);break;default:console.log("Other attachment ready to send:",O)}},[z,M,S]),L=zo(k);return<>
|
|
378
|
-
{I&&P&&<
|
|
379
|
-
<
|
|
380
|
-
<
|
|
381
|
-
<
|
|
382
|
-
<
|
|
383
|
-
</
|
|
375
|
+
</Sa>
|
|
376
|
+
</Us>
|
|
377
|
+
</Us>},Ro=Ta;import To,{forwardRef as ja,useRef as Oa,useImperativeHandle as Ha,useCallback as Fa}from"react";import{View as Go,TextInput as Na,TouchableOpacity as Ks,Platform as qs}from"react-native";import{Plus as Wa,Send as Ua,Mic as Ka}from"lucide-react-native";import{useRef as Ia,useCallback as Le}from"react";import{Alert as Q}from"react-native";import{Camera as va,Image as Pa,MapPin as Aa,User as za,FileText as Ba,BarChart3 as Va,Calendar as Da}from"lucide-react-native";var wa={maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"},$o=async(M,S={})=>{try{let R;try{R=await import("expo-image-manipulator")}catch(V){console.log("expo-image-manipulator not available, returning original image info:",V);let z=`image_${Date.now()}.jpg`;return{uri:M,width:1920,height:1920,fileName:z}}let C={...wa,...S};console.log("Starting image compression...",{uri:M,options:C});let T=await R.manipulateAsync(M,[],{});console.log("Original image info:",{width:T.width,height:T.height,uri:T.uri});let A=[];if(C.maxWidth||C.maxHeight){let{width:V,height:D}=T,z=V,L=D;if(C.maxWidth&&V>C.maxWidth){let k=C.maxWidth/V;z=C.maxWidth,L=D*k}if(C.maxHeight&&L>C.maxHeight){let k=C.maxHeight/L;L=C.maxHeight,z=z*k}(z!==V||L!==D)&&(A.push({resize:{width:Math.round(z),height:Math.round(L)}}),console.log("Resizing image:",{from:{width:V,height:D},to:{width:Math.round(z),height:Math.round(L)}}))}let I={compress:C.quality,format:C.format==="png"?R.SaveFormat?.PNG:R.SaveFormat?.JPEG};console.log("Applying compression with options:",I);let P=await R.manipulateAsync(M,A,I);console.log("Image compression completed:",{originalUri:M,compressedUri:P.uri,finalDimensions:{width:P.width,height:P.height}});let B=Date.now(),j=C.format==="png"?"png":"jpg",v=`compressed_image_${B}.${j}`;return{uri:P.uri,width:P.width,height:P.height,fileName:v}}catch(R){console.error("Error compressing image:",R);let C=R instanceof Error?R.message:"Unknown error";throw new Error(`Failed to compress image: ${C}`)}},Yo=(M,S)=>M>3e3||S>3e3?{maxWidth:1920,maxHeight:1920,quality:.7,format:"jpeg"}:M>1920||S>1920?{maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"}:{quality:.9,format:"jpeg"};var ka=[{id:"photo",label:"Photo",icon:Pa,color:"#3B82F6"},{id:"camera",label:"Camera",icon:va,color:"#6B7280"},{id:"location",label:"Location",icon:Aa,color:"#10B981"},{id:"contact",label:"Contact",icon:za,color:"#6B7280"},{id:"document",label:"Document",icon:Ba,color:"#3B82F6"},{id:"poll",label:"Poll",icon:Va,color:"#F59E0B"},{id:"event",label:"Event",icon:Da,color:"#EF4444"}],So=M=>{let S=Ia(null),R=Le(async()=>{console.log("Photo selection initiated");try{let v;try{v=await import("expo-image-picker")}catch(z){console.log("expo-image-picker not available:",z),Q.alert("Feature Not Available","Photo selection requires expo-image-picker to be installed. Please install expo-image-picker to use this feature.",[{text:"OK"}]);return}console.log("Requesting photo library permissions...");let{status:V}=await v.requestMediaLibraryPermissionsAsync();if(console.log("Photo library permission status:",V),V!=="granted"){Q.alert("Permission needed","Please grant photo library access to select images.");return}console.log("Waiting for UI to stabilize..."),await new Promise(z=>setTimeout(()=>z(void 0),300)),console.log("Launching image picker...");let D=await v.launchImageLibraryAsync({mediaTypes:"images",allowsEditing:!0,aspect:[4,3],quality:.8,allowsMultipleSelection:!1});if(console.log("Image picker result:",D),!D.canceled&&D.assets&&D.assets.length>0){let z=D.assets[0];console.log("Photo selected successfully:",z.uri);try{console.log("Starting image compression...");let L=Yo(z.width||1920,z.height||1920),k=await $o(z.uri,L);console.log("Image compression completed:",k),M?.({type:"image",data:{...k,originalFileSize:z.fileSize}})}catch(L){console.error("Image compression failed:",L),Q.alert("Compression Error","Failed to compress image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:z.uri,width:z.width,height:z.height,fileSize:z.fileSize,fileName:z.fileName||"image.jpg"}})}}else console.log("Photo selection was canceled by user")}catch(v){console.error("Error in photo selection process:",v),Q.alert("Photo Selection Error","Failed to open photo library. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),C=Le(async()=>{console.log("Camera capture initiated");try{let v;try{v=await import("expo-image-picker")}catch(z){console.log("expo-image-picker not available:",z),Q.alert("Feature Not Available","Camera capture requires expo-image-picker to be installed. Please install expo-image-picker to use this feature.",[{text:"OK"}]);return}console.log("Requesting camera permissions...");let{status:V}=await v.requestCameraPermissionsAsync();if(console.log("Camera permission status:",V),V!=="granted"){Q.alert("Permission needed","Please grant camera access to take photos.");return}console.log("Waiting for UI to stabilize..."),await new Promise(z=>setTimeout(()=>z(void 0),300)),console.log("Launching camera...");let D=await v.launchCameraAsync({allowsEditing:!0,aspect:[4,3],quality:.8,mediaTypes:"images"});if(console.log("Camera result:",D),!D.canceled&&D.assets&&D.assets.length>0){let z=D.assets[0];console.log("Photo captured successfully:",z.uri);try{console.log("Starting camera image compression...");let L=Yo(z.width||1920,z.height||1920),k=await $o(z.uri,L);console.log("Camera image compression completed:",k),M?.({type:"image",data:{...k,originalFileSize:z.fileSize}})}catch(L){console.error("Camera image compression failed:",L),Q.alert("Compression Error","Failed to compress captured image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:z.uri,width:z.width,height:z.height,fileSize:z.fileSize,fileName:z.fileName||"camera_photo.jpg"}})}}else console.log("Camera capture was canceled by user")}catch(v){console.error("Error in camera capture process:",v),Q.alert("Camera Error","Failed to open camera. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),T=Le(async()=>{console.log("Location sharing initiated");try{let v;try{v=await import("expo-location")}catch(k){console.log("expo-location not available:",k),Q.alert("Feature Not Available","Location sharing requires expo-location to be installed. Please install expo-location to use this feature.",[{text:"OK"}]);return}console.log("Requesting location permissions...");let{status:V}=await v.requestForegroundPermissionsAsync();if(console.log("Location permission status:",V),V!=="granted"){Q.alert("Permission needed","Please grant location access to share your location.");return}console.log("Getting current location...");let D=await v.getCurrentPositionAsync({accuracy:v.Accuracy.High});console.log("Getting address from coordinates...");let z=await v.reverseGeocodeAsync({latitude:D.coords.latitude,longitude:D.coords.longitude}),L={coordinates:{latitude:D.coords.latitude,longitude:D.coords.longitude},address:z[0]||null,timestamp:D.timestamp};console.log("Location shared successfully:",L.coordinates),M?.({type:"location",data:L})}catch(v){console.error("Error in location sharing process:",v),Q.alert("Location Error","Failed to get your location. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),A=Le(async()=>{try{let v;try{v=await import("expo-contacts")}catch(D){console.log("expo-contacts not available:",D),Q.alert("Feature Not Available","Contact sharing requires expo-contacts to be installed. Please install expo-contacts to use this feature.",[{text:"OK"}]);return}let{status:V}=await v.requestPermissionsAsync();if(V!=="granted"){Q.alert("Permission needed","Please grant contacts access to share contacts.");return}Q.alert("Contact Sharing","Contact selection feature is coming soon! This would open a contact picker.",[{text:"OK",onPress:()=>console.log("Contact sharing acknowledged")}])}catch(v){console.error("Error accessing contacts:",v),Q.alert("Error","Failed to access contacts. Please try again.")}finally{S.current?.hide()}},[]),I=Le(async()=>{console.log("Document selection initiated");try{let v;try{v=await import("expo-document-picker")}catch(D){console.log("expo-document-picker not available:",D),Q.alert("Feature Not Available","Document selection requires expo-document-picker to be installed. Please install expo-document-picker to use this feature.",[{text:"OK"}]);return}console.log("Waiting for UI to stabilize..."),await new Promise(D=>setTimeout(()=>D(void 0),300)),console.log("Launching document picker...");let V=await v.getDocumentAsync({type:"*/*",copyToCacheDirectory:!0,multiple:!1});if(console.log("Document picker result:",V),!V.canceled&&V.assets&&V.assets.length>0){let D=V.assets[0];console.log("Document selected successfully:",D.name),M?.({type:"document",data:{uri:D.uri,name:D.name,size:D.size,mimeType:D.mimeType}})}else console.log("Document selection was canceled by user")}catch(v){console.error("Error in document selection process:",v),Q.alert("Document Selection Error","Failed to open document picker. Please try again.",[{text:"OK"}])}},[M]),P=Le(()=>{Q.alert("Create Poll","Poll creation feature is coming soon! This would open a poll creation interface.",[{text:"OK",onPress:()=>console.log("Poll creation acknowledged")}])},[]),B=Le(()=>{Q.alert("Create Event","Event creation feature is coming soon! This would open an event creation interface.",[{text:"OK",onPress:()=>console.log("Event creation acknowledged")}])},[]),j=Le(async v=>{console.log(`Selected attachment option: ${v}`);try{switch(v){case"photo":await R();break;case"camera":await C();break;case"location":await T();break;case"contact":await A();break;case"document":await I();break;case"poll":P();break;case"event":B();break;default:console.warn(`Unknown attachment option: ${v}`)}}catch(V){console.error(`Error handling ${v}:`,V),Q.alert("Error",`Failed to handle ${v}. Please try again.`)}},[R,C,T,A,I,P,B]);return{menuRef:S,handleOptionSelect:j,options:ka}};import Ee,{useRef as La,useCallback as pe,createContext as Ea,useContext as md}from"react";var kt=(M={})=>{let{initialValue:S="",initialHeight:R=50,onValueChange:C,onHeightChange:T,onSend:A,onAttachmentSend:I,onReplyCancel:P,onFocus:B,onBlur:j,maxHeight:v=100,minHeight:V=50,maxLength:D=1e3,placeholder:z="Type a message..."}=M,L=La(null),[k,O]=Ee.useState(S),[H,F]=Ee.useState(R),[N,E]=Ee.useState(!1),[J,ie]=Ee.useState(null),[Y,X]=Ee.useState([]),le=Ee.useMemo(()=>({value:k,height:H,isFocused:N,replyToMessage:J,attachments:Y}),[k,H,N,J,Y]),me=pe(oe=>{O(oe),C?.(oe)},[C]),ne=pe(oe=>{let de=Math.max(V,Math.min(v,oe));F(de),T?.(de)},[V,v,T]),Z=pe(()=>{E(!0),B?.()},[B]),W=pe(()=>{E(!1),j?.()},[j]),ce=pe(oe=>{let{height:de}=oe.nativeEvent.contentSize,St=Math.max(V,Math.min(v,de+16));ne(St)},[V,v,ne]),ye=pe(()=>{A&&(k||Y.length>0)&&(A(k,Y,J),O(S),X([]),ie(null),F(R))},[A,k,Y,J,S,R]),he=pe(oe=>{I?(I(oe,k),k&&O(S)):X(de=>[...de,{...oe,id:Date.now().toString()}])},[I,k,S]),re=pe(oe=>{X(de=>[...de,oe])},[]),ge=pe(oe=>{X(de=>de.filter(St=>St.id!==oe))},[]),xe=pe(()=>{X([])},[]),ee=pe(()=>{ie(null),P?.()},[P]),Te=pe(()=>{L.current?.focus()},[]),vo=Ee.useMemo(()=>({setValue:me,setHeight:ne,setFocus:E,setReplyToMessage:ie,addAttachment:re,removeAttachment:ge,clearAttachments:xe,sendMessage:ye,cancelReply:ee,focusInput:Te,handleAttachmentSelected:he,handleContentSizeChange:ce,handleFocus:Z,handleBlur:W}),[me,ne,E,ie,re,ge,xe,ye,ee,Te,he,ce,Z,W]),Po=Ee.useMemo(()=>({textInputRef:L}),[]);return{state:le,actions:vo,refs:Po}},pd=Ea(null);var we=ja(({value:M,onChangeText:S,onSend:R,onFocus:C,height:T,onContentSizeChange:A,replyToMessage:I,onCancelReply:P,onAttachmentSend:B},j)=>{let v=q(),V=Oa(null);Ha(j,()=>({focus:()=>{V.current?.focus()}}));let{state:D,actions:z}=kt({initialValue:M,initialHeight:T,onValueChange:S,onHeightChange:A,onSend:R,onAttachmentSend:B,onReplyCancel:P,onFocus:C});To.useEffect(()=>{M!==D.value&&z.setValue(M)},[M,D.value,z]),To.useEffect(()=>{T!==D.height&&z.setHeight(T)},[T,D.height,z]),To.useEffect(()=>{I!==D.replyToMessage&&z.setReplyToMessage(I||null)},[I,D.replyToMessage,z]),To.useEffect(()=>{if(I&&V.current){let O=setTimeout(()=>{V.current?.focus()},100);return()=>clearTimeout(O)}},[I]);let L=Fa(O=>{if(console.log("Attachment selected:",O),B)B(O,M.trim()||void 0),M.trim()&&S("");else switch(O.type){case"image":console.log("Image attachment ready to send:",{uri:O.data.uri,dimensions:{width:O.data.width,height:O.data.height},fileName:O.data.fileName});break;case"document":console.log("Document attachment ready to send:",{name:O.data.name,size:O.data.size});break;case"location":console.log("Location attachment ready to send:",O.data.coordinates);break;case"contact":console.log("Contact attachment ready to send:",O.data);break;default:console.log("Other attachment ready to send:",O)}},[B,M,S]),k=So(L);return<>
|
|
378
|
+
{I&&P&&<Vt replyToMessage={I}onCancel={P}/>}
|
|
379
|
+
<Go style={{borderTopWidth:1,borderTopColor:v.colors.borderLight,backgroundColor:v.colors.background}}>
|
|
380
|
+
<Go style={{flexDirection:"row",alignItems:"center",backgroundColor:v.colors.background,paddingHorizontal:v.spacing.lg,paddingVertical:v.spacing.sm,minHeight:T}}>
|
|
381
|
+
<Ks style={{marginRight:v.spacing.md}}onPress={()=>k.menuRef.current?.show()}>
|
|
382
|
+
<Wa size={24}color={v.colors.textSecondary}/>
|
|
383
|
+
</Ks>
|
|
384
384
|
|
|
385
|
-
<
|
|
386
|
-
<
|
|
387
|
-
</
|
|
385
|
+
<Go style={{flex:1,flexDirection:"row",alignItems:"center",borderRadius:v.borderRadius.full,backgroundColor:v.colors.surfaceSecondary,paddingHorizontal:v.spacing.lg,paddingVertical:6}}>
|
|
386
|
+
<Na ref={V}style={{flex:1,fontSize:v.typography.fontSize.base,maxHeight:70,minHeight:18,paddingTop:qs.OS==="ios"?6:3,paddingBottom:qs.OS==="ios"?6:3,color:v.colors.text}}value={M}onChangeText={S}placeholder='Type a message...'placeholderTextColor={v.colors.textMuted}multiline maxLength={1e3}onFocus={C}onContentSizeChange={z.handleContentSizeChange}returnKeyType='default'textAlignVertical='center'/>
|
|
387
|
+
</Go>
|
|
388
388
|
|
|
389
|
-
<
|
|
390
|
-
{M.trim()?<
|
|
391
|
-
</
|
|
392
|
-
</
|
|
393
|
-
</
|
|
389
|
+
<Ks onPress={R}style={{marginLeft:v.spacing.md,height:40,width:40,alignItems:"center",justifyContent:"center",borderRadius:v.borderRadius.full,backgroundColor:M.trim()?v.colors.primary:v.colors.gray[300]}}disabled={!M.trim()}>
|
|
390
|
+
{M.trim()?<Ua size={18}color='white'/>:<Ka size={18}color='white'/>}
|
|
391
|
+
</Ks>
|
|
392
|
+
</Go>
|
|
393
|
+
</Go>
|
|
394
394
|
|
|
395
|
-
<
|
|
396
|
-
</>});we.displayName="MessageInput";import{View as
|
|
395
|
+
<We ref={k.menuRef}onOptionSelect={k.handleOptionSelect}options={k.options}/>
|
|
396
|
+
</>});we.displayName="MessageInput";import{View as Id,TextInput as Pd,TouchableOpacity as Ad,Platform as zd}from"react-native";import{Plus as Vd,Send as Dd,Mic as Ld}from"lucide-react-native";import Si,{forwardRef as Ti}from"react";import Xa,{createContext as Qa,useContext as Za,useMemo as ei}from"react";import{useMemo as $a,useCallback as Ya}from"react";function Lt(M,S={}){let{initialNumToRender:R=20,maxToRenderPerBatch:C=10,windowSize:T=10}=S,A=$a(()=>Vs(M).reverse(),[M]),I=Ya(P=>P.listItemType==="date-separator"?P.id:P.id.toString(),[]);return{messageItems:A,keyExtractor:I,flatListProps:{initialNumToRender:R,maxToRenderPerBatch:C,windowSize:T,inverted:!0,showsVerticalScrollIndicator:!1,keyboardShouldPersistTaps:"handled",removeClippedSubviews:!1,scrollEventThrottle:16}}}import{useState as Ga,useCallback as Ue,useRef as $s}from"react";function _o(M={}){let{scrollThreshold:S=50,autoScrollToBottom:R=!0}=M,C=$s(null),[T,A]=Ga({isNearBottom:!0,isNearTop:!1,showScrollToBottomButton:!1}),I=$s(0),P=Ue(L=>{let{contentOffset:k,contentSize:O,layoutMeasurement:H}=L.nativeEvent,F=k.y,N=Math.abs(F)<S,E=Math.abs(F)>O.height-H.height-S;A({isNearBottom:N,isNearTop:E,showScrollToBottomButton:!N})},[S]),B=Ue(L=>{let k=L>I.current;return I.current=L,k},[]),j=Ue(()=>{},[]),v=Ue((L=!0)=>{C.current&&C.current.scrollToOffset({offset:0,animated:L})},[]),V=Ue((L,k=!0)=>{C.current&&C.current.scrollToOffset({offset:L,animated:k})},[]),D=Ue((L,k=!0)=>{C.current&&C.current.scrollToIndex({index:L,animated:k})},[]),z=Ue(L=>{B(L)&&R&&C.current&&setTimeout(()=>{v()},100)},[B,R,v]);return{flatListRef:C,scrollState:T,handleScroll:P,handleContentSizeChange:j,handleNewMessages:z,scrollToEnd:v,scrollToOffset:V,scrollToIndex:D}}import{useState as _a,useCallback as Jo}from"react";function Et(M={}){let{enableMessageActions:S=!0}=M,[R,C]=_a({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0}),T=Jo((P,B)=>{S&&C({actionSheetVisible:!0,selectedMessage:P,messagePosition:B})},[S]),A=Jo(()=>{C({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0})},[]),I=Jo((P,B)=>{if(!R.selectedMessage)return;let{selectedMessage:j}=R;switch(P){case"reply":B?.onReply?.(j);break;case"copy":if(B?.onCopy)B.onCopy(j);else{let v=j.type==="image"&&j.imageData?j.text||"Image message":j.text;import("./clipboard-O4FPD4J6.mjs").then(({copyToClipboard:V})=>{V(v)}).catch(()=>{console.log("Clipboard functionality not available")})}break;case"delete":B?.onDelete?.(j.id);break;default:B?.onCustomAction?.(P,j);break}A()},[R.selectedMessage,A]);return{actionState:R,handleMessageLongPress:T,handleActionSheetClose:A,handleActionPress:I}}import{useState as Ys,useCallback as jt}from"react";function Ot(M={}){let{enableReactionDetails:S=!0}=M,[R,C]=Ys({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),[T,A]=Ys(null),I=jt(V=>{S&&V.reactions&&V.reactions.length>0&&(A(V),C({isReactionDetailsVisible:!0,selectedReactions:V.reactions,selectedMessageText:V.text}))},[S]),P=jt(()=>{C({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),A(null)},[]),B=jt((V,D)=>{T&&D?.(T.id,V),P()},[T,P]),j=jt((V,D)=>{T&&D?.(T.id,V),P()},[T,P]),v=jt((V,D)=>{T&&D?.(T.id,V)},[T]);return{reactionState:R,selectedMessage:T,handleReactionPress:I,handleReactionDetailsClose:P,handleAddReaction:B,handleRemoveReaction:j,handleEmojiReact:v}}import{useState as Ja,useCallback as Gs}from"react";function Xo(){let[M,S]=Ja({replyToMessage:null}),R=Gs(T=>{S({replyToMessage:T})},[]),C=Gs(()=>{S({replyToMessage:null})},[]);return{replyState:M,setReplyToMessage:R,clearReply:C}}var _s=Qa(null);function Ct(){let M=Za(_s);if(!M)throw new Error("useMessageListContext must be used within MessageListProvider");return M}function Ht({children:M,messages:S,config:R={},...C}){let T=Lt(S,R),A=_o(R),I=Et(R),P=Ot(R),B=Xo();Xa.useEffect(()=>{A.handleNewMessages(S.length)},[S.length,A.handleNewMessages]);let j=ei(()=>({messageList:T,scroll:A,actions:I,reactions:P,reply:B,config:R,callbacks:C}),[T,A,I,P,B,R,C]);return<_s.Provider value={j}>
|
|
397
397
|
{M}
|
|
398
|
-
</
|
|
399
|
-
<
|
|
400
|
-
<
|
|
401
|
-
<
|
|
402
|
-
<
|
|
403
|
-
<
|
|
404
|
-
<
|
|
405
|
-
</
|
|
406
|
-
</
|
|
398
|
+
</_s.Provider>}import{useCallback as wo}from"react";import{View as Mi,StyleSheet as Ci,FlatList as Ri}from"react-native";var je={Provider:Ht,Container:({children:M,style:S})=><Mi style={[Js.container,S]}>{M}</Mi>,Messages:({renderMessage:M,style:S})=>{let{messageList:R,scroll:C,actions:T,reactions:A,callbacks:I}=Ct(),P=wo(({item:j,index:v})=>M&&j.listItemType!=="date-separator"?M({message:j,index:v})||null:j.listItemType==="date-separator"?<Ro date={j.date}displayDate={j.displayDate}/>:<Xt message={j}onLongPress={T.handleMessageLongPress}onReactionPress={A.handleReactionPress}onReactionRemove={I.onReactionRemove}/>,[T.handleMessageLongPress,A.handleReactionPress,I.onReactionRemove,M]),B=wo(j=>{C.handleScroll(j);let{isNearBottom:v,isNearTop:V}=C.scrollState;I.onScrollPositionChange?.(v,V),v&&I.onScrollToBottom?.(),V&&I.onScrollToTop?.()},[C.handleScroll,C.scrollState,I]);return<Ri ref={C.flatListRef}data={R.messageItems}renderItem={P}keyExtractor={R.keyExtractor}contentContainerStyle={[Js.contentContainer,S]}onContentSizeChange={C.handleContentSizeChange}onScroll={B}{...R.flatListProps}/>},TypingIndicator:({isVisible:M})=>M?<Mt isVisible={M}/>:null,ScrollButton:({visible:M,isReplyActive:S,onPress:R})=>{let{scroll:C}=Ct();return<Co visible={M??C.scrollState.showScrollToBottomButton}onPress={R??C.scrollToEnd}isReplyActive={S}/>},ActionSheet:()=>{let{actions:M,reactions:S,reply:R,callbacks:C,config:T}=Ct(),A=wo(P=>{M.handleActionPress(P,{onReply:B=>{R.setReplyToMessage(B),C.onReplyMessage?.(B)},onDelete:C.onMessageDelete,onCustomAction:C.onActionPress})},[M.handleActionPress,R.setReplyToMessage,C]),I=wo(P=>{console.log("\u{1F525} MessageListCompound - handleEmojiReact called with emoji:",P);let B=M.actionState.selectedMessage;console.log("\u{1F525} MessageListCompound - selectedMessage:",B?.id,"callbacks.onReactionAdd exists:",!!C.onReactionAdd),B&&C.onReactionAdd?(console.log("\u{1F525} MessageListCompound - Calling onReactionAdd for message:",B.id,"emoji:",P),C.onReactionAdd(B.id,P)):console.log("\u{1F525} MessageListCompound - NOT calling onReactionAdd. selectedMessage:",!!B,"callback exists:",!!C.onReactionAdd)},[M.actionState.selectedMessage,C.onReactionAdd]);return T.enableMessageActions?<Qt visible={M.actionState.actionSheetVisible}onClose={M.handleActionSheetClose}isMyMessage={M.actionState.selectedMessage?.isMe||!1}selectedMessage={M.actionState.selectedMessage||void 0}messagePosition={M.actionState.messagePosition}onActionPress={A}onEmojiReact={I}/>:null},ReactionDetails:()=>{let{reactions:M,callbacks:S,config:R}=Ct();return R.enableReactionDetails?<Zt visible={M.reactionState.isReactionDetailsVisible}onClose={M.handleReactionDetailsClose}reactions={M.reactionState.selectedReactions}messageText={M.reactionState.selectedMessageText}onRemoveReaction={C=>M.handleRemoveReaction(C,S.onReactionRemove)}/>:null}},Js=Ci.create({container:{flex:1},contentContainer:{paddingVertical:16}});var Ie=Ti(({messages:M,isTyping:S,showScrollToBottom:R=!1,isReplyActive:C=!1,...T},A)=>{let I={scrollThreshold:T.scrollThreshold,autoScrollToBottom:T.autoScrollToBottom,enableMessageActions:T.enableMessageActions,enableReactionDetails:T.enableReactionDetails},P={onScrollToBottom:T.onScrollToBottom,onScrollToTop:T.onScrollToTop,onScrollPositionChange:T.onScrollPositionChange,onReactionAdd:T.onReactionAdd,onReactionRemove:T.onReactionRemove,onMessageDelete:T.onMessageDelete,onReplyMessage:T.onReplyMessage,onActionPress:T.onActionPress};return Si.useImperativeHandle(A,()=>({scrollToEnd:(B=!0)=>{},scrollToOffset:(B,j=!0)=>{},scrollToIndex:(B,j=!0)=>{}}),[]),<Ht messages={M}config={I}{...P}>
|
|
399
|
+
<je.Container>
|
|
400
|
+
<je.Messages/>
|
|
401
|
+
<je.TypingIndicator isVisible={S}/>
|
|
402
|
+
<je.ScrollButton visible={R?void 0:!1}isReplyActive={C}/>
|
|
403
|
+
<je.ActionSheet/>
|
|
404
|
+
<je.ReactionDetails/>
|
|
405
|
+
</je.Container>
|
|
406
|
+
</Ht>});Ie.displayName="MessageList";import wi from"react";function ae(M){let S=wi.forwardRef((C,T)=>(qe(),<M{...C}ref={T}/>)),R=M.displayName||M.name||"Component";return S.displayName=`RequireAuth(${R})`,S}function be(M){return(...S)=>(qe(),M(...S))}import{FlatList as Bi}from"react-native";import{View as Nt,Text as Io,TouchableOpacity as Pi}from"react-native";import{View as Qo,Text as Ii}from"react-native";var vi=({avatar:M,isOnline:S=!1,size:R="medium"})=>{let C=q(),T=()=>{switch(R){case"small":return{width:32,height:32};case"large":return{width:64,height:64};default:return{width:48,height:48}}},A=()=>{switch(R){case"small":return C.typography.fontSize.sm;case"large":return C.typography.fontSize.xxl;default:return C.typography.fontSize.lg}},I=()=>{switch(R){case"small":return{width:12,height:12};case"large":return{width:24,height:24};default:return{width:16,height:16}}},P=T(),B=I();return<Qo style={{position:"relative"}}>
|
|
407
407
|
{}
|
|
408
|
-
<
|
|
409
|
-
<
|
|
408
|
+
<Qo style={[P,{borderRadius:C.borderRadius.full,backgroundColor:C.colors.gray[200],alignItems:"center",justifyContent:"center"}]}>
|
|
409
|
+
<Ii style={{fontSize:A(),color:C.colors.text}}>
|
|
410
410
|
{M}
|
|
411
|
-
</
|
|
412
|
-
</
|
|
411
|
+
</Ii>
|
|
412
|
+
</Qo>
|
|
413
413
|
|
|
414
414
|
{}
|
|
415
|
-
{S&&<
|
|
416
|
-
</
|
|
417
|
-
<
|
|
418
|
-
|
|
419
|
-
</
|
|
415
|
+
{S&&<Qo style={[B,{position:"absolute",bottom:-2,right:-2,backgroundColor:C.colors.online,borderRadius:C.borderRadius.full,borderWidth:2,borderColor:C.colors.background}]}/>}
|
|
416
|
+
</Qo>},Ft=vi;var Ai=({item:M,onPress:S})=>{let R=q(),C=M.unreadCount&&M.unreadCount>0;return<Pi style={{flexDirection:"row",alignItems:"center",paddingHorizontal:R.spacing.lg,paddingVertical:R.spacing.md,borderBottomWidth:1,borderBottomColor:R.colors.borderLight,backgroundColor:C?R.colors.unread:R.colors.background}}onPress={()=>S(M)}>
|
|
417
|
+
<Nt style={{marginRight:R.spacing.md}}>
|
|
418
|
+
<Ft avatar={M.avatar}isOnline={M.isOnline}size="medium"/>
|
|
419
|
+
</Nt>
|
|
420
420
|
|
|
421
|
-
<
|
|
421
|
+
<Nt style={{flex:1,marginRight:R.spacing.md}}>
|
|
422
422
|
{}
|
|
423
|
-
<
|
|
424
|
-
<
|
|
423
|
+
<Nt style={{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:R.spacing.xs}}>
|
|
424
|
+
<Io style={{fontSize:R.typography.fontSize.base,flex:1,fontWeight:C?R.typography.fontWeight.bold:R.typography.fontWeight.semibold,color:R.colors.text}}>
|
|
425
425
|
{M.name}
|
|
426
|
-
</
|
|
427
|
-
<
|
|
426
|
+
</Io>
|
|
427
|
+
<Io style={{fontSize:R.typography.fontSize.sm,marginLeft:R.spacing.sm,color:C?R.colors.gray[700]:R.colors.textSecondary,fontWeight:C?R.typography.fontWeight.medium:R.typography.fontWeight.normal}}>
|
|
428
428
|
{M.time}
|
|
429
|
-
</
|
|
430
|
-
</
|
|
429
|
+
</Io>
|
|
430
|
+
</Nt>
|
|
431
431
|
|
|
432
432
|
{}
|
|
433
|
-
<
|
|
434
|
-
<
|
|
433
|
+
<Nt style={{flexDirection:"row",alignItems:"center"}}>
|
|
434
|
+
<Io style={{fontSize:R.typography.fontSize.sm,flex:1,color:C?R.colors.gray[800]:R.colors.textSecondary,fontWeight:C?R.typography.fontWeight.medium:R.typography.fontWeight.normal}}numberOfLines={1}>
|
|
435
435
|
{M.message}
|
|
436
|
-
</
|
|
437
|
-
{M.unreadCount&&<
|
|
438
|
-
<
|
|
436
|
+
</Io>
|
|
437
|
+
{M.unreadCount&&<Nt style={{width:20,height:20,backgroundColor:R.colors.primary,borderRadius:R.borderRadius.full,alignItems:"center",justifyContent:"center",marginLeft:R.spacing.sm}}>
|
|
438
|
+
<Io style={{fontSize:R.typography.fontSize.xs,color:"white",fontWeight:R.typography.fontWeight.bold}}>
|
|
439
439
|
{M.unreadCount}
|
|
440
|
-
</
|
|
441
|
-
</
|
|
442
|
-
</
|
|
443
|
-
</
|
|
444
|
-
</
|
|
445
|
-
<
|
|
440
|
+
</Io>
|
|
441
|
+
</Nt>}
|
|
442
|
+
</Nt>
|
|
443
|
+
</Nt>
|
|
444
|
+
</Pi>},Wt=Ai;var Vi=({chats:M,onChatPress:S})=>{let R=({item:C})=><Wt item={C}onPress={S}/>;return<Bi data={M}renderItem={R}keyExtractor={C=>C.id}showsVerticalScrollIndicator={!1}style={{flex:1}}/>},Zo=Vi;import{View as Di,Text as Li}from"react-native";var Ei=({title:M})=>{let S=q();return<Di style={{backgroundColor:S.colors.background,paddingHorizontal:S.spacing.lg,paddingVertical:S.spacing.lg,borderBottomWidth:1,borderBottomColor:S.colors.borderLight}}>
|
|
445
|
+
<Li style={{fontSize:S.typography.fontSize.xxl,fontWeight:S.typography.fontWeight.bold,color:S.colors.text}}>
|
|
446
446
|
{M}
|
|
447
|
-
</
|
|
448
|
-
</
|
|
449
|
-
<
|
|
450
|
-
<
|
|
451
|
-
<
|
|
452
|
-
</
|
|
447
|
+
</Li>
|
|
448
|
+
</Di>},es=Ei;import{View as Ms,TextInput as Oi,TouchableOpacity as Hi}from"react-native";import{Search as Fi,X as Ni}from"lucide-react-native";var Wi=({value:M,onChangeText:S,onClear:R,placeholder:C="Search chats..."})=>{let T=q();return<Ms style={{backgroundColor:T.colors.background,paddingHorizontal:T.spacing.lg,paddingVertical:T.spacing.md,borderBottomWidth:1,borderBottomColor:T.colors.borderLight}}>
|
|
449
|
+
<Ms style={{position:"relative"}}>
|
|
450
|
+
<Ms style={{position:"absolute",left:T.spacing.md,top:"50%",transform:[{translateY:-10}],zIndex:10}}>
|
|
451
|
+
<Fi size={20}color={T.colors.textMuted}/>
|
|
452
|
+
</Ms>
|
|
453
453
|
|
|
454
|
-
<
|
|
454
|
+
<Oi value={M}onChangeText={S}placeholder={C}placeholderTextColor={T.colors.textMuted}style={{backgroundColor:T.colors.surfaceSecondary,borderRadius:T.borderRadius.full,paddingLeft:48,paddingRight:40,paddingVertical:T.spacing.md,color:T.colors.text,fontSize:T.typography.fontSize.base}}autoCapitalize="none"autoCorrect={!1}clearButtonMode="never"/>
|
|
455
455
|
|
|
456
|
-
{M.length>0&&<
|
|
457
|
-
<
|
|
458
|
-
</
|
|
459
|
-
</
|
|
460
|
-
</
|
|
456
|
+
{M.length>0&&<Hi onPress={R}style={{position:"absolute",right:T.spacing.md,top:"50%",transform:[{translateY:-10}]}}hitSlop={{top:10,bottom:10,left:10,right:10}}>
|
|
457
|
+
<Ni size={20}color={T.colors.textMuted}/>
|
|
458
|
+
</Hi>}
|
|
459
|
+
</Ms>
|
|
460
|
+
</Ms>},Cs=Wi;import{useState as Ui,useCallback as Rt}from"react";import Rs from"dayjs";var Ke=Rs(),Xs=Ke.subtract(1,"day"),Qs=Ke.subtract(2,"day"),Zs=Ke.subtract(3,"day"),Ki=[{id:1,text:"Hi! How are you?",isMe:!1,timestamp:Zs.hour(10).minute(30).toISOString(),senderName:"Anna"},{id:2,text:"Hey! Great, thanks! And you?",isMe:!0,timestamp:Zs.hour(10).minute(31).toISOString(),reactions:[{emoji:"\u2764\uFE0F",count:1,users:["anna"]}]},{id:3,text:"Good too! What are we doing tonight?",isMe:!1,timestamp:Qs.hour(14).minute(20).toISOString(),senderName:"Anna"},{id:4,text:"Maybe we could go to the movies?",isMe:!0,timestamp:Qs.hour(14).minute(25).toISOString(),reactions:[{emoji:"\u{1F44D}",count:2,users:["anna","me"]},{emoji:"\u{1F3AC}",count:1,users:["anna"]}]},{id:5,text:"Good idea! I'll check the showtimes",isMe:!1,timestamp:Xs.hour(9).minute(15).toISOString(),senderName:"Anna"},{id:6,text:"Great! What movies are you interested in?",isMe:!0,timestamp:Xs.hour(9).minute(20).toISOString()},{id:7,text:"Maybe something action or comedy?",isMe:!1,timestamp:Ke.hour(8).minute(30).toISOString(),senderName:"Anna",reactions:[{emoji:"\u{1F602}",count:1,users:["me"]},{emoji:"\u{1F3AD}",count:1,users:["anna"]}]},{id:8,text:"Sounds great! I'll check what's playing",isMe:!0,timestamp:Ke.hour(8).minute(35).toISOString()},{id:9,text:"Perfect! What time should we meet?",isMe:!1,timestamp:Ke.hour(9).minute(10).toISOString(),senderName:"Anna",replyTo:{id:8,text:"Sounds great! I'll check what's playing",senderName:void 0,isMe:!0,type:"text"}},{id:10,text:"How about 7:00 PM? The show is at 8:00 PM",isMe:!0,timestamp:Ke.hour(9).minute(15).toISOString(),reactions:[{emoji:"\u{1F44D}",count:1,users:["anna"]},{emoji:"\u23F0",count:1,users:["me"]}]}],Ss=M=>{let S=Ki.map(v=>v.isMe?v:{...v,senderName:M||v.senderName}),[R,C]=Ui(S),T=Rt((v,V)=>{if(console.log("sendMessage called with text:",v,"and replyTo:",V),!v.trim())return;let D={id:Date.now(),text:v.trim(),isMe:!0,timestamp:Rs().toISOString(),status:"sent",replyTo:V};C(z=>[...z,D]),setTimeout(()=>{C(z=>z.map(L=>L.id===D.id?{...L,status:"delivered"}:L))},1e3),setTimeout(()=>{C(z=>z.map(L=>L.id===D.id?{...L,status:"read"}:L))},3e3)},[]),A=Rt((v,V,D)=>{let z={id:Date.now(),text:V||"",isMe:!0,timestamp:Rs().toISOString(),status:"sent",type:"image",imageData:v,replyTo:D};C(L=>[...L,z]),setTimeout(()=>{C(L=>L.map(k=>k.id===z.id?{...k,status:"delivered"}:k))},1e3),setTimeout(()=>{C(L=>L.map(k=>k.id===z.id?{...k,status:"read"}:k))},3e3)},[]),I=Rt((v,V)=>{C(D=>D.map(z=>z.id===v?{...z,status:V}:z))},[]),P=Rt((v,V)=>{C(D=>D.map(z=>{if(z.id===v){let L=z.reactions||[],k=L.findIndex(O=>O.emoji===V);if(k>=0){let O=[...L];return O[k]={...O[k],count:O[k].count+1,users:[...O[k].users,"me"]},{...z,reactions:O}}else{let O={emoji:V,count:1,users:["me"]};return{...z,reactions:[...L,O]}}}return z}))},[]),B=Rt((v,V)=>{console.log("removeReaction 1212121 called with messageId:",v,"and emoji:",V),C(D=>D.map(z=>{if(z.id===v){let L=z.reactions||[],k=L.findIndex(O=>O.emoji===V);if(k>=0){let O=L[k];if(O.count>1){let H=[...L];return H[k]={...O,count:O.count-1,users:O.users.filter(F=>F!=="me")},{...z,reactions:H}}else return{...z,reactions:L.filter(H=>H.emoji!==V)}}}return z}))},[]),j=Rt(v=>{console.log("deleteMessage called with messageId:",v),C(V=>{let D=V.map(z=>z.id===v?{...z,deleted:!0}:z);return console.log("Message marked as deleted:",v),D})},[]);return{messages:R,sendMessage:T,sendImageMessage:A,updateMessageStatus:I,addReaction:P,deleteMessage:j,removeReaction:B}};import{useState as en,useCallback as Se}from"react";var Ts=(M={})=>{qe();let[S,R]=en(M.initialMessages||[]),[C,T]=en(!1),A=Se((L,k)=>{let O={id:Date.now(),text:L,isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:k?{id:k.id,text:k.text,senderName:k.senderName,isMe:k.isMe}:void 0};R(H=>[O,...H])},[]),I=Se(L=>{R(k=>[L,...k])},[]),P=Se((L,k)=>{R(O=>O.map(H=>H.id===L?{...H,...k}:H))},[]),B=Se(L=>{R(k=>k.filter(O=>O.id!==L))},[]),j=Se((L,k)=>{R(O=>O.map(H=>{if(H.id!==L)return H;let F=H.reactions||[];if(F.find(E=>E.emoji===k))return{...H,reactions:F.map(E=>E.emoji===k?{...E,count:E.count+1,users:[...E.users,"current-user"]}:E)};{let E={emoji:k,count:1,users:["current-user"]};return{...H,reactions:[...F,E]}}}))},[]),v=Se((L,k)=>{R(O=>O.map(H=>{if(H.id!==L)return H;let F=H.reactions||[],N=F.find(E=>E.emoji===k);return N?N.count<=1?{...H,reactions:F.filter(E=>E.emoji!==k)}:{...H,reactions:F.map(E=>E.emoji===k?{...E,count:E.count-1,users:E.users.filter(J=>J!=="current-user")}:E)}:H}))},[]),V=Se(L=>{T(L)},[]),D=Se(()=>{R(M.initialMessages||[]),T(!1)},[M.initialMessages]),z=Se(L=>S.find(k=>k.id===L),[S]);return{messages:S,isTyping:C,sendMessage:A,addReaction:j,removeReaction:v,setMessages:R,addMessage:I,updateMessage:P,deleteMessage:B,setTyping:V,resetChat:D,getMessageById:z}};import{useState as wm,useCallback as Im,useRef as vm,useEffect as Pm}from"react";var Xm=ae(Do),Qm=ae(Ao),Zm=be(Tt),tg=ae(Ie),og=ae(we),ng=ae(Kt),ag=ae(Mt),lg=ae(Zo),cg=ae(Wt),dg=ae(es),ug=ae(Cs),pg=ae(Ft),hg=ae(We),xg=ae(Bs),bg=be(q),Tg=be(Ts),wg=be(Ss),Ig=be(Lt),vg=be(Et),Pg=be(Ot),Ag=be(It),Bg=be(kt);export{hg as AttachmentMenu,Xm as Chat,pg as ChatAvatar,dg as ChatHeader,cg as ChatItem,lg as ChatList,ug as ChatListSearchBar,Qm as ChatProvider,ng as ChatScreenHeader,og as MessageInput,tg as MessageList,xg as ThemeProvider,ag as TypingIndicator,vt as defaultTheme,tn as getAuthState,on as getProjectId,nn as initChat,sn as isInitialized,Ag as useAttachments,Zm as useChatConfig,wg as useChatMessages,Tg as useChatSDK,vg as useMessageActions,Bg as useMessageInput,Ig as useMessageList,Pg as useMessageReactions,bg as useTheme};
|