@flowengage/react-chatbot 1.5.5 → 1.5.7

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.
@@ -335,18 +335,18 @@ class ScribeAudioProcessor extends AudioWorkletProcessor {
335
335
 
336
336
  registerProcessor("scribeAudioProcessor", ScribeAudioProcessor);
337
337
 
338
- `),iE,aE;(function(e){e.PCM_8000=`pcm_8000`,e.PCM_16000=`pcm_16000`,e.PCM_22050=`pcm_22050`,e.PCM_24000=`pcm_24000`,e.PCM_44100=`pcm_44100`,e.PCM_48000=`pcm_48000`,e.ULAW_8000=`ulaw_8000`})(iE||={}),function(e){e.MANUAL=`manual`,e.VAD=`vad`}(aE||={});var oE=class e{static getWebSocketUri(t=e.DEFAULT_BASE_URI){return`${t}/v1/speech-to-text/realtime`}static buildWebSocketUri(t){let n=e.getWebSocketUri(t.baseUri),r=new URLSearchParams;if(r.append(`model_id`,t.modelId),r.append(`token`,t.token),t.commitStrategy!==void 0&&r.append(`commit_strategy`,t.commitStrategy),t.audioFormat!==void 0&&r.append(`audio_format`,t.audioFormat),t.vadSilenceThresholdSecs!==void 0){if(t.vadSilenceThresholdSecs<=.3||t.vadSilenceThresholdSecs>3)throw Error(`vadSilenceThresholdSecs must be between 0.3 and 3.0`);r.append(`vad_silence_threshold_secs`,t.vadSilenceThresholdSecs.toString())}if(t.vadThreshold!==void 0){if(t.vadThreshold<.1||t.vadThreshold>.9)throw Error(`vadThreshold must be between 0.1 and 0.9`);r.append(`vad_threshold`,t.vadThreshold.toString())}if(t.minSpeechDurationMs!==void 0){if(t.minSpeechDurationMs<=50||t.minSpeechDurationMs>2e3)throw Error(`minSpeechDurationMs must be between 50 and 2000`);r.append(`min_speech_duration_ms`,t.minSpeechDurationMs.toString())}if(t.minSilenceDurationMs!==void 0){if(t.minSilenceDurationMs<=50||t.minSilenceDurationMs>2e3)throw Error(`minSilenceDurationMs must be between 50 and 2000`);r.append(`min_silence_duration_ms`,t.minSilenceDurationMs.toString())}t.languageCode!==void 0&&r.append(`language_code`,t.languageCode),t.includeTimestamps!==void 0&&r.append(`include_timestamps`,t.includeTimestamps?`true`:`false`);let i=r.toString();return i?`${n}?${i}`:n}static connect(t){if(!t.modelId)throw Error(`modelId is required`);let n=new nE(`microphone`in t&&t.microphone?16e3:t.sampleRate),r=e.buildWebSocketUri(t),i=new WebSocket(r);return`microphone`in t&&t.microphone&&i.addEventListener(`open`,()=>{e.streamFromMicrophone(t,n)}),n.setWebSocket(i),n}static async streamFromMicrophone(e,t){try{var n,r,i;let a=await navigator.mediaDevices.getUserMedia({audio:{deviceId:e.microphone?.deviceId,echoCancellation:(n=e.microphone?.echoCancellation)==null||n,noiseSuppression:(r=e.microphone?.noiseSuppression)==null||r,autoGainControl:(i=e.microphone?.autoGainControl)==null||i,channelCount:e.microphone?.channelCount??1,sampleRate:{ideal:16e3}}}),o=new AudioContext({sampleRate:16e3});await rE(o.audioWorklet);let s=o.createMediaStreamSource(a),c=new AudioWorkletNode(o,`scribeAudioProcessor`);c.port.onmessage=e=>{let{audioData:n}=e.data,r=new Uint8Array(n),i=``;for(let e=0;e<r.length;e++)i+=String.fromCharCode(r[e]);let a=btoa(i);t.send({audioBase64:a})},s.connect(c),o.state===`suspended`&&await o.resume(),t._audioCleanup=()=>{a.getTracks().forEach(e=>{e.stop()}),s.disconnect(),c.disconnect(),o.close()}}catch(e){throw console.error(`Failed to start microphone streaming:`,e),e}}};oE.DEFAULT_BASE_URI=`wss://api.elevenlabs.io`;var sE=class extends jT{static startSession(e){return e.textOnly?JT.startSession(e):$T.startSession(e)}},cE=({size:e=20})=>(0,N.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M10.68 13.31a16 16 0 003.41 2.6l1.27-1.27a2 2 0 012.11-.45 12.84 12.84 0 002.81.7 2 2 0 011.72 2v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.42 19.42 0 013.07 8.62 19.79 19.79 0 01.1 2 2 2 0 012.11 0h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L6.18 7.84`}),(0,N.jsx)(`line`,{x1:`23`,y1:`1`,x2:`1`,y2:`23`})]}),lE=()=>(0,N.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`5`}),(0,N.jsx)(`polyline`,{points:`5 12 12 5 19 12`})]}),uE=()=>(0,N.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`polyline`,{points:`9 17 4 12 9 7`}),(0,N.jsx)(`path`,{d:`M20 18v-2a4 4 0 00-4-4H4`})]}),dE=()=>(0,N.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,N.jsx)(`path`,{d:`M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.42 19.42 0 01-6.12-6.11A19.79 19.79 0 012 4.11 2 2 0 014.11 2h3a2 2 0 012 1.72c.13.96.37 1.91.71 2.81a2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.9.34 1.85.58 2.81.71A2 2 0 0122 16.92z`})}),fE=({className:e=``})=>(0,N.jsxs)(`svg`,{className:e,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,N.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,N.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),pE=({size:e=14})=>(0,N.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M12 8V4H8`}),(0,N.jsx)(`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`}),(0,N.jsx)(`path`,{d:`M2 14h2`}),(0,N.jsx)(`path`,{d:`M20 14h2`}),(0,N.jsx)(`path`,{d:`M15 13v2`}),(0,N.jsx)(`path`,{d:`M9 13v2`})]}),mE=({size:e=20,strokeWidth:t=2,color:n=`currentColor`})=>(0,N.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:n,strokeWidth:t,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,N.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),hE=(e=``)=>String(e).replace(/<[^>]+>/g,``).replace(/\s+/g,` `).trim(),gE=(e=``)=>String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`);function _E(e){let t=String(e||``).trim();if(!t)return t;let n=/^<p>\s*<strong>([\s\S]*?)<\/strong>\s*<\/p>$/i.exec(t);if(n&&!/<\/?strong\b/i.test(n[1]))return`<p>${n[1]}</p>`;let r=/^<strong>([\s\S]*?)<\/strong>$/i.exec(t);if(r&&!/<\/?strong\b/i.test(r[1])){let e=r[1].trim();return/^<(?:p|ul|ol)\b/i.test(e)?e:`<p>${e}</p>`}return e}var vE=(e=``)=>{let t=String(e||``).trim();if(!t)return``;if(/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t))return _E(t);let n=t.replace(/\r\n/g,`
338
+ `),iE,aE;(function(e){e.PCM_8000=`pcm_8000`,e.PCM_16000=`pcm_16000`,e.PCM_22050=`pcm_22050`,e.PCM_24000=`pcm_24000`,e.PCM_44100=`pcm_44100`,e.PCM_48000=`pcm_48000`,e.ULAW_8000=`ulaw_8000`})(iE||={}),function(e){e.MANUAL=`manual`,e.VAD=`vad`}(aE||={});var oE=class e{static getWebSocketUri(t=e.DEFAULT_BASE_URI){return`${t}/v1/speech-to-text/realtime`}static buildWebSocketUri(t){let n=e.getWebSocketUri(t.baseUri),r=new URLSearchParams;if(r.append(`model_id`,t.modelId),r.append(`token`,t.token),t.commitStrategy!==void 0&&r.append(`commit_strategy`,t.commitStrategy),t.audioFormat!==void 0&&r.append(`audio_format`,t.audioFormat),t.vadSilenceThresholdSecs!==void 0){if(t.vadSilenceThresholdSecs<=.3||t.vadSilenceThresholdSecs>3)throw Error(`vadSilenceThresholdSecs must be between 0.3 and 3.0`);r.append(`vad_silence_threshold_secs`,t.vadSilenceThresholdSecs.toString())}if(t.vadThreshold!==void 0){if(t.vadThreshold<.1||t.vadThreshold>.9)throw Error(`vadThreshold must be between 0.1 and 0.9`);r.append(`vad_threshold`,t.vadThreshold.toString())}if(t.minSpeechDurationMs!==void 0){if(t.minSpeechDurationMs<=50||t.minSpeechDurationMs>2e3)throw Error(`minSpeechDurationMs must be between 50 and 2000`);r.append(`min_speech_duration_ms`,t.minSpeechDurationMs.toString())}if(t.minSilenceDurationMs!==void 0){if(t.minSilenceDurationMs<=50||t.minSilenceDurationMs>2e3)throw Error(`minSilenceDurationMs must be between 50 and 2000`);r.append(`min_silence_duration_ms`,t.minSilenceDurationMs.toString())}t.languageCode!==void 0&&r.append(`language_code`,t.languageCode),t.includeTimestamps!==void 0&&r.append(`include_timestamps`,t.includeTimestamps?`true`:`false`);let i=r.toString();return i?`${n}?${i}`:n}static connect(t){if(!t.modelId)throw Error(`modelId is required`);let n=new nE(`microphone`in t&&t.microphone?16e3:t.sampleRate),r=e.buildWebSocketUri(t),i=new WebSocket(r);return`microphone`in t&&t.microphone&&i.addEventListener(`open`,()=>{e.streamFromMicrophone(t,n)}),n.setWebSocket(i),n}static async streamFromMicrophone(e,t){try{var n,r,i;let a=await navigator.mediaDevices.getUserMedia({audio:{deviceId:e.microphone?.deviceId,echoCancellation:(n=e.microphone?.echoCancellation)==null||n,noiseSuppression:(r=e.microphone?.noiseSuppression)==null||r,autoGainControl:(i=e.microphone?.autoGainControl)==null||i,channelCount:e.microphone?.channelCount??1,sampleRate:{ideal:16e3}}}),o=new AudioContext({sampleRate:16e3});await rE(o.audioWorklet);let s=o.createMediaStreamSource(a),c=new AudioWorkletNode(o,`scribeAudioProcessor`);c.port.onmessage=e=>{let{audioData:n}=e.data,r=new Uint8Array(n),i=``;for(let e=0;e<r.length;e++)i+=String.fromCharCode(r[e]);let a=btoa(i);t.send({audioBase64:a})},s.connect(c),o.state===`suspended`&&await o.resume(),t._audioCleanup=()=>{a.getTracks().forEach(e=>{e.stop()}),s.disconnect(),c.disconnect(),o.close()}}catch(e){throw console.error(`Failed to start microphone streaming:`,e),e}}};oE.DEFAULT_BASE_URI=`wss://api.elevenlabs.io`;var sE=class extends jT{static startSession(e){return e.textOnly?JT.startSession(e):$T.startSession(e)}},cE=375,lE=6e3,uE={wordsSoFar:0,speechStartTime:0,isVoice:!1,items:[],timers:[],textDraining:!1,lastHighlightId:null};function dE(e){let t=Math.max(0,e.wordOffset*cE-(Date.now()-uE.speechStartTime));uE.timers.push(setTimeout(e.execute,t))}function fE(){if(!uE.items.length){uE.textDraining=!1;return}uE.textDraining=!0;let e=uE.items.shift();setTimeout(e.execute,300),uE.timers.push(setTimeout(fE,e.holdMs))}function pE(e){uE.isVoice?uE.speechStartTime>0?dE(e):(uE.items.push(e),uE.timers.push(setTimeout(()=>{let t=uE.items.indexOf(e);t!==-1&&(uE.items.splice(t,1),e.execute())},lE))):(uE.items.push(e),uE.textDraining||fE())}function mE(e,t=5e3){pE({execute:e,wordOffset:uE.wordsSoFar,holdMs:t})}function hE(e,t,n=5e3){pE({execute:e,wordOffset:t,holdMs:n})}function gE(){uE.speechStartTime=Date.now(),uE.items.forEach(dE),uE.items=[]}function _E(){uE.items.forEach(e=>e.execute()),uE.items=[]}function vE(e){uE.wordsSoFar+=e}function yE(){return uE.wordsSoFar}function bE(e){uE.isVoice=e}function xE(e){uE.lastHighlightId=e}function SE(){uE.timers.forEach(clearTimeout),Object.assign(uE,{wordsSoFar:0,speechStartTime:0,items:[],timers:[],textDraining:!1,lastHighlightId:null})}var CE=null;function wE(e){try{e.scrollIntoView({behavior:`smooth`,block:`center`})}catch{}}function TE(e){EE(),CE=Object.assign(document.createElement(`div`),{id:`fe-spotlight-overlay`}),CE.style.cssText=`position:fixed;inset:0;background:rgba(0,0,0,0.35);z-index:9998;pointer-events:none;transition:opacity 0.4s ease;opacity:0;`,document.body.appendChild(CE),CE.offsetHeight,CE.style.opacity=`1`,e.style.position=`relative`,e.style.zIndex=`9999`}function EE(){if(CE){CE.style.opacity=`0`;let e=CE;setTimeout(()=>e.parentNode?.removeChild(e),400),CE=null}document.querySelectorAll(`[data-fe-highlighted]`).forEach(e=>{e.style.zIndex=``,e.style.position=``})}function DE(e){!e||e.hasAttribute(`data-fe-highlighted`)||(OE(),wE(e),e.setAttribute(`data-fe-orig-style`,e.style.cssText),e.setAttribute(`data-fe-highlighted`,`true`),Object.assign(e.style,{outline:`3px solid #2563eb`,outlineOffset:`8px`,background:`rgba(37,99,235,0.08)`,borderRadius:`8px`,padding:`12px 16px`,transition:`all 0.4s ease`}),TE(e),setTimeout(OE,6e4))}function OE(){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`)),EE()}function kE(){return Array.from(document.querySelectorAll(`h2, h3`)).map(e=>{let t=e.textContent.trim().replace(/[\u2013\u2014:]/g,` `).replace(/\([^)]*\)/g,``).replace(/\s+/g,` `).trim().toLowerCase(),n=t.split(` `).filter(e=>e.length>2),r=[t];for(let e=0;e<=n.length-2;e++)r.push(n.slice(e,e+2).join(` `)),e<=n.length-3&&r.push(n.slice(e,e+3).join(` `));return{element:e,id:e.id||t.replace(/\s+/g,`-`).slice(0,60),keywords:r}})}function AE(e,t=!1){let n=kE();if(!n.length)return;let r=e.toLowerCase(),i=yE(),a=t?400:240,o=e.trim().split(/\s+/).length,s=n.map(t=>{let n=t.keywords.filter(e=>e.length>=10).reduce((e,t)=>{let n=r.indexOf(t);return n!==-1&&n<e?n:e},1/0);return n===1/0?null:{entry:t,wordOffset:e.substring(0,n).trim().split(/\s+/).filter(Boolean).length}}).filter(Boolean).sort((e,t)=>e.wordOffset-t.wordOffset);if(!s.length)return;let c=new Set;s.forEach(({entry:e,wordOffset:t},n)=>{if(c.has(e.id))return;c.add(e.id);let r=s[n+1]?.wordOffset??o,l=Math.max(3e3,Math.min((r-t)*a,2e4)),{element:u,id:d}=e;hE(()=>{xE(d),DE(u)},i+t,l)})}var jE=({size:e=20})=>(0,N.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M10.68 13.31a16 16 0 003.41 2.6l1.27-1.27a2 2 0 012.11-.45 12.84 12.84 0 002.81.7 2 2 0 011.72 2v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.42 19.42 0 013.07 8.62 19.79 19.79 0 01.1 2 2 2 0 012.11 0h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L6.18 7.84`}),(0,N.jsx)(`line`,{x1:`23`,y1:`1`,x2:`1`,y2:`23`})]}),ME=()=>(0,N.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`5`}),(0,N.jsx)(`polyline`,{points:`5 12 12 5 19 12`})]}),NE=()=>(0,N.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`polyline`,{points:`9 17 4 12 9 7`}),(0,N.jsx)(`path`,{d:`M20 18v-2a4 4 0 00-4-4H4`})]}),PE=()=>(0,N.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,N.jsx)(`path`,{d:`M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.42 19.42 0 01-6.12-6.11A19.79 19.79 0 012 4.11 2 2 0 014.11 2h3a2 2 0 012 1.72c.13.96.37 1.91.71 2.81a2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.9.34 1.85.58 2.81.71A2 2 0 0122 16.92z`})}),FE=({className:e=``})=>(0,N.jsxs)(`svg`,{className:e,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,N.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,N.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),IE=({size:e=14})=>(0,N.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M12 8V4H8`}),(0,N.jsx)(`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`}),(0,N.jsx)(`path`,{d:`M2 14h2`}),(0,N.jsx)(`path`,{d:`M20 14h2`}),(0,N.jsx)(`path`,{d:`M15 13v2`}),(0,N.jsx)(`path`,{d:`M9 13v2`})]}),LE=({size:e=20,strokeWidth:t=2,color:n=`currentColor`})=>(0,N.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:n,strokeWidth:t,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,N.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),RE=(e=``)=>String(e).replace(/<[^>]+>/g,``).replace(/\s+/g,` `).trim(),zE=(e=``)=>String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`);function BE(e){let t=String(e||``).trim();if(!t)return t;let n=/^<p>\s*<strong>([\s\S]*?)<\/strong>\s*<\/p>$/i.exec(t);if(n&&!/<\/?strong\b/i.test(n[1]))return`<p>${n[1]}</p>`;let r=/^<strong>([\s\S]*?)<\/strong>$/i.exec(t);if(r&&!/<\/?strong\b/i.test(r[1])){let e=r[1].trim();return/^<(?:p|ul|ol)\b/i.test(e)?e:`<p>${e}</p>`}return e}var VE=(e=``)=>{let t=String(e||``).trim();if(!t)return``;if(/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t))return BE(t);let n=t.replace(/\r\n/g,`
339
339
  `).replace(/\n{3,}/g,`
340
340
 
341
- `).split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean),r=e=>gE(e).replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g,`<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/\*([^*\n]+)\*/g,`<em>$1</em>`);return _E(n.map(e=>{let t=e.split(`
342
- `).map(e=>e.trim()).filter(Boolean),n=t.filter(e=>/^[-*]\s+/.test(e));if(n.length>=2&&n.length===t.length)return`<ul>${n.map(e=>`<li>${r(e.replace(/^[-*]\s+/,``))}</li>`).join(``)}</ul>`;let i=e.split(/\s+(?=[-*]\s+\*\*?)/).map(e=>e.trim()).filter(Boolean);return i.length>=2&&i.every(e=>/^[-*]\s+/.test(e))?`<ul>${i.map(e=>`<li>${r(e.replace(/^[-*]\s+/,``))}</li>`).join(``)}</ul>`:`<p>${r(e).replace(/\n/g,`<br />`)}</p>`}).join(``))},yE=new Set([`application/pdf`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`]),bE=new Set([`.pdf`,`.docx`,`.png`,`.jpg`,`.jpeg`]),xE=`image/png,image/jpeg,.pdf,.docx`;function SE(e){if(!e)return!1;let t=typeof e.name==`string`?e.name.toLowerCase():``,n=t.includes(`.`)?`.${t.split(`.`).pop()}`:``,r=typeof e.type==`string`?e.type.toLowerCase():``;return r===`image/png`||r===`image/jpeg`||yE.has(r)||bE.has(n)}function CE(e){return e?SE(e)?e.size>2097152?`File must be 2 MB or smaller.`:``:`Only PNG, JPEG, PDF, and DOCX files are allowed.`:`No file selected.`}function wE(e=0){if(!Number.isFinite(e)||e<=0)return``;let t=[`B`,`KB`,`MB`,`GB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;let i=n>=10||r===0?0:1;return`${n.toFixed(i)} ${t[r]}`}function TE(e){return e?e.name||`Attachment`:``}function EE(e){if(!e||typeof e!=`string`)return`?`;let t=e.trim();if(!t)return`?`;let n=t.split(/\s+/).filter(Boolean);return n.length>=2?`${n[0][0]}${n[n.length-1][0]}`.toUpperCase():t.slice(0,2).toUpperCase()}function DE({src:e,name:t,imgStyle:n,initialsSpanStyle:r}){let[i,a]=(0,b.useState)(!1),o=typeof e==`string`?e.trim():``;return(0,b.useEffect)(()=>{a(!1)},[o]),o&&!i?(0,N.jsx)(`img`,{src:o,alt:``,onError:()=>a(!0),style:n}):(0,N.jsx)(`span`,{style:r,children:EE(t)})}function OE({chatHistory:e,isAiTyping:t,isAgentTyping:n,setReplyContext:r,TypingDots:i,primaryColor:a=`#3B82F6`,agentHeadshot:o=null,agentDisplayName:s=`Agent`,botAvatarNode:c=null}){let l=(0,b.useRef)(null),u=e=>{if(!e)return`just now`;let t=new Date,n=new Date(e),r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return`just now`;let i=Math.floor(r/60);if(i<60)return`${i} min${i>1?`s`:``} ago`;let a=Math.floor(i/60);if(a<24)return`${a} hr${a>1?`s`:``} ago`;let o=Math.floor(a/24);return`${o} day${o>1?`s`:``} ago`};return(0,b.useEffect)(()=>{l.current&&l.current.scrollIntoView({behavior:`smooth`})},[e.length,t,n]),(0,N.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,padding:`10px 16px 20px`,display:`flex`,flexDirection:`column`,background:`transparent`},children:[e.map(e=>{let t=e.sender===`system`,n=e.sender===`user`,i=e.sender===`ai`||e.sender===`bot`,l=e.sender===`agent`,d=e.isPending,f=e.type===`file`&&e.metadata?.fileUrl,p=e.agent_name||e.agentName||e.metadata?.agentName||s,m=typeof e.sender_headshot==`string`&&e.sender_headshot.trim()||typeof o==`string`&&o.trim()||null,h=hE(e.replyToContent||e.replyContext?.message||``),g=e.replyToSender===`user`?`You`:e.replyToSender===`agent`?`Agent`:e.replyToSender===`ai`||e.replyToSender===`bot`?`AI Assistant`:`Message`;return t?(0,N.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,margin:`8px 0`},children:(0,N.jsx)(`div`,{style:{padding:`6px 12px`,borderRadius:`9999px`,background:`#f3f4f6`,color:`#6b7280`,fontSize:`12px`,fontWeight:500},children:e.message})},e.id):(0,N.jsxs)(`div`,{style:{display:`flex`,justifyContent:n?`flex-end`:`flex-start`,alignItems:`flex-start`,marginBottom:`16px`,gap:`8px`,flexDirection:`row`},children:[!n&&(i||l)&&(0,N.jsx)(`div`,{style:{width:`32px`,height:`32px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,background:l?`#f3f4f6`:c&&i?`transparent`:`var(--flowengage-primary)`,color:l?a:`#fff`,boxShadow:l?`0 2px 8px rgba(0,0,0,0.06)`:c&&i?`none`:`0 8px 20px rgba(59,130,246,0.24)`,overflow:`hidden`,border:l?`1px solid ${a}22`:`none`,fontSize:`12px`,fontWeight:800,marginTop:!d&&(i||l)?`22px`:`0px`},children:i?c||(0,N.jsx)(pE,{size:16}):(0,N.jsx)(DE,{src:m||``,name:p,imgStyle:{width:`100%`,height:`100%`,objectFit:`cover`},initialsSpanStyle:{lineHeight:1}})}),(0,N.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:n?`flex-end`:`flex-start`,maxWidth:`75%`,minWidth:0},children:[!d&&!n&&(i||l)&&(0,N.jsxs)(`button`,{type:`button`,onClick:()=>r(e),style:{opacity:1,marginBottom:`4px`,display:`flex`,alignItems:`center`,gap:`4px`,fontSize:`11px`,color:`#9ca3af`,background:`transparent`,border:0,cursor:`pointer`,padding:0,marginLeft:`2px`},onMouseEnter:e=>{e.currentTarget.style.color=`#4b5563`},onMouseLeave:e=>{e.currentTarget.style.color=`#9ca3af`},children:[(0,N.jsx)(uE,{}),`Reply`]}),(0,N.jsxs)(`div`,{style:{padding:`12px 16px`,borderRadius:n?`20px 6px 20px 20px`:`6px 20px 20px 20px`,lineHeight:1.5,boxShadow:`0 2px 8px rgba(0,0,0,0.06)`,background:n?`var(--flowengage-primary)`:`rgba(255,255,255,0.92)`,color:n?`#fff`:`#111827`,fontSize:`14px`,opacity:d?.55:1,transition:`opacity 0.3s ease`,wordBreak:`break-word`,width:`fit-content`},children:[h&&(0,N.jsxs)(`div`,{style:{marginBottom:`8px`,borderRadius:`14px`,borderLeft:n?`2px solid rgba(255,255,255,0.8)`:`2px solid var(--flowengage-primary)`,padding:`8px 12px`,fontSize:`12px`,background:n?`rgba(255,255,255,0.15)`:`#f9fafb`,color:n?`rgba(255,255,255,0.9)`:`#6b7280`},children:[(0,N.jsx)(`div`,{style:{marginBottom:`2px`,fontWeight:600},children:g}),(0,N.jsx)(`div`,{style:{display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`},children:h})]}),f?(()=>{let t=e.metadata.fileType||``,r=e.metadata.fileName||e.message||`File`,i=wE(e.metadata.fileSize),a=t.startsWith(`image/`),o=t===`application/pdf`?{color:`#ef4444`,label:`PDF`}:t.includes(`word`)||t.includes(`docx`)?{color:`#3b82f6`,label:`DOCX`}:t.includes(`excel`)||t.includes(`sheet`)||t===`text/csv`?{color:`#10b981`,label:`XLSX`}:{color:`#6b7280`,label:`FILE`};return(0,N.jsx)(`div`,{style:{minWidth:`200px`,maxWidth:`240px`},children:(0,N.jsx)(`a`,{href:e.metadata.fileUrl,target:`_blank`,rel:`noopener noreferrer`,style:{textDecoration:`none`,display:`block`},children:a?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`img`,{src:e.metadata.fileUrl,alt:r,style:{width:`100%`,borderRadius:`10px`,display:`block`,maxHeight:`180px`,objectFit:`cover`}}),(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginTop:`7px`,gap:`6px`},children:[(0,N.jsx)(`span`,{style:{fontSize:`12px`,color:n?`rgba(255,255,255,0.85)`:`#374151`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},children:r}),i&&(0,N.jsx)(`span`,{style:{fontSize:`11px`,flexShrink:0,color:n?`rgba(255,255,255,0.6)`:`#9ca3af`},children:i})]})]}):(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`10px`,background:n?`rgba(255,255,255,0.15)`:`#f3f4f6`,borderRadius:`12px`,padding:`10px 12px`},children:[(0,N.jsxs)(`div`,{style:{width:`38px`,height:`46px`,borderRadius:`8px`,background:n?`rgba(255,255,255,0.22)`:`#fff`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,flexShrink:0,boxShadow:`0 1px 4px rgba(0,0,0,0.1)`,gap:`3px`},children:[(0,N.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:n?`#fff`:o.color,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,N.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]}),(0,N.jsx)(`span`,{style:{fontSize:`7px`,fontWeight:800,letterSpacing:`0.04em`,color:n?`#fff`:o.color,lineHeight:1},children:o.label})]}),(0,N.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,N.jsx)(`div`,{style:{fontSize:`13px`,fontWeight:600,color:n?`#fff`:`#111827`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:r}),i&&(0,N.jsx)(`div`,{style:{fontSize:`11px`,marginTop:`3px`,color:n?`rgba(255,255,255,0.6)`:`#9ca3af`},children:i})]}),(0,N.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:n?`rgba(255,255,255,0.65)`:`#9ca3af`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,N.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,N.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,N.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})]})})})})():i?(0,N.jsx)(`div`,{className:`flowengage-message-content fe-bot-message`,dangerouslySetInnerHTML:{__html:vE(e.message)}}):(0,N.jsx)(`div`,{style:{whiteSpace:n||l?`normal`:`pre-wrap`},children:e.message}),d&&(0,N.jsx)(`span`,{style:{fontSize:`10px`,marginLeft:`6px`,opacity:.7},children:`sending…`})]}),(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`4px`,marginTop:`4px`,padding:`0 4px`,alignSelf:n?`flex-end`:`flex-start`},children:[(0,N.jsx)(`span`,{style:{fontSize:`10px`,color:`#9ca3af`,fontWeight:500},children:u(e.timestamp||e.createdAt)}),(0,N.jsx)(`span`,{style:{fontSize:`10px`,fontWeight:700,color:n?`var(--flowengage-primary)`:`#9ca3af`},children:d?`○`:`✓`})]})]})]},e.id)}),t&&(0,N.jsxs)(`div`,{style:{marginBottom:`16px`,display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,N.jsx)(`div`,{style:{width:`32px`,height:`32px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,background:c?`transparent`:`var(--flowengage-primary)`,color:`#fff`,boxShadow:c?`none`:`0 8px 20px rgba(59,130,246,0.24)`,overflow:`hidden`},children:c||(0,N.jsx)(pE,{size:16})}),(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`2px`,color:`#374151`,fontSize:`13px`,fontWeight:500,fontStyle:`italic`},children:[`Analysing`,[0,1,2].map(e=>(0,N.jsx)(`span`,{style:{animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`},children:`.`},e))]})]}),n&&(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`8px`,marginBottom:`12px`},children:[(0,N.jsx)(`div`,{style:{width:`32px`,height:`32px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,overflow:`hidden`},children:(0,N.jsx)(DE,{src:o||``,name:s,imgStyle:{width:`100%`,height:`100%`,objectFit:`cover`},initialsSpanStyle:{lineHeight:1}})}),(0,N.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`12px 16px`,borderRadius:`18px`,background:`#fff`,boxShadow:`0 2px 6px rgba(0,0,0,0.04)`},children:[0,1,2].map(e=>(0,N.jsx)(`span`,{style:{width:`7px`,height:`7px`,borderRadius:`50%`,background:`#9ca3af`,animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`}},e))})]}),(0,N.jsx)(`div`,{ref:l})]})}function kE({input:e,setInput:t,onSubmit:n,isConversationEnded:r,callUiActive:i,handleToggleVoice:a,activeScreen:o,inputDisabled:s,replyContext:c,clearReplyContext:l,requiresEmail:u,emailInput:d,setEmailInput:f,emailError:p,showVoiceToggle:m=!1,voiceEnabled:h=!0,onFileSelect:g,selectedFile:_=null,onRemoveSelectedFile:v,attachmentError:y=``,isUploadingAttachment:x=!1,inputPlaceholder:ee=`Type your message`}){let S=(0,b.useRef)(null),C=c?.sender===`user`?`You`:c?.sender===`agent`?`Agent`:`AI Assistant`,te=u?!!d?.trim():!!e?.trim()||!!_,ne=s||x||!te,re=!u&&h&&m;return(0,N.jsxs)(`div`,{style:{padding:`0 20px`,background:`transparent`},children:[r&&(0,N.jsx)(`div`,{style:{marginBottom:`8px`,padding:`8px 16px`,borderRadius:`12px`,background:`#f3f4f6`,color:`#6b7280`,fontSize:`12px`,textAlign:`center`,fontWeight:500},children:`This conversation has ended.`}),c&&(0,N.jsxs)(`div`,{style:{marginBottom:`8px`,display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,gap:`12px`,borderRadius:`16px`,border:`1px solid rgba(0,0,0,0.05)`,background:`#fff`,padding:`12px 16px`,boxShadow:`0 8px 24px rgba(0,0,0,0.05)`},children:[(0,N.jsxs)(`div`,{style:{minWidth:0,flex:1,borderLeft:`2px solid var(--flowengage-primary)`,paddingLeft:`12px`},children:[(0,N.jsxs)(`div`,{style:{fontSize:`12px`,fontWeight:600,color:`var(--flowengage-primary)`},children:[`Replying to `,C]}),(0,N.jsx)(`div`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:`12px`,color:`#6b7280`},children:c.replyToContent||c.message})]}),(0,N.jsx)(`button`,{type:`button`,style:{width:`28px`,height:`28px`,borderRadius:`9999px`,border:0,background:`#f3f4f6`,color:`#6b7280`,transition:`color 0.2s ease, background 0.2s ease`,cursor:`pointer`},onClick:l,"aria-label":`Cancel reply`,onMouseEnter:e=>{e.currentTarget.style.background=`#e5e7eb`,e.currentTarget.style.color=`#374151`},onMouseLeave:e=>{e.currentTarget.style.background=`#f3f4f6`,e.currentTarget.style.color=`#6b7280`},children:`×`})]}),u&&(0,N.jsx)(`div`,{style:{marginBottom:`8px`,padding:`0 8px`},children:(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`8px`,color:`#111827`,fontSize:`14px`,fontWeight:500,textAlign:`center`},children:[(0,N.jsx)(`span`,{style:{display:`inline-flex`,width:`22px`,height:`22px`,borderRadius:`9999px`,alignItems:`center`,justifyContent:`center`,background:`rgba(59,130,246,0.08)`,color:`var(--flowengage-primary)`},children:(0,N.jsx)(pE,{size:13})}),(0,N.jsx)(`span`,{children:`Please provide your email address so we can help you.`})]})}),_&&!u&&(0,N.jsxs)(`div`,{style:{marginBottom:`10px`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`12px`,borderRadius:`16px`,border:`1px solid rgba(0,0,0,0.06)`,background:`#fff`,padding:`12px 14px`,boxShadow:`0 8px 24px rgba(0,0,0,0.05)`},children:[(0,N.jsxs)(`div`,{style:{minWidth:0,flex:1},children:[(0,N.jsx)(`div`,{style:{fontSize:`12px`,fontWeight:600,color:`var(--flowengage-primary)`,marginBottom:`2px`},children:`Attachment ready`}),(0,N.jsx)(`div`,{style:{fontSize:`13px`,color:`#111827`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:TE(_)}),(0,N.jsx)(`div`,{style:{fontSize:`12px`,color:`#6b7280`,marginTop:`2px`},children:wE(_.size)})]}),(0,N.jsx)(`button`,{type:`button`,style:{width:`28px`,height:`28px`,borderRadius:`9999px`,border:0,background:`#f3f4f6`,color:`#6b7280`,transition:`color 0.2s ease, background 0.2s ease`,cursor:`pointer`,flexShrink:0},onClick:v,"aria-label":`Remove attachment`,onMouseEnter:e=>{e.currentTarget.style.background=`#e5e7eb`,e.currentTarget.style.color=`#374151`},onMouseLeave:e=>{e.currentTarget.style.background=`#f3f4f6`,e.currentTarget.style.color=`#6b7280`},children:`×`})]}),(0,N.jsxs)(`form`,{style:{display:`flex`,alignItems:`center`,gap:`12px`,padding:`8px`,border:`1px solid rgba(0,0,0,0.06)`,borderRadius:`9999px`,background:`#fff`,boxShadow:`0 4px 14px rgba(0,0,0,0.04)`,opacity:r?.5:1},onSubmit:n,children:[re?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`input`,{ref:S,type:`file`,accept:xE,style:{display:`none`},onChange:e=>{let t=e.target.files?.[0];t&&g?.(t),e.target.value=``}}),(0,N.jsx)(`button`,{type:`button`,style:{width:`36px`,height:`36px`,borderRadius:`9999px`,background:`#f3f4f8`,color:`var(--flowengage-primary)`,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`background 0.2s ease, opacity 0.2s ease`,border:0,cursor:`pointer`,flexShrink:0},onClick:()=>S.current?.click(),title:`Attach file`,"aria-label":`Attach file`,disabled:r||x,onMouseEnter:e=>{e.currentTarget.style.opacity=`0.8`},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`},children:(0,N.jsx)(mE,{size:18,color:`currentColor`})})]}):null,(0,N.jsx)(`input`,{className:`flowengage-chat-text-input`,style:{flex:1,minWidth:0,border:`none`,fontFamily:`inherit`,fontSize:`14px`,outline:`none`,padding:`6px 0`,paddingLeft:re?`0`:`8px`,color:`#111827`,background:`transparent`},value:u?d:e,onChange:e=>{if(u){f(e.target.value);return}t(e.target.value)},placeholder:r?`Conversation ended`:u?`Enter your Email`:o===`agent`?`Message the agent…`:ee,disabled:s,type:u?`email`:`text`,autoComplete:u?`email`:`off`}),(0,N.jsx)(`button`,{type:`submit`,style:{width:`36px`,height:`36px`,borderRadius:`9999px`,background:`var(--flowengage-primary)`,color:`#fff`,border:`none`,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`opacity 0.2s ease`,cursor:ne?`not-allowed`:`pointer`,opacity:ne?.45:1},disabled:ne,onMouseEnter:e=>{ne||(e.currentTarget.style.opacity=`0.85`)},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`},children:(0,N.jsx)(lE,{})})]}),!u&&y&&(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`7px 4px 0`},children:[(0,N.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#dc2626`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,N.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,N.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,N.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,N.jsx)(`span`,{style:{fontSize:`11px`,color:`#dc2626`,fontWeight:500},children:y})]}),u&&p&&(0,N.jsx)(`div`,{style:{padding:`8px 16px 0`,fontSize:`12px`,fontWeight:500,color:`#f43f5e`},children:p})]})}var AE=({muted:e=!1})=>(0,N.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-6.83 2.83`}),(0,N.jsx)(`path`,{d:`M19 10a7 7 0 01-1.62 4.49M5 10a7 7 0 008.79 6.77`}),(0,N.jsx)(`path`,{d:`M12 19v4M8 23h8`}),e&&(0,N.jsx)(`line`,{x1:`2`,y1:`2`,x2:`22`,y2:`22`})]}),jE=({variant:e,onClick:t,children:n,icon:r,compact:i=!1,iconOnly:a=!1,active:o=!1,ariaLabel:s})=>(0,N.jsxs)(`button`,{type:`button`,className:[`flowengage-call-btn`,`flowengage-call-btn-${e}`,i?`compact`:``,a?`icon-only`:``,o?`active`:``].filter(Boolean).join(` `),onClick:t,"aria-label":s||n,title:s||n,children:[r,!a&&(0,N.jsx)(`span`,{children:n})]});function ME({webRTCError:e,micError:t,setMicError:n,dismissCallError:r,incomingCall:i,rejectCall:a,acceptCall:o,activeCallId:s,callConnectionState:c,formatCallDuration:l,callDurationSeconds:u,endWebRTCCall:d,isCallMuted:f,toggleCallMute:p,isAIVoiceActive:m,currentCallAgentName:h,isRateLimited:g,rateLimitMessage:_}){let v=(0,b.useRef)(null),y=(0,b.useCallback)(()=>{if(!v.current)return;let{audioContext:e,oscillator:t,interval:n,toneTimeout:r}=v.current;window.clearInterval(n),window.clearTimeout(r);try{t.stop()}catch{}try{e.close()}catch{}v.current=null},[]),x=(0,b.useCallback)(()=>{if(v.current||typeof window>`u`)return;let e=window.AudioContext||window.webkitAudioContext||null;if(e)try{let t=new e,n=t.createOscillator(),r=t.createGain();n.connect(r),r.connect(t.destination),n.frequency.value=0,n.type=`sine`,r.gain.value=.3;let i=()=>{v.current&&(window.clearTimeout(v.current.toneTimeout),n.frequency.value=440,v.current.toneTimeout=window.setTimeout(()=>{n.frequency.value=0},400))};t.state===`suspended`&&t.resume().catch(e=>{console.warn(`[FlowEngage] ringtone autoplay blocked`,e)}),n.start(),v.current={audioContext:t,oscillator:n,interval:null,toneTimeout:null},i(),v.current.interval=window.setInterval(i,1e3)}catch(e){console.warn(`[FlowEngage] failed to start ringtone`,e)}},[]);(0,b.useEffect)(()=>{if(i){x();return}y()},[i,x,y]),(0,b.useEffect)(()=>()=>y(),[y]);let ee=m?`header-mode`:`bottom-mode`,S=!!(i||s),C=i?`incoming`:c===`connected`?`connected`:`connecting`,te=(0,b.useMemo)(()=>C===`incoming`?`Incoming Call`:C===`connected`?`Voice Call Active`:`Connecting Call`,[C]),ne=(0,b.useMemo)(()=>C===`incoming`?`${h} wants to join a voice call`:C===`connected`?`You are connected to ${h} from this conversation.`:`Please wait while ${h}'s voice connection finishes setting up.`,[h,C]);return(0,N.jsxs)(N.Fragment,{children:[(e||t)&&(0,N.jsxs)(`div`,{style:{margin:`0 20px 10px`,padding:`12px 16px`,borderRadius:`12px`,background:`#fef2f2`,border:`1px solid #fee2e2`,display:`flex`,alignItems:`flex-start`,gap:`10px`},children:[(0,N.jsx)(fE,{className:``}),(0,N.jsx)(`span`,{style:{fontSize:`12px`,color:`#b91c1c`,lineHeight:1.5,flex:1},children:e||t}),(0,N.jsx)(`button`,{style:{flexShrink:0,background:`transparent`,border:0,color:`#f87171`,cursor:`pointer`,fontSize:`18px`,lineHeight:1},onClick:()=>{n(null),r()},onMouseEnter:e=>{e.currentTarget.style.color=`#dc2626`},onMouseLeave:e=>{e.currentTarget.style.color=`#f87171`},children:`×`})]}),S&&(0,N.jsx)(`div`,{className:`incoming-call-overlay ${ee}`,children:(0,N.jsx)(`div`,{className:[`incoming-call-container`,C===`connected`?`connected-layout`:``].filter(Boolean).join(` `),children:C===`connected`?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`call-connected-top`,children:[(0,N.jsxs)(`div`,{className:`call-connected-identity`,children:[(0,N.jsx)(`div`,{className:`call-icon-wrapper ${C}`,children:(0,N.jsx)(cE,{size:20})}),(0,N.jsxs)(`div`,{className:`call-info-group`,children:[(0,N.jsx)(`h3`,{className:`call-title`,children:te}),(0,N.jsx)(`p`,{className:`call-subtitle`,children:ne})]})]}),(0,N.jsx)(`div`,{className:`call-timer`,children:l(u)})]}),(0,N.jsxs)(`div`,{className:`call-actions connected`,children:[(0,N.jsx)(jE,{variant:`mute`,onClick:p,compact:m,active:f,icon:(0,N.jsx)(AE,{muted:f}),children:f?`Unmute`:`Mute`}),(0,N.jsx)(jE,{variant:`end`,onClick:d,compact:m,icon:(0,N.jsx)(cE,{size:14}),children:`End`})]})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`call-icon-wrapper ${C}`,children:[(0,N.jsx)(dE,{}),C===`incoming`&&(0,N.jsx)(`div`,{className:`call-pulse-animation`}),C===`connecting`&&(0,N.jsx)(`div`,{className:`call-connecting-animation`})]}),(0,N.jsxs)(`div`,{className:`call-info-group`,children:[(0,N.jsx)(`h3`,{className:`call-title`,children:te}),(0,N.jsx)(`p`,{className:`call-subtitle`,children:ne})]}),(0,N.jsx)(`div`,{className:`call-actions`,children:C===`incoming`&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(jE,{variant:`reject`,onClick:async()=>{y(),await a()},iconOnly:!0,icon:(0,N.jsx)(cE,{size:14}),ariaLabel:`Decline call`,children:`Decline`}),(0,N.jsx)(jE,{variant:`accept`,onClick:async()=>{y(),await o()},iconOnly:!0,icon:(0,N.jsx)(dE,{}),ariaLabel:`Accept call`,children:`Accept`})]})})]})})}),g&&(0,N.jsx)(`div`,{style:{margin:`0 20px 10px`,padding:`12px 16px`,fontSize:`13px`,borderRadius:`12px`,background:`#fee2e2`,color:`#991b1b`},children:_})]})}var NE=[`#135bd8`,`#ef334b`,`#ffbd2e`];function PE(e){return!Array.isArray(e)||e.length===0?NE:e.length===1?[e[0],e[0],e[0]]:e.length===2?[e[0],e[1],e[0]]:[e[0],e[1],e[2]]}var FE={idle:3,listening:.75,speaking:1.4,muted:.75,error:.08};function IE(e){if(!e||typeof e!=`string`)return[0,0,0];let t=e.replace(`#`,``),n=t.length===3?t.split(``).map(e=>e+e).join(``):t;return[parseInt(n.slice(0,2),16)/255,parseInt(n.slice(2,4),16)/255,parseInt(n.slice(4,6),16)/255]}function LE(e,t){if(!e||typeof e!=`string`)return`rgba(0,0,0,${t})`;if(e.startsWith(`rgb`))return e.replace(/[\d.]+\)$/,`${t})`);let n=e.replace(`#`,``),r=n.length===3?n.split(``).map(e=>e+e).join(``):n;return`rgba(${parseInt(r.slice(0,2),16)},${parseInt(r.slice(2,4),16)},${parseInt(r.slice(4,6),16)},${t})`}var RE=`
341
+ `).split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean),r=e=>zE(e).replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g,`<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/\*([^*\n]+)\*/g,`<em>$1</em>`);return BE(n.map(e=>{let t=e.split(`
342
+ `).map(e=>e.trim()).filter(Boolean),n=t.filter(e=>/^[-*]\s+/.test(e));if(n.length>=2&&n.length===t.length)return`<ul>${n.map(e=>`<li>${r(e.replace(/^[-*]\s+/,``))}</li>`).join(``)}</ul>`;let i=e.split(/\s+(?=[-*]\s+\*\*?)/).map(e=>e.trim()).filter(Boolean);return i.length>=2&&i.every(e=>/^[-*]\s+/.test(e))?`<ul>${i.map(e=>`<li>${r(e.replace(/^[-*]\s+/,``))}</li>`).join(``)}</ul>`:`<p>${r(e).replace(/\n/g,`<br />`)}</p>`}).join(``))},HE=new Set([`application/pdf`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`]),UE=new Set([`.pdf`,`.docx`,`.png`,`.jpg`,`.jpeg`]),WE=`image/png,image/jpeg,.pdf,.docx`;function GE(e){if(!e)return!1;let t=typeof e.name==`string`?e.name.toLowerCase():``,n=t.includes(`.`)?`.${t.split(`.`).pop()}`:``,r=typeof e.type==`string`?e.type.toLowerCase():``;return r===`image/png`||r===`image/jpeg`||HE.has(r)||UE.has(n)}function KE(e){return e?GE(e)?e.size>2097152?`File must be 2 MB or smaller.`:``:`Only PNG, JPEG, PDF, and DOCX files are allowed.`:`No file selected.`}function qE(e=0){if(!Number.isFinite(e)||e<=0)return``;let t=[`B`,`KB`,`MB`,`GB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;let i=n>=10||r===0?0:1;return`${n.toFixed(i)} ${t[r]}`}function JE(e){return e?e.name||`Attachment`:``}function YE(e){if(!e||typeof e!=`string`)return`?`;let t=e.trim();if(!t)return`?`;let n=t.split(/\s+/).filter(Boolean);return n.length>=2?`${n[0][0]}${n[n.length-1][0]}`.toUpperCase():t.slice(0,2).toUpperCase()}function XE({src:e,name:t,imgStyle:n,initialsSpanStyle:r}){let[i,a]=(0,b.useState)(!1),o=typeof e==`string`?e.trim():``;return(0,b.useEffect)(()=>{a(!1)},[o]),o&&!i?(0,N.jsx)(`img`,{src:o,alt:``,onError:()=>a(!0),style:n}):(0,N.jsx)(`span`,{style:r,children:YE(t)})}function ZE({chatHistory:e,isAiTyping:t,isAgentTyping:n,setReplyContext:r,TypingDots:i,primaryColor:a=`#3B82F6`,agentHeadshot:o=null,agentDisplayName:s=`Agent`,botAvatarNode:c=null}){let l=(0,b.useRef)(null),u=e=>{if(!e)return`just now`;let t=new Date,n=new Date(e),r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return`just now`;let i=Math.floor(r/60);if(i<60)return`${i} min${i>1?`s`:``} ago`;let a=Math.floor(i/60);if(a<24)return`${a} hr${a>1?`s`:``} ago`;let o=Math.floor(a/24);return`${o} day${o>1?`s`:``} ago`};return(0,b.useEffect)(()=>{l.current&&l.current.scrollIntoView({behavior:`smooth`})},[e.length,t,n]),(0,N.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,padding:`10px 16px 20px`,display:`flex`,flexDirection:`column`,background:`transparent`},children:[e.map(e=>{let t=e.sender===`system`,n=e.sender===`user`,i=e.sender===`ai`||e.sender===`bot`,l=e.sender===`agent`,d=e.isPending,f=e.type===`file`&&e.metadata?.fileUrl,p=e.agent_name||e.agentName||e.metadata?.agentName||s,m=typeof e.sender_headshot==`string`&&e.sender_headshot.trim()||typeof o==`string`&&o.trim()||null,h=RE(e.replyToContent||e.replyContext?.message||``),g=e.replyToSender===`user`?`You`:e.replyToSender===`agent`?`Agent`:e.replyToSender===`ai`||e.replyToSender===`bot`?`AI Assistant`:`Message`;return t?(0,N.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,margin:`8px 0`},children:(0,N.jsx)(`div`,{style:{padding:`6px 12px`,borderRadius:`9999px`,background:`#f3f4f6`,color:`#6b7280`,fontSize:`12px`,fontWeight:500},children:e.message})},e.id):(0,N.jsxs)(`div`,{style:{display:`flex`,justifyContent:n?`flex-end`:`flex-start`,alignItems:`flex-start`,marginBottom:`16px`,gap:`8px`,flexDirection:`row`},children:[!n&&(i||l)&&(0,N.jsx)(`div`,{style:{width:`32px`,height:`32px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,background:l?`#f3f4f6`:c&&i?`transparent`:`var(--flowengage-primary)`,color:l?a:`#fff`,boxShadow:l?`0 2px 8px rgba(0,0,0,0.06)`:c&&i?`none`:`0 8px 20px rgba(59,130,246,0.24)`,overflow:`hidden`,border:l?`1px solid ${a}22`:`none`,fontSize:`12px`,fontWeight:800,marginTop:!d&&(i||l)?`22px`:`0px`},children:i?c||(0,N.jsx)(IE,{size:16}):(0,N.jsx)(XE,{src:m||``,name:p,imgStyle:{width:`100%`,height:`100%`,objectFit:`cover`},initialsSpanStyle:{lineHeight:1}})}),(0,N.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:n?`flex-end`:`flex-start`,maxWidth:`75%`,minWidth:0},children:[!d&&!n&&(i||l)&&(0,N.jsxs)(`button`,{type:`button`,onClick:()=>r(e),style:{opacity:1,marginBottom:`4px`,display:`flex`,alignItems:`center`,gap:`4px`,fontSize:`11px`,color:`#9ca3af`,background:`transparent`,border:0,cursor:`pointer`,padding:0,marginLeft:`2px`},onMouseEnter:e=>{e.currentTarget.style.color=`#4b5563`},onMouseLeave:e=>{e.currentTarget.style.color=`#9ca3af`},children:[(0,N.jsx)(NE,{}),`Reply`]}),(0,N.jsxs)(`div`,{style:{padding:`12px 16px`,borderRadius:n?`20px 6px 20px 20px`:`6px 20px 20px 20px`,lineHeight:1.5,boxShadow:`0 2px 8px rgba(0,0,0,0.06)`,background:n?`var(--flowengage-primary)`:`rgba(255,255,255,0.92)`,color:n?`#fff`:`#111827`,fontSize:`14px`,opacity:d?.55:1,transition:`opacity 0.3s ease`,wordBreak:`break-word`,width:`fit-content`},children:[h&&(0,N.jsxs)(`div`,{style:{marginBottom:`8px`,borderRadius:`14px`,borderLeft:n?`2px solid rgba(255,255,255,0.8)`:`2px solid var(--flowengage-primary)`,padding:`8px 12px`,fontSize:`12px`,background:n?`rgba(255,255,255,0.15)`:`#f9fafb`,color:n?`rgba(255,255,255,0.9)`:`#6b7280`},children:[(0,N.jsx)(`div`,{style:{marginBottom:`2px`,fontWeight:600},children:g}),(0,N.jsx)(`div`,{style:{display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`},children:h})]}),f?(()=>{let t=e.metadata.fileType||``,r=e.metadata.fileName||e.message||`File`,i=qE(e.metadata.fileSize),a=t.startsWith(`image/`),o=t===`application/pdf`?{color:`#ef4444`,label:`PDF`}:t.includes(`word`)||t.includes(`docx`)?{color:`#3b82f6`,label:`DOCX`}:t.includes(`excel`)||t.includes(`sheet`)||t===`text/csv`?{color:`#10b981`,label:`XLSX`}:{color:`#6b7280`,label:`FILE`};return(0,N.jsx)(`div`,{style:{minWidth:`200px`,maxWidth:`240px`},children:(0,N.jsx)(`a`,{href:e.metadata.fileUrl,target:`_blank`,rel:`noopener noreferrer`,style:{textDecoration:`none`,display:`block`},children:a?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`img`,{src:e.metadata.fileUrl,alt:r,style:{width:`100%`,borderRadius:`10px`,display:`block`,maxHeight:`180px`,objectFit:`cover`}}),(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginTop:`7px`,gap:`6px`},children:[(0,N.jsx)(`span`,{style:{fontSize:`12px`,color:n?`rgba(255,255,255,0.85)`:`#374151`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},children:r}),i&&(0,N.jsx)(`span`,{style:{fontSize:`11px`,flexShrink:0,color:n?`rgba(255,255,255,0.6)`:`#9ca3af`},children:i})]})]}):(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`10px`,background:n?`rgba(255,255,255,0.15)`:`#f3f4f6`,borderRadius:`12px`,padding:`10px 12px`},children:[(0,N.jsxs)(`div`,{style:{width:`38px`,height:`46px`,borderRadius:`8px`,background:n?`rgba(255,255,255,0.22)`:`#fff`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,flexShrink:0,boxShadow:`0 1px 4px rgba(0,0,0,0.1)`,gap:`3px`},children:[(0,N.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:n?`#fff`:o.color,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,N.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]}),(0,N.jsx)(`span`,{style:{fontSize:`7px`,fontWeight:800,letterSpacing:`0.04em`,color:n?`#fff`:o.color,lineHeight:1},children:o.label})]}),(0,N.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,N.jsx)(`div`,{style:{fontSize:`13px`,fontWeight:600,color:n?`#fff`:`#111827`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:r}),i&&(0,N.jsx)(`div`,{style:{fontSize:`11px`,marginTop:`3px`,color:n?`rgba(255,255,255,0.6)`:`#9ca3af`},children:i})]}),(0,N.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:n?`rgba(255,255,255,0.65)`:`#9ca3af`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,N.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,N.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,N.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})]})})})})():i?(0,N.jsx)(`div`,{className:`flowengage-message-content fe-bot-message`,dangerouslySetInnerHTML:{__html:VE(e.message)}}):(0,N.jsx)(`div`,{style:{whiteSpace:n||l?`normal`:`pre-wrap`},children:e.message}),d&&(0,N.jsx)(`span`,{style:{fontSize:`10px`,marginLeft:`6px`,opacity:.7},children:`sending…`})]}),(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`4px`,marginTop:`4px`,padding:`0 4px`,alignSelf:n?`flex-end`:`flex-start`},children:[(0,N.jsx)(`span`,{style:{fontSize:`10px`,color:`#9ca3af`,fontWeight:500},children:u(e.timestamp||e.createdAt)}),(0,N.jsx)(`span`,{style:{fontSize:`10px`,fontWeight:700,color:n?`var(--flowengage-primary)`:`#9ca3af`},children:d?`○`:`✓`})]})]})]},e.id)}),t&&(0,N.jsxs)(`div`,{style:{marginBottom:`16px`,display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,N.jsx)(`div`,{style:{width:`32px`,height:`32px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,background:c?`transparent`:`var(--flowengage-primary)`,color:`#fff`,boxShadow:c?`none`:`0 8px 20px rgba(59,130,246,0.24)`,overflow:`hidden`},children:c||(0,N.jsx)(IE,{size:16})}),(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`2px`,color:`#374151`,fontSize:`13px`,fontWeight:500,fontStyle:`italic`},children:[`Analysing`,[0,1,2].map(e=>(0,N.jsx)(`span`,{style:{animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`},children:`.`},e))]})]}),n&&(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`8px`,marginBottom:`12px`},children:[(0,N.jsx)(`div`,{style:{width:`32px`,height:`32px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,overflow:`hidden`},children:(0,N.jsx)(XE,{src:o||``,name:s,imgStyle:{width:`100%`,height:`100%`,objectFit:`cover`},initialsSpanStyle:{lineHeight:1}})}),(0,N.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`12px 16px`,borderRadius:`18px`,background:`#fff`,boxShadow:`0 2px 6px rgba(0,0,0,0.04)`},children:[0,1,2].map(e=>(0,N.jsx)(`span`,{style:{width:`7px`,height:`7px`,borderRadius:`50%`,background:`#9ca3af`,animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`}},e))})]}),(0,N.jsx)(`div`,{ref:l})]})}function QE({input:e,setInput:t,onSubmit:n,isConversationEnded:r,callUiActive:i,handleToggleVoice:a,activeScreen:o,inputDisabled:s,replyContext:c,clearReplyContext:l,requiresEmail:u,emailInput:d,setEmailInput:f,emailError:p,showVoiceToggle:m=!1,voiceEnabled:h=!0,onFileSelect:g,selectedFile:_=null,onRemoveSelectedFile:v,attachmentError:y=``,isUploadingAttachment:x=!1,inputPlaceholder:ee=`Type your message`}){let S=(0,b.useRef)(null),C=c?.sender===`user`?`You`:c?.sender===`agent`?`Agent`:`AI Assistant`,te=u?!!d?.trim():!!e?.trim()||!!_,ne=s||x||!te,re=!u&&h&&m;return(0,N.jsxs)(`div`,{style:{padding:`0 20px`,background:`transparent`},children:[r&&(0,N.jsx)(`div`,{style:{marginBottom:`8px`,padding:`8px 16px`,borderRadius:`12px`,background:`#f3f4f6`,color:`#6b7280`,fontSize:`12px`,textAlign:`center`,fontWeight:500},children:`This conversation has ended.`}),c&&(0,N.jsxs)(`div`,{style:{marginBottom:`8px`,display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,gap:`12px`,borderRadius:`16px`,border:`1px solid rgba(0,0,0,0.05)`,background:`#fff`,padding:`12px 16px`,boxShadow:`0 8px 24px rgba(0,0,0,0.05)`},children:[(0,N.jsxs)(`div`,{style:{minWidth:0,flex:1,borderLeft:`2px solid var(--flowengage-primary)`,paddingLeft:`12px`},children:[(0,N.jsxs)(`div`,{style:{fontSize:`12px`,fontWeight:600,color:`var(--flowengage-primary)`},children:[`Replying to `,C]}),(0,N.jsx)(`div`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:`12px`,color:`#6b7280`},children:c.replyToContent||c.message})]}),(0,N.jsx)(`button`,{type:`button`,style:{width:`28px`,height:`28px`,borderRadius:`9999px`,border:0,background:`#f3f4f6`,color:`#6b7280`,transition:`color 0.2s ease, background 0.2s ease`,cursor:`pointer`},onClick:l,"aria-label":`Cancel reply`,onMouseEnter:e=>{e.currentTarget.style.background=`#e5e7eb`,e.currentTarget.style.color=`#374151`},onMouseLeave:e=>{e.currentTarget.style.background=`#f3f4f6`,e.currentTarget.style.color=`#6b7280`},children:`×`})]}),u&&(0,N.jsx)(`div`,{style:{marginBottom:`8px`,padding:`0 8px`},children:(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`8px`,color:`#111827`,fontSize:`14px`,fontWeight:500,textAlign:`center`},children:[(0,N.jsx)(`span`,{style:{display:`inline-flex`,width:`22px`,height:`22px`,borderRadius:`9999px`,alignItems:`center`,justifyContent:`center`,background:`rgba(59,130,246,0.08)`,color:`var(--flowengage-primary)`},children:(0,N.jsx)(IE,{size:13})}),(0,N.jsx)(`span`,{children:`Please provide your email address so we can help you.`})]})}),_&&!u&&(0,N.jsxs)(`div`,{style:{marginBottom:`10px`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`12px`,borderRadius:`16px`,border:`1px solid rgba(0,0,0,0.06)`,background:`#fff`,padding:`12px 14px`,boxShadow:`0 8px 24px rgba(0,0,0,0.05)`},children:[(0,N.jsxs)(`div`,{style:{minWidth:0,flex:1},children:[(0,N.jsx)(`div`,{style:{fontSize:`12px`,fontWeight:600,color:`var(--flowengage-primary)`,marginBottom:`2px`},children:`Attachment ready`}),(0,N.jsx)(`div`,{style:{fontSize:`13px`,color:`#111827`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:JE(_)}),(0,N.jsx)(`div`,{style:{fontSize:`12px`,color:`#6b7280`,marginTop:`2px`},children:qE(_.size)})]}),(0,N.jsx)(`button`,{type:`button`,style:{width:`28px`,height:`28px`,borderRadius:`9999px`,border:0,background:`#f3f4f6`,color:`#6b7280`,transition:`color 0.2s ease, background 0.2s ease`,cursor:`pointer`,flexShrink:0},onClick:v,"aria-label":`Remove attachment`,onMouseEnter:e=>{e.currentTarget.style.background=`#e5e7eb`,e.currentTarget.style.color=`#374151`},onMouseLeave:e=>{e.currentTarget.style.background=`#f3f4f6`,e.currentTarget.style.color=`#6b7280`},children:`×`})]}),(0,N.jsxs)(`form`,{style:{display:`flex`,alignItems:`center`,gap:`12px`,padding:`8px`,border:`1px solid rgba(0,0,0,0.06)`,borderRadius:`9999px`,background:`#fff`,boxShadow:`0 4px 14px rgba(0,0,0,0.04)`,opacity:r?.5:1},onSubmit:n,children:[re?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`input`,{ref:S,type:`file`,accept:WE,style:{display:`none`},onChange:e=>{let t=e.target.files?.[0];t&&g?.(t),e.target.value=``}}),(0,N.jsx)(`button`,{type:`button`,style:{width:`36px`,height:`36px`,borderRadius:`9999px`,background:`#f3f4f8`,color:`var(--flowengage-primary)`,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`background 0.2s ease, opacity 0.2s ease`,border:0,cursor:`pointer`,flexShrink:0},onClick:()=>S.current?.click(),title:`Attach file`,"aria-label":`Attach file`,disabled:r||x,onMouseEnter:e=>{e.currentTarget.style.opacity=`0.8`},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`},children:(0,N.jsx)(LE,{size:18,color:`currentColor`})})]}):null,(0,N.jsx)(`input`,{className:`flowengage-chat-text-input`,style:{flex:1,minWidth:0,border:`none`,fontFamily:`inherit`,fontSize:`14px`,outline:`none`,padding:`6px 0`,paddingLeft:re?`0`:`8px`,color:`#111827`,background:`transparent`},value:u?d:e,onChange:e=>{if(u){f(e.target.value);return}t(e.target.value)},placeholder:r?`Conversation ended`:u?`Enter your Email`:o===`agent`?`Message the agent…`:ee,disabled:s,type:u?`email`:`text`,autoComplete:u?`email`:`off`}),(0,N.jsx)(`button`,{type:`submit`,style:{width:`36px`,height:`36px`,borderRadius:`9999px`,background:`var(--flowengage-primary)`,color:`#fff`,border:`none`,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`opacity 0.2s ease`,cursor:ne?`not-allowed`:`pointer`,opacity:ne?.45:1},disabled:ne,onMouseEnter:e=>{ne||(e.currentTarget.style.opacity=`0.85`)},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`},children:(0,N.jsx)(ME,{})})]}),!u&&y&&(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`7px 4px 0`},children:[(0,N.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#dc2626`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,N.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,N.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,N.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,N.jsx)(`span`,{style:{fontSize:`11px`,color:`#dc2626`,fontWeight:500},children:y})]}),u&&p&&(0,N.jsx)(`div`,{style:{padding:`8px 16px 0`,fontSize:`12px`,fontWeight:500,color:`#f43f5e`},children:p})]})}var $E=({muted:e=!1})=>(0,N.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-6.83 2.83`}),(0,N.jsx)(`path`,{d:`M19 10a7 7 0 01-1.62 4.49M5 10a7 7 0 008.79 6.77`}),(0,N.jsx)(`path`,{d:`M12 19v4M8 23h8`}),e&&(0,N.jsx)(`line`,{x1:`2`,y1:`2`,x2:`22`,y2:`22`})]}),eD=({variant:e,onClick:t,children:n,icon:r,compact:i=!1,iconOnly:a=!1,active:o=!1,ariaLabel:s})=>(0,N.jsxs)(`button`,{type:`button`,className:[`flowengage-call-btn`,`flowengage-call-btn-${e}`,i?`compact`:``,a?`icon-only`:``,o?`active`:``].filter(Boolean).join(` `),onClick:t,"aria-label":s||n,title:s||n,children:[r,!a&&(0,N.jsx)(`span`,{children:n})]});function tD({webRTCError:e,micError:t,setMicError:n,dismissCallError:r,incomingCall:i,rejectCall:a,acceptCall:o,activeCallId:s,callConnectionState:c,formatCallDuration:l,callDurationSeconds:u,endWebRTCCall:d,isCallMuted:f,toggleCallMute:p,isAIVoiceActive:m,currentCallAgentName:h,isRateLimited:g,rateLimitMessage:_}){let v=(0,b.useRef)(null),y=(0,b.useCallback)(()=>{if(!v.current)return;let{audioContext:e,oscillator:t,interval:n,toneTimeout:r}=v.current;window.clearInterval(n),window.clearTimeout(r);try{t.stop()}catch{}try{e.close()}catch{}v.current=null},[]),x=(0,b.useCallback)(()=>{if(v.current||typeof window>`u`)return;let e=window.AudioContext||window.webkitAudioContext||null;if(e)try{let t=new e,n=t.createOscillator(),r=t.createGain();n.connect(r),r.connect(t.destination),n.frequency.value=0,n.type=`sine`,r.gain.value=.3;let i=()=>{v.current&&(window.clearTimeout(v.current.toneTimeout),n.frequency.value=440,v.current.toneTimeout=window.setTimeout(()=>{n.frequency.value=0},400))};t.state===`suspended`&&t.resume().catch(e=>{console.warn(`[FlowEngage] ringtone autoplay blocked`,e)}),n.start(),v.current={audioContext:t,oscillator:n,interval:null,toneTimeout:null},i(),v.current.interval=window.setInterval(i,1e3)}catch(e){console.warn(`[FlowEngage] failed to start ringtone`,e)}},[]);(0,b.useEffect)(()=>{if(i){x();return}y()},[i,x,y]),(0,b.useEffect)(()=>()=>y(),[y]);let ee=m?`header-mode`:`bottom-mode`,S=!!(i||s),C=i?`incoming`:c===`connected`?`connected`:`connecting`,te=(0,b.useMemo)(()=>C===`incoming`?`Incoming Call`:C===`connected`?`Voice Call Active`:`Connecting Call`,[C]),ne=(0,b.useMemo)(()=>C===`incoming`?`${h} wants to join a voice call`:C===`connected`?`You are connected to ${h} from this conversation.`:`Please wait while ${h}'s voice connection finishes setting up.`,[h,C]);return(0,N.jsxs)(N.Fragment,{children:[(e||t)&&(0,N.jsxs)(`div`,{style:{margin:`0 20px 10px`,padding:`12px 16px`,borderRadius:`12px`,background:`#fef2f2`,border:`1px solid #fee2e2`,display:`flex`,alignItems:`flex-start`,gap:`10px`},children:[(0,N.jsx)(FE,{className:``}),(0,N.jsx)(`span`,{style:{fontSize:`12px`,color:`#b91c1c`,lineHeight:1.5,flex:1},children:e||t}),(0,N.jsx)(`button`,{style:{flexShrink:0,background:`transparent`,border:0,color:`#f87171`,cursor:`pointer`,fontSize:`18px`,lineHeight:1},onClick:()=>{n(null),r()},onMouseEnter:e=>{e.currentTarget.style.color=`#dc2626`},onMouseLeave:e=>{e.currentTarget.style.color=`#f87171`},children:`×`})]}),S&&(0,N.jsx)(`div`,{className:`incoming-call-overlay ${ee}`,children:(0,N.jsx)(`div`,{className:[`incoming-call-container`,C===`connected`?`connected-layout`:``].filter(Boolean).join(` `),children:C===`connected`?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`call-connected-top`,children:[(0,N.jsxs)(`div`,{className:`call-connected-identity`,children:[(0,N.jsx)(`div`,{className:`call-icon-wrapper ${C}`,children:(0,N.jsx)(jE,{size:20})}),(0,N.jsxs)(`div`,{className:`call-info-group`,children:[(0,N.jsx)(`h3`,{className:`call-title`,children:te}),(0,N.jsx)(`p`,{className:`call-subtitle`,children:ne})]})]}),(0,N.jsx)(`div`,{className:`call-timer`,children:l(u)})]}),(0,N.jsxs)(`div`,{className:`call-actions connected`,children:[(0,N.jsx)(eD,{variant:`mute`,onClick:p,compact:m,active:f,icon:(0,N.jsx)($E,{muted:f}),children:f?`Unmute`:`Mute`}),(0,N.jsx)(eD,{variant:`end`,onClick:d,compact:m,icon:(0,N.jsx)(jE,{size:14}),children:`End`})]})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`call-icon-wrapper ${C}`,children:[(0,N.jsx)(PE,{}),C===`incoming`&&(0,N.jsx)(`div`,{className:`call-pulse-animation`}),C===`connecting`&&(0,N.jsx)(`div`,{className:`call-connecting-animation`})]}),(0,N.jsxs)(`div`,{className:`call-info-group`,children:[(0,N.jsx)(`h3`,{className:`call-title`,children:te}),(0,N.jsx)(`p`,{className:`call-subtitle`,children:ne})]}),(0,N.jsx)(`div`,{className:`call-actions`,children:C===`incoming`&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(eD,{variant:`reject`,onClick:async()=>{y(),await a()},iconOnly:!0,icon:(0,N.jsx)(jE,{size:14}),ariaLabel:`Decline call`,children:`Decline`}),(0,N.jsx)(eD,{variant:`accept`,onClick:async()=>{y(),await o()},iconOnly:!0,icon:(0,N.jsx)(PE,{}),ariaLabel:`Accept call`,children:`Accept`})]})})]})})}),g&&(0,N.jsx)(`div`,{style:{margin:`0 20px 10px`,padding:`12px 16px`,fontSize:`13px`,borderRadius:`12px`,background:`#fee2e2`,color:`#991b1b`},children:_})]})}var nD=[`#135bd8`,`#ef334b`,`#ffbd2e`];function rD(e){return!Array.isArray(e)||e.length===0?nD:e.length===1?[e[0],e[0],e[0]]:e.length===2?[e[0],e[1],e[0]]:[e[0],e[1],e[2]]}var iD={idle:3,listening:.75,speaking:1.4,muted:.75,error:.08};function aD(e){if(!e||typeof e!=`string`)return[0,0,0];let t=e.replace(`#`,``),n=t.length===3?t.split(``).map(e=>e+e).join(``):t;return[parseInt(n.slice(0,2),16)/255,parseInt(n.slice(2,4),16)/255,parseInt(n.slice(4,6),16)/255]}function oD(e,t){if(!e||typeof e!=`string`)return`rgba(0,0,0,${t})`;if(e.startsWith(`rgb`))return e.replace(/[\d.]+\)$/,`${t})`);let n=e.replace(`#`,``),r=n.length===3?n.split(``).map(e=>e+e).join(``):n;return`rgba(${parseInt(r.slice(0,2),16)},${parseInt(r.slice(2,4),16)},${parseInt(r.slice(4,6),16)},${t})`}var sD=`
343
343
  attribute vec2 a_pos;
344
344
  varying vec2 v_uv;
345
345
  void main() {
346
346
  v_uv = a_pos * 0.5 + 0.5;
347
347
  gl_Position = vec4(a_pos, 0.0, 1.0);
348
348
  }
349
- `,zE=`
349
+ `,cD=`
350
350
  precision highp float;
351
351
 
352
352
  varying vec2 v_uv;
@@ -462,7 +462,7 @@ registerProcessor("scribeAudioProcessor", ScribeAudioProcessor);
462
462
 
463
463
  gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
464
464
  }
465
- `;function BE(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 VE({size:e=94,voiceState:t=`idle`,isMuted:n=!1,colors:r,onClick:i,style:a,className:o}){let[s,c,l]=PE(r),u=t===`speaking`,d=e<=50,f=(0,b.useRef)(null),p=(0,b.useRef)(FE[t]??.35);(0,b.useEffect)(()=>{p.current=FE[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=BE(r,RE,zE);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,IE(s)),r.uniform3fv(u.c2,IE(c)),r.uniform3fv(u.c3,IE(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,N.jsxs)(`div`,{style:{position:`relative`,width:e,height:e,flexShrink:0,cursor:i?`pointer`:`default`,...a},className:o,onClick:i,children:[u&&!d&&(0,N.jsx)(dp.div,{style:{position:`absolute`,inset:-10,borderRadius:`50%`,background:`radial-gradient(circle, ${LE(s,.18)} 0%, transparent 70%)`,pointerEvents:`none`},animate:{opacity:[.3,.75]},transition:{duration:1,repeat:1/0,repeatType:`mirror`,ease:`easeInOut`}}),(0,N.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,N.jsx)(`canvas`,{ref:f,style:{width:`100%`,height:`100%`,display:`block`}})}),u&&(0,N.jsx)(`div`,{style:{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,pointerEvents:`none`,zIndex:1},children:(0,N.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`3px`},children:[4,8,12,8,4].map((e,t)=>(0,N.jsx)(dp.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 HE=375,UE=6e3,WE={wordsSoFar:0,speechStartTime:0,isSpeaking:!1,items:[],timers:[],textDraining:!1,lastHighlightId:null,isVoiceMode:!1};function GE(e,t=5e3){let n={execute:e,wordOffset:WE.wordsSoFar,holdMs:t};if(WE.isVoiceMode)if(WE.speechStartTime>0)KE(n);else{WE.items.push(n);let e=setTimeout(()=>{let e=WE.items.indexOf(n);e!==-1&&(WE.items.splice(e,1),n.execute())},UE);WE.timers.push(e)}else WE.items.push(n),WE.textDraining||qE()}function KE(e){let t=e.wordOffset*HE,n=Date.now()-WE.speechStartTime,r=Math.max(0,t-n),i=setTimeout(e.execute,r);WE.timers.push(i)}function qE(){if(WE.items.length===0){WE.textDraining=!1;return}WE.textDraining=!0;let e=WE.items.shift();setTimeout(()=>e.execute(),300);let t=setTimeout(qE,e.holdMs);WE.timers.push(t)}function JE(){WE.timers.forEach(clearTimeout),WE.wordsSoFar=0,WE.speechStartTime=0,WE.isSpeaking=!1,WE.items=[],WE.timers=[],WE.textDraining=!1,WE.lastHighlightId=null}var YE=80,XE=null;function ZE(e){requestAnimationFrame(()=>{let t=e.getBoundingClientRect(),n=t.top+t.height/2,r=YE,i=r+(window.innerHeight-r)/2,a=window.pageYOffset+n-i;window.scrollTo({top:Math.max(0,a),behavior:`smooth`})})}function QE(e){$E(),XE=document.createElement(`div`),XE.id=`fe-spotlight-overlay`,XE.style.cssText=`position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.35);z-index:9998;pointer-events:none;transition:opacity 0.4s ease;opacity:0;`,document.body.appendChild(XE),XE.offsetHeight,XE.style.opacity=`1`,e.style.position=`relative`,e.style.zIndex=`9999`}function $E(){if(XE){XE.style.opacity=`0`;let e=XE;setTimeout(()=>{e.parentNode&&e.parentNode.removeChild(e)},400),XE=null}document.querySelectorAll(`[data-fe-highlighted]`).forEach(e=>{e.style.zIndex=``,e.style.position=``})}function eD(e){if(!e||e.hasAttribute(`data-fe-highlighted`))return;tD(),ZE(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`,QE(e),setTimeout(()=>tD(),6e4)}function tD(){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`)),$E()}var Q=`fe-vv`;function nD(){if(typeof document>`u`||document.getElementById(`${Q}-styles`))return;let e=`
465
+ `;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,N.jsxs)(`div`,{style:{position:`relative`,width:e,height:e,flexShrink:0,cursor:i?`pointer`:`default`,...a},className:o,onClick:i,children:[u&&!d&&(0,N.jsx)(dp.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,N.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,N.jsx)(`canvas`,{ref:f,style:{width:`100%`,height:`100%`,display:`block`}})}),u&&(0,N.jsx)(`div`,{style:{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,pointerEvents:`none`,zIndex:1},children:(0,N.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`3px`},children:[4,8,12,8,4].map((e,t)=>(0,N.jsx)(dp.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 Q=`fe-vv`;function dD(){if(typeof document>`u`||document.getElementById(`${Q}-styles`))return;let e=`
466
466
  /* ── Action toast ───────────────────────────────────────────────────────────── */
467
467
  #${Q}-toast {
468
468
  position: fixed;
@@ -602,15 +602,15 @@ registerProcessor("scribeAudioProcessor", ScribeAudioProcessor);
602
602
  50% { transform: translate(-4px,-4px) scale(0.82); }
603
603
  100% { transform: translate(-4px,-4px) scale(1); }
604
604
  }
605
- `,t=document.createElement(`style`);t.id=`${Q}-styles`,t.textContent=e,(document.head||document.documentElement).appendChild(t)}var rD=null,iD=null;function aD(){return(!rD||!rD.isConnected)&&(rD=document.createElement(`div`),rD.id=`${Q}-toast`,document.body.appendChild(rD)),rD}function oD(e,{spinner:t=!0,icon:n=null,duration:r=0}={}){if(typeof document>`u`)return;nD(),iD&&=(clearTimeout(iD),null);let i=aD();if(i.innerHTML=``,n){let e=document.createElement(`span`);e.className=`${Q}-icon`,e.textContent=n,i.appendChild(e)}else if(t){let e=document.createElement(`span`);e.className=`${Q}-spin`,i.appendChild(e)}let a=document.createElement(`span`);a.textContent=e,i.appendChild(a),i.classList.remove(`${Q}-show`),i.offsetHeight,i.classList.add(`${Q}-show`),r>0&&(iD=setTimeout(()=>sD(),r))}function sD(e=0){rD&&(e>0?iD=setTimeout(()=>{rD&&rD.classList.remove(`${Q}-show`)},e):rD&&rD.classList.remove(`${Q}-show`))}var cD=null,lD=[];function uD(){return(!cD||!cD.isConnected)&&(cD=document.createElement(`div`),cD.id=`${Q}-bar`,document.body.appendChild(cD)),cD}function dD(){if(typeof document>`u`)return;nD(),lD.forEach(clearTimeout),lD=[];let e=uD();e.style.transition=`none`,e.style.width=`0%`,e.classList.add(`${Q}-bar-active`),e.offsetHeight,e.style.transition=`width 0.35s ease, opacity 0.25s ease`;let t=[[80,`width 0.6s ease`],[92,`width 1.2s ease`]],n=50;for(let[e,r]of t){let t=n,i=e,a=r;lD.push(setTimeout(()=>{cD&&(cD.style.transition=a,cD.style.width=`${i}%`)},t)),n+=800}}function fD(){cD&&(lD.forEach(clearTimeout),lD=[],cD.style.transition=`width 0.2s ease`,cD.style.width=`100%`,lD.push(setTimeout(()=>{cD&&(cD.style.transition=`opacity 0.35s ease`,cD.style.opacity=`0`,lD.push(setTimeout(()=>{cD&&(cD.style.width=`0%`,cD.classList.remove(`${Q}-bar-active`))},380)))},220)))}function pD(){typeof document>`u`||document.querySelectorAll(`.${Q}-field-active, .${Q}-field-filled`).forEach(e=>e.classList.remove(`${Q}-field-active`,`${Q}-field-filled`))}function mD(e){!e||typeof document>`u`||(nD(),pD(),e.classList.add(`${Q}-field-active`))}function hD(e){e&&(e.classList.remove(`${Q}-field-active`),e.classList.add(`${Q}-field-filled`),setTimeout(()=>{e.isConnected&&e.classList.remove(`${Q}-field-filled`)},1400))}var gD=`<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
605
+ `,t=document.createElement(`style`);t.id=`${Q}-styles`,t.textContent=e,(document.head||document.documentElement).appendChild(t)}var fD=null,pD=null;function mD(){return(!fD||!fD.isConnected)&&(fD=document.createElement(`div`),fD.id=`${Q}-toast`,document.body.appendChild(fD)),fD}function hD(e,{spinner:t=!0,icon:n=null,duration:r=0}={}){if(typeof document>`u`)return;dD(),pD&&=(clearTimeout(pD),null);let i=mD();if(i.innerHTML=``,n){let e=document.createElement(`span`);e.className=`${Q}-icon`,e.textContent=n,i.appendChild(e)}else if(t){let e=document.createElement(`span`);e.className=`${Q}-spin`,i.appendChild(e)}let a=document.createElement(`span`);a.textContent=e,i.appendChild(a),i.classList.remove(`${Q}-show`),i.offsetHeight,i.classList.add(`${Q}-show`),r>0&&(pD=setTimeout(()=>gD(),r))}function gD(e=0){fD&&(e>0?pD=setTimeout(()=>{fD&&fD.classList.remove(`${Q}-show`)},e):fD&&fD.classList.remove(`${Q}-show`))}var _D=null,vD=[];function yD(){return(!_D||!_D.isConnected)&&(_D=document.createElement(`div`),_D.id=`${Q}-bar`,document.body.appendChild(_D)),_D}function bD(){if(typeof document>`u`)return;dD(),vD.forEach(clearTimeout),vD=[];let e=yD();e.style.transition=`none`,e.style.width=`0%`,e.classList.add(`${Q}-bar-active`),e.offsetHeight,e.style.transition=`width 0.35s ease, opacity 0.25s ease`;let t=[[80,`width 0.6s ease`],[92,`width 1.2s ease`]],n=50;for(let[e,r]of t){let t=n,i=e,a=r;vD.push(setTimeout(()=>{_D&&(_D.style.transition=a,_D.style.width=`${i}%`)},t)),n+=800}}function xD(){_D&&(vD.forEach(clearTimeout),vD=[],_D.style.transition=`width 0.2s ease`,_D.style.width=`100%`,vD.push(setTimeout(()=>{_D&&(_D.style.transition=`opacity 0.35s ease`,_D.style.opacity=`0`,vD.push(setTimeout(()=>{_D&&(_D.style.width=`0%`,_D.classList.remove(`${Q}-bar-active`))},380)))},220)))}function SD(){typeof document>`u`||document.querySelectorAll(`.${Q}-field-active, .${Q}-field-filled`).forEach(e=>e.classList.remove(`${Q}-field-active`,`${Q}-field-filled`))}function CD(e){!e||typeof document>`u`||(dD(),SD(),e.classList.add(`${Q}-field-active`))}function wD(e){e&&(e.classList.remove(`${Q}-field-active`),e.classList.add(`${Q}-field-filled`),setTimeout(()=>{e.isConnected&&e.classList.remove(`${Q}-field-filled`)},1400))}var TD=`<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
606
606
  <filter id="${Q}-csh">
607
607
  <feDropShadow dx="1" dy="2" stdDeviation="1.5" flood-color="#00000060"/>
608
608
  </filter>
609
609
  <path d="M4 2L19 10.5L11 12.8L8 20L4 2Z"
610
610
  fill="white" stroke="#1e1b4b" stroke-width="1.6" stroke-linejoin="round"
611
611
  filter="url(#${Q}-csh)"/>
612
- </svg>`,_D=null,vD=!1;function yD(){return(!_D||!_D.isConnected)&&(_D=document.createElement(`div`),_D.id=`${Q}-cursor`,_D.innerHTML=gD,document.body.appendChild(_D),vD=!1),_D}async function bD(e){if(typeof document>`u`||!e)return;nD();let t;try{t=e.getBoundingClientRect()}catch{return}let n=t.left+Math.min(16,t.width*.2),r=t.top+Math.min(12,t.height*.25),i=yD();vD||=(i.style.transition=`none`,i.style.left=`${window.innerWidth/2}px`,i.style.top=`${window.innerHeight*.4}px`,i.classList.add(`${Q}-cursor-visible`),i.offsetHeight,i.style.transition=`left 0.32s cubic-bezier(0.25,0.46,0.45,0.94), top 0.32s cubic-bezier(0.25,0.46,0.45,0.94), opacity 0.2s ease`,!0),i.style.left=`${n}px`,i.style.top=`${r}px`,await wD(360)}function xD(e=!1){_D&&(e?(_D.classList.remove(`${Q}-cursor-visible`),vD=!1):(_D.classList.remove(`${Q}-cursor-visible`),setTimeout(()=>{vD=!1},250)))}async function SD(e){_D&&(_D.classList.add(`${Q}-cursor-click`),await wD(280),_D.classList.remove(`${Q}-cursor-click`))}function CD(e){if(!e||typeof document>`u`)return;nD();let t;try{t=e.getBoundingClientRect()}catch{return}let n=e.style.position,r=e.style.overflow,i=window.getComputedStyle(e).position;[`relative`,`absolute`,`fixed`,`sticky`].includes(i)||(e.style.position=`relative`),e.style.overflow=`hidden`;let a=document.createElement(`span`);a.className=`${Q}-ripple`;let o=Math.max(t.width,t.height)*1.2;Object.assign(a.style,{width:`${o}px`,height:`${o}px`,left:`${t.width/2-o/2}px`,top:`${t.height/2-o/2}px`}),e.appendChild(a),setTimeout(()=>{a.remove(),e.style.position=n,e.style.overflow=r},650)}function wD(e){return new Promise(t=>setTimeout(t,e))}function $(...e){ln()&&console.log(`[FlowEngage:voice-tools]`,...e)}function TD(e){return new Promise(t=>setTimeout(t,e))}var ED=`#flowengage-root, .flowengage-shell, .flowengage-widget-root`;function DD(e){if(!e||typeof e.closest!=`function`)return!1;try{return!!e.closest(ED)}catch{return!1}}function OD(e){try{let t=e.ownerDocument?.defaultView;if(t)return t.getComputedStyle(e)}catch{}return window.getComputedStyle(e)}function kD(e){let t=new Set;function n(r){if(!r||t.has(r))return;t.add(r),e(r);let i=r.querySelectorAll(`iframe`);for(let e of i)if(!DD(e))try{let t=e.contentDocument;t&&n(t)}catch{}}typeof document<`u`&&n(document)}function AD(e){return e==null?null:String(e).replace(/\u00a0/g,` `).replace(/\s*\*+\s*$/u,``).replace(/\s+/g,` `).trim()}function jD(e){let t=e.ownerDocument||document,n=e.getAttribute(`aria-labelledby`);if(n){let e=n.trim().split(/\s+/).filter(Boolean),r=[];for(let n of e)try{let e=t.getElementById(n);e?.textContent&&r.push(e.textContent.trim())}catch{}if(r.length)return AD(r.join(` `))}if(e.labels&&e.labels.length)return AD(e.labels[0].textContent);let r=e.id;if(r)try{let e=t.querySelector(`label[for="${CSS.escape(r)}"]`);if(e)return AD(e.textContent)}catch{let e=t.querySelector(`label[for="${r.replace(/"/g,`\\"`)}"]`);if(e)return AD(e.textContent)}let i=e.previousElementSibling;for(let e=0;e<6&&i;e+=1){if(i.tagName===`LABEL`)return AD(i.textContent);let e=(i.className||``).toString().toLowerCase();if(/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)){let e=AD(i.textContent);if(e)return e}i=i.previousElementSibling}let a=e.parentElement;for(let e=0;e<5&&a;e+=1){if(a.tagName===`LABEL`)return AD(a.textContent);let e=a.querySelector?.(`:scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']`);if(e?.textContent)return AD(e.textContent);a=a.parentElement}let o=e.getAttribute(`aria-label`);return o?AD(o):null}function MD(){let e=[];return kD(t=>{e.push(...Array.from(t.querySelectorAll(`input, select, textarea`)).filter(e=>{if(DD(e))return!1;let t=(e.type||``).toLowerCase();if([`hidden`,`submit`,`button`,`image`].includes(t)||e.disabled||e.readOnly)return!1;try{let t=OD(e);if(t.display===`none`||t.visibility===`hidden`)return!1}catch{}return!0}))}),e}function ND(){return MD().map((e,t)=>({formIndex:0,fieldIndex:t,tag:e.tagName,type:e.type||`text`,name:e.name||null,id:e.id||null,label:jD(e),placeholder:e.placeholder||null}))}function PD(){let e=[];return kD(t=>{e.push(...Array.from(t.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"]`)).filter(e=>{if(DD(e)||e.disabled)return!1;try{let t=OD(e);if(t.display===`none`||t.visibility===`hidden`)return!1}catch{}return!0}))}),e.slice(0,60).map((e,t)=>({index:t,text:(e.textContent||e.value||``).replace(/\s+/g,` `).trim().slice(0,120)||null,ariaLabel:e.getAttribute(`aria-label`),type:e.type||e.tagName}))}function FD(e){return String(e||``).toLowerCase().replace(/\u00a0/g,` `).replace(/\*/g,``).replace(/\s+/g,` `).trim()}function ID(e){let t=FD(e);return t=t.replace(/\s+field\s*$/i,``).trim(),t}function LD(e,t){let n=ID(t);if(!n)return 0;let r=(e.name||``).toLowerCase(),i=(e.id||``).toLowerCase();if(r===`url`&&/url|website|domain|site|audit/.test(n)||(i===`url-input`||i.endsWith(`-url-input`))&&/url|website|domain|site|audit/.test(n))return 100;let a=[e.name,e.id,e.placeholder,jD(e),e.getAttribute(`aria-label`),e.getAttribute(`title`),e.getAttribute(`data-testid`),e.getAttribute(`autocomplete`)].filter(Boolean).map(e=>FD(e)),o=0;for(let e of a){if(!e)continue;if(e.includes(n)||n.includes(e)){o=Math.max(o,100);continue}let t=n.split(/\s+/).filter(e=>e.length>1);if(!t.length)continue;let r=0;for(let n of t)e.includes(n)&&(r+=1);o=Math.max(o,r/t.length*88)}return o}var RD=28;function zD(e,t){let n=null,r=0;for(let i of e){let e=LD(i,t);e>r&&(r=e,n=i)}return!n||r<RD?null:n}function BD(e,t,n){let r=String(t||``).toLowerCase().trim(),i=String(n||``).trim();if(!(/^https?:\/\//i.test(i)||/\.\w{2,}(\/|\s|$)/.test(i)||r.includes(`url`)||r.includes(`website`)||r.includes(`domain`)||r.includes(`site`)))return null;let a=null,o=0;for(let t of e){if(t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`)continue;let e=(t.type||``).toLowerCase();if([`hidden`,`submit`,`button`,`checkbox`,`radio`].includes(e))continue;let n=0;(e===`url`||e===`text`||e===`search`)&&(n+=45);let r=[t.name,t.id,t.placeholder,jD(t),t.getAttribute(`aria-label`),t.getAttribute(`autocomplete`)].filter(Boolean).join(` `).toLowerCase();/(website|url|domain|site\s*url)/.test(r)&&(n+=55),n>o&&(o=n,a=t)}return!a||o<42?null:a}function VD(e){let t=String(e??``).trim();return t?/^https?:\/\//i.test(t)?!0:/\.\w{2,}(\/|\s|$)/.test(t):!1}function HD(e){let t=String(e??``).toLowerCase().trim();return t?!!(t===`url`||t===`website`||t===`website url`||t===`website_url`||t===`enter website url`||t.includes(`website`)||t.includes(`domain`)||/(enter\s+website|site\s*url|page\s*url)/.test(t)):!1}function UD(e){if(!e||e.tagName!==`INPUT`&&e.tagName!==`TEXTAREA`)return!1;let t=(e.type||``).toLowerCase();return![`hidden`,`submit`,`button`,`checkbox`,`radio`,`file`].includes(t)}function WD(e){if(!UD(e))return!1;let t=(e.name||``).toLowerCase(),n=(e.id||``).toLowerCase(),r=[e.name,e.id,e.placeholder,jD(e),e.getAttribute(`aria-label`)].filter(Boolean).join(` `).toLowerCase();return t===`url`||n===`url-input`||n.endsWith(`-url-input`)||/(website\s*url|enter\s+website|site\s*url)/.test(r)||/(website|domain)/.test(r)&&/(url|site)/.test(r)}function GD(e,t,n){let r=String(t??``),i=String(n??``),a=JD(e,r)||zD(e,r)||BD(e,r,i);if(!a)return[];let o=new Set([a]);if(VD(i)&&HD(r))for(let t of e)t!==a&&WD(t)&&o.add(t);let s=Array.from(o);return s.sort((e,t)=>{if(e===t)return 0;let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0}),s}function KD(e,t){try{if(!e?.getBoundingClientRect||!t?.getBoundingClientRect)return 1/0;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i={x:n.left+n.width/2,y:n.top+n.height/2},a={x:r.left+r.width/2,y:r.top+r.height/2};return Math.hypot(i.x-a.x,i.y-a.y)}catch{return 1/0}}function qD(e){if(!e||typeof e!=`string`)return null;let t=null;return kD(n=>{try{let r=n.getElementById(e);r&&!DD(r)&&r.matches?.(`input, select, textarea`)&&(t=r)}catch{}}),t}function JD(e,t){let n=String(t??``).trim();if(!n)return null;let r=n.match(/^name:\s*([\w.-]+)$/i);if(r){let t=r[1];for(let n of e)if(n.name===t)return n}let i=n.match(/^id:\s*([\w.-]+)$/i);if(i){let e=qD(i[1]);if(e)return e}let a=n.startsWith(`#`)?n.slice(1):n;if(/^[\w-]+$/.test(a)){let e=qD(a);if(e)return e}let o=n.toLowerCase().replace(/\s+/g,` `);if(o===`url`||o===`website`||o===`website url`||o===`website_url`||o===`enter website url`)for(let t of e){let e=(t.name||``).toLowerCase(),n=(t.id||``).toLowerCase();if(e===`url`||n===`url-input`||n.endsWith(`-url-input`))return t}return null}function YD(e,t){let n=String(t||``).toLowerCase().trim();if(!n)return 0;let r=[e.textContent,e.value,e.getAttribute(`aria-label`),e.getAttribute(`title`)].filter(Boolean).join(` `).toLowerCase().replace(/\s+/g,` `);if(r.includes(n))return 100;let i=n.split(/\s+/).filter(e=>e.length>1);if(!i.length)return 0;let a=0;for(let e of i)r.includes(e)&&(a+=1);return a/i.length*92}function XD(e,t){let n=[];kD(e=>{n.push(...Array.from(e.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"]`)).filter(e=>{if(DD(e)||e.disabled)return!1;try{let t=OD(e);if(t.display===`none`||t.visibility===`hidden`)return!1}catch{}return!0}))});let r=0,i=n.map(t=>({el:t,s:YD(t,e)}));for(let{s:e}of i)e>r&&(r=e);if(r<36)return null;let a=i.filter(({s:e})=>e===r).map(({el:e})=>e);if(a.length===1)return a[0];let o=Array.isArray(t)?t.filter(e=>e&&e.isConnected):[];if(o.length){let e=a[0],t=1/0;for(let n of a)for(let r of o){let i=KD(n,r);i<t&&(t=i,e=n)}return e}return a[0]}function ZD(e){if(e==null)return{};if(typeof e==`string`){let t=e.trim();if(!t)return{};try{return JSON.parse(t)}catch{return{url:t}}}return e}function QD(e){let t=ZD(e);if(Array.isArray(t)&&t.length>0){let e=t[0];if(e?.field_key!=null||e?.fieldKey!=null)return t.map(e=>({field_key:e.field_key??e.fieldKey,value:e.value}))}if(!t||typeof t!=`object`)return[];let n=t.fields??t.Fields??t.field_list??t.fieldList??t.data?.fields;if(typeof n==`string`)try{n=JSON.parse(n)}catch{n=null}n&&!Array.isArray(n)&&typeof n==`object`&&(n=Object.values(n)),(!n||n.length===0)&&(t.field_key!=null||t.fieldKey!=null)&&t.value!=null&&(n=[{field_key:t.field_key??t.fieldKey,value:t.value}]);let r=t.website_url??t.websiteUrl??t.url??t.website??t.domain??t.site_url??t.siteUrl;return(!n||n.length===0)&&r!=null&&String(r).trim()&&(n=[{field_key:t.field_key??t.fieldKey??`url`,value:String(r).trim()}]),Array.isArray(n)?n.map(e=>({field_key:e?.field_key??e?.fieldKey,value:e?.value??e?.Value})):[]}function $D(e){if(!e||typeof e!=`string`)return[];let t=e.trim();if(!t||/\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t))return[];let n=t.match(/https?:\/\/[^\s<>"']+/i);if(n)return[{field_key:`url`,value:n[0].replace(/[.,;:)]+$/,``)}];let r=t.match(/\b(?:[\w-]+\.)+[a-z]{2,}\b/i);if(r){let e=r[0].replace(/[.,;:)]+$/,``);return/^https?:/i.test(e)||(e=`https://${e}`),[{field_key:`url`,value:e}]}return[]}function eO(e){if(!e||typeof e!=`string`)return[];let t=e.trim();if(!t)return[];let n=[],r=new Set,i=/\b([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\b/i,a=(e,t)=>{let i=String(t??``).trim().replace(/^["']|["']$/g,``);if(!i||i.length>800)return;let a=`${e}\0${i}`;r.has(a)||(r.add(a),n.push({field_key:e,value:i}))},o=t.match(/^\s*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\s*$/i);if(o)return a(`Email Address`,o[1]),n;let s=t.match(/\b(?:please\s+)?(?:enter|type|put)\s+(.+?)\s+in(?:to)?\s+(?:the\s+)?(?:full\s*name|full\s*name\s*field|name\s*field)\b/i);if(s&&a(`Full Name`,s[1]),s=t.match(/\bfull\s*name,?\s*(?:please\s+)?(?:enter|type|put)\s+(.+?)(?:\.|$|!|\?)/i),s&&a(`Full Name`,s[1]),s=t.match(/\bfull\s*name\s*(?:is|:|please\s+enter|-)\s*(.+?)(?:\.|$|(?=\s+(?:and|my\s+email|email|message))\b)/i),s&&a(`Full Name`,s[1]),s=t.match(/\b(.+?)\s+for\s+(?:the\s+)?full\s*name\b/i),s){let e=s[1].trim();e.length>1&&e.length<120&&!/@/.test(e)&&a(`Full Name`,e)}if(s=t.match(/\b(?:email|e-mail)(?:\s*address)?\s*(?:is|:|please\s+use|enter|-)\s*([^\s@]+@[^\s@]+\.[^\s,]+)/i),s&&a(`Email Address`,s[1]),s=t.match(/\b(?:enter|type|put)\s+([^\s@]+@[^\s@]+\.[^\s,]+)\s+in(?:to)?\s+(?:the\s+)?(?:email|e-mail)/i),s&&a(`Email Address`,s[1]),s=t.match(/\b(?:message|comment)\s*(?:is|:|please\s+enter|-)\s*(.+)$/is),s){let e=s[1].trim();e.length>0&&a(`Message`,e)}if(!n.some(e=>/email/i.test(String(e.field_key)))){let e=t.match(i);if(e){let r=t.replace(e[0],``).trim().replace(/^(please|it's|it is|use|is|my email is|e-?mail is)\s*/i,``).replace(/[.,;:!?]+$/,``).trim();if(t.length<=96&&r.length<=36)return a(`Email Address`,e[1]),n}}if(n.length===0){let e=t.split(/\s+/).filter(Boolean).length,n=/[.!?]/.test(t)||e>=6||t.length>=24&&e>=5||t.length>=42,r=/^[A-Z][a-z]+\s+[A-Z][a-z]+$/.test(t.trim());n&&t.length>=16&&!i.test(t)&&!r&&a(`Message`,t)}return n}function tO(e){if(!e||typeof e!=`object`)return null;let t=e.url??e.target_url??e.page_url??e.pageUrl??e.link??e.href??e.path;return t==null?null:String(t).trim()||null}function nO(e){if(!e||typeof e!=`object`)return null;let t=e.query??e.q??e.search??e.text??e.keywords;return t==null?null:String(t).trim()||null}function rO(e,t,n){if(!n?.skipScroll)try{e.scrollIntoView({block:`center`,inline:`nearest`})}catch{try{e.scrollIntoView(!0)}catch{}}try{e.focus({preventScroll:!0})}catch{try{e.focus()}catch{}}let r=e.tagName,i=(e.type||``).toLowerCase();if(r===`SELECT`)return e.value=String(t),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0})),!0;if(i===`checkbox`||i===`radio`)return e.checked=[`1`,`true`,`yes`,`on`].includes(String(t).toLowerCase().trim()),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0})),!0;let a=String(t);if(r===`INPUT`||r===`TEXTAREA`){let t=e.ownerDocument?.defaultView||window,n=r===`TEXTAREA`?t.HTMLTextAreaElement.prototype:t.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(n,`value`);i?.set?i.set.call(e,a):e.value=a}else e.value=a;let o={bubbles:!0,cancelable:!0,composed:!0};try{e.dispatchEvent(new InputEvent(`input`,{...o,inputType:`insertText`,data:a}))}catch{e.dispatchEvent(new Event(`input`,o))}e.dispatchEvent(new Event(`change`,o));try{queueMicrotask(()=>{try{e.dispatchEvent(new Event(`input`,o)),e.dispatchEvent(new Event(`change`,o))}catch{}})}catch{}return!0}function iO(){let e={};document.querySelectorAll(`h1, h2, h3, h4, h5, h6`).forEach(t=>{if(t.id)return;let n=t.textContent.trim();if(!n)return;let r=n.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).substring(0,60);if(e[r]){let t=2;for(;e[r+`-`+t];)t++;r=r+`-`+t}e[r]=!0,t.id=r})}function aO(e){let t=e.siteId||null,n=(e.apiBaseUrl||``).replace(/\/$/,``),r=typeof e.getLastUserVoiceText==`function`?e.getLastUserVoiceText:null,i=[],a={flowengage_navigate:async n=>{$(`flowengage_navigate ▶ raw parameters:`,n);let r=ZD(n),i=tO(r),a=r.section_text??r.sectionText??r.section;if($(`flowengage_navigate · coerced:`,{url:i,sectionText:a}),!i){let e=`Missing url: pass a string url, path like /pricing, or JSON with a url field.`;return $(`flowengage_navigate ✖`,e),e}if(!await xn(i,{siteId:t,apiBaseUrl:e.apiBaseUrl})){let e=`That page is not available in the site index; answer without navigating.`;return $(`flowengage_navigate ✖ blocked`,e),e}try{if(oD(`Navigating to ${i}...`,{spinner:!0}),dD(),JE(),tD(),$(`flowengage_navigate → shadowNavigate`,i),await Cn(i),await TD(400),iO(),a&&typeof a==`string`){let e=gn(null,a);e&&GE(()=>eD(e)),$(`flowengage_navigate · highlight`,{sectionText:a,found:!!e})}let e=`OK_NAVIGATION ${i}`;return $(`flowengage_navigate ✓`,e),oD(`Navigation complete`,{spinner:!1,icon:`✅`,duration:1200}),e}catch(e){let t=`Navigation error: ${e?.message||String(e)}`;return $(`flowengage_navigate ✖`,t),oD(`Navigation failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{fD(),sD(900)}},flowengage_highlight:async e=>{$(`flowengage_highlight ▶`,e);let t=ZD(e),n=t?.section_id||t?.sectionId,r=t?.section_text||t?.sectionText,i=gn(n||null,r||null);return i?(GE(()=>eD(i)),$(`flowengage_highlight ✓ (enqueued)`),`Highlighted the section.`):($(`flowengage_highlight ✖ no element`),`Could not find that section on the page.`)},flowengage_read_content:async e=>{$(`flowengage_read_content ▶`,e);let t=ZD(e),n=t?.section_text||t?.sectionText||``;try{let e=``;if(n){let t=gn(null,n);if(!t)return`Could not find section "${n}" on the page.`;let r=[t.textContent.trim()],i=t.nextElementSibling;for(;i&&!/^H[1-3]$/i.test(i.tagName);){let e=i.textContent.trim();e&&r.push(e),i=i.nextElementSibling}e=r.join(`
613
- `)}else{let t=(document.querySelector(`main`)||document.querySelector(`article`)||document.querySelector(`[role="main"]`)||document.querySelector(`#content`)||document.querySelector(`.content`)||document.body).cloneNode(!0);t.querySelectorAll(`nav, footer, header, aside, script, style, noscript, .nav, .footer, .header, .sidebar`).forEach(e=>e.remove()),e=t.textContent.replace(/\s+/g,` `).trim()}return e.length>8e3&&(e=e.substring(0,8e3)+`... (truncated)`),$(`flowengage_read_content ✓`,`${e.length} chars`),e||`No readable content found on this page.`}catch(e){return $(`flowengage_read_content ✖`,e.message),`Could not read page content: ${e.message}`}},flowengage_search:async e=>{$(`flowengage_search ▶`,e);let r=nO(ZD(e));if($(`flowengage_search · query:`,r,`siteId:`,t,`apiBase:`,n||`(empty)`),!r)return $(`flowengage_search ✖ missing query`),`Missing query parameter.`;if(!t)return $(`flowengage_search ✖ no siteId`),`Site is not configured for search.`;if(!n)return $(`flowengage_search ✖ no api base`),`API base URL is missing; cannot search.`;try{let e=`${n}/api/site-tools/search`;$(`flowengage_search → POST`,e);let i=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({siteId:t,query:r,currentUrl:typeof window<`u`?window.location.href:``})}),a=await i.json();if($(`flowengage_search · HTTP`,i.status,`success:`,a.success),!a.success){let e=a.error||`Search failed.`;return $(`flowengage_search ✖`,e),e}let o=a.results||[];return $(`flowengage_search ✓`,`${o.length} result(s)`,o.slice(0,3).map(e=>e?.url||e)),JSON.stringify(o)}catch(e){let t=`Search error: ${e.message||`network`}`;return $(`flowengage_search ✖`,t),t}},flowengage_page_content:async e=>{$(`flowengage_page_content ▶`,e);let r=ZD(e),i=r?.url||r?.page_url||``;if($(`flowengage_page_content · url:`,i,`siteId:`,t,`apiBase:`,n||`(empty)`),!i)return $(`flowengage_page_content ✖ missing url`),`Missing url parameter.`;if(!t)return $(`flowengage_page_content ✖ no siteId`),`Site is not configured.`;if(!n)return $(`flowengage_page_content ✖ no api base`),`API base URL is missing; cannot fetch page content.`;try{let e=`${n}/api/site-tools/page-content`;$(`flowengage_page_content → POST`,e);let r=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({siteId:t,url:i})}),a=await r.json();if($(`flowengage_page_content · HTTP`,r.status,`success:`,a.success),!a.success){let e=a.error||`Failed to get page content.`;return $(`flowengage_page_content ✖`,e),e}return $(`flowengage_page_content ✓`,`title: ${a.title}`,`sections: ${(a.sections||[]).length}`,`content: ${(a.content||``).length} chars`),JSON.stringify({title:a.title,url:a.url,sections:a.sections,content:a.content})}catch(e){let t=`Page content error: ${e.message||`network`}`;return $(`flowengage_page_content ✖`,t),t}},flowengage_end_session:async()=>($(`flowengage_end_session ▶`),typeof e.requestEndSession==`function`&&e.requestEndSession(),`Voice session is ending.`),flowengage_list_forms:async()=>{let e=ND(),t=PD();return $(`flowengage_list_forms ✓`,`${e.length} field(s)`,`${t.length} button(s)`),JSON.stringify({fields:e,buttons:t,hint:`field_key: placeholder/label, name (e.g. url), id (e.g. url-input). If the page has two URL boxes, flowengage_fill_form sets all matching URL inputs. flowengage_click_button picks the Conduct Audit nearest the filled field when labels duplicate.`})},flowengage_fill_form:async e=>{try{$(`flowengage_fill_form ▶ raw:`,e),pD();let t=QD(e);if(!t.length&&r){let e=r(),n=$D(e);n.length?$(`flowengage_fill_form · inferred URL from last user utterance (model omitted usable fields):`,n):(n=eO(e),n.length&&$(`flowengage_fill_form · inferred contact fields from last user utterance (empty tool params):`,n)),n.length&&(t=n)}if($(`flowengage_fill_form · normalized fields:`,t),!t.length)return`No fields provided. Call flowengage_list_forms for field_key strings, then flowengage_fill_form with { "fields": [ { "field_key": "<label or placeholder from list>", "value": "<user value>" } ] }. Never use empty {}. Pass the value the user just said (email, message, name, URL) in fields.`;let n=[];for(let e of t){let t=e?.field_key??e?.fieldKey,r=e?.value;if(t==null||r==null)continue;oD(`Filling ${String(t)}...`,{spinner:!0});let a=MD(),o=GD(a,String(t),r);if(o.length){for(let[e,t]of o.entries())mD(t),await bD(t),rO(t,r,{skipScroll:e>0}),hD(t),await TD(120);i=o,n.push(String(t));continue}let s=JD(a,String(t));s||=zD(a,String(t)),s||=BD(a,String(t),r),s&&(mD(s),await bD(s),rO(s,r),hD(s),await TD(120),i=[s],n.push(String(t)))}if(!n.length)return $(`flowengage_fill_form ✖ no matches`),`Could not match any fields. Call flowengage_list_forms and use field_key values that match placeholder, label, name, or id (e.g. Enter Website URL). Ensure the form is on the page, not the chat panel.`;let a=`OK_FILLED: ${n.join(`, `)}`;return $(`flowengage_fill_form ✓`,a),oD(`Form filled`,{spinner:!1,icon:`✅`,duration:1100}),a}catch(e){let t=`flowengage_fill_form error: ${e?.message||String(e)}`;return $(`flowengage_fill_form ✖`,t),oD(`Failed to fill form`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{xD(),pD(),sD(700)}},flowengage_click_button:async e=>{let t=ZD(e),n=(t.button_text??t.buttonText??t.text??``).trim();if($(`flowengage_click_button ▶`,n),!n)return`Missing button_text: pass the visible label, e.g. Conduct Audit.`;let r=XD(n,i);if(!r)return $(`flowengage_click_button ✖ no match`),`Could not find a button matching "${n}". Call flowengage_list_forms to see button texts.`;try{oD(`Clicking ${n}...`,{spinner:!0});try{r.scrollIntoView({block:`center`,inline:`nearest`})}catch{r.scrollIntoView(!0)}await bD(r),r.focus?.(),await SD(r),CD(r),r.click();let e=(r.textContent||r.value||r.getAttribute(`aria-label`)||``).trim().slice(0,80)||`button`,t=`OK_CLICK ${e}`;return $(`flowengage_click_button ✓`,t),oD(`Clicked ${e}`,{spinner:!1,icon:`✅`,duration:1200}),t}catch(e){let t=`Click failed: ${e?.message||String(e)}`;return $(`flowengage_click_button ✖`,t),oD(`Click failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{xD(),sD(700)}}};return{...a,navigateToPage:a.flowengage_navigate,highlightOnPage:a.flowengage_highlight,searchSiteContent:a.flowengage_search,getPageContent:a.flowengage_page_content,endVoiceSession:a.flowengage_end_session,listPageForms:a.flowengage_list_forms,fillFormFields:a.flowengage_fill_form,clickPageButton:a.flowengage_click_button}}function oO(e){return!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,async n=>{let r=ln();r?console.log(`[FlowEngage:voice-tool] ▶`,e,n):console.info(`[FlowEngage] voice tool » ${e}`);let i;try{i=await t(n)}catch(t){let n=`Tool error: ${t?.message||String(t)}`;return console.error(`[FlowEngage] voice tool ${e} threw:`,t),n}let a=typeof i==`string`?i.length>220?`${i.slice(0,220)}…`:i:String(i);return r?console.log(`[FlowEngage:voice-tool] ◀`,e,a):console.info(`[FlowEngage] voice tool « ${e}:`,a),i}]))}var sO={blue:`#135bd8`,red:`#ef334b`,yellow:`#ffbd2e`,dark:`#0d1b2a`,highlight:`rgba(255,255,255,0.9)`,green:`#10b981`};function cO(e){if(!Array.isArray(e)||e.length<2)return`linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa`;let[t,n,r]=e;return e.length>=3&&r?[`radial-gradient(ellipse 80% 70% at -10% 50%, ${t}1a 0%, transparent 70%)`,`radial-gradient(ellipse 70% 80% at 110% 30%, ${n}1a 0%, transparent 70%)`,`radial-gradient(ellipse 80% 60% at 50% 110%, ${r}1a 0%, transparent 70%)`,`#f7f8fa`].join(`, `):[`radial-gradient(ellipse 80% 100% at -10% 50%, ${t}1a 0%, transparent 70%)`,`radial-gradient(ellipse 80% 100% at 110% 50%, ${n}1a 0%, transparent 70%)`,`#f7f8fa`].join(`, `)}function lO(e){if(!e||typeof e!=`string`)return`#1a1a1a`;let t=e.replace(`#`,``),n=t.length===3?t.split(``).map(e=>e+e).join(``):t,r=parseInt(n.slice(0,2),16)/255,i=parseInt(n.slice(2,4),16)/255,a=parseInt(n.slice(4,6),16)/255,o=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;return .2126*o(r)+.7152*o(i)+.0722*o(a)>.179?`#1a1a1a`:`#ffffff`}function uO({logo:e,style:t}){if(!e)return null;if(typeof e==`string`)return(0,N.jsx)(`img`,{src:e,alt:``,style:{objectFit:`contain`,flexShrink:0,display:`block`,...t}});let n=typeof e==`function`?b.createElement(e):b.isValidElement(e)?e:null;return n?(0,N.jsx)(`span`,{className:`fe-logo-slot`,style:{display:`inline-flex`,alignItems:`center`,flexShrink:0,overflow:`hidden`,...t},children:n}):null}function dO({title:e}){return(0,N.jsx)(`div`,{style:{width:`100%`,height:`100%`,borderRadius:`16px`,background:`linear-gradient(135deg, rgba(59,130,246,0.16) 0%, rgba(59,130,246,0.08) 100%)`,color:`#2563eb`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:`18px`,fontWeight:700,letterSpacing:`-0.03em`},children:String(e||`FE`).split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0]?.toUpperCase()||``).join(``)||`FE`})}function fO(e,t){let n=(t||``).trim();return n?!!(/\b(let'?s|let us)\s+(end|stop|finish|wrap up|close)\s+(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n)||/\bend\s+(this\s+)?(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n)||/\b(hang\s+up|disconnect)\b/i.test(n)||/\b(that'?s all|we'?re done)\b/i.test(n)||e===`bot`&&(/\b(I'?ll|I will|Let me|I can|I'?m going to)\s+(end|close)\s+(the\s+)?(voice\s+)?(session|call)\b/i.test(n)||/\b(ending|closing)\s+(the\s+)?(voice\s+)?session\b|\bvoice\s+session\s+(is\s+)?(now\s+)?(ended|over|closing)\b/i.test(n)||/\b(session|call)\s+(is\s+)?(now\s+)?(ended|over)\b/i.test(n)||/\bwe\s+can\s+end\s+(the\s+)?(session|call)?\s*(here|now)\b/i.test(n)||/\b(wrapping\s+up|signing\s+off)\b/i.test(n))||/^(goodbye|bye|that'?s all|we'?re done|hang up|disconnect)\b/i.test(n)):!1}function pO({orbColors:e,...t}){return(0,N.jsx)(VE,{colors:e,...t})}function mO({copy:e,orbColors:t,primaryColor:n,onYes:r,onLater:i,isMobile:a}){let o=n||sO.green,s=lO(o),c=a?72:94,l=(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:a?`14px`:`18px`},children:[(0,N.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,N.jsx)(dp.p,{initial:{x:-16,opacity:0},animate:{x:0,opacity:1},transition:{type:`spring`,stiffness:260,damping:24,delay:.36},style:{margin:`0 0 14px`,fontSize:a?`16px`:`18px`,fontWeight:700,color:`white`,lineHeight:1.4,textShadow:`0 1px 4px rgba(0,0,0,0.35)`,maxWidth:a?void 0:`210px`},children:e.entryPrompt}),(0,N.jsxs)(dp.div,{initial:{y:10,opacity:0},animate:{y:0,opacity:1},transition:{type:`spring`,stiffness:260,damping:24,delay:.54},style:{display:`flex`,gap:`8px`,flexWrap:`nowrap`},children:[(0,N.jsx)(`button`,{onClick:r,style:{padding:a?`9px 20px`:`10px 28px`,borderRadius:`999px`,background:o,color:s,fontWeight:700,fontSize:a?`14px`:`15px`,border:`none`,cursor:`pointer`,whiteSpace:`nowrap`,boxShadow:`0 4px 16px ${o}66`,transition:`transform 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.04)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`},children:e.yesLabel}),(0,N.jsx)(`button`,{onClick:i,style:{padding:a?`9px 16px`:`10px 22px`,borderRadius:`999px`,background:`transparent`,color:`white`,fontWeight:600,fontSize:a?`14px`:`15px`,border:`2px solid rgba(255,255,255,0.55)`,cursor:`pointer`,whiteSpace:`nowrap`,transition:`border-color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.borderColor=`rgba(255,255,255,0.9)`},onMouseLeave:e=>{e.currentTarget.style.borderColor=`rgba(255,255,255,0.55)`},children:e.laterLabel})]})]}),(0,N.jsx)(dp.div,{initial:{x:120,opacity:0},animate:{x:0,opacity:1},transition:{type:`spring`,stiffness:220,damping:22,delay:0},style:{flexShrink:0},children:(0,N.jsx)(pO,{size:c,orbColors:t})})]});return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(dp.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.4},style:{position:`fixed`,inset:0,background:`rgba(0,0,0,0.72)`,zIndex:-1}}),a?(0,N.jsx)(`div`,{style:{position:`absolute`,bottom:0,left:0,right:0,padding:`24px 20px 40px`,overflow:`hidden`},children:l}):l]})}function hO({copy:e,orbColors:t,primaryColor:n,onVoice:r,onText:i,onClose:a}){let o=n||sO.green,s=lO(o);return(0,N.jsxs)(dp.div,{initial:{scale:50/300,borderRadius:`50%`},animate:{scale:1,borderRadius:`24px`},transition:{type:`spring`,stiffness:260,damping:26},style:{transformOrigin:`bottom right`,background:`white`,padding:`28px 28px 24px`,width:`300px`,display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`20px`,boxShadow:`0 20px 60px rgba(0,0,0,0.2)`,position:`relative`,overflow:`hidden`},children:[(0,N.jsx)(`button`,{onClick:a,style:{position:`absolute`,top:`14px`,right:`14px`,background:`none`,border:`none`,cursor:`pointer`,color:`#9ca3af`,padding:`4px`,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,transition:`color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.color=`#374151`},onMouseLeave:e=>{e.currentTarget.style.color=`#9ca3af`},children:(0,N.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,N.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}),(0,N.jsx)(pO,{size:82,orbColors:t}),(0,N.jsx)(`p`,{style:{margin:0,fontSize:`17px`,fontWeight:600,color:`#111827`,textAlign:`center`,lineHeight:1.4},children:e.connectionTitle}),(0,N.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,width:`100%`},children:[(0,N.jsx)(`button`,{onClick:r,style:{flex:1,padding:`12px`,borderRadius:`999px`,background:o,color:s,fontWeight:700,fontSize:`15px`,border:`none`,cursor:`pointer`,transition:`transform 0.15s ease`,boxShadow:`0 4px 12px ${o}55`},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.03)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`},children:e.voiceLabel}),(0,N.jsx)(`button`,{onClick:i,style:{flex:1,padding:`12px`,borderRadius:`999px`,background:`transparent`,color:`#111827`,fontWeight:600,fontSize:`15px`,border:`2px solid #d1d5db`,cursor:`pointer`,transition:`border-color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.borderColor=`#6b7280`},onMouseLeave:e=>{e.currentTarget.style.borderColor=`#d1d5db`},children:e.textLabel})]})]})}function gO({orbColors:e,onEnterChat:t,onEndChat:n,agentId:r,siteId:i,apiBaseUrl:a,historyRef:o,onMessageSync:s}){let[c,l]=(0,b.useState)(`idle`),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(!1),m=(0,b.useRef)(null),h=(0,b.useRef)(``),g=(0,b.useRef)(async()=>{}),_=(0,b.useRef)(!1),v=(0,b.useRef)(!1),y=(0,b.useRef)(!1),x=(0,b.useRef)(!1),ee=(0,b.useRef)(`minimized`),S=(0,b.useRef)(null),C=(0,b.useCallback)((e=`minimized`)=>{ee.current=e,x.current=!0,queueMicrotask(()=>{_.current||(_.current=!0,g.current?.())})},[o]),te=(0,b.useCallback)(async e=>{x.current=!0;try{await m.current?.endSession?.()}catch{}m.current=null,l(`idle`),d(!1),_.current=!1,typeof s==`function`&&await s(o.current),e?.()},[o,s]);return g.current=()=>te(ee.current===`chat`?t:n),(0,b.useEffect)(()=>{v.current=u},[u]),(0,b.useEffect)(()=>{let e=!1,n=null;return(async()=>{if(!r){l(`error`);return}try{if((await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),e)return;o.current=[],h.current=``,_.current=!1,y.current=!1,x.current=!1,ee.current=`minimized`;let t=oO(aO({siteId:i||null,apiBaseUrl:a||null,getLastUserVoiceText:()=>h.current,requestEndSession:()=>{C()}})),s=await sE.startSession({agentId:r,clientTools:t,onUnhandledClientToolCall:e=>console.error(`[FlowEngage] Unhandled tool:`,e?.tool_name),onModeChange:({mode:t})=>{e||l(t===`speaking`?`speaking`:`listening`)},onMessage:t=>{if(e)return;let n=t.role===`user`?`user`:`bot`,r=t.message||t.text||t.content||``;r&&(n===`user`&&(h.current=r),o.current=[...o.current,{sender:n,message:r,timestamp:new Date().toISOString()}],fO(n,r)&&C(`minimized`))},onError:t=>{if(!e&&!x.current&&!y.current){y.current=!0,console.error(`[FlowEngageVoiceCall] session:error`,{message:t?.message,name:t?.name,raw:t});try{m.current?.setMicMuted?.(!0)}catch{}d(!0),l(`error`),C(`chat`)}},onDisconnect:()=>{if(!e&&!x.current&&!y.current){y.current=!0,console.warn(`[FlowEngageVoiceCall] session:disconnected`,{historyCount:o.current?.length||0,lastUserText:h.current||``,wasMuted:v.current});try{m.current?.setMicMuted?.(!0)}catch{}d(!0),C(`chat`)}}});if(e){s.endSession().catch(()=>{});return}n=s,m.current=s,l(`listening`);try{let e=typeof window<`u`?window.location.href:``,n=`[]`;try{n=await t.list_page_forms()}catch{}s.sendContextualUpdate(`Page: ${e}. SiteId: ${i||`unknown`}. Forms: ${n}. Voice: call end_voice_session or say you are ending the session to stop.`)}catch{}}catch(n){e||(console.error(`[FlowEngage] startSession failed`,n),l(`error`),ee.current=`chat`,window.setTimeout(()=>{e||t?.()},0))}})(),()=>{e=!0,x.current=!0,(n||m.current)?.endSession?.().catch(()=>{})}},[r,i,a,C]),(0,b.useEffect)(()=>{if(!f)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;S.current&&!S.current.contains(t)&&p(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[f]),(0,N.jsx)(N.Fragment,{children:(0,N.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`14px`,animation:`fe-orb-slide-up 0.42s cubic-bezier(0.16,1,0.3,1)`},children:[(0,N.jsxs)(`div`,{style:{position:`relative`},children:[c===`listening`&&(0,N.jsx)(`span`,{style:{position:`absolute`,right:`100%`,marginRight:`18px`,top:`50%`,transform:`translateY(-50%)`,color:`white`,fontSize:`18px`,fontWeight:600,letterSpacing:`0.01em`,textShadow:`0 2px 4px rgba(0,0,0,0.4)`,whiteSpace:`nowrap`},children:`Listening...`}),(0,N.jsx)(pO,{size:94,voiceState:c,isMuted:u,orbColors:e})]}),c===`error`&&(0,N.jsx)(`span`,{style:{color:`#f87171`,fontSize:`13px`,fontWeight:500},children:`Could not start voice session.`}),(0,N.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,alignItems:`center`},children:[(0,N.jsx)(`button`,{onClick:async()=>{if(m.current)try{u?(await m.current.setMicMuted?.(!1),d(!1)):(await m.current.setMicMuted?.(!0),d(!0))}catch{}},title:u?`Unmute`:`Mute`,style:{width:`44px`,height:`44px`,borderRadius:`50%`,background:u?`#7f1d1d`:`#1f2937`,border:u?`1.5px solid #ef4444`:`1.5px solid #4b5563`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:u?`#f87171`:`white`,transition:`all 0.2s ease`,boxShadow:`0 2px 8px rgba(0,0,0,0.4)`},children:u?(0,N.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`line`,{x1:`1`,y1:`1`,x2:`23`,y2:`23`}),(0,N.jsx)(`path`,{d:`M9 9v3a3 3 0 005.12 2.12M15 9.34V4a3 3 0 00-5.94-.6`}),(0,N.jsx)(`path`,{d:`M17 16.95A7 7 0 015 12v-2m14 0v2a7 7 0 01-.11 1.23`}),(0,N.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`23`}),(0,N.jsx)(`line`,{x1:`8`,y1:`23`,x2:`16`,y2:`23`})]}):(0,N.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`,fill:`currentColor`,stroke:`none`}),(0,N.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`})]})}),(0,N.jsxs)(`div`,{style:{position:`relative`,isolation:`isolate`,zIndex:10},ref:S,children:[(0,N.jsx)(`button`,{onClick:()=>p(e=>!e),style:{width:`44px`,height:`44px`,borderRadius:`50%`,background:`#1f2937`,border:`1.5px solid #4b5563`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:`white`,transition:`background 0.2s ease`,boxShadow:`0 2px 8px rgba(0,0,0,0.4)`},children:(0,N.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`currentColor`,children:[(0,N.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.8`}),(0,N.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.8`}),(0,N.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.8`})]})}),f&&(0,N.jsxs)(`div`,{style:{position:`absolute`,bottom:`54px`,right:0,zIndex:9999,background:`rgba(15,22,36,0.96)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,overflow:`hidden`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,minWidth:`210px`,border:`1px solid rgba(255,255,255,0.07)`,animation:`fe-orb-fade-in 0.18s ease`},children:[(0,N.jsxs)(`button`,{onClick:()=>{p(!1),ee.current=`chat`,te(t)},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,N.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,N.jsx)(`path`,{d:`M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z`})}),`Enter Chat Mode`]}),(0,N.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,N.jsxs)(`button`,{onClick:()=>{p(!1),ee.current=`minimized`,te(n)},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`#f87171`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(248,113,113,0.1)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,N.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M10.68 13.31a16 16 0 003.41 2.6l1.27-1.27a2 2 0 012.11-.45 12.84 12.84 0 002.81.7 2 2 0 011.72 2v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.42 19.42 0 013.07 8.62 19.79 19.79 0 01.1 2 2 2 0 012.11 0h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L6.18 7.84`}),(0,N.jsx)(`line`,{x1:`23`,y1:`1`,x2:`1`,y2:`23`})]}),`End Conversation`]})]})]})]})]})})}function _O({orbColors:e}){return(0,N.jsx)(`div`,{style:{flexShrink:0,width:`36px`,height:`36px`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,N.jsx)(pO,{size:36,orbColors:e})})}var vO=()=>(0,N.jsx)(`div`,{style:{display:`flex`,marginBottom:`12px`,justifyContent:`flex-start`},children:(0,N.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`12px 16px`,borderRadius:`18px`,background:`#fff`,boxShadow:`0 2px 6px rgba(0,0,0,0.04)`},children:[0,1,2].map(e=>(0,N.jsx)(`span`,{style:{width:`7px`,height:`7px`,borderRadius:`50%`,background:`#9ca3af`,animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`}},e))})});function yO({copy:e,orbColors:t,primaryColor:n,chatBgGradient:r,logo:i,quickChatOptions:a,onQuickChatSelect:o,isMobile:s,chatHistory:c,isAiTyping:l,isAgentTyping:u,activeScreen:d,agentName:f,agentHeadshot:p,fallbackAgentName:m,input:h,setInput:g,onSubmit:_,isConversationEnded:v,isLoading:y,isRateLimited:x,rateLimitMessage:ee,selectedFile:S,onFileSelect:C,onRemoveSelectedFile:te,attachmentError:ne,isUploadingAttachment:re,requiresEmail:ie,emailInput:ae,setEmailInput:oe,emailError:se,replyContext:ce,setReplyContext:le,webRTCError:ue,micError:de,setMicError:w,dismissCallError:T,incomingCall:fe,rejectCall:pe,acceptCall:me,activeCallId:he,callConnectionState:E,isCallMuted:D,toggleCallMute:ge,endWebRTCCall:_e,formatCallDuration:ve,callDurationSeconds:ye,onCollapse:be,onStartVoice:xe,showPoweredBy:Se}){let Ce=c.length>0,we=y||x||v,Te=!!(fe||he),[Ee,De]=(0,b.useState)(!1),Oe=(0,b.useRef)(null);return(0,b.useEffect)(()=>{if(!Ee)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;Oe.current&&!Oe.current.contains(t)&&De(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Ee]),(0,N.jsxs)(`div`,{style:s?{"--flowengage-primary":n,"--flowengage-accent":n,position:`fixed`,inset:0,width:`100%`,height:`100dvh`,background:r,borderRadius:0,display:`flex`,flexDirection:`column`,overflow:`hidden`,animation:`fe-orb-slide-up 0.28s cubic-bezier(0.16,1,0.3,1)`}:{"--flowengage-primary":n,"--flowengage-accent":n,width:`min(390px, calc(100vw - 40px))`,height:`min(640px, calc(100vh - 120px))`,background:r,borderRadius:`22px`,boxShadow:`0 24px 64px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08)`,display:`flex`,flexDirection:`column`,overflow:`hidden`,position:`relative`,animation:`fe-orb-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)`},children:[(0,N.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`40px minmax(0, 1fr) 40px`,alignItems:`center`,columnGap:`14px`,padding:`16px 18px 14px`,background:`transparent`,flexShrink:0},children:[(0,N.jsx)(`button`,{onClick:be,style:{width:`40px`,height:`40px`,background:`none`,border:`none`,cursor:`pointer`,color:`#6b7280`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`4px`,borderRadius:`10px`,transition:`color 0.15s ease`,flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.color=`#111827`},onMouseLeave:e=>{e.currentTarget.style.color=`#6b7280`},children:(0,N.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,N.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}),(0,N.jsxs)(`div`,{style:{minWidth:0,maxWidth:s?`100%`:`250px`,width:`100%`,justifySelf:`center`,display:`grid`,gridTemplateColumns:`minmax(72px, 40%) minmax(0, 60%)`,alignItems:`center`},children:[(0,N.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:`center`,height:`40px`},children:i?(0,N.jsx)(uO,{logo:i,style:{height:`34px`,width:`100%`,maxWidth:`96px`}}):(0,N.jsx)(`div`,{style:{width:`40px`,height:`40px`,flexShrink:0},children:(0,N.jsx)(dO,{title:e.chatTitle})})}),(0,N.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`},children:(0,N.jsx)(`span`,{style:{fontSize:`15px`,fontWeight:600,color:`#111827`,letterSpacing:`-0.01em`,lineHeight:1.2,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:e.chatTitle,children:e.chatTitle})})]}),(0,N.jsxs)(`div`,{style:{position:`relative`,isolation:`isolate`,zIndex:10},ref:Oe,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>De(e=>!e),style:{width:`40px`,height:`40px`,background:`none`,border:`none`,cursor:`pointer`,color:`#6b7280`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`4px`,borderRadius:`10px`,transition:`color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.color=`#111827`},onMouseLeave:e=>{e.currentTarget.style.color=`#6b7280`},"aria-label":`Chat options`,children:(0,N.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,N.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`}),(0,N.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`}),(0,N.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.5`})]})}),Ee&&(0,N.jsxs)(`div`,{style:{position:`absolute`,top:`34px`,right:0,background:`rgba(15,22,36,0.96)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,overflow:`hidden`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,minWidth:`210px`,border:`1px solid rgba(255,255,255,0.07)`,animation:`fe-orb-fade-in 0.18s ease`},children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>{De(!1),xe?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,N.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`}),(0,N.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`})]}),`Enter Voice Mode`]}),(0,N.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>{De(!1),be?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`#f87171`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(248,113,113,0.1)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,N.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M10.68 13.31a16 16 0 003.41 2.6l1.27-1.27a2 2 0 012.11-.45 12.84 12.84 0 002.81.7 2 2 0 011.72 2v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.42 19.42 0 013.07 8.62 19.79 19.79 0 01.1 2 2 2 0 012.11 0h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L6.18 7.84`}),(0,N.jsx)(`line`,{x1:`23`,y1:`1`,x2:`1`,y2:`23`})]}),`Close Conversation`]})]})]})]}),(0,N.jsx)(ME,{webRTCError:ue,micError:de,setMicError:w,dismissCallError:T,incomingCall:fe,rejectCall:pe,acceptCall:me,activeCallId:he,callConnectionState:E,formatCallDuration:ve,callDurationSeconds:ye,endWebRTCCall:_e,isCallMuted:D,toggleCallMute:ge,isAIVoiceActive:!1,currentCallAgentName:f||m,isRateLimited:x,rateLimitMessage:ee}),(0,N.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,background:`transparent`},children:Ce?(0,N.jsx)(OE,{chatHistory:c,isAiTyping:l,isAgentTyping:u,setReplyContext:le,TypingDots:vO,primaryColor:n,agentHeadshot:p,agentDisplayName:f||m,botAvatarNode:(0,N.jsx)(_O,{orbColors:t})}):(0,N.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`22px`,padding:`28px 24px`},children:[(0,N.jsx)(pO,{size:94,orbColors:t}),(0,N.jsx)(`p`,{style:{margin:0,textAlign:`center`,fontSize:`16px`,color:`#374151`,lineHeight:1.55,maxWidth:`270px`},children:e.introGreeting}),a.length>0&&(0,N.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`8px`,justifyContent:`center`,width:`100%`,padding:`0 8px`},children:a.map(e=>(0,N.jsx)(`button`,{onClick:()=>o?.(e),style:{padding:`8px 16px`,borderRadius:`999px`,background:`white`,border:`1.5px solid ${n}33`,color:n||`#374151`,fontSize:`13px`,fontWeight:500,cursor:`pointer`,transition:`all 0.15s ease`,boxShadow:`0 1px 4px rgba(0,0,0,0.06)`},onMouseEnter:e=>{e.currentTarget.style.background=`${n}12`,e.currentTarget.style.borderColor=n},onMouseLeave:e=>{e.currentTarget.style.background=`white`,e.currentTarget.style.borderColor=`${n}33`},children:e.label||e.text},e.id))})]})}),(0,N.jsx)(`div`,{style:{background:`transparent`,flexShrink:0,position:`relative`,zIndex:1,padding:ie?`6px 0 0`:`12px 0 0`},children:(0,N.jsx)(kE,{input:h,setInput:g,onSubmit:_,isConversationEnded:v,callUiActive:Te,handleToggleVoice:xe,showVoiceToggle:d===`agent`,activeScreen:d,inputDisabled:we,replyContext:ce,clearReplyContext:()=>le(null),onFileSelect:C,selectedFile:S,onRemoveSelectedFile:te,attachmentError:ne,isUploadingAttachment:re,requiresEmail:ie,emailInput:ae,setEmailInput:oe,emailError:se,inputPlaceholder:e.inputPlaceholder})}),(0,N.jsx)(`div`,{style:{flexShrink:0,textAlign:`center`,padding:`12px 20px 18px`,pointerEvents:`none`},children:Se&&(0,N.jsxs)(`span`,{style:{fontSize:`11px`,color:`#9ca3af`,letterSpacing:`0.01em`,userSelect:`none`},children:[`Powered by `,(0,N.jsx)(`strong`,{style:{fontWeight:600,color:`#6b7280`},children:`FlowEngage`})]})})]})}function bO(){let{status:e,runtimeConfig:t,resolvedConfig:n,chatHistory:r,isOpen:i,activeScreen:a,isHumanHandled:o,agentName:s,agentHeadshot:c,visitorEmail:l,isAgentTyping:u,isAiTyping:d,isLoading:f,isRateLimited:p,rateLimitMessage:m,isConversationEnded:h,incomingCall:g,activeCallId:_,callConnectionState:v,callConnectedAt:y,isCallMuted:x,webRTCError:ee,language:S,historyRef:C,onMessageSync:te,sendMessage:ne,uploadChatFile:re,openWidget:ie,captureVisitorEmail:ae,setVoiceMode:oe,endConversation:se,acceptCall:ce,rejectCall:le,endWebRTCCall:ue,toggleCallMute:de,dismissCallError:w,startTyping:T,stopTyping:fe,updateTypingDraft:pe}=cn();(0,b.useEffect)(()=>{try{mn()}catch{}},[]);let me=t?.widgetSettings||{},he=n?.widgetSettings||{},E={...me.branding||{},...he.branding||{}},D={...me.theme||{},...he.theme||{}},ge=Array.isArray(D.orbColors)&&D.orbColors.length>0?D.orbColors:null,_e=ge?.[0]||D.primaryColor||`#3B82F6`,ve=D.position||`bottom-right`,ye=E.fallbackAgentName||`Agent`,be=cO(ge??D.chatBgColors),xe=E.logo||E.logoUrl||null,Se=S||`en`,Ce=me.recommendations?.[Se]||[],we=(he.recommendations?.[Se]??Ce).filter(e=>String(e?.label??``).trim()).map((e,t)=>({id:e.key||`qr-${t}`,label:e.label,message:e.label,text:e.label})),Te=Array.isArray(E.quickChatOptions)&&E.quickChatOptions.length>0?E.quickChatOptions:we,Ee=E.hideWatermark===!0?!1:E.showPoweredBy!==!1,De=E.chatbotEnabled!==!1&&D.chatbotEnabled!==!1,Oe=me.greetings?.[S]||he.greetings?.[S]||E.introGreeting||`Hello, I'm here to help you know more about OpenSense Labs.`,ke={entryPrompt:E.entryPrompt||`Do you want to explore in a new way?`,yesLabel:E.yesLabel||`Yes`,laterLabel:E.laterLabel||`Later`,connectionTitle:E.connectionTitle||`How would you like to connect?`,voiceLabel:E.voiceLabel||`Voice`,textLabel:E.textLabel||`Text`,chatTitle:E.headerName||`Chat with FlowEngage`,introGreeting:Oe,inputPlaceholder:E.inputPlaceholder||`Type your message`,analysingLabel:E.analysingLabel||`analysing...`},Ae=he.elevenLabsAgentId||t?.elevenLabsAgentId||null,je=t?.siteId||n?.siteId||null,O=t?.apiBaseUrl||``,Me=(0,b.useMemo)(()=>s&&String(s).trim()||t?.ownerName&&String(t.ownerName).trim()||t?.websiteName&&String(t.websiteName).trim()||`Agent`,[s,t?.ownerName,t?.websiteName]),Ne=c&&String(c).trim()||t?.ownerProfileImageUrl&&String(t.ownerProfileImageUrl).trim()||null,Pe=r.some(e=>e.sender===`user`),Fe=(0,b.useMemo)(()=>{let e=r.findIndex(e=>e.sender===`user`);return e===-1?!1:r.slice(e+1).some(e=>e.sender===`bot`||e.sender===`ai`||e.sender===`agent`)},[r]),Ie=!l&&Pe&&Fe,Le=!!(he._dashboardLivePreview||me._dashboardLivePreview),[Re,ze]=(0,b.useState)(()=>Le?`text_chat`:`entry_prompt`),[Be,Ve]=(0,b.useState)(``),[He,Ue]=(0,b.useState)(null),[k,A]=(0,b.useState)(l||``),[We,j]=(0,b.useState)(``),[Ge,Ke]=(0,b.useState)(0),[qe,Je]=(0,b.useState)(null),[Ye,Xe]=(0,b.useState)(null),[Ze,Qe]=(0,b.useState)(``),[$e,et]=(0,b.useState)(!1),tt=(0,b.useRef)(null),nt=(0,b.useRef)(!1);(0,b.useLayoutEffect)(()=>{e!==`ready`||nt.current||(nt.current=!0,r.length>0&&ze(`minimized_orb`))},[e,r]);let[rt,it]=(0,b.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: 640px)`).matches);(0,b.useEffect)(()=>{let e=window.matchMedia(`(max-width: 640px)`),t=e=>it(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,b.useEffect)(()=>{A(l||``),l&&j(``)},[l]);let at=(0,b.useCallback)(()=>{Xe(null),Qe(``)},[]),ot=(0,b.useCallback)(e=>{let t=CE(e);if(t){Xe(null),Qe(t);return}Xe(e),Qe(``)},[]);(0,b.useEffect)(()=>{if(!y||v!==`connected`){Ke(0);return}let e=()=>{let e=new Date(y).getTime();isNaN(e)||Ke(Math.max(0,Math.floor((Date.now()-e)/1e3)))};e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[y,v]),(0,b.useEffect)(()=>{let e=g?.callId||_||null;if(!e){tt.current=null;return}(g?.callId||v===`connecting`||v===`connected`)&&(!(!i||Re===`minimized_orb`||Re===`voice_mode`)&&tt.current===e||(console.log(`[FlowEngageWidget] forcing call UI to front`,{forcedKey:e,isOpen:i,surface:Re,hasIncomingCall:!!g?.callId,activeCallId:_,callConnectionState:v}),tt.current=e,Re===`voice_mode`&&oe?.(!1),ie?.(),ze(`text_chat`)))},[_,v,g?.callId,i,ie,oe,Re]),(0,b.useEffect)(()=>{if(!o||h){pe?.(``),fe?.();return}if(!Be.trim()||Ye){pe?.(``),fe?.();return}T?.();let e=window.setTimeout(()=>pe?.(Be),120),t=window.setTimeout(()=>fe?.(),1200);return()=>{window.clearTimeout(e),window.clearTimeout(t)}},[Be,Ye,o,h,T,fe,pe]);let st=e=>e?{replyTo:e.messageId||e.id||null,replyToContent:(e.replyToContent||e.message||``).replace(/<[^>]+>/g,``).trim().slice(0,200),replyToSender:e.sender||null}:null,ct=async e=>{if(e.preventDefault(),h)return;if(Ie){let e=k.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){j(`Please enter a valid email so we can continue helping you.`);return}await ae(e),j(``);return}let t=st(He);if(!Be.trim()&&!Ye)return;if(Ye){try{et(!0),Qe(``);let e=await re(Ye),n=e?.data||e,r=Be.trim()||`Shared file: ${TE(Ye)}`;Ve(``),Ue(null),at(),await ne(r,``,t,{type:`file`,metadata:{fileUrl:n?.fileUrl,fileName:n?.fileName||Ye.name,fileType:n?.fileType||Ye.type,fileSize:n?.fileSize||Ye.size}})}catch(e){Qe(e?.message||`Failed to upload the selected file.`)}finally{et(!1)}return}let n=Be.trim();Ve(``),Ue(null),await ne(n,``,t)},lt=e=>{let t=Math.floor(e/60);return`${String(t).padStart(2,`0`)}:${String(e%60).padStart(2,`0`)}`},ut=(0,b.useCallback)(async e=>{if(h||f)return;let t=e.message||e.label||e.text||``;t.trim()&&await ne(t.trim(),``)},[h,f,ne]),dt=rt&&(Re===`text_chat`||Re===`entry_prompt`)?{inset:0}:ve===`bottom-left`?{left:`1.5rem`,bottom:`1.5rem`}:{right:`1.5rem`,bottom:`1.5rem`},ft=()=>ze(`minimized_orb`),pt=()=>ze(`connection_modal`),mt=()=>{ie({notifyChatInitiated:!0}),oe?.(!0),ze(`voice_mode`)},ht=()=>{ie({notifyChatInitiated:!0}),oe?.(!1),ze(`text_chat`)},gt=()=>{oe?.(!1),ft()};return e!==`ready`||!De?null:(0,N.jsxs)(`div`,{className:`flowengage-widget-root`,style:{position:`fixed`,zIndex:999999,...dt},children:[Re===`entry_prompt`&&(0,N.jsx)(mO,{copy:ke,orbColors:ge,primaryColor:_e,onYes:mt,onLater:ft,isMobile:rt}),Re===`minimized_orb`&&(0,N.jsx)(dp.div,{layoutId:`fe-main-orb`,initial:{scale:94/50},animate:{scale:1},transition:{type:`spring`,stiffness:220,damping:26},style:{transformOrigin:`bottom right`,display:`inline-block`},children:(0,N.jsx)(pO,{size:50,orbColors:ge,onClick:pt})}),Re===`connection_modal`&&(0,N.jsx)(hO,{copy:ke,orbColors:ge,primaryColor:_e,onVoice:mt,onText:ht,onClose:ft}),Re===`voice_mode`&&(0,N.jsx)(gO,{orbColors:ge,onEnterChat:ht,onEndChat:gt,agentId:Ae,siteId:je,apiBaseUrl:O,historyRef:C,onMessageSync:te},`voice`),Re===`text_chat`&&(0,N.jsx)(yO,{copy:ke,orbColors:ge,primaryColor:_e,chatBgGradient:be,logo:xe,quickChatOptions:Te,onQuickChatSelect:ut,isMobile:rt,chatHistory:r,isAiTyping:d,isAgentTyping:u,activeScreen:a,agentName:Me,agentHeadshot:Ne,fallbackAgentName:ye,input:Be,setInput:Ve,onSubmit:ct,isConversationEnded:h,isLoading:f,isRateLimited:p,rateLimitMessage:m,selectedFile:Ye,onFileSelect:ot,onRemoveSelectedFile:at,attachmentError:Ze,isUploadingAttachment:$e,requiresEmail:Ie,emailInput:k,setEmailInput:A,emailError:We,replyContext:He,setReplyContext:Ue,webRTCError:ee,micError:qe,setMicError:Je,dismissCallError:w,incomingCall:g,rejectCall:le,acceptCall:ce,activeCallId:_,callConnectionState:v,isCallMuted:x,toggleCallMute:de,endWebRTCCall:ue,formatCallDuration:lt,callDurationSeconds:Ge,onCollapse:ft,onStartVoice:mt,onEndConversation:se,showPoweredBy:Ee}),(0,N.jsx)(`style`,{children:`
612
+ </svg>`,ED=null,DD=!1;function OD(){return(!ED||!ED.isConnected)&&(ED=document.createElement(`div`),ED.id=`${Q}-cursor`,ED.innerHTML=TD,document.body.appendChild(ED),DD=!1),ED}async function kD(e){if(typeof document>`u`||!e)return;dD();let t;try{t=e.getBoundingClientRect()}catch{return}let n=t.left+Math.min(16,t.width*.2),r=t.top+Math.min(12,t.height*.25),i=OD();DD||=(i.style.transition=`none`,i.style.left=`${window.innerWidth/2}px`,i.style.top=`${window.innerHeight*.4}px`,i.classList.add(`${Q}-cursor-visible`),i.offsetHeight,i.style.transition=`left 0.32s cubic-bezier(0.25,0.46,0.45,0.94), top 0.32s cubic-bezier(0.25,0.46,0.45,0.94), opacity 0.2s ease`,!0),i.style.left=`${n}px`,i.style.top=`${r}px`,await ND(360)}function AD(e=!1){ED&&(e?(ED.classList.remove(`${Q}-cursor-visible`),DD=!1):(ED.classList.remove(`${Q}-cursor-visible`),setTimeout(()=>{DD=!1},250)))}async function jD(e){ED&&(ED.classList.add(`${Q}-cursor-click`),await ND(280),ED.classList.remove(`${Q}-cursor-click`))}function MD(e){if(!e||typeof document>`u`)return;dD();let t;try{t=e.getBoundingClientRect()}catch{return}let n=e.style.position,r=e.style.overflow,i=window.getComputedStyle(e).position;[`relative`,`absolute`,`fixed`,`sticky`].includes(i)||(e.style.position=`relative`),e.style.overflow=`hidden`;let a=document.createElement(`span`);a.className=`${Q}-ripple`;let o=Math.max(t.width,t.height)*1.2;Object.assign(a.style,{width:`${o}px`,height:`${o}px`,left:`${t.width/2-o/2}px`,top:`${t.height/2-o/2}px`}),e.appendChild(a),setTimeout(()=>{a.remove(),e.style.position=n,e.style.overflow=r},650)}function ND(e){return new Promise(t=>setTimeout(t,e))}function $(...e){ln()&&console.log(`[FlowEngage:voice-tools]`,...e)}function PD(e){return new Promise(t=>setTimeout(t,e))}var FD=`#flowengage-root, .flowengage-shell, .flowengage-widget-root`;function ID(e){if(!e||typeof e.closest!=`function`)return!1;try{return!!e.closest(FD)}catch{return!1}}function LD(e){try{let t=e.ownerDocument?.defaultView;if(t)return t.getComputedStyle(e)}catch{}return window.getComputedStyle(e)}function RD(e){let t=new Set;function n(r){if(!r||t.has(r))return;t.add(r),e(r);let i=r.querySelectorAll(`iframe`);for(let e of i)if(!ID(e))try{let t=e.contentDocument;t&&n(t)}catch{}}typeof document<`u`&&n(document)}function zD(e){return e==null?null:String(e).replace(/\u00a0/g,` `).replace(/\s*\*+\s*$/u,``).replace(/\s+/g,` `).trim()}function BD(e){let t=e.ownerDocument||document,n=e.getAttribute(`aria-labelledby`);if(n){let e=n.trim().split(/\s+/).filter(Boolean),r=[];for(let n of e)try{let e=t.getElementById(n);e?.textContent&&r.push(e.textContent.trim())}catch{}if(r.length)return zD(r.join(` `))}if(e.labels&&e.labels.length)return zD(e.labels[0].textContent);let r=e.id;if(r)try{let e=t.querySelector(`label[for="${CSS.escape(r)}"]`);if(e)return zD(e.textContent)}catch{let e=t.querySelector(`label[for="${r.replace(/"/g,`\\"`)}"]`);if(e)return zD(e.textContent)}let i=e.previousElementSibling;for(let e=0;e<6&&i;e+=1){if(i.tagName===`LABEL`)return zD(i.textContent);let e=(i.className||``).toString().toLowerCase();if(/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)){let e=zD(i.textContent);if(e)return e}i=i.previousElementSibling}let a=e.parentElement;for(let e=0;e<5&&a;e+=1){if(a.tagName===`LABEL`)return zD(a.textContent);let e=a.querySelector?.(`:scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']`);if(e?.textContent)return zD(e.textContent);a=a.parentElement}let o=e.getAttribute(`aria-label`);return o?zD(o):null}function VD(){let e=[];return RD(t=>{e.push(...Array.from(t.querySelectorAll(`input, select, textarea`)).filter(e=>{if(ID(e))return!1;let t=(e.type||``).toLowerCase();if([`hidden`,`submit`,`button`,`image`].includes(t)||e.disabled||e.readOnly)return!1;try{let t=LD(e);if(t.display===`none`||t.visibility===`hidden`)return!1}catch{}return!0}))}),e}function HD(){return VD().map((e,t)=>({formIndex:0,fieldIndex:t,tag:e.tagName,type:e.type||`text`,name:e.name||null,id:e.id||null,label:BD(e),placeholder:e.placeholder||null}))}function UD(){let e=[];return RD(t=>{e.push(...Array.from(t.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"]`)).filter(e=>{if(ID(e)||e.disabled)return!1;try{let t=LD(e);if(t.display===`none`||t.visibility===`hidden`)return!1}catch{}return!0}))}),e.slice(0,60).map((e,t)=>({index:t,text:(e.textContent||e.value||``).replace(/\s+/g,` `).trim().slice(0,120)||null,ariaLabel:e.getAttribute(`aria-label`),type:e.type||e.tagName}))}function WD(e){return String(e||``).toLowerCase().replace(/\u00a0/g,` `).replace(/\*/g,``).replace(/\s+/g,` `).trim()}function GD(e){let t=WD(e);return t=t.replace(/\s+field\s*$/i,``).trim(),t}function KD(e,t){let n=GD(t);if(!n)return 0;let r=(e.name||``).toLowerCase(),i=(e.id||``).toLowerCase();if(r===`url`&&/url|website|domain|site|audit/.test(n)||(i===`url-input`||i.endsWith(`-url-input`))&&/url|website|domain|site|audit/.test(n))return 100;let a=[e.name,e.id,e.placeholder,BD(e),e.getAttribute(`aria-label`),e.getAttribute(`title`),e.getAttribute(`data-testid`),e.getAttribute(`autocomplete`)].filter(Boolean).map(e=>WD(e)),o=0;for(let e of a){if(!e)continue;if(e.includes(n)||n.includes(e)){o=Math.max(o,100);continue}let t=n.split(/\s+/).filter(e=>e.length>1);if(!t.length)continue;let r=0;for(let n of t)e.includes(n)&&(r+=1);o=Math.max(o,r/t.length*88)}return o}var qD=28;function JD(e,t){let n=null,r=0;for(let i of e){let e=KD(i,t);e>r&&(r=e,n=i)}return!n||r<qD?null:n}function YD(e,t,n){let r=String(t||``).toLowerCase().trim(),i=String(n||``).trim();if(!(/^https?:\/\//i.test(i)||/\.\w{2,}(\/|\s|$)/.test(i)||r.includes(`url`)||r.includes(`website`)||r.includes(`domain`)||r.includes(`site`)))return null;let a=null,o=0;for(let t of e){if(t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`)continue;let e=(t.type||``).toLowerCase();if([`hidden`,`submit`,`button`,`checkbox`,`radio`].includes(e))continue;let n=0;(e===`url`||e===`text`||e===`search`)&&(n+=45);let r=[t.name,t.id,t.placeholder,BD(t),t.getAttribute(`aria-label`),t.getAttribute(`autocomplete`)].filter(Boolean).join(` `).toLowerCase();/(website|url|domain|site\s*url)/.test(r)&&(n+=55),n>o&&(o=n,a=t)}return!a||o<42?null:a}function XD(e){let t=String(e??``).trim();return t?/^https?:\/\//i.test(t)?!0:/\.\w{2,}(\/|\s|$)/.test(t):!1}function ZD(e){let t=String(e??``).toLowerCase().trim();return t?!!(t===`url`||t===`website`||t===`website url`||t===`website_url`||t===`enter website url`||t.includes(`website`)||t.includes(`domain`)||/(enter\s+website|site\s*url|page\s*url)/.test(t)):!1}function QD(e){if(!e||e.tagName!==`INPUT`&&e.tagName!==`TEXTAREA`)return!1;let t=(e.type||``).toLowerCase();return![`hidden`,`submit`,`button`,`checkbox`,`radio`,`file`].includes(t)}function $D(e){if(!QD(e))return!1;let t=(e.name||``).toLowerCase(),n=(e.id||``).toLowerCase(),r=[e.name,e.id,e.placeholder,BD(e),e.getAttribute(`aria-label`)].filter(Boolean).join(` `).toLowerCase();return t===`url`||n===`url-input`||n.endsWith(`-url-input`)||/(website\s*url|enter\s+website|site\s*url)/.test(r)||/(website|domain)/.test(r)&&/(url|site)/.test(r)}function eO(e,t,n){let r=String(t??``),i=String(n??``),a=rO(e,r)||JD(e,r)||YD(e,r,i);if(!a)return[];let o=new Set([a]);if(XD(i)&&ZD(r))for(let t of e)t!==a&&$D(t)&&o.add(t);let s=Array.from(o);return s.sort((e,t)=>{if(e===t)return 0;let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0}),s}function tO(e,t){try{if(!e?.getBoundingClientRect||!t?.getBoundingClientRect)return 1/0;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i={x:n.left+n.width/2,y:n.top+n.height/2},a={x:r.left+r.width/2,y:r.top+r.height/2};return Math.hypot(i.x-a.x,i.y-a.y)}catch{return 1/0}}function nO(e){if(!e||typeof e!=`string`)return null;let t=null;return RD(n=>{try{let r=n.getElementById(e);r&&!ID(r)&&r.matches?.(`input, select, textarea`)&&(t=r)}catch{}}),t}function rO(e,t){let n=String(t??``).trim();if(!n)return null;let r=n.match(/^name:\s*([\w.-]+)$/i);if(r){let t=r[1];for(let n of e)if(n.name===t)return n}let i=n.match(/^id:\s*([\w.-]+)$/i);if(i){let e=nO(i[1]);if(e)return e}let a=n.startsWith(`#`)?n.slice(1):n;if(/^[\w-]+$/.test(a)){let e=nO(a);if(e)return e}let o=n.toLowerCase().replace(/\s+/g,` `);if(o===`url`||o===`website`||o===`website url`||o===`website_url`||o===`enter website url`)for(let t of e){let e=(t.name||``).toLowerCase(),n=(t.id||``).toLowerCase();if(e===`url`||n===`url-input`||n.endsWith(`-url-input`))return t}return null}function iO(e,t){let n=String(t||``).toLowerCase().trim();if(!n)return 0;let r=[e.textContent,e.value,e.getAttribute(`aria-label`),e.getAttribute(`title`)].filter(Boolean).join(` `).toLowerCase().replace(/\s+/g,` `);if(r.includes(n))return 100;let i=n.split(/\s+/).filter(e=>e.length>1);if(!i.length)return 0;let a=0;for(let e of i)r.includes(e)&&(a+=1);return a/i.length*92}function aO(e,t){let n=[];RD(e=>{n.push(...Array.from(e.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"]`)).filter(e=>{if(ID(e)||e.disabled)return!1;try{let t=LD(e);if(t.display===`none`||t.visibility===`hidden`)return!1}catch{}return!0}))});let r=0,i=n.map(t=>({el:t,s:iO(t,e)}));for(let{s:e}of i)e>r&&(r=e);if(r<36)return null;let a=i.filter(({s:e})=>e===r).map(({el:e})=>e);if(a.length===1)return a[0];let o=Array.isArray(t)?t.filter(e=>e&&e.isConnected):[];if(o.length){let e=a[0],t=1/0;for(let n of a)for(let r of o){let i=tO(n,r);i<t&&(t=i,e=n)}return e}return a[0]}function oO(e){if(e==null)return{};if(typeof e==`string`){let t=e.trim();if(!t)return{};try{return JSON.parse(t)}catch{return{url:t}}}return e}function sO(e){let t=oO(e);if(Array.isArray(t)&&t.length>0){let e=t[0];if(e?.field_key!=null||e?.fieldKey!=null)return t.map(e=>({field_key:e.field_key??e.fieldKey,value:e.value}))}if(!t||typeof t!=`object`)return[];let n=t.fields??t.Fields??t.field_list??t.fieldList??t.data?.fields;if(typeof n==`string`)try{n=JSON.parse(n)}catch{n=null}n&&!Array.isArray(n)&&typeof n==`object`&&(n=Object.values(n)),(!n||n.length===0)&&(t.field_key!=null||t.fieldKey!=null)&&t.value!=null&&(n=[{field_key:t.field_key??t.fieldKey,value:t.value}]);let r=t.website_url??t.websiteUrl??t.url??t.website??t.domain??t.site_url??t.siteUrl;return(!n||n.length===0)&&r!=null&&String(r).trim()&&(n=[{field_key:t.field_key??t.fieldKey??`url`,value:String(r).trim()}]),Array.isArray(n)?n.map(e=>({field_key:e?.field_key??e?.fieldKey,value:e?.value??e?.Value})):[]}function cO(e){if(!e||typeof e!=`string`)return[];let t=e.trim();if(!t||/\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t))return[];let n=t.match(/https?:\/\/[^\s<>"']+/i);if(n)return[{field_key:`url`,value:n[0].replace(/[.,;:)]+$/,``)}];let r=t.match(/\b(?:[\w-]+\.)+[a-z]{2,}\b/i);if(r){let e=r[0].replace(/[.,;:)]+$/,``);return/^https?:/i.test(e)||(e=`https://${e}`),[{field_key:`url`,value:e}]}return[]}function lO(e){if(!e||typeof e!=`string`)return[];let t=e.trim();if(!t)return[];let n=[],r=new Set,i=/\b([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\b/i,a=(e,t)=>{let i=String(t??``).trim().replace(/^["']|["']$/g,``);if(!i||i.length>800)return;let a=`${e}\0${i}`;r.has(a)||(r.add(a),n.push({field_key:e,value:i}))},o=t.match(/^\s*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\s*$/i);if(o)return a(`Email Address`,o[1]),n;let s=t.match(/\b(?:please\s+)?(?:enter|type|put)\s+(.+?)\s+in(?:to)?\s+(?:the\s+)?(?:full\s*name|full\s*name\s*field|name\s*field)\b/i);if(s&&a(`Full Name`,s[1]),s=t.match(/\bfull\s*name,?\s*(?:please\s+)?(?:enter|type|put)\s+(.+?)(?:\.|$|!|\?)/i),s&&a(`Full Name`,s[1]),s=t.match(/\bfull\s*name\s*(?:is|:|please\s+enter|-)\s*(.+?)(?:\.|$|(?=\s+(?:and|my\s+email|email|message))\b)/i),s&&a(`Full Name`,s[1]),s=t.match(/\b(.+?)\s+for\s+(?:the\s+)?full\s*name\b/i),s){let e=s[1].trim();e.length>1&&e.length<120&&!/@/.test(e)&&a(`Full Name`,e)}if(s=t.match(/\b(?:email|e-mail)(?:\s*address)?\s*(?:is|:|please\s+use|enter|-)\s*([^\s@]+@[^\s@]+\.[^\s,]+)/i),s&&a(`Email Address`,s[1]),s=t.match(/\b(?:enter|type|put)\s+([^\s@]+@[^\s@]+\.[^\s,]+)\s+in(?:to)?\s+(?:the\s+)?(?:email|e-mail)/i),s&&a(`Email Address`,s[1]),s=t.match(/\b(?:message|comment)\s*(?:is|:|please\s+enter|-)\s*(.+)$/is),s){let e=s[1].trim();e.length>0&&a(`Message`,e)}if(!n.some(e=>/email/i.test(String(e.field_key)))){let e=t.match(i);if(e){let r=t.replace(e[0],``).trim().replace(/^(please|it's|it is|use|is|my email is|e-?mail is)\s*/i,``).replace(/[.,;:!?]+$/,``).trim();if(t.length<=96&&r.length<=36)return a(`Email Address`,e[1]),n}}if(n.length===0){let e=t.split(/\s+/).filter(Boolean).length,n=/[.!?]/.test(t)||e>=6||t.length>=24&&e>=5||t.length>=42,r=/^[A-Z][a-z]+\s+[A-Z][a-z]+$/.test(t.trim());n&&t.length>=16&&!i.test(t)&&!r&&a(`Message`,t)}return n}function uO(e){if(!e||typeof e!=`object`)return null;let t=e.url??e.target_url??e.page_url??e.pageUrl??e.link??e.href??e.path;return t==null?null:String(t).trim()||null}function dO(e){if(!e||typeof e!=`object`)return null;let t=e.query??e.q??e.search??e.text??e.keywords;return t==null?null:String(t).trim()||null}function fO(e,t,n){if(!n?.skipScroll)try{e.scrollIntoView({block:`center`,inline:`nearest`})}catch{try{e.scrollIntoView(!0)}catch{}}try{e.focus({preventScroll:!0})}catch{try{e.focus()}catch{}}let r=e.tagName,i=(e.type||``).toLowerCase();if(r===`SELECT`)return e.value=String(t),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0})),!0;if(i===`checkbox`||i===`radio`)return e.checked=[`1`,`true`,`yes`,`on`].includes(String(t).toLowerCase().trim()),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0})),!0;let a=String(t);if(r===`INPUT`||r===`TEXTAREA`){let t=e.ownerDocument?.defaultView||window,n=r===`TEXTAREA`?t.HTMLTextAreaElement.prototype:t.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(n,`value`);i?.set?i.set.call(e,a):e.value=a}else e.value=a;let o={bubbles:!0,cancelable:!0,composed:!0};try{e.dispatchEvent(new InputEvent(`input`,{...o,inputType:`insertText`,data:a}))}catch{e.dispatchEvent(new Event(`input`,o))}e.dispatchEvent(new Event(`change`,o));try{queueMicrotask(()=>{try{e.dispatchEvent(new Event(`input`,o)),e.dispatchEvent(new Event(`change`,o))}catch{}})}catch{}return!0}function pO(){let e={};document.querySelectorAll(`h1, h2, h3, h4, h5, h6`).forEach(t=>{if(t.id)return;let n=t.textContent.trim();if(!n)return;let r=n.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).substring(0,60);if(e[r]){let t=2;for(;e[r+`-`+t];)t++;r=r+`-`+t}e[r]=!0,t.id=r})}function mO(e){let t=e.siteId||null,n=(e.apiBaseUrl||``).replace(/\/$/,``),r=typeof e.getLastUserVoiceText==`function`?e.getLastUserVoiceText:null,i=[],a={flowengage_navigate:async n=>{$(`flowengage_navigate ▶ raw parameters:`,n);let r=oO(n),i=uO(r),a=r.section_text??r.sectionText??r.section;if($(`flowengage_navigate · coerced:`,{url:i,sectionText:a}),!i){let e=`Missing url: pass a string url, path like /pricing, or JSON with a url field.`;return $(`flowengage_navigate ✖`,e),e}if(!await xn(i,{siteId:t,apiBaseUrl:e.apiBaseUrl})){let e=`That page is not available in the site index; answer without navigating.`;return $(`flowengage_navigate ✖ blocked`,e),e}try{if(hD(`Navigating to ${i}...`,{spinner:!0}),bD(),SE(),OE(),$(`flowengage_navigate → shadowNavigate`,i),await Cn(i),await PD(400),pO(),a&&typeof a==`string`){let e=gn(null,a);e&&mE(()=>DE(e)),$(`flowengage_navigate · highlight`,{sectionText:a,found:!!e})}let e=`OK_NAVIGATION ${i}`;return $(`flowengage_navigate ✓`,e),hD(`Navigation complete`,{spinner:!1,icon:`✅`,duration:1200}),e}catch(e){let t=`Navigation error: ${e?.message||String(e)}`;return $(`flowengage_navigate ✖`,t),hD(`Navigation failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{xD(),gD(900)}},flowengage_highlight:async e=>{$(`flowengage_highlight ▶`,e);let t=oO(e),n=t?.section_id||t?.sectionId,r=t?.section_text||t?.sectionText,i=gn(n||null,r||null);return i?(mE(()=>DE(i)),$(`flowengage_highlight ✓ (enqueued)`),`Highlighted the section.`):($(`flowengage_highlight ✖ no element`),`Could not find that section on the page.`)},flowengage_read_content:async e=>{$(`flowengage_read_content ▶`,e);let t=oO(e),n=t?.section_text||t?.sectionText||``;try{let e=``;if(n){let t=gn(null,n);if(!t)return`Could not find section "${n}" on the page.`;let r=[t.textContent.trim()],i=t.nextElementSibling;for(;i&&!/^H[1-3]$/i.test(i.tagName);){let e=i.textContent.trim();e&&r.push(e),i=i.nextElementSibling}e=r.join(`
613
+ `)}else{let t=(document.querySelector(`main`)||document.querySelector(`article`)||document.querySelector(`[role="main"]`)||document.querySelector(`#content`)||document.querySelector(`.content`)||document.body).cloneNode(!0);t.querySelectorAll(`nav, footer, header, aside, script, style, noscript, .nav, .footer, .header, .sidebar`).forEach(e=>e.remove()),e=t.textContent.replace(/\s+/g,` `).trim()}return e.length>8e3&&(e=e.substring(0,8e3)+`... (truncated)`),$(`flowengage_read_content ✓`,`${e.length} chars`),e||`No readable content found on this page.`}catch(e){return $(`flowengage_read_content ✖`,e.message),`Could not read page content: ${e.message}`}},flowengage_search:async e=>{$(`flowengage_search ▶`,e);let r=dO(oO(e));if($(`flowengage_search · query:`,r,`siteId:`,t,`apiBase:`,n||`(empty)`),!r)return $(`flowengage_search ✖ missing query`),`Missing query parameter.`;if(!t)return $(`flowengage_search ✖ no siteId`),`Site is not configured for search.`;if(!n)return $(`flowengage_search ✖ no api base`),`API base URL is missing; cannot search.`;try{let e=`${n}/api/site-tools/search`;$(`flowengage_search → POST`,e);let i=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({siteId:t,query:r,currentUrl:typeof window<`u`?window.location.href:``})}),a=await i.json();if($(`flowengage_search · HTTP`,i.status,`success:`,a.success),!a.success){let e=a.error||`Search failed.`;return $(`flowengage_search ✖`,e),e}let o=a.results||[];return $(`flowengage_search ✓`,`${o.length} result(s)`,o.slice(0,3).map(e=>e?.url||e)),JSON.stringify(o)}catch(e){let t=`Search error: ${e.message||`network`}`;return $(`flowengage_search ✖`,t),t}},flowengage_page_content:async e=>{$(`flowengage_page_content ▶`,e);let r=oO(e),i=r?.url||r?.page_url||``;if($(`flowengage_page_content · url:`,i,`siteId:`,t,`apiBase:`,n||`(empty)`),!i)return $(`flowengage_page_content ✖ missing url`),`Missing url parameter.`;if(!t)return $(`flowengage_page_content ✖ no siteId`),`Site is not configured.`;if(!n)return $(`flowengage_page_content ✖ no api base`),`API base URL is missing; cannot fetch page content.`;try{let e=`${n}/api/site-tools/page-content`;$(`flowengage_page_content → POST`,e);let r=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({siteId:t,url:i})}),a=await r.json();if($(`flowengage_page_content · HTTP`,r.status,`success:`,a.success),!a.success){let e=a.error||`Failed to get page content.`;return $(`flowengage_page_content ✖`,e),e}return $(`flowengage_page_content ✓`,`title: ${a.title}`,`sections: ${(a.sections||[]).length}`,`content: ${(a.content||``).length} chars`),JSON.stringify({title:a.title,url:a.url,sections:a.sections,content:a.content})}catch(e){let t=`Page content error: ${e.message||`network`}`;return $(`flowengage_page_content ✖`,t),t}},flowengage_end_session:async()=>($(`flowengage_end_session ▶`),typeof e.requestEndSession==`function`&&e.requestEndSession(),`Voice session is ending.`),flowengage_list_forms:async()=>{let e=HD(),t=UD();return $(`flowengage_list_forms ✓`,`${e.length} field(s)`,`${t.length} button(s)`),JSON.stringify({fields:e,buttons:t,hint:`field_key: placeholder/label, name (e.g. url), id (e.g. url-input). If the page has two URL boxes, flowengage_fill_form sets all matching URL inputs. flowengage_click_button picks the Conduct Audit nearest the filled field when labels duplicate.`})},flowengage_fill_form:async e=>{try{$(`flowengage_fill_form ▶ raw:`,e),SD();let t=sO(e);if(!t.length&&r){let e=r(),n=cO(e);n.length?$(`flowengage_fill_form · inferred URL from last user utterance (model omitted usable fields):`,n):(n=lO(e),n.length&&$(`flowengage_fill_form · inferred contact fields from last user utterance (empty tool params):`,n)),n.length&&(t=n)}if($(`flowengage_fill_form · normalized fields:`,t),!t.length)return`No fields provided. Call flowengage_list_forms for field_key strings, then flowengage_fill_form with { "fields": [ { "field_key": "<label or placeholder from list>", "value": "<user value>" } ] }. Never use empty {}. Pass the value the user just said (email, message, name, URL) in fields.`;let n=[];for(let e of t){let t=e?.field_key??e?.fieldKey,r=e?.value;if(t==null||r==null)continue;hD(`Filling ${String(t)}...`,{spinner:!0});let a=VD(),o=eO(a,String(t),r);if(o.length){for(let[e,t]of o.entries())CD(t),await kD(t),fO(t,r,{skipScroll:e>0}),wD(t),await PD(120);i=o,n.push(String(t));continue}let s=rO(a,String(t));s||=JD(a,String(t)),s||=YD(a,String(t),r),s&&(CD(s),await kD(s),fO(s,r),wD(s),await PD(120),i=[s],n.push(String(t)))}if(!n.length)return $(`flowengage_fill_form ✖ no matches`),`Could not match any fields. Call flowengage_list_forms and use field_key values that match placeholder, label, name, or id (e.g. Enter Website URL). Ensure the form is on the page, not the chat panel.`;let a=`OK_FILLED: ${n.join(`, `)}`;return $(`flowengage_fill_form ✓`,a),hD(`Form filled`,{spinner:!1,icon:`✅`,duration:1100}),a}catch(e){let t=`flowengage_fill_form error: ${e?.message||String(e)}`;return $(`flowengage_fill_form ✖`,t),hD(`Failed to fill form`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{AD(),SD(),gD(700)}},flowengage_click_button:async e=>{let t=oO(e),n=(t.button_text??t.buttonText??t.text??``).trim();if($(`flowengage_click_button ▶`,n),!n)return`Missing button_text: pass the visible label, e.g. Conduct Audit.`;let r=aO(n,i);if(!r)return $(`flowengage_click_button ✖ no match`),`Could not find a button matching "${n}". Call flowengage_list_forms to see button texts.`;try{hD(`Clicking ${n}...`,{spinner:!0});try{r.scrollIntoView({block:`center`,inline:`nearest`})}catch{r.scrollIntoView(!0)}await kD(r),r.focus?.(),await jD(r),MD(r),r.click();let e=(r.textContent||r.value||r.getAttribute(`aria-label`)||``).trim().slice(0,80)||`button`,t=`OK_CLICK ${e}`;return $(`flowengage_click_button ✓`,t),hD(`Clicked ${e}`,{spinner:!1,icon:`✅`,duration:1200}),t}catch(e){let t=`Click failed: ${e?.message||String(e)}`;return $(`flowengage_click_button ✖`,t),hD(`Click failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{AD(),gD(700)}}};return{...a,navigateToPage:a.flowengage_navigate,highlightOnPage:a.flowengage_highlight,searchSiteContent:a.flowengage_search,getPageContent:a.flowengage_page_content,endVoiceSession:a.flowengage_end_session,listPageForms:a.flowengage_list_forms,fillFormFields:a.flowengage_fill_form,clickPageButton:a.flowengage_click_button}}function hO(e){return!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,async n=>{let r=ln();r?console.log(`[FlowEngage:voice-tool] ▶`,e,n):console.info(`[FlowEngage] voice tool » ${e}`);let i;try{i=await t(n)}catch(t){let n=`Tool error: ${t?.message||String(t)}`;return console.error(`[FlowEngage] voice tool ${e} threw:`,t),n}let a=typeof i==`string`?i.length>220?`${i.slice(0,220)}…`:i:String(i);return r?console.log(`[FlowEngage:voice-tool] ◀`,e,a):console.info(`[FlowEngage] voice tool « ${e}:`,a),i}]))}var gO={blue:`#135bd8`,red:`#ef334b`,yellow:`#ffbd2e`,dark:`#0d1b2a`,highlight:`rgba(255,255,255,0.9)`,green:`#10b981`};function _O(e){if(!Array.isArray(e)||e.length<2)return`linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa`;let[t,n,r]=e;return e.length>=3&&r?[`radial-gradient(ellipse 80% 70% at -10% 50%, ${t}1a 0%, transparent 70%)`,`radial-gradient(ellipse 70% 80% at 110% 30%, ${n}1a 0%, transparent 70%)`,`radial-gradient(ellipse 80% 60% at 50% 110%, ${r}1a 0%, transparent 70%)`,`#f7f8fa`].join(`, `):[`radial-gradient(ellipse 80% 100% at -10% 50%, ${t}1a 0%, transparent 70%)`,`radial-gradient(ellipse 80% 100% at 110% 50%, ${n}1a 0%, transparent 70%)`,`#f7f8fa`].join(`, `)}function vO(e){if(!e||typeof e!=`string`)return`#1a1a1a`;let t=e.replace(`#`,``),n=t.length===3?t.split(``).map(e=>e+e).join(``):t,r=parseInt(n.slice(0,2),16)/255,i=parseInt(n.slice(2,4),16)/255,a=parseInt(n.slice(4,6),16)/255,o=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;return .2126*o(r)+.7152*o(i)+.0722*o(a)>.179?`#1a1a1a`:`#ffffff`}function yO({logo:e,style:t}){if(!e)return null;if(typeof e==`string`)return(0,N.jsx)(`img`,{src:e,alt:``,style:{objectFit:`contain`,flexShrink:0,display:`block`,...t}});let n=typeof e==`function`?b.createElement(e):b.isValidElement(e)?e:null;return n?(0,N.jsx)(`span`,{className:`fe-logo-slot`,style:{display:`inline-flex`,alignItems:`center`,flexShrink:0,overflow:`hidden`,...t},children:n}):null}function bO({title:e}){return(0,N.jsx)(`div`,{style:{width:`100%`,height:`100%`,borderRadius:`16px`,background:`linear-gradient(135deg, rgba(59,130,246,0.16) 0%, rgba(59,130,246,0.08) 100%)`,color:`#2563eb`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:`18px`,fontWeight:700,letterSpacing:`-0.03em`},children:String(e||`FE`).split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0]?.toUpperCase()||``).join(``)||`FE`})}function xO(e,t){let n=(t||``).trim();return n?!!(/\b(let'?s|let us)\s+(end|stop|finish|wrap up|close)\s+(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n)||/\bend\s+(this\s+)?(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n)||/\b(hang\s+up|disconnect)\b/i.test(n)||/\b(that'?s all|we'?re done)\b/i.test(n)||e===`bot`&&(/\b(I'?ll|I will|Let me|I can|I'?m going to)\s+(end|close)\s+(the\s+)?(voice\s+)?(session|call)\b/i.test(n)||/\b(ending|closing)\s+(the\s+)?(voice\s+)?session\b|\bvoice\s+session\s+(is\s+)?(now\s+)?(ended|over|closing)\b/i.test(n)||/\b(session|call)\s+(is\s+)?(now\s+)?(ended|over)\b/i.test(n)||/\bwe\s+can\s+end\s+(the\s+)?(session|call)?\s*(here|now)\b/i.test(n)||/\b(wrapping\s+up|signing\s+off)\b/i.test(n))||/^(goodbye|bye|that'?s all|we'?re done|hang up|disconnect)\b/i.test(n)):!1}function SO({orbColors:e,...t}){return(0,N.jsx)(uD,{colors:e,...t})}function CO({copy:e,orbColors:t,primaryColor:n,onYes:r,onLater:i,isMobile:a}){let o=n||gO.green,s=vO(o),c=a?72:94,l=(0,N.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:a?`14px`:`18px`},children:[(0,N.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,N.jsx)(dp.p,{initial:{x:-16,opacity:0},animate:{x:0,opacity:1},transition:{type:`spring`,stiffness:260,damping:24,delay:.36},style:{margin:`0 0 14px`,fontSize:a?`16px`:`18px`,fontWeight:700,color:`white`,lineHeight:1.4,textShadow:`0 1px 4px rgba(0,0,0,0.35)`,maxWidth:a?void 0:`210px`},children:e.entryPrompt}),(0,N.jsxs)(dp.div,{initial:{y:10,opacity:0},animate:{y:0,opacity:1},transition:{type:`spring`,stiffness:260,damping:24,delay:.54},style:{display:`flex`,gap:`8px`,flexWrap:`nowrap`},children:[(0,N.jsx)(`button`,{onClick:r,style:{padding:a?`9px 20px`:`10px 28px`,borderRadius:`999px`,background:o,color:s,fontWeight:700,fontSize:a?`14px`:`15px`,border:`none`,cursor:`pointer`,whiteSpace:`nowrap`,boxShadow:`0 4px 16px ${o}66`,transition:`transform 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.04)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`},children:e.yesLabel}),(0,N.jsx)(`button`,{onClick:i,style:{padding:a?`9px 16px`:`10px 22px`,borderRadius:`999px`,background:`transparent`,color:`white`,fontWeight:600,fontSize:a?`14px`:`15px`,border:`2px solid rgba(255,255,255,0.55)`,cursor:`pointer`,whiteSpace:`nowrap`,transition:`border-color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.borderColor=`rgba(255,255,255,0.9)`},onMouseLeave:e=>{e.currentTarget.style.borderColor=`rgba(255,255,255,0.55)`},children:e.laterLabel})]})]}),(0,N.jsx)(dp.div,{initial:{x:120,opacity:0},animate:{x:0,opacity:1},transition:{type:`spring`,stiffness:220,damping:22,delay:0},style:{flexShrink:0},children:(0,N.jsx)(SO,{size:c,orbColors:t})})]});return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(dp.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.4},style:{position:`fixed`,inset:0,background:`rgba(0,0,0,0.72)`,zIndex:-1}}),a?(0,N.jsx)(`div`,{style:{position:`absolute`,bottom:0,left:0,right:0,padding:`24px 20px 40px`,overflow:`hidden`},children:l}):l]})}function wO({copy:e,orbColors:t,primaryColor:n,onVoice:r,onText:i,onClose:a}){let o=n||gO.green,s=vO(o);return(0,N.jsxs)(dp.div,{initial:{scale:50/300,borderRadius:`50%`},animate:{scale:1,borderRadius:`24px`},transition:{type:`spring`,stiffness:260,damping:26},style:{transformOrigin:`bottom right`,background:`white`,padding:`28px 28px 24px`,width:`300px`,display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`20px`,boxShadow:`0 20px 60px rgba(0,0,0,0.2)`,position:`relative`,overflow:`hidden`},children:[(0,N.jsx)(`button`,{onClick:a,style:{position:`absolute`,top:`14px`,right:`14px`,background:`none`,border:`none`,cursor:`pointer`,color:`#9ca3af`,padding:`4px`,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,transition:`color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.color=`#374151`},onMouseLeave:e=>{e.currentTarget.style.color=`#9ca3af`},children:(0,N.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,N.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}),(0,N.jsx)(SO,{size:82,orbColors:t}),(0,N.jsx)(`p`,{style:{margin:0,fontSize:`17px`,fontWeight:600,color:`#111827`,textAlign:`center`,lineHeight:1.4},children:e.connectionTitle}),(0,N.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,width:`100%`},children:[(0,N.jsx)(`button`,{onClick:r,style:{flex:1,padding:`12px`,borderRadius:`999px`,background:o,color:s,fontWeight:700,fontSize:`15px`,border:`none`,cursor:`pointer`,transition:`transform 0.15s ease`,boxShadow:`0 4px 12px ${o}55`},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.03)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`},children:e.voiceLabel}),(0,N.jsx)(`button`,{onClick:i,style:{flex:1,padding:`12px`,borderRadius:`999px`,background:`transparent`,color:`#111827`,fontWeight:600,fontSize:`15px`,border:`2px solid #d1d5db`,cursor:`pointer`,transition:`border-color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.borderColor=`#6b7280`},onMouseLeave:e=>{e.currentTarget.style.borderColor=`#d1d5db`},children:e.textLabel})]})]})}function TO({orbColors:e,onEnterChat:t,onEndChat:n,agentId:r,siteId:i,apiBaseUrl:a,historyRef:o,onMessageSync:s}){let[c,l]=(0,b.useState)(`idle`),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(!1),m=(0,b.useRef)(null),h=(0,b.useRef)(``),g=(0,b.useRef)(async()=>{}),_=(0,b.useRef)(!1),v=(0,b.useRef)(!1),y=(0,b.useRef)(!1),x=(0,b.useRef)(!1),ee=(0,b.useRef)(`minimized`),S=(0,b.useRef)(null),C=(0,b.useCallback)((e=`minimized`)=>{ee.current=e,x.current=!0,queueMicrotask(()=>{_.current||(_.current=!0,g.current?.())})},[o]),te=(0,b.useCallback)(async e=>{x.current=!0;try{await m.current?.endSession?.()}catch{}m.current=null,l(`idle`),d(!1),_.current=!1,typeof s==`function`&&await s(o.current),e?.()},[o,s]);return g.current=()=>te(ee.current===`chat`?t:n),(0,b.useEffect)(()=>{v.current=u},[u]),(0,b.useEffect)(()=>{let e=!1,n=null;return(async()=>{if(!r){l(`error`);return}try{if((await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),e)return;o.current=[],h.current=``,_.current=!1,y.current=!1,x.current=!1,ee.current=`minimized`,bE(!0),SE();let t=hO(mO({siteId:i||null,apiBaseUrl:a||null,getLastUserVoiceText:()=>h.current,requestEndSession:()=>{C()}})),s=await sE.startSession({agentId:r,clientTools:t,onUnhandledClientToolCall:e=>console.error(`[FlowEngage] Unhandled tool:`,e?.tool_name),onModeChange:({mode:t})=>{e||(l(t===`speaking`?`speaking`:`listening`),t===`speaking`?gE():_E())},onMessage:t=>{if(e)return;let n=t.role===`user`?`user`:`bot`,r=t.message||t.text||t.content||``;r&&(n===`user`&&(h.current=r,SE(),OE()),n===`bot`&&(AE(r,!0),vE(r.trim().split(/\s+/).length)),o.current=[...o.current,{sender:n,message:r,timestamp:new Date().toISOString()}],xO(n,r)&&C(`minimized`))},onError:t=>{if(!e&&!x.current&&!y.current){y.current=!0,console.error(`[FlowEngageVoiceCall] session:error`,{message:t?.message,name:t?.name,raw:t});try{m.current?.setMicMuted?.(!0)}catch{}d(!0),l(`error`),C(`chat`)}},onDisconnect:()=>{if(!e&&!x.current&&!y.current){y.current=!0,console.warn(`[FlowEngageVoiceCall] session:disconnected`,{historyCount:o.current?.length||0,lastUserText:h.current||``,wasMuted:v.current});try{m.current?.setMicMuted?.(!0)}catch{}d(!0),SE(),OE(),bE(!1),C(`chat`)}}});if(e){s.endSession().catch(()=>{});return}n=s,m.current=s,l(`listening`);try{let e=typeof window<`u`?window.location.href:``,n=`[]`;try{n=await t.flowengage_list_forms()}catch{}s.sendContextualUpdate(`Page: ${e}. SiteId: ${i||`unknown`}. Forms: ${n}. Voice: call end_voice_session or say you are ending the session to stop.`)}catch{}}catch(n){e||(console.error(`[FlowEngage] startSession failed`,n),l(`error`),ee.current=`chat`,window.setTimeout(()=>{e||t?.()},0))}})(),()=>{e=!0,x.current=!0,(n||m.current)?.endSession?.().catch(()=>{})}},[r,i,a,C]),(0,b.useEffect)(()=>{if(!f)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;S.current&&!S.current.contains(t)&&p(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[f]),(0,N.jsx)(N.Fragment,{children:(0,N.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`14px`,animation:`fe-orb-slide-up 0.42s cubic-bezier(0.16,1,0.3,1)`},children:[(0,N.jsxs)(`div`,{style:{position:`relative`},children:[c===`listening`&&(0,N.jsx)(`span`,{style:{position:`absolute`,right:`100%`,marginRight:`18px`,top:`50%`,transform:`translateY(-50%)`,color:`white`,fontSize:`18px`,fontWeight:600,letterSpacing:`0.01em`,textShadow:`0 2px 4px rgba(0,0,0,0.4)`,whiteSpace:`nowrap`},children:`Listening...`}),(0,N.jsx)(SO,{size:94,voiceState:c,isMuted:u,orbColors:e})]}),c===`error`&&(0,N.jsx)(`span`,{style:{color:`#f87171`,fontSize:`13px`,fontWeight:500},children:`Could not start voice session.`}),(0,N.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,alignItems:`center`},children:[(0,N.jsx)(`button`,{onClick:async()=>{if(m.current)try{u?(await m.current.setMicMuted?.(!1),d(!1)):(await m.current.setMicMuted?.(!0),d(!0))}catch{}},title:u?`Unmute`:`Mute`,style:{width:`44px`,height:`44px`,borderRadius:`50%`,background:u?`#7f1d1d`:`#1f2937`,border:u?`1.5px solid #ef4444`:`1.5px solid #4b5563`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:u?`#f87171`:`white`,transition:`all 0.2s ease`,boxShadow:`0 2px 8px rgba(0,0,0,0.4)`},children:u?(0,N.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`line`,{x1:`1`,y1:`1`,x2:`23`,y2:`23`}),(0,N.jsx)(`path`,{d:`M9 9v3a3 3 0 005.12 2.12M15 9.34V4a3 3 0 00-5.94-.6`}),(0,N.jsx)(`path`,{d:`M17 16.95A7 7 0 015 12v-2m14 0v2a7 7 0 01-.11 1.23`}),(0,N.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`23`}),(0,N.jsx)(`line`,{x1:`8`,y1:`23`,x2:`16`,y2:`23`})]}):(0,N.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`,fill:`currentColor`,stroke:`none`}),(0,N.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`})]})}),(0,N.jsxs)(`div`,{style:{position:`relative`,isolation:`isolate`,zIndex:10},ref:S,children:[(0,N.jsx)(`button`,{onClick:()=>p(e=>!e),style:{width:`44px`,height:`44px`,borderRadius:`50%`,background:`#1f2937`,border:`1.5px solid #4b5563`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:`white`,transition:`background 0.2s ease`,boxShadow:`0 2px 8px rgba(0,0,0,0.4)`},children:(0,N.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`currentColor`,children:[(0,N.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.8`}),(0,N.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.8`}),(0,N.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.8`})]})}),f&&(0,N.jsxs)(`div`,{style:{position:`absolute`,bottom:`54px`,right:0,zIndex:9999,background:`rgba(15,22,36,0.96)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,overflow:`hidden`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,minWidth:`210px`,border:`1px solid rgba(255,255,255,0.07)`,animation:`fe-orb-fade-in 0.18s ease`},children:[(0,N.jsxs)(`button`,{onClick:()=>{p(!1),ee.current=`chat`,te(t)},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,N.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,N.jsx)(`path`,{d:`M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z`})}),`Enter Chat Mode`]}),(0,N.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,N.jsxs)(`button`,{onClick:()=>{p(!1),ee.current=`minimized`,te(n)},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`#f87171`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(248,113,113,0.1)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,N.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M10.68 13.31a16 16 0 003.41 2.6l1.27-1.27a2 2 0 012.11-.45 12.84 12.84 0 002.81.7 2 2 0 011.72 2v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.42 19.42 0 013.07 8.62 19.79 19.79 0 01.1 2 2 2 0 012.11 0h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L6.18 7.84`}),(0,N.jsx)(`line`,{x1:`23`,y1:`1`,x2:`1`,y2:`23`})]}),`End Conversation`]})]})]})]})]})})}function EO({orbColors:e}){return(0,N.jsx)(`div`,{style:{flexShrink:0,width:`36px`,height:`36px`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,N.jsx)(SO,{size:36,orbColors:e})})}var DO=()=>(0,N.jsx)(`div`,{style:{display:`flex`,marginBottom:`12px`,justifyContent:`flex-start`},children:(0,N.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`12px 16px`,borderRadius:`18px`,background:`#fff`,boxShadow:`0 2px 6px rgba(0,0,0,0.04)`},children:[0,1,2].map(e=>(0,N.jsx)(`span`,{style:{width:`7px`,height:`7px`,borderRadius:`50%`,background:`#9ca3af`,animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`}},e))})});function OO({copy:e,orbColors:t,primaryColor:n,chatBgGradient:r,logo:i,quickChatOptions:a,onQuickChatSelect:o,isMobile:s,chatHistory:c,isAiTyping:l,isAgentTyping:u,activeScreen:d,agentName:f,agentHeadshot:p,fallbackAgentName:m,input:h,setInput:g,onSubmit:_,isConversationEnded:v,isLoading:y,isRateLimited:x,rateLimitMessage:ee,selectedFile:S,onFileSelect:C,onRemoveSelectedFile:te,attachmentError:ne,isUploadingAttachment:re,requiresEmail:ie,emailInput:ae,setEmailInput:oe,emailError:se,replyContext:ce,setReplyContext:le,webRTCError:ue,micError:de,setMicError:w,dismissCallError:T,incomingCall:fe,rejectCall:pe,acceptCall:me,activeCallId:he,callConnectionState:E,isCallMuted:D,toggleCallMute:ge,endWebRTCCall:_e,formatCallDuration:ve,callDurationSeconds:ye,onCollapse:be,onStartVoice:xe,showPoweredBy:Se}){let Ce=c.length>0,we=y||x||v,Te=!!(fe||he),[Ee,De]=(0,b.useState)(!1),Oe=(0,b.useRef)(null);return(0,b.useEffect)(()=>{if(!Ee)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;Oe.current&&!Oe.current.contains(t)&&De(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Ee]),(0,N.jsxs)(`div`,{style:s?{"--flowengage-primary":n,"--flowengage-accent":n,position:`fixed`,inset:0,width:`100%`,height:`100dvh`,background:r,borderRadius:0,display:`flex`,flexDirection:`column`,overflow:`hidden`,animation:`fe-orb-slide-up 0.28s cubic-bezier(0.16,1,0.3,1)`}:{"--flowengage-primary":n,"--flowengage-accent":n,width:`min(390px, calc(100vw - 40px))`,height:`min(640px, calc(100vh - 120px))`,background:r,borderRadius:`22px`,boxShadow:`0 24px 64px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08)`,display:`flex`,flexDirection:`column`,overflow:`hidden`,position:`relative`,animation:`fe-orb-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)`},children:[(0,N.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`40px minmax(0, 1fr) 40px`,alignItems:`center`,columnGap:`14px`,padding:`16px 18px 14px`,background:`transparent`,flexShrink:0},children:[(0,N.jsx)(`button`,{onClick:be,style:{width:`40px`,height:`40px`,background:`none`,border:`none`,cursor:`pointer`,color:`#6b7280`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`4px`,borderRadius:`10px`,transition:`color 0.15s ease`,flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.color=`#111827`},onMouseLeave:e=>{e.currentTarget.style.color=`#6b7280`},children:(0,N.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,N.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}),(0,N.jsxs)(`div`,{style:{minWidth:0,maxWidth:s?`100%`:`250px`,width:`100%`,justifySelf:`center`,display:`grid`,gridTemplateColumns:`minmax(72px, 40%) minmax(0, 60%)`,alignItems:`center`},children:[(0,N.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:`center`,height:`40px`},children:i?(0,N.jsx)(yO,{logo:i,style:{height:`34px`,width:`100%`,maxWidth:`96px`}}):(0,N.jsx)(`div`,{style:{width:`40px`,height:`40px`,flexShrink:0},children:(0,N.jsx)(bO,{title:e.chatTitle})})}),(0,N.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`},children:(0,N.jsx)(`span`,{style:{fontSize:`15px`,fontWeight:600,color:`#111827`,letterSpacing:`-0.01em`,lineHeight:1.2,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:e.chatTitle,children:e.chatTitle})})]}),(0,N.jsxs)(`div`,{style:{position:`relative`,isolation:`isolate`,zIndex:10},ref:Oe,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>De(e=>!e),style:{width:`40px`,height:`40px`,background:`none`,border:`none`,cursor:`pointer`,color:`#6b7280`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`4px`,borderRadius:`10px`,transition:`color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.color=`#111827`},onMouseLeave:e=>{e.currentTarget.style.color=`#6b7280`},"aria-label":`Chat options`,children:(0,N.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,N.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`}),(0,N.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`}),(0,N.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.5`})]})}),Ee&&(0,N.jsxs)(`div`,{style:{position:`absolute`,top:`34px`,right:0,background:`rgba(15,22,36,0.96)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,overflow:`hidden`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,minWidth:`210px`,border:`1px solid rgba(255,255,255,0.07)`,animation:`fe-orb-fade-in 0.18s ease`},children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>{De(!1),xe?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,N.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`}),(0,N.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`})]}),`Enter Voice Mode`]}),(0,N.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>{De(!1),be?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`#f87171`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(248,113,113,0.1)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,N.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,N.jsx)(`path`,{d:`M10.68 13.31a16 16 0 003.41 2.6l1.27-1.27a2 2 0 012.11-.45 12.84 12.84 0 002.81.7 2 2 0 011.72 2v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.42 19.42 0 013.07 8.62 19.79 19.79 0 01.1 2 2 2 0 012.11 0h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L6.18 7.84`}),(0,N.jsx)(`line`,{x1:`23`,y1:`1`,x2:`1`,y2:`23`})]}),`Close Conversation`]})]})]})]}),(0,N.jsx)(tD,{webRTCError:ue,micError:de,setMicError:w,dismissCallError:T,incomingCall:fe,rejectCall:pe,acceptCall:me,activeCallId:he,callConnectionState:E,formatCallDuration:ve,callDurationSeconds:ye,endWebRTCCall:_e,isCallMuted:D,toggleCallMute:ge,isAIVoiceActive:!1,currentCallAgentName:f||m,isRateLimited:x,rateLimitMessage:ee}),(0,N.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,background:`transparent`},children:Ce?(0,N.jsx)(ZE,{chatHistory:c,isAiTyping:l,isAgentTyping:u,setReplyContext:le,TypingDots:DO,primaryColor:n,agentHeadshot:p,agentDisplayName:f||m,botAvatarNode:(0,N.jsx)(EO,{orbColors:t})}):(0,N.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`22px`,padding:`28px 24px`},children:[(0,N.jsx)(SO,{size:94,orbColors:t}),(0,N.jsx)(`p`,{style:{margin:0,textAlign:`center`,fontSize:`16px`,color:`#374151`,lineHeight:1.55,maxWidth:`270px`},children:e.introGreeting}),a.length>0&&(0,N.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`8px`,justifyContent:`center`,width:`100%`,padding:`0 8px`},children:a.map(e=>(0,N.jsx)(`button`,{onClick:()=>o?.(e),style:{padding:`8px 16px`,borderRadius:`999px`,background:`white`,border:`1.5px solid ${n}33`,color:n||`#374151`,fontSize:`13px`,fontWeight:500,cursor:`pointer`,transition:`all 0.15s ease`,boxShadow:`0 1px 4px rgba(0,0,0,0.06)`},onMouseEnter:e=>{e.currentTarget.style.background=`${n}12`,e.currentTarget.style.borderColor=n},onMouseLeave:e=>{e.currentTarget.style.background=`white`,e.currentTarget.style.borderColor=`${n}33`},children:e.label||e.text},e.id))})]})}),(0,N.jsx)(`div`,{style:{background:`transparent`,flexShrink:0,position:`relative`,zIndex:1,padding:ie?`6px 0 0`:`12px 0 0`},children:(0,N.jsx)(QE,{input:h,setInput:g,onSubmit:_,isConversationEnded:v,callUiActive:Te,handleToggleVoice:xe,showVoiceToggle:d===`agent`,activeScreen:d,inputDisabled:we,replyContext:ce,clearReplyContext:()=>le(null),onFileSelect:C,selectedFile:S,onRemoveSelectedFile:te,attachmentError:ne,isUploadingAttachment:re,requiresEmail:ie,emailInput:ae,setEmailInput:oe,emailError:se,inputPlaceholder:e.inputPlaceholder})}),(0,N.jsx)(`div`,{style:{flexShrink:0,textAlign:`center`,padding:`12px 20px 18px`,pointerEvents:`none`},children:Se&&(0,N.jsxs)(`span`,{style:{fontSize:`11px`,color:`#9ca3af`,letterSpacing:`0.01em`,userSelect:`none`},children:[`Powered by `,(0,N.jsx)(`strong`,{style:{fontWeight:600,color:`#6b7280`},children:`FlowEngage`})]})})]})}function kO(){let{status:e,runtimeConfig:t,resolvedConfig:n,chatHistory:r,isOpen:i,activeScreen:a,isHumanHandled:o,agentName:s,agentHeadshot:c,visitorEmail:l,isAgentTyping:u,isAiTyping:d,isLoading:f,isRateLimited:p,rateLimitMessage:m,isConversationEnded:h,incomingCall:g,activeCallId:_,callConnectionState:v,callConnectedAt:y,isCallMuted:x,webRTCError:ee,language:S,historyRef:C,onMessageSync:te,sendMessage:ne,uploadChatFile:re,openWidget:ie,captureVisitorEmail:ae,setVoiceMode:oe,endConversation:se,acceptCall:ce,rejectCall:le,endWebRTCCall:ue,toggleCallMute:de,dismissCallError:w,startTyping:T,stopTyping:fe,updateTypingDraft:pe}=cn();(0,b.useEffect)(()=>{try{mn()}catch{}},[]);let me=t?.widgetSettings||{},he=n?.widgetSettings||{},E={...me.branding||{},...he.branding||{}},D={...me.theme||{},...he.theme||{}},ge=Array.isArray(D.orbColors)&&D.orbColors.length>0?D.orbColors:null,_e=ge?.[0]||D.primaryColor||`#3B82F6`,ve=D.position||`bottom-right`,ye=E.fallbackAgentName||`Agent`,be=_O(ge??D.chatBgColors),xe=E.logo||E.logoUrl||null,Se=S||`en`,Ce=me.recommendations?.[Se]||[],we=(he.recommendations?.[Se]??Ce).filter(e=>String(e?.label??``).trim()).map((e,t)=>({id:e.key||`qr-${t}`,label:e.label,message:e.label,text:e.label})),Te=Array.isArray(E.quickChatOptions)&&E.quickChatOptions.length>0?E.quickChatOptions:we,Ee=E.hideWatermark===!0?!1:E.showPoweredBy!==!1,De=E.chatbotEnabled!==!1&&D.chatbotEnabled!==!1,Oe=me.greetings?.[S]||he.greetings?.[S]||E.introGreeting||`Hello, I'm here to help you know more about OpenSense Labs.`,ke={entryPrompt:E.entryPrompt||`Do you want to explore in a new way?`,yesLabel:E.yesLabel||`Yes`,laterLabel:E.laterLabel||`Later`,connectionTitle:E.connectionTitle||`How would you like to connect?`,voiceLabel:E.voiceLabel||`Voice`,textLabel:E.textLabel||`Text`,chatTitle:E.headerName||`Chat with FlowEngage`,introGreeting:Oe,inputPlaceholder:E.inputPlaceholder||`Type your message`,analysingLabel:E.analysingLabel||`analysing...`},Ae=he.elevenLabsAgentId||t?.elevenLabsAgentId||null,je=t?.siteId||n?.siteId||null,O=t?.apiBaseUrl||``,Me=(0,b.useMemo)(()=>s&&String(s).trim()||t?.ownerName&&String(t.ownerName).trim()||t?.websiteName&&String(t.websiteName).trim()||`Agent`,[s,t?.ownerName,t?.websiteName]),Ne=c&&String(c).trim()||t?.ownerProfileImageUrl&&String(t.ownerProfileImageUrl).trim()||null,Pe=r.some(e=>e.sender===`user`),Fe=(0,b.useMemo)(()=>{let e=r.findIndex(e=>e.sender===`user`);return e===-1?!1:r.slice(e+1).some(e=>e.sender===`bot`||e.sender===`ai`||e.sender===`agent`)},[r]),Ie=!l&&Pe&&Fe,Le=!!(he._dashboardLivePreview||me._dashboardLivePreview),[Re,ze]=(0,b.useState)(()=>Le?`text_chat`:`entry_prompt`),[Be,Ve]=(0,b.useState)(``),[He,Ue]=(0,b.useState)(null),[k,A]=(0,b.useState)(l||``),[We,j]=(0,b.useState)(``),[Ge,Ke]=(0,b.useState)(0),[qe,Je]=(0,b.useState)(null),[Ye,Xe]=(0,b.useState)(null),[Ze,Qe]=(0,b.useState)(``),[$e,et]=(0,b.useState)(!1),tt=(0,b.useRef)(null),nt=(0,b.useRef)(!1);(0,b.useLayoutEffect)(()=>{e!==`ready`||nt.current||(nt.current=!0,r.length>0&&ze(`minimized_orb`))},[e,r]);let[rt,it]=(0,b.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: 640px)`).matches);(0,b.useEffect)(()=>{let e=window.matchMedia(`(max-width: 640px)`),t=e=>it(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,b.useEffect)(()=>{A(l||``),l&&j(``)},[l]);let at=(0,b.useCallback)(()=>{Xe(null),Qe(``)},[]),ot=(0,b.useCallback)(e=>{let t=KE(e);if(t){Xe(null),Qe(t);return}Xe(e),Qe(``)},[]);(0,b.useEffect)(()=>{if(!y||v!==`connected`){Ke(0);return}let e=()=>{let e=new Date(y).getTime();isNaN(e)||Ke(Math.max(0,Math.floor((Date.now()-e)/1e3)))};e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[y,v]),(0,b.useEffect)(()=>{let e=g?.callId||_||null;if(!e){tt.current=null;return}(g?.callId||v===`connecting`||v===`connected`)&&(!(!i||Re===`minimized_orb`||Re===`voice_mode`)&&tt.current===e||(console.log(`[FlowEngageWidget] forcing call UI to front`,{forcedKey:e,isOpen:i,surface:Re,hasIncomingCall:!!g?.callId,activeCallId:_,callConnectionState:v}),tt.current=e,Re===`voice_mode`&&oe?.(!1),ie?.(),ze(`text_chat`)))},[_,v,g?.callId,i,ie,oe,Re]),(0,b.useEffect)(()=>{if(!o||h){pe?.(``),fe?.();return}if(!Be.trim()||Ye){pe?.(``),fe?.();return}T?.();let e=window.setTimeout(()=>pe?.(Be),120),t=window.setTimeout(()=>fe?.(),1200);return()=>{window.clearTimeout(e),window.clearTimeout(t)}},[Be,Ye,o,h,T,fe,pe]);let st=e=>e?{replyTo:e.messageId||e.id||null,replyToContent:(e.replyToContent||e.message||``).replace(/<[^>]+>/g,``).trim().slice(0,200),replyToSender:e.sender||null}:null,ct=async e=>{if(e.preventDefault(),h)return;if(Ie){let e=k.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){j(`Please enter a valid email so we can continue helping you.`);return}await ae(e),j(``);return}let t=st(He);if(!Be.trim()&&!Ye)return;if(Ye){try{et(!0),Qe(``);let e=await re(Ye),n=e?.data||e,r=Be.trim()||`Shared file: ${JE(Ye)}`;Ve(``),Ue(null),at(),await ne(r,``,t,{type:`file`,metadata:{fileUrl:n?.fileUrl,fileName:n?.fileName||Ye.name,fileType:n?.fileType||Ye.type,fileSize:n?.fileSize||Ye.size}})}catch(e){Qe(e?.message||`Failed to upload the selected file.`)}finally{et(!1)}return}let n=Be.trim();Ve(``),Ue(null),await ne(n,``,t)},lt=e=>{let t=Math.floor(e/60);return`${String(t).padStart(2,`0`)}:${String(e%60).padStart(2,`0`)}`},ut=(0,b.useCallback)(async e=>{if(h||f)return;let t=e.message||e.label||e.text||``;t.trim()&&await ne(t.trim(),``)},[h,f,ne]),dt=rt&&(Re===`text_chat`||Re===`entry_prompt`)?{inset:0}:ve===`bottom-left`?{left:`1.5rem`,bottom:`1.5rem`}:{right:`1.5rem`,bottom:`1.5rem`},ft=()=>ze(`minimized_orb`),pt=()=>ze(`connection_modal`),mt=()=>{ie({notifyChatInitiated:!0}),oe?.(!0),ze(`voice_mode`)},ht=()=>{ie({notifyChatInitiated:!0}),oe?.(!1),ze(`text_chat`)},gt=()=>{oe?.(!1),ft()};return e!==`ready`||!De?null:(0,N.jsxs)(`div`,{className:`flowengage-widget-root`,style:{position:`fixed`,zIndex:999999,...dt},children:[Re===`entry_prompt`&&(0,N.jsx)(CO,{copy:ke,orbColors:ge,primaryColor:_e,onYes:mt,onLater:ft,isMobile:rt}),Re===`minimized_orb`&&(0,N.jsx)(dp.div,{layoutId:`fe-main-orb`,initial:{scale:94/50},animate:{scale:1},transition:{type:`spring`,stiffness:220,damping:26},style:{transformOrigin:`bottom right`,display:`inline-block`},children:(0,N.jsx)(SO,{size:50,orbColors:ge,onClick:pt})}),Re===`connection_modal`&&(0,N.jsx)(wO,{copy:ke,orbColors:ge,primaryColor:_e,onVoice:mt,onText:ht,onClose:ft}),Re===`voice_mode`&&(0,N.jsx)(TO,{orbColors:ge,onEnterChat:ht,onEndChat:gt,agentId:Ae,siteId:je,apiBaseUrl:O,historyRef:C,onMessageSync:te},`voice`),Re===`text_chat`&&(0,N.jsx)(OO,{copy:ke,orbColors:ge,primaryColor:_e,chatBgGradient:be,logo:xe,quickChatOptions:Te,onQuickChatSelect:ut,isMobile:rt,chatHistory:r,isAiTyping:d,isAgentTyping:u,activeScreen:a,agentName:Me,agentHeadshot:Ne,fallbackAgentName:ye,input:Be,setInput:Ve,onSubmit:ct,isConversationEnded:h,isLoading:f,isRateLimited:p,rateLimitMessage:m,selectedFile:Ye,onFileSelect:ot,onRemoveSelectedFile:at,attachmentError:Ze,isUploadingAttachment:$e,requiresEmail:Ie,emailInput:k,setEmailInput:A,emailError:We,replyContext:He,setReplyContext:Ue,webRTCError:ee,micError:qe,setMicError:Je,dismissCallError:w,incomingCall:g,rejectCall:le,acceptCall:ce,activeCallId:_,callConnectionState:v,isCallMuted:x,toggleCallMute:de,endWebRTCCall:ue,formatCallDuration:lt,callDurationSeconds:Ge,onCollapse:ft,onStartVoice:mt,onEndConversation:se,showPoweredBy:Ee}),(0,N.jsx)(`style`,{children:`
614
614
  /* Force any SVG (or img) inside LogoSlot to fill the container height
615
615
  regardless of whether the component forwards its style prop. */
616
616
  .fe-logo-slot svg,
@@ -628,4 +628,4 @@ registerProcessor("scribeAudioProcessor", ScribeAudioProcessor);
628
628
  @keyframes fe-orb-bar-3 { from{height:8px} to{height:20px} }
629
629
  @keyframes fe-orb-bar-4 { from{height:6px} to{height:16px} }
630
630
  @keyframes fe-dot-bounce { 0%,80%,100%{transform:translateY(0);opacity:.5} 40%{transform:translateY(-5px);opacity:1} }
631
- `})]})}var xO=`:host{all:initial;box-sizing:border-box!important;color:#111827!important;-webkit-font-smoothing:antialiased!important;z-index:2147483647!important;background:0 0!important;border:none!important;margin:0!important;padding:0!important;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif!important;font-size:16px!important;line-height:1.5!important;display:block!important;position:relative!important}:host *,:host :before,:host :after{box-sizing:border-box}.flowengage-widget-root{-moz-osx-font-smoothing:grayscale;text-rendering:optimizelegibility;color:#111827!important;-webkit-font-smoothing:antialiased!important;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif!important;font-size:16px!important;line-height:1.5!important}.flowengage-widget-root *,.flowengage-widget-root :before,.flowengage-widget-root :after{font-family:inherit!important}.flowengage-widget-root input,.flowengage-widget-root textarea,.flowengage-widget-root button,.flowengage-widget-root select,.flowengage-widget-root optgroup,.flowengage-widget-root option{font-family:inherit!important;font-size:inherit!important;line-height:inherit!important}.flowengage-shell,.flowengage-shell *{font-family:inherit!important}.flowengage-chat-panel{border:none;border-radius:0;outline:none;flex-direction:column;width:100%;height:100%;display:flex;position:relative;overflow:hidden;box-shadow:0 20px 50px #00000026}.flowengage-chat-text-input{margin:0!important}.flowengage-chat-text-input:focus{box-shadow:none!important;border:none!important;outline:none!important}@media (width>=768px){.flowengage-chat-panel{border-radius:24px;width:min(423px,100vw - 40px);height:min(700px,100vh - 120px)}}.flowengage-shell[data-open=true]{inset:0}@media (width>=768px){.flowengage-shell[data-open=true]{inset:auto 1.5rem 1.5rem auto}}.flowengage-logo-fallback{background:conic-gradient(from 180deg, var(--flowengage-primary) 0%, var(--flowengage-accent) 45%, var(--flowengage-primary) 100%)}.fe-bot-message p{margin:0 0 .5em}.fe-bot-message p:last-child{margin-bottom:0}.fe-bot-message ul,.fe-bot-message ol{margin:.4em 0 .4em 1.2em;padding:0}.fe-bot-message li{margin-bottom:.25em}.fe-bot-message strong{font-weight:600}.fe-bot-message a{color:var(--flowengage-primary);text-decoration:underline}.fe-bot-message a:hover{opacity:.8}.incoming-call-overlay{z-index:1000;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);background:#1a1a2ef2;justify-content:center;align-items:center;transition:all .3s ease-in-out;display:flex;position:absolute;left:0;right:0}.incoming-call-overlay.bottom-mode{border-top:2px solid #ffffff1a;min-height:120px;animation:.4s cubic-bezier(.16,1,.3,1) slideUpBanner;top:auto;bottom:0;box-shadow:0 -10px 30px #00000080}.incoming-call-overlay.header-mode{border-bottom:2px solid #ffffff1a;min-height:80px;animation:.4s cubic-bezier(.16,1,.3,1) slideDownBanner;top:0;bottom:auto;box-shadow:0 10px 30px #00000080}.incoming-call-container{justify-content:space-between;align-items:center;gap:14px;width:100%;padding:14px 16px;display:flex}.incoming-call-container.connected-layout{flex-direction:column;justify-content:center;align-items:stretch;gap:14px}.call-connected-top{justify-content:space-between;align-items:center;gap:16px;width:100%;display:flex}.call-connected-identity{flex:1;align-items:center;gap:14px;min-width:0;display:flex}.call-icon-wrapper{color:#fff;z-index:1;border-radius:9999px;flex-shrink:0;justify-content:center;align-items:center;width:54px;height:54px;margin-right:4px;display:flex;position:relative}.call-icon-wrapper.incoming{background:linear-gradient(135deg,#4caf50,#45a049);animation:1s ease-in-out infinite bounce}.call-icon-wrapper.connecting{background:linear-gradient(135deg,#2196f3,#1976d2)}.call-icon-wrapper.connected{background:linear-gradient(135deg,#4caf50,#45a049)}.call-pulse-animation{z-index:-1;background:#4caf504d;border-radius:50%;width:120px;height:120px;animation:1.5s ease-out infinite pulse;position:absolute}.call-connecting-animation{z-index:-1;border:3px solid #0000;border-top-color:#2196f3;border-radius:50%;width:100px;height:100px;animation:1s linear infinite spin;position:absolute}.call-info-group{flex-direction:column;flex:1;min-width:0;margin-right:8px;display:flex}.call-title{color:#fff;white-space:normal;text-overflow:clip;margin:0;font-size:16px;font-weight:700;line-height:1.2;overflow:visible}.call-subtitle{color:#ffffffb3;white-space:normal;text-overflow:clip;margin:4px 0 0;font-size:12px;line-height:1.35;overflow:visible}.call-timer{text-align:center;color:#fff;flex-shrink:0;min-width:54px;font-size:13px;font-weight:700}.call-actions{flex-shrink:0;align-items:center;gap:8px;display:flex}.call-actions.connected{justify-content:center;width:100%}.flowengage-call-btn{cursor:pointer;color:#fff;border:none;border-radius:8px;justify-content:center;align-items:center;gap:6px;min-width:92px;padding:8px 12px;font-size:12px;font-weight:600;line-height:1;transition:transform .2s,box-shadow .2s,background .2s;display:flex}.flowengage-call-btn svg{flex-shrink:0;display:block}.flowengage-call-btn span{justify-content:center;align-items:center;line-height:1;display:flex}.flowengage-call-btn.icon-only{border-radius:9999px;width:46px;min-width:46px;height:46px;padding:0}.flowengage-call-btn-accept{background:linear-gradient(135deg,#4caf50,#45a049);box-shadow:0 8px 24px #4caf5066}.flowengage-call-btn-reject,.flowengage-call-btn-end{background:linear-gradient(135deg,#f44336,#d32f2f);box-shadow:0 4px 12px #f4433666}.flowengage-call-btn-mute{background:#ffffff1a;border:2px solid #fff3}.flowengage-call-btn-mute.active{background:#f443364d;border-color:#f44336}.flowengage-call-btn:hover:not(:disabled){transform:scale(1.05)}.incoming-call-overlay.header-mode .flowengage-call-btn{border-radius:9999px!important;width:36px!important;min-width:36px!important;height:36px!important;padding:0!important}.incoming-call-overlay.header-mode .flowengage-call-btn span{display:none!important}.incoming-call-overlay.header-mode .call-icon-wrapper{width:40px;height:40px;margin-right:0}.incoming-call-overlay.header-mode .call-info-group{min-width:0}.incoming-call-overlay.header-mode .call-title,.incoming-call-overlay.header-mode .call-subtitle{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}@media (width<=640px){.incoming-call-container{align-items:flex-start;gap:10px;padding:12px 14px}.incoming-call-container.connected-layout{align-items:stretch}.call-connected-top{flex-direction:column;align-items:flex-start;gap:10px}.call-connected-identity{width:100%}.call-info-group{margin-right:0}.call-actions{flex-wrap:wrap;align-self:stretch;gap:6px}.call-actions.connected{justify-content:stretch}.call-actions.connected .flowengage-call-btn{flex:1}.flowengage-call-btn{min-width:78px;padding:8px 10px}}@keyframes slideUpBanner{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes slideDownBanner{0%{transform:translateY(-100%)}to{transform:translateY(0)}}@keyframes bounce{0%,to{transform:translateY(0)}50%{transform:translateY(-10px)}}@keyframes pulse{0%{opacity:1;transform:scale(.8)}to{opacity:0;transform:scale(2)}}@keyframes spin{to{transform:rotate(360deg)}}.fe-screen-fade-in{animation:.4s cubic-bezier(.16,1,.3,1) forwards feFadeIn}@keyframes feFadeIn{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.flowengage-initial-bg{background-color:#fff;position:relative;overflow:hidden}.flowengage-initial-bg:before{content:"";background:linear-gradient(to bottom, var(--flowengage-primary) 0%, var(--flowengage-accent) 55%, white 82%);opacity:0;pointer-events:none;z-index:0;transition:opacity .6s cubic-bezier(.4,0,.2,1);position:absolute;inset:0}.flowengage-initial-bg.is-initial:before{opacity:1}.flowengage-content-wrapper{z-index:1;flex-direction:column;flex:1;min-height:0;display:flex;position:relative}`,SO=null,CO=!1;function wO(){let e=document.createElement(`div`);e.id=`flowengage-root`;let t=e.attachShadow({mode:`open`}),n=document.createElement(`style`);n.textContent=xO,t.appendChild(n);let r=document.createElement(`div`);return r.setAttribute(`data-flowengage-mount`,`true`),r.className=`flowengage-widget-root`,t.appendChild(r),{host:e,mount:r}}function TO(e){if(document.body){e();return}let t=new MutationObserver(()=>{document.body&&(t.disconnect(),e())});t.observe(document.documentElement,{childList:!0})}function EO({siteId:e,language:t=`en`,widgetSettings:n={},apiBaseUrl:r}){if(CO){console.warn(`[FlowEngage] Already initialized. Call FlowEngage.destroy() first to re-initialize.`);return}if(!e){console.error(`[FlowEngage] siteId is required. Pass it via data-site-id attribute or FlowEngage.init({ siteId: 'YOUR_SITE_ID' }).`);return}if(!document.body){console.error(`[FlowEngage] document.body is not available yet. The widget will auto-retry once the DOM is ready.`),TO(()=>EO({siteId:e,language:t,widgetSettings:n,apiBaseUrl:r}));return}if(document.getElementById(`flowengage-root`)){console.warn(`[FlowEngage] #flowengage-root already exists. Skipping duplicate mount.`);return}let{host:i,mount:a}=wO();document.body.appendChild(i),SO=(0,x.createRoot)(a);let o={widgetSettings:n,...r&&{apiBaseUrl:r}};SO.render(b.createElement(Mn,{siteId:e,language:t,config:o},b.createElement(bO))),CO=!0}var DO={init({siteId:e,language:t=`en`,widgetSettings:n={},apiBaseUrl:r}={}){document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>TO(()=>EO({siteId:e,language:t,widgetSettings:n,apiBaseUrl:r}))):TO(()=>EO({siteId:e,language:t,widgetSettings:n,apiBaseUrl:r}))},destroy(){SO&&=(SO.unmount(),null);let e=document.getElementById(`flowengage-root`);e&&e.remove();let t=document.getElementById(`flowengage-styles`);t&&t.remove(),CO=!1}},OO=()=>{let e=document.currentScript;(!e||!e.getAttribute(`data-site-id`))&&(e=document.querySelector(`script[data-site-id]`));let t=e?.getAttribute(`data-site-id`);if(!t)return;let n=e?.getAttribute(`data-language`)||`en`,r=e?.getAttribute(`data-api-url`)||void 0,i={};try{let t=e?.getAttribute(`data-widget-settings`);t&&(i=JSON.parse(t))}catch{}let a={widgetSettings:i,...r&&{apiBaseUrl:r}};TO(()=>EO({siteId:t,language:n,widgetSettings:a.widgetSettings,apiBaseUrl:r}))};return document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,OO):OO(),typeof window<`u`&&(window.FlowEngage=DO),DO})();
631
+ `})]})}var AO=`:host{all:initial;box-sizing:border-box!important;color:#111827!important;-webkit-font-smoothing:antialiased!important;z-index:2147483647!important;background:0 0!important;border:none!important;margin:0!important;padding:0!important;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif!important;font-size:16px!important;line-height:1.5!important;display:block!important;position:relative!important}:host *,:host :before,:host :after{box-sizing:border-box}.flowengage-widget-root{-moz-osx-font-smoothing:grayscale;text-rendering:optimizelegibility;color:#111827!important;-webkit-font-smoothing:antialiased!important;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif!important;font-size:16px!important;line-height:1.5!important}.flowengage-widget-root *,.flowengage-widget-root :before,.flowengage-widget-root :after{font-family:inherit!important}.flowengage-widget-root input,.flowengage-widget-root textarea,.flowengage-widget-root button,.flowengage-widget-root select,.flowengage-widget-root optgroup,.flowengage-widget-root option{font-family:inherit!important;font-size:inherit!important;line-height:inherit!important}.flowengage-shell,.flowengage-shell *{font-family:inherit!important}.flowengage-chat-panel{border:none;border-radius:0;outline:none;flex-direction:column;width:100%;height:100%;display:flex;position:relative;overflow:hidden;box-shadow:0 20px 50px #00000026}.flowengage-chat-text-input{margin:0!important}.flowengage-chat-text-input:focus{box-shadow:none!important;border:none!important;outline:none!important}@media (width>=768px){.flowengage-chat-panel{border-radius:24px;width:min(423px,100vw - 40px);height:min(700px,100vh - 120px)}}.flowengage-shell[data-open=true]{inset:0}@media (width>=768px){.flowengage-shell[data-open=true]{inset:auto 1.5rem 1.5rem auto}}.flowengage-logo-fallback{background:conic-gradient(from 180deg, var(--flowengage-primary) 0%, var(--flowengage-accent) 45%, var(--flowengage-primary) 100%)}.fe-bot-message p{margin:0 0 .5em}.fe-bot-message p:last-child{margin-bottom:0}.fe-bot-message ul,.fe-bot-message ol{margin:.4em 0 .4em 1.2em;padding:0}.fe-bot-message li{margin-bottom:.25em}.fe-bot-message strong{font-weight:600}.fe-bot-message a{color:var(--flowengage-primary);text-decoration:underline}.fe-bot-message a:hover{opacity:.8}.incoming-call-overlay{z-index:1000;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);background:#1a1a2ef2;justify-content:center;align-items:center;transition:all .3s ease-in-out;display:flex;position:absolute;left:0;right:0}.incoming-call-overlay.bottom-mode{border-top:2px solid #ffffff1a;min-height:120px;animation:.4s cubic-bezier(.16,1,.3,1) slideUpBanner;top:auto;bottom:0;box-shadow:0 -10px 30px #00000080}.incoming-call-overlay.header-mode{border-bottom:2px solid #ffffff1a;min-height:80px;animation:.4s cubic-bezier(.16,1,.3,1) slideDownBanner;top:0;bottom:auto;box-shadow:0 10px 30px #00000080}.incoming-call-container{justify-content:space-between;align-items:center;gap:14px;width:100%;padding:14px 16px;display:flex}.incoming-call-container.connected-layout{flex-direction:column;justify-content:center;align-items:stretch;gap:14px}.call-connected-top{justify-content:space-between;align-items:center;gap:16px;width:100%;display:flex}.call-connected-identity{flex:1;align-items:center;gap:14px;min-width:0;display:flex}.call-icon-wrapper{color:#fff;z-index:1;border-radius:9999px;flex-shrink:0;justify-content:center;align-items:center;width:54px;height:54px;margin-right:4px;display:flex;position:relative}.call-icon-wrapper.incoming{background:linear-gradient(135deg,#4caf50,#45a049);animation:1s ease-in-out infinite bounce}.call-icon-wrapper.connecting{background:linear-gradient(135deg,#2196f3,#1976d2)}.call-icon-wrapper.connected{background:linear-gradient(135deg,#4caf50,#45a049)}.call-pulse-animation{z-index:-1;background:#4caf504d;border-radius:50%;width:120px;height:120px;animation:1.5s ease-out infinite pulse;position:absolute}.call-connecting-animation{z-index:-1;border:3px solid #0000;border-top-color:#2196f3;border-radius:50%;width:100px;height:100px;animation:1s linear infinite spin;position:absolute}.call-info-group{flex-direction:column;flex:1;min-width:0;margin-right:8px;display:flex}.call-title{color:#fff;white-space:normal;text-overflow:clip;margin:0;font-size:16px;font-weight:700;line-height:1.2;overflow:visible}.call-subtitle{color:#ffffffb3;white-space:normal;text-overflow:clip;margin:4px 0 0;font-size:12px;line-height:1.35;overflow:visible}.call-timer{text-align:center;color:#fff;flex-shrink:0;min-width:54px;font-size:13px;font-weight:700}.call-actions{flex-shrink:0;align-items:center;gap:8px;display:flex}.call-actions.connected{justify-content:center;width:100%}.flowengage-call-btn{cursor:pointer;color:#fff;border:none;border-radius:8px;justify-content:center;align-items:center;gap:6px;min-width:92px;padding:8px 12px;font-size:12px;font-weight:600;line-height:1;transition:transform .2s,box-shadow .2s,background .2s;display:flex}.flowengage-call-btn svg{flex-shrink:0;display:block}.flowengage-call-btn span{justify-content:center;align-items:center;line-height:1;display:flex}.flowengage-call-btn.icon-only{border-radius:9999px;width:46px;min-width:46px;height:46px;padding:0}.flowengage-call-btn-accept{background:linear-gradient(135deg,#4caf50,#45a049);box-shadow:0 8px 24px #4caf5066}.flowengage-call-btn-reject,.flowengage-call-btn-end{background:linear-gradient(135deg,#f44336,#d32f2f);box-shadow:0 4px 12px #f4433666}.flowengage-call-btn-mute{background:#ffffff1a;border:2px solid #fff3}.flowengage-call-btn-mute.active{background:#f443364d;border-color:#f44336}.flowengage-call-btn:hover:not(:disabled){transform:scale(1.05)}.incoming-call-overlay.header-mode .flowengage-call-btn{border-radius:9999px!important;width:36px!important;min-width:36px!important;height:36px!important;padding:0!important}.incoming-call-overlay.header-mode .flowengage-call-btn span{display:none!important}.incoming-call-overlay.header-mode .call-icon-wrapper{width:40px;height:40px;margin-right:0}.incoming-call-overlay.header-mode .call-info-group{min-width:0}.incoming-call-overlay.header-mode .call-title,.incoming-call-overlay.header-mode .call-subtitle{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}@media (width<=640px){.incoming-call-container{align-items:flex-start;gap:10px;padding:12px 14px}.incoming-call-container.connected-layout{align-items:stretch}.call-connected-top{flex-direction:column;align-items:flex-start;gap:10px}.call-connected-identity{width:100%}.call-info-group{margin-right:0}.call-actions{flex-wrap:wrap;align-self:stretch;gap:6px}.call-actions.connected{justify-content:stretch}.call-actions.connected .flowengage-call-btn{flex:1}.flowengage-call-btn{min-width:78px;padding:8px 10px}}@keyframes slideUpBanner{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes slideDownBanner{0%{transform:translateY(-100%)}to{transform:translateY(0)}}@keyframes bounce{0%,to{transform:translateY(0)}50%{transform:translateY(-10px)}}@keyframes pulse{0%{opacity:1;transform:scale(.8)}to{opacity:0;transform:scale(2)}}@keyframes spin{to{transform:rotate(360deg)}}.fe-screen-fade-in{animation:.4s cubic-bezier(.16,1,.3,1) forwards feFadeIn}@keyframes feFadeIn{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.flowengage-initial-bg{background-color:#fff;position:relative;overflow:hidden}.flowengage-initial-bg:before{content:"";background:linear-gradient(to bottom, var(--flowengage-primary) 0%, var(--flowengage-accent) 55%, white 82%);opacity:0;pointer-events:none;z-index:0;transition:opacity .6s cubic-bezier(.4,0,.2,1);position:absolute;inset:0}.flowengage-initial-bg.is-initial:before{opacity:1}.flowengage-content-wrapper{z-index:1;flex-direction:column;flex:1;min-height:0;display:flex;position:relative}`,jO=null,MO=!1;function NO(){let e=document.createElement(`div`);e.id=`flowengage-root`;let t=e.attachShadow({mode:`open`}),n=document.createElement(`style`);n.textContent=AO,t.appendChild(n);let r=document.createElement(`div`);return r.setAttribute(`data-flowengage-mount`,`true`),r.className=`flowengage-widget-root`,t.appendChild(r),{host:e,mount:r}}function PO(e){if(document.body){e();return}let t=new MutationObserver(()=>{document.body&&(t.disconnect(),e())});t.observe(document.documentElement,{childList:!0})}function FO({siteId:e,language:t=`en`,widgetSettings:n={},apiBaseUrl:r}){if(MO){console.warn(`[FlowEngage] Already initialized. Call FlowEngage.destroy() first to re-initialize.`);return}if(!e){console.error(`[FlowEngage] siteId is required. Pass it via data-site-id attribute or FlowEngage.init({ siteId: 'YOUR_SITE_ID' }).`);return}if(!document.body){console.error(`[FlowEngage] document.body is not available yet. The widget will auto-retry once the DOM is ready.`),PO(()=>FO({siteId:e,language:t,widgetSettings:n,apiBaseUrl:r}));return}if(document.getElementById(`flowengage-root`)){console.warn(`[FlowEngage] #flowengage-root already exists. Skipping duplicate mount.`);return}let{host:i,mount:a}=NO();document.body.appendChild(i),jO=(0,x.createRoot)(a);let o={widgetSettings:n,...r&&{apiBaseUrl:r}};jO.render(b.createElement(Mn,{siteId:e,language:t,config:o},b.createElement(kO))),MO=!0}var IO={init({siteId:e,language:t=`en`,widgetSettings:n={},apiBaseUrl:r}={}){document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>PO(()=>FO({siteId:e,language:t,widgetSettings:n,apiBaseUrl:r}))):PO(()=>FO({siteId:e,language:t,widgetSettings:n,apiBaseUrl:r}))},destroy(){jO&&=(jO.unmount(),null);let e=document.getElementById(`flowengage-root`);e&&e.remove();let t=document.getElementById(`flowengage-styles`);t&&t.remove(),MO=!1}},LO=()=>{let e=document.currentScript;(!e||!e.getAttribute(`data-site-id`))&&(e=document.querySelector(`script[data-site-id]`));let t=e?.getAttribute(`data-site-id`);if(!t)return;let n=e?.getAttribute(`data-language`)||`en`,r=e?.getAttribute(`data-api-url`)||void 0,i={};try{let t=e?.getAttribute(`data-widget-settings`);t&&(i=JSON.parse(t))}catch{}let a={widgetSettings:i,...r&&{apiBaseUrl:r}};PO(()=>FO({siteId:t,language:n,widgetSettings:a.widgetSettings,apiBaseUrl:r}))};return document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,LO):LO(),typeof window<`u`&&(window.FlowEngage=IO),IO})();