@flowengage/react-chatbot 1.8.13 → 1.8.14

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.
@@ -461,9 +461,10 @@ registerProcessor("scribeAudioProcessor", ScribeAudioProcessor);
461
461
 
462
462
  gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
463
463
  }
464
- `;function lD(e,t,n){let r=(t,n)=>{let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(console.error(`[AnimatedOrb shader]`,e.getShaderInfoLog(r)),null)},i=r(e.VERTEX_SHADER,t),a=r(e.FRAGMENT_SHADER,n);if(!i||!a)return null;let o=e.createProgram();return e.attachShader(o,i),e.attachShader(o,a),e.linkProgram(o),e.getProgramParameter(o,e.LINK_STATUS)?o:(console.error(`[AnimatedOrb link]`,e.getProgramInfoLog(o)),null)}function uD({size:e=94,voiceState:t=`idle`,isMuted:n=!1,colors:r,onClick:i,style:a,className:o}){let[s,c,l]=rD(r),u=t===`speaking`,d=e<=50,f=(0,b.useRef)(null),p=(0,b.useRef)(iD[t]??.35);(0,b.useEffect)(()=>{p.current=iD[t]??.35},[t]),(0,b.useEffect)(()=>{let t=f.current;if(!t)return;let n=Math.min(window.devicePixelRatio||1,2);t.width=e*n,t.height=e*n;let r=t.getContext(`webgl`,{alpha:!0,antialias:!0})||t.getContext(`experimental-webgl`,{alpha:!0,antialias:!0});if(!r){console.warn(`[AnimatedOrb] WebGL unavailable.`);return}let i=lD(r,sD,cD);if(!i){console.error(`[AnimatedOrb] WebGL program failed to compile/link`);return}r.useProgram(i);let a=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,a),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),r.STATIC_DRAW);let o=r.getAttribLocation(i,`a_pos`);r.enableVertexAttribArray(o),r.vertexAttribPointer(o,2,r.FLOAT,!1,0,0);let u={time:r.getUniformLocation(i,`u_time`),speed:r.getUniformLocation(i,`u_speed`),c1:r.getUniformLocation(i,`u_c1`),c2:r.getUniformLocation(i,`u_c2`),c3:r.getUniformLocation(i,`u_c3`)};r.uniform3fv(u.c1,aD(s)),r.uniform3fv(u.c2,aD(c)),r.uniform3fv(u.c3,aD(l)),r.viewport(0,0,t.width,t.height);let d=performance.now(),m,h=e=>{r.uniform1f(u.time,(e-d)/1e3),r.uniform1f(u.speed,p.current),r.drawArrays(r.TRIANGLES,0,6),m=requestAnimationFrame(h)};return m=requestAnimationFrame(h),()=>{cancelAnimationFrame(m),r.deleteProgram(i),r.deleteBuffer(a)}},[s,c,l,e]);let m=n?`saturate(0.3) brightness(1.1)`:t===`error`?`saturate(0.4) hue-rotate(28deg)`:`none`;return(0,M.jsxs)(`div`,{style:{position:`relative`,width:e,height:e,flexShrink:0,cursor:i?`pointer`:`default`,...a},className:o,onClick:i,children:[u&&!d&&(0,M.jsx)(jp.div,{style:{position:`absolute`,inset:-10,borderRadius:`50%`,background:`radial-gradient(circle, ${oD(s,.18)} 0%, transparent 70%)`,pointerEvents:`none`},animate:{opacity:[.3,.75]},transition:{duration:1,repeat:1/0,repeatType:`mirror`,ease:`easeInOut`}}),(0,M.jsx)(`div`,{style:{width:e,height:e,borderRadius:`50%`,overflow:`hidden`,WebkitMaskImage:`-webkit-radial-gradient(white, black)`,filter:m,transition:`filter 1.2s ease`},children:(0,M.jsx)(`canvas`,{ref:f,style:{width:`100%`,height:`100%`,display:`block`}})}),u&&(0,M.jsx)(`div`,{style:{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,pointerEvents:`none`,zIndex:1},children:(0,M.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`3px`},children:[4,8,12,8,4].map((e,t)=>(0,M.jsx)(jp.div,{style:{width:`3px`,borderRadius:`3px`,background:`rgba(255,255,255,0.85)`},animate:{height:[4,e+8,4]},transition:{duration:.48,delay:t*.08,repeat:1/0,ease:`easeInOut`}},t))})})]})}var dD=`fe_voice_session`,fD=`fe_tab_id`,pD=40,mD=2e3,hD=300*1e3,gD=60*1e3,_D=30*1e3;function vD(){let e=new Uint8Array(16);try{crypto.getRandomValues(e)}catch{for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256)}return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function yD(){try{let e=sessionStorage.getItem(fD);return e||(e=vD(),sessionStorage.setItem(fD,e)),e}catch{return vD()}}function bD(e,t){return`${(e||[]).length}:${t%1e5}`}function xD(e,t){return Array.isArray(e)?e.length<=t?e:e.slice(e.length-t):[]}function SD(){if(typeof document>`u`)return{headings:[],activeHighlightText:null,activeHighlightId:null};let e=document.querySelector(`.fe-highlight-section`);return{headings:Array.from(document.querySelectorAll(`h1,h2,h3,h4`)).filter(e=>!e.closest(`#flowengage-root`)).map(e=>({tag:e.tagName,text:e.textContent.trim().slice(0,100),id:e.id||null})).slice(0,25),activeHighlightText:e?.textContent?.trim().slice(0,100)||null,activeHighlightId:e?.id||null}}function CD(e){if(!e)return`Unknown state.`;let{state:t,lastAgentText:n,lastUserText:r,toolName:i,toolParams:a,estimatedSpokenWords:o,agentTextWordCount:s,unspokenSuffix:c}=e,l=[];return t===`speaking`?(l.push(`You were SPEAKING.`),n&&(l.push(`You had spoken approximately ${o??`?`} of ${s??`?`} words.`),l.push(`Your response text: "${n}"`),c&&l.push(`Estimated unspoken remainder: "${c}"`))):t===`listening`?(l.push(`You were LISTENING for the user's response.`),r&&l.push(`Last user message: "${r}"`)):t===`tool_calling`?i===`flowengage_navigate`?(l.push(`Navigation ALREADY COMPLETED — you successfully navigated to this page.`),l.push(`DO NOT call flowengage_navigate again. You are already on the destination.`),n&&l.push(`Before navigating you said: "${n}"`)):(l.push(`You were executing tool: ${i||`unknown`}`),a&&l.push(`Tool parameters: ${JSON.stringify(a)}`),n&&l.push(`Your last spoken text before the tool call: "${n}"`)):l.push(`Session state at capture: ${t||`idle`}`),l.join(`
464
+ `;function lD(e,t,n){let r=(t,n)=>{let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(console.error(`[AnimatedOrb shader]`,e.getShaderInfoLog(r)),null)},i=r(e.VERTEX_SHADER,t),a=r(e.FRAGMENT_SHADER,n);if(!i||!a)return null;let o=e.createProgram();return e.attachShader(o,i),e.attachShader(o,a),e.linkProgram(o),e.getProgramParameter(o,e.LINK_STATUS)?o:(console.error(`[AnimatedOrb link]`,e.getProgramInfoLog(o)),null)}function uD({size:e=94,voiceState:t=`idle`,isMuted:n=!1,colors:r,onClick:i,style:a,className:o}){let[s,c,l]=rD(r),u=t===`speaking`,d=e<=50,f=(0,b.useRef)(null),p=(0,b.useRef)(iD[t]??.35);(0,b.useEffect)(()=>{p.current=iD[t]??.35},[t]),(0,b.useEffect)(()=>{let t=f.current;if(!t)return;let n=Math.min(window.devicePixelRatio||1,2);t.width=e*n,t.height=e*n;let r=t.getContext(`webgl`,{alpha:!0,antialias:!0})||t.getContext(`experimental-webgl`,{alpha:!0,antialias:!0});if(!r){console.warn(`[AnimatedOrb] WebGL unavailable.`);return}let i=lD(r,sD,cD);if(!i){console.error(`[AnimatedOrb] WebGL program failed to compile/link`);return}r.useProgram(i);let a=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,a),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),r.STATIC_DRAW);let o=r.getAttribLocation(i,`a_pos`);r.enableVertexAttribArray(o),r.vertexAttribPointer(o,2,r.FLOAT,!1,0,0);let u={time:r.getUniformLocation(i,`u_time`),speed:r.getUniformLocation(i,`u_speed`),c1:r.getUniformLocation(i,`u_c1`),c2:r.getUniformLocation(i,`u_c2`),c3:r.getUniformLocation(i,`u_c3`)};r.uniform3fv(u.c1,aD(s)),r.uniform3fv(u.c2,aD(c)),r.uniform3fv(u.c3,aD(l)),r.viewport(0,0,t.width,t.height);let d=performance.now(),m,h=e=>{r.uniform1f(u.time,(e-d)/1e3),r.uniform1f(u.speed,p.current),r.drawArrays(r.TRIANGLES,0,6),m=requestAnimationFrame(h)};return m=requestAnimationFrame(h),()=>{cancelAnimationFrame(m),r.deleteProgram(i),r.deleteBuffer(a)}},[s,c,l,e]);let m=n?`saturate(0.3) brightness(1.1)`:t===`error`?`saturate(0.4) hue-rotate(28deg)`:`none`;return(0,M.jsxs)(`div`,{style:{position:`relative`,width:e,height:e,flexShrink:0,cursor:i?`pointer`:`default`,...a},className:o,onClick:i,children:[u&&!d&&(0,M.jsx)(jp.div,{style:{position:`absolute`,inset:-10,borderRadius:`50%`,background:`radial-gradient(circle, ${oD(s,.18)} 0%, transparent 70%)`,pointerEvents:`none`},animate:{opacity:[.3,.75]},transition:{duration:1,repeat:1/0,repeatType:`mirror`,ease:`easeInOut`}}),(0,M.jsx)(`div`,{style:{width:e,height:e,borderRadius:`50%`,overflow:`hidden`,WebkitMaskImage:`-webkit-radial-gradient(white, black)`,filter:m,transition:`filter 1.2s ease`},children:(0,M.jsx)(`canvas`,{ref:f,style:{width:`100%`,height:`100%`,display:`block`}})}),u&&(0,M.jsx)(`div`,{style:{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,pointerEvents:`none`,zIndex:1},children:(0,M.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`3px`},children:[4,8,12,8,4].map((e,t)=>(0,M.jsx)(jp.div,{style:{width:`3px`,borderRadius:`3px`,background:`rgba(255,255,255,0.85)`},animate:{height:[4,e+8,4]},transition:{duration:.48,delay:t*.08,repeat:1/0,ease:`easeInOut`}},t))})})]})}var dD=`fe_voice_session`,fD=`fe_tab_id`,pD=40,mD=2e3,hD=300*1e3,gD=60*1e3,_D=30*1e3;function vD(){let e=new Uint8Array(16);try{crypto.getRandomValues(e)}catch{for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256)}return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function yD(){try{let e=sessionStorage.getItem(fD);return e||(e=vD(),sessionStorage.setItem(fD,e)),e}catch{return vD()}}function bD(e,t){return`${(e||[]).length}:${t%1e5}`}function xD(e,t){return Array.isArray(e)?e.length<=t?e:e.slice(e.length-t):[]}function SD(){if(typeof document>`u`)return{headings:[],activeHighlightText:null,activeHighlightId:null};let e=document.querySelector(`.fe-highlight-section`);return{headings:Array.from(document.querySelectorAll(`h1,h2,h3,h4`)).filter(e=>!e.closest(`#flowengage-root`)).map(e=>({tag:e.tagName,text:e.textContent.trim().slice(0,100),id:e.id||null})).slice(0,25),activeHighlightText:e?.textContent?.trim().slice(0,100)||null,activeHighlightId:e?.id||null}}function CD(e){if(!e)return`Unknown state.`;let{state:t,lastAgentText:n,lastUserText:r,toolName:i,toolParams:a,estimatedSpokenWords:o,agentTextWordCount:s,unspokenSuffix:c}=e,l=[];return t===`speaking`?(l.push(`You were SPEAKING.`),n&&(l.push(`You had spoken approximately ${o??`?`} of ${s??`?`} words.`),l.push(`Your response text: "${n}"`),c&&l.push(`Estimated unspoken remainder: "${c}"`))):t===`listening`?(l.push(`You were LISTENING for the user's response.`),r&&l.push(`Last user message: "${r}"`)):t===`tool_calling`?i===`flowengage_navigate`?(l.push(`Navigation ALREADY COMPLETED — you successfully navigated to this page.`),l.push(`DO NOT call flowengage_navigate again. You are already on the destination.`),r&&l.push(`The user's last request was: "${r}"`),n&&l.push(`Before navigating you said: "${n}"`)):(l.push(`You were executing tool: ${i||`unknown`}`),a&&l.push(`Tool parameters: ${JSON.stringify(a)}`),n&&l.push(`Your last spoken text before the tool call: "${n}"`)):l.push(`Session state at capture: ${t||`idle`}`),l.join(`
465
465
  `)}function wD(e,t){try{let n={v:2,sid:e.siteId||``,aid:e.agentId||``,ut:(e.interruption?.lastUserText||``).slice(0,50),ts:Math.floor(t/1e3)};return`compact:${btoa(unescape(encodeURIComponent(JSON.stringify(n))))}`}catch{return null}}function TD(e,t){if(!t)return e;try{let n=new URL(e,window.location.href);return n.searchParams.set(`_fe_resume`,t),n.href}catch{return e+(e.includes(`?`)?`&`:`?`)+`_fe_resume=`+t}}function ED(){if(typeof window>`u`)return null;try{let e=new URL(window.location.href),t=e.searchParams.get(`_fe_resume`);if(!t)return null;e.searchParams.delete(`_fe_resume`);let n=e.pathname+(e.search?e.search:``)+(e.hash?e.hash:``);return window.history.replaceState(window.history.state,``,n),t}catch{return null}}var DD={capture(e){let t=vD(),n=Date.now(),r=xD(e.history,pD),i=(e.interruption?.lastAgentText||``).slice(0,mD),a=e.interruption?.estimatedSpokenWords||0,o=e.interruption?.agentTextWordCount||i.split(/\s+/).filter(Boolean).length,s=``;e.interruption?.state===`speaking`&&i&&a>0&&(s=i.split(/\s+/).slice(a).join(` `));let c={version:2,sessionKey:t,tabId:yD(),siteId:e.siteId,chatId:e.chatId||null,agentId:e.agentId,ts:n,expiresAt:n+hD,resumeAttempts:0,consumed:!1,trigger:e.trigger,navigationConfidence:e.navigationConfidence||`medium`,fromUrl:typeof window<`u`?window.location.href:``,targetUrl:e.targetUrl||null,interruption:{...e.interruption,lastAgentText:i,estimatedSpokenWords:a,agentTextWordCount:o,unspokenSuffix:s,micWasGranted:!0,isMuted:e.interruption?.isMuted||!1,hadError:e.interruption?.hadError||!1},fromPageContext:SD(),history:r,historyTotalTurns:(e.history||[]).length,storageChecksum:bD(r,n)};try{return sessionStorage.setItem(dD,JSON.stringify(c)),{ok:!0,sessionKey:t,compact:null}}catch{return{ok:!1,sessionKey:null,compact:wD(e,n)}}},read(e){if(typeof window>`u`)return null;let t=ED();if(t?.startsWith(`compact:`)){try{let n=JSON.parse(decodeURIComponent(escape(atob(t.slice(8))))),r=Date.now()/1e3-(n.ts||0);if(n.v===2&&n.sid===e&&r<300)return{_compact:!0,_resumeMode:`auto`,siteId:n.sid,agentId:n.aid,chatId:null,history:[],historyTotalTurns:0,trigger:`agent_navigate`,navigationConfidence:`medium`,fromUrl:``,interruption:{state:`listening`,lastUserText:n.ut||``,lastAgentText:``},fromPageContext:{headings:[],activeHighlightText:null}}}catch{}return null}let n;try{n=JSON.parse(sessionStorage.getItem(dD)||`null`)}catch{return null}if(!n)return null;if(n.version!==2)return this._discard(`version`);if(n.siteId!==e)return this._discard(`siteId`);if(Date.now()>n.expiresAt)return this._discard(`expired`);if(n.consumed)return this._discard(`consumed`);if(n.resumeAttempts>=2)return this._discard(`loop_guard`);if(bD(n.history,n.ts)!==n.storageChecksum)return this._discard(`checksum`);if(n.trigger===`agent_navigate`&&t&&t!==n.sessionKey)return this._discard(`key_mismatch`);if(n.trigger===`pagehide`){if(Date.now()-n.ts>_D)return this._discard(`pagehide_stale`);n._resumeMode=`banner`}else if(n.trigger===`user_link_click`){if(Date.now()-n.ts>gD)return this._discard(`user_nav_stale`);n._resumeMode=`auto`}else n._resumeMode=`auto`;n.resumeAttempts+=1;try{sessionStorage.setItem(dD,JSON.stringify(n))}catch{}return n},clear(){try{sessionStorage.removeItem(dD)}catch{}},buildResumePrompt(e,t,n){let r=(e.history||[]).map(e=>`[${e.sender===`user`?`User`:`Agent`}]: ${e.message}`).join(`
