@usechat/react-native 1.0.1 → 1.0.2
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.d.mts +303 -608
- package/dist/index.d.ts +303 -608
- package/dist/index.js +282 -300
- package/dist/index.mjs +302 -320
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,155 +1,145 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
"use strict";var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Please call initChat() with a valid project ID.
|
|
18
|
-
</Re.Text>
|
|
19
|
-
</Re.View>;if(C){let P=C;return<P/>}try{return Wo(),<M{...A}/>}catch(P){return<Re.View style={We.container}>
|
|
20
|
-
<Re.Text style={We.errorTitle}>Authorization Error</Re.Text>
|
|
21
|
-
<Re.Text style={We.errorText}>
|
|
22
|
-
{P instanceof Error?P.message:"Unknown error"}
|
|
23
|
-
</Re.Text>
|
|
24
|
-
</Re.View>}}}var We=Re.StyleSheet.create({container:{flex:1,justifyContent:"center",alignItems:"center",padding:20,backgroundColor:"#f5f5f5"},text:{marginTop:10,fontSize:16,color:"#666",textAlign:"center"},errorTitle:{fontSize:18,fontWeight:"bold",color:"#d32f2f",marginBottom:10,textAlign:"center"},errorText:{fontSize:14,color:"#666",textAlign:"center",marginBottom:15,lineHeight:20},helpText:{fontSize:12,color:"#999",textAlign:"center",lineHeight:16,fontFamily:"monospace"}});function qs(M={}){let{licenseKey:S,attribution:C=!0,environment:R="production"}=M;return R==="development"?{isValid:!0,type:"free",requiresAttribution:!0,message:"Development mode - remember to include attribution in production"}:S?S.startsWith("usechat_")&&S.length>20?{isValid:!0,type:"commercial",requiresAttribution:!1,message:"Commercial license active"}:{isValid:!1,type:"invalid",requiresAttribution:!0,message:"Invalid license key format"}:C?{isValid:!0,type:"free",requiresAttribution:!0,message:"Free license - attribution required"}:{isValid:!1,type:"invalid",requiresAttribution:!0,message:"Commercial license required or attribution must be enabled"}}function $s(){return"Powered by UseChat SDK - https://usechat.dev"}function Ys(M){if(__DEV__){let S=M.isValid?"\u2705":"\u274C";console.log(`${S} UseChat SDK License: ${M.message}`),M.requiresAttribution&&console.log("\u{1F4DD} Attribution required:",$s()),M.isValid||console.warn("\u26A0\uFE0F License violation detected. Please visit https://usechat.dev/licensing for more information.")}}function ls(M){let S=qs(M);return __DEV__&&Ys(S),S}var ds=(0,Io.createContext)(null),_s=({children:M,config:S={}})=>{let C=ls(S),R={keyboardBehavior:"padding",keyboardVerticalOffset:60,enableReactionDetails:!0,enableMessageActions:!0,enableScrollToBottom:!0,enableTypingIndicator:!0,...S};return<ds.Provider value={{config:R}}>
|
|
25
|
-
<vo.KeyboardProvider>
|
|
26
|
-
<vo.KeyboardAvoidingView behavior={R.keyboardBehavior}style={[Gs.keyboardContainer]}keyboardVerticalOffset={R.keyboardVerticalOffset}>
|
|
2
|
+
"use strict";var _s=Object.create;var So=Object.defineProperty;var Js=Object.getOwnPropertyDescriptor;var Xs=Object.getOwnPropertyNames;var Qs=Object.getPrototypeOf,Zs=Object.prototype.hasOwnProperty;var er=(M,T)=>()=>(M&&(T=M(M=0)),T);var ps=(M,T)=>{for(var C in T)So(M,C,{get:T[C],enumerable:!0})},hs=(M,T,C,R)=>{if(T&&typeof T=="object"||typeof T=="function")for(let S of Xs(T))!Zs.call(M,S)&&S!==C&&So(M,S,{get:()=>T[S],enumerable:!(R=Js(T,S))||R.enumerable});return M};var Q=(M,T,C)=>(C=M!=null?_s(Qs(M)):{},hs(T||!M||!M.__esModule?So(C,"default",{value:M,enumerable:!0}):C,M)),tr=M=>hs(So({},"__esModule",{value:!0}),M);var Fs={};ps(Fs,{copyToClipboard:()=>zr,isClipboardAvailable:()=>Br});var zr,Br,Ns=er(()=>{"use strict";zr=async M=>{console.log("copyToClipboard called with text:",M);try{try{let{setStringAsync:T}=await import("expo-clipboard");console.log("expo-clipboard imported successfully"),console.log("setStringAsync function:",T),await T(M),console.log("Text copied to clipboard successfully")}catch(T){throw console.error("Failed to import expo-clipboard:",T),new Error("expo-clipboard not available")}try{let T=await import("react-native-toast-message"),C=T.default||T;console.log("react-native-toast-message imported successfully"),C.show({type:"success",text1:"Copied to clipboard",text2:"Message copied successfully",position:"bottom",visibilityTime:2e3}),console.log("Toast shown successfully")}catch(T){console.log("Toast not available, but message copied to clipboard"),console.error("Toast import error:",T)}return!0}catch(T){console.error("Failed to copy to clipboard:",T);try{let C=await import("react-native-toast-message");(C.default||C).show({type:"error",text1:"Copy failed",text2:"Failed to copy message to clipboard",position:"bottom",visibilityTime:2e3})}catch(C){console.error("Copy failed: expo-clipboard not available"),console.error("Toast import error:",C)}return!1}},Br=async()=>{try{return await import("expo-clipboard"),!0}catch{return!1}}});var an={};ps(an,{AttachmentMenu:()=>Jr,Chat:()=>Or,ChatAvatar:()=>_r,ChatHeader:()=>Yr,ChatItem:()=>$r,ChatList:()=>qr,ChatListSearchBar:()=>Gr,ChatProvider:()=>Hr,ChatScreenHeader:()=>Ur,MessageInput:()=>Wr,MessageList:()=>Nr,ThemeProvider:()=>Xr,TypingIndicator:()=>Kr,defaultTheme:()=>It,getAuthState:()=>ys,getProjectId:()=>xs,initChat:()=>Ms,isInitialized:()=>bs,useAttachments:()=>rn,useChatConfig:()=>Fr,useChatMessages:()=>en,useChatSDK:()=>Zr,useMessageActions:()=>on,useMessageInput:()=>nn,useMessageList:()=>tn,useMessageReactions:()=>sn,useTheme:()=>Qr});module.exports=tr(an);var at={isInitialized:!1,projectId:null,error:null},fs=M=>{at={isInitialized:!0,projectId:M,error:null}},Ct=M=>{at={isInitialized:!1,projectId:null,error:M}};var ys=()=>({...at}),wt=()=>{if(at.error)throw new Error(`UseChat SDK initialization failed: ${at.error}
|
|
3
|
+
|
|
4
|
+
Please call initChat() with a valid project ID before using any UseChat components or hooks.
|
|
5
|
+
|
|
6
|
+
Example:
|
|
7
|
+
import { initChat } from '@usechat/react-native';
|
|
8
|
+
await initChat({ projectId: 'your-project-id' });`);if(!at.isInitialized)throw new Error(`UseChat SDK is not initialized.
|
|
9
|
+
|
|
10
|
+
Please call initChat() with a valid project ID before using any UseChat components or hooks.
|
|
11
|
+
|
|
12
|
+
Example:
|
|
13
|
+
import { initChat } from '@usechat/react-native';
|
|
14
|
+
await initChat({ projectId: 'your-project-id' });`)},xs=()=>(wt(),at.projectId),bs=()=>at.isInitialized&&!at.error;var Ms=async M=>{let{projectId:T,apiUrl:C="http://localhost:3000/api/chat/init",debug:R=!1}=M;if(!T){let S="Project ID is required";throw Ct(S),new Error(S)}try{R&&console.log(`[UseChat SDK] Validating projectId: ${T}`);let S=await fetch(C,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:T})});if(R&&console.log(`[Chat SDK] Response status: ${S.status}, ok: ${S.ok}`),!S.ok){let P=`HTTP ${S.status}: ${S.statusText}`;try{let z=await S.json();P=z.error||z.message||P}catch{try{let j=await S.text();j&&(P=`Server error: ${j}`)}catch{P=`Failed to initialize chat (HTTP ${S.status})`}}throw Ct(P),new Error(P)}let A;try{let P=await S.text();if(R&&console.log(`[Chat SDK] Response text: ${P}`),!P){let z="Server returned empty response";throw Ct(z),new Error(z)}A=JSON.parse(P)}catch(P){R&&console.error("[Chat SDK] JSON parse error:",P);let z="Server returned invalid JSON response";throw Ct(z),new Error(z)}if(!A||typeof A!="object"){let P="Server returned invalid response format";throw Ct(P),new Error(P)}let I=A;return R&&console.log(`[UseChat SDK] Successfully initialized with projectId: ${T}`),fs(T),I}catch(S){R&&console.error("[Chat SDK] Init error:",S);let A;throw S instanceof TypeError&&S.message.includes("fetch")?A="Network error: Unable to connect to server. Please check your internet connection.":S instanceof Error?A=S.message:A="Failed to initialize chat: Unknown error",A.includes("Project ID is required")||Ct(A),new Error(A)}};var ve=Q(require("react")),st=require("react-native");var wo=require("react"),Cs=require("react-native"),Io=require("react-native-keyboard-controller"),Rs=(0,wo.createContext)(null),or=({children:M,config:T={}})=>{let C={keyboardBehavior:"padding",keyboardVerticalOffset:60,enableReactionDetails:!0,enableMessageActions:!0,enableScrollToBottom:!0,enableTypingIndicator:!0,...T};return<Rs.Provider value={{config:C}}>
|
|
15
|
+
<Io.KeyboardProvider>
|
|
16
|
+
<Io.KeyboardAvoidingView behavior={C.keyboardBehavior}style={[sr.keyboardContainer]}keyboardVerticalOffset={C.keyboardVerticalOffset}>
|
|
27
17
|
{}
|
|
28
18
|
{M}
|
|
29
|
-
</
|
|
30
|
-
</
|
|
31
|
-
</
|
|
32
|
-
{N||<
|
|
19
|
+
</Io.KeyboardAvoidingView>
|
|
20
|
+
</Io.KeyboardProvider>
|
|
21
|
+
</Rs.Provider>},Xo=or,qt=()=>{let M=(0,wo.useContext)(Rs);if(!M)throw new Error("useChatConfig must be used within a ChatProvider");return M.config},sr=Cs.StyleSheet.create({container:{flex:1},keyboardContainer:{flex:1,overflow:"hidden"}});var ot=require("react"),$t=(M={})=>{let{uploader:T,maxAttachments:C=10,maxFileSize:R=10*1024*1024,allowedTypes:S=["image/*","application/pdf","text/*"],onAttachmentAdd:A,onAttachmentRemove:I,onAttachmentUpload:P}=M,[z,j]=(0,ot.useState)([]),[v,B]=(0,ot.useState)(!1),[V,D]=(0,ot.useState)(0),k=(0,ot.useCallback)(N=>{if(z.length>=C){console.warn(`Maximum ${C} attachments allowed`);return}if(N.data?.size&&N.data.size>R){console.warn(`File size exceeds ${R/(1024*1024)}MB limit`);return}if(N.data?.type&&!S.some(je=>je.endsWith("/*")?N.data.type.startsWith(je.slice(0,-1)):N.data.type===je)){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(te=>[...te,E]),A&&A(E)},[z.length,C,R,S,A]),L=(0,ot.useCallback)(N=>{j(E=>E.filter(te=>te.id!==N)),I&&I(N)},[I]),O=(0,ot.useCallback)(()=>{j([])},[]),H=(0,ot.useCallback)(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 te={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};k(te)}catch(E){console.error("Error opening picker:",E)}},[k]),F=(0,ot.useCallback)(async()=>{if(!T)return console.warn("No uploader provided, skipping upload"),z;if(z.length===0)return[];B(!0),D(0);try{let N=z.map(async(J,Me)=>{try{j(Ce=>Ce.map(U=>U.id===J.id?{...U,uploadStatus:"uploading",uploadProgress:0}:U));let Oe=setInterval(()=>{j(Ce=>Ce.map(U=>U.id===J.id?{...U,uploadProgress:Math.min((U.uploadProgress??0)+10,90)}:U))},100),qe=await T.upload(J.data);clearInterval(Oe);let Ve={...J,uploadStatus:"completed",uploadProgress:100,data:{...J.data,url:qe.url,metadata:qe.metadata}};return j(Ce=>Ce.map(U=>U.id===J.id?Ve:U)),Ve}catch(Oe){return console.error(`Error uploading attachment ${J.id}:`,Oe),j(qe=>qe.map(Ve=>Ve.id===J.id?{...Ve,uploadStatus:"failed",uploadProgress:0}:Ve)),{...J,uploadStatus:"failed",uploadProgress:0}}}),E=await Promise.all(N),je=E.filter(J=>J.uploadStatus==="completed").length/E.length*100;return D(je),P&&P(E),E}catch(N){return console.error("Error uploading attachments:",N),z}finally{B(!1)}},[z,T,P]);return{attachments:z,openPicker:H,addAttachment:k,removeAttachment:L,clearAttachments:O,uploadAttachments:F,isUploading:v,uploadProgress:V}};var Ye=require("react"),Ts=(M={})=>{let{onSend:T,onFocus:C,initialValue:R="",maxLength:S=1e3}=M,[A,I]=(0,Ye.useState)(R),[P,z]=(0,Ye.useState)(40),[j,v]=(0,Ye.useState)(!1),B=(0,Ye.useCallback)(F=>{F.length<=S&&I(F)},[S]),V=(0,Ye.useCallback)(F=>{if(!A.trim()&&(!F||F.length===0))return;let N=A.trim();T&&T(N,F),I(""),z(40)},[A,T]),D=(0,Ye.useCallback)(()=>{v(!0),C&&C()},[C]),k=(0,Ye.useCallback)(()=>{v(!1)},[]),L=(0,Ye.useCallback)(F=>{z(Math.max(40,Math.min(F,120)))},[]),O=(0,Ye.useCallback)(()=>{I(""),z(40)},[]),H=(0,Ye.useCallback)(F=>{I(F)},[]);return{message:A,composerHeight:P,isFocused:j,handleTextChange:B,handleSend:V,handleFocus:D,handleBlur:k,handleContentSizeChange:L,clearMessage:O,setMessage:H}};var rr=({messages:M,components:T={},renderProps:C={},onMessageSend:R,onReactionAdd:S,onReactionRemove:A,onMessageDelete:I,onActionPress:P,attachmentUploader:z,maxAttachments:j=10,maxFileSize:v=10*1024*1024,allowedFileTypes:B=["image/*","application/pdf","text/*"],enableReactionDetails:V,enableMessageActions:D=!0,enableScrollToBottom:k,enableTypingIndicator:L,isTyping:O=!1,typingUserName:H,isLoading:F=!1,loadingComponent:N})=>{let E=qt(),[te,je]=(0,ve.useState)(!1),J=T.MessageList||mt,Me=T.MessageInput||ut,Oe=V??E.enableReactionDetails??!0,qe=D??E.enableMessageActions??!0,Ve=k??E.enableScrollToBottom??!0,Ce=L??E.enableTypingIndicator??!0,[U,He]=(0,ve.useState)(null),et=(0,ve.useRef)(null),[_e,De]=(0,ve.useState)(M||[]),$e=(0,ve.useRef)((M||[]).length+1);ve.default.useEffect(()=>{M&&(De(M),$e.current=M.length+1)},[M]),ve.default.useEffect(()=>{if(U&&et.current){let K=setTimeout(()=>{et.current?.focus()},150);return()=>clearTimeout(K)}},[U]);let tt=$t({uploader:z,maxAttachments:j,maxFileSize:v,allowedTypes:B}),Se=Ts({onSend:(K,G)=>{if(U){let X={id:U.id,text:U.text,senderName:U.senderName,senderId:U.senderId,isMe:U.isMe,timestamp:U.timestamp,type:U.type==="image"?"image":"text",imageData:U.imageData};if(G&&G.length>0){let q=G[0],Ie={id:$e.current++,text:K.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:X,attachments:G,type:q.type==="image"?"image":"text",...q.type==="image"&&q.data&&{imageData:{uri:q.data.uri||"",width:q.data.width||300,height:q.data.height||200,fileName:q.fileName||"image.jpg",fileSize:q.fileSize||0}}};De(Je=>[...Je,Ie]),R&&R(Ie)}else{let q={id:$e.current++,text:K.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:X};De(Ie=>[...Ie,q]),R&&R(q)}He(null)}else if(G&&G.length>0){let X=G[0],q={id:$e.current++,text:K.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",attachments:G,type:X.type==="image"?"image":"text",...X.type==="image"&&X.data&&{imageData:{uri:X.data.uri||"",width:X.data.width||300,height:X.data.height||200,fileName:X.fileName||"image.jpg",fileSize:X.fileSize||0}}};De(Ie=>[...Ie,q]),R&&R(q)}else{let X={id:$e.current++,text:K.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent"};De(q=>[...q,X]),R&&R(X)}tt.clearAttachments()},onFocus:()=>{}}),dt=(0,ve.useCallback)((K,G)=>{console.log("\u{1F525} Chat - addReaction called with messageId:",K,"and emoji:",G),De(X=>X.map(q=>q.id===K?q.reactions?.find(Je=>Je.emoji===G)?{...q,reactions:q.reactions?.map(Je=>Je.emoji===G?{...Je,count:Je.count+1,users:[...Je.users,"currentUser"]}:Je)}:{...q,reactions:[...q.reactions||[],{emoji:G,count:1,users:["currentUser"]}]}:q)),S&&S(K,G)},[S]),_o=(0,ve.useCallback)((K,G)=>{De(X=>X.map(q=>q.id===K?{...q,reactions:q.reactions?.map(Ie=>Ie.emoji===G?{...Ie,count:Math.max(0,Ie.count-1),users:Ie.users.filter(Je=>Je!=="currentUser")}:Ie).filter(Ie=>Ie.count>0)}:q)),A&&A(K,G)},[A]),Jo=(0,ve.useCallback)(K=>{De(G=>G.map(X=>X.id===K?{...X,deleted:!0,text:"",reactions:void 0}:X)),I&&I(K)},[I]),Pe=(0,ve.useCallback)(()=>{He(null)},[]),Fe=(0,ve.useCallback)(K=>{He(K),setTimeout(()=>{et.current?.focus()},100)},[]),Kt=(0,ve.useCallback)(K=>{if(te)return;let{layout:G}=K.nativeEvent;G.height<=0||je(!0)},[te]);if(F)return<st.View style={Rt.container}>
|
|
22
|
+
{N||<st.View style={Rt.loadingContainer}>
|
|
33
23
|
{}
|
|
34
|
-
</
|
|
35
|
-
</
|
|
36
|
-
<
|
|
37
|
-
<
|
|
38
|
-
</
|
|
39
|
-
</
|
|
40
|
-
<
|
|
41
|
-
<J messages={
|
|
24
|
+
</st.View>}
|
|
25
|
+
</st.View>;if(!te)return<st.View style={Rt.container}>
|
|
26
|
+
<st.View style={Rt.chatContainer}onLayout={Kt}>
|
|
27
|
+
<st.View style={Rt.loadingContainer}>{N}</st.View>
|
|
28
|
+
</st.View>
|
|
29
|
+
</st.View>;let gs=C.renderInput;return<st.View style={Rt.container}>
|
|
30
|
+
<st.View style={Rt.fill}>
|
|
31
|
+
<J messages={_e}isTyping={Ce?O:!1}typingUserName={H}showScrollToBottom={Ve}isReplyActive={!!U}enableMessageActions={qe}enableReactionDetails={Oe}onReactionAdd={dt}onReactionRemove={_o}onMessageDelete={Jo}onReplyMessage={Fe}onActionPress={(K,G)=>{K==="reply"?Fe(G):P?.(K,G)}}/>
|
|
42
32
|
|
|
43
|
-
{
|
|
33
|
+
{gs?gs({value:Se.message,onChangeText:Se.handleTextChange,onSend:Se.handleSend,onFocus:Se.handleFocus,height:Se.composerHeight,onContentSizeChange:Se.handleContentSizeChange,replyToMessage:U,onCancelReply:Pe,attachments:tt.attachments,onAttachmentAdd:tt.addAttachment,onAttachmentRemove:tt.removeAttachment,onAttachmentUpload:tt.uploadAttachments}):<Me ref={et}value={Se.message}onChangeText={Se.handleTextChange}onSend={Se.handleSend}onFocus={Se.handleFocus}height={Se.composerHeight}onContentSizeChange={Se.handleContentSizeChange}replyToMessage={U}onCancelReply={Pe}onAttachmentSend={(K,G)=>{let X=K.type==="image",q={id:$e.current++,text:G?.trim()||"",isMe:!0,timestamp:new Date().toISOString(),status:"sent",type:X?"image":"text",...X&&K.data&&{imageData:{uri:K.data.uri||"",width:K.data.width||300,height:K.data.height||200,fileName:K.data.fileName||K.data.name||"image.jpg",fileSize:K.data.fileSize||K.data.size||0}}};De(Ie=>[...Ie,q]),R&&R(q),Se.handleTextChange("")}}/>}
|
|
44
34
|
|
|
45
35
|
{}
|
|
46
|
-
</
|
|
36
|
+
</st.View>
|
|
47
37
|
|
|
48
38
|
{}
|
|
49
|
-
</
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
<
|
|
53
|
-
</
|
|
39
|
+
</st.View>},Rt=st.StyleSheet.create({container:{flex:1},chatContainer:{flex:1,overflow:"hidden"},fill:{flex:1},loadingContainer:{flex:1,justifyContent:"center",alignItems:"center"}}),Qo=rr;var we=require("react-native"),gt=require("lucide-react-native");var ws=require("react");var vo=require("react");var It={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 Zo=(0,vo.createContext)(It),nr=(M,T)=>({colors:{...M.colors,...T.colors},spacing:{...M.spacing,...T.spacing},borderRadius:{...M.borderRadius,...T.borderRadius},typography:{...M.typography,...T.typography}}),Ss=({children:M,theme:T})=>{let C=(0,vo.useMemo)(()=>T?nr(It,T):It,[T]);return<Zo.Provider value={C}>{M}</Zo.Provider>};var $=()=>{let M=(0,ws.useContext)(Zo);if(!M)throw new Error("useTheme must be used within a ThemeProvider");return M};var ar=({name:M="George Alan",isOnline:T=!0,onBack:C=()=>{},onVideoCall:R=()=>{},onVoiceCall:S=()=>{},onInfo:A=()=>{}})=>{let I=$();return<we.View 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
|
+
<we.View style={{flex:1,flexDirection:"row",alignItems:"center"}}>
|
|
41
|
+
<we.TouchableOpacity onPress={C}style={{marginRight:I.spacing.md}}>
|
|
42
|
+
<gt.ArrowLeft size={24}color={I.colors.gray[700]}/>
|
|
43
|
+
</we.TouchableOpacity>
|
|
54
44
|
|
|
55
|
-
<
|
|
45
|
+
<we.View style={{flex:1,flexDirection:"row",alignItems:"center"}}>
|
|
56
46
|
{}
|
|
57
|
-
<
|
|
58
|
-
<
|
|
59
|
-
<
|
|
47
|
+
<we.View style={{position:"relative",marginRight:I.spacing.md}}>
|
|
48
|
+
<we.View style={{height:40,width:40,alignItems:"center",justifyContent:"center",borderRadius:I.borderRadius.full,backgroundColor:I.colors.gray[200]}}>
|
|
49
|
+
<we.Text style={{fontSize:I.typography.fontSize.base,color:I.colors.text}}>
|
|
60
50
|
👤
|
|
61
|
-
</
|
|
62
|
-
</
|
|
63
|
-
{
|
|
64
|
-
</
|
|
51
|
+
</we.Text>
|
|
52
|
+
</we.View>
|
|
53
|
+
{T&&<we.View 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
|
+
</we.View>
|
|
65
55
|
|
|
66
|
-
<
|
|
67
|
-
<
|
|
56
|
+
<we.View style={{flex:1}}>
|
|
57
|
+
<we.Text style={{fontSize:I.typography.fontSize.lg,fontWeight:I.typography.fontWeight.semibold,color:I.colors.text}}>
|
|
68
58
|
{M}
|
|
69
|
-
</
|
|
70
|
-
<
|
|
71
|
-
{
|
|
72
|
-
</
|
|
73
|
-
</
|
|
74
|
-
</
|
|
75
|
-
</
|
|
59
|
+
</we.Text>
|
|
60
|
+
<we.Text style={{fontSize:I.typography.fontSize.sm,color:I.colors.textSecondary}}>
|
|
61
|
+
{T?"Online":"Offline"}
|
|
62
|
+
</we.Text>
|
|
63
|
+
</we.View>
|
|
64
|
+
</we.View>
|
|
65
|
+
</we.View>
|
|
76
66
|
|
|
77
|
-
<
|
|
67
|
+
<we.View style={{flexDirection:"row",alignItems:"center",gap:I.spacing.lg}}>
|
|
78
68
|
{}
|
|
79
|
-
{R&&<
|
|
80
|
-
<
|
|
81
|
-
</
|
|
82
|
-
{
|
|
83
|
-
<
|
|
84
|
-
</
|
|
85
|
-
{A&&<
|
|
86
|
-
<
|
|
87
|
-
</
|
|
88
|
-
</
|
|
89
|
-
</
|
|
90
|
-
<
|
|
69
|
+
{R&&<we.TouchableOpacity onPress={R}>
|
|
70
|
+
<gt.Video size={24}color={I.colors.gray[700]}/>
|
|
71
|
+
</we.TouchableOpacity>}
|
|
72
|
+
{S&&<we.TouchableOpacity onPress={S}>
|
|
73
|
+
<gt.Phone size={24}color={I.colors.gray[700]}/>
|
|
74
|
+
</we.TouchableOpacity>}
|
|
75
|
+
{A&&<we.TouchableOpacity onPress={A}>
|
|
76
|
+
<gt.Info size={24}color={I.colors.gray[700]}/>
|
|
77
|
+
</we.TouchableOpacity>}
|
|
78
|
+
</we.View>
|
|
79
|
+
</we.View>},Po=ar;var Bs=require("react"),Te=require("react-native");var vt=Q(require("dayjs")),Is=Q(require("dayjs/plugin/isToday")),vs=Q(require("dayjs/plugin/isYesterday"));vt.default.extend(Is.default);vt.default.extend(vs.default);var ir=M=>{let T=(0,vt.default)(M);return T.isToday()?"Today":T.isYesterday()?"Yesterday":T.format("ddd D MMMM")},lr=M=>(0,vt.default)(M).format("YYYY-MM-DD"),Ps=M=>{if(M.length===0)return[];let T=[],C=null;return M.forEach((R,S)=>{let A=lr(R.timestamp);if(C!==A){let P=ir(R.timestamp),z={id:`date-${A}`,listItemType:"date-separator",date:A,displayDate:P};T.push(z),C=A}let I={...R,listItemType:"message"};T.push(I)}),T},es=M=>(0,vt.default)(M).format("HH:mm");var Xe=require("react-native");var cr=({replyTo:M,isMyMessage:T})=>{let C=$(),R=(j,v=50)=>j.length<=v?j:j.substring(0,v)+"...",S=T?"rgba(255, 255, 255, 0.3)":C.colors.primary,A=T?"rgba(255, 255, 255, 0.8)":C.colors.primary,I=T?"rgba(255, 255, 255, 0.7)":C.colors.textSecondary,P=T?"rgba(255, 255, 255, 0.1)":C.colors.surfaceSecondary,z=M.type==="image"&&M.imageData;return<Xe.View style={{marginBottom:C.spacing.sm,borderRadius:C.borderRadius.md,padding:C.spacing.sm,backgroundColor:P,borderLeftWidth:4,borderLeftColor:S}}>
|
|
80
|
+
<Xe.Text style={{fontSize:C.typography.fontSize.xs,fontWeight:C.typography.fontWeight.medium,color:A,marginBottom:C.spacing.xs}}>
|
|
91
81
|
{M.isMe?"You":M.senderName||"Sender"}
|
|
92
|
-
</
|
|
82
|
+
</Xe.Text>
|
|
93
83
|
|
|
94
|
-
{
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
<
|
|
84
|
+
{z?<Xe.View style={{flexDirection:"row",alignItems:"center"}}>
|
|
85
|
+
<Xe.Image source={{uri:M.imageData.uri}}style={{width:40,height:40,borderRadius:C.borderRadius.sm,marginRight:C.spacing.sm}}resizeMode="cover"/>
|
|
86
|
+
<Xe.View style={{flex:1}}>
|
|
87
|
+
<Xe.Text style={{fontSize:C.typography.fontSize.xs,color:I,fontStyle:"italic",marginBottom:C.spacing.xs}}>
|
|
98
88
|
📷 Image
|
|
99
|
-
</
|
|
100
|
-
{M.text&&M.text.trim()&&<
|
|
89
|
+
</Xe.Text>
|
|
90
|
+
{M.text&&M.text.trim()&&<Xe.Text style={{fontSize:C.typography.fontSize.sm,color:I,lineHeight:C.typography.lineHeight.tight}}>
|
|
101
91
|
{R(M.text,30)}
|
|
102
|
-
</
|
|
103
|
-
</
|
|
104
|
-
</
|
|
92
|
+
</Xe.Text>}
|
|
93
|
+
</Xe.View>
|
|
94
|
+
</Xe.View>:<Xe.Text style={{fontSize:C.typography.fontSize.sm,color:I,lineHeight:C.typography.lineHeight.tight}}>
|
|
105
95
|
{R(M.text)}
|
|
106
|
-
</
|
|
107
|
-
</
|
|
108
|
-
<
|
|
96
|
+
</Xe.Text>}
|
|
97
|
+
</Xe.View>},Pt=cr;var it=require("react"),Re=require("react-native");var{width:ts,height:As}=Re.Dimensions.get("window"),dr=({imageData:M,isMe:T,onImagePress:C,onLongPress:R})=>{let S=$(),[A,I]=(0,it.useState)(!1),[P,z]=(0,it.useState)(!1),v=(0,it.useCallback)(()=>{let O=ts*.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])(),B=(0,it.useCallback)(()=>{C?C():I(!0)},[C]),V=(0,it.useCallback)(()=>{console.error("Failed to load image:",M.uri),z(!0)},[M.uri]),D=(0,it.useCallback)(()=>{I(!1)},[]),L=(0,it.useCallback)(()=>{if(!M.width||!M.height)return{width:ts,height:As*.8};let O=M.width/M.height,H=ts*.9,F=As*.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?<Re.View style={[pt.errorContainer,{width:v.width,height:v.height,backgroundColor:T?S.colors.messageBubble.sent:S.colors.messageBubble.received,borderRadius:S.borderRadius.lg}]}>
|
|
98
|
+
<Re.Text style={[pt.errorText,{color:T?S.colors.messageBubble.sentText:S.colors.messageBubble.receivedText,fontSize:S.typography.fontSize.sm}]}>
|
|
109
99
|
Failed to load image
|
|
110
|
-
</
|
|
111
|
-
</
|
|
112
|
-
<
|
|
113
|
-
<
|
|
114
|
-
<
|
|
100
|
+
</Re.Text>
|
|
101
|
+
</Re.View>:<>
|
|
102
|
+
<Re.Pressable onPress={B}onLongPress={R}delayLongPress={500}>
|
|
103
|
+
<Re.View style={[pt.imageContainer,{borderRadius:S.borderRadius.lg,overflow:"hidden"}]}>
|
|
104
|
+
<Re.Image source={{uri:M.uri}}style={[pt.image,{width:v.width,height:v.height}]}resizeMode='cover'onError={V}/>
|
|
115
105
|
|
|
116
106
|
{}
|
|
117
|
-
<
|
|
118
|
-
</
|
|
119
|
-
</
|
|
107
|
+
<Re.View style={pt.imageOverlay}/>
|
|
108
|
+
</Re.View>
|
|
109
|
+
</Re.Pressable>
|
|
120
110
|
|
|
121
111
|
{}
|
|
122
|
-
<
|
|
123
|
-
<
|
|
124
|
-
<
|
|
125
|
-
<
|
|
126
|
-
</
|
|
127
|
-
</
|
|
128
|
-
</
|
|
129
|
-
</>},
|
|
130
|
-
<
|
|
131
|
-
<
|
|
132
|
-
<
|
|
133
|
-
<
|
|
112
|
+
<Re.Modal visible={A}transparent animationType='fade'onRequestClose={D}>
|
|
113
|
+
<Re.Pressable style={pt.modalContainer}onPress={D}>
|
|
114
|
+
<Re.View style={pt.modalContent}>
|
|
115
|
+
<Re.Image source={{uri:M.uri}}style={[pt.modalImage,{width:L.width,height:L.height,borderRadius:S.borderRadius.lg}]}resizeMode='contain'/>
|
|
116
|
+
</Re.View>
|
|
117
|
+
</Re.Pressable>
|
|
118
|
+
</Re.Modal>
|
|
119
|
+
</>},pt=Re.StyleSheet.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"}}),Ao=dr;var rt=require("react-native"),zs=require("lucide-react-native");var ur=({isMe:M,timestamp:T,senderName:C})=>{let R=$();return<rt.View style={[At.container,{alignSelf:M?"flex-end":"flex-start",maxWidth:"80%"}]}>
|
|
120
|
+
<rt.View style={[At.messageBubble,{backgroundColor:R.colors.gray[100],borderColor:R.colors.gray[200]}]}>
|
|
121
|
+
<rt.View style={At.content}>
|
|
122
|
+
<zs.Trash2 size={16}color={R.colors.gray[500]}/>
|
|
123
|
+
<rt.Text style={[At.deletedText,{color:R.colors.gray[500]}]}>
|
|
134
124
|
This message was deleted
|
|
135
|
-
</
|
|
136
|
-
</
|
|
137
|
-
</
|
|
138
|
-
<
|
|
139
|
-
<
|
|
140
|
-
{
|
|
141
|
-
</
|
|
142
|
-
</
|
|
143
|
-
</
|
|
144
|
-
<Te.Pressable ref={
|
|
145
|
-
{M.replyTo&&<
|
|
125
|
+
</rt.Text>
|
|
126
|
+
</rt.View>
|
|
127
|
+
</rt.View>
|
|
128
|
+
<rt.View style={[At.metadata,{alignSelf:M?"flex-end":"flex-start"}]}>
|
|
129
|
+
<rt.Text style={[At.timestamp,{color:R.colors.gray[400]}]}>
|
|
130
|
+
{T}
|
|
131
|
+
</rt.Text>
|
|
132
|
+
</rt.View>
|
|
133
|
+
</rt.View>},At=rt.StyleSheet.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}}),Bo=ur;var mr=({message:M,onLongPress:T,onReactionPress:C})=>{let R=$(),S=(0,Bs.useRef)(null),A=()=>{S.current?S.current.measureInWindow((z,j,v,B)=>{let V={x:Math.round(z),y:Math.round(j),width:Math.round(v),height:Math.round(B)};T?.(M,V)}):T?.(M)},I=()=>{M.reactions&&M.reactions.length>0&&C?.(M)},P=M.type==="image"&&M.imageData;return M.deleted?<Bo isMe={M.isMe}timestamp={es(M.timestamp)}senderName={M.senderName}/>:<Te.View style={{marginBottom:R.spacing.md,alignItems:M.isMe?"flex-end":"flex-start",marginHorizontal:R.spacing.sm}}>
|
|
134
|
+
<Te.Pressable ref={S}onLongPress={A}delayLongPress={500}style={{maxWidth:P?"75%":"80%",borderRadius:P?R.borderRadius.lg:R.borderRadius.xl,borderBottomRightRadius:M.isMe?4:P?R.borderRadius.lg:R.borderRadius.xl,borderBottomLeftRadius:M.isMe?P?R.borderRadius.lg:R.borderRadius.xl:4,paddingHorizontal:P?0:R.spacing.lg,paddingVertical:P?0:R.spacing.md,backgroundColor:P?"transparent":M.isMe?R.colors.messageBubble.sent:R.colors.messageBubble.received,overflow:"hidden"}}>
|
|
135
|
+
{M.replyTo&&<Pt replyTo={M.replyTo}isMyMessage={M.isMe}/>}
|
|
146
136
|
|
|
147
|
-
{
|
|
137
|
+
{P?<Ao imageData={M.imageData}isMe={M.isMe}onLongPress={A}/>:<Te.Text style={{fontSize:R.typography.fontSize.base,color:M.isMe?R.colors.messageBubble.sentText:R.colors.messageBubble.receivedText}}>
|
|
148
138
|
{M.text}
|
|
149
139
|
</Te.Text>}
|
|
150
140
|
|
|
151
141
|
{}
|
|
152
|
-
{
|
|
142
|
+
{P&&M.text&&M.text.trim()&&<Te.View style={{paddingHorizontal:R.spacing.lg,paddingVertical:R.spacing.md,backgroundColor:M.isMe?R.colors.messageBubble.sent:R.colors.messageBubble.received,borderRadius:R.borderRadius.lg,marginTop:R.spacing.xs}}>
|
|
153
143
|
<Te.Text style={{fontSize:R.typography.fontSize.base,color:M.isMe?R.colors.messageBubble.sentText:R.colors.messageBubble.receivedText}}>
|
|
154
144
|
{M.text}
|
|
155
145
|
</Te.Text>
|
|
@@ -158,19 +148,19 @@
|
|
|
158
148
|
|
|
159
149
|
{}
|
|
160
150
|
{M.reactions&&M.reactions.length>0&&<Te.TouchableOpacity onPress={I}style={{marginTop:R.spacing.xs,flexDirection:"row",alignItems:"center",backgroundColor:R.colors.background,borderRadius:R.borderRadius.full,justifyContent:M.isMe?"flex-end":"flex-start"}}>
|
|
161
|
-
{M.reactions.map((
|
|
151
|
+
{M.reactions.map((z,j)=><Te.View key={`${z.emoji}-${j}`}style={{flexDirection:"row",alignItems:"center",padding:R.spacing.xs}}>
|
|
162
152
|
<Te.Text style={{fontSize:R.typography.fontSize.sm}}>
|
|
163
|
-
{
|
|
153
|
+
{z.emoji}
|
|
164
154
|
</Te.Text>
|
|
165
|
-
{
|
|
166
|
-
{
|
|
155
|
+
{z.count>1&&<Te.Text style={{fontSize:R.typography.fontSize.xs,color:R.colors.textSecondary,marginLeft:R.spacing.xs,fontWeight:R.typography.fontWeight.medium}}>
|
|
156
|
+
{z.count}
|
|
167
157
|
</Te.Text>}
|
|
168
158
|
</Te.View>)}
|
|
169
159
|
</Te.TouchableOpacity>}
|
|
170
160
|
|
|
171
161
|
<Te.View style={{marginHorizontal:R.spacing.sm,marginTop:R.spacing.xs,flexDirection:"row",alignItems:"center",justifyContent:M.isMe?"flex-end":"flex-start"}}>
|
|
172
162
|
<Te.Text style={{fontSize:R.typography.fontSize.xs,color:R.colors.textSecondary}}>
|
|
173
|
-
{
|
|
163
|
+
{es(M.timestamp)}
|
|
174
164
|
</Te.Text>
|
|
175
165
|
{M.isMe&&M.status&&<Te.View style={{marginLeft:R.spacing.xs}}>
|
|
176
166
|
{M.status==="sent"&&<Te.Text style={{fontSize:R.typography.fontSize.xs,color:R.colors.gray[400]}}>
|
|
@@ -184,19 +174,19 @@
|
|
|
184
174
|
</Te.Text>}
|
|
185
175
|
</Te.View>}
|
|
186
176
|
</Te.View>
|
|
187
|
-
</Te.View>},
|
|
177
|
+
</Te.View>},Vo=mr;var Z=require("react-native"),Vs=require("lucide-react-native");var gr=({replyToMessage:M,onCancel:T})=>{let C=$(),R=(I,P=50)=>I.length<=P?I:I.substring(0,P)+"...",S=!!M.replyTo,A=M.type==="image"&&M.imageData;return<Z.View style={{borderBottomWidth:1,borderBottomColor:C.colors.border,backgroundColor:C.colors.surface,paddingHorizontal:C.spacing.lg,paddingVertical:C.spacing.md}}>
|
|
188
178
|
<Z.View style={{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}>
|
|
189
179
|
<Z.View style={{flex:1,marginRight:C.spacing.md}}>
|
|
190
180
|
<Z.View style={{flexDirection:"row",alignItems:"center",marginBottom:C.spacing.xs}}>
|
|
191
|
-
<Z.View style={{width:4,backgroundColor:C.colors.primary,borderRadius:C.borderRadius.full,marginRight:C.spacing.md,height:
|
|
181
|
+
<Z.View style={{width:4,backgroundColor:C.colors.primary,borderRadius:C.borderRadius.full,marginRight:C.spacing.md,height:S?48:32}}/>
|
|
192
182
|
<Z.View style={{flex:1}}>
|
|
193
183
|
<Z.Text style={{fontSize:C.typography.fontSize.xs,fontWeight:C.typography.fontWeight.medium,color:C.colors.primary,marginBottom:C.spacing.xs}}>
|
|
194
184
|
Replying to {M.isMe?"yourself":M.senderName||"sender"}
|
|
195
|
-
{
|
|
185
|
+
{S&&" (reply thread)"}
|
|
196
186
|
</Z.Text>
|
|
197
187
|
|
|
198
188
|
{}
|
|
199
|
-
{
|
|
189
|
+
{S&&<Z.View style={{marginBottom:C.spacing.sm,padding:C.spacing.sm,backgroundColor:C.colors.surfaceSecondary,borderRadius:C.borderRadius.md,borderLeftWidth:2,borderLeftColor:C.colors.gray[300]}}>
|
|
200
190
|
<Z.Text style={{fontSize:C.typography.fontSize.xs,color:C.colors.textSecondary,marginBottom:C.spacing.xs}}>
|
|
201
191
|
Originally replying to: {M.replyTo.isMe?"yourself":M.replyTo.senderName||"sender"}
|
|
202
192
|
</Z.Text>
|
|
@@ -222,15 +212,15 @@
|
|
|
222
212
|
</Z.View>
|
|
223
213
|
</Z.View>
|
|
224
214
|
|
|
225
|
-
<Z.TouchableOpacity onPress={
|
|
226
|
-
<
|
|
215
|
+
<Z.TouchableOpacity onPress={T}style={{height:32,width:32,alignItems:"center",justifyContent:"center",borderRadius:C.borderRadius.full,backgroundColor:C.colors.gray[200]}}hitSlop={{top:8,bottom:8,left:8,right:8}}>
|
|
216
|
+
<Vs.X size={16}color={C.colors.textSecondary}/>
|
|
227
217
|
</Z.TouchableOpacity>
|
|
228
218
|
</Z.View>
|
|
229
|
-
</Z.View>},
|
|
230
|
-
<W.TouchableOpacity style={
|
|
219
|
+
</Z.View>},Yt=gr;var ze=require("react"),W=require("react-native"),ht=require("lucide-react-native");var Do=require("react"),Ds=Q(require("rn-emoji-keyboard")),pr=({visible:M,onClose:T,onEmojiSelected:C})=>{let[R,S]=(0,Do.useState)(!1);(0,Do.useEffect)(()=>{S(!!M)},[M]);let A=P=>{console.log("Selected emoji:",P),C(P.emoji),S(!1),T()},I=()=>{S(!1),T()};return M?<Ds.default onEmojiSelected={A}open={R}onClose={I}enableSearchBar/>:null},Bt=pr;var Mr=({visible:M,onPress:T,children:C})=>M?<W.View style={Ae.overlay}>
|
|
220
|
+
<W.TouchableOpacity style={Ae.backdrop}onPress={T}activeOpacity={1}/>
|
|
231
221
|
{C}
|
|
232
|
-
</W.View>:null,{width:
|
|
233
|
-
{M.replyTo&&<
|
|
222
|
+
</W.View>:null,{width:Vt,height:os}=W.Dimensions.get("window"),Cr=({message:M,positions:T,messagePosition:C,containerRef:R,containerOffset:S,setContainerOffset:A})=>{let I=$(),P=(0,ze.useRef)(new W.Animated.Value(C.y)).current,z=(0,ze.useRef)(new W.Animated.Value(0)).current,j=(0,ze.useRef)(!1),v=M.type==="image"&&M.imageData;return(0,ze.useEffect)(()=>{j.current=!1,R.current&&R.current.measureInWindow((B,V,D,k)=>{A({x:B,y:V});let L=C.y-V,O=T.messagePreviewTop-V;P.setValue(L),z.setValue(0),requestAnimationFrame(()=>{W.Animated.parallel([W.Animated.timing(P,{toValue:O,duration:250,useNativeDriver:!1}),W.Animated.timing(z,{toValue:1,duration:250,useNativeDriver:!1})]).start(()=>{j.current=!0})})})},[T.messagePreviewTop,C.y,R]),<W.Animated.View style={{position:"absolute",top:P,left:C.x,width:C.width,height:M.replyTo?C.height+10:C.height,zIndex:1e3,opacity:z,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&&<Pt replyTo={M.replyTo}isMyMessage={M.isMe}/>}
|
|
234
224
|
|
|
235
225
|
{v?<W.View>
|
|
236
226
|
<W.Image source={{uri:M.imageData.uri}}style={{width:C.width,height:C.height,borderRadius:I.borderRadius.lg}}resizeMode='cover'/>
|
|
@@ -243,50 +233,50 @@
|
|
|
243
233
|
</W.View>:<W.Text style={{fontSize:I.typography.fontSize.base,color:M.isMe?I.colors.messageBubble.sentText:I.colors.messageBubble.receivedText}}>
|
|
244
234
|
{M.text}
|
|
245
235
|
</W.Text>}
|
|
246
|
-
</W.Animated.View>},
|
|
236
|
+
</W.Animated.View>},Rr=({visible:M,onClose:T,isMyMessage:C,selectedMessage:R,messagePosition:S,onActionPress:A,onEmojiReact:I})=>{let[P,z]=(0,ze.useState)(!1),j=(0,ze.useRef)(null),[v,B]=(0,ze.useState)({x:0,y:0}),V=(0,ze.useRef)(new W.Animated.Value(0)).current,D=(0,ze.useRef)(new W.Animated.Value(0)).current,k=(0,ze.useRef)(!1),L=(0,ze.useRef)(!1),O=Me=>{A(Me),T()},H=Me=>{I?.(Me),T()},F=()=>{z(!0)},N=()=>{z(!1)},E=Me=>{I?.(Me),z(!1),T()},te=["\u2764\uFE0F","\u{1F602}","\u{1F62E}","\u{1F622}","\u{1F621}","\u{1F44D}"],J=(()=>{if(!S)return{emojiBar:{top:os/2-200,left:Vt/2-160},actionMenu:{top:os/2+50,left:Vt/2-100}};let Me=320,Oe=60,qe=200,Ve=160,Ce=20,U=8,He,et,_e,De,$e,tt=os/2,Se=Oe+U+S.height+U+Ve,dt=tt-Se/2;return et=dt,$e=dt+Oe+U,De=dt+Oe+U+S.height+U,He=S.x,_e=S.x,He+Me>Vt-Ce&&(He=Vt-Me-Ce),He<Ce&&(He=Ce),_e+qe>Vt-Ce&&(_e=Vt-qe-Ce),_e<Ce&&(_e=Ce),{emojiBar:{top:et,left:He},actionMenu:{top:De,left:_e},messagePreviewTop:$e,isNearAverageHeight:!0,isNearTop:!0,isEdgeCase:!0}})();return(0,ze.useEffect)(()=>{M&&S&&!L.current&&(V.setValue(0),D.setValue(0),setTimeout(()=>{W.Animated.sequence([W.Animated.timing(V,{toValue:1,duration:200,useNativeDriver:!1}),W.Animated.timing(D,{toValue:1,duration:200,useNativeDriver:!1})]).start(()=>{L.current=!0})},50))},[M,S,V,D]),(0,ze.useEffect)(()=>{M||(k.current=!1,L.current=!1,V.setValue(0),D.setValue(0))},[M,V,D]),M?<>
|
|
247
237
|
{}
|
|
248
|
-
<
|
|
249
|
-
<W.Pressable style={
|
|
250
|
-
</
|
|
238
|
+
<Mr visible={!0}onPress={T}>
|
|
239
|
+
<W.Pressable style={Ae.overlayPressable}onPress={T}/>
|
|
240
|
+
</Mr>
|
|
251
241
|
|
|
252
|
-
<W.View ref={
|
|
242
|
+
<W.View ref={j}style={{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"}}>
|
|
253
243
|
{}
|
|
254
244
|
</W.View>
|
|
255
245
|
|
|
256
246
|
{}
|
|
257
|
-
{
|
|
247
|
+
{S&&R&&<Cr message={R}positions={J}messagePosition={S}containerRef={j}containerOffset={v}setContainerOffset={B}/>}
|
|
258
248
|
|
|
259
249
|
{}
|
|
260
|
-
<W.Animated.View style={[
|
|
261
|
-
<W.ScrollView horizontal showsHorizontalScrollIndicator={!1}contentContainerStyle={
|
|
262
|
-
{te.map((Me,
|
|
263
|
-
<W.Text style={
|
|
250
|
+
<W.Animated.View style={[Ae.emojiBar,{position:"absolute",top:J.emojiBar.top-(v.y||0),left:J.emojiBar.left,opacity:V,pointerEvents:"auto"}]}>
|
|
251
|
+
<W.ScrollView horizontal showsHorizontalScrollIndicator={!1}contentContainerStyle={Ae.emojiContainer}>
|
|
252
|
+
{te.map((Me,Oe)=><W.TouchableOpacity key={Oe}style={Ae.emojiButton}onPress={()=>H(Me)}>
|
|
253
|
+
<W.Text style={Ae.emojiText}>{Me}</W.Text>
|
|
264
254
|
</W.TouchableOpacity>)}
|
|
265
|
-
<W.TouchableOpacity style={
|
|
266
|
-
<
|
|
255
|
+
<W.TouchableOpacity style={Ae.addEmojiButton}onPress={F}>
|
|
256
|
+
<ht.Plus size={20}color='#666'/>
|
|
267
257
|
</W.TouchableOpacity>
|
|
268
258
|
</W.ScrollView>
|
|
269
259
|
</W.Animated.View>
|
|
270
260
|
|
|
271
261
|
{}
|
|
272
|
-
<W.Animated.View style={[
|
|
273
|
-
<W.View style={
|
|
262
|
+
<W.Animated.View style={[Ae.actionMenu,{position:"absolute",top:J.actionMenu.top-(v.y||0)+(R?.replyTo?10:0),left:J.actionMenu.left,opacity:D,pointerEvents:"auto"}]}>
|
|
263
|
+
<W.View style={Ae.actionItems}>
|
|
274
264
|
{}
|
|
275
|
-
<W.TouchableOpacity style={
|
|
276
|
-
<
|
|
277
|
-
<W.Text style={
|
|
265
|
+
<W.TouchableOpacity style={Ae.actionRow}onPress={()=>O("reply")}>
|
|
266
|
+
<ht.Reply size={18}color='#333'/>
|
|
267
|
+
<W.Text style={Ae.actionLabel}>Reply</W.Text>
|
|
278
268
|
</W.TouchableOpacity>
|
|
279
269
|
|
|
280
270
|
{}
|
|
281
|
-
<W.TouchableOpacity style={
|
|
282
|
-
<
|
|
283
|
-
<W.Text style={
|
|
271
|
+
<W.TouchableOpacity style={Ae.actionRow}onPress={()=>O("copy")}>
|
|
272
|
+
<ht.Copy size={18}color='#333'/>
|
|
273
|
+
<W.Text style={Ae.actionLabel}>Copy</W.Text>
|
|
284
274
|
</W.TouchableOpacity>
|
|
285
275
|
|
|
286
276
|
{}
|
|
287
|
-
{C&&<W.TouchableOpacity style={
|
|
288
|
-
<
|
|
289
|
-
<W.Text style={[
|
|
277
|
+
{C&&<W.TouchableOpacity style={Ae.actionRow}onPress={()=>O("delete")}>
|
|
278
|
+
<ht.Trash2 size={18}color='#ff4444'/>
|
|
279
|
+
<W.Text style={[Ae.actionLabel,{color:"#ff4444"}]}>
|
|
290
280
|
Delete
|
|
291
281
|
</W.Text>
|
|
292
282
|
</W.TouchableOpacity>}
|
|
@@ -294,185 +284,177 @@
|
|
|
294
284
|
</W.Animated.View>
|
|
295
285
|
|
|
296
286
|
{}
|
|
297
|
-
<
|
|
298
|
-
</>:null},
|
|
299
|
-
<
|
|
287
|
+
<Bt visible={P}onClose={N}onEmojiSelected={E}/>
|
|
288
|
+
</>:null},Ae=W.StyleSheet.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:{...W.StyleSheet.absoluteFillObject,zIndex:1e3},backdrop:{...W.StyleSheet.absoluteFillObject,backgroundColor:"rgba(0, 0, 0, 0.8)"}}),Lo=Rr;var Dt=require("react"),_=require("react-native"),ks=Q(require("react-native-actions-sheet"));var Tr=({visible:M,onClose:T,reactions:C,messageText:R,onAddReaction:S,onRemoveReaction:A})=>{let I=(0,Dt.useRef)(null),[P,z]=(0,Dt.useState)(!1);(0,Dt.useEffect)(()=>{M?I.current?.show():I.current?.hide()},[M]);let v=(()=>{let H=[];return C.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})(),B=C.reduce((H,F)=>H+F.count,0),V=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})},D=()=>{I.current?.hide(),T(),setTimeout(()=>{z(!0)},300)},k=()=>{z(!1)},L=H=>{console.log("Selected emoji from picker:",H),S?.(H),z(!1),T()},O=()=>{I.current?.hide(),T()};return<>
|
|
289
|
+
<ks.default ref={I}onClose={O}containerStyle={ee.container}headerAlwaysVisible={!0}gestureEnabled={!0}closeOnTouchBackdrop={!0}>
|
|
300
290
|
{}
|
|
301
|
-
<
|
|
302
|
-
<
|
|
303
|
-
<
|
|
304
|
-
<
|
|
305
|
-
</
|
|
306
|
-
</
|
|
291
|
+
<_.View style={ee.header}>
|
|
292
|
+
<_.Text style={ee.title}>{B} reactions</_.Text>
|
|
293
|
+
<_.TouchableOpacity onPress={O}style={ee.closeButton}>
|
|
294
|
+
<_.Text style={ee.closeText}>✕</_.Text>
|
|
295
|
+
</_.TouchableOpacity>
|
|
296
|
+
</_.View>
|
|
307
297
|
|
|
308
298
|
{}
|
|
309
|
-
<
|
|
310
|
-
<
|
|
299
|
+
<_.View style={ee.messagePreview}>
|
|
300
|
+
<_.Text style={ee.messageText}numberOfLines={2}>
|
|
311
301
|
{R}
|
|
312
|
-
</
|
|
313
|
-
</
|
|
302
|
+
</_.Text>
|
|
303
|
+
</_.View>
|
|
314
304
|
|
|
315
305
|
{}
|
|
316
|
-
<
|
|
306
|
+
<_.View style={ee.reactionButtons}>
|
|
317
307
|
{}
|
|
318
308
|
|
|
319
|
-
{C.map((F
|
|
320
|
-
<
|
|
321
|
-
<
|
|
322
|
-
</
|
|
323
|
-
</
|
|
309
|
+
{C.map((H,F)=><_.View key={F}style={ee.reactionButton}>
|
|
310
|
+
<_.Text style={ee.reactionEmoji}>{H.emoji}</_.Text>
|
|
311
|
+
<_.Text style={ee.reactionCount}>{H.count}</_.Text>
|
|
312
|
+
</_.View>)}
|
|
313
|
+
</_.View>
|
|
324
314
|
|
|
325
315
|
{}
|
|
326
|
-
<
|
|
327
|
-
{v.map(
|
|
328
|
-
<
|
|
329
|
-
<
|
|
330
|
-
<
|
|
331
|
-
<
|
|
332
|
-
{
|
|
333
|
-
</
|
|
334
|
-
</
|
|
335
|
-
<
|
|
336
|
-
<
|
|
337
|
-
</
|
|
316
|
+
<_.ScrollView style={ee.userReactionsList}showsVerticalScrollIndicator={!1}>
|
|
317
|
+
{v.map(H=>{let F=H.name==="You",N=F?_.TouchableOpacity:_.View;return<N key={H.id}style={[ee.userReactionItem,F&&ee.tappableUserReactionItem]}onPress={F?()=>V(H):void 0}activeOpacity={F?.7:1}>
|
|
318
|
+
<_.View style={ee.userInfo}>
|
|
319
|
+
<_.Text style={ee.userAvatar}>{H.avatar}</_.Text>
|
|
320
|
+
<_.View style={ee.userDetails}>
|
|
321
|
+
<_.Text style={ee.userName}>{H.name}</_.Text>
|
|
322
|
+
{F&&<_.Text style={ee.removeText}>Tap to remove</_.Text>}
|
|
323
|
+
</_.View>
|
|
324
|
+
</_.View>
|
|
325
|
+
<_.View style={ee.userReactionEmoji}>
|
|
326
|
+
<_.Text style={ee.emojiText}>{H.emoji}</_.Text>
|
|
327
|
+
</_.View>
|
|
338
328
|
</N>})}
|
|
339
|
-
</
|
|
340
|
-
</
|
|
329
|
+
</_.ScrollView>
|
|
330
|
+
</ks.default>
|
|
341
331
|
|
|
342
332
|
{}
|
|
343
|
-
<
|
|
344
|
-
</>},ee=
|
|
345
|
-
<
|
|
333
|
+
<Bt visible={P}onClose={k}onEmojiSelected={L}/>
|
|
334
|
+
</>},ee=_.StyleSheet.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}}),Eo=Tr;var kt=Q(require("react")),Qe=require("react-native"),Ls=Q(require("react-native-actions-sheet")),Es=require("lucide-react-native"),Tt=(0,kt.forwardRef)(({onOptionSelect:M,options:T},C)=>{let R=kt.default.useRef(null);(0,kt.useImperativeHandle)(C,()=>({show:()=>R.current?.show(),hide:()=>R.current?.hide()}));let S=A=>{M(A),R.current?.hide()};return<Ls.default ref={R}headerAlwaysVisible gestureEnabled={!0}statusBarTranslucent drawUnderStatusBar={!1}containerStyle={{borderTopLeftRadius:20,borderTopRightRadius:20}}>
|
|
335
|
+
<Qe.View style={{padding:20,width:"100%"}}>
|
|
346
336
|
|
|
347
337
|
{}
|
|
348
|
-
<
|
|
349
|
-
<
|
|
338
|
+
<Qe.View style={{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:20}}>
|
|
339
|
+
<Qe.Text style={{fontSize:18,fontWeight:"600",color:"#1F2937"}}>
|
|
350
340
|
Share Content
|
|
351
|
-
</
|
|
352
|
-
<
|
|
353
|
-
<
|
|
354
|
-
</
|
|
355
|
-
</
|
|
341
|
+
</Qe.Text>
|
|
342
|
+
<Qe.TouchableOpacity onPress={()=>R.current?.hide()}>
|
|
343
|
+
<Es.X size={24}color="#6B7280"/>
|
|
344
|
+
</Qe.TouchableOpacity>
|
|
345
|
+
</Qe.View>
|
|
356
346
|
|
|
357
347
|
{}
|
|
358
|
-
<
|
|
359
|
-
{
|
|
360
|
-
<
|
|
348
|
+
<Qe.View style={{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",paddingBottom:20}}>
|
|
349
|
+
{T.map(A=>{let I=A.icon;return<Qe.TouchableOpacity key={A.id}style={{width:"30%",aspectRatio:1,marginBottom:20,alignItems:"center",justifyContent:"center"}}onPress={()=>S(A.id)}>
|
|
350
|
+
<Qe.View style={{width:60,height:60,borderRadius:30,backgroundColor:"#F3F4F6",alignItems:"center",justifyContent:"center",marginBottom:8}}>
|
|
361
351
|
<I size={24}color={A.color}/>
|
|
362
|
-
</
|
|
363
|
-
<
|
|
352
|
+
</Qe.View>
|
|
353
|
+
<Qe.Text style={{fontSize:12,color:"#6B7280",textAlign:"center",fontWeight:"500"}}>
|
|
364
354
|
{A.label}
|
|
365
|
-
</
|
|
366
|
-
</
|
|
367
|
-
</
|
|
368
|
-
</
|
|
369
|
-
</
|
|
370
|
-
<
|
|
371
|
-
<
|
|
372
|
-
<
|
|
373
|
-
<
|
|
374
|
-
<
|
|
375
|
-
</
|
|
376
|
-
</
|
|
377
|
-
</
|
|
378
|
-
{({pressed:
|
|
379
|
-
<
|
|
380
|
-
</
|
|
381
|
-
</
|
|
382
|
-
<
|
|
383
|
-
<
|
|
355
|
+
</Qe.Text>
|
|
356
|
+
</Qe.TouchableOpacity>})}
|
|
357
|
+
</Qe.View>
|
|
358
|
+
</Qe.View>
|
|
359
|
+
</Ls.default>});Tt.displayName="AttachmentMenu";var jo=require("react"),ke=require("react-native"),Sr=({isVisible:M})=>{let T=(0,jo.useRef)(new ke.Animated.Value(0)).current;return(0,jo.useEffect)(()=>{if(!M){T.setValue(0);return}let C=ke.Animated.loop(ke.Animated.sequence([ke.Animated.timing(T,{toValue:1,duration:1200,useNativeDriver:!0}),ke.Animated.timing(T,{toValue:0,duration:1200,useNativeDriver:!0})]));return C.start(),()=>{C.stop()}},[M,T]),M?<ke.View style={Lt.container}>
|
|
360
|
+
<ke.View style={Lt.bubble}>
|
|
361
|
+
<ke.View style={Lt.dotsContainer}>
|
|
362
|
+
<ke.Animated.View style={[Lt.dot,{opacity:T.interpolate({inputRange:[0,.5,1],outputRange:[.3,1,.3]}),transform:[{translateY:T.interpolate({inputRange:[0,.5,1],outputRange:[0,-4,0]})}]}]}/>
|
|
363
|
+
<ke.Animated.View style={[Lt.dot,{opacity:T.interpolate({inputRange:[.33,.83,1.33],outputRange:[.3,1,.3]}),transform:[{translateY:T.interpolate({inputRange:[.33,.83,1.33],outputRange:[0,-4,0]})}]}]}/>
|
|
364
|
+
<ke.Animated.View style={[Lt.dot,{opacity:T.interpolate({inputRange:[.66,1.16,1.66],outputRange:[.3,1,.3]}),transform:[{translateY:T.interpolate({inputRange:[.66,1.16,1.66],outputRange:[0,-4,0]})}]}]}/>
|
|
365
|
+
</ke.View>
|
|
366
|
+
</ke.View>
|
|
367
|
+
</ke.View>:null},Lt=ke.StyleSheet.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}}),Et=Sr;var Oo=Q(require("react")),jt=require("react-native"),js=require("lucide-react-native");var wr=({visible:M,onPress:T,isReplyActive:C=!1})=>{let R=$(),S=Oo.default.useRef(new jt.Animated.Value(0)).current,[A,I]=Oo.default.useState(!1);return Oo.default.useEffect(()=>{jt.Animated.timing(S,{toValue:M?1:0,duration:200,useNativeDriver:!0}).start(()=>{I(M)})},[M,S]),!M&&!A?null:<jt.Pressable onPress={T}hitSlop={{top:10,bottom:10,left:10,right:10}}>
|
|
368
|
+
{({pressed:P})=><jt.Animated.View style={[{position:"absolute",bottom:40,right:R.spacing.lg,zIndex:9999,width:32,height:32,backgroundColor:R.colors.background,borderRadius:R.borderRadius.xl,justifyContent:"center",alignItems:"center",shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.25,shadowRadius:3.84,elevation:5,opacity:S,transform:P?[{scale:.95}]:[]}]}>
|
|
369
|
+
<js.ChevronDown size={20}color={R.colors.text}/>
|
|
370
|
+
</jt.Animated.View>}
|
|
371
|
+
</jt.Pressable>},Ho=wr;var Gt=require("react-native");var Ir=({displayDate:M})=>{let T=$();return<Gt.View style={{marginVertical:T.spacing.lg,alignItems:"center"}}>
|
|
372
|
+
<Gt.View style={{borderRadius:T.borderRadius.full,backgroundColor:T.colors.surfaceSecondary,paddingHorizontal:T.spacing.md,paddingVertical:T.spacing.xs}}>
|
|
373
|
+
<Gt.Text style={{fontSize:T.typography.fontSize.xs,color:T.colors.textSecondary,fontWeight:T.typography.fontWeight.medium}}>
|
|
384
374
|
{M}
|
|
385
|
-
</
|
|
386
|
-
</
|
|
387
|
-
</co.View>},Qt=In;var Ue=Q(require("react")),Je=require("react-native"),to=require("lucide-react-native");var tt=require("react"),Be=require("react-native"),je=require("lucide-react-native"),vt=Q(require("expo-image-picker")),Is=Q(require("expo-document-picker")),Pt=Q(require("expo-location")),vs=Q(require("expo-contacts"));var Zt=Q(require("expo-image-manipulator")),vn={maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"},Yo=async(M,S={})=>{try{let C={...vn,...S};console.log("Starting image compression...",{uri:M,options:C});let R=await Zt.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:V}=R,D=v,B=V;if(C.maxWidth&&v>C.maxWidth){let k=C.maxWidth/v;D=C.maxWidth,B=V*k}if(C.maxHeight&&B>C.maxHeight){let k=C.maxHeight/B;B=C.maxHeight,D=D*k}(D!==v||B!==V)&&(T.push({resize:{width:Math.round(D),height:Math.round(B)}}),console.log("Resizing image:",{from:{width:v,height:V},to:{width:Math.round(D),height:Math.round(B)}}))}let A={compress:C.quality,format:C.format==="png"?Zt.SaveFormat.PNG:Zt.SaveFormat.JPEG};console.log("Applying compression with options:",A);let I=await Zt.manipulateAsync(M,T,A);console.log("Image compression completed:",{originalUri:M,compressedUri:I.uri,finalDimensions:{width:I.width,height:I.height}});let z=Date.now(),P=C.format==="png"?"png":"jpg",E=`compressed_image_${z}.${P}`;return{uri:I.uri,width:I.width,height:I.height,fileName:E}}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}`)}},_o=(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 Pn=[{id:"photo",label:"Photo",icon:je.Image,color:"#3B82F6"},{id:"camera",label:"Camera",icon:je.Camera,color:"#6B7280"},{id:"location",label:"Location",icon:je.MapPin,color:"#10B981"},{id:"contact",label:"Contact",icon:je.User,color:"#6B7280"},{id:"document",label:"Document",icon:je.FileText,color:"#3B82F6"},{id:"poll",label:"Poll",icon:je.BarChart3,color:"#F59E0B"},{id:"event",label:"Event",icon:je.Calendar,color:"#EF4444"}],eo=M=>{let S=(0,tt.useRef)(null),C=(0,tt.useCallback)(async()=>{console.log("Photo selection initiated");try{console.log("Requesting photo library permissions...");let{status:v}=await vt.requestMediaLibraryPermissionsAsync();if(console.log("Photo library permission status:",v),v!=="granted"){Be.Alert.alert("Permission needed","Please grant photo library access to select images.");return}console.log("Waiting for UI to stabilize..."),await new Promise(D=>setTimeout(()=>D(void 0),300)),console.log("Launching image picker...");let V=await vt.launchImageLibraryAsync({mediaTypes:"images",allowsEditing:!0,aspect:[4,3],quality:.8,allowsMultipleSelection:!1});if(console.log("Image picker result:",V),!V.canceled&&V.assets&&V.assets.length>0){let D=V.assets[0];console.log("Photo selected successfully:",D.uri);try{console.log("Starting image compression...");let B=_o(D.width||1920,D.height||1920),k=await Yo(D.uri,B);console.log("Image compression completed:",k),M?.({type:"image",data:{...k,originalFileSize:D.fileSize}})}catch(B){console.error("Image compression failed:",B),Be.Alert.alert("Compression Error","Failed to compress image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:D.uri,width:D.width,height:D.height,fileSize:D.fileSize,fileName:D.fileName||"image.jpg"}})}}else console.log("Photo selection was canceled by user")}catch(v){console.error("Error in photo selection process:",v),Be.Alert.alert("Photo Selection Error","Failed to open photo library. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),R=(0,tt.useCallback)(async()=>{console.log("Camera capture initiated");try{console.log("Requesting camera permissions...");let{status:v}=await vt.requestCameraPermissionsAsync();if(console.log("Camera permission status:",v),v!=="granted"){Be.Alert.alert("Permission needed","Please grant camera access to take photos.");return}console.log("Waiting for UI to stabilize..."),await new Promise(D=>setTimeout(()=>D(void 0),300)),console.log("Launching camera...");let V=await vt.launchCameraAsync({allowsEditing:!0,aspect:[4,3],quality:.8,mediaTypes:"images"});if(console.log("Camera result:",V),!V.canceled&&V.assets&&V.assets.length>0){let D=V.assets[0];console.log("Photo captured successfully:",D.uri);try{console.log("Starting camera image compression...");let B=_o(D.width||1920,D.height||1920),k=await Yo(D.uri,B);console.log("Camera image compression completed:",k),M?.({type:"image",data:{...k,originalFileSize:D.fileSize}})}catch(B){console.error("Camera image compression failed:",B),Be.Alert.alert("Compression Error","Failed to compress captured image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:D.uri,width:D.width,height:D.height,fileSize:D.fileSize,fileName:D.fileName||"camera_photo.jpg"}})}}else console.log("Camera capture was canceled by user")}catch(v){console.error("Error in camera capture process:",v),Be.Alert.alert("Camera Error","Failed to open camera. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),T=(0,tt.useCallback)(async()=>{console.log("Location sharing initiated");try{console.log("Requesting location permissions...");let{status:v}=await Pt.requestForegroundPermissionsAsync();if(console.log("Location permission status:",v),v!=="granted"){Be.Alert.alert("Permission needed","Please grant location access to share your location.");return}console.log("Getting current location...");let V=await Pt.getCurrentPositionAsync({accuracy:Pt.Accuracy.High});console.log("Getting address from coordinates...");let D=await Pt.reverseGeocodeAsync({latitude:V.coords.latitude,longitude:V.coords.longitude}),B={coordinates:{latitude:V.coords.latitude,longitude:V.coords.longitude},address:D[0]||null,timestamp:V.timestamp};console.log("Location shared successfully:",B.coordinates),M?.({type:"location",data:B})}catch(v){console.error("Error in location sharing process:",v),Be.Alert.alert("Location Error","Failed to get your location. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),A=(0,tt.useCallback)(async()=>{try{let{status:v}=await vs.requestPermissionsAsync();if(v!=="granted"){Be.Alert.alert("Permission needed","Please grant contacts access to share contacts.");return}Be.Alert.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),Be.Alert.alert("Error","Failed to access contacts. Please try again.")}finally{S.current?.hide()}},[]),I=(0,tt.useCallback)(async()=>{console.log("Document selection initiated");try{console.log("Waiting for UI to stabilize..."),await new Promise(V=>setTimeout(()=>V(void 0),300)),console.log("Launching document picker...");let v=await Is.getDocumentAsync({type:"*/*",copyToCacheDirectory:!0,multiple:!1});if(console.log("Document picker result:",v),!v.canceled&&v.assets&&v.assets.length>0){let V=v.assets[0];console.log("Document selected successfully:",V.name),M?.({type:"document",data:{uri:V.uri,name:V.name,size:V.size,mimeType:V.mimeType}})}else console.log("Document selection was canceled by user")}catch(v){console.error("Error in document selection process:",v),Be.Alert.alert("Document Selection Error","Failed to open document picker. Please try again.",[{text:"OK"}])}},[M]),z=(0,tt.useCallback)(()=>{Be.Alert.alert("Create Poll","Poll creation feature is coming soon! This would open a poll creation interface.",[{text:"OK",onPress:()=>console.log("Poll creation acknowledged")}])},[]),P=(0,tt.useCallback)(()=>{Be.Alert.alert("Create Event","Event creation feature is coming soon! This would open an event creation interface.",[{text:"OK",onPress:()=>console.log("Event creation acknowledged")}])},[]),E=(0,tt.useCallback)(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":z();break;case"event":P();break;default:console.warn(`Unknown attachment option: ${v}`)}}catch(V){console.error(`Error handling ${v}:`,V),Be.Alert.alert("Error",`Failed to handle ${v}. Please try again.`)}},[C,R,T,A,I,z,P]);return{menuRef:S,handleOptionSelect:E,options:Pn}};var Y=Q(require("react")),uo=(M={})=>{let{initialValue:S="",initialHeight:C=50,onValueChange:R,onHeightChange:T,onSend:A,onAttachmentSend:I,onReplyCancel:z,onFocus:P,onBlur:E,maxHeight:v=100,minHeight:V=50,maxLength:D=1e3,placeholder:B="Type a message..."}=M,k=(0,Y.useRef)(null),[L,O]=Y.default.useState(S),[F,H]=Y.default.useState(C),[N,j]=Y.default.useState(!1),[te,Oe]=Y.default.useState(null),[J,Me]=Y.default.useState([]),Fe=Y.default.useMemo(()=>({value:L,height:F,isFocused:N,replyToMessage:te,attachments:J}),[L,F,N,te,J]),Ye=(0,Y.useCallback)(Ae=>{O(Ae),R?.(Ae)},[R]),ke=(0,Y.useCallback)(Ae=>{let Ne=Math.max(V,Math.min(v,Ae));H(Ne),T?.(Ne)},[V,v,T]),Ce=(0,Y.useCallback)(()=>{j(!0),P?.()},[P]),U=(0,Y.useCallback)(()=>{j(!1),E?.()},[E]),He=(0,Y.useCallback)(Ae=>{let{height:Ne}=Ae.nativeEvent.contentSize,ao=Math.max(V,Math.min(v,Ne+16));ke(ao)},[V,v,ke]),st=(0,Y.useCallback)(()=>{A&&(L||J.length>0)&&(A(L,J,te),O(S),Me([]),Oe(null),H(C))},[A,L,J,te,S,C]),Xe=(0,Y.useCallback)(Ae=>{I?(I(Ae,L),L&&O(S)):Me(Ne=>[...Ne,{...Ae,id:Date.now().toString()}])},[I,L,S]),Le=(0,Y.useCallback)(Ae=>{Me(Ne=>[...Ne,Ae])},[]),_e=(0,Y.useCallback)(Ae=>{Me(Ne=>Ne.filter(ao=>ao.id!==Ae))},[]),nt=(0,Y.useCallback)(()=>{Me([])},[]),we=(0,Y.useCallback)(()=>{Oe(null),z?.()},[z]),pt=(0,Y.useCallback)(()=>{k.current?.focus()},[]),Ho=Y.default.useMemo(()=>({setValue:Ye,setHeight:ke,setFocus:j,setReplyToMessage:Oe,addAttachment:Le,removeAttachment:_e,clearAttachments:nt,sendMessage:st,cancelReply:we,focusInput:pt,handleAttachmentSelected:Xe,handleContentSizeChange:He,handleFocus:Ce,handleBlur:U}),[Ye,ke,j,Oe,Le,_e,nt,st,we,pt,Xe,He,Ce,U]),No=Y.default.useMemo(()=>({textInputRef:k}),[]);return{state:Fe,actions:Ho,refs:No}},Ps=(0,Y.createContext)(null),lt=()=>{let M=(0,Y.useContext)(Ps);if(!M)throw new Error("useMessageInputContext must be used within MessageInputProvider");return M},Go=({children:M,value:S})=><Ps.Provider value={S}>
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
<to.Plus size={24}color={v.colors.textSecondary}/>
|
|
395
|
-
</Je.TouchableOpacity>
|
|
375
|
+
</Gt.Text>
|
|
376
|
+
</Gt.View>
|
|
377
|
+
</Gt.View>},Fo=Ir;var Ne=Q(require("react")),Ge=require("react-native"),Ht=require("lucide-react-native");var Ze=require("react"),Be=require("react-native"),Le=require("lucide-react-native"),ft=Q(require("expo-image-picker")),Os=Q(require("expo-document-picker")),yt=Q(require("expo-location")),Hs=Q(require("expo-contacts"));var Ot=Q(require("expo-image-manipulator")),vr={maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"},ss=async(M,T={})=>{try{let C={...vr,...T};console.log("Starting image compression...",{uri:M,options:C});let R=await Ot.manipulateAsync(M,[],{});console.log("Original image info:",{width:R.width,height:R.height,uri:R.uri});let S=[];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)&&(S.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"?Ot.SaveFormat.PNG:Ot.SaveFormat.JPEG};console.log("Applying compression with options:",A);let I=await Ot.manipulateAsync(M,S,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}`)}},rs=(M,T)=>M>3e3||T>3e3?{maxWidth:1920,maxHeight:1920,quality:.7,format:"jpeg"}:M>1920||T>1920?{maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"}:{quality:.9,format:"jpeg"};var Pr=[{id:"photo",label:"Photo",icon:Le.Image,color:"#3B82F6"},{id:"camera",label:"Camera",icon:Le.Camera,color:"#6B7280"},{id:"location",label:"Location",icon:Le.MapPin,color:"#10B981"},{id:"contact",label:"Contact",icon:Le.User,color:"#6B7280"},{id:"document",label:"Document",icon:Le.FileText,color:"#3B82F6"},{id:"poll",label:"Poll",icon:Le.BarChart3,color:"#F59E0B"},{id:"event",label:"Event",icon:Le.Calendar,color:"#EF4444"}],No=M=>{let T=(0,Ze.useRef)(null),C=(0,Ze.useCallback)(async()=>{console.log("Photo selection initiated");try{console.log("Requesting photo library permissions...");let{status:v}=await ft.requestMediaLibraryPermissionsAsync();if(console.log("Photo library permission status:",v),v!=="granted"){Be.Alert.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 ft.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=rs(V.width||1920,V.height||1920),k=await ss(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),Be.Alert.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),Be.Alert.alert("Photo Selection Error","Failed to open photo library. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),R=(0,Ze.useCallback)(async()=>{console.log("Camera capture initiated");try{console.log("Requesting camera permissions...");let{status:v}=await ft.requestCameraPermissionsAsync();if(console.log("Camera permission status:",v),v!=="granted"){Be.Alert.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 ft.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=rs(V.width||1920,V.height||1920),k=await ss(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),Be.Alert.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),Be.Alert.alert("Camera Error","Failed to open camera. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),S=(0,Ze.useCallback)(async()=>{console.log("Location sharing initiated");try{console.log("Requesting location permissions...");let{status:v}=await yt.requestForegroundPermissionsAsync();if(console.log("Location permission status:",v),v!=="granted"){Be.Alert.alert("Permission needed","Please grant location access to share your location.");return}console.log("Getting current location...");let B=await yt.getCurrentPositionAsync({accuracy:yt.Accuracy.High});console.log("Getting address from coordinates...");let V=await yt.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),Be.Alert.alert("Location Error","Failed to get your location. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),A=(0,Ze.useCallback)(async()=>{try{let{status:v}=await Hs.requestPermissionsAsync();if(v!=="granted"){Be.Alert.alert("Permission needed","Please grant contacts access to share contacts.");return}Be.Alert.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),Be.Alert.alert("Error","Failed to access contacts. Please try again.")}finally{T.current?.hide()}},[]),I=(0,Ze.useCallback)(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 Os.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),Be.Alert.alert("Document Selection Error","Failed to open document picker. Please try again.",[{text:"OK"}])}},[M]),P=(0,Ze.useCallback)(()=>{Be.Alert.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=(0,Ze.useCallback)(()=>{Be.Alert.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=(0,Ze.useCallback)(async v=>{console.log(`Selected attachment option: ${v}`);try{switch(v){case"photo":await C();break;case"camera":await R();break;case"location":await S();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),Be.Alert.alert("Error",`Failed to handle ${v}. Please try again.`)}},[C,R,S,A,I,P,z]);return{menuRef:T,handleOptionSelect:j,options:Pr}};var Y=Q(require("react")),_t=(M={})=>{let{initialValue:T="",initialHeight:C=50,onValueChange:R,onHeightChange:S,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=(0,Y.useRef)(null),[L,O]=Y.default.useState(T),[H,F]=Y.default.useState(C),[N,E]=Y.default.useState(!1),[te,je]=Y.default.useState(null),[J,Me]=Y.default.useState([]),Oe=Y.default.useMemo(()=>({value:L,height:H,isFocused:N,replyToMessage:te,attachments:J}),[L,H,N,te,J]),qe=(0,Y.useCallback)(Pe=>{O(Pe),R?.(Pe)},[R]),Ve=(0,Y.useCallback)(Pe=>{let Fe=Math.max(B,Math.min(v,Pe));F(Fe),S?.(Fe)},[B,v,S]),Ce=(0,Y.useCallback)(()=>{E(!0),z?.()},[z]),U=(0,Y.useCallback)(()=>{E(!1),j?.()},[j]),He=(0,Y.useCallback)(Pe=>{let{height:Fe}=Pe.nativeEvent.contentSize,Kt=Math.max(B,Math.min(v,Fe+16));Ve(Kt)},[B,v,Ve]),et=(0,Y.useCallback)(()=>{A&&(L||J.length>0)&&(A(L,J,te),O(T),Me([]),je(null),F(C))},[A,L,J,te,T,C]),_e=(0,Y.useCallback)(Pe=>{I?(I(Pe,L),L&&O(T)):Me(Fe=>[...Fe,{...Pe,id:Date.now().toString()}])},[I,L,T]),De=(0,Y.useCallback)(Pe=>{Me(Fe=>[...Fe,Pe])},[]),$e=(0,Y.useCallback)(Pe=>{Me(Fe=>Fe.filter(Kt=>Kt.id!==Pe))},[]),tt=(0,Y.useCallback)(()=>{Me([])},[]),Se=(0,Y.useCallback)(()=>{je(null),P?.()},[P]),dt=(0,Y.useCallback)(()=>{k.current?.focus()},[]),_o=Y.default.useMemo(()=>({setValue:qe,setHeight:Ve,setFocus:E,setReplyToMessage:je,addAttachment:De,removeAttachment:$e,clearAttachments:tt,sendMessage:et,cancelReply:Se,focusInput:dt,handleAttachmentSelected:_e,handleContentSizeChange:He,handleFocus:Ce,handleBlur:U}),[qe,Ve,E,je,De,$e,tt,et,Se,dt,_e,He,Ce,U]),Jo=Y.default.useMemo(()=>({textInputRef:k}),[]);return{state:Oe,actions:_o,refs:Jo}},Fa=(0,Y.createContext)(null);var ut=(0,Ne.forwardRef)(({value:M,onChangeText:T,onSend:C,onFocus:R,height:S,onContentSizeChange:A,replyToMessage:I,onCancelReply:P,onAttachmentSend:z},j)=>{let v=$(),B=(0,Ne.useRef)(null);(0,Ne.useImperativeHandle)(j,()=>({focus:()=>{B.current?.focus()}}));let{state:V,actions:D}=_t({initialValue:M,initialHeight:S,onValueChange:T,onHeightChange:A,onSend:C,onAttachmentSend:z,onReplyCancel:P,onFocus:R});Ne.default.useEffect(()=>{M!==V.value&&D.setValue(M)},[M,V.value,D]),Ne.default.useEffect(()=>{S!==V.height&&D.setHeight(S)},[S,V.height,D]),Ne.default.useEffect(()=>{I!==V.replyToMessage&&D.setReplyToMessage(I||null)},[I,V.replyToMessage,D]),Ne.default.useEffect(()=>{if(I&&B.current){let O=setTimeout(()=>{B.current?.focus()},100);return()=>clearTimeout(O)}},[I]);let k=(0,Ne.useCallback)(O=>{if(console.log("Attachment selected:",O),z)z(O,M.trim()||void 0),M.trim()&&T("");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,T]),L=No(k);return<>
|
|
378
|
+
{I&&P&&<Yt replyToMessage={I}onCancel={P}/>}
|
|
379
|
+
<Ge.View style={{borderTopWidth:1,borderTopColor:v.colors.borderLight,backgroundColor:v.colors.background}}>
|
|
380
|
+
<Ge.View style={{flexDirection:"row",alignItems:"center",backgroundColor:v.colors.background,paddingHorizontal:v.spacing.lg,paddingVertical:v.spacing.sm,minHeight:S}}>
|
|
381
|
+
<Ge.TouchableOpacity style={{marginRight:v.spacing.md}}onPress={()=>L.menuRef.current?.show()}>
|
|
382
|
+
<Ht.Plus size={24}color={v.colors.textSecondary}/>
|
|
383
|
+
</Ge.TouchableOpacity>
|
|
396
384
|
|
|
397
|
-
<
|
|
398
|
-
<
|
|
399
|
-
</
|
|
385
|
+
<Ge.View style={{flex:1,flexDirection:"row",alignItems:"center",borderRadius:v.borderRadius.full,backgroundColor:v.colors.surfaceSecondary,paddingHorizontal:v.spacing.lg,paddingVertical:6}}>
|
|
386
|
+
<Ge.TextInput ref={B}style={{flex:1,fontSize:v.typography.fontSize.base,maxHeight:70,minHeight:18,paddingTop:Ge.Platform.OS==="ios"?6:3,paddingBottom:Ge.Platform.OS==="ios"?6:3,color:v.colors.text}}value={M}onChangeText={T}placeholder='Type a message...'placeholderTextColor={v.colors.textMuted}multiline maxLength={1e3}onFocus={R}onContentSizeChange={D.handleContentSizeChange}returnKeyType='default'textAlignVertical='center'/>
|
|
387
|
+
</Ge.View>
|
|
400
388
|
|
|
401
|
-
<
|
|
402
|
-
{M.trim()?<
|
|
403
|
-
</
|
|
404
|
-
</
|
|
405
|
-
</
|
|
389
|
+
<Ge.TouchableOpacity onPress={C}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()?<Ht.Send size={18}color='white'/>:<Ht.Mic size={18}color='white'/>}
|
|
391
|
+
</Ge.TouchableOpacity>
|
|
392
|
+
</Ge.View>
|
|
393
|
+
</Ge.View>
|
|
406
394
|
|
|
407
|
-
<
|
|
408
|
-
</>});
|
|
409
|
-
<ct.TextInput ref={R.textInputRef}style={{flex:1,fontSize:T.typography.fontSize.base,maxHeight:70,minHeight:18,paddingTop:ct.Platform.OS==="ios"?6:3,paddingBottom:ct.Platform.OS==="ios"?6:3,color:T.colors.text}}value={S.value}onChangeText={C.setValue}placeholder='Type a message...'placeholderTextColor={T.colors.textMuted}multiline maxLength={1e3}onFocus={C.handleFocus}onBlur={C.handleBlur}onContentSizeChange={C.handleContentSizeChange}returnKeyType='default'textAlignVertical='center'/>
|
|
410
|
-
</ct.View>},AttachmentButton:({render:M})=>{let{actions:S}=lt(),C=K(),R=eo(S.handleAttachmentSelected);return M?M({actions:S,attachmentMenu:R}):<ct.TouchableOpacity style={{marginRight:C.spacing.md}}onPress={()=>R.menuRef.current?.show()}>
|
|
411
|
-
<oo.Plus size={24}color={C.colors.textSecondary}/>
|
|
412
|
-
</ct.TouchableOpacity>},SendButton:({render:M})=>{let{state:S,actions:C}=lt(),R=K();return M?M({state:S,actions:C}):<ct.TouchableOpacity onPress={C.sendMessage}style={{marginLeft:R.spacing.md,height:40,width:40,alignItems:"center",justifyContent:"center",borderRadius:R.borderRadius.full,backgroundColor:S.value&&S.value.toString().trim()||S.attachments.length>0?R.colors.primary:R.colors.gray[300]}}disabled={!S.value&&S.attachments.length===0}>
|
|
413
|
-
{S.value&&S.value.toString().trim()||S.attachments.length>0?<oo.Send size={18}color='white'/>:<oo.Mic size={18}color='white'/>}
|
|
414
|
-
</ct.TouchableOpacity>},AttachmentMenu:({render:M})=>{let{actions:S}=lt(),C=eo(S.handleAttachmentSelected);return M?M({actions:S,attachmentMenu:C}):<It ref={C.menuRef}onOptionSelect={C.handleOptionSelect}options={C.options}/>}};var Eo=Q(require("react"));var At=Q(require("react"));var Lo=require("react");function mo(M,S={}){let{initialNumToRender:C=20,maxToRenderPerBatch:R=10,windowSize:T=10}=S,A=(0,Lo.useMemo)(()=>fs(M).reverse(),[M]),I=(0,Lo.useCallback)(z=>z.listItemType==="date-separator"?z.id:z.id.toString(),[]);return{messageItems:A,keyExtractor:I,flatListProps:{initialNumToRender:C,maxToRenderPerBatch:R,windowSize:T,inverted:!0,showsVerticalScrollIndicator:!1,keyboardShouldPersistTaps:"handled",removeClippedSubviews:!1,scrollEventThrottle:16}}}var Ke=require("react");function go(M={}){let{scrollThreshold:S=50,autoScrollToBottom:C=!0}=M,R=(0,Ke.useRef)(null),[T,A]=(0,Ke.useState)({isNearBottom:!0,isNearTop:!1,showScrollToBottomButton:!1}),I=(0,Ke.useRef)(0),z=(0,Ke.useCallback)(k=>{let{contentOffset:L,contentSize:O,layoutMeasurement:F}=k.nativeEvent,H=L.y,N=Math.abs(H)<S,j=Math.abs(H)>O.height-F.height-S;A({isNearBottom:N,isNearTop:j,showScrollToBottomButton:!N})},[S]),P=(0,Ke.useCallback)(k=>{let L=k>I.current;return I.current=k,L},[]),E=(0,Ke.useCallback)(()=>{},[]),v=(0,Ke.useCallback)((k=!0)=>{R.current&&R.current.scrollToOffset({offset:0,animated:k})},[]),V=(0,Ke.useCallback)((k,L=!0)=>{R.current&&R.current.scrollToOffset({offset:k,animated:L})},[]),D=(0,Ke.useCallback)((k,L=!0)=>{R.current&&R.current.scrollToIndex({index:k,animated:L})},[]),B=(0,Ke.useCallback)(k=>{P(k)&&C&&R.current&&setTimeout(()=>{v()},100)},[P,C,v]);return{flatListRef:R,scrollState:T,handleScroll:z,handleContentSizeChange:E,handleNewMessages:B,scrollToEnd:v,scrollToOffset:V,scrollToIndex:D}}var so=require("react");function po(M={}){let{enableMessageActions:S=!0}=M,[C,R]=(0,so.useState)({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0}),T=(0,so.useCallback)((z,P)=>{S&&R({actionSheetVisible:!0,selectedMessage:z,messagePosition:P})},[S]),A=(0,so.useCallback)(()=>{R({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0})},[]),I=(0,so.useCallback)((z,P)=>{if(!C.selectedMessage)return;let{selectedMessage:E}=C;switch(z){case"reply":P?.onReply?.(E);break;case"copy":if(P?.onCopy)P.onCopy(E);else{let v=E.type==="image"&&E.imageData?E.text||"Image message":E.text;Promise.resolve().then(()=>(zs(),As)).then(({copyToClipboard:V})=>{V(v)}).catch(()=>{console.log("Clipboard functionality not available")})}break;case"delete":P?.onDelete?.(E.id);break;default:P?.onCustomAction?.(z,E);break}A()},[C.selectedMessage,A]);return{actionState:C,handleMessageLongPress:T,handleActionSheetClose:A,handleActionPress:I}}var mt=require("react");function ho(M={}){let{enableReactionDetails:S=!0}=M,[C,R]=(0,mt.useState)({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),[T,A]=(0,mt.useState)(null),I=(0,mt.useCallback)(V=>{S&&V.reactions&&V.reactions.length>0&&(A(V),R({isReactionDetailsVisible:!0,selectedReactions:V.reactions,selectedMessageText:V.text}))},[S]),z=(0,mt.useCallback)(()=>{R({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),A(null)},[]),P=(0,mt.useCallback)((V,D)=>{T&&D?.(T.id,V),z()},[T,z]),E=(0,mt.useCallback)((V,D)=>{T&&D?.(T.id,V),z()},[T,z]),v=(0,mt.useCallback)((V,D)=>{T&&D?.(T.id,V)},[T]);return{reactionState:C,selectedMessage:T,handleReactionPress:I,handleReactionDetailsClose:z,handleAddReaction:P,handleRemoveReaction:E,handleEmojiReact:v}}var fo=require("react");function yo(){let[M,S]=(0,fo.useState)({replyToMessage:null}),C=(0,fo.useCallback)(T=>{S({replyToMessage:T})},[]),R=(0,fo.useCallback)(()=>{S({replyToMessage:null})},[]);return{replyState:M,setReplyToMessage:C,clearReply:R}}var Vs=(0,At.createContext)(null);function zt(){let M=(0,At.useContext)(Vs);if(!M)throw new Error("useMessageListContext must be used within MessageListProvider");return M}function Lt({children:M,messages:S,config:C={},...R}){let T=mo(S,C),A=go(C),I=po(C),z=ho(C),P=yo();At.default.useEffect(()=>{A.handleNewMessages(S.length)},[S.length,A.handleNewMessages]);let E=(0,At.useMemo)(()=>({messageList:T,scroll:A,actions:I,reactions:z,reply:P,config:C,callbacks:R}),[T,A,I,z,P,C,R]);return<Vs.Provider value={E}>
|
|
395
|
+
<Tt ref={L.menuRef}onOptionSelect={L.handleOptionSelect}options={L.options}/>
|
|
396
|
+
</>});ut.displayName="MessageInput";var Wo=require("react-native"),ns=require("lucide-react-native");var Ko=Q(require("react"));var xt=Q(require("react"));var Uo=require("react");function Jt(M,T={}){let{initialNumToRender:C=20,maxToRenderPerBatch:R=10,windowSize:S=10}=T,A=(0,Uo.useMemo)(()=>Ps(M).reverse(),[M]),I=(0,Uo.useCallback)(P=>P.listItemType==="date-separator"?P.id:P.id.toString(),[]);return{messageItems:A,keyExtractor:I,flatListProps:{initialNumToRender:C,maxToRenderPerBatch:R,windowSize:S,inverted:!0,showsVerticalScrollIndicator:!1,keyboardShouldPersistTaps:"handled",removeClippedSubviews:!1,scrollEventThrottle:16}}}var We=require("react");function as(M={}){let{scrollThreshold:T=50,autoScrollToBottom:C=!0}=M,R=(0,We.useRef)(null),[S,A]=(0,We.useState)({isNearBottom:!0,isNearTop:!1,showScrollToBottomButton:!1}),I=(0,We.useRef)(0),P=(0,We.useCallback)(k=>{let{contentOffset:L,contentSize:O,layoutMeasurement:H}=k.nativeEvent,F=L.y,N=Math.abs(F)<T,E=Math.abs(F)>O.height-H.height-T;A({isNearBottom:N,isNearTop:E,showScrollToBottomButton:!N})},[T]),z=(0,We.useCallback)(k=>{let L=k>I.current;return I.current=k,L},[]),j=(0,We.useCallback)(()=>{},[]),v=(0,We.useCallback)((k=!0)=>{R.current&&R.current.scrollToOffset({offset:0,animated:k})},[]),B=(0,We.useCallback)((k,L=!0)=>{R.current&&R.current.scrollToOffset({offset:k,animated:L})},[]),V=(0,We.useCallback)((k,L=!0)=>{R.current&&R.current.scrollToIndex({index:k,animated:L})},[]),D=(0,We.useCallback)(k=>{z(k)&&C&&R.current&&setTimeout(()=>{v()},100)},[z,C,v]);return{flatListRef:R,scrollState:S,handleScroll:P,handleContentSizeChange:j,handleNewMessages:D,scrollToEnd:v,scrollToOffset:B,scrollToIndex:V}}var Ft=require("react");function Xt(M={}){let{enableMessageActions:T=!0}=M,[C,R]=(0,Ft.useState)({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0}),S=(0,Ft.useCallback)((P,z)=>{T&&R({actionSheetVisible:!0,selectedMessage:P,messagePosition:z})},[T]),A=(0,Ft.useCallback)(()=>{R({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0})},[]),I=(0,Ft.useCallback)((P,z)=>{if(!C.selectedMessage)return;let{selectedMessage:j}=C;switch(P){case"reply":z?.onReply?.(j);break;case"copy":if(z?.onCopy)z.onCopy(j);else{let v=j.type==="image"&&j.imageData?j.text||"Image message":j.text;Promise.resolve().then(()=>(Ns(),Fs)).then(({copyToClipboard:B})=>{B(v)}).catch(()=>{console.log("Clipboard functionality not available")})}break;case"delete":z?.onDelete?.(j.id);break;default:z?.onCustomAction?.(P,j);break}A()},[C.selectedMessage,A]);return{actionState:C,handleMessageLongPress:S,handleActionSheetClose:A,handleActionPress:I}}var lt=require("react");function Qt(M={}){let{enableReactionDetails:T=!0}=M,[C,R]=(0,lt.useState)({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),[S,A]=(0,lt.useState)(null),I=(0,lt.useCallback)(B=>{T&&B.reactions&&B.reactions.length>0&&(A(B),R({isReactionDetailsVisible:!0,selectedReactions:B.reactions,selectedMessageText:B.text}))},[T]),P=(0,lt.useCallback)(()=>{R({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),A(null)},[]),z=(0,lt.useCallback)((B,V)=>{S&&V?.(S.id,B),P()},[S,P]),j=(0,lt.useCallback)((B,V)=>{S&&V?.(S.id,B),P()},[S,P]),v=(0,lt.useCallback)((B,V)=>{S&&V?.(S.id,B)},[S]);return{reactionState:C,selectedMessage:S,handleReactionPress:I,handleReactionDetailsClose:P,handleAddReaction:z,handleRemoveReaction:j,handleEmojiReact:v}}var Zt=require("react");function is(){let[M,T]=(0,Zt.useState)({replyToMessage:null}),C=(0,Zt.useCallback)(S=>{T({replyToMessage:S})},[]),R=(0,Zt.useCallback)(()=>{T({replyToMessage:null})},[]);return{replyState:M,setReplyToMessage:C,clearReply:R}}var Ws=(0,xt.createContext)(null);function Nt(){let M=(0,xt.useContext)(Ws);if(!M)throw new Error("useMessageListContext must be used within MessageListProvider");return M}function Mo({children:M,messages:T,config:C={},...R}){let S=Jt(T,C),A=as(C),I=Xt(C),P=Qt(C),z=is();xt.default.useEffect(()=>{A.handleNewMessages(T.length)},[T.length,A.handleNewMessages]);let j=(0,xt.useMemo)(()=>({messageList:S,scroll:A,actions:I,reactions:P,reply:z,config:C,callbacks:R}),[S,A,I,P,z,C,R]);return<Ws.Provider value={j}>
|
|
415
397
|
{M}
|
|
416
|
-
</
|
|
417
|
-
<
|
|
418
|
-
<
|
|
419
|
-
<
|
|
420
|
-
<
|
|
421
|
-
<
|
|
422
|
-
<
|
|
423
|
-
</
|
|
424
|
-
</
|
|
398
|
+
</Ws.Provider>}var Co=require("react"),Wt=require("react-native");var bt={Provider:Mo,Container:({children:M,style:T})=><Wt.View style={[Us.container,T]}>{M}</Wt.View>,Messages:({renderMessage:M,style:T})=>{let{messageList:C,scroll:R,actions:S,reactions:A,callbacks:I}=Nt(),P=(0,Co.useCallback)(({item:j,index:v})=>M&&j.listItemType!=="date-separator"?M({message:j,index:v})||null:j.listItemType==="date-separator"?<Fo date={j.date}displayDate={j.displayDate}/>:<Vo message={j}onLongPress={S.handleMessageLongPress}onReactionPress={A.handleReactionPress}onReactionRemove={I.onReactionRemove}/>,[S.handleMessageLongPress,A.handleReactionPress,I.onReactionRemove,M]),z=(0,Co.useCallback)(j=>{R.handleScroll(j);let{isNearBottom:v,isNearTop:B}=R.scrollState;I.onScrollPositionChange?.(v,B),v&&I.onScrollToBottom?.(),B&&I.onScrollToTop?.()},[R.handleScroll,R.scrollState,I]);return<Wt.FlatList ref={R.flatListRef}data={C.messageItems}renderItem={P}keyExtractor={C.keyExtractor}contentContainerStyle={[Us.contentContainer,T]}onContentSizeChange={R.handleContentSizeChange}onScroll={z}{...C.flatListProps}/>},TypingIndicator:({isVisible:M})=>M?<Et isVisible={M}/>:null,ScrollButton:({visible:M,isReplyActive:T,onPress:C})=>{let{scroll:R}=Nt();return<Ho visible={M??R.scrollState.showScrollToBottomButton}onPress={C??R.scrollToEnd}isReplyActive={T}/>},ActionSheet:()=>{let{actions:M,reactions:T,reply:C,callbacks:R,config:S}=Nt(),A=(0,Co.useCallback)(P=>{M.handleActionPress(P,{onReply:z=>{C.setReplyToMessage(z),R.onReplyMessage?.(z)},onDelete:R.onMessageDelete,onCustomAction:R.onActionPress})},[M.handleActionPress,C.setReplyToMessage,R]),I=(0,Co.useCallback)(P=>{console.log("\u{1F525} MessageListCompound - handleEmojiReact called with emoji:",P);let z=M.actionState.selectedMessage;console.log("\u{1F525} MessageListCompound - selectedMessage:",z?.id,"callbacks.onReactionAdd exists:",!!R.onReactionAdd),z&&R.onReactionAdd?(console.log("\u{1F525} MessageListCompound - Calling onReactionAdd for message:",z.id,"emoji:",P),R.onReactionAdd(z.id,P)):console.log("\u{1F525} MessageListCompound - NOT calling onReactionAdd. selectedMessage:",!!z,"callback exists:",!!R.onReactionAdd)},[M.actionState.selectedMessage,R.onReactionAdd]);return S.enableMessageActions?<Lo 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:T,config:C}=Nt();return C.enableReactionDetails?<Eo visible={M.reactionState.isReactionDetailsVisible}onClose={M.handleReactionDetailsClose}reactions={M.reactionState.selectedReactions}messageText={M.reactionState.selectedMessageText}onRemoveReaction={R=>M.handleRemoveReaction(R,T.onReactionRemove)}/>:null}},Us=Wt.StyleSheet.create({container:{flex:1},contentContainer:{paddingVertical:16}});var mt=(0,Ko.forwardRef)(({messages:M,isTyping:T,showScrollToBottom:C=!1,isReplyActive:R=!1,...S},A)=>{let I={scrollThreshold:S.scrollThreshold,autoScrollToBottom:S.autoScrollToBottom,enableMessageActions:S.enableMessageActions,enableReactionDetails:S.enableReactionDetails},P={onScrollToBottom:S.onScrollToBottom,onScrollToTop:S.onScrollToTop,onScrollPositionChange:S.onScrollPositionChange,onReactionAdd:S.onReactionAdd,onReactionRemove:S.onReactionRemove,onMessageDelete:S.onMessageDelete,onReplyMessage:S.onReplyMessage,onActionPress:S.onActionPress};return Ko.default.useImperativeHandle(A,()=>({scrollToEnd:(z=!0)=>{},scrollToOffset:(z,j=!0)=>{},scrollToIndex:(z,j=!0)=>{}}),[]),<Mo messages={M}config={I}{...P}>
|
|
399
|
+
<bt.Container>
|
|
400
|
+
<bt.Messages/>
|
|
401
|
+
<bt.TypingIndicator isVisible={T}/>
|
|
402
|
+
<bt.ScrollButton visible={C?void 0:!1}isReplyActive={R}/>
|
|
403
|
+
<bt.ActionSheet/>
|
|
404
|
+
<bt.ReactionDetails/>
|
|
405
|
+
</bt.Container>
|
|
406
|
+
</Mo>});mt.displayName="MessageList";var Ks=Q(require("react"));function Ee(M){let T=Ks.default.forwardRef((R,S)=>(wt(),<M{...R}ref={S}/>)),C=M.displayName||M.name||"Component";return T.displayName=`RequireAuth(${C})`,T}function nt(M){return(...T)=>(wt(),M(...T))}var qs=require("react-native");var Ue=require("react-native");var Ut=require("react-native");var Vr=({avatar:M,isOnline:T=!1,size:C="medium"})=>{let R=$(),S=()=>{switch(C){case"small":return{width:32,height:32};case"large":return{width:64,height:64};default:return{width:48,height:48}}},A=()=>{switch(C){case"small":return R.typography.fontSize.sm;case"large":return R.typography.fontSize.xxl;default:return R.typography.fontSize.lg}},I=()=>{switch(C){case"small":return{width:12,height:12};case"large":return{width:24,height:24};default:return{width:16,height:16}}},P=S(),z=I();return<Ut.View style={{position:"relative"}}>
|
|
425
407
|
{}
|
|
426
|
-
<
|
|
427
|
-
<
|
|
408
|
+
<Ut.View style={[P,{borderRadius:R.borderRadius.full,backgroundColor:R.colors.gray[200],alignItems:"center",justifyContent:"center"}]}>
|
|
409
|
+
<Ut.Text style={{fontSize:A(),color:R.colors.text}}>
|
|
428
410
|
{M}
|
|
429
|
-
</
|
|
430
|
-
</
|
|
411
|
+
</Ut.Text>
|
|
412
|
+
</Ut.View>
|
|
431
413
|
|
|
432
414
|
{}
|
|
433
|
-
{
|
|
434
|
-
</
|
|
435
|
-
<
|
|
436
|
-
<
|
|
437
|
-
</
|
|
415
|
+
{T&&<Ut.View style={[z,{position:"absolute",bottom:-2,right:-2,backgroundColor:R.colors.online,borderRadius:R.borderRadius.full,borderWidth:2,borderColor:R.colors.background}]}/>}
|
|
416
|
+
</Ut.View>},Ro=Vr;var Dr=({item:M,onPress:T})=>{let C=$(),R=M.unreadCount&&M.unreadCount>0;return<Ue.TouchableOpacity style={{flexDirection:"row",alignItems:"center",paddingHorizontal:C.spacing.lg,paddingVertical:C.spacing.md,borderBottomWidth:1,borderBottomColor:C.colors.borderLight,backgroundColor:R?C.colors.unread:C.colors.background}}onPress={()=>T(M)}>
|
|
417
|
+
<Ue.View style={{marginRight:C.spacing.md}}>
|
|
418
|
+
<Ro avatar={M.avatar}isOnline={M.isOnline}size="medium"/>
|
|
419
|
+
</Ue.View>
|
|
438
420
|
|
|
439
|
-
<
|
|
421
|
+
<Ue.View style={{flex:1,marginRight:C.spacing.md}}>
|
|
440
422
|
{}
|
|
441
|
-
<
|
|
442
|
-
<
|
|
423
|
+
<Ue.View style={{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:C.spacing.xs}}>
|
|
424
|
+
<Ue.Text style={{fontSize:C.typography.fontSize.base,flex:1,fontWeight:R?C.typography.fontWeight.bold:C.typography.fontWeight.semibold,color:C.colors.text}}>
|
|
443
425
|
{M.name}
|
|
444
|
-
</
|
|
445
|
-
<
|
|
426
|
+
</Ue.Text>
|
|
427
|
+
<Ue.Text style={{fontSize:C.typography.fontSize.sm,marginLeft:C.spacing.sm,color:R?C.colors.gray[700]:C.colors.textSecondary,fontWeight:R?C.typography.fontWeight.medium:C.typography.fontWeight.normal}}>
|
|
446
428
|
{M.time}
|
|
447
|
-
</
|
|
448
|
-
</
|
|
429
|
+
</Ue.Text>
|
|
430
|
+
</Ue.View>
|
|
449
431
|
|
|
450
432
|
{}
|
|
451
|
-
<
|
|
452
|
-
<
|
|
433
|
+
<Ue.View style={{flexDirection:"row",alignItems:"center"}}>
|
|
434
|
+
<Ue.Text style={{fontSize:C.typography.fontSize.sm,flex:1,color:R?C.colors.gray[800]:C.colors.textSecondary,fontWeight:R?C.typography.fontWeight.medium:C.typography.fontWeight.normal}}numberOfLines={1}>
|
|
453
435
|
{M.message}
|
|
454
|
-
</
|
|
455
|
-
{M.unreadCount&&<
|
|
456
|
-
<
|
|
436
|
+
</Ue.Text>
|
|
437
|
+
{M.unreadCount&&<Ue.View style={{width:20,height:20,backgroundColor:C.colors.primary,borderRadius:C.borderRadius.full,alignItems:"center",justifyContent:"center",marginLeft:C.spacing.sm}}>
|
|
438
|
+
<Ue.Text style={{fontSize:C.typography.fontSize.xs,color:"white",fontWeight:C.typography.fontWeight.bold}}>
|
|
457
439
|
{M.unreadCount}
|
|
458
|
-
</
|
|
459
|
-
</
|
|
460
|
-
</
|
|
461
|
-
</
|
|
462
|
-
</
|
|
463
|
-
<
|
|
440
|
+
</Ue.Text>
|
|
441
|
+
</Ue.View>}
|
|
442
|
+
</Ue.View>
|
|
443
|
+
</Ue.View>
|
|
444
|
+
</Ue.TouchableOpacity>},To=Dr;var kr=({chats:M,onChatPress:T})=>{let C=({item:R})=><To item={R}onPress={T}/>;return<qs.FlatList data={M}renderItem={C}keyExtractor={R=>R.id}showsVerticalScrollIndicator={!1}style={{flex:1}}/>},ls=kr;var qo=require("react-native");var Lr=({title:M})=>{let T=$();return<qo.View style={{backgroundColor:T.colors.background,paddingHorizontal:T.spacing.lg,paddingVertical:T.spacing.lg,borderBottomWidth:1,borderBottomColor:T.colors.borderLight}}>
|
|
445
|
+
<qo.Text style={{fontSize:T.typography.fontSize.xxl,fontWeight:T.typography.fontWeight.bold,color:T.colors.text}}>
|
|
464
446
|
{M}
|
|
465
|
-
</
|
|
466
|
-
</
|
|
467
|
-
<
|
|
468
|
-
<
|
|
469
|
-
|
|
470
|
-
</
|
|
447
|
+
</qo.Text>
|
|
448
|
+
</qo.View>},cs=Lr;var Mt=require("react-native"),$o=require("lucide-react-native");var Er=({value:M,onChangeText:T,onClear:C,placeholder:R="Search chats..."})=>{let S=$();return<Mt.View style={{backgroundColor:S.colors.background,paddingHorizontal:S.spacing.lg,paddingVertical:S.spacing.md,borderBottomWidth:1,borderBottomColor:S.colors.borderLight}}>
|
|
449
|
+
<Mt.View style={{position:"relative"}}>
|
|
450
|
+
<Mt.View style={{position:"absolute",left:S.spacing.md,top:"50%",transform:[{translateY:-10}],zIndex:10}}>
|
|
451
|
+
<$o.Search size={20}color={S.colors.textMuted}/>
|
|
452
|
+
</Mt.View>
|
|
471
453
|
|
|
472
|
-
<
|
|
454
|
+
<Mt.TextInput value={M}onChangeText={T}placeholder={R}placeholderTextColor={S.colors.textMuted}style={{backgroundColor:S.colors.surfaceSecondary,borderRadius:S.borderRadius.full,paddingLeft:48,paddingRight:40,paddingVertical:S.spacing.md,color:S.colors.text,fontSize:S.typography.fontSize.base}}autoCapitalize="none"autoCorrect={!1}clearButtonMode="never"/>
|
|
473
455
|
|
|
474
|
-
{M.length>0&&<
|
|
475
|
-
|
|
476
|
-
</
|
|
477
|
-
</
|
|
478
|
-
</
|
|
456
|
+
{M.length>0&&<Mt.TouchableOpacity onPress={C}style={{position:"absolute",right:S.spacing.md,top:"50%",transform:[{translateY:-10}]}}hitSlop={{top:10,bottom:10,left:10,right:10}}>
|
|
457
|
+
<$o.X size={20}color={S.colors.textMuted}/>
|
|
458
|
+
</Mt.TouchableOpacity>}
|
|
459
|
+
</Mt.View>
|
|
460
|
+
</Mt.View>},ds=Er;var ct=require("react"),Yo=Q(require("dayjs")),St=(0,Yo.default)(),$s=St.subtract(1,"day"),Ys=St.subtract(2,"day"),Gs=St.subtract(3,"day"),jr=[{id:1,text:"Hi! How are you?",isMe:!1,timestamp:Gs.hour(10).minute(30).toISOString(),senderName:"Anna"},{id:2,text:"Hey! Great, thanks! And you?",isMe:!0,timestamp:Gs.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:Ys.hour(14).minute(20).toISOString(),senderName:"Anna"},{id:4,text:"Maybe we could go to the movies?",isMe:!0,timestamp:Ys.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:$s.hour(9).minute(15).toISOString(),senderName:"Anna"},{id:6,text:"Great! What movies are you interested in?",isMe:!0,timestamp:$s.hour(9).minute(20).toISOString()},{id:7,text:"Maybe something action or comedy?",isMe:!1,timestamp:St.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:St.hour(8).minute(35).toISOString()},{id:9,text:"Perfect! What time should we meet?",isMe:!1,timestamp:St.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:St.hour(9).minute(15).toISOString(),reactions:[{emoji:"\u{1F44D}",count:1,users:["anna"]},{emoji:"\u23F0",count:1,users:["me"]}]}],us=M=>{let T=jr.map(v=>v.isMe?v:{...v,senderName:M||v.senderName}),[C,R]=(0,ct.useState)(T),S=(0,ct.useCallback)((v,B)=>{if(console.log("sendMessage called with text:",v,"and replyTo:",B),!v.trim())return;let V={id:Date.now(),text:v.trim(),isMe:!0,timestamp:(0,Yo.default)().toISOString(),status:"sent",replyTo:B};R(D=>[...D,V]),setTimeout(()=>{R(D=>D.map(k=>k.id===V.id?{...k,status:"delivered"}:k))},1e3),setTimeout(()=>{R(D=>D.map(k=>k.id===V.id?{...k,status:"read"}:k))},3e3)},[]),A=(0,ct.useCallback)((v,B,V)=>{let D={id:Date.now(),text:B||"",isMe:!0,timestamp:(0,Yo.default)().toISOString(),status:"sent",type:"image",imageData:v,replyTo:V};R(k=>[...k,D]),setTimeout(()=>{R(k=>k.map(L=>L.id===D.id?{...L,status:"delivered"}:L))},1e3),setTimeout(()=>{R(k=>k.map(L=>L.id===D.id?{...L,status:"read"}:L))},3e3)},[]),I=(0,ct.useCallback)((v,B)=>{R(V=>V.map(D=>D.id===v?{...D,status:B}:D))},[]),P=(0,ct.useCallback)((v,B)=>{R(V=>V.map(D=>{if(D.id===v){let k=D.reactions||[],L=k.findIndex(O=>O.emoji===B);if(L>=0){let O=[...k];return O[L]={...O[L],count:O[L].count+1,users:[...O[L].users,"me"]},{...D,reactions:O}}else{let O={emoji:B,count:1,users:["me"]};return{...D,reactions:[...k,O]}}}return D}))},[]),z=(0,ct.useCallback)((v,B)=>{console.log("removeReaction 1212121 called with messageId:",v,"and emoji:",B),R(V=>V.map(D=>{if(D.id===v){let k=D.reactions||[],L=k.findIndex(O=>O.emoji===B);if(L>=0){let O=k[L];if(O.count>1){let H=[...k];return H[L]={...O,count:O.count-1,users:O.users.filter(F=>F!=="me")},{...D,reactions:H}}else return{...D,reactions:k.filter(H=>H.emoji!==B)}}}return D}))},[]),j=(0,ct.useCallback)(v=>{console.log("deleteMessage called with messageId:",v),R(B=>{let V=B.map(D=>D.id===v?{...D,deleted:!0}:D);return console.log("Message marked as deleted:",v),V})},[]);return{messages:C,sendMessage:S,sendImageMessage:A,updateMessageStatus:I,addReaction:P,deleteMessage:j,removeReaction:z}};var Ke=require("react");var ms=(M={})=>{wt();let[T,C]=(0,Ke.useState)(M.initialMessages||[]),[R,S]=(0,Ke.useState)(!1),A=(0,Ke.useCallback)((k,L)=>{let O={id:Date.now(),text:k,isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:L?{id:L.id,text:L.text,senderName:L.senderName,isMe:L.isMe}:void 0};C(H=>[O,...H])},[]),I=(0,Ke.useCallback)(k=>{C(L=>[k,...L])},[]),P=(0,Ke.useCallback)((k,L)=>{C(O=>O.map(H=>H.id===k?{...H,...L}:H))},[]),z=(0,Ke.useCallback)(k=>{C(L=>L.filter(O=>O.id!==k))},[]),j=(0,Ke.useCallback)((k,L)=>{C(O=>O.map(H=>{if(H.id!==k)return H;let F=H.reactions||[];if(F.find(E=>E.emoji===L))return{...H,reactions:F.map(E=>E.emoji===L?{...E,count:E.count+1,users:[...E.users,"current-user"]}:E)};{let E={emoji:L,count:1,users:["current-user"]};return{...H,reactions:[...F,E]}}}))},[]),v=(0,Ke.useCallback)((k,L)=>{C(O=>O.map(H=>{if(H.id!==k)return H;let F=H.reactions||[],N=F.find(E=>E.emoji===L);return N?N.count<=1?{...H,reactions:F.filter(E=>E.emoji!==L)}:{...H,reactions:F.map(E=>E.emoji===L?{...E,count:E.count-1,users:E.users.filter(te=>te!=="current-user")}:E)}:H}))},[]),B=(0,Ke.useCallback)(k=>{S(k)},[]),V=(0,Ke.useCallback)(()=>{C(M.initialMessages||[]),S(!1)},[M.initialMessages]),D=(0,Ke.useCallback)(k=>T.find(L=>L.id===k),[T]);return{messages:T,isTyping:R,sendMessage:A,addReaction:j,removeReaction:v,setMessages:C,addMessage:I,updateMessage:P,deleteMessage:z,setTyping:B,resetChat:V,getMessageById:D}};var Go=require("react");var Or=Ee(Qo),Hr=Ee(Xo),Fr=nt(qt),Nr=Ee(mt),Wr=Ee(ut),Ur=Ee(Po),Kr=Ee(Et),qr=Ee(ls),$r=Ee(To),Yr=Ee(cs),Gr=Ee(ds),_r=Ee(Ro),Jr=Ee(Tt),Xr=Ee(Ss),Qr=nt($),Zr=nt(ms),en=nt(us),tn=nt(Jt),on=nt(Xt),sn=nt(Qt),rn=nt($t),nn=nt(_t);0&&(module.exports={AttachmentMenu,Chat,ChatAvatar,ChatHeader,ChatItem,ChatList,ChatListSearchBar,ChatProvider,ChatScreenHeader,MessageInput,MessageList,ThemeProvider,TypingIndicator,defaultTheme,getAuthState,getProjectId,initChat,isInitialized,useAttachments,useChatConfig,useChatMessages,useChatSDK,useMessageActions,useMessageInput,useMessageList,useMessageReactions,useTheme});
|