@whoz-oss/coday-client 3.29.0 → 3.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/browser/{chunk-C3cvHmBJ.js → chunk--r2IPkvN.js} +1 -1
  2. package/browser/chunk-1mA1C1Ia.js +1 -0
  3. package/browser/{chunk-D5UGtM5T.js → chunk-4NMdLPHF.js} +1 -1
  4. package/browser/chunk-4QqbIPaR.js +1 -0
  5. package/browser/{chunk-C6x9SBjG.js → chunk-AB2V4DzP.js} +1 -1
  6. package/browser/{chunk-D-vld_6F.js → chunk-B-Ejl4sU.js} +1 -1
  7. package/browser/{chunk-CrYRdxC9.js → chunk-B3KKH9dW.js} +1 -1
  8. package/browser/{chunk-Ov4I3GYD.js → chunk-B4hQ_D8H.js} +1 -1
  9. package/browser/{chunk-Bo1DjeiW.js → chunk-BFY0pXEf.js} +1 -1
  10. package/browser/{chunk-Bbb2Oy9I.js → chunk-BPkyqr-f.js} +1 -1
  11. package/browser/chunk-BWcVMw4T.js +1 -0
  12. package/browser/{chunk-sqjr_Ky0.js → chunk-BXZoje_o.js} +1 -1
  13. package/browser/{chunk-Cmp8otOQ.js → chunk-B_-1xOxe.js} +1 -1
  14. package/browser/{chunk-CCQAu0MS.js → chunk-B_gHVcU6.js} +1 -1
  15. package/browser/{chunk-CG4buEjj.js → chunk-BhXLqAug.js} +1 -1
  16. package/browser/{chunk-CHSLALZZ.js → chunk-BjFLkaZE.js} +1 -1
  17. package/browser/{chunk-DOV6c8DN.js → chunk-Bk2EXxig.js} +2 -2
  18. package/browser/{chunk-DpKLsgM9.js → chunk-BopMYlkE.js} +1 -1
  19. package/browser/{chunk-ChTqQ8HQ.js → chunk-BpSHA6TV.js} +1 -1
  20. package/browser/{chunk-B1gTtKFG.js → chunk-BrUYkz33.js} +1 -1
  21. package/browser/{chunk-BjBW1d-u.js → chunk-Bx_FH6m3.js} +1 -1
  22. package/browser/{chunk-1xKCP6gl.js → chunk-C0KRHI6e.js} +1 -1
  23. package/browser/{chunk-DG8M0PqZ.js → chunk-C2Inb2UP.js} +1 -1
  24. package/browser/{chunk-D2pgQ9ii.js → chunk-CEQ5C5Tx.js} +1 -1
  25. package/browser/{chunk-CdkqXKu3.js → chunk-CG3MF0H4.js} +1 -1
  26. package/browser/{chunk-BtBbv-Bf.js → chunk-CGn0orvL.js} +1 -1
  27. package/browser/chunk-CJGzYd_S.js +1 -0
  28. package/browser/{chunk-Bv_n_Pea.js → chunk-CJIgE5YB.js} +3 -3
  29. package/browser/{chunk-cNEt2yX6.js → chunk-CJxkwaxD.js} +1 -1
  30. package/browser/{chunk-CFfiJ53b.js → chunk-CK18gZ63.js} +1 -1
  31. package/browser/{chunk-BloWX02p.js → chunk-CNmZmLwF.js} +1 -1
  32. package/browser/{chunk-CxozF4Vf.js → chunk-COD2O4SF.js} +1 -1
  33. package/browser/{chunk-D_aTK145.js → chunk-CZmNdEYy.js} +1 -1
  34. package/browser/{chunk-CE5rgBGE.js → chunk-C_J2R_PK.js} +1 -1
  35. package/browser/{chunk-BlUiCEeR.js → chunk-CglVp4ZH.js} +1 -1
  36. package/browser/{chunk-DZe-m4Sd.js → chunk-CkBh9-Fw.js} +1 -1
  37. package/browser/{chunk-CRrjfkUg.js → chunk-CnEa9fH2.js} +2 -2
  38. package/browser/{chunk-CGL1Leue.js → chunk-CniyJRG1.js} +1 -1
  39. package/browser/{chunk-cg5smJeu.js → chunk-Cq3KqN1m.js} +1 -1
  40. package/browser/{chunk-q9uyoVUw.js → chunk-CtHF-uul.js} +1 -1
  41. package/browser/chunk-D-QPhn7p.js +1 -0
  42. package/browser/{chunk-bIJnspzL.js → chunk-D-l2ORqm.js} +1 -1
  43. package/browser/chunk-D3BAOO_0.js +1 -0
  44. package/browser/{chunk-Boc0RvBR.js → chunk-D3fatnCm.js} +1 -1
  45. package/browser/{chunk-Ddpg0y75.js → chunk-D3gurhpR.js} +1 -1
  46. package/browser/{chunk-CCEiNYBj.js → chunk-D6BBuWSd.js} +1 -1
  47. package/browser/{chunk-CFY3CFkD.js → chunk-D8sYWCcr.js} +1 -1
  48. package/browser/{chunk-Bol7PdRu.js → chunk-DAk8SIkq.js} +1 -1
  49. package/browser/{chunk-BIdH1XJF.js → chunk-DFLL0Odh.js} +1 -1
  50. package/browser/{chunk-RUBMO7Yb.js → chunk-DR5zNU0n.js} +1 -1
  51. package/browser/{chunk-u3jxNXQ8.js → chunk-DVrM3JI8.js} +1 -1
  52. package/browser/{chunk-BmHNWYuZ.js → chunk-DWSvE7KY.js} +1 -1
  53. package/browser/{chunk-DX05HUs9.js → chunk-DZUhjamf.js} +1 -1
  54. package/browser/{chunk-Cw62GRPX.js → chunk-DZuvl0-q.js} +1 -1
  55. package/browser/{chunk-DKg7p59a.js → chunk-DmNKvrHl.js} +1 -1
  56. package/browser/chunk-DnMJl9Ao.js +1 -0
  57. package/browser/{chunk-G_l8BMaJ.js → chunk-DqzTsn7a.js} +1 -1
  58. package/browser/{chunk-CjKxvXTd.js → chunk-DsFEZkSl.js} +1 -1
  59. package/browser/{chunk-BSAXfS2x.js → chunk-DstI03OT.js} +1 -1
  60. package/browser/{chunk-CERsD1uZ.js → chunk-DzWQQKpk.js} +1 -1
  61. package/browser/{chunk-BvO---8Y.js → chunk-F5WjZgr6.js} +1 -1
  62. package/browser/{chunk-DuNMllH-.js → chunk-KIJUJ9nq.js} +1 -1
  63. package/browser/chunk-Mxaxers6.js +1 -0
  64. package/browser/{chunk-CGlvdEI7.js → chunk-O4nbXJCv.js} +1 -1
  65. package/browser/{chunk-vQXZQsZC.js → chunk-P6Fi8ohd.js} +1 -1
  66. package/browser/{chunk-DgmZwFcU.js → chunk-QcmfFN_C.js} +1 -1
  67. package/browser/{chunk-DczzZnS1.js → chunk-S9BROQKc.js} +1 -1
  68. package/browser/{chunk-_2qKLbuS.js → chunk-VE530Qd2.js} +1 -1
  69. package/browser/{chunk-CBwpP2V0.js → chunk-bgvmHk7z.js} +1 -1
  70. package/browser/chunk-kFOHrPbJ.js +10 -0
  71. package/browser/chunk-lU3996br.js +1 -0
  72. package/browser/index.html +1 -1
  73. package/browser/{main-2GG5NZ4C.js → main-2EYBZUJC.js} +9 -9
  74. package/package.json +1 -1
  75. package/browser/chunk-C-VoWDOg.js +0 -10
  76. package/browser/chunk-C0DMx9CU.js +0 -1
  77. package/browser/chunk-C5mPb_F4.js +0 -1
  78. package/browser/chunk-CpGwP-5T.js +0 -1
  79. package/browser/chunk-CrZEE1qa.js +0 -1
  80. package/browser/chunk-Dz1wgxrF.js +0 -1
  81. package/browser/chunk-Fh0Lvh-K.js +0 -1
  82. package/browser/chunk-WuZ8xi__.js +0 -1
  83. package/browser/chunk-a4RWgm8g.js +0 -1
