@flowengage/react-chatbot 8.0.80 → 8.0.81

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.
@@ -30,7 +30,7 @@ Error generating stack: `+e.message+`
30
30
  box-shadow: none !important;
31
31
  transition: outline-color 0.25s ease, box-shadow 0.25s ease !important;
32
32
  }
33
- `,document.head.appendChild(e)};function ur(e,t){if(typeof document>`u`)return null;if(e){let n=document.getElementById(e)||document.querySelector(`[data-section="${e}"]`);if(n)return n;t||=e.replace(/[-_]+/g,` `).trim()}if(!t)return null;let n=t.toLowerCase().trim(),r=n.split(/\s+/).filter(e=>e.length>2),i=Array.from(document.querySelectorAll(`h1.h2.h3.h4.h5.h6.[data-section].section[id].[id].main li.article li.[role='main'] li.[class*='card'].[class*='Card'].[class*='feature'].[class*='Feature'].[class*='tier'].[class*='Tier'].[class*='plan'].[class*='Plan'].[class*='pricing'].[class*='Pricing'].[class*='testimonial'].[class*='Testimonial'].[class*='team'].[class*='Team'].[class*='service'].[class*='Service'].[class*='block'].[role='listitem'].[role='article'].[role='region'].dt.dd`.split(`.`).join(`, `))).filter(e=>{if(jn(e))return!1;let t=e.textContent.trim();return!(t.length<3||t.length>5e3||e.closest(`nav, footer, header, aside, .nav, .footer, .header`))});for(let e of i)if(Mn(e).toLowerCase()===n)return e;for(let e of i){let t=Mn(e).toLowerCase();if(t.startsWith(n)||t.endsWith(n))return e}let a=[];for(let e of i){let t=Mn(e).toLowerCase();t.includes(n)&&a.push({el:e,len:t.length})}if(a.length)return a.sort((e,t)=>e.len-t.len),a[0].el;for(let e of i){let t=Mn(e).toLowerCase();if(t.length>3&&n.includes(t))return e}if(r.length>0){let e=null,t=0;for(let n of i){let i=Mn(n).toLowerCase(),a=0;for(let e of r)i.includes(e)&&a++;let o=a/r.length;o>t&&o>=.6&&(t=o,e=n)}if(e)return e}let o=Array.from(document.querySelectorAll(`main [role='group']`)).filter(e=>!jn(e)),s=[];for(let e of o){let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();t.length<15||t.length>8e3||t.includes(n)&&s.push({el:e,len:t.length})}if(s.length)return s.sort((e,t)=>e.len-t.len),s[0].el;if(r.length>0){let e=Array.from(document.querySelectorAll(`main a[href], article a[href], .views-row a[href], h2 a[href], h3 a[href], .card a[href], [class*='teaser'] a[href]`)).filter(e=>{if(jn(e))return!1;try{let t=e.getAttribute(`href`)||``;if(!t||t===`#`||t.startsWith(`javascript:`))return!1}catch{return!1}let t=e.textContent.replace(/\s+/g,` `).trim();return t.length>=3&&t.length<=220}),t=null,n=0;for(let i of e){let e=i.textContent.replace(/\s+/g,` `).toLowerCase(),a=0;for(let t of r)e.includes(t)&&a++;let o=a/r.length;o>n&&o>=.5&&(n=o,t=i)}if(t)return t.closest(`article`)||t.closest(`.views-row`)||t}let c=document.querySelectorAll(`section, article, .card, [class*='feature'], [class*='service']`);for(let e of c){if(jn(e))continue;let t=e.querySelector(`h1, h2, h3, h4, h5, h6`);if(t){let r=t.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(r.includes(n)||n.includes(r))return e}}let l=document.querySelectorAll(`li, strong, blockquote, dt`);for(let e of l){if(jn(e))continue;let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<500)return e.tagName===`STRONG`&&e.parentElement?.tagName===`LI`?e.parentElement:e}let u=Array.from(document.querySelectorAll(`a[href]`)).filter(e=>!jn(e));u.sort((e,t)=>(e.textContent||``).trim().length-(t.textContent||``).trim().length);for(let e of u){let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<500)return e}let d=document.querySelectorAll(`p`);for(let e of d){if(jn(e))continue;let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<800)return e}return null}function dr(e,{speaking:t=!1,scroll:n=!0}={}){if(!e||typeof document>`u`)return;lr();let r=document.querySelectorAll(`.fe-highlight-section`);for(let t of r)t!==e&&(t.classList.remove(`fe-highlight-section`,`fe-highlight-speaking`),t.classList.add(`fe-highlight-exiting`),setTimeout(()=>t.classList.remove(`fe-highlight-exiting`),300));if(e.classList.remove(`fe-highlight-exiting`),e.classList.add(`fe-highlight-section`),t?e.classList.add(`fe-highlight-speaking`):e.classList.remove(`fe-highlight-speaking`),n)try{e.scrollIntoView({behavior:`smooth`,block:`center`})}catch{try{e.scrollIntoView(!0)}catch{}}}function fr(){typeof document>`u`||(document.querySelectorAll(`.fe-highlight-section, .fe-highlight-exiting`).forEach(e=>e.classList.remove(`fe-highlight-section`,`fe-highlight-speaking`,`fe-highlight-exiting`)),kn())}function pr(e){if(typeof window>`u`)return e;try{let t=new URL(String(e).trim(),window.location.href);return!/^https?:$/i.test(t.protocol)||t.origin===window.location.origin?t.href:new URL(t.pathname+t.search+t.hash,window.location.origin).href}catch{return e}}async function mr(e){if(typeof window>`u`)return!1;try{let t=new URL(String(e).trim(),window.location.href),n=t.origin===window.location.origin?t.href:new URL(t.pathname+t.search+t.hash,window.location.origin).href;return(await fetch(n,{method:`HEAD`,mode:`same-origin`,cache:`no-store`})).ok}catch{return!1}}async function hr(e,{siteId:t,apiBaseUrl:n}){if(!e)return{allowed:!1,correctedUrl:null};let r=!1;try{r=!!Yn()}catch{r=!1}let i=async()=>({allowed:r?!1:await mr(e),correctedUrl:null});if(!t||!n)return console.warn(`[FlowEngage] shouldProceedWithNavigation: missing siteId or apiBaseUrl`),i();let a=String(n).replace(/\/$/,``),o=new URLSearchParams({siteId:String(t),url:String(e).trim()});try{let e=await(await fetch(`${a}/api/widget/navigate-allowed?${o.toString()}`)).json().catch(()=>({}));return e.success&&e.allowed?{allowed:!0,correctedUrl:e.correctedUrl||null}:i()}catch(e){return console.warn(`[FlowEngage] navigate-allowed check failed:`,e?.message),i()}}function gr(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(Pn,JSON.stringify({sectionText:e,ts:Date.now()}))}catch{}}async function _r(e,{skipPushState:t=!1,isBack:n=!1}={}){if(typeof window>`u`||typeof document>`u`)return!1;try{if(new URL(e,window.location.href).origin!==window.location.origin)return!1}catch{return!1}or();let r=new AbortController,i=setTimeout(()=>r.abort(),8e3);try{let a=await fetch(e,{credentials:`same-origin`,cache:`no-store`,signal:r.signal});if(clearTimeout(i),!a.ok)return sr(),!1;let o=await a.text(),s=new DOMParser().parseFromString(o,`text/html`),c=document.getElementById(`flowengage-root`);if(!c)return sr(),!1;try{typeof window.Drupal?.detachBehaviors==`function`&&window.Drupal.detachBehaviors(document.body,window.drupalSettings)}catch{}document.querySelectorAll(`script`).forEach(e=>{e.setAttribute(`data-fe-original`,`true`)}),Array.from(document.body.children).forEach(e=>{if(e===c)return;let t=e.tagName?.toUpperCase();t===`AUDIO`||t===`VIDEO`||e.remove()}),Zn();let l=new Set(Array.from(document.querySelectorAll(`link[rel='stylesheet']`)).map(e=>{try{return new URL(e.getAttribute(`href`)||``,window.location.href).href}catch{return``}}));for(let t of Array.from(s.head.querySelectorAll(`link[rel='stylesheet']`))){let n=t.getAttribute(`href`);if(!n)continue;let r;try{r=new URL(n,e).href}catch{continue}if(l.has(r))continue;let i=document.createElement(`link`);i.rel=`stylesheet`,i.href=r,i.setAttribute(Xn,`true`),t.media&&(i.media=t.media),document.head.appendChild(i)}for(let e of Array.from(s.head.querySelectorAll(`style`))){if(!e.textContent.trim())continue;let t=e.textContent.trim().slice(0,120);if(Array.from(document.head.querySelectorAll(`style:not([data-fe-swap-css])`)).some(e=>e.textContent.trim().slice(0,120)===t))continue;let n=document.createElement(`style`);n.textContent=e.textContent,n.setAttribute(Xn,`true`),document.head.appendChild(n)}Array.from(s.body.children).forEach(e=>{e.tagName?.toUpperCase()!==`SCRIPT`&&document.body.insertBefore(document.importNode(e,!0),c)});let u=document.querySelectorAll(`script:not([data-fe-replayed])`);for(let e of u){if(e.closest(`#flowengage-root, .flowengage-shell`)||e.hasAttribute(`data-fe-original`)||e.hasAttribute(`data-fe-replayed`))continue;let t=e.getAttribute(`src`),n=e.getAttribute(`type`)||``;if(!(n&&n!==`text/javascript`&&n!==``&&!n.includes(`drupal-ajax`))){if(n.includes(`drupal-ajax`)){e.setAttribute(`data-fe-replayed`,`true`);try{let t=JSON.parse(e.textContent);if(Array.isArray(t))for(let e of t){if((e.command===`insert`||e.command===`insert_new_content`)&&e.selector&&e.data){let t=document.querySelector(e.selector);t&&(e.method===`replaceWith`?t.outerHTML=e.data:e.method===`html`||e.method===`replace`?t.innerHTML=e.data:e.method===`append`?t.insertAdjacentHTML(`beforeend`,e.data):e.method===`prepend`?t.insertAdjacentHTML(`afterbegin`,e.data):t.innerHTML=e.data,Nn(`trySpaNavigate: BigPipe replacement →`,e.selector))}if(e.command===`settings`&&e.settings)try{window.drupalSettings&&typeof window.drupalSettings==`object`&&Object.assign(window.drupalSettings,e.settings)}catch{}}}catch(e){Nn(`trySpaNavigate: BigPipe parse error:`,e.message)}continue}if(!t&&e.textContent.trim()){let t=e.textContent;if(/window\.location\s*[.=]|location\s*\.\s*(href|assign|replace|reload)\s*[=(]/i.test(t)){e.setAttribute(`data-fe-replayed`,`true`);continue}let n=document.createElement(`script`);n.textContent=t,n.setAttribute(`data-fe-replayed`,`true`),e.parentNode.replaceChild(n,e)}}}try{for(let e of Array.from(s.querySelectorAll(`script`))){let t=(e.textContent||``).match(/drupalSettings\s*[,=]\s*(\{[\s\S]*?\})\s*[;)]/);if(t){try{let e=JSON.parse(t[1]);window.drupalSettings&&typeof window.drupalSettings==`object`?Object.assign(window.drupalSettings,e):window.drupalSettings=e,Nn(`trySpaNavigate: updated drupalSettings from new page`)}catch{}break}}}catch{}let d=window.location.assign.bind(window.location),f=window.location.replace.bind(window.location),p=!0;window.location.assign=e=>{if(p){Nn(`trySpaNavigate: blocked location.assign from replayed script:`,e);return}return d(e)},window.location.replace=e=>{if(p){Nn(`trySpaNavigate: blocked location.replace from replayed script:`,e);return}return f(e)};function m(e){let t=e.toLowerCase();return!!(/\/jquery[.\-\/]/.test(t)||/\/jquery\.min\.js/.test(t)||/\/jquery-once/.test(t)||/\/jquery\.once/.test(t)||/\/jquery\.ui[\./]/.test(t)||/\/jqueryui/.test(t)||/\/core\/misc\//.test(t)||/\/core\/modules\//.test(t)||/\/misc\/drupal\.js/.test(t)||/\/lodash[.\-\/]/.test(t)||/\/underscore[.\-\/]/.test(t)||/\/backbone[.\-\/]/.test(t)||/\/modernizr[.\-\/]/.test(t)||/\/popper[.\-\/]/.test(t)||/\/bootstrap\.min\.js/.test(t)||/\/bootstrap\.bundle/.test(t))}let h=new Set(Array.from(document.querySelectorAll(`script[src]`)).map(e=>{try{return new URL(e.getAttribute(`src`)||``,window.location.href).href}catch{return``}}));function g(t,n){let r=t.getAttribute(`src`)||``;if(r.includes(`flowengage`))return;let i=document.createElement(`script`);if(r){let n;try{n=new URL(r,e).href}catch{return}if(h.has(n)){if(m(n))return;Nn(`trySpaNavigate: re-running theme/custom script:`,n)}h.add(n),i.src=n,i.async=t.async,i.defer=t.defer}else if(t.textContent.trim()){let e=t.textContent;if(/window\.location\s*[.=]|location\s*\.\s*(href|assign|replace|reload)\s*[=(]/i.test(e)){Nn(`trySpaNavigate: skipping inline script with navigation:`,e.slice(0,120));return}if(/^\s*\(?\s*(?:window\.)?drupalSettings\s*[,=]/.test(e))return;i.textContent=e}else return;let a=t.getAttribute(`type`);a&&a!==`text/javascript`&&a!==``&&(i.type=a),n.parentNode.insertBefore(i,n)}for(let e of Array.from(s.head.querySelectorAll(`script`)))g(e,c);for(let e of Array.from(s.body.querySelectorAll(`script`)))g(e,c);try{typeof window.Drupal?.attachBehaviors==`function`&&window.Drupal.attachBehaviors(document.body,window.drupalSettings)}catch{}try{typeof window.jQuery==`function`&&(window.jQuery(document).trigger(`ready`),window.dispatchEvent(new Event(`resize`)))}catch{}try{document.dispatchEvent(new Event(`DOMContentLoaded`,{bubbles:!0,cancelable:!1}))}catch{}try{window.dispatchEvent(new Event(`load`))}catch{}try{let e=document.querySelectorAll(`iframe:not([data-fe-skip-reload])`);for(let t of e){if(t.closest(`#flowengage-root, .flowengage-shell`))continue;let e=t.getAttribute(`src`)||t.src;e&&e!==`about:blank`&&!e.startsWith(`javascript:`)&&(Nn(`trySpaNavigate: reloading iframe:`,e),t.src=e)}}catch{}try{let e=document.querySelectorAll(`.g-recaptcha, [data-sitekey]`);if(e.length>0){if(typeof window.grecaptcha?.render==`function`){for(let t of e)if(!t.closest(`#flowengage-root`)){t.innerHTML=``;try{window.grecaptcha.render(t,{sitekey:t.getAttribute(`data-sitekey`)||``}),Nn(`trySpaNavigate: re-rendered reCAPTCHA`)}catch{}}}else if(!document.querySelector(`script[src*='recaptcha']`)){let e=document.createElement(`script`);e.src=`https://www.google.com/recaptcha/api.js?render=explicit`,e.async=!0,document.head.appendChild(e),Nn(`trySpaNavigate: injected reCAPTCHA script`)}}}catch{}if(setTimeout(()=>{p=!1,window.location.assign=d,window.location.replace=f},2e3),s.title&&(document.title=s.title),!t)try{history.pushState({flowengageSpa:!0},``,e)}catch{}if(Wn(),Kn(),n){try{er()}catch{}try{rr()}catch{}}else window.scrollTo(0,0);sr(),ir(e);try{sessionStorage.removeItem(Pn)}catch{}try{sessionStorage.removeItem(In)}catch{}try{Un=new URL(e,window.location.origin).pathname}catch{}return Nn(`trySpaNavigate: succeeded →`,e),!0}catch{return clearTimeout(i),sr(),!1}}function vr(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(In,JSON.stringify({voiceWasActive:!0,targetUrl:String(e),ts:Date.now()}))}catch{}}function yr(){if(!(typeof sessionStorage>`u`))try{sessionStorage.removeItem(In)}catch{}}function br(){if(typeof window>`u`||typeof sessionStorage>`u`)return{shouldResumeVoice:!1,targetUrl:null};let e;try{e=JSON.parse(sessionStorage.getItem(In)||`null`)}catch{return{shouldResumeVoice:!1,targetUrl:null}}if(!e)return{shouldResumeVoice:!1,targetUrl:null};try{sessionStorage.removeItem(In)}catch{}return e.voiceWasActive?Date.now()-e.ts>Ln?(Nn(`initVoiceNavResume: state expired, skipping`),{shouldResumeVoice:!1,targetUrl:null}):(Nn(`initVoiceNavResume: voice was active during navigation to`,e.targetUrl),{shouldResumeVoice:!0,targetUrl:e.targetUrl||null}):{shouldResumeVoice:!1,targetUrl:null}}function xr(){if(typeof document>`u`)return!1;let e=/(^|\W)(404|page not found|not found|page (?:doesn'?t|does not) exist|no longer exists|couldn'?t find (?:this|that|the) page|error 404|oops[!,. ].*(?:not found|doesn'?t exist))(\W|$)/i,t=(document.title||``).trim();if(t&&e.test(t))return!0;let n=document.querySelector(`main, [role="main"], #content, .content`)||document.body;if(n){let t=n.querySelectorAll(`h1, h2`);for(let n of t){let t=(n.textContent||``).replace(/\s+/g,` `).trim();if(t&&t.length<80&&e.test(t))return!0}}return!1}async function Sr(e,t={}){if(typeof window>`u`)return{navigated:!1};let{sectionText:n,voiceActive:r=!1}=t;try{let t=pr(e),i=new URL(t,window.location.origin);if(i.hash&&i.pathname===window.location.pathname){let e=document.getElementById(i.hash.slice(1));if(e)return e.scrollIntoView({behavior:`smooth`,block:`start`}),{navigated:!0}}if(i.pathname===window.location.pathname&&i.search===window.location.search&&!i.hash)return{navigated:!1,reason:`already-on-page`};let a=i.pathname+i.search+i.hash,o=window.next?.router;if(o?.push)return new Promise(e=>{let t=()=>{o.events?.off(`routeChangeComplete`,t),e({navigated:!0})};o.events?.on(`routeChangeComplete`,t),o.push(a),setTimeout(t,5e3)});if(window.__NEXT_ROUTER__?.push)return window.__NEXT_ROUTER__.push(a),{navigated:!0};if(Yn()){n&&gr(n);let e=window.location.href;try{window.history.pushState({},``,i.href),window.dispatchEvent(new PopStateEvent(`popstate`,{state:{}}))}catch{}if(await new Promise(e=>setTimeout(e,400)),xr()){try{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`,{state:{}}))}catch{}return n&&gr(n),r||Ee(),window.location.assign(i.href),{navigated:!0}}return{navigated:!0}}return n&&gr(n),r||Ee(),window.location.assign(i.href),{navigated:!0}}catch(t){console.warn(`[FlowEngage] shadowNavigate error:`,t),n&&gr(n);try{window.location.href=pr(e)}catch{window.location.href=e}return{navigated:!0}}}var Cr=!1,wr=null;function Tr(e){wr=e,typeof window<`u`&&(window.__fe_triggerVoiceNavHooks=()=>{try{e.onBeforeNavigate()}catch{}}),!Cr&&(Cr=!0,!(typeof document>`u`)&&(document.addEventListener(`click`,e=>{if(!wr)return;let t=e.target.closest?.(`a[href]`);if(!t||t.closest(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`))return;let n=t.getAttribute(`href`)||``;if(!n||n===`#`||n.startsWith(`javascript:`)||n.startsWith(`mailto:`)||n.startsWith(`tel:`)||t.hasAttribute(`download`)||t.target===`_blank`||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let r;try{if(r=new URL(n,window.location.href),r.origin!==window.location.origin)return}catch{return}if(!(r.pathname===window.location.pathname&&r.hash)&&!(r.pathname===window.location.pathname&&r.search===window.location.search&&!r.hash)){Nn(`voice-link-hook: saving state before navigation →`,r.href);try{wr.onBeforeNavigate()}catch{}}},!0),document.addEventListener(`submit`,e=>{if(wr&&!e.target?.closest?.(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)){Nn(`voice-form-hook: saving state before form submit`);try{wr.onBeforeNavigate()}catch{}}},!0)))}function Er(){wr=null,Nn(`voice-nav-hooks: deactivated`)}var Dr=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),H=s(((e,t)=>{t.exports=Dr()}))(),Or=e=>!e||typeof e!=`string`?e:e.replace(/<human_assistance_request[^>]*>/gi,``).replace(/<\/human_assistance_request>/gi,``).replace(/<navigate[^>]*\/>/gi,``).replace(/<navigate[^>]*>[\s\S]*?<\/navigate>/gi,``).replace(/<[a-z]+(?:_[a-z]+)+[^>]*>[\s\S]*?<\/[a-z]+(?:_[a-z]+)+>/gi,``).replace(/<[a-z]+(?:_[a-z]+)+[^>]*\/>/gi,``).trim(),kr=(e=[])=>e.filter(e=>e.type!==`call_recording`&&!(typeof e.message==`string`&&e.message.includes(`AI chat recording`))).map(e=>({...e,message:Or(e.message),isPending:!1,id:e.messageId||`${e.sender}-${e.timestamp||Date.now()}-${Math.random()}`}));function Ar(e){if(!e||typeof e!=`string`)return null;let t=e.match(/<navigate([^>]*?)(?:\/>|>[\s\S]*?<\/navigate>)/i);if(!t)return null;let n=t[1],r=n.match(/url=["']([^"']+)["']/i);if(!r)return null;let i=n.match(/section=["']([^"']+)["']/i)||n.match(/highlight=["']([^"']+)["']/i);return{url:r[1].trim(),section:i?.[1]?.trim()||null}}var jr=(e,t)=>e?typeof e==`string`?e:e.message||e.error||e.reason||t:t,Mr=(e={})=>{if(!e?.candidate)return null;if(typeof e.candidate==`object`)return e.candidate;let t=e.sdpMid!==void 0&&e.sdpMid!==null&&e.sdpMid!==``,n=e.sdpMLineIndex!==void 0&&e.sdpMLineIndex!==null;return!t&&!n?null:{candidate:e.candidate,...t?{sdpMid:e.sdpMid}:{},...n?{sdpMLineIndex:e.sdpMLineIndex}:{}}},Nr=(e=[],t=`Agent`)=>{for(let t of e)if(typeof t==`string`&&t.trim())return t.trim();return t},Pr=(e=[],t,n=6)=>!t?.message||e.slice(-n).some(e=>e.sender===`system`&&e.message===t.message)?e:[...e,t];function Fr({siteId:e,config:t,children:n,language:r=`en`}){let i=(0,b.useMemo)(()=>e?{...t||{},siteId:e}:t||null,[e,t]),[a,o]=(0,b.useState)(0),[s,c]=(0,b.useState)(`booting`),[l,u]=(0,b.useState)(null),[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(``),[h,g]=(0,b.useState)([]),_=(0,b.useCallback)(()=>{g(e=>[...e,{id:`nav-fail-${e.length}-${Math.random().toString(36).slice(2,8)}`,sender:`bot`,message:`I couldn't find that page on our site — could you tell me more about what you're looking for?`,timestamp:new Date().toISOString()}])},[]),v=(0,b.useCallback)(()=>{g(e=>e.slice(-3).some(e=>(e.sender===`bot`||e.sender===`assistant`)&&/already on (that|this|the)\b/i.test(String(e.message||``)))?e:[...e,{id:`nav-already-${e.length}-${Math.random().toString(36).slice(2,8)}`,sender:`bot`,message:`Looks like you're already on this page!`,timestamp:new Date().toISOString()}])},[]),[y,x]=(0,b.useState)(j().isOpen),[C,w]=(0,b.useState)(j().activeScreen),[T,E]=(0,b.useState)(j().isHumanHandled),[O,ne]=(0,b.useState)(j().agentName),[oe,k]=(0,b.useState)(j().agentHeadshot),[A,se]=(0,b.useState)(()=>de(i?.siteId)),[N,pe]=(0,b.useState)(!1),[me,ge]=(0,b.useState)(!1),[P,_e]=(0,b.useState)(`idle`),[ve,ye]=(0,b.useState)(!1),[be,xe]=(0,b.useState)(!1),[Se,we]=(0,b.useState)(``),[Te,Ee]=(0,b.useState)(!1),[De,Oe]=(0,b.useState)(0),[F,ke]=(0,b.useState)(0),[Ae,je]=(0,b.useState)(!1),[I,Fe]=(0,b.useState)(null),[Ie,Le]=(0,b.useState)(null),[Re,L]=(0,b.useState)(`idle`),[ze,Be]=(0,b.useState)(null),[Ve,He]=(0,b.useState)(!1),[Ue,We]=(0,b.useState)(``),[Ge,Ke]=(0,b.useState)(!1),qe=(0,b.useRef)(null),R=(0,b.useRef)(null),Je=(0,b.useRef)(``),Ye=(0,b.useRef)(!1),Xe=(0,b.useRef)(null),z=(0,b.useRef)(null),Ze=(0,b.useRef)(null),Qe=(0,b.useRef)(null),$e=(0,b.useRef)(null),et=(0,b.useRef)(null),tt=(0,b.useRef)(null),nt=(0,b.useRef)(!1),rt=(0,b.useRef)({url:null,at:0}),B=(0,b.useCallback)((e,t)=>{let n=e;try{n=new URL(e,window.location.origin).href}catch{}let r=rt.current;return r.url===n&&Date.now()-r.at<4e3?Promise.resolve({navigated:!0,deduped:!0}):(rt.current={url:n,at:Date.now()},Sr(e,t))},[]),it=(0,b.useRef)([]),at=(0,b.useRef)(null),ot=(0,b.useRef)(null),st=(0,b.useRef)(null),ct=(0,b.useRef)(!1),lt=(0,b.useRef)(!1),ut=(0,b.useRef)(``),dt=(0,b.useRef)(null),ft=(0,b.useRef)(null),pt=(0,b.useRef)([]),mt=(0,b.useRef)(0),ht=(0,b.useRef)(O),gt=(0,b.useRef)([]),_t=(0,b.useRef)(!1),vt=(0,b.useRef)(!1),yt=(0,b.useRef)(i),bt=(0,b.useRef)({notifyRouteChange:()=>{},cleanup:()=>{}}),xt=(0,b.useCallback)((e={})=>{let t=!!e.is_human_handled;return E(t),t?(w(`agent`),e.agent_info?.name&&ne(e.agent_info.name),e.agent_info?.headshot&&k(e.agent_info.headshot),t):(w(`ai`),t)},[]),St=(0,b.useMemo)(()=>{let e=d?.widgetSettings?.call?.maxDurationSeconds??i?.widgetSettings?.call?.maxDurationSeconds??i?.callMaxDurationSeconds,t=Number(e);return Number.isFinite(t)&&t>0?t:te},[i,d]);(0,b.useEffect)(()=>{z.current=I},[I]),(0,b.useEffect)(()=>{ht.current=O},[O]),(0,b.useEffect)(()=>{vt.current=Te},[Te]),(0,b.useEffect)(()=>{yt.current=i},[i]);let Ct=()=>{We(``)},wt=(0,b.useCallback)(()=>{st.current&&=(window.clearTimeout(st.current),null)},[]),Tt=e=>{let t=typeof e==`string`?e.trim().toLowerCase():``;return se(t),fe(t,i?.siteId),t};(0,b.useEffect)(()=>{let e=i?.siteId;if(!e)return;let t=de(e);if(t){se(t);return}se(t=>(t&&fe(t,e),t))},[i?.siteId]);let Et=(e=`unspecified`)=>{let t=at.current||et.current?.callId,n=mt.current,r=dt.current;if(dt.current=null,mt.current=0,r&&r.state!==`inactive`){r.onstop=()=>{let e=pt.current;if(pt.current=[],e.length>0&&t&&R.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;R.current.uploadRecording(t,r,i).then(e=>console.log(`[FlowEngageCall] recording upload success`,e)).catch(e=>console.warn(`[FlowEngageCall] recording upload failed`,e))}};try{r.stop()}catch{r.onstop=null,pt.current=[]}}else if(r&&r.state===`inactive`){let e=pt.current;if(pt.current=[],e.length>0&&t&&R.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;R.current.uploadRecording(t,r,i).then(e=>console.log(`[FlowEngageCall] recording upload success`,e)).catch(e=>console.warn(`[FlowEngageCall] recording upload failed`,e))}}else pt.current=[];if(ft.current){try{ft.current.close()}catch{}ft.current=null}Ze.current&&=(Ze.current.close(),null),Qe.current&&=(Qe.current.getTracks().forEach(e=>e.stop()),null),$e.current&&=($e.current.srcObject=null,$e.current.remove(),null),wt(),et.current=null,it.current=[],at.current=null,ot.current=null,ct.current=!1,He(!1),Fe(null),Le(null),L(`idle`),Be(null)},Dt=(e=new Date().toISOString())=>{let t=qe.current,n=at.current||et.current?.callId;if(!(!t?.connected||!n||ct.current)){ct.current=!0,t.emit(`call:connected`,{callId:n,chatId:Je.current,connectedAt:e});try{let e=Qe.current,t=$e.current?.srcObject;if(e&&t&&!dt.current){pt.current=[];let n=new(window.AudioContext||window.webkitAudioContext);ft.current=n;let r=n.createMediaStreamDestination();n.createMediaStreamSource(e).connect(r),n.createMediaStreamSource(t).connect(r);let i=window.MediaRecorder.isTypeSupported(`audio/webm`)?`audio/webm`:`audio/mp4`,a=new window.MediaRecorder(r.stream,{mimeType:i});a.ondataavailable=e=>{e.data&&e.data.size>0&&pt.current.push(e.data)},dt.current=a,mt.current=Date.now(),a.start(1e3),setTimeout(()=>{try{if(!window.speechSynthesis)return;let e=new SpeechSynthesisUtterance(`This call is being recorded for quality and training purposes.`);if(e.rate=.95,e.pitch=1,e.volume=1,window.MediaStreamTrackGenerator||window.AudioContext)try{let t=n.createMediaStreamDestination();e.onstart=()=>{try{let i=document.createElement(`audio`);i.style.display=`none`,i.srcObject=t.stream,document.body.appendChild(i),i.play().catch(()=>{});let a=n.createMediaStreamSource(t.stream);a.connect(r),e.onend=()=>{try{a.disconnect()}catch{}try{i.remove()}catch{}}}catch{}}}catch{}window.speechSynthesis.speak(e)}catch{}},200)}}catch{}}},Ot=(e={})=>{if(!e.callId)return;let t=ot.current===e.callId,n=at.current===e.callId,r=z.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(wt(),Fe(null),t||n){at.current=e.callId,Le(e.callId),L(e=>e===`connected`?e:`connecting`),x(!0);return}L(`idle`)}},kt=(e={})=>{if(!e.callId)return;let t=ot.current===e.callId,n=at.current===e.callId,r=z.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(wt(),n){Et();return}ot.current=null,et.current=null,it.current=[],Fe(null),L(`idle`)}},At=async(e={})=>{let t=Ze.current,n=qe.current,r=e.sdpOffer||e.offer?.sdp;if(!t||!n?.connected||!r||!e.callId){console.log(`[FlowEngageProvider] deferring remote offer until peer/socket ready`,{callId:e.callId,chatId:Je.current,hasPeerConnection:!!t,socketConnected:!!n?.connected,hasOffer:!!r}),et.current=e;return}if(await t.setRemoteDescription(new RTCSessionDescription({type:`offer`,sdp:r})),it.current.length>0){console.log(`[FlowEngageProvider] flushing queued agent ICE candidates after remote offer`,{callId:e.callId,chatId:Je.current,queuedCount:it.current.length});for(let e of it.current)await t.addIceCandidate(new RTCIceCandidate(e));it.current=[]}let i=await t.createAnswer();await t.setLocalDescription(i),n.emit(`call:answer`,{callId:e.callId,sdpAnswer:i.sdp,chatId:Je.current})};(0,b.useEffect)(()=>{M({isOpen:y,activeScreen:C,isHumanHandled:T,agentName:O,agentHeadshot:oe})},[y,C,T,O,oe]),(0,b.useEffect)(()=>{let e=!0;return(async()=>{Ke(!0);try{let t=S(i),n=await Ne(t);if(!e)return;let a=t.siteId,o=ce(a),s=he(a),l=``;try{let e=Ye.current,r=Xe.current;if(Ye.current=!1,Xe.current=null,l=(await Me({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:a,priorChatId:e||r?null:o||re(),forceNew:e,resumeChatId:r,visitorId:s}))?.data?.chatId,!l)throw Error(`resolve-session returned no chatId`);ie(),ue(a,l)}catch(e){console.warn(`[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id`,e?.message||e),l=o||ae(),ue(a,l)}Je.current=l;let u=Pe({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:t.siteId,visitorId:s});R.current=u,f({...n,apiBaseUrl:t.apiBaseUrl}),m(l);let d=n?.widgetSettings?.branding?.fallbackAgentName||`Agent`,p=xn({apiBaseUrl:t.apiBaseUrl,userId:n.userId,chatId:l,siteId:t.siteId});qe.current=p,p.on(`connect`,async()=>{_e(`connected`);let e=Je.current;if(e&&R.current)try{xt(await R.current.checkHumanHandled(e))}catch{}}),p.on(`disconnect`,()=>{_e(`disconnected`)}),p.on(`aiTyping`,()=>{ge(!0)}),p.on(`ai:typing`,()=>{ge(!0)}),p.on(`messageReceived`,e=>{let t=e.message||e,n={...t,message:Or(t.message)};ge(!1),pe(!1),!(n.type===`call_recording`||typeof n.message==`string`&&n.message.includes(`AI chat recording`))&&g(e=>[...e.filter(e=>!e.isPending),{...n,isPending:!1,id:n.messageId||`${n.sender}-${Date.now()}-${Math.random()}`}])}),p.on(`conversationStarted`,e=>{e?.message&&g(t=>[...t,{id:`system-start-${Date.now()}`,sender:`system`,message:e.message,timestamp:new Date().toISOString(),isPending:!1}])}),p.on(`message:new`,e=>{let t=e.message||e,n={...t,message:Or(t.message)};ge(!1),!(n.type===`call_recording`||typeof n.message==`string`&&n.message.includes(`AI chat recording`))&&((n.sender===`agent`||n.agent_name||n.sender===`ai`||n.sender===`bot`)&&pe(!1),g(e=>n.sender===`bot`||n.sender===`ai`?[...e,{...n,isPending:!1,id:n.messageId||`${n.sender}-${Date.now()}-${Math.random()}`}]:e.some(e=>e.id===n.messageId||e.sender===n.sender&&e.message===n.message&&e.isPending)?e.map(e=>e.sender===n.sender&&e.message===n.message&&e.isPending?{...n,isPending:!1,id:n.messageId||e.id}:e):[...e,{...n,isPending:!1,id:n.messageId||`${n.sender}-${Date.now()}-${Math.random()}`}]),(n.sender===`agent`||n.agent_name)&&(E(!0),w(`agent`),ne(Nr([n.agent_name,n.agentName,n.metadata?.agentName],d)),n.sender_headshot&&k(n.sender_headshot),x(!0),Oe(e=>e+1)))});let h=(e={})=>{let t=Nr([e.agent?.name,e.agentName,e.agent_name,ht.current],d);E(!0),w(`agent`),ne(t),k(e.agent?.headshot||null),x(!0),Oe(e=>e+1),g(e=>Pr(e,{id:`agent-joined-${Date.now()}`,sender:`system`,message:`${t} has joined the chat.`,timestamp:new Date().toISOString(),isPending:!1}))},y=(e={})=>{let t=Nr([e.agent?.name,e.agentName,e.agent_name,ht.current],d);E(!1),w(`ai`),g(e=>Pr(e,{id:`agent-left-${Date.now()}`,sender:`system`,message:`${t} has left the chat.`,timestamp:new Date().toISOString(),isPending:!1}))};p.on(`agent:joined`,h),p.on(`agentJoined`,h),p.on(`agent:left`,y),p.on(`agentLeft`,y),p.on(`conversationEnded`,e=>{je(!0);let t=e?.message||`This conversation has ended. Thank you for reaching out!`;g(e=>[...e,{id:`conversation-ended-${Date.now()}`,sender:`system`,message:t,timestamp:new Date().toISOString(),isPending:!1}])}),p.on(`chat:history_update`,e=>{let t=kr(e.chat_history||[]);g(t),t.length===0&&(je(!1),E(!1),w(`ai`),ge(!1),pe(!1))}),p.on(`conversation:reset`,()=>{g([]),je(!1),E(!1),w(`ai`),ge(!1),pe(!1)}),p.on(`voice:end_session`,(e={})=>{console.log(`[FlowEngageProvider] voice:end_session received — ending voice session`),ke(e=>e+1),x(!0),Oe(e=>e+1)}),p.on(`typing:start`,e=>{e.sender===`agent`&&pe(!0)}),p.on(`typing:stop`,e=>{e.sender===`agent`&&pe(!1)}),p.on(`call:incoming`,(e={})=>{let t=Nr([e.agentName,e.ownerName,e.agent?.name,ht.current],`Agent`);Ct(),wt(),ct.current=!1,Fe({callId:e.callId,from:e.from||`owner`,agentId:e.agentId||null,agentName:t}),ne(e=>Nr([t,e],`Agent`)),L(`incoming`),Be(null),x(!0)}),p.on(`call:offer`,async(e={})=>{et.current=e;try{await At(e)}catch(e){console.error(`[FlowEngageProvider] failed to apply remote offer`,e)}}),p.on(`call:ice-candidate-from-agent`,async(e={})=>{if(e.candidate)try{let t=Mr(e);if(!t){console.warn(`[FlowEngageProvider] ignoring invalid ICE candidate payload`,e);return}if(!Ze.current||!Ze.current.remoteDescription){console.log(`[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready`,{callId:e.callId,chatId:e.chatId||Je.current,queueSize:it.current.length+1}),it.current.push(t);return}await Ze.current.addIceCandidate(new RTCIceCandidate(t))}catch(e){console.error(`[FlowEngageProvider] failed to add ICE candidate`,e)}}),p.on(`call:ended`,()=>{Ct(),Et(`socket:call_ended`)}),p.on(`call:accepted`,(e={})=>{Ot(e)}),p.on(`call:accepted_by_other`,(e={})=>{Ot(e)}),p.on(`call:rejected`,(e={})=>{kt(e)}),p.on(`call:missed`,(e={})=>{kt(e)}),p.on(`call:failed`,(e={})=>{kt(e)}),p.on(`call:connected`,(e={})=>{if(!e.callId)return;let t=ot.current===e.callId,n=at.current===e.callId,r=et.current?.callId===e.callId,i=z.current?.callId===e.callId;if(!t&&!n&&!r){i&&(Fe(null),L(`idle`));return}ct.current=!0,ot.current=null,at.current=e.callId,Le(e.callId),Fe(null),L(`connected`),Be(e.connectedAt||new Date().toISOString()),x(!0)}),p.on(`call:unavailable`,(e={})=>{Et(`socket:call_unavailable`),We(jr(e,`This visitor is not available for a call right now.`)),x(!0)}),p.on(`call:error`,(e={})=>{Et(`socket:call_error`),We(jr(e,`We couldn't connect the call right now.`)),x(!0)}),p.on(`visitor:navigate`,async({url:e,section:t,highlight:n}={})=>{e&&B(e,{voiceActive:vt.current}).then(({navigated:e,reason:r})=>{if(!e){r===`not-found`?_():r===`already-on-page`&&v();return}let i=t||n;i&&setTimeout(()=>{let e=ur(null,i);e&&dr(e)},300)})}),p.on(`visitor:highlight`,({sectionId:e,sectionText:t}={})=>{if(!e&&!t)return;let n=ur(e||null,t||null);n&&dr(n)}),p.on(`visitor:clear_highlight`,()=>{fr()}),bt.current=Sn({socket:p,chatId:l});let b=await u.loadHistory(l,r);if(!e)return;g(kr(b.chat_history||[])),E(!!b.is_human_handled),w(b.is_human_handled?`agent`:C);let T=b?.visitor_email||b?.visitorEmail;if(T&&String(T).trim()&&Tt(String(T).trim()),await new Promise(e=>setTimeout(e,500)),!e)return;c(`ready`)}catch(t){if(!e)return;u(t),c(`error`)}finally{e&&Ke(!1)}})(),()=>{e=!1,bt.current?.cleanup?.(),Et(),qe.current?.disconnect()}},[i,r,a]),(0,b.useEffect)(()=>()=>{if(Te&&!_t.current&&gt.current.length>0){let e=Je.current,t=gt.current,n=R.current;n&&e&&t.length>0&&(console.log(`[FlowEngageProvider] safety-net: syncing voice transcript on unmount`),n.beaconSyncVoice(e,t)||n.syncVoice(e,t).catch(()=>{}),_t.current=!0)}},[Te,d]);let jt=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=R.current;!e||!p||jt.current!==y&&(y&&jt.current!==null?e.updateChatStatus(p,`open`).catch(()=>{}):jt.current===!0&&e.updateChatStatus(p,`widget_closed`).catch(()=>{}),jt.current=y)},[y,p]),(0,b.useEffect)(()=>{let e=()=>{let e=Je.current,t=R.current;!e||!t||typeof navigator>`u`||t.beaconWidgetClosed?.(e)||t.updateChatStatus(e,`widget_closed`).catch(()=>{})};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[]);let Mt=async()=>{if(!(!I?.callId||!R.current||!qe.current||!p)){Ct(),ot.current=I.callId,wt();try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});Qe.current=e;let t=[{urls:`stun:stun.l.google.com:19302`}];try{let e=await R.current.getIceServersConfig();e?.data?.iceServers?.length&&(t=e.data.iceServers)}catch(e){console.warn(`[FlowEngageProvider] ice-config fetch failed, using STUN default`,e)}let n=new RTCPeerConnection({iceServers:t});Ze.current=n,n.onconnectionstatechange=()=>{let e=n.connectionState;if(e===`connected`){let e=new Date().toISOString();L(`connected`),Be(t=>t||e),Dt(e);return}if(e===`connecting`){L(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&Et(`peer:connection_${e}`)},n.oniceconnectionstatechange=()=>{let e=n.iceConnectionState;if(e===`connected`||e===`completed`){let e=new Date().toISOString();L(`connected`),Be(t=>t||e),Dt(e);return}if(e===`checking`||e===`new`){L(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&Et(`peer:ice_${e}`)},n.onsignalingstatechange=()=>{},n.onicegatheringstatechange=()=>{},e.getTracks().forEach(t=>{n.addTrack(t,e)}),n.onicecandidate=e=>{if(!e.candidate||!qe.current?.connected)return;let t=e.candidate;qe.current.emit(`call:ice-candidate`,{callId:I.callId,candidate:t.candidate,sdpMid:t.sdpMid,sdpMLineIndex:t.sdpMLineIndex,chatId:p,from:`customer`})},n.ontrack=e=>{let[t]=e.streams||[],[n]=t?.getAudioTracks?.()||[];if(!$e.current){let e=document.createElement(`audio`);e.id=`flowengage-remote-audio`,e.autoplay=!0,e.playsInline=!0,e.onplay=()=>{},e.onpause=()=>{},e.onended=()=>{},e.onerror=e=>{},$e.current=e,document.body.appendChild(e)}$e.current.srcObject=e.streams[0];let r=I?.callId,i=r&&(ot.current===r||at.current===r);if(!ct.current&&i){let e=new Date().toISOString();L(`connected`),Be(t=>t||e),at.current=r,Le(r),Dt(e)}$e.current.srcObject=t||null;let a=$e.current.play?.();a?.catch&&a.catch(e=>{})};let r=et.current;r&&(console.log(`[FlowEngageProvider] found pending remote offer during accept`,{callId:r.callId||I.callId,chatId:p}),await At({...r,callId:r.callId||I.callId})),await R.current.acceptCall(I.callId,p),qe.current?.emit(`call:accepted`,{callId:I.callId,chatId:p}),at.current=I.callId,Le(I.callId),L(e=>e===`connected`||ct.current?`connected`:`connecting`),Fe(null),x(!0)}catch(e){if(ot.current=null,Et(`accept_call_failed`),e?.status===404||e?.status===409||e?.status===422){We(jr(e,`This visitor call is no longer available.`));return}if(e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`){try{await R.current.rejectCall(I.callId,p)}catch(e){console.error(`[FlowEngageProvider] failed to reject call after microphone denial`,e)}We(`Microphone access was denied. Please allow microphone access to accept the call.`);return}We(`We couldn't connect the call right now. Please try again.`)}}},Nt=async()=>{if(!I?.callId||!R.current||!p){Et(`reject_call_without_server_context`);return}let e=I.callId;wt(),Ct(),qe.current?.emit(`call:rejected`,{callId:e,chatId:p,reason:`visitor_declined`});try{await R.current.rejectCall(e,p)}catch(e){We(jr(e,`We couldn't decline the call cleanly.`))}finally{Et(`reject_call_finally`)}},Pt=(0,b.useRef)(Nt);Pt.current=Nt,(0,b.useEffect)(()=>{if(!I?.callId||Ie){wt();return}let e=I.callId;return wt(),st.current=window.setTimeout(()=>{z.current?.callId===e&&ot.current!==e&&at.current!==e&&Pt.current()},D),()=>{st.current&&=(window.clearTimeout(st.current),null)}},[Ie,wt,I?.callId]);let Ft=async()=>{if(!Ie||!R.current||!p){Et(`end_call_without_server_context`);return}Ct();try{await R.current.endWebRTCCall(Ie,p)}catch(e){We(jr(e,`The call ended locally, but the server could not be updated.`))}finally{Et(`end_call_finally`)}},It=()=>{let e=Qe.current?.getAudioTracks?.()||[],t=Ze.current?.getSenders?.().map(e=>e.track).filter(e=>e?.kind===`audio`)||[],n=[...e,...t].filter(Boolean);if(n.length===0)return;let r=!Ve;n.forEach(e=>{e.enabled=!r}),He(r)},Lt=async(e={})=>{let t=e.notifyChatInitiated===!0;if(x(!0),!(!t||!R.current||!p||typeof window>`u`)){try{await R.current.trackVisitor({chatId:p,currentPagePath:window.location.pathname||`/`})}catch{}try{await R.current.updateChatStatus(p,`open`)}catch{}}},Rt=async e=>{let t=Tt(e);if(!t||!R.current||!Je.current)return t;try{await R.current.trackVisitor({chatId:Je.current,currentPagePath:typeof window<`u`&&window.location.pathname||`/`,email:t})}catch(e){console.error(`[FlowEngageProvider] failed to persist visitor email`,e)}return t},zt=()=>{!p||!qe.current?.connected||lt.current||(lt.current=!0,qe.current.emit(`typing:start`,{chatId:p,sender:`user`}))},Bt=()=>{!p||!qe.current?.connected||!lt.current||(lt.current=!1,qe.current.emit(`typing:stop`,{chatId:p,sender:`user`}))},Vt=(e=``)=>{let t=typeof e==`string`?e:``;!p||!qe.current?.connected||t!==``&&ut.current===t||(ut.current=t,qe.current.emit(`typing:update`,{chatId:p,sender:`user`,text:t}))};function Ht(){if(typeof document>`u`)return null;try{let e=(document.querySelector(`main`)||document.querySelector(`[role='main']`)||document.querySelector(`article`)||document.querySelector(`#content`)||document.querySelector(`.content`)||document.body).cloneNode(!0);e.querySelectorAll(`nav, footer, header, aside, script, style, noscript, #flowengage-root, .flowengage-shell, .flowengage-widget-root, [id*='flowengage'], [class*='flowengage']`).forEach(e=>e.remove());let t=e.textContent.replace(/\s+/g,` `).trim();return t.length>0?t.substring(0,3e3):null}catch{return null}}let Ut=async(e,t=``,n=null,i={})=>{let a=typeof e==`string`?e.trim():``;if(!a||!R.current||!p||s!==`ready`||Ae)return;Bt(),nt.current=!1;let o=/^\s*(yes|yeah|sure|ok|okay|go ahead|take me(?: there)?(?!\s+\w)|navigate(?!\s+(?:me\s+)?to\s+\w)|yep|absolutely|please do|do it|let'?s go|go there|show me(?!\s+(?:the|a|an)\s+\w)|go to it|bring me there|navigate me there)\b/i,c=/^\s*(?:yes|yeah|sure|ok|okay|yep|absolutely)\s+(?!(?:please|do\s+it|let'?s|that|this|there|it|thanks|go|cool|great|perfect|sounds|alright|proceed)\b)\w/i,l=/\b(take me|navigate|go to|show me|bring me|open|go there|navigate to|take me to|let'?s go to)\b/i;if(tt.current&&o.test(a)&&!c.test(a)){let{url:e,section:t}=tt.current;tt.current=null,nt.current=!0,console.log(`[FWH Nav] Client-side nav firing →`,e),B(e,{voiceActive:vt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&v();return}!t||!vt.current||setTimeout(()=>{let e=ur(null,t);e&&dr(e)},300)})}else o.test(a)||(tt.current=null);let d=`pending-user-${Date.now()}`,f={id:d,sender:`user`,message:e,timestamp:new Date().toISOString(),isPending:!0,type:i?.type||`text`,metadata:i?.metadata||void 0,...n||{}};g(e=>[...e,f]);let m=T;if(m)try{m=xt(await R.current.checkHumanHandled(p))}catch{}if(m&&qe.current?.connected){qe.current.emit(`customer:message`,{chatId:p,content:e,sender:`user`,email:A||void 0,type:i?.type||`text`,metadata:i?.metadata||{},...n||{}});return}ye(!0);try{let o=await R.current.sendAiMessage(p,e,r,t,{...n||{},...A?{email:A}:{}},{...i,currentPageUrl:typeof window<`u`?window.location.href:void 0,currentPageTitle:typeof window<`u`?document.title:void 0,currentPagePath:typeof window<`u`?window.location.pathname:void 0,currentPageContent:Ht()||void 0}),s=o.chat_history||[];if(console.log(`[FWH Nav Debug] API response fields:`,{has_navigate:!!o.navigate,navigate:o.navigate,has_pending_navigate:!!o.pending_navigate,pending_navigate:o.pending_navigate,last_bot_msg:[...s].reverse().find(e=>e.sender===`bot`)?.message?.substring(0,80)}),o.pending_navigate?.url){let e={url:o.pending_navigate.url,section:o.pending_navigate.section||null};l.test(a)?(console.log(`[FWH Nav] Auto-navigating (intent detected) →`,e.url),B(e.url,{voiceActive:vt.current}).then(({navigated:t,reason:n})=>{if(!t){n===`not-found`?_():n===`already-on-page`&&v();return}e.section&&setTimeout(()=>{let t=ur(null,e.section);t&&dr(t)},300)})):(tt.current=e,console.log(`[FWH Nav] Stored pending nav →`,tt.current))}if(o.navigate?.url)if(nt.current)nt.current=!1;else{let{url:e,section:t}=o.navigate;B(e,{voiceActive:vt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&v();return}t&&setTimeout(()=>{let e=ur(null,t);e&&dr(e)},300)})}else if(o.highlight?.section){let e=o.highlight.section;setTimeout(()=>{let t=ur(null,e);t&&dr(t)},150)}else{let e=[...s].reverse().find(e=>e.sender===`bot`||e.sender===`assistant`);if(e?.message){let t=Ar(e.message);t&&hr(t.url,{siteId:yt.current?.siteId,apiBaseUrl:yt.current?.apiBaseUrl}).then(({allowed:e,correctedUrl:n})=>{if(!e){_();return}B(n||t.url,{voiceActive:vt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&v();return}!t.section||!vt.current||setTimeout(()=>{let e=ur(null,t.section);e&&dr(e)},300)})})}}g(kr(s)),E(!!o.is_human_handled),w(o.is_human_handled?`agent`:`ai`),ge(!1),ye(!1),await R.current.updateChatStatus(p,`messageSent`)}catch(e){g(e=>e.filter(e=>e.id!==d)),ge(!1),ye(!1),e.status===429?(xe(!0),we(e.message),window.setTimeout(()=>{xe(!1),we(``)},ee)):u(e)}},Wt=async e=>{if(!R.current||!e)throw Error(`Upload is unavailable right now.`);return R.current.uploadChatFile(e)},Gt=async e=>{if(!(!R.current||!p)){try{let t=e?`voice`:`text`;await R.current.setChatMode(p,t)}catch{}Ee(e),e&&(_t.current=!1)}},Kt=async e=>{if(_t.current)return;if(_t.current=!0,!R.current||!p||!e?.length){Ee(!1);return}let t=()=>{let t=kr(e);g(e=>{if(!e.length)return t;let n=e[e.length-1],r=t[0];return n&&r&&n.sender===r.sender&&n.message===r.message?e:[...e,...t]})};try{let n=await R.current.syncVoice(p,e);if(n?.chat_history?.length)g(kr(n.chat_history));else if(n?.success)try{let e=await R.current.loadHistory(p,r);e?.chat_history?.length?g(kr(e.chat_history)):t()}catch{t()}else t()}catch{t()}finally{Ee(!1)}},qt=async()=>{if(!(!R.current||!p)){Te&&!_t.current&&gt.current.length>0&&await Kt(gt.current);try{await R.current.endConversation(p)}catch{try{await R.current.updateChatStatus(p,`ended`)}catch{}}je(!0),g(e=>[...e,{id:`conversation-ended-${Date.now()}`,sender:`system`,message:`This conversation has ended. Thank you for reaching out!`,timestamp:new Date().toISOString(),isPending:!1}])}};(0,b.useEffect)(()=>{if(Re!==`connected`||!Ie||!p||!ze||!St)return;let e=new Date(ze).getTime(),t=Number.isFinite(e)?Date.now()-e:0,n=Math.max(0,St*1e3-t),r=window.setTimeout(()=>{We(`The call ended because it reached the time limit.`),Ft()},n);return()=>window.clearTimeout(r)},[Ie,ze,Re,p,Ft,St]),(0,b.useEffect)(()=>{let e=()=>{let e=Je.current,t=R.current;if(!t||!e)return;if(vt.current&&gt.current.length>0&&Ce(),!_t.current&&gt.current.length>0&&(t.beaconSyncVoice(e,gt.current)||t.syncVoice(e,gt.current).catch(()=>{}),_t.current=!0),at.current){t.beaconEndWebRTCCall(at.current,e);return}let n=ot.current||z.current?.callId;n&&t.beaconCustomerUnavailable(n,e)};return window.addEventListener(`pagehide`,e),window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`pagehide`,e),window.removeEventListener(`beforeunload`,e)}},[]);let Jt=(0,b.useCallback)(()=>{let e=i?.siteId;le(e),Ye.current=!0,Xe.current=null,qe.current?.disconnect(),g([]),m(``),Je.current=``,je(!1),E(!1),ne(null),k(null),Ke(!0),o(e=>e+1)},[i?.siteId]),Yt=(0,b.useCallback)(e=>{i?.siteId,Ye.current=!1,Xe.current=e,qe.current?.disconnect(),g([]),m(``),Je.current=``,je(!1),E(!1),ne(null),k(null),Ke(!0),o(e=>e+1)},[i?.siteId]),Xt=(0,b.useMemo)(()=>({status:s,error:l,runtimeConfig:d,resolvedConfig:i,chatId:p,chatHistory:h,isOpen:y,activeScreen:C,isHumanHandled:T,agentName:O,agentHeadshot:oe,visitorEmail:A,isAgentTyping:N,isAiTyping:me,connectionStatus:P,isLoading:ve,isVoiceMode:Te,isRateLimited:be,rateLimitMessage:Se,isConversationEnded:Ae,isSessionRestoring:Ge,openToChatCounter:De,voiceEndCounter:F,incomingCall:I,activeCallId:Ie,callConnectionState:Re,callConnectedAt:ze,isCallMuted:Ve,webRTCError:Ue,language:r,historyRef:gt,hasSyncedRef:_t,dismissCallError:Ct,captureVisitorEmail:Rt,startTyping:zt,stopTyping:Bt,updateTypingDraft:Vt,notifyRouteChange:()=>bt.current?.notifyRouteChange?.(),openWidget:Lt,closeWidget:()=>x(!1),toggleWidget:()=>{if(y){x(!1);return}Lt({notifyChatInitiated:!0})},sendMessage:Ut,uploadChatFile:Wt,setVoiceMode:Gt,onMessageSync:Kt,endConversation:qt,startNewChat:Jt,resumeChat:Yt,getVisitorChatHistory:()=>R.current?.getVisitorChatHistory?.(),getVisitorChatThread:e=>R.current?.getVisitorChatThread?.(e),acceptCall:Mt,rejectCall:Nt,endWebRTCCall:Ft,toggleCallMute:It}),[s,l,d,i,p,h,y,C,T,O,oe,A,N,me,P,ve,Te,be,Se,Ae,Ge,De,F,I,Ie,Re,ze,Ve,Ue,r,Rt,zt,Bt,Vt,Mt,Nt,Ft,It,Lt,Ut,Wt,Gt,Kt,qt,Jt,Ct]);return(0,H.jsx)(Cn.Provider,{value:Xt,children:n})}var Ir=(0,b.createContext)({});function Lr(e){let t=(0,b.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Rr=typeof window<`u`?b.useLayoutEffect:b.useEffect,zr=(0,b.createContext)(null);function Br(e,t){e.indexOf(t)===-1&&e.push(t)}function Vr(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Hr=(e,t,n)=>n>t?t:n<e?e:n,Ur={},Wr=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Gr(e){return typeof e==`object`&&!!e}var Kr=e=>/^0[^.\s]+$/u.test(e);function qr(e){let t;return()=>(t===void 0&&(t=e()),t)}var Jr=e=>e,Yr=(e,t)=>n=>t(e(n)),Xr=(...e)=>e.reduce(Yr),Zr=(e,t,n)=>{let r=t-e;return r===0?1:(n-e)/r},Qr=class{constructor(){this.subscriptions=[]}add(e){return Br(this.subscriptions,e),()=>Vr(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},$r=e=>e*1e3,ei=e=>e/1e3;function ti(e,t){return t?1e3/t*e:0}var ni=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,ri=1e-7,ii=12;function ai(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=ni(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>ri&&++s<ii);return o}function oi(e,t,n,r){if(e===t&&n===r)return Jr;let i=t=>ai(t,0,1,e,n);return e=>e===0||e===1?e:ni(i(e),t,r)}var si=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,ci=e=>t=>1-e(1-t),li=oi(.33,1.53,.69,.99),ui=ci(li),di=si(ui),fi=e=>e>=1?1:(e*=2)<1?.5*ui(e):.5*(2-2**(-10*(e-1))),pi=e=>1-Math.sin(Math.acos(e)),mi=ci(pi),hi=si(pi),gi=oi(.42,0,1,1),_i=oi(0,0,.58,1),vi=oi(.42,0,.58,1),yi=e=>Array.isArray(e)&&typeof e[0]!=`number`,bi=e=>Array.isArray(e)&&typeof e[0]==`number`,xi={linear:Jr,easeIn:gi,easeInOut:vi,easeOut:_i,circIn:pi,circInOut:hi,circOut:mi,backIn:ui,backInOut:di,backOut:li,anticipate:fi},Si=e=>typeof e==`string`,Ci=e=>{if(bi(e)){e.length;let[t,n,r,i]=e;return oi(t,n,r,i)}else if(Si(e))return xi[e],`${e}`,xi[e];return e},wi=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`],Ti={value:null,addProjectionMetrics:null};function Ei(e,t){let n=new Set,r=new Set,i=!1,a=!1,o=new WeakSet,s={delta:0,timestamp:0,isProcessing:!1},c=0;function l(t){o.has(t)&&(u.schedule(t),e()),c++,t(s)}let u={schedule:(e,t=!1,a=!1)=>{let s=a&&i?n:r;return t&&o.add(e),s.add(e),e},cancel:e=>{r.delete(e),o.delete(e)},process:e=>{if(s=e,i){a=!0;return}i=!0;let o=n;n=r,r=o,n.forEach(l),t&&Ti.value&&Ti.value.frameloop[t].push(c),c=0,n.clear(),i=!1,a&&(a=!1,u.process(e))}};return u}var Di=40;function Oi(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=wi.reduce((e,n)=>(e[n]=Ei(a,t?n:void 0),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=Ur.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,Di),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:wi.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<wi.length;t++)o[wi[t]].cancel(e)},state:i,steps:o}}var{schedule:U,cancel:ki,state:W,steps:Ai}=Oi(typeof requestAnimationFrame<`u`?requestAnimationFrame:Jr,!0),ji;function Mi(){ji=void 0}var Ni={now:()=>(ji===void 0&&Ni.set(W.isProcessing||Ur.useManualTiming?W.timestamp:performance.now()),ji),set:e=>{ji=e,queueMicrotask(Mi)}},Pi={layout:0,mainThread:0,waapi:0},Fi=e=>t=>typeof t==`string`&&t.startsWith(e),Ii=Fi(`--`),Li=Fi(`var(--`),Ri=e=>Li(e)?zi.test(e.split(`/*`)[0].trim()):!1,zi=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Bi(e){return typeof e==`string`?e.split(`/*`)[0].includes(`var(--`):!1}var Vi={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Hi={...Vi,transform:e=>Hr(0,1,e)},Ui={...Vi,default:1},Wi=e=>Math.round(e*1e5)/1e5,Gi=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Ki(e){return e==null}var qi=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ji=(e,t)=>n=>!!(typeof n==`string`&&qi.test(n)&&n.startsWith(e)||t&&!Ki(n)&&Object.prototype.hasOwnProperty.call(n,t)),Yi=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Gi);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Xi=e=>Hr(0,255,e),Zi={...Vi,transform:e=>Math.round(Xi(e))},Qi={test:Ji(`rgb`,`red`),parse:Yi(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Zi.transform(e)+`, `+Zi.transform(t)+`, `+Zi.transform(n)+`, `+Wi(Hi.transform(r))+`)`};function $i(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var ea={test:Ji(`#`),parse:$i,transform:Qi.transform},ta=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),na=ta(`deg`),ra=ta(`%`),G=ta(`px`),ia=ta(`vh`),aa=ta(`vw`),oa={...ra,parse:e=>ra.parse(e)/100,transform:e=>ra.transform(e*100)},sa={test:Ji(`hsl`,`hue`),parse:Yi(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+ra.transform(Wi(t))+`, `+ra.transform(Wi(n))+`, `+Wi(Hi.transform(r))+`)`},ca={test:e=>Qi.test(e)||ea.test(e)||sa.test(e),parse:e=>Qi.test(e)?Qi.parse(e):sa.test(e)?sa.parse(e):ea.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Qi.transform(e):sa.transform(e),getAnimatableNone:e=>{let t=ca.parse(e);return t.alpha=0,ca.transform(t)}},la=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function ua(e){return isNaN(e)&&typeof e==`string`&&(e.match(Gi)?.length||0)+(e.match(la)?.length||0)>0}var da=`number`,fa=`color`,pa=`var`,ma=`var(`,ha="${}",ga=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function _a(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(ga,e=>(ca.test(e)?(r.color.push(a),i.push(fa),n.push(ca.parse(e))):e.startsWith(ma)?(r.var.push(a),i.push(pa),n.push(e)):(r.number.push(a),i.push(da),n.push(parseFloat(e))),++a,ha)).split(ha),indexes:r,types:i}}function va(e){return _a(e).values}function ya({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];e===da?i+=Wi(r[a]):e===fa?i+=ca.transform(r[a]):i+=r[a]}return i}}function ba(e){return ya(_a(e))}var xa=e=>typeof e==`number`?0:ca.test(e)?ca.getAnimatableNone(e):e,Sa=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:xa(e);function Ca(e){let t=_a(e);return ya(t)(t.values.map((e,n)=>Sa(e,t.split[n])))}var wa={test:ua,parse:va,createTransformer:ba,getAnimatableNone:Ca};function Ta(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Ea({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=Ta(s,r,e+1/3),a=Ta(s,r,e),o=Ta(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Da(e,t){return n=>n>0?t:e}var Oa=(e,t,n)=>e+(t-e)*n,ka=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Aa=[ea,Qi,sa],ja=e=>Aa.find(t=>t.test(e));function Ma(e){let t=ja(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===sa&&(n=Ea(n)),n}var Na=(e,t)=>{let n=Ma(e),r=Ma(t);if(!n||!r)return Da(e,t);let i={...n};return e=>(i.red=ka(n.red,r.red,e),i.green=ka(n.green,r.green,e),i.blue=ka(n.blue,r.blue,e),i.alpha=Oa(n.alpha,r.alpha,e),Qi.transform(i))},Pa=new Set([`none`,`hidden`]);function Fa(e,t){return Pa.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Ia(e,t){return n=>Oa(e,t,n)}function La(e){return typeof e==`number`?Ia:typeof e==`string`?Ri(e)?Da:ca.test(e)?Na:Va:Array.isArray(e)?Ra:typeof e==`object`?ca.test(e)?Na:za:Da}function Ra(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>La(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function za(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=La(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function Ba(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var Va=(e,t)=>{let n=wa.createTransformer(t),r=_a(e),i=_a(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?Pa.has(e)&&!i.values.length||Pa.has(t)&&!r.values.length?Fa(e,t):Xr(Ra(Ba(r,i),i.values),n):(`${e}${t}`,Da(e,t))};function Ha(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?Oa(e,t,n):La(e)(e,t)}var Ua=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>U.update(t,e),stop:()=>ki(t),now:()=>W.isProcessing?W.timestamp:Ni.now()}},Wa=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},Ga=2e4;function Ka(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}function qa(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(Ka(r),Ga);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:ei(i)}}var Ja={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function Ya(e,t){return e*Math.sqrt(1-t*t)}var Xa=12;function Za(e,t,n){let r=n;for(let n=1;n<Xa;n++)r-=e(r)/t(r);return r}var Qa=.001;function $a({duration:e=Ja.duration,bounce:t=Ja.bounce,velocity:n=Ja.velocity,mass:r=Ja.mass}){let i,a;Ja.maxDuration;let o=1-t;o=Hr(Ja.minDamping,Ja.maxDamping,o),e=Hr(Ja.minDuration,Ja.maxDuration,ei(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=Ya(t,o),c=Math.exp(-i);return Qa-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=Ya(t**2,o);return(-i(t)+Qa>0?-1:1)*((a-s)*c)/l}):(i=t=>{let r=Math.exp(-t*e),i=(t-n)*e+1;return-Qa+r*i},a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=Za(i,a,s);if(e=$r(e),isNaN(c))return{stiffness:Ja.stiffness,damping:Ja.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var eo=[`duration`,`bounce`],to=[`stiffness`,`damping`,`mass`];function no(e,t){return t.some(t=>e[t]!==void 0)}function ro(e){let t={velocity:Ja.velocity,stiffness:Ja.stiffness,damping:Ja.damping,mass:Ja.mass,isResolvedFromDuration:!1,...e};if(!no(e,to)&&no(e,eo))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Hr(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Ja.mass,stiffness:i,damping:a}}else{let n=$a({...e,velocity:0});t={...t,...n,mass:Ja.mass},t.isResolvedFromDuration=!0}return t}function io(e=Ja.visualDuration,t=Ja.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=ro({...n,velocity:-ei(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=ei(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?Ja.restSpeed.granular:Ja.restSpeed.default,i||=v?Ja.restDelta.granular:Ja.restDelta.default;let y,b,x,S,C,w;if(h<1)x=Ya(_,h),S=(m+h*_*g)/x,y=e=>o-Math.exp(-h*_*e)*(S*Math.sin(x*e)+g*Math.cos(x*e)),C=h*_*S+g*x,w=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(C*Math.sin(x*e)+w*Math.cos(x*e));else if(h===1){y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;b=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+h*_*g)/e,n=h*_*t-g*e,r=h*_*g-t*e;b=t=>{let i=Math.exp(-h*_*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let T={calculatedDuration:p&&d||null,velocity:e=>$r(b(e)),next:e=>{if(!p&&h<1){let t=Math.exp(-h*_*e),n=Math.sin(x*e),a=Math.cos(x*e),c=o-t*(S*n+g*a),l=$r(t*(C*n+w*a));return s.done=Math.abs(l)<=r&&Math.abs(o-c)<=i,s.value=s.done?o:c,s}let t=y(e);if(p)s.done=e>=d;else{let n=$r(b(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(Ka(T),Ga),t=Wa(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}io.applyToOptions=e=>{let t=qa(e,100,io);return e.ease=t.ease,e.duration=$r(t.duration),e.type=`keyframes`,e};var ao=5;function oo(e,t,n){let r=Math.max(t-ao,0);return ti(n-e(r),t-r)}function K({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=io({keyframes:[f.value,m(f.value)],velocity:oo(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function so(e,t,n){let r=[],i=n||Ur.mix||Ha,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=Xr(Array.isArray(t)?t[n]||Jr:t,a)),r.push(a)}return r}function co(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=so(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=Zr(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Hr(e[0],e[a-1],t)):l}function lo(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=Zr(0,t,r);e.push(Oa(n,1,i))}}function uo(e){let t=[0];return lo(t,e.length-1),t}function fo(e,t){return e.map(e=>e*t)}function po(e,t){return e.map(()=>t||vi).splice(0,e.length-1)}function mo({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=yi(r)?r.map(Ci):Ci(r),a={done:!1,value:t[0]},o=co(fo(n&&n.length===t.length?n:uo(t),e),t,{ease:Array.isArray(i)?i:po(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var ho=e=>e!==null;function go(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(ho),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var _o={decay:K,inertia:K,tween:mo,keyframes:mo,spring:io};function vo(e){typeof e.type==`string`&&(e.type=_o[e.type])}var yo=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},bo=e=>e/100,xo=class extends yo{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==Ni.now()&&this.tick(Ni.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},Pi.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;vo(e);let{type:t=mo,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||mo;s!==mo&&typeof o[0]!=`number`&&(this.mixKeyframes=Xr(bo,Ha(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=Ka(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime===null?this.currentTime=t:this.currentTime=this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=Hr(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==K&&(b.value=go(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return ei(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ei(e)}get time(){return ei(this.currentTime)}set time(e){e=$r(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return oo(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Ni.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=ei(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Ua,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(Ni.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null,Pi.mainThread--}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function So(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var Co=e=>e*180/Math.PI,wo=e=>Eo(Co(Math.atan2(e[1],e[0]))),To={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:wo,rotateZ:wo,skewX:e=>Co(Math.atan(e[1])),skewY:e=>Co(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Eo=e=>(e%=360,e<0&&(e+=360),e),Do=wo,Oo=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),ko=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Ao={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Oo,scaleY:ko,scale:e=>(Oo(e)+ko(e))/2,rotateX:e=>Eo(Co(Math.atan2(e[6],e[5]))),rotateY:e=>Eo(Co(Math.atan2(-e[2],e[0]))),rotateZ:Do,rotate:Do,skewX:e=>Co(Math.atan(e[4])),skewY:e=>Co(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function jo(e){return e.includes(`scale`)?1:0}function Mo(e,t){if(!e||e===`none`)return jo(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=Ao,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=To,i=t}if(!i)return jo(t);let a=r[t],o=i[1].split(`,`).map(Po);return typeof a==`function`?a(o):o[a]}var No=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return Mo(n,t)};function Po(e){return parseFloat(e.trim())}var Fo=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Io=new Set(Fo),Lo=e=>e===Vi||e===G,Ro=new Set([`x`,`y`,`z`]),zo=Fo.filter(e=>!Ro.has(e));function Bo(e){let t=[];return zo.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith(`scale`)?1:0))}),t}var Vo={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Mo(t,`x`),y:(e,{transform:t})=>Mo(t,`y`)};Vo.translateX=Vo.x,Vo.translateY=Vo.y;var Ho=new Set,Uo=!1,Wo=!1,Go=!1;function Ko(){if(Wo){let e=Array.from(Ho).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=Bo(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}Wo=!1,Uo=!1,Ho.forEach(e=>e.complete(Go)),Ho.clear()}function qo(){Ho.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Wo=!0)})}function Jo(){Go=!0,qo(),Ko(),Go=!1}var Yo=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(Ho.add(this),Uo||(Uo=!0,U.read(qo),U.resolveKeyframes(Ko))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}So(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ho.delete(this)}cancel(){this.state===`scheduled`&&(Ho.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Xo=e=>e.startsWith(`--`);function Zo(e,t,n){Xo(t)?e.style.setProperty(t,n):e.style[t]=n}var Qo={};function $o(e,t){let n=qr(e);return()=>Qo[t]??n()}var es=$o(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),ts=$o(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),ns=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,rs={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:ns([0,.65,.55,1]),circOut:ns([.55,0,1,.45]),backIn:ns([.31,.01,.66,-.59]),backOut:ns([.33,1.53,.69,.99])};function is(e,t){if(e)return typeof e==`function`?ts()?Wa(e,t):`ease-out`:bi(e)?ns(e):Array.isArray(e)?e.map(e=>is(e,t)||rs.easeOut):rs[e]}function as(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=is(s,i);Array.isArray(d)&&(u.easing=d),Ti.value&&Pi.waapi++;let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};l&&(f.pseudoElement=l);let p=e.animate(u,f);return Ti.value&&p.finished.finally(()=>{Pi.waapi--}),p}function os(e){return typeof e==`function`&&`applyToOptions`in e}function ss({type:e,...t}){return os(e)&&ts()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var cs=class extends yo{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=ss(e);this.animation=as(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=go(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),Zo(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e===`idle`||e===`finished`||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return ei(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ei(e)}get time(){return ei(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=$r(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&es()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),Jr):r(this)}},ls={anticipate:fi,backInOut:di,circInOut:hi};function us(e){return e in ls}function ds(e){typeof e.ease==`string`&&us(e.ease)&&(e.ease=ls[e.ease])}var fs=10,ps=class extends cs{constructor(e){ds(e),vo(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new xo({...a,autoplay:!1}),s=Math.max(fs,Ni.now()-this.startTime),c=Hr(0,fs,s-fs),l=o.sample(s).value,{name:u}=this.options;i&&u&&Zo(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},ms=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(wa.test(e)||e===`0`)&&!e.startsWith(`url(`));function hs(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function gs(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=ms(i,t),s=ms(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:hs(e)||(n===`spring`||os(n))&&r}function _s(e){e.duration=0,e.type=`keyframes`}var vs=new Set([`opacity`,`clipPath`,`filter`,`transform`]),ys=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function bs(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&ys.test(e[t]))return!0;return!1}var xs=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),Ss=qr(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function Cs(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:c,transformTemplate:l}=t.owner.getProps();return Ss()&&n&&(vs.has(n)||xs.has(n)&&bs(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var ws=40,Ts=class extends yo{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Ni.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u};this.keyframeResolver=new(l?.KeyframeResolver||Yo)(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=Ni.now();let u=!0;gs(e,i,a,o)||(u=!1,(Ur.instantAnimations||!s)&&l?.(go(e,n,t)),e[0]=e[e.length-1],_s(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>ws?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&Cs(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new ps({...d,element:p})}catch{m=new xo(d)}else m=new xo(d);m.finished.then(()=>{this.notifyFinished()}).catch(Jr),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Jo()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function Es(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var Ds=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Os(e){let t=Ds.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function ks(e,t,n=1){`${e}`;let[r,i]=Os(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Wr(e)?parseFloat(e):e}return Ri(i)?ks(i,t,n+1):i}var As={type:`spring`,stiffness:500,damping:25,restSpeed:10},js=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Ms={type:`keyframes`,duration:.8},Ns={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Ps=(e,{keyframes:t})=>t.length>2?Ms:Io.has(e)?e.startsWith(`scale`)?js(t[1]):As:Ns;function Fs(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Is(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Fs(n,e)}var Ls=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Rs(e){for(let t in e)if(!Ls.has(t))return!0;return!1}var zs=(e,t,n,r={},i,a)=>o=>{let s=Is(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=$r(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};Rs(s)||Object.assign(u,Ps(e,u)),u.duration&&=$r(u.duration),u.repeatDelay&&=$r(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(_s(u),u.delay===0&&(d=!0)),(Ur.instantAnimations||Ur.skipAnimations||i?.shouldSkipAnimations)&&(d=!0,_s(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=go(u.keyframes,s);if(e!==void 0){U.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new xo(u):new Ts(u)};function Bs(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Vs(e,t,n,r){if(typeof t==`function`){let[i,a]=Bs(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=Bs(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Hs(e,t,n){let r=e.getProps();return Vs(r,t,n===void 0?r.custom:n,e)}var Us=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...Fo]),Ws=30,Gs=e=>!isNaN(parseFloat(e)),Ks={current:void 0},qs=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Ni.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Ni.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Gs(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new Qr);let n=this.events[e].add(t);return e===`change`?()=>{n(),U.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return Ks.current&&Ks.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Ni.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Ws)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Ws);return ti(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function Js(e,t){return new qs(e,t)}var Ys=e=>Array.isArray(e);function Xs(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Js(n))}function Zs(e){return Ys(e)?e[e.length-1]||0:e}function Qs(e,t){let{transitionEnd:n={},transition:r={},...i}=Hs(e,t)||{};i={...i,...n};for(let t in i)Xs(e,t,Zs(i[t]))}var $s=e=>!!(e&&e.getVelocity);function ec(e){return!!($s(e)&&e.add)}function tc(e,t){let n=e.getValue(`willChange`);if(ec(n))return n.add(t);if(!n&&Ur.WillChange){let n=new Ur.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function nc(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var rc=`data-`+nc(`framerAppearId`);function ic(e){return e.props[rc]}function ac({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function oc(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Fs(a,c):c;let l=a?.reduceMotion;r&&(a=r);let u=[],d=i&&e.animationState&&e.animationState.getState()[i];for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||d&&ac(d,t))continue;let o={delay:n,...Is(a||{},t)},c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){U.update(()=>r.set(i));continue}let f=!1;if(window.MotionHandoffAnimation){let n=ic(e);if(n){let e=window.MotionHandoffAnimation(n,t,U);e!==null&&(o.startTime=e,f=!0)}}tc(e,t);let p=l??e.shouldReduceMotion;r.start(zs(t,r,i,p&&Us.has(t)?{type:!1}:o,e,f));let m=r.animation;m&&u.push(m)}if(o){let t=()=>U.update(()=>{o&&Qs(e,o)});u.length?Promise.all(u).then(t):t()}return u}function sc(e,t,n={}){let r=Hs(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(oc(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return cc(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function cc(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(sc(c,t,{...o,delay:n+(typeof r==`function`?0:r)+Es(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function lc(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>sc(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=sc(e,t,n);else{let i=typeof t==`function`?Hs(e,t,n.custom):t;r=Promise.all(oc(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var uc={test:e=>e===`auto`,parse:e=>e},dc=e=>t=>t.test(e),fc=[Vi,G,ra,na,aa,ia,uc],pc=e=>fc.find(dc(e));function mc(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||Kr(e)}var hc=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function gc(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Gi)||[];if(!r)return e;let i=n.replace(r,``),a=hc.has(t)?1:0;return r!==n&&(a*=100),t+`(`+a+i+`)`}var _c=/\b([a-z-]*)\(.*?\)/gu,vc={...wa,getAnimatableNone:e=>{let t=e.match(_c);return t?t.map(gc).join(` `):e}},yc={...wa,getAnimatableNone:e=>{let t=wa.parse(e);return wa.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},bc={...Vi,transform:Math.round},xc={borderWidth:G,borderTopWidth:G,borderRightWidth:G,borderBottomWidth:G,borderLeftWidth:G,borderRadius:G,borderTopLeftRadius:G,borderTopRightRadius:G,borderBottomRightRadius:G,borderBottomLeftRadius:G,width:G,maxWidth:G,height:G,maxHeight:G,top:G,right:G,bottom:G,left:G,inset:G,insetBlock:G,insetBlockStart:G,insetBlockEnd:G,insetInline:G,insetInlineStart:G,insetInlineEnd:G,padding:G,paddingTop:G,paddingRight:G,paddingBottom:G,paddingLeft:G,paddingBlock:G,paddingBlockStart:G,paddingBlockEnd:G,paddingInline:G,paddingInlineStart:G,paddingInlineEnd:G,margin:G,marginTop:G,marginRight:G,marginBottom:G,marginLeft:G,marginBlock:G,marginBlockStart:G,marginBlockEnd:G,marginInline:G,marginInlineStart:G,marginInlineEnd:G,fontSize:G,backgroundPositionX:G,backgroundPositionY:G,rotate:na,rotateX:na,rotateY:na,rotateZ:na,scale:Ui,scaleX:Ui,scaleY:Ui,scaleZ:Ui,skew:na,skewX:na,skewY:na,distance:G,translateX:G,translateY:G,translateZ:G,x:G,y:G,z:G,perspective:G,transformPerspective:G,opacity:Hi,originX:oa,originY:oa,originZ:G,zIndex:bc,fillOpacity:Hi,strokeOpacity:Hi,numOctaves:bc},Sc={...xc,color:ca,backgroundColor:ca,outlineColor:ca,fill:ca,stroke:ca,borderColor:ca,borderTopColor:ca,borderRightColor:ca,borderBottomColor:ca,borderLeftColor:ca,filter:vc,WebkitFilter:vc,mask:yc,WebkitMask:yc},Cc=e=>Sc[e],wc=new Set([vc,yc]);function Tc(e,t){let n=Cc(e);return wc.has(n)||(n=wa),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var Ec=new Set([`auto`,`none`,`0`]);function Dc(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!Ec.has(t)&&_a(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=Tc(n,i)}var Oc=class extends Yo{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Ri(r))){let i=ks(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Us.has(n)||e.length!==2)return;let[r,i]=e,a=pc(r),o=pc(i);if(Bi(r)!==Bi(i)&&Vo[n]){this.needsMeasurement=!0;return}if(a!==o)if(Lo(a)&&Lo(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else Vo[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||mc(e[t]))&&n.push(t);n.length&&Dc(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Vo[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=Vo[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}};function kc(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var Ac=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function jc(e){return Gr(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:Mc,cancel:Nc}=Oi(queueMicrotask,!1),Pc={x:!1,y:!1};function Fc(){return Pc.x||Pc.y}function Ic(e){return e===`x`||e===`y`?Pc[e]?null:(Pc[e]=!0,()=>{Pc[e]=!1}):Pc.x||Pc.y?null:(Pc.x=Pc.y=!0,()=>{Pc.x=Pc.y=!1})}function Lc(e,t){let n=kc(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function Rc(e){return!(e.pointerType===`touch`||Fc())}function zc(e,t,n={}){let[r,i,a]=Lc(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!Rc(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var Bc=(e,t)=>t?e===t?!0:Bc(e,t.parentElement):!1,Vc=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Hc=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Uc(e){return Hc.has(e.tagName)||e.isContentEditable===!0}var Wc=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Gc(e){return Wc.has(e.tagName)||e.isContentEditable===!0}var Kc=new WeakSet;function qc(e){return t=>{t.key===`Enter`&&e(t)}}function Jc(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var Yc=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=qc(()=>{if(Kc.has(n))return;Jc(n,`down`);let e=qc(()=>{Jc(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Jc(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Xc(e){return Vc(e)&&!Fc()}var Zc=new WeakSet;function Qc(e,t,n={}){let[r,i,a]=Lc(e,n),o=e=>{let r=e.currentTarget;if(!Xc(e)||Zc.has(e))return;Kc.add(r),n.stopPropagation&&Zc.add(e);let a=t(r,e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),Kc.has(r)&&Kc.delete(r),Xc(e)&&typeof a==`function`&&a(e,{success:t})},s=e=>{o(e,r===window||r===document||n.useGlobalTarget||Bc(r,e.target))},c=e=>{o(e,!1)};window.addEventListener(`pointerup`,s,i),window.addEventListener(`pointercancel`,c,i)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),jc(e)&&(e.addEventListener(`focus`,e=>Yc(e,i)),!Uc(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function $c(e){return Gr(e)&&`ownerSVGElement`in e}var el=new WeakMap,tl,nl=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:$c(r)&&`getBBox`in r?r.getBBox()[t]:r[n],rl=nl(`inline`,`width`,`offsetWidth`),il=nl(`block`,`height`,`offsetHeight`);function al({target:e,borderBoxSize:t}){el.get(e)?.forEach(n=>{n(e,{get width(){return rl(e,t)},get height(){return il(e,t)}})})}function ol(e){e.forEach(al)}function sl(){typeof ResizeObserver>`u`||(tl=new ResizeObserver(ol))}function cl(e,t){tl||sl();let n=kc(e);return n.forEach(e=>{let n=el.get(e);n||(n=new Set,el.set(e,n)),n.add(t),tl?.observe(e)}),()=>{n.forEach(e=>{let n=el.get(e);n?.delete(t),n?.size||tl?.unobserve(e)})}}var ll=new Set,ul;function dl(){ul=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};ll.forEach(t=>t(e))},window.addEventListener(`resize`,ul)}function fl(e){return ll.add(e),ul||dl(),()=>{ll.delete(e),!ll.size&&typeof ul==`function`&&(window.removeEventListener(`resize`,ul),ul=void 0)}}function pl(e,t){return typeof e==`function`?fl(e):cl(e,t)}function ml(e){return $c(e)&&e.tagName===`svg`}var hl=[...fc,ca,wa],gl=e=>hl.find(dc(e)),_l=()=>({translate:0,scale:1,origin:0,originPoint:0}),vl=()=>({x:_l(),y:_l()}),yl=()=>({min:0,max:0}),bl=()=>({x:yl(),y:yl()}),xl=new WeakMap;function Sl(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function Cl(e){return typeof e==`string`||Array.isArray(e)}var wl=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],Tl=[`initial`,...wl];function El(e){return Sl(e.animate)||Tl.some(t=>Cl(e[t]))}function Dl(e){return!!(El(e)||e.variants)}function Ol(e,t,n){for(let r in t){let i=t[r],a=n[r];if($s(i))e.addValue(r,i);else if($s(a))e.addValue(r,Js(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,Js(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var kl={current:null},Al={current:!1},jl=typeof window<`u`;function Ml(){if(Al.current=!0,jl)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>kl.current=e.matches;e.addEventListener(`change`,t),t()}else kl.current=!1}var Nl=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Pl={};function Fl(e){Pl=e}function Il(){return Pl}var Ll=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Yo,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Ni.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,U.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=El(t),this.isVariantNode=Dl(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&$s(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];this.current=e,xl.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(Al.current||Ml(),this.shouldReduceMotion=kl.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),ki(this.notifyUpdate),ki(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&vs.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new cs({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:$r(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Io.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&U.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i(),t.owner&&t.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in Pl){let t=Pl[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):bl()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<Nl.length;t++){let n=Nl[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=Ol(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=Js(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(Wr(n)||Kr(n))?n=parseFloat(n):!gl(n)&&wa.test(t)&&(n=Tc(e,t)),this.setBaseTarget(e,$s(n)?n.get():n)),$s(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=Vs(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!$s(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new Qr),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Mc.render(this.render)}},Rl=class extends Ll{constructor(){super(...arguments),this.KeyframeResolver=Oc}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;$s(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},q=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function J({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function Y({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function zl(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Bl(e){return e===void 0||e===1}function Vl({scale:e,scaleX:t,scaleY:n}){return!Bl(e)||!Bl(t)||!Bl(n)}function Hl(e){return Vl(e)||Ul(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Ul(e){return Wl(e.x)||Wl(e.y)}function Wl(e){return e&&e!==`0%`}function Gl(e,t,n){return n+t*(e-n)}function Kl(e,t,n,r,i){return i!==void 0&&(e=Gl(e,i,r)),Gl(e,n,r)+t}function ql(e,t=0,n=1,r,i){e.min=Kl(e.min,t,n,r,i),e.max=Kl(e.max,t,n,r,i)}function Jl(e,{x:t,y:n}){ql(e.x,t.translate,t.scale,t.originPoint),ql(e.y,n.translate,n.scale,n.originPoint)}var Yl=.999999999999,Xl=1.0000000000001;function Zl(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(Ql(e.x,-a.scroll.offset.x),Ql(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Jl(e,o)),r&&Hl(a.latestValues)&&tu(e,a.latestValues,a.layout?.layoutBox))}t.x<Xl&&t.x>Yl&&(t.x=1),t.y<Xl&&t.y>Yl&&(t.y=1)}function Ql(e,t){e.min+=t,e.max+=t}function $l(e,t,n,r,i=.5){ql(e,t,n,Oa(e.min,e.max,i),r)}function eu(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function tu(e,t,n){let r=n??e;$l(e.x,eu(t.x,r.x),t.scaleX,t.scale,t.originX),$l(e.y,eu(t.y,r.y),t.scaleY,t.scale,t.originY)}function nu(e,t){return J(zl(e.getBoundingClientRect(),t))}function ru(e,t,n){let r=nu(e,n),{scroll:i}=t;return i&&(Ql(r.x,i.offset.x),Ql(r.y,i.offset.y)),r}var iu={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},au=Fo.length;function ou(e,t,n){let r=``,i=!0;for(let a=0;a<au;a++){let o=Fo[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===(o.startsWith(`scale`)?1:0);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=Ac(s,xc[o]);if(!c){i=!1;let t=iu[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}return r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function su(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(Io.has(e)){o=!0;continue}else if(Ii(e)){i[e]=n;continue}else{let t=Ac(n,xc[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=ou(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}function cu(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function lu(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var uu={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(G.test(e))e=parseFloat(e);else return e;return`${lu(e,t.target.x)}% ${lu(e,t.target.y)}%`}},du={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=wa.parse(e);if(i.length>5)return r;let a=wa.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=Oa(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},fu={borderRadius:{...uu,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:uu,borderTopRightRadius:uu,borderBottomLeftRadius:uu,borderBottomRightRadius:uu,boxShadow:du};function pu(e,{layout:t,layoutId:n}){return Io.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!fu[e]||e===`opacity`)}function mu(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)($s(r[t])||i&&$s(i[t])||pu(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function hu(e){return window.getComputedStyle(e)}var gu=class extends Rl{constructor(){super(...arguments),this.type=`html`,this.renderInstance=cu}readValueFromInstance(e,t){if(Io.has(t))return this.projection?.isProjecting?jo(t):No(e,t);{let n=hu(e),r=(Ii(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return nu(e,t)}build(e,t,n){su(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return mu(e,t,n)}},_u={offset:`stroke-dashoffset`,array:`stroke-dasharray`},vu={offset:`strokeDashoffset`,array:`strokeDasharray`};function yu(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?_u:vu;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var bu=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function xu(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(su(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of bu)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&yu(d,i,a,o,!1)}var Su=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),Cu=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function wu(e,t,n,r){cu(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(Su.has(n)?n:nc(n),t.attrs[n])}function Tu(e,t,n){let r=mu(e,t,n);for(let n in e)if($s(e[n])||$s(t[n])){let t=Fo.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var Eu=class extends Rl{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=bl}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Io.has(t)){let e=Cc(t);return e&&e.default||0}return t=Su.has(t)?t:nc(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Tu(e,t,n)}build(e,t,n){xu(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){wu(e,t,n,r)}mount(e){this.isSVGTag=Cu(e.tagName),super.mount(e)}},Du=Tl.length;function Ou(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&Ou(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<Du;n++){let r=Tl[n],i=e.props[r];(Cl(i)||i===!1)&&(t[r]=i)}return t}function ku(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var Au=[...wl].reverse(),ju=wl.length;function Mu(e){return t=>Promise.all(t.map(({animation:t,options:n})=>lc(e,t,n)))}function Nu(e){let t=Mu(e),n=Iu(),r=!0,i=!1,a=t=>(n,r)=>{let i=Hs(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=Ou(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<ju;t++){let p=Au[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=Cl(h),_=p===o?m.isActive:null;_===!1&&(f=t);let v=h===c[p]&&h!==s[p]&&g;if(v&&(r||i)&&e.manuallyAnimateOnMount&&(v=!1),m.protectedKeys={...d},!m.isActive&&_===null||!h&&!m.prevProp||Sl(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=Pu(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,T={...w,...C},E=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=Ys(t)&&Ys(n)?!ku(t,n):t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let ee=v&&y;b&&(!ee||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!ee&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=Hs(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=Es(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Hs(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Iu(),i=!0}}}function Pu(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!ku(t,e):!1}function Fu(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Iu(){return{animate:Fu(!0),whileInView:Fu(),whileHover:Fu(),whileTap:Fu(),whileDrag:Fu(),whileFocus:Fu(),exit:Fu()}}function Lu(e,t){e.min=t.min,e.max=t.max}function Ru(e,t){Lu(e.x,t.x),Lu(e.y,t.y)}function zu(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var Bu=1e-4,Vu=1-Bu,Hu=1+Bu,Uu=.01,Wu=0-Uu,Gu=0+Uu;function X(e){return e.max-e.min}function Ku(e,t,n){return Math.abs(e-t)<=n}function qu(e,t,n,r=.5){e.origin=r,e.originPoint=Oa(t.min,t.max,e.origin),e.scale=X(n)/X(t),e.translate=Oa(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Vu&&e.scale<=Hu||isNaN(e.scale))&&(e.scale=1),(e.translate>=Wu&&e.translate<=Gu||isNaN(e.translate))&&(e.translate=0)}function Ju(e,t,n,r){qu(e.x,t.x,n.x,r?r.originX:void 0),qu(e.y,t.y,n.y,r?r.originY:void 0)}function Yu(e,t,n,r=0){e.min=(r?Oa(n.min,n.max,r):n.min)+t.min,e.max=e.min+X(t)}function Xu(e,t,n,r){Yu(e.x,t.x,n.x,r?.x),Yu(e.y,t.y,n.y,r?.y)}function Zu(e,t,n,r=0){let i=r?Oa(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+X(t)}function Qu(e,t,n,r){Zu(e.x,t.x,n.x,r?.x),Zu(e.y,t.y,n.y,r?.y)}function $u(e,t,n,r,i){return e-=t,e=Gl(e,1/n,r),i!==void 0&&(e=Gl(e,1/i,r)),e}function ed(e,t=0,n=1,r=.5,i,a=e,o=e){if(ra.test(t)&&(t=parseFloat(t),t=Oa(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=Oa(a.min,a.max,r);e===a&&(s-=t),e.min=$u(e.min,t,n,s,i),e.max=$u(e.max,t,n,s,i)}function td(e,t,[n,r,i],a,o){ed(e,t[n],t[r],t[i],t.scale,a,o)}var nd=[`x`,`scaleX`,`originX`],rd=[`y`,`scaleY`,`originY`];function id(e,t,n,r){td(e.x,t,nd,n?n.x:void 0,r?r.x:void 0),td(e.y,t,rd,n?n.y:void 0,r?r.y:void 0)}function ad(e){return e.translate===0&&e.scale===1}function od(e){return ad(e.x)&&ad(e.y)}function sd(e,t){return e.min===t.min&&e.max===t.max}function cd(e,t){return sd(e.x,t.x)&&sd(e.y,t.y)}function ld(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function ud(e,t){return ld(e.x,t.x)&&ld(e.y,t.y)}function dd(e){return X(e.x)/X(e.y)}function fd(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function pd(e){return[e(`x`),e(`y`)]}function md(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,rotateX:i,rotateY:a,skewX:o,skewY:s}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotateX(${i}deg) `),a&&(r+=`rotateY(${a}deg) `),o&&(r+=`skewX(${o}deg) `),s&&(r+=`skewY(${s}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var hd=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`],gd=hd.length,_d=e=>typeof e==`string`?parseFloat(e):e,vd=e=>typeof e==`number`||G.test(e);function yd(e,t,n,r,i,a){i?(e.opacity=Oa(0,n.opacity??1,Z(r)),e.opacityExit=Oa(t.opacity??1,0,xd(r))):a&&(e.opacity=Oa(t.opacity??1,n.opacity??1,r));for(let i=0;i<gd;i++){let a=hd[i],o=bd(t,a),s=bd(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||vd(o)===vd(s)?(e[a]=Math.max(Oa(_d(o),_d(s),r),0),(ra.test(s)||ra.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=Oa(t.rotate||0,n.rotate||0,r))}function bd(e,t){return e[t]===void 0?e.borderRadius:e[t]}var Z=Sd(0,.5,mi),xd=Sd(.5,.95,Jr);function Sd(e,t,n){return r=>r<e?0:r>t?1:n(Zr(e,t,r))}function Cd(e,t,n){let r=$s(e)?e:Js(e);return r.start(zs(``,r,t,n)),r.animation}function wd(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var Td=(e,t)=>e.depth-t.depth,Ed=class{constructor(){this.children=[],this.isDirty=!1}add(e){Br(this.children,e),this.isDirty=!0}remove(e){Vr(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Td),this.isDirty=!1,this.children.forEach(e)}};function Dd(e,t){let n=Ni.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(ki(r),e(a-t))};return U.setup(r,!0),()=>ki(r)}function Od(e){return $s(e)?e.get():e}var kd=class{constructor(){this.members=[]}add(e){Br(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(Vr(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Vr(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},Ad={hasAnimatedSinceResize:!0,hasEverUpdated:!1},jd={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},Md=[``,`X`,`Y`,`Z`],Nd=1e3,Pd=0;function Fd(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Id(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=ic(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,U,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Id(r)}function Ld({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=Pd++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,Ti.value&&(jd.nodes=jd.calculatedTargetDeltas=jd.calculatedProjections=0),this.nodes.forEach(Bd),this.nodes.forEach(Yd),this.nodes.forEach(Xd),this.nodes.forEach(Vd),Ti.addProjectionMetrics&&Ti.addProjectionMetrics(jd)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new Ed)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new Qr),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=$c(t)&&!ml(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;U.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=Dd(i,250),Ad.hasAnimatedSinceResize&&(Ad.hasAnimatedSinceResize=!1,this.nodes.forEach(Jd)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||rf,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!ud(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...Is(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l)}else t||Jd(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),ki(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Zd),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Id(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(Wd),this.nodes.forEach(Ud);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Gd);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Kd),this.nodes.forEach(qd),this.nodes.forEach(Rd),this.nodes.forEach(zd)):this.nodes.forEach(Gd),this.clearAllSnapshots();let e=Ni.now();W.delta=Hr(0,1e3/60,e-W.timestamp),W.timestamp=e,W.isProcessing=!0,Ai.update.process(W),Ai.preRender.process(W),Ai.render.process(W),W.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Mc.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Hd),this.sharedNodes.forEach(Qd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,U.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){U.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!X(this.snapshot.measuredBox.x)&&!X(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||=bl(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!od(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Hl(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),cf(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return bl();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(uf))){let{scroll:e}=this.root;e&&(Ql(t.x,e.offset.x),Ql(t.y,e.offset.y))}return t}removeElementScroll(e){let t=bl();if(Ru(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&Ru(t,e),Ql(t.x,i.offset.x),Ql(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||bl();Ru(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(Ql(r.x,-n.scroll.offset.x),Ql(r.y,-n.scroll.offset.y)),Hl(n.latestValues)&&tu(r,n.latestValues,n.layout?.layoutBox)}return Hl(this.latestValues)&&tu(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=bl();Ru(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Hl(n.latestValues))continue;let r;n.instance&&(Vl(n.latestValues)&&n.updateSnapshot(),r=bl(),Ru(r,n.measurePageBox())),id(t,n.latestValues,n.snapshot?.layoutBox,r)}return Hl(this.latestValues)&&id(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0?!0:e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==W.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=W.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=bl(),this.targetWithTransforms=bl()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Xu(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Ru(this.target,this.layout.layoutBox),Jl(this.target,this.targetDelta)):Ru(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),Ti.value&&jd.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Vl(this.parent.latestValues)||Ul(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=bl(),this.relativeTargetOrigin=bl(),Qu(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Ru(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===W.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;Ru(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;Zl(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=bl());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(zu(this.prevProjectionDelta.x,this.projectionDelta.x),zu(this.prevProjectionDelta.y,this.projectionDelta.y)),Ju(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!fd(this.projectionDelta.x,this.prevProjectionDelta.x)||!fd(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),Ti.value&&jd.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=vl(),this.projectionDelta=vl(),this.projectionDeltaWithTransform=vl()}setAnimationOrigin(e,t=!1){let n=this.snapshot,r=n?n.latestValues:{},i={...this.latestValues},a=vl();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=bl(),s=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),c=this.getStack(),l=!c||c.members.length<=1,u=!!(s&&!l&&this.options.crossfade===!0&&!this.path.some(nf));this.animationProgress=0;let d;this.mixTargetDelta=t=>{let n=t/1e3;$d(a.x,e.x,n),$d(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Qu(o,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),tf(this.relativeTarget,this.relativeTargetOrigin,o,n),d&&cd(this.relativeTarget,d)&&(this.isProjectionDirty=!1),d||=bl(),Ru(d,this.relativeTarget)),s&&(this.animationValues=i,yd(i,r,this.latestValues,n,u,l)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(ki(this.pendingAnimation),void 0),this.pendingAnimation=U.update(()=>{Ad.hasAnimatedSinceResize=!0,Pi.layout++,this.motionValue||=Js(0),this.motionValue.jump(0,!1),this.currentAnimation=Cd(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{Pi.layout--},onComplete:()=>{Pi.layout--,e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Nd),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&lf(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||bl();let t=X(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=X(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}Ru(t,n),tu(t,i),Ju(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new kd),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return e?e.lead===this:!0}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&Fd(`z`,e,r,this.animationValues);for(let t=0;t<Md.length;t++)Fd(`rotate${Md[t]}`,e,r,this.animationValues),Fd(`skew${Md[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=Od(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=Od(t?.pointerEvents)||``),this.hasProjected&&!Hl(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=md(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,r.animationValues?e.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in fu){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=fu[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?Od(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(Ud),this.root.sharedNodes.clear()}}}function Rd(e){e.updateLayout()}function zd(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)pd(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=X(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Lu(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else lf(i,t.layoutBox,n)&&pd(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=X(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=vl();Ju(o,n,t.layoutBox);let s=vl();a?Ju(s,e.applyTransform(r,!0),t.measuredBox):Ju(s,n,t.layoutBox);let c=!od(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=bl();Qu(s,t.layoutBox,i.layoutBox,o);let c=bl();Qu(c,n,a.layoutBox,o),ud(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function Bd(e){Ti.value&&jd.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function Vd(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Hd(e){e.clearSnapshot()}function Ud(e){e.clearMeasurements()}function Wd(e){e.isLayoutDirty=!0,e.updateLayout()}function Gd(e){e.isLayoutDirty=!1}function Kd(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function qd(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function Jd(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Yd(e){e.resolveTargetDelta()}function Xd(e){e.calcProjection()}function Zd(e){e.resetSkewAndRotation()}function Qd(e){e.removeLeadSnapshot()}function $d(e,t,n){e.translate=Oa(t.translate,0,n),e.scale=Oa(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ef(e,t,n,r){e.min=Oa(t.min,n.min,r),e.max=Oa(t.max,n.max,r)}function tf(e,t,n,r){ef(e.x,t.x,n.x,r),ef(e.y,t.y,n.y,r)}function nf(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var rf={duration:.45,ease:[.4,0,.1,1]},af=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),of=af(`applewebkit/`)&&!af(`chrome/`)?Math.round:Jr;function sf(e){e.min=of(e.min),e.max=of(e.max)}function cf(e){sf(e.x),sf(e.y)}function lf(e,t,n){return e===`position`||e===`preserve-aspect`&&!Ku(dd(t),dd(n),.2)}function uf(e){return e!==e.root&&e.scroll?.wasRoot}var df=Ld({attachResizeListener:(e,t)=>wd(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),ff={current:void 0},pf=Ld({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!ff.current){let e=new df({});e.mount(window),e.setOptions({layoutScroll:!0}),ff.current=e}return ff.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),mf=(0,b.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function hf(e=!0){let t=(0,b.useContext)(zr);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,b.useId)();(0,b.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,b.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var gf=(0,b.createContext)({strict:!1}),_f={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},vf=!1;function yf(){if(vf)return;let e={};for(let t in _f)e[t]={isEnabled:e=>_f[t].some(t=>!!e[t])};Fl(e),vf=!0}function bf(){return yf(),Il()}function xf(e){let t=bf();for(let n in e)t[n]={...t[n],...e[n]};Fl(t)}var Sf=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function Cf(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||Sf.has(e)}var wf=c({default:()=>Tf}),Tf,Ef=o((()=>{throw Tf={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),Df=e=>!Cf(e);function Of(e){typeof e==`function`&&(Df=t=>t.startsWith(`on`)?!Cf(t):e(t))}try{Of((Ef(),d(wf)).default)}catch{}function kf(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||$s(e[i])||(Df(i)||n===!0&&Cf(i)||!t&&!Cf(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var Af=(0,b.createContext)({});function jf(e,t){if(El(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Cl(t)?t:void 0,animate:Cl(n)?n:void 0}}return e.inherit===!1?{}:t}function Mf(e){let{initial:t,animate:n}=jf(e,(0,b.useContext)(Af));return(0,b.useMemo)(()=>({initial:t,animate:n}),[Nf(t),Nf(n)])}function Nf(e){return Array.isArray(e)?e.join(` `):e}var Pf=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ff(e,t,n){for(let r in t)!$s(t[r])&&!pu(r,n)&&(e[r]=t[r])}function If({transformTemplate:e},t){return(0,b.useMemo)(()=>{let n=Pf();return su(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Lf(e,t){let n=e.style||{},r={};return Ff(r,n,e),Object.assign(r,If(e,t)),r}function Rf(e,t){let n={},r=Lf(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var zf=()=>({...Pf(),attrs:{}});function Bf(e,t,n,r){let i=(0,b.useMemo)(()=>{let n=zf();return xu(n,t,Cu(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Ff(t,e.style,e),i.style={...t,...i.style}}return i}var Vf=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function Hf(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(Vf.indexOf(e)>-1||/[A-Z]/u.test(e))}function Uf(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??Hf(e)?Bf:Rf)(t,r,i,e),c=kf(t,typeof e==`string`,a),l=e===b.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,b.useMemo)(()=>$s(u)?u.get():u,[u]);return(0,b.createElement)(e,{...l,children:d})}function Wf({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Gf(n,r,i,e),renderState:t()}}function Gf(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=Od(a[e]);let{initial:o,animate:s}=e,c=El(e),l=Dl(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!Sl(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Vs(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var Kf=e=>(t,n)=>{let r=(0,b.useContext)(Af),i=(0,b.useContext)(zr),a=()=>Wf(e,t,r,i);return n?a():Lr(a)},qf=Kf({scrapeMotionValuesFromProps:mu,createRenderState:Pf}),Jf=Kf({scrapeMotionValuesFromProps:Tu,createRenderState:zf}),Yf=Symbol.for(`motionComponentSymbol`);function Xf(e,t,n){let r=(0,b.useRef)(n);(0,b.useInsertionEffect)(()=>{r.current=n});let i=(0,b.useRef)(null);return(0,b.useCallback)(n=>{n&&e.onMount?.(n);let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n);t&&(n?t.mount(n):t.unmount())},[t])}var Zf=(0,b.createContext)({});function Qf(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function $f(e,t,n,r,i,a){let{visualElement:o}=(0,b.useContext)(Af),s=(0,b.useContext)(gf),c=(0,b.useContext)(zr),l=(0,b.useContext)(mf),u=l.reducedMotion,d=l.skipAnimations,f=(0,b.useRef)(null),p=(0,b.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,b.useContext)(Zf);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&ep(f.current,n,i,h);let g=(0,b.useRef)(!1);(0,b.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[rc],v=(0,b.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return Rr(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,b.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function ep(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:tp(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&Qf(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function tp(e){if(e)return e.options.allowProjection===!1?tp(e.parent):e.projection}function np(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&xf(r);let a=n?n===`svg`:Hf(e),o=a?Jf:qf;function s(n,s){let c,l={...(0,b.useContext)(mf),...n,layoutId:rp(n)},{isStatic:u}=l,d=Mf(n),f=o(n,u);if(!u&&typeof window<`u`){ip(l,r);let t=ap(l);c=t.MeasureLayout,d.visualElement=$f(e,f,l,i,t.ProjectionNode,a)}return(0,H.jsxs)(Af.Provider,{value:d,children:[c&&d.visualElement?(0,H.jsx)(c,{visualElement:d.visualElement,...l}):null,Uf(e,n,Xf(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,b.forwardRef)(s);return c[Yf]=e,c}function rp({layoutId:e}){let t=(0,b.useContext)(Ir).id;return t&&e!==void 0?t+`-`+e:e}function ip(e,t){(0,b.useContext)(gf).strict}function ap(e){let{drag:t,layout:n}=bf();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function op(e,t){if(typeof Proxy>`u`)return np;let n=new Map,r=(n,r)=>np(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,np(a,void 0,e,t)),n.get(a))})}var sp=(e,t)=>t.isSVG??Hf(e)?new Eu(t):new gu(t,{allowProjection:e!==b.Fragment}),cp=class extends q{constructor(e){super(e),e.animationState||=Nu(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();Sl(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},lp=0,up={animation:{Feature:cp},exit:{Feature:class extends q{constructor(){super(...arguments),this.id=lp++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`){let n=Hs(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function dp(e){return{point:{x:e.pageX,y:e.pageY}}}var fp=e=>t=>Vc(t)&&e(t,dp(t));function pp(e,t,n,r){return wd(e,t,fp(n),r)}var mp=({current:e})=>e?e.ownerDocument.defaultView:null,hp=(e,t)=>Math.abs(e-t);function gp(e,t){let n=hp(e.x,t.x),r=hp(e.y,t.y);return Math.sqrt(n**2+r**2)}var _p=new Set([`auto`,`scroll`]),vp=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=yp(this.lastRawMoveEventInfo,this.transformPagePoint));let e=xp(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=gp(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=W;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=yp(t,this.transformPagePoint),U.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=xp(e.type===`pointercancel`?this.lastMoveEventInfo:yp(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!Vc(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=yp(dp(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=W;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,xp(s,this.history)),this.removeListeners=Xr(pp(this.contextWindow,`pointermove`,this.handlePointerMove),pp(this.contextWindow,`pointerup`,this.handlePointerUp),pp(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(_p.has(e.overflowX)||_p.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),U.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ki(this.updatePoint)}};function yp(e,t){return t?{point:t(e.point)}:e}function bp(e,t){return{x:e.x-t.x,y:e.y-t.y}}function xp({point:e},t){return{point:e,delta:bp(e,Cp(t)),offset:bp(e,Sp(t)),velocity:wp(t,.1)}}function Sp(e){return e[0]}function Cp(e){return e[e.length-1]}function wp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=Cp(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>$r(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>$r(t)*2&&(r=e[1]);let a=ei(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function Tp(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?Oa(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?Oa(n,e,r.max):Math.min(e,n)),e}function Ep(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function Dp(e,{top:t,left:n,bottom:r,right:i}){return{x:Ep(e.x,n,i),y:Ep(e.y,t,r)}}function Op(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function kp(e,t){return{x:Op(e.x,t.x),y:Op(e.y,t.y)}}function Ap(e,t){let n=.5,r=X(e),i=X(t);return i>r?n=Zr(t.min,t.max-r,e.min):r>i&&(n=Zr(e.min,e.max-i,t.min)),Hr(0,1,n)}function jp(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var Mp=.35;function Np(e=Mp){return e===!1?e=0:e===!0&&(e=Mp),{x:Pp(e,`left`,`right`),y:Pp(e,`top`,`bottom`)}}function Pp(e,t,n){return{min:Fp(e,t),max:Fp(e,n)}}function Fp(e,t){return typeof e==`number`?e:e[t]||0}var Ip=new WeakMap,Lp=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=bl(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(dp(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Ic(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),pd(e=>{let t=this.getAxisMotionValue(e).get()||0;if(ra.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=X(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&U.update(()=>i(e,t),!1,!0),tc(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=Vp(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&U.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new vp(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:mp(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&U.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!Bp(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Tp(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&Qf(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=Dp(n.layoutBox,e):this.constraints=!1,this.elastic=Np(t),r!==this.constraints&&!Qf(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&pd(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=jp(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Qf(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=ru(n,r.root,this.visualElement.getTransformPagePoint()),a=kp(r.layout.layoutBox,i);if(t){let e=t(Y(a));this.hasMutatedConstraints=!!e,e&&(a=J(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=pd(o=>{if(!Bp(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return tc(this.visualElement,e),n.start(zs(e,n,0,t,this.visualElement,!1))}stopAnimation(){pd(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps();return n[t]||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){pd(t=>{let{drag:n}=this.getProps();if(!Bp(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-Oa(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Qf(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};pd(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Ap({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),pd(t=>{if(!Bp(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(Oa(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Ip.set(this.visualElement,this);let e=this.visualElement.current,t=pp(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&Gc(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();Qf(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=zp(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),U.read(r);let o=wd(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(pd(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=Mp,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function Rp(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function zp(e,t,n){let r=pl(e,Rp(n)),i=pl(t,Rp(n));return()=>{r(),i()}}function Bp(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Vp(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var Hp=class extends q{constructor(e){super(e),this.removeGroupControls=Jr,this.removeListeners=Jr,this.controls=new Lp(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Jr}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},Up=e=>(t,n)=>{e&&U.update(()=>e(t,n),!1,!0)},Wp=class extends q{constructor(){super(...arguments),this.removePointerDownListener=Jr}onPointerDown(e){this.session=new vp(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:mp(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Up(e),onStart:Up(t),onMove:Up(n),onEnd:(e,t)=>{delete this.session,r&&U.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=pp(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},Gp=!1,Kp=class extends b.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),Gp&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Ad.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),Gp=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||U.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),Mc.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Gp=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function qp(e){let[t,n]=hf(),r=(0,b.useContext)(Ir);return(0,H.jsx)(Kp,{...e,layoutGroup:r,switchLayoutGroup:(0,b.useContext)(Zf),isPresent:t,safeToRemove:n})}var Jp={pan:{Feature:Wp},drag:{Feature:Hp,ProjectionNode:pf,MeasureLayout:qp}};function Yp(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&U.postRender(()=>i(t,dp(t)))}var Xp=class extends q{mount(){let{current:e}=this.node;e&&(this.unmount=zc(e,(e,t)=>(Yp(this.node,t,`Start`),e=>Yp(this.node,e,`End`))))}unmount(){}},Zp=class extends q{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=Xr(wd(this.node.current,`focus`,()=>this.onFocus()),wd(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function Qp(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&U.postRender(()=>i(t,dp(t)))}var $p=class extends q{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Qc(e,(e,t)=>(Qp(this.node,t,`Start`),(e,{success:t})=>Qp(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},em=new WeakMap,tm=new WeakMap,nm=e=>{let t=em.get(e.target);t&&t(e)},rm=e=>{e.forEach(nm)};function im({root:e,...t}){let n=e||document;tm.has(n)||tm.set(n,{});let r=tm.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(rm,{root:e,...t})),r[i]}function am(e,t,n){let r=im(t);return em.set(e,n),r.observe(e),()=>{em.delete(e),r.unobserve(e)}}var om={some:0,all:1},sm=class extends q{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:om[r]};this.stopObserver=am(this.node.current,a,e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)})}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(cm(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function cm({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var lm={inView:{Feature:sm},tap:{Feature:$p},focus:{Feature:Zp},hover:{Feature:Xp}},um={layout:{ProjectionNode:pf,MeasureLayout:qp}},dm=op({...up,...lm,...Jp,...um},sp),fm=24e3,pm=2048,mm=1200,hm=.05,gm=4,_m=.03,vm=2,ym=11;function bm(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t/e.length)}function xm(e){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++){let r=Math.max(-1,Math.min(1,e[n]));t[n]=r<0?r*32768:r*32767}return t}function Sm(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]/32768;return t}var Cm=.09,wm=[`audio/webm`,`audio/mp4`];function Tm(){return typeof window>`u`||window.MediaRecorder===void 0?null:wm.find(e=>window.MediaRecorder.isTypeSupported(e))||null}function Em(e,t,n,r,i){if(!r.length||!n||!e)return;let a=new Blob(r,{type:i}),o=new FormData;o.append(`audio`,a,`aichat-${n}.webm`),o.append(`voiceSessionId`,n),o.append(`siteId`,t||``),fetch(`${e}/api/voice/upload-chat-recording`,{method:`POST`,body:o}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(e=>console.warn(`[FlowEngage] voice recording upload failed:`,e.message))}function Dm(e,t,n){let r=0,i=0,a=[],o=()=>{a.forEach(e=>{try{e.stop()}catch{}}),a=[],r=0},s=()=>r>e.currentTime;return{enqueue:o=>{let c=Sm(o),l=e.createBuffer(1,c.length,fm);l.copyToChannel(c,0);let u=e.createBufferSource();u.buffer=l,u.connect(e.destination),n&&u.connect(n);let d=!s(),f=d?e.currentTime+Cm:r;d&&(i=f),u.start(f),r=f+l.duration,a.push(u),u.onended=()=>{a=a.filter(e=>e!==u),!a.length&&!s()&&t?.()}},stop:o,isPlaying:s,playedMs:()=>Math.max(0,(e.currentTime-i)*1e3)}}async function Om(e,t,n){let r=new URLSearchParams({siteId:t||``});n&&r.set(`chatId`,n);let i=await fetch(`${e}/api/voice/session?${r.toString()}`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(i.status===429){let e=await i.json().catch(()=>({}));throw Error(e.message||`Too many voice sessions started. Please wait a minute before trying again.`)}if(!i.ok)throw Error(`Could not start a voice session.`);let a=await i.json();if(!a?.success||!a.wsUrl)throw Error(a?.error||`Voice session was refused.`);return a}async function km(e){let{apiBaseUrl:t,siteId:n,chatId:r,clientTools:i={},onConnect:a,onDisconnect:o,onMessage:s,onModeChange:c,onError:l,onUnhandledClientToolCall:u,onAgentTurnEnd:d,onSessionInfo:f,onSessionEnding:p}=e,m=await Om(t,n,r);f?.({emailOnFile:!!m.emailOnFile});let h={type:`Start`};e.greeting!==void 0&&(h.greeting=e.greeting||null);let g=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),_=new(window.AudioContext||window.webkitAudioContext)({sampleRate:fm});_.state===`suspended`&&await _.resume();let v=_.createMediaStreamDestination(),y=Tm(),b=[],x=null,S=r||n||null;y&&(x=new window.MediaRecorder(v.stream,{mimeType:y}),x.ondataavailable=e=>{e.data&&e.data.size>0&&b.push(e.data)},x.start());let C=new WebSocket(m.wsUrl);C.binaryType=`arraybuffer`;let w=new Set,T={role:null,text:``,timer:null,debug:null},E=``,ee=()=>{T.timer&&=(clearTimeout(T.timer),null);let e=T.text.trim(),t=T.role,n=T.debug;if(T.text=``,T.role=null,T.debug=null,!(!e||!t)){if(t===`agent`){if(e===E){console.debug(`[FlowEngage] duplicate agent turn suppressed`);return}E=e}s?.({role:t,message:e,debug:n})}},te=(e,t,n)=>{t&&(T.role&&T.role!==e&&ee(),T.role=e,T.text=T.text?`${T.text} ${t}`.replace(/\s+/g,` `):t,n&&(T.debug=n),T.timer&&clearTimeout(T.timer),T.timer=setTimeout(ee,mm))},D=!1,O=!1,ne=!1,re=!1,ie=!0,ae=0,oe=!1,k=!1,A=hm,se=gm,ce=null,le=!1,ue=()=>{ce&&clearTimeout(ce);let e=()=>{if(!D){if(j.isPlaying()){ce=setTimeout(e,150);return}if(ce=null,le){p?.();return}!D&&C.readyState===WebSocket.OPEN&&C.send(JSON.stringify({type:`PlaybackDrained`})),d?.()}};ce=setTimeout(e,150)},j=Dm(_,()=>{re&&(re=!1,c?.({mode:`listening`}))},v),M=_.createMediaStreamSource(g);M.connect(v);let de=_.createScriptProcessor(pm,1,1),fe=!1,N=0,pe=0;de.onaudioprocess=e=>{if(D||C.readyState!==WebSocket.OPEN)return;let t=e.inputBuffer.getChannelData(0),n=()=>C.send(new Int16Array(t.length).buffer);if(O){ne||(ne=!0,console.debug(`[FlowEngage] mic held — streaming silence to keep socket alive`)),fe=!1,N=0,pe=0,n();return}let r=bm(t);if(j.isPlaying()||k?(fe=!1,N=0,pe=0):r>=_m?(pe=0,N+=1,!fe&&N>=vm&&(fe=!0,c?.({mode:`user-speaking`}))):(N=0,fe&&++pe>=ym&&(fe=!1,pe=0,c?.({mode:`thinking`,tentative:!0}))),(j.isPlaying()||k)&&!oe){if(r<A){ae=0,n();return}if(ae+=1,ae<se){n();return}oe=!0,ae=0;let e=j.playedMs();j.stop(),ie=!1,k=!1,ce&&!le&&(clearTimeout(ce),ce=null),C.send(JSON.stringify({type:`VisitorInterrupted`,played_ms:Math.round(e)})),console.debug(`[FlowEngage] barge-in — visitor spoke over the agent`)}C.send(xm(t).buffer)},M.connect(de),de.connect(_.destination);let me=()=>{if(!D){D=!0,ce&&=(clearTimeout(ce),null),ee(),j.stop();try{de.disconnect(),M.disconnect()}catch{}if(g.getTracks().forEach(e=>e.stop()),x&&x.state!==`inactive`){x.onstop=()=>Em(t,n,S,b,y);try{x.stop()}catch{x.onstop=null}}else b.length&&Em(t,n,S,b,y);_.close().catch(()=>{}),(C.readyState===WebSocket.OPEN||C.readyState===WebSocket.CONNECTING)&&C.close()}},he=async e=>{let t=i[e.name];if(!t)return u?.({tool_name:e.name}),{error:`Unknown tool ${e.name}`};let n={};try{n=JSON.parse(e.arguments||`{}`)}catch{}try{return await t(n)}catch(e){return{error:e?.message||`Tool execution failed`}}},ge=async e=>{for(let t of e.functions||[]){if(!t.client_side)continue;let e=await he(t);if(D||C.readyState!==WebSocket.OPEN)return;C.send(JSON.stringify({type:`FunctionCallResponse`,id:t.id,name:t.name,content:typeof e==`string`?e:JSON.stringify(e??{})}))}},P=e=>{switch(e.type){case`Welcome`:Number.isFinite(e.barge_in_rms)&&e.barge_in_rms>0&&(A=e.barge_in_rms),Number.isFinite(e.barge_in_frames)&&e.barge_in_frames>0&&(se=e.barge_in_frames),S=e.session_id||r||n||null,a?.({conversationId:S});break;case`ConversationText`:{let t=String(e.content||``);if(e.role===`user`){let e=t.trim();if(w.has(e)){w.delete(e);break}if(/^\[SYSTEM:/i.test(e)||/^Continue (now )?to the next section/i.test(e)||/^That was the last section/i.test(e)){console.debug(`[FlowEngage] widget instruction hidden from transcript`);break}}te(e.role===`user`?`user`:`agent`,t,e.debug);break}case`UserStartedSpeaking`:ee(),j.stop(),k=!1,ie=!1,re=!1,ce&&!le&&(clearTimeout(ce),ce=null),c?.({mode:`listening`});break;case`AgentStartedSpeaking`:ie=!0,re=!0,oe=!1,ae=0,c?.({mode:`speaking`});break;case`AgentAudioDone`:k=!1,ee(),ue(),j.isPlaying()||(re=!1,c?.({mode:`listening`}));break;case`FunctionCallRequest`:ge(e);break;case`AgentPreparing`:k=!0;break;case`SessionEnding`:console.debug(`[FlowEngage] server is ending the session:`,e.reason||`unspecified`),le=!0;break;case`AgentThinking`:c?.({mode:`thinking`});break;case`PromptUpdated`:break;case`Error`:console.error(`[FlowEngage:Voice]`,e.code||``,e.description||e),l?.(Error(e.description||`Voice service error`));break;case`Warning`:console.warn(`[FlowEngage:Voice]`,e.code||``,e.description||``);break;default:break}};return C.onopen=()=>C.send(JSON.stringify(h)),C.onmessage=e=>{if(e.data instanceof ArrayBuffer){ie&&j.enqueue(new Int16Array(e.data));return}try{P(JSON.parse(e.data))}catch{}},C.onerror=()=>l?.(Error(`Voice connection failed`)),C.onclose=()=>{me(),o?.()},{endSession:async()=>me(),sendContextualUpdate:e=>{D||C.readyState!==WebSocket.OPEN||!e||C.send(JSON.stringify({type:`UpdatePrompt`,prompt:e}))},sendUserMessage:(e,{silent:t=!0,suppressQuestion:n=!1}={})=>{D||C.readyState!==WebSocket.OPEN||!e||(t&&w.add(e.trim()),C.send(JSON.stringify({type:`InjectUserMessage`,content:e,suppress_question:n})))},injectAgentSpeech:(e,t=`interrupt`)=>{D||C.readyState!==WebSocket.OPEN||!e||C.send(JSON.stringify({type:`InjectAgentMessage`,message:e,behavior:t}))},setWalkthroughActive:e=>{D||C.readyState!==WebSocket.OPEN||C.send(JSON.stringify({type:`WalkthroughActive`,active:!!e}))},setMicMuted:e=>{O=!!e,!D&&C.readyState===WebSocket.OPEN&&C.send(JSON.stringify({type:`MicHeld`,held:O}))},get status(){return D?`disconnected`:`connected`}}}var Am={startSession:km},jm=({size:e=18,color:t=`currentColor`})=>(0,H.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,H.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`,fill:t}),(0,H.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`,stroke:t,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),Mm=({size:e=20})=>(0,H.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.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,H.jsx)(`line`,{x1:`23`,y1:`1`,x2:`1`,y2:`23`})]}),Nm=({size:e=18})=>(0,H.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`5`}),(0,H.jsx)(`polyline`,{points:`5 12 12 5 19 12`})]}),Pm=()=>(0,H.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`polyline`,{points:`9 17 4 12 9 7`}),(0,H.jsx)(`path`,{d:`M20 18v-2a4 4 0 00-4-4H4`})]}),Fm=()=>(0,H.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,H.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`})}),Im=({className:e=``})=>(0,H.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,H.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,H.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,H.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),Lm=({size:e=14})=>(0,H.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{d:`M12 8V4H8`}),(0,H.jsx)(`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`}),(0,H.jsx)(`path`,{d:`M2 14h2`}),(0,H.jsx)(`path`,{d:`M20 14h2`}),(0,H.jsx)(`path`,{d:`M15 13v2`}),(0,H.jsx)(`path`,{d:`M9 13v2`})]}),Rm=({size:e=20,strokeWidth:t=2,color:n=`currentColor`})=>(0,H.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:n,strokeWidth:t,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,H.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),zm=({size:e=20,color:t=`currentColor`})=>(0,H.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,H.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:t}),(0,H.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:t}),(0,H.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:t})]}),Bm=({size:e=20,color:t=`currentColor`})=>(0,H.jsxs)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,H.jsx)(`path`,{d:`M22 11.5667C22 16.8499 17.5222 21.1334 12 21.1334C11.3507 21.1343 10.7032 21.0742 10.0654 20.9545C9.60633 20.8682 9.37678 20.8251 9.21653 20.8496C9.05627 20.8741 8.82918 20.9948 8.37499 21.2364C7.09014 21.9197 5.59195 22.161 4.15111 21.893C4.69874 21.2194 5.07275 20.4112 5.23778 19.5448C5.33778 19.0148 5.09 18.5 4.71889 18.1231C3.03333 16.4115 2 14.1051 2 11.5667C2 6.28357 6.47778 2 12 2C17.5222 2 22 6.28357 22 11.5667Z`,stroke:`white`,"stroke-width":`1.5`,"stroke-linejoin":`round`}),(0,H.jsx)(`path`,{d:`M11.9955 12H12.0045M15.991 12H16M8 12H8.00897`,stroke:`white`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]}),Vm=()=>(0,H.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,H.jsx)(`path`,{d:`M16.7133 8.59374C18.1939 8.98463 19.2229 9.47922 20.1589 10.0848C21.5432 10.9804 22.1367 12.5944 21.9737 14.1517C21.9049 14.8099 21.3744 15.1246 20.7592 14.9544L19.3705 14.57C18.2697 14.2653 17.7193 14.1129 17.3837 13.71C17.0481 13.307 17.0086 12.751 16.9296 11.6391L16.7133 8.59374ZM16.7133 8.59374C13.7164 7.80255 10.2871 7.80163 7.28669 8.59374M7.28669 8.59374C5.80606 8.98463 4.77711 9.47923 3.84113 10.0848C2.45683 10.9804 1.86334 12.5944 2.02628 14.1517C2.09514 14.8099 2.62563 15.1246 3.24078 14.9544L4.62954 14.57C5.73032 14.2653 6.28071 14.1129 6.61631 13.71C6.95191 13.307 6.9914 12.751 7.07038 11.6391L7.28669 8.59374Z`,stroke:`#E30C12`,"stroke-width":`1.5`,"stroke-linejoin":`round`})}),Hm=({size:e=24})=>(0,H.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{d:`M12 19v3`}),(0,H.jsx)(`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`}),(0,H.jsx)(`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`}),(0,H.jsx)(`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`}),(0,H.jsx)(`path`,{d:`m2 2 20 20`}),(0,H.jsx)(`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`})]}),Um=(e=``)=>String(e).replace(/<[^>]+>/g,``).replace(/\s+/g,` `).trim(),Wm=(e=``)=>String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),Gm=new Set([`p`,`br`,`ul`,`ol`,`li`,`strong`,`em`,`b`,`i`,`a`]),Km=/^https?:\/\//i;function qm(e){let t=Array.from(e.childNodes);for(let n of t)if(n.nodeType===Node.ELEMENT_NODE){let t=n.tagName.toLowerCase();if(!Gm.has(t)){e.replaceChild(document.createTextNode(n.textContent),n);continue}let r={};if(t===`a`){let e=n.getAttribute(`href`)||``;Km.test(e)&&(r.href=e),r.target=`_blank`,r.rel=`noopener noreferrer`}for(;n.attributes.length>0;)n.removeAttribute(n.attributes[0].name);for(let[e,t]of Object.entries(r))n.setAttribute(e,t);qm(n)}else n.nodeType!==Node.TEXT_NODE&&e.removeChild(n)}function Jm(e){let t=document.createElement(`div`);return t.innerHTML=e,qm(t),t.innerHTML}function Ym(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 Xm=(e=``)=>{let t=String(e||``).trim();if(!t)return``;if(/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t))return Ym(Jm(t));let n=t.replace(/\r\n/g,`
33
+ `,document.head.appendChild(e)};function ur(e,t){if(typeof document>`u`)return null;if(e){let n=document.getElementById(e)||document.querySelector(`[data-section="${e}"]`);if(n)return n;t||=e.replace(/[-_]+/g,` `).trim()}if(!t)return null;let n=t.toLowerCase().trim(),r=n.split(/\s+/).filter(e=>e.length>2),i=Array.from(document.querySelectorAll(`h1.h2.h3.h4.h5.h6.[data-section].section[id].[id].main li.article li.[role='main'] li.[class*='card'].[class*='Card'].[class*='feature'].[class*='Feature'].[class*='tier'].[class*='Tier'].[class*='plan'].[class*='Plan'].[class*='pricing'].[class*='Pricing'].[class*='testimonial'].[class*='Testimonial'].[class*='team'].[class*='Team'].[class*='service'].[class*='Service'].[class*='block'].[role='listitem'].[role='article'].[role='region'].dt.dd`.split(`.`).join(`, `))).filter(e=>{if(jn(e))return!1;let t=e.textContent.trim();return!(t.length<3||t.length>5e3||e.closest(`nav, footer, header, aside, .nav, .footer, .header`))});for(let e of i)if(Mn(e).toLowerCase()===n)return e;for(let e of i){let t=Mn(e).toLowerCase();if(t.startsWith(n)||t.endsWith(n))return e}let a=[];for(let e of i){let t=Mn(e).toLowerCase();t.includes(n)&&a.push({el:e,len:t.length})}if(a.length)return a.sort((e,t)=>e.len-t.len),a[0].el;for(let e of i){let t=Mn(e).toLowerCase();if(t.length>3&&n.includes(t))return e}if(r.length>0){let e=null,t=0;for(let n of i){let i=Mn(n).toLowerCase(),a=0;for(let e of r)i.includes(e)&&a++;let o=a/r.length;o>t&&o>=.6&&(t=o,e=n)}if(e)return e}let o=Array.from(document.querySelectorAll(`main [role='group']`)).filter(e=>!jn(e)),s=[];for(let e of o){let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();t.length<15||t.length>8e3||t.includes(n)&&s.push({el:e,len:t.length})}if(s.length)return s.sort((e,t)=>e.len-t.len),s[0].el;if(r.length>0){let e=Array.from(document.querySelectorAll(`main a[href], article a[href], .views-row a[href], h2 a[href], h3 a[href], .card a[href], [class*='teaser'] a[href]`)).filter(e=>{if(jn(e))return!1;try{let t=e.getAttribute(`href`)||``;if(!t||t===`#`||t.startsWith(`javascript:`))return!1}catch{return!1}let t=e.textContent.replace(/\s+/g,` `).trim();return t.length>=3&&t.length<=220}),t=null,n=0;for(let i of e){let e=i.textContent.replace(/\s+/g,` `).toLowerCase(),a=0;for(let t of r)e.includes(t)&&a++;let o=a/r.length;o>n&&o>=.5&&(n=o,t=i)}if(t)return t.closest(`article`)||t.closest(`.views-row`)||t}let c=document.querySelectorAll(`section, article, .card, [class*='feature'], [class*='service']`);for(let e of c){if(jn(e))continue;let t=e.querySelector(`h1, h2, h3, h4, h5, h6`);if(t){let r=t.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(r.includes(n)||n.includes(r))return e}}let l=document.querySelectorAll(`li, strong, blockquote, dt`);for(let e of l){if(jn(e))continue;let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<500)return e.tagName===`STRONG`&&e.parentElement?.tagName===`LI`?e.parentElement:e}let u=Array.from(document.querySelectorAll(`a[href]`)).filter(e=>!jn(e));u.sort((e,t)=>(e.textContent||``).trim().length-(t.textContent||``).trim().length);for(let e of u){let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<500)return e}let d=document.querySelectorAll(`p`);for(let e of d){if(jn(e))continue;let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<800)return e}return null}function dr(e,{speaking:t=!1,scroll:n=!0}={}){if(!e||typeof document>`u`)return;lr();let r=document.querySelectorAll(`.fe-highlight-section`);for(let t of r)t!==e&&(t.classList.remove(`fe-highlight-section`,`fe-highlight-speaking`),t.classList.add(`fe-highlight-exiting`),setTimeout(()=>t.classList.remove(`fe-highlight-exiting`),300));if(e.classList.remove(`fe-highlight-exiting`),e.classList.add(`fe-highlight-section`),t?e.classList.add(`fe-highlight-speaking`):e.classList.remove(`fe-highlight-speaking`),n)try{e.scrollIntoView({behavior:`smooth`,block:`center`})}catch{try{e.scrollIntoView(!0)}catch{}}}function fr(){typeof document>`u`||(document.querySelectorAll(`.fe-highlight-section, .fe-highlight-exiting`).forEach(e=>e.classList.remove(`fe-highlight-section`,`fe-highlight-speaking`,`fe-highlight-exiting`)),kn())}function pr(e){if(typeof window>`u`)return e;try{let t=new URL(String(e).trim(),window.location.href);return!/^https?:$/i.test(t.protocol)||t.origin===window.location.origin?t.href:new URL(t.pathname+t.search+t.hash,window.location.origin).href}catch{return e}}async function mr(e){if(typeof window>`u`)return!1;try{let t=new URL(String(e).trim(),window.location.href),n=t.origin===window.location.origin?t.href:new URL(t.pathname+t.search+t.hash,window.location.origin).href;return(await fetch(n,{method:`HEAD`,mode:`same-origin`,cache:`no-store`})).ok}catch{return!1}}async function hr(e,{siteId:t,apiBaseUrl:n}){if(!e)return{allowed:!1,correctedUrl:null};let r=!1;try{r=!!Yn()}catch{r=!1}let i=async()=>({allowed:r?!1:await mr(e),correctedUrl:null});if(!t||!n)return console.warn(`[FlowEngage] shouldProceedWithNavigation: missing siteId or apiBaseUrl`),i();let a=String(n).replace(/\/$/,``),o=new URLSearchParams({siteId:String(t),url:String(e).trim()});try{let e=await(await fetch(`${a}/api/widget/navigate-allowed?${o.toString()}`)).json().catch(()=>({}));return e.success&&e.allowed?{allowed:!0,correctedUrl:e.correctedUrl||null}:i()}catch(e){return console.warn(`[FlowEngage] navigate-allowed check failed:`,e?.message),i()}}function gr(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(Pn,JSON.stringify({sectionText:e,ts:Date.now()}))}catch{}}async function _r(e,{skipPushState:t=!1,isBack:n=!1}={}){if(typeof window>`u`||typeof document>`u`)return!1;try{if(new URL(e,window.location.href).origin!==window.location.origin)return!1}catch{return!1}or();let r=new AbortController,i=setTimeout(()=>r.abort(),8e3);try{let a=await fetch(e,{credentials:`same-origin`,cache:`no-store`,signal:r.signal});if(clearTimeout(i),!a.ok)return sr(),!1;let o=await a.text(),s=new DOMParser().parseFromString(o,`text/html`),c=document.getElementById(`flowengage-root`);if(!c)return sr(),!1;try{typeof window.Drupal?.detachBehaviors==`function`&&window.Drupal.detachBehaviors(document.body,window.drupalSettings)}catch{}document.querySelectorAll(`script`).forEach(e=>{e.setAttribute(`data-fe-original`,`true`)}),Array.from(document.body.children).forEach(e=>{if(e===c)return;let t=e.tagName?.toUpperCase();t===`AUDIO`||t===`VIDEO`||e.remove()}),Zn();let l=new Set(Array.from(document.querySelectorAll(`link[rel='stylesheet']`)).map(e=>{try{return new URL(e.getAttribute(`href`)||``,window.location.href).href}catch{return``}}));for(let t of Array.from(s.head.querySelectorAll(`link[rel='stylesheet']`))){let n=t.getAttribute(`href`);if(!n)continue;let r;try{r=new URL(n,e).href}catch{continue}if(l.has(r))continue;let i=document.createElement(`link`);i.rel=`stylesheet`,i.href=r,i.setAttribute(Xn,`true`),t.media&&(i.media=t.media),document.head.appendChild(i)}for(let e of Array.from(s.head.querySelectorAll(`style`))){if(!e.textContent.trim())continue;let t=e.textContent.trim().slice(0,120);if(Array.from(document.head.querySelectorAll(`style:not([data-fe-swap-css])`)).some(e=>e.textContent.trim().slice(0,120)===t))continue;let n=document.createElement(`style`);n.textContent=e.textContent,n.setAttribute(Xn,`true`),document.head.appendChild(n)}Array.from(s.body.children).forEach(e=>{e.tagName?.toUpperCase()!==`SCRIPT`&&document.body.insertBefore(document.importNode(e,!0),c)});let u=document.querySelectorAll(`script:not([data-fe-replayed])`);for(let e of u){if(e.closest(`#flowengage-root, .flowengage-shell`)||e.hasAttribute(`data-fe-original`)||e.hasAttribute(`data-fe-replayed`))continue;let t=e.getAttribute(`src`),n=e.getAttribute(`type`)||``;if(!(n&&n!==`text/javascript`&&n!==``&&!n.includes(`drupal-ajax`))){if(n.includes(`drupal-ajax`)){e.setAttribute(`data-fe-replayed`,`true`);try{let t=JSON.parse(e.textContent);if(Array.isArray(t))for(let e of t){if((e.command===`insert`||e.command===`insert_new_content`)&&e.selector&&e.data){let t=document.querySelector(e.selector);t&&(e.method===`replaceWith`?t.outerHTML=e.data:e.method===`html`||e.method===`replace`?t.innerHTML=e.data:e.method===`append`?t.insertAdjacentHTML(`beforeend`,e.data):e.method===`prepend`?t.insertAdjacentHTML(`afterbegin`,e.data):t.innerHTML=e.data,Nn(`trySpaNavigate: BigPipe replacement →`,e.selector))}if(e.command===`settings`&&e.settings)try{window.drupalSettings&&typeof window.drupalSettings==`object`&&Object.assign(window.drupalSettings,e.settings)}catch{}}}catch(e){Nn(`trySpaNavigate: BigPipe parse error:`,e.message)}continue}if(!t&&e.textContent.trim()){let t=e.textContent;if(/window\.location\s*[.=]|location\s*\.\s*(href|assign|replace|reload)\s*[=(]/i.test(t)){e.setAttribute(`data-fe-replayed`,`true`);continue}let n=document.createElement(`script`);n.textContent=t,n.setAttribute(`data-fe-replayed`,`true`),e.parentNode.replaceChild(n,e)}}}try{for(let e of Array.from(s.querySelectorAll(`script`))){let t=(e.textContent||``).match(/drupalSettings\s*[,=]\s*(\{[\s\S]*?\})\s*[;)]/);if(t){try{let e=JSON.parse(t[1]);window.drupalSettings&&typeof window.drupalSettings==`object`?Object.assign(window.drupalSettings,e):window.drupalSettings=e,Nn(`trySpaNavigate: updated drupalSettings from new page`)}catch{}break}}}catch{}let d=window.location.assign.bind(window.location),f=window.location.replace.bind(window.location),p=!0;window.location.assign=e=>{if(p){Nn(`trySpaNavigate: blocked location.assign from replayed script:`,e);return}return d(e)},window.location.replace=e=>{if(p){Nn(`trySpaNavigate: blocked location.replace from replayed script:`,e);return}return f(e)};function m(e){let t=e.toLowerCase();return!!(/\/jquery[.\-\/]/.test(t)||/\/jquery\.min\.js/.test(t)||/\/jquery-once/.test(t)||/\/jquery\.once/.test(t)||/\/jquery\.ui[\./]/.test(t)||/\/jqueryui/.test(t)||/\/core\/misc\//.test(t)||/\/core\/modules\//.test(t)||/\/misc\/drupal\.js/.test(t)||/\/lodash[.\-\/]/.test(t)||/\/underscore[.\-\/]/.test(t)||/\/backbone[.\-\/]/.test(t)||/\/modernizr[.\-\/]/.test(t)||/\/popper[.\-\/]/.test(t)||/\/bootstrap\.min\.js/.test(t)||/\/bootstrap\.bundle/.test(t))}let h=new Set(Array.from(document.querySelectorAll(`script[src]`)).map(e=>{try{return new URL(e.getAttribute(`src`)||``,window.location.href).href}catch{return``}}));function g(t,n){let r=t.getAttribute(`src`)||``;if(r.includes(`flowengage`))return;let i=document.createElement(`script`);if(r){let n;try{n=new URL(r,e).href}catch{return}if(h.has(n)){if(m(n))return;Nn(`trySpaNavigate: re-running theme/custom script:`,n)}h.add(n),i.src=n,i.async=t.async,i.defer=t.defer}else if(t.textContent.trim()){let e=t.textContent;if(/window\.location\s*[.=]|location\s*\.\s*(href|assign|replace|reload)\s*[=(]/i.test(e)){Nn(`trySpaNavigate: skipping inline script with navigation:`,e.slice(0,120));return}if(/^\s*\(?\s*(?:window\.)?drupalSettings\s*[,=]/.test(e))return;i.textContent=e}else return;let a=t.getAttribute(`type`);a&&a!==`text/javascript`&&a!==``&&(i.type=a),n.parentNode.insertBefore(i,n)}for(let e of Array.from(s.head.querySelectorAll(`script`)))g(e,c);for(let e of Array.from(s.body.querySelectorAll(`script`)))g(e,c);try{typeof window.Drupal?.attachBehaviors==`function`&&window.Drupal.attachBehaviors(document.body,window.drupalSettings)}catch{}try{typeof window.jQuery==`function`&&(window.jQuery(document).trigger(`ready`),window.dispatchEvent(new Event(`resize`)))}catch{}try{document.dispatchEvent(new Event(`DOMContentLoaded`,{bubbles:!0,cancelable:!1}))}catch{}try{window.dispatchEvent(new Event(`load`))}catch{}try{let e=document.querySelectorAll(`iframe:not([data-fe-skip-reload])`);for(let t of e){if(t.closest(`#flowengage-root, .flowengage-shell`))continue;let e=t.getAttribute(`src`)||t.src;e&&e!==`about:blank`&&!e.startsWith(`javascript:`)&&(Nn(`trySpaNavigate: reloading iframe:`,e),t.src=e)}}catch{}try{let e=document.querySelectorAll(`.g-recaptcha, [data-sitekey]`);if(e.length>0){if(typeof window.grecaptcha?.render==`function`){for(let t of e)if(!t.closest(`#flowengage-root`)){t.innerHTML=``;try{window.grecaptcha.render(t,{sitekey:t.getAttribute(`data-sitekey`)||``}),Nn(`trySpaNavigate: re-rendered reCAPTCHA`)}catch{}}}else if(!document.querySelector(`script[src*='recaptcha']`)){let e=document.createElement(`script`);e.src=`https://www.google.com/recaptcha/api.js?render=explicit`,e.async=!0,document.head.appendChild(e),Nn(`trySpaNavigate: injected reCAPTCHA script`)}}}catch{}if(setTimeout(()=>{p=!1,window.location.assign=d,window.location.replace=f},2e3),s.title&&(document.title=s.title),!t)try{history.pushState({flowengageSpa:!0},``,e)}catch{}if(Wn(),Kn(),n){try{er()}catch{}try{rr()}catch{}}else window.scrollTo(0,0);sr(),ir(e);try{sessionStorage.removeItem(Pn)}catch{}try{sessionStorage.removeItem(In)}catch{}try{Un=new URL(e,window.location.origin).pathname}catch{}return Nn(`trySpaNavigate: succeeded →`,e),!0}catch{return clearTimeout(i),sr(),!1}}function vr(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(In,JSON.stringify({voiceWasActive:!0,targetUrl:String(e),ts:Date.now()}))}catch{}}function yr(){if(!(typeof sessionStorage>`u`))try{sessionStorage.removeItem(In)}catch{}}function br(){if(typeof window>`u`||typeof sessionStorage>`u`)return{shouldResumeVoice:!1,targetUrl:null};let e;try{e=JSON.parse(sessionStorage.getItem(In)||`null`)}catch{return{shouldResumeVoice:!1,targetUrl:null}}if(!e)return{shouldResumeVoice:!1,targetUrl:null};try{sessionStorage.removeItem(In)}catch{}return e.voiceWasActive?Date.now()-e.ts>Ln?(Nn(`initVoiceNavResume: state expired, skipping`),{shouldResumeVoice:!1,targetUrl:null}):(Nn(`initVoiceNavResume: voice was active during navigation to`,e.targetUrl),{shouldResumeVoice:!0,targetUrl:e.targetUrl||null}):{shouldResumeVoice:!1,targetUrl:null}}function xr(){if(typeof document>`u`)return!1;let e=/(^|\W)(404|page not found|not found|page (?:doesn'?t|does not) exist|no longer exists|couldn'?t find (?:this|that|the) page|error 404|oops[!,. ].*(?:not found|doesn'?t exist))(\W|$)/i,t=(document.title||``).trim();if(t&&e.test(t))return!0;let n=document.querySelector(`main, [role="main"], #content, .content`)||document.body;if(n){let t=n.querySelectorAll(`h1, h2`);for(let n of t){let t=(n.textContent||``).replace(/\s+/g,` `).trim();if(t&&t.length<80&&e.test(t))return!0}}return!1}async function Sr(e,t={}){if(typeof window>`u`)return{navigated:!1};let{sectionText:n,voiceActive:r=!1}=t;try{let t=pr(e),i=new URL(t,window.location.origin);if(i.hash&&i.pathname===window.location.pathname){let e=document.getElementById(i.hash.slice(1));if(e)return e.scrollIntoView({behavior:`smooth`,block:`start`}),{navigated:!0}}if(i.pathname===window.location.pathname&&i.search===window.location.search&&!i.hash)return{navigated:!1,reason:`already-on-page`};let a=i.pathname+i.search+i.hash,o=window.next?.router;if(o?.push)return new Promise(e=>{let t=()=>{o.events?.off(`routeChangeComplete`,t),e({navigated:!0})};o.events?.on(`routeChangeComplete`,t),o.push(a),setTimeout(t,5e3)});if(window.__NEXT_ROUTER__?.push)return window.__NEXT_ROUTER__.push(a),{navigated:!0};if(Yn()){n&&gr(n);let e=window.location.href;try{window.history.pushState({},``,i.href),window.dispatchEvent(new PopStateEvent(`popstate`,{state:{}}))}catch{}if(await new Promise(e=>setTimeout(e,400)),xr()){try{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`,{state:{}}))}catch{}return n&&gr(n),r||Ee(),window.location.assign(i.href),{navigated:!0}}return{navigated:!0}}return n&&gr(n),r||Ee(),window.location.assign(i.href),{navigated:!0}}catch(t){console.warn(`[FlowEngage] shadowNavigate error:`,t),n&&gr(n);try{window.location.href=pr(e)}catch{window.location.href=e}return{navigated:!0}}}var Cr=!1,wr=null;function Tr(e){wr=e,typeof window<`u`&&(window.__fe_triggerVoiceNavHooks=()=>{try{e.onBeforeNavigate()}catch{}}),!Cr&&(Cr=!0,!(typeof document>`u`)&&(document.addEventListener(`click`,e=>{if(!wr)return;let t=e.target.closest?.(`a[href]`);if(!t||t.closest(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`))return;let n=t.getAttribute(`href`)||``;if(!n||n===`#`||n.startsWith(`javascript:`)||n.startsWith(`mailto:`)||n.startsWith(`tel:`)||t.hasAttribute(`download`)||t.target===`_blank`||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let r;try{if(r=new URL(n,window.location.href),r.origin!==window.location.origin)return}catch{return}if(!(r.pathname===window.location.pathname&&r.hash)&&!(r.pathname===window.location.pathname&&r.search===window.location.search&&!r.hash)){Nn(`voice-link-hook: saving state before navigation →`,r.href);try{wr.onBeforeNavigate()}catch{}}},!0),document.addEventListener(`submit`,e=>{if(wr&&!e.target?.closest?.(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)){Nn(`voice-form-hook: saving state before form submit`);try{wr.onBeforeNavigate()}catch{}}},!0)))}function Er(){wr=null,Nn(`voice-nav-hooks: deactivated`)}var Dr=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),H=s(((e,t)=>{t.exports=Dr()}))(),Or=e=>!e||typeof e!=`string`?e:e.replace(/<human_assistance_request[^>]*>/gi,``).replace(/<\/human_assistance_request>/gi,``).replace(/<navigate[^>]*\/>/gi,``).replace(/<navigate[^>]*>[\s\S]*?<\/navigate>/gi,``).replace(/<[a-z]+(?:_[a-z]+)+[^>]*>[\s\S]*?<\/[a-z]+(?:_[a-z]+)+>/gi,``).replace(/<[a-z]+(?:_[a-z]+)+[^>]*\/>/gi,``).trim(),kr=(e=[])=>e.filter(e=>e.type!==`call_recording`&&!(typeof e.message==`string`&&e.message.includes(`AI chat recording`))).map(e=>({...e,message:Or(e.message),isPending:!1,id:e.messageId||`${e.sender}-${e.timestamp||Date.now()}-${Math.random()}`}));function Ar(e){if(!e||typeof e!=`string`)return null;let t=e.match(/<navigate([^>]*?)(?:\/>|>[\s\S]*?<\/navigate>)/i);if(!t)return null;let n=t[1],r=n.match(/url=["']([^"']+)["']/i);if(!r)return null;let i=n.match(/section=["']([^"']+)["']/i)||n.match(/highlight=["']([^"']+)["']/i);return{url:r[1].trim(),section:i?.[1]?.trim()||null}}var jr=(e,t)=>e?typeof e==`string`?e:e.message||e.error||e.reason||t:t,Mr=(e={})=>{if(!e?.candidate)return null;if(typeof e.candidate==`object`)return e.candidate;let t=e.sdpMid!==void 0&&e.sdpMid!==null&&e.sdpMid!==``,n=e.sdpMLineIndex!==void 0&&e.sdpMLineIndex!==null;return!t&&!n?null:{candidate:e.candidate,...t?{sdpMid:e.sdpMid}:{},...n?{sdpMLineIndex:e.sdpMLineIndex}:{}}},Nr=(e=[],t=`Agent`)=>{for(let t of e)if(typeof t==`string`&&t.trim())return t.trim();return t},Pr=(e=[],t,n=6)=>!t?.message||e.slice(-n).some(e=>e.sender===`system`&&e.message===t.message)?e:[...e,t];function Fr({siteId:e,config:t,children:n,language:r=`en`}){let i=(0,b.useMemo)(()=>e?{...t||{},siteId:e}:t||null,[e,t]),[a,o]=(0,b.useState)(0),[s,c]=(0,b.useState)(`booting`),[l,u]=(0,b.useState)(null),[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(``),[h,g]=(0,b.useState)([]),_=(0,b.useCallback)(()=>{g(e=>[...e,{id:`nav-fail-${e.length}-${Math.random().toString(36).slice(2,8)}`,sender:`bot`,message:`I couldn't find that page on our site — could you tell me more about what you're looking for?`,timestamp:new Date().toISOString()}])},[]),v=(0,b.useCallback)(()=>{g(e=>e.slice(-3).some(e=>(e.sender===`bot`||e.sender===`assistant`)&&/already on (that|this|the)\b/i.test(String(e.message||``)))?e:[...e,{id:`nav-already-${e.length}-${Math.random().toString(36).slice(2,8)}`,sender:`bot`,message:`Looks like you're already on this page!`,timestamp:new Date().toISOString()}])},[]),[y,x]=(0,b.useState)(j().isOpen),[C,w]=(0,b.useState)(j().activeScreen),[T,E]=(0,b.useState)(j().isHumanHandled),[O,ne]=(0,b.useState)(j().agentName),[oe,k]=(0,b.useState)(j().agentHeadshot),[A,se]=(0,b.useState)(()=>de(i?.siteId)),[N,pe]=(0,b.useState)(!1),[me,ge]=(0,b.useState)(!1),[P,_e]=(0,b.useState)(`idle`),[ve,ye]=(0,b.useState)(!1),[be,xe]=(0,b.useState)(!1),[Se,we]=(0,b.useState)(``),[Te,Ee]=(0,b.useState)(!1),[De,Oe]=(0,b.useState)(0),[F,ke]=(0,b.useState)(0),[Ae,je]=(0,b.useState)(!1),[I,Fe]=(0,b.useState)(null),[Ie,Le]=(0,b.useState)(null),[Re,L]=(0,b.useState)(`idle`),[ze,Be]=(0,b.useState)(null),[Ve,He]=(0,b.useState)(!1),[Ue,We]=(0,b.useState)(``),[Ge,Ke]=(0,b.useState)(!1),qe=(0,b.useRef)(null),R=(0,b.useRef)(null),Je=(0,b.useRef)(``),Ye=(0,b.useRef)(!1),Xe=(0,b.useRef)(null),z=(0,b.useRef)(null),Ze=(0,b.useRef)(null),Qe=(0,b.useRef)(null),$e=(0,b.useRef)(null),et=(0,b.useRef)(null),tt=(0,b.useRef)(null),nt=(0,b.useRef)(!1),rt=(0,b.useRef)({url:null,at:0}),B=(0,b.useCallback)((e,t)=>{let n=e;try{n=new URL(e,window.location.origin).href}catch{}let r=rt.current;return r.url===n&&Date.now()-r.at<4e3?Promise.resolve({navigated:!0,deduped:!0}):(rt.current={url:n,at:Date.now()},Sr(e,t))},[]),it=(0,b.useRef)([]),at=(0,b.useRef)(null),ot=(0,b.useRef)(null),st=(0,b.useRef)(null),ct=(0,b.useRef)(!1),lt=(0,b.useRef)(!1),ut=(0,b.useRef)(``),dt=(0,b.useRef)(null),ft=(0,b.useRef)(null),pt=(0,b.useRef)([]),mt=(0,b.useRef)(0),ht=(0,b.useRef)(O),gt=(0,b.useRef)([]),_t=(0,b.useRef)(!1),vt=(0,b.useRef)(!1),yt=(0,b.useRef)(i),bt=(0,b.useRef)({notifyRouteChange:()=>{},cleanup:()=>{}}),xt=(0,b.useCallback)((e={})=>{let t=!!e.is_human_handled;return E(t),t?(w(`agent`),e.agent_info?.name&&ne(e.agent_info.name),e.agent_info?.headshot&&k(e.agent_info.headshot),t):(w(`ai`),t)},[]),St=(0,b.useMemo)(()=>{let e=d?.widgetSettings?.call?.maxDurationSeconds??i?.widgetSettings?.call?.maxDurationSeconds??i?.callMaxDurationSeconds,t=Number(e);return Number.isFinite(t)&&t>0?t:te},[i,d]);(0,b.useEffect)(()=>{z.current=I},[I]),(0,b.useEffect)(()=>{ht.current=O},[O]),(0,b.useEffect)(()=>{vt.current=Te},[Te]),(0,b.useEffect)(()=>{yt.current=i},[i]);let Ct=()=>{We(``)},wt=(0,b.useCallback)(()=>{st.current&&=(window.clearTimeout(st.current),null)},[]),Tt=e=>{let t=typeof e==`string`?e.trim().toLowerCase():``;return se(t),fe(t,i?.siteId),t};(0,b.useEffect)(()=>{let e=i?.siteId;if(!e)return;let t=de(e);if(t){se(t);return}se(t=>(t&&fe(t,e),t))},[i?.siteId]);let Et=(e=`unspecified`)=>{let t=at.current||et.current?.callId,n=mt.current,r=dt.current;if(dt.current=null,mt.current=0,r&&r.state!==`inactive`){r.onstop=()=>{let e=pt.current;if(pt.current=[],e.length>0&&t&&R.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;R.current.uploadRecording(t,r,i).then(e=>console.log(`[FlowEngageCall] recording upload success`,e)).catch(e=>console.warn(`[FlowEngageCall] recording upload failed`,e))}};try{r.stop()}catch{r.onstop=null,pt.current=[]}}else if(r&&r.state===`inactive`){let e=pt.current;if(pt.current=[],e.length>0&&t&&R.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;R.current.uploadRecording(t,r,i).then(e=>console.log(`[FlowEngageCall] recording upload success`,e)).catch(e=>console.warn(`[FlowEngageCall] recording upload failed`,e))}}else pt.current=[];if(ft.current){try{ft.current.close()}catch{}ft.current=null}Ze.current&&=(Ze.current.close(),null),Qe.current&&=(Qe.current.getTracks().forEach(e=>e.stop()),null),$e.current&&=($e.current.srcObject=null,$e.current.remove(),null),wt(),et.current=null,it.current=[],at.current=null,ot.current=null,ct.current=!1,He(!1),Fe(null),Le(null),L(`idle`),Be(null)},Dt=(e=new Date().toISOString())=>{let t=qe.current,n=at.current||et.current?.callId;if(!(!t?.connected||!n||ct.current)){ct.current=!0,t.emit(`call:connected`,{callId:n,chatId:Je.current,connectedAt:e});try{let e=Qe.current,t=$e.current?.srcObject;if(e&&t&&!dt.current){pt.current=[];let n=new(window.AudioContext||window.webkitAudioContext);ft.current=n;let r=n.createMediaStreamDestination();n.createMediaStreamSource(e).connect(r),n.createMediaStreamSource(t).connect(r);let i=window.MediaRecorder.isTypeSupported(`audio/webm`)?`audio/webm`:`audio/mp4`,a=new window.MediaRecorder(r.stream,{mimeType:i});a.ondataavailable=e=>{e.data&&e.data.size>0&&pt.current.push(e.data)},dt.current=a,mt.current=Date.now(),a.start(1e3),setTimeout(()=>{try{if(!window.speechSynthesis)return;let e=new SpeechSynthesisUtterance(`This call is being recorded for quality and training purposes.`);if(e.rate=.95,e.pitch=1,e.volume=1,window.MediaStreamTrackGenerator||window.AudioContext)try{let t=n.createMediaStreamDestination();e.onstart=()=>{try{let i=document.createElement(`audio`);i.style.display=`none`,i.srcObject=t.stream,document.body.appendChild(i),i.play().catch(()=>{});let a=n.createMediaStreamSource(t.stream);a.connect(r),e.onend=()=>{try{a.disconnect()}catch{}try{i.remove()}catch{}}}catch{}}}catch{}window.speechSynthesis.speak(e)}catch{}},200)}}catch{}}},Ot=(e={})=>{if(!e.callId)return;let t=ot.current===e.callId,n=at.current===e.callId,r=z.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(wt(),Fe(null),t||n){at.current=e.callId,Le(e.callId),L(e=>e===`connected`?e:`connecting`),x(!0);return}L(`idle`)}},kt=(e={})=>{if(!e.callId)return;let t=ot.current===e.callId,n=at.current===e.callId,r=z.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(wt(),n){Et();return}ot.current=null,et.current=null,it.current=[],Fe(null),L(`idle`)}},At=async(e={})=>{let t=Ze.current,n=qe.current,r=e.sdpOffer||e.offer?.sdp;if(!t||!n?.connected||!r||!e.callId){console.log(`[FlowEngageProvider] deferring remote offer until peer/socket ready`,{callId:e.callId,chatId:Je.current,hasPeerConnection:!!t,socketConnected:!!n?.connected,hasOffer:!!r}),et.current=e;return}if(await t.setRemoteDescription(new RTCSessionDescription({type:`offer`,sdp:r})),it.current.length>0){console.log(`[FlowEngageProvider] flushing queued agent ICE candidates after remote offer`,{callId:e.callId,chatId:Je.current,queuedCount:it.current.length});for(let e of it.current)await t.addIceCandidate(new RTCIceCandidate(e));it.current=[]}let i=await t.createAnswer();await t.setLocalDescription(i),n.emit(`call:answer`,{callId:e.callId,sdpAnswer:i.sdp,chatId:Je.current})};(0,b.useEffect)(()=>{M({isOpen:y,activeScreen:C,isHumanHandled:T,agentName:O,agentHeadshot:oe})},[y,C,T,O,oe]),(0,b.useEffect)(()=>{let e=!0;return(async()=>{Ke(!0);try{let t=S(i),n=await Ne(t);if(!e)return;let a=t.siteId,o=ce(a),s=he(a),l=``;try{let e=Ye.current,r=Xe.current;if(Ye.current=!1,Xe.current=null,l=(await Me({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:a,priorChatId:e||r?null:o||re(),forceNew:e,resumeChatId:r,visitorId:s}))?.data?.chatId,!l)throw Error(`resolve-session returned no chatId`);ie(),ue(a,l)}catch(e){console.warn(`[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id`,e?.message||e),l=o||ae(),ue(a,l)}Je.current=l;let u=Pe({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:t.siteId,visitorId:s});R.current=u,f({...n,apiBaseUrl:t.apiBaseUrl}),m(l);let d=n?.widgetSettings?.branding?.fallbackAgentName||`Agent`,p=xn({apiBaseUrl:t.apiBaseUrl,userId:n.userId,chatId:l,siteId:t.siteId});qe.current=p,p.on(`connect`,async()=>{_e(`connected`);let e=Je.current;if(e&&R.current)try{xt(await R.current.checkHumanHandled(e))}catch{}}),p.on(`disconnect`,()=>{_e(`disconnected`)}),p.on(`aiTyping`,()=>{ge(!0)}),p.on(`ai:typing`,()=>{ge(!0)}),p.on(`messageReceived`,e=>{let t=e.message||e,n={...t,message:Or(t.message)};ge(!1),pe(!1),!(n.type===`call_recording`||typeof n.message==`string`&&n.message.includes(`AI chat recording`))&&g(e=>[...e.filter(e=>!e.isPending),{...n,isPending:!1,id:n.messageId||`${n.sender}-${Date.now()}-${Math.random()}`}])}),p.on(`conversationStarted`,e=>{e?.message&&g(t=>[...t,{id:`system-start-${Date.now()}`,sender:`system`,message:e.message,timestamp:new Date().toISOString(),isPending:!1}])}),p.on(`message:new`,e=>{let t=e.message||e,n={...t,message:Or(t.message)};ge(!1),!(n.type===`call_recording`||typeof n.message==`string`&&n.message.includes(`AI chat recording`))&&((n.sender===`agent`||n.agent_name||n.sender===`ai`||n.sender===`bot`)&&pe(!1),g(e=>n.sender===`bot`||n.sender===`ai`?[...e,{...n,isPending:!1,id:n.messageId||`${n.sender}-${Date.now()}-${Math.random()}`}]:e.some(e=>e.id===n.messageId||e.sender===n.sender&&e.message===n.message&&e.isPending)?e.map(e=>e.sender===n.sender&&e.message===n.message&&e.isPending?{...n,isPending:!1,id:n.messageId||e.id}:e):[...e,{...n,isPending:!1,id:n.messageId||`${n.sender}-${Date.now()}-${Math.random()}`}]),(n.sender===`agent`||n.agent_name)&&(E(!0),w(`agent`),ne(Nr([n.agent_name,n.agentName,n.metadata?.agentName],d)),n.sender_headshot&&k(n.sender_headshot),x(!0),Oe(e=>e+1)))});let h=(e={})=>{let t=Nr([e.agent?.name,e.agentName,e.agent_name,ht.current],d);E(!0),w(`agent`),ne(t),k(e.agent?.headshot||null),x(!0),Oe(e=>e+1),g(e=>Pr(e,{id:`agent-joined-${Date.now()}`,sender:`system`,message:`${t} has joined the chat.`,timestamp:new Date().toISOString(),isPending:!1}))},y=(e={})=>{let t=Nr([e.agent?.name,e.agentName,e.agent_name,ht.current],d);E(!1),w(`ai`),g(e=>Pr(e,{id:`agent-left-${Date.now()}`,sender:`system`,message:`${t} has left the chat.`,timestamp:new Date().toISOString(),isPending:!1}))};p.on(`agent:joined`,h),p.on(`agentJoined`,h),p.on(`agent:left`,y),p.on(`agentLeft`,y),p.on(`conversationEnded`,e=>{je(!0);let t=e?.message||`This conversation has ended. Thank you for reaching out!`;g(e=>[...e,{id:`conversation-ended-${Date.now()}`,sender:`system`,message:t,timestamp:new Date().toISOString(),isPending:!1}])}),p.on(`chat:history_update`,e=>{let t=kr(e.chat_history||[]);g(t),t.length===0&&(je(!1),E(!1),w(`ai`),ge(!1),pe(!1))}),p.on(`conversation:reset`,()=>{g([]),je(!1),E(!1),w(`ai`),ge(!1),pe(!1)}),p.on(`voice:end_session`,(e={})=>{console.log(`[FlowEngageProvider] voice:end_session received — ending voice session`),ke(e=>e+1),x(!0),Oe(e=>e+1)}),p.on(`typing:start`,e=>{e.sender===`agent`&&pe(!0)}),p.on(`typing:stop`,e=>{e.sender===`agent`&&pe(!1)}),p.on(`call:incoming`,(e={})=>{let t=Nr([e.agentName,e.ownerName,e.agent?.name,ht.current],`Agent`);Ct(),wt(),ct.current=!1,Fe({callId:e.callId,from:e.from||`owner`,agentId:e.agentId||null,agentName:t}),ne(e=>Nr([t,e],`Agent`)),L(`incoming`),Be(null),x(!0)}),p.on(`call:offer`,async(e={})=>{et.current=e;try{await At(e)}catch(e){console.error(`[FlowEngageProvider] failed to apply remote offer`,e)}}),p.on(`call:ice-candidate-from-agent`,async(e={})=>{if(e.candidate)try{let t=Mr(e);if(!t){console.warn(`[FlowEngageProvider] ignoring invalid ICE candidate payload`,e);return}if(!Ze.current||!Ze.current.remoteDescription){console.log(`[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready`,{callId:e.callId,chatId:e.chatId||Je.current,queueSize:it.current.length+1}),it.current.push(t);return}await Ze.current.addIceCandidate(new RTCIceCandidate(t))}catch(e){console.error(`[FlowEngageProvider] failed to add ICE candidate`,e)}}),p.on(`call:ended`,()=>{Ct(),Et(`socket:call_ended`)}),p.on(`call:accepted`,(e={})=>{Ot(e)}),p.on(`call:accepted_by_other`,(e={})=>{Ot(e)}),p.on(`call:rejected`,(e={})=>{kt(e)}),p.on(`call:missed`,(e={})=>{kt(e)}),p.on(`call:failed`,(e={})=>{kt(e)}),p.on(`call:connected`,(e={})=>{if(!e.callId)return;let t=ot.current===e.callId,n=at.current===e.callId,r=et.current?.callId===e.callId,i=z.current?.callId===e.callId;if(!t&&!n&&!r){i&&(Fe(null),L(`idle`));return}ct.current=!0,ot.current=null,at.current=e.callId,Le(e.callId),Fe(null),L(`connected`),Be(e.connectedAt||new Date().toISOString()),x(!0)}),p.on(`call:unavailable`,(e={})=>{Et(`socket:call_unavailable`),We(jr(e,`This visitor is not available for a call right now.`)),x(!0)}),p.on(`call:error`,(e={})=>{Et(`socket:call_error`),We(jr(e,`We couldn't connect the call right now.`)),x(!0)}),p.on(`visitor:navigate`,async({url:e,section:t,highlight:n}={})=>{e&&B(e,{voiceActive:vt.current}).then(({navigated:e,reason:r})=>{if(!e){r===`not-found`?_():r===`already-on-page`&&v();return}let i=t||n;i&&setTimeout(()=>{let e=ur(null,i);e&&dr(e)},300)})}),p.on(`visitor:highlight`,({sectionId:e,sectionText:t}={})=>{if(!e&&!t)return;let n=ur(e||null,t||null);n&&dr(n)}),p.on(`visitor:clear_highlight`,()=>{fr()}),bt.current=Sn({socket:p,chatId:l});let b=await u.loadHistory(l,r);if(!e)return;g(kr(b.chat_history||[])),E(!!b.is_human_handled),w(b.is_human_handled?`agent`:C);let T=b?.visitor_email||b?.visitorEmail;if(T&&String(T).trim()&&Tt(String(T).trim()),await new Promise(e=>setTimeout(e,500)),!e)return;c(`ready`)}catch(t){if(!e)return;u(t),c(`error`)}finally{e&&Ke(!1)}})(),()=>{e=!1,bt.current?.cleanup?.(),Et(),qe.current?.disconnect()}},[i,r,a]),(0,b.useEffect)(()=>()=>{if(Te&&!_t.current&&gt.current.length>0){let e=Je.current,t=gt.current,n=R.current;n&&e&&t.length>0&&(console.log(`[FlowEngageProvider] safety-net: syncing voice transcript on unmount`),n.beaconSyncVoice(e,t)||n.syncVoice(e,t).catch(()=>{}),_t.current=!0)}},[Te,d]);let jt=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=R.current;!e||!p||jt.current!==y&&(y&&jt.current!==null?e.updateChatStatus(p,`open`).catch(()=>{}):jt.current===!0&&e.updateChatStatus(p,`widget_closed`).catch(()=>{}),jt.current=y)},[y,p]),(0,b.useEffect)(()=>{let e=()=>{let e=Je.current,t=R.current;!e||!t||typeof navigator>`u`||t.beaconWidgetClosed?.(e)||t.updateChatStatus(e,`widget_closed`).catch(()=>{})};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[]);let Mt=async()=>{if(!(!I?.callId||!R.current||!qe.current||!p)){Ct(),ot.current=I.callId,wt();try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});Qe.current=e;let t=[{urls:`stun:stun.l.google.com:19302`}];try{let e=await R.current.getIceServersConfig();e?.data?.iceServers?.length&&(t=e.data.iceServers)}catch(e){console.warn(`[FlowEngageProvider] ice-config fetch failed, using STUN default`,e)}let n=new RTCPeerConnection({iceServers:t});Ze.current=n,n.onconnectionstatechange=()=>{let e=n.connectionState;if(e===`connected`){let e=new Date().toISOString();L(`connected`),Be(t=>t||e),Dt(e);return}if(e===`connecting`){L(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&Et(`peer:connection_${e}`)},n.oniceconnectionstatechange=()=>{let e=n.iceConnectionState;if(e===`connected`||e===`completed`){let e=new Date().toISOString();L(`connected`),Be(t=>t||e),Dt(e);return}if(e===`checking`||e===`new`){L(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&Et(`peer:ice_${e}`)},n.onsignalingstatechange=()=>{},n.onicegatheringstatechange=()=>{},e.getTracks().forEach(t=>{n.addTrack(t,e)}),n.onicecandidate=e=>{if(!e.candidate||!qe.current?.connected)return;let t=e.candidate;qe.current.emit(`call:ice-candidate`,{callId:I.callId,candidate:t.candidate,sdpMid:t.sdpMid,sdpMLineIndex:t.sdpMLineIndex,chatId:p,from:`customer`})},n.ontrack=e=>{let[t]=e.streams||[],[n]=t?.getAudioTracks?.()||[];if(!$e.current){let e=document.createElement(`audio`);e.id=`flowengage-remote-audio`,e.autoplay=!0,e.playsInline=!0,e.onplay=()=>{},e.onpause=()=>{},e.onended=()=>{},e.onerror=e=>{},$e.current=e,document.body.appendChild(e)}$e.current.srcObject=e.streams[0];let r=I?.callId,i=r&&(ot.current===r||at.current===r);if(!ct.current&&i){let e=new Date().toISOString();L(`connected`),Be(t=>t||e),at.current=r,Le(r),Dt(e)}$e.current.srcObject=t||null;let a=$e.current.play?.();a?.catch&&a.catch(e=>{})};let r=et.current;r&&(console.log(`[FlowEngageProvider] found pending remote offer during accept`,{callId:r.callId||I.callId,chatId:p}),await At({...r,callId:r.callId||I.callId})),await R.current.acceptCall(I.callId,p),qe.current?.emit(`call:accepted`,{callId:I.callId,chatId:p}),at.current=I.callId,Le(I.callId),L(e=>e===`connected`||ct.current?`connected`:`connecting`),Fe(null),x(!0)}catch(e){if(ot.current=null,Et(`accept_call_failed`),e?.status===404||e?.status===409||e?.status===422){We(jr(e,`This visitor call is no longer available.`));return}if(e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`){try{await R.current.rejectCall(I.callId,p)}catch(e){console.error(`[FlowEngageProvider] failed to reject call after microphone denial`,e)}We(`Microphone access was denied. Please allow microphone access to accept the call.`);return}We(`We couldn't connect the call right now. Please try again.`)}}},Nt=async()=>{if(!I?.callId||!R.current||!p){Et(`reject_call_without_server_context`);return}let e=I.callId;wt(),Ct(),qe.current?.emit(`call:rejected`,{callId:e,chatId:p,reason:`visitor_declined`});try{await R.current.rejectCall(e,p)}catch(e){We(jr(e,`We couldn't decline the call cleanly.`))}finally{Et(`reject_call_finally`)}},Pt=(0,b.useRef)(Nt);Pt.current=Nt,(0,b.useEffect)(()=>{if(!I?.callId||Ie){wt();return}let e=I.callId;return wt(),st.current=window.setTimeout(()=>{z.current?.callId===e&&ot.current!==e&&at.current!==e&&Pt.current()},D),()=>{st.current&&=(window.clearTimeout(st.current),null)}},[Ie,wt,I?.callId]);let Ft=async()=>{if(!Ie||!R.current||!p){Et(`end_call_without_server_context`);return}Ct();try{await R.current.endWebRTCCall(Ie,p)}catch(e){We(jr(e,`The call ended locally, but the server could not be updated.`))}finally{Et(`end_call_finally`)}},It=()=>{let e=Qe.current?.getAudioTracks?.()||[],t=Ze.current?.getSenders?.().map(e=>e.track).filter(e=>e?.kind===`audio`)||[],n=[...e,...t].filter(Boolean);if(n.length===0)return;let r=!Ve;n.forEach(e=>{e.enabled=!r}),He(r)},Lt=async(e={})=>{let t=e.notifyChatInitiated===!0;if(x(!0),!(!t||!R.current||!p||typeof window>`u`)){try{await R.current.trackVisitor({chatId:p,currentPagePath:window.location.pathname||`/`})}catch{}try{await R.current.updateChatStatus(p,`open`)}catch{}}},Rt=async e=>{let t=Tt(e);if(!t||!R.current||!Je.current)return t;try{await R.current.trackVisitor({chatId:Je.current,currentPagePath:typeof window<`u`&&window.location.pathname||`/`,email:t})}catch(e){console.error(`[FlowEngageProvider] failed to persist visitor email`,e)}return t},zt=()=>{!p||!qe.current?.connected||lt.current||(lt.current=!0,qe.current.emit(`typing:start`,{chatId:p,sender:`user`}))},Bt=()=>{!p||!qe.current?.connected||!lt.current||(lt.current=!1,qe.current.emit(`typing:stop`,{chatId:p,sender:`user`}))},Vt=(e=``)=>{let t=typeof e==`string`?e:``;!p||!qe.current?.connected||t!==``&&ut.current===t||(ut.current=t,qe.current.emit(`typing:update`,{chatId:p,sender:`user`,text:t}))};function Ht(){if(typeof document>`u`)return null;try{let e=(document.querySelector(`main`)||document.querySelector(`[role='main']`)||document.querySelector(`article`)||document.querySelector(`#content`)||document.querySelector(`.content`)||document.body).cloneNode(!0);e.querySelectorAll(`nav, footer, header, aside, script, style, noscript, #flowengage-root, .flowengage-shell, .flowengage-widget-root, [id*='flowengage'], [class*='flowengage']`).forEach(e=>e.remove());let t=e.textContent.replace(/\s+/g,` `).trim();return t.length>0?t.substring(0,3e3):null}catch{return null}}let Ut=async(e,t=``,n=null,i={})=>{let a=typeof e==`string`?e.trim():``;if(!a||!R.current||!p||s!==`ready`||Ae)return;Bt(),nt.current=!1;let o=/^\s*(yes|yeah|sure|ok|okay|go ahead|take me(?: there)?(?!\s+\w)|navigate(?!\s+(?:me\s+)?to\s+\w)|yep|absolutely|please do|do it|let'?s go|go there|show me(?!\s+(?:the|a|an)\s+\w)|go to it|bring me there|navigate me there)\b/i,c=/^\s*(?:yes|yeah|sure|ok|okay|yep|absolutely)\s+(?!(?:please|do\s+it|let'?s|that|this|there|it|thanks|go|cool|great|perfect|sounds|alright|proceed)\b)\w/i,l=/\b(take me|navigate|go to|show me|bring me|open|go there|navigate to|take me to|let'?s go to)\b/i;if(tt.current&&o.test(a)&&!c.test(a)){let{url:e,section:t}=tt.current;tt.current=null,nt.current=!0,console.log(`[FWH Nav] Client-side nav firing →`,e),B(e,{voiceActive:vt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&v();return}!t||!vt.current||setTimeout(()=>{let e=ur(null,t);e&&dr(e)},300)})}else o.test(a)||(tt.current=null);let d=`pending-user-${Date.now()}`,f={id:d,sender:`user`,message:e,timestamp:new Date().toISOString(),isPending:!0,type:i?.type||`text`,metadata:i?.metadata||void 0,...n||{}};g(e=>[...e,f]);let m=T;if(m)try{m=xt(await R.current.checkHumanHandled(p))}catch{}if(m&&qe.current?.connected){qe.current.emit(`customer:message`,{chatId:p,content:e,sender:`user`,email:A||void 0,type:i?.type||`text`,metadata:i?.metadata||{},...n||{}});return}ye(!0);try{let o=await R.current.sendAiMessage(p,e,r,t,{...n||{},...A?{email:A}:{}},{...i,currentPageUrl:typeof window<`u`?window.location.href:void 0,currentPageTitle:typeof window<`u`?document.title:void 0,currentPagePath:typeof window<`u`?window.location.pathname:void 0,currentPageContent:Ht()||void 0}),s=o.chat_history||[];if(console.log(`[FWH Nav Debug] API response fields:`,{has_navigate:!!o.navigate,navigate:o.navigate,has_pending_navigate:!!o.pending_navigate,pending_navigate:o.pending_navigate,last_bot_msg:[...s].reverse().find(e=>e.sender===`bot`)?.message?.substring(0,80)}),o.pending_navigate?.url){let e={url:o.pending_navigate.url,section:o.pending_navigate.section||null};l.test(a)?(console.log(`[FWH Nav] Auto-navigating (intent detected) →`,e.url),B(e.url,{voiceActive:vt.current}).then(({navigated:t,reason:n})=>{if(!t){n===`not-found`?_():n===`already-on-page`&&v();return}e.section&&setTimeout(()=>{let t=ur(null,e.section);t&&dr(t)},300)})):(tt.current=e,console.log(`[FWH Nav] Stored pending nav →`,tt.current))}if(o.navigate?.url)if(nt.current)nt.current=!1;else{let{url:e,section:t}=o.navigate;B(e,{voiceActive:vt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&v();return}t&&setTimeout(()=>{let e=ur(null,t);e&&dr(e)},300)})}else if(o.highlight?.section){let e=o.highlight.section;setTimeout(()=>{let t=ur(null,e);t&&dr(t)},150)}else{let e=[...s].reverse().find(e=>e.sender===`bot`||e.sender===`assistant`);if(e?.message){let t=Ar(e.message);t&&hr(t.url,{siteId:yt.current?.siteId,apiBaseUrl:yt.current?.apiBaseUrl}).then(({allowed:e,correctedUrl:n})=>{if(!e){_();return}B(n||t.url,{voiceActive:vt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&v();return}!t.section||!vt.current||setTimeout(()=>{let e=ur(null,t.section);e&&dr(e)},300)})})}}g(kr(s)),E(!!o.is_human_handled),w(o.is_human_handled?`agent`:`ai`),ge(!1),ye(!1),await R.current.updateChatStatus(p,`messageSent`)}catch(e){g(e=>e.filter(e=>e.id!==d)),ge(!1),ye(!1),e.status===429?(xe(!0),we(e.message),window.setTimeout(()=>{xe(!1),we(``)},ee)):u(e)}},Wt=async e=>{if(!R.current||!e)throw Error(`Upload is unavailable right now.`);return R.current.uploadChatFile(e)},Gt=async e=>{if(!(!R.current||!p)){try{let t=e?`voice`:`text`;await R.current.setChatMode(p,t)}catch{}Ee(e),e&&(_t.current=!1)}},Kt=async e=>{if(_t.current)return;if(_t.current=!0,!R.current||!p||!e?.length){Ee(!1);return}let t=()=>{let t=kr(e);g(e=>{if(!e.length)return t;let n=e[e.length-1],r=t[0];return n&&r&&n.sender===r.sender&&n.message===r.message?e:[...e,...t]})};try{let n=await R.current.syncVoice(p,e);if(n?.chat_history?.length)g(kr(n.chat_history));else if(n?.success)try{let e=await R.current.loadHistory(p,r);e?.chat_history?.length?g(kr(e.chat_history)):t()}catch{t()}else t()}catch{t()}finally{Ee(!1)}},qt=async()=>{if(!(!R.current||!p)){Te&&!_t.current&&gt.current.length>0&&await Kt(gt.current);try{await R.current.endConversation(p)}catch{try{await R.current.updateChatStatus(p,`ended`)}catch{}}je(!0),g(e=>[...e,{id:`conversation-ended-${Date.now()}`,sender:`system`,message:`This conversation has ended. Thank you for reaching out!`,timestamp:new Date().toISOString(),isPending:!1}])}};(0,b.useEffect)(()=>{if(Re!==`connected`||!Ie||!p||!ze||!St)return;let e=new Date(ze).getTime(),t=Number.isFinite(e)?Date.now()-e:0,n=Math.max(0,St*1e3-t),r=window.setTimeout(()=>{We(`The call ended because it reached the time limit.`),Ft()},n);return()=>window.clearTimeout(r)},[Ie,ze,Re,p,Ft,St]),(0,b.useEffect)(()=>{let e=()=>{let e=Je.current,t=R.current;if(!t||!e)return;if(vt.current&&gt.current.length>0&&Ce(),!_t.current&&gt.current.length>0&&(t.beaconSyncVoice(e,gt.current)||t.syncVoice(e,gt.current).catch(()=>{}),_t.current=!0),at.current){t.beaconEndWebRTCCall(at.current,e);return}let n=ot.current||z.current?.callId;n&&t.beaconCustomerUnavailable(n,e)};return window.addEventListener(`pagehide`,e),window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`pagehide`,e),window.removeEventListener(`beforeunload`,e)}},[]);let Jt=(0,b.useCallback)(()=>{let e=i?.siteId;le(e),Ye.current=!0,Xe.current=null,qe.current?.disconnect(),g([]),m(``),Je.current=``,je(!1),E(!1),ne(null),k(null),Ke(!0),o(e=>e+1)},[i?.siteId]),Yt=(0,b.useCallback)(e=>{i?.siteId,Ye.current=!1,Xe.current=e,qe.current?.disconnect(),g([]),m(``),Je.current=``,je(!1),E(!1),ne(null),k(null),Ke(!0),o(e=>e+1)},[i?.siteId]),Xt=(0,b.useMemo)(()=>({status:s,error:l,runtimeConfig:d,resolvedConfig:i,chatId:p,chatHistory:h,isOpen:y,activeScreen:C,isHumanHandled:T,agentName:O,agentHeadshot:oe,visitorEmail:A,isAgentTyping:N,isAiTyping:me,connectionStatus:P,isLoading:ve,isVoiceMode:Te,isRateLimited:be,rateLimitMessage:Se,isConversationEnded:Ae,isSessionRestoring:Ge,openToChatCounter:De,voiceEndCounter:F,incomingCall:I,activeCallId:Ie,callConnectionState:Re,callConnectedAt:ze,isCallMuted:Ve,webRTCError:Ue,language:r,historyRef:gt,hasSyncedRef:_t,dismissCallError:Ct,captureVisitorEmail:Rt,startTyping:zt,stopTyping:Bt,updateTypingDraft:Vt,notifyRouteChange:()=>bt.current?.notifyRouteChange?.(),openWidget:Lt,closeWidget:()=>x(!1),toggleWidget:()=>{if(y){x(!1);return}Lt({notifyChatInitiated:!0})},sendMessage:Ut,uploadChatFile:Wt,setVoiceMode:Gt,onMessageSync:Kt,endConversation:qt,startNewChat:Jt,resumeChat:Yt,getVisitorChatHistory:()=>R.current?.getVisitorChatHistory?.(),getVisitorChatThread:e=>R.current?.getVisitorChatThread?.(e),acceptCall:Mt,rejectCall:Nt,endWebRTCCall:Ft,toggleCallMute:It}),[s,l,d,i,p,h,y,C,T,O,oe,A,N,me,P,ve,Te,be,Se,Ae,Ge,De,F,I,Ie,Re,ze,Ve,Ue,r,Rt,zt,Bt,Vt,Mt,Nt,Ft,It,Lt,Ut,Wt,Gt,Kt,qt,Jt,Ct]);return(0,H.jsx)(Cn.Provider,{value:Xt,children:n})}var Ir=(0,b.createContext)({});function Lr(e){let t=(0,b.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Rr=typeof window<`u`?b.useLayoutEffect:b.useEffect,zr=(0,b.createContext)(null);function Br(e,t){e.indexOf(t)===-1&&e.push(t)}function Vr(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Hr=(e,t,n)=>n>t?t:n<e?e:n,Ur={},Wr=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Gr(e){return typeof e==`object`&&!!e}var Kr=e=>/^0[^.\s]+$/u.test(e);function qr(e){let t;return()=>(t===void 0&&(t=e()),t)}var Jr=e=>e,Yr=(e,t)=>n=>t(e(n)),Xr=(...e)=>e.reduce(Yr),Zr=(e,t,n)=>{let r=t-e;return r===0?1:(n-e)/r},Qr=class{constructor(){this.subscriptions=[]}add(e){return Br(this.subscriptions,e),()=>Vr(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},$r=e=>e*1e3,ei=e=>e/1e3;function ti(e,t){return t?1e3/t*e:0}var ni=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,ri=1e-7,ii=12;function ai(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=ni(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>ri&&++s<ii);return o}function oi(e,t,n,r){if(e===t&&n===r)return Jr;let i=t=>ai(t,0,1,e,n);return e=>e===0||e===1?e:ni(i(e),t,r)}var si=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,ci=e=>t=>1-e(1-t),li=oi(.33,1.53,.69,.99),ui=ci(li),di=si(ui),fi=e=>e>=1?1:(e*=2)<1?.5*ui(e):.5*(2-2**(-10*(e-1))),pi=e=>1-Math.sin(Math.acos(e)),mi=ci(pi),hi=si(pi),gi=oi(.42,0,1,1),_i=oi(0,0,.58,1),vi=oi(.42,0,.58,1),yi=e=>Array.isArray(e)&&typeof e[0]!=`number`,bi=e=>Array.isArray(e)&&typeof e[0]==`number`,xi={linear:Jr,easeIn:gi,easeInOut:vi,easeOut:_i,circIn:pi,circInOut:hi,circOut:mi,backIn:ui,backInOut:di,backOut:li,anticipate:fi},Si=e=>typeof e==`string`,Ci=e=>{if(bi(e)){e.length;let[t,n,r,i]=e;return oi(t,n,r,i)}else if(Si(e))return xi[e],`${e}`,xi[e];return e},wi=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`],Ti={value:null,addProjectionMetrics:null};function Ei(e,t){let n=new Set,r=new Set,i=!1,a=!1,o=new WeakSet,s={delta:0,timestamp:0,isProcessing:!1},c=0;function l(t){o.has(t)&&(u.schedule(t),e()),c++,t(s)}let u={schedule:(e,t=!1,a=!1)=>{let s=a&&i?n:r;return t&&o.add(e),s.add(e),e},cancel:e=>{r.delete(e),o.delete(e)},process:e=>{if(s=e,i){a=!0;return}i=!0;let o=n;n=r,r=o,n.forEach(l),t&&Ti.value&&Ti.value.frameloop[t].push(c),c=0,n.clear(),i=!1,a&&(a=!1,u.process(e))}};return u}var Di=40;function Oi(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=wi.reduce((e,n)=>(e[n]=Ei(a,t?n:void 0),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=Ur.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,Di),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:wi.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<wi.length;t++)o[wi[t]].cancel(e)},state:i,steps:o}}var{schedule:U,cancel:ki,state:W,steps:Ai}=Oi(typeof requestAnimationFrame<`u`?requestAnimationFrame:Jr,!0),ji;function Mi(){ji=void 0}var Ni={now:()=>(ji===void 0&&Ni.set(W.isProcessing||Ur.useManualTiming?W.timestamp:performance.now()),ji),set:e=>{ji=e,queueMicrotask(Mi)}},Pi={layout:0,mainThread:0,waapi:0},Fi=e=>t=>typeof t==`string`&&t.startsWith(e),Ii=Fi(`--`),Li=Fi(`var(--`),Ri=e=>Li(e)?zi.test(e.split(`/*`)[0].trim()):!1,zi=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Bi(e){return typeof e==`string`?e.split(`/*`)[0].includes(`var(--`):!1}var Vi={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Hi={...Vi,transform:e=>Hr(0,1,e)},Ui={...Vi,default:1},Wi=e=>Math.round(e*1e5)/1e5,Gi=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Ki(e){return e==null}var qi=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ji=(e,t)=>n=>!!(typeof n==`string`&&qi.test(n)&&n.startsWith(e)||t&&!Ki(n)&&Object.prototype.hasOwnProperty.call(n,t)),Yi=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Gi);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Xi=e=>Hr(0,255,e),Zi={...Vi,transform:e=>Math.round(Xi(e))},Qi={test:Ji(`rgb`,`red`),parse:Yi(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Zi.transform(e)+`, `+Zi.transform(t)+`, `+Zi.transform(n)+`, `+Wi(Hi.transform(r))+`)`};function $i(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var ea={test:Ji(`#`),parse:$i,transform:Qi.transform},ta=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),na=ta(`deg`),ra=ta(`%`),G=ta(`px`),ia=ta(`vh`),aa=ta(`vw`),oa={...ra,parse:e=>ra.parse(e)/100,transform:e=>ra.transform(e*100)},sa={test:Ji(`hsl`,`hue`),parse:Yi(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+ra.transform(Wi(t))+`, `+ra.transform(Wi(n))+`, `+Wi(Hi.transform(r))+`)`},ca={test:e=>Qi.test(e)||ea.test(e)||sa.test(e),parse:e=>Qi.test(e)?Qi.parse(e):sa.test(e)?sa.parse(e):ea.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Qi.transform(e):sa.transform(e),getAnimatableNone:e=>{let t=ca.parse(e);return t.alpha=0,ca.transform(t)}},la=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function ua(e){return isNaN(e)&&typeof e==`string`&&(e.match(Gi)?.length||0)+(e.match(la)?.length||0)>0}var da=`number`,fa=`color`,pa=`var`,ma=`var(`,ha="${}",ga=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function _a(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(ga,e=>(ca.test(e)?(r.color.push(a),i.push(fa),n.push(ca.parse(e))):e.startsWith(ma)?(r.var.push(a),i.push(pa),n.push(e)):(r.number.push(a),i.push(da),n.push(parseFloat(e))),++a,ha)).split(ha),indexes:r,types:i}}function va(e){return _a(e).values}function ya({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];e===da?i+=Wi(r[a]):e===fa?i+=ca.transform(r[a]):i+=r[a]}return i}}function ba(e){return ya(_a(e))}var xa=e=>typeof e==`number`?0:ca.test(e)?ca.getAnimatableNone(e):e,Sa=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:xa(e);function Ca(e){let t=_a(e);return ya(t)(t.values.map((e,n)=>Sa(e,t.split[n])))}var wa={test:ua,parse:va,createTransformer:ba,getAnimatableNone:Ca};function Ta(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Ea({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=Ta(s,r,e+1/3),a=Ta(s,r,e),o=Ta(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Da(e,t){return n=>n>0?t:e}var Oa=(e,t,n)=>e+(t-e)*n,ka=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Aa=[ea,Qi,sa],ja=e=>Aa.find(t=>t.test(e));function Ma(e){let t=ja(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===sa&&(n=Ea(n)),n}var Na=(e,t)=>{let n=Ma(e),r=Ma(t);if(!n||!r)return Da(e,t);let i={...n};return e=>(i.red=ka(n.red,r.red,e),i.green=ka(n.green,r.green,e),i.blue=ka(n.blue,r.blue,e),i.alpha=Oa(n.alpha,r.alpha,e),Qi.transform(i))},Pa=new Set([`none`,`hidden`]);function Fa(e,t){return Pa.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Ia(e,t){return n=>Oa(e,t,n)}function La(e){return typeof e==`number`?Ia:typeof e==`string`?Ri(e)?Da:ca.test(e)?Na:Va:Array.isArray(e)?Ra:typeof e==`object`?ca.test(e)?Na:za:Da}function Ra(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>La(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function za(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=La(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function Ba(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var Va=(e,t)=>{let n=wa.createTransformer(t),r=_a(e),i=_a(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?Pa.has(e)&&!i.values.length||Pa.has(t)&&!r.values.length?Fa(e,t):Xr(Ra(Ba(r,i),i.values),n):(`${e}${t}`,Da(e,t))};function Ha(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?Oa(e,t,n):La(e)(e,t)}var Ua=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>U.update(t,e),stop:()=>ki(t),now:()=>W.isProcessing?W.timestamp:Ni.now()}},Wa=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},Ga=2e4;function Ka(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}function qa(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(Ka(r),Ga);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:ei(i)}}var Ja={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function Ya(e,t){return e*Math.sqrt(1-t*t)}var Xa=12;function Za(e,t,n){let r=n;for(let n=1;n<Xa;n++)r-=e(r)/t(r);return r}var Qa=.001;function $a({duration:e=Ja.duration,bounce:t=Ja.bounce,velocity:n=Ja.velocity,mass:r=Ja.mass}){let i,a;Ja.maxDuration;let o=1-t;o=Hr(Ja.minDamping,Ja.maxDamping,o),e=Hr(Ja.minDuration,Ja.maxDuration,ei(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=Ya(t,o),c=Math.exp(-i);return Qa-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=Ya(t**2,o);return(-i(t)+Qa>0?-1:1)*((a-s)*c)/l}):(i=t=>{let r=Math.exp(-t*e),i=(t-n)*e+1;return-Qa+r*i},a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=Za(i,a,s);if(e=$r(e),isNaN(c))return{stiffness:Ja.stiffness,damping:Ja.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var eo=[`duration`,`bounce`],to=[`stiffness`,`damping`,`mass`];function no(e,t){return t.some(t=>e[t]!==void 0)}function ro(e){let t={velocity:Ja.velocity,stiffness:Ja.stiffness,damping:Ja.damping,mass:Ja.mass,isResolvedFromDuration:!1,...e};if(!no(e,to)&&no(e,eo))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Hr(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Ja.mass,stiffness:i,damping:a}}else{let n=$a({...e,velocity:0});t={...t,...n,mass:Ja.mass},t.isResolvedFromDuration=!0}return t}function io(e=Ja.visualDuration,t=Ja.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=ro({...n,velocity:-ei(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=ei(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?Ja.restSpeed.granular:Ja.restSpeed.default,i||=v?Ja.restDelta.granular:Ja.restDelta.default;let y,b,x,S,C,w;if(h<1)x=Ya(_,h),S=(m+h*_*g)/x,y=e=>o-Math.exp(-h*_*e)*(S*Math.sin(x*e)+g*Math.cos(x*e)),C=h*_*S+g*x,w=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(C*Math.sin(x*e)+w*Math.cos(x*e));else if(h===1){y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;b=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+h*_*g)/e,n=h*_*t-g*e,r=h*_*g-t*e;b=t=>{let i=Math.exp(-h*_*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let T={calculatedDuration:p&&d||null,velocity:e=>$r(b(e)),next:e=>{if(!p&&h<1){let t=Math.exp(-h*_*e),n=Math.sin(x*e),a=Math.cos(x*e),c=o-t*(S*n+g*a),l=$r(t*(C*n+w*a));return s.done=Math.abs(l)<=r&&Math.abs(o-c)<=i,s.value=s.done?o:c,s}let t=y(e);if(p)s.done=e>=d;else{let n=$r(b(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(Ka(T),Ga),t=Wa(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}io.applyToOptions=e=>{let t=qa(e,100,io);return e.ease=t.ease,e.duration=$r(t.duration),e.type=`keyframes`,e};var ao=5;function oo(e,t,n){let r=Math.max(t-ao,0);return ti(n-e(r),t-r)}function K({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=io({keyframes:[f.value,m(f.value)],velocity:oo(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function so(e,t,n){let r=[],i=n||Ur.mix||Ha,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=Xr(Array.isArray(t)?t[n]||Jr:t,a)),r.push(a)}return r}function co(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=so(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=Zr(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Hr(e[0],e[a-1],t)):l}function lo(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=Zr(0,t,r);e.push(Oa(n,1,i))}}function uo(e){let t=[0];return lo(t,e.length-1),t}function fo(e,t){return e.map(e=>e*t)}function po(e,t){return e.map(()=>t||vi).splice(0,e.length-1)}function mo({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=yi(r)?r.map(Ci):Ci(r),a={done:!1,value:t[0]},o=co(fo(n&&n.length===t.length?n:uo(t),e),t,{ease:Array.isArray(i)?i:po(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var ho=e=>e!==null;function go(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(ho),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var _o={decay:K,inertia:K,tween:mo,keyframes:mo,spring:io};function vo(e){typeof e.type==`string`&&(e.type=_o[e.type])}var yo=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},bo=e=>e/100,xo=class extends yo{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==Ni.now()&&this.tick(Ni.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},Pi.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;vo(e);let{type:t=mo,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||mo;s!==mo&&typeof o[0]!=`number`&&(this.mixKeyframes=Xr(bo,Ha(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=Ka(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime===null?this.currentTime=t:this.currentTime=this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=Hr(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==K&&(b.value=go(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return ei(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ei(e)}get time(){return ei(this.currentTime)}set time(e){e=$r(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return oo(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Ni.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=ei(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Ua,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(Ni.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null,Pi.mainThread--}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function So(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var Co=e=>e*180/Math.PI,wo=e=>Eo(Co(Math.atan2(e[1],e[0]))),To={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:wo,rotateZ:wo,skewX:e=>Co(Math.atan(e[1])),skewY:e=>Co(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Eo=e=>(e%=360,e<0&&(e+=360),e),Do=wo,Oo=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),ko=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Ao={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Oo,scaleY:ko,scale:e=>(Oo(e)+ko(e))/2,rotateX:e=>Eo(Co(Math.atan2(e[6],e[5]))),rotateY:e=>Eo(Co(Math.atan2(-e[2],e[0]))),rotateZ:Do,rotate:Do,skewX:e=>Co(Math.atan(e[4])),skewY:e=>Co(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function jo(e){return e.includes(`scale`)?1:0}function Mo(e,t){if(!e||e===`none`)return jo(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=Ao,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=To,i=t}if(!i)return jo(t);let a=r[t],o=i[1].split(`,`).map(Po);return typeof a==`function`?a(o):o[a]}var No=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return Mo(n,t)};function Po(e){return parseFloat(e.trim())}var Fo=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Io=new Set(Fo),Lo=e=>e===Vi||e===G,Ro=new Set([`x`,`y`,`z`]),zo=Fo.filter(e=>!Ro.has(e));function Bo(e){let t=[];return zo.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith(`scale`)?1:0))}),t}var Vo={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Mo(t,`x`),y:(e,{transform:t})=>Mo(t,`y`)};Vo.translateX=Vo.x,Vo.translateY=Vo.y;var Ho=new Set,Uo=!1,Wo=!1,Go=!1;function Ko(){if(Wo){let e=Array.from(Ho).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=Bo(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}Wo=!1,Uo=!1,Ho.forEach(e=>e.complete(Go)),Ho.clear()}function qo(){Ho.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Wo=!0)})}function Jo(){Go=!0,qo(),Ko(),Go=!1}var Yo=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(Ho.add(this),Uo||(Uo=!0,U.read(qo),U.resolveKeyframes(Ko))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}So(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ho.delete(this)}cancel(){this.state===`scheduled`&&(Ho.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Xo=e=>e.startsWith(`--`);function Zo(e,t,n){Xo(t)?e.style.setProperty(t,n):e.style[t]=n}var Qo={};function $o(e,t){let n=qr(e);return()=>Qo[t]??n()}var es=$o(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),ts=$o(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),ns=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,rs={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:ns([0,.65,.55,1]),circOut:ns([.55,0,1,.45]),backIn:ns([.31,.01,.66,-.59]),backOut:ns([.33,1.53,.69,.99])};function is(e,t){if(e)return typeof e==`function`?ts()?Wa(e,t):`ease-out`:bi(e)?ns(e):Array.isArray(e)?e.map(e=>is(e,t)||rs.easeOut):rs[e]}function as(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=is(s,i);Array.isArray(d)&&(u.easing=d),Ti.value&&Pi.waapi++;let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};l&&(f.pseudoElement=l);let p=e.animate(u,f);return Ti.value&&p.finished.finally(()=>{Pi.waapi--}),p}function os(e){return typeof e==`function`&&`applyToOptions`in e}function ss({type:e,...t}){return os(e)&&ts()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var cs=class extends yo{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=ss(e);this.animation=as(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=go(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),Zo(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e===`idle`||e===`finished`||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return ei(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ei(e)}get time(){return ei(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=$r(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&es()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),Jr):r(this)}},ls={anticipate:fi,backInOut:di,circInOut:hi};function us(e){return e in ls}function ds(e){typeof e.ease==`string`&&us(e.ease)&&(e.ease=ls[e.ease])}var fs=10,ps=class extends cs{constructor(e){ds(e),vo(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new xo({...a,autoplay:!1}),s=Math.max(fs,Ni.now()-this.startTime),c=Hr(0,fs,s-fs),l=o.sample(s).value,{name:u}=this.options;i&&u&&Zo(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},ms=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(wa.test(e)||e===`0`)&&!e.startsWith(`url(`));function hs(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function gs(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=ms(i,t),s=ms(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:hs(e)||(n===`spring`||os(n))&&r}function _s(e){e.duration=0,e.type=`keyframes`}var vs=new Set([`opacity`,`clipPath`,`filter`,`transform`]),ys=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function bs(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&ys.test(e[t]))return!0;return!1}var xs=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),Ss=qr(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function Cs(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:c,transformTemplate:l}=t.owner.getProps();return Ss()&&n&&(vs.has(n)||xs.has(n)&&bs(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var ws=40,Ts=class extends yo{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Ni.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u};this.keyframeResolver=new(l?.KeyframeResolver||Yo)(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=Ni.now();let u=!0;gs(e,i,a,o)||(u=!1,(Ur.instantAnimations||!s)&&l?.(go(e,n,t)),e[0]=e[e.length-1],_s(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>ws?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&Cs(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new ps({...d,element:p})}catch{m=new xo(d)}else m=new xo(d);m.finished.then(()=>{this.notifyFinished()}).catch(Jr),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Jo()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function Es(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var Ds=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Os(e){let t=Ds.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function ks(e,t,n=1){`${e}`;let[r,i]=Os(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Wr(e)?parseFloat(e):e}return Ri(i)?ks(i,t,n+1):i}var As={type:`spring`,stiffness:500,damping:25,restSpeed:10},js=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Ms={type:`keyframes`,duration:.8},Ns={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Ps=(e,{keyframes:t})=>t.length>2?Ms:Io.has(e)?e.startsWith(`scale`)?js(t[1]):As:Ns;function Fs(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Is(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Fs(n,e)}var Ls=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Rs(e){for(let t in e)if(!Ls.has(t))return!0;return!1}var zs=(e,t,n,r={},i,a)=>o=>{let s=Is(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=$r(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};Rs(s)||Object.assign(u,Ps(e,u)),u.duration&&=$r(u.duration),u.repeatDelay&&=$r(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(_s(u),u.delay===0&&(d=!0)),(Ur.instantAnimations||Ur.skipAnimations||i?.shouldSkipAnimations)&&(d=!0,_s(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=go(u.keyframes,s);if(e!==void 0){U.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new xo(u):new Ts(u)};function Bs(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Vs(e,t,n,r){if(typeof t==`function`){let[i,a]=Bs(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=Bs(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Hs(e,t,n){let r=e.getProps();return Vs(r,t,n===void 0?r.custom:n,e)}var Us=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...Fo]),Ws=30,Gs=e=>!isNaN(parseFloat(e)),Ks={current:void 0},qs=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Ni.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Ni.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Gs(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new Qr);let n=this.events[e].add(t);return e===`change`?()=>{n(),U.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return Ks.current&&Ks.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Ni.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Ws)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Ws);return ti(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function Js(e,t){return new qs(e,t)}var Ys=e=>Array.isArray(e);function Xs(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Js(n))}function Zs(e){return Ys(e)?e[e.length-1]||0:e}function Qs(e,t){let{transitionEnd:n={},transition:r={},...i}=Hs(e,t)||{};i={...i,...n};for(let t in i)Xs(e,t,Zs(i[t]))}var $s=e=>!!(e&&e.getVelocity);function ec(e){return!!($s(e)&&e.add)}function tc(e,t){let n=e.getValue(`willChange`);if(ec(n))return n.add(t);if(!n&&Ur.WillChange){let n=new Ur.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function nc(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var rc=`data-`+nc(`framerAppearId`);function ic(e){return e.props[rc]}function ac({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function oc(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Fs(a,c):c;let l=a?.reduceMotion;r&&(a=r);let u=[],d=i&&e.animationState&&e.animationState.getState()[i];for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||d&&ac(d,t))continue;let o={delay:n,...Is(a||{},t)},c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){U.update(()=>r.set(i));continue}let f=!1;if(window.MotionHandoffAnimation){let n=ic(e);if(n){let e=window.MotionHandoffAnimation(n,t,U);e!==null&&(o.startTime=e,f=!0)}}tc(e,t);let p=l??e.shouldReduceMotion;r.start(zs(t,r,i,p&&Us.has(t)?{type:!1}:o,e,f));let m=r.animation;m&&u.push(m)}if(o){let t=()=>U.update(()=>{o&&Qs(e,o)});u.length?Promise.all(u).then(t):t()}return u}function sc(e,t,n={}){let r=Hs(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(oc(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return cc(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function cc(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(sc(c,t,{...o,delay:n+(typeof r==`function`?0:r)+Es(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function lc(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>sc(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=sc(e,t,n);else{let i=typeof t==`function`?Hs(e,t,n.custom):t;r=Promise.all(oc(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var uc={test:e=>e===`auto`,parse:e=>e},dc=e=>t=>t.test(e),fc=[Vi,G,ra,na,aa,ia,uc],pc=e=>fc.find(dc(e));function mc(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||Kr(e)}var hc=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function gc(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Gi)||[];if(!r)return e;let i=n.replace(r,``),a=hc.has(t)?1:0;return r!==n&&(a*=100),t+`(`+a+i+`)`}var _c=/\b([a-z-]*)\(.*?\)/gu,vc={...wa,getAnimatableNone:e=>{let t=e.match(_c);return t?t.map(gc).join(` `):e}},yc={...wa,getAnimatableNone:e=>{let t=wa.parse(e);return wa.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},bc={...Vi,transform:Math.round},xc={borderWidth:G,borderTopWidth:G,borderRightWidth:G,borderBottomWidth:G,borderLeftWidth:G,borderRadius:G,borderTopLeftRadius:G,borderTopRightRadius:G,borderBottomRightRadius:G,borderBottomLeftRadius:G,width:G,maxWidth:G,height:G,maxHeight:G,top:G,right:G,bottom:G,left:G,inset:G,insetBlock:G,insetBlockStart:G,insetBlockEnd:G,insetInline:G,insetInlineStart:G,insetInlineEnd:G,padding:G,paddingTop:G,paddingRight:G,paddingBottom:G,paddingLeft:G,paddingBlock:G,paddingBlockStart:G,paddingBlockEnd:G,paddingInline:G,paddingInlineStart:G,paddingInlineEnd:G,margin:G,marginTop:G,marginRight:G,marginBottom:G,marginLeft:G,marginBlock:G,marginBlockStart:G,marginBlockEnd:G,marginInline:G,marginInlineStart:G,marginInlineEnd:G,fontSize:G,backgroundPositionX:G,backgroundPositionY:G,rotate:na,rotateX:na,rotateY:na,rotateZ:na,scale:Ui,scaleX:Ui,scaleY:Ui,scaleZ:Ui,skew:na,skewX:na,skewY:na,distance:G,translateX:G,translateY:G,translateZ:G,x:G,y:G,z:G,perspective:G,transformPerspective:G,opacity:Hi,originX:oa,originY:oa,originZ:G,zIndex:bc,fillOpacity:Hi,strokeOpacity:Hi,numOctaves:bc},Sc={...xc,color:ca,backgroundColor:ca,outlineColor:ca,fill:ca,stroke:ca,borderColor:ca,borderTopColor:ca,borderRightColor:ca,borderBottomColor:ca,borderLeftColor:ca,filter:vc,WebkitFilter:vc,mask:yc,WebkitMask:yc},Cc=e=>Sc[e],wc=new Set([vc,yc]);function Tc(e,t){let n=Cc(e);return wc.has(n)||(n=wa),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var Ec=new Set([`auto`,`none`,`0`]);function Dc(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!Ec.has(t)&&_a(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=Tc(n,i)}var Oc=class extends Yo{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Ri(r))){let i=ks(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Us.has(n)||e.length!==2)return;let[r,i]=e,a=pc(r),o=pc(i);if(Bi(r)!==Bi(i)&&Vo[n]){this.needsMeasurement=!0;return}if(a!==o)if(Lo(a)&&Lo(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else Vo[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||mc(e[t]))&&n.push(t);n.length&&Dc(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Vo[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=Vo[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}};function kc(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var Ac=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function jc(e){return Gr(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:Mc,cancel:Nc}=Oi(queueMicrotask,!1),Pc={x:!1,y:!1};function Fc(){return Pc.x||Pc.y}function Ic(e){return e===`x`||e===`y`?Pc[e]?null:(Pc[e]=!0,()=>{Pc[e]=!1}):Pc.x||Pc.y?null:(Pc.x=Pc.y=!0,()=>{Pc.x=Pc.y=!1})}function Lc(e,t){let n=kc(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function Rc(e){return!(e.pointerType===`touch`||Fc())}function zc(e,t,n={}){let[r,i,a]=Lc(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!Rc(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var Bc=(e,t)=>t?e===t?!0:Bc(e,t.parentElement):!1,Vc=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Hc=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Uc(e){return Hc.has(e.tagName)||e.isContentEditable===!0}var Wc=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Gc(e){return Wc.has(e.tagName)||e.isContentEditable===!0}var Kc=new WeakSet;function qc(e){return t=>{t.key===`Enter`&&e(t)}}function Jc(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var Yc=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=qc(()=>{if(Kc.has(n))return;Jc(n,`down`);let e=qc(()=>{Jc(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Jc(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Xc(e){return Vc(e)&&!Fc()}var Zc=new WeakSet;function Qc(e,t,n={}){let[r,i,a]=Lc(e,n),o=e=>{let r=e.currentTarget;if(!Xc(e)||Zc.has(e))return;Kc.add(r),n.stopPropagation&&Zc.add(e);let a=t(r,e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),Kc.has(r)&&Kc.delete(r),Xc(e)&&typeof a==`function`&&a(e,{success:t})},s=e=>{o(e,r===window||r===document||n.useGlobalTarget||Bc(r,e.target))},c=e=>{o(e,!1)};window.addEventListener(`pointerup`,s,i),window.addEventListener(`pointercancel`,c,i)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),jc(e)&&(e.addEventListener(`focus`,e=>Yc(e,i)),!Uc(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function $c(e){return Gr(e)&&`ownerSVGElement`in e}var el=new WeakMap,tl,nl=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:$c(r)&&`getBBox`in r?r.getBBox()[t]:r[n],rl=nl(`inline`,`width`,`offsetWidth`),il=nl(`block`,`height`,`offsetHeight`);function al({target:e,borderBoxSize:t}){el.get(e)?.forEach(n=>{n(e,{get width(){return rl(e,t)},get height(){return il(e,t)}})})}function ol(e){e.forEach(al)}function sl(){typeof ResizeObserver>`u`||(tl=new ResizeObserver(ol))}function cl(e,t){tl||sl();let n=kc(e);return n.forEach(e=>{let n=el.get(e);n||(n=new Set,el.set(e,n)),n.add(t),tl?.observe(e)}),()=>{n.forEach(e=>{let n=el.get(e);n?.delete(t),n?.size||tl?.unobserve(e)})}}var ll=new Set,ul;function dl(){ul=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};ll.forEach(t=>t(e))},window.addEventListener(`resize`,ul)}function fl(e){return ll.add(e),ul||dl(),()=>{ll.delete(e),!ll.size&&typeof ul==`function`&&(window.removeEventListener(`resize`,ul),ul=void 0)}}function pl(e,t){return typeof e==`function`?fl(e):cl(e,t)}function ml(e){return $c(e)&&e.tagName===`svg`}var hl=[...fc,ca,wa],gl=e=>hl.find(dc(e)),_l=()=>({translate:0,scale:1,origin:0,originPoint:0}),vl=()=>({x:_l(),y:_l()}),yl=()=>({min:0,max:0}),bl=()=>({x:yl(),y:yl()}),xl=new WeakMap;function Sl(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function Cl(e){return typeof e==`string`||Array.isArray(e)}var wl=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],Tl=[`initial`,...wl];function El(e){return Sl(e.animate)||Tl.some(t=>Cl(e[t]))}function Dl(e){return!!(El(e)||e.variants)}function Ol(e,t,n){for(let r in t){let i=t[r],a=n[r];if($s(i))e.addValue(r,i);else if($s(a))e.addValue(r,Js(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,Js(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var kl={current:null},Al={current:!1},jl=typeof window<`u`;function Ml(){if(Al.current=!0,jl)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>kl.current=e.matches;e.addEventListener(`change`,t),t()}else kl.current=!1}var Nl=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Pl={};function Fl(e){Pl=e}function Il(){return Pl}var Ll=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Yo,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Ni.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,U.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=El(t),this.isVariantNode=Dl(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&$s(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];this.current=e,xl.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(Al.current||Ml(),this.shouldReduceMotion=kl.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),ki(this.notifyUpdate),ki(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&vs.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new cs({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:$r(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Io.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&U.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i(),t.owner&&t.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in Pl){let t=Pl[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):bl()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<Nl.length;t++){let n=Nl[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=Ol(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=Js(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(Wr(n)||Kr(n))?n=parseFloat(n):!gl(n)&&wa.test(t)&&(n=Tc(e,t)),this.setBaseTarget(e,$s(n)?n.get():n)),$s(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=Vs(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!$s(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new Qr),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Mc.render(this.render)}},Rl=class extends Ll{constructor(){super(...arguments),this.KeyframeResolver=Oc}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;$s(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},q=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function J({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function Y({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function zl(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Bl(e){return e===void 0||e===1}function Vl({scale:e,scaleX:t,scaleY:n}){return!Bl(e)||!Bl(t)||!Bl(n)}function Hl(e){return Vl(e)||Ul(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Ul(e){return Wl(e.x)||Wl(e.y)}function Wl(e){return e&&e!==`0%`}function Gl(e,t,n){return n+t*(e-n)}function Kl(e,t,n,r,i){return i!==void 0&&(e=Gl(e,i,r)),Gl(e,n,r)+t}function ql(e,t=0,n=1,r,i){e.min=Kl(e.min,t,n,r,i),e.max=Kl(e.max,t,n,r,i)}function Jl(e,{x:t,y:n}){ql(e.x,t.translate,t.scale,t.originPoint),ql(e.y,n.translate,n.scale,n.originPoint)}var Yl=.999999999999,Xl=1.0000000000001;function Zl(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(Ql(e.x,-a.scroll.offset.x),Ql(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Jl(e,o)),r&&Hl(a.latestValues)&&tu(e,a.latestValues,a.layout?.layoutBox))}t.x<Xl&&t.x>Yl&&(t.x=1),t.y<Xl&&t.y>Yl&&(t.y=1)}function Ql(e,t){e.min+=t,e.max+=t}function $l(e,t,n,r,i=.5){ql(e,t,n,Oa(e.min,e.max,i),r)}function eu(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function tu(e,t,n){let r=n??e;$l(e.x,eu(t.x,r.x),t.scaleX,t.scale,t.originX),$l(e.y,eu(t.y,r.y),t.scaleY,t.scale,t.originY)}function nu(e,t){return J(zl(e.getBoundingClientRect(),t))}function ru(e,t,n){let r=nu(e,n),{scroll:i}=t;return i&&(Ql(r.x,i.offset.x),Ql(r.y,i.offset.y)),r}var iu={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},au=Fo.length;function ou(e,t,n){let r=``,i=!0;for(let a=0;a<au;a++){let o=Fo[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===(o.startsWith(`scale`)?1:0);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=Ac(s,xc[o]);if(!c){i=!1;let t=iu[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}return r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function su(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(Io.has(e)){o=!0;continue}else if(Ii(e)){i[e]=n;continue}else{let t=Ac(n,xc[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=ou(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}function cu(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function lu(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var uu={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(G.test(e))e=parseFloat(e);else return e;return`${lu(e,t.target.x)}% ${lu(e,t.target.y)}%`}},du={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=wa.parse(e);if(i.length>5)return r;let a=wa.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=Oa(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},fu={borderRadius:{...uu,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:uu,borderTopRightRadius:uu,borderBottomLeftRadius:uu,borderBottomRightRadius:uu,boxShadow:du};function pu(e,{layout:t,layoutId:n}){return Io.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!fu[e]||e===`opacity`)}function mu(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)($s(r[t])||i&&$s(i[t])||pu(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function hu(e){return window.getComputedStyle(e)}var gu=class extends Rl{constructor(){super(...arguments),this.type=`html`,this.renderInstance=cu}readValueFromInstance(e,t){if(Io.has(t))return this.projection?.isProjecting?jo(t):No(e,t);{let n=hu(e),r=(Ii(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return nu(e,t)}build(e,t,n){su(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return mu(e,t,n)}},_u={offset:`stroke-dashoffset`,array:`stroke-dasharray`},vu={offset:`strokeDashoffset`,array:`strokeDasharray`};function yu(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?_u:vu;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var bu=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function xu(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(su(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of bu)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&yu(d,i,a,o,!1)}var Su=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),Cu=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function wu(e,t,n,r){cu(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(Su.has(n)?n:nc(n),t.attrs[n])}function Tu(e,t,n){let r=mu(e,t,n);for(let n in e)if($s(e[n])||$s(t[n])){let t=Fo.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var Eu=class extends Rl{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=bl}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Io.has(t)){let e=Cc(t);return e&&e.default||0}return t=Su.has(t)?t:nc(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Tu(e,t,n)}build(e,t,n){xu(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){wu(e,t,n,r)}mount(e){this.isSVGTag=Cu(e.tagName),super.mount(e)}},Du=Tl.length;function Ou(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&Ou(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<Du;n++){let r=Tl[n],i=e.props[r];(Cl(i)||i===!1)&&(t[r]=i)}return t}function ku(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var Au=[...wl].reverse(),ju=wl.length;function Mu(e){return t=>Promise.all(t.map(({animation:t,options:n})=>lc(e,t,n)))}function Nu(e){let t=Mu(e),n=Iu(),r=!0,i=!1,a=t=>(n,r)=>{let i=Hs(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=Ou(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<ju;t++){let p=Au[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=Cl(h),_=p===o?m.isActive:null;_===!1&&(f=t);let v=h===c[p]&&h!==s[p]&&g;if(v&&(r||i)&&e.manuallyAnimateOnMount&&(v=!1),m.protectedKeys={...d},!m.isActive&&_===null||!h&&!m.prevProp||Sl(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=Pu(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,T={...w,...C},E=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=Ys(t)&&Ys(n)?!ku(t,n):t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let ee=v&&y;b&&(!ee||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!ee&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=Hs(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=Es(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Hs(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Iu(),i=!0}}}function Pu(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!ku(t,e):!1}function Fu(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Iu(){return{animate:Fu(!0),whileInView:Fu(),whileHover:Fu(),whileTap:Fu(),whileDrag:Fu(),whileFocus:Fu(),exit:Fu()}}function Lu(e,t){e.min=t.min,e.max=t.max}function Ru(e,t){Lu(e.x,t.x),Lu(e.y,t.y)}function zu(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var Bu=1e-4,Vu=1-Bu,Hu=1+Bu,Uu=.01,Wu=0-Uu,Gu=0+Uu;function X(e){return e.max-e.min}function Ku(e,t,n){return Math.abs(e-t)<=n}function qu(e,t,n,r=.5){e.origin=r,e.originPoint=Oa(t.min,t.max,e.origin),e.scale=X(n)/X(t),e.translate=Oa(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Vu&&e.scale<=Hu||isNaN(e.scale))&&(e.scale=1),(e.translate>=Wu&&e.translate<=Gu||isNaN(e.translate))&&(e.translate=0)}function Ju(e,t,n,r){qu(e.x,t.x,n.x,r?r.originX:void 0),qu(e.y,t.y,n.y,r?r.originY:void 0)}function Yu(e,t,n,r=0){e.min=(r?Oa(n.min,n.max,r):n.min)+t.min,e.max=e.min+X(t)}function Xu(e,t,n,r){Yu(e.x,t.x,n.x,r?.x),Yu(e.y,t.y,n.y,r?.y)}function Zu(e,t,n,r=0){let i=r?Oa(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+X(t)}function Qu(e,t,n,r){Zu(e.x,t.x,n.x,r?.x),Zu(e.y,t.y,n.y,r?.y)}function $u(e,t,n,r,i){return e-=t,e=Gl(e,1/n,r),i!==void 0&&(e=Gl(e,1/i,r)),e}function ed(e,t=0,n=1,r=.5,i,a=e,o=e){if(ra.test(t)&&(t=parseFloat(t),t=Oa(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=Oa(a.min,a.max,r);e===a&&(s-=t),e.min=$u(e.min,t,n,s,i),e.max=$u(e.max,t,n,s,i)}function td(e,t,[n,r,i],a,o){ed(e,t[n],t[r],t[i],t.scale,a,o)}var nd=[`x`,`scaleX`,`originX`],rd=[`y`,`scaleY`,`originY`];function id(e,t,n,r){td(e.x,t,nd,n?n.x:void 0,r?r.x:void 0),td(e.y,t,rd,n?n.y:void 0,r?r.y:void 0)}function ad(e){return e.translate===0&&e.scale===1}function od(e){return ad(e.x)&&ad(e.y)}function sd(e,t){return e.min===t.min&&e.max===t.max}function cd(e,t){return sd(e.x,t.x)&&sd(e.y,t.y)}function ld(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function ud(e,t){return ld(e.x,t.x)&&ld(e.y,t.y)}function dd(e){return X(e.x)/X(e.y)}function fd(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function pd(e){return[e(`x`),e(`y`)]}function md(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,rotateX:i,rotateY:a,skewX:o,skewY:s}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotateX(${i}deg) `),a&&(r+=`rotateY(${a}deg) `),o&&(r+=`skewX(${o}deg) `),s&&(r+=`skewY(${s}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var hd=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`],gd=hd.length,_d=e=>typeof e==`string`?parseFloat(e):e,vd=e=>typeof e==`number`||G.test(e);function yd(e,t,n,r,i,a){i?(e.opacity=Oa(0,n.opacity??1,Z(r)),e.opacityExit=Oa(t.opacity??1,0,xd(r))):a&&(e.opacity=Oa(t.opacity??1,n.opacity??1,r));for(let i=0;i<gd;i++){let a=hd[i],o=bd(t,a),s=bd(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||vd(o)===vd(s)?(e[a]=Math.max(Oa(_d(o),_d(s),r),0),(ra.test(s)||ra.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=Oa(t.rotate||0,n.rotate||0,r))}function bd(e,t){return e[t]===void 0?e.borderRadius:e[t]}var Z=Sd(0,.5,mi),xd=Sd(.5,.95,Jr);function Sd(e,t,n){return r=>r<e?0:r>t?1:n(Zr(e,t,r))}function Cd(e,t,n){let r=$s(e)?e:Js(e);return r.start(zs(``,r,t,n)),r.animation}function wd(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var Td=(e,t)=>e.depth-t.depth,Ed=class{constructor(){this.children=[],this.isDirty=!1}add(e){Br(this.children,e),this.isDirty=!0}remove(e){Vr(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Td),this.isDirty=!1,this.children.forEach(e)}};function Dd(e,t){let n=Ni.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(ki(r),e(a-t))};return U.setup(r,!0),()=>ki(r)}function Od(e){return $s(e)?e.get():e}var kd=class{constructor(){this.members=[]}add(e){Br(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(Vr(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Vr(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},Ad={hasAnimatedSinceResize:!0,hasEverUpdated:!1},jd={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},Md=[``,`X`,`Y`,`Z`],Nd=1e3,Pd=0;function Fd(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Id(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=ic(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,U,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Id(r)}function Ld({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=Pd++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,Ti.value&&(jd.nodes=jd.calculatedTargetDeltas=jd.calculatedProjections=0),this.nodes.forEach(Bd),this.nodes.forEach(Yd),this.nodes.forEach(Xd),this.nodes.forEach(Vd),Ti.addProjectionMetrics&&Ti.addProjectionMetrics(jd)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new Ed)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new Qr),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=$c(t)&&!ml(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;U.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=Dd(i,250),Ad.hasAnimatedSinceResize&&(Ad.hasAnimatedSinceResize=!1,this.nodes.forEach(Jd)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||rf,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!ud(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...Is(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l)}else t||Jd(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),ki(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Zd),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Id(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(Wd),this.nodes.forEach(Ud);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Gd);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Kd),this.nodes.forEach(qd),this.nodes.forEach(Rd),this.nodes.forEach(zd)):this.nodes.forEach(Gd),this.clearAllSnapshots();let e=Ni.now();W.delta=Hr(0,1e3/60,e-W.timestamp),W.timestamp=e,W.isProcessing=!0,Ai.update.process(W),Ai.preRender.process(W),Ai.render.process(W),W.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Mc.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Hd),this.sharedNodes.forEach(Qd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,U.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){U.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!X(this.snapshot.measuredBox.x)&&!X(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||=bl(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!od(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Hl(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),cf(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return bl();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(uf))){let{scroll:e}=this.root;e&&(Ql(t.x,e.offset.x),Ql(t.y,e.offset.y))}return t}removeElementScroll(e){let t=bl();if(Ru(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&Ru(t,e),Ql(t.x,i.offset.x),Ql(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||bl();Ru(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(Ql(r.x,-n.scroll.offset.x),Ql(r.y,-n.scroll.offset.y)),Hl(n.latestValues)&&tu(r,n.latestValues,n.layout?.layoutBox)}return Hl(this.latestValues)&&tu(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=bl();Ru(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Hl(n.latestValues))continue;let r;n.instance&&(Vl(n.latestValues)&&n.updateSnapshot(),r=bl(),Ru(r,n.measurePageBox())),id(t,n.latestValues,n.snapshot?.layoutBox,r)}return Hl(this.latestValues)&&id(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0?!0:e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==W.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=W.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=bl(),this.targetWithTransforms=bl()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Xu(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Ru(this.target,this.layout.layoutBox),Jl(this.target,this.targetDelta)):Ru(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),Ti.value&&jd.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Vl(this.parent.latestValues)||Ul(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=bl(),this.relativeTargetOrigin=bl(),Qu(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Ru(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===W.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;Ru(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;Zl(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=bl());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(zu(this.prevProjectionDelta.x,this.projectionDelta.x),zu(this.prevProjectionDelta.y,this.projectionDelta.y)),Ju(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!fd(this.projectionDelta.x,this.prevProjectionDelta.x)||!fd(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),Ti.value&&jd.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=vl(),this.projectionDelta=vl(),this.projectionDeltaWithTransform=vl()}setAnimationOrigin(e,t=!1){let n=this.snapshot,r=n?n.latestValues:{},i={...this.latestValues},a=vl();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=bl(),s=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),c=this.getStack(),l=!c||c.members.length<=1,u=!!(s&&!l&&this.options.crossfade===!0&&!this.path.some(nf));this.animationProgress=0;let d;this.mixTargetDelta=t=>{let n=t/1e3;$d(a.x,e.x,n),$d(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Qu(o,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),tf(this.relativeTarget,this.relativeTargetOrigin,o,n),d&&cd(this.relativeTarget,d)&&(this.isProjectionDirty=!1),d||=bl(),Ru(d,this.relativeTarget)),s&&(this.animationValues=i,yd(i,r,this.latestValues,n,u,l)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(ki(this.pendingAnimation),void 0),this.pendingAnimation=U.update(()=>{Ad.hasAnimatedSinceResize=!0,Pi.layout++,this.motionValue||=Js(0),this.motionValue.jump(0,!1),this.currentAnimation=Cd(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{Pi.layout--},onComplete:()=>{Pi.layout--,e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Nd),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&lf(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||bl();let t=X(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=X(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}Ru(t,n),tu(t,i),Ju(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new kd),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return e?e.lead===this:!0}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&Fd(`z`,e,r,this.animationValues);for(let t=0;t<Md.length;t++)Fd(`rotate${Md[t]}`,e,r,this.animationValues),Fd(`skew${Md[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=Od(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=Od(t?.pointerEvents)||``),this.hasProjected&&!Hl(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=md(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,r.animationValues?e.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in fu){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=fu[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?Od(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(Ud),this.root.sharedNodes.clear()}}}function Rd(e){e.updateLayout()}function zd(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)pd(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=X(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Lu(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else lf(i,t.layoutBox,n)&&pd(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=X(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=vl();Ju(o,n,t.layoutBox);let s=vl();a?Ju(s,e.applyTransform(r,!0),t.measuredBox):Ju(s,n,t.layoutBox);let c=!od(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=bl();Qu(s,t.layoutBox,i.layoutBox,o);let c=bl();Qu(c,n,a.layoutBox,o),ud(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function Bd(e){Ti.value&&jd.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function Vd(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Hd(e){e.clearSnapshot()}function Ud(e){e.clearMeasurements()}function Wd(e){e.isLayoutDirty=!0,e.updateLayout()}function Gd(e){e.isLayoutDirty=!1}function Kd(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function qd(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function Jd(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Yd(e){e.resolveTargetDelta()}function Xd(e){e.calcProjection()}function Zd(e){e.resetSkewAndRotation()}function Qd(e){e.removeLeadSnapshot()}function $d(e,t,n){e.translate=Oa(t.translate,0,n),e.scale=Oa(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ef(e,t,n,r){e.min=Oa(t.min,n.min,r),e.max=Oa(t.max,n.max,r)}function tf(e,t,n,r){ef(e.x,t.x,n.x,r),ef(e.y,t.y,n.y,r)}function nf(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var rf={duration:.45,ease:[.4,0,.1,1]},af=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),of=af(`applewebkit/`)&&!af(`chrome/`)?Math.round:Jr;function sf(e){e.min=of(e.min),e.max=of(e.max)}function cf(e){sf(e.x),sf(e.y)}function lf(e,t,n){return e===`position`||e===`preserve-aspect`&&!Ku(dd(t),dd(n),.2)}function uf(e){return e!==e.root&&e.scroll?.wasRoot}var df=Ld({attachResizeListener:(e,t)=>wd(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),ff={current:void 0},pf=Ld({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!ff.current){let e=new df({});e.mount(window),e.setOptions({layoutScroll:!0}),ff.current=e}return ff.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),mf=(0,b.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function hf(e=!0){let t=(0,b.useContext)(zr);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,b.useId)();(0,b.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,b.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var gf=(0,b.createContext)({strict:!1}),_f={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},vf=!1;function yf(){if(vf)return;let e={};for(let t in _f)e[t]={isEnabled:e=>_f[t].some(t=>!!e[t])};Fl(e),vf=!0}function bf(){return yf(),Il()}function xf(e){let t=bf();for(let n in e)t[n]={...t[n],...e[n]};Fl(t)}var Sf=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function Cf(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||Sf.has(e)}var wf=c({default:()=>Tf}),Tf,Ef=o((()=>{throw Tf={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),Df=e=>!Cf(e);function Of(e){typeof e==`function`&&(Df=t=>t.startsWith(`on`)?!Cf(t):e(t))}try{Of((Ef(),d(wf)).default)}catch{}function kf(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||$s(e[i])||(Df(i)||n===!0&&Cf(i)||!t&&!Cf(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var Af=(0,b.createContext)({});function jf(e,t){if(El(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Cl(t)?t:void 0,animate:Cl(n)?n:void 0}}return e.inherit===!1?{}:t}function Mf(e){let{initial:t,animate:n}=jf(e,(0,b.useContext)(Af));return(0,b.useMemo)(()=>({initial:t,animate:n}),[Nf(t),Nf(n)])}function Nf(e){return Array.isArray(e)?e.join(` `):e}var Pf=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ff(e,t,n){for(let r in t)!$s(t[r])&&!pu(r,n)&&(e[r]=t[r])}function If({transformTemplate:e},t){return(0,b.useMemo)(()=>{let n=Pf();return su(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Lf(e,t){let n=e.style||{},r={};return Ff(r,n,e),Object.assign(r,If(e,t)),r}function Rf(e,t){let n={},r=Lf(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var zf=()=>({...Pf(),attrs:{}});function Bf(e,t,n,r){let i=(0,b.useMemo)(()=>{let n=zf();return xu(n,t,Cu(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Ff(t,e.style,e),i.style={...t,...i.style}}return i}var Vf=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function Hf(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(Vf.indexOf(e)>-1||/[A-Z]/u.test(e))}function Uf(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??Hf(e)?Bf:Rf)(t,r,i,e),c=kf(t,typeof e==`string`,a),l=e===b.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,b.useMemo)(()=>$s(u)?u.get():u,[u]);return(0,b.createElement)(e,{...l,children:d})}function Wf({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Gf(n,r,i,e),renderState:t()}}function Gf(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=Od(a[e]);let{initial:o,animate:s}=e,c=El(e),l=Dl(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!Sl(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Vs(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var Kf=e=>(t,n)=>{let r=(0,b.useContext)(Af),i=(0,b.useContext)(zr),a=()=>Wf(e,t,r,i);return n?a():Lr(a)},qf=Kf({scrapeMotionValuesFromProps:mu,createRenderState:Pf}),Jf=Kf({scrapeMotionValuesFromProps:Tu,createRenderState:zf}),Yf=Symbol.for(`motionComponentSymbol`);function Xf(e,t,n){let r=(0,b.useRef)(n);(0,b.useInsertionEffect)(()=>{r.current=n});let i=(0,b.useRef)(null);return(0,b.useCallback)(n=>{n&&e.onMount?.(n);let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n);t&&(n?t.mount(n):t.unmount())},[t])}var Zf=(0,b.createContext)({});function Qf(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function $f(e,t,n,r,i,a){let{visualElement:o}=(0,b.useContext)(Af),s=(0,b.useContext)(gf),c=(0,b.useContext)(zr),l=(0,b.useContext)(mf),u=l.reducedMotion,d=l.skipAnimations,f=(0,b.useRef)(null),p=(0,b.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,b.useContext)(Zf);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&ep(f.current,n,i,h);let g=(0,b.useRef)(!1);(0,b.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[rc],v=(0,b.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return Rr(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,b.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function ep(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:tp(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&Qf(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function tp(e){if(e)return e.options.allowProjection===!1?tp(e.parent):e.projection}function np(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&xf(r);let a=n?n===`svg`:Hf(e),o=a?Jf:qf;function s(n,s){let c,l={...(0,b.useContext)(mf),...n,layoutId:rp(n)},{isStatic:u}=l,d=Mf(n),f=o(n,u);if(!u&&typeof window<`u`){ip(l,r);let t=ap(l);c=t.MeasureLayout,d.visualElement=$f(e,f,l,i,t.ProjectionNode,a)}return(0,H.jsxs)(Af.Provider,{value:d,children:[c&&d.visualElement?(0,H.jsx)(c,{visualElement:d.visualElement,...l}):null,Uf(e,n,Xf(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,b.forwardRef)(s);return c[Yf]=e,c}function rp({layoutId:e}){let t=(0,b.useContext)(Ir).id;return t&&e!==void 0?t+`-`+e:e}function ip(e,t){(0,b.useContext)(gf).strict}function ap(e){let{drag:t,layout:n}=bf();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function op(e,t){if(typeof Proxy>`u`)return np;let n=new Map,r=(n,r)=>np(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,np(a,void 0,e,t)),n.get(a))})}var sp=(e,t)=>t.isSVG??Hf(e)?new Eu(t):new gu(t,{allowProjection:e!==b.Fragment}),cp=class extends q{constructor(e){super(e),e.animationState||=Nu(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();Sl(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},lp=0,up={animation:{Feature:cp},exit:{Feature:class extends q{constructor(){super(...arguments),this.id=lp++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`){let n=Hs(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function dp(e){return{point:{x:e.pageX,y:e.pageY}}}var fp=e=>t=>Vc(t)&&e(t,dp(t));function pp(e,t,n,r){return wd(e,t,fp(n),r)}var mp=({current:e})=>e?e.ownerDocument.defaultView:null,hp=(e,t)=>Math.abs(e-t);function gp(e,t){let n=hp(e.x,t.x),r=hp(e.y,t.y);return Math.sqrt(n**2+r**2)}var _p=new Set([`auto`,`scroll`]),vp=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=yp(this.lastRawMoveEventInfo,this.transformPagePoint));let e=xp(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=gp(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=W;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=yp(t,this.transformPagePoint),U.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=xp(e.type===`pointercancel`?this.lastMoveEventInfo:yp(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!Vc(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=yp(dp(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=W;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,xp(s,this.history)),this.removeListeners=Xr(pp(this.contextWindow,`pointermove`,this.handlePointerMove),pp(this.contextWindow,`pointerup`,this.handlePointerUp),pp(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(_p.has(e.overflowX)||_p.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),U.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ki(this.updatePoint)}};function yp(e,t){return t?{point:t(e.point)}:e}function bp(e,t){return{x:e.x-t.x,y:e.y-t.y}}function xp({point:e},t){return{point:e,delta:bp(e,Cp(t)),offset:bp(e,Sp(t)),velocity:wp(t,.1)}}function Sp(e){return e[0]}function Cp(e){return e[e.length-1]}function wp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=Cp(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>$r(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>$r(t)*2&&(r=e[1]);let a=ei(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function Tp(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?Oa(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?Oa(n,e,r.max):Math.min(e,n)),e}function Ep(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function Dp(e,{top:t,left:n,bottom:r,right:i}){return{x:Ep(e.x,n,i),y:Ep(e.y,t,r)}}function Op(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function kp(e,t){return{x:Op(e.x,t.x),y:Op(e.y,t.y)}}function Ap(e,t){let n=.5,r=X(e),i=X(t);return i>r?n=Zr(t.min,t.max-r,e.min):r>i&&(n=Zr(e.min,e.max-i,t.min)),Hr(0,1,n)}function jp(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var Mp=.35;function Np(e=Mp){return e===!1?e=0:e===!0&&(e=Mp),{x:Pp(e,`left`,`right`),y:Pp(e,`top`,`bottom`)}}function Pp(e,t,n){return{min:Fp(e,t),max:Fp(e,n)}}function Fp(e,t){return typeof e==`number`?e:e[t]||0}var Ip=new WeakMap,Lp=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=bl(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(dp(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Ic(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),pd(e=>{let t=this.getAxisMotionValue(e).get()||0;if(ra.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=X(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&U.update(()=>i(e,t),!1,!0),tc(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=Vp(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&U.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new vp(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:mp(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&U.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!Bp(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Tp(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&Qf(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=Dp(n.layoutBox,e):this.constraints=!1,this.elastic=Np(t),r!==this.constraints&&!Qf(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&pd(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=jp(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Qf(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=ru(n,r.root,this.visualElement.getTransformPagePoint()),a=kp(r.layout.layoutBox,i);if(t){let e=t(Y(a));this.hasMutatedConstraints=!!e,e&&(a=J(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=pd(o=>{if(!Bp(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return tc(this.visualElement,e),n.start(zs(e,n,0,t,this.visualElement,!1))}stopAnimation(){pd(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps();return n[t]||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){pd(t=>{let{drag:n}=this.getProps();if(!Bp(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-Oa(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Qf(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};pd(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Ap({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),pd(t=>{if(!Bp(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(Oa(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Ip.set(this.visualElement,this);let e=this.visualElement.current,t=pp(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&Gc(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();Qf(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=zp(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),U.read(r);let o=wd(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(pd(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=Mp,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function Rp(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function zp(e,t,n){let r=pl(e,Rp(n)),i=pl(t,Rp(n));return()=>{r(),i()}}function Bp(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Vp(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var Hp=class extends q{constructor(e){super(e),this.removeGroupControls=Jr,this.removeListeners=Jr,this.controls=new Lp(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Jr}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},Up=e=>(t,n)=>{e&&U.update(()=>e(t,n),!1,!0)},Wp=class extends q{constructor(){super(...arguments),this.removePointerDownListener=Jr}onPointerDown(e){this.session=new vp(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:mp(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Up(e),onStart:Up(t),onMove:Up(n),onEnd:(e,t)=>{delete this.session,r&&U.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=pp(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},Gp=!1,Kp=class extends b.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),Gp&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Ad.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),Gp=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||U.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),Mc.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Gp=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function qp(e){let[t,n]=hf(),r=(0,b.useContext)(Ir);return(0,H.jsx)(Kp,{...e,layoutGroup:r,switchLayoutGroup:(0,b.useContext)(Zf),isPresent:t,safeToRemove:n})}var Jp={pan:{Feature:Wp},drag:{Feature:Hp,ProjectionNode:pf,MeasureLayout:qp}};function Yp(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&U.postRender(()=>i(t,dp(t)))}var Xp=class extends q{mount(){let{current:e}=this.node;e&&(this.unmount=zc(e,(e,t)=>(Yp(this.node,t,`Start`),e=>Yp(this.node,e,`End`))))}unmount(){}},Zp=class extends q{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=Xr(wd(this.node.current,`focus`,()=>this.onFocus()),wd(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function Qp(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&U.postRender(()=>i(t,dp(t)))}var $p=class extends q{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Qc(e,(e,t)=>(Qp(this.node,t,`Start`),(e,{success:t})=>Qp(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},em=new WeakMap,tm=new WeakMap,nm=e=>{let t=em.get(e.target);t&&t(e)},rm=e=>{e.forEach(nm)};function im({root:e,...t}){let n=e||document;tm.has(n)||tm.set(n,{});let r=tm.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(rm,{root:e,...t})),r[i]}function am(e,t,n){let r=im(t);return em.set(e,n),r.observe(e),()=>{em.delete(e),r.unobserve(e)}}var om={some:0,all:1},sm=class extends q{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:om[r]};this.stopObserver=am(this.node.current,a,e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)})}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(cm(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function cm({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var lm={inView:{Feature:sm},tap:{Feature:$p},focus:{Feature:Zp},hover:{Feature:Xp}},um={layout:{ProjectionNode:pf,MeasureLayout:qp}},dm=op({...up,...lm,...Jp,...um},sp),fm=24e3,pm=2048,mm=1200,hm=.05,gm=4,_m=.03,vm=2,ym=11;function bm(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t/e.length)}function xm(e){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++){let r=Math.max(-1,Math.min(1,e[n]));t[n]=r<0?r*32768:r*32767}return t}function Sm(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]/32768;return t}var Cm=.09,wm=[`audio/webm`,`audio/mp4`];function Tm(){return typeof window>`u`||window.MediaRecorder===void 0?null:wm.find(e=>window.MediaRecorder.isTypeSupported(e))||null}function Em(e,t,n,r,i){if(!r.length||!n||!e)return;let a=new Blob(r,{type:i}),o=new FormData;o.append(`audio`,a,`aichat-${n}.webm`),o.append(`voiceSessionId`,n),o.append(`siteId`,t||``),fetch(`${e}/api/voice/upload-chat-recording`,{method:`POST`,body:o}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(e=>console.warn(`[FlowEngage] voice recording upload failed:`,e.message))}function Dm(e,t,n){let r=0,i=0,a=[],o=()=>{a.forEach(e=>{try{e.stop()}catch{}}),a=[],r=0},s=()=>r>e.currentTime;return{enqueue:o=>{let c=Sm(o),l=e.createBuffer(1,c.length,fm);l.copyToChannel(c,0);let u=e.createBufferSource();u.buffer=l,u.connect(e.destination),n&&u.connect(n);let d=!s(),f=d?e.currentTime+Cm:r;d&&(i=f),u.start(f),r=f+l.duration,a.push(u),u.onended=()=>{a=a.filter(e=>e!==u),!a.length&&!s()&&t?.()}},stop:o,isPlaying:s,playedMs:()=>Math.max(0,(e.currentTime-i)*1e3)}}async function Om(e,t,n){let r=new URLSearchParams({siteId:t||``});n&&r.set(`chatId`,n);let i=await fetch(`${e}/api/voice/session?${r.toString()}`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(i.status===429){let e=await i.json().catch(()=>({}));throw Error(e.message||`Too many voice sessions started. Please wait a minute before trying again.`)}if(!i.ok)throw Error(`Could not start a voice session.`);let a=await i.json();if(!a?.success||!a.wsUrl)throw Error(a?.error||`Voice session was refused.`);return a}async function km(e){let{apiBaseUrl:t,siteId:n,chatId:r,clientTools:i={},onConnect:a,onDisconnect:o,onMessage:s,onModeChange:c,onError:l,onUnhandledClientToolCall:u,onAgentTurnEnd:d,onSessionInfo:f,onSessionEnding:p}=e,m=await Om(t,n,r);f?.({emailOnFile:!!m.emailOnFile});let h={type:`Start`};e.greeting!==void 0&&(h.greeting=e.greeting||null);let g=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),_=new(window.AudioContext||window.webkitAudioContext)({sampleRate:fm});_.state===`suspended`&&await _.resume();let v=_.createMediaStreamDestination(),y=Tm(),b=[],x=null,S=r||n||null;y&&(x=new window.MediaRecorder(v.stream,{mimeType:y}),x.ondataavailable=e=>{e.data&&e.data.size>0&&b.push(e.data)},x.start());let C=new WebSocket(m.wsUrl);C.binaryType=`arraybuffer`;let w=new Set,T={role:null,text:``,timer:null,debug:null},E=``,ee=()=>{T.timer&&=(clearTimeout(T.timer),null);let e=T.text.trim(),t=T.role,n=T.debug;if(T.text=``,T.role=null,T.debug=null,!(!e||!t)){if(t===`agent`){if(e===E){console.debug(`[FlowEngage] duplicate agent turn suppressed`);return}E=e}s?.({role:t,message:e,debug:n})}},te=(e,t,n)=>{t&&(T.role&&T.role!==e&&ee(),T.role=e,T.text=T.text?`${T.text} ${t}`.replace(/\s+/g,` `):t,n&&(T.debug=n),T.timer&&clearTimeout(T.timer),T.timer=setTimeout(ee,mm))},D=!1,O=!1,ne=!1,re=!1,ie=!0,ae=0,oe=!1,k=!1,A=hm,se=gm,ce=null,le=!1,ue=(e=!0)=>{ce&&clearTimeout(ce);let t=()=>{if(!D){if(j.isPlaying()){ce=setTimeout(t,150);return}if(ce=null,le){p?.();return}!D&&C.readyState===WebSocket.OPEN&&C.send(JSON.stringify({type:`PlaybackDrained`})),e&&d?.()}};ce=setTimeout(t,150)},j=Dm(_,()=>{re&&(re=!1,c?.({mode:`listening`}))},v),M=_.createMediaStreamSource(g);M.connect(v);let de=_.createScriptProcessor(pm,1,1),fe=!1,N=0,pe=0;de.onaudioprocess=e=>{if(D||C.readyState!==WebSocket.OPEN)return;let t=e.inputBuffer.getChannelData(0),n=()=>C.send(new Int16Array(t.length).buffer);if(O){ne||(ne=!0,console.debug(`[FlowEngage] mic held — streaming silence to keep socket alive`)),fe=!1,N=0,pe=0,n();return}let r=bm(t);if(j.isPlaying()||k?(fe=!1,N=0,pe=0):r>=_m?(pe=0,N+=1,!fe&&N>=vm&&(fe=!0,c?.({mode:`user-speaking`}))):(N=0,fe&&++pe>=ym&&(fe=!1,pe=0,c?.({mode:`thinking`,tentative:!0}))),(j.isPlaying()||k)&&!oe){if(r<A){ae=0,n();return}if(ae+=1,ae<se){n();return}oe=!0,ae=0;let e=j.playedMs();j.stop(),ie=!1,k=!1,ce&&!le&&(clearTimeout(ce),ce=null),C.send(JSON.stringify({type:`VisitorInterrupted`,played_ms:Math.round(e)})),console.debug(`[FlowEngage] barge-in — visitor spoke over the agent`)}C.send(xm(t).buffer)},M.connect(de),de.connect(_.destination);let me=()=>{if(!D){D=!0,ce&&=(clearTimeout(ce),null),ee(),j.stop();try{de.disconnect(),M.disconnect()}catch{}if(g.getTracks().forEach(e=>e.stop()),x&&x.state!==`inactive`){x.onstop=()=>Em(t,n,S,b,y);try{x.stop()}catch{x.onstop=null}}else b.length&&Em(t,n,S,b,y);_.close().catch(()=>{}),(C.readyState===WebSocket.OPEN||C.readyState===WebSocket.CONNECTING)&&C.close()}},he=async e=>{let t=i[e.name];if(!t)return u?.({tool_name:e.name}),{error:`Unknown tool ${e.name}`};let n={};try{n=JSON.parse(e.arguments||`{}`)}catch{}try{return await t(n)}catch(e){return{error:e?.message||`Tool execution failed`}}},ge=async e=>{for(let t of e.functions||[]){if(!t.client_side)continue;let e=await he(t);if(D||C.readyState!==WebSocket.OPEN)return;C.send(JSON.stringify({type:`FunctionCallResponse`,id:t.id,name:t.name,content:typeof e==`string`?e:JSON.stringify(e??{})}))}},P=e=>{switch(e.type){case`Welcome`:Number.isFinite(e.barge_in_rms)&&e.barge_in_rms>0&&(A=e.barge_in_rms),Number.isFinite(e.barge_in_frames)&&e.barge_in_frames>0&&(se=e.barge_in_frames),S=e.session_id||r||n||null,a?.({conversationId:S});break;case`ConversationText`:{let t=String(e.content||``);if(e.role===`user`){let e=t.trim();if(w.has(e)){w.delete(e);break}if(/^\[SYSTEM:/i.test(e)||/^Continue (now )?to the next section/i.test(e)||/^That was the last section/i.test(e)){console.debug(`[FlowEngage] widget instruction hidden from transcript`);break}}te(e.role===`user`?`user`:`agent`,t,e.debug);break}case`UserStartedSpeaking`:ee(),j.stop(),k=!1,ie=!1,re=!1,ce&&!le&&(clearTimeout(ce),ce=null),c?.({mode:`listening`});break;case`AgentStartedSpeaking`:ie=!0,re=!0,oe=!1,ae=0,c?.({mode:`speaking`});break;case`AgentAudioDone`:k=!1,ee(),ue(e.turnComplete!==!1),j.isPlaying()||(re=!1,c?.({mode:`listening`}));break;case`FunctionCallRequest`:ge(e);break;case`AgentPreparing`:k=!0;break;case`SessionEnding`:console.debug(`[FlowEngage] server is ending the session:`,e.reason||`unspecified`),le=!0;break;case`AgentThinking`:c?.({mode:`thinking`});break;case`PromptUpdated`:break;case`Error`:console.error(`[FlowEngage:Voice]`,e.code||``,e.description||e),l?.(Error(e.description||`Voice service error`));break;case`Warning`:console.warn(`[FlowEngage:Voice]`,e.code||``,e.description||``);break;default:break}};return C.onopen=()=>C.send(JSON.stringify(h)),C.onmessage=e=>{if(e.data instanceof ArrayBuffer){ie&&j.enqueue(new Int16Array(e.data));return}try{P(JSON.parse(e.data))}catch{}},C.onerror=()=>l?.(Error(`Voice connection failed`)),C.onclose=()=>{me(),o?.()},{endSession:async()=>me(),sendContextualUpdate:e=>{D||C.readyState!==WebSocket.OPEN||!e||C.send(JSON.stringify({type:`UpdatePrompt`,prompt:e}))},sendUserMessage:(e,{silent:t=!0,suppressQuestion:n=!1}={})=>{D||C.readyState!==WebSocket.OPEN||!e||(t&&w.add(e.trim()),C.send(JSON.stringify({type:`InjectUserMessage`,content:e,suppress_question:n})))},injectAgentSpeech:(e,t=`interrupt`)=>{D||C.readyState!==WebSocket.OPEN||!e||C.send(JSON.stringify({type:`InjectAgentMessage`,message:e,behavior:t}))},setWalkthroughActive:e=>{D||C.readyState!==WebSocket.OPEN||C.send(JSON.stringify({type:`WalkthroughActive`,active:!!e}))},setMicMuted:e=>{O=!!e,!D&&C.readyState===WebSocket.OPEN&&C.send(JSON.stringify({type:`MicHeld`,held:O}))},get status(){return D?`disconnected`:`connected`}}}var Am={startSession:km},jm=({size:e=18,color:t=`currentColor`})=>(0,H.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,H.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`,fill:t}),(0,H.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`,stroke:t,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),Mm=({size:e=20})=>(0,H.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.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,H.jsx)(`line`,{x1:`23`,y1:`1`,x2:`1`,y2:`23`})]}),Nm=({size:e=18})=>(0,H.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`5`}),(0,H.jsx)(`polyline`,{points:`5 12 12 5 19 12`})]}),Pm=()=>(0,H.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`polyline`,{points:`9 17 4 12 9 7`}),(0,H.jsx)(`path`,{d:`M20 18v-2a4 4 0 00-4-4H4`})]}),Fm=()=>(0,H.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,H.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`})}),Im=({className:e=``})=>(0,H.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,H.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,H.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,H.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),Lm=({size:e=14})=>(0,H.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{d:`M12 8V4H8`}),(0,H.jsx)(`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`}),(0,H.jsx)(`path`,{d:`M2 14h2`}),(0,H.jsx)(`path`,{d:`M20 14h2`}),(0,H.jsx)(`path`,{d:`M15 13v2`}),(0,H.jsx)(`path`,{d:`M9 13v2`})]}),Rm=({size:e=20,strokeWidth:t=2,color:n=`currentColor`})=>(0,H.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:n,strokeWidth:t,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,H.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),zm=({size:e=20,color:t=`currentColor`})=>(0,H.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,H.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:t}),(0,H.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:t}),(0,H.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:t})]}),Bm=({size:e=20,color:t=`currentColor`})=>(0,H.jsxs)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,H.jsx)(`path`,{d:`M22 11.5667C22 16.8499 17.5222 21.1334 12 21.1334C11.3507 21.1343 10.7032 21.0742 10.0654 20.9545C9.60633 20.8682 9.37678 20.8251 9.21653 20.8496C9.05627 20.8741 8.82918 20.9948 8.37499 21.2364C7.09014 21.9197 5.59195 22.161 4.15111 21.893C4.69874 21.2194 5.07275 20.4112 5.23778 19.5448C5.33778 19.0148 5.09 18.5 4.71889 18.1231C3.03333 16.4115 2 14.1051 2 11.5667C2 6.28357 6.47778 2 12 2C17.5222 2 22 6.28357 22 11.5667Z`,stroke:`white`,"stroke-width":`1.5`,"stroke-linejoin":`round`}),(0,H.jsx)(`path`,{d:`M11.9955 12H12.0045M15.991 12H16M8 12H8.00897`,stroke:`white`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]}),Vm=()=>(0,H.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,H.jsx)(`path`,{d:`M16.7133 8.59374C18.1939 8.98463 19.2229 9.47922 20.1589 10.0848C21.5432 10.9804 22.1367 12.5944 21.9737 14.1517C21.9049 14.8099 21.3744 15.1246 20.7592 14.9544L19.3705 14.57C18.2697 14.2653 17.7193 14.1129 17.3837 13.71C17.0481 13.307 17.0086 12.751 16.9296 11.6391L16.7133 8.59374ZM16.7133 8.59374C13.7164 7.80255 10.2871 7.80163 7.28669 8.59374M7.28669 8.59374C5.80606 8.98463 4.77711 9.47923 3.84113 10.0848C2.45683 10.9804 1.86334 12.5944 2.02628 14.1517C2.09514 14.8099 2.62563 15.1246 3.24078 14.9544L4.62954 14.57C5.73032 14.2653 6.28071 14.1129 6.61631 13.71C6.95191 13.307 6.9914 12.751 7.07038 11.6391L7.28669 8.59374Z`,stroke:`#E30C12`,"stroke-width":`1.5`,"stroke-linejoin":`round`})}),Hm=({size:e=24})=>(0,H.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{d:`M12 19v3`}),(0,H.jsx)(`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`}),(0,H.jsx)(`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`}),(0,H.jsx)(`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`}),(0,H.jsx)(`path`,{d:`m2 2 20 20`}),(0,H.jsx)(`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`})]}),Um=(e=``)=>String(e).replace(/<[^>]+>/g,``).replace(/\s+/g,` `).trim(),Wm=(e=``)=>String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),Gm=new Set([`p`,`br`,`ul`,`ol`,`li`,`strong`,`em`,`b`,`i`,`a`]),Km=/^https?:\/\//i;function qm(e){let t=Array.from(e.childNodes);for(let n of t)if(n.nodeType===Node.ELEMENT_NODE){let t=n.tagName.toLowerCase();if(!Gm.has(t)){e.replaceChild(document.createTextNode(n.textContent),n);continue}let r={};if(t===`a`){let e=n.getAttribute(`href`)||``;Km.test(e)&&(r.href=e),r.target=`_blank`,r.rel=`noopener noreferrer`}for(;n.attributes.length>0;)n.removeAttribute(n.attributes[0].name);for(let[e,t]of Object.entries(r))n.setAttribute(e,t);qm(n)}else n.nodeType!==Node.TEXT_NODE&&e.removeChild(n)}function Jm(e){let t=document.createElement(`div`);return t.innerHTML=e,qm(t),t.innerHTML}function Ym(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 Xm=(e=``)=>{let t=String(e||``).trim();if(!t)return``;if(/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t))return Ym(Jm(t));let n=t.replace(/\r\n/g,`
34
34
  `).replace(/\n{3,}/g,`
35
35
 
36
36
  `).split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean),r=e=>Wm(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 Ym(n.map(e=>{let t=e.split(`
@@ -342,7 +342,7 @@ Error generating stack: `+e.message+`
342
342
  `).trim()}function pg(e){let t=e.siteId||null,n=(e.apiBaseUrl||``).replace(/\/$/,``),r=typeof e.getLastUserVoiceText==`function`?e.getLastUserVoiceText:null,i=[],a={"fwh-navigate-mvp":async n=>{$(`fwh-navigate-mvp ▶ raw parameters:`,n);let i=cg(n),a=lg(i),o=i.section_text??i.sectionText??i.section,s=Array.isArray(i.expected_landmarks)?i.expected_landmarks:Array.isArray(i.expectedLandmarks)?i.expectedLandmarks:[];if($(`fwh-navigate-mvp · coerced:`,{url:a,sectionText:o,expectedLandmarks:s}),!a){let e=`Missing url: pass a string url, path like /pricing, or JSON with a url field.`;return $(`fwh-navigate-mvp ✖`,e),e}if(typeof window<`u`)try{let e=new URL(a,window.location.href);if(e.origin!==window.location.origin&&/^https?:$/i.test(e.protocol)){let t=e.hostname;return $(`fwh-navigate-mvp ✖ external URL blocked:`,e.href),`EXTERNAL_LINK_BLOCKED: The URL "${a}" points to an external site (${t}) that opens in a new tab. I cannot open new tabs or navigate to external sites. Tell the visitor exactly this: "That link opens an external app — I'm not able to open it for you, but you can click the link directly in the navigation header."`}}catch{}if(typeof window<`u`){try{let e=new URL(a,window.location.href);if(e.pathname===window.location.pathname&&e.search===window.location.search)return $(`fwh-navigate-mvp ✖ already on page, skipping`),`OK_ALREADY_ON_PAGE. The visitor is already on this page. Do not navigate. Proceed directly with highlights, answering the question, or reading page content.`}catch{}let e=window.__fe_user_nav_during_speech;if(e&&Date.now()-e.ts<3e4)try{if(new URL(a,window.location.href).pathname===e.fromPath)return $(`flowengage_navigate ✖ blocked — would navigate back to page visitor just left`,e),`NAV_BLOCKED: The visitor just left "${e.fromPageName}" and is now on "${e.toPageName}". Do NOT navigate them back. If they said "continue", resume verbally from where you left off — no navigation needed. If they want to return, they will navigate themselves.`}catch{}}let{allowed:c,correctedUrl:l}=await hr(a,{siteId:t,apiBaseUrl:e.apiBaseUrl});if(!c){let e=`PAGE_NOT_IN_SITE: "${a}" is NOT a real page on this site — do NOT guess or invent URL paths. Do NOT tell the visitor you are taking them there. Instead, find the REAL page: look at your Popular Pages / Site Pages list for the closest actual match, or call fwh-list-nav-links-mvp (to read the site's real menu links) or fwh-search-mvp (to find the right page). If a close match exists (e.g. the visitor said "support" and the site has "Technical Support"), tell them the ACTUAL page name and ask "we don't have a page called that, but we do have [real page] — would you like me to take you there?" Then navigate only to that verified URL.`;return $(`fwh-navigate-mvp ✖ blocked`,e),e}l&&l!==a&&($(`fwh-navigate-mvp · corrected url:`,{requested:a,correctedUrl:l}),a=l);try{Mh(`Navigating to ${a}...`,{spinner:!0}),Lh(),kn();try{let e=r?r():``;if(e&&t){let n=Dh([{sender:`user`,message:e}]);n&&ye(t,n)}}catch{}Ce();let e=a;try{e=new URL(a,typeof window<`u`?window.location.href:``).href}catch{}let n=`this`;try{let e=new URL(a,window.location.href).pathname.split(`/`).filter(Boolean).pop()||``;n=e?e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()):`Home`}catch{}t&&typeof window<`u`&&ke(t,window.location.href,e,n),vr(e),$(`fwh-navigate-mvp → real navigation`,a);let i=typeof window<`u`&&!!Yn();if(typeof window<`u`&&window.__fe_triggerVoiceNavHooks&&window.__fe_triggerVoiceNavHooks(),i&&Bn(12e3),Sr(a,{voiceActive:!0}).catch(()=>{}),i)try{let e=new URL(a,window.location.origin).pathname,t=window.location.pathname,n=Date.now()+2e3;for(;Date.now()<n&&!(typeof window<`u`&&window.location.pathname===e);)await new Promise(e=>setTimeout(e,80));let r=typeof window<`u`?window.location.pathname:e,i=typeof window<`u`?window.location.href:a;(r.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),$(`fwh-navigate-mvp → SPA nav complete. target:`,e,`actual:`,r);try{typeof window<`u`&&window.scrollTo(0,0)}catch{}let o=[],s=null,c=``,l=Date.now()+12e3;for(;Date.now()<l&&(await new Promise(e=>setTimeout(e,300)),{headings:o,pageTitleHeading:s,introText:c}=dg(),!(o.length>=1)););ug(),$(`fwh-navigate-mvp → page headings collected:`,o,`titleHeading:`,s);let u=o.length?o.join(` | `):`none`,d=o.length?`Use ONLY these exact heading strings for fwh-highlight-mvp — never invent or abbreviate.`:`No headings collected yet — call fwh-get-current-page-mvp immediately (no speech) to get the live headings before speaking or highlighting.`,f=s?` "${s}" is the PAGE TITLE, not a content section — do not fwh-highlight-mvp it separately; if doing a walkthrough, just fold this intro into your opening line: "${c||`(no intro text found)`}"`:c?` No separate page-title heading detected, but this intro text precedes the first section — mention it briefly before covering sections: "${c}"`:``,p=``;try{if(o.length>0){let e=o.slice(0,3),t=[];for(let n of e){let e=ur(null,n);if(e){let r=fg(e).substring(0,800);r&&t.push(`[Section: ${n}] ${r}`)}}t.length>0&&(p=` CONTENT FOR FIRST FEW SECTIONS: ${t.join(` | `)}. Use this content to answer immediately if the visitor asks about one of these sections.`)}}catch{}if(xr())return yr(),$(`fwh-navigate-mvp ✖ landed on a not-found/404 page:`,i),`NAVIGATION_PAGE_NOT_FOUND. The page at ${i} does not exist — it shows a "not found"/404 error, not real content. Do NOT offer a page overview, do NOT describe or highlight any sections, do NOT claim the navigation succeeded. Tell the visitor EXACTLY: "It looks like that page doesn't exist — I couldn't find it. Would you like me to take you somewhere else?" Then STOP and wait for their reply.`;let m=Date.now()+4e3,h=typeof window<`u`?window.location.pathname:r;for(;Date.now()<m&&!Xh(h,e)&&Xh(h,t);)await new Promise(e=>setTimeout(e,120)),h=window.location.pathname;$(`fwh-navigate-mvp route settle:`,{startPath:t,targetPath:e,settledPath:h});let g=typeof window<`u`?window.location.href:i,_=(h.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())||`Home`,v=Xh(h,e),y=!Xh(h,t),b=v||y;return $(`fwh-navigate-mvp settled:`,h,`target:`,e,`match:`,b),b?(yr(),`OK_NAVIGATE_SPA. Visitor is now on: ${g} (page: "${_}") | Section headings: ${u}.${f} ${d}${p} Now confirm the arrival in ONE short sentence phrased for what the visitor actually asked for — mention the page by name and what it lets them do (e.g. for a contact request: "I've taken you to the Contact Us page — filling in this form sends your query straight to our team."). Do NOT use a fixed template. Then, in the same breath, offer either a specific section or a full overview. Then STOP — wait for their reply.`):(yr(),`NAVIGATION_DID_NOT_HAPPEN. The visitor is STILL on ${g} (page: "${_}") — the navigation did not go through. Do NOT say "I have navigated you". Do NOT claim success. Tell the visitor EXACTLY: "Sorry, I couldn't open that page just now. Would you like me to try again, or is there something else I can help with?" Then STOP and wait for their reply.`)}catch{}let o=`this`;try{let e=new URL(a,window.location.href).pathname.split(`/`).filter(Boolean).pop()||``;o=e?e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()):`Home`}catch{}return`OK_NAVIGATE_RELOADING. Navigating to the page now; the voice session will resume automatically on the new page. When the session resumes, say EXACTLY: "I have navigated you on ${o} page. Do you want to know about any specific section or want a complete overview?" Then STOP — wait for the visitor's reply.`}catch(e){let t=`Navigation error: ${e?.message||String(e)}`;return $(`fwh-navigate-mvp ✖`,t),Mh(`Navigation failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{Rh(),Nh(900)}},"fwh-highlight-mvp":async e=>{$(`fwh-highlight-mvp ▶`,e);let t=cg(e),n=t?.section_id||t?.sectionId,r=t?.section_text||t?.sectionText;if(Bn(3e3),typeof window<`u`&&window.__fe_user_nav_during_speech){let e=window.__fe_user_nav_during_speech,t=window.location.pathname;if(Date.now()-e.ts>=3e4)window.__fe_user_nav_during_speech=null;else return $(`flowengage_highlight ✖ blocked — user navigated during speech`,e),`NAV_CHANGED: The visitor navigated from "${e.fromPageName}" to "${e.toPageName}" (current path: ${t}) while you were speaking. STOP the current walkthrough immediately. DO NOT call fwh-highlight-mvp again. Say out loud: "I see you've navigated to the ${e.toPageName} page — do you want me to continue what I was explaining, or shall I guide you through this page?" Wait for the visitor's answer before doing anything else.`}ug();let i=(e=>e&&e.replace(/^\d+\.\s*/,``).replace(/^["']|["']$/g,``).trim())(r),a=ur(n||null,i||null);if(!a&&i){let e=Date.now()+600;for(;!a&&Date.now()<e;)await new Promise(e=>setTimeout(e,50)),ug(),a=ur(null,i)}if(!a){$(`fwh-highlight-mvp ✖ no element for:`,i||n);let{headings:e}=dg(),t=e.length?`Page headings: ${e.map(e=>`"${e}"`).join(` | `)}. Use one of these EXACT strings for section_text — no numbers, no quotes around them.`:`No headings found — skip highlight and continue speaking.`;return`HIGHLIGHT_NOT_FOUND: "${i||n}" on the current page. ${t}`}return On(a),$(`fwh-highlight-mvp ✓`,i||n),`OK_HIGHLIGHT: "${i||n}". Your NEXT response must be speech only (no tool call) describing THIS section — "${i||n}" — using its own content. Do not ask whether to continue.`},"fwh-read-content-mvp":async e=>{$(`fwh-read-content-mvp ▶`,e);let t=cg(e),n=t?.section_text||t?.sectionText||``;try{let e=``;if(n){let t=ur(null,n);if(!t)return`Could not find section "${n}" on the page.`;e=fg(t)}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, #flowengage-root, .flowengage-shell, .flowengage-widget-root`).forEach(e=>e.remove()),e=t.textContent.replace(/\s+/g,` `).trim()}return e.length>8e3&&(e=e.substring(0,8e3)+`... (truncated)`),$(`fwh-read-content-mvp ✓`,`${e.length} chars`),e||`No readable content found on this page.`}catch(e){return $(`fwh-read-content-mvp ✖`,e.message),`Could not read page content: ${e.message}`}},"fwh-page-content-mvp":async e=>{$(`fwh-page-content-mvp ▶`,e);let r=cg(e),i=r?.url||r?.page_url||``;if($(`fwh-page-content-mvp · url:`,i,`siteId:`,t,`apiBase:`,n||`(empty)`),!i)return $(`fwh-page-content-mvp ✖ missing url`),`Missing url parameter.`;if(!t)return $(`fwh-page-content-mvp ✖ no siteId`),`Site is not configured.`;if(!n)return $(`fwh-page-content-mvp ✖ no api base`),`API base URL is missing; cannot fetch page content.`;try{let e=`${n}/api/site-tools/page-content`;$(`fwh-page-content-mvp → 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($(`fwh-page-content-mvp · HTTP`,r.status,`success:`,a.success),!a.success){let e=a.error||`Failed to get page content.`;return $(`fwh-page-content-mvp ✖`,e),`${e} FALLBACK REQUIRED: This page is not in the search index. Call fwh-read-content-mvp (no parameters) immediately to read the live page content directly from the visitor's browser — do NOT tell the visitor you cannot access the page.`}return $(`fwh-page-content-mvp ✓`,`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 $(`fwh-page-content-mvp ✖`,t),t}},"fwh-search-mvp":async e=>{$(`fwh-search-mvp ▶`,e);let r=cg(e).query;if(!r)return $(`fwh-search-mvp ✖ missing query`),`Missing query parameter.`;if(!t)return $(`fwh-search-mvp ✖ no siteId`),`Search unavailable (no siteId configured).`;if(!n)return $(`fwh-search-mvp ✖ no api base`),`Search unavailable (no API base URL).`;try{let e=`${n}/api/site-tools/search`;$(`fwh-search-mvp → 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($(`fwh-search-mvp · HTTP`,i.status,`success:`,a.success),!a.success||!a.results?.length)return`No results found for that query. Try rephrasing, or use fwh-read-content-mvp to read the current page.`;let o=a.results.slice(0,5).map((e,t)=>`${t+1}. ${e.title||e.url} (${e.url})${e.snippet?` — ${e.snippet}`:``}`).join(`
343
343
  `);return $(`fwh-search-mvp ✓`,`${a.results.length} result(s)`),`SEARCH_RESULTS:\n${o}`}catch(e){return $(`fwh-search-mvp ✖`,e.message),`Search failed. Use fwh-read-content-mvp to read the current page instead.`}},"fwh-list-nav-links-mvp":async()=>{if($(`fwh-list-nav-links-mvp ▶`),typeof window>`u`)return`Cannot read navigation (no browser context).`;let e=new Map,t=[],n=[`nav a`,`[role='navigation'] a`,`header a`,`.navbar a`,`.nav a`,`.menu a`,`.navigation a`,`.header a`,`[class*='nav'] a`,`[class*='menu'] a`,`[class*='header'] a`];if(Qh(t=>{for(let r of n)try{t.querySelectorAll(r).forEach(t=>{if(jn(t))return;let n=t.getAttribute(`href`),r=(t.textContent||``).replace(/\s+/g,` `).trim();if(!r||!n||n===`#`||n.startsWith(`javascript:`))return;try{let e=t.parentElement;if(e&&Zh(e).display===`none`&&!e.closest(`nav, [role='navigation'], header, [class*='nav'], [class*='menu']`))return}catch{}let i=r.toLowerCase()+`|`+n;e.has(i)||e.set(i,{text:r,href:n})})}catch{}t.querySelectorAll(`select`).forEach(t=>{if(jn(t))return;let n=eg(t);/nav|menu|page|section|go to/i.test(n||t.name||t.id||``)&&Array.from(t.options).forEach(r=>{if(!r.value||r.disabled)return;let i=r.text.trim();if(!i)return;let a=i.toLowerCase()+`|`+r.value;e.has(a)||e.set(a,{text:i,href:r.value,isSelectOption:!0,selectLabel:n||t.name||`dropdown`})})})}),e.forEach(e=>t.push(e)),!t.length)return`NAV_LINKS: No navigation links found on this page. Use fwh-read-content-mvp to read page content or fwh-search-mvp to search the site.`;let r=t.slice(0,50).map((e,t)=>`${t+1}. "${e.text}"${e.isSelectOption?` (dropdown option in "${e.selectLabel}")`:``} → ${e.href}`).join(`
344
344
  `);return $(`fwh-list-nav-links-mvp ✓`,`${t.length} links`),`NAV_LINKS (${t.length} total, showing up to 50):\n${r}\n\nIMPORTANT: Use the EXACT text shown above when reading link names to the visitor. Do NOT rename, abbreviate, or invent options not listed here. To navigate, call fwh-navigate-mvp with the href value.`},"fwh-end-session-mvp":async()=>($(`fwh-end-session-mvp ▶`),typeof e.requestEndSession==`function`&&e.requestEndSession(),`Voice session is ending.`),"fwh-request-email-mvp":async()=>($(`fwh-request-email-mvp ▶`),typeof e.requestEmailCollection==`function`&&e.requestEmailCollection(),`EMAIL_BOX_SHOWN. An email input text box is now visible to the visitor. Say EXACTLY: "Please enter your email in the text box to continue." Then stop and wait silently — do NOT ask them to say it aloud, do NOT repeat, and do NOT answer any other question until you receive the EMAIL_SAVED message.`),"fwh-get-current-page-mvp":async()=>{if($(`fwh-get-current-page-mvp ▶`),typeof window>`u`)return`Cannot determine current page (no browser context).`;let e=window.location.href,t=window.location.pathname,n=document.title||``;if(xr())return $(`fwh-get-current-page-mvp ✓ 404 detected`,{url:e}),`CURRENT_PAGE_NOT_FOUND. The visitor is currently on a 404 / page-not-found error page (${e}). There is no real content here. Do NOT describe this page, do NOT list sections, do NOT offer a walkthrough, and do NOT describe it from your own knowledge. Tell the visitor plainly that the page they are on doesn't exist, and offer to take them somewhere that does.`;let{headings:r,pageTitleHeading:i,introText:a}=dg();$(`fwh-get-current-page-mvp ✓`,{url:e,path:t,title:n}),$(`fwh-get-current-page-mvp → page headings collected:`,r,`titleHeading:`,i);let o=i?` NOTE: "${i}" is the PAGE TITLE, not a content section — do NOT fwh-highlight-mvp it or list it as a separate section in a walkthrough. Instead, open with a brief 1-2 sentence summary of this intro text before covering the real sections: "${a||`(no intro text captured)`}"`:a?` NOTE: no separate page-title heading was detected, but this intro text appears before the first section — open your walkthrough with a brief 1-2 sentence summary of it before covering sections: "${a}"`:``;if(!r.length)return`CURRENT_PAGE. URL: ${e} | Title: ${n} |${o} No structured section headings found on this page. If there is intro text above, describe it; otherwise describe the page from your knowledge. Do not call this tool again.`;let s=r.map(e=>`"${e}"`).join(` | `);return`CURRENT_PAGE. URL: ${e} | Title: ${n} | Page sections (${r.length} total): ${s}.${o} *** WALKTHROUGH: do NOT drive it yourself. Do not call fwh-highlight-mvp and do not decide the order — highlighting and section order are handled for you. You will be told which section to describe, one at a time. When told, describe ONLY that section in 3-4 sentences and then stop; never announce another section, never ask whether to continue. ***`},"fwh-list-forms-mvp":async()=>{let e=ng(),t=rg();$(`fwh-list-forms-mvp ✓`,`${e.length} field(s)`,`${t.length} button(s)`);let n=e.map(e=>({...e,inputCategory:e.tag===`SELECT`?`dropdown_select`:`text_input`}));return JSON.stringify({fields:n,buttons:t,hint:`field_key: use the label/placeholder/name shown above. CRITICAL: fields with inputCategory='dropdown_select' are SELECT elements — their field_key must match the SELECT's own label (e.g. 'Company Size'), NOT the option text (e.g. 'Small Business') and NOT a nearby text input label. Never fill a SELECT option value into a text input.`})},"fwh-fill-form-mvp":async()=>`FORM_FILLING_DISABLED: Form filling is not available at this time. Tell the visitor what fields are present (use fwh-list-forms-mvp) and ask them to fill the form themselves.`,"fwh-click-button-mvp":async e=>{let t=cg(e),n=(t.button_text??t.buttonText??t.text??``).trim(),r=(t.card_context??t.cardContext??``).trim();if($(`fwh-click-button-mvp ▶`,n,r?`(card_context: ${r})`:``),!n)return`Missing button_text: pass the visible label, e.g. Conduct Audit.`;let a=sg(n,i,r);if(!a)return $(`fwh-click-button-mvp ✖ no match`),`Could not find a button matching "${n}". Call fwh-list-forms-mvp to see button texts.`;try{Mh(`Clicking ${n}...`,{spinner:!0});try{a.scrollIntoView({block:`center`,inline:`nearest`})}catch{a.scrollIntoView(!0)}await Uh(a),a.focus?.(),await Gh(a),Kh(a),a.click();let e=(a.textContent||a.value||a.getAttribute(`aria-label`)||``).trim().slice(0,80)||`button`,t=`OK_CLICK ${e}`;return $(`fwh-click-button-mvp ✓`,t),Mh(`Clicked ${e}`,{spinner:!1,icon:`✅`,duration:1200}),t}catch(e){let t=`Click failed: ${e?.message||String(e)}`;return $(`fwh-click-button-mvp ✖`,t),Mh(`Click failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{Wh(),Nh(700)}}};return{...a,highlightOnPage:a[`fwh-highlight-mvp`],getPageContent:a[`fwh-page-content-mvp`],endVoiceSession:a[`fwh-end-session-mvp`],listPageForms:a[`fwh-list-forms-mvp`],fillFormFields:a[`fwh-fill-form-mvp`],clickPageButton:a[`fwh-click-button-mvp`]}}var mg=/^(get in touch|contact us|let'?s (talk|connect)|subscribe|newsletter|follow us|quick links|company|solutions|what we do|resources|legal|sitemap|share this)/i;function hg(){try{let{headings:e}=dg();return(e||[]).map(e=>typeof e==`string`?e:e?.text||``).filter(Boolean).filter(e=>!mg.test(e.trim()))}catch{return[]}}function gg(e){return!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,async n=>{let r=Tn();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 _g={blue:`#135bd8`,red:`#ef334b`,yellow:`#ffbd2e`,dark:`#0d1b2a`,highlight:`rgba(255,255,255,0.9)`,green:`#10b981`};function vg(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 yg(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 bg(e){let[t,n]=b.useState(null),r=typeof e==`string`?e.trim():``;return b.useEffect(()=>{if(!r){n(null);return}n(null);let e=!1,t=new window.Image;return t.onload=()=>{e||n(r)},t.onerror=()=>{e||n(null)},t.src=r,()=>{e=!0}},[r]),t}function xg({logo:e,style:t}){let n=bg(typeof e==`string`?e:null);if(!e)return null;if(typeof e==`string`)return n?(0,H.jsx)(`img`,{src:n,alt:``,style:{objectFit:`contain`,flexShrink:0,display:`block`,...t}}):null;let r=typeof e==`function`?b.createElement(e):b.isValidElement(e)?e:null;return r?(0,H.jsx)(`span`,{className:`fe-logo-slot`,style:{display:`inline-flex`,alignItems:`center`,flexShrink:0,overflow:`hidden`,...t},children:r}):null}function Sg({title:e}){return(0,H.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 Cg(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)||e===`bot`&&(/\b(that'?s all|we'?re done)\b/i.test(n)||/\b(goodbye|bye)\b/i.test(n)||/\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))):!1}function wg({orbColors:e,...t}){return(0,H.jsx)(vh,{colors:e,...t})}function Tg({copy:e,orbColors:t,primaryColor:n,onYes:r,onLater:i,isMobile:a,isClosing:o}){let s=n||_g.green,c=yg(s),l=a?72:94,u=(0,H.jsxs)(`div`,{style:{display:`flex`,alignItems:a?`flex-end`:`center`,gap:a?`7px`:`9px`},children:[(0,H.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,H.jsx)(dm.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:`14px`,fontWeight:700,color:`white`,lineHeight:1.4,textShadow:`0 1px 4px rgba(0,0,0,0.35)`,maxWidth:`210px`,wordBreak:`break-word`,overflow:`hidden`,display:`-webkit-box`,WebkitLineClamp:4,WebkitBoxOrient:`vertical`},children:e.entryPrompt}),(0,H.jsxs)(dm.div,{initial:{y:10,opacity:0},animate:{y:0,opacity:1},transition:{type:`spring`,stiffness:260,damping:24,delay:.54},style:{display:`flex`,gap:`16px`,flexWrap:`nowrap`},children:[(0,H.jsx)(`button`,{onClick:r,style:{height:`31px`,boxSizing:`border-box`,padding:`0 16px`,borderRadius:`999px`,background:s,color:c,fontWeight:400,fontSize:`14px`,border:`none`,cursor:`pointer`,whiteSpace:`nowrap`,boxShadow:`0 4px 16px ${s}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,H.jsx)(`button`,{onClick:i,style:{height:`31px`,boxSizing:`border-box`,padding:`0 16px`,borderRadius:`999px`,background:`transparent`,color:`white`,fontWeight:400,fontSize:`14px`,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,H.jsx)(dm.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,H.jsx)(wg,{size:l,orbColors:t})})]});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(dm.div,{initial:{opacity:0},animate:{opacity:o?0:1},transition:{duration:.28},style:{position:`fixed`,inset:0,background:`rgba(0,0,0,0.72)`,zIndex:-1}}),a?(0,H.jsx)(`div`,{style:{position:`absolute`,bottom:0,left:0,right:0,padding:`24px 20px 40px`,overflow:`hidden`,animation:o?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:``},children:u}):(0,H.jsx)(`div`,{style:{animation:o?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:``},children:u})]})}function Eg({copy:e,orbColors:t,primaryColor:n,onVoice:r,onText:i,onClose:a,isMobile:o,isClosing:s}){let c=n||_g.green,l=yg(c);return(0,H.jsxs)(dm.div,{initial:{scale:50/350,borderRadius:`50%`},animate:s?{scale:50/350,opacity:0,borderRadius:`50%`}:{scale:1,borderRadius:`16px`,opacity:1},transition:{type:`spring`,stiffness:260,damping:26},style:{transformOrigin:o?`bottom center`:`bottom right`,background:`white`,width:o?`100%`:`350px`,height:`245px`,padding:`24px 40px 32px`,boxSizing:`border-box`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`space-between`,boxShadow:`0 20px 60px rgba(0,0,0,0.2)`,position:`relative`,overflow:`hidden`},children:[(0,H.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,H.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,H.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}),(0,H.jsx)(wg,{size:72,orbColors:t}),(0,H.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,H.jsx)(`p`,{style:{margin:0,fontSize:`16px`,fontWeight:400,color:`#111827`,lineHeight:1.4},children:e.connectionTitle}),e.connectionSubtitle&&(0,H.jsx)(`p`,{style:{margin:`6px 0 0`,fontSize:`13px`,fontWeight:400,color:`#6b7280`,lineHeight:1.4},children:e.connectionSubtitle})]}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`16px`,width:`100%`},children:[(0,H.jsx)(`button`,{onClick:r,style:{width:`127px`,height:`43px`,borderRadius:`999px`,background:c,color:l,fontWeight:400,fontSize:`16px`,border:`none`,cursor:`pointer`,transition:`transform 0.15s ease`,boxShadow:`0 4px 12px ${c}55`},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.03)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`},children:e.voiceLabel}),(0,H.jsx)(`button`,{onClick:i,style:{width:`127px`,height:`43px`,borderRadius:`999px`,background:`transparent`,color:`#111827`,fontWeight:400,fontSize:`16px`,border:`1.5px 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 Dg({orbColors:e,onEnterChat:t,onEndChat:n,agentId:r,siteId:i,apiBaseUrl:a,chatId:o,historyRef:s,onMessageSync:c,voiceEndCounter:l,websiteName:u,voiceFirstMessage:d,captureVisitorEmail:f,emailRequired:p,emailCaptureEnabled:m=!0,listeningLabel:h=`Listening...`,thinkingLabel:g=`Thinking...`,enterChatModeLabel:_=`Enter Chat Mode`,endConversationLabel:v=`End Conversation`}){(0,b.useEffect)(()=>(console.log(`[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED`),()=>console.log(`[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED`)),[]);let[y,x]=(0,b.useState)(`idle`),[S,C]=(0,b.useState)(!1),[w,T]=(0,b.useState)(!1),[E,ee]=(0,b.useState)(!1),[te,D]=(0,b.useState)(``),[O,ne]=(0,b.useState)(``),re=(0,b.useRef)(!1),ie=(0,b.useRef)(!1),ae=(0,b.useRef)(null),oe=(0,b.useRef)(0),k=(0,b.useRef)(``),A=(0,b.useRef)(!1),se=(0,b.useRef)(0),ce=(0,b.useRef)(!1),le=(0,b.useRef)(!1),ue=(0,b.useRef)(!1),j=(0,b.useRef)([]),M=(0,b.useRef)(null),de=e=>{ce.current=e,e||(le.current=!1),N.current?.setWalkthroughActive?.(e)};M.current=async()=>{if(le.current)return;let e=j.current;fe.current+=1;let t=fe.current,n=e[t];if(!n){de(!1),e.length&&N.current?.sendUserMessage?.(`That was the last section. Say so in one short sentence and ask if they want to explore any section further.`);return}try{await toolsRef.current?.highlightOnPage?.({section_text:n})}catch{}console.debug(`[FlowEngage] walkthrough step ${t+1}/${e.length}: ${n}`),N.current?.sendUserMessage?.(`Describe the section titled "${n}" in 3-4 sentences, starting with ${t===0?`Starting with`:`Next —`} ${n}. Describe ONLY this section. If this section contains named sub-items (steps, checklist entries, cards, plans, FAQs, team members), name EVERY one of them in order with a short phrase each — never skip or collapse them into a summary; read the section's content silently first (fwh-read-content-mvp) if you don't already have it. Do not mention any other section, do not ask whether to continue, then stop.`,{suppressQuestion:!0})};let fe=(0,b.useRef)(0),N=(0,b.useRef)(null),pe=(0,b.useRef)(``),me=(0,b.useRef)(async()=>{}),he=(0,b.useRef)(!1),ge=(0,b.useRef)(!1),P=(0,b.useRef)(!1),_e=(0,b.useRef)(!1),ve=(0,b.useRef)(`minimized`),Se=(0,b.useRef)(null),we=(0,b.useRef)(null),Te=(0,b.useRef)(null),Ee=(0,b.useRef)(0),De=(0,b.useRef)(!1),F=(0,b.useRef)(`idle`),ke=(0,b.useRef)(null),je=(0,b.useRef)(!1),I=(0,b.useRef)(null),Me=(0,b.useCallback)((e=`minimized`)=>{console.warn(`[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called`,{destination:e,stack:Error().stack?.split(`
345
- `).slice(1,4).join(` | `)}),ve.current=e,_e.current=!0,queueMicrotask(()=>{he.current||(he.current=!0,me.current?.())})},[s]),Ne=(0,b.useCallback)(()=>{ae.current&&=(clearTimeout(ae.current),null)},[]);(0,b.useEffect)(()=>{if(p){re.current=!1;return}if(re.current=!0,ie.current=!1,ee(!1),Ne(),A.current){A.current=!1,N.current?.setMicMuted?.(!1);let e=k.current;k.current=``,N.current?.injectAgentSpeech?.(`Thanks — I already have your email on file.`,`interrupt`),e&&N.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`)}N.current?.sendContextualUpdate?.(`EMAIL REQUIREMENT SATISFIED — the visitor's email is already on file. All earlier instructions about requiring or asking for an email are VOID. Never ask for it again.`)},[p,Ne]);let Pe=/(walk\s*(me\s*)?through|walkthrough|take me through|(complete|full|detailed) (overview|understanding|walkthrough|picture|breakdown|explanation)|give me (a|an|the) (overview|tour|walk)|tell me about (each|all)|go through (it|them|each|all)|overview of|one by one|tell me everything|explain (me )?(this|the) (whole |entire |full )?page|everything (about|on) this page|show me (each|all|around))/i,Fe=/(that covers everything|that was all|covered everything|that(?:'|’)?s everything)/i,Ie=/^((uh+|um+|so|well|okay|ok|yeah)[,.\s]+)*(yes|yeah|yep|yup|sure|ok(ay)?|please|continue|go on|next|keep going|carry on|go ahead|resume|back to the tour)[\s.!,]*$/i,Le=(0,b.useCallback)(()=>{Ne(),ae.current=setTimeout(()=>{if(!(!ie.current||re.current))if(oe.current<3){oe.current+=1;try{N.current?.injectAgentSpeech?.(`I still need your email in the box below to continue — could you enter it, please?`,`queue`)}catch{}Le()}else{try{N.current?.injectAgentSpeech?.(`Since I haven't received your email, I'll close this session for now. Feel free to come back anytime — take care!`,`queue`)}catch{}ie.current=!1,ee(!1),Ne(),De.current=!0}},1e4)},[Ne]),Re=(0,b.useCallback)(async e=>{_e.current=!0;try{kn()}catch{}if(i)try{Ae(i)}catch{}try{await N.current?.endSession?.()}catch{}let t=Se.current,n=we.current;if(t&&o&&a){let e=n?Math.round((Date.now()-n)/1e3):0;fetch(`${a}/api/voice/save-chat-recording`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({chatId:o,voiceSessionId:t,duration:e,siteId:i})}).catch(e=>console.warn(`[FlowEngage] save-chat-recording failed:`,e.message))}if(Se.current=null,we.current=null,N.current=null,x(`idle`),C(!1),he.current=!1,Er(),i)try{xe(i)}catch{}typeof c==`function`&&await c(s.current),e?.()},[s,c,i,o,a]);me.current=()=>Re(ve.current===`chat`?t:n),(0,b.useEffect)(()=>{ge.current=S},[S]),(0,b.useEffect)(()=>{l&&Me(`chat`)},[l]),(0,b.useEffect)(()=>{let e=!1,l=null,f=null,h=null;return(async()=>{if(!i){x(`error`);return}try{if((await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),e)return;s.current=[],pe.current=``,he.current=!1,P.current=!1,_e.current=!1,ve.current=`minimized`,Tr({onBeforeNavigate:()=>{if(i&&s.current.length>0)try{let e=Dh(s.current);e&&ye(i,e)}catch{}if(!Yn()){let e=Se.current,t=we.current;if(e&&o&&a)try{let n=t?Math.round((Date.now()-t)/1e3):0,r=JSON.stringify({chatId:o,voiceSessionId:e,duration:n,siteId:i}),s=`${a}/api/voice/save-chat-recording`;fetch(s,{method:`POST`,headers:{"Content-Type":`application/json`},body:r,keepalive:!0}).catch(()=>{}),Se.current=null,we.current=null}catch{}}Ce()}});let t=gg(pg({siteId:i||null,apiBaseUrl:a||null,chatId:o||null,getLastUserVoiceText:()=>pe.current,requestEndSession:()=>{De.current=!0},requestEmailCollection:()=>{m&&(re.current||ie.current||(ie.current=!0,oe.current=0,ee(!0),Le()))}})),n=i?be(i):null,r=!!n?.transcript,c=i?Ae(i):null,g=!!c,_=typeof window<`u`?window.location.pathname:`/`,v=typeof document<`u`?document.title:``,y=_.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i,``)||`/`,b=y===`/`||y===``,S={apiBaseUrl:a,siteId:i,chatId:o,clientTools:t},w=(_.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),T=``;v&&v.includes(`|`)&&(T=v.split(`|`).map(e=>e.trim()).filter(Boolean).reduce((e,t)=>e.length<=t.length?e:t));let E=T||w||`this page`,te=(()=>{if(!c?.targetUrl)return!0;try{return new URL(c.targetUrl,window.location.href).pathname.replace(/\/$/,``)===window.location.pathname.replace(/\/$/,``)}catch{return!0}})(),D=(()=>{if(!c?.targetUrl)return null;try{return new URL(c.targetUrl,window.location.href).pathname}catch{return null}})();if(g&&!te)S.greeting=`You're on the ${E} page. What would you like to know?`,console.warn(`[FlowEngage] nav target "${c?.pageName}" not reached — on "${E}" instead; not claiming navigation`);else if(g){let e=c?.pageName||E;S.greeting=`I have navigated you on ${e} page. Do you want to know about any specific section or want a complete overview?`,console.log(`[FlowEngage] 🔄 Agent-nav resume: greeting set for "${e}" (${_})`)}else if(r)S.greeting=`Welcome back! I see you're now on the ${E} page. Would you like me to continue what I was explaining before, or would you like to know about this page instead?`;else{let e=u||``;S.greeting=d||(b?e?`Hi, welcome to ${e}! How may I help you?`:`Hi, welcome! How may I help you?`:`Welcome to the ${E} page!`),b||console.log(`[FlowEngage] 🏠 Page-context greeting: "${E}" for ${_}`)}let O=!1,ne=g?`NAVIGATION COMPLETE — The exact phrase "I have navigated you on [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript?`Prior transcript:\n${n.transcript}\n`:`(no prior transcript)`}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.`:null,ae=!1,me=!g&&!r?`Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead.`:null,xe=r&&!g,Te=!1,Re=xe?`The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript?`Prior transcript:\n${n.transcript}\n`:`(no prior transcript, or the visitor navigated before saying much)`}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.`:null,L=!1,ze=!1,Be=m&&!!p&&!ue.current,Ve=await Am.startSession({...S,onConnect:({conversationId:e})=>{Se.current=e,we.current=Date.now(),console.log(`[FlowEngage] 🎙️ AI chat session connected:`,e)},onUnhandledClientToolCall:e=>console.error(`[FlowEngage] Unhandled tool:`,e?.tool_name),onSessionInfo:({emailOnFile:e})=>{ue.current=!!e,e&&(re.current=!0,ie.current=!1,ee(!1),Ne(),console.log(`[FlowEngage] email already on file per server — gate disabled`))},onAgentTurnEnd:()=>{e||ce.current&&(le.current||A.current||setTimeout(()=>M.current?.(),250))},onSessionEnding:()=>{e||Me(`minimized`)},onModeChange:({mode:t,tentative:n})=>{if(!e){if(t===`speaking`){ke.current&&=(clearTimeout(ke.current),null),I.current&&=(clearTimeout(I.current),null),x(`speaking`),F.current=`speaking`,je.current=!1;return}if(t===`user-speaking`){if(I.current&&=(clearTimeout(I.current),null),F.current===`speaking`)return;ke.current&&=(clearTimeout(ke.current),null),F.current!==`listening`&&(x(`listening`),F.current=`listening`);return}if(t===`thinking`){if(ke.current&&=(clearTimeout(ke.current),null),I.current&&=(clearTimeout(I.current),null),F.current===`speaking`)return;x(`thinking`),F.current=`thinking`,n&&(I.current=setTimeout(()=>{I.current=null,!(e||F.current!==`thinking`)&&(F.current=`listening`,x(`listening`))},4e3));return}if(F.current=`listening`,De.current){De.current=!1,Me();return}if(Be&&!ze&&!re.current&&!ue.current){ze=!0,O=!0,ae=!0;try{N.current?.sendContextualUpdate?.(`CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. Do NOT speak right now. Wait silently for the visitor to speak first. The MOMENT the visitor says ANYTHING — a question, a request, or just a greeting — your ENTIRE next response must be EXACTLY this one sentence: "Before I answer that, could you please enter your email in the text box below?" Do NOT answer their question. Do NOT say anything about the topic. Do NOT begin an answer and then switch — your first word must be "Before". After you say that sentence, stay completely silent until you receive an EMAIL_SAVED message, then thank them briefly and answer their question in full.`)}catch{}}if(ne&&!O){O=!0;try{N.current?.sendContextualUpdate?.(ne)}catch{}}if(Re&&!Te){Te=!0;try{N.current?.sendContextualUpdate?.(Re)}catch{}}if(me&&!ae){ae=!0;try{N.current?.sendContextualUpdate?.(me)}catch{}}ke.current&&clearTimeout(ke.current),ke.current=setTimeout(()=>{e||F.current!==`speaking`&&(je.current||(ke.current=null,F.current=`listening`,x(`listening`)))},1200)}},onMessage:t=>{if(e||A.current&&t.role!==`user`&&!/email/i.test(String(t.message||``)))return;if(t.role===`user`&&Pe.test(String(t.message||``)))typeof window<`u`&&(window.__fe_user_nav_during_speech=null),de(!0),le.current=!1,se.current=0,fe.current=-1,j.current=hg(),setTimeout(()=>M.current?.(),400),console.log(`[FlowEngage] walkthrough armed — ${j.current.length} sections on this page`);else if(t.role===`user`&&ce.current){let e=String(t.message||``).trim();Ie.test(e)?le.current&&(le.current=!1,console.debug(`[FlowEngage] walkthrough resumed by visitor`),setTimeout(()=>M.current?.(),300)):(le.current=!0,console.debug(`[FlowEngage] walkthrough paused — visitor interjected`))}if(t.role!==`user`&&Fe.test(String(t.message||``))){let e=j.current.length;!e||fe.current>=e-1?de(!1):console.debug(`[FlowEngage] agent claimed completion at step ${fe.current+1}/${e} — ignoring, tour continues`)}let n=t.role===`user`?`user`:`bot`,r=t.message||t.text||t.content||``;if(r){if(n===`user`){pe.current=r,typeof window<`u`&&(window.__fe_user_nav_during_speech=null),je.current=!0,ke.current&&=(clearTimeout(ke.current),null),F.current!==`speaking`&&(x(`thinking`),F.current=`thinking`);try{kn()}catch{}Be&&!L&&!re.current&&!ue.current&&(L=!0,k.current=r,A.current=!0,N.current?.injectAgentSpeech?.(`Before I answer that, could you please enter your email in the text box below?`,`interrupt`),N.current?.setMicMuted?.(!0),ie.current||(ie.current=!0,oe.current=0,ee(!0),Le()))}if(s.current=[...s.current,{sender:n,message:r,timestamp:new Date().toISOString(),debug:t.debug}],i)try{let e=Dh(s.current);e&&ye(i,e)}catch{}if(Cg(n,r)){De.current=!0;return}if(ge.current&&n===`bot`&&/are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r))if(Ee.current+=1,Ee.current===2)try{N.current?.sendContextualUpdate?.(`IMPORTANT: The visitor is muted and has not responded to your last 2 checks. Make exactly ONE more check. If there is still no response, say: 'I feel like you are not active, so I'm ending this session. You can connect with me anytime.' then immediately call the fwh-end-session-mvp tool to end the voice session. Do NOT ask again after that.`)}catch{}else Ee.current>=5&&Me(`minimized`)}},onError:t=>{if(!e&&!_e.current&&!P.current&&!Oe()){P.current=!0,console.error(`[FlowEngageVoiceCall] session:error`,{message:t?.message,name:t?.name,raw:t});try{N.current?.setMicMuted?.(!0)}catch{}C(!0),x(`error`),Me(`chat`)}},onDisconnect:t=>{if(e||_e.current||P.current||Oe())return;let n=s.current?.length||0;console.warn(`[FlowEngageVoiceCall] session:disconnected`,{historyCount:n,reason:t?.reason,closeCode:t?.context?.code,closeReason:t?.context?.reason||t?.message,lastUserText:pe.current||``,wasMuted:ge.current}),P.current=!0;try{N.current?.setMicMuted?.(!0)}catch{}C(!0),Me(`chat`)}});if(e){console.warn(`[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately`),Ve.endSession().catch(()=>{});return}l=Ve,N.current=Ve,x(`listening`);try{let e=typeof window<`u`?window.location.href:``,a=`[]`;try{a=await t[`fwh-list-forms-mvp`]()}catch{}let o=`none`;if(typeof window<`u`&&typeof document<`u`)try{let e=`#flowengage-root, .flowengage-shell, .flowengage-widget-root`,t=document.querySelector(`main, [role='main']`)||document.body,n=Array.from(t.querySelectorAll(`h1, h2, h3`)).filter(t=>!t.closest(e)).map(e=>e.textContent.replace(/\s+/g,` `).trim()).filter(e=>e.length>2&&e.length<200);n.length||(n=Array.from(document.body.querySelectorAll(`h1, h2, h3`)).filter(t=>!t.closest(e)).map(e=>e.textContent.replace(/\s+/g,` `).trim()).filter(e=>e.length>2&&e.length<200)),n.length&&(o=[...new Set(n)].slice(0,15).join(` | `))}catch{}let s=r&&!g?`RESUMING PRIOR SESSION — DO NOT GREET. The visitor is continuing the same conversation after a page reload. Do not introduce yourself or re-state your capabilities. Wait silently until the visitor speaks; if you must speak first, briefly acknowledge where you left off in one short sentence.\nPrior transcript:\n${n?.transcript||``}\n\n`:``;Ve.sendContextualUpdate(`${s}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${o}. SiteId: ${i||`unknown`}. Forms: ${a}. ${p?``:`Visitor's email is already on file from a prior session — do NOT ask for it again. `}The visitor is ALREADY on this page — do NOT offer to navigate there. WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. The approximate headings above are for routing awareness ONLY — they are NOT precise enough for fwh-highlight-mvp. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`)}catch{}if(typeof window<`u`){let t=window.location.pathname,n=Date.now(),r=e=>{try{return(decodeURIComponent(e||`/`).replace(/\/+$/,``)||`/`).toLowerCase()}catch{return((e||`/`).replace(/\/+$/,``)||`/`).toLowerCase()}},i=()=>{if(e)return;let i=window.location.pathname;if(r(i)===r(t)){t=i;return}if(D&&r(i)===r(D)){t=i;return}if(Date.now()-n<8e3){t=i;return}if(Vn()){t=i;return}let a=t;t=i;let o=window.location.href,s=typeof document<`u`?document.title:``,c=typeof document<`u`?Array.from(document.querySelectorAll(`h1, h2, h3, h4`)).filter(e=>!e.closest(`#flowengage-root, .flowengage-shell`)).map(e=>({tag:e.tagName,text:e.textContent.trim()})).filter(e=>e.text.length>0&&e.text.length<200).slice(0,20):[];try{kn()}catch{}let l=e=>(e.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())||`Home`,u=l(a),d=l(i);typeof window<`u`&&(window.__fe_user_nav_during_speech={fromPath:a,toPath:i,fromPageName:u,toPageName:d,ts:Date.now()}),console.log(`[FlowEngage] visitor navigation detected: "${a}" → "${i}" (agent target: ${D||`none`})`);try{N.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${d}" page (${o}). Page title: "${s}". Sections: ${JSON.stringify(c)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${d} page — would you like me to continue what I was explaining, or shall I walk you through this page?" Then wait for my answer. IF I say continue/yes/carry on: resume speaking verbally from where you left off — do NOT call fwh-navigate-mvp, do NOT call fwh-highlight-mvp, the visitor will navigate themselves if needed. IF I want to hear about this page: call fwh-highlight-mvp for sections of "${d}" only.]`)}catch{}};f=window.history.pushState.bind(window.history),window.history.pushState=(...e)=>{f(...e),setTimeout(i,50)},h=()=>setTimeout(i,50),window.addEventListener(`popstate`,h)}}catch(r){e||(console.error(`[FlowEngage] startSession failed`,r),r.message&&r.message.includes(`Too many voice sessions`)?(alert(r.message),n&&n(`minimized`)):(x(`error`),ve.current=`chat`,window.setTimeout(()=>{e||t?.()},0)))}})(),()=>{console.warn(`[FlowEngage:VoiceDebug] ⚠️ useEffect CLEANUP fired — session will be killed`,{agentId:r,siteId:i,apiBaseUrl:a}),e=!0,_e.current=!0;try{kn()}catch{}if(i)try{Ae(i)}catch{}typeof window<`u`&&(window.__fe_user_nav_during_speech=null),Er(),ke.current&&=(clearTimeout(ke.current),null),I.current&&=(clearTimeout(I.current),null),ae.current&&=(clearTimeout(ae.current),null),je.current=!1,F.current=`idle`,f&&typeof window<`u`&&(window.history.pushState=f),h&&typeof window<`u`&&window.removeEventListener(`popstate`,h);let t=l||N.current,n=Se.current,u=we.current;if(t?.endSession?.().catch(()=>{}),n&&o&&a){let e=u?Math.round((Date.now()-u)/1e3):0,t=JSON.stringify({chatId:o,voiceSessionId:n,duration:e,siteId:i}),r=`${a}/api/voice/save-chat-recording`;typeof navigator<`u`&&navigator.sendBeacon&&navigator.sendBeacon(r,new Blob([t],{type:`application/json`}))||fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`},body:t,keepalive:!0}).catch(()=>{}),Se.current=null,we.current=null}typeof c==`function`&&s.current.length>0&&c(s.current).catch?.(()=>{})}},[r,i,a,Me]),(0,b.useEffect)(()=>{if(!w)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;Te.current&&!Te.current.contains(t)&&T(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[w]);let L=async()=>{if(N.current)try{if(S){Ee.current=0,await N.current.setMicMuted?.(!1),C(!1);try{N.current.sendContextualUpdate?.(`The visitor has unmuted. Resume normal interaction and wait for them to speak.`)}catch{}}else{Ee.current=0,await N.current.setMicMuted?.(!0),C(!0);try{N.current.sendContextualUpdate?.(`The visitor has muted their microphone. Do NOT speak, ask if they are there, or prompt them in any way. Stay completely silent until they unmute.`)}catch{}}}catch{}},ze=(0,b.useCallback)(async e=>{e?.preventDefault?.();let t=te.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)){ne(`Please enter a valid email address.`);return}ne(``),re.current=!0,ie.current=!1,Ne(),ee(!1),D(``),A.current=!1;try{typeof f==`function`&&await f(t)}catch{}N.current?.setMicMuted?.(!1);let n=k.current;k.current=``;try{N.current?.injectAgentSpeech?.(`Thank you for submitting your email.`),N.current?.sendUserMessage?.(n||`The visitor's email is on file. Carry on helping them and never ask for it again.`)}catch{}},[te,f,Ne]),Be=Array.isArray(e)&&e[0]||`#3B82F6`;return(0,H.jsxs)(`div`,{ref:Te,style:{position:`relative`,display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`14px`,animation:`fe-orb-slide-up 0.42s cubic-bezier(0.16,1,0.3,1)`},children:[E&&(0,H.jsxs)(`form`,{onSubmit:ze,style:{width:`270px`,maxWidth:`calc(100vw - 40px)`,boxSizing:`border-box`,background:`rgba(15,22,36,0.97)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,padding:`16px`,display:`flex`,flexDirection:`column`,gap:`10px`,animation:`fe-orb-fade-in 0.18s ease`},children:[(0,H.jsx)(`span`,{style:{color:`white`,fontSize:`13px`,fontWeight:600,lineHeight:1.4},children:`Please enter your email to continue`}),(0,H.jsx)(`input`,{type:`email`,inputMode:`email`,autoComplete:`email`,autoFocus:!0,value:te,onChange:e=>{D(e.target.value),O&&ne(``)},placeholder:`you@example.com`,style:{width:`100%`,boxSizing:`border-box`,padding:`10px 12px`,borderRadius:`10px`,border:O?`1.5px solid #ef4444`:`1.5px solid #4b5563`,background:`#1f2937`,color:`white`,fontSize:`14px`,outline:`none`}}),O&&(0,H.jsx)(`span`,{style:{color:`#f87171`,fontSize:`12px`},children:O}),(0,H.jsx)(`button`,{type:`submit`,disabled:!te.trim(),style:{width:`100%`,padding:`10px 12px`,borderRadius:`10px`,border:`none`,background:te.trim()?Be:`#374151`,color:`white`,fontSize:`14px`,fontWeight:600,cursor:te.trim()?`pointer`:`default`,transition:`background 0.2s ease`},children:`Submit`})]}),(0,H.jsxs)(`div`,{style:{position:`relative`},children:[(y===`listening`||y===`thinking`)&&!S&&(0,H.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:y===`thinking`?g:h}),S&&(0,H.jsx)(`span`,{style:{position:`absolute`,right:`100%`,marginRight:`18px`,top:`50%`,transform:`translateY(-50%)`,color:`#f87171`,fontSize:`16px`,fontWeight:600,letterSpacing:`0.01em`,textShadow:`0 2px 4px rgba(0,0,0,0.4)`,whiteSpace:`nowrap`},children:`Muted`}),(0,H.jsx)(wg,{size:72,voiceState:y,isMuted:S,orbColors:e})]}),y===`error`&&(0,H.jsx)(`span`,{style:{color:`#f87171`,fontSize:`13px`,fontWeight:500},children:`Could not start voice session.`}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,alignItems:`center`},children:[(0,H.jsx)(`button`,{onClick:L,title:S?`Unmute`:`Mute`,style:{width:`24px`,height:`24px`,borderRadius:`50%`,background:S?`#7f1d1d`:`#1f2937`,border:S?`1.5px solid #ef4444`:`1.5px solid #4b5563`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:S?`#f87171`:`white`,transition:`all 0.2s ease`,boxShadow:`0 2px 8px rgba(0,0,0,0.4)`,padding:0,flexShrink:0},children:S?(0,H.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`line`,{x1:`1`,y1:`1`,x2:`23`,y2:`23`}),(0,H.jsx)(`path`,{d:`M9 9v3a3 3 0 005.12 2.12M15 9.34V4a3 3 0 00-5.94-.6`}),(0,H.jsx)(`path`,{d:`M17 16.95A7 7 0 015 12v-2m14 0v2a7 7 0 01-.11 1.23`}),(0,H.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`23`}),(0,H.jsx)(`line`,{x1:`8`,y1:`23`,x2:`16`,y2:`23`})]}):(0,H.jsx)(jm,{size:16,color:`currentColor`})}),(0,H.jsx)(`button`,{onClick:()=>T(e=>!e),style:{width:`24px`,height:`24px`,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)`,padding:0,flexShrink:0},children:(0,H.jsx)(zm,{size:16,color:`currentColor`})})]}),w&&(0,H.jsxs)(`div`,{style:{position:`absolute`,bottom:0,right:0,width:`230px`,zIndex:9999,background:`rgba(15,22,36,0.96)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,animation:`fe-orb-fade-in 0.18s ease`,padding:`12px 12px 40px`},children:[(0,H.jsxs)(`button`,{onClick:()=>{T(!1),ve.current=`chat`,Re(t)},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`12px 16px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`,borderRadius:`8px`,whiteSpace:`nowrap`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,H.jsx)(Bm,{}),_]}),(0,H.jsxs)(`button`,{onClick:()=>{T(!1),ve.current=`minimized`,Re(n)},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`12px 16px`,background:`none`,border:`none`,color:`#E30C12`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`,borderRadius:`8px`,whiteSpace:`nowrap`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(227,12,18,0.1)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,H.jsx)(Vm,{}),v]}),(0,H.jsx)(`button`,{onClick:()=>T(!1),style:{position:`absolute`,bottom:`8px`,right:`8px`,width:`24px`,height:`24px`,borderRadius:`50%`,background:`rgba(255,255,255,0.15)`,border:`none`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:`white`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.25)`},onMouseLeave:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.15)`},children:(0,H.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,H.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})]})}function Og({orbColors:e}){let t=Array.isArray(e)&&e.length>0?e:[`#135bd8`,`#ef334b`,`#ffbd2e`],n=t[0],r=t[1]||t[0],i=t[2]||t[0];return(0,H.jsx)(`div`,{style:{width:`32px`,height:`32px`,borderRadius:`50%`,flexShrink:0,background:`
345
+ `).slice(1,4).join(` | `)}),ve.current=e,_e.current=!0,queueMicrotask(()=>{he.current||(he.current=!0,me.current?.())})},[s]),Ne=(0,b.useCallback)(()=>{ae.current&&=(clearTimeout(ae.current),null)},[]);(0,b.useEffect)(()=>{if(p){re.current=!1;return}if(re.current=!0,ie.current=!1,ee(!1),Ne(),A.current){A.current=!1,N.current?.setMicMuted?.(!1);let e=k.current;k.current=``,N.current?.injectAgentSpeech?.(`Thanks — I already have your email on file.`,`interrupt`),e&&N.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`)}N.current?.sendContextualUpdate?.(`EMAIL REQUIREMENT SATISFIED — the visitor's email is already on file. All earlier instructions about requiring or asking for an email are VOID. Never ask for it again.`)},[p,Ne]);let Pe=/(walk\s*(me\s*)?through|walkthrough|take me through|(complete|full|detailed) (overview|understanding|walkthrough|picture|breakdown|explanation)|give me (a|an|the) (overview|tour|walk)|tell me about (each|all)|go through (it|them|each|all)|overview of|one by one|tell me everything|explain (me )?(this|the) (whole |entire |full )?page|everything (about|on) this page|show me (each|all|around))/i,Fe=/(that covers everything|that was all|covered everything|that(?:'|’)?s everything)/i,Ie=/^((uh+|um+|so|well|okay|ok|yeah)[,.\s]+)*(yes|yeah|yep|yup|sure|ok(ay)?|please|continue|go on|next|keep going|carry on|go ahead|resume|back to the tour)[\s.!,]*$/i,Le=(0,b.useCallback)(()=>{Ne(),ae.current=setTimeout(()=>{if(!(!ie.current||re.current))if(oe.current<3){oe.current+=1;try{N.current?.injectAgentSpeech?.(`I still need your email in the box below to continue — could you enter it, please?`,`queue`)}catch{}Le()}else{try{N.current?.injectAgentSpeech?.(`Since I haven't received your email, I'll close this session for now. Feel free to come back anytime — take care!`,`queue`)}catch{}ie.current=!1,ee(!1),Ne(),De.current=!0}},1e4)},[Ne]),Re=(0,b.useCallback)(async e=>{_e.current=!0;try{kn()}catch{}if(i)try{Ae(i)}catch{}try{await N.current?.endSession?.()}catch{}let t=Se.current,n=we.current;if(t&&o&&a){let e=n?Math.round((Date.now()-n)/1e3):0;fetch(`${a}/api/voice/save-chat-recording`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({chatId:o,voiceSessionId:t,duration:e,siteId:i})}).catch(e=>console.warn(`[FlowEngage] save-chat-recording failed:`,e.message))}if(Se.current=null,we.current=null,N.current=null,x(`idle`),C(!1),he.current=!1,Er(),i)try{xe(i)}catch{}typeof c==`function`&&await c(s.current),e?.()},[s,c,i,o,a]);me.current=()=>Re(ve.current===`chat`?t:n),(0,b.useEffect)(()=>{ge.current=S},[S]),(0,b.useEffect)(()=>{l&&Me(`chat`)},[l]),(0,b.useEffect)(()=>{let e=!1,l=null,f=null,h=null;return(async()=>{if(!i){x(`error`);return}try{if((await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),e)return;s.current=[],pe.current=``,he.current=!1,P.current=!1,_e.current=!1,ve.current=`minimized`,Tr({onBeforeNavigate:()=>{if(i&&s.current.length>0)try{let e=Dh(s.current);e&&ye(i,e)}catch{}if(!Yn()){let e=Se.current,t=we.current;if(e&&o&&a)try{let n=t?Math.round((Date.now()-t)/1e3):0,r=JSON.stringify({chatId:o,voiceSessionId:e,duration:n,siteId:i}),s=`${a}/api/voice/save-chat-recording`;fetch(s,{method:`POST`,headers:{"Content-Type":`application/json`},body:r,keepalive:!0}).catch(()=>{}),Se.current=null,we.current=null}catch{}}Ce()}});let t=gg(pg({siteId:i||null,apiBaseUrl:a||null,chatId:o||null,getLastUserVoiceText:()=>pe.current,requestEndSession:()=>{De.current=!0},requestEmailCollection:()=>{m&&(re.current||ie.current||(ie.current=!0,oe.current=0,ee(!0),Le()))}})),n=i?be(i):null,r=!!n?.transcript,c=i?Ae(i):null,g=!!c,_=typeof window<`u`?window.location.pathname:`/`,v=typeof document<`u`?document.title:``,y=_.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i,``)||`/`,b=y===`/`||y===``,S={apiBaseUrl:a,siteId:i,chatId:o,clientTools:t},w=(_.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),T=``;v&&v.includes(`|`)&&(T=v.split(`|`).map(e=>e.trim()).filter(Boolean).reduce((e,t)=>e.length<=t.length?e:t));let E=T||w||`this page`,te=(()=>{if(!c?.targetUrl)return!0;try{return new URL(c.targetUrl,window.location.href).pathname.replace(/\/$/,``)===window.location.pathname.replace(/\/$/,``)}catch{return!0}})(),D=(()=>{if(!c?.targetUrl)return null;try{return new URL(c.targetUrl,window.location.href).pathname}catch{return null}})();if(g&&!te)S.greeting=`You're on the ${E} page. What would you like to know?`,console.warn(`[FlowEngage] nav target "${c?.pageName}" not reached — on "${E}" instead; not claiming navigation`);else if(g){let e=c?.pageName||E;S.greeting=`I have navigated you on ${e} page. Do you want to know about any specific section or want a complete overview?`,console.log(`[FlowEngage] 🔄 Agent-nav resume: greeting set for "${e}" (${_})`)}else if(r)S.greeting=`Welcome back! I see you're now on the ${E} page. Would you like me to continue what I was explaining before, or would you like to know about this page instead?`;else{let e=u||``;S.greeting=d||(b?e?`Hi, welcome to ${e}! How may I help you?`:`Hi, welcome! How may I help you?`:`Welcome to the ${E} page!`),b||console.log(`[FlowEngage] 🏠 Page-context greeting: "${E}" for ${_}`)}let O=!1,ne=g?`NAVIGATION COMPLETE — The exact phrase "I have navigated you on [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript?`Prior transcript:\n${n.transcript}\n`:`(no prior transcript)`}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.`:null,ae=!1,me=!g&&!r?`Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead.`:null,xe=r&&!g,Te=!1,Re=xe?`The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript?`Prior transcript:\n${n.transcript}\n`:`(no prior transcript, or the visitor navigated before saying much)`}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.`:null,L=!1,ze=!1,Be=m&&!!p&&!ue.current,Ve=await Am.startSession({...S,onConnect:({conversationId:e})=>{Se.current=e,we.current=Date.now(),console.log(`[FlowEngage] 🎙️ AI chat session connected:`,e)},onUnhandledClientToolCall:e=>console.error(`[FlowEngage] Unhandled tool:`,e?.tool_name),onSessionInfo:({emailOnFile:e})=>{ue.current=!!e,e&&(re.current=!0,ie.current=!1,ee(!1),Ne(),console.log(`[FlowEngage] email already on file per server — gate disabled`))},onAgentTurnEnd:()=>{e||ce.current&&(le.current||A.current||setTimeout(()=>M.current?.(),250))},onSessionEnding:()=>{e||Me(`minimized`)},onModeChange:({mode:t,tentative:n})=>{if(!e){if(t===`speaking`){ke.current&&=(clearTimeout(ke.current),null),I.current&&=(clearTimeout(I.current),null),x(`speaking`),F.current=`speaking`,je.current=!1;return}if(t===`user-speaking`){try{kn()}catch{}if(I.current&&=(clearTimeout(I.current),null),F.current===`speaking`)return;ke.current&&=(clearTimeout(ke.current),null),F.current!==`listening`&&(x(`listening`),F.current=`listening`);return}if(t===`thinking`){if(ke.current&&=(clearTimeout(ke.current),null),I.current&&=(clearTimeout(I.current),null),F.current===`speaking`)return;x(`thinking`),F.current=`thinking`,n&&(I.current=setTimeout(()=>{I.current=null,!(e||F.current!==`thinking`)&&(F.current=`listening`,x(`listening`))},4e3));return}if(F.current=`listening`,De.current){De.current=!1,Me();return}if(Be&&!ze&&!re.current&&!ue.current){ze=!0,O=!0,ae=!0;try{N.current?.sendContextualUpdate?.(`CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. Do NOT speak right now. Wait silently for the visitor to speak first. The MOMENT the visitor says ANYTHING — a question, a request, or just a greeting — your ENTIRE next response must be EXACTLY this one sentence: "Before I answer that, could you please enter your email in the text box below?" Do NOT answer their question. Do NOT say anything about the topic. Do NOT begin an answer and then switch — your first word must be "Before". After you say that sentence, stay completely silent until you receive an EMAIL_SAVED message, then thank them briefly and answer their question in full.`)}catch{}}if(ne&&!O){O=!0;try{N.current?.sendContextualUpdate?.(ne)}catch{}}if(Re&&!Te){Te=!0;try{N.current?.sendContextualUpdate?.(Re)}catch{}}if(me&&!ae){ae=!0;try{N.current?.sendContextualUpdate?.(me)}catch{}}ke.current&&clearTimeout(ke.current),ke.current=setTimeout(()=>{e||F.current!==`speaking`&&(je.current||(ke.current=null,F.current=`listening`,x(`listening`)))},1200)}},onMessage:t=>{if(e||A.current&&t.role!==`user`&&!/email/i.test(String(t.message||``)))return;if(t.role===`user`&&Pe.test(String(t.message||``)))typeof window<`u`&&(window.__fe_user_nav_during_speech=null),de(!0),le.current=!1,se.current=0,fe.current=-1,j.current=hg(),setTimeout(()=>M.current?.(),400),console.log(`[FlowEngage] walkthrough armed — ${j.current.length} sections on this page`);else if(t.role===`user`&&ce.current){let e=String(t.message||``).trim();Ie.test(e)?le.current&&(le.current=!1,console.debug(`[FlowEngage] walkthrough resumed by visitor`),setTimeout(()=>M.current?.(),300)):(le.current=!0,console.debug(`[FlowEngage] walkthrough paused — visitor interjected`))}if(t.role!==`user`&&Fe.test(String(t.message||``))){let e=j.current.length;!e||fe.current>=e-1?de(!1):console.debug(`[FlowEngage] agent claimed completion at step ${fe.current+1}/${e} — ignoring, tour continues`)}let n=t.role===`user`?`user`:`bot`,r=t.message||t.text||t.content||``;if(r){if(n===`user`&&(pe.current=r,typeof window<`u`&&(window.__fe_user_nav_during_speech=null),je.current=!0,ke.current&&=(clearTimeout(ke.current),null),F.current!==`speaking`&&(x(`thinking`),F.current=`thinking`),Be&&!L&&!re.current&&!ue.current&&(L=!0,k.current=r,A.current=!0,N.current?.injectAgentSpeech?.(`Before I answer that, could you please enter your email in the text box below?`,`interrupt`),N.current?.setMicMuted?.(!0),ie.current||(ie.current=!0,oe.current=0,ee(!0),Le()))),s.current=[...s.current,{sender:n,message:r,timestamp:new Date().toISOString(),debug:t.debug}],i)try{let e=Dh(s.current);e&&ye(i,e)}catch{}if(Cg(n,r)){De.current=!0;return}if(ge.current&&n===`bot`&&/are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r))if(Ee.current+=1,Ee.current===2)try{N.current?.sendContextualUpdate?.(`IMPORTANT: The visitor is muted and has not responded to your last 2 checks. Make exactly ONE more check. If there is still no response, say: 'I feel like you are not active, so I'm ending this session. You can connect with me anytime.' then immediately call the fwh-end-session-mvp tool to end the voice session. Do NOT ask again after that.`)}catch{}else Ee.current>=5&&Me(`minimized`)}},onError:t=>{if(!e&&!_e.current&&!P.current&&!Oe()){P.current=!0,console.error(`[FlowEngageVoiceCall] session:error`,{message:t?.message,name:t?.name,raw:t});try{N.current?.setMicMuted?.(!0)}catch{}C(!0),x(`error`),Me(`chat`)}},onDisconnect:t=>{if(e||_e.current||P.current||Oe())return;let n=s.current?.length||0;console.warn(`[FlowEngageVoiceCall] session:disconnected`,{historyCount:n,reason:t?.reason,closeCode:t?.context?.code,closeReason:t?.context?.reason||t?.message,lastUserText:pe.current||``,wasMuted:ge.current}),P.current=!0;try{N.current?.setMicMuted?.(!0)}catch{}C(!0),Me(`chat`)}});if(e){console.warn(`[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately`),Ve.endSession().catch(()=>{});return}l=Ve,N.current=Ve,x(`listening`);try{let e=typeof window<`u`?window.location.href:``,a=`[]`;try{a=await t[`fwh-list-forms-mvp`]()}catch{}let o=`none`;if(typeof window<`u`&&typeof document<`u`)try{let e=`#flowengage-root, .flowengage-shell, .flowengage-widget-root`,t=document.querySelector(`main, [role='main']`)||document.body,n=Array.from(t.querySelectorAll(`h1, h2, h3`)).filter(t=>!t.closest(e)).map(e=>e.textContent.replace(/\s+/g,` `).trim()).filter(e=>e.length>2&&e.length<200);n.length||(n=Array.from(document.body.querySelectorAll(`h1, h2, h3`)).filter(t=>!t.closest(e)).map(e=>e.textContent.replace(/\s+/g,` `).trim()).filter(e=>e.length>2&&e.length<200)),n.length&&(o=[...new Set(n)].slice(0,15).join(` | `))}catch{}let s=r&&!g?`RESUMING PRIOR SESSION — DO NOT GREET. The visitor is continuing the same conversation after a page reload. Do not introduce yourself or re-state your capabilities. Wait silently until the visitor speaks; if you must speak first, briefly acknowledge where you left off in one short sentence.\nPrior transcript:\n${n?.transcript||``}\n\n`:``;Ve.sendContextualUpdate(`${s}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${o}. SiteId: ${i||`unknown`}. Forms: ${a}. ${p?``:`Visitor's email is already on file from a prior session — do NOT ask for it again. `}The visitor is ALREADY on this page — do NOT offer to navigate there. WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. The approximate headings above are for routing awareness ONLY — they are NOT precise enough for fwh-highlight-mvp. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`)}catch{}if(typeof window<`u`){let t=window.location.pathname,n=Date.now(),r=e=>{try{return(decodeURIComponent(e||`/`).replace(/\/+$/,``)||`/`).toLowerCase()}catch{return((e||`/`).replace(/\/+$/,``)||`/`).toLowerCase()}},i=()=>{if(e)return;let i=window.location.pathname;if(r(i)===r(t)){t=i;return}if(D&&r(i)===r(D)){t=i;return}if(Date.now()-n<8e3){t=i;return}if(Vn()){t=i;return}let a=t;t=i;let o=window.location.href,s=typeof document<`u`?document.title:``,c=typeof document<`u`?Array.from(document.querySelectorAll(`h1, h2, h3, h4`)).filter(e=>!e.closest(`#flowengage-root, .flowengage-shell`)).map(e=>({tag:e.tagName,text:e.textContent.trim()})).filter(e=>e.text.length>0&&e.text.length<200).slice(0,20):[];try{kn()}catch{}let l=e=>(e.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())||`Home`,u=l(a),d=l(i);typeof window<`u`&&(window.__fe_user_nav_during_speech={fromPath:a,toPath:i,fromPageName:u,toPageName:d,ts:Date.now()}),console.log(`[FlowEngage] visitor navigation detected: "${a}" → "${i}" (agent target: ${D||`none`})`);try{N.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${d}" page (${o}). Page title: "${s}". Sections: ${JSON.stringify(c)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${d} page — would you like me to continue what I was explaining, or shall I walk you through this page?" Then wait for my answer. IF I say continue/yes/carry on: resume speaking verbally from where you left off — do NOT call fwh-navigate-mvp, do NOT call fwh-highlight-mvp, the visitor will navigate themselves if needed. IF I want to hear about this page: call fwh-highlight-mvp for sections of "${d}" only.]`)}catch{}};f=window.history.pushState.bind(window.history),window.history.pushState=(...e)=>{f(...e),setTimeout(i,50)},h=()=>setTimeout(i,50),window.addEventListener(`popstate`,h)}}catch(r){e||(console.error(`[FlowEngage] startSession failed`,r),r.message&&r.message.includes(`Too many voice sessions`)?(alert(r.message),n&&n(`minimized`)):(x(`error`),ve.current=`chat`,window.setTimeout(()=>{e||t?.()},0)))}})(),()=>{console.warn(`[FlowEngage:VoiceDebug] ⚠️ useEffect CLEANUP fired — session will be killed`,{agentId:r,siteId:i,apiBaseUrl:a}),e=!0,_e.current=!0;try{kn()}catch{}if(i)try{Ae(i)}catch{}typeof window<`u`&&(window.__fe_user_nav_during_speech=null),Er(),ke.current&&=(clearTimeout(ke.current),null),I.current&&=(clearTimeout(I.current),null),ae.current&&=(clearTimeout(ae.current),null),je.current=!1,F.current=`idle`,f&&typeof window<`u`&&(window.history.pushState=f),h&&typeof window<`u`&&window.removeEventListener(`popstate`,h);let t=l||N.current,n=Se.current,u=we.current;if(t?.endSession?.().catch(()=>{}),n&&o&&a){let e=u?Math.round((Date.now()-u)/1e3):0,t=JSON.stringify({chatId:o,voiceSessionId:n,duration:e,siteId:i}),r=`${a}/api/voice/save-chat-recording`;typeof navigator<`u`&&navigator.sendBeacon&&navigator.sendBeacon(r,new Blob([t],{type:`application/json`}))||fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`},body:t,keepalive:!0}).catch(()=>{}),Se.current=null,we.current=null}typeof c==`function`&&s.current.length>0&&c(s.current).catch?.(()=>{})}},[r,i,a,Me]),(0,b.useEffect)(()=>{if(!w)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;Te.current&&!Te.current.contains(t)&&T(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[w]);let L=async()=>{if(N.current)try{if(S){Ee.current=0,await N.current.setMicMuted?.(!1),C(!1);try{N.current.sendContextualUpdate?.(`The visitor has unmuted. Resume normal interaction and wait for them to speak.`)}catch{}}else{Ee.current=0,await N.current.setMicMuted?.(!0),C(!0);try{N.current.sendContextualUpdate?.(`The visitor has muted their microphone. Do NOT speak, ask if they are there, or prompt them in any way. Stay completely silent until they unmute.`)}catch{}}}catch{}},ze=(0,b.useCallback)(async e=>{e?.preventDefault?.();let t=te.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)){ne(`Please enter a valid email address.`);return}ne(``),re.current=!0,ie.current=!1,Ne(),ee(!1),D(``),A.current=!1;try{typeof f==`function`&&await f(t)}catch{}N.current?.setMicMuted?.(!1);let n=k.current;k.current=``;try{N.current?.injectAgentSpeech?.(`Thank you for submitting your email.`),N.current?.sendUserMessage?.(n||`The visitor's email is on file. Carry on helping them and never ask for it again.`)}catch{}},[te,f,Ne]),Be=Array.isArray(e)&&e[0]||`#3B82F6`;return(0,H.jsxs)(`div`,{ref:Te,style:{position:`relative`,display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`14px`,animation:`fe-orb-slide-up 0.42s cubic-bezier(0.16,1,0.3,1)`},children:[E&&(0,H.jsxs)(`form`,{onSubmit:ze,style:{width:`270px`,maxWidth:`calc(100vw - 40px)`,boxSizing:`border-box`,background:`rgba(15,22,36,0.97)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,padding:`16px`,display:`flex`,flexDirection:`column`,gap:`10px`,animation:`fe-orb-fade-in 0.18s ease`},children:[(0,H.jsx)(`span`,{style:{color:`white`,fontSize:`13px`,fontWeight:600,lineHeight:1.4},children:`Please enter your email to continue`}),(0,H.jsx)(`input`,{type:`email`,inputMode:`email`,autoComplete:`email`,autoFocus:!0,value:te,onChange:e=>{D(e.target.value),O&&ne(``)},placeholder:`you@example.com`,style:{width:`100%`,boxSizing:`border-box`,padding:`10px 12px`,borderRadius:`10px`,border:O?`1.5px solid #ef4444`:`1.5px solid #4b5563`,background:`#1f2937`,color:`white`,fontSize:`14px`,outline:`none`}}),O&&(0,H.jsx)(`span`,{style:{color:`#f87171`,fontSize:`12px`},children:O}),(0,H.jsx)(`button`,{type:`submit`,disabled:!te.trim(),style:{width:`100%`,padding:`10px 12px`,borderRadius:`10px`,border:`none`,background:te.trim()?Be:`#374151`,color:`white`,fontSize:`14px`,fontWeight:600,cursor:te.trim()?`pointer`:`default`,transition:`background 0.2s ease`},children:`Submit`})]}),(0,H.jsxs)(`div`,{style:{position:`relative`},children:[(y===`listening`||y===`thinking`)&&!S&&(0,H.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:y===`thinking`?g:h}),S&&(0,H.jsx)(`span`,{style:{position:`absolute`,right:`100%`,marginRight:`18px`,top:`50%`,transform:`translateY(-50%)`,color:`#f87171`,fontSize:`16px`,fontWeight:600,letterSpacing:`0.01em`,textShadow:`0 2px 4px rgba(0,0,0,0.4)`,whiteSpace:`nowrap`},children:`Muted`}),(0,H.jsx)(wg,{size:72,voiceState:y,isMuted:S,orbColors:e})]}),y===`error`&&(0,H.jsx)(`span`,{style:{color:`#f87171`,fontSize:`13px`,fontWeight:500},children:`Could not start voice session.`}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,alignItems:`center`},children:[(0,H.jsx)(`button`,{onClick:L,title:S?`Unmute`:`Mute`,style:{width:`24px`,height:`24px`,borderRadius:`50%`,background:S?`#7f1d1d`:`#1f2937`,border:S?`1.5px solid #ef4444`:`1.5px solid #4b5563`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:S?`#f87171`:`white`,transition:`all 0.2s ease`,boxShadow:`0 2px 8px rgba(0,0,0,0.4)`,padding:0,flexShrink:0},children:S?(0,H.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`line`,{x1:`1`,y1:`1`,x2:`23`,y2:`23`}),(0,H.jsx)(`path`,{d:`M9 9v3a3 3 0 005.12 2.12M15 9.34V4a3 3 0 00-5.94-.6`}),(0,H.jsx)(`path`,{d:`M17 16.95A7 7 0 015 12v-2m14 0v2a7 7 0 01-.11 1.23`}),(0,H.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`23`}),(0,H.jsx)(`line`,{x1:`8`,y1:`23`,x2:`16`,y2:`23`})]}):(0,H.jsx)(jm,{size:16,color:`currentColor`})}),(0,H.jsx)(`button`,{onClick:()=>T(e=>!e),style:{width:`24px`,height:`24px`,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)`,padding:0,flexShrink:0},children:(0,H.jsx)(zm,{size:16,color:`currentColor`})})]}),w&&(0,H.jsxs)(`div`,{style:{position:`absolute`,bottom:0,right:0,width:`230px`,zIndex:9999,background:`rgba(15,22,36,0.96)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,animation:`fe-orb-fade-in 0.18s ease`,padding:`12px 12px 40px`},children:[(0,H.jsxs)(`button`,{onClick:()=>{T(!1),ve.current=`chat`,Re(t)},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`12px 16px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`,borderRadius:`8px`,whiteSpace:`nowrap`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,H.jsx)(Bm,{}),_]}),(0,H.jsxs)(`button`,{onClick:()=>{T(!1),ve.current=`minimized`,Re(n)},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`12px 16px`,background:`none`,border:`none`,color:`#E30C12`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`,borderRadius:`8px`,whiteSpace:`nowrap`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(227,12,18,0.1)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,H.jsx)(Vm,{}),v]}),(0,H.jsx)(`button`,{onClick:()=>T(!1),style:{position:`absolute`,bottom:`8px`,right:`8px`,width:`24px`,height:`24px`,borderRadius:`50%`,background:`rgba(255,255,255,0.15)`,border:`none`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:`white`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.25)`},onMouseLeave:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.15)`},children:(0,H.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,H.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})]})}function Og({orbColors:e}){let t=Array.isArray(e)&&e.length>0?e:[`#135bd8`,`#ef334b`,`#ffbd2e`],n=t[0],r=t[1]||t[0],i=t[2]||t[0];return(0,H.jsx)(`div`,{style:{width:`32px`,height:`32px`,borderRadius:`50%`,flexShrink:0,background:`
346
346
  radial-gradient(circle at 18% 50%, ${n} 0%, ${n}99 35%, transparent 65%),
347
347
  radial-gradient(circle at 82% 50%, ${r} 0%, ${r}99 35%, transparent 65%),
348
348
  radial-gradient(circle at 50% 82%, ${i} 0%, ${i}99 30%, transparent 58%),