@whoz-oss/coday-client 0.153.0 → 0.160.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.
- package/3rdpartylicenses.txt +26 -26
- package/browser/{chunk-TCYPGB6P.js → chunk-3WSHO4HH.js} +1 -1
- package/browser/{chunk-TWTJJETM.js → chunk-44ROPJW7.js} +1 -1
- package/browser/{chunk-J6KC3ETK.js → chunk-44U6NIYJ.js} +1 -1
- package/browser/{chunk-AEXWYSY4.js → chunk-4RMKYA7C.js} +1 -1
- package/browser/chunk-5DYITBLP.js +1 -0
- package/browser/chunk-5ETOAW5I.js +1 -0
- package/browser/{chunk-GZ5XFG52.js → chunk-73MM2OCC.js} +1 -1
- package/browser/{chunk-FXW6JMJT.js → chunk-73XLCIE3.js} +1 -1
- package/browser/chunk-7INOPTJ6.js +1 -0
- package/browser/{chunk-64KUJ72Y.js → chunk-AKNP533G.js} +1 -1
- package/browser/{chunk-EL5IQEU5.js → chunk-AUD6VMQP.js} +1 -1
- package/browser/chunk-B5UWPZYC.js +61 -0
- package/browser/{chunk-3PF557D6.js → chunk-BJL3QU5V.js} +1 -1
- package/browser/{chunk-HBPEHALV.js → chunk-C6PPTNHE.js} +1 -1
- package/browser/chunk-CFTOIYSG.js +1 -0
- package/browser/{chunk-QMQRJWM2.js → chunk-CQCFF5QA.js} +1 -1
- package/browser/{chunk-F32VEQPY.js → chunk-DWPYG4F6.js} +1 -1
- package/browser/{chunk-GKBRHSMN.js → chunk-EQGMNQH5.js} +1 -1
- package/browser/chunk-F4YDJMK7.js +1 -0
- package/browser/{chunk-4PT56FZA.js → chunk-FJTJITU2.js} +1 -1
- package/browser/{chunk-NGOS7UTY.js → chunk-GTNTE2V7.js} +1 -1
- package/browser/chunk-IJ2PFSZT.js +1 -0
- package/browser/chunk-IKNFRB6Z.js +1 -0
- package/browser/{chunk-NUN4WTCP.js → chunk-IW7LOGR6.js} +1 -1
- package/browser/{chunk-46WAGL6T.js → chunk-JK7XVLXN.js} +1 -1
- package/browser/{chunk-MKE7HI6X.js → chunk-LANL6XWU.js} +1 -1
- package/browser/{chunk-OAN35RIR.js → chunk-LEIES4AA.js} +1 -1
- package/browser/{chunk-JLVW3WZE.js → chunk-LHRGRELF.js} +1 -1
- package/browser/{chunk-6HXHF2SN.js → chunk-LLIN4HKG.js} +1 -1
- package/browser/{chunk-VU5WR5CP.js → chunk-MRYQF7JC.js} +1 -1
- package/browser/{chunk-H7MV7NCQ.js → chunk-NBZFBJ7T.js} +1 -1
- package/browser/chunk-NHYWTBYT.js +1 -0
- package/browser/{chunk-P7CSUKFY.js → chunk-OXXWNVGU.js} +1 -1
- package/browser/{chunk-MUQFZY3N.js → chunk-PGO5PZRK.js} +1 -1
- package/browser/chunk-PP5TBFXE.js +31 -0
- package/browser/chunk-Q7MOXRND.js +1 -0
- package/browser/{chunk-TGT4RBUY.js → chunk-QEUPJ2EM.js} +1 -1
- package/browser/chunk-RF7IRXXE.js +1 -0
- package/browser/{chunk-LHEQ6HXJ.js → chunk-S4QJJ7B3.js} +1 -1
- package/browser/{chunk-KRK3FNKB.js → chunk-VIFGZQZS.js} +1 -1
- package/browser/{chunk-SKABLB3F.js → chunk-WP6SVXZC.js} +1 -1
- package/browser/{chunk-ZV2GXJ7Q.js → chunk-WPGSXQ5M.js} +1 -1
- package/browser/{chunk-7YDOHTEK.js → chunk-XLNZCT7N.js} +1 -1
- package/browser/{chunk-IREZ3UJ3.js → chunk-Y2GNO2KX.js} +1 -1
- package/browser/chunk-Y2JOUXVN.js +1 -0
- package/browser/{chunk-I5HSEFR4.js → chunk-ZKUCVZCJ.js} +1 -1
- package/browser/index.html +1 -1
- package/browser/{main-3RWS5R5L.js → main-FLHOTSKQ.js} +1 -1
- package/package.json +1 -1
- package/browser/chunk-5JACHD45.js +0 -1
- package/browser/chunk-DFZI6Z7W.js +0 -1
- package/browser/chunk-EC2BCDCL.js +0 -1
- package/browser/chunk-FHERZTSZ.js +0 -1
- package/browser/chunk-FIVJTOO5.js +0 -1
- package/browser/chunk-JWRID2EL.js +0 -1
- package/browser/chunk-LMGSBI4E.js +0 -1
- package/browser/chunk-N5UH5PRX.js +0 -1
- package/browser/chunk-UVTRXG6W.js +0 -1
- package/browser/chunk-WG653S5D.js +0 -91
- package/browser/chunk-WMRLIQ4E.js +0 -1
- package/browser/chunk-XHE2FLNY.js +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import{a as Cn}from"./chunk-XDTTR6NK.js";import{a as je,b as Ue,e as _n,g as ce}from"./chunk-CQCFF5QA.js";import{a as yn,b as wn,c as Tn}from"./chunk-B5UWPZYC.js";import{a as Ke}from"./chunk-2NBVMKPO.js";import{a as $e,b as X,c as cn,g as mn,h as pn,i as un,m as gn,n as hn,p as fn,r as Qe,t as bn,v as vn,w as se,y as Xe}from"./chunk-PK3KWLLW.js";import{a as xn}from"./chunk-4HKHCNH5.js";import{d as Kt}from"./chunk-UARV2YUR.js";import{a as In}from"./chunk-VIPJVFGJ.js";import{p as On,r as kn}from"./chunk-DWPYG4F6.js";import{b as ln,p as Sn,q as Mn,r as En,v as Pn}from"./chunk-XLNZCT7N.js";import{a as dn,c as Ge}from"./chunk-WJFUKUVD.js";import{a as R,b as L}from"./chunk-DYANOPHQ.js";import{E as Ye,c as Be,g as We,m as qe}from"./chunk-F4YDJMK7.js";import{b as Q}from"./chunk-NMGDBGR3.js";import{E as rn,K as an,O as re,Q as sn,R as Ne,S as ae,i as Jt,j as Zt,p as en,s as tn,t as nn,z as on}from"./chunk-4YLSQZJK.js";import{$b as qt,B as W,Bb as _,D as De,Db as h,Fb as l,Fc as ze,G as Ft,Ga as z,Ha as Lt,Hc as Xt,Ic as St,Ja as zt,Jb as ge,Ka as c,Kb as J,Kc as j,Lb as Z,Pa as Nt,Rb as N,Sc as Y,T as F,Tb as p,Ub as S,Vb as he,Vc as G,Wa as T,Wb as Ae,Xa as $t,Xb as Fe,Ya as jt,Yb as Re,Z as k,Za as Ut,Zb as He,_ as Rt,_b as Wt,a as de,ac as Yt,b as Oe,bc as Gt,ca as m,d as P,dc as Ee,ec as Qt,fc as Tt,g as ke,ga as f,h as B,ha as b,i as Ie,jb as oe,kc as Ve,la as Ht,lb as u,m as xt,mb as g,n as Dt,oa as M,pa as Vt,pb as H,qb as V,rb as C,sb as a,t as ne,ta as ie,tb as s,u as At,ub as y,uc as Le,va as q,vb as yt,wb as wt,xb as Bt,ya as ue}from"./chunk-QPN22TF2.js";var Je=class i{sanitizer=m(G);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=Ut({name:"highlight",type:i,pure:!0})};var fe=class i{http=m(Y);projectState=m(Q);threadState=m(X);transcribeAudio(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow();return this.http.post(`/api/projects/${o}/transcribe`,de({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`,de({audio:e,mimeType:t},n?{language:n}:{}))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=k({token:i,factory:i.\u0275fac,providedIn:"root"})};var hi=["messageInput"],fi=["fileInput"],bi=(i,e)=>e.name;function vi(i,e){i&1&&(a(0,"div",3),y(1,"span",8),p(2," Recording... Click mic to stop "),s())}function Ci(i,e){i&1&&(a(0,"div",3),y(1,"span",9),p(2," Transcribing... "),s())}function _i(i,e){if(i&1&&(a(0,"span",14),p(1),s()),i&2){let t=l().$implicit,n=l(2);c(),S(" "+(n.getParameterFormat(t)||""))}}function xi(i,e){if(i&1){let t=_();a(0,"div",11),h("click",function(){let o=f(t).$index,r=l(2);return b(r.selectAutocompleteItemByClick(o))})("keydown.enter",function(){let o=f(t).$index,r=l(2);return b(r.selectAutocompleteItemByClick(o))})("keydown.space",function(){let o=f(t).$index,r=l(2);return b(r.selectAutocompleteItemByClick(o))})("mouseenter",function(){let o=f(t).$index,r=l(2);return b(r.selectedAutocompleteIndex=o)}),a(1,"div",12),y(2,"span",13),Ee(3,"highlight"),u(4,_i,2,1,"span",14),s(),y(5,"div",15),Ee(6,"highlight"),s()}if(i&2){let t=e.$implicit,n=e.$index,o=l(2);N("selected",n===o.selectedAutocompleteIndex),oe("aria-selected",n===o.selectedAutocompleteIndex),c(2),C("innerHTML",Tt(3,6,o.autocompleteTrigger+t.name,o.getAutocompleteQuery()),z),c(2),g(o.hasParameterFormat(t)?4:-1),c(),C("innerHTML",Tt(6,9,t.description,o.getAutocompleteQuery()),z)}}function yi(i,e){if(i&1&&(a(0,"div",4),H(1,xi,7,12,"div",10,bi),s()),i&2){let t=l();c(),V(t.autocompleteItems)}}function wi(i,e){if(i&1){let t=_();a(0,"ds-icon-button",18),h("action",function(){f(t);let o=l(2);return b(o.onStopClick())}),s()}}function Ti(i,e){if(i&1){let t=_();a(0,"ds-icon-button",19),h("action",function(){f(t);let o=l(2);return b(o.sendMessage())}),s()}if(i&2){let t=l(2);N("hidden",t.isDisabled||!t.message.trim())("active",!!t.message.trim()&&!t.isDisabled),C("title",t.getSendButtonTooltip())("disabled",t.isDisabled||!t.message.trim())}}function Si(i,e){if(i&1){let t=_();a(0,"ds-icon-button",21),h("action",function(){f(t);let o=l(3);return b(o.triggerFileUpload())}),s(),a(1,"input",22,1),h("change",function(o){f(t);let r=l(3);return b(r.onFileInputChange(o))}),s()}if(i&2){let t=l(3);C("disabled",t.isDisabled)}}function Mi(i,e){if(i&1){let t=_();u(0,Si,3,1),a(1,"ds-icon-button",20),h("action",function(){f(t);let o=l(2);return b(o.toggleRecording())}),s()}if(i&2){let t=l(2);g(!t.showWelcome&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?0:-1),c(),N("hidden",t.message.trim()&&!t.isRecording&&!t.isTranscribing),C("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 Ei(i,e){if(i&1&&(a(0,"div",7),u(1,wi,1,0,"ds-icon-button",16),u(2,Ti,1,6,"ds-icon-button",17),u(3,Mi,2,6),s()),i&2){let t=l();c(),g(t.isThinking?1:-1),c(),g((!t.isThinking||t.message.trim())&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?2:-1),c(),g(t.isThinking?-1:3)}}var Ze=class i{isDisabled=!1;showWelcome=!1;isThinking=!1;isStarting=!1;isSessionInitializing=!1;isStopping=!1;filesPasted=new M;messageSubmitted=new M;voiceMessageReady=new M;voiceRecordingToggled=new M;heightChanged=new M;stopRequested=new M;textareaFocused=new M;messageInput;fileInput;message="";isRecording=!1;isTranscribing=!1;isFocused=!1;recognition=null;mediaRecorder=null;audioChunks=[];voiceInputMode="browser";get isVoiceMessageMode(){return this.voiceInputMode==="voice-message"}sessionHadTranscript=!1;pendingLineBreaksTimeout=null;lastProcessedResultIndex=0;useEnterToSend=!1;currentInvite="";subscriptions=[];thinkingPhrases=["Processing request...","Thinking...","Working on it..."];currentThinkingPhrase="Processing request...";thinkingPhraseIndex=0;thinkingInterval=null;autocompleteVisible=!1;autocompleteTrigger=null;autocompleteItems=[];selectedAutocompleteIndex=0;preferencesService=m(se);codayService=m(ce);agentApiService=m(Cn);promptApiService=m(In);projectStateService=m(Q);audioApiService=m(fe);threadStateService=m(X);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=!1,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(!0)):(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey)&&!e.shiftKey&&(e.preventDefault(),this.sendMessage(!0)))}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=!1){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=!0,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 P(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=!1,this.voiceRecordingToggled.emit(!1)}})}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=!1,this.voiceRecordingToggled.emit(!1)}}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=!0;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=!1;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=!1,this.voiceMessageReady.emit({base64:o,mimeType:t,language:d});return}this.audioApiService.sendVoiceMessage(o,t,d).subscribe({next:v=>{this.isTranscribing=!1,console.log("[WHISPER] Voice message sent, transcription:",v.transcription?.substring(0,50))},error:v=>{console.error("[WHISPER] Voice message error:",v),this.isTranscribing=!1,this.fallbackToTranscription(o,t,d)}})}else this.audioApiService.transcribeAudio(o,t,d).subscribe({next:v=>{this.isTranscribing=!1,v.text&&this.appendToTextarea(v.text+" ")},error:v=>{console.error("[WHISPER] Transcription error:",v),this.isTranscribing=!1}})},n.readAsDataURL(e)}fallbackToTranscription(e,t,n){this.audioApiService.transcribeAudio(e,t,n).subscribe({next:o=>{this.isTranscribing=!1,o.text&&this.appendToTextarea(o.text+" ")},error:o=>{console.error("[WHISPER] Fallback transcription also failed:",o),this.isTranscribing=!1}})}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=!0,this.recognition.interimResults=!0,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=!0,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=!1,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=!1,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 P(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=!1,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
|
+
|
|
3
|
+
`),this.sessionHadTranscript=!1),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=!1,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=T({type:i,selectors:[["app-chat-textarea"]],viewQuery:function(t,n){if(t&1&&ge(hi,7)(fi,5),t&2){let o;J(o=Z())&&(n.messageInput=o.first),J(o=Z())&&(n.fileInput=o.first)}},hostBindings:function(t,n){t&1&&h("paste",function(r){return n.onPaste(r)})("click",function(r){return n.onDocumentClick(r)},zt)},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:[q],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=_();a(0,"div",2),u(1,vi,3,0,"div",3),u(2,Ci,3,0,"div",3),u(3,yi,3,0,"div",4),a(4,"div",5)(5,"textarea",6,0),He("ngModelChange",function(d){return f(o),Re(n.message,d)||(n.message=d),b(d)}),h("keydown",function(d){return n.onKeyDown(d)})("input",function(){return n.onInput()})("focus",function(){return f(o),n.isFocused=!0,b(n.textareaFocused.emit())})("blur",function(){return n.isFocused=!1}),s(),u(7,Ei,4,3,"div",7),s()()}t&2&&(c(),g(!n.isVoiceMessageMode&&n.isRecording?1:-1),c(),g(!n.isVoiceMessageMode&&n.isTranscribing?2:-1),c(),g(n.autocompleteVisible?3:-1),c(),N("focused",n.isFocused)("welcome-mode",n.showWelcome)("is-thinking",n.isThinking)("is-listening",n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),c(),Fe("ngModel",n.message),C("placeholder",n.getPlaceholder())("disabled",n.isDisabled||n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),c(2),g(n.isSessionInitializing?-1:7))},dependencies:[Ye,Be,We,qe,On,Je],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}}']})};var be=class i{unreadCountSubject=new Ie(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=k({token:i,factory:i.\u0275fac,providedIn:"root"})};var et=class i{ATTENTION_EMOJI="\u{1F534}";isSystemActive=!1;systemActiveTimer=null;SYSTEM_ACTIVE_TIMEOUT=4e3;unreadService=m(be);project=m(Q);constructor(){this.initializeTitleUpdates()}initializeTitleUpdates(){At([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=!0,this.systemActiveTimer&&clearTimeout(this.systemActiveTimer),this.systemActiveTimer=setTimeout(()=>{console.log("[TAB-TITLE] System active timeout - hiding hourglass"),this.isSystemActive=!1,this.forceUpdateTitle()},this.SYSTEM_ACTIVE_TIMEOUT),this.forceUpdateTitle()}setSystemInactive(){console.log("[TAB-TITLE] System inactive - hiding hourglass"),this.isSystemActive=!1,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=k({token:i,factory:i.\u0275fac,providedIn:"root"})};var tt=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=k({token:i,factory:i.\u0275fac,providedIn:"root"})};var Pi=(i,e)=>e.label;function Oi(i,e){if(i&1){let t=_();a(0,"button",2),h("click",function(o){let r=f(t).$implicit,d=l();return b(d.executeAction(r,o))}),a(1,"mat-icon"),p(2),s()()}if(i&2){let t=e.$implicit;oe("title",t.tooltip||t.label),c(),oe("aria-label",t.label),c(),S(t.icon)}}var nt=class i{actions=[];executeAction(e,t){t.stopPropagation(),e.action()}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=T({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&&(a(0,"div",0),H(1,Oi,3,3,"button",1,Pi),s()),t&2&&(c(),V(n.actions))},dependencies:[j,re,R],styles:[".context-menu-wrapper[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center}.context-menu-wrapper[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{transform:scale(.75)}"]})};var K=class i{renderer;constructor(){this.renderer=new yn,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!1;if(e.startsWith("//"))return!0;try{return new URL(e,window.location.href).hostname!==window.location.hostname}catch(t){return!1}}escapeHtml(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,n=>t[n]||n)}parse(e){return P(this,null,function*(){let t=yield wn.parse(e,{renderer:this.renderer,breaks:!0,gfm:!0});return Tn.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=k({token:i,factory:i.\u0275fac,providedIn:"root"})};var ki=i=>({"user-message-wrapper":i});function Ii(i,e){if(i&1&&(a(0,"div",5)(1,"div",9),p(2),s()()),i&2){let t=l(2);c(2),he(" ",t.message.speaker," ")}}function Di(i,e){if(i&1&&(a(0,"time",7),p(1),s()),i&2){let t=l(2);c(),S(t.formattedTimestamp)}}function Ai(i,e){if(i&1&&(a(0,"div",8),y(1,"app-message-context-menu",10),s()),i&2){let t=l(2);c(),C("actions",t.actions)}}function Fi(i,e){if(i&1&&(u(0,Ii,3,1,"div",5),y(1,"div",6),u(2,Di,2,1,"time",7),u(3,Ai,2,1,"div",8)),i&2){let t=l();g(t.shouldShowSpeaker?0:-1),c(),C("innerHTML",t.renderedContent,z),c(),g(t.formattedTimestamp?2:-1),c(),g(t.isLongMessage&&t.shouldShowActions&&t.message.role==="assistant"?3:-1)}}function Ri(i,e){if(i&1&&(a(0,"a",12),p(1,"view"),s()),i&2){let t=l(2);C("href",t.eventLink,Lt)}}function Hi(i,e){if(i&1&&(a(0,"div",2),y(1,"span",11),u(2,Ri,2,1,"a",12),s()),i&2){let t=l();c(),C("innerHTML",t.renderedContent,z),c(),g(t.eventLink?2:-1)}}function Vi(i,e){if(i&1&&(a(0,"div",3),y(1,"app-message-context-menu",10),s()),i&2){let t=l();c(),C("actions",t.actions)}}function Li(i,e){if(i&1&&(a(0,"div",4),y(1,"app-message-context-menu",10),s()),i&2){let t=l();c(),C("actions",t.actions)}}var ve=class i{destroy$=new B;message;canDelete=!0;isOtherUser=!1;copyRequested=new M;deleteRequested=new M;renderedContent="";shouldHideTechnical=!1;shouldHideWarning=!1;sanitizer=m(G);notificationService=m(xn);preferencesService=m(se);projectState=m(Q);threadState=m(X);markdownService=m(K);get messageClasses(){return{[this.message.role]:!0,[this.message.type]:!0,"hidden-technical":this.shouldHideTechnical&&this.message.type==="technical","hidden-warning":this.shouldHideWarning&&this.message.type==="warning","other-user":this.isOtherUser}}ngOnInit(){return P(this,null,function*(){yield this.renderMarkdown(),this.preferencesService.hideTechnicalMessages$.pipe(F(this.destroy$)).subscribe(e=>{this.shouldHideTechnical=e}),this.preferencesService.hideWarningMessages$.pipe(F(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=m(St);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 isLongMessage(){let e=this.extractTextContent();return e.length>1e3||e.split(`
|
|
4
|
+
`).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:!0}),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(),t=this.threadState.getSelectedThreadId();return!e||!t?null:`/api/projects/${e}/threads/${t}/messages/${encodeURIComponent(this.message.eventId)}/formatted`}renderMarkdown(){return P(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 P(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=`
|
|
5
|
+
<div class="image-content">
|
|
6
|
+
<img src="${o}"
|
|
7
|
+
alt="${r}"
|
|
8
|
+
class="message-image"
|
|
9
|
+
style="max-width: 100%; height: auto; margin: 8px 0; border-radius: 8px; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); transition: transform 0.2s ease, box-shadow 0.2s ease;"
|
|
10
|
+
onclick="window.open(this.src, '_blank')" />
|
|
11
|
+
</div>
|
|
12
|
+
`;t.push(d)}else if(n.type==="audio"){let o=`data:${n.mimeType};base64,${n.content}`,r=n.transcription?`<div class="audio-transcription" style="margin-top: 4px; font-style: italic; color: var(--text-secondary, #666); font-size: 0.9em;">\u201C${n.transcription}\u201D</div>`:"",d=`
|
|
13
|
+
<div class="audio-content" style="margin: 8px 0;">
|
|
14
|
+
<audio controls preload="metadata" style="width: 100%; max-width: 400px; display: block;">
|
|
15
|
+
<source src="${o}" type="${n.mimeType}">
|
|
16
|
+
Your browser does not support the audio element.
|
|
17
|
+
</audio>
|
|
18
|
+
${r}
|
|
19
|
+
</div>
|
|
20
|
+
`;t.push(d)}return t.join("")})}onCopy(){let e=this.extractTextContent();e.trim()&&navigator.clipboard.writeText(e).then(()=>{console.log("[CHAT-MESSAGE] Message copied to clipboard"),this.notificationService.success("Message copied to clipboard")}).catch(t=>{console.error("[CHAT-MESSAGE] Failed to copy message:",t),this.notificationService.error("Failed to copy message")}),this.copyRequested.emit(this.message)}onDelete(){console.log("[CHAT-MESSAGE] Delete requested for message:",this.message.id),this.deleteRequested.emit(this.message)}extractTextContent(){return this.message.content.filter(e=>e.type==="text"||e.type==="audio"&&e.transcription).map(e=>e.type==="text"?e.content:`[Voice message]: ${e.transcription}`).join(`
|
|
21
|
+
|
|
22
|
+
`)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=T({type:i,selectors:[["app-chat-message"]],inputs:{message:"message",canDelete:"canDelete",isOtherUser:"isOtherUser"},outputs:{copyRequested:"copyRequested",deleteRequested:"deleteRequested"},features:[qt([St])],decls:6,vars:8,consts:[[1,"message-wrapper",3,"ngClass"],[1,"message",3,"ngClass"],[1,"simple-content","markdown-content"],[1,"actions","assistant-top-actions"],[1,"actions","user-top-actions"],[1,"message-header"],[1,"content","markdown-content",3,"innerHTML"],[1,"message-timestamp"],[1,"actions","bottom-actions"],[1,"speaker"],[3,"actions"],[3,"innerHTML"],["target","_blank",1,"event-link",3,"href"]],template:function(t,n){t&1&&(a(0,"div",0)(1,"div",1),u(2,Fi,4,4),u(3,Hi,3,2,"div",2),s(),u(4,Vi,2,1,"div",3),u(5,Li,2,1,"div",4),s()),t&2&&(C("ngClass",Gt(6,ki,n.message.role==="user")),c(),C("ngClass",n.messageClasses),c(),g(n.isSimplified?-1:2),c(),g(n.isSimplified?3:-1),c(),g(!n.isLongMessage&&n.shouldShowActions&&n.message.role==="assistant"?4:-1),c(),g(n.shouldShowActions&&n.message.role==="user"?5:-1))},dependencies:[nt,ze],styles:[".message-wrapper[_ngcontent-%COMP%]{margin:0;display:flex;align-items:flex-start;gap:.5rem}.message-wrapper.user-message-wrapper[_ngcontent-%COMP%]{margin:.75rem 0;flex-direction:row-reverse;align-items:flex-start}.message-wrapper.user-message-wrapper[_ngcontent-%COMP%]:has(.other-user){flex-direction:row}.message[_ngcontent-%COMP%]{position:relative}.message.user[_ngcontent-%COMP%]{padding:1rem 1.25rem .5rem}.message.user[_ngcontent-%COMP%] .message-timestamp[_ngcontent-%COMP%]{display:block;text-align:right;font-size:.7rem;color:var(--color-text-secondary, #6272a4);white-space:nowrap;margin-top:.4rem;opacity:.7}.message.user[_ngcontent-%COMP%]{background:var(--color-message-user);border-radius:18px 18px 6px;border:1px solid var(--glass-border);box-shadow:none;backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);width:fit-content;max-width:75%;min-width:120px;word-wrap:break-word;transition:transform .2s ease,box-shadow .2s ease}.message.user[_ngcontent-%COMP%]:hover{transform:translateY(-1px);box-shadow:0 12px 40px #1f268733}.message.user.other-user[_ngcontent-%COMP%]{border-bottom-right-radius:18px;border-bottom-left-radius:6px}.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}.message.system[_ngcontent-%COMP%], .message.technical[_ngcontent-%COMP%]{padding:.5rem .75rem;background:transparent;border:none;box-shadow:none;backdrop-filter:none;-webkit-backdrop-filter:none;margin:0;font-family:SF Mono,Monaco,Menlo,monospace;font-size:.85rem;color:var(--color-text-secondary);max-width:none;width:auto;min-width:auto}.message.system[_ngcontent-%COMP%]:hover, .message.technical[_ngcontent-%COMP%]:hover{transform:none;box-shadow:none}.message.hidden-technical[_ngcontent-%COMP%], .message.hidden-warning[_ngcontent-%COMP%]{display:none!important}.message.error[_ngcontent-%COMP%]{padding:1rem 1.25rem;background:#ff3b301f;border-left:3px solid var(--color-error);color:var(--color-error)}.message.warning[_ngcontent-%COMP%]{padding:1rem 1.25rem;background:#ff95001f;border-left:3px solid var(--color-warning);color:var(--color-warning)}.message-header[_ngcontent-%COMP%]{margin-bottom:.5rem}.speaker[_ngcontent-%COMP%]{font-weight:600;font-size:.85rem;color:var(--color-text-secondary, #6272a4)}.content[_ngcontent-%COMP%]{line-height:1.5}.context-menu-top[_ngcontent-%COMP%]{top:.5rem;right:.5rem;z-index:10}.context-menu-bottom[_ngcontent-%COMP%]{bottom:.5rem;right:.5rem;z-index:10}.user-top-actions[_ngcontent-%COMP%]{display:flex;align-items:flex-start;padding-top:.5rem;opacity:0;transition:opacity .2s ease}.user-message-wrapper[_ngcontent-%COMP%]:hover .user-top-actions[_ngcontent-%COMP%]{opacity:1}.assistant-top-actions[_ngcontent-%COMP%]{display:flex;align-items:flex-start;padding-top:.5rem;opacity:0;transition:opacity .2s ease}.message-wrapper[_ngcontent-%COMP%]:hover .assistant-top-actions[_ngcontent-%COMP%]{opacity:1}.simple-content[_ngcontent-%COMP%]{display:flex}.simple-content[_ngcontent-%COMP%] .event-link[_ngcontent-%COMP%]{margin-left:5px;font-size:.9em;color:var(--color-link, #3498db);text-decoration:none}.simple-content[_ngcontent-%COMP%] .event-link[_ngcontent-%COMP%]:hover{text-decoration:underline}.text-part[_ngcontent-%COMP%]{margin:4px 0}.image-content[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;margin:1em 0}.message-image[_ngcontent-%COMP%]{display:block;max-width:100%;height:auto;margin:8px 0;border-radius:12px;cursor:pointer;box-shadow:var(--glass-shadow);transition:transform .3s ease,box-shadow .3s ease;border:1px solid var(--glass-border)}.message-image[_ngcontent-%COMP%]:hover{transform:scale(1.02) translateY(-2px);box-shadow:0 16px 48px #00000026}@media(max-width:768px){.message-image[_ngcontent-%COMP%]{border-radius:4px;margin:6px 0}}@media(max-width:480px){.message-image[_ngcontent-%COMP%]{margin:4px 0}}"]})};var Ni=(i,e)=>e.id;function $i(i,e){if(i&1&&(a(0,"span",4),p(1),s()),i&2){let t=l();c(),S(t.taskSummary)}}function ji(i,e){i&1&&(a(0,"div",6),y(1,"mat-spinner",8),a(2,"span"),p(3,"Loading..."),s()()),i&2&&(c(),C("diameter",16))}function Ui(i,e){if(i&1&&y(0,"app-delegation-inline",9),i&2){let t=l().$implicit;C("subThreadId",t.subThreadId)("agentName",t.delegationAgentName)}}function Bi(i,e){if(i&1&&y(0,"app-chat-message",10),i&2){let t=l().$implicit;C("message",t)("canDelete",!1)}}function Wi(i,e){if(i&1&&u(0,Ui,1,2,"app-delegation-inline",9)(1,Bi,1,2,"app-chat-message",10),i&2){let t=e.$implicit;g(t.type==="delegation"?0:1)}}function qi(i,e){if(i&1&&(a(0,"div",7)(1,"div",11),p(2),s()()),i&2){let t=l(2);c(2),S(t.streamingText)}}function Yi(i,e){if(i&1&&(a(0,"div",5),u(1,ji,4,1,"div",6),H(2,Wi,2,1,null,null,Ni),u(4,qi,3,1,"div",7),s()),i&2){let t=l();c(),g(t.isLoading&&t.subMessages.length===0?1:-1),c(),V(t.subMessages),c(2),g(t.streamingText?4:-1)}}var it=class i{subThreadId;agentName;isExpanded=!1;isLoading=!1;subMessages=[];streamingText="";restLoaded=!1;messageIds=new Set;eventSubscription;codayService=m(ce);threadApi=m($e);get taskSummary(){let e=this.subMessages.find(t=>t.role==="user");if(e){let t=e.content.filter(n=>n.type==="text").map(n=>n.content).join(" ");return t.length>120?t.substring(0,120)+"...":t}return""}ngOnInit(){for(let e of this.codayService.getBufferedSubThreadEvents(this.subThreadId))this.handleSubThreadEvent(e);this.eventSubscription=this.codayService.subThreadEvents$.pipe(W(e=>e.threadId===this.subThreadId)).subscribe(e=>this.handleSubThreadEvent(e))}ngOnDestroy(){this.eventSubscription?.unsubscribe()}toggle(){this.isExpanded=!this.isExpanded,this.isExpanded&&!this.restLoaded&&this.loadSubThreadMessages()}loadSubThreadMessages(){this.isLoading=!0,this.threadApi.getThreadMessages(this.subThreadId).subscribe({next:e=>{if(e.messages){for(let t of e.messages){let n=vn(t);n&&this.handleSubThreadEvent(n)}this.subMessages=[...this.subMessages].sort((t,n)=>t.id.localeCompare(n.id))}this.restLoaded=!0,this.isLoading=!1},error:e=>{console.error("[DELEGATION-INLINE] Failed to load sub-thread messages:",e),this.restLoaded=!0,this.isLoading=!1}})}handleSubThreadEvent(e){e instanceof mn?this.addMessage({id:e.timestamp,role:"user",speaker:"User",content:[{type:"text",content:e.answer}],timestamp:new Date,type:"text"}):e instanceof un?this.streamingText+=e.chunk:e instanceof fn?(e.role==="assistant"&&(this.streamingText=""),this.addMessage({id:e.timestamp,role:e.role,speaker:e.name,content:e.content,timestamp:new Date,type:"text"})):e instanceof gn?this.addMessage({id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:e.toSingleLineString()}],timestamp:new Date,type:"technical",eventId:e.timestamp}):e instanceof hn?this.addMessage({id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:e.toSingleLineString()}],timestamp:new Date,type:"technical",eventId:e.timestamp}):e instanceof bn?this.addMessage({id:e.timestamp,role:"system",speaker:e.agentName,content:[{type:"text",content:""}],timestamp:new Date,type:"delegation",subThreadId:e.subThreadId,delegationAgentName:e.agentName}):e instanceof pn&&this.addMessage({id:e.timestamp,role:"system",speaker:e.speaker??"System",content:[{type:"text",content:e.text}],timestamp:new Date,type:"technical"})}addMessage(e){this.messageIds.has(e.id)||(this.messageIds.add(e.id),this.subMessages=[...this.subMessages,e])}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=T({type:i,selectors:[["app-delegation-inline"]],inputs:{subThreadId:"subThreadId",agentName:"agentName"},decls:8,vars:4,consts:[[1,"delegation-inline"],["role","button","tabindex","0",1,"delegation-header",3,"click","keydown.enter","keydown.space"],[1,"expand-icon"],[1,"agent-name"],[1,"task-summary"],[1,"delegation-body"],[1,"loading"],[1,"streaming-message"],[3,"diameter"],[3,"subThreadId","agentName"],[3,"message","canDelete"],[1,"content"]],template:function(t,n){t&1&&(a(0,"div",0)(1,"div",1),h("click",function(){return n.toggle()})("keydown.enter",function(){return n.toggle()})("keydown.space",function(){return n.toggle()}),a(2,"mat-icon",2),p(3),s(),a(4,"span",3),p(5),s(),u(6,$i,2,1,"span",4),s(),u(7,Yi,5,2,"div",5),s()),t&2&&(c(3),S(n.isExpanded?"expand_more":"chevron_right"),c(2),S(n.agentName),c(),g(n.taskSummary?6:-1),c(),g(n.isExpanded?7:-1))},dependencies:[i,j,L,R,Ue,je,ve],styles:[".delegation-inline[_ngcontent-%COMP%]{margin:.5rem 0;border-left:3px solid var(--color-primary, #6366f1);border-radius:4px;background:var(--color-bg-secondary);overflow:hidden}.delegation-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;cursor:pointer;-webkit-user-select:none;user-select:none}.delegation-header[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.delegation-header[_ngcontent-%COMP%] .expand-icon[_ngcontent-%COMP%]{font-size:18px;width:18px;height:18px;color:var(--color-text-secondary, #94a3b8)}.delegation-header[_ngcontent-%COMP%] .agent-name[_ngcontent-%COMP%]{font-weight:600;color:var(--color-primary, #6366f1);white-space:nowrap}.delegation-header[_ngcontent-%COMP%] .task-summary[_ngcontent-%COMP%]{flex:1;color:var(--color-text-secondary, #94a3b8);font-size:.85rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.delegation-body[_ngcontent-%COMP%]{padding:0 .75rem .75rem 1.5rem;border-top:1px solid var(--color-border-light)}.delegation-body[_ngcontent-%COMP%] .loading[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.75rem 0;color:var(--color-text-secondary, #94a3b8);font-size:.85rem}.delegation-body[_ngcontent-%COMP%] .sub-messages[_ngcontent-%COMP%]{padding:.5rem 0}"]})};var ot=class i{thinkingPhrases=["Processing request...","Thinking...","Working on it..."];currentThinkingPhrase="Processing request...";thinkingPhraseIndex=0;thinkingInterval=null;ngOnInit(){this.startThinkingAnimation()}ngOnDestroy(){this.stopThinkingAnimation()}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..."}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=T({type:i,selectors:[["app-thinking-loader"]],decls:8,vars:1,consts:[[1,"message-wrapper"],[1,"message","assistant","thinking-message"],[1,"content"],[1,"thinking-loader"],[1,"logo-container"],["src","CODAY-Logo.png","alt","Coday Logo",1,"coday-logo"],[1,"thinking-text"]],template:function(t,n){t&1&&(yt(0,"div",0)(1,"div",1)(2,"div",2)(3,"div",3)(4,"div",4),Bt(5,"img",5),wt(),yt(6,"p",6),p(7),wt()()()()()),t&2&&(c(7),S(n.currentThinkingPhrase))},dependencies:[j],styles:[".message-wrapper[_ngcontent-%COMP%]{margin:0;display:flex;align-items:flex-start;gap:.5rem}.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}.message.thinking-message[_ngcontent-%COMP%] .content[_ngcontent-%COMP%]{line-height:1.5}.thinking-loader[_ngcontent-%COMP%]{display:flex;align-items:center;gap:1rem;padding:.75rem 0}.logo-container[_ngcontent-%COMP%]{position:relative;width:32px;height:32px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.coday-logo[_ngcontent-%COMP%]{width:100%;height:100%;object-fit:contain;animation:_ngcontent-%COMP%_pulse 2s ease-in-out infinite;filter:drop-shadow(0 1px 4px rgba(0,0,0,.1))}.thinking-text[_ngcontent-%COMP%]{font-size:.95rem;font-weight:400;color:var(--color-text-secondary);margin:0;animation:_ngcontent-%COMP%_fadeInOut 2s ease-in-out infinite;letter-spacing:.01em;font-style:italic}@keyframes _ngcontent-%COMP%_pulse{0%,to{transform:scale(1);opacity:1}50%{transform:scale(1.1);opacity:.7}}@keyframes _ngcontent-%COMP%_fadeInOut{0%,to{opacity:.6}50%{opacity:1}}@media(max-width:768px){.logo-container[_ngcontent-%COMP%]{width:28px;height:28px}.thinking-text[_ngcontent-%COMP%]{font-size:.875rem}.thinking-loader[_ngcontent-%COMP%]{gap:.75rem}}@media print{.thinking-loader[_ngcontent-%COMP%]{display:none!important}}"]})};var Gi=(i,e)=>e.id;function Qi(i,e){if(i&1&&y(0,"app-delegation-inline",3),i&2){let t=l().$implicit;C("subThreadId",t.subThreadId)("agentName",t.delegationAgentName)}}function Xi(i,e){if(i&1){let t=_();a(0,"app-chat-message",5),h("copyRequested",function(o){f(t);let r=l(2);return b(r.onCopyMessage(o))})("deleteRequested",function(o){f(t);let r=l(2);return b(r.onDeleteMessage(o))}),s()}if(i&2){let t=l(),n=t.$implicit,o=t.$index,r=l();C("message",n)("canDelete",r.canDeleteMessage(o))("isOtherUser",n.role==="user"&&!!r.currentUsername&&n.speaker!==r.currentUsername)}}function Ki(i,e){if(i&1&&u(0,Qi,1,2,"app-delegation-inline",3)(1,Xi,1,3,"app-chat-message",4),i&2){let t=e.$implicit;g(t.type==="delegation"?0:1)}}function Ji(i,e){if(i&1&&(a(0,"div",1),y(1,"div",6),s()),i&2){let t=l();c(),C("innerHTML",t.renderedStreamingText,z)}}function Zi(i,e){i&1&&y(0,"app-thinking-loader")}function eo(i,e){if(i&1){let t=_();a(0,"button",7),h("click",function(){f(t);let o=l();return b(o.goToBottom())}),a(1,"mat-icon",8),p(2,"arrow_downward"),s()()}}var rt=class i{messages=[];streamingText="";isThinking=!1;currentUsername="";copyRequested=new M;stopRequested=new M;lastMessageCount=0;destroy$=new B;renderedStreamingText="";isTracking=!0;showGoToBottom=!1;scrollContainer=null;lastScrollTop=0;NEAR_BOTTOM_THRESHOLD=100;scrollCheckTimeout;isProgrammaticScroll=!1;MESSAGE_FRESHNESS_THRESHOLD=300*1e3;elementRef=m(ue);unreadService=m(be);voiceSynthesisService=m(_n);preferencesService=m(se);codayService=m(ce);markdownService=m(K);sanitizer=m(G);ngOnInit(){this.findScrollContainer(),this.setupFocusListeners()}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),this.scrollCheckTimeout&&clearTimeout(this.scrollCheckTimeout),window.removeEventListener("focus",this.handleWindowFocus),window.removeEventListener("blur",this.handleWindowBlur)}ngOnChanges(e){e.streamingText&&(this.renderStreamingText(),this.streamingText&&this.isTracking&&setTimeout(()=>this.scrollToBottom(),0))}ngAfterViewChecked(){if(this.messages.length!==this.lastMessageCount){console.log("[CHAT-HISTORY] Message count changed:",this.lastMessageCount,"->",this.messages.length);let e=this.messages.length-this.lastMessageCount;e>0&&(this.handleNewMessages(e),this.handleVoiceAnnouncement(e)),this.lastMessageCount=this.messages.length,this.isTracking&&this.scrollToBottom()}this.scrollContainer||this.findScrollContainer()}scrollToBottom(){try{this.scrollContainer||this.findScrollContainer(),this.scrollContainer&&(this.isProgrammaticScroll=!0,setTimeout(()=>{this.scrollContainer&&this.scrollContainer.scrollTo({top:this.scrollContainer.scrollHeight,behavior:"smooth"}),setTimeout(()=>{this.isProgrammaticScroll=!1},600)},50))}catch(e){console.error("Error scrolling to bottom:",e)}}trackByMessageId(e,t){return t.id}onCopyMessage(e){let t=e.content.filter(n=>n.type==="text").map(n=>n.content).join(`
|
|
23
|
+
|
|
24
|
+
`);navigator.clipboard.writeText(t).then(()=>console.log("Message copied")).catch(n=>console.error("Failed to copy:",n)),this.copyRequested.emit(e)}onStop(){this.stopRequested.emit()}canDeleteMessage(e){return e===0?!1:!this.isThinking}onDeleteMessage(e){if(console.log("[CHAT-HISTORY] Delete requested for message:",e.id),this.messages.findIndex(o=>o.id===e.id)===0){console.warn("[CHAT-HISTORY] Cannot delete first message");return}if(this.isThinking){console.warn("[CHAT-HISTORY] Cannot delete message while agent is thinking");return}if(e.role!=="user"){console.warn("[CHAT-HISTORY] Can only delete user messages");return}confirm(`Delete this message and all following messages?
|
|
25
|
+
|
|
26
|
+
This action cannot be undone once you post another message.`)&&(console.log("[CHAT-HISTORY] Proceeding with message deletion"),this.codayService.deleteMessage(e.id).subscribe({next:o=>{o.success?console.log("[CHAT-HISTORY] Message deleted successfully"):(console.error("[CHAT-HISTORY] Failed to delete message:",o.error),alert(`Failed to delete message: ${o.error}`))},error:o=>{console.error("[CHAT-HISTORY] Error deleting message:",o),alert(`Error deleting message: ${o.message||"Unknown error"}`)}}))}onScroll(){}findScrollContainer(){let e=this.elementRef.nativeElement;this.scrollContainer=e.closest(".chat-wrapper"),this.scrollContainer?(console.log("[CHAT-HISTORY] Scroll container found"),this.scrollContainer.addEventListener("scroll",this.handleScroll.bind(this)),this.lastScrollTop=this.scrollContainer.scrollTop,this.checkScrollPosition()):(console.warn("[CHAT-HISTORY] Scroll container not found"),setTimeout(()=>this.findScrollContainer(),100))}handleScroll=()=>{if(!this.scrollContainer)return;let e=this.scrollContainer.scrollTop;if(Math.abs(e-this.lastScrollTop)<1){this.lastScrollTop=e;return}if(this.isProgrammaticScroll){this.lastScrollTop=e;return}console.log("[CHAT-HISTORY] User scroll detected - disabling auto-scroll"),this.isTracking&&(this.isTracking=!1,this.showGoToBottom=!0),clearTimeout(this.scrollCheckTimeout),this.scrollCheckTimeout=setTimeout(()=>{this.checkScrollPosition()},500),this.lastScrollTop=e};checkScrollPosition(){if(!this.scrollContainer)return;let{scrollTop:e,scrollHeight:t,clientHeight:n}=this.scrollContainer,r=t-e-n<=this.NEAR_BOTTOM_THRESHOLD;r&&!this.isTracking&&(console.log("[CHAT-HISTORY] Near bottom - re-enabling auto-scroll"),this.isTracking=!0,this.showGoToBottom=!1,this.unreadService.markAllAsRead()),!this.isTracking&&!r&&(this.showGoToBottom=!0)}goToBottom(){console.log("[CHAT-HISTORY] Go to bottom clicked - re-enabling auto-scroll"),this.scrollToBottom(),this.isTracking=!0,this.showGoToBottom=!1,this.unreadService.markAllAsRead()}handleNewMessages(e){let n=this.messages.slice(-e).filter(r=>r.role==="assistant");if(n.length===0){console.log("[CHAT-HISTORY] No new assistant messages to count");return}if(this.shouldMarkNewMessagesAsUnread()){console.log("[CHAT-HISTORY] Marking",n.length,"new assistant messages as unread");for(let r=0;r<n.length;r++)this.unreadService.addUnread()}else console.log("[CHAT-HISTORY] New assistant messages are considered read (user is focused and tracking)")}shouldMarkNewMessagesAsUnread(){return document.hasFocus()?this.isTracking?!1:(console.log("[CHAT-HISTORY] User is not tracking (scrolled up) -> unread"),!0):(console.log("[CHAT-HISTORY] Tab does not have focus -> unread"),!0)}setupFocusListeners(){window.addEventListener("focus",this.handleWindowFocus),window.addEventListener("blur",this.handleWindowBlur)}handleWindowFocus=()=>{console.log("[CHAT-HISTORY] Window gained focus"),this.isTracking&&(console.log("[CHAT-HISTORY] User is tracking and focused -> marking messages as read"),this.unreadService.markAllAsRead())};handleWindowBlur=()=>{console.log("[CHAT-HISTORY] Window lost focus")};handleVoiceAnnouncement(e){if(!this.preferencesService.getVoiceAnnounceEnabled())return;let o=this.messages.slice(-e).filter(v=>v.role==="assistant");if(o.length===0){console.log("[CHAT-HISTORY] No new assistant messages to announce");return}let r=o[o.length-1];if(!r){console.warn("[CHAT-HISTORY] No last assistant message found");return}if(!this.isMessageRecentEnoughForAnnouncement(r)){console.log("[CHAT-HISTORY] Message too old for voice announcement");return}if(this.preferencesService.getVoiceMode()==="notification")console.log("[CHAT-HISTORY] Playing notification sound for new assistant message"),this.voiceSynthesisService.ding();else{let v=this.extractTextContentFromMessage(r);if(v.trim()){console.log("[CHAT-HISTORY] Announcing new assistant message via speech");let U=this.preferencesService.getVoiceReadFullText()?v:this.extractPartialText(v);this.voiceSynthesisService.speak(U).then(D=>{D||console.warn("[CHAT-HISTORY] Failed to announce message via speech")}).catch(D=>{console.error("[CHAT-HISTORY] Error during voice announcement:",D)})}}}isMessageRecentEnoughForAnnouncement(e){try{let t=e.timestamp.getTime();return Date.now()-t<=this.MESSAGE_FRESHNESS_THRESHOLD}catch(t){return console.warn("[CHAT-HISTORY] Error checking message freshness:",t),!0}}extractTextContentFromMessage(e){return e.content.filter(t=>t.type==="text").map(t=>t.content).join(`
|
|
27
|
+
|
|
28
|
+
`)}extractPartialText(e){return e.split(`
|
|
29
|
+
`).filter(d=>d.trim().length>0).reduce((d,v)=>{if(d.paragraphs>=3)return d;let x=v.length>80?1:0;return{paragraphs:d.paragraphs+x,text:d.text+(d.text?`
|
|
30
|
+
`:"")+v}},{paragraphs:0,text:""}).text||e}renderStreamingText(){return P(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=T({type:i,selectors:[["app-chat-history"]],hostBindings:function(t,n){t&1&&h("scroll",function(){return n.onScroll()})},inputs:{messages:"messages",streamingText:"streamingText",isThinking:"isThinking",currentUsername:"currentUsername"},outputs:{copyRequested:"copyRequested",stopRequested:"stopRequested"},features:[q],decls:6,vars:3,consts:[[1,"chat-history"],[1,"streaming-message","message","assistant"],["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&&(a(0,"div",0),H(1,Ki,2,1,null,null,Gi),u(3,Ji,2,1,"div",1),u(4,Zi,1,0,"app-thinking-loader"),u(5,eo,3,0,"button",2),s()),t&2&&(c(),V(n.messages),c(2),g(n.streamingText?3:-1),c(),g(n.isThinking?4:-1),c(),g(n.showGoToBottom?5:-1))},dependencies:[ve,R,ot,Ne,it],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}}"]})};var to=["buttonContainer"],no=["freeTextInput"],io=(i,e)=>e.value;function oo(i,e){i&1&&(a(0,"mat-icon",10),p(1,"keyboard_return"),s())}function ro(i,e){if(i&1){let t=_();a(0,"button",8),h("click",function(){let o=f(t).$implicit,r=l(2);return b(r.onOptionClick(o.value))}),a(1,"span",9),p(2),s(),u(3,oo,2,0,"mat-icon",10),s()}if(i&2){let t=e.$implicit,n=e.$index,o=l(2);N("highlighted",n===o.highlightedIndex),C("disabled",t.disabled)("id","choice-option-"+n),oe("aria-selected",n===o.highlightedIndex),c(2),S(t.label),c(),g(n===o.highlightedIndex?3:-1)}}function ao(i,e){if(i&1){let t=_();a(0,"div",6)(1,"span",11),p(2,"Or type your own answer:"),s(),a(3,"div",12)(4,"input",13,1),He("ngModelChange",function(o){f(t);let r=l(2);return Re(r.freeTextValue,o)||(r.freeTextValue=o),b(o)}),h("keydown",function(o){f(t);let r=l(2);return b(r.onFreeTextKeyDown(o))}),s(),a(6,"button",14),h("click",function(){f(t);let o=l(2);return b(o.onFreeTextSubmit())}),a(7,"mat-icon"),p(8,"send"),s()()()()}if(i&2){let t=l(2);c(4),Fe("ngModel",t.freeTextValue),c(2),C("disabled",!t.freeTextValue.trim())}}function so(i,e){if(i&1&&(a(0,"div",7)(1,"mat-icon"),p(2,"search"),s(),a(3,"span"),p(4),s()()),i&2){let t=l(2);c(4),S(t.searchText)}}function co(i,e){if(i&1){let t=_();a(0,"div",2),y(1,"div",3),Ee(2,"async"),a(3,"div",4,0),h("keydown",function(o){f(t);let r=l();return b(r.onKeyDown(o))}),H(5,ro,4,7,"button",5,io),s(),u(7,ao,9,2,"div",6),u(8,so,5,1,"div",7),s()}if(i&2){let t=l();c(),C("innerHTML",Qt(2,4,t.renderedLabel$),z),c(2),oe("aria-activedescendant","choice-option-"+t.highlightedIndex),c(2),V(t.options),c(2),g(t.allowFreeText?7:-1),c(),g(t.searchText?8:-1)}}var at=class i{options=[];allowFreeText=!1;set labelHtml(e){typeof e=="object"?this.renderedLabelSubject.next(e):this.renderLabelMarkdown(e)}isVisible=!1;choiceSelected=new M;buttonContainer;freeTextInput;highlightedIndex=0;searchText="";freeTextValue="";searchTimeout;destroy$=new B;renderedLabelSubject=new Ie("");renderedLabel$=this.renderedLabelSubject.asObservable();sanitizer=m(G);markdownService=m(K);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 P(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=T({type:i,selectors:[["app-choice-select"]],viewQuery:function(t,n){if(t&1&&ge(to,5)(no,5),t&2){let o;J(o=Z())&&(n.buttonContainer=o.first),J(o=Z())&&(n.freeTextInput=o.first)}},inputs:{options:"options",allowFreeText:"allowFreeText",labelHtml:"labelHtml",isVisible:"isVisible"},outputs:{choiceSelected:"choiceSelected"},features:[q],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&&u(0,co,9,6,"div",2),t&2&&g(n.isVisible?0:-1)},dependencies:[L,R,Ye,Be,We,qe,Xt],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}}"]})};function lo(i,e){if(i&1){let t=_();a(0,"div",0)(1,"div",1)(2,"mat-icon"),p(3,"lock_open"),s()(),a(4,"div",2)(5,"p",3),p(6,"Authorization required"),s(),a(7,"p",4)(8,"strong"),p(9),s(),p(10," needs your permission to continue. "),s()(),a(11,"div",5)(12,"button",6),h("click",function(){let o=f(t),r=l();return b(r.onCancel(o))}),p(13,"Cancel"),s(),a(14,"button",7),h("click",function(){let o=f(t),r=l();return b(r.onAuthorize(o))}),a(15,"mat-icon"),p(16,"open_in_new"),s(),p(17," Authorize "),s()()()}i&2&&(c(9),S(e.integrationName))}var st=class i{oauthService=m(Ke);pendingRequest=Ge(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=T({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&&u(0,lo,18,1,"div",0),t&2){let o;g((o=n.pendingRequest())?0:-1,o)}},dependencies:[L,R],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}"],changeDetection:0})};var ct=class i{http=m(Y);projectState=m(Q);threadState=m(X);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 ke(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:x=>{o.next({success:x.success,filename:x.filename}),o.complete()},error:x=>o.error(x)})},r.onerror=()=>o.error(new Error("Failed to read file")),r.readAsDataURL(e)})}listFiles(){return this.http.get(this.getBaseUrl()).pipe(ne(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=k({token:i,factory:i.\u0275fac,providedIn:"root"})};var _e=class i{fileApi=m(ct);eventStream=m(Xe);filesSignal=ie([]);isLoadingSignal=ie(!1);currentProjectSignal=ie(null);currentThreadSignal=ie(null);files=Ve(()=>this.filesSignal());isLoading=Ve(()=>this.isLoadingSignal());fileCount=Ve(()=>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(!0),this.fileApi.listFiles().subscribe({next:e=>{let t=e.map(n=>Oe(de({},n),{lastModified:new Date(n.lastModified)})).sort((n,o)=>o.lastModified.getTime()-n.lastModified.getTime());this.filesSignal.set(t),this.isLoadingSignal.set(!1)},error:e=>{console.error("[FILE_EXCHANGE_STATE] Error loading files:",e),this.isLoadingSignal.set(!1)}})}uploadFile(e){return P(this,null,function*(){return new Promise(t=>{this.fileApi.uploadFile(e).subscribe({next:()=>{this.refreshFileList(),t({success:!0})},error:n=>{console.error("[FILE_EXCHANGE_STATE] Upload error:",n),t({success:!1,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 P(this,null,function*(){return new Promise(t=>{this.fileApi.deleteFile(e).subscribe({next:()=>{this.refreshFileList(),t({success:!0})},error:n=>{console.error("[FILE_EXCHANGE_STATE] Delete error:",n),t({success:!1,error:n.message||"Delete failed"})}})})})}subscribeToFileEvents(){this.eventStream.events$.pipe(W(e=>e instanceof Qe),dn()).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(x=>x.filename!==e.filename),o=t.find(x=>x.filename===e.filename),r=e.timestamp,d=e.timestamp.lastIndexOf("-");if(d>0){let x=e.timestamp.substring(d+1);x.length===5&&/^[a-z0-9]+$/.test(x)&&(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=k({token:i,factory:i.\u0275fac,providedIn:"root"})};function mo(i,e){if(i&1&&y(0,"div",1),i&2){let t=l();C("innerHTML",t.renderedContent,z)}}function po(i,e){if(i&1&&y(0,"iframe",2),i&2){let t=l();C("srcdoc",t.content,z)}}function uo(i,e){if(i&1&&(a(0,"pre",3),p(1),s()),i&2){let t=l();c(),S(t.content)}}var lt=class i{content="";format="text";renderedContent="";sanitizer=m(G);markdownService=m(K);ngOnChanges(e){(e.content||e.format)&&this.renderContent()}renderContent(){this.format==="markdown"?this.renderMarkdown():this.format==="json"&&this.formatJson()}renderMarkdown(){return P(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=T({type:i,selectors:[["app-content-renderer"]],inputs:{content:"content",format:"format"},features:[q],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&&(a(0,"div",0),u(1,mo,1,1,"div",1)(2,po,1,1,"iframe",2)(3,uo,2,1,"pre",3),s()),t&2&&(C("ngClass","format-"+n.format),c(),g(n.format==="markdown"?1:n.format==="html"?2:3))},dependencies:[j,ze],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}"]})};var xe=class i{http=m(Y);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(ne(d=>{let v=d.body||"",x=new Blob([v]).size;return{content:v,format:r,filename:n,size:x}}),De(d=>(console.error("[CONTENT_VIEWER] Error loading file:",n,d),Dt(()=>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=k({token:i,factory:i.\u0275fac,providedIn:"root"})};function go(i,e){if(i&1){let t=_();a(0,"button",12),h("click",function(){f(t);let o=l();return b(o.download())}),a(1,"mat-icon"),p(2,"download"),s()()}}function ho(i,e){i&1&&(a(0,"div",9),y(1,"mat-spinner",13),a(2,"p"),p(3,"Loading file content..."),s()())}function fo(i,e){if(i&1){let t=_();a(0,"div",10)(1,"mat-icon",14),p(2,"error_outline"),s(),a(3,"p",15),p(4),s(),a(5,"button",16),h("click",function(){f(t);let o=l();return b(o.download())}),a(6,"mat-icon"),p(7,"download"),s(),p(8," Download instead "),s()()}if(i&2){let t=l();c(4),S(t.error)}}function bo(i,e){if(i&1&&y(0,"app-content-renderer",11),i&2){let t=l();C("content",t.fileContent.content)("format",t.fileContent.format)}}var dt=class i{destroy$=new B;file;projectName;threadId;closeViewer=new M;contentService=m(xe);eventStream=m(Xe);fileContent=null;isLoading=!1;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=!0,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=!1},error:e=>{console.error("[CONTENT_VIEWER] Error loading content:",e),this.error=e.message||"Failed to load file content",this.isLoading=!1}})}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(W(e=>e instanceof Qe),W(e=>e.filename===this.file.filename),W(e=>e.operation==="updated"),F(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=T({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&&(a(0,"div",0)(1,"div",1)(2,"div",2)(3,"span",3),p(4),s(),a(5,"span",4),p(6),s()(),a(7,"div",5),u(8,go,3,0,"button",6),a(9,"button",7),h("click",function(){return n.onClose()}),a(10,"mat-icon"),p(11,"chevron_right"),s()()()(),a(12,"div",8),u(13,ho,4,0,"div",9),u(14,fo,9,1,"div",10),u(15,bo,1,2,"app-content-renderer",11),s()()),t&2&&(c(4),S(n.file.filename),c(2),S(n.formatSize(n.file.size)),c(2),g(n.fileContent&&!n.isLoading&&!n.error?8:-1),c(5),g(n.isLoading?13:-1),c(),g(n.error?14:-1),c(),g(n.fileContent&&!n.isLoading&&!n.error?15:-1))},dependencies:[j,L,R,ae,sn,re,Ue,je,lt],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}"]})};var vo=Math.pow(10,8)*24*60*60*1e3,Cl=-vo,mt=6048e5,Dn=864e5;var Co=3600;var An=Co*24,_l=An*7,_o=An*365.2425,xo=_o/12,xl=xo*3,Et=Symbol.for("constructDateFrom");function I(i,e){return typeof i=="function"?i(e):i&&typeof i=="object"&&Et in i?i[Et](e):i instanceof Date?new i.constructor(e):new Date(e)}function O(i,e){return I(e||i,i)}function Fn(i,e,t){let n=O(i,t?.in);return isNaN(e)?I(t?.in||i,NaN):(e&&n.setDate(n.getDate()+e),n)}var yo={};function le(){return yo}function ee(i,e){let t=le(),n=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,o=O(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 me(i,e){return ee(i,Oe(de({},e),{weekStartsOn:1}))}function pt(i,e){let t=O(i,e?.in),n=t.getFullYear(),o=I(t,0);o.setFullYear(n+1,0,4),o.setHours(0,0,0,0);let r=me(o),d=I(t,0);d.setFullYear(n,0,4),d.setHours(0,0,0,0);let v=me(d);return t.getTime()>=r.getTime()?n+1:t.getTime()>=v.getTime()?n:n-1}function Pt(i){let e=O(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 ye(i,...e){let t=I.bind(null,i||e.find(n=>typeof n=="object"));return e.map(t)}function we(i,e){let t=O(i,e?.in);return t.setHours(0,0,0,0),t}function ut(i,e,t){let[n,o]=ye(t?.in,i,e),r=we(n),d=we(o),v=+r-Pt(r),x=+d-Pt(d);return Math.round((v-x)/Dn)}function Rn(i,e){let t=pt(i,e),n=I(e?.in||i,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),me(n)}function Hn(i){return I(i,Date.now())}function Vn(i,e,t){let[n,o]=ye(t?.in,i,e);return+we(n)==+we(o)}function Ln(i){return i instanceof Date||typeof i=="object"&&Object.prototype.toString.call(i)==="[object Date]"}function zn(i){return!(!Ln(i)&&typeof i!="number"||isNaN(+O(i)))}function $n(i,e,t){let[n,o]=ye(t?.in,i,e),r=Nn(n,o),d=Math.abs(ut(n,o));n.setDate(n.getDate()-r*d);let v=+(Nn(n,o)===-r),x=r*(d-v);return x===0?0:x}function Nn(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 jn(i,e){let t=O(i,e?.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}var wo={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"}},Un=(i,e,t)=>{let n,o=wo[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 gt(i){return(e={})=>{let t=e.width?String(e.width):i.defaultWidth;return i.formats[t]||i.formats[i.defaultWidth]}}var To={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},So={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Mo={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Bn={date:gt({formats:To,defaultWidth:"full"}),time:gt({formats:So,defaultWidth:"full"}),dateTime:gt({formats:Mo,defaultWidth:"full"})};var Eo={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Wn=(i,e,t,n)=>Eo[i];function Te(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 Po={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Oo={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ko={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"]},Io={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"]},Do={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"}},Ao={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"}},Fo=(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"},qn={ordinalNumber:Fo,era:Te({values:Po,defaultWidth:"wide"}),quarter:Te({values:Oo,defaultWidth:"wide",argumentCallback:i=>i-1}),month:Te({values:ko,defaultWidth:"wide"}),day:Te({values:Io,defaultWidth:"wide"}),dayPeriod:Te({values:Do,defaultWidth:"wide",formattingValues:Ao,defaultFormattingWidth:"wide"})};function Se(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],x=Array.isArray(v)?Ho(v,A=>A.test(d)):Ro(v,A=>A.test(d)),U;U=i.valueCallback?i.valueCallback(x):x,U=t.valueCallback?t.valueCallback(U):U;let D=e.slice(d.length);return{value:U,rest:D}}}function Ro(i,e){for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&e(i[t]))return t}function Ho(i,e){for(let t=0;t<i.length;t++)if(e(i[t]))return t}function Yn(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 Vo=/^(\d+)(th|st|nd|rd)?/i,Lo=/\d+/i,zo={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},No={any:[/^b/i,/^(a|c)/i]},$o={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},jo={any:[/1/i,/2/i,/3/i,/4/i]},Uo={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},Bo={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]},Wo={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},qo={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]},Yo={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},Go={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}},Gn={ordinalNumber:Yn({matchPattern:Vo,parsePattern:Lo,valueCallback:i=>parseInt(i,10)}),era:Se({matchPatterns:zo,defaultMatchWidth:"wide",parsePatterns:No,defaultParseWidth:"any"}),quarter:Se({matchPatterns:$o,defaultMatchWidth:"wide",parsePatterns:jo,defaultParseWidth:"any",valueCallback:i=>i+1}),month:Se({matchPatterns:Uo,defaultMatchWidth:"wide",parsePatterns:Bo,defaultParseWidth:"any"}),day:Se({matchPatterns:Wo,defaultMatchWidth:"wide",parsePatterns:qo,defaultParseWidth:"any"}),dayPeriod:Se({matchPatterns:Yo,defaultMatchWidth:"any",parsePatterns:Go,defaultParseWidth:"any"})};var Ot={code:"en-US",formatDistance:Un,formatLong:Bn,formatRelative:Wn,localize:qn,match:Gn,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Qn(i,e){let t=O(i,e?.in);return ut(t,jn(t))+1}function Xn(i,e){let t=O(i,e?.in),n=+me(t)-+Rn(t);return Math.round(n/mt)+1}function ht(i,e){let t=O(i,e?.in),n=t.getFullYear(),o=le(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,d=I(e?.in||i,0);d.setFullYear(n+1,0,r),d.setHours(0,0,0,0);let v=ee(d,e),x=I(e?.in||i,0);x.setFullYear(n,0,r),x.setHours(0,0,0,0);let U=ee(x,e);return+t>=+v?n+1:+t>=+U?n:n-1}function Kn(i,e){let t=le(),n=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,o=ht(i,e),r=I(e?.in||i,0);return r.setFullYear(o,0,n),r.setHours(0,0,0,0),ee(r,e)}function Jn(i,e){let t=O(i,e?.in),n=+ee(t,e)-+Kn(t,e);return Math.round(n/mt)+1}function w(i,e){let t=i<0?"-":"",n=Math.abs(i).toString().padStart(e,"0");return t+n}var te={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 Me={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},kt={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 te.y(i,e)},Y:function(i,e,t,n){let o=ht(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=pt(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 te.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=Jn(i,n);return e==="wo"?t.ordinalNumber(o,{unit:"week"}):w(o,e.length)},I:function(i,e,t){let n=Xn(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"}):te.d(i,e)},D:function(i,e,t){let n=Qn(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=Me.noon:n===0?o=Me.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=Me.evening:n>=12?o=Me.afternoon:n>=4?o=Me.morning:o=Me.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 te.h(i,e)},H:function(i,e,t){return e==="Ho"?t.ordinalNumber(i.getHours(),{unit:"hour"}):te.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"}):te.m(i,e)},s:function(i,e,t){return e==="so"?t.ordinalNumber(i.getSeconds(),{unit:"second"}):te.s(i,e)},S:function(i,e){return te.S(i,e)},X:function(i,e,t){let n=i.getTimezoneOffset();if(n===0)return"Z";switch(e){case"X":return ei(n);case"XXXX":case"XX":return pe(n);default:return pe(n,":")}},x:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"x":return ei(n);case"xxxx":case"xx":return pe(n);default:return pe(n,":")}},O:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+Zn(n,":");default:return"GMT"+pe(n,":")}},z:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+Zn(n,":");default:return"GMT"+pe(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 Zn(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 ei(i,e){return i%60===0?(i>0?"-":"+")+w(Math.abs(i)/60,2):pe(i,e)}function pe(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 ti=(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"})}},ni=(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"})}},Qo=(i,e)=>{let t=i.match(/(P+)(p+)?/)||[],n=t[1],o=t[2];if(!o)return ti(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}}",ti(n,e)).replace("{{time}}",ni(o,e))},ii={p:ni,P:Qo};var Xo=/^D+$/,Ko=/^Y+$/,Jo=["D","DD","YY","YYYY"];function oi(i){return Xo.test(i)}function ri(i){return Ko.test(i)}function ai(i,e,t){let n=Zo(i,e,t);if(console.warn(n),Jo.includes(i))throw new RangeError(n)}function Zo(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 er=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,tr=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,nr=/^'([^]*?)'?$/,ir=/''/g,or=/[a-zA-Z]/;function It(i,e,t){let n=le(),o=t?.locale??n.locale??Ot,r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,d=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,v=O(i,t?.in);if(!zn(v))throw new RangeError("Invalid time value");let x=e.match(tr).map(D=>{let A=D[0];if(A==="p"||A==="P"){let _t=ii[A];return _t(D,o.formatLong)}return D}).join("").match(er).map(D=>{if(D==="''")return{isToken:!1,value:"'"};let A=D[0];if(A==="'")return{isToken:!1,value:rr(D)};if(kt[A])return{isToken:!0,value:D};if(A.match(or))throw new RangeError("Format string contains an unescaped latin alphabet character `"+A+"`");return{isToken:!1,value:D}});o.localize.preprocessor&&(x=o.localize.preprocessor(v,x));let U={firstWeekContainsDate:r,weekStartsOn:d,locale:o};return x.map(D=>{if(!D.isToken)return D.value;let A=D.value;(!t?.useAdditionalWeekYearTokens&&ri(A)||!t?.useAdditionalDayOfYearTokens&&oi(A))&&ai(A,e,String(i));let _t=kt[A[0]];return _t(v,A,o.localize,U)}).join("")}function rr(i){let e=i.match(nr);return e?e[1].replace(ir,"'"):i}function si(i,e,t){return Fn(i,-e,t)}function ci(i,e){return Vn(I(e?.in||i,i),si(Hn(e?.in||i),1))}function li(i){if(!i||isNaN(i.getTime()))return"unknown";let e=new Date,t=It(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(ci(i))return`yesterday ${t}`;let d=$n(e,i);return d<7?`${d}d ago ${t}`:`${It(i,"dd/MM/yyyy")} ${t}`}var ar=(i,e)=>e.filename;function sr(i,e){if(i&1){let t=_();a(0,"button",11),h("click",function(){f(t);let o=l(2);return b(o.downloadAll())}),a(1,"mat-icon"),p(2,"download_for_offline"),s()()}}function cr(i,e){i&1&&(a(0,"div",10),y(1,"span",12),a(2,"span",13),p(3,"Loading files..."),s()())}function lr(i,e){i&1&&(a(0,"div",14)(1,"mat-icon",15),p(2,"folder_open"),s(),a(3,"p",16),p(4,"No files in exchange space"),s(),a(5,"p",17),p(6,"Upload files to share with the agent"),s()())}function dr(i,e){if(i&1){let t=_();a(0,"button",28),h("click",function(){f(t);let o=l().$implicit,r=l(4);return b(r.viewFile(o))}),a(1,"mat-icon"),p(2,"visibility"),s()()}}function mr(i,e){if(i&1){let t=_();a(0,"div",18)(1,"div",19)(2,"mat-icon",20),p(3),s(),a(4,"div",21)(5,"span",22),p(6),s(),a(7,"span",23),p(8),s()()(),a(9,"div",24),u(10,dr,3,0,"button",25),a(11,"button",26),h("click",function(){let o=f(t).$implicit,r=l(4);return b(r.download(o))}),a(12,"mat-icon"),p(13,"download"),s()(),a(14,"button",27),h("click",function(){let o=f(t).$implicit,r=l(4);return b(r.delete(o))}),a(15,"mat-icon"),p(16,"delete"),s()()()()}if(i&2){let t=e.$implicit,n=l(4);c(3),S(n.getFileIcon(t.filename)),c(2),C("title",t.filename),c(),S(t.filename),c(2),Ae("",n.formatSize(t.size)," \u2022 ",n.formatDate(t.lastModified)),c(2),g(n.canViewFile(t)?10:-1)}}function pr(i,e){if(i&1&&H(0,mr,17,6,"div",18,ar),i&2){let t=l(3);V(t.files())}}function ur(i,e){if(i&1&&u(0,lr,7,0,"div",14)(1,pr,2,0),i&2){let t=l(2);g(t.files().length===0?0:1)}}function gr(i,e){if(i&1){let t=_();a(0,"div",0)(1,"div",2)(2,"div",3)(3,"h3",4),p(4,"Exchange"),s(),a(5,"span",5),p(6),s()(),a(7,"div",6),u(8,sr,3,0,"button",7),a(9,"button",8),h("click",function(){f(t);let o=l();return b(o.close())}),a(10,"mat-icon"),p(11,"chevron_right"),s()()()(),a(12,"div",9),u(13,cr,4,0,"div",10)(14,ur,2,1),s()()}if(i&2){let t=l();c(6),he("(",t.files().length,")"),c(2),g(t.files().length>0?8:-1),c(5),g(t.isLoading()?13:14)}}function hr(i,e){if(i&1){let t=_();a(0,"app-content-viewer",29),h("closeViewer",function(){f(t);let o=l();return b(o.backToList())}),s()}if(i&2){let t=l();C("file",t.currentFile)("projectName",t.projectName)("threadId",t.threadId)}}var ft=class i{projectName;threadId;closeDrawer=new M;fileExchangeState=m(_e);contentViewerService=m(xe);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 P(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 li(e)}canViewFile(e){return this.contentViewerService.isFormatViewable(e.filename)&&this.contentViewerService.isViewable(e.size)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=T({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&&(u(0,gr,15,3,"div",0),u(1,hr,1,3,"app-content-viewer",1)),t&2&&(g(n.viewerState==="list"?0:-1),c(),g(n.viewerState==="content"&&n.currentFile?1:-1))},dependencies:[j,L,R,ae,re,dt],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))}}"]})};var bt=class i{http=m(Y);listUsers(){return this.http.get("/api/users")}static \u0275fac=function(t){return new(t||i)};static \u0275prov=k({token:i,factory:i.\u0275fac,providedIn:"root"})};var vt=class i{excludedUserIds=[];placeholder="Search username";disabled=!1;userSelected=new M;userApi=m(bt);search(e){let t=e.toLowerCase();return this.userApi.listUsers().pipe(ne(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=T({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&&(a(0,"ds-autocomplete-input",0),h("itemSelected",function(r){return n.onItemSelected(r)}),s()),t&2&&C("dataSource",n)("placeholder",n.placeholder)("disabled",n.disabled)},dependencies:[kn],styles:["[_nghost-%COMP%]{display:block}"]})};var fr=(i,e)=>e.userId;function br(i,e){if(i&1&&(a(0,"div",7),p(1),s()),i&2){let t=l();c(),S(t.errorMessage())}}function vr(i,e){if(i&1){let t=_();a(0,"button",13),h("click",function(){f(t);let o=l().$implicit,r=l();return b(r.removeUser(o.userId))}),a(1,"mat-icon"),p(2,"close"),s()()}}function Cr(i,e){if(i&1&&(a(0,"div",9)(1,"mat-icon",10),p(2,"person"),s(),a(3,"span",11),p(4),s(),u(5,vr,3,0,"button",12),s()),i&2){let t=e.$implicit,n=l();c(4),S(t.userId),c(),g(n.users.length>1?5:-1)}}var Pe=class i{threadId;users=[];currentUsername;userAdded=new M;userRemoved=new M;closed=new M;isAdding=ie(!1);errorMessage=ie("");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(!1)}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=T({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&&(a(0,"div",0)(1,"div",1)(2,"div",2)(3,"mat-icon"),p(4,"group"),s(),a(5,"span"),p(6,"Share"),s()(),a(7,"button",3),h("click",function(){return n.close()}),a(8,"mat-icon"),p(9,"chevron_right"),s()()(),a(10,"div",4)(11,"span"),p(12,"Participants"),s()(),a(13,"div",5)(14,"app-user-autocomplete",6),h("userSelected",function(r){return n.onUserSelected(r)}),s()(),u(15,br,2,1,"div",7),a(16,"div",8),H(17,Cr,6,2,"div",9,fr),s()()),t&2&&(c(14),C("excludedUserIds",n.excludedUserIds)("disabled",n.isAdding()),c(),g(n.errorMessage()?15:-1),c(2),V(n.users))},dependencies:[L,R,ae,re,ln,vt],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)}"]})};var di="mat-badge-content",_r=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275cmp=T({type:i,selectors:[["ng-component"]],decls:0,vars:0,template:function(n,o){},styles:[`.mat-badge{position:relative}.mat-badge.mat-badge{overflow:visible}.mat-badge-content{position:absolute;text-align:center;display:inline-block;transition:transform 200ms ease-in-out;transform:scale(0.6);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;box-sizing:border-box;pointer-events:none;background-color:var(--mat-badge-background-color, var(--mat-sys-error));color:var(--mat-badge-text-color, var(--mat-sys-on-error));font-family:var(--mat-badge-text-font, var(--mat-sys-label-small-font));font-weight:var(--mat-badge-text-weight, var(--mat-sys-label-small-weight));border-radius:var(--mat-badge-container-shape, var(--mat-sys-corner-full))}.mat-badge-above .mat-badge-content{bottom:100%}.mat-badge-below .mat-badge-content{top:100%}.mat-badge-before .mat-badge-content{right:100%}[dir=rtl] .mat-badge-before .mat-badge-content{right:auto;left:100%}.mat-badge-after .mat-badge-content{left:100%}[dir=rtl] .mat-badge-after .mat-badge-content{left:auto;right:100%}@media(forced-colors: active){.mat-badge-content{outline:solid 1px;border-radius:0}}.mat-badge-disabled .mat-badge-content{background-color:var(--mat-badge-disabled-state-background-color, color-mix(in srgb, var(--mat-sys-error) 38%, transparent));color:var(--mat-badge-disabled-state-text-color, var(--mat-sys-on-error))}.mat-badge-hidden .mat-badge-content{display:none}.ng-animate-disabled .mat-badge-content,.mat-badge-content._mat-animation-noopable{transition:none}.mat-badge-content.mat-badge-active{transform:none}.mat-badge-small .mat-badge-content{width:var(--mat-badge-legacy-small-size-container-size, unset);height:var(--mat-badge-legacy-small-size-container-size, unset);min-width:var(--mat-badge-small-size-container-size, 6px);min-height:var(--mat-badge-small-size-container-size, 6px);line-height:var(--mat-badge-small-size-line-height, 6px);padding:var(--mat-badge-small-size-container-padding, 0);font-size:var(--mat-badge-small-size-text-size, 0);margin:var(--mat-badge-small-size-container-offset, -6px 0)}.mat-badge-small.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-small-size-container-overlap-offset, -6px)}.mat-badge-medium .mat-badge-content{width:var(--mat-badge-legacy-container-size, unset);height:var(--mat-badge-legacy-container-size, unset);min-width:var(--mat-badge-container-size, 16px);min-height:var(--mat-badge-container-size, 16px);line-height:var(--mat-badge-line-height, 16px);padding:var(--mat-badge-container-padding, 0 4px);font-size:var(--mat-badge-text-size, var(--mat-sys-label-small-size));margin:var(--mat-badge-container-offset, -12px 0)}.mat-badge-medium.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-container-overlap-offset, -12px)}.mat-badge-large .mat-badge-content{width:var(--mat-badge-legacy-large-size-container-size, unset);height:var(--mat-badge-legacy-large-size-container-size, unset);min-width:var(--mat-badge-large-size-container-size, 16px);min-height:var(--mat-badge-large-size-container-size, 16px);line-height:var(--mat-badge-large-size-line-height, 16px);padding:var(--mat-badge-large-size-container-padding, 0 4px);font-size:var(--mat-badge-large-size-text-size, var(--mat-sys-label-small-size));margin:var(--mat-badge-large-size-container-offset, -12px 0)}.mat-badge-large.mat-badge-overlap .mat-badge-content{margin:var(--mat-badge-large-size-container-overlap-offset, -12px)}
|
|
31
|
+
`],encapsulation:2,changeDetection:0})}return i})(),mi=(()=>{class i{_ngZone=m(Vt);_elementRef=m(ue);_ariaDescriber=m(on);_renderer=m(Nt);_animationsDisabled=an();_idGenerator=m(nn);get color(){return this._color}set color(t){this._setColor(t),this._color=t}_color="primary";overlap=!0;disabled=!1;position="above after";get content(){return this._content}set content(t){this._updateRenderedContent(t)}_content;get description(){return this._description}set description(t){this._updateDescription(t)}_description;size="medium";hidden=!1;_badgeElement;_inlineBadgeDescription;_isInitialized=!1;_interactivityChecker=m(en);_document=m(Ht);constructor(){let t=m(Jt);t.load(_r),t.load(Zt)}isAbove(){return this.position.indexOf("below")===-1}isAfter(){return this.position.indexOf("before")===-1}getBadgeElement(){return this._badgeElement}ngOnInit(){this._clearExistingBadges(),this.content&&!this._badgeElement&&(this._badgeElement=this._createBadgeElement(),this._updateRenderedContent(this.content)),this._isInitialized=!0}ngAfterViewInit(){}ngOnDestroy(){this._renderer.destroyNode&&(this._renderer.destroyNode(this._badgeElement),this._inlineBadgeDescription?.remove()),this._ariaDescriber.removeDescription(this._elementRef.nativeElement,this.description)}_isHostInteractive(){return this._interactivityChecker.isFocusable(this._elementRef.nativeElement,{ignoreVisibility:!0})}_createBadgeElement(){let t=this._renderer.createElement("span"),n="mat-badge-active";return t.setAttribute("id",this._idGenerator.getId("mat-badge-content-")),t.setAttribute("aria-hidden","true"),t.classList.add(di),this._animationsDisabled&&t.classList.add("_mat-animation-noopable"),this._elementRef.nativeElement.appendChild(t),typeof requestAnimationFrame=="function"&&!this._animationsDisabled?this._ngZone.runOutsideAngular(()=>{requestAnimationFrame(()=>{t.classList.add(n)})}):t.classList.add(n),t}_updateRenderedContent(t){let n=`${t??""}`.trim();this._isInitialized&&n&&!this._badgeElement&&(this._badgeElement=this._createBadgeElement()),this._badgeElement&&(this._badgeElement.textContent=n),this._content=n}_updateDescription(t){this._ariaDescriber.removeDescription(this._elementRef.nativeElement,this.description),(!t||this._isHostInteractive())&&this._removeInlineDescription(),this._description=t,this._isHostInteractive()?this._ariaDescriber.describe(this._elementRef.nativeElement,t):this._updateInlineDescription()}_updateInlineDescription(){this._inlineBadgeDescription||(this._inlineBadgeDescription=this._document.createElement("span"),this._inlineBadgeDescription.classList.add("cdk-visually-hidden")),this._inlineBadgeDescription.textContent=this.description,this._badgeElement?.appendChild(this._inlineBadgeDescription)}_removeInlineDescription(){this._inlineBadgeDescription?.remove(),this._inlineBadgeDescription=void 0}_setColor(t){let n=this._elementRef.nativeElement.classList;n.remove(`mat-badge-${this._color}`),t&&n.add(`mat-badge-${t}`)}_clearExistingBadges(){let t=this._elementRef.nativeElement.querySelectorAll(`:scope > .${di}`);for(let n of Array.from(t))n!==this._badgeElement&&n.remove()}static \u0275fac=function(n){return new(n||i)};static \u0275dir=jt({type:i,selectors:[["","matBadge",""]],hostAttrs:[1,"mat-badge"],hostVars:20,hostBindings:function(n,o){n&2&&N("mat-badge-overlap",o.overlap)("mat-badge-above",o.isAbove())("mat-badge-below",!o.isAbove())("mat-badge-before",!o.isAfter())("mat-badge-after",o.isAfter())("mat-badge-small",o.size==="small")("mat-badge-medium",o.size==="medium")("mat-badge-large",o.size==="large")("mat-badge-hidden",o.hidden||!o.content)("mat-badge-disabled",o.disabled)},inputs:{color:[0,"matBadgeColor","color"],overlap:[2,"matBadgeOverlap","overlap",Le],disabled:[2,"matBadgeDisabled","disabled",Le],position:[0,"matBadgePosition","position"],content:[0,"matBadge","content"],description:[0,"matBadgeDescription","description"],size:[0,"matBadgeSize","size"],hidden:[2,"matBadgeHidden","hidden",Le]}})}return i})(),pi=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=$t({type:i});static \u0275inj=Rt({imports:[tn,rn]})}return i})();var Ct=class i{http=m(Y);maxFileSize=5*1024*1024;supportedTypes=["image/png","image/jpeg","image/gif","image/webp"];validateFile(e){if(!this.supportedTypes.includes(e.type))throw new Error(`Unsupported file type: ${e.type}`);if(e.size>this.maxFileSize)throw new Error(`File too large: ${(e.size/1024/1024).toFixed(1)}MB exceeds 5MB limit`)}fileToBase64(e){return P(this,null,function*(){return new Promise((t,n)=>{let o=new FileReader;o.onload=()=>{let r=o.result;if(!r){n(new Error("Failed to read file"));return}let d=r.split(",")[1];if(!d){n(new Error("Invalid file format"));return}t(d)},o.onerror=n,o.readAsDataURL(e)})})}getUploadUrl(e,t){return`/api/projects/${e}/threads/${t}/upload`}uploadImage(e,t,n){console.log("[IMAGE-UPLOAD] uploadImage - file:",e.name,e.type,e.size),console.log("[IMAGE-UPLOAD] uploadImage - project:",t,"thread:",n);try{console.log("[IMAGE-UPLOAD] Validating file..."),this.validateFile(e)}catch(o){return console.log("[IMAGE-UPLOAD] Validation failed:",o),xt({success:!1,error:o instanceof Error?o.message:"Validation failed"})}return new ke(o=>{console.log("[IMAGE-UPLOAD] Converting to base64..."),this.fileToBase64(e).then(r=>{console.log("[IMAGE-UPLOAD] Base64 length:",r.length),console.log("[IMAGE-UPLOAD] Sending upload request..."),this.http.post(this.getUploadUrl(t,n),{content:r,mimeType:e.type,filename:e.name}).pipe(ne(d=>(console.log("[IMAGE-UPLOAD] Upload success result:",d),{success:!0,processedSize:d.processedSize,dimensions:d.dimensions})),De(d=>{console.log("[IMAGE-UPLOAD] Upload failed:",d);let v=d.error?.error||d.message||"Upload failed";return xt({success:!1,error:v})})).subscribe({next:d=>{o.next(d),o.complete()},error:d=>o.error(d)})}).catch(r=>{console.log("[IMAGE-UPLOAD] Base64 conversion failed:",r),o.next({success:!1,error:r instanceof Error?r.message:"Failed to read file"}),o.complete()})})}hasImageFiles(e){if(console.log("[IMAGE-UPLOAD] hasImageFiles - dataTransfer:",e),!e)return console.log("[IMAGE-UPLOAD] hasImageFiles - no dataTransfer"),!1;if(console.log("[IMAGE-UPLOAD] hasImageFiles - types:",Array.from(e.types)),!Array.from(e.types).includes("Files"))return console.log("[IMAGE-UPLOAD] hasImageFiles - no Files type"),!1;let t=Array.from(e.files||[]);console.log("[IMAGE-UPLOAD] hasImageFiles - files:",t.map(o=>({name:o.name,type:o.type})));let n=t.some(o=>this.supportedTypes.includes(o.type));return console.log("[IMAGE-UPLOAD] hasImageFiles - result:",n),n}filterImageFiles(e){return Array.from(e).filter(n=>this.supportedTypes.includes(n.type))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=k({token:i,factory:i.\u0275fac,providedIn:"root"})};var yr=["inputSection"],wr=()=>[];function Tr(i,e){if(i&1){let t=_();a(0,"button",20),h("click",function(){f(t);let o=l();return b(o.toggleFileDrawer())}),a(1,"mat-icon"),p(2,"folder_open"),s()()}if(i&2){let t=l();N("has-files",t.fileCount>0),C("title",Wt("Files Exchange",t.fileCount>0?" ("+t.fileCount+" file"+(t.fileCount>1?"s":"")+")":""))("matBadge",t.fileCount>0?t.fileCount:null)}}function Sr(i,e){if(i&1){let t=_();a(0,"button",21),h("click",function(){f(t);let o=l();return b(o.toggleSharePanel())}),a(1,"mat-icon"),p(2,"group"),s()()}if(i&2){let t=l();N("has-shared-users",((t.threadDetails==null||t.threadDetails.users==null?null:t.threadDetails.users.length)??0)>1)}}function Mr(i,e){if(i&1&&(a(0,"div",6),p(1),s()),i&2){let t=l();c(),Ae(" \u26A0\uFE0F Connection lost. Reconnecting... (",t.connectionStatus.reconnectAttempts,"/",t.connectionStatus.maxAttempts,") ")}}function Er(i,e){if(i&1&&(a(0,"div",22),p(1),s()),i&2){let t=l();N("error",t.uploadStatus.isError),c(),he(" ",t.uploadStatus.message," ")}}function Pr(i,e){if(i&1){let t=_();a(0,"app-chat-textarea",23),h("messageSubmitted",function(o){f(t);let r=l();return b(r.onMessageSubmitted(o))})("voiceRecordingToggled",function(o){f(t);let r=l();return b(r.onVoiceToggled(o))})("heightChanged",function(o){f(t);let r=l();return b(r.onInputHeightChanged(o))})("stopRequested",function(){f(t);let o=l();return b(o.onStopRequested())})("filesPasted",function(o){f(t);let r=l();return b(r.onFilesPasted(o))}),s()}if(i&2){let t=l();C("isDisabled",!t.isConnected)("isSessionInitializing",!1)("showWelcome",!1)("isThinking",t.isThinking)("isStarting",!1)}}function Or(i,e){if(i&1){let t=_();a(0,"app-choice-select",24),h("choiceSelected",function(o){f(t);let r=l();return b(r.onChoiceSelected(o))}),s()}if(i&2){let t=l();C("options",t.currentChoice.options)("labelHtml",t.currentChoice.label)("isVisible",!!t.currentChoice)("allowFreeText",t.currentChoice.allowFreeText)}}function kr(i,e){i&1&&y(0,"app-oauth-request-panel")}function Ir(i,e){if(i&1){let t=_();a(0,"app-file-exchange-drawer",25),h("closeDrawer",function(){f(t);let o=l();return b(o.closeDrawer())}),s()}if(i&2){let t=l();C("projectName",t.projectName)("threadId",t.threadId)}}function Dr(i,e){if(i&1){let t=_();a(0,"app-thread-share",26),h("userAdded",function(o){f(t);let r=l();return b(r.onUserAdded(o))})("userRemoved",function(o){f(t);let r=l();return b(r.onUserRemoved(o))})("closed",function(){f(t);let o=l();return b(o.closeDrawer())}),s()}if(i&2){let t=l();C("threadId",t.threadId)("users",t.threadDetails.users||Yt(3,wr))("currentUsername",t.currentUsername)}}function Ar(i,e){i&1&&(a(0,"div",19)(1,"div",27)(2,"div",28),p(3,"\u{1F4CE}"),s(),a(4,"div",29),p(5,"Drop files here to upload"),s(),a(6,"div",30),p(7,"Images will be added to conversation, other files to exchange space"),s()()())}var ui=class i{projectName;threadId;chatFocused=new M;drawerStateChange=new M;destroy$=new B;connectionDestroy$=new B;inputSection;messages=[];streamingText="";isThinking=!1;currentChoice=null;connectionStatus=null;isConnected=!1;showConnectionStatus=!1;hasEverConnected=!1;inputSectionHeight=80;uploadStatus={message:"",isError:!1};isDragOver=!1;drawerMode="none";get isDrawerOpen(){return this.drawerMode!=="none"}threadDetails=null;threadShareRef;get fileCount(){return this.fileExchangeState.fileCount()}currentUsername="";authEnabled=!1;pendingFirstMessage=null;subscriptions=[];codayService=m(ce);oauthService=m(Ke);pendingOAuthRequest=Ge(this.oauthService.pendingRequest$,{initialValue:null});preferencesService=m(se);titleService=m(et);elementRef=m(ue);threadState=m(X);threadApiService=m($e);userService=m(cn);router=m(Kt);imageUploadService=m(Ct);fileExchangeState=m(_e);firstMessageState=m(tt);audioApiService=m(fe);ngOnInit(){if(console.log("[THREAD] Initializing with project:",this.projectName,"thread:",this.threadId),!this.projectName||!this.threadId){console.error("[THREAD] Missing required inputs: projectName or threadId");return}this.setupPrintHandlers(),this.userService.authEnabled$.pipe(F(this.destroy$)).subscribe(e=>{this.authEnabled=e}),this.userService.username$.pipe(F(this.destroy$)).subscribe(e=>{this.currentUsername=e??"",this.messages.length>0&&(this.messages=[...this.messages])}),this.initializeThreadConnection()}ngOnChanges(e){console.log("[THREAD] ngOnChanges called",e),e.threadId&&(console.log("[THREAD] threadId changed:",{firstChange:e.threadId.firstChange,previousValue:e.threadId.previousValue,currentValue:e.threadId.currentValue}),e.threadId.firstChange||(console.log("[THREAD] Reconnecting to new thread"),this.initializeThreadConnection()))}initializeThreadConnection(){console.log("[THREAD] Initializing connection for thread:",this.threadId),this.fileExchangeState.initializeForThread(this.projectName,this.threadId),this.connectionDestroy$.next(),this.codayService.messages$.pipe(F(this.connectionDestroy$)).subscribe(n=>{console.log("[THREAD] Messages updated:",n.length),this.messages=n}),this.codayService.streamingText$.pipe(F(this.connectionDestroy$)).subscribe(n=>{this.streamingText=n}),this.codayService.isThinking$.pipe(F(this.connectionDestroy$)).subscribe(n=>{this.isThinking=n}),this.codayService.currentChoice$.pipe(F(this.connectionDestroy$)).subscribe(n=>{this.currentChoice=n}),this.codayService.connectionStatus$.pipe(F(this.connectionDestroy$)).subscribe(n=>{this.connectionStatus=n,this.isConnected=n.connected,n.connected&&!this.hasEverConnected&&(this.hasEverConnected=!0,this.showConnectionStatus=!0),!n.connected&&!this.hasEverConnected?setTimeout(()=>{!this.isConnected&&!this.hasEverConnected&&(this.showConnectionStatus=!0)},2e3):!n.connected&&this.hasEverConnected?this.showConnectionStatus=!0:n.connected&&(this.showConnectionStatus=!0)}),this.codayService.threadUpdateEvent$.pipe(F(this.connectionDestroy$)).subscribe(n=>{n&&(console.log("[THREAD] Thread update event received:",n),this.threadState.refreshThreadList())}),this.threadState.selectedThread$.pipe(F(this.connectionDestroy$)).subscribe(n=>{this.threadDetails=n}),this.codayService.resetMessages(),this.codayService.setTabTitleService(this.titleService),console.log("[THREAD] Connecting to thread event stream"),this.codayService.connectToThread(this.projectName,this.threadId),this.threadApiService.getThreadMessages(this.threadId).pipe(F(this.connectionDestroy$)).subscribe({next:({messages:n})=>{console.log("[THREAD] Loaded",n.length,"messages from REST history"),this.codayService.loadHistoryFromRest(n)},error:n=>console.warn("[THREAD] Could not load REST history:",n)});let e=this.firstMessageState.consumePendingVoiceMessage();if(e){console.log("[THREAD] Pending voice message found, waiting for InviteEvent before sending"),this.codayService.setThinkingForPendingMessage(),this.subscriptions.push(this.codayService.currentInviteEvent$.pipe(W(n=>!!n),Ft(1)).subscribe(()=>{console.log("[THREAD] InviteEvent received, sending pending voice message"),this.audioApiService.sendVoiceMessage(e.base64,e.mimeType,e.language).subscribe({next:n=>{console.log("[THREAD] First voice message sent, transcription:",n.transcription?.substring(0,50))},error:n=>{console.error("[THREAD] Failed to send first voice message:",n)}})}));return}let t=this.firstMessageState.consumePendingFirstMessage();t?(console.log("[THREAD] First message pending:",t.substring(0,50)+"..."),this.pendingFirstMessage=t,this.codayService.setThinkingForPendingMessage(),this.subscribeToFirstInvite()):console.log("[THREAD] No first message found in state service")}ngAfterViewChecked(){if(this.inputSection?.nativeElement){let e=this.inputSection.nativeElement.offsetHeight;e!==this.inputSectionHeight&&e>0&&(this.inputSectionHeight=e)}}ngOnDestroy(){console.log("[THREAD] Destroying component"),this.connectionDestroy$.next(),this.connectionDestroy$.complete(),this.destroy$.next(),this.destroy$.complete(),this.fileExchangeState.clear(),this.subscriptions.forEach(e=>e.unsubscribe()),this.subscriptions=[],window.removeEventListener("beforeprint",this.handleBeforePrint),window.removeEventListener("afterprint",this.handleAfterPrint)}onMessageSubmitted(e){console.log("[THREAD] Sending message:",e),this.codayService.sendMessage(e)}onVoiceToggled(e){console.log("[VOICE] Recording:",e)}onChoiceSelected(e){console.log("[THREAD] Choice selected:",e),this.codayService.sendChoice(e)}onCopyMessage(e){console.log("[COPY] Message copied:",e.id)}onStopRequested(){this.threadState.stop()}onInputHeightChanged(e){console.log("[THREAD] Input height changed:",e),this.inputSectionHeight=e}onFilesPasted(e){console.log("[THREAD] File(s) pasted:",e.length);let t=this.imageUploadService.filterImageFiles(e),n=e.filter(o=>!o.type.startsWith("image/"));t.length&&this.uploadFilesSequentially(t,0),n.length&&this.uploadFilesToExchangeSpace(n),!t.length&&!n.length&&this.showUploadError("No supported files found")}emitDrawerState(){this.drawerStateChange.emit(this.isDrawerOpen)}toggleFileDrawer(){this.drawerMode=this.drawerMode==="files"?"none":"files",this.emitDrawerState()}toggleSharePanel(){this.drawerMode=this.drawerMode==="share"?"none":"share",this.emitDrawerState()}closeDrawer(){this.drawerMode="none",this.emitDrawerState()}onUserAdded(e){if(console.log("[THREAD] Adding user to thread:",e),!this.threadDetails)return;let t=this.threadDetails.users||[];if(t.some(o=>o.userId===e)){this.threadShareRef?.setError("User already has access to this thread");return}this.threadShareRef?.setAdding(!0);let n=[...t,{userId:e}];this.threadState.updateThreadUsers(this.threadId,n).pipe(F(this.destroy$)).subscribe({next:()=>{console.log("[THREAD] User added successfully"),this.threadShareRef?.setAdding(!1),this.threadState.refreshSelectedThread()},error:o=>{console.error("[THREAD] Error adding user:",o),this.threadShareRef?.setError(o?.error?.error||"Failed to add user")}})}onUserRemoved(e){if(console.log("[THREAD] Removing user from thread:",e),!this.threadDetails)return;let t=e===this.currentUsername,n=(this.threadDetails.users||[]).filter(o=>o.userId!==e);this.threadState.updateThreadUsers(this.threadId,n).pipe(F(this.destroy$)).subscribe({next:()=>{console.log("[THREAD] User removed successfully"),t?(this.threadState.clearSelection(),this.threadState.refreshThreadList(),this.router.navigate(["project",this.projectName])):this.threadState.refreshSelectedThread()},error:o=>{console.error("[THREAD] Error removing user:",o)}})}onDragEnter(e){e.preventDefault(),e.dataTransfer?.types.includes("Files")&&(console.log("[THREAD] Image files detected - showing drag overlay"),this.isDragOver=!0)}onDragOver(e){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")}onDragLeave(e){this.elementRef.nativeElement.contains(e.relatedTarget)||(console.log("[THREAD] Leaving component area - hiding drag overlay"),this.isDragOver=!1)}onDrop(e){e.preventDefault(),this.isDragOver=!1,console.log("[THREAD] Files dropped:",e.dataTransfer?.files?.length||0);let t=e.dataTransfer?.files;if(!t||t.length===0){console.log("[THREAD] No files in drop event");return}let n=this.imageUploadService.filterImageFiles(t),o=Array.from(t).filter(r=>!r.type.startsWith("image/"));console.log("[THREAD] Image files:",n.length,"Other files:",o.length),n.length>0&&this.uploadFilesSequentially(n,0),o.length>0&&this.uploadFilesToExchangeSpace(o),n.length===0&&o.length===0&&this.showUploadError("No supported files found")}uploadFilesSequentially(e,t){if(t>=e.length)return;let n=e[t];if(!n){console.error("[THREAD] File at index",t,"is undefined");return}console.log("[THREAD] Uploading file:",n.name),this.uploadStatus={message:`Uploading ${n.name}...`,isError:!1},this.imageUploadService.uploadImage(n,this.projectName,this.threadId).subscribe({next:o=>{o.success?(console.log("[THREAD] Upload successful:",n.name),this.uploadStatus={message:`\u2713 ${n.name} uploaded (${(o.processedSize/1024).toFixed(1)} KB)`,isError:!1},setTimeout(()=>{this.uploadStatus.isError||(this.uploadStatus={message:"",isError:!1})},3e3),this.uploadFilesSequentially(e,t+1)):(console.error("[THREAD] Upload failed:",n.name,o.error),this.showUploadError(`Failed to upload ${n.name}: ${o.error}`))},error:o=>{console.error("[THREAD] Upload error:",n.name,o),this.showUploadError(`Failed to upload ${n.name}: ${o.message||"Unknown error"}`)}})}showUploadError(e){this.uploadStatus={message:e,isError:!0},setTimeout(()=>{this.uploadStatus={message:"",isError:!1}},5e3)}uploadFilesToExchangeSpace(e){return P(this,null,function*(){for(let t of e){console.log("[THREAD] Uploading to exchange space:",t.name),this.uploadStatus={message:`Uploading ${t.name}...`,isError:!1};let n=yield this.fileExchangeState.uploadFile(t);if(n.success)console.log("[THREAD] Upload to exchange space successful:",t.name),this.uploadStatus={message:`\u2713 ${t.name} uploaded to exchange space`,isError:!1},setTimeout(()=>{this.uploadStatus.isError||(this.uploadStatus={message:"",isError:!1})},3e3);else{console.error("[THREAD] Upload to exchange space failed:",t.name,n.error),this.showUploadError(`Failed to upload ${t.name}: ${n.error}`);break}}})}subscribeToFirstInvite(){console.log("[THREAD] Subscribing to wait for InviteEvent"),this.subscriptions.push(this.codayService.currentInviteEvent$.subscribe(e=>{if(e&&this.pendingFirstMessage){console.log("[THREAD] Received InviteEvent, sending pending message");let t=this.pendingFirstMessage;this.pendingFirstMessage=null,this.codayService.sendMessage(t)}}))}setupPrintHandlers(){window.addEventListener("beforeprint",this.handleBeforePrint),window.addEventListener("afterprint",this.handleAfterPrint)}handleBeforePrint=()=>{console.log("[PRINT] Before print event triggered");let e=this.preferencesService.getPrintTechnicalMessages();console.log("[PRINT] Print technical messages:",e),e?document.body.classList.add("print-include-technical"):document.body.classList.remove("print-include-technical")};handleAfterPrint=()=>{console.log("[PRINT] After print event triggered"),document.body.classList.remove("print-include-technical")};static \u0275fac=function(t){return new(t||i)};static \u0275cmp=T({type:i,selectors:[["app-thread"]],viewQuery:function(t,n){if(t&1&&ge(yr,5)(Pe,5),t&2){let o;J(o=Z())&&(n.inputSection=o.first),J(o=Z())&&(n.threadShareRef=o.first)}},inputs:{projectName:"projectName",threadId:"threadId"},outputs:{chatFocused:"chatFocused",drawerStateChange:"drawerStateChange"},features:[q],decls:22,vars:16,consts:[["inputSection",""],[1,"drag-drop-wrapper",3,"dragenter","dragover","dragleave","drop"],[1,"file-drawer-container",3,"hasBackdrop"],[1,"thread-container"],["matFab","","type","button",1,"file-drawer-toggle-btn",3,"has-files","matBadge","title"],["matFab","","title","Share thread","type","button",1,"share-toggle-btn",3,"has-shared-users"],[1,"connection-status"],[1,"chat-wrapper",3,"mousedown","touchstart"],[1,"chat-center"],[3,"copyRequested","stopRequested","messages","streamingText","isThinking","currentUsername"],[1,"upload-status",3,"error"],[1,"input-section"],[1,"input-center"],[1,"input-glass"],[3,"isDisabled","isSessionInitializing","showWelcome","isThinking","isStarting"],[1,"choice-overlay",3,"options","labelHtml","isVisible","allowFreeText"],["mode","side","position","end",3,"closed","opened"],[3,"projectName","threadId"],[3,"threadId","users","currentUsername"],[1,"drag-overlay"],["matFab","","type","button",1,"file-drawer-toggle-btn",3,"click","matBadge","title"],["matFab","","title","Share thread","type","button",1,"share-toggle-btn",3,"click"],[1,"upload-status"],[3,"messageSubmitted","voiceRecordingToggled","heightChanged","stopRequested","filesPasted","isDisabled","isSessionInitializing","showWelcome","isThinking","isStarting"],[1,"choice-overlay",3,"choiceSelected","options","labelHtml","isVisible","allowFreeText"],[3,"closeDrawer","projectName","threadId"],[3,"userAdded","userRemoved","closed","threadId","users","currentUsername"],[1,"drag-overlay-content"],[1,"drag-icon"],[1,"drag-text"],[1,"drag-hint"]],template:function(t,n){t&1&&(a(0,"div",1),h("dragenter",function(r){return n.onDragEnter(r)})("dragover",function(r){return n.onDragOver(r)})("dragleave",function(r){return n.onDragLeave(r)})("drop",function(r){return n.onDrop(r)}),a(1,"mat-drawer-container",2)(2,"mat-drawer-content")(3,"div",3),u(4,Tr,3,5,"button",4),u(5,Sr,3,2,"button",5),u(6,Mr,2,2,"div",6),a(7,"div",7),h("mousedown",function(){return n.chatFocused.emit()})("touchstart",function(){return n.chatFocused.emit()}),a(8,"div",8)(9,"app-chat-history",9),h("copyRequested",function(r){return n.onCopyMessage(r)})("stopRequested",function(){return n.onStopRequested()}),s(),u(10,Er,2,3,"div",10),s()(),a(11,"div",11,0)(13,"div",12)(14,"div",13),u(15,Pr,1,5,"app-chat-textarea",14),u(16,Or,1,4,"app-choice-select",15),u(17,kr,1,0,"app-oauth-request-panel"),s()()()()(),a(18,"mat-drawer",16),h("closed",function(){return n.closeDrawer()}),u(19,Ir,1,2,"app-file-exchange-drawer",17),u(20,Dr,1,4,"app-thread-share",18),s()(),u(21,Ar,8,0,"div",19),s()),t&2&&(c(),C("hasBackdrop",!1),c(3),g(n.drawerMode!=="files"?4:-1),c(),g(n.authEnabled&&n.drawerMode!=="share"?5:-1),c(),g(n.showConnectionStatus&&n.connectionStatus&&!n.connectionStatus.connected?6:-1),c(3),C("messages",n.messages)("streamingText",n.streamingText)("isThinking",n.isThinking)("currentUsername",n.currentUsername),c(),g(n.uploadStatus.message?10:-1),c(5),g(!n.currentChoice&&!n.pendingOAuthRequest()?15:-1),c(),g(n.currentChoice?16:-1),c(),g(n.pendingOAuthRequest()?17:-1),c(),C("opened",n.isDrawerOpen),c(),g(n.drawerMode==="files"?19:-1),c(),g(n.drawerMode==="share"&&n.threadDetails?20:-1),c(),g(n.isDragOver?21:-1))},dependencies:[rt,Ze,at,st,ft,Pe,Pn,Mn,En,Sn,L,R,ae,Ne,pi,mi],styles:[".drag-drop-wrapper[_ngcontent-%COMP%]{height:100vh;height:100dvh;width:100%;position:relative}.thread-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;width:100%;position:relative;background:transparent}.file-drawer-toggle-btn[_ngcontent-%COMP%]{position:fixed!important;top:1rem!important;right:1rem!important;z-index:100!important}.file-drawer-toggle-btn.has-files[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_pulse-subtle 3s infinite}@media(max-width:768px){.file-drawer-toggle-btn[_ngcontent-%COMP%]{width:40px!important;height:40px!important;top:.75rem!important;right:.75rem!important}.file-drawer-toggle-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}}.share-toggle-btn[_ngcontent-%COMP%]{position:fixed!important;top:5rem!important;right:1rem!important;z-index:100!important}.share-toggle-btn.has-shared-users[_ngcontent-%COMP%]{color:var(--color-primary)!important}@media(max-width:768px){.share-toggle-btn[_ngcontent-%COMP%]{width:40px!important;height:40px!important;top:calc(1.25rem + 40px)!important;right:.75rem!important}.share-toggle-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}}@keyframes _ngcontent-%COMP%_pulse-subtle{0%,to{box-shadow:0 2px 8px #00000026}50%{box-shadow:0 4px 16px rgba(var(--color-primary-rgb, 25, 118, 210),.3)}}.file-drawer-container[_ngcontent-%COMP%]{height:100dvh;width:100%;background:var(--color-bg)}.file-drawer-container[_ngcontent-%COMP%] .mat-drawer-content{display:flex;flex-direction:column;height:100%;overflow:hidden;background:transparent}.file-drawer-container[_ngcontent-%COMP%] .mat-drawer{width:35%;min-width:280px;max-width:480px;box-shadow:-2px 0 8px #0000001a}@media(max-width:768px){.file-drawer-container[_ngcontent-%COMP%] .mat-drawer{width:100%;max-width:100%;padding-bottom:env(safe-area-inset-bottom,0px)}}.file-drawer-container[_ngcontent-%COMP%] .mat-drawer-backdrop{display:none}.connection-status[_ngcontent-%COMP%]{position:fixed;top:0;left:0;right:0;z-index:1000;background:var(--color-warning);color:var(--color-text);padding:.5rem 1rem;text-align:center;font-size:.9rem;box-shadow:0 2px 4px #0000001a}.chat-wrapper[_ngcontent-%COMP%]{flex:1;overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;width:100%;padding:1rem 0}.chat-center[_ngcontent-%COMP%]{max-width:800px;width:100%;margin:0 auto;padding:0 2rem;display:flex;flex-direction:column;gap:1rem}@media(max-width:768px){.chat-center[_ngcontent-%COMP%]{padding:0 1rem}}.input-section[_ngcontent-%COMP%]{width:100%;padding:1rem 0;padding-bottom:calc(1rem + env(safe-area-inset-bottom,0px));background:transparent;position:relative}.input-center[_ngcontent-%COMP%]{max-width:800px;width:100%;margin:0 auto;padding:0 2rem}@media(max-width:768px){.input-center[_ngcontent-%COMP%]{padding:0 1rem}}.choice-overlay[_ngcontent-%COMP%]{display:block;width:100%}.upload-status[_ngcontent-%COMP%]{padding:.75rem 1rem;border-radius:8px;background:var(--color-success-light);color:var(--color-text);font-size:.9rem;text-align:center}.upload-status.error[_ngcontent-%COMP%]{background:var(--color-error-light)}@media print{.file-drawer-toggle-btn[_ngcontent-%COMP%], .share-toggle-btn[_ngcontent-%COMP%], .connection-status[_ngcontent-%COMP%]{display:none}.thread-container[_ngcontent-%COMP%]{background:#fff}.input-section[_ngcontent-%COMP%]{display:none}}"]})};export{Ze as a,et as b,tt as c,ui as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as a}from"./chunk-AKNP533G.js";import"./chunk-OD5UXNU5.js";import"./chunk-ZTTTDVEL.js";import"./chunk-UARV2YUR.js";import"./chunk-DWPYG4F6.js";import"./chunk-XLNZCT7N.js";import"./chunk-WJFUKUVD.js";import"./chunk-2GHS5VUE.js";import"./chunk-DYANOPHQ.js";import"./chunk-F4YDJMK7.js";import"./chunk-4YLSQZJK.js";import"./chunk-QPN22TF2.js";export{a as UserListComponent};
|