@usechat/react-native 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +16 -6
- package/dist/index.d.ts +16 -6
- package/dist/index.js +259 -256
- package/dist/index.mjs +310 -307
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var da=Object.create;var Bo=Object.defineProperty;var ua=Object.getOwnPropertyDescriptor;var ma=Object.getOwnPropertyNames;var pa=Object.getPrototypeOf,ga=Object.prototype.hasOwnProperty;var ha=(C,S)=>()=>(C&&(S=C(C=0)),S);var vs=(C,S)=>{for(var T in S)Bo(C,T,{get:S[T],enumerable:!0})},Ps=(C,S,T,M)=>{if(S&&typeof S=="object"||typeof S=="function")for(let R of ma(S))!ga.call(C,R)&&R!==T&&Bo(C,R,{get:()=>S[R],enumerable:!(M=ua(S,R))||M.enumerable});return C};var Y=(C,S,T)=>(T=C!=null?da(pa(C)):{},Ps(S||!C||!C.__esModule?Bo(T,"default",{value:C,enumerable:!0}):T,C)),fa=C=>Ps(Bo({},"__esModule",{value:!0}),C);var ta={};vs(ta,{copyToClipboard:()=>Ka,isClipboardAvailable:()=>$a});var Ka,$a,oa=ha(()=>{"use strict";Ka=async C=>{console.log("copyToClipboard called with text:",C);try{try{let{setStringAsync:S}=await import("expo-clipboard");console.log("expo-clipboard imported successfully"),console.log("setStringAsync function:",S),await S(C),console.log("Text copied to clipboard successfully")}catch(S){throw console.error("Failed to import expo-clipboard:",S),new Error("expo-clipboard not available")}try{let S=await import("react-native-toast-message"),T=S.default||S;console.log("react-native-toast-message imported successfully"),T.show({type:"success",text1:"Copied to clipboard",text2:"Message copied successfully",position:"bottom",visibilityTime:2e3}),console.log("Toast shown successfully")}catch(S){console.log("Toast not available, but message copied to clipboard"),console.error("Toast import error:",S)}return!0}catch(S){console.error("Failed to copy to clipboard:",S);try{let T=await import("react-native-toast-message");(T.default||T).show({type:"error",text1:"Copy failed",text2:"Failed to copy message to clipboard",position:"bottom",visibilityTime:2e3})}catch(T){console.error("Copy failed: expo-clipboard not available"),console.error("Toast import error:",T)}return!1}},$a=async()=>{try{return await import("expo-clipboard"),!0}catch{return!1}}});var Rn={};vs(Rn,{AttachmentMenu:()=>pn,Chat:()=>en,ChatAvatar:()=>mn,ChatHeader:()=>dn,ChatItem:()=>cn,ChatList:()=>ln,ChatListSearchBar:()=>un,ChatProvider:()=>tn,ChatScreenHeader:()=>nn,I18nProvider:()=>Xt,MessageInput:()=>an,MessageList:()=>sn,ThemeProvider:()=>gn,TypingIndicator:()=>rn,defaultTheme:()=>Dt,defaultTranslations:()=>Gt,getAuthState:()=>Ds,getInitStatus:()=>Eo,getProjectId:()=>Vs,getTranslation:()=>zt,initChat:()=>Bs,isInitialized:()=>Lo,isInitializing:()=>jo,isSupportedLocale:()=>Jt,useAttachments:()=>Tn,useChatConfig:()=>on,useChatMessages:()=>yn,useChatSDK:()=>fn,useDateFormatter:()=>Sn,useMessageActions:()=>bn,useMessageInput:()=>Mn,useMessageList:()=>xn,useMessageReactions:()=>Cn,useTheme:()=>hn,useTranslation:()=>ds,useTranslationFunction:()=>ke});module.exports=fa(Rn);var Ge={status:"idle",projectId:null,error:null},As=()=>{Ge={status:"pending",projectId:null,error:null}},zs=C=>{Ge={status:"success",projectId:C,error:null}},ko=C=>{Ge={status:"error",projectId:null,error:C}};var Ds=()=>({...Ge}),At=()=>{if(Ge.status==="error")throw new Error(`UseChat SDK: Invalid Project ID
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
${Ge.error}
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
import { initChat } from '@usechat/react-native';
|
|
8
|
-
await initChat({ projectId: 'your-project-id' });`);if(!lt.isInitialized)throw new Error(`UseChat SDK is not initialized.
|
|
6
|
+
Please check your project ID in the UseChat dashboard: https://app.usechat.dev`);if(Ge.status==="idle")throw new Error(`UseChat SDK is not initialized.
|
|
9
7
|
|
|
10
|
-
Please call initChat() with
|
|
8
|
+
Please call initChat() with your project ID before using any UseChat components.
|
|
11
9
|
|
|
12
10
|
Example:
|
|
13
11
|
import { initChat } from '@usechat/react-native';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
|
|
13
|
+
// In your app entry point (_layout.tsx or App.tsx):
|
|
14
|
+
await initChat({ projectId: 'your-project-id' });`);return Ge.status==="pending"?"pending":"ready"},Vs=()=>{if(At()==="pending")throw new Error("SDK is still initializing");return Ge.projectId},Lo=()=>Ge.status==="success",jo=()=>Ge.status==="pending",Eo=()=>Ge.status;var ya="https://usechat.dev/api/validate-project",_t=null,Bs=async C=>{let{projectId:S,apiUrl:T=ya,debug:M=!1}=C;if(Lo())return M&&console.log(`[UseChat SDK] Already initialized with projectId: ${S}`),{success:!0,message:"Chat SDK already initialized",projectId:S,activatedAt:new Date().toISOString()};if(jo()&&_t)return M&&console.log("[UseChat SDK] Initialization already in progress..."),_t;if(!S||typeof S!="string"||S.trim()===""){let R="Project ID is required";throw ko(R),new Error(`[UseChat SDK] ${R}`)}return As(),M&&console.log(`[UseChat SDK] Initializing with projectId: ${S}`),_t=(async()=>{try{let R=await fetch(`${T}?projectId=${S}`,{method:"GET",headers:{"Content-Type":"application/json"}}),A=await R.json();if(!R.ok){let I=A.error||`Project ID "${S}" not found. Please check your project ID.`;throw ko(I),new Error(`[UseChat SDK] ${I}`)}return zs(S),M&&console.log(`[UseChat SDK] Successfully initialized with project: ${A.name}`),{success:!0,message:`Chat SDK initialized with project: ${A.name}`,projectId:S,projectName:A.name,activatedAt:new Date().toISOString()}}catch(R){if(R instanceof Error&&R.message.startsWith("[UseChat SDK]"))throw R;let A="Failed to initialize SDK. Please check your network connection.";throw ko(A),new Error(`[UseChat SDK] ${A}`)}finally{_t=null}})(),_t};var Pe=Y(require("react")),it=require("react-native");var Fo=require("react"),ks=require("react-native"),Oo=require("react-native-keyboard-controller");var nt=require("react");var xa={"input.placeholder":"Type a message...","search.placeholder":"Search chats...","status.online":"Online","status.offline":"Offline","status.typing":"typing...","message.deleted":"This message was deleted","message.sending":"Sending...","message.sent":"Sent","message.delivered":"Delivered","message.read":"Read","message.failed":"Failed to send","action.reply":"Reply","action.copy":"Copy","action.delete":"Delete","action.cancel":"Cancel","action.send":"Send","action.clear":"Clear","action.clearAll":"Clear All","attachment.add":"Add attachment","attachment.remove":"Remove","attachment.clear":"Clear","attachment.attachments":"Attachments:","accessibility.back":"Go back","accessibility.send":"Send message","accessibility.attach":"Add attachment","accessibility.emoji":"Add emoji","accessibility.videoCall":"Start video call","accessibility.voiceCall":"Start voice call","accessibility.info":"Chat info","accessibility.search":"Search chats","accessibility.typing":"Someone is typing","error.fileTooLarge":"File is too large","error.invalidFileType":"Invalid file type","error.maxAttachments":"Maximum attachments reached","error.networkError":"Network error occurred","time.justNow":"Just now","time.minutesAgo":"{{count}} min ago","time.hoursAgo":"{{count}}h ago","time.daysAgo":"{{count}}d ago","time.weeksAgo":"{{count}}w ago","time.monthsAgo":"{{count}}mo ago","time.yearsAgo":"{{count}}y ago","date.today":"Today","date.yesterday":"Yesterday","date.todayWithTime":"Today {{time}}","date.yesterdayWithTime":"Yesterday {{time}}"},ba={"input.placeholder":"Napisz wiadomo\u015B\u0107...","search.placeholder":"Szukaj czat\xF3w...","status.online":"Online","status.offline":"Offline","status.typing":"pisze...","message.deleted":"Ta wiadomo\u015B\u0107 zosta\u0142a usuni\u0119ta","message.sending":"Wysy\u0142anie...","message.sent":"Wys\u0142ano","message.delivered":"Dostarczono","message.read":"Przeczytano","message.failed":"Nie uda\u0142o si\u0119 wys\u0142a\u0107","action.reply":"Odpowiedz","action.copy":"Kopiuj","action.delete":"Usu\u0144","action.cancel":"Anuluj","action.send":"Wy\u015Blij","action.clear":"Wyczy\u015B\u0107","action.clearAll":"Wyczy\u015B\u0107 wszystko","attachment.add":"Dodaj za\u0142\u0105cznik","attachment.remove":"Usu\u0144","attachment.clear":"Wyczy\u015B\u0107","attachment.attachments":"Za\u0142\u0105czniki:","accessibility.back":"Wr\xF3\u0107","accessibility.send":"Wy\u015Blij wiadomo\u015B\u0107","accessibility.attach":"Dodaj za\u0142\u0105cznik","accessibility.emoji":"Dodaj emoji","accessibility.videoCall":"Rozpocznij wideorozmow\u0119","accessibility.voiceCall":"Rozpocznij rozmow\u0119 g\u0142osow\u0105","accessibility.info":"Informacje o czacie","accessibility.search":"Szukaj czat\xF3w","accessibility.typing":"Kto\u015B pisze","error.fileTooLarge":"Plik jest za du\u017Cy","error.invalidFileType":"Nieprawid\u0142owy typ pliku","error.maxAttachments":"Osi\u0105gni\u0119to maksymaln\u0105 liczb\u0119 za\u0142\u0105cznik\xF3w","error.networkError":"Wyst\u0105pi\u0142 b\u0142\u0105d sieci","time.justNow":"W\u0142a\u015Bnie teraz","time.minutesAgo":"{{count}} min temu","time.hoursAgo":"{{count}}h temu","time.daysAgo":"{{count}}d temu","time.weeksAgo":"{{count}}t temu","time.monthsAgo":"{{count}}mies temu","time.yearsAgo":"{{count}}l temu","date.today":"Dzisiaj","date.yesterday":"Wczoraj","date.todayWithTime":"Dzisiaj {{time}}","date.yesterdayWithTime":"Wczoraj {{time}}"},Gt={en:xa,pl:ba},zt=C=>Gt[C]||Gt.en,Jt=C=>C==="en"||C==="pl";var cs=(0,nt.createContext)(void 0),Xt=({children:C,locale:S="en",fallbackLocale:T="en"})=>{let[M,R]=(0,nt.useState)(S),A=(0,nt.useCallback)((V,E={})=>{let B=zt(M)[V];return!B&&M!==T&&(B=zt(T)[V]),B?B.replace(/\{\{(\w+)\}\}/g,(k,z)=>E[z]?.toString()||k):(console.warn(`Translation missing for key: ${V} in locale: ${M}`),V)},[M,T]),I=(0,nt.useCallback)(V=>{Jt(V)?R(V):(console.warn(`Unsupported locale: ${V}. Falling back to 'en'`),R("en"))},[]),P={t:A,locale:M,setLocale:I};return<cs.Provider value={P}>
|
|
15
|
+
{C}
|
|
16
|
+
</cs.Provider>},ds=()=>{let C=(0,nt.useContext)(cs);if(!C)throw new Error("useTranslation must be used within an I18nProvider");return C},ke=()=>{let C=(0,nt.useContext)(cs);return C?C.t:S=>S};var Ls=(0,Fo.createContext)(null),Ca=({children:C,config:S={},locale:T="en"})=>{let M={keyboardBehavior:"padding",keyboardVerticalOffset:60,enableReactionDetails:!0,enableMessageActions:!0,enableScrollToBottom:!0,enableTypingIndicator:!0,...S};return<Xt locale={T}>
|
|
17
|
+
<Ls.Provider value={{config:M}}>
|
|
18
|
+
<Oo.KeyboardProvider>
|
|
19
|
+
<Oo.KeyboardAvoidingView behavior={M.keyboardBehavior}style={[Ta.keyboardContainer]}keyboardVerticalOffset={M.keyboardVerticalOffset}>
|
|
20
20
|
{}
|
|
21
|
-
{
|
|
22
|
-
</
|
|
23
|
-
</
|
|
24
|
-
</
|
|
25
|
-
|
|
26
|
-
{N||<
|
|
21
|
+
{C}
|
|
22
|
+
</Oo.KeyboardAvoidingView>
|
|
23
|
+
</Oo.KeyboardProvider>
|
|
24
|
+
</Ls.Provider>
|
|
25
|
+
</Xt>},us=Ca,Zt=()=>{let C=(0,Fo.useContext)(Ls);if(!C)throw new Error("useChatConfig must be used within a ChatProvider");return C.config},Ta=ks.StyleSheet.create({container:{flex:1},keyboardContainer:{flex:1,overflow:"hidden"}});var rt=require("react"),Qt=(C={})=>{let{uploader:S,maxAttachments:T=10,maxFileSize:M=10*1024*1024,allowedTypes:R=["image/*","application/pdf","text/*"],onAttachmentAdd:A,onAttachmentRemove:I,onAttachmentUpload:P}=C,[V,E]=(0,rt.useState)([]),[v,B]=(0,rt.useState)(!1),[k,z]=(0,rt.useState)(0),D=(0,rt.useCallback)(N=>{if(V.length>=T){console.warn(`Maximum ${T} attachments allowed`);return}if(N.data?.size&&N.data.size>M){console.warn(`File size exceeds ${M/(1024*1024)}MB limit`);return}if(N.data?.type&&!R.some(je=>je.endsWith("/*")?N.data.type.startsWith(je.slice(0,-1)):N.data.type===je)){console.warn(`File type ${N.data.type} not allowed`);return}let F={...N,id:N.id||`att_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,uploadStatus:"pending",uploadProgress:0};E(te=>[...te,F]),A&&A(F)},[V.length,T,M,R,A]),L=(0,rt.useCallback)(N=>{E(F=>F.filter(te=>te.id!==N)),I&&I(N)},[I]),O=(0,rt.useCallback)(()=>{E([])},[]),j=(0,rt.useCallback)(async N=>{try{let F;switch(N){case"image":F={type:"image",data:{uri:"mock-image-uri",width:800,height:600,fileName:"image.jpg",fileSize:1024*1024}};break;case"document":F={type:"document",data:{uri:"mock-document-uri",name:"document.pdf",size:2048*1024,mimeType:"application/pdf"}};break;case"location":F={type:"location",data:{coordinates:{latitude:0,longitude:0},address:"Mock Address",timestamp:Date.now()}};break;case"contact":F={type:"contact",data:{id:"contact-1",name:"John Doe",phoneNumbers:["+1234567890"],emails:["john@example.com"]}};break;default:throw new Error(`Unsupported attachment type: ${N}`)}let te={id:`att_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,type:N,data:F.data,fileName:F.data.fileName||F.data.name,fileSize:F.data.fileSize||F.data.size,mimeType:F.data.mimeType,uploadStatus:"pending",uploadProgress:0};D(te)}catch(F){console.error("Error opening picker:",F)}},[D]),H=(0,rt.useCallback)(async()=>{if(!S)return console.warn("No uploader provided, skipping upload"),V;if(V.length===0)return[];B(!0),z(0);try{let N=V.map(async(Ce,Ee)=>{try{E(qe=>qe.map(U=>U.id===Ce.id?{...U,uploadStatus:"uploading",uploadProgress:0}:U));let Te=setInterval(()=>{E(qe=>qe.map(U=>U.id===Ce.id?{...U,uploadProgress:Math.min((U.uploadProgress??0)+10,90)}:U))},100),Be=await S.upload(Ce.data);clearInterval(Te);let Ae={...Ce,uploadStatus:"completed",uploadProgress:100,data:{...Ce.data,url:Be.url,metadata:Be.metadata}};return E(qe=>qe.map(U=>U.id===Ce.id?Ae:U)),Ae}catch(Te){return console.error(`Error uploading attachment ${Ce.id}:`,Te),E(Be=>Be.map(Ae=>Ae.id===Ce.id?{...Ae,uploadStatus:"failed",uploadProgress:0}:Ae)),{...Ce,uploadStatus:"failed",uploadProgress:0}}}),F=await Promise.all(N),je=F.filter(Ce=>Ce.uploadStatus==="completed").length/F.length*100;return z(je),P&&P(F),F}catch(N){return console.error("Error uploading attachments:",N),V}finally{B(!1)}},[V,S,P]);return{attachments:V,openPicker:j,addAttachment:D,removeAttachment:L,clearAttachments:O,uploadAttachments:H,isUploading:v,uploadProgress:k}};var Je=require("react"),js=(C={})=>{let{onSend:S,onFocus:T,initialValue:M="",maxLength:R=1e3}=C,[A,I]=(0,Je.useState)(M),[P,V]=(0,Je.useState)(40),[E,v]=(0,Je.useState)(!1),B=(0,Je.useCallback)(H=>{H.length<=R&&I(H)},[R]),k=(0,Je.useCallback)(H=>{if(!A.trim()&&(!H||H.length===0))return;let N=A.trim();S&&S(N,H),I(""),V(40)},[A,S]),z=(0,Je.useCallback)(()=>{v(!0),T&&T()},[T]),D=(0,Je.useCallback)(()=>{v(!1)},[]),L=(0,Je.useCallback)(H=>{V(Math.max(40,Math.min(H,120)))},[]),O=(0,Je.useCallback)(()=>{I(""),V(40)},[]),j=(0,Je.useCallback)(H=>{I(H)},[]);return{message:A,composerHeight:P,isFocused:E,handleTextChange:B,handleSend:k,handleFocus:z,handleBlur:D,handleContentSizeChange:L,clearMessage:O,setMessage:j}};var Ma=({messages:C,components:S={},renderProps:T={},onMessageSend:M,onReactionAdd:R,onReactionRemove:A,onMessageDelete:I,onActionPress:P,attachmentUploader:V,maxAttachments:E=10,maxFileSize:v=10*1024*1024,allowedFileTypes:B=["image/*","application/pdf","text/*"],enableReactionDetails:k,enableMessageActions:z=!0,enableScrollToBottom:D,enableTypingIndicator:L,isTyping:O=!1,typingUserName:j,isLoading:H=!1,loadingComponent:N})=>{let F=Zt(),[te,je]=(0,Pe.useState)(!1),Ce=S.MessageList||pt,Ee=S.MessageInput||mt,Te=k??F.enableReactionDetails??!0,Be=z??F.enableMessageActions??!0,Ae=D??F.enableScrollToBottom??!0,qe=L??F.enableTypingIndicator??!0,[U,Ye]=(0,Pe.useState)(null),Fe=(0,Pe.useRef)(null),[Mt,Me]=(0,Pe.useState)(C||[]),_e=(0,Pe.useRef)((C||[]).length+1);Pe.default.useEffect(()=>{C&&(Me(C),_e.current=C.length+1)},[C]),Pe.default.useEffect(()=>{if(U&&Fe.current){let K=setTimeout(()=>{Fe.current?.focus()},150);return()=>clearTimeout(K)}},[U]);let Ze=Qt({uploader:V,maxAttachments:E,maxFileSize:v,allowedTypes:B}),we=js({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 $=G[0],ve={id:_e.current++,text:K.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:X,attachments:G,type:$.type==="image"?"image":"text",...$.type==="image"&&$.data&&{imageData:{uri:$.data.uri||"",width:$.data.width||300,height:$.data.height||200,fileName:$.fileName||"image.jpg",fileSize:$.fileSize||0}}};Me(Qe=>[...Qe,ve]),M&&M(ve)}else{let $={id:_e.current++,text:K.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:X};Me(ve=>[...ve,$]),M&&M($)}Ye(null)}else if(G&&G.length>0){let X=G[0],$={id:_e.current++,text:K.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent",attachments:G,type:X.type==="image"?"image":"text",...X.type==="image"&&X.data&&{imageData:{uri:X.data.uri||"",width:X.data.width||300,height:X.data.height||200,fileName:X.fileName||"image.jpg",fileSize:X.fileSize||0}}};Me(ve=>[...ve,$]),M&&M($)}else{let X={id:_e.current++,text:K.trim(),isMe:!0,timestamp:new Date().toISOString(),status:"sent"};Me($=>[...$,X]),M&&M(X)}Ze.clearAttachments()},onFocus:()=>{}}),Pt=(0,Pe.useCallback)((K,G)=>{console.log("\u{1F525} Chat - addReaction called with messageId:",K,"and emoji:",G),Me(X=>X.map($=>$.id===K?$.reactions?.find(Qe=>Qe.emoji===G)?{...$,reactions:$.reactions?.map(Qe=>Qe.emoji===G?{...Qe,count:Qe.count+1,users:[...Qe.users,"currentUser"]}:Qe)}:{...$,reactions:[...$.reactions||[],{emoji:G,count:1,users:["currentUser"]}]}:$)),R&&R(K,G)},[R]),St=(0,Pe.useCallback)((K,G)=>{Me(X=>X.map($=>$.id===K?{...$,reactions:$.reactions?.map(ve=>ve.emoji===G?{...ve,count:Math.max(0,ve.count-1),users:ve.users.filter(Qe=>Qe!=="currentUser")}:ve).filter(ve=>ve.count>0)}:$)),A&&A(K,G)},[A]),ls=(0,Pe.useCallback)(K=>{Me(G=>G.map(X=>X.id===K?{...X,deleted:!0,text:"",reactions:void 0}:X)),I&&I(K)},[I]),ze=(0,Pe.useCallback)(()=>{Ye(null)},[]),Ne=(0,Pe.useCallback)(K=>{Ye(K),setTimeout(()=>{Fe.current?.focus()},100)},[]),Yt=(0,Pe.useCallback)(K=>{if(te)return;let{layout:G}=K.nativeEvent;G.height<=0||je(!0)},[te]);if(H)return<it.View style={Rt.container}>
|
|
26
|
+
{N||<it.View style={Rt.loadingContainer}>
|
|
27
27
|
{}
|
|
28
|
-
</
|
|
29
|
-
</
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
</
|
|
33
|
-
</
|
|
34
|
-
<
|
|
35
|
-
<
|
|
28
|
+
</it.View>}
|
|
29
|
+
</it.View>;if(!te)return<it.View style={Rt.container}>
|
|
30
|
+
<it.View style={Rt.chatContainer}onLayout={Yt}>
|
|
31
|
+
<it.View style={Rt.loadingContainer}>{N}</it.View>
|
|
32
|
+
</it.View>
|
|
33
|
+
</it.View>;let Is=T.renderInput;return<it.View style={Rt.container}>
|
|
34
|
+
<it.View style={Rt.fill}>
|
|
35
|
+
<Ce messages={Mt}isTyping={qe?O:!1}typingUserName={j}showScrollToBottom={Ae}isReplyActive={!!U}enableMessageActions={Be}enableReactionDetails={Te}onReactionAdd={Pt}onReactionRemove={St}onMessageDelete={ls}onReplyMessage={Ne}onActionPress={(K,G)=>{K==="reply"?Ne(G):P?.(K,G)}}/>
|
|
36
36
|
|
|
37
|
-
{
|
|
37
|
+
{Is?Is({value:we.message,onChangeText:we.handleTextChange,onSend:we.handleSend,onFocus:we.handleFocus,height:we.composerHeight,onContentSizeChange:we.handleContentSizeChange,replyToMessage:U,onCancelReply:ze,attachments:Ze.attachments,onAttachmentAdd:Ze.addAttachment,onAttachmentRemove:Ze.removeAttachment,onAttachmentUpload:Ze.uploadAttachments}):<Ee ref={Fe}value={we.message}onChangeText={we.handleTextChange}onSend={we.handleSend}onFocus={we.handleFocus}height={we.composerHeight}onContentSizeChange={we.handleContentSizeChange}replyToMessage={U}onCancelReply={ze}onAttachmentSend={(K,G)=>{let X=K.type==="image",$={id:_e.current++,text:G?.trim()||"",isMe:!0,timestamp:new Date().toISOString(),status:"sent",type:X?"image":"text",...X&&K.data&&{imageData:{uri:K.data.uri||"",width:K.data.width||300,height:K.data.height||200,fileName:K.data.fileName||K.data.name||"image.jpg",fileSize:K.data.fileSize||K.data.size||0}}};Me(ve=>[...ve,$]),M&&M($),we.handleTextChange("")}}/>}
|
|
38
38
|
|
|
39
39
|
{}
|
|
40
|
-
</
|
|
40
|
+
</it.View>
|
|
41
41
|
|
|
42
42
|
{}
|
|
43
|
-
</
|
|
43
|
+
</it.View>},Rt=it.StyleSheet.create({container:{flex:1},chatContainer:{flex:1,overflow:"hidden"},fill:{flex:1},loadingContainer:{flex:1,justifyContent:"center",alignItems:"center"}}),ms=Ma;var Ie=require("react-native"),gt=require("lucide-react-native");var Fs=require("react");var Ho=require("react");var Dt={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 ps=(0,Ho.createContext)(Dt),Sa=(C,S)=>({colors:{...C.colors,...S.colors},spacing:{...C.spacing,...S.spacing},borderRadius:{...C.borderRadius,...S.borderRadius},typography:{...C.typography,...S.typography}}),Es=({children:C,theme:S})=>{let T=(0,Ho.useMemo)(()=>S?Sa(Dt,S):Dt,[S]);return<ps.Provider value={T}>{C}</ps.Provider>};var q=()=>{let C=(0,Fs.useContext)(ps);if(!C)throw new Error("useTheme must be used within a ThemeProvider");return C};var Ra=({name:C="George Alan",isOnline:S=!0,onBack:T=()=>{},onVideoCall:M,onVoiceCall:R,onInfo:A})=>{let I=q(),P=ke();return<Ie.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}}>
|
|
44
44
|
<Ie.View style={{flex:1,flexDirection:"row",alignItems:"center"}}>
|
|
45
45
|
<Ie.TouchableOpacity onPress={T}style={{marginRight:I.spacing.md}}>
|
|
46
46
|
<gt.ArrowLeft size={24}color={I.colors.gray[700]}/>
|
|
@@ -54,15 +54,15 @@ await initChat({ projectId: 'your-project-id' });`)},Ts=()=>(vt(),lt.projectId),
|
|
|
54
54
|
👤
|
|
55
55
|
</Ie.Text>
|
|
56
56
|
</Ie.View>
|
|
57
|
-
{
|
|
57
|
+
{S&&<Ie.View style={{position:"absolute",bottom:-2,right:-2,height:12,width:12,borderRadius:I.borderRadius.full,borderWidth:1,borderColor:I.colors.background,backgroundColor:I.colors.online}}/>}
|
|
58
58
|
</Ie.View>
|
|
59
59
|
|
|
60
60
|
<Ie.View style={{flex:1}}>
|
|
61
61
|
<Ie.Text style={{fontSize:I.typography.fontSize.lg,fontWeight:I.typography.fontWeight.semibold,color:I.colors.text}}>
|
|
62
|
-
{
|
|
62
|
+
{C}
|
|
63
63
|
</Ie.Text>
|
|
64
64
|
<Ie.Text style={{fontSize:I.typography.fontSize.sm,color:I.colors.textSecondary}}>
|
|
65
|
-
{P(
|
|
65
|
+
{P(S?"status.online":"status.offline")}
|
|
66
66
|
</Ie.Text>
|
|
67
67
|
</Ie.View>
|
|
68
68
|
</Ie.View>
|
|
@@ -70,217 +70,217 @@ await initChat({ projectId: 'your-project-id' });`)},Ts=()=>(vt(),lt.projectId),
|
|
|
70
70
|
|
|
71
71
|
<Ie.View style={{flexDirection:"row",alignItems:"center",gap:I.spacing.lg}}>
|
|
72
72
|
{}
|
|
73
|
-
{
|
|
73
|
+
{M&&<Ie.TouchableOpacity onPress={M}>
|
|
74
74
|
<gt.Video size={24}color={I.colors.gray[700]}/>
|
|
75
75
|
</Ie.TouchableOpacity>}
|
|
76
|
-
{
|
|
76
|
+
{R&&<Ie.TouchableOpacity onPress={R}>
|
|
77
77
|
<gt.Phone size={24}color={I.colors.gray[700]}/>
|
|
78
78
|
</Ie.TouchableOpacity>}
|
|
79
|
-
{
|
|
79
|
+
{A&&<Ie.TouchableOpacity onPress={A}>
|
|
80
80
|
<gt.Info size={24}color={I.colors.gray[700]}/>
|
|
81
81
|
</Ie.TouchableOpacity>}
|
|
82
82
|
</Ie.View>
|
|
83
|
-
</Ie.View>},
|
|
84
|
-
<
|
|
85
|
-
{
|
|
86
|
-
</
|
|
83
|
+
</Ie.View>},No=Ra;var _s=require("react"),Re=require("react-native");var et=Y(require("dayjs")),Os=Y(require("dayjs/plugin/isToday")),Hs=Y(require("dayjs/plugin/isYesterday")),Ns=Y(require("dayjs/plugin/relativeTime")),Ws=Y(require("dayjs/plugin/localizedFormat")),dr=require("dayjs/locale/pl"),ur=require("dayjs/locale/en");et.default.extend(Os.default);et.default.extend(Hs.default);et.default.extend(Ns.default);et.default.extend(Ws.default);var wa=(C,S="en")=>{let T=(0,et.default)(C).locale(S);return T.isToday()?S==="pl"?"Dzisiaj":"Today":T.isYesterday()?S==="pl"?"Wczoraj":"Yesterday":T.format("ddd D MMMM")},Us=(C,S,T="en")=>{let M=(0,et.default)(C).locale(T);return M.isToday()?S("date.today"):M.isYesterday()?S("date.yesterday"):M.format("ddd D MMMM")},Ia=C=>(0,et.default)(C).format("YYYY-MM-DD"),Wo=(C,S="en")=>{if(C.length===0)return[];let T=[],M=null;return C.forEach((R,A)=>{let I=Ia(R.timestamp);if(M!==I){let V=wa(R.timestamp,S),E={id:`date-${I}`,listItemType:"date-separator",date:I,displayDate:V};T.push(E),M=I}let P={...R,listItemType:"message"};T.push(P)}),T},eo=(C,S="en")=>(0,et.default)(C).locale(S).format("HH:mm"),Ks=(C,S="en")=>(0,et.default)(C).locale(S).fromNow();var $s=(C,S,T="en")=>{let M=(0,et.default)(C).locale(T);return M.isToday()?S("date.todayWithTime",{time:M.format("HH:mm")}):M.isYesterday()?S("date.yesterdayWithTime",{time:M.format("HH:mm")}):M.format("DD MMM YYYY HH:mm")};var tt=require("react-native");var va=({replyTo:C,isMyMessage:S})=>{let T=q(),M=(E,v=50)=>E.length<=v?E:E.substring(0,v)+"...",R=S?"rgba(255, 255, 255, 0.3)":T.colors.primary,A=S?"rgba(255, 255, 255, 0.8)":T.colors.primary,I=S?"rgba(255, 255, 255, 0.7)":T.colors.textSecondary,P=S?"rgba(255, 255, 255, 0.1)":T.colors.surfaceSecondary,V=C.type==="image"&&C.imageData;return<tt.View style={{marginBottom:T.spacing.sm,borderRadius:T.borderRadius.md,padding:T.spacing.sm,backgroundColor:P,borderLeftWidth:4,borderLeftColor:R}}>
|
|
84
|
+
<tt.Text style={{fontSize:T.typography.fontSize.xs,fontWeight:T.typography.fontWeight.medium,color:A,marginBottom:T.spacing.xs}}>
|
|
85
|
+
{C.isMe?"You":C.senderName||"Sender"}
|
|
86
|
+
</tt.Text>
|
|
87
87
|
|
|
88
|
-
{
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
<
|
|
88
|
+
{V?<tt.View style={{flexDirection:"row",alignItems:"center"}}>
|
|
89
|
+
<tt.Image source={{uri:C.imageData.uri}}style={{width:40,height:40,borderRadius:T.borderRadius.sm,marginRight:T.spacing.sm}}resizeMode="cover"/>
|
|
90
|
+
<tt.View style={{flex:1}}>
|
|
91
|
+
<tt.Text style={{fontSize:T.typography.fontSize.xs,color:I,fontStyle:"italic",marginBottom:T.spacing.xs}}>
|
|
92
92
|
📷 Image
|
|
93
|
-
</
|
|
94
|
-
{
|
|
95
|
-
{C
|
|
96
|
-
</
|
|
97
|
-
</
|
|
98
|
-
</
|
|
99
|
-
{C
|
|
100
|
-
</
|
|
101
|
-
</
|
|
102
|
-
<
|
|
93
|
+
</tt.Text>
|
|
94
|
+
{C.text&&C.text.trim()&&<tt.Text style={{fontSize:T.typography.fontSize.sm,color:I,lineHeight:T.typography.lineHeight.tight}}>
|
|
95
|
+
{M(C.text,30)}
|
|
96
|
+
</tt.Text>}
|
|
97
|
+
</tt.View>
|
|
98
|
+
</tt.View>:<tt.Text style={{fontSize:T.typography.fontSize.sm,color:I,lineHeight:T.typography.lineHeight.tight}}>
|
|
99
|
+
{M(C.text)}
|
|
100
|
+
</tt.Text>}
|
|
101
|
+
</tt.View>},Vt=va;var ct=require("react"),Se=require("react-native");var{width:gs,height:qs}=Se.Dimensions.get("window"),Pa=({imageData:C,isMe:S,onImagePress:T,onLongPress:M})=>{let R=q(),[A,I]=(0,ct.useState)(!1),[P,V]=(0,ct.useState)(!1),v=(0,ct.useCallback)(()=>{let O=gs*.6,j=300;if(!C.width||!C.height)return{width:O,height:j};let H=C.width/C.height,N=O,F=N/H;return F>j&&(F=j,N=F*H),{width:Math.round(N),height:Math.round(F)}},[C.width,C.height])(),B=(0,ct.useCallback)(()=>{T?T():I(!0)},[T]),k=(0,ct.useCallback)(()=>{console.error("Failed to load image:",C.uri),V(!0)},[C.uri]),z=(0,ct.useCallback)(()=>{I(!1)},[]),L=(0,ct.useCallback)(()=>{if(!C.width||!C.height)return{width:gs,height:qs*.8};let O=C.width/C.height,j=gs*.9,H=qs*.8,N=j,F=N/O;return F>H&&(F=H,N=F*O),{width:Math.round(N),height:Math.round(F)}},[C.width,C.height])();return P?<Se.View style={[ht.errorContainer,{width:v.width,height:v.height,backgroundColor:S?R.colors.messageBubble.sent:R.colors.messageBubble.received,borderRadius:R.borderRadius.lg}]}>
|
|
102
|
+
<Se.Text style={[ht.errorText,{color:S?R.colors.messageBubble.sentText:R.colors.messageBubble.receivedText,fontSize:R.typography.fontSize.sm}]}>
|
|
103
103
|
Failed to load image
|
|
104
|
-
</
|
|
105
|
-
</
|
|
106
|
-
<
|
|
107
|
-
<
|
|
108
|
-
<
|
|
104
|
+
</Se.Text>
|
|
105
|
+
</Se.View>:<>
|
|
106
|
+
<Se.Pressable onPress={B}onLongPress={M}delayLongPress={500}>
|
|
107
|
+
<Se.View style={[ht.imageContainer,{borderRadius:R.borderRadius.lg,overflow:"hidden"}]}>
|
|
108
|
+
<Se.Image source={{uri:C.uri}}style={[ht.image,{width:v.width,height:v.height}]}resizeMode='cover'onError={k}/>
|
|
109
109
|
|
|
110
110
|
{}
|
|
111
|
-
<
|
|
112
|
-
</
|
|
113
|
-
</
|
|
111
|
+
<Se.View style={ht.imageOverlay}/>
|
|
112
|
+
</Se.View>
|
|
113
|
+
</Se.Pressable>
|
|
114
114
|
|
|
115
115
|
{}
|
|
116
|
-
<
|
|
117
|
-
<
|
|
118
|
-
<
|
|
119
|
-
<
|
|
120
|
-
</
|
|
121
|
-
</
|
|
122
|
-
</
|
|
123
|
-
</>},ht=
|
|
124
|
-
<
|
|
125
|
-
<
|
|
126
|
-
<
|
|
127
|
-
<
|
|
128
|
-
{
|
|
129
|
-
</
|
|
130
|
-
</
|
|
131
|
-
</
|
|
132
|
-
<
|
|
133
|
-
<
|
|
134
|
-
{
|
|
135
|
-
</
|
|
136
|
-
</
|
|
137
|
-
</
|
|
138
|
-
<
|
|
139
|
-
{
|
|
116
|
+
<Se.Modal visible={A}transparent animationType='fade'onRequestClose={z}>
|
|
117
|
+
<Se.Pressable style={ht.modalContainer}onPress={z}>
|
|
118
|
+
<Se.View style={ht.modalContent}>
|
|
119
|
+
<Se.Image source={{uri:C.uri}}style={[ht.modalImage,{width:L.width,height:L.height,borderRadius:R.borderRadius.lg}]}resizeMode='contain'/>
|
|
120
|
+
</Se.View>
|
|
121
|
+
</Se.Pressable>
|
|
122
|
+
</Se.Modal>
|
|
123
|
+
</>},ht=Se.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"}}),Uo=Pa;var lt=require("react-native"),Ys=require("lucide-react-native");var Aa=({isMe:C,timestamp:S,senderName:T})=>{let M=q(),R=ke();return<lt.View style={[Bt.container,{alignSelf:C?"flex-end":"flex-start",maxWidth:"80%"}]}>
|
|
124
|
+
<lt.View style={[Bt.messageBubble,{backgroundColor:M.colors.gray[100],borderColor:M.colors.gray[200]}]}>
|
|
125
|
+
<lt.View style={Bt.content}>
|
|
126
|
+
<Ys.Trash2 size={16}color={M.colors.gray[500]}/>
|
|
127
|
+
<lt.Text style={[Bt.deletedText,{color:M.colors.gray[500]}]}>
|
|
128
|
+
{R("message.deleted")}
|
|
129
|
+
</lt.Text>
|
|
130
|
+
</lt.View>
|
|
131
|
+
</lt.View>
|
|
132
|
+
<lt.View style={[Bt.metadata,{alignSelf:C?"flex-end":"flex-start"}]}>
|
|
133
|
+
<lt.Text style={[Bt.timestamp,{color:M.colors.gray[400]}]}>
|
|
134
|
+
{S}
|
|
135
|
+
</lt.Text>
|
|
136
|
+
</lt.View>
|
|
137
|
+
</lt.View>},Bt=lt.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}}),Ko=Aa;var za=({message:C,onLongPress:S,onReactionPress:T})=>{let M=q(),R=(0,_s.useRef)(null),A=()=>{R.current?R.current.measureInWindow((V,E,v,B)=>{let k={x:Math.round(V),y:Math.round(E),width:Math.round(v),height:Math.round(B)};S?.(C,k)}):S?.(C)},I=()=>{C.reactions&&C.reactions.length>0&&T?.(C)},P=C.type==="image"&&C.imageData;return C.deleted?<Ko isMe={C.isMe}timestamp={eo(C.timestamp)}senderName={C.senderName}/>:<Re.View style={{marginBottom:M.spacing.md,alignItems:C.isMe?"flex-end":"flex-start",marginHorizontal:M.spacing.sm}}>
|
|
138
|
+
<Re.Pressable ref={R}onLongPress={A}delayLongPress={500}style={{maxWidth:P?"75%":"80%",borderRadius:P?M.borderRadius.lg:M.borderRadius.xl,borderBottomRightRadius:C.isMe?4:P?M.borderRadius.lg:M.borderRadius.xl,borderBottomLeftRadius:C.isMe?P?M.borderRadius.lg:M.borderRadius.xl:4,paddingHorizontal:P?0:M.spacing.lg,paddingVertical:P?0:M.spacing.md,backgroundColor:P?"transparent":C.isMe?M.colors.messageBubble.sent:M.colors.messageBubble.received,overflow:"hidden"}}>
|
|
139
|
+
{C.replyTo&&<Vt replyTo={C.replyTo}isMyMessage={C.isMe}/>}
|
|
140
140
|
|
|
141
|
-
{P?<
|
|
142
|
-
{
|
|
143
|
-
</
|
|
141
|
+
{P?<Uo imageData={C.imageData}isMe={C.isMe}onLongPress={A}/>:<Re.Text style={{fontSize:M.typography.fontSize.base,color:C.isMe?M.colors.messageBubble.sentText:M.colors.messageBubble.receivedText}}>
|
|
142
|
+
{C.text}
|
|
143
|
+
</Re.Text>}
|
|
144
144
|
|
|
145
145
|
{}
|
|
146
|
-
{P&&
|
|
147
|
-
<
|
|
148
|
-
{
|
|
149
|
-
</
|
|
150
|
-
</
|
|
151
|
-
</
|
|
146
|
+
{P&&C.text&&C.text.trim()&&<Re.View style={{paddingHorizontal:M.spacing.lg,paddingVertical:M.spacing.md,backgroundColor:C.isMe?M.colors.messageBubble.sent:M.colors.messageBubble.received,borderRadius:M.borderRadius.lg,marginTop:M.spacing.xs}}>
|
|
147
|
+
<Re.Text style={{fontSize:M.typography.fontSize.base,color:C.isMe?M.colors.messageBubble.sentText:M.colors.messageBubble.receivedText}}>
|
|
148
|
+
{C.text}
|
|
149
|
+
</Re.Text>
|
|
150
|
+
</Re.View>}
|
|
151
|
+
</Re.Pressable>
|
|
152
152
|
|
|
153
153
|
{}
|
|
154
|
-
{
|
|
155
|
-
{
|
|
156
|
-
<
|
|
157
|
-
{
|
|
158
|
-
</
|
|
159
|
-
{
|
|
160
|
-
{
|
|
161
|
-
</
|
|
162
|
-
</
|
|
163
|
-
</
|
|
154
|
+
{C.reactions&&C.reactions.length>0&&<Re.TouchableOpacity onPress={I}style={{marginTop:M.spacing.xs,flexDirection:"row",alignItems:"center",backgroundColor:M.colors.background,borderRadius:M.borderRadius.full,justifyContent:C.isMe?"flex-end":"flex-start"}}>
|
|
155
|
+
{C.reactions.map((V,E)=><Re.View key={`${V.emoji}-${E}`}style={{flexDirection:"row",alignItems:"center",padding:M.spacing.xs}}>
|
|
156
|
+
<Re.Text style={{fontSize:M.typography.fontSize.sm}}>
|
|
157
|
+
{V.emoji}
|
|
158
|
+
</Re.Text>
|
|
159
|
+
{V.count>1&&<Re.Text style={{fontSize:M.typography.fontSize.xs,color:M.colors.textSecondary,marginLeft:M.spacing.xs,fontWeight:M.typography.fontWeight.medium}}>
|
|
160
|
+
{V.count}
|
|
161
|
+
</Re.Text>}
|
|
162
|
+
</Re.View>)}
|
|
163
|
+
</Re.TouchableOpacity>}
|
|
164
164
|
|
|
165
|
-
<
|
|
166
|
-
<
|
|
167
|
-
{
|
|
168
|
-
</
|
|
169
|
-
{
|
|
170
|
-
{
|
|
165
|
+
<Re.View style={{marginHorizontal:M.spacing.sm,marginTop:M.spacing.xs,flexDirection:"row",alignItems:"center",justifyContent:C.isMe?"flex-end":"flex-start"}}>
|
|
166
|
+
<Re.Text style={{fontSize:M.typography.fontSize.xs,color:M.colors.textSecondary}}>
|
|
167
|
+
{eo(C.timestamp)}
|
|
168
|
+
</Re.Text>
|
|
169
|
+
{C.isMe&&C.status&&<Re.View style={{marginLeft:M.spacing.xs}}>
|
|
170
|
+
{C.status==="sent"&&<Re.Text style={{fontSize:M.typography.fontSize.xs,color:M.colors.gray[400]}}>
|
|
171
171
|
✓
|
|
172
|
-
</
|
|
173
|
-
{
|
|
172
|
+
</Re.Text>}
|
|
173
|
+
{C.status==="delivered"&&<Re.Text style={{fontSize:M.typography.fontSize.xs,color:M.colors.gray[400]}}>
|
|
174
174
|
✓✓
|
|
175
|
-
</
|
|
176
|
-
{
|
|
175
|
+
</Re.Text>}
|
|
176
|
+
{C.status==="read"&&<Re.Text style={{fontSize:M.typography.fontSize.xs,color:M.colors.primary}}>
|
|
177
177
|
✓✓
|
|
178
|
-
</
|
|
179
|
-
</
|
|
180
|
-
</
|
|
181
|
-
</
|
|
178
|
+
</Re.Text>}
|
|
179
|
+
</Re.View>}
|
|
180
|
+
</Re.View>
|
|
181
|
+
</Re.View>},$o=za;var Z=require("react-native"),Gs=require("lucide-react-native");var Da=({replyToMessage:C,onCancel:S})=>{let T=q(),M=(I,P=50)=>I.length<=P?I:I.substring(0,P)+"...",R=!!C.replyTo,A=C.type==="image"&&C.imageData;return<Z.View style={{borderBottomWidth:1,borderBottomColor:T.colors.border,backgroundColor:T.colors.surface,paddingHorizontal:T.spacing.lg,paddingVertical:T.spacing.md}}>
|
|
182
182
|
<Z.View style={{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}>
|
|
183
183
|
<Z.View style={{flex:1,marginRight:T.spacing.md}}>
|
|
184
184
|
<Z.View style={{flexDirection:"row",alignItems:"center",marginBottom:T.spacing.xs}}>
|
|
185
|
-
<Z.View style={{width:4,backgroundColor:T.colors.primary,borderRadius:T.borderRadius.full,marginRight:T.spacing.md,height:
|
|
185
|
+
<Z.View style={{width:4,backgroundColor:T.colors.primary,borderRadius:T.borderRadius.full,marginRight:T.spacing.md,height:R?48:32}}/>
|
|
186
186
|
<Z.View style={{flex:1}}>
|
|
187
187
|
<Z.Text style={{fontSize:T.typography.fontSize.xs,fontWeight:T.typography.fontWeight.medium,color:T.colors.primary,marginBottom:T.spacing.xs}}>
|
|
188
|
-
Replying to {
|
|
189
|
-
{
|
|
188
|
+
Replying to {C.isMe?"yourself":C.senderName||"sender"}
|
|
189
|
+
{R&&" (reply thread)"}
|
|
190
190
|
</Z.Text>
|
|
191
191
|
|
|
192
192
|
{}
|
|
193
|
-
{
|
|
193
|
+
{R&&<Z.View style={{marginBottom:T.spacing.sm,padding:T.spacing.sm,backgroundColor:T.colors.surfaceSecondary,borderRadius:T.borderRadius.md,borderLeftWidth:2,borderLeftColor:T.colors.gray[300]}}>
|
|
194
194
|
<Z.Text style={{fontSize:T.typography.fontSize.xs,color:T.colors.textSecondary,marginBottom:T.spacing.xs}}>
|
|
195
|
-
Originally replying to: {
|
|
195
|
+
Originally replying to: {C.replyTo.isMe?"yourself":C.replyTo.senderName||"sender"}
|
|
196
196
|
</Z.Text>
|
|
197
197
|
<Z.Text style={{fontSize:T.typography.fontSize.xs,color:T.colors.textSecondary,lineHeight:T.typography.lineHeight.tight}}>
|
|
198
|
-
{C
|
|
198
|
+
{M(C.replyTo.text,40)}
|
|
199
199
|
</Z.Text>
|
|
200
200
|
</Z.View>}
|
|
201
201
|
|
|
202
|
-
{
|
|
203
|
-
<Z.Image source={{uri:
|
|
202
|
+
{A?<Z.View style={{flexDirection:"row",alignItems:"center"}}>
|
|
203
|
+
<Z.Image source={{uri:C.imageData.uri}}style={{width:32,height:32,borderRadius:T.borderRadius.sm,marginRight:T.spacing.sm}}resizeMode="cover"/>
|
|
204
204
|
<Z.View style={{flex:1}}>
|
|
205
205
|
<Z.Text style={{fontSize:T.typography.fontSize.xs,color:T.colors.gray[600],fontStyle:"italic",marginBottom:T.spacing.xs}}>
|
|
206
206
|
📷 Image
|
|
207
207
|
</Z.Text>
|
|
208
|
-
{
|
|
209
|
-
{C
|
|
208
|
+
{C.text&&C.text.trim()&&<Z.Text style={{fontSize:T.typography.fontSize.sm,color:T.colors.gray[700],lineHeight:T.typography.lineHeight.tight}}>
|
|
209
|
+
{M(C.text,40)}
|
|
210
210
|
</Z.Text>}
|
|
211
211
|
</Z.View>
|
|
212
212
|
</Z.View>:<Z.Text style={{fontSize:T.typography.fontSize.sm,color:T.colors.gray[700],lineHeight:T.typography.lineHeight.tight}}>
|
|
213
|
-
{C
|
|
213
|
+
{M(C.text)}
|
|
214
214
|
</Z.Text>}
|
|
215
215
|
</Z.View>
|
|
216
216
|
</Z.View>
|
|
217
217
|
</Z.View>
|
|
218
218
|
|
|
219
|
-
<Z.TouchableOpacity onPress={
|
|
220
|
-
<
|
|
219
|
+
<Z.TouchableOpacity onPress={S}style={{height:32,width:32,alignItems:"center",justifyContent:"center",borderRadius:T.borderRadius.full,backgroundColor:T.colors.gray[200]}}hitSlop={{top:8,bottom:8,left:8,right:8}}>
|
|
220
|
+
<Gs.X size={16}color={T.colors.textSecondary}/>
|
|
221
221
|
</Z.TouchableOpacity>
|
|
222
222
|
</Z.View>
|
|
223
|
-
</Z.View>},
|
|
224
|
-
<W.TouchableOpacity style={
|
|
223
|
+
</Z.View>},Co=Da;var Ve=require("react"),W=require("react-native"),ft=require("lucide-react-native");var qo=require("react"),Js=Y(require("rn-emoji-keyboard")),Va=({visible:C,onClose:S,onEmojiSelected:T})=>{let[M,R]=(0,qo.useState)(!1);(0,qo.useEffect)(()=>{R(!!C)},[C]);let A=P=>{console.log("Selected emoji:",P),T(P.emoji),R(!1),S()},I=()=>{R(!1),S()};return C?<Js.default onEmojiSelected={A}open={M}onClose={I}enableSearchBar/>:null},Lt=Va;var Ba=({visible:C,onPress:S,children:T})=>C?<W.View style={De.overlay}>
|
|
224
|
+
<W.TouchableOpacity style={De.backdrop}onPress={S}activeOpacity={1}/>
|
|
225
225
|
{T}
|
|
226
|
-
</W.View>:null,{width:
|
|
227
|
-
{
|
|
226
|
+
</W.View>:null,{width:jt,height:hs}=W.Dimensions.get("window"),La=({message:C,positions:S,messagePosition:T,containerRef:M,containerOffset:R,setContainerOffset:A})=>{let I=q(),P=(0,Ve.useRef)(new W.Animated.Value(T.y)).current,V=(0,Ve.useRef)(new W.Animated.Value(0)).current,E=(0,Ve.useRef)(!1),v=C.type==="image"&&C.imageData;return(0,Ve.useEffect)(()=>{E.current=!1,M.current&&M.current.measureInWindow((B,k,z,D)=>{A({x:B,y:k});let L=T.y-k,O=S.messagePreviewTop-k;P.setValue(L),V.setValue(0),requestAnimationFrame(()=>{W.Animated.parallel([W.Animated.timing(P,{toValue:O,duration:250,useNativeDriver:!1}),W.Animated.timing(V,{toValue:1,duration:250,useNativeDriver:!1})]).start(()=>{E.current=!0})})})},[S.messagePreviewTop,T.y,M]),<W.Animated.View style={{position:"absolute",top:P,left:T.x,width:T.width,height:C.replyTo?T.height+10:T.height,zIndex:1e3,opacity:V,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":C.isMe?I.colors.messageBubble.sent:I.colors.messageBubble.received,overflow:"hidden"}}>
|
|
227
|
+
{C.replyTo&&<Vt replyTo={C.replyTo}isMyMessage={C.isMe}/>}
|
|
228
228
|
|
|
229
229
|
{v?<W.View>
|
|
230
|
-
<W.Image source={{uri:
|
|
230
|
+
<W.Image source={{uri:C.imageData.uri}}style={{width:T.width,height:T.height,borderRadius:I.borderRadius.lg}}resizeMode='cover'/>
|
|
231
231
|
{}
|
|
232
|
-
{
|
|
233
|
-
<W.Text style={{fontSize:I.typography.fontSize.base,color:
|
|
234
|
-
{
|
|
232
|
+
{C.text&&C.text.trim()&&<W.View style={{paddingHorizontal:I.spacing.lg,paddingVertical:I.spacing.md,backgroundColor:C.isMe?I.colors.messageBubble.sent:I.colors.messageBubble.received,borderRadius:I.borderRadius.lg,marginTop:I.spacing.xs}}>
|
|
233
|
+
<W.Text style={{fontSize:I.typography.fontSize.base,color:C.isMe?I.colors.messageBubble.sentText:I.colors.messageBubble.receivedText}}>
|
|
234
|
+
{C.text}
|
|
235
235
|
</W.Text>
|
|
236
236
|
</W.View>}
|
|
237
|
-
</W.View>:<W.Text style={{fontSize:I.typography.fontSize.base,color:
|
|
238
|
-
{
|
|
237
|
+
</W.View>:<W.Text style={{fontSize:I.typography.fontSize.base,color:C.isMe?I.colors.messageBubble.sentText:I.colors.messageBubble.receivedText}}>
|
|
238
|
+
{C.text}
|
|
239
239
|
</W.Text>}
|
|
240
|
-
</W.Animated.View>},
|
|
240
|
+
</W.Animated.View>},ja=({visible:C,onClose:S,isMyMessage:T,selectedMessage:M,messagePosition:R,onActionPress:A,onEmojiReact:I})=>{let P=ke(),[V,E]=(0,Ve.useState)(!1),v=(0,Ve.useRef)(null),[B,k]=(0,Ve.useState)({x:0,y:0}),z=(0,Ve.useRef)(new W.Animated.Value(0)).current,D=(0,Ve.useRef)(new W.Animated.Value(0)).current,L=(0,Ve.useRef)(!1),O=(0,Ve.useRef)(!1),j=Te=>{A(Te),S()},H=Te=>{I?.(Te),S()},N=()=>{E(!0)},F=()=>{E(!1)},te=Te=>{I?.(Te),E(!1),S()},je=["\u2764\uFE0F","\u{1F602}","\u{1F62E}","\u{1F622}","\u{1F621}","\u{1F44D}"],Ee=(()=>{if(!R)return{emojiBar:{top:hs/2-200,left:jt/2-160},actionMenu:{top:hs/2+50,left:jt/2-100}};let Te=320,Be=60,Ae=200,qe=160,U=20,Ye=8,Fe,Mt,Me,_e,Ze,we=hs/2,Pt=Be+Ye+R.height+Ye+qe,St=we-Pt/2;return Mt=St,Ze=St+Be+Ye,_e=St+Be+Ye+R.height+Ye,Fe=R.x,Me=R.x,Fe+Te>jt-U&&(Fe=jt-Te-U),Fe<U&&(Fe=U),Me+Ae>jt-U&&(Me=jt-Ae-U),Me<U&&(Me=U),{emojiBar:{top:Mt,left:Fe},actionMenu:{top:_e,left:Me},messagePreviewTop:Ze,isNearAverageHeight:!0,isNearTop:!0,isEdgeCase:!0}})();return(0,Ve.useEffect)(()=>{C&&R&&!O.current&&(z.setValue(0),D.setValue(0),setTimeout(()=>{W.Animated.sequence([W.Animated.timing(z,{toValue:1,duration:200,useNativeDriver:!1}),W.Animated.timing(D,{toValue:1,duration:200,useNativeDriver:!1})]).start(()=>{O.current=!0})},50))},[C,R,z,D]),(0,Ve.useEffect)(()=>{C||(L.current=!1,O.current=!1,z.setValue(0),D.setValue(0))},[C,z,D]),C?<>
|
|
241
241
|
{}
|
|
242
|
-
<
|
|
243
|
-
<W.Pressable style={
|
|
244
|
-
</
|
|
242
|
+
<Ba visible={!0}onPress={S}>
|
|
243
|
+
<W.Pressable style={De.overlayPressable}onPress={S}/>
|
|
244
|
+
</Ba>
|
|
245
245
|
|
|
246
246
|
<W.View ref={v}style={{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"}}>
|
|
247
247
|
{}
|
|
248
248
|
</W.View>
|
|
249
249
|
|
|
250
250
|
{}
|
|
251
|
-
{
|
|
251
|
+
{R&&M&&<La message={M}positions={Ee}messagePosition={R}containerRef={v}containerOffset={B}setContainerOffset={k}/>}
|
|
252
252
|
|
|
253
253
|
{}
|
|
254
|
-
<W.Animated.View style={[
|
|
255
|
-
<W.ScrollView horizontal showsHorizontalScrollIndicator={!1}contentContainerStyle={
|
|
256
|
-
{je.map((Te,
|
|
257
|
-
<W.Text style={
|
|
254
|
+
<W.Animated.View style={[De.emojiBar,{position:"absolute",top:Ee.emojiBar.top-(B.y||0),left:Ee.emojiBar.left,opacity:z,pointerEvents:"auto"}]}>
|
|
255
|
+
<W.ScrollView horizontal showsHorizontalScrollIndicator={!1}contentContainerStyle={De.emojiContainer}>
|
|
256
|
+
{je.map((Te,Be)=><W.TouchableOpacity key={Be}style={De.emojiButton}onPress={()=>H(Te)}>
|
|
257
|
+
<W.Text style={De.emojiText}>{Te}</W.Text>
|
|
258
258
|
</W.TouchableOpacity>)}
|
|
259
|
-
<W.TouchableOpacity style={
|
|
259
|
+
<W.TouchableOpacity style={De.addEmojiButton}onPress={N}>
|
|
260
260
|
<ft.Plus size={20}color='#666'/>
|
|
261
261
|
</W.TouchableOpacity>
|
|
262
262
|
</W.ScrollView>
|
|
263
263
|
</W.Animated.View>
|
|
264
264
|
|
|
265
265
|
{}
|
|
266
|
-
<W.Animated.View style={[
|
|
267
|
-
<W.View style={
|
|
266
|
+
<W.Animated.View style={[De.actionMenu,{position:"absolute",top:Ee.actionMenu.top-(B.y||0)+(M?.replyTo?10:0),left:Ee.actionMenu.left,opacity:D,pointerEvents:"auto"}]}>
|
|
267
|
+
<W.View style={De.actionItems}>
|
|
268
268
|
{}
|
|
269
|
-
<W.TouchableOpacity style={
|
|
269
|
+
<W.TouchableOpacity style={De.actionRow}onPress={()=>j("reply")}>
|
|
270
270
|
<ft.Reply size={18}color='#333'/>
|
|
271
|
-
<W.Text style={
|
|
271
|
+
<W.Text style={De.actionLabel}>{P("action.reply")}</W.Text>
|
|
272
272
|
</W.TouchableOpacity>
|
|
273
273
|
|
|
274
274
|
{}
|
|
275
|
-
<W.TouchableOpacity style={
|
|
275
|
+
<W.TouchableOpacity style={De.actionRow}onPress={()=>j("copy")}>
|
|
276
276
|
<ft.Copy size={18}color='#333'/>
|
|
277
|
-
<W.Text style={
|
|
277
|
+
<W.Text style={De.actionLabel}>{P("action.copy")}</W.Text>
|
|
278
278
|
</W.TouchableOpacity>
|
|
279
279
|
|
|
280
280
|
{}
|
|
281
|
-
{T&&<W.TouchableOpacity style={
|
|
281
|
+
{T&&<W.TouchableOpacity style={De.actionRow}onPress={()=>j("delete")}>
|
|
282
282
|
<ft.Trash2 size={18}color='#ff4444'/>
|
|
283
|
-
<W.Text style={[
|
|
283
|
+
<W.Text style={[De.actionLabel,{color:"#ff4444"}]}>
|
|
284
284
|
{P("action.delete")}
|
|
285
285
|
</W.Text>
|
|
286
286
|
</W.TouchableOpacity>}
|
|
@@ -288,9 +288,9 @@ await initChat({ projectId: 'your-project-id' });`)},Ts=()=>(vt(),lt.projectId),
|
|
|
288
288
|
</W.Animated.View>
|
|
289
289
|
|
|
290
290
|
{}
|
|
291
|
-
<
|
|
292
|
-
</>:null},
|
|
293
|
-
<
|
|
291
|
+
<Lt visible={V}onClose={F}onEmojiSelected={te}/>
|
|
292
|
+
</>:null},De=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)"}}),Yo=ja;var Et=require("react"),J=require("react-native"),Xs=Y(require("react-native-actions-sheet"));var Ea=({visible:C,onClose:S,reactions:T,messageText:M,onAddReaction:R,onRemoveReaction:A})=>{let I=(0,Et.useRef)(null),[P,V]=(0,Et.useState)(!1);(0,Et.useEffect)(()=>{C?I.current?.show():I.current?.hide()},[C]);let v=(()=>{let j=[];return T.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 F=0;F<Math.min(H.count,N.length);F++)j.push({id:`${H.emoji}-${F}`,name:N[F].name,avatar:N[F].avatar,emoji:H.emoji,timestamp:new Date().toISOString()})}),j})(),B=T.reduce((j,H)=>j+H.count,0),k=j=>{console.log("Remove reaction called with:",j),console.log("onRemoveReaction prop exists:",!!A),console.log("User is current user:",j.name==="You"),j.name==="You"&&A?(console.log("Calling onRemoveReaction with emoji:",j.emoji),A(j.emoji)):console.log("Not calling onRemoveReaction because:",{isCurrentUser:j.name==="You",hasCallback:!!A})},z=()=>{I.current?.hide(),S(),setTimeout(()=>{V(!0)},300)},D=()=>{V(!1)},L=j=>{console.log("Selected emoji from picker:",j),R?.(j),V(!1),S()},O=()=>{I.current?.hide(),S()};return<>
|
|
293
|
+
<Xs.default ref={I}onClose={O}containerStyle={Q.container}headerAlwaysVisible={!0}gestureEnabled={!0}closeOnTouchBackdrop={!0}>
|
|
294
294
|
{}
|
|
295
295
|
<J.View style={Q.header}>
|
|
296
296
|
<J.Text style={Q.title}>{B} reactions</J.Text>
|
|
@@ -302,7 +302,7 @@ await initChat({ projectId: 'your-project-id' });`)},Ts=()=>(vt(),lt.projectId),
|
|
|
302
302
|
{}
|
|
303
303
|
<J.View style={Q.messagePreview}>
|
|
304
304
|
<J.Text style={Q.messageText}numberOfLines={2}>
|
|
305
|
-
{
|
|
305
|
+
{M}
|
|
306
306
|
</J.Text>
|
|
307
307
|
</J.View>
|
|
308
308
|
|
|
@@ -331,133 +331,136 @@ await initChat({ projectId: 'your-project-id' });`)},Ts=()=>(vt(),lt.projectId),
|
|
|
331
331
|
</J.View>
|
|
332
332
|
</N>})}
|
|
333
333
|
</J.ScrollView>
|
|
334
|
-
</
|
|
334
|
+
</Xs.default>
|
|
335
335
|
|
|
336
336
|
{}
|
|
337
|
-
<
|
|
338
|
-
</>},Q=J.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}}),
|
|
339
|
-
<
|
|
337
|
+
<Lt visible={P}onClose={D}onEmojiSelected={L}/>
|
|
338
|
+
</>},Q=J.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}}),_o=Ea;var Ft=Y(require("react")),ot=require("react-native"),Zs=Y(require("react-native-actions-sheet")),Qs=require("lucide-react-native"),It=(0,Ft.forwardRef)(({onOptionSelect:C,options:S},T)=>{let M=Ft.default.useRef(null);(0,Ft.useImperativeHandle)(T,()=>({show:()=>M.current?.show(),hide:()=>M.current?.hide()}));let R=A=>{C(A),M.current?.hide()};return<Zs.default ref={M}headerAlwaysVisible gestureEnabled={!0}statusBarTranslucent drawUnderStatusBar={!1}containerStyle={{borderTopLeftRadius:20,borderTopRightRadius:20}}>
|
|
339
|
+
<ot.View style={{padding:20,width:"100%"}}>
|
|
340
340
|
|
|
341
341
|
{}
|
|
342
|
-
<
|
|
343
|
-
<
|
|
342
|
+
<ot.View style={{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:20}}>
|
|
343
|
+
<ot.Text style={{fontSize:18,fontWeight:"600",color:"#1F2937"}}>
|
|
344
344
|
Share Content
|
|
345
|
-
</
|
|
346
|
-
<
|
|
347
|
-
<
|
|
348
|
-
</
|
|
349
|
-
</
|
|
345
|
+
</ot.Text>
|
|
346
|
+
<ot.TouchableOpacity onPress={()=>M.current?.hide()}>
|
|
347
|
+
<Qs.X size={24}color="#6B7280"/>
|
|
348
|
+
</ot.TouchableOpacity>
|
|
349
|
+
</ot.View>
|
|
350
350
|
|
|
351
351
|
{}
|
|
352
|
-
<
|
|
353
|
-
{
|
|
354
|
-
<
|
|
355
|
-
<I size={24}color={
|
|
356
|
-
</
|
|
357
|
-
<
|
|
358
|
-
{
|
|
359
|
-
</
|
|
360
|
-
</
|
|
361
|
-
</
|
|
362
|
-
</
|
|
363
|
-
</
|
|
364
|
-
<Le.View style={
|
|
365
|
-
<Le.View style={
|
|
366
|
-
<Le.Animated.View style={[
|
|
367
|
-
<Le.Animated.View style={[
|
|
368
|
-
<Le.Animated.View style={[
|
|
352
|
+
<ot.View style={{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",paddingBottom:20}}>
|
|
353
|
+
{S.map(A=>{let I=A.icon;return<ot.TouchableOpacity key={A.id}style={{width:"30%",aspectRatio:1,marginBottom:20,alignItems:"center",justifyContent:"center"}}onPress={()=>R(A.id)}>
|
|
354
|
+
<ot.View style={{width:60,height:60,borderRadius:30,backgroundColor:"#F3F4F6",alignItems:"center",justifyContent:"center",marginBottom:8}}>
|
|
355
|
+
<I size={24}color={A.color}/>
|
|
356
|
+
</ot.View>
|
|
357
|
+
<ot.Text style={{fontSize:12,color:"#6B7280",textAlign:"center",fontWeight:"500"}}>
|
|
358
|
+
{A.label}
|
|
359
|
+
</ot.Text>
|
|
360
|
+
</ot.TouchableOpacity>})}
|
|
361
|
+
</ot.View>
|
|
362
|
+
</ot.View>
|
|
363
|
+
</Zs.default>});It.displayName="AttachmentMenu";var Go=require("react"),Le=require("react-native"),Fa=({isVisible:C})=>{let S=(0,Go.useRef)(new Le.Animated.Value(0)).current;return(0,Go.useEffect)(()=>{if(!C){S.setValue(0);return}let T=Le.Animated.loop(Le.Animated.sequence([Le.Animated.timing(S,{toValue:1,duration:1200,useNativeDriver:!0}),Le.Animated.timing(S,{toValue:0,duration:1200,useNativeDriver:!0})]));return T.start(),()=>{T.stop()}},[C,S]),C?<Le.View style={Ot.container}>
|
|
364
|
+
<Le.View style={Ot.bubble}>
|
|
365
|
+
<Le.View style={Ot.dotsContainer}>
|
|
366
|
+
<Le.Animated.View style={[Ot.dot,{opacity:S.interpolate({inputRange:[0,.5,1],outputRange:[.3,1,.3]}),transform:[{translateY:S.interpolate({inputRange:[0,.5,1],outputRange:[0,-4,0]})}]}]}/>
|
|
367
|
+
<Le.Animated.View style={[Ot.dot,{opacity:S.interpolate({inputRange:[.33,.83,1.33],outputRange:[.3,1,.3]}),transform:[{translateY:S.interpolate({inputRange:[.33,.83,1.33],outputRange:[0,-4,0]})}]}]}/>
|
|
368
|
+
<Le.Animated.View style={[Ot.dot,{opacity:S.interpolate({inputRange:[.66,1.16,1.66],outputRange:[.3,1,.3]}),transform:[{translateY:S.interpolate({inputRange:[.66,1.16,1.66],outputRange:[0,-4,0]})}]}]}/>
|
|
369
369
|
</Le.View>
|
|
370
370
|
</Le.View>
|
|
371
|
-
</Le.View>:null},
|
|
372
|
-
{({pressed:P})=><
|
|
373
|
-
<
|
|
374
|
-
</
|
|
375
|
-
</
|
|
376
|
-
<
|
|
377
|
-
<
|
|
378
|
-
{
|
|
379
|
-
</
|
|
380
|
-
</
|
|
381
|
-
</Zt.View>},No=Pa;var We=$(require("react")),Je=require("react-native"),Ht=require("lucide-react-native");var ot=require("react"),ee=require("react-native"),Oe=require("lucide-react-native");var Aa={maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"},ns=async(M,R={})=>{try{let T;try{T=await import("expo-image-manipulator")}catch(B){console.log("expo-image-manipulator not available, returning original image info:",B);let A=`image_${Date.now()}.jpg`;return{uri:M,width:1920,height:1920,fileName:A}}let C={...Aa,...R};console.log("Starting image compression...",{uri:M,options:C});let S=await T.manipulateAsync(M,[],{});console.log("Original image info:",{width:S.width,height:S.height,uri:S.uri});let V=[];if(C.maxWidth||C.maxHeight){let{width:B,height:k}=S,A=B,z=k;if(C.maxWidth&&B>C.maxWidth){let L=C.maxWidth/B;A=C.maxWidth,z=k*L}if(C.maxHeight&&z>C.maxHeight){let L=C.maxHeight/z;z=C.maxHeight,A=A*L}(A!==B||z!==k)&&(V.push({resize:{width:Math.round(A),height:Math.round(z)}}),console.log("Resizing image:",{from:{width:B,height:k},to:{width:Math.round(A),height:Math.round(z)}}))}let I={compress:C.quality,format:C.format==="png"?T.SaveFormat?.PNG:T.SaveFormat?.JPEG};console.log("Applying compression with options:",I);let P=await T.manipulateAsync(M,V,I);console.log("Image compression completed:",{originalUri:M,compressedUri:P.uri,finalDimensions:{width:P.width,height:P.height}});let D=Date.now(),E=C.format==="png"?"png":"jpg",v=`compressed_image_${D}.${E}`;return{uri:P.uri,width:P.width,height:P.height,fileName:v}}catch(T){console.error("Error compressing image:",T);let C=T instanceof Error?T.message:"Unknown error";throw new Error(`Failed to compress image: ${C}`)}},rs=(M,R)=>M>3e3||R>3e3?{maxWidth:1920,maxHeight:1920,quality:.7,format:"jpeg"}:M>1920||R>1920?{maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"}:{quality:.9,format:"jpeg"};var za=[{id:"photo",label:"Photo",icon:Oe.Image,color:"#3B82F6"},{id:"camera",label:"Camera",icon:Oe.Camera,color:"#6B7280"},{id:"location",label:"Location",icon:Oe.MapPin,color:"#10B981"},{id:"contact",label:"Contact",icon:Oe.User,color:"#6B7280"},{id:"document",label:"Document",icon:Oe.FileText,color:"#3B82F6"},{id:"poll",label:"Poll",icon:Oe.BarChart3,color:"#F59E0B"},{id:"event",label:"Event",icon:Oe.Calendar,color:"#EF4444"}],Wo=M=>{let R=(0,ot.useRef)(null),T=(0,ot.useCallback)(async()=>{console.log("Photo selection initiated");try{let v;try{v=await import("expo-image-picker")}catch(A){console.log("expo-image-picker not available:",A),ee.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:B}=await v.requestMediaLibraryPermissionsAsync();if(console.log("Photo library permission status:",B),B!=="granted"){ee.Alert.alert("Permission needed","Please grant photo library access to select images.");return}console.log("Waiting for UI to stabilize..."),await new Promise(A=>setTimeout(()=>A(void 0),300)),console.log("Launching image picker...");let k=await v.launchImageLibraryAsync({mediaTypes:"images",allowsEditing:!0,aspect:[4,3],quality:.8,allowsMultipleSelection:!1});if(console.log("Image picker result:",k),!k.canceled&&k.assets&&k.assets.length>0){let A=k.assets[0];console.log("Photo selected successfully:",A.uri);try{console.log("Starting image compression...");let z=rs(A.width||1920,A.height||1920),L=await ns(A.uri,z);console.log("Image compression completed:",L),M?.({type:"image",data:{...L,originalFileSize:A.fileSize}})}catch(z){console.error("Image compression failed:",z),ee.Alert.alert("Compression Error","Failed to compress image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:A.uri,width:A.width,height:A.height,fileSize:A.fileSize,fileName:A.fileName||"image.jpg"}})}}else console.log("Photo selection was canceled by user")}catch(v){console.error("Error in photo selection process:",v),ee.Alert.alert("Photo Selection Error","Failed to open photo library. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),C=(0,ot.useCallback)(async()=>{console.log("Camera capture initiated");try{let v;try{v=await import("expo-image-picker")}catch(A){console.log("expo-image-picker not available:",A),ee.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:B}=await v.requestCameraPermissionsAsync();if(console.log("Camera permission status:",B),B!=="granted"){ee.Alert.alert("Permission needed","Please grant camera access to take photos.");return}console.log("Waiting for UI to stabilize..."),await new Promise(A=>setTimeout(()=>A(void 0),300)),console.log("Launching camera...");let k=await v.launchCameraAsync({allowsEditing:!0,aspect:[4,3],quality:.8,mediaTypes:"images"});if(console.log("Camera result:",k),!k.canceled&&k.assets&&k.assets.length>0){let A=k.assets[0];console.log("Photo captured successfully:",A.uri);try{console.log("Starting camera image compression...");let z=rs(A.width||1920,A.height||1920),L=await ns(A.uri,z);console.log("Camera image compression completed:",L),M?.({type:"image",data:{...L,originalFileSize:A.fileSize}})}catch(z){console.error("Camera image compression failed:",z),ee.Alert.alert("Compression Error","Failed to compress captured image. Sending original image.",[{text:"OK"}]),M?.({type:"image",data:{uri:A.uri,width:A.width,height:A.height,fileSize:A.fileSize,fileName:A.fileName||"camera_photo.jpg"}})}}else console.log("Camera capture was canceled by user")}catch(v){console.error("Error in camera capture process:",v),ee.Alert.alert("Camera Error","Failed to open camera. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),S=(0,ot.useCallback)(async()=>{console.log("Location sharing initiated");try{let v;try{v=await import("expo-location")}catch(L){console.log("expo-location not available:",L),ee.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:B}=await v.requestForegroundPermissionsAsync();if(console.log("Location permission status:",B),B!=="granted"){ee.Alert.alert("Permission needed","Please grant location access to share your location.");return}console.log("Getting current location...");let k=await v.getCurrentPositionAsync({accuracy:v.Accuracy.High});console.log("Getting address from coordinates...");let A=await v.reverseGeocodeAsync({latitude:k.coords.latitude,longitude:k.coords.longitude}),z={coordinates:{latitude:k.coords.latitude,longitude:k.coords.longitude},address:A[0]||null,timestamp:k.timestamp};console.log("Location shared successfully:",z.coordinates),M?.({type:"location",data:z})}catch(v){console.error("Error in location sharing process:",v),ee.Alert.alert("Location Error","Failed to get your location. Please try again or check your device permissions.",[{text:"OK"}])}},[M]),V=(0,ot.useCallback)(async()=>{try{let v;try{v=await import("expo-contacts")}catch(k){console.log("expo-contacts not available:",k),ee.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:B}=await v.requestPermissionsAsync();if(B!=="granted"){ee.Alert.alert("Permission needed","Please grant contacts access to share contacts.");return}ee.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),ee.Alert.alert("Error","Failed to access contacts. Please try again.")}finally{R.current?.hide()}},[]),I=(0,ot.useCallback)(async()=>{console.log("Document selection initiated");try{let v;try{v=await import("expo-document-picker")}catch(k){console.log("expo-document-picker not available:",k),ee.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(k=>setTimeout(()=>k(void 0),300)),console.log("Launching document picker...");let B=await v.getDocumentAsync({type:"*/*",copyToCacheDirectory:!0,multiple:!1});if(console.log("Document picker result:",B),!B.canceled&&B.assets&&B.assets.length>0){let k=B.assets[0];console.log("Document selected successfully:",k.name),M?.({type:"document",data:{uri:k.uri,name:k.name,size:k.size,mimeType:k.mimeType}})}else console.log("Document selection was canceled by user")}catch(v){console.error("Error in document selection process:",v),ee.Alert.alert("Document Selection Error","Failed to open document picker. Please try again.",[{text:"OK"}])}},[M]),P=(0,ot.useCallback)(()=>{ee.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")}])},[]),D=(0,ot.useCallback)(()=>{ee.Alert.alert("Create Event","Event creation feature is coming soon! This would open an event creation interface.",[{text:"OK",onPress:()=>console.log("Event creation acknowledged")}])},[]),E=(0,ot.useCallback)(async v=>{console.log(`Selected attachment option: ${v}`);try{switch(v){case"photo":await T();break;case"camera":await C();break;case"location":await S();break;case"contact":await V();break;case"document":await I();break;case"poll":P();break;case"event":D();break;default:console.warn(`Unknown attachment option: ${v}`)}}catch(B){console.error(`Error handling ${v}:`,B),ee.Alert.alert("Error",`Failed to handle ${v}. Please try again.`)}},[T,C,S,V,I,P,D]);return{menuRef:R,handleOptionSelect:E,options:za}};var G=$(require("react")),Qt=(M={})=>{let{initialValue:R="",initialHeight:T=50,onValueChange:C,onHeightChange:S,onSend:V,onAttachmentSend:I,onReplyCancel:P,onFocus:D,onBlur:E,maxHeight:v=100,minHeight:B=50,maxLength:k=1e3,placeholder:A="Type a message..."}=M,z=(0,G.useRef)(null),[L,O]=G.default.useState(R),[j,H]=G.default.useState(T),[N,F]=G.default.useState(!1),[te,je]=G.default.useState(null),[Me,Ee]=G.default.useState([]),Te=G.default.useMemo(()=>({value:L,height:j,isFocused:N,replyToMessage:te,attachments:Me}),[L,j,N,te,Me]),De=(0,G.useCallback)(ze=>{O(ze),C?.(ze)},[C]),Ae=(0,G.useCallback)(ze=>{let Ne=Math.max(B,Math.min(v,ze));H(Ne),S?.(Ne)},[B,v,S]),Ye=(0,G.useCallback)(()=>{F(!0),D?.()},[D]),U=(0,G.useCallback)(()=>{F(!1),E?.()},[E]),$e=(0,G.useCallback)(ze=>{let{height:Ne}=ze.nativeEvent.contentSize,Kt=Math.max(B,Math.min(v,Ne+16));Ae(Kt)},[B,v,Ae]),Fe=(0,G.useCallback)(()=>{V&&(L||Me.length>0)&&(V(L,Me,te),O(R),Ee([]),je(null),H(T))},[V,L,Me,te,R,T]),Tt=(0,G.useCallback)(ze=>{I?(I(ze,L),L&&O(R)):Ee(Ne=>[...Ne,{...ze,id:Date.now().toString()}])},[I,L,R]),Ce=(0,G.useCallback)(ze=>{Ee(Ne=>[...Ne,ze])},[]),Ge=(0,G.useCallback)(ze=>{Ee(Ne=>Ne.filter(Kt=>Kt.id!==ze))},[]),Xe=(0,G.useCallback)(()=>{Ee([])},[]),we=(0,G.useCallback)(()=>{je(null),P?.()},[P]),It=(0,G.useCallback)(()=>{z.current?.focus()},[]),Ct=G.default.useMemo(()=>({setValue:De,setHeight:Ae,setFocus:F,setReplyToMessage:je,addAttachment:Ce,removeAttachment:Ge,clearAttachments:Xe,sendMessage:Fe,cancelReply:we,focusInput:It,handleAttachmentSelected:Tt,handleContentSizeChange:$e,handleFocus:Ye,handleBlur:U}),[De,Ae,F,je,Ce,Ge,Xe,Fe,we,It,Tt,$e,Ye,U]),Xo=G.default.useMemo(()=>({textInputRef:z}),[]);return{state:Te,actions:Ct,refs:Xo}},ai=(0,G.createContext)(null);var mt=(0,We.forwardRef)(({value:M,onChangeText:R,onSend:T,onFocus:C,height:S,onContentSizeChange:V,replyToMessage:I,onCancelReply:P,onAttachmentSend:D},E)=>{let v=Y(),B=ke(),k=(0,We.useRef)(null);(0,We.useImperativeHandle)(E,()=>({focus:()=>{k.current?.focus()}}));let{state:A,actions:z}=Qt({initialValue:M,initialHeight:S,onValueChange:R,onHeightChange:V,onSend:T,onAttachmentSend:D,onReplyCancel:P,onFocus:C});We.default.useEffect(()=>{M!==A.value&&z.setValue(M)},[M,A.value,z]),We.default.useEffect(()=>{S!==A.height&&z.setHeight(S)},[S,A.height,z]),We.default.useEffect(()=>{I!==A.replyToMessage&&z.setReplyToMessage(I||null)},[I,A.replyToMessage,z]),We.default.useEffect(()=>{if(I&&k.current){let j=setTimeout(()=>{k.current?.focus()},100);return()=>clearTimeout(j)}},[I]);let L=(0,We.useCallback)(j=>{if(console.log("Attachment selected:",j),D)D(j,M.trim()||void 0),M.trim()&&R("");else switch(j.type){case"image":console.log("Image attachment ready to send:",{uri:j.data.uri,dimensions:{width:j.data.width,height:j.data.height},fileName:j.data.fileName});break;case"document":console.log("Document attachment ready to send:",{name:j.data.name,size:j.data.size});break;case"location":console.log("Location attachment ready to send:",j.data.coordinates);break;case"contact":console.log("Contact attachment ready to send:",j.data);break;default:console.log("Other attachment ready to send:",j)}},[D,M,R]),O=Wo(L);return<>
|
|
382
|
-
{I&&P&&<
|
|
383
|
-
<
|
|
384
|
-
<
|
|
385
|
-
<
|
|
386
|
-
<
|
|
387
|
-
</
|
|
388
|
-
|
|
389
|
-
<
|
|
390
|
-
<
|
|
391
|
-
</
|
|
392
|
-
|
|
393
|
-
<
|
|
394
|
-
{
|
|
395
|
-
</
|
|
396
|
-
</
|
|
397
|
-
</
|
|
398
|
-
|
|
399
|
-
<
|
|
400
|
-
</>});mt.displayName="MessageInput";var
|
|
401
|
-
{
|
|
402
|
-
|
|
371
|
+
</Le.View>:null},Ot=Le.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}}),Ht=Fa;var Jo=Y(require("react")),Nt=require("react-native"),ea=require("lucide-react-native");var Oa=({visible:C,onPress:S,isReplyActive:T=!1})=>{let M=q(),R=Jo.default.useRef(new Nt.Animated.Value(0)).current,[A,I]=Jo.default.useState(!1);return Jo.default.useEffect(()=>{Nt.Animated.timing(R,{toValue:C?1:0,duration:200,useNativeDriver:!0}).start(()=>{I(C)})},[C,R]),!C&&!A?null:<Nt.Pressable onPress={S}hitSlop={{top:10,bottom:10,left:10,right:10}}>
|
|
372
|
+
{({pressed:P})=><Nt.Animated.View style={[{position:"absolute",bottom:40,right:M.spacing.lg,zIndex:9999,width:32,height:32,backgroundColor:M.colors.background,borderRadius:M.borderRadius.xl,justifyContent:"center",alignItems:"center",shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.25,shadowRadius:3.84,elevation:5,opacity:R,transform:P?[{scale:.95}]:[]}]}>
|
|
373
|
+
<ea.ChevronDown size={20}color={M.colors.text}/>
|
|
374
|
+
</Nt.Animated.View>}
|
|
375
|
+
</Nt.Pressable>},Xo=Oa;var To=require("react-native");var Ha=({displayDate:C})=>{let S=q();return<To.View style={{marginVertical:S.spacing.lg,alignItems:"center"}}>
|
|
376
|
+
<To.View style={{borderRadius:S.borderRadius.full,backgroundColor:S.colors.surfaceSecondary,paddingHorizontal:S.spacing.md,paddingVertical:S.spacing.xs}}>
|
|
377
|
+
<To.Text style={{fontSize:S.typography.fontSize.xs,color:S.colors.textSecondary,fontWeight:S.typography.fontWeight.medium}}>
|
|
378
|
+
{C}
|
|
379
|
+
</To.Text>
|
|
380
|
+
</To.View>
|
|
381
|
+
</To.View>},Zo=Ha;var We=Y(require("react")),Xe=require("react-native"),Wt=require("lucide-react-native");var st=require("react"),ee=require("react-native"),Oe=require("lucide-react-native");var Na={maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"},fs=async(C,S={})=>{try{let T;try{T=await import("expo-image-manipulator")}catch(B){console.log("expo-image-manipulator not available, returning original image info:",B);let z=`image_${Date.now()}.jpg`;return{uri:C,width:1920,height:1920,fileName:z}}let M={...Na,...S};console.log("Starting image compression...",{uri:C,options:M});let R=await T.manipulateAsync(C,[],{});console.log("Original image info:",{width:R.width,height:R.height,uri:R.uri});let A=[];if(M.maxWidth||M.maxHeight){let{width:B,height:k}=R,z=B,D=k;if(M.maxWidth&&B>M.maxWidth){let L=M.maxWidth/B;z=M.maxWidth,D=k*L}if(M.maxHeight&&D>M.maxHeight){let L=M.maxHeight/D;D=M.maxHeight,z=z*L}(z!==B||D!==k)&&(A.push({resize:{width:Math.round(z),height:Math.round(D)}}),console.log("Resizing image:",{from:{width:B,height:k},to:{width:Math.round(z),height:Math.round(D)}}))}let I={compress:M.quality,format:M.format==="png"?T.SaveFormat?.PNG:T.SaveFormat?.JPEG};console.log("Applying compression with options:",I);let P=await T.manipulateAsync(C,A,I);console.log("Image compression completed:",{originalUri:C,compressedUri:P.uri,finalDimensions:{width:P.width,height:P.height}});let V=Date.now(),E=M.format==="png"?"png":"jpg",v=`compressed_image_${V}.${E}`;return{uri:P.uri,width:P.width,height:P.height,fileName:v}}catch(T){console.error("Error compressing image:",T);let M=T instanceof Error?T.message:"Unknown error";throw new Error(`Failed to compress image: ${M}`)}},ys=(C,S)=>C>3e3||S>3e3?{maxWidth:1920,maxHeight:1920,quality:.7,format:"jpeg"}:C>1920||S>1920?{maxWidth:1920,maxHeight:1920,quality:.8,format:"jpeg"}:{quality:.9,format:"jpeg"};var Wa=[{id:"photo",label:"Photo",icon:Oe.Image,color:"#3B82F6"},{id:"camera",label:"Camera",icon:Oe.Camera,color:"#6B7280"},{id:"location",label:"Location",icon:Oe.MapPin,color:"#10B981"},{id:"contact",label:"Contact",icon:Oe.User,color:"#6B7280"},{id:"document",label:"Document",icon:Oe.FileText,color:"#3B82F6"},{id:"poll",label:"Poll",icon:Oe.BarChart3,color:"#F59E0B"},{id:"event",label:"Event",icon:Oe.Calendar,color:"#EF4444"}],Qo=C=>{let S=(0,st.useRef)(null),T=(0,st.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),ee.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:B}=await v.requestMediaLibraryPermissionsAsync();if(console.log("Photo library permission status:",B),B!=="granted"){ee.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 k=await v.launchImageLibraryAsync({mediaTypes:"images",allowsEditing:!0,aspect:[4,3],quality:.8,allowsMultipleSelection:!1});if(console.log("Image picker result:",k),!k.canceled&&k.assets&&k.assets.length>0){let z=k.assets[0];console.log("Photo selected successfully:",z.uri);try{console.log("Starting image compression...");let D=ys(z.width||1920,z.height||1920),L=await fs(z.uri,D);console.log("Image compression completed:",L),C?.({type:"image",data:{...L,originalFileSize:z.fileSize}})}catch(D){console.error("Image compression failed:",D),ee.Alert.alert("Compression Error","Failed to compress image. Sending original image.",[{text:"OK"}]),C?.({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),ee.Alert.alert("Photo Selection Error","Failed to open photo library. Please try again or check your device permissions.",[{text:"OK"}])}},[C]),M=(0,st.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),ee.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:B}=await v.requestCameraPermissionsAsync();if(console.log("Camera permission status:",B),B!=="granted"){ee.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 k=await v.launchCameraAsync({allowsEditing:!0,aspect:[4,3],quality:.8,mediaTypes:"images"});if(console.log("Camera result:",k),!k.canceled&&k.assets&&k.assets.length>0){let z=k.assets[0];console.log("Photo captured successfully:",z.uri);try{console.log("Starting camera image compression...");let D=ys(z.width||1920,z.height||1920),L=await fs(z.uri,D);console.log("Camera image compression completed:",L),C?.({type:"image",data:{...L,originalFileSize:z.fileSize}})}catch(D){console.error("Camera image compression failed:",D),ee.Alert.alert("Compression Error","Failed to compress captured image. Sending original image.",[{text:"OK"}]),C?.({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),ee.Alert.alert("Camera Error","Failed to open camera. Please try again or check your device permissions.",[{text:"OK"}])}},[C]),R=(0,st.useCallback)(async()=>{console.log("Location sharing initiated");try{let v;try{v=await import("expo-location")}catch(L){console.log("expo-location not available:",L),ee.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:B}=await v.requestForegroundPermissionsAsync();if(console.log("Location permission status:",B),B!=="granted"){ee.Alert.alert("Permission needed","Please grant location access to share your location.");return}console.log("Getting current location...");let k=await v.getCurrentPositionAsync({accuracy:v.Accuracy.High});console.log("Getting address from coordinates...");let z=await v.reverseGeocodeAsync({latitude:k.coords.latitude,longitude:k.coords.longitude}),D={coordinates:{latitude:k.coords.latitude,longitude:k.coords.longitude},address:z[0]||null,timestamp:k.timestamp};console.log("Location shared successfully:",D.coordinates),C?.({type:"location",data:D})}catch(v){console.error("Error in location sharing process:",v),ee.Alert.alert("Location Error","Failed to get your location. Please try again or check your device permissions.",[{text:"OK"}])}},[C]),A=(0,st.useCallback)(async()=>{try{let v;try{v=await import("expo-contacts")}catch(k){console.log("expo-contacts not available:",k),ee.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:B}=await v.requestPermissionsAsync();if(B!=="granted"){ee.Alert.alert("Permission needed","Please grant contacts access to share contacts.");return}ee.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),ee.Alert.alert("Error","Failed to access contacts. Please try again.")}finally{S.current?.hide()}},[]),I=(0,st.useCallback)(async()=>{console.log("Document selection initiated");try{let v;try{v=await import("expo-document-picker")}catch(k){console.log("expo-document-picker not available:",k),ee.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(k=>setTimeout(()=>k(void 0),300)),console.log("Launching document picker...");let B=await v.getDocumentAsync({type:"*/*",copyToCacheDirectory:!0,multiple:!1});if(console.log("Document picker result:",B),!B.canceled&&B.assets&&B.assets.length>0){let k=B.assets[0];console.log("Document selected successfully:",k.name),C?.({type:"document",data:{uri:k.uri,name:k.name,size:k.size,mimeType:k.mimeType}})}else console.log("Document selection was canceled by user")}catch(v){console.error("Error in document selection process:",v),ee.Alert.alert("Document Selection Error","Failed to open document picker. Please try again.",[{text:"OK"}])}},[C]),P=(0,st.useCallback)(()=>{ee.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")}])},[]),V=(0,st.useCallback)(()=>{ee.Alert.alert("Create Event","Event creation feature is coming soon! This would open an event creation interface.",[{text:"OK",onPress:()=>console.log("Event creation acknowledged")}])},[]),E=(0,st.useCallback)(async v=>{console.log(`Selected attachment option: ${v}`);try{switch(v){case"photo":await T();break;case"camera":await M();break;case"location":await R();break;case"contact":await A();break;case"document":await I();break;case"poll":P();break;case"event":V();break;default:console.warn(`Unknown attachment option: ${v}`)}}catch(B){console.error(`Error handling ${v}:`,B),ee.Alert.alert("Error",`Failed to handle ${v}. Please try again.`)}},[T,M,R,A,I,P,V]);return{menuRef:S,handleOptionSelect:E,options:Wa}};var _=Y(require("react")),Mo=(C={})=>{let{initialValue:S="",initialHeight:T=50,onValueChange:M,onHeightChange:R,onSend:A,onAttachmentSend:I,onReplyCancel:P,onFocus:V,onBlur:E,maxHeight:v=100,minHeight:B=50,maxLength:k=1e3,placeholder:z="Type a message..."}=C,D=(0,_.useRef)(null),[L,O]=_.default.useState(S),[j,H]=_.default.useState(T),[N,F]=_.default.useState(!1),[te,je]=_.default.useState(null),[Ce,Ee]=_.default.useState([]),Te=_.default.useMemo(()=>({value:L,height:j,isFocused:N,replyToMessage:te,attachments:Ce}),[L,j,N,te,Ce]),Be=(0,_.useCallback)(ze=>{O(ze),M?.(ze)},[M]),Ae=(0,_.useCallback)(ze=>{let Ne=Math.max(B,Math.min(v,ze));H(Ne),R?.(Ne)},[B,v,R]),qe=(0,_.useCallback)(()=>{F(!0),V?.()},[V]),U=(0,_.useCallback)(()=>{F(!1),E?.()},[E]),Ye=(0,_.useCallback)(ze=>{let{height:Ne}=ze.nativeEvent.contentSize,Yt=Math.max(B,Math.min(v,Ne+16));Ae(Yt)},[B,v,Ae]),Fe=(0,_.useCallback)(()=>{A&&(L||Ce.length>0)&&(A(L,Ce,te),O(S),Ee([]),je(null),H(T))},[A,L,Ce,te,S,T]),Mt=(0,_.useCallback)(ze=>{I?(I(ze,L),L&&O(S)):Ee(Ne=>[...Ne,{...ze,id:Date.now().toString()}])},[I,L,S]),Me=(0,_.useCallback)(ze=>{Ee(Ne=>[...Ne,ze])},[]),_e=(0,_.useCallback)(ze=>{Ee(Ne=>Ne.filter(Yt=>Yt.id!==ze))},[]),Ze=(0,_.useCallback)(()=>{Ee([])},[]),we=(0,_.useCallback)(()=>{je(null),P?.()},[P]),Pt=(0,_.useCallback)(()=>{D.current?.focus()},[]),St=_.default.useMemo(()=>({setValue:Be,setHeight:Ae,setFocus:F,setReplyToMessage:je,addAttachment:Me,removeAttachment:_e,clearAttachments:Ze,sendMessage:Fe,cancelReply:we,focusInput:Pt,handleAttachmentSelected:Mt,handleContentSizeChange:Ye,handleFocus:qe,handleBlur:U}),[Be,Ae,F,je,Me,_e,Ze,Fe,we,Pt,Mt,Ye,qe,U]),ls=_.default.useMemo(()=>({textInputRef:D}),[]);return{state:Te,actions:St,refs:ls}},xi=(0,_.createContext)(null);var mt=(0,We.forwardRef)(({value:C,onChangeText:S,onSend:T,onFocus:M,height:R,onContentSizeChange:A,replyToMessage:I,onCancelReply:P,onAttachmentSend:V},E)=>{let v=q(),B=ke(),k=(0,We.useRef)(null);(0,We.useImperativeHandle)(E,()=>({focus:()=>{k.current?.focus()}}));let{state:z,actions:D}=Mo({initialValue:C,initialHeight:R,onValueChange:S,onHeightChange:A,onSend:T,onAttachmentSend:V,onReplyCancel:P,onFocus:M});We.default.useEffect(()=>{C!==z.value&&D.setValue(C)},[C,z.value,D]),We.default.useEffect(()=>{R!==z.height&&D.setHeight(R)},[R,z.height,D]),We.default.useEffect(()=>{I!==z.replyToMessage&&D.setReplyToMessage(I||null)},[I,z.replyToMessage,D]),We.default.useEffect(()=>{if(I&&k.current){let j=setTimeout(()=>{k.current?.focus()},100);return()=>clearTimeout(j)}},[I]);let L=(0,We.useCallback)(j=>{if(console.log("Attachment selected:",j),V)V(j,C.trim()||void 0),C.trim()&&S("");else switch(j.type){case"image":console.log("Image attachment ready to send:",{uri:j.data.uri,dimensions:{width:j.data.width,height:j.data.height},fileName:j.data.fileName});break;case"document":console.log("Document attachment ready to send:",{name:j.data.name,size:j.data.size});break;case"location":console.log("Location attachment ready to send:",j.data.coordinates);break;case"contact":console.log("Contact attachment ready to send:",j.data);break;default:console.log("Other attachment ready to send:",j)}},[V,C,S]),O=Qo(L);return<>
|
|
382
|
+
{I&&P&&<Co replyToMessage={I}onCancel={P}/>}
|
|
383
|
+
<Xe.View style={{borderTopWidth:1,borderTopColor:v.colors.borderLight,backgroundColor:v.colors.background}}>
|
|
384
|
+
<Xe.View style={{flexDirection:"row",alignItems:"center",backgroundColor:v.colors.background,paddingHorizontal:v.spacing.lg,paddingVertical:v.spacing.sm,minHeight:R}}>
|
|
385
|
+
<Xe.TouchableOpacity style={{marginRight:v.spacing.md}}onPress={()=>O.menuRef.current?.show()}>
|
|
386
|
+
<Wt.Plus size={24}color={v.colors.textSecondary}/>
|
|
387
|
+
</Xe.TouchableOpacity>
|
|
388
|
+
|
|
389
|
+
<Xe.View style={{flex:1,flexDirection:"row",alignItems:"center",borderRadius:v.borderRadius.full,backgroundColor:v.colors.surfaceSecondary,paddingHorizontal:v.spacing.lg,paddingVertical:6}}>
|
|
390
|
+
<Xe.TextInput ref={k}style={{flex:1,fontSize:v.typography.fontSize.base,maxHeight:70,minHeight:18,paddingTop:Xe.Platform.OS==="ios"?6:3,paddingBottom:Xe.Platform.OS==="ios"?6:3,color:v.colors.text}}value={C}onChangeText={S}placeholder={B("input.placeholder")}placeholderTextColor={v.colors.textMuted}multiline maxLength={1e3}onFocus={M}onContentSizeChange={D.handleContentSizeChange}returnKeyType='default'textAlignVertical='center'/>
|
|
391
|
+
</Xe.View>
|
|
392
|
+
|
|
393
|
+
<Xe.TouchableOpacity onPress={T}style={{marginLeft:v.spacing.md,height:40,width:40,alignItems:"center",justifyContent:"center",borderRadius:v.borderRadius.full,backgroundColor:C.trim()?v.colors.primary:v.colors.gray[300]}}disabled={!C.trim()}>
|
|
394
|
+
{C.trim()?<Wt.Send size={18}color='white'/>:<Wt.Mic size={18}color='white'/>}
|
|
395
|
+
</Xe.TouchableOpacity>
|
|
396
|
+
</Xe.View>
|
|
397
|
+
</Xe.View>
|
|
398
|
+
|
|
399
|
+
<It ref={O.menuRef}onOptionSelect={O.handleOptionSelect}options={O.options}/>
|
|
400
|
+
</>});mt.displayName="MessageInput";var es=require("react-native"),xs=require("lucide-react-native");var os=Y(require("react"));var yt=Y(require("react"));var ts=require("react");function So(C,S={}){let{initialNumToRender:T=20,maxToRenderPerBatch:M=10,windowSize:R=10}=S,A=(0,ts.useMemo)(()=>Wo(C).reverse(),[C]),I=(0,ts.useCallback)(P=>P.listItemType==="date-separator"?P.id:P.id.toString(),[]);return{messageItems:A,keyExtractor:I,flatListProps:{initialNumToRender:T,maxToRenderPerBatch:M,windowSize:R,inverted:!0,showsVerticalScrollIndicator:!1,keyboardShouldPersistTaps:"handled",removeClippedSubviews:!1,scrollEventThrottle:16}}}var Ue=require("react");function bs(C={}){let{scrollThreshold:S=50,autoScrollToBottom:T=!0}=C,M=(0,Ue.useRef)(null),[R,A]=(0,Ue.useState)({isNearBottom:!0,isNearTop:!1,showScrollToBottomButton:!1}),I=(0,Ue.useRef)(0),P=(0,Ue.useCallback)(D=>{let{contentOffset:L,contentSize:O,layoutMeasurement:j}=D.nativeEvent,H=L.y,N=Math.abs(H)<S,F=Math.abs(H)>O.height-j.height-S;A({isNearBottom:N,isNearTop:F,showScrollToBottomButton:!N})},[S]),V=(0,Ue.useCallback)(D=>{let L=D>I.current;return I.current=D,L},[]),E=(0,Ue.useCallback)(()=>{},[]),v=(0,Ue.useCallback)((D=!0)=>{M.current&&M.current.scrollToOffset({offset:0,animated:D})},[]),B=(0,Ue.useCallback)((D,L=!0)=>{M.current&&M.current.scrollToOffset({offset:D,animated:L})},[]),k=(0,Ue.useCallback)((D,L=!0)=>{M.current&&M.current.scrollToIndex({index:D,animated:L})},[]),z=(0,Ue.useCallback)(D=>{V(D)&&T&&M.current&&setTimeout(()=>{v()},100)},[V,T,v]);return{flatListRef:M,scrollState:R,handleScroll:P,handleContentSizeChange:E,handleNewMessages:z,scrollToEnd:v,scrollToOffset:B,scrollToIndex:k}}var Ut=require("react");function Ro(C={}){let{enableMessageActions:S=!0}=C,[T,M]=(0,Ut.useState)({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0}),R=(0,Ut.useCallback)((P,V)=>{S&&M({actionSheetVisible:!0,selectedMessage:P,messagePosition:V})},[S]),A=(0,Ut.useCallback)(()=>{M({actionSheetVisible:!1,selectedMessage:null,messagePosition:void 0})},[]),I=(0,Ut.useCallback)((P,V)=>{if(!T.selectedMessage)return;let{selectedMessage:E}=T;switch(P){case"reply":V?.onReply?.(E);break;case"copy":if(V?.onCopy)V.onCopy(E);else{let v=E.type==="image"&&E.imageData?E.text||"Image message":E.text;Promise.resolve().then(()=>(oa(),ta)).then(({copyToClipboard:B})=>{B(v)}).catch(()=>{console.log("Clipboard functionality not available")})}break;case"delete":V?.onDelete?.(E.id);break;default:V?.onCustomAction?.(P,E);break}A()},[T.selectedMessage,A]);return{actionState:T,handleMessageLongPress:R,handleActionSheetClose:A,handleActionPress:I}}var dt=require("react");function wo(C={}){let{enableReactionDetails:S=!0}=C,[T,M]=(0,dt.useState)({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),[R,A]=(0,dt.useState)(null),I=(0,dt.useCallback)(B=>{S&&B.reactions&&B.reactions.length>0&&(A(B),M({isReactionDetailsVisible:!0,selectedReactions:B.reactions,selectedMessageText:B.text}))},[S]),P=(0,dt.useCallback)(()=>{M({isReactionDetailsVisible:!1,selectedReactions:[],selectedMessageText:""}),A(null)},[]),V=(0,dt.useCallback)((B,k)=>{R&&k?.(R.id,B),P()},[R,P]),E=(0,dt.useCallback)((B,k)=>{R&&k?.(R.id,B),P()},[R,P]),v=(0,dt.useCallback)((B,k)=>{R&&k?.(R.id,B)},[R]);return{reactionState:T,selectedMessage:R,handleReactionPress:I,handleReactionDetailsClose:P,handleAddReaction:V,handleRemoveReaction:E,handleEmojiReact:v}}var Io=require("react");function Cs(){let[C,S]=(0,Io.useState)({replyToMessage:null}),T=(0,Io.useCallback)(R=>{S({replyToMessage:R})},[]),M=(0,Io.useCallback)(()=>{S({replyToMessage:null})},[]);return{replyState:C,setReplyToMessage:T,clearReply:M}}var sa=(0,yt.createContext)(null);function Kt(){let C=(0,yt.useContext)(sa);if(!C)throw new Error("useMessageListContext must be used within MessageListProvider");return C}function Po({children:C,messages:S,config:T={},...M}){let R=So(S,T),A=bs(T),I=Ro(T),P=wo(T),V=Cs();yt.default.useEffect(()=>{A.handleNewMessages(S.length)},[S.length,A.handleNewMessages]);let E=(0,yt.useMemo)(()=>({messageList:R,scroll:A,actions:I,reactions:P,reply:V,config:T,callbacks:M}),[R,A,I,P,V,T,M]);return<sa.Provider value={E}>
|
|
401
|
+
{C}
|
|
402
|
+
</sa.Provider>}var Ao=require("react"),$t=require("react-native");var xt={Provider:Po,Container:({children:C,style:S})=><$t.View style={[aa.container,S]}>{C}</$t.View>,Messages:({renderMessage:C,style:S})=>{let{messageList:T,scroll:M,actions:R,reactions:A,callbacks:I}=Kt(),P=(0,Ao.useCallback)(({item:E,index:v})=>C&&E.listItemType!=="date-separator"?C({message:E,index:v})||null:E.listItemType==="date-separator"?<Zo date={E.date}displayDate={E.displayDate}/>:<$o message={E}onLongPress={R.handleMessageLongPress}onReactionPress={A.handleReactionPress}onReactionRemove={I.onReactionRemove}/>,[R.handleMessageLongPress,A.handleReactionPress,I.onReactionRemove,C]),V=(0,Ao.useCallback)(E=>{M.handleScroll(E);let{isNearBottom:v,isNearTop:B}=M.scrollState;I.onScrollPositionChange?.(v,B),v&&I.onScrollToBottom?.(),B&&I.onScrollToTop?.()},[M.handleScroll,M.scrollState,I]);return<$t.FlatList ref={M.flatListRef}data={T.messageItems}renderItem={P}keyExtractor={T.keyExtractor}contentContainerStyle={[aa.contentContainer,S]}onContentSizeChange={M.handleContentSizeChange}onScroll={V}{...T.flatListProps}/>},TypingIndicator:({isVisible:C})=>C?<Ht isVisible={C}/>:null,ScrollButton:({visible:C,isReplyActive:S,onPress:T})=>{let{scroll:M}=Kt();return<Xo visible={C??M.scrollState.showScrollToBottomButton}onPress={T??M.scrollToEnd}isReplyActive={S}/>},ActionSheet:()=>{let{actions:C,reactions:S,reply:T,callbacks:M,config:R}=Kt(),A=(0,Ao.useCallback)(P=>{C.handleActionPress(P,{onReply:V=>{T.setReplyToMessage(V),M.onReplyMessage?.(V)},onDelete:M.onMessageDelete,onCustomAction:M.onActionPress})},[C.handleActionPress,T.setReplyToMessage,M]),I=(0,Ao.useCallback)(P=>{console.log("\u{1F525} MessageListCompound - handleEmojiReact called with emoji:",P);let V=C.actionState.selectedMessage;console.log("\u{1F525} MessageListCompound - selectedMessage:",V?.id,"callbacks.onReactionAdd exists:",!!M.onReactionAdd),V&&M.onReactionAdd?(console.log("\u{1F525} MessageListCompound - Calling onReactionAdd for message:",V.id,"emoji:",P),M.onReactionAdd(V.id,P)):console.log("\u{1F525} MessageListCompound - NOT calling onReactionAdd. selectedMessage:",!!V,"callback exists:",!!M.onReactionAdd)},[C.actionState.selectedMessage,M.onReactionAdd]);return R.enableMessageActions?<Yo visible={C.actionState.actionSheetVisible}onClose={C.handleActionSheetClose}isMyMessage={C.actionState.selectedMessage?.isMe||!1}selectedMessage={C.actionState.selectedMessage||void 0}messagePosition={C.actionState.messagePosition}onActionPress={A}onEmojiReact={I}/>:null},ReactionDetails:()=>{let{reactions:C,callbacks:S,config:T}=Kt();return T.enableReactionDetails?<_o visible={C.reactionState.isReactionDetailsVisible}onClose={C.handleReactionDetailsClose}reactions={C.reactionState.selectedReactions}messageText={C.reactionState.selectedMessageText}onRemoveReaction={M=>C.handleRemoveReaction(M,S.onReactionRemove)}/>:null}},aa=$t.StyleSheet.create({container:{flex:1},contentContainer:{paddingVertical:16}});var pt=(0,os.forwardRef)(({messages:C,isTyping:S,showScrollToBottom:T=!1,isReplyActive:M=!1,...R},A)=>{let I={scrollThreshold:R.scrollThreshold,autoScrollToBottom:R.autoScrollToBottom,enableMessageActions:R.enableMessageActions,enableReactionDetails:R.enableReactionDetails},P={onScrollToBottom:R.onScrollToBottom,onScrollToTop:R.onScrollToTop,onScrollPositionChange:R.onScrollPositionChange,onReactionAdd:R.onReactionAdd,onReactionRemove:R.onReactionRemove,onMessageDelete:R.onMessageDelete,onReplyMessage:R.onReplyMessage,onActionPress:R.onActionPress};return os.default.useImperativeHandle(A,()=>({scrollToEnd:(V=!0)=>{},scrollToOffset:(V,E=!0)=>{},scrollToIndex:(V,E=!0)=>{}}),[]),<Po messages={C}config={I}{...P}>
|
|
403
403
|
<xt.Container>
|
|
404
404
|
<xt.Messages/>
|
|
405
|
-
<xt.TypingIndicator isVisible={
|
|
406
|
-
<xt.ScrollButton visible={T?void 0:!1}isReplyActive={
|
|
405
|
+
<xt.TypingIndicator isVisible={S}/>
|
|
406
|
+
<xt.ScrollButton visible={T?void 0:!1}isReplyActive={M}/>
|
|
407
407
|
<xt.ActionSheet/>
|
|
408
408
|
<xt.ReactionDetails/>
|
|
409
409
|
</xt.Container>
|
|
410
|
-
</
|
|
411
|
-
|
|
412
|
-
|
|
410
|
+
</Po>});pt.displayName="MessageList";var qt=Y(require("react")),bt=require("react-native");var Ya=()=><bt.View style={na.container}>
|
|
411
|
+
<bt.ActivityIndicator size="small"color="#007AFF"/>
|
|
412
|
+
<bt.Text style={na.text}>Initializing...</bt.Text>
|
|
413
|
+
</bt.View>,na=bt.StyleSheet.create({container:{flex:1,justifyContent:"center",alignItems:"center",padding:20},text:{marginTop:8,fontSize:14,color:"#666"}});function He(C){let S=qt.default.forwardRef((M,R)=>{let[,A]=(0,qt.useState)(0),I=At();return(0,qt.useEffect)(()=>{if(I==="pending"){let P=setInterval(()=>{Eo()!=="pending"&&(clearInterval(P),A(E=>E+1))},100);return()=>clearInterval(P)}},[I]),I==="pending"?<Ya/>:<C{...M}ref={R}/>}),T=C.displayName||C.name||"Component";return S.displayName=`RequireAuth(${T})`,S}function at(C){return(...S)=>{if(At()==="pending")throw new Error("[UseChat SDK] SDK is still initializing. Make sure to await initChat() before rendering components that use this hook.");return C(...S)}}var ss=require("react-native");var Ke=require("react-native");var Ct=require("react-native");var _a=({avatar:C,isOnline:S=!1,size:T="medium"})=>{let M=q(),R=()=>{switch(T){case"small":return{width:32,height:32};case"large":return{width:64,height:64};default:return{width:48,height:48}}},A=()=>{switch(T){case"small":return{width:12,height:12};case"large":return{width:24,height:24};default:return{width:16,height:16}}},I=R(),P=A(),E=(()=>{switch(T){case"small":return 14;case"large":return 28;default:return 20}})();return<Ct.View style={{position:"relative"}}>
|
|
414
|
+
{C&&C.trim()!==""?<Ct.Image source={{uri:C}}style={[I,{borderRadius:M.borderRadius.full}]}resizeMode="cover"/>:<Ct.View style={[I,{borderRadius:M.borderRadius.full,backgroundColor:M.colors.primary,justifyContent:"center",alignItems:"center"}]}>
|
|
415
|
+
<Ct.Text style={{color:M.colors.background,fontSize:E,fontWeight:"600"}}>
|
|
413
416
|
👤
|
|
414
|
-
</
|
|
415
|
-
</
|
|
417
|
+
</Ct.Text>
|
|
418
|
+
</Ct.View>}
|
|
416
419
|
|
|
417
420
|
{}
|
|
418
|
-
{
|
|
419
|
-
</
|
|
421
|
+
{S&&<Ct.View style={[P,{position:"absolute",bottom:-2,right:-2,backgroundColor:M.colors.online,borderRadius:M.borderRadius.full,borderWidth:2,borderColor:M.colors.background}]}/>}
|
|
422
|
+
</Ct.View>},Do=_a;var Ga=({item:C,onPress:S})=>{let T=q(),M=C.unreadCount&&C.unreadCount>0;return<Ke.TouchableOpacity style={{flexDirection:"row",alignItems:"center",paddingHorizontal:T.spacing.lg,paddingVertical:T.spacing.md,borderBottomWidth:1,borderBottomColor:T.colors.borderLight,backgroundColor:M?T.colors.unread:T.colors.background}}onPress={()=>S(C)}>
|
|
420
423
|
<Ke.View style={{marginRight:T.spacing.md}}>
|
|
421
|
-
<
|
|
424
|
+
<Do avatar={C.avatar}isOnline={C.isOnline}size="medium"/>
|
|
422
425
|
</Ke.View>
|
|
423
426
|
|
|
424
427
|
<Ke.View style={{flex:1,marginRight:T.spacing.md}}>
|
|
425
428
|
{}
|
|
426
429
|
<Ke.View style={{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:T.spacing.xs}}>
|
|
427
|
-
<Ke.Text style={{fontSize:T.typography.fontSize.base,flex:1,fontWeight:
|
|
428
|
-
{
|
|
430
|
+
<Ke.Text style={{fontSize:T.typography.fontSize.base,flex:1,fontWeight:M?T.typography.fontWeight.bold:T.typography.fontWeight.semibold,color:T.colors.text}}>
|
|
431
|
+
{C.name}
|
|
429
432
|
</Ke.Text>
|
|
430
|
-
<Ke.Text style={{fontSize:T.typography.fontSize.sm,marginLeft:T.spacing.sm,color:
|
|
431
|
-
{
|
|
433
|
+
<Ke.Text style={{fontSize:T.typography.fontSize.sm,marginLeft:T.spacing.sm,color:M?T.colors.gray[700]:T.colors.textSecondary,fontWeight:M?T.typography.fontWeight.medium:T.typography.fontWeight.normal}}>
|
|
434
|
+
{C.time}
|
|
432
435
|
</Ke.Text>
|
|
433
436
|
</Ke.View>
|
|
434
437
|
|
|
435
438
|
{}
|
|
436
439
|
<Ke.View style={{flexDirection:"row",alignItems:"center"}}>
|
|
437
|
-
<Ke.Text style={{fontSize:T.typography.fontSize.sm,flex:1,color:
|
|
438
|
-
{
|
|
440
|
+
<Ke.Text style={{fontSize:T.typography.fontSize.sm,flex:1,color:M?T.colors.gray[800]:T.colors.textSecondary,fontWeight:M?T.typography.fontWeight.medium:T.typography.fontWeight.normal}}numberOfLines={1}>
|
|
441
|
+
{C.message}
|
|
439
442
|
</Ke.Text>
|
|
440
|
-
{
|
|
443
|
+
{C.unreadCount&&<Ke.View style={{width:20,height:20,backgroundColor:T.colors.primary,borderRadius:T.borderRadius.full,alignItems:"center",justifyContent:"center",marginLeft:T.spacing.sm}}>
|
|
441
444
|
<Ke.Text style={{fontSize:T.typography.fontSize.xs,color:"white",fontWeight:T.typography.fontWeight.bold}}>
|
|
442
|
-
{
|
|
445
|
+
{C.unreadCount}
|
|
443
446
|
</Ke.Text>
|
|
444
447
|
</Ke.View>}
|
|
445
448
|
</Ke.View>
|
|
446
449
|
</Ke.View>
|
|
447
|
-
</Ke.TouchableOpacity>},
|
|
448
|
-
|
|
449
|
-
{
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
<
|
|
453
|
-
<
|
|
454
|
-
<
|
|
455
|
-
</
|
|
450
|
+
</Ke.TouchableOpacity>},Vo=Ga;var Ja=({chats:C,onChatPress:S,onRefresh:T,refreshing:M=!1})=>{let R=({item:A})=><Vo item={A}onPress={S}/>;return<ss.FlatList data={C}renderItem={R}keyExtractor={A=>A.id}showsVerticalScrollIndicator={!1}style={{flex:1}}refreshControl={T?<ss.RefreshControl refreshing={M}onRefresh={T}tintColor="#007AFF"colors={["#007AFF"]}/>:void 0}/>},Ts=Ja;var as=require("react-native");var Xa=({title:C})=>{let S=q();return<as.View style={{backgroundColor:S.colors.background,paddingHorizontal:S.spacing.lg,paddingVertical:S.spacing.lg,borderBottomWidth:1,borderBottomColor:S.colors.borderLight}}>
|
|
451
|
+
<as.Text style={{fontSize:S.typography.fontSize.xxl,fontWeight:S.typography.fontWeight.bold,color:S.colors.text}}>
|
|
452
|
+
{C}
|
|
453
|
+
</as.Text>
|
|
454
|
+
</as.View>},Ms=Xa;var Tt=require("react-native"),ns=require("lucide-react-native");var Za=({value:C,onChangeText:S,onClear:T,placeholder:M})=>{let R=q(),I=ke()("search.placeholder");return<Tt.View style={{backgroundColor:R.colors.background,paddingHorizontal:R.spacing.lg,paddingVertical:R.spacing.md,borderBottomWidth:1,borderBottomColor:R.colors.borderLight}}>
|
|
455
|
+
<Tt.View style={{position:"relative"}}>
|
|
456
|
+
<Tt.View style={{position:"absolute",left:R.spacing.md,top:"50%",transform:[{translateY:-10}],zIndex:10}}>
|
|
457
|
+
<ns.Search size={20}color={R.colors.textMuted}/>
|
|
458
|
+
</Tt.View>
|
|
456
459
|
|
|
457
|
-
<
|
|
460
|
+
<Tt.TextInput value={C}onChangeText={S}placeholder={M||I}placeholderTextColor={R.colors.textMuted}style={{backgroundColor:R.colors.surfaceSecondary,borderRadius:R.borderRadius.full,paddingLeft:48,paddingRight:40,paddingVertical:R.spacing.md,color:R.colors.text,fontSize:R.typography.fontSize.base}}autoCapitalize="none"autoCorrect={!1}clearButtonMode="never"/>
|
|
458
461
|
|
|
459
|
-
{
|
|
460
|
-
<
|
|
461
|
-
</
|
|
462
|
-
</
|
|
463
|
-
</
|
|
462
|
+
{C.length>0&&<Tt.TouchableOpacity onPress={T}style={{position:"absolute",right:R.spacing.md,top:"50%",transform:[{translateY:-10}]}}hitSlop={{top:10,bottom:10,left:10,right:10}}>
|
|
463
|
+
<ns.X size={20}color={R.colors.textMuted}/>
|
|
464
|
+
</Tt.TouchableOpacity>}
|
|
465
|
+
</Tt.View>
|
|
466
|
+
</Tt.View>},Ss=Za;var ut=require("react"),rs=Y(require("dayjs")),vt=(0,rs.default)(),ra=vt.subtract(1,"day"),ia=vt.subtract(2,"day"),la=vt.subtract(3,"day"),Qa=[{id:1,text:"Hi! How are you?",isMe:!1,timestamp:la.hour(10).minute(30).toISOString(),senderName:"Anna"},{id:2,text:"Hey! Great, thanks! And you?",isMe:!0,timestamp:la.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:ia.hour(14).minute(20).toISOString(),senderName:"Anna"},{id:4,text:"Maybe we could go to the movies?",isMe:!0,timestamp:ia.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:ra.hour(9).minute(15).toISOString(),senderName:"Anna"},{id:6,text:"Great! What movies are you interested in?",isMe:!0,timestamp:ra.hour(9).minute(20).toISOString()},{id:7,text:"Maybe something action or comedy?",isMe:!1,timestamp:vt.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:vt.hour(8).minute(35).toISOString()},{id:9,text:"Perfect! What time should we meet?",isMe:!1,timestamp:vt.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:vt.hour(9).minute(15).toISOString(),reactions:[{emoji:"\u{1F44D}",count:1,users:["anna"]},{emoji:"\u23F0",count:1,users:["me"]}]}],Rs=C=>{let S=Qa.map(v=>v.isMe?v:{...v,senderName:C||v.senderName}),[T,M]=(0,ut.useState)(S),R=(0,ut.useCallback)((v,B)=>{if(console.log("sendMessage called with text:",v,"and replyTo:",B),!v.trim())return;let k={id:Date.now(),text:v.trim(),isMe:!0,timestamp:(0,rs.default)().toISOString(),status:"sent",replyTo:B};M(z=>[...z,k]),setTimeout(()=>{M(z=>z.map(D=>D.id===k.id?{...D,status:"delivered"}:D))},1e3),setTimeout(()=>{M(z=>z.map(D=>D.id===k.id?{...D,status:"read"}:D))},3e3)},[]),A=(0,ut.useCallback)((v,B,k)=>{let z={id:Date.now(),text:B||"",isMe:!0,timestamp:(0,rs.default)().toISOString(),status:"sent",type:"image",imageData:v,replyTo:k};M(D=>[...D,z]),setTimeout(()=>{M(D=>D.map(L=>L.id===z.id?{...L,status:"delivered"}:L))},1e3),setTimeout(()=>{M(D=>D.map(L=>L.id===z.id?{...L,status:"read"}:L))},3e3)},[]),I=(0,ut.useCallback)((v,B)=>{M(k=>k.map(z=>z.id===v?{...z,status:B}:z))},[]),P=(0,ut.useCallback)((v,B)=>{M(k=>k.map(z=>{if(z.id===v){let D=z.reactions||[],L=D.findIndex(O=>O.emoji===B);if(L>=0){let O=[...D];return O[L]={...O[L],count:O[L].count+1,users:[...O[L].users,"me"]},{...z,reactions:O}}else{let O={emoji:B,count:1,users:["me"]};return{...z,reactions:[...D,O]}}}return z}))},[]),V=(0,ut.useCallback)((v,B)=>{console.log("removeReaction 1212121 called with messageId:",v,"and emoji:",B),M(k=>k.map(z=>{if(z.id===v){let D=z.reactions||[],L=D.findIndex(O=>O.emoji===B);if(L>=0){let O=D[L];if(O.count>1){let j=[...D];return j[L]={...O,count:O.count-1,users:O.users.filter(H=>H!=="me")},{...z,reactions:j}}else return{...z,reactions:D.filter(j=>j.emoji!==B)}}}return z}))},[]),E=(0,ut.useCallback)(v=>{console.log("deleteMessage called with messageId:",v),M(B=>{let k=B.map(z=>z.id===v?{...z,deleted:!0}:z);return console.log("Message marked as deleted:",v),k})},[]);return{messages:T,sendMessage:R,sendImageMessage:A,updateMessageStatus:I,addReaction:P,deleteMessage:E,removeReaction:V}};var $e=require("react");var ws=(C={})=>{At();let[S,T]=(0,$e.useState)(C.initialMessages||[]),[M,R]=(0,$e.useState)(!1),A=(0,$e.useCallback)((D,L)=>{let O={id:Date.now(),text:D,isMe:!0,timestamp:new Date().toISOString(),status:"sent",replyTo:L?{id:L.id,text:L.text,senderName:L.senderName,isMe:L.isMe}:void 0};T(j=>[O,...j])},[]),I=(0,$e.useCallback)(D=>{T(L=>[D,...L])},[]),P=(0,$e.useCallback)((D,L)=>{T(O=>O.map(j=>j.id===D?{...j,...L}:j))},[]),V=(0,$e.useCallback)(D=>{T(L=>L.filter(O=>O.id!==D))},[]),E=(0,$e.useCallback)((D,L)=>{T(O=>O.map(j=>{if(j.id!==D)return j;let H=j.reactions||[];if(H.find(F=>F.emoji===L))return{...j,reactions:H.map(F=>F.emoji===L?{...F,count:F.count+1,users:[...F.users,"current-user"]}:F)};{let F={emoji:L,count:1,users:["current-user"]};return{...j,reactions:[...H,F]}}}))},[]),v=(0,$e.useCallback)((D,L)=>{T(O=>O.map(j=>{if(j.id!==D)return j;let H=j.reactions||[],N=H.find(F=>F.emoji===L);return N?N.count<=1?{...j,reactions:H.filter(F=>F.emoji!==L)}:{...j,reactions:H.map(F=>F.emoji===L?{...F,count:F.count-1,users:F.users.filter(te=>te!=="current-user")}:F)}:j}))},[]),B=(0,$e.useCallback)(D=>{R(D)},[]),k=(0,$e.useCallback)(()=>{T(C.initialMessages||[]),R(!1)},[C.initialMessages]),z=(0,$e.useCallback)(D=>S.find(L=>L.id===D),[S]);return{messages:S,isTyping:M,sendMessage:A,addReaction:E,removeReaction:v,setMessages:T,addMessage:I,updateMessage:P,deleteMessage:V,setTyping:B,resetChat:k,getMessageById:z}};var is=require("react");var ca=()=>{let C=ke(),S=()=>"en";return{formatDate:P=>Us(P,C,S()),formatTime:P=>eo(P,S()),formatRelative:P=>Ks(P,S()),formatDateTimeWithTime:P=>$s(P,C,S()),groupMessages:P=>Wo(P,S())}};var en=He(ms),tn=He(us),on=at(Zt),sn=He(pt),an=He(mt),nn=He(No),rn=He(Ht),ln=He(Ts),cn=He(Vo),dn=He(Ms),un=He(Ss),mn=He(Do),pn=He(It),gn=He(Es),hn=at(q),fn=at(ws),yn=at(Rs),xn=at(So),bn=at(Ro),Cn=at(wo),Tn=at(Qt),Mn=at(Mo),Sn=at(ca);0&&(module.exports={AttachmentMenu,Chat,ChatAvatar,ChatHeader,ChatItem,ChatList,ChatListSearchBar,ChatProvider,ChatScreenHeader,I18nProvider,MessageInput,MessageList,ThemeProvider,TypingIndicator,defaultTheme,defaultTranslations,getAuthState,getInitStatus,getProjectId,getTranslation,initChat,isInitialized,isInitializing,isSupportedLocale,useAttachments,useChatConfig,useChatMessages,useChatSDK,useDateFormatter,useMessageActions,useMessageInput,useMessageList,useMessageReactions,useTheme,useTranslation,useTranslationFunction});
|