diff --git a/404.html b/404.html index 5c0adb7..fcf38bc 100644 --- a/404.html +++ b/404.html @@ -41,5 +41,5 @@ - + diff --git a/512.9fa6a3d9d716749f.js b/512.9fa6a3d9d716749f.js deleted file mode 100644 index 863d305..0000000 --- a/512.9fa6a3d9d716749f.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkangor=self.webpackChunkangor||[]).push([[512],{1512:(xe,N,c)=>{c.r(N),c.d(N,{default:()=>ve});var t=c(3107),_=c(8716);let O=(()=>{class i{constructor(){}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["chat"]],decls:3,vars:0,consts:[[1,"absolute","inset-0","flex","min-w-0","flex-col","overflow-hidden"],[1,"flex","flex-auto","overflow-hidden"]],template:function(n,o){1&n&&(t.j41(0,"div",0)(1,"div",1),t.nrm(2,"router-outlet"),t.k0s()())},dependencies:[_.n3],encapsulation:2,changeDetection:0})}}return i})();var f=c(3014),F=c(1217),I=c(8447),V=c(1698),R=c(8915),B=c(1787),K=c(3016),Y=c(1483),X=c(7610),G=c(2867),D=c(7947),S=c(7178),L=c(5492),$=c(3797),H=c(8078),z=c(3149),W=c(3125),Q=c(7121);let b=(()=>{class i{constructor(e,n,o,r){this._signerService=e,this._storageService=n,this._relayService=o,this._metadataQueueService=r,this.chatList=[],this.latestMessageTimestamps={},this.messageQueue=[],this.isDecrypting=!1,this.decryptedPrivateKey="",this._chat=new F.t(null),this._chats=new F.t(null),this._contact=new F.t(null),this._contacts=new F.t(null),this._profile=new F.t(null),this._unsubscribeAll=new I.B}get profile$(){return this._profile.asObservable()}get chat$(){return this._chat.asObservable()}get chats$(){return this._chats.asObservable()}get contact$(){return this._contact.asObservable()}get contacts$(){return this._contacts.asObservable()}checkCurrentChatOnPageRefresh(e){e&&this.getChatById(e).subscribe(o=>{o&&(this._chat.next(o),this.loadAndFetchChatHistory(e))})}getContact(e){var n=this;return(0,f.A)(function*(){try{if(!e)return;n._storageService.profile$.subscribe(o=>{o&&o.pubKey&&o.metadata&&o.pubKey===e&&n._contact.next({pubKey:e,displayName:o.metadata.name?o.metadata.name:"Unknown",picture:o.metadata.picture,about:o.metadata.about})})}catch(o){console.error("Error fetching contact metadata:",o)}})()}getContacts(){return new V.c(e=>(this._storageService.getAllProfiles().then(n=>{if(n&&n.length>0){const o=n.map(r=>(r.pubKey||console.error("Contact is missing pubKey:",r),r));this._contacts.next(o),e.next(o)}else e.next([]);e.complete()}).catch(n=>{console.error("Error loading cached contacts from IndexedDB:",n),e.next([]),e.complete()}),{unsubscribe(){}}))}getProfile(){var e=this;return(0,f.A)(function*(){try{e._storageService.profile$.subscribe(n=>{n&&n.pubKey&&n.metadata&&n.pubKey===e._signerService.getPublicKey()&&e._profile.next(n.metadata)}),e._storageService.getProfile(e._signerService.getPublicKey()).then(n=>{e._profile.next(n)})}catch(n){console.error("Error fetching profile metadata:",n)}})()}getChats(){var e=this;return(0,f.A)(function*(){const n=e._signerService.getPublicKey(),o=yield e._signerService.isUsingExtension(),r=yield e._signerService.isUsingSecretKey();return e.decryptedPrivateKey=r?yield e._signerService.getDecryptedSecretKey():"",yield Promise.all([e.subscribeToChatList(n,o,r,e.decryptedPrivateKey)]),e.getChatListStream()})()}subscribeToChatList(e,n,o,r){var a=this;return this._relayService.ensureConnectedRelays().then((0,f.A)(function*(){const u=[{kinds:[$.rV],authors:[e],limit:1500},{kinds:[$.rV],"#p":[e],limit:1500}];var l;a._relayService.getPool().subscribeMany(a._relayService.getConnectedRelays(),u,{onevent:(l=(0,f.A)(function*(d){const h=d.pubkey===e?d.tags.find(M=>"p"===M[0])?.[1]||"":d.pubkey;h&&d.created_at>(a.latestMessageTimestamps[h]||0)&&(a.messageQueue.push(d),a.processNextMessage(e,n,o,r))}),function(h){return l.apply(this,arguments)}),oneose:()=>{(a.chatList||[]).length>0&&a._chats.next(a.chatList)}})})),this.getChatListStream()}processNextMessage(e,n,o,r){var a=this;return(0,f.A)(function*(){if(!a.isDecrypting&&0!==a.messageQueue.length){a.isDecrypting=!0;try{for(;a.messageQueue.length>0;){const u=a.messageQueue.shift();if(!u)continue;const l=u.pubkey===e,d=l?u.tags.find(y=>"p"===y[0])?.[1]||"":u.pubkey;if(!d)continue;const h=yield a.decryptReceivedMessage(u,n,o,r,d);h&&a.addOrUpdateChatList(d,h,u.created_at,l)}}catch{}finally{a.isDecrypting=!1}}})()}addOrUpdateChatList(e,n,o,r){const a=this.chatList.find(l=>l.contact?.pubKey===e),u={id:`${e}-${o}`,chatId:e,contactId:e,isMine:r,value:n,createdAt:new Date(1e3*o).toISOString()};if(a)a.messages?.some(d=>d.id===u.id)||(a.messages=[...a.messages||[],u].sort((d,h)=>new Date(d.createdAt).getTime()-new Date(h.createdAt).getTime()),Number(a.lastMessageAt)h.pubKey===e)||{pubKey:e};this.chatList.push({id:e,contact:{pubKey:l.pubKey,name:l.name||"Unknown",picture:l.picture||"/images/avatars/avatar-placeholder.png",about:l.about||"",displayName:l.displayName||l.name||"Unknown"},lastMessage:n,lastMessageAt:o,messages:[u]})}this.chatList.sort((l,d)=>Number(d.lastMessageAt)-Number(l.lastMessageAt)),this._chats.next(this.chatList),this._storageService.profile$.pipe((0,Y.p)(l=>l&&l.pubKey===e)).subscribe(l=>{const d=this.chatList.find(h=>h.contact?.pubKey===e);d&&(d.contact={...d.contact,name:l.metadata?.name||d.contact.name,picture:l.metadata?.picture||d.contact.picture,about:l.metadata?.about||d.contact.about,displayName:l.metadata?.displayName||l.metadata?.name||d.contact.displayName},this._chats.next(this.chatList))})}getChatListStream(){return this._chats.asObservable()}decryptReceivedMessage(e,n,o,r,a){var u=this;return(0,f.A)(function*(){return n&&!o?yield u._signerService.decryptMessageWithExtension(a,e.content):o&&!n?yield u._signerService.decryptMessage(r,a,e.content):void 0})()}loadAndFetchChatHistory(e,n=!1){var o=this;return(0,f.A)(function*(){const r=o._signerService.getPublicKey(),a=[{kinds:[$.rV],authors:[r],"#p":[e],limit:10},{kinds:[$.rV],authors:[e],"#p":[r],limit:10}],u=[];if(o._relayService.getPool().subscribeMany(o._relayService.getConnectedRelays(),a,{onevent:(l=(0,f.A)(function*(d){const h=d.pubkey===r,y=h?e:d.pubkey,M=yield o._signerService.isUsingExtension(),_e=yield o._signerService.isUsingSecretKey(),T=yield o.decryptReceivedMessage(d,M,_e,o.decryptedPrivateKey,y);if(T){const U=Math.floor(d.created_at),Ce={id:d.id,chatId:e,contactId:y,isMine:h,value:T,createdAt:new Date(1e3*U).toISOString()};n&&u.push(Ce),o.addOrUpdateChatList(e,T,U,h),o._chat.next(o.chatList.find(be=>be.id===e))}}),function(h){return l.apply(this,arguments)}),oneose:()=>{}}),n)return yield new Promise(l=>setTimeout(l,1e3)),u;var l})()}updateChat(e,n){return this.chats$.pipe((0,X.s)(1),(0,G.n)(o=>{const r=n.contact?.pubKey;if(!r)return(0,R.$)("No public key found for this chat");const a={kind:4,pubkey:r,content:JSON.stringify(n),created_at:Math.floor(Date.now()/1e3),tags:[["p",r]]};return a.id=(0,L.dq)(a),(0,B.H)(this._relayService.publishEventToWriteRelays(a)).pipe((0,D.T)(()=>{if(o){const u=o.findIndex(l=>l.id===e);-1!==u&&(o[u]=n,this._chats.next(o))}return n}),(0,S.W)(u=>(console.error("Failed to update chat via Nostr:",u),(0,R.$)(u))))}))}getChatById(e,n=null){return this.recipientPublicKey=e,(0,B.H)(Promise.all([this._signerService.getPublicKey()])).pipe((0,G.n)(()=>this.chats$.pipe((0,X.s)(1),(0,G.n)(o=>{if(!o||0===o.length)return this.createNewChat(e,n);const r=o.find(a=>a.id===e);return r?(this._chat.next(r),this.loadAndFetchChatHistory(this.recipientPublicKey),(0,K.of)(r)):this.createNewChat(e,n)}))),(0,S.W)(o=>(console.error("Error fetching chat by id from Nostr:",o),(0,R.$)(o))))}createNewChat(e,n=null){const o={id:e||"",contact:n?{pubKey:n.pubKey||e,name:n.name||"Unknown",picture:n.picture||"/images/avatars/avatar-placeholder.png"}:{pubKey:e,name:"Unknown",picture:"/images/avatars/avatar-placeholder.png"},lastMessage:"new chat...",lastMessageAt:Math.floor(Date.now()/1e3)||0,messages:[]};return this._metadataQueueService.addPublicKey(e),this._storageService.profile$.pipe((0,Y.p)(r=>r&&r.pubKey===e),(0,D.T)(r=>(o.contact={pubKey:e,name:r.metadata?.name||"Unknown",picture:r.metadata?.picture||"/images/avatars/avatar-placeholder.png",about:r.metadata?.about||"",displayName:r.metadata?.displayName||r.metadata?.name||"Unknown"},o)))}resetChat(){this._chat.next(null)}sendPrivateMessage(e){var n=this;return(0,f.A)(function*(){try{n.message=e;const o=yield n._signerService.isUsingExtension(),r=yield n._signerService.isUsingSecretKey();if(o&&!r)yield n.handleMessageSendingWithExtension();else if(!o&&r){if(!n.isValidMessageSetup())return void console.error("Message, sender private key, or recipient public key is not properly set.");const a=yield n._signerService.encryptMessage(n.decryptedPrivateKey,n.recipientPublicKey,n.message),u=n._signerService.getUnsignedEvent(4,[["p",n.recipientPublicKey]],a),l=n._signerService.getSignedEvent(u,n.decryptedPrivateKey);(yield n._relayService.publishEventToWriteRelays(l))?n.message="":console.error("Failed to send the message.")}}catch(o){console.error("Error sending private message:",o)}})()}handleMessageSendingWithExtension(){var e=this;return(0,f.A)(function*(){try{const n=yield e._signerService.encryptMessageWithExtension(e.message,e.recipientPublicKey),o=yield e._signerService.signEventWithExtension({kind:4,pubkey:e._signerService.getPublicKey(),tags:[["p",e.recipientPublicKey]],content:n,created_at:Math.floor(Date.now()/1e3)});(yield e._relayService.publishEventToWriteRelays(o))?e.message="":console.error("Failed to send the message with extension.")}catch(n){console.error("Error sending message with extension:",n)}})()}isValidMessageSetup(){return""!==this.message.trim()&&""!==this.recipientPublicKey}ngOnDestroy(){this._unsubscribeAll.next(),this._unsubscribeAll.complete()}static{this.\u0275fac=function(n){return new(n||i)(t.KVO(H.A),t.KVO(z.n),t.KVO(W.b),t.KVO(Q.T))}}static{this.\u0275prov=t.jDH({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var g=c(4460),p=c(9471),v=c(6071),m=c(3904),k=c(6389),x=c(7818),C=c(5785),Z=c(9561);let J=(()=>{class i{transform(e){return/\.(jpeg|jpg|gif|png|bmp|svg|webp|tiff)$/i.test(e)?"\u{1f304} image":/\.(mp4|mov|avi|mkv|webm|flv|wmv|mpeg|3gp)$/i.test(e)?"\u{1f3ac} video":/\.(mp3|wav|ogg|m4a|aac|flac)$/i.test(e)?"\u{1f3b5} audio":/\.pdf$/i.test(e)?"\u{1f4c1} pdf":/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/.test(e)?"\u{1f4fd}\ufe0f youtube":/https?:\/\/(www\.)?vimeo.com\/(\d+)/.test(e)?"\u{1f4fd}\ufe0f vimeo":/https?:\/\/(www\.)?instagram.com\/p\/[a-zA-Z0-9_-]+/.test(e)?"\u{1f52e} instagram":/https?:\/\/(www\.)?twitter.com\/[a-zA-Z0-9_]+\/status\/[0-9]+/.test(e)?"\u{1f426} twitter":/(https?:\/\/[^\s]+)/.test(e)?"\u{1f310} url":e}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275pipe=t.EJ8({name:"checkmessage",type:i,pure:!0})}}return i})();var w=c(5424);function q(i,s){if(1&i){const e=t.RV6();t.j41(0,"div",15),t.bIt("click",function(){t.eBV(e);const o=t.XpG().$implicit,r=t.XpG(2);return t.Njj(r.openChat(o))}),t.EFF(1),t.k0s()}if(2&i){const e=t.XpG().$implicit;t.R7$(),t.SpI(" ",e.name.charAt(0)," ")}}function tt(i,s){if(1&i&&t.nrm(0,"img",10),2&i){const e=t.XpG().$implicit;t.Y8G("src",e.picture,t.B4B)}}function et(i,s){if(1&i&&(t.j41(0,"div",11),t.EFF(1),t.k0s()),2&i){const e=t.XpG().$implicit;t.R7$(),t.SpI(" ",e.name.charAt(0)," ")}}function nt(i,s){if(1&i){const e=t.RV6();t.DNE(0,q,2,1,"div",7),t.j41(1,"div",8),t.bIt("click",function(){const o=t.eBV(e).$implicit,r=t.XpG(2);return t.Njj(r.openChat(o))}),t.j41(2,"div",9),t.DNE(3,tt,1,1,"img",10)(4,et,2,1,"div",11),t.k0s(),t.j41(5,"div",12)(6,"div",13),t.EFF(7),t.k0s(),t.j41(8,"div",14),t.EFF(9),t.k0s()()()}if(2&i){const e=s.$implicit,n=s.$index,o=t.XpG(2);t.vxM(0===n||e.name.charAt(0)!==o.contacts[n-1].name.charAt(0)?0:-1),t.R7$(3),t.vxM(e.picture?3:-1),t.R7$(),t.vxM(e.picture?-1:4),t.R7$(3),t.SpI(" ",e.name," "),t.R7$(2),t.SpI(" ",e.about," ")}}function it(i,s){if(1&i&&t.Z7z(0,nt,10,5,null,null,t.BUC().trackByFn,!0),2&i){const e=t.XpG();t.Dyx(e.contacts)}}function ot(i,s){1&i&&(t.j41(0,"div",6),t.EFF(1," There are no contacts! "),t.k0s())}let rt=(()=>{class i{constructor(e,n){this._chatService=e,this.router=n,this.contacts=[],this._unsubscribeAll=new I.B}ngOnInit(){this._chatService.contacts$.pipe((0,w.Q)(this._unsubscribeAll)).subscribe(e=>{this.contacts=e})}ngOnDestroy(){this._unsubscribeAll.next(null),this._unsubscribeAll.complete()}trackByFn(e,n){return n.id||e}openChat(e){this._chatService.getChatById(e.pubKey,e).subscribe({next:n=>{console.log("Chat loaded or created:",n),this.router.navigate(["/chat",e.pubKey])},error:n=>{console.error("Error loading or creating chat:",n)},complete:()=>{this.drawer.close()}})}static{this.\u0275fac=function(n){return new(n||i)(t.rXU(b),t.rXU(_.Ix))}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["chat-new-chat"]],inputs:{drawer:"drawer"},decls:9,vars:2,consts:[[1,"bg-card","flex","h-full","flex-auto","flex-col","overflow-hidden","dark:bg-default"],[1,"-mb-px","flex","h-18","flex-0","items-center","bg-gray-50","px-6","dark:bg-transparent"],["mat-icon-button","",3,"click"],[3,"svgIcon"],[1,"ml-2","text-2xl","font-semibold"],[1,"relative","overflow-y-auto"],[1,"border-t","p-8","text-center","text-4xl","font-semibold","tracking-tight","sm:p-16"],[1,"text-secondary","sticky","top-0","z-10","-mt-px","border-b","border-t","bg-gray-100","px-6","py-1","font-medium","uppercase","dark:bg-gray-900","md:px-8"],[1,"z-20","flex","cursor-pointer","items-center","border-b","px-6","py-4","dark:hover:bg-hover","hover:bg-gray-100","md:px-8",3,"click"],[1,"flex","h-10","w-10","flex-0","items-center","justify-center","overflow-hidden","rounded-full"],["onerror","this.onerror=null; this.src='/images/avatars/avatar-placeholder.png';","alt","Contact picture",1,"h-full","w-full","object-cover",3,"src"],[1,"flex","h-full","w-full","items-center","justify-center","rounded-full","bg-gray-200","text-lg","uppercase","text-gray-600","dark:bg-gray-700","dark:text-gray-200"],[1,"ml-4","min-w-0"],[1,"truncate","font-medium","leading-5"],[1,"text-secondary","truncate","leading-5"],[1,"text-secondary","sticky","top-0","z-10","-mt-px","border-b","border-t","bg-gray-100","px-6","py-1","font-medium","uppercase","dark:bg-gray-900","md:px-8",3,"click"]],template:function(n,o){1&n&&(t.j41(0,"div",0)(1,"div",1)(2,"button",2),t.bIt("click",function(){return o.drawer.close()}),t.nrm(3,"mat-icon",3),t.k0s(),t.j41(4,"div",4),t.EFF(5,"New chat"),t.k0s()(),t.j41(6,"div",5),t.DNE(7,it,2,0)(8,ot,2,0,"div",6),t.k0s()()),2&n&&(t.R7$(3),t.Y8G("svgIcon","heroicons_outline:arrow-long-left"),t.R7$(4),t.vxM(o.contacts.length?7:8))},dependencies:[p.Hl,p.iY,m.m_,m.An],encapsulation:2,changeDetection:0})}}return i})();var j=c(936);function st(i,s){if(1&i&&t.nrm(0,"img",7),2&i){const e=t.XpG();t.Y8G("src",e.profile.picture,t.B4B)("alt","Profile picture")}}function at(i,s){if(1&i&&(t.j41(0,"div",8),t.EFF(1),t.k0s()),2&i){const e=t.XpG();t.R7$(),t.SpI(" ",e.profile.name.charAt(0)," ")}}let ct=(()=>{class i{constructor(e){this._chatService=e,this._unsubscribeAll=new I.B}ngOnInit(){this._chatService.profile$.pipe((0,w.Q)(this._unsubscribeAll)).subscribe(e=>{this.profile=e})}ngOnDestroy(){this._unsubscribeAll.next(null),this._unsubscribeAll.complete()}static{this.\u0275fac=function(n){return new(n||i)(t.rXU(b))}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["chat-profile"]],inputs:{drawer:"drawer"},decls:32,vars:9,consts:[[1,"bg-card","flex","flex-auto","flex-col","overflow-y-auto","dark:bg-default"],[1,"flex","h-18","flex-0","items-center","border-b","bg-gray-50","px-6","dark:bg-transparent"],["mat-icon-button","",3,"click"],[3,"svgIcon"],[1,"ml-2","text-2xl","font-semibold"],[1,"px-6"],[1,"relative","mx-auto","mt-8","flex","h-40","w-40","flex-0","rounded-full"],["onerror","this.onerror=null; this.src='/images/avatars/avatar-placeholder.png';",1,"h-full","w-full","rounded-full","object-cover",3,"src","alt"],[1,"flex","h-full","w-full","items-center","justify-center","rounded-full","bg-gray-200","text-8xl","font-semibold","uppercase","text-gray-600","dark:bg-gray-700","dark:text-gray-200"],[1,"mx-2","mt-8","flex","flex-col","space-y-6"],[1,"flex","items-center"],[1,"icon-size-5","mr-3","text-gray-500",3,"svgIcon"],[1,"text-sm","font-medium","text-gray-500"],[1,"text-lg"]],template:function(n,o){1&n&&(t.j41(0,"div",0)(1,"div",1)(2,"button",2),t.bIt("click",function(){return o.drawer.close()}),t.nrm(3,"mat-icon",3),t.k0s(),t.j41(4,"div",4),t.EFF(5,"Profile"),t.k0s()(),t.j41(6,"div",5)(7,"div",6),t.DNE(8,st,1,2,"img",7)(9,at,2,1,"div",8),t.k0s(),t.j41(10,"div",9)(11,"div",10),t.nrm(12,"mat-icon",11),t.j41(13,"div")(14,"div",12),t.EFF(15,"Name"),t.k0s(),t.j41(16,"div",13),t.EFF(17),t.k0s()()(),t.j41(18,"div",10),t.nrm(19,"mat-icon",11),t.j41(20,"div")(21,"div",12),t.EFF(22,"Username"),t.k0s(),t.j41(23,"div",13),t.EFF(24),t.k0s()()(),t.j41(25,"div",10),t.nrm(26,"mat-icon",11),t.j41(27,"div")(28,"div",12),t.EFF(29,"About"),t.k0s(),t.j41(30,"div",13),t.EFF(31),t.k0s()()()()()()),2&n&&(t.R7$(3),t.Y8G("svgIcon","heroicons_outline:arrow-long-left"),t.R7$(5),t.vxM(o.profile.picture?8:-1),t.R7$(),t.vxM(o.profile.picture?-1:9),t.R7$(3),t.Y8G("svgIcon","heroicons_solid:user-circle"),t.R7$(5),t.JRh(o.profile.name),t.R7$(2),t.Y8G("svgIcon","heroicons_solid:envelope"),t.R7$(5),t.JRh(o.profile.username),t.R7$(2),t.Y8G("svgIcon","heroicons_solid:identification"),t.R7$(5),t.JRh(o.profile.about))},dependencies:[p.Hl,p.iY,m.m_,m.An,v.RG,k.fS,j.YN],encapsulation:2,changeDetection:0})}}return i})();var lt=c(3871);const dt=(i,s)=>({"dark:hover:bg-hover hover:bg-gray-100":i,"bg-primary-50 dark:bg-hover":s}),ut=i=>[i],ht=(i,s)=>({"absolute inset-0 z-20 flex lg:static lg:inset-auto":i,"hidden lg:flex":s});function mt(i,s){if(1&i&&t.nrm(0,"chat-new-chat",6),2&i){t.XpG();const e=t.sdS(3);t.Y8G("drawer",e)}}function pt(i,s){if(1&i&&t.nrm(0,"chat-profile",6),2&i){t.XpG();const e=t.sdS(3);t.Y8G("drawer",e)}}function gt(i,s){if(1&i&&t.nrm(0,"img",15),2&i){const e=t.XpG(2);t.Y8G("src",null==e.profile?null:e.profile.picture,t.B4B)}}function ft(i,s){if(1&i&&(t.j41(0,"div",16),t.EFF(1),t.k0s()),2&i){const e=t.XpG(2);t.R7$(),t.SpI(" ",null==e.profile||null==e.profile.name?null:e.profile.name.charAt(0)," ")}}function vt(i,s){if(1&i&&t.nrm(0,"div",39),2&i){const e=t.XpG().$implicit,n=t.XpG(3);t.AVh("ring-primary-50",n.selectedChat&&n.selectedChat.id===e.id)}}function _t(i,s){if(1&i&&t.nrm(0,"img",40),2&i){const e=t.XpG().$implicit;t.Y8G("src",null==e.contact?null:e.contact.picture,t.B4B)}}function Ct(i,s){if(1&i&&(t.j41(0,"div",16),t.EFF(1),t.k0s()),2&i){const e=t.XpG().$implicit;t.R7$(),t.SpI(" ",null==e.contact||null==e.contact.name?null:e.contact.name.charAt(0)," ")}}function bt(i,s){1&i&&t.nrm(0,"mat-icon",38),2&i&&t.Y8G("svgIcon","heroicons_solid:speaker-x-mark")}function xt(i,s){if(1&i&&(t.j41(0,"a",28)(1,"div",29),t.DNE(2,vt,1,2,"div",30)(3,_t,1,1,"img",31)(4,Ct,2,1,"div",32),t.k0s(),t.j41(5,"div",33)(6,"div",34),t.EFF(7),t.k0s(),t.j41(8,"div",35),t.EFF(9),t.nI1(10,"checkmessage"),t.k0s()(),t.j41(11,"div",36)(12,"div",37),t.EFF(13),t.nI1(14,"ago"),t.k0s(),t.DNE(15,bt,1,1,"mat-icon",38),t.k0s()()),2&i){const e=s.$implicit,n=t.XpG(3);t.Y8G("ngClass",t.l_i(17,dt,!n.selectedChat||n.selectedChat.id!==e.id,n.selectedChat&&n.selectedChat.id===e.id))("routerLink",t.eq3(20,ut,e.id)),t.R7$(2),t.vxM(e.unreadCount>0?2:-1),t.R7$(),t.Y8G("ngIf",null==e.contact?null:e.contact.picture),t.R7$(),t.Y8G("ngIf",!(null!=e.contact&&e.contact.picture)),t.R7$(3),t.SpI(" ",null==e.contact?null:e.contact.name," "),t.R7$(),t.AVh("text-primary",e.unreadCount>0)("dark:text-primary-500",e.unreadCount>0),t.R7$(),t.SpI(" ",t.bMT(10,13,e.lastMessage)," "),t.R7$(4),t.SpI(" ",t.bMT(14,15,e.lastMessageAt)," "),t.R7$(2),t.vxM(e.muted?15:-1)}}function yt(i,s){if(1&i&&t.Z7z(0,xt,16,22,"a",28,t.BUC().trackByFn,!0),2&i){const e=t.XpG(2);t.Dyx(e.filteredChats)}}function kt(i,s){1&i&&(t.j41(0,"div",9),t.nrm(1,"mat-icon",41),t.j41(2,"div",42),t.EFF(3," No chats "),t.k0s()()),2&i&&(t.R7$(),t.Y8G("svgIcon","heroicons_outline:chat-bubble-oval-left-ellipsis"))}function wt(i,s){if(1&i){const e=t.RV6();t.j41(0,"div",8)(1,"div",11)(2,"div",12)(3,"div",13),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.openProfile())}),t.j41(4,"div",14),t.DNE(5,gt,1,1,"img",15)(6,ft,2,1,"div",16),t.k0s(),t.j41(7,"div",17),t.EFF(8),t.k0s()(),t.j41(9,"button",18),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.openNewChat())}),t.nrm(10,"mat-icon",19),t.k0s(),t.j41(11,"button",20),t.nrm(12,"mat-icon",19),t.j41(13,"mat-menu",null,1)(15,"button",21),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.openProfile())}),t.nrm(16,"mat-icon",19),t.EFF(17," Profile "),t.k0s(),t.j41(18,"button",22),t.nrm(19,"mat-icon",19),t.EFF(20," Archived "),t.k0s(),t.j41(21,"button",22),t.nrm(22,"mat-icon",19),t.EFF(23," Starred "),t.k0s(),t.j41(24,"button",22),t.nrm(25,"mat-icon",19),t.EFF(26," Settings "),t.k0s()()()(),t.j41(27,"div",23)(28,"mat-form-field",24),t.nrm(29,"mat-icon",25),t.j41(30,"input",26,2),t.bIt("input",function(){t.eBV(e);const o=t.sdS(31),r=t.XpG();return t.Njj(r.filterChats(o.value))}),t.k0s()()()(),t.j41(32,"div",27),t.DNE(33,yt,2,0)(34,kt,4,1,"div",9),t.k0s()()}if(2&i){const e=t.sdS(14),n=t.XpG();t.R7$(5),t.vxM(null!=n.profile&&n.profile.picture?5:-1),t.R7$(),t.vxM(null!=n.profile&&n.profile.picture?-1:6),t.R7$(2),t.SpI(" ",null==n.profile?null:n.profile.name," "),t.R7$(2),t.Y8G("svgIcon","heroicons_outline:plus-circle"),t.R7$(),t.Y8G("matMenuTriggerFor",e),t.R7$(),t.Y8G("svgIcon","heroicons_outline:ellipsis-vertical"),t.R7$(4),t.Y8G("svgIcon","heroicons_outline:user-circle"),t.R7$(3),t.Y8G("svgIcon","heroicons_outline:archive-box"),t.R7$(3),t.Y8G("svgIcon","heroicons_outline:star"),t.R7$(3),t.Y8G("svgIcon","heroicons_outline:cog-8-tooth"),t.R7$(3),t.Y8G("subscriptSizing","dynamic"),t.R7$(),t.Y8G("svgIcon","heroicons_solid:magnifying-glass"),t.R7$(),t.Y8G("autocomplete","off")("placeholder","Search or start new chat"),t.R7$(3),t.vxM(n.filteredChats.length>0?33:34)}}function jt(i,s){1&i&&(t.j41(0,"div",9),t.nrm(1,"mat-icon",41),t.j41(2,"div",42),t.EFF(3," No chats "),t.k0s()()),2&i&&(t.R7$(),t.Y8G("svgIcon","heroicons_outline:chat-bubble-oval-left-ellipsis"))}function Ft(i,s){if(1&i&&(t.j41(0,"div",10),t.nrm(1,"router-outlet"),t.k0s()),2&i){const e=t.XpG();t.Y8G("ngClass",t.l_i(1,ht,e.selectedChat&&e.selectedChat.id,!e.selectedChat||!e.selectedChat.id))}}let It=(()=>{class i{constructor(e,n,o,r){this._chatService=e,this._changeDetectorRef=n,this.route=o,this._angorNavigationService=r,this.chats=[],this.filteredChats=[],this.drawerOpened=!1,this._unsubscribeAll=new I.B}updateNavigationBadge(){const e=this._angorNavigationService.getComponent("mainNavigation");e&&(this._angorNavigationService.getItem("chat",e.navigation).badge.title="0",e.refresh())}ngOnInit(){this.updateNavigationBadge(),this._chatService.chats$.pipe((0,w.Q)(this._unsubscribeAll)).subscribe(n=>{this.chats=this.filteredChats=n,this._markForCheck()}),this._chatService.profile$.pipe((0,w.Q)(this._unsubscribeAll)).subscribe(n=>{this.profile=n,this._markForCheck()}),this._chatService.chat$.pipe((0,w.Q)(this._unsubscribeAll)).subscribe(n=>{this.selectedChat=n,this._markForCheck()});const e=localStorage.getItem("currentChatId");e&&this._chatService.checkCurrentChatOnPageRefresh(e)}ngOnDestroy(){this._unsubscribeAll.next(),this._unsubscribeAll.complete(),this._chatService.resetChat(),localStorage.removeItem("currentChatId")}filterChats(e){if(e){const n=e.toLowerCase();this.filteredChats=this.chats.filter(o=>o.contact?.name.toLowerCase().includes(n))}else this.filteredChats=this.chats;this._markForCheck()}openNewChat(){this.drawerComponent="new-chat",this.drawerOpened=!0,this._markForCheck()}openProfile(){this.drawerComponent="profile",this.drawerOpened=!0,this._markForCheck()}trackByFn(e,n){return n.id||e}_markForCheck(){this._changeDetectorRef.markForCheck()}static{this.\u0275fac=function(n){return new(n||i)(t.rXU(b),t.rXU(t.gRc),t.rXU(_.nX),t.rXU(lt.lX))}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["chat-chats"]],decls:10,vars:7,consts:[["drawer",""],["chatsHeaderMenu",""],["searchField",""],[1,"bg-card","relative","flex","w-full","flex-auto","dark:bg-transparent"],[1,"h-full","flex-auto",3,"hasBackdrop"],[1,"w-full","dark:bg-gray-900","sm:w-100","lg:border-r","lg:shadow-none",3,"openedChange","autoFocus","opened"],[3,"drawer"],[1,"flex","overflow-hidden"],[1,"bg-card","relative","flex","w-full","min-w-0","flex-auto","flex-col","dark:bg-transparent","lg:min-w-100","lg:max-w-100"],[1,"flex","h-full","flex-auto","flex-col","items-center","justify-center"],[1,"flex-auto","border-l",3,"ngClass"],[1,"flex","flex-0","flex-col","border-b","bg-gray-50","px-8","py-4","dark:bg-transparent"],[1,"flex","items-center"],[1,"mr-1","flex","cursor-pointer","items-center",3,"click"],[1,"h-10","w-10"],["onerror","this.onerror=null; this.src='/images/avatars/avatar-placeholder.png';","alt","Profile picture",1,"h-full","w-full","rounded-full","object-cover",3,"src"],[1,"flex","h-full","w-full","items-center","justify-center","rounded-full","bg-gray-200","text-lg","uppercase","text-gray-600","dark:bg-gray-700","dark:text-gray-200"],[1,"ml-4","truncate","font-medium"],["mat-icon-button","",1,"ml-auto",3,"click"],[3,"svgIcon"],["mat-icon-button","",1,"-mr-4","ml-1",3,"matMenuTriggerFor"],["mat-menu-item","",3,"click"],["mat-menu-item",""],[1,"mt-4"],[1,"angor-mat-rounded","angor-mat-dense","w-full",3,"subscriptSizing"],["matPrefix","",1,"icon-size-5",3,"svgIcon"],["matInput","",3,"input","autocomplete","placeholder"],[1,"flex-auto","overflow-y-auto"],[1,"z-20","flex","cursor-pointer","items-center","border-b","px-8","py-5",3,"ngClass","routerLink"],[1,"relative","flex","h-10","w-10","flex-0","items-center","justify-center"],[1,"ring-bg-card","absolute","bottom-0","right-0","-ml-0.5","h-2","w-2","flex-0","rounded-full","bg-primary","text-on-primary","ring-2","dark:bg-primary-500","dark:ring-gray-900",3,"ring-primary-50"],["class","h-full w-full rounded-full object-cover","alt","Contact picture",3,"src",4,"ngIf"],["class","flex h-full w-full items-center justify-center rounded-full bg-gray-200 text-lg uppercase text-gray-600 dark:bg-gray-700 dark:text-gray-200",4,"ngIf"],[1,"ml-4","min-w-0"],[1,"truncate","font-medium","leading-5"],[1,"text-secondary","truncate","leading-5"],[1,"ml-auto","flex","flex-col","items-end","self-start","pl-2"],[1,"text-secondary","overflow-hidden","whitespace-nowrap","text-sm","leading-5"],[1,"text-hint","icon-size-5",3,"svgIcon"],[1,"ring-bg-card","absolute","bottom-0","right-0","-ml-0.5","h-2","w-2","flex-0","rounded-full","bg-primary","text-on-primary","ring-2","dark:bg-primary-500","dark:ring-gray-900"],["alt","Contact picture",1,"h-full","w-full","rounded-full","object-cover",3,"src"],[1,"icon-size-24",3,"svgIcon"],[1,"text-secondary","mt-4","text-2xl","font-semibold","tracking-tight"]],template:function(n,o){if(1&n){const r=t.RV6();t.j41(0,"div",3)(1,"mat-drawer-container",4)(2,"mat-drawer",5,0),t.mxI("openedChange",function(u){return t.eBV(r),t.DH7(o.drawerOpened,u)||(o.drawerOpened=u),t.Njj(u)}),t.DNE(4,mt,1,1,"chat-new-chat",6)(5,pt,1,1,"chat-profile",6),t.k0s(),t.j41(6,"mat-drawer-content",7),t.DNE(7,wt,35,15,"div",8)(8,jt,4,1,"div",9)(9,Ft,2,4,"div",10),t.k0s()()()}2&n&&(t.R7$(),t.Y8G("hasBackdrop",!1),t.R7$(),t.Y8G("autoFocus",!1),t.R50("opened",o.drawerOpened),t.R7$(2),t.vxM("new-chat"===o.drawerComponent?4:-1),t.R7$(),t.vxM("profile"===o.drawerComponent?5:-1),t.R7$(2),t.vxM(o.chats&&o.chats.length>0?7:8),t.R7$(2),t.vxM(o.chats&&o.chats.length>0?9:-1))},dependencies:[C.vg,C.qe,C.$C,C.$l,rt,ct,p.Hl,p.iY,m.m_,m.An,x.Cn,x.kk,x.fb,x.Cp,v.RG,v.rl,v.JW,k.fS,k.fg,g.YU,_.Wk,_.n3,Z.g,g.MD,g.bT,J],encapsulation:2,changeDetection:0})}}return i})(),Rt=(()=>{class i{constructor(){}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["chat-empty-conversation"]],decls:5,vars:1,consts:[[1,"bg-card","flex","flex-auto","flex-col","overflow-y-auto","dark:bg-default","lg:overflow-hidden"],[1,"flex","flex-auto","flex-col","items-center","justify-center","bg-gray-100","dark:bg-transparent"],[1,"icon-size-24",3,"svgIcon"],[1,"text-secondary","mt-4","text-2xl","font-semibold","tracking-tight"]],template:function(n,o){1&n&&(t.j41(0,"div",0)(1,"div",1),t.nrm(2,"mat-icon",2),t.j41(3,"div",3),t.EFF(4," Select a conversation or start a new chat "),t.k0s()()()),2&n&&(t.R7$(2),t.Y8G("svgIcon","heroicons_outline:chat-bubble-oval-left-ellipsis"))},dependencies:[m.m_,m.An],encapsulation:2,changeDetection:0})}}return i})();var A=c(708),$t=c(1556),E=c(7544),Gt=c(4375),P=c(7691);let St=(()=>{class i{constructor(e){this.http=e}getTopGifs(e,n){const r=(new P.Nl).append("key",n).append("q",e);return this.http.get("https://g.tenor.com/v1/search",{params:r})}static{this.\u0275fac=function(n){return new(n||i)(t.KVO(P.Qq))}}static{this.\u0275prov=t.jDH({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();function Et(i,s){if(1&i){const e=t.RV6();t.j41(0,"div",8),t.bIt("click",function(){const o=t.eBV(e).$implicit,r=t.XpG(2);return t.Njj(r.selectGif(o))}),t.nrm(1,"img",9),t.k0s()}if(2&i){const e=s.$implicit;t.R7$(),t.Y8G("src",e,t.B4B)}}function Mt(i,s){if(1&i&&(t.j41(0,"div",6),t.DNE(1,Et,2,1,"div",7),t.k0s()),2&i){const e=t.XpG();t.R7$(),t.Y8G("ngForOf",e.gifsFound)}}let Tt=(()=>{class i{constructor(e,n,o,r){this.gifService=e,this.dialogRef=n,this._changeDetectorRef=o,this.data=r,this.gifSearch="",this.gifsFound=[]}searchGif(){this.gifSearch&&""!==this.gifSearch.trim()?this.data.apiKey?this.gifService.getTopGifs(this.gifSearch,this.data.apiKey).subscribe(e=>{this.gifsFound=e.results.map(n=>n.media[0].gif.url),this._changeDetectorRef.detectChanges()},e=>{console.error("Error fetching GIFs:",e)}):console.error("API key is missing."):console.error("Search term is empty.")}selectGif(e){this.dialogRef.close(e)}closeDialog(){this.dialogRef.close()}static{this.\u0275fac=function(n){return new(n||i)(t.rXU(St),t.rXU(E.CP),t.rXU(t.gRc),t.rXU(E.Vh))}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["gif-dialog"]],decls:10,vars:3,consts:[["mat-dialog-content",""],["appearance","outline",1,"full-width"],["matInput","","placeholder","keyword...",3,"ngModelChange","keyup.enter","ngModel"],["mat-icon-button","","matSuffix","",1,"ml-2","mr-2",3,"click"],[3,"svgIcon"],["class","results-container mt-4 grid grid-cols-3 gap-4",4,"ngIf"],[1,"results-container","mt-4","grid","grid-cols-3","gap-4"],["class","gif-preview h-24 w-full cursor-pointer",3,"click",4,"ngFor","ngForOf"],[1,"gif-preview","h-24","w-full","cursor-pointer",3,"click"],[1,"h-full","w-full","object-cover",3,"src"]],template:function(n,o){1&n&&(t.j41(0,"div",0)(1,"mat-form-field",1)(2,"mat-label"),t.EFF(3,"Search GIF"),t.k0s(),t.j41(4,"input",2),t.mxI("ngModelChange",function(a){return t.DH7(o.gifSearch,a)||(o.gifSearch=a),a}),t.bIt("keyup.enter",function(){return o.searchGif()}),t.k0s(),t.j41(5,"button",3),t.bIt("click",function(){return o.searchGif()}),t.nrm(6,"mat-icon",4),t.k0s(),t.j41(7,"mat-hint"),t.EFF(8,'Enter a keyword like "funny" or "cat" and hit search!'),t.k0s()(),t.DNE(9,Mt,2,1,"div",5),t.k0s()),2&n&&(t.R7$(4),t.R50("ngModel",o.gifSearch),t.R7$(2),t.Y8G("svgIcon","heroicons_outline:magnifying-glass"),t.R7$(3),t.Y8G("ngIf",o.gifsFound.length>0))},dependencies:[C.vg,p.Hl,p.iY,m.m_,m.An,j.YN,j.me,j.BC,j.vS,v.nJ,v.rl,j.X1,g.MD,g.Sq,g.bT,Gt.Ve,v.MV,v.yw,v.RG,k.fS,k.fg],styles:[".full-width[_ngcontent-%COMP%]{width:100%}.results-container[_ngcontent-%COMP%]{max-height:300px;overflow-y:auto;overflow-x:hidden}.gif-preview[_ngcontent-%COMP%]{transition:transform .2s}.gif-preview[_ngcontent-%COMP%]:hover{transform:scale(1.1)}"],changeDetection:0})}}return i})();const Nt=i=>["/profile",i];function Bt(i,s){if(1&i&&t.nrm(0,"img",8),2&i){const e=t.XpG();t.Y8G("src",null==e.chat.contact?null:e.chat.contact.picture,t.B4B)("alt","Contact picture")}}function Yt(i,s){if(1&i&&(t.j41(0,"div",9),t.EFF(1),t.k0s()),2&i){const e=t.XpG();t.R7$(),t.SpI(" ",null==e.chat.contact?null:e.chat.contact.name.charAt(0)," ")}}let Xt=(()=>{class i{constructor(){}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["chat-contact-info"]],inputs:{chat:"chat",drawer:"drawer"},decls:16,vars:8,consts:[[1,"bg-card","flex","h-full","flex-auto","flex-col","dark:bg-default"],[1,"flex","h-18","flex-0","items-center","border-b","bg-gray-50","px-4","dark:bg-transparent"],["mat-icon-button","",3,"click"],[3,"svgIcon"],[1,"ml-2","text-lg","font-medium"],[1,"overflow-y-auto"],[1,"mt-8","flex","flex-col","items-center"],[1,"h-40","w-40","rounded-full"],["onerror","this.onerror=null; this.src='/images/avatars/avatar-placeholder.png';",1,"h-full","w-full","rounded-full","object-cover",3,"src","alt"],[1,"flex","h-full","w-full","items-center","justify-center","rounded-full","bg-gray-200","text-8xl","font-semibold","uppercase","text-gray-600","dark:bg-gray-700","dark:text-gray-200"],[1,"mt-4","text-lg","font-medium"],[3,"routerLink"],[1,"text-secondary","ml-4","mr-4","mt-0.5","text-md"]],template:function(n,o){1&n&&(t.j41(0,"div",0)(1,"div",1)(2,"button",2),t.bIt("click",function(){return o.drawer.close()}),t.nrm(3,"mat-icon",3),t.k0s(),t.j41(4,"div",4),t.EFF(5,"Contact info"),t.k0s()(),t.j41(6,"div",5)(7,"div",6)(8,"div",7),t.DNE(9,Bt,1,2,"img",8)(10,Yt,2,1,"div",9),t.k0s(),t.j41(11,"div",10)(12,"a",11),t.EFF(13),t.k0s()(),t.j41(14,"div",12),t.EFF(15),t.k0s()()()()),2&n&&(t.R7$(3),t.Y8G("svgIcon","heroicons_outline:x-mark"),t.R7$(6),t.vxM(null!=o.chat.contact&&o.chat.contact.picture?9:-1),t.R7$(),t.vxM(null!=o.chat.contact&&o.chat.contact.picture?-1:10),t.R7$(2),t.Y8G("routerLink",t.eq3(6,Nt,null==o.chat.contact?null:o.chat.contact.pubKey)),t.R7$(),t.SpI(" ",null==o.chat.contact?null:o.chat.contact.name," "),t.R7$(2),t.SpI(" ",null==o.chat.contact?null:o.chat.contact.about," "))},dependencies:[p.Hl,p.iY,m.m_,m.An,_.iI,_.Wk],encapsulation:2,changeDetection:0})}}return i})();var Dt=c(2012),At=c(1109),Pt=c(6388),Ut=c(9207);const Ot=["messageInput"],Vt=()=>["./"],Kt=i=>({active:i}),Lt=(i,s,e,n)=>({"items-end":i,"items-start":s,"mt-0.5":e,"mt-3":n}),Ht=(i,s)=>({"bg-gray-400 text-blue-50":i,"bg-gray-500 text-gray-50":s}),zt=(i,s)=>({"-right-1 -mr-px mb-px text-gray-400":i,"-left-1 -ml-px mb-px -scale-x-1 text-gray-500":s}),Wt=(i,s)=>({"mr-3":i,"ml-3":s});function Qt(i,s){if(1&i&&t.nrm(0,"img",15),2&i){const e=t.XpG(2);t.Y8G("src",null==e.chat.contact?null:e.chat.contact.avatar,t.B4B)}}function Zt(i,s){if(1&i&&(t.j41(0,"div",16),t.EFF(1),t.k0s()),2&i){const e=t.XpG(2);t.R7$(),t.SpI(" ",null==e.chat.contact?null:e.chat.contact.name.charAt(0)," ")}}function Jt(i,s){1&i&&(t.qex(0),t.nrm(1,"mat-icon",12),t.EFF(2," Mute notifications "),t.bVm()),2&i&&(t.R7$(),t.Y8G("svgIcon","heroicons_outline:speaker-x-mark"))}function qt(i,s){1&i&&(t.qex(0),t.nrm(1,"mat-icon",12),t.EFF(2," Unmute notifications "),t.bVm()),2&i&&(t.R7$(),t.Y8G("svgIcon","heroicons_outline:speaker-wave"))}function te(i,s){if(1&i&&(t.j41(0,"div",32),t.nrm(1,"div",33),t.j41(2,"div",34),t.EFF(3),t.nI1(4,"date"),t.k0s(),t.nrm(5,"div",33),t.k0s()),2&i){const e=t.XpG().$implicit;t.R7$(3),t.SpI(" ",t.i5U(4,1,e.createdAt,"longDate")," ")}}function ee(i,s){1&i&&t.eu8(0)}function ne(i,s){if(1&i&&(t.j41(0,"div",37),t.DNE(1,ee,1,0,"ng-container",40),t.k0s()),2&i){const e=t.XpG(2).$implicit;t.XpG(2);const n=t.sdS(4);t.Y8G("ngClass",t.l_i(2,zt,e.isMine,!e.isMine)),t.R7$(),t.Y8G("ngTemplateOutlet",n)}}function ie(i,s){if(1&i&&(t.j41(0,"div",44),t.nrm(1,"iframe",45),t.k0s()),2&i){const e=t.XpG().$implicit;t.R7$(),t.Y8G("src",e.safeWord,t.f$h)}}function oe(i,s){if(1&i&&(t.j41(0,"div",44),t.nrm(1,"img",46),t.k0s()),2&i){const e=t.XpG().$implicit;t.R7$(),t.Y8G("src",e.safeWord,t.B4B)}}function re(i,s){if(1&i&&(t.j41(0,"div",44)(1,"video",47),t.nrm(2,"source",48),t.EFF(3," Your browser does not support the video tag. "),t.k0s()()),2&i){const e=t.XpG().$implicit;t.R7$(2),t.Y8G("src",e.safeWord,t.B4B)}}function se(i,s){if(1&i&&(t.j41(0,"div",44)(1,"audio",49),t.nrm(2,"source",50),t.EFF(3," Your browser does not support the audio element. "),t.k0s()()),2&i){const e=t.XpG().$implicit;t.R7$(2),t.Y8G("src",e.safeWord,t.B4B)}}function ae(i,s){if(1&i&&(t.j41(0,"div",51)(1,"a",52),t.EFF(2),t.k0s()()),2&i){const e=t.XpG().$implicit;t.R7$(),t.Y8G("href",e.word,t.B4B),t.R7$(),t.JRh(e.word)}}function ce(i,s){if(1&i&&(t.j41(0,"span",51),t.EFF(1),t.k0s()),2&i){const e=t.XpG().$implicit;t.R7$(),t.JRh(e)}}function le(i,s){if(1&i&&(t.j41(0,"div",41),t.DNE(1,ie,2,1,"div",42)(2,oe,2,1,"div",42)(3,re,4,1,"div",42)(4,se,4,1,"div",42)(5,ae,3,2,"div",43)(6,ce,2,1,"span",43),t.k0s()),2&i){const e=s.$implicit;t.R7$(),t.Y8G("ngIf","youtube"===e.token),t.R7$(),t.Y8G("ngIf","image"===e.token),t.R7$(),t.Y8G("ngIf","video"===e.token),t.R7$(),t.Y8G("ngIf","audio"===e.token),t.R7$(),t.Y8G("ngIf","link"===e.token),t.R7$(),t.Y8G("ngIf",!e.token)}}function de(i,s){if(1&i&&(t.j41(0,"div",39),t.EFF(1),t.nI1(2,"date"),t.k0s()),2&i){const e=t.XpG(2).$implicit;t.Y8G("ngClass",t.l_i(5,Wt,e.isMine,!e.isMine)),t.R7$(),t.SpI(" ",t.i5U(2,2,e.createdAt,"HH:mm")," ")}}function ue(i,s){if(1&i&&(t.j41(0,"div")(1,"div",35)(2,"div",36),t.DNE(3,ne,2,5,"div",37)(4,le,7,6,"div",38),t.k0s(),t.DNE(5,de,3,8,"div",39),t.k0s()()),2&i){const e=t.XpG(),n=e.$implicit,o=e.$index,r=e.$count,a=t.XpG(2);t.R7$(),t.Y8G("ngClass",t.ziG(6,Lt,n.isMine,!n.isMine,o>0&&a.chat.messages[o-1].isMine===n.isMine,o>0&&a.chat.messages[o-1].isMine!==n.isMine)),t.R7$(),t.Y8G("ngClass",t.l_i(11,Ht,n.isMine,!n.isMine)),t.R7$(),t.vxM(o===r-1||a.chat.messages[o+1].isMine!==n.isMine?3:-1),t.R7$(),t.Y8G("ngForOf",a.parseContent.parseContent(n.value))("ngForTrackBy",a.trackByFn),t.R7$(),t.vxM(0===o||o===r-1||a.chat.messages[o+1].isMine!==n.isMine||a.chat.messages[o+1].createdAt!==n.createdAt?5:-1)}}function he(i,s){if(1&i&&(t.DNE(0,te,6,4,"div",32),t.nI1(1,"date"),t.nI1(2,"date"),t.DNE(3,ue,6,14,"div",21)),2&i){const e=s.$implicit,n=s.$index,o=t.XpG(2);t.vxM(0===n||t.i5U(1,2,o.chat.messages[n-1].createdAt,"d")!==t.i5U(2,5,e.createdAt,"d")?0:-1),t.R7$(3),t.Y8G("ngIf",!e.id.includes("new-chat"))}}function me(i,s){if(1&i){const e=t.RV6();t.j41(0,"div",53)(1,"emoji-mart",54),t.bIt("emojiClick",function(o){t.eBV(e);const r=t.XpG(2);return t.Njj(r.addEmoji(o))}),t.k0s()()}if(2&i){const e=t.XpG(2);t.R7$(),t.Y8G("darkMode",e.darkMode)}}function pe(i,s){if(1&i){const e=t.RV6();t.j41(0,"mat-drawer-container",5)(1,"mat-drawer",7,1),t.mxI("openedChange",function(o){t.eBV(e);const r=t.XpG();return t.DH7(r.drawerOpened,o)||(r.drawerOpened=o),t.Njj(o)}),t.nrm(3,"chat-contact-info",8),t.k0s(),t.j41(4,"mat-drawer-content",9)(5,"div",10)(6,"a",11),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.resetChat())}),t.nrm(7,"mat-icon",12),t.k0s(),t.j41(8,"div",13),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.openContactInfo())}),t.j41(9,"div",14),t.DNE(10,Qt,1,1,"img",15)(11,Zt,2,1,"div",16),t.k0s(),t.j41(12,"div",17),t.EFF(13),t.k0s()(),t.j41(14,"button",18),t.nrm(15,"mat-icon",12),t.j41(16,"mat-menu",null,2)(18,"button",19),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.openContactInfo())}),t.nrm(19,"mat-icon",12),t.EFF(20," Contact info "),t.k0s(),t.j41(21,"button",20),t.nrm(22,"mat-icon",12),t.EFF(23," Select messages "),t.k0s(),t.j41(24,"button",19),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.toggleMuteNotifications())}),t.DNE(25,Jt,3,1,"ng-container",21)(26,qt,3,1,"ng-container",21),t.k0s(),t.j41(27,"button",20),t.nrm(28,"mat-icon",12),t.EFF(29," Clear messages "),t.k0s(),t.j41(30,"button",20),t.nrm(31,"mat-icon",12),t.EFF(32," Delete chat "),t.k0s()()()(),t.j41(33,"div",22)(34,"div",23),t.Z7z(35,he,4,8,null,null,t.BUC().trackByFn,!0),t.k0s()(),t.j41(37,"div",24)(38,"div",25)(39,"button",26),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.openGifDialog())}),t.nrm(40,"mat-icon",12),t.k0s(),t.j41(41,"button",26),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.toggleEmojiPicker())}),t.nrm(42,"mat-icon",12),t.k0s(),t.DNE(43,me,2,1,"div",27),t.j41(44,"button",26),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.toggleSpeechRecognition())}),t.nrm(45,"mat-icon",28),t.k0s()(),t.j41(46,"mat-form-field",29)(47,"textarea",30,3),t.bIt("keydown",function(o){t.eBV(e);const r=t.XpG();return t.Njj(r.handleKeyDown(o))}),t.k0s()(),t.j41(49,"div",31)(50,"button",26),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.sendMessage())}),t.nrm(51,"mat-icon",12),t.k0s()()()()()}if(2&i){const e=t.sdS(2),n=t.sdS(17),o=t.XpG();t.Y8G("hasBackdrop",!1),t.R7$(),t.Y8G("autoFocus",!1)("mode",o.drawerMode)("position","end"),t.R50("opened",o.drawerOpened),t.R7$(2),t.Y8G("drawer",e)("chat",o.chat),t.R7$(3),t.Y8G("routerLink",t.lJ4(26,Vt)),t.R7$(),t.Y8G("svgIcon","heroicons_outline:arrow-long-left"),t.R7$(3),t.vxM(null!=o.chat.contact&&o.chat.contact.avatar?10:-1),t.R7$(),t.vxM(null!=o.chat.contact&&o.chat.contact.avatar?-1:11),t.R7$(2),t.SpI(" ",null==o.chat.contact?null:o.chat.contact.name," "),t.R7$(),t.Y8G("matMenuTriggerFor",n),t.R7$(),t.Y8G("svgIcon","heroicons_outline:ellipsis-vertical"),t.R7$(4),t.Y8G("svgIcon","heroicons_outline:user-circle"),t.R7$(3),t.Y8G("svgIcon","heroicons_outline:check-circle"),t.R7$(3),t.Y8G("ngIf",!o.chat.muted),t.R7$(),t.Y8G("ngIf",o.chat.muted),t.R7$(2),t.Y8G("svgIcon","heroicons_outline:backspace"),t.R7$(3),t.Y8G("svgIcon","heroicons_outline:trash"),t.R7$(4),t.Dyx(o.chat.messages),t.R7$(5),t.Y8G("svgIcon","heroicons_outline:gif"),t.R7$(2),t.Y8G("svgIcon","heroicons_outline:face-smile"),t.R7$(),t.Y8G("ngIf",o.showEmojiPicker),t.R7$(2),t.Y8G("ngClass",t.eq3(27,Kt,o.isListening))("svgIcon",o.isListening?"heroicons_solid:microphone":"heroicons_outline:microphone"),t.R7$(6),t.Y8G("svgIcon","heroicons_outline:paper-airplane")}}function ge(i,s){1&i&&(t.j41(0,"div",6),t.nrm(1,"mat-icon",55),t.j41(2,"div",56),t.EFF(3," Select a conversation or start a new chat "),t.k0s()()),2&i&&(t.R7$(),t.Y8G("svgIcon","heroicons_outline:chat-bubble-oval-left-ellipsis"))}function fe(i,s){1&i&&(t.qSk(),t.j41(0,"svg",57)(1,"g",58),t.nrm(2,"path",59),t.k0s()())}const ve=[{path:"",component:O,resolve:{chats:()=>(0,t.WQX)(b).getChats(),contacts:()=>(0,t.WQX)(b).getContacts(),profile:()=>(0,t.WQX)(b).getProfile()},children:[{path:"",component:It,children:[{path:"",pathMatch:"full",component:Rt},{path:":id",component:(()=>{class i{constructor(e,n,o,r,a,u,l,d){this._changeDetectorRef=e,this._chatService=n,this._angorMediaWatcherService=o,this._ngZone=r,this._angorConfigService=a,this.dialog=u,this.sanitizer=l,this.parseContent=d,this.drawerMode="side",this.drawerOpened=!1,this._unsubscribeAll=new I.B,this.showEmojiPicker=!1,this.darkMode=!1,this.finalTranscript="",this.isListening=!1,this.userEdited=!1;const h=window.SpeechRecognition||window.webkitSpeechRecognition;h?(this.recognition=new h,this.recognition.lang="en-US",this.recognition.continuous=!0,this.recognition.interimResults=!0,this.setupRecognitionEvents()):console.error("Speech recognition is not supported in this browser.")}openGifDialog(){this.dialog.open(Tt,{width:"600px",maxHeight:"80vh",data:{apiKey:"LIVDSRZULELA"}}).afterClosed().subscribe(n=>{if(n){const o=n;o&&(this.messageInput.nativeElement.value="",this._chatService.sendPrivateMessage(o).then(()=>{this.messageInput.nativeElement.value="",this.finalTranscript=""}).catch(r=>{console.error("Failed to send message:",r)}),this.finalTranscript="",this.userEdited=!1)}})}ngOnInit(){this._angorConfigService.config$.subscribe(e=>{"auto"===e.scheme?this.detectSystemTheme():this.darkMode="dark"===e.scheme}),this._chatService.chat$.pipe((0,w.Q)(this._unsubscribeAll)).subscribe(e=>{this.chat=e,this._changeDetectorRef.markForCheck()}),this._angorMediaWatcherService.onMediaChange$.pipe((0,w.Q)(this._unsubscribeAll)).subscribe(({matchingAliases:e})=>{this.drawerMode=e.includes("lg")?"side":"over",this._changeDetectorRef.markForCheck()})}_resizeMessageInput(){this._ngZone.runOutsideAngular(()=>{setTimeout(()=>{this.messageInput.nativeElement.style.height="auto",this._changeDetectorRef.detectChanges(),this.messageInput.nativeElement.style.height=`${this.messageInput.nativeElement.scrollHeight}px`,this._changeDetectorRef.detectChanges()})})}setupRecognitionEvents(){this.recognition.onresult=e=>{let n="";for(let o=e.resultIndex;o{console.error("Speech recognition error detected: ",e.error)},this.recognition.onend=()=>{this.isListening=!1}}toggleSpeechRecognition(){this.finalTranscript="",this.isListening?(this.recognition.stop(),this.isListening=!1):(this.recognition.start(),this.isListening=!0,this.userEdited=!1)}handleUserInput(e){this.userEdited=!0}ngOnDestroy(){this._unsubscribeAll.next(null),this._unsubscribeAll.complete()}openContactInfo(){this.drawerOpened=!0,this._changeDetectorRef.markForCheck()}resetChat(){this._chatService.resetChat(),this.drawerOpened=!1,this._changeDetectorRef.markForCheck()}toggleMuteNotifications(){this.chat.muted=!this.chat.muted,this._chatService.updateChat(this.chat.id,this.chat).subscribe()}trackByFn(e,n){return n.id||e}detectSystemTheme(){const e=window.matchMedia("(prefers-color-scheme: dark)");this.darkMode=e.matches,e.addEventListener("change",n=>{this.darkMode=n.matches})}handleKeyDown(e){"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),this.sendMessage())}sendMessage(){const e=this.messageInput.nativeElement.value.trim();e&&(this.messageInput.nativeElement.value="",this._chatService.sendPrivateMessage(e).then(()=>{this.messageInput.nativeElement.value="",this.finalTranscript=""}).catch(n=>{console.error("Failed to send message:",n)}),this.finalTranscript="",this.userEdited=!1)}addEmoji(e){this.messageInput.nativeElement.value+=e.emoji.native,this.showEmojiPicker=!1}toggleEmojiPicker(){this.showEmojiPicker=!this.showEmojiPicker}static{this.\u0275fac=function(n){return new(n||i)(t.rXU(t.gRc),t.rXU(b),t.rXU(Dt.l),t.rXU(t.SKi),t.rXU(At.P),t.rXU(E.bZ),t.rXU(Pt.up),t.rXU(Ut.m))}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["chat-conversation"]],viewQuery:function(n,o){if(1&n&&t.GBs(Ot,5),2&n){let r;t.mGM(r=t.lsd())&&(o.messageInput=r.first)}},hostBindings:function(n,o){1&n&&t.bIt("input",function(){return o._resizeMessageInput()})("ngModelChange",function(){return o._resizeMessageInput()})},decls:5,vars:1,consts:[["speechBubbleExtension",""],["drawer",""],["conversationHeaderMenu",""],["messageInput",""],[1,"bg-card","flex","flex-auto","flex-col","overflow-y-auto","dark:bg-default","lg:overflow-hidden"],[1,"h-full","flex-auto",3,"hasBackdrop"],[1,"flex","flex-auto","flex-col","items-center","justify-center","bg-gray-100","dark:bg-transparent"],[1,"w-full","dark:bg-gray-900","sm:w-100","lg:border-l","lg:shadow-none",3,"openedChange","autoFocus","mode","position","opened"],[3,"drawer","chat"],[1,"flex","flex-col","overflow-hidden"],[1,"flex","h-18","flex-0","items-center","border-b","bg-gray-50","px-4","dark:bg-transparent","md:px-6"],["mat-icon-button","",1,"md:-ml-2","lg:hidden",3,"click","routerLink"],[3,"svgIcon"],[1,"ml-2","mr-2","flex","cursor-pointer","items-center","lg:ml-0",3,"click"],[1,"relative","flex","h-10","w-10","flex-0","items-center","justify-center"],["onerror","this.onerror=null; this.src='/images/avatars/avatar-placeholder.png';","alt","Contact picture",1,"h-full","w-full","rounded-full","object-cover",3,"src"],[1,"flex","h-full","w-full","items-center","justify-center","rounded-full","bg-gray-200","text-lg","uppercase","text-gray-600","dark:bg-gray-700","dark:text-gray-200"],[1,"ml-4","truncate","text-lg","font-medium","leading-5"],["mat-icon-button","",1,"ml-auto",3,"matMenuTriggerFor"],["mat-menu-item","",3,"click"],["mat-menu-item",""],[4,"ngIf"],[1,"flex","h-full","flex-col-reverse","overflow-y-auto"],[1,"bg-card","flex","flex-auto","shrink","flex-col","p-6","dark:bg-transparent"],[1,"flex","items-end","border-t","bg-gray-50","p-4","dark:bg-transparent"],[1,"my-px","flex","h-11","items-center"],["mat-icon-button","",3,"click"],["class","emoji-picker-container",4,"ngIf"],[3,"ngClass","svgIcon"],["subscriptSizing","dynamic",1,"angor-mat-dense","angor-mat-rounded","angor-mat-bold","ml-4","w-full"],["matInput","","cdkTextareaAutosize","",1,"max-h-20",3,"keydown"],[1,"my-px","ml-4","flex","h-11","items-center"],[1,"-mx-6","my-3","flex","items-center","justify-center"],[1,"flex-auto","border-b"],[1,"text-secondary","mx-4","flex-0","text-sm","font-medium","leading-5"],[1,"flex","flex-col",3,"ngClass"],[1,"relative","max-w-3/4","rounded-lg","px-2","py-2",3,"ngClass"],[1,"absolute","bottom-0","w-3",3,"ngClass"],["style","display: inline-block; overflow-wrap: break-word; white-space: pre-wrap;",4,"ngFor","ngForOf","ngForTrackBy"],[1,"text-secondary","my-0.5","text-sm","font-medium",3,"ngClass"],[4,"ngTemplateOutlet"],[2,"display","inline-block","overflow-wrap","break-word","white-space","pre-wrap"],["style","display: block;",4,"ngIf"],["style","display: inline-block; overflow-wrap: break-word;",4,"ngIf"],[2,"display","block"],["width","560","height","315","frameborder","0","allowfullscreen","",3,"src"],["alt","Embedded Image",2,"max-width","100%",3,"src"],["controls","",2,"max-width","100%"],["type","video/mp4",3,"src"],["controls",""],["type","audio/mpeg",3,"src"],[2,"display","inline-block","overflow-wrap","break-word"],["target","_blank",3,"href"],[1,"emoji-picker-container"],[3,"emojiClick","darkMode"],[1,"icon-size-24",3,"svgIcon"],[1,"text-secondary","mt-4","text-2xl","font-semibold","tracking-tight"],["width","100%","height","100%","viewBox","0 0 66 66","xmlns","http://www.w3.org/2000/svg"],["id","Page-1","stroke","none","stroke-width","1","fill","none","fill-rule","evenodd"],["d","M1.01522827,0.516204834 C-8.83532715,54.3062744 61.7609863,70.5215302 64.8009949,64.3061218 C68.8074951,54.8859711 30.1663208,52.9997559 37.5036011,0.516204834 L1.01522827,0.516204834 Z","fill","currentColor","fill-rule","nonzero"]],template:function(n,o){1&n&&(t.j41(0,"div",4),t.DNE(1,pe,52,29,"mat-drawer-container",5)(2,ge,4,1,"div",6)(3,fe,3,0,"ng-template",null,0,t.C5r),t.k0s()),2&n&&(t.R7$(),t.vxM(o.chat?1:2))},dependencies:[C.vg,C.qe,C.$C,C.$l,Xt,p.Hl,p.pQ,p.iY,_.Wk,m.m_,m.An,x.Cn,x.kk,x.fb,x.Cp,g.YU,g.T3,v.RG,v.rl,k.fS,k.fg,A.xb,A.EE,g.vh,$t.Ic,g.MD,g.Sq,g.bT],styles:[".c-img,.c-video{max-width:100%;border-radius:10px}\n"],encapsulation:2,changeDetection:0})}}return i})(),resolve:{conversation:(i,s)=>{const e=(0,t.WQX)(b),n=(0,t.WQX)(_.Ix);let o=i.paramMap.get("id")||localStorage.getItem("currentChatId");if(!o){const r=s.url.split("/").slice(0,-1).join("/");return n.navigateByUrl(r),(0,R.$)("No chat ID provided")}return localStorage.setItem("currentChatId",o),e.getChatById(o).pipe((0,S.W)(r=>{console.error("Error fetching conversation:",r);const a=s.url.split("/").slice(0,-1).join("/");return n.navigateByUrl(a),(0,R.$)(r)}))}}}]}]}]}}]); \ No newline at end of file diff --git a/512.a68be118134746e7.js b/512.a68be118134746e7.js new file mode 100644 index 0000000..eab1f4c --- /dev/null +++ b/512.a68be118134746e7.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkangor=self.webpackChunkangor||[]).push([[512],{1512:(be,N,c)=>{c.r(N),c.d(N,{default:()=>ve});var t=c(3107),_=c(8716);let O=(()=>{class i{constructor(){}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["chat"]],decls:3,vars:0,consts:[[1,"absolute","inset-0","flex","min-w-0","flex-col","overflow-hidden"],[1,"flex","flex-auto","overflow-hidden"]],template:function(n,o){1&n&&(t.j41(0,"div",0)(1,"div",1),t.nrm(2,"router-outlet"),t.k0s()())},dependencies:[_.n3],encapsulation:2,changeDetection:0})}}return i})();var f=c(3014),I=c(1217),R=c(8447),V=c(1698),F=c(8915),B=c(1787),K=c(3016),X=c(1483),Y=c(7610),G=c(2867),D=c(7947),S=c(7178),L=c(5492),$=c(3797),H=c(8078),z=c(3149),W=c(3125),Q=c(7121);let x=(()=>{class i{constructor(e,n,o,r){this._signerService=e,this._storageService=n,this._relayService=o,this._metadataQueueService=r,this.chatList=[],this.latestMessageTimestamps={},this.messageQueue=[],this.isDecrypting=!1,this.decryptedPrivateKey="",this._chat=new I.t(null),this._chats=new I.t(null),this._contact=new I.t(null),this._contacts=new I.t(null),this._profile=new I.t(null),this._unsubscribeAll=new R.B}get profile$(){return this._profile.asObservable()}get chat$(){return this._chat.asObservable()}get chats$(){return this._chats.asObservable()}get contact$(){return this._contact.asObservable()}get contacts$(){return this._contacts.asObservable()}checkCurrentChatOnPageRefresh(e){e&&this.getChatById(e).subscribe(o=>{o&&(this._chat.next(o),this.loadAndFetchChatHistory(e))})}getContact(e){var n=this;return(0,f.A)(function*(){try{if(!e)return;n._storageService.profile$.subscribe(o=>{o&&o.pubKey&&o.metadata&&o.pubKey===e&&n._contact.next({pubKey:e,displayName:o.metadata.name?o.metadata.name:"Unknown",picture:o.metadata.picture,about:o.metadata.about})})}catch(o){console.error("Error fetching contact metadata:",o)}})()}getContacts(){return new V.c(e=>(this._storageService.getAllProfiles().then(n=>{if(n&&n.length>0){const o=n.map(r=>(r.pubKey||console.error("Contact is missing pubKey:",r),r));this._contacts.next(o),e.next(o)}else e.next([]);e.complete()}).catch(n=>{console.error("Error loading cached contacts from IndexedDB:",n),e.next([]),e.complete()}),{unsubscribe(){}}))}getProfile(){var e=this;return(0,f.A)(function*(){try{e._storageService.profile$.subscribe(n=>{n&&n.pubKey&&n.metadata&&n.pubKey===e._signerService.getPublicKey()&&e._profile.next(n.metadata)}),e._storageService.getProfile(e._signerService.getPublicKey()).then(n=>{e._profile.next(n)})}catch(n){console.error("Error fetching profile metadata:",n)}})()}getChats(){var e=this;return(0,f.A)(function*(){const n=e._signerService.getPublicKey(),o=yield e._signerService.isUsingExtension(),r=yield e._signerService.isUsingSecretKey();return e.decryptedPrivateKey=r?yield e._signerService.getDecryptedSecretKey():"",yield Promise.all([e.subscribeToChatList(n,o,r,e.decryptedPrivateKey)]),e.getChatListStream()})()}subscribeToChatList(e,n,o,r){var a=this;return this._relayService.ensureConnectedRelays().then((0,f.A)(function*(){const u=[{kinds:[$.rV],authors:[e],limit:1500},{kinds:[$.rV],"#p":[e],limit:1500}];var l;a._relayService.getPool().subscribeMany(a._relayService.getConnectedRelays(),u,{onevent:(l=(0,f.A)(function*(d){const h=d.pubkey===e?d.tags.find(M=>"p"===M[0])?.[1]||"":d.pubkey;h&&d.created_at>(a.latestMessageTimestamps[h]||0)&&(a.messageQueue.push(d),a.processNextMessage(e,n,o,r))}),function(h){return l.apply(this,arguments)}),oneose:()=>{(a.chatList||[]).length>0&&a._chats.next(a.chatList)}})})),this.getChatListStream()}processNextMessage(e,n,o,r){var a=this;return(0,f.A)(function*(){if(!a.isDecrypting&&0!==a.messageQueue.length){a.isDecrypting=!0;try{for(;a.messageQueue.length>0;){const u=a.messageQueue.shift();if(!u)continue;const l=u.pubkey===e,d=l?u.tags.find(y=>"p"===y[0])?.[1]||"":u.pubkey;if(!d)continue;const h=yield a.decryptReceivedMessage(u,n,o,r,d);h&&a.addOrUpdateChatList(d,h,u.created_at,l)}}catch{}finally{a.isDecrypting=!1}}})()}addOrUpdateChatList(e,n,o,r){const a=this.chatList.find(l=>l.contact?.pubKey===e),u={id:`${e}-${o}`,chatId:e,contactId:e,isMine:r,value:n,createdAt:new Date(1e3*o).toISOString()};if(a)a.messages?.some(d=>d.id===u.id)||(a.messages=[...a.messages||[],u].sort((d,h)=>new Date(d.createdAt).getTime()-new Date(h.createdAt).getTime()),Number(a.lastMessageAt)h.pubKey===e)||{pubKey:e};this.chatList.push({id:e,contact:{pubKey:l.pubKey,name:l.name||"Unknown",picture:l.picture||"/images/avatars/avatar-placeholder.png",about:l.about||"",displayName:l.displayName||l.name||"Unknown"},lastMessage:n,lastMessageAt:o,messages:[u]})}this.chatList.sort((l,d)=>Number(d.lastMessageAt)-Number(l.lastMessageAt)),this._chats.next(this.chatList),this._storageService.profile$.pipe((0,X.p)(l=>l&&l.pubKey===e)).subscribe(l=>{const d=this.chatList.find(h=>h.contact?.pubKey===e);d&&(d.contact={...d.contact,name:l.metadata?.name||d.contact.name,picture:l.metadata?.picture||d.contact.picture,about:l.metadata?.about||d.contact.about,displayName:l.metadata?.displayName||l.metadata?.name||d.contact.displayName},this._chats.next(this.chatList))})}getChatListStream(){return this._chats.asObservable()}decryptReceivedMessage(e,n,o,r,a){var u=this;return(0,f.A)(function*(){return n&&!o?yield u._signerService.decryptMessageWithExtension(a,e.content):o&&!n?yield u._signerService.decryptMessage(r,a,e.content):void 0})()}loadAndFetchChatHistory(e,n=!1){var o=this;return(0,f.A)(function*(){const r=o._signerService.getPublicKey(),a=[{kinds:[$.rV],authors:[r],"#p":[e],limit:10},{kinds:[$.rV],authors:[e],"#p":[r],limit:10}],u=[];if(o._relayService.getPool().subscribeMany(o._relayService.getConnectedRelays(),a,{onevent:(l=(0,f.A)(function*(d){const h=d.pubkey===r,y=h?e:d.pubkey,M=yield o._signerService.isUsingExtension(),_e=yield o._signerService.isUsingSecretKey(),T=yield o.decryptReceivedMessage(d,M,_e,o.decryptedPrivateKey,y);if(T){const U=Math.floor(d.created_at),Ce={id:d.id,chatId:e,contactId:y,isMine:h,value:T,createdAt:new Date(1e3*U).toISOString()};n&&u.push(Ce),o.addOrUpdateChatList(e,T,U,h),o._chat.next(o.chatList.find(xe=>xe.id===e))}}),function(h){return l.apply(this,arguments)}),oneose:()=>{}}),n)return yield new Promise(l=>setTimeout(l,1e3)),u;var l})()}updateChat(e,n){return this.chats$.pipe((0,Y.s)(1),(0,G.n)(o=>{const r=n.contact?.pubKey;if(!r)return(0,F.$)("No public key found for this chat");const a={kind:4,pubkey:r,content:JSON.stringify(n),created_at:Math.floor(Date.now()/1e3),tags:[["p",r]]};return a.id=(0,L.dq)(a),(0,B.H)(this._relayService.publishEventToWriteRelays(a)).pipe((0,D.T)(()=>{if(o){const u=o.findIndex(l=>l.id===e);-1!==u&&(o[u]=n,this._chats.next(o))}return n}),(0,S.W)(u=>(console.error("Failed to update chat via Nostr:",u),(0,F.$)(u))))}))}getChatById(e,n=null){return this.recipientPublicKey=e,(0,B.H)(Promise.all([this._signerService.getPublicKey()])).pipe((0,G.n)(()=>this.chats$.pipe((0,Y.s)(1),(0,G.n)(o=>{if(!o||0===o.length)return this.createNewChat(e,n);const r=o.find(a=>a.id===e);return r?(this._chat.next(r),this.loadAndFetchChatHistory(this.recipientPublicKey),(0,K.of)(r)):this.createNewChat(e,n)}))),(0,S.W)(o=>(console.error("Error fetching chat by id from Nostr:",o),(0,F.$)(o))))}createNewChat(e,n=null){const o={id:e||"",contact:n?{pubKey:n.pubKey||e,name:n.name||"Unknown",picture:n.picture||"/images/avatars/avatar-placeholder.png"}:{pubKey:e,name:"Unknown",picture:"/images/avatars/avatar-placeholder.png"},lastMessage:"new chat...",lastMessageAt:Math.floor(Date.now()/1e3)||0,messages:[]};return this._metadataQueueService.addPublicKey(e),this._storageService.profile$.pipe((0,X.p)(r=>r&&r.pubKey===e),(0,D.T)(r=>(o.contact={pubKey:e,name:r.metadata?.name||"Unknown",picture:r.metadata?.picture||"/images/avatars/avatar-placeholder.png",about:r.metadata?.about||"",displayName:r.metadata?.displayName||r.metadata?.name||"Unknown"},o)))}resetChat(){this._chat.next(null)}sendPrivateMessage(e){var n=this;return(0,f.A)(function*(){try{n.message=e;const o=yield n._signerService.isUsingExtension(),r=yield n._signerService.isUsingSecretKey();if(o&&!r)yield n.handleMessageSendingWithExtension();else if(!o&&r){if(!n.isValidMessageSetup())return void console.error("Message, sender private key, or recipient public key is not properly set.");const a=yield n._signerService.encryptMessage(n.decryptedPrivateKey,n.recipientPublicKey,n.message),u=n._signerService.getUnsignedEvent(4,[["p",n.recipientPublicKey]],a),l=n._signerService.getSignedEvent(u,n.decryptedPrivateKey);(yield n._relayService.publishEventToWriteRelays(l))?n.message="":console.error("Failed to send the message.")}}catch(o){console.error("Error sending private message:",o)}})()}handleMessageSendingWithExtension(){var e=this;return(0,f.A)(function*(){try{const n=yield e._signerService.encryptMessageWithExtension(e.message,e.recipientPublicKey),o=yield e._signerService.signEventWithExtension({kind:4,pubkey:e._signerService.getPublicKey(),tags:[["p",e.recipientPublicKey]],content:n,created_at:Math.floor(Date.now()/1e3)});(yield e._relayService.publishEventToWriteRelays(o))?e.message="":console.error("Failed to send the message with extension.")}catch(n){console.error("Error sending message with extension:",n)}})()}isValidMessageSetup(){return""!==this.message.trim()&&""!==this.recipientPublicKey}ngOnDestroy(){this._unsubscribeAll.next(),this._unsubscribeAll.complete()}static{this.\u0275fac=function(n){return new(n||i)(t.KVO(H.A),t.KVO(z.n),t.KVO(W.b),t.KVO(Q.T))}}static{this.\u0275prov=t.jDH({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var g=c(4460),p=c(9471),v=c(6071),m=c(3904),k=c(6389),b=c(7818),C=c(5785),Z=c(9561);let J=(()=>{class i{transform(e){return/\.(jpeg|jpg|gif|png|bmp|svg|webp|tiff)$/i.test(e)?"\u{1f304} image":/\.(mp4|mov|avi|mkv|webm|flv|wmv|mpeg|3gp)$/i.test(e)?"\u{1f3ac} video":/\.(mp3|wav|ogg|m4a|aac|flac)$/i.test(e)?"\u{1f3b5} audio":/\.pdf$/i.test(e)?"\u{1f4c1} pdf":/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/.test(e)?"\u{1f4fd}\ufe0f youtube":/https?:\/\/(www\.)?vimeo.com\/(\d+)/.test(e)?"\u{1f4fd}\ufe0f vimeo":/https?:\/\/(www\.)?instagram.com\/p\/[a-zA-Z0-9_-]+/.test(e)?"\u{1f52e} instagram":/https?:\/\/(www\.)?twitter.com\/[a-zA-Z0-9_]+\/status\/[0-9]+/.test(e)?"\u{1f426} twitter":/(https?:\/\/[^\s]+)/.test(e)?"\u{1f310} url":e}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275pipe=t.EJ8({name:"checkmessage",type:i,pure:!0})}}return i})();var w=c(5424);function q(i,s){if(1&i){const e=t.RV6();t.j41(0,"div",15),t.bIt("click",function(){t.eBV(e);const o=t.XpG().$implicit,r=t.XpG(2);return t.Njj(r.openChat(o))}),t.EFF(1),t.k0s()}if(2&i){const e=t.XpG().$implicit;t.R7$(),t.SpI(" ",e.name.charAt(0)," ")}}function tt(i,s){if(1&i&&t.nrm(0,"img",10),2&i){const e=t.XpG().$implicit;t.Y8G("src",e.picture,t.B4B)}}function et(i,s){if(1&i&&(t.j41(0,"div",11),t.EFF(1),t.k0s()),2&i){const e=t.XpG().$implicit;t.R7$(),t.SpI(" ",e.name.charAt(0)," ")}}function nt(i,s){if(1&i){const e=t.RV6();t.DNE(0,q,2,1,"div",7),t.j41(1,"div",8),t.bIt("click",function(){const o=t.eBV(e).$implicit,r=t.XpG(2);return t.Njj(r.openChat(o))}),t.j41(2,"div",9),t.DNE(3,tt,1,1,"img",10)(4,et,2,1,"div",11),t.k0s(),t.j41(5,"div",12)(6,"div",13),t.EFF(7),t.k0s(),t.j41(8,"div",14),t.EFF(9),t.k0s()()()}if(2&i){const e=s.$implicit,n=s.$index,o=t.XpG(2);t.vxM(0===n||e.name.charAt(0)!==o.contacts[n-1].name.charAt(0)?0:-1),t.R7$(3),t.vxM(e.picture?3:-1),t.R7$(),t.vxM(e.picture?-1:4),t.R7$(3),t.SpI(" ",e.name," "),t.R7$(2),t.SpI(" ",e.about," ")}}function it(i,s){if(1&i&&t.Z7z(0,nt,10,5,null,null,t.BUC().trackByFn,!0),2&i){const e=t.XpG();t.Dyx(e.contacts)}}function ot(i,s){1&i&&(t.j41(0,"div",6),t.EFF(1," There are no contacts! "),t.k0s())}let rt=(()=>{class i{constructor(e,n){this._chatService=e,this.router=n,this.contacts=[],this._unsubscribeAll=new R.B}ngOnInit(){this._chatService.contacts$.pipe((0,w.Q)(this._unsubscribeAll)).subscribe(e=>{this.contacts=e})}ngOnDestroy(){this._unsubscribeAll.next(null),this._unsubscribeAll.complete()}trackByFn(e,n){return n.id||e}openChat(e){this._chatService.getChatById(e.pubKey,e).subscribe({next:n=>{console.log("Chat loaded or created:",n),this.router.navigate(["/chat",e.pubKey])},error:n=>{console.error("Error loading or creating chat:",n)},complete:()=>{this.drawer.close()}})}static{this.\u0275fac=function(n){return new(n||i)(t.rXU(x),t.rXU(_.Ix))}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["chat-new-chat"]],inputs:{drawer:"drawer"},decls:9,vars:2,consts:[[1,"bg-card","flex","h-full","flex-auto","flex-col","overflow-hidden","dark:bg-default"],[1,"-mb-px","flex","h-18","flex-0","items-center","bg-gray-50","px-6","dark:bg-transparent"],["mat-icon-button","",3,"click"],[3,"svgIcon"],[1,"ml-2","text-2xl","font-semibold"],[1,"relative","overflow-y-auto"],[1,"border-t","p-8","text-center","text-4xl","font-semibold","tracking-tight","sm:p-16"],[1,"text-secondary","sticky","top-0","z-10","-mt-px","border-b","border-t","bg-gray-100","px-6","py-1","font-medium","uppercase","dark:bg-gray-900","md:px-8"],[1,"z-20","flex","cursor-pointer","items-center","border-b","px-6","py-4","dark:hover:bg-hover","hover:bg-gray-100","md:px-8",3,"click"],[1,"flex","h-10","w-10","flex-0","items-center","justify-center","overflow-hidden","rounded-full"],["onerror","this.onerror=null; this.src='/images/avatars/avatar-placeholder.png';","alt","Contact picture",1,"h-full","w-full","object-cover",3,"src"],[1,"flex","h-full","w-full","items-center","justify-center","rounded-full","bg-gray-200","text-lg","uppercase","text-gray-600","dark:bg-gray-700","dark:text-gray-200"],[1,"ml-4","min-w-0"],[1,"truncate","font-medium","leading-5"],[1,"text-secondary","truncate","leading-5"],[1,"text-secondary","sticky","top-0","z-10","-mt-px","border-b","border-t","bg-gray-100","px-6","py-1","font-medium","uppercase","dark:bg-gray-900","md:px-8",3,"click"]],template:function(n,o){1&n&&(t.j41(0,"div",0)(1,"div",1)(2,"button",2),t.bIt("click",function(){return o.drawer.close()}),t.nrm(3,"mat-icon",3),t.k0s(),t.j41(4,"div",4),t.EFF(5,"New chat"),t.k0s()(),t.j41(6,"div",5),t.DNE(7,it,2,0)(8,ot,2,0,"div",6),t.k0s()()),2&n&&(t.R7$(3),t.Y8G("svgIcon","heroicons_outline:arrow-long-left"),t.R7$(4),t.vxM(o.contacts.length?7:8))},dependencies:[p.Hl,p.iY,m.m_,m.An],encapsulation:2,changeDetection:0})}}return i})();var j=c(936);function st(i,s){if(1&i&&t.nrm(0,"img",7),2&i){const e=t.XpG();t.Y8G("src",e.profile.picture,t.B4B)("alt","Profile picture")}}function at(i,s){if(1&i&&(t.j41(0,"div",8),t.EFF(1),t.k0s()),2&i){const e=t.XpG();t.R7$(),t.SpI(" ",e.profile.name.charAt(0)," ")}}let ct=(()=>{class i{constructor(e){this._chatService=e,this._unsubscribeAll=new R.B}ngOnInit(){this._chatService.profile$.pipe((0,w.Q)(this._unsubscribeAll)).subscribe(e=>{this.profile=e})}ngOnDestroy(){this._unsubscribeAll.next(null),this._unsubscribeAll.complete()}static{this.\u0275fac=function(n){return new(n||i)(t.rXU(x))}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["chat-profile"]],inputs:{drawer:"drawer"},decls:32,vars:9,consts:[[1,"bg-card","flex","flex-auto","flex-col","overflow-y-auto","dark:bg-default"],[1,"flex","h-18","flex-0","items-center","border-b","bg-gray-50","px-6","dark:bg-transparent"],["mat-icon-button","",3,"click"],[3,"svgIcon"],[1,"ml-2","text-2xl","font-semibold"],[1,"px-6"],[1,"relative","mx-auto","mt-8","flex","h-40","w-40","flex-0","rounded-full"],["onerror","this.onerror=null; this.src='/images/avatars/avatar-placeholder.png';",1,"h-full","w-full","rounded-full","object-cover",3,"src","alt"],[1,"flex","h-full","w-full","items-center","justify-center","rounded-full","bg-gray-200","text-8xl","font-semibold","uppercase","text-gray-600","dark:bg-gray-700","dark:text-gray-200"],[1,"mx-2","mt-8","flex","flex-col","space-y-6"],[1,"flex","items-center"],[1,"icon-size-5","mr-3","text-gray-500",3,"svgIcon"],[1,"text-sm","font-medium","text-gray-500"],[1,"text-lg"]],template:function(n,o){1&n&&(t.j41(0,"div",0)(1,"div",1)(2,"button",2),t.bIt("click",function(){return o.drawer.close()}),t.nrm(3,"mat-icon",3),t.k0s(),t.j41(4,"div",4),t.EFF(5,"Profile"),t.k0s()(),t.j41(6,"div",5)(7,"div",6),t.DNE(8,st,1,2,"img",7)(9,at,2,1,"div",8),t.k0s(),t.j41(10,"div",9)(11,"div",10),t.nrm(12,"mat-icon",11),t.j41(13,"div")(14,"div",12),t.EFF(15,"Name"),t.k0s(),t.j41(16,"div",13),t.EFF(17),t.k0s()()(),t.j41(18,"div",10),t.nrm(19,"mat-icon",11),t.j41(20,"div")(21,"div",12),t.EFF(22,"Username"),t.k0s(),t.j41(23,"div",13),t.EFF(24),t.k0s()()(),t.j41(25,"div",10),t.nrm(26,"mat-icon",11),t.j41(27,"div")(28,"div",12),t.EFF(29,"About"),t.k0s(),t.j41(30,"div",13),t.EFF(31),t.k0s()()()()()()),2&n&&(t.R7$(3),t.Y8G("svgIcon","heroicons_outline:arrow-long-left"),t.R7$(5),t.vxM(o.profile.picture?8:-1),t.R7$(),t.vxM(o.profile.picture?-1:9),t.R7$(3),t.Y8G("svgIcon","heroicons_solid:user-circle"),t.R7$(5),t.JRh(o.profile.name),t.R7$(2),t.Y8G("svgIcon","heroicons_solid:envelope"),t.R7$(5),t.JRh(o.profile.username),t.R7$(2),t.Y8G("svgIcon","heroicons_solid:identification"),t.R7$(5),t.JRh(o.profile.about))},dependencies:[p.Hl,p.iY,m.m_,m.An,v.RG,k.fS,j.YN],encapsulation:2,changeDetection:0})}}return i})();var lt=c(3871);const dt=(i,s)=>({"dark:hover:bg-hover hover:bg-gray-100":i,"bg-primary-50 dark:bg-hover":s}),ut=i=>[i],ht=(i,s)=>({"absolute inset-0 z-20 flex lg:static lg:inset-auto":i,"hidden lg:flex":s});function mt(i,s){if(1&i&&t.nrm(0,"chat-new-chat",6),2&i){t.XpG();const e=t.sdS(3);t.Y8G("drawer",e)}}function pt(i,s){if(1&i&&t.nrm(0,"chat-profile",6),2&i){t.XpG();const e=t.sdS(3);t.Y8G("drawer",e)}}function gt(i,s){if(1&i&&t.nrm(0,"img",15),2&i){const e=t.XpG(2);t.Y8G("src",null==e.profile?null:e.profile.picture,t.B4B)}}function ft(i,s){if(1&i&&(t.j41(0,"div",16),t.EFF(1),t.k0s()),2&i){const e=t.XpG(2);t.R7$(),t.SpI(" ",null==e.profile||null==e.profile.name?null:e.profile.name.charAt(0)," ")}}function vt(i,s){if(1&i&&t.nrm(0,"div",38),2&i){const e=t.XpG().$implicit,n=t.XpG(3);t.AVh("ring-primary-50",n.selectedChat&&n.selectedChat.id===e.id)}}function _t(i,s){if(1&i&&t.nrm(0,"img",39),2&i){const e=t.XpG().$implicit;t.Y8G("src",null==e.contact?null:e.contact.picture,t.B4B)}}function Ct(i,s){if(1&i&&(t.j41(0,"div",16),t.EFF(1),t.k0s()),2&i){const e=t.XpG().$implicit;t.R7$(),t.SpI(" ",null==e.contact||null==e.contact.name?null:e.contact.name.charAt(0)," ")}}function xt(i,s){1&i&&t.nrm(0,"mat-icon",37),2&i&&t.Y8G("svgIcon","heroicons_solid:speaker-x-mark")}function bt(i,s){if(1&i&&(t.j41(0,"a",27)(1,"div",28),t.DNE(2,vt,1,2,"div",29)(3,_t,1,1,"img",30)(4,Ct,2,1,"div",31),t.k0s(),t.j41(5,"div",32)(6,"div",33),t.EFF(7),t.k0s(),t.j41(8,"div",34),t.EFF(9),t.nI1(10,"checkmessage"),t.k0s()(),t.j41(11,"div",35)(12,"div",36),t.EFF(13),t.nI1(14,"ago"),t.k0s(),t.DNE(15,xt,1,1,"mat-icon",37),t.k0s()()),2&i){const e=s.$implicit,n=t.XpG(3);t.Y8G("ngClass",t.l_i(17,dt,!n.selectedChat||n.selectedChat.id!==e.id,n.selectedChat&&n.selectedChat.id===e.id))("routerLink",t.eq3(20,ut,e.id)),t.R7$(2),t.vxM(e.unreadCount>0?2:-1),t.R7$(),t.Y8G("ngIf",null==e.contact?null:e.contact.picture),t.R7$(),t.Y8G("ngIf",!(null!=e.contact&&e.contact.picture)),t.R7$(3),t.SpI(" ",null==e.contact?null:e.contact.name," "),t.R7$(),t.AVh("text-primary",e.unreadCount>0)("dark:text-primary-500",e.unreadCount>0),t.R7$(),t.SpI(" ",t.bMT(10,13,e.lastMessage)," "),t.R7$(4),t.SpI(" ",t.bMT(14,15,e.lastMessageAt)," "),t.R7$(2),t.vxM(e.muted?15:-1)}}function yt(i,s){if(1&i&&t.Z7z(0,bt,16,22,"a",27,t.BUC().trackByFn,!0),2&i){const e=t.XpG(2);t.Dyx(e.filteredChats)}}function kt(i,s){1&i&&(t.j41(0,"div",9),t.nrm(1,"mat-icon",40),t.j41(2,"div",41),t.EFF(3," No chats "),t.k0s()()),2&i&&(t.R7$(),t.Y8G("svgIcon","heroicons_outline:chat-bubble-oval-left-ellipsis"))}function wt(i,s){if(1&i){const e=t.RV6();t.j41(0,"div",8)(1,"div",11)(2,"div",12)(3,"div",13),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.openProfile())}),t.j41(4,"div",14),t.DNE(5,gt,1,1,"img",15)(6,ft,2,1,"div",16),t.k0s(),t.j41(7,"div",17),t.EFF(8),t.k0s()(),t.j41(9,"button",18),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.openNewChat())}),t.nrm(10,"mat-icon",19),t.k0s(),t.j41(11,"button",20),t.nrm(12,"mat-icon",19),t.j41(13,"mat-menu",null,1)(15,"button",21),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.openProfile())}),t.nrm(16,"mat-icon",19),t.EFF(17," Profile "),t.k0s()()()(),t.j41(18,"div",22)(19,"mat-form-field",23),t.nrm(20,"mat-icon",24),t.j41(21,"input",25,2),t.bIt("input",function(){t.eBV(e);const o=t.sdS(22),r=t.XpG();return t.Njj(r.filterChats(o.value))}),t.k0s()()()(),t.j41(23,"div",26),t.DNE(24,yt,2,0)(25,kt,4,1,"div",9),t.k0s()()}if(2&i){const e=t.sdS(14),n=t.XpG();t.R7$(5),t.vxM(null!=n.profile&&n.profile.picture?5:-1),t.R7$(),t.vxM(null!=n.profile&&n.profile.picture?-1:6),t.R7$(2),t.SpI(" ",null==n.profile?null:n.profile.name," "),t.R7$(2),t.Y8G("svgIcon","heroicons_outline:plus-circle"),t.R7$(),t.Y8G("matMenuTriggerFor",e),t.R7$(),t.Y8G("svgIcon","heroicons_outline:ellipsis-vertical"),t.R7$(4),t.Y8G("svgIcon","heroicons_outline:user-circle"),t.R7$(3),t.Y8G("subscriptSizing","dynamic"),t.R7$(),t.Y8G("svgIcon","heroicons_solid:magnifying-glass"),t.R7$(),t.Y8G("autocomplete","off")("placeholder","Search or start new chat"),t.R7$(3),t.vxM(n.filteredChats.length>0?24:25)}}function jt(i,s){1&i&&(t.j41(0,"div",9),t.nrm(1,"mat-icon",40),t.j41(2,"div",41),t.EFF(3," No chats "),t.k0s()()),2&i&&(t.R7$(),t.Y8G("svgIcon","heroicons_outline:chat-bubble-oval-left-ellipsis"))}function It(i,s){if(1&i&&(t.j41(0,"div",10),t.nrm(1,"router-outlet"),t.k0s()),2&i){const e=t.XpG();t.Y8G("ngClass",t.l_i(1,ht,e.selectedChat&&e.selectedChat.id,!e.selectedChat||!e.selectedChat.id))}}let Rt=(()=>{class i{constructor(e,n,o,r){this._chatService=e,this._changeDetectorRef=n,this.route=o,this._angorNavigationService=r,this.chats=[],this.filteredChats=[],this.drawerOpened=!1,this._unsubscribeAll=new R.B}updateNavigationBadge(){const e=this._angorNavigationService.getComponent("mainNavigation");e&&(this._angorNavigationService.getItem("chat",e.navigation).badge.title="0",e.refresh())}ngOnInit(){this.updateNavigationBadge(),this._chatService.chats$.pipe((0,w.Q)(this._unsubscribeAll)).subscribe(n=>{this.chats=this.filteredChats=n,this._markForCheck()}),this._chatService.profile$.pipe((0,w.Q)(this._unsubscribeAll)).subscribe(n=>{this.profile=n,this._markForCheck()}),this._chatService.chat$.pipe((0,w.Q)(this._unsubscribeAll)).subscribe(n=>{this.selectedChat=n,this._markForCheck()});const e=localStorage.getItem("currentChatId");e&&this._chatService.checkCurrentChatOnPageRefresh(e)}ngOnDestroy(){this._unsubscribeAll.next(),this._unsubscribeAll.complete(),this._chatService.resetChat(),localStorage.removeItem("currentChatId")}filterChats(e){if(e){const n=e.toLowerCase();this.filteredChats=this.chats.filter(o=>o.contact?.name.toLowerCase().includes(n))}else this.filteredChats=this.chats;this._markForCheck()}openNewChat(){this.drawerComponent="new-chat",this.drawerOpened=!0,this._markForCheck()}openProfile(){this.drawerComponent="profile",this.drawerOpened=!0,this._markForCheck()}trackByFn(e,n){return n.id||e}_markForCheck(){this._changeDetectorRef.markForCheck()}static{this.\u0275fac=function(n){return new(n||i)(t.rXU(x),t.rXU(t.gRc),t.rXU(_.nX),t.rXU(lt.lX))}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["chat-chats"]],decls:10,vars:7,consts:[["drawer",""],["chatsHeaderMenu",""],["searchField",""],[1,"bg-card","relative","flex","w-full","flex-auto","dark:bg-transparent"],[1,"h-full","flex-auto",3,"hasBackdrop"],[1,"w-full","dark:bg-gray-900","sm:w-100","lg:border-r","lg:shadow-none",3,"openedChange","autoFocus","opened"],[3,"drawer"],[1,"flex","overflow-hidden"],[1,"bg-card","relative","flex","w-full","min-w-0","flex-auto","flex-col","dark:bg-transparent","lg:min-w-100","lg:max-w-100"],[1,"flex","h-full","flex-auto","flex-col","items-center","justify-center"],[1,"flex-auto","border-l",3,"ngClass"],[1,"flex","flex-0","flex-col","border-b","bg-gray-50","px-8","py-4","dark:bg-transparent"],[1,"flex","items-center"],[1,"mr-1","flex","cursor-pointer","items-center",3,"click"],[1,"h-10","w-10"],["onerror","this.onerror=null; this.src='/images/avatars/avatar-placeholder.png';","alt","Profile picture",1,"h-full","w-full","rounded-full","object-cover",3,"src"],[1,"flex","h-full","w-full","items-center","justify-center","rounded-full","bg-gray-200","text-lg","uppercase","text-gray-600","dark:bg-gray-700","dark:text-gray-200"],[1,"ml-4","truncate","font-medium"],["mat-icon-button","",1,"ml-auto",3,"click"],[3,"svgIcon"],["mat-icon-button","",1,"-mr-4","ml-1",3,"matMenuTriggerFor"],["mat-menu-item","",3,"click"],[1,"mt-4"],[1,"angor-mat-rounded","angor-mat-dense","w-full",3,"subscriptSizing"],["matPrefix","",1,"icon-size-5",3,"svgIcon"],["matInput","",3,"input","autocomplete","placeholder"],[1,"flex-auto","overflow-y-auto"],[1,"z-20","flex","cursor-pointer","items-center","border-b","px-8","py-5",3,"ngClass","routerLink"],[1,"relative","flex","h-10","w-10","flex-0","items-center","justify-center"],[1,"ring-bg-card","absolute","bottom-0","right-0","-ml-0.5","h-2","w-2","flex-0","rounded-full","bg-primary","text-on-primary","ring-2","dark:bg-primary-500","dark:ring-gray-900",3,"ring-primary-50"],["class","h-full w-full rounded-full object-cover","alt","Contact picture",3,"src",4,"ngIf"],["class","flex h-full w-full items-center justify-center rounded-full bg-gray-200 text-lg uppercase text-gray-600 dark:bg-gray-700 dark:text-gray-200",4,"ngIf"],[1,"ml-4","min-w-0"],[1,"truncate","font-medium","leading-5"],[1,"text-secondary","truncate","leading-5"],[1,"ml-auto","flex","flex-col","items-end","self-start","pl-2"],[1,"text-secondary","overflow-hidden","whitespace-nowrap","text-sm","leading-5"],[1,"text-hint","icon-size-5",3,"svgIcon"],[1,"ring-bg-card","absolute","bottom-0","right-0","-ml-0.5","h-2","w-2","flex-0","rounded-full","bg-primary","text-on-primary","ring-2","dark:bg-primary-500","dark:ring-gray-900"],["alt","Contact picture",1,"h-full","w-full","rounded-full","object-cover",3,"src"],[1,"icon-size-24",3,"svgIcon"],[1,"text-secondary","mt-4","text-2xl","font-semibold","tracking-tight"]],template:function(n,o){if(1&n){const r=t.RV6();t.j41(0,"div",3)(1,"mat-drawer-container",4)(2,"mat-drawer",5,0),t.mxI("openedChange",function(u){return t.eBV(r),t.DH7(o.drawerOpened,u)||(o.drawerOpened=u),t.Njj(u)}),t.DNE(4,mt,1,1,"chat-new-chat",6)(5,pt,1,1,"chat-profile",6),t.k0s(),t.j41(6,"mat-drawer-content",7),t.DNE(7,wt,26,12,"div",8)(8,jt,4,1,"div",9)(9,It,2,4,"div",10),t.k0s()()()}2&n&&(t.R7$(),t.Y8G("hasBackdrop",!1),t.R7$(),t.Y8G("autoFocus",!1),t.R50("opened",o.drawerOpened),t.R7$(2),t.vxM("new-chat"===o.drawerComponent?4:-1),t.R7$(),t.vxM("profile"===o.drawerComponent?5:-1),t.R7$(2),t.vxM(o.chats&&o.chats.length>0?7:8),t.R7$(2),t.vxM(o.chats&&o.chats.length>0?9:-1))},dependencies:[C.vg,C.qe,C.$C,C.$l,rt,ct,p.Hl,p.iY,m.m_,m.An,b.Cn,b.kk,b.fb,b.Cp,v.RG,v.rl,v.JW,k.fS,k.fg,g.YU,_.Wk,_.n3,Z.g,g.MD,g.bT,J],encapsulation:2,changeDetection:0})}}return i})(),Ft=(()=>{class i{constructor(){}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["chat-empty-conversation"]],decls:5,vars:1,consts:[[1,"bg-card","flex","flex-auto","flex-col","overflow-y-auto","dark:bg-default","lg:overflow-hidden"],[1,"flex","flex-auto","flex-col","items-center","justify-center","bg-gray-100","dark:bg-transparent"],[1,"icon-size-24",3,"svgIcon"],[1,"text-secondary","mt-4","text-2xl","font-semibold","tracking-tight"]],template:function(n,o){1&n&&(t.j41(0,"div",0)(1,"div",1),t.nrm(2,"mat-icon",2),t.j41(3,"div",3),t.EFF(4," Select a conversation or start a new chat "),t.k0s()()()),2&n&&(t.R7$(2),t.Y8G("svgIcon","heroicons_outline:chat-bubble-oval-left-ellipsis"))},dependencies:[m.m_,m.An],encapsulation:2,changeDetection:0})}}return i})();var A=c(708),$t=c(1556),E=c(7544),Gt=c(4375),P=c(7691);let St=(()=>{class i{constructor(e){this.http=e}getTopGifs(e,n){const r=(new P.Nl).append("key",n).append("q",e);return this.http.get("https://g.tenor.com/v1/search",{params:r})}static{this.\u0275fac=function(n){return new(n||i)(t.KVO(P.Qq))}}static{this.\u0275prov=t.jDH({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();function Et(i,s){if(1&i){const e=t.RV6();t.j41(0,"div",8),t.bIt("click",function(){const o=t.eBV(e).$implicit,r=t.XpG(2);return t.Njj(r.selectGif(o))}),t.nrm(1,"img",9),t.k0s()}if(2&i){const e=s.$implicit;t.R7$(),t.Y8G("src",e,t.B4B)}}function Mt(i,s){if(1&i&&(t.j41(0,"div",6),t.DNE(1,Et,2,1,"div",7),t.k0s()),2&i){const e=t.XpG();t.R7$(),t.Y8G("ngForOf",e.gifsFound)}}let Tt=(()=>{class i{constructor(e,n,o,r){this.gifService=e,this.dialogRef=n,this._changeDetectorRef=o,this.data=r,this.gifSearch="",this.gifsFound=[]}searchGif(){this.gifSearch&&""!==this.gifSearch.trim()?this.data.apiKey?this.gifService.getTopGifs(this.gifSearch,this.data.apiKey).subscribe(e=>{this.gifsFound=e.results.map(n=>n.media[0].gif.url),this._changeDetectorRef.detectChanges()},e=>{console.error("Error fetching GIFs:",e)}):console.error("API key is missing."):console.error("Search term is empty.")}selectGif(e){this.dialogRef.close(e)}closeDialog(){this.dialogRef.close()}static{this.\u0275fac=function(n){return new(n||i)(t.rXU(St),t.rXU(E.CP),t.rXU(t.gRc),t.rXU(E.Vh))}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["gif-dialog"]],decls:10,vars:3,consts:[["mat-dialog-content",""],["appearance","outline",1,"full-width"],["matInput","","placeholder","keyword...",3,"ngModelChange","keyup.enter","ngModel"],["mat-icon-button","","matSuffix","",1,"ml-2","mr-2",3,"click"],[3,"svgIcon"],["class","results-container mt-4 grid grid-cols-3 gap-4",4,"ngIf"],[1,"results-container","mt-4","grid","grid-cols-3","gap-4"],["class","gif-preview h-24 w-full cursor-pointer",3,"click",4,"ngFor","ngForOf"],[1,"gif-preview","h-24","w-full","cursor-pointer",3,"click"],[1,"h-full","w-full","object-cover",3,"src"]],template:function(n,o){1&n&&(t.j41(0,"div",0)(1,"mat-form-field",1)(2,"mat-label"),t.EFF(3,"Search GIF"),t.k0s(),t.j41(4,"input",2),t.mxI("ngModelChange",function(a){return t.DH7(o.gifSearch,a)||(o.gifSearch=a),a}),t.bIt("keyup.enter",function(){return o.searchGif()}),t.k0s(),t.j41(5,"button",3),t.bIt("click",function(){return o.searchGif()}),t.nrm(6,"mat-icon",4),t.k0s(),t.j41(7,"mat-hint"),t.EFF(8,'Enter a keyword like "funny" or "cat" and hit search!'),t.k0s()(),t.DNE(9,Mt,2,1,"div",5),t.k0s()),2&n&&(t.R7$(4),t.R50("ngModel",o.gifSearch),t.R7$(2),t.Y8G("svgIcon","heroicons_outline:magnifying-glass"),t.R7$(3),t.Y8G("ngIf",o.gifsFound.length>0))},dependencies:[C.vg,p.Hl,p.iY,m.m_,m.An,j.YN,j.me,j.BC,j.vS,v.nJ,v.rl,j.X1,g.MD,g.Sq,g.bT,Gt.Ve,v.MV,v.yw,v.RG,k.fS,k.fg],styles:[".full-width[_ngcontent-%COMP%]{width:100%}.results-container[_ngcontent-%COMP%]{max-height:300px;overflow-y:auto;overflow-x:hidden}.gif-preview[_ngcontent-%COMP%]{transition:transform .2s}.gif-preview[_ngcontent-%COMP%]:hover{transform:scale(1.1)}"],changeDetection:0})}}return i})();const Nt=i=>["/profile",i];function Bt(i,s){if(1&i&&t.nrm(0,"img",8),2&i){const e=t.XpG();t.Y8G("src",null==e.chat.contact?null:e.chat.contact.picture,t.B4B)("alt","Contact picture")}}function Xt(i,s){if(1&i&&(t.j41(0,"div",9),t.EFF(1),t.k0s()),2&i){const e=t.XpG();t.R7$(),t.SpI(" ",null==e.chat.contact?null:e.chat.contact.name.charAt(0)," ")}}let Yt=(()=>{class i{constructor(){}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["chat-contact-info"]],inputs:{chat:"chat",drawer:"drawer"},decls:16,vars:8,consts:[[1,"bg-card","flex","h-full","flex-auto","flex-col","dark:bg-default"],[1,"flex","h-18","flex-0","items-center","border-b","bg-gray-50","px-4","dark:bg-transparent"],["mat-icon-button","",3,"click"],[3,"svgIcon"],[1,"ml-2","text-lg","font-medium"],[1,"overflow-y-auto"],[1,"mt-8","flex","flex-col","items-center"],[1,"h-40","w-40","rounded-full"],["onerror","this.onerror=null; this.src='/images/avatars/avatar-placeholder.png';",1,"h-full","w-full","rounded-full","object-cover",3,"src","alt"],[1,"flex","h-full","w-full","items-center","justify-center","rounded-full","bg-gray-200","text-8xl","font-semibold","uppercase","text-gray-600","dark:bg-gray-700","dark:text-gray-200"],[1,"mt-4","text-lg","font-medium"],[3,"routerLink"],[1,"text-secondary","ml-4","mr-4","mt-0.5","text-md"]],template:function(n,o){1&n&&(t.j41(0,"div",0)(1,"div",1)(2,"button",2),t.bIt("click",function(){return o.drawer.close()}),t.nrm(3,"mat-icon",3),t.k0s(),t.j41(4,"div",4),t.EFF(5,"Contact info"),t.k0s()(),t.j41(6,"div",5)(7,"div",6)(8,"div",7),t.DNE(9,Bt,1,2,"img",8)(10,Xt,2,1,"div",9),t.k0s(),t.j41(11,"div",10)(12,"a",11),t.EFF(13),t.k0s()(),t.j41(14,"div",12),t.EFF(15),t.k0s()()()()),2&n&&(t.R7$(3),t.Y8G("svgIcon","heroicons_outline:x-mark"),t.R7$(6),t.vxM(null!=o.chat.contact&&o.chat.contact.picture?9:-1),t.R7$(),t.vxM(null!=o.chat.contact&&o.chat.contact.picture?-1:10),t.R7$(2),t.Y8G("routerLink",t.eq3(6,Nt,null==o.chat.contact?null:o.chat.contact.pubKey)),t.R7$(),t.SpI(" ",null==o.chat.contact?null:o.chat.contact.name," "),t.R7$(2),t.SpI(" ",null==o.chat.contact?null:o.chat.contact.about," "))},dependencies:[p.Hl,p.iY,m.m_,m.An,_.iI,_.Wk],encapsulation:2,changeDetection:0})}}return i})();var Dt=c(2012),At=c(1109),Pt=c(6388),Ut=c(9207);const Ot=["messageInput"],Vt=()=>["./"],Kt=i=>({active:i}),Lt=(i,s,e,n)=>({"items-end":i,"items-start":s,"mt-0.5":e,"mt-3":n}),Ht=(i,s)=>({"bg-gray-400 text-blue-50":i,"bg-gray-500 text-gray-50":s}),zt=(i,s)=>({"-right-1 -mr-px mb-px text-gray-400":i,"-left-1 -ml-px mb-px -scale-x-1 text-gray-500":s}),Wt=(i,s)=>({"mr-3":i,"ml-3":s});function Qt(i,s){if(1&i&&t.nrm(0,"img",15),2&i){const e=t.XpG(2);t.Y8G("src",null==e.chat.contact?null:e.chat.contact.avatar,t.B4B)}}function Zt(i,s){if(1&i&&(t.j41(0,"div",16),t.EFF(1),t.k0s()),2&i){const e=t.XpG(2);t.R7$(),t.SpI(" ",null==e.chat.contact?null:e.chat.contact.name.charAt(0)," ")}}function Jt(i,s){1&i&&(t.qex(0),t.nrm(1,"mat-icon",12),t.EFF(2," Mute notifications "),t.bVm()),2&i&&(t.R7$(),t.Y8G("svgIcon","heroicons_outline:speaker-x-mark"))}function qt(i,s){1&i&&(t.qex(0),t.nrm(1,"mat-icon",12),t.EFF(2," Unmute notifications "),t.bVm()),2&i&&(t.R7$(),t.Y8G("svgIcon","heroicons_outline:speaker-wave"))}function te(i,s){if(1&i&&(t.j41(0,"div",31),t.nrm(1,"div",32),t.j41(2,"div",33),t.EFF(3),t.nI1(4,"date"),t.k0s(),t.nrm(5,"div",32),t.k0s()),2&i){const e=t.XpG().$implicit;t.R7$(3),t.SpI(" ",t.i5U(4,1,e.createdAt,"longDate")," ")}}function ee(i,s){1&i&&t.eu8(0)}function ne(i,s){if(1&i&&(t.j41(0,"div",36),t.DNE(1,ee,1,0,"ng-container",39),t.k0s()),2&i){const e=t.XpG(2).$implicit;t.XpG(2);const n=t.sdS(4);t.Y8G("ngClass",t.l_i(2,zt,e.isMine,!e.isMine)),t.R7$(),t.Y8G("ngTemplateOutlet",n)}}function ie(i,s){if(1&i&&(t.j41(0,"div",43),t.nrm(1,"iframe",44),t.k0s()),2&i){const e=t.XpG().$implicit;t.R7$(),t.Y8G("src",e.safeWord,t.f$h)}}function oe(i,s){if(1&i&&(t.j41(0,"div",43),t.nrm(1,"img",45),t.k0s()),2&i){const e=t.XpG().$implicit;t.R7$(),t.Y8G("src",e.safeWord,t.B4B)}}function re(i,s){if(1&i&&(t.j41(0,"div",43)(1,"video",46),t.nrm(2,"source",47),t.EFF(3," Your browser does not support the video tag. "),t.k0s()()),2&i){const e=t.XpG().$implicit;t.R7$(2),t.Y8G("src",e.safeWord,t.B4B)}}function se(i,s){if(1&i&&(t.j41(0,"div",43)(1,"audio",48),t.nrm(2,"source",49),t.EFF(3," Your browser does not support the audio element. "),t.k0s()()),2&i){const e=t.XpG().$implicit;t.R7$(2),t.Y8G("src",e.safeWord,t.B4B)}}function ae(i,s){if(1&i&&(t.j41(0,"div",50)(1,"a",51),t.EFF(2),t.k0s()()),2&i){const e=t.XpG().$implicit;t.R7$(),t.Y8G("href",e.word,t.B4B),t.R7$(),t.JRh(e.word)}}function ce(i,s){if(1&i&&(t.j41(0,"span",50),t.EFF(1),t.k0s()),2&i){const e=t.XpG().$implicit;t.R7$(),t.JRh(e)}}function le(i,s){if(1&i&&(t.j41(0,"div",40),t.DNE(1,ie,2,1,"div",41)(2,oe,2,1,"div",41)(3,re,4,1,"div",41)(4,se,4,1,"div",41)(5,ae,3,2,"div",42)(6,ce,2,1,"span",42),t.k0s()),2&i){const e=s.$implicit;t.R7$(),t.Y8G("ngIf","youtube"===e.token),t.R7$(),t.Y8G("ngIf","image"===e.token),t.R7$(),t.Y8G("ngIf","video"===e.token),t.R7$(),t.Y8G("ngIf","audio"===e.token),t.R7$(),t.Y8G("ngIf","link"===e.token),t.R7$(),t.Y8G("ngIf",!e.token)}}function de(i,s){if(1&i&&(t.j41(0,"div",38),t.EFF(1),t.nI1(2,"date"),t.k0s()),2&i){const e=t.XpG(2).$implicit;t.Y8G("ngClass",t.l_i(5,Wt,e.isMine,!e.isMine)),t.R7$(),t.SpI(" ",t.i5U(2,2,e.createdAt,"HH:mm")," ")}}function ue(i,s){if(1&i&&(t.j41(0,"div")(1,"div",34)(2,"div",35),t.DNE(3,ne,2,5,"div",36)(4,le,7,6,"div",37),t.k0s(),t.DNE(5,de,3,8,"div",38),t.k0s()()),2&i){const e=t.XpG(),n=e.$implicit,o=e.$index,r=e.$count,a=t.XpG(2);t.R7$(),t.Y8G("ngClass",t.ziG(6,Lt,n.isMine,!n.isMine,o>0&&a.chat.messages[o-1].isMine===n.isMine,o>0&&a.chat.messages[o-1].isMine!==n.isMine)),t.R7$(),t.Y8G("ngClass",t.l_i(11,Ht,n.isMine,!n.isMine)),t.R7$(),t.vxM(o===r-1||a.chat.messages[o+1].isMine!==n.isMine?3:-1),t.R7$(),t.Y8G("ngForOf",a.parseContent.parseContent(n.value))("ngForTrackBy",a.trackByFn),t.R7$(),t.vxM(0===o||o===r-1||a.chat.messages[o+1].isMine!==n.isMine||a.chat.messages[o+1].createdAt!==n.createdAt?5:-1)}}function he(i,s){if(1&i&&(t.DNE(0,te,6,4,"div",31),t.nI1(1,"date"),t.nI1(2,"date"),t.DNE(3,ue,6,14,"div",20)),2&i){const e=s.$implicit,n=s.$index,o=t.XpG(2);t.vxM(0===n||t.i5U(1,2,o.chat.messages[n-1].createdAt,"d")!==t.i5U(2,5,e.createdAt,"d")?0:-1),t.R7$(3),t.Y8G("ngIf",!e.id.includes("new-chat"))}}function me(i,s){if(1&i){const e=t.RV6();t.j41(0,"div",52)(1,"emoji-mart",53),t.bIt("emojiClick",function(o){t.eBV(e);const r=t.XpG(2);return t.Njj(r.addEmoji(o))}),t.k0s()()}if(2&i){const e=t.XpG(2);t.R7$(),t.Y8G("darkMode",e.darkMode)}}function pe(i,s){if(1&i){const e=t.RV6();t.j41(0,"mat-drawer-container",5)(1,"mat-drawer",7,1),t.mxI("openedChange",function(o){t.eBV(e);const r=t.XpG();return t.DH7(r.drawerOpened,o)||(r.drawerOpened=o),t.Njj(o)}),t.nrm(3,"chat-contact-info",8),t.k0s(),t.j41(4,"mat-drawer-content",9)(5,"div",10)(6,"a",11),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.resetChat())}),t.nrm(7,"mat-icon",12),t.k0s(),t.j41(8,"div",13),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.openContactInfo())}),t.j41(9,"div",14),t.DNE(10,Qt,1,1,"img",15)(11,Zt,2,1,"div",16),t.k0s(),t.j41(12,"div",17),t.EFF(13),t.k0s()(),t.j41(14,"button",18),t.nrm(15,"mat-icon",12),t.j41(16,"mat-menu",null,2)(18,"button",19),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.openContactInfo())}),t.nrm(19,"mat-icon",12),t.EFF(20," Contact info "),t.k0s(),t.j41(21,"button",19),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.toggleMuteNotifications())}),t.DNE(22,Jt,3,1,"ng-container",20)(23,qt,3,1,"ng-container",20),t.k0s()()()(),t.j41(24,"div",21)(25,"div",22),t.Z7z(26,he,4,8,null,null,t.BUC().trackByFn,!0),t.k0s()(),t.j41(28,"div",23)(29,"div",24)(30,"button",25),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.openGifDialog())}),t.nrm(31,"mat-icon",12),t.k0s(),t.j41(32,"button",25),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.toggleEmojiPicker())}),t.nrm(33,"mat-icon",12),t.k0s(),t.DNE(34,me,2,1,"div",26),t.j41(35,"button",25),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.toggleSpeechRecognition())}),t.nrm(36,"mat-icon",27),t.k0s()(),t.j41(37,"mat-form-field",28)(38,"textarea",29,3),t.bIt("keydown",function(o){t.eBV(e);const r=t.XpG();return t.Njj(r.handleKeyDown(o))}),t.k0s()(),t.j41(40,"div",30)(41,"button",25),t.bIt("click",function(){t.eBV(e);const o=t.XpG();return t.Njj(o.sendMessage())}),t.nrm(42,"mat-icon",12),t.k0s()()()()()}if(2&i){const e=t.sdS(2),n=t.sdS(17),o=t.XpG();t.Y8G("hasBackdrop",!1),t.R7$(),t.Y8G("autoFocus",!1)("mode",o.drawerMode)("position","end"),t.R50("opened",o.drawerOpened),t.R7$(2),t.Y8G("drawer",e)("chat",o.chat),t.R7$(3),t.Y8G("routerLink",t.lJ4(23,Vt)),t.R7$(),t.Y8G("svgIcon","heroicons_outline:arrow-long-left"),t.R7$(3),t.vxM(null!=o.chat.contact&&o.chat.contact.avatar?10:-1),t.R7$(),t.vxM(null!=o.chat.contact&&o.chat.contact.avatar?-1:11),t.R7$(2),t.SpI(" ",null==o.chat.contact?null:o.chat.contact.name," "),t.R7$(),t.Y8G("matMenuTriggerFor",n),t.R7$(),t.Y8G("svgIcon","heroicons_outline:ellipsis-vertical"),t.R7$(4),t.Y8G("svgIcon","heroicons_outline:user-circle"),t.R7$(3),t.Y8G("ngIf",!o.chat.muted),t.R7$(),t.Y8G("ngIf",o.chat.muted),t.R7$(3),t.Dyx(o.chat.messages),t.R7$(5),t.Y8G("svgIcon","heroicons_outline:gif"),t.R7$(2),t.Y8G("svgIcon","heroicons_outline:face-smile"),t.R7$(),t.Y8G("ngIf",o.showEmojiPicker),t.R7$(2),t.Y8G("ngClass",t.eq3(24,Kt,o.isListening))("svgIcon",o.isListening?"heroicons_solid:microphone":"heroicons_outline:microphone"),t.R7$(6),t.Y8G("svgIcon","heroicons_outline:paper-airplane")}}function ge(i,s){1&i&&(t.j41(0,"div",6),t.nrm(1,"mat-icon",54),t.j41(2,"div",55),t.EFF(3," Select a conversation or start a new chat "),t.k0s()()),2&i&&(t.R7$(),t.Y8G("svgIcon","heroicons_outline:chat-bubble-oval-left-ellipsis"))}function fe(i,s){1&i&&(t.qSk(),t.j41(0,"svg",56)(1,"g",57),t.nrm(2,"path",58),t.k0s()())}const ve=[{path:"",component:O,resolve:{chats:()=>(0,t.WQX)(x).getChats(),contacts:()=>(0,t.WQX)(x).getContacts(),profile:()=>(0,t.WQX)(x).getProfile()},children:[{path:"",component:Rt,children:[{path:"",pathMatch:"full",component:Ft},{path:":id",component:(()=>{class i{constructor(e,n,o,r,a,u,l,d){this._changeDetectorRef=e,this._chatService=n,this._angorMediaWatcherService=o,this._ngZone=r,this._angorConfigService=a,this.dialog=u,this.sanitizer=l,this.parseContent=d,this.drawerMode="side",this.drawerOpened=!1,this._unsubscribeAll=new R.B,this.showEmojiPicker=!1,this.darkMode=!1,this.finalTranscript="",this.isListening=!1,this.userEdited=!1;const h=window.SpeechRecognition||window.webkitSpeechRecognition;h?(this.recognition=new h,this.recognition.lang="en-US",this.recognition.continuous=!0,this.recognition.interimResults=!0,this.setupRecognitionEvents()):console.error("Speech recognition is not supported in this browser.")}openGifDialog(){this.dialog.open(Tt,{width:"600px",maxHeight:"80vh",data:{apiKey:"LIVDSRZULELA"}}).afterClosed().subscribe(n=>{if(n){const o=n;o&&(this.messageInput.nativeElement.value="",this._chatService.sendPrivateMessage(o).then(()=>{this.messageInput.nativeElement.value="",this.finalTranscript=""}).catch(r=>{console.error("Failed to send message:",r)}),this.finalTranscript="",this.userEdited=!1)}})}ngOnInit(){this._angorConfigService.config$.subscribe(e=>{"auto"===e.scheme?this.detectSystemTheme():this.darkMode="dark"===e.scheme}),this._chatService.chat$.pipe((0,w.Q)(this._unsubscribeAll)).subscribe(e=>{this.chat=e,this._changeDetectorRef.markForCheck()}),this._angorMediaWatcherService.onMediaChange$.pipe((0,w.Q)(this._unsubscribeAll)).subscribe(({matchingAliases:e})=>{this.drawerMode=e.includes("lg")?"side":"over",this._changeDetectorRef.markForCheck()})}_resizeMessageInput(){this._ngZone.runOutsideAngular(()=>{setTimeout(()=>{this.messageInput.nativeElement.style.height="auto",this._changeDetectorRef.detectChanges(),this.messageInput.nativeElement.style.height=`${this.messageInput.nativeElement.scrollHeight}px`,this._changeDetectorRef.detectChanges()})})}setupRecognitionEvents(){this.recognition.onresult=e=>{let n="";for(let o=e.resultIndex;o{console.error("Speech recognition error detected: ",e.error)},this.recognition.onend=()=>{this.isListening=!1}}toggleSpeechRecognition(){this.finalTranscript="",this.isListening?(this.recognition.stop(),this.isListening=!1):(this.recognition.start(),this.isListening=!0,this.userEdited=!1)}handleUserInput(e){this.userEdited=!0}ngOnDestroy(){this._unsubscribeAll.next(null),this._unsubscribeAll.complete()}openContactInfo(){this.drawerOpened=!0,this._changeDetectorRef.markForCheck()}resetChat(){this._chatService.resetChat(),this.drawerOpened=!1,this._changeDetectorRef.markForCheck()}toggleMuteNotifications(){this.chat.muted=!this.chat.muted,this._chatService.updateChat(this.chat.id,this.chat).subscribe()}trackByFn(e,n){return n.id||e}detectSystemTheme(){const e=window.matchMedia("(prefers-color-scheme: dark)");this.darkMode=e.matches,e.addEventListener("change",n=>{this.darkMode=n.matches})}handleKeyDown(e){"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),this.sendMessage())}sendMessage(){const e=this.messageInput.nativeElement.value.trim();e&&(this.messageInput.nativeElement.value="",this._chatService.sendPrivateMessage(e).then(()=>{this.messageInput.nativeElement.value="",this.finalTranscript=""}).catch(n=>{console.error("Failed to send message:",n)}),this.finalTranscript="",this.userEdited=!1)}addEmoji(e){this.messageInput.nativeElement.value+=e.emoji.native,this.showEmojiPicker=!1}toggleEmojiPicker(){this.showEmojiPicker=!this.showEmojiPicker}static{this.\u0275fac=function(n){return new(n||i)(t.rXU(t.gRc),t.rXU(x),t.rXU(Dt.l),t.rXU(t.SKi),t.rXU(At.P),t.rXU(E.bZ),t.rXU(Pt.up),t.rXU(Ut.m))}}static{this.\u0275cmp=t.VBU({type:i,selectors:[["chat-conversation"]],viewQuery:function(n,o){if(1&n&&t.GBs(Ot,5),2&n){let r;t.mGM(r=t.lsd())&&(o.messageInput=r.first)}},hostBindings:function(n,o){1&n&&t.bIt("input",function(){return o._resizeMessageInput()})("ngModelChange",function(){return o._resizeMessageInput()})},decls:5,vars:1,consts:[["speechBubbleExtension",""],["drawer",""],["conversationHeaderMenu",""],["messageInput",""],[1,"bg-card","flex","flex-auto","flex-col","overflow-y-auto","dark:bg-default","lg:overflow-hidden"],[1,"h-full","flex-auto",3,"hasBackdrop"],[1,"flex","flex-auto","flex-col","items-center","justify-center","bg-gray-100","dark:bg-transparent"],[1,"w-full","dark:bg-gray-900","sm:w-100","lg:border-l","lg:shadow-none",3,"openedChange","autoFocus","mode","position","opened"],[3,"drawer","chat"],[1,"flex","flex-col","overflow-hidden"],[1,"flex","h-18","flex-0","items-center","border-b","bg-gray-50","px-4","dark:bg-transparent","md:px-6"],["mat-icon-button","",1,"md:-ml-2","lg:hidden",3,"click","routerLink"],[3,"svgIcon"],[1,"ml-2","mr-2","flex","cursor-pointer","items-center","lg:ml-0",3,"click"],[1,"relative","flex","h-10","w-10","flex-0","items-center","justify-center"],["onerror","this.onerror=null; this.src='/images/avatars/avatar-placeholder.png';","alt","Contact picture",1,"h-full","w-full","rounded-full","object-cover",3,"src"],[1,"flex","h-full","w-full","items-center","justify-center","rounded-full","bg-gray-200","text-lg","uppercase","text-gray-600","dark:bg-gray-700","dark:text-gray-200"],[1,"ml-4","truncate","text-lg","font-medium","leading-5"],["mat-icon-button","",1,"ml-auto",3,"matMenuTriggerFor"],["mat-menu-item","",3,"click"],[4,"ngIf"],[1,"flex","h-full","flex-col-reverse","overflow-y-auto"],[1,"bg-card","flex","flex-auto","shrink","flex-col","p-6","dark:bg-transparent"],[1,"flex","items-end","border-t","bg-gray-50","p-4","dark:bg-transparent"],[1,"my-px","flex","h-11","items-center"],["mat-icon-button","",3,"click"],["class","emoji-picker-container",4,"ngIf"],[3,"ngClass","svgIcon"],["subscriptSizing","dynamic",1,"angor-mat-dense","angor-mat-rounded","angor-mat-bold","ml-4","w-full"],["matInput","","cdkTextareaAutosize","",1,"max-h-20",3,"keydown"],[1,"my-px","ml-4","flex","h-11","items-center"],[1,"-mx-6","my-3","flex","items-center","justify-center"],[1,"flex-auto","border-b"],[1,"text-secondary","mx-4","flex-0","text-sm","font-medium","leading-5"],[1,"flex","flex-col",3,"ngClass"],[1,"relative","max-w-3/4","rounded-lg","px-2","py-2",3,"ngClass"],[1,"absolute","bottom-0","w-3",3,"ngClass"],["style","display: inline-block; overflow-wrap: break-word; white-space: pre-wrap;",4,"ngFor","ngForOf","ngForTrackBy"],[1,"text-secondary","my-0.5","text-sm","font-medium",3,"ngClass"],[4,"ngTemplateOutlet"],[2,"display","inline-block","overflow-wrap","break-word","white-space","pre-wrap"],["style","display: block;",4,"ngIf"],["style","display: inline-block; overflow-wrap: break-word;",4,"ngIf"],[2,"display","block"],["width","560","height","315","frameborder","0","allowfullscreen","",3,"src"],["alt","Embedded Image",2,"max-width","100%",3,"src"],["controls","",2,"max-width","100%"],["type","video/mp4",3,"src"],["controls",""],["type","audio/mpeg",3,"src"],[2,"display","inline-block","overflow-wrap","break-word"],["target","_blank",3,"href"],[1,"emoji-picker-container"],[3,"emojiClick","darkMode"],[1,"icon-size-24",3,"svgIcon"],[1,"text-secondary","mt-4","text-2xl","font-semibold","tracking-tight"],["width","100%","height","100%","viewBox","0 0 66 66","xmlns","http://www.w3.org/2000/svg"],["id","Page-1","stroke","none","stroke-width","1","fill","none","fill-rule","evenodd"],["d","M1.01522827,0.516204834 C-8.83532715,54.3062744 61.7609863,70.5215302 64.8009949,64.3061218 C68.8074951,54.8859711 30.1663208,52.9997559 37.5036011,0.516204834 L1.01522827,0.516204834 Z","fill","currentColor","fill-rule","nonzero"]],template:function(n,o){1&n&&(t.j41(0,"div",4),t.DNE(1,pe,43,26,"mat-drawer-container",5)(2,ge,4,1,"div",6)(3,fe,3,0,"ng-template",null,0,t.C5r),t.k0s()),2&n&&(t.R7$(),t.vxM(o.chat?1:2))},dependencies:[C.vg,C.qe,C.$C,C.$l,Yt,p.Hl,p.pQ,p.iY,_.Wk,m.m_,m.An,b.Cn,b.kk,b.fb,b.Cp,g.YU,g.T3,v.RG,v.rl,k.fS,k.fg,A.xb,A.EE,g.vh,$t.Ic,g.MD,g.Sq,g.bT],styles:[".c-img,.c-video{max-width:100%;border-radius:10px}\n"],encapsulation:2,changeDetection:0})}}return i})(),resolve:{conversation:(i,s)=>{const e=(0,t.WQX)(x),n=(0,t.WQX)(_.Ix);let o=i.paramMap.get("id")||localStorage.getItem("currentChatId");if(!o){const r=s.url.split("/").slice(0,-1).join("/");return n.navigateByUrl(r),(0,F.$)("No chat ID provided")}return localStorage.setItem("currentChatId",o),e.getChatById(o).pipe((0,S.W)(r=>{console.error("Error fetching conversation:",r);const a=s.url.split("/").slice(0,-1).join("/");return n.navigateByUrl(a),(0,F.$)(r)}))}}}]}]}]}}]); \ No newline at end of file diff --git a/index.html b/index.html index 5c0adb7..fcf38bc 100644 --- a/index.html +++ b/index.html @@ -41,5 +41,5 @@ - + diff --git a/ngsw.json b/ngsw.json index 22db457..3abab98 100644 --- a/ngsw.json +++ b/ngsw.json @@ -1,6 +1,6 @@ { "configVersion": 1, - "timestamp": 1732973133494, + "timestamp": 1732998970063, "index": "/index.html", "assetGroups": [], "dataGroups": [], diff --git a/runtime.5295f3108bcd534f.js b/runtime.78bf003aff6c56ad.js similarity index 96% rename from runtime.5295f3108bcd534f.js rename to runtime.78bf003aff6c56ad.js index c06f8ec..f430ee1 100644 --- a/runtime.5295f3108bcd534f.js +++ b/runtime.78bf003aff6c56ad.js @@ -1 +1 @@ -(()=>{"use strict";var e,v={},g={};function r(e){var n=g[e];if(void 0!==n)return n.exports;var a=g[e]={id:e,loaded:!1,exports:{}};return v[e].call(a.exports,a,a.exports,r),a.loaded=!0,a.exports}r.m=v,e=[],r.O=(n,a,d,i)=>{if(!a){var t=1/0;for(f=0;f=i)&&Object.keys(r.O).every(p=>r.O[p](a[o]))?a.splice(o--,1):(l=!1,i0&&e[f-1][2]>i;f--)e[f]=e[f-1];e[f]=[a,d,i]},r.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return r.d(n,{a:n}),n},r.d=(e,n)=>{for(var a in n)r.o(n,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:n[a]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce((n,a)=>(r.f[a](e,n),n),[])),r.u=e=>(76===e?"common":e)+"."+{45:"c05d13a02e05e1d8",76:"6ad480d0e9aeb8cb",87:"89382f6778c57112",126:"882bbf93d79b0241",232:"e86c6a10c949ded0",256:"0e13c4fd2d85a687",318:"afda1c4d799c528b",371:"1350987134a35fcd",394:"1387a9799f07f379",512:"9fa6a3d9d716749f",523:"1d564178fdfd679e",544:"eda92231287fa498",556:"14e4bee993e6d7c2",664:"8a10de4594052b2f",767:"bdc7935b901bf4f4",785:"20609070e643f838",836:"dbe90a7b5bc003c1",859:"5c6e13c9e52b4d5a",863:"0d7c11f1ff5ee5d0",957:"5e3037fca5fc8f88"}[e]+".js",r.miniCssF=e=>{},r.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={},n="angor:";r.l=(a,d,i,f)=>{if(e[a])e[a].push(d);else{var t,l;if(void 0!==i)for(var o=document.getElementsByTagName("script"),c=0;c{t.onerror=t.onload=null,clearTimeout(s);var h=e[a];if(delete e[a],t.parentNode&&t.parentNode.removeChild(t),h&&h.forEach(_=>_(p)),m)return m(p)},s=setTimeout(u.bind(null,void 0,{type:"timeout",target:t}),12e4);t.onerror=u.bind(null,t.onerror),t.onload=u.bind(null,t.onload),l&&document.head.appendChild(t)}}})(),r.r=e=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e;r.tt=()=>(void 0===e&&(e={createScriptURL:n=>n},typeof trustedTypes<"u"&&trustedTypes.createPolicy&&(e=trustedTypes.createPolicy("angular#bundler",e))),e)})(),r.tu=e=>r.tt().createScriptURL(e),r.p="",(()=>{var e={121:0};r.f.j=(d,i)=>{var f=r.o(e,d)?e[d]:void 0;if(0!==f)if(f)i.push(f[2]);else if(121!=d){var t=new Promise((b,u)=>f=e[d]=[b,u]);i.push(f[2]=t);var l=r.p+r.u(d),o=new Error;r.l(l,b=>{if(r.o(e,d)&&(0!==(f=e[d])&&(e[d]=void 0),f)){var u=b&&("load"===b.type?"missing":b.type),s=b&&b.target&&b.target.src;o.message="Loading chunk "+d+" failed.\n("+u+": "+s+")",o.name="ChunkLoadError",o.type=u,o.request=s,f[1](o)}},"chunk-"+d,d)}else e[d]=0},r.O.j=d=>0===e[d];var n=(d,i)=>{var o,c,[f,t,l]=i,b=0;if(f.some(s=>0!==e[s])){for(o in t)r.o(t,o)&&(r.m[o]=t[o]);if(l)var u=l(r)}for(d&&d(i);b{"use strict";var e,v={},g={};function r(e){var n=g[e];if(void 0!==n)return n.exports;var a=g[e]={id:e,loaded:!1,exports:{}};return v[e].call(a.exports,a,a.exports,r),a.loaded=!0,a.exports}r.m=v,e=[],r.O=(n,a,d,i)=>{if(!a){var t=1/0;for(f=0;f=i)&&Object.keys(r.O).every(p=>r.O[p](a[o]))?a.splice(o--,1):(l=!1,i0&&e[f-1][2]>i;f--)e[f]=e[f-1];e[f]=[a,d,i]},r.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return r.d(n,{a:n}),n},r.d=(e,n)=>{for(var a in n)r.o(n,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:n[a]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce((n,a)=>(r.f[a](e,n),n),[])),r.u=e=>(76===e?"common":e)+"."+{45:"c05d13a02e05e1d8",76:"6ad480d0e9aeb8cb",87:"89382f6778c57112",126:"882bbf93d79b0241",232:"e86c6a10c949ded0",256:"0e13c4fd2d85a687",318:"afda1c4d799c528b",371:"1350987134a35fcd",394:"1387a9799f07f379",512:"a68be118134746e7",523:"1d564178fdfd679e",544:"eda92231287fa498",556:"14e4bee993e6d7c2",664:"8a10de4594052b2f",767:"bdc7935b901bf4f4",785:"20609070e643f838",836:"dbe90a7b5bc003c1",859:"5c6e13c9e52b4d5a",863:"0d7c11f1ff5ee5d0",957:"5e3037fca5fc8f88"}[e]+".js",r.miniCssF=e=>{},r.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={},n="angor:";r.l=(a,d,i,f)=>{if(e[a])e[a].push(d);else{var t,l;if(void 0!==i)for(var o=document.getElementsByTagName("script"),c=0;c{t.onerror=t.onload=null,clearTimeout(s);var h=e[a];if(delete e[a],t.parentNode&&t.parentNode.removeChild(t),h&&h.forEach(_=>_(p)),m)return m(p)},s=setTimeout(u.bind(null,void 0,{type:"timeout",target:t}),12e4);t.onerror=u.bind(null,t.onerror),t.onload=u.bind(null,t.onload),l&&document.head.appendChild(t)}}})(),r.r=e=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e;r.tt=()=>(void 0===e&&(e={createScriptURL:n=>n},typeof trustedTypes<"u"&&trustedTypes.createPolicy&&(e=trustedTypes.createPolicy("angular#bundler",e))),e)})(),r.tu=e=>r.tt().createScriptURL(e),r.p="",(()=>{var e={121:0};r.f.j=(d,i)=>{var f=r.o(e,d)?e[d]:void 0;if(0!==f)if(f)i.push(f[2]);else if(121!=d){var t=new Promise((b,u)=>f=e[d]=[b,u]);i.push(f[2]=t);var l=r.p+r.u(d),o=new Error;r.l(l,b=>{if(r.o(e,d)&&(0!==(f=e[d])&&(e[d]=void 0),f)){var u=b&&("load"===b.type?"missing":b.type),s=b&&b.target&&b.target.src;o.message="Loading chunk "+d+" failed.\n("+u+": "+s+")",o.name="ChunkLoadError",o.type=u,o.request=s,f[1](o)}},"chunk-"+d,d)}else e[d]=0},r.O.j=d=>0===e[d];var n=(d,i)=>{var o,c,[f,t,l]=i,b=0;if(f.some(s=>0!==e[s])){for(o in t)r.o(t,o)&&(r.m[o]=t[o]);if(l)var u=l(r)}for(d&&d(i);b