@whoz-oss/coday-client 3.23.0 → 3.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/browser/{chunk-KccQKSLr.js → chunk--j9cf9d6.js} +2 -2
  2. package/browser/chunk-2dXF6kxO.js +1 -0
  3. package/browser/{chunk-YGA4ansj.js → chunk-6ZQ87jQV.js} +1 -1
  4. package/browser/{chunk-BpzIo3TO.js → chunk-AfeufHde.js} +1 -1
  5. package/browser/{chunk-CqZF9JZo.js → chunk-B2UoGfZ3.js} +6 -6
  6. package/browser/{chunk-BfzDf8xE.js → chunk-B6pr9Now.js} +1 -1
  7. package/browser/{chunk-DNlBxwgK.js → chunk-BAyZlfDb.js} +1 -1
  8. package/browser/{chunk-VyuxzGHt.js → chunk-BH0AuKDN.js} +1 -1
  9. package/browser/{chunk-DVGYZ6ty.js → chunk-BP7WYYNR.js} +1 -1
  10. package/browser/{chunk-BIOQZPFJ.js → chunk-BRAKs_V4.js} +2 -2
  11. package/browser/{chunk-CMHnK5hV.js → chunk-BSmtz5y3.js} +2 -2
  12. package/browser/{chunk-BQFfxCd3.js → chunk-BUi4VbRk.js} +1 -1
  13. package/browser/{chunk-B3Yorxwd.js → chunk-BWE4takb.js} +1 -1
  14. package/browser/chunk-BZIfffSY.js +1 -0
  15. package/browser/chunk-BaAG5SRs.js +9 -0
  16. package/browser/{chunk-CWQR6xJk.js → chunk-BkZ4nMy0.js} +1 -1
  17. package/browser/{chunk-Cg68_3Ns.js → chunk-Bkl_Vpe1.js} +1 -1
  18. package/browser/{chunk-Bc0TgO1-.js → chunk-BorcVzNx.js} +1 -1
  19. package/browser/{chunk-COoOJuQT.js → chunk-Bsd6cfhc.js} +1 -1
  20. package/browser/{chunk-CXhfjTCk.js → chunk-Btjdv26a.js} +1 -1
  21. package/browser/{chunk-BrNRhqhm.js → chunk-Bv19t8Yr.js} +1 -1
  22. package/browser/{chunk-C3MIs5_Y.js → chunk-ByqToPFV.js} +1 -1
  23. package/browser/{chunk-BQwFVWSb.js → chunk-C0cIJD6B.js} +1 -1
  24. package/browser/{chunk-DHr7_ikE.js → chunk-C3uyXZ11.js} +1 -1
  25. package/browser/{chunk-BZCIYJOL.js → chunk-C4kiVp0I.js} +1 -1
  26. package/browser/{chunk-sz0CVF1-.js → chunk-CBsoAXBW.js} +1 -1
  27. package/browser/chunk-CCSxTkZ-.js +1 -0
  28. package/browser/{chunk-lkvHsW8k.js → chunk-CDteNbQE.js} +1 -1
  29. package/browser/{chunk-CuOGglmC.js → chunk-CIFgO2HT.js} +1 -1
  30. package/browser/{chunk-DH3pQb49.js → chunk-CKdscASQ.js} +1 -1
  31. package/browser/{chunk-B3kY-GQk.js → chunk-CPuMGlfm.js} +1 -1
  32. package/browser/{chunk-BCqtwdIe.js → chunk-CU9SkJlG.js} +1 -1
  33. package/browser/{chunk-CJD8ErVH.js → chunk-CWfLK-02.js} +1 -1
  34. package/browser/{chunk-CXwHeDac.js → chunk-CXFeBkf0.js} +1 -1
  35. package/browser/{chunk-D9wXETZp.js → chunk-Cc6av_kK.js} +2 -2
  36. package/browser/{chunk-D89TfP1E.js → chunk-Ccwn8U1w.js} +1 -1
  37. package/browser/chunk-Ce6h2FeE.js +1 -0
  38. package/browser/chunk-CfZ8rkw0.js +1 -0
  39. package/browser/{chunk-CT4atmse.js → chunk-CgtOp5dr.js} +3 -3
  40. package/browser/{chunk-CaL6ZXsO.js → chunk-CmWqV8dc.js} +6 -6
  41. package/browser/{chunk-CRyr4oOy.js → chunk-ComIIQUU.js} +1 -1
  42. package/browser/{chunk-D7p9n5a9.js → chunk-Cyh4DuAi.js} +1 -1
  43. package/browser/{chunk-DdUOdkVr.js → chunk-D26Rjl-2.js} +1 -1
  44. package/browser/{chunk-SsHAmybq.js → chunk-D62ekcvB.js} +1 -1
  45. package/browser/{chunk-bl1pitLA.js → chunk-DEUnwPWC.js} +1 -1
  46. package/browser/{chunk-DL11Jf1L.js → chunk-DIKc_N9D.js} +1 -1
  47. package/browser/{chunk-O1I9EEmj.js → chunk-DIY-0Lon.js} +1 -1
  48. package/browser/{chunk-DkP2MwMu.js → chunk-DT0j_Tak.js} +1 -1
  49. package/browser/{chunk-ChsKwSBf.js → chunk-DaphJW96.js} +1 -1
  50. package/browser/{chunk-BqC6QWDU.js → chunk-Dgr7xggj.js} +3 -3
  51. package/browser/chunk-DpWl8Hmh.js +2 -0
  52. package/browser/{chunk-BdZ0xOqX.js → chunk-DrcS-IIH.js} +5 -5
  53. package/browser/{chunk-DrKKLE1-.js → chunk-DuGczpUf.js} +2 -2
  54. package/browser/{chunk-BT7IPqmu.js → chunk-DwD-3Qe0.js} +1 -1
  55. package/browser/{chunk-CyJ_au6Y.js → chunk-Dx97073t.js} +5 -5
  56. package/browser/{chunk-BoiQFZ4H.js → chunk-DyyifT6r.js} +1 -1
  57. package/browser/chunk-GWd9G-Nj.js +1 -0
  58. package/browser/{chunk-B2FRxZw1.js → chunk-L0O9mlbO.js} +1 -1
  59. package/browser/{chunk-oqOgDyIj.js → chunk-OZvSiKvx.js} +1 -1
  60. package/browser/chunk-OpIcFxMt.js +1 -0
  61. package/browser/{chunk-B4K0ULQ8.js → chunk-OqElmTmR.js} +1 -1
  62. package/browser/{chunk-bHVjhtHf.js → chunk-RFOuzDB-.js} +1 -1
  63. package/browser/{chunk-B0USjT_j.js → chunk-bEyVnMri.js} +1 -1
  64. package/browser/{chunk-CZ4gj_xn.js → chunk-ehgi4mB8.js} +1 -1
  65. package/browser/{chunk-uY_BCJ93.js → chunk-iT-BBh_o.js} +1 -1
  66. package/browser/{chunk-C9T7UBD_.js → chunk-iiREShnX.js} +1 -1
  67. package/browser/{chunk-DF3Ha0Tb.js → chunk-pyvVjc-9.js} +1 -1
  68. package/browser/{chunk-BSc7HTHd.js → chunk-rWPj3GdK.js} +1 -1
  69. package/browser/{chunk-oIPYJtHA.js → chunk-sI2K91LE.js} +1 -1
  70. package/browser/index.html +1 -1
  71. package/browser/{main-RXIVNUWK.js → main-4LGWVPVH.js} +18 -18
  72. package/package.json +1 -1
  73. package/browser/chunk-7dyrHGkF.js +0 -1
  74. package/browser/chunk-BXGcSbBl.js +0 -1
  75. package/browser/chunk-BujvNLrF.js +0 -1
  76. package/browser/chunk-C4IJySYO.js +0 -2
  77. package/browser/chunk-CjgyOse7.js +0 -1
  78. package/browser/chunk-CzL7jU35.js +0 -1
  79. package/browser/chunk-D8dXXVY5.js +0 -9
  80. package/browser/chunk-DqfAYcrx.js +0 -1
  81. package/browser/chunk-yfVcVvz_.js +0 -1