466
- `),i=CD(e.interruption),a=(t||[]).map(e=>e.text).join(`, `),o=``,s=``;try{o=new URL(e.fromUrl||``).pathname}catch{o=e.fromUrl||``}try{s=new URL(n||window.location.href).pathname}catch{s=n||``}return[`VOICE SESSION AUTO-RESUMED AFTER PAGE NAVIGATION.`,`Navigation confidence: ${(e.navigationConfidence||`medium`).toUpperCase()}`,`Navigation: ${o} → ${s}`,``,`── Prior Conversation (${e.historyTotalTurns} turns) ──`,r||`(no prior turns)`,``,`── Your State at Interruption ──`,i,``,`── Current Page ──`,`URL: ${n||(typeof window<`u`?window.location.href:``)}`,`Sections: ${a||`none detected`}`,``,`── CRITICAL INSTRUCTIONS ──`,`1. DO NOT re-introduce yourself.`,`2. DO NOT ask the user what they need — you already know from the conversation above.`,`3. Continue the conversation naturally as if the navigation was seamless.`,`4. If you were mid-sentence, complete your thought naturally.`,`5. The navigation has ALREADY COMPLETED — you are now on the destination page. Do NOT call flowengage_navigate again.`,`6. Only acknowledge the page change if it adds meaningful context.`,`7. The user may speak at any time — stop immediately and listen.`,`8. Use the sections listed above to guide what you highlight next.`].join(`
466
+ `),i=e.interruption?.lastUserText;if(i){let t=[...e.history||[]].reverse().find(e=>e.sender===`user`);(!t||t.message!==i)&&(r+=(r?`
467
+ `:``)+`[User]: ${i}`)}let a=CD(e.interruption),o=(t||[]).map(e=>e.text).join(`, `),s=``,c=``;try{s=new URL(e.fromUrl||``).pathname}catch{s=e.fromUrl||``}try{c=new URL(n||window.location.href).pathname}catch{c=n||``}return[`VOICE SESSION AUTO-RESUMED AFTER PAGE NAVIGATION.`,`Navigation confidence: ${(e.navigationConfidence||`medium`).toUpperCase()}`,`Navigation: ${s} → ${c}`,``,`── Prior Conversation (${e.historyTotalTurns} turns) ──`,r||`(no prior turns)`,``,`── Your State at Interruption ──`,a,``,`── Current Page ──`,`URL: ${n||(typeof window<`u`?window.location.href:``)}`,`Sections: ${o||`none detected`}`,``,`── CRITICAL INSTRUCTIONS ──`,`1. DO NOT re-introduce yourself.`,`2. DO NOT ask the user what they need — you already know from the conversation above.`,`3. Continue the conversation naturally as if the navigation was seamless.`,`4. If you were mid-sentence, complete your thought naturally.`,`5. The navigation has ALREADY COMPLETED — you are now on the destination page. Do NOT call flowengage_navigate again.`,`6. Only acknowledge the page change if it adds meaningful context.`,`7. The user may speak at any time — stop immediately and listen.`,`8. Use the sections listed above to guide what you highlight next.`].join(`
467
468
  `)},_discard(e){try{sessionStorage.removeItem(dD)}catch{}return null}};function OD(){try{let e=JSON.parse(sessionStorage.getItem(dD)||`null`);return e?.trigger===`agent_navigate`&&Date.now()-(e.ts||0)<1e4}catch{return!1}}var kD={wordsSoFar:0,speechStartTime:0,isSpeaking:!1,items:[],timers:[],lastHighlightId:null,isVoiceMode:!1};function AD(){return kD.wordsSoFar}function jD(){kD.timers.forEach(clearTimeout),kD.wordsSoFar=0,kD.speechStartTime=0,kD.isSpeaking=!1,kD.items=[],kD.timers=[],kD.lastHighlightId=null}var MD=80;function ND(e){requestAnimationFrame(()=>{let t=e.getBoundingClientRect(),n=t.top+t.height/2,r=MD,i=r+(window.innerHeight-r)/2,a=window.pageYOffset+n-i;window.scrollTo({top:Math.max(0,a),behavior:`smooth`})})}function PD(e){if(!e||e.hasAttribute(`data-fe-highlighted`))return;FD(),e.classList?.remove(`fe-highlight-section`,`fe-highlight-speaking`,`fe-highlight-exiting`),ND(e);let t=e.style.cssText;e.setAttribute(`data-fe-highlighted`,`true`),e.setAttribute(`data-fe-orig-style`,t),e.style.outline=`3px solid #2563eb`,e.style.outlineOffset=`8px`,e.style.background=`rgba(37, 99, 235, 0.08)`,e.style.borderRadius=`8px`,e.style.padding=`12px 16px`,e.style.transition=`all 0.4s ease`}function FD(){let e=document.querySelector(`[data-fe-highlighted]`);e&&(e.style.cssText=e.getAttribute(`data-fe-orig-style`)||``,e.removeAttribute(`data-fe-highlighted`),e.removeAttribute(`data-fe-orig-style`))}var Q=`fe-vv`;function ID(){if(typeof document>`u`||document.getElementById(`${Q}-styles`))return;let e=`