@@ -1,6 +1,6 @@
1
- import {f}from'./chunk-Bol7PdRu.js';import {G as Ge,z as z$1,Q as Qe,E as Et,y as yt$2}from'./chunk-CE5rgBGE.js';import {U as Ue$1,x as x$2,i as is}from'./chunk-G_l8BMaJ.js';import {al as vt$1,an as ue,g,ay as O,F,L,az as Xt,U,N,p as pe$1,G,ap as wd,ae as kt,aA as an,av as B,e as xw,h as hr$1,aB as fr$1,aC as Tu,k as ws,q as Rg,J as Jw,o as pl,X as XE,v as bg,y as eC,D as Pg,E as EC,I as IC,P as P$1,aD as Py,Y as x,a9 as lC,ai as tm,aa as If,aj as KC,ab as wf,a3 as VI,A as Ug,ak as em,a6 as UI,B as dE,a as Gi$1,aE as W,H as py,W as br$1,aF as R,r as re,a7 as ya,aG as fe,m as mT,x as x$1,w as w$1,aH as z,b as U$1,aI as bS,t as rC,z as oC,aJ as Tr$1,aK as xb,am as qm,j as Gn$1,n as GC,aL as wo$1,aM as Zn$2,aN as Nn,aO as wt$2,aP as G$1,aQ as $a,aR as Fs,aS as K,aT as Ut,aU as Ue,aV as U$2,aW as C,aX as D$1,aY as ft$1,aZ as js,a_ as QT,ac as gC,a$ as XC,b0 as Qg,a5 as vl,S as Sg,ah as rT,b1 as On,b2 as kb,b3 as Sb,b4 as oT,b5 as nT,aw as hl,b6 as _g,ax as gl,l as le,b7 as u,b8 as B$1,b9 as T,ba as v,bb as m,bc as R$1,bd as h,be as A,a8 as Yg,bf as aT,bg as uT,T as Tg,bh as By,i as pr$1,bi as lT,bj as aE,bk as yh}from'./main-2GG5NZ4C.js';import {s}from'./chunk-CG4buEjj.js';import {d}from'./chunk-BmHNWYuZ.js';import {S as Se$1,P as Pn}from'./chunk-BjBW1d-u.js';import {u as ui$1,m as mt$1,p as pt$1,Z as Z$1,V as Ve}from'./chunk-Bbb2Oy9I.js';import {y as yt$1,w as wt$1,t as ti$1,Y as Ye,Z as Zn$1,c as cn}from'./chunk-D_aTK145.js';var ot=class i{sanitizer=g(bS);transform(e,t){if(!t||!e)return e;let n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`(${n})`,"gi"),r=e.replace(o,"<strong>$1</strong>");return this.sanitizer.bypassSecurityTrustHtml(r)}static \u0275fac=function(t){return new(t||i)};static \u0275pipe=On({name:"highlight",type:i,pure:true})};var be=class i{http=g(py);projectState=g(P$1);threadState=g(U);transcribeAudio(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow();return this.http.post(`/api/projects/${o}/transcribe`,w$1({audio:e,mimeType:t},n?{language:n}:{}))}sendVoiceMessage(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow(),r=this.threadState.getSelectedThreadIdOrThrow();return this.http.post(`/api/projects/${o}/threads/${r}/voice-message`,w$1({audio:e,mimeType:t},n?{language:n}:{}))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var yi=["messageInput"],wi=["fileInput"],Ti=(i,e)=>e.name;function Si(i,e){i&1&&(ws(0,"div",3),Sg(1,"span",8),GC(2," Recording... Click mic to stop "),pl());}function Mi(i,e){i&1&&(ws(0,"div",3),Sg(1,"span",9),GC(2," Transcribing... "),pl());}function Ei(i,e){if(i&1&&(ws(0,"span",14),GC(1),pl()),i&2){let t=gC().$implicit,n=gC(2);XE(),Yg(" "+(n.getParameterFormat(t)||""));}}function Oi(i,e){if(i&1){let t=lC();ws(0,"div",11),Rg("click",function(){let o=If(t).$index,r=gC(2);return wf(r.selectAutocompleteItemByClick(o))})("keydown.enter",function(){let o=If(t).$index,r=gC(2);return wf(r.selectAutocompleteItemByClick(o))})("keydown.space",function(){let o=If(t).$index,r=gC(2);return wf(r.selectAutocompleteItemByClick(o))})("mouseenter",function(){let o=If(t).$index,r=gC(2);return wf(r.selectedAutocompleteIndex=o)}),ws(1,"div",12),Sg(2,"span",13),aT(3,"highlight"),Jw(4,Ei,2,1,"span",14),pl(),Sg(5,"div",15),aT(6,"highlight"),pl();}if(i&2){let t=e.$implicit,n=e.$index,o=gC(2);Ug("selected",n===o.selectedAutocompleteIndex),Tg("aria-selected",n===o.selectedAutocompleteIndex),XE(2),bg("innerHTML",lT(3,6,o.autocompleteTrigger+t.name,o.getAutocompleteQuery()),aE),XE(2),eC(o.hasParameterFormat(t)?4:-1),XE(),bg("innerHTML",lT(6,9,t.description,o.getAutocompleteQuery()),aE);}}function Pi(i,e){if(i&1&&(ws(0,"div",4),rC(1,Oi,7,12,"div",10,Ti),pl()),i&2){let t=gC();XE(),oC(t.autocompleteItems);}}function ki(i,e){if(i&1){let t=lC();ws(0,"ds-icon-button",18),Rg("action",function(){If(t);let o=gC(2);return wf(o.onStopClick())}),pl();}}function Ii(i,e){if(i&1){let t=lC();ws(0,"ds-icon-button",19),Rg("action",function(){If(t);let o=gC(2);return wf(o.sendMessage())}),pl();}if(i&2){let t=gC(2);Ug("hidden",t.isDisabled||!t.message.trim())("active",!!t.message.trim()&&!t.isDisabled),bg("title",t.getSendButtonTooltip())("disabled",t.isDisabled||!t.message.trim());}}function Di(i,e){if(i&1){let t=lC();ws(0,"ds-icon-button",21),Rg("action",function(){If(t);let o=gC(3);return wf(o.triggerFileUpload())}),pl(),ws(1,"input",22,1),Rg("change",function(o){If(t);let r=gC(3);return wf(r.onFileInputChange(o))}),pl();}if(i&2){let t=gC(3);bg("disabled",t.isDisabled);}}function Ai(i,e){if(i&1){let t=lC();Jw(0,Di,3,1),ws(1,"ds-icon-button",20),Rg("action",function(){If(t);let o=gC(2);return wf(o.toggleRecording())}),pl();}if(i&2){let t=gC(2);eC(!t.showWelcome&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?0:-1),XE(),Ug("hidden",t.message.trim()&&!t.isRecording&&!t.isTranscribing),bg("variant",t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing)?"danger":"default")("disabled",t.isVoiceMessageMode&&t.isTranscribing)("title",t.isRecording?"Click to stop recording":t.isTranscribing?"Uploading...":"Click to start recording");}}function Fi(i,e){if(i&1&&(ws(0,"div",7),Jw(1,ki,1,0,"ds-icon-button",16),Jw(2,Ii,1,6,"ds-icon-button",17),Jw(3,Ai,2,6),pl()),i&2){let t=gC();XE(),eC(t.isThinking?1:-1),XE(),eC((!t.isThinking||t.message.trim())&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?2:-1),XE(),eC(t.isThinking?-1:3);}}var rt=class i{isDisabled=false;showWelcome=false;isThinking=false;isStarting=false;isSessionInitializing=false;isStopping=false;filesPasted=new vt$1;messageSubmitted=new vt$1;voiceMessageReady=new vt$1;voiceRecordingToggled=new vt$1;heightChanged=new vt$1;stopRequested=new vt$1;textareaFocused=new vt$1;messageInput;fileInput;message="";isRecording=false;isTranscribing=false;isFocused=false;recognition=null;mediaRecorder=null;audioChunks=[];voiceInputMode="browser";get isVoiceMessageMode(){return this.voiceInputMode==="voice-message"}sessionHadTranscript=false;pendingLineBreaksTimeout=null;lastProcessedResultIndex=0;useEnterToSend=false;currentInvite="";subscriptions=[];thinkingPhrases=["Processing request...","Thinking...","Working on it..."];currentThinkingPhrase="Processing request...";thinkingPhraseIndex=0;thinkingInterval=null;autocompleteVisible=false;autocompleteTrigger=null;autocompleteItems=[];selectedAutocompleteIndex=0;preferencesService=g(L);codayService=g(Ge);agentApiService=g(f);promptApiService=g(d);projectStateService=g(P$1);audioApiService=g(be);threadStateService=g(U);ngOnInit(){this.initializeVoiceInput(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.subscriptions.push(this.preferencesService.voiceLanguage$.subscribe(()=>this.updateRecognitionLanguage())),this.subscriptions.push(this.preferencesService.voiceInputMode$.subscribe(e=>{this.voiceInputMode=e;})),this.subscriptions.push(this.preferencesService.enterToSend$.subscribe(e=>{this.useEnterToSend=e;})),this.subscribeToInviteEvents(),this.subscribeToMessageRestore();}ngAfterViewInit(){this.adjustTextareaHeight(),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),200);});}ngOnChanges(e){e.isThinking&&(e.isThinking.currentValue?this.startThinkingAnimation():(this.stopThinkingAnimation(),this.isStopping=false,e.isThinking.previousValue&&(console.log("[CHAT-TEXTAREA] Thinking ended, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100);})))),e.isSessionInitializing&&!e.isSessionInitializing.currentValue&&e.isSessionInitializing.previousValue&&(console.log("[CHAT-TEXTAREA] Session initialization completed, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100);})),e.isStarting&&!e.isStarting.currentValue&&e.isStarting.previousValue&&this.isThinking&&(this.thinkingPhraseIndex===0?(console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index 0 - restarting animation"),this.stopThinkingAnimation(),this.startThinkingAnimation()):console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index",this.thinkingPhraseIndex,"- continuing without restart"));}ngOnDestroy(){this.subscriptions.forEach(e=>e.unsubscribe()),this.subscriptions=[],this.clearPendingLineBreaks(),this.stopThinkingAnimation();}onKeyDown(e){if(this.autocompleteVisible)switch(e.key){case "ArrowDown":e.preventDefault(),this.selectedAutocompleteIndex=Math.min(this.selectedAutocompleteIndex+1,this.autocompleteItems.length-1),this.scrollSelectedItemIntoView();return;case "ArrowUp":e.preventDefault(),this.selectedAutocompleteIndex=Math.max(this.selectedAutocompleteIndex-1,0),this.scrollSelectedItemIntoView();return;case "Tab":case "Enter":if(!this.message.includes(" ")){e.preventDefault(),this.selectAutocompleteItem();return}break;case "Escape":e.preventDefault(),this.hideAutocomplete();return}e.key==="Enter"&&(this.useEnterToSend?!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),this.sendMessage(true)):(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey)&&!e.shiftKey&&(e.preventDefault(),this.sendMessage(true)));}onInput(){this.adjustTextareaHeight(),this.checkForAutocomplete();}onPaste(e){let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(r=>r.kind==="file");if(!n.length)return;e.preventDefault();let o=n.reduce((r,d)=>{let v=d.getAsFile();return v?[...r,v]:r},[]);o.length&&this.filesPasted.emit(o);}triggerFileUpload(){console.log("[CHAT-TEXTAREA] Triggering file upload"),this.fileInput?.nativeElement?.click();}onFileInputChange(e){let t=e.target,n=t.files;if(!n||n.length===0){console.log("[CHAT-TEXTAREA] No files selected");return}console.log("[CHAT-TEXTAREA] Files selected:",n.length);let o=Array.from(n);this.filesPasted.emit(o),t.value="";}onDocumentClick(e){if(!this.autocompleteVisible)return;let t=e.target,n=document.querySelector(".autocomplete-popup"),o=this.messageInput?.nativeElement;n&&!n.contains(t)&&o&&!o.contains(t)&&this.hideAutocomplete();}sendMessage(e=false){let t=this.message.trim();!this.isDisabled&&(e||t)&&(this.isRecording&&this.recognition&&(this.clearPendingLineBreaks(),this.recognition.stop()),this.messageSubmitted.emit(t),this.message="",setTimeout(()=>this.adjustTextareaHeight(),0));}onStopClick(){this.isStopping=true,this.stopRequested.emit();}toggleRecording(){this.isRecording?this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.stopWhisperRecording():this.stopRecording():this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.startWhisperRecording():this.startRecording();}startWhisperRecording(){return B(this,null,function*(){if(!this.isRecording)try{let e=yield navigator.mediaDevices.getUserMedia({audio:!0});this.audioChunks=[],this.mediaRecorder=new MediaRecorder(e),this.mediaRecorder.ondataavailable=t=>{t.data.size>0&&this.audioChunks.push(t.data);},this.mediaRecorder.onstop=()=>{e.getTracks().forEach(t=>t.stop()),this.processWhisperAudio();},this.mediaRecorder.onerror=t=>{console.error("[WHISPER] MediaRecorder error:",t),e.getTracks().forEach(n=>n.stop()),this.isRecording=!1,this.voiceRecordingToggled.emit(!1);},this.mediaRecorder.start(),this.isRecording=!0,this.voiceRecordingToggled.emit(!0),console.log("[WHISPER] Started recording");}catch(e){console.error("[WHISPER] Failed to start recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(false);}})}stopWhisperRecording(){if(!(!this.mediaRecorder||!this.isRecording))try{this.mediaRecorder.stop(),this.isRecording=!1,this.voiceRecordingToggled.emit(!1),console.log("[WHISPER] Stopped recording");}catch(e){console.error("[WHISPER] Failed to stop recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(false);}}processWhisperAudio(){if(this.audioChunks.length===0)return;let e=new Blob(this.audioChunks,{type:this.mediaRecorder?.mimeType||"audio/webm"}),t=e.type.split(";")[0]||"audio/webm";this.audioChunks=[],this.isTranscribing=true;let n=new FileReader;n.onloadend=()=>{let o=n.result.split(",")[1];if(!o){console.error("[WHISPER] Failed to read audio as base64"),this.isTranscribing=false;return}let d=this.preferencesService.getVoiceLanguage().split("-")[0];if(this.voiceInputMode==="voice-message"){if(!this.threadStateService.getSelectedThreadId()){console.log("[WHISPER] No thread selected \u2014 emitting voiceMessageReady for thread creation"),this.isTranscribing=false,this.voiceMessageReady.emit({base64:o,mimeType:t,language:d});return}this.audioApiService.sendVoiceMessage(o,t,d).subscribe({next:v=>{this.isTranscribing=false,console.log("[WHISPER] Voice message sent, transcription:",v.transcription?.substring(0,50));},error:v=>{console.error("[WHISPER] Voice message error:",v),this.isTranscribing=false,this.fallbackToTranscription(o,t,d);}});}else this.audioApiService.transcribeAudio(o,t,d).subscribe({next:v=>{this.isTranscribing=false,v.text&&this.appendToTextarea(v.text+" ");},error:v=>{console.error("[WHISPER] Transcription error:",v),this.isTranscribing=false;}});},n.readAsDataURL(e);}fallbackToTranscription(e,t,n){this.audioApiService.transcribeAudio(e,t,n).subscribe({next:o=>{this.isTranscribing=false,o.text&&this.appendToTextarea(o.text+" ");},error:o=>{console.error("[WHISPER] Fallback transcription also failed:",o),this.isTranscribing=false;}});}initializeVoiceInput(){let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(console.log("[SPEECH] speechRecognition",e),!e){console.warn("[SPEECH] Speech Recognition API not available");return}this.recognition=new e,this.recognition.continuous=true,this.recognition.interimResults=true,this.recognition.maxAlternatives=1,this.recognition.lang=this.getSelectedLanguage();try{"grammars"in this.recognition&&(this.recognition.serviceURI=void 0);}catch(t){console.log("[SPEECH] Advanced speech recognition parameters not supported");}this.recognition.onresult=t=>{let n="",o=Math.max(t.resultIndex,this.lastProcessedResultIndex);for(let r=o;r<t.results.length;r++)t.results[r].isFinal&&(n+=t.results[r][0].transcript,this.lastProcessedResultIndex=r+1);if(n){let r=this.improveTranscriptPunctuation(n.trim());this.sessionHadTranscript=true,console.log("[SPEECH] onresult ending, appending to textarea",this.isRecording),this.appendToTextarea(r);}},this.recognition.onend=()=>{console.log("[SPEECH] Recognition ended. Was recording:",this.isRecording),this.isRecording=false,this.lastProcessedResultIndex=0,this.voiceRecordingToggled.emit(this.isRecording);},this.recognition.onerror=t=>{console.error("[SPEECH] Speech recognition error:",t.error),console.log("[SPEECH] Error details:",{error:t.error,message:t.message,timeStamp:t.timeStamp}),this.isRecording=false,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording);},this.recognition.onstart=()=>{console.log("[SPEECH] Recognition started successfully");},this.recognition.onspeechstart=()=>{console.log("[SPEECH] Speech detected");},this.recognition.onspeechend=()=>{console.log("[SPEECH] Speech ended");};}startRecording(){return B(this,null,function*(){if(!(!this.recognition||this.isRecording))try{this.isRecording=!0,this.sessionHadTranscript=!1,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording),this.recognition.start(),console.log("[SPEECH] Started recording");}catch(e){console.error("[SPEECH] Failed to start recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(this.isRecording);}})}stopRecording(){if(!this.recognition||!this.isRecording){console.log("[SPEECH] stopRecording not recording");return}try{console.log("[SPEECH] stopRecording recognition stop"),this.recognition.stop(),this.schedulePendingLineBreaks();}catch(e){console.error("[SPEECH] Failed to stop recording:",e);}}getSelectedLanguage(){return this.preferencesService.getVoiceLanguage()}updateRecognitionLanguage(){if(this.recognition){let e=this.getSelectedLanguage();this.recognition.lang=e,console.log("[SPEECH] Language changed to:",e);}}improveTranscriptPunctuation(e){let t=e;return /[.!?]$/.test(t.trim())||(t=t.trim()+"."),t=t.charAt(0).toUpperCase()+t.slice(1),t=t.replace(/\s+/g," "),t=t+" ",t}appendToTextarea(e){let t=this.message;if(this.message=t?`${t}${e}`:e,this.messageInput?.nativeElement){this.messageInput.nativeElement.focus();let n=this.message.length;this.messageInput.nativeElement.setSelectionRange(n,n);}setTimeout(()=>this.adjustTextareaHeight(),0);}schedulePendingLineBreaks(){this.clearPendingLineBreaks(),this.pendingLineBreaksTimeout=window.setTimeout(()=>{this.sessionHadTranscript&&(console.log("[SPEECH] Adding line breaks after transcript session"),this.appendToTextarea(`
1
+ import {f}from'./chunk-DAk8SIkq.js';import {G as Ge,z as z$1,Q as Qe,E as Et,y as yt$2}from'./chunk-C_J2R_PK.js';import {U as Ue$1,x as x$2,i as is}from'./chunk-DqzTsn7a.js';import {al as vt$1,an as ue,g,ay as O,F,L,az as Xt,U,N,p as pe$1,G,ap as wd,ae as kt,aA as an,av as B,e as xw,h as hr$1,aB as fr$1,aC as Tu,k as ws,q as Rg,J as Jw,o as pl,X as XE,v as bg,y as eC,D as Pg,E as EC,I as IC,P as P$1,aD as Ly,Y as x,a9 as lC,ai as tm,aa as If,aj as KC,ab as wf,a3 as VI,A as Ug,ak as em,a6 as UI,B as dE,a as Gi$1,aE as W,H as py,W as br$1,aF as R,r as re,a7 as ya,aG as fe,m as mT,x as x$1,w as w$1,aH as z,b as U$1,aI as bS,t as rC,z as oC,aJ as Tr$1,aK as xb,am as qm,j as Gn$1,n as GC,aL as wo$1,aM as Zn$2,aN as Nn,aO as wt$2,aP as G$1,aQ as $a,aR as Fs,aS as K,aT as Ut,aU as Ue,aV as U$2,aW as C,aX as D$1,aY as ft$1,aZ as js,a_ as QT,ac as gC,a$ as XC,b0 as Qg,a5 as vl,S as Sg,ah as rT,b1 as On,b2 as kb,b3 as Sb,b4 as oT,b5 as nT,aw as hl,b6 as _g,ax as gl,l as le,b7 as u,b8 as B$1,b9 as T,ba as v,bb as m,bc as R$1,bd as h,be as A,a8 as Yg,bf as aT,bg as uT,T as Tg,bh as Vy,i as pr$1,bi as lT,bj as aE,bk as yh}from'./main-2EYBZUJC.js';import {s}from'./chunk-BhXLqAug.js';import {d}from'./chunk-DWSvE7KY.js';import {S as Se$1,P as Pn}from'./chunk-Bx_FH6m3.js';import {u as ui$1,m as mt$1,p as pt$1,Z as Z$1,V as Ve}from'./chunk-BPkyqr-f.js';import {y as yt$1,w as wt$1,t as ti$1,Y as Ye,Z as Zn$1,c as cn}from'./chunk-CZmNdEYy.js';var ot=class i{sanitizer=g(bS);transform(e,t){if(!t||!e)return e;let n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`(${n})`,"gi"),r=e.replace(o,"<strong>$1</strong>");return this.sanitizer.bypassSecurityTrustHtml(r)}static \u0275fac=function(t){return new(t||i)};static \u0275pipe=On({name:"highlight",type:i,pure:true})};var be=class i{http=g(py);projectState=g(P$1);threadState=g(U);transcribeAudio(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow();return this.http.post(`/api/projects/${o}/transcribe`,w$1({audio:e,mimeType:t},n?{language:n}:{}))}sendVoiceMessage(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow(),r=this.threadState.getSelectedThreadIdOrThrow();return this.http.post(`/api/projects/${o}/threads/${r}/voice-message`,w$1({audio:e,mimeType:t},n?{language:n}:{}))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var yi=["messageInput"],wi=["fileInput"],Ti=(i,e)=>e.name;function Si(i,e){i&1&&(ws(0,"div",3),Sg(1,"span",8),GC(2," Recording... Click mic to stop "),pl());}function Mi(i,e){i&1&&(ws(0,"div",3),Sg(1,"span",9),GC(2," Transcribing... "),pl());}function Ei(i,e){if(i&1&&(ws(0,"span",14),GC(1),pl()),i&2){let t=gC().$implicit,n=gC(2);XE(),Yg(" "+(n.getParameterFormat(t)||""));}}function Oi(i,e){if(i&1){let t=lC();ws(0,"div",11),Rg("click",function(){let o=If(t).$index,r=gC(2);return wf(r.selectAutocompleteItemByClick(o))})("keydown.enter",function(){let o=If(t).$index,r=gC(2);return wf(r.selectAutocompleteItemByClick(o))})("keydown.space",function(){let o=If(t).$index,r=gC(2);return wf(r.selectAutocompleteItemByClick(o))})("mouseenter",function(){let o=If(t).$index,r=gC(2);return wf(r.selectedAutocompleteIndex=o)}),ws(1,"div",12),Sg(2,"span",13),aT(3,"highlight"),Jw(4,Ei,2,1,"span",14),pl(),Sg(5,"div",15),aT(6,"highlight"),pl();}if(i&2){let t=e.$implicit,n=e.$index,o=gC(2);Ug("selected",n===o.selectedAutocompleteIndex),Tg("aria-selected",n===o.selectedAutocompleteIndex),XE(2),bg("innerHTML",lT(3,6,o.autocompleteTrigger+t.name,o.getAutocompleteQuery()),aE),XE(2),eC(o.hasParameterFormat(t)?4:-1),XE(),bg("innerHTML",lT(6,9,t.description,o.getAutocompleteQuery()),aE);}}function Pi(i,e){if(i&1&&(ws(0,"div",4),rC(1,Oi,7,12,"div",10,Ti),pl()),i&2){let t=gC();XE(),oC(t.autocompleteItems);}}function ki(i,e){if(i&1){let t=lC();ws(0,"ds-icon-button",18),Rg("action",function(){If(t);let o=gC(2);return wf(o.onStopClick())}),pl();}}function Ii(i,e){if(i&1){let t=lC();ws(0,"ds-icon-button",19),Rg("action",function(){If(t);let o=gC(2);return wf(o.sendMessage())}),pl();}if(i&2){let t=gC(2);Ug("hidden",t.isDisabled||!t.message.trim())("active",!!t.message.trim()&&!t.isDisabled),bg("title",t.getSendButtonTooltip())("disabled",t.isDisabled||!t.message.trim());}}function Di(i,e){if(i&1){let t=lC();ws(0,"ds-icon-button",21),Rg("action",function(){If(t);let o=gC(3);return wf(o.triggerFileUpload())}),pl(),ws(1,"input",22,1),Rg("change",function(o){If(t);let r=gC(3);return wf(r.onFileInputChange(o))}),pl();}if(i&2){let t=gC(3);bg("disabled",t.isDisabled);}}function Ai(i,e){if(i&1){let t=lC();Jw(0,Di,3,1),ws(1,"ds-icon-button",20),Rg("action",function(){If(t);let o=gC(2);return wf(o.toggleRecording())}),pl();}if(i&2){let t=gC(2);eC(!t.showWelcome&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?0:-1),XE(),Ug("hidden",t.message.trim()&&!t.isRecording&&!t.isTranscribing),bg("variant",t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing)?"danger":"default")("disabled",t.isVoiceMessageMode&&t.isTranscribing)("title",t.isRecording?"Click to stop recording":t.isTranscribing?"Uploading...":"Click to start recording");}}function Fi(i,e){if(i&1&&(ws(0,"div",7),Jw(1,ki,1,0,"ds-icon-button",16),Jw(2,Ii,1,6,"ds-icon-button",17),Jw(3,Ai,2,6),pl()),i&2){let t=gC();XE(),eC(t.isThinking?1:-1),XE(),eC((!t.isThinking||t.message.trim())&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?2:-1),XE(),eC(t.isThinking?-1:3);}}var rt=class i{isDisabled=false;showWelcome=false;isThinking=false;isStarting=false;isSessionInitializing=false;isStopping=false;filesPasted=new vt$1;messageSubmitted=new vt$1;voiceMessageReady=new vt$1;voiceRecordingToggled=new vt$1;heightChanged=new vt$1;stopRequested=new vt$1;textareaFocused=new vt$1;messageInput;fileInput;message="";isRecording=false;isTranscribing=false;isFocused=false;recognition=null;mediaRecorder=null;audioChunks=[];voiceInputMode="browser";get isVoiceMessageMode(){return this.voiceInputMode==="voice-message"}sessionHadTranscript=false;pendingLineBreaksTimeout=null;lastProcessedResultIndex=0;useEnterToSend=false;currentInvite="";subscriptions=[];thinkingPhrases=["Processing request...","Thinking...","Working on it..."];currentThinkingPhrase="Processing request...";thinkingPhraseIndex=0;thinkingInterval=null;autocompleteVisible=false;autocompleteTrigger=null;autocompleteItems=[];selectedAutocompleteIndex=0;preferencesService=g(L);codayService=g(Ge);agentApiService=g(f);promptApiService=g(d);projectStateService=g(P$1);audioApiService=g(be);threadStateService=g(U);ngOnInit(){this.initializeVoiceInput(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.subscriptions.push(this.preferencesService.voiceLanguage$.subscribe(()=>this.updateRecognitionLanguage())),this.subscriptions.push(this.preferencesService.voiceInputMode$.subscribe(e=>{this.voiceInputMode=e;})),this.subscriptions.push(this.preferencesService.enterToSend$.subscribe(e=>{this.useEnterToSend=e;})),this.subscribeToInviteEvents(),this.subscribeToMessageRestore();}ngAfterViewInit(){this.adjustTextareaHeight(),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),200);});}ngOnChanges(e){e.isThinking&&(e.isThinking.currentValue?this.startThinkingAnimation():(this.stopThinkingAnimation(),this.isStopping=false,e.isThinking.previousValue&&(console.log("[CHAT-TEXTAREA] Thinking ended, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100);})))),e.isSessionInitializing&&!e.isSessionInitializing.currentValue&&e.isSessionInitializing.previousValue&&(console.log("[CHAT-TEXTAREA] Session initialization completed, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100);})),e.isStarting&&!e.isStarting.currentValue&&e.isStarting.previousValue&&this.isThinking&&(this.thinkingPhraseIndex===0?(console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index 0 - restarting animation"),this.stopThinkingAnimation(),this.startThinkingAnimation()):console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index",this.thinkingPhraseIndex,"- continuing without restart"));}ngOnDestroy(){this.subscriptions.forEach(e=>e.unsubscribe()),this.subscriptions=[],this.clearPendingLineBreaks(),this.stopThinkingAnimation();}onKeyDown(e){if(this.autocompleteVisible)switch(e.key){case "ArrowDown":e.preventDefault(),this.selectedAutocompleteIndex=Math.min(this.selectedAutocompleteIndex+1,this.autocompleteItems.length-1),this.scrollSelectedItemIntoView();return;case "ArrowUp":e.preventDefault(),this.selectedAutocompleteIndex=Math.max(this.selectedAutocompleteIndex-1,0),this.scrollSelectedItemIntoView();return;case "Tab":case "Enter":if(!this.message.includes(" ")){e.preventDefault(),this.selectAutocompleteItem();return}break;case "Escape":e.preventDefault(),this.hideAutocomplete();return}e.key==="Enter"&&(this.useEnterToSend?!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),this.sendMessage(true)):(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey)&&!e.shiftKey&&(e.preventDefault(),this.sendMessage(true)));}onInput(){this.adjustTextareaHeight(),this.checkForAutocomplete();}onPaste(e){let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(r=>r.kind==="file");if(!n.length)return;e.preventDefault();let o=n.reduce((r,d)=>{let v=d.getAsFile();return v?[...r,v]:r},[]);o.length&&this.filesPasted.emit(o);}triggerFileUpload(){console.log("[CHAT-TEXTAREA] Triggering file upload"),this.fileInput?.nativeElement?.click();}onFileInputChange(e){let t=e.target,n=t.files;if(!n||n.length===0){console.log("[CHAT-TEXTAREA] No files selected");return}console.log("[CHAT-TEXTAREA] Files selected:",n.length);let o=Array.from(n);this.filesPasted.emit(o),t.value="";}onDocumentClick(e){if(!this.autocompleteVisible)return;let t=e.target,n=document.querySelector(".autocomplete-popup"),o=this.messageInput?.nativeElement;n&&!n.contains(t)&&o&&!o.contains(t)&&this.hideAutocomplete();}sendMessage(e=false){let t=this.message.trim();!this.isDisabled&&(e||t)&&(this.isRecording&&this.recognition&&(this.clearPendingLineBreaks(),this.recognition.stop()),this.messageSubmitted.emit(t),this.message="",setTimeout(()=>this.adjustTextareaHeight(),0));}onStopClick(){this.isStopping=true,this.stopRequested.emit();}toggleRecording(){this.isRecording?this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.stopWhisperRecording():this.stopRecording():this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.startWhisperRecording():this.startRecording();}startWhisperRecording(){return B(this,null,function*(){if(!this.isRecording)try{let e=yield navigator.mediaDevices.getUserMedia({audio:!0});this.audioChunks=[],this.mediaRecorder=new MediaRecorder(e),this.mediaRecorder.ondataavailable=t=>{t.data.size>0&&this.audioChunks.push(t.data);},this.mediaRecorder.onstop=()=>{e.getTracks().forEach(t=>t.stop()),this.processWhisperAudio();},this.mediaRecorder.onerror=t=>{console.error("[WHISPER] MediaRecorder error:",t),e.getTracks().forEach(n=>n.stop()),this.isRecording=!1,this.voiceRecordingToggled.emit(!1);},this.mediaRecorder.start(),this.isRecording=!0,this.voiceRecordingToggled.emit(!0),console.log("[WHISPER] Started recording");}catch(e){console.error("[WHISPER] Failed to start recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(false);}})}stopWhisperRecording(){if(!(!this.mediaRecorder||!this.isRecording))try{this.mediaRecorder.stop(),this.isRecording=!1,this.voiceRecordingToggled.emit(!1),console.log("[WHISPER] Stopped recording");}catch(e){console.error("[WHISPER] Failed to stop recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(false);}}processWhisperAudio(){if(this.audioChunks.length===0)return;let e=new Blob(this.audioChunks,{type:this.mediaRecorder?.mimeType||"audio/webm"}),t=e.type.split(";")[0]||"audio/webm";this.audioChunks=[],this.isTranscribing=true;let n=new FileReader;n.onloadend=()=>{let o=n.result.split(",")[1];if(!o){console.error("[WHISPER] Failed to read audio as base64"),this.isTranscribing=false;return}let d=this.preferencesService.getVoiceLanguage().split("-")[0];if(this.voiceInputMode==="voice-message"){if(!this.threadStateService.getSelectedThreadId()){console.log("[WHISPER] No thread selected \u2014 emitting voiceMessageReady for thread creation"),this.isTranscribing=false,this.voiceMessageReady.emit({base64:o,mimeType:t,language:d});return}this.audioApiService.sendVoiceMessage(o,t,d).subscribe({next:v=>{this.isTranscribing=false,console.log("[WHISPER] Voice message sent, transcription:",v.transcription?.substring(0,50));},error:v=>{console.error("[WHISPER] Voice message error:",v),this.isTranscribing=false,this.fallbackToTranscription(o,t,d);}});}else this.audioApiService.transcribeAudio(o,t,d).subscribe({next:v=>{this.isTranscribing=false,v.text&&this.appendToTextarea(v.text+" ");},error:v=>{console.error("[WHISPER] Transcription error:",v),this.isTranscribing=false;}});},n.readAsDataURL(e);}fallbackToTranscription(e,t,n){this.audioApiService.transcribeAudio(e,t,n).subscribe({next:o=>{this.isTranscribing=false,o.text&&this.appendToTextarea(o.text+" ");},error:o=>{console.error("[WHISPER] Fallback transcription also failed:",o),this.isTranscribing=false;}});}initializeVoiceInput(){let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(console.log("[SPEECH] speechRecognition",e),!e){console.warn("[SPEECH] Speech Recognition API not available");return}this.recognition=new e,this.recognition.continuous=true,this.recognition.interimResults=true,this.recognition.maxAlternatives=1,this.recognition.lang=this.getSelectedLanguage();try{"grammars"in this.recognition&&(this.recognition.serviceURI=void 0);}catch(t){console.log("[SPEECH] Advanced speech recognition parameters not supported");}this.recognition.onresult=t=>{let n="",o=Math.max(t.resultIndex,this.lastProcessedResultIndex);for(let r=o;r<t.results.length;r++)t.results[r].isFinal&&(n+=t.results[r][0].transcript,this.lastProcessedResultIndex=r+1);if(n){let r=this.improveTranscriptPunctuation(n.trim());this.sessionHadTranscript=true,console.log("[SPEECH] onresult ending, appending to textarea",this.isRecording),this.appendToTextarea(r);}},this.recognition.onend=()=>{console.log("[SPEECH] Recognition ended. Was recording:",this.isRecording),this.isRecording=false,this.lastProcessedResultIndex=0,this.voiceRecordingToggled.emit(this.isRecording);},this.recognition.onerror=t=>{console.error("[SPEECH] Speech recognition error:",t.error),console.log("[SPEECH] Error details:",{error:t.error,message:t.message,timeStamp:t.timeStamp}),this.isRecording=false,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording);},this.recognition.onstart=()=>{console.log("[SPEECH] Recognition started successfully");},this.recognition.onspeechstart=()=>{console.log("[SPEECH] Speech detected");},this.recognition.onspeechend=()=>{console.log("[SPEECH] Speech ended");};}startRecording(){return B(this,null,function*(){if(!(!this.recognition||this.isRecording))try{this.isRecording=!0,this.sessionHadTranscript=!1,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording),this.recognition.start(),console.log("[SPEECH] Started recording");}catch(e){console.error("[SPEECH] Failed to start recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(this.isRecording);}})}stopRecording(){if(!this.recognition||!this.isRecording){console.log("[SPEECH] stopRecording not recording");return}try{console.log("[SPEECH] stopRecording recognition stop"),this.recognition.stop(),this.schedulePendingLineBreaks();}catch(e){console.error("[SPEECH] Failed to stop recording:",e);}}getSelectedLanguage(){return this.preferencesService.getVoiceLanguage()}updateRecognitionLanguage(){if(this.recognition){let e=this.getSelectedLanguage();this.recognition.lang=e,console.log("[SPEECH] Language changed to:",e);}}improveTranscriptPunctuation(e){let t=e;return /[.!?]$/.test(t.trim())||(t=t.trim()+"."),t=t.charAt(0).toUpperCase()+t.slice(1),t=t.replace(/\s+/g," "),t=t+" ",t}appendToTextarea(e){let t=this.message;if(this.message=t?`${t}${e}`:e,this.messageInput?.nativeElement){this.messageInput.nativeElement.focus();let n=this.message.length;this.messageInput.nativeElement.setSelectionRange(n,n);}setTimeout(()=>this.adjustTextareaHeight(),0);}schedulePendingLineBreaks(){this.clearPendingLineBreaks(),this.pendingLineBreaksTimeout=window.setTimeout(()=>{this.sessionHadTranscript&&(console.log("[SPEECH] Adding line breaks after transcript session"),this.appendToTextarea(`
2
2
 
3
- `),this.sessionHadTranscript=false),this.pendingLineBreaksTimeout=null;},500);}clearPendingLineBreaks(){this.pendingLineBreaksTimeout&&(clearTimeout(this.pendingLineBreaksTimeout),this.pendingLineBreaksTimeout=null);}adjustTextareaHeight(){let e=this.messageInput?.nativeElement;if(!e)return;let t=e.parentElement?.offsetHeight??e.offsetHeight+32;this.heightChanged.emit(t);}getSendButtonShortcut(){return this.useEnterToSend?"Enter":navigator.platform.toLowerCase().includes("mac")?"\u2318+Enter":"Ctrl+Enter"}getSendButtonTooltip(){return this.useEnterToSend?"Send message (Enter) - Shift+Enter for new line":`Send message (${navigator.platform.toLowerCase().includes("mac")?"Cmd+Enter":"Ctrl+Enter"}) - Enter for new line`}getPlaceholder(){return this.isSessionInitializing?"Initializing session...":this.isThinking?this.isStopping?"Stopping...":this.isStarting?"Processing request...":this.currentThinkingPhrase:this.isVoiceMessageMode&&this.isTranscribing?"Uploading...":this.isVoiceMessageMode&&this.isRecording?"Listening...":this.showWelcome?"How can I help you today?":"Type '@' for agents, '/' for commands, or just your message..."}startThinkingAnimation(){this.thinkingPhraseIndex=0,this.currentThinkingPhrase=this.thinkingPhrases[0]??"Thinking...",this.thinkingInterval=window.setInterval(()=>{this.thinkingPhraseIndex<this.thinkingPhrases.length-1&&(this.thinkingPhraseIndex++,this.currentThinkingPhrase=this.thinkingPhrases[this.thinkingPhraseIndex]??"Thinking...");},2e3);}stopThinkingAnimation(){this.thinkingInterval&&(clearInterval(this.thinkingInterval),this.thinkingInterval=null),this.thinkingPhraseIndex=0,this.currentThinkingPhrase="Thinking...";}subscribeToInviteEvents(){this.subscriptions.push(this.codayService.currentInviteEvent$.subscribe(e=>{e?this.handleInviteEvent(e.invite,e.defaultValue):this.currentInvite="";}));}handleInviteEvent(e,t){this.currentInvite=e,t&&(this.message=t,setTimeout(()=>this.adjustTextareaHeight(),0)),setTimeout(()=>{this.messageInput?.nativeElement&&this.messageInput.nativeElement.focus();},50);}subscribeToMessageRestore(){this.subscriptions.push(this.codayService.messageToRestore$.subscribe(e=>{e.trim()&&(console.log("[CHAT-TEXTAREA] Restoring message content:",e.substring(0,50)+"..."),this.restoreMessageContent(e));}));}restoreMessageContent(e){this.message=e,this.messageInput?.nativeElement&&(this.messageInput.nativeElement.focus(),setTimeout(()=>{let t=this.messageInput.nativeElement,n=this.message.length;t.setSelectionRange(n,n);},0)),setTimeout(()=>this.adjustTextareaHeight(),10);}focusTextarea(){let e=this.messageInput?.nativeElement;console.log("[CHAT-TEXTAREA] focusTextarea called",{hasElement:!!e,isDisabled:this.isDisabled,isThinking:this.isThinking,elementDisabled:e?.disabled,isSessionInitializing:this.isSessionInitializing}),e&&!e.disabled?(e.focus(),console.log("[CHAT-TEXTAREA] Textarea focused successfully")):console.log("[CHAT-TEXTAREA] Focus blocked - element disabled or not available");}checkForAutocomplete(){let e=this.message;if(e.startsWith("@")){let t=e.substring(1);if(t.includes(" ")){this.hideAutocomplete();return}this.showAgentAutocomplete(t);return}if(e.startsWith("/")){let t=e.substring(1);if(t.includes(" ")){this.hideAutocomplete();return}this.showPromptAutocomplete(t);return}this.hideAutocomplete();}showAgentAutocomplete(e){this.autocompleteTrigger="@";try{let t=this.projectStateService.getSelectedProjectIdOrThrow();this.agentApiService.getAgentsAutocomplete(t,e).subscribe({next:n=>{this.autocompleteItems=n,this.autocompleteVisible=n.length>0,this.selectedAutocompleteIndex=0;},error:n=>{console.error("[AUTOCOMPLETE] Error loading agents:",n),this.hideAutocomplete();}});}catch(t){console.warn("[AUTOCOMPLETE] No project selected, cannot load agents"),this.hideAutocomplete();}}showPromptAutocomplete(e){this.autocompleteTrigger="/";try{let t=this.projectStateService.getSelectedProjectIdOrThrow();this.promptApiService.getPromptsAutocomplete(t,e).subscribe({next:n=>{this.autocompleteItems=n,this.autocompleteVisible=n.length>0,this.selectedAutocompleteIndex=0;},error:n=>{console.error("[AUTOCOMPLETE] Error loading prompts:",n),this.hideAutocomplete();}});}catch(t){console.warn("[AUTOCOMPLETE] No project selected, cannot load prompts"),this.hideAutocomplete();}}hideAutocomplete(){this.autocompleteVisible=false,this.autocompleteItems=[],this.selectedAutocompleteIndex=0;}selectAutocompleteItem(){let e=this.autocompleteItems[this.selectedAutocompleteIndex];if(!e)return;let t=null;if(this.autocompleteTrigger==="/"){let n=e,o=n.parameterFormat;if(console.log(n),o===void 0)this.message=`/${e.name}`;else if(o==="")this.message=`/${e.name} `;else {this.message=`/${e.name} ${o}`;let r=this.message.indexOf('=""');r!==-1&&(t=r+2);}}else this.message=`@${e.name} `;this.hideAutocomplete(),setTimeout(()=>{if(this.messageInput?.nativeElement)if(this.messageInput.nativeElement.focus(),t!==null)this.messageInput.nativeElement.setSelectionRange(t,t);else {let n=this.message.length;this.messageInput.nativeElement.setSelectionRange(n,n);}},0);}selectAutocompleteItemByClick(e){this.selectedAutocompleteIndex=e,this.selectAutocompleteItem();}getAutocompleteQuery(){return this.message.substring(1).split(" ")[0]??""}getParameterFormat(e){return e.parameterFormat}hasParameterFormat(e){return this.autocompleteTrigger==="/"&&e.parameterFormat!==void 0}scrollSelectedItemIntoView(){setTimeout(()=>{let e=document.querySelector(".autocomplete-popup");if(!e)return;let t=e.querySelector(".autocomplete-item.selected");t&&t.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});},0);}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-chat-textarea"]],viewQuery:function(t,n){if(t&1&&Pg(yi,7)(wi,5),t&2){let o;EC(o=IC())&&(n.messageInput=o.first),EC(o=IC())&&(n.fileInput=o.first);}},hostBindings:function(t,n){t&1&&Rg("paste",function(r){return n.onPaste(r)})("click",function(r){return n.onDocumentClick(r)},dE);},inputs:{isDisabled:"isDisabled",showWelcome:"showWelcome",isThinking:"isThinking",isStarting:"isStarting",isSessionInitializing:"isSessionInitializing"},outputs:{filesPasted:"filesPasted",messageSubmitted:"messageSubmitted",voiceMessageReady:"voiceMessageReady",voiceRecordingToggled:"voiceRecordingToggled",heightChanged:"heightChanged",stopRequested:"stopRequested",textareaFocused:"textareaFocused"},features:[Tu],decls:8,vars:15,consts:[["messageInput",""],["fileInput",""],[1,"chat-input-container"],[1,"recording-indicator"],[1,"autocomplete-popup"],[1,"input-row","grouped-input"],[1,"message-input",3,"ngModelChange","keydown","input","focus","blur","ngModel","placeholder","disabled"],[1,"actions"],[1,"recording-dot"],[1,"transcribing-dot"],["role","option","tabindex","0",1,"autocomplete-item",3,"selected"],["role","option","tabindex","0",1,"autocomplete-item",3,"click","keydown.enter","keydown.space","mouseenter"],[1,"item-name"],[3,"innerHTML"],[1,"parameter-format"],[1,"item-description",3,"innerHTML"],["icon","stop","variant","danger","title","Stop generation",1,"action-btn"],["icon","send","variant","primary",1,"send-btn",3,"title","disabled","hidden","active"],["icon","stop","variant","danger","title","Stop generation",1,"action-btn",3,"action"],["icon","send","variant","primary",1,"send-btn",3,"action","title","disabled"],["icon","mic",1,"voice-btn",3,"action","variant","disabled","title"],["icon","attach_file","variant","default","title","Upload files (images or documents)",1,"upload-btn",3,"action","disabled"],["type","file","multiple","","accept","image/*,application/pdf,.pdf,.doc,.docx,.txt,.md,.json,.yaml,.yml,.csv,.xml,.html",2,"display","none",3,"change"]],template:function(t,n){if(t&1){let o=lC();ws(0,"div",2),Jw(1,Si,3,0,"div",3),Jw(2,Mi,3,0,"div",3),Jw(3,Pi,3,0,"div",4),ws(4,"div",5)(5,"textarea",6,0),tm("ngModelChange",function(d){return If(o),KC(n.message,d)||(n.message=d),wf(d)}),Rg("keydown",function(d){return n.onKeyDown(d)})("input",function(){return n.onInput()})("focus",function(){return If(o),n.isFocused=true,wf(n.textareaFocused.emit())})("blur",function(){return n.isFocused=false}),pl(),VI(),Jw(7,Fi,4,3,"div",7),pl()();}t&2&&(XE(),eC(!n.isVoiceMessageMode&&n.isRecording?1:-1),XE(),eC(!n.isVoiceMessageMode&&n.isTranscribing?2:-1),XE(),eC(n.autocompleteVisible?3:-1),XE(),Ug("focused",n.isFocused)("welcome-mode",n.showWelcome)("is-thinking",n.isThinking)("is-listening",n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),XE(),em("ngModel",n.message),bg("placeholder",n.getPlaceholder())("disabled",n.isDisabled||n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),UI(),XE(2),eC(n.isSessionInitializing?-1:7));},dependencies:[ti$1,Ye,Zn$1,cn,Se$1,ot],styles:['@keyframes _ngcontent-%COMP%_gradientBorderShift{0%{background-position:0 0}50%{background-position:100% 0}to{background-position:0 0}}.chat-input-container[_ngcontent-%COMP%]{flex-shrink:0;width:100%;position:relative}.thinking-progress[_ngcontent-%COMP%]{position:absolute;top:0;left:0;right:0;height:3px;z-index:1}.thinking-progress[_ngcontent-%COMP%] .mdc-linear-progress__bar-inner{border-top-width:3px}.input-row.grouped-input[_ngcontent-%COMP%]{display:flex;align-items:stretch;background:var(--glass-bg);border-radius:16px;padding:0 .15rem 0 1.25rem;position:relative;transition:border-color .2s,box-shadow .2s,background .3s}.input-row[_ngcontent-%COMP%]{position:relative;background:var(--glass-bg, #1e1e1e)!important;background-clip:padding-box}.input-row[_ngcontent-%COMP%]:before{content:"";position:absolute;inset:-2px;border-radius:inherit;background-size:200% 100%;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:xor;mask-composite:exclude;padding:1px;pointer-events:none;z-index:-1;animation:_ngcontent-%COMP%_gradientBorderShift 3s ease-in-out infinite}.input-row.is-listening[_ngcontent-%COMP%]:before{inset:0;-webkit-mask:none;mask:none;padding:0;opacity:.15;z-index:0;background:linear-gradient(90deg,var(--color-error, #ef4444) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-error, #ef4444) 100%);background-size:200% 100%;animation:_ngcontent-%COMP%_gradientBorderShift 2s ease-in-out infinite}.input-row.is-listening[_ngcontent-%COMP%] .message-input[_ngcontent-%COMP%], .input-row.is-listening[_ngcontent-%COMP%] .action-btn[_ngcontent-%COMP%]{position:relative;z-index:1}.input-row.is-thinking[_ngcontent-%COMP%]:before{inset:0;-webkit-mask:none;mask:none;padding:0;opacity:.15;z-index:0;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% 100%;animation:_ngcontent-%COMP%_gradientBorderShift 3s ease-in-out infinite}.input-row.is-thinking[_ngcontent-%COMP%] .message-input[_ngcontent-%COMP%], .input-row.is-thinking[_ngcontent-%COMP%] .action-btn[_ngcontent-%COMP%]{position:relative;z-index:1}.input-row.grouped-input.focused[_ngcontent-%COMP%]:not(.is-thinking):before{background:var(--color-primary);animation:none}.input-row.grouped-input.focused[_ngcontent-%COMP%]:not(.is-thinking){box-shadow:0 0 0 4px #007aff1a}.message-input[_ngcontent-%COMP%]{flex:1;border:none;outline:none;background:transparent!important;box-shadow:none;font-size:1rem;padding:1rem 0;color:var(--color-text);resize:none;field-sizing:content;min-height:36px;max-height:70vh;overflow-y:auto;font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,system-ui,sans-serif;line-height:1.5}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar{width:8px}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--color-text-secondary)}.message-input[_ngcontent-%COMP%]:focus{outline:none;border:none;box-shadow:none}.message-input[_ngcontent-%COMP%]:disabled{background-color:var(--color-bg-secondary);color:var(--color-text-secondary);cursor:not-allowed;opacity:.6}.message-input[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary);transition:opacity .3s ease-in-out}.message-input[_ngcontent-%COMP%]:disabled::placeholder{animation:_ngcontent-%COMP%_thinkingPulsate 2s ease-in-out infinite}@keyframes _ngcontent-%COMP%_thinkingPulsate{0%,to{opacity:.6}50%{opacity:1}}.voice-btn[_ngcontent-%COMP%], .send-btn[_ngcontent-%COMP%], .action-btn[_ngcontent-%COMP%], .upload-btn[_ngcontent-%COMP%]{margin:0}.actions[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-wrap:wrap;justify-content:center}.send-btn[_ngcontent-%COMP%]{transition:opacity .4s,margin-left .4s}.send-btn.active[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{opacity:1}.send-btn[_ngcontent-%COMP%]:not(.active) button[_ngcontent-%COMP%]{opacity:0;margin-left:calc(-.5rem - 36px)}.send-btn[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:hover:not(:disabled){color:#fff;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-primary, #3b82f6) 20%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 80%,var(--color-primary, #3b82f6) 100%);background-size:300% auto;animation:sendButtonGradientShift 6s ease-in-out infinite;box-shadow:0 4px 14px #007aff30;transform:scale(1.2)}.send-btn[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:active:not(:disabled){transform:scale(1.3);box-shadow:0 4px 24px #007aff30}.recording-indicator[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin-top:.2rem;margin-bottom:.2rem;color:var(--color-error, #ff5555);font-size:.9rem;position:absolute;top:-1.5rem}@keyframes _ngcontent-%COMP%_pulse{0%,to{opacity:1}50%{opacity:.5}}.autocomplete-popup[_ngcontent-%COMP%]{position:absolute;bottom:100%;left:0;right:0;margin-bottom:.5rem;background:var(--glass-bg);-webkit-backdrop-filter:var(--glass-backdrop-blur);backdrop-filter:var(--glass-backdrop-blur);border-radius:12px;box-shadow:0 8px 32px #00000026;border:1px solid var(--color-border);max-height:400px;max-width:500px;overflow-y:auto;z-index:100}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar{width:8px}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--color-text-secondary)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%]{padding:.75rem 1rem;cursor:pointer;transition:background .2s;border-left:3px solid transparent}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%]:hover, .autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item.selected[_ngcontent-%COMP%]{background:var(--color-bg-hover)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item.selected[_ngcontent-%COMP%]{border-left-color:var(--color-primary)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%]{font-weight:600;color:var(--color-text);margin-bottom:.25rem;font-family:SF Mono,Monaco,Menlo,Cascadia Code,Consolas,monospace;font-size:.95rem}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%] strong{font-weight:700;color:var(--color-primary);background:var(--color-primary-light, rgba(99, 102, 241, .1));padding:0 2px;border-radius:2px}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%] .parameter-format[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-weight:400;opacity:.7}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-description[_ngcontent-%COMP%]{font-size:.85rem;color:var(--color-text-secondary);line-height:1.3}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-description[_ngcontent-%COMP%] strong{font-weight:700;color:var(--color-primary);background:var(--color-primary-light, rgba(99, 102, 241, .1))}@media print{.thinking-progress[_ngcontent-%COMP%], .action-btn[_ngcontent-%COMP%], .voice-btn[_ngcontent-%COMP%], .send-btn[_ngcontent-%COMP%], .upload-btn[_ngcontent-%COMP%], .recording-indicator[_ngcontent-%COMP%], .autocomplete-popup[_ngcontent-%COMP%]{display:none!important}}'],changeDetection:1})};var Ce=class i{unreadCountSubject=new Tr$1(0);unreadCount$=this.unreadCountSubject.asObservable();constructor(){console.log("[UNREAD] Service initialized");}addUnread(){let t=this.unreadCountSubject.value+1;this.unreadCountSubject.next(t),console.log("[UNREAD] Added unread message, total:",t);}markAllAsRead(){this.unreadCountSubject.value>0&&(this.unreadCountSubject.next(0),console.log("[UNREAD] Marked all messages as read"));}getCurrentCount(){return this.unreadCountSubject.value}reset(){this.unreadCountSubject.next(0),console.log("[UNREAD] Counter reset");}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var at=class i{ATTENTION_EMOJI="\u{1F534}";isSystemActive=false;systemActiveTimer=null;SYSTEM_ACTIVE_TIMEOUT=4e3;unreadService=g(Ce);project=g(P$1);constructor(){this.initializeTitleUpdates();}initializeTitleUpdates(){Py([this.project.selectedProject$,this.unreadService.unreadCount$]).subscribe(([e,t])=>{this.updateTitle(e?.name??"...",t);});}updateTitle(e,t){let n;this.isSystemActive?n=`\u23F3${t>0?` (${t}) `:" "}${e}`:t>0?n=`${this.ATTENTION_EMOJI} (${t}) ${e}`:n=e,document.title=n,console.log("[TAB-TITLE] Updated to:",n);}setSystemActive(){console.log("[TAB-TITLE] System active - showing hourglass"),this.isSystemActive=true,this.systemActiveTimer&&clearTimeout(this.systemActiveTimer),this.systemActiveTimer=setTimeout(()=>{console.log("[TAB-TITLE] System active timeout - hiding hourglass"),this.isSystemActive=false,this.forceUpdateTitle();},this.SYSTEM_ACTIVE_TIMEOUT),this.forceUpdateTitle();}setSystemInactive(){console.log("[TAB-TITLE] System inactive - hiding hourglass"),this.isSystemActive=false,this.systemActiveTimer&&(clearTimeout(this.systemActiveTimer),this.systemActiveTimer=null),this.forceUpdateTitle();}forceUpdateTitle(){let e=this.project.getSelectedProjectId()??"...",t=this.unreadService.getCurrentCount();this.updateTitle(e,t);}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var st=class i{pendingFirstMessage=null;pendingVoiceMessage=null;setPendingFirstMessage(e){console.log("[FIRST-MESSAGE-STATE] Storing pending first message:",e.substring(0,50)+"..."),this.pendingFirstMessage=e;}consumePendingFirstMessage(){let e=this.pendingFirstMessage;return e?(console.log("[FIRST-MESSAGE-STATE] Consuming pending first message:",e.substring(0,50)+"..."),this.pendingFirstMessage=null):console.log("[FIRST-MESSAGE-STATE] No pending first message to consume"),e}setPendingVoiceMessage(e){console.log("[FIRST-MESSAGE-STATE] Storing pending voice message"),this.pendingVoiceMessage=e;}consumePendingVoiceMessage(){let e=this.pendingVoiceMessage;return e&&(console.log("[FIRST-MESSAGE-STATE] Consuming pending voice message"),this.pendingVoiceMessage=null),e}hasPendingFirstMessage(){return this.pendingFirstMessage!==null||this.pendingVoiceMessage!==null}clear(){this.pendingFirstMessage&&(console.log("[FIRST-MESSAGE-STATE] Clearing pending first message"),this.pendingFirstMessage=null),this.pendingVoiceMessage=null;}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var Ri=(i,e)=>e.label;function Hi(i,e){if(i&1){let t=lC();ws(0,"button",2),Rg("click",function(o){let r=If(t).$implicit,d=gC();return wf(d.executeAction(r,o))}),ws(1,"mat-icon"),GC(2),pl()();}if(i&2){let t=e.$implicit;Tg("title",t.tooltip||t.label),XE(),Tg("aria-label",t.label),XE(),Yg(t.icon);}}var ct=class i{actions=[];executeAction(e,t){t.stopPropagation(),e.action();}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-message-context-menu"]],inputs:{actions:"actions"},decls:3,vars:0,consts:[[1,"context-menu-wrapper"],["mat-icon-button",""],["mat-icon-button","",3,"click"]],template:function(t,n){t&1&&(ws(0,"div",0),rC(1,Hi,3,3,"button",1,Ri),pl()),t&2&&(XE(),oC(n.actions));},dependencies:[qm,Gn$1,wt$1],styles:[".context-menu-wrapper[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center}.context-menu-wrapper[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{transform:scale(.75)}"],changeDetection:1})};var Z=class i{renderer;constructor(){this.renderer=new Ue$1,this.configureRenderer();}configureRenderer(){let e=this.renderer.link.bind(this.renderer);this.renderer.link=t=>{let n=this.isExternalLink(t.href),o=e(t);if(n){o=o.replace("<a ",'<a target="_blank" rel="noopener noreferrer" ');let r=t.title?`${t.text} - ${t.title} (opens in new tab)`:`${t.text} (opens in new tab)`;o=o.replace("<a ",`<a aria-label="${this.escapeHtml(r)}" `),o=o.replace("</a>",'<span class="external-link-icon" aria-hidden="true">\u2197</span></a>');}return o};}isExternalLink(e){if(!e||e.startsWith("/")||e.startsWith("#")||e.startsWith("?"))return false;if(e.startsWith("//"))return true;try{return new URL(e,window.location.href).hostname!==window.location.hostname}catch(t){return false}}escapeHtml(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return e.replace(/[&<>"']/g,n=>t[n]||n)}parse(e){return B(this,null,function*(){let t=yield x$2.parse(e,{renderer:this.renderer,breaks:true,gfm:true});return is.sanitize(t,{ADD_TAGS:["span"],ADD_ATTR:["aria-hidden","aria-label","target","rel"],ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))/i})})}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var Vi=i=>({"user-message-wrapper":i});function Li(i,e){if(i&1&&(ws(0,"div",4)(1,"div",8),GC(2),pl()()),i&2){let t=gC(2);XE(2),vl(" ",t.message.speaker," ");}}function zi(i,e){if(i&1&&(ws(0,"time",6),GC(1),pl()),i&2){let t=gC(2);XE(),Yg(t.formattedTimestamp);}}function Ni(i,e){if(i&1&&(ws(0,"div",7),Sg(1,"app-message-context-menu",9),pl()),i&2){let t=gC(2);XE(),bg("actions",t.actions);}}function $i(i,e){if(i&1&&(Jw(0,Li,3,1,"div",4),Sg(1,"div",5),Jw(2,zi,2,1,"time",6),Jw(3,Ni,2,1,"div",7)),i&2){let t=gC();eC(t.shouldShowSpeaker?0:-1),XE(),bg("innerHTML",t.renderedContent,aE),XE(),eC(t.formattedTimestamp?2:-1),XE(),eC(t.isLongMessage&&t.shouldShowActions&&t.message.role==="assistant"?3:-1);}}function ji(i,e){if(i&1&&Sg(0,"span",12),i&2){let t=gC(3);bg("innerHTML",t.renderedContent,aE);}}function Ui(i,e){if(i&1&&(ws(0,"span",13),GC(1),pl()),i&2){let t=gC(3);XE(),Yg(t.collapsedErrorText);}}function Bi(i,e){i&1&&GC(0," Show less \u25B2 ");}function Wi(i,e){i&1&&GC(0," Show more \u25BC ");}function qi(i,e){if(i&1){let t=lC();ws(0,"div",10),Jw(1,ji,1,1,"span",12)(2,Ui,2,1,"span",13),ws(3,"button",14),Rg("click",function(){If(t);let o=gC(2);return wf(o.toggleErrorExpanded())}),Jw(4,Bi,1,0)(5,Wi,1,0),pl()();}if(i&2){let t=gC(2);XE(),eC(t.isErrorExpanded()?1:2),XE(3),eC(t.isErrorExpanded()?4:5);}}function Yi(i,e){i&1&&GC(0," \u25B2 ");}function Gi(i,e){i&1&&GC(0," \u25BC ");}function Qi(i,e){if(i&1&&(ws(0,"a",17),GC(1,"view"),pl()),i&2){let t=gC(3);bg("href",t.eventLink,yh);}}function Xi(i,e){if(i&1&&(ws(0,"pre",18),GC(1),pl()),i&2){let t=gC(3);XE(),Yg(t.message.fullContent);}}function Ki(i,e){if(i&1){let t=lC();ws(0,"div",15),Sg(1,"span",12),ws(2,"button",16),Rg("click",function(){If(t);let o=gC(2);return wf(o.toggleTechnicalExpanded())}),Jw(3,Yi,1,0)(4,Gi,1,0),pl(),Jw(5,Qi,2,1,"a",17),pl(),Jw(6,Xi,2,1,"pre",18);}if(i&2){let t=gC(2);XE(),bg("innerHTML",t.renderedContent,aE),XE(2),eC(t.isTechnicalExpanded()?3:4),XE(2),eC(t.eventLink?5:-1),XE(),eC(t.isTechnicalExpanded()?6:-1);}}function Ji(i,e){if(i&1&&(ws(0,"a",17),GC(1,"view"),pl()),i&2){let t=gC(3);bg("href",t.eventLink,yh);}}function Zi(i,e){if(i&1&&(ws(0,"div",11),Sg(1,"span",12),Jw(2,Ji,2,1,"a",17),pl()),i&2){let t=gC(2);XE(),bg("innerHTML",t.renderedContent,aE),XE(),eC(t.eventLink?2:-1);}}function eo(i,e){if(i&1&&Jw(0,qi,6,2,"div",10)(1,Ki,7,4)(2,Zi,3,2,"div",11),i&2){let t=gC();eC(t.message.type==="error"&&t.isLongError?0:t.message.type==="technical"&&t.message.fullContent?1:2);}}function to(i,e){if(i&1&&(ws(0,"div",2),Sg(1,"app-message-context-menu",9),pl()),i&2){let t=gC();XE(),bg("actions",t.actions);}}function no(i,e){if(i&1&&(ws(0,"div",3),Sg(1,"app-message-context-menu",9),pl()),i&2){let t=gC();XE(),bg("actions",t.actions);}}var ve=class i{destroy$=new ue;message;canDelete=true;isOtherUser=false;containingThreadId;copyRequested=new vt$1;deleteRequested=new vt$1;renderedContent="";shouldHideTechnical=false;shouldHideWarning=false;isErrorExpanded=Gi$1(false);static ERROR_COLLAPSE_LINE_THRESHOLD=5;isTechnicalExpanded=Gi$1(false);sanitizer=g(bS);notificationService=g(s);preferencesService=g(L);projectState=g(P$1);threadState=g(U);markdownService=g(Z);get messageClasses(){return {[this.message.role]:true,[this.message.type]:true,"hidden-technical":this.shouldHideTechnical&&this.message.type==="technical","hidden-warning":this.shouldHideWarning&&this.message.type==="warning","other-user":this.isOtherUser}}ngOnInit(){return B(this,null,function*(){yield this.renderMarkdown(),this.preferencesService.hideTechnicalMessages$.pipe(wd(this.destroy$)).subscribe(e=>{this.shouldHideTechnical=e;}),this.preferencesService.hideWarningMessages$.pipe(wd(this.destroy$)).subscribe(e=>{this.shouldHideWarning=e;}),this.shouldHideTechnical=this.preferencesService.getHideTechnicalMessages(),this.shouldHideWarning=this.preferencesService.getHideWarningMessages();})}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete();}get shouldShowSpeaker(){return this.message.role==="user"?this.isOtherUser||this.message.speaker.startsWith("@"):this.message.role==="assistant"}get shouldShowActions(){return this.message.role==="user"||this.message.role==="assistant"}get isSimplified(){return this.message.role!=="user"&&this.message.role!=="assistant"}datePipe=g(kb);get formattedTimestamp(){if(this.message.role!=="user"||!this.message.timestamp)return null;let e=new Date().toDateString()===this.message.timestamp.toDateString();return this.datePipe.transform(this.message.timestamp,e?"HH:mm":"dd/MM HH:mm")}get isLongError(){return this.message.type!=="error"?false:this.extractTextContent().split(/\n|\\n/).length>i.ERROR_COLLAPSE_LINE_THRESHOLD}get collapsedErrorText(){return this.extractTextContent().split(/\n|\\n/).slice(0,i.ERROR_COLLAPSE_LINE_THRESHOLD).join(`
3
+ `),this.sessionHadTranscript=false),this.pendingLineBreaksTimeout=null;},500);}clearPendingLineBreaks(){this.pendingLineBreaksTimeout&&(clearTimeout(this.pendingLineBreaksTimeout),this.pendingLineBreaksTimeout=null);}adjustTextareaHeight(){let e=this.messageInput?.nativeElement;if(!e)return;let t=e.parentElement?.offsetHeight??e.offsetHeight+32;this.heightChanged.emit(t);}getSendButtonShortcut(){return this.useEnterToSend?"Enter":navigator.platform.toLowerCase().includes("mac")?"\u2318+Enter":"Ctrl+Enter"}getSendButtonTooltip(){return this.useEnterToSend?"Send message (Enter) - Shift+Enter for new line":`Send message (${navigator.platform.toLowerCase().includes("mac")?"Cmd+Enter":"Ctrl+Enter"}) - Enter for new line`}getPlaceholder(){return this.isSessionInitializing?"Initializing session...":this.isThinking?this.isStopping?"Stopping...":this.isStarting?"Processing request...":this.currentThinkingPhrase:this.isVoiceMessageMode&&this.isTranscribing?"Uploading...":this.isVoiceMessageMode&&this.isRecording?"Listening...":this.showWelcome?"How can I help you today?":"Type '@' for agents, '/' for commands, or just your message..."}startThinkingAnimation(){this.thinkingPhraseIndex=0,this.currentThinkingPhrase=this.thinkingPhrases[0]??"Thinking...",this.thinkingInterval=window.setInterval(()=>{this.thinkingPhraseIndex<this.thinkingPhrases.length-1&&(this.thinkingPhraseIndex++,this.currentThinkingPhrase=this.thinkingPhrases[this.thinkingPhraseIndex]??"Thinking...");},2e3);}stopThinkingAnimation(){this.thinkingInterval&&(clearInterval(this.thinkingInterval),this.thinkingInterval=null),this.thinkingPhraseIndex=0,this.currentThinkingPhrase="Thinking...";}subscribeToInviteEvents(){this.subscriptions.push(this.codayService.currentInviteEvent$.subscribe(e=>{e?this.handleInviteEvent(e.invite,e.defaultValue):this.currentInvite="";}));}handleInviteEvent(e,t){this.currentInvite=e,t&&(this.message=t,setTimeout(()=>this.adjustTextareaHeight(),0)),setTimeout(()=>{this.messageInput?.nativeElement&&this.messageInput.nativeElement.focus();},50);}subscribeToMessageRestore(){this.subscriptions.push(this.codayService.messageToRestore$.subscribe(e=>{e.trim()&&(console.log("[CHAT-TEXTAREA] Restoring message content:",e.substring(0,50)+"..."),this.restoreMessageContent(e));}));}restoreMessageContent(e){this.message=e,this.messageInput?.nativeElement&&(this.messageInput.nativeElement.focus(),setTimeout(()=>{let t=this.messageInput.nativeElement,n=this.message.length;t.setSelectionRange(n,n);},0)),setTimeout(()=>this.adjustTextareaHeight(),10);}focusTextarea(){let e=this.messageInput?.nativeElement;console.log("[CHAT-TEXTAREA] focusTextarea called",{hasElement:!!e,isDisabled:this.isDisabled,isThinking:this.isThinking,elementDisabled:e?.disabled,isSessionInitializing:this.isSessionInitializing}),e&&!e.disabled?(e.focus(),console.log("[CHAT-TEXTAREA] Textarea focused successfully")):console.log("[CHAT-TEXTAREA] Focus blocked - element disabled or not available");}checkForAutocomplete(){let e=this.message;if(e.startsWith("@")){let t=e.substring(1);if(t.includes(" ")){this.hideAutocomplete();return}this.showAgentAutocomplete(t);return}if(e.startsWith("/")){let t=e.substring(1);if(t.includes(" ")){this.hideAutocomplete();return}this.showPromptAutocomplete(t);return}this.hideAutocomplete();}showAgentAutocomplete(e){this.autocompleteTrigger="@";try{let t=this.projectStateService.getSelectedProjectIdOrThrow();this.agentApiService.getAgentsAutocomplete(t,e).subscribe({next:n=>{this.autocompleteItems=n,this.autocompleteVisible=n.length>0,this.selectedAutocompleteIndex=0;},error:n=>{console.error("[AUTOCOMPLETE] Error loading agents:",n),this.hideAutocomplete();}});}catch(t){console.warn("[AUTOCOMPLETE] No project selected, cannot load agents"),this.hideAutocomplete();}}showPromptAutocomplete(e){this.autocompleteTrigger="/";try{let t=this.projectStateService.getSelectedProjectIdOrThrow();this.promptApiService.getPromptsAutocomplete(t,e).subscribe({next:n=>{this.autocompleteItems=n,this.autocompleteVisible=n.length>0,this.selectedAutocompleteIndex=0;},error:n=>{console.error("[AUTOCOMPLETE] Error loading prompts:",n),this.hideAutocomplete();}});}catch(t){console.warn("[AUTOCOMPLETE] No project selected, cannot load prompts"),this.hideAutocomplete();}}hideAutocomplete(){this.autocompleteVisible=false,this.autocompleteItems=[],this.selectedAutocompleteIndex=0;}selectAutocompleteItem(){let e=this.autocompleteItems[this.selectedAutocompleteIndex];if(!e)return;let t=null;if(this.autocompleteTrigger==="/"){let n=e,o=n.parameterFormat;if(console.log(n),o===void 0)this.message=`/${e.name}`;else if(o==="")this.message=`/${e.name} `;else {this.message=`/${e.name} ${o}`;let r=this.message.indexOf('=""');r!==-1&&(t=r+2);}}else this.message=`@${e.name} `;this.hideAutocomplete(),setTimeout(()=>{if(this.messageInput?.nativeElement)if(this.messageInput.nativeElement.focus(),t!==null)this.messageInput.nativeElement.setSelectionRange(t,t);else {let n=this.message.length;this.messageInput.nativeElement.setSelectionRange(n,n);}},0);}selectAutocompleteItemByClick(e){this.selectedAutocompleteIndex=e,this.selectAutocompleteItem();}getAutocompleteQuery(){return this.message.substring(1).split(" ")[0]??""}getParameterFormat(e){return e.parameterFormat}hasParameterFormat(e){return this.autocompleteTrigger==="/"&&e.parameterFormat!==void 0}scrollSelectedItemIntoView(){setTimeout(()=>{let e=document.querySelector(".autocomplete-popup");if(!e)return;let t=e.querySelector(".autocomplete-item.selected");t&&t.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});},0);}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-chat-textarea"]],viewQuery:function(t,n){if(t&1&&Pg(yi,7)(wi,5),t&2){let o;EC(o=IC())&&(n.messageInput=o.first),EC(o=IC())&&(n.fileInput=o.first);}},hostBindings:function(t,n){t&1&&Rg("paste",function(r){return n.onPaste(r)})("click",function(r){return n.onDocumentClick(r)},dE);},inputs:{isDisabled:"isDisabled",showWelcome:"showWelcome",isThinking:"isThinking",isStarting:"isStarting",isSessionInitializing:"isSessionInitializing"},outputs:{filesPasted:"filesPasted",messageSubmitted:"messageSubmitted",voiceMessageReady:"voiceMessageReady",voiceRecordingToggled:"voiceRecordingToggled",heightChanged:"heightChanged",stopRequested:"stopRequested",textareaFocused:"textareaFocused"},features:[Tu],decls:8,vars:15,consts:[["messageInput",""],["fileInput",""],[1,"chat-input-container"],[1,"recording-indicator"],[1,"autocomplete-popup"],[1,"input-row","grouped-input"],[1,"message-input",3,"ngModelChange","keydown","input","focus","blur","ngModel","placeholder","disabled"],[1,"actions"],[1,"recording-dot"],[1,"transcribing-dot"],["role","option","tabindex","0",1,"autocomplete-item",3,"selected"],["role","option","tabindex","0",1,"autocomplete-item",3,"click","keydown.enter","keydown.space","mouseenter"],[1,"item-name"],[3,"innerHTML"],[1,"parameter-format"],[1,"item-description",3,"innerHTML"],["icon","stop","variant","danger","title","Stop generation",1,"action-btn"],["icon","send","variant","primary",1,"send-btn",3,"title","disabled","hidden","active"],["icon","stop","variant","danger","title","Stop generation",1,"action-btn",3,"action"],["icon","send","variant","primary",1,"send-btn",3,"action","title","disabled"],["icon","mic",1,"voice-btn",3,"action","variant","disabled","title"],["icon","attach_file","variant","default","title","Upload files (images or documents)",1,"upload-btn",3,"action","disabled"],["type","file","multiple","","accept","image/*,application/pdf,.pdf,.doc,.docx,.txt,.md,.json,.yaml,.yml,.csv,.xml,.html",2,"display","none",3,"change"]],template:function(t,n){if(t&1){let o=lC();ws(0,"div",2),Jw(1,Si,3,0,"div",3),Jw(2,Mi,3,0,"div",3),Jw(3,Pi,3,0,"div",4),ws(4,"div",5)(5,"textarea",6,0),tm("ngModelChange",function(d){return If(o),KC(n.message,d)||(n.message=d),wf(d)}),Rg("keydown",function(d){return n.onKeyDown(d)})("input",function(){return n.onInput()})("focus",function(){return If(o),n.isFocused=true,wf(n.textareaFocused.emit())})("blur",function(){return n.isFocused=false}),pl(),VI(),Jw(7,Fi,4,3,"div",7),pl()();}t&2&&(XE(),eC(!n.isVoiceMessageMode&&n.isRecording?1:-1),XE(),eC(!n.isVoiceMessageMode&&n.isTranscribing?2:-1),XE(),eC(n.autocompleteVisible?3:-1),XE(),Ug("focused",n.isFocused)("welcome-mode",n.showWelcome)("is-thinking",n.isThinking)("is-listening",n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),XE(),em("ngModel",n.message),bg("placeholder",n.getPlaceholder())("disabled",n.isDisabled||n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),UI(),XE(2),eC(n.isSessionInitializing?-1:7));},dependencies:[ti$1,Ye,Zn$1,cn,Se$1,ot],styles:['@keyframes _ngcontent-%COMP%_gradientBorderShift{0%{background-position:0 0}50%{background-position:100% 0}to{background-position:0 0}}.chat-input-container[_ngcontent-%COMP%]{flex-shrink:0;width:100%;position:relative}.thinking-progress[_ngcontent-%COMP%]{position:absolute;top:0;left:0;right:0;height:3px;z-index:1}.thinking-progress[_ngcontent-%COMP%] .mdc-linear-progress__bar-inner{border-top-width:3px}.input-row.grouped-input[_ngcontent-%COMP%]{display:flex;align-items:stretch;background:var(--glass-bg);border-radius:16px;padding:0 .15rem 0 1.25rem;position:relative;transition:border-color .2s,box-shadow .2s,background .3s}.input-row[_ngcontent-%COMP%]{position:relative;background:var(--glass-bg, #1e1e1e)!important;background-clip:padding-box}.input-row[_ngcontent-%COMP%]:before{content:"";position:absolute;inset:-2px;border-radius:inherit;background-size:200% 100%;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:xor;mask-composite:exclude;padding:1px;pointer-events:none;z-index:-1;animation:_ngcontent-%COMP%_gradientBorderShift 3s ease-in-out infinite}.input-row.is-listening[_ngcontent-%COMP%]:before{inset:0;-webkit-mask:none;mask:none;padding:0;opacity:.15;z-index:0;background:linear-gradient(90deg,var(--color-error, #ef4444) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-error, #ef4444) 100%);background-size:200% 100%;animation:_ngcontent-%COMP%_gradientBorderShift 2s ease-in-out infinite}.input-row.is-listening[_ngcontent-%COMP%] .message-input[_ngcontent-%COMP%], .input-row.is-listening[_ngcontent-%COMP%] .action-btn[_ngcontent-%COMP%]{position:relative;z-index:1}.input-row.is-thinking[_ngcontent-%COMP%]:before{inset:0;-webkit-mask:none;mask:none;padding:0;opacity:.15;z-index:0;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% 100%;animation:_ngcontent-%COMP%_gradientBorderShift 3s ease-in-out infinite}.input-row.is-thinking[_ngcontent-%COMP%] .message-input[_ngcontent-%COMP%], .input-row.is-thinking[_ngcontent-%COMP%] .action-btn[_ngcontent-%COMP%]{position:relative;z-index:1}.input-row.grouped-input.focused[_ngcontent-%COMP%]:not(.is-thinking):before{background:var(--color-primary);animation:none}.input-row.grouped-input.focused[_ngcontent-%COMP%]:not(.is-thinking){box-shadow:0 0 0 4px #007aff1a}.message-input[_ngcontent-%COMP%]{flex:1;border:none;outline:none;background:transparent!important;box-shadow:none;font-size:1rem;padding:1rem 0;color:var(--color-text);resize:none;field-sizing:content;min-height:36px;max-height:70vh;overflow-y:auto;font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,system-ui,sans-serif;line-height:1.5}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar{width:8px}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--color-text-secondary)}.message-input[_ngcontent-%COMP%]:focus{outline:none;border:none;box-shadow:none}.message-input[_ngcontent-%COMP%]:disabled{background-color:var(--color-bg-secondary);color:var(--color-text-secondary);cursor:not-allowed;opacity:.6}.message-input[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary);transition:opacity .3s ease-in-out}.message-input[_ngcontent-%COMP%]:disabled::placeholder{animation:_ngcontent-%COMP%_thinkingPulsate 2s ease-in-out infinite}@keyframes _ngcontent-%COMP%_thinkingPulsate{0%,to{opacity:.6}50%{opacity:1}}.voice-btn[_ngcontent-%COMP%], .send-btn[_ngcontent-%COMP%], .action-btn[_ngcontent-%COMP%], .upload-btn[_ngcontent-%COMP%]{margin:0}.actions[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-wrap:wrap;justify-content:center}.send-btn[_ngcontent-%COMP%]{transition:opacity .4s,margin-left .4s}.send-btn.active[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{opacity:1}.send-btn[_ngcontent-%COMP%]:not(.active) button[_ngcontent-%COMP%]{opacity:0;margin-left:calc(-.5rem - 36px)}.send-btn[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:hover:not(:disabled){color:#fff;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-primary, #3b82f6) 20%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 80%,var(--color-primary, #3b82f6) 100%);background-size:300% auto;animation:sendButtonGradientShift 6s ease-in-out infinite;box-shadow:0 4px 14px #007aff30;transform:scale(1.2)}.send-btn[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:active:not(:disabled){transform:scale(1.3);box-shadow:0 4px 24px #007aff30}.recording-indicator[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin-top:.2rem;margin-bottom:.2rem;color:var(--color-error, #ff5555);font-size:.9rem;position:absolute;top:-1.5rem}@keyframes _ngcontent-%COMP%_pulse{0%,to{opacity:1}50%{opacity:.5}}.autocomplete-popup[_ngcontent-%COMP%]{position:absolute;bottom:100%;left:0;right:0;margin-bottom:.5rem;background:var(--glass-bg);-webkit-backdrop-filter:var(--glass-backdrop-blur);backdrop-filter:var(--glass-backdrop-blur);border-radius:12px;box-shadow:0 8px 32px #00000026;border:1px solid var(--color-border);max-height:400px;max-width:500px;overflow-y:auto;z-index:100}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar{width:8px}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--color-text-secondary)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%]{padding:.75rem 1rem;cursor:pointer;transition:background .2s;border-left:3px solid transparent}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%]:hover, .autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item.selected[_ngcontent-%COMP%]{background:var(--color-bg-hover)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item.selected[_ngcontent-%COMP%]{border-left-color:var(--color-primary)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%]{font-weight:600;color:var(--color-text);margin-bottom:.25rem;font-family:SF Mono,Monaco,Menlo,Cascadia Code,Consolas,monospace;font-size:.95rem}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%] strong{font-weight:700;color:var(--color-primary);background:var(--color-primary-light, rgba(99, 102, 241, .1));padding:0 2px;border-radius:2px}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%] .parameter-format[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-weight:400;opacity:.7}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-description[_ngcontent-%COMP%]{font-size:.85rem;color:var(--color-text-secondary);line-height:1.3}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-description[_ngcontent-%COMP%] strong{font-weight:700;color:var(--color-primary);background:var(--color-primary-light, rgba(99, 102, 241, .1))}@media print{.thinking-progress[_ngcontent-%COMP%], .action-btn[_ngcontent-%COMP%], .voice-btn[_ngcontent-%COMP%], .send-btn[_ngcontent-%COMP%], .upload-btn[_ngcontent-%COMP%], .recording-indicator[_ngcontent-%COMP%], .autocomplete-popup[_ngcontent-%COMP%]{display:none!important}}'],changeDetection:1})};var Ce=class i{unreadCountSubject=new Tr$1(0);unreadCount$=this.unreadCountSubject.asObservable();constructor(){console.log("[UNREAD] Service initialized");}addUnread(){let t=this.unreadCountSubject.value+1;this.unreadCountSubject.next(t),console.log("[UNREAD] Added unread message, total:",t);}markAllAsRead(){this.unreadCountSubject.value>0&&(this.unreadCountSubject.next(0),console.log("[UNREAD] Marked all messages as read"));}getCurrentCount(){return this.unreadCountSubject.value}reset(){this.unreadCountSubject.next(0),console.log("[UNREAD] Counter reset");}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var at=class i{ATTENTION_EMOJI="\u{1F534}";isSystemActive=false;systemActiveTimer=null;SYSTEM_ACTIVE_TIMEOUT=4e3;unreadService=g(Ce);project=g(P$1);constructor(){this.initializeTitleUpdates();}initializeTitleUpdates(){Ly([this.project.selectedProject$,this.unreadService.unreadCount$]).subscribe(([e,t])=>{this.updateTitle(e?.name??"...",t);});}updateTitle(e,t){let n;this.isSystemActive?n=`\u23F3${t>0?` (${t}) `:" "}${e}`:t>0?n=`${this.ATTENTION_EMOJI} (${t}) ${e}`:n=e,document.title=n,console.log("[TAB-TITLE] Updated to:",n);}setSystemActive(){console.log("[TAB-TITLE] System active - showing hourglass"),this.isSystemActive=true,this.systemActiveTimer&&clearTimeout(this.systemActiveTimer),this.systemActiveTimer=setTimeout(()=>{console.log("[TAB-TITLE] System active timeout - hiding hourglass"),this.isSystemActive=false,this.forceUpdateTitle();},this.SYSTEM_ACTIVE_TIMEOUT),this.forceUpdateTitle();}setSystemInactive(){console.log("[TAB-TITLE] System inactive - hiding hourglass"),this.isSystemActive=false,this.systemActiveTimer&&(clearTimeout(this.systemActiveTimer),this.systemActiveTimer=null),this.forceUpdateTitle();}forceUpdateTitle(){let e=this.project.getSelectedProjectId()??"...",t=this.unreadService.getCurrentCount();this.updateTitle(e,t);}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var st=class i{pendingFirstMessage=null;pendingVoiceMessage=null;setPendingFirstMessage(e){console.log("[FIRST-MESSAGE-STATE] Storing pending first message:",e.substring(0,50)+"..."),this.pendingFirstMessage=e;}consumePendingFirstMessage(){let e=this.pendingFirstMessage;return e?(console.log("[FIRST-MESSAGE-STATE] Consuming pending first message:",e.substring(0,50)+"..."),this.pendingFirstMessage=null):console.log("[FIRST-MESSAGE-STATE] No pending first message to consume"),e}setPendingVoiceMessage(e){console.log("[FIRST-MESSAGE-STATE] Storing pending voice message"),this.pendingVoiceMessage=e;}consumePendingVoiceMessage(){let e=this.pendingVoiceMessage;return e&&(console.log("[FIRST-MESSAGE-STATE] Consuming pending voice message"),this.pendingVoiceMessage=null),e}hasPendingFirstMessage(){return this.pendingFirstMessage!==null||this.pendingVoiceMessage!==null}clear(){this.pendingFirstMessage&&(console.log("[FIRST-MESSAGE-STATE] Clearing pending first message"),this.pendingFirstMessage=null),this.pendingVoiceMessage=null;}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var Ri=(i,e)=>e.label;function Hi(i,e){if(i&1){let t=lC();ws(0,"button",2),Rg("click",function(o){let r=If(t).$implicit,d=gC();return wf(d.executeAction(r,o))}),ws(1,"mat-icon"),GC(2),pl()();}if(i&2){let t=e.$implicit;Tg("title",t.tooltip||t.label),XE(),Tg("aria-label",t.label),XE(),Yg(t.icon);}}var ct=class i{actions=[];executeAction(e,t){t.stopPropagation(),e.action();}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-message-context-menu"]],inputs:{actions:"actions"},decls:3,vars:0,consts:[[1,"context-menu-wrapper"],["mat-icon-button",""],["mat-icon-button","",3,"click"]],template:function(t,n){t&1&&(ws(0,"div",0),rC(1,Hi,3,3,"button",1,Ri),pl()),t&2&&(XE(),oC(n.actions));},dependencies:[qm,Gn$1,wt$1],styles:[".context-menu-wrapper[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center}.context-menu-wrapper[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{transform:scale(.75)}"],changeDetection:1})};var Z=class i{renderer;constructor(){this.renderer=new Ue$1,this.configureRenderer();}configureRenderer(){let e=this.renderer.link.bind(this.renderer);this.renderer.link=t=>{let n=this.isExternalLink(t.href),o=e(t);if(n){o=o.replace("<a ",'<a target="_blank" rel="noopener noreferrer" ');let r=t.title?`${t.text} - ${t.title} (opens in new tab)`:`${t.text} (opens in new tab)`;o=o.replace("<a ",`<a aria-label="${this.escapeHtml(r)}" `),o=o.replace("</a>",'<span class="external-link-icon" aria-hidden="true">\u2197</span></a>');}return o};}isExternalLink(e){if(!e||e.startsWith("/")||e.startsWith("#")||e.startsWith("?"))return false;if(e.startsWith("//"))return true;try{return new URL(e,window.location.href).hostname!==window.location.hostname}catch(t){return false}}escapeHtml(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return e.replace(/[&<>"']/g,n=>t[n]||n)}parse(e){return B(this,null,function*(){let t=yield x$2.parse(e,{renderer:this.renderer,breaks:true,gfm:true});return is.sanitize(t,{ADD_TAGS:["span"],ADD_ATTR:["aria-hidden","aria-label","target","rel"],ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))/i})})}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var Vi=i=>({"user-message-wrapper":i});function Li(i,e){if(i&1&&(ws(0,"div",4)(1,"div",8),GC(2),pl()()),i&2){let t=gC(2);XE(2),vl(" ",t.message.speaker," ");}}function zi(i,e){if(i&1&&(ws(0,"time",6),GC(1),pl()),i&2){let t=gC(2);XE(),Yg(t.formattedTimestamp);}}function Ni(i,e){if(i&1&&(ws(0,"div",7),Sg(1,"app-message-context-menu",9),pl()),i&2){let t=gC(2);XE(),bg("actions",t.actions);}}function $i(i,e){if(i&1&&(Jw(0,Li,3,1,"div",4),Sg(1,"div",5),Jw(2,zi,2,1,"time",6),Jw(3,Ni,2,1,"div",7)),i&2){let t=gC();eC(t.shouldShowSpeaker?0:-1),XE(),bg("innerHTML",t.renderedContent,aE),XE(),eC(t.formattedTimestamp?2:-1),XE(),eC(t.isLongMessage&&t.shouldShowActions&&t.message.role==="assistant"?3:-1);}}function ji(i,e){if(i&1&&Sg(0,"span",12),i&2){let t=gC(3);bg("innerHTML",t.renderedContent,aE);}}function Ui(i,e){if(i&1&&(ws(0,"span",13),GC(1),pl()),i&2){let t=gC(3);XE(),Yg(t.collapsedErrorText);}}function Bi(i,e){i&1&&GC(0," Show less \u25B2 ");}function Wi(i,e){i&1&&GC(0," Show more \u25BC ");}function qi(i,e){if(i&1){let t=lC();ws(0,"div",10),Jw(1,ji,1,1,"span",12)(2,Ui,2,1,"span",13),ws(3,"button",14),Rg("click",function(){If(t);let o=gC(2);return wf(o.toggleErrorExpanded())}),Jw(4,Bi,1,0)(5,Wi,1,0),pl()();}if(i&2){let t=gC(2);XE(),eC(t.isErrorExpanded()?1:2),XE(3),eC(t.isErrorExpanded()?4:5);}}function Yi(i,e){i&1&&GC(0," \u25B2 ");}function Gi(i,e){i&1&&GC(0," \u25BC ");}function Qi(i,e){if(i&1&&(ws(0,"a",17),GC(1,"view"),pl()),i&2){let t=gC(3);bg("href",t.eventLink,yh);}}function Xi(i,e){if(i&1&&(ws(0,"pre",18),GC(1),pl()),i&2){let t=gC(3);XE(),Yg(t.message.fullContent);}}function Ki(i,e){if(i&1){let t=lC();ws(0,"div",15),Sg(1,"span",12),ws(2,"button",16),Rg("click",function(){If(t);let o=gC(2);return wf(o.toggleTechnicalExpanded())}),Jw(3,Yi,1,0)(4,Gi,1,0),pl(),Jw(5,Qi,2,1,"a",17),pl(),Jw(6,Xi,2,1,"pre",18);}if(i&2){let t=gC(2);XE(),bg("innerHTML",t.renderedContent,aE),XE(2),eC(t.isTechnicalExpanded()?3:4),XE(2),eC(t.eventLink?5:-1),XE(),eC(t.isTechnicalExpanded()?6:-1);}}function Ji(i,e){if(i&1&&(ws(0,"a",17),GC(1,"view"),pl()),i&2){let t=gC(3);bg("href",t.eventLink,yh);}}function Zi(i,e){if(i&1&&(ws(0,"div",11),Sg(1,"span",12),Jw(2,Ji,2,1,"a",17),pl()),i&2){let t=gC(2);XE(),bg("innerHTML",t.renderedContent,aE),XE(),eC(t.eventLink?2:-1);}}function eo(i,e){if(i&1&&Jw(0,qi,6,2,"div",10)(1,Ki,7,4)(2,Zi,3,2,"div",11),i&2){let t=gC();eC(t.message.type==="error"&&t.isLongError?0:t.message.type==="technical"&&t.message.fullContent?1:2);}}function to(i,e){if(i&1&&(ws(0,"div",2),Sg(1,"app-message-context-menu",9),pl()),i&2){let t=gC();XE(),bg("actions",t.actions);}}function no(i,e){if(i&1&&(ws(0,"div",3),Sg(1,"app-message-context-menu",9),pl()),i&2){let t=gC();XE(),bg("actions",t.actions);}}var ve=class i{destroy$=new ue;message;canDelete=true;isOtherUser=false;containingThreadId;copyRequested=new vt$1;deleteRequested=new vt$1;renderedContent="";shouldHideTechnical=false;shouldHideWarning=false;isErrorExpanded=Gi$1(false);static ERROR_COLLAPSE_LINE_THRESHOLD=5;isTechnicalExpanded=Gi$1(false);sanitizer=g(bS);notificationService=g(s);preferencesService=g(L);projectState=g(P$1);threadState=g(U);markdownService=g(Z);get messageClasses(){return {[this.message.role]:true,[this.message.type]:true,"hidden-technical":this.shouldHideTechnical&&this.message.type==="technical","hidden-warning":this.shouldHideWarning&&this.message.type==="warning","other-user":this.isOtherUser}}ngOnInit(){return B(this,null,function*(){yield this.renderMarkdown(),this.preferencesService.hideTechnicalMessages$.pipe(wd(this.destroy$)).subscribe(e=>{this.shouldHideTechnical=e;}),this.preferencesService.hideWarningMessages$.pipe(wd(this.destroy$)).subscribe(e=>{this.shouldHideWarning=e;}),this.shouldHideTechnical=this.preferencesService.getHideTechnicalMessages(),this.shouldHideWarning=this.preferencesService.getHideWarningMessages();})}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete();}get shouldShowSpeaker(){return this.message.role==="user"?this.isOtherUser||this.message.speaker.startsWith("@"):this.message.role==="assistant"}get shouldShowActions(){return this.message.role==="user"||this.message.role==="assistant"}get isSimplified(){return this.message.role!=="user"&&this.message.role!=="assistant"}datePipe=g(kb);get formattedTimestamp(){if(this.message.role!=="user"||!this.message.timestamp)return null;let e=new Date().toDateString()===this.message.timestamp.toDateString();return this.datePipe.transform(this.message.timestamp,e?"HH:mm":"dd/MM HH:mm")}get isLongError(){return this.message.type!=="error"?false:this.extractTextContent().split(/\n|\\n/).length>i.ERROR_COLLAPSE_LINE_THRESHOLD}get collapsedErrorText(){return this.extractTextContent().split(/\n|\\n/).slice(0,i.ERROR_COLLAPSE_LINE_THRESHOLD).join(`
4
4
  `)+"\u2026"}toggleErrorExpanded(){this.isErrorExpanded.update(e=>!e);}toggleTechnicalExpanded(){this.isTechnicalExpanded.update(e=>!e);}get isLongMessage(){let e=this.extractTextContent();return e.length>1e3||e.split(`
5
5
  `).length>20}get actions(){let e=[];return this.message.role==="user"&&this.canDelete&&e.push({icon:"delete",label:"Delete from here",tooltip:"Delete this message and all following messages",action:()=>this.onDelete(),destructive:true}),e.push({icon:"content_copy",label:"Copy message",tooltip:"Copy message content to clipboard",action:()=>this.onCopy()}),e}get eventLink(){if(!this.message.eventId)return null;let e=this.projectState.getSelectedProjectId();if(!e)return null;let t=this.containingThreadId??this.threadState.getSelectedThreadId();return t?`/api/projects/${e}/threads/${t}/messages/${encodeURIComponent(this.message.eventId)}/formatted`:null}renderMarkdown(){return B(this,null,function*(){try{let e=yield this.renderRichContent(this.message.content);this.renderedContent=this.sanitizer.bypassSecurityTrustHtml(e);}catch(e){console.error("Error parsing rich content:",e);let t=this.extractTextContent();this.renderedContent=this.sanitizer.bypassSecurityTrustHtml(t);}})}renderRichContent(e){return B(this,null,function*(){let t=[];for(let n of e)if(n.type==="text"){let o=yield this.markdownService.parse(n.content);t.push(`<div class="text-part">${o}</div>`);}else if(n.type==="image"){let o=`data:${n.mimeType};base64,${n.content}`,r=n.source||"Image",d=`
6
6
  <div class="image-content">
@@ -28,7 +28,7 @@ This action cannot be undone once you post another message.`)&&(console.log("[CH
28
28
 
29
29
  `)}extractPartialText(e){return e.split(`
30
30
  `).filter(d=>d.trim().length>0).reduce((d,v)=>{if(d.paragraphs>=3)return d;let y=v.length>80?1:0;return {paragraphs:d.paragraphs+y,text:d.text+(d.text?`
31
- `:"")+v}},{paragraphs:0,text:""}).text||e}renderStreamingText(){return B(this,null,function*(){if(!this.streamingText){this.renderedStreamingText="";return}try{let e=yield this.markdownService.parse(this.streamingText);this.renderedStreamingText=this.sanitizer.bypassSecurityTrustHtml(e);}catch(e){console.error("[CHAT-HISTORY] Error rendering streaming text markdown:",e),this.renderedStreamingText=this.sanitizer.bypassSecurityTrustHtml(this.streamingText);}})}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-chat-history"]],hostBindings:function(t,n){t&1&&Rg("scroll",function(){return n.onScroll()});},inputs:{messages:"messages",streamingText:"streamingText",isThinking:"isThinking",currentUsername:"currentUsername"},outputs:{copyRequested:"copyRequested",stopRequested:"stopRequested"},features:[Tu],decls:6,vars:3,consts:[[1,"chat-history"],[1,"streaming-message","message","assistant"],[3,"runningDelegations"],["mat-fab","","color","primary","title","Go to bottom",1,"go-to-bottom-btn"],[3,"subThreadId","agentName"],[3,"message","canDelete","isOtherUser"],[3,"copyRequested","deleteRequested","message","canDelete","isOtherUser"],[1,"content","markdown-content",3,"innerHTML"],["mat-fab","","color","primary","title","Go to bottom",1,"go-to-bottom-btn",3,"click"],["fontSet","material-icons-outlined"]],template:function(t,n){t&1&&(ws(0,"div",0),rC(1,xo,2,1,null,null,Co),Jw(3,yo,2,1,"div",1),Jw(4,wo,1,1,"app-thinking-loader",2),Jw(5,To,3,0,"button",3),pl()),t&2&&(XE(),oC(n.messages),XE(2),eC(n.streamingText?3:-1),XE(),eC(n.isThinking?4:-1),XE(),eC(n.showGoToBottom?5:-1));},dependencies:[ve,wt$1,dt,fr$1,lt],styles:[".streaming-message.assistant[_ngcontent-%COMP%]{background:transparent;border:none;box-shadow:none;border-radius:0;margin-left:0;margin-right:auto;padding:.5rem 0;width:100%;max-width:none;min-width:0}.streaming-message[_ngcontent-%COMP%] .content[_ngcontent-%COMP%]{color:var(--color-text);line-height:1.5}.go-to-bottom-btn[_ngcontent-%COMP%]{position:fixed!important;bottom:30%!important;right:1rem!important;z-index:1000!important}@media(max-width:768px){.go-to-bottom-btn[_ngcontent-%COMP%]{width:40px!important;height:40px!important;right:.75rem!important}.go-to-bottom-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}}@media print{[_nghost-%COMP%]{display:block!important;height:auto!important;max-height:none!important;overflow:visible!important;position:static!important}.chat-history[_ngcontent-%COMP%]{display:block!important;height:auto!important;max-height:none!important;overflow:visible!important;position:static!important}.go-to-bottom-btn[_ngcontent-%COMP%]{display:none!important}}"],changeDetection:1})};var So=["buttonContainer"],Mo=["freeTextInput"],Eo=(i,e)=>e.value;function Oo(i,e){i&1&&(ws(0,"mat-icon",10),GC(1,"keyboard_return"),pl());}function Po(i,e){if(i&1){let t=lC();ws(0,"button",8),Rg("click",function(){let o=If(t).$implicit,r=gC(2);return wf(r.onOptionClick(o.value))}),ws(1,"span",9),GC(2),pl(),Jw(3,Oo,2,0,"mat-icon",10),pl();}if(i&2){let t=e.$implicit,n=e.$index,o=gC(2);Ug("highlighted",n===o.highlightedIndex),bg("disabled",t.disabled)("id","choice-option-"+n),Tg("aria-selected",n===o.highlightedIndex),XE(2),Yg(t.label),XE(),eC(n===o.highlightedIndex?3:-1);}}function ko(i,e){if(i&1){let t=lC();ws(0,"div",6)(1,"span",11),GC(2,"Or type your own answer:"),pl(),ws(3,"div",12)(4,"input",13,1),tm("ngModelChange",function(o){If(t);let r=gC(2);return KC(r.freeTextValue,o)||(r.freeTextValue=o),wf(o)}),Rg("keydown",function(o){If(t);let r=gC(2);return wf(r.onFreeTextKeyDown(o))}),pl(),VI(),ws(6,"button",14),Rg("click",function(){If(t);let o=gC(2);return wf(o.onFreeTextSubmit())}),ws(7,"mat-icon"),GC(8,"send"),pl()()()();}if(i&2){let t=gC(2);XE(4),em("ngModel",t.freeTextValue),UI(),XE(2),bg("disabled",!t.freeTextValue.trim());}}function Io(i,e){if(i&1&&(ws(0,"div",7)(1,"mat-icon"),GC(2,"search"),pl(),ws(3,"span"),GC(4),pl()()),i&2){let t=gC(2);XE(4),Yg(t.searchText);}}function Do(i,e){if(i&1){let t=lC();ws(0,"div",2),Sg(1,"div",3),aT(2,"async"),ws(3,"div",4,0),Rg("keydown",function(o){If(t);let r=gC();return wf(r.onKeyDown(o))}),rC(5,Po,4,7,"button",5,Eo),pl(),Jw(7,ko,9,2,"div",6),Jw(8,Io,5,1,"div",7),pl();}if(i&2){let t=gC();XE(),bg("innerHTML",uT(2,4,t.renderedLabel$),aE),XE(2),Tg("aria-activedescendant","choice-option-"+t.highlightedIndex),XE(2),oC(t.options),XE(2),eC(t.allowFreeText?7:-1),XE(),eC(t.searchText?8:-1);}}var pt=class i{options=[];allowFreeText=false;set labelHtml(e){typeof e=="object"?this.renderedLabelSubject.next(e):this.renderLabelMarkdown(e);}isVisible=false;choiceSelected=new vt$1;buttonContainer;freeTextInput;highlightedIndex=0;searchText="";freeTextValue="";searchTimeout;destroy$=new ue;renderedLabelSubject=new Tr$1("");renderedLabel$=this.renderedLabelSubject.asObservable();sanitizer=g(bS);markdownService=g(Z);ngOnDestroy(){this.renderedLabelSubject.complete(),this.destroy$.next(),this.destroy$.complete(),this.searchTimeout&&clearTimeout(this.searchTimeout);}ngAfterViewInit(){this.isVisible&&this.buttonContainer&&setTimeout(()=>this.focusContainer(),100);}ngOnChanges(e){e.isVisible&&e.isVisible.currentValue&&!e.isVisible.previousValue&&(this.highlightedIndex=0,setTimeout(()=>this.focusContainer(),150)),e.options&&!e.options.firstChange&&(this.highlightedIndex=0,this.searchText="",this.freeTextValue="");}focusContainer(){this.buttonContainer?.nativeElement&&this.buttonContainer.nativeElement.focus();}onKeyDown(e){if(this.options.filter(n=>!n.disabled).length!==0)switch(e.key){case "ArrowDown":e.preventDefault(),this.moveHighlight(1);break;case "ArrowUp":e.preventDefault(),this.moveHighlight(-1);break;case "Enter":case " ":e.preventDefault(),this.selectHighlighted();break;case "Home":e.preventDefault(),this.highlightFirst();break;case "End":e.preventDefault(),this.highlightLast();break;case "Escape":e.preventDefault();break;default:e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.handleTypeAhead(e.key);break}}moveHighlight(e){let t=this.options.map((r,d)=>({opt:r,idx:d})).filter(({opt:r})=>!r.disabled).map(({idx:r})=>r);if(t.length===0)return;let o=t.findIndex(r=>r===this.highlightedIndex)+e;if(o>=0&&o<t.length){let r=t[o];r!==void 0&&(this.highlightedIndex=r,this.scrollToHighlighted());}else if(e===1&&o>=t.length){let r=t[0];r!==void 0&&(this.highlightedIndex=r,this.scrollToHighlighted());}else if(e===-1&&o<0){let r=t[t.length-1];r!==void 0&&(this.highlightedIndex=r,this.scrollToHighlighted());}}highlightFirst(){let e=this.options.findIndex(t=>!t.disabled);e>=0&&(this.highlightedIndex=e,this.scrollToHighlighted());}highlightLast(){let e=this.options.map((t,n)=>({opt:t,idx:n})).filter(({opt:t})=>!t.disabled).map(({idx:t})=>t);if(e.length>0){let t=e[e.length-1];t!==void 0&&(this.highlightedIndex=t,this.scrollToHighlighted());}}scrollToHighlighted(){setTimeout(()=>{let e=document.getElementById("choice-option-"+this.highlightedIndex);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"});},0);}selectHighlighted(){let e=this.options[this.highlightedIndex];e&&!e.disabled&&this.onOptionClick(e.value);}handleTypeAhead(e){this.searchText+=e.toLowerCase();let t=this.options.findIndex(n=>!n.disabled&&n.label.toLowerCase().startsWith(this.searchText));t>=0&&(this.highlightedIndex=t,this.scrollToHighlighted()),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout(()=>{this.searchText="";},1e3);}onOptionClick(e){this.choiceSelected.emit(e);}onFreeTextSubmit(){let e=this.freeTextValue.trim();e&&(this.freeTextValue="",this.choiceSelected.emit(e));}onFreeTextKeyDown(e){e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.onFreeTextSubmit());}renderLabelMarkdown(e){return B(this,null,function*(){if(!e){this.renderedLabelSubject.next(this.sanitizer.bypassSecurityTrustHtml(""));return}try{let t=yield this.markdownService.parse(e);this.renderedLabelSubject.next(this.sanitizer.bypassSecurityTrustHtml(t));}catch(t){console.error("[CHOICE-SELECT] Error parsing label markdown:",t),this.renderedLabelSubject.next(this.sanitizer.bypassSecurityTrustHtml(e));}})}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-choice-select"]],viewQuery:function(t,n){if(t&1&&Pg(So,5)(Mo,5),t&2){let o;EC(o=IC())&&(n.buttonContainer=o.first),EC(o=IC())&&(n.freeTextInput=o.first);}},inputs:{options:"options",allowFreeText:"allowFreeText",labelHtml:"labelHtml",isVisible:"isVisible"},outputs:{choiceSelected:"choiceSelected"},features:[Tu],decls:1,vars:1,consts:[["buttonContainer",""],["freeTextInput",""],[1,"choice-container"],[1,"choice-label",3,"innerHTML"],["role","listbox","tabindex","0",1,"choice-buttons",3,"keydown"],["type","button","role","option",1,"choice-button",3,"highlighted","disabled","id"],[1,"free-text-section"],[1,"search-indicator"],["type","button","role","option",1,"choice-button",3,"click","disabled","id"],[1,"choice-button-label"],[1,"choice-button-icon"],[1,"free-text-hint"],[1,"free-text-input-row"],["type","text","placeholder","Type a custom answer\u2026","aria-label","Custom answer",1,"free-text-input",3,"ngModelChange","keydown","ngModel"],["type","button","aria-label","Send custom answer",1,"free-text-send-btn",3,"click","disabled"]],template:function(t,n){t&1&&Jw(0,Do,9,6,"div",2),t&2&&eC(n.isVisible?0:-1);},dependencies:[yt$1,wt$1,ti$1,Ye,Zn$1,cn,xb],styles:[".choice-container[_ngcontent-%COMP%]{width:100%;display:flex;flex-direction:column;gap:1rem}.choice-label[_ngcontent-%COMP%]{display:block;font-weight:500;color:var(--color-text);font-size:1rem;line-height:1.5}.choice-label[_ngcontent-%COMP%] p{margin:0 0 .5rem}.choice-label[_ngcontent-%COMP%] p:last-child{margin-bottom:0}.choice-label[_ngcontent-%COMP%] code{background:var(--color-code-bg);padding:.2em .4em;border-radius:4px;font-family:monospace;font-size:.9em}.choice-label[_ngcontent-%COMP%] strong{font-weight:600}.choice-buttons[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem;max-height:400px;overflow-y:auto;padding:.5rem;background:var(--color-background);border:2px solid var(--color-border);border-radius:12px;outline:none}.choice-buttons[_ngcontent-%COMP%]:focus-within{border-color:var(--color-primary);box-shadow:0 0 0 3px #007aff1a}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar{width:8px}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:var(--color-background);border-radius:4px}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--color-text-secondary)}.choice-button[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;width:100%;padding:.75rem 1rem;border:1px solid var(--color-border);border-radius:8px;background:var(--color-background);color:var(--color-text);font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,system-ui,sans-serif;font-size:1rem;text-align:left;cursor:pointer;transition:all .2s ease}.choice-button[_ngcontent-%COMP%]:hover:not(:disabled):not(.highlighted){background:var(--color-bg-hover);border-color:var(--color-primary);transform:translate(2px)}.choice-button.highlighted[_ngcontent-%COMP%]{background:var(--color-primary);color:#fff;border-color:var(--color-primary);box-shadow:0 2px 8px #007aff4d}.choice-button.highlighted[_ngcontent-%COMP%] .choice-button-icon[_ngcontent-%COMP%]{color:#fff}.choice-button[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.choice-button[_ngcontent-%COMP%]:focus{outline:none}.choice-button-label[_ngcontent-%COMP%]{flex:1;line-height:1.5}.choice-button-icon[_ngcontent-%COMP%]{flex-shrink:0;margin-left:.5rem;font-size:1.2rem;width:1.2rem;height:1.2rem}.free-text-section[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.free-text-hint[_ngcontent-%COMP%]{font-size:.85rem;color:var(--color-text-secondary);font-style:italic}.free-text-input-row[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:center}.free-text-input[_ngcontent-%COMP%]{flex:1;padding:.625rem .875rem;border:1px solid var(--color-border);border-radius:8px;background:var(--color-background);color:var(--color-text);font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,system-ui,sans-serif;font-size:1rem;outline:none;transition:border-color .2s ease,box-shadow .2s ease}.free-text-input[_ngcontent-%COMP%]:focus{border-color:var(--color-primary);box-shadow:0 0 0 3px #007aff1a}.free-text-input[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary);opacity:.7}.free-text-send-btn[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;flex-shrink:0;border:none;border-radius:8px;background:var(--color-primary);color:#fff;cursor:pointer;transition:background .2s ease,opacity .2s ease}.free-text-send-btn[_ngcontent-%COMP%]:hover:not(:disabled){opacity:.9}.free-text-send-btn[_ngcontent-%COMP%]:disabled{opacity:.4;cursor:not-allowed}.free-text-send-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.2rem;width:1.2rem;height:1.2rem}.search-indicator[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.5rem 1rem;background:var(--color-primary);color:#fff;border-radius:8px;font-size:.9rem;font-weight:500;animation:_ngcontent-%COMP%_fadeIn .2s ease}.search-indicator[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1rem;width:1rem;height:1rem;color:#fff}@keyframes _ngcontent-%COMP%_fadeIn{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@media(max-width:480px){.choice-container[_ngcontent-%COMP%]{gap:.75rem}.choice-label[_ngcontent-%COMP%]{font-size:.95rem}.choice-buttons[_ngcontent-%COMP%]{max-height:300px;gap:.375rem}.choice-button[_ngcontent-%COMP%]{font-size:.95rem;padding:.625rem .875rem}}@media print{.choice-buttons[_ngcontent-%COMP%]{max-height:none;overflow:visible}.search-indicator[_ngcontent-%COMP%]{display:none!important}}"],changeDetection:1})};function Ao(i,e){if(i&1){let t=lC();ws(0,"div",0)(1,"div",1)(2,"mat-icon"),GC(3,"lock_open"),pl()(),ws(4,"div",2)(5,"p",3),GC(6,"Authorization required"),pl(),ws(7,"p",4)(8,"strong"),GC(9),pl(),GC(10," needs your permission to continue. "),pl()(),ws(11,"div",5)(12,"button",6),Rg("click",function(){let o=If(t),r=gC();return wf(r.onCancel(o))}),GC(13,"Cancel"),pl(),ws(14,"button",7),Rg("click",function(){let o=If(t),r=gC();return wf(r.onAuthorize(o))}),ws(15,"mat-icon"),GC(16,"open_in_new"),pl(),GC(17," Authorize "),pl()()();}i&2&&(XE(9),Yg(e.integrationName));}var gt=class i{oauthService=g(O);pendingRequest=F(this.oauthService.pendingRequest$,{initialValue:null});onAuthorize(e){this.oauthService.openPopup(e);}onCancel(e){this.oauthService.cancelRequest(e);}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-oauth-request-panel"]],decls:1,vars:1,consts:[[1,"oauth-panel"],[1,"oauth-icon"],[1,"oauth-content"],[1,"oauth-title"],[1,"oauth-description"],[1,"oauth-actions"],["type","button",1,"oauth-btn","oauth-btn--cancel",3,"click"],["type","button",1,"oauth-btn","oauth-btn--authorize",3,"click"]],template:function(t,n){if(t&1&&Jw(0,Ao,18,1,"div",0),t&2){let o;eC((o=n.pendingRequest())?0:-1,o);}},dependencies:[yt$1,wt$1],styles:[".oauth-panel[_ngcontent-%COMP%]{display:flex;align-items:center;gap:1rem;padding:1rem;border:1px solid var(--color-border);border-radius:12px;background:var(--color-background);width:100%}@media(max-width:480px){.oauth-panel[_ngcontent-%COMP%]{flex-direction:column;align-items:flex-start}}.oauth-icon[_ngcontent-%COMP%]{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;border-radius:50%;background:var(--color-primary);color:#fff}.oauth-icon[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.25rem;width:1.25rem;height:1.25rem}.oauth-content[_ngcontent-%COMP%]{flex:1;min-width:0}.oauth-title[_ngcontent-%COMP%]{margin:0 0 .25rem;font-weight:600;font-size:.95rem;color:var(--color-text)}.oauth-description[_ngcontent-%COMP%]{margin:0;font-size:.875rem;color:var(--color-text-secondary)}.oauth-actions[_ngcontent-%COMP%]{display:flex;gap:.5rem;flex-shrink:0}.oauth-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;padding:.5rem 1rem;border-radius:8px;border:1px solid var(--color-border);font-size:.9rem;font-family:inherit;cursor:pointer;transition:all .2s ease}.oauth-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1rem;width:1rem;height:1rem}.oauth-btn--cancel[_ngcontent-%COMP%]{background:var(--color-background);color:var(--color-text-secondary)}.oauth-btn--cancel[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover);color:var(--color-text)}.oauth-btn--authorize[_ngcontent-%COMP%]{background:var(--color-primary);color:#fff;border-color:var(--color-primary)}.oauth-btn--authorize[_ngcontent-%COMP%]:hover{opacity:.9}"]})};var ut=class i{http=g(py);projectState=g(P$1);threadState=g(U);getBaseUrl(){return `/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/threads/${this.threadState.getSelectedThreadIdOrThrow()}/files`}uploadFile(e){let t=this.projectState.getSelectedProjectIdOrThrow(),n=this.threadState.getSelectedThreadIdOrThrow();return new R(o=>{let r=new FileReader;r.onload=()=>{let v=r.result.split(",")[1];this.http.post(`/api/projects/${t}/threads/${n}/upload`,{content:v,mimeType:e.type||"application/octet-stream",filename:e.name}).subscribe({next:y=>{o.next({success:y.success,filename:y.filename}),o.complete();},error:y=>o.error(y)});},r.onerror=()=>o.error(new Error("Failed to read file")),r.readAsDataURL(e);})}listFiles(){return this.http.get(this.getBaseUrl()).pipe(re(e=>e.files))}downloadFile(e){let t=encodeURIComponent(e);return this.http.get(`${this.getBaseUrl()}/${t}`,{responseType:"blob"})}deleteFile(e){let t=encodeURIComponent(e);return this.http.delete(`${this.getBaseUrl()}/${t}`)}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var ye=class i{fileApi=g(ut);eventStream=g(fe);filesSignal=Gi$1([]);isLoadingSignal=Gi$1(false);currentProjectSignal=Gi$1(null);currentThreadSignal=Gi$1(null);files=mT(()=>this.filesSignal());isLoading=mT(()=>this.isLoadingSignal());fileCount=mT(()=>this.filesSignal().length);constructor(){this.subscribeToFileEvents();}initializeForThread(e,t){this.currentProjectSignal.set(e),this.currentThreadSignal.set(t),this.refreshFileList();}clear(){this.filesSignal.set([]),this.currentProjectSignal.set(null),this.currentThreadSignal.set(null);}refreshFileList(){this.isLoadingSignal.set(true),this.fileApi.listFiles().subscribe({next:e=>{let t=e.map(n=>x$1(w$1({},n),{lastModified:new Date(n.lastModified)})).sort((n,o)=>o.lastModified.getTime()-n.lastModified.getTime());this.filesSignal.set(t),this.isLoadingSignal.set(false);},error:e=>{console.error("[FILE_EXCHANGE_STATE] Error loading files:",e),this.isLoadingSignal.set(false);}});}uploadFile(e){return B(this,null,function*(){return new Promise(t=>{this.fileApi.uploadFile(e).subscribe({next:()=>{this.refreshFileList(),t({success:true});},error:n=>{console.error("[FILE_EXCHANGE_STATE] Upload error:",n),t({success:false,error:n.message||"Upload failed"});}});})})}downloadAllFiles(){let e=this.filesSignal();if(e.length===0){console.warn("[FILE_EXCHANGE_STATE] No files to download");return}e.forEach((t,n)=>{setTimeout(()=>{this.downloadFile(t.filename);},n*300);});}downloadFile(e){this.fileApi.downloadFile(e).subscribe({next:t=>{let n=window.URL.createObjectURL(t),o=document.createElement("a");o.href=n,o.download=e,o.click(),window.URL.revokeObjectURL(n);},error:t=>{console.error("[FILE_EXCHANGE_STATE] Download error:",t);}});}deleteFile(e){return B(this,null,function*(){return new Promise(t=>{this.fileApi.deleteFile(e).subscribe({next:()=>{this.refreshFileList(),t({success:true});},error:n=>{console.error("[FILE_EXCHANGE_STATE] Delete error:",n),t({success:false,error:n.message||"Delete failed"});}});})})}subscribeToFileEvents(){this.eventStream.events$.pipe(kt(e=>e instanceof z),U$1()).subscribe(e=>{this.handleFileEvent(e);});}handleFileEvent(e){let t=this.filesSignal();switch(e.operation){case "created":{let n=e.timestamp,o=e.timestamp.lastIndexOf("-");if(o>0){let d=e.timestamp.substring(o+1);d.length===5&&/^[a-z0-9]+$/.test(d)&&(n=e.timestamp.substring(0,o));}let r={filename:e.filename,size:e.size||0,lastModified:new Date(n)};this.filesSignal.set([r,...t]);break}case "updated":{let n=t.filter(y=>y.filename!==e.filename),o=t.find(y=>y.filename===e.filename),r=e.timestamp,d=e.timestamp.lastIndexOf("-");if(d>0){let y=e.timestamp.substring(d+1);y.length===5&&/^[a-z0-9]+$/.test(y)&&(r=e.timestamp.substring(0,d));}let v={filename:e.filename,size:e.size||o?.size||0,lastModified:new Date(r)};this.filesSignal.set([v,...n]);break}case "deleted":{let n=t.filter(o=>o.filename!==e.filename);this.filesSignal.set(n);break}}}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};function Fo(i,e){if(i&1&&Sg(0,"div",1),i&2){let t=gC();bg("innerHTML",t.renderedContent,aE);}}function Ro(i,e){if(i&1&&Sg(0,"iframe",2),i&2){let t=gC();bg("srcdoc",t.content,aE);}}function Ho(i,e){if(i&1&&(ws(0,"pre",3),GC(1),pl()),i&2){let t=gC();XE(),Yg(t.content);}}var ht=class i{content="";format="text";renderedContent="";sanitizer=g(bS);markdownService=g(Z);ngOnChanges(e){(e.content||e.format)&&this.renderContent();}renderContent(){this.format==="markdown"?this.renderMarkdown():this.format==="json"&&this.formatJson();}renderMarkdown(){return B(this,null,function*(){try{let e=yield this.markdownService.parse(this.content);this.renderedContent=this.sanitizer.bypassSecurityTrustHtml(e);}catch(e){console.error("[CONTENT_RENDERER] Error rendering markdown:",e),this.content=this.content;}})}formatJson(){try{let e=JSON.parse(this.content);this.content=JSON.stringify(e,null,2);}catch(e){console.error("[CONTENT_RENDERER] Error formatting JSON:",e);}}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-content-renderer"]],inputs:{content:"content",format:"format"},features:[Tu],decls:4,vars:2,consts:[[1,"content-renderer",3,"ngClass"],[1,"markdown-content",3,"innerHTML"],["sandbox","allow-same-origin",1,"html-viewer",3,"srcdoc"],[1,"code-content"]],template:function(t,n){t&1&&(ws(0,"div",0),Jw(1,Fo,1,1,"div",1)(2,Ro,1,1,"iframe",2)(3,Ho,2,1,"pre",3),pl()),t&2&&(bg("ngClass","format-"+n.format),XE(),eC(n.format==="markdown"?1:n.format==="html"?2:3));},dependencies:[qm,Sb],styles:[".content-renderer[_ngcontent-%COMP%]{width:100%;height:100%;overflow:auto;padding:1rem}.markdown-content[_ngcontent-%COMP%]{line-height:1.6;color:var(--color-text)}.code-content[_ngcontent-%COMP%]{font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:.9rem;line-height:1.5;margin:0;white-space:pre-wrap;word-wrap:break-word;color:var(--color-text)}.format-json[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%]{color:var(--color-code-text, #d63384)}.format-yaml[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%], .format-text[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%]{color:var(--color-text)}.html-viewer[_ngcontent-%COMP%]{width:100%;height:100%;min-height:400px;border:1px solid var(--color-border);border-radius:8px;background:#fff}"],changeDetection:1})};var we=class i{http=g(py);MAX_FILE_SIZE=20*1024*1024;isViewable(e){return e<=this.MAX_FILE_SIZE}isFormatViewable(e){let t=e.split(".").pop()?.toLowerCase();return !(t&&["pdf","png","jpg","jpeg","gif","webp","zip","tar","gz","exe","bin","doc","docx","xls","xlsx","ppt","pptx"].includes(t))}detectFormat(e){switch(e.split(".").pop()?.toLowerCase()){case "md":return "markdown";case "json":return "json";case "yaml":case "yml":return "yaml";case "html":case "htm":return "html";default:return "text"}}loadFileContent(e,t,n){let o=`/api/projects/${e}/threads/${t}/files/${encodeURIComponent(n)}`,r=this.detectFormat(n);return this.http.get(o,{responseType:"text",observe:"response"}).pipe(re(d=>{let v=d.body||"",y=new Blob([v]).size;return {content:v,format:r,filename:n,size:y}}),ya(d=>(console.error("[CONTENT_VIEWER] Error loading file:",n,d),By(()=>new Error(`Failed to load file: ${d.message||"Unknown error"}`)))))}formatSize(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};function Vo(i,e){if(i&1){let t=lC();ws(0,"button",12),Rg("click",function(){If(t);let o=gC();return wf(o.download())}),ws(1,"mat-icon"),GC(2,"download"),pl()();}}function Lo(i,e){i&1&&(ws(0,"div",9),Sg(1,"mat-spinner",13),ws(2,"p"),GC(3,"Loading file content..."),pl()());}function zo(i,e){if(i&1){let t=lC();ws(0,"div",10)(1,"mat-icon",14),GC(2,"error_outline"),pl(),ws(3,"p",15),GC(4),pl(),ws(5,"button",16),Rg("click",function(){If(t);let o=gC();return wf(o.download())}),ws(6,"mat-icon"),GC(7,"download"),pl(),GC(8," Download instead "),pl()();}if(i&2){let t=gC();XE(4),Yg(t.error);}}function No(i,e){if(i&1&&Sg(0,"app-content-renderer",11),i&2){let t=gC();bg("content",t.fileContent.content)("format",t.fileContent.format);}}var ft=class i{destroy$=new ue;file;projectName;threadId;closeViewer=new vt$1;contentService=g(we);eventStream=g(fe);fileContent=null;isLoading=false;error="";ngOnInit(){this.loadContent(),this.subscribeToFileEvents();}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete();}loadContent(){if(!this.contentService.isViewable(this.file.size)){this.error=`File too large to view (${this.contentService.formatSize(this.file.size)}). Maximum size: 20 MB.`;return}this.isLoading=true,this.error="",this.contentService.loadFileContent(this.projectName,this.threadId,this.file.filename).subscribe({next:e=>{console.log("[CONTENT_VIEWER] Content loaded:",e.filename),this.fileContent=e,this.isLoading=false;},error:e=>{console.error("[CONTENT_VIEWER] Error loading content:",e),this.error=e.message||"Failed to load file content",this.isLoading=false;}});}onClose(){this.closeViewer.emit();}download(){let e=new Blob([this.fileContent?.content||""],{type:"text/plain"}),t=window.URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download=this.file.filename,n.click(),window.URL.revokeObjectURL(t);}formatSize(e){return this.contentService.formatSize(e)}subscribeToFileEvents(){this.eventStream.events$.pipe(kt(e=>e instanceof z),kt(e=>e.filename===this.file.filename),kt(e=>e.operation==="updated"),wd(this.destroy$)).subscribe(e=>{console.log("[CONTENT_VIEWER] File updated event received, reloading:",e.filename),e.size&&(this.file.size=e.size),this.loadContent();});}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-content-viewer"]],inputs:{file:"file",projectName:"projectName",threadId:"threadId"},outputs:{closeViewer:"closeViewer"},decls:16,vars:6,consts:[[1,"viewer-container"],[1,"viewer-header"],[1,"header-info"],[1,"filename"],[1,"file-size"],[1,"header-actions"],["mat-icon-button","","title","Download","type","button"],["mat-icon-button","","title","Close","type","button",3,"click"],[1,"viewer-content"],[1,"loading-state"],[1,"error-state"],[3,"content","format"],["mat-icon-button","","title","Download","type","button",3,"click"],["diameter","48"],[1,"error-icon"],[1,"error-message"],["mat-raised-button","","color","primary","type","button",3,"click"]],template:function(t,n){t&1&&(ws(0,"div",0)(1,"div",1)(2,"div",2)(3,"span",3),GC(4),pl(),ws(5,"span",4),GC(6),pl()(),ws(7,"div",5),Jw(8,Vo,3,0,"button",6),ws(9,"button",7),Rg("click",function(){return n.onClose()}),ws(10,"mat-icon"),GC(11,"chevron_right"),pl()()()(),ws(12,"div",8),Jw(13,Lo,4,0,"div",9),Jw(14,zo,9,1,"div",10),Jw(15,No,1,2,"app-content-renderer",11),pl()()),t&2&&(XE(4),Yg(n.file.filename),XE(2),Yg(n.formatSize(n.file.size)),XE(2),eC(n.fileContent&&!n.isLoading&&!n.error?8:-1),XE(5),eC(n.isLoading?13:-1),XE(),eC(n.error?14:-1),XE(),eC(n.fileContent&&!n.isLoading&&!n.error?15:-1));},dependencies:[qm,yt$1,wt$1,hr$1,pr$1,Gn$1,Et,yt$2,ht],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;height:100%}.viewer-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;height:100%;background:var(--color-bg)}.viewer-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:1rem;border-bottom:1px solid var(--color-border);background:var(--color-bg);flex-shrink:0}.header-info[_ngcontent-%COMP%]{flex:1;min-width:0;display:flex;flex-direction:column;gap:.25rem}.filename[_ngcontent-%COMP%]{font-weight:500;color:var(--color-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.file-size[_ngcontent-%COMP%]{font-size:.75rem;color:var(--color-text-secondary)}.header-actions[_ngcontent-%COMP%]{display:flex;gap:.25rem;flex-shrink:0}.viewer-content[_ngcontent-%COMP%]{flex:1;overflow:auto;background:var(--color-bg)}.loading-state[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:1rem;color:var(--color-text-secondary)}.error-state[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:1rem;padding:2rem;text-align:center}.error-icon[_ngcontent-%COMP%]{font-size:3rem;width:3rem;height:3rem;color:var(--color-error)}.error-message[_ngcontent-%COMP%]{color:var(--color-text);margin:0;max-width:400px}"],changeDetection:1})};var bt=6048e5,zn=864e5;var Dt=Symbol.for("constructDateFrom");function D(i,e){return typeof i=="function"?i(e):i&&typeof i=="object"&&Dt in i?i[Dt](e):i instanceof Date?new i.constructor(e):new Date(e)}function P(i,e){return D(e||i,i)}function $n(i,e,t){let n=P(i,t?.in);return isNaN(e)?D(i,NaN):(n.setDate(n.getDate()+e),n)}var Wo={};function de(){return Wo}function ne(i,e){let t=de(),n=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,o=P(i,e?.in),r=o.getDay(),d=(r<n?7:0)+r-n;return o.setDate(o.getDate()-d),o.setHours(0,0,0,0),o}function pe(i,e){return ne(i,x$1(w$1({},e),{weekStartsOn:1}))}function Ct(i,e){let t=P(i,e?.in),n=t.getFullYear(),o=D(t,0);o.setFullYear(n+1,0,4),o.setHours(0,0,0,0);let r=pe(o),d=D(t,0);d.setFullYear(n,0,4),d.setHours(0,0,0,0);let v=pe(d);return t.getTime()>=r.getTime()?n+1:t.getTime()>=v.getTime()?n:n-1}function At(i){let e=P(i),t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+i-+t}function Te(i,...e){let t=D.bind(null,e.find(n=>typeof n=="object"));return e.map(t)}function Se(i,e){let t=P(i,e?.in);return t.setHours(0,0,0,0),t}function vt(i,e,t){let[n,o]=Te(t?.in,i,e),r=Se(n),d=Se(o),v=+r-At(r),y=+d-At(d);return Math.round((v-y)/zn)}function jn(i,e){let t=Ct(i,e),n=D(i,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),pe(n)}function Un(i){return D(i,Date.now())}function Bn(i,e,t){let[n,o]=Te(t?.in,i,e);return +Se(n)==+Se(o)}function Wn(i){return i instanceof Date||typeof i=="object"&&Object.prototype.toString.call(i)==="[object Date]"}function qn(i){return !(!Wn(i)&&typeof i!="number"||isNaN(+P(i)))}function Gn(i,e,t){let[n,o]=Te(t?.in,i,e),r=Yn(n,o),d=Math.abs(vt(n,o));n.setDate(n.getDate()-r*d);let v=+(Yn(n,o)===-r),y=r*(d-v);return y===0?0:y}function Yn(i,e){let t=i.getFullYear()-e.getFullYear()||i.getMonth()-e.getMonth()||i.getDate()-e.getDate()||i.getHours()-e.getHours()||i.getMinutes()-e.getMinutes()||i.getSeconds()-e.getSeconds()||i.getMilliseconds()-e.getMilliseconds();return t<0?-1:t>0?1:t}function Qn(i,e){let t=P(i,e?.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}var qo={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Xn=(i,e,t)=>{let n,o=qo[i];return typeof o=="string"?n=o:e===1?n=o.one:n=o.other.replace("{{count}}",e.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n};function _t(i){return (e={})=>{let t=e.width?String(e.width):i.defaultWidth;return i.formats[t]||i.formats[i.defaultWidth]}}var Yo={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Go={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Qo={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Kn={date:_t({formats:Yo,defaultWidth:"full"}),time:_t({formats:Go,defaultWidth:"full"}),dateTime:_t({formats:Qo,defaultWidth:"full"})};var Xo={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Jn=(i,e,t,n)=>Xo[i];function Me(i){return (e,t)=>{let n=t?.context?String(t.context):"standalone",o;if(n==="formatting"&&i.formattingValues){let d=i.defaultFormattingWidth||i.defaultWidth,v=t?.width?String(t.width):d;o=i.formattingValues[v]||i.formattingValues[d];}else {let d=i.defaultWidth,v=t?.width?String(t.width):i.defaultWidth;o=i.values[v]||i.values[d];}let r=i.argumentCallback?i.argumentCallback(e):e;return o[r]}}var Ko={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Jo={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Zo={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},er={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},tr={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},nr={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},ir=(i,e)=>{let t=Number(i),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},Zn={ordinalNumber:ir,era:Me({values:Ko,defaultWidth:"wide"}),quarter:Me({values:Jo,defaultWidth:"wide",argumentCallback:i=>i-1}),month:Me({values:Zo,defaultWidth:"wide"}),day:Me({values:er,defaultWidth:"wide"}),dayPeriod:Me({values:tr,defaultWidth:"wide",formattingValues:nr,defaultFormattingWidth:"wide"})};function Ee(i){return (e,t={})=>{let n=t.width,o=n&&i.matchPatterns[n]||i.matchPatterns[i.defaultMatchWidth],r=e.match(o);if(!r)return null;let d=r[0],v=n&&i.parsePatterns[n]||i.parsePatterns[i.defaultParseWidth],y=Array.isArray(v)?rr(v,F=>F.test(d)):or(v,F=>F.test(d)),q;q=i.valueCallback?i.valueCallback(y):y,q=t.valueCallback?t.valueCallback(q):q;let A=e.slice(d.length);return {value:q,rest:A}}}function or(i,e){for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&e(i[t]))return t}function rr(i,e){for(let t=0;t<i.length;t++)if(e(i[t]))return t}function ei(i){return (e,t={})=>{let n=e.match(i.matchPattern);if(!n)return null;let o=n[0],r=e.match(i.parsePattern);if(!r)return null;let d=i.valueCallback?i.valueCallback(r[0]):r[0];d=t.valueCallback?t.valueCallback(d):d;let v=e.slice(o.length);return {value:d,rest:v}}}var ar=/^(\d+)(th|st|nd|rd)?/i,sr=/\d+/i,cr={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},lr={any:[/^b/i,/^(a|c)/i]},dr={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},mr={any:[/1/i,/2/i,/3/i,/4/i]},pr={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},gr={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},ur={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},hr={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},fr={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},br={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},ti={ordinalNumber:ei({matchPattern:ar,parsePattern:sr,valueCallback:i=>parseInt(i,10)}),era:Ee({matchPatterns:cr,defaultMatchWidth:"wide",parsePatterns:lr,defaultParseWidth:"any"}),quarter:Ee({matchPatterns:dr,defaultMatchWidth:"wide",parsePatterns:mr,defaultParseWidth:"any",valueCallback:i=>i+1}),month:Ee({matchPatterns:pr,defaultMatchWidth:"wide",parsePatterns:gr,defaultParseWidth:"any"}),day:Ee({matchPatterns:ur,defaultMatchWidth:"wide",parsePatterns:hr,defaultParseWidth:"any"}),dayPeriod:Ee({matchPatterns:fr,defaultMatchWidth:"any",parsePatterns:br,defaultParseWidth:"any"})};var Ft={code:"en-US",formatDistance:Xn,formatLong:Kn,formatRelative:Jn,localize:Zn,match:ti,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ni(i,e){let t=P(i,e?.in);return vt(t,Qn(t))+1}function ii(i,e){let t=P(i,e?.in),n=+pe(t)-+jn(t);return Math.round(n/bt)+1}function xt(i,e){let t=P(i,e?.in),n=t.getFullYear(),o=de(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,d=D(e?.in||i,0);d.setFullYear(n+1,0,r),d.setHours(0,0,0,0);let v=ne(d,e),y=D(e?.in||i,0);y.setFullYear(n,0,r),y.setHours(0,0,0,0);let q=ne(y,e);return +t>=+v?n+1:+t>=+q?n:n-1}function oi(i,e){let t=de(),n=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,o=xt(i,e),r=D(e?.in||i,0);return r.setFullYear(o,0,n),r.setHours(0,0,0,0),ne(r,e)}function ri(i,e){let t=P(i,e?.in),n=+ne(t,e)-+oi(t,e);return Math.round(n/bt)+1}function w(i,e){let t=i<0?"-":"",n=Math.abs(i).toString().padStart(e,"0");return t+n}var ie={y(i,e){let t=i.getFullYear(),n=t>0?t:1-t;return w(e==="yy"?n%100:n,e.length)},M(i,e){let t=i.getMonth();return e==="M"?String(t+1):w(t+1,2)},d(i,e){return w(i.getDate(),e.length)},a(i,e){let t=i.getHours()/12>=1?"pm":"am";switch(e){case "a":case "aa":return t.toUpperCase();case "aaa":return t;case "aaaaa":return t[0];default:return t==="am"?"a.m.":"p.m."}},h(i,e){return w(i.getHours()%12||12,e.length)},H(i,e){return w(i.getHours(),e.length)},m(i,e){return w(i.getMinutes(),e.length)},s(i,e){return w(i.getSeconds(),e.length)},S(i,e){let t=e.length,n=i.getMilliseconds(),o=Math.trunc(n*Math.pow(10,t-3));return w(o,e.length)}};var Oe={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Rt={G:function(i,e,t){let n=i.getFullYear()>0?1:0;switch(e){case "G":case "GG":case "GGG":return t.era(n,{width:"abbreviated"});case "GGGGG":return t.era(n,{width:"narrow"});default:return t.era(n,{width:"wide"})}},y:function(i,e,t){if(e==="yo"){let n=i.getFullYear(),o=n>0?n:1-n;return t.ordinalNumber(o,{unit:"year"})}return ie.y(i,e)},Y:function(i,e,t,n){let o=xt(i,n),r=o>0?o:1-o;if(e==="YY"){let d=r%100;return w(d,2)}return e==="Yo"?t.ordinalNumber(r,{unit:"year"}):w(r,e.length)},R:function(i,e){let t=Ct(i);return w(t,e.length)},u:function(i,e){let t=i.getFullYear();return w(t,e.length)},Q:function(i,e,t){let n=Math.ceil((i.getMonth()+1)/3);switch(e){case "Q":return String(n);case "QQ":return w(n,2);case "Qo":return t.ordinalNumber(n,{unit:"quarter"});case "QQQ":return t.quarter(n,{width:"abbreviated",context:"formatting"});case "QQQQQ":return t.quarter(n,{width:"narrow",context:"formatting"});default:return t.quarter(n,{width:"wide",context:"formatting"})}},q:function(i,e,t){let n=Math.ceil((i.getMonth()+1)/3);switch(e){case "q":return String(n);case "qq":return w(n,2);case "qo":return t.ordinalNumber(n,{unit:"quarter"});case "qqq":return t.quarter(n,{width:"abbreviated",context:"standalone"});case "qqqqq":return t.quarter(n,{width:"narrow",context:"standalone"});default:return t.quarter(n,{width:"wide",context:"standalone"})}},M:function(i,e,t){let n=i.getMonth();switch(e){case "M":case "MM":return ie.M(i,e);case "Mo":return t.ordinalNumber(n+1,{unit:"month"});case "MMM":return t.month(n,{width:"abbreviated",context:"formatting"});case "MMMMM":return t.month(n,{width:"narrow",context:"formatting"});default:return t.month(n,{width:"wide",context:"formatting"})}},L:function(i,e,t){let n=i.getMonth();switch(e){case "L":return String(n+1);case "LL":return w(n+1,2);case "Lo":return t.ordinalNumber(n+1,{unit:"month"});case "LLL":return t.month(n,{width:"abbreviated",context:"standalone"});case "LLLLL":return t.month(n,{width:"narrow",context:"standalone"});default:return t.month(n,{width:"wide",context:"standalone"})}},w:function(i,e,t,n){let o=ri(i,n);return e==="wo"?t.ordinalNumber(o,{unit:"week"}):w(o,e.length)},I:function(i,e,t){let n=ii(i);return e==="Io"?t.ordinalNumber(n,{unit:"week"}):w(n,e.length)},d:function(i,e,t){return e==="do"?t.ordinalNumber(i.getDate(),{unit:"date"}):ie.d(i,e)},D:function(i,e,t){let n=ni(i);return e==="Do"?t.ordinalNumber(n,{unit:"dayOfYear"}):w(n,e.length)},E:function(i,e,t){let n=i.getDay();switch(e){case "E":case "EE":case "EEE":return t.day(n,{width:"abbreviated",context:"formatting"});case "EEEEE":return t.day(n,{width:"narrow",context:"formatting"});case "EEEEEE":return t.day(n,{width:"short",context:"formatting"});default:return t.day(n,{width:"wide",context:"formatting"})}},e:function(i,e,t,n){let o=i.getDay(),r=(o-n.weekStartsOn+8)%7||7;switch(e){case "e":return String(r);case "ee":return w(r,2);case "eo":return t.ordinalNumber(r,{unit:"day"});case "eee":return t.day(o,{width:"abbreviated",context:"formatting"});case "eeeee":return t.day(o,{width:"narrow",context:"formatting"});case "eeeeee":return t.day(o,{width:"short",context:"formatting"});default:return t.day(o,{width:"wide",context:"formatting"})}},c:function(i,e,t,n){let o=i.getDay(),r=(o-n.weekStartsOn+8)%7||7;switch(e){case "c":return String(r);case "cc":return w(r,e.length);case "co":return t.ordinalNumber(r,{unit:"day"});case "ccc":return t.day(o,{width:"abbreviated",context:"standalone"});case "ccccc":return t.day(o,{width:"narrow",context:"standalone"});case "cccccc":return t.day(o,{width:"short",context:"standalone"});default:return t.day(o,{width:"wide",context:"standalone"})}},i:function(i,e,t){let n=i.getDay(),o=n===0?7:n;switch(e){case "i":return String(o);case "ii":return w(o,e.length);case "io":return t.ordinalNumber(o,{unit:"day"});case "iii":return t.day(n,{width:"abbreviated",context:"formatting"});case "iiiii":return t.day(n,{width:"narrow",context:"formatting"});case "iiiiii":return t.day(n,{width:"short",context:"formatting"});default:return t.day(n,{width:"wide",context:"formatting"})}},a:function(i,e,t){let o=i.getHours()/12>=1?"pm":"am";switch(e){case "a":case "aa":return t.dayPeriod(o,{width:"abbreviated",context:"formatting"});case "aaa":return t.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case "aaaaa":return t.dayPeriod(o,{width:"narrow",context:"formatting"});default:return t.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(i,e,t){let n=i.getHours(),o;switch(n===12?o=Oe.noon:n===0?o=Oe.midnight:o=n/12>=1?"pm":"am",e){case "b":case "bb":return t.dayPeriod(o,{width:"abbreviated",context:"formatting"});case "bbb":return t.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case "bbbbb":return t.dayPeriod(o,{width:"narrow",context:"formatting"});default:return t.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(i,e,t){let n=i.getHours(),o;switch(n>=17?o=Oe.evening:n>=12?o=Oe.afternoon:n>=4?o=Oe.morning:o=Oe.night,e){case "B":case "BB":case "BBB":return t.dayPeriod(o,{width:"abbreviated",context:"formatting"});case "BBBBB":return t.dayPeriod(o,{width:"narrow",context:"formatting"});default:return t.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(i,e,t){if(e==="ho"){let n=i.getHours()%12;return n===0&&(n=12),t.ordinalNumber(n,{unit:"hour"})}return ie.h(i,e)},H:function(i,e,t){return e==="Ho"?t.ordinalNumber(i.getHours(),{unit:"hour"}):ie.H(i,e)},K:function(i,e,t){let n=i.getHours()%12;return e==="Ko"?t.ordinalNumber(n,{unit:"hour"}):w(n,e.length)},k:function(i,e,t){let n=i.getHours();return n===0&&(n=24),e==="ko"?t.ordinalNumber(n,{unit:"hour"}):w(n,e.length)},m:function(i,e,t){return e==="mo"?t.ordinalNumber(i.getMinutes(),{unit:"minute"}):ie.m(i,e)},s:function(i,e,t){return e==="so"?t.ordinalNumber(i.getSeconds(),{unit:"second"}):ie.s(i,e)},S:function(i,e){return ie.S(i,e)},X:function(i,e,t){let n=i.getTimezoneOffset();if(n===0)return "Z";switch(e){case "X":return si(n);case "XXXX":case "XX":return ge(n);default:return ge(n,":")}},x:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case "x":return si(n);case "xxxx":case "xx":return ge(n);default:return ge(n,":")}},O:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case "O":case "OO":case "OOO":return "GMT"+ai(n,":");default:return "GMT"+ge(n,":")}},z:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case "z":case "zz":case "zzz":return "GMT"+ai(n,":");default:return "GMT"+ge(n,":")}},t:function(i,e,t){let n=Math.trunc(+i/1e3);return w(n,e.length)},T:function(i,e,t){return w(+i,e.length)}};function ai(i,e=""){let t=i>0?"-":"+",n=Math.abs(i),o=Math.trunc(n/60),r=n%60;return r===0?t+String(o):t+String(o)+e+w(r,2)}function si(i,e){return i%60===0?(i>0?"-":"+")+w(Math.abs(i)/60,2):ge(i,e)}function ge(i,e=""){let t=i>0?"-":"+",n=Math.abs(i),o=w(Math.trunc(n/60),2),r=w(n%60,2);return t+o+e+r}var ci=(i,e)=>{switch(i){case "P":return e.date({width:"short"});case "PP":return e.date({width:"medium"});case "PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},li=(i,e)=>{switch(i){case "p":return e.time({width:"short"});case "pp":return e.time({width:"medium"});case "ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},Cr=(i,e)=>{let t=i.match(/(P+)(p+)?/)||[],n=t[1],o=t[2];if(!o)return ci(i,e);let r;switch(n){case "P":r=e.dateTime({width:"short"});break;case "PP":r=e.dateTime({width:"medium"});break;case "PPP":r=e.dateTime({width:"long"});break;default:r=e.dateTime({width:"full"});break}return r.replace("{{date}}",ci(n,e)).replace("{{time}}",li(o,e))},di={p:li,P:Cr};var vr=/^D+$/,_r=/^Y+$/,xr=["D","DD","YY","YYYY"];function mi(i){return vr.test(i)}function pi(i){return _r.test(i)}function gi(i,e,t){let n=yr(i,e,t);if(console.warn(n),xr.includes(i))throw new RangeError(n)}function yr(i,e,t){let n=i[0]==="Y"?"years":"days of the month";return `Use \`${i.toLowerCase()}\` instead of \`${i}\` (in \`${e}\`) for formatting ${n} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var wr=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Tr=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Sr=/^'([^]*?)'?$/,Mr=/''/g,Er=/[a-zA-Z]/;function Ht(i,e,t){let n=de(),o=n.locale??Ft,r=n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,d=n.weekStartsOn??n.locale?.options?.weekStartsOn??0,v=P(i,t?.in);if(!qn(v))throw new RangeError("Invalid time value");let y=e.match(Tr).map(A=>{let F=A[0];if(F==="p"||F==="P"){let Mt=di[F];return Mt(A,o.formatLong)}return A}).join("").match(wr).map(A=>{if(A==="''")return {isToken:false,value:"'"};let F=A[0];if(F==="'")return {isToken:false,value:Or(A)};if(Rt[F])return {isToken:true,value:A};if(F.match(Er))throw new RangeError("Format string contains an unescaped latin alphabet character `"+F+"`");return {isToken:false,value:A}});o.localize.preprocessor&&(y=o.localize.preprocessor(v,y));let q={firstWeekContainsDate:r,weekStartsOn:d,locale:o};return y.map(A=>{if(!A.isToken)return A.value;let F=A.value;(pi(F)||mi(F))&&gi(F,e,String(i));let Mt=Rt[F[0]];return Mt(v,F,o.localize,q)}).join("")}function Or(i){let e=i.match(Sr);return e?e[1].replace(Mr,"'"):i}function ui(i,e,t){return $n(i,-1,t)}function hi(i,e){return Bn(D(i,i),ui(Un(i)))}function fi(i){if(!i||isNaN(i.getTime()))return "unknown";let e=new Date,t=Ht(i,"HH:mm:ss"),n=e.getTime()-i.getTime(),o=Math.floor(n/(1e3*60));if(o<1)return `just now (${t})`;if(o<60)return `${o} min ago (${t})`;let r=Math.floor(n/(1e3*60*60));if(r<24)return `${r}h ago (${t})`;if(hi(i))return `yesterday ${t}`;let d=Gn(e,i);return d<7?`${d}d ago ${t}`:`${Ht(i,"dd/MM/yyyy")} ${t}`}var Pr=(i,e)=>e.filename;function kr(i,e){if(i&1){let t=lC();ws(0,"button",11),Rg("click",function(){If(t);let o=gC(2);return wf(o.downloadAll())}),ws(1,"mat-icon"),GC(2,"download_for_offline"),pl()();}}function Ir(i,e){i&1&&(ws(0,"div",10),Sg(1,"span",12),ws(2,"span",13),GC(3,"Loading files..."),pl()());}function Dr(i,e){i&1&&(ws(0,"div",14)(1,"mat-icon",15),GC(2,"folder_open"),pl(),ws(3,"p",16),GC(4,"No files in exchange space"),pl(),ws(5,"p",17),GC(6,"Upload files to share with the agent"),pl()());}function Ar(i,e){if(i&1){let t=lC();ws(0,"button",28),Rg("click",function(){If(t);let o=gC().$implicit,r=gC(4);return wf(r.viewFile(o))}),ws(1,"mat-icon"),GC(2,"visibility"),pl()();}}function Fr(i,e){if(i&1){let t=lC();ws(0,"div",18)(1,"div",19)(2,"mat-icon",20),GC(3),pl(),ws(4,"div",21)(5,"span",22),GC(6),pl(),ws(7,"span",23),GC(8),pl()()(),ws(9,"div",24),Jw(10,Ar,3,0,"button",25),ws(11,"button",26),Rg("click",function(){let o=If(t).$implicit,r=gC(4);return wf(r.download(o))}),ws(12,"mat-icon"),GC(13,"download"),pl()(),ws(14,"button",27),Rg("click",function(){let o=If(t).$implicit,r=gC(4);return wf(r.delete(o))}),ws(15,"mat-icon"),GC(16,"delete"),pl()()()();}if(i&2){let t=e.$implicit,n=gC(4);XE(3),Yg(n.getFileIcon(t.filename)),XE(2),bg("title",t.filename),XE(),Yg(t.filename),XE(2),Qg("",n.formatSize(t.size)," \u2022 ",n.formatDate(t.lastModified)),XE(2),eC(n.canViewFile(t)?10:-1);}}function Rr(i,e){if(i&1&&rC(0,Fr,17,6,"div",18,Pr),i&2){let t=gC(3);oC(t.files());}}function Hr(i,e){if(i&1&&Jw(0,Dr,7,0,"div",14)(1,Rr,2,0),i&2){let t=gC(2);eC(t.files().length===0?0:1);}}function Vr(i,e){if(i&1){let t=lC();ws(0,"div",0)(1,"div",2)(2,"div",3)(3,"h3",4),GC(4,"Exchange"),pl(),ws(5,"span",5),GC(6),pl()(),ws(7,"div",6),Jw(8,kr,3,0,"button",7),ws(9,"button",8),Rg("click",function(){If(t);let o=gC();return wf(o.close())}),ws(10,"mat-icon"),GC(11,"chevron_right"),pl()()()(),ws(12,"div",9),Jw(13,Ir,4,0,"div",10)(14,Hr,2,1),pl()();}if(i&2){let t=gC();XE(6),vl("(",t.files().length,")"),XE(2),eC(t.files().length>0?8:-1),XE(5),eC(t.isLoading()?13:14);}}function Lr(i,e){if(i&1){let t=lC();ws(0,"app-content-viewer",29),Rg("closeViewer",function(){If(t);let o=gC();return wf(o.backToList())}),pl();}if(i&2){let t=gC();bg("file",t.currentFile)("projectName",t.projectName)("threadId",t.threadId);}}var yt=class i{projectName;threadId;closeDrawer=new vt$1;fileExchangeState=g(ye);contentViewerService=g(we);files=this.fileExchangeState.files;isLoading=this.fileExchangeState.isLoading;viewerState="list";currentFile=null;close(){this.viewerState==="content"?this.backToList():this.closeDrawer.emit();}viewFile(e){this.currentFile=e,this.viewerState="content";}backToList(){this.viewerState="list",this.currentFile=null;}downloadAll(){this.fileExchangeState.downloadAllFiles();}download(e){this.fileExchangeState.downloadFile(e.filename);}delete(e){return B(this,null,function*(){if(!confirm(`Delete file "${e.filename}"?`))return;let n=yield this.fileExchangeState.deleteFile(e.filename);n.success||alert(`Failed to delete file: ${n.error}`);})}getFileIcon(e){switch(e.split(".").pop()?.toLowerCase()){case "pdf":return "picture_as_pdf";case "csv":case "xlsx":case "xls":return "table_chart";case "txt":case "md":return "description";case "jpg":case "jpeg":case "png":case "gif":case "webp":return "image";case "zip":case "tar":case "gz":return "folder_zip";default:return "insert_drive_file"}}formatSize(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}formatDate(e){return fi(e)}canViewFile(e){return this.contentViewerService.isFormatViewable(e.filename)&&this.contentViewerService.isViewable(e.size)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-file-exchange-drawer"]],inputs:{projectName:"projectName",threadId:"threadId"},outputs:{closeDrawer:"closeDrawer"},decls:2,vars:2,consts:[[1,"file-drawer-container"],[3,"file","projectName","threadId"],[1,"drawer-header"],[1,"header-left"],[1,"drawer-title"],[1,"file-count"],[1,"header-actions"],["mat-icon-button","","title","Download all files","type","button",1,"download-all-btn"],["mat-icon-button","","title","Close","type","button",1,"close-btn",3,"click"],[1,"file-list"],[1,"file-loading"],["mat-icon-button","","title","Download all files","type","button",1,"download-all-btn",3,"click"],[1,"loading-spinner"],[1,"loading-text"],[1,"file-empty"],[1,"empty-icon"],[1,"empty-text"],[1,"empty-hint"],[1,"file-item"],[1,"file-info"],[1,"file-icon"],[1,"file-details"],[1,"file-name",3,"title"],[1,"file-meta"],[1,"file-actions"],["mat-icon-button","","title","View","type","button",1,"action-btn","view-btn"],["mat-icon-button","","title","Download","type","button",1,"action-btn","download-btn",3,"click"],["mat-icon-button","","title","Delete","type","button",1,"action-btn","delete-btn",3,"click"],["mat-icon-button","","title","View","type","button",1,"action-btn","view-btn",3,"click"],[3,"closeViewer","file","projectName","threadId"]],template:function(t,n){t&1&&(Jw(0,Vr,15,3,"div",0),Jw(1,Lr,1,3,"app-content-viewer",1)),t&2&&(eC(n.viewerState==="list"?0:-1),XE(),eC(n.viewerState==="content"&&n.currentFile?1:-1));},dependencies:[qm,yt$1,wt$1,hr$1,Gn$1,ft],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;height:100%}.file-drawer-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;height:100%;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);color:var(--color-text)}.drawer-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--color-border);flex-shrink:0}.header-left[_ngcontent-%COMP%]{display:flex;align-items:baseline;gap:.5rem}.header-actions[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.25rem}.drawer-title[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:600;color:var(--color-text)}.file-count[_ngcontent-%COMP%]{font-size:.9rem;color:var(--color-text-secondary)}.download-all-btn[_ngcontent-%COMP%]{color:var(--color-primary)}.download-all-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.close-btn[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.close-btn[_ngcontent-%COMP%]:hover{color:var(--color-text);background:var(--color-bg-hover)}.file-list[_ngcontent-%COMP%]{flex:1;overflow-y:auto;padding:.5rem}.file-loading[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:3rem 1rem;gap:1rem;color:var(--color-text-secondary)}.loading-spinner[_ngcontent-%COMP%]{display:inline-block;width:32px;height:32px;border:3px solid var(--color-border);border-top-color:var(--color-primary);border-radius:50%;animation:_ngcontent-%COMP%_spin .8s linear infinite}@keyframes _ngcontent-%COMP%_spin{to{transform:rotate(360deg)}}.loading-text[_ngcontent-%COMP%]{font-size:.9rem}.file-empty[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:3rem 1rem;text-align:center;color:var(--color-text-secondary)}.empty-icon[_ngcontent-%COMP%]{font-size:64px;width:64px;height:64px;margin-bottom:1rem;opacity:.5}.empty-text[_ngcontent-%COMP%]{margin:0 0 .5rem;font-size:1rem;font-weight:500}.empty-hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;opacity:.7}.file-item[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:.75rem;border-radius:8px;transition:background .2s;gap:1rem}.file-item[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.file-item[_ngcontent-%COMP%]:hover .file-actions[_ngcontent-%COMP%]{opacity:1}.file-info[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.75rem;flex:1;min-width:0}.file-icon[_ngcontent-%COMP%]{flex-shrink:0;color:var(--color-primary);font-size:28px;width:28px;height:28px}.file-details[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.25rem;min-width:0}.file-name[_ngcontent-%COMP%]{font-weight:500;color:var(--color-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.file-meta[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary)}.file-actions[_ngcontent-%COMP%]{display:flex;gap:.25rem;flex-shrink:0;opacity:0;transition:opacity .2s}.action-btn[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.action-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.action-btn.view-btn[_ngcontent-%COMP%]:hover, .action-btn.download-btn[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.action-btn.delete-btn[_ngcontent-%COMP%]:hover{color:var(--color-error)}@media(max-width:768px){.file-actions[_ngcontent-%COMP%]{opacity:1}.file-item[_ngcontent-%COMP%]{padding:1rem .75rem}.drawer-header[_ngcontent-%COMP%]{padding:.75rem;padding-top:calc(.75rem + env(safe-area-inset-top,0px))}}"],changeDetection:1})};var wt=class i{http=g(py);listUsers(){return this.http.get("/api/users")}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var Tt=class i{excludedUserIds=[];placeholder="Search username";disabled=false;userSelected=new vt$1;userApi=g(wt);search(e){let t=e.toLowerCase();return this.userApi.listUsers().pipe(re(n=>n.filter(o=>!this.excludedUserIds.includes(o.username)).filter(o=>o.username.toLowerCase().includes(t)).map(o=>({id:o.username,name:o.username}))))}onItemSelected(e){this.userSelected.emit(e.id);}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-user-autocomplete"]],inputs:{excludedUserIds:"excludedUserIds",placeholder:"placeholder",disabled:"disabled"},outputs:{userSelected:"userSelected"},decls:1,vars:3,consts:[[3,"itemSelected","dataSource","placeholder","disabled"]],template:function(t,n){t&1&&(ws(0,"ds-autocomplete-input",0),Rg("itemSelected",function(r){return n.onItemSelected(r)}),pl()),t&2&&bg("dataSource",n)("placeholder",n.placeholder)("disabled",n.disabled);},dependencies:[Pn],styles:["[_nghost-%COMP%]{display:block}"],changeDetection:1})};var zr=(i,e)=>e.userId;function Nr(i,e){if(i&1&&(ws(0,"div",7),GC(1),pl()),i&2){let t=gC();XE(),Yg(t.errorMessage());}}function $r(i,e){if(i&1){let t=lC();ws(0,"button",13),Rg("click",function(){If(t);let o=gC().$implicit,r=gC();return wf(r.removeUser(o.userId))}),ws(1,"mat-icon"),GC(2,"close"),pl()();}}function jr(i,e){if(i&1&&(ws(0,"div",9)(1,"mat-icon",10),GC(2,"person"),pl(),ws(3,"span",11),GC(4),pl(),Jw(5,$r,3,0,"button",12),pl()),i&2){let t=e.$implicit,n=gC();XE(4),Yg(t.userId),XE(),eC(n.users.length>1?5:-1);}}var ke=class i{threadId;users=[];currentUsername;userAdded=new vt$1;userRemoved=new vt$1;closed=new vt$1;isAdding=Gi$1(false);errorMessage=Gi$1("");get excludedUserIds(){return [this.currentUsername,...this.users.map(e=>e.userId)]}setAdding(e){this.isAdding.set(e);}setError(e){this.errorMessage.set(e),this.isAdding.set(false);}onUserSelected(e){this.errorMessage.set(""),this.userAdded.emit(e);}removeUser(e){this.userRemoved.emit(e);}close(){this.closed.emit();}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-thread-share"]],inputs:{threadId:"threadId",users:"users",currentUsername:"currentUsername"},outputs:{userAdded:"userAdded",userRemoved:"userRemoved",closed:"closed"},decls:19,vars:3,consts:[[1,"thread-share"],[1,"share-header"],[1,"header-left"],["mat-icon-button","","title","Close","type","button",1,"close-btn",3,"click"],[1,"share-subheader"],[1,"add-user-section"],[3,"userSelected","excludedUserIds","disabled"],[1,"error-message"],[1,"users-list"],[1,"user-item"],[1,"user-icon"],[1,"user-name"],["mat-icon-button","","title","Remove user",1,"remove-button"],["mat-icon-button","","title","Remove user",1,"remove-button",3,"click"]],template:function(t,n){t&1&&(ws(0,"div",0)(1,"div",1)(2,"div",2)(3,"mat-icon"),GC(4,"group"),pl(),ws(5,"span"),GC(6,"Share"),pl()(),ws(7,"button",3),Rg("click",function(){return n.close()}),ws(8,"mat-icon"),GC(9,"chevron_right"),pl()()(),ws(10,"div",4)(11,"span"),GC(12,"Participants"),pl()(),ws(13,"div",5)(14,"app-user-autocomplete",6),Rg("userSelected",function(r){return n.onUserSelected(r)}),pl()(),Jw(15,Nr,2,1,"div",7),ws(16,"div",8),rC(17,jr,6,2,"div",9,zr),pl()()),t&2&&(XE(14),bg("excludedUserIds",n.excludedUserIds)("disabled",n.isAdding()),XE(),eC(n.errorMessage()?15:-1),XE(2),oC(n.users));},dependencies:[yt$1,wt$1,hr$1,Gn$1,Ve,Tt],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;height:100%}.thread-share[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);color:var(--color-text)}.share-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:1rem;padding-top:calc(1rem + env(safe-area-inset-top,0px));border-bottom:1px solid var(--color-border);flex-shrink:0}.share-header[_ngcontent-%COMP%] .header-left[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;font-weight:600;font-size:1.1rem;color:var(--color-text)}.share-header[_ngcontent-%COMP%] .header-left[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px;color:var(--color-text-secondary)}.share-header[_ngcontent-%COMP%] .close-btn[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.share-header[_ngcontent-%COMP%] .close-btn[_ngcontent-%COMP%]:hover{color:var(--color-text);background:var(--color-bg-hover)}.share-subheader[_ngcontent-%COMP%]{padding:.75rem 1rem .25rem;font-size:.75rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:var(--color-text-secondary)}.add-user-section[_ngcontent-%COMP%]{display:flex;align-items:center;padding:0 1rem .75rem;width:50%}.error-message[_ngcontent-%COMP%]{color:var(--color-error);font-size:.75rem;margin-top:-.5rem;padding:0 1rem}.users-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.25rem;padding:.25rem}.user-item[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;border-radius:6px;transition:background .15s ease}.user-item[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.user-icon[_ngcontent-%COMP%]{font-size:18px;width:18px;height:18px;color:var(--color-text-secondary);flex-shrink:0}.user-name[_ngcontent-%COMP%]{flex:1;font-size:.875rem;color:var(--color-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.remove-button[_ngcontent-%COMP%]{flex-shrink:0;width:28px!important;height:28px!important;padding:0!important}.remove-button[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:16px;width:16px;height:16px;color:var(--color-text-secondary)}.remove-button[_ngcontent-%COMP%]:hover mat-icon[_ngcontent-%COMP%]{color:var(--color-error, #ef4444)}"],changeDetection:1})};var Ur=new C("MAT_BADGE_CONFIG"),bi="mat-badge-content",Br=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275cmp=xw({type:i,selectors:[["ng-component"]],decls:0,vars:0,template:function(n,o){},styles:[`.mat-badge {
31
+ `:"")+v}},{paragraphs:0,text:""}).text||e}renderStreamingText(){return B(this,null,function*(){if(!this.streamingText){this.renderedStreamingText="";return}try{let e=yield this.markdownService.parse(this.streamingText);this.renderedStreamingText=this.sanitizer.bypassSecurityTrustHtml(e);}catch(e){console.error("[CHAT-HISTORY] Error rendering streaming text markdown:",e),this.renderedStreamingText=this.sanitizer.bypassSecurityTrustHtml(this.streamingText);}})}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-chat-history"]],hostBindings:function(t,n){t&1&&Rg("scroll",function(){return n.onScroll()});},inputs:{messages:"messages",streamingText:"streamingText",isThinking:"isThinking",currentUsername:"currentUsername"},outputs:{copyRequested:"copyRequested",stopRequested:"stopRequested"},features:[Tu],decls:6,vars:3,consts:[[1,"chat-history"],[1,"streaming-message","message","assistant"],[3,"runningDelegations"],["mat-fab","","color","primary","title","Go to bottom",1,"go-to-bottom-btn"],[3,"subThreadId","agentName"],[3,"message","canDelete","isOtherUser"],[3,"copyRequested","deleteRequested","message","canDelete","isOtherUser"],[1,"content","markdown-content",3,"innerHTML"],["mat-fab","","color","primary","title","Go to bottom",1,"go-to-bottom-btn",3,"click"],["fontSet","material-icons-outlined"]],template:function(t,n){t&1&&(ws(0,"div",0),rC(1,xo,2,1,null,null,Co),Jw(3,yo,2,1,"div",1),Jw(4,wo,1,1,"app-thinking-loader",2),Jw(5,To,3,0,"button",3),pl()),t&2&&(XE(),oC(n.messages),XE(2),eC(n.streamingText?3:-1),XE(),eC(n.isThinking?4:-1),XE(),eC(n.showGoToBottom?5:-1));},dependencies:[ve,wt$1,dt,fr$1,lt],styles:[".streaming-message.assistant[_ngcontent-%COMP%]{background:transparent;border:none;box-shadow:none;border-radius:0;margin-left:0;margin-right:auto;padding:.5rem 0;width:100%;max-width:none;min-width:0}.streaming-message[_ngcontent-%COMP%] .content[_ngcontent-%COMP%]{color:var(--color-text);line-height:1.5}.go-to-bottom-btn[_ngcontent-%COMP%]{position:fixed!important;bottom:30%!important;right:1rem!important;z-index:1000!important}@media(max-width:768px){.go-to-bottom-btn[_ngcontent-%COMP%]{width:40px!important;height:40px!important;right:.75rem!important}.go-to-bottom-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}}@media print{[_nghost-%COMP%]{display:block!important;height:auto!important;max-height:none!important;overflow:visible!important;position:static!important}.chat-history[_ngcontent-%COMP%]{display:block!important;height:auto!important;max-height:none!important;overflow:visible!important;position:static!important}.go-to-bottom-btn[_ngcontent-%COMP%]{display:none!important}}"],changeDetection:1})};var So=["buttonContainer"],Mo=["freeTextInput"],Eo=(i,e)=>e.value;function Oo(i,e){i&1&&(ws(0,"mat-icon",10),GC(1,"keyboard_return"),pl());}function Po(i,e){if(i&1){let t=lC();ws(0,"button",8),Rg("click",function(){let o=If(t).$implicit,r=gC(2);return wf(r.onOptionClick(o.value))}),ws(1,"span",9),GC(2),pl(),Jw(3,Oo,2,0,"mat-icon",10),pl();}if(i&2){let t=e.$implicit,n=e.$index,o=gC(2);Ug("highlighted",n===o.highlightedIndex),bg("disabled",t.disabled)("id","choice-option-"+n),Tg("aria-selected",n===o.highlightedIndex),XE(2),Yg(t.label),XE(),eC(n===o.highlightedIndex?3:-1);}}function ko(i,e){if(i&1){let t=lC();ws(0,"div",6)(1,"span",11),GC(2,"Or type your own answer:"),pl(),ws(3,"div",12)(4,"input",13,1),tm("ngModelChange",function(o){If(t);let r=gC(2);return KC(r.freeTextValue,o)||(r.freeTextValue=o),wf(o)}),Rg("keydown",function(o){If(t);let r=gC(2);return wf(r.onFreeTextKeyDown(o))}),pl(),VI(),ws(6,"button",14),Rg("click",function(){If(t);let o=gC(2);return wf(o.onFreeTextSubmit())}),ws(7,"mat-icon"),GC(8,"send"),pl()()()();}if(i&2){let t=gC(2);XE(4),em("ngModel",t.freeTextValue),UI(),XE(2),bg("disabled",!t.freeTextValue.trim());}}function Io(i,e){if(i&1&&(ws(0,"div",7)(1,"mat-icon"),GC(2,"search"),pl(),ws(3,"span"),GC(4),pl()()),i&2){let t=gC(2);XE(4),Yg(t.searchText);}}function Do(i,e){if(i&1){let t=lC();ws(0,"div",2),Sg(1,"div",3),aT(2,"async"),ws(3,"div",4,0),Rg("keydown",function(o){If(t);let r=gC();return wf(r.onKeyDown(o))}),rC(5,Po,4,7,"button",5,Eo),pl(),Jw(7,ko,9,2,"div",6),Jw(8,Io,5,1,"div",7),pl();}if(i&2){let t=gC();XE(),bg("innerHTML",uT(2,4,t.renderedLabel$),aE),XE(2),Tg("aria-activedescendant","choice-option-"+t.highlightedIndex),XE(2),oC(t.options),XE(2),eC(t.allowFreeText?7:-1),XE(),eC(t.searchText?8:-1);}}var pt=class i{options=[];allowFreeText=false;set labelHtml(e){typeof e=="object"?this.renderedLabelSubject.next(e):this.renderLabelMarkdown(e);}isVisible=false;choiceSelected=new vt$1;buttonContainer;freeTextInput;highlightedIndex=0;searchText="";freeTextValue="";searchTimeout;destroy$=new ue;renderedLabelSubject=new Tr$1("");renderedLabel$=this.renderedLabelSubject.asObservable();sanitizer=g(bS);markdownService=g(Z);ngOnDestroy(){this.renderedLabelSubject.complete(),this.destroy$.next(),this.destroy$.complete(),this.searchTimeout&&clearTimeout(this.searchTimeout);}ngAfterViewInit(){this.isVisible&&this.buttonContainer&&setTimeout(()=>this.focusContainer(),100);}ngOnChanges(e){e.isVisible&&e.isVisible.currentValue&&!e.isVisible.previousValue&&(this.highlightedIndex=0,setTimeout(()=>this.focusContainer(),150)),e.options&&!e.options.firstChange&&(this.highlightedIndex=0,this.searchText="",this.freeTextValue="");}focusContainer(){this.buttonContainer?.nativeElement&&this.buttonContainer.nativeElement.focus();}onKeyDown(e){if(this.options.filter(n=>!n.disabled).length!==0)switch(e.key){case "ArrowDown":e.preventDefault(),this.moveHighlight(1);break;case "ArrowUp":e.preventDefault(),this.moveHighlight(-1);break;case "Enter":case " ":e.preventDefault(),this.selectHighlighted();break;case "Home":e.preventDefault(),this.highlightFirst();break;case "End":e.preventDefault(),this.highlightLast();break;case "Escape":e.preventDefault();break;default:e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.handleTypeAhead(e.key);break}}moveHighlight(e){let t=this.options.map((r,d)=>({opt:r,idx:d})).filter(({opt:r})=>!r.disabled).map(({idx:r})=>r);if(t.length===0)return;let o=t.findIndex(r=>r===this.highlightedIndex)+e;if(o>=0&&o<t.length){let r=t[o];r!==void 0&&(this.highlightedIndex=r,this.scrollToHighlighted());}else if(e===1&&o>=t.length){let r=t[0];r!==void 0&&(this.highlightedIndex=r,this.scrollToHighlighted());}else if(e===-1&&o<0){let r=t[t.length-1];r!==void 0&&(this.highlightedIndex=r,this.scrollToHighlighted());}}highlightFirst(){let e=this.options.findIndex(t=>!t.disabled);e>=0&&(this.highlightedIndex=e,this.scrollToHighlighted());}highlightLast(){let e=this.options.map((t,n)=>({opt:t,idx:n})).filter(({opt:t})=>!t.disabled).map(({idx:t})=>t);if(e.length>0){let t=e[e.length-1];t!==void 0&&(this.highlightedIndex=t,this.scrollToHighlighted());}}scrollToHighlighted(){setTimeout(()=>{let e=document.getElementById("choice-option-"+this.highlightedIndex);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"});},0);}selectHighlighted(){let e=this.options[this.highlightedIndex];e&&!e.disabled&&this.onOptionClick(e.value);}handleTypeAhead(e){this.searchText+=e.toLowerCase();let t=this.options.findIndex(n=>!n.disabled&&n.label.toLowerCase().startsWith(this.searchText));t>=0&&(this.highlightedIndex=t,this.scrollToHighlighted()),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout(()=>{this.searchText="";},1e3);}onOptionClick(e){this.choiceSelected.emit(e);}onFreeTextSubmit(){let e=this.freeTextValue.trim();e&&(this.freeTextValue="",this.choiceSelected.emit(e));}onFreeTextKeyDown(e){e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.onFreeTextSubmit());}renderLabelMarkdown(e){return B(this,null,function*(){if(!e){this.renderedLabelSubject.next(this.sanitizer.bypassSecurityTrustHtml(""));return}try{let t=yield this.markdownService.parse(e);this.renderedLabelSubject.next(this.sanitizer.bypassSecurityTrustHtml(t));}catch(t){console.error("[CHOICE-SELECT] Error parsing label markdown:",t),this.renderedLabelSubject.next(this.sanitizer.bypassSecurityTrustHtml(e));}})}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-choice-select"]],viewQuery:function(t,n){if(t&1&&Pg(So,5)(Mo,5),t&2){let o;EC(o=IC())&&(n.buttonContainer=o.first),EC(o=IC())&&(n.freeTextInput=o.first);}},inputs:{options:"options",allowFreeText:"allowFreeText",labelHtml:"labelHtml",isVisible:"isVisible"},outputs:{choiceSelected:"choiceSelected"},features:[Tu],decls:1,vars:1,consts:[["buttonContainer",""],["freeTextInput",""],[1,"choice-container"],[1,"choice-label",3,"innerHTML"],["role","listbox","tabindex","0",1,"choice-buttons",3,"keydown"],["type","button","role","option",1,"choice-button",3,"highlighted","disabled","id"],[1,"free-text-section"],[1,"search-indicator"],["type","button","role","option",1,"choice-button",3,"click","disabled","id"],[1,"choice-button-label"],[1,"choice-button-icon"],[1,"free-text-hint"],[1,"free-text-input-row"],["type","text","placeholder","Type a custom answer\u2026","aria-label","Custom answer",1,"free-text-input",3,"ngModelChange","keydown","ngModel"],["type","button","aria-label","Send custom answer",1,"free-text-send-btn",3,"click","disabled"]],template:function(t,n){t&1&&Jw(0,Do,9,6,"div",2),t&2&&eC(n.isVisible?0:-1);},dependencies:[yt$1,wt$1,ti$1,Ye,Zn$1,cn,xb],styles:[".choice-container[_ngcontent-%COMP%]{width:100%;display:flex;flex-direction:column;gap:1rem}.choice-label[_ngcontent-%COMP%]{display:block;font-weight:500;color:var(--color-text);font-size:1rem;line-height:1.5}.choice-label[_ngcontent-%COMP%] p{margin:0 0 .5rem}.choice-label[_ngcontent-%COMP%] p:last-child{margin-bottom:0}.choice-label[_ngcontent-%COMP%] code{background:var(--color-code-bg);padding:.2em .4em;border-radius:4px;font-family:monospace;font-size:.9em}.choice-label[_ngcontent-%COMP%] strong{font-weight:600}.choice-buttons[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem;max-height:400px;overflow-y:auto;padding:.5rem;background:var(--color-background);border:2px solid var(--color-border);border-radius:12px;outline:none}.choice-buttons[_ngcontent-%COMP%]:focus-within{border-color:var(--color-primary);box-shadow:0 0 0 3px #007aff1a}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar{width:8px}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:var(--color-background);border-radius:4px}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.choice-buttons[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--color-text-secondary)}.choice-button[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;width:100%;padding:.75rem 1rem;border:1px solid var(--color-border);border-radius:8px;background:var(--color-background);color:var(--color-text);font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,system-ui,sans-serif;font-size:1rem;text-align:left;cursor:pointer;transition:all .2s ease}.choice-button[_ngcontent-%COMP%]:hover:not(:disabled):not(.highlighted){background:var(--color-bg-hover);border-color:var(--color-primary);transform:translate(2px)}.choice-button.highlighted[_ngcontent-%COMP%]{background:var(--color-primary);color:#fff;border-color:var(--color-primary);box-shadow:0 2px 8px #007aff4d}.choice-button.highlighted[_ngcontent-%COMP%] .choice-button-icon[_ngcontent-%COMP%]{color:#fff}.choice-button[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.choice-button[_ngcontent-%COMP%]:focus{outline:none}.choice-button-label[_ngcontent-%COMP%]{flex:1;line-height:1.5}.choice-button-icon[_ngcontent-%COMP%]{flex-shrink:0;margin-left:.5rem;font-size:1.2rem;width:1.2rem;height:1.2rem}.free-text-section[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.free-text-hint[_ngcontent-%COMP%]{font-size:.85rem;color:var(--color-text-secondary);font-style:italic}.free-text-input-row[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:center}.free-text-input[_ngcontent-%COMP%]{flex:1;padding:.625rem .875rem;border:1px solid var(--color-border);border-radius:8px;background:var(--color-background);color:var(--color-text);font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,system-ui,sans-serif;font-size:1rem;outline:none;transition:border-color .2s ease,box-shadow .2s ease}.free-text-input[_ngcontent-%COMP%]:focus{border-color:var(--color-primary);box-shadow:0 0 0 3px #007aff1a}.free-text-input[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary);opacity:.7}.free-text-send-btn[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;flex-shrink:0;border:none;border-radius:8px;background:var(--color-primary);color:#fff;cursor:pointer;transition:background .2s ease,opacity .2s ease}.free-text-send-btn[_ngcontent-%COMP%]:hover:not(:disabled){opacity:.9}.free-text-send-btn[_ngcontent-%COMP%]:disabled{opacity:.4;cursor:not-allowed}.free-text-send-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.2rem;width:1.2rem;height:1.2rem}.search-indicator[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.5rem 1rem;background:var(--color-primary);color:#fff;border-radius:8px;font-size:.9rem;font-weight:500;animation:_ngcontent-%COMP%_fadeIn .2s ease}.search-indicator[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1rem;width:1rem;height:1rem;color:#fff}@keyframes _ngcontent-%COMP%_fadeIn{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@media(max-width:480px){.choice-container[_ngcontent-%COMP%]{gap:.75rem}.choice-label[_ngcontent-%COMP%]{font-size:.95rem}.choice-buttons[_ngcontent-%COMP%]{max-height:300px;gap:.375rem}.choice-button[_ngcontent-%COMP%]{font-size:.95rem;padding:.625rem .875rem}}@media print{.choice-buttons[_ngcontent-%COMP%]{max-height:none;overflow:visible}.search-indicator[_ngcontent-%COMP%]{display:none!important}}"],changeDetection:1})};function Ao(i,e){if(i&1){let t=lC();ws(0,"div",0)(1,"div",1)(2,"mat-icon"),GC(3,"lock_open"),pl()(),ws(4,"div",2)(5,"p",3),GC(6,"Authorization required"),pl(),ws(7,"p",4)(8,"strong"),GC(9),pl(),GC(10," needs your permission to continue. "),pl()(),ws(11,"div",5)(12,"button",6),Rg("click",function(){let o=If(t),r=gC();return wf(r.onCancel(o))}),GC(13,"Cancel"),pl(),ws(14,"button",7),Rg("click",function(){let o=If(t),r=gC();return wf(r.onAuthorize(o))}),ws(15,"mat-icon"),GC(16,"open_in_new"),pl(),GC(17," Authorize "),pl()()();}i&2&&(XE(9),Yg(e.integrationName));}var gt=class i{oauthService=g(O);pendingRequest=F(this.oauthService.pendingRequest$,{initialValue:null});onAuthorize(e){this.oauthService.openPopup(e);}onCancel(e){this.oauthService.cancelRequest(e);}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-oauth-request-panel"]],decls:1,vars:1,consts:[[1,"oauth-panel"],[1,"oauth-icon"],[1,"oauth-content"],[1,"oauth-title"],[1,"oauth-description"],[1,"oauth-actions"],["type","button",1,"oauth-btn","oauth-btn--cancel",3,"click"],["type","button",1,"oauth-btn","oauth-btn--authorize",3,"click"]],template:function(t,n){if(t&1&&Jw(0,Ao,18,1,"div",0),t&2){let o;eC((o=n.pendingRequest())?0:-1,o);}},dependencies:[yt$1,wt$1],styles:[".oauth-panel[_ngcontent-%COMP%]{display:flex;align-items:center;gap:1rem;padding:1rem;border:1px solid var(--color-border);border-radius:12px;background:var(--color-background);width:100%}@media(max-width:480px){.oauth-panel[_ngcontent-%COMP%]{flex-direction:column;align-items:flex-start}}.oauth-icon[_ngcontent-%COMP%]{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:2.5rem;height:2.5rem;border-radius:50%;background:var(--color-primary);color:#fff}.oauth-icon[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.25rem;width:1.25rem;height:1.25rem}.oauth-content[_ngcontent-%COMP%]{flex:1;min-width:0}.oauth-title[_ngcontent-%COMP%]{margin:0 0 .25rem;font-weight:600;font-size:.95rem;color:var(--color-text)}.oauth-description[_ngcontent-%COMP%]{margin:0;font-size:.875rem;color:var(--color-text-secondary)}.oauth-actions[_ngcontent-%COMP%]{display:flex;gap:.5rem;flex-shrink:0}.oauth-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;padding:.5rem 1rem;border-radius:8px;border:1px solid var(--color-border);font-size:.9rem;font-family:inherit;cursor:pointer;transition:all .2s ease}.oauth-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1rem;width:1rem;height:1rem}.oauth-btn--cancel[_ngcontent-%COMP%]{background:var(--color-background);color:var(--color-text-secondary)}.oauth-btn--cancel[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover);color:var(--color-text)}.oauth-btn--authorize[_ngcontent-%COMP%]{background:var(--color-primary);color:#fff;border-color:var(--color-primary)}.oauth-btn--authorize[_ngcontent-%COMP%]:hover{opacity:.9}"]})};var ut=class i{http=g(py);projectState=g(P$1);threadState=g(U);getBaseUrl(){return `/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/threads/${this.threadState.getSelectedThreadIdOrThrow()}/files`}uploadFile(e){let t=this.projectState.getSelectedProjectIdOrThrow(),n=this.threadState.getSelectedThreadIdOrThrow();return new R(o=>{let r=new FileReader;r.onload=()=>{let v=r.result.split(",")[1];this.http.post(`/api/projects/${t}/threads/${n}/upload`,{content:v,mimeType:e.type||"application/octet-stream",filename:e.name}).subscribe({next:y=>{o.next({success:y.success,filename:y.filename}),o.complete();},error:y=>o.error(y)});},r.onerror=()=>o.error(new Error("Failed to read file")),r.readAsDataURL(e);})}listFiles(){return this.http.get(this.getBaseUrl()).pipe(re(e=>e.files))}downloadFile(e){let t=encodeURIComponent(e);return this.http.get(`${this.getBaseUrl()}/${t}`,{responseType:"blob"})}deleteFile(e){let t=encodeURIComponent(e);return this.http.delete(`${this.getBaseUrl()}/${t}`)}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var ye=class i{fileApi=g(ut);eventStream=g(fe);filesSignal=Gi$1([]);isLoadingSignal=Gi$1(false);currentProjectSignal=Gi$1(null);currentThreadSignal=Gi$1(null);files=mT(()=>this.filesSignal());isLoading=mT(()=>this.isLoadingSignal());fileCount=mT(()=>this.filesSignal().length);constructor(){this.subscribeToFileEvents();}initializeForThread(e,t){this.currentProjectSignal.set(e),this.currentThreadSignal.set(t),this.refreshFileList();}clear(){this.filesSignal.set([]),this.currentProjectSignal.set(null),this.currentThreadSignal.set(null);}refreshFileList(){this.isLoadingSignal.set(true),this.fileApi.listFiles().subscribe({next:e=>{let t=e.map(n=>x$1(w$1({},n),{lastModified:new Date(n.lastModified)})).sort((n,o)=>o.lastModified.getTime()-n.lastModified.getTime());this.filesSignal.set(t),this.isLoadingSignal.set(false);},error:e=>{console.error("[FILE_EXCHANGE_STATE] Error loading files:",e),this.isLoadingSignal.set(false);}});}uploadFile(e){return B(this,null,function*(){return new Promise(t=>{this.fileApi.uploadFile(e).subscribe({next:()=>{this.refreshFileList(),t({success:true});},error:n=>{console.error("[FILE_EXCHANGE_STATE] Upload error:",n),t({success:false,error:n.message||"Upload failed"});}});})})}downloadAllFiles(){let e=this.filesSignal();if(e.length===0){console.warn("[FILE_EXCHANGE_STATE] No files to download");return}e.forEach((t,n)=>{setTimeout(()=>{this.downloadFile(t.filename);},n*300);});}downloadFile(e){this.fileApi.downloadFile(e).subscribe({next:t=>{let n=window.URL.createObjectURL(t),o=document.createElement("a");o.href=n,o.download=e,o.click(),window.URL.revokeObjectURL(n);},error:t=>{console.error("[FILE_EXCHANGE_STATE] Download error:",t);}});}deleteFile(e){return B(this,null,function*(){return new Promise(t=>{this.fileApi.deleteFile(e).subscribe({next:()=>{this.refreshFileList(),t({success:true});},error:n=>{console.error("[FILE_EXCHANGE_STATE] Delete error:",n),t({success:false,error:n.message||"Delete failed"});}});})})}subscribeToFileEvents(){this.eventStream.events$.pipe(kt(e=>e instanceof z),U$1()).subscribe(e=>{this.handleFileEvent(e);});}handleFileEvent(e){let t=this.filesSignal();switch(e.operation){case "created":{let n=e.timestamp,o=e.timestamp.lastIndexOf("-");if(o>0){let d=e.timestamp.substring(o+1);d.length===5&&/^[a-z0-9]+$/.test(d)&&(n=e.timestamp.substring(0,o));}let r={filename:e.filename,size:e.size||0,lastModified:new Date(n)};this.filesSignal.set([r,...t]);break}case "updated":{let n=t.filter(y=>y.filename!==e.filename),o=t.find(y=>y.filename===e.filename),r=e.timestamp,d=e.timestamp.lastIndexOf("-");if(d>0){let y=e.timestamp.substring(d+1);y.length===5&&/^[a-z0-9]+$/.test(y)&&(r=e.timestamp.substring(0,d));}let v={filename:e.filename,size:e.size||o?.size||0,lastModified:new Date(r)};this.filesSignal.set([v,...n]);break}case "deleted":{let n=t.filter(o=>o.filename!==e.filename);this.filesSignal.set(n);break}}}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};function Fo(i,e){if(i&1&&Sg(0,"div",1),i&2){let t=gC();bg("innerHTML",t.renderedContent,aE);}}function Ro(i,e){if(i&1&&Sg(0,"iframe",2),i&2){let t=gC();bg("srcdoc",t.content,aE);}}function Ho(i,e){if(i&1&&(ws(0,"pre",3),GC(1),pl()),i&2){let t=gC();XE(),Yg(t.content);}}var ht=class i{content="";format="text";renderedContent="";sanitizer=g(bS);markdownService=g(Z);ngOnChanges(e){(e.content||e.format)&&this.renderContent();}renderContent(){this.format==="markdown"?this.renderMarkdown():this.format==="json"&&this.formatJson();}renderMarkdown(){return B(this,null,function*(){try{let e=yield this.markdownService.parse(this.content);this.renderedContent=this.sanitizer.bypassSecurityTrustHtml(e);}catch(e){console.error("[CONTENT_RENDERER] Error rendering markdown:",e),this.content=this.content;}})}formatJson(){try{let e=JSON.parse(this.content);this.content=JSON.stringify(e,null,2);}catch(e){console.error("[CONTENT_RENDERER] Error formatting JSON:",e);}}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-content-renderer"]],inputs:{content:"content",format:"format"},features:[Tu],decls:4,vars:2,consts:[[1,"content-renderer",3,"ngClass"],[1,"markdown-content",3,"innerHTML"],["sandbox","allow-same-origin",1,"html-viewer",3,"srcdoc"],[1,"code-content"]],template:function(t,n){t&1&&(ws(0,"div",0),Jw(1,Fo,1,1,"div",1)(2,Ro,1,1,"iframe",2)(3,Ho,2,1,"pre",3),pl()),t&2&&(bg("ngClass","format-"+n.format),XE(),eC(n.format==="markdown"?1:n.format==="html"?2:3));},dependencies:[qm,Sb],styles:[".content-renderer[_ngcontent-%COMP%]{width:100%;height:100%;overflow:auto;padding:1rem}.markdown-content[_ngcontent-%COMP%]{line-height:1.6;color:var(--color-text)}.code-content[_ngcontent-%COMP%]{font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:.9rem;line-height:1.5;margin:0;white-space:pre-wrap;word-wrap:break-word;color:var(--color-text)}.format-json[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%]{color:var(--color-code-text, #d63384)}.format-yaml[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%], .format-text[_ngcontent-%COMP%] .code-content[_ngcontent-%COMP%]{color:var(--color-text)}.html-viewer[_ngcontent-%COMP%]{width:100%;height:100%;min-height:400px;border:1px solid var(--color-border);border-radius:8px;background:#fff}"],changeDetection:1})};var we=class i{http=g(py);MAX_FILE_SIZE=20*1024*1024;isViewable(e){return e<=this.MAX_FILE_SIZE}isFormatViewable(e){let t=e.split(".").pop()?.toLowerCase();return !(t&&["pdf","png","jpg","jpeg","gif","webp","zip","tar","gz","exe","bin","doc","docx","xls","xlsx","ppt","pptx"].includes(t))}detectFormat(e){switch(e.split(".").pop()?.toLowerCase()){case "md":return "markdown";case "json":return "json";case "yaml":case "yml":return "yaml";case "html":case "htm":return "html";default:return "text"}}loadFileContent(e,t,n){let o=`/api/projects/${e}/threads/${t}/files/${encodeURIComponent(n)}`,r=this.detectFormat(n);return this.http.get(o,{responseType:"text",observe:"response"}).pipe(re(d=>{let v=d.body||"",y=new Blob([v]).size;return {content:v,format:r,filename:n,size:y}}),ya(d=>(console.error("[CONTENT_VIEWER] Error loading file:",n,d),Vy(()=>new Error(`Failed to load file: ${d.message||"Unknown error"}`)))))}formatSize(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};function Vo(i,e){if(i&1){let t=lC();ws(0,"button",12),Rg("click",function(){If(t);let o=gC();return wf(o.download())}),ws(1,"mat-icon"),GC(2,"download"),pl()();}}function Lo(i,e){i&1&&(ws(0,"div",9),Sg(1,"mat-spinner",13),ws(2,"p"),GC(3,"Loading file content..."),pl()());}function zo(i,e){if(i&1){let t=lC();ws(0,"div",10)(1,"mat-icon",14),GC(2,"error_outline"),pl(),ws(3,"p",15),GC(4),pl(),ws(5,"button",16),Rg("click",function(){If(t);let o=gC();return wf(o.download())}),ws(6,"mat-icon"),GC(7,"download"),pl(),GC(8," Download instead "),pl()();}if(i&2){let t=gC();XE(4),Yg(t.error);}}function No(i,e){if(i&1&&Sg(0,"app-content-renderer",11),i&2){let t=gC();bg("content",t.fileContent.content)("format",t.fileContent.format);}}var ft=class i{destroy$=new ue;file;projectName;threadId;closeViewer=new vt$1;contentService=g(we);eventStream=g(fe);fileContent=null;isLoading=false;error="";ngOnInit(){this.loadContent(),this.subscribeToFileEvents();}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete();}loadContent(){if(!this.contentService.isViewable(this.file.size)){this.error=`File too large to view (${this.contentService.formatSize(this.file.size)}). Maximum size: 20 MB.`;return}this.isLoading=true,this.error="",this.contentService.loadFileContent(this.projectName,this.threadId,this.file.filename).subscribe({next:e=>{console.log("[CONTENT_VIEWER] Content loaded:",e.filename),this.fileContent=e,this.isLoading=false;},error:e=>{console.error("[CONTENT_VIEWER] Error loading content:",e),this.error=e.message||"Failed to load file content",this.isLoading=false;}});}onClose(){this.closeViewer.emit();}download(){let e=new Blob([this.fileContent?.content||""],{type:"text/plain"}),t=window.URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download=this.file.filename,n.click(),window.URL.revokeObjectURL(t);}formatSize(e){return this.contentService.formatSize(e)}subscribeToFileEvents(){this.eventStream.events$.pipe(kt(e=>e instanceof z),kt(e=>e.filename===this.file.filename),kt(e=>e.operation==="updated"),wd(this.destroy$)).subscribe(e=>{console.log("[CONTENT_VIEWER] File updated event received, reloading:",e.filename),e.size&&(this.file.size=e.size),this.loadContent();});}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-content-viewer"]],inputs:{file:"file",projectName:"projectName",threadId:"threadId"},outputs:{closeViewer:"closeViewer"},decls:16,vars:6,consts:[[1,"viewer-container"],[1,"viewer-header"],[1,"header-info"],[1,"filename"],[1,"file-size"],[1,"header-actions"],["mat-icon-button","","title","Download","type","button"],["mat-icon-button","","title","Close","type","button",3,"click"],[1,"viewer-content"],[1,"loading-state"],[1,"error-state"],[3,"content","format"],["mat-icon-button","","title","Download","type","button",3,"click"],["diameter","48"],[1,"error-icon"],[1,"error-message"],["mat-raised-button","","color","primary","type","button",3,"click"]],template:function(t,n){t&1&&(ws(0,"div",0)(1,"div",1)(2,"div",2)(3,"span",3),GC(4),pl(),ws(5,"span",4),GC(6),pl()(),ws(7,"div",5),Jw(8,Vo,3,0,"button",6),ws(9,"button",7),Rg("click",function(){return n.onClose()}),ws(10,"mat-icon"),GC(11,"chevron_right"),pl()()()(),ws(12,"div",8),Jw(13,Lo,4,0,"div",9),Jw(14,zo,9,1,"div",10),Jw(15,No,1,2,"app-content-renderer",11),pl()()),t&2&&(XE(4),Yg(n.file.filename),XE(2),Yg(n.formatSize(n.file.size)),XE(2),eC(n.fileContent&&!n.isLoading&&!n.error?8:-1),XE(5),eC(n.isLoading?13:-1),XE(),eC(n.error?14:-1),XE(),eC(n.fileContent&&!n.isLoading&&!n.error?15:-1));},dependencies:[qm,yt$1,wt$1,hr$1,pr$1,Gn$1,Et,yt$2,ht],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;height:100%}.viewer-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;height:100%;background:var(--color-bg)}.viewer-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:1rem;border-bottom:1px solid var(--color-border);background:var(--color-bg);flex-shrink:0}.header-info[_ngcontent-%COMP%]{flex:1;min-width:0;display:flex;flex-direction:column;gap:.25rem}.filename[_ngcontent-%COMP%]{font-weight:500;color:var(--color-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.file-size[_ngcontent-%COMP%]{font-size:.75rem;color:var(--color-text-secondary)}.header-actions[_ngcontent-%COMP%]{display:flex;gap:.25rem;flex-shrink:0}.viewer-content[_ngcontent-%COMP%]{flex:1;overflow:auto;background:var(--color-bg)}.loading-state[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:1rem;color:var(--color-text-secondary)}.error-state[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:1rem;padding:2rem;text-align:center}.error-icon[_ngcontent-%COMP%]{font-size:3rem;width:3rem;height:3rem;color:var(--color-error)}.error-message[_ngcontent-%COMP%]{color:var(--color-text);margin:0;max-width:400px}"],changeDetection:1})};var bt=6048e5,zn=864e5;var Dt=Symbol.for("constructDateFrom");function D(i,e){return typeof i=="function"?i(e):i&&typeof i=="object"&&Dt in i?i[Dt](e):i instanceof Date?new i.constructor(e):new Date(e)}function P(i,e){return D(e||i,i)}function $n(i,e,t){let n=P(i,t?.in);return isNaN(e)?D(i,NaN):(n.setDate(n.getDate()+e),n)}var Wo={};function de(){return Wo}function ne(i,e){let t=de(),n=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,o=P(i,e?.in),r=o.getDay(),d=(r<n?7:0)+r-n;return o.setDate(o.getDate()-d),o.setHours(0,0,0,0),o}function pe(i,e){return ne(i,x$1(w$1({},e),{weekStartsOn:1}))}function Ct(i,e){let t=P(i,e?.in),n=t.getFullYear(),o=D(t,0);o.setFullYear(n+1,0,4),o.setHours(0,0,0,0);let r=pe(o),d=D(t,0);d.setFullYear(n,0,4),d.setHours(0,0,0,0);let v=pe(d);return t.getTime()>=r.getTime()?n+1:t.getTime()>=v.getTime()?n:n-1}function At(i){let e=P(i),t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+i-+t}function Te(i,...e){let t=D.bind(null,e.find(n=>typeof n=="object"));return e.map(t)}function Se(i,e){let t=P(i,e?.in);return t.setHours(0,0,0,0),t}function vt(i,e,t){let[n,o]=Te(t?.in,i,e),r=Se(n),d=Se(o),v=+r-At(r),y=+d-At(d);return Math.round((v-y)/zn)}function jn(i,e){let t=Ct(i,e),n=D(i,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),pe(n)}function Un(i){return D(i,Date.now())}function Bn(i,e,t){let[n,o]=Te(t?.in,i,e);return +Se(n)==+Se(o)}function Wn(i){return i instanceof Date||typeof i=="object"&&Object.prototype.toString.call(i)==="[object Date]"}function qn(i){return !(!Wn(i)&&typeof i!="number"||isNaN(+P(i)))}function Gn(i,e,t){let[n,o]=Te(t?.in,i,e),r=Yn(n,o),d=Math.abs(vt(n,o));n.setDate(n.getDate()-r*d);let v=+(Yn(n,o)===-r),y=r*(d-v);return y===0?0:y}function Yn(i,e){let t=i.getFullYear()-e.getFullYear()||i.getMonth()-e.getMonth()||i.getDate()-e.getDate()||i.getHours()-e.getHours()||i.getMinutes()-e.getMinutes()||i.getSeconds()-e.getSeconds()||i.getMilliseconds()-e.getMilliseconds();return t<0?-1:t>0?1:t}function Qn(i,e){let t=P(i,e?.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}var qo={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Xn=(i,e,t)=>{let n,o=qo[i];return typeof o=="string"?n=o:e===1?n=o.one:n=o.other.replace("{{count}}",e.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n};function _t(i){return (e={})=>{let t=e.width?String(e.width):i.defaultWidth;return i.formats[t]||i.formats[i.defaultWidth]}}var Yo={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Go={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Qo={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Kn={date:_t({formats:Yo,defaultWidth:"full"}),time:_t({formats:Go,defaultWidth:"full"}),dateTime:_t({formats:Qo,defaultWidth:"full"})};var Xo={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Jn=(i,e,t,n)=>Xo[i];function Me(i){return (e,t)=>{let n=t?.context?String(t.context):"standalone",o;if(n==="formatting"&&i.formattingValues){let d=i.defaultFormattingWidth||i.defaultWidth,v=t?.width?String(t.width):d;o=i.formattingValues[v]||i.formattingValues[d];}else {let d=i.defaultWidth,v=t?.width?String(t.width):i.defaultWidth;o=i.values[v]||i.values[d];}let r=i.argumentCallback?i.argumentCallback(e):e;return o[r]}}var Ko={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Jo={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Zo={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},er={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},tr={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},nr={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},ir=(i,e)=>{let t=Number(i),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},Zn={ordinalNumber:ir,era:Me({values:Ko,defaultWidth:"wide"}),quarter:Me({values:Jo,defaultWidth:"wide",argumentCallback:i=>i-1}),month:Me({values:Zo,defaultWidth:"wide"}),day:Me({values:er,defaultWidth:"wide"}),dayPeriod:Me({values:tr,defaultWidth:"wide",formattingValues:nr,defaultFormattingWidth:"wide"})};function Ee(i){return (e,t={})=>{let n=t.width,o=n&&i.matchPatterns[n]||i.matchPatterns[i.defaultMatchWidth],r=e.match(o);if(!r)return null;let d=r[0],v=n&&i.parsePatterns[n]||i.parsePatterns[i.defaultParseWidth],y=Array.isArray(v)?rr(v,F=>F.test(d)):or(v,F=>F.test(d)),q;q=i.valueCallback?i.valueCallback(y):y,q=t.valueCallback?t.valueCallback(q):q;let A=e.slice(d.length);return {value:q,rest:A}}}function or(i,e){for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&e(i[t]))return t}function rr(i,e){for(let t=0;t<i.length;t++)if(e(i[t]))return t}function ei(i){return (e,t={})=>{let n=e.match(i.matchPattern);if(!n)return null;let o=n[0],r=e.match(i.parsePattern);if(!r)return null;let d=i.valueCallback?i.valueCallback(r[0]):r[0];d=t.valueCallback?t.valueCallback(d):d;let v=e.slice(o.length);return {value:d,rest:v}}}var ar=/^(\d+)(th|st|nd|rd)?/i,sr=/\d+/i,cr={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},lr={any:[/^b/i,/^(a|c)/i]},dr={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},mr={any:[/1/i,/2/i,/3/i,/4/i]},pr={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},gr={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},ur={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},hr={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},fr={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},br={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},ti={ordinalNumber:ei({matchPattern:ar,parsePattern:sr,valueCallback:i=>parseInt(i,10)}),era:Ee({matchPatterns:cr,defaultMatchWidth:"wide",parsePatterns:lr,defaultParseWidth:"any"}),quarter:Ee({matchPatterns:dr,defaultMatchWidth:"wide",parsePatterns:mr,defaultParseWidth:"any",valueCallback:i=>i+1}),month:Ee({matchPatterns:pr,defaultMatchWidth:"wide",parsePatterns:gr,defaultParseWidth:"any"}),day:Ee({matchPatterns:ur,defaultMatchWidth:"wide",parsePatterns:hr,defaultParseWidth:"any"}),dayPeriod:Ee({matchPatterns:fr,defaultMatchWidth:"any",parsePatterns:br,defaultParseWidth:"any"})};var Ft={code:"en-US",formatDistance:Xn,formatLong:Kn,formatRelative:Jn,localize:Zn,match:ti,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ni(i,e){let t=P(i,e?.in);return vt(t,Qn(t))+1}function ii(i,e){let t=P(i,e?.in),n=+pe(t)-+jn(t);return Math.round(n/bt)+1}function xt(i,e){let t=P(i,e?.in),n=t.getFullYear(),o=de(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,d=D(e?.in||i,0);d.setFullYear(n+1,0,r),d.setHours(0,0,0,0);let v=ne(d,e),y=D(e?.in||i,0);y.setFullYear(n,0,r),y.setHours(0,0,0,0);let q=ne(y,e);return +t>=+v?n+1:+t>=+q?n:n-1}function oi(i,e){let t=de(),n=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,o=xt(i,e),r=D(e?.in||i,0);return r.setFullYear(o,0,n),r.setHours(0,0,0,0),ne(r,e)}function ri(i,e){let t=P(i,e?.in),n=+ne(t,e)-+oi(t,e);return Math.round(n/bt)+1}function w(i,e){let t=i<0?"-":"",n=Math.abs(i).toString().padStart(e,"0");return t+n}var ie={y(i,e){let t=i.getFullYear(),n=t>0?t:1-t;return w(e==="yy"?n%100:n,e.length)},M(i,e){let t=i.getMonth();return e==="M"?String(t+1):w(t+1,2)},d(i,e){return w(i.getDate(),e.length)},a(i,e){let t=i.getHours()/12>=1?"pm":"am";switch(e){case "a":case "aa":return t.toUpperCase();case "aaa":return t;case "aaaaa":return t[0];default:return t==="am"?"a.m.":"p.m."}},h(i,e){return w(i.getHours()%12||12,e.length)},H(i,e){return w(i.getHours(),e.length)},m(i,e){return w(i.getMinutes(),e.length)},s(i,e){return w(i.getSeconds(),e.length)},S(i,e){let t=e.length,n=i.getMilliseconds(),o=Math.trunc(n*Math.pow(10,t-3));return w(o,e.length)}};var Oe={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Rt={G:function(i,e,t){let n=i.getFullYear()>0?1:0;switch(e){case "G":case "GG":case "GGG":return t.era(n,{width:"abbreviated"});case "GGGGG":return t.era(n,{width:"narrow"});default:return t.era(n,{width:"wide"})}},y:function(i,e,t){if(e==="yo"){let n=i.getFullYear(),o=n>0?n:1-n;return t.ordinalNumber(o,{unit:"year"})}return ie.y(i,e)},Y:function(i,e,t,n){let o=xt(i,n),r=o>0?o:1-o;if(e==="YY"){let d=r%100;return w(d,2)}return e==="Yo"?t.ordinalNumber(r,{unit:"year"}):w(r,e.length)},R:function(i,e){let t=Ct(i);return w(t,e.length)},u:function(i,e){let t=i.getFullYear();return w(t,e.length)},Q:function(i,e,t){let n=Math.ceil((i.getMonth()+1)/3);switch(e){case "Q":return String(n);case "QQ":return w(n,2);case "Qo":return t.ordinalNumber(n,{unit:"quarter"});case "QQQ":return t.quarter(n,{width:"abbreviated",context:"formatting"});case "QQQQQ":return t.quarter(n,{width:"narrow",context:"formatting"});default:return t.quarter(n,{width:"wide",context:"formatting"})}},q:function(i,e,t){let n=Math.ceil((i.getMonth()+1)/3);switch(e){case "q":return String(n);case "qq":return w(n,2);case "qo":return t.ordinalNumber(n,{unit:"quarter"});case "qqq":return t.quarter(n,{width:"abbreviated",context:"standalone"});case "qqqqq":return t.quarter(n,{width:"narrow",context:"standalone"});default:return t.quarter(n,{width:"wide",context:"standalone"})}},M:function(i,e,t){let n=i.getMonth();switch(e){case "M":case "MM":return ie.M(i,e);case "Mo":return t.ordinalNumber(n+1,{unit:"month"});case "MMM":return t.month(n,{width:"abbreviated",context:"formatting"});case "MMMMM":return t.month(n,{width:"narrow",context:"formatting"});default:return t.month(n,{width:"wide",context:"formatting"})}},L:function(i,e,t){let n=i.getMonth();switch(e){case "L":return String(n+1);case "LL":return w(n+1,2);case "Lo":return t.ordinalNumber(n+1,{unit:"month"});case "LLL":return t.month(n,{width:"abbreviated",context:"standalone"});case "LLLLL":return t.month(n,{width:"narrow",context:"standalone"});default:return t.month(n,{width:"wide",context:"standalone"})}},w:function(i,e,t,n){let o=ri(i,n);return e==="wo"?t.ordinalNumber(o,{unit:"week"}):w(o,e.length)},I:function(i,e,t){let n=ii(i);return e==="Io"?t.ordinalNumber(n,{unit:"week"}):w(n,e.length)},d:function(i,e,t){return e==="do"?t.ordinalNumber(i.getDate(),{unit:"date"}):ie.d(i,e)},D:function(i,e,t){let n=ni(i);return e==="Do"?t.ordinalNumber(n,{unit:"dayOfYear"}):w(n,e.length)},E:function(i,e,t){let n=i.getDay();switch(e){case "E":case "EE":case "EEE":return t.day(n,{width:"abbreviated",context:"formatting"});case "EEEEE":return t.day(n,{width:"narrow",context:"formatting"});case "EEEEEE":return t.day(n,{width:"short",context:"formatting"});default:return t.day(n,{width:"wide",context:"formatting"})}},e:function(i,e,t,n){let o=i.getDay(),r=(o-n.weekStartsOn+8)%7||7;switch(e){case "e":return String(r);case "ee":return w(r,2);case "eo":return t.ordinalNumber(r,{unit:"day"});case "eee":return t.day(o,{width:"abbreviated",context:"formatting"});case "eeeee":return t.day(o,{width:"narrow",context:"formatting"});case "eeeeee":return t.day(o,{width:"short",context:"formatting"});default:return t.day(o,{width:"wide",context:"formatting"})}},c:function(i,e,t,n){let o=i.getDay(),r=(o-n.weekStartsOn+8)%7||7;switch(e){case "c":return String(r);case "cc":return w(r,e.length);case "co":return t.ordinalNumber(r,{unit:"day"});case "ccc":return t.day(o,{width:"abbreviated",context:"standalone"});case "ccccc":return t.day(o,{width:"narrow",context:"standalone"});case "cccccc":return t.day(o,{width:"short",context:"standalone"});default:return t.day(o,{width:"wide",context:"standalone"})}},i:function(i,e,t){let n=i.getDay(),o=n===0?7:n;switch(e){case "i":return String(o);case "ii":return w(o,e.length);case "io":return t.ordinalNumber(o,{unit:"day"});case "iii":return t.day(n,{width:"abbreviated",context:"formatting"});case "iiiii":return t.day(n,{width:"narrow",context:"formatting"});case "iiiiii":return t.day(n,{width:"short",context:"formatting"});default:return t.day(n,{width:"wide",context:"formatting"})}},a:function(i,e,t){let o=i.getHours()/12>=1?"pm":"am";switch(e){case "a":case "aa":return t.dayPeriod(o,{width:"abbreviated",context:"formatting"});case "aaa":return t.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case "aaaaa":return t.dayPeriod(o,{width:"narrow",context:"formatting"});default:return t.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(i,e,t){let n=i.getHours(),o;switch(n===12?o=Oe.noon:n===0?o=Oe.midnight:o=n/12>=1?"pm":"am",e){case "b":case "bb":return t.dayPeriod(o,{width:"abbreviated",context:"formatting"});case "bbb":return t.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case "bbbbb":return t.dayPeriod(o,{width:"narrow",context:"formatting"});default:return t.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(i,e,t){let n=i.getHours(),o;switch(n>=17?o=Oe.evening:n>=12?o=Oe.afternoon:n>=4?o=Oe.morning:o=Oe.night,e){case "B":case "BB":case "BBB":return t.dayPeriod(o,{width:"abbreviated",context:"formatting"});case "BBBBB":return t.dayPeriod(o,{width:"narrow",context:"formatting"});default:return t.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(i,e,t){if(e==="ho"){let n=i.getHours()%12;return n===0&&(n=12),t.ordinalNumber(n,{unit:"hour"})}return ie.h(i,e)},H:function(i,e,t){return e==="Ho"?t.ordinalNumber(i.getHours(),{unit:"hour"}):ie.H(i,e)},K:function(i,e,t){let n=i.getHours()%12;return e==="Ko"?t.ordinalNumber(n,{unit:"hour"}):w(n,e.length)},k:function(i,e,t){let n=i.getHours();return n===0&&(n=24),e==="ko"?t.ordinalNumber(n,{unit:"hour"}):w(n,e.length)},m:function(i,e,t){return e==="mo"?t.ordinalNumber(i.getMinutes(),{unit:"minute"}):ie.m(i,e)},s:function(i,e,t){return e==="so"?t.ordinalNumber(i.getSeconds(),{unit:"second"}):ie.s(i,e)},S:function(i,e){return ie.S(i,e)},X:function(i,e,t){let n=i.getTimezoneOffset();if(n===0)return "Z";switch(e){case "X":return si(n);case "XXXX":case "XX":return ge(n);default:return ge(n,":")}},x:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case "x":return si(n);case "xxxx":case "xx":return ge(n);default:return ge(n,":")}},O:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case "O":case "OO":case "OOO":return "GMT"+ai(n,":");default:return "GMT"+ge(n,":")}},z:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case "z":case "zz":case "zzz":return "GMT"+ai(n,":");default:return "GMT"+ge(n,":")}},t:function(i,e,t){let n=Math.trunc(+i/1e3);return w(n,e.length)},T:function(i,e,t){return w(+i,e.length)}};function ai(i,e=""){let t=i>0?"-":"+",n=Math.abs(i),o=Math.trunc(n/60),r=n%60;return r===0?t+String(o):t+String(o)+e+w(r,2)}function si(i,e){return i%60===0?(i>0?"-":"+")+w(Math.abs(i)/60,2):ge(i,e)}function ge(i,e=""){let t=i>0?"-":"+",n=Math.abs(i),o=w(Math.trunc(n/60),2),r=w(n%60,2);return t+o+e+r}var ci=(i,e)=>{switch(i){case "P":return e.date({width:"short"});case "PP":return e.date({width:"medium"});case "PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},li=(i,e)=>{switch(i){case "p":return e.time({width:"short"});case "pp":return e.time({width:"medium"});case "ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},Cr=(i,e)=>{let t=i.match(/(P+)(p+)?/)||[],n=t[1],o=t[2];if(!o)return ci(i,e);let r;switch(n){case "P":r=e.dateTime({width:"short"});break;case "PP":r=e.dateTime({width:"medium"});break;case "PPP":r=e.dateTime({width:"long"});break;default:r=e.dateTime({width:"full"});break}return r.replace("{{date}}",ci(n,e)).replace("{{time}}",li(o,e))},di={p:li,P:Cr};var vr=/^D+$/,_r=/^Y+$/,xr=["D","DD","YY","YYYY"];function mi(i){return vr.test(i)}function pi(i){return _r.test(i)}function gi(i,e,t){let n=yr(i,e,t);if(console.warn(n),xr.includes(i))throw new RangeError(n)}function yr(i,e,t){let n=i[0]==="Y"?"years":"days of the month";return `Use \`${i.toLowerCase()}\` instead of \`${i}\` (in \`${e}\`) for formatting ${n} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var wr=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Tr=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Sr=/^'([^]*?)'?$/,Mr=/''/g,Er=/[a-zA-Z]/;function Ht(i,e,t){let n=de(),o=n.locale??Ft,r=n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,d=n.weekStartsOn??n.locale?.options?.weekStartsOn??0,v=P(i,t?.in);if(!qn(v))throw new RangeError("Invalid time value");let y=e.match(Tr).map(A=>{let F=A[0];if(F==="p"||F==="P"){let Mt=di[F];return Mt(A,o.formatLong)}return A}).join("").match(wr).map(A=>{if(A==="''")return {isToken:false,value:"'"};let F=A[0];if(F==="'")return {isToken:false,value:Or(A)};if(Rt[F])return {isToken:true,value:A};if(F.match(Er))throw new RangeError("Format string contains an unescaped latin alphabet character `"+F+"`");return {isToken:false,value:A}});o.localize.preprocessor&&(y=o.localize.preprocessor(v,y));let q={firstWeekContainsDate:r,weekStartsOn:d,locale:o};return y.map(A=>{if(!A.isToken)return A.value;let F=A.value;(pi(F)||mi(F))&&gi(F,e,String(i));let Mt=Rt[F[0]];return Mt(v,F,o.localize,q)}).join("")}function Or(i){let e=i.match(Sr);return e?e[1].replace(Mr,"'"):i}function ui(i,e,t){return $n(i,-1,t)}function hi(i,e){return Bn(D(i,i),ui(Un(i)))}function fi(i){if(!i||isNaN(i.getTime()))return "unknown";let e=new Date,t=Ht(i,"HH:mm:ss"),n=e.getTime()-i.getTime(),o=Math.floor(n/(1e3*60));if(o<1)return `just now (${t})`;if(o<60)return `${o} min ago (${t})`;let r=Math.floor(n/(1e3*60*60));if(r<24)return `${r}h ago (${t})`;if(hi(i))return `yesterday ${t}`;let d=Gn(e,i);return d<7?`${d}d ago ${t}`:`${Ht(i,"dd/MM/yyyy")} ${t}`}var Pr=(i,e)=>e.filename;function kr(i,e){if(i&1){let t=lC();ws(0,"button",11),Rg("click",function(){If(t);let o=gC(2);return wf(o.downloadAll())}),ws(1,"mat-icon"),GC(2,"download_for_offline"),pl()();}}function Ir(i,e){i&1&&(ws(0,"div",10),Sg(1,"span",12),ws(2,"span",13),GC(3,"Loading files..."),pl()());}function Dr(i,e){i&1&&(ws(0,"div",14)(1,"mat-icon",15),GC(2,"folder_open"),pl(),ws(3,"p",16),GC(4,"No files in exchange space"),pl(),ws(5,"p",17),GC(6,"Upload files to share with the agent"),pl()());}function Ar(i,e){if(i&1){let t=lC();ws(0,"button",28),Rg("click",function(){If(t);let o=gC().$implicit,r=gC(4);return wf(r.viewFile(o))}),ws(1,"mat-icon"),GC(2,"visibility"),pl()();}}function Fr(i,e){if(i&1){let t=lC();ws(0,"div",18)(1,"div",19)(2,"mat-icon",20),GC(3),pl(),ws(4,"div",21)(5,"span",22),GC(6),pl(),ws(7,"span",23),GC(8),pl()()(),ws(9,"div",24),Jw(10,Ar,3,0,"button",25),ws(11,"button",26),Rg("click",function(){let o=If(t).$implicit,r=gC(4);return wf(r.download(o))}),ws(12,"mat-icon"),GC(13,"download"),pl()(),ws(14,"button",27),Rg("click",function(){let o=If(t).$implicit,r=gC(4);return wf(r.delete(o))}),ws(15,"mat-icon"),GC(16,"delete"),pl()()()();}if(i&2){let t=e.$implicit,n=gC(4);XE(3),Yg(n.getFileIcon(t.filename)),XE(2),bg("title",t.filename),XE(),Yg(t.filename),XE(2),Qg("",n.formatSize(t.size)," \u2022 ",n.formatDate(t.lastModified)),XE(2),eC(n.canViewFile(t)?10:-1);}}function Rr(i,e){if(i&1&&rC(0,Fr,17,6,"div",18,Pr),i&2){let t=gC(3);oC(t.files());}}function Hr(i,e){if(i&1&&Jw(0,Dr,7,0,"div",14)(1,Rr,2,0),i&2){let t=gC(2);eC(t.files().length===0?0:1);}}function Vr(i,e){if(i&1){let t=lC();ws(0,"div",0)(1,"div",2)(2,"div",3)(3,"h3",4),GC(4,"Exchange"),pl(),ws(5,"span",5),GC(6),pl()(),ws(7,"div",6),Jw(8,kr,3,0,"button",7),ws(9,"button",8),Rg("click",function(){If(t);let o=gC();return wf(o.close())}),ws(10,"mat-icon"),GC(11,"chevron_right"),pl()()()(),ws(12,"div",9),Jw(13,Ir,4,0,"div",10)(14,Hr,2,1),pl()();}if(i&2){let t=gC();XE(6),vl("(",t.files().length,")"),XE(2),eC(t.files().length>0?8:-1),XE(5),eC(t.isLoading()?13:14);}}function Lr(i,e){if(i&1){let t=lC();ws(0,"app-content-viewer",29),Rg("closeViewer",function(){If(t);let o=gC();return wf(o.backToList())}),pl();}if(i&2){let t=gC();bg("file",t.currentFile)("projectName",t.projectName)("threadId",t.threadId);}}var yt=class i{projectName;threadId;closeDrawer=new vt$1;fileExchangeState=g(ye);contentViewerService=g(we);files=this.fileExchangeState.files;isLoading=this.fileExchangeState.isLoading;viewerState="list";currentFile=null;close(){this.viewerState==="content"?this.backToList():this.closeDrawer.emit();}viewFile(e){this.currentFile=e,this.viewerState="content";}backToList(){this.viewerState="list",this.currentFile=null;}downloadAll(){this.fileExchangeState.downloadAllFiles();}download(e){this.fileExchangeState.downloadFile(e.filename);}delete(e){return B(this,null,function*(){if(!confirm(`Delete file "${e.filename}"?`))return;let n=yield this.fileExchangeState.deleteFile(e.filename);n.success||alert(`Failed to delete file: ${n.error}`);})}getFileIcon(e){switch(e.split(".").pop()?.toLowerCase()){case "pdf":return "picture_as_pdf";case "csv":case "xlsx":case "xls":return "table_chart";case "txt":case "md":return "description";case "jpg":case "jpeg":case "png":case "gif":case "webp":return "image";case "zip":case "tar":case "gz":return "folder_zip";default:return "insert_drive_file"}}formatSize(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}formatDate(e){return fi(e)}canViewFile(e){return this.contentViewerService.isFormatViewable(e.filename)&&this.contentViewerService.isViewable(e.size)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-file-exchange-drawer"]],inputs:{projectName:"projectName",threadId:"threadId"},outputs:{closeDrawer:"closeDrawer"},decls:2,vars:2,consts:[[1,"file-drawer-container"],[3,"file","projectName","threadId"],[1,"drawer-header"],[1,"header-left"],[1,"drawer-title"],[1,"file-count"],[1,"header-actions"],["mat-icon-button","","title","Download all files","type","button",1,"download-all-btn"],["mat-icon-button","","title","Close","type","button",1,"close-btn",3,"click"],[1,"file-list"],[1,"file-loading"],["mat-icon-button","","title","Download all files","type","button",1,"download-all-btn",3,"click"],[1,"loading-spinner"],[1,"loading-text"],[1,"file-empty"],[1,"empty-icon"],[1,"empty-text"],[1,"empty-hint"],[1,"file-item"],[1,"file-info"],[1,"file-icon"],[1,"file-details"],[1,"file-name",3,"title"],[1,"file-meta"],[1,"file-actions"],["mat-icon-button","","title","View","type","button",1,"action-btn","view-btn"],["mat-icon-button","","title","Download","type","button",1,"action-btn","download-btn",3,"click"],["mat-icon-button","","title","Delete","type","button",1,"action-btn","delete-btn",3,"click"],["mat-icon-button","","title","View","type","button",1,"action-btn","view-btn",3,"click"],[3,"closeViewer","file","projectName","threadId"]],template:function(t,n){t&1&&(Jw(0,Vr,15,3,"div",0),Jw(1,Lr,1,3,"app-content-viewer",1)),t&2&&(eC(n.viewerState==="list"?0:-1),XE(),eC(n.viewerState==="content"&&n.currentFile?1:-1));},dependencies:[qm,yt$1,wt$1,hr$1,Gn$1,ft],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;height:100%}.file-drawer-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;height:100%;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);color:var(--color-text)}.drawer-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--color-border);flex-shrink:0}.header-left[_ngcontent-%COMP%]{display:flex;align-items:baseline;gap:.5rem}.header-actions[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.25rem}.drawer-title[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:600;color:var(--color-text)}.file-count[_ngcontent-%COMP%]{font-size:.9rem;color:var(--color-text-secondary)}.download-all-btn[_ngcontent-%COMP%]{color:var(--color-primary)}.download-all-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.close-btn[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.close-btn[_ngcontent-%COMP%]:hover{color:var(--color-text);background:var(--color-bg-hover)}.file-list[_ngcontent-%COMP%]{flex:1;overflow-y:auto;padding:.5rem}.file-loading[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:3rem 1rem;gap:1rem;color:var(--color-text-secondary)}.loading-spinner[_ngcontent-%COMP%]{display:inline-block;width:32px;height:32px;border:3px solid var(--color-border);border-top-color:var(--color-primary);border-radius:50%;animation:_ngcontent-%COMP%_spin .8s linear infinite}@keyframes _ngcontent-%COMP%_spin{to{transform:rotate(360deg)}}.loading-text[_ngcontent-%COMP%]{font-size:.9rem}.file-empty[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:3rem 1rem;text-align:center;color:var(--color-text-secondary)}.empty-icon[_ngcontent-%COMP%]{font-size:64px;width:64px;height:64px;margin-bottom:1rem;opacity:.5}.empty-text[_ngcontent-%COMP%]{margin:0 0 .5rem;font-size:1rem;font-weight:500}.empty-hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;opacity:.7}.file-item[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:.75rem;border-radius:8px;transition:background .2s;gap:1rem}.file-item[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.file-item[_ngcontent-%COMP%]:hover .file-actions[_ngcontent-%COMP%]{opacity:1}.file-info[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.75rem;flex:1;min-width:0}.file-icon[_ngcontent-%COMP%]{flex-shrink:0;color:var(--color-primary);font-size:28px;width:28px;height:28px}.file-details[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.25rem;min-width:0}.file-name[_ngcontent-%COMP%]{font-weight:500;color:var(--color-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.file-meta[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary)}.file-actions[_ngcontent-%COMP%]{display:flex;gap:.25rem;flex-shrink:0;opacity:0;transition:opacity .2s}.action-btn[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.action-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.action-btn.view-btn[_ngcontent-%COMP%]:hover, .action-btn.download-btn[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.action-btn.delete-btn[_ngcontent-%COMP%]:hover{color:var(--color-error)}@media(max-width:768px){.file-actions[_ngcontent-%COMP%]{opacity:1}.file-item[_ngcontent-%COMP%]{padding:1rem .75rem}.drawer-header[_ngcontent-%COMP%]{padding:.75rem;padding-top:calc(.75rem + env(safe-area-inset-top,0px))}}"],changeDetection:1})};var wt=class i{http=g(py);listUsers(){return this.http.get("/api/users")}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var Tt=class i{excludedUserIds=[];placeholder="Search username";disabled=false;userSelected=new vt$1;userApi=g(wt);search(e){let t=e.toLowerCase();return this.userApi.listUsers().pipe(re(n=>n.filter(o=>!this.excludedUserIds.includes(o.username)).filter(o=>o.username.toLowerCase().includes(t)).map(o=>({id:o.username,name:o.username}))))}onItemSelected(e){this.userSelected.emit(e.id);}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-user-autocomplete"]],inputs:{excludedUserIds:"excludedUserIds",placeholder:"placeholder",disabled:"disabled"},outputs:{userSelected:"userSelected"},decls:1,vars:3,consts:[[3,"itemSelected","dataSource","placeholder","disabled"]],template:function(t,n){t&1&&(ws(0,"ds-autocomplete-input",0),Rg("itemSelected",function(r){return n.onItemSelected(r)}),pl()),t&2&&bg("dataSource",n)("placeholder",n.placeholder)("disabled",n.disabled);},dependencies:[Pn],styles:["[_nghost-%COMP%]{display:block}"],changeDetection:1})};var zr=(i,e)=>e.userId;function Nr(i,e){if(i&1&&(ws(0,"div",7),GC(1),pl()),i&2){let t=gC();XE(),Yg(t.errorMessage());}}function $r(i,e){if(i&1){let t=lC();ws(0,"button",13),Rg("click",function(){If(t);let o=gC().$implicit,r=gC();return wf(r.removeUser(o.userId))}),ws(1,"mat-icon"),GC(2,"close"),pl()();}}function jr(i,e){if(i&1&&(ws(0,"div",9)(1,"mat-icon",10),GC(2,"person"),pl(),ws(3,"span",11),GC(4),pl(),Jw(5,$r,3,0,"button",12),pl()),i&2){let t=e.$implicit,n=gC();XE(4),Yg(t.userId),XE(),eC(n.users.length>1?5:-1);}}var ke=class i{threadId;users=[];currentUsername;userAdded=new vt$1;userRemoved=new vt$1;closed=new vt$1;isAdding=Gi$1(false);errorMessage=Gi$1("");get excludedUserIds(){return [this.currentUsername,...this.users.map(e=>e.userId)]}setAdding(e){this.isAdding.set(e);}setError(e){this.errorMessage.set(e),this.isAdding.set(false);}onUserSelected(e){this.errorMessage.set(""),this.userAdded.emit(e);}removeUser(e){this.userRemoved.emit(e);}close(){this.closed.emit();}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["app-thread-share"]],inputs:{threadId:"threadId",users:"users",currentUsername:"currentUsername"},outputs:{userAdded:"userAdded",userRemoved:"userRemoved",closed:"closed"},decls:19,vars:3,consts:[[1,"thread-share"],[1,"share-header"],[1,"header-left"],["mat-icon-button","","title","Close","type","button",1,"close-btn",3,"click"],[1,"share-subheader"],[1,"add-user-section"],[3,"userSelected","excludedUserIds","disabled"],[1,"error-message"],[1,"users-list"],[1,"user-item"],[1,"user-icon"],[1,"user-name"],["mat-icon-button","","title","Remove user",1,"remove-button"],["mat-icon-button","","title","Remove user",1,"remove-button",3,"click"]],template:function(t,n){t&1&&(ws(0,"div",0)(1,"div",1)(2,"div",2)(3,"mat-icon"),GC(4,"group"),pl(),ws(5,"span"),GC(6,"Share"),pl()(),ws(7,"button",3),Rg("click",function(){return n.close()}),ws(8,"mat-icon"),GC(9,"chevron_right"),pl()()(),ws(10,"div",4)(11,"span"),GC(12,"Participants"),pl()(),ws(13,"div",5)(14,"app-user-autocomplete",6),Rg("userSelected",function(r){return n.onUserSelected(r)}),pl()(),Jw(15,Nr,2,1,"div",7),ws(16,"div",8),rC(17,jr,6,2,"div",9,zr),pl()()),t&2&&(XE(14),bg("excludedUserIds",n.excludedUserIds)("disabled",n.isAdding()),XE(),eC(n.errorMessage()?15:-1),XE(2),oC(n.users));},dependencies:[yt$1,wt$1,hr$1,Gn$1,Ve,Tt],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;height:100%}.thread-share[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);color:var(--color-text)}.share-header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:1rem;padding-top:calc(1rem + env(safe-area-inset-top,0px));border-bottom:1px solid var(--color-border);flex-shrink:0}.share-header[_ngcontent-%COMP%] .header-left[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;font-weight:600;font-size:1.1rem;color:var(--color-text)}.share-header[_ngcontent-%COMP%] .header-left[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px;color:var(--color-text-secondary)}.share-header[_ngcontent-%COMP%] .close-btn[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.share-header[_ngcontent-%COMP%] .close-btn[_ngcontent-%COMP%]:hover{color:var(--color-text);background:var(--color-bg-hover)}.share-subheader[_ngcontent-%COMP%]{padding:.75rem 1rem .25rem;font-size:.75rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:var(--color-text-secondary)}.add-user-section[_ngcontent-%COMP%]{display:flex;align-items:center;padding:0 1rem .75rem;width:50%}.error-message[_ngcontent-%COMP%]{color:var(--color-error);font-size:.75rem;margin-top:-.5rem;padding:0 1rem}.users-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.25rem;padding:.25rem}.user-item[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;border-radius:6px;transition:background .15s ease}.user-item[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.user-icon[_ngcontent-%COMP%]{font-size:18px;width:18px;height:18px;color:var(--color-text-secondary);flex-shrink:0}.user-name[_ngcontent-%COMP%]{flex:1;font-size:.875rem;color:var(--color-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.remove-button[_ngcontent-%COMP%]{flex-shrink:0;width:28px!important;height:28px!important;padding:0!important}.remove-button[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:16px;width:16px;height:16px;color:var(--color-text-secondary)}.remove-button[_ngcontent-%COMP%]:hover mat-icon[_ngcontent-%COMP%]{color:var(--color-error, #ef4444)}"],changeDetection:1})};var Ur=new C("MAT_BADGE_CONFIG"),bi="mat-badge-content",Br=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275cmp=xw({type:i,selectors:[["ng-component"]],decls:0,vars:0,template:function(n,o){},styles:[`.mat-badge {
32
32
  position: relative;
33
33
  }
34
34
  .mat-badge.mat-badge {