@@ -1,4 +1,4 @@
1
- import {an as ue,g,L,ci as me,ap as zy,av as dt$1,j as jw,k as Cs,J as JC,m as hl,ai as rm,aj as iT,n as kg,a3 as ZI,M as Mg,o as aC,q as dC,t as sI,ak as nm,a6 as QI,_ as _g,u as cC,v as fC,a5 as Dl,aL as wo,aM as Zn$1,aO as wt$1,az as Xt,aW as C,cj as Pn,ce as kb,c8 as ob,af as wg,ag as ET,c9 as Pf,ck as Lf,ch as Ag,A as AC,S as Sg,ad as $g,b$ as UC,w as zg,x as jg,y as MC,N as NC,aJ as Tr,aG as fe,cl as be,p as pe,l as le,bU as Fd,b9 as T,b8 as B,be as A,b7 as u,bd as h,cm as M,d as O,ba as v,bb as m,c as b,cn as F,f,V,bc as R,co as H,cp as K,ca as _e,K as x,X as z$1,Y as Ue,am as Ym,i as Gn,e as pr,a0 as jt,a2 as Nt,a1 as Vt,b0 as Xg,ac as CC}from'./main-RXIVNUWK.js';import {s as se}from'./chunk-DrKKLE1-.js';import {t as ti,Q as Qn,e as ei,Y as Ye$1,h as _n,A as At,m as mn,Z as Zn,c as cn,w as wt}from'./chunk-B3kY-GQk.js';var Xe=["determinateSpinner"];function et(c,e){if(c&1&&(Pf(),Cs(0,"svg",11),Mg(1,"circle",12),hl()),c&2){let t=CC();Sg("viewBox",t._viewBox()),sI(),$g("stroke-dasharray",t._strokeCircumference(),"px")("stroke-dashoffset",t._strokeCircumference()/2,"px")("stroke-width",t._circleStrokeWidth(),"%"),Sg("r",t._circleRadius());}}var tt=new C("mat-progress-spinner-default-options",{providedIn:"root",factory:()=>({diameter:qe})}),qe=100,nt=10,yt=(()=>{class c{_elementRef=g(Xt);_noopAnimations;get color(){return this._color||this._defaultColor}set color(t){this._color=t;}_color;_defaultColor="primary";_determinateCircle;constructor(){let t=g(tt),n=Pn(),i=this._elementRef.nativeElement;this._noopAnimations=n==="di-disabled"&&!!t&&!t._forceAnimations,this.mode=i.nodeName.toLowerCase()==="mat-spinner"?"indeterminate":"determinate",!this._noopAnimations&&n==="reduced-motion"&&i.classList.add("mat-progress-spinner-reduced-motion"),t&&(t.color&&(this.color=this._defaultColor=t.color),t.diameter&&(this.diameter=t.diameter),t.strokeWidth&&(this.strokeWidth=t.strokeWidth));}mode;get value(){return this.mode==="determinate"?this._value:0}set value(t){this._value=Math.max(0,Math.min(100,t||0));}_value=0;get diameter(){return this._diameter}set diameter(t){this._diameter=t||0;}_diameter=qe;get strokeWidth(){return this._strokeWidth??this.diameter/10}set strokeWidth(t){this._strokeWidth=t||0;}_strokeWidth;_circleRadius(){return (this.diameter-nt)/2}_viewBox(){let t=this._circleRadius()*2+this.strokeWidth;return `0 0 ${t} ${t}`}_strokeCircumference(){return 2*Math.PI*this._circleRadius()}_strokeDashOffset(){return this.mode==="determinate"?this._strokeCircumference()*(100-this._value)/100:null}_circleStrokeWidth(){return this.strokeWidth/this.diameter*100}static \u0275fac=function(n){return new(n||c)};static \u0275cmp=jw({type:c,selectors:[["mat-progress-spinner"],["mat-spinner"]],viewQuery:function(n,i){if(n&1&&jg(Xe,5),n&2){let o;MC(o=NC())&&(i._determinateCircle=o.first);}},hostAttrs:["role","progressbar","tabindex","-1",1,"mat-mdc-progress-spinner","mdc-circular-progress"],hostVars:18,hostBindings:function(n,i){n&2&&(Sg("aria-valuemin",0)("aria-valuemax",100)("aria-valuenow",i.mode==="determinate"?i.value:null)("mode",i.mode),UC("mat-"+i.color),$g("width",i.diameter,"px")("height",i.diameter,"px")("--mat-progress-spinner-size",i.diameter+"px")("--mat-progress-spinner-active-indicator-width",i.diameter+"px"),zg("_mat-animation-noopable",i._noopAnimations)("mdc-circular-progress--indeterminate",i.mode==="indeterminate"));},inputs:{color:"color",mode:"mode",value:[2,"value","value",ob],diameter:[2,"diameter","diameter",ob],strokeWidth:[2,"strokeWidth","strokeWidth",ob]},exportAs:["matProgressSpinner"],decls:14,vars:11,consts:[["circle",""],["determinateSpinner",""],["aria-hidden","true",1,"mdc-circular-progress__determinate-container"],["xmlns","http://www.w3.org/2000/svg","focusable","false",1,"mdc-circular-progress__determinate-circle-graphic"],["cx","50%","cy","50%",1,"mdc-circular-progress__determinate-circle"],["aria-hidden","true",1,"mdc-circular-progress__indeterminate-container"],[1,"mdc-circular-progress__spinner-layer"],[1,"mdc-circular-progress__circle-clipper","mdc-circular-progress__circle-left"],[3,"ngTemplateOutlet"],[1,"mdc-circular-progress__gap-patch"],[1,"mdc-circular-progress__circle-clipper","mdc-circular-progress__circle-right"],["xmlns","http://www.w3.org/2000/svg","focusable","false",1,"mdc-circular-progress__indeterminate-circle-graphic"],["cx","50%","cy","50%"]],template:function(n,i){if(n&1&&(wg(0,et,2,8,"ng-template",null,0,ET),Cs(2,"div",2,1),Pf(),Cs(4,"svg",3),Mg(5,"circle",4),hl()(),Lf(),Cs(6,"div",5)(7,"div",6)(8,"div",7),Ag(9,8),hl(),Cs(10,"div",9),Ag(11,8),hl(),Cs(12,"div",10),Ag(13,8),hl()()()),n&2){let o=AC(1);sI(4),Sg("viewBox",i._viewBox()),sI(),$g("stroke-dasharray",i._strokeCircumference(),"px")("stroke-dashoffset",i._strokeDashOffset(),"px")("stroke-width",i._circleStrokeWidth(),"%"),Sg("r",i._circleRadius()),sI(4),_g("ngTemplateOutlet",o),sI(2),_g("ngTemplateOutlet",o),sI(2),_g("ngTemplateOutlet",o);}},dependencies:[kb],styles:[`.mat-mdc-progress-spinner {
1
+ import {an as ue,g,L,ci as me,ap as _d,av as dt$1,j as jw,k as Cs,J as JC,m as hl,ai as sm,aj as iT,n as Lg,a3 as ZI,A as Ag,o as aC,q as dC,u as sI,ak as im,a6 as QI,x as xg,v as cC,w as fC,a5 as Dl,aL as wo,aM as Zn$1,aO as wt$1,az as Xt,aW as C,cj as Pn,ce as kb,c8 as ob,af as bg,ag as ET,c9 as Bf,ck as Vf,ch as kg,t as AC,N as Ng,ad as Wg,b$ as UC,y as qg,H as Hg,M as MC,B as NC,aJ as Tr,aG as fe,cl as be,p as pe,l as le,bU as jd,b9 as T,b8 as B,be as A,b7 as u,bd as h,cm as M,d as O,ba as v,bb as m,c as b,cn as F,f,V,bc as R,co as H,cp as K,ca as _e,Y as x,Z as z$1,_ as Ue,am as Xm,i as Gn,e as pr,a0 as jt,a2 as Nt,a1 as Vt,b0 as tm,ac as CC}from'./main-4LGWVPVH.js';import {s as se}from'./chunk-DuGczpUf.js';import {t as ti,Q as Qn,e as ei,Y as Ye$1,h as _n,A as At,m as mn,Z as Zn,c as cn,w as wt}from'./chunk-CPuMGlfm.js';var Xe=["determinateSpinner"];function et(c,e){if(c&1&&(Bf(),Cs(0,"svg",11),Ag(1,"circle",12),hl()),c&2){let t=CC();Ng("viewBox",t._viewBox()),sI(),Wg("stroke-dasharray",t._strokeCircumference(),"px")("stroke-dashoffset",t._strokeCircumference()/2,"px")("stroke-width",t._circleStrokeWidth(),"%"),Ng("r",t._circleRadius());}}var tt=new C("mat-progress-spinner-default-options",{providedIn:"root",factory:()=>({diameter:qe})}),qe=100,nt=10,yt=(()=>{class c{_elementRef=g(Xt);_noopAnimations;get color(){return this._color||this._defaultColor}set color(t){this._color=t;}_color;_defaultColor="primary";_determinateCircle;constructor(){let t=g(tt),n=Pn(),i=this._elementRef.nativeElement;this._noopAnimations=n==="di-disabled"&&!!t&&!t._forceAnimations,this.mode=i.nodeName.toLowerCase()==="mat-spinner"?"indeterminate":"determinate",!this._noopAnimations&&n==="reduced-motion"&&i.classList.add("mat-progress-spinner-reduced-motion"),t&&(t.color&&(this.color=this._defaultColor=t.color),t.diameter&&(this.diameter=t.diameter),t.strokeWidth&&(this.strokeWidth=t.strokeWidth));}mode;get value(){return this.mode==="determinate"?this._value:0}set value(t){this._value=Math.max(0,Math.min(100,t||0));}_value=0;get diameter(){return this._diameter}set diameter(t){this._diameter=t||0;}_diameter=qe;get strokeWidth(){return this._strokeWidth??this.diameter/10}set strokeWidth(t){this._strokeWidth=t||0;}_strokeWidth;_circleRadius(){return (this.diameter-nt)/2}_viewBox(){let t=this._circleRadius()*2+this.strokeWidth;return `0 0 ${t} ${t}`}_strokeCircumference(){return 2*Math.PI*this._circleRadius()}_strokeDashOffset(){return this.mode==="determinate"?this._strokeCircumference()*(100-this._value)/100:null}_circleStrokeWidth(){return this.strokeWidth/this.diameter*100}static \u0275fac=function(n){return new(n||c)};static \u0275cmp=jw({type:c,selectors:[["mat-progress-spinner"],["mat-spinner"]],viewQuery:function(n,i){if(n&1&&Hg(Xe,5),n&2){let o;MC(o=NC())&&(i._determinateCircle=o.first);}},hostAttrs:["role","progressbar","tabindex","-1",1,"mat-mdc-progress-spinner","mdc-circular-progress"],hostVars:18,hostBindings:function(n,i){n&2&&(Ng("aria-valuemin",0)("aria-valuemax",100)("aria-valuenow",i.mode==="determinate"?i.value:null)("mode",i.mode),UC("mat-"+i.color),Wg("width",i.diameter,"px")("height",i.diameter,"px")("--mat-progress-spinner-size",i.diameter+"px")("--mat-progress-spinner-active-indicator-width",i.diameter+"px"),qg("_mat-animation-noopable",i._noopAnimations)("mdc-circular-progress--indeterminate",i.mode==="indeterminate"));},inputs:{color:"color",mode:"mode",value:[2,"value","value",ob],diameter:[2,"diameter","diameter",ob],strokeWidth:[2,"strokeWidth","strokeWidth",ob]},exportAs:["matProgressSpinner"],decls:14,vars:11,consts:[["circle",""],["determinateSpinner",""],["aria-hidden","true",1,"mdc-circular-progress__determinate-container"],["xmlns","http://www.w3.org/2000/svg","focusable","false",1,"mdc-circular-progress__determinate-circle-graphic"],["cx","50%","cy","50%",1,"mdc-circular-progress__determinate-circle"],["aria-hidden","true",1,"mdc-circular-progress__indeterminate-container"],[1,"mdc-circular-progress__spinner-layer"],[1,"mdc-circular-progress__circle-clipper","mdc-circular-progress__circle-left"],[3,"ngTemplateOutlet"],[1,"mdc-circular-progress__gap-patch"],[1,"mdc-circular-progress__circle-clipper","mdc-circular-progress__circle-right"],["xmlns","http://www.w3.org/2000/svg","focusable","false",1,"mdc-circular-progress__indeterminate-circle-graphic"],["cx","50%","cy","50%"]],template:function(n,i){if(n&1&&(bg(0,et,2,8,"ng-template",null,0,ET),Cs(2,"div",2,1),Bf(),Cs(4,"svg",3),Ag(5,"circle",4),hl()(),Vf(),Cs(6,"div",5)(7,"div",6)(8,"div",7),kg(9,8),hl(),Cs(10,"div",9),kg(11,8),hl(),Cs(12,"div",10),kg(13,8),hl()()()),n&2){let o=AC(1);sI(4),Ng("viewBox",i._viewBox()),sI(),Wg("stroke-dasharray",i._strokeCircumference(),"px")("stroke-dashoffset",i._strokeDashOffset(),"px")("stroke-width",i._circleStrokeWidth(),"%"),Ng("r",i._circleRadius()),sI(4),xg("ngTemplateOutlet",o),sI(2),xg("ngTemplateOutlet",o),sI(2),xg("ngTemplateOutlet",o);}},dependencies:[kb],styles:[`.mat-mdc-progress-spinner {
2
2
  --mat-progress-spinner-animation-multiplier: 1;
3
3
  display: block;
4
4
  overflow: hidden;
@@ -173,10 +173,10 @@ import {an as ue,g,L,ci as me,ap as zy,av as dt$1,j as jw,k as Cs,J as JC,m as h
173
173
  transform: rotate(-265deg);
174
174
  }
175
175
  }
176
- `],encapsulation:2})}return c})();var Et=(()=>{class c{static \u0275fac=function(n){return new(n||c)};static \u0275mod=wo({type:c});static \u0275inj=Zn$1({imports:[wt$1]})}return c})();var z=class c{destroy$=new ue;voices;currentUtterance=null;currentOnEndCallback=null;speakingSubject=new Tr(false);speaking$=this.speakingSubject.asObservable();volume=.8;rate=1.2;language="en-US";selectedVoice;preferencesService=g(L);constructor(){this.initializeSpeechSynthesis(),this.subscribeToPreferences();}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),this.stopSpeech();}initializeSpeechSynthesis(){if(!("speechSynthesis"in window)){console.warn("[VOICE-SERVICE] Speech synthesis not available"),this.voices=new Promise(e=>e([]));return}this.voices=new Promise((e,t)=>{let n=speechSynthesis.getVoices();if(n.length)e(n);else {let i=setTimeout(()=>{t("no voices found");},2e3);speechSynthesis.addEventListener("voiceschanged",()=>{let o=speechSynthesis.getVoices();o.length&&(clearTimeout(i),e(o));});}}),console.log("[VOICE-SERVICE] Speech synthesis initialized");}subscribeToPreferences(){this.preferencesService.voiceVolume$.pipe(zy(this.destroy$)).subscribe(e=>{this.volume=e,console.log("[VOICE-SERVICE] Volume updated to:",e);}),this.preferencesService.voiceRate$.pipe(zy(this.destroy$)).subscribe(e=>{this.rate=e,console.log("[VOICE-SERVICE] Rate updated to:",e);}),this.preferencesService.voiceLanguage$.pipe(zy(this.destroy$)).subscribe(e=>{this.language=e,console.log("[VOICE-SERVICE] Language updated to:",e),this.updateSelectedVoiceForLanguage();}),this.preferencesService.selectedVoice$.pipe(zy(this.destroy$)).subscribe(e=>{this.setSelectedVoice(e);}),this.volume=this.preferencesService.getVoiceVolume(),this.rate=this.preferencesService.getVoiceRate(),this.language=this.preferencesService.getVoiceLanguage(),this.setSelectedVoice(this.preferencesService.getSelectedVoice());}isReady(){return "speechSynthesis"in window&&this.selectedVoice!==void 0}isSpeaking(){return speechSynthesis.speaking}speak(e,t){return dt$1(this,null,function*(){if(!this.selectedVoice)return console.warn("[VOICE-SERVICE] No voice selected"),false;if(!e.trim())return console.warn("[VOICE-SERVICE] No text to speak"),false;let n=this.extractPlainText(e);if(!n.trim())return console.warn("[VOICE-SERVICE] No text to speak after markdown cleaning"),false;this.stopSpeech();try{let i=new SpeechSynthesisUtterance(n);i.voice=this.selectedVoice,i.lang=this.selectedVoice.lang,i.volume=this.volume,i.rate=this.rate,this.currentOnEndCallback=t||null,t&&(i.onend=()=>{this.currentOnEndCallback===t&&(this.currentOnEndCallback=null,t());},i.onerror=()=>{this.currentOnEndCallback===t&&(this.currentOnEndCallback=null,t());}),this.currentUtterance=i,this.speakingSubject.next(!0);let o=i.onend,E=i.onerror;return i.onend=C=>{this.speakingSubject.next(!1),o&&o.call(i,C);},i.onerror=C=>{this.speakingSubject.next(!1),E&&E.call(i,C);},speechSynthesis.speak(i),console.log("[VOICE-SERVICE] Started speaking:",e.substring(0,50)+"..."),!0}catch(i){return console.error("[VOICE-SERVICE] Error speaking:",i),false}})}stopSpeech(){if(this.currentUtterance||speechSynthesis.speaking){if(speechSynthesis.cancel(),this.currentUtterance=null,this.currentOnEndCallback){let e=this.currentOnEndCallback;this.currentOnEndCallback=null,e();}this.speakingSubject.next(false),console.log("[VOICE-SERVICE] Speech stopped");}}ding(){try{let e=new(window.AudioContext||window.webkitAudioContext),t=e.createOscillator(),n=e.createGain();t.connect(n),n.connect(e.destination),t.frequency.setValueAtTime(800,e.currentTime),n.gain.setValueAtTime(.1,e.currentTime),n.gain.exponentialRampToValueAtTime(.01,e.currentTime+.1),t.start(e.currentTime),t.stop(e.currentTime+.1),console.log("[VOICE-SERVICE] Notification sound played");}catch(e){console.error("[VOICE-SERVICE] Notification sound failed:",e);}}getVoicesForLanguage(){return dt$1(this,null,function*(){try{let e=this.language.slice(0,2),t=yield this.voices;if(!t||t.length===0)return console.warn("[VOICE-SERVICE] No voices available on system"),[];let n=t.filter(i=>i.lang.toLowerCase().startsWith(e)).sort((i,o)=>i.localService&&!o.localService?-1:!i.localService&&o.localService?1:i.name.localeCompare(o.name));return console.log("[VOICE-SERVICE] Found matching voices:",n.length,"for language:",e),n.map(i=>({name:i.name,lang:i.lang,localService:i.localService,default:i.default,displayName:this.formatVoiceDisplayName(i)}))}catch(e){return console.error("[VOICE-SERVICE] Error getting voices for language:",e),[]}})}formatVoiceDisplayName(e){let t=e.localService?"\u{1F3E0}":"\u2601\uFE0F",n=e.default?" \u2B50":"";return `${t} ${e.name} (${e.lang})${n}`}setSelectedVoice(e){return dt$1(this,null,function*(){if(!e){this.selectedVoice=void 0;return}let[t,n]=e.split("|");if(!t||!n){this.selectedVoice=void 0;return}let i=(yield this.voices)?.find(o=>o.name===t&&o.lang===n);i?(this.selectedVoice=i,console.log("[VOICE-SERVICE] Selected voice:",i.name,i.lang)):(this.selectedVoice=void 0,console.warn("[VOICE-SERVICE] Voice not found:",t,n));})}updateSelectedVoiceForLanguage(){return dt$1(this,null,function*(){let e=yield this.getVoicesForLanguage();if(e.length===0){console.warn("[VOICE-SERVICE] No voices available for language:",this.language),this.selectedVoice=void 0,this.preferencesService.setSelectedVoice(null);return}let t=this.preferencesService.getSelectedVoice();if(t){let[i,o]=t.split("|"),E=o?.slice(0,2),C=this.language.slice(0,2);if(E===C&&e.some(q=>q.name===i&&q.lang===o)){console.log("[VOICE-SERVICE] Keeping current voice for language:",t);return}}let n=e[0];if(n){let i=`${n.name}|${n.lang}`;this.preferencesService.setSelectedVoice(i),console.log("[VOICE-SERVICE] Auto-selected voice for language change:",n.displayName);}})}testSelectedVoice(){setTimeout(()=>{if(!this.selectedVoice){console.log("[VOICE-SERVICE] No voice selected for test");return}this.stopSpeech();let e=this.getTestText();e&&this.speak(e);},100);}getTestText(){let e=this.language.slice(0,2),t={fr:"Bonjour, ceci est un test de la voix s\xE9lectionn\xE9e.",en:"Hello, this is a test of the selected voice.",es:"Hola, esta es una prueba de la voz seleccionada.",de:"Hallo, dies ist ein Test der ausgew\xE4hlten Stimme.",it:"Ciao, questo \xE8 un test della voce selezionata.",pt:"Ol\xE1, este \xE9 um teste da voz selecionada.",ja:"\u3053\u3093\u306B\u3061\u306F\u3001\u3053\u308C\u306F\u9078\u629E\u3055\u308C\u305F\u97F3\u58F0\u306E\u30C6\u30B9\u30C8\u3067\u3059\u3002",ko:"\uC548\uB155\uD558\uC138\uC694, \uC774\uAC83\uC740 \uC120\uD0DD\uB41C \uC74C\uC131\uC758 \uD14C\uC2A4\uD2B8\uC785\uB2C8\uB2E4.",zh:"\u4F60\u597D\uFF0C\u8FD9\u662F\u6240\u9009\u8BED\u97F3\u7684\u6D4B\u8BD5\u3002",ru:"\u041F\u0440\u0438\u0432\u0435\u0442, \u044D\u0442\u043E \u0442\u0435\u0441\u0442 \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u043E\u0433\u043E \u0433\u043E\u043B\u043E\u0441\u0430.",ar:"\u0645\u0631\u062D\u0628\u0627\u060C \u0647\u0630\u0627 \u0627\u062E\u062A\u0628\u0627\u0631 \u0644\u0644\u0635\u0648\u062A \u0627\u0644\u0645\u062D\u062F\u062F."};return t[e]||t.en}extractPlainText(e){let t=e.replace(/[\u{1F600}-\u{1F64F}]|[\u{1F300}-\u{1F5FF}]|[\u{1F680}-\u{1F6FF}]|[\u{1F1E0}-\u{1F1FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]|⭐/gu,"").replace(/```[\s\S]*?```/g,"code block").replace(/`([^`]+)`/g,"$1").replace(/\*\*\*(.*?)\*\*\*/g,"$1").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/~~(.*?)~~/g,"$1").replace(/#{1,6}\s*(.*)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/https?:\/\/[^\s]+/g,"link").replace(/&nbsp;/g," ").replace(/&amp;/g,"and").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"');return t=this.addNaturalPunctuation(t),t.replace(/\s+/g," ").trim()}addNaturalPunctuation(e){return e.replace(/\n+/g,`
176
+ `],encapsulation:2})}return c})();var Et=(()=>{class c{static \u0275fac=function(n){return new(n||c)};static \u0275mod=wo({type:c});static \u0275inj=Zn$1({imports:[wt$1]})}return c})();var z=class c{destroy$=new ue;voices;currentUtterance=null;currentOnEndCallback=null;speakingSubject=new Tr(false);speaking$=this.speakingSubject.asObservable();volume=.8;rate=1.2;language="en-US";selectedVoice;preferencesService=g(L);constructor(){this.initializeSpeechSynthesis(),this.subscribeToPreferences();}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),this.stopSpeech();}initializeSpeechSynthesis(){if(!("speechSynthesis"in window)){console.warn("[VOICE-SERVICE] Speech synthesis not available"),this.voices=new Promise(e=>e([]));return}this.voices=new Promise((e,t)=>{let n=speechSynthesis.getVoices();if(n.length)e(n);else {let i=setTimeout(()=>{t("no voices found");},2e3);speechSynthesis.addEventListener("voiceschanged",()=>{let o=speechSynthesis.getVoices();o.length&&(clearTimeout(i),e(o));});}}),console.log("[VOICE-SERVICE] Speech synthesis initialized");}subscribeToPreferences(){this.preferencesService.voiceVolume$.pipe(_d(this.destroy$)).subscribe(e=>{this.volume=e,console.log("[VOICE-SERVICE] Volume updated to:",e);}),this.preferencesService.voiceRate$.pipe(_d(this.destroy$)).subscribe(e=>{this.rate=e,console.log("[VOICE-SERVICE] Rate updated to:",e);}),this.preferencesService.voiceLanguage$.pipe(_d(this.destroy$)).subscribe(e=>{this.language=e,console.log("[VOICE-SERVICE] Language updated to:",e),this.updateSelectedVoiceForLanguage();}),this.preferencesService.selectedVoice$.pipe(_d(this.destroy$)).subscribe(e=>{this.setSelectedVoice(e);}),this.volume=this.preferencesService.getVoiceVolume(),this.rate=this.preferencesService.getVoiceRate(),this.language=this.preferencesService.getVoiceLanguage(),this.setSelectedVoice(this.preferencesService.getSelectedVoice());}isReady(){return "speechSynthesis"in window&&this.selectedVoice!==void 0}isSpeaking(){return speechSynthesis.speaking}speak(e,t){return dt$1(this,null,function*(){if(!this.selectedVoice)return console.warn("[VOICE-SERVICE] No voice selected"),false;if(!e.trim())return console.warn("[VOICE-SERVICE] No text to speak"),false;let n=this.extractPlainText(e);if(!n.trim())return console.warn("[VOICE-SERVICE] No text to speak after markdown cleaning"),false;this.stopSpeech();try{let i=new SpeechSynthesisUtterance(n);i.voice=this.selectedVoice,i.lang=this.selectedVoice.lang,i.volume=this.volume,i.rate=this.rate,this.currentOnEndCallback=t||null,t&&(i.onend=()=>{this.currentOnEndCallback===t&&(this.currentOnEndCallback=null,t());},i.onerror=()=>{this.currentOnEndCallback===t&&(this.currentOnEndCallback=null,t());}),this.currentUtterance=i,this.speakingSubject.next(!0);let o=i.onend,E=i.onerror;return i.onend=C=>{this.speakingSubject.next(!1),o&&o.call(i,C);},i.onerror=C=>{this.speakingSubject.next(!1),E&&E.call(i,C);},speechSynthesis.speak(i),console.log("[VOICE-SERVICE] Started speaking:",e.substring(0,50)+"..."),!0}catch(i){return console.error("[VOICE-SERVICE] Error speaking:",i),false}})}stopSpeech(){if(this.currentUtterance||speechSynthesis.speaking){if(speechSynthesis.cancel(),this.currentUtterance=null,this.currentOnEndCallback){let e=this.currentOnEndCallback;this.currentOnEndCallback=null,e();}this.speakingSubject.next(false),console.log("[VOICE-SERVICE] Speech stopped");}}ding(){try{let e=new(window.AudioContext||window.webkitAudioContext),t=e.createOscillator(),n=e.createGain();t.connect(n),n.connect(e.destination),t.frequency.setValueAtTime(800,e.currentTime),n.gain.setValueAtTime(.1,e.currentTime),n.gain.exponentialRampToValueAtTime(.01,e.currentTime+.1),t.start(e.currentTime),t.stop(e.currentTime+.1),console.log("[VOICE-SERVICE] Notification sound played");}catch(e){console.error("[VOICE-SERVICE] Notification sound failed:",e);}}getVoicesForLanguage(){return dt$1(this,null,function*(){try{let e=this.language.slice(0,2),t=yield this.voices;if(!t||t.length===0)return console.warn("[VOICE-SERVICE] No voices available on system"),[];let n=t.filter(i=>i.lang.toLowerCase().startsWith(e)).sort((i,o)=>i.localService&&!o.localService?-1:!i.localService&&o.localService?1:i.name.localeCompare(o.name));return console.log("[VOICE-SERVICE] Found matching voices:",n.length,"for language:",e),n.map(i=>({name:i.name,lang:i.lang,localService:i.localService,default:i.default,displayName:this.formatVoiceDisplayName(i)}))}catch(e){return console.error("[VOICE-SERVICE] Error getting voices for language:",e),[]}})}formatVoiceDisplayName(e){let t=e.localService?"\u{1F3E0}":"\u2601\uFE0F",n=e.default?" \u2B50":"";return `${t} ${e.name} (${e.lang})${n}`}setSelectedVoice(e){return dt$1(this,null,function*(){if(!e){this.selectedVoice=void 0;return}let[t,n]=e.split("|");if(!t||!n){this.selectedVoice=void 0;return}let i=(yield this.voices)?.find(o=>o.name===t&&o.lang===n);i?(this.selectedVoice=i,console.log("[VOICE-SERVICE] Selected voice:",i.name,i.lang)):(this.selectedVoice=void 0,console.warn("[VOICE-SERVICE] Voice not found:",t,n));})}updateSelectedVoiceForLanguage(){return dt$1(this,null,function*(){let e=yield this.getVoicesForLanguage();if(e.length===0){console.warn("[VOICE-SERVICE] No voices available for language:",this.language),this.selectedVoice=void 0,this.preferencesService.setSelectedVoice(null);return}let t=this.preferencesService.getSelectedVoice();if(t){let[i,o]=t.split("|"),E=o?.slice(0,2),C=this.language.slice(0,2);if(E===C&&e.some(q=>q.name===i&&q.lang===o)){console.log("[VOICE-SERVICE] Keeping current voice for language:",t);return}}let n=e[0];if(n){let i=`${n.name}|${n.lang}`;this.preferencesService.setSelectedVoice(i),console.log("[VOICE-SERVICE] Auto-selected voice for language change:",n.displayName);}})}testSelectedVoice(){setTimeout(()=>{if(!this.selectedVoice){console.log("[VOICE-SERVICE] No voice selected for test");return}this.stopSpeech();let e=this.getTestText();e&&this.speak(e);},100);}getTestText(){let e=this.language.slice(0,2),t={fr:"Bonjour, ceci est un test de la voix s\xE9lectionn\xE9e.",en:"Hello, this is a test of the selected voice.",es:"Hola, esta es una prueba de la voz seleccionada.",de:"Hallo, dies ist ein Test der ausgew\xE4hlten Stimme.",it:"Ciao, questo \xE8 un test della voce selezionata.",pt:"Ol\xE1, este \xE9 um teste da voz selecionada.",ja:"\u3053\u3093\u306B\u3061\u306F\u3001\u3053\u308C\u306F\u9078\u629E\u3055\u308C\u305F\u97F3\u58F0\u306E\u30C6\u30B9\u30C8\u3067\u3059\u3002",ko:"\uC548\uB155\uD558\uC138\uC694, \uC774\uAC83\uC740 \uC120\uD0DD\uB41C \uC74C\uC131\uC758 \uD14C\uC2A4\uD2B8\uC785\uB2C8\uB2E4.",zh:"\u4F60\u597D\uFF0C\u8FD9\u662F\u6240\u9009\u8BED\u97F3\u7684\u6D4B\u8BD5\u3002",ru:"\u041F\u0440\u0438\u0432\u0435\u0442, \u044D\u0442\u043E \u0442\u0435\u0441\u0442 \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u043E\u0433\u043E \u0433\u043E\u043B\u043E\u0441\u0430.",ar:"\u0645\u0631\u062D\u0628\u0627\u060C \u0647\u0630\u0627 \u0627\u062E\u062A\u0628\u0627\u0631 \u0644\u0644\u0635\u0648\u062A \u0627\u0644\u0645\u062D\u062F\u062F."};return t[e]||t.en}extractPlainText(e){let t=e.replace(/[\u{1F600}-\u{1F64F}]|[\u{1F300}-\u{1F5FF}]|[\u{1F680}-\u{1F6FF}]|[\u{1F1E0}-\u{1F1FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]|⭐/gu,"").replace(/```[\s\S]*?```/g,"code block").replace(/`([^`]+)`/g,"$1").replace(/\*\*\*(.*?)\*\*\*/g,"$1").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/~~(.*?)~~/g,"$1").replace(/#{1,6}\s*(.*)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/https?:\/\/[^\s]+/g,"link").replace(/&nbsp;/g," ").replace(/&amp;/g,"and").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"');return t=this.addNaturalPunctuation(t),t.replace(/\s+/g," ").trim()}addNaturalPunctuation(e){return e.replace(/\n+/g,`
177
177
  `).split(`
178
- `).map(t=>this.addPeriodIfNeeded(t.trim())).filter(t=>t.length>0).join(" ")}addPeriodIfNeeded(e){return e?/[.!?;:]$/.test(e)?e:e+".":""}static \u0275fac=function(t){return new(t||c)};static \u0275prov=x({token:c,factory:c.\u0275fac,providedIn:"root"})};var rt=(c,e)=>e.code,at=(c,e)=>e.name+e.lang;function st(c,e){c&1&&(Cs(0,"div",17)(1,"mat-icon",39),JC(2,"warning"),hl(),Cs(3,"span",40),JC(4," Browser notifications have been blocked. To enable them, please reset the site permissions in your browser settings. "),hl()());}function ct(c,e){if(c&1&&(Cs(0,"option",25),JC(1),hl()),c&2){let t=e.$implicit;_g("value",t.code),sI(),Xg("",t.flag," ",t.label);}}function lt(c,e){c&1&&(Cs(0,"option",32),JC(1,"Loading voices..."),hl());}function dt(c,e){c&1&&(Cs(0,"option",32),JC(1,"No voice available"),hl());}function pt(c,e){if(c&1&&(Cs(0,"option",25),JC(1),hl()),c&2){let t=e.$implicit;_g("value",t.name+"|"+t.lang),sI(),Dl(" ",t.displayName," ");}}var Ye=class c{destroy$=new ue;selectedTheme="light";selectedThemeVariant="industry";selectedVoiceLanguage="en-US";useEnterToSend=false;printTechnicalMessages=false;showTechnicalMessages=true;showWarningMessages=true;voiceInputMode="browser";voiceAnnounceEnabled=false;voiceMode="speech";voiceReadFullText=false;voiceVolume=80;voiceRate=120;agentNotificationEnabled=false;notificationSoundEnabled=true;browserNotificationEnabled=false;browserNotificationDenied=false;missionPreviewEnabled=false;availableVoices=[];selectedVoiceId=null;loadingVoices=false;voiceLanguageOptions=[{code:"fr-FR",label:"Fran\xE7ais",flag:"\u{1F1EB}\u{1F1F7}"},{code:"en-US",label:"English (US)",flag:"\u{1F1FA}\u{1F1F8}"},{code:"en-GB",label:"English (UK)",flag:"\u{1F1EC}\u{1F1E7}"},{code:"es-ES",label:"Espa\xF1ol",flag:"\u{1F1EA}\u{1F1F8}"},{code:"de-DE",label:"Deutsch",flag:"\u{1F1E9}\u{1F1EA}"},{code:"it-IT",label:"Italiano",flag:"\u{1F1EE}\u{1F1F9}"},{code:"pt-BR",label:"Portugu\xEAs",flag:"\u{1F1E7}\u{1F1F7}"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E",flag:"\u{1F1EF}\u{1F1F5}"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4",flag:"\u{1F1F0}\u{1F1F7}"},{code:"zh-CN",label:"\u4E2D\u6587 (\u7B80\u4F53)",flag:"\u{1F1E8}\u{1F1F3}"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",flag:"\u{1F1F7}\u{1F1FA}"},{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",flag:"\u{1F1F8}\u{1F1E6}"}];preferencesService=g(L);voiceSynthesisService=g(z);themeService=g(me);ngOnInit(){let e=this.themeService.getCurrentTheme();this.selectedTheme=e.mode,this.selectedThemeVariant=e.variant,this.selectedVoiceLanguage=this.preferencesService.getVoiceLanguage(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.printTechnicalMessages=this.preferencesService.getPrintTechnicalMessages(),this.showTechnicalMessages=!this.preferencesService.getHideTechnicalMessages(),this.showWarningMessages=!this.preferencesService.getHideWarningMessages(),this.voiceInputMode=this.preferencesService.getVoiceInputMode(),this.voiceAnnounceEnabled=this.preferencesService.getVoiceAnnounceEnabled(),this.voiceMode=this.preferencesService.getVoiceMode(),this.voiceReadFullText=this.preferencesService.getVoiceReadFullText(),this.voiceVolume=Math.round(this.preferencesService.getVoiceVolume()*100),this.voiceRate=Math.round(this.preferencesService.getVoiceRate()*100),this.selectedVoiceId=this.preferencesService.getSelectedVoice(),this.agentNotificationEnabled=this.preferencesService.getAgentNotificationEnabled(),this.notificationSoundEnabled=this.preferencesService.getNotificationSoundEnabled(),this.browserNotificationEnabled=this.preferencesService.getBrowserNotificationEnabled(),this.missionPreviewEnabled=this.preferencesService.getMissionPreviewEnabled(),this.loadAvailableVoices(),this.themeService.currentTheme$.pipe(zy(this.destroy$)).subscribe(t=>{this.selectedTheme=t.mode,this.selectedThemeVariant=t.variant;}),this.preferencesService.voiceLanguage$.pipe(zy(this.destroy$)).subscribe(t=>{this.selectedVoiceLanguage=t;}),this.preferencesService.enterToSend$.pipe(zy(this.destroy$)).subscribe(t=>{this.useEnterToSend=t;}),this.preferencesService.printTechnicalMessages$.pipe(zy(this.destroy$)).subscribe(t=>{this.printTechnicalMessages=t;}),this.preferencesService.hideTechnicalMessages$.pipe(zy(this.destroy$)).subscribe(t=>{this.showTechnicalMessages=!t;}),this.preferencesService.hideWarningMessages$.pipe(zy(this.destroy$)).subscribe(t=>{this.showWarningMessages=!t;}),this.preferencesService.voiceInputMode$.pipe(zy(this.destroy$)).subscribe(t=>{this.voiceInputMode=t;}),this.preferencesService.voiceAnnounceEnabled$.pipe(zy(this.destroy$)).subscribe(t=>{this.voiceAnnounceEnabled=t;}),this.preferencesService.voiceMode$.pipe(zy(this.destroy$)).subscribe(t=>{this.voiceMode=t;}),this.preferencesService.voiceReadFullText$.pipe(zy(this.destroy$)).subscribe(t=>{this.voiceReadFullText=t;}),this.preferencesService.voiceVolume$.pipe(zy(this.destroy$)).subscribe(t=>{this.voiceVolume=Math.round(t*100);}),this.preferencesService.voiceRate$.pipe(zy(this.destroy$)).subscribe(t=>{this.voiceRate=Math.round(t*100);}),this.preferencesService.selectedVoice$.pipe(zy(this.destroy$)).subscribe(t=>{this.selectedVoiceId=t;}),this.preferencesService.voiceLanguage$.pipe(zy(this.destroy$)).subscribe(()=>{this.loadAvailableVoices();}),this.preferencesService.agentNotificationEnabled$.pipe(zy(this.destroy$)).subscribe(t=>{this.agentNotificationEnabled=t;}),this.preferencesService.notificationSoundEnabled$.pipe(zy(this.destroy$)).subscribe(t=>{this.notificationSoundEnabled=t;}),this.preferencesService.browserNotificationEnabled$.pipe(zy(this.destroy$)).subscribe(t=>{this.browserNotificationEnabled=t,this.checkNotificationPermission();}),this.preferencesService.missionPreviewEnabled$.pipe(zy(this.destroy$)).subscribe(t=>{this.missionPreviewEnabled=t;});}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete();}onThemeChange(){console.log("[OPTIONS] Theme changed to:",this.selectedTheme),this.themeService.setTheme({variant:this.selectedThemeVariant,mode:this.selectedTheme});}onVoiceLanguageChange(){console.log("[OPTIONS] Voice language changed to:",this.selectedVoiceLanguage),this.preferencesService.setVoiceLanguage(this.selectedVoiceLanguage);}onEnterToSendChange(){console.log("[OPTIONS] Enter to send changed to:",this.useEnterToSend),this.preferencesService.setEnterToSend(this.useEnterToSend);}onPrintTechnicalMessagesChange(){console.log("[OPTIONS] Print technical messages changed to:",this.printTechnicalMessages),this.preferencesService.setPrintTechnicalMessages(this.printTechnicalMessages);}onShowTechnicalMessagesChange(){let e=!this.showTechnicalMessages;console.log("[OPTIONS] Show technical messages changed to:",this.showTechnicalMessages,"(hide:",e,")"),this.preferencesService.setHideTechnicalMessages(e);}onShowWarningMessagesChange(){let e=!this.showWarningMessages;console.log("[OPTIONS] Show warning messages changed to:",this.showWarningMessages,"(hide:",e,")"),this.preferencesService.setHideWarningMessages(e);}onVoiceInputModeChange(e){let t=e.target.value;console.log("[OPTIONS] Voice input mode changed to:",t),this.preferencesService.setVoiceInputMode(t);}onVoiceAnnounceEnabledChange(){console.log("[OPTIONS] Voice announce enabled changed to:",this.voiceAnnounceEnabled),this.preferencesService.setVoiceAnnounceEnabled(this.voiceAnnounceEnabled);}onVoiceModeChange(){console.log("[OPTIONS] Voice mode changed to:",this.voiceMode),this.preferencesService.setVoiceMode(this.voiceMode);}onVoiceReadFullTextChange(){console.log("[OPTIONS] Voice read full text changed to:",this.voiceReadFullText),this.preferencesService.setVoiceReadFullText(this.voiceReadFullText);}onVoiceVolumeChange(){let e=this.voiceVolume/100;console.log("[OPTIONS] Voice volume changed to:",e),this.preferencesService.setVoiceVolume(e);}onVoiceRateChange(){let e=this.voiceRate/100;console.log("[OPTIONS] Voice rate changed to:",e),this.preferencesService.setVoiceRate(e);}loadAvailableVoices(){return dt$1(this,null,function*(){this.loadingVoices=true;try{this.availableVoices=yield this.voiceSynthesisService.getVoicesForLanguage(),console.log("[OPTIONS] Loaded",this.availableVoices.length,"voices for current language");}catch(e){console.error("[OPTIONS] Error loading voices:",e),this.availableVoices=[];}finally{this.loadingVoices=false;}})}onSelectedVoiceChange(){console.log("[OPTIONS] Selected voice changed to:",this.selectedVoiceId),this.preferencesService.setSelectedVoice(this.selectedVoiceId);}testVoice(){console.log("[OPTIONS] Testing voice with current settings"),this.voiceSynthesisService.testSelectedVoice();}onAgentNotificationEnabledChange(){console.log("[OPTIONS] Agent notification enabled changed to:",this.agentNotificationEnabled),this.preferencesService.setAgentNotificationEnabled(this.agentNotificationEnabled);}onNotificationSoundEnabledChange(){console.log("[OPTIONS] Notification sound enabled changed to:",this.notificationSoundEnabled),this.preferencesService.setNotificationSoundEnabled(this.notificationSoundEnabled);}onBrowserNotificationEnabledChange(){console.log("[OPTIONS] Browser notification enabled changed to:",this.browserNotificationEnabled),this.preferencesService.setBrowserNotificationEnabled(this.browserNotificationEnabled);}onMissionPreviewEnabledChange(){console.log("[OPTIONS] Mission preview panel enabled changed to:",this.missionPreviewEnabled),this.preferencesService.setMissionPreviewEnabled(this.missionPreviewEnabled);}checkNotificationPermission(){"Notification"in window&&(this.browserNotificationDenied=Notification.permission==="denied",console.log("[OPTIONS] Notification permission status:",Notification.permission));}static \u0275fac=function(t){return new(t||c)};static \u0275cmp=jw({type:c,selectors:[["app-options-panel"]],decls:168,vars:37,consts:[[1,"options-content"],[1,"option-section"],[1,"section-title"],[1,"option-group"],[1,"radio-group"],[1,"option-radio"],["type","radio","name","theme","value","light",3,"ngModelChange","change","ngModel"],[1,"radio-mark"],["type","radio","name","theme","value","dark",3,"ngModelChange","change","ngModel"],["type","radio","name","theme","value","system",3,"ngModelChange","change","ngModel"],[1,"option-label"],["type","radio","name","enterBehavior",3,"ngModelChange","change","value","ngModel"],[1,"toggle-option"],["color","primary",3,"ngModelChange","change","ngModel"],[1,"option-label-with-hint"],[1,"option-hint"],["color","primary",3,"ngModelChange","change","ngModel","disabled"],[1,"notification-error"],["for","voice-input-mode-select",1,"option-label"],["id","voice-input-mode-select",1,"option-select",3,"change","value"],["value","browser"],["value","whisper"],["value","voice-message"],["for","voice-language-select",1,"option-label"],["id","voice-language-select",1,"option-select",3,"ngModelChange","change","ngModel"],[3,"value"],["type","radio","name","voiceAnnounce",3,"ngModelChange","change","value","ngModel"],["type","radio","name","voiceMode","value","speech",3,"ngModelChange","change","ngModel"],["type","radio","name","voiceMode","value","notification",3,"ngModelChange","change","ngModel"],["type","radio","name","voiceReadFull",3,"ngModelChange","change","value","ngModel"],["for","voice-select",1,"option-label"],["id","voice-select",1,"option-select",3,"ngModelChange","change","ngModel","disabled"],["value",""],["role","button","tabindex","0","title","Test voice with current settings",1,"test-voice-link",3,"click"],[1,"thread-name"],["for","voice-volume-slider",1,"option-label"],["id","voice-volume-slider","type","range","min","0","max","100","step","5",1,"option-slider",3,"ngModelChange","input","ngModel"],["for","voice-rate-slider",1,"option-label"],["id","voice-rate-slider","type","range","min","50","max","200","step","10",1,"option-slider",3,"ngModelChange","input","ngModel"],[1,"error-icon"],[1,"error-message"]],template:function(t,n){t&1&&(Cs(0,"div",0)(1,"div",1)(2,"div",2)(3,"mat-icon"),JC(4,"palette"),hl(),Cs(5,"span"),JC(6,"Appearance"),hl()(),Cs(7,"div",3)(8,"div",4)(9,"label",5)(10,"input",6),rm("ngModelChange",function(o){return iT(n.selectedTheme,o)||(n.selectedTheme=o),o}),kg("change",function(){return n.onThemeChange()}),hl(),ZI(),Mg(11,"span",7),JC(12," Light "),hl(),Cs(13,"label",5)(14,"input",8),rm("ngModelChange",function(o){return iT(n.selectedTheme,o)||(n.selectedTheme=o),o}),kg("change",function(){return n.onThemeChange()}),hl(),ZI(),Mg(15,"span",7),JC(16," Dark "),hl(),Cs(17,"label",5)(18,"input",9),rm("ngModelChange",function(o){return iT(n.selectedTheme,o)||(n.selectedTheme=o),o}),kg("change",function(){return n.onThemeChange()}),hl(),ZI(),Mg(19,"span",7),JC(20," System "),hl()()()(),Cs(21,"div",1)(22,"div",2)(23,"mat-icon"),JC(24,"chat_bubble_outline"),hl(),Cs(25,"span"),JC(26,"Messaging"),hl()(),Cs(27,"div",3)(28,"span",10),JC(29,"Send message behavior:"),hl(),Cs(30,"div",4)(31,"label",5)(32,"input",11),rm("ngModelChange",function(o){return iT(n.useEnterToSend,o)||(n.useEnterToSend=o),o}),kg("change",function(){return n.onEnterToSendChange()}),hl(),ZI(),Mg(33,"span",7),JC(34," Enter to send "),hl(),Cs(35,"label",5)(36,"input",11),rm("ngModelChange",function(o){return iT(n.useEnterToSend,o)||(n.useEnterToSend=o),o}),kg("change",function(){return n.onEnterToSendChange()}),hl(),ZI(),Mg(37,"span",7),JC(38," Enter for new line "),hl()()(),Cs(39,"div",3)(40,"div",12)(41,"span",10),JC(42,"Show technical messages"),hl(),Cs(43,"mat-slide-toggle",13),rm("ngModelChange",function(o){return iT(n.showTechnicalMessages,o)||(n.showTechnicalMessages=o),o}),kg("change",function(){return n.onShowTechnicalMessagesChange()}),hl(),ZI(),hl()(),Cs(44,"div",3)(45,"div",12)(46,"span",10),JC(47,"Show warning messages"),hl(),Cs(48,"mat-slide-toggle",13),rm("ngModelChange",function(o){return iT(n.showWarningMessages,o)||(n.showWarningMessages=o),o}),kg("change",function(){return n.onShowWarningMessagesChange()}),hl(),ZI(),hl()(),Cs(49,"div",3)(50,"div",12)(51,"span",10),JC(52,"Include technical messages in print"),hl(),Cs(53,"mat-slide-toggle",13),rm("ngModelChange",function(o){return iT(n.printTechnicalMessages,o)||(n.printTechnicalMessages=o),o}),kg("change",function(){return n.onPrintTechnicalMessagesChange()}),hl(),ZI(),hl()()(),Cs(54,"div",1)(55,"div",2)(56,"mat-icon"),JC(57,"rocket_launch"),hl(),Cs(58,"span"),JC(59,"Mission Control"),hl()(),Cs(60,"div",3)(61,"div",12)(62,"div",14)(63,"span",10),JC(64,"Side-by-side thread preview"),hl(),Cs(65,"span",15),JC(66,"Click a mission card to open a preview panel. Recommended for large screens."),hl()(),Cs(67,"mat-slide-toggle",13),rm("ngModelChange",function(o){return iT(n.missionPreviewEnabled,o)||(n.missionPreviewEnabled=o),o}),kg("change",function(){return n.onMissionPreviewEnabledChange()}),hl(),ZI(),hl()()(),Cs(68,"div",1)(69,"div",2)(70,"mat-icon"),JC(71,"notifications"),hl(),Cs(72,"span"),JC(73,"Notifications"),hl()(),Cs(74,"div",3)(75,"div",12)(76,"span",10),JC(77,"Notify when the agent answers or requests input"),hl(),Cs(78,"mat-slide-toggle",13),rm("ngModelChange",function(o){return iT(n.agentNotificationEnabled,o)||(n.agentNotificationEnabled=o),o}),kg("change",function(){return n.onAgentNotificationEnabledChange()}),hl(),ZI(),hl()(),Cs(79,"div",3)(80,"div",12)(81,"span",10),JC(82,"Notification sound"),hl(),Cs(83,"mat-slide-toggle",16),rm("ngModelChange",function(o){return iT(n.notificationSoundEnabled,o)||(n.notificationSoundEnabled=o),o}),kg("change",function(){return n.onNotificationSoundEnabledChange()}),hl(),ZI(),hl()(),Cs(84,"div",3)(85,"div",12)(86,"span",10),JC(87,"Browser notification"),hl(),Cs(88,"mat-slide-toggle",16),rm("ngModelChange",function(o){return iT(n.browserNotificationEnabled,o)||(n.browserNotificationEnabled=o),o}),kg("change",function(){return n.onBrowserNotificationEnabledChange()}),hl(),ZI(),hl(),aC(89,st,5,0,"div",17),hl()(),Cs(90,"div",1)(91,"div",2)(92,"mat-icon"),JC(93,"record_voice_over"),hl(),Cs(94,"span"),JC(95,"Voice & Speech"),hl()(),Cs(96,"div",3)(97,"label",18),JC(98,"Voice input method:"),hl(),Cs(99,"select",19),kg("change",function(o){return n.onVoiceInputModeChange(o)}),Cs(100,"option",20),JC(101,"Browser (real-time)"),hl(),Cs(102,"option",21),JC(103,"Whisper (higher accuracy)"),hl(),Cs(104,"option",22),JC(105,"Voice message (send audio)"),hl()()(),Cs(106,"div",3)(107,"label",23),JC(108,"Voice recognition language:"),hl(),Cs(109,"select",24),rm("ngModelChange",function(o){return iT(n.selectedVoiceLanguage,o)||(n.selectedVoiceLanguage=o),o}),kg("change",function(){return n.onVoiceLanguageChange()}),dC(110,ct,2,3,"option",25,rt),hl(),ZI(),hl(),Cs(112,"div",3)(113,"span",10),JC(114,"Automatic announcement:"),hl(),Cs(115,"div",4)(116,"label",5)(117,"input",26),rm("ngModelChange",function(o){return iT(n.voiceAnnounceEnabled,o)||(n.voiceAnnounceEnabled=o),o}),kg("change",function(){return n.onVoiceAnnounceEnabledChange()}),hl(),ZI(),Mg(118,"span",7),JC(119," Enabled "),hl(),Cs(120,"label",5)(121,"input",26),rm("ngModelChange",function(o){return iT(n.voiceAnnounceEnabled,o)||(n.voiceAnnounceEnabled=o),o}),kg("change",function(){return n.onVoiceAnnounceEnabledChange()}),hl(),ZI(),Mg(122,"span",7),JC(123," Disabled "),hl()()(),Cs(124,"div",3)(125,"span",10),JC(126,"Voice mode:"),hl(),Cs(127,"div",4)(128,"label",5)(129,"input",27),rm("ngModelChange",function(o){return iT(n.voiceMode,o)||(n.voiceMode=o),o}),kg("change",function(){return n.onVoiceModeChange()}),hl(),ZI(),Mg(130,"span",7),JC(131," Voice synthesis "),hl(),Cs(132,"label",5)(133,"input",28),rm("ngModelChange",function(o){return iT(n.voiceMode,o)||(n.voiceMode=o),o}),kg("change",function(){return n.onVoiceModeChange()}),hl(),ZI(),Mg(134,"span",7),JC(135," Sound notification "),hl()()(),Cs(136,"div",3)(137,"span",10),JC(138,"Message reading:"),hl(),Cs(139,"div",4)(140,"label",5)(141,"input",29),rm("ngModelChange",function(o){return iT(n.voiceReadFullText,o)||(n.voiceReadFullText=o),o}),kg("change",function(){return n.onVoiceReadFullTextChange()}),hl(),ZI(),Mg(142,"span",7),JC(143," Full message "),hl(),Cs(144,"label",5)(145,"input",29),rm("ngModelChange",function(o){return iT(n.voiceReadFullText,o)||(n.voiceReadFullText=o),o}),kg("change",function(){return n.onVoiceReadFullTextChange()}),hl(),ZI(),Mg(146,"span",7),JC(147," First paragraphs only "),hl()()(),Cs(148,"div",3)(149,"label",30),JC(150,"Selected voice:"),hl(),Cs(151,"select",31),rm("ngModelChange",function(o){return iT(n.selectedVoiceId,o)||(n.selectedVoiceId=o),o}),kg("change",function(){return n.onSelectedVoiceChange()}),aC(152,lt,2,0,"option",32),aC(153,dt,2,0,"option",32),dC(154,pt,2,2,"option",25,at),hl(),ZI(),Mg(156,"div",10),Cs(157,"a",33),kg("click",function(){return n.testVoice()}),Cs(158,"span",34),JC(159,"Test voice"),hl()()(),Cs(160,"div",3)(161,"label",35),JC(162),hl(),Cs(163,"input",36),rm("ngModelChange",function(o){return iT(n.voiceVolume,o)||(n.voiceVolume=o),o}),kg("input",function(){return n.onVoiceVolumeChange()}),hl(),ZI(),hl(),Cs(164,"div",3)(165,"label",37),JC(166),hl(),Cs(167,"input",38),rm("ngModelChange",function(o){return iT(n.voiceRate,o)||(n.voiceRate=o),o}),kg("input",function(){return n.onVoiceRateChange()}),hl(),ZI(),hl()()()),t&2&&(sI(10),nm("ngModel",n.selectedTheme),QI(),sI(4),nm("ngModel",n.selectedTheme),QI(),sI(4),nm("ngModel",n.selectedTheme),QI(),sI(14),_g("value",true),nm("ngModel",n.useEnterToSend),QI(),sI(4),_g("value",false),nm("ngModel",n.useEnterToSend),QI(),sI(7),nm("ngModel",n.showTechnicalMessages),QI(),sI(5),nm("ngModel",n.showWarningMessages),QI(),sI(5),nm("ngModel",n.printTechnicalMessages),QI(),sI(14),nm("ngModel",n.missionPreviewEnabled),QI(),sI(11),nm("ngModel",n.agentNotificationEnabled),QI(),sI(5),nm("ngModel",n.notificationSoundEnabled),_g("disabled",!n.agentNotificationEnabled),QI(),sI(5),nm("ngModel",n.browserNotificationEnabled),_g("disabled",!n.agentNotificationEnabled||n.browserNotificationDenied),QI(),sI(),cC(n.browserNotificationDenied?89:-1),sI(10),_g("value",n.voiceInputMode),sI(10),nm("ngModel",n.selectedVoiceLanguage),QI(),sI(),fC(n.voiceLanguageOptions),sI(7),_g("value",true),nm("ngModel",n.voiceAnnounceEnabled),QI(),sI(4),_g("value",false),nm("ngModel",n.voiceAnnounceEnabled),QI(),sI(8),nm("ngModel",n.voiceMode),QI(),sI(4),nm("ngModel",n.voiceMode),QI(),sI(8),_g("value",true),nm("ngModel",n.voiceReadFullText),QI(),sI(4),_g("value",false),nm("ngModel",n.voiceReadFullText),QI(),sI(6),nm("ngModel",n.selectedVoiceId),_g("disabled",n.loadingVoices||n.availableVoices.length===0),QI(),sI(),cC(n.loadingVoices?152:-1),sI(),cC(!n.loadingVoices&&n.availableVoices.length===0?153:-1),sI(),fC(n.availableVoices),sI(8),Dl("Volume: ",n.voiceVolume,"%"),sI(),nm("ngModel",n.voiceVolume),QI(),sI(3),Dl("Speed: ",n.voiceRate,"%"),sI(),nm("ngModel",n.voiceRate),QI());},dependencies:[ti,Qn,ei,Ye$1,_n,At,mn,Zn,cn,wt,se],styles:['.options-content[_ngcontent-%COMP%]{padding:0;width:100%}.option-group[_ngcontent-%COMP%]{padding:0 1rem 1rem;margin-bottom:1rem;border-bottom:1px solid var(--color-border-light)}.option-group[_ngcontent-%COMP%]:last-child{margin-bottom:0;padding-bottom:0;border-bottom:none}.option-label[_ngcontent-%COMP%]{display:block;margin-bottom:.5rem;font-weight:500;color:var(--color-text);font-size:.875rem}.toggle-option[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;gap:1rem}.toggle-option[_ngcontent-%COMP%] .option-label[_ngcontent-%COMP%]{margin-bottom:0;flex:1}.toggle-option[_ngcontent-%COMP%] mat-slide-toggle[_ngcontent-%COMP%]{flex-shrink:0}.option-label-with-hint[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.25rem;flex:1}.option-label-with-hint[_ngcontent-%COMP%] .option-label[_ngcontent-%COMP%]{margin-bottom:0}.option-label-with-hint[_ngcontent-%COMP%] .option-hint[_ngcontent-%COMP%]{font-size:.775rem;color:var(--color-text-secondary);line-height:1.4}.option-select[_ngcontent-%COMP%]{width:100%;padding:.5rem;border:1px solid var(--color-border);border-radius:4px;background:var(--color-input-bg);color:var(--color-text);font-size:.875rem;cursor:pointer}.option-select[_ngcontent-%COMP%]:focus{outline:none;border-color:var(--color-primary);box-shadow:0 0 0 3px #7064fb1a}.option-select[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.option-select[_ngcontent-%COMP%] option[_ngcontent-%COMP%]{padding:.5rem}.option-checkbox[_ngcontent-%COMP%]{display:flex;align-items:center;cursor:pointer;font-size:.875rem;color:var(--color-text);-webkit-user-select:none;user-select:none}.option-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{display:none}.option-checkbox[_ngcontent-%COMP%] .checkmark[_ngcontent-%COMP%]{width:18px;height:18px;border:2px solid var(--color-border);border-radius:3px;margin-right:.75rem;display:flex;align-items:center;justify-content:center;transition:all .2s ease;flex-shrink:0}.option-checkbox[_ngcontent-%COMP%] .checkmark[_ngcontent-%COMP%]:after{content:"";width:10px;height:6px;border-left:2px solid transparent;border-bottom:2px solid transparent;transform:rotate(-45deg);transition:all .2s ease;opacity:0}.option-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]:checked + .checkmark[_ngcontent-%COMP%]{background-color:var(--color-primary);border-color:var(--color-primary)}.option-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]:checked + .checkmark[_ngcontent-%COMP%]:after{border-left-color:#fff;border-bottom-color:#fff;opacity:1}.option-checkbox[_ngcontent-%COMP%]:hover .checkmark[_ngcontent-%COMP%]{border-color:var(--color-primary)}.option-checkbox[_ngcontent-%COMP%]:focus-within .checkmark[_ngcontent-%COMP%]{box-shadow:0 0 0 3px #7064fb1a}.option-section[_ngcontent-%COMP%]{padding-top:1rem;margin-top:1rem;border-top:2px solid var(--color-border)}.option-section[_ngcontent-%COMP%]:first-child{border-top:none;padding-top:0;margin-top:0}.section-title[_ngcontent-%COMP%]{margin:0 0 1rem;padding:0 1rem;font-size:.9rem;font-weight:600;color:var(--color-text);display:flex;align-items:center;gap:.5rem}.section-title[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}.radio-group[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.option-radio[_ngcontent-%COMP%]{display:flex;align-items:center;cursor:pointer;font-size:.875rem;color:var(--color-text);-webkit-user-select:none;user-select:none}.option-radio[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{display:none}.option-radio[_ngcontent-%COMP%] .radio-mark[_ngcontent-%COMP%]{width:16px;height:16px;border:2px solid var(--color-border);border-radius:50%;margin-right:.5rem;display:flex;align-items:center;justify-content:center;transition:all .2s ease;flex-shrink:0;position:relative}.option-radio[_ngcontent-%COMP%] .radio-mark[_ngcontent-%COMP%]:after{content:"";width:8px;height:8px;border-radius:50%;background-color:var(--color-primary);transition:all .2s ease;opacity:0;transform:scale(0)}.option-radio[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]:checked + .radio-mark[_ngcontent-%COMP%]{border-color:var(--color-primary)}.option-radio[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]:checked + .radio-mark[_ngcontent-%COMP%]:after{opacity:1;transform:scale(1)}.option-radio[_ngcontent-%COMP%]:hover .radio-mark[_ngcontent-%COMP%]{border-color:var(--color-primary)}.option-radio[_ngcontent-%COMP%]:focus-within .radio-mark[_ngcontent-%COMP%]{box-shadow:0 0 0 3px #7064fb1a}.option-slider[_ngcontent-%COMP%]{width:100%;height:6px;border-radius:3px;background:var(--color-bg-solid);outline:none;cursor:pointer;-webkit-appearance:none;appearance:none}.option-slider[_ngcontent-%COMP%]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:20px;height:20px;border-radius:50%;background:var(--color-primary);cursor:pointer;border:2px solid white;box-shadow:0 2px 6px #0003;transition:all .2s ease}.option-slider[_ngcontent-%COMP%]::-webkit-slider-thumb:hover{transform:scale(1.1);box-shadow:0 2px 8px #0000004d}.option-slider[_ngcontent-%COMP%]::-moz-range-thumb{width:20px;height:20px;border-radius:50%;background:var(--color-primary);cursor:pointer;border:2px solid white;box-shadow:0 2px 6px #0003;transition:all .2s ease}.option-slider[_ngcontent-%COMP%]::-moz-range-thumb:hover{transform:scale(1.1);box-shadow:0 2px 8px #0000004d}.option-slider[_ngcontent-%COMP%]::-webkit-slider-track{height:6px;border-radius:3px;background:var(--color-bg-secondary)}.option-slider[_ngcontent-%COMP%]::-moz-range-track{height:6px;border-radius:3px;background:var(--color-bg-secondary);border:none}.option-slider[_ngcontent-%COMP%]:focus{outline:none}.option-slider[_ngcontent-%COMP%]:focus::-webkit-slider-thumb{box-shadow:0 0 0 3px #7064fb4d,0 2px 6px #0003}.option-slider[_ngcontent-%COMP%]:focus::-moz-range-thumb{box-shadow:0 0 0 3px #7064fb4d,0 2px 6px #0003}.test-voice-btn[_ngcontent-%COMP%]{width:100%;padding:.75rem 1rem;background:var(--color-primary);color:#fff;border:none;border-radius:6px;font-size:.875rem;font-weight:500;cursor:pointer;transition:all .2s ease;display:flex;align-items:center;justify-content:center;gap:.5rem}.test-voice-btn[_ngcontent-%COMP%]:hover{background:var(--color-primary-hover);transform:translateY(-1px);box-shadow:0 2px 8px #7064fb4d}.test-voice-btn[_ngcontent-%COMP%]:active{transform:translateY(0);box-shadow:0 1px 4px #7064fb4d}.test-voice-btn[_ngcontent-%COMP%]:focus{outline:none;box-shadow:0 0 0 3px #7064fb4d}.test-voice-btn[_ngcontent-%COMP%]:disabled{background:var(--color-bg-secondary);color:var(--color-text-secondary);cursor:not-allowed;transform:none;box-shadow:none}.test-voice-link[_ngcontent-%COMP%]{text-decoration-thickness:1.5px;text-underline-offset:3px;background:transparent;border:none;padding:0;font-size:.775rem;font-weight:400;cursor:pointer;transition:all .2s ease;display:inline-flex;align-items:center;justify-content:center;gap:.5rem;text-decoration:underline}.test-voice-link[_ngcontent-%COMP%]:hover{color:var(--color-primary-hover, var(--color-primary));text-decoration-thickness:2px}.test-voice-link[_ngcontent-%COMP%]:active{opacity:.8}.test-voice-link[_ngcontent-%COMP%]:focus{outline:2px solid var(--color-primary);outline-offset:2px}.test-voice-link[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}.notification-error[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.5rem;padding:.75rem;margin-top:.75rem;background-color:#d32f2f1a;border:1px solid rgba(211,47,47,.3);border-radius:6px;font-size:.8125rem;line-height:1.5}.notification-error[_ngcontent-%COMP%] .error-icon[_ngcontent-%COMP%]{color:#d32f2f;font-size:20px;width:20px;height:20px;flex-shrink:0;margin-top:2px}.notification-error[_ngcontent-%COMP%] .error-message[_ngcontent-%COMP%]{color:var(--color-text);flex:1}.notification-error[_ngcontent-%COMP%]{margin-top:.75rem;padding:.75rem;background-color:#f443361a;border:1px solid rgba(244,67,54,.3);border-radius:6px;display:flex;align-items:flex-start;gap:.5rem}.notification-error[_ngcontent-%COMP%] .error-icon[_ngcontent-%COMP%]{color:#f44336;font-size:20px;width:20px;height:20px;flex-shrink:0;margin-top:2px}.notification-error[_ngcontent-%COMP%] .error-message[_ngcontent-%COMP%]{font-size:.8125rem;color:var(--color-text);line-height:1.5;flex:1}'],changeDetection:1})};function Qe(c){let e=c.args??"",t;try{let n=JSON.parse(e);t=JSON.stringify(n,null,2);}catch(n){t=e;}return `\u{1F527} ${c.name}
178
+ `).map(t=>this.addPeriodIfNeeded(t.trim())).filter(t=>t.length>0).join(" ")}addPeriodIfNeeded(e){return e?/[.!?;:]$/.test(e)?e:e+".":""}static \u0275fac=function(t){return new(t||c)};static \u0275prov=x({token:c,factory:c.\u0275fac,providedIn:"root"})};var rt=(c,e)=>e.code,at=(c,e)=>e.name+e.lang;function st(c,e){c&1&&(Cs(0,"div",17)(1,"mat-icon",39),JC(2,"warning"),hl(),Cs(3,"span",40),JC(4," Browser notifications have been blocked. To enable them, please reset the site permissions in your browser settings. "),hl()());}function ct(c,e){if(c&1&&(Cs(0,"option",25),JC(1),hl()),c&2){let t=e.$implicit;xg("value",t.code),sI(),tm("",t.flag," ",t.label);}}function lt(c,e){c&1&&(Cs(0,"option",32),JC(1,"Loading voices..."),hl());}function dt(c,e){c&1&&(Cs(0,"option",32),JC(1,"No voice available"),hl());}function pt(c,e){if(c&1&&(Cs(0,"option",25),JC(1),hl()),c&2){let t=e.$implicit;xg("value",t.name+"|"+t.lang),sI(),Dl(" ",t.displayName," ");}}var Ye=class c{destroy$=new ue;selectedTheme="light";selectedThemeVariant="industry";selectedVoiceLanguage="en-US";useEnterToSend=false;printTechnicalMessages=false;showTechnicalMessages=true;showWarningMessages=true;voiceInputMode="browser";voiceAnnounceEnabled=false;voiceMode="speech";voiceReadFullText=false;voiceVolume=80;voiceRate=120;agentNotificationEnabled=false;notificationSoundEnabled=true;browserNotificationEnabled=false;browserNotificationDenied=false;missionPreviewEnabled=false;availableVoices=[];selectedVoiceId=null;loadingVoices=false;voiceLanguageOptions=[{code:"fr-FR",label:"Fran\xE7ais",flag:"\u{1F1EB}\u{1F1F7}"},{code:"en-US",label:"English (US)",flag:"\u{1F1FA}\u{1F1F8}"},{code:"en-GB",label:"English (UK)",flag:"\u{1F1EC}\u{1F1E7}"},{code:"es-ES",label:"Espa\xF1ol",flag:"\u{1F1EA}\u{1F1F8}"},{code:"de-DE",label:"Deutsch",flag:"\u{1F1E9}\u{1F1EA}"},{code:"it-IT",label:"Italiano",flag:"\u{1F1EE}\u{1F1F9}"},{code:"pt-BR",label:"Portugu\xEAs",flag:"\u{1F1E7}\u{1F1F7}"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E",flag:"\u{1F1EF}\u{1F1F5}"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4",flag:"\u{1F1F0}\u{1F1F7}"},{code:"zh-CN",label:"\u4E2D\u6587 (\u7B80\u4F53)",flag:"\u{1F1E8}\u{1F1F3}"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",flag:"\u{1F1F7}\u{1F1FA}"},{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",flag:"\u{1F1F8}\u{1F1E6}"}];preferencesService=g(L);voiceSynthesisService=g(z);themeService=g(me);ngOnInit(){let e=this.themeService.getCurrentTheme();this.selectedTheme=e.mode,this.selectedThemeVariant=e.variant,this.selectedVoiceLanguage=this.preferencesService.getVoiceLanguage(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.printTechnicalMessages=this.preferencesService.getPrintTechnicalMessages(),this.showTechnicalMessages=!this.preferencesService.getHideTechnicalMessages(),this.showWarningMessages=!this.preferencesService.getHideWarningMessages(),this.voiceInputMode=this.preferencesService.getVoiceInputMode(),this.voiceAnnounceEnabled=this.preferencesService.getVoiceAnnounceEnabled(),this.voiceMode=this.preferencesService.getVoiceMode(),this.voiceReadFullText=this.preferencesService.getVoiceReadFullText(),this.voiceVolume=Math.round(this.preferencesService.getVoiceVolume()*100),this.voiceRate=Math.round(this.preferencesService.getVoiceRate()*100),this.selectedVoiceId=this.preferencesService.getSelectedVoice(),this.agentNotificationEnabled=this.preferencesService.getAgentNotificationEnabled(),this.notificationSoundEnabled=this.preferencesService.getNotificationSoundEnabled(),this.browserNotificationEnabled=this.preferencesService.getBrowserNotificationEnabled(),this.missionPreviewEnabled=this.preferencesService.getMissionPreviewEnabled(),this.loadAvailableVoices(),this.themeService.currentTheme$.pipe(_d(this.destroy$)).subscribe(t=>{this.selectedTheme=t.mode,this.selectedThemeVariant=t.variant;}),this.preferencesService.voiceLanguage$.pipe(_d(this.destroy$)).subscribe(t=>{this.selectedVoiceLanguage=t;}),this.preferencesService.enterToSend$.pipe(_d(this.destroy$)).subscribe(t=>{this.useEnterToSend=t;}),this.preferencesService.printTechnicalMessages$.pipe(_d(this.destroy$)).subscribe(t=>{this.printTechnicalMessages=t;}),this.preferencesService.hideTechnicalMessages$.pipe(_d(this.destroy$)).subscribe(t=>{this.showTechnicalMessages=!t;}),this.preferencesService.hideWarningMessages$.pipe(_d(this.destroy$)).subscribe(t=>{this.showWarningMessages=!t;}),this.preferencesService.voiceInputMode$.pipe(_d(this.destroy$)).subscribe(t=>{this.voiceInputMode=t;}),this.preferencesService.voiceAnnounceEnabled$.pipe(_d(this.destroy$)).subscribe(t=>{this.voiceAnnounceEnabled=t;}),this.preferencesService.voiceMode$.pipe(_d(this.destroy$)).subscribe(t=>{this.voiceMode=t;}),this.preferencesService.voiceReadFullText$.pipe(_d(this.destroy$)).subscribe(t=>{this.voiceReadFullText=t;}),this.preferencesService.voiceVolume$.pipe(_d(this.destroy$)).subscribe(t=>{this.voiceVolume=Math.round(t*100);}),this.preferencesService.voiceRate$.pipe(_d(this.destroy$)).subscribe(t=>{this.voiceRate=Math.round(t*100);}),this.preferencesService.selectedVoice$.pipe(_d(this.destroy$)).subscribe(t=>{this.selectedVoiceId=t;}),this.preferencesService.voiceLanguage$.pipe(_d(this.destroy$)).subscribe(()=>{this.loadAvailableVoices();}),this.preferencesService.agentNotificationEnabled$.pipe(_d(this.destroy$)).subscribe(t=>{this.agentNotificationEnabled=t;}),this.preferencesService.notificationSoundEnabled$.pipe(_d(this.destroy$)).subscribe(t=>{this.notificationSoundEnabled=t;}),this.preferencesService.browserNotificationEnabled$.pipe(_d(this.destroy$)).subscribe(t=>{this.browserNotificationEnabled=t,this.checkNotificationPermission();}),this.preferencesService.missionPreviewEnabled$.pipe(_d(this.destroy$)).subscribe(t=>{this.missionPreviewEnabled=t;});}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete();}onThemeChange(){console.log("[OPTIONS] Theme changed to:",this.selectedTheme),this.themeService.setTheme({variant:this.selectedThemeVariant,mode:this.selectedTheme});}onVoiceLanguageChange(){console.log("[OPTIONS] Voice language changed to:",this.selectedVoiceLanguage),this.preferencesService.setVoiceLanguage(this.selectedVoiceLanguage);}onEnterToSendChange(){console.log("[OPTIONS] Enter to send changed to:",this.useEnterToSend),this.preferencesService.setEnterToSend(this.useEnterToSend);}onPrintTechnicalMessagesChange(){console.log("[OPTIONS] Print technical messages changed to:",this.printTechnicalMessages),this.preferencesService.setPrintTechnicalMessages(this.printTechnicalMessages);}onShowTechnicalMessagesChange(){let e=!this.showTechnicalMessages;console.log("[OPTIONS] Show technical messages changed to:",this.showTechnicalMessages,"(hide:",e,")"),this.preferencesService.setHideTechnicalMessages(e);}onShowWarningMessagesChange(){let e=!this.showWarningMessages;console.log("[OPTIONS] Show warning messages changed to:",this.showWarningMessages,"(hide:",e,")"),this.preferencesService.setHideWarningMessages(e);}onVoiceInputModeChange(e){let t=e.target.value;console.log("[OPTIONS] Voice input mode changed to:",t),this.preferencesService.setVoiceInputMode(t);}onVoiceAnnounceEnabledChange(){console.log("[OPTIONS] Voice announce enabled changed to:",this.voiceAnnounceEnabled),this.preferencesService.setVoiceAnnounceEnabled(this.voiceAnnounceEnabled);}onVoiceModeChange(){console.log("[OPTIONS] Voice mode changed to:",this.voiceMode),this.preferencesService.setVoiceMode(this.voiceMode);}onVoiceReadFullTextChange(){console.log("[OPTIONS] Voice read full text changed to:",this.voiceReadFullText),this.preferencesService.setVoiceReadFullText(this.voiceReadFullText);}onVoiceVolumeChange(){let e=this.voiceVolume/100;console.log("[OPTIONS] Voice volume changed to:",e),this.preferencesService.setVoiceVolume(e);}onVoiceRateChange(){let e=this.voiceRate/100;console.log("[OPTIONS] Voice rate changed to:",e),this.preferencesService.setVoiceRate(e);}loadAvailableVoices(){return dt$1(this,null,function*(){this.loadingVoices=true;try{this.availableVoices=yield this.voiceSynthesisService.getVoicesForLanguage(),console.log("[OPTIONS] Loaded",this.availableVoices.length,"voices for current language");}catch(e){console.error("[OPTIONS] Error loading voices:",e),this.availableVoices=[];}finally{this.loadingVoices=false;}})}onSelectedVoiceChange(){console.log("[OPTIONS] Selected voice changed to:",this.selectedVoiceId),this.preferencesService.setSelectedVoice(this.selectedVoiceId);}testVoice(){console.log("[OPTIONS] Testing voice with current settings"),this.voiceSynthesisService.testSelectedVoice();}onAgentNotificationEnabledChange(){console.log("[OPTIONS] Agent notification enabled changed to:",this.agentNotificationEnabled),this.preferencesService.setAgentNotificationEnabled(this.agentNotificationEnabled);}onNotificationSoundEnabledChange(){console.log("[OPTIONS] Notification sound enabled changed to:",this.notificationSoundEnabled),this.preferencesService.setNotificationSoundEnabled(this.notificationSoundEnabled);}onBrowserNotificationEnabledChange(){console.log("[OPTIONS] Browser notification enabled changed to:",this.browserNotificationEnabled),this.preferencesService.setBrowserNotificationEnabled(this.browserNotificationEnabled);}onMissionPreviewEnabledChange(){console.log("[OPTIONS] Mission preview panel enabled changed to:",this.missionPreviewEnabled),this.preferencesService.setMissionPreviewEnabled(this.missionPreviewEnabled);}checkNotificationPermission(){"Notification"in window&&(this.browserNotificationDenied=Notification.permission==="denied",console.log("[OPTIONS] Notification permission status:",Notification.permission));}static \u0275fac=function(t){return new(t||c)};static \u0275cmp=jw({type:c,selectors:[["app-options-panel"]],decls:168,vars:37,consts:[[1,"options-content"],[1,"option-section"],[1,"section-title"],[1,"option-group"],[1,"radio-group"],[1,"option-radio"],["type","radio","name","theme","value","light",3,"ngModelChange","change","ngModel"],[1,"radio-mark"],["type","radio","name","theme","value","dark",3,"ngModelChange","change","ngModel"],["type","radio","name","theme","value","system",3,"ngModelChange","change","ngModel"],[1,"option-label"],["type","radio","name","enterBehavior",3,"ngModelChange","change","value","ngModel"],[1,"toggle-option"],["color","primary",3,"ngModelChange","change","ngModel"],[1,"option-label-with-hint"],[1,"option-hint"],["color","primary",3,"ngModelChange","change","ngModel","disabled"],[1,"notification-error"],["for","voice-input-mode-select",1,"option-label"],["id","voice-input-mode-select",1,"option-select",3,"change","value"],["value","browser"],["value","whisper"],["value","voice-message"],["for","voice-language-select",1,"option-label"],["id","voice-language-select",1,"option-select",3,"ngModelChange","change","ngModel"],[3,"value"],["type","radio","name","voiceAnnounce",3,"ngModelChange","change","value","ngModel"],["type","radio","name","voiceMode","value","speech",3,"ngModelChange","change","ngModel"],["type","radio","name","voiceMode","value","notification",3,"ngModelChange","change","ngModel"],["type","radio","name","voiceReadFull",3,"ngModelChange","change","value","ngModel"],["for","voice-select",1,"option-label"],["id","voice-select",1,"option-select",3,"ngModelChange","change","ngModel","disabled"],["value",""],["role","button","tabindex","0","title","Test voice with current settings",1,"test-voice-link",3,"click"],[1,"thread-name"],["for","voice-volume-slider",1,"option-label"],["id","voice-volume-slider","type","range","min","0","max","100","step","5",1,"option-slider",3,"ngModelChange","input","ngModel"],["for","voice-rate-slider",1,"option-label"],["id","voice-rate-slider","type","range","min","50","max","200","step","10",1,"option-slider",3,"ngModelChange","input","ngModel"],[1,"error-icon"],[1,"error-message"]],template:function(t,n){t&1&&(Cs(0,"div",0)(1,"div",1)(2,"div",2)(3,"mat-icon"),JC(4,"palette"),hl(),Cs(5,"span"),JC(6,"Appearance"),hl()(),Cs(7,"div",3)(8,"div",4)(9,"label",5)(10,"input",6),sm("ngModelChange",function(o){return iT(n.selectedTheme,o)||(n.selectedTheme=o),o}),Lg("change",function(){return n.onThemeChange()}),hl(),ZI(),Ag(11,"span",7),JC(12," Light "),hl(),Cs(13,"label",5)(14,"input",8),sm("ngModelChange",function(o){return iT(n.selectedTheme,o)||(n.selectedTheme=o),o}),Lg("change",function(){return n.onThemeChange()}),hl(),ZI(),Ag(15,"span",7),JC(16," Dark "),hl(),Cs(17,"label",5)(18,"input",9),sm("ngModelChange",function(o){return iT(n.selectedTheme,o)||(n.selectedTheme=o),o}),Lg("change",function(){return n.onThemeChange()}),hl(),ZI(),Ag(19,"span",7),JC(20," System "),hl()()()(),Cs(21,"div",1)(22,"div",2)(23,"mat-icon"),JC(24,"chat_bubble_outline"),hl(),Cs(25,"span"),JC(26,"Messaging"),hl()(),Cs(27,"div",3)(28,"span",10),JC(29,"Send message behavior:"),hl(),Cs(30,"div",4)(31,"label",5)(32,"input",11),sm("ngModelChange",function(o){return iT(n.useEnterToSend,o)||(n.useEnterToSend=o),o}),Lg("change",function(){return n.onEnterToSendChange()}),hl(),ZI(),Ag(33,"span",7),JC(34," Enter to send "),hl(),Cs(35,"label",5)(36,"input",11),sm("ngModelChange",function(o){return iT(n.useEnterToSend,o)||(n.useEnterToSend=o),o}),Lg("change",function(){return n.onEnterToSendChange()}),hl(),ZI(),Ag(37,"span",7),JC(38," Enter for new line "),hl()()(),Cs(39,"div",3)(40,"div",12)(41,"span",10),JC(42,"Show technical messages"),hl(),Cs(43,"mat-slide-toggle",13),sm("ngModelChange",function(o){return iT(n.showTechnicalMessages,o)||(n.showTechnicalMessages=o),o}),Lg("change",function(){return n.onShowTechnicalMessagesChange()}),hl(),ZI(),hl()(),Cs(44,"div",3)(45,"div",12)(46,"span",10),JC(47,"Show warning messages"),hl(),Cs(48,"mat-slide-toggle",13),sm("ngModelChange",function(o){return iT(n.showWarningMessages,o)||(n.showWarningMessages=o),o}),Lg("change",function(){return n.onShowWarningMessagesChange()}),hl(),ZI(),hl()(),Cs(49,"div",3)(50,"div",12)(51,"span",10),JC(52,"Include technical messages in print"),hl(),Cs(53,"mat-slide-toggle",13),sm("ngModelChange",function(o){return iT(n.printTechnicalMessages,o)||(n.printTechnicalMessages=o),o}),Lg("change",function(){return n.onPrintTechnicalMessagesChange()}),hl(),ZI(),hl()()(),Cs(54,"div",1)(55,"div",2)(56,"mat-icon"),JC(57,"rocket_launch"),hl(),Cs(58,"span"),JC(59,"Mission Control"),hl()(),Cs(60,"div",3)(61,"div",12)(62,"div",14)(63,"span",10),JC(64,"Side-by-side thread preview"),hl(),Cs(65,"span",15),JC(66,"Click a mission card to open a preview panel. Recommended for large screens."),hl()(),Cs(67,"mat-slide-toggle",13),sm("ngModelChange",function(o){return iT(n.missionPreviewEnabled,o)||(n.missionPreviewEnabled=o),o}),Lg("change",function(){return n.onMissionPreviewEnabledChange()}),hl(),ZI(),hl()()(),Cs(68,"div",1)(69,"div",2)(70,"mat-icon"),JC(71,"notifications"),hl(),Cs(72,"span"),JC(73,"Notifications"),hl()(),Cs(74,"div",3)(75,"div",12)(76,"span",10),JC(77,"Notify when the agent answers or requests input"),hl(),Cs(78,"mat-slide-toggle",13),sm("ngModelChange",function(o){return iT(n.agentNotificationEnabled,o)||(n.agentNotificationEnabled=o),o}),Lg("change",function(){return n.onAgentNotificationEnabledChange()}),hl(),ZI(),hl()(),Cs(79,"div",3)(80,"div",12)(81,"span",10),JC(82,"Notification sound"),hl(),Cs(83,"mat-slide-toggle",16),sm("ngModelChange",function(o){return iT(n.notificationSoundEnabled,o)||(n.notificationSoundEnabled=o),o}),Lg("change",function(){return n.onNotificationSoundEnabledChange()}),hl(),ZI(),hl()(),Cs(84,"div",3)(85,"div",12)(86,"span",10),JC(87,"Browser notification"),hl(),Cs(88,"mat-slide-toggle",16),sm("ngModelChange",function(o){return iT(n.browserNotificationEnabled,o)||(n.browserNotificationEnabled=o),o}),Lg("change",function(){return n.onBrowserNotificationEnabledChange()}),hl(),ZI(),hl(),aC(89,st,5,0,"div",17),hl()(),Cs(90,"div",1)(91,"div",2)(92,"mat-icon"),JC(93,"record_voice_over"),hl(),Cs(94,"span"),JC(95,"Voice & Speech"),hl()(),Cs(96,"div",3)(97,"label",18),JC(98,"Voice input method:"),hl(),Cs(99,"select",19),Lg("change",function(o){return n.onVoiceInputModeChange(o)}),Cs(100,"option",20),JC(101,"Browser (real-time)"),hl(),Cs(102,"option",21),JC(103,"Whisper (higher accuracy)"),hl(),Cs(104,"option",22),JC(105,"Voice message (send audio)"),hl()()(),Cs(106,"div",3)(107,"label",23),JC(108,"Voice recognition language:"),hl(),Cs(109,"select",24),sm("ngModelChange",function(o){return iT(n.selectedVoiceLanguage,o)||(n.selectedVoiceLanguage=o),o}),Lg("change",function(){return n.onVoiceLanguageChange()}),dC(110,ct,2,3,"option",25,rt),hl(),ZI(),hl(),Cs(112,"div",3)(113,"span",10),JC(114,"Automatic announcement:"),hl(),Cs(115,"div",4)(116,"label",5)(117,"input",26),sm("ngModelChange",function(o){return iT(n.voiceAnnounceEnabled,o)||(n.voiceAnnounceEnabled=o),o}),Lg("change",function(){return n.onVoiceAnnounceEnabledChange()}),hl(),ZI(),Ag(118,"span",7),JC(119," Enabled "),hl(),Cs(120,"label",5)(121,"input",26),sm("ngModelChange",function(o){return iT(n.voiceAnnounceEnabled,o)||(n.voiceAnnounceEnabled=o),o}),Lg("change",function(){return n.onVoiceAnnounceEnabledChange()}),hl(),ZI(),Ag(122,"span",7),JC(123," Disabled "),hl()()(),Cs(124,"div",3)(125,"span",10),JC(126,"Voice mode:"),hl(),Cs(127,"div",4)(128,"label",5)(129,"input",27),sm("ngModelChange",function(o){return iT(n.voiceMode,o)||(n.voiceMode=o),o}),Lg("change",function(){return n.onVoiceModeChange()}),hl(),ZI(),Ag(130,"span",7),JC(131," Voice synthesis "),hl(),Cs(132,"label",5)(133,"input",28),sm("ngModelChange",function(o){return iT(n.voiceMode,o)||(n.voiceMode=o),o}),Lg("change",function(){return n.onVoiceModeChange()}),hl(),ZI(),Ag(134,"span",7),JC(135," Sound notification "),hl()()(),Cs(136,"div",3)(137,"span",10),JC(138,"Message reading:"),hl(),Cs(139,"div",4)(140,"label",5)(141,"input",29),sm("ngModelChange",function(o){return iT(n.voiceReadFullText,o)||(n.voiceReadFullText=o),o}),Lg("change",function(){return n.onVoiceReadFullTextChange()}),hl(),ZI(),Ag(142,"span",7),JC(143," Full message "),hl(),Cs(144,"label",5)(145,"input",29),sm("ngModelChange",function(o){return iT(n.voiceReadFullText,o)||(n.voiceReadFullText=o),o}),Lg("change",function(){return n.onVoiceReadFullTextChange()}),hl(),ZI(),Ag(146,"span",7),JC(147," First paragraphs only "),hl()()(),Cs(148,"div",3)(149,"label",30),JC(150,"Selected voice:"),hl(),Cs(151,"select",31),sm("ngModelChange",function(o){return iT(n.selectedVoiceId,o)||(n.selectedVoiceId=o),o}),Lg("change",function(){return n.onSelectedVoiceChange()}),aC(152,lt,2,0,"option",32),aC(153,dt,2,0,"option",32),dC(154,pt,2,2,"option",25,at),hl(),ZI(),Ag(156,"div",10),Cs(157,"a",33),Lg("click",function(){return n.testVoice()}),Cs(158,"span",34),JC(159,"Test voice"),hl()()(),Cs(160,"div",3)(161,"label",35),JC(162),hl(),Cs(163,"input",36),sm("ngModelChange",function(o){return iT(n.voiceVolume,o)||(n.voiceVolume=o),o}),Lg("input",function(){return n.onVoiceVolumeChange()}),hl(),ZI(),hl(),Cs(164,"div",3)(165,"label",37),JC(166),hl(),Cs(167,"input",38),sm("ngModelChange",function(o){return iT(n.voiceRate,o)||(n.voiceRate=o),o}),Lg("input",function(){return n.onVoiceRateChange()}),hl(),ZI(),hl()()()),t&2&&(sI(10),im("ngModel",n.selectedTheme),QI(),sI(4),im("ngModel",n.selectedTheme),QI(),sI(4),im("ngModel",n.selectedTheme),QI(),sI(14),xg("value",true),im("ngModel",n.useEnterToSend),QI(),sI(4),xg("value",false),im("ngModel",n.useEnterToSend),QI(),sI(7),im("ngModel",n.showTechnicalMessages),QI(),sI(5),im("ngModel",n.showWarningMessages),QI(),sI(5),im("ngModel",n.printTechnicalMessages),QI(),sI(14),im("ngModel",n.missionPreviewEnabled),QI(),sI(11),im("ngModel",n.agentNotificationEnabled),QI(),sI(5),im("ngModel",n.notificationSoundEnabled),xg("disabled",!n.agentNotificationEnabled),QI(),sI(5),im("ngModel",n.browserNotificationEnabled),xg("disabled",!n.agentNotificationEnabled||n.browserNotificationDenied),QI(),sI(),cC(n.browserNotificationDenied?89:-1),sI(10),xg("value",n.voiceInputMode),sI(10),im("ngModel",n.selectedVoiceLanguage),QI(),sI(),fC(n.voiceLanguageOptions),sI(7),xg("value",true),im("ngModel",n.voiceAnnounceEnabled),QI(),sI(4),xg("value",false),im("ngModel",n.voiceAnnounceEnabled),QI(),sI(8),im("ngModel",n.voiceMode),QI(),sI(4),im("ngModel",n.voiceMode),QI(),sI(8),xg("value",true),im("ngModel",n.voiceReadFullText),QI(),sI(4),xg("value",false),im("ngModel",n.voiceReadFullText),QI(),sI(6),im("ngModel",n.selectedVoiceId),xg("disabled",n.loadingVoices||n.availableVoices.length===0),QI(),sI(),cC(n.loadingVoices?152:-1),sI(),cC(!n.loadingVoices&&n.availableVoices.length===0?153:-1),sI(),fC(n.availableVoices),sI(8),Dl("Volume: ",n.voiceVolume,"%"),sI(),im("ngModel",n.voiceVolume),QI(),sI(3),Dl("Speed: ",n.voiceRate,"%"),sI(),im("ngModel",n.voiceRate),QI());},dependencies:[ti,Qn,ei,Ye$1,_n,At,mn,Zn,cn,wt,se],styles:['.options-content[_ngcontent-%COMP%]{padding:0;width:100%}.option-group[_ngcontent-%COMP%]{padding:0 1rem 1rem;margin-bottom:1rem;border-bottom:1px solid var(--color-border-light)}.option-group[_ngcontent-%COMP%]:last-child{margin-bottom:0;padding-bottom:0;border-bottom:none}.option-label[_ngcontent-%COMP%]{display:block;margin-bottom:.5rem;font-weight:500;color:var(--color-text);font-size:.875rem}.toggle-option[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;gap:1rem}.toggle-option[_ngcontent-%COMP%] .option-label[_ngcontent-%COMP%]{margin-bottom:0;flex:1}.toggle-option[_ngcontent-%COMP%] mat-slide-toggle[_ngcontent-%COMP%]{flex-shrink:0}.option-label-with-hint[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.25rem;flex:1}.option-label-with-hint[_ngcontent-%COMP%] .option-label[_ngcontent-%COMP%]{margin-bottom:0}.option-label-with-hint[_ngcontent-%COMP%] .option-hint[_ngcontent-%COMP%]{font-size:.775rem;color:var(--color-text-secondary);line-height:1.4}.option-select[_ngcontent-%COMP%]{width:100%;padding:.5rem;border:1px solid var(--color-border);border-radius:4px;background:var(--color-input-bg);color:var(--color-text);font-size:.875rem;cursor:pointer}.option-select[_ngcontent-%COMP%]:focus{outline:none;border-color:var(--color-primary);box-shadow:0 0 0 3px #7064fb1a}.option-select[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.option-select[_ngcontent-%COMP%] option[_ngcontent-%COMP%]{padding:.5rem}.option-checkbox[_ngcontent-%COMP%]{display:flex;align-items:center;cursor:pointer;font-size:.875rem;color:var(--color-text);-webkit-user-select:none;user-select:none}.option-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{display:none}.option-checkbox[_ngcontent-%COMP%] .checkmark[_ngcontent-%COMP%]{width:18px;height:18px;border:2px solid var(--color-border);border-radius:3px;margin-right:.75rem;display:flex;align-items:center;justify-content:center;transition:all .2s ease;flex-shrink:0}.option-checkbox[_ngcontent-%COMP%] .checkmark[_ngcontent-%COMP%]:after{content:"";width:10px;height:6px;border-left:2px solid transparent;border-bottom:2px solid transparent;transform:rotate(-45deg);transition:all .2s ease;opacity:0}.option-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]:checked + .checkmark[_ngcontent-%COMP%]{background-color:var(--color-primary);border-color:var(--color-primary)}.option-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]:checked + .checkmark[_ngcontent-%COMP%]:after{border-left-color:#fff;border-bottom-color:#fff;opacity:1}.option-checkbox[_ngcontent-%COMP%]:hover .checkmark[_ngcontent-%COMP%]{border-color:var(--color-primary)}.option-checkbox[_ngcontent-%COMP%]:focus-within .checkmark[_ngcontent-%COMP%]{box-shadow:0 0 0 3px #7064fb1a}.option-section[_ngcontent-%COMP%]{padding-top:1rem;margin-top:1rem;border-top:2px solid var(--color-border)}.option-section[_ngcontent-%COMP%]:first-child{border-top:none;padding-top:0;margin-top:0}.section-title[_ngcontent-%COMP%]{margin:0 0 1rem;padding:0 1rem;font-size:.9rem;font-weight:600;color:var(--color-text);display:flex;align-items:center;gap:.5rem}.section-title[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}.radio-group[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.option-radio[_ngcontent-%COMP%]{display:flex;align-items:center;cursor:pointer;font-size:.875rem;color:var(--color-text);-webkit-user-select:none;user-select:none}.option-radio[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{display:none}.option-radio[_ngcontent-%COMP%] .radio-mark[_ngcontent-%COMP%]{width:16px;height:16px;border:2px solid var(--color-border);border-radius:50%;margin-right:.5rem;display:flex;align-items:center;justify-content:center;transition:all .2s ease;flex-shrink:0;position:relative}.option-radio[_ngcontent-%COMP%] .radio-mark[_ngcontent-%COMP%]:after{content:"";width:8px;height:8px;border-radius:50%;background-color:var(--color-primary);transition:all .2s ease;opacity:0;transform:scale(0)}.option-radio[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]:checked + .radio-mark[_ngcontent-%COMP%]{border-color:var(--color-primary)}.option-radio[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]:checked + .radio-mark[_ngcontent-%COMP%]:after{opacity:1;transform:scale(1)}.option-radio[_ngcontent-%COMP%]:hover .radio-mark[_ngcontent-%COMP%]{border-color:var(--color-primary)}.option-radio[_ngcontent-%COMP%]:focus-within .radio-mark[_ngcontent-%COMP%]{box-shadow:0 0 0 3px #7064fb1a}.option-slider[_ngcontent-%COMP%]{width:100%;height:6px;border-radius:3px;background:var(--color-bg-solid);outline:none;cursor:pointer;-webkit-appearance:none;appearance:none}.option-slider[_ngcontent-%COMP%]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:20px;height:20px;border-radius:50%;background:var(--color-primary);cursor:pointer;border:2px solid white;box-shadow:0 2px 6px #0003;transition:all .2s ease}.option-slider[_ngcontent-%COMP%]::-webkit-slider-thumb:hover{transform:scale(1.1);box-shadow:0 2px 8px #0000004d}.option-slider[_ngcontent-%COMP%]::-moz-range-thumb{width:20px;height:20px;border-radius:50%;background:var(--color-primary);cursor:pointer;border:2px solid white;box-shadow:0 2px 6px #0003;transition:all .2s ease}.option-slider[_ngcontent-%COMP%]::-moz-range-thumb:hover{transform:scale(1.1);box-shadow:0 2px 8px #0000004d}.option-slider[_ngcontent-%COMP%]::-webkit-slider-track{height:6px;border-radius:3px;background:var(--color-bg-secondary)}.option-slider[_ngcontent-%COMP%]::-moz-range-track{height:6px;border-radius:3px;background:var(--color-bg-secondary);border:none}.option-slider[_ngcontent-%COMP%]:focus{outline:none}.option-slider[_ngcontent-%COMP%]:focus::-webkit-slider-thumb{box-shadow:0 0 0 3px #7064fb4d,0 2px 6px #0003}.option-slider[_ngcontent-%COMP%]:focus::-moz-range-thumb{box-shadow:0 0 0 3px #7064fb4d,0 2px 6px #0003}.test-voice-btn[_ngcontent-%COMP%]{width:100%;padding:.75rem 1rem;background:var(--color-primary);color:#fff;border:none;border-radius:6px;font-size:.875rem;font-weight:500;cursor:pointer;transition:all .2s ease;display:flex;align-items:center;justify-content:center;gap:.5rem}.test-voice-btn[_ngcontent-%COMP%]:hover{background:var(--color-primary-hover);transform:translateY(-1px);box-shadow:0 2px 8px #7064fb4d}.test-voice-btn[_ngcontent-%COMP%]:active{transform:translateY(0);box-shadow:0 1px 4px #7064fb4d}.test-voice-btn[_ngcontent-%COMP%]:focus{outline:none;box-shadow:0 0 0 3px #7064fb4d}.test-voice-btn[_ngcontent-%COMP%]:disabled{background:var(--color-bg-secondary);color:var(--color-text-secondary);cursor:not-allowed;transform:none;box-shadow:none}.test-voice-link[_ngcontent-%COMP%]{text-decoration-thickness:1.5px;text-underline-offset:3px;background:transparent;border:none;padding:0;font-size:.775rem;font-weight:400;cursor:pointer;transition:all .2s ease;display:inline-flex;align-items:center;justify-content:center;gap:.5rem;text-decoration:underline}.test-voice-link[_ngcontent-%COMP%]:hover{color:var(--color-primary-hover, var(--color-primary));text-decoration-thickness:2px}.test-voice-link[_ngcontent-%COMP%]:active{opacity:.8}.test-voice-link[_ngcontent-%COMP%]:focus{outline:2px solid var(--color-primary);outline-offset:2px}.test-voice-link[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}.notification-error[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.5rem;padding:.75rem;margin-top:.75rem;background-color:#d32f2f1a;border:1px solid rgba(211,47,47,.3);border-radius:6px;font-size:.8125rem;line-height:1.5}.notification-error[_ngcontent-%COMP%] .error-icon[_ngcontent-%COMP%]{color:#d32f2f;font-size:20px;width:20px;height:20px;flex-shrink:0;margin-top:2px}.notification-error[_ngcontent-%COMP%] .error-message[_ngcontent-%COMP%]{color:var(--color-text);flex:1}.notification-error[_ngcontent-%COMP%]{margin-top:.75rem;padding:.75rem;background-color:#f443361a;border:1px solid rgba(244,67,54,.3);border-radius:6px;display:flex;align-items:flex-start;gap:.5rem}.notification-error[_ngcontent-%COMP%] .error-icon[_ngcontent-%COMP%]{color:#f44336;font-size:20px;width:20px;height:20px;flex-shrink:0;margin-top:2px}.notification-error[_ngcontent-%COMP%] .error-message[_ngcontent-%COMP%]{font-size:.8125rem;color:var(--color-text);line-height:1.5;flex:1}'],changeDetection:1})};function Qe(c){let e=c.args??"",t;try{let n=JSON.parse(e);t=JSON.stringify(n,null,2);}catch(n){t=e;}return `\u{1F527} ${c.name}
179
179
 
180
- ${t}`}var Ge=class c{destroy$=new ue;currentProject=null;currentThread=null;messagesSubject=new Tr([]);isThinkingSubject=new Tr(false);currentChoiceSubject=new Tr(null);projectTitleSubject=new Tr("Coday");currentInviteEventSubject=new Tr(null);messageToRestoreSubject=new Tr("");threadUpdateEventSubject=new Tr(null);currentChoiceEvent=null;thinkingTimeout=null;accumulatedChunks="";streamingTextSubject=new Tr("");subThreadEventsSubject=new ue;subThreadEvents$=this.subThreadEventsSubject.asObservable();subThreadEventBuffers=new Map;getBufferedSubThreadEvents(e){return this.subThreadEventBuffers.get(e)??[]}messages$=this.messagesSubject.asObservable();streamingText$=this.streamingTextSubject.asObservable();isThinking$=this.isThinkingSubject.asObservable();currentChoice$=this.currentChoiceSubject.asObservable();currentInviteEvent$=this.currentInviteEventSubject.asObservable();messageToRestore$=this.messageToRestoreSubject.asObservable();threadUpdateEvent$=this.threadUpdateEventSubject.asObservable();connectionStatus$;tabTitleService=null;eventStream=g(fe);messageApi=g(be);userService=g(pe);constructor(){this.connectionStatus$=this.eventStream.connectionStatus$,this.initializeEventHandling();}setTabTitleService(e){this.tabTitleService=e;}connectToThread(e,t){this.currentProject=e,this.currentThread=t,this.eventStream.connectToThread(e,t);}loadHistoryFromRest(e){for(let t of e){let n=le(t);n&&this.handleEvent(n,true);}}resetMessages(){this.messagesSubject.next([]),this.currentChoiceSubject.next(null),this.currentInviteEventSubject.next(null),this.currentChoiceEvent=null,this.accumulatedChunks="",this.streamingTextSubject.next(""),this.subThreadEventBuffers.clear(),this.stopThinking();}sendMessage(e){if(!this.currentProject||!this.currentThread){console.error("[CODAY] Cannot send message: no project or thread selected");return}let t=this.currentInviteEventSubject.value;if(t){this.clearThinkingTimeout(),this.isThinkingSubject.next(true),this.thinkingTimeout=setTimeout(()=>{this.thinkingTimeout=null,this.stopThinking(),console.warn("[CODAY] Safety timeout: no server response after 30 s, releasing thinking state");},3e4),this.tabTitleService?.setSystemActive(),this.currentInviteEventSubject.next(null);let n=t.buildAnswer(e);this.messageApi.sendMessage(n).subscribe({error:i=>{console.error("[CODAY] Send invite answer error:",i),this.currentInviteEventSubject.next(t),this.stopThinking();}});}else this.messageApi.sendFreeMessage(e).subscribe({error:n=>{console.error("[CODAY] Send error:",n);}});}sendChoice(e){if(!this.currentProject||!this.currentThread){console.error("[CODAY] Cannot send choice: no project or thread selected");return}if(this.currentChoiceEvent){this.clearThinkingTimeout(),this.isThinkingSubject.next(true),this.thinkingTimeout=setTimeout(()=>{this.thinkingTimeout=null,this.stopThinking(),console.warn("[CODAY] Safety timeout: no server response after 30 s, releasing thinking state");},3e4),this.tabTitleService?.setSystemActive();let t=this.currentChoiceEvent.buildAnswer(e);this.currentChoiceSubject.next(null),this.currentChoiceEvent=null,this.messageApi.sendMessage(t).subscribe({next:()=>{},error:n=>{console.error("[CODAY-CHOICE] Choice error:",n),this.stopThinking();}});}else console.error("[CODAY-CHOICE] No choice event available for choice:",e);}deleteMessage(e){let t=this.messagesSubject.value.find(i=>i.id===e),n=this.extractTextContentFromMessage(t);return this.messageApi.deleteMessage(e).pipe(Fd(i=>{i.success&&(this.removeMessagesFromIndex(e),n.trim()&&this.messageToRestoreSubject.next(n));}))}getCurrentProjectTitle(){return this.projectTitleSubject.value}getCurrentInviteEvent(){return this.currentInviteEventSubject.value}setThinkingForPendingMessage(){this.isThinkingSubject.next(true),this.tabTitleService?.setSystemActive();}initializeEventHandling(){this.eventStream.events$.pipe(zy(this.destroy$)).subscribe({next:e=>this.handleEvent(e),error:e=>console.error("[CODAY] Event stream error:",e),complete:()=>console.log("[CODAY] Event stream completed")});}handleEvent(e,t=false){if(e.threadId&&e.threadId!==this.currentThread){let n=this.subThreadEventBuffers.get(e.threadId);n?n.push(e):this.subThreadEventBuffers.set(e.threadId,[e]),this.subThreadEventsSubject.next(e);return}e instanceof T?this.handleMessageEvent(e):e instanceof B?this.handleTextChunkEvent(e):e instanceof A?this.handleTextEvent(e):e instanceof u?this.handleAnswerEvent(e):e instanceof h?this.handleErrorEvent(e):e instanceof M?this.handleWarnEvent(e):e instanceof O?this.handleThinkingEvent(e):e instanceof v?this.handleToolRequestEvent(e):e instanceof m?this.handleToolResponseEvent(e):e instanceof b?this.handleChoiceEvent(e,t):e instanceof F?this.handleHeartBeatEvent(e):e instanceof f?this.handleInviteEvent(e,t):e instanceof V?this.handleThreadUpdateEvent(e):e instanceof R?this.handleDelegationEvent(e):e instanceof H||e instanceof K||console.warn("[CODAY] Unhandled event type:",e.type);}handleDelegationEvent(e){if(console.log("[CODAY] DelegationEvent received:",e.subThreadId,e.agentName),this.messagesSubject.value.findIndex(i=>i.subThreadId===e.subThreadId)===-1){let i={id:e.timestamp,role:"system",speaker:e.agentName,content:[{type:"text",content:""}],timestamp:new Date,type:"delegation",subThreadId:e.subThreadId,delegationAgentName:e.agentName};this.addMessage(i);}}handleThreadUpdateEvent(e){this.threadUpdateEventSubject.next(e);}handleMessageEvent(e){e.role==="assistant"&&this.accumulatedChunks&&(this.accumulatedChunks="",this.streamingTextSubject.next(""));let t={id:e.timestamp,role:e.role,speaker:e.name,content:e.content,timestamp:e.date,type:"text"};this.addMessage(t);}handleTextChunkEvent(e){this.accumulatedChunks+=e.chunk,this.streamingTextSubject.next(this.accumulatedChunks);}handleTextEvent(e){let t={id:e.timestamp,role:e.speaker?"assistant":"system",speaker:e.speaker??"System",content:[{type:"text",content:e.text}],timestamp:e.date,type:e.speaker?"text":"technical"};this.addMessage(t);}handleAnswerEvent(e){let t=this.currentInviteEventSubject.value;if(t){let i=!!e.parentKey&&e.parentKey===t.timestamp,o=!e.parentKey&&e.date>=t.date;(i||o)&&this.currentInviteEventSubject.next(null);}if(this.currentChoiceEvent){let i=!!e.parentKey&&e.parentKey===this.currentChoiceEvent.timestamp,o=!e.parentKey&&e.date>=this.currentChoiceEvent.date;(i||o)&&(this.currentChoiceEvent=null,this.currentChoiceSubject.next(null));}if(e.silent)return;let n={id:e.timestamp,role:"user",speaker:e.name??this.userService.getUsername()??"User",content:[{type:"text",content:e.answer}],timestamp:e.date,type:"text",parentKey:e.parentKey,invite:e.invite};this.addMessage(n);}handleErrorEvent(e){let t={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:`Error: ${JSON.stringify(e.error)}`}],timestamp:e.date,type:"error"};this.addMessage(t);}handleWarnEvent(e){let t={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:`Warning: ${JSON.stringify(e.warning)}`}],timestamp:e.date,type:"warning"};this.addMessage(t);}handleThinkingEvent(e){this.currentInviteEventSubject.value||this.currentChoiceEvent||(this.clearThinkingTimeout(),this.isThinkingSubject.next(true),this.tabTitleService?.setSystemActive(),this.thinkingTimeout=setTimeout(()=>{this.isThinkingSubject.next(false),this.thinkingTimeout=null,this.tabTitleService?.setSystemInactive();},O.debounce+1e3));}handleToolRequestEvent(e){let t={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:e.toSingleLineString()}],timestamp:e.date,type:"technical",eventId:e.timestamp,fullContent:Qe(e)};this.addMessage(t);}handleToolResponseEvent(e){let t={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:e.toSingleLineString()}],timestamp:e.date,type:"technical",eventId:e.timestamp};this.addMessage(t);}handleChoiceEvent(e,t=false){this.stopThinking();let n={id:e.timestamp,role:"assistant",speaker:"Assistant",content:[{type:"text",content:e.optionalQuestion?`${e.optionalQuestion} ${e.invite}`:e.invite}],timestamp:e.date,type:"text"};if(this.addMessage(n),t||this.messagesSubject.value.some(y=>y.parentKey===e.timestamp||y.role==="user"&&y.timestamp>e.date||y.role==="assistant"&&y.timestamp>e.date))return;this.currentChoiceEvent=e,this.tabTitleService?.setSystemInactive();let E=e.options.map(y=>({value:y,label:y})),C=e.optionalQuestion?`${e.optionalQuestion} ${e.invite}`:e.invite;this.currentChoiceSubject.next({options:E,label:C,allowFreeText:e.allowFreeText});}handleHeartBeatEvent(e){}handleInviteEvent(e,t=false){if(this.stopThinking(),e.invite===_e)t||(this.currentInviteEventSubject.next(e),this.tabTitleService?.setSystemInactive());else {let i={id:e.timestamp,role:"assistant",speaker:"Assistant",content:[{type:"text",content:e.invite}],timestamp:e.date,type:"text"};this.addMessage(i),this.messagesSubject.value.some(C=>C.parentKey===e.timestamp||C.role==="user"&&C.timestamp>e.date||C.role==="assistant"&&C.timestamp>e.date)||t||(this.currentInviteEventSubject.next(e),this.tabTitleService?.setSystemInactive());}}addMessage(e){let t=this.messagesSubject.value;t.some(n=>n.id===e.id)||this.messagesSubject.next([...t,e]);}removeMessagesFromIndex(e){let t=this.messagesSubject.value,n=t.findIndex(o=>o.id===e);if(n===-1||n===0)return;let i=t.slice(0,n);this.messagesSubject.next(i),this.stopThinking();}extractTextContentFromMessage(e){return e?e.content.filter(t=>t.type==="text").map(t=>t.content).join(`
180
+ ${t}`}var Ge=class c{destroy$=new ue;currentProject=null;currentThread=null;messagesSubject=new Tr([]);isThinkingSubject=new Tr(false);currentChoiceSubject=new Tr(null);projectTitleSubject=new Tr("Coday");currentInviteEventSubject=new Tr(null);messageToRestoreSubject=new Tr("");threadUpdateEventSubject=new Tr(null);currentChoiceEvent=null;thinkingTimeout=null;accumulatedChunks="";streamingTextSubject=new Tr("");subThreadEventsSubject=new ue;subThreadEvents$=this.subThreadEventsSubject.asObservable();subThreadEventBuffers=new Map;getBufferedSubThreadEvents(e){return this.subThreadEventBuffers.get(e)??[]}messages$=this.messagesSubject.asObservable();streamingText$=this.streamingTextSubject.asObservable();isThinking$=this.isThinkingSubject.asObservable();currentChoice$=this.currentChoiceSubject.asObservable();currentInviteEvent$=this.currentInviteEventSubject.asObservable();messageToRestore$=this.messageToRestoreSubject.asObservable();threadUpdateEvent$=this.threadUpdateEventSubject.asObservable();connectionStatus$;tabTitleService=null;eventStream=g(fe);messageApi=g(be);userService=g(pe);constructor(){this.connectionStatus$=this.eventStream.connectionStatus$,this.initializeEventHandling();}setTabTitleService(e){this.tabTitleService=e;}connectToThread(e,t){this.currentProject=e,this.currentThread=t,this.eventStream.connectToThread(e,t);}loadHistoryFromRest(e){for(let t of e){let n=le(t);n&&this.handleEvent(n,true);}}resetMessages(){this.messagesSubject.next([]),this.currentChoiceSubject.next(null),this.currentInviteEventSubject.next(null),this.currentChoiceEvent=null,this.accumulatedChunks="",this.streamingTextSubject.next(""),this.subThreadEventBuffers.clear(),this.stopThinking();}sendMessage(e){if(!this.currentProject||!this.currentThread){console.error("[CODAY] Cannot send message: no project or thread selected");return}let t=this.currentInviteEventSubject.value;if(t){this.clearThinkingTimeout(),this.isThinkingSubject.next(true),this.thinkingTimeout=setTimeout(()=>{this.thinkingTimeout=null,this.stopThinking(),console.warn("[CODAY] Safety timeout: no server response after 30 s, releasing thinking state");},3e4),this.tabTitleService?.setSystemActive(),this.currentInviteEventSubject.next(null);let n=t.buildAnswer(e);this.messageApi.sendMessage(n).subscribe({error:i=>{console.error("[CODAY] Send invite answer error:",i),this.currentInviteEventSubject.next(t),this.stopThinking();}});}else this.messageApi.sendFreeMessage(e).subscribe({error:n=>{console.error("[CODAY] Send error:",n);}});}sendChoice(e){if(!this.currentProject||!this.currentThread){console.error("[CODAY] Cannot send choice: no project or thread selected");return}if(this.currentChoiceEvent){this.clearThinkingTimeout(),this.isThinkingSubject.next(true),this.thinkingTimeout=setTimeout(()=>{this.thinkingTimeout=null,this.stopThinking(),console.warn("[CODAY] Safety timeout: no server response after 30 s, releasing thinking state");},3e4),this.tabTitleService?.setSystemActive();let t=this.currentChoiceEvent.buildAnswer(e);this.currentChoiceSubject.next(null),this.currentChoiceEvent=null,this.messageApi.sendMessage(t).subscribe({next:()=>{},error:n=>{console.error("[CODAY-CHOICE] Choice error:",n),this.stopThinking();}});}else console.error("[CODAY-CHOICE] No choice event available for choice:",e);}deleteMessage(e){let t=this.messagesSubject.value.find(i=>i.id===e),n=this.extractTextContentFromMessage(t);return this.messageApi.deleteMessage(e).pipe(jd(i=>{i.success&&(this.removeMessagesFromIndex(e),n.trim()&&this.messageToRestoreSubject.next(n));}))}getCurrentProjectTitle(){return this.projectTitleSubject.value}getCurrentInviteEvent(){return this.currentInviteEventSubject.value}setThinkingForPendingMessage(){this.isThinkingSubject.next(true),this.tabTitleService?.setSystemActive();}initializeEventHandling(){this.eventStream.events$.pipe(_d(this.destroy$)).subscribe({next:e=>this.handleEvent(e),error:e=>console.error("[CODAY] Event stream error:",e),complete:()=>console.log("[CODAY] Event stream completed")});}handleEvent(e,t=false){if(e.threadId&&e.threadId!==this.currentThread){let n=this.subThreadEventBuffers.get(e.threadId);n?n.push(e):this.subThreadEventBuffers.set(e.threadId,[e]),this.subThreadEventsSubject.next(e);return}e instanceof T?this.handleMessageEvent(e):e instanceof B?this.handleTextChunkEvent(e):e instanceof A?this.handleTextEvent(e):e instanceof u?this.handleAnswerEvent(e):e instanceof h?this.handleErrorEvent(e):e instanceof M?this.handleWarnEvent(e):e instanceof O?this.handleThinkingEvent(e):e instanceof v?this.handleToolRequestEvent(e):e instanceof m?this.handleToolResponseEvent(e):e instanceof b?this.handleChoiceEvent(e,t):e instanceof F?this.handleHeartBeatEvent(e):e instanceof f?this.handleInviteEvent(e,t):e instanceof V?this.handleThreadUpdateEvent(e):e instanceof R?this.handleDelegationEvent(e):e instanceof H||e instanceof K||console.warn("[CODAY] Unhandled event type:",e.type);}handleDelegationEvent(e){if(console.log("[CODAY] DelegationEvent received:",e.subThreadId,e.agentName),this.messagesSubject.value.findIndex(i=>i.subThreadId===e.subThreadId)===-1){let i={id:e.timestamp,role:"system",speaker:e.agentName,content:[{type:"text",content:""}],timestamp:new Date,type:"delegation",subThreadId:e.subThreadId,delegationAgentName:e.agentName};this.addMessage(i);}}handleThreadUpdateEvent(e){this.threadUpdateEventSubject.next(e);}handleMessageEvent(e){e.role==="assistant"&&this.accumulatedChunks&&(this.accumulatedChunks="",this.streamingTextSubject.next(""));let t={id:e.timestamp,role:e.role,speaker:e.name,content:e.content,timestamp:e.date,type:"text"};this.addMessage(t);}handleTextChunkEvent(e){this.accumulatedChunks+=e.chunk,this.streamingTextSubject.next(this.accumulatedChunks);}handleTextEvent(e){let t={id:e.timestamp,role:e.speaker?"assistant":"system",speaker:e.speaker??"System",content:[{type:"text",content:e.text}],timestamp:e.date,type:e.speaker?"text":"technical"};this.addMessage(t);}handleAnswerEvent(e){let t=this.currentInviteEventSubject.value;if(t){let i=!!e.parentKey&&e.parentKey===t.timestamp,o=!e.parentKey&&e.date>=t.date;(i||o)&&this.currentInviteEventSubject.next(null);}if(this.currentChoiceEvent){let i=!!e.parentKey&&e.parentKey===this.currentChoiceEvent.timestamp,o=!e.parentKey&&e.date>=this.currentChoiceEvent.date;(i||o)&&(this.currentChoiceEvent=null,this.currentChoiceSubject.next(null));}if(e.silent)return;let n={id:e.timestamp,role:"user",speaker:e.name??this.userService.getUsername()??"User",content:[{type:"text",content:e.answer}],timestamp:e.date,type:"text",parentKey:e.parentKey,invite:e.invite};this.addMessage(n);}handleErrorEvent(e){let t={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:`Error: ${JSON.stringify(e.error)}`}],timestamp:e.date,type:"error"};this.addMessage(t);}handleWarnEvent(e){let t={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:`Warning: ${JSON.stringify(e.warning)}`}],timestamp:e.date,type:"warning"};this.addMessage(t);}handleThinkingEvent(e){this.currentInviteEventSubject.value||this.currentChoiceEvent||(this.clearThinkingTimeout(),this.isThinkingSubject.next(true),this.tabTitleService?.setSystemActive(),this.thinkingTimeout=setTimeout(()=>{this.isThinkingSubject.next(false),this.thinkingTimeout=null,this.tabTitleService?.setSystemInactive();},O.debounce+1e3));}handleToolRequestEvent(e){let t={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:e.toSingleLineString()}],timestamp:e.date,type:"technical",eventId:e.timestamp,fullContent:Qe(e)};this.addMessage(t);}handleToolResponseEvent(e){let t={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:e.toSingleLineString()}],timestamp:e.date,type:"technical",eventId:e.timestamp};this.addMessage(t);}handleChoiceEvent(e,t=false){this.stopThinking();let n={id:e.timestamp,role:"assistant",speaker:"Assistant",content:[{type:"text",content:e.optionalQuestion?`${e.optionalQuestion} ${e.invite}`:e.invite}],timestamp:e.date,type:"text"};if(this.addMessage(n),t||this.messagesSubject.value.some(y=>y.parentKey===e.timestamp||y.role==="user"&&y.timestamp>e.date||y.role==="assistant"&&y.timestamp>e.date))return;this.currentChoiceEvent=e,this.tabTitleService?.setSystemInactive();let E=e.options.map(y=>({value:y,label:y})),C=e.optionalQuestion?`${e.optionalQuestion} ${e.invite}`:e.invite;this.currentChoiceSubject.next({options:E,label:C,allowFreeText:e.allowFreeText});}handleHeartBeatEvent(e){}handleInviteEvent(e,t=false){if(this.stopThinking(),e.invite===_e)t||(this.currentInviteEventSubject.next(e),this.tabTitleService?.setSystemInactive());else {let i={id:e.timestamp,role:"assistant",speaker:"Assistant",content:[{type:"text",content:e.invite}],timestamp:e.date,type:"text"};this.addMessage(i),this.messagesSubject.value.some(C=>C.parentKey===e.timestamp||C.role==="user"&&C.timestamp>e.date||C.role==="assistant"&&C.timestamp>e.date)||t||(this.currentInviteEventSubject.next(e),this.tabTitleService?.setSystemInactive());}}addMessage(e){let t=this.messagesSubject.value;t.some(n=>n.id===e.id)||this.messagesSubject.next([...t,e]);}removeMessagesFromIndex(e){let t=this.messagesSubject.value,n=t.findIndex(o=>o.id===e);if(n===-1||n===0)return;let i=t.slice(0,n);this.messagesSubject.next(i),this.stopThinking();}extractTextContentFromMessage(e){return e?e.content.filter(t=>t.type==="text").map(t=>t.content).join(`
181
181
 
182
- `):""}clearThinkingTimeout(){this.thinkingTimeout&&(clearTimeout(this.thinkingTimeout),this.thinkingTimeout=null);}stopThinking(){this.clearThinkingTimeout(),this.isThinkingSubject.next(false),this.tabTitleService&&this.tabTitleService.setSystemInactive();}ngOnDestroy(){this.clearThinkingTimeout(),this.destroy$.next(),this.destroy$.complete(),this.currentInviteEventSubject.complete(),this.messageToRestoreSubject.complete(),this.threadUpdateEventSubject.complete(),this.streamingTextSubject.complete(),this.eventStream.disconnect();}static \u0275fac=function(t){return new(t||c)};static \u0275prov=x({token:c,factory:c.\u0275fac,providedIn:"root"})};function gt(c,e){if(c&1&&(Cs(0,"div",3),JC(1),hl()),c&2){let t=CC();sI(),Dl("\u274C ",t.errorMessage);}}var Ze=class c{dialogRef=g(z$1);data=g(Ue);jsonContent;errorMessage="";title;constructor(){this.jsonContent=this.data.initialContent,this.title=this.data.title||this.getDefaultTitle(this.data.configType,this.data.projectName);}getDefaultTitle(e,t){return e==="user"?"User Configuration":`Project Configuration: ${t||"Unknown"}`}onSave(){this.errorMessage="";let e;try{e=JSON.parse(this.jsonContent);}catch(t){this.errorMessage=`Invalid JSON syntax: ${t instanceof Error?t.message:"Unknown error"}`;return}this.dialogRef.close(e);}onCancel(){this.dialogRef.close();}static \u0275fac=function(t){return new(t||c)};static \u0275cmp=jw({type:c,selectors:[["app-json-editor"]],decls:13,vars:3,consts:[["mat-dialog-title",""],["mat-icon-button","","title","Close",1,"close-button",3,"click"],["spellcheck","false","placeholder","Enter JSON configuration...",1,"json-textarea",3,"ngModelChange","ngModel"],[1,"error-message"],["align","end"],["matButton","",3,"click"],["matButton","filled","color","primary",3,"click"]],template:function(t,n){t&1&&(Cs(0,"div",0),JC(1),Cs(2,"button",1),kg("click",function(){return n.onCancel()}),Cs(3,"mat-icon"),JC(4,"close"),hl()()(),Cs(5,"mat-dialog-content")(6,"textarea",2),rm("ngModelChange",function(o){return iT(n.jsonContent,o)||(n.jsonContent=o),o}),hl(),ZI(),aC(7,gt,2,1,"div",3),hl(),Cs(8,"mat-dialog-actions",4)(9,"button",5),kg("click",function(){return n.onCancel()}),JC(10,"Cancel"),hl(),Cs(11,"button",6),kg("click",function(){return n.onSave()}),JC(12,"Save"),hl()()),t&2&&(sI(),Dl(" ",n.title," "),sI(5),nm("ngModel",n.jsonContent),QI(),sI(),cC(n.errorMessage?7:-1));},dependencies:[Ym,ti,Ye$1,Zn,cn,wt,Gn,pr,jt,Nt,Vt],styles:["[mat-dialog-title][_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center}[mat-dialog-title][_ngcontent-%COMP%] .close-button[_ngcontent-%COMP%]{margin-left:auto}mat-dialog-content[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;min-height:400px}.json-textarea[_ngcontent-%COMP%]{flex:1;min-height:300px;max-height:80vh;padding:1rem;font-family:Monaco,Menlo,Ubuntu Mono,Consolas,monospace;font-size:.875rem;line-height:1.5;background:var(--color-code-bg);color:var(--color-text);border:1px solid var(--color-border);border-radius:4px;resize:vertical;outline:none;transition:border-color .2s}.json-textarea[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.json-textarea[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary);opacity:.6}.error-message[_ngcontent-%COMP%]{padding:.75rem 1rem;border-radius:4px;font-size:.875rem;line-height:1.4;background:#dc26261a;color:#dc2626;border:1px solid rgba(220,38,38,.3)}"],changeDetection:1})};export{Et as E,Ge as G,Qe as Q,Ye as Y,Ze as Z,yt as y,z};
182
+ `):""}clearThinkingTimeout(){this.thinkingTimeout&&(clearTimeout(this.thinkingTimeout),this.thinkingTimeout=null);}stopThinking(){this.clearThinkingTimeout(),this.isThinkingSubject.next(false),this.tabTitleService&&this.tabTitleService.setSystemInactive();}ngOnDestroy(){this.clearThinkingTimeout(),this.destroy$.next(),this.destroy$.complete(),this.currentInviteEventSubject.complete(),this.messageToRestoreSubject.complete(),this.threadUpdateEventSubject.complete(),this.streamingTextSubject.complete(),this.eventStream.disconnect();}static \u0275fac=function(t){return new(t||c)};static \u0275prov=x({token:c,factory:c.\u0275fac,providedIn:"root"})};function gt(c,e){if(c&1&&(Cs(0,"div",3),JC(1),hl()),c&2){let t=CC();sI(),Dl("\u274C ",t.errorMessage);}}var Ze=class c{dialogRef=g(z$1);data=g(Ue);jsonContent;errorMessage="";title;constructor(){this.jsonContent=this.data.initialContent,this.title=this.data.title||this.getDefaultTitle(this.data.configType,this.data.projectName);}getDefaultTitle(e,t){return e==="user"?"User Configuration":`Project Configuration: ${t||"Unknown"}`}onSave(){this.errorMessage="";let e;try{e=JSON.parse(this.jsonContent);}catch(t){this.errorMessage=`Invalid JSON syntax: ${t instanceof Error?t.message:"Unknown error"}`;return}this.dialogRef.close(e);}onCancel(){this.dialogRef.close();}static \u0275fac=function(t){return new(t||c)};static \u0275cmp=jw({type:c,selectors:[["app-json-editor"]],decls:13,vars:3,consts:[["mat-dialog-title",""],["mat-icon-button","","title","Close",1,"close-button",3,"click"],["spellcheck","false","placeholder","Enter JSON configuration...",1,"json-textarea",3,"ngModelChange","ngModel"],[1,"error-message"],["align","end"],["matButton","",3,"click"],["matButton","filled","color","primary",3,"click"]],template:function(t,n){t&1&&(Cs(0,"div",0),JC(1),Cs(2,"button",1),Lg("click",function(){return n.onCancel()}),Cs(3,"mat-icon"),JC(4,"close"),hl()()(),Cs(5,"mat-dialog-content")(6,"textarea",2),sm("ngModelChange",function(o){return iT(n.jsonContent,o)||(n.jsonContent=o),o}),hl(),ZI(),aC(7,gt,2,1,"div",3),hl(),Cs(8,"mat-dialog-actions",4)(9,"button",5),Lg("click",function(){return n.onCancel()}),JC(10,"Cancel"),hl(),Cs(11,"button",6),Lg("click",function(){return n.onSave()}),JC(12,"Save"),hl()()),t&2&&(sI(),Dl(" ",n.title," "),sI(5),im("ngModel",n.jsonContent),QI(),sI(),cC(n.errorMessage?7:-1));},dependencies:[Xm,ti,Ye$1,Zn,cn,wt,Gn,pr,jt,Nt,Vt],styles:["[mat-dialog-title][_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center}[mat-dialog-title][_ngcontent-%COMP%] .close-button[_ngcontent-%COMP%]{margin-left:auto}mat-dialog-content[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;min-height:400px}.json-textarea[_ngcontent-%COMP%]{flex:1;min-height:300px;max-height:80vh;padding:1rem;font-family:Monaco,Menlo,Ubuntu Mono,Consolas,monospace;font-size:.875rem;line-height:1.5;background:var(--color-code-bg);color:var(--color-text);border:1px solid var(--color-border);border-radius:4px;resize:vertical;outline:none;transition:border-color .2s}.json-textarea[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.json-textarea[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary);opacity:.6}.error-message[_ngcontent-%COMP%]{padding:.75rem 1rem;border-radius:4px;font-size:.875rem;line-height:1.4;background:#dc26261a;color:#dc2626;border:1px solid rgba(220,38,38,.3)}"],changeDetection:1})};export{Et as E,Ge as G,Qe as Q,Ye as Y,Ze as Z,yt as y,z};
@@ -1,4 +1,4 @@
1
- import {b as Qe}from'./chunk-CqZF9JZo.js';import {D as D$1,i as y}from'./chunk-B3kY-GQk.js';import {g,B as gy,bU as Fd,K as x,aL as wo,aM as Zn,aO as wt,az as Xt,bw as St,bs as bl,aW as C,aS as K,al as vt,aX as D,bx as on,by as dm,aT as Ut,j as jw,bz as Oi,aC as bu,a_ as rb,bA as bC,k as Cs,n as kg,M as Mg,m as hl,o as aC,bB as SC,A as AC,_ as _g,t as sI,w as zg,S as Sg,u as cC,b5 as lT,bC as _i,c8 as ob,c0 as Rg,b$ as UC,x as jg,y as MC,N as NC,c9 as Pf}from'./main-RXIVNUWK.js';var ae=["switch"],ie=["*"];function ne(a,s){a&1&&(Cs(0,"span",11),Pf(),Cs(1,"svg",13),Mg(2,"path",14),hl(),Cs(3,"svg",15),Mg(4,"path",16),hl()());}var ce=new C("mat-slide-toggle-default-options",{providedIn:"root",factory:()=>({disableToggleValue:false,hideIcon:false,disabledInteractive:false})}),b=class{source;checked;constructor(s,e){this.source=s,this.checked=e;}},se=(()=>{class a{_elementRef=g(Xt);_focusMonitor=g(St);_changeDetectorRef=g(bl);defaults=g(ce);_onChange=e=>{};_onTouched=()=>{};_validatorOnChange=()=>{};_uniqueId;_checked=false;_createChangeEvent(e){return new b(this,e)}_labelId;get buttonId(){return `${this.id||this._uniqueId}-button`}_switchElement;focus(){this._switchElement.nativeElement.focus();}_noopAnimations=K();_focused=false;name=null;id;labelPosition="after";ariaLabel=null;ariaLabelledby=null;ariaDescribedby;required=false;color;disabled=false;disableRipple=false;tabIndex=0;get checked(){return this._checked}set checked(e){this._checked=e,this._changeDetectorRef.markForCheck();}hideIcon;disabledInteractive;change=new vt;toggleChange=new vt;get inputId(){return `${this.id||this._uniqueId}-input`}constructor(){g(D).load(on);let e=g(new dm("tabindex"),{optional:true}),i=this.defaults;this.tabIndex=e==null?0:parseInt(e)||0,this.color=i.color||"accent",this.id=this._uniqueId=g(Ut).getId("mat-mdc-slide-toggle-"),this.hideIcon=i.hideIcon??false,this.disabledInteractive=i.disabledInteractive??false,this._labelId=this._uniqueId+"-label";}ngAfterContentInit(){this._focusMonitor.monitor(this._elementRef,true).subscribe(e=>{e==="keyboard"||e==="program"?(this._focused=true,this._changeDetectorRef.markForCheck()):e||Promise.resolve().then(()=>{this._focused=false,this._onTouched(),this._changeDetectorRef.markForCheck();});});}ngOnChanges(e){e.required&&this._validatorOnChange();}ngOnDestroy(){this._focusMonitor.stopMonitoring(this._elementRef);}writeValue(e){this.checked=!!e;}registerOnChange(e){this._onChange=e;}registerOnTouched(e){this._onTouched=e;}validate(e){return this.required&&e.value!==true?{required:true}:null}registerOnValidatorChange(e){this._validatorOnChange=e;}setDisabledState(e){this.disabled=e,this._changeDetectorRef.markForCheck();}toggle(){this.checked=!this.checked,this._onChange(this.checked);}_emitChangeEvent(){this._onChange(this.checked),this.change.emit(this._createChangeEvent(this.checked));}_handleClick(){this.disabled||(this.toggleChange.emit(),this.defaults.disableToggleValue||(this.checked=!this.checked,this._onChange(this.checked),this.change.emit(new b(this,this.checked))));}_getAriaLabelledBy(){return this.ariaLabelledby?this.ariaLabelledby:this.ariaLabel?null:this._labelId}static \u0275fac=function(i){return new(i||a)};static \u0275cmp=jw({type:a,selectors:[["mat-slide-toggle"]],viewQuery:function(i,t){if(i&1&&jg(ae,5),i&2){let r;MC(r=NC())&&(t._switchElement=r.first);}},hostAttrs:[1,"mat-mdc-slide-toggle"],hostVars:13,hostBindings:function(i,t){i&2&&(Rg("id",t.id),Sg("tabindex",null)("aria-label",null)("name",null)("aria-labelledby",null),UC(t.color?"mat-"+t.color:""),zg("mat-mdc-slide-toggle-focused",t._focused)("mat-mdc-slide-toggle-checked",t.checked)("_mat-animation-noopable",t._noopAnimations));},inputs:{name:"name",id:"id",labelPosition:"labelPosition",ariaLabel:[0,"aria-label","ariaLabel"],ariaLabelledby:[0,"aria-labelledby","ariaLabelledby"],ariaDescribedby:[0,"aria-describedby","ariaDescribedby"],required:[2,"required","required",rb],color:"color",disabled:[2,"disabled","disabled",rb],disableRipple:[2,"disableRipple","disableRipple",rb],tabIndex:[2,"tabIndex","tabIndex",e=>e==null?0:ob(e)],checked:[2,"checked","checked",rb],hideIcon:[2,"hideIcon","hideIcon",rb],disabledInteractive:[2,"disabledInteractive","disabledInteractive",rb]},outputs:{change:"change",toggleChange:"toggleChange"},exportAs:["matSlideToggle"],features:[lT([{provide:D$1,useExisting:_i(()=>a),multi:true},{provide:y,useExisting:a,multi:true}]),bu],ngContentSelectors:ie,decls:14,vars:27,consts:[["switch",""],["mat-internal-form-field","",3,"labelPosition"],["role","switch","type","button",1,"mdc-switch",3,"click","tabIndex","disabled"],[1,"mat-mdc-slide-toggle-touch-target"],[1,"mdc-switch__track"],[1,"mdc-switch__handle-track"],[1,"mdc-switch__handle"],[1,"mdc-switch__shadow"],[1,"mdc-elevation-overlay"],[1,"mdc-switch__ripple"],["mat-ripple","",1,"mat-mdc-slide-toggle-ripple","mat-focus-indicator",3,"matRippleTrigger","matRippleDisabled","matRippleCentered"],[1,"mdc-switch__icons"],[1,"mdc-label",3,"click","for"],["viewBox","0 0 24 24","aria-hidden","true",1,"mdc-switch__icon","mdc-switch__icon--on"],["d","M19.69,5.23L8.96,15.96l-4.23-4.23L2.96,13.5l6,6L21.46,7L19.69,5.23z"],["viewBox","0 0 24 24","aria-hidden","true",1,"mdc-switch__icon","mdc-switch__icon--off"],["d","M20 13H4v-2h16v2z"]],template:function(i,t){if(i&1&&(bC(),Cs(0,"div",1)(1,"button",2,0),kg("click",function(){return t._handleClick()}),Mg(3,"div",3)(4,"span",4),Cs(5,"span",5)(6,"span",6)(7,"span",7),Mg(8,"span",8),hl(),Cs(9,"span",9),Mg(10,"span",10),hl(),aC(11,ne,5,0,"span",11),hl()()(),Cs(12,"label",12),kg("click",function(ee){return ee.stopPropagation()}),SC(13),hl()()),i&2){let r=AC(2);_g("labelPosition",t.labelPosition),sI(),zg("mdc-switch--selected",t.checked)("mdc-switch--unselected",!t.checked)("mdc-switch--checked",t.checked)("mdc-switch--disabled",t.disabled)("mat-mdc-slide-toggle-disabled-interactive",t.disabledInteractive),_g("tabIndex",t.disabled&&!t.disabledInteractive?-1:t.tabIndex)("disabled",t.disabled&&!t.disabledInteractive),Sg("id",t.buttonId)("name",t.name)("aria-label",t.ariaLabel)("aria-labelledby",t._getAriaLabelledBy())("aria-describedby",t.ariaDescribedby)("aria-required",t.required||null)("aria-checked",t.checked)("aria-disabled",t.disabled&&t.disabledInteractive?"true":null),sI(9),_g("matRippleTrigger",r)("matRippleDisabled",t.disableRipple||t.disabled)("matRippleCentered",true),sI(),cC(t.hideIcon?-1:11),sI(),_g("for",t.buttonId),Sg("id",t._labelId);}},dependencies:[Oi,Qe],styles:[`.mdc-switch {
1
+ import {b as Qe}from'./chunk-B2UoGfZ3.js';import {D as D$1,i as y}from'./chunk-CPuMGlfm.js';import {g,E as vy,bU as jd,Y as x,aL as wo,aM as Zn,aO as wt,az as Xt,bw as St,bs as bl,aW as C,aS as K,al as vt,aX as D,bx as on,by as hm,aT as Ut,j as jw,bz as Oi,aC as bu,a_ as rb,bA as bC,k as Cs,n as Lg,A as Ag,m as hl,o as aC,bB as SC,t as AC,x as xg,u as sI,y as qg,N as Ng,v as cC,b5 as lT,bC as _i,c8 as ob,c0 as Fg,b$ as UC,H as Hg,M as MC,B as NC,c9 as Bf}from'./main-4LGWVPVH.js';var ae=["switch"],ie=["*"];function ne(a,s){a&1&&(Cs(0,"span",11),Bf(),Cs(1,"svg",13),Ag(2,"path",14),hl(),Cs(3,"svg",15),Ag(4,"path",16),hl()());}var ce=new C("mat-slide-toggle-default-options",{providedIn:"root",factory:()=>({disableToggleValue:false,hideIcon:false,disabledInteractive:false})}),b=class{source;checked;constructor(s,e){this.source=s,this.checked=e;}},se=(()=>{class a{_elementRef=g(Xt);_focusMonitor=g(St);_changeDetectorRef=g(bl);defaults=g(ce);_onChange=e=>{};_onTouched=()=>{};_validatorOnChange=()=>{};_uniqueId;_checked=false;_createChangeEvent(e){return new b(this,e)}_labelId;get buttonId(){return `${this.id||this._uniqueId}-button`}_switchElement;focus(){this._switchElement.nativeElement.focus();}_noopAnimations=K();_focused=false;name=null;id;labelPosition="after";ariaLabel=null;ariaLabelledby=null;ariaDescribedby;required=false;color;disabled=false;disableRipple=false;tabIndex=0;get checked(){return this._checked}set checked(e){this._checked=e,this._changeDetectorRef.markForCheck();}hideIcon;disabledInteractive;change=new vt;toggleChange=new vt;get inputId(){return `${this.id||this._uniqueId}-input`}constructor(){g(D).load(on);let e=g(new hm("tabindex"),{optional:true}),i=this.defaults;this.tabIndex=e==null?0:parseInt(e)||0,this.color=i.color||"accent",this.id=this._uniqueId=g(Ut).getId("mat-mdc-slide-toggle-"),this.hideIcon=i.hideIcon??false,this.disabledInteractive=i.disabledInteractive??false,this._labelId=this._uniqueId+"-label";}ngAfterContentInit(){this._focusMonitor.monitor(this._elementRef,true).subscribe(e=>{e==="keyboard"||e==="program"?(this._focused=true,this._changeDetectorRef.markForCheck()):e||Promise.resolve().then(()=>{this._focused=false,this._onTouched(),this._changeDetectorRef.markForCheck();});});}ngOnChanges(e){e.required&&this._validatorOnChange();}ngOnDestroy(){this._focusMonitor.stopMonitoring(this._elementRef);}writeValue(e){this.checked=!!e;}registerOnChange(e){this._onChange=e;}registerOnTouched(e){this._onTouched=e;}validate(e){return this.required&&e.value!==true?{required:true}:null}registerOnValidatorChange(e){this._validatorOnChange=e;}setDisabledState(e){this.disabled=e,this._changeDetectorRef.markForCheck();}toggle(){this.checked=!this.checked,this._onChange(this.checked);}_emitChangeEvent(){this._onChange(this.checked),this.change.emit(this._createChangeEvent(this.checked));}_handleClick(){this.disabled||(this.toggleChange.emit(),this.defaults.disableToggleValue||(this.checked=!this.checked,this._onChange(this.checked),this.change.emit(new b(this,this.checked))));}_getAriaLabelledBy(){return this.ariaLabelledby?this.ariaLabelledby:this.ariaLabel?null:this._labelId}static \u0275fac=function(i){return new(i||a)};static \u0275cmp=jw({type:a,selectors:[["mat-slide-toggle"]],viewQuery:function(i,t){if(i&1&&Hg(ae,5),i&2){let r;MC(r=NC())&&(t._switchElement=r.first);}},hostAttrs:[1,"mat-mdc-slide-toggle"],hostVars:13,hostBindings:function(i,t){i&2&&(Fg("id",t.id),Ng("tabindex",null)("aria-label",null)("name",null)("aria-labelledby",null),UC(t.color?"mat-"+t.color:""),qg("mat-mdc-slide-toggle-focused",t._focused)("mat-mdc-slide-toggle-checked",t.checked)("_mat-animation-noopable",t._noopAnimations));},inputs:{name:"name",id:"id",labelPosition:"labelPosition",ariaLabel:[0,"aria-label","ariaLabel"],ariaLabelledby:[0,"aria-labelledby","ariaLabelledby"],ariaDescribedby:[0,"aria-describedby","ariaDescribedby"],required:[2,"required","required",rb],color:"color",disabled:[2,"disabled","disabled",rb],disableRipple:[2,"disableRipple","disableRipple",rb],tabIndex:[2,"tabIndex","tabIndex",e=>e==null?0:ob(e)],checked:[2,"checked","checked",rb],hideIcon:[2,"hideIcon","hideIcon",rb],disabledInteractive:[2,"disabledInteractive","disabledInteractive",rb]},outputs:{change:"change",toggleChange:"toggleChange"},exportAs:["matSlideToggle"],features:[lT([{provide:D$1,useExisting:_i(()=>a),multi:true},{provide:y,useExisting:a,multi:true}]),bu],ngContentSelectors:ie,decls:14,vars:27,consts:[["switch",""],["mat-internal-form-field","",3,"labelPosition"],["role","switch","type","button",1,"mdc-switch",3,"click","tabIndex","disabled"],[1,"mat-mdc-slide-toggle-touch-target"],[1,"mdc-switch__track"],[1,"mdc-switch__handle-track"],[1,"mdc-switch__handle"],[1,"mdc-switch__shadow"],[1,"mdc-elevation-overlay"],[1,"mdc-switch__ripple"],["mat-ripple","",1,"mat-mdc-slide-toggle-ripple","mat-focus-indicator",3,"matRippleTrigger","matRippleDisabled","matRippleCentered"],[1,"mdc-switch__icons"],[1,"mdc-label",3,"click","for"],["viewBox","0 0 24 24","aria-hidden","true",1,"mdc-switch__icon","mdc-switch__icon--on"],["d","M19.69,5.23L8.96,15.96l-4.23-4.23L2.96,13.5l6,6L21.46,7L19.69,5.23z"],["viewBox","0 0 24 24","aria-hidden","true",1,"mdc-switch__icon","mdc-switch__icon--off"],["d","M20 13H4v-2h16v2z"]],template:function(i,t){if(i&1&&(bC(),Cs(0,"div",1)(1,"button",2,0),Lg("click",function(){return t._handleClick()}),Ag(3,"div",3)(4,"span",4),Cs(5,"span",5)(6,"span",6)(7,"span",7),Ag(8,"span",8),hl(),Cs(9,"span",9),Ag(10,"span",10),hl(),aC(11,ne,5,0,"span",11),hl()()(),Cs(12,"label",12),Lg("click",function(ee){return ee.stopPropagation()}),SC(13),hl()()),i&2){let r=AC(2);xg("labelPosition",t.labelPosition),sI(),qg("mdc-switch--selected",t.checked)("mdc-switch--unselected",!t.checked)("mdc-switch--checked",t.checked)("mdc-switch--disabled",t.disabled)("mat-mdc-slide-toggle-disabled-interactive",t.disabledInteractive),xg("tabIndex",t.disabled&&!t.disabledInteractive?-1:t.tabIndex)("disabled",t.disabled&&!t.disabledInteractive),Ng("id",t.buttonId)("name",t.name)("aria-label",t.ariaLabel)("aria-labelledby",t._getAriaLabelledBy())("aria-describedby",t.ariaDescribedby)("aria-required",t.required||null)("aria-checked",t.checked)("aria-disabled",t.disabled&&t.disabledInteractive?"true":null),sI(9),xg("matRippleTrigger",r)("matRippleDisabled",t.disableRipple||t.disabled)("matRippleCentered",true),sI(),cC(t.hideIcon?-1:11),sI(),xg("for",t.buttonId),Ng("id",t._labelId);}},dependencies:[Oi,Qe],styles:[`.mdc-switch {
2
2
  align-items: center;
3
3
  background: none;
4
4
  border: none;
@@ -426,4 +426,4 @@ import {b as Qe}from'./chunk-CqZF9JZo.js';import {D as D$1,i as y}from'./chunk-B
426
426
  right: 50%;
427
427
  transform: translate(50%, -50%);
428
428
  }
429
- `],encapsulation:2})}return a})(),ke=(()=>{class a{static \u0275fac=function(i){return new(i||a)};static \u0275mod=wo({type:a});static \u0275inj=Zn({imports:[se,wt]})}return a})();var W=class a{http=g(gy);getUserConfig(){return this.http.get("/api/config/user").pipe(Fd(s=>console.log("[CONFIG-API] User config retrieved:",s)))}updateUserConfig(s){return this.http.put("/api/config/user",s).pipe(Fd(e=>console.log("[CONFIG-API] User config updated:",e)))}static \u0275fac=function(e){return new(e||a)};static \u0275prov=x({token:a,factory:a.\u0275fac,providedIn:"root"})};export{W,ke as k,se as s};
429
+ `],encapsulation:2})}return a})(),ke=(()=>{class a{static \u0275fac=function(i){return new(i||a)};static \u0275mod=wo({type:a});static \u0275inj=Zn({imports:[se,wt]})}return a})();var W=class a{http=g(vy);getUserConfig(){return this.http.get("/api/config/user").pipe(jd(s=>console.log("[CONFIG-API] User config retrieved:",s)))}updateUserConfig(s){return this.http.put("/api/config/user",s).pipe(jd(e=>console.log("[CONFIG-API] User config updated:",e)))}static \u0275fac=function(e){return new(e||a)};static \u0275prov=x({token:a,factory:a.\u0275fac,providedIn:"root"})};export{W,ke as k,se as s};
@@ -1 +1 @@
1
- import {g,bm as xm,W as Wi,T as TT,cF as $b,j as jw,h as hr,i as Gn,k as Cs,n as kg,J as JC,m as hl,a3 as ZI,o as aC,t as sI,_ as _g,a6 as QI,u as cC,C as Ce,z as z$1,a as P,$ as $y,b as U,K as x,b1 as On,bf as gT,ac as CC,a8 as Kg,bi as vT,cG as DT,q as dC,cH as iC,M as Mg,v as fC,B as gy,cI as xt,aw as gl,ax as ml,c9 as Pf,b6 as Ng,ck as Lf,S as Sg,a5 as Dl,a9 as vC,cJ as Fg,aa as Cf,ab as Tf,ad as $g}from'./main-RXIVNUWK.js';import {t as ti,Q as Qn,e as ei,Y as Ye$1,A as At,Z as Zn,c as cn,y as yt,w as wt}from'./chunk-B3kY-GQk.js';var Ae=(o,t)=>t.date,He=(o,t)=>t.x,$e=(o,t)=>t.label;function Ve(o,t){o&1&&(gl(0,"div",0),JC(1,"No daily data points for this period."),ml());}function Le(o,t){if(o&1&&(Pf(),Ng(0,"rect",18)),o&2){let e=CC().$implicit,n=CC(2);Sg("x",e.w+6)("y",n.yBase-e.tokensStubH)("width",e.w)("height",e.tokensStubH);}}function Ge(o,t){if(o&1&&(Pf(),Ng(0,"rect",19)(1,"rect",20)),o&2){let e=CC().$implicit,n=CC(2);Sg("x",e.w+6)("y",n.yBase-(e.promptH??0))("width",e.w)("height",e.promptH??0),sI(),Sg("x",e.w+6)("y",n.yBase-((e.promptH??0)+(e.completionH??0)))("width",e.w)("height",e.completionH??0);}}function Ye(o,t){if(o&1){let e=vC();Pf(),gl(0,"g",15),Fg("mouseenter",function(i){let d=Cf(e).$implicit,u=CC(2);return Tf(u.showTooltip(i,d.point))})("mousemove",function(i){let d=Cf(e).$implicit,u=CC(2);return Tf(u.showTooltip(i,d.point))})("mouseleave",function(){Cf(e);let i=CC(2);return Tf(i.hideTooltip())}),Ng(1,"rect",16)(2,"rect",17),aC(3,Le,1,4,":svg:rect",18)(4,Ge,2,8),ml();}if(o&2){let e=t.$implicit,n=CC(2);Sg("transform","translate("+e.xGroup+",0)"),sI(),Sg("y",n.yTop)("width",e.groupW)("height",n.yBase-n.yTop),sI(),Sg("y",n.yBase-e.costH)("width",e.w)("height",e.costH),sI(),cC(e.tokensStubH!==null?3:4);}}function We(o,t){if(o&1&&(Pf(),gl(0,"text",5),JC(1),ml()),o&2){let e=t.$implicit,n=CC(2);Sg("x",e.x)("y",n.yAxis),sI(),Kg(e.label);}}function je(o,t){if(o&1&&(gl(0,"div",24),JC(1),ml(),gl(2,"div",25),JC(3),ml()),o&2){let e=t.$implicit;sI(),Kg(e.label),sI(2),Kg(e.value);}}function ze(o,t){if(o&1&&(gl(0,"div",21)(1,"div",22),JC(2),ml(),gl(3,"div",23),dC(4,je,4,2,null,null,$e),ml()()),o&2){let e=CC(2);$g("left",e.tooltip().x+12,"px")("top",e.tooltip().y+12,"px"),sI(2),Kg(e.tooltip().data.date),sI(2),fC(e.tooltipLines());}}function Xe(o,t){if(o&1&&(gl(0,"div",8)(1,"span",10),JC(2),ml()()),o&2){let e=CC(2);sI(2),Kg(e.tokenCoverageLabel());}}function Je(o,t){if(o&1&&(gl(0,"div",1),Pf(),gl(1,"svg",2),Ng(2,"line",3)(3,"line",3),dC(4,Ye,5,8,":svg:g",4,Ae),dC(6,We,2,3,":svg:text",5,He),ml(),aC(8,ze,6,5,"div",6),Lf(),gl(9,"div",7)(10,"div",8),Ng(11,"span",9),gl(12,"span",10),JC(13,"Cost (per day)"),ml(),gl(14,"span",11),JC(15),ml()(),gl(16,"div",8),Ng(17,"span",12),gl(18,"span",10),JC(19,"Prompt tokens"),ml()(),gl(20,"div",8),Ng(21,"span",13),gl(22,"span",10),JC(23,"Completion tokens"),ml()(),gl(24,"div",8),Ng(25,"span",14),gl(26,"span",10),JC(27,"Tokens missing"),ml()(),gl(28,"div",8)(29,"span",10),JC(30,"Tokens scale"),ml(),gl(31,"span",11),JC(32),ml()(),aC(33,Xe,3,1,"div",8),ml()()),o&2){let e=CC();sI(),Sg("viewBox",e.viewBox),sI(),Sg("y1",e.yTop)("x2",720)("y2",e.yTop),sI(),Sg("y1",e.yBase)("x2",720)("y2",e.yBase),sI(),fC(e.bars()),sI(2),fC(e.axisLabels()),sI(2),cC(e.tooltip().visible&&e.tooltip().data?8:-1),sI(7),Dl("max ",e.maxCostLabel()),sI(17),Dl("max ",e.maxTokensLabel()),sI(),cC(e.tokenCoverageLabel()?33:-1);}}var j=class o{points=[];width=720;height=240;paddingX=12;paddingY=16;bottomAxisH=48;viewBox=`0 0 ${this.width} ${this.height}`;innerW=this.width-this.paddingX*2;innerH=this.height-this.paddingY*2-this.bottomAxisH;barGap=6;groupGap=14;safePoints=TT(()=>(this.points??[]).filter(t=>!!t.date));maxCost=TT(()=>Math.max(0,...this.safePoints().map(t=>t.cost??0)));maxTokens=TT(()=>{let t=this.safePoints().map(e=>{let n=e.promptTokens??null,i=e.completionTokens??null;return n===null&&i===null?null:(n??0)+(i??0)}).filter(e=>e!==null);return Math.max(0,...t)});tokenCoverageLabel=TT(()=>{let t=this.safePoints();return t.length===0?"":`Tokens available for ${t.filter(n=>n.promptTokens!==null||n.completionTokens!==null).length}/${t.length} days`});maxCostLabel=TT(()=>"$"+(new $b("en-US").transform(this.maxCost(),"1.2-2")??"0.00"));maxTokensLabel=TT(()=>new $b("en-US").transform(this.maxTokens(),"1.0-2")??"0");tooltip=Wi({visible:false,x:0,y:0,data:null});toTooltipData(t){let e=t.promptTokens,n=t.completionTokens,i=e===null&&n===null?null:(e??0)+(n??0);return {date:t.date,cost:t.cost??0,promptTokens:e,completionTokens:n,totalTokens:i,callCount:t.callCount??0}}showTooltip(t,e){let i=t.currentTarget?.closest(".chart")?.getBoundingClientRect(),d=i?t.clientX-i.left:t.clientX,u=i?t.clientY-i.top:t.clientY,f=320,k=170,U=12,C=i?Math.max(0,i.width-f-U):d,B=i?Math.max(0,i.height-k-U):u,F=i?Math.min(Math.max(0,d),C):d,ne=i?Math.min(Math.max(0,u),B):u;this.tooltip.set({visible:true,x:F,y:ne,data:this.toTooltipData(e)});}hideTooltip(){this.tooltip.update(t=>z$1(P({},t),{visible:false}));}formatTokens(t){return t===null?"\u2014":new $b("en-US").transform(t,"1.0-2")??"0"}formatCost(t){return "$"+(new $b("en-US").transform(t??0,"1.2-2")??"0.00")}tooltipLines=TT(()=>{let t=this.tooltip(),e=t.data;return !t.visible||!e?[]:[{label:"Cost",value:this.formatCost(e.cost)},{label:"Prompt tokens",value:this.formatTokens(e.promptTokens)},{label:"Completion tokens",value:this.formatTokens(e.completionTokens)},{label:"Total tokens",value:this.formatTokens(e.totalTokens)},{label:"Calls",value:`${e.callCount}`}]});bars=TT(()=>{let t=this.safePoints(),e=t.length;if(e===0)return [];let n=(this.innerW-(e-1)*this.groupGap)/e,i=Math.max(2,n),d=(i-this.barGap)/2,u=Math.max(1,d),f=this.maxCost()||1,k=this.maxTokens()||1,U=45;return t.map((C,B)=>{let F=this.paddingX+B*(i+this.groupGap),Ie=(C.cost??0)/f*this.innerH,oe=C.promptTokens,ae=C.completionTokens,Z=oe!==null||ae!==null,Ne=oe??0,Ue=ae??0,Be=Z?Ne/k*this.innerH:null,Fe=Z?Ue/k*this.innerH:null;return {date:C.date,point:C,xGroup:F,groupW:i,xCost:F,w:u,costH:Ie,xTokens:F+u+this.barGap,promptH:Be,completionH:Fe,tokensStubH:Z?null:U}})});axisLabels=TT(()=>{let t=this.safePoints(),e=t.length;if(e===0)return [];let i=Math.max(1,Math.ceil(e/8)),d=(this.innerW-(e-1)*this.groupGap)/e,u=Math.max(2,d);return t.map((f,k)=>({p:f,i:k})).filter(({i:f})=>f%i===0||f===e-1).map(({p:f,i:k})=>{let C=this.paddingX+k*(u+this.groupGap)+u/2,B=f.date.slice(5);return {x:C,label:B}})});yTop=this.paddingY;yBase=this.paddingY+this.innerH;yAxis=this.yBase+28;static \u0275fac=function(e){return new(e||o)};static \u0275cmp=jw({type:o,selectors:[["app-daily-series-chart"]],inputs:{points:"points"},decls:2,vars:1,consts:[[1,"muted"],[1,"chart"],["preserveAspectRatio","none","role","img","aria-label","Daily token and cost usage",1,"chart__svg"],["x1","0",1,"chart__grid"],[1,"chart__day"],["text-anchor","middle",1,"chart__axis-label"],[1,"chart__tooltip",3,"left","top"],[1,"chart__legend"],[1,"chart__legend-item"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--cost"],[1,"chart__legend-label"],[1,"chart__legend-value"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--prompt"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--completion"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--tokens-missing"],[1,"chart__day",3,"mouseenter","mousemove","mouseleave"],["x","0",1,"chart__hover"],["x","0",1,"chart__bar","chart__bar--cost"],[1,"chart__bar","chart__bar--tokens-missing"],[1,"chart__bar","chart__bar--prompt"],[1,"chart__bar","chart__bar--completion"],[1,"chart__tooltip"],[1,"chart__tooltip-title"],[1,"chart__tooltip-grid"],[1,"chart__tooltip-label"],[1,"chart__tooltip-value"]],template:function(e,n){e&1&&aC(0,Ve,2,0,"div",0)(1,Je,34,11,"div",1),e&2&&cC(n.safePoints().length===0?0:1);},styles:[".chart[_ngcontent-%COMP%]{display:grid;gap:.5rem;position:relative}.chart__svg[_ngcontent-%COMP%]{width:100%;height:260px;display:block;border-radius:12px;background:var(--color-bg-secondary, rgba(255, 255, 255, .72));border:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.chart__grid[_ngcontent-%COMP%]{stroke:var(--color-border-light, rgba(0, 0, 0, .08));stroke-width:1}.chart__day[_ngcontent-%COMP%]{cursor:default}.chart__hover[_ngcontent-%COMP%]{fill:transparent}.chart__day[_ngcontent-%COMP%]:hover .chart__hover[_ngcontent-%COMP%]{fill:var(--color-bg-hover, rgba(0, 0, 0, .03))}.chart__tooltip[_ngcontent-%COMP%]{position:absolute;z-index:2;min-width:220px;max-width:320px;padding:10px 12px;border-radius:12px;background:rgb(var(--color-bg-secondary-rgb, 255 255 255)/1);border:1px solid var(--color-border-light, rgba(0, 0, 0, .08));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .12));pointer-events:none}.chart__tooltip-title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:6px}.chart__tooltip-grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr auto;column-gap:10px;row-gap:4px}.chart__tooltip-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__tooltip-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums;text-align:right}.chart__bar[_ngcontent-%COMP%]{shape-rendering:geometricPrecision;rx:2;ry:2}.chart__bar--cost[_ngcontent-%COMP%]{fill:var(--color-primary, #007aff);opacity:.85}.chart__bar--prompt[_ngcontent-%COMP%]{fill:var(--color-success, #34c759);opacity:.85}.chart__bar--completion[_ngcontent-%COMP%]{fill:var(--color-warning, #ff9500);opacity:.85}.chart__bar--tokens-missing[_ngcontent-%COMP%]{fill:transparent;stroke:var(--color-text-secondary, rgba(29, 29, 31, .55));stroke-width:1.5;stroke-dasharray:4 3}.chart__axis-label[_ngcontent-%COMP%]{fill:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:12px;font-variant-numeric:tabular-nums}.chart__legend[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:.75rem;flex-wrap:wrap}.chart__legend-item[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:baseline}.chart__legend-swatch[_ngcontent-%COMP%]{width:10px;height:10px;border-radius:3px;align-self:center}.chart__legend-swatch--cost[_ngcontent-%COMP%]{background:var(--color-primary, #007aff)}.chart__legend-swatch--prompt[_ngcontent-%COMP%]{background:var(--color-success, #34c759)}.chart__legend-swatch--completion[_ngcontent-%COMP%]{background:var(--color-warning, #ff9500)}.chart__legend-swatch--tokens-missing[_ngcontent-%COMP%]{background:transparent;border:1px dashed var(--color-text-secondary, rgba(29, 29, 31, .55))}.chart__legend-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__legend-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}"]})};var X=class o{http=g(gy);getTokenUsage(t){let e=new xt;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage",{params:e})}getTokenUsageSeries(t){let e=new xt;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage/series",{params:e})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=x({token:o,factory:o.\u0275fac,providedIn:"root"})};function Pe(o){return `${o}`.padStart(2,"0")}function we(o){return `${o.getUTCFullYear()}-${Pe(o.getUTCMonth()+1)}-${Pe(o.getUTCDate())}`}function qe(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),1))}function Ke(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth()+1,1))}var J=class o{api=g(X);destroyRef=g(Ce);defaultFrom=we(qe());defaultTo=we(Ke());draftFilters=Wi({from:this.defaultFrom,to:this.defaultTo});appliedFilters=Wi({from:this.defaultFrom,to:this.defaultTo});loading=Wi(false);error=Wi(null);aggregation=Wi(null);seriesResponse=Wi(null);series=Wi(null);tokenDataPartial=Wi(false);aggregationByModelId=Wi(null);seriesByModelId=Wi(null);init(){this.reload();}setDraftFrom(t){this.draftFilters.update(e=>z$1(P({},e),{from:t}));}setDraftTo(t){this.draftFilters.update(e=>z$1(P({},e),{to:t}));}clearDraftFrom(){this.setDraftFrom(null);}clearDraftTo(){this.setDraftTo(null);}apply(){this.appliedFilters.set(this.draftFilters()),this.reload();}addNullableTokens(t,e){return t===null&&e===null?null:(t??0)+(e??0)}aggregateByModelId(t){let e=new Map;for(let n of t){let i=n.modelId,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0});}return [...e.values()].sort((n,i)=>(i.totalTokens??0)-(n.totalTokens??0))}aggregateSeriesByModelId(t){let e=new Map;for(let n of t){let i=`${n.date}|${n.modelId}`,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{date:n.date,agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0});}return [...e.values()].sort((n,i)=>n.date<i.date?-1:1)}reload(){let{from:t,to:e}=this.appliedFilters();this.loading.set(true),this.error.set(null),$y({aggregation:this.api.getTokenUsage({from:t,to:e}),series:this.api.getTokenUsageSeries({from:t,to:e})}).pipe(U(this.destroyRef)).subscribe({next:({aggregation:n,series:i})=>{this.aggregation.set(n),this.seriesResponse.set(i);let d=i.points??[];this.series.set(d),this.tokenDataPartial.set(n.tokenDataPartial||i.tokenDataPartial);let u=this.aggregateByModelId(n.models??[]);this.aggregationByModelId.set(u),this.seriesByModelId.set(this.aggregateSeriesByModelId(d)),this.loading.set(false);},error:n=>{this.loading.set(false),this.aggregation.set(null),this.seriesResponse.set(null),this.series.set(null),this.tokenDataPartial.set(false),this.aggregationByModelId.set(null),this.seriesByModelId.set(null),this.error.set(n instanceof Error?n.message:"Failed to load token usage");}});}static \u0275fac=function(e){return new(e||o)};static \u0275prov=x({token:o,factory:o.\u0275fac,providedIn:"root"})};var q=function(){throw new Error("DON'T USE this INSIDE A FUNCTION CALLED BY | call OR | apply IT MUST BE A PURE FUNCTION!")},De=typeof Proxy!="function"?Object.seal({}):new Proxy({},{get:q,set:q,deleteProperty:q,has:q}),K=class o{transform(t,e){if(typeof e!="function")throw new TypeError("You must pass a PURE function to | call");return e?.call(De,t)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=On({name:"call",type:o,pure:true})},Q=class o{transform(t,...e){if(typeof t!="function")throw new TypeError("You must use | apply on a PURE function");return t.apply(De,e)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=On({name:"apply",type:o,pure:true})};function Qe(o,t){o&1&&(Cs(0,"div",23),JC(1," Partial data \u2014 token counts may not cover the full period "),hl());}function Ze(o,t){o&1&&(Cs(0,"div",24),JC(1," No token data collected for this period "),hl());}function et(o,t){if(o&1&&(Cs(0,"div",19)(1,"div",20)(2,"div",21),JC(3,"Total tokens"),hl(),Cs(4,"div",22),JC(5),gT(6,"call"),hl()(),Cs(7,"div",20)(8,"div",21),JC(9,"Total calls"),hl(),Cs(10,"div",22),JC(11),hl()(),Cs(12,"div",20)(13,"div",21),JC(14,"Total cost"),hl(),Cs(15,"div",22),JC(16),gT(17,"apply"),hl()()(),aC(18,Qe,2,0,"div",23),aC(19,Ze,2,0,"div",24)),o&2){let e=CC();sI(5),Kg(vT(6,5,e.totalRow().totalTokens,e.formatTokenValue)),sI(6),Kg(e.totalRow().callCount),sI(5),Kg(DT(17,8,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)),sI(2),cC(e.isPartialPeriod()?18:-1),sI(),cC(e.isMissingPeriod()?19:-1);}}function tt(o,t){o&1&&(Cs(0,"div",16)(1,"div",25),JC(2,"Loading token usage\u2026"),hl()());}function nt(o,t){if(o&1&&(Cs(0,"div",17)(1,"div",26),JC(2,"Failed to load"),hl(),Cs(3,"div",25),JC(4),hl()()),o&2){let e=CC();sI(4),Kg(e.state.error());}}function ot(o,t){o&1&&(Cs(0,"div",16)(1,"div",26),JC(2,"No data"),hl(),Cs(3,"div",25),JC(4,"No token usage recorded yet for this period."),hl()());}function at(o,t){if(o&1&&(Cs(0,"div",32)(1,"div",29),JC(2),hl(),Cs(3,"div",29),JC(4),hl(),Cs(5,"div",29),JC(6),hl(),Cs(7,"div",30),JC(8),gT(9,"call"),hl(),Cs(10,"div",30),JC(11),gT(12,"call"),hl(),Cs(13,"div",30),JC(14),gT(15,"call"),hl(),Cs(16,"div",30),JC(17),hl(),Cs(18,"div",30),JC(19),gT(20,"apply"),hl()()),o&2){let e=t.$implicit,n=CC(2);sI(2),Kg(e.agentName),sI(2),Kg(e.providerName),sI(2),Kg(e.modelId),sI(2),Kg(vT(9,8,e.promptTokens,n.formatTokenValue)),sI(3),Kg(vT(12,11,e.completionTokens,n.formatTokenValue)),sI(3),Kg(vT(15,14,e.totalTokens,n.formatTokenValue)),sI(3),Kg(e.callCount),sI(2),Dl(" ",DT(20,17,n.formatCostValue,n.isMissingPeriod(),e.cost)," ");}}function it(o,t){if(o&1&&(Cs(0,"div",33)(1,"div",29),JC(2),hl(),Cs(3,"div",29),JC(4),hl(),Cs(5,"div",29),JC(6),hl(),Cs(7,"div",30),JC(8),gT(9,"call"),hl(),Cs(10,"div",30),JC(11),gT(12,"call"),hl(),Cs(13,"div",30),JC(14),gT(15,"call"),hl(),Cs(16,"div",30),JC(17),hl(),Cs(18,"div",30),JC(19),gT(20,"apply"),hl()()),o&2){let e=CC(2);sI(2),Kg(e.totalRow().agentName),sI(2),Kg(e.totalRow().providerName),sI(2),Kg(e.totalRow().modelId),sI(2),Kg(vT(9,8,e.totalRow().promptTokens,e.formatTokenValue)),sI(3),Dl(" ",vT(12,11,e.totalRow().completionTokens,e.formatTokenValue)," "),sI(3),Kg(vT(15,14,e.totalRow().totalTokens,e.formatTokenValue)),sI(3),Kg(e.totalRow().callCount),sI(2),Dl(" ",DT(20,17,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)," ");}}function rt(o,t){if(o&1&&(Cs(0,"div",18)(1,"section",16)(2,"div",26),JC(3,"Summary"),hl(),Cs(4,"div",27)(5,"div",28)(6,"div",29),JC(7,"agentName"),hl(),Cs(8,"div",29),JC(9,"providerName"),hl(),Cs(10,"div",29),JC(11,"modelId"),hl(),Cs(12,"div",30),JC(13,"promptTokens"),hl(),Cs(14,"div",30),JC(15,"completionTokens"),hl(),Cs(16,"div",30),JC(17,"totalTokens"),hl(),Cs(18,"div",30),JC(19,"callCount"),hl(),Cs(20,"div",30),JC(21,"cost"),hl()(),Cs(22,"div",31),dC(23,at,21,21,"div",32,iC().trackRow,true),aC(25,it,21,21,"div",33),hl()()(),Cs(26,"section",16)(27,"div",26),JC(28,"Daily series"),hl(),Mg(29,"app-daily-series-chart",34),hl()()),o&2){let e=CC();sI(23),fC(e.rows()),sI(2),cC(e.totalRow()?25:-1),sI(4),_g("points",e.chartPoints());}}var Ee="\u2014",Oe=class o{location=g(xm);state=g(J);view=Wi("byModel");rowsByAgent=TT(()=>this.state.aggregation()?.models??[]);totalRow=TT(()=>this.state.aggregation()?.total??null);rowsByModel=TT(()=>this.state.aggregationByModelId()??[]);chartPointsByAgent=TT(()=>{let t=this.state.series()??[];return this.aggregateDailyPoints(t)});chartPointsByModel=TT(()=>{let t=this.state.seriesByModelId()??[];return this.aggregateDailyPoints(t)});chartPoints=TT(()=>this.view()==="byAgent"?this.chartPointsByAgent():this.chartPointsByModel());rows=TT(()=>this.view()==="byAgent"?this.rowsByAgent():this.rowsByModel());isEmpty=TT(()=>{let t=this.state.aggregation();return t?(t.models?.length??0)===0&&(t.total?.callCount??0)===0:false});ngOnInit(){this.state.init();}onFromChange(t){this.state.setDraftFrom(t||null);}onToChange(t){this.state.setDraftTo(t||null);}clearFrom(){this.state.clearDraftFrom();}clearTo(){this.state.clearDraftTo();}apply(){this.state.apply();}aggregateDailyPoints(t){let e=new Map;for(let n of t){let i=e.get(n.date);if(!i)e.set(n.date,{date:n.date,promptTokens:n.promptTokens,completionTokens:n.completionTokens,cost:n.cost??0,callCount:n.callCount??0});else {let d=(u,f)=>u===null&&f===null?null:(u??0)+(f??0);i.promptTokens=d(i.promptTokens,n.promptTokens),i.completionTokens=d(i.completionTokens,n.completionTokens),i.cost=(i.cost??0)+(n.cost??0),i.callCount=(i.callCount??0)+(n.callCount??0);}}return [...e.values()].sort((n,i)=>n.date<i.date?-1:1)}trackRow(t,e){return `${e.agentName}|${e.providerName}|${e.modelId}`}isMissingPeriod=TT(()=>{if(this.state.loading())return false;let t=this.state.aggregation()?.total;return t?t.totalTokens===null&&(t.cost===null||t.cost===void 0):false});isPartialPeriod=TT(()=>!this.isMissingPeriod()&&this.state.tokenDataPartial());navigateBack(){this.location.back();}formatTokenValue(t){return t===null?Ee:new $b("en-US").transform(t,"1.0-2")??"0"}formatCostValue(t,e){return t?Ee:"$"+(new $b("en-US").transform(e??0,"1.2-2")??"0.00")}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=jw({type:o,selectors:[["app-token-usage"]],decls:41,vars:8,consts:[[1,"page"],[1,"page__header"],[1,"page__title-block"],["mat-icon-button","","title","Back",3,"click"],[1,"page__title"],[1,"page__subtitle"],[1,"filters"],[1,"filters__field"],[1,"filters__label"],[1,"filters__control"],["type","date",1,"filters__input",3,"ngModelChange","ngModel"],["type","button",1,"filters__clear",3,"click","disabled"],[1,"filters__select",3,"ngModelChange","ngModel"],["value","byModel"],["value","byAgent"],["type","button",1,"filters__apply",3,"click","disabled"],[1,"card"],[1,"card","card--error"],[1,"grid"],[1,"kpis"],[1,"kpi"],[1,"kpi__label"],[1,"kpi__value"],["title","Some calls in this period were recorded before token tracking was enabled. Token counts reflect only the portion where data was collected.",1,"hint"],["title","No token usage data was collected for this period.",1,"hint"],[1,"muted"],[1,"card__title"],[1,"table"],[1,"table__head"],[1,"table__cell"],[1,"table__cell","table__cell--num"],[1,"table__body"],[1,"table__row"],[1,"table__row","table__row--total"],[3,"points"]],template:function(e,n){e&1&&(Cs(0,"section",0)(1,"header",1)(2,"div",2)(3,"button",3),kg("click",function(){return n.navigateBack()}),Cs(4,"mat-icon"),JC(5,"chevron_left"),hl()(),Cs(6,"div")(7,"h1",4),JC(8,"Token Usage"),hl(),Cs(9,"p",5),JC(10,"Track prompt and completion token usage by agent and model."),hl()()(),Cs(11,"div",6)(12,"label",7)(13,"span",8),JC(14,"From"),hl(),Cs(15,"div",9)(16,"input",10),kg("ngModelChange",function(d){return n.onFromChange(d)}),hl(),ZI(),Cs(17,"button",11),kg("click",function(){return n.clearFrom()}),JC(18," Clear "),hl()()(),Cs(19,"label",7)(20,"span",8),JC(21,"To"),hl(),Cs(22,"div",9)(23,"input",10),kg("ngModelChange",function(d){return n.onToChange(d)}),hl(),ZI(),Cs(24,"button",11),kg("click",function(){return n.clearTo()}),JC(25," Clear "),hl()()(),Cs(26,"label",7)(27,"span",8),JC(28,"View"),hl(),Cs(29,"select",12),kg("ngModelChange",function(d){return n.view.set(d)}),Cs(30,"option",13),JC(31,"By model"),hl(),Cs(32,"option",14),JC(33,"By agent"),hl()(),ZI(),hl(),Cs(34,"button",15),kg("click",function(){return n.apply()}),JC(35,"Apply"),hl()()(),aC(36,et,20,12),aC(37,tt,3,0,"div",16)(38,nt,5,1,"div",17)(39,ot,5,0,"div",16)(40,rt,30,2,"div",18),hl()),e&2&&(sI(16),_g("ngModel",n.state.draftFilters().from),QI(),sI(),_g("disabled",!n.state.draftFilters().from),sI(6),_g("ngModel",n.state.draftFilters().to),QI(),sI(),_g("disabled",!n.state.draftFilters().to),sI(5),_g("ngModel",n.view()),QI(),sI(5),_g("disabled",n.state.loading()),sI(2),cC(n.totalRow()?36:-1),sI(),cC(n.state.loading()?37:n.state.error()?38:n.isEmpty()?39:40));},dependencies:[ti,Qn,ei,Ye$1,At,Zn,cn,j,hr,Gn,yt,wt,K,Q],styles:[".page[_ngcontent-%COMP%]{padding:1.5rem;color:var(--color-text, #1d1d1f)}.page__header[_ngcontent-%COMP%]{display:flex;align-items:flex-start;justify-content:space-between;gap:1.5rem;margin-bottom:1rem}.page__title-block[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.75rem}.page__title[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:650}.page__subtitle[_ngcontent-%COMP%]{margin:.25rem 0 0;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.95rem}.filters[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:flex-end;gap:.75rem}.filters__field[_ngcontent-%COMP%]{display:grid;gap:.25rem}.filters__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.filters__control[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}.filters__input[_ngcontent-%COMP%], .filters__select[_ngcontent-%COMP%]{height:34px;padding:0 .5rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f)}.filters__apply[_ngcontent-%COMP%], .filters__clear[_ngcontent-%COMP%]{height:34px;padding:0 .75rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f);cursor:pointer}.kpis[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.75rem;margin:.75rem 0 1rem}@media(max-width:900px){.kpis[_ngcontent-%COMP%]{grid-template-columns:1fr}}.kpi[_ngcontent-%COMP%]{border-radius:14px;padding:.75rem 1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.kpi__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.kpi__value[_ngcontent-%COMP%]{margin-top:.25rem;font-size:1.2rem;font-weight:650;font-variant-numeric:tabular-nums}.filters__apply[_ngcontent-%COMP%]{border-color:var(--color-primary, #007aff);background:var(--color-primary, #007aff);color:var(--color-text-inverse, #ffffff)}.filters__apply[_ngcontent-%COMP%]:disabled, .filters__clear[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1.5fr 1fr;gap:1rem;align-items:start}@media(max-width:1100px){.grid[_ngcontent-%COMP%]{grid-template-columns:1fr}}.card[_ngcontent-%COMP%]{border-radius:14px;padding:1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.card--error[_ngcontent-%COMP%]{border-color:var(--color-error, #ff3b30)}.card__title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:.75rem}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.table[_ngcontent-%COMP%]{overflow-x:auto}.table__head[_ngcontent-%COMP%], .table__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr 2fr 1fr 1fr 1fr .7fr 1fr;gap:.5rem;align-items:center}.table__head[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));padding:.25rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row[_ngcontent-%COMP%]{padding:.5rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row--total[_ngcontent-%COMP%]{font-weight:650;background:var(--color-bg-hover, rgba(0, 0, 0, .03));border-radius:10px;padding:.6rem .5rem;border-bottom:none;margin-top:.5rem}.table__cell[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.table__cell--num[_ngcontent-%COMP%]{text-align:right;font-variant-numeric:tabular-nums}.hint[_ngcontent-%COMP%]{margin:.25rem 0 1rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}"],changeDetection:1})};export{Oe as TokenUsageComponent};
1
+ import {g,bm as Om,W as Wi,T as TT,cF as $b,j as jw,h as hr,i as Gn,k as Cs,n as Lg,J as JC,m as hl,a3 as ZI,o as aC,u as sI,x as xg,a6 as QI,v as cC,C as Ce,z as z$1,a as P,S as Wy,b as U,Y as x,b1 as On,bf as gT,ac as CC,a8 as em,bi as vT,cG as DT,q as dC,cH as iC,A as Ag,w as fC,E as vy,cI as xt,aw as gl,ax as ml,c9 as Bf,b6 as Rg,ck as Vf,N as Ng,a5 as Dl,a9 as vC,cJ as jg,aa as Sf,ab as _f,ad as Wg}from'./main-4LGWVPVH.js';import {t as ti,Q as Qn,e as ei,Y as Ye$1,A as At,Z as Zn,c as cn,y as yt,w as wt}from'./chunk-CPuMGlfm.js';var Ae=(o,t)=>t.date,He=(o,t)=>t.x,$e=(o,t)=>t.label;function Ve(o,t){o&1&&(gl(0,"div",0),JC(1,"No daily data points for this period."),ml());}function Le(o,t){if(o&1&&(Bf(),Rg(0,"rect",18)),o&2){let e=CC().$implicit,n=CC(2);Ng("x",e.w+6)("y",n.yBase-e.tokensStubH)("width",e.w)("height",e.tokensStubH);}}function Ge(o,t){if(o&1&&(Bf(),Rg(0,"rect",19)(1,"rect",20)),o&2){let e=CC().$implicit,n=CC(2);Ng("x",e.w+6)("y",n.yBase-(e.promptH??0))("width",e.w)("height",e.promptH??0),sI(),Ng("x",e.w+6)("y",n.yBase-((e.promptH??0)+(e.completionH??0)))("width",e.w)("height",e.completionH??0);}}function Ye(o,t){if(o&1){let e=vC();Bf(),gl(0,"g",15),jg("mouseenter",function(i){let d=Sf(e).$implicit,u=CC(2);return _f(u.showTooltip(i,d.point))})("mousemove",function(i){let d=Sf(e).$implicit,u=CC(2);return _f(u.showTooltip(i,d.point))})("mouseleave",function(){Sf(e);let i=CC(2);return _f(i.hideTooltip())}),Rg(1,"rect",16)(2,"rect",17),aC(3,Le,1,4,":svg:rect",18)(4,Ge,2,8),ml();}if(o&2){let e=t.$implicit,n=CC(2);Ng("transform","translate("+e.xGroup+",0)"),sI(),Ng("y",n.yTop)("width",e.groupW)("height",n.yBase-n.yTop),sI(),Ng("y",n.yBase-e.costH)("width",e.w)("height",e.costH),sI(),cC(e.tokensStubH!==null?3:4);}}function We(o,t){if(o&1&&(Bf(),gl(0,"text",5),JC(1),ml()),o&2){let e=t.$implicit,n=CC(2);Ng("x",e.x)("y",n.yAxis),sI(),em(e.label);}}function je(o,t){if(o&1&&(gl(0,"div",24),JC(1),ml(),gl(2,"div",25),JC(3),ml()),o&2){let e=t.$implicit;sI(),em(e.label),sI(2),em(e.value);}}function ze(o,t){if(o&1&&(gl(0,"div",21)(1,"div",22),JC(2),ml(),gl(3,"div",23),dC(4,je,4,2,null,null,$e),ml()()),o&2){let e=CC(2);Wg("left",e.tooltip().x+12,"px")("top",e.tooltip().y+12,"px"),sI(2),em(e.tooltip().data.date),sI(2),fC(e.tooltipLines());}}function Xe(o,t){if(o&1&&(gl(0,"div",8)(1,"span",10),JC(2),ml()()),o&2){let e=CC(2);sI(2),em(e.tokenCoverageLabel());}}function Je(o,t){if(o&1&&(gl(0,"div",1),Bf(),gl(1,"svg",2),Rg(2,"line",3)(3,"line",3),dC(4,Ye,5,8,":svg:g",4,Ae),dC(6,We,2,3,":svg:text",5,He),ml(),aC(8,ze,6,5,"div",6),Vf(),gl(9,"div",7)(10,"div",8),Rg(11,"span",9),gl(12,"span",10),JC(13,"Cost (per day)"),ml(),gl(14,"span",11),JC(15),ml()(),gl(16,"div",8),Rg(17,"span",12),gl(18,"span",10),JC(19,"Prompt tokens"),ml()(),gl(20,"div",8),Rg(21,"span",13),gl(22,"span",10),JC(23,"Completion tokens"),ml()(),gl(24,"div",8),Rg(25,"span",14),gl(26,"span",10),JC(27,"Tokens missing"),ml()(),gl(28,"div",8)(29,"span",10),JC(30,"Tokens scale"),ml(),gl(31,"span",11),JC(32),ml()(),aC(33,Xe,3,1,"div",8),ml()()),o&2){let e=CC();sI(),Ng("viewBox",e.viewBox),sI(),Ng("y1",e.yTop)("x2",720)("y2",e.yTop),sI(),Ng("y1",e.yBase)("x2",720)("y2",e.yBase),sI(),fC(e.bars()),sI(2),fC(e.axisLabels()),sI(2),cC(e.tooltip().visible&&e.tooltip().data?8:-1),sI(7),Dl("max ",e.maxCostLabel()),sI(17),Dl("max ",e.maxTokensLabel()),sI(),cC(e.tokenCoverageLabel()?33:-1);}}var j=class o{points=[];width=720;height=240;paddingX=12;paddingY=16;bottomAxisH=48;viewBox=`0 0 ${this.width} ${this.height}`;innerW=this.width-this.paddingX*2;innerH=this.height-this.paddingY*2-this.bottomAxisH;barGap=6;groupGap=14;safePoints=TT(()=>(this.points??[]).filter(t=>!!t.date));maxCost=TT(()=>Math.max(0,...this.safePoints().map(t=>t.cost??0)));maxTokens=TT(()=>{let t=this.safePoints().map(e=>{let n=e.promptTokens??null,i=e.completionTokens??null;return n===null&&i===null?null:(n??0)+(i??0)}).filter(e=>e!==null);return Math.max(0,...t)});tokenCoverageLabel=TT(()=>{let t=this.safePoints();return t.length===0?"":`Tokens available for ${t.filter(n=>n.promptTokens!==null||n.completionTokens!==null).length}/${t.length} days`});maxCostLabel=TT(()=>"$"+(new $b("en-US").transform(this.maxCost(),"1.2-2")??"0.00"));maxTokensLabel=TT(()=>new $b("en-US").transform(this.maxTokens(),"1.0-2")??"0");tooltip=Wi({visible:false,x:0,y:0,data:null});toTooltipData(t){let e=t.promptTokens,n=t.completionTokens,i=e===null&&n===null?null:(e??0)+(n??0);return {date:t.date,cost:t.cost??0,promptTokens:e,completionTokens:n,totalTokens:i,callCount:t.callCount??0}}showTooltip(t,e){let i=t.currentTarget?.closest(".chart")?.getBoundingClientRect(),d=i?t.clientX-i.left:t.clientX,u=i?t.clientY-i.top:t.clientY,f=320,k=170,U=12,C=i?Math.max(0,i.width-f-U):d,B=i?Math.max(0,i.height-k-U):u,F=i?Math.min(Math.max(0,d),C):d,ne=i?Math.min(Math.max(0,u),B):u;this.tooltip.set({visible:true,x:F,y:ne,data:this.toTooltipData(e)});}hideTooltip(){this.tooltip.update(t=>z$1(P({},t),{visible:false}));}formatTokens(t){return t===null?"\u2014":new $b("en-US").transform(t,"1.0-2")??"0"}formatCost(t){return "$"+(new $b("en-US").transform(t??0,"1.2-2")??"0.00")}tooltipLines=TT(()=>{let t=this.tooltip(),e=t.data;return !t.visible||!e?[]:[{label:"Cost",value:this.formatCost(e.cost)},{label:"Prompt tokens",value:this.formatTokens(e.promptTokens)},{label:"Completion tokens",value:this.formatTokens(e.completionTokens)},{label:"Total tokens",value:this.formatTokens(e.totalTokens)},{label:"Calls",value:`${e.callCount}`}]});bars=TT(()=>{let t=this.safePoints(),e=t.length;if(e===0)return [];let n=(this.innerW-(e-1)*this.groupGap)/e,i=Math.max(2,n),d=(i-this.barGap)/2,u=Math.max(1,d),f=this.maxCost()||1,k=this.maxTokens()||1,U=45;return t.map((C,B)=>{let F=this.paddingX+B*(i+this.groupGap),Ie=(C.cost??0)/f*this.innerH,oe=C.promptTokens,ae=C.completionTokens,Z=oe!==null||ae!==null,Ne=oe??0,Ue=ae??0,Be=Z?Ne/k*this.innerH:null,Fe=Z?Ue/k*this.innerH:null;return {date:C.date,point:C,xGroup:F,groupW:i,xCost:F,w:u,costH:Ie,xTokens:F+u+this.barGap,promptH:Be,completionH:Fe,tokensStubH:Z?null:U}})});axisLabels=TT(()=>{let t=this.safePoints(),e=t.length;if(e===0)return [];let i=Math.max(1,Math.ceil(e/8)),d=(this.innerW-(e-1)*this.groupGap)/e,u=Math.max(2,d);return t.map((f,k)=>({p:f,i:k})).filter(({i:f})=>f%i===0||f===e-1).map(({p:f,i:k})=>{let C=this.paddingX+k*(u+this.groupGap)+u/2,B=f.date.slice(5);return {x:C,label:B}})});yTop=this.paddingY;yBase=this.paddingY+this.innerH;yAxis=this.yBase+28;static \u0275fac=function(e){return new(e||o)};static \u0275cmp=jw({type:o,selectors:[["app-daily-series-chart"]],inputs:{points:"points"},decls:2,vars:1,consts:[[1,"muted"],[1,"chart"],["preserveAspectRatio","none","role","img","aria-label","Daily token and cost usage",1,"chart__svg"],["x1","0",1,"chart__grid"],[1,"chart__day"],["text-anchor","middle",1,"chart__axis-label"],[1,"chart__tooltip",3,"left","top"],[1,"chart__legend"],[1,"chart__legend-item"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--cost"],[1,"chart__legend-label"],[1,"chart__legend-value"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--prompt"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--completion"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--tokens-missing"],[1,"chart__day",3,"mouseenter","mousemove","mouseleave"],["x","0",1,"chart__hover"],["x","0",1,"chart__bar","chart__bar--cost"],[1,"chart__bar","chart__bar--tokens-missing"],[1,"chart__bar","chart__bar--prompt"],[1,"chart__bar","chart__bar--completion"],[1,"chart__tooltip"],[1,"chart__tooltip-title"],[1,"chart__tooltip-grid"],[1,"chart__tooltip-label"],[1,"chart__tooltip-value"]],template:function(e,n){e&1&&aC(0,Ve,2,0,"div",0)(1,Je,34,11,"div",1),e&2&&cC(n.safePoints().length===0?0:1);},styles:[".chart[_ngcontent-%COMP%]{display:grid;gap:.5rem;position:relative}.chart__svg[_ngcontent-%COMP%]{width:100%;height:260px;display:block;border-radius:12px;background:var(--color-bg-secondary, rgba(255, 255, 255, .72));border:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.chart__grid[_ngcontent-%COMP%]{stroke:var(--color-border-light, rgba(0, 0, 0, .08));stroke-width:1}.chart__day[_ngcontent-%COMP%]{cursor:default}.chart__hover[_ngcontent-%COMP%]{fill:transparent}.chart__day[_ngcontent-%COMP%]:hover .chart__hover[_ngcontent-%COMP%]{fill:var(--color-bg-hover, rgba(0, 0, 0, .03))}.chart__tooltip[_ngcontent-%COMP%]{position:absolute;z-index:2;min-width:220px;max-width:320px;padding:10px 12px;border-radius:12px;background:rgb(var(--color-bg-secondary-rgb, 255 255 255)/1);border:1px solid var(--color-border-light, rgba(0, 0, 0, .08));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .12));pointer-events:none}.chart__tooltip-title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:6px}.chart__tooltip-grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr auto;column-gap:10px;row-gap:4px}.chart__tooltip-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__tooltip-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums;text-align:right}.chart__bar[_ngcontent-%COMP%]{shape-rendering:geometricPrecision;rx:2;ry:2}.chart__bar--cost[_ngcontent-%COMP%]{fill:var(--color-primary, #007aff);opacity:.85}.chart__bar--prompt[_ngcontent-%COMP%]{fill:var(--color-success, #34c759);opacity:.85}.chart__bar--completion[_ngcontent-%COMP%]{fill:var(--color-warning, #ff9500);opacity:.85}.chart__bar--tokens-missing[_ngcontent-%COMP%]{fill:transparent;stroke:var(--color-text-secondary, rgba(29, 29, 31, .55));stroke-width:1.5;stroke-dasharray:4 3}.chart__axis-label[_ngcontent-%COMP%]{fill:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:12px;font-variant-numeric:tabular-nums}.chart__legend[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:.75rem;flex-wrap:wrap}.chart__legend-item[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:baseline}.chart__legend-swatch[_ngcontent-%COMP%]{width:10px;height:10px;border-radius:3px;align-self:center}.chart__legend-swatch--cost[_ngcontent-%COMP%]{background:var(--color-primary, #007aff)}.chart__legend-swatch--prompt[_ngcontent-%COMP%]{background:var(--color-success, #34c759)}.chart__legend-swatch--completion[_ngcontent-%COMP%]{background:var(--color-warning, #ff9500)}.chart__legend-swatch--tokens-missing[_ngcontent-%COMP%]{background:transparent;border:1px dashed var(--color-text-secondary, rgba(29, 29, 31, .55))}.chart__legend-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__legend-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}"]})};var X=class o{http=g(vy);getTokenUsage(t){let e=new xt;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage",{params:e})}getTokenUsageSeries(t){let e=new xt;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage/series",{params:e})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=x({token:o,factory:o.\u0275fac,providedIn:"root"})};function Pe(o){return `${o}`.padStart(2,"0")}function we(o){return `${o.getUTCFullYear()}-${Pe(o.getUTCMonth()+1)}-${Pe(o.getUTCDate())}`}function qe(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),1))}function Ke(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth()+1,1))}var J=class o{api=g(X);destroyRef=g(Ce);defaultFrom=we(qe());defaultTo=we(Ke());draftFilters=Wi({from:this.defaultFrom,to:this.defaultTo});appliedFilters=Wi({from:this.defaultFrom,to:this.defaultTo});loading=Wi(false);error=Wi(null);aggregation=Wi(null);seriesResponse=Wi(null);series=Wi(null);tokenDataPartial=Wi(false);aggregationByModelId=Wi(null);seriesByModelId=Wi(null);init(){this.reload();}setDraftFrom(t){this.draftFilters.update(e=>z$1(P({},e),{from:t}));}setDraftTo(t){this.draftFilters.update(e=>z$1(P({},e),{to:t}));}clearDraftFrom(){this.setDraftFrom(null);}clearDraftTo(){this.setDraftTo(null);}apply(){this.appliedFilters.set(this.draftFilters()),this.reload();}addNullableTokens(t,e){return t===null&&e===null?null:(t??0)+(e??0)}aggregateByModelId(t){let e=new Map;for(let n of t){let i=n.modelId,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0});}return [...e.values()].sort((n,i)=>(i.totalTokens??0)-(n.totalTokens??0))}aggregateSeriesByModelId(t){let e=new Map;for(let n of t){let i=`${n.date}|${n.modelId}`,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{date:n.date,agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0});}return [...e.values()].sort((n,i)=>n.date<i.date?-1:1)}reload(){let{from:t,to:e}=this.appliedFilters();this.loading.set(true),this.error.set(null),Wy({aggregation:this.api.getTokenUsage({from:t,to:e}),series:this.api.getTokenUsageSeries({from:t,to:e})}).pipe(U(this.destroyRef)).subscribe({next:({aggregation:n,series:i})=>{this.aggregation.set(n),this.seriesResponse.set(i);let d=i.points??[];this.series.set(d),this.tokenDataPartial.set(n.tokenDataPartial||i.tokenDataPartial);let u=this.aggregateByModelId(n.models??[]);this.aggregationByModelId.set(u),this.seriesByModelId.set(this.aggregateSeriesByModelId(d)),this.loading.set(false);},error:n=>{this.loading.set(false),this.aggregation.set(null),this.seriesResponse.set(null),this.series.set(null),this.tokenDataPartial.set(false),this.aggregationByModelId.set(null),this.seriesByModelId.set(null),this.error.set(n instanceof Error?n.message:"Failed to load token usage");}});}static \u0275fac=function(e){return new(e||o)};static \u0275prov=x({token:o,factory:o.\u0275fac,providedIn:"root"})};var q=function(){throw new Error("DON'T USE this INSIDE A FUNCTION CALLED BY | call OR | apply IT MUST BE A PURE FUNCTION!")},De=typeof Proxy!="function"?Object.seal({}):new Proxy({},{get:q,set:q,deleteProperty:q,has:q}),K=class o{transform(t,e){if(typeof e!="function")throw new TypeError("You must pass a PURE function to | call");return e?.call(De,t)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=On({name:"call",type:o,pure:true})},Q=class o{transform(t,...e){if(typeof t!="function")throw new TypeError("You must use | apply on a PURE function");return t.apply(De,e)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=On({name:"apply",type:o,pure:true})};function Qe(o,t){o&1&&(Cs(0,"div",23),JC(1," Partial data \u2014 token counts may not cover the full period "),hl());}function Ze(o,t){o&1&&(Cs(0,"div",24),JC(1," No token data collected for this period "),hl());}function et(o,t){if(o&1&&(Cs(0,"div",19)(1,"div",20)(2,"div",21),JC(3,"Total tokens"),hl(),Cs(4,"div",22),JC(5),gT(6,"call"),hl()(),Cs(7,"div",20)(8,"div",21),JC(9,"Total calls"),hl(),Cs(10,"div",22),JC(11),hl()(),Cs(12,"div",20)(13,"div",21),JC(14,"Total cost"),hl(),Cs(15,"div",22),JC(16),gT(17,"apply"),hl()()(),aC(18,Qe,2,0,"div",23),aC(19,Ze,2,0,"div",24)),o&2){let e=CC();sI(5),em(vT(6,5,e.totalRow().totalTokens,e.formatTokenValue)),sI(6),em(e.totalRow().callCount),sI(5),em(DT(17,8,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)),sI(2),cC(e.isPartialPeriod()?18:-1),sI(),cC(e.isMissingPeriod()?19:-1);}}function tt(o,t){o&1&&(Cs(0,"div",16)(1,"div",25),JC(2,"Loading token usage\u2026"),hl()());}function nt(o,t){if(o&1&&(Cs(0,"div",17)(1,"div",26),JC(2,"Failed to load"),hl(),Cs(3,"div",25),JC(4),hl()()),o&2){let e=CC();sI(4),em(e.state.error());}}function ot(o,t){o&1&&(Cs(0,"div",16)(1,"div",26),JC(2,"No data"),hl(),Cs(3,"div",25),JC(4,"No token usage recorded yet for this period."),hl()());}function at(o,t){if(o&1&&(Cs(0,"div",32)(1,"div",29),JC(2),hl(),Cs(3,"div",29),JC(4),hl(),Cs(5,"div",29),JC(6),hl(),Cs(7,"div",30),JC(8),gT(9,"call"),hl(),Cs(10,"div",30),JC(11),gT(12,"call"),hl(),Cs(13,"div",30),JC(14),gT(15,"call"),hl(),Cs(16,"div",30),JC(17),hl(),Cs(18,"div",30),JC(19),gT(20,"apply"),hl()()),o&2){let e=t.$implicit,n=CC(2);sI(2),em(e.agentName),sI(2),em(e.providerName),sI(2),em(e.modelId),sI(2),em(vT(9,8,e.promptTokens,n.formatTokenValue)),sI(3),em(vT(12,11,e.completionTokens,n.formatTokenValue)),sI(3),em(vT(15,14,e.totalTokens,n.formatTokenValue)),sI(3),em(e.callCount),sI(2),Dl(" ",DT(20,17,n.formatCostValue,n.isMissingPeriod(),e.cost)," ");}}function it(o,t){if(o&1&&(Cs(0,"div",33)(1,"div",29),JC(2),hl(),Cs(3,"div",29),JC(4),hl(),Cs(5,"div",29),JC(6),hl(),Cs(7,"div",30),JC(8),gT(9,"call"),hl(),Cs(10,"div",30),JC(11),gT(12,"call"),hl(),Cs(13,"div",30),JC(14),gT(15,"call"),hl(),Cs(16,"div",30),JC(17),hl(),Cs(18,"div",30),JC(19),gT(20,"apply"),hl()()),o&2){let e=CC(2);sI(2),em(e.totalRow().agentName),sI(2),em(e.totalRow().providerName),sI(2),em(e.totalRow().modelId),sI(2),em(vT(9,8,e.totalRow().promptTokens,e.formatTokenValue)),sI(3),Dl(" ",vT(12,11,e.totalRow().completionTokens,e.formatTokenValue)," "),sI(3),em(vT(15,14,e.totalRow().totalTokens,e.formatTokenValue)),sI(3),em(e.totalRow().callCount),sI(2),Dl(" ",DT(20,17,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)," ");}}function rt(o,t){if(o&1&&(Cs(0,"div",18)(1,"section",16)(2,"div",26),JC(3,"Summary"),hl(),Cs(4,"div",27)(5,"div",28)(6,"div",29),JC(7,"agentName"),hl(),Cs(8,"div",29),JC(9,"providerName"),hl(),Cs(10,"div",29),JC(11,"modelId"),hl(),Cs(12,"div",30),JC(13,"promptTokens"),hl(),Cs(14,"div",30),JC(15,"completionTokens"),hl(),Cs(16,"div",30),JC(17,"totalTokens"),hl(),Cs(18,"div",30),JC(19,"callCount"),hl(),Cs(20,"div",30),JC(21,"cost"),hl()(),Cs(22,"div",31),dC(23,at,21,21,"div",32,iC().trackRow,true),aC(25,it,21,21,"div",33),hl()()(),Cs(26,"section",16)(27,"div",26),JC(28,"Daily series"),hl(),Ag(29,"app-daily-series-chart",34),hl()()),o&2){let e=CC();sI(23),fC(e.rows()),sI(2),cC(e.totalRow()?25:-1),sI(4),xg("points",e.chartPoints());}}var Ee="\u2014",Oe=class o{location=g(Om);state=g(J);view=Wi("byModel");rowsByAgent=TT(()=>this.state.aggregation()?.models??[]);totalRow=TT(()=>this.state.aggregation()?.total??null);rowsByModel=TT(()=>this.state.aggregationByModelId()??[]);chartPointsByAgent=TT(()=>{let t=this.state.series()??[];return this.aggregateDailyPoints(t)});chartPointsByModel=TT(()=>{let t=this.state.seriesByModelId()??[];return this.aggregateDailyPoints(t)});chartPoints=TT(()=>this.view()==="byAgent"?this.chartPointsByAgent():this.chartPointsByModel());rows=TT(()=>this.view()==="byAgent"?this.rowsByAgent():this.rowsByModel());isEmpty=TT(()=>{let t=this.state.aggregation();return t?(t.models?.length??0)===0&&(t.total?.callCount??0)===0:false});ngOnInit(){this.state.init();}onFromChange(t){this.state.setDraftFrom(t||null);}onToChange(t){this.state.setDraftTo(t||null);}clearFrom(){this.state.clearDraftFrom();}clearTo(){this.state.clearDraftTo();}apply(){this.state.apply();}aggregateDailyPoints(t){let e=new Map;for(let n of t){let i=e.get(n.date);if(!i)e.set(n.date,{date:n.date,promptTokens:n.promptTokens,completionTokens:n.completionTokens,cost:n.cost??0,callCount:n.callCount??0});else {let d=(u,f)=>u===null&&f===null?null:(u??0)+(f??0);i.promptTokens=d(i.promptTokens,n.promptTokens),i.completionTokens=d(i.completionTokens,n.completionTokens),i.cost=(i.cost??0)+(n.cost??0),i.callCount=(i.callCount??0)+(n.callCount??0);}}return [...e.values()].sort((n,i)=>n.date<i.date?-1:1)}trackRow(t,e){return `${e.agentName}|${e.providerName}|${e.modelId}`}isMissingPeriod=TT(()=>{if(this.state.loading())return false;let t=this.state.aggregation()?.total;return t?t.totalTokens===null&&(t.cost===null||t.cost===void 0):false});isPartialPeriod=TT(()=>!this.isMissingPeriod()&&this.state.tokenDataPartial());navigateBack(){this.location.back();}formatTokenValue(t){return t===null?Ee:new $b("en-US").transform(t,"1.0-2")??"0"}formatCostValue(t,e){return t?Ee:"$"+(new $b("en-US").transform(e??0,"1.2-2")??"0.00")}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=jw({type:o,selectors:[["app-token-usage"]],decls:41,vars:8,consts:[[1,"page"],[1,"page__header"],[1,"page__title-block"],["mat-icon-button","","title","Back",3,"click"],[1,"page__title"],[1,"page__subtitle"],[1,"filters"],[1,"filters__field"],[1,"filters__label"],[1,"filters__control"],["type","date",1,"filters__input",3,"ngModelChange","ngModel"],["type","button",1,"filters__clear",3,"click","disabled"],[1,"filters__select",3,"ngModelChange","ngModel"],["value","byModel"],["value","byAgent"],["type","button",1,"filters__apply",3,"click","disabled"],[1,"card"],[1,"card","card--error"],[1,"grid"],[1,"kpis"],[1,"kpi"],[1,"kpi__label"],[1,"kpi__value"],["title","Some calls in this period were recorded before token tracking was enabled. Token counts reflect only the portion where data was collected.",1,"hint"],["title","No token usage data was collected for this period.",1,"hint"],[1,"muted"],[1,"card__title"],[1,"table"],[1,"table__head"],[1,"table__cell"],[1,"table__cell","table__cell--num"],[1,"table__body"],[1,"table__row"],[1,"table__row","table__row--total"],[3,"points"]],template:function(e,n){e&1&&(Cs(0,"section",0)(1,"header",1)(2,"div",2)(3,"button",3),Lg("click",function(){return n.navigateBack()}),Cs(4,"mat-icon"),JC(5,"chevron_left"),hl()(),Cs(6,"div")(7,"h1",4),JC(8,"Token Usage"),hl(),Cs(9,"p",5),JC(10,"Track prompt and completion token usage by agent and model."),hl()()(),Cs(11,"div",6)(12,"label",7)(13,"span",8),JC(14,"From"),hl(),Cs(15,"div",9)(16,"input",10),Lg("ngModelChange",function(d){return n.onFromChange(d)}),hl(),ZI(),Cs(17,"button",11),Lg("click",function(){return n.clearFrom()}),JC(18," Clear "),hl()()(),Cs(19,"label",7)(20,"span",8),JC(21,"To"),hl(),Cs(22,"div",9)(23,"input",10),Lg("ngModelChange",function(d){return n.onToChange(d)}),hl(),ZI(),Cs(24,"button",11),Lg("click",function(){return n.clearTo()}),JC(25," Clear "),hl()()(),Cs(26,"label",7)(27,"span",8),JC(28,"View"),hl(),Cs(29,"select",12),Lg("ngModelChange",function(d){return n.view.set(d)}),Cs(30,"option",13),JC(31,"By model"),hl(),Cs(32,"option",14),JC(33,"By agent"),hl()(),ZI(),hl(),Cs(34,"button",15),Lg("click",function(){return n.apply()}),JC(35,"Apply"),hl()()(),aC(36,et,20,12),aC(37,tt,3,0,"div",16)(38,nt,5,1,"div",17)(39,ot,5,0,"div",16)(40,rt,30,2,"div",18),hl()),e&2&&(sI(16),xg("ngModel",n.state.draftFilters().from),QI(),sI(),xg("disabled",!n.state.draftFilters().from),sI(6),xg("ngModel",n.state.draftFilters().to),QI(),sI(),xg("disabled",!n.state.draftFilters().to),sI(5),xg("ngModel",n.view()),QI(),sI(5),xg("disabled",n.state.loading()),sI(2),cC(n.totalRow()?36:-1),sI(),cC(n.state.loading()?37:n.state.error()?38:n.isEmpty()?39:40));},dependencies:[ti,Qn,ei,Ye$1,At,Zn,cn,j,hr,Gn,yt,wt,K,Q],styles:[".page[_ngcontent-%COMP%]{padding:1.5rem;color:var(--color-text, #1d1d1f)}.page__header[_ngcontent-%COMP%]{display:flex;align-items:flex-start;justify-content:space-between;gap:1.5rem;margin-bottom:1rem}.page__title-block[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.75rem}.page__title[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:650}.page__subtitle[_ngcontent-%COMP%]{margin:.25rem 0 0;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.95rem}.filters[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:flex-end;gap:.75rem}.filters__field[_ngcontent-%COMP%]{display:grid;gap:.25rem}.filters__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.filters__control[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}.filters__input[_ngcontent-%COMP%], .filters__select[_ngcontent-%COMP%]{height:34px;padding:0 .5rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f)}.filters__apply[_ngcontent-%COMP%], .filters__clear[_ngcontent-%COMP%]{height:34px;padding:0 .75rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f);cursor:pointer}.kpis[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.75rem;margin:.75rem 0 1rem}@media(max-width:900px){.kpis[_ngcontent-%COMP%]{grid-template-columns:1fr}}.kpi[_ngcontent-%COMP%]{border-radius:14px;padding:.75rem 1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.kpi__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.kpi__value[_ngcontent-%COMP%]{margin-top:.25rem;font-size:1.2rem;font-weight:650;font-variant-numeric:tabular-nums}.filters__apply[_ngcontent-%COMP%]{border-color:var(--color-primary, #007aff);background:var(--color-primary, #007aff);color:var(--color-text-inverse, #ffffff)}.filters__apply[_ngcontent-%COMP%]:disabled, .filters__clear[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1.5fr 1fr;gap:1rem;align-items:start}@media(max-width:1100px){.grid[_ngcontent-%COMP%]{grid-template-columns:1fr}}.card[_ngcontent-%COMP%]{border-radius:14px;padding:1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.card--error[_ngcontent-%COMP%]{border-color:var(--color-error, #ff3b30)}.card__title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:.75rem}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.table[_ngcontent-%COMP%]{overflow-x:auto}.table__head[_ngcontent-%COMP%], .table__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr 2fr 1fr 1fr 1fr .7fr 1fr;gap:.5rem;align-items:center}.table__head[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));padding:.25rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row[_ngcontent-%COMP%]{padding:.5rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row--total[_ngcontent-%COMP%]{font-weight:650;background:var(--color-bg-hover, rgba(0, 0, 0, .03));border-radius:10px;padding:.6rem .5rem;border-bottom:none;margin-top:.5rem}.table__cell[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.table__cell--num[_ngcontent-%COMP%]{text-align:right;font-variant-numeric:tabular-nums}.hint[_ngcontent-%COMP%]{margin:.25rem 0 1rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}"],changeDetection:1})};export{Oe as TokenUsageComponent};