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