468
469
  /* ── Action toast ───────────────────────────────────────────────────────────── */
469
470
  #${Q}-toast {
@@ -453,9 +453,10 @@ registerProcessor("scribeAudioProcessor", ScribeAudioProcessor);
453
453
 
454
454
  gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
455
455
  }
456
- `;function iD(e,t,n){let r=(t,n)=>{let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(console.error(`[AnimatedOrb shader]`,e.getShaderInfoLog(r)),null)},i=r(e.VERTEX_SHADER,t),a=r(e.FRAGMENT_SHADER,n);if(!i||!a)return null;let o=e.createProgram();return e.attachShader(o,i),e.attachShader(o,a),e.linkProgram(o),e.getProgramParameter(o,e.LINK_STATUS)?o:(console.error(`[AnimatedOrb link]`,e.getProgramInfoLog(o)),null)}function aD({size:e=94,voiceState:t=`idle`,isMuted:n=!1,colors:r,onClick:i,style:a,className:o}){let[s,c,l]=QE(r),u=t===`speaking`,p=e<=50,m=(0,d.useRef)(null),h=(0,d.useRef)($E[t]??.35);(0,d.useEffect)(()=>{h.current=$E[t]??.35},[t]),(0,d.useEffect)(()=>{let t=m.current;if(!t)return;let n=Math.min(window.devicePixelRatio||1,2);t.width=e*n,t.height=e*n;let r=t.getContext(`webgl`,{alpha:!0,antialias:!0})||t.getContext(`experimental-webgl`,{alpha:!0,antialias:!0});if(!r){console.warn(`[AnimatedOrb] WebGL unavailable.`);return}let i=iD(r,nD,rD);if(!i){console.error(`[AnimatedOrb] WebGL program failed to compile/link`);return}r.useProgram(i);let a=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,a),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),r.STATIC_DRAW);let o=r.getAttribLocation(i,`a_pos`);r.enableVertexAttribArray(o),r.vertexAttribPointer(o,2,r.FLOAT,!1,0,0);let u={time:r.getUniformLocation(i,`u_time`),speed:r.getUniformLocation(i,`u_speed`),c1:r.getUniformLocation(i,`u_c1`),c2:r.getUniformLocation(i,`u_c2`),c3:r.getUniformLocation(i,`u_c3`)};r.uniform3fv(u.c1,eD(s)),r.uniform3fv(u.c2,eD(c)),r.uniform3fv(u.c3,eD(l)),r.viewport(0,0,t.width,t.height);let d=performance.now(),f,p=e=>{r.uniform1f(u.time,(e-d)/1e3),r.uniform1f(u.speed,h.current),r.drawArrays(r.TRIANGLES,0,6),f=requestAnimationFrame(p)};return f=requestAnimationFrame(p),()=>{cancelAnimationFrame(f),r.deleteProgram(i),r.deleteBuffer(a)}},[s,c,l,e]);let g=n?`saturate(0.3) brightness(1.1)`:t===`error`?`saturate(0.4) hue-rotate(28deg)`:`none`;return(0,f.jsxs)(`div`,{style:{position:`relative`,width:e,height:e,flexShrink:0,cursor:i?`pointer`:`default`,...a},className:o,onClick:i,children:[u&&!p&&(0,f.jsx)(Mp.div,{style:{position:`absolute`,inset:-10,borderRadius:`50%`,background:`radial-gradient(circle, ${tD(s,.18)} 0%, transparent 70%)`,pointerEvents:`none`},animate:{opacity:[.3,.75]},transition:{duration:1,repeat:1/0,repeatType:`mirror`,ease:`easeInOut`}}),(0,f.jsx)(`div`,{style:{width:e,height:e,borderRadius:`50%`,overflow:`hidden`,WebkitMaskImage:`-webkit-radial-gradient(white, black)`,filter:g,transition:`filter 1.2s ease`},children:(0,f.jsx)(`canvas`,{ref:m,style:{width:`100%`,height:`100%`,display:`block`}})}),u&&(0,f.jsx)(`div`,{style:{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,pointerEvents:`none`,zIndex:1},children:(0,f.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`3px`},children:[4,8,12,8,4].map((e,t)=>(0,f.jsx)(Mp.div,{style:{width:`3px`,borderRadius:`3px`,background:`rgba(255,255,255,0.85)`},animate:{height:[4,e+8,4]},transition:{duration:.48,delay:t*.08,repeat:1/0,ease:`easeInOut`}},t))})})]})}var oD=`fe_voice_session`,sD=`fe_tab_id`,cD=40,lD=2e3,uD=300*1e3,dD=60*1e3,fD=30*1e3;function pD(){let e=new Uint8Array(16);try{crypto.getRandomValues(e)}catch{for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256)}return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function mD(){try{let e=sessionStorage.getItem(sD);return e||(e=pD(),sessionStorage.setItem(sD,e)),e}catch{return pD()}}function hD(e,t){return`${(e||[]).length}:${t%1e5}`}function gD(e,t){return Array.isArray(e)?e.length<=t?e:e.slice(e.length-t):[]}function _D(){if(typeof document>`u`)return{headings:[],activeHighlightText:null,activeHighlightId:null};let e=document.querySelector(`.fe-highlight-section`);return{headings:Array.from(document.querySelectorAll(`h1,h2,h3,h4`)).filter(e=>!e.closest(`#flowengage-root`)).map(e=>({tag:e.tagName,text:e.textContent.trim().slice(0,100),id:e.id||null})).slice(0,25),activeHighlightText:e?.textContent?.trim().slice(0,100)||null,activeHighlightId:e?.id||null}}function vD(e){if(!e)return`Unknown state.`;let{state:t,lastAgentText:n,lastUserText:r,toolName:i,toolParams:a,estimatedSpokenWords:o,agentTextWordCount:s,unspokenSuffix:c}=e,l=[];return t===`speaking`?(l.push(`You were SPEAKING.`),n&&(l.push(`You had spoken approximately ${o??`?`} of ${s??`?`} words.`),l.push(`Your response text: "${n}"`),c&&l.push(`Estimated unspoken remainder: "${c}"`))):t===`listening`?(l.push(`You were LISTENING for the user's response.`),r&&l.push(`Last user message: "${r}"`)):t===`tool_calling`?i===`flowengage_navigate`?(l.push(`Navigation ALREADY COMPLETED — you successfully navigated to this page.`),l.push(`DO NOT call flowengage_navigate again. You are already on the destination.`),n&&l.push(`Before navigating you said: "${n}"`)):(l.push(`You were executing tool: ${i||`unknown`}`),a&&l.push(`Tool parameters: ${JSON.stringify(a)}`),n&&l.push(`Your last spoken text before the tool call: "${n}"`)):l.push(`Session state at capture: ${t||`idle`}`),l.join(`
456
+ `;function iD(e,t,n){let r=(t,n)=>{let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(console.error(`[AnimatedOrb shader]`,e.getShaderInfoLog(r)),null)},i=r(e.VERTEX_SHADER,t),a=r(e.FRAGMENT_SHADER,n);if(!i||!a)return null;let o=e.createProgram();return e.attachShader(o,i),e.attachShader(o,a),e.linkProgram(o),e.getProgramParameter(o,e.LINK_STATUS)?o:(console.error(`[AnimatedOrb link]`,e.getProgramInfoLog(o)),null)}function aD({size:e=94,voiceState:t=`idle`,isMuted:n=!1,colors:r,onClick:i,style:a,className:o}){let[s,c,l]=QE(r),u=t===`speaking`,p=e<=50,m=(0,d.useRef)(null),h=(0,d.useRef)($E[t]??.35);(0,d.useEffect)(()=>{h.current=$E[t]??.35},[t]),(0,d.useEffect)(()=>{let t=m.current;if(!t)return;let n=Math.min(window.devicePixelRatio||1,2);t.width=e*n,t.height=e*n;let r=t.getContext(`webgl`,{alpha:!0,antialias:!0})||t.getContext(`experimental-webgl`,{alpha:!0,antialias:!0});if(!r){console.warn(`[AnimatedOrb] WebGL unavailable.`);return}let i=iD(r,nD,rD);if(!i){console.error(`[AnimatedOrb] WebGL program failed to compile/link`);return}r.useProgram(i);let a=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,a),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),r.STATIC_DRAW);let o=r.getAttribLocation(i,`a_pos`);r.enableVertexAttribArray(o),r.vertexAttribPointer(o,2,r.FLOAT,!1,0,0);let u={time:r.getUniformLocation(i,`u_time`),speed:r.getUniformLocation(i,`u_speed`),c1:r.getUniformLocation(i,`u_c1`),c2:r.getUniformLocation(i,`u_c2`),c3:r.getUniformLocation(i,`u_c3`)};r.uniform3fv(u.c1,eD(s)),r.uniform3fv(u.c2,eD(c)),r.uniform3fv(u.c3,eD(l)),r.viewport(0,0,t.width,t.height);let d=performance.now(),f,p=e=>{r.uniform1f(u.time,(e-d)/1e3),r.uniform1f(u.speed,h.current),r.drawArrays(r.TRIANGLES,0,6),f=requestAnimationFrame(p)};return f=requestAnimationFrame(p),()=>{cancelAnimationFrame(f),r.deleteProgram(i),r.deleteBuffer(a)}},[s,c,l,e]);let g=n?`saturate(0.3) brightness(1.1)`:t===`error`?`saturate(0.4) hue-rotate(28deg)`:`none`;return(0,f.jsxs)(`div`,{style:{position:`relative`,width:e,height:e,flexShrink:0,cursor:i?`pointer`:`default`,...a},className:o,onClick:i,children:[u&&!p&&(0,f.jsx)(Mp.div,{style:{position:`absolute`,inset:-10,borderRadius:`50%`,background:`radial-gradient(circle, ${tD(s,.18)} 0%, transparent 70%)`,pointerEvents:`none`},animate:{opacity:[.3,.75]},transition:{duration:1,repeat:1/0,repeatType:`mirror`,ease:`easeInOut`}}),(0,f.jsx)(`div`,{style:{width:e,height:e,borderRadius:`50%`,overflow:`hidden`,WebkitMaskImage:`-webkit-radial-gradient(white, black)`,filter:g,transition:`filter 1.2s ease`},children:(0,f.jsx)(`canvas`,{ref:m,style:{width:`100%`,height:`100%`,display:`block`}})}),u&&(0,f.jsx)(`div`,{style:{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,pointerEvents:`none`,zIndex:1},children:(0,f.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`3px`},children:[4,8,12,8,4].map((e,t)=>(0,f.jsx)(Mp.div,{style:{width:`3px`,borderRadius:`3px`,background:`rgba(255,255,255,0.85)`},animate:{height:[4,e+8,4]},transition:{duration:.48,delay:t*.08,repeat:1/0,ease:`easeInOut`}},t))})})]})}var oD=`fe_voice_session`,sD=`fe_tab_id`,cD=40,lD=2e3,uD=300*1e3,dD=60*1e3,fD=30*1e3;function pD(){let e=new Uint8Array(16);try{crypto.getRandomValues(e)}catch{for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256)}return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function mD(){try{let e=sessionStorage.getItem(sD);return e||(e=pD(),sessionStorage.setItem(sD,e)),e}catch{return pD()}}function hD(e,t){return`${(e||[]).length}:${t%1e5}`}function gD(e,t){return Array.isArray(e)?e.length<=t?e:e.slice(e.length-t):[]}function _D(){if(typeof document>`u`)return{headings:[],activeHighlightText:null,activeHighlightId:null};let e=document.querySelector(`.fe-highlight-section`);return{headings:Array.from(document.querySelectorAll(`h1,h2,h3,h4`)).filter(e=>!e.closest(`#flowengage-root`)).map(e=>({tag:e.tagName,text:e.textContent.trim().slice(0,100),id:e.id||null})).slice(0,25),activeHighlightText:e?.textContent?.trim().slice(0,100)||null,activeHighlightId:e?.id||null}}function vD(e){if(!e)return`Unknown state.`;let{state:t,lastAgentText:n,lastUserText:r,toolName:i,toolParams:a,estimatedSpokenWords:o,agentTextWordCount:s,unspokenSuffix:c}=e,l=[];return t===`speaking`?(l.push(`You were SPEAKING.`),n&&(l.push(`You had spoken approximately ${o??`?`} of ${s??`?`} words.`),l.push(`Your response text: "${n}"`),c&&l.push(`Estimated unspoken remainder: "${c}"`))):t===`listening`?(l.push(`You were LISTENING for the user's response.`),r&&l.push(`Last user message: "${r}"`)):t===`tool_calling`?i===`flowengage_navigate`?(l.push(`Navigation ALREADY COMPLETED — you successfully navigated to this page.`),l.push(`DO NOT call flowengage_navigate again. You are already on the destination.`),r&&l.push(`The user's last request was: "${r}"`),n&&l.push(`Before navigating you said: "${n}"`)):(l.push(`You were executing tool: ${i||`unknown`}`),a&&l.push(`Tool parameters: ${JSON.stringify(a)}`),n&&l.push(`Your last spoken text before the tool call: "${n}"`)):l.push(`Session state at capture: ${t||`idle`}`),l.join(`
457
457
  `)}function yD(e,t){try{let n={v:2,sid:e.siteId||``,aid:e.agentId||``,ut:(e.interruption?.lastUserText||``).slice(0,50),ts:Math.floor(t/1e3)};return`compact:${btoa(unescape(encodeURIComponent(JSON.stringify(n))))}`}catch{return null}}function bD(e,t){if(!t)return e;try{let n=new URL(e,window.location.href);return n.searchParams.set(`_fe_resume`,t),n.href}catch{return e+(e.includes(`?`)?`&`:`?`)+`_fe_resume=`+t}}function xD(){if(typeof window>`u`)return null;try{let e=new URL(window.location.href),t=e.searchParams.get(`_fe_resume`);if(!t)return null;e.searchParams.delete(`_fe_resume`);let n=e.pathname+(e.search?e.search:``)+(e.hash?e.hash:``);return window.history.replaceState(window.history.state,``,n),t}catch{return null}}var SD={capture(e){let t=pD(),n=Date.now(),r=gD(e.history,cD),i=(e.interruption?.lastAgentText||``).slice(0,lD),a=e.interruption?.estimatedSpokenWords||0,o=e.interruption?.agentTextWordCount||i.split(/\s+/).filter(Boolean).length,s=``;e.interruption?.state===`speaking`&&i&&a>0&&(s=i.split(/\s+/).slice(a).join(` `));let c={version:2,sessionKey:t,tabId:mD(),siteId:e.siteId,chatId:e.chatId||null,agentId:e.agentId,ts:n,expiresAt:n+uD,resumeAttempts:0,consumed:!1,trigger:e.trigger,navigationConfidence:e.navigationConfidence||`medium`,fromUrl:typeof window<`u`?window.location.href:``,targetUrl:e.targetUrl||null,interruption:{...e.interruption,lastAgentText:i,estimatedSpokenWords:a,agentTextWordCount:o,unspokenSuffix:s,micWasGranted:!0,isMuted:e.interruption?.isMuted||!1,hadError:e.interruption?.hadError||!1},fromPageContext:_D(),history:r,historyTotalTurns:(e.history||[]).length,storageChecksum:hD(r,n)};try{return sessionStorage.setItem(oD,JSON.stringify(c)),{ok:!0,sessionKey:t,compact:null}}catch{return{ok:!1,sessionKey:null,compact:yD(e,n)}}},read(e){if(typeof window>`u`)return null;let t=xD();if(t?.startsWith(`compact:`)){try{let n=JSON.parse(decodeURIComponent(escape(atob(t.slice(8))))),r=Date.now()/1e3-(n.ts||0);if(n.v===2&&n.sid===e&&r<300)return{_compact:!0,_resumeMode:`auto`,siteId:n.sid,agentId:n.aid,chatId:null,history:[],historyTotalTurns:0,trigger:`agent_navigate`,navigationConfidence:`medium`,fromUrl:``,interruption:{state:`listening`,lastUserText:n.ut||``,lastAgentText:``},fromPageContext:{headings:[],activeHighlightText:null}}}catch{}return null}let n;try{n=JSON.parse(sessionStorage.getItem(oD)||`null`)}catch{return null}if(!n)return null;if(n.version!==2)return this._discard(`version`);if(n.siteId!==e)return this._discard(`siteId`);if(Date.now()>n.expiresAt)return this._discard(`expired`);if(n.consumed)return this._discard(`consumed`);if(n.resumeAttempts>=2)return this._discard(`loop_guard`);if(hD(n.history,n.ts)!==n.storageChecksum)return this._discard(`checksum`);if(n.trigger===`agent_navigate`&&t&&t!==n.sessionKey)return this._discard(`key_mismatch`);if(n.trigger===`pagehide`){if(Date.now()-n.ts>fD)return this._discard(`pagehide_stale`);n._resumeMode=`banner`}else if(n.trigger===`user_link_click`){if(Date.now()-n.ts>dD)return this._discard(`user_nav_stale`);n._resumeMode=`auto`}else n._resumeMode=`auto`;n.resumeAttempts+=1;try{sessionStorage.setItem(oD,JSON.stringify(n))}catch{}return n},clear(){try{sessionStorage.removeItem(oD)}catch{}},buildResumePrompt(e,t,n){let r=(e.history||[]).map(e=>`[${e.sender===`user`?`User`:`Agent`}]: ${e.message}`).join(`
