(function(){try{var g=typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};g["__faroBundleId_Speechify Chrome Extension"]="13.4.1"}catch(l){}})();
import{c as m,d as i,e as b,f as y,g as h,i as L}from"./chunk-O2NGNVNH.js";import{m as p,n as P,p as f,q as D,r as C,s as k}from"./chunk-LZ6UXASV.js";import{a as d,f as l,h as S}from"./chunk-XBE3KAOI.js";var n,v=d(()=>{"use strict";l();S();D();k();n=f()(C(()=>({initialUrl:null,currentUrl:null,currentUrlState:null,currentUrlMetadata:null,config:null,activeSummaryControllers:new Map,activeChatControllers:new Map,questionInput:"",currentSessionState:null})))});var w,O,A=d(()=>{"use strict";l();S();w=()=>crypto.randomUUID(),O=()=>({hasContent:!1,contentCount:0})});var u,I,N,X,Y,Z,_,$,ee,te,se,ne,T=d(()=>{l();S();P();L();v();A();u=p("SessionActions"),I=async()=>{let{currentSessionState:e}=n.getState();e&&e.messages.length>0&&await i(e);let t=w(),s=Date.now(),r={sessionId:t,startTime:s,messages:[],urls:[]};return n.setState({currentSessionState:r}),u.debug("Started new session:",t),r},N=async e=>{let{currentSessionState:t}=n.getState();t&&t.messages.length>0&&await i(t);let s=await m(e);return s?(n.setState({currentSessionState:s}),u.debug("Loaded session:",e),s):null},X=async e=>{let{currentSessionState:t,currentUrl:s}=n.getState();if(t||(t=await I()),t.messages.some(a=>a.id===e.id))return;let r=t.messages.length===0&&e.type==="user",o={...t,messages:[...t.messages,e],urls:s&&!t.urls.includes(s)?[...t.urls,s]:t.urls,...r?{title:e.content}:{}};n.setState({currentSessionState:o}),await i(o)},Y=async(e,t)=>{let{currentSessionState:s}=n.getState();if(!s)return;let r=s.messages.map(a=>a.id===e?{...a,...t,updatedAt:Date.now()}:a),o={...s,messages:r};n.setState({currentSessionState:o}),await i(o)},Z=async()=>b(),_=async e=>{await y(e)},$=async()=>{let{currentSessionState:e,activeChatControllers:t,activeSummaryControllers:s}=n.getState();if(e){let r=new Map(t),o=new Map(s),a=r.get(e.sessionId);a&&(a.abort(),r.delete(e.sessionId));let c=o.get(e.sessionId);c&&(c.abort(),o.delete(e.sessionId)),n.setState({activeChatControllers:r,activeSummaryControllers:o})}await h(),n.setState({currentSessionState:null}),u.info("Cleared all sessions")},ee=async(e,t)=>{let s=await m(e);if(!s)return;let r={...s,title:t};await i(r);let{currentSessionState:o}=n.getState();o?.sessionId===e&&n.setState({currentSessionState:r})},te=async e=>{let{currentSessionState:t}=n.getState();if(!t){let o={...await I(),questionRecommendations:e};n.setState({currentSessionState:o}),await i(o);return}let s={...t,questionRecommendations:e};n.setState({currentSessionState:s}),await i(s)},se=async()=>{let{currentSessionState:e,activeChatControllers:t,activeSummaryControllers:s}=n.getState();if(!e)return;let r=new Map(t),o=new Map(s),a=r.get(e.sessionId);a&&(a.abort(),r.delete(e.sessionId));let c=o.get(e.sessionId);c&&(c.abort(),o.delete(e.sessionId));let g={...e,messages:[],chatId:void 0,isChatStreaming:void 0,summaryData:void 0,summaryFeedback:void 0,isLoadingSummary:void 0};n.setState({currentSessionState:g,activeChatControllers:r,activeSummaryControllers:o}),await i(g),u.info("Cleared chat for current session")},ne=async e=>{let{currentSessionState:t}=n.getState();t&&(t.exitedVoiceMode=e,n.setState({currentSessionState:t}))}});export{n as a,v as b,w as c,O as d,A as e,I as f,N as g,X as h,Y as i,Z as j,_ as k,$ as l,ee as m,te as n,se as o,ne as p,T as q};
//# sourceMappingURL=chunk-7OA7UB43.js.map
