@whoz-oss/coday-client 0.224.2 → 0.225.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-SDAXOB46.js → chunk-2HCJBDRI.js} +1 -1
- package/browser/{chunk-AEGHERYH.js → chunk-3SKJ5SNK.js} +1 -1
- package/browser/{chunk-L2CXQ5ZG.js → chunk-3XRWFLI7.js} +1 -1
- package/browser/{chunk-CUMGGWQ7.js → chunk-CC2JFA5X.js} +1 -1
- package/browser/{chunk-I2FVKUBH.js → chunk-IFHVRSTC.js} +1 -1
- package/browser/{chunk-O7ZDJZQW.js → chunk-KGJBI3SN.js} +1 -1
- package/browser/{chunk-6QV7QLHP.js → chunk-VFKWKYIG.js} +1 -1
- package/browser/{chunk-X7WD62KI.js → chunk-Y3VADJFG.js} +1 -1
- package/browser/index.html +1 -1
- package/browser/{main-JHUIVPZ4.js → main-TMN4EWBV.js} +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as re,b as ie,c as V}from"./chunk-N4H6RBJP.js";import{a as oe}from"./chunk-X7WD62KI.js";import{a as Q,b as X,e as ne}from"./chunk-L2CXQ5ZG.js";import{a as G,b as C,c as B,h as Z,s as ee,x as te}from"./chunk-AEGHERYH.js";import{c as K}from"./chunk-MZT6I3S3.js";import"./chunk-WUU4G5YQ.js";import"./chunk-DVUB4DDV.js";import"./chunk-MWPKXBXJ.js";import"./chunk-OX7PDXEA.js";import"./chunk-7EDSHFWH.js";import{a as _,c as f}from"./chunk-3ZLLFAXF.js";import{a as H,b as W}from"./chunk-Q2M4W42M.js";import"./chunk-DDWYQORF.js";import{a as Y,b as M}from"./chunk-JF3TWRKD.js";import{Q as U,S as J}from"./chunk-B46LXCLF.js";import{Bb as S,Db as h,Fb as l,Ka as p,Rb as j,T as L,Tb as c,Ub as k,Vb as z,Wa as N,Z as w,ca as d,ga as u,h as A,ha as g,jb as E,lb as b,ma as $,mb as y,mc as v,pb as x,qb as T,rb as P,sb as a,t as I,ta as O,tb as s,ub as D}from"./chunk-KJ5SIUGY.js";var R=class n{threadState=d(C);codayService=d(ne);threadList=f(this.threadState.threadList$,{initialValue:[]});selectedThread=f(this.threadState.selectedThread$,{initialValue:null});isThinking=f(this.codayService.isThinking$,{initialValue:!1});inviteEvent=f(this.codayService.currentInviteEvent$.pipe(I(t=>t?.invite===Z?null:t)),{initialValue:null});tasks=v(()=>{let t=this.threadList(),e=this.selectedThread(),r=this.isThinking(),o=this.inviteEvent();return t.filter(i=>!i.parentThreadId).map(i=>{let m=!!e&&i.id===e.id;return{id:i.id,name:i.name,summary:i.summary,modifiedDate:i.modifiedDate,starring:i.starring??[],users:i.users??[],status:this.deriveStatus(i,m,r,!!o),isActive:m,worktreeProject:i.worktreeProject}}).sort((i,m)=>{let q=V[i.status]-V[m.status];return q!==0?q:i.modifiedDate>m.modifiedDate?-1:1})});deriveStatus(t,e,r,o){let i=Date.now()-new Date(t.modifiedDate).getTime();return t.closedByUser?"done":t.pendingInvite?"waiting-you":e?r?"in-progress":"paused":i<ie?"in-progress":"paused"}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var F=class n{projectState=d(M);threadState=d(C);destroy$=new A;eventSource=null;currentProject=null;constructor(){this.projectState.selectedProject$.pipe(L(this.destroy$)).subscribe(t=>{let e=t?.name??null;e!==this.currentProject&&(this.disconnect(),e&&this.connect(e))})}connect(t,e=5e3){this.currentProject=t;let r=`/api/projects/${encodeURIComponent(t)}/event-stream`;console.log(`[PROJECT_SSE] Connecting to ${r}`),this.eventSource=new EventSource(r),this.eventSource.onmessage=o=>{try{let i=JSON.parse(o.data),m=te(i);if(!m)return;m instanceof ee&&(console.log("[PROJECT_SSE] ThreadUpdateEvent \u2014 refreshing thread list"),this.threadState.refreshThreadList())}catch(i){console.warn("[PROJECT_SSE] Failed to parse event:",i)}},this.eventSource.onerror=()=>{this.eventSource?.readyState===EventSource.CLOSED&&(console.warn(`[PROJECT_SSE] Connection closed for ${t}, reconnecting in ${e}ms`),this.eventSource=null,setTimeout(()=>{this.currentProject===t&&this.connect(t,Math.min(e*2,6e4))},e))}}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null,console.log(`[PROJECT_SSE] Disconnected from project ${this.currentProject}`)),this.currentProject=null}ngOnDestroy(){this.disconnect(),this.destroy$.next(),this.destroy$.complete()}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var ce=(n,t)=>t.key,de=(n,t)=>t.status,le=(n,t)=>t.id;function pe(n,t){n&1&&D(0,"mat-spinner",6)}function me(n,t){n&1&&(a(0,"mat-icon"),c(1,"add"),s())}function ue(n,t){if(n&1&&(a(0,"span",16),c(1),s()),n&2){let e=l().$implicit,r=l();p(),k(r.filterCounts()[e.key])}}function ge(n,t){if(n&1){let e=S();a(0,"button",15),h("click",function(){let o=u(e).$implicit,i=l();return g(i.setFilter(o.key))}),a(1,"mat-icon",10),c(2),s(),a(3,"span"),c(4),s(),b(5,ue,2,1,"span",16),s()}if(n&2){let e=t.$implicit,r=l();j("active",r.activeFilter()===e.key),E("aria-selected",r.activeFilter()===e.key),p(2),k(e.icon),p(2),k(e.label),p(),y(r.filterCounts()[e.key]>0?5:-1)}}function _e(n,t){n&1&&(a(0,"div",12),D(1,"mat-spinner",17),a(2,"p"),c(3,"Loading tasks\u2026"),s()())}function fe(n,t){if(n&1){let e=S();a(0,"p"),c(1,"No tasks yet. Start your first one!"),s(),a(2,"button",19),h("click",function(){u(e);let o=l(2);return g(o.createTask())}),a(3,"mat-icon"),c(4,"add"),s(),c(5," New Task "),s()}}function he(n,t){n&1&&(a(0,"p"),c(1,"No tasks in this category."),s())}function ke(n,t){if(n&1&&(a(0,"div",13)(1,"mat-icon",18),c(2,"rocket_launch"),s(),b(3,fe,6,0)(4,he,2,0,"p"),s()),n&2){let e=l();p(3),y(e.activeFilter()==="all"?3:4)}}function ve(n,t){if(n&1){let e=S();a(0,"app-task-card",25),h("stopRequested",function(o){u(e);let i=l(3);return g(i.onStopRequested(o))})("deleteRequested",function(o){u(e);let i=l(3);return g(i.onDeleteRequested(o))})("starToggled",function(o){u(e);let i=l(3);return g(i.onStarToggled(o))})("markDoneRequested",function(o){u(e);let i=l(3);return g(i.onMarkDoneRequested(o))})("markActiveRequested",function(o){u(e);let i=l(3);return g(i.onMarkActiveRequested(o))}),s()}if(n&2){let e=t.$implicit;P("task",e)}}function Ce(n,t){if(n&1&&(a(0,"section",20)(1,"h2",21)(2,"mat-icon",22),c(3),s(),c(4),a(5,"span",23),c(6),s()(),a(7,"div",14),x(8,ve,1,1,"app-task-card",24,le),s()()),n&2){let e=t.$implicit;p(3),k(e.icon),p(),z(" ",e.label," "),p(2),k(e.tasks.length),p(2),T(e.tasks)}}function be(n,t){if(n&1&&x(0,Ce,10,3,"section",20,de),n&2){let e=l();T(e.taskGroups())}}function ye(n,t){if(n&1){let e=S();a(0,"app-task-card",25),h("stopRequested",function(o){u(e);let i=l(2);return g(i.onStopRequested(o))})("deleteRequested",function(o){u(e);let i=l(2);return g(i.onDeleteRequested(o))})("starToggled",function(o){u(e);let i=l(2);return g(i.onStarToggled(o))})("markDoneRequested",function(o){u(e);let i=l(2);return g(i.onMarkDoneRequested(o))})("markActiveRequested",function(o){u(e);let i=l(2);return g(i.onMarkActiveRequested(o))}),s()}if(n&2){let e=t.$implicit;P("task",e)}}function xe(n,t){if(n&1&&(a(0,"div",14),x(1,ye,1,1,"app-task-card",24,le),s()),n&2){let e=l();p(),T(e.filteredTasks())}}var Te=[{key:"all",label:"All",icon:"grid_view"},{key:"waiting-you",label:"Waiting for you",icon:"mark_unread_chat_alt"},{key:"in-progress",label:"In progress",icon:"pending"},{key:"paused",label:"Paused",icon:"pause_circle"},{key:"done",label:"Done",icon:"check_circle"}],se=class n{router=d(K);projectState=d(M);threadState=d(C);threadApi=d(G);taskStatus=d(R);userService=d(B);projectApi=d(Y);destroyRef=d($);_projectEventStream=d(F);filters=Te;activeFilter=O("all");starredOnly=O(!1);isCreating=O(!1);isLoadingList=f(this.threadState.isLoadingThreadList$,{initialValue:!1});username=f(this.userService.username$,{initialValue:null});allTasks=this.taskStatus.tasks;filteredTasks=v(()=>{let t=this.activeFilter(),e=this.username(),r=this.allTasks();return this.starredOnly()&&e&&(r=r.filter(o=>o.starring.includes(e))),t==="all"?r:r.filter(o=>o.status===t)});filterCounts=v(()=>{let t=this.username(),e=this.allTasks();return this.starredOnly()&&t&&(e=e.filter(r=>r.starring.includes(t))),{all:e.length,"waiting-you":e.filter(r=>r.status==="waiting-you").length,"in-progress":e.filter(r=>r.status==="in-progress").length,paused:e.filter(r=>r.status==="paused").length,done:e.filter(r=>r.status==="done").length}});taskGroups=v(()=>{let t=this.username(),e=this.allTasks();this.starredOnly()&&t&&(e=e.filter(o=>o.starring.includes(t)));let r=[{status:"waiting-you",label:"Waiting for you",icon:"mark_unread_chat_alt",tasks:[]},{status:"in-progress",label:"In progress",icon:"pending",tasks:[]},{status:"done",label:"Done",icon:"check_circle",tasks:[]},{status:"paused",label:"Paused",icon:"pause_circle",tasks:[]},{status:"error",label:"Error",icon:"error",tasks:[]}];for(let o of e){let i=r.find(m=>m.status===o.status);i&&i.tasks.push(o)}return r.filter(o=>o.tasks.length>0)});ngOnInit(){this.userService.fetchCurrentUser().pipe(_(this.destroyRef)).subscribe({error:t=>console.warn("[TASK-CONTROL] Could not fetch user:",t)})}setFilter(t){this.activeFilter.set(t)}toggleStarredFilter(){this.starredOnly.update(t=>!t)}createTask(){let t=this.projectState.getSelectedProjectId();!t||this.isCreating()||(this.isCreating.set(!0),this.threadApi.createThread().pipe(_(this.destroyRef)).subscribe({next:e=>{this.isCreating.set(!1),this.router.navigate(["project",t,"thread",e.thread.id])},error:e=>{console.error("[TASK-CONTROL] Failed to create thread:",e),this.isCreating.set(!1)}}))}onStopRequested(t){this.threadApi.stopThread(t).pipe(_(this.destroyRef)).subscribe({error:e=>console.error("[TASK-CONTROL] Failed to stop thread:",e)})}onDeleteRequested(t){this.threadApi.deleteThread(t).pipe(_(this.destroyRef)).subscribe({next:()=>this.threadState.refreshThreadList(),error:e=>console.error("[TASK-CONTROL] Failed to delete thread:",e)})}onStarToggled(t){let e=this.username();if(!e)return;let r=this.allTasks().find(m=>m.id===t);if(!r)return;let o=r.starring.includes(e),i=o?this.threadApi.unstarThread(t):this.threadApi.starThread(t);this.threadState.updateStarLocal(t,!o,e),i.pipe(_(this.destroyRef)).subscribe({error:m=>{console.error("[TASK-CONTROL] Failed to toggle star:",m),this.threadState.refreshThreadList()}})}onMarkDoneRequested(t){let e=this.projectState.getSelectedProjectId();e&&this.projectApi.markThreadDone(e,t).pipe(_(this.destroyRef)).subscribe({next:()=>this.threadState.refreshThreadList(),error:r=>console.error("[TASK-CONTROL] Failed to mark task as done:",r)})}onMarkActiveRequested(t){let e=this.projectState.getSelectedProjectId();e&&this.projectApi.markThreadActive(e,t).pipe(_(this.destroyRef)).subscribe({next:()=>this.threadState.refreshThreadList(),error:r=>console.error("[TASK-CONTROL] Failed to mark task as active:",r)})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-task-control"]],decls:25,vars:6,consts:[[1,"task-control"],[1,"tc-header"],[1,"tc-title-row"],[1,"tc-title"],[1,"title-icon"],["mat-flat-button","","aria-label","Start a new task",1,"new-task-btn",3,"click","disabled"],["diameter","16"],["role","tablist","aria-label","Filter tasks",1,"tc-filters"],["role","tab",1,"filter-chip",3,"active"],["role","switch","aria-label","Show starred tasks only",1,"filter-chip","starred-filter",3,"click"],[1,"filter-icon"],[1,"tc-grid-wrapper"],[1,"tc-loading"],[1,"tc-empty"],[1,"tc-grid"],["role","tab",1,"filter-chip",3,"click"],[1,"filter-badge"],["diameter","40"],[1,"empty-icon"],["mat-flat-button","",1,"new-task-btn",3,"click"],[1,"tc-group"],[1,"tc-group-title"],[1,"group-icon"],[1,"group-count"],[3,"task"],[3,"stopRequested","deleteRequested","starToggled","markDoneRequested","markActiveRequested","task"]],template:function(e,r){e&1&&(a(0,"app-sidenav")(1,"div",0)(2,"header",1)(3,"div",2)(4,"h1",3)(5,"mat-icon",4),c(6,"rocket_launch"),s(),c(7," Task Control "),s(),a(8,"button",5),h("click",function(){return r.createTask()}),b(9,pe,1,0,"mat-spinner",6)(10,me,2,0,"mat-icon"),c(11," New Task "),s()(),a(12,"nav",7),x(13,ge,6,6,"button",8,ce),a(15,"button",9),h("click",function(){return r.toggleStarredFilter()}),a(16,"mat-icon",10),c(17,"star"),s(),a(18,"span"),c(19,"Starred"),s()()()(),a(20,"main",11),b(21,_e,4,0,"div",12)(22,ke,5,1,"div",13)(23,be,2,0)(24,xe,3,0,"div",14),s()()()),e&2&&(p(8),P("disabled",r.isCreating()),p(),y(r.isCreating()?9:10),p(4),T(r.filters),p(2),j("active",r.starredOnly()),E("aria-checked",r.starredOnly()),p(6),y(r.isLoadingList()?21:r.filteredTasks().length===0?22:r.activeFilter()==="all"?23:24))},dependencies:[re,oe,W,H,J,U,X,Q],styles:[".glass-panel[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow)}.glass-interactive[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);transition:all .3s cubic-bezier(.4,0,.2,1)}.glass-interactive[_ngcontent-%COMP%]:hover{transform:translateY(-2px);box-shadow:0 12px 40px #00000026}.glass-interactive[_ngcontent-%COMP%]:active{transform:translateY(0)}.glass-card[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);border-radius:20px;padding:1.5rem}.glass-button[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);transition:all .3s cubic-bezier(.4,0,.2,1)}.glass-button[_ngcontent-%COMP%]:hover{transform:translateY(-2px);box-shadow:0 12px 40px #00000026}.glass-button[_ngcontent-%COMP%]:active{transform:translateY(0)}.glass-button[_ngcontent-%COMP%]{border-radius:12px;padding:.75rem 1.5rem;font-weight:600;cursor:pointer}.glass-button[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed;transform:none}.glass-button[_ngcontent-%COMP%]:disabled:hover{transform:none}.smooth-theme-transition[_ngcontent-%COMP%]{transition:background .3s ease,color .3s ease,border-color .3s ease,box-shadow .3s ease}[_nghost-%COMP%]{display:flex;height:100vh;width:100%;overflow:hidden}.task-control[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;overflow:hidden;padding:1.5rem;gap:1.25rem;box-sizing:border-box}.tc-header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;flex-shrink:0}.tc-title-row[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:1rem}.tc-title[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text)}.tc-title[_ngcontent-%COMP%] .title-icon[_ngcontent-%COMP%]{font-size:1.5rem;width:1.5rem;height:1.5rem;color:var(--color-primary)}.new-task-btn[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.375rem;background:var(--color-primary);color:var(--color-text-inverse);border-radius:12px;font-weight:600;padding:0 1rem;height:36px;flex-shrink:0}.new-task-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.1rem;width:1.1rem;height:1.1rem}.new-task-btn[_ngcontent-%COMP%] mat-spinner[_ngcontent-%COMP%]{display:inline-block}.tc-filters[_ngcontent-%COMP%]{display:flex;gap:.5rem;flex-wrap:wrap}.filter-chip[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);display:flex;align-items:center;gap:.375rem;padding:.375rem .875rem;border-radius:100px;font-size:.8rem;font-weight:500;color:var(--color-text-secondary);cursor:pointer;border:1px solid var(--color-border);transition:background .15s ease,color .15s ease,border-color .15s ease;white-space:nowrap}.filter-chip[_ngcontent-%COMP%] .filter-icon[_ngcontent-%COMP%]{font-size:.9rem;width:.9rem;height:.9rem}.filter-chip[_ngcontent-%COMP%] .filter-badge[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-text-inverse);border-radius:100px;padding:0 .375rem;font-size:.7rem;font-weight:700;min-width:18px;text-align:center;line-height:18px}.filter-chip.active[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-text-inverse);border-color:var(--color-primary)}.filter-chip.active[_ngcontent-%COMP%] .filter-icon[_ngcontent-%COMP%]{color:var(--color-text-inverse)}.filter-chip.active[_ngcontent-%COMP%] .filter-badge[_ngcontent-%COMP%]{background:#ffffff4d;color:var(--color-text-inverse)}.filter-chip[_ngcontent-%COMP%]:hover:not(.active){background:var(--color-bg-hover);color:var(--color-text)}.starred-filter.active[_ngcontent-%COMP%]{background:#f5a62326;border-color:#f5a623;color:#f5a623}.starred-filter.active[_ngcontent-%COMP%] .filter-icon[_ngcontent-%COMP%]{color:#f5a623}.tc-group[_ngcontent-%COMP%]{margin-bottom:1.5rem}.tc-group[_ngcontent-%COMP%]:last-child{margin-bottom:0}.tc-group-title[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin:0 0 .75rem;font-size:.85rem;font-weight:600;color:var(--color-text-secondary);text-transform:uppercase;letter-spacing:.05em}.tc-group-title[_ngcontent-%COMP%] .group-icon[_ngcontent-%COMP%]{font-size:1rem;width:1rem;height:1rem}.tc-group-title[_ngcontent-%COMP%] .group-count[_ngcontent-%COMP%]{background:var(--color-bg-hover);border-radius:100px;padding:0 .375rem;font-size:.75rem;font-weight:700;min-width:18px;text-align:center;line-height:18px}.tc-grid-wrapper[_ngcontent-%COMP%]{flex:1;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--color-border) transparent}.tc-grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:1rem;padding-bottom:1rem}@media(max-width:600px){.tc-grid[_ngcontent-%COMP%]{grid-template-columns:1fr}}.tc-loading[_ngcontent-%COMP%], .tc-empty[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1rem;height:100%;min-height:240px;color:var(--color-text-secondary);text-align:center}.tc-loading[_ngcontent-%COMP%] p[_ngcontent-%COMP%], .tc-empty[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;font-size:.95rem}.empty-icon[_ngcontent-%COMP%]{font-size:3rem;width:3rem;height:3rem;opacity:.3}"],changeDetection:0})};export{se as TaskControlComponent};
|
|
1
|
+
import{a as re,b as ie,c as V}from"./chunk-N4H6RBJP.js";import{a as oe}from"./chunk-Y3VADJFG.js";import{a as Q,b as X,e as ne}from"./chunk-3XRWFLI7.js";import{a as G,b as C,c as B,h as Z,s as ee,x as te}from"./chunk-3SKJ5SNK.js";import{c as K}from"./chunk-MZT6I3S3.js";import"./chunk-WUU4G5YQ.js";import"./chunk-DVUB4DDV.js";import"./chunk-MWPKXBXJ.js";import"./chunk-OX7PDXEA.js";import"./chunk-7EDSHFWH.js";import{a as _,c as f}from"./chunk-3ZLLFAXF.js";import{a as H,b as W}from"./chunk-Q2M4W42M.js";import"./chunk-DDWYQORF.js";import{a as Y,b as M}from"./chunk-JF3TWRKD.js";import{Q as U,S as J}from"./chunk-B46LXCLF.js";import{Bb as S,Db as h,Fb as l,Ka as p,Rb as j,T as L,Tb as c,Ub as k,Vb as z,Wa as N,Z as w,ca as d,ga as u,h as A,ha as g,jb as E,lb as b,ma as $,mb as y,mc as v,pb as x,qb as T,rb as P,sb as a,t as I,ta as O,tb as s,ub as D}from"./chunk-KJ5SIUGY.js";var R=class n{threadState=d(C);codayService=d(ne);threadList=f(this.threadState.threadList$,{initialValue:[]});selectedThread=f(this.threadState.selectedThread$,{initialValue:null});isThinking=f(this.codayService.isThinking$,{initialValue:!1});inviteEvent=f(this.codayService.currentInviteEvent$.pipe(I(t=>t?.invite===Z?null:t)),{initialValue:null});tasks=v(()=>{let t=this.threadList(),e=this.selectedThread(),r=this.isThinking(),o=this.inviteEvent();return t.filter(i=>!i.parentThreadId).map(i=>{let m=!!e&&i.id===e.id;return{id:i.id,name:i.name,summary:i.summary,modifiedDate:i.modifiedDate,starring:i.starring??[],users:i.users??[],status:this.deriveStatus(i,m,r,!!o),isActive:m,worktreeProject:i.worktreeProject}}).sort((i,m)=>{let q=V[i.status]-V[m.status];return q!==0?q:i.modifiedDate>m.modifiedDate?-1:1})});deriveStatus(t,e,r,o){let i=Date.now()-new Date(t.modifiedDate).getTime();return t.closedByUser?"done":t.pendingInvite?"waiting-you":e?r?"in-progress":"paused":i<ie?"in-progress":"paused"}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var F=class n{projectState=d(M);threadState=d(C);destroy$=new A;eventSource=null;currentProject=null;constructor(){this.projectState.selectedProject$.pipe(L(this.destroy$)).subscribe(t=>{let e=t?.name??null;e!==this.currentProject&&(this.disconnect(),e&&this.connect(e))})}connect(t,e=5e3){this.currentProject=t;let r=`/api/projects/${encodeURIComponent(t)}/event-stream`;console.log(`[PROJECT_SSE] Connecting to ${r}`),this.eventSource=new EventSource(r),this.eventSource.onmessage=o=>{try{let i=JSON.parse(o.data),m=te(i);if(!m)return;m instanceof ee&&(console.log("[PROJECT_SSE] ThreadUpdateEvent \u2014 refreshing thread list"),this.threadState.refreshThreadList())}catch(i){console.warn("[PROJECT_SSE] Failed to parse event:",i)}},this.eventSource.onerror=()=>{this.eventSource?.readyState===EventSource.CLOSED&&(console.warn(`[PROJECT_SSE] Connection closed for ${t}, reconnecting in ${e}ms`),this.eventSource=null,setTimeout(()=>{this.currentProject===t&&this.connect(t,Math.min(e*2,6e4))},e))}}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null,console.log(`[PROJECT_SSE] Disconnected from project ${this.currentProject}`)),this.currentProject=null}ngOnDestroy(){this.disconnect(),this.destroy$.next(),this.destroy$.complete()}static \u0275fac=function(e){return new(e||n)};static \u0275prov=w({token:n,factory:n.\u0275fac,providedIn:"root"})};var ce=(n,t)=>t.key,de=(n,t)=>t.status,le=(n,t)=>t.id;function pe(n,t){n&1&&D(0,"mat-spinner",6)}function me(n,t){n&1&&(a(0,"mat-icon"),c(1,"add"),s())}function ue(n,t){if(n&1&&(a(0,"span",16),c(1),s()),n&2){let e=l().$implicit,r=l();p(),k(r.filterCounts()[e.key])}}function ge(n,t){if(n&1){let e=S();a(0,"button",15),h("click",function(){let o=u(e).$implicit,i=l();return g(i.setFilter(o.key))}),a(1,"mat-icon",10),c(2),s(),a(3,"span"),c(4),s(),b(5,ue,2,1,"span",16),s()}if(n&2){let e=t.$implicit,r=l();j("active",r.activeFilter()===e.key),E("aria-selected",r.activeFilter()===e.key),p(2),k(e.icon),p(2),k(e.label),p(),y(r.filterCounts()[e.key]>0?5:-1)}}function _e(n,t){n&1&&(a(0,"div",12),D(1,"mat-spinner",17),a(2,"p"),c(3,"Loading tasks\u2026"),s()())}function fe(n,t){if(n&1){let e=S();a(0,"p"),c(1,"No tasks yet. Start your first one!"),s(),a(2,"button",19),h("click",function(){u(e);let o=l(2);return g(o.createTask())}),a(3,"mat-icon"),c(4,"add"),s(),c(5," New Task "),s()}}function he(n,t){n&1&&(a(0,"p"),c(1,"No tasks in this category."),s())}function ke(n,t){if(n&1&&(a(0,"div",13)(1,"mat-icon",18),c(2,"rocket_launch"),s(),b(3,fe,6,0)(4,he,2,0,"p"),s()),n&2){let e=l();p(3),y(e.activeFilter()==="all"?3:4)}}function ve(n,t){if(n&1){let e=S();a(0,"app-task-card",25),h("stopRequested",function(o){u(e);let i=l(3);return g(i.onStopRequested(o))})("deleteRequested",function(o){u(e);let i=l(3);return g(i.onDeleteRequested(o))})("starToggled",function(o){u(e);let i=l(3);return g(i.onStarToggled(o))})("markDoneRequested",function(o){u(e);let i=l(3);return g(i.onMarkDoneRequested(o))})("markActiveRequested",function(o){u(e);let i=l(3);return g(i.onMarkActiveRequested(o))}),s()}if(n&2){let e=t.$implicit;P("task",e)}}function Ce(n,t){if(n&1&&(a(0,"section",20)(1,"h2",21)(2,"mat-icon",22),c(3),s(),c(4),a(5,"span",23),c(6),s()(),a(7,"div",14),x(8,ve,1,1,"app-task-card",24,le),s()()),n&2){let e=t.$implicit;p(3),k(e.icon),p(),z(" ",e.label," "),p(2),k(e.tasks.length),p(2),T(e.tasks)}}function be(n,t){if(n&1&&x(0,Ce,10,3,"section",20,de),n&2){let e=l();T(e.taskGroups())}}function ye(n,t){if(n&1){let e=S();a(0,"app-task-card",25),h("stopRequested",function(o){u(e);let i=l(2);return g(i.onStopRequested(o))})("deleteRequested",function(o){u(e);let i=l(2);return g(i.onDeleteRequested(o))})("starToggled",function(o){u(e);let i=l(2);return g(i.onStarToggled(o))})("markDoneRequested",function(o){u(e);let i=l(2);return g(i.onMarkDoneRequested(o))})("markActiveRequested",function(o){u(e);let i=l(2);return g(i.onMarkActiveRequested(o))}),s()}if(n&2){let e=t.$implicit;P("task",e)}}function xe(n,t){if(n&1&&(a(0,"div",14),x(1,ye,1,1,"app-task-card",24,le),s()),n&2){let e=l();p(),T(e.filteredTasks())}}var Te=[{key:"all",label:"All",icon:"grid_view"},{key:"waiting-you",label:"Waiting for you",icon:"mark_unread_chat_alt"},{key:"in-progress",label:"In progress",icon:"pending"},{key:"paused",label:"Paused",icon:"pause_circle"},{key:"done",label:"Done",icon:"check_circle"}],se=class n{router=d(K);projectState=d(M);threadState=d(C);threadApi=d(G);taskStatus=d(R);userService=d(B);projectApi=d(Y);destroyRef=d($);_projectEventStream=d(F);filters=Te;activeFilter=O("all");starredOnly=O(!1);isCreating=O(!1);isLoadingList=f(this.threadState.isLoadingThreadList$,{initialValue:!1});username=f(this.userService.username$,{initialValue:null});allTasks=this.taskStatus.tasks;filteredTasks=v(()=>{let t=this.activeFilter(),e=this.username(),r=this.allTasks();return this.starredOnly()&&e&&(r=r.filter(o=>o.starring.includes(e))),t==="all"?r:r.filter(o=>o.status===t)});filterCounts=v(()=>{let t=this.username(),e=this.allTasks();return this.starredOnly()&&t&&(e=e.filter(r=>r.starring.includes(t))),{all:e.length,"waiting-you":e.filter(r=>r.status==="waiting-you").length,"in-progress":e.filter(r=>r.status==="in-progress").length,paused:e.filter(r=>r.status==="paused").length,done:e.filter(r=>r.status==="done").length}});taskGroups=v(()=>{let t=this.username(),e=this.allTasks();this.starredOnly()&&t&&(e=e.filter(o=>o.starring.includes(t)));let r=[{status:"waiting-you",label:"Waiting for you",icon:"mark_unread_chat_alt",tasks:[]},{status:"in-progress",label:"In progress",icon:"pending",tasks:[]},{status:"done",label:"Done",icon:"check_circle",tasks:[]},{status:"paused",label:"Paused",icon:"pause_circle",tasks:[]},{status:"error",label:"Error",icon:"error",tasks:[]}];for(let o of e){let i=r.find(m=>m.status===o.status);i&&i.tasks.push(o)}return r.filter(o=>o.tasks.length>0)});ngOnInit(){this.userService.fetchCurrentUser().pipe(_(this.destroyRef)).subscribe({error:t=>console.warn("[TASK-CONTROL] Could not fetch user:",t)})}setFilter(t){this.activeFilter.set(t)}toggleStarredFilter(){this.starredOnly.update(t=>!t)}createTask(){let t=this.projectState.getSelectedProjectId();!t||this.isCreating()||(this.isCreating.set(!0),this.threadApi.createThread().pipe(_(this.destroyRef)).subscribe({next:e=>{this.isCreating.set(!1),this.router.navigate(["project",t,"thread",e.thread.id])},error:e=>{console.error("[TASK-CONTROL] Failed to create thread:",e),this.isCreating.set(!1)}}))}onStopRequested(t){this.threadApi.stopThread(t).pipe(_(this.destroyRef)).subscribe({error:e=>console.error("[TASK-CONTROL] Failed to stop thread:",e)})}onDeleteRequested(t){this.threadApi.deleteThread(t).pipe(_(this.destroyRef)).subscribe({next:()=>this.threadState.refreshThreadList(),error:e=>console.error("[TASK-CONTROL] Failed to delete thread:",e)})}onStarToggled(t){let e=this.username();if(!e)return;let r=this.allTasks().find(m=>m.id===t);if(!r)return;let o=r.starring.includes(e),i=o?this.threadApi.unstarThread(t):this.threadApi.starThread(t);this.threadState.updateStarLocal(t,!o,e),i.pipe(_(this.destroyRef)).subscribe({error:m=>{console.error("[TASK-CONTROL] Failed to toggle star:",m),this.threadState.refreshThreadList()}})}onMarkDoneRequested(t){let e=this.projectState.getSelectedProjectId();e&&this.projectApi.markThreadDone(e,t).pipe(_(this.destroyRef)).subscribe({next:()=>this.threadState.refreshThreadList(),error:r=>console.error("[TASK-CONTROL] Failed to mark task as done:",r)})}onMarkActiveRequested(t){let e=this.projectState.getSelectedProjectId();e&&this.projectApi.markThreadActive(e,t).pipe(_(this.destroyRef)).subscribe({next:()=>this.threadState.refreshThreadList(),error:r=>console.error("[TASK-CONTROL] Failed to mark task as active:",r)})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=N({type:n,selectors:[["app-task-control"]],decls:25,vars:6,consts:[[1,"task-control"],[1,"tc-header"],[1,"tc-title-row"],[1,"tc-title"],[1,"title-icon"],["mat-flat-button","","aria-label","Start a new task",1,"new-task-btn",3,"click","disabled"],["diameter","16"],["role","tablist","aria-label","Filter tasks",1,"tc-filters"],["role","tab",1,"filter-chip",3,"active"],["role","switch","aria-label","Show starred tasks only",1,"filter-chip","starred-filter",3,"click"],[1,"filter-icon"],[1,"tc-grid-wrapper"],[1,"tc-loading"],[1,"tc-empty"],[1,"tc-grid"],["role","tab",1,"filter-chip",3,"click"],[1,"filter-badge"],["diameter","40"],[1,"empty-icon"],["mat-flat-button","",1,"new-task-btn",3,"click"],[1,"tc-group"],[1,"tc-group-title"],[1,"group-icon"],[1,"group-count"],[3,"task"],[3,"stopRequested","deleteRequested","starToggled","markDoneRequested","markActiveRequested","task"]],template:function(e,r){e&1&&(a(0,"app-sidenav")(1,"div",0)(2,"header",1)(3,"div",2)(4,"h1",3)(5,"mat-icon",4),c(6,"rocket_launch"),s(),c(7," Task Control "),s(),a(8,"button",5),h("click",function(){return r.createTask()}),b(9,pe,1,0,"mat-spinner",6)(10,me,2,0,"mat-icon"),c(11," New Task "),s()(),a(12,"nav",7),x(13,ge,6,6,"button",8,ce),a(15,"button",9),h("click",function(){return r.toggleStarredFilter()}),a(16,"mat-icon",10),c(17,"star"),s(),a(18,"span"),c(19,"Starred"),s()()()(),a(20,"main",11),b(21,_e,4,0,"div",12)(22,ke,5,1,"div",13)(23,be,2,0)(24,xe,3,0,"div",14),s()()()),e&2&&(p(8),P("disabled",r.isCreating()),p(),y(r.isCreating()?9:10),p(4),T(r.filters),p(2),j("active",r.starredOnly()),E("aria-checked",r.starredOnly()),p(6),y(r.isLoadingList()?21:r.filteredTasks().length===0?22:r.activeFilter()==="all"?23:24))},dependencies:[re,oe,W,H,J,U,X,Q],styles:[".glass-panel[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow)}.glass-interactive[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);transition:all .3s cubic-bezier(.4,0,.2,1)}.glass-interactive[_ngcontent-%COMP%]:hover{transform:translateY(-2px);box-shadow:0 12px 40px #00000026}.glass-interactive[_ngcontent-%COMP%]:active{transform:translateY(0)}.glass-card[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);border-radius:20px;padding:1.5rem}.glass-button[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);transition:all .3s cubic-bezier(.4,0,.2,1)}.glass-button[_ngcontent-%COMP%]:hover{transform:translateY(-2px);box-shadow:0 12px 40px #00000026}.glass-button[_ngcontent-%COMP%]:active{transform:translateY(0)}.glass-button[_ngcontent-%COMP%]{border-radius:12px;padding:.75rem 1.5rem;font-weight:600;cursor:pointer}.glass-button[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed;transform:none}.glass-button[_ngcontent-%COMP%]:disabled:hover{transform:none}.smooth-theme-transition[_ngcontent-%COMP%]{transition:background .3s ease,color .3s ease,border-color .3s ease,box-shadow .3s ease}[_nghost-%COMP%]{display:flex;height:100vh;width:100%;overflow:hidden}.task-control[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;overflow:hidden;padding:1.5rem;gap:1.25rem;box-sizing:border-box}.tc-header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1rem;flex-shrink:0}.tc-title-row[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:1rem}.tc-title[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text)}.tc-title[_ngcontent-%COMP%] .title-icon[_ngcontent-%COMP%]{font-size:1.5rem;width:1.5rem;height:1.5rem;color:var(--color-primary)}.new-task-btn[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.375rem;background:var(--color-primary);color:var(--color-text-inverse);border-radius:12px;font-weight:600;padding:0 1rem;height:36px;flex-shrink:0}.new-task-btn[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:1.1rem;width:1.1rem;height:1.1rem}.new-task-btn[_ngcontent-%COMP%] mat-spinner[_ngcontent-%COMP%]{display:inline-block}.tc-filters[_ngcontent-%COMP%]{display:flex;gap:.5rem;flex-wrap:wrap}.filter-chip[_ngcontent-%COMP%]{background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);box-shadow:var(--glass-shadow);display:flex;align-items:center;gap:.375rem;padding:.375rem .875rem;border-radius:100px;font-size:.8rem;font-weight:500;color:var(--color-text-secondary);cursor:pointer;border:1px solid var(--color-border);transition:background .15s ease,color .15s ease,border-color .15s ease;white-space:nowrap}.filter-chip[_ngcontent-%COMP%] .filter-icon[_ngcontent-%COMP%]{font-size:.9rem;width:.9rem;height:.9rem}.filter-chip[_ngcontent-%COMP%] .filter-badge[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-text-inverse);border-radius:100px;padding:0 .375rem;font-size:.7rem;font-weight:700;min-width:18px;text-align:center;line-height:18px}.filter-chip.active[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-text-inverse);border-color:var(--color-primary)}.filter-chip.active[_ngcontent-%COMP%] .filter-icon[_ngcontent-%COMP%]{color:var(--color-text-inverse)}.filter-chip.active[_ngcontent-%COMP%] .filter-badge[_ngcontent-%COMP%]{background:#ffffff4d;color:var(--color-text-inverse)}.filter-chip[_ngcontent-%COMP%]:hover:not(.active){background:var(--color-bg-hover);color:var(--color-text)}.starred-filter.active[_ngcontent-%COMP%]{background:#f5a62326;border-color:#f5a623;color:#f5a623}.starred-filter.active[_ngcontent-%COMP%] .filter-icon[_ngcontent-%COMP%]{color:#f5a623}.tc-group[_ngcontent-%COMP%]{margin-bottom:1.5rem}.tc-group[_ngcontent-%COMP%]:last-child{margin-bottom:0}.tc-group-title[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;margin:0 0 .75rem;font-size:.85rem;font-weight:600;color:var(--color-text-secondary);text-transform:uppercase;letter-spacing:.05em}.tc-group-title[_ngcontent-%COMP%] .group-icon[_ngcontent-%COMP%]{font-size:1rem;width:1rem;height:1rem}.tc-group-title[_ngcontent-%COMP%] .group-count[_ngcontent-%COMP%]{background:var(--color-bg-hover);border-radius:100px;padding:0 .375rem;font-size:.75rem;font-weight:700;min-width:18px;text-align:center;line-height:18px}.tc-grid-wrapper[_ngcontent-%COMP%]{flex:1;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--color-border) transparent}.tc-grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:1rem;padding-bottom:1rem}@media(max-width:600px){.tc-grid[_ngcontent-%COMP%]{grid-template-columns:1fr}}.tc-loading[_ngcontent-%COMP%], .tc-empty[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1rem;height:100%;min-height:240px;color:var(--color-text-secondary);text-align:center}.tc-loading[_ngcontent-%COMP%] p[_ngcontent-%COMP%], .tc-empty[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;font-size:.95rem}.empty-icon[_ngcontent-%COMP%]{font-size:3rem;width:3rem;height:3rem;opacity:.3}"],changeDetection:0})};export{se as TaskControlComponent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as de,b as w}from"./chunk-JF3TWRKD.js";import{D as $,J as se,P as ce,R as re,S as ie,V as g,Wc as E,Z as c,a as T,b as C,ca as a,d,h as j,i as r,m as D,n as k,pa as le,t as te,u as ne}from"./chunk-KJ5SIUGY.js";var N=class n{http=a(E);projectState=a(w);getBaseUrl(){return`/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/threads`}listThreads(){return this.http.get(this.getBaseUrl())}listAllThreads(){return this.http.get("/api/threads")}getThread(e){return this.http.get(`${this.getBaseUrl()}/${e}`)}createThread(e){let t=e?{name:e}:{};return this.http.post(this.getBaseUrl(),t)}updateThread(e,t){return this.http.put(`${this.getBaseUrl()}/${e}`,{name:t})}updateThreadUsers(e,t){return this.http.put(`${this.getBaseUrl()}/${e}`,{users:t})}starThread(e){return this.http.post(`${this.getBaseUrl()}/${e}/star`,{})}unstarThread(e){return this.http.delete(`${this.getBaseUrl()}/${e}/star`)}deleteThread(e){return this.http.delete(`${this.getBaseUrl()}/${e}`)}stopThread(e){return this.http.post(`${this.getBaseUrl()}/${e}/stop`,{})}getThreadMessages(e){return this.http.get(`${this.getBaseUrl()}/${e}/messages`)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=c({token:n,factory:n.\u0275fac,providedIn:"root"})};var U=class n{selectedThreadIdSubject=new r(null);isLoadingSubject=new r(!1);isLoadingThreadListSubject=new r(!1);refreshThreadListSubject=new j;threadListSubject=new r([]);hasLoadedOncePerProject=new Map;currentProjectName=null;isLoading$=this.isLoadingSubject.asObservable();isLoadingThreadList$=this.isLoadingThreadListSubject.asObservable();threadApi=a(N);projectStateService=a(w);projectApi=a(de);projectName$=this.projectStateService.selectedProject$.pipe(te(e=>e?.name),se());constructor(){ne([this.projectName$,this.refreshThreadListSubject.asObservable().pipe(re(void 0))]).pipe(g(([e])=>{e!==this.currentProjectName&&(console.log("[THREAD_STATE] Project changed, clearing thread list"),this.threadListSubject.next([]),this.currentProjectName=e),e?this.hasLoadedOncePerProject.get(e)?console.log("[THREAD_STATE] Refreshing thread list for project",e,"(no spinner)"):(console.log("[THREAD_STATE] Initial load for project",e,"- showing spinner"),this.isLoadingThreadListSubject.next(!0)):(console.log("[THREAD_STATE] No project selected, hiding spinner"),this.isLoadingThreadListSubject.next(!1))}),ie(([e])=>e?(console.log("[THREAD_STATE] Fetching threads for project:",e),this.threadApi.listThreads().pipe(te(t=>({threads:t,projectName:e})),$(t=>(console.error("[THREAD_STATE] Error loading thread list:",t),D({threads:[],projectName:e}))))):(console.log("[THREAD_STATE] No project selected, returning empty list"),D({threads:[],projectName:null}))),g(({threads:e,projectName:t})=>{console.log("[THREAD_STATE] Thread list loaded:",e.length,"threads for project",t),t&&this.hasLoadedOncePerProject.set(t,!0),this.isLoadingThreadListSubject.next(!1),this.threadListSubject.next(e)})).subscribe()}threadList$=this.threadListSubject.asObservable();refreshSelectedThreadSubject=new j;selectedThread$=ne([this.projectName$,this.selectedThreadIdSubject.pipe(se()),this.refreshSelectedThreadSubject.pipe(re(void 0))]).pipe(ie(([e,t])=>!e||!t?D(null):(this.isLoadingSubject.next(!0),this.threadApi.getThread(t).pipe(ce({bufferSize:1,refCount:!0})))),g(()=>{this.isLoadingSubject.next(!1)}));selectThread(e){this.selectedThreadIdSubject.next(e)}getSelectedThreadId(){return this.selectedThreadIdSubject.value}getSelectedThreadIdOrThrow(){let e=this.selectedThreadIdSubject.value;if(!e)throw new Error("[THREAD_STATE] No thread selected");return e}clearSelection(){this.selectedThreadIdSubject.next(null)}stop(){let e=this.selectedThreadIdSubject.value;if(!e){console.error("[THREAD_STATE] Cannot stop: no thread selected");return}console.log("[THREAD_STATE] Stopping thread:",e),this.threadApi.stopThread(e).subscribe({next:t=>console.log("[THREAD_STATE] Stop signal sent:",t.message),error:t=>console.error("[THREAD_STATE] Error stopping thread:",t)})}refreshThreadList(){console.log("[THREAD_STATE] Manually refreshing thread list"),this.refreshThreadListSubject.next()}updateStarLocal(e,t,s){let P=this.threadListSubject.value.map(l=>{if(l.id!==e)return l;let p=l.starring||[];return t&&!p.includes(s)?C(T({},l),{starring:[...p,s]}):!t&&p.includes(s)?C(T({},l),{starring:p.filter(I=>I!==s)}):l});this.threadListSubject.next(P)}refreshSelectedThread(){this.refreshSelectedThreadSubject.next()}updateThreadUsers(e,t){return this.threadApi.updateThreadUsers(e,t).pipe(g(()=>{this.refreshThreadList()}),$(s=>(console.error("[THREAD_STATE] Error updating thread users:",s),k(()=>s))))}markDone(e){let t=this.projectStateService.getSelectedProjectId();if(!t){console.error("[THREAD_STATE] Cannot mark done: no project selected");return}this.projectApi.markThreadDone(t,e).subscribe({next:()=>this.refreshThreadList(),error:s=>console.error("[THREAD_STATE] Failed to mark thread as done:",s)})}markActive(e){let t=this.projectStateService.getSelectedProjectId();if(!t){console.error("[THREAD_STATE] Cannot mark active: no project selected");return}this.projectApi.markThreadActive(t,e).subscribe({next:()=>this.refreshThreadList(),error:s=>console.error("[THREAD_STATE] Failed to mark thread as active:",s)})}renameThread(e,t){let s=t.trim();return!s||s.length===0?(console.error("[THREAD_STATE] Cannot rename thread: name is empty after trimming"),k(()=>new Error("Thread name cannot be empty"))):(console.log("[THREAD_STATE] Renaming thread:",e,"to:",s),this.threadApi.updateThread(e,s).pipe(g(i=>{console.log("[THREAD_STATE] Thread renamed successfully:",i),this.refreshThreadList()}),$(i=>(console.error("[THREAD_STATE] Error renaming thread:",i),k(()=>i)))))}static \u0275fac=function(t){return new(t||n)};static \u0275prov=c({token:n,factory:n.\u0275fac,providedIn:"root"})};var ue=class n{http=a(E);usernameSubject=new r(null);authEnabledSubject=new r(!1);username$=this.usernameSubject.asObservable();authEnabled$=this.authEnabledSubject.asObservable();fetchCurrentUser(){return this.http.get("/api/user/me").pipe(g(e=>{this.usernameSubject.next(e.username),this.authEnabledSubject.next(e.authEnabled)}))}getUsername(){return this.usernameSubject.value}static \u0275fac=function(t){return new(t||n)};static \u0275prov=c({token:n,factory:n.\u0275fac,providedIn:"root"})};var L=class n{STORAGE_KEY="coday-preferences";isDesktopApp=!1;electronStorage=null;voiceLanguageSubject=new r("en-US");voiceLanguage$=this.voiceLanguageSubject.asObservable();voiceInputModeSubject=new r("browser");voiceInputMode$=this.voiceInputModeSubject.asObservable();enterToSendSubject=new r(!0);enterToSend$=this.enterToSendSubject.asObservable();voiceAnnounceEnabledSubject=new r(!1);voiceAnnounceEnabled$=this.voiceAnnounceEnabledSubject.asObservable();voiceModeSubject=new r("speech");voiceMode$=this.voiceModeSubject.asObservable();voiceReadFullTextSubject=new r(!1);voiceReadFullText$=this.voiceReadFullTextSubject.asObservable();voiceVolumeSubject=new r(.8);voiceVolume$=this.voiceVolumeSubject.asObservable();voiceRateSubject=new r(1.2);voiceRate$=this.voiceRateSubject.asObservable();selectedVoiceSubject=new r(null);selectedVoice$=this.selectedVoiceSubject.asObservable();printTechnicalMessagesSubject=new r(!1);printTechnicalMessages$=this.printTechnicalMessagesSubject.asObservable();hideTechnicalMessagesSubject=new r(!0);hideTechnicalMessages$=this.hideTechnicalMessagesSubject.asObservable();hideWarningMessagesSubject=new r(!1);hideWarningMessages$=this.hideWarningMessagesSubject.asObservable();agentNotificationEnabledSubject=new r(!1);agentNotificationEnabled$=this.agentNotificationEnabledSubject.asObservable();notificationSoundEnabledSubject=new r(!1);notificationSoundEnabled$=this.notificationSoundEnabledSubject.asObservable();browserNotificationEnabledSubject=new r(!1);browserNotificationEnabled$=this.browserNotificationEnabledSubject.asObservable();themeSubject=new r("light");theme$=this.themeSubject.asObservable();missionPreviewEnabledSubject=new r(!1);missionPreviewEnabled$=this.missionPreviewEnabledSubject.asObservable();constructor(){console.log("[PREFERENCES] Initializing preferences service"),typeof window<"u"&&window.codayDesktop?.storage&&(this.isDesktopApp=!0,this.electronStorage=window.codayDesktop.storage,console.log("[PREFERENCES] Running in desktop app mode with persistent storage")),this.initializePreferences()}initializePreferences(){this.isDesktopApp?this.loadPreferencesAsync():this.loadPreferencesSync()}loadPreferencesSync(){let e=this.getPreferenceSync("voiceLanguage","en-US")??"en-US";this.voiceLanguageSubject.next(e),console.log("[PREFERENCES] Voice language initialized to:",e);let t=this.getPreferenceSync("useEnterToSend",!0)??!0;this.enterToSendSubject.next(t),console.log("[PREFERENCES] Enter to send initialized to:",t);let s=this.getPreferenceSync("voiceAnnounceEnabled",!1)??!1;this.voiceAnnounceEnabledSubject.next(s);let i=this.getPreferenceSync("voiceMode","speech")??"speech";this.voiceModeSubject.next(i);let P=this.getPreferenceSync("voiceReadFullText",!1)??!1;this.voiceReadFullTextSubject.next(P);let l=this.getPreferenceSync("voiceVolume",.8)??.8;this.voiceVolumeSubject.next(l);let p=this.getPreferenceSync("voiceRate",1.2)??1.2;this.voiceRateSubject.next(p);let I=this.getPreferenceSync("selectedVoice",null)??null;this.selectedVoiceSubject.next(I);let _=this.getPreferenceSync("printTechnicalMessages",!1)??!1;this.printTechnicalMessagesSubject.next(_);let K=this.getPreferenceSync("hideTechnicalMessages",!0)??!0;this.hideTechnicalMessagesSubject.next(K);let G=this.getPreferenceSync("hideWarningMessages",!1)??!1;this.hideWarningMessagesSubject.next(G);let Q=this.getPreferenceSync("agentNotificationEnabled",!1)??!1;this.agentNotificationEnabledSubject.next(Q);let J=this.getPreferenceSync("notificationSoundEnabled",!0)??!0;this.notificationSoundEnabledSubject.next(J);let Y=this.getPreferenceSync("browserNotificationEnabled",!1)??!1;this.browserNotificationEnabledSubject.next(Y);let X=this.getPreferenceSync("theme","light")??"light";this.themeSubject.next(X);let Z=this.getPreferenceSync("missionPreviewEnabled",!1)??!1;this.missionPreviewEnabledSubject.next(Z);let ee=this.getPreferenceSync("voiceInputMode","browser")??"browser";this.voiceInputModeSubject.next(ee),console.log("[PREFERENCES] All preferences initialized successfully")}loadPreferencesAsync(){return d(this,null,function*(){let e=(yield this.getPreferenceAsync("voiceLanguage","en-US"))??"en-US";this.voiceLanguageSubject.next(e),console.log("[PREFERENCES] Voice language initialized to:",e);let t=(yield this.getPreferenceAsync("useEnterToSend",!0))??!0;this.enterToSendSubject.next(t),console.log("[PREFERENCES] Enter to send initialized to:",t);let s=(yield this.getPreferenceAsync("voiceAnnounceEnabled",!1))??!1;this.voiceAnnounceEnabledSubject.next(s);let i=(yield this.getPreferenceAsync("voiceMode","speech"))??"speech";this.voiceModeSubject.next(i);let P=(yield this.getPreferenceAsync("voiceReadFullText",!1))??!1;this.voiceReadFullTextSubject.next(P);let l=(yield this.getPreferenceAsync("voiceVolume",.8))??.8;this.voiceVolumeSubject.next(l);let p=(yield this.getPreferenceAsync("voiceRate",1.2))??1.2;this.voiceRateSubject.next(p);let I=(yield this.getPreferenceAsync("selectedVoice",null))??null;this.selectedVoiceSubject.next(I);let _=(yield this.getPreferenceAsync("printTechnicalMessages",!1))??!1;this.printTechnicalMessagesSubject.next(_);let K=(yield this.getPreferenceAsync("hideTechnicalMessages",!0))??!0;this.hideTechnicalMessagesSubject.next(K);let G=(yield this.getPreferenceAsync("hideWarningMessages",!1))??!1;this.hideWarningMessagesSubject.next(G);let Q=(yield this.getPreferenceAsync("agentNotificationEnabled",!1))??!1;this.agentNotificationEnabledSubject.next(Q);let J=(yield this.getPreferenceAsync("notificationSoundEnabled",!0))??!0;this.notificationSoundEnabledSubject.next(J);let Y=(yield this.getPreferenceAsync("browserNotificationEnabled",!1))??!1;this.browserNotificationEnabledSubject.next(Y);let X=(yield this.getPreferenceAsync("theme","light"))??"light";this.themeSubject.next(X);let Z=(yield this.getPreferenceAsync("missionPreviewEnabled",!1))??!1;this.missionPreviewEnabledSubject.next(Z);let ee=(yield this.getPreferenceAsync("voiceInputMode","browser"))??"browser";this.voiceInputModeSubject.next(ee),console.log("[PREFERENCES] All preferences initialized successfully (async)")})}getPreference(e,t){return this.getPreferenceSync(e,t)}getPreferenceSync(e,t){try{let s=localStorage.getItem(this.STORAGE_KEY);if(!s)return t;let i=JSON.parse(s);return i[e]!==void 0?i[e]:t}catch(s){return t}}getPreferenceAsync(e,t){return d(this,null,function*(){if(!this.electronStorage)return this.getPreferenceSync(e,t);try{let s=yield this.electronStorage.get(this.STORAGE_KEY);if(!s)return t;let i=JSON.parse(s);return i[e]!==void 0?i[e]:t}catch(s){return t}})}setPreference(e,t){this.isDesktopApp?this.setPreferenceAsync(e,t):this.setPreferenceSync(e,t)}setPreferenceSync(e,t){try{let s=localStorage.getItem(this.STORAGE_KEY),i=s?JSON.parse(s):{};i[e]=t,localStorage.setItem(this.STORAGE_KEY,JSON.stringify(i)),this.updateSubject(e,t)}catch(s){console.error("Failed to set preference:",s)}}setPreferenceAsync(e,t){return d(this,null,function*(){if(!this.electronStorage){this.setPreferenceSync(e,t);return}try{let s=yield this.electronStorage.get(this.STORAGE_KEY),i=s?JSON.parse(s):{};i[e]=t,yield this.electronStorage.set(this.STORAGE_KEY,JSON.stringify(i)),this.updateSubject(e,t)}catch(s){console.error("Failed to set preference:",s)}})}updateSubject(e,t){e==="voiceLanguage"&&this.voiceLanguageSubject.next(t),e==="useEnterToSend"&&this.enterToSendSubject.next(t),e==="voiceAnnounceEnabled"&&this.voiceAnnounceEnabledSubject.next(t),e==="voiceMode"&&this.voiceModeSubject.next(t),e==="voiceReadFullText"&&this.voiceReadFullTextSubject.next(t),e==="voiceVolume"&&this.voiceVolumeSubject.next(t),e==="voiceRate"&&this.voiceRateSubject.next(t),e==="selectedVoice"&&this.selectedVoiceSubject.next(t),e==="printTechnicalMessages"&&this.printTechnicalMessagesSubject.next(t),e==="hideTechnicalMessages"&&this.hideTechnicalMessagesSubject.next(t),e==="hideWarningMessages"&&this.hideWarningMessagesSubject.next(t),e==="agentNotificationEnabled"&&this.agentNotificationEnabledSubject.next(t),e==="notificationSoundEnabled"&&this.notificationSoundEnabledSubject.next(t),e==="browserNotificationEnabled"&&this.browserNotificationEnabledSubject.next(t),e==="theme"&&this.themeSubject.next(t),e==="voiceInputMode"&&this.voiceInputModeSubject.next(t),e==="missionPreviewEnabled"&&this.missionPreviewEnabledSubject.next(t)}setVoiceLanguage(e){console.log("[PREFERENCES] Setting voice language to:",e),this.setPreference("voiceLanguage",e)}getVoiceLanguage(){return this.getPreference("voiceLanguage","en-US")??"en-US"}setVoiceInputMode(e){console.log("[PREFERENCES] Setting voice input mode to:",e),this.setPreference("voiceInputMode",e)}getVoiceInputMode(){return this.getPreference("voiceInputMode","browser")??"browser"}setEnterToSend(e){console.log("[PREFERENCES] Setting Enter to send to:",e),this.setPreference("useEnterToSend",e)}getEnterToSend(){return this.getPreference("useEnterToSend",!1)??!1}setVoiceAnnounceEnabled(e){console.log("[PREFERENCES] Setting voice announce enabled to:",e),this.setPreference("voiceAnnounceEnabled",e)}getVoiceAnnounceEnabled(){return this.getPreference("voiceAnnounceEnabled",!1)??!1}setVoiceMode(e){console.log("[PREFERENCES] Setting voice mode to:",e),this.setPreference("voiceMode",e)}getVoiceMode(){return this.getPreference("voiceMode","speech")??"speech"}setVoiceReadFullText(e){console.log("[PREFERENCES] Setting voice read full text to:",e),this.setPreference("voiceReadFullText",e)}getVoiceReadFullText(){return this.getPreference("voiceReadFullText",!1)??!1}setVoiceVolume(e){let t=Math.max(0,Math.min(1,e));console.log("[PREFERENCES] Setting voice volume to:",t),this.setPreference("voiceVolume",t)}getVoiceVolume(){return this.getPreference("voiceVolume",.8)??.8}setVoiceRate(e){let t=Math.max(.5,Math.min(2,e));console.log("[PREFERENCES] Setting voice rate to:",t),this.setPreference("voiceRate",t)}getVoiceRate(){return this.getPreference("voiceRate",1.2)??1.2}setSelectedVoice(e){console.log("[PREFERENCES] Setting selected voice to:",e),this.setPreference("selectedVoice",e)}getSelectedVoice(){return this.getPreference("selectedVoice",null)??null}setPrintTechnicalMessages(e){console.log("[PREFERENCES] Setting print technical messages to:",e),this.setPreference("printTechnicalMessages",e)}getPrintTechnicalMessages(){return this.getPreference("printTechnicalMessages",!1)??!1}setHideTechnicalMessages(e){console.log("[PREFERENCES] Setting hide technical messages to:",e),this.setPreference("hideTechnicalMessages",e)}getHideTechnicalMessages(){return this.getPreference("hideTechnicalMessages",!0)??!0}setHideWarningMessages(e){console.log("[PREFERENCES] Setting hide warning messages to:",e),this.setPreference("hideWarningMessages",e)}getHideWarningMessages(){return this.getPreference("hideWarningMessages",!1)??!1}setAgentNotificationEnabled(e){console.log("[PREFERENCES] Setting agent notification enabled to:",e),this.setPreference("agentNotificationEnabled",e)}getAgentNotificationEnabled(){return this.getPreference("agentNotificationEnabled",!1)??!1}setNotificationSoundEnabled(e){console.log("[PREFERENCES] Setting notification sound enabled to:",e),this.setPreference("notificationSoundEnabled",e)}getNotificationSoundEnabled(){return this.getPreference("notificationSoundEnabled",!0)??!0}setBrowserNotificationEnabled(e){console.log("[PREFERENCES] Setting browser notification enabled to:",e),this.setPreference("browserNotificationEnabled",e)}getBrowserNotificationEnabled(){return this.getPreference("browserNotificationEnabled",!1)??!1}setMissionPreviewEnabled(e){this.setPreference("missionPreviewEnabled",e)}getMissionPreviewEnabled(){return this.getPreference("missionPreviewEnabled",!1)??!1}getMissionPreviewPanelWidth(){return this.getPreference("missionPreviewPanelWidth",33)??33}setMissionPreviewPanelWidth(e){this.setPreference("missionPreviewPanelWidth",e)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=c({token:n,factory:n.\u0275fac,providedIn:"root"})};function oe(n,e=80){if(n.length<=e)return n;try{if(n.trim().startsWith("{")||n.trim().startsWith("[")){let t=JSON.parse(n),s=JSON.stringify(t);return s.length<=e?s:s.substring(0,e)+`...(${s.length} chars)`}}catch(t){}return n.substring(0,e)+"..."}var o=class{constructor(e,t){this.type=t;if(e.timestamp)this.timestamp=e.timestamp;else{let s=Math.random().toString(36).substring(2,7);this.timestamp=`${new Date().toISOString()}-${s}`}this.parentKey=e.parentKey,this.threadId=e.threadId,this.length=0}timestamp;parentKey;static type;length;threadId;get date(){let e=this.timestamp.lastIndexOf("-");if(e>0){let t=this.timestamp.substring(e+1);if(t.length===5&&/^[a-z0-9]+$/.test(t))return new Date(this.timestamp.substring(0,e))}return new Date(this.timestamp)}},q=class extends o{invite;constructor(e,t){super(e,t),this.invite=e.invite}buildAnswer(e){return new u({answer:e,parentKey:this.timestamp,invite:this.invite})}},F=class n extends o{static type="heartbeat";constructor(e){super(e,n.type)}},f=class n extends q{defaultValue;static type="invite";constructor(e){super(e,n.type),this.defaultValue=e.defaultValue}},He="InviteEventDefault",u=class n extends o{answer;invite;name;silent;static type="answer";constructor(e){super(e,n.type),this.answer=e.answer??"No answer",this.invite=e.invite,this.name=e.name,this.silent=e.silent}},A=class n extends o{speaker;text;static type="text";constructor(e){super(e,n.type),this.speaker=e.speaker,this.text=e.text}},B=class n extends o{chunk;static type="text_chunk";constructor(e){super(e,n.type),this.chunk=e.chunk,this.length=this.chunk.length}},M=class n extends o{warning;static type="warn";constructor(e){super(e,n.type),this.warning=e.warning}},h=class n extends o{error;static type="error";constructor(e){super(e,n.type),this.error=e.error}},b=class n extends q{options;optionalQuestion;allowFreeText;static type="choice";constructor(e){super(e,n.type),this.options=Array.isArray(e.options)?e.options:[],this.optionalQuestion=e.optionalQuestion,this.allowFreeText=e.allowFreeText??!1}},v=class n extends o{toolRequestId;name;args;static type="tool_request";constructor(e){super(e,n.type),this.toolRequestId=e.toolRequestId??this.timestamp,this.name=e.name,this.args=e.args,this.length=this.args.length+this.name.length+this.toolRequestId.length+20}buildResponse(e){return new m({output:e,toolRequestId:this.toolRequestId,parentKey:this.timestamp})}toSingleLineString(e=50){let t=oe(this.args,e);return`\u{1F527} ${this.name}(${t})`}},m=class n extends o{toolRequestId;output;static type="tool_response";constructor(e){if(super(e,n.type),this.toolRequestId=e.toolRequestId||this.timestamp||new Date().toISOString(),this.output=e.output,typeof this.output=="string")this.length=this.output.length+this.toolRequestId.length+20;else if(this.output.type==="text")this.length=this.output.content.length+this.toolRequestId.length+20;else if(this.output.type==="image"){let t=(this.output.width??0)*(this.output.height??0)/750;this.length=(t?t*3.5:this.output.content.length)+this.toolRequestId.length+20}else this.length=this.toolRequestId.length+20}getTextOutput(){return typeof this.output=="string"?this.output:this.output.type==="text"?this.output.content:this.output.type==="image"?`[Image: ${this.output.mimeType}]`:""}toSingleLineString(e=50){let t=this.getTextOutput(),s=oe(t,e),i=typeof this.output!="string"&&this.output.type==="image"?" [image]":"";return`\u2B91 ${s}${i}`}},O=class n extends o{static type="thinking";static debounce=5e3;constructor(e){super(e,n.type)}},y=class n extends o{summary;static type="summary";constructor(e){super(e,n.type),this.summary=e.summary,this.length=this.summary.length}toSingleLineString(e=80){return`\u{1F4CB} Summary: ${oe(this.summary,e)}`}},S=class n extends o{role;name;content;static type="message";constructor(e){super(e,n.type),this.role=e.role,this.name=e.name,this.content=e.content,this.length=this.content.map(t=>{if(t.type==="text")return t.content.length;if(t.type==="image"){let s=(t.width||0)*(t.height||0)/750;return s?s*3.5:t.content.length}return t.type==="audio"?t.transcription?.length??100:0}).reduce((t,s)=>t+s,0)}getTextContent(){return this.content.filter(e=>e.type==="text").map(e=>e.content).join(`
|
|
1
|
+
import{a as de,b as w}from"./chunk-JF3TWRKD.js";import{D as $,J as se,P as ce,R as re,S as ie,V as g,Wc as E,Z as c,a as T,b as C,ca as a,d,h as j,i as r,m as D,n as k,pa as le,t as te,u as ne}from"./chunk-KJ5SIUGY.js";var N=class n{http=a(E);projectState=a(w);getBaseUrl(){return`/api/projects/${this.projectState.getSelectedProjectIdOrThrow()}/threads`}listThreads(){return this.http.get(this.getBaseUrl())}listAllThreads(){return this.http.get("/api/threads")}getThread(e){return this.http.get(`${this.getBaseUrl()}/${e}`)}createThread(e){let t=e?{name:e}:{};return this.http.post(this.getBaseUrl(),t)}updateThread(e,t){return this.http.put(`${this.getBaseUrl()}/${e}`,{name:t})}updateThreadUsers(e,t){return this.http.put(`${this.getBaseUrl()}/${e}`,{users:t})}starThread(e){return this.http.post(`${this.getBaseUrl()}/${e}/star`,{})}unstarThread(e){return this.http.delete(`${this.getBaseUrl()}/${e}/star`)}deleteThread(e){return this.http.delete(`${this.getBaseUrl()}/${e}`)}stopThread(e){return this.http.post(`${this.getBaseUrl()}/${e}/stop`,{})}getThreadMessages(e){return this.http.get(`${this.getBaseUrl()}/${e}/messages`)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=c({token:n,factory:n.\u0275fac,providedIn:"root"})};var U=class n{selectedThreadIdSubject=new r(null);isLoadingSubject=new r(!1);isLoadingThreadListSubject=new r(!1);refreshThreadListSubject=new j;threadListSubject=new r([]);hasLoadedOncePerProject=new Map;currentProjectName=null;isLoading$=this.isLoadingSubject.asObservable();isLoadingThreadList$=this.isLoadingThreadListSubject.asObservable();threadApi=a(N);projectStateService=a(w);projectApi=a(de);projectName$=this.projectStateService.selectedProject$.pipe(te(e=>e?.name),se());constructor(){ne([this.projectName$,this.refreshThreadListSubject.asObservable().pipe(re(void 0))]).pipe(g(([e])=>{e!==this.currentProjectName&&(console.log("[THREAD_STATE] Project changed, clearing thread list"),this.threadListSubject.next([]),this.currentProjectName=e),e?this.hasLoadedOncePerProject.get(e)?console.log("[THREAD_STATE] Refreshing thread list for project",e,"(no spinner)"):(console.log("[THREAD_STATE] Initial load for project",e,"- showing spinner"),this.isLoadingThreadListSubject.next(!0)):(console.log("[THREAD_STATE] No project selected, hiding spinner"),this.isLoadingThreadListSubject.next(!1))}),ie(([e])=>e?(console.log("[THREAD_STATE] Fetching threads for project:",e),this.threadApi.listThreads().pipe(te(t=>({threads:t,projectName:e})),$(t=>(console.error("[THREAD_STATE] Error loading thread list:",t),D({threads:[],projectName:e}))))):(console.log("[THREAD_STATE] No project selected, returning empty list"),D({threads:[],projectName:null}))),g(({threads:e,projectName:t})=>{console.log("[THREAD_STATE] Thread list loaded:",e.length,"threads for project",t),t&&this.hasLoadedOncePerProject.set(t,!0),this.isLoadingThreadListSubject.next(!1),this.threadListSubject.next(e)})).subscribe()}threadList$=this.threadListSubject.asObservable();refreshSelectedThreadSubject=new j;selectedThread$=ne([this.projectName$,this.selectedThreadIdSubject.pipe(se()),this.refreshSelectedThreadSubject.pipe(re(void 0))]).pipe(ie(([e,t])=>!e||!t?D(null):(this.isLoadingSubject.next(!0),this.threadApi.getThread(t).pipe(ce({bufferSize:1,refCount:!0})))),g(()=>{this.isLoadingSubject.next(!1)}));selectThread(e){this.selectedThreadIdSubject.next(e)}getSelectedThreadId(){return this.selectedThreadIdSubject.value}getSelectedThreadIdOrThrow(){let e=this.selectedThreadIdSubject.value;if(!e)throw new Error("[THREAD_STATE] No thread selected");return e}clearSelection(){this.selectedThreadIdSubject.next(null)}stop(){let e=this.selectedThreadIdSubject.value;if(!e){console.error("[THREAD_STATE] Cannot stop: no thread selected");return}console.log("[THREAD_STATE] Stopping thread:",e),this.threadApi.stopThread(e).subscribe({next:t=>console.log("[THREAD_STATE] Stop signal sent:",t.message),error:t=>console.error("[THREAD_STATE] Error stopping thread:",t)})}refreshThreadList(){console.log("[THREAD_STATE] Manually refreshing thread list"),this.refreshThreadListSubject.next()}updateStarLocal(e,t,s){let P=this.threadListSubject.value.map(l=>{if(l.id!==e)return l;let p=l.starring||[];return t&&!p.includes(s)?C(T({},l),{starring:[...p,s]}):!t&&p.includes(s)?C(T({},l),{starring:p.filter(I=>I!==s)}):l});this.threadListSubject.next(P)}refreshSelectedThread(){this.refreshSelectedThreadSubject.next()}updateThreadUsers(e,t){return this.threadApi.updateThreadUsers(e,t).pipe(g(()=>{this.refreshThreadList()}),$(s=>(console.error("[THREAD_STATE] Error updating thread users:",s),k(()=>s))))}markDone(e){let t=this.projectStateService.getSelectedProjectId();if(!t){console.error("[THREAD_STATE] Cannot mark done: no project selected");return}this.projectApi.markThreadDone(t,e).subscribe({next:()=>this.refreshThreadList(),error:s=>console.error("[THREAD_STATE] Failed to mark thread as done:",s)})}markActive(e){let t=this.projectStateService.getSelectedProjectId();if(!t){console.error("[THREAD_STATE] Cannot mark active: no project selected");return}this.projectApi.markThreadActive(t,e).subscribe({next:()=>this.refreshThreadList(),error:s=>console.error("[THREAD_STATE] Failed to mark thread as active:",s)})}renameThread(e,t){let s=t.trim();return!s||s.length===0?(console.error("[THREAD_STATE] Cannot rename thread: name is empty after trimming"),k(()=>new Error("Thread name cannot be empty"))):(console.log("[THREAD_STATE] Renaming thread:",e,"to:",s),this.threadApi.updateThread(e,s).pipe(g(i=>{console.log("[THREAD_STATE] Thread renamed successfully:",i),this.refreshThreadList()}),$(i=>(console.error("[THREAD_STATE] Error renaming thread:",i),k(()=>i)))))}static \u0275fac=function(t){return new(t||n)};static \u0275prov=c({token:n,factory:n.\u0275fac,providedIn:"root"})};var ue=class n{http=a(E);usernameSubject=new r(null);authEnabledSubject=new r(!1);username$=this.usernameSubject.asObservable();authEnabled$=this.authEnabledSubject.asObservable();fetchCurrentUser(){return this.http.get("/api/user/me").pipe(g(e=>{this.usernameSubject.next(e.username),this.authEnabledSubject.next(e.authEnabled)}))}getUsername(){return this.usernameSubject.value}static \u0275fac=function(t){return new(t||n)};static \u0275prov=c({token:n,factory:n.\u0275fac,providedIn:"root"})};var L=class n{STORAGE_KEY="coday-preferences";isDesktopApp=!1;electronStorage=null;voiceLanguageSubject=new r("en-US");voiceLanguage$=this.voiceLanguageSubject.asObservable();voiceInputModeSubject=new r("browser");voiceInputMode$=this.voiceInputModeSubject.asObservable();enterToSendSubject=new r(!0);enterToSend$=this.enterToSendSubject.asObservable();voiceAnnounceEnabledSubject=new r(!1);voiceAnnounceEnabled$=this.voiceAnnounceEnabledSubject.asObservable();voiceModeSubject=new r("speech");voiceMode$=this.voiceModeSubject.asObservable();voiceReadFullTextSubject=new r(!1);voiceReadFullText$=this.voiceReadFullTextSubject.asObservable();voiceVolumeSubject=new r(.8);voiceVolume$=this.voiceVolumeSubject.asObservable();voiceRateSubject=new r(1.2);voiceRate$=this.voiceRateSubject.asObservable();selectedVoiceSubject=new r(null);selectedVoice$=this.selectedVoiceSubject.asObservable();printTechnicalMessagesSubject=new r(!1);printTechnicalMessages$=this.printTechnicalMessagesSubject.asObservable();hideTechnicalMessagesSubject=new r(!0);hideTechnicalMessages$=this.hideTechnicalMessagesSubject.asObservable();hideWarningMessagesSubject=new r(!1);hideWarningMessages$=this.hideWarningMessagesSubject.asObservable();agentNotificationEnabledSubject=new r(!1);agentNotificationEnabled$=this.agentNotificationEnabledSubject.asObservable();notificationSoundEnabledSubject=new r(!1);notificationSoundEnabled$=this.notificationSoundEnabledSubject.asObservable();browserNotificationEnabledSubject=new r(!1);browserNotificationEnabled$=this.browserNotificationEnabledSubject.asObservable();themeSubject=new r("light");theme$=this.themeSubject.asObservable();missionPreviewEnabledSubject=new r(!1);missionPreviewEnabled$=this.missionPreviewEnabledSubject.asObservable();constructor(){console.log("[PREFERENCES] Initializing preferences service"),typeof window<"u"&&window.codayDesktop?.storage&&(this.isDesktopApp=!0,this.electronStorage=window.codayDesktop.storage,console.log("[PREFERENCES] Running in desktop app mode with persistent storage")),this.initializePreferences()}initializePreferences(){this.isDesktopApp?this.loadPreferencesAsync():this.loadPreferencesSync()}loadPreferencesSync(){let e=this.getPreferenceSync("voiceLanguage","en-US")??"en-US";this.voiceLanguageSubject.next(e),console.log("[PREFERENCES] Voice language initialized to:",e);let t=this.getPreferenceSync("useEnterToSend",!0)??!0;this.enterToSendSubject.next(t),console.log("[PREFERENCES] Enter to send initialized to:",t);let s=this.getPreferenceSync("voiceAnnounceEnabled",!1)??!1;this.voiceAnnounceEnabledSubject.next(s);let i=this.getPreferenceSync("voiceMode","speech")??"speech";this.voiceModeSubject.next(i);let P=this.getPreferenceSync("voiceReadFullText",!1)??!1;this.voiceReadFullTextSubject.next(P);let l=this.getPreferenceSync("voiceVolume",.8)??.8;this.voiceVolumeSubject.next(l);let p=this.getPreferenceSync("voiceRate",1.2)??1.2;this.voiceRateSubject.next(p);let I=this.getPreferenceSync("selectedVoice",null)??null;this.selectedVoiceSubject.next(I);let _=this.getPreferenceSync("printTechnicalMessages",!1)??!1;this.printTechnicalMessagesSubject.next(_);let K=this.getPreferenceSync("hideTechnicalMessages",!0)??!0;this.hideTechnicalMessagesSubject.next(K);let G=this.getPreferenceSync("hideWarningMessages",!1)??!1;this.hideWarningMessagesSubject.next(G);let Q=this.getPreferenceSync("agentNotificationEnabled",!1)??!1;this.agentNotificationEnabledSubject.next(Q);let J=this.getPreferenceSync("notificationSoundEnabled",!0)??!0;this.notificationSoundEnabledSubject.next(J);let Y=this.getPreferenceSync("browserNotificationEnabled",!1)??!1;this.browserNotificationEnabledSubject.next(Y);let X=this.getPreferenceSync("theme","light")??"light";this.themeSubject.next(X);let Z=this.getPreferenceSync("missionPreviewEnabled",!1)??!1;this.missionPreviewEnabledSubject.next(Z);let ee=this.getPreferenceSync("voiceInputMode","browser")??"browser";this.voiceInputModeSubject.next(ee),console.log("[PREFERENCES] All preferences initialized successfully")}loadPreferencesAsync(){return d(this,null,function*(){let e=(yield this.getPreferenceAsync("voiceLanguage","en-US"))??"en-US";this.voiceLanguageSubject.next(e),console.log("[PREFERENCES] Voice language initialized to:",e);let t=(yield this.getPreferenceAsync("useEnterToSend",!0))??!0;this.enterToSendSubject.next(t),console.log("[PREFERENCES] Enter to send initialized to:",t);let s=(yield this.getPreferenceAsync("voiceAnnounceEnabled",!1))??!1;this.voiceAnnounceEnabledSubject.next(s);let i=(yield this.getPreferenceAsync("voiceMode","speech"))??"speech";this.voiceModeSubject.next(i);let P=(yield this.getPreferenceAsync("voiceReadFullText",!1))??!1;this.voiceReadFullTextSubject.next(P);let l=(yield this.getPreferenceAsync("voiceVolume",.8))??.8;this.voiceVolumeSubject.next(l);let p=(yield this.getPreferenceAsync("voiceRate",1.2))??1.2;this.voiceRateSubject.next(p);let I=(yield this.getPreferenceAsync("selectedVoice",null))??null;this.selectedVoiceSubject.next(I);let _=(yield this.getPreferenceAsync("printTechnicalMessages",!1))??!1;this.printTechnicalMessagesSubject.next(_);let K=(yield this.getPreferenceAsync("hideTechnicalMessages",!0))??!0;this.hideTechnicalMessagesSubject.next(K);let G=(yield this.getPreferenceAsync("hideWarningMessages",!1))??!1;this.hideWarningMessagesSubject.next(G);let Q=(yield this.getPreferenceAsync("agentNotificationEnabled",!1))??!1;this.agentNotificationEnabledSubject.next(Q);let J=(yield this.getPreferenceAsync("notificationSoundEnabled",!0))??!0;this.notificationSoundEnabledSubject.next(J);let Y=(yield this.getPreferenceAsync("browserNotificationEnabled",!1))??!1;this.browserNotificationEnabledSubject.next(Y);let X=(yield this.getPreferenceAsync("theme","light"))??"light";this.themeSubject.next(X);let Z=(yield this.getPreferenceAsync("missionPreviewEnabled",!1))??!1;this.missionPreviewEnabledSubject.next(Z);let ee=(yield this.getPreferenceAsync("voiceInputMode","browser"))??"browser";this.voiceInputModeSubject.next(ee),console.log("[PREFERENCES] All preferences initialized successfully (async)")})}getPreference(e,t){return this.getPreferenceSync(e,t)}getPreferenceSync(e,t){try{let s=localStorage.getItem(this.STORAGE_KEY);if(!s)return t;let i=JSON.parse(s);return i[e]!==void 0?i[e]:t}catch(s){return t}}getPreferenceAsync(e,t){return d(this,null,function*(){if(!this.electronStorage)return this.getPreferenceSync(e,t);try{let s=yield this.electronStorage.get(this.STORAGE_KEY);if(!s)return t;let i=JSON.parse(s);return i[e]!==void 0?i[e]:t}catch(s){return t}})}setPreference(e,t){this.isDesktopApp?this.setPreferenceAsync(e,t):this.setPreferenceSync(e,t)}setPreferenceSync(e,t){try{let s=localStorage.getItem(this.STORAGE_KEY),i=s?JSON.parse(s):{};i[e]=t,localStorage.setItem(this.STORAGE_KEY,JSON.stringify(i)),this.updateSubject(e,t)}catch(s){console.error("Failed to set preference:",s)}}setPreferenceAsync(e,t){return d(this,null,function*(){if(!this.electronStorage){this.setPreferenceSync(e,t);return}try{let s=yield this.electronStorage.get(this.STORAGE_KEY),i=s?JSON.parse(s):{};i[e]=t,yield this.electronStorage.set(this.STORAGE_KEY,JSON.stringify(i)),this.updateSubject(e,t)}catch(s){console.error("Failed to set preference:",s)}})}updateSubject(e,t){e==="voiceLanguage"&&this.voiceLanguageSubject.next(t),e==="useEnterToSend"&&this.enterToSendSubject.next(t),e==="voiceAnnounceEnabled"&&this.voiceAnnounceEnabledSubject.next(t),e==="voiceMode"&&this.voiceModeSubject.next(t),e==="voiceReadFullText"&&this.voiceReadFullTextSubject.next(t),e==="voiceVolume"&&this.voiceVolumeSubject.next(t),e==="voiceRate"&&this.voiceRateSubject.next(t),e==="selectedVoice"&&this.selectedVoiceSubject.next(t),e==="printTechnicalMessages"&&this.printTechnicalMessagesSubject.next(t),e==="hideTechnicalMessages"&&this.hideTechnicalMessagesSubject.next(t),e==="hideWarningMessages"&&this.hideWarningMessagesSubject.next(t),e==="agentNotificationEnabled"&&this.agentNotificationEnabledSubject.next(t),e==="notificationSoundEnabled"&&this.notificationSoundEnabledSubject.next(t),e==="browserNotificationEnabled"&&this.browserNotificationEnabledSubject.next(t),e==="theme"&&this.themeSubject.next(t),e==="voiceInputMode"&&this.voiceInputModeSubject.next(t),e==="missionPreviewEnabled"&&this.missionPreviewEnabledSubject.next(t)}setVoiceLanguage(e){console.log("[PREFERENCES] Setting voice language to:",e),this.setPreference("voiceLanguage",e)}getVoiceLanguage(){return this.getPreference("voiceLanguage","en-US")??"en-US"}setVoiceInputMode(e){console.log("[PREFERENCES] Setting voice input mode to:",e),this.setPreference("voiceInputMode",e)}getVoiceInputMode(){return this.getPreference("voiceInputMode","browser")??"browser"}setEnterToSend(e){console.log("[PREFERENCES] Setting Enter to send to:",e),this.setPreference("useEnterToSend",e)}getEnterToSend(){return this.getPreference("useEnterToSend",!1)??!1}setVoiceAnnounceEnabled(e){console.log("[PREFERENCES] Setting voice announce enabled to:",e),this.setPreference("voiceAnnounceEnabled",e)}getVoiceAnnounceEnabled(){return this.getPreference("voiceAnnounceEnabled",!1)??!1}setVoiceMode(e){console.log("[PREFERENCES] Setting voice mode to:",e),this.setPreference("voiceMode",e)}getVoiceMode(){return this.getPreference("voiceMode","speech")??"speech"}setVoiceReadFullText(e){console.log("[PREFERENCES] Setting voice read full text to:",e),this.setPreference("voiceReadFullText",e)}getVoiceReadFullText(){return this.getPreference("voiceReadFullText",!1)??!1}setVoiceVolume(e){let t=Math.max(0,Math.min(1,e));console.log("[PREFERENCES] Setting voice volume to:",t),this.setPreference("voiceVolume",t)}getVoiceVolume(){return this.getPreference("voiceVolume",.8)??.8}setVoiceRate(e){let t=Math.max(.5,Math.min(2,e));console.log("[PREFERENCES] Setting voice rate to:",t),this.setPreference("voiceRate",t)}getVoiceRate(){return this.getPreference("voiceRate",1.2)??1.2}setSelectedVoice(e){console.log("[PREFERENCES] Setting selected voice to:",e),this.setPreference("selectedVoice",e)}getSelectedVoice(){return this.getPreference("selectedVoice",null)??null}setPrintTechnicalMessages(e){console.log("[PREFERENCES] Setting print technical messages to:",e),this.setPreference("printTechnicalMessages",e)}getPrintTechnicalMessages(){return this.getPreference("printTechnicalMessages",!1)??!1}setHideTechnicalMessages(e){console.log("[PREFERENCES] Setting hide technical messages to:",e),this.setPreference("hideTechnicalMessages",e)}getHideTechnicalMessages(){return this.getPreference("hideTechnicalMessages",!0)??!0}setHideWarningMessages(e){console.log("[PREFERENCES] Setting hide warning messages to:",e),this.setPreference("hideWarningMessages",e)}getHideWarningMessages(){return this.getPreference("hideWarningMessages",!1)??!1}setAgentNotificationEnabled(e){console.log("[PREFERENCES] Setting agent notification enabled to:",e),this.setPreference("agentNotificationEnabled",e)}getAgentNotificationEnabled(){return this.getPreference("agentNotificationEnabled",!1)??!1}setNotificationSoundEnabled(e){console.log("[PREFERENCES] Setting notification sound enabled to:",e),this.setPreference("notificationSoundEnabled",e)}getNotificationSoundEnabled(){return this.getPreference("notificationSoundEnabled",!0)??!0}setBrowserNotificationEnabled(e){console.log("[PREFERENCES] Setting browser notification enabled to:",e),this.setPreference("browserNotificationEnabled",e)}getBrowserNotificationEnabled(){return this.getPreference("browserNotificationEnabled",!1)??!1}setMissionPreviewEnabled(e){this.setPreference("missionPreviewEnabled",e)}getMissionPreviewEnabled(){return this.getPreference("missionPreviewEnabled",!1)??!1}getMissionPreviewPanelWidth(){return this.getPreference("missionPreviewPanelWidth",33)??33}setMissionPreviewPanelWidth(e){this.setPreference("missionPreviewPanelWidth",e)}static \u0275fac=function(t){return new(t||n)};static \u0275prov=c({token:n,factory:n.\u0275fac,providedIn:"root"})};function oe(n,e=80){if(n.length<=e)return n;try{if(n.trim().startsWith("{")||n.trim().startsWith("[")){let t=JSON.parse(n),s=JSON.stringify(t);return s.length<=e?s:s.substring(0,e)+`...(${s.length} chars)`}}catch(t){}return n.substring(0,e)+"..."}var o=class{constructor(e,t){this.type=t;if(e.timestamp)this.timestamp=e.timestamp;else{let s=Math.random().toString(36).substring(2,7);this.timestamp=`${new Date().toISOString()}-${s}`}this.parentKey=e.parentKey,this.threadId=e.threadId,this.length=0}timestamp;parentKey;static type;length;threadId;get date(){let e=this.timestamp.lastIndexOf("-");if(e>0){let t=this.timestamp.substring(e+1);if(t.length===5&&/^[a-z0-9]+$/.test(t))return new Date(this.timestamp.substring(0,e))}return new Date(this.timestamp)}},q=class extends o{invite;constructor(e,t){super(e,t),this.invite=e.invite}buildAnswer(e){return new u({answer:e,parentKey:this.timestamp,invite:this.invite})}},F=class n extends o{static type="heartbeat";constructor(e){super(e,n.type)}},f=class n extends q{defaultValue;static type="invite";constructor(e){super(e,n.type),this.defaultValue=e.defaultValue}},He="InviteEventDefault",u=class n extends o{answer;invite;name;silent;static type="answer";constructor(e){super(e,n.type),this.answer=e.answer??"No answer",this.invite=e.invite,this.name=e.name,this.silent=e.silent}},A=class n extends o{speaker;text;static type="text";constructor(e){super(e,n.type),this.speaker=e.speaker,this.text=e.text}},B=class n extends o{chunk;static type="text_chunk";constructor(e){super(e,n.type),this.chunk=e.chunk,this.length=this.chunk.length}},M=class n extends o{warning;static type="warn";constructor(e){super(e,n.type),this.warning=e.warning}},h=class n extends o{error;static type="error";constructor(e){super(e,n.type),this.error=e.error}},b=class n extends q{options;optionalQuestion;allowFreeText;static type="choice";constructor(e){super(e,n.type),this.options=Array.isArray(e.options)?e.options:[],this.optionalQuestion=e.optionalQuestion,this.allowFreeText=e.allowFreeText??!1}},v=class n extends o{toolRequestId;name;args;static type="tool_request";constructor(e){super(e,n.type),this.toolRequestId=e.toolRequestId??this.timestamp,this.name=e.name,this.args=e.args,this.length=this.args.length+this.name.length+this.toolRequestId.length+20}buildResponse(e){return new m({output:e,toolRequestId:this.toolRequestId,parentKey:this.timestamp})}toSingleLineString(e=50){let t=oe(this.args,e);return`\u{1F527} ${this.name}(${t})`}},m=class n extends o{toolRequestId;output;static type="tool_response";constructor(e){if(super(e,n.type),this.toolRequestId=e.toolRequestId||this.timestamp||new Date().toISOString(),this.output=e.output,typeof this.output=="string")this.length=this.output.length+this.toolRequestId.length+20;else if(this.output.type==="text")this.length=this.output.content.length+this.toolRequestId.length+20;else if(this.output.type==="image"){let t=(this.output.width??0)*(this.output.height??0)/750;this.length=(t?t*3.5:this.output.content.length)+this.toolRequestId.length+20}else this.length=this.toolRequestId.length+20}getTextOutput(){return typeof this.output=="string"?this.output:this.output.type==="text"?this.output.content:this.output.type==="image"?`[Image: ${this.output.mimeType}]`:""}toSingleLineString(e=50){let t=this.getTextOutput(),s=oe(t,e),i=typeof this.output!="string"&&this.output.type==="image"?" [image]":"";return`\u2B91 ${s}${i}`}},O=class n extends o{static type="thinking";static debounce=5e3;constructor(e){super(e,n.type)}},y=class n extends o{summary;static type="summary";constructor(e){super(e,n.type),this.summary=e.summary,this.length=this.summary.length}toSingleLineString(e=80){return`\u{1F4CB} Summary: ${oe(this.summary,e)}`}},S=class n extends o{role;name;content;static type="message";constructor(e){super(e,n.type),this.role=e.role,this.name=e.name;let t=e.content;Array.isArray(t)?this.content=t.map(s=>typeof s=="string"?{type:"text",content:s}:s):typeof t=="string"?this.content=[{type:"text",content:t}]:t&&typeof t=="object"&&"type"in t?this.content=[t]:this.content=[],this.length=this.content.map(s=>{if(s.type==="text")return s.content.length;if(s.type==="image"){let i=(s.width||0)*(s.height||0)/750;return i?i*3.5:s.content.length}return s.type==="audio"?s.transcription?.length??100:0}).reduce((s,i)=>s+i,0)}getTextContent(){return this.content.filter(e=>e.type==="text").map(e=>e.content).join(`
|
|
2
2
|
`)}},V=class n extends o{threadId;name;summary;users;static type="thread_update";constructor(e){super(e,n.type),this.threadId=e.threadId,this.name=e.name,this.summary=e.summary,this.users=e.users}},z=class n extends o{filename;operation;size;mimeType;static type="file";constructor(e){super(e,n.type),this.filename=e.filename,this.operation=e.operation,this.size=e.size,this.mimeType=e.mimeType}toSingleLineString(){let e=this.operation==="created"?"\u{1F4C4}":this.operation==="updated"?"\u{1F4DD}":"\u{1F5D1}\uFE0F",t=this.size?` (${(this.size/1024).toFixed(1)} KB)`:"";return`${e} ${this.operation}: ${this.filename}${t}`}},H=class n extends o{authUrl;state;integrationName;static type="oauth_request";constructor(e){super(e,n.type),this.authUrl=e.authUrl,this.state=e.state,this.integrationName=e.integrationName}},R=class n extends o{subThreadId;agentName;static type="delegation";constructor(e){super(e,n.type),this.subThreadId=e.subThreadId,this.agentName=e.agentName}},W=class n extends o{code;state;integrationName;error;errorDescription;static type="oauth_callback";constructor(e){super(e,n.type),this.code=e.code,this.state=e.state,this.integrationName=e.integrationName,this.error=e.error,this.errorDescription=e.errorDescription}},fe={[S.type]:S,[u.type]:u,[b.type]:b,[R.type]:R,[h.type]:h,[F.type]:F,[f.type]:f,[v.type]:v,[m.type]:m,[A.type]:A,[B.type]:B,[O.type]:O,[M.type]:M,[V.type]:V,[y.type]:y,[z.type]:z,[H.type]:H,[W.type]:W};function ae(n){let e=fe[n.type];return e?new e(n):void 0}var Ye=[{id:"builtin-plan",name:"plan",description:"Build a plan to complete the given task",source:"builtin",commands:[`@ We start a 3 phase process to build a comprehensive execution plan for the following task:
|
|
3
3
|
|
|
4
4
|
<task>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as be,d as N,e as _e,f as Te,g as we,h as Oe,i as Pe,j as xe,k as ke,l as Ve,m as Ie,n as Ne,o as je,p as We,q as U,r as Re,s as Ae,u as De,v as Fe,w as Le,x as Be,y as ze,z as Ue}from"./chunk-
|
|
1
|
+
import{c as be,d as N,e as _e,f as Te,g as we,h as Oe,i as Pe,j as xe,k as ke,l as Ve,m as Ie,n as Ne,o as je,p as We,q as U,r as Re,s as Ae,u as De,v as Fe,w as Le,x as Be,y as ze,z as Ue}from"./chunk-3SKJ5SNK.js";import{a as $e}from"./chunk-WUU4G5YQ.js";import{a as pe,b as ge,e as me,f as he,g as ue}from"./chunk-OX7PDXEA.js";import{a as j}from"./chunk-Q2M4W42M.js";import{E as D,c as W,g as R,m as A,p as Se,q as Ce,x as ye,y as Ee,z as Me}from"./chunk-DDWYQORF.js";import{E as le,J as de,O as ve,Q as fe}from"./chunk-B46LXCLF.js";import{$b as h,Ab as x,Db as d,Fb as k,Jb as X,Jc as se,Ka as c,Kb as ee,Lb as te,Oc as ce,Pb as ne,Qb as V,Rb as ie,Sb as oe,T as p,Tb as s,V as J,Vb as y,Wa as E,Wb as re,Xa as Q,Z as P,Zb as g,_ as Y,_b as m,aa as K,ab as Z,ca as v,d as S,h as C,i as b,ia as B,ja as q,jb as M,jc as ae,lb as T,mb as w,pb as $,qb as z,rb as u,sb as a,tb as r,ub as f,ya as G,yc as I}from"./chunk-KJ5SIUGY.js";var qe=["determinateSpinner"];function Ge(l,e){if(l&1&&(B(),a(0,"svg",11),f(1,"circle",12),r()),l&2){let n=k();M("viewBox",n._viewBox()),c(),V("stroke-dasharray",n._strokeCircumference(),"px")("stroke-dashoffset",n._strokeCircumference()/2,"px")("stroke-width",n._circleStrokeWidth(),"%"),M("r",n._circleRadius())}}var Qe=new K("mat-progress-spinner-default-options",{providedIn:"root",factory:()=>({diameter:He})}),He=100,Ze=10,St=(()=>{class l{_elementRef=v(G);_noopAnimations;get color(){return this._color||this._defaultColor}set color(n){this._color=n}_color;_defaultColor="primary";_determinateCircle;constructor(){let n=v(Qe),t=de(),i=this._elementRef.nativeElement;this._noopAnimations=t==="di-disabled"&&!!n&&!n._forceAnimations,this.mode=i.nodeName.toLowerCase()==="mat-spinner"?"indeterminate":"determinate",!this._noopAnimations&&t==="reduced-motion"&&i.classList.add("mat-progress-spinner-reduced-motion"),n&&(n.color&&(this.color=this._defaultColor=n.color),n.diameter&&(this.diameter=n.diameter),n.strokeWidth&&(this.strokeWidth=n.strokeWidth))}mode;get value(){return this.mode==="determinate"?this._value:0}set value(n){this._value=Math.max(0,Math.min(100,n||0))}_value=0;get diameter(){return this._diameter}set diameter(n){this._diameter=n||0}_diameter=He;get strokeWidth(){return this._strokeWidth??this.diameter/10}set strokeWidth(n){this._strokeWidth=n||0}_strokeWidth;_circleRadius(){return(this.diameter-Ze)/2}_viewBox(){let n=this._circleRadius()*2+this.strokeWidth;return`0 0 ${n} ${n}`}_strokeCircumference(){return 2*Math.PI*this._circleRadius()}_strokeDashOffset(){return this.mode==="determinate"?this._strokeCircumference()*(100-this._value)/100:null}_circleStrokeWidth(){return this.strokeWidth/this.diameter*100}static \u0275fac=function(t){return new(t||l)};static \u0275cmp=E({type:l,selectors:[["mat-progress-spinner"],["mat-spinner"]],viewQuery:function(t,i){if(t&1&&X(qe,5),t&2){let o;ee(o=te())&&(i._determinateCircle=o.first)}},hostAttrs:["role","progressbar","tabindex","-1",1,"mat-mdc-progress-spinner","mdc-circular-progress"],hostVars:18,hostBindings:function(t,i){t&2&&(M("aria-valuemin",0)("aria-valuemax",100)("aria-valuenow",i.mode==="determinate"?i.value:null)("mode",i.mode),oe("mat-"+i.color),V("width",i.diameter,"px")("height",i.diameter,"px")("--mat-progress-spinner-size",i.diameter+"px")("--mat-progress-spinner-active-indicator-width",i.diameter+"px"),ie("_mat-animation-noopable",i._noopAnimations)("mdc-circular-progress--indeterminate",i.mode==="indeterminate"))},inputs:{color:"color",mode:"mode",value:[2,"value","value",I],diameter:[2,"diameter","diameter",I],strokeWidth:[2,"strokeWidth","strokeWidth",I]},exportAs:["matProgressSpinner"],decls:14,vars:11,consts:[["circle",""],["determinateSpinner",""],["aria-hidden","true",1,"mdc-circular-progress__determinate-container"],["xmlns","http://www.w3.org/2000/svg","focusable","false",1,"mdc-circular-progress__determinate-circle-graphic"],["cx","50%","cy","50%",1,"mdc-circular-progress__determinate-circle"],["aria-hidden","true",1,"mdc-circular-progress__indeterminate-container"],[1,"mdc-circular-progress__spinner-layer"],[1,"mdc-circular-progress__circle-clipper","mdc-circular-progress__circle-left"],[3,"ngTemplateOutlet"],[1,"mdc-circular-progress__gap-patch"],[1,"mdc-circular-progress__circle-clipper","mdc-circular-progress__circle-right"],["xmlns","http://www.w3.org/2000/svg","focusable","false",1,"mdc-circular-progress__indeterminate-circle-graphic"],["cx","50%","cy","50%"]],template:function(t,i){if(t&1&&(Z(0,Ge,2,8,"ng-template",null,0,ae),a(2,"div",2,1),B(),a(4,"svg",3),f(5,"circle",4),r()(),q(),a(6,"div",5)(7,"div",6)(8,"div",7),x(9,8),r(),a(10,"div",9),x(11,8),r(),a(12,"div",10),x(13,8),r()()()),t&2){let o=ne(1);c(4),M("viewBox",i._viewBox()),c(),V("stroke-dasharray",i._strokeCircumference(),"px")("stroke-dashoffset",i._strokeDashOffset(),"px")("stroke-width",i._circleStrokeWidth(),"%"),M("r",i._circleRadius()),c(4),u("ngTemplateOutlet",o),c(2),u("ngTemplateOutlet",o),c(2),u("ngTemplateOutlet",o)}},dependencies:[se],styles:[`.mat-mdc-progress-spinner{--mat-progress-spinner-animation-multiplier: 1;display:block;overflow:hidden;line-height:0;position:relative;direction:ltr;transition:opacity 250ms cubic-bezier(0.4, 0, 0.6, 1)}.mat-mdc-progress-spinner circle{stroke-width:var(--mat-progress-spinner-active-indicator-width, 4px)}.mat-mdc-progress-spinner._mat-animation-noopable,.mat-mdc-progress-spinner._mat-animation-noopable .mdc-circular-progress__determinate-circle{transition:none !important}.mat-mdc-progress-spinner._mat-animation-noopable .mdc-circular-progress__indeterminate-circle-graphic,.mat-mdc-progress-spinner._mat-animation-noopable .mdc-circular-progress__spinner-layer,.mat-mdc-progress-spinner._mat-animation-noopable .mdc-circular-progress__indeterminate-container{animation:none !important}.mat-mdc-progress-spinner._mat-animation-noopable .mdc-circular-progress__indeterminate-container circle{stroke-dasharray:0 !important}@media(forced-colors: active){.mat-mdc-progress-spinner .mdc-circular-progress__indeterminate-circle-graphic,.mat-mdc-progress-spinner .mdc-circular-progress__determinate-circle{stroke:currentColor;stroke:CanvasText}}.mat-progress-spinner-reduced-motion{--mat-progress-spinner-animation-multiplier: 1.25}.mdc-circular-progress__determinate-container,.mdc-circular-progress__indeterminate-circle-graphic,.mdc-circular-progress__indeterminate-container,.mdc-circular-progress__spinner-layer{position:absolute;width:100%;height:100%}.mdc-circular-progress__determinate-container{transform:rotate(-90deg)}.mdc-circular-progress--indeterminate .mdc-circular-progress__determinate-container{opacity:0}.mdc-circular-progress__indeterminate-container{font-size:0;letter-spacing:0;white-space:nowrap;opacity:0}.mdc-circular-progress--indeterminate .mdc-circular-progress__indeterminate-container{opacity:1;animation:mdc-circular-progress-container-rotate calc(1568.2352941176ms*var(--mat-progress-spinner-animation-multiplier)) linear infinite}.mdc-circular-progress__determinate-circle-graphic,.mdc-circular-progress__indeterminate-circle-graphic{fill:rgba(0,0,0,0)}.mat-mdc-progress-spinner .mdc-circular-progress__determinate-circle,.mat-mdc-progress-spinner .mdc-circular-progress__indeterminate-circle-graphic{stroke:var(--mat-progress-spinner-active-indicator-color, var(--mat-sys-primary))}@media(forced-colors: active){.mat-mdc-progress-spinner .mdc-circular-progress__determinate-circle,.mat-mdc-progress-spinner .mdc-circular-progress__indeterminate-circle-graphic{stroke:CanvasText}}.mdc-circular-progress__determinate-circle{transition:stroke-dashoffset 500ms cubic-bezier(0, 0, 0.2, 1)}.mdc-circular-progress__gap-patch{position:absolute;top:0;left:47.5%;box-sizing:border-box;width:5%;height:100%;overflow:hidden}.mdc-circular-progress__gap-patch .mdc-circular-progress__indeterminate-circle-graphic{left:-900%;width:2000%;transform:rotate(180deg)}.mdc-circular-progress__circle-clipper .mdc-circular-progress__indeterminate-circle-graphic{width:200%}.mdc-circular-progress__circle-right .mdc-circular-progress__indeterminate-circle-graphic{left:-100%}.mdc-circular-progress--indeterminate .mdc-circular-progress__circle-left .mdc-circular-progress__indeterminate-circle-graphic{animation:mdc-circular-progress-left-spin calc(1333ms*var(--mat-progress-spinner-animation-multiplier)) cubic-bezier(0.4, 0, 0.2, 1) infinite both}.mdc-circular-progress--indeterminate .mdc-circular-progress__circle-right .mdc-circular-progress__indeterminate-circle-graphic{animation:mdc-circular-progress-right-spin calc(1333ms*var(--mat-progress-spinner-animation-multiplier)) cubic-bezier(0.4, 0, 0.2, 1) infinite both}.mdc-circular-progress__circle-clipper{display:inline-flex;position:relative;width:50%;height:100%;overflow:hidden}.mdc-circular-progress--indeterminate .mdc-circular-progress__spinner-layer{animation:mdc-circular-progress-spinner-layer-rotate calc(5332ms*var(--mat-progress-spinner-animation-multiplier)) cubic-bezier(0.4, 0, 0.2, 1) infinite both}@keyframes mdc-circular-progress-container-rotate{to{transform:rotate(360deg)}}@keyframes mdc-circular-progress-spinner-layer-rotate{12.5%{transform:rotate(135deg)}25%{transform:rotate(270deg)}37.5%{transform:rotate(405deg)}50%{transform:rotate(540deg)}62.5%{transform:rotate(675deg)}75%{transform:rotate(810deg)}87.5%{transform:rotate(945deg)}100%{transform:rotate(1080deg)}}@keyframes mdc-circular-progress-left-spin{from{transform:rotate(265deg)}50%{transform:rotate(130deg)}to{transform:rotate(265deg)}}@keyframes mdc-circular-progress-right-spin{from{transform:rotate(-265deg)}50%{transform:rotate(-130deg)}to{transform:rotate(-265deg)}}
|
|
2
2
|
`],encapsulation:2,changeDetection:0})}return l})();var Ct=(()=>{class l{static \u0275fac=function(t){return new(t||l)};static \u0275mod=Q({type:l});static \u0275inj=Y({imports:[le]})}return l})();var L=class l{destroy$=new C;voices;currentUtterance=null;currentOnEndCallback=null;speakingSubject=new b(!1);speaking$=this.speakingSubject.asObservable();volume=.8;rate=1.2;language="en-US";selectedVoice;preferencesService=v(N);constructor(){this.initializeSpeechSynthesis(),this.subscribeToPreferences()}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),this.stopSpeech()}initializeSpeechSynthesis(){if(!("speechSynthesis"in window)){console.warn("[VOICE-SERVICE] Speech synthesis not available"),this.voices=new Promise(e=>e([]));return}this.voices=new Promise((e,n)=>{let t=speechSynthesis.getVoices();if(t.length)e(t);else{let i=setTimeout(()=>{n("no voices found")},2e3);speechSynthesis.addEventListener("voiceschanged",()=>{let o=speechSynthesis.getVoices();o.length&&(clearTimeout(i),e(o))})}}),console.log("[VOICE-SERVICE] Speech synthesis initialized")}subscribeToPreferences(){this.preferencesService.voiceVolume$.pipe(p(this.destroy$)).subscribe(e=>{this.volume=e,console.log("[VOICE-SERVICE] Volume updated to:",e)}),this.preferencesService.voiceRate$.pipe(p(this.destroy$)).subscribe(e=>{this.rate=e,console.log("[VOICE-SERVICE] Rate updated to:",e)}),this.preferencesService.voiceLanguage$.pipe(p(this.destroy$)).subscribe(e=>{this.language=e,console.log("[VOICE-SERVICE] Language updated to:",e),this.updateSelectedVoiceForLanguage()}),this.preferencesService.selectedVoice$.pipe(p(this.destroy$)).subscribe(e=>{this.setSelectedVoice(e)}),this.volume=this.preferencesService.getVoiceVolume(),this.rate=this.preferencesService.getVoiceRate(),this.language=this.preferencesService.getVoiceLanguage(),this.setSelectedVoice(this.preferencesService.getSelectedVoice())}isReady(){return"speechSynthesis"in window&&this.selectedVoice!==void 0}isSpeaking(){return speechSynthesis.speaking}speak(e,n){return S(this,null,function*(){if(!this.selectedVoice)return console.warn("[VOICE-SERVICE] No voice selected"),!1;if(!e.trim())return console.warn("[VOICE-SERVICE] No text to speak"),!1;let t=this.extractPlainText(e);if(!t.trim())return console.warn("[VOICE-SERVICE] No text to speak after markdown cleaning"),!1;this.stopSpeech();try{let i=new SpeechSynthesisUtterance(t);i.voice=this.selectedVoice,i.lang=this.selectedVoice.lang,i.volume=this.volume,i.rate=this.rate,this.currentOnEndCallback=n||null,n&&(i.onend=()=>{this.currentOnEndCallback===n&&(this.currentOnEndCallback=null,n())},i.onerror=()=>{this.currentOnEndCallback===n&&(this.currentOnEndCallback=null,n())}),this.currentUtterance=i,this.speakingSubject.next(!0);let o=i.onend,_=i.onerror;return i.onend=O=>{this.speakingSubject.next(!1),o&&o.call(i,O)},i.onerror=O=>{this.speakingSubject.next(!1),_&&_.call(i,O)},speechSynthesis.speak(i),console.log("[VOICE-SERVICE] Started speaking:",e.substring(0,50)+"..."),!0}catch(i){return console.error("[VOICE-SERVICE] Error speaking:",i),!1}})}stopSpeech(){if(this.currentUtterance||speechSynthesis.speaking){if(speechSynthesis.cancel(),this.currentUtterance=null,this.currentOnEndCallback){let e=this.currentOnEndCallback;this.currentOnEndCallback=null,e()}this.speakingSubject.next(!1),console.log("[VOICE-SERVICE] Speech stopped")}}ding(){try{let e=new(window.AudioContext||window.webkitAudioContext),n=e.createOscillator(),t=e.createGain();n.connect(t),t.connect(e.destination),n.frequency.setValueAtTime(800,e.currentTime),t.gain.setValueAtTime(.1,e.currentTime),t.gain.exponentialRampToValueAtTime(.01,e.currentTime+.1),n.start(e.currentTime),n.stop(e.currentTime+.1),console.log("[VOICE-SERVICE] Notification sound played")}catch(e){console.error("[VOICE-SERVICE] Notification sound failed:",e)}}getVoicesForLanguage(){return S(this,null,function*(){try{let e=this.language.slice(0,2),n=yield this.voices;if(!n||n.length===0)return console.warn("[VOICE-SERVICE] No voices available on system"),[];let t=n.filter(i=>i.lang.toLowerCase().startsWith(e)).sort((i,o)=>i.localService&&!o.localService?-1:!i.localService&&o.localService?1:i.name.localeCompare(o.name));return console.log("[VOICE-SERVICE] Found matching voices:",t.length,"for language:",e),t.map(i=>({name:i.name,lang:i.lang,localService:i.localService,default:i.default,displayName:this.formatVoiceDisplayName(i)}))}catch(e){return console.error("[VOICE-SERVICE] Error getting voices for language:",e),[]}})}formatVoiceDisplayName(e){let n=e.localService?"\u{1F3E0}":"\u2601\uFE0F",t=e.default?" \u2B50":"";return`${n} ${e.name} (${e.lang})${t}`}setSelectedVoice(e){return S(this,null,function*(){if(!e){this.selectedVoice=void 0;return}let[n,t]=e.split("|");if(!n||!t){this.selectedVoice=void 0;return}let i=(yield this.voices)?.find(o=>o.name===n&&o.lang===t);i?(this.selectedVoice=i,console.log("[VOICE-SERVICE] Selected voice:",i.name,i.lang)):(this.selectedVoice=void 0,console.warn("[VOICE-SERVICE] Voice not found:",n,t))})}updateSelectedVoiceForLanguage(){return S(this,null,function*(){let e=yield this.getVoicesForLanguage();if(e.length===0){console.warn("[VOICE-SERVICE] No voices available for language:",this.language),this.selectedVoice=void 0,this.preferencesService.setSelectedVoice(null);return}let n=this.preferencesService.getSelectedVoice();if(n){let[i,o]=n.split("|"),_=o?.slice(0,2),O=this.language.slice(0,2);if(_===O&&e.some(H=>H.name===i&&H.lang===o)){console.log("[VOICE-SERVICE] Keeping current voice for language:",n);return}}let t=e[0];if(t){let i=`${t.name}|${t.lang}`;this.preferencesService.setSelectedVoice(i),console.log("[VOICE-SERVICE] Auto-selected voice for language change:",t.displayName)}})}testSelectedVoice(){setTimeout(()=>{if(!this.selectedVoice){console.log("[VOICE-SERVICE] No voice selected for test");return}this.stopSpeech();let e=this.getTestText();e&&this.speak(e)},100)}getTestText(){let e=this.language.slice(0,2),n={fr:"Bonjour, ceci est un test de la voix s\xE9lectionn\xE9e.",en:"Hello, this is a test of the selected voice.",es:"Hola, esta es una prueba de la voz seleccionada.",de:"Hallo, dies ist ein Test der ausgew\xE4hlten Stimme.",it:"Ciao, questo \xE8 un test della voce selezionata.",pt:"Ol\xE1, este \xE9 um teste da voz selecionada.",ja:"\u3053\u3093\u306B\u3061\u306F\u3001\u3053\u308C\u306F\u9078\u629E\u3055\u308C\u305F\u97F3\u58F0\u306E\u30C6\u30B9\u30C8\u3067\u3059\u3002",ko:"\uC548\uB155\uD558\uC138\uC694, \uC774\uAC83\uC740 \uC120\uD0DD\uB41C \uC74C\uC131\uC758 \uD14C\uC2A4\uD2B8\uC785\uB2C8\uB2E4.",zh:"\u4F60\u597D\uFF0C\u8FD9\u662F\u6240\u9009\u8BED\u97F3\u7684\u6D4B\u8BD5\u3002",ru:"\u041F\u0440\u0438\u0432\u0435\u0442, \u044D\u0442\u043E \u0442\u0435\u0441\u0442 \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u043E\u0433\u043E \u0433\u043E\u043B\u043E\u0441\u0430.",ar:"\u0645\u0631\u062D\u0628\u0627\u060C \u0647\u0630\u0627 \u0627\u062E\u062A\u0628\u0627\u0631 \u0644\u0644\u0635\u0648\u062A \u0627\u0644\u0645\u062D\u062F\u062F."};return n[e]||n.en||"Hello, this is a test."}extractPlainText(e){let n=e.replace(/[\u{1F600}-\u{1F64F}]|[\u{1F300}-\u{1F5FF}]|[\u{1F680}-\u{1F6FF}]|[\u{1F1E0}-\u{1F1FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]|⭐/gu,"").replace(/```[\s\S]*?```/g,"code block").replace(/`([^`]+)`/g,"$1").replace(/\*\*\*(.*?)\*\*\*/g,"$1").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/~~(.*?)~~/g,"$1").replace(/#{1,6}\s*(.*)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/https?:\/\/[^\s]+/g,"link").replace(/ /g," ").replace(/&/g,"and").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"');return n=this.addNaturalPunctuation(n),n.replace(/\s+/g," ").trim()}addNaturalPunctuation(e){return e.replace(/\n+/g,`
|
|
3
3
|
`).split(`
|
|
4
4
|
`).map(n=>this.addPeriodIfNeeded(n.trim())).filter(n=>n.length>0).join(" ")}addPeriodIfNeeded(e){return e?/[.!?;:]$/.test(e)?e:e+".":""}static \u0275fac=function(n){return new(n||l)};static \u0275prov=P({token:l,factory:l.\u0275fac,providedIn:"root"})};var tt=(l,e)=>e.code,nt=(l,e)=>e.name+e.lang;function it(l,e){l&1&&(a(0,"div",17)(1,"mat-icon",39),s(2,"warning"),r(),a(3,"span",40),s(4," Browser notifications have been blocked. To enable them, please reset the site permissions in your browser settings. "),r()())}function ot(l,e){if(l&1&&(a(0,"option",25),s(1),r()),l&2){let n=e.$implicit;u("value",n.code),c(),re("",n.flag," ",n.label)}}function rt(l,e){l&1&&(a(0,"option",32),s(1,"Loading voices..."),r())}function at(l,e){l&1&&(a(0,"option",32),s(1,"No voice available"),r())}function st(l,e){if(l&1&&(a(0,"option",25),s(1),r()),l&2){let n=e.$implicit;u("value",n.name+"|"+n.lang),c(),y(" ",n.displayName," ")}}var Je=class l{destroy$=new C;selectedTheme="light";selectedVoiceLanguage="en-US";useEnterToSend=!1;printTechnicalMessages=!1;showTechnicalMessages=!0;showWarningMessages=!0;voiceInputMode="browser";voiceAnnounceEnabled=!1;voiceMode="speech";voiceReadFullText=!1;voiceVolume=80;voiceRate=120;agentNotificationEnabled=!1;notificationSoundEnabled=!0;browserNotificationEnabled=!1;browserNotificationDenied=!1;missionPreviewEnabled=!1;availableVoices=[];selectedVoiceId=null;loadingVoices=!1;voiceLanguageOptions=[{code:"fr-FR",label:"Fran\xE7ais",flag:"\u{1F1EB}\u{1F1F7}"},{code:"en-US",label:"English (US)",flag:"\u{1F1FA}\u{1F1F8}"},{code:"en-GB",label:"English (UK)",flag:"\u{1F1EC}\u{1F1E7}"},{code:"es-ES",label:"Espa\xF1ol",flag:"\u{1F1EA}\u{1F1F8}"},{code:"de-DE",label:"Deutsch",flag:"\u{1F1E9}\u{1F1EA}"},{code:"it-IT",label:"Italiano",flag:"\u{1F1EE}\u{1F1F9}"},{code:"pt-BR",label:"Portugu\xEAs",flag:"\u{1F1E7}\u{1F1F7}"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E",flag:"\u{1F1EF}\u{1F1F5}"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4",flag:"\u{1F1F0}\u{1F1F7}"},{code:"zh-CN",label:"\u4E2D\u6587 (\u7B80\u4F53)",flag:"\u{1F1E8}\u{1F1F3}"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",flag:"\u{1F1F7}\u{1F1FA}"},{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",flag:"\u{1F1F8}\u{1F1E6}"}];preferencesService=v(N);voiceSynthesisService=v(L);themeService=v(_e);ngOnInit(){this.selectedTheme=this.themeService.getCurrentTheme(),this.selectedVoiceLanguage=this.preferencesService.getVoiceLanguage(),this.useEnterToSend=this.preferencesService.getEnterToSend(),this.printTechnicalMessages=this.preferencesService.getPrintTechnicalMessages(),this.showTechnicalMessages=!this.preferencesService.getHideTechnicalMessages(),this.showWarningMessages=!this.preferencesService.getHideWarningMessages(),this.voiceInputMode=this.preferencesService.getVoiceInputMode(),this.voiceAnnounceEnabled=this.preferencesService.getVoiceAnnounceEnabled(),this.voiceMode=this.preferencesService.getVoiceMode(),this.voiceReadFullText=this.preferencesService.getVoiceReadFullText(),this.voiceVolume=Math.round(this.preferencesService.getVoiceVolume()*100),this.voiceRate=Math.round(this.preferencesService.getVoiceRate()*100),this.selectedVoiceId=this.preferencesService.getSelectedVoice(),this.agentNotificationEnabled=this.preferencesService.getAgentNotificationEnabled(),this.notificationSoundEnabled=this.preferencesService.getNotificationSoundEnabled(),this.browserNotificationEnabled=this.preferencesService.getBrowserNotificationEnabled(),this.missionPreviewEnabled=this.preferencesService.getMissionPreviewEnabled(),this.loadAvailableVoices(),this.themeService.currentTheme$.pipe(p(this.destroy$)).subscribe(e=>{this.selectedTheme=e}),this.preferencesService.voiceLanguage$.pipe(p(this.destroy$)).subscribe(e=>{this.selectedVoiceLanguage=e}),this.preferencesService.enterToSend$.pipe(p(this.destroy$)).subscribe(e=>{this.useEnterToSend=e}),this.preferencesService.printTechnicalMessages$.pipe(p(this.destroy$)).subscribe(e=>{this.printTechnicalMessages=e}),this.preferencesService.hideTechnicalMessages$.pipe(p(this.destroy$)).subscribe(e=>{this.showTechnicalMessages=!e}),this.preferencesService.hideWarningMessages$.pipe(p(this.destroy$)).subscribe(e=>{this.showWarningMessages=!e}),this.preferencesService.voiceInputMode$.pipe(p(this.destroy$)).subscribe(e=>{this.voiceInputMode=e}),this.preferencesService.voiceAnnounceEnabled$.pipe(p(this.destroy$)).subscribe(e=>{this.voiceAnnounceEnabled=e}),this.preferencesService.voiceMode$.pipe(p(this.destroy$)).subscribe(e=>{this.voiceMode=e}),this.preferencesService.voiceReadFullText$.pipe(p(this.destroy$)).subscribe(e=>{this.voiceReadFullText=e}),this.preferencesService.voiceVolume$.pipe(p(this.destroy$)).subscribe(e=>{this.voiceVolume=Math.round(e*100)}),this.preferencesService.voiceRate$.pipe(p(this.destroy$)).subscribe(e=>{this.voiceRate=Math.round(e*100)}),this.preferencesService.selectedVoice$.pipe(p(this.destroy$)).subscribe(e=>{this.selectedVoiceId=e}),this.preferencesService.voiceLanguage$.pipe(p(this.destroy$)).subscribe(()=>{this.loadAvailableVoices()}),this.preferencesService.agentNotificationEnabled$.pipe(p(this.destroy$)).subscribe(e=>{this.agentNotificationEnabled=e}),this.preferencesService.notificationSoundEnabled$.pipe(p(this.destroy$)).subscribe(e=>{this.notificationSoundEnabled=e}),this.preferencesService.browserNotificationEnabled$.pipe(p(this.destroy$)).subscribe(e=>{this.browserNotificationEnabled=e,this.checkNotificationPermission()}),this.preferencesService.missionPreviewEnabled$.pipe(p(this.destroy$)).subscribe(e=>{this.missionPreviewEnabled=e})}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}onThemeChange(){console.log("[OPTIONS] Theme changed to:",this.selectedTheme),this.themeService.setTheme(this.selectedTheme)}onVoiceLanguageChange(){console.log("[OPTIONS] Voice language changed to:",this.selectedVoiceLanguage),this.preferencesService.setVoiceLanguage(this.selectedVoiceLanguage)}onEnterToSendChange(){console.log("[OPTIONS] Enter to send changed to:",this.useEnterToSend),this.preferencesService.setEnterToSend(this.useEnterToSend)}onPrintTechnicalMessagesChange(){console.log("[OPTIONS] Print technical messages changed to:",this.printTechnicalMessages),this.preferencesService.setPrintTechnicalMessages(this.printTechnicalMessages)}onShowTechnicalMessagesChange(){let e=!this.showTechnicalMessages;console.log("[OPTIONS] Show technical messages changed to:",this.showTechnicalMessages,"(hide:",e,")"),this.preferencesService.setHideTechnicalMessages(e)}onShowWarningMessagesChange(){let e=!this.showWarningMessages;console.log("[OPTIONS] Show warning messages changed to:",this.showWarningMessages,"(hide:",e,")"),this.preferencesService.setHideWarningMessages(e)}onVoiceInputModeChange(e){let n=e.target.value;console.log("[OPTIONS] Voice input mode changed to:",n),this.preferencesService.setVoiceInputMode(n)}onVoiceAnnounceEnabledChange(){console.log("[OPTIONS] Voice announce enabled changed to:",this.voiceAnnounceEnabled),this.preferencesService.setVoiceAnnounceEnabled(this.voiceAnnounceEnabled)}onVoiceModeChange(){console.log("[OPTIONS] Voice mode changed to:",this.voiceMode),this.preferencesService.setVoiceMode(this.voiceMode)}onVoiceReadFullTextChange(){console.log("[OPTIONS] Voice read full text changed to:",this.voiceReadFullText),this.preferencesService.setVoiceReadFullText(this.voiceReadFullText)}onVoiceVolumeChange(){let e=this.voiceVolume/100;console.log("[OPTIONS] Voice volume changed to:",e),this.preferencesService.setVoiceVolume(e)}onVoiceRateChange(){let e=this.voiceRate/100;console.log("[OPTIONS] Voice rate changed to:",e),this.preferencesService.setVoiceRate(e)}loadAvailableVoices(){return S(this,null,function*(){this.loadingVoices=!0;try{this.availableVoices=yield this.voiceSynthesisService.getVoicesForLanguage(),console.log("[OPTIONS] Loaded",this.availableVoices.length,"voices for current language")}catch(e){console.error("[OPTIONS] Error loading voices:",e),this.availableVoices=[]}finally{this.loadingVoices=!1}})}onSelectedVoiceChange(){console.log("[OPTIONS] Selected voice changed to:",this.selectedVoiceId),this.preferencesService.setSelectedVoice(this.selectedVoiceId)}testVoice(){console.log("[OPTIONS] Testing voice with current settings"),this.voiceSynthesisService.testSelectedVoice()}onAgentNotificationEnabledChange(){console.log("[OPTIONS] Agent notification enabled changed to:",this.agentNotificationEnabled),this.preferencesService.setAgentNotificationEnabled(this.agentNotificationEnabled)}onNotificationSoundEnabledChange(){console.log("[OPTIONS] Notification sound enabled changed to:",this.notificationSoundEnabled),this.preferencesService.setNotificationSoundEnabled(this.notificationSoundEnabled)}onBrowserNotificationEnabledChange(){console.log("[OPTIONS] Browser notification enabled changed to:",this.browserNotificationEnabled),this.preferencesService.setBrowserNotificationEnabled(this.browserNotificationEnabled)}onMissionPreviewEnabledChange(){console.log("[OPTIONS] Mission preview panel enabled changed to:",this.missionPreviewEnabled),this.preferencesService.setMissionPreviewEnabled(this.missionPreviewEnabled)}checkNotificationPermission(){"Notification"in window&&(this.browserNotificationDenied=Notification.permission==="denied",console.log("[OPTIONS] Notification permission status:",Notification.permission))}static \u0275fac=function(n){return new(n||l)};static \u0275cmp=E({type:l,selectors:[["app-options-panel"]],decls:168,vars:37,consts:[[1,"options-content"],[1,"option-section"],[1,"section-title"],[1,"option-group"],[1,"radio-group"],[1,"option-radio"],["type","radio","name","theme","value","light",3,"ngModelChange","change","ngModel"],[1,"radio-mark"],["type","radio","name","theme","value","dark",3,"ngModelChange","change","ngModel"],["type","radio","name","theme","value","system",3,"ngModelChange","change","ngModel"],[1,"option-label"],["type","radio","name","enterBehavior",3,"ngModelChange","change","value","ngModel"],[1,"toggle-option"],["color","primary",3,"ngModelChange","change","ngModel"],[1,"option-label-with-hint"],[1,"option-hint"],["color","primary",3,"ngModelChange","change","ngModel","disabled"],[1,"notification-error"],["for","voice-input-mode-select",1,"option-label"],["id","voice-input-mode-select",1,"option-select",3,"change","value"],["value","browser"],["value","whisper"],["value","voice-message"],["for","voice-language-select",1,"option-label"],["id","voice-language-select",1,"option-select",3,"ngModelChange","change","ngModel"],[3,"value"],["type","radio","name","voiceAnnounce",3,"ngModelChange","change","value","ngModel"],["type","radio","name","voiceMode","value","speech",3,"ngModelChange","change","ngModel"],["type","radio","name","voiceMode","value","notification",3,"ngModelChange","change","ngModel"],["type","radio","name","voiceReadFull",3,"ngModelChange","change","value","ngModel"],["for","voice-select",1,"option-label"],["id","voice-select",1,"option-select",3,"ngModelChange","change","ngModel","disabled"],["value",""],["role","button","tabindex","0","title","Test voice with current settings",1,"test-voice-link",3,"click"],[1,"thread-name"],["for","voice-volume-slider",1,"option-label"],["id","voice-volume-slider","type","range","min","0","max","100","step","5",1,"option-slider",3,"ngModelChange","input","ngModel"],["for","voice-rate-slider",1,"option-label"],["id","voice-rate-slider","type","range","min","50","max","200","step","10",1,"option-slider",3,"ngModelChange","input","ngModel"],[1,"error-icon"],[1,"error-message"]],template:function(n,t){n&1&&(a(0,"div",0)(1,"div",1)(2,"div",2)(3,"mat-icon"),s(4,"palette"),r(),a(5,"span"),s(6,"Appearance"),r()(),a(7,"div",3)(8,"div",4)(9,"label",5)(10,"input",6),h("ngModelChange",function(o){return m(t.selectedTheme,o)||(t.selectedTheme=o),o}),d("change",function(){return t.onThemeChange()}),r(),f(11,"span",7),s(12," Light "),r(),a(13,"label",5)(14,"input",8),h("ngModelChange",function(o){return m(t.selectedTheme,o)||(t.selectedTheme=o),o}),d("change",function(){return t.onThemeChange()}),r(),f(15,"span",7),s(16," Dark "),r(),a(17,"label",5)(18,"input",9),h("ngModelChange",function(o){return m(t.selectedTheme,o)||(t.selectedTheme=o),o}),d("change",function(){return t.onThemeChange()}),r(),f(19,"span",7),s(20," System "),r()()()(),a(21,"div",1)(22,"div",2)(23,"mat-icon"),s(24,"chat_bubble_outline"),r(),a(25,"span"),s(26,"Messaging"),r()(),a(27,"div",3)(28,"span",10),s(29,"Send message behavior:"),r(),a(30,"div",4)(31,"label",5)(32,"input",11),h("ngModelChange",function(o){return m(t.useEnterToSend,o)||(t.useEnterToSend=o),o}),d("change",function(){return t.onEnterToSendChange()}),r(),f(33,"span",7),s(34," Enter to send "),r(),a(35,"label",5)(36,"input",11),h("ngModelChange",function(o){return m(t.useEnterToSend,o)||(t.useEnterToSend=o),o}),d("change",function(){return t.onEnterToSendChange()}),r(),f(37,"span",7),s(38," Enter for new line "),r()()(),a(39,"div",3)(40,"div",12)(41,"span",10),s(42,"Show technical messages"),r(),a(43,"mat-slide-toggle",13),h("ngModelChange",function(o){return m(t.showTechnicalMessages,o)||(t.showTechnicalMessages=o),o}),d("change",function(){return t.onShowTechnicalMessagesChange()}),r()()(),a(44,"div",3)(45,"div",12)(46,"span",10),s(47,"Show warning messages"),r(),a(48,"mat-slide-toggle",13),h("ngModelChange",function(o){return m(t.showWarningMessages,o)||(t.showWarningMessages=o),o}),d("change",function(){return t.onShowWarningMessagesChange()}),r()()(),a(49,"div",3)(50,"div",12)(51,"span",10),s(52,"Include technical messages in print"),r(),a(53,"mat-slide-toggle",13),h("ngModelChange",function(o){return m(t.printTechnicalMessages,o)||(t.printTechnicalMessages=o),o}),d("change",function(){return t.onPrintTechnicalMessagesChange()}),r()()()(),a(54,"div",1)(55,"div",2)(56,"mat-icon"),s(57,"rocket_launch"),r(),a(58,"span"),s(59,"Mission Control"),r()(),a(60,"div",3)(61,"div",12)(62,"div",14)(63,"span",10),s(64,"Side-by-side thread preview"),r(),a(65,"span",15),s(66,"Click a mission card to open a preview panel. Recommended for large screens."),r()(),a(67,"mat-slide-toggle",13),h("ngModelChange",function(o){return m(t.missionPreviewEnabled,o)||(t.missionPreviewEnabled=o),o}),d("change",function(){return t.onMissionPreviewEnabledChange()}),r()()()(),a(68,"div",1)(69,"div",2)(70,"mat-icon"),s(71,"notifications"),r(),a(72,"span"),s(73,"Notifications"),r()(),a(74,"div",3)(75,"div",12)(76,"span",10),s(77,"Notify when the agent answers or requests input"),r(),a(78,"mat-slide-toggle",13),h("ngModelChange",function(o){return m(t.agentNotificationEnabled,o)||(t.agentNotificationEnabled=o),o}),d("change",function(){return t.onAgentNotificationEnabledChange()}),r()()(),a(79,"div",3)(80,"div",12)(81,"span",10),s(82,"Notification sound"),r(),a(83,"mat-slide-toggle",16),h("ngModelChange",function(o){return m(t.notificationSoundEnabled,o)||(t.notificationSoundEnabled=o),o}),d("change",function(){return t.onNotificationSoundEnabledChange()}),r()()(),a(84,"div",3)(85,"div",12)(86,"span",10),s(87,"Browser notification"),r(),a(88,"mat-slide-toggle",16),h("ngModelChange",function(o){return m(t.browserNotificationEnabled,o)||(t.browserNotificationEnabled=o),o}),d("change",function(){return t.onBrowserNotificationEnabledChange()}),r()(),T(89,it,5,0,"div",17),r()(),a(90,"div",1)(91,"div",2)(92,"mat-icon"),s(93,"record_voice_over"),r(),a(94,"span"),s(95,"Voice & Speech"),r()(),a(96,"div",3)(97,"label",18),s(98,"Voice input method:"),r(),a(99,"select",19),d("change",function(o){return t.onVoiceInputModeChange(o)}),a(100,"option",20),s(101,"Browser (real-time)"),r(),a(102,"option",21),s(103,"Whisper (higher accuracy)"),r(),a(104,"option",22),s(105,"Voice message (send audio)"),r()()(),a(106,"div",3)(107,"label",23),s(108,"Voice recognition language:"),r(),a(109,"select",24),h("ngModelChange",function(o){return m(t.selectedVoiceLanguage,o)||(t.selectedVoiceLanguage=o),o}),d("change",function(){return t.onVoiceLanguageChange()}),$(110,ot,2,3,"option",25,tt),r()(),a(112,"div",3)(113,"span",10),s(114,"Automatic announcement:"),r(),a(115,"div",4)(116,"label",5)(117,"input",26),h("ngModelChange",function(o){return m(t.voiceAnnounceEnabled,o)||(t.voiceAnnounceEnabled=o),o}),d("change",function(){return t.onVoiceAnnounceEnabledChange()}),r(),f(118,"span",7),s(119," Enabled "),r(),a(120,"label",5)(121,"input",26),h("ngModelChange",function(o){return m(t.voiceAnnounceEnabled,o)||(t.voiceAnnounceEnabled=o),o}),d("change",function(){return t.onVoiceAnnounceEnabledChange()}),r(),f(122,"span",7),s(123," Disabled "),r()()(),a(124,"div",3)(125,"span",10),s(126,"Voice mode:"),r(),a(127,"div",4)(128,"label",5)(129,"input",27),h("ngModelChange",function(o){return m(t.voiceMode,o)||(t.voiceMode=o),o}),d("change",function(){return t.onVoiceModeChange()}),r(),f(130,"span",7),s(131," Voice synthesis "),r(),a(132,"label",5)(133,"input",28),h("ngModelChange",function(o){return m(t.voiceMode,o)||(t.voiceMode=o),o}),d("change",function(){return t.onVoiceModeChange()}),r(),f(134,"span",7),s(135," Sound notification "),r()()(),a(136,"div",3)(137,"span",10),s(138,"Message reading:"),r(),a(139,"div",4)(140,"label",5)(141,"input",29),h("ngModelChange",function(o){return m(t.voiceReadFullText,o)||(t.voiceReadFullText=o),o}),d("change",function(){return t.onVoiceReadFullTextChange()}),r(),f(142,"span",7),s(143," Full message "),r(),a(144,"label",5)(145,"input",29),h("ngModelChange",function(o){return m(t.voiceReadFullText,o)||(t.voiceReadFullText=o),o}),d("change",function(){return t.onVoiceReadFullTextChange()}),r(),f(146,"span",7),s(147," First paragraphs only "),r()()(),a(148,"div",3)(149,"label",30),s(150,"Selected voice:"),r(),a(151,"select",31),h("ngModelChange",function(o){return m(t.selectedVoiceId,o)||(t.selectedVoiceId=o),o}),d("change",function(){return t.onSelectedVoiceChange()}),T(152,rt,2,0,"option",32),T(153,at,2,0,"option",32),$(154,st,2,2,"option",25,nt),r(),f(156,"div",10),a(157,"a",33),d("click",function(){return t.testVoice()}),a(158,"span",34),s(159,"Test voice"),r()()(),a(160,"div",3)(161,"label",35),s(162),r(),a(163,"input",36),h("ngModelChange",function(o){return m(t.voiceVolume,o)||(t.voiceVolume=o),o}),d("input",function(){return t.onVoiceVolumeChange()}),r()(),a(164,"div",3)(165,"label",37),s(166),r(),a(167,"input",38),h("ngModelChange",function(o){return m(t.voiceRate,o)||(t.voiceRate=o),o}),d("input",function(){return t.onVoiceRateChange()}),r()()()()),n&2&&(c(10),g("ngModel",t.selectedTheme),c(4),g("ngModel",t.selectedTheme),c(4),g("ngModel",t.selectedTheme),c(14),u("value",!0),g("ngModel",t.useEnterToSend),c(4),u("value",!1),g("ngModel",t.useEnterToSend),c(7),g("ngModel",t.showTechnicalMessages),c(5),g("ngModel",t.showWarningMessages),c(5),g("ngModel",t.printTechnicalMessages),c(14),g("ngModel",t.missionPreviewEnabled),c(11),g("ngModel",t.agentNotificationEnabled),c(5),g("ngModel",t.notificationSoundEnabled),u("disabled",!t.agentNotificationEnabled),c(5),g("ngModel",t.browserNotificationEnabled),u("disabled",!t.agentNotificationEnabled||t.browserNotificationDenied),c(),w(t.browserNotificationDenied?89:-1),c(10),u("value",t.voiceInputMode),c(10),g("ngModel",t.selectedVoiceLanguage),c(),z(t.voiceLanguageOptions),c(7),u("value",!0),g("ngModel",t.voiceAnnounceEnabled),c(4),u("value",!1),g("ngModel",t.voiceAnnounceEnabled),c(8),g("ngModel",t.voiceMode),c(4),g("ngModel",t.voiceMode),c(8),u("value",!0),g("ngModel",t.voiceReadFullText),c(4),u("value",!1),g("ngModel",t.voiceReadFullText),c(6),g("ngModel",t.selectedVoiceId),u("disabled",t.loadingVoices||t.availableVoices.length===0),c(),w(t.loadingVoices?152:-1),c(),w(!t.loadingVoices&&t.availableVoices.length===0?153:-1),c(),z(t.availableVoices),c(8),y("Volume: ",t.voiceVolume,"%"),c(),g("ngModel",t.voiceVolume),c(3),y("Speed: ",t.voiceRate,"%"),c(),g("ngModel",t.voiceRate))},dependencies:[D,Ee,Me,W,Ce,ye,Se,R,A,j,$e],styles:['.options-content[_ngcontent-%COMP%]{padding:0;width:100%}.option-group[_ngcontent-%COMP%]{padding:0 1rem 1rem;margin-bottom:1rem;border-bottom:1px solid var(--color-border-light)}.option-group[_ngcontent-%COMP%]:last-child{margin-bottom:0;padding-bottom:0;border-bottom:none}.option-label[_ngcontent-%COMP%]{display:block;margin-bottom:.5rem;font-weight:500;color:var(--color-text);font-size:.875rem}.toggle-option[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;gap:1rem}.toggle-option[_ngcontent-%COMP%] .option-label[_ngcontent-%COMP%]{margin-bottom:0;flex:1}.toggle-option[_ngcontent-%COMP%] mat-slide-toggle[_ngcontent-%COMP%]{flex-shrink:0}.option-label-with-hint[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.25rem;flex:1}.option-label-with-hint[_ngcontent-%COMP%] .option-label[_ngcontent-%COMP%]{margin-bottom:0}.option-label-with-hint[_ngcontent-%COMP%] .option-hint[_ngcontent-%COMP%]{font-size:.775rem;color:var(--color-text-secondary);line-height:1.4}.option-select[_ngcontent-%COMP%]{width:100%;padding:.5rem;border:1px solid var(--color-border);border-radius:4px;background:var(--color-input-bg);color:var(--color-text);font-size:.875rem;cursor:pointer}.option-select[_ngcontent-%COMP%]:focus{outline:none;border-color:var(--color-primary);box-shadow:0 0 0 3px #7064fb1a}.option-select[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.option-select[_ngcontent-%COMP%] option[_ngcontent-%COMP%]{padding:.5rem}.option-checkbox[_ngcontent-%COMP%]{display:flex;align-items:center;cursor:pointer;font-size:.875rem;color:var(--color-text);-webkit-user-select:none;user-select:none}.option-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{display:none}.option-checkbox[_ngcontent-%COMP%] .checkmark[_ngcontent-%COMP%]{width:18px;height:18px;border:2px solid var(--color-border);border-radius:3px;margin-right:.75rem;display:flex;align-items:center;justify-content:center;transition:all .2s ease;flex-shrink:0}.option-checkbox[_ngcontent-%COMP%] .checkmark[_ngcontent-%COMP%]:after{content:"";width:10px;height:6px;border-left:2px solid transparent;border-bottom:2px solid transparent;transform:rotate(-45deg);transition:all .2s ease;opacity:0}.option-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]:checked + .checkmark[_ngcontent-%COMP%]{background-color:var(--color-primary);border-color:var(--color-primary)}.option-checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]:checked + .checkmark[_ngcontent-%COMP%]:after{border-left-color:#fff;border-bottom-color:#fff;opacity:1}.option-checkbox[_ngcontent-%COMP%]:hover .checkmark[_ngcontent-%COMP%]{border-color:var(--color-primary)}.option-checkbox[_ngcontent-%COMP%]:focus-within .checkmark[_ngcontent-%COMP%]{box-shadow:0 0 0 3px #7064fb1a}.option-section[_ngcontent-%COMP%]{padding-top:1rem;margin-top:1rem;border-top:2px solid var(--color-border)}.option-section[_ngcontent-%COMP%]:first-child{border-top:none;padding-top:0;margin-top:0}.section-title[_ngcontent-%COMP%]{margin:0 0 1rem;padding:0 1rem;font-size:.9rem;font-weight:600;color:var(--color-text);display:flex;align-items:center;gap:.5rem}.section-title[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}.radio-group[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.option-radio[_ngcontent-%COMP%]{display:flex;align-items:center;cursor:pointer;font-size:.875rem;color:var(--color-text);-webkit-user-select:none;user-select:none}.option-radio[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{display:none}.option-radio[_ngcontent-%COMP%] .radio-mark[_ngcontent-%COMP%]{width:16px;height:16px;border:2px solid var(--color-border);border-radius:50%;margin-right:.5rem;display:flex;align-items:center;justify-content:center;transition:all .2s ease;flex-shrink:0;position:relative}.option-radio[_ngcontent-%COMP%] .radio-mark[_ngcontent-%COMP%]:after{content:"";width:8px;height:8px;border-radius:50%;background-color:var(--color-primary);transition:all .2s ease;opacity:0;transform:scale(0)}.option-radio[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]:checked + .radio-mark[_ngcontent-%COMP%]{border-color:var(--color-primary)}.option-radio[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]:checked + .radio-mark[_ngcontent-%COMP%]:after{opacity:1;transform:scale(1)}.option-radio[_ngcontent-%COMP%]:hover .radio-mark[_ngcontent-%COMP%]{border-color:var(--color-primary)}.option-radio[_ngcontent-%COMP%]:focus-within .radio-mark[_ngcontent-%COMP%]{box-shadow:0 0 0 3px #7064fb1a}.option-slider[_ngcontent-%COMP%]{width:100%;height:6px;border-radius:3px;background:var(--color-bg-solid);outline:none;cursor:pointer;-webkit-appearance:none;appearance:none}.option-slider[_ngcontent-%COMP%]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:20px;height:20px;border-radius:50%;background:var(--color-primary);cursor:pointer;border:2px solid white;box-shadow:0 2px 6px #0003;transition:all .2s ease}.option-slider[_ngcontent-%COMP%]::-webkit-slider-thumb:hover{transform:scale(1.1);box-shadow:0 2px 8px #0000004d}.option-slider[_ngcontent-%COMP%]::-moz-range-thumb{width:20px;height:20px;border-radius:50%;background:var(--color-primary);cursor:pointer;border:2px solid white;box-shadow:0 2px 6px #0003;transition:all .2s ease}.option-slider[_ngcontent-%COMP%]::-moz-range-thumb:hover{transform:scale(1.1);box-shadow:0 2px 8px #0000004d}.option-slider[_ngcontent-%COMP%]::-webkit-slider-track{height:6px;border-radius:3px;background:var(--color-bg-secondary)}.option-slider[_ngcontent-%COMP%]::-moz-range-track{height:6px;border-radius:3px;background:var(--color-bg-secondary);border:none}.option-slider[_ngcontent-%COMP%]:focus{outline:none}.option-slider[_ngcontent-%COMP%]:focus::-webkit-slider-thumb{box-shadow:0 0 0 3px #7064fb4d,0 2px 6px #0003}.option-slider[_ngcontent-%COMP%]:focus::-moz-range-thumb{box-shadow:0 0 0 3px #7064fb4d,0 2px 6px #0003}.test-voice-btn[_ngcontent-%COMP%]{width:100%;padding:.75rem 1rem;background:var(--color-primary);color:#fff;border:none;border-radius:6px;font-size:.875rem;font-weight:500;cursor:pointer;transition:all .2s ease;display:flex;align-items:center;justify-content:center;gap:.5rem}.test-voice-btn[_ngcontent-%COMP%]:hover{background:var(--color-primary-hover);transform:translateY(-1px);box-shadow:0 2px 8px #7064fb4d}.test-voice-btn[_ngcontent-%COMP%]:active{transform:translateY(0);box-shadow:0 1px 4px #7064fb4d}.test-voice-btn[_ngcontent-%COMP%]:focus{outline:none;box-shadow:0 0 0 3px #7064fb4d}.test-voice-btn[_ngcontent-%COMP%]:disabled{background:var(--color-bg-secondary);color:var(--color-text-secondary);cursor:not-allowed;transform:none;box-shadow:none}.test-voice-link[_ngcontent-%COMP%]{text-decoration-thickness:1.5px;text-underline-offset:3px;background:transparent;border:none;padding:0;font-size:.775rem;font-weight:400;cursor:pointer;transition:all .2s ease;display:inline-flex;align-items:center;justify-content:center;gap:.5rem;text-decoration:underline}.test-voice-link[_ngcontent-%COMP%]:hover{color:var(--color-primary-hover, var(--color-primary));text-decoration-thickness:2px}.test-voice-link[_ngcontent-%COMP%]:active{opacity:.8}.test-voice-link[_ngcontent-%COMP%]:focus{outline:2px solid var(--color-primary);outline-offset:2px}.test-voice-link[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px}.notification-error[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.5rem;padding:.75rem;margin-top:.75rem;background-color:#d32f2f1a;border:1px solid rgba(211,47,47,.3);border-radius:6px;font-size:.8125rem;line-height:1.5}.notification-error[_ngcontent-%COMP%] .error-icon[_ngcontent-%COMP%]{color:#d32f2f;font-size:20px;width:20px;height:20px;flex-shrink:0;margin-top:2px}.notification-error[_ngcontent-%COMP%] .error-message[_ngcontent-%COMP%]{color:var(--color-text);flex:1}.notification-error[_ngcontent-%COMP%]{margin-top:.75rem;padding:.75rem;background-color:#f443361a;border:1px solid rgba(244,67,54,.3);border-radius:6px;display:flex;align-items:flex-start;gap:.5rem}.notification-error[_ngcontent-%COMP%] .error-icon[_ngcontent-%COMP%]{color:#f44336;font-size:20px;width:20px;height:20px;flex-shrink:0;margin-top:2px}.notification-error[_ngcontent-%COMP%] .error-message[_ngcontent-%COMP%]{font-size:.8125rem;color:var(--color-text);line-height:1.5;flex:1}']})};var Ye=class l{destroy$=new C;currentProject=null;currentThread=null;messagesSubject=new b([]);isThinkingSubject=new b(!1);currentChoiceSubject=new b(null);projectTitleSubject=new b("Coday");currentInviteEventSubject=new b(null);messageToRestoreSubject=new b("");threadUpdateEventSubject=new b(null);currentChoiceEvent=null;thinkingTimeout=null;accumulatedChunks="";streamingTextSubject=new b("");subThreadEventsSubject=new C;subThreadEvents$=this.subThreadEventsSubject.asObservable();subThreadEventBuffers=new Map;getBufferedSubThreadEvents(e){return this.subThreadEventBuffers.get(e)??[]}messages$=this.messagesSubject.asObservable();streamingText$=this.streamingTextSubject.asObservable();isThinking$=this.isThinkingSubject.asObservable();currentChoice$=this.currentChoiceSubject.asObservable();currentInviteEvent$=this.currentInviteEventSubject.asObservable();messageToRestore$=this.messageToRestoreSubject.asObservable();threadUpdateEvent$=this.threadUpdateEventSubject.asObservable();connectionStatus$;tabTitleService=null;eventStream=v(ze);messageApi=v(Ue);userService=v(be);constructor(){this.connectionStatus$=this.eventStream.connectionStatus$,this.initializeEventHandling()}setTabTitleService(e){this.tabTitleService=e}connectToThread(e,n){this.currentProject=e,this.currentThread=n,this.eventStream.connectToThread(e,n)}loadHistoryFromRest(e){for(let n of e){let t=Be(n);t&&this.handleEvent(t)}}resetMessages(){this.messagesSubject.next([]),this.currentChoiceSubject.next(null),this.currentInviteEventSubject.next(null),this.currentChoiceEvent=null,this.accumulatedChunks="",this.streamingTextSubject.next(""),this.subThreadEventBuffers.clear(),this.stopThinking()}sendMessage(e){if(!this.currentProject||!this.currentThread){console.error("[CODAY] Cannot send message: no project or thread selected");return}let n=this.currentInviteEventSubject.value;if(n){this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive(),this.currentInviteEventSubject.next(null);let t=n.buildAnswer(e);this.messageApi.sendMessage(t).subscribe({error:i=>{console.error("[CODAY] Send invite answer error:",i),this.currentInviteEventSubject.next(n),this.stopThinking()}})}else this.messageApi.sendFreeMessage(e).subscribe({error:t=>{console.error("[CODAY] Send error:",t)}})}sendChoice(e){if(!this.currentProject||!this.currentThread){console.error("[CODAY] Cannot send choice: no project or thread selected");return}if(this.currentChoiceEvent){this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive();let n=this.currentChoiceEvent.buildAnswer(e);this.currentChoiceSubject.next(null),this.currentChoiceEvent=null,this.messageApi.sendMessage(n).subscribe({next:()=>{},error:t=>{console.error("[CODAY-CHOICE] Choice error:",t),this.stopThinking()}})}else console.error("[CODAY-CHOICE] No choice event available for choice:",e)}deleteMessage(e){let n=this.messagesSubject.value.find(i=>i.id===e),t=this.extractTextContentFromMessage(n);return this.messageApi.deleteMessage(e).pipe(J(i=>{i.success&&(this.removeMessagesFromIndex(e),t.trim()&&this.messageToRestoreSubject.next(t))}))}getCurrentProjectTitle(){return this.projectTitleSubject.value}getCurrentInviteEvent(){return this.currentInviteEventSubject.value}setThinkingForPendingMessage(){this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive()}initializeEventHandling(){this.eventStream.events$.pipe(p(this.destroy$)).subscribe({next:e=>this.handleEvent(e),error:e=>console.error("[CODAY] Event stream error:",e),complete:()=>console.log("[CODAY] Event stream completed")})}handleEvent(e){if(e.threadId&&e.threadId!==this.currentThread){let n=this.subThreadEventBuffers.get(e.threadId);n?n.push(e):this.subThreadEventBuffers.set(e.threadId,[e]),this.subThreadEventsSubject.next(e);return}e instanceof Re?this.handleMessageEvent(e):e instanceof ke?this.handleTextChunkEvent(e):e instanceof xe?this.handleTextEvent(e):e instanceof Pe?this.handleAnswerEvent(e):e instanceof Ie?this.handleErrorEvent(e):e instanceof Ve?this.handleWarnEvent(e):e instanceof U?this.handleThinkingEvent(e):e instanceof je?this.handleToolRequestEvent(e):e instanceof We?this.handleToolResponseEvent(e):e instanceof Ne?this.handleChoiceEvent(e):e instanceof Te?this.handleHeartBeatEvent(e):e instanceof we?this.handleInviteEvent(e):e instanceof Ae?this.handleThreadUpdateEvent(e):e instanceof Fe?this.handleDelegationEvent(e):e instanceof De||e instanceof Le||console.warn("[CODAY] Unhandled event type:",e.type)}handleDelegationEvent(e){if(console.log("[CODAY] DelegationEvent received:",e.subThreadId,e.agentName),this.messagesSubject.value.findIndex(i=>i.subThreadId===e.subThreadId)===-1){let i={id:e.timestamp,role:"system",speaker:e.agentName,content:[{type:"text",content:""}],timestamp:new Date,type:"delegation",subThreadId:e.subThreadId,delegationAgentName:e.agentName};this.addMessage(i)}}handleThreadUpdateEvent(e){this.threadUpdateEventSubject.next(e)}handleMessageEvent(e){e.role==="assistant"&&this.accumulatedChunks&&(this.accumulatedChunks="",this.streamingTextSubject.next(""));let n={id:e.timestamp,role:e.role,speaker:e.name,content:e.content,timestamp:e.date,type:"text"};this.addMessage(n)}handleTextChunkEvent(e){this.accumulatedChunks+=e.chunk,this.streamingTextSubject.next(this.accumulatedChunks)}handleTextEvent(e){let n={id:e.timestamp,role:e.speaker?"assistant":"system",speaker:e.speaker??"System",content:[{type:"text",content:e.text}],timestamp:e.date,type:e.speaker?"text":"technical"};this.addMessage(n)}handleAnswerEvent(e){let n=this.currentInviteEventSubject.value;if(n){let i=!!e.parentKey&&e.parentKey===n.timestamp,o=!e.parentKey&&e.date>=n.date;(i||o)&&this.currentInviteEventSubject.next(null)}if(e.silent)return;let t={id:e.timestamp,role:"user",speaker:e.name??this.userService.getUsername()??"User",content:[{type:"text",content:e.answer}],timestamp:e.date,type:"text",parentKey:e.parentKey,invite:e.invite};this.addMessage(t)}handleErrorEvent(e){let n={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:`Error: ${JSON.stringify(e.error)}`}],timestamp:e.date,type:"error"};this.addMessage(n)}handleWarnEvent(e){let n={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:`Warning: ${JSON.stringify(e.warning)}`}],timestamp:e.date,type:"warning"};this.addMessage(n)}handleThinkingEvent(e){this.currentInviteEventSubject.value||this.currentChoiceEvent||(this.clearThinkingTimeout(),this.isThinkingSubject.next(!0),this.tabTitleService?.setSystemActive(),this.thinkingTimeout=setTimeout(()=>{this.isThinkingSubject.next(!1),this.thinkingTimeout=null,this.tabTitleService?.setSystemInactive()},U.debounce+1e3))}handleToolRequestEvent(e){let n={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:e.toSingleLineString()}],timestamp:e.date,type:"technical",eventId:e.timestamp};this.addMessage(n)}handleToolResponseEvent(e){let n={id:e.timestamp,role:"system",speaker:"System",content:[{type:"text",content:e.toSingleLineString()}],timestamp:e.date,type:"technical",eventId:e.timestamp};this.addMessage(n)}handleChoiceEvent(e){this.stopThinking(),this.currentChoiceEvent=e,this.tabTitleService?.setSystemInactive();let n=e.options.map(i=>({value:i,label:i})),t=e.optionalQuestion?`${e.optionalQuestion} ${e.invite}`:e.invite;this.currentChoiceSubject.next({options:n,label:t,allowFreeText:e.allowFreeText})}handleHeartBeatEvent(e){}handleInviteEvent(e){if(this.stopThinking(),e.invite===Oe)this.currentInviteEventSubject.next(e),this.tabTitleService?.setSystemInactive();else{let t={id:e.timestamp,role:"assistant",speaker:"Assistant",content:[{type:"text",content:e.invite}],timestamp:e.date,type:"text"};this.addMessage(t),this.messagesSubject.value.some(_=>_.parentKey===e.timestamp||_.role==="user"&&_.timestamp>e.date||_.role==="assistant"&&_.timestamp>e.date)||(this.currentInviteEventSubject.next(e),this.tabTitleService?.setSystemInactive())}}addMessage(e){let n=this.messagesSubject.value;n.some(t=>t.id===e.id)||this.messagesSubject.next([...n,e])}removeMessagesFromIndex(e){let n=this.messagesSubject.value,t=n.findIndex(o=>o.id===e);if(t===-1||t===0)return;let i=n.slice(0,t);this.messagesSubject.next(i),this.stopThinking()}extractTextContentFromMessage(e){return e?e.content.filter(n=>n.type==="text").map(n=>n.content).join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as E}from"./chunk-X7WD62KI.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-O7ZDJZQW.js";import"./chunk-S5XVTDPO.js";import{e as I}from"./chunk-L2CXQ5ZG.js";import"./chunk-VR3I4RKJ.js";import"./chunk-I2FVKUBH.js";import{a as L,d as b}from"./chunk-AEGHERYH.js";import"./chunk-Z43UATKA.js";import"./chunk-R7YB3V2E.js";import{a as $,c as H}from"./chunk-MZT6I3S3.js";import"./chunk-RX6XVTR7.js";import"./chunk-A7WS3RLV.js";import"./chunk-WUU4G5YQ.js";import"./chunk-DVUB4DDV.js";import"./chunk-N347WQAU.js";import"./chunk-MWPKXBXJ.js";import"./chunk-OX7PDXEA.js";import"./chunk-7EDSHFWH.js";import"./chunk-3ZLLFAXF.js";import"./chunk-Q2M4W42M.js";import"./chunk-DDWYQORF.js";import"./chunk-JF3TWRKD.js";import"./chunk-B46LXCLF.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-KJ5SIUGY.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-Y3VADJFG.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-KGJBI3SN.js";import"./chunk-S5XVTDPO.js";import{e as I}from"./chunk-3XRWFLI7.js";import"./chunk-VR3I4RKJ.js";import"./chunk-IFHVRSTC.js";import{a as L,d as b}from"./chunk-3SKJ5SNK.js";import"./chunk-Z43UATKA.js";import"./chunk-R7YB3V2E.js";import{a as $,c as H}from"./chunk-MZT6I3S3.js";import"./chunk-RX6XVTR7.js";import"./chunk-A7WS3RLV.js";import"./chunk-WUU4G5YQ.js";import"./chunk-DVUB4DDV.js";import"./chunk-N347WQAU.js";import"./chunk-MWPKXBXJ.js";import"./chunk-OX7PDXEA.js";import"./chunk-7EDSHFWH.js";import"./chunk-3ZLLFAXF.js";import"./chunk-Q2M4W42M.js";import"./chunk-DDWYQORF.js";import"./chunk-JF3TWRKD.js";import"./chunk-B46LXCLF.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-KJ5SIUGY.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{w as l,y as A,z as m}from"./chunk-
|
|
1
|
+
import{w as l,y as A,z as m}from"./chunk-3SKJ5SNK.js";import{a as u}from"./chunk-Z43UATKA.js";import{B as v,Z as S,ca as h,i as g}from"./chunk-KJ5SIUGY.js";var O=class c{eventStream=h(A);messageApi=h(m);pendingStates=new Map;popupCheckInterval=null;popupClosedAt=null;static POPUP_CLOSE_GRACE_MS=2e3;pendingRequest$=new g(null);messageHandler=e=>this.handlePopupMessage(e);storageHandler=e=>this.handleStorageEvent(e);constructor(){this.eventStream.events$.pipe(v(e=>e.type==="oauth_request")).subscribe(e=>this.handleOAuthRequest(e)),window.addEventListener("message",this.messageHandler),window.addEventListener("storage",this.storageHandler),this.drainLocalStorage()}ngOnDestroy(){window.removeEventListener("message",this.messageHandler),window.removeEventListener("storage",this.storageHandler),this.pendingRequest$.complete(),this.popupCheckInterval&&clearInterval(this.popupCheckInterval)}startPopupMonitoring(e,t){this.popupCheckInterval&&clearInterval(this.popupCheckInterval),this.popupCheckInterval=setInterval(()=>{if(e.closed){if(this.popupClosedAt===null){this.popupClosedAt=Date.now(),console.log("[OAuth Service] Popup closed, waiting for postMessage grace period...");return}if(Date.now()-this.popupClosedAt<c.POPUP_CLOSE_GRACE_MS)return;if(console.log("[OAuth Service] Grace period elapsed, popup closed by user"),clearInterval(this.popupCheckInterval),this.popupCheckInterval=null,this.popupClosedAt=null,this.pendingStates.has(t)){console.warn("[OAuth Service] OAuth cancelled - popup closed without completing authentication");let s=this.pendingStates.get(t);if(this.pendingStates.delete(t),s){let a=new l({state:t,integrationName:s,error:"user_cancelled",errorDescription:"User closed the popup without completing authentication"});this.messageApi.sendMessage(a).subscribe({next:()=>console.log("[OAuth Service] Cancellation sent to backend"),error:n=>console.error("[OAuth Service] Failed to send cancellation:",n)})}}}else this.popupClosedAt!==null&&(console.log("[OAuth Service] Popup reopened/navigating, resetting grace period"),this.popupClosedAt=null)},500)}openPopup(e){console.log("[OAuth Service] Opening popup from user gesture:",e.integrationName);let t=600,o=900,s=window.screenX+(window.outerWidth-t)/2,a=window.screenY+(window.outerHeight-o)/2,n=`width=${t},height=${o},left=${s},top=${a},popup=yes,resizable=yes,scrollbars=yes`,r=window.open(e.authUrl,"oauth_popup",n);console.log("[OAuth Service] Popup opened:",!!r),r?(r.focus(),this.startPopupMonitoring(r,e.state),this.pendingRequest$.next(null)):console.warn("[OAuth Service] Popup was blocked by the browser")}cancelRequest(e){console.log("[OAuth Service] OAuth cancelled by user via inline panel"),this.pendingStates.delete(e.state),this.pendingRequest$.next(null);let t=new l({state:e.state,integrationName:e.integrationName,error:"user_cancelled",errorDescription:"User dismissed the authorization panel"});this.messageApi.sendMessage(t).subscribe({next:()=>console.log("[OAuth Service] Cancellation sent to backend"),error:o=>console.error("[OAuth Service] Failed to send cancellation:",o)})}handleOAuthRequest(e){console.log("[OAuth Service] Received OAuthRequestEvent:",e.integrationName,e.state),this.pendingStates.set(e.state,e.integrationName),console.log("[OAuth Service] Pending states:",Array.from(this.pendingStates.keys())),this.pendingRequest$.next(e)}handlePopupMessage(e){if(console.log("[OAuth Service] Received postMessage:",e.origin,e.data),e.origin!==window.location.origin){console.warn("[OAuth Service] Rejected message from different origin:",e.origin);return}this.processCallbackData(e.data)}handleStorageEvent(e){e.key!==u||!e.newValue||(console.log("[OAuth Service] Received localStorage callback fallback"),this.drainLocalStorage())}drainLocalStorage(){let e=localStorage.getItem(u);if(e){localStorage.removeItem(u),console.log("[OAuth Service] Processing localStorage OAuth callback fallback");try{let t=JSON.parse(e);this.processCallbackData(t)}catch(t){console.error("[OAuth Service] Failed to parse localStorage OAuth callback:",t)}}}processCallbackData(e){let{code:t,state:o,error:s,errorDescription:a}=e??{};if(s){console.log("[OAuth Service] OAuth error received:",s,a);let i=this.pendingStates.get(o);if(i){this.pendingStates.delete(o),this.popupCheckInterval&&(clearInterval(this.popupCheckInterval),this.popupCheckInterval=null,this.popupClosedAt=null);let d=new l({state:o,integrationName:i,error:s,errorDescription:a});this.messageApi.sendMessage(d).subscribe({next:()=>console.log("[OAuth Service] Error callback sent to backend"),error:p=>console.error("[OAuth Service] Failed to send error callback:",p)})}return}if(!t){console.warn("[OAuth Service] Message missing code:",e);return}console.log("[OAuth Service] Processing callback - code:",t,"state:",o);let n=o?this.pendingStates.get(o):void 0,r=o;if(!n&&this.pendingStates.size===1){let i=this.pendingStates.entries().next().value;if(i){let[d,p]=i;console.warn("[OAuth Service] State missing from callback, using sole pending flow:",p),n=p,r=d}}if(!n){console.warn("[OAuth Service] Unknown or ambiguous state:",o,"Pending states:",Array.from(this.pendingStates.keys()));return}console.log("[OAuth Service] Found integration:",n),this.pendingStates.delete(r),this.popupCheckInterval&&(clearInterval(this.popupCheckInterval),this.popupCheckInterval=null,this.popupClosedAt=null);let f=new l({code:t,state:r,integrationName:n});console.log("[OAuth Service] Sending callback to backend..."),this.messageApi.sendMessage(f).subscribe({next:()=>console.log("[OAuth Service] Callback sent to backend successfully"),error:i=>console.error("[OAuth Service] Failed to send callback:",i)})}static \u0275fac=function(t){return new(t||c)};static \u0275prov=S({token:c,factory:c.\u0275fac,providedIn:"root"})};export{O as a};
|