458
- `),i=vD(e.interruption),a=(t||[]).map(e=>e.text).join(`, `),o=``,s=``;try{o=new URL(e.fromUrl||``).pathname}catch{o=e.fromUrl||``}try{s=new URL(n||window.location.href).pathname}catch{s=n||``}return[`VOICE SESSION AUTO-RESUMED AFTER PAGE NAVIGATION.`,`Navigation confidence: ${(e.navigationConfidence||`medium`).toUpperCase()}`,`Navigation: ${o} → ${s}`,``,`── Prior Conversation (${e.historyTotalTurns} turns) ──`,r||`(no prior turns)`,``,`── Your State at Interruption ──`,i,``,`── Current Page ──`,`URL: ${n||(typeof window<`u`?window.location.href:``)}`,`Sections: ${a||`none detected`}`,``,`── CRITICAL INSTRUCTIONS ──`,`1. DO NOT re-introduce yourself.`,`2. DO NOT ask the user what they need — you already know from the conversation above.`,`3. Continue the conversation naturally as if the navigation was seamless.`,`4. If you were mid-sentence, complete your thought naturally.`,`5. The navigation has ALREADY COMPLETED — you are now on the destination page. Do NOT call flowengage_navigate again.`,`6. Only acknowledge the page change if it adds meaningful context.`,`7. The user may speak at any time — stop immediately and listen.`,`8. Use the sections listed above to guide what you highlight next.`].join(`
458
+ `),i=e.interruption?.lastUserText;if(i){let t=[...e.history||[]].reverse().find(e=>e.sender===`user`);(!t||t.message!==i)&&(r+=(r?`
459
+ `:``)+`[User]: ${i}`)}let a=vD(e.interruption),o=(t||[]).map(e=>e.text).join(`, `),s=``,c=``;try{s=new URL(e.fromUrl||``).pathname}catch{s=e.fromUrl||``}try{c=new URL(n||window.location.href).pathname}catch{c=n||``}return[`VOICE SESSION AUTO-RESUMED AFTER PAGE NAVIGATION.`,`Navigation confidence: ${(e.navigationConfidence||`medium`).toUpperCase()}`,`Navigation: ${s} → ${c}`,``,`── Prior Conversation (${e.historyTotalTurns} turns) ──`,r||`(no prior turns)`,``,`── Your State at Interruption ──`,a,``,`── Current Page ──`,`URL: ${n||(typeof window<`u`?window.location.href:``)}`,`Sections: ${o||`none detected`}`,``,`── CRITICAL INSTRUCTIONS ──`,`1. DO NOT re-introduce yourself.`,`2. DO NOT ask the user what they need — you already know from the conversation above.`,`3. Continue the conversation naturally as if the navigation was seamless.`,`4. If you were mid-sentence, complete your thought naturally.`,`5. The navigation has ALREADY COMPLETED — you are now on the destination page. Do NOT call flowengage_navigate again.`,`6. Only acknowledge the page change if it adds meaningful context.`,`7. The user may speak at any time — stop immediately and listen.`,`8. Use the sections listed above to guide what you highlight next.`].join(`
459
460
  `)},_discard(e){typeof process<`u`&&process.env.NODE_ENV!==`production`&&console.log(`[VoiceSessionStore] discarded: ${e}`);try{sessionStorage.removeItem(oD)}catch{}return null}};function CD(){try{let e=JSON.parse(sessionStorage.getItem(oD)||`null`);return e?.trigger===`agent_navigate`&&Date.now()-(e.ts||0)<1e4}catch{return!1}}var wD={wordsSoFar:0,speechStartTime:0,isSpeaking:!1,items:[],timers:[],lastHighlightId:null,isVoiceMode:!1};function TD(){return wD.wordsSoFar}function ED(){wD.timers.forEach(clearTimeout),wD.wordsSoFar=0,wD.speechStartTime=0,wD.isSpeaking=!1,wD.items=[],wD.timers=[],wD.lastHighlightId=null}var DD=80;function OD(e){requestAnimationFrame(()=>{let t=e.getBoundingClientRect(),n=t.top+t.height/2,r=DD,i=r+(window.innerHeight-r)/2,a=window.pageYOffset+n-i;window.scrollTo({top:Math.max(0,a),behavior:`smooth`})})}function kD(e){if(!e||e.hasAttribute(`data-fe-highlighted`))return;AD(),e.classList?.remove(`fe-highlight-section`,`fe-highlight-speaking`,`fe-highlight-exiting`),OD(e);let t=e.style.cssText;e.setAttribute(`data-fe-highlighted`,`true`),e.setAttribute(`data-fe-orig-style`,t),e.style.outline=`3px solid #2563eb`,e.style.outlineOffset=`8px`,e.style.background=`rgba(37, 99, 235, 0.08)`,e.style.borderRadius=`8px`,e.style.padding=`12px 16px`,e.style.transition=`all 0.4s ease`}function AD(){let e=document.querySelector(`[data-fe-highlighted]`);e&&(e.style.cssText=e.getAttribute(`data-fe-orig-style`)||``,e.removeAttribute(`data-fe-highlighted`),e.removeAttribute(`data-fe-orig-style`))}var Q=`fe-vv`;function jD(){if(typeof document>`u`||document.getElementById(`${Q}-styles`))return;let e=`
