@whoz-oss/coday-client 0.212.0 → 0.213.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/{chunk-6AVOYZCH.js → chunk-24GQIJ2V.js} +1 -1
- package/browser/{chunk-V4N6GKHW.js → chunk-2HEJ7K6I.js} +1 -1
- package/browser/{chunk-S5RA5ZES.js → chunk-4CDCFIEK.js} +1 -1
- package/browser/{chunk-7U5MROHI.js → chunk-4OCEBSTP.js} +1 -1
- package/browser/{chunk-NUQZWQIL.js → chunk-5GF6TTRK.js} +1 -1
- package/browser/{chunk-OINUZPA5.js → chunk-6MPSH5Y7.js} +1 -1
- package/browser/{chunk-PY555EP5.js → chunk-7FKWFZ3A.js} +1 -1
- package/browser/chunk-7FTSWXXP.js +1 -0
- package/browser/{chunk-CAGXAQN4.js → chunk-7RVP2EHC.js} +1 -1
- package/browser/{chunk-GUV6MT45.js → chunk-C3TALDAV.js} +1 -1
- package/browser/{chunk-E2KMSNBI.js → chunk-C47ZCNLR.js} +1 -1
- package/browser/{chunk-HV2LANES.js → chunk-CRJUN7EB.js} +1 -1
- package/browser/{chunk-XSG2UKSS.js → chunk-DB2U5ZVV.js} +1 -1
- package/browser/{chunk-QSWJW2CT.js → chunk-DEXRATBM.js} +1 -1
- package/browser/{chunk-FUCTIGHD.js → chunk-EFCBXNFU.js} +1 -1
- package/browser/{chunk-SPSSJANY.js → chunk-GVYMNRD4.js} +1 -1
- package/browser/{chunk-JEN2LAHJ.js → chunk-HMFEXHRI.js} +1 -1
- package/browser/{chunk-VLPN6IDQ.js → chunk-J7IFGV56.js} +1 -1
- package/browser/{chunk-K6PYQXSH.js → chunk-JCMCMBHO.js} +1 -1
- package/browser/{chunk-2M7UJVMC.js → chunk-JIPJ76UT.js} +1 -1
- package/browser/{chunk-SOAR3OAC.js → chunk-K7JRH3HO.js} +6 -6
- package/browser/{chunk-XRPNDAPU.js → chunk-KQVQSY4A.js} +1 -1
- package/browser/{chunk-KK4POI54.js → chunk-LCLP27IJ.js} +1 -1
- package/browser/{chunk-EKYOF32Y.js → chunk-MSMRBM6R.js} +1 -1
- package/browser/{chunk-DJOQI226.js → chunk-MVRV42NP.js} +1 -1
- package/browser/{chunk-O73HCJ4T.js → chunk-N5FLB2OL.js} +1 -1
- package/browser/{chunk-DVROUT7T.js → chunk-ONZHMPPP.js} +1 -1
- package/browser/{chunk-6SDJIZMP.js → chunk-OVCLHAFH.js} +1 -1
- package/browser/{chunk-WPII4MHK.js → chunk-QCUONBHJ.js} +1 -1
- package/browser/{chunk-M3LG5XSB.js → chunk-RTAXT4D4.js} +1 -1
- package/browser/{chunk-YTQT7NZE.js → chunk-TASI5WPN.js} +1 -1
- package/browser/{chunk-HPTWGGVI.js → chunk-TEJQAOQQ.js} +1 -1
- package/browser/chunk-UFZICL7S.js +1 -0
- package/browser/{chunk-UL6K7Q2E.js → chunk-VPYY4J2W.js} +1 -1
- package/browser/{chunk-3HJTBDXT.js → chunk-W7YYBRGC.js} +1 -1
- package/browser/{chunk-HPVNIFEJ.js → chunk-XEZKOM4R.js} +1 -1
- package/browser/{chunk-UR4HA56C.js → chunk-ZE2KJJWW.js} +1 -1
- package/browser/{chunk-3W2U42II.js → chunk-ZPHUI4F6.js} +1 -1
- package/browser/index.html +1 -1
- package/browser/{main-HWU5NMWS.js → main-JYYTUNUG.js} +1 -1
- package/package.json +1 -1
- package/browser/chunk-S3LSARXT.js +0 -1
- package/browser/chunk-VOUBTGWM.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as E}from"./chunk-BJM7MKOH.js";import{c as S,d as _,f as u,g as C}from"./chunk-QVW2GZXC.js";import{a as q,b as U,c as Y,d as Q}from"./chunk-7U5MROHI.js";import"./chunk-OWSH6KVW.js";import{e as I}from"./chunk-34BTCCLM.js";import"./chunk-WIYSZEOD.js";import"./chunk-4TH4ERQY.js";import{a as L,d as b}from"./chunk-NAHXPRXR.js";import"./chunk-CA4E6QDU.js";import"./chunk-QCDV42EK.js";import{a as $,c as H}from"./chunk-P4GNUQZT.js";import"./chunk-BZS55WHS.js";import"./chunk-V7NUXN3R.js";import"./chunk-KD3BJ52V.js";import"./chunk-UDEMKCGK.js";import"./chunk-SOAR3OAC.js";import"./chunk-EBAEYY2S.js";import"./chunk-C2XSJPYF.js";import"./chunk-BZ7URUNM.js";import"./chunk-SKBT6DBT.js";import"./chunk-GF3EMWCA.js";import"./chunk-Z6RFJ6L3.js";import"./chunk-LN55MSDV.js";import"./chunk-OPSHMM4H.js";import{B as x,Bb as M,Db as y,Fb as s,Jb as W,Ka as m,Kb as O,Lb as P,N as A,T as p,Tb as G,Ub as z,Wa as v,Z as F,ca as a,d as k,ga as c,h as f,ha as d,lb as V,mb as j,rb as w,sb as h,tb as g,ub as R,vb as D,wb as B}from"./chunk-5NLXR4MK.js";var T=class o{welcomeMessages=["Welcome to Coday","Bienvenue sur Coday","Bienvenido a Coday","Willkommen bei Coday","Benvenuto su Coday","Bem-vindo ao Coday","Welkom bij Coday","\u0414\u043E\u0431\u0440\u043E \u043F\u043E\u0436\u0430\u043B\u043E\u0432\u0430\u0442\u044C \u0432 Coday","Coday \u3078\u3088\u3046\u3053\u305D","\u6B22\u8FCE\u6765\u5230 Coday","Coday \uC5D0 \uC624\uC2E0 \uAC83\uC744 \uD658\uC601\uD569\uB2C8\uB2E4","\u0645\u0631\u062D\u0628\u064B\u0627 \u0628\u0643 \u0641\u064A Coday"];currentWelcomeIndex=0;currentWelcomeMessage=this.welcomeMessages[0];welcomeRotationInterval;ngOnInit(){this.startWelcomeRotation()}ngOnDestroy(){this.stopWelcomeRotation()}startWelcomeRotation(){this.welcomeRotationInterval=window.setInterval(()=>{this.currentWelcomeIndex=(this.currentWelcomeIndex+1)%this.welcomeMessages.length,this.currentWelcomeMessage=this.welcomeMessages[this.currentWelcomeIndex]},3e3)}stopWelcomeRotation(){this.welcomeRotationInterval&&(clearInterval(this.welcomeRotationInterval),this.welcomeRotationInterval=void 0)}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=v({type:o,selectors:[["app-welcome-message"]],decls:2,vars:1,consts:[[1,"welcome-title"]],template:function(t,i){t&1&&(D(0,"h1",0),G(1),B()),t&2&&(m(),z(i.currentWelcomeMessage))},styles:[".welcome-title[_ngcontent-%COMP%]{font-size:clamp(1.5rem,4vw,4rem);font-weight:700;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% auto;background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;animation:_ngcontent-%COMP%_gradientShift 3s ease-in-out infinite;margin:0;padding:0;line-height:1.2;transition:opacity .5s ease-in-out;display:block;min-height:1.2em;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@keyframes _ngcontent-%COMP%_gradientShift{0%{background-position:0% center}50%{background-position:100% center}to{background-position:0% center}}"]})};var N=class o{destroy$=new f;isSetup=!1;codayService=a(I);preferencesService=a(b);setup(){if(this.isSetup){console.warn("[AGENT-NOTIFICATION] Service already set up");return}console.log("[AGENT-NOTIFICATION] Setting up agent notification service"),this.codayService.isThinking$.pipe(p(this.destroy$),A(),x(([e,t])=>e===!0&&t===!1)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Agent stopped thinking, notifying task finished"),this.notifyTaskFinishedIfEnabled()}),this.preferencesService.browserNotificationEnabled$.pipe(p(this.destroy$),A(),x(([e,t])=>e===!1&&t===!0)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Browser notifications enabled, checking permission"),this.handleBrowserNotificationEnabled()}),this.isSetup=!0}notifyTaskFinishedIfEnabled(){this.preferencesService.getAgentNotificationEnabled()&&(this.preferencesService.getNotificationSoundEnabled()&&this.playCompletionSound(),this.preferencesService.getBrowserNotificationEnabled()&&this.sendBrowserNotification())}playCompletionSound(){try{let e=new(window.AudioContext||window.webkitAudioContext),t=e.createOscillator(),i=e.createGain();t.connect(i),i.connect(e.destination),t.frequency.setValueAtTime(700,e.currentTime),i.gain.setValueAtTime(.1,e.currentTime),i.gain.exponentialRampToValueAtTime(.01,e.currentTime+.08),t.start(e.currentTime),t.stop(e.currentTime+.08);let n=e.createOscillator(),r=e.createGain();n.connect(r),r.connect(e.destination);let l=e.currentTime+.11;n.frequency.setValueAtTime(950,l),r.gain.setValueAtTime(.1,l),r.gain.exponentialRampToValueAtTime(.01,l+.09),n.start(l),n.stop(l+.09),console.log("[AGENT-NOTIFICATION] Completion sound played")}catch(e){console.error("[AGENT-NOTIFICATION] Failed to play completion sound:",e)}}handleBrowserNotificationEnabled(){return k(this,null,function*(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications"),this.preferencesService.setBrowserNotificationEnabled(!1);return}if(Notification.permission==="denied"){console.warn("[AGENT-NOTIFICATION] Permission denied, disabling browser notifications"),this.preferencesService.setBrowserNotificationEnabled(!1);return}if(Notification.permission==="granted"){console.log("[AGENT-NOTIFICATION] Permission already granted, showing confirmation"),this.createConfirmationNotification();return}try{(yield Notification.requestPermission())==="granted"?(console.log("[AGENT-NOTIFICATION] Permission granted, showing confirmation"),this.createConfirmationNotification()):(console.log("[AGENT-NOTIFICATION] Permission denied or dismissed"),this.preferencesService.setBrowserNotificationEnabled(!1))}catch(e){console.error("[AGENT-NOTIFICATION] Error requesting permission:",e),this.preferencesService.setBrowserNotificationEnabled(!1)}})}sendBrowserNotification(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications");return}if(document.hasFocus()){console.warn("[AGENT-NOTIFICATION] Document is focused, skipping browser notification");return}Notification.permission==="granted"?this.createTaskCompleteNotification():console.warn("[AGENT-NOTIFICATION] Permission not granted, cannot send notification")}createConfirmationNotification(){let e=new Notification("Coday - Notifications Enabled",{body:"You will be notified when the agent completes tasks",icon:"/favicon.ico",tag:"coday-notifications-enabled",requireInteraction:!1});setTimeout(()=>e.close(),4e3),e.onclick=()=>{window.focus(),e.close()},console.log("[AGENT-NOTIFICATION] Confirmation notification sent")}createTaskCompleteNotification(){let e=new Notification("Coday - Task Complete",{body:"The agent has finished and is waiting for your input",icon:"/favicon.ico",tag:"coday-task-complete",requireInteraction:!1});setTimeout(()=>e.close(),5e3),e.onclick=()=>{window.focus(),e.close()},console.log("[AGENT-NOTIFICATION] Task complete notification sent")}ngOnDestroy(){console.log("[AGENT-NOTIFICATION] Service destroyed"),this.destroy$.next(),this.destroy$.complete()}static \u0275fac=function(t){return new(t||o)};static \u0275prov=F({token:o,factory:o.\u0275fac,providedIn:"root"})};var Z=["inputSection"];function ee(o,e){if(o&1){let t=M();h(0,"app-thread",4),y("chatFocused",function(){c(t);let n=s();return d(n.onChatFocusedOnMobile())})("drawerStateChange",function(n){c(t);let r=s();return d(r.onDrawerStateChange(n))}),g()}if(o&2){let t=s();w("projectName",t.projectName)("threadId",t.threadId)}}function te(o,e){if(o&1){let t=M();h(0,"div",5),R(1,"app-welcome-message"),g(),h(2,"div",6,0)(4,"div",7)(5,"div",8)(6,"app-chat-textarea",9),y("messageSubmitted",function(n){c(t);let r=s();return d(r.onMessageSubmitted(n))})("voiceMessageReady",function(n){c(t);let r=s();return d(r.onVoiceMessageReady(n))})("voiceRecordingToggled",function(n){c(t);let r=s();return d(r.onVoiceToggled(n))})("heightChanged",function(n){c(t);let r=s();return d(r.onInputHeightChanged(n))})("textareaFocused",function(){c(t);let n=s();return d(n.onChatFocusedOnMobile())}),g()()()()}if(o&2){let t=s();m(6),w("isDisabled",t.isSessionInitializing)("isSessionInitializing",t.isSessionInitializing)("showWelcome",!0)("isThinking",!1)("isStarting",t.isStartingFirstMessage)}}var K=class o{destroy$=new f;inputSection;sidenav;projectName="";threadId=null;isSessionInitializing=!1;isStartingFirstMessage=!1;inputSectionHeight=80;codayService=a(I);titleService=a(U);preferencesService=a(b);route=a($);router=a(H);threadApiService=a(L);agentNotificationService=a(N);firstMessageState=a(Y);constructor(){console.log("[MAIN-APP] Using new thread-based architecture (no clientId needed)")}ngOnInit(){this.agentNotificationService.setup(),this.setupPrintHandlers(),this.route.params.pipe(p(this.destroy$)).subscribe(e=>{let t=e.projectName,i=e.threadId||null;console.log("[MAIN-APP] Route params updated:",{project:t,thread:i,previousProject:this.projectName,previousThread:this.threadId}),this.projectName=t,this.threadId=i,this.threadId?console.log("[MAIN-APP] Thread selected - ThreadComponent will display"):(console.log("[MAIN-APP] No thread selected - showing welcome view"),this.initializeWelcomeView())})}initializeWelcomeView(){this.codayService.setTabTitleService(this.titleService)}ngAfterViewInit(){setTimeout(()=>this.updateInputSectionHeight(),100)}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),window.removeEventListener("beforeprint",this.handleBeforePrint),window.removeEventListener("afterprint",this.handleAfterPrint)}onMessageSubmitted(e){console.log("[MAIN-APP] First message submitted from welcome view:",e),this.isSessionInitializing=!0,this.isStartingFirstMessage=!0,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created:",t.thread.id),this.firstMessageState.setPendingFirstMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id])},error:t=>{console.error("[MAIN-APP] Failed to create thread:",t),this.isSessionInitializing=!1,this.isStartingFirstMessage=!1,alert("Failed to create conversation: "+(t.message||"Unknown error"))}})}onVoiceToggled(e){console.log("[VOICE] Recording in welcome view:",e)}onVoiceMessageReady(e){console.log("[MAIN-APP] Voice message ready from welcome view"),this.isSessionInitializing=!0,this.isStartingFirstMessage=!0,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created for voice message:",t.thread.id),this.firstMessageState.setPendingVoiceMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id])},error:t=>{console.error("[MAIN-APP] Failed to create thread for voice message:",t),this.isSessionInitializing=!1,this.isStartingFirstMessage=!1,alert("Failed to create conversation: "+(t.message||"Unknown error"))}})}isDrawerOpen=!1;onDrawerStateChange(e){this.isDrawerOpen=e}onChatFocusedOnMobile(){window.innerWidth<1024&&this.sidenav?.close()}onInputHeightChanged(e){console.log("[MAIN-APP] Input height changed:",e),this.inputSectionHeight=e}updateInputSectionHeight(){if(this.inputSection?.nativeElement){let e=this.inputSection.nativeElement.offsetHeight;e!==this.inputSectionHeight&&(console.log("[MAIN-APP] Input section height updated:",e),this.inputSectionHeight=e)}}setupPrintHandlers(){window.addEventListener("beforeprint",this.handleBeforePrint),window.addEventListener("afterprint",this.handleAfterPrint)}handleBeforePrint=()=>{console.log("[PRINT] Before print event triggered");let e=this.preferencesService.getPrintTechnicalMessages();console.log("[PRINT] Print technical messages:",e),e?document.body.classList.add("print-include-technical"):document.body.classList.remove("print-include-technical")};handleAfterPrint=()=>{console.log("[PRINT] After print event triggered"),document.body.classList.remove("print-include-technical")};static \u0275fac=function(t){return new(t||o)};static \u0275cmp=v({type:o,selectors:[["app-main"]],viewQuery:function(t,i){if(t&1&&W(Z,5)(E,5),t&2){let n;O(n=P())&&(i.inputSection=n.first),O(n=P())&&(i.sidenav=n.first)}},decls:4,vars:2,consts:[["inputSection",""],[3,"drawerOpen"],[1,"app",3,"mousedown","touchstart"],[3,"projectName","threadId"],[3,"chatFocused","drawerStateChange","projectName","threadId"],[1,"welcome-section"],[1,"input-section"],[1,"input-center"],[1,"input-glass"],[3,"messageSubmitted","voiceMessageReady","voiceRecordingToggled","heightChanged","textareaFocused","isDisabled","isSessionInitializing","showWelcome","isThinking","isStarting"]],template:function(t,i){t&1&&(h(0,"app-sidenav",1)(1,"div",2),y("mousedown",function(){return i.onChatFocusedOnMobile()})("touchstart",function(){return i.onChatFocusedOnMobile()}),V(2,ee,1,2,"app-thread",3)(3,te,7,5),g()()),t&2&&(w("drawerOpen",i.isDrawerOpen),m(2),j(i.threadId?2:3))},dependencies:[q,Q,T,E],styles:["[_nghost-%COMP%]{display:flex;height:100vh;width:100%;overflow:hidden;justify-content:center}.app[_ngcontent-%COMP%]{width:100%;max-width:100%;min-width:0;height:100%;display:flex;flex-direction:column;background:var(--color-bg);color:var(--color-text);transition:all .3s ease;position:relative;justify-content:center;overflow:hidden}.chat-wrapper[_ngcontent-%COMP%]{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;background:transparent;width:100%;padding:2.5rem 0 1.5rem;display:flex;justify-content:center}.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem}@media(max-width:768px){.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{padding:0 1rem}}.welcome-section[_ngcontent-%COMP%]{flex-shrink:0;text-align:center;padding:2rem 1rem;animation:_ngcontent-%COMP%_fadeInUp .8s ease-out;display:flex;justify-content:center;align-items:center;width:100%;min-width:0;overflow:hidden}@keyframes _ngcontent-%COMP%_fadeInUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}.input-section[_ngcontent-%COMP%]{flex-shrink:0;position:relative;border-top:none;background:transparent;box-shadow:none;padding:2.5rem 0 2rem;overflow-y:visible;max-height:none;width:100%;z-index:10;pointer-events:none;display:flex;justify-content:center}.input-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem;display:flex;justify-content:center;align-items:end;position:relative;pointer-events:auto}@media(max-width:768px){.input-center[_ngcontent-%COMP%]{padding:0 1rem}}.input-glass[_ngcontent-%COMP%]{background:none;box-shadow:none;width:100%;min-height:64px;display:flex;align-items:stretch;gap:0;pointer-events:auto;position:relative;overflow:visible}.input-glass[_ngcontent-%COMP%] app-chat-textarea[_ngcontent-%COMP%]{width:100%;min-width:0;flex:1 1 auto;align-self:stretch;display:flex}body.dark[_nghost-%COMP%], body.dark [_nghost-%COMP%], [_ngcontent-%COMP%]:root[data-theme=dark] .input-glass[_ngcontent-%COMP%]{background:#24283073;border-color:#b4c8ff17;box-shadow:0 8px 32px #0000002b,0 1.5px 8px #00000012}.choice-overlay[_ngcontent-%COMP%]{z-index:10;width:100%;display:flex;justify-content:center;align-items:center}.upload-status[_ngcontent-%COMP%]{position:fixed;bottom:100px;left:50%;transform:translate(-50%);z-index:1000;display:flex;align-items:center;padding:12px 20px;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);border-radius:16px;font-size:.9em;color:var(--color-text);box-shadow:var(--glass-shadow);max-width:300px;text-align:center}.upload-status.error[_ngcontent-%COMP%]{background:#ff3b3026;color:var(--color-error);border-color:#ff3b304d}@media(max-width:768px){.welcome-section[_ngcontent-%COMP%]{padding:1.5rem 1rem}.input-section[_ngcontent-%COMP%]{padding:1.5rem .75rem 1rem}.input-center[_ngcontent-%COMP%]{padding:0 .5rem}}@media print{[_nghost-%COMP%]{display:block!important;height:auto!important;overflow:visible!important}.app[_ngcontent-%COMP%]{height:auto!important;overflow:visible!important;display:block!important}.input-section[_ngcontent-%COMP%], .welcome-section[_ngcontent-%COMP%]{display:none!important}}"],data:{animation:[S("slideIn",[C(":enter",[u({transform:"translateY(100%)",opacity:0}),_("300ms ease-out",u({transform:"translateY(0)",opacity:1}))]),C(":leave",[_("200ms ease-in",u({transform:"translateY(100%)",opacity:0}))])])]}})};export{K as MainAppComponent};
|
|
1
|
+
import{a as E}from"./chunk-BJM7MKOH.js";import{c as S,d as _,f as u,g as C}from"./chunk-QVW2GZXC.js";import{a as q,b as U,c as Y,d as Q}from"./chunk-4OCEBSTP.js";import"./chunk-OWSH6KVW.js";import{e as I}from"./chunk-34BTCCLM.js";import"./chunk-WIYSZEOD.js";import"./chunk-4TH4ERQY.js";import{a as L,d as b}from"./chunk-NAHXPRXR.js";import"./chunk-CA4E6QDU.js";import"./chunk-QCDV42EK.js";import{a as $,c as H}from"./chunk-P4GNUQZT.js";import"./chunk-BZS55WHS.js";import"./chunk-V7NUXN3R.js";import"./chunk-KD3BJ52V.js";import"./chunk-UDEMKCGK.js";import"./chunk-K7JRH3HO.js";import"./chunk-EBAEYY2S.js";import"./chunk-C2XSJPYF.js";import"./chunk-BZ7URUNM.js";import"./chunk-SKBT6DBT.js";import"./chunk-GF3EMWCA.js";import"./chunk-Z6RFJ6L3.js";import"./chunk-LN55MSDV.js";import"./chunk-OPSHMM4H.js";import{B as x,Bb as M,Db as y,Fb as s,Jb as W,Ka as m,Kb as O,Lb as P,N as A,T as p,Tb as G,Ub as z,Wa as v,Z as F,ca as a,d as k,ga as c,h as f,ha as d,lb as V,mb as j,rb as w,sb as h,tb as g,ub as R,vb as D,wb as B}from"./chunk-5NLXR4MK.js";var T=class o{welcomeMessages=["Welcome to Coday","Bienvenue sur Coday","Bienvenido a Coday","Willkommen bei Coday","Benvenuto su Coday","Bem-vindo ao Coday","Welkom bij Coday","\u0414\u043E\u0431\u0440\u043E \u043F\u043E\u0436\u0430\u043B\u043E\u0432\u0430\u0442\u044C \u0432 Coday","Coday \u3078\u3088\u3046\u3053\u305D","\u6B22\u8FCE\u6765\u5230 Coday","Coday \uC5D0 \uC624\uC2E0 \uAC83\uC744 \uD658\uC601\uD569\uB2C8\uB2E4","\u0645\u0631\u062D\u0628\u064B\u0627 \u0628\u0643 \u0641\u064A Coday"];currentWelcomeIndex=0;currentWelcomeMessage=this.welcomeMessages[0];welcomeRotationInterval;ngOnInit(){this.startWelcomeRotation()}ngOnDestroy(){this.stopWelcomeRotation()}startWelcomeRotation(){this.welcomeRotationInterval=window.setInterval(()=>{this.currentWelcomeIndex=(this.currentWelcomeIndex+1)%this.welcomeMessages.length,this.currentWelcomeMessage=this.welcomeMessages[this.currentWelcomeIndex]},3e3)}stopWelcomeRotation(){this.welcomeRotationInterval&&(clearInterval(this.welcomeRotationInterval),this.welcomeRotationInterval=void 0)}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=v({type:o,selectors:[["app-welcome-message"]],decls:2,vars:1,consts:[[1,"welcome-title"]],template:function(t,i){t&1&&(D(0,"h1",0),G(1),B()),t&2&&(m(),z(i.currentWelcomeMessage))},styles:[".welcome-title[_ngcontent-%COMP%]{font-size:clamp(1.5rem,4vw,4rem);font-weight:700;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% auto;background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;animation:_ngcontent-%COMP%_gradientShift 3s ease-in-out infinite;margin:0;padding:0;line-height:1.2;transition:opacity .5s ease-in-out;display:block;min-height:1.2em;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@keyframes _ngcontent-%COMP%_gradientShift{0%{background-position:0% center}50%{background-position:100% center}to{background-position:0% center}}"]})};var N=class o{destroy$=new f;isSetup=!1;codayService=a(I);preferencesService=a(b);setup(){if(this.isSetup){console.warn("[AGENT-NOTIFICATION] Service already set up");return}console.log("[AGENT-NOTIFICATION] Setting up agent notification service"),this.codayService.isThinking$.pipe(p(this.destroy$),A(),x(([e,t])=>e===!0&&t===!1)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Agent stopped thinking, notifying task finished"),this.notifyTaskFinishedIfEnabled()}),this.preferencesService.browserNotificationEnabled$.pipe(p(this.destroy$),A(),x(([e,t])=>e===!1&&t===!0)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Browser notifications enabled, checking permission"),this.handleBrowserNotificationEnabled()}),this.isSetup=!0}notifyTaskFinishedIfEnabled(){this.preferencesService.getAgentNotificationEnabled()&&(this.preferencesService.getNotificationSoundEnabled()&&this.playCompletionSound(),this.preferencesService.getBrowserNotificationEnabled()&&this.sendBrowserNotification())}playCompletionSound(){try{let e=new(window.AudioContext||window.webkitAudioContext),t=e.createOscillator(),i=e.createGain();t.connect(i),i.connect(e.destination),t.frequency.setValueAtTime(700,e.currentTime),i.gain.setValueAtTime(.1,e.currentTime),i.gain.exponentialRampToValueAtTime(.01,e.currentTime+.08),t.start(e.currentTime),t.stop(e.currentTime+.08);let n=e.createOscillator(),r=e.createGain();n.connect(r),r.connect(e.destination);let l=e.currentTime+.11;n.frequency.setValueAtTime(950,l),r.gain.setValueAtTime(.1,l),r.gain.exponentialRampToValueAtTime(.01,l+.09),n.start(l),n.stop(l+.09),console.log("[AGENT-NOTIFICATION] Completion sound played")}catch(e){console.error("[AGENT-NOTIFICATION] Failed to play completion sound:",e)}}handleBrowserNotificationEnabled(){return k(this,null,function*(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications"),this.preferencesService.setBrowserNotificationEnabled(!1);return}if(Notification.permission==="denied"){console.warn("[AGENT-NOTIFICATION] Permission denied, disabling browser notifications"),this.preferencesService.setBrowserNotificationEnabled(!1);return}if(Notification.permission==="granted"){console.log("[AGENT-NOTIFICATION] Permission already granted, showing confirmation"),this.createConfirmationNotification();return}try{(yield Notification.requestPermission())==="granted"?(console.log("[AGENT-NOTIFICATION] Permission granted, showing confirmation"),this.createConfirmationNotification()):(console.log("[AGENT-NOTIFICATION] Permission denied or dismissed"),this.preferencesService.setBrowserNotificationEnabled(!1))}catch(e){console.error("[AGENT-NOTIFICATION] Error requesting permission:",e),this.preferencesService.setBrowserNotificationEnabled(!1)}})}sendBrowserNotification(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications");return}if(document.hasFocus()){console.warn("[AGENT-NOTIFICATION] Document is focused, skipping browser notification");return}Notification.permission==="granted"?this.createTaskCompleteNotification():console.warn("[AGENT-NOTIFICATION] Permission not granted, cannot send notification")}createConfirmationNotification(){let e=new Notification("Coday - Notifications Enabled",{body:"You will be notified when the agent completes tasks",icon:"/favicon.ico",tag:"coday-notifications-enabled",requireInteraction:!1});setTimeout(()=>e.close(),4e3),e.onclick=()=>{window.focus(),e.close()},console.log("[AGENT-NOTIFICATION] Confirmation notification sent")}createTaskCompleteNotification(){let e=new Notification("Coday - Task Complete",{body:"The agent has finished and is waiting for your input",icon:"/favicon.ico",tag:"coday-task-complete",requireInteraction:!1});setTimeout(()=>e.close(),5e3),e.onclick=()=>{window.focus(),e.close()},console.log("[AGENT-NOTIFICATION] Task complete notification sent")}ngOnDestroy(){console.log("[AGENT-NOTIFICATION] Service destroyed"),this.destroy$.next(),this.destroy$.complete()}static \u0275fac=function(t){return new(t||o)};static \u0275prov=F({token:o,factory:o.\u0275fac,providedIn:"root"})};var Z=["inputSection"];function ee(o,e){if(o&1){let t=M();h(0,"app-thread",4),y("chatFocused",function(){c(t);let n=s();return d(n.onChatFocusedOnMobile())})("drawerStateChange",function(n){c(t);let r=s();return d(r.onDrawerStateChange(n))}),g()}if(o&2){let t=s();w("projectName",t.projectName)("threadId",t.threadId)}}function te(o,e){if(o&1){let t=M();h(0,"div",5),R(1,"app-welcome-message"),g(),h(2,"div",6,0)(4,"div",7)(5,"div",8)(6,"app-chat-textarea",9),y("messageSubmitted",function(n){c(t);let r=s();return d(r.onMessageSubmitted(n))})("voiceMessageReady",function(n){c(t);let r=s();return d(r.onVoiceMessageReady(n))})("voiceRecordingToggled",function(n){c(t);let r=s();return d(r.onVoiceToggled(n))})("heightChanged",function(n){c(t);let r=s();return d(r.onInputHeightChanged(n))})("textareaFocused",function(){c(t);let n=s();return d(n.onChatFocusedOnMobile())}),g()()()()}if(o&2){let t=s();m(6),w("isDisabled",t.isSessionInitializing)("isSessionInitializing",t.isSessionInitializing)("showWelcome",!0)("isThinking",!1)("isStarting",t.isStartingFirstMessage)}}var K=class o{destroy$=new f;inputSection;sidenav;projectName="";threadId=null;isSessionInitializing=!1;isStartingFirstMessage=!1;inputSectionHeight=80;codayService=a(I);titleService=a(U);preferencesService=a(b);route=a($);router=a(H);threadApiService=a(L);agentNotificationService=a(N);firstMessageState=a(Y);constructor(){console.log("[MAIN-APP] Using new thread-based architecture (no clientId needed)")}ngOnInit(){this.agentNotificationService.setup(),this.setupPrintHandlers(),this.route.params.pipe(p(this.destroy$)).subscribe(e=>{let t=e.projectName,i=e.threadId||null;console.log("[MAIN-APP] Route params updated:",{project:t,thread:i,previousProject:this.projectName,previousThread:this.threadId}),this.projectName=t,this.threadId=i,this.threadId?console.log("[MAIN-APP] Thread selected - ThreadComponent will display"):(console.log("[MAIN-APP] No thread selected - showing welcome view"),this.initializeWelcomeView())})}initializeWelcomeView(){this.codayService.setTabTitleService(this.titleService)}ngAfterViewInit(){setTimeout(()=>this.updateInputSectionHeight(),100)}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),window.removeEventListener("beforeprint",this.handleBeforePrint),window.removeEventListener("afterprint",this.handleAfterPrint)}onMessageSubmitted(e){console.log("[MAIN-APP] First message submitted from welcome view:",e),this.isSessionInitializing=!0,this.isStartingFirstMessage=!0,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created:",t.thread.id),this.firstMessageState.setPendingFirstMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id])},error:t=>{console.error("[MAIN-APP] Failed to create thread:",t),this.isSessionInitializing=!1,this.isStartingFirstMessage=!1,alert("Failed to create conversation: "+(t.message||"Unknown error"))}})}onVoiceToggled(e){console.log("[VOICE] Recording in welcome view:",e)}onVoiceMessageReady(e){console.log("[MAIN-APP] Voice message ready from welcome view"),this.isSessionInitializing=!0,this.isStartingFirstMessage=!0,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created for voice message:",t.thread.id),this.firstMessageState.setPendingVoiceMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id])},error:t=>{console.error("[MAIN-APP] Failed to create thread for voice message:",t),this.isSessionInitializing=!1,this.isStartingFirstMessage=!1,alert("Failed to create conversation: "+(t.message||"Unknown error"))}})}isDrawerOpen=!1;onDrawerStateChange(e){this.isDrawerOpen=e}onChatFocusedOnMobile(){window.innerWidth<1024&&this.sidenav?.close()}onInputHeightChanged(e){console.log("[MAIN-APP] Input height changed:",e),this.inputSectionHeight=e}updateInputSectionHeight(){if(this.inputSection?.nativeElement){let e=this.inputSection.nativeElement.offsetHeight;e!==this.inputSectionHeight&&(console.log("[MAIN-APP] Input section height updated:",e),this.inputSectionHeight=e)}}setupPrintHandlers(){window.addEventListener("beforeprint",this.handleBeforePrint),window.addEventListener("afterprint",this.handleAfterPrint)}handleBeforePrint=()=>{console.log("[PRINT] Before print event triggered");let e=this.preferencesService.getPrintTechnicalMessages();console.log("[PRINT] Print technical messages:",e),e?document.body.classList.add("print-include-technical"):document.body.classList.remove("print-include-technical")};handleAfterPrint=()=>{console.log("[PRINT] After print event triggered"),document.body.classList.remove("print-include-technical")};static \u0275fac=function(t){return new(t||o)};static \u0275cmp=v({type:o,selectors:[["app-main"]],viewQuery:function(t,i){if(t&1&&W(Z,5)(E,5),t&2){let n;O(n=P())&&(i.inputSection=n.first),O(n=P())&&(i.sidenav=n.first)}},decls:4,vars:2,consts:[["inputSection",""],[3,"drawerOpen"],[1,"app",3,"mousedown","touchstart"],[3,"projectName","threadId"],[3,"chatFocused","drawerStateChange","projectName","threadId"],[1,"welcome-section"],[1,"input-section"],[1,"input-center"],[1,"input-glass"],[3,"messageSubmitted","voiceMessageReady","voiceRecordingToggled","heightChanged","textareaFocused","isDisabled","isSessionInitializing","showWelcome","isThinking","isStarting"]],template:function(t,i){t&1&&(h(0,"app-sidenav",1)(1,"div",2),y("mousedown",function(){return i.onChatFocusedOnMobile()})("touchstart",function(){return i.onChatFocusedOnMobile()}),V(2,ee,1,2,"app-thread",3)(3,te,7,5),g()()),t&2&&(w("drawerOpen",i.isDrawerOpen),m(2),j(i.threadId?2:3))},dependencies:[q,Q,T,E],styles:["[_nghost-%COMP%]{display:flex;height:100vh;width:100%;overflow:hidden;justify-content:center}.app[_ngcontent-%COMP%]{width:100%;max-width:100%;min-width:0;height:100%;display:flex;flex-direction:column;background:var(--color-bg);color:var(--color-text);transition:all .3s ease;position:relative;justify-content:center;overflow:hidden}.chat-wrapper[_ngcontent-%COMP%]{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;background:transparent;width:100%;padding:2.5rem 0 1.5rem;display:flex;justify-content:center}.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem}@media(max-width:768px){.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{padding:0 1rem}}.welcome-section[_ngcontent-%COMP%]{flex-shrink:0;text-align:center;padding:2rem 1rem;animation:_ngcontent-%COMP%_fadeInUp .8s ease-out;display:flex;justify-content:center;align-items:center;width:100%;min-width:0;overflow:hidden}@keyframes _ngcontent-%COMP%_fadeInUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}.input-section[_ngcontent-%COMP%]{flex-shrink:0;position:relative;border-top:none;background:transparent;box-shadow:none;padding:2.5rem 0 2rem;overflow-y:visible;max-height:none;width:100%;z-index:10;pointer-events:none;display:flex;justify-content:center}.input-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem;display:flex;justify-content:center;align-items:end;position:relative;pointer-events:auto}@media(max-width:768px){.input-center[_ngcontent-%COMP%]{padding:0 1rem}}.input-glass[_ngcontent-%COMP%]{background:none;box-shadow:none;width:100%;min-height:64px;display:flex;align-items:stretch;gap:0;pointer-events:auto;position:relative;overflow:visible}.input-glass[_ngcontent-%COMP%] app-chat-textarea[_ngcontent-%COMP%]{width:100%;min-width:0;flex:1 1 auto;align-self:stretch;display:flex}body.dark[_nghost-%COMP%], body.dark [_nghost-%COMP%], [_ngcontent-%COMP%]:root[data-theme=dark] .input-glass[_ngcontent-%COMP%]{background:#24283073;border-color:#b4c8ff17;box-shadow:0 8px 32px #0000002b,0 1.5px 8px #00000012}.choice-overlay[_ngcontent-%COMP%]{z-index:10;width:100%;display:flex;justify-content:center;align-items:center}.upload-status[_ngcontent-%COMP%]{position:fixed;bottom:100px;left:50%;transform:translate(-50%);z-index:1000;display:flex;align-items:center;padding:12px 20px;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);border-radius:16px;font-size:.9em;color:var(--color-text);box-shadow:var(--glass-shadow);max-width:300px;text-align:center}.upload-status.error[_ngcontent-%COMP%]{background:#ff3b3026;color:var(--color-error);border-color:#ff3b304d}@media(max-width:768px){.welcome-section[_ngcontent-%COMP%]{padding:1.5rem 1rem}.input-section[_ngcontent-%COMP%]{padding:1.5rem .75rem 1rem}.input-center[_ngcontent-%COMP%]{padding:0 .5rem}}@media print{[_nghost-%COMP%]{display:block!important;height:auto!important;overflow:visible!important}.app[_ngcontent-%COMP%]{height:auto!important;overflow:visible!important;display:block!important}.input-section[_ngcontent-%COMP%], .welcome-section[_ngcontent-%COMP%]{display:none!important}}"],data:{animation:[S("slideIn",[C(":enter",[u({transform:"translateY(100%)",opacity:0}),_("300ms ease-out",u({transform:"translateY(0)",opacity:1}))]),C(":leave",[_("200ms ease-in",u({transform:"translateY(100%)",opacity:0}))])])]}})};export{K as MainAppComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Y}from"./chunk-KP4KMDLX.js";import{a as Z}from"./chunk-GPZP3WYQ.js";import"./chunk-U5L2OULZ.js";import"./chunk-2BN4B3OL.js";import{h as B}from"./chunk-W7ZS65Y4.js";import{a as R,c as L}from"./chunk-P4GNUQZT.js";import{t as X}from"./chunk-SOAR3OAC.js";import"./chunk-EBAEYY2S.js";import"./chunk-BZ7URUNM.js";import{a as v,c as y}from"./chunk-SKBT6DBT.js";import"./chunk-GF3EMWCA.js";import{F as W,c as z,e as x,g as A,h as G,i as q,l as u,n as j,p as $,s as J,w as U,x as H,y as K,z as Q}from"./chunk-Z6RFJ6L3.js";import"./chunk-OPSHMM4H.js";import{Bb as T,Db as g,Fb as p,Ka as a,Tb as l,Ub as b,Vb as N,Wa as w,ca as m,ga as _,ha as h,kb as I,lb as M,lc as D,m as E,ma as F,mb as P,pb as O,qb as k,rb as s,sb as i,ta as d,tb as o,ua as V,ub as C}from"./chunk-5NLXR4MK.js";function te(r,e){r&1&&(i(0,"p",5),l(1,"Loading\u2026"),o())}function ne(r,e){if(r&1&&(i(0,"label",10),C(1,"input",25),i(2,"span"),l(3),o()()),r&2){let t=e.$implicit,n=p(2);a(),s("value",t.value)("formControl",n.scopeControl)("disabled",t.value==="namespace"&&!n.isAdmin()),a(2),b(t.label)}}function oe(r,e){if(r&1&&(i(0,"option",16),l(1),o()),r&2){let t=e.$implicit;s("value",t.type),a(),b(t.displayName)}}function ie(r,e){if(r&1){let t=T();i(0,"div",21)(1,"ds-json-schema-form",26),g("valueChange",function(c){_(t);let f=p(2);return h(f.onParamsChange(c))}),o()()}if(r&2){let t=p(2);a(),s("schema",e)("value",t.initialParams())}}function re(r,e){if(r&1){let t=T();i(0,"form",7),g("ngSubmit",function(){_(t);let c=p();return h(c.submit())}),i(1,"fieldset",8)(2,"legend",9),l(3,"Scope"),o(),O(4,ne,4,4,"label",10,I().trackByScope,!0),o(),i(6,"div",11)(7,"label",12),l(8,"Type "),i(9,"span",13),l(10,"*"),o()(),i(11,"select",14)(12,"option",15),l(13,"Select type"),o(),O(14,oe,2,2,"option",16,I().trackByType,!0),o()(),i(16,"div",11)(17,"label",17),l(18,"Name "),i(19,"span",13),l(20,"*"),o()(),C(21,"input",18),o(),i(22,"div",11)(23,"label",19),l(24,"Description"),o(),C(25,"textarea",20),o(),M(26,ie,2,2,"div",21),i(27,"div",22)(28,"button",23),l(29),o(),i(30,"button",24),g("click",function(){_(t);let c=p();return h(c.cancel())}),l(31,"Cancel"),o()()()}if(r&2){let t,n=p();s("formGroup",n.form),a(),s("disabled",n.isEditMode()),a(3),k(n.scopeOptions),a(7),s("formControl",n.typeControl),a(3),k(n.integrationTypes()),a(7),s("formControl",n.nameControl),a(4),s("formControl",n.descriptionControl),a(),P((t=n.schema())?26:-1,t),a(2),s("disabled",n.nameControl.invalid||n.typeControl.invalid||n.isSubmitting()),a(),N(" ",n.isEditMode()?"Save changes":"Create"," ")}}var ae=new Set(["platform","namespace","userOnNs","userGlobal"]),S=Object.freeze({platform:"Configuration plateforme",namespace:"Configuration du namespace",userOnNs:"Pour moi sur ce namespace",userGlobal:"Pour moi globalement"}),ee=class r{route=m(R);router=m(L);destroyRef=m(F);state=m(Y);integrationTypeController=m(B);namespaceRole=m(Z);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;isAdmin=y(this.isPlatformMode?E(!0):this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:this.isPlatformMode});form=new q({name:new u("",{nonNullable:!0,validators:[x.required,x.minLength(1)]}),description:new u(null),type:new u("",{nonNullable:!0,validators:[x.required]}),scope:new u("namespace",{nonNullable:!0})});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get typeControl(){return this.form.controls.type}get scopeControl(){return this.form.controls.scope}isEditMode=d(!1);isSubmitting=d(!1);isLoading=d(!1);scopeOptions=[{value:"platform",label:S.platform},{value:"namespace",label:S.namespace},{value:"userOnNs",label:S.userOnNs},{value:"userGlobal",label:S.userGlobal}];paramsValue=d(null);initialParams=d(null);integrationTypes=y(this.integrationTypeController.listTypesIntegrationType(),{initialValue:[]});selectedType=y(this.form.controls.type.valueChanges,{initialValue:this.form.controls.type.value});schema=D(()=>{let e=this.selectedType();return e?this.integrationTypes().find(n=>n.type===e)?.configSchema??null:null});existingConfig=null;constructor(){V(()=>{if(this.isAdmin()||this.isEditMode())return;["platform","namespace"].includes(this.scopeControl.value)&&this.scopeControl.setValue("userOnNs")})}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let e=this.route.snapshot.paramMap,t=this.route.snapshot.queryParamMap,n=e.get("integrationId");if(n){this.isEditMode.set(!0),this.scopeControl.disable(),this.loadConfig(n);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable();return}let c=this.parseScope(t.get("scope"));this.scopeControl.setValue(c);let f=t.get("template");f&&this.hydrateFromTemplate(f)}parseScope(e){return e&&ae.has(e)?e:"namespace"}deriveScopeFromConfig(e){return!e.userId&&!e.namespaceId?"platform":e.userId?e.namespaceId?"userOnNs":"userGlobal":"namespace"}loadConfig(e){this.isLoading.set(!0),this.state.getById(e).pipe(v(this.destroyRef)).subscribe({next:t=>{this.existingConfig=t,this.scopeControl.setValue(this.deriveScopeFromConfig(t)),this.applyConfigToForm(t),this.isLoading.set(!1)},error:()=>{this.isLoading.set(!1),console.warn(`[IntegrationForm] Could not load config '${e}' \u2014 navigating back`),this.navigateBack()}})}hydrateFromTemplate(e){this.isLoading.set(!0),this.state.getById(e).pipe(v(this.destroyRef)).subscribe({next:t=>{this.applyConfigToForm(t),this.isLoading.set(!1),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:!0})},error:t=>{console.warn(`[IntegrationForm] Could not hydrate from template ${e}:`,t),this.isLoading.set(!1),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:!0})}})}applyConfigToForm(e){this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.typeControl.setValue(e.integrationType),this.initialParams.set(e.parameters),this.paramsValue.set(e.parameters)}onParamsChange(e){this.paramsValue.set(e)}submit(){if(this.nameControl.invalid||this.typeControl.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(!0);let e=this.descriptionControl.value?.trim(),t={name:this.nameControl.value.trim(),description:e||null,integrationType:this.typeControl.value,parameters:this.paramsValue()},n=this.form.getRawValue().scope;(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,t,n,this.existingConfig):this.state.create(t,n,this.namespaceId??null)).pipe(v(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(!1)})}cancel(){this.navigateBack()}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","integration-configs"]):this.router.navigate(["/agentos",this.namespaceId,"integrations"])}trackByType(e,t){return t.type}trackByScope(e,t){return t.value}static \u0275fac=function(t){return new(t||r)};static \u0275cmp=w({type:r,selectors:[["agentos-integration-form"]],decls:10,vars:2,consts:[[1,"integration-form"],[1,"integration-form__header"],["type","button","title","Back to integrations",1,"integration-form__back",3,"click"],[1,"integration-form__back-icon"],[1,"integration-form__title"],[1,"integration-form__loading"],[1,"integration-form__form",3,"formGroup"],[1,"integration-form__form",3,"ngSubmit","formGroup"],[1,"integration-form__field","integration-form__scope",3,"disabled"],[1,"integration-form__label"],[1,"integration-form__scope-option"],[1,"integration-form__field"],["for","integration-type",1,"integration-form__label"],["aria-hidden","true"],["id","integration-type",1,"integration-form__select",3,"formControl"],["value","","disabled",""],[3,"value"],["for","integration-name",1,"integration-form__label"],["id","integration-name","type","text","placeholder","Integration name","autocomplete","off",1,"integration-form__input",3,"formControl"],["for","integration-description",1,"integration-form__label"],["id","integration-description","placeholder","Optional description","rows","3",1,"integration-form__textarea",3,"formControl"],[1,"integration-form__schema-form"],[1,"integration-form__actions"],["type","submit",1,"integration-form__btn","integration-form__btn--primary",3,"disabled"],["type","button",1,"integration-form__btn",3,"click"],["type","radio",3,"value","formControl","disabled"],[3,"valueChange","schema","value"]],template:function(t,n){t&1&&(i(0,"div",0)(1,"header",1)(2,"button",2),g("click",function(){return n.cancel()}),i(3,"span",3),l(4,"\u2190"),o(),l(5," Integrations "),o(),i(6,"h1",4),l(7),o()(),M(8,te,2,0,"p",5)(9,re,32,8,"form",6),o()),t&2&&(a(7),b(n.isEditMode()?"Edit integration":"New integration"),a(),P(n.isLoading()?8:9))},dependencies:[W,j,K,Q,z,H,$,A,G,J,U,X],styles:[".integration-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:560px;margin:0 auto;padding:2rem 1rem}.integration-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.integration-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-primary, #007aff);font-family:inherit}.integration-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.integration-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.integration-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text, #1d1d1f);letter-spacing:-.02em}.integration-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73);font-size:.9rem;margin:0}.integration-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.integration-form__scope[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.4rem;border:1px solid var(--color-border-light, rgba(0, 0, 0, .06));border-radius:10px;padding:.75rem 1rem;background:transparent;margin:0}.integration-form__scope[disabled][_ngcontent-%COMP%]{opacity:.6}.integration-form__scope-option[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.5rem;font-size:.875rem;color:var(--color-text, #1d1d1f);cursor:pointer}.integration-form__scope-option[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{margin:0}.integration-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.integration-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text, #1d1d1f)}.integration-form__input[_ngcontent-%COMP%], .integration-form__textarea[_ngcontent-%COMP%], .integration-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .1));background:transparent;color:var(--color-text, #1d1d1f);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.integration-form__input[_ngcontent-%COMP%]:focus, .integration-form__textarea[_ngcontent-%COMP%]:focus, .integration-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-primary, #007aff)}.integration-form__input[_ngcontent-%COMP%]::placeholder, .integration-form__textarea[_ngcontent-%COMP%]::placeholder, .integration-form__select[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary, #6e6e73)}.integration-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:4.5rem;line-height:1.5}.integration-form__select[_ngcontent-%COMP%]{cursor:pointer}.integration-form__select[_ngcontent-%COMP%] option[disabled][_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73)}.integration-form__schema-form[_ngcontent-%COMP%]{padding:1rem;border-radius:10px;border:1px solid var(--color-border-light, rgba(0, 0, 0, .06));background:var(--glass-bg, rgba(255, 255, 255, .5));-webkit-backdrop-filter:var(--glass-backdrop-blur, blur(20px));backdrop-filter:var(--glass-backdrop-blur, blur(20px))}.integration-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.integration-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .1));background:transparent;color:var(--color-text, #1d1d1f);font-size:.9375rem;font-family:inherit;cursor:pointer;transition:background .15s ease,border-color .15s ease}.integration-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-surface-hover, rgba(0, 0, 0, .04))}.integration-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.integration-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-primary, #007aff);border-color:var(--color-primary, #007aff);color:#fff}.integration-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover, #0051d5);border-color:var(--color-primary-hover, #0051d5)}"],changeDetection:0})};export{ee as IntegrationFormComponent};
|
|
1
|
+
import{a as Y}from"./chunk-KP4KMDLX.js";import{a as Z}from"./chunk-GPZP3WYQ.js";import"./chunk-U5L2OULZ.js";import"./chunk-2BN4B3OL.js";import{h as B}from"./chunk-W7ZS65Y4.js";import{a as R,c as L}from"./chunk-P4GNUQZT.js";import{t as X}from"./chunk-K7JRH3HO.js";import"./chunk-EBAEYY2S.js";import"./chunk-BZ7URUNM.js";import{a as v,c as y}from"./chunk-SKBT6DBT.js";import"./chunk-GF3EMWCA.js";import{F as W,c as z,e as x,g as A,h as G,i as q,l as u,n as j,p as $,s as J,w as U,x as H,y as K,z as Q}from"./chunk-Z6RFJ6L3.js";import"./chunk-OPSHMM4H.js";import{Bb as T,Db as g,Fb as p,Ka as a,Tb as l,Ub as b,Vb as N,Wa as w,ca as m,ga as _,ha as h,kb as I,lb as M,lc as D,m as E,ma as F,mb as P,pb as O,qb as k,rb as s,sb as i,ta as d,tb as o,ua as V,ub as C}from"./chunk-5NLXR4MK.js";function te(r,e){r&1&&(i(0,"p",5),l(1,"Loading\u2026"),o())}function ne(r,e){if(r&1&&(i(0,"label",10),C(1,"input",25),i(2,"span"),l(3),o()()),r&2){let t=e.$implicit,n=p(2);a(),s("value",t.value)("formControl",n.scopeControl)("disabled",t.value==="namespace"&&!n.isAdmin()),a(2),b(t.label)}}function oe(r,e){if(r&1&&(i(0,"option",16),l(1),o()),r&2){let t=e.$implicit;s("value",t.type),a(),b(t.displayName)}}function ie(r,e){if(r&1){let t=T();i(0,"div",21)(1,"ds-json-schema-form",26),g("valueChange",function(c){_(t);let f=p(2);return h(f.onParamsChange(c))}),o()()}if(r&2){let t=p(2);a(),s("schema",e)("value",t.initialParams())}}function re(r,e){if(r&1){let t=T();i(0,"form",7),g("ngSubmit",function(){_(t);let c=p();return h(c.submit())}),i(1,"fieldset",8)(2,"legend",9),l(3,"Scope"),o(),O(4,ne,4,4,"label",10,I().trackByScope,!0),o(),i(6,"div",11)(7,"label",12),l(8,"Type "),i(9,"span",13),l(10,"*"),o()(),i(11,"select",14)(12,"option",15),l(13,"Select type"),o(),O(14,oe,2,2,"option",16,I().trackByType,!0),o()(),i(16,"div",11)(17,"label",17),l(18,"Name "),i(19,"span",13),l(20,"*"),o()(),C(21,"input",18),o(),i(22,"div",11)(23,"label",19),l(24,"Description"),o(),C(25,"textarea",20),o(),M(26,ie,2,2,"div",21),i(27,"div",22)(28,"button",23),l(29),o(),i(30,"button",24),g("click",function(){_(t);let c=p();return h(c.cancel())}),l(31,"Cancel"),o()()()}if(r&2){let t,n=p();s("formGroup",n.form),a(),s("disabled",n.isEditMode()),a(3),k(n.scopeOptions),a(7),s("formControl",n.typeControl),a(3),k(n.integrationTypes()),a(7),s("formControl",n.nameControl),a(4),s("formControl",n.descriptionControl),a(),P((t=n.schema())?26:-1,t),a(2),s("disabled",n.nameControl.invalid||n.typeControl.invalid||n.isSubmitting()),a(),N(" ",n.isEditMode()?"Save changes":"Create"," ")}}var ae=new Set(["platform","namespace","userOnNs","userGlobal"]),S=Object.freeze({platform:"Configuration plateforme",namespace:"Configuration du namespace",userOnNs:"Pour moi sur ce namespace",userGlobal:"Pour moi globalement"}),ee=class r{route=m(R);router=m(L);destroyRef=m(F);state=m(Y);integrationTypeController=m(B);namespaceRole=m(Z);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;isAdmin=y(this.isPlatformMode?E(!0):this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:this.isPlatformMode});form=new q({name:new u("",{nonNullable:!0,validators:[x.required,x.minLength(1)]}),description:new u(null),type:new u("",{nonNullable:!0,validators:[x.required]}),scope:new u("namespace",{nonNullable:!0})});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get typeControl(){return this.form.controls.type}get scopeControl(){return this.form.controls.scope}isEditMode=d(!1);isSubmitting=d(!1);isLoading=d(!1);scopeOptions=[{value:"platform",label:S.platform},{value:"namespace",label:S.namespace},{value:"userOnNs",label:S.userOnNs},{value:"userGlobal",label:S.userGlobal}];paramsValue=d(null);initialParams=d(null);integrationTypes=y(this.integrationTypeController.listTypesIntegrationType(),{initialValue:[]});selectedType=y(this.form.controls.type.valueChanges,{initialValue:this.form.controls.type.value});schema=D(()=>{let e=this.selectedType();return e?this.integrationTypes().find(n=>n.type===e)?.configSchema??null:null});existingConfig=null;constructor(){V(()=>{if(this.isAdmin()||this.isEditMode())return;["platform","namespace"].includes(this.scopeControl.value)&&this.scopeControl.setValue("userOnNs")})}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let e=this.route.snapshot.paramMap,t=this.route.snapshot.queryParamMap,n=e.get("integrationId");if(n){this.isEditMode.set(!0),this.scopeControl.disable(),this.loadConfig(n);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable();return}let c=this.parseScope(t.get("scope"));this.scopeControl.setValue(c);let f=t.get("template");f&&this.hydrateFromTemplate(f)}parseScope(e){return e&&ae.has(e)?e:"namespace"}deriveScopeFromConfig(e){return!e.userId&&!e.namespaceId?"platform":e.userId?e.namespaceId?"userOnNs":"userGlobal":"namespace"}loadConfig(e){this.isLoading.set(!0),this.state.getById(e).pipe(v(this.destroyRef)).subscribe({next:t=>{this.existingConfig=t,this.scopeControl.setValue(this.deriveScopeFromConfig(t)),this.applyConfigToForm(t),this.isLoading.set(!1)},error:()=>{this.isLoading.set(!1),console.warn(`[IntegrationForm] Could not load config '${e}' \u2014 navigating back`),this.navigateBack()}})}hydrateFromTemplate(e){this.isLoading.set(!0),this.state.getById(e).pipe(v(this.destroyRef)).subscribe({next:t=>{this.applyConfigToForm(t),this.isLoading.set(!1),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:!0})},error:t=>{console.warn(`[IntegrationForm] Could not hydrate from template ${e}:`,t),this.isLoading.set(!1),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:!0})}})}applyConfigToForm(e){this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.typeControl.setValue(e.integrationType),this.initialParams.set(e.parameters),this.paramsValue.set(e.parameters)}onParamsChange(e){this.paramsValue.set(e)}submit(){if(this.nameControl.invalid||this.typeControl.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(!0);let e=this.descriptionControl.value?.trim(),t={name:this.nameControl.value.trim(),description:e||null,integrationType:this.typeControl.value,parameters:this.paramsValue()},n=this.form.getRawValue().scope;(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,t,n,this.existingConfig):this.state.create(t,n,this.namespaceId??null)).pipe(v(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(!1)})}cancel(){this.navigateBack()}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","integration-configs"]):this.router.navigate(["/agentos",this.namespaceId,"integrations"])}trackByType(e,t){return t.type}trackByScope(e,t){return t.value}static \u0275fac=function(t){return new(t||r)};static \u0275cmp=w({type:r,selectors:[["agentos-integration-form"]],decls:10,vars:2,consts:[[1,"integration-form"],[1,"integration-form__header"],["type","button","title","Back to integrations",1,"integration-form__back",3,"click"],[1,"integration-form__back-icon"],[1,"integration-form__title"],[1,"integration-form__loading"],[1,"integration-form__form",3,"formGroup"],[1,"integration-form__form",3,"ngSubmit","formGroup"],[1,"integration-form__field","integration-form__scope",3,"disabled"],[1,"integration-form__label"],[1,"integration-form__scope-option"],[1,"integration-form__field"],["for","integration-type",1,"integration-form__label"],["aria-hidden","true"],["id","integration-type",1,"integration-form__select",3,"formControl"],["value","","disabled",""],[3,"value"],["for","integration-name",1,"integration-form__label"],["id","integration-name","type","text","placeholder","Integration name","autocomplete","off",1,"integration-form__input",3,"formControl"],["for","integration-description",1,"integration-form__label"],["id","integration-description","placeholder","Optional description","rows","3",1,"integration-form__textarea",3,"formControl"],[1,"integration-form__schema-form"],[1,"integration-form__actions"],["type","submit",1,"integration-form__btn","integration-form__btn--primary",3,"disabled"],["type","button",1,"integration-form__btn",3,"click"],["type","radio",3,"value","formControl","disabled"],[3,"valueChange","schema","value"]],template:function(t,n){t&1&&(i(0,"div",0)(1,"header",1)(2,"button",2),g("click",function(){return n.cancel()}),i(3,"span",3),l(4,"\u2190"),o(),l(5," Integrations "),o(),i(6,"h1",4),l(7),o()(),M(8,te,2,0,"p",5)(9,re,32,8,"form",6),o()),t&2&&(a(7),b(n.isEditMode()?"Edit integration":"New integration"),a(),P(n.isLoading()?8:9))},dependencies:[W,j,K,Q,z,H,$,A,G,J,U,X],styles:[".integration-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:560px;margin:0 auto;padding:2rem 1rem}.integration-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.integration-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-primary, #007aff);font-family:inherit}.integration-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.integration-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.integration-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text, #1d1d1f);letter-spacing:-.02em}.integration-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73);font-size:.9rem;margin:0}.integration-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.integration-form__scope[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.4rem;border:1px solid var(--color-border-light, rgba(0, 0, 0, .06));border-radius:10px;padding:.75rem 1rem;background:transparent;margin:0}.integration-form__scope[disabled][_ngcontent-%COMP%]{opacity:.6}.integration-form__scope-option[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.5rem;font-size:.875rem;color:var(--color-text, #1d1d1f);cursor:pointer}.integration-form__scope-option[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{margin:0}.integration-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.integration-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text, #1d1d1f)}.integration-form__input[_ngcontent-%COMP%], .integration-form__textarea[_ngcontent-%COMP%], .integration-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .1));background:transparent;color:var(--color-text, #1d1d1f);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.integration-form__input[_ngcontent-%COMP%]:focus, .integration-form__textarea[_ngcontent-%COMP%]:focus, .integration-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-primary, #007aff)}.integration-form__input[_ngcontent-%COMP%]::placeholder, .integration-form__textarea[_ngcontent-%COMP%]::placeholder, .integration-form__select[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary, #6e6e73)}.integration-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:4.5rem;line-height:1.5}.integration-form__select[_ngcontent-%COMP%]{cursor:pointer}.integration-form__select[_ngcontent-%COMP%] option[disabled][_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73)}.integration-form__schema-form[_ngcontent-%COMP%]{padding:1rem;border-radius:10px;border:1px solid var(--color-border-light, rgba(0, 0, 0, .06));background:var(--glass-bg, rgba(255, 255, 255, .5));-webkit-backdrop-filter:var(--glass-backdrop-blur, blur(20px));backdrop-filter:var(--glass-backdrop-blur, blur(20px))}.integration-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.integration-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .1));background:transparent;color:var(--color-text, #1d1d1f);font-size:.9375rem;font-family:inherit;cursor:pointer;transition:background .15s ease,border-color .15s ease}.integration-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-surface-hover, rgba(0, 0, 0, .04))}.integration-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.integration-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-primary, #007aff);border-color:var(--color-primary, #007aff);color:#fff}.integration-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover, #0051d5);border-color:var(--color-primary-hover, #0051d5)}"],changeDetection:0})};export{ee as IntegrationFormComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ge}from"./chunk-3FFHE56W.js";import{a as Ke,b as We}from"./chunk-CAGXAQN4.js";import{a as $e}from"./chunk-A34IERCN.js";import{a as fe}from"./chunk-J5W3AZMJ.js";import{a as _e,b as be,c as ve,d as xe,e as ye,f as Ae,g as Pe,h as Me,i as Oe,j as Ie,k as Se,l as Ee,m as we,n as Fe,o as Te,p as De,q as He,r as Ne,s as ze,t as Le}from"./chunk-VOUBTGWM.js";import{a as ke}from"./chunk-XC3I4AWV.js";import{a as Ce,b as he,c as q}from"./chunk-NCFBQG5D.js";import"./chunk-O37JOBGG.js";import{a as Ue}from"./chunk-3W2U42II.js";import"./chunk-IDD4RLL7.js";import{a as J}from"./chunk-2BN4B3OL.js";import{a as le,b as ge,c as ue}from"./chunk-7EHCV7WH.js";import{a as je,b as Ve}from"./chunk-HPTWGGVI.js";import{a as Re,b as Be}from"./chunk-S3LSARXT.js";import{a as $,e as G,k as K}from"./chunk-W7ZS65Y4.js";import"./chunk-WIYSZEOD.js";import{a as V,c as P}from"./chunk-P4GNUQZT.js";import{r as Y}from"./chunk-SOAR3OAC.js";import"./chunk-EBAEYY2S.js";import"./chunk-BZ7URUNM.js";import{a as W}from"./chunk-SKBT6DBT.js";import"./chunk-GF3EMWCA.js";import"./chunk-Z6RFJ6L3.js";import"./chunk-OPSHMM4H.js";import{Bb as D,Cb as H,Db as C,Eb as N,Fb as _,Jc as B,Ka as m,Rb as z,Tb as i,Ub as h,Vc as j,Wa as p,ca as d,ec as L,fc as U,ga as S,ha as k,kb as w,lb as l,lc as R,ma as E,mb as g,pb as F,qb as T,rb as y,sb as a,ta as b,tb as s,ub as x,vb as u,wb as f,xb as A}from"./chunk-5NLXR4MK.js";var t=()=>!0;var Je=[{path:"",loadComponent:()=>import("./chunk-GDWZ2TMN.js").then(e=>e.AgentosShellComponent),children:[{path:"home",canActivate:[t],loadComponent:()=>import("./chunk-UL6K7Q2E.js").then(e=>e.CaseShellComponent)},{path:"",loadComponent:()=>import("./chunk-M3LG5XSB.js").then(e=>e.LayoutComponent),children:[{path:"namespaces/new",canActivate:[t],loadComponent:()=>import("./chunk-3F2YMBKP.js").then(e=>e.NamespaceFormComponent)},{path:"namespaces/:namespaceId/edit",canActivate:[t],loadComponent:()=>import("./chunk-3F2YMBKP.js").then(e=>e.NamespaceFormComponent)},{path:"namespaces",canActivate:[t],loadComponent:()=>import("./chunk-DVROUT7T.js").then(e=>e.NamespaceListComponent)},{path:"admin",canActivate:[t],loadComponent:()=>import("./chunk-K6PYQXSH.js").then(e=>e.AdminHomeComponent)},{path:"admin/users/new",canActivate:[t],loadComponent:()=>import("./chunk-SDINNYUR.js").then(e=>e.UserFormComponent)},{path:"admin/users/:userId/edit",canActivate:[t],loadComponent:()=>import("./chunk-SDINNYUR.js").then(e=>e.UserFormComponent)},{path:"admin/users",canActivate:[t],loadComponent:()=>import("./chunk-EKYOF32Y.js").then(e=>e.UserListComponent)},{path:"admin/integration-configs/new",canActivate:[t],loadComponent:()=>import("./chunk-V4N6GKHW.js").then(e=>e.IntegrationFormComponent)},{path:"admin/integration-configs/:integrationId/edit",canActivate:[t],loadComponent:()=>import("./chunk-V4N6GKHW.js").then(e=>e.IntegrationFormComponent)},{path:"admin/integration-configs",canActivate:[t],loadComponent:()=>import("./chunk-HPVNIFEJ.js").then(e=>e.PlatformIntegrationConfigsComponent)},{path:"admin/prompts/new",canActivate:[t],loadComponent:()=>import("./chunk-TUARXNRR.js").then(e=>e.PromptFormComponent)},{path:"admin/prompts/:promptId/edit",canActivate:[t],loadComponent:()=>import("./chunk-TUARXNRR.js").then(e=>e.PromptFormComponent)},{path:"admin/prompts",canActivate:[t],loadComponent:()=>import("./chunk-3HJTBDXT.js").then(e=>e.PlatformPromptsComponent)},{path:"admin/ai-providers/new",canActivate:[t],loadComponent:()=>import("./chunk-GCJZKHAW.js").then(e=>e.AiProviderFormComponent)},{path:"admin/ai-providers/:aiProviderId/edit",canActivate:[t],loadComponent:()=>import("./chunk-GCJZKHAW.js").then(e=>e.AiProviderFormComponent)},{path:"admin/ai-providers",canActivate:[t],loadComponent:()=>import("./chunk-SPSSJANY.js").then(e=>e.PlatformAiProvidersComponent)},{path:"admin/ai-models/new",canActivate:[t],loadComponent:()=>import("./chunk-V3HCXJKS.js").then(e=>e.AiModelFormComponent)},{path:"admin/ai-models/:modelId/edit",canActivate:[t],loadComponent:()=>import("./chunk-V3HCXJKS.js").then(e=>e.AiModelFormComponent)},{path:"admin/ai-models",canActivate:[t],loadComponent:()=>import("./chunk-E2KMSNBI.js").then(e=>e.PlatformAiModelsComponent)},{path:"admin/agent-configs/new",canActivate:[t],loadComponent:()=>import("./chunk-F4BSKSY7.js").then(e=>e.AgentConfigFormComponent)},{path:"admin/agent-configs/:agentConfigId/edit",canActivate:[t],loadComponent:()=>import("./chunk-F4BSKSY7.js").then(e=>e.AgentConfigFormComponent)},{path:"admin/agent-configs/:agentConfigId/inspect",canActivate:[t],loadComponent:()=>import("./chunk-EFCODPLG.js").then(e=>e.AgentConfigInspectComponent)},{path:"admin/agent-configs",canActivate:[t],loadComponent:()=>import("./chunk-QSWJW2CT.js").then(e=>e.PlatformAgentConfigsComponent)},{path:"me",canActivate:[t],loadComponent:()=>import("./chunk-WPII4MHK.js").then(e=>e.UserProfileComponent)},{path:"user",canActivate:[t],loadComponent:()=>import("./chunk-WPII4MHK.js").then(e=>e.UserProfileComponent)},{path:":namespaceId/integrations/new",canActivate:[t],loadComponent:()=>import("./chunk-V4N6GKHW.js").then(e=>e.IntegrationFormComponent)},{path:":namespaceId/integrations/:integrationId/edit",canActivate:[t],loadComponent:()=>import("./chunk-V4N6GKHW.js").then(e=>e.IntegrationFormComponent)},{path:":namespaceId/integrations",canActivate:[t],loadComponent:()=>import("./chunk-NUQZWQIL.js").then(e=>e.IntegrationsAllScopesComponent)},{path:":namespaceId/ai-providers/new",canActivate:[t],loadComponent:()=>import("./chunk-GCJZKHAW.js").then(e=>e.AiProviderFormComponent)},{path:":namespaceId/ai-providers/:aiProviderId/edit",canActivate:[t],loadComponent:()=>import("./chunk-GCJZKHAW.js").then(e=>e.AiProviderFormComponent)},{path:":namespaceId/ai-providers",canActivate:[t],loadComponent:()=>import("./chunk-VLPN6IDQ.js").then(e=>e.AiProvidersAllScopesComponent)},{path:":namespaceId/ai-models/new",canActivate:[t],loadComponent:()=>import("./chunk-V3HCXJKS.js").then(e=>e.AiModelFormComponent)},{path:":namespaceId/ai-models/:modelId/edit",canActivate:[t],loadComponent:()=>import("./chunk-V3HCXJKS.js").then(e=>e.AiModelFormComponent)},{path:":namespaceId/ai-models",canActivate:[t],loadComponent:()=>import("./chunk-2M7UJVMC.js").then(e=>e.NamespaceAiModelsComponent)},{path:":namespaceId/prompts/new",canActivate:[t],loadComponent:()=>import("./chunk-TUARXNRR.js").then(e=>e.PromptFormComponent)},{path:":namespaceId/prompts/:promptId/edit",canActivate:[t],loadComponent:()=>import("./chunk-TUARXNRR.js").then(e=>e.PromptFormComponent)},{path:":namespaceId/prompts",canActivate:[t],loadComponent:()=>import("./chunk-OINUZPA5.js").then(e=>e.NamespacePromptsComponent)},{path:":namespaceId/agent-configs/new",canActivate:[t],loadComponent:()=>import("./chunk-F4BSKSY7.js").then(e=>e.AgentConfigFormComponent)},{path:":namespaceId/agent-configs/:agentConfigId/edit",canActivate:[t],loadComponent:()=>import("./chunk-F4BSKSY7.js").then(e=>e.AgentConfigFormComponent)},{path:":namespaceId/agent-configs/:agentConfigId/inspect",canActivate:[t],loadComponent:()=>import("./chunk-EFCODPLG.js").then(e=>e.AgentConfigInspectComponent)},{path:":namespaceId/agent-configs",canActivate:[t],loadComponent:()=>import("./chunk-DJOQI226.js").then(e=>e.NamespaceAgentConfigsComponent)},{path:"",redirectTo:"namespaces",pathMatch:"full"}]}]}];function te(e,o){e&1&&A(0,"span",1)}function ne(e,o){e&1&&A(0,"span",2)}function oe(e,o){e&1&&A(0,"span",3)}var v=class e{pluginService=d(K);online=b(null);ngOnInit(){this.pluginService.getAllPlugins().subscribe({next:()=>this.online.set(!0),error:()=>this.online.set(!1)})}static \u0275fac=function(n){return new(n||e)};static \u0275cmp=p({type:e,selectors:[["agentos-backend-status"]],decls:4,vars:1,consts:[[1,"backend-status"],["title","AgentOS online",1,"dot","dot--online"],["title","AgentOS offline",1,"dot","dot--offline"],["title","Checking\u2026",1,"dot","dot--checking"]],template:function(n,r){if(n&1&&(u(0,"div",0),l(1,te,1,0,"span",1)(2,ne,1,0,"span",2)(3,oe,1,0,"span",3),f()),n&2){let c;m(),g((c=r.online())===!0?1:c===!1?2:3)}},styles:[".backend-status[_ngcontent-%COMP%]{display:flex;align-items:center}.dot[_ngcontent-%COMP%]{width:8px;height:8px;border-radius:50%;flex-shrink:0}.dot--online[_ngcontent-%COMP%]{background:var(--color-success, #34c759)}.dot--offline[_ngcontent-%COMP%]{background:var(--color-error, #ff3b30)}.dot--checking[_ngcontent-%COMP%]{background:var(--color-text-secondary, #6e6e73);opacity:.5;animation:_ngcontent-%COMP%_pulse 1.2s ease-in-out infinite}@keyframes _ngcontent-%COMP%_pulse{0%,to{opacity:.5}50%{opacity:1}}"]})};function ae(e,o){if(e&1){let n=D();a(0,"button",9),C("click",function(){S(n);let c=_();return k(c.navigateToAdmin())}),a(1,"span",10),i(2,"\u2699\uFE0F"),s()()}}function ie(e,o){if(e&1&&(a(0,"span",7),i(1),s()),e&2){let n=_();m(),h(n.userInitials)}}function re(e,o){e&1&&(a(0,"span",8),i(1,"\u25EF"),s())}var Q=class e{router=d(P);userState=d(J);destroyRef=d(E);currentUser=this.userState.currentUser;navigateHome(){this.router.navigate(["/agentos/home"])}isAdmin=R(()=>this.userState.currentUser()?.isAdmin===!0);navigateToAdmin(){this.router.navigate(["/agentos/admin"])}ngOnInit(){this.currentUser()||this.userState.loadMe().pipe(W(this.destroyRef)).subscribe()}get userInitials(){let o=this.currentUser();if(!o)return"";let n=o.firstname?.[0]??"",r=o.lastname?.[0]??"";return(n+r).toUpperCase()||o.email?.[0]?.toUpperCase()||"?"}get isOnProfilePage(){return this.router.url.startsWith("/agentos/me")}toggleProfile(){this.isOnProfilePage?window.history.length>1?window.history.back():this.router.navigate(["/agentos"]):this.router.navigate(["/agentos/me"])}static \u0275fac=function(n){return new(n||e)};static \u0275cmp=p({type:e,selectors:[["agentos-header"]],decls:11,vars:5,consts:[[1,"header"],["type","button","title","Home",1,"header__brand",3,"click"],["src","CODAY-Logo.png","alt","Coday",1,"header__logo-img"],[1,"header__logo-text"],[1,"header__nav"],["type","button","title","Admin",1,"header__admin-btn"],["type","button",1,"header__user-btn",3,"click","title"],[1,"header__user-initials"],[1,"header__user-icon"],["type","button","title","Admin",1,"header__admin-btn",3,"click"],[1,"header__admin-icon"]],template:function(n,r){n&1&&(a(0,"header",0)(1,"button",1),C("click",function(){return r.navigateHome()}),x(2,"img",2),a(3,"span",3),i(4,"Coday"),s()(),a(5,"nav",4),x(6,"agentos-backend-status"),l(7,ae,3,0,"button",5),a(8,"button",6),C("click",function(){return r.toggleProfile()}),l(9,ie,2,1,"span",7)(10,re,2,0,"span",8),s()()()),n&2&&(m(7),g(r.isAdmin()?7:-1),m(),z("header__user-btn--active",r.isOnProfilePage),y("title",r.isOnProfilePage?"Back":"My profile"),m(),g(r.userInitials?9:10))},dependencies:[v],styles:[".header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:0 1.5rem;height:56px;background:var(--glass-bg, rgba(255, 255, 255, .72));border-bottom:1px solid var(--glass-border, rgba(255, 255, 255, .18));backdrop-filter:var(--glass-backdrop-blur, blur(20px));-webkit-backdrop-filter:var(--glass-backdrop-blur, blur(20px));position:sticky;top:0;z-index:100}.header__brand[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;background:none;border:none;padding:0;cursor:pointer;border-radius:6px;transition:opacity .15s ease}.header__brand[_ngcontent-%COMP%]:hover{opacity:.7}.header__logo-img[_ngcontent-%COMP%]{width:32px;height:32px;object-fit:contain}.header__logo-text[_ngcontent-%COMP%]{font-size:1rem;font-weight:700;letter-spacing:-.01em;color:var(--color-text, #1d1d1f)}.header__nav[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}.header__admin-btn[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:50%;border:1.5px solid var(--color-border, rgba(0, 0, 0, .1));background:var(--color-bg-secondary, rgba(0, 0, 0, .04));cursor:pointer;transition:background .15s ease,border-color .15s ease;padding:0;font-family:inherit;font-size:1rem;line-height:1}.header__admin-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover, rgba(0, 0, 0, .08));border-color:var(--color-primary, #007aff)}.header__admin-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.header__user-btn[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:50%;border:1.5px solid var(--color-border, rgba(0, 0, 0, .1));background:var(--color-bg-secondary, rgba(0, 0, 0, .04));cursor:pointer;transition:background .15s ease,border-color .15s ease;padding:0;font-family:inherit}.header__user-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover, rgba(0, 0, 0, .08));border-color:var(--color-primary, #007aff)}.header__user-btn--active[_ngcontent-%COMP%]{background:var(--color-primary, #007aff);border-color:var(--color-primary, #007aff)}.header__user-btn--active[_ngcontent-%COMP%] .header__user-initials[_ngcontent-%COMP%], .header__user-btn--active[_ngcontent-%COMP%] .header__user-icon[_ngcontent-%COMP%]{color:#fff}.header__user-initials[_ngcontent-%COMP%]{font-size:.75rem;font-weight:600;color:var(--color-text, #1d1d1f);line-height:1;letter-spacing:.02em}.header__user-icon[_ngcontent-%COMP%]{font-size:1rem;color:var(--color-text-secondary, #6e6e73);line-height:1}"]})};function se(e,o){e&1&&(u(0,"p",6),i(1,"No cases yet. Start one below."),f())}function me(e,o){if(e&1&&(u(0,"div",7)(1,"span",8),i(2),f(),u(3,"span",9),i(4),f()()),e&2){let n=o.$implicit;m(2),h(n.id),m(2),h(n.status)}}function ce(e,o){if(e&1&&F(0,me,5,2,"div",7,w().trackById,!0),e&2){let n=_();T(n)}}function de(e,o){e&1&&l(0,se,2,0,"p",6)(1,ce,2,0),e&2&&g(o.length===0?0:1)}var X=class e{http=d(j);router=d(P);route=d(V);config=d($);caseController=d(G);preferences=d(q);namespaceId=this.route.snapshot.params.namespaceId;cases$=this.caseController.listByParentCase(this.namespaceId);inputValue=b("");onInput(o){this.inputValue.set(o.target.value)}onKeydown(o){this.preferences.shouldSend(o)&&(o.preventDefault(),this.submit())}submit(){this.inputValue().trim()&&this.http.post(`${this.config.basePath}/api/cases`,{namespaceId:this.namespaceId,metadata:{}}).subscribe(n=>{this.inputValue.set(""),this.router.navigate(["/agentos",this.namespaceId,"cases",n.id??""])})}trackById(o,n){return n.id??""}static \u0275fac=function(n){return new(n||e)};static \u0275cmp=p({type:e,selectors:[["agentos-case-list"]],decls:11,vars:5,consts:[[1,"case-list"],[1,"case-list__header"],[1,"case-list__items"],[1,"case-list__composer"],["placeholder","Start a new case\u2026","rows","3",1,"case-list__input",3,"input","keydown","value"],[1,"case-list__hint"],[1,"case-list__empty"],[1,"case-list__item"],[1,"case-list__item-id"],[1,"case-list__item-status"]],template:function(n,r){if(n&1&&(u(0,"div",0)(1,"header",1)(2,"h2"),i(3,"Cases"),f()(),u(4,"div",2),l(5,de,2,1),L(6,"async"),f(),u(7,"div",3)(8,"textarea",4),N("input",function(I){return r.onInput(I)})("keydown",function(I){return r.onKeydown(I)}),f(),u(9,"p",5),i(10),f()()()),n&2){let c;m(5),g((c=U(6,3,r.cases$))?5:-1,c),m(3),H("value",r.inputValue()),m(2),h(r.preferences.composerHint())}},dependencies:[B],styles:[".case-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;max-width:720px;margin:0 auto;padding:2rem;gap:1.5rem}.case-list__header[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text, #1d1d1f);letter-spacing:-.02em}.case-list__items[_ngcontent-%COMP%]{flex:1;overflow-y:auto}.case-list__empty[_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73);font-size:.9rem;margin:0}.case-list__composer[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.case-list__input[_ngcontent-%COMP%]{width:100%;resize:none;padding:.75rem 1rem;border-radius:12px;border:1px solid var(--color-border, rgba(0, 0, 0, .1));background:var(--glass-bg, rgba(255, 255, 255, .72));-webkit-backdrop-filter:var(--glass-backdrop-blur, blur(20px));backdrop-filter:var(--glass-backdrop-blur, blur(20px));color:var(--color-text, #1d1d1f);font-size:.95rem;font-family:inherit;line-height:1.5;outline:none;box-sizing:border-box;transition:border-color .15s ease}.case-list__input[_ngcontent-%COMP%]:focus{border-color:var(--color-primary, #007aff)}.case-list__input[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary, #6e6e73)}.case-list__hint[_ngcontent-%COMP%]{margin:0;font-size:.75rem;color:var(--color-text-secondary, #6e6e73);opacity:.7}"]})};var Z=class e{case;static toListItem(o){return{id:o.id??"",name:o.title??o.id??"\u2014",description:void 0}}static \u0275fac=function(n){return new(n||e)};static \u0275cmp=p({type:e,selectors:[["agentos-case-item"]],inputs:{case:"case"},decls:0,vars:0,template:function(n,r){},encapsulation:2,changeDetection:0})};function pe(e,o){if(e&1&&(a(0,"p",11),i(1," Last action: "),a(2,"strong"),i(3),s()()),e&2){let n=_();m(3),h(n.lastAction())}}var ee=class e{lastAction=b(null);onSend(){this.lastAction.set("send")}onStop(){this.lastAction.set("stop")}onAttach(){this.lastAction.set("attach")}static \u0275fac=function(n){return new(n||e)};static \u0275cmp=p({type:e,selectors:[["agentos-hello"]],decls:35,vars:2,consts:[[1,"hello-agentos"],[1,"card"],[1,"badge"],[1,"principles"],[1,"demo"],[1,"demo-label"],[1,"demo-buttons"],["icon","send","variant","primary","title","Send",3,"action"],["icon","stop","variant","danger","title","Stop",3,"action"],["icon","attach_file","variant","default","title","Attach",3,"action"],["icon","mic","variant","default","title","Record",3,"action","disabled"],[1,"demo-feedback"]],template:function(n,r){n&1&&(a(0,"div",0)(1,"div",1)(2,"div",2),i(3,"AgentOS UI"),s(),a(4,"h1"),i(5,"Hello AgentOS"),s(),a(6,"p"),i(7," This component lives in "),a(8,"code"),i(9,"libs/agentos-ui"),s(),i(10," \u2014 isolated from Coday internals, ready to be published as "),a(11,"code"),i(12,"@whoz-oss/agentos-ui"),s(),i(13,". "),s(),x(14,"agentos-backend-status"),a(15,"ul",3)(16,"li"),i(17,"\u2726 No imports from Coday app"),s(),a(18,"li"),i(19,"\u2726 CSS custom properties as host contract"),s(),a(20,"li"),i(21,"\u2726 Standalone Angular components"),s(),a(22,"li"),i(23,"\u2726 Signals-first reactive state"),s()(),a(24,"div",4)(25,"p",5),i(26,"ds-icon-button from "),a(27,"code"),i(28,"@whoz-oss/design-system"),s()(),a(29,"div",6)(30,"ds-icon-button",7),C("action",function(){return r.onSend()}),s(),a(31,"ds-icon-button",8),C("action",function(){return r.onStop()}),s(),a(32,"ds-icon-button",9),C("action",function(){return r.onAttach()}),s(),a(33,"ds-icon-button",10),C("action",function(){return r.onAttach()}),s()(),l(34,pe,4,1,"p",11),s()()()),n&2&&(m(33),y("disabled",!0),m(),g(r.lastAction()?34:-1))},dependencies:[Y,v],styles:['@charset "UTF-8";.hello-agentos[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;min-height:100vh;padding:2rem}.card[_ngcontent-%COMP%]{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 32px 0 rgba(31, 38, 135, .15));backdrop-filter:var(--glass-backdrop-blur, blur(20px));-webkit-backdrop-filter:var(--glass-backdrop-blur, blur(20px));border-radius:20px;padding:3rem;max-width:480px;width:100%;text-align:center}.badge[_ngcontent-%COMP%]{display:inline-block;background:var(--color-primary, #007aff);color:var(--color-text-inverse, #ffffff);font-size:.75rem;font-weight:600;letter-spacing:.08em;text-transform:uppercase;padding:.25rem .75rem;border-radius:100px;margin-bottom:1.5rem}h1[_ngcontent-%COMP%]{color:var(--color-text, #1d1d1f);font-size:2rem;font-weight:700;margin:0 0 1rem;letter-spacing:-.02em}p[_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73);line-height:1.6;margin:0 0 1.5rem}p[_ngcontent-%COMP%] code[_ngcontent-%COMP%]{background:var(--color-code-bg, rgba(142, 142, 147, .12));color:var(--color-code-text, #ff375f);padding:.125rem .375rem;border-radius:6px;font-size:.875em;border:1px solid var(--color-border, rgba(0, 0, 0, .1))}.principles[_ngcontent-%COMP%]{list-style:none;margin:0 0 1.5rem;padding:0;text-align:left;display:flex;flex-direction:column;gap:.5rem}.principles[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73);font-size:.9rem;padding:.5rem .75rem;background:var(--color-bg-hover, rgba(0, 0, 0, .04));border-radius:8px;border:1px solid var(--color-border-light, rgba(40, 40, 40, .08))}.demo[_ngcontent-%COMP%]{border-top:1px solid var(--color-border-light, rgba(40, 40, 40, .08));padding-top:1.25rem}.demo[_ngcontent-%COMP%] .demo-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73);font-size:.8rem;margin:0 0 .75rem}.demo[_ngcontent-%COMP%] .demo-label[_ngcontent-%COMP%] code[_ngcontent-%COMP%]{background:var(--color-code-bg, rgba(142, 142, 147, .12));color:var(--color-code-text, #ff375f);padding:.125rem .375rem;border-radius:6px;font-size:.875em;border:1px solid var(--color-border, rgba(0, 0, 0, .1))}.demo[_ngcontent-%COMP%] .demo-buttons[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:center;justify-content:center;padding:.75rem;background:var(--color-bg-hover, rgba(0, 0, 0, .04));border-radius:12px;border:1px solid var(--color-border-light, rgba(40, 40, 40, .08))}.demo[_ngcontent-%COMP%] .demo-feedback[_ngcontent-%COMP%]{margin:.75rem 0 0;font-size:.85rem;color:var(--color-text-secondary, #6e6e73)}.demo[_ngcontent-%COMP%] .demo-feedback[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{color:var(--color-primary, #007aff)}']})};export{Je as AGENTOS_ROUTES,Re as ActionCardChipsDirective,Be as ActionCardComponent,fe as AgentosShellComponent,ge as AgentosThemeService,he as AgentosUserPreferencesService,v as BackendStatusComponent,He as CaseChatComponent,ze as CaseDrawerComponent,Ne as CaseHomeComponent,Z as CaseItemComponent,X as CaseListComponent,Le as CaseShellComponent,Ce as ENTER_KEY_BEHAVIORS,Ee as ExchangeContentViewerComponent,Te as ExchangeDrawerComponent,Fe as ExchangeFileListComponent,we as ExchangeItemComponent,De as ExchangeShellComponent,_e as ExchangeStateService,Q as HeaderComponent,ee as HelloAgentosComponent,Ue as LayoutComponent,be as MAX_VIEWABLE_SIZE,ke as MarkdownPipe,je as NamespaceItemComponent,Ve as NamespaceListComponent,le as THEME_MODES,ue as THEME_PORT,q as USER_PREFERENCES_PORT,$e as UserAdminStateService,Ge as UserFormComponent,Ke as UserItemComponent,We as UserListComponent,J as UserStateService,t as agentosReadyGuard,Oe as canViewFile,Ae as detectFormat,Se as exchangeMutationScope,ye as formatDate,xe as formatSize,ve as getFileIcon,Pe as isFormatViewable,Me as isViewable,Ie as reindentJson};
|
|
1
|
+
import{a as Ge}from"./chunk-3FFHE56W.js";import{a as Ke,b as We}from"./chunk-7RVP2EHC.js";import{a as $e}from"./chunk-A34IERCN.js";import{a as fe}from"./chunk-J5W3AZMJ.js";import{a as _e,b as be,c as ve,d as xe,e as ye,f as Ae,g as Pe,h as Me,i as Oe,j as Ie,k as Se,l as Ee,m as we,n as Fe,o as Te,p as De,q as He,r as Ne,s as ze,t as Le}from"./chunk-7FTSWXXP.js";import{a as ke}from"./chunk-XC3I4AWV.js";import{a as Ce,b as he,c as q}from"./chunk-NCFBQG5D.js";import"./chunk-O37JOBGG.js";import{a as Ue}from"./chunk-ZPHUI4F6.js";import"./chunk-IDD4RLL7.js";import{a as J}from"./chunk-2BN4B3OL.js";import{a as le,b as ge,c as ue}from"./chunk-7EHCV7WH.js";import{a as je,b as Ve}from"./chunk-TEJQAOQQ.js";import{a as Re,b as Be}from"./chunk-UFZICL7S.js";import{a as $,e as G,k as K}from"./chunk-W7ZS65Y4.js";import"./chunk-WIYSZEOD.js";import{a as V,c as P}from"./chunk-P4GNUQZT.js";import{r as Y}from"./chunk-K7JRH3HO.js";import"./chunk-EBAEYY2S.js";import"./chunk-BZ7URUNM.js";import{a as W}from"./chunk-SKBT6DBT.js";import"./chunk-GF3EMWCA.js";import"./chunk-Z6RFJ6L3.js";import"./chunk-OPSHMM4H.js";import{Bb as D,Cb as H,Db as C,Eb as N,Fb as _,Jc as B,Ka as m,Rb as z,Tb as i,Ub as h,Vc as j,Wa as p,ca as d,ec as L,fc as U,ga as S,ha as k,kb as w,lb as l,lc as R,ma as E,mb as g,pb as F,qb as T,rb as y,sb as a,ta as b,tb as s,ub as x,vb as u,wb as f,xb as A}from"./chunk-5NLXR4MK.js";var t=()=>!0;var Je=[{path:"",loadComponent:()=>import("./chunk-GDWZ2TMN.js").then(e=>e.AgentosShellComponent),children:[{path:"home",canActivate:[t],loadComponent:()=>import("./chunk-VPYY4J2W.js").then(e=>e.CaseShellComponent)},{path:"",loadComponent:()=>import("./chunk-RTAXT4D4.js").then(e=>e.LayoutComponent),children:[{path:"namespaces/new",canActivate:[t],loadComponent:()=>import("./chunk-3F2YMBKP.js").then(e=>e.NamespaceFormComponent)},{path:"namespaces/:namespaceId/edit",canActivate:[t],loadComponent:()=>import("./chunk-3F2YMBKP.js").then(e=>e.NamespaceFormComponent)},{path:"namespaces",canActivate:[t],loadComponent:()=>import("./chunk-ONZHMPPP.js").then(e=>e.NamespaceListComponent)},{path:"admin",canActivate:[t],loadComponent:()=>import("./chunk-JCMCMBHO.js").then(e=>e.AdminHomeComponent)},{path:"admin/users/new",canActivate:[t],loadComponent:()=>import("./chunk-SDINNYUR.js").then(e=>e.UserFormComponent)},{path:"admin/users/:userId/edit",canActivate:[t],loadComponent:()=>import("./chunk-SDINNYUR.js").then(e=>e.UserFormComponent)},{path:"admin/users",canActivate:[t],loadComponent:()=>import("./chunk-MSMRBM6R.js").then(e=>e.UserListComponent)},{path:"admin/integration-configs/new",canActivate:[t],loadComponent:()=>import("./chunk-2HEJ7K6I.js").then(e=>e.IntegrationFormComponent)},{path:"admin/integration-configs/:integrationId/edit",canActivate:[t],loadComponent:()=>import("./chunk-2HEJ7K6I.js").then(e=>e.IntegrationFormComponent)},{path:"admin/integration-configs",canActivate:[t],loadComponent:()=>import("./chunk-XEZKOM4R.js").then(e=>e.PlatformIntegrationConfigsComponent)},{path:"admin/prompts/new",canActivate:[t],loadComponent:()=>import("./chunk-TUARXNRR.js").then(e=>e.PromptFormComponent)},{path:"admin/prompts/:promptId/edit",canActivate:[t],loadComponent:()=>import("./chunk-TUARXNRR.js").then(e=>e.PromptFormComponent)},{path:"admin/prompts",canActivate:[t],loadComponent:()=>import("./chunk-W7YYBRGC.js").then(e=>e.PlatformPromptsComponent)},{path:"admin/ai-providers/new",canActivate:[t],loadComponent:()=>import("./chunk-GCJZKHAW.js").then(e=>e.AiProviderFormComponent)},{path:"admin/ai-providers/:aiProviderId/edit",canActivate:[t],loadComponent:()=>import("./chunk-GCJZKHAW.js").then(e=>e.AiProviderFormComponent)},{path:"admin/ai-providers",canActivate:[t],loadComponent:()=>import("./chunk-GVYMNRD4.js").then(e=>e.PlatformAiProvidersComponent)},{path:"admin/ai-models/new",canActivate:[t],loadComponent:()=>import("./chunk-V3HCXJKS.js").then(e=>e.AiModelFormComponent)},{path:"admin/ai-models/:modelId/edit",canActivate:[t],loadComponent:()=>import("./chunk-V3HCXJKS.js").then(e=>e.AiModelFormComponent)},{path:"admin/ai-models",canActivate:[t],loadComponent:()=>import("./chunk-C47ZCNLR.js").then(e=>e.PlatformAiModelsComponent)},{path:"admin/agent-configs/new",canActivate:[t],loadComponent:()=>import("./chunk-F4BSKSY7.js").then(e=>e.AgentConfigFormComponent)},{path:"admin/agent-configs/:agentConfigId/edit",canActivate:[t],loadComponent:()=>import("./chunk-F4BSKSY7.js").then(e=>e.AgentConfigFormComponent)},{path:"admin/agent-configs/:agentConfigId/inspect",canActivate:[t],loadComponent:()=>import("./chunk-EFCODPLG.js").then(e=>e.AgentConfigInspectComponent)},{path:"admin/agent-configs",canActivate:[t],loadComponent:()=>import("./chunk-DEXRATBM.js").then(e=>e.PlatformAgentConfigsComponent)},{path:"me",canActivate:[t],loadComponent:()=>import("./chunk-QCUONBHJ.js").then(e=>e.UserProfileComponent)},{path:"user",canActivate:[t],loadComponent:()=>import("./chunk-QCUONBHJ.js").then(e=>e.UserProfileComponent)},{path:":namespaceId/integrations/new",canActivate:[t],loadComponent:()=>import("./chunk-2HEJ7K6I.js").then(e=>e.IntegrationFormComponent)},{path:":namespaceId/integrations/:integrationId/edit",canActivate:[t],loadComponent:()=>import("./chunk-2HEJ7K6I.js").then(e=>e.IntegrationFormComponent)},{path:":namespaceId/integrations",canActivate:[t],loadComponent:()=>import("./chunk-5GF6TTRK.js").then(e=>e.IntegrationsAllScopesComponent)},{path:":namespaceId/ai-providers/new",canActivate:[t],loadComponent:()=>import("./chunk-GCJZKHAW.js").then(e=>e.AiProviderFormComponent)},{path:":namespaceId/ai-providers/:aiProviderId/edit",canActivate:[t],loadComponent:()=>import("./chunk-GCJZKHAW.js").then(e=>e.AiProviderFormComponent)},{path:":namespaceId/ai-providers",canActivate:[t],loadComponent:()=>import("./chunk-J7IFGV56.js").then(e=>e.AiProvidersAllScopesComponent)},{path:":namespaceId/ai-models/new",canActivate:[t],loadComponent:()=>import("./chunk-V3HCXJKS.js").then(e=>e.AiModelFormComponent)},{path:":namespaceId/ai-models/:modelId/edit",canActivate:[t],loadComponent:()=>import("./chunk-V3HCXJKS.js").then(e=>e.AiModelFormComponent)},{path:":namespaceId/ai-models",canActivate:[t],loadComponent:()=>import("./chunk-JIPJ76UT.js").then(e=>e.NamespaceAiModelsComponent)},{path:":namespaceId/prompts/new",canActivate:[t],loadComponent:()=>import("./chunk-TUARXNRR.js").then(e=>e.PromptFormComponent)},{path:":namespaceId/prompts/:promptId/edit",canActivate:[t],loadComponent:()=>import("./chunk-TUARXNRR.js").then(e=>e.PromptFormComponent)},{path:":namespaceId/prompts",canActivate:[t],loadComponent:()=>import("./chunk-6MPSH5Y7.js").then(e=>e.NamespacePromptsComponent)},{path:":namespaceId/agent-configs/new",canActivate:[t],loadComponent:()=>import("./chunk-F4BSKSY7.js").then(e=>e.AgentConfigFormComponent)},{path:":namespaceId/agent-configs/:agentConfigId/edit",canActivate:[t],loadComponent:()=>import("./chunk-F4BSKSY7.js").then(e=>e.AgentConfigFormComponent)},{path:":namespaceId/agent-configs/:agentConfigId/inspect",canActivate:[t],loadComponent:()=>import("./chunk-EFCODPLG.js").then(e=>e.AgentConfigInspectComponent)},{path:":namespaceId/agent-configs",canActivate:[t],loadComponent:()=>import("./chunk-MVRV42NP.js").then(e=>e.NamespaceAgentConfigsComponent)},{path:"",redirectTo:"namespaces",pathMatch:"full"}]}]}];function te(e,o){e&1&&A(0,"span",1)}function ne(e,o){e&1&&A(0,"span",2)}function oe(e,o){e&1&&A(0,"span",3)}var v=class e{pluginService=d(K);online=b(null);ngOnInit(){this.pluginService.getAllPlugins().subscribe({next:()=>this.online.set(!0),error:()=>this.online.set(!1)})}static \u0275fac=function(n){return new(n||e)};static \u0275cmp=p({type:e,selectors:[["agentos-backend-status"]],decls:4,vars:1,consts:[[1,"backend-status"],["title","AgentOS online",1,"dot","dot--online"],["title","AgentOS offline",1,"dot","dot--offline"],["title","Checking\u2026",1,"dot","dot--checking"]],template:function(n,r){if(n&1&&(u(0,"div",0),l(1,te,1,0,"span",1)(2,ne,1,0,"span",2)(3,oe,1,0,"span",3),f()),n&2){let c;m(),g((c=r.online())===!0?1:c===!1?2:3)}},styles:[".backend-status[_ngcontent-%COMP%]{display:flex;align-items:center}.dot[_ngcontent-%COMP%]{width:8px;height:8px;border-radius:50%;flex-shrink:0}.dot--online[_ngcontent-%COMP%]{background:var(--color-success, #34c759)}.dot--offline[_ngcontent-%COMP%]{background:var(--color-error, #ff3b30)}.dot--checking[_ngcontent-%COMP%]{background:var(--color-text-secondary, #6e6e73);opacity:.5;animation:_ngcontent-%COMP%_pulse 1.2s ease-in-out infinite}@keyframes _ngcontent-%COMP%_pulse{0%,to{opacity:.5}50%{opacity:1}}"]})};function ae(e,o){if(e&1){let n=D();a(0,"button",9),C("click",function(){S(n);let c=_();return k(c.navigateToAdmin())}),a(1,"span",10),i(2,"\u2699\uFE0F"),s()()}}function ie(e,o){if(e&1&&(a(0,"span",7),i(1),s()),e&2){let n=_();m(),h(n.userInitials)}}function re(e,o){e&1&&(a(0,"span",8),i(1,"\u25EF"),s())}var Q=class e{router=d(P);userState=d(J);destroyRef=d(E);currentUser=this.userState.currentUser;navigateHome(){this.router.navigate(["/agentos/home"])}isAdmin=R(()=>this.userState.currentUser()?.isAdmin===!0);navigateToAdmin(){this.router.navigate(["/agentos/admin"])}ngOnInit(){this.currentUser()||this.userState.loadMe().pipe(W(this.destroyRef)).subscribe()}get userInitials(){let o=this.currentUser();if(!o)return"";let n=o.firstname?.[0]??"",r=o.lastname?.[0]??"";return(n+r).toUpperCase()||o.email?.[0]?.toUpperCase()||"?"}get isOnProfilePage(){return this.router.url.startsWith("/agentos/me")}toggleProfile(){this.isOnProfilePage?window.history.length>1?window.history.back():this.router.navigate(["/agentos"]):this.router.navigate(["/agentos/me"])}static \u0275fac=function(n){return new(n||e)};static \u0275cmp=p({type:e,selectors:[["agentos-header"]],decls:11,vars:5,consts:[[1,"header"],["type","button","title","Home",1,"header__brand",3,"click"],["src","CODAY-Logo.png","alt","Coday",1,"header__logo-img"],[1,"header__logo-text"],[1,"header__nav"],["type","button","title","Admin",1,"header__admin-btn"],["type","button",1,"header__user-btn",3,"click","title"],[1,"header__user-initials"],[1,"header__user-icon"],["type","button","title","Admin",1,"header__admin-btn",3,"click"],[1,"header__admin-icon"]],template:function(n,r){n&1&&(a(0,"header",0)(1,"button",1),C("click",function(){return r.navigateHome()}),x(2,"img",2),a(3,"span",3),i(4,"Coday"),s()(),a(5,"nav",4),x(6,"agentos-backend-status"),l(7,ae,3,0,"button",5),a(8,"button",6),C("click",function(){return r.toggleProfile()}),l(9,ie,2,1,"span",7)(10,re,2,0,"span",8),s()()()),n&2&&(m(7),g(r.isAdmin()?7:-1),m(),z("header__user-btn--active",r.isOnProfilePage),y("title",r.isOnProfilePage?"Back":"My profile"),m(),g(r.userInitials?9:10))},dependencies:[v],styles:[".header[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;padding:0 1.5rem;height:56px;background:var(--glass-bg, rgba(255, 255, 255, .72));border-bottom:1px solid var(--glass-border, rgba(255, 255, 255, .18));backdrop-filter:var(--glass-backdrop-blur, blur(20px));-webkit-backdrop-filter:var(--glass-backdrop-blur, blur(20px));position:sticky;top:0;z-index:100}.header__brand[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;background:none;border:none;padding:0;cursor:pointer;border-radius:6px;transition:opacity .15s ease}.header__brand[_ngcontent-%COMP%]:hover{opacity:.7}.header__logo-img[_ngcontent-%COMP%]{width:32px;height:32px;object-fit:contain}.header__logo-text[_ngcontent-%COMP%]{font-size:1rem;font-weight:700;letter-spacing:-.01em;color:var(--color-text, #1d1d1f)}.header__nav[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}.header__admin-btn[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:50%;border:1.5px solid var(--color-border, rgba(0, 0, 0, .1));background:var(--color-bg-secondary, rgba(0, 0, 0, .04));cursor:pointer;transition:background .15s ease,border-color .15s ease;padding:0;font-family:inherit;font-size:1rem;line-height:1}.header__admin-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover, rgba(0, 0, 0, .08));border-color:var(--color-primary, #007aff)}.header__admin-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.header__user-btn[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:50%;border:1.5px solid var(--color-border, rgba(0, 0, 0, .1));background:var(--color-bg-secondary, rgba(0, 0, 0, .04));cursor:pointer;transition:background .15s ease,border-color .15s ease;padding:0;font-family:inherit}.header__user-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover, rgba(0, 0, 0, .08));border-color:var(--color-primary, #007aff)}.header__user-btn--active[_ngcontent-%COMP%]{background:var(--color-primary, #007aff);border-color:var(--color-primary, #007aff)}.header__user-btn--active[_ngcontent-%COMP%] .header__user-initials[_ngcontent-%COMP%], .header__user-btn--active[_ngcontent-%COMP%] .header__user-icon[_ngcontent-%COMP%]{color:#fff}.header__user-initials[_ngcontent-%COMP%]{font-size:.75rem;font-weight:600;color:var(--color-text, #1d1d1f);line-height:1;letter-spacing:.02em}.header__user-icon[_ngcontent-%COMP%]{font-size:1rem;color:var(--color-text-secondary, #6e6e73);line-height:1}"]})};function se(e,o){e&1&&(u(0,"p",6),i(1,"No cases yet. Start one below."),f())}function me(e,o){if(e&1&&(u(0,"div",7)(1,"span",8),i(2),f(),u(3,"span",9),i(4),f()()),e&2){let n=o.$implicit;m(2),h(n.id),m(2),h(n.status)}}function ce(e,o){if(e&1&&F(0,me,5,2,"div",7,w().trackById,!0),e&2){let n=_();T(n)}}function de(e,o){e&1&&l(0,se,2,0,"p",6)(1,ce,2,0),e&2&&g(o.length===0?0:1)}var X=class e{http=d(j);router=d(P);route=d(V);config=d($);caseController=d(G);preferences=d(q);namespaceId=this.route.snapshot.params.namespaceId;cases$=this.caseController.listByParentCase(this.namespaceId);inputValue=b("");onInput(o){this.inputValue.set(o.target.value)}onKeydown(o){this.preferences.shouldSend(o)&&(o.preventDefault(),this.submit())}submit(){this.inputValue().trim()&&this.http.post(`${this.config.basePath}/api/cases`,{namespaceId:this.namespaceId,metadata:{}}).subscribe(n=>{this.inputValue.set(""),this.router.navigate(["/agentos",this.namespaceId,"cases",n.id??""])})}trackById(o,n){return n.id??""}static \u0275fac=function(n){return new(n||e)};static \u0275cmp=p({type:e,selectors:[["agentos-case-list"]],decls:11,vars:5,consts:[[1,"case-list"],[1,"case-list__header"],[1,"case-list__items"],[1,"case-list__composer"],["placeholder","Start a new case\u2026","rows","3",1,"case-list__input",3,"input","keydown","value"],[1,"case-list__hint"],[1,"case-list__empty"],[1,"case-list__item"],[1,"case-list__item-id"],[1,"case-list__item-status"]],template:function(n,r){if(n&1&&(u(0,"div",0)(1,"header",1)(2,"h2"),i(3,"Cases"),f()(),u(4,"div",2),l(5,de,2,1),L(6,"async"),f(),u(7,"div",3)(8,"textarea",4),N("input",function(I){return r.onInput(I)})("keydown",function(I){return r.onKeydown(I)}),f(),u(9,"p",5),i(10),f()()()),n&2){let c;m(5),g((c=U(6,3,r.cases$))?5:-1,c),m(3),H("value",r.inputValue()),m(2),h(r.preferences.composerHint())}},dependencies:[B],styles:[".case-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;max-width:720px;margin:0 auto;padding:2rem;gap:1.5rem}.case-list__header[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text, #1d1d1f);letter-spacing:-.02em}.case-list__items[_ngcontent-%COMP%]{flex:1;overflow-y:auto}.case-list__empty[_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73);font-size:.9rem;margin:0}.case-list__composer[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.case-list__input[_ngcontent-%COMP%]{width:100%;resize:none;padding:.75rem 1rem;border-radius:12px;border:1px solid var(--color-border, rgba(0, 0, 0, .1));background:var(--glass-bg, rgba(255, 255, 255, .72));-webkit-backdrop-filter:var(--glass-backdrop-blur, blur(20px));backdrop-filter:var(--glass-backdrop-blur, blur(20px));color:var(--color-text, #1d1d1f);font-size:.95rem;font-family:inherit;line-height:1.5;outline:none;box-sizing:border-box;transition:border-color .15s ease}.case-list__input[_ngcontent-%COMP%]:focus{border-color:var(--color-primary, #007aff)}.case-list__input[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary, #6e6e73)}.case-list__hint[_ngcontent-%COMP%]{margin:0;font-size:.75rem;color:var(--color-text-secondary, #6e6e73);opacity:.7}"]})};var Z=class e{case;static toListItem(o){return{id:o.id??"",name:o.title??o.id??"\u2014",description:void 0}}static \u0275fac=function(n){return new(n||e)};static \u0275cmp=p({type:e,selectors:[["agentos-case-item"]],inputs:{case:"case"},decls:0,vars:0,template:function(n,r){},encapsulation:2,changeDetection:0})};function pe(e,o){if(e&1&&(a(0,"p",11),i(1," Last action: "),a(2,"strong"),i(3),s()()),e&2){let n=_();m(3),h(n.lastAction())}}var ee=class e{lastAction=b(null);onSend(){this.lastAction.set("send")}onStop(){this.lastAction.set("stop")}onAttach(){this.lastAction.set("attach")}static \u0275fac=function(n){return new(n||e)};static \u0275cmp=p({type:e,selectors:[["agentos-hello"]],decls:35,vars:2,consts:[[1,"hello-agentos"],[1,"card"],[1,"badge"],[1,"principles"],[1,"demo"],[1,"demo-label"],[1,"demo-buttons"],["icon","send","variant","primary","title","Send",3,"action"],["icon","stop","variant","danger","title","Stop",3,"action"],["icon","attach_file","variant","default","title","Attach",3,"action"],["icon","mic","variant","default","title","Record",3,"action","disabled"],[1,"demo-feedback"]],template:function(n,r){n&1&&(a(0,"div",0)(1,"div",1)(2,"div",2),i(3,"AgentOS UI"),s(),a(4,"h1"),i(5,"Hello AgentOS"),s(),a(6,"p"),i(7," This component lives in "),a(8,"code"),i(9,"libs/agentos-ui"),s(),i(10," \u2014 isolated from Coday internals, ready to be published as "),a(11,"code"),i(12,"@whoz-oss/agentos-ui"),s(),i(13,". "),s(),x(14,"agentos-backend-status"),a(15,"ul",3)(16,"li"),i(17,"\u2726 No imports from Coday app"),s(),a(18,"li"),i(19,"\u2726 CSS custom properties as host contract"),s(),a(20,"li"),i(21,"\u2726 Standalone Angular components"),s(),a(22,"li"),i(23,"\u2726 Signals-first reactive state"),s()(),a(24,"div",4)(25,"p",5),i(26,"ds-icon-button from "),a(27,"code"),i(28,"@whoz-oss/design-system"),s()(),a(29,"div",6)(30,"ds-icon-button",7),C("action",function(){return r.onSend()}),s(),a(31,"ds-icon-button",8),C("action",function(){return r.onStop()}),s(),a(32,"ds-icon-button",9),C("action",function(){return r.onAttach()}),s(),a(33,"ds-icon-button",10),C("action",function(){return r.onAttach()}),s()(),l(34,pe,4,1,"p",11),s()()()),n&2&&(m(33),y("disabled",!0),m(),g(r.lastAction()?34:-1))},dependencies:[Y,v],styles:['@charset "UTF-8";.hello-agentos[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;min-height:100vh;padding:2rem}.card[_ngcontent-%COMP%]{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 32px 0 rgba(31, 38, 135, .15));backdrop-filter:var(--glass-backdrop-blur, blur(20px));-webkit-backdrop-filter:var(--glass-backdrop-blur, blur(20px));border-radius:20px;padding:3rem;max-width:480px;width:100%;text-align:center}.badge[_ngcontent-%COMP%]{display:inline-block;background:var(--color-primary, #007aff);color:var(--color-text-inverse, #ffffff);font-size:.75rem;font-weight:600;letter-spacing:.08em;text-transform:uppercase;padding:.25rem .75rem;border-radius:100px;margin-bottom:1.5rem}h1[_ngcontent-%COMP%]{color:var(--color-text, #1d1d1f);font-size:2rem;font-weight:700;margin:0 0 1rem;letter-spacing:-.02em}p[_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73);line-height:1.6;margin:0 0 1.5rem}p[_ngcontent-%COMP%] code[_ngcontent-%COMP%]{background:var(--color-code-bg, rgba(142, 142, 147, .12));color:var(--color-code-text, #ff375f);padding:.125rem .375rem;border-radius:6px;font-size:.875em;border:1px solid var(--color-border, rgba(0, 0, 0, .1))}.principles[_ngcontent-%COMP%]{list-style:none;margin:0 0 1.5rem;padding:0;text-align:left;display:flex;flex-direction:column;gap:.5rem}.principles[_ngcontent-%COMP%] li[_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73);font-size:.9rem;padding:.5rem .75rem;background:var(--color-bg-hover, rgba(0, 0, 0, .04));border-radius:8px;border:1px solid var(--color-border-light, rgba(40, 40, 40, .08))}.demo[_ngcontent-%COMP%]{border-top:1px solid var(--color-border-light, rgba(40, 40, 40, .08));padding-top:1.25rem}.demo[_ngcontent-%COMP%] .demo-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73);font-size:.8rem;margin:0 0 .75rem}.demo[_ngcontent-%COMP%] .demo-label[_ngcontent-%COMP%] code[_ngcontent-%COMP%]{background:var(--color-code-bg, rgba(142, 142, 147, .12));color:var(--color-code-text, #ff375f);padding:.125rem .375rem;border-radius:6px;font-size:.875em;border:1px solid var(--color-border, rgba(0, 0, 0, .1))}.demo[_ngcontent-%COMP%] .demo-buttons[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:center;justify-content:center;padding:.75rem;background:var(--color-bg-hover, rgba(0, 0, 0, .04));border-radius:12px;border:1px solid var(--color-border-light, rgba(40, 40, 40, .08))}.demo[_ngcontent-%COMP%] .demo-feedback[_ngcontent-%COMP%]{margin:.75rem 0 0;font-size:.85rem;color:var(--color-text-secondary, #6e6e73)}.demo[_ngcontent-%COMP%] .demo-feedback[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{color:var(--color-primary, #007aff)}']})};export{Je as AGENTOS_ROUTES,Re as ActionCardChipsDirective,Be as ActionCardComponent,fe as AgentosShellComponent,ge as AgentosThemeService,he as AgentosUserPreferencesService,v as BackendStatusComponent,He as CaseChatComponent,ze as CaseDrawerComponent,Ne as CaseHomeComponent,Z as CaseItemComponent,X as CaseListComponent,Le as CaseShellComponent,Ce as ENTER_KEY_BEHAVIORS,Ee as ExchangeContentViewerComponent,Te as ExchangeDrawerComponent,Fe as ExchangeFileListComponent,we as ExchangeItemComponent,De as ExchangeShellComponent,_e as ExchangeStateService,Q as HeaderComponent,ee as HelloAgentosComponent,Ue as LayoutComponent,be as MAX_VIEWABLE_SIZE,ke as MarkdownPipe,je as NamespaceItemComponent,Ve as NamespaceListComponent,le as THEME_MODES,ue as THEME_PORT,q as USER_PREFERENCES_PORT,$e as UserAdminStateService,Ge as UserFormComponent,Ke as UserItemComponent,We as UserListComponent,J as UserStateService,t as agentosReadyGuard,Oe as canViewFile,Ae as detectFormat,Se as exchangeMutationScope,ye as formatDate,xe as formatSize,ve as getFileIcon,Pe as isFormatViewable,Me as isViewable,Ie as reindentJson};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Cn}from"./chunk-OWSH6KVW.js";import{a as Ue,b as Be,c as _n,e as ce}from"./chunk-34BTCCLM.js";import{a as yn,b as wn,c as Tn}from"./chunk-WIYSZEOD.js";import{a as Ke}from"./chunk-4TH4ERQY.js";import{a as je,b as X,c as ln,d as se,i as mn,j as pn,k as un,o as gn,p as hn,r as fn,t as Qe,v as bn,x as vn,y as Xe}from"./chunk-NAHXPRXR.js";import{a as xn}from"./chunk-QCDV42EK.js";import{c as Kt}from"./chunk-P4GNUQZT.js";import{a as In}from"./chunk-V7NUXN3R.js";import{r as On,u as kn}from"./chunk-SOAR3OAC.js";import{b as dn,h as Sn,i as Mn,j as En,n as Pn}from"./chunk-EBAEYY2S.js";import{a as cn,c as $e}from"./chunk-SKBT6DBT.js";import{a as R,b as L}from"./chunk-GF3EMWCA.js";import{E as Ge,c as We,g as qe,m as Ye}from"./chunk-Z6RFJ6L3.js";import{b as Q}from"./chunk-LN55MSDV.js";import{E as rn,K as an,O as re,Q as sn,R as Ne,S as ae,i as Jt,j as Zt,p as en,s as tn,t as nn,z as on}from"./chunk-OPSHMM4H.js";import{$b as Wt,B as W,Bb as _,D as De,Db as h,Fb as l,G as Ft,Ga as z,Ha as Lt,Hc as ze,Ja as zt,Jb as ge,Jc as Xt,Ka as c,Kb as J,Kc as St,Lb as Z,Nc as j,Pa as Nt,Rb as N,T as F,Tb as p,Ub as S,Vb as he,Vc as Y,Wa as T,Wb as Ae,Xa as $t,Ya as jt,Yb as Fe,Yc as G,Z as k,Za as Ut,Zb as Re,_ as Rt,_b as He,a as de,ac as qt,b as Oe,bc as Yt,ca as m,cc as Gt,d as P,ec as Ee,fc as Qt,g as ke,ga as f,gc as Tt,h as B,ha as b,i as Ie,jb as oe,la as Ht,lb as u,lc as Ve,m as xt,mb as g,n as Dt,oa as M,pa as Vt,pb as H,qb as V,rb as C,sb as a,t as ne,ta as ie,tb as s,u as At,ub as y,va as q,vb as yt,wb as wt,wc as Le,xb as Bt,ya as ue}from"./chunk-5NLXR4MK.js";var Je=class i{sanitizer=m(G);transform(e,t){if(!t||!e)return e;let n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`(${n})`,"gi"),r=e.replace(o,"<strong>$1</strong>");return this.sanitizer.bypassSecurityTrustHtml(r)}static \u0275fac=function(t){return new(t||i)};static \u0275pipe=Ut({name:"highlight",type:i,pure:!0})};var fe=class i{http=m(Y);projectState=m(Q);threadState=m(X);transcribeAudio(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow();return this.http.post(`/api/projects/${o}/transcribe`,de({audio:e,mimeType:t},n?{language:n}:{}))}sendVoiceMessage(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow(),r=this.threadState.getSelectedThreadIdOrThrow();return this.http.post(`/api/projects/${o}/threads/${r}/voice-message`,de({audio:e,mimeType:t},n?{language:n}:{}))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=k({token:i,factory:i.\u0275fac,providedIn:"root"})};var hi=["messageInput"],fi=["fileInput"],bi=(i,e)=>e.name;function vi(i,e){i&1&&(a(0,"div",3),y(1,"span",8),p(2," Recording... Click mic to stop "),s())}function Ci(i,e){i&1&&(a(0,"div",3),y(1,"span",9),p(2," Transcribing... "),s())}function _i(i,e){if(i&1&&(a(0,"span",14),p(1),s()),i&2){let t=l().$implicit,n=l(2);c(),S(" "+(n.getParameterFormat(t)||""))}}function xi(i,e){if(i&1){let t=_();a(0,"div",11),h("click",function(){let o=f(t).$index,r=l(2);return b(r.selectAutocompleteItemByClick(o))})("keydown.enter",function(){let o=f(t).$index,r=l(2);return b(r.selectAutocompleteItemByClick(o))})("keydown.space",function(){let o=f(t).$index,r=l(2);return b(r.selectAutocompleteItemByClick(o))})("mouseenter",function(){let o=f(t).$index,r=l(2);return b(r.selectedAutocompleteIndex=o)}),a(1,"div",12),y(2,"span",13),Ee(3,"highlight"),u(4,_i,2,1,"span",14),s(),y(5,"div",15),Ee(6,"highlight"),s()}if(i&2){let t=e.$implicit,n=e.$index,o=l(2);N("selected",n===o.selectedAutocompleteIndex),oe("aria-selected",n===o.selectedAutocompleteIndex),c(2),C("innerHTML",Tt(3,6,o.autocompleteTrigger+t.name,o.getAutocompleteQuery()),z),c(2),g(o.hasParameterFormat(t)?4:-1),c(),C("innerHTML",Tt(6,9,t.description,o.getAutocompleteQuery()),z)}}function yi(i,e){if(i&1&&(a(0,"div",4),H(1,xi,7,12,"div",10,bi),s()),i&2){let t=l();c(),V(t.autocompleteItems)}}function wi(i,e){if(i&1){let t=_();a(0,"ds-icon-button",18),h("action",function(){f(t);let o=l(2);return b(o.onStopClick())}),s()}}function Ti(i,e){if(i&1){let t=_();a(0,"ds-icon-button",19),h("action",function(){f(t);let o=l(2);return b(o.sendMessage())}),s()}if(i&2){let t=l(2);N("hidden",t.isDisabled||!t.message.trim())("active",!!t.message.trim()&&!t.isDisabled),C("title",t.getSendButtonTooltip())("disabled",t.isDisabled||!t.message.trim())}}function Si(i,e){if(i&1){let t=_();a(0,"ds-icon-button",21),h("action",function(){f(t);let o=l(3);return b(o.triggerFileUpload())}),s(),a(1,"input",22,1),h("change",function(o){f(t);let r=l(3);return b(r.onFileInputChange(o))}),s()}if(i&2){let t=l(3);C("disabled",t.isDisabled)}}function Mi(i,e){if(i&1){let t=_();u(0,Si,3,1),a(1,"ds-icon-button",20),h("action",function(){f(t);let o=l(2);return b(o.toggleRecording())}),s()}if(i&2){let t=l(2);g(!t.showWelcome&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?0:-1),c(),N("hidden",t.message.trim()&&!t.isRecording&&!t.isTranscribing),C("variant",t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing)?"danger":"default")("disabled",t.isVoiceMessageMode&&t.isTranscribing)("title",t.isRecording?"Click to stop recording":t.isTranscribing?"Uploading...":"Click to start recording")}}function Ei(i,e){if(i&1&&(a(0,"div",7),u(1,wi,1,0,"ds-icon-button",16),u(2,Ti,1,6,"ds-icon-button",17),u(3,Mi,2,6),s()),i&2){let t=l();c(),g(t.isThinking?1:-1),c(),g((!t.isThinking||t.message.trim())&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?2:-1),c(),g(t.isThinking?-1:3)}}var Ze=class i{isDisabled=!1;showWelcome=!1;isThinking=!1;isStarting=!1;isSessionInitializing=!1;isStopping=!1;filesPasted=new M;messageSubmitted=new M;voiceMessageReady=new M;voiceRecordingToggled=new M;heightChanged=new M;stopRequested=new M;textareaFocused=new M;messageInput;fileInput;message="";isRecording=!1;isTranscribing=!1;isFocused=!1;recognition=null;mediaRecorder=null;audioChunks=[];voiceInputMode="browser";get isVoiceMessageMode(){return this.voiceInputMode==="voice-message"}sessionHadTranscript=!1;pendingLineBreaksTimeout=null;lastProcessedResultIndex=0;useEnterToSend=!1;currentInvite="";subscriptions=[];thinkingPhrases=["Processing request...","Thinking...","Working on it..."];currentThinkingPhrase="Processing request...";thinkingPhraseIndex=0;thinkingInterval=null;autocompleteVisible=!1;autocompleteTrigger=null;autocompleteItems=[];selectedAutocompleteIndex=0;preferencesService=m(se);codayService=m(ce);agentApiService=m(Cn);promptApiService=m(In);projectStateService=m(Q);audioApiService=m(fe);threadStateService=m(X);ngOnInit(){this.initializeVoiceInput(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.subscriptions.push(this.preferencesService.voiceLanguage$.subscribe(()=>this.updateRecognitionLanguage())),this.subscriptions.push(this.preferencesService.voiceInputMode$.subscribe(e=>{this.voiceInputMode=e})),this.subscriptions.push(this.preferencesService.enterToSend$.subscribe(e=>{this.useEnterToSend=e})),this.subscribeToInviteEvents(),this.subscribeToMessageRestore()}ngAfterViewInit(){this.adjustTextareaHeight(),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),200)})}ngOnChanges(e){e.isThinking&&(e.isThinking.currentValue?this.startThinkingAnimation():(this.stopThinkingAnimation(),this.isStopping=!1,e.isThinking.previousValue&&(console.log("[CHAT-TEXTAREA] Thinking ended, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100)})))),e.isSessionInitializing&&!e.isSessionInitializing.currentValue&&e.isSessionInitializing.previousValue&&(console.log("[CHAT-TEXTAREA] Session initialization completed, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100)})),e.isStarting&&!e.isStarting.currentValue&&e.isStarting.previousValue&&this.isThinking&&(this.thinkingPhraseIndex===0?(console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index 0 - restarting animation"),this.stopThinkingAnimation(),this.startThinkingAnimation()):console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index",this.thinkingPhraseIndex,"- continuing without restart"))}ngOnDestroy(){this.subscriptions.forEach(e=>e.unsubscribe()),this.subscriptions=[],this.clearPendingLineBreaks(),this.stopThinkingAnimation()}onKeyDown(e){if(this.autocompleteVisible)switch(e.key){case"ArrowDown":e.preventDefault(),this.selectedAutocompleteIndex=Math.min(this.selectedAutocompleteIndex+1,this.autocompleteItems.length-1),this.scrollSelectedItemIntoView();return;case"ArrowUp":e.preventDefault(),this.selectedAutocompleteIndex=Math.max(this.selectedAutocompleteIndex-1,0),this.scrollSelectedItemIntoView();return;case"Tab":case"Enter":if(!this.message.includes(" ")){e.preventDefault(),this.selectAutocompleteItem();return}break;case"Escape":e.preventDefault(),this.hideAutocomplete();return}e.key==="Enter"&&(this.useEnterToSend?!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),this.sendMessage(!0)):(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey)&&!e.shiftKey&&(e.preventDefault(),this.sendMessage(!0)))}onInput(){this.adjustTextareaHeight(),this.checkForAutocomplete()}onPaste(e){let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(r=>r.kind==="file");if(!n.length)return;e.preventDefault();let o=n.reduce((r,d)=>{let v=d.getAsFile();return v?[...r,v]:r},[]);o.length&&this.filesPasted.emit(o)}triggerFileUpload(){console.log("[CHAT-TEXTAREA] Triggering file upload"),this.fileInput?.nativeElement?.click()}onFileInputChange(e){let t=e.target,n=t.files;if(!n||n.length===0){console.log("[CHAT-TEXTAREA] No files selected");return}console.log("[CHAT-TEXTAREA] Files selected:",n.length);let o=Array.from(n);this.filesPasted.emit(o),t.value=""}onDocumentClick(e){if(!this.autocompleteVisible)return;let t=e.target,n=document.querySelector(".autocomplete-popup"),o=this.messageInput?.nativeElement;n&&!n.contains(t)&&o&&!o.contains(t)&&this.hideAutocomplete()}sendMessage(e=!1){let t=this.message.trim();!this.isDisabled&&(e||t)&&(this.isRecording&&this.recognition&&(this.clearPendingLineBreaks(),this.recognition.stop()),this.messageSubmitted.emit(t),this.message="",setTimeout(()=>this.adjustTextareaHeight(),0))}onStopClick(){this.isStopping=!0,this.stopRequested.emit()}toggleRecording(){this.isRecording?this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.stopWhisperRecording():this.stopRecording():this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.startWhisperRecording():this.startRecording()}startWhisperRecording(){return P(this,null,function*(){if(!this.isRecording)try{let e=yield navigator.mediaDevices.getUserMedia({audio:!0});this.audioChunks=[],this.mediaRecorder=new MediaRecorder(e),this.mediaRecorder.ondataavailable=t=>{t.data.size>0&&this.audioChunks.push(t.data)},this.mediaRecorder.onstop=()=>{e.getTracks().forEach(t=>t.stop()),this.processWhisperAudio()},this.mediaRecorder.onerror=t=>{console.error("[WHISPER] MediaRecorder error:",t),e.getTracks().forEach(n=>n.stop()),this.isRecording=!1,this.voiceRecordingToggled.emit(!1)},this.mediaRecorder.start(),this.isRecording=!0,this.voiceRecordingToggled.emit(!0),console.log("[WHISPER] Started recording")}catch(e){console.error("[WHISPER] Failed to start recording:",e),this.isRecording=!1,this.voiceRecordingToggled.emit(!1)}})}stopWhisperRecording(){if(!(!this.mediaRecorder||!this.isRecording))try{this.mediaRecorder.stop(),this.isRecording=!1,this.voiceRecordingToggled.emit(!1),console.log("[WHISPER] Stopped recording")}catch(e){console.error("[WHISPER] Failed to stop recording:",e),this.isRecording=!1,this.voiceRecordingToggled.emit(!1)}}processWhisperAudio(){if(this.audioChunks.length===0)return;let e=new Blob(this.audioChunks,{type:this.mediaRecorder?.mimeType||"audio/webm"}),t=e.type.split(";")[0]||"audio/webm";this.audioChunks=[],this.isTranscribing=!0;let n=new FileReader;n.onloadend=()=>{let o=n.result.split(",")[1];if(!o){console.error("[WHISPER] Failed to read audio as base64"),this.isTranscribing=!1;return}let d=this.preferencesService.getVoiceLanguage().split("-")[0];if(this.voiceInputMode==="voice-message"){if(!this.threadStateService.getSelectedThreadId()){console.log("[WHISPER] No thread selected \u2014 emitting voiceMessageReady for thread creation"),this.isTranscribing=!1,this.voiceMessageReady.emit({base64:o,mimeType:t,language:d});return}this.audioApiService.sendVoiceMessage(o,t,d).subscribe({next:v=>{this.isTranscribing=!1,console.log("[WHISPER] Voice message sent, transcription:",v.transcription?.substring(0,50))},error:v=>{console.error("[WHISPER] Voice message error:",v),this.isTranscribing=!1,this.fallbackToTranscription(o,t,d)}})}else this.audioApiService.transcribeAudio(o,t,d).subscribe({next:v=>{this.isTranscribing=!1,v.text&&this.appendToTextarea(v.text+" ")},error:v=>{console.error("[WHISPER] Transcription error:",v),this.isTranscribing=!1}})},n.readAsDataURL(e)}fallbackToTranscription(e,t,n){this.audioApiService.transcribeAudio(e,t,n).subscribe({next:o=>{this.isTranscribing=!1,o.text&&this.appendToTextarea(o.text+" ")},error:o=>{console.error("[WHISPER] Fallback transcription also failed:",o),this.isTranscribing=!1}})}initializeVoiceInput(){let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(console.log("[SPEECH] speechRecognition",e),!e){console.warn("[SPEECH] Speech Recognition API not available");return}this.recognition=new e,this.recognition.continuous=!0,this.recognition.interimResults=!0,this.recognition.maxAlternatives=1,this.recognition.lang=this.getSelectedLanguage();try{"grammars"in this.recognition&&(this.recognition.serviceURI=void 0)}catch(t){console.log("[SPEECH] Advanced speech recognition parameters not supported")}this.recognition.onresult=t=>{let n="",o=Math.max(t.resultIndex,this.lastProcessedResultIndex);for(let r=o;r<t.results.length;r++)t.results[r].isFinal&&(n+=t.results[r][0].transcript,this.lastProcessedResultIndex=r+1);if(n){let r=this.improveTranscriptPunctuation(n.trim());this.sessionHadTranscript=!0,console.log("[SPEECH] onresult ending, appending to textarea",this.isRecording),this.appendToTextarea(r)}},this.recognition.onend=()=>{console.log("[SPEECH] Recognition ended. Was recording:",this.isRecording),this.isRecording=!1,this.lastProcessedResultIndex=0,this.voiceRecordingToggled.emit(this.isRecording)},this.recognition.onerror=t=>{console.error("[SPEECH] Speech recognition error:",t.error),console.log("[SPEECH] Error details:",{error:t.error,message:t.message,timeStamp:t.timeStamp}),this.isRecording=!1,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording)},this.recognition.onstart=()=>{console.log("[SPEECH] Recognition started successfully")},this.recognition.onspeechstart=()=>{console.log("[SPEECH] Speech detected")},this.recognition.onspeechend=()=>{console.log("[SPEECH] Speech ended")}}startRecording(){return P(this,null,function*(){if(!(!this.recognition||this.isRecording))try{this.isRecording=!0,this.sessionHadTranscript=!1,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording),this.recognition.start(),console.log("[SPEECH] Started recording")}catch(e){console.error("[SPEECH] Failed to start recording:",e),this.isRecording=!1,this.voiceRecordingToggled.emit(this.isRecording)}})}stopRecording(){if(!this.recognition||!this.isRecording){console.log("[SPEECH] stopRecording not recording");return}try{console.log("[SPEECH] stopRecording recognition stop"),this.recognition.stop(),this.schedulePendingLineBreaks()}catch(e){console.error("[SPEECH] Failed to stop recording:",e)}}getSelectedLanguage(){return this.preferencesService.getVoiceLanguage()}updateRecognitionLanguage(){if(this.recognition){let e=this.getSelectedLanguage();this.recognition.lang=e,console.log("[SPEECH] Language changed to:",e)}}improveTranscriptPunctuation(e){let t=e;return/[.!?]$/.test(t.trim())||(t=t.trim()+"."),t=t.charAt(0).toUpperCase()+t.slice(1),t=t.replace(/\s+/g," "),t=t+" ",t}appendToTextarea(e){let t=this.message;if(this.message=t?`${t}${e}`:e,this.messageInput?.nativeElement){this.messageInput.nativeElement.focus();let n=this.message.length;this.messageInput.nativeElement.setSelectionRange(n,n)}setTimeout(()=>this.adjustTextareaHeight(),0)}schedulePendingLineBreaks(){this.clearPendingLineBreaks(),this.pendingLineBreaksTimeout=window.setTimeout(()=>{this.sessionHadTranscript&&(console.log("[SPEECH] Adding line breaks after transcript session"),this.appendToTextarea(`
|
|
1
|
+
import{a as Cn}from"./chunk-OWSH6KVW.js";import{a as Ue,b as Be,c as _n,e as ce}from"./chunk-34BTCCLM.js";import{a as yn,b as wn,c as Tn}from"./chunk-WIYSZEOD.js";import{a as Ke}from"./chunk-4TH4ERQY.js";import{a as je,b as X,c as ln,d as se,i as mn,j as pn,k as un,o as gn,p as hn,r as fn,t as Qe,v as bn,x as vn,y as Xe}from"./chunk-NAHXPRXR.js";import{a as xn}from"./chunk-QCDV42EK.js";import{c as Kt}from"./chunk-P4GNUQZT.js";import{a as In}from"./chunk-V7NUXN3R.js";import{r as On,u as kn}from"./chunk-K7JRH3HO.js";import{b as dn,h as Sn,i as Mn,j as En,n as Pn}from"./chunk-EBAEYY2S.js";import{a as cn,c as $e}from"./chunk-SKBT6DBT.js";import{a as R,b as L}from"./chunk-GF3EMWCA.js";import{E as Ge,c as We,g as qe,m as Ye}from"./chunk-Z6RFJ6L3.js";import{b as Q}from"./chunk-LN55MSDV.js";import{E as rn,K as an,O as re,Q as sn,R as Ne,S as ae,i as Jt,j as Zt,p as en,s as tn,t as nn,z as on}from"./chunk-OPSHMM4H.js";import{$b as Wt,B as W,Bb as _,D as De,Db as h,Fb as l,G as Ft,Ga as z,Ha as Lt,Hc as ze,Ja as zt,Jb as ge,Jc as Xt,Ka as c,Kb as J,Kc as St,Lb as Z,Nc as j,Pa as Nt,Rb as N,T as F,Tb as p,Ub as S,Vb as he,Vc as Y,Wa as T,Wb as Ae,Xa as $t,Ya as jt,Yb as Fe,Yc as G,Z as k,Za as Ut,Zb as Re,_ as Rt,_b as He,a as de,ac as qt,b as Oe,bc as Yt,ca as m,cc as Gt,d as P,ec as Ee,fc as Qt,g as ke,ga as f,gc as Tt,h as B,ha as b,i as Ie,jb as oe,la as Ht,lb as u,lc as Ve,m as xt,mb as g,n as Dt,oa as M,pa as Vt,pb as H,qb as V,rb as C,sb as a,t as ne,ta as ie,tb as s,u as At,ub as y,va as q,vb as yt,wb as wt,wc as Le,xb as Bt,ya as ue}from"./chunk-5NLXR4MK.js";var Je=class i{sanitizer=m(G);transform(e,t){if(!t||!e)return e;let n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`(${n})`,"gi"),r=e.replace(o,"<strong>$1</strong>");return this.sanitizer.bypassSecurityTrustHtml(r)}static \u0275fac=function(t){return new(t||i)};static \u0275pipe=Ut({name:"highlight",type:i,pure:!0})};var fe=class i{http=m(Y);projectState=m(Q);threadState=m(X);transcribeAudio(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow();return this.http.post(`/api/projects/${o}/transcribe`,de({audio:e,mimeType:t},n?{language:n}:{}))}sendVoiceMessage(e,t,n){let o=this.projectState.getSelectedProjectIdOrThrow(),r=this.threadState.getSelectedThreadIdOrThrow();return this.http.post(`/api/projects/${o}/threads/${r}/voice-message`,de({audio:e,mimeType:t},n?{language:n}:{}))}static \u0275fac=function(t){return new(t||i)};static \u0275prov=k({token:i,factory:i.\u0275fac,providedIn:"root"})};var hi=["messageInput"],fi=["fileInput"],bi=(i,e)=>e.name;function vi(i,e){i&1&&(a(0,"div",3),y(1,"span",8),p(2," Recording... Click mic to stop "),s())}function Ci(i,e){i&1&&(a(0,"div",3),y(1,"span",9),p(2," Transcribing... "),s())}function _i(i,e){if(i&1&&(a(0,"span",14),p(1),s()),i&2){let t=l().$implicit,n=l(2);c(),S(" "+(n.getParameterFormat(t)||""))}}function xi(i,e){if(i&1){let t=_();a(0,"div",11),h("click",function(){let o=f(t).$index,r=l(2);return b(r.selectAutocompleteItemByClick(o))})("keydown.enter",function(){let o=f(t).$index,r=l(2);return b(r.selectAutocompleteItemByClick(o))})("keydown.space",function(){let o=f(t).$index,r=l(2);return b(r.selectAutocompleteItemByClick(o))})("mouseenter",function(){let o=f(t).$index,r=l(2);return b(r.selectedAutocompleteIndex=o)}),a(1,"div",12),y(2,"span",13),Ee(3,"highlight"),u(4,_i,2,1,"span",14),s(),y(5,"div",15),Ee(6,"highlight"),s()}if(i&2){let t=e.$implicit,n=e.$index,o=l(2);N("selected",n===o.selectedAutocompleteIndex),oe("aria-selected",n===o.selectedAutocompleteIndex),c(2),C("innerHTML",Tt(3,6,o.autocompleteTrigger+t.name,o.getAutocompleteQuery()),z),c(2),g(o.hasParameterFormat(t)?4:-1),c(),C("innerHTML",Tt(6,9,t.description,o.getAutocompleteQuery()),z)}}function yi(i,e){if(i&1&&(a(0,"div",4),H(1,xi,7,12,"div",10,bi),s()),i&2){let t=l();c(),V(t.autocompleteItems)}}function wi(i,e){if(i&1){let t=_();a(0,"ds-icon-button",18),h("action",function(){f(t);let o=l(2);return b(o.onStopClick())}),s()}}function Ti(i,e){if(i&1){let t=_();a(0,"ds-icon-button",19),h("action",function(){f(t);let o=l(2);return b(o.sendMessage())}),s()}if(i&2){let t=l(2);N("hidden",t.isDisabled||!t.message.trim())("active",!!t.message.trim()&&!t.isDisabled),C("title",t.getSendButtonTooltip())("disabled",t.isDisabled||!t.message.trim())}}function Si(i,e){if(i&1){let t=_();a(0,"ds-icon-button",21),h("action",function(){f(t);let o=l(3);return b(o.triggerFileUpload())}),s(),a(1,"input",22,1),h("change",function(o){f(t);let r=l(3);return b(r.onFileInputChange(o))}),s()}if(i&2){let t=l(3);C("disabled",t.isDisabled)}}function Mi(i,e){if(i&1){let t=_();u(0,Si,3,1),a(1,"ds-icon-button",20),h("action",function(){f(t);let o=l(2);return b(o.toggleRecording())}),s()}if(i&2){let t=l(2);g(!t.showWelcome&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?0:-1),c(),N("hidden",t.message.trim()&&!t.isRecording&&!t.isTranscribing),C("variant",t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing)?"danger":"default")("disabled",t.isVoiceMessageMode&&t.isTranscribing)("title",t.isRecording?"Click to stop recording":t.isTranscribing?"Uploading...":"Click to start recording")}}function Ei(i,e){if(i&1&&(a(0,"div",7),u(1,wi,1,0,"ds-icon-button",16),u(2,Ti,1,6,"ds-icon-button",17),u(3,Mi,2,6),s()),i&2){let t=l();c(),g(t.isThinking?1:-1),c(),g((!t.isThinking||t.message.trim())&&!(t.isVoiceMessageMode&&(t.isRecording||t.isTranscribing))?2:-1),c(),g(t.isThinking?-1:3)}}var Ze=class i{isDisabled=!1;showWelcome=!1;isThinking=!1;isStarting=!1;isSessionInitializing=!1;isStopping=!1;filesPasted=new M;messageSubmitted=new M;voiceMessageReady=new M;voiceRecordingToggled=new M;heightChanged=new M;stopRequested=new M;textareaFocused=new M;messageInput;fileInput;message="";isRecording=!1;isTranscribing=!1;isFocused=!1;recognition=null;mediaRecorder=null;audioChunks=[];voiceInputMode="browser";get isVoiceMessageMode(){return this.voiceInputMode==="voice-message"}sessionHadTranscript=!1;pendingLineBreaksTimeout=null;lastProcessedResultIndex=0;useEnterToSend=!1;currentInvite="";subscriptions=[];thinkingPhrases=["Processing request...","Thinking...","Working on it..."];currentThinkingPhrase="Processing request...";thinkingPhraseIndex=0;thinkingInterval=null;autocompleteVisible=!1;autocompleteTrigger=null;autocompleteItems=[];selectedAutocompleteIndex=0;preferencesService=m(se);codayService=m(ce);agentApiService=m(Cn);promptApiService=m(In);projectStateService=m(Q);audioApiService=m(fe);threadStateService=m(X);ngOnInit(){this.initializeVoiceInput(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.subscriptions.push(this.preferencesService.voiceLanguage$.subscribe(()=>this.updateRecognitionLanguage())),this.subscriptions.push(this.preferencesService.voiceInputMode$.subscribe(e=>{this.voiceInputMode=e})),this.subscriptions.push(this.preferencesService.enterToSend$.subscribe(e=>{this.useEnterToSend=e})),this.subscribeToInviteEvents(),this.subscribeToMessageRestore()}ngAfterViewInit(){this.adjustTextareaHeight(),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),200)})}ngOnChanges(e){e.isThinking&&(e.isThinking.currentValue?this.startThinkingAnimation():(this.stopThinkingAnimation(),this.isStopping=!1,e.isThinking.previousValue&&(console.log("[CHAT-TEXTAREA] Thinking ended, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100)})))),e.isSessionInitializing&&!e.isSessionInitializing.currentValue&&e.isSessionInitializing.previousValue&&(console.log("[CHAT-TEXTAREA] Session initialization completed, scheduling focus"),requestAnimationFrame(()=>{setTimeout(()=>this.focusTextarea(),100)})),e.isStarting&&!e.isStarting.currentValue&&e.isStarting.previousValue&&this.isThinking&&(this.thinkingPhraseIndex===0?(console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index 0 - restarting animation"),this.stopThinkingAnimation(),this.startThinkingAnimation()):console.log("[CHAT-TEXTAREA] Transitioning from Starting to Thinking at index",this.thinkingPhraseIndex,"- continuing without restart"))}ngOnDestroy(){this.subscriptions.forEach(e=>e.unsubscribe()),this.subscriptions=[],this.clearPendingLineBreaks(),this.stopThinkingAnimation()}onKeyDown(e){if(this.autocompleteVisible)switch(e.key){case"ArrowDown":e.preventDefault(),this.selectedAutocompleteIndex=Math.min(this.selectedAutocompleteIndex+1,this.autocompleteItems.length-1),this.scrollSelectedItemIntoView();return;case"ArrowUp":e.preventDefault(),this.selectedAutocompleteIndex=Math.max(this.selectedAutocompleteIndex-1,0),this.scrollSelectedItemIntoView();return;case"Tab":case"Enter":if(!this.message.includes(" ")){e.preventDefault(),this.selectAutocompleteItem();return}break;case"Escape":e.preventDefault(),this.hideAutocomplete();return}e.key==="Enter"&&(this.useEnterToSend?!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),this.sendMessage(!0)):(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey)&&!e.shiftKey&&(e.preventDefault(),this.sendMessage(!0)))}onInput(){this.adjustTextareaHeight(),this.checkForAutocomplete()}onPaste(e){let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(r=>r.kind==="file");if(!n.length)return;e.preventDefault();let o=n.reduce((r,d)=>{let v=d.getAsFile();return v?[...r,v]:r},[]);o.length&&this.filesPasted.emit(o)}triggerFileUpload(){console.log("[CHAT-TEXTAREA] Triggering file upload"),this.fileInput?.nativeElement?.click()}onFileInputChange(e){let t=e.target,n=t.files;if(!n||n.length===0){console.log("[CHAT-TEXTAREA] No files selected");return}console.log("[CHAT-TEXTAREA] Files selected:",n.length);let o=Array.from(n);this.filesPasted.emit(o),t.value=""}onDocumentClick(e){if(!this.autocompleteVisible)return;let t=e.target,n=document.querySelector(".autocomplete-popup"),o=this.messageInput?.nativeElement;n&&!n.contains(t)&&o&&!o.contains(t)&&this.hideAutocomplete()}sendMessage(e=!1){let t=this.message.trim();!this.isDisabled&&(e||t)&&(this.isRecording&&this.recognition&&(this.clearPendingLineBreaks(),this.recognition.stop()),this.messageSubmitted.emit(t),this.message="",setTimeout(()=>this.adjustTextareaHeight(),0))}onStopClick(){this.isStopping=!0,this.stopRequested.emit()}toggleRecording(){this.isRecording?this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.stopWhisperRecording():this.stopRecording():this.voiceInputMode==="whisper"||this.voiceInputMode==="voice-message"?this.startWhisperRecording():this.startRecording()}startWhisperRecording(){return P(this,null,function*(){if(!this.isRecording)try{let e=yield navigator.mediaDevices.getUserMedia({audio:!0});this.audioChunks=[],this.mediaRecorder=new MediaRecorder(e),this.mediaRecorder.ondataavailable=t=>{t.data.size>0&&this.audioChunks.push(t.data)},this.mediaRecorder.onstop=()=>{e.getTracks().forEach(t=>t.stop()),this.processWhisperAudio()},this.mediaRecorder.onerror=t=>{console.error("[WHISPER] MediaRecorder error:",t),e.getTracks().forEach(n=>n.stop()),this.isRecording=!1,this.voiceRecordingToggled.emit(!1)},this.mediaRecorder.start(),this.isRecording=!0,this.voiceRecordingToggled.emit(!0),console.log("[WHISPER] Started recording")}catch(e){console.error("[WHISPER] Failed to start recording:",e),this.isRecording=!1,this.voiceRecordingToggled.emit(!1)}})}stopWhisperRecording(){if(!(!this.mediaRecorder||!this.isRecording))try{this.mediaRecorder.stop(),this.isRecording=!1,this.voiceRecordingToggled.emit(!1),console.log("[WHISPER] Stopped recording")}catch(e){console.error("[WHISPER] Failed to stop recording:",e),this.isRecording=!1,this.voiceRecordingToggled.emit(!1)}}processWhisperAudio(){if(this.audioChunks.length===0)return;let e=new Blob(this.audioChunks,{type:this.mediaRecorder?.mimeType||"audio/webm"}),t=e.type.split(";")[0]||"audio/webm";this.audioChunks=[],this.isTranscribing=!0;let n=new FileReader;n.onloadend=()=>{let o=n.result.split(",")[1];if(!o){console.error("[WHISPER] Failed to read audio as base64"),this.isTranscribing=!1;return}let d=this.preferencesService.getVoiceLanguage().split("-")[0];if(this.voiceInputMode==="voice-message"){if(!this.threadStateService.getSelectedThreadId()){console.log("[WHISPER] No thread selected \u2014 emitting voiceMessageReady for thread creation"),this.isTranscribing=!1,this.voiceMessageReady.emit({base64:o,mimeType:t,language:d});return}this.audioApiService.sendVoiceMessage(o,t,d).subscribe({next:v=>{this.isTranscribing=!1,console.log("[WHISPER] Voice message sent, transcription:",v.transcription?.substring(0,50))},error:v=>{console.error("[WHISPER] Voice message error:",v),this.isTranscribing=!1,this.fallbackToTranscription(o,t,d)}})}else this.audioApiService.transcribeAudio(o,t,d).subscribe({next:v=>{this.isTranscribing=!1,v.text&&this.appendToTextarea(v.text+" ")},error:v=>{console.error("[WHISPER] Transcription error:",v),this.isTranscribing=!1}})},n.readAsDataURL(e)}fallbackToTranscription(e,t,n){this.audioApiService.transcribeAudio(e,t,n).subscribe({next:o=>{this.isTranscribing=!1,o.text&&this.appendToTextarea(o.text+" ")},error:o=>{console.error("[WHISPER] Fallback transcription also failed:",o),this.isTranscribing=!1}})}initializeVoiceInput(){let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(console.log("[SPEECH] speechRecognition",e),!e){console.warn("[SPEECH] Speech Recognition API not available");return}this.recognition=new e,this.recognition.continuous=!0,this.recognition.interimResults=!0,this.recognition.maxAlternatives=1,this.recognition.lang=this.getSelectedLanguage();try{"grammars"in this.recognition&&(this.recognition.serviceURI=void 0)}catch(t){console.log("[SPEECH] Advanced speech recognition parameters not supported")}this.recognition.onresult=t=>{let n="",o=Math.max(t.resultIndex,this.lastProcessedResultIndex);for(let r=o;r<t.results.length;r++)t.results[r].isFinal&&(n+=t.results[r][0].transcript,this.lastProcessedResultIndex=r+1);if(n){let r=this.improveTranscriptPunctuation(n.trim());this.sessionHadTranscript=!0,console.log("[SPEECH] onresult ending, appending to textarea",this.isRecording),this.appendToTextarea(r)}},this.recognition.onend=()=>{console.log("[SPEECH] Recognition ended. Was recording:",this.isRecording),this.isRecording=!1,this.lastProcessedResultIndex=0,this.voiceRecordingToggled.emit(this.isRecording)},this.recognition.onerror=t=>{console.error("[SPEECH] Speech recognition error:",t.error),console.log("[SPEECH] Error details:",{error:t.error,message:t.message,timeStamp:t.timeStamp}),this.isRecording=!1,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording)},this.recognition.onstart=()=>{console.log("[SPEECH] Recognition started successfully")},this.recognition.onspeechstart=()=>{console.log("[SPEECH] Speech detected")},this.recognition.onspeechend=()=>{console.log("[SPEECH] Speech ended")}}startRecording(){return P(this,null,function*(){if(!(!this.recognition||this.isRecording))try{this.isRecording=!0,this.sessionHadTranscript=!1,this.lastProcessedResultIndex=0,this.clearPendingLineBreaks(),this.voiceRecordingToggled.emit(this.isRecording),this.recognition.start(),console.log("[SPEECH] Started recording")}catch(e){console.error("[SPEECH] Failed to start recording:",e),this.isRecording=!1,this.voiceRecordingToggled.emit(this.isRecording)}})}stopRecording(){if(!this.recognition||!this.isRecording){console.log("[SPEECH] stopRecording not recording");return}try{console.log("[SPEECH] stopRecording recognition stop"),this.recognition.stop(),this.schedulePendingLineBreaks()}catch(e){console.error("[SPEECH] Failed to stop recording:",e)}}getSelectedLanguage(){return this.preferencesService.getVoiceLanguage()}updateRecognitionLanguage(){if(this.recognition){let e=this.getSelectedLanguage();this.recognition.lang=e,console.log("[SPEECH] Language changed to:",e)}}improveTranscriptPunctuation(e){let t=e;return/[.!?]$/.test(t.trim())||(t=t.trim()+"."),t=t.charAt(0).toUpperCase()+t.slice(1),t=t.replace(/\s+/g," "),t=t+" ",t}appendToTextarea(e){let t=this.message;if(this.message=t?`${t}${e}`:e,this.messageInput?.nativeElement){this.messageInput.nativeElement.focus();let n=this.message.length;this.messageInput.nativeElement.setSelectionRange(n,n)}setTimeout(()=>this.adjustTextareaHeight(),0)}schedulePendingLineBreaks(){this.clearPendingLineBreaks(),this.pendingLineBreaksTimeout=window.setTimeout(()=>{this.sessionHadTranscript&&(console.log("[SPEECH] Adding line breaks after transcript session"),this.appendToTextarea(`
|
|
2
2
|
|
|
3
3
|
`),this.sessionHadTranscript=!1),this.pendingLineBreaksTimeout=null},500)}clearPendingLineBreaks(){this.pendingLineBreaksTimeout&&(clearTimeout(this.pendingLineBreaksTimeout),this.pendingLineBreaksTimeout=null)}adjustTextareaHeight(){let e=this.messageInput?.nativeElement;if(!e)return;let t=e.parentElement?.offsetHeight??e.offsetHeight+32;this.heightChanged.emit(t)}getSendButtonShortcut(){return this.useEnterToSend?"Enter":navigator.platform.toLowerCase().includes("mac")?"\u2318+Enter":"Ctrl+Enter"}getSendButtonTooltip(){return this.useEnterToSend?"Send message (Enter) - Shift+Enter for new line":`Send message (${navigator.platform.toLowerCase().includes("mac")?"Cmd+Enter":"Ctrl+Enter"}) - Enter for new line`}getPlaceholder(){return this.isSessionInitializing?"Initializing session...":this.isThinking?this.isStopping?"Stopping...":this.isStarting?"Processing request...":this.currentThinkingPhrase:this.isVoiceMessageMode&&this.isTranscribing?"Uploading...":this.isVoiceMessageMode&&this.isRecording?"Listening...":this.showWelcome?"How can I help you today?":"Type '@' for agents, '/' for commands, or just your message..."}startThinkingAnimation(){this.thinkingPhraseIndex=0,this.currentThinkingPhrase=this.thinkingPhrases[0]??"Thinking...",this.thinkingInterval=window.setInterval(()=>{this.thinkingPhraseIndex<this.thinkingPhrases.length-1&&(this.thinkingPhraseIndex++,this.currentThinkingPhrase=this.thinkingPhrases[this.thinkingPhraseIndex]??"Thinking...")},2e3)}stopThinkingAnimation(){this.thinkingInterval&&(clearInterval(this.thinkingInterval),this.thinkingInterval=null),this.thinkingPhraseIndex=0,this.currentThinkingPhrase="Thinking..."}subscribeToInviteEvents(){this.subscriptions.push(this.codayService.currentInviteEvent$.subscribe(e=>{e?this.handleInviteEvent(e.invite,e.defaultValue):this.currentInvite=""}))}handleInviteEvent(e,t){this.currentInvite=e,t&&(this.message=t,setTimeout(()=>this.adjustTextareaHeight(),0)),setTimeout(()=>{this.messageInput?.nativeElement&&this.messageInput.nativeElement.focus()},50)}subscribeToMessageRestore(){this.subscriptions.push(this.codayService.messageToRestore$.subscribe(e=>{e.trim()&&(console.log("[CHAT-TEXTAREA] Restoring message content:",e.substring(0,50)+"..."),this.restoreMessageContent(e))}))}restoreMessageContent(e){this.message=e,this.messageInput?.nativeElement&&(this.messageInput.nativeElement.focus(),setTimeout(()=>{let t=this.messageInput.nativeElement,n=this.message.length;t.setSelectionRange(n,n)},0)),setTimeout(()=>this.adjustTextareaHeight(),10)}focusTextarea(){let e=this.messageInput?.nativeElement;console.log("[CHAT-TEXTAREA] focusTextarea called",{hasElement:!!e,isDisabled:this.isDisabled,isThinking:this.isThinking,elementDisabled:e?.disabled,isSessionInitializing:this.isSessionInitializing}),e&&!e.disabled?(e.focus(),console.log("[CHAT-TEXTAREA] Textarea focused successfully")):console.log("[CHAT-TEXTAREA] Focus blocked - element disabled or not available")}checkForAutocomplete(){let e=this.message;if(e.startsWith("@")){let t=e.substring(1);if(t.includes(" ")){this.hideAutocomplete();return}this.showAgentAutocomplete(t);return}if(e.startsWith("/")){let t=e.substring(1);if(t.includes(" ")){this.hideAutocomplete();return}this.showPromptAutocomplete(t);return}this.hideAutocomplete()}showAgentAutocomplete(e){this.autocompleteTrigger="@";try{let t=this.projectStateService.getSelectedProjectIdOrThrow();this.agentApiService.getAgentsAutocomplete(t,e).subscribe({next:n=>{this.autocompleteItems=n,this.autocompleteVisible=n.length>0,this.selectedAutocompleteIndex=0},error:n=>{console.error("[AUTOCOMPLETE] Error loading agents:",n),this.hideAutocomplete()}})}catch(t){console.warn("[AUTOCOMPLETE] No project selected, cannot load agents"),this.hideAutocomplete()}}showPromptAutocomplete(e){this.autocompleteTrigger="/";try{let t=this.projectStateService.getSelectedProjectIdOrThrow();this.promptApiService.getPromptsAutocomplete(t,e).subscribe({next:n=>{this.autocompleteItems=n,this.autocompleteVisible=n.length>0,this.selectedAutocompleteIndex=0},error:n=>{console.error("[AUTOCOMPLETE] Error loading prompts:",n),this.hideAutocomplete()}})}catch(t){console.warn("[AUTOCOMPLETE] No project selected, cannot load prompts"),this.hideAutocomplete()}}hideAutocomplete(){this.autocompleteVisible=!1,this.autocompleteItems=[],this.selectedAutocompleteIndex=0}selectAutocompleteItem(){let e=this.autocompleteItems[this.selectedAutocompleteIndex];if(!e)return;let t=null;if(this.autocompleteTrigger==="/"){let n=e,o=n.parameterFormat;if(console.log(n),o===void 0)this.message=`/${e.name}`;else if(o==="")this.message=`/${e.name} `;else{this.message=`/${e.name} ${o}`;let r=this.message.indexOf('=""');r!==-1&&(t=r+2)}}else this.message=`@${e.name} `;this.hideAutocomplete(),setTimeout(()=>{if(this.messageInput?.nativeElement)if(this.messageInput.nativeElement.focus(),t!==null)this.messageInput.nativeElement.setSelectionRange(t,t);else{let n=this.message.length;this.messageInput.nativeElement.setSelectionRange(n,n)}},0)}selectAutocompleteItemByClick(e){this.selectedAutocompleteIndex=e,this.selectAutocompleteItem()}getAutocompleteQuery(){return this.message.substring(1).split(" ")[0]??""}getParameterFormat(e){return e.parameterFormat}hasParameterFormat(e){return this.autocompleteTrigger==="/"&&e.parameterFormat!==void 0}scrollSelectedItemIntoView(){setTimeout(()=>{let e=document.querySelector(".autocomplete-popup");if(!e)return;let t=e.querySelector(".autocomplete-item.selected");t&&t.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},0)}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=T({type:i,selectors:[["app-chat-textarea"]],viewQuery:function(t,n){if(t&1&&ge(hi,7)(fi,5),t&2){let o;J(o=Z())&&(n.messageInput=o.first),J(o=Z())&&(n.fileInput=o.first)}},hostBindings:function(t,n){t&1&&h("paste",function(r){return n.onPaste(r)})("click",function(r){return n.onDocumentClick(r)},zt)},inputs:{isDisabled:"isDisabled",showWelcome:"showWelcome",isThinking:"isThinking",isStarting:"isStarting",isSessionInitializing:"isSessionInitializing"},outputs:{filesPasted:"filesPasted",messageSubmitted:"messageSubmitted",voiceMessageReady:"voiceMessageReady",voiceRecordingToggled:"voiceRecordingToggled",heightChanged:"heightChanged",stopRequested:"stopRequested",textareaFocused:"textareaFocused"},features:[q],decls:8,vars:15,consts:[["messageInput",""],["fileInput",""],[1,"chat-input-container"],[1,"recording-indicator"],[1,"autocomplete-popup"],[1,"input-row","grouped-input"],[1,"message-input",3,"ngModelChange","keydown","input","focus","blur","ngModel","placeholder","disabled"],[1,"actions"],[1,"recording-dot"],[1,"transcribing-dot"],["role","option","tabindex","0",1,"autocomplete-item",3,"selected"],["role","option","tabindex","0",1,"autocomplete-item",3,"click","keydown.enter","keydown.space","mouseenter"],[1,"item-name"],[3,"innerHTML"],[1,"parameter-format"],[1,"item-description",3,"innerHTML"],["icon","stop","variant","danger","title","Stop generation",1,"action-btn"],["icon","send","variant","primary",1,"send-btn",3,"title","disabled","hidden","active"],["icon","stop","variant","danger","title","Stop generation",1,"action-btn",3,"action"],["icon","send","variant","primary",1,"send-btn",3,"action","title","disabled"],["icon","mic",1,"voice-btn",3,"action","variant","disabled","title"],["icon","attach_file","variant","default","title","Upload files (images or documents)",1,"upload-btn",3,"action","disabled"],["type","file","multiple","","accept","image/*,application/pdf,.pdf,.doc,.docx,.txt,.md,.json,.yaml,.yml,.csv,.xml,.html",2,"display","none",3,"change"]],template:function(t,n){if(t&1){let o=_();a(0,"div",2),u(1,vi,3,0,"div",3),u(2,Ci,3,0,"div",3),u(3,yi,3,0,"div",4),a(4,"div",5)(5,"textarea",6,0),He("ngModelChange",function(d){return f(o),Re(n.message,d)||(n.message=d),b(d)}),h("keydown",function(d){return n.onKeyDown(d)})("input",function(){return n.onInput()})("focus",function(){return f(o),n.isFocused=!0,b(n.textareaFocused.emit())})("blur",function(){return n.isFocused=!1}),s(),u(7,Ei,4,3,"div",7),s()()}t&2&&(c(),g(!n.isVoiceMessageMode&&n.isRecording?1:-1),c(),g(!n.isVoiceMessageMode&&n.isTranscribing?2:-1),c(),g(n.autocompleteVisible?3:-1),c(),N("focused",n.isFocused)("welcome-mode",n.showWelcome)("is-thinking",n.isThinking)("is-listening",n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),c(),Fe("ngModel",n.message),C("placeholder",n.getPlaceholder())("disabled",n.isDisabled||n.isVoiceMessageMode&&(n.isRecording||n.isTranscribing)),c(2),g(n.isSessionInitializing?-1:7))},dependencies:[Ge,We,qe,Ye,On,Je],styles:['@keyframes _ngcontent-%COMP%_gradientBorderShift{0%{background-position:0 0}50%{background-position:100% 0}to{background-position:0 0}}.chat-input-container[_ngcontent-%COMP%]{flex-shrink:0;width:100%;position:relative}.thinking-progress[_ngcontent-%COMP%]{position:absolute;top:0;left:0;right:0;height:3px;z-index:1}.thinking-progress[_ngcontent-%COMP%] .mdc-linear-progress__bar-inner{border-top-width:3px}.input-row.grouped-input[_ngcontent-%COMP%]{display:flex;align-items:stretch;background:var(--glass-bg);border-radius:16px;padding:0 .15rem 0 1.25rem;position:relative;transition:border-color .2s,box-shadow .2s,background .3s}.input-row[_ngcontent-%COMP%]{position:relative;background:var(--glass-bg, #1e1e1e)!important;background-clip:padding-box}.input-row[_ngcontent-%COMP%]:before{content:"";position:absolute;inset:-2px;border-radius:inherit;background-size:200% 100%;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:xor;mask-composite:exclude;padding:1px;pointer-events:none;z-index:-1;animation:_ngcontent-%COMP%_gradientBorderShift 3s ease-in-out infinite}.input-row.is-listening[_ngcontent-%COMP%]:before{inset:0;-webkit-mask:none;mask:none;padding:0;opacity:.15;z-index:0;background:linear-gradient(90deg,var(--color-error, #ef4444) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-error, #ef4444) 100%);background-size:200% 100%;animation:_ngcontent-%COMP%_gradientBorderShift 2s ease-in-out infinite}.input-row.is-listening[_ngcontent-%COMP%] .message-input[_ngcontent-%COMP%], .input-row.is-listening[_ngcontent-%COMP%] .action-btn[_ngcontent-%COMP%]{position:relative;z-index:1}.input-row.is-thinking[_ngcontent-%COMP%]:before{inset:0;-webkit-mask:none;mask:none;padding:0;opacity:.15;z-index:0;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% 100%;animation:_ngcontent-%COMP%_gradientBorderShift 3s ease-in-out infinite}.input-row.is-thinking[_ngcontent-%COMP%] .message-input[_ngcontent-%COMP%], .input-row.is-thinking[_ngcontent-%COMP%] .action-btn[_ngcontent-%COMP%]{position:relative;z-index:1}.input-row.grouped-input.focused[_ngcontent-%COMP%]:not(.is-thinking):before{background:var(--color-primary);animation:none}.input-row.grouped-input.focused[_ngcontent-%COMP%]:not(.is-thinking){box-shadow:0 0 0 4px #007aff1a}.message-input[_ngcontent-%COMP%]{flex:1;border:none;outline:none;background:transparent!important;box-shadow:none;font-size:1rem;padding:1rem 0;color:var(--color-text);resize:none;field-sizing:content;min-height:36px;max-height:70vh;overflow-y:auto;font-family:-apple-system,BlinkMacSystemFont,SF Pro Display,system-ui,sans-serif;line-height:1.5}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar{width:8px}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.message-input[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--color-text-secondary)}.message-input[_ngcontent-%COMP%]:focus{outline:none;border:none;box-shadow:none}.message-input[_ngcontent-%COMP%]:disabled{background-color:var(--color-bg-secondary);color:var(--color-text-secondary);cursor:not-allowed;opacity:.6}.message-input[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary);transition:opacity .3s ease-in-out}.message-input[_ngcontent-%COMP%]:disabled::placeholder{animation:_ngcontent-%COMP%_thinkingPulsate 2s ease-in-out infinite}@keyframes _ngcontent-%COMP%_thinkingPulsate{0%,to{opacity:.6}50%{opacity:1}}.voice-btn[_ngcontent-%COMP%], .send-btn[_ngcontent-%COMP%], .action-btn[_ngcontent-%COMP%], .upload-btn[_ngcontent-%COMP%]{margin:0}.actions[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-wrap:wrap;justify-content:center}.send-btn[_ngcontent-%COMP%]{transition:opacity .4s,margin-left .4s}.send-btn.active[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{opacity:1}.send-btn[_ngcontent-%COMP%]:not(.active) button[_ngcontent-%COMP%]{opacity:0;margin-left:calc(-.5rem - 36px)}.send-btn[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:hover:not(:disabled){color:#fff;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-primary, #3b82f6) 20%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 80%,var(--color-primary, #3b82f6) 100%);background-size:300% auto;animation:sendButtonGradientShift 6s ease-in-out infinite;box-shadow:0 4px 14px #007aff30;transform:scale(1.2)}.send-btn[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:active:not(:disabled){transform:scale(1.3);box-shadow:0 4px 24px #007aff30}.recording-indicator[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin-top:.2rem;margin-bottom:.2rem;color:var(--color-error, #ff5555);font-size:.9rem;position:absolute;top:-1.5rem}@keyframes _ngcontent-%COMP%_pulse{0%,to{opacity:1}50%{opacity:.5}}.autocomplete-popup[_ngcontent-%COMP%]{position:absolute;bottom:100%;left:0;right:0;margin-bottom:.5rem;background:var(--glass-bg);-webkit-backdrop-filter:var(--glass-backdrop-blur);backdrop-filter:var(--glass-backdrop-blur);border-radius:12px;box-shadow:0 8px 32px #00000026;border:1px solid var(--color-border);max-height:400px;max-width:500px;overflow-y:auto;z-index:100}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar{width:8px}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.autocomplete-popup[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--color-text-secondary)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%]{padding:.75rem 1rem;cursor:pointer;transition:background .2s;border-left:3px solid transparent}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%]:hover, .autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item.selected[_ngcontent-%COMP%]{background:var(--color-bg-hover)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item.selected[_ngcontent-%COMP%]{border-left-color:var(--color-primary)}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%]{font-weight:600;color:var(--color-text);margin-bottom:.25rem;font-family:SF Mono,Monaco,Menlo,Cascadia Code,Consolas,monospace;font-size:.95rem}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%] strong{font-weight:700;color:var(--color-primary);background:var(--color-primary-light, rgba(99, 102, 241, .1));padding:0 2px;border-radius:2px}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-name[_ngcontent-%COMP%] .parameter-format[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-weight:400;opacity:.7}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-description[_ngcontent-%COMP%]{font-size:.85rem;color:var(--color-text-secondary);line-height:1.3}.autocomplete-popup[_ngcontent-%COMP%] .autocomplete-item[_ngcontent-%COMP%] .item-description[_ngcontent-%COMP%] strong{font-weight:700;color:var(--color-primary);background:var(--color-primary-light, rgba(99, 102, 241, .1))}@media print{.thinking-progress[_ngcontent-%COMP%], .action-btn[_ngcontent-%COMP%], .voice-btn[_ngcontent-%COMP%], .send-btn[_ngcontent-%COMP%], .upload-btn[_ngcontent-%COMP%], .recording-indicator[_ngcontent-%COMP%], .autocomplete-popup[_ngcontent-%COMP%]{display:none!important}}']})};var be=class i{unreadCountSubject=new Ie(0);unreadCount$=this.unreadCountSubject.asObservable();constructor(){console.log("[UNREAD] Service initialized")}addUnread(){let t=this.unreadCountSubject.value+1;this.unreadCountSubject.next(t),console.log("[UNREAD] Added unread message, total:",t)}markAllAsRead(){this.unreadCountSubject.value>0&&(this.unreadCountSubject.next(0),console.log("[UNREAD] Marked all messages as read"))}getCurrentCount(){return this.unreadCountSubject.value}reset(){this.unreadCountSubject.next(0),console.log("[UNREAD] Counter reset")}static \u0275fac=function(t){return new(t||i)};static \u0275prov=k({token:i,factory:i.\u0275fac,providedIn:"root"})};var et=class i{ATTENTION_EMOJI="\u{1F534}";isSystemActive=!1;systemActiveTimer=null;SYSTEM_ACTIVE_TIMEOUT=4e3;unreadService=m(be);project=m(Q);constructor(){this.initializeTitleUpdates()}initializeTitleUpdates(){At([this.project.selectedProject$,this.unreadService.unreadCount$]).subscribe(([e,t])=>{this.updateTitle(e?.name??"...",t)})}updateTitle(e,t){let n;this.isSystemActive?n=`\u23F3${t>0?` (${t}) `:" "}${e}`:t>0?n=`${this.ATTENTION_EMOJI} (${t}) ${e}`:n=e,document.title=n,console.log("[TAB-TITLE] Updated to:",n)}setSystemActive(){console.log("[TAB-TITLE] System active - showing hourglass"),this.isSystemActive=!0,this.systemActiveTimer&&clearTimeout(this.systemActiveTimer),this.systemActiveTimer=setTimeout(()=>{console.log("[TAB-TITLE] System active timeout - hiding hourglass"),this.isSystemActive=!1,this.forceUpdateTitle()},this.SYSTEM_ACTIVE_TIMEOUT),this.forceUpdateTitle()}setSystemInactive(){console.log("[TAB-TITLE] System inactive - hiding hourglass"),this.isSystemActive=!1,this.systemActiveTimer&&(clearTimeout(this.systemActiveTimer),this.systemActiveTimer=null),this.forceUpdateTitle()}forceUpdateTitle(){let e=this.project.getSelectedProjectId()??"...",t=this.unreadService.getCurrentCount();this.updateTitle(e,t)}static \u0275fac=function(t){return new(t||i)};static \u0275prov=k({token:i,factory:i.\u0275fac,providedIn:"root"})};var tt=class i{pendingFirstMessage=null;pendingVoiceMessage=null;setPendingFirstMessage(e){console.log("[FIRST-MESSAGE-STATE] Storing pending first message:",e.substring(0,50)+"..."),this.pendingFirstMessage=e}consumePendingFirstMessage(){let e=this.pendingFirstMessage;return e?(console.log("[FIRST-MESSAGE-STATE] Consuming pending first message:",e.substring(0,50)+"..."),this.pendingFirstMessage=null):console.log("[FIRST-MESSAGE-STATE] No pending first message to consume"),e}setPendingVoiceMessage(e){console.log("[FIRST-MESSAGE-STATE] Storing pending voice message"),this.pendingVoiceMessage=e}consumePendingVoiceMessage(){let e=this.pendingVoiceMessage;return e&&(console.log("[FIRST-MESSAGE-STATE] Consuming pending voice message"),this.pendingVoiceMessage=null),e}hasPendingFirstMessage(){return this.pendingFirstMessage!==null||this.pendingVoiceMessage!==null}clear(){this.pendingFirstMessage&&(console.log("[FIRST-MESSAGE-STATE] Clearing pending first message"),this.pendingFirstMessage=null),this.pendingVoiceMessage=null}static \u0275fac=function(t){return new(t||i)};static \u0275prov=k({token:i,factory:i.\u0275fac,providedIn:"root"})};var Pi=(i,e)=>e.label;function Oi(i,e){if(i&1){let t=_();a(0,"button",2),h("click",function(o){let r=f(t).$implicit,d=l();return b(d.executeAction(r,o))}),a(1,"mat-icon"),p(2),s()()}if(i&2){let t=e.$implicit;oe("title",t.tooltip||t.label),c(),oe("aria-label",t.label),c(),S(t.icon)}}var nt=class i{actions=[];executeAction(e,t){t.stopPropagation(),e.action()}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=T({type:i,selectors:[["app-message-context-menu"]],inputs:{actions:"actions"},decls:3,vars:0,consts:[[1,"context-menu-wrapper"],["mat-icon-button",""],["mat-icon-button","",3,"click"]],template:function(t,n){t&1&&(a(0,"div",0),H(1,Oi,3,3,"button",1,Pi),s()),t&2&&(c(),V(n.actions))},dependencies:[j,re,R],styles:[".context-menu-wrapper[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center}.context-menu-wrapper[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{transform:scale(.75)}"]})};var K=class i{renderer;constructor(){this.renderer=new yn,this.configureRenderer()}configureRenderer(){let e=this.renderer.link.bind(this.renderer);this.renderer.link=t=>{let n=this.isExternalLink(t.href),o=e(t);if(n){o=o.replace("<a ",'<a target="_blank" rel="noopener noreferrer" ');let r=t.title?`${t.text} - ${t.title} (opens in new tab)`:`${t.text} (opens in new tab)`;o=o.replace("<a ",`<a aria-label="${this.escapeHtml(r)}" `),o=o.replace("</a>",'<span class="external-link-icon" aria-hidden="true">\u2197</span></a>')}return o}}isExternalLink(e){if(!e||e.startsWith("/")||e.startsWith("#")||e.startsWith("?"))return!1;if(e.startsWith("//"))return!0;try{return new URL(e,window.location.href).hostname!==window.location.hostname}catch(t){return!1}}escapeHtml(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,n=>t[n]||n)}parse(e){return P(this,null,function*(){let t=yield wn.parse(e,{renderer:this.renderer,breaks:!0,gfm:!0});return Tn.sanitize(t,{ADD_TAGS:["span"],ADD_ATTR:["aria-hidden","aria-label","target","rel"],ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))/i})})}static \u0275fac=function(t){return new(t||i)};static \u0275prov=k({token:i,factory:i.\u0275fac,providedIn:"root"})};var ki=i=>({"user-message-wrapper":i});function Ii(i,e){if(i&1&&(a(0,"div",5)(1,"div",9),p(2),s()()),i&2){let t=l(2);c(2),he(" ",t.message.speaker," ")}}function Di(i,e){if(i&1&&(a(0,"time",7),p(1),s()),i&2){let t=l(2);c(),S(t.formattedTimestamp)}}function Ai(i,e){if(i&1&&(a(0,"div",8),y(1,"app-message-context-menu",10),s()),i&2){let t=l(2);c(),C("actions",t.actions)}}function Fi(i,e){if(i&1&&(u(0,Ii,3,1,"div",5),y(1,"div",6),u(2,Di,2,1,"time",7),u(3,Ai,2,1,"div",8)),i&2){let t=l();g(t.shouldShowSpeaker?0:-1),c(),C("innerHTML",t.renderedContent,z),c(),g(t.formattedTimestamp?2:-1),c(),g(t.isLongMessage&&t.shouldShowActions&&t.message.role==="assistant"?3:-1)}}function Ri(i,e){if(i&1&&(a(0,"a",12),p(1,"view"),s()),i&2){let t=l(2);C("href",t.eventLink,Lt)}}function Hi(i,e){if(i&1&&(a(0,"div",2),y(1,"span",11),u(2,Ri,2,1,"a",12),s()),i&2){let t=l();c(),C("innerHTML",t.renderedContent,z),c(),g(t.eventLink?2:-1)}}function Vi(i,e){if(i&1&&(a(0,"div",3),y(1,"app-message-context-menu",10),s()),i&2){let t=l();c(),C("actions",t.actions)}}function Li(i,e){if(i&1&&(a(0,"div",4),y(1,"app-message-context-menu",10),s()),i&2){let t=l();c(),C("actions",t.actions)}}var ve=class i{destroy$=new B;message;canDelete=!0;isOtherUser=!1;copyRequested=new M;deleteRequested=new M;renderedContent="";shouldHideTechnical=!1;shouldHideWarning=!1;sanitizer=m(G);notificationService=m(xn);preferencesService=m(se);projectState=m(Q);threadState=m(X);markdownService=m(K);get messageClasses(){return{[this.message.role]:!0,[this.message.type]:!0,"hidden-technical":this.shouldHideTechnical&&this.message.type==="technical","hidden-warning":this.shouldHideWarning&&this.message.type==="warning","other-user":this.isOtherUser}}ngOnInit(){return P(this,null,function*(){yield this.renderMarkdown(),this.preferencesService.hideTechnicalMessages$.pipe(F(this.destroy$)).subscribe(e=>{this.shouldHideTechnical=e}),this.preferencesService.hideWarningMessages$.pipe(F(this.destroy$)).subscribe(e=>{this.shouldHideWarning=e}),this.shouldHideTechnical=this.preferencesService.getHideTechnicalMessages(),this.shouldHideWarning=this.preferencesService.getHideWarningMessages()})}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}get shouldShowSpeaker(){return this.message.role==="user"?this.isOtherUser||this.message.speaker.startsWith("@"):this.message.role==="assistant"}get shouldShowActions(){return this.message.role==="user"||this.message.role==="assistant"}get isSimplified(){return this.message.role!=="user"&&this.message.role!=="assistant"}datePipe=m(St);get formattedTimestamp(){if(this.message.role!=="user"||!this.message.timestamp)return null;let e=new Date().toDateString()===this.message.timestamp.toDateString();return this.datePipe.transform(this.message.timestamp,e?"HH:mm":"dd/MM HH:mm")}get isLongMessage(){let e=this.extractTextContent();return e.length>1e3||e.split(`
|
|
4
4
|
`).length>20}get actions(){let e=[];return this.message.role==="user"&&this.canDelete&&e.push({icon:"delete",label:"Delete from here",tooltip:"Delete this message and all following messages",action:()=>this.onDelete(),destructive:!0}),e.push({icon:"content_copy",label:"Copy message",tooltip:"Copy message content to clipboard",action:()=>this.onCopy()}),e}get eventLink(){if(!this.message.eventId)return null;let e=this.projectState.getSelectedProjectId(),t=this.threadState.getSelectedThreadId();return!e||!t?null:`/api/projects/${e}/threads/${t}/messages/${encodeURIComponent(this.message.eventId)}/formatted`}renderMarkdown(){return P(this,null,function*(){try{let e=yield this.renderRichContent(this.message.content);this.renderedContent=this.sanitizer.bypassSecurityTrustHtml(e)}catch(e){console.error("Error parsing rich content:",e);let t=this.extractTextContent();this.renderedContent=this.sanitizer.bypassSecurityTrustHtml(t)}})}renderRichContent(e){return P(this,null,function*(){let t=[];for(let n of e)if(n.type==="text"){let o=yield this.markdownService.parse(n.content);t.push(`<div class="text-part">${o}</div>`)}else if(n.type==="image"){let o=`data:${n.mimeType};base64,${n.content}`,r=n.source||"Image",d=`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as G}from"./chunk-AIC4U2MU.js";import{a as V}from"./chunk-KP4KMDLX.js";import{a as B}from"./chunk-
|
|
1
|
+
import{a as G}from"./chunk-AIC4U2MU.js";import{a as V}from"./chunk-KP4KMDLX.js";import{a as B}from"./chunk-7FKWFZ3A.js";import{a as K}from"./chunk-GPZP3WYQ.js";import"./chunk-U5L2OULZ.js";import"./chunk-2BN4B3OL.js";import"./chunk-W7ZS65Y4.js";import{a as D,c as $}from"./chunk-P4GNUQZT.js";import{r as P,x as L}from"./chunk-K7JRH3HO.js";import"./chunk-EBAEYY2S.js";import"./chunk-BZ7URUNM.js";import{a as c}from"./chunk-SKBT6DBT.js";import"./chunk-GF3EMWCA.js";import"./chunk-Z6RFJ6L3.js";import"./chunk-OPSHMM4H.js";import{Bb as A,Db as g,Fb as s,Jc as N,Ka as C,Pb as x,S as y,Tb as E,Ub as w,Wa as v,ab as R,bc as O,ca as r,ec as M,fc as T,ga as l,ha as m,ic as q,lb as b,m as _,ma as I,mb as S,rb as f,sb as p,t as u,ta as h,tb as d}from"./chunk-5NLXR4MK.js";var z=()=>[];function W(o,e){if(o&1&&(p(0,"p",3),E(1),d()),o&2){let t=s().$implicit;C(),w(t.name)}}function U(o,e){if(o&1){let t=A();p(0,"agentos-integration-config-item",5),g("editRequested",function(){let i=l(t),a=s(2);return m(a.onEdit(i))})("deleteRequested",function(){let i=l(t),a=s(2);return m(a.onDelete(i))})("duplicateRequested",function(){let i=l(t),a=s(2);return m(a.onDuplicate(i))}),d()}if(o&2){let t=e,n=s(2);f("config",t.config)("scope",t.scope)("readOnly",t.scope==="platform"||t.scope==="namespace"&&!n.isAdmin())}}function X(o,e){if(o&1&&b(0,W,2,1,"p",3)(1,U,1,3,"agentos-integration-config-item",4),o&2){let t,n=e.$implicit,i=s();S(i.isEmptyPlaceholder(n.id)?0:(t=i.resolve(n.id))?1:-1,t)}}var k=Object.freeze({platform:"Configurations plateforme",namespace:"Configurations du namespace",userOnNs:"Mes overrides sur ce namespace",userGlobal:"Mes overrides globaux"}),F="__empty__",j=class o{route=r(D);router=r($);destroyRef=r(I);state=r(V);namespaceRole=r(K);namespaceId=this.route.snapshot.params.namespaceId;isAdmin=h(!1);listItems$=this.state.vm$.pipe(u(e=>this.toListItems(e)));resolved=new Map;ngOnInit(){this.route.paramMap.pipe(c(this.destroyRef)).subscribe(e=>{let t=e.get("namespaceId")??"";t&&t!==this.namespaceId&&(this.namespaceId=t),this.state.setNamespace(t)}),this.route.paramMap.pipe(u(e=>e.get("namespaceId")??""),y(e=>e?this.namespaceRole.isAdminOfNamespace$(e):_(!1)),c(this.destroyRef)).subscribe(e=>this.isAdmin.set(e)),this.state.vm$.pipe(c(this.destroyRef)).subscribe(e=>{let t=new Map;e.platform.forEach(n=>{n.id&&t.set(this.itemKey("platform",n.id),{config:n,scope:"platform"})}),e.namespace.forEach(n=>{n.id&&t.set(this.itemKey("namespace",n.id),{config:n,scope:"namespace"})}),e.userOnNs.forEach(n=>{n.id&&t.set(this.itemKey("userOnNs",n.id),{config:n,scope:"userOnNs"})}),e.userGlobal.forEach(n=>{n.id&&t.set(this.itemKey("userGlobal",n.id),{config:n,scope:"userGlobal"})}),this.resolved=t})}isEmptyPlaceholder(e){return e.startsWith(F)}resolve(e){return this.resolved.get(e)??null}itemKey(e,t){return`${e}:${t}`}goBack(){this.router.navigate(["/agentos","namespaces"])}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"integrations","new"],{queryParams:{scope:G(this.isAdmin())}})}onEdit(e){let t=e.config.id??"";this.router.navigate(["/agentos",this.namespaceId,"integrations",t,"edit"],{queryParams:{scope:e.scope}})}onDelete(e){let t=e.config.id;t&&this.state.delete(t,e.scope).pipe(c(this.destroyRef)).subscribe({error:n=>{console.error(`[IntegrationsAllScopes] Delete failed for ${e.scope}:${t}:`,n)}})}onDuplicate(e){if(!e.config.id)return;let n=(e.scope==="namespace"||e.scope==="platform")&&!this.isAdmin()?"userOnNs":e.scope;this.router.navigate(["/agentos",this.namespaceId,"integrations","new"],{queryParams:{scope:n,template:e.config.id,templateScope:e.scope}})}toListItems(e){let t=[];return t.push(...this.sectionItems("platform",e.platform)),t.push(...this.sectionItems("namespace",e.namespace)),t.push(...this.sectionItems("userOnNs",e.userOnNs)),t.push(...this.sectionItems("userGlobal",e.userGlobal)),t}sectionItems(e,t){return t.length===0?[{id:`${F}${e}`,name:"Aucune configuration",groupKey:e,groupLabel:k[e]}]:t.filter(n=>!!n.id).map(n=>({id:this.itemKey(e,n.id),name:n.name,description:n.integrationType,groupKey:e,groupLabel:k[e]}))}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=v({type:o,selectors:[["agentos-integrations-all-scopes"]],decls:5,vars:6,consts:[["integrationItemTpl",""],["title","Integrations","emptyMessage","No integrations available.","cardMinWidth","400px",3,"createRequested","items","showCreate","itemTemplate"],["toolbar-start","","icon","arrow_back","title","Back",3,"action"],[1,"integrations-all-scopes__empty"],[3,"config","scope","readOnly"],[3,"editRequested","deleteRequested","duplicateRequested","config","scope","readOnly"]],template:function(t,n){if(t&1&&(p(0,"ds-entity-list",1),M(1,"async"),g("createRequested",function(){return n.openCreateForm()}),p(2,"ds-icon-button",2),g("action",function(){return n.goBack()}),d()(),R(3,X,2,1,"ng-template",null,0,q)),t&2){let i=x(4);f("items",T(1,3,n.listItems$)??O(5,z))("showCreate",!0)("itemTemplate",i)}},dependencies:[L,B,P,N],styles:[".integrations-all-scopes__empty[_ngcontent-%COMP%]{margin:0;padding:.65rem 1rem;font-size:.85rem;font-style:italic;color:var(--color-text-secondary)}"],changeDetection:0})};export{j as IntegrationsAllScopesComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as L}from"./chunk-
|
|
1
|
+
import{a as L}from"./chunk-C3TALDAV.js";import{a as D}from"./chunk-O37JOBGG.js";import"./chunk-W7ZS65Y4.js";import{a as E,c as $}from"./chunk-P4GNUQZT.js";import{x as O}from"./chunk-K7JRH3HO.js";import"./chunk-EBAEYY2S.js";import"./chunk-BZ7URUNM.js";import{a as l}from"./chunk-SKBT6DBT.js";import"./chunk-GF3EMWCA.js";import"./chunk-Z6RFJ6L3.js";import"./chunk-OPSHMM4H.js";import{Bb as x,D as y,Db as m,Fb as a,Jc as T,Pb as N,S as P,Tb as w,Wa as b,ab as v,bc as M,ca as p,ec as B,fc as S,ga as g,ha as h,i as d,ic as k,lb as I,m as u,ma as C,mb as R,rb as s,sb as i,t as f,tb as c,z as _}from"./chunk-5NLXR4MK.js";var F=()=>[];function U(r,t){if(r&1){let o=x();i(0,"agentos-prompt-item",4),m("deleteRequested",function(n){g(o);let A=a(2);return h(A.deletePrompt(n))}),c()}if(r&2){let o=a().$implicit,e=a();s("prompt",t)("namespaceId",e.namespaceId)("readOnly",e.isPlatformPrompt(o.id))}}function V(r,t){if(r&1&&I(0,U,1,3,"agentos-prompt-item",3),r&2){let o,e=t.$implicit,n=a();R((o=n.resolvePrompt(e.id))?0:-1,o)}}var j="platform",G="namespace",q=class r{route=p(E);router=p($);destroyRef=p(C);promptState=p(D);namespaceId=this.route.snapshot.params.namespaceId;refresh$=new d(void 0);allPrompts$=this.refresh$.pipe(P(()=>_({platform:this.promptState.listPlatform().pipe(y(()=>u([]))),namespace:this.promptState.listByNamespace(this.namespaceId)})));promptItems$=this.allPrompts$.pipe(f(({platform:t,namespace:o})=>[...t.map(e=>({id:e.id??"",name:e.name,description:e.description,groupKey:j,groupLabel:"Platform (read-only)"})),...o.map(e=>({id:e.id??"",name:e.name,description:e.description,groupKey:G,groupLabel:"Namespace"}))]));namespacePromptsById=new Map;platformPromptsById=new Map;constructor(){this.allPrompts$.pipe(l(this.destroyRef)).subscribe(({platform:t,namespace:o})=>{this.platformPromptsById=new Map(t.map(e=>[e.id??"",e])),this.namespacePromptsById=new Map(o.map(e=>[e.id??"",e]))})}goBack(){this.router.navigate(["/agentos","namespaces"])}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"prompts","new"])}deletePrompt(t){this.promptState.delete(t.id??"").pipe(l(this.destroyRef)).subscribe(()=>this.refresh$.next())}resolvePrompt(t){return this.platformPromptsById.get(t)??this.namespacePromptsById.get(t)??null}isPlatformPrompt(t){return this.platformPromptsById.has(t)}static \u0275fac=function(o){return new(o||r)};static \u0275cmp=b({type:r,selectors:[["agentos-namespace-prompts"]],decls:6,vars:6,consts:[["promptItemTpl",""],["title","Prompts","emptyMessage","No prompts defined yet. Add one above.","cardMinWidth","400px",3,"createRequested","items","showCreate","itemTemplate"],["toolbar-start","","type","button",1,"namespace-prompts__back",3,"click"],[3,"prompt","namespaceId","readOnly"],[3,"deleteRequested","prompt","namespaceId","readOnly"]],template:function(o,e){if(o&1&&(i(0,"ds-entity-list",1),B(1,"async"),m("createRequested",function(){return e.openCreateForm()}),i(2,"button",2),m("click",function(){return e.goBack()}),w(3,"\u2190 Namespaces"),c()(),v(4,V,1,1,"ng-template",null,0,k)),o&2){let n=N(5);s("items",S(1,3,e.promptItems$)??M(5,F))("showCreate",!0)("itemTemplate",n)}},dependencies:[O,L,T],styles:[".namespace-prompts__back[_ngcontent-%COMP%]{background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-primary, #007aff);font-family:inherit}.namespace-prompts__back[_ngcontent-%COMP%]:hover{text-decoration:underline}"],changeDetection:0})};export{q as NamespacePromptsComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as I}from"./chunk-
|
|
1
|
+
import{r as I}from"./chunk-K7JRH3HO.js";import{Bb as p,Db as d,Fb as c,Ka as r,Tb as s,Ub as C,Vb as w,Wa as x,ga as l,ha as g,jb as y,lb as u,lc as h,mb as b,oc as f,pc as _,sb as n,ta as v,tb as i}from"./chunk-5NLXR4MK.js";function O(o,m){if(o&1){let e=p();n(0,"span",7),s(1,"Delete?"),i(),n(2,"ds-icon-button",8),d("action",function(){l(e);let a=c();return g(a.onDeleteConfirmed())}),i(),n(3,"ds-icon-button",9),d("action",function(){l(e);let a=c();return g(a.onDeleteCancelled())}),i()}}function M(o,m){if(o&1){let e=p();n(0,"ds-icon-button",11),d("action",function(){l(e);let a=c(2);return g(a.onEdit())}),i(),n(1,"ds-icon-button",12),d("action",function(){l(e);let a=c(2);return g(a.onDeleteArmed())}),i()}}function S(o,m){if(o&1){let e=p();n(0,"ds-icon-button",10),d("action",function(){l(e);let a=c();return g(a.onDuplicate())}),i(),u(1,M,2,0)}if(o&2){let e=c();r(),b(e.readOnly()?-1:1)}}var P=Object.freeze({platform:{label:"PLATFORM",ariaLabel:"Configuration partag\xE9e plateforme",variant:"neutral"},namespace:{label:"NS",ariaLabel:"Configuration partag\xE9e du namespace",variant:"neutral"},userOnNs:{label:"USER \xD7 NS",ariaLabel:"Configuration utilisateur sur ce namespace",variant:"info"},userGlobal:{label:"USER GLOBAL",ariaLabel:"Configuration utilisateur globale",variant:"warning"}}),D=class o{config=_.required();scope=_.required();readOnly=_(!1);editRequested=f();deleteRequested=f();duplicateRequested=f();pendingDelete=v(!1);badge=h(()=>P[this.scope()]);onEdit(){this.editRequested.emit(this.config())}onDuplicate(){this.duplicateRequested.emit(this.config())}onDeleteArmed(){this.pendingDelete.set(!0)}onDeleteConfirmed(){this.pendingDelete.set(!1),this.deleteRequested.emit(this.config())}onDeleteCancelled(){this.pendingDelete.set(!1)}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=x({type:o,selectors:[["agentos-integration-config-item"]],inputs:{config:[1,"config"],scope:[1,"scope"],readOnly:[1,"readOnly"]},outputs:{editRequested:"editRequested",deleteRequested:"deleteRequested",duplicateRequested:"duplicateRequested"},decls:12,vars:6,consts:[["role","listitem",1,"integration-config-item"],[1,"integration-config-item__body"],[1,"integration-config-item__heading"],[1,"integration-config-item__name"],[1,"integration-config-item__badge"],[1,"integration-config-item__type"],[1,"integration-config-item__actions"],[1,"integration-config-item__confirm-label"],["icon","check","variant","danger","title","Confirm deletion",3,"action"],["icon","close","title","Cancel deletion",3,"action"],["icon","content_copy","title","Duplicate this configuration",3,"action"],["icon","edit","title","Edit integration",3,"action"],["icon","delete","variant","danger","title","Delete integration",3,"action"]],template:function(e,t){e&1&&(n(0,"div",0)(1,"div",1)(2,"div",2)(3,"span",3),s(4),i(),n(5,"span",4),s(6),i()(),n(7,"span",5),s(8),i()(),n(9,"div",6),u(10,O,4,0)(11,S,2,1),i()()),e&2&&(r(4),C(t.config().name),r(),y("data-variant",t.badge().variant)("aria-label",t.badge().ariaLabel),r(),w(" ",t.badge().label," "),r(2),C(t.config().integrationType),r(2),b(t.pendingDelete()?10:11))},dependencies:[I],styles:[".integration-config-item[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;padding:.75rem 1rem;border-radius:10px;border:1px solid var(--color-border);background:var(--glass-bg);-webkit-backdrop-filter:var(--glass-backdrop-blur);backdrop-filter:var(--glass-backdrop-blur);transition:background .15s ease,border-color .15s ease}.integration-config-item[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover);border-color:var(--color-primary)}.integration-config-item__body[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column;gap:.2rem;min-width:0}.integration-config-item__heading[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;min-width:0}.integration-config-item__name[_ngcontent-%COMP%]{font-size:.95rem;font-weight:500;color:var(--color-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;min-width:0}.integration-config-item__badge[_ngcontent-%COMP%]{flex-shrink:0;font-size:.65rem;font-weight:600;letter-spacing:.04em;padding:.15rem .5rem;border-radius:999px;border:1px solid transparent;text-transform:uppercase;white-space:nowrap}.integration-config-item__badge[data-variant=neutral][_ngcontent-%COMP%]{background:var(--color-bg-secondary);color:var(--color-text-secondary);border-color:var(--color-border)}.integration-config-item__badge[data-variant=info][_ngcontent-%COMP%]{background:color-mix(in srgb,var(--color-info) 12%,transparent);color:var(--color-info);border-color:color-mix(in srgb,var(--color-info) 30%,transparent)}.integration-config-item__badge[data-variant=warning][_ngcontent-%COMP%]{background:color-mix(in srgb,var(--color-warning) 12%,transparent);color:var(--color-warning);border-color:color-mix(in srgb,var(--color-warning) 30%,transparent)}.integration-config-item__type[_ngcontent-%COMP%]{font-size:.78rem;color:var(--color-text-secondary);font-family:monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.integration-config-item__actions[_ngcontent-%COMP%]{flex-shrink:0;display:flex;align-items:center;gap:.125rem;opacity:0;transition:opacity .15s ease}.integration-config-item[_ngcontent-%COMP%]:hover .integration-config-item__actions[_ngcontent-%COMP%], .integration-config-item[_ngcontent-%COMP%]:focus-within .integration-config-item__actions[_ngcontent-%COMP%]{opacity:1}.integration-config-item__confirm-label[_ngcontent-%COMP%]{font-size:.8rem;font-weight:500;color:var(--color-error);margin-right:.25rem;white-space:nowrap}"],changeDetection:0})};export{D as a};
|