cartethyia 2.6.5 → 2.6.6

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.
Files changed (69) hide show
  1. package/dist/dashboard/assets/{BannedPage-B7OjIxCp.js → BannedPage-1v5rzKMl.js} +1 -1
  2. package/dist/dashboard/assets/BannedPage-1v5rzKMl.js.gz +0 -0
  3. package/dist/dashboard/assets/{CliToolDetailPage-Bt-6y24w.js → CliToolDetailPage-chMg74ct.js} +1 -1
  4. package/dist/dashboard/assets/CliToolDetailPage-chMg74ct.js.gz +0 -0
  5. package/dist/dashboard/assets/{CliToolsPage-C6LunsuE.js → CliToolsPage-CKG-Vxrt.js} +1 -1
  6. package/dist/dashboard/assets/CliToolsPage-CKG-Vxrt.js.gz +0 -0
  7. package/dist/dashboard/assets/{CombosPage-CgyfN2Yy.js → CombosPage-JYmVKzIx.js} +1 -1
  8. package/dist/dashboard/assets/CombosPage-JYmVKzIx.js.gz +0 -0
  9. package/dist/dashboard/assets/{ConsoleLogPage-BHWU7y6j.js → ConsoleLogPage-CPflWDry.js} +1 -1
  10. package/dist/dashboard/assets/ConsoleLogPage-CPflWDry.js.gz +0 -0
  11. package/dist/dashboard/assets/{CustomizationPage-xIjU736m.js → CustomizationPage-B0EYUE47.js} +1 -1
  12. package/dist/dashboard/assets/CustomizationPage-B0EYUE47.js.gz +0 -0
  13. package/dist/dashboard/assets/{HealthEventsModal-DeT1zkYG.js → HealthEventsModal-F1c4lkNG.js} +1 -1
  14. package/dist/dashboard/assets/HealthEventsModal-F1c4lkNG.js.gz +0 -0
  15. package/dist/dashboard/assets/{LoginPage-ChVqIAam.js → LoginPage-BYTpzcoU.js} +1 -1
  16. package/dist/dashboard/assets/LoginPage-BYTpzcoU.js.gz +0 -0
  17. package/dist/dashboard/assets/{OverviewPage-BD4GkRtS.js → OverviewPage-DIYZRAcb.js} +1 -1
  18. package/dist/dashboard/assets/OverviewPage-DIYZRAcb.js.gz +0 -0
  19. package/dist/dashboard/assets/{ProviderDetailPage-BJXwqpKj.js → ProviderDetailPage-CM4MNy45.js} +1 -1
  20. package/dist/dashboard/assets/ProviderDetailPage-CM4MNy45.js.gz +0 -0
  21. package/dist/dashboard/assets/{ProvidersPage-Ck64riM5.js → ProvidersPage-Bsoqg2HG.js} +1 -1
  22. package/dist/dashboard/assets/ProvidersPage-Bsoqg2HG.js.gz +0 -0
  23. package/dist/dashboard/assets/{ProxyPage-Br_Leqq0.js → ProxyPage-8G3doV7j.js} +1 -1
  24. package/dist/dashboard/assets/ProxyPage-8G3doV7j.js.gz +0 -0
  25. package/dist/dashboard/assets/{QuotaPage-D2gyhfa8.js → QuotaPage-CVIQq6JG.js} +1 -1
  26. package/dist/dashboard/assets/QuotaPage-CVIQq6JG.js.gz +0 -0
  27. package/dist/dashboard/assets/{SettingsPage-1dbYb8cM.js → SettingsPage-BgXvRN2Q.js} +1 -1
  28. package/dist/dashboard/assets/SettingsPage-BgXvRN2Q.js.gz +0 -0
  29. package/dist/dashboard/assets/{SetupPage-DUTFy9wH.js → SetupPage-BCx07-bj.js} +1 -1
  30. package/dist/dashboard/assets/SetupPage-BCx07-bj.js.gz +0 -0
  31. package/dist/dashboard/assets/{SortableList-BZEhfDpZ.js → SortableList-MhkB6msu.js} +1 -1
  32. package/dist/dashboard/assets/SortableList-MhkB6msu.js.gz +0 -0
  33. package/dist/dashboard/assets/{StudioPage-GBDtsJjh.js → StudioPage-CTqK6Nsj.js} +1 -1
  34. package/dist/dashboard/assets/StudioPage-CTqK6Nsj.js.gz +0 -0
  35. package/dist/dashboard/assets/{UsagePage-CxidMvxq.js → UsagePage-Do65OWbr.js} +1 -1
  36. package/dist/dashboard/assets/UsagePage-Do65OWbr.js.gz +0 -0
  37. package/dist/dashboard/assets/{entry-BrksMru8.js → entry-CBHzQ6Qh.js} +3 -3
  38. package/dist/dashboard/assets/entry-CBHzQ6Qh.js.gz +0 -0
  39. package/dist/dashboard/assets/{index-DU61iviS.js → index-Ck4uwuYb.js} +2 -2
  40. package/dist/dashboard/assets/index-Ck4uwuYb.js.gz +0 -0
  41. package/dist/dashboard/assets/{select-Ciq_KFQ1.js → select-BrrUDUPc.js} +1 -1
  42. package/dist/dashboard/assets/select-BrrUDUPc.js.gz +0 -0
  43. package/dist/dashboard/index.html +1 -1
  44. package/dist/dashboard/index.html.gz +0 -0
  45. package/dist/dashboard/precompressed-assets.json +21 -21
  46. package/package.json +1 -1
  47. package/scripts/cli/tray.ts +34 -10
  48. package/src/transport/dispatch/streaming/finalize.ts +64 -2
  49. package/dist/dashboard/assets/BannedPage-B7OjIxCp.js.gz +0 -0
  50. package/dist/dashboard/assets/CliToolDetailPage-Bt-6y24w.js.gz +0 -0
  51. package/dist/dashboard/assets/CliToolsPage-C6LunsuE.js.gz +0 -0
  52. package/dist/dashboard/assets/CombosPage-CgyfN2Yy.js.gz +0 -0
  53. package/dist/dashboard/assets/ConsoleLogPage-BHWU7y6j.js.gz +0 -0
  54. package/dist/dashboard/assets/CustomizationPage-xIjU736m.js.gz +0 -0
  55. package/dist/dashboard/assets/HealthEventsModal-DeT1zkYG.js.gz +0 -0
  56. package/dist/dashboard/assets/LoginPage-ChVqIAam.js.gz +0 -0
  57. package/dist/dashboard/assets/OverviewPage-BD4GkRtS.js.gz +0 -0
  58. package/dist/dashboard/assets/ProviderDetailPage-BJXwqpKj.js.gz +0 -0
  59. package/dist/dashboard/assets/ProvidersPage-Ck64riM5.js.gz +0 -0
  60. package/dist/dashboard/assets/ProxyPage-Br_Leqq0.js.gz +0 -0
  61. package/dist/dashboard/assets/QuotaPage-D2gyhfa8.js.gz +0 -0
  62. package/dist/dashboard/assets/SettingsPage-1dbYb8cM.js.gz +0 -0
  63. package/dist/dashboard/assets/SetupPage-DUTFy9wH.js.gz +0 -0
  64. package/dist/dashboard/assets/SortableList-BZEhfDpZ.js.gz +0 -0
  65. package/dist/dashboard/assets/StudioPage-GBDtsJjh.js.gz +0 -0
  66. package/dist/dashboard/assets/UsagePage-CxidMvxq.js.gz +0 -0
  67. package/dist/dashboard/assets/entry-BrksMru8.js.gz +0 -0
  68. package/dist/dashboard/assets/index-DU61iviS.js.gz +0 -0
  69. package/dist/dashboard/assets/select-Ciq_KFQ1.js.gz +0 -0
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/entry-BrksMru8.js","assets/jsx-runtime-CXUMngI_.js","assets/app-MdVfwraB.js","assets/app-BUSiYL6F.css","assets/terminal-0_IjPWTk.js","assets/numbers-Dulqgys5.js","assets/use-modal-focus-By7oJoGd.js","assets/dialog-Iec_ywbD.js","assets/assert-DU6qrMA_.js","assets/query-keys-UETqfytp.js","assets/mutation-g_fduiNw.js","assets/useMutation-EDFRkn1i.js","assets/dialog-actions-B1axpEg7.js","assets/entry-BRszm4_Z.js","assets/brain-Cwed_72z.js","assets/chevron-right-BXIy5l3h.js","assets/circle-check-BU3v_mFW.js","assets/eye-C_hawfH4.js","assets/github-badge-BuDsrsPn.js","assets/state-DhZBfWgx.js","assets/key-round-UkavsGxp.js","assets/clipboard-button-e-Mlk0FH.js","assets/use-clipboard-B0Sy03fE.js","assets/scaling-nWE4Cx8f.js","assets/wrench-B6E1oEuY.js","assets/card-BOPBuBzD.js","assets/download-dRFo5_Wu.js","assets/tokens-COzario9.js","assets/stream-retry-5QnVuSSo.js","assets/entry-DcobaKFu.js","assets/arrow-right-Dl5yKnp8.js","assets/log-in-BmRjy60c.js","assets/message-circle-CCxGwRvv.js","assets/shield-check-DVS0Foqh.js","assets/use-reduced-motion-C4B0R6Sz.js"])))=>i.map(i=>d[i]);
2
- (function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function e(e){return e===`/share`||e.startsWith(`/share/`)?`share`:e===`/console`||e.startsWith(`/console/`)?`console`:`landing`}var t=`modulepreload`,n=function(e){return`/`+e},r={},i=function(e,i,a){let o=Promise.resolve();if(i&&i.length>0){let e=document.getElementsByTagName(`link`),s=document.querySelector(`meta[property=csp-nonce]`),c=s?.nonce||s?.getAttribute(`nonce`);function l(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function u(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}o=l(i.map(i=>{if(i=n(i,a),i=u(i),i in r)return;r[i]=!0;let o=i.endsWith(`.css`);for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.href===i&&(!o||n.rel===`stylesheet`))return}let s=document.createElement(`link`);if(s.rel=o?`stylesheet`:t,o||(s.as=`script`),s.crossOrigin=``,s.href=i,c&&s.setAttribute(`nonce`,c),document.head.appendChild(s),o)return new Promise((e,t)=>{s.addEventListener(`load`,e),s.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${i}`)))})}))}function s(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return o.then(t=>{for(let e of t||[])e.status===`rejected`&&s(e.reason);return e().catch(s)})},a=document.getElementById(`root`);if(a===null)throw Error(`Dashboard root element is missing`);var o=e(window.location.pathname);o===`console`?i(async()=>{let{mountConsole:e}=await import(`./entry-BrksMru8.js`);return{mountConsole:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(({mountConsole:e})=>e(a)):o===`share`?i(()=>import(`./entry-BRszm4_Z.js`).then(()=>void 0),__vite__mapDeps([13,1,2,3,14,5,15,16,17,18,19,20,21,22,23,24,25,26,27,28])):i(async()=>{let{mountLanding:e}=await import(`./entry-DcobaKFu.js`);return{mountLanding:e}},__vite__mapDeps([29,1,2,3,4,30,18,31,32,33,34])).then(({mountLanding:e})=>e(a));export{i as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/entry-CBHzQ6Qh.js","assets/jsx-runtime-CXUMngI_.js","assets/app-MdVfwraB.js","assets/app-BUSiYL6F.css","assets/terminal-0_IjPWTk.js","assets/numbers-Dulqgys5.js","assets/use-modal-focus-By7oJoGd.js","assets/dialog-Iec_ywbD.js","assets/assert-DU6qrMA_.js","assets/query-keys-UETqfytp.js","assets/mutation-g_fduiNw.js","assets/useMutation-EDFRkn1i.js","assets/dialog-actions-B1axpEg7.js","assets/entry-BRszm4_Z.js","assets/brain-Cwed_72z.js","assets/chevron-right-BXIy5l3h.js","assets/circle-check-BU3v_mFW.js","assets/eye-C_hawfH4.js","assets/github-badge-BuDsrsPn.js","assets/state-DhZBfWgx.js","assets/key-round-UkavsGxp.js","assets/clipboard-button-e-Mlk0FH.js","assets/use-clipboard-B0Sy03fE.js","assets/scaling-nWE4Cx8f.js","assets/wrench-B6E1oEuY.js","assets/card-BOPBuBzD.js","assets/download-dRFo5_Wu.js","assets/tokens-COzario9.js","assets/stream-retry-5QnVuSSo.js","assets/entry-DcobaKFu.js","assets/arrow-right-Dl5yKnp8.js","assets/log-in-BmRjy60c.js","assets/message-circle-CCxGwRvv.js","assets/shield-check-DVS0Foqh.js","assets/use-reduced-motion-C4B0R6Sz.js"])))=>i.map(i=>d[i]);
2
+ (function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function e(e){return e===`/share`||e.startsWith(`/share/`)?`share`:e===`/console`||e.startsWith(`/console/`)?`console`:`landing`}var t=`modulepreload`,n=function(e){return`/`+e},r={},i=function(e,i,a){let o=Promise.resolve();if(i&&i.length>0){let e=document.getElementsByTagName(`link`),s=document.querySelector(`meta[property=csp-nonce]`),c=s?.nonce||s?.getAttribute(`nonce`);function l(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function u(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}o=l(i.map(i=>{if(i=n(i,a),i=u(i),i in r)return;r[i]=!0;let o=i.endsWith(`.css`);for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.href===i&&(!o||n.rel===`stylesheet`))return}let s=document.createElement(`link`);if(s.rel=o?`stylesheet`:t,o||(s.as=`script`),s.crossOrigin=``,s.href=i,c&&s.setAttribute(`nonce`,c),document.head.appendChild(s),o)return new Promise((e,t)=>{s.addEventListener(`load`,e),s.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${i}`)))})}))}function s(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return o.then(t=>{for(let e of t||[])e.status===`rejected`&&s(e.reason);return e().catch(s)})},a=document.getElementById(`root`);if(a===null)throw Error(`Dashboard root element is missing`);var o=e(window.location.pathname);o===`console`?i(async()=>{let{mountConsole:e}=await import(`./entry-CBHzQ6Qh.js`);return{mountConsole:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(({mountConsole:e})=>e(a)):o===`share`?i(()=>import(`./entry-BRszm4_Z.js`).then(()=>void 0),__vite__mapDeps([13,1,2,3,14,5,15,16,17,18,19,20,21,22,23,24,25,26,27,28])):i(async()=>{let{mountLanding:e}=await import(`./entry-DcobaKFu.js`);return{mountLanding:e}},__vite__mapDeps([29,1,2,3,4,30,18,31,32,33,34])).then(({mountLanding:e})=>e(a));export{i as t};
@@ -1,4 +1,4 @@
1
- import{o as e,r as t,t as n}from"./jsx-runtime-CXUMngI_.js";import{u as r}from"./app-MdVfwraB.js";import{O as i,m as a}from"./numbers-Dulqgys5.js";import{lt as o}from"./entry-BrksMru8.js";var s=e(t(),1),c=e(r(),1),l=Object.defineProperty,u=(e,t)=>l(e,`name`,{value:t,configurable:!0});function d(e,[t,n]){return Math.min(n,Math.max(t,e))}u(d,`clamp`);var f=Object.defineProperty,p=(e,t)=>f(e,`name`,{value:t,configurable:!0}),m=!!(typeof window<`u`&&window.document&&window.document.createElement);function h(e,t,{checkForDefaultPrevented:n=!0}={}){return p(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}p(h,`composeEventHandlers`);function g(e){if(!m)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}p(g,`getOwnerWindow`);function _(e){if(!m)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}p(_,`getOwnerDocument`);function v(e,t=!1){let{activeElement:n}=_(e);if(!n?.nodeName)return null;if(y(n)&&n.contentDocument)return v(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=_(n).getElementById(e);if(t)return t}}return n}p(v,`getActiveElement`);function y(e){return e.tagName===`IFRAME`}p(y,`isFrame`);var b=n(),x=Object.defineProperty,S=(e,t)=>x(e,`name`,{value:t,configurable:!0});function C(e,t){let n=s.createContext(t);n.displayName=e+`Context`;let r=S(e=>{let{children:t,...r}=e,i=s.useMemo(()=>r,Object.values(r));return(0,b.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=s.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return S(i,`useContext`),[r,i]}S(C,`createContext`);function w(e,t=[]){let n=[];function r(t,r){let i=s.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=S(t=>{let{scope:n,children:r,...o}=t,c=n?.[e]?.[a]||i,l=s.useMemo(()=>o,Object.values(o));return(0,b.jsx)(c.Provider,{value:l,children:r})},`Provider`);o.displayName=t+`Provider`;function c(n,o,c={}){let{optional:l=!1}=c,u=o?.[e]?.[a]||i,d=s.useContext(u);if(d)return d;if(r!==void 0)return r;if(!l)throw Error(`\`${n}\` must be used within \`${t}\``)}return S(c,`useContext`),[o,c]}S(r,`createContext`);let i=S(()=>{let t=n.map(e=>s.createContext(e));return S(function(n){let r=n?.[e]||t;return s.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,T(i,...t)]}S(w,`createContextScope`);function T(...e){let t=e[0];if(e.length===1)return t;let n=S(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return S(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}S(T,`composeContextScopes`);var E=Object.defineProperty,D=(e,t)=>E(e,`name`,{value:t,configurable:!0});function O(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}D(O,`setRef`);function k(...e){return t=>{let n=!1,r=e.map(e=>{let r=O(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():O(e[t],null)}}}}D(k,`composeRefs`);function A(...e){return s.useCallback(k(...e),e)}D(A,`useComposedRefs`);var j=Object.defineProperty,M=(e,t)=>j(e,`name`,{value:t,configurable:!0});function N(e){let t=s.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,c=[];te(r)&&typeof ae==`function`&&(r=ae(r._payload)),s.Children.forEach(r,e=>{if(z(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;te(n)&&typeof ae==`function`&&(n=ae(n._payload)),a=I(t,n),c.push(a?.props?.children)}else c.push(e)}),a?a=s.cloneElement(a,void 0,c):!o&&s.Children.count(r)===1&&s.isValidElement(r)&&(a=r);let l=a?R(a):void 0,u=A(n,l);if(!a){if(r||r===0)throw Error(o?ie(e):re(e));return r}let d=L(i,a.props??{});return a.type!==s.Fragment&&(d.ref=n?u:l),s.cloneElement(a,d)});return t.displayName=`${e}.Slot`,t}M(N,`createSlot`);var P=Symbol.for(`radix.slottable`);function F(e){let t=M(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=P,t}M(F,`createSlottable`);var I=M((e,t)=>{if(`child`in e.props){let t=e.props.child;return s.isValidElement(t)?s.cloneElement(t,void 0,e.props.children(t.props.children)):null}return s.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function L(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}M(L,`mergeProps`);function R(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}M(R,`getElementRef`);function z(e){return s.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===P}M(z,`isSlottable`);var ee=Symbol.for(`react.lazy`);function te(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===ee&&`_payload`in e&&ne(e._payload)}M(te,`isLazyComponent`);function ne(e){return typeof e==`object`&&!!e&&`then`in e}M(ne,`isPromiseLike`);var re=M(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),ie=M(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),ae=s.use,oe=Object.defineProperty,B=(e,t)=>oe(e,`name`,{value:t,configurable:!0});function se(e){let t=e+`CollectionProvider`,[n,r]=w(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=B(e=>{let{scope:t,children:n}=e,r=s.useRef(null),a=s.useRef(new Map).current;return(0,b.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let c=e+`CollectionSlot`,l=N(c),u=s.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=A(t,a(c,n).collectionRef);return(0,b.jsx)(l,{ref:i,children:r})});u.displayName=c;let d=e+`CollectionItemSlot`,f=`data-radix-collection-item`,p=N(d),m=s.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=s.useRef(null),c=A(t,o),l=a(d,n);return s.useEffect(()=>(l.itemMap.set(o,{ref:o,...i}),()=>void l.itemMap.delete(o))),(0,b.jsx)(p,{[f]:``,ref:c,children:r})});m.displayName=d;function h(t){let n=a(e+`CollectionConsumer`,t);return s.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return B(h,`useCollection`),[{Provider:o,Slot:u,ItemSlot:m},h,r]}B(se,`createCollection`);var ce=new WeakMap,le=class e extends Map{static{B(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],ce.set(this,!0)}set(e,t){return ce.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=fe(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=ue(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=ue(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return ue(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function ue(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=de(e,t);return n===-1?void 0:e[n]}B(ue,`at`);function de(e,t){let n=e.length,r=fe(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}B(de,`toSafeIndex`);function fe(e){return e!==e||e===0?0:Math.trunc(e)}B(fe,`toSafeInteger`);function pe(e){let t=e+`CollectionProvider`,[n,r]=w(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new le,setItemMap:B(()=>void 0,`setItemMap`)}),o=B(({state:e,...t})=>e?(0,b.jsx)(l,{...t,state:e}):(0,b.jsx)(c,{...t}),`CollectionProvider`);o.displayName=t;let c=B(e=>{let t=g();return(0,b.jsx)(l,{...e,state:t})},`CollectionInit`);c.displayName=t+`Init`;let l=B(e=>{let{scope:t,children:n,state:r}=e,a=s.useRef(null),[o,c]=s.useState(null),l=A(a,c),[u,d]=r;return s.useEffect(()=>{if(!o)return;let e=_e(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,b.jsx)(i,{scope:t,itemMap:u,setItemMap:d,collectionRef:l,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);l.displayName=t+`Impl`;let u=e+`CollectionSlot`,d=N(u),f=s.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=A(t,a(u,n).collectionRef);return(0,b.jsx)(d,{ref:i,children:r})});f.displayName=u;let p=e+`CollectionItemSlot`,m=N(p),h=s.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=s.useRef(null),[c,l]=s.useState(null),u=A(t,o,l),{setItemMap:d}=a(p,n),f=s.useRef(i);me(f.current,i)||(f.current=i);let h=f.current;return s.useEffect(()=>{let e=h;return d(t=>c?t.has(c)?t.set(c,{...e,element:c}).toSorted(ge):(t.set(c,{...e,element:c}),t.toSorted(ge)):t),()=>{d(e=>!c||!e.has(c)?e:(e.delete(c),new le(e)))}},[c,h,d]),(0,b.jsx)(m,{"data-radix-collection-item":``,ref:u,children:r})});h.displayName=p;function g(){return s.useState(new le)}B(g,`useInitCollection`);function _(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return B(_,`useCollection`),[{Provider:o,Slot:f,ItemSlot:h},{createCollectionScope:r,useCollection:_,useInitCollection:g}]}B(pe,`createCollection`);function me(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}B(me,`shallowEqual`);function he(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}B(he,`isElementPreceding`);function ge(e,t){return!e[1].element||!t[1].element?0:he(e[1].element,t[1].element)?-1:1}B(ge,`sortByDocumentPosition`);function _e(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}B(_e,`getChildListObserver`);var ve=Object.defineProperty,ye=(e,t)=>ve(e,`name`,{value:t,configurable:!0}),be=s.createContext(void 0);function xe(e){let t=s.useContext(be);return e||t||`ltr`}ye(xe,`useDirection`);var Se=Object.defineProperty,Ce=(e,t)=>Se(e,`name`,{value:t,configurable:!0}),V=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=N(`Primitive.${t}`),r=s.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,b.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function we(e,t){e&&c.flushSync(()=>e.dispatchEvent(t))}Ce(we,`dispatchDiscreteCustomEvent`);var Te=Object.defineProperty,Ee=(e,t)=>Te(e,`name`,{value:t,configurable:!0});function H(e){let t=s.useRef(e);return s.useEffect(()=>{t.current=e}),s.useMemo(()=>((...e)=>t.current?.(...e)),[])}Ee(H,`useCallbackRef`);var De=Object.defineProperty,U=(e,t)=>De(e,`name`,{value:t,configurable:!0}),Oe=`dismissableLayer.update`,ke=`dismissableLayer.pointerDownOutside`,Ae=`dismissableLayer.focusOutside`,je,Me=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ne=s.forwardRef(U(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:c,onDismiss:l,...u}=e,d=s.useContext(Me),[f,p]=s.useState(null),m=f?.ownerDocument??globalThis?.document,[,g]=s.useState({}),_=A(t,p),v=Array.from(d.layers),[y]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),x=y?v.indexOf(y):-1,S=f?v.indexOf(f):-1,C=d.layersWithOutsidePointerEventsDisabled.size>0,w=S>=x,T=s.useRef(!1),E=Ie(e=>{a?.(e),c?.(e),e.defaultPrevented||l?.()},{ownerDocument:m,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:T,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:s.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...d.branches].some(t=>t.contains(e));return w&&!t},[d.branches,w])}),D=Le(e=>{if(r&&T.current)return;let t=e.target;[...d.branches].some(e=>e.contains(t))||(o?.(e),c?.(e),e.defaultPrevented||l?.())},m),O=f?S===v.length-1:!1,k=H(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))});return s.useEffect(()=>{if(O)return m.addEventListener(`keydown`,k,{capture:!0}),()=>m.removeEventListener(`keydown`,k,{capture:!0})},[m,O,k]),s.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(je=m.body.style.pointerEvents,m.body.style.pointerEvents=`none`),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),Re(),()=>{n&&(d.layersWithOutsidePointerEventsDisabled.delete(f),d.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=je))}},[f,m,n,d]),s.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),Re())},[f,d]),s.useEffect(()=>{let e=U(()=>g({}),`handleUpdate`);return document.addEventListener(Oe,e),()=>document.removeEventListener(Oe,e)},[]),(0,b.jsx)(V.div,{...u,ref:_,style:{pointerEvents:C?w?`auto`:`none`:void 0,...e.style},onFocusCapture:h(e.onFocusCapture,D.onFocusCapture),onBlurCapture:h(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:h(e.onPointerDownCapture,E.onPointerDownCapture)})},`DismissableLayer`));function Pe(){let e=s.useContext(Me),[t,n]=s.useState(null);return s.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}U(Pe,`useDismissableLayerSurface`);var Fe=U(()=>!0,`IS_TRUE`);function Ie(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Fe}=t,c=H(e),l=s.useRef(!1),u=s.useRef(!1),d=s.useRef(new Map),f=s.useRef(()=>{});return s.useEffect(()=>{function e(){u.current=!1,i.current=!1,d.current.clear()}U(e,`resetOutsideInteraction`);function t(){return Array.from(d.current.values()).some(Boolean)}U(t,`isOutsideInteractionIntercepted`);function s(e){if(!u.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||d.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{u.current&&f.current()},0)}U(s,`handleInteractionCapture`);function p(e){u.current&&d.current.set(e.type,!1)}U(p,`handleInteractionBubble`);let m=U(a=>{if(a.target&&!l.current){let s=function(){n.removeEventListener(`click`,f.current);let r=t();e(),r||ze(ke,c,p,{discrete:!0})};if(U(s,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,f.current),e(),l.current=!1;return}let p={originalEvent:a};u.current=!0,i.current=r&&a.button===0,d.current.clear(),!r||a.button!==0?s():(n.removeEventListener(`click`,f.current),f.current=s,n.addEventListener(`click`,f.current,{once:!0}))}else n.removeEventListener(`click`,f.current),e();l.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,s,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,f.current);for(let e of h)n.removeEventListener(e,s,!0),n.removeEventListener(e,p)}},[n,c,r,i,a,o]),{onPointerDownCapture:U(()=>l.current=!0,`onPointerDownCapture`)}}U(Ie,`usePointerDownOutside`);function Le(e,t=globalThis?.document){let n=H(e),r=s.useRef(!1);return s.useEffect(()=>{let e=U(e=>{e.target&&!r.current&&ze(Ae,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:U(()=>r.current=!0,`onFocusCapture`),onBlurCapture:U(()=>r.current=!1,`onBlurCapture`)}}U(Le,`useFocusOutside`);function Re(){let e=new CustomEvent(Oe);document.dispatchEvent(e)}U(Re,`dispatchUpdate`);function ze(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?we(i,a):i.dispatchEvent(a)}U(ze,`handleAndDispatchCustomEvent`);var Be=Object.defineProperty,Ve=(e,t)=>Be(e,`name`,{value:t,configurable:!0}),He=0,Ue=null;function We(e){return Ge(),e.children}Ve(We,`FocusGuards`);function Ge(){s.useEffect(()=>{Ue||={start:Ke(),end:Ke()};let{start:e,end:t}=Ue;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),He++,()=>{He===1&&(Ue?.start.remove(),Ue?.end.remove(),Ue=null),He=Math.max(0,He-1)}},[])}Ve(Ge,`useFocusGuards`);function Ke(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}Ve(Ke,`createFocusGuard`);var qe=Object.defineProperty,W=(e,t)=>qe(e,`name`,{value:t,configurable:!0}),Je=`focusScope.autoFocusOnMount`,Ye=`focusScope.autoFocusOnUnmount`,Xe={bubbles:!1,cancelable:!0},Ze=s.forwardRef(W(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[c,l]=s.useState(null),u=H(i),d=H(a),f=s.useRef(null),p=A(t,l),m=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(r){let e=function(e){if(m.paused||!c)return;let t=e.target;c.contains(t)?f.current=t:G(f.current,{select:!0})},t=function(e){if(m.paused||!c)return;let t=e.relatedTarget;t!==null&&(c.contains(t)||G(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&G(c)};W(e,`handleFocusIn`),W(t,`handleFocusOut`),W(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,c,m.paused]),s.useEffect(()=>{if(c){it.add(m);let e=document.activeElement;if(!c.contains(e)){let t=new CustomEvent(Je,Xe);c.addEventListener(Je,u),c.dispatchEvent(t),t.defaultPrevented||(Qe(st(et(c)),{select:!0}),document.activeElement===e&&G(c))}return()=>{c.removeEventListener(Je,u),setTimeout(()=>{let t=new CustomEvent(Ye,Xe);c.addEventListener(Ye,d),c.dispatchEvent(t),t.defaultPrevented||G(e??document.body,{select:!0}),c.removeEventListener(Ye,d),it.remove(m)},0)}}},[c,u,d,m]);let h=s.useCallback(e=>{if(!n&&!r||m.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=$e(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&G(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&G(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,m.paused]);return(0,b.jsx)(V.div,{tabIndex:-1,...o,ref:p,onKeyDown:h})},`FocusScope`));function Qe(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(G(r,{select:t}),document.activeElement!==n)return}W(Qe,`focusFirst`);function $e(e){let t=et(e);return[tt(t,e),tt(t.reverse(),e)]}W($e,`getTabbableEdges`);function et(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:W(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}W(et,`getTabbableCandidates`);function tt(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):nt(r,{upTo:t})))return r}W(tt,`findVisible`);function nt(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}W(nt,`isHidden`);function rt(e){return e instanceof HTMLInputElement&&`select`in e}W(rt,`isSelectableInput`);function G(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&rt(e)&&t&&e.select()}}W(G,`focus`);var it=at();function at(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=ot(e,t),e.unshift(t)},remove(t){e=ot(e,t),e[0]?.resume()}}}W(at,`createFocusScopesStack`);function ot(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}W(ot,`arrayRemove`);function st(e){return e.filter(e=>e.tagName!==`A`)}W(st,`removeLinks`);var K=globalThis?.document?s.useLayoutEffect:()=>{},ct=Object.defineProperty,lt=(e,t)=>ct(e,`name`,{value:t,configurable:!0}),ut=s.useId||(()=>void 0),dt=0;function ft(e){let[t,n]=s.useState(ut());return K(()=>{e||n(e=>e??String(dt++))},[e]),e||(t?`radix-${t}`:``)}lt(ft,`useId`);var pt=[`top`,`right`,`bottom`,`left`],mt=Math.min,ht=Math.max,gt=Math.round,_t=Math.floor,vt=e=>({x:e,y:e}),yt={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function bt(e,t,n){return ht(e,mt(t,n))}function xt(e,t){return typeof e==`function`?e(t):e}function St(e){return e.split(`-`)[0]}function Ct(e){return e.split(`-`)[1]}function wt(e){return e===`x`?`y`:`x`}function Tt(e){return e===`y`?`height`:`width`}function q(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Et(e){return wt(q(e))}function Dt(e,t,n){n===void 0&&(n=!1);let r=Ct(e),i=Et(e),a=Tt(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=It(o)),[o,It(o)]}function Ot(e){let t=It(e);return[kt(e),t,kt(t)]}function kt(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var At=[`left`,`right`],jt=[`right`,`left`],Mt=[`top`,`bottom`],Nt=[`bottom`,`top`];function Pt(e,t,n){switch(e){case`top`:case`bottom`:return n?t?jt:At:t?At:jt;case`left`:case`right`:return t?Mt:Nt;default:return[]}}function Ft(e,t,n,r){let i=Ct(e),a=Pt(St(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(kt)))),a}function It(e){let t=St(e);return yt[t]+e.slice(t.length)}function Lt(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Rt(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Lt(e)}function zt(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Bt(e,t,n){let{reference:r,floating:i}=e,a=q(t),o=Et(t),s=Tt(o),c=St(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Ct(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Vt(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=xt(t,e),p=Rt(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=zt(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=zt(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Ht=50,Ut=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Vt},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Bt(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Ht&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Bt(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Wt=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=xt(e,t)||{};if(l==null)return{};let d=Rt(u),f={x:n,y:r},p=Et(i),m=Tt(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=mt(d[_],T),D=mt(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=bt(E,k,O),j=!c.arrow&&Ct(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Gt=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=xt(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=St(r),_=q(o),v=St(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[It(o)]:Ot(o)),x=p!==`none`;!d&&x&&b.push(...Ft(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Dt(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===q(t)||T.every(e=>q(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=q(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Kt(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function qt(e){return pt.some(t=>e[t]>=0)}var Jt=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=xt(e,t);switch(i){case`referenceHidden`:{let e=Kt(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:qt(e)}}}case`escaped`:{let e=Kt(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:qt(e)}}}default:return{}}}}},Yt=new Set([`left`,`top`]);async function Xt(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=St(n),s=Ct(n),c=q(n)===`y`,l=Yt.has(o)?-1:1,u=a&&c?-1:1,d=xt(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Zt=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Xt(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Qt=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=xt(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=q(i),p=wt(f),m=u[p],h=u[f],g=(e,t)=>bt(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},$t=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=xt(e,t),u={x:n,y:r},d=q(i),f=wt(d),p=u[f],m=u[d],h=xt(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Yt.has(St(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},en=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=xt(e,t),c=await i.detectOverflow(t,s),l=St(n),u=Ct(n),d=q(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=mt(p-c[m],g),y=mt(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*ht(c.left,c.right):S=p-2*ht(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function tn(){return typeof window<`u`}function nn(e){return an(e)?(e.nodeName||``).toLowerCase():`#document`}function J(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function rn(e){return((an(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function an(e){return tn()?e instanceof Node||e instanceof J(e).Node:!1}function Y(e){return tn()?e instanceof Element||e instanceof J(e).Element:!1}function on(e){return tn()?e instanceof HTMLElement||e instanceof J(e).HTMLElement:!1}function sn(e){return!tn()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof J(e).ShadowRoot}function cn(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=X(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ln(e){return/^(table|td|th)$/.test(nn(e))}function un(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var dn=/transform|translate|scale|rotate|perspective|filter/,fn=/paint|layout|strict|content/,pn=e=>!!e&&e!==`none`,mn;function hn(e){let t=Y(e)?X(e):e;return pn(t.transform)||pn(t.translate)||pn(t.scale)||pn(t.rotate)||pn(t.perspective)||!_n()&&(pn(t.backdropFilter)||pn(t.filter))||dn.test(t.willChange||``)||fn.test(t.contain||``)}function gn(e){let t=bn(e);for(;on(t)&&!vn(t);){if(hn(t))return t;if(un(t))return null;t=bn(t)}return null}function _n(){return mn??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),mn}function vn(e){return/^(html|body|#document)$/.test(nn(e))}function X(e){return J(e).getComputedStyle(e)}function yn(e){return Y(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function bn(e){if(nn(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||sn(e)&&e.host||rn(e);return sn(t)?t.host:t}function xn(e){let t=bn(e);return vn(t)?(e.ownerDocument||e).body:on(t)&&cn(t)?t:xn(t)}function Sn(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=xn(e),i=r===e.ownerDocument?.body,a=J(r);if(i){let e=Cn(a);return t.concat(a,a.visualViewport||[],cn(r)?r:[],e&&n?Sn(e):[])}return t.concat(r,Sn(r,[],n))}function Cn(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function wn(e){let t=X(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=on(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=gt(n)!==a||gt(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Tn(e){return Y(e)?e:e.contextElement}function En(e){let t=Tn(e);if(!on(t))return vt(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=wn(t),o=(a?gt(n.width):n.width)/r,s=(a?gt(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Dn=vt(0);function On(e){let t=J(e);return!_n()||!t.visualViewport?Dn:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function kn(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===J(e)}function An(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Tn(e),o=vt(1);t&&(r?Y(r)&&(o=En(r)):o=En(e));let s=kn(a,n,r)?On(a):vt(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=J(a),t=Y(r)?J(r):r,n=e,i=Cn(n);for(;i&&t!==n;){let e=En(i),t=i.getBoundingClientRect(),r=X(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=J(i),i=Cn(n)}}return zt({width:u,height:d,x:c,y:l})}function jn(e,t){let n=yn(e).scrollLeft;return t?t.left+n:An(rn(e)).left+n}function Mn(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-jn(e,n),y:n.top+t.scrollTop}}function Nn(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=rn(r),s=t?un(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=vt(1),u=vt(0),d=on(r);if((d||!a)&&((nn(r)!==`body`||cn(o))&&(c=yn(r)),d)){let e=An(r);l=En(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Mn(o,c):vt(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Pn(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Fn(e){let t=yn(e),n=e.ownerDocument.body,r=ht(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=ht(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+jn(e),o=-t.scrollTop;return X(n).direction===`rtl`&&(a+=ht(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var In=25;function Ln(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=J(e),a=rn(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!_n()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(jn(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=In&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Rn(e,t){let n=An(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=En(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function zn(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Ln(e,n,t);else if(t===`document`)r=Fn(rn(e));else if(Y(t))r=Rn(t,n);else{let n=On(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return zt(r)}function Bn(e,t){let n=t.get(e);if(n)return n;let r=Sn(e,[],!1).filter(e=>Y(e)&&nn(e)!==`body`),i=null,a=X(e).position===`fixed`,o=a?bn(e):e;for(;Y(o)&&!vn(o);){let e=X(o),t=hn(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=bn(o)}return t.set(e,r),r}function Vn(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?un(t)?[]:Bn(t,this._c):[].concat(n),r],o=zn(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=zn(t,a[e],i);s=ht(n.top,s),c=mt(n.right,c),l=mt(n.bottom,l),u=ht(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Hn(e){let{width:t,height:n}=wn(e);return{width:t,height:n}}function Un(e,t,n){let r=on(t),i=rn(t),a=n===`fixed`,o=An(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=vt(0);if((r||!a)&&((nn(t)!==`body`||cn(i))&&(s=yn(t)),r)){let e=An(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=jn(i));let l=i&&!r&&!a?Mn(i,s):vt(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Wn(e){return X(e).position===`static`}function Gn(e,t){if(!on(e)||X(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return rn(e)===n&&(n=n.ownerDocument.body),n}function Kn(e,t){let n=J(e);if(un(e))return n;if(!on(e)){let t=bn(e);for(;t&&!vn(t);){if(Y(t)&&!Wn(t))return t;t=bn(t)}return n}let r=Gn(e,t);for(;r&&ln(r)&&Wn(r);)r=Gn(r,t);return r&&vn(r)&&Wn(r)&&!hn(r)?n:r||gn(e)||n}var qn=async function(e){let t=this.getOffsetParent||Kn,n=this.getDimensions,r=await n(e.floating);return{reference:Un(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Jn(e){return X(e).direction===`rtl`}var Yn={convertOffsetParentRelativeRectToViewportRelativeRect:Nn,getDocumentElement:rn,getClippingRect:Vn,getOffsetParent:Kn,getElementRects:qn,getClientRects:Pn,getDimensions:Hn,getScale:En,isElement:Y,isRTL:Jn};function Xn(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Zn(e,t,n){let r=null,i,a=rn(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=_t(d),h=_t(a.clientWidth-(u+f)),g=_t(a.clientHeight-(d+p)),_=_t(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:ht(0,mt(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Xn(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=J(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Qn(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Tn(e),u=i||a?[...l?Sn(l):[],...t?Sn(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Zn(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?An(e):null;c&&g();function g(){let t=An(e);h&&!Xn(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var $n=Zt,er=Qt,tr=Gt,nr=en,rr=Jt,ir=Wt,ar=$t,or=(e,t,n)=>{let r=new Map,i=n??{},a={...Yn,...i.platform,_c:r};return Ut(e,t,{...i,platform:a})},sr=typeof document<`u`?s.useLayoutEffect:function(){};function cr(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!cr(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!cr(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function lr(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ur(e,t){let n=lr(e);return Math.round(t*n)/n}function dr(e){let t=s.useRef(e);return sr(()=>{t.current=e}),t}function fr(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[f,p]=s.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=s.useState(r);cr(m,r)||h(r);let[g,_]=s.useState(null),[v,y]=s.useState(null),b=s.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=s.useCallback(e=>{e!==T.current&&(T.current=e,y(e))},[]),S=a||g,C=o||v,w=s.useRef(null),T=s.useRef(null),E=s.useRef(f),D=u!=null,O=dr(u),k=dr(i),A=dr(d),j=s.useCallback(()=>{if(!w.current||!T.current)return;let e={placement:t,strategy:n,middleware:m};k.current&&(e.platform=k.current),or(w.current,T.current,e).then(e=>{let t={...e,isPositioned:A.current!==!1};M.current&&!cr(E.current,t)&&(E.current=t,c.flushSync(()=>{p(t)}))})},[m,t,n,k,A]);sr(()=>{d===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,p(e=>({...e,isPositioned:!1})))},[d]);let M=s.useRef(!1);sr(()=>(M.current=!0,()=>{M.current=!1}),[]),sr(()=>{if(S&&(w.current=S),C&&(T.current=C),S&&C){if(O.current)return O.current(S,C,j);j()}},[S,C,j,O,D]);let N=s.useMemo(()=>({reference:w,floating:T,setReference:b,setFloating:x}),[b,x]),P=s.useMemo(()=>({reference:S,floating:C}),[S,C]),F=s.useMemo(()=>{let e={position:n,left:0,top:0};if(!P.floating)return e;let t=ur(P.floating,f.x),r=ur(P.floating,f.y);return l?{...e,transform:`translate(`+t+`px, `+r+`px)`,...lr(P.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,l,P.floating,f.x,f.y]);return s.useMemo(()=>({...f,update:j,refs:N,elements:P,floatingStyles:F}),[f,j,N,P,F])}var pr=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:ir({element:r.current,padding:i}).fn(n):r?ir({element:r,padding:i}).fn(n):{}}}},mr=(e,t)=>{let n=$n(e);return{name:n.name,fn:n.fn,options:[e,t]}},hr=(e,t)=>{let n=er(e);return{name:n.name,fn:n.fn,options:[e,t]}},gr=(e,t)=>({fn:ar(e).fn,options:[e,t]}),_r=(e,t)=>{let n=tr(e);return{name:n.name,fn:n.fn,options:[e,t]}},vr=(e,t)=>{let n=nr(e);return{name:n.name,fn:n.fn,options:[e,t]}},yr=(e,t)=>{let n=rr(e);return{name:n.name,fn:n.fn,options:[e,t]}},br=(e,t)=>{let n=pr(e);return{name:n.name,fn:n.fn,options:[e,t]}},xr=Object.defineProperty,Sr=(e,t)=>xr(e,`name`,{value:t,configurable:!0});function Cr(e){let[t,n]=s.useState(void 0);return K(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}Sr(Cr,`useSize`);var wr=Object.defineProperty,Tr=(e,t)=>wr(e,`name`,{value:t,configurable:!0}),Er=`Popper`,[Dr,Or]=w(Er),[kr,Ar]=Dr(Er),jr=Tr(e=>{let{__scopePopper:t,children:n}=e,[r,i]=s.useState(null),[a,o]=s.useState(void 0);return(0,b.jsx)(kr,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Mr=`PopperAnchor`,Nr=s.forwardRef(Tr(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=Ar(Mr,n),o=s.useRef(null),c=a.onAnchorChange,l=A(t,s.useCallback(e=>{o.current=e,e&&c(e)},[c])),u=s.useRef(null);s.useEffect(()=>{if(!r)return;let e=u.current;u.current=r.current,e!==u.current&&c(u.current)});let d=a.placementState&&Br(a.placementState),f=d?.[0],p=d?.[1];return r?null:(0,b.jsx)(V.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...i,ref:l})},`PopperAnchor`)),Pr=`PopperContent`,[Fr,Ir]=Dr(Pr),Lr=s.forwardRef(Tr(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f=`partial`,hideWhenDetached:p=!1,updatePositionStrategy:m=`optimized`,onPlaced:h,...g}=e,_=Ar(Pr,n),[v,y]=s.useState(null),x=A(t,y),[S,C]=s.useState(null),w=Cr(S),T=w?.width??0,E=w?.height??0,D=r+(a===`center`?``:`-`+a),O=typeof d==`number`?d:{top:0,right:0,bottom:0,left:0,...d},k=Array.isArray(u)?u:[u],j=k.length>0,M={padding:O,boundary:k.filter(Rr),altBoundary:j},{refs:N,floatingStyles:P,placement:F,isPositioned:I,middlewareData:L}=fr({strategy:`fixed`,placement:D,whileElementsMounted:Tr((...e)=>Qn(...e,{animationFrame:m===`always`}),`whileElementsMounted`),elements:{reference:_.anchor},middleware:[mr({mainAxis:i+E,alignmentAxis:o}),l&&hr({mainAxis:!0,crossAxis:!1,limiter:f===`partial`?gr():void 0,...M}),l&&_r({...M}),vr({...M,apply:Tr(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),S&&br({element:S,padding:c}),zr({arrowWidth:T,arrowHeight:E}),p&&yr({strategy:`referenceHidden`,...M,boundary:j?M.boundary:void 0})]}),R=_.setPlacementState;K(()=>(R(F),()=>{R(void 0)}),[F,R]);let[z,ee]=Br(F),te=H(h);K(()=>{I&&te?.()},[I,te]);let ne=L.arrow?.x,re=L.arrow?.y,ie=L.arrow?.centerOffset!==0,[ae,oe]=s.useState();return K(()=>{v&&oe(window.getComputedStyle(v).zIndex)},[v]),(0,b.jsx)(`div`,{ref:N.setFloating,"data-radix-popper-content-wrapper":``,style:{...P,transform:I?P.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[L.transformOrigin?.x,L.transformOrigin?.y].join(` `),...L.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,b.jsx)(Fr,{scope:n,placedSide:z,placedAlign:ee,onArrowChange:C,arrowX:ne,arrowY:re,shouldHideArrow:ie,children:(0,b.jsx)(V.div,{"data-side":z,"data-align":ee,...g,ref:x,style:{...g.style,animation:I?g.style?.animation:`none`}})})})},`PopperContent`));function Rr(e){return e!==null}Tr(Rr,`isNotNull`);var zr=Tr(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Br(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Br(e){let[t,n=`center`]=e.split(`-`);return[t,n]}Tr(Br,`getSideAndAlignFromPlacement`);var Vr=jr,Hr=Nr,Ur=Lr,Wr=Object.defineProperty,Gr=s.forwardRef(((e,t)=>Wr(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=s.useState(!1);K(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?c.createPortal((0,b.jsx)(V.div,{...r,ref:t}),o):null},`Portal`)),Kr=Object.defineProperty,qr=(e,t)=>Kr(e,`name`,{value:t,configurable:!0});function Jr(e,t){return s.useReducer((e,n)=>t[e][n]??e,e)}qr(Jr,`useStateMachine`);var Yr=qr(e=>{let{present:t,children:n}=e,r=Xr(t),i=typeof n==`function`?n({present:r.isPresent}):s.Children.only(n),a=Qr(r.ref,ei(i));return typeof n==`function`||r.isPresent?s.cloneElement(i,{ref:a}):null},`Presence`);function Xr(e){let[t,n]=s.useState(),r=s.useRef(null),i=s.useRef(e),a=s.useRef(`none`),o=s.useRef(void 0),[c,l]=Jr(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return s.useEffect(()=>{c===`mounted`?(a.current=o.current??$r(r.current),o.current=void 0):a.current=`none`},[c]),K(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=$r(t);e?(o.current=s,l(`MOUNT`)):s===`none`||t?.display===`none`?l(`UNMOUNT`):l(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,l]),K(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=qr(a=>{let o=$r(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(l(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=qr(e=>{e.target===t&&(a.current=$r(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}l(`ANIMATION_END`)},[t,l]),{isPresent:[`mounted`,`unmountSuspended`].includes(c),ref:s.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=$r(t)}else r.current=null;n(e)},[])}}qr(Xr,`usePresence`);function Zr(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}qr(Zr,`setRef`);function Qr(...e){let t=s.useRef(e);return t.current=e,s.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Zr(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():Zr(n[e],null)}}},[])}qr(Qr,`useStableComposedRefs`);function $r(e){return e?.animationName||`none`}qr($r,`getAnimationName`);function ei(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}qr(ei,`getElementRef`);var ti=Object.defineProperty,ni=(e,t)=>ti(e,`name`,{value:t,configurable:!0}),ri=s.useEffectEvent,ii=s.useInsertionEffect;function ai(e){if(typeof ri==`function`)return ri(e);let t=s.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof ii==`function`?ii(()=>{t.current=e}):K(()=>{t.current=e}),s.useMemo(()=>((...e)=>t.current?.(...e)),[])}ni(ai,`useEffectEvent`);var oi=Object.defineProperty,si=(e,t)=>oi(e,`name`,{value:t,configurable:!0}),ci=s.useInsertionEffect||K;function li({prop:e,defaultProp:t,onChange:n=si(()=>{},`onChange`),caller:r}){let[i,a,o]=ui({defaultProp:t,onChange:n}),c=e!==void 0;return[c?e:i,s.useCallback(t=>{if(c){let n=di(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[c,e,a,o])]}si(li,`useControllableState`);function ui({defaultProp:e,onChange:t}){let[n,r]=s.useState(e),i=s.useRef(n),a=s.useRef(t);return ci(()=>{a.current=t},[t]),s.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}si(ui,`useUncontrolledState`);function di(e){return typeof e==`function`}si(di,`isFunction`);var fi=Symbol(`RADIX:SYNC_STATE`);function pi(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:c}=t,l=i!==void 0,u=ai(o),d=[{...n,state:a}];r&&d.push(r);let[f,p]=s.useReducer((t,n)=>{if(n.type===fi)return{...t,state:n.state};let r=e(t,n);return l&&!Object.is(r.state,t.state)&&u(r.state),r},...d),m=f.state,h=s.useRef(m);s.useEffect(()=>{h.current!==m&&(h.current=m,l||u(m))},[m,h,l]);let g=s.useMemo(()=>i===void 0?f:{...f,state:i},[f,i]);return s.useEffect(()=>{l&&!Object.is(i,f.state)&&p({type:fi,state:i})},[i,f.state,l]),[g,p]}si(pi,`useControllableStateReducer`);var mi=Object.defineProperty,hi=(e,t)=>mi(e,`name`,{value:t,configurable:!0});function gi(e){let t=s.useRef({value:e,previous:e});return s.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}hi(gi,`usePrevious`);var _i=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),vi=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},yi=new WeakMap,bi=new WeakMap,xi={},Si=0,Ci=function(e){return e&&(e.host||Ci(e.parentNode))},wi=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Ci(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Ti=function(e,t,n,r){var i=wi(t,Array.isArray(e)?e:[e]);xi[n]||(xi[n]=new WeakMap);var a=xi[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(yi.get(e)||0)+1,l=(a.get(e)||0)+1;yi.set(e,c),a.set(e,l),o.push(e),c===1&&i&&bi.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),Si++,function(){o.forEach(function(e){var t=yi.get(e)-1,i=a.get(e)-1;yi.set(e,t),a.set(e,i),t||(bi.has(e)||e.removeAttribute(r),bi.delete(e)),i||e.removeAttribute(n)}),Si--,Si||(yi=new WeakMap,yi=new WeakMap,bi=new WeakMap,xi={})}},Ei=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||vi(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Ti(r,i,n,`aria-hidden`)):function(){return null}},Z=function(){return Z=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Z.apply(this,arguments)};function Di(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Oi(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var ki=`right-scroll-bar-position`,Ai=`width-before-scroll-bar`,ji=`with-scroll-bars-hidden`,Mi=`--removed-body-scroll-bar-size`;function Ni(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Pi(e,t){var n=(0,s.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Fi=typeof window<`u`?s.useLayoutEffect:s.useEffect,Ii=new WeakMap;function Li(e,t){var n=Pi(t||null,function(t){return e.forEach(function(e){return Ni(e,t)})});return Fi(function(){var t=Ii.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Ni(e,null)}),i.forEach(function(e){r.has(e)||Ni(e,a)})}Ii.set(n,e)},[e]),n}function Ri(e){return e}function zi(e,t){t===void 0&&(t=Ri);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Bi(e){e===void 0&&(e={});var t=zi(null);return t.options=Z({async:!0,ssr:!1},e),t}var Vi=function(e){var t=e.sideCar,n=Di(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return s.createElement(r,Z({},n))};Vi.isSideCarExport=!0;function Hi(e,t){return e.useMedium(t),Vi}var Ui=Bi(),Wi=function(){},Gi=s.forwardRef(function(e,t){var n=s.useRef(null),r=s.useState({onScrollCapture:Wi,onWheelCapture:Wi,onTouchMoveCapture:Wi}),i=r[0],a=r[1],o=e.forwardProps,c=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=Di(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=Li([n,t]),w=Z(Z({},x),i);return s.createElement(s.Fragment,null,d&&s.createElement(S,{sideCar:Ui,removeScrollBar:u,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?s.cloneElement(s.Children.only(c),Z(Z({},w),{ref:C})):s.createElement(y,Z({},w,{className:l,ref:C}),c))});Gi.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Gi.classNames={fullWidth:Ai,zeroRight:ki};var Ki=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function qi(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Ki();return t&&e.setAttribute(`nonce`,t),e}function Ji(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Yi(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Xi=function(){var e=0,t=null;return{add:function(n){e==0&&(t=qi())&&(Ji(t,n),Yi(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Zi=function(){var e=Xi();return function(t,n){s.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Qi=function(){var e=Zi();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},$i={left:0,top:0,right:0,gap:0},ea=function(e){return parseInt(e||``,10)||0},ta=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[ea(n),ea(r),ea(i)]},na=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return $i;var t=ta(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ra=Qi(),ia=`data-scroll-locked`,aa=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
1
+ import{o as e,r as t,t as n}from"./jsx-runtime-CXUMngI_.js";import{u as r}from"./app-MdVfwraB.js";import{O as i,m as a}from"./numbers-Dulqgys5.js";import{lt as o}from"./entry-CBHzQ6Qh.js";var s=e(t(),1),c=e(r(),1),l=Object.defineProperty,u=(e,t)=>l(e,`name`,{value:t,configurable:!0});function d(e,[t,n]){return Math.min(n,Math.max(t,e))}u(d,`clamp`);var f=Object.defineProperty,p=(e,t)=>f(e,`name`,{value:t,configurable:!0}),m=!!(typeof window<`u`&&window.document&&window.document.createElement);function h(e,t,{checkForDefaultPrevented:n=!0}={}){return p(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}p(h,`composeEventHandlers`);function g(e){if(!m)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}p(g,`getOwnerWindow`);function _(e){if(!m)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}p(_,`getOwnerDocument`);function v(e,t=!1){let{activeElement:n}=_(e);if(!n?.nodeName)return null;if(y(n)&&n.contentDocument)return v(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=_(n).getElementById(e);if(t)return t}}return n}p(v,`getActiveElement`);function y(e){return e.tagName===`IFRAME`}p(y,`isFrame`);var b=n(),x=Object.defineProperty,S=(e,t)=>x(e,`name`,{value:t,configurable:!0});function C(e,t){let n=s.createContext(t);n.displayName=e+`Context`;let r=S(e=>{let{children:t,...r}=e,i=s.useMemo(()=>r,Object.values(r));return(0,b.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=s.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return S(i,`useContext`),[r,i]}S(C,`createContext`);function w(e,t=[]){let n=[];function r(t,r){let i=s.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=S(t=>{let{scope:n,children:r,...o}=t,c=n?.[e]?.[a]||i,l=s.useMemo(()=>o,Object.values(o));return(0,b.jsx)(c.Provider,{value:l,children:r})},`Provider`);o.displayName=t+`Provider`;function c(n,o,c={}){let{optional:l=!1}=c,u=o?.[e]?.[a]||i,d=s.useContext(u);if(d)return d;if(r!==void 0)return r;if(!l)throw Error(`\`${n}\` must be used within \`${t}\``)}return S(c,`useContext`),[o,c]}S(r,`createContext`);let i=S(()=>{let t=n.map(e=>s.createContext(e));return S(function(n){let r=n?.[e]||t;return s.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,T(i,...t)]}S(w,`createContextScope`);function T(...e){let t=e[0];if(e.length===1)return t;let n=S(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return S(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}S(T,`composeContextScopes`);var E=Object.defineProperty,D=(e,t)=>E(e,`name`,{value:t,configurable:!0});function O(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}D(O,`setRef`);function k(...e){return t=>{let n=!1,r=e.map(e=>{let r=O(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():O(e[t],null)}}}}D(k,`composeRefs`);function A(...e){return s.useCallback(k(...e),e)}D(A,`useComposedRefs`);var j=Object.defineProperty,M=(e,t)=>j(e,`name`,{value:t,configurable:!0});function N(e){let t=s.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,c=[];te(r)&&typeof ae==`function`&&(r=ae(r._payload)),s.Children.forEach(r,e=>{if(z(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;te(n)&&typeof ae==`function`&&(n=ae(n._payload)),a=I(t,n),c.push(a?.props?.children)}else c.push(e)}),a?a=s.cloneElement(a,void 0,c):!o&&s.Children.count(r)===1&&s.isValidElement(r)&&(a=r);let l=a?R(a):void 0,u=A(n,l);if(!a){if(r||r===0)throw Error(o?ie(e):re(e));return r}let d=L(i,a.props??{});return a.type!==s.Fragment&&(d.ref=n?u:l),s.cloneElement(a,d)});return t.displayName=`${e}.Slot`,t}M(N,`createSlot`);var P=Symbol.for(`radix.slottable`);function F(e){let t=M(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=P,t}M(F,`createSlottable`);var I=M((e,t)=>{if(`child`in e.props){let t=e.props.child;return s.isValidElement(t)?s.cloneElement(t,void 0,e.props.children(t.props.children)):null}return s.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function L(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}M(L,`mergeProps`);function R(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}M(R,`getElementRef`);function z(e){return s.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===P}M(z,`isSlottable`);var ee=Symbol.for(`react.lazy`);function te(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===ee&&`_payload`in e&&ne(e._payload)}M(te,`isLazyComponent`);function ne(e){return typeof e==`object`&&!!e&&`then`in e}M(ne,`isPromiseLike`);var re=M(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),ie=M(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),ae=s.use,oe=Object.defineProperty,B=(e,t)=>oe(e,`name`,{value:t,configurable:!0});function se(e){let t=e+`CollectionProvider`,[n,r]=w(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=B(e=>{let{scope:t,children:n}=e,r=s.useRef(null),a=s.useRef(new Map).current;return(0,b.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let c=e+`CollectionSlot`,l=N(c),u=s.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=A(t,a(c,n).collectionRef);return(0,b.jsx)(l,{ref:i,children:r})});u.displayName=c;let d=e+`CollectionItemSlot`,f=`data-radix-collection-item`,p=N(d),m=s.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=s.useRef(null),c=A(t,o),l=a(d,n);return s.useEffect(()=>(l.itemMap.set(o,{ref:o,...i}),()=>void l.itemMap.delete(o))),(0,b.jsx)(p,{[f]:``,ref:c,children:r})});m.displayName=d;function h(t){let n=a(e+`CollectionConsumer`,t);return s.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return B(h,`useCollection`),[{Provider:o,Slot:u,ItemSlot:m},h,r]}B(se,`createCollection`);var ce=new WeakMap,le=class e extends Map{static{B(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],ce.set(this,!0)}set(e,t){return ce.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=fe(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=ue(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=ue(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return ue(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function ue(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=de(e,t);return n===-1?void 0:e[n]}B(ue,`at`);function de(e,t){let n=e.length,r=fe(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}B(de,`toSafeIndex`);function fe(e){return e!==e||e===0?0:Math.trunc(e)}B(fe,`toSafeInteger`);function pe(e){let t=e+`CollectionProvider`,[n,r]=w(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new le,setItemMap:B(()=>void 0,`setItemMap`)}),o=B(({state:e,...t})=>e?(0,b.jsx)(l,{...t,state:e}):(0,b.jsx)(c,{...t}),`CollectionProvider`);o.displayName=t;let c=B(e=>{let t=g();return(0,b.jsx)(l,{...e,state:t})},`CollectionInit`);c.displayName=t+`Init`;let l=B(e=>{let{scope:t,children:n,state:r}=e,a=s.useRef(null),[o,c]=s.useState(null),l=A(a,c),[u,d]=r;return s.useEffect(()=>{if(!o)return;let e=_e(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,b.jsx)(i,{scope:t,itemMap:u,setItemMap:d,collectionRef:l,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);l.displayName=t+`Impl`;let u=e+`CollectionSlot`,d=N(u),f=s.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=A(t,a(u,n).collectionRef);return(0,b.jsx)(d,{ref:i,children:r})});f.displayName=u;let p=e+`CollectionItemSlot`,m=N(p),h=s.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=s.useRef(null),[c,l]=s.useState(null),u=A(t,o,l),{setItemMap:d}=a(p,n),f=s.useRef(i);me(f.current,i)||(f.current=i);let h=f.current;return s.useEffect(()=>{let e=h;return d(t=>c?t.has(c)?t.set(c,{...e,element:c}).toSorted(ge):(t.set(c,{...e,element:c}),t.toSorted(ge)):t),()=>{d(e=>!c||!e.has(c)?e:(e.delete(c),new le(e)))}},[c,h,d]),(0,b.jsx)(m,{"data-radix-collection-item":``,ref:u,children:r})});h.displayName=p;function g(){return s.useState(new le)}B(g,`useInitCollection`);function _(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return B(_,`useCollection`),[{Provider:o,Slot:f,ItemSlot:h},{createCollectionScope:r,useCollection:_,useInitCollection:g}]}B(pe,`createCollection`);function me(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}B(me,`shallowEqual`);function he(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}B(he,`isElementPreceding`);function ge(e,t){return!e[1].element||!t[1].element?0:he(e[1].element,t[1].element)?-1:1}B(ge,`sortByDocumentPosition`);function _e(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}B(_e,`getChildListObserver`);var ve=Object.defineProperty,ye=(e,t)=>ve(e,`name`,{value:t,configurable:!0}),be=s.createContext(void 0);function xe(e){let t=s.useContext(be);return e||t||`ltr`}ye(xe,`useDirection`);var Se=Object.defineProperty,Ce=(e,t)=>Se(e,`name`,{value:t,configurable:!0}),V=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=N(`Primitive.${t}`),r=s.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,b.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function we(e,t){e&&c.flushSync(()=>e.dispatchEvent(t))}Ce(we,`dispatchDiscreteCustomEvent`);var Te=Object.defineProperty,Ee=(e,t)=>Te(e,`name`,{value:t,configurable:!0});function H(e){let t=s.useRef(e);return s.useEffect(()=>{t.current=e}),s.useMemo(()=>((...e)=>t.current?.(...e)),[])}Ee(H,`useCallbackRef`);var De=Object.defineProperty,U=(e,t)=>De(e,`name`,{value:t,configurable:!0}),Oe=`dismissableLayer.update`,ke=`dismissableLayer.pointerDownOutside`,Ae=`dismissableLayer.focusOutside`,je,Me=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ne=s.forwardRef(U(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:c,onDismiss:l,...u}=e,d=s.useContext(Me),[f,p]=s.useState(null),m=f?.ownerDocument??globalThis?.document,[,g]=s.useState({}),_=A(t,p),v=Array.from(d.layers),[y]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),x=y?v.indexOf(y):-1,S=f?v.indexOf(f):-1,C=d.layersWithOutsidePointerEventsDisabled.size>0,w=S>=x,T=s.useRef(!1),E=Ie(e=>{a?.(e),c?.(e),e.defaultPrevented||l?.()},{ownerDocument:m,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:T,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:s.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...d.branches].some(t=>t.contains(e));return w&&!t},[d.branches,w])}),D=Le(e=>{if(r&&T.current)return;let t=e.target;[...d.branches].some(e=>e.contains(t))||(o?.(e),c?.(e),e.defaultPrevented||l?.())},m),O=f?S===v.length-1:!1,k=H(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))});return s.useEffect(()=>{if(O)return m.addEventListener(`keydown`,k,{capture:!0}),()=>m.removeEventListener(`keydown`,k,{capture:!0})},[m,O,k]),s.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(je=m.body.style.pointerEvents,m.body.style.pointerEvents=`none`),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),Re(),()=>{n&&(d.layersWithOutsidePointerEventsDisabled.delete(f),d.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=je))}},[f,m,n,d]),s.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),Re())},[f,d]),s.useEffect(()=>{let e=U(()=>g({}),`handleUpdate`);return document.addEventListener(Oe,e),()=>document.removeEventListener(Oe,e)},[]),(0,b.jsx)(V.div,{...u,ref:_,style:{pointerEvents:C?w?`auto`:`none`:void 0,...e.style},onFocusCapture:h(e.onFocusCapture,D.onFocusCapture),onBlurCapture:h(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:h(e.onPointerDownCapture,E.onPointerDownCapture)})},`DismissableLayer`));function Pe(){let e=s.useContext(Me),[t,n]=s.useState(null);return s.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}U(Pe,`useDismissableLayerSurface`);var Fe=U(()=>!0,`IS_TRUE`);function Ie(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Fe}=t,c=H(e),l=s.useRef(!1),u=s.useRef(!1),d=s.useRef(new Map),f=s.useRef(()=>{});return s.useEffect(()=>{function e(){u.current=!1,i.current=!1,d.current.clear()}U(e,`resetOutsideInteraction`);function t(){return Array.from(d.current.values()).some(Boolean)}U(t,`isOutsideInteractionIntercepted`);function s(e){if(!u.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||d.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{u.current&&f.current()},0)}U(s,`handleInteractionCapture`);function p(e){u.current&&d.current.set(e.type,!1)}U(p,`handleInteractionBubble`);let m=U(a=>{if(a.target&&!l.current){let s=function(){n.removeEventListener(`click`,f.current);let r=t();e(),r||ze(ke,c,p,{discrete:!0})};if(U(s,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,f.current),e(),l.current=!1;return}let p={originalEvent:a};u.current=!0,i.current=r&&a.button===0,d.current.clear(),!r||a.button!==0?s():(n.removeEventListener(`click`,f.current),f.current=s,n.addEventListener(`click`,f.current,{once:!0}))}else n.removeEventListener(`click`,f.current),e();l.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,s,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,f.current);for(let e of h)n.removeEventListener(e,s,!0),n.removeEventListener(e,p)}},[n,c,r,i,a,o]),{onPointerDownCapture:U(()=>l.current=!0,`onPointerDownCapture`)}}U(Ie,`usePointerDownOutside`);function Le(e,t=globalThis?.document){let n=H(e),r=s.useRef(!1);return s.useEffect(()=>{let e=U(e=>{e.target&&!r.current&&ze(Ae,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:U(()=>r.current=!0,`onFocusCapture`),onBlurCapture:U(()=>r.current=!1,`onBlurCapture`)}}U(Le,`useFocusOutside`);function Re(){let e=new CustomEvent(Oe);document.dispatchEvent(e)}U(Re,`dispatchUpdate`);function ze(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?we(i,a):i.dispatchEvent(a)}U(ze,`handleAndDispatchCustomEvent`);var Be=Object.defineProperty,Ve=(e,t)=>Be(e,`name`,{value:t,configurable:!0}),He=0,Ue=null;function We(e){return Ge(),e.children}Ve(We,`FocusGuards`);function Ge(){s.useEffect(()=>{Ue||={start:Ke(),end:Ke()};let{start:e,end:t}=Ue;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),He++,()=>{He===1&&(Ue?.start.remove(),Ue?.end.remove(),Ue=null),He=Math.max(0,He-1)}},[])}Ve(Ge,`useFocusGuards`);function Ke(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}Ve(Ke,`createFocusGuard`);var qe=Object.defineProperty,W=(e,t)=>qe(e,`name`,{value:t,configurable:!0}),Je=`focusScope.autoFocusOnMount`,Ye=`focusScope.autoFocusOnUnmount`,Xe={bubbles:!1,cancelable:!0},Ze=s.forwardRef(W(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[c,l]=s.useState(null),u=H(i),d=H(a),f=s.useRef(null),p=A(t,l),m=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(r){let e=function(e){if(m.paused||!c)return;let t=e.target;c.contains(t)?f.current=t:G(f.current,{select:!0})},t=function(e){if(m.paused||!c)return;let t=e.relatedTarget;t!==null&&(c.contains(t)||G(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&G(c)};W(e,`handleFocusIn`),W(t,`handleFocusOut`),W(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,c,m.paused]),s.useEffect(()=>{if(c){it.add(m);let e=document.activeElement;if(!c.contains(e)){let t=new CustomEvent(Je,Xe);c.addEventListener(Je,u),c.dispatchEvent(t),t.defaultPrevented||(Qe(st(et(c)),{select:!0}),document.activeElement===e&&G(c))}return()=>{c.removeEventListener(Je,u),setTimeout(()=>{let t=new CustomEvent(Ye,Xe);c.addEventListener(Ye,d),c.dispatchEvent(t),t.defaultPrevented||G(e??document.body,{select:!0}),c.removeEventListener(Ye,d),it.remove(m)},0)}}},[c,u,d,m]);let h=s.useCallback(e=>{if(!n&&!r||m.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=$e(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&G(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&G(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,m.paused]);return(0,b.jsx)(V.div,{tabIndex:-1,...o,ref:p,onKeyDown:h})},`FocusScope`));function Qe(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(G(r,{select:t}),document.activeElement!==n)return}W(Qe,`focusFirst`);function $e(e){let t=et(e);return[tt(t,e),tt(t.reverse(),e)]}W($e,`getTabbableEdges`);function et(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:W(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}W(et,`getTabbableCandidates`);function tt(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):nt(r,{upTo:t})))return r}W(tt,`findVisible`);function nt(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}W(nt,`isHidden`);function rt(e){return e instanceof HTMLInputElement&&`select`in e}W(rt,`isSelectableInput`);function G(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&rt(e)&&t&&e.select()}}W(G,`focus`);var it=at();function at(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=ot(e,t),e.unshift(t)},remove(t){e=ot(e,t),e[0]?.resume()}}}W(at,`createFocusScopesStack`);function ot(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}W(ot,`arrayRemove`);function st(e){return e.filter(e=>e.tagName!==`A`)}W(st,`removeLinks`);var K=globalThis?.document?s.useLayoutEffect:()=>{},ct=Object.defineProperty,lt=(e,t)=>ct(e,`name`,{value:t,configurable:!0}),ut=s.useId||(()=>void 0),dt=0;function ft(e){let[t,n]=s.useState(ut());return K(()=>{e||n(e=>e??String(dt++))},[e]),e||(t?`radix-${t}`:``)}lt(ft,`useId`);var pt=[`top`,`right`,`bottom`,`left`],mt=Math.min,ht=Math.max,gt=Math.round,_t=Math.floor,vt=e=>({x:e,y:e}),yt={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function bt(e,t,n){return ht(e,mt(t,n))}function xt(e,t){return typeof e==`function`?e(t):e}function St(e){return e.split(`-`)[0]}function Ct(e){return e.split(`-`)[1]}function wt(e){return e===`x`?`y`:`x`}function Tt(e){return e===`y`?`height`:`width`}function q(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Et(e){return wt(q(e))}function Dt(e,t,n){n===void 0&&(n=!1);let r=Ct(e),i=Et(e),a=Tt(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=It(o)),[o,It(o)]}function Ot(e){let t=It(e);return[kt(e),t,kt(t)]}function kt(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var At=[`left`,`right`],jt=[`right`,`left`],Mt=[`top`,`bottom`],Nt=[`bottom`,`top`];function Pt(e,t,n){switch(e){case`top`:case`bottom`:return n?t?jt:At:t?At:jt;case`left`:case`right`:return t?Mt:Nt;default:return[]}}function Ft(e,t,n,r){let i=Ct(e),a=Pt(St(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(kt)))),a}function It(e){let t=St(e);return yt[t]+e.slice(t.length)}function Lt(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Rt(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Lt(e)}function zt(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Bt(e,t,n){let{reference:r,floating:i}=e,a=q(t),o=Et(t),s=Tt(o),c=St(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Ct(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Vt(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=xt(t,e),p=Rt(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=zt(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=zt(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Ht=50,Ut=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Vt},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Bt(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Ht&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Bt(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Wt=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=xt(e,t)||{};if(l==null)return{};let d=Rt(u),f={x:n,y:r},p=Et(i),m=Tt(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=mt(d[_],T),D=mt(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=bt(E,k,O),j=!c.arrow&&Ct(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Gt=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=xt(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=St(r),_=q(o),v=St(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[It(o)]:Ot(o)),x=p!==`none`;!d&&x&&b.push(...Ft(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Dt(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===q(t)||T.every(e=>q(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=q(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Kt(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function qt(e){return pt.some(t=>e[t]>=0)}var Jt=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=xt(e,t);switch(i){case`referenceHidden`:{let e=Kt(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:qt(e)}}}case`escaped`:{let e=Kt(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:qt(e)}}}default:return{}}}}},Yt=new Set([`left`,`top`]);async function Xt(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=St(n),s=Ct(n),c=q(n)===`y`,l=Yt.has(o)?-1:1,u=a&&c?-1:1,d=xt(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Zt=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Xt(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Qt=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=xt(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=q(i),p=wt(f),m=u[p],h=u[f],g=(e,t)=>bt(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},$t=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=xt(e,t),u={x:n,y:r},d=q(i),f=wt(d),p=u[f],m=u[d],h=xt(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Yt.has(St(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},en=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=xt(e,t),c=await i.detectOverflow(t,s),l=St(n),u=Ct(n),d=q(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=mt(p-c[m],g),y=mt(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*ht(c.left,c.right):S=p-2*ht(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function tn(){return typeof window<`u`}function nn(e){return an(e)?(e.nodeName||``).toLowerCase():`#document`}function J(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function rn(e){return((an(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function an(e){return tn()?e instanceof Node||e instanceof J(e).Node:!1}function Y(e){return tn()?e instanceof Element||e instanceof J(e).Element:!1}function on(e){return tn()?e instanceof HTMLElement||e instanceof J(e).HTMLElement:!1}function sn(e){return!tn()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof J(e).ShadowRoot}function cn(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=X(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ln(e){return/^(table|td|th)$/.test(nn(e))}function un(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var dn=/transform|translate|scale|rotate|perspective|filter/,fn=/paint|layout|strict|content/,pn=e=>!!e&&e!==`none`,mn;function hn(e){let t=Y(e)?X(e):e;return pn(t.transform)||pn(t.translate)||pn(t.scale)||pn(t.rotate)||pn(t.perspective)||!_n()&&(pn(t.backdropFilter)||pn(t.filter))||dn.test(t.willChange||``)||fn.test(t.contain||``)}function gn(e){let t=bn(e);for(;on(t)&&!vn(t);){if(hn(t))return t;if(un(t))return null;t=bn(t)}return null}function _n(){return mn??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),mn}function vn(e){return/^(html|body|#document)$/.test(nn(e))}function X(e){return J(e).getComputedStyle(e)}function yn(e){return Y(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function bn(e){if(nn(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||sn(e)&&e.host||rn(e);return sn(t)?t.host:t}function xn(e){let t=bn(e);return vn(t)?(e.ownerDocument||e).body:on(t)&&cn(t)?t:xn(t)}function Sn(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=xn(e),i=r===e.ownerDocument?.body,a=J(r);if(i){let e=Cn(a);return t.concat(a,a.visualViewport||[],cn(r)?r:[],e&&n?Sn(e):[])}return t.concat(r,Sn(r,[],n))}function Cn(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function wn(e){let t=X(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=on(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=gt(n)!==a||gt(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Tn(e){return Y(e)?e:e.contextElement}function En(e){let t=Tn(e);if(!on(t))return vt(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=wn(t),o=(a?gt(n.width):n.width)/r,s=(a?gt(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Dn=vt(0);function On(e){let t=J(e);return!_n()||!t.visualViewport?Dn:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function kn(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===J(e)}function An(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Tn(e),o=vt(1);t&&(r?Y(r)&&(o=En(r)):o=En(e));let s=kn(a,n,r)?On(a):vt(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=J(a),t=Y(r)?J(r):r,n=e,i=Cn(n);for(;i&&t!==n;){let e=En(i),t=i.getBoundingClientRect(),r=X(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=J(i),i=Cn(n)}}return zt({width:u,height:d,x:c,y:l})}function jn(e,t){let n=yn(e).scrollLeft;return t?t.left+n:An(rn(e)).left+n}function Mn(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-jn(e,n),y:n.top+t.scrollTop}}function Nn(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=rn(r),s=t?un(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=vt(1),u=vt(0),d=on(r);if((d||!a)&&((nn(r)!==`body`||cn(o))&&(c=yn(r)),d)){let e=An(r);l=En(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Mn(o,c):vt(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Pn(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Fn(e){let t=yn(e),n=e.ownerDocument.body,r=ht(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=ht(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+jn(e),o=-t.scrollTop;return X(n).direction===`rtl`&&(a+=ht(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var In=25;function Ln(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=J(e),a=rn(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!_n()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(jn(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=In&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Rn(e,t){let n=An(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=En(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function zn(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Ln(e,n,t);else if(t===`document`)r=Fn(rn(e));else if(Y(t))r=Rn(t,n);else{let n=On(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return zt(r)}function Bn(e,t){let n=t.get(e);if(n)return n;let r=Sn(e,[],!1).filter(e=>Y(e)&&nn(e)!==`body`),i=null,a=X(e).position===`fixed`,o=a?bn(e):e;for(;Y(o)&&!vn(o);){let e=X(o),t=hn(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=bn(o)}return t.set(e,r),r}function Vn(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?un(t)?[]:Bn(t,this._c):[].concat(n),r],o=zn(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=zn(t,a[e],i);s=ht(n.top,s),c=mt(n.right,c),l=mt(n.bottom,l),u=ht(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Hn(e){let{width:t,height:n}=wn(e);return{width:t,height:n}}function Un(e,t,n){let r=on(t),i=rn(t),a=n===`fixed`,o=An(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=vt(0);if((r||!a)&&((nn(t)!==`body`||cn(i))&&(s=yn(t)),r)){let e=An(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=jn(i));let l=i&&!r&&!a?Mn(i,s):vt(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Wn(e){return X(e).position===`static`}function Gn(e,t){if(!on(e)||X(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return rn(e)===n&&(n=n.ownerDocument.body),n}function Kn(e,t){let n=J(e);if(un(e))return n;if(!on(e)){let t=bn(e);for(;t&&!vn(t);){if(Y(t)&&!Wn(t))return t;t=bn(t)}return n}let r=Gn(e,t);for(;r&&ln(r)&&Wn(r);)r=Gn(r,t);return r&&vn(r)&&Wn(r)&&!hn(r)?n:r||gn(e)||n}var qn=async function(e){let t=this.getOffsetParent||Kn,n=this.getDimensions,r=await n(e.floating);return{reference:Un(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Jn(e){return X(e).direction===`rtl`}var Yn={convertOffsetParentRelativeRectToViewportRelativeRect:Nn,getDocumentElement:rn,getClippingRect:Vn,getOffsetParent:Kn,getElementRects:qn,getClientRects:Pn,getDimensions:Hn,getScale:En,isElement:Y,isRTL:Jn};function Xn(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Zn(e,t,n){let r=null,i,a=rn(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=_t(d),h=_t(a.clientWidth-(u+f)),g=_t(a.clientHeight-(d+p)),_=_t(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:ht(0,mt(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Xn(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=J(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Qn(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Tn(e),u=i||a?[...l?Sn(l):[],...t?Sn(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Zn(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?An(e):null;c&&g();function g(){let t=An(e);h&&!Xn(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var $n=Zt,er=Qt,tr=Gt,nr=en,rr=Jt,ir=Wt,ar=$t,or=(e,t,n)=>{let r=new Map,i=n??{},a={...Yn,...i.platform,_c:r};return Ut(e,t,{...i,platform:a})},sr=typeof document<`u`?s.useLayoutEffect:function(){};function cr(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!cr(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!cr(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function lr(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ur(e,t){let n=lr(e);return Math.round(t*n)/n}function dr(e){let t=s.useRef(e);return sr(()=>{t.current=e}),t}function fr(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[f,p]=s.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=s.useState(r);cr(m,r)||h(r);let[g,_]=s.useState(null),[v,y]=s.useState(null),b=s.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=s.useCallback(e=>{e!==T.current&&(T.current=e,y(e))},[]),S=a||g,C=o||v,w=s.useRef(null),T=s.useRef(null),E=s.useRef(f),D=u!=null,O=dr(u),k=dr(i),A=dr(d),j=s.useCallback(()=>{if(!w.current||!T.current)return;let e={placement:t,strategy:n,middleware:m};k.current&&(e.platform=k.current),or(w.current,T.current,e).then(e=>{let t={...e,isPositioned:A.current!==!1};M.current&&!cr(E.current,t)&&(E.current=t,c.flushSync(()=>{p(t)}))})},[m,t,n,k,A]);sr(()=>{d===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,p(e=>({...e,isPositioned:!1})))},[d]);let M=s.useRef(!1);sr(()=>(M.current=!0,()=>{M.current=!1}),[]),sr(()=>{if(S&&(w.current=S),C&&(T.current=C),S&&C){if(O.current)return O.current(S,C,j);j()}},[S,C,j,O,D]);let N=s.useMemo(()=>({reference:w,floating:T,setReference:b,setFloating:x}),[b,x]),P=s.useMemo(()=>({reference:S,floating:C}),[S,C]),F=s.useMemo(()=>{let e={position:n,left:0,top:0};if(!P.floating)return e;let t=ur(P.floating,f.x),r=ur(P.floating,f.y);return l?{...e,transform:`translate(`+t+`px, `+r+`px)`,...lr(P.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,l,P.floating,f.x,f.y]);return s.useMemo(()=>({...f,update:j,refs:N,elements:P,floatingStyles:F}),[f,j,N,P,F])}var pr=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:ir({element:r.current,padding:i}).fn(n):r?ir({element:r,padding:i}).fn(n):{}}}},mr=(e,t)=>{let n=$n(e);return{name:n.name,fn:n.fn,options:[e,t]}},hr=(e,t)=>{let n=er(e);return{name:n.name,fn:n.fn,options:[e,t]}},gr=(e,t)=>({fn:ar(e).fn,options:[e,t]}),_r=(e,t)=>{let n=tr(e);return{name:n.name,fn:n.fn,options:[e,t]}},vr=(e,t)=>{let n=nr(e);return{name:n.name,fn:n.fn,options:[e,t]}},yr=(e,t)=>{let n=rr(e);return{name:n.name,fn:n.fn,options:[e,t]}},br=(e,t)=>{let n=pr(e);return{name:n.name,fn:n.fn,options:[e,t]}},xr=Object.defineProperty,Sr=(e,t)=>xr(e,`name`,{value:t,configurable:!0});function Cr(e){let[t,n]=s.useState(void 0);return K(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}Sr(Cr,`useSize`);var wr=Object.defineProperty,Tr=(e,t)=>wr(e,`name`,{value:t,configurable:!0}),Er=`Popper`,[Dr,Or]=w(Er),[kr,Ar]=Dr(Er),jr=Tr(e=>{let{__scopePopper:t,children:n}=e,[r,i]=s.useState(null),[a,o]=s.useState(void 0);return(0,b.jsx)(kr,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Mr=`PopperAnchor`,Nr=s.forwardRef(Tr(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=Ar(Mr,n),o=s.useRef(null),c=a.onAnchorChange,l=A(t,s.useCallback(e=>{o.current=e,e&&c(e)},[c])),u=s.useRef(null);s.useEffect(()=>{if(!r)return;let e=u.current;u.current=r.current,e!==u.current&&c(u.current)});let d=a.placementState&&Br(a.placementState),f=d?.[0],p=d?.[1];return r?null:(0,b.jsx)(V.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...i,ref:l})},`PopperAnchor`)),Pr=`PopperContent`,[Fr,Ir]=Dr(Pr),Lr=s.forwardRef(Tr(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f=`partial`,hideWhenDetached:p=!1,updatePositionStrategy:m=`optimized`,onPlaced:h,...g}=e,_=Ar(Pr,n),[v,y]=s.useState(null),x=A(t,y),[S,C]=s.useState(null),w=Cr(S),T=w?.width??0,E=w?.height??0,D=r+(a===`center`?``:`-`+a),O=typeof d==`number`?d:{top:0,right:0,bottom:0,left:0,...d},k=Array.isArray(u)?u:[u],j=k.length>0,M={padding:O,boundary:k.filter(Rr),altBoundary:j},{refs:N,floatingStyles:P,placement:F,isPositioned:I,middlewareData:L}=fr({strategy:`fixed`,placement:D,whileElementsMounted:Tr((...e)=>Qn(...e,{animationFrame:m===`always`}),`whileElementsMounted`),elements:{reference:_.anchor},middleware:[mr({mainAxis:i+E,alignmentAxis:o}),l&&hr({mainAxis:!0,crossAxis:!1,limiter:f===`partial`?gr():void 0,...M}),l&&_r({...M}),vr({...M,apply:Tr(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),S&&br({element:S,padding:c}),zr({arrowWidth:T,arrowHeight:E}),p&&yr({strategy:`referenceHidden`,...M,boundary:j?M.boundary:void 0})]}),R=_.setPlacementState;K(()=>(R(F),()=>{R(void 0)}),[F,R]);let[z,ee]=Br(F),te=H(h);K(()=>{I&&te?.()},[I,te]);let ne=L.arrow?.x,re=L.arrow?.y,ie=L.arrow?.centerOffset!==0,[ae,oe]=s.useState();return K(()=>{v&&oe(window.getComputedStyle(v).zIndex)},[v]),(0,b.jsx)(`div`,{ref:N.setFloating,"data-radix-popper-content-wrapper":``,style:{...P,transform:I?P.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[L.transformOrigin?.x,L.transformOrigin?.y].join(` `),...L.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,b.jsx)(Fr,{scope:n,placedSide:z,placedAlign:ee,onArrowChange:C,arrowX:ne,arrowY:re,shouldHideArrow:ie,children:(0,b.jsx)(V.div,{"data-side":z,"data-align":ee,...g,ref:x,style:{...g.style,animation:I?g.style?.animation:`none`}})})})},`PopperContent`));function Rr(e){return e!==null}Tr(Rr,`isNotNull`);var zr=Tr(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Br(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Br(e){let[t,n=`center`]=e.split(`-`);return[t,n]}Tr(Br,`getSideAndAlignFromPlacement`);var Vr=jr,Hr=Nr,Ur=Lr,Wr=Object.defineProperty,Gr=s.forwardRef(((e,t)=>Wr(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=s.useState(!1);K(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?c.createPortal((0,b.jsx)(V.div,{...r,ref:t}),o):null},`Portal`)),Kr=Object.defineProperty,qr=(e,t)=>Kr(e,`name`,{value:t,configurable:!0});function Jr(e,t){return s.useReducer((e,n)=>t[e][n]??e,e)}qr(Jr,`useStateMachine`);var Yr=qr(e=>{let{present:t,children:n}=e,r=Xr(t),i=typeof n==`function`?n({present:r.isPresent}):s.Children.only(n),a=Qr(r.ref,ei(i));return typeof n==`function`||r.isPresent?s.cloneElement(i,{ref:a}):null},`Presence`);function Xr(e){let[t,n]=s.useState(),r=s.useRef(null),i=s.useRef(e),a=s.useRef(`none`),o=s.useRef(void 0),[c,l]=Jr(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return s.useEffect(()=>{c===`mounted`?(a.current=o.current??$r(r.current),o.current=void 0):a.current=`none`},[c]),K(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=$r(t);e?(o.current=s,l(`MOUNT`)):s===`none`||t?.display===`none`?l(`UNMOUNT`):l(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,l]),K(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=qr(a=>{let o=$r(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(l(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=qr(e=>{e.target===t&&(a.current=$r(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}l(`ANIMATION_END`)},[t,l]),{isPresent:[`mounted`,`unmountSuspended`].includes(c),ref:s.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=$r(t)}else r.current=null;n(e)},[])}}qr(Xr,`usePresence`);function Zr(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}qr(Zr,`setRef`);function Qr(...e){let t=s.useRef(e);return t.current=e,s.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Zr(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():Zr(n[e],null)}}},[])}qr(Qr,`useStableComposedRefs`);function $r(e){return e?.animationName||`none`}qr($r,`getAnimationName`);function ei(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}qr(ei,`getElementRef`);var ti=Object.defineProperty,ni=(e,t)=>ti(e,`name`,{value:t,configurable:!0}),ri=s.useEffectEvent,ii=s.useInsertionEffect;function ai(e){if(typeof ri==`function`)return ri(e);let t=s.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof ii==`function`?ii(()=>{t.current=e}):K(()=>{t.current=e}),s.useMemo(()=>((...e)=>t.current?.(...e)),[])}ni(ai,`useEffectEvent`);var oi=Object.defineProperty,si=(e,t)=>oi(e,`name`,{value:t,configurable:!0}),ci=s.useInsertionEffect||K;function li({prop:e,defaultProp:t,onChange:n=si(()=>{},`onChange`),caller:r}){let[i,a,o]=ui({defaultProp:t,onChange:n}),c=e!==void 0;return[c?e:i,s.useCallback(t=>{if(c){let n=di(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[c,e,a,o])]}si(li,`useControllableState`);function ui({defaultProp:e,onChange:t}){let[n,r]=s.useState(e),i=s.useRef(n),a=s.useRef(t);return ci(()=>{a.current=t},[t]),s.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}si(ui,`useUncontrolledState`);function di(e){return typeof e==`function`}si(di,`isFunction`);var fi=Symbol(`RADIX:SYNC_STATE`);function pi(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:c}=t,l=i!==void 0,u=ai(o),d=[{...n,state:a}];r&&d.push(r);let[f,p]=s.useReducer((t,n)=>{if(n.type===fi)return{...t,state:n.state};let r=e(t,n);return l&&!Object.is(r.state,t.state)&&u(r.state),r},...d),m=f.state,h=s.useRef(m);s.useEffect(()=>{h.current!==m&&(h.current=m,l||u(m))},[m,h,l]);let g=s.useMemo(()=>i===void 0?f:{...f,state:i},[f,i]);return s.useEffect(()=>{l&&!Object.is(i,f.state)&&p({type:fi,state:i})},[i,f.state,l]),[g,p]}si(pi,`useControllableStateReducer`);var mi=Object.defineProperty,hi=(e,t)=>mi(e,`name`,{value:t,configurable:!0});function gi(e){let t=s.useRef({value:e,previous:e});return s.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}hi(gi,`usePrevious`);var _i=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),vi=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},yi=new WeakMap,bi=new WeakMap,xi={},Si=0,Ci=function(e){return e&&(e.host||Ci(e.parentNode))},wi=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Ci(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Ti=function(e,t,n,r){var i=wi(t,Array.isArray(e)?e:[e]);xi[n]||(xi[n]=new WeakMap);var a=xi[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(yi.get(e)||0)+1,l=(a.get(e)||0)+1;yi.set(e,c),a.set(e,l),o.push(e),c===1&&i&&bi.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),Si++,function(){o.forEach(function(e){var t=yi.get(e)-1,i=a.get(e)-1;yi.set(e,t),a.set(e,i),t||(bi.has(e)||e.removeAttribute(r),bi.delete(e)),i||e.removeAttribute(n)}),Si--,Si||(yi=new WeakMap,yi=new WeakMap,bi=new WeakMap,xi={})}},Ei=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||vi(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Ti(r,i,n,`aria-hidden`)):function(){return null}},Z=function(){return Z=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Z.apply(this,arguments)};function Di(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Oi(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var ki=`right-scroll-bar-position`,Ai=`width-before-scroll-bar`,ji=`with-scroll-bars-hidden`,Mi=`--removed-body-scroll-bar-size`;function Ni(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Pi(e,t){var n=(0,s.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Fi=typeof window<`u`?s.useLayoutEffect:s.useEffect,Ii=new WeakMap;function Li(e,t){var n=Pi(t||null,function(t){return e.forEach(function(e){return Ni(e,t)})});return Fi(function(){var t=Ii.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Ni(e,null)}),i.forEach(function(e){r.has(e)||Ni(e,a)})}Ii.set(n,e)},[e]),n}function Ri(e){return e}function zi(e,t){t===void 0&&(t=Ri);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Bi(e){e===void 0&&(e={});var t=zi(null);return t.options=Z({async:!0,ssr:!1},e),t}var Vi=function(e){var t=e.sideCar,n=Di(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return s.createElement(r,Z({},n))};Vi.isSideCarExport=!0;function Hi(e,t){return e.useMedium(t),Vi}var Ui=Bi(),Wi=function(){},Gi=s.forwardRef(function(e,t){var n=s.useRef(null),r=s.useState({onScrollCapture:Wi,onWheelCapture:Wi,onTouchMoveCapture:Wi}),i=r[0],a=r[1],o=e.forwardProps,c=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=Di(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=p,C=Li([n,t]),w=Z(Z({},x),i);return s.createElement(s.Fragment,null,d&&s.createElement(S,{sideCar:Ui,removeScrollBar:u,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?s.cloneElement(s.Children.only(c),Z(Z({},w),{ref:C})):s.createElement(y,Z({},w,{className:l,ref:C}),c))});Gi.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Gi.classNames={fullWidth:Ai,zeroRight:ki};var Ki=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function qi(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Ki();return t&&e.setAttribute(`nonce`,t),e}function Ji(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Yi(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Xi=function(){var e=0,t=null;return{add:function(n){e==0&&(t=qi())&&(Ji(t,n),Yi(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Zi=function(){var e=Xi();return function(t,n){s.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Qi=function(){var e=Zi();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},$i={left:0,top:0,right:0,gap:0},ea=function(e){return parseInt(e||``,10)||0},ta=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[ea(n),ea(r),ea(i)]},na=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return $i;var t=ta(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ra=Qi(),ia=`data-scroll-locked`,aa=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
2
2
  .${ji} {
3
3
  overflow: hidden ${r};
4
4
  padding-right: ${s}px ${r};
@@ -92,7 +92,7 @@
92
92
  })();
93
93
  </script>
94
94
  <title>Cartethyia</title>
95
- <script type="module" crossorigin src="/assets/index-DU61iviS.js"></script>
95
+ <script type="module" crossorigin src="/assets/index-Ck4uwuYb.js"></script>
96
96
  </head>
97
97
  <body>
98
98
  <div id="root"></div>
Binary file
@@ -2,27 +2,27 @@
2
2
  "count": 114,
3
3
  "assets": [
4
4
  "assets\\AccountCooldown-Bjo92Qat.js",
5
- "assets\\BannedPage-B7OjIxCp.js",
6
- "assets\\CliToolDetailPage-Bt-6y24w.js",
7
- "assets\\CliToolsPage-C6LunsuE.js",
8
- "assets\\CombosPage-CgyfN2Yy.js",
9
- "assets\\ConsoleLogPage-BHWU7y6j.js",
10
- "assets\\CustomizationPage-xIjU736m.js",
11
- "assets\\HealthEventsModal-DeT1zkYG.js",
12
- "assets\\LoginPage-ChVqIAam.js",
5
+ "assets\\BannedPage-1v5rzKMl.js",
6
+ "assets\\CliToolDetailPage-chMg74ct.js",
7
+ "assets\\CliToolsPage-CKG-Vxrt.js",
8
+ "assets\\CombosPage-JYmVKzIx.js",
9
+ "assets\\ConsoleLogPage-CPflWDry.js",
10
+ "assets\\CustomizationPage-B0EYUE47.js",
11
+ "assets\\HealthEventsModal-F1c4lkNG.js",
12
+ "assets\\LoginPage-BYTpzcoU.js",
13
13
  "assets\\ModelPicker-CA1kLs45.js",
14
- "assets\\OverviewPage-BD4GkRtS.js",
15
- "assets\\ProviderDetailPage-BJXwqpKj.js",
14
+ "assets\\OverviewPage-DIYZRAcb.js",
15
+ "assets\\ProviderDetailPage-CM4MNy45.js",
16
16
  "assets\\ProviderIcon-CmfzxpVM.js",
17
- "assets\\ProvidersPage-Ck64riM5.js",
18
- "assets\\ProxyPage-Br_Leqq0.js",
19
- "assets\\QuotaPage-D2gyhfa8.js",
20
- "assets\\SettingsPage-1dbYb8cM.js",
21
- "assets\\SetupPage-DUTFy9wH.js",
22
- "assets\\SortableList-BZEhfDpZ.js",
23
- "assets\\StudioPage-GBDtsJjh.js",
17
+ "assets\\ProvidersPage-Bsoqg2HG.js",
18
+ "assets\\ProxyPage-8G3doV7j.js",
19
+ "assets\\QuotaPage-CVIQq6JG.js",
20
+ "assets\\SettingsPage-BgXvRN2Q.js",
21
+ "assets\\SetupPage-BCx07-bj.js",
22
+ "assets\\SortableList-MhkB6msu.js",
23
+ "assets\\StudioPage-CTqK6Nsj.js",
24
24
  "assets\\ToolIcon-K1ckcDKg.js",
25
- "assets\\UsagePage-CxidMvxq.js",
25
+ "assets\\UsagePage-Do65OWbr.js",
26
26
  "assets\\api-keys-C23S9sgp.js",
27
27
  "assets\\app-BUSiYL6F.css",
28
28
  "assets\\app-MdVfwraB.js",
@@ -47,14 +47,14 @@
47
47
  "assets\\download-dRFo5_Wu.js",
48
48
  "assets\\drawer-Bs8MIIHc.js",
49
49
  "assets\\entry-BRszm4_Z.js",
50
- "assets\\entry-BrksMru8.js",
50
+ "assets\\entry-CBHzQ6Qh.js",
51
51
  "assets\\entry-DcobaKFu.js",
52
52
  "assets\\eye-C_hawfH4.js",
53
53
  "assets\\eye-off-Bk5g2luF.js",
54
54
  "assets\\gauge-BbIMy7MB.js",
55
55
  "assets\\github-badge-BuDsrsPn.js",
56
56
  "assets\\image-BPaouViG.js",
57
- "assets\\index-DU61iviS.js",
57
+ "assets\\index-Ck4uwuYb.js",
58
58
  "assets\\inline-DToMICwl.js",
59
59
  "assets\\input-WlyHWeG2.js",
60
60
  "assets\\jsx-runtime-CXUMngI_.js",
@@ -97,7 +97,7 @@
97
97
  "assets\\routing-BPUo-W8d.js",
98
98
  "assets\\scaling-nWE4Cx8f.js",
99
99
  "assets\\search-JOKus9rb.js",
100
- "assets\\select-Ciq_KFQ1.js",
100
+ "assets\\select-BrrUDUPc.js",
101
101
  "assets\\settings--3hxSyry.js",
102
102
  "assets\\shield-check-DVS0Foqh.js",
103
103
  "assets\\stack-B1w5BM0u.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cartethyia",
3
- "version": "2.6.5",
3
+ "version": "2.6.6",
4
4
  "description": "A powerful, self-hosted reverse proxy for OpenAI- and Anthropic-compatible AI clients, powered by native Bun and Elysia. It serves both protocols from a single server, routes every model across any configured provider, and translates requests and responses in real time — streaming and prompt caching included. Underneath it runs a full delivery engine: per-account health tracking, quota and cooldown enforcement, automatic failover across pools and providers, usage accounting, and telemetry. Point OpenCode, Cline, Claude Code, Codex, or any compatible client at Cartethyia and it keeps its native protocol while the gateway absorbs every provider-specific difference behind it. Runs on embedded SQLite or external PostgreSQL with optional Redis coordination, ships as a global CLI with a system-tray console, and needs only Bun 1.4+ alongside Node.js/npm.",
5
5
  "license": "GPL-3.0-only",
6
6
  "type": "module",
@@ -32,13 +32,33 @@ import { restoreControllerAfterFailedHandoff } from "./controller";
32
32
  const TRAY_HEALTH_POLL_MS = 10_000;
33
33
 
34
34
  /**
35
- * Consecutive misses to forgive before a dead gateway closes the tray.
35
+ * How long the gateway must be unreachable before the tray closes.
36
36
  *
37
- * One refusal is not a stopped gateway — a probe can lose a race with startup
38
- * or a slow request — and closing the icon on one would make startup feel
39
- * random.
37
+ * A count of consecutive misses was the wrong shape: a gateway that is
38
+ * answering, but slowly, misses every probe exactly like a gateway that is
39
+ * gone. Under load — a large prompt, a synchronous GC — `/health` cannot
40
+ * answer inside the probe timeout, so three polls in a row missed and the tray
41
+ * closed itself while the gateway was still serving. `carte --tray` looked
42
+ * fine only because it starts idle and never carries that load.
43
+ *
44
+ * Bounded by wall-clock instead: a gateway that is truly gone stops being
45
+ * reachable immediately and stays that way, so it still closes the tray
46
+ * promptly, while a gateway that is merely busy keeps answering often enough
47
+ * to reset the clock. The window is long enough to span a request that runs
48
+ * to the deadline.
49
+ */
50
+ const TRAY_HEALTH_UNREACHABLE_BEFORE_CLOSE_MS = 120_000;
51
+
52
+ /**
53
+ * How long one health probe waits before counting as a miss.
54
+ *
55
+ * Short probes are the other half of the same bug: `/health` is served by the
56
+ * same process that is busy streaming a response, so a 2 s budget failed on a
57
+ * busy gateway that was perfectly healthy. This is far longer than a healthy
58
+ * answer takes and far shorter than the poll interval, so it cannot overlap
59
+ * the next probe.
40
60
  */
41
- const TRAY_HEALTH_MISSES_BEFORE_CLOSE = 3;
61
+ const TRAY_HEALTH_PROBE_TIMEOUT_MS = 15_000;
42
62
 
43
63
  export async function startTray(): Promise<void> {
44
64
  const handoff = inheritedControllerHandoff();
@@ -162,7 +182,10 @@ async function runTray(): Promise<void> {
162
182
  reportTrayStartup({ status: "ready", url: dashboardUrl });
163
183
  console.log(`Cartethyia is running at ${dashboardUrl}`);
164
184
 
165
- let misses = 0;
185
+ // The timestamp of the last probe the gateway actually answered, not a
186
+ // miss counter: a busy gateway answers sometimes, and that must reset the
187
+ // clock rather than being averaged away with its own silences.
188
+ let lastSeenAliveAt = Date.now();
166
189
  // A detached child's `exited` never settles on Windows, so the old
167
190
  // `await current.exited` would have parked here forever and the tray would
168
191
  // never notice the gateway going away. Poll its health endpoint instead:
@@ -173,14 +196,15 @@ async function runTray(): Promise<void> {
173
196
  await Bun.sleep(TRAY_HEALTH_POLL_MS);
174
197
  if (closing || gateway === null && adoptedGateway === null) continue;
175
198
  const alive = await fetch(`http://127.0.0.1:${port}/health`, {
176
- signal: AbortSignal.timeout(2_000),
199
+ signal: AbortSignal.timeout(TRAY_HEALTH_PROBE_TIMEOUT_MS),
177
200
  }).then((response) => response.ok).catch(() => false);
178
201
  if (alive) {
179
- misses = 0;
202
+ lastSeenAliveAt = Date.now();
180
203
  continue;
181
204
  }
182
- misses += 1;
183
- if (misses < TRAY_HEALTH_MISSES_BEFORE_CLOSE) continue;
205
+ // Only a gateway that has been unreachable for the whole window is
206
+ // treated as gone. One slow answer inside it is enough to start over.
207
+ if (Date.now() - lastSeenAliveAt < TRAY_HEALTH_UNREACHABLE_BEFORE_CLOSE_MS) continue;
184
208
  gateway = null;
185
209
  console.error("Cartethyia stopped answering; the tray is closing.");
186
210
  await close(1);
@@ -96,6 +96,17 @@ export interface StreamFinalizeInput {
96
96
  * stream back into the error path and emitting duplicate telemetry rows (and
97
97
  * a second resource release) for one request.
98
98
  */
99
+
100
+ /**
101
+ * How long a deferred release waits for the reader it was handed to.
102
+ *
103
+ * Only a backstop: the pull or `attachController` it defers to normally
104
+ * releases first. Long enough that a reader mid-write is never cut off, short
105
+ * enough that a reader which never runs does not leave the flight registered
106
+ * indefinitely.
107
+ */
108
+ const DEFERRED_RELEASE_BACKSTOP_MS = 30_000;
109
+
99
110
  export class StreamFinalizer {
100
111
  /**
101
112
  * True only while a `pull()` is awaiting the upstream iterator. A watchdog
@@ -105,6 +116,8 @@ export class StreamFinalizer {
105
116
  * abort handler instead.
106
117
  */
107
118
  pullActive = false;
119
+ /** Backstop timer for an abort whose release was deferred to another reader. */
120
+ private releaseBackstop: ReturnType<typeof setTimeout> | undefined;
108
121
 
109
122
  /**
110
123
  * Max time between upstream events before the stream is declared stalled,
@@ -183,6 +196,29 @@ export class StreamFinalizer {
183
196
  this.stallTimer = undefined;
184
197
  }
185
198
 
199
+ /**
200
+ * Guarantees {@link releaseStreamResources} runs after a deferred abort.
201
+ *
202
+ * Two branches of `onStreamAbort` hand the release to some other reader — an
203
+ * active pull, or `attachController` — and return. When that reader never
204
+ * runs, nothing releases: the flight stays in the in-flight registry and the
205
+ * gauge never returns to zero, which is indistinguishable from permanent
206
+ * load. A server-side abort (deadline, 504) is the case that reaches them,
207
+ * because only a client disconnect is handled inline.
208
+ *
209
+ * The timer is unref'd so it cannot keep the process alive during shutdown,
210
+ * and `releaseStreamResources` is idempotent (`streamReleased`), so a pull
211
+ * that does settle first simply makes this a no-op.
212
+ */
213
+ private armDeferredReleaseBackstop(): void {
214
+ if (this.releaseBackstop !== undefined) return;
215
+ this.releaseBackstop = setTimeout(() => {
216
+ this.releaseBackstop = undefined;
217
+ void this.releaseStreamResources();
218
+ }, DEFERRED_RELEASE_BACKSTOP_MS);
219
+ this.releaseBackstop.unref?.();
220
+ }
221
+
186
222
  /**
187
223
  * Attaches the stream controller so an abort can settle even when no pull is
188
224
  * currently pending (for example, the client stopped reading between chunks).
@@ -257,10 +293,28 @@ export class StreamFinalizer {
257
293
  // Let an active pull emit the terminal frame for a server drain or
258
294
  // deadline. With no pull, no reader will handle it, so this listener must
259
295
  // emit and close through the attached controller itself.
260
- if (this.pullActive && !clientDisconnect) return;
296
+ // Deferring to the pull assumes the pull will settle and release. It may
297
+ // not: a pull awaits the upstream iterator, and an upstream that went
298
+ // quiet after the abort leaves that await pending — so nothing ever
299
+ // reaches `releaseStreamResources()` and the flight stays registered
300
+ // forever. A server-side abort (deadline, 504) is exactly the case, since
301
+ // only a client disconnect takes the path below.
302
+ //
303
+ // Arm a backstop instead of returning bare. If the pull does settle it
304
+ // releases first and this becomes a no-op, so the normal path is
305
+ // unchanged; if it never does, the flight is still reaped.
306
+ if (this.pullActive && !clientDisconnect) {
307
+ this.armDeferredReleaseBackstop();
308
+ return;
309
+ }
261
310
  // Before ReadableStream.start attaches its controller, defer server-side
262
311
  // failures so attachController can deliver the typed terminal frame.
263
- if (!clientDisconnect && this.streamController === undefined) return;
312
+ if (!clientDisconnect && this.streamController === undefined) {
313
+ // Same assumption, same consequence: attachController is expected to
314
+ // deliver the frame and release. Nothing guarantees it runs.
315
+ this.armDeferredReleaseBackstop();
316
+ return;
317
+ }
264
318
  if (clientDisconnect) {
265
319
  const { candidate } = this.input;
266
320
  if (!state.outcome) {
@@ -336,6 +390,14 @@ export class StreamFinalizer {
336
390
  if (this.streamReleased) return;
337
391
  this.streamReleased = true;
338
392
  const { state, deps, prepared, lease, reservation, proxySlot } = this.input;
393
+ // The deferred-release backstop has done its job — or the reader it
394
+ // deferred to beat it here. Either way the timer must not outlive the
395
+ // release, and an unref'd timer left armed would fire into a released
396
+ // finalizer.
397
+ if (this.releaseBackstop !== undefined) {
398
+ clearTimeout(this.releaseBackstop);
399
+ this.releaseBackstop = undefined;
400
+ }
339
401
  state.abortController.signal.removeEventListener("abort", this.handleAbort);
340
402
  this.streamController = undefined;
341
403
  this.clearClientKeepaliveTimer();