@whoz-oss/coday-client 1.3.2 → 1.3.4
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-BXQCdGUa.js → chunk-3QjpTDpt.js} +1 -1
- package/browser/{chunk-ZTE9Vro-.js → chunk-7IEj5tud.js} +1 -1
- package/browser/{chunk-nSxfGVc8.js → chunk-8RFsf09R.js} +1 -1
- package/browser/{chunk-CRuFXEnP.js → chunk-9rFJllaP.js} +1 -1
- package/browser/{chunk-CeRWUb5g.js → chunk-B3mPWOwM.js} +1 -1
- package/browser/{chunk-SiAnBXor.js → chunk-BDqV-dXo.js} +1 -1
- package/browser/chunk-BGM4NjUk.js +1 -0
- package/browser/{chunk-TBsNfd0k.js → chunk-BMBD8g8i.js} +1 -1
- package/browser/chunk-BYAMVo7F.js +1 -0
- package/browser/{chunk-DeVzkEKK.js → chunk-BbOdBhQy.js} +1 -1
- package/browser/{chunk-E8b2_4uB.js → chunk-Bc_JiT75.js} +1 -1
- package/browser/{chunk-DlFFzFSe.js → chunk-BfoCTjUr.js} +1 -1
- package/browser/{chunk-BdWvjltK.js → chunk-BhKcjruH.js} +1 -1
- package/browser/{chunk-CNMTF87H.js → chunk-Bj9y8qST.js} +1 -1
- package/browser/{chunk-DGa4-UJW.js → chunk-Brj8HlXc.js} +1 -1
- package/browser/{chunk-Ckk6G7IP.js → chunk-BxT6IsjS.js} +1 -1
- package/browser/{chunk-eTAQJYle.js → chunk-By4bK8Lp.js} +1 -1
- package/browser/chunk-C8qVsVH8.js +1 -0
- package/browser/{chunk-CaxOrx5M.js → chunk-CFw8eyQX.js} +1 -1
- package/browser/{chunk-x7Suyrio.js → chunk-CH0b9ss9.js} +1 -1
- package/browser/{chunk-BovznIFZ.js → chunk-CInfUnUL.js} +1 -1
- package/browser/{chunk-DEhf9VBD.js → chunk-CJpYYZh2.js} +1 -1
- package/browser/{chunk-CcTN_TUb.js → chunk-CTjZECqR.js} +1 -1
- package/browser/{chunk-C7-Gy0Uz.js → chunk-CTx3Z0hA.js} +1 -1
- package/browser/{chunk-CZ6ILxDX.js → chunk-CVuNrNOH.js} +1 -1
- package/browser/{chunk-BpA60NxS.js → chunk-CXVQ4M5H.js} +1 -1
- package/browser/{chunk-CW742eC7.js → chunk-Cb82rqle.js} +4 -4
- package/browser/chunk-CbSC-SSJ.js +1 -0
- package/browser/chunk-CeTVH-vp.js +2 -0
- package/browser/{chunk-BmjhXCgH.js → chunk-Cek4dv2K.js} +1 -1
- package/browser/{chunk-BGeY6TJl.js → chunk-CekA5yLC.js} +1 -1
- package/browser/{chunk-D0tFEYpV.js → chunk-CisLHTrk.js} +1 -1
- package/browser/chunk-Cm35aeo6.js +1 -0
- package/browser/{chunk-Bi1D1MPS.js → chunk-Cm42_zF7.js} +1 -1
- package/browser/{chunk-G4MCwSm-.js → chunk-CpMYZ9dG.js} +1 -1
- package/browser/{chunk-DwB1vH9w.js → chunk-CrExrE4n.js} +1 -1
- package/browser/{chunk-Bh_9bCDZ.js → chunk-CsvLyu6R.js} +1 -1
- package/browser/{chunk-BjDDtMsE.js → chunk-Cy-MbcIf.js} +1 -1
- package/browser/{chunk-BWc0GaFw.js → chunk-CywonzJi.js} +1 -1
- package/browser/{chunk-BemBoNs5.js → chunk-D1ggthOI.js} +1 -1
- package/browser/{chunk-BBJc_ez4.js → chunk-DFaRJnOg.js} +1 -1
- package/browser/{chunk-n_Kgbuh3.js → chunk-DJz2cMcV.js} +1 -1
- package/browser/{chunk-BPJe1_uM.js → chunk-DLhvPTZP.js} +1 -1
- package/browser/{chunk-20v-HoGw.js → chunk-DVSN51SP.js} +1 -1
- package/browser/{chunk-B4CKPT8-.js → chunk-DWrJdp3G.js} +1 -1
- package/browser/{chunk-RbE7PtJh.js → chunk-DXVBbChn.js} +1 -1
- package/browser/{chunk-Cdu5JsaS.js → chunk-DgFkTqkZ.js} +1 -1
- package/browser/chunk-DoS8-ZTX.js +1 -0
- package/browser/{chunk-C_7QzTv7.js → chunk-DpRS0jIN.js} +1 -1
- package/browser/{chunk-CyEZHdnA.js → chunk-DvV6rFWO.js} +1 -1
- package/browser/{chunk-_PndMs0h.js → chunk-Lluy_pM_.js} +1 -1
- package/browser/{chunk-DUczAw5C.js → chunk-NPBU5yIa.js} +1 -1
- package/browser/{chunk-CteHmI07.js → chunk-OpV-oEpT.js} +1 -1
- package/browser/{chunk-DJOhzAbC.js → chunk-S_TYzsa6.js} +1 -1
- package/browser/{chunk-BptxX0h6.js → chunk-X4zIHpcE.js} +1 -1
- package/browser/{chunk-BQ2Vio1f.js → chunk-_Wj2M8II.js} +1 -1
- package/browser/{chunk-BtYN6RGw.js → chunk-_kolzKbl.js} +1 -1
- package/browser/chunk-_si25xRH.js +1 -0
- package/browser/{chunk-DzuMSf1O.js → chunk-eCkjwC-y.js} +1 -1
- package/browser/{chunk-Bh7gCjj4.js → chunk-eqpKdy80.js} +1 -1
- package/browser/{chunk-B4iDNUj6.js → chunk-hL6iczXD.js} +1 -1
- package/browser/{chunk-BXiOP6ZW.js → chunk-hcl2JPuw.js} +1 -1
- package/browser/{chunk-CiWRvj1N.js → chunk-i62b6Gtt.js} +1 -1
- package/browser/{chunk-C2TRQfu4.js → chunk-vkYtcaIT.js} +1 -1
- package/browser/{chunk-B9gLRfDm.js → chunk-xk_bqNV0.js} +1 -1
- package/browser/{chunk-D5NtIZG6.js → chunk-zyGtaVKQ.js} +1 -1
- package/browser/index.html +1 -1
- package/browser/{main-DXWHG4XK.js → main-FEA3BAHM.js} +2 -2
- package/package.json +1 -1
- package/browser/chunk-BIEjPnD4.js +0 -2
- package/browser/chunk-BUhtdVBd.js +0 -1
- package/browser/chunk-Balbg-lh.js +0 -1
- package/browser/chunk-CFvRU8Pw.js +0 -1
- package/browser/chunk-CmmK8635.js +0 -1
- package/browser/chunk-DvC7mEoN.js +0 -1
- package/browser/chunk-SlWicxh3.js +0 -1
- package/browser/chunk-spTKcuel.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {n as ne}from'./chunk-
|
|
1
|
+
import {n as ne}from'./chunk-_kolzKbl.js';import {g,Z as z$1,_ as Ue,A as Aw,$ as zt,a0 as jt,a1 as Vt,a2 as Nt,i as hr,p as pr,v as vs,W as WC,k as fl,n as eC,l as Ag,X as XE,y as Hg,a5 as yl,a8 as Zg,t as tC,r as Tg,a9 as dC,ai as Jg,aa as If,ac as mC,aj as KC,ab as wf,a3 as HI,ak as Xg,a6 as $I}from'./main-FEA3BAHM.js';import {y as yt,w as wt,t as ti,Z as Zn,c as cn}from'./chunk-DFaRJnOg.js';function G(c,p){if(c&1){let t=dC();vs(0,"mat-checkbox",5),Jg("ngModelChange",function(l){If(t);let f=mC();return KC(f.checkboxChecked,l)||(f.checkboxChecked=l),wf(l)}),WC(1),fl(),HI();}if(c&2){let t=mC();Xg("ngModel",t.checkboxChecked),$I(),XE(),Zg(t.data.checkboxLabel);}}var z=class c{dialogRef=g(z$1);data=g(Ue);checkboxChecked=false;confirm(){this.dialogRef.close({confirmed:true,checkboxChecked:this.checkboxChecked});}cancel(){this.dialogRef.close({confirmed:false});}static \u0275fac=function(t){return new(t||c)};static \u0275cmp=Aw({type:c,selectors:[["app-confirm-dialog"]],decls:13,vars:8,consts:[["mat-dialog-title",""],[3,"ngModel"],["align","end"],["mat-button","",3,"click"],["mat-flat-button","",3,"click","color"],[3,"ngModelChange","ngModel"]],template:function(t,e){t&1&&(vs(0,"h2",0)(1,"mat-icon"),WC(2,"warning"),fl(),WC(3),fl(),vs(4,"mat-dialog-content")(5,"p"),WC(6),fl(),eC(7,G,2,2,"mat-checkbox",1),fl(),vs(8,"mat-dialog-actions",2)(9,"button",3),Ag("click",function(){return e.cancel()}),WC(10),fl(),vs(11,"button",4),Ag("click",function(){return e.confirm()}),WC(12),fl()()),t&2&&(XE(),Hg("destructive",!!e.data.isDestructive),XE(2),yl(" ",e.data.title,`
|
|
2
2
|
`),XE(3),Zg(e.data.message),XE(),tC(e.data.checkboxLabel?7:-1),XE(3),Zg(e.data.cancelLabel??"Cancel"),XE(),Tg("color",e.data.isDestructive?"warn":"primary"),XE(),yl(" ",e.data.confirmLabel??"Confirm"," "));},dependencies:[zt,jt,Vt,Nt,hr,pr,yt,wt,ne,ti,Zn,cn],styles:["h2[mat-dialog-title][_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}h2[mat-dialog-title][_ngcontent-%COMP%] mat-icon.destructive[_ngcontent-%COMP%]{color:var(--color-error, #f44336)}mat-dialog-content[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{color:var(--color-text-secondary);line-height:1.5}mat-dialog-content[_ngcontent-%COMP%] mat-checkbox[_ngcontent-%COMP%]{display:block;margin-top:8px;font-size:.875rem}"]})};export{z};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {f}from'./chunk-E8b2_4uB.js';import {G as Ge,$,K as Ke,E as Et,y as yt$2}from'./chunk-BXiOP6ZW.js';import {U as Ue$1,x as x$1,i as is}from'./chunk-_PndMs0h.js';import {al as yt,an as ce,g,ay as O,F,L,az as Qt,U,N,h as he,G,ap as Vy,ae as Ot,aA as sn,av as dt$1,A as Aw,i as hr$1,aB as fr$1,aC as Cu,v as vs,l as Ag,n as eC,k as fl,X as XE,r as Tg,t as tC,D as Fg,I as IC,E as wC,P as P$1,aD as Ly,Y as x,a9 as dC,ai as Jg,aa as If,aj as KC,ab as wf,a3 as HI,y as Hg,ak as Xg,a6 as $I,B as dE,J as dy,S as ha,aE as A,u as ue,a7 as ga,aF as me$1,H as Hi$1,m as mT,z as z$1,a as P$2,aG as z,b as U$1,aH as TS,q as oC,x as iC,aI as Tr$1,aJ as Nb,am as Gm,j as Gn$1,W as WC,aK as Do$1,aL as qn$1,aM as Nn$1,aN as wt$1,aO as G$1,aP as $a,aQ as As,aR as K,aS as Ut,aT as Ue,aU as U$2,aV as w,aW as D,aX as ft$1,aY as ks,aZ as YT,ac as mC,a_ as XC,a$ as Yg,a5 as yl,o as bg,ah as rT,b0 as An,b1 as Ob,b2 as bb,b3 as oT,b4 as nT,aw as pl,b5 as Sg,ax as hl,a8 as Zg,c as ce$1,b6 as u,b7 as B,b8 as T$1,b9 as v,ba as m,bb as R,bc as h,bd as A$1,be as aT,bf as uT,C as Cg,bg as Hy,p as pr$1,bh as lT,bi as aE,bj as yh}from'./main-DXWHG4XK.js';import {s}from'./chunk-x7Suyrio.js';import {d}from'./chunk-BjDDtMsE.js';import {S as Se$1,P as Pn}from'./chunk-RbE7PtJh.js';import {u as ui$1,m as mt$1,p as pt$1,Z,V as Ve}from'./chunk-Ckk6G7IP.js';import {y as yt$1,w as wt,t as ti$1,Y as Ye,Z as Zn$1,c as cn}from'./chunk-BBJc_ez4.js';var et=class i{sanitizer=g(TS);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=An({name:"highlight",type:i,pure:true})};var fe=class i{http=g(dy);projectState=g(P$1);threadState=g(U);transcribeAudio(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow();return this.http.post(`/api/projects/${o}/transcribe`,P$2({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`,P$2({audio:e,mimeType:t},n?{language:n}:{}))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var _i=["messageInput"],xi=["fileInput"],yi=(i,e)=>e.name;function wi(i,e){i&1&&(vs(0,"div",3),bg(1,"span",8),WC(2," Recording... Click mic to stop "),fl());}function Ti(i,e){i&1&&(vs(0,"div",3),bg(1,"span",9),WC(2," Transcribing... "),fl());}function Si(i,e){if(i&1&&(vs(0,"span",14),WC(1),fl()),i&2){let t=mC().$implicit,n=mC(2);XE(),Zg(" "+(n.getParameterFormat(t)||""));}}function Mi(i,e){if(i&1){let t=dC();vs(0,"div",11),Ag("click",function(){let o=If(t).$index,r=mC(2);return wf(r.selectAutocompleteItemByClick(o))})("keydown.enter",function(){let o=If(t).$index,r=mC(2);return wf(r.selectAutocompleteItemByClick(o))})("keydown.space",function(){let o=If(t).$index,r=mC(2);return wf(r.selectAutocompleteItemByClick(o))})("mouseenter",function(){let o=If(t).$index,r=mC(2);return wf(r.selectedAutocompleteIndex=o)}),vs(1,"div",12),bg(2,"span",13),aT(3,"highlight"),eC(4,Si,2,1,"span",14),fl(),bg(5,"div",15),aT(6,"highlight"),fl();}if(i&2){let t=e.$implicit,n=e.$index,o=mC(2);Hg("selected",n===o.selectedAutocompleteIndex),Cg("aria-selected",n===o.selectedAutocompleteIndex),XE(2),Tg("innerHTML",lT(3,6,o.autocompleteTrigger+t.name,o.getAutocompleteQuery()),aE),XE(2),tC(o.hasParameterFormat(t)?4:-1),XE(),Tg("innerHTML",lT(6,9,t.description,o.getAutocompleteQuery()),aE);}}function Ei(i,e){if(i&1&&(vs(0,"div",4),oC(1,Mi,7,12,"div",10,yi),fl()),i&2){let t=mC();XE(),iC(t.autocompleteItems);}}function Oi(i,e){if(i&1){let t=dC();vs(0,"ds-icon-button",18),Ag("action",function(){If(t);let o=mC(2);return wf(o.onStopClick())}),fl();}}function Pi(i,e){if(i&1){let t=dC();vs(0,"ds-icon-button",19),Ag("action",function(){If(t);let o=mC(2);return wf(o.sendMessage())}),fl();}if(i&2){let t=mC(2);Hg("hidden",t.isDisabled||!t.message.trim())("active",!!t.message.trim()&&!t.isDisabled),Tg("title",t.getSendButtonTooltip())("disabled",t.isDisabled||!t.message.trim());}}function ki(i,e){if(i&1){let t=dC();vs(0,"ds-icon-button",21),Ag("action",function(){If(t);let o=mC(3);return wf(o.triggerFileUpload())}),fl(),vs(1,"input",22,1),Ag("change",function(o){If(t);let r=mC(3);return wf(r.onFileInputChange(o))}),fl();}if(i&2){let t=mC(3);Tg("disabled",t.isDisabled);}}function Ii(i,e){if(i&1){let t=dC();eC(0,ki,3,1),vs(1,"ds-icon-button",20),Ag("action",function(){If(t);let o=mC(2);return wf(o.toggleRecording())}),fl();}if(i&2){let t=mC(2);tC(!t.showWelcome&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?0:-1),XE(),Hg("hidden",t.message.trim()&&!t.isRecording&&!t.isTranscribing),Tg("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 Di(i,e){if(i&1&&(vs(0,"div",7),eC(1,Oi,1,0,"ds-icon-button",16),eC(2,Pi,1,6,"ds-icon-button",17),eC(3,Ii,2,6),fl()),i&2){let t=mC();XE(),tC(t.isThinking?1:-1),XE(),tC((!t.isThinking||t.message.trim())&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?2:-1),XE(),tC(t.isThinking?-1:3);}}var tt=class i{isDisabled=false;showWelcome=false;isThinking=false;isStarting=false;isSessionInitializing=false;isStopping=false;filesPasted=new yt;messageSubmitted=new yt;voiceMessageReady=new yt;voiceRecordingToggled=new yt;heightChanged=new yt;stopRequested=new yt;textareaFocused=new yt;messageInput;fileInput;message="";isRecording=false;isTranscribing=false;isFocused=false;recognition=null;mediaRecorder=null;audioChunks=[];voiceInputMode="browser";get isVoiceMessageMode(){return this.voiceInputMode==="voice-message"}sessionHadTranscript=false;pendingLineBreaksTimeout=null;lastProcessedResultIndex=0;useEnterToSend=false;currentInvite="";subscriptions=[];thinkingPhrases=["Processing request...","Thinking...","Working on it..."];currentThinkingPhrase="Processing request...";thinkingPhraseIndex=0;thinkingInterval=null;autocompleteVisible=false;autocompleteTrigger=null;autocompleteItems=[];selectedAutocompleteIndex=0;preferencesService=g(L);codayService=g(Ge);agentApiService=g(f);promptApiService=g(d);projectStateService=g(P$1);audioApiService=g(fe);threadStateService=g(U);ngOnInit(){this.initializeVoiceInput(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.subscriptions.push(this.preferencesService.voiceLanguage$.subscribe(()=>this.updateRecognitionLanguage())),this.subscriptions.push(this.preferencesService.voiceInputMode$.subscribe(e=>{this.voiceInputMode=e;})),this.subscriptions.push(this.preferencesService.enterToSend$.subscribe(e=>{this.useEnterToSend=e;})),this.subscribeToInviteEvents(),this.subscribeToMessageRestore();}ngAfterViewInit(){this.adjustTextareaHeight(),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),200);});}ngOnChanges(e){e.isThinking&&(e.isThinking.currentValue?this.startThinkingAnimation():(this.stopThinkingAnimation(),this.isStopping=false,e.isThinking.previousValue&&(console.log("[CHAT-TEXTAREA] Thinking ended, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100);})))),e.isSessionInitializing&&!e.isSessionInitializing.currentValue&&e.isSessionInitializing.previousValue&&(console.log("[CHAT-TEXTAREA] Session initialization completed, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100);})),e.isStarting&&!e.isStarting.currentValue&&e.isStarting.previousValue&&this.isThinking&&(this.thinkingPhraseIndex===0?(console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index 0 - restarting animation"),this.stopThinkingAnimation(),this.startThinkingAnimation()):console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index",this.thinkingPhraseIndex,"- continuing without restart"));}ngOnDestroy(){this.subscriptions.forEach(e=>e.unsubscribe()),this.subscriptions=[],this.clearPendingLineBreaks(),this.stopThinkingAnimation();}onKeyDown(e){if(this.autocompleteVisible)switch(e.key){case "ArrowDown":e.preventDefault(),this.selectedAutocompleteIndex=Math.min(this.selectedAutocompleteIndex+1,this.autocompleteItems.length-1),this.scrollSelectedItemIntoView();return;case "ArrowUp":e.preventDefault(),this.selectedAutocompleteIndex=Math.max(this.selectedAutocompleteIndex-1,0),this.scrollSelectedItemIntoView();return;case "Tab":case "Enter":if(!this.message.includes(" ")){e.preventDefault(),this.selectAutocompleteItem();return}break;case "Escape":e.preventDefault(),this.hideAutocomplete();return}e.key==="Enter"&&(this.useEnterToSend?!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),this.sendMessage(true)):(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey)&&!e.shiftKey&&(e.preventDefault(),this.sendMessage(true)));}onInput(){this.adjustTextareaHeight(),this.checkForAutocomplete();}onPaste(e){let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(r=>r.kind==="file");if(!n.length)return;e.preventDefault();let o=n.reduce((r,d)=>{let v=d.getAsFile();return v?[...r,v]:r},[]);o.length&&this.filesPasted.emit(o);}triggerFileUpload(){console.log("[CHAT-TEXTAREA] Triggering file upload"),this.fileInput?.nativeElement?.click();}onFileInputChange(e){let t=e.target,n=t.files;if(!n||n.length===0){console.log("[CHAT-TEXTAREA] No files selected");return}console.log("[CHAT-TEXTAREA] Files selected:",n.length);let o=Array.from(n);this.filesPasted.emit(o),t.value="";}onDocumentClick(e){if(!this.autocompleteVisible)return;let t=e.target,n=document.querySelector(".autocomplete-popup"),o=this.messageInput?.nativeElement;n&&!n.contains(t)&&o&&!o.contains(t)&&this.hideAutocomplete();}sendMessage(e=false){let t=this.message.trim();!this.isDisabled&&(e||t)&&(this.isRecording&&this.recognition&&(this.clearPendingLineBreaks(),this.recognition.stop()),this.messageSubmitted.emit(t),this.message="",setTimeout(()=>this.adjustTextareaHeight(),0));}onStopClick(){this.isStopping=true,this.stopRequested.emit();}toggleRecording(){this.isRecording?this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.stopWhisperRecording():this.stopRecording():this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.startWhisperRecording():this.startRecording();}startWhisperRecording(){return dt$1(this,null,function*(){if(!this.isRecording)try{let e=yield navigator.mediaDevices.getUserMedia({audio:!0});this.audioChunks=[],this.mediaRecorder=new MediaRecorder(e),this.mediaRecorder.ondataavailable=t=>{t.data.size>0&&this.audioChunks.push(t.data);},this.mediaRecorder.onstop=()=>{e.getTracks().forEach(t=>t.stop()),this.processWhisperAudio();},this.mediaRecorder.onerror=t=>{console.error("[WHISPER] MediaRecorder error:",t),e.getTracks().forEach(n=>n.stop()),this.isRecording=!1,this.voiceRecordingToggled.emit(!1);},this.mediaRecorder.start(),this.isRecording=!0,this.voiceRecordingToggled.emit(!0),console.log("[WHISPER] Started recording");}catch(e){console.error("[WHISPER] Failed to start recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(false);}})}stopWhisperRecording(){if(!(!this.mediaRecorder||!this.isRecording))try{this.mediaRecorder.stop(),this.isRecording=!1,this.voiceRecordingToggled.emit(!1),console.log("[WHISPER] Stopped recording");}catch(e){console.error("[WHISPER] Failed to stop recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(false);}}processWhisperAudio(){if(this.audioChunks.length===0)return;let e=new Blob(this.audioChunks,{type:this.mediaRecorder?.mimeType||"audio/webm"}),t=e.type.split(";")[0]||"audio/webm";this.audioChunks=[],this.isTranscribing=true;let n=new FileReader;n.onloadend=()=>{let o=n.result.split(",")[1];if(!o){console.error("[WHISPER] Failed to read audio as base64"),this.isTranscribing=false;return}let d=this.preferencesService.getVoiceLanguage().split("-")[0];if(this.voiceInputMode==="voice-message"){if(!this.threadStateService.getSelectedThreadId()){console.log("[WHISPER] No thread selected \u2014 emitting voiceMessageReady for thread creation"),this.isTranscribing=false,this.voiceMessageReady.emit({base64:o,mimeType:t,language:d});return}this.audioApiService.sendVoiceMessage(o,t,d).subscribe({next:v=>{this.isTranscribing=false,console.log("[WHISPER] Voice message sent, transcription:",v.transcription?.substring(0,50));},error:v=>{console.error("[WHISPER] Voice message error:",v),this.isTranscribing=false,this.fallbackToTranscription(o,t,d);}});}else this.audioApiService.transcribeAudio(o,t,d).subscribe({next:v=>{this.isTranscribing=false,v.text&&this.appendToTextarea(v.text+" ");},error:v=>{console.error("[WHISPER] Transcription error:",v),this.isTranscribing=false;}});},n.readAsDataURL(e);}fallbackToTranscription(e,t,n){this.audioApiService.transcribeAudio(e,t,n).subscribe({next:o=>{this.isTranscribing=false,o.text&&this.appendToTextarea(o.text+" ");},error:o=>{console.error("[WHISPER] Fallback transcription also failed:",o),this.isTranscribing=false;}});}initializeVoiceInput(){let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(console.log("[SPEECH] speechRecognition",e),!e){console.warn("[SPEECH] Speech Recognition API not available");return}this.recognition=new e,this.recognition.continuous=true,this.recognition.interimResults=true,this.recognition.maxAlternatives=1,this.recognition.lang=this.getSelectedLanguage();try{"grammars"in this.recognition&&(this.recognition.serviceURI=void 0);}catch(t){console.log("[SPEECH] Advanced speech recognition parameters not supported");}this.recognition.onresult=t=>{let n="",o=Math.max(t.resultIndex,this.lastProcessedResultIndex);for(let r=o;r<t.results.length;r++)t.results[r].isFinal&&(n+=t.results[r][0].transcript,this.lastProcessedResultIndex=r+1);if(n){let r=this.improveTranscriptPunctuation(n.trim());this.sessionHadTranscript=true,console.log("[SPEECH] onresult ending, appending to textarea",this.isRecording),this.appendToTextarea(r);}},this.recognition.onend=()=>{console.log("[SPEECH] Recognition ended. Was recording:",this.isRecording),this.isRecording=false,this.lastProcessedResultIndex=0,this.voiceRecordingToggled.emit(this.isRecording);},this.recognition.onerror=t=>{console.error("[SPEECH] Speech recognition error:",t.error),console.log("[SPEECH] Error details:",{error:t.error,message:t.message,timeStamp:t.timeStamp}),this.isRecording=false,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording);},this.recognition.onstart=()=>{console.log("[SPEECH] Recognition started successfully");},this.recognition.onspeechstart=()=>{console.log("[SPEECH] Speech detected");},this.recognition.onspeechend=()=>{console.log("[SPEECH] Speech ended");};}startRecording(){return dt$1(this,null,function*(){if(!(!this.recognition||this.isRecording))try{this.isRecording=!0,this.sessionHadTranscript=!1,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording),this.recognition.start(),console.log("[SPEECH] Started recording");}catch(e){console.error("[SPEECH] Failed to start recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(this.isRecording);}})}stopRecording(){if(!this.recognition||!this.isRecording){console.log("[SPEECH] stopRecording not recording");return}try{console.log("[SPEECH] stopRecording recognition stop"),this.recognition.stop(),this.schedulePendingLineBreaks();}catch(e){console.error("[SPEECH] Failed to stop recording:",e);}}getSelectedLanguage(){return this.preferencesService.getVoiceLanguage()}updateRecognitionLanguage(){if(this.recognition){let e=this.getSelectedLanguage();this.recognition.lang=e,console.log("[SPEECH] Language changed to:",e);}}improveTranscriptPunctuation(e){let t=e;return /[.!?]$/.test(t.trim())||(t=t.trim()+"."),t=t.charAt(0).toUpperCase()+t.slice(1),t=t.replace(/\s+/g," "),t=t+" ",t}appendToTextarea(e){let t=this.message;if(this.message=t?`${t}${e}`:e,this.messageInput?.nativeElement){this.messageInput.nativeElement.focus();let n=this.message.length;this.messageInput.nativeElement.setSelectionRange(n,n);}setTimeout(()=>this.adjustTextareaHeight(),0);}schedulePendingLineBreaks(){this.clearPendingLineBreaks(),this.pendingLineBreaksTimeout=window.setTimeout(()=>{this.sessionHadTranscript&&(console.log("[SPEECH] Adding line breaks after transcript session"),this.appendToTextarea(`
|
|
1
|
+
import {f}from'./chunk-Bc_JiT75.js';import {G as Ge,$,K as Ke,E as Et,y as yt$2}from'./chunk-hcl2JPuw.js';import {U as Ue$1,x as x$1,i as is}from'./chunk-Lluy_pM_.js';import {al as yt,an as ce,g,ay as O,F,L,az as Qt,U,N,h as he,G,ap as Vy,ae as Ot,aA as sn,av as dt$1,A as Aw,i as hr$1,aB as fr$1,aC as Cu,v as vs,l as Ag,n as eC,k as fl,X as XE,r as Tg,t as tC,D as Fg,I as IC,E as wC,P as P$1,aD as Ly,Y as x,a9 as dC,ai as Jg,aa as If,aj as KC,ab as wf,a3 as HI,y as Hg,ak as Xg,a6 as $I,B as dE,J as dy,S as ha,aE as A,u as ue,a7 as ga,aF as me$1,H as Hi$1,m as mT,z as z$1,a as P$2,aG as z,b as U$1,aH as TS,q as oC,x as iC,aI as Tr$1,aJ as Nb,am as Gm,j as Gn$1,W as WC,aK as Do$1,aL as qn$1,aM as Nn$1,aN as wt$1,aO as G$1,aP as $a,aQ as As,aR as K,aS as Ut,aT as Ue,aU as U$2,aV as w,aW as D,aX as ft$1,aY as ks,aZ as YT,ac as mC,a_ as XC,a$ as Yg,a5 as yl,o as bg,ah as rT,b0 as An,b1 as Ob,b2 as bb,b3 as oT,b4 as nT,aw as pl,b5 as Sg,ax as hl,a8 as Zg,c as ce$1,b6 as u,b7 as B,b8 as T$1,b9 as v,ba as m,bb as R,bc as h,bd as A$1,be as aT,bf as uT,C as Cg,bg as Hy,p as pr$1,bh as lT,bi as aE,bj as yh}from'./main-FEA3BAHM.js';import {s}from'./chunk-CH0b9ss9.js';import {d}from'./chunk-Cy-MbcIf.js';import {S as Se$1,P as Pn}from'./chunk-DXVBbChn.js';import {u as ui$1,m as mt$1,p as pt$1,Z,V as Ve}from'./chunk-BxT6IsjS.js';import {y as yt$1,w as wt,t as ti$1,Y as Ye,Z as Zn$1,c as cn}from'./chunk-DFaRJnOg.js';var et=class i{sanitizer=g(TS);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=An({name:"highlight",type:i,pure:true})};var fe=class i{http=g(dy);projectState=g(P$1);threadState=g(U);transcribeAudio(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow();return this.http.post(`/api/projects/${o}/transcribe`,P$2({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`,P$2({audio:e,mimeType:t},n?{language:n}:{}))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var _i=["messageInput"],xi=["fileInput"],yi=(i,e)=>e.name;function wi(i,e){i&1&&(vs(0,"div",3),bg(1,"span",8),WC(2," Recording... Click mic to stop "),fl());}function Ti(i,e){i&1&&(vs(0,"div",3),bg(1,"span",9),WC(2," Transcribing... "),fl());}function Si(i,e){if(i&1&&(vs(0,"span",14),WC(1),fl()),i&2){let t=mC().$implicit,n=mC(2);XE(),Zg(" "+(n.getParameterFormat(t)||""));}}function Mi(i,e){if(i&1){let t=dC();vs(0,"div",11),Ag("click",function(){let o=If(t).$index,r=mC(2);return wf(r.selectAutocompleteItemByClick(o))})("keydown.enter",function(){let o=If(t).$index,r=mC(2);return wf(r.selectAutocompleteItemByClick(o))})("keydown.space",function(){let o=If(t).$index,r=mC(2);return wf(r.selectAutocompleteItemByClick(o))})("mouseenter",function(){let o=If(t).$index,r=mC(2);return wf(r.selectedAutocompleteIndex=o)}),vs(1,"div",12),bg(2,"span",13),aT(3,"highlight"),eC(4,Si,2,1,"span",14),fl(),bg(5,"div",15),aT(6,"highlight"),fl();}if(i&2){let t=e.$implicit,n=e.$index,o=mC(2);Hg("selected",n===o.selectedAutocompleteIndex),Cg("aria-selected",n===o.selectedAutocompleteIndex),XE(2),Tg("innerHTML",lT(3,6,o.autocompleteTrigger+t.name,o.getAutocompleteQuery()),aE),XE(2),tC(o.hasParameterFormat(t)?4:-1),XE(),Tg("innerHTML",lT(6,9,t.description,o.getAutocompleteQuery()),aE);}}function Ei(i,e){if(i&1&&(vs(0,"div",4),oC(1,Mi,7,12,"div",10,yi),fl()),i&2){let t=mC();XE(),iC(t.autocompleteItems);}}function Oi(i,e){if(i&1){let t=dC();vs(0,"ds-icon-button",18),Ag("action",function(){If(t);let o=mC(2);return wf(o.onStopClick())}),fl();}}function Pi(i,e){if(i&1){let t=dC();vs(0,"ds-icon-button",19),Ag("action",function(){If(t);let o=mC(2);return wf(o.sendMessage())}),fl();}if(i&2){let t=mC(2);Hg("hidden",t.isDisabled||!t.message.trim())("active",!!t.message.trim()&&!t.isDisabled),Tg("title",t.getSendButtonTooltip())("disabled",t.isDisabled||!t.message.trim());}}function ki(i,e){if(i&1){let t=dC();vs(0,"ds-icon-button",21),Ag("action",function(){If(t);let o=mC(3);return wf(o.triggerFileUpload())}),fl(),vs(1,"input",22,1),Ag("change",function(o){If(t);let r=mC(3);return wf(r.onFileInputChange(o))}),fl();}if(i&2){let t=mC(3);Tg("disabled",t.isDisabled);}}function Ii(i,e){if(i&1){let t=dC();eC(0,ki,3,1),vs(1,"ds-icon-button",20),Ag("action",function(){If(t);let o=mC(2);return wf(o.toggleRecording())}),fl();}if(i&2){let t=mC(2);tC(!t.showWelcome&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?0:-1),XE(),Hg("hidden",t.message.trim()&&!t.isRecording&&!t.isTranscribing),Tg("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 Di(i,e){if(i&1&&(vs(0,"div",7),eC(1,Oi,1,0,"ds-icon-button",16),eC(2,Pi,1,6,"ds-icon-button",17),eC(3,Ii,2,6),fl()),i&2){let t=mC();XE(),tC(t.isThinking?1:-1),XE(),tC((!t.isThinking||t.message.trim())&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?2:-1),XE(),tC(t.isThinking?-1:3);}}var tt=class i{isDisabled=false;showWelcome=false;isThinking=false;isStarting=false;isSessionInitializing=false;isStopping=false;filesPasted=new yt;messageSubmitted=new yt;voiceMessageReady=new yt;voiceRecordingToggled=new yt;heightChanged=new yt;stopRequested=new yt;textareaFocused=new yt;messageInput;fileInput;message="";isRecording=false;isTranscribing=false;isFocused=false;recognition=null;mediaRecorder=null;audioChunks=[];voiceInputMode="browser";get isVoiceMessageMode(){return this.voiceInputMode==="voice-message"}sessionHadTranscript=false;pendingLineBreaksTimeout=null;lastProcessedResultIndex=0;useEnterToSend=false;currentInvite="";subscriptions=[];thinkingPhrases=["Processing request...","Thinking...","Working on it..."];currentThinkingPhrase="Processing request...";thinkingPhraseIndex=0;thinkingInterval=null;autocompleteVisible=false;autocompleteTrigger=null;autocompleteItems=[];selectedAutocompleteIndex=0;preferencesService=g(L);codayService=g(Ge);agentApiService=g(f);promptApiService=g(d);projectStateService=g(P$1);audioApiService=g(fe);threadStateService=g(U);ngOnInit(){this.initializeVoiceInput(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.subscriptions.push(this.preferencesService.voiceLanguage$.subscribe(()=>this.updateRecognitionLanguage())),this.subscriptions.push(this.preferencesService.voiceInputMode$.subscribe(e=>{this.voiceInputMode=e;})),this.subscriptions.push(this.preferencesService.enterToSend$.subscribe(e=>{this.useEnterToSend=e;})),this.subscribeToInviteEvents(),this.subscribeToMessageRestore();}ngAfterViewInit(){this.adjustTextareaHeight(),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),200);});}ngOnChanges(e){e.isThinking&&(e.isThinking.currentValue?this.startThinkingAnimation():(this.stopThinkingAnimation(),this.isStopping=false,e.isThinking.previousValue&&(console.log("[CHAT-TEXTAREA] Thinking ended, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100);})))),e.isSessionInitializing&&!e.isSessionInitializing.currentValue&&e.isSessionInitializing.previousValue&&(console.log("[CHAT-TEXTAREA] Session initialization completed, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100);})),e.isStarting&&!e.isStarting.currentValue&&e.isStarting.previousValue&&this.isThinking&&(this.thinkingPhraseIndex===0?(console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index 0 - restarting animation"),this.stopThinkingAnimation(),this.startThinkingAnimation()):console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index",this.thinkingPhraseIndex,"- continuing without restart"));}ngOnDestroy(){this.subscriptions.forEach(e=>e.unsubscribe()),this.subscriptions=[],this.clearPendingLineBreaks(),this.stopThinkingAnimation();}onKeyDown(e){if(this.autocompleteVisible)switch(e.key){case "ArrowDown":e.preventDefault(),this.selectedAutocompleteIndex=Math.min(this.selectedAutocompleteIndex+1,this.autocompleteItems.length-1),this.scrollSelectedItemIntoView();return;case "ArrowUp":e.preventDefault(),this.selectedAutocompleteIndex=Math.max(this.selectedAutocompleteIndex-1,0),this.scrollSelectedItemIntoView();return;case "Tab":case "Enter":if(!this.message.includes(" ")){e.preventDefault(),this.selectAutocompleteItem();return}break;case "Escape":e.preventDefault(),this.hideAutocomplete();return}e.key==="Enter"&&(this.useEnterToSend?!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),this.sendMessage(true)):(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey)&&!e.shiftKey&&(e.preventDefault(),this.sendMessage(true)));}onInput(){this.adjustTextareaHeight(),this.checkForAutocomplete();}onPaste(e){let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(r=>r.kind==="file");if(!n.length)return;e.preventDefault();let o=n.reduce((r,d)=>{let v=d.getAsFile();return v?[...r,v]:r},[]);o.length&&this.filesPasted.emit(o);}triggerFileUpload(){console.log("[CHAT-TEXTAREA] Triggering file upload"),this.fileInput?.nativeElement?.click();}onFileInputChange(e){let t=e.target,n=t.files;if(!n||n.length===0){console.log("[CHAT-TEXTAREA] No files selected");return}console.log("[CHAT-TEXTAREA] Files selected:",n.length);let o=Array.from(n);this.filesPasted.emit(o),t.value="";}onDocumentClick(e){if(!this.autocompleteVisible)return;let t=e.target,n=document.querySelector(".autocomplete-popup"),o=this.messageInput?.nativeElement;n&&!n.contains(t)&&o&&!o.contains(t)&&this.hideAutocomplete();}sendMessage(e=false){let t=this.message.trim();!this.isDisabled&&(e||t)&&(this.isRecording&&this.recognition&&(this.clearPendingLineBreaks(),this.recognition.stop()),this.messageSubmitted.emit(t),this.message="",setTimeout(()=>this.adjustTextareaHeight(),0));}onStopClick(){this.isStopping=true,this.stopRequested.emit();}toggleRecording(){this.isRecording?this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.stopWhisperRecording():this.stopRecording():this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.startWhisperRecording():this.startRecording();}startWhisperRecording(){return dt$1(this,null,function*(){if(!this.isRecording)try{let e=yield navigator.mediaDevices.getUserMedia({audio:!0});this.audioChunks=[],this.mediaRecorder=new MediaRecorder(e),this.mediaRecorder.ondataavailable=t=>{t.data.size>0&&this.audioChunks.push(t.data);},this.mediaRecorder.onstop=()=>{e.getTracks().forEach(t=>t.stop()),this.processWhisperAudio();},this.mediaRecorder.onerror=t=>{console.error("[WHISPER] MediaRecorder error:",t),e.getTracks().forEach(n=>n.stop()),this.isRecording=!1,this.voiceRecordingToggled.emit(!1);},this.mediaRecorder.start(),this.isRecording=!0,this.voiceRecordingToggled.emit(!0),console.log("[WHISPER] Started recording");}catch(e){console.error("[WHISPER] Failed to start recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(false);}})}stopWhisperRecording(){if(!(!this.mediaRecorder||!this.isRecording))try{this.mediaRecorder.stop(),this.isRecording=!1,this.voiceRecordingToggled.emit(!1),console.log("[WHISPER] Stopped recording");}catch(e){console.error("[WHISPER] Failed to stop recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(false);}}processWhisperAudio(){if(this.audioChunks.length===0)return;let e=new Blob(this.audioChunks,{type:this.mediaRecorder?.mimeType||"audio/webm"}),t=e.type.split(";")[0]||"audio/webm";this.audioChunks=[],this.isTranscribing=true;let n=new FileReader;n.onloadend=()=>{let o=n.result.split(",")[1];if(!o){console.error("[WHISPER] Failed to read audio as base64"),this.isTranscribing=false;return}let d=this.preferencesService.getVoiceLanguage().split("-")[0];if(this.voiceInputMode==="voice-message"){if(!this.threadStateService.getSelectedThreadId()){console.log("[WHISPER] No thread selected \u2014 emitting voiceMessageReady for thread creation"),this.isTranscribing=false,this.voiceMessageReady.emit({base64:o,mimeType:t,language:d});return}this.audioApiService.sendVoiceMessage(o,t,d).subscribe({next:v=>{this.isTranscribing=false,console.log("[WHISPER] Voice message sent, transcription:",v.transcription?.substring(0,50));},error:v=>{console.error("[WHISPER] Voice message error:",v),this.isTranscribing=false,this.fallbackToTranscription(o,t,d);}});}else this.audioApiService.transcribeAudio(o,t,d).subscribe({next:v=>{this.isTranscribing=false,v.text&&this.appendToTextarea(v.text+" ");},error:v=>{console.error("[WHISPER] Transcription error:",v),this.isTranscribing=false;}});},n.readAsDataURL(e);}fallbackToTranscription(e,t,n){this.audioApiService.transcribeAudio(e,t,n).subscribe({next:o=>{this.isTranscribing=false,o.text&&this.appendToTextarea(o.text+" ");},error:o=>{console.error("[WHISPER] Fallback transcription also failed:",o),this.isTranscribing=false;}});}initializeVoiceInput(){let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(console.log("[SPEECH] speechRecognition",e),!e){console.warn("[SPEECH] Speech Recognition API not available");return}this.recognition=new e,this.recognition.continuous=true,this.recognition.interimResults=true,this.recognition.maxAlternatives=1,this.recognition.lang=this.getSelectedLanguage();try{"grammars"in this.recognition&&(this.recognition.serviceURI=void 0);}catch(t){console.log("[SPEECH] Advanced speech recognition parameters not supported");}this.recognition.onresult=t=>{let n="",o=Math.max(t.resultIndex,this.lastProcessedResultIndex);for(let r=o;r<t.results.length;r++)t.results[r].isFinal&&(n+=t.results[r][0].transcript,this.lastProcessedResultIndex=r+1);if(n){let r=this.improveTranscriptPunctuation(n.trim());this.sessionHadTranscript=true,console.log("[SPEECH] onresult ending, appending to textarea",this.isRecording),this.appendToTextarea(r);}},this.recognition.onend=()=>{console.log("[SPEECH] Recognition ended. Was recording:",this.isRecording),this.isRecording=false,this.lastProcessedResultIndex=0,this.voiceRecordingToggled.emit(this.isRecording);},this.recognition.onerror=t=>{console.error("[SPEECH] Speech recognition error:",t.error),console.log("[SPEECH] Error details:",{error:t.error,message:t.message,timeStamp:t.timeStamp}),this.isRecording=false,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording);},this.recognition.onstart=()=>{console.log("[SPEECH] Recognition started successfully");},this.recognition.onspeechstart=()=>{console.log("[SPEECH] Speech detected");},this.recognition.onspeechend=()=>{console.log("[SPEECH] Speech ended");};}startRecording(){return dt$1(this,null,function*(){if(!(!this.recognition||this.isRecording))try{this.isRecording=!0,this.sessionHadTranscript=!1,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording),this.recognition.start(),console.log("[SPEECH] Started recording");}catch(e){console.error("[SPEECH] Failed to start recording:",e),this.isRecording=false,this.voiceRecordingToggled.emit(this.isRecording);}})}stopRecording(){if(!this.recognition||!this.isRecording){console.log("[SPEECH] stopRecording not recording");return}try{console.log("[SPEECH] stopRecording recognition stop"),this.recognition.stop(),this.schedulePendingLineBreaks();}catch(e){console.error("[SPEECH] Failed to stop recording:",e);}}getSelectedLanguage(){return this.preferencesService.getVoiceLanguage()}updateRecognitionLanguage(){if(this.recognition){let e=this.getSelectedLanguage();this.recognition.lang=e,console.log("[SPEECH] Language changed to:",e);}}improveTranscriptPunctuation(e){let t=e;return /[.!?]$/.test(t.trim())||(t=t.trim()+"."),t=t.charAt(0).toUpperCase()+t.slice(1),t=t.replace(/\s+/g," "),t=t+" ",t}appendToTextarea(e){let t=this.message;if(this.message=t?`${t}${e}`:e,this.messageInput?.nativeElement){this.messageInput.nativeElement.focus();let n=this.message.length;this.messageInput.nativeElement.setSelectionRange(n,n);}setTimeout(()=>this.adjustTextareaHeight(),0);}schedulePendingLineBreaks(){this.clearPendingLineBreaks(),this.pendingLineBreaksTimeout=window.setTimeout(()=>{this.sessionHadTranscript&&(console.log("[SPEECH] Adding line breaks after transcript session"),this.appendToTextarea(`
|
|
2
2
|
|
|
3
3
|
`),this.sessionHadTranscript=false),this.pendingLineBreaksTimeout=null;},500);}clearPendingLineBreaks(){this.pendingLineBreaksTimeout&&(clearTimeout(this.pendingLineBreaksTimeout),this.pendingLineBreaksTimeout=null);}adjustTextareaHeight(){let e=this.messageInput?.nativeElement;if(!e)return;let t=e.parentElement?.offsetHeight??e.offsetHeight+32;this.heightChanged.emit(t);}getSendButtonShortcut(){return this.useEnterToSend?"Enter":navigator.platform.toLowerCase().includes("mac")?"\u2318+Enter":"Ctrl+Enter"}getSendButtonTooltip(){return this.useEnterToSend?"Send message (Enter) - Shift+Enter for new line":`Send message (${navigator.platform.toLowerCase().includes("mac")?"Cmd+Enter":"Ctrl+Enter"}) - Enter for new line`}getPlaceholder(){return this.isSessionInitializing?"Initializing session...":this.isThinking?this.isStopping?"Stopping...":this.isStarting?"Processing request...":this.currentThinkingPhrase:this.isVoiceMessageMode&&this.isTranscribing?"Uploading...":this.isVoiceMessageMode&&this.isRecording?"Listening...":this.showWelcome?"How can I help you today?":"Type '@' for agents, '/' for commands, or just your message..."}startThinkingAnimation(){this.thinkingPhraseIndex=0,this.currentThinkingPhrase=this.thinkingPhrases[0]??"Thinking...",this.thinkingInterval=window.setInterval(()=>{this.thinkingPhraseIndex<this.thinkingPhrases.length-1&&(this.thinkingPhraseIndex++,this.currentThinkingPhrase=this.thinkingPhrases[this.thinkingPhraseIndex]??"Thinking...");},2e3);}stopThinkingAnimation(){this.thinkingInterval&&(clearInterval(this.thinkingInterval),this.thinkingInterval=null),this.thinkingPhraseIndex=0,this.currentThinkingPhrase="Thinking...";}subscribeToInviteEvents(){this.subscriptions.push(this.codayService.currentInviteEvent$.subscribe(e=>{e?this.handleInviteEvent(e.invite,e.defaultValue):this.currentInvite="";}));}handleInviteEvent(e,t){this.currentInvite=e,t&&(this.message=t,setTimeout(()=>this.adjustTextareaHeight(),0)),setTimeout(()=>{this.messageInput?.nativeElement&&this.messageInput.nativeElement.focus();},50);}subscribeToMessageRestore(){this.subscriptions.push(this.codayService.messageToRestore$.subscribe(e=>{e.trim()&&(console.log("[CHAT-TEXTAREA] Restoring message content:",e.substring(0,50)+"..."),this.restoreMessageContent(e));}));}restoreMessageContent(e){this.message=e,this.messageInput?.nativeElement&&(this.messageInput.nativeElement.focus(),setTimeout(()=>{let t=this.messageInput.nativeElement,n=this.message.length;t.setSelectionRange(n,n);},0)),setTimeout(()=>this.adjustTextareaHeight(),10);}focusTextarea(){let e=this.messageInput?.nativeElement;console.log("[CHAT-TEXTAREA] focusTextarea called",{hasElement:!!e,isDisabled:this.isDisabled,isThinking:this.isThinking,elementDisabled:e?.disabled,isSessionInitializing:this.isSessionInitializing}),e&&!e.disabled?(e.focus(),console.log("[CHAT-TEXTAREA] Textarea focused successfully")):console.log("[CHAT-TEXTAREA] Focus blocked - element disabled or not available");}checkForAutocomplete(){let e=this.message;if(e.startsWith("@")){let t=e.substring(1);if(t.includes(" ")){this.hideAutocomplete();return}this.showAgentAutocomplete(t);return}if(e.startsWith("/")){let t=e.substring(1);if(t.includes(" ")){this.hideAutocomplete();return}this.showPromptAutocomplete(t);return}this.hideAutocomplete();}showAgentAutocomplete(e){this.autocompleteTrigger="@";try{let t=this.projectStateService.getSelectedProjectIdOrThrow();this.agentApiService.getAgentsAutocomplete(t,e).subscribe({next:n=>{this.autocompleteItems=n,this.autocompleteVisible=n.length>0,this.selectedAutocompleteIndex=0;},error:n=>{console.error("[AUTOCOMPLETE] Error loading agents:",n),this.hideAutocomplete();}});}catch(t){console.warn("[AUTOCOMPLETE] No project selected, cannot load agents"),this.hideAutocomplete();}}showPromptAutocomplete(e){this.autocompleteTrigger="/";try{let t=this.projectStateService.getSelectedProjectIdOrThrow();this.promptApiService.getPromptsAutocomplete(t,e).subscribe({next:n=>{this.autocompleteItems=n,this.autocompleteVisible=n.length>0,this.selectedAutocompleteIndex=0;},error:n=>{console.error("[AUTOCOMPLETE] Error loading prompts:",n),this.hideAutocomplete();}});}catch(t){console.warn("[AUTOCOMPLETE] No project selected, cannot load prompts"),this.hideAutocomplete();}}hideAutocomplete(){this.autocompleteVisible=false,this.autocompleteItems=[],this.selectedAutocompleteIndex=0;}selectAutocompleteItem(){let e=this.autocompleteItems[this.selectedAutocompleteIndex];if(!e)return;let t=null;if(this.autocompleteTrigger==="/"){let n=e,o=n.parameterFormat;if(console.log(n),o===void 0)this.message=`/${e.name}`;else if(o==="")this.message=`/${e.name} `;else {this.message=`/${e.name} ${o}`;let r=this.message.indexOf('=""');r!==-1&&(t=r+2);}}else this.message=`@${e.name} `;this.hideAutocomplete(),setTimeout(()=>{if(this.messageInput?.nativeElement)if(this.messageInput.nativeElement.focus(),t!==null)this.messageInput.nativeElement.setSelectionRange(t,t);else {let n=this.message.length;this.messageInput.nativeElement.setSelectionRange(n,n);}},0);}selectAutocompleteItemByClick(e){this.selectedAutocompleteIndex=e,this.selectAutocompleteItem();}getAutocompleteQuery(){return this.message.substring(1).split(" ")[0]??""}getParameterFormat(e){return e.parameterFormat}hasParameterFormat(e){return this.autocompleteTrigger==="/"&&e.parameterFormat!==void 0}scrollSelectedItemIntoView(){setTimeout(()=>{let e=document.querySelector(".autocomplete-popup");if(!e)return;let t=e.querySelector(".autocomplete-item.selected");t&&t.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});},0);}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=Aw({type:i,selectors:[["app-chat-textarea"]],viewQuery:function(t,n){if(t&1&&Fg(_i,7)(xi,5),t&2){let o;IC(o=wC())&&(n.messageInput=o.first),IC(o=wC())&&(n.fileInput=o.first);}},hostBindings:function(t,n){t&1&&Ag("paste",function(r){return n.onPaste(r)})("click",function(r){return n.onDocumentClick(r)},dE);},inputs:{isDisabled:"isDisabled",showWelcome:"showWelcome",isThinking:"isThinking",isStarting:"isStarting",isSessionInitializing:"isSessionInitializing"},outputs:{filesPasted:"filesPasted",messageSubmitted:"messageSubmitted",voiceMessageReady:"voiceMessageReady",voiceRecordingToggled:"voiceRecordingToggled",heightChanged:"heightChanged",stopRequested:"stopRequested",textareaFocused:"textareaFocused"},features:[Cu],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=dC();vs(0,"div",2),eC(1,wi,3,0,"div",3),eC(2,Ti,3,0,"div",3),eC(3,Ei,3,0,"div",4),vs(4,"div",5)(5,"textarea",6,0),Jg("ngModelChange",function(d){return If(o),KC(n.message,d)||(n.message=d),wf(d)}),Ag("keydown",function(d){return n.onKeyDown(d)})("input",function(){return n.onInput()})("focus",function(){return If(o),n.isFocused=true,wf(n.textareaFocused.emit())})("blur",function(){return n.isFocused=false}),fl(),HI(),eC(7,Di,4,3,"div",7),fl()();}t&2&&(XE(),tC(!n.isVoiceMessageMode&&n.isRecording?1:-1),XE(),tC(!n.isVoiceMessageMode&&n.isTranscribing?2:-1),XE(),tC(n.autocompleteVisible?3:-1),XE(),Hg("focused",n.isFocused)("welcome-mode",n.showWelcome)("is-thinking",n.isThinking)("is-listening",n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),XE(),Xg("ngModel",n.message),Tg("placeholder",n.getPlaceholder())("disabled",n.isDisabled||n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),$I(),XE(2),tC(n.isSessionInitializing?-1:7));},dependencies:[ti$1,Ye,Zn$1,cn,Se$1,et],styles:['@keyframes _ngcontent-%COMP%_gradientBorderShift{0%{background-position:0 0}50%{background-position:100% 0}to{background-position:0 0}}.chat-input-container[_ngcontent-%COMP%]{flex-shrink:0;width:100%;position:relative}.thinking-progress[_ngcontent-%COMP%]{position:absolute;top:0;left:0;right:0;height:3px;z-index:1}.thinking-progress[_ngcontent-%COMP%] .mdc-linear-progress__bar-inner{border-top-width:3px}.input-row.grouped-input[_ngcontent-%COMP%]{display:flex;align-items:stretch;background:var(--glass-bg);border-radius:16px;padding:0 .15rem 0 1.25rem;position:relative;transition:border-color .2s,box-shadow .2s,background .3s}.input-row[_ngcontent-%COMP%]{position:relative;background:var(--glass-bg, #1e1e1e)!important;background-clip:padding-box}.input-row[_ngcontent-%COMP%]:before{content:"";position:absolute;inset:-2px;border-radius:inherit;background-size:200% 100%;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:xor;mask-composite:exclude;padding:1px;pointer-events:none;z-index:-1;animation:_ngcontent-%COMP%_gradientBorderShift 3s ease-in-out infinite}.input-row.is-listening[_ngcontent-%COMP%]:before{inset:0;-webkit-mask:none;mask:none;padding:0;opacity:.15;z-index:0;background:linear-gradient(90deg,var(--color-error, #ef4444) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-error, #ef4444) 100%);background-size:200% 100%;animation:_ngcontent-%COMP%_gradientBorderShift 2s ease-in-out infinite}.input-row.is-listening[_ngcontent-%COMP%] .message-input[_ngcontent-%COMP%], .input-row.is-listening[_ngcontent-%COMP%] .action-btn[_ngcontent-%COMP%]{position:relative;z-index:1}.input-row.is-thinking[_ngcontent-%COMP%]:before{inset:0;-webkit-mask:none;mask:none;padding:0;opacity:.15;z-index:0;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% 100%;animation:_ngcontent-%COMP%_gradientBorderShift 3s ease-in-out infinite}.input-row.is-thinking[_ngcontent-%COMP%] .message-input[_ngcontent-%COMP%], .input-row.is-thinking[_ngcontent-%COMP%] .action-btn[_ngcontent-%COMP%]{position:relative;z-index:1}.input-row.grouped-input.focused[_ngcontent-%COMP%]:not(.is-thinking):before{background:var(--color-primary);animation:none}.input-row.grouped-input.focused[_ngcontent-%COMP%]:not(.is-thinking){box-shadow:0 0 0 4px #007aff1a}.message-input[_ngcontent-%COMP%]{flex:1;border:none;outline:none;background:transparent!important;box-shadow:none;font-size:1rem;padding:1rem 0;color:var(--color-text);resize:none;field-sizing:content;min-height:36px;max-height:70vh;overflow-y:auto;font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,system-ui,sans-serif;line-height:1.5}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar{width:8px}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--color-text-secondary)}.message-input[_ngcontent-%COMP%]:focus{outline:none;border:none;box-shadow:none}.message-input[_ngcontent-%COMP%]:disabled{background-color:var(--color-bg-secondary);color:var(--color-text-secondary);cursor:not-allowed;opacity:.6}.message-input[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary);transition:opacity .3s ease-in-out}.message-input[_ngcontent-%COMP%]:disabled::placeholder{animation:_ngcontent-%COMP%_thinkingPulsate 2s ease-in-out infinite}@keyframes _ngcontent-%COMP%_thinkingPulsate{0%,to{opacity:.6}50%{opacity:1}}.voice-btn[_ngcontent-%COMP%], .send-btn[_ngcontent-%COMP%], .action-btn[_ngcontent-%COMP%], .upload-btn[_ngcontent-%COMP%]{margin:0}.actions[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-wrap:wrap;justify-content:center}.send-btn[_ngcontent-%COMP%]{transition:opacity .4s,margin-left .4s}.send-btn.active[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{opacity:1}.send-btn[_ngcontent-%COMP%]:not(.active) button[_ngcontent-%COMP%]{opacity:0;margin-left:calc(-.5rem - 36px)}.send-btn[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:hover:not(:disabled){color:#fff;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-primary, #3b82f6) 20%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 80%,var(--color-primary, #3b82f6) 100%);background-size:300% auto;animation:sendButtonGradientShift 6s ease-in-out infinite;box-shadow:0 4px 14px #007aff30;transform:scale(1.2)}.send-btn[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:active:not(:disabled){transform:scale(1.3);box-shadow:0 4px 24px #007aff30}.recording-indicator[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin-top:.2rem;margin-bottom:.2rem;color:var(--color-error, #ff5555);font-size:.9rem;position:absolute;top:-1.5rem}@keyframes _ngcontent-%COMP%_pulse{0%,to{opacity:1}50%{opacity:.5}}.autocomplete-popup[_ngcontent-%COMP%]{position:absolute;bottom:100%;left:0;right:0;margin-bottom:.5rem;background:var(--glass-bg);-webkit-backdrop-filter:var(--glass-backdrop-blur);backdrop-filter:var(--glass-backdrop-blur);border-radius:12px;box-shadow:0 8px 32px #00000026;border:1px solid var(--color-border);max-height:400px;max-width:500px;overflow-y:auto;z-index:100}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar{width:8px}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--color-text-secondary)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%]{padding:.75rem 1rem;cursor:pointer;transition:background .2s;border-left:3px solid transparent}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%]:hover, .autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item.selected[_ngcontent-%COMP%]{background:var(--color-bg-hover)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item.selected[_ngcontent-%COMP%]{border-left-color:var(--color-primary)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%]{font-weight:600;color:var(--color-text);margin-bottom:.25rem;font-family:SF Mono,Monaco,Menlo,Cascadia Code,Consolas,monospace;font-size:.95rem}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%] strong{font-weight:700;color:var(--color-primary);background:var(--color-primary-light, rgba(99, 102, 241, .1));padding:0 2px;border-radius:2px}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%] .parameter-format[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-weight:400;opacity:.7}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-description[_ngcontent-%COMP%]{font-size:.85rem;color:var(--color-text-secondary);line-height:1.3}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-description[_ngcontent-%COMP%] strong{font-weight:700;color:var(--color-primary);background:var(--color-primary-light, rgba(99, 102, 241, .1))}@media print{.thinking-progress[_ngcontent-%COMP%], .action-btn[_ngcontent-%COMP%], .voice-btn[_ngcontent-%COMP%], .send-btn[_ngcontent-%COMP%], .upload-btn[_ngcontent-%COMP%], .recording-indicator[_ngcontent-%COMP%], .autocomplete-popup[_ngcontent-%COMP%]{display:none!important}}'],changeDetection:1})};var be=class i{unreadCountSubject=new Tr$1(0);unreadCount$=this.unreadCountSubject.asObservable();constructor(){console.log("[UNREAD] Service initialized");}addUnread(){let t=this.unreadCountSubject.value+1;this.unreadCountSubject.next(t),console.log("[UNREAD] Added unread message, total:",t);}markAllAsRead(){this.unreadCountSubject.value>0&&(this.unreadCountSubject.next(0),console.log("[UNREAD] Marked all messages as read"));}getCurrentCount(){return this.unreadCountSubject.value}reset(){this.unreadCountSubject.next(0),console.log("[UNREAD] Counter reset");}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var nt=class i{ATTENTION_EMOJI="\u{1F534}";isSystemActive=false;systemActiveTimer=null;SYSTEM_ACTIVE_TIMEOUT=4e3;unreadService=g(be);project=g(P$1);constructor(){this.initializeTitleUpdates();}initializeTitleUpdates(){Ly([this.project.selectedProject$,this.unreadService.unreadCount$]).subscribe(([e,t])=>{this.updateTitle(e?.name??"...",t);});}updateTitle(e,t){let n;this.isSystemActive?n=`\u23F3${t>0?` (${t}) `:" "}${e}`:t>0?n=`${this.ATTENTION_EMOJI} (${t}) ${e}`:n=e,document.title=n,console.log("[TAB-TITLE] Updated to:",n);}setSystemActive(){console.log("[TAB-TITLE] System active - showing hourglass"),this.isSystemActive=true,this.systemActiveTimer&&clearTimeout(this.systemActiveTimer),this.systemActiveTimer=setTimeout(()=>{console.log("[TAB-TITLE] System active timeout - hiding hourglass"),this.isSystemActive=false,this.forceUpdateTitle();},this.SYSTEM_ACTIVE_TIMEOUT),this.forceUpdateTitle();}setSystemInactive(){console.log("[TAB-TITLE] System inactive - hiding hourglass"),this.isSystemActive=false,this.systemActiveTimer&&(clearTimeout(this.systemActiveTimer),this.systemActiveTimer=null),this.forceUpdateTitle();}forceUpdateTitle(){let e=this.project.getSelectedProjectId()??"...",t=this.unreadService.getCurrentCount();this.updateTitle(e,t);}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var 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=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var Ai=(i,e)=>e.label;function Fi(i,e){if(i&1){let t=dC();vs(0,"button",2),Ag("click",function(o){let r=If(t).$implicit,d=mC();return wf(d.executeAction(r,o))}),vs(1,"mat-icon"),WC(2),fl()();}if(i&2){let t=e.$implicit;Cg("title",t.tooltip||t.label),XE(),Cg("aria-label",t.label),XE(),Zg(t.icon);}}var ot=class i{actions=[];executeAction(e,t){t.stopPropagation(),e.action();}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=Aw({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&&(vs(0,"div",0),oC(1,Fi,3,3,"button",1,Ai),fl()),t&2&&(XE(),iC(n.actions));},dependencies:[Gm,Gn$1,wt],styles:[".context-menu-wrapper[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center}.context-menu-wrapper[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{transform:scale(.75)}"],changeDetection:1})};var J=class i{renderer;constructor(){this.renderer=new Ue$1,this.configureRenderer();}configureRenderer(){let e=this.renderer.link.bind(this.renderer);this.renderer.link=t=>{let n=this.isExternalLink(t.href),o=e(t);if(n){o=o.replace("<a ",'<a target="_blank" rel="noopener noreferrer" ');let r=t.title?`${t.text} - ${t.title} (opens in new tab)`:`${t.text} (opens in new tab)`;o=o.replace("<a ",`<a aria-label="${this.escapeHtml(r)}" `),o=o.replace("</a>",'<span class="external-link-icon" aria-hidden="true">\u2197</span></a>');}return o};}isExternalLink(e){if(!e||e.startsWith("/")||e.startsWith("#")||e.startsWith("?"))return false;if(e.startsWith("//"))return true;try{return new URL(e,window.location.href).hostname!==window.location.hostname}catch(t){return false}}escapeHtml(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,n=>t[n]||n)}parse(e){return dt$1(this,null,function*(){let t=yield x$1.parse(e,{renderer:this.renderer,breaks:true,gfm:true});return is.sanitize(t,{ADD_TAGS:["span"],ADD_ATTR:["aria-hidden","aria-label","target","rel"],ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))/i})})}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};var Ri=i=>({"user-message-wrapper":i});function Hi(i,e){if(i&1&&(vs(0,"div",4)(1,"div",8),WC(2),fl()()),i&2){let t=mC(2);XE(2),yl(" ",t.message.speaker," ");}}function Vi(i,e){if(i&1&&(vs(0,"time",6),WC(1),fl()),i&2){let t=mC(2);XE(),Zg(t.formattedTimestamp);}}function Li(i,e){if(i&1&&(vs(0,"div",7),bg(1,"app-message-context-menu",9),fl()),i&2){let t=mC(2);XE(),Tg("actions",t.actions);}}function zi(i,e){if(i&1&&(eC(0,Hi,3,1,"div",4),bg(1,"div",5),eC(2,Vi,2,1,"time",6),eC(3,Li,2,1,"div",7)),i&2){let t=mC();tC(t.shouldShowSpeaker?0:-1),XE(),Tg("innerHTML",t.renderedContent,aE),XE(),tC(t.formattedTimestamp?2:-1),XE(),tC(t.isLongMessage&&t.shouldShowActions&&t.message.role==="assistant"?3:-1);}}function Ni(i,e){if(i&1&&bg(0,"span",12),i&2){let t=mC(3);Tg("innerHTML",t.renderedContent,aE);}}function $i(i,e){if(i&1&&(vs(0,"span",13),WC(1),fl()),i&2){let t=mC(3);XE(),Zg(t.collapsedErrorText);}}function ji(i,e){i&1&&WC(0," Show less \u25B2 ");}function Ui(i,e){i&1&&WC(0," Show more \u25BC ");}function Bi(i,e){if(i&1){let t=dC();vs(0,"div",10),eC(1,Ni,1,1,"span",12)(2,$i,2,1,"span",13),vs(3,"button",14),Ag("click",function(){If(t);let o=mC(2);return wf(o.toggleErrorExpanded())}),eC(4,ji,1,0)(5,Ui,1,0),fl()();}if(i&2){let t=mC(2);XE(),tC(t.isErrorExpanded()?1:2),XE(3),tC(t.isErrorExpanded()?4:5);}}function Wi(i,e){i&1&&WC(0," \u25B2 ");}function qi(i,e){i&1&&WC(0," \u25BC ");}function Yi(i,e){if(i&1&&(vs(0,"a",17),WC(1,"view"),fl()),i&2){let t=mC(3);Tg("href",t.eventLink,yh);}}function Gi(i,e){if(i&1&&(vs(0,"pre",18),WC(1),fl()),i&2){let t=mC(3);XE(),Zg(t.message.fullContent);}}function Qi(i,e){if(i&1){let t=dC();vs(0,"div",15),bg(1,"span",12),vs(2,"button",16),Ag("click",function(){If(t);let o=mC(2);return wf(o.toggleTechnicalExpanded())}),eC(3,Wi,1,0)(4,qi,1,0),fl(),eC(5,Yi,2,1,"a",17),fl(),eC(6,Gi,2,1,"pre",18);}if(i&2){let t=mC(2);XE(),Tg("innerHTML",t.renderedContent,aE),XE(2),tC(t.isTechnicalExpanded()?3:4),XE(2),tC(t.eventLink?5:-1),XE(),tC(t.isTechnicalExpanded()?6:-1);}}function Xi(i,e){if(i&1&&(vs(0,"a",17),WC(1,"view"),fl()),i&2){let t=mC(3);Tg("href",t.eventLink,yh);}}function Ki(i,e){if(i&1&&(vs(0,"div",11),bg(1,"span",12),eC(2,Xi,2,1,"a",17),fl()),i&2){let t=mC(2);XE(),Tg("innerHTML",t.renderedContent,aE),XE(),tC(t.eventLink?2:-1);}}function Ji(i,e){if(i&1&&eC(0,Bi,6,2,"div",10)(1,Qi,7,4)(2,Ki,3,2,"div",11),i&2){let t=mC();tC(t.message.type==="error"&&t.isLongError?0:t.message.type==="technical"&&t.message.fullContent?1:2);}}function Zi(i,e){if(i&1&&(vs(0,"div",2),bg(1,"app-message-context-menu",9),fl()),i&2){let t=mC();XE(),Tg("actions",t.actions);}}function eo(i,e){if(i&1&&(vs(0,"div",3),bg(1,"app-message-context-menu",9),fl()),i&2){let t=mC();XE(),Tg("actions",t.actions);}}var Ce=class i{destroy$=new ce;message;canDelete=true;isOtherUser=false;containingThreadId;copyRequested=new yt;deleteRequested=new yt;renderedContent="";shouldHideTechnical=false;shouldHideWarning=false;isErrorExpanded=Hi$1(false);static ERROR_COLLAPSE_LINE_THRESHOLD=5;isTechnicalExpanded=Hi$1(false);sanitizer=g(TS);notificationService=g(s);preferencesService=g(L);projectState=g(P$1);threadState=g(U);markdownService=g(J);get messageClasses(){return {[this.message.role]:true,[this.message.type]:true,"hidden-technical":this.shouldHideTechnical&&this.message.type==="technical","hidden-warning":this.shouldHideWarning&&this.message.type==="warning","other-user":this.isOtherUser}}ngOnInit(){return dt$1(this,null,function*(){yield this.renderMarkdown(),this.preferencesService.hideTechnicalMessages$.pipe(Vy(this.destroy$)).subscribe(e=>{this.shouldHideTechnical=e;}),this.preferencesService.hideWarningMessages$.pipe(Vy(this.destroy$)).subscribe(e=>{this.shouldHideWarning=e;}),this.shouldHideTechnical=this.preferencesService.getHideTechnicalMessages(),this.shouldHideWarning=this.preferencesService.getHideWarningMessages();})}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete();}get shouldShowSpeaker(){return this.message.role==="user"?this.isOtherUser||this.message.speaker.startsWith("@"):this.message.role==="assistant"}get shouldShowActions(){return this.message.role==="user"||this.message.role==="assistant"}get isSimplified(){return this.message.role!=="user"&&this.message.role!=="assistant"}datePipe=g(Ob);get formattedTimestamp(){if(this.message.role!=="user"||!this.message.timestamp)return null;let e=new Date().toDateString()===this.message.timestamp.toDateString();return this.datePipe.transform(this.message.timestamp,e?"HH:mm":"dd/MM HH:mm")}get isLongError(){return this.message.type!=="error"?false:this.extractTextContent().split(/\n|\\n/).length>i.ERROR_COLLAPSE_LINE_THRESHOLD}get collapsedErrorText(){return this.extractTextContent().split(/\n|\\n/).slice(0,i.ERROR_COLLAPSE_LINE_THRESHOLD).join(`
|
|
4
4
|
`)+"\u2026"}toggleErrorExpanded(){this.isErrorExpanded.update(e=>!e);}toggleTechnicalExpanded(){this.isTechnicalExpanded.update(e=>!e);}get isLongMessage(){let e=this.extractTextContent();return e.length>1e3||e.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {I}from'./chunk-
|
|
1
|
+
import {I}from'./chunk-CekA5yLC.js';import {m}from'./chunk-Cb82rqle.js';import {g,ao as V$1,G as G$1,w as we,aI as Tr,H as Hi,bR as ma,Q as By,a7 as ga,S as ha,u as ue,b as U$1,A as Aw,aJ as Nb,v as vs,be as aT,l as Ag,W as WC,k as fl,af as Dg,T as TC,r as Tg,bf as uT,ah as rT,n as eC,ac as mC,t as tC,a9 as dC,aa as If,ab as wf,ag as fT}from'./main-FEA3BAHM.js';import {W as Wn}from'./chunk-DXVBbChn.js';import'./chunk-BxT6IsjS.js';import'./chunk-DFaRJnOg.js';import'./chunk-Lluy_pM_.js';var U=()=>[];function V(r,t){if(r&1){let o=dC();vs(0,"agentos-prompt-item",4),Ag("deleteRequested",function(n){If(o);let F=mC(2);return wf(F.deletePrompt(n))}),fl();}if(r&2){let o=mC().$implicit,e=mC();Tg("prompt",t)("namespaceId",e.namespaceId)("readOnly",e.isPlatformPrompt(o.id));}}function j(r,t){if(r&1&&eC(0,V,1,3,"agentos-prompt-item",3),r&2){let o,e=t.$implicit,n=mC();tC((o=n.resolvePrompt(e.id))?0:-1,o);}}var G="platform",K="namespace",A=class r{route=g(V$1);router=g(G$1);destroyRef=g(we);promptState=g(m);namespaceId=this.route.snapshot.params.namespaceId;refresh$=new Tr(void 0);isLoading=Hi(true);allPrompts$=this.refresh$.pipe(ma(()=>(this.isLoading.set(true),By({platform:this.promptState.listPlatform().pipe(ga(()=>ha([]))),namespace:this.promptState.listByNamespace(this.namespaceId)}))));promptItems$=this.allPrompts$.pipe(ue(({platform:t,namespace:o})=>[...t.map(e=>({id:e.id??"",name:e.name,description:e.description,groupKey:G,groupLabel:"Platform (read-only)"})),...o.map(e=>({id:e.id??"",name:e.name,description:e.description,groupKey:K,groupLabel:"Namespace"}))]));namespacePromptsById=new Map;platformPromptsById=new Map;constructor(){this.allPrompts$.pipe(U$1(this.destroyRef)).subscribe({next:({platform:t,namespace:o})=>{this.platformPromptsById=new Map(t.map(e=>[e.id??"",e])),this.namespacePromptsById=new Map(o.map(e=>[e.id??"",e])),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}goBack(){this.router.navigate(["/agentos","namespaces"]);}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"prompts","new"]);}deletePrompt(t){this.promptState.delete(t.id??"").pipe(U$1(this.destroyRef)).subscribe(()=>this.refresh$.next());}resolvePrompt(t){return this.platformPromptsById.get(t)??this.namespacePromptsById.get(t)??null}isPlatformPrompt(t){return this.platformPromptsById.has(t)}static \u0275fac=function(o){return new(o||r)};static \u0275cmp=Aw({type:r,selectors:[["agentos-namespace-prompts"]],decls:6,vars:7,consts:[["promptItemTpl",""],["title","Prompts","emptyMessage","No prompts defined yet. Add one above.","cardMinWidth","400px",3,"createRequested","items","loading","showCreate","itemTemplate"],["toolbar-start","","type","button",1,"namespace-prompts__back",3,"click"],[3,"prompt","namespaceId","readOnly"],[3,"deleteRequested","prompt","namespaceId","readOnly"]],template:function(o,e){if(o&1&&(vs(0,"ds-entity-list",1),aT(1,"async"),Ag("createRequested",function(){return e.openCreateForm()}),vs(2,"button",2),Ag("click",function(){return e.goBack()}),WC(3,"\u2190 Namespaces"),fl()(),Dg(4,j,1,1,"ng-template",null,0,fT)),o&2){let n=TC(5);Tg("items",uT(1,4,e.promptItems$)??rT(6,U))("loading",e.isLoading())("showCreate",true)("itemTemplate",n);}},dependencies:[Wn,I,Nb],styles:[".namespace-prompts__back[_ngcontent-%COMP%]{background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-primary, #007aff);font-family:inherit}.namespace-prompts__back[_ngcontent-%COMP%]:hover{text-decoration:underline}"]})};export{A as NamespacePromptsComponent};
|