@whoz-oss/coday-client 0.126.0 → 0.128.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/browser/{chunk-PWDBCAQS.js → chunk-3TO5PQRD.js} +1 -1
- package/browser/{chunk-WGDWYJII.js → chunk-3YSNMKXU.js} +1 -1
- package/browser/{chunk-KC2EKCAS.js → chunk-5B6P72NR.js} +1 -1
- package/browser/chunk-7A54VTP2.js +3 -0
- package/browser/{chunk-CH66E3U2.js → chunk-7CFO7WWZ.js} +1 -1
- package/browser/chunk-7T6Q4MDL.js +2 -0
- package/browser/{chunk-V6CWNYSW.js → chunk-7XSGZTN3.js} +1 -1
- package/browser/{chunk-OSNI7IJI.js → chunk-ADWJAQMQ.js} +1 -1
- package/browser/chunk-D6WU5O4X.js +1 -0
- package/browser/{chunk-POHHXEMY.js → chunk-DVO44NIX.js} +6 -6
- package/browser/{chunk-G2OAJDIX.js → chunk-EU3J4G2Y.js} +1 -1
- package/browser/chunk-FFMGEAGW.js +1 -0
- package/browser/{chunk-KUVTFZWT.js → chunk-FPNKDL3E.js} +1 -1
- package/browser/chunk-GEUVTKHG.js +2 -0
- package/browser/{chunk-H76RJSSA.js → chunk-GG2XORTA.js} +1 -1
- package/browser/chunk-GVX63TKQ.js +1 -0
- package/browser/{chunk-NCBEPUYQ.js → chunk-H6Q42HHV.js} +1 -1
- package/browser/chunk-IJ2YZMNS.js +1 -0
- package/browser/chunk-JWEUUCFC.js +1 -0
- package/browser/{chunk-O2IJMHBE.js → chunk-LLDKKRUC.js} +1 -1
- package/browser/{chunk-UKTBOEDG.js → chunk-MVATXMLV.js} +1 -1
- package/browser/{chunk-K3XBOMJY.js → chunk-NZDKKDRG.js} +1 -1
- package/browser/{chunk-TVFEAMIC.js → chunk-ONXSTLRN.js} +1 -1
- package/browser/{chunk-R47KFHEX.js → chunk-QU37OGFO.js} +1 -1
- package/browser/{chunk-H5SXHH6A.js → chunk-RHFQ7GO2.js} +1 -1
- package/browser/chunk-RQLQ22PM.js +4 -0
- package/browser/chunk-SDNXWYG5.js +5 -0
- package/browser/{chunk-ECBXPEAC.js → chunk-TSDYLM5L.js} +2 -2
- package/browser/{chunk-OR62LCJX.js → chunk-VGRGY2U3.js} +1 -1
- package/browser/chunk-WQUBEVZN.js +5 -0
- package/browser/chunk-YCJZTFYJ.js +270 -0
- package/browser/{chunk-H7YMYOPC.js → chunk-YXFL2FTT.js} +1 -1
- package/browser/{chunk-CYLHTE22.js → chunk-Z26H5ES2.js} +1 -1
- package/browser/index.html +1 -1
- package/browser/main-YSLZYJ4P.js +1 -0
- package/package.json +1 -1
- package/browser/chunk-53STPEYQ.js +0 -3
- package/browser/chunk-7MXZXY4I.js +0 -1
- package/browser/chunk-EKBLXJOJ.js +0 -1
- package/browser/chunk-EZOSEC5V.js +0 -7
- package/browser/chunk-HCG45H7O.js +0 -2
- package/browser/chunk-JG37UR26.js +0 -270
- package/browser/chunk-KVR4NGLT.js +0 -1
- package/browser/chunk-LPN5AG4A.js +0 -1
- package/browser/chunk-LR7LOR4R.js +0 -4
- package/browser/chunk-PWF6LYR2.js +0 -1
- package/browser/chunk-TLVTUJPE.js +0 -2
- package/browser/chunk-UKAN3Y3I.js +0 -2
- package/browser/main-DARYETMO.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{a as ye,b as vr,c as ki}from"./chunk-EZOSEC5V.js";import{c as Si,d as bn,f as Ht,g as xn,k as On}from"./chunk-UKTBOEDG.js";import{a as Re,b as er,c as Ce,d as En}from"./chunk-EKBLXJOJ.js";import{a as pr}from"./chunk-UORJVNGU.js";import{a as vn,b as Cn}from"./chunk-HCG45H7O.js";import{a as gt,e as nr,f as ir,g as or,k as rr,l as ar,n as sr,p as kn,r as lr,t as cr}from"./chunk-JG37UR26.js";import{a as xr}from"./chunk-I5OT3IGD.js";import"./chunk-MWWLTJ77.js";import{b as jo,d as fn}from"./chunk-QWMDAFBN.js";import"./chunk-WNNKQ2DH.js";import{a as _r}from"./chunk-AQ3SEH2N.js";import"./chunk-UKAN3Y3I.js";import{b as fr,d as br}from"./chunk-LR7LOR4R.js";import{a as mr,b as ur,c as hr,g as gr}from"./chunk-ZAM3WGZM.js";import"./chunk-53STPEYQ.js";import{b as tr}from"./chunk-AK6F2DC7.js";import{a as dr,b as Mn}from"./chunk-AJOXSD6I.js";import"./chunk-DRBOHCTP.js";import"./chunk-IXD43YQI.js";import{a as J,b as he}from"./chunk-WPC6XC7P.js";import{C as Sn,c as yn,g as wn,m as Tn}from"./chunk-XJUBZLY2.js";import{b as De}from"./chunk-XIQ3L6H6.js";import{E as Zo,K as Ko,O as Ye,Q as Jo,R as _n,S as Ge,i as Wo,j as qo,p as Yo,s as Go,t as Xo,z as Qo}from"./chunk-B2QA6UZX.js";import{$b as zo,B as ge,Bb as E,D as ln,Db as w,Ec as gn,Fb as m,G as Mo,Ga as fe,Gc as Bo,Ha as Po,Hc as Ti,Ja as Ao,Jb as qe,Jc as ve,Ka as p,Kb as xe,Lb as _e,N as yi,Pa as Do,Rb as be,Rc as Pe,T as B,Tb as f,Ub as D,Uc as Ae,Vb as ht,Wa as P,Wb as cn,Xa as Ro,Xb as dn,Ya as Fo,Yb as pn,Z as j,Za as No,Zb as mn,_ as Eo,_b as Ho,a as q,ac as $o,b as Oe,bc as Vo,ca as u,d as N,dc as Lt,ec as Uo,fc as wi,g as an,ga as C,h as oe,ha as y,i as sn,jb as We,kc as un,la as Oo,lb as x,m as Ci,mb as _,n as So,oa as H,pa as Io,pb as me,qb as ue,rb as k,sb as c,t as Be,ta as je,tb as d,tc as hn,u as ko,ub as A,va as Ie,vb as Ft,wb as Nt,xb as Lo,ya as ut}from"./chunk-3JGMGRXW.js";var In=class i{sanitizer=u(Ae);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=No({name:"highlight",type:i,pure:!0})};var ft=class i{http=u(Pe);projectState=u(De);threadState=u(Re);transcribeAudio(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow();return this.http.post(`/api/projects/${o}/transcribe`,q({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`,q({audio:e,mimeType:t},n?{language:n}:{}))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var Xa=["messageInput"],Qa=["fileInput"],Za=(i,e)=>e.name;function Ka(i,e){i&1&&(c(0,"div",3),A(1,"span",8),f(2," Recording... Click mic to stop "),d())}function Ja(i,e){i&1&&(c(0,"div",3),A(1,"span",9),f(2," Transcribing... "),d())}function es(i,e){if(i&1&&(c(0,"span",14),f(1),d()),i&2){let t=m().$implicit,n=m(2);p(),D(" "+(n.getParameterFormat(t)||""))}}function ts(i,e){if(i&1){let t=E();c(0,"div",11),w("click",function(){let o=C(t).$index,r=m(2);return y(r.selectAutocompleteItemByClick(o))})("keydown.enter",function(){let o=C(t).$index,r=m(2);return y(r.selectAutocompleteItemByClick(o))})("keydown.space",function(){let o=C(t).$index,r=m(2);return y(r.selectAutocompleteItemByClick(o))})("mouseenter",function(){let o=C(t).$index,r=m(2);return y(r.selectedAutocompleteIndex=o)}),c(1,"div",12),A(2,"span",13),Lt(3,"highlight"),x(4,es,2,1,"span",14),d(),A(5,"div",15),Lt(6,"highlight"),d()}if(i&2){let t=e.$implicit,n=e.$index,o=m(2);be("selected",n===o.selectedAutocompleteIndex),We("aria-selected",n===o.selectedAutocompleteIndex),p(2),k("innerHTML",wi(3,6,o.autocompleteTrigger+t.name,o.getAutocompleteQuery()),fe),p(2),_(o.hasParameterFormat(t)?4:-1),p(),k("innerHTML",wi(6,9,t.description,o.getAutocompleteQuery()),fe)}}function ns(i,e){if(i&1&&(c(0,"div",4),me(1,ts,7,12,"div",10,Za),d()),i&2){let t=m();p(),ue(t.autocompleteItems)}}function is(i,e){if(i&1){let t=E();c(0,"ds-icon-button",18),w("action",function(){C(t);let o=m(2);return y(o.onStopClick())}),d()}}function os(i,e){if(i&1){let t=E();c(0,"ds-icon-button",19),w("action",function(){C(t);let o=m(2);return y(o.sendMessage())}),d()}if(i&2){let t=m(2);be("hidden",t.isDisabled||!t.message.trim())("active",!!t.message.trim()&&!t.isDisabled),k("title",t.getSendButtonTooltip())("disabled",t.isDisabled||!t.message.trim())}}function rs(i,e){if(i&1){let t=E();c(0,"ds-icon-button",21),w("action",function(){C(t);let o=m(3);return y(o.triggerFileUpload())}),d(),c(1,"input",22,1),w("change",function(o){C(t);let r=m(3);return y(r.onFileInputChange(o))}),d()}if(i&2){let t=m(3);k("disabled",t.isDisabled)}}function as(i,e){if(i&1){let t=E();x(0,rs,3,1),c(1,"ds-icon-button",20),w("action",function(){C(t);let o=m(2);return y(o.toggleRecording())}),d()}if(i&2){let t=m(2);_(!t.showWelcome&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?0:-1),p(),be("hidden",t.message.trim()&&!t.isRecording&&!t.isTranscribing),k("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 ss(i,e){if(i&1&&(c(0,"div",7),x(1,is,1,0,"ds-icon-button",16),x(2,os,1,6,"ds-icon-button",17),x(3,as,2,6),d()),i&2){let t=m();p(),_(t.isThinking?1:-1),p(),_((!t.isThinking||t.message.trim())&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?2:-1),p(),_(t.isThinking?-1:3)}}var bt=class i{isDisabled=!1;showWelcome=!1;isThinking=!1;isStarting=!1;isSessionInitializing=!1;isStopping=!1;filesPasted=new H;messageSubmitted=new H;voiceMessageReady=new H;voiceRecordingToggled=new H;heightChanged=new H;stopRequested=new H;textareaFocused=new H;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=u(Ce);codayService=u(ye);agentApiService=u(pr);promptApiService=u(_r);projectStateService=u(De);audioApiService=u(ft);threadStateService=u(Re);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,a)=>{let l=a.getAsFile();return l?[...r,l]: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 N(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 a=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:a});return}this.audioApiService.sendVoiceMessage(o,t,a).subscribe({next:l=>{this.isTranscribing=!1,console.log("[WHISPER] Voice message sent, transcription:",l.transcription?.substring(0,50))},error:l=>{console.error("[WHISPER] Voice message error:",l),this.isTranscribing=!1,this.fallbackToTranscription(o,t,a)}})}else this.audioApiService.transcribeAudio(o,t,a).subscribe({next:l=>{this.isTranscribing=!1,l.text&&this.appendToTextarea(l.text+" ")},error:l=>{console.error("[WHISPER] Transcription error:",l),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 N(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(`
|
|
1
|
+
import{a as ye,b as ki}from"./chunk-SDNXWYG5.js";import{c as Si,d as bn,f as Ht,g as xn,k as On}from"./chunk-MVATXMLV.js";import{a as Re,b as En}from"./chunk-GVX63TKQ.js";import{a as pr}from"./chunk-UORJVNGU.js";import{a as vn,b as Cn,e as mr}from"./chunk-WQUBEVZN.js";import{a as gt,b as er,f as ir,g as or,h as rr,l as ar,m as sr,o as lr,q as Mn,s as cr,u as dr,v as Ce}from"./chunk-YCJZTFYJ.js";import{a as _r}from"./chunk-I5OT3IGD.js";import"./chunk-MWWLTJ77.js";import{b as jo,d as fn}from"./chunk-QWMDAFBN.js";import"./chunk-WNNKQ2DH.js";import{a as vr}from"./chunk-AQ3SEH2N.js";import"./chunk-7T6Q4MDL.js";import{b as br,d as xr}from"./chunk-7A54VTP2.js";import{a as ur,b as hr,c as gr,g as fr}from"./chunk-ZAM3WGZM.js";import"./chunk-RQLQ22PM.js";import{b as tr}from"./chunk-AK6F2DC7.js";import{a as nr,b as kn}from"./chunk-AJOXSD6I.js";import"./chunk-DRBOHCTP.js";import"./chunk-IXD43YQI.js";import{a as J,b as he}from"./chunk-WPC6XC7P.js";import{C as Sn,c as yn,g as wn,m as Tn}from"./chunk-XJUBZLY2.js";import{b as De}from"./chunk-XIQ3L6H6.js";import{E as Zo,K as Ko,O as Ye,Q as Jo,R as _n,S as Ge,i as Wo,j as qo,p as Yo,s as Go,t as Xo,z as Qo}from"./chunk-B2QA6UZX.js";import{$b as zo,B as ge,Bb as E,D as ln,Db as w,Ec as gn,Fb as m,G as Mo,Ga as fe,Gc as Bo,Ha as Po,Hc as Ti,Ja as Ao,Jb as qe,Jc as ve,Ka as p,Kb as xe,Lb as _e,N as yi,Pa as Do,Rb as be,Rc as Pe,T as B,Tb as f,Ub as D,Uc as Ae,Vb as ht,Wa as P,Wb as cn,Xa as Ro,Xb as dn,Ya as Fo,Yb as pn,Z as j,Za as No,Zb as mn,_ as Eo,_b as Ho,a as q,ac as $o,b as Oe,bc as Vo,ca as u,d as N,dc as Lt,ec as Uo,fc as wi,g as an,ga as C,h as oe,ha as y,i as sn,jb as We,kc as un,la as Oo,lb as x,m as Ci,mb as _,n as So,oa as H,pa as Io,pb as me,qb as ue,rb as k,sb as c,t as Be,ta as je,tb as d,tc as hn,u as ko,ub as A,va as Ie,vb as Ft,wb as Nt,xb as Lo,ya as ut}from"./chunk-3JGMGRXW.js";var In=class i{sanitizer=u(Ae);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=No({name:"highlight",type:i,pure:!0})};var ft=class i{http=u(Pe);projectState=u(De);threadState=u(Re);transcribeAudio(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow();return this.http.post(`/api/projects/${o}/transcribe`,q({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`,q({audio:e,mimeType:t},n?{language:n}:{}))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var Xa=["messageInput"],Qa=["fileInput"],Za=(i,e)=>e.name;function Ka(i,e){i&1&&(c(0,"div",3),A(1,"span",8),f(2," Recording... Click mic to stop "),d())}function Ja(i,e){i&1&&(c(0,"div",3),A(1,"span",9),f(2," Transcribing... "),d())}function es(i,e){if(i&1&&(c(0,"span",14),f(1),d()),i&2){let t=m().$implicit,n=m(2);p(),D(" "+(n.getParameterFormat(t)||""))}}function ts(i,e){if(i&1){let t=E();c(0,"div",11),w("click",function(){let o=C(t).$index,r=m(2);return y(r.selectAutocompleteItemByClick(o))})("keydown.enter",function(){let o=C(t).$index,r=m(2);return y(r.selectAutocompleteItemByClick(o))})("keydown.space",function(){let o=C(t).$index,r=m(2);return y(r.selectAutocompleteItemByClick(o))})("mouseenter",function(){let o=C(t).$index,r=m(2);return y(r.selectedAutocompleteIndex=o)}),c(1,"div",12),A(2,"span",13),Lt(3,"highlight"),x(4,es,2,1,"span",14),d(),A(5,"div",15),Lt(6,"highlight"),d()}if(i&2){let t=e.$implicit,n=e.$index,o=m(2);be("selected",n===o.selectedAutocompleteIndex),We("aria-selected",n===o.selectedAutocompleteIndex),p(2),k("innerHTML",wi(3,6,o.autocompleteTrigger+t.name,o.getAutocompleteQuery()),fe),p(2),_(o.hasParameterFormat(t)?4:-1),p(),k("innerHTML",wi(6,9,t.description,o.getAutocompleteQuery()),fe)}}function ns(i,e){if(i&1&&(c(0,"div",4),me(1,ts,7,12,"div",10,Za),d()),i&2){let t=m();p(),ue(t.autocompleteItems)}}function is(i,e){if(i&1){let t=E();c(0,"ds-icon-button",18),w("action",function(){C(t);let o=m(2);return y(o.onStopClick())}),d()}}function os(i,e){if(i&1){let t=E();c(0,"ds-icon-button",19),w("action",function(){C(t);let o=m(2);return y(o.sendMessage())}),d()}if(i&2){let t=m(2);be("hidden",t.isDisabled||!t.message.trim())("active",!!t.message.trim()&&!t.isDisabled),k("title",t.getSendButtonTooltip())("disabled",t.isDisabled||!t.message.trim())}}function rs(i,e){if(i&1){let t=E();c(0,"ds-icon-button",21),w("action",function(){C(t);let o=m(3);return y(o.triggerFileUpload())}),d(),c(1,"input",22,1),w("change",function(o){C(t);let r=m(3);return y(r.onFileInputChange(o))}),d()}if(i&2){let t=m(3);k("disabled",t.isDisabled)}}function as(i,e){if(i&1){let t=E();x(0,rs,3,1),c(1,"ds-icon-button",20),w("action",function(){C(t);let o=m(2);return y(o.toggleRecording())}),d()}if(i&2){let t=m(2);_(!t.showWelcome&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?0:-1),p(),be("hidden",t.message.trim()&&!t.isRecording&&!t.isTranscribing),k("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 ss(i,e){if(i&1&&(c(0,"div",7),x(1,is,1,0,"ds-icon-button",16),x(2,os,1,6,"ds-icon-button",17),x(3,as,2,6),d()),i&2){let t=m();p(),_(t.isThinking?1:-1),p(),_((!t.isThinking||t.message.trim())&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?2:-1),p(),_(t.isThinking?-1:3)}}var bt=class i{isDisabled=!1;showWelcome=!1;isThinking=!1;isStarting=!1;isSessionInitializing=!1;isStopping=!1;filesPasted=new H;messageSubmitted=new H;voiceMessageReady=new H;voiceRecordingToggled=new H;heightChanged=new H;stopRequested=new H;textareaFocused=new H;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=u(Ce);codayService=u(ye);agentApiService=u(pr);promptApiService=u(vr);projectStateService=u(De);audioApiService=u(ft);threadStateService=u(Re);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,a)=>{let l=a.getAsFile();return l?[...r,l]: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 N(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 a=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:a});return}this.audioApiService.sendVoiceMessage(o,t,a).subscribe({next:l=>{this.isTranscribing=!1,console.log("[WHISPER] Voice message sent, transcription:",l.transcription?.substring(0,50))},error:l=>{console.error("[WHISPER] Voice message error:",l),this.isTranscribing=!1,this.fallbackToTranscription(o,t,a)}})}else this.audioApiService.transcribeAudio(o,t,a).subscribe({next:l=>{this.isTranscribing=!1,l.text&&this.appendToTextarea(l.text+" ")},error:l=>{console.error("[WHISPER] Transcription error:",l),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 N(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
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=P({type:i,selectors:[["app-chat-textarea"]],viewQuery:function(t,n){if(t&1&&qe(Xa,7)(Qa,5),t&2){let o;xe(o=_e())&&(n.messageInput=o.first),xe(o=_e())&&(n.fileInput=o.first)}},hostBindings:function(t,n){t&1&&w("paste",function(r){return n.onPaste(r)})("click",function(r){return n.onDocumentClick(r)},Ao)},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:[Ie],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=E();c(0,"div",2),x(1,Ka,3,0,"div",3),x(2,Ja,3,0,"div",3),x(3,ns,3,0,"div",4),c(4,"div",5)(5,"textarea",6,0),mn("ngModelChange",function(a){return C(o),pn(n.message,a)||(n.message=a),y(a)}),w("keydown",function(a){return n.onKeyDown(a)})("input",function(){return n.onInput()})("focus",function(){return C(o),n.isFocused=!0,y(n.textareaFocused.emit())})("blur",function(){return n.isFocused=!1}),d(),x(7,ss,4,3,"div",7),d()()}t&2&&(p(),_(!n.isVoiceMessageMode&&n.isRecording?1:-1),p(),_(!n.isVoiceMessageMode&&n.isTranscribing?2:-1),p(),_(n.autocompleteVisible?3:-1),p(),be("focused",n.isFocused)("welcome-mode",n.showWelcome)("is-thinking",n.isThinking)("is-listening",n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),p(),dn("ngModel",n.message),k("placeholder",n.getPlaceholder())("disabled",n.isDisabled||n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),p(2),_(n.isSessionInitializing?-1:7))},dependencies:[Sn,yn,wn,Tn,fr,In],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 ls=(i,e)=>e.label;function cs(i,e){if(i&1){let t=E();c(0,"button",2),w("click",function(o){let r=C(t).$implicit,a=m();return y(a.executeAction(r,o))}),c(1,"mat-icon"),f(2),d()()}if(i&2){let t=e.$implicit;We("title",t.tooltip||t.label),p(),We("aria-label",t.label),p(),D(t.icon)}}var Pn=class i{actions=[];executeAction(e,t){t.stopPropagation(),e.action()}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=P({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&&(c(0,"div",0),me(1,cs,3,3,"button",1,ls),d()),t&2&&(p(),ue(n.actions))},dependencies:[ve,Ye,J],styles:[".context-menu-wrapper[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center}.context-menu-wrapper[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{transform:scale(.75)}"]})};function Ii(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var it=Ii();function Mr(i){it=i}var Ut={exec:()=>null};function R(i,e=""){let t=typeof i=="string"?i:i.source,n={replace:(o,r)=>{let a=typeof r=="string"?r:r.source;return a=a.replace(ae.caret,"$1"),t=t.replace(o,a),n},getRegex:()=>new RegExp(t,e)};return n}var ae={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:i=>new RegExp(`^( {0,3}${i})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}#`),htmlBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}<(?:[a-z].*>|!--)`,"i")},ds=/^(?:[ \t]*(?:\n|$))+/,ps=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ms=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Bt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,us=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Pi=/(?:[*+-]|\d{1,9}[.)])/,Er=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Or=R(Er).replace(/bull/g,Pi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),hs=R(Er).replace(/bull/g,Pi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ai=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,gs=/^[^\n]+/,Di=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,fs=R(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Di).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),bs=R(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Pi).getRegex(),Fn="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Ri=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,xs=R("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Ri).replace("tag",Fn).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ir=R(Ai).replace("hr",Bt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fn).getRegex(),_s=R(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ir).getRegex(),Fi={blockquote:_s,code:ps,def:fs,fences:ms,heading:us,hr:Bt,html:xs,lheading:Or,list:bs,newline:ds,paragraph:Ir,table:Ut,text:gs},Cr=R("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Bt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fn).getRegex(),vs=Oe(q({},Fi),{lheading:hs,table:Cr,paragraph:R(Ai).replace("hr",Bt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Cr).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fn).getRegex()}),Cs=Oe(q({},Fi),{html:R(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ri).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ut,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:R(Ai).replace("hr",Bt).replace("heading",` *#{1,6} *[^
|
|
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=P({type:i,selectors:[["app-chat-textarea"]],viewQuery:function(t,n){if(t&1&&qe(Xa,7)(Qa,5),t&2){let o;xe(o=_e())&&(n.messageInput=o.first),xe(o=_e())&&(n.fileInput=o.first)}},hostBindings:function(t,n){t&1&&w("paste",function(r){return n.onPaste(r)})("click",function(r){return n.onDocumentClick(r)},Ao)},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:[Ie],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=E();c(0,"div",2),x(1,Ka,3,0,"div",3),x(2,Ja,3,0,"div",3),x(3,ns,3,0,"div",4),c(4,"div",5)(5,"textarea",6,0),mn("ngModelChange",function(a){return C(o),pn(n.message,a)||(n.message=a),y(a)}),w("keydown",function(a){return n.onKeyDown(a)})("input",function(){return n.onInput()})("focus",function(){return C(o),n.isFocused=!0,y(n.textareaFocused.emit())})("blur",function(){return n.isFocused=!1}),d(),x(7,ss,4,3,"div",7),d()()}t&2&&(p(),_(!n.isVoiceMessageMode&&n.isRecording?1:-1),p(),_(!n.isVoiceMessageMode&&n.isTranscribing?2:-1),p(),_(n.autocompleteVisible?3:-1),p(),be("focused",n.isFocused)("welcome-mode",n.showWelcome)("is-thinking",n.isThinking)("is-listening",n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),p(),dn("ngModel",n.message),k("placeholder",n.getPlaceholder())("disabled",n.isDisabled||n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),p(2),_(n.isSessionInitializing?-1:7))},dependencies:[Sn,yn,wn,Tn,br,In],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 ls=(i,e)=>e.label;function cs(i,e){if(i&1){let t=E();c(0,"button",2),w("click",function(o){let r=C(t).$implicit,a=m();return y(a.executeAction(r,o))}),c(1,"mat-icon"),f(2),d()()}if(i&2){let t=e.$implicit;We("title",t.tooltip||t.label),p(),We("aria-label",t.label),p(),D(t.icon)}}var Pn=class i{actions=[];executeAction(e,t){t.stopPropagation(),e.action()}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=P({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&&(c(0,"div",0),me(1,cs,3,3,"button",1,ls),d()),t&2&&(p(),ue(n.actions))},dependencies:[ve,Ye,J],styles:[".context-menu-wrapper[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center}.context-menu-wrapper[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{transform:scale(.75)}"]})};function Ii(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var it=Ii();function Mr(i){it=i}var Ut={exec:()=>null};function R(i,e=""){let t=typeof i=="string"?i:i.source,n={replace:(o,r)=>{let a=typeof r=="string"?r:r.source;return a=a.replace(ae.caret,"$1"),t=t.replace(o,a),n},getRegex:()=>new RegExp(t,e)};return n}var ae={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:i=>new RegExp(`^( {0,3}${i})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}#`),htmlBeginRegex:i=>new RegExp(`^ {0,${Math.min(3,i-1)}}<(?:[a-z].*>|!--)`,"i")},ds=/^(?:[ \t]*(?:\n|$))+/,ps=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ms=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Bt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,us=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Pi=/(?:[*+-]|\d{1,9}[.)])/,Er=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Or=R(Er).replace(/bull/g,Pi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),hs=R(Er).replace(/bull/g,Pi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ai=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,gs=/^[^\n]+/,Di=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,fs=R(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Di).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),bs=R(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Pi).getRegex(),Fn="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Ri=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,xs=R("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Ri).replace("tag",Fn).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ir=R(Ai).replace("hr",Bt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fn).getRegex(),_s=R(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ir).getRegex(),Fi={blockquote:_s,code:ps,def:fs,fences:ms,heading:us,hr:Bt,html:xs,lheading:Or,list:bs,newline:ds,paragraph:Ir,table:Ut,text:gs},Cr=R("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Bt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fn).getRegex(),vs=Oe(q({},Fi),{lheading:hs,table:Cr,paragraph:R(Ai).replace("hr",Bt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Cr).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fn).getRegex()}),Cs=Oe(q({},Fi),{html:R(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ri).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ut,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:R(Ai).replace("hr",Bt).replace("heading",` *#{1,6} *[^
|
|
4
4
|
]`).replace("lheading",Or).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()}),ys=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ws=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Pr=/^( {2,}|\\)\n(?!\s*$)/,Ts=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Nn=/[\p{P}\p{S}]/u,Ni=/[\s\p{P}\p{S}]/u,Ar=/[^\s\p{P}\p{S}]/u,Ss=R(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ni).getRegex(),Dr=/(?!~)[\p{P}\p{S}]/u,ks=/(?!~)[\s\p{P}\p{S}]/u,Ms=/(?:[^\s\p{P}\p{S}]|~)/u,Es=/\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,Rr=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Os=R(Rr,"u").replace(/punct/g,Nn).getRegex(),Is=R(Rr,"u").replace(/punct/g,Dr).getRegex(),Fr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Ps=R(Fr,"gu").replace(/notPunctSpace/g,Ar).replace(/punctSpace/g,Ni).replace(/punct/g,Nn).getRegex(),As=R(Fr,"gu").replace(/notPunctSpace/g,Ms).replace(/punctSpace/g,ks).replace(/punct/g,Dr).getRegex(),Ds=R("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ar).replace(/punctSpace/g,Ni).replace(/punct/g,Nn).getRegex(),Rs=R(/\\(punct)/,"gu").replace(/punct/g,Nn).getRegex(),Fs=R(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ns=R(Ri).replace("(?:-->|$)","-->").getRegex(),Ls=R("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ns).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Dn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Hs=R(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Dn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Nr=R(/^!?\[(label)\]\[(ref)\]/).replace("label",Dn).replace("ref",Di).getRegex(),Lr=R(/^!?\[(ref)\](?:\[\])?/).replace("ref",Di).getRegex(),zs=R("reflink|nolink(?!\\()","g").replace("reflink",Nr).replace("nolink",Lr).getRegex(),yr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Li={_backpedal:Ut,anyPunctuation:Rs,autolink:Fs,blockSkip:Es,br:Pr,code:ws,del:Ut,emStrongLDelim:Os,emStrongRDelimAst:Ps,emStrongRDelimUnd:Ds,escape:ys,link:Hs,nolink:Lr,punctuation:Ss,reflink:Nr,reflinkSearch:zs,tag:Ls,text:Ts,url:Ut},$s=Oe(q({},Li),{link:R(/^!?\[(label)\]\((.*?)\)/).replace("label",Dn).getRegex(),reflink:R(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Dn).getRegex()}),Mi=Oe(q({},Li),{emStrongRDelimAst:As,emStrongLDelim:Is,url:R(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",yr).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:R(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",yr).getRegex()}),Vs=Oe(q({},Mi),{br:R(Pr).replace("{2,}","*").getRegex(),text:R(Mi.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()}),An={normal:Fi,gfm:vs,pedantic:Cs},zt={normal:Li,gfm:Mi,breaks:Vs,pedantic:$s},Us={"&":"&","<":"<",">":">",'"':""","'":"'"},wr=i=>Us[i];function Fe(i,e){if(e){if(ae.escapeTest.test(i))return i.replace(ae.escapeReplace,wr)}else if(ae.escapeTestNoEncode.test(i))return i.replace(ae.escapeReplaceNoEncode,wr);return i}function Tr(i){try{i=encodeURI(i).replace(ae.percentDecode,"%")}catch(e){return null}return i}function Sr(i,e){let t=i.replace(ae.findPipe,(r,a,l)=>{let h=!1,b=a;for(;--b>=0&&l[b]==="\\";)h=!h;return h?"|":" |"}),n=t.split(ae.splitPipe),o=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;o<n.length;o++)n[o]=n[o].trim().replace(ae.slashPipe,"|");return n}function $t(i,e,t){let n=i.length;if(n===0)return"";let o=0;for(;o<n;){let r=i.charAt(n-o-1);if(r===e&&!t)o++;else if(r!==e&&t)o++;else break}return i.slice(0,n-o)}function Bs(i,e){if(i.indexOf(e[1])===-1)return-1;let t=0;for(let n=0;n<i.length;n++)if(i[n]==="\\")n++;else if(i[n]===e[0])t++;else if(i[n]===e[1]&&(t--,t<0))return n;return t>0?-2:-1}function kr(i,e,t,n,o){let r=e.href,a=e.title||null,l=i[1].replace(o.other.outputLinkReplace,"$1");n.state.inLink=!0;let h={type:i[0].charAt(0)==="!"?"image":"link",raw:t,href:r,title:a,text:l,tokens:n.inlineTokens(l)};return n.state.inLink=!1,h}function js(i,e,t){let n=i.match(t.other.indentCodeCompensation);if(n===null)return e;let o=n[1];return e.split(`
|
|
5
5
|
`).map(r=>{let a=r.match(t.other.beginningSpace);if(a===null)return r;let[l]=a;return l.length>=o.length?r.slice(o.length):r}).join(`
|
|
6
6
|
`)}var Rn=class{options;rules;lexer;constructor(i){this.options=i||it}space(i){let e=this.rules.block.newline.exec(i);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(i){let e=this.rules.block.code.exec(i);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:$t(t,`
|
|
@@ -60,7 +60,7 @@ ${i}</tr>
|
|
|
60
60
|
`}strong({tokens:i}){return`<strong>${this.parser.parseInline(i)}</strong>`}em({tokens:i}){return`<em>${this.parser.parseInline(i)}</em>`}codespan({text:i}){return`<code>${Fe(i,!0)}</code>`}br(i){return"<br>"}del({tokens:i}){return`<del>${this.parser.parseInline(i)}</del>`}link({href:i,title:e,tokens:t}){let n=this.parser.parseInline(t),o=Tr(i);if(o===null)return n;i=o;let r='<a href="'+i+'"';return e&&(r+=' title="'+Fe(e)+'"'),r+=">"+n+"</a>",r}image({href:i,title:e,text:t,tokens:n}){n&&(t=this.parser.parseInline(n,this.parser.textRenderer));let o=Tr(i);if(o===null)return Fe(t);i=o;let r=`<img src="${i}" alt="${t}"`;return e&&(r+=` title="${Fe(e)}"`),r+=">",r}text(i){return"tokens"in i&&i.tokens?this.parser.parseInline(i.tokens):"escaped"in i&&i.escaped?i.text:Fe(i.text)}},Hi=class{strong({text:i}){return i}em({text:i}){return i}codespan({text:i}){return i}del({text:i}){return i}html({text:i}){return i}text({text:i}){return i}link({text:i}){return""+i}image({text:i}){return""+i}br(){return""}},Se=class Oi{options;renderer;textRenderer;constructor(e){this.options=e||it,this.options.renderer=this.options.renderer||new xt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Hi}static parse(e,t){return new Oi(t).parse(e)}static parseInline(e,t){return new Oi(t).parseInline(e)}parse(e,t=!0){let n="";for(let o=0;o<e.length;o++){let r=e[o];if(this.options.extensions?.renderers?.[r.type]){let l=r,h=this.options.extensions.renderers[l.type].call({parser:this},l);if(h!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=h||"";continue}}let a=r;switch(a.type){case"space":{n+=this.renderer.space(a);continue}case"hr":{n+=this.renderer.hr(a);continue}case"heading":{n+=this.renderer.heading(a);continue}case"code":{n+=this.renderer.code(a);continue}case"table":{n+=this.renderer.table(a);continue}case"blockquote":{n+=this.renderer.blockquote(a);continue}case"list":{n+=this.renderer.list(a);continue}case"html":{n+=this.renderer.html(a);continue}case"def":{n+=this.renderer.def(a);continue}case"paragraph":{n+=this.renderer.paragraph(a);continue}case"text":{let l=a,h=this.renderer.text(l);for(;o+1<e.length&&e[o+1].type==="text";)l=e[++o],h+=`
|
|
61
61
|
`+this.renderer.text(l);t?n+=this.renderer.paragraph({type:"paragraph",raw:h,text:h,tokens:[{type:"text",raw:h,text:h,escaped:!0}]}):n+=h;continue}default:{let l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(e,t=this.renderer){let n="";for(let o=0;o<e.length;o++){let r=e[o];if(this.options.extensions?.renderers?.[r.type]){let l=this.options.extensions.renderers[r.type].call({parser:this},r);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=l||"";continue}}let a=r;switch(a.type){case"escape":{n+=t.text(a);break}case"html":{n+=t.html(a);break}case"link":{n+=t.link(a);break}case"image":{n+=t.image(a);break}case"strong":{n+=t.strong(a);break}case"em":{n+=t.em(a);break}case"codespan":{n+=t.codespan(a);break}case"br":{n+=t.br(a);break}case"del":{n+=t.del(a);break}case"text":{n+=t.text(a);break}default:{let l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}},Vt=class{options;block;constructor(i){this.options=i||it}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(i){return i}postprocess(i){return i}processAllTokens(i){return i}emStrongMask(i){return i}provideLexer(){return this.block?Te.lex:Te.lexInline}provideParser(){return this.block?Se.parse:Se.parseInline}},Ws=class{defaults=Ii();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Se;Renderer=xt;TextRenderer=Hi;Lexer=Te;Tokenizer=Rn;Hooks=Vt;constructor(...i){this.use(...i)}walkTokens(i,e){let t=[];for(let n of i)switch(t=t.concat(e.call(this,n)),n.type){case"table":{let o=n;for(let r of o.header)t=t.concat(this.walkTokens(r.tokens,e));for(let r of o.rows)for(let a of r)t=t.concat(this.walkTokens(a.tokens,e));break}case"list":{let o=n;t=t.concat(this.walkTokens(o.items,e));break}default:{let o=n;this.defaults.extensions?.childTokens?.[o.type]?this.defaults.extensions.childTokens[o.type].forEach(r=>{let a=o[r].flat(1/0);t=t.concat(this.walkTokens(a,e))}):o.tokens&&(t=t.concat(this.walkTokens(o.tokens,e)))}}return t}use(...i){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return i.forEach(t=>{let n=q({},t);if(n.async=this.defaults.async||n.async||!1,t.extensions&&(t.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){let r=e.renderers[o.name];r?e.renderers[o.name]=function(...a){let l=o.renderer.apply(this,a);return l===!1&&(l=r.apply(this,a)),l}:e.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let r=e[o.level];r?r.unshift(o.tokenizer):e[o.level]=[o.tokenizer],o.start&&(o.level==="block"?e.startBlock?e.startBlock.push(o.start):e.startBlock=[o.start]:o.level==="inline"&&(e.startInline?e.startInline.push(o.start):e.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(e.childTokens[o.name]=o.childTokens)}),n.extensions=e),t.renderer){let o=this.defaults.renderer||new xt(this.defaults);for(let r in t.renderer){if(!(r in o))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;let a=r,l=t.renderer[a],h=o[a];o[a]=(...b)=>{let S=l.apply(o,b);return S===!1&&(S=h.apply(o,b)),S||""}}n.renderer=o}if(t.tokenizer){let o=this.defaults.tokenizer||new Rn(this.defaults);for(let r in t.tokenizer){if(!(r in o))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let a=r,l=t.tokenizer[a],h=o[a];o[a]=(...b)=>{let S=l.apply(o,b);return S===!1&&(S=h.apply(o,b)),S}}n.tokenizer=o}if(t.hooks){let o=this.defaults.hooks||new Vt;for(let r in t.hooks){if(!(r in o))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;let a=r,l=t.hooks[a],h=o[a];Vt.passThroughHooks.has(r)?o[a]=b=>{if(this.defaults.async&&Vt.passThroughHooksRespectAsync.has(r))return N(this,null,function*(){let M=yield l.call(o,b);return h.call(o,M)});let S=l.call(o,b);return h.call(o,S)}:o[a]=(...b)=>{if(this.defaults.async)return N(this,null,function*(){let M=yield l.apply(o,b);return M===!1&&(M=yield h.apply(o,b)),M});let S=l.apply(o,b);return S===!1&&(S=h.apply(o,b)),S}}n.hooks=o}if(t.walkTokens){let o=this.defaults.walkTokens,r=t.walkTokens;n.walkTokens=function(a){let l=[];return l.push(r.call(this,a)),o&&(l=l.concat(o.call(this,a))),l}}this.defaults=q(q({},this.defaults),n)}),this}setOptions(i){return this.defaults=q(q({},this.defaults),i),this}lexer(i,e){return Te.lex(i,e??this.defaults)}parser(i,e){return Se.parse(i,e??this.defaults)}parseMarkdown(i){return(e,t)=>{let n=q({},t),o=q(q({},this.defaults),n),r=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&n.async===!1)return r(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return r(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return r(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(o.hooks&&(o.hooks.options=o,o.hooks.block=i),o.async)return N(this,null,function*(){let a=o.hooks?yield o.hooks.preprocess(e):e,l=yield(o.hooks?yield o.hooks.provideLexer():i?Te.lex:Te.lexInline)(a,o),h=o.hooks?yield o.hooks.processAllTokens(l):l;o.walkTokens&&(yield Promise.all(this.walkTokens(h,o.walkTokens)));let b=yield(o.hooks?yield o.hooks.provideParser():i?Se.parse:Se.parseInline)(h,o);return o.hooks?yield o.hooks.postprocess(b):b}).catch(r);try{o.hooks&&(e=o.hooks.preprocess(e));let a=(o.hooks?o.hooks.provideLexer():i?Te.lex:Te.lexInline)(e,o);o.hooks&&(a=o.hooks.processAllTokens(a)),o.walkTokens&&this.walkTokens(a,o.walkTokens);let l=(o.hooks?o.hooks.provideParser():i?Se.parse:Se.parseInline)(a,o);return o.hooks&&(l=o.hooks.postprocess(l)),l}catch(a){return r(a)}}}onError(i,e){return t=>{if(t.message+=`
|
|
62
62
|
Please report this to https://github.com/markedjs/marked.`,i){let n="<p>An error occurred:</p><pre>"+Fe(t.message+"",!0)+"</pre>";return e?Promise.resolve(n):n}if(e)return Promise.reject(t);throw t}}},nt=new Ws;function L(i,e){return nt.parse(i,e)}L.options=L.setOptions=function(i){return nt.setOptions(i),L.defaults=nt.defaults,Mr(L.defaults),L};L.getDefaults=Ii;L.defaults=it;L.use=function(...i){return nt.use(...i),L.defaults=nt.defaults,Mr(L.defaults),L};L.walkTokens=function(i,e){return nt.walkTokens(i,e)};L.parseInline=nt.parseInline;L.Parser=Se;L.parser=Se.parse;L.Renderer=xt;L.TextRenderer=Hi;L.Lexer=Te;L.lexer=Te.lex;L.Tokenizer=Rn;L.Hooks=Vt;L.parse=L;var wp=L.options,Tp=L.setOptions,Sp=L.use,kp=L.walkTokens,Mp=L.parseInline;var Ep=Se.parse,Op=Te.lex;var{entries:qr,setPrototypeOf:Hr,isFrozen:qs,getPrototypeOf:Ys,getOwnPropertyDescriptor:Gs}=Object,{freeze:le,seal:we,create:Wi}=Object,{apply:qi,construct:Yi}=typeof Reflect<"u"&&Reflect;le||(le=function(e){return e});we||(we=function(e){return e});qi||(qi=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];return e.apply(t,o)});Yi||(Yi=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return new e(...n)});var Ln=ce(Array.prototype.forEach),Xs=ce(Array.prototype.lastIndexOf),zr=ce(Array.prototype.pop),jt=ce(Array.prototype.push),Qs=ce(Array.prototype.splice),zn=ce(String.prototype.toLowerCase),zi=ce(String.prototype.toString),$i=ce(String.prototype.match),Wt=ce(String.prototype.replace),Zs=ce(String.prototype.indexOf),Ks=ce(String.prototype.trim),ke=ce(Object.prototype.hasOwnProperty),se=ce(RegExp.prototype.test),qt=Js(TypeError);function ce(i){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return qi(i,e,n)}}function Js(i){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Yi(i,t)}}function O(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:zn;Hr&&Hr(i,null);let n=e.length;for(;n--;){let o=e[n];if(typeof o=="string"){let r=t(o);r!==o&&(qs(e)||(e[n]=r),o=r)}i[o]=!0}return i}function el(i){for(let e=0;e<i.length;e++)ke(i,e)||(i[e]=null);return i}function Ne(i){let e=Wi(null);for(let[t,n]of qr(i))ke(i,t)&&(Array.isArray(n)?e[t]=el(n):n&&typeof n=="object"&&n.constructor===Object?e[t]=Ne(n):e[t]=n);return e}function Yt(i,e){for(;i!==null;){let n=Gs(i,e);if(n){if(n.get)return ce(n.get);if(typeof n.value=="function")return ce(n.value)}i=Ys(i)}function t(){return null}return t}var $r=le(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Vi=le(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ui=le(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),tl=le(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Bi=le(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),nl=le(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Vr=le(["#text"]),Ur=le(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),ji=le(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Br=le(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Hn=le(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),il=we(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ol=we(/<%[\w\W]*|[\w\W]*%>/gm),rl=we(/\$\{[\w\W]*/gm),al=we(/^data-[\-\w.\u00B7-\uFFFF]+$/),sl=we(/^aria-[\-\w]+$/),Yr=we(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ll=we(/^(?:\w+script|data):/i),cl=we(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Gr=we(/^html$/i),dl=we(/^[a-z][.\w]*(-[.\w]+)+$/i),jr=Object.freeze({__proto__:null,ARIA_ATTR:sl,ATTR_WHITESPACE:cl,CUSTOM_ELEMENT:dl,DATA_ATTR:al,DOCTYPE_NAME:Gr,ERB_EXPR:ol,IS_ALLOWED_URI:Yr,IS_SCRIPT_OR_DATA:ll,MUSTACHE_EXPR:il,TMPLIT_EXPR:rl}),Gt={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},pl=function(){return typeof window>"u"?null:window},ml=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null,o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));let r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML(a){return a},createScriptURL(a){return a}})}catch(a){return console.warn("TrustedTypes policy "+r+" could not be created."),null}},Wr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Xr(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:pl(),e=T=>Xr(T);if(e.version="3.3.1",e.removed=[],!i||!i.document||i.document.nodeType!==Gt.document||!i.Element)return e.isSupported=!1,e;let{document:t}=i,n=t,o=n.currentScript,{DocumentFragment:r,HTMLTemplateElement:a,Node:l,Element:h,NodeFilter:b,NamedNodeMap:S=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:M,DOMParser:I,trustedTypes:Y}=i,$=h.prototype,de=Yt($,"cloneNode"),Qt=Yt($,"remove"),Pt=Yt($,"nextSibling"),Zt=Yt($,"childNodes"),Qe=Yt($,"parentNode");if(typeof a=="function"){let T=t.createElement("template");T.content&&T.content.ownerDocument&&(t=T.content.ownerDocument)}let Z,Ze="",{implementation:Ke,createNodeIterator:Je,createDocumentFragment:Da,getElementsByTagName:Ra}=t,{importNode:Fa}=n,ie=Wr();e.isSupported=typeof qr=="function"&&typeof Qe=="function"&&Ke&&Ke.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:ai,ERB_EXPR:si,TMPLIT_EXPR:li,DATA_ATTR:Na,ARIA_ATTR:La,IS_SCRIPT_OR_DATA:Ha,ATTR_WHITESPACE:eo,CUSTOM_ELEMENT:za}=jr,{IS_ALLOWED_URI:to}=jr,K=null,no=O({},[...$r,...Vi,...Ui,...Bi,...Vr]),ee=null,io=O({},[...Ur,...ji,...Br,...Hn]),W=Object.seal(Wi(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),At=null,ci=null,at=Object.seal(Wi(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),oo=!0,di=!0,ro=!1,ao=!0,st=!1,Kt=!0,et=!1,pi=!1,mi=!1,lt=!1,Jt=!1,en=!1,so=!0,lo=!1,$a="user-content-",ui=!0,Dt=!1,ct={},Me=null,hi=O({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),co=null,po=O({},["audio","video","img","source","image","track"]),gi=null,mo=O({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),tn="http://www.w3.org/1998/Math/MathML",nn="http://www.w3.org/2000/svg",He="http://www.w3.org/1999/xhtml",dt=He,fi=!1,bi=null,Va=O({},[tn,nn,He],zi),on=O({},["mi","mo","mn","ms","mtext"]),rn=O({},["annotation-xml"]),Ua=O({},["title","style","font","a","script"]),Rt=null,Ba=["application/xhtml+xml","text/html"],ja="text/html",Q=null,pt=null,Wa=t.createElement("form"),uo=function(s){return s instanceof RegExp||s instanceof Function},xi=function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(pt&&pt===s)){if((!s||typeof s!="object")&&(s={}),s=Ne(s),Rt=Ba.indexOf(s.PARSER_MEDIA_TYPE)===-1?ja:s.PARSER_MEDIA_TYPE,Q=Rt==="application/xhtml+xml"?zi:zn,K=ke(s,"ALLOWED_TAGS")?O({},s.ALLOWED_TAGS,Q):no,ee=ke(s,"ALLOWED_ATTR")?O({},s.ALLOWED_ATTR,Q):io,bi=ke(s,"ALLOWED_NAMESPACES")?O({},s.ALLOWED_NAMESPACES,zi):Va,gi=ke(s,"ADD_URI_SAFE_ATTR")?O(Ne(mo),s.ADD_URI_SAFE_ATTR,Q):mo,co=ke(s,"ADD_DATA_URI_TAGS")?O(Ne(po),s.ADD_DATA_URI_TAGS,Q):po,Me=ke(s,"FORBID_CONTENTS")?O({},s.FORBID_CONTENTS,Q):hi,At=ke(s,"FORBID_TAGS")?O({},s.FORBID_TAGS,Q):Ne({}),ci=ke(s,"FORBID_ATTR")?O({},s.FORBID_ATTR,Q):Ne({}),ct=ke(s,"USE_PROFILES")?s.USE_PROFILES:!1,oo=s.ALLOW_ARIA_ATTR!==!1,di=s.ALLOW_DATA_ATTR!==!1,ro=s.ALLOW_UNKNOWN_PROTOCOLS||!1,ao=s.ALLOW_SELF_CLOSE_IN_ATTR!==!1,st=s.SAFE_FOR_TEMPLATES||!1,Kt=s.SAFE_FOR_XML!==!1,et=s.WHOLE_DOCUMENT||!1,lt=s.RETURN_DOM||!1,Jt=s.RETURN_DOM_FRAGMENT||!1,en=s.RETURN_TRUSTED_TYPE||!1,mi=s.FORCE_BODY||!1,so=s.SANITIZE_DOM!==!1,lo=s.SANITIZE_NAMED_PROPS||!1,ui=s.KEEP_CONTENT!==!1,Dt=s.IN_PLACE||!1,to=s.ALLOWED_URI_REGEXP||Yr,dt=s.NAMESPACE||He,on=s.MATHML_TEXT_INTEGRATION_POINTS||on,rn=s.HTML_INTEGRATION_POINTS||rn,W=s.CUSTOM_ELEMENT_HANDLING||{},s.CUSTOM_ELEMENT_HANDLING&&uo(s.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(W.tagNameCheck=s.CUSTOM_ELEMENT_HANDLING.tagNameCheck),s.CUSTOM_ELEMENT_HANDLING&&uo(s.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(W.attributeNameCheck=s.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),s.CUSTOM_ELEMENT_HANDLING&&typeof s.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(W.allowCustomizedBuiltInElements=s.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),st&&(di=!1),Jt&&(lt=!0),ct&&(K=O({},Vr),ee=[],ct.html===!0&&(O(K,$r),O(ee,Ur)),ct.svg===!0&&(O(K,Vi),O(ee,ji),O(ee,Hn)),ct.svgFilters===!0&&(O(K,Ui),O(ee,ji),O(ee,Hn)),ct.mathMl===!0&&(O(K,Bi),O(ee,Br),O(ee,Hn))),s.ADD_TAGS&&(typeof s.ADD_TAGS=="function"?at.tagCheck=s.ADD_TAGS:(K===no&&(K=Ne(K)),O(K,s.ADD_TAGS,Q))),s.ADD_ATTR&&(typeof s.ADD_ATTR=="function"?at.attributeCheck=s.ADD_ATTR:(ee===io&&(ee=Ne(ee)),O(ee,s.ADD_ATTR,Q))),s.ADD_URI_SAFE_ATTR&&O(gi,s.ADD_URI_SAFE_ATTR,Q),s.FORBID_CONTENTS&&(Me===hi&&(Me=Ne(Me)),O(Me,s.FORBID_CONTENTS,Q)),s.ADD_FORBID_CONTENTS&&(Me===hi&&(Me=Ne(Me)),O(Me,s.ADD_FORBID_CONTENTS,Q)),ui&&(K["#text"]=!0),et&&O(K,["html","head","body"]),K.table&&(O(K,["tbody"]),delete At.tbody),s.TRUSTED_TYPES_POLICY){if(typeof s.TRUSTED_TYPES_POLICY.createHTML!="function")throw qt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof s.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw qt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');Z=s.TRUSTED_TYPES_POLICY,Ze=Z.createHTML("")}else Z===void 0&&(Z=ml(Y,o)),Z!==null&&typeof Ze=="string"&&(Ze=Z.createHTML(""));le&&le(s),pt=s}},ho=O({},[...Vi,...Ui,...tl]),go=O({},[...Bi,...nl]),qa=function(s){let g=Qe(s);(!g||!g.tagName)&&(g={namespaceURI:dt,tagName:"template"});let v=zn(s.tagName),V=zn(g.tagName);return bi[s.namespaceURI]?s.namespaceURI===nn?g.namespaceURI===He?v==="svg":g.namespaceURI===tn?v==="svg"&&(V==="annotation-xml"||on[V]):!!ho[v]:s.namespaceURI===tn?g.namespaceURI===He?v==="math":g.namespaceURI===nn?v==="math"&&rn[V]:!!go[v]:s.namespaceURI===He?g.namespaceURI===nn&&!rn[V]||g.namespaceURI===tn&&!on[V]?!1:!go[v]&&(Ua[v]||!ho[v]):!!(Rt==="application/xhtml+xml"&&bi[s.namespaceURI]):!1},Ee=function(s){jt(e.removed,{element:s});try{Qe(s).removeChild(s)}catch(g){Qt(s)}},tt=function(s,g){try{jt(e.removed,{attribute:g.getAttributeNode(s),from:g})}catch(v){jt(e.removed,{attribute:null,from:g})}if(g.removeAttribute(s),s==="is")if(lt||Jt)try{Ee(g)}catch(v){}else try{g.setAttribute(s,"")}catch(v){}},fo=function(s){let g=null,v=null;if(mi)s="<remove></remove>"+s;else{let G=$i(s,/^[\r\n\t ]+/);v=G&&G[0]}Rt==="application/xhtml+xml"&&dt===He&&(s='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+s+"</body></html>");let V=Z?Z.createHTML(s):s;if(dt===He)try{g=new I().parseFromString(V,Rt)}catch(G){}if(!g||!g.documentElement){g=Ke.createDocument(dt,"template",null);try{g.documentElement.innerHTML=fi?Ze:V}catch(G){}}let ne=g.body||g.documentElement;return s&&v&&ne.insertBefore(t.createTextNode(v),ne.childNodes[0]||null),dt===He?Ra.call(g,et?"html":"body")[0]:et?g.documentElement:ne},bo=function(s){return Je.call(s.ownerDocument||s,s,b.SHOW_ELEMENT|b.SHOW_COMMENT|b.SHOW_TEXT|b.SHOW_PROCESSING_INSTRUCTION|b.SHOW_CDATA_SECTION,null)},_i=function(s){return s instanceof M&&(typeof s.nodeName!="string"||typeof s.textContent!="string"||typeof s.removeChild!="function"||!(s.attributes instanceof S)||typeof s.removeAttribute!="function"||typeof s.setAttribute!="function"||typeof s.namespaceURI!="string"||typeof s.insertBefore!="function"||typeof s.hasChildNodes!="function")},xo=function(s){return typeof l=="function"&&s instanceof l};function ze(T,s,g){Ln(T,v=>{v.call(e,s,g,pt)})}let _o=function(s){let g=null;if(ze(ie.beforeSanitizeElements,s,null),_i(s))return Ee(s),!0;let v=Q(s.nodeName);if(ze(ie.uponSanitizeElement,s,{tagName:v,allowedTags:K}),Kt&&s.hasChildNodes()&&!xo(s.firstElementChild)&&se(/<[/\w!]/g,s.innerHTML)&&se(/<[/\w!]/g,s.textContent)||s.nodeType===Gt.progressingInstruction||Kt&&s.nodeType===Gt.comment&&se(/<[/\w]/g,s.data))return Ee(s),!0;if(!(at.tagCheck instanceof Function&&at.tagCheck(v))&&(!K[v]||At[v])){if(!At[v]&&Co(v)&&(W.tagNameCheck instanceof RegExp&&se(W.tagNameCheck,v)||W.tagNameCheck instanceof Function&&W.tagNameCheck(v)))return!1;if(ui&&!Me[v]){let V=Qe(s)||s.parentNode,ne=Zt(s)||s.childNodes;if(ne&&V){let G=ne.length;for(let pe=G-1;pe>=0;--pe){let $e=de(ne[pe],!0);$e.__removalCount=(s.__removalCount||0)+1,V.insertBefore($e,Pt(s))}}}return Ee(s),!0}return s instanceof h&&!qa(s)||(v==="noscript"||v==="noembed"||v==="noframes")&&se(/<\/no(script|embed|frames)/i,s.innerHTML)?(Ee(s),!0):(st&&s.nodeType===Gt.text&&(g=s.textContent,Ln([ai,si,li],V=>{g=Wt(g,V," ")}),s.textContent!==g&&(jt(e.removed,{element:s.cloneNode()}),s.textContent=g)),ze(ie.afterSanitizeElements,s,null),!1)},vo=function(s,g,v){if(so&&(g==="id"||g==="name")&&(v in t||v in Wa))return!1;if(!(di&&!ci[g]&&se(Na,g))){if(!(oo&&se(La,g))){if(!(at.attributeCheck instanceof Function&&at.attributeCheck(g,s))){if(!ee[g]||ci[g]){if(!(Co(s)&&(W.tagNameCheck instanceof RegExp&&se(W.tagNameCheck,s)||W.tagNameCheck instanceof Function&&W.tagNameCheck(s))&&(W.attributeNameCheck instanceof RegExp&&se(W.attributeNameCheck,g)||W.attributeNameCheck instanceof Function&&W.attributeNameCheck(g,s))||g==="is"&&W.allowCustomizedBuiltInElements&&(W.tagNameCheck instanceof RegExp&&se(W.tagNameCheck,v)||W.tagNameCheck instanceof Function&&W.tagNameCheck(v))))return!1}else if(!gi[g]){if(!se(to,Wt(v,eo,""))){if(!((g==="src"||g==="xlink:href"||g==="href")&&s!=="script"&&Zs(v,"data:")===0&&co[s])){if(!(ro&&!se(Ha,Wt(v,eo,"")))){if(v)return!1}}}}}}}return!0},Co=function(s){return s!=="annotation-xml"&&$i(s,za)},yo=function(s){ze(ie.beforeSanitizeAttributes,s,null);let{attributes:g}=s;if(!g||_i(s))return;let v={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ee,forceKeepAttr:void 0},V=g.length;for(;V--;){let ne=g[V],{name:G,namespaceURI:pe,value:$e}=ne,mt=Q(G),vi=$e,te=G==="value"?vi:Ks(vi);if(v.attrName=mt,v.attrValue=te,v.keepAttr=!0,v.forceKeepAttr=void 0,ze(ie.uponSanitizeAttribute,s,v),te=v.attrValue,lo&&(mt==="id"||mt==="name")&&(tt(G,s),te=$a+te),Kt&&se(/((--!?|])>)|<\/(style|title|textarea)/i,te)){tt(G,s);continue}if(mt==="attributename"&&$i(te,"href")){tt(G,s);continue}if(v.forceKeepAttr)continue;if(!v.keepAttr){tt(G,s);continue}if(!ao&&se(/\/>/i,te)){tt(G,s);continue}st&&Ln([ai,si,li],To=>{te=Wt(te,To," ")});let wo=Q(s.nodeName);if(!vo(wo,mt,te)){tt(G,s);continue}if(Z&&typeof Y=="object"&&typeof Y.getAttributeType=="function"&&!pe)switch(Y.getAttributeType(wo,mt)){case"TrustedHTML":{te=Z.createHTML(te);break}case"TrustedScriptURL":{te=Z.createScriptURL(te);break}}if(te!==vi)try{pe?s.setAttributeNS(pe,G,te):s.setAttribute(G,te),_i(s)?Ee(s):zr(e.removed)}catch(To){tt(G,s)}}ze(ie.afterSanitizeAttributes,s,null)},Ya=function T(s){let g=null,v=bo(s);for(ze(ie.beforeSanitizeShadowDOM,s,null);g=v.nextNode();)ze(ie.uponSanitizeShadowNode,g,null),_o(g),yo(g),g.content instanceof r&&T(g.content);ze(ie.afterSanitizeShadowDOM,s,null)};return e.sanitize=function(T){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},g=null,v=null,V=null,ne=null;if(fi=!T,fi&&(T="<!-->"),typeof T!="string"&&!xo(T))if(typeof T.toString=="function"){if(T=T.toString(),typeof T!="string")throw qt("dirty is not a string, aborting")}else throw qt("toString is not a function");if(!e.isSupported)return T;if(pi||xi(s),e.removed=[],typeof T=="string"&&(Dt=!1),Dt){if(T.nodeName){let $e=Q(T.nodeName);if(!K[$e]||At[$e])throw qt("root node is forbidden and cannot be sanitized in-place")}}else if(T instanceof l)g=fo("<!---->"),v=g.ownerDocument.importNode(T,!0),v.nodeType===Gt.element&&v.nodeName==="BODY"||v.nodeName==="HTML"?g=v:g.appendChild(v);else{if(!lt&&!st&&!et&&T.indexOf("<")===-1)return Z&&en?Z.createHTML(T):T;if(g=fo(T),!g)return lt?null:en?Ze:""}g&&mi&&Ee(g.firstChild);let G=bo(Dt?T:g);for(;V=G.nextNode();)_o(V),yo(V),V.content instanceof r&&Ya(V.content);if(Dt)return T;if(lt){if(Jt)for(ne=Da.call(g.ownerDocument);g.firstChild;)ne.appendChild(g.firstChild);else ne=g;return(ee.shadowroot||ee.shadowrootmode)&&(ne=Fa.call(n,ne,!0)),ne}let pe=et?g.outerHTML:g.innerHTML;return et&&K["!doctype"]&&g.ownerDocument&&g.ownerDocument.doctype&&g.ownerDocument.doctype.name&&se(Gr,g.ownerDocument.doctype.name)&&(pe="<!DOCTYPE "+g.ownerDocument.doctype.name+`>
|
|
63
|
-
`+pe),st&&Ln([ai,si,li],$e=>{pe=Wt(pe,$e," ")}),Z&&en?Z.createHTML(pe):pe},e.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};xi(T),pi=!0},e.clearConfig=function(){pt=null,pi=!1},e.isValidAttribute=function(T,s,g){pt||xi({});let v=Q(T),V=Q(s);return vo(v,V,g)},e.addHook=function(T,s){typeof s=="function"&&jt(ie[T],s)},e.removeHook=function(T,s){if(s!==void 0){let g=Xs(ie[T],s);return g===-1?void 0:Qs(ie[T],g,1)[0]}return zr(ie[T])},e.removeHooks=function(T){ie[T]=[]},e.removeAllHooks=function(){ie=Wr()},e}var Qr=Xr();var Le=class i{renderer;constructor(){this.renderer=new xt,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 N(this,null,function*(){let t=yield L.parse(e,{renderer:this.renderer,breaks:!0,gfm:!0});return Qr.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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var ul=i=>({"user-message-wrapper":i});function hl(i,e){if(i&1&&(c(0,"div",5)(1,"div",9),f(2),d()()),i&2){let t=m(2);p(2),ht(" ",t.message.speaker," ")}}function gl(i,e){if(i&1&&(c(0,"time",7),f(1),d()),i&2){let t=m(2);p(),D(t.formattedTimestamp)}}function fl(i,e){if(i&1&&(c(0,"div",8),A(1,"app-message-context-menu",10),d()),i&2){let t=m(2);p(),k("actions",t.actions)}}function bl(i,e){if(i&1&&(x(0,hl,3,1,"div",5),A(1,"div",6),x(2,gl,2,1,"time",7),x(3,fl,2,1,"div",8)),i&2){let t=m();_(t.shouldShowSpeaker?0:-1),p(),k("innerHTML",t.renderedContent,fe),p(),_(t.formattedTimestamp?2:-1),p(),_(t.isLongMessage&&t.shouldShowActions&&t.message.role==="assistant"?3:-1)}}function xl(i,e){if(i&1&&(c(0,"a",12),f(1,"view"),d()),i&2){let t=m(2);k("href",t.eventLink,Po)}}function _l(i,e){if(i&1&&(c(0,"div",2),A(1,"span",11),x(2,xl,2,1,"a",12),d()),i&2){let t=m();p(),k("innerHTML",t.renderedContent,fe),p(),_(t.eventLink?2:-1)}}function vl(i,e){if(i&1&&(c(0,"div",3),A(1,"app-message-context-menu",10),d()),i&2){let t=m();p(),k("actions",t.actions)}}function Cl(i,e){if(i&1&&(c(0,"div",4),A(1,"app-message-context-menu",10),d()),i&2){let t=m();p(),k("actions",t.actions)}}var _t=class i{destroy$=new oe;message;canDelete=!0;isOtherUser=!1;copyRequested=new H;deleteRequested=new H;renderedContent="";shouldHideTechnical=!1;shouldHideWarning=!1;sanitizer=u(Ae);notificationService=u(
|
|
63
|
+
`+pe),st&&Ln([ai,si,li],$e=>{pe=Wt(pe,$e," ")}),Z&&en?Z.createHTML(pe):pe},e.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};xi(T),pi=!0},e.clearConfig=function(){pt=null,pi=!1},e.isValidAttribute=function(T,s,g){pt||xi({});let v=Q(T),V=Q(s);return vo(v,V,g)},e.addHook=function(T,s){typeof s=="function"&&jt(ie[T],s)},e.removeHook=function(T,s){if(s!==void 0){let g=Xs(ie[T],s);return g===-1?void 0:Qs(ie[T],g,1)[0]}return zr(ie[T])},e.removeHooks=function(T){ie[T]=[]},e.removeAllHooks=function(){ie=Wr()},e}var Qr=Xr();var Le=class i{renderer;constructor(){this.renderer=new xt,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 N(this,null,function*(){let t=yield L.parse(e,{renderer:this.renderer,breaks:!0,gfm:!0});return Qr.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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var ul=i=>({"user-message-wrapper":i});function hl(i,e){if(i&1&&(c(0,"div",5)(1,"div",9),f(2),d()()),i&2){let t=m(2);p(2),ht(" ",t.message.speaker," ")}}function gl(i,e){if(i&1&&(c(0,"time",7),f(1),d()),i&2){let t=m(2);p(),D(t.formattedTimestamp)}}function fl(i,e){if(i&1&&(c(0,"div",8),A(1,"app-message-context-menu",10),d()),i&2){let t=m(2);p(),k("actions",t.actions)}}function bl(i,e){if(i&1&&(x(0,hl,3,1,"div",5),A(1,"div",6),x(2,gl,2,1,"time",7),x(3,fl,2,1,"div",8)),i&2){let t=m();_(t.shouldShowSpeaker?0:-1),p(),k("innerHTML",t.renderedContent,fe),p(),_(t.formattedTimestamp?2:-1),p(),_(t.isLongMessage&&t.shouldShowActions&&t.message.role==="assistant"?3:-1)}}function xl(i,e){if(i&1&&(c(0,"a",12),f(1,"view"),d()),i&2){let t=m(2);k("href",t.eventLink,Po)}}function _l(i,e){if(i&1&&(c(0,"div",2),A(1,"span",11),x(2,xl,2,1,"a",12),d()),i&2){let t=m();p(),k("innerHTML",t.renderedContent,fe),p(),_(t.eventLink?2:-1)}}function vl(i,e){if(i&1&&(c(0,"div",3),A(1,"app-message-context-menu",10),d()),i&2){let t=m();p(),k("actions",t.actions)}}function Cl(i,e){if(i&1&&(c(0,"div",4),A(1,"app-message-context-menu",10),d()),i&2){let t=m();p(),k("actions",t.actions)}}var _t=class i{destroy$=new oe;message;canDelete=!0;isOtherUser=!1;copyRequested=new H;deleteRequested=new H;renderedContent="";shouldHideTechnical=!1;shouldHideWarning=!1;sanitizer=u(Ae);notificationService=u(_r);preferencesService=u(Ce);projectState=u(De);threadState=u(Re);markdownService=u(Le);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 N(this,null,function*(){yield this.renderMarkdown(),this.preferencesService.hideTechnicalMessages$.pipe(B(this.destroy$)).subscribe(e=>{this.shouldHideTechnical=e}),this.preferencesService.hideWarningMessages$.pipe(B(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=u(Ti);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(`
|
|
64
64
|
`).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 N(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 N(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",a=`
|
|
65
65
|
<div class="image-content">
|
|
66
66
|
<img src="${o}"
|
|
@@ -79,7 +79,7 @@ Please report this to https://github.com/markedjs/marked.`,i){let n="<p>An error
|
|
|
79
79
|
</div>
|
|
80
80
|
`;t.push(a)}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(`
|
|
81
81
|
|
|
82
|
-
`)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=P({type:i,selectors:[["app-chat-message"]],inputs:{message:"message",canDelete:"canDelete",isOtherUser:"isOtherUser"},outputs:{copyRequested:"copyRequested",deleteRequested:"deleteRequested"},features:[zo([Ti])],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&&(c(0,"div",0)(1,"div",1),x(2,bl,4,4),x(3,_l,3,2,"div",2),d(),x(4,vl,2,1,"div",3),x(5,Cl,2,1,"div",4),d()),t&2&&(k("ngClass",Vo(6,ul,n.message.role==="user")),p(),k("ngClass",n.messageClasses),p(),_(n.isSimplified?-1:2),p(),_(n.isSimplified?3:-1),p(),_(!n.isLongMessage&&n.shouldShowActions&&n.message.role==="assistant"?4:-1),p(),_(n.shouldShowActions&&n.message.role==="user"?5:-1))},dependencies:[Pn,gn],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 wl=(i,e)=>e.id;function Tl(i,e){if(i&1&&(c(0,"span",4),f(1),d()),i&2){let t=m();p(),D(t.taskSummary)}}function Sl(i,e){i&1&&(c(0,"div",6),A(1,"mat-spinner",8),c(2,"span"),f(3,"Loading..."),d()()),i&2&&(p(),k("diameter",16))}function kl(i,e){if(i&1&&A(0,"app-delegation-inline",9),i&2){let t=m().$implicit;k("subThreadId",t.subThreadId)("agentName",t.delegationAgentName)}}function Ml(i,e){if(i&1&&A(0,"app-chat-message",10),i&2){let t=m().$implicit;k("message",t)("canDelete",!1)}}function El(i,e){if(i&1&&x(0,kl,1,2,"app-delegation-inline",9)(1,Ml,1,2,"app-chat-message",10),i&2){let t=e.$implicit;_(t.type==="delegation"?0:1)}}function Ol(i,e){if(i&1&&(c(0,"div",7)(1,"div",11),f(2),d()()),i&2){let t=m(2);p(2),D(t.streamingText)}}function Il(i,e){if(i&1&&(c(0,"div",5),x(1,Sl,4,1,"div",6),me(2,El,2,1,null,null,wl),x(4,Ol,3,1,"div",7),d()),i&2){let t=m();p(),_(t.isLoading&&t.subMessages.length===0?1:-1),p(),ue(t.subMessages),p(2),_(t.streamingText?4:-1)}}var $n=class i{subThreadId;agentName;isExpanded=!1;isLoading=!1;subMessages=[];streamingText="";restLoaded=!1;messageIds=new Set;eventSubscription;codayService=u(ye);threadApi=u(gt);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(ge(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=cr(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 nr?this.addMessage({id:e.timestamp,role:"user",speaker:"User",content:[{type:"text",content:e.answer}],timestamp:new Date,type:"text"}):e instanceof or?this.streamingText+=e.chunk:e instanceof sr?(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 rr?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 ar?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 lr?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 ir&&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=P({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&&(c(0,"div",0)(1,"div",1),w("click",function(){return n.toggle()})("keydown.enter",function(){return n.toggle()})("keydown.space",function(){return n.toggle()}),c(2,"mat-icon",2),f(3),d(),c(4,"span",3),f(5),d(),x(6,Tl,2,1,"span",4),d(),x(7,Il,5,2,"div",5),d()),t&2&&(p(3),D(n.isExpanded?"expand_more":"chevron_right"),p(2),D(n.agentName),p(),_(n.taskSummary?6:-1),p(),_(n.isExpanded?7:-1))},dependencies:[i,ve,he,J,Cn,vn,_t],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 Ct=class i{unreadCountSubject=new sn(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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var Vn=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=P({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&&(Ft(0,"div",0)(1,"div",1)(2,"div",2)(3,"div",3)(4,"div",4),Lo(5,"img",5),Nt(),Ft(6,"p",6),f(7),Nt()()()()()),t&2&&(p(7),D(n.currentThinkingPhrase))},dependencies:[ve],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 Pl=(i,e)=>e.id;function Al(i,e){if(i&1&&A(0,"app-delegation-inline",3),i&2){let t=m().$implicit;k("subThreadId",t.subThreadId)("agentName",t.delegationAgentName)}}function Dl(i,e){if(i&1){let t=E();c(0,"app-chat-message",5),w("copyRequested",function(o){C(t);let r=m(2);return y(r.onCopyMessage(o))})("deleteRequested",function(o){C(t);let r=m(2);return y(r.onDeleteMessage(o))}),d()}if(i&2){let t=m(),n=t.$implicit,o=t.$index,r=m();k("message",n)("canDelete",r.canDeleteMessage(o))("isOtherUser",n.role==="user"&&!!r.currentUsername&&n.speaker!==r.currentUsername)}}function Rl(i,e){if(i&1&&x(0,Al,1,2,"app-delegation-inline",3)(1,Dl,1,3,"app-chat-message",4),i&2){let t=e.$implicit;_(t.type==="delegation"?0:1)}}function Fl(i,e){if(i&1&&(c(0,"div",1),A(1,"div",6),d()),i&2){let t=m();p(),k("innerHTML",t.renderedStreamingText,fe)}}function Nl(i,e){i&1&&A(0,"app-thinking-loader")}function Ll(i,e){if(i&1){let t=E();c(0,"button",7),w("click",function(){C(t);let o=m();return y(o.goToBottom())}),c(1,"mat-icon",8),f(2,"arrow_downward"),d()()}}var Un=class i{messages=[];streamingText="";isThinking=!1;currentUsername="";copyRequested=new H;stopRequested=new H;lastMessageCount=0;destroy$=new oe;renderedStreamingText="";isTracking=!0;showGoToBottom=!1;scrollContainer=null;lastScrollTop=0;NEAR_BOTTOM_THRESHOLD=100;scrollCheckTimeout;isProgrammaticScroll=!1;MESSAGE_FRESHNESS_THRESHOLD=300*1e3;elementRef=u(ut);unreadService=u(Ct);voiceSynthesisService=u(vr);preferencesService=u(Ce);codayService=u(ye);markdownService=u(Le);sanitizer=u(Ae);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(`
|
|
82
|
+
`)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=P({type:i,selectors:[["app-chat-message"]],inputs:{message:"message",canDelete:"canDelete",isOtherUser:"isOtherUser"},outputs:{copyRequested:"copyRequested",deleteRequested:"deleteRequested"},features:[zo([Ti])],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&&(c(0,"div",0)(1,"div",1),x(2,bl,4,4),x(3,_l,3,2,"div",2),d(),x(4,vl,2,1,"div",3),x(5,Cl,2,1,"div",4),d()),t&2&&(k("ngClass",Vo(6,ul,n.message.role==="user")),p(),k("ngClass",n.messageClasses),p(),_(n.isSimplified?-1:2),p(),_(n.isSimplified?3:-1),p(),_(!n.isLongMessage&&n.shouldShowActions&&n.message.role==="assistant"?4:-1),p(),_(n.shouldShowActions&&n.message.role==="user"?5:-1))},dependencies:[Pn,gn],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 wl=(i,e)=>e.id;function Tl(i,e){if(i&1&&(c(0,"span",4),f(1),d()),i&2){let t=m();p(),D(t.taskSummary)}}function Sl(i,e){i&1&&(c(0,"div",6),A(1,"mat-spinner",8),c(2,"span"),f(3,"Loading..."),d()()),i&2&&(p(),k("diameter",16))}function kl(i,e){if(i&1&&A(0,"app-delegation-inline",9),i&2){let t=m().$implicit;k("subThreadId",t.subThreadId)("agentName",t.delegationAgentName)}}function Ml(i,e){if(i&1&&A(0,"app-chat-message",10),i&2){let t=m().$implicit;k("message",t)("canDelete",!1)}}function El(i,e){if(i&1&&x(0,kl,1,2,"app-delegation-inline",9)(1,Ml,1,2,"app-chat-message",10),i&2){let t=e.$implicit;_(t.type==="delegation"?0:1)}}function Ol(i,e){if(i&1&&(c(0,"div",7)(1,"div",11),f(2),d()()),i&2){let t=m(2);p(2),D(t.streamingText)}}function Il(i,e){if(i&1&&(c(0,"div",5),x(1,Sl,4,1,"div",6),me(2,El,2,1,null,null,wl),x(4,Ol,3,1,"div",7),d()),i&2){let t=m();p(),_(t.isLoading&&t.subMessages.length===0?1:-1),p(),ue(t.subMessages),p(2),_(t.streamingText?4:-1)}}var $n=class i{subThreadId;agentName;isExpanded=!1;isLoading=!1;subMessages=[];streamingText="";restLoaded=!1;messageIds=new Set;eventSubscription;codayService=u(ye);threadApi=u(gt);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(ge(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=dr(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 ir?this.addMessage({id:e.timestamp,role:"user",speaker:"User",content:[{type:"text",content:e.answer}],timestamp:new Date,type:"text"}):e instanceof rr?this.streamingText+=e.chunk:e instanceof lr?(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 ar?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 sr?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 cr?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 or&&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=P({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&&(c(0,"div",0)(1,"div",1),w("click",function(){return n.toggle()})("keydown.enter",function(){return n.toggle()})("keydown.space",function(){return n.toggle()}),c(2,"mat-icon",2),f(3),d(),c(4,"span",3),f(5),d(),x(6,Tl,2,1,"span",4),d(),x(7,Il,5,2,"div",5),d()),t&2&&(p(3),D(n.isExpanded?"expand_more":"chevron_right"),p(2),D(n.agentName),p(),_(n.taskSummary?6:-1),p(),_(n.isExpanded?7:-1))},dependencies:[i,ve,he,J,Cn,vn,_t],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 Ct=class i{unreadCountSubject=new sn(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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var Vn=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=P({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&&(Ft(0,"div",0)(1,"div",1)(2,"div",2)(3,"div",3)(4,"div",4),Lo(5,"img",5),Nt(),Ft(6,"p",6),f(7),Nt()()()()()),t&2&&(p(7),D(n.currentThinkingPhrase))},dependencies:[ve],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 Pl=(i,e)=>e.id;function Al(i,e){if(i&1&&A(0,"app-delegation-inline",3),i&2){let t=m().$implicit;k("subThreadId",t.subThreadId)("agentName",t.delegationAgentName)}}function Dl(i,e){if(i&1){let t=E();c(0,"app-chat-message",5),w("copyRequested",function(o){C(t);let r=m(2);return y(r.onCopyMessage(o))})("deleteRequested",function(o){C(t);let r=m(2);return y(r.onDeleteMessage(o))}),d()}if(i&2){let t=m(),n=t.$implicit,o=t.$index,r=m();k("message",n)("canDelete",r.canDeleteMessage(o))("isOtherUser",n.role==="user"&&!!r.currentUsername&&n.speaker!==r.currentUsername)}}function Rl(i,e){if(i&1&&x(0,Al,1,2,"app-delegation-inline",3)(1,Dl,1,3,"app-chat-message",4),i&2){let t=e.$implicit;_(t.type==="delegation"?0:1)}}function Fl(i,e){if(i&1&&(c(0,"div",1),A(1,"div",6),d()),i&2){let t=m();p(),k("innerHTML",t.renderedStreamingText,fe)}}function Nl(i,e){i&1&&A(0,"app-thinking-loader")}function Ll(i,e){if(i&1){let t=E();c(0,"button",7),w("click",function(){C(t);let o=m();return y(o.goToBottom())}),c(1,"mat-icon",8),f(2,"arrow_downward"),d()()}}var Un=class i{messages=[];streamingText="";isThinking=!1;currentUsername="";copyRequested=new H;stopRequested=new H;lastMessageCount=0;destroy$=new oe;renderedStreamingText="";isTracking=!0;showGoToBottom=!1;scrollContainer=null;lastScrollTop=0;NEAR_BOTTOM_THRESHOLD=100;scrollCheckTimeout;isProgrammaticScroll=!1;MESSAGE_FRESHNESS_THRESHOLD=300*1e3;elementRef=u(ut);unreadService=u(Ct);voiceSynthesisService=u(mr);preferencesService=u(Ce);codayService=u(ye);markdownService=u(Le);sanitizer=u(Ae);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(`
|
|
83
83
|
|
|
84
84
|
`);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?
|
|
85
85
|
|
|
@@ -87,5 +87,5 @@ This action cannot be undone once you post another message.`)&&(console.log("[CH
|
|
|
87
87
|
|
|
88
88
|
`)}extractPartialText(e){return e.split(`
|
|
89
89
|
`).filter(a=>a.trim().length>0).reduce((a,l)=>{if(a.paragraphs>=3)return a;let h=l.length>80?1:0;return{paragraphs:a.paragraphs+h,text:a.text+(a.text?`
|
|
90
|
-
`:"")+l}},{paragraphs:0,text:""}).text||e}renderStreamingText(){return N(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=P({type:i,selectors:[["app-chat-history"]],hostBindings:function(t,n){t&1&&w("scroll",function(){return n.onScroll()})},inputs:{messages:"messages",streamingText:"streamingText",isThinking:"isThinking",currentUsername:"currentUsername"},outputs:{copyRequested:"copyRequested",stopRequested:"stopRequested"},features:[Ie],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&&(c(0,"div",0),me(1,Rl,2,1,null,null,Pl),x(3,Fl,2,1,"div",1),x(4,Nl,1,0,"app-thinking-loader"),x(5,Ll,3,0,"button",2),d()),t&2&&(p(),ue(n.messages),p(2),_(n.streamingText?3:-1),p(),_(n.isThinking?4:-1),p(),_(n.showGoToBottom?5:-1))},dependencies:[_t,J,Vn,_n,$n],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 Hl=["buttonContainer"],zl=["freeTextInput"],$l=(i,e)=>e.value;function Vl(i,e){i&1&&(c(0,"mat-icon",10),f(1,"keyboard_return"),d())}function Ul(i,e){if(i&1){let t=E();c(0,"button",8),w("click",function(){let o=C(t).$implicit,r=m(2);return y(r.onOptionClick(o.value))}),c(1,"span",9),f(2),d(),x(3,Vl,2,0,"mat-icon",10),d()}if(i&2){let t=e.$implicit,n=e.$index,o=m(2);be("highlighted",n===o.highlightedIndex),k("disabled",t.disabled)("id","choice-option-"+n),We("aria-selected",n===o.highlightedIndex),p(2),D(t.label),p(),_(n===o.highlightedIndex?3:-1)}}function Bl(i,e){if(i&1){let t=E();c(0,"div",6)(1,"span",11),f(2,"Or type your own answer:"),d(),c(3,"div",12)(4,"input",13,1),mn("ngModelChange",function(o){C(t);let r=m(2);return pn(r.freeTextValue,o)||(r.freeTextValue=o),y(o)}),w("keydown",function(o){C(t);let r=m(2);return y(r.onFreeTextKeyDown(o))}),d(),c(6,"button",14),w("click",function(){C(t);let o=m(2);return y(o.onFreeTextSubmit())}),c(7,"mat-icon"),f(8,"send"),d()()()()}if(i&2){let t=m(2);p(4),dn("ngModel",t.freeTextValue),p(2),k("disabled",!t.freeTextValue.trim())}}function jl(i,e){if(i&1&&(c(0,"div",7)(1,"mat-icon"),f(2,"search"),d(),c(3,"span"),f(4),d()()),i&2){let t=m(2);p(4),D(t.searchText)}}function Wl(i,e){if(i&1){let t=E();c(0,"div",2),A(1,"div",3),Lt(2,"async"),c(3,"div",4,0),w("keydown",function(o){C(t);let r=m();return y(r.onKeyDown(o))}),me(5,Ul,4,7,"button",5,$l),d(),x(7,Bl,9,2,"div",6),x(8,jl,5,1,"div",7),d()}if(i&2){let t=m();p(),k("innerHTML",Uo(2,4,t.renderedLabel$),fe),p(2),We("aria-activedescendant","choice-option-"+t.highlightedIndex),p(2),ue(t.options),p(2),_(t.allowFreeText?7:-1),p(),_(t.searchText?8:-1)}}var Bn=class i{options=[];allowFreeText=!1;set labelHtml(e){typeof e=="object"?this.renderedLabelSubject.next(e):this.renderLabelMarkdown(e)}isVisible=!1;choiceSelected=new H;buttonContainer;freeTextInput;highlightedIndex=0;searchText="";freeTextValue="";searchTimeout;destroy$=new oe;renderedLabelSubject=new sn("");renderedLabel$=this.renderedLabelSubject.asObservable();sanitizer=u(Ae);markdownService=u(Le);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,a)=>({opt:r,idx:a})).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 N(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=P({type:i,selectors:[["app-choice-select"]],viewQuery:function(t,n){if(t&1&&qe(Hl,5)(zl,5),t&2){let o;xe(o=_e())&&(n.buttonContainer=o.first),xe(o=_e())&&(n.freeTextInput=o.first)}},inputs:{options:"options",allowFreeText:"allowFreeText",labelHtml:"labelHtml",isVisible:"isVisible"},outputs:{choiceSelected:"choiceSelected"},features:[Ie],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&&x(0,Wl,9,6,"div",2),t&2&&_(n.isVisible?0:-1)},dependencies:[he,J,Sn,yn,wn,Tn,Bo],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 ql(i,e){if(i&1){let t=E();c(0,"div",0)(1,"div",1)(2,"mat-icon"),f(3,"lock_open"),d()(),c(4,"div",2)(5,"p",3),f(6,"Authorization required"),d(),c(7,"p",4)(8,"strong"),f(9),d(),f(10," needs your permission to continue. "),d()(),c(11,"div",5)(12,"button",6),w("click",function(){let o=C(t),r=m();return y(r.onCancel(o))}),f(13,"Cancel"),d(),c(14,"button",7),w("click",function(){let o=C(t),r=m();return y(r.onAuthorize(o))}),c(15,"mat-icon"),f(16,"open_in_new"),d(),f(17," Authorize "),d()()()}i&2&&(p(9),D(e.integrationName))}var jn=class i{oauthService=u(On);pendingRequest=Mn(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=P({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&&x(0,ql,18,1,"div",0),t&2){let o;_((o=n.pendingRequest())?0:-1,o)}},dependencies:[he,J],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 Wn=class i{http=u(Pe);projectState=u(De);threadState=u(Re);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 an(o=>{let r=new FileReader;r.onload=()=>{let l=r.result.split(",")[1];this.http.post(`/api/projects/${t}/threads/${n}/upload`,{content:l,mimeType:e.type||"application/octet-stream",filename:e.name}).subscribe({next:h=>{o.next({success:h.success,filename:h.filename}),o.complete()},error:h=>o.error(h)})},r.onerror=()=>o.error(new Error("Failed to read file")),r.readAsDataURL(e)})}listFiles(){return this.http.get(this.getBaseUrl()).pipe(Be(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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var yt=class i{fileApi=u(Wn);eventStream=u(En);filesSignal=je([]);isLoadingSignal=je(!1);currentProjectSignal=je(null);currentThreadSignal=je(null);files=un(()=>this.filesSignal());isLoading=un(()=>this.isLoadingSignal());fileCount=un(()=>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(q({},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 N(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 N(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(ge(e=>e instanceof kn),dr()).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 a=e.timestamp.substring(o+1);a.length===5&&/^[a-z0-9]+$/.test(a)&&(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(h=>h.filename!==e.filename),o=t.find(h=>h.filename===e.filename),r=e.timestamp,a=e.timestamp.lastIndexOf("-");if(a>0){let h=e.timestamp.substring(a+1);h.length===5&&/^[a-z0-9]+$/.test(h)&&(r=e.timestamp.substring(0,a))}let l={filename:e.filename,size:e.size||o?.size||0,lastModified:new Date(r)};this.filesSignal.set([l,...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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};function Yl(i,e){if(i&1&&A(0,"div",1),i&2){let t=m();k("innerHTML",t.renderedContent,fe)}}function Gl(i,e){if(i&1&&A(0,"iframe",2),i&2){let t=m();k("srcdoc",t.content,fe)}}function Xl(i,e){if(i&1&&(c(0,"pre",3),f(1),d()),i&2){let t=m();p(),D(t.content)}}var qn=class i{content="";format="text";renderedContent="";sanitizer=u(Ae);markdownService=u(Le);ngOnChanges(e){(e.content||e.format)&&this.renderContent()}renderContent(){this.format==="markdown"?this.renderMarkdown():this.format==="json"&&this.formatJson()}renderMarkdown(){return N(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=P({type:i,selectors:[["app-content-renderer"]],inputs:{content:"content",format:"format"},features:[Ie],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&&(c(0,"div",0),x(1,Yl,1,1,"div",1)(2,Gl,1,1,"iframe",2)(3,Xl,2,1,"pre",3),d()),t&2&&(k("ngClass","format-"+n.format),p(),_(n.format==="markdown"?1:n.format==="html"?2:3))},dependencies:[ve,gn],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 wt=class i{http=u(Pe);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(Be(a=>{let l=a.body||"",h=new Blob([l]).size;return{content:l,format:r,filename:n,size:h}}),ln(a=>(console.error("[CONTENT_VIEWER] Error loading file:",n,a),So(()=>new Error(`Failed to load file: ${a.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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};function Ql(i,e){if(i&1){let t=E();c(0,"button",12),w("click",function(){C(t);let o=m();return y(o.download())}),c(1,"mat-icon"),f(2,"download"),d()()}}function Zl(i,e){i&1&&(c(0,"div",9),A(1,"mat-spinner",13),c(2,"p"),f(3,"Loading file content..."),d()())}function Kl(i,e){if(i&1){let t=E();c(0,"div",10)(1,"mat-icon",14),f(2,"error_outline"),d(),c(3,"p",15),f(4),d(),c(5,"button",16),w("click",function(){C(t);let o=m();return y(o.download())}),c(6,"mat-icon"),f(7,"download"),d(),f(8," Download instead "),d()()}if(i&2){let t=m();p(4),D(t.error)}}function Jl(i,e){if(i&1&&A(0,"app-content-renderer",11),i&2){let t=m();k("content",t.fileContent.content)("format",t.fileContent.format)}}var Yn=class i{destroy$=new oe;file;projectName;threadId;closeViewer=new H;contentService=u(wt);eventStream=u(En);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(ge(e=>e instanceof kn),ge(e=>e.filename===this.file.filename),ge(e=>e.operation==="updated"),B(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=P({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&&(c(0,"div",0)(1,"div",1)(2,"div",2)(3,"span",3),f(4),d(),c(5,"span",4),f(6),d()(),c(7,"div",5),x(8,Ql,3,0,"button",6),c(9,"button",7),w("click",function(){return n.onClose()}),c(10,"mat-icon"),f(11,"chevron_right"),d()()()(),c(12,"div",8),x(13,Zl,4,0,"div",9),x(14,Kl,9,1,"div",10),x(15,Jl,1,2,"app-content-renderer",11),d()()),t&2&&(p(4),D(n.file.filename),p(2),D(n.formatSize(n.file.size)),p(2),_(n.fileContent&&!n.isLoading&&!n.error?8:-1),p(5),_(n.isLoading?13:-1),p(),_(n.error?14:-1),p(),_(n.fileContent&&!n.isLoading&&!n.error?15:-1))},dependencies:[ve,he,J,Ge,Jo,Ye,Cn,vn,qn],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 ec=Math.pow(10,8)*24*60*60*1e3,Mh=-ec,Gn=6048e5,Zr=864e5;var tc=3600;var Kr=tc*24,Eh=Kr*7,nc=Kr*365.2425,ic=nc/12,Oh=ic*3,Xi=Symbol.for("constructDateFrom");function X(i,e){return typeof i=="function"?i(e):i&&typeof i=="object"&&Xi in i?i[Xi](e):i instanceof Date?new i.constructor(e):new Date(e)}function U(i,e){return X(e||i,i)}function Jr(i,e,t){let n=U(i,t?.in);return isNaN(e)?X(t?.in||i,NaN):(e&&n.setDate(n.getDate()+e),n)}var oc={};function Xe(){return oc}function Ve(i,e){let t=Xe(),n=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,o=U(i,e?.in),r=o.getDay(),a=(r<n?7:0)+r-n;return o.setDate(o.getDate()-a),o.setHours(0,0,0,0),o}function ot(i,e){return Ve(i,Oe(q({},e),{weekStartsOn:1}))}function Xn(i,e){let t=U(i,e?.in),n=t.getFullYear(),o=X(t,0);o.setFullYear(n+1,0,4),o.setHours(0,0,0,0);let r=ot(o),a=X(t,0);a.setFullYear(n,0,4),a.setHours(0,0,0,0);let l=ot(a);return t.getTime()>=r.getTime()?n+1:t.getTime()>=l.getTime()?n:n-1}function Qi(i){let e=U(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 Tt(i,...e){let t=X.bind(null,i||e.find(n=>typeof n=="object"));return e.map(t)}function St(i,e){let t=U(i,e?.in);return t.setHours(0,0,0,0),t}function Qn(i,e,t){let[n,o]=Tt(t?.in,i,e),r=St(n),a=St(o),l=+r-Qi(r),h=+a-Qi(a);return Math.round((l-h)/Zr)}function ea(i,e){let t=Xn(i,e),n=X(e?.in||i,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),ot(n)}function ta(i){return X(i,Date.now())}function na(i,e,t){let[n,o]=Tt(t?.in,i,e);return+St(n)==+St(o)}function ia(i){return i instanceof Date||typeof i=="object"&&Object.prototype.toString.call(i)==="[object Date]"}function oa(i){return!(!ia(i)&&typeof i!="number"||isNaN(+U(i)))}function aa(i,e,t){let[n,o]=Tt(t?.in,i,e),r=ra(n,o),a=Math.abs(Qn(n,o));n.setDate(n.getDate()-r*a);let l=+(ra(n,o)===-r),h=r*(a-l);return h===0?0:h}function ra(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 sa(i,e){let t=U(i,e?.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}var rc={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"}},la=(i,e,t)=>{let n,o=rc[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 Zn(i){return(e={})=>{let t=e.width?String(e.width):i.defaultWidth;return i.formats[t]||i.formats[i.defaultWidth]}}var ac={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},sc={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},lc={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ca={date:Zn({formats:ac,defaultWidth:"full"}),time:Zn({formats:sc,defaultWidth:"full"}),dateTime:Zn({formats:lc,defaultWidth:"full"})};var cc={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},da=(i,e,t,n)=>cc[i];function kt(i){return(e,t)=>{let n=t?.context?String(t.context):"standalone",o;if(n==="formatting"&&i.formattingValues){let a=i.defaultFormattingWidth||i.defaultWidth,l=t?.width?String(t.width):a;o=i.formattingValues[l]||i.formattingValues[a]}else{let a=i.defaultWidth,l=t?.width?String(t.width):i.defaultWidth;o=i.values[l]||i.values[a]}let r=i.argumentCallback?i.argumentCallback(e):e;return o[r]}}var dc={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},pc={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},mc={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"]},uc={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"]},hc={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"}},gc={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"}},fc=(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"},pa={ordinalNumber:fc,era:kt({values:dc,defaultWidth:"wide"}),quarter:kt({values:pc,defaultWidth:"wide",argumentCallback:i=>i-1}),month:kt({values:mc,defaultWidth:"wide"}),day:kt({values:uc,defaultWidth:"wide"}),dayPeriod:kt({values:hc,defaultWidth:"wide",formattingValues:gc,defaultFormattingWidth:"wide"})};function Mt(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 a=r[0],l=n&&i.parsePatterns[n]||i.parsePatterns[i.defaultParseWidth],h=Array.isArray(l)?xc(l,M=>M.test(a)):bc(l,M=>M.test(a)),b;b=i.valueCallback?i.valueCallback(h):h,b=t.valueCallback?t.valueCallback(b):b;let S=e.slice(a.length);return{value:b,rest:S}}}function bc(i,e){for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&e(i[t]))return t}function xc(i,e){for(let t=0;t<i.length;t++)if(e(i[t]))return t}function ma(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 a=i.valueCallback?i.valueCallback(r[0]):r[0];a=t.valueCallback?t.valueCallback(a):a;let l=e.slice(o.length);return{value:a,rest:l}}}var _c=/^(\d+)(th|st|nd|rd)?/i,vc=/\d+/i,Cc={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},yc={any:[/^b/i,/^(a|c)/i]},wc={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Tc={any:[/1/i,/2/i,/3/i,/4/i]},Sc={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},kc={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]},Mc={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},Ec={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]},Oc={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},Ic={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}},ua={ordinalNumber:ma({matchPattern:_c,parsePattern:vc,valueCallback:i=>parseInt(i,10)}),era:Mt({matchPatterns:Cc,defaultMatchWidth:"wide",parsePatterns:yc,defaultParseWidth:"any"}),quarter:Mt({matchPatterns:wc,defaultMatchWidth:"wide",parsePatterns:Tc,defaultParseWidth:"any",valueCallback:i=>i+1}),month:Mt({matchPatterns:Sc,defaultMatchWidth:"wide",parsePatterns:kc,defaultParseWidth:"any"}),day:Mt({matchPatterns:Mc,defaultMatchWidth:"wide",parsePatterns:Ec,defaultParseWidth:"any"}),dayPeriod:Mt({matchPatterns:Oc,defaultMatchWidth:"any",parsePatterns:Ic,defaultParseWidth:"any"})};var Zi={code:"en-US",formatDistance:la,formatLong:ca,formatRelative:da,localize:pa,match:ua,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ha(i,e){let t=U(i,e?.in);return Qn(t,sa(t))+1}function ga(i,e){let t=U(i,e?.in),n=+ot(t)-+ea(t);return Math.round(n/Gn)+1}function Kn(i,e){let t=U(i,e?.in),n=t.getFullYear(),o=Xe(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,a=X(e?.in||i,0);a.setFullYear(n+1,0,r),a.setHours(0,0,0,0);let l=Ve(a,e),h=X(e?.in||i,0);h.setFullYear(n,0,r),h.setHours(0,0,0,0);let b=Ve(h,e);return+t>=+l?n+1:+t>=+b?n:n-1}function fa(i,e){let t=Xe(),n=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,o=Kn(i,e),r=X(e?.in||i,0);return r.setFullYear(o,0,n),r.setHours(0,0,0,0),Ve(r,e)}function ba(i,e){let t=U(i,e?.in),n=+Ve(t,e)-+fa(t,e);return Math.round(n/Gn)+1}function F(i,e){let t=i<0?"-":"",n=Math.abs(i).toString().padStart(e,"0");return t+n}var Ue={y(i,e){let t=i.getFullYear(),n=t>0?t:1-t;return F(e==="yy"?n%100:n,e.length)},M(i,e){let t=i.getMonth();return e==="M"?String(t+1):F(t+1,2)},d(i,e){return F(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 F(i.getHours()%12||12,e.length)},H(i,e){return F(i.getHours(),e.length)},m(i,e){return F(i.getMinutes(),e.length)},s(i,e){return F(i.getSeconds(),e.length)},S(i,e){let t=e.length,n=i.getMilliseconds(),o=Math.trunc(n*Math.pow(10,t-3));return F(o,e.length)}};var Et={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Ki={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 Ue.y(i,e)},Y:function(i,e,t,n){let o=Kn(i,n),r=o>0?o:1-o;if(e==="YY"){let a=r%100;return F(a,2)}return e==="Yo"?t.ordinalNumber(r,{unit:"year"}):F(r,e.length)},R:function(i,e){let t=Xn(i);return F(t,e.length)},u:function(i,e){let t=i.getFullYear();return F(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 F(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 F(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 Ue.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 F(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=ba(i,n);return e==="wo"?t.ordinalNumber(o,{unit:"week"}):F(o,e.length)},I:function(i,e,t){let n=ga(i);return e==="Io"?t.ordinalNumber(n,{unit:"week"}):F(n,e.length)},d:function(i,e,t){return e==="do"?t.ordinalNumber(i.getDate(),{unit:"date"}):Ue.d(i,e)},D:function(i,e,t){let n=ha(i);return e==="Do"?t.ordinalNumber(n,{unit:"dayOfYear"}):F(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 F(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 F(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 F(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=Et.noon:n===0?o=Et.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=Et.evening:n>=12?o=Et.afternoon:n>=4?o=Et.morning:o=Et.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 Ue.h(i,e)},H:function(i,e,t){return e==="Ho"?t.ordinalNumber(i.getHours(),{unit:"hour"}):Ue.H(i,e)},K:function(i,e,t){let n=i.getHours()%12;return e==="Ko"?t.ordinalNumber(n,{unit:"hour"}):F(n,e.length)},k:function(i,e,t){let n=i.getHours();return n===0&&(n=24),e==="ko"?t.ordinalNumber(n,{unit:"hour"}):F(n,e.length)},m:function(i,e,t){return e==="mo"?t.ordinalNumber(i.getMinutes(),{unit:"minute"}):Ue.m(i,e)},s:function(i,e,t){return e==="so"?t.ordinalNumber(i.getSeconds(),{unit:"second"}):Ue.s(i,e)},S:function(i,e){return Ue.S(i,e)},X:function(i,e,t){let n=i.getTimezoneOffset();if(n===0)return"Z";switch(e){case"X":return _a(n);case"XXXX":case"XX":return rt(n);default:return rt(n,":")}},x:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"x":return _a(n);case"xxxx":case"xx":return rt(n);default:return rt(n,":")}},O:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+xa(n,":");default:return"GMT"+rt(n,":")}},z:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+xa(n,":");default:return"GMT"+rt(n,":")}},t:function(i,e,t){let n=Math.trunc(+i/1e3);return F(n,e.length)},T:function(i,e,t){return F(+i,e.length)}};function xa(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+F(r,2)}function _a(i,e){return i%60===0?(i>0?"-":"+")+F(Math.abs(i)/60,2):rt(i,e)}function rt(i,e=""){let t=i>0?"-":"+",n=Math.abs(i),o=F(Math.trunc(n/60),2),r=F(n%60,2);return t+o+e+r}var va=(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"})}},Ca=(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"})}},Pc=(i,e)=>{let t=i.match(/(P+)(p+)?/)||[],n=t[1],o=t[2];if(!o)return va(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}}",va(n,e)).replace("{{time}}",Ca(o,e))},ya={p:Ca,P:Pc};var Ac=/^D+$/,Dc=/^Y+$/,Rc=["D","DD","YY","YYYY"];function wa(i){return Ac.test(i)}function Ta(i){return Dc.test(i)}function Sa(i,e,t){let n=Fc(i,e,t);if(console.warn(n),Rc.includes(i))throw new RangeError(n)}function Fc(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 Nc=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Lc=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Hc=/^'([^]*?)'?$/,zc=/''/g,$c=/[a-zA-Z]/;function Ji(i,e,t){let n=Xe(),o=t?.locale??n.locale??Zi,r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,a=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,l=U(i,t?.in);if(!oa(l))throw new RangeError("Invalid time value");let h=e.match(Lc).map(S=>{let M=S[0];if(M==="p"||M==="P"){let I=ya[M];return I(S,o.formatLong)}return S}).join("").match(Nc).map(S=>{if(S==="''")return{isToken:!1,value:"'"};let M=S[0];if(M==="'")return{isToken:!1,value:Vc(S)};if(Ki[M])return{isToken:!0,value:S};if(M.match($c))throw new RangeError("Format string contains an unescaped latin alphabet character `"+M+"`");return{isToken:!1,value:S}});o.localize.preprocessor&&(h=o.localize.preprocessor(l,h));let b={firstWeekContainsDate:r,weekStartsOn:a,locale:o};return h.map(S=>{if(!S.isToken)return S.value;let M=S.value;(!t?.useAdditionalWeekYearTokens&&Ta(M)||!t?.useAdditionalDayOfYearTokens&&wa(M))&&Sa(M,e,String(i));let I=Ki[M[0]];return I(l,M,o.localize,b)}).join("")}function Vc(i){let e=i.match(Hc);return e?e[1].replace(zc,"'"):i}function ka(i,e,t){return Jr(i,-e,t)}function Ma(i,e){return na(X(e?.in||i,i),ka(ta(e?.in||i),1))}function Ea(i){if(!i||isNaN(i.getTime()))return"unknown";let e=new Date,t=Ji(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(Ma(i))return`yesterday ${t}`;let a=aa(e,i);return a<7?`${a}d ago ${t}`:`${Ji(i,"dd/MM/yyyy")} ${t}`}var Uc=(i,e)=>e.filename;function Bc(i,e){if(i&1){let t=E();c(0,"button",11),w("click",function(){C(t);let o=m(2);return y(o.downloadAll())}),c(1,"mat-icon"),f(2,"download_for_offline"),d()()}}function jc(i,e){i&1&&(c(0,"div",10),A(1,"span",12),c(2,"span",13),f(3,"Loading files..."),d()())}function Wc(i,e){i&1&&(c(0,"div",14)(1,"mat-icon",15),f(2,"folder_open"),d(),c(3,"p",16),f(4,"No files in exchange space"),d(),c(5,"p",17),f(6,"Upload files to share with the agent"),d()())}function qc(i,e){if(i&1){let t=E();c(0,"button",28),w("click",function(){C(t);let o=m().$implicit,r=m(4);return y(r.viewFile(o))}),c(1,"mat-icon"),f(2,"visibility"),d()()}}function Yc(i,e){if(i&1){let t=E();c(0,"div",18)(1,"div",19)(2,"mat-icon",20),f(3),d(),c(4,"div",21)(5,"span",22),f(6),d(),c(7,"span",23),f(8),d()()(),c(9,"div",24),x(10,qc,3,0,"button",25),c(11,"button",26),w("click",function(){let o=C(t).$implicit,r=m(4);return y(r.download(o))}),c(12,"mat-icon"),f(13,"download"),d()(),c(14,"button",27),w("click",function(){let o=C(t).$implicit,r=m(4);return y(r.delete(o))}),c(15,"mat-icon"),f(16,"delete"),d()()()()}if(i&2){let t=e.$implicit,n=m(4);p(3),D(n.getFileIcon(t.filename)),p(2),k("title",t.filename),p(),D(t.filename),p(2),cn("",n.formatSize(t.size)," \u2022 ",n.formatDate(t.lastModified)),p(2),_(n.canViewFile(t)?10:-1)}}function Gc(i,e){if(i&1&&me(0,Yc,17,6,"div",18,Uc),i&2){let t=m(3);ue(t.files())}}function Xc(i,e){if(i&1&&x(0,Wc,7,0,"div",14)(1,Gc,2,0),i&2){let t=m(2);_(t.files().length===0?0:1)}}function Qc(i,e){if(i&1){let t=E();c(0,"div",0)(1,"div",2)(2,"div",3)(3,"h3",4),f(4,"Exchange"),d(),c(5,"span",5),f(6),d()(),c(7,"div",6),x(8,Bc,3,0,"button",7),c(9,"button",8),w("click",function(){C(t);let o=m();return y(o.close())}),c(10,"mat-icon"),f(11,"chevron_right"),d()()()(),c(12,"div",9),x(13,jc,4,0,"div",10)(14,Xc,2,1),d()()}if(i&2){let t=m();p(6),ht("(",t.files().length,")"),p(2),_(t.files().length>0?8:-1),p(5),_(t.isLoading()?13:14)}}function Zc(i,e){if(i&1){let t=E();c(0,"app-content-viewer",29),w("closeViewer",function(){C(t);let o=m();return y(o.backToList())}),d()}if(i&2){let t=m();k("file",t.currentFile)("projectName",t.projectName)("threadId",t.threadId)}}var Jn=class i{projectName;threadId;closeDrawer=new H;fileExchangeState=u(yt);contentViewerService=u(wt);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 N(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 Ea(e)}canViewFile(e){return this.contentViewerService.isFormatViewable(e.filename)&&this.contentViewerService.isViewable(e.size)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=P({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&&(x(0,Qc,15,3,"div",0),x(1,Zc,1,3,"app-content-viewer",1)),t&2&&(_(n.viewerState==="list"?0:-1),p(),_(n.viewerState==="content"&&n.currentFile?1:-1))},dependencies:[ve,he,J,Ge,Ye,Yn],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 ei=class i{http=u(Pe);listUsers(){return this.http.get("/api/users")}static \u0275fac=function(t){return new(t||i)};static \u0275prov=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var ti=class i{excludedUserIds=[];placeholder="Search username";disabled=!1;userSelected=new H;userApi=u(ei);search(e){let t=e.toLowerCase();return this.userApi.listUsers().pipe(Be(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=P({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&&(c(0,"ds-autocomplete-input",0),w("itemSelected",function(r){return n.onItemSelected(r)}),d()),t&2&&k("dataSource",n)("placeholder",n.placeholder)("disabled",n.disabled)},dependencies:[br],styles:["[_nghost-%COMP%]{display:block}"]})};var Kc=(i,e)=>e.userId;function Jc(i,e){if(i&1&&(c(0,"div",7),f(1),d()),i&2){let t=m();p(),D(t.errorMessage())}}function ed(i,e){if(i&1){let t=E();c(0,"button",13),w("click",function(){C(t);let o=m().$implicit,r=m();return y(r.removeUser(o.userId))}),c(1,"mat-icon"),f(2,"close"),d()()}}function td(i,e){if(i&1&&(c(0,"div",9)(1,"mat-icon",10),f(2,"person"),d(),c(3,"span",11),f(4),d(),x(5,ed,3,0,"button",12),d()),i&2){let t=e.$implicit,n=m();p(4),D(t.userId),p(),_(n.users.length>1?5:-1)}}var Xt=class i{threadId;users=[];currentUsername;userAdded=new H;userRemoved=new H;closed=new H;isAdding=je(!1);errorMessage=je("");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=P({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&&(c(0,"div",0)(1,"div",1)(2,"div",2)(3,"mat-icon"),f(4,"group"),d(),c(5,"span"),f(6,"Share"),d()(),c(7,"button",3),w("click",function(){return n.close()}),c(8,"mat-icon"),f(9,"chevron_right"),d()()(),c(10,"div",4)(11,"span"),f(12,"Participants"),d()(),c(13,"div",5)(14,"app-user-autocomplete",6),w("userSelected",function(r){return n.onUserSelected(r)}),d()(),x(15,Jc,2,1,"div",7),c(16,"div",8),me(17,td,6,2,"div",9,Kc),d()()),t&2&&(p(14),k("excludedUserIds",n.excludedUserIds)("disabled",n.isAdding()),p(),_(n.errorMessage()?15:-1),p(2),ue(n.users))},dependencies:[he,J,Ge,Ye,tr,ti],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 Oa="mat-badge-content",nd=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275cmp=P({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)}
|
|
91
|
-
`],encapsulation:2,changeDetection:0})}return i})(),Ia=(()=>{class i{_ngZone=u(Io);_elementRef=u(ut);_ariaDescriber=u(Qo);_renderer=u(Do);_animationsDisabled=Ko();_idGenerator=u(Xo);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=u(Yo);_document=u(Oo);constructor(){let t=u(Wo);t.load(nd),t.load(qo)}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(Oa),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 > .${Oa}`);for(let n of Array.from(t))n!==this._badgeElement&&n.remove()}static \u0275fac=function(n){return new(n||i)};static \u0275dir=Fo({type:i,selectors:[["","matBadge",""]],hostAttrs:[1,"mat-badge"],hostVars:20,hostBindings:function(n,o){n&2&&be("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",hn],disabled:[2,"matBadgeDisabled","disabled",hn],position:[0,"matBadgePosition","position"],content:[0,"matBadge","content"],description:[0,"matBadgeDescription","description"],size:[0,"matBadgeSize","size"],hidden:[2,"matBadgeHidden","hidden",hn]}})}return i})(),Pa=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=Ro({type:i});static \u0275inj=Eo({imports:[Go,Zo]})}return i})();var Ot=class i{ATTENTION_EMOJI="\u{1F534}";isSystemActive=!1;systemActiveTimer=null;SYSTEM_ACTIVE_TIMEOUT=4e3;unreadService=u(Ct);project=u(De);constructor(){this.initializeTitleUpdates()}initializeTitleUpdates(){ko([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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var ni=class i{http=u(Pe);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 N(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 a=r.split(",")[1];if(!a){n(new Error("Invalid file format"));return}t(a)},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),Ci({success:!1,error:o instanceof Error?o.message:"Validation failed"})}return new an(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(Be(a=>(console.log("[IMAGE-UPLOAD] Upload success result:",a),{success:!0,processedSize:a.processedSize,dimensions:a.dimensions})),ln(a=>{console.log("[IMAGE-UPLOAD] Upload failed:",a);let l=a.error?.error||a.message||"Upload failed";return Ci({success:!1,error:l})})).subscribe({next:a=>{o.next(a),o.complete()},error:a=>o.error(a)})}).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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var It=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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var od=["inputSection"],rd=()=>[];function ad(i,e){if(i&1){let t=E();c(0,"button",20),w("click",function(){C(t);let o=m();return y(o.toggleFileDrawer())}),c(1,"mat-icon"),f(2,"folder_open"),d()()}if(i&2){let t=m();be("has-files",t.fileCount>0),k("title",Ho("Files Exchange",t.fileCount>0?" ("+t.fileCount+" file"+(t.fileCount>1?"s":"")+")":""))("matBadge",t.fileCount>0?t.fileCount:null)}}function sd(i,e){if(i&1){let t=E();c(0,"button",21),w("click",function(){C(t);let o=m();return y(o.toggleSharePanel())}),c(1,"mat-icon"),f(2,"group"),d()()}if(i&2){let t=m();be("has-shared-users",((t.threadDetails==null||t.threadDetails.users==null?null:t.threadDetails.users.length)??0)>1)}}function ld(i,e){if(i&1&&(c(0,"div",6),f(1),d()),i&2){let t=m();p(),cn(" \u26A0\uFE0F Connection lost. Reconnecting... (",t.connectionStatus.reconnectAttempts,"/",t.connectionStatus.maxAttempts,") ")}}function cd(i,e){if(i&1&&(c(0,"div",22),f(1),d()),i&2){let t=m();be("error",t.uploadStatus.isError),p(),ht(" ",t.uploadStatus.message," ")}}function dd(i,e){if(i&1){let t=E();c(0,"app-chat-textarea",23),w("messageSubmitted",function(o){C(t);let r=m();return y(r.onMessageSubmitted(o))})("voiceRecordingToggled",function(o){C(t);let r=m();return y(r.onVoiceToggled(o))})("heightChanged",function(o){C(t);let r=m();return y(r.onInputHeightChanged(o))})("stopRequested",function(){C(t);let o=m();return y(o.onStopRequested())})("filesPasted",function(o){C(t);let r=m();return y(r.onFilesPasted(o))}),d()}if(i&2){let t=m();k("isDisabled",!t.isConnected)("isSessionInitializing",!1)("showWelcome",!1)("isThinking",t.isThinking)("isStarting",!1)}}function pd(i,e){if(i&1){let t=E();c(0,"app-choice-select",24),w("choiceSelected",function(o){C(t);let r=m();return y(r.onChoiceSelected(o))}),d()}if(i&2){let t=m();k("options",t.currentChoice.options)("labelHtml",t.currentChoice.label)("isVisible",!!t.currentChoice)("allowFreeText",t.currentChoice.allowFreeText)}}function md(i,e){i&1&&A(0,"app-oauth-request-panel")}function ud(i,e){if(i&1){let t=E();c(0,"app-file-exchange-drawer",25),w("closeDrawer",function(){C(t);let o=m();return y(o.closeDrawer())}),d()}if(i&2){let t=m();k("projectName",t.projectName)("threadId",t.threadId)}}function hd(i,e){if(i&1){let t=E();c(0,"app-thread-share",26),w("userAdded",function(o){C(t);let r=m();return y(r.onUserAdded(o))})("userRemoved",function(o){C(t);let r=m();return y(r.onUserRemoved(o))})("closed",function(){C(t);let o=m();return y(o.closeDrawer())}),d()}if(i&2){let t=m();k("threadId",t.threadId)("users",t.threadDetails.users||$o(3,rd))("currentUsername",t.currentUsername)}}function gd(i,e){i&1&&(c(0,"div",19)(1,"div",27)(2,"div",28),f(3,"\u{1F4CE}"),d(),c(4,"div",29),f(5,"Drop files here to upload"),d(),c(6,"div",30),f(7,"Images will be added to conversation, other files to exchange space"),d()()())}var ii=class i{projectName;threadId;chatFocused=new H;drawerStateChange=new H;destroy$=new oe;connectionDestroy$=new oe;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=u(ye);oauthService=u(On);pendingOAuthRequest=Mn(this.oauthService.pendingRequest$,{initialValue:null});preferencesService=u(Ce);titleService=u(Ot);elementRef=u(ut);threadState=u(Re);threadApiService=u(gt);userService=u(er);router=u(fn);imageUploadService=u(ni);fileExchangeState=u(yt);firstMessageState=u(It);audioApiService=u(ft);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(B(this.destroy$)).subscribe(e=>{this.authEnabled=e}),this.userService.username$.pipe(B(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(B(this.connectionDestroy$)).subscribe(n=>{console.log("[THREAD] Messages updated:",n.length),this.messages=n}),this.codayService.streamingText$.pipe(B(this.connectionDestroy$)).subscribe(n=>{this.streamingText=n}),this.codayService.isThinking$.pipe(B(this.connectionDestroy$)).subscribe(n=>{this.isThinking=n}),this.codayService.currentChoice$.pipe(B(this.connectionDestroy$)).subscribe(n=>{this.currentChoice=n}),this.codayService.connectionStatus$.pipe(B(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(B(this.connectionDestroy$)).subscribe(n=>{n&&(console.log("[THREAD] Thread update event received:",n),this.threadState.refreshThreadList())}),this.threadState.selectedThread$.pipe(B(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(B(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(ge(n=>!!n),Mo(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(B(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(B(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 N(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=P({type:i,selectors:[["app-thread"]],viewQuery:function(t,n){if(t&1&&qe(od,5)(Xt,5),t&2){let o;xe(o=_e())&&(n.inputSection=o.first),xe(o=_e())&&(n.threadShareRef=o.first)}},inputs:{projectName:"projectName",threadId:"threadId"},outputs:{chatFocused:"chatFocused",drawerStateChange:"drawerStateChange"},features:[Ie],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&&(c(0,"div",1),w("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)}),c(1,"mat-drawer-container",2)(2,"mat-drawer-content")(3,"div",3),x(4,ad,3,5,"button",4),x(5,sd,3,2,"button",5),x(6,ld,2,2,"div",6),c(7,"div",7),w("mousedown",function(){return n.chatFocused.emit()})("touchstart",function(){return n.chatFocused.emit()}),c(8,"div",8)(9,"app-chat-history",9),w("copyRequested",function(r){return n.onCopyMessage(r)})("stopRequested",function(){return n.onStopRequested()}),d(),x(10,cd,2,3,"div",10),d()(),c(11,"div",11,0)(13,"div",12)(14,"div",13),x(15,dd,1,5,"app-chat-textarea",14),x(16,pd,1,4,"app-choice-select",15),x(17,md,1,0,"app-oauth-request-panel"),d()()()()(),c(18,"mat-drawer",16),w("closed",function(){return n.closeDrawer()}),x(19,ud,1,2,"app-file-exchange-drawer",17),x(20,hd,1,4,"app-thread-share",18),d()(),x(21,gd,8,0,"div",19),d()),t&2&&(p(),k("hasBackdrop",!1),p(3),_(n.drawerMode!=="files"?4:-1),p(),_(n.authEnabled&&n.drawerMode!=="share"?5:-1),p(),_(n.showConnectionStatus&&n.connectionStatus&&!n.connectionStatus.connected?6:-1),p(3),k("messages",n.messages)("streamingText",n.streamingText)("isThinking",n.isThinking)("currentUsername",n.currentUsername),p(),_(n.uploadStatus.message?10:-1),p(5),_(!n.currentChoice&&!n.pendingOAuthRequest()?15:-1),p(),_(n.currentChoice?16:-1),p(),_(n.pendingOAuthRequest()?17:-1),p(),k("opened",n.isDrawerOpen),p(),_(n.drawerMode==="files"?19:-1),p(),_(n.drawerMode==="share"&&n.threadDetails?20:-1),p(),_(n.isDragOver?21:-1))},dependencies:[Un,bt,Bn,jn,Jn,Xt,gr,ur,hr,mr,he,J,Ge,_n,Pa,Ia],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}}"]})};var oi=class i{welcomeMessages=["Welcome to Coday","Bienvenue sur Coday","Bienvenido a Coday","Willkommen bei Coday","Benvenuto su Coday","Bem-vindo ao Coday","Welkom bij Coday","\u0414\u043E\u0431\u0440\u043E \u043F\u043E\u0436\u0430\u043B\u043E\u0432\u0430\u0442\u044C \u0432 Coday","Coday \u3078\u3088\u3046\u3053\u305D","\u6B22\u8FCE\u6765\u5230 Coday","Coday \uC5D0 \uC624\uC2E0 \uAC83\uC744 \uD658\uC601\uD569\uB2C8\uB2E4","\u0645\u0631\u062D\u0628\u064B\u0627 \u0628\u0643 \u0641\u064A Coday"];currentWelcomeIndex=0;currentWelcomeMessage=this.welcomeMessages[0];welcomeRotationInterval;ngOnInit(){this.startWelcomeRotation()}ngOnDestroy(){this.stopWelcomeRotation()}startWelcomeRotation(){this.welcomeRotationInterval=window.setInterval(()=>{this.currentWelcomeIndex=(this.currentWelcomeIndex+1)%this.welcomeMessages.length,this.currentWelcomeMessage=this.welcomeMessages[this.currentWelcomeIndex]},3e3)}stopWelcomeRotation(){this.welcomeRotationInterval&&(clearInterval(this.welcomeRotationInterval),this.welcomeRotationInterval=void 0)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=P({type:i,selectors:[["app-welcome-message"]],decls:2,vars:1,consts:[[1,"welcome-title"]],template:function(t,n){t&1&&(Ft(0,"h1",0),f(1),Nt()),t&2&&(p(),D(n.currentWelcomeMessage))},styles:[".welcome-title[_ngcontent-%COMP%]{font-size:clamp(1.5rem,4vw,4rem);font-weight:700;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% auto;background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;animation:_ngcontent-%COMP%_gradientShift 3s ease-in-out infinite;margin:0;padding:0;line-height:1.2;transition:opacity .5s ease-in-out;display:block;min-height:1.2em;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@keyframes _ngcontent-%COMP%_gradientShift{0%{background-position:0% center}50%{background-position:100% center}to{background-position:0% center}}"]})};var ri=class i{destroy$=new oe;isSetup=!1;codayService=u(ye);preferencesService=u(Ce);setup(){if(this.isSetup){console.warn("[AGENT-NOTIFICATION] Service already set up");return}console.log("[AGENT-NOTIFICATION] Setting up agent notification service"),this.codayService.isThinking$.pipe(B(this.destroy$),yi(),ge(([e,t])=>e===!0&&t===!1)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Agent stopped thinking, notifying task finished"),this.notifyTaskFinishedIfEnabled()}),this.preferencesService.browserNotificationEnabled$.pipe(B(this.destroy$),yi(),ge(([e,t])=>e===!1&&t===!0)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Browser notifications enabled, checking permission"),this.handleBrowserNotificationEnabled()}),this.isSetup=!0}notifyTaskFinishedIfEnabled(){this.preferencesService.getAgentNotificationEnabled()&&(this.preferencesService.getNotificationSoundEnabled()&&this.playCompletionSound(),this.preferencesService.getBrowserNotificationEnabled()&&this.sendBrowserNotification())}playCompletionSound(){try{let e=new(window.AudioContext||window.webkitAudioContext),t=e.createOscillator(),n=e.createGain();t.connect(n),n.connect(e.destination),t.frequency.setValueAtTime(700,e.currentTime),n.gain.setValueAtTime(.1,e.currentTime),n.gain.exponentialRampToValueAtTime(.01,e.currentTime+.08),t.start(e.currentTime),t.stop(e.currentTime+.08);let o=e.createOscillator(),r=e.createGain();o.connect(r),r.connect(e.destination);let a=e.currentTime+.11;o.frequency.setValueAtTime(950,a),r.gain.setValueAtTime(.1,a),r.gain.exponentialRampToValueAtTime(.01,a+.09),o.start(a),o.stop(a+.09),console.log("[AGENT-NOTIFICATION] Completion sound played")}catch(e){console.error("[AGENT-NOTIFICATION] Failed to play completion sound:",e)}}handleBrowserNotificationEnabled(){return N(this,null,function*(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications"),this.preferencesService.setBrowserNotificationEnabled(!1);return}if(Notification.permission==="denied"){console.warn("[AGENT-NOTIFICATION] Permission denied, disabling browser notifications"),this.preferencesService.setBrowserNotificationEnabled(!1);return}if(Notification.permission==="granted"){console.log("[AGENT-NOTIFICATION] Permission already granted, showing confirmation"),this.createConfirmationNotification();return}try{(yield Notification.requestPermission())==="granted"?(console.log("[AGENT-NOTIFICATION] Permission granted, showing confirmation"),this.createConfirmationNotification()):(console.log("[AGENT-NOTIFICATION] Permission denied or dismissed"),this.preferencesService.setBrowserNotificationEnabled(!1))}catch(e){console.error("[AGENT-NOTIFICATION] Error requesting permission:",e),this.preferencesService.setBrowserNotificationEnabled(!1)}})}sendBrowserNotification(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications");return}if(document.hasFocus()){console.warn("[AGENT-NOTIFICATION] Document is focused, skipping browser notification");return}Notification.permission==="granted"?this.createTaskCompleteNotification():console.warn("[AGENT-NOTIFICATION] Permission not granted, cannot send notification")}createConfirmationNotification(){let e=new Notification("Coday - Notifications Enabled",{body:"You will be notified when the agent completes tasks",icon:"/favicon.ico",tag:"coday-notifications-enabled",requireInteraction:!1});setTimeout(()=>e.close(),4e3),e.onclick=()=>{window.focus(),e.close()},console.log("[AGENT-NOTIFICATION] Confirmation notification sent")}createTaskCompleteNotification(){let e=new Notification("Coday - Task Complete",{body:"The agent has finished and is waiting for your input",icon:"/favicon.ico",tag:"coday-task-complete",requireInteraction:!1});setTimeout(()=>e.close(),5e3),e.onclick=()=>{window.focus(),e.close()},console.log("[AGENT-NOTIFICATION] Task complete notification sent")}ngOnDestroy(){console.log("[AGENT-NOTIFICATION] Service destroyed"),this.destroy$.next(),this.destroy$.complete()}static \u0275fac=function(t){return new(t||i)};static \u0275prov=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var fd=["inputSection"];function bd(i,e){if(i&1){let t=E();c(0,"app-thread",4),w("chatFocused",function(){C(t);let o=m();return y(o.onChatFocusedOnMobile())})("drawerStateChange",function(o){C(t);let r=m();return y(r.onDrawerStateChange(o))}),d()}if(i&2){let t=m();k("projectName",t.projectName)("threadId",t.threadId)}}function xd(i,e){if(i&1){let t=E();c(0,"div",5),A(1,"app-welcome-message"),d(),c(2,"div",6,0)(4,"div",7)(5,"div",8)(6,"app-chat-textarea",9),w("messageSubmitted",function(o){C(t);let r=m();return y(r.onMessageSubmitted(o))})("voiceMessageReady",function(o){C(t);let r=m();return y(r.onVoiceMessageReady(o))})("voiceRecordingToggled",function(o){C(t);let r=m();return y(r.onVoiceToggled(o))})("heightChanged",function(o){C(t);let r=m();return y(r.onInputHeightChanged(o))})("textareaFocused",function(){C(t);let o=m();return y(o.onChatFocusedOnMobile())}),d()()()()}if(i&2){let t=m();p(6),k("isDisabled",t.isSessionInitializing)("isSessionInitializing",t.isSessionInitializing)("showWelcome",!0)("isThinking",!1)("isStarting",t.isStartingFirstMessage)}}var Aa=class i{destroy$=new oe;inputSection;sidenav;projectName="";threadId=null;isSessionInitializing=!1;isStartingFirstMessage=!1;inputSectionHeight=80;codayService=u(ye);titleService=u(Ot);preferencesService=u(Ce);route=u(jo);router=u(fn);threadApiService=u(gt);agentNotificationService=u(ri);firstMessageState=u(It);constructor(){console.log("[MAIN-APP] Using new thread-based architecture (no clientId needed)")}ngOnInit(){this.agentNotificationService.setup(),this.setupPrintHandlers(),this.route.params.pipe(B(this.destroy$)).subscribe(e=>{let t=e.projectName,n=e.threadId||null;console.log("[MAIN-APP] Route params updated:",{project:t,thread:n,previousProject:this.projectName,previousThread:this.threadId}),this.projectName=t,this.threadId=n,this.threadId?console.log("[MAIN-APP] Thread selected - ThreadComponent will display"):(console.log("[MAIN-APP] No thread selected - showing welcome view"),this.initializeWelcomeView())})}initializeWelcomeView(){this.codayService.setTabTitleService(this.titleService)}ngAfterViewInit(){setTimeout(()=>this.updateInputSectionHeight(),100)}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),window.removeEventListener("beforeprint",this.handleBeforePrint),window.removeEventListener("afterprint",this.handleAfterPrint)}onMessageSubmitted(e){console.log("[MAIN-APP] First message submitted from welcome view:",e),this.isSessionInitializing=!0,this.isStartingFirstMessage=!0,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created:",t.thread.id),this.firstMessageState.setPendingFirstMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id])},error:t=>{console.error("[MAIN-APP] Failed to create thread:",t),this.isSessionInitializing=!1,this.isStartingFirstMessage=!1,alert("Failed to create conversation: "+(t.message||"Unknown error"))}})}onVoiceToggled(e){console.log("[VOICE] Recording in welcome view:",e)}onVoiceMessageReady(e){console.log("[MAIN-APP] Voice message ready from welcome view"),this.isSessionInitializing=!0,this.isStartingFirstMessage=!0,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created for voice message:",t.thread.id),this.firstMessageState.setPendingVoiceMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id])},error:t=>{console.error("[MAIN-APP] Failed to create thread for voice message:",t),this.isSessionInitializing=!1,this.isStartingFirstMessage=!1,alert("Failed to create conversation: "+(t.message||"Unknown error"))}})}isDrawerOpen=!1;onDrawerStateChange(e){this.isDrawerOpen=e}onChatFocusedOnMobile(){window.innerWidth<1024&&this.sidenav?.close()}onInputHeightChanged(e){console.log("[MAIN-APP] Input height changed:",e),this.inputSectionHeight=e}updateInputSectionHeight(){if(this.inputSection?.nativeElement){let e=this.inputSection.nativeElement.offsetHeight;e!==this.inputSectionHeight&&(console.log("[MAIN-APP] Input section height updated:",e),this.inputSectionHeight=e)}}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=P({type:i,selectors:[["app-main"]],viewQuery:function(t,n){if(t&1&&qe(fd,5)(ki,5),t&2){let o;xe(o=_e())&&(n.inputSection=o.first),xe(o=_e())&&(n.sidenav=o.first)}},decls:4,vars:2,consts:[["inputSection",""],[3,"drawerOpen"],[1,"app",3,"mousedown","touchstart"],[3,"projectName","threadId"],[3,"chatFocused","drawerStateChange","projectName","threadId"],[1,"welcome-section"],[1,"input-section"],[1,"input-center"],[1,"input-glass"],[3,"messageSubmitted","voiceMessageReady","voiceRecordingToggled","heightChanged","textareaFocused","isDisabled","isSessionInitializing","showWelcome","isThinking","isStarting"]],template:function(t,n){t&1&&(c(0,"app-sidenav",1)(1,"div",2),w("mousedown",function(){return n.onChatFocusedOnMobile()})("touchstart",function(){return n.onChatFocusedOnMobile()}),x(2,bd,1,2,"app-thread",3)(3,xd,7,5),d()()),t&2&&(k("drawerOpen",n.isDrawerOpen),p(2),_(n.threadId?2:3))},dependencies:[bt,ii,oi,ki],styles:["[_nghost-%COMP%]{display:flex;height:100vh;width:100%;overflow:hidden;justify-content:center}.app[_ngcontent-%COMP%]{width:100%;max-width:100%;min-width:0;height:100%;display:flex;flex-direction:column;background:var(--color-bg);color:var(--color-text);transition:all .3s ease;position:relative;justify-content:center;overflow:hidden}.chat-wrapper[_ngcontent-%COMP%]{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;background:transparent;width:100%;padding:2.5rem 0 1.5rem;display:flex;justify-content:center}.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem}@media(max-width:768px){.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{padding:0 1rem}}.welcome-section[_ngcontent-%COMP%]{flex-shrink:0;text-align:center;padding:2rem 1rem;animation:_ngcontent-%COMP%_fadeInUp .8s ease-out;display:flex;justify-content:center;align-items:center;width:100%;min-width:0;overflow:hidden}@keyframes _ngcontent-%COMP%_fadeInUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}.input-section[_ngcontent-%COMP%]{flex-shrink:0;position:relative;border-top:none;background:transparent;box-shadow:none;padding:2.5rem 0 2rem;overflow-y:visible;max-height:none;width:100%;z-index:10;pointer-events:none;display:flex;justify-content:center}.input-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem;display:flex;justify-content:center;align-items:end;position:relative;pointer-events:auto}@media(max-width:768px){.input-center[_ngcontent-%COMP%]{padding:0 1rem}}.input-glass[_ngcontent-%COMP%]{background:none;box-shadow:none;width:100%;min-height:64px;display:flex;align-items:stretch;gap:0;pointer-events:auto;position:relative;overflow:visible}.input-glass[_ngcontent-%COMP%] app-chat-textarea[_ngcontent-%COMP%]{width:100%;min-width:0;flex:1 1 auto;align-self:stretch;display:flex}body.dark[_nghost-%COMP%], body.dark [_nghost-%COMP%], [_ngcontent-%COMP%]:root[data-theme=dark] .input-glass[_ngcontent-%COMP%]{background:#24283073;border-color:#b4c8ff17;box-shadow:0 8px 32px #0000002b,0 1.5px 8px #00000012}.choice-overlay[_ngcontent-%COMP%]{z-index:10;width:100%;display:flex;justify-content:center;align-items:center}.upload-status[_ngcontent-%COMP%]{position:fixed;bottom:100px;left:50%;transform:translate(-50%);z-index:1000;display:flex;align-items:center;padding:12px 20px;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);border-radius:16px;font-size:.9em;color:var(--color-text);box-shadow:var(--glass-shadow);max-width:300px;text-align:center}.upload-status.error[_ngcontent-%COMP%]{background:#ff3b3026;color:var(--color-error);border-color:#ff3b304d}@media(max-width:768px){.welcome-section[_ngcontent-%COMP%]{padding:1.5rem 1rem}.input-section[_ngcontent-%COMP%]{padding:1.5rem .75rem 1rem}.input-center[_ngcontent-%COMP%]{padding:0 .5rem}}@media print{[_nghost-%COMP%]{display:block!important;height:auto!important;overflow:visible!important}.app[_ngcontent-%COMP%]{height:auto!important;overflow:visible!important;display:block!important}.input-section[_ngcontent-%COMP%], .welcome-section[_ngcontent-%COMP%]{display:none!important}}"],data:{animation:[Si("slideIn",[xn(":enter",[Ht({transform:"translateY(100%)",opacity:0}),bn("300ms ease-out",Ht({transform:"translateY(0)",opacity:1}))]),xn(":leave",[bn("200ms ease-in",Ht({transform:"translateY(100%)",opacity:0}))])])]}})};export{Aa as MainAppComponent};
|
|
90
|
+
`:"")+l}},{paragraphs:0,text:""}).text||e}renderStreamingText(){return N(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=P({type:i,selectors:[["app-chat-history"]],hostBindings:function(t,n){t&1&&w("scroll",function(){return n.onScroll()})},inputs:{messages:"messages",streamingText:"streamingText",isThinking:"isThinking",currentUsername:"currentUsername"},outputs:{copyRequested:"copyRequested",stopRequested:"stopRequested"},features:[Ie],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&&(c(0,"div",0),me(1,Rl,2,1,null,null,Pl),x(3,Fl,2,1,"div",1),x(4,Nl,1,0,"app-thinking-loader"),x(5,Ll,3,0,"button",2),d()),t&2&&(p(),ue(n.messages),p(2),_(n.streamingText?3:-1),p(),_(n.isThinking?4:-1),p(),_(n.showGoToBottom?5:-1))},dependencies:[_t,J,Vn,_n,$n],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 Hl=["buttonContainer"],zl=["freeTextInput"],$l=(i,e)=>e.value;function Vl(i,e){i&1&&(c(0,"mat-icon",10),f(1,"keyboard_return"),d())}function Ul(i,e){if(i&1){let t=E();c(0,"button",8),w("click",function(){let o=C(t).$implicit,r=m(2);return y(r.onOptionClick(o.value))}),c(1,"span",9),f(2),d(),x(3,Vl,2,0,"mat-icon",10),d()}if(i&2){let t=e.$implicit,n=e.$index,o=m(2);be("highlighted",n===o.highlightedIndex),k("disabled",t.disabled)("id","choice-option-"+n),We("aria-selected",n===o.highlightedIndex),p(2),D(t.label),p(),_(n===o.highlightedIndex?3:-1)}}function Bl(i,e){if(i&1){let t=E();c(0,"div",6)(1,"span",11),f(2,"Or type your own answer:"),d(),c(3,"div",12)(4,"input",13,1),mn("ngModelChange",function(o){C(t);let r=m(2);return pn(r.freeTextValue,o)||(r.freeTextValue=o),y(o)}),w("keydown",function(o){C(t);let r=m(2);return y(r.onFreeTextKeyDown(o))}),d(),c(6,"button",14),w("click",function(){C(t);let o=m(2);return y(o.onFreeTextSubmit())}),c(7,"mat-icon"),f(8,"send"),d()()()()}if(i&2){let t=m(2);p(4),dn("ngModel",t.freeTextValue),p(2),k("disabled",!t.freeTextValue.trim())}}function jl(i,e){if(i&1&&(c(0,"div",7)(1,"mat-icon"),f(2,"search"),d(),c(3,"span"),f(4),d()()),i&2){let t=m(2);p(4),D(t.searchText)}}function Wl(i,e){if(i&1){let t=E();c(0,"div",2),A(1,"div",3),Lt(2,"async"),c(3,"div",4,0),w("keydown",function(o){C(t);let r=m();return y(r.onKeyDown(o))}),me(5,Ul,4,7,"button",5,$l),d(),x(7,Bl,9,2,"div",6),x(8,jl,5,1,"div",7),d()}if(i&2){let t=m();p(),k("innerHTML",Uo(2,4,t.renderedLabel$),fe),p(2),We("aria-activedescendant","choice-option-"+t.highlightedIndex),p(2),ue(t.options),p(2),_(t.allowFreeText?7:-1),p(),_(t.searchText?8:-1)}}var Bn=class i{options=[];allowFreeText=!1;set labelHtml(e){typeof e=="object"?this.renderedLabelSubject.next(e):this.renderLabelMarkdown(e)}isVisible=!1;choiceSelected=new H;buttonContainer;freeTextInput;highlightedIndex=0;searchText="";freeTextValue="";searchTimeout;destroy$=new oe;renderedLabelSubject=new sn("");renderedLabel$=this.renderedLabelSubject.asObservable();sanitizer=u(Ae);markdownService=u(Le);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,a)=>({opt:r,idx:a})).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 N(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=P({type:i,selectors:[["app-choice-select"]],viewQuery:function(t,n){if(t&1&&qe(Hl,5)(zl,5),t&2){let o;xe(o=_e())&&(n.buttonContainer=o.first),xe(o=_e())&&(n.freeTextInput=o.first)}},inputs:{options:"options",allowFreeText:"allowFreeText",labelHtml:"labelHtml",isVisible:"isVisible"},outputs:{choiceSelected:"choiceSelected"},features:[Ie],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&&x(0,Wl,9,6,"div",2),t&2&&_(n.isVisible?0:-1)},dependencies:[he,J,Sn,yn,wn,Tn,Bo],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 ql(i,e){if(i&1){let t=E();c(0,"div",0)(1,"div",1)(2,"mat-icon"),f(3,"lock_open"),d()(),c(4,"div",2)(5,"p",3),f(6,"Authorization required"),d(),c(7,"p",4)(8,"strong"),f(9),d(),f(10," needs your permission to continue. "),d()(),c(11,"div",5)(12,"button",6),w("click",function(){let o=C(t),r=m();return y(r.onCancel(o))}),f(13,"Cancel"),d(),c(14,"button",7),w("click",function(){let o=C(t),r=m();return y(r.onAuthorize(o))}),c(15,"mat-icon"),f(16,"open_in_new"),d(),f(17," Authorize "),d()()()}i&2&&(p(9),D(e.integrationName))}var jn=class i{oauthService=u(On);pendingRequest=kn(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=P({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&&x(0,ql,18,1,"div",0),t&2){let o;_((o=n.pendingRequest())?0:-1,o)}},dependencies:[he,J],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 Wn=class i{http=u(Pe);projectState=u(De);threadState=u(Re);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 an(o=>{let r=new FileReader;r.onload=()=>{let l=r.result.split(",")[1];this.http.post(`/api/projects/${t}/threads/${n}/upload`,{content:l,mimeType:e.type||"application/octet-stream",filename:e.name}).subscribe({next:h=>{o.next({success:h.success,filename:h.filename}),o.complete()},error:h=>o.error(h)})},r.onerror=()=>o.error(new Error("Failed to read file")),r.readAsDataURL(e)})}listFiles(){return this.http.get(this.getBaseUrl()).pipe(Be(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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var yt=class i{fileApi=u(Wn);eventStream=u(En);filesSignal=je([]);isLoadingSignal=je(!1);currentProjectSignal=je(null);currentThreadSignal=je(null);files=un(()=>this.filesSignal());isLoading=un(()=>this.isLoadingSignal());fileCount=un(()=>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(q({},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 N(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 N(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(ge(e=>e instanceof Mn),nr()).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 a=e.timestamp.substring(o+1);a.length===5&&/^[a-z0-9]+$/.test(a)&&(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(h=>h.filename!==e.filename),o=t.find(h=>h.filename===e.filename),r=e.timestamp,a=e.timestamp.lastIndexOf("-");if(a>0){let h=e.timestamp.substring(a+1);h.length===5&&/^[a-z0-9]+$/.test(h)&&(r=e.timestamp.substring(0,a))}let l={filename:e.filename,size:e.size||o?.size||0,lastModified:new Date(r)};this.filesSignal.set([l,...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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};function Yl(i,e){if(i&1&&A(0,"div",1),i&2){let t=m();k("innerHTML",t.renderedContent,fe)}}function Gl(i,e){if(i&1&&A(0,"iframe",2),i&2){let t=m();k("srcdoc",t.content,fe)}}function Xl(i,e){if(i&1&&(c(0,"pre",3),f(1),d()),i&2){let t=m();p(),D(t.content)}}var qn=class i{content="";format="text";renderedContent="";sanitizer=u(Ae);markdownService=u(Le);ngOnChanges(e){(e.content||e.format)&&this.renderContent()}renderContent(){this.format==="markdown"?this.renderMarkdown():this.format==="json"&&this.formatJson()}renderMarkdown(){return N(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=P({type:i,selectors:[["app-content-renderer"]],inputs:{content:"content",format:"format"},features:[Ie],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&&(c(0,"div",0),x(1,Yl,1,1,"div",1)(2,Gl,1,1,"iframe",2)(3,Xl,2,1,"pre",3),d()),t&2&&(k("ngClass","format-"+n.format),p(),_(n.format==="markdown"?1:n.format==="html"?2:3))},dependencies:[ve,gn],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 wt=class i{http=u(Pe);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(Be(a=>{let l=a.body||"",h=new Blob([l]).size;return{content:l,format:r,filename:n,size:h}}),ln(a=>(console.error("[CONTENT_VIEWER] Error loading file:",n,a),So(()=>new Error(`Failed to load file: ${a.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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};function Ql(i,e){if(i&1){let t=E();c(0,"button",12),w("click",function(){C(t);let o=m();return y(o.download())}),c(1,"mat-icon"),f(2,"download"),d()()}}function Zl(i,e){i&1&&(c(0,"div",9),A(1,"mat-spinner",13),c(2,"p"),f(3,"Loading file content..."),d()())}function Kl(i,e){if(i&1){let t=E();c(0,"div",10)(1,"mat-icon",14),f(2,"error_outline"),d(),c(3,"p",15),f(4),d(),c(5,"button",16),w("click",function(){C(t);let o=m();return y(o.download())}),c(6,"mat-icon"),f(7,"download"),d(),f(8," Download instead "),d()()}if(i&2){let t=m();p(4),D(t.error)}}function Jl(i,e){if(i&1&&A(0,"app-content-renderer",11),i&2){let t=m();k("content",t.fileContent.content)("format",t.fileContent.format)}}var Yn=class i{destroy$=new oe;file;projectName;threadId;closeViewer=new H;contentService=u(wt);eventStream=u(En);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(ge(e=>e instanceof Mn),ge(e=>e.filename===this.file.filename),ge(e=>e.operation==="updated"),B(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=P({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&&(c(0,"div",0)(1,"div",1)(2,"div",2)(3,"span",3),f(4),d(),c(5,"span",4),f(6),d()(),c(7,"div",5),x(8,Ql,3,0,"button",6),c(9,"button",7),w("click",function(){return n.onClose()}),c(10,"mat-icon"),f(11,"chevron_right"),d()()()(),c(12,"div",8),x(13,Zl,4,0,"div",9),x(14,Kl,9,1,"div",10),x(15,Jl,1,2,"app-content-renderer",11),d()()),t&2&&(p(4),D(n.file.filename),p(2),D(n.formatSize(n.file.size)),p(2),_(n.fileContent&&!n.isLoading&&!n.error?8:-1),p(5),_(n.isLoading?13:-1),p(),_(n.error?14:-1),p(),_(n.fileContent&&!n.isLoading&&!n.error?15:-1))},dependencies:[ve,he,J,Ge,Jo,Ye,Cn,vn,qn],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 ec=Math.pow(10,8)*24*60*60*1e3,Mh=-ec,Gn=6048e5,Zr=864e5;var tc=3600;var Kr=tc*24,Eh=Kr*7,nc=Kr*365.2425,ic=nc/12,Oh=ic*3,Xi=Symbol.for("constructDateFrom");function X(i,e){return typeof i=="function"?i(e):i&&typeof i=="object"&&Xi in i?i[Xi](e):i instanceof Date?new i.constructor(e):new Date(e)}function U(i,e){return X(e||i,i)}function Jr(i,e,t){let n=U(i,t?.in);return isNaN(e)?X(t?.in||i,NaN):(e&&n.setDate(n.getDate()+e),n)}var oc={};function Xe(){return oc}function Ve(i,e){let t=Xe(),n=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,o=U(i,e?.in),r=o.getDay(),a=(r<n?7:0)+r-n;return o.setDate(o.getDate()-a),o.setHours(0,0,0,0),o}function ot(i,e){return Ve(i,Oe(q({},e),{weekStartsOn:1}))}function Xn(i,e){let t=U(i,e?.in),n=t.getFullYear(),o=X(t,0);o.setFullYear(n+1,0,4),o.setHours(0,0,0,0);let r=ot(o),a=X(t,0);a.setFullYear(n,0,4),a.setHours(0,0,0,0);let l=ot(a);return t.getTime()>=r.getTime()?n+1:t.getTime()>=l.getTime()?n:n-1}function Qi(i){let e=U(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 Tt(i,...e){let t=X.bind(null,i||e.find(n=>typeof n=="object"));return e.map(t)}function St(i,e){let t=U(i,e?.in);return t.setHours(0,0,0,0),t}function Qn(i,e,t){let[n,o]=Tt(t?.in,i,e),r=St(n),a=St(o),l=+r-Qi(r),h=+a-Qi(a);return Math.round((l-h)/Zr)}function ea(i,e){let t=Xn(i,e),n=X(e?.in||i,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),ot(n)}function ta(i){return X(i,Date.now())}function na(i,e,t){let[n,o]=Tt(t?.in,i,e);return+St(n)==+St(o)}function ia(i){return i instanceof Date||typeof i=="object"&&Object.prototype.toString.call(i)==="[object Date]"}function oa(i){return!(!ia(i)&&typeof i!="number"||isNaN(+U(i)))}function aa(i,e,t){let[n,o]=Tt(t?.in,i,e),r=ra(n,o),a=Math.abs(Qn(n,o));n.setDate(n.getDate()-r*a);let l=+(ra(n,o)===-r),h=r*(a-l);return h===0?0:h}function ra(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 sa(i,e){let t=U(i,e?.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}var rc={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"}},la=(i,e,t)=>{let n,o=rc[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 Zn(i){return(e={})=>{let t=e.width?String(e.width):i.defaultWidth;return i.formats[t]||i.formats[i.defaultWidth]}}var ac={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},sc={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},lc={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ca={date:Zn({formats:ac,defaultWidth:"full"}),time:Zn({formats:sc,defaultWidth:"full"}),dateTime:Zn({formats:lc,defaultWidth:"full"})};var cc={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},da=(i,e,t,n)=>cc[i];function kt(i){return(e,t)=>{let n=t?.context?String(t.context):"standalone",o;if(n==="formatting"&&i.formattingValues){let a=i.defaultFormattingWidth||i.defaultWidth,l=t?.width?String(t.width):a;o=i.formattingValues[l]||i.formattingValues[a]}else{let a=i.defaultWidth,l=t?.width?String(t.width):i.defaultWidth;o=i.values[l]||i.values[a]}let r=i.argumentCallback?i.argumentCallback(e):e;return o[r]}}var dc={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},pc={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},mc={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"]},uc={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"]},hc={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"}},gc={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"}},fc=(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"},pa={ordinalNumber:fc,era:kt({values:dc,defaultWidth:"wide"}),quarter:kt({values:pc,defaultWidth:"wide",argumentCallback:i=>i-1}),month:kt({values:mc,defaultWidth:"wide"}),day:kt({values:uc,defaultWidth:"wide"}),dayPeriod:kt({values:hc,defaultWidth:"wide",formattingValues:gc,defaultFormattingWidth:"wide"})};function Mt(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 a=r[0],l=n&&i.parsePatterns[n]||i.parsePatterns[i.defaultParseWidth],h=Array.isArray(l)?xc(l,M=>M.test(a)):bc(l,M=>M.test(a)),b;b=i.valueCallback?i.valueCallback(h):h,b=t.valueCallback?t.valueCallback(b):b;let S=e.slice(a.length);return{value:b,rest:S}}}function bc(i,e){for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&e(i[t]))return t}function xc(i,e){for(let t=0;t<i.length;t++)if(e(i[t]))return t}function ma(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 a=i.valueCallback?i.valueCallback(r[0]):r[0];a=t.valueCallback?t.valueCallback(a):a;let l=e.slice(o.length);return{value:a,rest:l}}}var _c=/^(\d+)(th|st|nd|rd)?/i,vc=/\d+/i,Cc={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},yc={any:[/^b/i,/^(a|c)/i]},wc={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Tc={any:[/1/i,/2/i,/3/i,/4/i]},Sc={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},kc={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]},Mc={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},Ec={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]},Oc={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},Ic={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}},ua={ordinalNumber:ma({matchPattern:_c,parsePattern:vc,valueCallback:i=>parseInt(i,10)}),era:Mt({matchPatterns:Cc,defaultMatchWidth:"wide",parsePatterns:yc,defaultParseWidth:"any"}),quarter:Mt({matchPatterns:wc,defaultMatchWidth:"wide",parsePatterns:Tc,defaultParseWidth:"any",valueCallback:i=>i+1}),month:Mt({matchPatterns:Sc,defaultMatchWidth:"wide",parsePatterns:kc,defaultParseWidth:"any"}),day:Mt({matchPatterns:Mc,defaultMatchWidth:"wide",parsePatterns:Ec,defaultParseWidth:"any"}),dayPeriod:Mt({matchPatterns:Oc,defaultMatchWidth:"any",parsePatterns:Ic,defaultParseWidth:"any"})};var Zi={code:"en-US",formatDistance:la,formatLong:ca,formatRelative:da,localize:pa,match:ua,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ha(i,e){let t=U(i,e?.in);return Qn(t,sa(t))+1}function ga(i,e){let t=U(i,e?.in),n=+ot(t)-+ea(t);return Math.round(n/Gn)+1}function Kn(i,e){let t=U(i,e?.in),n=t.getFullYear(),o=Xe(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,a=X(e?.in||i,0);a.setFullYear(n+1,0,r),a.setHours(0,0,0,0);let l=Ve(a,e),h=X(e?.in||i,0);h.setFullYear(n,0,r),h.setHours(0,0,0,0);let b=Ve(h,e);return+t>=+l?n+1:+t>=+b?n:n-1}function fa(i,e){let t=Xe(),n=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,o=Kn(i,e),r=X(e?.in||i,0);return r.setFullYear(o,0,n),r.setHours(0,0,0,0),Ve(r,e)}function ba(i,e){let t=U(i,e?.in),n=+Ve(t,e)-+fa(t,e);return Math.round(n/Gn)+1}function F(i,e){let t=i<0?"-":"",n=Math.abs(i).toString().padStart(e,"0");return t+n}var Ue={y(i,e){let t=i.getFullYear(),n=t>0?t:1-t;return F(e==="yy"?n%100:n,e.length)},M(i,e){let t=i.getMonth();return e==="M"?String(t+1):F(t+1,2)},d(i,e){return F(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 F(i.getHours()%12||12,e.length)},H(i,e){return F(i.getHours(),e.length)},m(i,e){return F(i.getMinutes(),e.length)},s(i,e){return F(i.getSeconds(),e.length)},S(i,e){let t=e.length,n=i.getMilliseconds(),o=Math.trunc(n*Math.pow(10,t-3));return F(o,e.length)}};var Et={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Ki={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 Ue.y(i,e)},Y:function(i,e,t,n){let o=Kn(i,n),r=o>0?o:1-o;if(e==="YY"){let a=r%100;return F(a,2)}return e==="Yo"?t.ordinalNumber(r,{unit:"year"}):F(r,e.length)},R:function(i,e){let t=Xn(i);return F(t,e.length)},u:function(i,e){let t=i.getFullYear();return F(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 F(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 F(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 Ue.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 F(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=ba(i,n);return e==="wo"?t.ordinalNumber(o,{unit:"week"}):F(o,e.length)},I:function(i,e,t){let n=ga(i);return e==="Io"?t.ordinalNumber(n,{unit:"week"}):F(n,e.length)},d:function(i,e,t){return e==="do"?t.ordinalNumber(i.getDate(),{unit:"date"}):Ue.d(i,e)},D:function(i,e,t){let n=ha(i);return e==="Do"?t.ordinalNumber(n,{unit:"dayOfYear"}):F(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 F(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 F(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 F(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=Et.noon:n===0?o=Et.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=Et.evening:n>=12?o=Et.afternoon:n>=4?o=Et.morning:o=Et.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 Ue.h(i,e)},H:function(i,e,t){return e==="Ho"?t.ordinalNumber(i.getHours(),{unit:"hour"}):Ue.H(i,e)},K:function(i,e,t){let n=i.getHours()%12;return e==="Ko"?t.ordinalNumber(n,{unit:"hour"}):F(n,e.length)},k:function(i,e,t){let n=i.getHours();return n===0&&(n=24),e==="ko"?t.ordinalNumber(n,{unit:"hour"}):F(n,e.length)},m:function(i,e,t){return e==="mo"?t.ordinalNumber(i.getMinutes(),{unit:"minute"}):Ue.m(i,e)},s:function(i,e,t){return e==="so"?t.ordinalNumber(i.getSeconds(),{unit:"second"}):Ue.s(i,e)},S:function(i,e){return Ue.S(i,e)},X:function(i,e,t){let n=i.getTimezoneOffset();if(n===0)return"Z";switch(e){case"X":return _a(n);case"XXXX":case"XX":return rt(n);default:return rt(n,":")}},x:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"x":return _a(n);case"xxxx":case"xx":return rt(n);default:return rt(n,":")}},O:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+xa(n,":");default:return"GMT"+rt(n,":")}},z:function(i,e,t){let n=i.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+xa(n,":");default:return"GMT"+rt(n,":")}},t:function(i,e,t){let n=Math.trunc(+i/1e3);return F(n,e.length)},T:function(i,e,t){return F(+i,e.length)}};function xa(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+F(r,2)}function _a(i,e){return i%60===0?(i>0?"-":"+")+F(Math.abs(i)/60,2):rt(i,e)}function rt(i,e=""){let t=i>0?"-":"+",n=Math.abs(i),o=F(Math.trunc(n/60),2),r=F(n%60,2);return t+o+e+r}var va=(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"})}},Ca=(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"})}},Pc=(i,e)=>{let t=i.match(/(P+)(p+)?/)||[],n=t[1],o=t[2];if(!o)return va(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}}",va(n,e)).replace("{{time}}",Ca(o,e))},ya={p:Ca,P:Pc};var Ac=/^D+$/,Dc=/^Y+$/,Rc=["D","DD","YY","YYYY"];function wa(i){return Ac.test(i)}function Ta(i){return Dc.test(i)}function Sa(i,e,t){let n=Fc(i,e,t);if(console.warn(n),Rc.includes(i))throw new RangeError(n)}function Fc(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 Nc=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Lc=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Hc=/^'([^]*?)'?$/,zc=/''/g,$c=/[a-zA-Z]/;function Ji(i,e,t){let n=Xe(),o=t?.locale??n.locale??Zi,r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,a=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,l=U(i,t?.in);if(!oa(l))throw new RangeError("Invalid time value");let h=e.match(Lc).map(S=>{let M=S[0];if(M==="p"||M==="P"){let I=ya[M];return I(S,o.formatLong)}return S}).join("").match(Nc).map(S=>{if(S==="''")return{isToken:!1,value:"'"};let M=S[0];if(M==="'")return{isToken:!1,value:Vc(S)};if(Ki[M])return{isToken:!0,value:S};if(M.match($c))throw new RangeError("Format string contains an unescaped latin alphabet character `"+M+"`");return{isToken:!1,value:S}});o.localize.preprocessor&&(h=o.localize.preprocessor(l,h));let b={firstWeekContainsDate:r,weekStartsOn:a,locale:o};return h.map(S=>{if(!S.isToken)return S.value;let M=S.value;(!t?.useAdditionalWeekYearTokens&&Ta(M)||!t?.useAdditionalDayOfYearTokens&&wa(M))&&Sa(M,e,String(i));let I=Ki[M[0]];return I(l,M,o.localize,b)}).join("")}function Vc(i){let e=i.match(Hc);return e?e[1].replace(zc,"'"):i}function ka(i,e,t){return Jr(i,-e,t)}function Ma(i,e){return na(X(e?.in||i,i),ka(ta(e?.in||i),1))}function Ea(i){if(!i||isNaN(i.getTime()))return"unknown";let e=new Date,t=Ji(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(Ma(i))return`yesterday ${t}`;let a=aa(e,i);return a<7?`${a}d ago ${t}`:`${Ji(i,"dd/MM/yyyy")} ${t}`}var Uc=(i,e)=>e.filename;function Bc(i,e){if(i&1){let t=E();c(0,"button",11),w("click",function(){C(t);let o=m(2);return y(o.downloadAll())}),c(1,"mat-icon"),f(2,"download_for_offline"),d()()}}function jc(i,e){i&1&&(c(0,"div",10),A(1,"span",12),c(2,"span",13),f(3,"Loading files..."),d()())}function Wc(i,e){i&1&&(c(0,"div",14)(1,"mat-icon",15),f(2,"folder_open"),d(),c(3,"p",16),f(4,"No files in exchange space"),d(),c(5,"p",17),f(6,"Upload files to share with the agent"),d()())}function qc(i,e){if(i&1){let t=E();c(0,"button",28),w("click",function(){C(t);let o=m().$implicit,r=m(4);return y(r.viewFile(o))}),c(1,"mat-icon"),f(2,"visibility"),d()()}}function Yc(i,e){if(i&1){let t=E();c(0,"div",18)(1,"div",19)(2,"mat-icon",20),f(3),d(),c(4,"div",21)(5,"span",22),f(6),d(),c(7,"span",23),f(8),d()()(),c(9,"div",24),x(10,qc,3,0,"button",25),c(11,"button",26),w("click",function(){let o=C(t).$implicit,r=m(4);return y(r.download(o))}),c(12,"mat-icon"),f(13,"download"),d()(),c(14,"button",27),w("click",function(){let o=C(t).$implicit,r=m(4);return y(r.delete(o))}),c(15,"mat-icon"),f(16,"delete"),d()()()()}if(i&2){let t=e.$implicit,n=m(4);p(3),D(n.getFileIcon(t.filename)),p(2),k("title",t.filename),p(),D(t.filename),p(2),cn("",n.formatSize(t.size)," \u2022 ",n.formatDate(t.lastModified)),p(2),_(n.canViewFile(t)?10:-1)}}function Gc(i,e){if(i&1&&me(0,Yc,17,6,"div",18,Uc),i&2){let t=m(3);ue(t.files())}}function Xc(i,e){if(i&1&&x(0,Wc,7,0,"div",14)(1,Gc,2,0),i&2){let t=m(2);_(t.files().length===0?0:1)}}function Qc(i,e){if(i&1){let t=E();c(0,"div",0)(1,"div",2)(2,"div",3)(3,"h3",4),f(4,"Exchange"),d(),c(5,"span",5),f(6),d()(),c(7,"div",6),x(8,Bc,3,0,"button",7),c(9,"button",8),w("click",function(){C(t);let o=m();return y(o.close())}),c(10,"mat-icon"),f(11,"chevron_right"),d()()()(),c(12,"div",9),x(13,jc,4,0,"div",10)(14,Xc,2,1),d()()}if(i&2){let t=m();p(6),ht("(",t.files().length,")"),p(2),_(t.files().length>0?8:-1),p(5),_(t.isLoading()?13:14)}}function Zc(i,e){if(i&1){let t=E();c(0,"app-content-viewer",29),w("closeViewer",function(){C(t);let o=m();return y(o.backToList())}),d()}if(i&2){let t=m();k("file",t.currentFile)("projectName",t.projectName)("threadId",t.threadId)}}var Jn=class i{projectName;threadId;closeDrawer=new H;fileExchangeState=u(yt);contentViewerService=u(wt);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 N(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 Ea(e)}canViewFile(e){return this.contentViewerService.isFormatViewable(e.filename)&&this.contentViewerService.isViewable(e.size)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=P({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&&(x(0,Qc,15,3,"div",0),x(1,Zc,1,3,"app-content-viewer",1)),t&2&&(_(n.viewerState==="list"?0:-1),p(),_(n.viewerState==="content"&&n.currentFile?1:-1))},dependencies:[ve,he,J,Ge,Ye,Yn],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 ei=class i{http=u(Pe);listUsers(){return this.http.get("/api/users")}static \u0275fac=function(t){return new(t||i)};static \u0275prov=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var ti=class i{excludedUserIds=[];placeholder="Search username";disabled=!1;userSelected=new H;userApi=u(ei);search(e){let t=e.toLowerCase();return this.userApi.listUsers().pipe(Be(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=P({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&&(c(0,"ds-autocomplete-input",0),w("itemSelected",function(r){return n.onItemSelected(r)}),d()),t&2&&k("dataSource",n)("placeholder",n.placeholder)("disabled",n.disabled)},dependencies:[xr],styles:["[_nghost-%COMP%]{display:block}"]})};var Kc=(i,e)=>e.userId;function Jc(i,e){if(i&1&&(c(0,"div",7),f(1),d()),i&2){let t=m();p(),D(t.errorMessage())}}function ed(i,e){if(i&1){let t=E();c(0,"button",13),w("click",function(){C(t);let o=m().$implicit,r=m();return y(r.removeUser(o.userId))}),c(1,"mat-icon"),f(2,"close"),d()()}}function td(i,e){if(i&1&&(c(0,"div",9)(1,"mat-icon",10),f(2,"person"),d(),c(3,"span",11),f(4),d(),x(5,ed,3,0,"button",12),d()),i&2){let t=e.$implicit,n=m();p(4),D(t.userId),p(),_(n.users.length>1?5:-1)}}var Xt=class i{threadId;users=[];currentUsername;userAdded=new H;userRemoved=new H;closed=new H;isAdding=je(!1);errorMessage=je("");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=P({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&&(c(0,"div",0)(1,"div",1)(2,"div",2)(3,"mat-icon"),f(4,"group"),d(),c(5,"span"),f(6,"Share"),d()(),c(7,"button",3),w("click",function(){return n.close()}),c(8,"mat-icon"),f(9,"chevron_right"),d()()(),c(10,"div",4)(11,"span"),f(12,"Participants"),d()(),c(13,"div",5)(14,"app-user-autocomplete",6),w("userSelected",function(r){return n.onUserSelected(r)}),d()(),x(15,Jc,2,1,"div",7),c(16,"div",8),me(17,td,6,2,"div",9,Kc),d()()),t&2&&(p(14),k("excludedUserIds",n.excludedUserIds)("disabled",n.isAdding()),p(),_(n.errorMessage()?15:-1),p(2),ue(n.users))},dependencies:[he,J,Ge,Ye,tr,ti],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 Oa="mat-badge-content",nd=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275cmp=P({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)}
|
|
91
|
+
`],encapsulation:2,changeDetection:0})}return i})(),Ia=(()=>{class i{_ngZone=u(Io);_elementRef=u(ut);_ariaDescriber=u(Qo);_renderer=u(Do);_animationsDisabled=Ko();_idGenerator=u(Xo);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=u(Yo);_document=u(Oo);constructor(){let t=u(Wo);t.load(nd),t.load(qo)}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(Oa),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 > .${Oa}`);for(let n of Array.from(t))n!==this._badgeElement&&n.remove()}static \u0275fac=function(n){return new(n||i)};static \u0275dir=Fo({type:i,selectors:[["","matBadge",""]],hostAttrs:[1,"mat-badge"],hostVars:20,hostBindings:function(n,o){n&2&&be("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",hn],disabled:[2,"matBadgeDisabled","disabled",hn],position:[0,"matBadgePosition","position"],content:[0,"matBadge","content"],description:[0,"matBadgeDescription","description"],size:[0,"matBadgeSize","size"],hidden:[2,"matBadgeHidden","hidden",hn]}})}return i})(),Pa=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=Ro({type:i});static \u0275inj=Eo({imports:[Go,Zo]})}return i})();var Ot=class i{ATTENTION_EMOJI="\u{1F534}";isSystemActive=!1;systemActiveTimer=null;SYSTEM_ACTIVE_TIMEOUT=4e3;unreadService=u(Ct);project=u(De);constructor(){this.initializeTitleUpdates()}initializeTitleUpdates(){ko([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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var ni=class i{http=u(Pe);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 N(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 a=r.split(",")[1];if(!a){n(new Error("Invalid file format"));return}t(a)},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),Ci({success:!1,error:o instanceof Error?o.message:"Validation failed"})}return new an(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(Be(a=>(console.log("[IMAGE-UPLOAD] Upload success result:",a),{success:!0,processedSize:a.processedSize,dimensions:a.dimensions})),ln(a=>{console.log("[IMAGE-UPLOAD] Upload failed:",a);let l=a.error?.error||a.message||"Upload failed";return Ci({success:!1,error:l})})).subscribe({next:a=>{o.next(a),o.complete()},error:a=>o.error(a)})}).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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var It=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=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var od=["inputSection"],rd=()=>[];function ad(i,e){if(i&1){let t=E();c(0,"button",20),w("click",function(){C(t);let o=m();return y(o.toggleFileDrawer())}),c(1,"mat-icon"),f(2,"folder_open"),d()()}if(i&2){let t=m();be("has-files",t.fileCount>0),k("title",Ho("Files Exchange",t.fileCount>0?" ("+t.fileCount+" file"+(t.fileCount>1?"s":"")+")":""))("matBadge",t.fileCount>0?t.fileCount:null)}}function sd(i,e){if(i&1){let t=E();c(0,"button",21),w("click",function(){C(t);let o=m();return y(o.toggleSharePanel())}),c(1,"mat-icon"),f(2,"group"),d()()}if(i&2){let t=m();be("has-shared-users",((t.threadDetails==null||t.threadDetails.users==null?null:t.threadDetails.users.length)??0)>1)}}function ld(i,e){if(i&1&&(c(0,"div",6),f(1),d()),i&2){let t=m();p(),cn(" \u26A0\uFE0F Connection lost. Reconnecting... (",t.connectionStatus.reconnectAttempts,"/",t.connectionStatus.maxAttempts,") ")}}function cd(i,e){if(i&1&&(c(0,"div",22),f(1),d()),i&2){let t=m();be("error",t.uploadStatus.isError),p(),ht(" ",t.uploadStatus.message," ")}}function dd(i,e){if(i&1){let t=E();c(0,"app-chat-textarea",23),w("messageSubmitted",function(o){C(t);let r=m();return y(r.onMessageSubmitted(o))})("voiceRecordingToggled",function(o){C(t);let r=m();return y(r.onVoiceToggled(o))})("heightChanged",function(o){C(t);let r=m();return y(r.onInputHeightChanged(o))})("stopRequested",function(){C(t);let o=m();return y(o.onStopRequested())})("filesPasted",function(o){C(t);let r=m();return y(r.onFilesPasted(o))}),d()}if(i&2){let t=m();k("isDisabled",!t.isConnected)("isSessionInitializing",!1)("showWelcome",!1)("isThinking",t.isThinking)("isStarting",!1)}}function pd(i,e){if(i&1){let t=E();c(0,"app-choice-select",24),w("choiceSelected",function(o){C(t);let r=m();return y(r.onChoiceSelected(o))}),d()}if(i&2){let t=m();k("options",t.currentChoice.options)("labelHtml",t.currentChoice.label)("isVisible",!!t.currentChoice)("allowFreeText",t.currentChoice.allowFreeText)}}function md(i,e){i&1&&A(0,"app-oauth-request-panel")}function ud(i,e){if(i&1){let t=E();c(0,"app-file-exchange-drawer",25),w("closeDrawer",function(){C(t);let o=m();return y(o.closeDrawer())}),d()}if(i&2){let t=m();k("projectName",t.projectName)("threadId",t.threadId)}}function hd(i,e){if(i&1){let t=E();c(0,"app-thread-share",26),w("userAdded",function(o){C(t);let r=m();return y(r.onUserAdded(o))})("userRemoved",function(o){C(t);let r=m();return y(r.onUserRemoved(o))})("closed",function(){C(t);let o=m();return y(o.closeDrawer())}),d()}if(i&2){let t=m();k("threadId",t.threadId)("users",t.threadDetails.users||$o(3,rd))("currentUsername",t.currentUsername)}}function gd(i,e){i&1&&(c(0,"div",19)(1,"div",27)(2,"div",28),f(3,"\u{1F4CE}"),d(),c(4,"div",29),f(5,"Drop files here to upload"),d(),c(6,"div",30),f(7,"Images will be added to conversation, other files to exchange space"),d()()())}var ii=class i{projectName;threadId;chatFocused=new H;drawerStateChange=new H;destroy$=new oe;connectionDestroy$=new oe;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=u(ye);oauthService=u(On);pendingOAuthRequest=kn(this.oauthService.pendingRequest$,{initialValue:null});preferencesService=u(Ce);titleService=u(Ot);elementRef=u(ut);threadState=u(Re);threadApiService=u(gt);userService=u(er);router=u(fn);imageUploadService=u(ni);fileExchangeState=u(yt);firstMessageState=u(It);audioApiService=u(ft);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(B(this.destroy$)).subscribe(e=>{this.authEnabled=e}),this.userService.username$.pipe(B(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(B(this.connectionDestroy$)).subscribe(n=>{console.log("[THREAD] Messages updated:",n.length),this.messages=n}),this.codayService.streamingText$.pipe(B(this.connectionDestroy$)).subscribe(n=>{this.streamingText=n}),this.codayService.isThinking$.pipe(B(this.connectionDestroy$)).subscribe(n=>{this.isThinking=n}),this.codayService.currentChoice$.pipe(B(this.connectionDestroy$)).subscribe(n=>{this.currentChoice=n}),this.codayService.connectionStatus$.pipe(B(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(B(this.connectionDestroy$)).subscribe(n=>{n&&(console.log("[THREAD] Thread update event received:",n),this.threadState.refreshThreadList())}),this.threadState.selectedThread$.pipe(B(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(B(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(ge(n=>!!n),Mo(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(B(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(B(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 N(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=P({type:i,selectors:[["app-thread"]],viewQuery:function(t,n){if(t&1&&qe(od,5)(Xt,5),t&2){let o;xe(o=_e())&&(n.inputSection=o.first),xe(o=_e())&&(n.threadShareRef=o.first)}},inputs:{projectName:"projectName",threadId:"threadId"},outputs:{chatFocused:"chatFocused",drawerStateChange:"drawerStateChange"},features:[Ie],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&&(c(0,"div",1),w("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)}),c(1,"mat-drawer-container",2)(2,"mat-drawer-content")(3,"div",3),x(4,ad,3,5,"button",4),x(5,sd,3,2,"button",5),x(6,ld,2,2,"div",6),c(7,"div",7),w("mousedown",function(){return n.chatFocused.emit()})("touchstart",function(){return n.chatFocused.emit()}),c(8,"div",8)(9,"app-chat-history",9),w("copyRequested",function(r){return n.onCopyMessage(r)})("stopRequested",function(){return n.onStopRequested()}),d(),x(10,cd,2,3,"div",10),d()(),c(11,"div",11,0)(13,"div",12)(14,"div",13),x(15,dd,1,5,"app-chat-textarea",14),x(16,pd,1,4,"app-choice-select",15),x(17,md,1,0,"app-oauth-request-panel"),d()()()()(),c(18,"mat-drawer",16),w("closed",function(){return n.closeDrawer()}),x(19,ud,1,2,"app-file-exchange-drawer",17),x(20,hd,1,4,"app-thread-share",18),d()(),x(21,gd,8,0,"div",19),d()),t&2&&(p(),k("hasBackdrop",!1),p(3),_(n.drawerMode!=="files"?4:-1),p(),_(n.authEnabled&&n.drawerMode!=="share"?5:-1),p(),_(n.showConnectionStatus&&n.connectionStatus&&!n.connectionStatus.connected?6:-1),p(3),k("messages",n.messages)("streamingText",n.streamingText)("isThinking",n.isThinking)("currentUsername",n.currentUsername),p(),_(n.uploadStatus.message?10:-1),p(5),_(!n.currentChoice&&!n.pendingOAuthRequest()?15:-1),p(),_(n.currentChoice?16:-1),p(),_(n.pendingOAuthRequest()?17:-1),p(),k("opened",n.isDrawerOpen),p(),_(n.drawerMode==="files"?19:-1),p(),_(n.drawerMode==="share"&&n.threadDetails?20:-1),p(),_(n.isDragOver?21:-1))},dependencies:[Un,bt,Bn,jn,Jn,Xt,fr,hr,gr,ur,he,J,Ge,_n,Pa,Ia],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}}"]})};var oi=class i{welcomeMessages=["Welcome to Coday","Bienvenue sur Coday","Bienvenido a Coday","Willkommen bei Coday","Benvenuto su Coday","Bem-vindo ao Coday","Welkom bij Coday","\u0414\u043E\u0431\u0440\u043E \u043F\u043E\u0436\u0430\u043B\u043E\u0432\u0430\u0442\u044C \u0432 Coday","Coday \u3078\u3088\u3046\u3053\u305D","\u6B22\u8FCE\u6765\u5230 Coday","Coday \uC5D0 \uC624\uC2E0 \uAC83\uC744 \uD658\uC601\uD569\uB2C8\uB2E4","\u0645\u0631\u062D\u0628\u064B\u0627 \u0628\u0643 \u0641\u064A Coday"];currentWelcomeIndex=0;currentWelcomeMessage=this.welcomeMessages[0];welcomeRotationInterval;ngOnInit(){this.startWelcomeRotation()}ngOnDestroy(){this.stopWelcomeRotation()}startWelcomeRotation(){this.welcomeRotationInterval=window.setInterval(()=>{this.currentWelcomeIndex=(this.currentWelcomeIndex+1)%this.welcomeMessages.length,this.currentWelcomeMessage=this.welcomeMessages[this.currentWelcomeIndex]},3e3)}stopWelcomeRotation(){this.welcomeRotationInterval&&(clearInterval(this.welcomeRotationInterval),this.welcomeRotationInterval=void 0)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=P({type:i,selectors:[["app-welcome-message"]],decls:2,vars:1,consts:[[1,"welcome-title"]],template:function(t,n){t&1&&(Ft(0,"h1",0),f(1),Nt()),t&2&&(p(),D(n.currentWelcomeMessage))},styles:[".welcome-title[_ngcontent-%COMP%]{font-size:clamp(1.5rem,4vw,4rem);font-weight:700;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% auto;background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;animation:_ngcontent-%COMP%_gradientShift 3s ease-in-out infinite;margin:0;padding:0;line-height:1.2;transition:opacity .5s ease-in-out;display:block;min-height:1.2em;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@keyframes _ngcontent-%COMP%_gradientShift{0%{background-position:0% center}50%{background-position:100% center}to{background-position:0% center}}"]})};var ri=class i{destroy$=new oe;isSetup=!1;codayService=u(ye);preferencesService=u(Ce);setup(){if(this.isSetup){console.warn("[AGENT-NOTIFICATION] Service already set up");return}console.log("[AGENT-NOTIFICATION] Setting up agent notification service"),this.codayService.isThinking$.pipe(B(this.destroy$),yi(),ge(([e,t])=>e===!0&&t===!1)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Agent stopped thinking, notifying task finished"),this.notifyTaskFinishedIfEnabled()}),this.preferencesService.browserNotificationEnabled$.pipe(B(this.destroy$),yi(),ge(([e,t])=>e===!1&&t===!0)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Browser notifications enabled, checking permission"),this.handleBrowserNotificationEnabled()}),this.isSetup=!0}notifyTaskFinishedIfEnabled(){this.preferencesService.getAgentNotificationEnabled()&&(this.preferencesService.getNotificationSoundEnabled()&&this.playCompletionSound(),this.preferencesService.getBrowserNotificationEnabled()&&this.sendBrowserNotification())}playCompletionSound(){try{let e=new(window.AudioContext||window.webkitAudioContext),t=e.createOscillator(),n=e.createGain();t.connect(n),n.connect(e.destination),t.frequency.setValueAtTime(700,e.currentTime),n.gain.setValueAtTime(.1,e.currentTime),n.gain.exponentialRampToValueAtTime(.01,e.currentTime+.08),t.start(e.currentTime),t.stop(e.currentTime+.08);let o=e.createOscillator(),r=e.createGain();o.connect(r),r.connect(e.destination);let a=e.currentTime+.11;o.frequency.setValueAtTime(950,a),r.gain.setValueAtTime(.1,a),r.gain.exponentialRampToValueAtTime(.01,a+.09),o.start(a),o.stop(a+.09),console.log("[AGENT-NOTIFICATION] Completion sound played")}catch(e){console.error("[AGENT-NOTIFICATION] Failed to play completion sound:",e)}}handleBrowserNotificationEnabled(){return N(this,null,function*(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications"),this.preferencesService.setBrowserNotificationEnabled(!1);return}if(Notification.permission==="denied"){console.warn("[AGENT-NOTIFICATION] Permission denied, disabling browser notifications"),this.preferencesService.setBrowserNotificationEnabled(!1);return}if(Notification.permission==="granted"){console.log("[AGENT-NOTIFICATION] Permission already granted, showing confirmation"),this.createConfirmationNotification();return}try{(yield Notification.requestPermission())==="granted"?(console.log("[AGENT-NOTIFICATION] Permission granted, showing confirmation"),this.createConfirmationNotification()):(console.log("[AGENT-NOTIFICATION] Permission denied or dismissed"),this.preferencesService.setBrowserNotificationEnabled(!1))}catch(e){console.error("[AGENT-NOTIFICATION] Error requesting permission:",e),this.preferencesService.setBrowserNotificationEnabled(!1)}})}sendBrowserNotification(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications");return}if(document.hasFocus()){console.warn("[AGENT-NOTIFICATION] Document is focused, skipping browser notification");return}Notification.permission==="granted"?this.createTaskCompleteNotification():console.warn("[AGENT-NOTIFICATION] Permission not granted, cannot send notification")}createConfirmationNotification(){let e=new Notification("Coday - Notifications Enabled",{body:"You will be notified when the agent completes tasks",icon:"/favicon.ico",tag:"coday-notifications-enabled",requireInteraction:!1});setTimeout(()=>e.close(),4e3),e.onclick=()=>{window.focus(),e.close()},console.log("[AGENT-NOTIFICATION] Confirmation notification sent")}createTaskCompleteNotification(){let e=new Notification("Coday - Task Complete",{body:"The agent has finished and is waiting for your input",icon:"/favicon.ico",tag:"coday-task-complete",requireInteraction:!1});setTimeout(()=>e.close(),5e3),e.onclick=()=>{window.focus(),e.close()},console.log("[AGENT-NOTIFICATION] Task complete notification sent")}ngOnDestroy(){console.log("[AGENT-NOTIFICATION] Service destroyed"),this.destroy$.next(),this.destroy$.complete()}static \u0275fac=function(t){return new(t||i)};static \u0275prov=j({token:i,factory:i.\u0275fac,providedIn:"root"})};var fd=["inputSection"];function bd(i,e){if(i&1){let t=E();c(0,"app-thread",4),w("chatFocused",function(){C(t);let o=m();return y(o.onChatFocusedOnMobile())})("drawerStateChange",function(o){C(t);let r=m();return y(r.onDrawerStateChange(o))}),d()}if(i&2){let t=m();k("projectName",t.projectName)("threadId",t.threadId)}}function xd(i,e){if(i&1){let t=E();c(0,"div",5),A(1,"app-welcome-message"),d(),c(2,"div",6,0)(4,"div",7)(5,"div",8)(6,"app-chat-textarea",9),w("messageSubmitted",function(o){C(t);let r=m();return y(r.onMessageSubmitted(o))})("voiceMessageReady",function(o){C(t);let r=m();return y(r.onVoiceMessageReady(o))})("voiceRecordingToggled",function(o){C(t);let r=m();return y(r.onVoiceToggled(o))})("heightChanged",function(o){C(t);let r=m();return y(r.onInputHeightChanged(o))})("textareaFocused",function(){C(t);let o=m();return y(o.onChatFocusedOnMobile())}),d()()()()}if(i&2){let t=m();p(6),k("isDisabled",t.isSessionInitializing)("isSessionInitializing",t.isSessionInitializing)("showWelcome",!0)("isThinking",!1)("isStarting",t.isStartingFirstMessage)}}var Aa=class i{destroy$=new oe;inputSection;sidenav;projectName="";threadId=null;isSessionInitializing=!1;isStartingFirstMessage=!1;inputSectionHeight=80;codayService=u(ye);titleService=u(Ot);preferencesService=u(Ce);route=u(jo);router=u(fn);threadApiService=u(gt);agentNotificationService=u(ri);firstMessageState=u(It);constructor(){console.log("[MAIN-APP] Using new thread-based architecture (no clientId needed)")}ngOnInit(){this.agentNotificationService.setup(),this.setupPrintHandlers(),this.route.params.pipe(B(this.destroy$)).subscribe(e=>{let t=e.projectName,n=e.threadId||null;console.log("[MAIN-APP] Route params updated:",{project:t,thread:n,previousProject:this.projectName,previousThread:this.threadId}),this.projectName=t,this.threadId=n,this.threadId?console.log("[MAIN-APP] Thread selected - ThreadComponent will display"):(console.log("[MAIN-APP] No thread selected - showing welcome view"),this.initializeWelcomeView())})}initializeWelcomeView(){this.codayService.setTabTitleService(this.titleService)}ngAfterViewInit(){setTimeout(()=>this.updateInputSectionHeight(),100)}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),window.removeEventListener("beforeprint",this.handleBeforePrint),window.removeEventListener("afterprint",this.handleAfterPrint)}onMessageSubmitted(e){console.log("[MAIN-APP] First message submitted from welcome view:",e),this.isSessionInitializing=!0,this.isStartingFirstMessage=!0,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created:",t.thread.id),this.firstMessageState.setPendingFirstMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id])},error:t=>{console.error("[MAIN-APP] Failed to create thread:",t),this.isSessionInitializing=!1,this.isStartingFirstMessage=!1,alert("Failed to create conversation: "+(t.message||"Unknown error"))}})}onVoiceToggled(e){console.log("[VOICE] Recording in welcome view:",e)}onVoiceMessageReady(e){console.log("[MAIN-APP] Voice message ready from welcome view"),this.isSessionInitializing=!0,this.isStartingFirstMessage=!0,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created for voice message:",t.thread.id),this.firstMessageState.setPendingVoiceMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id])},error:t=>{console.error("[MAIN-APP] Failed to create thread for voice message:",t),this.isSessionInitializing=!1,this.isStartingFirstMessage=!1,alert("Failed to create conversation: "+(t.message||"Unknown error"))}})}isDrawerOpen=!1;onDrawerStateChange(e){this.isDrawerOpen=e}onChatFocusedOnMobile(){window.innerWidth<1024&&this.sidenav?.close()}onInputHeightChanged(e){console.log("[MAIN-APP] Input height changed:",e),this.inputSectionHeight=e}updateInputSectionHeight(){if(this.inputSection?.nativeElement){let e=this.inputSection.nativeElement.offsetHeight;e!==this.inputSectionHeight&&(console.log("[MAIN-APP] Input section height updated:",e),this.inputSectionHeight=e)}}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=P({type:i,selectors:[["app-main"]],viewQuery:function(t,n){if(t&1&&qe(fd,5)(ki,5),t&2){let o;xe(o=_e())&&(n.inputSection=o.first),xe(o=_e())&&(n.sidenav=o.first)}},decls:4,vars:2,consts:[["inputSection",""],[3,"drawerOpen"],[1,"app",3,"mousedown","touchstart"],[3,"projectName","threadId"],[3,"chatFocused","drawerStateChange","projectName","threadId"],[1,"welcome-section"],[1,"input-section"],[1,"input-center"],[1,"input-glass"],[3,"messageSubmitted","voiceMessageReady","voiceRecordingToggled","heightChanged","textareaFocused","isDisabled","isSessionInitializing","showWelcome","isThinking","isStarting"]],template:function(t,n){t&1&&(c(0,"app-sidenav",1)(1,"div",2),w("mousedown",function(){return n.onChatFocusedOnMobile()})("touchstart",function(){return n.onChatFocusedOnMobile()}),x(2,bd,1,2,"app-thread",3)(3,xd,7,5),d()()),t&2&&(k("drawerOpen",n.isDrawerOpen),p(2),_(n.threadId?2:3))},dependencies:[bt,ii,oi,ki],styles:["[_nghost-%COMP%]{display:flex;height:100vh;width:100%;overflow:hidden;justify-content:center}.app[_ngcontent-%COMP%]{width:100%;max-width:100%;min-width:0;height:100%;display:flex;flex-direction:column;background:var(--color-bg);color:var(--color-text);transition:all .3s ease;position:relative;justify-content:center;overflow:hidden}.chat-wrapper[_ngcontent-%COMP%]{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;background:transparent;width:100%;padding:2.5rem 0 1.5rem;display:flex;justify-content:center}.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem}@media(max-width:768px){.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{padding:0 1rem}}.welcome-section[_ngcontent-%COMP%]{flex-shrink:0;text-align:center;padding:2rem 1rem;animation:_ngcontent-%COMP%_fadeInUp .8s ease-out;display:flex;justify-content:center;align-items:center;width:100%;min-width:0;overflow:hidden}@keyframes _ngcontent-%COMP%_fadeInUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}.input-section[_ngcontent-%COMP%]{flex-shrink:0;position:relative;border-top:none;background:transparent;box-shadow:none;padding:2.5rem 0 2rem;overflow-y:visible;max-height:none;width:100%;z-index:10;pointer-events:none;display:flex;justify-content:center}.input-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem;display:flex;justify-content:center;align-items:end;position:relative;pointer-events:auto}@media(max-width:768px){.input-center[_ngcontent-%COMP%]{padding:0 1rem}}.input-glass[_ngcontent-%COMP%]{background:none;box-shadow:none;width:100%;min-height:64px;display:flex;align-items:stretch;gap:0;pointer-events:auto;position:relative;overflow:visible}.input-glass[_ngcontent-%COMP%] app-chat-textarea[_ngcontent-%COMP%]{width:100%;min-width:0;flex:1 1 auto;align-self:stretch;display:flex}body.dark[_nghost-%COMP%], body.dark [_nghost-%COMP%], [_ngcontent-%COMP%]:root[data-theme=dark] .input-glass[_ngcontent-%COMP%]{background:#24283073;border-color:#b4c8ff17;box-shadow:0 8px 32px #0000002b,0 1.5px 8px #00000012}.choice-overlay[_ngcontent-%COMP%]{z-index:10;width:100%;display:flex;justify-content:center;align-items:center}.upload-status[_ngcontent-%COMP%]{position:fixed;bottom:100px;left:50%;transform:translate(-50%);z-index:1000;display:flex;align-items:center;padding:12px 20px;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);border-radius:16px;font-size:.9em;color:var(--color-text);box-shadow:var(--glass-shadow);max-width:300px;text-align:center}.upload-status.error[_ngcontent-%COMP%]{background:#ff3b3026;color:var(--color-error);border-color:#ff3b304d}@media(max-width:768px){.welcome-section[_ngcontent-%COMP%]{padding:1.5rem 1rem}.input-section[_ngcontent-%COMP%]{padding:1.5rem .75rem 1rem}.input-center[_ngcontent-%COMP%]{padding:0 .5rem}}@media print{[_nghost-%COMP%]{display:block!important;height:auto!important;overflow:visible!important}.app[_ngcontent-%COMP%]{height:auto!important;overflow:visible!important;display:block!important}.input-section[_ngcontent-%COMP%], .welcome-section[_ngcontent-%COMP%]{display:none!important}}"],data:{animation:[Si("slideIn",[xn(":enter",[Ht({transform:"translateY(100%)",opacity:0}),bn("300ms ease-out",Ht({transform:"translateY(0)",opacity:1}))]),xn(":leave",[bn("200ms ease-in",Ht({transform:"translateY(100%)",opacity:0}))])])]}})};export{Aa as MainAppComponent};
|