@flowengage/react-chatbot 8.0.110 → 8.0.111
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.
|
@@ -33,7 +33,7 @@ Error generating stack: `+e.message+`
|
|
|
33
33
|
box-shadow: none !important;
|
|
34
34
|
transition: outline-color 0.25s ease, box-shadow 0.25s ease !important;
|
|
35
35
|
}
|
|
36
|
-
`,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}var Sr=6e3,Cr=250,wr=700;async function Tr(){if(typeof window>`u`)return;let e=window.__fe_agentAudioPlaying;if(typeof e!=`function`){await new Promise(e=>setTimeout(e,wr));return}let t=Date.now()+Sr;for(;Date.now()<t;){let t=!1;try{t=e()}catch{t=!1}if(!t)break;await new Promise(e=>setTimeout(e,100))}await new Promise(e=>setTimeout(e,Cr))}async function Er(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;if(window.Shopify)return n&&gr(n),r||we(),r?Tr().then(()=>window.location.assign(i.href)):window.location.assign(i.href),{navigated:!0};let 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||we(),window.location.assign(i.href),{navigated:!0}}return{navigated:!0}}return n&&gr(n),r||we(),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 Dr=!1,Or=null;function kr(e){Or=e,typeof window<`u`&&(window.__fe_triggerVoiceNavHooks=()=>{try{e.onBeforeNavigate()}catch{}}),!Dr&&(Dr=!0,!(typeof document>`u`)&&(document.addEventListener(`click`,e=>{if(!Or)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{Or.onBeforeNavigate()}catch{}}},!0),document.addEventListener(`submit`,e=>{if(Or&&!e.target?.closest?.(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)){Nn(`voice-form-hook: saving state before form submit`);try{Or.onBeforeNavigate()}catch{}}},!0)))}function Ar(){Or=null,Nn(`voice-nav-hooks: deactivated`)}var jr=4e3,Mr=null;function Nr(){let e=typeof window<`u`&&window.Shopify?.routes?.root||`/`;return e.endsWith(`/`)?e:`${e}/`}async function Pr(e,t={}){let n=new AbortController,r=setTimeout(()=>n.abort(),jr);try{let r=await fetch(e,{credentials:`same-origin`,signal:n.signal,...t,headers:{Accept:`application/json`,...t.body?{"Content-Type":`application/json`}:{},...t.headers||{}}}),i=await r.json().catch(()=>({}));if(!r.ok){let e=Error(i.description||i.message||`Cart request failed (${r.status})`);throw e.status=r.status,r.status===422&&i.description&&(e.userMessage=i.description),e}return i}finally{clearTimeout(r)}}async function Fr(){if(Mr!==null)return Mr;if(typeof window>`u`)return Mr=!1;if(window.Shopify)return Mr=!0;try{let e=await Pr(`${Nr()}cart.js`);Mr=e&&typeof e.item_count==`number`}catch{Mr=!1}return Mr}async function Ir(){return Pr(`${Nr()}cart.js`)}function Lr(){return typeof window>`u`?null:window.__flowengageCustomer?.id||null}function Rr(e){return typeof e!=`number`||Number.isNaN(e)?null:(e/100).toFixed(2)}async function zr(){try{if(!await Fr())return null;let e=await Ir();return{itemCount:e.item_count,subtotal:Rr(e.items_subtotal_price),currency:e.currency||null,items:(e.items||[]).map(e=>({title:e.product_title||e.title,variantTitle:e.variant_title||null,quantity:e.quantity,linePrice:Rr(e.final_line_price??e.line_price),handle:e.handle||null}))}}catch{return null}}async function Br(e,t=null){let n=await Pr(`${Nr()}products/${encodeURIComponent(e)}.js`),r=n.variants||[];if(!r.length){let t=Error(`No variants for ${e}`);throw t.userMessage=`"${n.title||e}" has no purchasable options right now.`,t}let i=null;if(t){let e=t.toLowerCase();if(i=r.find(t=>(t.title||``).toLowerCase()===e)||r.find(t=>{let n=[t.title,...t.options||[]].join(` `).toLowerCase();return e.split(/[\s/,-]+/).filter(Boolean).every(e=>n.includes(e))}),!i){let e=Error(`Variant not found: ${t}`);throw e.userMessage=`I couldn't find a "${t}" option for ${n.title}. Available: ${r.map(e=>e.title).slice(0,6).join(`, `)}.`,e}}else i=r.find(e=>e.available)||r[0];if(!i.available){let e=Error(`Variant unavailable: ${i.title}`);throw e.userMessage=`Sorry — ${n.title}${i.title&&i.title!==`Default Title`?` (${i.title})`:``} is currently sold out.`,e}return{variant:i,product:n}}async function Vr(e,t=1){return Pr(`${Nr()}cart/add.js`,{method:`POST`,body:JSON.stringify({items:[{id:e,quantity:t}]})})}async function Hr(e,t){return Pr(`${Nr()}cart/change.js`,{method:`POST`,body:JSON.stringify({line:e,quantity:t})})}function Ur(){return`${Nr()}cart`}function Wr(){return`${Nr()}checkout`}function Gr(e){return`${Nr()}products/${encodeURIComponent(e)}`}async function Kr(e,t=6){let n=new URLSearchParams({q:e,"resources[type]":`product`,"resources[limit]":String(t)});try{return((await Pr(`${Nr()}search/suggest.json?${n.toString()}`))?.resources?.results?.products||[]).map(e=>({title:e.title,handle:e.handle,price:e.price||null,url:e.url||null}))}catch{return[]}}function qr(){return typeof window>`u`?!1:/\/cart\/?$/.test(window.location.pathname)}var Jr=[`form[action*="/cart"]`,`cart-items`,`cart-drawer-items`,`.cart-items`,`.cart__items`,`#main-cart-items`,`[data-cart-items]`].join(`, `);function Yr(e){if(/cart/i.test(e.id))return!0;try{return!!e.querySelector(Jr)}catch{return!1}}async function Xr(){if(typeof document>`u`)return!1;let e=Array.from(document.querySelectorAll(`[id^="shopify-section-"]`)).filter(Yr);if(!e.length)return!1;let t=e.map(e=>e.id.replace(/^shopify-section-/,``));try{let e=await Pr(`${window.location.pathname}?sections=${encodeURIComponent(t.join(`,`))}`),n=!1;for(let[t,r]of Object.entries(e||{})){if(!r||typeof r!=`string`)continue;let e=document.getElementById(`shopify-section-${t}`);if(!e)continue;let i=document.createElement(`div`);i.innerHTML=r;let a=i.querySelector(`#shopify-section-${t}`)||i.firstElementChild;a&&(e.innerHTML=a.innerHTML,n=!0)}return n}catch{return!1}}var Zr=[`[data-cart-count]`,`.cart-count-bubble`,`.cart-count`,`#CartCount`,`.cart-link__bubble`,`.site-header__cart-count`,`#cart-icon-bubble`];function Qr(e){if(typeof document>`u`)return;let t=String(e);for(let e of Zr)document.querySelectorAll(e).forEach(e=>{e.hasAttribute(`data-cart-count`)&&e.setAttribute(`data-cart-count`,t),e.querySelectorAll(`span, div, sup`).forEach(e=>{e.children.length===0&&/\d/.test(e.textContent||``)&&(e.textContent=(e.textContent||``).replace(/\d+/,t))}),e.children.length===0&&/^\s*\d+\s*$/.test(e.textContent||``)&&(e.textContent=t)})}function $r(e){if(typeof document>`u`)return;let t={cart:e,source:`flowengage`};[`cart:updated`,`cart:refresh`,`cart:change`,`cart-drawer:refresh`].forEach(e=>{try{document.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0}))}catch{}});try{window.dispatchEvent(new CustomEvent(`cart:refresh`,{detail:t}))}catch{}}async function ei(e){let t=await Xr();return!t&&qr()&&(await new Promise(e=>setTimeout(e,600)),t=await Xr()),e&&typeof e.item_count==`number`&&Qr(e.item_count),$r(e||null),{sectionsSwapped:t}}async function ti(e){try{let{sectionsSwapped:t}=await ei(e);if(!t&&qr())return` (The list on this page may need a quick refresh to show it.)`}catch{}return``}function ni(e){let t=Rr(e.items_subtotal_price),n=e.item_count;return t==null?``:` Your cart now has ${n} item${n===1?``:`s`} — subtotal ${t}${e.currency?` ${e.currency}`:``}.`}function ri(e,t){let n=t.title&&t.title!==`Default Title`;return`${e.title}${n?` (${t.title})`:``}`}function ii(e,t){return e?.userMessage||t}var ai={async add(e){let{variant:t,product:n}=await Br(e.productHandle,e.variantTitle||null);await Vr(t.id,e.quantity||1);let r=await Ir(),i=await ti(r);return{message:`✅ Added ${e.quantity||1} × ${ri(n,t)} to your cart.${ni(r)}${i}`}},async update(e){let t=(await Ir()).items?.[e.line-1];if(!t)return{message:`⚠️ I couldn't find item #${e.line} in your cart — it may have changed. Ask me "what's in my cart?" to see the current list.`};let n=await Hr(e.line,e.quantity),r=await ti(n);return{message:`✅ Updated ${t.product_title||t.title} to quantity ${e.quantity}.${ni(n)}${r}`}},async remove(e){let t=(await Ir()).items?.[e.line-1];if(!t)return{message:`⚠️ I couldn't find item #${e.line} in your cart — it may have changed. Ask me "what's in my cart?" to see the current list.`};let n=await Hr(e.line,0),r=await ti(n);return{message:`🗑️ Removed ${t.product_title||t.title} from your cart.${ni(n)}${r}`}},async view_cart(){return{message:`Opening your cart…`,navigateTo:Ur()}},async checkout(){return(await Ir()).item_count?{message:`Taking you to checkout…`,navigateTo:Wr()}:{message:`Your cart is empty — add something first and I'll take you straight to checkout.`}},async view_product(e){return{message:`Opening the product page…`,navigateTo:Gr(e.productHandle)}}},oi={add:`⚠️ I couldn't add that to your cart — please try from the product page.`,update:`⚠️ I couldn't update that cart item — please try again.`,remove:`⚠️ I couldn't remove that cart item — please try again.`,view_cart:`⚠️ I couldn't open the cart page.`,checkout:`⚠️ I couldn't start checkout — you can open the cart and check out from there.`,view_product:`⚠️ I couldn't open that product page.`};async function si(e){let t={messages:[],navigateTo:null};if(!Array.isArray(e)||e.length===0)return t;if(!await Fr())return t.messages.push(`⚠️ Cart actions only work on the store's own website — please try from the shop page.`),t;for(let n of e){let e=ai[n?.type];if(e)try{let r=await e(n);r.message&&t.messages.push(r.message),r.navigateTo&&(t.navigateTo=r.navigateTo)}catch(e){console.warn(`[FlowEngage:Cart] ${n.type} failed:`,e),t.messages.push(ii(e,oi[n.type]))}}return t}var ci=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=ci()}))(),li=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(),ui=(e=[])=>e.filter(e=>e.type!==`call_recording`&&!(typeof e.message==`string`&&e.message.includes(`AI chat recording`))).map(e=>({...e,message:li(e.message),isPending:!1,id:e.messageId||`${e.sender}-${e.timestamp||Date.now()}-${Math.random()}`}));function di(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 fi=(e,t)=>e?typeof e==`string`?e:e.message||e.error||e.reason||t:t,pi=(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}:{}}},mi=(e=[],t=`Agent`)=>{for(let t of e)if(typeof t==`string`&&t.trim())return t.trim();return t},hi=(e=[],t,n=6)=>!t?.message||e.slice(-n).some(e=>e.sender===`system`&&e.message===t.message)?e:[...e,t];function gi({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)(e=>{si(e).then(({messages:e,navigateTo:t})=>{e.length&&g(t=>[...t,...e.map((e,n)=>({id:`cart-${t.length+n}-${Math.random().toString(36).slice(2,8)}`,sender:`bot`,message:e,timestamp:new Date().toISOString()}))]),t&&setTimeout(()=>{window.location.assign(t)},900)})},[]),y=(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()}])},[]),[x,C]=(0,b.useState)(N().isOpen),[w,T]=(0,b.useState)(N().activeScreen),[E,k]=(0,b.useState)(N().isHumanHandled),[A,ie]=(0,b.useState)(N().agentName),[j,M]=(0,b.useState)(N().agentHeadshot),[ae,de]=(0,b.useState)(()=>le(i?.siteId)),[F,fe]=(0,b.useState)(!1),[me,I]=(0,b.useState)(!1),[he,ge]=(0,b.useState)(`idle`),[_e,ve]=(0,b.useState)(!1),[ye,be]=(0,b.useState)(!1),[Se,Ce]=(0,b.useState)(``),[we,Te]=(0,b.useState)(!1),[Ee,De]=(0,b.useState)(0),[Oe,ke]=(0,b.useState)(0),[Ae,L]=(0,b.useState)(!1),[R,Pe]=(0,b.useState)(null),[Fe,Ie]=(0,b.useState)(null),[Le,Re]=(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),z=(0,b.useRef)(null),Je=(0,b.useRef)(``),Ye=(0,b.useRef)(!1),Xe=(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)(null),rt=(0,b.useRef)(!1),it=(0,b.useRef)({url:null,at:0}),at=(0,b.useCallback)((e,t)=>{Bn(6e3);let n=e;try{n=new URL(e,window.location.origin).href}catch{}let r=it.current;return r.url===n&&Date.now()-r.at<4e3?Promise.resolve({navigated:!0,deduped:!0}):(it.current={url:n,at:Date.now()},Er(e,t))},[]),ot=(0,b.useRef)([]),B=(0,b.useRef)(null),st=(0,b.useRef)(null),ct=(0,b.useRef)(null),lt=(0,b.useRef)(!1),ut=(0,b.useRef)(!1),dt=(0,b.useRef)(``),ft=(0,b.useRef)(null),pt=(0,b.useRef)(null),mt=(0,b.useRef)([]),ht=(0,b.useRef)(0),gt=(0,b.useRef)(A),_t=(0,b.useRef)([]),vt=(0,b.useRef)(!1),yt=(0,b.useRef)(!1),bt=(0,b.useRef)(i),xt=(0,b.useRef)({notifyRouteChange:()=>{},cleanup:()=>{}}),St=(0,b.useCallback)((e={})=>{let t=!!e.is_human_handled;return k(t),t?(T(`agent`),e.agent_info?.name&&ie(e.agent_info.name),e.agent_info?.headshot&&M(e.agent_info.headshot),t):(T(`ai`),t)},[]),Ct=(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:D},[i,d]);(0,b.useEffect)(()=>{Ze.current=R},[R]),(0,b.useEffect)(()=>{gt.current=A},[A]),(0,b.useEffect)(()=>{yt.current=we},[we]),(0,b.useEffect)(()=>{bt.current=i},[i]);let wt=()=>{We(``)},Tt=(0,b.useCallback)(()=>{ct.current&&=(window.clearTimeout(ct.current),null)},[]),Et=e=>{let t=typeof e==`string`?e.trim().toLowerCase():``;return de(t),ue(t,i?.siteId),t};(0,b.useEffect)(()=>{let e=i?.siteId;if(!e)return;let t=le(e);if(t){de(t);return}de(t=>(t&&ue(t,e),t))},[i?.siteId]);let Dt=(e=`unspecified`)=>{let t=B.current||tt.current?.callId,n=ht.current,r=ft.current;if(ft.current=null,ht.current=0,r&&r.state!==`inactive`){r.onstop=()=>{let e=mt.current;if(mt.current=[],e.length>0&&t&&z.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;z.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,mt.current=[]}}else if(r&&r.state===`inactive`){let e=mt.current;if(mt.current=[],e.length>0&&t&&z.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;z.current.uploadRecording(t,r,i).then(e=>console.log(`[FlowEngageCall] recording upload success`,e)).catch(e=>console.warn(`[FlowEngageCall] recording upload failed`,e))}}else mt.current=[];if(pt.current){try{pt.current.close()}catch{}pt.current=null}Qe.current&&=(Qe.current.close(),null),$e.current&&=($e.current.getTracks().forEach(e=>e.stop()),null),et.current&&=(et.current.srcObject=null,et.current.remove(),null),Tt(),tt.current=null,ot.current=[],B.current=null,st.current=null,lt.current=!1,He(!1),Pe(null),Ie(null),Re(`idle`),Be(null)},Ot=(e=new Date().toISOString())=>{let t=qe.current,n=B.current||tt.current?.callId;if(!(!t?.connected||!n||lt.current)){lt.current=!0,t.emit(`call:connected`,{callId:n,chatId:Je.current,connectedAt:e});try{let e=$e.current,t=et.current?.srcObject;if(e&&t&&!ft.current){mt.current=[];let n=new(window.AudioContext||window.webkitAudioContext);pt.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&&mt.current.push(e.data)},ft.current=a,ht.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{}}},kt=(e={})=>{if(!e.callId)return;let t=st.current===e.callId,n=B.current===e.callId,r=Ze.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(Tt(),Pe(null),t||n){B.current=e.callId,Ie(e.callId),Re(e=>e===`connected`?e:`connecting`),C(!0);return}Re(`idle`)}},At=(e={})=>{if(!e.callId)return;let t=st.current===e.callId,n=B.current===e.callId,r=Ze.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(Tt(),n){Dt();return}st.current=null,tt.current=null,ot.current=[],Pe(null),Re(`idle`)}},jt=async(e={})=>{let t=Qe.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}),tt.current=e;return}if(await t.setRemoteDescription(new RTCSessionDescription({type:`offer`,sdp:r})),ot.current.length>0){console.log(`[FlowEngageProvider] flushing queued agent ICE candidates after remote offer`,{callId:e.callId,chatId:Je.current,queuedCount:ot.current.length});for(let e of ot.current)await t.addIceCandidate(new RTCIceCandidate(e));ot.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)(()=>{P({isOpen:x,activeScreen:w,isHumanHandled:E,agentName:A,agentHeadshot:j})},[x,w,E,A,j]),(0,b.useEffect)(()=>{let e=!0;return(async()=>{Ke(!0);try{let t=S(i),n=await Me(t);if(!e)return;let a=t.siteId,o=oe(a),s=pe(a),l=``;try{let e=Ye.current,r=Xe.current;if(Ye.current=!1,Xe.current=null,l=(await je({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:a,priorChatId:e||r?null:o||te(),forceNew:e,resumeChatId:r,visitorId:s}))?.data?.chatId,!l)throw Error(`resolve-session returned no chatId`);ne(),ce(a,l)}catch(e){console.warn(`[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id`,e?.message||e),l=o||re(),ce(a,l)}Je.current=l;let u=Ne({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:t.siteId,visitorId:s});z.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()=>{ge(`connected`);let e=Je.current;if(e&&z.current)try{St(await z.current.checkHumanHandled(e))}catch{}}),p.on(`disconnect`,()=>{ge(`disconnected`)}),p.on(`aiTyping`,()=>{I(!0)}),p.on(`ai:typing`,()=>{I(!0)}),p.on(`messageReceived`,e=>{let t=e.message||e,n={...t,message:li(t.message)};I(!1),fe(!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:li(t.message)};I(!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`)&&fe(!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)&&(k(!0),T(`agent`),ie(mi([n.agent_name,n.agentName,n.metadata?.agentName],d)),n.sender_headshot&&M(n.sender_headshot),C(!0),De(e=>e+1)))});let h=(e={})=>{let t=mi([e.agent?.name,e.agentName,e.agent_name,gt.current],d);k(!0),T(`agent`),ie(t),M(e.agent?.headshot||null),C(!0),De(e=>e+1),g(e=>hi(e,{id:`agent-joined-${Date.now()}`,sender:`system`,message:`${t} has joined the chat.`,timestamp:new Date().toISOString(),isPending:!1}))},v=(e={})=>{let t=mi([e.agent?.name,e.agentName,e.agent_name,gt.current],d);k(!1),T(`ai`),g(e=>hi(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`,v),p.on(`agentLeft`,v),p.on(`conversationEnded`,e=>{L(!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=ui(e.chat_history||[]);g(t),t.length===0&&(L(!1),k(!1),T(`ai`),I(!1),fe(!1))}),p.on(`conversation:reset`,()=>{g([]),L(!1),k(!1),T(`ai`),I(!1),fe(!1)}),p.on(`voice:end_session`,(e={})=>{console.log(`[FlowEngageProvider] voice:end_session received — ending voice session`),ke(e=>e+1),C(!0),De(e=>e+1)}),p.on(`typing:start`,e=>{e.sender===`agent`&&fe(!0)}),p.on(`typing:stop`,e=>{e.sender===`agent`&&fe(!1)}),p.on(`call:incoming`,(e={})=>{let t=mi([e.agentName,e.ownerName,e.agent?.name,gt.current],`Agent`);wt(),Tt(),lt.current=!1,Pe({callId:e.callId,from:e.from||`owner`,agentId:e.agentId||null,agentName:t}),ie(e=>mi([t,e],`Agent`)),Re(`incoming`),Be(null),C(!0)}),p.on(`call:offer`,async(e={})=>{tt.current=e;try{await jt(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=pi(e);if(!t){console.warn(`[FlowEngageProvider] ignoring invalid ICE candidate payload`,e);return}if(!Qe.current||!Qe.current.remoteDescription){console.log(`[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready`,{callId:e.callId,chatId:e.chatId||Je.current,queueSize:ot.current.length+1}),ot.current.push(t);return}await Qe.current.addIceCandidate(new RTCIceCandidate(t))}catch(e){console.error(`[FlowEngageProvider] failed to add ICE candidate`,e)}}),p.on(`call:ended`,()=>{wt(),Dt(`socket:call_ended`)}),p.on(`call:accepted`,(e={})=>{kt(e)}),p.on(`call:accepted_by_other`,(e={})=>{kt(e)}),p.on(`call:rejected`,(e={})=>{At(e)}),p.on(`call:missed`,(e={})=>{At(e)}),p.on(`call:failed`,(e={})=>{At(e)}),p.on(`call:connected`,(e={})=>{if(!e.callId)return;let t=st.current===e.callId,n=B.current===e.callId,r=tt.current?.callId===e.callId,i=Ze.current?.callId===e.callId;if(!t&&!n&&!r){i&&(Pe(null),Re(`idle`));return}lt.current=!0,st.current=null,B.current=e.callId,Ie(e.callId),Pe(null),Re(`connected`),Be(e.connectedAt||new Date().toISOString()),C(!0)}),p.on(`call:unavailable`,(e={})=>{Dt(`socket:call_unavailable`),We(fi(e,`This visitor is not available for a call right now.`)),C(!0)}),p.on(`call:error`,(e={})=>{Dt(`socket:call_error`),We(fi(e,`We couldn't connect the call right now.`)),C(!0)}),p.on(`visitor:navigate`,async({url:e,section:t,highlight:n}={})=>{e&&at(e,{voiceActive:yt.current}).then(({navigated:e,reason:r})=>{if(!e){r===`not-found`?_():r===`already-on-page`&&y();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()}),xt.current=Sn({socket:p,chatId:l});let b=await u.loadHistory(l,r);if(!e)return;g(ui(b.chat_history||[])),k(!!b.is_human_handled),T(b.is_human_handled?`agent`:w);let x=b?.visitor_email||b?.visitorEmail;if(x&&String(x).trim()&&Et(String(x).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,xt.current?.cleanup?.(),Dt(),qe.current?.disconnect()}},[i,r,a]),(0,b.useEffect)(()=>()=>{if(we&&!vt.current&&_t.current.length>0){let e=Je.current,t=_t.current,n=z.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(()=>{}),vt.current=!0)}},[we,d]);let Mt=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=z.current;!e||!p||Mt.current!==x&&(x&&Mt.current!==null?e.updateChatStatus(p,`open`).catch(()=>{}):Mt.current===!0&&e.updateChatStatus(p,`widget_closed`).catch(()=>{}),Mt.current=x)},[x,p]),(0,b.useEffect)(()=>{let e=()=>{let e=Je.current,t=z.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 Nt=async()=>{if(!(!R?.callId||!z.current||!qe.current||!p)){wt(),st.current=R.callId,Tt();try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});$e.current=e;let t=[{urls:`stun:stun.l.google.com:19302`}];try{let e=await z.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});Qe.current=n,n.onconnectionstatechange=()=>{let e=n.connectionState;if(e===`connected`){let e=new Date().toISOString();Re(`connected`),Be(t=>t||e),Ot(e);return}if(e===`connecting`){Re(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&Dt(`peer:connection_${e}`)},n.oniceconnectionstatechange=()=>{let e=n.iceConnectionState;if(e===`connected`||e===`completed`){let e=new Date().toISOString();Re(`connected`),Be(t=>t||e),Ot(e);return}if(e===`checking`||e===`new`){Re(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&Dt(`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:R.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(!et.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=>{},et.current=e,document.body.appendChild(e)}et.current.srcObject=e.streams[0];let r=R?.callId,i=r&&(st.current===r||B.current===r);if(!lt.current&&i){let e=new Date().toISOString();Re(`connected`),Be(t=>t||e),B.current=r,Ie(r),Ot(e)}et.current.srcObject=t||null;let a=et.current.play?.();a?.catch&&a.catch(e=>{})};let r=tt.current;r&&(console.log(`[FlowEngageProvider] found pending remote offer during accept`,{callId:r.callId||R.callId,chatId:p}),await jt({...r,callId:r.callId||R.callId})),await z.current.acceptCall(R.callId,p),qe.current?.emit(`call:accepted`,{callId:R.callId,chatId:p}),B.current=R.callId,Ie(R.callId),Re(e=>e===`connected`||lt.current?`connected`:`connecting`),Pe(null),C(!0)}catch(e){if(st.current=null,Dt(`accept_call_failed`),e?.status===404||e?.status===409||e?.status===422){We(fi(e,`This visitor call is no longer available.`));return}if(e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`){try{await z.current.rejectCall(R.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.`)}}},Pt=async()=>{if(!R?.callId||!z.current||!p){Dt(`reject_call_without_server_context`);return}let e=R.callId;Tt(),wt(),qe.current?.emit(`call:rejected`,{callId:e,chatId:p,reason:`visitor_declined`});try{await z.current.rejectCall(e,p)}catch(e){We(fi(e,`We couldn't decline the call cleanly.`))}finally{Dt(`reject_call_finally`)}},Ft=(0,b.useRef)(Pt);Ft.current=Pt,(0,b.useEffect)(()=>{if(!R?.callId||Fe){Tt();return}let e=R.callId;return Tt(),ct.current=window.setTimeout(()=>{Ze.current?.callId===e&&st.current!==e&&B.current!==e&&Ft.current()},O),()=>{ct.current&&=(window.clearTimeout(ct.current),null)}},[Fe,Tt,R?.callId]);let It=async()=>{if(!Fe||!z.current||!p){Dt(`end_call_without_server_context`);return}wt();try{await z.current.endWebRTCCall(Fe,p)}catch(e){We(fi(e,`The call ended locally, but the server could not be updated.`))}finally{Dt(`end_call_finally`)}},Lt=()=>{let e=$e.current?.getAudioTracks?.()||[],t=Qe.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)},Rt=async(e={})=>{let t=e.notifyChatInitiated===!0;if(C(!0),!(!t||!z.current||!p||typeof window>`u`)){try{await z.current.trackVisitor({chatId:p,currentPagePath:window.location.pathname||`/`})}catch{}try{await z.current.updateChatStatus(p,`open`)}catch{}}},zt=async e=>{let t=Et(e);if(!t||!z.current||!Je.current)return t;try{await z.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},Bt=()=>{!p||!qe.current?.connected||ut.current||(ut.current=!0,qe.current.emit(`typing:start`,{chatId:p,sender:`user`}))},Vt=()=>{!p||!qe.current?.connected||!ut.current||(ut.current=!1,qe.current.emit(`typing:stop`,{chatId:p,sender:`user`}))},Ht=(e=``)=>{let t=typeof e==`string`?e:``;!p||!qe.current?.connected||t!==``&&dt.current===t||(dt.current=t,qe.current.emit(`typing:update`,{chatId:p,sender:`user`,text:t}))};function Ut(){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 Wt=async(e,t=``,n=null,i={})=>{let a=typeof e==`string`?e.trim():``;if(!a||!z.current||!p||s!==`ready`||Ae)return;Vt(),rt.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(nt.current&&o.test(a)&&!c.test(a)){let{url:e,section:t}=nt.current;nt.current=null,rt.current=!0,console.log(`[FWH Nav] Client-side nav firing →`,e),at(e,{voiceActive:yt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&y();return}!t||!yt.current||setTimeout(()=>{let e=ur(null,t);e&&dr(e)},300)})}else o.test(a)||(nt.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=E;if(m)try{m=St(await z.current.checkHumanHandled(p))}catch{}if(m&&qe.current?.connected){qe.current.emit(`customer:message`,{chatId:p,content:e,sender:`user`,email:ae||void 0,type:i?.type||`text`,metadata:i?.metadata||{},...n||{}});return}ve(!0);try{let o=await zr(),s=Lr(),c=`stream-preview-${Date.now().toString(36)}`,u=e=>{I(!1),g(t=>{let n=t.findIndex(e=>e.id===c);if(n===-1)return[...t,{id:c,sender:`bot`,message:e,timestamp:new Date().toISOString(),isStreaming:!0}];let r=[...t];return r[n]={...r[n],message:r[n].message+e},r})},d=await z.current.sendAiMessage(p,e,r,t,{...n||{},...ae?{email:ae}:{}},{...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:Ut()||void 0,...o?{shopifyCart:o}:{},...s?{shopifyCustomerId:s}:{}},u),f=d.chat_history||[];if(console.log(`[FWH Nav Debug] API response fields:`,{has_navigate:!!d.navigate,navigate:d.navigate,has_pending_navigate:!!d.pending_navigate,pending_navigate:d.pending_navigate,last_bot_msg:[...f].reverse().find(e=>e.sender===`bot`)?.message?.substring(0,80)}),d.pending_navigate?.url){let e={url:d.pending_navigate.url,section:d.pending_navigate.section||null};l.test(a)?(console.log(`[FWH Nav] Auto-navigating (intent detected) →`,e.url),at(e.url,{voiceActive:yt.current}).then(({navigated:t,reason:n})=>{if(!t){n===`not-found`?_():n===`already-on-page`&&y();return}e.section&&setTimeout(()=>{let t=ur(null,e.section);t&&dr(t)},300)})):(nt.current=e,console.log(`[FWH Nav] Stored pending nav →`,nt.current))}if(d.navigate?.url)if(rt.current)rt.current=!1;else{let{url:e,section:t}=d.navigate;at(e,{voiceActive:yt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&y();return}t&&setTimeout(()=>{let e=ur(null,t);e&&dr(e)},300)})}else if(d.highlight?.section){let e=d.highlight.section;setTimeout(()=>{let t=ur(null,e);t&&dr(t)},150)}else{let e=[...f].reverse().find(e=>e.sender===`bot`||e.sender===`assistant`);if(e?.message){let t=di(e.message);t&&hr(t.url,{siteId:bt.current?.siteId,apiBaseUrl:bt.current?.apiBaseUrl}).then(({allowed:e,correctedUrl:n})=>{if(!e){_();return}at(n||t.url,{voiceActive:yt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&y();return}!t.section||!yt.current||setTimeout(()=>{let e=ur(null,t.section);e&&dr(e)},300)})})}}g(ui(f)),Array.isArray(d.cart_actions)&&d.cart_actions.length&&v(d.cart_actions),k(!!d.is_human_handled),T(d.is_human_handled?`agent`:`ai`),I(!1),ve(!1),await z.current.updateChatStatus(p,`messageSent`)}catch(e){g(e=>e.filter(e=>e.id!==d&&!e.isStreaming)),I(!1),ve(!1),e.status===429?(be(!0),Ce(e.message),window.setTimeout(()=>{be(!1),Ce(``)},ee)):u(e)}},Gt=async e=>{if(!z.current||!e)throw Error(`Upload is unavailable right now.`);return z.current.uploadChatFile(e)},Kt=async e=>{if(!(!z.current||!p)){try{let t=e?`voice`:`text`;await z.current.setChatMode(p,t)}catch{}Te(e),e&&(vt.current=!1)}},qt=async e=>{if(vt.current)return;if(vt.current=!0,!z.current||!p||!e?.length){Te(!1);return}let t=()=>{let t=ui(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 z.current.syncVoice(p,e);if(n?.chat_history?.length)g(ui(n.chat_history));else if(n?.success)try{let e=await z.current.loadHistory(p,r);e?.chat_history?.length?g(ui(e.chat_history)):t()}catch{t()}else t()}catch{t()}finally{Te(!1)}},Jt=async()=>{if(!(!z.current||!p)){we&&!vt.current&&_t.current.length>0&&await qt(_t.current);try{await z.current.endConversation(p)}catch{try{await z.current.updateChatStatus(p,`ended`)}catch{}}L(!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(Le!==`connected`||!Fe||!p||!ze||!Ct)return;let e=new Date(ze).getTime(),t=Number.isFinite(e)?Date.now()-e:0,n=Math.max(0,Ct*1e3-t),r=window.setTimeout(()=>{We(`The call ended because it reached the time limit.`),It()},n);return()=>window.clearTimeout(r)},[Fe,ze,Le,p,It,Ct]),(0,b.useEffect)(()=>{let e=()=>{let e=Je.current,t=z.current;if(!t||!e)return;if(yt.current&&_t.current.length>0&&xe(),!vt.current&&_t.current.length>0&&(t.beaconSyncVoice(e,_t.current)||t.syncVoice(e,_t.current).catch(()=>{}),vt.current=!0),B.current){t.beaconEndWebRTCCall(B.current,e);return}let n=st.current||Ze.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 Yt=(0,b.useCallback)(()=>{let e=i?.siteId;se(e),Ye.current=!0,Xe.current=null,qe.current?.disconnect(),g([]),m(``),Je.current=``,L(!1),k(!1),ie(null),M(null),Ke(!0),o(e=>e+1)},[i?.siteId]),Xt=(0,b.useCallback)(e=>{i?.siteId,Ye.current=!1,Xe.current=e,qe.current?.disconnect(),g([]),m(``),Je.current=``,L(!1),k(!1),ie(null),M(null),Ke(!0),o(e=>e+1)},[i?.siteId]),Zt=(0,b.useMemo)(()=>({status:s,error:l,runtimeConfig:d,resolvedConfig:i,chatId:p,chatHistory:h,isOpen:x,activeScreen:w,isHumanHandled:E,agentName:A,agentHeadshot:j,visitorEmail:ae,isAgentTyping:F,isAiTyping:me,connectionStatus:he,isLoading:_e,isVoiceMode:we,isRateLimited:ye,rateLimitMessage:Se,isConversationEnded:Ae,isSessionRestoring:Ge,openToChatCounter:Ee,voiceEndCounter:Oe,incomingCall:R,activeCallId:Fe,callConnectionState:Le,callConnectedAt:ze,isCallMuted:Ve,webRTCError:Ue,language:r,historyRef:_t,hasSyncedRef:vt,dismissCallError:wt,captureVisitorEmail:zt,startTyping:Bt,stopTyping:Vt,updateTypingDraft:Ht,notifyRouteChange:()=>xt.current?.notifyRouteChange?.(),openWidget:Rt,closeWidget:()=>C(!1),toggleWidget:()=>{if(x){C(!1);return}Rt({notifyChatInitiated:!0})},sendMessage:Wt,uploadChatFile:Gt,setVoiceMode:Kt,onMessageSync:qt,endConversation:Jt,startNewChat:Yt,resumeChat:Xt,getVisitorChatHistory:()=>z.current?.getVisitorChatHistory?.(),getVisitorChatThread:e=>z.current?.getVisitorChatThread?.(e),acceptCall:Nt,rejectCall:Pt,endWebRTCCall:It,toggleCallMute:Lt}),[s,l,d,i,p,h,x,w,E,A,j,ae,F,me,he,_e,we,ye,Se,Ae,Ge,Ee,Oe,R,Fe,Le,ze,Ve,Ue,r,zt,Bt,Vt,Ht,Nt,Pt,It,Lt,Rt,Wt,Gt,Kt,qt,Jt,Yt,wt]);return(0,H.jsx)(Cn.Provider,{value:Zt,children:n})}var _i=(0,b.createContext)({});function vi(e){let t=(0,b.useRef)(null);return t.current===null&&(t.current=e()),t.current}var yi=typeof window<`u`?b.useLayoutEffect:b.useEffect,bi=(0,b.createContext)(null);function xi(e,t){e.indexOf(t)===-1&&e.push(t)}function Si(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Ci=(e,t,n)=>n>t?t:n<e?e:n,wi={},Ti=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Ei(e){return typeof e==`object`&&!!e}var Di=e=>/^0[^.\s]+$/u.test(e);function Oi(e){let t;return()=>(t===void 0&&(t=e()),t)}var ki=e=>e,Ai=(e,t)=>n=>t(e(n)),U=(...e)=>e.reduce(Ai),ji=(e,t,n)=>{let r=t-e;return r===0?1:(n-e)/r},Mi=class{constructor(){this.subscriptions=[]}add(e){return xi(this.subscriptions,e),()=>Si(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}},Ni=e=>e*1e3,Pi=e=>e/1e3;function Fi(e,t){return t?1e3/t*e:0}var Ii=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Li=1e-7,Ri=12;function zi(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=Ii(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>Li&&++s<Ri);return o}function Bi(e,t,n,r){if(e===t&&n===r)return ki;let i=t=>zi(t,0,1,e,n);return e=>e===0||e===1?e:Ii(i(e),t,r)}var Vi=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Hi=e=>t=>1-e(1-t),Ui=Bi(.33,1.53,.69,.99),Wi=Hi(Ui),Gi=Vi(Wi),Ki=e=>e>=1?1:(e*=2)<1?.5*Wi(e):.5*(2-2**(-10*(e-1))),qi=e=>1-Math.sin(Math.acos(e)),Ji=Hi(qi),Yi=Vi(qi),Xi=Bi(.42,0,1,1),Zi=Bi(0,0,.58,1),Qi=Bi(.42,0,.58,1),$i=e=>Array.isArray(e)&&typeof e[0]!=`number`,ea=e=>Array.isArray(e)&&typeof e[0]==`number`,ta={linear:ki,easeIn:Xi,easeInOut:Qi,easeOut:Zi,circIn:qi,circInOut:Yi,circOut:Ji,backIn:Wi,backInOut:Gi,backOut:Ui,anticipate:Ki},na=e=>typeof e==`string`,ra=e=>{if(ea(e)){e.length;let[t,n,r,i]=e;return Bi(t,n,r,i)}else if(na(e))return ta[e],`${e}`,ta[e];return e},ia=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`],aa={value:null,addProjectionMetrics:null};function oa(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&&aa.value&&aa.value.frameloop[t].push(c),c=0,n.clear(),i=!1,a&&(a=!1,u.process(e))}};return u}var sa=40;function ca(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=ia.reduce((e,n)=>(e[n]=oa(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=wi.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,sa),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:ia.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<ia.length;t++)o[ia[t]].cancel(e)},state:i,steps:o}}var{schedule:W,cancel:la,state:ua,steps:da}=ca(typeof requestAnimationFrame<`u`?requestAnimationFrame:ki,!0),fa;function pa(){fa=void 0}var ma={now:()=>(fa===void 0&&ma.set(ua.isProcessing||wi.useManualTiming?ua.timestamp:performance.now()),fa),set:e=>{fa=e,queueMicrotask(pa)}},ha={layout:0,mainThread:0,waapi:0},ga=e=>t=>typeof t==`string`&&t.startsWith(e),_a=ga(`--`),va=ga(`var(--`),ya=e=>va(e)?ba.test(e.split(`/*`)[0].trim()):!1,ba=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function xa(e){return typeof e==`string`?e.split(`/*`)[0].includes(`var(--`):!1}var Sa={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Ca={...Sa,transform:e=>Ci(0,1,e)},wa={...Sa,default:1},Ta=e=>Math.round(e*1e5)/1e5,Ea=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Da(e){return e==null}var Oa=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ka=(e,t)=>n=>!!(typeof n==`string`&&Oa.test(n)&&n.startsWith(e)||t&&!Da(n)&&Object.prototype.hasOwnProperty.call(n,t)),Aa=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Ea);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},ja=e=>Ci(0,255,e),Ma={...Sa,transform:e=>Math.round(ja(e))},Na={test:ka(`rgb`,`red`),parse:Aa(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Ma.transform(e)+`, `+Ma.transform(t)+`, `+Ma.transform(n)+`, `+Ta(Ca.transform(r))+`)`};function Pa(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 Fa={test:ka(`#`),parse:Pa,transform:Na.transform},Ia=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),La=Ia(`deg`),Ra=Ia(`%`),G=Ia(`px`),za=Ia(`vh`),Ba=Ia(`vw`),Va={...Ra,parse:e=>Ra.parse(e)/100,transform:e=>Ra.transform(e*100)},Ha={test:ka(`hsl`,`hue`),parse:Aa(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+Ra.transform(Ta(t))+`, `+Ra.transform(Ta(n))+`, `+Ta(Ca.transform(r))+`)`},Ua={test:e=>Na.test(e)||Fa.test(e)||Ha.test(e),parse:e=>Na.test(e)?Na.parse(e):Ha.test(e)?Ha.parse(e):Fa.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Na.transform(e):Ha.transform(e),getAnimatableNone:e=>{let t=Ua.parse(e);return t.alpha=0,Ua.transform(t)}},Wa=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Ga(e){return isNaN(e)&&typeof e==`string`&&(e.match(Ea)?.length||0)+(e.match(Wa)?.length||0)>0}var Ka=`number`,qa=`color`,Ja=`var`,Ya=`var(`,Xa="${}",Za=/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 Qa(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(Za,e=>(Ua.test(e)?(r.color.push(a),i.push(qa),n.push(Ua.parse(e))):e.startsWith(Ya)?(r.var.push(a),i.push(Ja),n.push(e)):(r.number.push(a),i.push(Ka),n.push(parseFloat(e))),++a,Xa)).split(Xa),indexes:r,types:i}}function $a(e){return Qa(e).values}function eo({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===Ka?i+=Ta(r[a]):e===qa?i+=Ua.transform(r[a]):i+=r[a]}return i}}function to(e){return eo(Qa(e))}var no=e=>typeof e==`number`?0:Ua.test(e)?Ua.getAnimatableNone(e):e,ro=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:no(e);function io(e){let t=Qa(e);return eo(t)(t.values.map((e,n)=>ro(e,t.split[n])))}var ao={test:Ga,parse:$a,createTransformer:to,getAnimatableNone:io};function oo(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 K({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=oo(s,r,e+1/3),a=oo(s,r,e),o=oo(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function so(e,t){return n=>n>0?t:e}var q=(e,t,n)=>e+(t-e)*n,co=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},lo=[Fa,Na,Ha],uo=e=>lo.find(t=>t.test(e));function fo(e){let t=uo(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===Ha&&(n=K(n)),n}var po=(e,t)=>{let n=fo(e),r=fo(t);if(!n||!r)return so(e,t);let i={...n};return e=>(i.red=co(n.red,r.red,e),i.green=co(n.green,r.green,e),i.blue=co(n.blue,r.blue,e),i.alpha=q(n.alpha,r.alpha,e),Na.transform(i))},mo=new Set([`none`,`hidden`]);function ho(e,t){return mo.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function go(e,t){return n=>q(e,t,n)}function _o(e){return typeof e==`number`?go:typeof e==`string`?ya(e)?so:Ua.test(e)?po:xo:Array.isArray(e)?vo:typeof e==`object`?Ua.test(e)?po:yo:so}function vo(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>_o(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function yo(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=_o(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function bo(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 xo=(e,t)=>{let n=ao.createTransformer(t),r=Qa(e),i=Qa(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?mo.has(e)&&!i.values.length||mo.has(t)&&!r.values.length?ho(e,t):U(vo(bo(r,i),i.values),n):(`${e}${t}`,so(e,t))};function So(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?q(e,t,n):_o(e)(e,t)}var Co=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>W.update(t,e),stop:()=>la(t),now:()=>ua.isProcessing?ua.timestamp:ma.now()}},wo=(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)})`},To=2e4;function Eo(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 Do(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(Eo(r),To);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:Pi(i)}}var Oo={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 ko(e,t){return e*Math.sqrt(1-t*t)}var Ao=12;function jo(e,t,n){let r=n;for(let n=1;n<Ao;n++)r-=e(r)/t(r);return r}var Mo=.001;function No({duration:e=Oo.duration,bounce:t=Oo.bounce,velocity:n=Oo.velocity,mass:r=Oo.mass}){let i,a;Oo.maxDuration;let o=1-t;o=Ci(Oo.minDamping,Oo.maxDamping,o),e=Ci(Oo.minDuration,Oo.maxDuration,Pi(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=ko(t,o),c=Math.exp(-i);return Mo-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=ko(t**2,o);return(-i(t)+Mo>0?-1:1)*((a-s)*c)/l}):(i=t=>{let r=Math.exp(-t*e),i=(t-n)*e+1;return-Mo+r*i},a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=jo(i,a,s);if(e=Ni(e),isNaN(c))return{stiffness:Oo.stiffness,damping:Oo.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var Po=[`duration`,`bounce`],Fo=[`stiffness`,`damping`,`mass`];function Io(e,t){return t.some(t=>e[t]!==void 0)}function Lo(e){let t={velocity:Oo.velocity,stiffness:Oo.stiffness,damping:Oo.damping,mass:Oo.mass,isResolvedFromDuration:!1,...e};if(!Io(e,Fo)&&Io(e,Po))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Ci(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Oo.mass,stiffness:i,damping:a}}else{let n=No({...e,velocity:0});t={...t,...n,mass:Oo.mass},t.isResolvedFromDuration=!0}return t}function Ro(e=Oo.visualDuration,t=Oo.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}=Lo({...n,velocity:-Pi(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=Pi(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?Oo.restSpeed.granular:Oo.restSpeed.default,i||=v?Oo.restDelta.granular:Oo.restDelta.default;let y,b,x,S,C,w;if(h<1)x=ko(_,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=>Ni(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=Ni(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=Ni(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(Eo(T),To),t=wo(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}Ro.applyToOptions=e=>{let t=Do(e,100,Ro);return e.ease=t.ease,e.duration=Ni(t.duration),e.type=`keyframes`,e};var zo=5;function Bo(e,t,n){let r=Math.max(t-zo,0);return Fi(n-e(r),t-r)}function Vo({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=Ro({keyframes:[f.value,m(f.value)],velocity:Bo(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 Ho(e,t,n){let r=[],i=n||wi.mix||So,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=U(Array.isArray(t)?t[n]||ki:t,a)),r.push(a)}return r}function Uo(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=Ho(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=ji(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Ci(e[0],e[a-1],t)):l}function Wo(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=ji(0,t,r);e.push(q(n,1,i))}}function Go(e){let t=[0];return Wo(t,e.length-1),t}function Ko(e,t){return e.map(e=>e*t)}function qo(e,t){return e.map(()=>t||Qi).splice(0,e.length-1)}function Jo({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=$i(r)?r.map(ra):ra(r),a={done:!1,value:t[0]},o=Uo(Ko(n&&n.length===t.length?n:Go(t),e),t,{ease:Array.isArray(i)?i:qo(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var Yo=e=>e!==null;function Xo(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(Yo),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var Zo={decay:Vo,inertia:Vo,tween:Jo,keyframes:Jo,spring:Ro};function Qo(e){typeof e.type==`string`&&(e.type=Zo[e.type])}var $o=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)}},es=e=>e/100,ts=class extends $o{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!==ma.now()&&this.tick(ma.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},ha.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;Qo(e);let{type:t=Jo,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||Jo;s!==Jo&&typeof o[0]!=`number`&&(this.mixKeyframes=U(es,So(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=Eo(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=Ci(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!==Vo&&(b.value=Xo(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 Pi(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Pi(e)}get time(){return Pi(this.currentTime)}set time(e){e=Ni(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 Bo(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(ma.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=Pi(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Co,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(ma.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,ha.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 ns(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var rs=e=>e*180/Math.PI,is=e=>os(rs(Math.atan2(e[1],e[0]))),as={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:is,rotateZ:is,skewX:e=>rs(Math.atan(e[1])),skewY:e=>rs(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},os=e=>(e%=360,e<0&&(e+=360),e),ss=is,cs=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),ls=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),us={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:cs,scaleY:ls,scale:e=>(cs(e)+ls(e))/2,rotateX:e=>os(rs(Math.atan2(e[6],e[5]))),rotateY:e=>os(rs(Math.atan2(-e[2],e[0]))),rotateZ:ss,rotate:ss,skewX:e=>rs(Math.atan(e[4])),skewY:e=>rs(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function ds(e){return e.includes(`scale`)?1:0}function fs(e,t){if(!e||e===`none`)return ds(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=us,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=as,i=t}if(!i)return ds(t);let a=r[t],o=i[1].split(`,`).map(ms);return typeof a==`function`?a(o):o[a]}var ps=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return fs(n,t)};function ms(e){return parseFloat(e.trim())}var hs=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],gs=new Set(hs),_s=e=>e===Sa||e===G,vs=new Set([`x`,`y`,`z`]),ys=hs.filter(e=>!vs.has(e));function bs(e){let t=[];return ys.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith(`scale`)?1:0))}),t}var xs={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})=>fs(t,`x`),y:(e,{transform:t})=>fs(t,`y`)};xs.translateX=xs.x,xs.translateY=xs.y;var Ss=new Set,Cs=!1,ws=!1,Ts=!1;function Es(){if(ws){let e=Array.from(Ss).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=bs(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)})}ws=!1,Cs=!1,Ss.forEach(e=>e.complete(Ts)),Ss.clear()}function Ds(){Ss.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(ws=!0)})}function Os(){Ts=!0,Ds(),Es(),Ts=!1}var ks=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?(Ss.add(this),Cs||(Cs=!0,W.read(Ds),W.resolveKeyframes(Es))):(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])}ns(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ss.delete(this)}cancel(){this.state===`scheduled`&&(Ss.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},As=e=>e.startsWith(`--`);function js(e,t,n){As(t)?e.style.setProperty(t,n):e.style[t]=n}var Ms={};function Ns(e,t){let n=Oi(e);return()=>Ms[t]??n()}var Ps=Ns(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),Fs=Ns(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),Is=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Ls={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:Is([0,.65,.55,1]),circOut:Is([.55,0,1,.45]),backIn:Is([.31,.01,.66,-.59]),backOut:Is([.33,1.53,.69,.99])};function Rs(e,t){if(e)return typeof e==`function`?Fs()?wo(e,t):`ease-out`:ea(e)?Is(e):Array.isArray(e)?e.map(e=>Rs(e,t)||Ls.easeOut):Ls[e]}function zs(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=Rs(s,i);Array.isArray(d)&&(u.easing=d),aa.value&&ha.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 aa.value&&p.finished.finally(()=>{ha.waapi--}),p}function Bs(e){return typeof e==`function`&&`applyToOptions`in e}function Vs({type:e,...t}){return Bs(e)&&Fs()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var Hs=class extends $o{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=Vs(e);this.animation=zs(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=Xo(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),js(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 Pi(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Pi(e)}get time(){return Pi(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Ni(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&&Ps()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),ki):r(this)}},Us={anticipate:Ki,backInOut:Gi,circInOut:Yi};function Ws(e){return e in Us}function Gs(e){typeof e.ease==`string`&&Ws(e.ease)&&(e.ease=Us[e.ease])}var Ks=10,qs=class extends Hs{constructor(e){Gs(e),Qo(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 ts({...a,autoplay:!1}),s=Math.max(Ks,ma.now()-this.startTime),c=Ci(0,Ks,s-Ks),l=o.sample(s).value,{name:u}=this.options;i&&u&&js(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},Js=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(ao.test(e)||e===`0`)&&!e.startsWith(`url(`));function Ys(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 Xs(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=Js(i,t),s=Js(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:Ys(e)||(n===`spring`||Bs(n))&&r}function Zs(e){e.duration=0,e.type=`keyframes`}var Qs=new Set([`opacity`,`clipPath`,`filter`,`transform`]),$s=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function ec(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&$s.test(e[t]))return!0;return!1}var tc=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),nc=Oi(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function rc(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 nc()&&n&&(Qs.has(n)||tc.has(n)&&ec(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var ic=40,ac=class extends $o{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=ma.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||ks)(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=ma.now();let u=!0;Xs(e,i,a,o)||(u=!1,(wi.instantAnimations||!s)&&l?.(Xo(e,n,t)),e[0]=e[e.length-1],Zs(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>ic?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&rc(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new qs({...d,element:p})}catch{m=new ts(d)}else m=new ts(d);m.finished.then(()=>{this.notifyFinished()}).catch(ki),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(),Os()),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 oc(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 sc=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function cc(e){let t=sc.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function lc(e,t,n=1){`${e}`;let[r,i]=cc(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Ti(e)?parseFloat(e):e}return ya(i)?lc(i,t,n+1):i}var uc={type:`spring`,stiffness:500,damping:25,restSpeed:10},dc=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),fc={type:`keyframes`,duration:.8},pc={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},mc=(e,{keyframes:t})=>t.length>2?fc:gs.has(e)?e.startsWith(`scale`)?dc(t[1]):uc:pc;function hc(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function gc(e,t){let n=e?.[t]??e?.default??e;return n===e?n:hc(n,e)}var _c=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function vc(e){for(let t in e)if(!_c.has(t))return!0;return!1}var yc=(e,t,n,r={},i,a)=>o=>{let s=gc(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=Ni(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};vc(s)||Object.assign(u,mc(e,u)),u.duration&&=Ni(u.duration),u.repeatDelay&&=Ni(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(Zs(u),u.delay===0&&(d=!0)),(wi.instantAnimations||wi.skipAnimations||i?.shouldSkipAnimations)&&(d=!0,Zs(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=Xo(u.keyframes,s);if(e!==void 0){W.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new ts(u):new ac(u)};function bc(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function xc(e,t,n,r){if(typeof t==`function`){let[i,a]=bc(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]=bc(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Sc(e,t,n){let r=e.getProps();return xc(r,t,n===void 0?r.custom:n,e)}var Cc=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...hs]),wc=30,Tc=e=>!isNaN(parseFloat(e)),Ec={current:void 0},Dc=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=ma.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=ma.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Tc(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 Mi);let n=this.events[e].add(t);return e===`change`?()=>{n(),W.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 Ec.current&&Ec.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=ma.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>wc)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,wc);return Fi(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 Oc(e,t){return new Dc(e,t)}var kc=e=>Array.isArray(e);function Ac(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Oc(n))}function jc(e){return kc(e)?e[e.length-1]||0:e}function Mc(e,t){let{transitionEnd:n={},transition:r={},...i}=Sc(e,t)||{};i={...i,...n};for(let t in i)Ac(e,t,jc(i[t]))}var Nc=e=>!!(e&&e.getVelocity);function Pc(e){return!!(Nc(e)&&e.add)}function Fc(e,t){let n=e.getValue(`willChange`);if(Pc(n))return n.add(t);if(!n&&wi.WillChange){let n=new wi.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function Ic(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var Lc=`data-`+Ic(`framerAppearId`);function Rc(e){return e.props[Lc]}function zc({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function Bc(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?hc(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&&zc(d,t))continue;let o={delay:n,...gc(a||{},t)},c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){W.update(()=>r.set(i));continue}let f=!1;if(window.MotionHandoffAnimation){let n=Rc(e);if(n){let e=window.MotionHandoffAnimation(n,t,W);e!==null&&(o.startTime=e,f=!0)}}Fc(e,t);let p=l??e.shouldReduceMotion;r.start(yc(t,r,i,p&&Cc.has(t)?{type:!1}:o,e,f));let m=r.animation;m&&u.push(m)}if(o){let t=()=>W.update(()=>{o&&Mc(e,o)});u.length?Promise.all(u).then(t):t()}return u}function Vc(e,t,n={}){let r=Sc(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(Bc(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return Hc(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 Hc(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(Vc(c,t,{...o,delay:n+(typeof r==`function`?0:r)+oc(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function Uc(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>Vc(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=Vc(e,t,n);else{let i=typeof t==`function`?Sc(e,t,n.custom):t;r=Promise.all(Bc(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var Wc={test:e=>e===`auto`,parse:e=>e},Gc=e=>t=>t.test(e),Kc=[Sa,G,Ra,La,Ba,za,Wc],qc=e=>Kc.find(Gc(e));function Jc(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||Di(e)}var Yc=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function Xc(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Ea)||[];if(!r)return e;let i=n.replace(r,``),a=Yc.has(t)?1:0;return r!==n&&(a*=100),t+`(`+a+i+`)`}var Zc=/\b([a-z-]*)\(.*?\)/gu,Qc={...ao,getAnimatableNone:e=>{let t=e.match(Zc);return t?t.map(Xc).join(` `):e}},$c={...ao,getAnimatableNone:e=>{let t=ao.parse(e);return ao.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},el={...Sa,transform:Math.round},tl={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:La,rotateX:La,rotateY:La,rotateZ:La,scale:wa,scaleX:wa,scaleY:wa,scaleZ:wa,skew:La,skewX:La,skewY:La,distance:G,translateX:G,translateY:G,translateZ:G,x:G,y:G,z:G,perspective:G,transformPerspective:G,opacity:Ca,originX:Va,originY:Va,originZ:G,zIndex:el,fillOpacity:Ca,strokeOpacity:Ca,numOctaves:el},nl={...tl,color:Ua,backgroundColor:Ua,outlineColor:Ua,fill:Ua,stroke:Ua,borderColor:Ua,borderTopColor:Ua,borderRightColor:Ua,borderBottomColor:Ua,borderLeftColor:Ua,filter:Qc,WebkitFilter:Qc,mask:$c,WebkitMask:$c},rl=e=>nl[e],il=new Set([Qc,$c]);function al(e,t){let n=rl(e);return il.has(n)||(n=ao),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var ol=new Set([`auto`,`none`,`0`]);function sl(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!ol.has(t)&&Qa(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=al(n,i)}var cl=class extends ks{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(),ya(r))){let i=lc(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Cc.has(n)||e.length!==2)return;let[r,i]=e,a=qc(r),o=qc(i);if(xa(r)!==xa(i)&&xs[n]){this.needsMeasurement=!0;return}if(a!==o)if(_s(a)&&_s(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else xs[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||Jc(e[t]))&&n.push(t);n.length&&sl(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=xs[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]=xs[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 ll(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 ul=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function dl(e){return Ei(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:fl,cancel:pl}=ca(queueMicrotask,!1),ml={x:!1,y:!1};function hl(){return ml.x||ml.y}function gl(e){return e===`x`||e===`y`?ml[e]?null:(ml[e]=!0,()=>{ml[e]=!1}):ml.x||ml.y?null:(ml.x=ml.y=!0,()=>{ml.x=ml.y=!1})}function _l(e,t){let n=ll(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function vl(e){return!(e.pointerType===`touch`||hl())}function yl(e,t,n={}){let[r,i,a]=_l(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(!vl(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 bl=(e,t)=>t?e===t?!0:bl(e,t.parentElement):!1,xl=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Sl=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Cl(e){return Sl.has(e.tagName)||e.isContentEditable===!0}var wl=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Tl(e){return wl.has(e.tagName)||e.isContentEditable===!0}var El=new WeakSet;function Dl(e){return t=>{t.key===`Enter`&&e(t)}}function Ol(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var kl=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=Dl(()=>{if(El.has(n))return;Ol(n,`down`);let e=Dl(()=>{Ol(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Ol(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Al(e){return xl(e)&&!hl()}var jl=new WeakSet;function Ml(e,t,n={}){let[r,i,a]=_l(e,n),o=e=>{let r=e.currentTarget;if(!Al(e)||jl.has(e))return;El.add(r),n.stopPropagation&&jl.add(e);let a=t(r,e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),El.has(r)&&El.delete(r),Al(e)&&typeof a==`function`&&a(e,{success:t})},s=e=>{o(e,r===window||r===document||n.useGlobalTarget||bl(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),dl(e)&&(e.addEventListener(`focus`,e=>kl(e,i)),!Cl(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function Nl(e){return Ei(e)&&`ownerSVGElement`in e}var Pl=new WeakMap,Fl,Il=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:Nl(r)&&`getBBox`in r?r.getBBox()[t]:r[n],Ll=Il(`inline`,`width`,`offsetWidth`),Rl=Il(`block`,`height`,`offsetHeight`);function J({target:e,borderBoxSize:t}){Pl.get(e)?.forEach(n=>{n(e,{get width(){return Ll(e,t)},get height(){return Rl(e,t)}})})}function Y(e){e.forEach(J)}function zl(){typeof ResizeObserver>`u`||(Fl=new ResizeObserver(Y))}function Bl(e,t){Fl||zl();let n=ll(e);return n.forEach(e=>{let n=Pl.get(e);n||(n=new Set,Pl.set(e,n)),n.add(t),Fl?.observe(e)}),()=>{n.forEach(e=>{let n=Pl.get(e);n?.delete(t),n?.size||Fl?.unobserve(e)})}}var Vl=new Set,Hl;function Ul(){Hl=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Vl.forEach(t=>t(e))},window.addEventListener(`resize`,Hl)}function Wl(e){return Vl.add(e),Hl||Ul(),()=>{Vl.delete(e),!Vl.size&&typeof Hl==`function`&&(window.removeEventListener(`resize`,Hl),Hl=void 0)}}function Gl(e,t){return typeof e==`function`?Wl(e):Bl(e,t)}function Kl(e){return Nl(e)&&e.tagName===`svg`}var ql=[...Kc,Ua,ao],Jl=e=>ql.find(Gc(e)),Yl=()=>({translate:0,scale:1,origin:0,originPoint:0}),Xl=()=>({x:Yl(),y:Yl()}),Zl=()=>({min:0,max:0}),X=()=>({x:Zl(),y:Zl()}),Ql=new WeakMap;function $l(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function eu(e){return typeof e==`string`||Array.isArray(e)}var tu=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],nu=[`initial`,...tu];function ru(e){return $l(e.animate)||nu.some(t=>eu(e[t]))}function iu(e){return!!(ru(e)||e.variants)}function au(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Nc(i))e.addValue(r,i);else if(Nc(a))e.addValue(r,Oc(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,Oc(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var ou={current:null},su={current:!1},cu=typeof window<`u`;function lu(){if(su.current=!0,cu)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>ou.current=e.matches;e.addEventListener(`change`,t),t()}else ou.current=!1}var uu=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],du={};function fu(e){du=e}function pu(){return du}var mu=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=ks,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=ma.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,W.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=ru(t),this.isVariantNode=iu(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&&Nc(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,Ql.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:(su.current||lu(),this.shouldReduceMotion=ou.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(),la(this.notifyUpdate),la(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&&Qs.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new Hs({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:Ni(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=gs.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&W.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 du){let t=du[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):X()}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<uu.length;t++){let n=uu[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=au(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=Oc(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`&&(Ti(n)||Di(n))?n=parseFloat(n):!Jl(n)&&ao.test(t)&&(n=al(e,t)),this.setBaseTarget(e,Nc(n)?n.get():n)),Nc(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=xc(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&&!Nc(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 Mi),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){fl.render(this.render)}},hu=class extends mu{constructor(){super(...arguments),this.KeyframeResolver=cl}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;Nc(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},gu=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function _u({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function vu({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function yu(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 bu(e){return e===void 0||e===1}function xu({scale:e,scaleX:t,scaleY:n}){return!bu(e)||!bu(t)||!bu(n)}function Su(e){return xu(e)||Cu(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Cu(e){return wu(e.x)||wu(e.y)}function wu(e){return e&&e!==`0%`}function Tu(e,t,n){return n+t*(e-n)}function Eu(e,t,n,r,i){return i!==void 0&&(e=Tu(e,i,r)),Tu(e,n,r)+t}function Du(e,t=0,n=1,r,i){e.min=Eu(e.min,t,n,r,i),e.max=Eu(e.max,t,n,r,i)}function Ou(e,{x:t,y:n}){Du(e.x,t.translate,t.scale,t.originPoint),Du(e.y,n.translate,n.scale,n.originPoint)}var ku=.999999999999,Au=1.0000000000001;function ju(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&&(Mu(e.x,-a.scroll.offset.x),Mu(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Ou(e,o)),r&&Su(a.latestValues)&&Fu(e,a.latestValues,a.layout?.layoutBox))}t.x<Au&&t.x>ku&&(t.x=1),t.y<Au&&t.y>ku&&(t.y=1)}function Mu(e,t){e.min+=t,e.max+=t}function Nu(e,t,n,r,i=.5){Du(e,t,n,q(e.min,e.max,i),r)}function Pu(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function Fu(e,t,n){let r=n??e;Nu(e.x,Pu(t.x,r.x),t.scaleX,t.scale,t.originX),Nu(e.y,Pu(t.y,r.y),t.scaleY,t.scale,t.originY)}function Iu(e,t){return _u(yu(e.getBoundingClientRect(),t))}function Lu(e,t,n){let r=Iu(e,n),{scroll:i}=t;return i&&(Mu(r.x,i.offset.x),Mu(r.y,i.offset.y)),r}var Ru={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},zu=hs.length;function Bu(e,t,n){let r=``,i=!0;for(let a=0;a<zu;a++){let o=hs[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=ul(s,tl[o]);if(!c){i=!1;let t=Ru[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}return r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function Vu(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(gs.has(e)){o=!0;continue}else if(_a(e)){i[e]=n;continue}else{let t=ul(n,tl[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=Bu(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 Hu(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 Uu(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var Wu={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(G.test(e))e=parseFloat(e);else return e;return`${Uu(e,t.target.x)}% ${Uu(e,t.target.y)}%`}},Gu={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=ao.parse(e);if(i.length>5)return r;let a=ao.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=q(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},Ku={borderRadius:{...Wu,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:Wu,borderTopRightRadius:Wu,borderBottomLeftRadius:Wu,borderBottomRightRadius:Wu,boxShadow:Gu};function qu(e,{layout:t,layoutId:n}){return gs.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!Ku[e]||e===`opacity`)}function Ju(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Nc(r[t])||i&&Nc(i[t])||qu(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function Yu(e){return window.getComputedStyle(e)}var Xu=class extends hu{constructor(){super(...arguments),this.type=`html`,this.renderInstance=Hu}readValueFromInstance(e,t){if(gs.has(t))return this.projection?.isProjecting?ds(t):ps(e,t);{let n=Yu(e),r=(_a(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return Iu(e,t)}build(e,t,n){Vu(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Ju(e,t,n)}},Zu={offset:`stroke-dashoffset`,array:`stroke-dasharray`},Qu={offset:`strokeDashoffset`,array:`strokeDasharray`};function $u(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?Zu:Qu;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var ed=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function td(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(Vu(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 ed)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&&$u(d,i,a,o,!1)}var nd=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`]),rd=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function id(e,t,n,r){Hu(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(nd.has(n)?n:Ic(n),t.attrs[n])}function ad(e,t,n){let r=Ju(e,t,n);for(let n in e)if(Nc(e[n])||Nc(t[n])){let t=hs.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var od=class extends hu{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=X}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(gs.has(t)){let e=rl(t);return e&&e.default||0}return t=nd.has(t)?t:Ic(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return ad(e,t,n)}build(e,t,n){td(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){id(e,t,n,r)}mount(e){this.isSVGTag=rd(e.tagName),super.mount(e)}},sd=nu.length;function cd(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&cd(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<sd;n++){let r=nu[n],i=e.props[r];(eu(i)||i===!1)&&(t[r]=i)}return t}function ld(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 ud=[...tu].reverse(),dd=tu.length;function fd(e){return t=>Promise.all(t.map(({animation:t,options:n})=>Uc(e,t,n)))}function pd(e){let t=fd(e),n=gd(),r=!0,i=!1,a=t=>(n,r)=>{let i=Sc(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=cd(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<dd;t++){let p=ud[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=eu(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||$l(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=md(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=kc(t)&&kc(n)?!ld(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=Sc(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=oc(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Sc(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=gd(),i=!0}}}function md(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!ld(t,e):!1}function hd(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function gd(){return{animate:hd(!0),whileInView:hd(),whileHover:hd(),whileTap:hd(),whileDrag:hd(),whileFocus:hd(),exit:hd()}}function _d(e,t){e.min=t.min,e.max=t.max}function vd(e,t){_d(e.x,t.x),_d(e.y,t.y)}function yd(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var bd=1e-4,Z=1-bd,xd=1+bd,Sd=.01,Cd=0-Sd,wd=0+Sd;function Td(e){return e.max-e.min}function Ed(e,t,n){return Math.abs(e-t)<=n}function Dd(e,t,n,r=.5){e.origin=r,e.originPoint=q(t.min,t.max,e.origin),e.scale=Td(n)/Td(t),e.translate=q(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Z&&e.scale<=xd||isNaN(e.scale))&&(e.scale=1),(e.translate>=Cd&&e.translate<=wd||isNaN(e.translate))&&(e.translate=0)}function Od(e,t,n,r){Dd(e.x,t.x,n.x,r?r.originX:void 0),Dd(e.y,t.y,n.y,r?r.originY:void 0)}function kd(e,t,n,r=0){e.min=(r?q(n.min,n.max,r):n.min)+t.min,e.max=e.min+Td(t)}function Ad(e,t,n,r){kd(e.x,t.x,n.x,r?.x),kd(e.y,t.y,n.y,r?.y)}function jd(e,t,n,r=0){let i=r?q(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+Td(t)}function Md(e,t,n,r){jd(e.x,t.x,n.x,r?.x),jd(e.y,t.y,n.y,r?.y)}function Nd(e,t,n,r,i){return e-=t,e=Tu(e,1/n,r),i!==void 0&&(e=Tu(e,1/i,r)),e}function Pd(e,t=0,n=1,r=.5,i,a=e,o=e){if(Ra.test(t)&&(t=parseFloat(t),t=q(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=q(a.min,a.max,r);e===a&&(s-=t),e.min=Nd(e.min,t,n,s,i),e.max=Nd(e.max,t,n,s,i)}function Fd(e,t,[n,r,i],a,o){Pd(e,t[n],t[r],t[i],t.scale,a,o)}var Id=[`x`,`scaleX`,`originX`],Ld=[`y`,`scaleY`,`originY`];function Rd(e,t,n,r){Fd(e.x,t,Id,n?n.x:void 0,r?r.x:void 0),Fd(e.y,t,Ld,n?n.y:void 0,r?r.y:void 0)}function zd(e){return e.translate===0&&e.scale===1}function Bd(e){return zd(e.x)&&zd(e.y)}function Vd(e,t){return e.min===t.min&&e.max===t.max}function Hd(e,t){return Vd(e.x,t.x)&&Vd(e.y,t.y)}function Ud(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Wd(e,t){return Ud(e.x,t.x)&&Ud(e.y,t.y)}function Gd(e){return Td(e.x)/Td(e.y)}function Kd(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function qd(e){return[e(`x`),e(`y`)]}function Jd(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 Yd=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`],Xd=Yd.length,Zd=e=>typeof e==`string`?parseFloat(e):e,Qd=e=>typeof e==`number`||G.test(e);function $d(e,t,n,r,i,a){i?(e.opacity=q(0,n.opacity??1,tf(r)),e.opacityExit=q(t.opacity??1,0,nf(r))):a&&(e.opacity=q(t.opacity??1,n.opacity??1,r));for(let i=0;i<Xd;i++){let a=Yd[i],o=ef(t,a),s=ef(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||Qd(o)===Qd(s)?(e[a]=Math.max(q(Zd(o),Zd(s),r),0),(Ra.test(s)||Ra.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=q(t.rotate||0,n.rotate||0,r))}function ef(e,t){return e[t]===void 0?e.borderRadius:e[t]}var tf=rf(0,.5,Ji),nf=rf(.5,.95,ki);function rf(e,t,n){return r=>r<e?0:r>t?1:n(ji(e,t,r))}function af(e,t,n){let r=Nc(e)?e:Oc(e);return r.start(yc(``,r,t,n)),r.animation}function of(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var sf=(e,t)=>e.depth-t.depth,cf=class{constructor(){this.children=[],this.isDirty=!1}add(e){xi(this.children,e),this.isDirty=!0}remove(e){Si(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(sf),this.isDirty=!1,this.children.forEach(e)}};function lf(e,t){let n=ma.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(la(r),e(a-t))};return W.setup(r,!0),()=>la(r)}function uf(e){return Nc(e)?e.get():e}var df=class{constructor(){this.members=[]}add(e){xi(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&&(Si(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Si(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)}},ff={hasAnimatedSinceResize:!0,hasEverUpdated:!1},pf={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},mf=[``,`X`,`Y`,`Z`],hf=1e3,gf=0;function _f(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function vf(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=Rc(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,W,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&vf(r)}function yf({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=gf++,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,aa.value&&(pf.nodes=pf.calculatedTargetDeltas=pf.calculatedProjections=0),this.nodes.forEach(Sf),this.nodes.forEach(jf),this.nodes.forEach(Mf),this.nodes.forEach(Cf),aa.addProjectionMetrics&&aa.addProjectionMetrics(pf)},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 cf)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new Mi),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=Nl(t)&&!Kl(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;W.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=lf(i,250),ff.hasAnimatedSinceResize&&(ff.hasAnimatedSinceResize=!1,this.nodes.forEach(Af)))})}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()||zf,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!Wd(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={...gc(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||Af(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(),la(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(Nf),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&&vf(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(Ef),this.nodes.forEach(Tf);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Df);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Of),this.nodes.forEach(kf),this.nodes.forEach(bf),this.nodes.forEach(xf)):this.nodes.forEach(Df),this.clearAllSnapshots();let e=ma.now();ua.delta=Ci(0,1e3/60,e-ua.timestamp),ua.timestamp=e,ua.isProcessing=!0,da.update.process(ua),da.preRender.process(ua),da.render.process(ua),ua.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,fl.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(wf),this.sharedNodes.forEach(Pf)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,W.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){W.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Td(this.snapshot.measuredBox.x)&&!Td(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||=X(),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&&!Bd(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Su(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)),Uf(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return X();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Gf))){let{scroll:e}=this.root;e&&(Mu(t.x,e.offset.x),Mu(t.y,e.offset.y))}return t}removeElementScroll(e){let t=X();if(vd(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&&vd(t,e),Mu(t.x,i.offset.x),Mu(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||X();vd(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&&(Mu(r.x,-n.scroll.offset.x),Mu(r.y,-n.scroll.offset.y)),Su(n.latestValues)&&Fu(r,n.latestValues,n.layout?.layoutBox)}return Su(this.latestValues)&&Fu(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=X();vd(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Su(n.latestValues))continue;let r;n.instance&&(xu(n.latestValues)&&n.updateSnapshot(),r=X(),vd(r,n.measurePageBox())),Rd(t,n.latestValues,n.snapshot?.layoutBox,r)}return Su(this.latestValues)&&Rd(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!==ua.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=ua.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=X(),this.targetWithTransforms=X()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Ad(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):vd(this.target,this.layout.layoutBox),Ou(this.target,this.targetDelta)):vd(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),aa.value&&pf.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||xu(this.parent.latestValues)||Cu(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=X(),this.relativeTargetOrigin=X(),Md(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),vd(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===ua.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;vd(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;ju(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=X());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(yd(this.prevProjectionDelta.x,this.projectionDelta.x),yd(this.prevProjectionDelta.y,this.projectionDelta.y)),Od(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!Kd(this.projectionDelta.x,this.prevProjectionDelta.x)||!Kd(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),aa.value&&pf.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=Xl(),this.projectionDelta=Xl(),this.projectionDeltaWithTransform=Xl()}setAnimationOrigin(e,t=!1){let n=this.snapshot,r=n?n.latestValues:{},i={...this.latestValues},a=Xl();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=X(),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(Rf));this.animationProgress=0;let d;this.mixTargetDelta=t=>{let n=t/1e3;Ff(a.x,e.x,n),Ff(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Md(o,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),Lf(this.relativeTarget,this.relativeTargetOrigin,o,n),d&&Hd(this.relativeTarget,d)&&(this.isProjectionDirty=!1),d||=X(),vd(d,this.relativeTarget)),s&&(this.animationValues=i,$d(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&&=(la(this.pendingAnimation),void 0),this.pendingAnimation=W.update(()=>{ff.hasAnimatedSinceResize=!0,ha.layout++,this.motionValue||=Oc(0),this.motionValue.jump(0,!1),this.currentAnimation=af(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{ha.layout--},onComplete:()=>{ha.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(hf),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&&Wf(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||X();let t=Td(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=Td(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}vd(t,n),Fu(t,i),Od(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new df),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&&_f(`z`,e,r,this.animationValues);for(let t=0;t<mf.length;t++)_f(`rotate${mf[t]}`,e,r,this.animationValues),_f(`skew${mf[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=uf(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=uf(t?.pointerEvents)||``),this.hasProjected&&!Su(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=Jd(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 Ku){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=Ku[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?uf(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(Tf),this.root.sharedNodes.clear()}}}function bf(e){e.updateLayout()}function xf(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`)qd(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=Td(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;_d(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else Wf(i,t.layoutBox,n)&&qd(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=Td(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=Xl();Od(o,n,t.layoutBox);let s=Xl();a?Od(s,e.applyTransform(r,!0),t.measuredBox):Od(s,n,t.layoutBox);let c=!Bd(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=X();Md(s,t.layoutBox,i.layoutBox,o);let c=X();Md(c,n,a.layoutBox,o),Wd(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 Sf(e){aa.value&&pf.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 Cf(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function wf(e){e.clearSnapshot()}function Tf(e){e.clearMeasurements()}function Ef(e){e.isLayoutDirty=!0,e.updateLayout()}function Df(e){e.isLayoutDirty=!1}function Of(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function kf(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function Af(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function jf(e){e.resolveTargetDelta()}function Mf(e){e.calcProjection()}function Nf(e){e.resetSkewAndRotation()}function Pf(e){e.removeLeadSnapshot()}function Ff(e,t,n){e.translate=q(t.translate,0,n),e.scale=q(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function If(e,t,n,r){e.min=q(t.min,n.min,r),e.max=q(t.max,n.max,r)}function Lf(e,t,n,r){If(e.x,t.x,n.x,r),If(e.y,t.y,n.y,r)}function Rf(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var zf={duration:.45,ease:[.4,0,.1,1]},Bf=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Vf=Bf(`applewebkit/`)&&!Bf(`chrome/`)?Math.round:ki;function Hf(e){e.min=Vf(e.min),e.max=Vf(e.max)}function Uf(e){Hf(e.x),Hf(e.y)}function Wf(e,t,n){return e===`position`||e===`preserve-aspect`&&!Ed(Gd(t),Gd(n),.2)}function Gf(e){return e!==e.root&&e.scroll?.wasRoot}var Kf=yf({attachResizeListener:(e,t)=>of(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),qf={current:void 0},Jf=yf({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!qf.current){let e=new Kf({});e.mount(window),e.setOptions({layoutScroll:!0}),qf.current=e}return qf.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),Yf=(0,b.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function Xf(e=!0){let t=(0,b.useContext)(bi);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 Zf=(0,b.createContext)({strict:!1}),Qf={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`]},$f=!1;function ep(){if($f)return;let e={};for(let t in Qf)e[t]={isEnabled:e=>Qf[t].some(t=>!!e[t])};fu(e),$f=!0}function tp(){return ep(),pu()}function np(e){let t=tp();for(let n in e)t[n]={...t[n],...e[n]};fu(t)}var rp=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 ip(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||rp.has(e)}var ap=c({default:()=>op}),op,sp=o((()=>{throw op={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),cp=e=>!ip(e);function lp(e){typeof e==`function`&&(cp=t=>t.startsWith(`on`)?!ip(t):e(t))}try{lp((sp(),d(ap)).default)}catch{}function up(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||Nc(e[i])||(cp(i)||n===!0&&ip(i)||!t&&!ip(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var dp=(0,b.createContext)({});function fp(e,t){if(ru(e)){let{initial:t,animate:n}=e;return{initial:t===!1||eu(t)?t:void 0,animate:eu(n)?n:void 0}}return e.inherit===!1?{}:t}function pp(e){let{initial:t,animate:n}=fp(e,(0,b.useContext)(dp));return(0,b.useMemo)(()=>({initial:t,animate:n}),[mp(t),mp(n)])}function mp(e){return Array.isArray(e)?e.join(` `):e}var hp=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function gp(e,t,n){for(let r in t)!Nc(t[r])&&!qu(r,n)&&(e[r]=t[r])}function _p({transformTemplate:e},t){return(0,b.useMemo)(()=>{let n=hp();return Vu(n,t,e),Object.assign({},n.vars,n.style)},[t])}function vp(e,t){let n=e.style||{},r={};return gp(r,n,e),Object.assign(r,_p(e,t)),r}function yp(e,t){let n={},r=vp(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 bp=()=>({...hp(),attrs:{}});function xp(e,t,n,r){let i=(0,b.useMemo)(()=>{let n=bp();return td(n,t,rd(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};gp(t,e.style,e),i.style={...t,...i.style}}return i}var Sp=[`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 Cp(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(Sp.indexOf(e)>-1||/[A-Z]/u.test(e))}function wp(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??Cp(e)?xp:yp)(t,r,i,e),c=up(t,typeof e==`string`,a),l=e===b.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,b.useMemo)(()=>Nc(u)?u.get():u,[u]);return(0,b.createElement)(e,{...l,children:d})}function Tp({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Ep(n,r,i,e),renderState:t()}}function Ep(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=uf(a[e]);let{initial:o,animate:s}=e,c=ru(e),l=iu(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`&&!$l(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=xc(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 Dp=e=>(t,n)=>{let r=(0,b.useContext)(dp),i=(0,b.useContext)(bi),a=()=>Tp(e,t,r,i);return n?a():vi(a)},Op=Dp({scrapeMotionValuesFromProps:Ju,createRenderState:hp}),kp=Dp({scrapeMotionValuesFromProps:ad,createRenderState:bp}),Ap=Symbol.for(`motionComponentSymbol`);function jp(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 Mp=(0,b.createContext)({});function Np(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function Pp(e,t,n,r,i,a){let{visualElement:o}=(0,b.useContext)(dp),s=(0,b.useContext)(Zf),c=(0,b.useContext)(bi),l=(0,b.useContext)(Yf),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)(Mp);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&Fp(f.current,n,i,h);let g=(0,b.useRef)(!1);(0,b.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[Lc],v=(0,b.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return yi(()=>{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 Fp(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:Ip(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&Np(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function Ip(e){if(e)return e.options.allowProjection===!1?Ip(e.parent):e.projection}function Lp(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&np(r);let a=n?n===`svg`:Cp(e),o=a?kp:Op;function s(n,s){let c,l={...(0,b.useContext)(Yf),...n,layoutId:Rp(n)},{isStatic:u}=l,d=pp(n),f=o(n,u);if(!u&&typeof window<`u`){zp(l,r);let t=Bp(l);c=t.MeasureLayout,d.visualElement=Pp(e,f,l,i,t.ProjectionNode,a)}return(0,H.jsxs)(dp.Provider,{value:d,children:[c&&d.visualElement?(0,H.jsx)(c,{visualElement:d.visualElement,...l}):null,wp(e,n,jp(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[Ap]=e,c}function Rp({layoutId:e}){let t=(0,b.useContext)(_i).id;return t&&e!==void 0?t+`-`+e:e}function zp(e,t){(0,b.useContext)(Zf).strict}function Bp(e){let{drag:t,layout:n}=tp();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function Vp(e,t){if(typeof Proxy>`u`)return Lp;let n=new Map,r=(n,r)=>Lp(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,Lp(a,void 0,e,t)),n.get(a))})}var Hp=(e,t)=>t.isSVG??Cp(e)?new od(t):new Xu(t,{allowProjection:e!==b.Fragment}),Up=class extends gu{constructor(e){super(e),e.animationState||=pd(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();$l(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?.()}},Wp=0,Gp={animation:{Feature:Up},exit:{Feature:class extends gu{constructor(){super(...arguments),this.id=Wp++,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=Sc(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 Kp(e){return{point:{x:e.pageX,y:e.pageY}}}var qp=e=>t=>xl(t)&&e(t,Kp(t));function Jp(e,t,n,r){return of(e,t,qp(n),r)}var Yp=({current:e})=>e?e.ownerDocument.defaultView:null,Xp=(e,t)=>Math.abs(e-t);function Zp(e,t){let n=Xp(e.x,t.x),r=Xp(e.y,t.y);return Math.sqrt(n**2+r**2)}var Qp=new Set([`auto`,`scroll`]),$p=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=em(this.lastRawMoveEventInfo,this.transformPagePoint));let e=nm(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=Zp(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=ua;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=em(t,this.transformPagePoint),W.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=nm(e.type===`pointercancel`?this.lastMoveEventInfo:em(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!xl(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=em(Kp(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=ua;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,nm(s,this.history)),this.removeListeners=U(Jp(this.contextWindow,`pointermove`,this.handlePointerMove),Jp(this.contextWindow,`pointerup`,this.handlePointerUp),Jp(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(Qp.has(e.overflowX)||Qp.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),W.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),la(this.updatePoint)}};function em(e,t){return t?{point:t(e.point)}:e}function tm(e,t){return{x:e.x-t.x,y:e.y-t.y}}function nm({point:e},t){return{point:e,delta:tm(e,im(t)),offset:tm(e,rm(t)),velocity:am(t,.1)}}function rm(e){return e[0]}function im(e){return e[e.length-1]}function am(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=im(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Ni(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Ni(t)*2&&(r=e[1]);let a=Pi(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 om(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?q(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?q(n,e,r.max):Math.min(e,n)),e}function sm(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 cm(e,{top:t,left:n,bottom:r,right:i}){return{x:sm(e.x,n,i),y:sm(e.y,t,r)}}function lm(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 um(e,t){return{x:lm(e.x,t.x),y:lm(e.y,t.y)}}function dm(e,t){let n=.5,r=Td(e),i=Td(t);return i>r?n=ji(t.min,t.max-r,e.min):r>i&&(n=ji(e.min,e.max-i,t.min)),Ci(0,1,n)}function fm(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 pm=.35;function mm(e=pm){return e===!1?e=0:e===!0&&(e=pm),{x:hm(e,`left`,`right`),y:hm(e,`top`,`bottom`)}}function hm(e,t,n){return{min:gm(e,t),max:gm(e,n)}}function gm(e,t){return typeof e==`number`?e:e[t]||0}var _m=new WeakMap,vm=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=X(),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(Kp(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=gl(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),qd(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=Td(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&W.update(()=>i(e,t),!1,!0),Fc(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=Sm(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&&W.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 $p(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:Yp(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&&W.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||!xm(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=om(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&&Np(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=cm(n.layoutBox,e):this.constraints=!1,this.elastic=mm(t),r!==this.constraints&&!Np(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&qd(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=fm(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Np(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=Lu(n,r.root,this.visualElement.getTransformPagePoint()),a=um(r.layout.layoutBox,i);if(t){let e=t(vu(a));this.hasMutatedConstraints=!!e,e&&(a=_u(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=qd(o=>{if(!xm(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 Fc(this.visualElement,e),n.start(yc(e,n,0,t,this.visualElement,!1))}stopAnimation(){qd(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){qd(t=>{let{drag:n}=this.getProps();if(!xm(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]-q(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Np(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};qd(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=dm({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(),qd(t=>{if(!xm(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(q(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;_m.set(this.visualElement,this);let e=this.visualElement.current,t=Jp(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&Tl(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();Np(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=bm(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),W.read(r);let o=of(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(qd(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=pm,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function ym(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function bm(e,t,n){let r=Gl(e,ym(n)),i=Gl(t,ym(n));return()=>{r(),i()}}function xm(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Sm(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var Cm=class extends gu{constructor(e){super(e),this.removeGroupControls=ki,this.removeListeners=ki,this.controls=new vm(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ki}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()}},wm=e=>(t,n)=>{e&&W.update(()=>e(t,n),!1,!0)},Tm=class extends gu{constructor(){super(...arguments),this.removePointerDownListener=ki}onPointerDown(e){this.session=new $p(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Yp(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:wm(e),onStart:wm(t),onMove:wm(n),onEnd:(e,t)=>{delete this.session,r&&W.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=Jp(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},Em=!1,Dm=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),Em&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),ff.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}),Em=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||W.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(),fl.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Em=!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 Om(e){let[t,n]=Xf(),r=(0,b.useContext)(_i);return(0,H.jsx)(Dm,{...e,layoutGroup:r,switchLayoutGroup:(0,b.useContext)(Mp),isPresent:t,safeToRemove:n})}var km={pan:{Feature:Tm},drag:{Feature:Cm,ProjectionNode:Jf,MeasureLayout:Om}};function Am(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&W.postRender(()=>i(t,Kp(t)))}var jm=class extends gu{mount(){let{current:e}=this.node;e&&(this.unmount=yl(e,(e,t)=>(Am(this.node,t,`Start`),e=>Am(this.node,e,`End`))))}unmount(){}},Mm=class extends gu{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=U(of(this.node.current,`focus`,()=>this.onFocus()),of(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function Nm(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&&W.postRender(()=>i(t,Kp(t)))}var Pm=class extends gu{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Ml(e,(e,t)=>(Nm(this.node,t,`Start`),(e,{success:t})=>Nm(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},Fm=new WeakMap,Im=new WeakMap,Lm=e=>{let t=Fm.get(e.target);t&&t(e)},Rm=e=>{e.forEach(Lm)};function zm({root:e,...t}){let n=e||document;Im.has(n)||Im.set(n,{});let r=Im.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(Rm,{root:e,...t})),r[i]}function Bm(e,t,n){let r=zm(t);return Fm.set(e,n),r.observe(e),()=>{Fm.delete(e),r.unobserve(e)}}var Vm={some:0,all:1},Hm=class extends gu{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:Vm[r]};this.stopObserver=Bm(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(Um(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function Um({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var Wm={inView:{Feature:Hm},tap:{Feature:Pm},focus:{Feature:Mm},hover:{Feature:jm}},Gm={layout:{ProjectionNode:Jf,MeasureLayout:Om}},Km=Vp({...Gp,...Wm,...km,...Gm},Hp),qm=24e3,Jm=2048,Ym=1200,Xm=.03,Zm=2,Qm=11;function $m(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t/e.length)}function eh(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 th(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]/32768;return t}var nh=.13,rh=[`audio/webm`,`audio/mp4`];function ih(){return typeof window>`u`||window.MediaRecorder===void 0?null:rh.find(e=>window.MediaRecorder.isTypeSupported(e))||null}function ah(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))}var oh=.02;function sh(e,t,n){let r=0,i=0,a=[],o=()=>{let t=e.currentTime;a.forEach(({source:e,gain:n})=>{try{n.gain.cancelScheduledValues(t),n.gain.setValueAtTime(n.gain.value,t),n.gain.linearRampToValueAtTime(0,t+oh),e.stop(t+oh)}catch{}}),a=[],r=0,i=0},s=()=>r>e.currentTime;return{enqueue:o=>{let c=th(o),l=e.createBuffer(1,c.length,qm);l.copyToChannel(c,0);let u=e.createBufferSource();u.buffer=l;let d=e.createGain();u.connect(d),d.connect(e.destination),n&&d.connect(n);let f=s()?r:e.currentTime+nh;i||=f,u.start(f),r=f+l.duration;let p={source:u,gain:d};a.push(p),u.onended=()=>{a=a.filter(e=>e!==p),!a.length&&!s()&&t?.()}},stop:o,isPlaying:s,playedMs:()=>Math.max(0,(e.currentTime-i)*1e3)}}async function ch(e,t,n){let r=new URLSearchParams({siteId:t||``});n&&r.set(`chatId`,n);let i=Lr();i&&r.set(`shopifyCustomerId`,String(i));let a=await fetch(`${e}/api/voice/session?${r.toString()}`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(a.status===429){let e=await a.json().catch(()=>({}));throw Error(e.message||`Too many voice sessions started. Please wait a minute before trying again.`)}if(!a.ok)throw Error(`Could not start a voice session.`);let o=await a.json();if(!o?.success||!o.wsUrl)throw Error(o?.error||`Voice session was refused.`);return o}async function lh(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 ch(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:qm});_.state===`suspended`&&await _.resume();let v=_.createMediaStreamDestination(),y=ih(),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})}},D=(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,Ym))},O=!1,k=!1,A=!1,te=!1,ne=!0,re=!1,ie=null,j=!1,M=!1,ae=()=>{ie&&clearTimeout(ie);let e=()=>{if(!O){if(oe.isPlaying()){ie=setTimeout(e,150);return}if(ie=null,j){p?.();return}!O&&C.readyState===WebSocket.OPEN&&C.send(JSON.stringify({type:`PlaybackDrained`})),M&&(M=!1,d?.())}};ie=setTimeout(e,150)},oe=sh(_,()=>{te&&(te=!1,c?.({mode:`listening`}))},v);typeof window<`u`&&(window.__fe_agentAudioPlaying=()=>oe.isPlaying());let se=_.createMediaStreamSource(g);se.connect(v);let ce=_.createScriptProcessor(Jm,1,1),N=!1,P=0,le=0;ce.onaudioprocess=e=>{if(O||C.readyState!==WebSocket.OPEN)return;let t=e.inputBuffer.getChannelData(0),n=()=>C.send(new Int16Array(t.length).buffer);if(k){A||(A=!0,console.debug(`[FlowEngage] mic held — streaming silence to keep socket alive`)),N=!1,P=0,le=0,n();return}let r=$m(t);oe.isPlaying()||re?(N=!1,P=0,le=0):r>=Xm?(le=0,P+=1,!N&&P>=Zm&&(N=!0,c?.({mode:`user-speaking`}))):(P=0,N&&++le>=Qm&&(N=!1,le=0,c?.({mode:`thinking`,tentative:!0}))),C.send(eh(t).buffer)},se.connect(ce),ce.connect(_.destination);let ue=()=>{if(!O){O=!0,ie&&=(clearTimeout(ie),null),ee(),oe.stop(),typeof window<`u`&&delete window.__fe_agentAudioPlaying;try{ce.disconnect(),se.disconnect()}catch{}if(g.getTracks().forEach(e=>e.stop()),x&&x.state!==`inactive`){x.onstop=()=>ah(t,n,S,b,y);try{x.stop()}catch{x.onstop=null}}else b.length&&ah(t,n,S,b,y);_.close().catch(()=>{}),(C.readyState===WebSocket.OPEN||C.readyState===WebSocket.CONNECTING)&&C.close()}},de=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`}}},F=async e=>{for(let t of e.functions||[]){if(!t.client_side)continue;let e=await de(t);if(O||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??{})}))}},fe=e=>{switch(e.type){case`Welcome`:Number.isFinite(e.barge_in_rms)&&e.barge_in_rms>0&&e.barge_in_rms,Number.isFinite(e.barge_in_frames)&&e.barge_in_frames>0&&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}}D(e.role===`user`?`user`:`agent`,t,e.debug);break}case`UserStartedSpeaking`:ee(),oe.stop(),re=!1,ne=!1,te=!1,ie&&!j&&(clearTimeout(ie),ie=null),M=!1,c?.({mode:`listening`});break;case`AgentStartedSpeaking`:ne=!0,te=!0,c?.({mode:`speaking`});break;case`AgentAudioDone`:re=!1,ee(),ae(),oe.isPlaying()||(te=!1,c?.({mode:`listening`}));break;case`FunctionCallRequest`:F(e);break;case`AgentPreparing`:re=!0;break;case`AgentTurnComplete`:M=!0,ae();break;case`SessionEnding`:console.debug(`[FlowEngage] server is ending the session:`,e.reason||`unspecified`),j=!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){ne&&oe.enqueue(new Int16Array(e.data));return}try{fe(JSON.parse(e.data))}catch{}},C.onerror=()=>l?.(Error(`Voice connection failed`)),C.onclose=()=>{ue(),o?.()},{endSession:async()=>ue(),sendContextualUpdate:e=>{O||C.readyState!==WebSocket.OPEN||!e||C.send(JSON.stringify({type:`UpdatePrompt`,prompt:e}))},sendUserMessage:(e,{silent:t=!0,suppressQuestion:n=!1}={})=>{O||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`)=>{O||C.readyState!==WebSocket.OPEN||!e||C.send(JSON.stringify({type:`InjectAgentMessage`,message:e,behavior:t}))},setWalkthroughActive:e=>{O||C.readyState!==WebSocket.OPEN||C.send(JSON.stringify({type:`WalkthroughActive`,active:!!e}))},setMicMuted:e=>{k=!!e,!O&&C.readyState===WebSocket.OPEN&&C.send(JSON.stringify({type:`MicHeld`,held:k}))},get status(){return O?`disconnected`:`connected`}}}var uh={startSession:lh},dh=({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`})]}),fh=({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`})]}),ph=({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`})]}),mh=()=>(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`})]}),hh=()=>(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`})}),gh=({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`})]}),_h=({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`})]}),vh=({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`})]}),yh=({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})]}),bh=({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`})]}),xh=()=>(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`})}),Sh=({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`})]}),Ch=(e=``)=>String(e).replace(/<[^>]+>/g,``).replace(/\s+/g,` `).trim(),wh=(e=``)=>String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),Th=new Set([`p`,`br`,`ul`,`ol`,`li`,`strong`,`em`,`b`,`i`,`a`]),Eh=/^https?:\/\//i;function Dh(e){let t=Array.from(e.childNodes);for(let n of t)if(n.nodeType===Node.ELEMENT_NODE){let t=n.tagName.toLowerCase();if(!Th.has(t)){e.replaceChild(document.createTextNode(n.textContent),n);continue}let r={};if(t===`a`){let e=n.getAttribute(`href`)||``;Eh.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);Dh(n)}else n.nodeType!==Node.TEXT_NODE&&e.removeChild(n)}function Oh(e){let t=document.createElement(`div`);return t.innerHTML=e,Dh(t),t.innerHTML}function kh(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 Ah=(e=``)=>{let t=String(e||``).trim();if(!t)return``;if(/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t))return kh(Oh(t));let n=t.replace(/\r\n/g,`
|
|
36
|
+
`,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}var Sr=6e3,Cr=250,wr=700;async function Tr(){if(typeof window>`u`)return;let e=window.__fe_agentAudioPlaying;if(typeof e!=`function`){await new Promise(e=>setTimeout(e,wr));return}let t=Date.now()+Sr;for(;Date.now()<t;){let t=!1;try{t=e()}catch{t=!1}if(!t)break;await new Promise(e=>setTimeout(e,100))}await new Promise(e=>setTimeout(e,Cr))}async function Er(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;if(window.Shopify)return n&&gr(n),r||we(),r?Tr().then(()=>window.location.assign(i.href)):window.location.assign(i.href),{navigated:!0};let 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||we(),window.location.assign(i.href),{navigated:!0}}return{navigated:!0}}return n&&gr(n),r||we(),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 Dr=!1,Or=null;function kr(e){Or=e,typeof window<`u`&&(window.__fe_triggerVoiceNavHooks=()=>{try{e.onBeforeNavigate()}catch{}}),!Dr&&(Dr=!0,!(typeof document>`u`)&&(document.addEventListener(`click`,e=>{if(!Or)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{Or.onBeforeNavigate()}catch{}}},!0),document.addEventListener(`submit`,e=>{if(Or&&!e.target?.closest?.(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)){Nn(`voice-form-hook: saving state before form submit`);try{Or.onBeforeNavigate()}catch{}}},!0)))}function Ar(){Or=null,Nn(`voice-nav-hooks: deactivated`)}var jr=4e3,Mr=null;function Nr(){let e=typeof window<`u`&&window.Shopify?.routes?.root||`/`;return e.endsWith(`/`)?e:`${e}/`}async function Pr(e,t={}){let n=new AbortController,r=setTimeout(()=>n.abort(),jr);try{let r=await fetch(e,{credentials:`same-origin`,signal:n.signal,...t,headers:{Accept:`application/json`,...t.body?{"Content-Type":`application/json`}:{},...t.headers||{}}}),i=await r.json().catch(()=>({}));if(!r.ok){let e=Error(i.description||i.message||`Cart request failed (${r.status})`);throw e.status=r.status,r.status===422&&i.description&&(e.userMessage=i.description),e}return i}finally{clearTimeout(r)}}async function Fr(){if(Mr!==null)return Mr;if(typeof window>`u`)return Mr=!1;if(window.Shopify)return Mr=!0;try{let e=await Pr(`${Nr()}cart.js`);Mr=e&&typeof e.item_count==`number`}catch{Mr=!1}return Mr}async function Ir(){return Pr(`${Nr()}cart.js`)}function Lr(){return typeof window>`u`?null:window.__flowengageCustomer?.id||null}function Rr(e){return typeof e!=`number`||Number.isNaN(e)?null:(e/100).toFixed(2)}async function zr(){try{if(!await Fr())return null;let e=await Ir();return{itemCount:e.item_count,subtotal:Rr(e.items_subtotal_price),currency:e.currency||null,items:(e.items||[]).map(e=>({title:e.product_title||e.title,variantTitle:e.variant_title||null,quantity:e.quantity,linePrice:Rr(e.final_line_price??e.line_price),handle:e.handle||null}))}}catch{return null}}async function Br(e,t=null){let n=await Pr(`${Nr()}products/${encodeURIComponent(e)}.js`),r=n.variants||[];if(!r.length){let t=Error(`No variants for ${e}`);throw t.userMessage=`"${n.title||e}" has no purchasable options right now.`,t}let i=null;if(t){let e=t.toLowerCase();if(i=r.find(t=>(t.title||``).toLowerCase()===e)||r.find(t=>{let n=[t.title,...t.options||[]].join(` `).toLowerCase();return e.split(/[\s/,-]+/).filter(Boolean).every(e=>n.includes(e))}),!i){let e=Error(`Variant not found: ${t}`);throw e.userMessage=`I couldn't find a "${t}" option for ${n.title}. Available: ${r.map(e=>e.title).slice(0,6).join(`, `)}.`,e}}else i=r.find(e=>e.available)||r[0];if(!i.available){let e=Error(`Variant unavailable: ${i.title}`);throw e.userMessage=`Sorry — ${n.title}${i.title&&i.title!==`Default Title`?` (${i.title})`:``} is currently sold out.`,e}return{variant:i,product:n}}async function Vr(e,t=1){return Pr(`${Nr()}cart/add.js`,{method:`POST`,body:JSON.stringify({items:[{id:e,quantity:t}]})})}async function Hr(e,t){return Pr(`${Nr()}cart/change.js`,{method:`POST`,body:JSON.stringify({line:e,quantity:t})})}function Ur(){return`${Nr()}cart`}function Wr(){return`${Nr()}checkout`}function Gr(e){return`${Nr()}products/${encodeURIComponent(e)}`}async function Kr(e,t=6){let n=new URLSearchParams({q:e,"resources[type]":`product`,"resources[limit]":String(t)});try{return((await Pr(`${Nr()}search/suggest.json?${n.toString()}`))?.resources?.results?.products||[]).map(e=>({title:e.title,handle:e.handle,price:e.price||null,url:e.url||null}))}catch{return[]}}function qr(){return typeof window>`u`?!1:/\/cart\/?$/.test(window.location.pathname)}var Jr=[`form[action*="/cart"]`,`cart-items`,`cart-drawer-items`,`.cart-items`,`.cart__items`,`#main-cart-items`,`[data-cart-items]`].join(`, `);function Yr(e){if(/cart/i.test(e.id))return!0;try{return!!e.querySelector(Jr)}catch{return!1}}async function Xr(){if(typeof document>`u`)return!1;let e=Array.from(document.querySelectorAll(`[id^="shopify-section-"]`)).filter(Yr);if(!e.length)return!1;let t=e.map(e=>e.id.replace(/^shopify-section-/,``));try{let e=await Pr(`${window.location.pathname}?sections=${encodeURIComponent(t.join(`,`))}`),n=!1;for(let[t,r]of Object.entries(e||{})){if(!r||typeof r!=`string`)continue;let e=document.getElementById(`shopify-section-${t}`);if(!e)continue;let i=document.createElement(`div`);i.innerHTML=r;let a=i.querySelector(`#shopify-section-${t}`)||i.firstElementChild;a&&(e.innerHTML=a.innerHTML,n=!0)}return n}catch{return!1}}var Zr=[`[data-cart-count]`,`.cart-count-bubble`,`.cart-count`,`#CartCount`,`.cart-link__bubble`,`.site-header__cart-count`,`#cart-icon-bubble`];function Qr(e){if(typeof document>`u`)return;let t=String(e);for(let e of Zr)document.querySelectorAll(e).forEach(e=>{e.hasAttribute(`data-cart-count`)&&e.setAttribute(`data-cart-count`,t),e.querySelectorAll(`span, div, sup`).forEach(e=>{e.children.length===0&&/\d/.test(e.textContent||``)&&(e.textContent=(e.textContent||``).replace(/\d+/,t))}),e.children.length===0&&/^\s*\d+\s*$/.test(e.textContent||``)&&(e.textContent=t)})}function $r(e){if(typeof document>`u`)return;let t={cart:e,source:`flowengage`};[`cart:updated`,`cart:refresh`,`cart:change`,`cart-drawer:refresh`].forEach(e=>{try{document.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0}))}catch{}});try{window.dispatchEvent(new CustomEvent(`cart:refresh`,{detail:t}))}catch{}}async function ei(e){let t=await Xr();return!t&&qr()&&(await new Promise(e=>setTimeout(e,600)),t=await Xr()),e&&typeof e.item_count==`number`&&Qr(e.item_count),$r(e||null),{sectionsSwapped:t}}async function ti(e){try{let{sectionsSwapped:t}=await ei(e);if(!t&&qr())return` (The list on this page may need a quick refresh to show it.)`}catch{}return``}function ni(e){let t=Rr(e.items_subtotal_price),n=e.item_count;return t==null?``:` Your cart now has ${n} item${n===1?``:`s`} — subtotal ${t}${e.currency?` ${e.currency}`:``}.`}function ri(e,t){let n=t.title&&t.title!==`Default Title`;return`${e.title}${n?` (${t.title})`:``}`}function ii(e,t){return e?.userMessage||t}var ai={async add(e){let{variant:t,product:n}=await Br(e.productHandle,e.variantTitle||null);await Vr(t.id,e.quantity||1);let r=await Ir(),i=await ti(r);return{message:`✅ Added ${e.quantity||1} × ${ri(n,t)} to your cart.${ni(r)}${i}`}},async update(e){let t=(await Ir()).items?.[e.line-1];if(!t)return{message:`⚠️ I couldn't find item #${e.line} in your cart — it may have changed. Ask me "what's in my cart?" to see the current list.`};let n=await Hr(e.line,e.quantity),r=await ti(n);return{message:`✅ Updated ${t.product_title||t.title} to quantity ${e.quantity}.${ni(n)}${r}`}},async remove(e){let t=(await Ir()).items?.[e.line-1];if(!t)return{message:`⚠️ I couldn't find item #${e.line} in your cart — it may have changed. Ask me "what's in my cart?" to see the current list.`};let n=await Hr(e.line,0),r=await ti(n);return{message:`🗑️ Removed ${t.product_title||t.title} from your cart.${ni(n)}${r}`}},async view_cart(){return{message:`Opening your cart…`,navigateTo:Ur()}},async checkout(){return(await Ir()).item_count?{message:`Taking you to checkout…`,navigateTo:Wr()}:{message:`Your cart is empty — add something first and I'll take you straight to checkout.`}},async view_product(e){return{message:`Opening the product page…`,navigateTo:Gr(e.productHandle)}}},oi={add:`⚠️ I couldn't add that to your cart — please try from the product page.`,update:`⚠️ I couldn't update that cart item — please try again.`,remove:`⚠️ I couldn't remove that cart item — please try again.`,view_cart:`⚠️ I couldn't open the cart page.`,checkout:`⚠️ I couldn't start checkout — you can open the cart and check out from there.`,view_product:`⚠️ I couldn't open that product page.`};async function si(e){let t={messages:[],navigateTo:null};if(!Array.isArray(e)||e.length===0)return t;if(!await Fr())return t.messages.push(`⚠️ Cart actions only work on the store's own website — please try from the shop page.`),t;for(let n of e){let e=ai[n?.type];if(e)try{let r=await e(n);r.message&&t.messages.push(r.message),r.navigateTo&&(t.navigateTo=r.navigateTo)}catch(e){console.warn(`[FlowEngage:Cart] ${n.type} failed:`,e),t.messages.push(ii(e,oi[n.type]))}}return t}var ci=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=ci()}))(),li=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(),ui=(e=[])=>e.filter(e=>e.type!==`call_recording`&&!(typeof e.message==`string`&&e.message.includes(`AI chat recording`))).map(e=>({...e,message:li(e.message),isPending:!1,id:e.messageId||`${e.sender}-${e.timestamp||Date.now()}-${Math.random()}`}));function di(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 fi=(e,t)=>e?typeof e==`string`?e:e.message||e.error||e.reason||t:t,pi=(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}:{}}},mi=(e=[],t=`Agent`)=>{for(let t of e)if(typeof t==`string`&&t.trim())return t.trim();return t},hi=(e=[],t,n=6)=>!t?.message||e.slice(-n).some(e=>e.sender===`system`&&e.message===t.message)?e:[...e,t];function gi({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)(e=>{si(e).then(({messages:e,navigateTo:t})=>{e.length&&g(t=>[...t,...e.map((e,n)=>({id:`cart-${t.length+n}-${Math.random().toString(36).slice(2,8)}`,sender:`bot`,message:e,timestamp:new Date().toISOString()}))]),t&&setTimeout(()=>{window.location.assign(t)},900)})},[]),y=(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()}])},[]),[x,C]=(0,b.useState)(N().isOpen),[w,T]=(0,b.useState)(N().activeScreen),[E,k]=(0,b.useState)(N().isHumanHandled),[A,ie]=(0,b.useState)(N().agentName),[j,M]=(0,b.useState)(N().agentHeadshot),[ae,de]=(0,b.useState)(()=>le(i?.siteId)),[F,fe]=(0,b.useState)(!1),[me,I]=(0,b.useState)(!1),[he,ge]=(0,b.useState)(`idle`),[_e,ve]=(0,b.useState)(!1),[ye,be]=(0,b.useState)(!1),[Se,Ce]=(0,b.useState)(``),[we,Te]=(0,b.useState)(!1),[Ee,De]=(0,b.useState)(0),[Oe,ke]=(0,b.useState)(0),[Ae,L]=(0,b.useState)(!1),[R,Pe]=(0,b.useState)(null),[Fe,Ie]=(0,b.useState)(null),[Le,Re]=(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),z=(0,b.useRef)(null),Je=(0,b.useRef)(``),Ye=(0,b.useRef)(!1),Xe=(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)(null),rt=(0,b.useRef)(!1),it=(0,b.useRef)({url:null,at:0}),at=(0,b.useCallback)((e,t)=>{Bn(6e3);let n=e;try{n=new URL(e,window.location.origin).href}catch{}let r=it.current;return r.url===n&&Date.now()-r.at<4e3?Promise.resolve({navigated:!0,deduped:!0}):(it.current={url:n,at:Date.now()},Er(e,t))},[]),ot=(0,b.useRef)([]),B=(0,b.useRef)(null),st=(0,b.useRef)(null),ct=(0,b.useRef)(null),lt=(0,b.useRef)(!1),ut=(0,b.useRef)(!1),dt=(0,b.useRef)(``),ft=(0,b.useRef)(null),pt=(0,b.useRef)(null),mt=(0,b.useRef)([]),ht=(0,b.useRef)(0),gt=(0,b.useRef)(A),_t=(0,b.useRef)([]),vt=(0,b.useRef)(!1),yt=(0,b.useRef)(!1),bt=(0,b.useRef)(i),xt=(0,b.useRef)({notifyRouteChange:()=>{},cleanup:()=>{}}),St=(0,b.useCallback)((e={})=>{let t=!!e.is_human_handled;return k(t),t?(T(`agent`),e.agent_info?.name&&ie(e.agent_info.name),e.agent_info?.headshot&&M(e.agent_info.headshot),t):(T(`ai`),t)},[]),Ct=(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:D},[i,d]);(0,b.useEffect)(()=>{Ze.current=R},[R]),(0,b.useEffect)(()=>{gt.current=A},[A]),(0,b.useEffect)(()=>{yt.current=we},[we]),(0,b.useEffect)(()=>{bt.current=i},[i]);let wt=()=>{We(``)},Tt=(0,b.useCallback)(()=>{ct.current&&=(window.clearTimeout(ct.current),null)},[]),Et=e=>{let t=typeof e==`string`?e.trim().toLowerCase():``;return de(t),ue(t,i?.siteId),t};(0,b.useEffect)(()=>{let e=i?.siteId;if(!e)return;let t=le(e);if(t){de(t);return}de(t=>(t&&ue(t,e),t))},[i?.siteId]);let Dt=(e=`unspecified`)=>{let t=B.current||tt.current?.callId,n=ht.current,r=ft.current;if(ft.current=null,ht.current=0,r&&r.state!==`inactive`){r.onstop=()=>{let e=mt.current;if(mt.current=[],e.length>0&&t&&z.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;z.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,mt.current=[]}}else if(r&&r.state===`inactive`){let e=mt.current;if(mt.current=[],e.length>0&&t&&z.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;z.current.uploadRecording(t,r,i).then(e=>console.log(`[FlowEngageCall] recording upload success`,e)).catch(e=>console.warn(`[FlowEngageCall] recording upload failed`,e))}}else mt.current=[];if(pt.current){try{pt.current.close()}catch{}pt.current=null}Qe.current&&=(Qe.current.close(),null),$e.current&&=($e.current.getTracks().forEach(e=>e.stop()),null),et.current&&=(et.current.srcObject=null,et.current.remove(),null),Tt(),tt.current=null,ot.current=[],B.current=null,st.current=null,lt.current=!1,He(!1),Pe(null),Ie(null),Re(`idle`),Be(null)},Ot=(e=new Date().toISOString())=>{let t=qe.current,n=B.current||tt.current?.callId;if(!(!t?.connected||!n||lt.current)){lt.current=!0,t.emit(`call:connected`,{callId:n,chatId:Je.current,connectedAt:e});try{let e=$e.current,t=et.current?.srcObject;if(e&&t&&!ft.current){mt.current=[];let n=new(window.AudioContext||window.webkitAudioContext);pt.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&&mt.current.push(e.data)},ft.current=a,ht.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{}}},kt=(e={})=>{if(!e.callId)return;let t=st.current===e.callId,n=B.current===e.callId,r=Ze.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(Tt(),Pe(null),t||n){B.current=e.callId,Ie(e.callId),Re(e=>e===`connected`?e:`connecting`),C(!0);return}Re(`idle`)}},At=(e={})=>{if(!e.callId)return;let t=st.current===e.callId,n=B.current===e.callId,r=Ze.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(Tt(),n){Dt();return}st.current=null,tt.current=null,ot.current=[],Pe(null),Re(`idle`)}},jt=async(e={})=>{let t=Qe.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}),tt.current=e;return}if(await t.setRemoteDescription(new RTCSessionDescription({type:`offer`,sdp:r})),ot.current.length>0){console.log(`[FlowEngageProvider] flushing queued agent ICE candidates after remote offer`,{callId:e.callId,chatId:Je.current,queuedCount:ot.current.length});for(let e of ot.current)await t.addIceCandidate(new RTCIceCandidate(e));ot.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)(()=>{P({isOpen:x,activeScreen:w,isHumanHandled:E,agentName:A,agentHeadshot:j})},[x,w,E,A,j]),(0,b.useEffect)(()=>{let e=!0;return(async()=>{Ke(!0);try{let t=S(i),n=await Me(t);if(!e)return;let a=t.siteId,o=oe(a),s=pe(a),l=``;try{let e=Ye.current,r=Xe.current;if(Ye.current=!1,Xe.current=null,l=(await je({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:a,priorChatId:e||r?null:o||te(),forceNew:e,resumeChatId:r,visitorId:s}))?.data?.chatId,!l)throw Error(`resolve-session returned no chatId`);ne(),ce(a,l)}catch(e){console.warn(`[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id`,e?.message||e),l=o||re(),ce(a,l)}Je.current=l;let u=Ne({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:t.siteId,visitorId:s});z.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()=>{ge(`connected`);let e=Je.current;if(e&&z.current)try{St(await z.current.checkHumanHandled(e))}catch{}}),p.on(`disconnect`,()=>{ge(`disconnected`)}),p.on(`aiTyping`,()=>{I(!0)}),p.on(`ai:typing`,()=>{I(!0)}),p.on(`messageReceived`,e=>{let t=e.message||e,n={...t,message:li(t.message)};I(!1),fe(!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:li(t.message)};I(!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`)&&fe(!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)&&(k(!0),T(`agent`),ie(mi([n.agent_name,n.agentName,n.metadata?.agentName],d)),n.sender_headshot&&M(n.sender_headshot),C(!0),De(e=>e+1)))});let h=(e={})=>{let t=mi([e.agent?.name,e.agentName,e.agent_name,gt.current],d);k(!0),T(`agent`),ie(t),M(e.agent?.headshot||null),C(!0),De(e=>e+1),g(e=>hi(e,{id:`agent-joined-${Date.now()}`,sender:`system`,message:`${t} has joined the chat.`,timestamp:new Date().toISOString(),isPending:!1}))},v=(e={})=>{let t=mi([e.agent?.name,e.agentName,e.agent_name,gt.current],d);k(!1),T(`ai`),g(e=>hi(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`,v),p.on(`agentLeft`,v),p.on(`conversationEnded`,e=>{L(!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=ui(e.chat_history||[]);g(t),t.length===0&&(L(!1),k(!1),T(`ai`),I(!1),fe(!1))}),p.on(`conversation:reset`,()=>{g([]),L(!1),k(!1),T(`ai`),I(!1),fe(!1)}),p.on(`voice:end_session`,(e={})=>{console.log(`[FlowEngageProvider] voice:end_session received — ending voice session`),ke(e=>e+1),C(!0),De(e=>e+1)}),p.on(`typing:start`,e=>{e.sender===`agent`&&fe(!0)}),p.on(`typing:stop`,e=>{e.sender===`agent`&&fe(!1)}),p.on(`call:incoming`,(e={})=>{let t=mi([e.agentName,e.ownerName,e.agent?.name,gt.current],`Agent`);wt(),Tt(),lt.current=!1,Pe({callId:e.callId,from:e.from||`owner`,agentId:e.agentId||null,agentName:t}),ie(e=>mi([t,e],`Agent`)),Re(`incoming`),Be(null),C(!0)}),p.on(`call:offer`,async(e={})=>{tt.current=e;try{await jt(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=pi(e);if(!t){console.warn(`[FlowEngageProvider] ignoring invalid ICE candidate payload`,e);return}if(!Qe.current||!Qe.current.remoteDescription){console.log(`[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready`,{callId:e.callId,chatId:e.chatId||Je.current,queueSize:ot.current.length+1}),ot.current.push(t);return}await Qe.current.addIceCandidate(new RTCIceCandidate(t))}catch(e){console.error(`[FlowEngageProvider] failed to add ICE candidate`,e)}}),p.on(`call:ended`,()=>{wt(),Dt(`socket:call_ended`)}),p.on(`call:accepted`,(e={})=>{kt(e)}),p.on(`call:accepted_by_other`,(e={})=>{kt(e)}),p.on(`call:rejected`,(e={})=>{At(e)}),p.on(`call:missed`,(e={})=>{At(e)}),p.on(`call:failed`,(e={})=>{At(e)}),p.on(`call:connected`,(e={})=>{if(!e.callId)return;let t=st.current===e.callId,n=B.current===e.callId,r=tt.current?.callId===e.callId,i=Ze.current?.callId===e.callId;if(!t&&!n&&!r){i&&(Pe(null),Re(`idle`));return}lt.current=!0,st.current=null,B.current=e.callId,Ie(e.callId),Pe(null),Re(`connected`),Be(e.connectedAt||new Date().toISOString()),C(!0)}),p.on(`call:unavailable`,(e={})=>{Dt(`socket:call_unavailable`),We(fi(e,`This visitor is not available for a call right now.`)),C(!0)}),p.on(`call:error`,(e={})=>{Dt(`socket:call_error`),We(fi(e,`We couldn't connect the call right now.`)),C(!0)}),p.on(`visitor:navigate`,async({url:e,section:t,highlight:n}={})=>{e&&at(e,{voiceActive:yt.current}).then(({navigated:e,reason:r})=>{if(!e){r===`not-found`?_():r===`already-on-page`&&y();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()}),xt.current=Sn({socket:p,chatId:l});let b=await u.loadHistory(l,r);if(!e)return;g(ui(b.chat_history||[])),k(!!b.is_human_handled),T(b.is_human_handled?`agent`:w);let x=b?.visitor_email||b?.visitorEmail;if(x&&String(x).trim()&&Et(String(x).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,xt.current?.cleanup?.(),Dt(),qe.current?.disconnect()}},[i,r,a]),(0,b.useEffect)(()=>()=>{if(we&&!vt.current&&_t.current.length>0){let e=Je.current,t=_t.current,n=z.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(()=>{}),vt.current=!0)}},[we,d]);let Mt=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=z.current;!e||!p||Mt.current!==x&&(x&&Mt.current!==null?e.updateChatStatus(p,`open`).catch(()=>{}):Mt.current===!0&&e.updateChatStatus(p,`widget_closed`).catch(()=>{}),Mt.current=x)},[x,p]),(0,b.useEffect)(()=>{let e=()=>{let e=Je.current,t=z.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 Nt=async()=>{if(!(!R?.callId||!z.current||!qe.current||!p)){wt(),st.current=R.callId,Tt();try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});$e.current=e;let t=[{urls:`stun:stun.l.google.com:19302`}];try{let e=await z.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});Qe.current=n,n.onconnectionstatechange=()=>{let e=n.connectionState;if(e===`connected`){let e=new Date().toISOString();Re(`connected`),Be(t=>t||e),Ot(e);return}if(e===`connecting`){Re(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&Dt(`peer:connection_${e}`)},n.oniceconnectionstatechange=()=>{let e=n.iceConnectionState;if(e===`connected`||e===`completed`){let e=new Date().toISOString();Re(`connected`),Be(t=>t||e),Ot(e);return}if(e===`checking`||e===`new`){Re(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&Dt(`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:R.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(!et.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=>{},et.current=e,document.body.appendChild(e)}et.current.srcObject=e.streams[0];let r=R?.callId,i=r&&(st.current===r||B.current===r);if(!lt.current&&i){let e=new Date().toISOString();Re(`connected`),Be(t=>t||e),B.current=r,Ie(r),Ot(e)}et.current.srcObject=t||null;let a=et.current.play?.();a?.catch&&a.catch(e=>{})};let r=tt.current;r&&(console.log(`[FlowEngageProvider] found pending remote offer during accept`,{callId:r.callId||R.callId,chatId:p}),await jt({...r,callId:r.callId||R.callId})),await z.current.acceptCall(R.callId,p),qe.current?.emit(`call:accepted`,{callId:R.callId,chatId:p}),B.current=R.callId,Ie(R.callId),Re(e=>e===`connected`||lt.current?`connected`:`connecting`),Pe(null),C(!0)}catch(e){if(st.current=null,Dt(`accept_call_failed`),e?.status===404||e?.status===409||e?.status===422){We(fi(e,`This visitor call is no longer available.`));return}if(e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`){try{await z.current.rejectCall(R.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.`)}}},Pt=async()=>{if(!R?.callId||!z.current||!p){Dt(`reject_call_without_server_context`);return}let e=R.callId;Tt(),wt(),qe.current?.emit(`call:rejected`,{callId:e,chatId:p,reason:`visitor_declined`});try{await z.current.rejectCall(e,p)}catch(e){We(fi(e,`We couldn't decline the call cleanly.`))}finally{Dt(`reject_call_finally`)}},Ft=(0,b.useRef)(Pt);Ft.current=Pt,(0,b.useEffect)(()=>{if(!R?.callId||Fe){Tt();return}let e=R.callId;return Tt(),ct.current=window.setTimeout(()=>{Ze.current?.callId===e&&st.current!==e&&B.current!==e&&Ft.current()},O),()=>{ct.current&&=(window.clearTimeout(ct.current),null)}},[Fe,Tt,R?.callId]);let It=async()=>{if(!Fe||!z.current||!p){Dt(`end_call_without_server_context`);return}wt();try{await z.current.endWebRTCCall(Fe,p)}catch(e){We(fi(e,`The call ended locally, but the server could not be updated.`))}finally{Dt(`end_call_finally`)}},Lt=()=>{let e=$e.current?.getAudioTracks?.()||[],t=Qe.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)},Rt=async(e={})=>{let t=e.notifyChatInitiated===!0;if(C(!0),!(!t||!z.current||!p||typeof window>`u`)){try{await z.current.trackVisitor({chatId:p,currentPagePath:window.location.pathname||`/`})}catch{}try{await z.current.updateChatStatus(p,`open`)}catch{}}},zt=async e=>{let t=Et(e);if(!t||!z.current||!Je.current)return t;try{await z.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},Bt=()=>{!p||!qe.current?.connected||ut.current||(ut.current=!0,qe.current.emit(`typing:start`,{chatId:p,sender:`user`}))},Vt=()=>{!p||!qe.current?.connected||!ut.current||(ut.current=!1,qe.current.emit(`typing:stop`,{chatId:p,sender:`user`}))},Ht=(e=``)=>{let t=typeof e==`string`?e:``;!p||!qe.current?.connected||t!==``&&dt.current===t||(dt.current=t,qe.current.emit(`typing:update`,{chatId:p,sender:`user`,text:t}))};function Ut(){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 Wt=async(e,t=``,n=null,i={})=>{let a=typeof e==`string`?e.trim():``;if(!a||!z.current||!p||s!==`ready`||Ae)return;Vt(),rt.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(nt.current&&o.test(a)&&!c.test(a)){let{url:e,section:t}=nt.current;nt.current=null,rt.current=!0,console.log(`[FWH Nav] Client-side nav firing →`,e),at(e,{voiceActive:yt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&y();return}!t||!yt.current||setTimeout(()=>{let e=ur(null,t);e&&dr(e)},300)})}else o.test(a)||(nt.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=E;if(m)try{m=St(await z.current.checkHumanHandled(p))}catch{}if(m&&qe.current?.connected){qe.current.emit(`customer:message`,{chatId:p,content:e,sender:`user`,email:ae||void 0,type:i?.type||`text`,metadata:i?.metadata||{},...n||{}});return}ve(!0);try{let o=await zr(),s=Lr(),c=`stream-preview-${Date.now().toString(36)}`,u=e=>{I(!1),g(t=>{let n=t.findIndex(e=>e.id===c);if(n===-1)return[...t,{id:c,sender:`bot`,message:e,timestamp:new Date().toISOString(),isStreaming:!0}];let r=[...t];return r[n]={...r[n],message:r[n].message+e},r})},d=await z.current.sendAiMessage(p,e,r,t,{...n||{},...ae?{email:ae}:{}},{...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:Ut()||void 0,...o?{shopifyCart:o}:{},...s?{shopifyCustomerId:s}:{}},u),f=d.chat_history||[];if(console.log(`[FWH Nav Debug] API response fields:`,{has_navigate:!!d.navigate,navigate:d.navigate,has_pending_navigate:!!d.pending_navigate,pending_navigate:d.pending_navigate,last_bot_msg:[...f].reverse().find(e=>e.sender===`bot`)?.message?.substring(0,80)}),d.pending_navigate?.url){let e={url:d.pending_navigate.url,section:d.pending_navigate.section||null};l.test(a)?(console.log(`[FWH Nav] Auto-navigating (intent detected) →`,e.url),at(e.url,{voiceActive:yt.current}).then(({navigated:t,reason:n})=>{if(!t){n===`not-found`?_():n===`already-on-page`&&y();return}e.section&&setTimeout(()=>{let t=ur(null,e.section);t&&dr(t)},300)})):(nt.current=e,console.log(`[FWH Nav] Stored pending nav →`,nt.current))}if(d.navigate?.url)if(rt.current)rt.current=!1;else{let{url:e,section:t}=d.navigate;at(e,{voiceActive:yt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&y();return}t&&setTimeout(()=>{let e=ur(null,t);e&&dr(e)},300)})}else if(d.highlight?.section){let e=d.highlight.section;setTimeout(()=>{let t=ur(null,e);t&&dr(t)},150)}else{let e=[...f].reverse().find(e=>e.sender===`bot`||e.sender===`assistant`);if(e?.message){let t=di(e.message);t&&hr(t.url,{siteId:bt.current?.siteId,apiBaseUrl:bt.current?.apiBaseUrl}).then(({allowed:e,correctedUrl:n})=>{if(!e){_();return}at(n||t.url,{voiceActive:yt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&y();return}!t.section||!yt.current||setTimeout(()=>{let e=ur(null,t.section);e&&dr(e)},300)})})}}g(ui(f)),Array.isArray(d.cart_actions)&&d.cart_actions.length&&v(d.cart_actions),k(!!d.is_human_handled),T(d.is_human_handled?`agent`:`ai`),I(!1),ve(!1),await z.current.updateChatStatus(p,`messageSent`)}catch(e){g(e=>e.filter(e=>e.id!==d&&!e.isStreaming)),I(!1),ve(!1),e.status===429?(be(!0),Ce(e.message),window.setTimeout(()=>{be(!1),Ce(``)},ee)):u(e)}},Gt=async e=>{if(!z.current||!e)throw Error(`Upload is unavailable right now.`);return z.current.uploadChatFile(e)},Kt=async e=>{if(!(!z.current||!p)){try{let t=e?`voice`:`text`;await z.current.setChatMode(p,t)}catch{}Te(e),e&&(vt.current=!1)}},qt=async e=>{if(vt.current)return;if(vt.current=!0,!z.current||!p||!e?.length){Te(!1);return}let t=()=>{let t=ui(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 z.current.syncVoice(p,e);if(n?.chat_history?.length)g(ui(n.chat_history));else if(n?.success)try{let e=await z.current.loadHistory(p,r);e?.chat_history?.length?g(ui(e.chat_history)):t()}catch{t()}else t()}catch{t()}finally{Te(!1)}},Jt=async()=>{if(!(!z.current||!p)){we&&!vt.current&&_t.current.length>0&&await qt(_t.current);try{await z.current.endConversation(p)}catch{try{await z.current.updateChatStatus(p,`ended`)}catch{}}L(!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(Le!==`connected`||!Fe||!p||!ze||!Ct)return;let e=new Date(ze).getTime(),t=Number.isFinite(e)?Date.now()-e:0,n=Math.max(0,Ct*1e3-t),r=window.setTimeout(()=>{We(`The call ended because it reached the time limit.`),It()},n);return()=>window.clearTimeout(r)},[Fe,ze,Le,p,It,Ct]),(0,b.useEffect)(()=>{let e=()=>{let e=Je.current,t=z.current;if(!t||!e)return;if(yt.current&&_t.current.length>0&&xe(),!vt.current&&_t.current.length>0&&(t.beaconSyncVoice(e,_t.current)||t.syncVoice(e,_t.current).catch(()=>{}),vt.current=!0),B.current){t.beaconEndWebRTCCall(B.current,e);return}let n=st.current||Ze.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 Yt=(0,b.useCallback)(()=>{let e=i?.siteId;se(e),Ye.current=!0,Xe.current=null,qe.current?.disconnect(),g([]),m(``),Je.current=``,L(!1),k(!1),ie(null),M(null),Ke(!0),o(e=>e+1)},[i?.siteId]),Xt=(0,b.useCallback)(e=>{i?.siteId,Ye.current=!1,Xe.current=e,qe.current?.disconnect(),g([]),m(``),Je.current=``,L(!1),k(!1),ie(null),M(null),Ke(!0),o(e=>e+1)},[i?.siteId]),Zt=(0,b.useMemo)(()=>({status:s,error:l,runtimeConfig:d,resolvedConfig:i,chatId:p,chatHistory:h,isOpen:x,activeScreen:w,isHumanHandled:E,agentName:A,agentHeadshot:j,visitorEmail:ae,isAgentTyping:F,isAiTyping:me,connectionStatus:he,isLoading:_e,isVoiceMode:we,isRateLimited:ye,rateLimitMessage:Se,isConversationEnded:Ae,isSessionRestoring:Ge,openToChatCounter:Ee,voiceEndCounter:Oe,incomingCall:R,activeCallId:Fe,callConnectionState:Le,callConnectedAt:ze,isCallMuted:Ve,webRTCError:Ue,language:r,historyRef:_t,hasSyncedRef:vt,dismissCallError:wt,captureVisitorEmail:zt,startTyping:Bt,stopTyping:Vt,updateTypingDraft:Ht,notifyRouteChange:()=>xt.current?.notifyRouteChange?.(),openWidget:Rt,closeWidget:()=>C(!1),toggleWidget:()=>{if(x){C(!1);return}Rt({notifyChatInitiated:!0})},sendMessage:Wt,uploadChatFile:Gt,setVoiceMode:Kt,onMessageSync:qt,endConversation:Jt,startNewChat:Yt,resumeChat:Xt,getVisitorChatHistory:()=>z.current?.getVisitorChatHistory?.(),getVisitorChatThread:e=>z.current?.getVisitorChatThread?.(e),acceptCall:Nt,rejectCall:Pt,endWebRTCCall:It,toggleCallMute:Lt}),[s,l,d,i,p,h,x,w,E,A,j,ae,F,me,he,_e,we,ye,Se,Ae,Ge,Ee,Oe,R,Fe,Le,ze,Ve,Ue,r,zt,Bt,Vt,Ht,Nt,Pt,It,Lt,Rt,Wt,Gt,Kt,qt,Jt,Yt,wt]);return(0,H.jsx)(Cn.Provider,{value:Zt,children:n})}var _i=(0,b.createContext)({});function vi(e){let t=(0,b.useRef)(null);return t.current===null&&(t.current=e()),t.current}var yi=typeof window<`u`?b.useLayoutEffect:b.useEffect,bi=(0,b.createContext)(null);function xi(e,t){e.indexOf(t)===-1&&e.push(t)}function Si(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Ci=(e,t,n)=>n>t?t:n<e?e:n,wi={},Ti=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Ei(e){return typeof e==`object`&&!!e}var Di=e=>/^0[^.\s]+$/u.test(e);function Oi(e){let t;return()=>(t===void 0&&(t=e()),t)}var ki=e=>e,Ai=(e,t)=>n=>t(e(n)),U=(...e)=>e.reduce(Ai),ji=(e,t,n)=>{let r=t-e;return r===0?1:(n-e)/r},Mi=class{constructor(){this.subscriptions=[]}add(e){return xi(this.subscriptions,e),()=>Si(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}},Ni=e=>e*1e3,Pi=e=>e/1e3;function Fi(e,t){return t?1e3/t*e:0}var Ii=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Li=1e-7,Ri=12;function zi(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=Ii(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>Li&&++s<Ri);return o}function Bi(e,t,n,r){if(e===t&&n===r)return ki;let i=t=>zi(t,0,1,e,n);return e=>e===0||e===1?e:Ii(i(e),t,r)}var Vi=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Hi=e=>t=>1-e(1-t),Ui=Bi(.33,1.53,.69,.99),Wi=Hi(Ui),Gi=Vi(Wi),Ki=e=>e>=1?1:(e*=2)<1?.5*Wi(e):.5*(2-2**(-10*(e-1))),qi=e=>1-Math.sin(Math.acos(e)),Ji=Hi(qi),Yi=Vi(qi),Xi=Bi(.42,0,1,1),Zi=Bi(0,0,.58,1),Qi=Bi(.42,0,.58,1),$i=e=>Array.isArray(e)&&typeof e[0]!=`number`,ea=e=>Array.isArray(e)&&typeof e[0]==`number`,ta={linear:ki,easeIn:Xi,easeInOut:Qi,easeOut:Zi,circIn:qi,circInOut:Yi,circOut:Ji,backIn:Wi,backInOut:Gi,backOut:Ui,anticipate:Ki},na=e=>typeof e==`string`,ra=e=>{if(ea(e)){e.length;let[t,n,r,i]=e;return Bi(t,n,r,i)}else if(na(e))return ta[e],`${e}`,ta[e];return e},ia=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`],aa={value:null,addProjectionMetrics:null};function oa(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&&aa.value&&aa.value.frameloop[t].push(c),c=0,n.clear(),i=!1,a&&(a=!1,u.process(e))}};return u}var sa=40;function ca(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=ia.reduce((e,n)=>(e[n]=oa(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=wi.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,sa),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:ia.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<ia.length;t++)o[ia[t]].cancel(e)},state:i,steps:o}}var{schedule:W,cancel:la,state:ua,steps:da}=ca(typeof requestAnimationFrame<`u`?requestAnimationFrame:ki,!0),fa;function pa(){fa=void 0}var ma={now:()=>(fa===void 0&&ma.set(ua.isProcessing||wi.useManualTiming?ua.timestamp:performance.now()),fa),set:e=>{fa=e,queueMicrotask(pa)}},ha={layout:0,mainThread:0,waapi:0},ga=e=>t=>typeof t==`string`&&t.startsWith(e),_a=ga(`--`),va=ga(`var(--`),ya=e=>va(e)?ba.test(e.split(`/*`)[0].trim()):!1,ba=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function xa(e){return typeof e==`string`?e.split(`/*`)[0].includes(`var(--`):!1}var Sa={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Ca={...Sa,transform:e=>Ci(0,1,e)},wa={...Sa,default:1},Ta=e=>Math.round(e*1e5)/1e5,Ea=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Da(e){return e==null}var Oa=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ka=(e,t)=>n=>!!(typeof n==`string`&&Oa.test(n)&&n.startsWith(e)||t&&!Da(n)&&Object.prototype.hasOwnProperty.call(n,t)),Aa=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Ea);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},ja=e=>Ci(0,255,e),Ma={...Sa,transform:e=>Math.round(ja(e))},Na={test:ka(`rgb`,`red`),parse:Aa(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Ma.transform(e)+`, `+Ma.transform(t)+`, `+Ma.transform(n)+`, `+Ta(Ca.transform(r))+`)`};function Pa(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 Fa={test:ka(`#`),parse:Pa,transform:Na.transform},Ia=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),La=Ia(`deg`),Ra=Ia(`%`),G=Ia(`px`),za=Ia(`vh`),Ba=Ia(`vw`),Va={...Ra,parse:e=>Ra.parse(e)/100,transform:e=>Ra.transform(e*100)},Ha={test:ka(`hsl`,`hue`),parse:Aa(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+Ra.transform(Ta(t))+`, `+Ra.transform(Ta(n))+`, `+Ta(Ca.transform(r))+`)`},Ua={test:e=>Na.test(e)||Fa.test(e)||Ha.test(e),parse:e=>Na.test(e)?Na.parse(e):Ha.test(e)?Ha.parse(e):Fa.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Na.transform(e):Ha.transform(e),getAnimatableNone:e=>{let t=Ua.parse(e);return t.alpha=0,Ua.transform(t)}},Wa=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Ga(e){return isNaN(e)&&typeof e==`string`&&(e.match(Ea)?.length||0)+(e.match(Wa)?.length||0)>0}var Ka=`number`,qa=`color`,Ja=`var`,Ya=`var(`,Xa="${}",Za=/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 Qa(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(Za,e=>(Ua.test(e)?(r.color.push(a),i.push(qa),n.push(Ua.parse(e))):e.startsWith(Ya)?(r.var.push(a),i.push(Ja),n.push(e)):(r.number.push(a),i.push(Ka),n.push(parseFloat(e))),++a,Xa)).split(Xa),indexes:r,types:i}}function $a(e){return Qa(e).values}function eo({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===Ka?i+=Ta(r[a]):e===qa?i+=Ua.transform(r[a]):i+=r[a]}return i}}function to(e){return eo(Qa(e))}var no=e=>typeof e==`number`?0:Ua.test(e)?Ua.getAnimatableNone(e):e,ro=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:no(e);function io(e){let t=Qa(e);return eo(t)(t.values.map((e,n)=>ro(e,t.split[n])))}var ao={test:Ga,parse:$a,createTransformer:to,getAnimatableNone:io};function oo(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 K({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=oo(s,r,e+1/3),a=oo(s,r,e),o=oo(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function so(e,t){return n=>n>0?t:e}var q=(e,t,n)=>e+(t-e)*n,co=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},lo=[Fa,Na,Ha],uo=e=>lo.find(t=>t.test(e));function fo(e){let t=uo(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===Ha&&(n=K(n)),n}var po=(e,t)=>{let n=fo(e),r=fo(t);if(!n||!r)return so(e,t);let i={...n};return e=>(i.red=co(n.red,r.red,e),i.green=co(n.green,r.green,e),i.blue=co(n.blue,r.blue,e),i.alpha=q(n.alpha,r.alpha,e),Na.transform(i))},mo=new Set([`none`,`hidden`]);function ho(e,t){return mo.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function go(e,t){return n=>q(e,t,n)}function _o(e){return typeof e==`number`?go:typeof e==`string`?ya(e)?so:Ua.test(e)?po:xo:Array.isArray(e)?vo:typeof e==`object`?Ua.test(e)?po:yo:so}function vo(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>_o(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function yo(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=_o(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function bo(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 xo=(e,t)=>{let n=ao.createTransformer(t),r=Qa(e),i=Qa(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?mo.has(e)&&!i.values.length||mo.has(t)&&!r.values.length?ho(e,t):U(vo(bo(r,i),i.values),n):(`${e}${t}`,so(e,t))};function So(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?q(e,t,n):_o(e)(e,t)}var Co=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>W.update(t,e),stop:()=>la(t),now:()=>ua.isProcessing?ua.timestamp:ma.now()}},wo=(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)})`},To=2e4;function Eo(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 Do(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(Eo(r),To);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:Pi(i)}}var Oo={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 ko(e,t){return e*Math.sqrt(1-t*t)}var Ao=12;function jo(e,t,n){let r=n;for(let n=1;n<Ao;n++)r-=e(r)/t(r);return r}var Mo=.001;function No({duration:e=Oo.duration,bounce:t=Oo.bounce,velocity:n=Oo.velocity,mass:r=Oo.mass}){let i,a;Oo.maxDuration;let o=1-t;o=Ci(Oo.minDamping,Oo.maxDamping,o),e=Ci(Oo.minDuration,Oo.maxDuration,Pi(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=ko(t,o),c=Math.exp(-i);return Mo-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=ko(t**2,o);return(-i(t)+Mo>0?-1:1)*((a-s)*c)/l}):(i=t=>{let r=Math.exp(-t*e),i=(t-n)*e+1;return-Mo+r*i},a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=jo(i,a,s);if(e=Ni(e),isNaN(c))return{stiffness:Oo.stiffness,damping:Oo.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var Po=[`duration`,`bounce`],Fo=[`stiffness`,`damping`,`mass`];function Io(e,t){return t.some(t=>e[t]!==void 0)}function Lo(e){let t={velocity:Oo.velocity,stiffness:Oo.stiffness,damping:Oo.damping,mass:Oo.mass,isResolvedFromDuration:!1,...e};if(!Io(e,Fo)&&Io(e,Po))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Ci(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Oo.mass,stiffness:i,damping:a}}else{let n=No({...e,velocity:0});t={...t,...n,mass:Oo.mass},t.isResolvedFromDuration=!0}return t}function Ro(e=Oo.visualDuration,t=Oo.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}=Lo({...n,velocity:-Pi(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=Pi(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?Oo.restSpeed.granular:Oo.restSpeed.default,i||=v?Oo.restDelta.granular:Oo.restDelta.default;let y,b,x,S,C,w;if(h<1)x=ko(_,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=>Ni(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=Ni(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=Ni(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(Eo(T),To),t=wo(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}Ro.applyToOptions=e=>{let t=Do(e,100,Ro);return e.ease=t.ease,e.duration=Ni(t.duration),e.type=`keyframes`,e};var zo=5;function Bo(e,t,n){let r=Math.max(t-zo,0);return Fi(n-e(r),t-r)}function Vo({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=Ro({keyframes:[f.value,m(f.value)],velocity:Bo(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 Ho(e,t,n){let r=[],i=n||wi.mix||So,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=U(Array.isArray(t)?t[n]||ki:t,a)),r.push(a)}return r}function Uo(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=Ho(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=ji(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Ci(e[0],e[a-1],t)):l}function Wo(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=ji(0,t,r);e.push(q(n,1,i))}}function Go(e){let t=[0];return Wo(t,e.length-1),t}function Ko(e,t){return e.map(e=>e*t)}function qo(e,t){return e.map(()=>t||Qi).splice(0,e.length-1)}function Jo({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=$i(r)?r.map(ra):ra(r),a={done:!1,value:t[0]},o=Uo(Ko(n&&n.length===t.length?n:Go(t),e),t,{ease:Array.isArray(i)?i:qo(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var Yo=e=>e!==null;function Xo(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(Yo),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var Zo={decay:Vo,inertia:Vo,tween:Jo,keyframes:Jo,spring:Ro};function Qo(e){typeof e.type==`string`&&(e.type=Zo[e.type])}var $o=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)}},es=e=>e/100,ts=class extends $o{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!==ma.now()&&this.tick(ma.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},ha.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;Qo(e);let{type:t=Jo,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||Jo;s!==Jo&&typeof o[0]!=`number`&&(this.mixKeyframes=U(es,So(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=Eo(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=Ci(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!==Vo&&(b.value=Xo(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 Pi(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Pi(e)}get time(){return Pi(this.currentTime)}set time(e){e=Ni(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 Bo(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(ma.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=Pi(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Co,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(ma.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,ha.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 ns(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var rs=e=>e*180/Math.PI,is=e=>os(rs(Math.atan2(e[1],e[0]))),as={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:is,rotateZ:is,skewX:e=>rs(Math.atan(e[1])),skewY:e=>rs(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},os=e=>(e%=360,e<0&&(e+=360),e),ss=is,cs=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),ls=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),us={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:cs,scaleY:ls,scale:e=>(cs(e)+ls(e))/2,rotateX:e=>os(rs(Math.atan2(e[6],e[5]))),rotateY:e=>os(rs(Math.atan2(-e[2],e[0]))),rotateZ:ss,rotate:ss,skewX:e=>rs(Math.atan(e[4])),skewY:e=>rs(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function ds(e){return e.includes(`scale`)?1:0}function fs(e,t){if(!e||e===`none`)return ds(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=us,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=as,i=t}if(!i)return ds(t);let a=r[t],o=i[1].split(`,`).map(ms);return typeof a==`function`?a(o):o[a]}var ps=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return fs(n,t)};function ms(e){return parseFloat(e.trim())}var hs=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],gs=new Set(hs),_s=e=>e===Sa||e===G,vs=new Set([`x`,`y`,`z`]),ys=hs.filter(e=>!vs.has(e));function bs(e){let t=[];return ys.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith(`scale`)?1:0))}),t}var xs={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})=>fs(t,`x`),y:(e,{transform:t})=>fs(t,`y`)};xs.translateX=xs.x,xs.translateY=xs.y;var Ss=new Set,Cs=!1,ws=!1,Ts=!1;function Es(){if(ws){let e=Array.from(Ss).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=bs(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)})}ws=!1,Cs=!1,Ss.forEach(e=>e.complete(Ts)),Ss.clear()}function Ds(){Ss.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(ws=!0)})}function Os(){Ts=!0,Ds(),Es(),Ts=!1}var ks=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?(Ss.add(this),Cs||(Cs=!0,W.read(Ds),W.resolveKeyframes(Es))):(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])}ns(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ss.delete(this)}cancel(){this.state===`scheduled`&&(Ss.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},As=e=>e.startsWith(`--`);function js(e,t,n){As(t)?e.style.setProperty(t,n):e.style[t]=n}var Ms={};function Ns(e,t){let n=Oi(e);return()=>Ms[t]??n()}var Ps=Ns(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),Fs=Ns(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),Is=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Ls={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:Is([0,.65,.55,1]),circOut:Is([.55,0,1,.45]),backIn:Is([.31,.01,.66,-.59]),backOut:Is([.33,1.53,.69,.99])};function Rs(e,t){if(e)return typeof e==`function`?Fs()?wo(e,t):`ease-out`:ea(e)?Is(e):Array.isArray(e)?e.map(e=>Rs(e,t)||Ls.easeOut):Ls[e]}function zs(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=Rs(s,i);Array.isArray(d)&&(u.easing=d),aa.value&&ha.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 aa.value&&p.finished.finally(()=>{ha.waapi--}),p}function Bs(e){return typeof e==`function`&&`applyToOptions`in e}function Vs({type:e,...t}){return Bs(e)&&Fs()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var Hs=class extends $o{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=Vs(e);this.animation=zs(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=Xo(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),js(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 Pi(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Pi(e)}get time(){return Pi(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Ni(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&&Ps()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),ki):r(this)}},Us={anticipate:Ki,backInOut:Gi,circInOut:Yi};function Ws(e){return e in Us}function Gs(e){typeof e.ease==`string`&&Ws(e.ease)&&(e.ease=Us[e.ease])}var Ks=10,qs=class extends Hs{constructor(e){Gs(e),Qo(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 ts({...a,autoplay:!1}),s=Math.max(Ks,ma.now()-this.startTime),c=Ci(0,Ks,s-Ks),l=o.sample(s).value,{name:u}=this.options;i&&u&&js(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},Js=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(ao.test(e)||e===`0`)&&!e.startsWith(`url(`));function Ys(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 Xs(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=Js(i,t),s=Js(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:Ys(e)||(n===`spring`||Bs(n))&&r}function Zs(e){e.duration=0,e.type=`keyframes`}var Qs=new Set([`opacity`,`clipPath`,`filter`,`transform`]),$s=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function ec(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&$s.test(e[t]))return!0;return!1}var tc=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),nc=Oi(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function rc(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 nc()&&n&&(Qs.has(n)||tc.has(n)&&ec(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var ic=40,ac=class extends $o{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=ma.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||ks)(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=ma.now();let u=!0;Xs(e,i,a,o)||(u=!1,(wi.instantAnimations||!s)&&l?.(Xo(e,n,t)),e[0]=e[e.length-1],Zs(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>ic?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&rc(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new qs({...d,element:p})}catch{m=new ts(d)}else m=new ts(d);m.finished.then(()=>{this.notifyFinished()}).catch(ki),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(),Os()),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 oc(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 sc=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function cc(e){let t=sc.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function lc(e,t,n=1){`${e}`;let[r,i]=cc(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Ti(e)?parseFloat(e):e}return ya(i)?lc(i,t,n+1):i}var uc={type:`spring`,stiffness:500,damping:25,restSpeed:10},dc=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),fc={type:`keyframes`,duration:.8},pc={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},mc=(e,{keyframes:t})=>t.length>2?fc:gs.has(e)?e.startsWith(`scale`)?dc(t[1]):uc:pc;function hc(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function gc(e,t){let n=e?.[t]??e?.default??e;return n===e?n:hc(n,e)}var _c=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function vc(e){for(let t in e)if(!_c.has(t))return!0;return!1}var yc=(e,t,n,r={},i,a)=>o=>{let s=gc(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=Ni(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};vc(s)||Object.assign(u,mc(e,u)),u.duration&&=Ni(u.duration),u.repeatDelay&&=Ni(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(Zs(u),u.delay===0&&(d=!0)),(wi.instantAnimations||wi.skipAnimations||i?.shouldSkipAnimations)&&(d=!0,Zs(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=Xo(u.keyframes,s);if(e!==void 0){W.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new ts(u):new ac(u)};function bc(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function xc(e,t,n,r){if(typeof t==`function`){let[i,a]=bc(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]=bc(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Sc(e,t,n){let r=e.getProps();return xc(r,t,n===void 0?r.custom:n,e)}var Cc=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...hs]),wc=30,Tc=e=>!isNaN(parseFloat(e)),Ec={current:void 0},Dc=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=ma.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=ma.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Tc(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 Mi);let n=this.events[e].add(t);return e===`change`?()=>{n(),W.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 Ec.current&&Ec.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=ma.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>wc)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,wc);return Fi(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 Oc(e,t){return new Dc(e,t)}var kc=e=>Array.isArray(e);function Ac(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Oc(n))}function jc(e){return kc(e)?e[e.length-1]||0:e}function Mc(e,t){let{transitionEnd:n={},transition:r={},...i}=Sc(e,t)||{};i={...i,...n};for(let t in i)Ac(e,t,jc(i[t]))}var Nc=e=>!!(e&&e.getVelocity);function Pc(e){return!!(Nc(e)&&e.add)}function Fc(e,t){let n=e.getValue(`willChange`);if(Pc(n))return n.add(t);if(!n&&wi.WillChange){let n=new wi.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function Ic(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var Lc=`data-`+Ic(`framerAppearId`);function Rc(e){return e.props[Lc]}function zc({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function Bc(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?hc(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&&zc(d,t))continue;let o={delay:n,...gc(a||{},t)},c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){W.update(()=>r.set(i));continue}let f=!1;if(window.MotionHandoffAnimation){let n=Rc(e);if(n){let e=window.MotionHandoffAnimation(n,t,W);e!==null&&(o.startTime=e,f=!0)}}Fc(e,t);let p=l??e.shouldReduceMotion;r.start(yc(t,r,i,p&&Cc.has(t)?{type:!1}:o,e,f));let m=r.animation;m&&u.push(m)}if(o){let t=()=>W.update(()=>{o&&Mc(e,o)});u.length?Promise.all(u).then(t):t()}return u}function Vc(e,t,n={}){let r=Sc(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(Bc(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return Hc(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 Hc(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(Vc(c,t,{...o,delay:n+(typeof r==`function`?0:r)+oc(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function Uc(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>Vc(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=Vc(e,t,n);else{let i=typeof t==`function`?Sc(e,t,n.custom):t;r=Promise.all(Bc(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var Wc={test:e=>e===`auto`,parse:e=>e},Gc=e=>t=>t.test(e),Kc=[Sa,G,Ra,La,Ba,za,Wc],qc=e=>Kc.find(Gc(e));function Jc(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||Di(e)}var Yc=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function Xc(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Ea)||[];if(!r)return e;let i=n.replace(r,``),a=Yc.has(t)?1:0;return r!==n&&(a*=100),t+`(`+a+i+`)`}var Zc=/\b([a-z-]*)\(.*?\)/gu,Qc={...ao,getAnimatableNone:e=>{let t=e.match(Zc);return t?t.map(Xc).join(` `):e}},$c={...ao,getAnimatableNone:e=>{let t=ao.parse(e);return ao.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},el={...Sa,transform:Math.round},tl={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:La,rotateX:La,rotateY:La,rotateZ:La,scale:wa,scaleX:wa,scaleY:wa,scaleZ:wa,skew:La,skewX:La,skewY:La,distance:G,translateX:G,translateY:G,translateZ:G,x:G,y:G,z:G,perspective:G,transformPerspective:G,opacity:Ca,originX:Va,originY:Va,originZ:G,zIndex:el,fillOpacity:Ca,strokeOpacity:Ca,numOctaves:el},nl={...tl,color:Ua,backgroundColor:Ua,outlineColor:Ua,fill:Ua,stroke:Ua,borderColor:Ua,borderTopColor:Ua,borderRightColor:Ua,borderBottomColor:Ua,borderLeftColor:Ua,filter:Qc,WebkitFilter:Qc,mask:$c,WebkitMask:$c},rl=e=>nl[e],il=new Set([Qc,$c]);function al(e,t){let n=rl(e);return il.has(n)||(n=ao),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var ol=new Set([`auto`,`none`,`0`]);function sl(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!ol.has(t)&&Qa(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=al(n,i)}var cl=class extends ks{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(),ya(r))){let i=lc(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Cc.has(n)||e.length!==2)return;let[r,i]=e,a=qc(r),o=qc(i);if(xa(r)!==xa(i)&&xs[n]){this.needsMeasurement=!0;return}if(a!==o)if(_s(a)&&_s(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else xs[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||Jc(e[t]))&&n.push(t);n.length&&sl(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=xs[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]=xs[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 ll(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 ul=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function dl(e){return Ei(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:fl,cancel:pl}=ca(queueMicrotask,!1),ml={x:!1,y:!1};function hl(){return ml.x||ml.y}function gl(e){return e===`x`||e===`y`?ml[e]?null:(ml[e]=!0,()=>{ml[e]=!1}):ml.x||ml.y?null:(ml.x=ml.y=!0,()=>{ml.x=ml.y=!1})}function _l(e,t){let n=ll(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function vl(e){return!(e.pointerType===`touch`||hl())}function yl(e,t,n={}){let[r,i,a]=_l(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(!vl(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 bl=(e,t)=>t?e===t?!0:bl(e,t.parentElement):!1,xl=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Sl=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Cl(e){return Sl.has(e.tagName)||e.isContentEditable===!0}var wl=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Tl(e){return wl.has(e.tagName)||e.isContentEditable===!0}var El=new WeakSet;function Dl(e){return t=>{t.key===`Enter`&&e(t)}}function Ol(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var kl=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=Dl(()=>{if(El.has(n))return;Ol(n,`down`);let e=Dl(()=>{Ol(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Ol(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Al(e){return xl(e)&&!hl()}var jl=new WeakSet;function Ml(e,t,n={}){let[r,i,a]=_l(e,n),o=e=>{let r=e.currentTarget;if(!Al(e)||jl.has(e))return;El.add(r),n.stopPropagation&&jl.add(e);let a=t(r,e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),El.has(r)&&El.delete(r),Al(e)&&typeof a==`function`&&a(e,{success:t})},s=e=>{o(e,r===window||r===document||n.useGlobalTarget||bl(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),dl(e)&&(e.addEventListener(`focus`,e=>kl(e,i)),!Cl(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function Nl(e){return Ei(e)&&`ownerSVGElement`in e}var Pl=new WeakMap,Fl,Il=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:Nl(r)&&`getBBox`in r?r.getBBox()[t]:r[n],Ll=Il(`inline`,`width`,`offsetWidth`),Rl=Il(`block`,`height`,`offsetHeight`);function J({target:e,borderBoxSize:t}){Pl.get(e)?.forEach(n=>{n(e,{get width(){return Ll(e,t)},get height(){return Rl(e,t)}})})}function Y(e){e.forEach(J)}function zl(){typeof ResizeObserver>`u`||(Fl=new ResizeObserver(Y))}function Bl(e,t){Fl||zl();let n=ll(e);return n.forEach(e=>{let n=Pl.get(e);n||(n=new Set,Pl.set(e,n)),n.add(t),Fl?.observe(e)}),()=>{n.forEach(e=>{let n=Pl.get(e);n?.delete(t),n?.size||Fl?.unobserve(e)})}}var Vl=new Set,Hl;function Ul(){Hl=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Vl.forEach(t=>t(e))},window.addEventListener(`resize`,Hl)}function Wl(e){return Vl.add(e),Hl||Ul(),()=>{Vl.delete(e),!Vl.size&&typeof Hl==`function`&&(window.removeEventListener(`resize`,Hl),Hl=void 0)}}function Gl(e,t){return typeof e==`function`?Wl(e):Bl(e,t)}function Kl(e){return Nl(e)&&e.tagName===`svg`}var ql=[...Kc,Ua,ao],Jl=e=>ql.find(Gc(e)),Yl=()=>({translate:0,scale:1,origin:0,originPoint:0}),Xl=()=>({x:Yl(),y:Yl()}),Zl=()=>({min:0,max:0}),X=()=>({x:Zl(),y:Zl()}),Ql=new WeakMap;function $l(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function eu(e){return typeof e==`string`||Array.isArray(e)}var tu=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],nu=[`initial`,...tu];function ru(e){return $l(e.animate)||nu.some(t=>eu(e[t]))}function iu(e){return!!(ru(e)||e.variants)}function au(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Nc(i))e.addValue(r,i);else if(Nc(a))e.addValue(r,Oc(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,Oc(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var ou={current:null},su={current:!1},cu=typeof window<`u`;function lu(){if(su.current=!0,cu)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>ou.current=e.matches;e.addEventListener(`change`,t),t()}else ou.current=!1}var uu=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],du={};function fu(e){du=e}function pu(){return du}var mu=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=ks,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=ma.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,W.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=ru(t),this.isVariantNode=iu(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&&Nc(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,Ql.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:(su.current||lu(),this.shouldReduceMotion=ou.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(),la(this.notifyUpdate),la(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&&Qs.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new Hs({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:Ni(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=gs.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&W.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 du){let t=du[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):X()}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<uu.length;t++){let n=uu[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=au(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=Oc(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`&&(Ti(n)||Di(n))?n=parseFloat(n):!Jl(n)&&ao.test(t)&&(n=al(e,t)),this.setBaseTarget(e,Nc(n)?n.get():n)),Nc(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=xc(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&&!Nc(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 Mi),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){fl.render(this.render)}},hu=class extends mu{constructor(){super(...arguments),this.KeyframeResolver=cl}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;Nc(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},gu=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function _u({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function vu({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function yu(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 bu(e){return e===void 0||e===1}function xu({scale:e,scaleX:t,scaleY:n}){return!bu(e)||!bu(t)||!bu(n)}function Su(e){return xu(e)||Cu(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Cu(e){return wu(e.x)||wu(e.y)}function wu(e){return e&&e!==`0%`}function Tu(e,t,n){return n+t*(e-n)}function Eu(e,t,n,r,i){return i!==void 0&&(e=Tu(e,i,r)),Tu(e,n,r)+t}function Du(e,t=0,n=1,r,i){e.min=Eu(e.min,t,n,r,i),e.max=Eu(e.max,t,n,r,i)}function Ou(e,{x:t,y:n}){Du(e.x,t.translate,t.scale,t.originPoint),Du(e.y,n.translate,n.scale,n.originPoint)}var ku=.999999999999,Au=1.0000000000001;function ju(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&&(Mu(e.x,-a.scroll.offset.x),Mu(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Ou(e,o)),r&&Su(a.latestValues)&&Fu(e,a.latestValues,a.layout?.layoutBox))}t.x<Au&&t.x>ku&&(t.x=1),t.y<Au&&t.y>ku&&(t.y=1)}function Mu(e,t){e.min+=t,e.max+=t}function Nu(e,t,n,r,i=.5){Du(e,t,n,q(e.min,e.max,i),r)}function Pu(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function Fu(e,t,n){let r=n??e;Nu(e.x,Pu(t.x,r.x),t.scaleX,t.scale,t.originX),Nu(e.y,Pu(t.y,r.y),t.scaleY,t.scale,t.originY)}function Iu(e,t){return _u(yu(e.getBoundingClientRect(),t))}function Lu(e,t,n){let r=Iu(e,n),{scroll:i}=t;return i&&(Mu(r.x,i.offset.x),Mu(r.y,i.offset.y)),r}var Ru={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},zu=hs.length;function Bu(e,t,n){let r=``,i=!0;for(let a=0;a<zu;a++){let o=hs[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=ul(s,tl[o]);if(!c){i=!1;let t=Ru[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}return r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function Vu(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(gs.has(e)){o=!0;continue}else if(_a(e)){i[e]=n;continue}else{let t=ul(n,tl[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=Bu(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 Hu(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 Uu(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var Wu={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(G.test(e))e=parseFloat(e);else return e;return`${Uu(e,t.target.x)}% ${Uu(e,t.target.y)}%`}},Gu={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=ao.parse(e);if(i.length>5)return r;let a=ao.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=q(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},Ku={borderRadius:{...Wu,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:Wu,borderTopRightRadius:Wu,borderBottomLeftRadius:Wu,borderBottomRightRadius:Wu,boxShadow:Gu};function qu(e,{layout:t,layoutId:n}){return gs.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!Ku[e]||e===`opacity`)}function Ju(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Nc(r[t])||i&&Nc(i[t])||qu(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function Yu(e){return window.getComputedStyle(e)}var Xu=class extends hu{constructor(){super(...arguments),this.type=`html`,this.renderInstance=Hu}readValueFromInstance(e,t){if(gs.has(t))return this.projection?.isProjecting?ds(t):ps(e,t);{let n=Yu(e),r=(_a(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return Iu(e,t)}build(e,t,n){Vu(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Ju(e,t,n)}},Zu={offset:`stroke-dashoffset`,array:`stroke-dasharray`},Qu={offset:`strokeDashoffset`,array:`strokeDasharray`};function $u(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?Zu:Qu;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var ed=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function td(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(Vu(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 ed)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&&$u(d,i,a,o,!1)}var nd=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`]),rd=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function id(e,t,n,r){Hu(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(nd.has(n)?n:Ic(n),t.attrs[n])}function ad(e,t,n){let r=Ju(e,t,n);for(let n in e)if(Nc(e[n])||Nc(t[n])){let t=hs.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var od=class extends hu{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=X}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(gs.has(t)){let e=rl(t);return e&&e.default||0}return t=nd.has(t)?t:Ic(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return ad(e,t,n)}build(e,t,n){td(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){id(e,t,n,r)}mount(e){this.isSVGTag=rd(e.tagName),super.mount(e)}},sd=nu.length;function cd(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&cd(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<sd;n++){let r=nu[n],i=e.props[r];(eu(i)||i===!1)&&(t[r]=i)}return t}function ld(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 ud=[...tu].reverse(),dd=tu.length;function fd(e){return t=>Promise.all(t.map(({animation:t,options:n})=>Uc(e,t,n)))}function pd(e){let t=fd(e),n=gd(),r=!0,i=!1,a=t=>(n,r)=>{let i=Sc(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=cd(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<dd;t++){let p=ud[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=eu(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||$l(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=md(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=kc(t)&&kc(n)?!ld(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=Sc(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=oc(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Sc(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=gd(),i=!0}}}function md(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!ld(t,e):!1}function hd(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function gd(){return{animate:hd(!0),whileInView:hd(),whileHover:hd(),whileTap:hd(),whileDrag:hd(),whileFocus:hd(),exit:hd()}}function _d(e,t){e.min=t.min,e.max=t.max}function vd(e,t){_d(e.x,t.x),_d(e.y,t.y)}function yd(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var bd=1e-4,Z=1-bd,xd=1+bd,Sd=.01,Cd=0-Sd,wd=0+Sd;function Td(e){return e.max-e.min}function Ed(e,t,n){return Math.abs(e-t)<=n}function Dd(e,t,n,r=.5){e.origin=r,e.originPoint=q(t.min,t.max,e.origin),e.scale=Td(n)/Td(t),e.translate=q(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Z&&e.scale<=xd||isNaN(e.scale))&&(e.scale=1),(e.translate>=Cd&&e.translate<=wd||isNaN(e.translate))&&(e.translate=0)}function Od(e,t,n,r){Dd(e.x,t.x,n.x,r?r.originX:void 0),Dd(e.y,t.y,n.y,r?r.originY:void 0)}function kd(e,t,n,r=0){e.min=(r?q(n.min,n.max,r):n.min)+t.min,e.max=e.min+Td(t)}function Ad(e,t,n,r){kd(e.x,t.x,n.x,r?.x),kd(e.y,t.y,n.y,r?.y)}function jd(e,t,n,r=0){let i=r?q(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+Td(t)}function Md(e,t,n,r){jd(e.x,t.x,n.x,r?.x),jd(e.y,t.y,n.y,r?.y)}function Nd(e,t,n,r,i){return e-=t,e=Tu(e,1/n,r),i!==void 0&&(e=Tu(e,1/i,r)),e}function Pd(e,t=0,n=1,r=.5,i,a=e,o=e){if(Ra.test(t)&&(t=parseFloat(t),t=q(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=q(a.min,a.max,r);e===a&&(s-=t),e.min=Nd(e.min,t,n,s,i),e.max=Nd(e.max,t,n,s,i)}function Fd(e,t,[n,r,i],a,o){Pd(e,t[n],t[r],t[i],t.scale,a,o)}var Id=[`x`,`scaleX`,`originX`],Ld=[`y`,`scaleY`,`originY`];function Rd(e,t,n,r){Fd(e.x,t,Id,n?n.x:void 0,r?r.x:void 0),Fd(e.y,t,Ld,n?n.y:void 0,r?r.y:void 0)}function zd(e){return e.translate===0&&e.scale===1}function Bd(e){return zd(e.x)&&zd(e.y)}function Vd(e,t){return e.min===t.min&&e.max===t.max}function Hd(e,t){return Vd(e.x,t.x)&&Vd(e.y,t.y)}function Ud(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Wd(e,t){return Ud(e.x,t.x)&&Ud(e.y,t.y)}function Gd(e){return Td(e.x)/Td(e.y)}function Kd(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function qd(e){return[e(`x`),e(`y`)]}function Jd(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 Yd=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`],Xd=Yd.length,Zd=e=>typeof e==`string`?parseFloat(e):e,Qd=e=>typeof e==`number`||G.test(e);function $d(e,t,n,r,i,a){i?(e.opacity=q(0,n.opacity??1,tf(r)),e.opacityExit=q(t.opacity??1,0,nf(r))):a&&(e.opacity=q(t.opacity??1,n.opacity??1,r));for(let i=0;i<Xd;i++){let a=Yd[i],o=ef(t,a),s=ef(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||Qd(o)===Qd(s)?(e[a]=Math.max(q(Zd(o),Zd(s),r),0),(Ra.test(s)||Ra.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=q(t.rotate||0,n.rotate||0,r))}function ef(e,t){return e[t]===void 0?e.borderRadius:e[t]}var tf=rf(0,.5,Ji),nf=rf(.5,.95,ki);function rf(e,t,n){return r=>r<e?0:r>t?1:n(ji(e,t,r))}function af(e,t,n){let r=Nc(e)?e:Oc(e);return r.start(yc(``,r,t,n)),r.animation}function of(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var sf=(e,t)=>e.depth-t.depth,cf=class{constructor(){this.children=[],this.isDirty=!1}add(e){xi(this.children,e),this.isDirty=!0}remove(e){Si(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(sf),this.isDirty=!1,this.children.forEach(e)}};function lf(e,t){let n=ma.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(la(r),e(a-t))};return W.setup(r,!0),()=>la(r)}function uf(e){return Nc(e)?e.get():e}var df=class{constructor(){this.members=[]}add(e){xi(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&&(Si(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Si(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)}},ff={hasAnimatedSinceResize:!0,hasEverUpdated:!1},pf={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},mf=[``,`X`,`Y`,`Z`],hf=1e3,gf=0;function _f(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function vf(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=Rc(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,W,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&vf(r)}function yf({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=gf++,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,aa.value&&(pf.nodes=pf.calculatedTargetDeltas=pf.calculatedProjections=0),this.nodes.forEach(Sf),this.nodes.forEach(jf),this.nodes.forEach(Mf),this.nodes.forEach(Cf),aa.addProjectionMetrics&&aa.addProjectionMetrics(pf)},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 cf)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new Mi),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=Nl(t)&&!Kl(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;W.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=lf(i,250),ff.hasAnimatedSinceResize&&(ff.hasAnimatedSinceResize=!1,this.nodes.forEach(Af)))})}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()||zf,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!Wd(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={...gc(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||Af(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(),la(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(Nf),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&&vf(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(Ef),this.nodes.forEach(Tf);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Df);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Of),this.nodes.forEach(kf),this.nodes.forEach(bf),this.nodes.forEach(xf)):this.nodes.forEach(Df),this.clearAllSnapshots();let e=ma.now();ua.delta=Ci(0,1e3/60,e-ua.timestamp),ua.timestamp=e,ua.isProcessing=!0,da.update.process(ua),da.preRender.process(ua),da.render.process(ua),ua.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,fl.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(wf),this.sharedNodes.forEach(Pf)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,W.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){W.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Td(this.snapshot.measuredBox.x)&&!Td(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||=X(),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&&!Bd(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Su(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)),Uf(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return X();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Gf))){let{scroll:e}=this.root;e&&(Mu(t.x,e.offset.x),Mu(t.y,e.offset.y))}return t}removeElementScroll(e){let t=X();if(vd(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&&vd(t,e),Mu(t.x,i.offset.x),Mu(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||X();vd(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&&(Mu(r.x,-n.scroll.offset.x),Mu(r.y,-n.scroll.offset.y)),Su(n.latestValues)&&Fu(r,n.latestValues,n.layout?.layoutBox)}return Su(this.latestValues)&&Fu(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=X();vd(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Su(n.latestValues))continue;let r;n.instance&&(xu(n.latestValues)&&n.updateSnapshot(),r=X(),vd(r,n.measurePageBox())),Rd(t,n.latestValues,n.snapshot?.layoutBox,r)}return Su(this.latestValues)&&Rd(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!==ua.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=ua.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=X(),this.targetWithTransforms=X()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Ad(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):vd(this.target,this.layout.layoutBox),Ou(this.target,this.targetDelta)):vd(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),aa.value&&pf.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||xu(this.parent.latestValues)||Cu(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=X(),this.relativeTargetOrigin=X(),Md(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),vd(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===ua.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;vd(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;ju(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=X());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(yd(this.prevProjectionDelta.x,this.projectionDelta.x),yd(this.prevProjectionDelta.y,this.projectionDelta.y)),Od(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!Kd(this.projectionDelta.x,this.prevProjectionDelta.x)||!Kd(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),aa.value&&pf.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=Xl(),this.projectionDelta=Xl(),this.projectionDeltaWithTransform=Xl()}setAnimationOrigin(e,t=!1){let n=this.snapshot,r=n?n.latestValues:{},i={...this.latestValues},a=Xl();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=X(),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(Rf));this.animationProgress=0;let d;this.mixTargetDelta=t=>{let n=t/1e3;Ff(a.x,e.x,n),Ff(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Md(o,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),Lf(this.relativeTarget,this.relativeTargetOrigin,o,n),d&&Hd(this.relativeTarget,d)&&(this.isProjectionDirty=!1),d||=X(),vd(d,this.relativeTarget)),s&&(this.animationValues=i,$d(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&&=(la(this.pendingAnimation),void 0),this.pendingAnimation=W.update(()=>{ff.hasAnimatedSinceResize=!0,ha.layout++,this.motionValue||=Oc(0),this.motionValue.jump(0,!1),this.currentAnimation=af(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{ha.layout--},onComplete:()=>{ha.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(hf),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&&Wf(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||X();let t=Td(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=Td(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}vd(t,n),Fu(t,i),Od(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new df),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&&_f(`z`,e,r,this.animationValues);for(let t=0;t<mf.length;t++)_f(`rotate${mf[t]}`,e,r,this.animationValues),_f(`skew${mf[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=uf(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=uf(t?.pointerEvents)||``),this.hasProjected&&!Su(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=Jd(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 Ku){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=Ku[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?uf(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(Tf),this.root.sharedNodes.clear()}}}function bf(e){e.updateLayout()}function xf(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`)qd(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=Td(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;_d(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else Wf(i,t.layoutBox,n)&&qd(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=Td(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=Xl();Od(o,n,t.layoutBox);let s=Xl();a?Od(s,e.applyTransform(r,!0),t.measuredBox):Od(s,n,t.layoutBox);let c=!Bd(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=X();Md(s,t.layoutBox,i.layoutBox,o);let c=X();Md(c,n,a.layoutBox,o),Wd(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 Sf(e){aa.value&&pf.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 Cf(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function wf(e){e.clearSnapshot()}function Tf(e){e.clearMeasurements()}function Ef(e){e.isLayoutDirty=!0,e.updateLayout()}function Df(e){e.isLayoutDirty=!1}function Of(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function kf(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function Af(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function jf(e){e.resolveTargetDelta()}function Mf(e){e.calcProjection()}function Nf(e){e.resetSkewAndRotation()}function Pf(e){e.removeLeadSnapshot()}function Ff(e,t,n){e.translate=q(t.translate,0,n),e.scale=q(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function If(e,t,n,r){e.min=q(t.min,n.min,r),e.max=q(t.max,n.max,r)}function Lf(e,t,n,r){If(e.x,t.x,n.x,r),If(e.y,t.y,n.y,r)}function Rf(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var zf={duration:.45,ease:[.4,0,.1,1]},Bf=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Vf=Bf(`applewebkit/`)&&!Bf(`chrome/`)?Math.round:ki;function Hf(e){e.min=Vf(e.min),e.max=Vf(e.max)}function Uf(e){Hf(e.x),Hf(e.y)}function Wf(e,t,n){return e===`position`||e===`preserve-aspect`&&!Ed(Gd(t),Gd(n),.2)}function Gf(e){return e!==e.root&&e.scroll?.wasRoot}var Kf=yf({attachResizeListener:(e,t)=>of(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),qf={current:void 0},Jf=yf({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!qf.current){let e=new Kf({});e.mount(window),e.setOptions({layoutScroll:!0}),qf.current=e}return qf.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),Yf=(0,b.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function Xf(e=!0){let t=(0,b.useContext)(bi);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 Zf=(0,b.createContext)({strict:!1}),Qf={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`]},$f=!1;function ep(){if($f)return;let e={};for(let t in Qf)e[t]={isEnabled:e=>Qf[t].some(t=>!!e[t])};fu(e),$f=!0}function tp(){return ep(),pu()}function np(e){let t=tp();for(let n in e)t[n]={...t[n],...e[n]};fu(t)}var rp=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 ip(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||rp.has(e)}var ap=c({default:()=>op}),op,sp=o((()=>{throw op={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),cp=e=>!ip(e);function lp(e){typeof e==`function`&&(cp=t=>t.startsWith(`on`)?!ip(t):e(t))}try{lp((sp(),d(ap)).default)}catch{}function up(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||Nc(e[i])||(cp(i)||n===!0&&ip(i)||!t&&!ip(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var dp=(0,b.createContext)({});function fp(e,t){if(ru(e)){let{initial:t,animate:n}=e;return{initial:t===!1||eu(t)?t:void 0,animate:eu(n)?n:void 0}}return e.inherit===!1?{}:t}function pp(e){let{initial:t,animate:n}=fp(e,(0,b.useContext)(dp));return(0,b.useMemo)(()=>({initial:t,animate:n}),[mp(t),mp(n)])}function mp(e){return Array.isArray(e)?e.join(` `):e}var hp=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function gp(e,t,n){for(let r in t)!Nc(t[r])&&!qu(r,n)&&(e[r]=t[r])}function _p({transformTemplate:e},t){return(0,b.useMemo)(()=>{let n=hp();return Vu(n,t,e),Object.assign({},n.vars,n.style)},[t])}function vp(e,t){let n=e.style||{},r={};return gp(r,n,e),Object.assign(r,_p(e,t)),r}function yp(e,t){let n={},r=vp(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 bp=()=>({...hp(),attrs:{}});function xp(e,t,n,r){let i=(0,b.useMemo)(()=>{let n=bp();return td(n,t,rd(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};gp(t,e.style,e),i.style={...t,...i.style}}return i}var Sp=[`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 Cp(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(Sp.indexOf(e)>-1||/[A-Z]/u.test(e))}function wp(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??Cp(e)?xp:yp)(t,r,i,e),c=up(t,typeof e==`string`,a),l=e===b.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,b.useMemo)(()=>Nc(u)?u.get():u,[u]);return(0,b.createElement)(e,{...l,children:d})}function Tp({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Ep(n,r,i,e),renderState:t()}}function Ep(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=uf(a[e]);let{initial:o,animate:s}=e,c=ru(e),l=iu(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`&&!$l(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=xc(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 Dp=e=>(t,n)=>{let r=(0,b.useContext)(dp),i=(0,b.useContext)(bi),a=()=>Tp(e,t,r,i);return n?a():vi(a)},Op=Dp({scrapeMotionValuesFromProps:Ju,createRenderState:hp}),kp=Dp({scrapeMotionValuesFromProps:ad,createRenderState:bp}),Ap=Symbol.for(`motionComponentSymbol`);function jp(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 Mp=(0,b.createContext)({});function Np(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function Pp(e,t,n,r,i,a){let{visualElement:o}=(0,b.useContext)(dp),s=(0,b.useContext)(Zf),c=(0,b.useContext)(bi),l=(0,b.useContext)(Yf),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)(Mp);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&Fp(f.current,n,i,h);let g=(0,b.useRef)(!1);(0,b.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[Lc],v=(0,b.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return yi(()=>{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 Fp(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:Ip(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&Np(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function Ip(e){if(e)return e.options.allowProjection===!1?Ip(e.parent):e.projection}function Lp(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&np(r);let a=n?n===`svg`:Cp(e),o=a?kp:Op;function s(n,s){let c,l={...(0,b.useContext)(Yf),...n,layoutId:Rp(n)},{isStatic:u}=l,d=pp(n),f=o(n,u);if(!u&&typeof window<`u`){zp(l,r);let t=Bp(l);c=t.MeasureLayout,d.visualElement=Pp(e,f,l,i,t.ProjectionNode,a)}return(0,H.jsxs)(dp.Provider,{value:d,children:[c&&d.visualElement?(0,H.jsx)(c,{visualElement:d.visualElement,...l}):null,wp(e,n,jp(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[Ap]=e,c}function Rp({layoutId:e}){let t=(0,b.useContext)(_i).id;return t&&e!==void 0?t+`-`+e:e}function zp(e,t){(0,b.useContext)(Zf).strict}function Bp(e){let{drag:t,layout:n}=tp();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function Vp(e,t){if(typeof Proxy>`u`)return Lp;let n=new Map,r=(n,r)=>Lp(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,Lp(a,void 0,e,t)),n.get(a))})}var Hp=(e,t)=>t.isSVG??Cp(e)?new od(t):new Xu(t,{allowProjection:e!==b.Fragment}),Up=class extends gu{constructor(e){super(e),e.animationState||=pd(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();$l(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?.()}},Wp=0,Gp={animation:{Feature:Up},exit:{Feature:class extends gu{constructor(){super(...arguments),this.id=Wp++,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=Sc(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 Kp(e){return{point:{x:e.pageX,y:e.pageY}}}var qp=e=>t=>xl(t)&&e(t,Kp(t));function Jp(e,t,n,r){return of(e,t,qp(n),r)}var Yp=({current:e})=>e?e.ownerDocument.defaultView:null,Xp=(e,t)=>Math.abs(e-t);function Zp(e,t){let n=Xp(e.x,t.x),r=Xp(e.y,t.y);return Math.sqrt(n**2+r**2)}var Qp=new Set([`auto`,`scroll`]),$p=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=em(this.lastRawMoveEventInfo,this.transformPagePoint));let e=nm(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=Zp(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=ua;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=em(t,this.transformPagePoint),W.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=nm(e.type===`pointercancel`?this.lastMoveEventInfo:em(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!xl(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=em(Kp(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=ua;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,nm(s,this.history)),this.removeListeners=U(Jp(this.contextWindow,`pointermove`,this.handlePointerMove),Jp(this.contextWindow,`pointerup`,this.handlePointerUp),Jp(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(Qp.has(e.overflowX)||Qp.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),W.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),la(this.updatePoint)}};function em(e,t){return t?{point:t(e.point)}:e}function tm(e,t){return{x:e.x-t.x,y:e.y-t.y}}function nm({point:e},t){return{point:e,delta:tm(e,im(t)),offset:tm(e,rm(t)),velocity:am(t,.1)}}function rm(e){return e[0]}function im(e){return e[e.length-1]}function am(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=im(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Ni(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Ni(t)*2&&(r=e[1]);let a=Pi(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 om(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?q(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?q(n,e,r.max):Math.min(e,n)),e}function sm(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 cm(e,{top:t,left:n,bottom:r,right:i}){return{x:sm(e.x,n,i),y:sm(e.y,t,r)}}function lm(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 um(e,t){return{x:lm(e.x,t.x),y:lm(e.y,t.y)}}function dm(e,t){let n=.5,r=Td(e),i=Td(t);return i>r?n=ji(t.min,t.max-r,e.min):r>i&&(n=ji(e.min,e.max-i,t.min)),Ci(0,1,n)}function fm(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 pm=.35;function mm(e=pm){return e===!1?e=0:e===!0&&(e=pm),{x:hm(e,`left`,`right`),y:hm(e,`top`,`bottom`)}}function hm(e,t,n){return{min:gm(e,t),max:gm(e,n)}}function gm(e,t){return typeof e==`number`?e:e[t]||0}var _m=new WeakMap,vm=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=X(),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(Kp(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=gl(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),qd(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=Td(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&W.update(()=>i(e,t),!1,!0),Fc(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=Sm(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&&W.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 $p(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:Yp(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&&W.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||!xm(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=om(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&&Np(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=cm(n.layoutBox,e):this.constraints=!1,this.elastic=mm(t),r!==this.constraints&&!Np(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&qd(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=fm(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Np(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=Lu(n,r.root,this.visualElement.getTransformPagePoint()),a=um(r.layout.layoutBox,i);if(t){let e=t(vu(a));this.hasMutatedConstraints=!!e,e&&(a=_u(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=qd(o=>{if(!xm(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 Fc(this.visualElement,e),n.start(yc(e,n,0,t,this.visualElement,!1))}stopAnimation(){qd(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){qd(t=>{let{drag:n}=this.getProps();if(!xm(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]-q(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Np(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};qd(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=dm({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(),qd(t=>{if(!xm(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(q(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;_m.set(this.visualElement,this);let e=this.visualElement.current,t=Jp(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&Tl(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();Np(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=bm(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),W.read(r);let o=of(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(qd(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=pm,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function ym(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function bm(e,t,n){let r=Gl(e,ym(n)),i=Gl(t,ym(n));return()=>{r(),i()}}function xm(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Sm(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var Cm=class extends gu{constructor(e){super(e),this.removeGroupControls=ki,this.removeListeners=ki,this.controls=new vm(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ki}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()}},wm=e=>(t,n)=>{e&&W.update(()=>e(t,n),!1,!0)},Tm=class extends gu{constructor(){super(...arguments),this.removePointerDownListener=ki}onPointerDown(e){this.session=new $p(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Yp(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:wm(e),onStart:wm(t),onMove:wm(n),onEnd:(e,t)=>{delete this.session,r&&W.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=Jp(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},Em=!1,Dm=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),Em&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),ff.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}),Em=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||W.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(),fl.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Em=!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 Om(e){let[t,n]=Xf(),r=(0,b.useContext)(_i);return(0,H.jsx)(Dm,{...e,layoutGroup:r,switchLayoutGroup:(0,b.useContext)(Mp),isPresent:t,safeToRemove:n})}var km={pan:{Feature:Tm},drag:{Feature:Cm,ProjectionNode:Jf,MeasureLayout:Om}};function Am(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&W.postRender(()=>i(t,Kp(t)))}var jm=class extends gu{mount(){let{current:e}=this.node;e&&(this.unmount=yl(e,(e,t)=>(Am(this.node,t,`Start`),e=>Am(this.node,e,`End`))))}unmount(){}},Mm=class extends gu{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=U(of(this.node.current,`focus`,()=>this.onFocus()),of(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function Nm(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&&W.postRender(()=>i(t,Kp(t)))}var Pm=class extends gu{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Ml(e,(e,t)=>(Nm(this.node,t,`Start`),(e,{success:t})=>Nm(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},Fm=new WeakMap,Im=new WeakMap,Lm=e=>{let t=Fm.get(e.target);t&&t(e)},Rm=e=>{e.forEach(Lm)};function zm({root:e,...t}){let n=e||document;Im.has(n)||Im.set(n,{});let r=Im.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(Rm,{root:e,...t})),r[i]}function Bm(e,t,n){let r=zm(t);return Fm.set(e,n),r.observe(e),()=>{Fm.delete(e),r.unobserve(e)}}var Vm={some:0,all:1},Hm=class extends gu{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:Vm[r]};this.stopObserver=Bm(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(Um(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function Um({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var Wm={inView:{Feature:Hm},tap:{Feature:Pm},focus:{Feature:Mm},hover:{Feature:jm}},Gm={layout:{ProjectionNode:Jf,MeasureLayout:Om}},Km=Vp({...Gp,...Wm,...km,...Gm},Hp),qm=24e3,Jm=2048,Ym=1200,Xm=.03,Zm=2,Qm=11;function $m(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t/e.length)}function eh(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 th(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]/32768;return t}var nh=.13,rh=[`audio/webm`,`audio/mp4`];function ih(){return typeof window>`u`||window.MediaRecorder===void 0?null:rh.find(e=>window.MediaRecorder.isTypeSupported(e))||null}function ah(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))}var oh=.02;function sh(e,t,n){let r=0,i=0,a=[],o=()=>{let t=e.currentTime;a.forEach(({source:e,gain:n})=>{try{n.gain.cancelScheduledValues(t),n.gain.setValueAtTime(n.gain.value,t),n.gain.linearRampToValueAtTime(0,t+oh),e.stop(t+oh)}catch{}}),a=[],r=0,i=0},s=()=>r>e.currentTime;return{enqueue:o=>{let c=th(o),l=e.createBuffer(1,c.length,qm);l.copyToChannel(c,0);let u=e.createBufferSource();u.buffer=l;let d=e.createGain();u.connect(d),d.connect(e.destination),n&&d.connect(n);let f=s()?r:e.currentTime+nh;i||=f,u.start(f),r=f+l.duration;let p={source:u,gain:d};a.push(p),u.onended=()=>{a=a.filter(e=>e!==p),!a.length&&!s()&&t?.()}},stop:o,isPlaying:s,playedMs:()=>Math.max(0,(e.currentTime-i)*1e3)}}async function ch(e,t,n){let r=new URLSearchParams({siteId:t||``});n&&r.set(`chatId`,n);let i=Lr();i&&r.set(`shopifyCustomerId`,String(i));let a=await fetch(`${e}/api/voice/session?${r.toString()}`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(a.status===429){let e=await a.json().catch(()=>({}));throw Error(e.message||`Too many voice sessions started. Please wait a minute before trying again.`)}if(!a.ok)throw Error(`Could not start a voice session.`);let o=await a.json();if(!o?.success||!o.wsUrl)throw Error(o?.error||`Voice session was refused.`);return o}async function lh(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 ch(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:qm});_.state===`suspended`&&await _.resume();let v=_.createMediaStreamDestination(),y=ih(),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})}},D=(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,Ym))},O=!1,k=!1,A=!1,te=!1,ne=!1,re=!0,ie=!1,j=null,M=!1,ae=!1,oe=()=>{j&&clearTimeout(j);let e=()=>{if(!O){if(se.isPlaying()){j=setTimeout(e,150);return}if(j=null,M){p?.();return}!O&&C.readyState===WebSocket.OPEN&&C.send(JSON.stringify({type:`PlaybackDrained`})),ae&&(ae=!1,d?.())}};j=setTimeout(e,150)},se=sh(_,()=>{te&&(te=!1,c?.({mode:ne?`thinking`:`listening`}))},v);typeof window<`u`&&(window.__fe_agentAudioPlaying=()=>se.isPlaying());let ce=_.createMediaStreamSource(g);ce.connect(v);let N=_.createScriptProcessor(Jm,1,1),P=!1,le=0,ue=0;N.onaudioprocess=e=>{if(O||C.readyState!==WebSocket.OPEN)return;let t=e.inputBuffer.getChannelData(0),n=()=>C.send(new Int16Array(t.length).buffer);if(k){A||(A=!0,console.debug(`[FlowEngage] mic held — streaming silence to keep socket alive`)),P=!1,le=0,ue=0,n();return}let r=$m(t);se.isPlaying()||ie?(P=!1,le=0,ue=0):r>=Xm?(ue=0,le+=1,!P&&le>=Zm&&(P=!0,c?.({mode:`user-speaking`}))):(le=0,P&&++ue>=Qm&&(P=!1,ue=0)),C.send(eh(t).buffer)},ce.connect(N),N.connect(_.destination);let de=()=>{if(!O){O=!0,j&&=(clearTimeout(j),null),ee(),se.stop(),typeof window<`u`&&delete window.__fe_agentAudioPlaying;try{N.disconnect(),ce.disconnect()}catch{}if(g.getTracks().forEach(e=>e.stop()),x&&x.state!==`inactive`){x.onstop=()=>ah(t,n,S,b,y);try{x.stop()}catch{x.onstop=null}}else b.length&&ah(t,n,S,b,y);_.close().catch(()=>{}),(C.readyState===WebSocket.OPEN||C.readyState===WebSocket.CONNECTING)&&C.close()}},F=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`}}},fe=async e=>{for(let t of e.functions||[]){if(!t.client_side)continue;let e=await F(t);if(O||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??{})}))}},pe=e=>{switch(e.type){case`Welcome`:Number.isFinite(e.barge_in_rms)&&e.barge_in_rms>0&&e.barge_in_rms,Number.isFinite(e.barge_in_frames)&&e.barge_in_frames>0&&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}}D(e.role===`user`?`user`:`agent`,t,e.debug);break}case`UserStartedSpeaking`:ee(),se.stop(),ie=!1,re=!1,te=!1,ne=!1,j&&!M&&(clearTimeout(j),j=null),ae=!1,c?.({mode:`listening`});break;case`AgentStartedSpeaking`:re=!0,te=!0,c?.({mode:`speaking`});break;case`AgentAudioDone`:ie=!1,ee(),oe(),se.isPlaying()||(te=!1,c?.({mode:ne?`thinking`:`listening`}));break;case`FunctionCallRequest`:fe(e);break;case`AgentPreparing`:ie=!0;break;case`AgentTurnComplete`:ne=!1,ae=!0,oe();break;case`SessionEnding`:console.debug(`[FlowEngage] server is ending the session:`,e.reason||`unspecified`),M=!0;break;case`AgentThinking`:ne=!0,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){re&&se.enqueue(new Int16Array(e.data));return}try{pe(JSON.parse(e.data))}catch{}},C.onerror=()=>l?.(Error(`Voice connection failed`)),C.onclose=()=>{de(),o?.()},{endSession:async()=>de(),sendContextualUpdate:e=>{O||C.readyState!==WebSocket.OPEN||!e||C.send(JSON.stringify({type:`UpdatePrompt`,prompt:e}))},sendUserMessage:(e,{silent:t=!0,suppressQuestion:n=!1}={})=>{O||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`)=>{O||C.readyState!==WebSocket.OPEN||!e||C.send(JSON.stringify({type:`InjectAgentMessage`,message:e,behavior:t}))},setWalkthroughActive:e=>{O||C.readyState!==WebSocket.OPEN||C.send(JSON.stringify({type:`WalkthroughActive`,active:!!e}))},setMicMuted:e=>{k=!!e,!O&&C.readyState===WebSocket.OPEN&&C.send(JSON.stringify({type:`MicHeld`,held:k}))},get status(){return O?`disconnected`:`connected`}}}var uh={startSession:lh},dh=({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`})]}),fh=({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`})]}),ph=({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`})]}),mh=()=>(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`})]}),hh=()=>(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`})}),gh=({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`})]}),_h=({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`})]}),vh=({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`})]}),yh=({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})]}),bh=({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`})]}),xh=()=>(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`})}),Sh=({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`})]}),Ch=(e=``)=>String(e).replace(/<[^>]+>/g,``).replace(/\s+/g,` `).trim(),wh=(e=``)=>String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),Th=new Set([`p`,`br`,`ul`,`ol`,`li`,`strong`,`em`,`b`,`i`,`a`]),Eh=/^https?:\/\//i;function Dh(e){let t=Array.from(e.childNodes);for(let n of t)if(n.nodeType===Node.ELEMENT_NODE){let t=n.tagName.toLowerCase();if(!Th.has(t)){e.replaceChild(document.createTextNode(n.textContent),n);continue}let r={};if(t===`a`){let e=n.getAttribute(`href`)||``;Eh.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);Dh(n)}else n.nodeType!==Node.TEXT_NODE&&e.removeChild(n)}function Oh(e){let t=document.createElement(`div`);return t.innerHTML=e,Dh(t),t.innerHTML}function kh(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 Ah=(e=``)=>{let t=String(e||``).trim();if(!t)return``;if(/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t))return kh(Oh(t));let n=t.replace(/\r\n/g,`
|
|
37
37
|
`).replace(/\n{3,}/g,`
|
|
38
38
|
|
|
39
39
|
`).split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean),r=e=>wh(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 kh(n.map(e=>{let t=e.split(`
|