460
461
  /* ── Action toast ───────────────────────────────────────────────────────────── */
461
462
  #${Q}-toast {
@@ -27722,7 +27722,7 @@ function AD() {
27722
27722
  function jD(e) {
27723
27723
  if (!e) return "Unknown state.";
27724
27724
  let { state: t, lastAgentText: n, lastUserText: r, toolName: i, toolParams: a, estimatedSpokenWords: o, agentTextWordCount: s, unspokenSuffix: c } = e, l = [];
27725
- return t === "speaking" ? (l.push("You were SPEAKING."), n && (l.push(`You had spoken approximately ${o ?? "?"} of ${s ?? "?"} words.`), l.push(`Your response text: "${n}"`), c && l.push(`Estimated unspoken remainder: "${c}"`))) : t === "listening" ? (l.push("You were LISTENING for the user's response."), r && l.push(`Last user message: "${r}"`)) : t === "tool_calling" ? i === "flowengage_navigate" ? (l.push("Navigation ALREADY COMPLETED — you successfully navigated to this page."), l.push("DO NOT call flowengage_navigate again. You are already on the destination."), n && l.push(`Before navigating you said: "${n}"`)) : (l.push(`You were executing tool: ${i || "unknown"}`), a && l.push(`Tool parameters: ${JSON.stringify(a)}`), n && l.push(`Your last spoken text before the tool call: "${n}"`)) : l.push(`Session state at capture: ${t || "idle"}`), l.join("\n");
27725
+ return t === "speaking" ? (l.push("You were SPEAKING."), n && (l.push(`You had spoken approximately ${o ?? "?"} of ${s ?? "?"} words.`), l.push(`Your response text: "${n}"`), c && l.push(`Estimated unspoken remainder: "${c}"`))) : t === "listening" ? (l.push("You were LISTENING for the user's response."), r && l.push(`Last user message: "${r}"`)) : t === "tool_calling" ? i === "flowengage_navigate" ? (l.push("Navigation ALREADY COMPLETED — you successfully navigated to this page."), l.push("DO NOT call flowengage_navigate again. You are already on the destination."), r && l.push(`The user's last request was: "${r}"`), n && l.push(`Before navigating you said: "${n}"`)) : (l.push(`You were executing tool: ${i || "unknown"}`), a && l.push(`Tool parameters: ${JSON.stringify(a)}`), n && l.push(`Your last spoken text before the tool call: "${n}"`)) : l.push(`Session state at capture: ${t || "idle"}`), l.join("\n");
27726
27726
  }
27727
27727
  function MD(e, t) {
27728
27728
  try {
@@ -27870,31 +27870,36 @@ var FD = {
27870
27870
  } catch {}
27871
27871
  },
27872
27872
  buildResumePrompt(e, t, n) {
27873
- let r = (e.history || []).map((e) => `[${e.sender === "user" ? "User" : "Agent"}]: ${e.message}`).join("\n"), i = jD(e.interruption), a = (t || []).map((e) => e.text).join(", "), o = "", s = "";
27873
+ let r = (e.history || []).map((e) => `[${e.sender === "user" ? "User" : "Agent"}]: ${e.message}`).join("\n"), i = e.interruption?.lastUserText;
27874
+ if (i) {
27875
+ let t = [...e.history || []].reverse().find((e) => e.sender === "user");
27876
+ (!t || t.message !== i) && (r += (r ? "\n" : "") + `[User]: ${i}`);
27877
+ }
27878
+ let a = jD(e.interruption), o = (t || []).map((e) => e.text).join(", "), s = "", c = "";
27874
27879
  try {
27875
- o = new URL(e.fromUrl || "").pathname;
27880
+ s = new URL(e.fromUrl || "").pathname;
27876
27881
  } catch {
27877
- o = e.fromUrl || "";
27882
+ s = e.fromUrl || "";
27878
27883
  }
27879
27884
  try {
27880
- s = new URL(n || window.location.href).pathname;
27885
+ c = new URL(n || window.location.href).pathname;
27881
27886
  } catch {
27882
- s = n || "";
27887
+ c = n || "";
27883
27888
  }
27884
27889
  return [
27885
27890
  "VOICE SESSION AUTO-RESUMED AFTER PAGE NAVIGATION.",
27886
27891
  `Navigation confidence: ${(e.navigationConfidence || "medium").toUpperCase()}`,
27887
- `Navigation: ${o} → ${s}`,
27892
+ `Navigation: ${s} → ${c}`,
27888
27893
  "",
27889
27894
  `── Prior Conversation (${e.historyTotalTurns} turns) ──`,
27890
27895
  r || "(no prior turns)",
27891
27896
  "",
27892
27897
  "── Your State at Interruption ──",
27893
- i,
27898
+ a,
27894
27899
  "",
27895
27900
  "── Current Page ──",
27896
27901
  `URL: ${n || (typeof window < "u" ? window.location.href : "")}`,
27897
- `Sections: ${a || "none detected"}`,
27902
+ `Sections: ${o || "none detected"}`,
27898
27903
  "",
27899
27904
  "── CRITICAL INSTRUCTIONS ──",
27900
27905
  "1. DO NOT re-introduce yourself.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowengage/react-chatbot",
3
- "version": "1.8.13",
3
+ "version": "1.8.14",
4
4
  "description": "Embeddable AI chat widget for React — powered by FlowEngage. Drop it in with a single siteId.",
5
5
  "keywords": [
6
6
  "chatbot",