1import{d as et}from"./chunk-RY5HQRYC.js";import{p as z}from"./chunk-BDPYG7QH.js";import{a as Ke}from"./chunk-UKFX7ZFT.js";import{a as de}from"./chunk-D6KOQZLJ.js";import{a as ce}from"./chunk-YBULNWC6.js";import{h as je,i as Ze,k as Je}from"./chunk-O2QQ5VAD.js";import{a as H}from"./chunk-4LING6RH.js";import{E as We,F as se,J as F,u as b,w as qe,x as Ue,z as Qe}from"./chunk-YUF7LLLH.js";import{a as le,b as _e}from"./chunk-ILO4ZXSP.js";import{C as ne,r as A}from"./chunk-HSR5XPRD.js";import{a as De,b as $e,e as we,f as re}from"./chunk-R6PN4VAS.js";import{Aa as oe,B as ye,Ba as ae,Q as Be}from"./chunk-E2CPCWXV.js";import{F as Xe,L as Ve,c as Le,i as ke,j as Ge,l as Ye,p as Fe,q as ze}from"./chunk-TDJPADBB.js";import{$c as P,Bd as ve,C as ue,Cc as I,Cd as ie,Fa as M,Fd as D,Ga as N,Gc as g,Gd as v,Hc as Ee,Hd as He,I as J,Ic as Me,Kc as h,La as ee,Mc as c,Pb as L,R as Se,Ra as p,Ua as ge,Ub as Oe,Uc as Ne,Vc as be,Wc as k,Yc as te,Z as y,ad as U,bd as B,e as j,ed as Re,fd as Ie,gd as Pe,ia as K,j as Z,ja as he,jc as Te,la as me,lc as u,nc as S,ne as xe,oc as Ae,qc as $,rc as w,sc as f,ta as fe,tc as o,td as G,uc as r,vc as C,vd as Y,xb as _,ya as T}from"./chunk-EB7A3FJJ.js";import{a as x}from"./chunk-NM5BXVII.js";import{a as Q,b as W}from"./chunk-E5QWB6YB.js";x();x();function ot(t,l){t&1&&(o(0,"p"),g(1,6),r())}function at(t,l){if(t&1&&(o(0,"p"),g(1,7),r()),t&2){let e=c(2);_(),Ee(e.maxLength),Me(1)}}function rt(t,l){if(t&1&&(o(0,"div",22),u(1,ot,2,0,"p")(2,at,2,1,"p"),r()),t&2){c();let e=k(10);_(),S(e.errors!=null&&e.errors.required?1:e.errors!=null&&e.errors.maxLength?2:-1)}}var lt=50,Ce=(()=>{class t{constructor(){this.dialogRef=T(De),this.data=T($e),this.maxLength=lt,this.title=this.data.initialTitle}submit(){let e=this.title.trim();!e||e.length>this.maxLength||this.dialogRef.close(e)}cancel(){this.dialogRef.close()}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275cmp=L({type:t,selectors:[["rename-conversation-dialog"]],decls:23,vars:6,consts:()=>{let e;e=$localize`Rename Chat`;let n;n=$localize`Chat name`;let i;i=$localize`Cancel`;let a;a=$localize`Save`;let s;s=$localize`Chat name is required`;let m;return m=$localize`Chat name must be ${"\uFFFD0\uFFFD"}:INTERPOLATION: characters or fewer`,[["form","ngForm"],["titleControl","ngModel"],e,n,i,a,s,m,[1,"flex-no-shrink","d-flex","pa-8"],[1,"h2","pt-16","px-16","flex-grow"],[3,"clicked"],[1,"dialog-content","mt-24"],[1,"px-24","pb-24",3,"ngSubmit"],["for","rename-chat-title",1,"form-label","required"],["type","text","id","rename-chat-title","name","title","autocomplete","off","required","","cdkFocusInitial","",1,"form-control","w-100",3,"ngModelChange","lazyMaxlength","ngModel"],[1,"d-flex","flex-wrap","form-text","mt-4"],["class","is-invalid",4,"ifInvalid"],[1,"ml-auto",3,"maxLength","string"],[1,"d-flex","flex-no-shrink","mt-24"],[1,"d-flex","ml-auto"],["type","button",1,"btn","md","secondary","mr-12",3,"click"],["type","submit",1,"btn","md","primary",3,"disabled"],[1,"is-invalid"]]},template:function(n,i){if(n&1){let a=I();o(0,"div",8)(1,"h2",9),g(2,2),r(),o(3,"close-button",10),h("clicked",function(){return i.cancel()}),r()(),o(4,"div",11)(5,"form",12,0),h("ngSubmit",function(){return i.submit()}),o(7,"label",13),g(8,3),r(),o(9,"input",14,1),Pe("ngModelChange",function(m){return M(a),Ie(i.title,m)||(i.title=m),N(m)}),r(),o(11,"div",15)(12,"div"),Oe(13,rt,3,1,"div",16),r(),C(14,"characters-left",17),r(),o(15,"div",18)(16,"div",19)(17,"button",20),h("click",function(){return i.cancel()}),o(18,"span"),g(19,4),r()(),o(20,"button",21)(21,"span"),g(22,5),r()()()()()()}if(n&2){let a=k(6),s=k(10);_(9),f("lazyMaxlength",i.maxLength),Re("ngModel",i.title),_(4),f("ifInvalid",s),_(),f("maxLength",i.maxLength)("string",i.title),_(6),f("disabled",a.invalid||!i.title.trim())}},dependencies:[we,Ve,ze,Le,ke,Ge,Xe,Fe,Ye,Ue,qe,Ke],encapsulation:2,changeDetection:0})}}return t})();var _t=(t,l)=>l.public_id;function st(t,l){if(t&1){let e=I();o(0,"button",22),h("click",function(){M(e);let i=c();return N(i.close())}),C(1,"icon",23),r()}}function ct(t,l){t&1&&C(0,"loader",20)}function dt(t,l){t&1&&C(0,"no-item",21)}function Ct(t,l){t&1&&C(0,"icon",29)}function mt(t,l){t&1&&C(0,"loader",31),t&2&&f("size",16)}function Tt(t,l){t&1&&C(0,"icon",32)}
1function pt(t,l){t&1&&(C(0,"icon",36),o(1,"span"),g(2,5),r())}function ut(t,l){t&1&&(C(0,"icon",37),o(1,"span"),g(2,6),r())}function St(t,l){if(t&1){let e=I();o(0,"div",26)(1,"button",27),h("click",function(){let i=M(e),a=i.$implicit,s=i.$index,m=c(2);return N(m.selectConversation(a,s))}),o(2,"span",28),P(3),r(),u(4,Ct,1,0,"icon",29),r(),o(5,"button",30),u(6,mt,1,1,"loader",31)(7,Tt,1,0,"icon",32),r(),o(8,"pfy-menu",33,0)(10,"button",34),h("click",function(){let i=M(e).$implicit,a=c(2);return N(a.togglePin(i,"sidebar"))}),u(11,pt,3,0)(12,ut,3,0),r(),o(13,"button",34),h("click",function(){let i=M(e).$implicit,a=c(2);return N(a.renameChat(i,"sidebar"))}),C(14,"icon",35),o(15,"span"),g(16,4),r()()()()}if(t&2){let e=l.$implicit,n=k(9),i=c(2);te("active",e.public_id===i.currentPublicId()),_(),te("text-normal",e.public_id!==i.currentPublicId()),f("title",e.title||i.resumeChatLabel),Te("aria-current",e.public_id===i.currentPublicId()?"true":null),_(2),B(" ",e.title||i.newChatLabel," "),_(),S(e.pinned_at?4:-1),_(),f("pfyMenuTriggerFor",n),_(),S(i.isPinning(e.public_id)?6:7),_(2),f("classList",i.forceDesktopMenus()?"force-desktop":"")("backdropClass",i.forceDesktopMenus()?"force-desktop":"pfy-menu-backdrop"),_(3),S(e.pinned_at?11:12)}}function ht(t,l){t&1&&C(0,"loader",20)}function ft(t,l){if(t&1&&(o(0,"div",24),$(1,St,17,13,"div",25,_t),r(),u(3,ht,1,0,"loader",20)),t&2){let e=c();_(),w(e.conversations()),_(2),S(e.loadingMore()?3:-1)}}var Ni=(()=>{class t{constructor(){this.chatbotService=T(z),this.usersService=T(se),this.analyticsService=T(F),this.liveAnnouncer=T(ye),this.dialogService=T(re),this.snackbarService=T(ne),this.destroyRef=T(ee),this.currentPublicId=v(null),this.chatbotAvatar=v(null),this.chatbotName=v.required(),this.fallbackIcon=v("common-chatbot"),this.isMobile=v(!1),this.closable=v(!0),this.searchActive=v(!1),this.forceDesktopMenus=v(!1),this.selected=D(),this.conversationUpdated=D(),this.newChatRequested=D(),this.closeRequested=D(),this.searchToggled=D(),this.conversations=p([]),this.loadingConversations=p(!0),this.nextOffset=p(0),this.loadingMore=p(!1),this.resumeChatLabel=$localize`:Tooltip on a sidebar conversation row that has not yet had a title generated:Resume chat`,this.newChatLabel=$localize`:Default placeholder for an untitled conversation:New Chat`,this.pinningPublicIds=p(new Set),this.cancelMessagesFetch=new j}static{this.PAGE_SIZE=30}ngOnInit(){this.usersService.isAuthenticated()?this.refresh():this.loadingConversations.set(!1)}refresh(){this.fetchPage(0,!0)}applyConversationUpdate(e){this.conversations.update(n=>n.map(i=>i.public_id===e.public_id?e:i))}fetchMore(){let e=this.nextOffset();e!==null&&this.fetchPage(e,!1)}fetchPage(e,n){this.loadingMore()||(this.loadingMore.set(!0),this.chatbotService.listConversations({limit:t.PAGE_SIZE,offset:e},{user:this.usersService.userData().id,has_messages:!0}).pipe(H(this.destroyRef)).subscribe(({results:i,next:a})=>{this.conversations.update(s=>n?i:[...s,...i]),this.loadingConversations.set(!1),this.loadingMore.set(!1),this.nextOffset.set(a?e+i.length:null)}))}selectConversation(e,n){this.cancelMessagesFetch.next(),ue({conversation:this.chatbotService.getConversation(e.public_id),page:this.chatbotService.getConversationMessages({conversation:e.id,pagination_method:"cursor"})}).pipe(H(this.destroyRef),he(this.cancelMessagesFetch)).subscribe(({conversation:a,page:s})=>{let m=[...s.results].reverse();this.selected.emit({conversation:a,messages:m,nextOlderUrl:s.next??null});let d=e.title||this.newChatLabel;this.liveAnnouncer.announce($localize`:Live announcement when a sidebar conversation is opened:Opened conversation: ${d}:title:`)});let i=Math.floor(A.now().diff(A.from(e.conversation_start),"days"));this.analyticsService.analyticsEvent({type:b.CHATBOT_HISTORY_ITEM_SELECTED,properties:{days_since_creation:i,list_position:n,is_pinned:!1,view_type:this.isMobile()?"mobile_drawer":"desktop_sidebar"}})}newChat(){this.newChatRequested.emit()}toggleSearch(){this.searchToggled.emit()}close(){this.closeRequested.emit()}isPinning(e){return this.pinningPublicIds().has(e)}togglePin(e,n){if(this.isPinning(e.public_id))return;let i=e.pinned_at===null,a=tt(e.conversation_start,A.now()),s=e.pinned_at!==null?tt(e.pinned_at,A.now()):0;this.pinningPublicIds.update(d=>new Set(d).add(e.public_id)),(i?this.chatbotService.pinConversation(e.public_id):this.chatbotService.unpinConversation(e.public_id)).pipe(y(()=>this.pinningPublicIds.update(d=>{let O=new Set(d);return O.delete(e.public_id),O})),H(this.destroyRef)).subscribe(d=>{this.conversationUpdated.emit(d),this.refresh(),this.snackbarService.success(i?$localize`:Snackbar after pinning a chat:Chat pinned`:$localize`:Snackbar after unpinning a chat:Chat unpinned`),this.analyticsService.analyticsEvent(i?{type:b.CHATBOT_HISTORY_ITEM_PINNED,properties:{location:n,days_since_creation:a}}:{type:b.CHATBOT_HISTORY_ITEM_UNPINNED,properties:{location:n,time_spent_pinned_days:s}})})}renameChat(e,n){let i=!!e.title&&e.title_is_autogenerated,a=e.title||this.newChatLabel;this.dialogService.smallDialog(Ce,{data:{initialTitle:a}}).closed.pipe(J(s=>!!s&&s!==e.title),H(this.destroyRef)).subscribe(s=>{this.chatbotService.renameConversation(e.public_id,s).pipe(H(this.destroyRef)).subscribe(m=>{this.conversationUpdated.emit(m),this.conversations.update(d=>d.map(O=>O.public_id===m.public_id?m:O)),this.snackbarService.success($localize`:Snackbar after renaming a chat:Chat has been renamed`),this.analyticsService.analyticsEvent({type:b.CHATBOT_HISTORY_ITEM_RENAMED,properties:{location:n,new_title_length:s.length,was_auto_generated:i}})})})}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275cmp=L({type:t,selectors:[["chatbot-history-sidebar"]],inputs:{currentPublicId:[1,"currentPublicId"],chatbotAvatar:[1,"chatbotAvatar"],chatbotName:[1,"chatbotName"],fallbackIcon:[1,"fallbackIcon"],isMobile:[1,"isMobile"],closable:[1,"closable"],searchActive:[1,"searchActive"],forceDesktopMenus:[1,"forceDesktopMenus"]},outputs:{selected:"selected",conversationUpdated:"conversationUpdated",newChatRequested:"newChatRequested",closeRequested:"closeRequested",searchToggled:"searchToggled"},decls:22,vars:11,consts:()=>{let e;e=$localize`Close chat menu`;let n;n=$localize`Close`;let i;i=$localize`Start a new chat to see it here.`;let a;a=$localize`New Chat`;let s;s=$localize`Search`;let m;m=$localize`Chats`;let d;d=$localize`Pinned`;let O;O=$localize`Chat options`;let X;X=$localize`Rename`;let V;V=$localize`Unpin`;let q;return q=$localize`:verb:Pin`,[["sidebarChatMenu",""],a,s,m,X,V,q,[1,"d-flex","align-items-center","gap-4","pl-12","pr-8","py-8","py-lg-12"],[1,"d-flex","align-items-center","gap-12","flex-grow","minw-0"],[1,"avatar","size-32"],[3,"fallbackIcon","manualOverrideSrc"],[1,"text-bold","text-truncate"],["type","button","aria-label",e,"tooltip",n,"cdkFocusInitial","",1,"btn","md","borderless"],[1,"pa-8","d-flex","flex-column","gap-4"],["type","button",1,"btn","md","borderless","w-100","justify-content-start",3,"click"],["name","common-comment-plus","aria-hidden","true",1,"size-20"],[1,"text-lg","text-base","text-normal","pl-4"],["name","common-search","aria-hidden","true",1,"size-20"],["scrollFade","","scrollFadeDistance","3%","infiniteScroll","",1,"flex-grow","minh-0","
1scroll-y","pa-8","pb-40","d-flex","flex-column",3,"scrolled","scrollWindow","infiniteScrollDisabled","fetchUntilScrollable"],[1,"px-12","py-8","mb-0","text-bold"],["padding","icon"],["message",i,1,"d-block","px-12","py-8","text-md"],["type","button","aria-label",e,"tooltip",n,"cdkFocusInitial","",1,"btn","md","borderless",3,"click"],["name","internal-chevron-left"],["role","list",1,"flex-grow"],["role","listitem",1,"chat-row","d-flex","align-items-center","gap-4","pr-8","pr-md-4","flex-no-shrink",3,"active"],["role","listitem",1,"chat-row","d-flex","align-items-center","gap-4","pr-8","pr-md-4","flex-no-shrink"],["type","button",1,"btn","borderless","flex-grow","justify-content-start","chat-row-main","minw-0","pl-8","pr-12","py-8",3,"click","title"],[1,"flex-grow","text-truncate","minw-0","text-lg","text-base"],["name","common-pin-outline","aria-label",d,1,"size-16","flex-no-shrink","text-quiet"],["type","button","tooltip",O,1,"btn","sm","borderless","chat-options-trigger","flex-no-shrink",3,"pfyMenuTriggerFor"],["padding","none",3,"size"],["name","internal-more"],[3,"classList","backdropClass"],["pfy-menu-item","","type","button",3,"click"],["name","internal-edit"],["name","common-pin-off"],["name","common-pin-outline"]]},template:function(n,i){n&1&&(o(0,"div",7)(1,"div",8)(2,"div",9),C(3,"profile-pic",10),r(),o(4,"h3",11),P(5),r()(),u(6,st,2,0,"button",12),r(),o(7,"div",13)(8,"button",14),h("click",function(){return i.newChat()}),C(9,"icon",15),o(10,"span",16),g(11,1),r()(),o(12,"button",14),h("click",function(){return i.toggleSearch()}),C(13,"icon",17),o(14,"span",16),g(15,2),r()()(),o(16,"div",18),h("scrolled",function(){return i.fetchMore()}),o(17,"h4",19),g(18,3),r(),u(19,ct,1,0,"loader",20)(20,dt,1,0,"no-item",21)(21,ft,4,1),r()),n&2&&(_(3),f("fallbackIcon",i.fallbackIcon())("manualOverrideSrc",i.chatbotAvatar()),_(2),U(i.chatbotName()),_(),S(i.closable()?6:-1),_(6),te("pressed",i.searchActive()),Te("aria-pressed",i.searchActive()),_(4),f("scrollWindow",!1)("infiniteScrollDisabled",i.loadingMore()||i.nextOffset()===null)("fetchUntilScrollable",i.conversations().length),_(3),S(i.loadingConversations()?19:i.conversations().length===0?20:21))},dependencies:[de,ae,ce,_e,le,Ze,je,Je,We,oe,et],styles:["[_nghost-%COMP%]{display:flex;flex-direction:column;flex:1 1 0;min-height:0}.chat-row[_ngcontent-%COMP%]{border-radius:var(--border-radius-base)}@media(max-width:879px){.chat-row[_ngcontent-%COMP%]{height:48px}}.chat-row[_ngcontent-%COMP%]:hover, .chat-row[_ngcontent-%COMP%]:focus-within, .chat-row[_ngcontent-%COMP%]:has(.chat-options-trigger[aria-expanded=true]){background:var(--n1-transp)}.chat-row.active[_ngcontent-%COMP%]{background:var(--n2-transp)}.chat-row[_ngcontent-%COMP%] .chat-row-main[_ngcontent-%COMP%]:hover, .chat-row[_ngcontent-%COMP%] .chat-row-main[_ngcontent-%COMP%]:active, .chat-row[_ngcontent-%COMP%] .chat-row-main.pressed[_ngcontent-%COMP%]{background:transparent!important}.chat-row[_ngcontent-%COMP%] .chat-row-main.btn[_ngcontent-%COMP%]{padding-right:0}@media(min-width:880px){.chat-options-trigger[_ngcontent-%COMP%]{display:none}.chat-row[_ngcontent-%COMP%]:hover .chat-options-trigger[_ngcontent-%COMP%], .chat-row[_ngcontent-%COMP%]:focus-within .chat-options-trigger[_ngcontent-%COMP%], .chat-row.active[_ngcontent-%COMP%] .chat-options-trigger[_ngcontent-%COMP%], .chat-row[_ngcontent-%COMP%]:has(.chat-options-trigger[aria-expanded=true]) .chat-options-trigger[_ngcontent-%COMP%]{display:inline-flex}}"],changeDetection:0})}}return t})();function tt(t,l){return Math.floor(l.diff(A.from(t),"days"))}x();var gt=["searchInput"],it=(t,l)=>l.public_id,Ot=(t,l)=>l.label;function At(t,l){t&1&&(o(0,"div",5),C(1,"loader",12),r())}function Et(t,l){t&1&&C(0,"no-item",10)}function Mt(t,l){if(t&1&&(o(0,"mark",20),P(1),r()),t&2){let e=c().$implicit;_(),U(e.text)}}function Nt(t,l){if(t&1&&(o(0,"span",21),P(1),r()),t&2){let e=c().$implicit;_(),U(e.text)}}function bt(t,l){if(t&1&&u(0,Mt,2,1,"mark",20)(1,Nt,2,1,"span",21),t&2){let e=l.$implicit;S(e.isMatch?0:1)}}function Rt(t,l){if(t&1&&(o(0,"div",17),P(1),G(2,"i18nPlural"),r()),t&2){let e=c().$implicit,n=c(3);_(),B(" ",Y(2,1,e.match_count,n.contentMatchesPluralMap)," ")}}function It(t,l){t&1&&C(0,"icon",18)}function Pt(t,l){if(t&1){let e=I();o(0,"button",15),h("click",function(){let i=M(e).$implicit,a=c(3);return N(a.selectConversation(i))}),o(1,"span",16)(2,"div"),$(3,bt,2,1,null,null,Ae),r(),u(5,Rt,3,4,"div",17),r(),u(6,It,1,0,"icon",18),o(7,"span",19),G(8,"dateFormat"),P(9),G(10,"dateFormat"),r()()}if(t&2){let e=l.$implicit,n=c(3);_(3),w(n.titleSegments(e.title||n.newChatLabel)),_(2),S(e.match_count>0?5:-1),_(),S(e.pinned_at?6:-1),_(),f("tooltip",Y(8,4,e.latest_message_timestamp,"MMM D, YYYY h:mm a")),_(2),B(" ",Y(10,7,e.latest_message_timestamp,"MMM D")," ")}}function vt(t,l){t&1&&C(0,"loader",12)}function Ht(t,l){if(t&1){let e=I();o(0,"div",13),h("scrolled",function(){M(e);let i=c(2);return N(i.fetchMoreFilter())}),$(1,Pt,11,10,"button",14,it),u(3,vt,1,0,"loader",12),r()}if(t&2){let e=c(2);f("scrollWindow",!1)("infiniteScrollDisabled",e.filterLoadingMore()||e.filterLoading()||e.filterNextOffset()===null)("fetchUntilScrollable",e.filterResults().length),_(),w(e.filterResults()),_(2),S(e.filterLoadingMore()?3:-1)}}function xt(t,l){if(t&1&&u(0,At,2,0,"div",5)(1,Et,1,0,"no-item",10)(2,Ht,4,4,"div",11),t&2){let e=c();S(e.filterLoading()?0:e.filterResults().length===0?1:2)}}function yt(t,l){t&1&&(o(0,"div",22),C(1,"loader",12),r())}function Bt(t,l){if(t&1){let e=I();o(0,"no-item",23)(1,"button",25),h("click",function(){M(e);let i=c(2);return N(i.chatbotService.requestNewChat())}),C(2,"icon",26),o(3,"span"),g(4,3),r()()()}}function Dt(t,l){t&1&&C(0,"icon",31)}function $t(t,l){if(t&1){let e=I();o(0,"button",15),h("click",function(){let i=M(e).$implicit,a=c(4);return N(a.selectConversation(i))}),o(1,"span",30),P(2),r(),u(3,Dt,1,0,"icon",31),o(4,"span",19),G(5,"dateFormat"),P(6),G(7,"dateFormat"),r()()}if(t&2){let e=l.$implicit,n=c(4);_(2),B(" ",e.title||n.newChatLabel," "),_(),S(e.pinned_at?3:-1),_(),f("tooltip",Y(5,4,e.latest_message_timestamp,"MMM D, YYYY h:mm a")),_(2),B(" ",Y(7,7,e.latest_message_timestamp,"MMM D")," ")}}function wt(t,l){if(t&1&&(o(0,"div")(1,"h3",28),P(2),r(),o(3,"div",29),$(4,$t,8,10,"button",14,it),r()()),t&2){let e=l.$implicit,n=c(3);_(2),B(" ",n.timeBucketLabel(e.label)," "),_(2),w(e.conversations)}}function Lt(t,l){t&1&&C(0,"loader",12)}function kt(t,l){if(t&1){let e=I();o(0,"div",27),h("scrolled",function(){M(e);let i=c(2);return N(i.fetchMore())}),$(1,wt,6,1,"div",null,Ot),u(3,Lt,1,0,"loader",12),r()}if(t&2){let e=c(2);f("scrollWindow",!1)("infiniteScrollDisabled",e.loadingMore()||e.nextOffset()===null)("fetchUntilScrollable",e.conversations().length),_(),w(e.groups()),_(2),S(e.loadingMore()?3:-1)}}function Gt(t,l){if(t&1&&u(0,yt,2,0,"div",22)(1,Bt,5,0,"no-item",23)(2,kt,4,4,"div",24),t&2){let e=c();S(e.loadingInitial()?0:e.conversations().length===0?1:2)}}var Qi=(()=>{class t{static{this.PAGE_SIZE=30}static{this.MIN_QUERY_LENGTH=3}constructor(){this.chatbotService=T(z),this.usersService=T(se),this.analyticsService=T(F),this.destroyRef=T(ee),this.active=v(!1),this.conversationSelected=D(),this.conversations=p([]),this.loadingInitial=p(!1),this.loadingMore=p(!1),this.nextOffset=p(0),this.query=p(""),this.trimmedQuery=ie(()=>this.query().trim()),this.committedQuery=p(""),this.filterMode=ie(()=>this.trimmedQuery().length>=t.MIN_QUERY_LENGTH&&this.committedQuery().length>=t.MIN_QUERY_LENGTH),this.filterResults=p([]),this.filterLoading=p(!1),this.filterLoadingMore=p(!1),this.filterNextOffset=p(null),this.searchRequestParam
1s={user:this.usersService.userData().id,has_messages:!0,ordering:"-title_matches,-match_count,-latest_message_timestamp"},this.newChatLabel=$localize`:Default placeholder for an untitled conversation:New Chat`,this.groups=ie(()=>this.chatbotService.groupConversationsByTime(this.conversations(),A.now())),this.searchInput=He("searchInput"),this.queryDebounced$=new j,this.contentMatchesPluralMap={"=1":$localize`1 content match`,other:$localize`:>1 content matches:# content matches`},ge(()=>{this.active()&&ve(()=>{this.trimmedQuery().length===0&&this.fetchBrowsePage(0,!0),this.searchInput().nativeElement.focus()})}),this.queryDebounced$.pipe(Se(300),K(e=>{let n=e.trim();return n.length<t.MIN_QUERY_LENGTH?(this.committedQuery.set(""),this.filterResults.set([]),this.filterNextOffset.set(null),this.filterLoading.set(!1),Z):(this.committedQuery.set(n),this.filterResults.set([]),this.filterNextOffset.set(null),this.filterLoading.set(!0),this.chatbotService.listConversations({limit:t.PAGE_SIZE,offset:0},W(Q({},this.searchRequestParams),{content__contains:n})).pipe(y(()=>this.filterLoading.set(!1))))}),H(this.destroyRef)).subscribe(({results:e,next:n,count:i})=>{this.filterResults.set(e),this.filterNextOffset.set(n?e.length:null),this.analyticsService.analyticsEvent({type:b.CHATBOT_SEARCH_QUERY_SUBMITTED,properties:{query_length:this.committedQuery().length,results_count:i}})})}onQueryInput(e){this.query.set(e),this.queryDebounced$.next(e)}titleSegments(e){return Be(e,this.committedQuery()).segments}fetchMore(){let e=this.nextOffset();e!==null&&this.fetchBrowsePage(e,!1)}fetchBrowsePage(e,n){this.loadingMore()||this.loadingInitial()||(n&&this.conversations().length===0?this.loadingInitial.set(!0):n||this.loadingMore.set(!0),this.chatbotService.listConversations({limit:t.PAGE_SIZE,offset:e},{user:this.usersService.userData().id,has_messages:!0,ordering:"-latest_message_timestamp"}).pipe(H(this.destroyRef),y(()=>{this.loadingInitial.set(!1),this.loadingMore.set(!1)})).subscribe(({results:i,next:a})=>{this.conversations.update(s=>n?i:[...s,...i]),this.nextOffset.set(a?e+i.length:null)}))}fetchMoreFilter(){let e=this.filterNextOffset();if(e===null||this.filterLoadingMore()||this.filterLoading())return;let n=this.trimmedQuery();n.length<t.MIN_QUERY_LENGTH||(this.filterLoadingMore.set(!0),this.chatbotService.listConversations({limit:t.PAGE_SIZE,offset:e},W(Q({},this.searchRequestParams),{content__contains:n})).pipe(H(this.destroyRef),y(()=>this.filterLoadingMore.set(!1))).subscribe(({results:i,next:a})=>{this.trimmedQuery()===n&&(this.filterResults.update(s=>[...s,...i]),this.filterNextOffset.set(a?e+i.length:null))}))}selectConversation(e){let i=(this.filterMode()?this.filterResults():this.conversations()).findIndex(a=>a.public_id===e.public_id);this.analyticsService.analyticsEvent({type:b.CHATBOT_SEARCH_RESULT_SELECTED,properties:{days_since_creation:Math.floor(A.now().diff(A.from(e.conversation_start),"days")),title_match:e.title_matches,content_matches:e.match_count,result_position:i}}),this.conversationSelected.emit(e)}applyConversationUpdate(e){let n=i=>i.map(a=>a.public_id===e.public_id?W(Q({},e),{title_matches:a.title_matches,match_count:a.match_count}):a);this.conversations.update(n),this.filterResults.update(n)}timeBucketLabel(e){switch(e){case"last_7_days":return $localize`:Time bucket heading in AI Agent search browse view:Last 7 days`;case"last_30_days":return $localize`:Time bucket heading in AI Agent search browse view:Last 30 days`;case"this_year":return $localize`:Time bucket heading in AI Agent search browse view:This year`;case"older":return $localize`:Time bucket heading in AI Agent search browse view:Older`}}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275cmp=L({type:t,selectors:[["chatbot-search"]],viewQuery:function(n,i){n&1&&Ne(i.searchInput,gt,5),n&2&&be()},inputs:{active:[1,"active"]},outputs:{conversationSelected:"conversationSelected"},decls:11,vars:2,consts:()=>{let e;e=$localize`Search for chats`;let n;n=$localize`Search`;let i;i=$localize`Search for chats`;let a;a=$localize`No matches`;let s;s=$localize`No conversations contain that phrase.`;let m;m=$localize`Pinned`;let d;d=$localize`Conversation is pinned`;let O;O=$localize`No Chats`;let X;X=$localize`Start a new chat to see it here.`;let V;V=$localize`New Chat`;let q;q=$localize`Pinned`;let E;return E=$localize`Conversation is pinned`,[["searchInput",""],n,i,V,[1,"d-flex","flex-column","flex-grow","minh-0","pt-16","pt-lg-80"],[1,"px-24"],[1,"h1","mb-12"],[1,"d-flex","align-items-center","gap-8","mb-8"],["for","chatbotSearchInput",1,"visually-hidden"],["id","chatbotSearchInput","type","search","autocomplete","off","maxlength","80","placeholder",e,1,"form-control","flex-grow",3,"input","value"],["logo","common-search","title",a,"message",s,1,"d-block","pa-40"],["infiniteScroll","",1,"flex-grow","minh-0","
1scroll-y","px-24","pb-40","pt-8","d-flex","flex-column","gap-4",3,"scrollWindow","infiniteScrollDisabled","fetchUntilScrollable"],["padding","icon"],["infiniteScroll","",1,"flex-grow","minh-0","scroll-y","px-24","pb-40","pt-8","d-flex","flex-column","gap-4",3,"scrolled","scrollWindow","infiniteScrollDisabled","fetchUntilScrollable"],["type","button",1,"btn","px-16","py-12","bg-n1","w-100","rounded-double","hoverable","align-items-center","gap-8","browse-row"],["type","button",1,"btn","px-16","py-12","bg-n1","w-100","rounded-double","hoverable","align-items-center","gap-8","browse-row",3,"click"],[1,"flex-grow","text-truncate","text-left","d-block"],[1,"text-sm","text-quiet"],["name","common-pin-outline","tooltip",m,"aria-label",d,1,"size-16","flex-no-shrink","text-quiet"],[1,"flex-no-shrink","text-quiet","text-sm",3,"tooltip"],[1,"mark-bold"],[1,"mx-0"],[1,"flex-grow","d-grid","place-content-center"],["logo","common-search","title",O,"message",X,1,"d-block","pa-40"],["infiniteScroll","",1,"flex-grow","minw-0","minh-0","scroll-y","px-24","pb-40","pt-8","d-flex","flex-column","gap-16",3,"scrollWindow","infiniteScrollDisabled","fetchUntilScrollable"],["type","button",1,"btn","primary","md","mt-12",3,"click"],["name","common-comment-plus","aria-hidden","true"],["infiniteScroll","",1,"flex-grow","minw-0","minh-0","scroll-y","px-24","pb-40","pt-8","d-flex","flex-column","gap-16",3,"scrolled","scrollWindow","infiniteScrollDisabled","fetchUntilScrollable"],[1,"py-8","text-md","text-quiet"],[1,"d-flex","flex-column","gap-4"],[1,"flex-grow","text-truncate","text-left"],["name","common-pin-outline","tooltip",q,"aria-label",E,1,"size-16","flex-no-shrink","text-quiet"]]},template:function(n,i){n&1&&(o(0,"div",4)(1,"div",5)(2,"h2",6),g(3,1),r(),o(4,"div",7)(5,"label",8),g(6,2),r(),o(7,"input",9,0),h("input",function(s){return i.onQueryInput(s.target.value)}),r()()(),u(9,xt,3,1)(10,Gt,3,1),r()),n&2&&(_(7),f("value",i.query()),_(2),S(i.filterMode()?9:10))},dependencies:[ce,de,ae,_e,le,oe,Qe,xe],styles:[".browse-row[_ngcontent-%COMP%]{transition:none}.browse-row[_ngcontent-%COMP%]:hover, .browse-row[_ngcontent-%COMP%]:focus-visible{box-shadow:inset 0 0 0 1px var(--border-color-base)}.is-tabbing[_nghost-%COMP%] .browse-row[_ngcontent-%COMP%]:hover, .is-tabbing [_nghost-%COMP%] .browse-row[_ngcontent-%COMP%]:hover, .is-tabbing[_nghost-%COMP%] .browse-row[_ngcontent-%COMP%]:focus-visible, .is-tabbing [_nghost-%COMP%] .browse-row[_ngcontent-%COMP%]:focus-visible{box-shadow:0 0 0 2px var(--white),0 0 0 4px var(--focus-outline-color)!important}"],changeDetection:0})}}return t})();x();var cn=(()=>{class t{constructor(){this.chatbotService=T(z),this.dialogService=T(re),this.snackbarService=T(ne),this.analyticsService=T(F),this.newChatLabel=$localize`:Default placeholder for an untitled conversation:New Chat`,this.pinningPublicIds=p(new Set)}isPinning(e){return this.pinningPublicIds().has(e)}togglePin(e,n){if(this.isPinning(e.public_id))return Z;let i=e.pinned_at===null,a=nt(e.conversation_start,A.now()),s=e.pinned_at!==null?nt(e.pinned_at,A.now()):0;return this.pinningPublicIds.update(d=>new Set(d).add(e.public_id)),(i?this.chatbotService.pinConversation(e.public_id):this.chatbotService.unpinConversation(e.public_id)).pipe(y(()=>this.pinningPublicIds.update(d=>{let O=new Set(d);return O.delete(e.public_id),O})),me(()=>{this.snackbarService.success(i?$localize`:Snackbar after pinning a chat:Chat pinned`:$localize`:Snackbar after unpinning a chat:Chat unpinned`),this.analyticsService.analyticsEvent(i?{type:b.CHATBOT_HISTORY_ITEM_PINNED,properties:{location:n,days_since_creation:a}}:{type:b.CHATBOT_HISTORY_ITEM_UNPINNED,properties:{location:n,time_spent_pinned_days:s}})}))}renameChat(e,n){let i=!!e.title&&e.title_is_autogenerated,a=e.title||this.newChatLabel;return this.dialogService.smallDialog(Ce,{data:{initialTitle:a}}).closed.pipe(J(s=>!!s&&s!==e.title),K(s=>this.chatbotService.renameConversation(e.public_id,s).pipe(me(()=>{this.snackbarService.success($localize`:Snackbar after renaming a chat:Chat has been renamed`),this.analyticsService.analyticsEvent({type:b.CHATBOT_HISTORY_ITEM_RENAMED,properties:{location:n,new_title_length:s.length,was_auto_generated:i}})}))))}static{this.\u0275fac=function(n){return new(n||t)}}static{this.\u0275prov=fe({token:t,factory:t.\u0275fac,providedIn:"root"})}}return t})();function nt(t,l){return Math.floor(l.diff(A.from(t),"days"))}export{Ni as a,Qi as b,cn as c};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.