import{a as nt,b as ot,c as st}from"./chunk-7YL35ZIO.js";import{e as tt,g as it}from"./chunk-MZH7I7UK.js";import{a as et}from"./chunk-JEBQFVFV.js";import{a as qe,b as rt}from"./chunk-UV4NIRDR.js";import{a as Je}from"./chunk-7CAH5JY2.js";import"./chunk-PVT2TCFK.js";import"./chunk-LMC2BXXM.js";import"./chunk-XT6MQKXX.js";import"./chunk-KW7LGSS5.js";import"./chunk-AAHKRPJ3.js";import"./chunk-S7TPI5WJ.js";import"./chunk-F6YS3FBI.js";import"./chunk-S7UDHO3E.js";import"./chunk-SZQILDRF.js";import"./chunk-QIJGSTAO.js";import"./chunk-5U7RRVH2.js";import"./chunk-O3MLOUKJ.js";import"./chunk-2C3QPSQO.js";import"./chunk-R6EOTM56.js";import"./chunk-OIAL2MBO.js";import"./chunk-PEEQSXXX.js";import"./chunk-CUOWKLRV.js";import"./chunk-M7NRMR5C.js";import"./chunk-2DOD3TZP.js";import"./chunk-6LCLSCUC.js";import"./chunk-3RTUOFQH.js";import"./chunk-NOQGKTKU.js";import"./chunk-WQRIIPLB.js";import{h as Ye,i as Ke,k as Qe}from"./chunk-7ZRO5KWR.js";import"./chunk-VJNS2G4F.js";import"./chunk-NK5MR2BM.js";import"./chunk-ZHB7Y3RV.js";import"./chunk-CV7XZEMK.js";import"./chunk-SXGSJAWW.js";import"./chunk-U24TZDHA.js";import"./chunk-4OC5AVTP.js";import"./chunk-5BQ7EGVC.js";import"./chunk-E5AMFSXI.js";import"./chunk-EGB5EUWP.js";import{a as x,c as K}from"./chunk-UACQJK7R.js";import{R as ze,T as Fe,W as Ue,da as Ge,ea as We,ja as Ze,z as Y}from"./chunk-Q232IBQN.js";import{j as je}from"./chunk-LGT7QKWT.js";import"./chunk-Z3H43YNT.js";import{A as ke,Ba as Xe,C as Le,c as Re,d as He}from"./chunk-E4UUPK46.js";import"./chunk-AK5L5EKD.js";import{j as Be,k as De,l as Ie,m as Ve,n as $e}from"./chunk-K3AFQ46O.js";import"./chunk-WWNBTMQ7.js";import{$ as _e,$c as we,Ac as M,Ad as S,Cb as fe,Da as d,Db as Ee,E as ce,Ea as _,Ec as A,Fb as W,Fd as D,G as $,Ha as pe,Ic as u,Ja as Ce,K as k,Kc as r,Ma as ge,Ob as Te,Pa as g,Qa as be,Sa as j,Sc as ye,Tc as xe,Uc as q,Vc as L,Wc as y,X as de,Xb as ve,Zc as B,_c as z,c as oe,cc as Me,e as X,f as se,fd as Ne,g as re,ga as H,gd as Pe,ha as he,hc as Z,hd as F,j as U,ja as me,jc as T,lc as v,nc as Se,o as ae,oc as Oe,p as le,pc as Ae,qc as E,rc as a,sc as l,tc as C,v as G,wb as c,xa as O,za as ue}from"./chunk-O7RN3KYY.js";import"./chunk-T6QEVPBZ.js";import"./chunk-MPPP2QUX.js";import{a as P}from"./chunk-ZE2KCNEA.js";import{a as w,b as N}from"./chunk-CEWFFWI2.js";P();P();var ct={schedule(n,o){let e=setTimeout(n,o);return()=>clearTimeout(e)}};function dt(n){return n.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`)}function _t(n){return!!n&&n.nodeType===Node.ELEMENT_NODE}var Q;function ht(n,o){if(!Q){let e=Element.prototype;Q=e.matches||e.matchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector}return n.nodeType===Node.ELEMENT_NODE?Q.call(n,o):!1}function mt(n){let o={};return n.forEach(({propName:e,templateName:i,transform:t})=>{o[dt(i)]=[e,t]}),o}function ut(n,o){return o.get(W).resolveComponentFactory(n).inputs}function pt(n,o){let e=n.childNodes,i=o.map(()=>[]),t=-1;o.some((s,p)=>s==="*"?(t=p,!0):!1);for(let s=0,p=e.length;s
t!=="*"&&ht(n,t)?(i=s,!0):!1),i}var gt=10,J=class{componentFactory;inputMap=new Map;constructor(o,e){this.componentFactory=e.get(W).resolveComponentFactory(o);for(let i of this.componentFactory.inputs)this.inputMap.set(i.propName,i.templateName)}create(o){return new ee(this.componentFactory,o,this.inputMap)}},ee=class{componentFactory;injector;inputMap;eventEmitters=new re(1);events=this.eventEmitters.pipe(H(o=>$(...o)));componentRef=null;scheduledDestroyFn=null;initialInputValues=new Map;ngZone;elementZone;appRef;cdScheduler;constructor(o,e,i){this.componentFactory=o,this.injector=e,this.inputMap=i,this.ngZone=this.injector.get(ge),this.appRef=this.injector.get(Me),this.cdScheduler=e.get(be),this.elementZone=typeof Zone>"u"?null:this.ngZone.run(()=>Zone.current)}connect(o){this.runInZone(()=>{if(this.scheduledDestroyFn!==null){this.scheduledDestroyFn(),this.scheduledDestroyFn=null;return}this.componentRef===null&&this.initializeComponent(o)})}disconnect(){this.runInZone(()=>{this.componentRef===null||this.scheduledDestroyFn!==null||(this.scheduledDestroyFn=ct.schedule(()=>{this.componentRef!==null&&(this.componentRef.destroy(),this.componentRef=null)},gt))})}getInputValue(o){return this.runInZone(()=>this.componentRef===null?this.initialInputValues.get(o):this.componentRef.instance[o])}setInputValue(o,e){if(this.componentRef===null){this.initialInputValues.set(o,e);return}this.runInZone(()=>{this.componentRef.setInput(this.inputMap.get(o)??o,e),fe(this.componentRef.hostView)&&(Ee(this.componentRef.changeDetectorRef),this.cdScheduler.notify(6))})}initializeComponent(o){let e=pe.create({providers:[],parent:this.injector}),i=pt(o,this.componentFactory.ngContentSelectors);this.componentRef=this.componentFactory.create(e,i,o),this.initializeInputs(),this.initializeOutputs(this.componentRef),this.appRef.attachView(this.componentRef.hostView),this.componentRef.hostView.detectChanges()}initializeInputs(){for(let[o,e]of this.initialInputValues)this.setInputValue(o,e);this.initialInputValues.clear()}initializeOutputs(o){let e=this.componentFactory.outputs.map(({propName:i,templateName:t})=>{let s=o.instance[i];return new oe(p=>{let h=s.subscribe(m=>p.next({name:t,value:m}));return()=>h.unsubscribe()})});this.eventEmitters.next(e)}runInZone(o){return this.elementZone&&Zone.current!==this.elementZone?this.ngZone.run(o):o()}},te=class extends HTMLElement{ngElementEventsSubscription=null};function at(n,o){let e=ut(n,o.injector),i=o.strategyFactory||new J(n,o.injector),t=mt(e);class s extends te{injector;static observedAttributes=Object.keys(t);get ngElementStrategy(){if(!this._ngElementStrategy){let h=this._ngElementStrategy=i.create(this.injector||o.injector);e.forEach(({propName:m,transform:b})=>{if(!this.hasOwnProperty(m))return;let I=this[m];delete this[m],h.setInputValue(m,I,b)})}return this._ngElementStrategy}_ngElementStrategy;constructor(h){super(),this.injector=h}attributeChangedCallback(h,m,b,I){let[V,R]=t[h];this.ngElementStrategy.setInputValue(V,b,R)}connectedCallback(){let h=!1;this.ngElementStrategy.events&&(this.subscribeToEvents(),h=!0),this.ngElementStrategy.connect(this),h||this.subscribeToEvents()}disconnectedCallback(){this._ngElementStrategy&&this._ngElementStrategy.disconnect(),this.ngElementEventsSubscription&&(this.ngElementEventsSubscription.unsubscribe(),this.ngElementEventsSubscription=null)}subscribeToEvents(){this.ngElementEventsSubscription=this.ngElementStrategy.events.subscribe(h=>{let m=new CustomEvent(h.name,{detail:h.value});this.dispatchEvent(m)})}}return e.forEach(({propName:p,transform:h,isSignal:m})=>{Object.defineProperty(s.prototype,p,{get(){let b=this.ngElementStrategy.getInputValue(p);return m&&ve(b)?b():b},set(b){this.ngElementStrategy.setInputValue(p,b,h)},configurable:!0,enumerable:!0})}),s}P();var bt=["wrapperEl"],ft=["chatbotCore"],Et=["sidebarToggle"],Tt=["historySidebar"],vt=["chatbotSearch"];function Mt(n,o){if(n&1){let e=M();a(0,"button",37),u("click",function(){let t=d(e).$implicit;r(2);let s=q(14);return r().toggle(),s.onOpen(),_(s.askQuestion(t))}),a(1,"span",38),B(2),l()()}if(n&2){let e=o.$implicit;c(2),z(e)}}function St(n,o){if(n&1){let e=M();a(0,"div",16)(1,"div",30)(2,"div",31)(3,"div"),B(4),l(),a(5,"span",32),B(6,"\u0387"),l(),a(7,"div"),A(8,6),l()(),a(9,"div",33),A(10,7),l(),a(11,"button",34),u("click",function(){d(e);let t=r(2);return _(t.greetingDismissed.set(!0))}),C(12,"icon",35),l()(),Oe(13,Mt,3,1,"button",36,Se),l()}if(n&2){let e=r();c(4),z(e.branding.chatbot_name),c(7),L("top",-8,"px")("right",-8,"px"),c(2),Ae(e.sample_questions)}}function Ot(n,o){if(n&1){let e=M();a(0,"button",39,2),u("click",function(){d(e);let t=r(2);return _(t.toggleSidebar())}),a(2,"div",20),C(3,"profile-pic",29),l(),C(4,"icon",40),l()}if(n&2){let e=r(2);Z("aria-expanded",e.sidebarOpen()),c(3),E("manualOverrideSrc",e.chatbotAvatar())}}function At(n,o){if(n&1&&(a(0,"div",20),C(1,"profile-pic",29),l()),n&2){let e=r(2);c(),E("manualOverrideSrc",e.chatbotAvatar())}}function yt(n,o){n&1&&C(0,"loader",43),n&2&&E("size",20)}function xt(n,o){n&1&&C(0,"icon",44)}function wt(n,o){n&1&&(C(0,"icon",47),a(1,"span"),A(2,9),l())}function Nt(n,o){n&1&&(C(0,"icon",48),a(1,"span"),A(2,10),l())}function Pt(n,o){if(n&1){let e=M();a(0,"button",41)(1,"span",42),B(2),l(),T(3,yt,1,1,"loader",43)(4,xt,1,0,"icon",44),l(),a(5,"pfy-menu",null,3)(7,"button",45),u("click",function(){d(e),r();let t=F(6),s=r();return _(s.togglePin(t,"header"))}),T(8,wt,3,0)(9,Nt,3,0),l(),a(10,"button",45),u("click",function(){d(e),r();let t=F(6),s=r();return _(s.renameChat(t,"header"))}),C(11,"icon",46),a(12,"span"),A(13,8),l()()()}if(n&2){let e=q(6);r();let i=F(6),t=r();E("title",t.activeTitle())("disabled",t.isPinning(i.public_id))("pfyMenuTriggerFor",e),c(2),z(t.activeTitle()),c(),v(t.isPinning(i.public_id)?3:4),c(5),v(i.pinned_at?8:9)}}function Bt(n,o){if(n&1&&(a(0,"h2",21),B(1),l()),n&2){let e=r();E("title",e.branding.chatbot_name),c(),we(" ",e.branding.chatbot_name," ")}}function Dt(n,o){if(n&1){let e=M();a(0,"button",49),u("click",function(){d(e);let t=r(2);return _(t.toggle())}),C(1,"icon",35),l()}}function It(n,o){if(n&1){let e=M();a(0,"button",53),u("click",function(){d(e);let t=r(3);return _(t.toggleSidebar())}),l()}}function Rt(n,o){if(n&1){let e=M();a(0,"aside",50),u("keydown.escape",function(){d(e);let t=r(2);return _(t.sidebarOpen()&&t.toggleSidebar())}),a(1,"chatbot-history-sidebar",51,4),u("selected",function(t){d(e);let s=r(2);return _(s.onConversationSelected(t))})("conversationUpdated",function(t){d(e);let s=r(2);return _(s.onConversationUpdated(t))})("newChatRequested",function(){d(e);let t=r(2);return _(t.newChat())})("closeRequested",function(){d(e);let t=r(2);return _(t.toggleSidebar())})("searchToggled",function(){d(e);let t=r(2);return _(t.toggleSearch())}),l()(),T(3,It,1,0,"button",52)}if(n&2){let e,i=r(),t=r();y("sidebar-open",t.sidebarOpen()),E("cdkTrapFocus",t.sidebarOpen())("cdkTrapFocusAutoCapture",t.sidebarOpen()),Z("inert",t.sidebarOpen()?null:""),c(),E("currentPublicId",t.mode()==="chat"?((e=t.activeConversation())==null?null:e.public_id)??null:null)("chatbotAvatar",t.chatbotAvatar())("chatbotName",i.branding.chatbot_name)("isMobile",!1)("searchActive",t.mode()==="search"),c(2),v(t.sidebarOpen()?3:-1)}}function Ht(n,o){if(n&1){let e=M();a(0,"chatbot-search",54,5),u("conversationSelected",function(t){d(e);let s=r(2);return _(s.onSearchConversationSelected(t))}),l()}if(n&2){let e=r(2);y("hidden",e.mode()!=="search"),E("active",e.mode()==="search")}}function Vt(n,o){if(n&1){let e=M();a(0,"div",15),T(1,St,15,5,"div",16),a(2,"div",17)(3,"div",18),T(4,Ot,5,2,"button",19)(5,At,2,1,"div",20),Ne(6),T(7,Pt,14,6)(8,Bt,2,2,"h2",21),a(9,"button",22),u("click",function(){d(e);let t=r();return _(t.newChat())}),C(10,"icon",23),l(),T(11,Dt,2,0,"button",24),l(),T(12,Rt,4,11),a(13,"chatbot-core",25,1),u("firstTurnComplete",function(t){d(e);let s=r();return _(s.onFirstTurnComplete(t))})("loadOlderMessages",function(){d(e);let t=r();return _(t.onLoadOlderMessages())})("conversationUpdated",function(t){d(e);let s=r();return _(s.onConversationUpdated(t))})("refreshConfig",function(){d(e);let t=r();return _(t.refreshConfigOnly$.next())}),l(),T(15,Ht,2,3,"chatbot-search",26),l(),a(16,"button",27),u("click",function(){d(e);let t=r();return _(t.toggle())}),a(17,"div",28),C(18,"profile-pic",29),l()()()}if(n&2){let e=r();y("pa-24",!e.fullscreenMobile())("fullscreen-mobile",e.fullscreenMobile()),c(),v(e.greetingVisible()?1:-1),c(),L("height",e.fullscreenMobile()?null:e.responsiveHeight(),"px")("width",e.fullscreenMobile()?null:e.responsiveWidth(),"px"),y("hidden",!e.visible()),c(2),v(e.usersService.isAuthenticated()?4:5),c(2);let i=Pe(e.activeConversation());c(),v(i&&e.activeTitle()&&e.mode()==="chat"?7:8),c(4),v(e.isMobile()?11:-1),c(),v(e.usersService.isAuthenticated()?12:-1),c(),y("hidden",e.mode()==="search"),E("aiChatbotConfig",o)("displayLoginButtonWhenUnauth",!0)("hideHeader",!0)("fullScreen",!1)("hydrateFromConversation",e.hydratePayload())("olderMessages",e.olderMessages())("loadingOlder",e.loadingOlderMessages())("canLoadOlder",e.canLoadOlder()),c(2),v(e.usersService.isAuthenticated()?15:-1),c(),y("hidden",e.fullscreenMobile()),c(2),E("manualOverrideSrc",e.chatbotAvatar())}}function $t(n,o){if(n&1){let e=M();a(0,"div",14)(1,"div",55)(2,"div"),A(3,11),l(),a(4,"button",56),u("click",function(){d(e);let t=r();return _(t.noAccessMessageVisible.set(!1))}),C(5,"icon",35),l()()()}n&2&&(c(4),L("top",-8,"px")("right",-8,"px"))}var lt=(()=>{class n{constructor(){this.chatbotService=O(Je),this.usersService=O(We),this.destroyRef=O(Ce),this.conversationActions=O(st),this.analyticsService=O(Ze),this.storageAccessService=O(tt),this.storageRestoreAttempted=!1,this.newChatLabel=$localize`:Default placeholder for an untitled conversation:New Chat`,this.chatbotWidth=400,this.chatbotHeight=664,this.iframeXPadding=48,this.iframeYPadding=104,this.greetingDismissedSessionKey="chatbot_greeting_dismissed",this.viewportSize=g({width:window.innerWidth,height:window.innerHeight}),this.responsiveWidth=S(()=>Math.min(this.chatbotWidth,this.viewportSize().width-this.iframeXPadding)),this.responsiveHeight=S(()=>Math.min(this.chatbotHeight,this.viewportSize().height-this.iframeYPadding)),this.hostViewportWidth=g(null),this.isMobile=S(()=>this.hostViewportWidth()?this.hostViewportWidth()<$e.XS:this.viewportSize().width