var Vr=Object.defineProperty;var qr=Object.getPrototypeOf;var Hr=Reflect.get;var Bn=n=>{throw TypeError(n)};var jr=(n,t,e)=>t in n?Vr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var f=(n,t,e)=>jr(n,typeof t!="symbol"?t+"":t,e),tn=(n,t,e)=>t.has(n)||Bn("Cannot "+e);var s=(n,t,e)=>(tn(n,t,"read from private field"),e?e.call(n):t.get(n)),a=(n,t,e)=>t.has(n)?Bn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),p=(n,t,e,r)=>(tn(n,t,"write to private field"),r?r.call(n,e):t.set(n,e),e),m=(n,t,e)=>(tn(n,t,"access private method"),e);var Wn=(n,t,e)=>Hr(qr(n),e,t);import"./Bzak7iHL.js";import{D as Yr,L as Xr,M as Zr,C as Jr,y as x,a6 as er,q as v,g as b,bu as Kn,W as Qr,aU as Rt,ay as $r,ax as _n,az as ts,u as es,a as bt,b as ns,av as rs,k as O,h as et,i as nt,j as rt,as as kt,p as Ft,aw as ss,m as Ot,bv as nr}from"./DScGFiBY.js";import{c as is,m as os,u as us}from"./B7h8GtFa.js";import{d as Dt}from"./BPc-JNDc.js";import{B as as,i as cs}from"./BlbL38UD.js";import{q as ls,B as hs,o as fs,f as y,r as ds,t as ps,u as gs,v as bs,w as Je,x as vt,b as Qe,l as rr,g as sr,i as ir,m as ms,c as vs,n as ys,y as ws}from"./B3aNbgJc.js";import{p as A}from"./DoRZqEmo.js";import{o as S}from"./BfWekp-4.js";const Ts=Symbol("NaN");function Ss(n,t,e){Yr&&Xr();var r=new as(n),i=!Zr();Jr(()=>{var o=t();o!==o&&(o=Ts),i&&o!==null&&typeof o=="object"&&(o={}),r.ensure(o,e)})}function mt(n){let t=x(er(n));return{[hs]:!0,[ls]:!0,get current(){return b(t)},set current(e){v(t,e,!0)}}}mt.from=fs;mt.with=y;mt.flatten=ds;mt.readonly=ps;mt.isBox=gs;mt.isWritableBox=bs;const xs=typeof window<"u"?window:void 0;function Es(n){let t=n.activeElement;for(;t!=null&&t.shadowRoot;){const e=t.shadowRoot.activeElement;if(e===t)break;t=e}return t}var R,L,W,Oe,P,Kt,Te;const En=class En extends Map{constructor(e){super();a(this,P);a(this,R,new Map);a(this,L,x(0));a(this,W,x(0));a(this,Oe,Kn||-1);if(e){for(var[r,i]of e)super.set(r,i);s(this,W).v=super.size}}has(e){var r=s(this,R),i=r.get(e);if(i===void 0){var o=super.get(e);if(o!==void 0)i=m(this,P,Kt).call(this,0),r.set(e,i);else return b(s(this,L)),!1}return b(i),!0}forEach(e,r){m(this,P,Te).call(this),super.forEach(e,r)}get(e){var r=s(this,R),i=r.get(e);if(i===void 0){var o=super.get(e);if(o!==void 0)i=m(this,P,Kt).call(this,0),r.set(e,i);else{b(s(this,L));return}}return b(i),super.get(e)}set(e,r){var d;var i=s(this,R),o=i.get(e),u=super.get(e),c=super.set(e,r),l=s(this,L);if(o===void 0)o=m(this,P,Kt).call(this,0),i.set(e,o),v(s(this,W),super.size),Rt(l);else if(u!==r){Rt(o);var h=l.reactions===null?null:new Set(l.reactions),g=h===null||!((d=o.reactions)!=null&&d.every(w=>h.has(w)));g&&Rt(l)}return c}delete(e){var r=s(this,R),i=r.get(e),o=super.delete(e);return i!==void 0&&(r.delete(e),v(s(this,W),super.size),v(i,-1),Rt(s(this,L))),o}clear(){if(super.size!==0){super.clear();var e=s(this,R);v(s(this,W),0);for(var r of e.values())v(r,-1);Rt(s(this,L)),e.clear()}}keys(){return b(s(this,L)),super.keys()}values(){return m(this,P,Te).call(this),super.values()}entries(){return m(this,P,Te).call(this),super.entries()}[Symbol.iterator](){return this.entries()}get size(){return b(s(this,W)),super.size}};R=new WeakMap,L=new WeakMap,W=new WeakMap,Oe=new WeakMap,P=new WeakSet,Kt=function(e){return Kn===s(this,Oe)?x(e):Qr(e)},Te=function(){b(s(this,L));var e=s(this,R);if(s(this,W).v!==e.size){for(var r of Wn(En.prototype,this,"keys").call(this))if(!e.has(r)){var i=m(this,P,Kt).call(this,0);e.set(r,i)}}for([,i]of s(this,R))b(i)};let nn=En;var yt,Ut;class Cs{constructor(t={}){a(this,yt);a(this,Ut);const{window:e=xs,document:r=e==null?void 0:e.document}=t;e!==void 0&&(p(this,yt,r),p(this,Ut,is(i=>{const o=S(e,"focusin",i),u=S(e,"focusout",i);return()=>{o(),u()}})))}get current(){var t;return(t=s(this,Ut))==null||t.call(this),s(this,yt)?Es(s(this,yt)):null}}yt=new WeakMap,Ut=new WeakMap;new Cs;var zt,K;class $e{constructor(t){a(this,zt);a(this,K);p(this,zt,t),p(this,K,Symbol(t))}get key(){return s(this,K)}exists(){return $r(s(this,K))}get(){const t=_n(s(this,K));if(t===void 0)throw new Error(`Context "${s(this,zt)}" not found`);return t}getOr(t){const e=_n(s(this,K));return e===void 0?t:e}set(t){return ts(s(this,K),t)}}zt=new WeakMap,K=new WeakMap;function As(n,t){switch(n){case"post":bt(t);break;case"pre":es(t);break}}function or(n,t,e,r={}){const{lazy:i=!1}=r;let o=!i,u=Array.isArray(n)?[]:void 0;As(t,()=>{const c=Array.isArray(n)?n.map(h=>h()):n();if(!o){o=!0,u=c;return}const l=ns(()=>e(c,u));return u=c,l})}function D(n,t,e){or(n,"post",t,e)}function Ms(n,t,e){or(n,"pre",t,e)}D.pre=Ms;function me(n){bt(()=>()=>{n()})}function Is(n,t){return setTimeout(t,n)}function q(n){rs().then(n)}const Ns=1,ks=9,Fs=11;function rn(n){return Je(n)&&n.nodeType===Ns&&typeof n.nodeName=="string"}function ur(n){return Je(n)&&n.nodeType===ks}function Os(n){var t;return Je(n)&&((t=n.constructor)==null?void 0:t.name)==="VisualViewport"}function Ds(n){return Je(n)&&n.nodeType!==void 0}function ar(n){return Ds(n)&&n.nodeType===Fs&&"host"in n}function Ps(n,t){var r;if(!n||!t||!rn(n)||!rn(t))return!1;const e=(r=t.getRootNode)==null?void 0:r.call(t);if(n===t||n.contains(t))return!0;if(e&&ar(e)){let i=t;for(;i;){if(n===i)return!0;i=i.parentNode||i.host}}return!1}function ve(n){return ur(n)?n:Os(n)?n.document:(n==null?void 0:n.ownerDocument)??document}function cr(n){var t;return ar(n)?cr(n.host):ur(n)?n.defaultView??window:rn(n)?((t=n.ownerDocument)==null?void 0:t.defaultView)??window:window}function Rs(n){let t=n.activeElement;for(;t!=null&&t.shadowRoot;){const e=t.shadowRoot.activeElement;if(e===t)break;t=e}return t}var Vt;class vn{constructor(t){f(this,"element");a(this,Vt,O(()=>this.element.current?this.element.current.getRootNode()??document:document));f(this,"getDocument",()=>ve(this.root));f(this,"getWindow",()=>this.getDocument().defaultView??window);f(this,"getActiveElement",()=>Rs(this.root));f(this,"isActiveElement",t=>t===this.getActiveElement());f(this,"querySelector",t=>this.root?this.root.querySelector(t):null);f(this,"querySelectorAll",t=>this.root?this.root.querySelectorAll(t):[]);f(this,"setTimeout",(t,e)=>this.getWindow().setTimeout(t,e));f(this,"clearTimeout",t=>this.getWindow().clearTimeout(t));typeof t=="function"?this.element=y(t):this.element=t}get root(){return b(s(this,Vt))}set root(t){v(s(this,Vt),t)}getElementById(t){return this.root.getElementById(t)}}Vt=new WeakMap;const Gt="ArrowDown",yn="ArrowLeft",wn="ArrowRight",Ae="ArrowUp",lr="End",hr="Enter",Ls="Escape",fr="Home",Bs="PageDown",Ws="PageUp",Tn=" ",Ks="Tab";function _s(n){return window.getComputedStyle(n).getPropertyValue("direction")}function Gs(n="ltr",t="horizontal"){return{horizontal:n==="rtl"?yn:wn,vertical:Gt}[t]}function Us(n="ltr",t="horizontal"){return{horizontal:n==="rtl"?wn:yn,vertical:Ae}[t]}function zs(n="ltr",t="horizontal"){return["ltr","rtl"].includes(n)||(n="ltr"),["horizontal","vertical"].includes(t)||(t="horizontal"),{nextKey:Gs(n,t),prevKey:Us(n,t)}}const dr=typeof document<"u",Gn=Vs();function Vs(){var n,t;return dr&&((n=window==null?void 0:window.navigator)==null?void 0:n.userAgent)&&(/iP(ad|hone|od)/.test(window.navigator.userAgent)||((t=window==null?void 0:window.navigator)==null?void 0:t.maxTouchPoints)>2&&/iPad|Macintosh/.test(window==null?void 0:window.navigator.userAgent))}function j(n){return n instanceof HTMLElement}function sn(n){return n instanceof Element}function pr(n){return n instanceof Element||n instanceof SVGElement}function so(n){return n!==null}function qs(n){return n instanceof HTMLInputElement&&"select"in n}var E,_;class Hs{constructor(t){a(this,E);a(this,_,mt(null));p(this,E,t)}getCandidateNodes(){return s(this,E).rootNode.current?s(this,E).candidateSelector?Array.from(s(this,E).rootNode.current.querySelectorAll(s(this,E).candidateSelector)):s(this,E).candidateAttr?Array.from(s(this,E).rootNode.current.querySelectorAll(`[${s(this,E).candidateAttr}]:not([data-disabled])`)):[]:[]}focusFirstCandidate(){var e;const t=this.getCandidateNodes();t.length&&((e=t[0])==null||e.focus())}handleKeydown(t,e,r=!1){var Pt,Y;const i=s(this,E).rootNode.current;if(!i||!t)return;const o=this.getCandidateNodes();if(!o.length)return;const u=o.indexOf(t),c=_s(i),{nextKey:l,prevKey:h}=zs(c,s(this,E).orientation.current),g=s(this,E).loop.current,d={[l]:u+1,[h]:u-1,[fr]:0,[lr]:o.length-1};if(r){const Rn=l===Gt?wn:Gt,Ln=h===Ae?yn:Ae;d[Rn]=u+1,d[Ln]=u-1}let w=d[e.key];if(w===void 0)return;e.preventDefault(),w<0&&g?w=o.length-1:w===o.length&&g&&(w=0);const M=o[w];if(M)return M.focus(),s(this,_).current=M.id,(Y=(Pt=s(this,E)).onCandidateFocus)==null||Y.call(Pt,M),M}getTabIndex(t){const e=this.getCandidateNodes(),r=s(this,_).current!==null;return t&&!r&&e[0]===t?(s(this,_).current=t.id,0):(t==null?void 0:t.id)===s(this,_).current?0:-1}setCurrentTabStopId(t){s(this,_).current=t}focusCurrentTabStop(){var r;const t=s(this,_).current;if(!t)return;const e=(r=s(this,E).rootNode.current)==null?void 0:r.querySelector(`#${t}`);!e||!j(e)||e.focus()}}E=new WeakMap,_=new WeakMap;var wt,ot,H,on,Se;class js{constructor(t){a(this,H);a(this,wt);a(this,ot,null);p(this,wt,t),me(()=>m(this,H,on).call(this))}run(t){m(this,H,on).call(this);const e=s(this,wt).ref.current;if(e){if(typeof e.getAnimations!="function"){m(this,H,Se).call(this,t);return}p(this,ot,window.requestAnimationFrame(()=>{const r=e.getAnimations();if(r.length===0){m(this,H,Se).call(this,t);return}Promise.allSettled(r.map(i=>i.finished)).then(()=>{m(this,H,Se).call(this,t)})}))}}}wt=new WeakMap,ot=new WeakMap,H=new WeakSet,on=function(){s(this,ot)&&(window.cancelAnimationFrame(s(this,ot)),p(this,ot,null))},Se=function(t){const e=()=>{t()};s(this,wt).afterTick?q(e):e()};var B,qt,Ht,ut;class Ys{constructor(t){a(this,B);a(this,qt);a(this,Ht);a(this,ut,x(!1));p(this,B,t),v(s(this,ut),t.open.current,!0),p(this,qt,t.enabled??!0),p(this,Ht,new js({ref:s(this,B).ref,afterTick:s(this,B).open})),D(()=>s(this,B).open.current,e=>{e&&v(s(this,ut),!0),s(this,qt)&&s(this,Ht).run(()=>{var r,i;e===s(this,B).open.current&&(s(this,B).open.current||v(s(this,ut),!1),(i=(r=s(this,B)).onComplete)==null||i.call(r))})})}get shouldRender(){return b(s(this,ut))}}B=new WeakMap,qt=new WeakMap,Ht=new WeakMap,ut=new WeakMap;function k(){}function Xs(n,t){var e=et(),r=nt(e);Ss(r,()=>t.children,i=>{var o=et(),u=nt(o);Dt(u,()=>t.children??kt),rt(i,o)}),rt(n,e)}const Zs=new $e("BitsConfig");function Js(){const n=new Qs(null,{});return Zs.getOr(n).opts}class Qs{constructor(t,e){f(this,"opts");const r=$s(t,e);this.opts={defaultPortalTo:r(i=>i.defaultPortalTo),defaultLocale:r(i=>i.defaultLocale)}}}function $s(n,t){return e=>y(()=>{var o,u;const i=(o=e(t))==null?void 0:o.current;if(i!==void 0)return i;if(n!==null)return(u=e(n.opts))==null?void 0:u.current})}function ti(n,t){return e=>{const r=Js();return y(()=>{const i=e();if(i!==void 0)return i;const o=n(r).current;return o!==void 0?o:t})}}const ei=ti(n=>n.defaultPortalTo,"body");function io(n,t){Ft(t,!0);const e=ei(()=>t.to),r=ss();let i=O(o);function o(){if(!dr||t.disabled)return null;let d=null;return typeof e.current=="string"?d=document.querySelector(e.current):d=e.current,d}let u;function c(){u&&(us(u),u=null)}D([()=>b(i),()=>t.disabled],([d,w])=>{if(!d||w){c();return}return u=os(Xs,{target:d,props:{children:t.children},context:r}),()=>{c()}});var l=et(),h=nt(l);{var g=d=>{var w=et(),M=nt(w);Dt(M,()=>t.children??kt),rt(d,w)};cs(h,d=>{t.disabled&&d(g)})}rt(n,l),Ot()}class ni{constructor(t,e={bubbles:!0,cancelable:!0}){f(this,"eventName");f(this,"options");this.eventName=t,this.options=e}createEvent(t){return new CustomEvent(this.eventName,{...this.options,detail:t})}dispatch(t,e){const r=this.createEvent(e);return t.dispatchEvent(r),r}listen(t,e,r){const i=o=>{e(o)};return S(t,this.eventName,i,r)}}function Un(n,t=500){let e=null;const r=(...i)=>{e!==null&&clearTimeout(e),e=setTimeout(()=>{n(...i)},t)};return r.destroy=()=>{e!==null&&(clearTimeout(e),e=null)},r}function gr(n,t){return n===t||n.contains(t)}function br(n){return(n==null?void 0:n.ownerDocument)??document}function ri(n,t){const{clientX:e,clientY:r}=n,i=t.getBoundingClientRect();return ei.right||ri.bottom}const si=[hr,Tn],ii=[Gt,Ws,fr],mr=[Ae,Bs,lr],oi=[...ii,...mr];function zn(n){return n.pointerType==="mouse"}function ui(n,{select:t=!1}={}){if(!n||!n.focus)return;const e=ve(n);if(e.activeElement===n)return;const r=e.activeElement;n.focus({preventScroll:!0}),n!==r&&qs(n)&&t&&n.select()}function ai(n,{select:t=!1}={},e){const r=e();for(const i of n)if(ui(i,{select:t}),e()!==r)return!0}let Lt=x(!1);const F=class F{constructor(){bt(()=>(F._refs===0&&(F._cleanup=nr(()=>{const t=[],e=i=>{v(Lt,!1)},r=i=>{v(Lt,!0)};return t.push(S(document,"pointerdown",e,{capture:!0}),S(document,"pointermove",e,{capture:!0}),S(document,"keydown",r,{capture:!0})),vt(...t)})),F._refs++,()=>{var t;F._refs--,F._refs===0&&(v(Lt,!1),(t=F._cleanup)==null||t.call(F))}))}get current(){return b(Lt)}set current(t){v(Lt,t,!0)}};f(F,"_refs",0),f(F,"_cleanup");let un=F;/*! * tabbable 6.4.0 * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE */var vr=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Me=vr.join(","),yr=typeof Element>"u",gt=yr?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Ie=!yr&&Element.prototype.getRootNode?function(n){var t;return n==null||(t=n.getRootNode)===null||t===void 0?void 0:t.call(n)}:function(n){return n==null?void 0:n.ownerDocument},Ne=function(t,e){var r;e===void 0&&(e=!0);var i=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),o=i===""||i==="true",u=o||e&&t&&(typeof t.closest=="function"?t.closest("[inert]"):Ne(t.parentNode));return u},ci=function(t){var e,r=t==null||(e=t.getAttribute)===null||e===void 0?void 0:e.call(t,"contenteditable");return r===""||r==="true"},wr=function(t,e,r){if(Ne(t))return[];var i=Array.prototype.slice.apply(t.querySelectorAll(Me));return e&>.call(t,Me)&&i.unshift(t),i=i.filter(r),i},ke=function(t,e,r){for(var i=[],o=Array.from(t);o.length;){var u=o.shift();if(!Ne(u,!1))if(u.tagName==="SLOT"){var c=u.assignedElements(),l=c.length?c:u.children,h=ke(l,!0,r);r.flatten?i.push.apply(i,h):i.push({scopeParent:u,candidates:h})}else{var g=gt.call(u,Me);g&&r.filter(u)&&(e||!t.includes(u))&&i.push(u);var d=u.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(u),w=!Ne(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(u));if(d&&w){var M=ke(d===!0?u.children:d.children,!0,r);r.flatten?i.push.apply(i,M):i.push({scopeParent:u,candidates:M})}else o.unshift.apply(o,u.children)}}return i},Tr=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Sr=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||ci(t))&&!Tr(t)?0:t.tabIndex},li=function(t,e){var r=Sr(t);return r<0&&e&&!Tr(t)?0:r},hi=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},xr=function(t){return t.tagName==="INPUT"},fi=function(t){return xr(t)&&t.type==="hidden"},di=function(t){var e=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return e},pi=function(t,e){for(var r=0;rsummary:first-of-type"),c=u?t.parentElement:t;if(gt.call(c,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof i=="function"){for(var l=t;t;){var h=t.parentElement,g=Ie(t);if(h&&!h.shadowRoot&&i(h)===!0)return Vn(t);t.assignedSlot?t=t.assignedSlot:!h&&g!==t.ownerDocument?t=g.host:t=h}t=l}if(vi(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return Vn(t);return!1},wi=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if(e.tagName==="FIELDSET"&&e.disabled){for(var r=0;r=0)},Er=function(t){var e=[],r=[];return t.forEach(function(i,o){var u=!!i.scopeParent,c=u?i.scopeParent:i,l=li(c,u),h=u?Er(i.candidates):c;l===0?u?e.push.apply(e,h):e.push(c):r.push({documentOrder:o,tabIndex:l,item:i,isScope:u,content:h})}),r.sort(hi).reduce(function(i,o){return o.isScope?i.push.apply(i,o.content):i.push(o.content),i},[]).concat(e)},Cr=function(t,e){e=e||{};var r;return e.getShadowRoot?r=ke([t],e.includeContainer,{filter:an.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:Ti}):r=wr(t,e.includeContainer,an.bind(null,e)),Er(r)},Ar=function(t,e){e=e||{};var r;return e.getShadowRoot?r=ke([t],e.includeContainer,{filter:Fe.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):r=wr(t,e.includeContainer,Fe.bind(null,e)),r},Sn=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return gt.call(t,Me)===!1?!1:an(e,t)},Si=vr.concat("iframe:not([inert]):not([inert] *)").join(","),Mr=function(t,e){if(e=e||{},!t)throw new Error("No node provided");return gt.call(t,Si)===!1?!1:Fe(e,t)};function _t(){return{getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"}}function xi(n,t){if(!Sn(n,_t()))return Ei(n,t);const e=ve(n),r=Cr(e.body,_t());t==="prev"&&r.reverse();const i=r.indexOf(n);return i===-1?e.body:r.slice(i+1)[0]}function Ei(n,t){const e=ve(n);if(!Mr(n,_t()))return e.body;const r=Ar(e.body,_t());t==="prev"&&r.reverse();const i=r.indexOf(n);return i===-1?e.body:r.slice(i+1).find(u=>Sn(u,_t()))??e.body}function Ir(n,t,e){const r=t.toLowerCase();if(r.endsWith(" ")){const d=r.slice(0,-1);if(n.filter(Y=>Y.toLowerCase().startsWith(d)).length<=1)return Ir(n,d,e);const M=e==null?void 0:e.toLowerCase();if(M&&M.startsWith(d)&&M.charAt(d.length)===" "&&t.trim()===d)return e;const Pt=n.filter(Y=>Y.toLowerCase().startsWith(r));if(Pt.length>0){const Y=e?n.indexOf(e):-1;return qn(Pt,Math.max(Y,0)).find(zr=>zr!==e)||e}}const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,u=o.toLowerCase(),c=e?n.indexOf(e):-1;let l=qn(n,Math.max(c,0));o.length===1&&(l=l.filter(d=>d!==e));const g=l.find(d=>d==null?void 0:d.toLowerCase().startsWith(u));return g!==e?g:void 0}function qn(n,t){return n.map((e,r)=>n[(t+r)%n.length])}const Ci={afterMs:1e4,onChange:k};function Nr(n,t){const{afterMs:e,onChange:r,getWindow:i}={...Ci,...t};let o=null,u=x(er(n));function c(){return i().setTimeout(()=>{v(u,n,!0),r==null||r(n)},e)}return bt(()=>()=>{o&&i().clearTimeout(o)}),y(()=>b(u),l=>{v(u,l,!0),r==null||r(l),o&&i().clearTimeout(o),o=c()})}var G,U,De,Pe;class Ai{constructor(t){a(this,G);a(this,U);a(this,De,O(()=>s(this,G).onMatch?s(this,G).onMatch:t=>t.focus()));a(this,Pe,O(()=>s(this,G).getCurrentItem?s(this,G).getCurrentItem:s(this,G).getActiveElement));p(this,G,t),p(this,U,Nr("",{afterMs:1e3,getWindow:t.getWindow})),this.handleTypeaheadSearch=this.handleTypeaheadSearch.bind(this),this.resetTypeahead=this.resetTypeahead.bind(this)}handleTypeaheadSearch(t,e){var l,h;if(!e.length)return;s(this,U).current=s(this,U).current+t;const r=b(s(this,Pe))(),i=((h=(l=e.find(g=>g===r))==null?void 0:l.textContent)==null?void 0:h.trim())??"",o=e.map(g=>{var d;return((d=g.textContent)==null?void 0:d.trim())??""}),u=Ir(o,s(this,U).current,i),c=e.find(g=>{var d;return((d=g.textContent)==null?void 0:d.trim())===u});return c&&b(s(this,De))(c),c}resetTypeahead(){s(this,U).current=""}get search(){return s(this,U).current}}G=new WeakMap,U=new WeakMap,De=new WeakMap,Pe=new WeakMap;var at,jt,Tt,X,st,cn,ln;class Mi{constructor(t){a(this,st);a(this,at);a(this,jt);a(this,Tt);a(this,X,x(null));p(this,at,t),p(this,jt,O(()=>s(this,at).enabled())),p(this,Tt,Nr(!1,{afterMs:t.transitTimeout??300,onChange:e=>{var r,i;b(s(this,jt))&&((i=(r=s(this,at)).setIsPointerInTransit)==null||i.call(r,e))},getWindow:()=>cr(s(this,at).triggerNode())})),D([t.triggerNode,t.contentNode,t.enabled],([e,r,i])=>{if(!e||!r||!i)return;const o=c=>{m(this,st,ln).call(this,c,r)},u=c=>{m(this,st,ln).call(this,c,e)};return vt(S(e,"pointerleave",o),S(r,"pointerleave",u))}),D(()=>b(s(this,X)),()=>{const e=i=>{var h,g;if(!b(s(this,X)))return;const o=i.target;if(!sn(o))return;const u={x:i.clientX,y:i.clientY},c=((h=t.triggerNode())==null?void 0:h.contains(o))||((g=t.contentNode())==null?void 0:g.contains(o)),l=!Fi(u,b(s(this,X)));c?m(this,st,cn).call(this):l&&(m(this,st,cn).call(this),t.onPointerExit())},r=ve(t.triggerNode()??t.contentNode());if(r)return S(r,"pointermove",e)})}}at=new WeakMap,jt=new WeakMap,Tt=new WeakMap,X=new WeakMap,st=new WeakSet,cn=function(){v(s(this,X),null),s(this,Tt).current=!1},ln=function(t,e){const r=t.currentTarget;if(!j(r))return;const i={x:t.clientX,y:t.clientY},o=Ii(i,r.getBoundingClientRect()),u=Ni(i,o),c=ki(e.getBoundingClientRect()),l=Oi([...u,...c]);v(s(this,X),l,!0),s(this,Tt).current=!0};function Ii(n,t){const e=Math.abs(t.top-n.y),r=Math.abs(t.bottom-n.y),i=Math.abs(t.right-n.x),o=Math.abs(t.left-n.x);switch(Math.min(e,r,i,o)){case o:return"left";case i:return"right";case e:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Ni(n,t,e=5){const r=e*1.5;switch(t){case"top":return[{x:n.x-e,y:n.y+e},{x:n.x,y:n.y-r},{x:n.x+e,y:n.y+e}];case"bottom":return[{x:n.x-e,y:n.y-e},{x:n.x,y:n.y+r},{x:n.x+e,y:n.y-e}];case"left":return[{x:n.x+e,y:n.y-e},{x:n.x-r,y:n.y},{x:n.x+e,y:n.y+e}];case"right":return[{x:n.x-e,y:n.y-e},{x:n.x+r,y:n.y},{x:n.x-e,y:n.y+e}]}}function ki(n){const{top:t,right:e,bottom:r,left:i}=n;return[{x:i,y:t},{x:e,y:t},{x:e,y:r},{x:i,y:r}]}function Fi(n,t){const{x:e,y:r}=n;let i=!1;for(let o=0,u=t.length-1;or!=g>r&&e<(h-c)*(r-l)/(g-l)+c&&(i=!i)}return i}function Oi(n){const t=n.slice();return t.sort((e,r)=>e.xr.x?1:e.yr.y?1:0),Di(t)}function Di(n){if(n.length<=1)return n.slice();const t=[];for(let r=0;r=2;){const o=t[t.length-1],u=t[t.length-2];if((o.x-u.x)*(i.y-u.y)>=(o.y-u.y)*(i.x-u.x))t.pop();else break}t.push(i)}t.pop();const e=[];for(let r=n.length-1;r>=0;r--){const i=n[r];for(;e.length>=2;){const o=e[e.length-1],u=e[e.length-2];if((o.x-u.x)*(i.y-u.y)>=(o.y-u.y)*(i.x-u.x))e.pop();else break}e.push(i)}return e.pop(),t.length===1&&e.length===1&&t[0].x===e[0].x&&t[0].y===e[0].y?t:t.concat(e)}const Pi="data-context-menu-trigger",Ri="data-context-menu-content",kr=new $e("Menu.Root"),xn=new $e("Menu.Root | Menu.Sub"),Fr=new $e("Menu.Content"),Li=new ni("bitsmenuopen",{bubbles:!1,cancelable:!0}),Bi=vs({component:"menu",parts:["trigger","content","sub-trigger","item","group","group-heading","checkbox-group","checkbox-item","radio-group","radio-item","separator","sub-content","arrow"]});var Yt,Xt;const Cn=class Cn{constructor(t){f(this,"opts");f(this,"isUsingKeyboard",new un);a(this,Yt,x(!1));a(this,Xt,x(!1));f(this,"getBitsAttr",t=>Bi.getAttr(t,this.opts.variant.current));this.opts=t}static create(t){const e=new Cn(t);return kr.set(e)}get ignoreCloseAutoFocus(){return b(s(this,Yt))}set ignoreCloseAutoFocus(t){v(s(this,Yt),t,!0)}get isPointerInTransit(){return b(s(this,Xt))}set isPointerInTransit(t){v(s(this,Xt),t,!0)}};Yt=new WeakMap,Xt=new WeakMap;let Hn=Cn;var Zt,Jt;const An=class An{constructor(t,e,r){f(this,"opts");f(this,"root");f(this,"parentMenu");f(this,"contentId",y(()=>""));a(this,Zt,x(null));f(this,"contentPresence");a(this,Jt,x(null));this.opts=t,this.root=e,this.parentMenu=r,this.contentPresence=new Ys({ref:y(()=>this.contentNode),open:this.opts.open,onComplete:()=>{this.opts.onOpenChangeComplete.current(this.opts.open.current)}}),r&&D(()=>r.opts.open.current,()=>{r.opts.open.current||(this.opts.open.current=!1)})}static create(t,e){return xn.set(new An(t,e,null))}get contentNode(){return b(s(this,Zt))}set contentNode(t){v(s(this,Zt),t,!0)}get triggerNode(){return b(s(this,Jt))}set triggerNode(t){v(s(this,Jt),t,!0)}toggleOpen(){this.opts.open.current=!this.opts.open.current}onOpen(){this.opts.open.current=!0}onClose(){this.opts.open.current=!1}};Zt=new WeakMap,Jt=new WeakMap;let jn=An;var Qt,$t,te,ee,ne,tt,Or,xe,re,se;const Mn=class Mn{constructor(t,e){a(this,tt);f(this,"opts");f(this,"parentMenu");f(this,"rovingFocusGroup");f(this,"domContext");f(this,"attachment");a(this,Qt,x(""));a(this,$t,0);a(this,te);a(this,ee,x(!1));a(this,ne);f(this,"onCloseAutoFocus",t=>{var e,r;(r=(e=this.opts.onCloseAutoFocus).current)==null||r.call(e,t),!(t.defaultPrevented||s(this,ne))&&this.parentMenu.triggerNode&&Sn(this.parentMenu.triggerNode)&&(t.preventDefault(),this.parentMenu.triggerNode.focus())});a(this,re,O(()=>({open:this.parentMenu.opts.open.current})));a(this,se,O(()=>({id:this.opts.id.current,role:"menu","aria-orientation":"vertical",[this.parentMenu.root.getBitsAttr("content")]:"","data-state":rr(this.parentMenu.opts.open.current),onkeydown:this.onkeydown,onblur:this.onblur,onfocus:this.onfocus,dir:this.parentMenu.root.opts.dir.current,style:{pointerEvents:"auto",contain:"layout style"},...this.attachment})));f(this,"popperProps",{onCloseAutoFocus:t=>this.onCloseAutoFocus(t)});this.opts=t,this.parentMenu=e,this.domContext=new vn(t.ref),this.attachment=Qe(this.opts.ref,r=>{this.parentMenu.contentNode!==r&&(this.parentMenu.contentNode=r)}),e.contentId=t.id,p(this,ne,t.isSub??!1),this.onkeydown=this.onkeydown.bind(this),this.onblur=this.onblur.bind(this),this.onfocus=this.onfocus.bind(this),this.handleInteractOutside=this.handleInteractOutside.bind(this),new Mi({contentNode:()=>this.parentMenu.contentNode,triggerNode:()=>this.parentMenu.triggerNode,enabled:()=>{var r;return this.parentMenu.opts.open.current&&!!((r=this.parentMenu.triggerNode)!=null&&r.hasAttribute(this.parentMenu.root.getBitsAttr("sub-trigger")))},onPointerExit:()=>{this.parentMenu.opts.open.current=!1},setIsPointerInTransit:r=>{this.parentMenu.root.isPointerInTransit=r}}),p(this,te,new Ai({getActiveElement:()=>this.domContext.getActiveElement(),getWindow:()=>this.domContext.getWindow()}).handleTypeaheadSearch),this.rovingFocusGroup=new Hs({rootNode:y(()=>this.parentMenu.contentNode),candidateAttr:this.parentMenu.root.getBitsAttr("item"),loop:this.opts.loop,orientation:y(()=>"vertical")}),D(()=>this.parentMenu.contentNode,r=>{if(!r)return;const i=()=>{q(()=>{this.parentMenu.root.isUsingKeyboard.current&&this.rovingFocusGroup.focusFirstCandidate()})};return Li.listen(r,i)}),bt(()=>{this.parentMenu.opts.open.current||this.domContext.getWindow().clearTimeout(s(this,$t))})}static create(t){return Fr.set(new Mn(t,xn.get()))}get search(){return b(s(this,Qt))}set search(t){v(s(this,Qt),t,!0)}get mounted(){return b(s(this,ee))}set mounted(t){v(s(this,ee),t,!0)}handleTabKeyDown(t){let e=this.parentMenu;for(;e.parentMenu!==null;)e=e.parentMenu;if(!e.triggerNode)return;t.preventDefault();const r=xi(e.triggerNode,t.shiftKey?"prev":"next");r?(this.parentMenu.root.ignoreCloseAutoFocus=!0,e.onClose(),q(()=>{r.focus(),q(()=>{this.parentMenu.root.ignoreCloseAutoFocus=!1})})):this.domContext.getDocument().body.focus()}onkeydown(t){var h,g;if(t.defaultPrevented)return;if(t.key===Ks){this.handleTabKeyDown(t);return}const e=t.target,r=t.currentTarget;if(!j(e)||!j(r))return;const i=((h=e.closest(`[${this.parentMenu.root.getBitsAttr("content")}]`))==null?void 0:h.id)===this.parentMenu.contentId.current,o=t.ctrlKey||t.altKey||t.metaKey,u=t.key.length===1;if(this.rovingFocusGroup.handleKeydown(e,t)||t.code==="Space")return;const l=m(this,tt,Or).call(this);i&&!o&&u&&s(this,te).call(this,t.key,l),((g=t.target)==null?void 0:g.id)===this.parentMenu.contentId.current&&oi.includes(t.key)&&(t.preventDefault(),mr.includes(t.key)&&l.reverse(),ai(l,{select:!1},()=>this.domContext.getActiveElement()))}onblur(t){var e,r;sn(t.currentTarget)&&sn(t.target)&&((r=(e=t.currentTarget).contains)!=null&&r.call(e,t.target)||(this.domContext.getWindow().clearTimeout(s(this,$t)),this.search=""))}onfocus(t){this.parentMenu.root.isUsingKeyboard.current&&q(()=>this.rovingFocusGroup.focusFirstCandidate())}onItemEnter(){return m(this,tt,xe).call(this)}onItemLeave(t){if(t.currentTarget.hasAttribute(this.parentMenu.root.getBitsAttr("sub-trigger"))||m(this,tt,xe).call(this)||this.parentMenu.root.isUsingKeyboard.current)return;const e=this.parentMenu.contentNode;e==null||e.focus(),this.rovingFocusGroup.setCurrentTabStopId("")}onTriggerLeave(){return!!m(this,tt,xe).call(this)}handleInteractOutside(t){var r;if(!pr(t.target))return;const e=(r=this.parentMenu.triggerNode)==null?void 0:r.id;if(t.target.id===e){t.preventDefault();return}t.target.closest(`#${e}`)&&t.preventDefault()}get shouldRender(){return this.parentMenu.contentPresence.shouldRender}get snippetProps(){return b(s(this,re))}set snippetProps(t){v(s(this,re),t)}get props(){return b(s(this,se))}set props(t){v(s(this,se),t)}};Qt=new WeakMap,$t=new WeakMap,te=new WeakMap,ee=new WeakMap,ne=new WeakMap,tt=new WeakSet,Or=function(){const t=this.parentMenu.contentNode;return t?Array.from(t.querySelectorAll(`[${this.parentMenu.root.getBitsAttr("item")}]:not([data-disabled])`)):[]},xe=function(){return this.parentMenu.root.isPointerInTransit},re=new WeakMap,se=new WeakMap;let Yn=Mn;var St,ie;class Wi{constructor(t,e){f(this,"opts");f(this,"content");f(this,"attachment");a(this,St,x(!1));a(this,ie,O(()=>({id:this.opts.id.current,tabindex:-1,role:"menuitem","aria-disabled":ir(this.opts.disabled.current),"data-disabled":sr(this.opts.disabled.current),"data-highlighted":b(s(this,St))?"":void 0,[this.content.parentMenu.root.getBitsAttr("item")]:"",onpointermove:this.onpointermove,onpointerleave:this.onpointerleave,onfocus:this.onfocus,onblur:this.onblur,...this.attachment})));this.opts=t,this.content=e,this.attachment=Qe(this.opts.ref),this.onpointermove=this.onpointermove.bind(this),this.onpointerleave=this.onpointerleave.bind(this),this.onfocus=this.onfocus.bind(this),this.onblur=this.onblur.bind(this)}onpointermove(t){if(!t.defaultPrevented&&zn(t))if(this.opts.disabled.current)this.content.onItemLeave(t);else{if(this.content.onItemEnter())return;const r=t.currentTarget;if(!j(r))return;r.focus()}}onpointerleave(t){t.defaultPrevented||zn(t)&&this.content.onItemLeave(t)}onfocus(t){q(()=>{t.defaultPrevented||this.opts.disabled.current||v(s(this,St),!0)})}onblur(t){q(()=>{t.defaultPrevented||v(s(this,St),!1)})}get props(){return b(s(this,ie))}set props(t){v(s(this,ie),t)}}St=new WeakMap,ie=new WeakMap;var oe,Re,Dr,ue;const In=class In{constructor(t,e){a(this,Re);f(this,"opts");f(this,"item");f(this,"root");a(this,oe,!1);a(this,ue,O(()=>ms(this.item.props,{onclick:this.onclick,onpointerdown:this.onpointerdown,onpointerup:this.onpointerup,onkeydown:this.onkeydown})));this.opts=t,this.item=e,this.root=e.content.parentMenu.root,this.onkeydown=this.onkeydown.bind(this),this.onclick=this.onclick.bind(this),this.onpointerdown=this.onpointerdown.bind(this),this.onpointerup=this.onpointerup.bind(this)}static create(t){const e=new Wi(t,Fr.get());return new In(t,e)}onkeydown(t){const e=this.item.content.search!=="";if(!(this.item.opts.disabled.current||e&&t.key===Tn)&&si.includes(t.key)){if(!j(t.currentTarget))return;t.currentTarget.click(),t.preventDefault()}}onclick(t){this.item.opts.disabled.current||m(this,Re,Dr).call(this)}onpointerup(t){var e;if(!t.defaultPrevented&&!s(this,oe)){if(!j(t.currentTarget))return;(e=t.currentTarget)==null||e.click()}}onpointerdown(t){p(this,oe,!0)}get props(){return b(s(this,ue))}set props(t){v(s(this,ue),t)}};oe=new WeakMap,Re=new WeakSet,Dr=function(){if(this.item.opts.disabled.current)return;const t=new CustomEvent("menuitemselect",{bubbles:!0,cancelable:!0});if(this.opts.onSelect.current(t),t.defaultPrevented){this.item.content.parentMenu.root.isUsingKeyboard.current=!1;return}this.opts.closeOnSelect.current&&this.item.content.parentMenu.root.opts.onClose()},ue=new WeakMap;let Xn=In;var ae;const Nn=class Nn{constructor(t,e){f(this,"opts");f(this,"root");f(this,"attachment");a(this,ae,O(()=>({id:this.opts.id.current,role:"group",[this.root.getBitsAttr("separator")]:"",...this.attachment})));this.opts=t,this.root=e,this.attachment=Qe(this.opts.ref)}static create(t){return new Nn(t,kr.get())}get props(){return b(s(this,ae))}set props(t){v(s(this,ae),t)}};ae=new WeakMap;let Zn=Nn;var Le,ce;const kn=class kn{constructor(t,e){f(this,"opts");f(this,"parentMenu");f(this,"attachment");f(this,"onclick",t=>{this.opts.disabled.current||t.detail!==0||(this.parentMenu.toggleOpen(),t.preventDefault())});f(this,"onpointerdown",t=>{if(!this.opts.disabled.current){if(t.pointerType==="touch")return t.preventDefault();t.button===0&&t.ctrlKey===!1&&(this.parentMenu.toggleOpen(),this.parentMenu.opts.open.current||t.preventDefault())}});f(this,"onpointerup",t=>{this.opts.disabled.current||t.pointerType==="touch"&&(t.preventDefault(),this.parentMenu.toggleOpen())});f(this,"onkeydown",t=>{if(!this.opts.disabled.current){if(t.key===Tn||t.key===hr){this.parentMenu.toggleOpen(),t.preventDefault();return}t.key===Gt&&(this.parentMenu.onOpen(),t.preventDefault())}});a(this,Le,O(()=>{if(this.parentMenu.opts.open.current&&this.parentMenu.contentId.current)return this.parentMenu.contentId.current}));a(this,ce,O(()=>({id:this.opts.id.current,disabled:this.opts.disabled.current,"aria-haspopup":"menu","aria-expanded":ir(this.parentMenu.opts.open.current),"aria-controls":b(s(this,Le)),"data-disabled":sr(this.opts.disabled.current),"data-state":rr(this.parentMenu.opts.open.current),[this.parentMenu.root.getBitsAttr("trigger")]:"",onclick:this.onclick,onpointerdown:this.onpointerdown,onpointerup:this.onpointerup,onkeydown:this.onkeydown,...this.attachment})));this.opts=t,this.parentMenu=e,this.attachment=Qe(this.opts.ref,r=>this.parentMenu.triggerNode=r)}static create(t){return new kn(t,xn.get())}get props(){return b(s(this,ce))}set props(t){v(s(this,ce),t)}};Le=new WeakMap,ce=new WeakMap;let Jn=kn;globalThis.bitsDismissableLayers??(globalThis.bitsDismissableLayers=new Map);var xt,ct,Z,Et,Ct,J,le,z,Be,Nt,Pr,We,At,Ke,_e,Ge,Ue,he,Rr,ze,Ve;const Fn=class Fn{constructor(t){a(this,Nt);f(this,"opts");a(this,xt);a(this,ct);a(this,Z,{pointerdown:!1});a(this,Et,!1);a(this,Ct,!1);a(this,J);a(this,le);a(this,z,k);a(this,Be,t=>{t.defaultPrevented||this.opts.ref.current&&q(()=>{var e,r;!this.opts.ref.current||s(this,Ue).call(this,t.target)||t.target&&!s(this,Ct)&&((r=(e=s(this,le)).current)==null||r.call(e,t))})});a(this,We,t=>{let e=t;e.defaultPrevented&&(e=Qn(t)),s(this,xt).current(t)});a(this,At,Un(t=>{if(!this.opts.ref.current){s(this,z).call(this);return}const e=this.opts.isValidEvent.current(t,this.opts.ref.current)||Gi(t,this.opts.ref.current);if(!s(this,Et)||m(this,Nt,Rr).call(this)||!e){s(this,z).call(this);return}let r=t;if(r.defaultPrevented&&(r=Qn(r)),s(this,ct).current!=="close"&&s(this,ct).current!=="defer-otherwise-close"){s(this,z).call(this);return}t.pointerType==="touch"?(s(this,z).call(this),p(this,z,S(s(this,J),"click",s(this,We),{once:!0}))):s(this,xt).current(r)},10));a(this,Ke,t=>{s(this,Z)[t.type]=!0});a(this,_e,t=>{s(this,Z)[t.type]=!1});a(this,Ge,()=>{this.opts.ref.current&&p(this,Et,_i(this.opts.ref.current))});a(this,Ue,t=>this.opts.ref.current?gr(this.opts.ref.current,t):!1);a(this,he,Un(()=>{for(const t in s(this,Z))s(this,Z)[t]=!1;p(this,Et,!1)},20));a(this,ze,()=>{p(this,Ct,!0)});a(this,Ve,()=>{p(this,Ct,!1)});f(this,"props",{onfocuscapture:s(this,ze),onblurcapture:s(this,Ve)});this.opts=t,p(this,ct,t.interactOutsideBehavior),p(this,xt,t.onInteractOutside),p(this,le,t.onFocusOutside),bt(()=>{p(this,J,br(this.opts.ref.current))});let e=k;const r=()=>{s(this,he).call(this),globalThis.bitsDismissableLayers.delete(this),s(this,At).destroy(),e()};D([()=>this.opts.enabled.current,()=>this.opts.ref.current],()=>{if(!(!this.opts.enabled.current||!this.opts.ref.current))return Is(1,()=>{this.opts.ref.current&&(globalThis.bitsDismissableLayers.set(this,s(this,ct)),e(),e=m(this,Nt,Pr).call(this))}),r}),me(()=>{s(this,he).destroy(),globalThis.bitsDismissableLayers.delete(this),s(this,At).destroy(),s(this,z).call(this),e()})}static create(t){return new Fn(t)}};xt=new WeakMap,ct=new WeakMap,Z=new WeakMap,Et=new WeakMap,Ct=new WeakMap,J=new WeakMap,le=new WeakMap,z=new WeakMap,Be=new WeakMap,Nt=new WeakSet,Pr=function(){return vt(S(s(this,J),"pointerdown",vt(s(this,Ke),s(this,Ge)),{capture:!0}),S(s(this,J),"pointerdown",vt(s(this,_e),s(this,At))),S(s(this,J),"focusin",s(this,Be)))},We=new WeakMap,At=new WeakMap,Ke=new WeakMap,_e=new WeakMap,Ge=new WeakMap,Ue=new WeakMap,he=new WeakMap,Rr=function(){return Object.values(s(this,Z)).some(Boolean)},ze=new WeakMap,Ve=new WeakMap;let hn=Fn;function Ki(n=[...globalThis.bitsDismissableLayers]){return n.findLast(([t,{current:e}])=>e==="close"||e==="ignore")}function _i(n){const t=[...globalThis.bitsDismissableLayers],e=Ki(t);if(e)return e[0].opts.ref.current===n;const[r]=t[0];return r.opts.ref.current===n}function Gi(n,t){const e=n.target;if(!pr(e))return!1;const r=!!e.closest(`[${Pi}]`);if("button"in n&&n.button>0&&!r)return!1;if("button"in n&&n.button===0&&r)return!0;const i=!!t.closest(`[${Ri}]`);return r&&i?!1:br(e).documentElement.contains(e)&&!gr(t,e)&&ri(n,t)}function Qn(n){const t=n.currentTarget,e=n.target;let r;n instanceof PointerEvent?r=new PointerEvent(n.type,n):r=new PointerEvent("pointerdown",n);let i=!1;return new Proxy(r,{get:(u,c)=>c==="currentTarget"?t:c==="target"?e:c==="preventDefault"?()=>{i=!0,typeof u.preventDefault=="function"&&u.preventDefault()}:c==="defaultPrevented"?i:c in u?u[c]:n[c]})}function oo(n,t){Ft(t,!0);let e=A(t,"interactOutsideBehavior",3,"close"),r=A(t,"onInteractOutside",3,k),i=A(t,"onFocusOutside",3,k),o=A(t,"isValidEvent",3,()=>!1);const u=hn.create({id:y(()=>t.id),interactOutsideBehavior:y(()=>e()),onInteractOutside:y(()=>r()),enabled:y(()=>t.enabled),onFocusOutside:y(()=>i()),isValidEvent:y(()=>o()),ref:t.ref});var c=et(),l=nt(c);Dt(l,()=>t.children??kt,()=>({props:u.props})),rt(n,c),Ot()}globalThis.bitsEscapeLayers??(globalThis.bitsEscapeLayers=new Map);var qe,He;const On=class On{constructor(t){f(this,"opts");f(this,"domContext");a(this,qe,()=>S(this.domContext.getDocument(),"keydown",s(this,He),{passive:!1}));a(this,He,t=>{if(t.key!==Ls||!Ui(this))return;const e=new KeyboardEvent(t.type,t);t.preventDefault();const r=this.opts.escapeKeydownBehavior.current;r!=="close"&&r!=="defer-otherwise-close"||this.opts.onEscapeKeydown.current(e)});this.opts=t,this.domContext=new vn(this.opts.ref);let e=k;D(()=>t.enabled.current,r=>(r&&(globalThis.bitsEscapeLayers.set(this,t.escapeKeydownBehavior),e=s(this,qe).call(this)),()=>{e(),globalThis.bitsEscapeLayers.delete(this)}))}static create(t){return new On(t)}};qe=new WeakMap,He=new WeakMap;let fn=On;function Ui(n){const t=[...globalThis.bitsEscapeLayers],e=t.findLast(([i,{current:o}])=>o==="close"||o==="ignore");if(e)return e[0]===n;const[r]=t[0];return r===n}function uo(n,t){Ft(t,!0);let e=A(t,"escapeKeydownBehavior",3,"close"),r=A(t,"onEscapeKeydown",3,k);fn.create({escapeKeydownBehavior:y(()=>e()),onEscapeKeydown:y(()=>r()),enabled:y(()=>t.enabled),ref:t.ref});var i=et(),o=nt(i);Dt(o,()=>t.children??kt),rt(n,i),Ot()}var V,fe,lt;const je=class je{constructor(){a(this,V,ys([]));a(this,fe,new WeakMap);a(this,lt,new WeakMap)}static getInstance(){return this.instance||(this.instance=new je),this.instance}register(t){const e=this.getActive();e&&e!==t&&e.pause();const r=document.activeElement;r&&r!==document.body&&s(this,lt).set(t,r),s(this,V).current=s(this,V).current.filter(i=>i!==t),s(this,V).current.unshift(t)}unregister(t){s(this,V).current=s(this,V).current.filter(r=>r!==t);const e=this.getActive();e&&e.resume()}getActive(){return s(this,V).current[0]}setFocusMemory(t,e){s(this,fe).set(t,e)}getFocusMemory(t){return s(this,fe).get(t)}isActiveScope(t){return this.getActive()===t}setPreFocusMemory(t,e){s(this,lt).set(t,e)}getPreFocusMemory(t){return s(this,lt).get(t)}clearPreFocusMemory(t){s(this,lt).delete(t)}};V=new WeakMap,fe=new WeakMap,lt=new WeakMap,f(je,"instance");let dn=je;var Q,C,I,ht,$,T,Lr,Br,Wr,Kr,gn,Ee,bn;const Dn=class Dn{constructor(t){a(this,T);a(this,Q,!1);a(this,C,null);a(this,I,dn.getInstance());a(this,ht,[]);a(this,$);p(this,$,t)}get paused(){return s(this,Q)}pause(){p(this,Q,!0)}resume(){p(this,Q,!1)}mount(t){s(this,C)&&this.unmount(),p(this,C,t),s(this,I).register(this),m(this,T,Kr).call(this),m(this,T,Br).call(this)}unmount(){s(this,C)&&(m(this,T,Lr).call(this),m(this,T,Wr).call(this),s(this,I).unregister(this),s(this,I).clearPreFocusMemory(this),p(this,C,null))}static use(t){let e=null;return D([()=>t.ref.current,()=>t.enabled.current],([r,i])=>{r&&i?(e||(e=new Dn(t)),e.mount(r)):e&&(e.unmount(),e=null)}),me(()=>{e==null||e.unmount()}),{get props(){return{tabindex:-1}}}}};Q=new WeakMap,C=new WeakMap,I=new WeakMap,ht=new WeakMap,$=new WeakMap,T=new WeakSet,Lr=function(){for(const t of s(this,ht))t();p(this,ht,[])},Br=function(){if(!s(this,C))return;const t=new CustomEvent("focusScope.onOpenAutoFocus",{bubbles:!1,cancelable:!0});s(this,$).onOpenAutoFocus.current(t),t.defaultPrevented||requestAnimationFrame(()=>{if(!s(this,C))return;const e=m(this,T,Ee).call(this);e?(e.focus(),s(this,I).setFocusMemory(this,e)):s(this,C).focus()})},Wr=function(){var e,r;const t=new CustomEvent("focusScope.onCloseAutoFocus",{bubbles:!1,cancelable:!0});if((r=(e=s(this,$).onCloseAutoFocus).current)==null||r.call(e,t),!t.defaultPrevented){const i=s(this,I).getPreFocusMemory(this);if(i&&document.contains(i))try{i.focus()}catch{document.body.focus()}}},Kr=function(){if(!s(this,C)||!s(this,$).trap.current)return;const t=s(this,C),e=t.ownerDocument,r=u=>{if(s(this,Q)||!s(this,I).isActiveScope(this))return;const c=u.target;if(!c)return;if(t.contains(c))s(this,I).setFocusMemory(this,c);else{const h=s(this,I).getFocusMemory(this);if(h&&t.contains(h)&&Mr(h))u.preventDefault(),h.focus();else{const g=m(this,T,Ee).call(this),d=m(this,T,bn).call(this)[0];(g||d||t).focus()}}},i=u=>{if(!s(this,$).loop||s(this,Q)||u.key!=="Tab"||!s(this,I).isActiveScope(this))return;const c=m(this,T,gn).call(this);if(c.length===0)return;const l=c[0],h=c[c.length-1];!u.shiftKey&&e.activeElement===h?(u.preventDefault(),l.focus()):u.shiftKey&&e.activeElement===l&&(u.preventDefault(),h.focus())};s(this,ht).push(S(e,"focusin",r,{capture:!0}),S(t,"keydown",i));const o=new MutationObserver(()=>{const u=s(this,I).getFocusMemory(this);if(u&&!t.contains(u)){const c=m(this,T,Ee).call(this),l=m(this,T,bn).call(this)[0],h=c||l;h?(h.focus(),s(this,I).setFocusMemory(this,h)):t.focus()}});o.observe(t,{childList:!0,subtree:!0}),s(this,ht).push(()=>o.disconnect())},gn=function(){return s(this,C)?Cr(s(this,C),{includeContainer:!1,getShadowRoot:!0}):[]},Ee=function(){return m(this,T,gn).call(this)[0]||null},bn=function(){return s(this,C)?Ar(s(this,C),{includeContainer:!1,getShadowRoot:!0}):[]};let pn=Dn;function ao(n,t){Ft(t,!0);let e=A(t,"enabled",3,!1),r=A(t,"trapFocus",3,!1),i=A(t,"loop",3,!1),o=A(t,"onCloseAutoFocus",3,k),u=A(t,"onOpenAutoFocus",3,k);const c=pn.use({enabled:y(()=>e()),trap:y(()=>r()),loop:i(),onCloseAutoFocus:y(()=>o()),onOpenAutoFocus:y(()=>u()),ref:t.ref});var l=et(),h=nt(l);Dt(h,()=>t.focusScope??kt,()=>({props:c.props})),rt(n,l),Ot()}globalThis.bitsTextSelectionLayers??(globalThis.bitsTextSelectionLayers=new Map);var Mt,Ye,_r,Xe,de;const Pn=class Pn{constructor(t){a(this,Ye);f(this,"opts");f(this,"domContext");a(this,Mt,k);a(this,Xe,t=>{const e=this.opts.ref.current,r=t.target;!j(e)||!j(r)||!this.opts.enabled.current||!Vi(this)||!Ps(e,r)||(this.opts.onPointerDown.current(t),!t.defaultPrevented&&p(this,Mt,zi(e,this.domContext.getDocument().body)))});a(this,de,()=>{s(this,Mt).call(this),p(this,Mt,k)});this.opts=t,this.domContext=new vn(t.ref);let e=k;D(()=>this.opts.enabled.current,r=>(r&&(globalThis.bitsTextSelectionLayers.set(this,this.opts.enabled),e(),e=m(this,Ye,_r).call(this)),()=>{e(),s(this,de).call(this),globalThis.bitsTextSelectionLayers.delete(this)}))}static create(t){return new Pn(t)}};Mt=new WeakMap,Ye=new WeakSet,_r=function(){return vt(S(this.domContext.getDocument(),"pointerdown",s(this,Xe)),S(this.domContext.getDocument(),"pointerup",ws(s(this,de),this.opts.onPointerUp.current)))},Xe=new WeakMap,de=new WeakMap;let mn=Pn;const $n=n=>n.style.userSelect||n.style.webkitUserSelect;function zi(n,t){const e=$n(t),r=$n(n);return ye(t,"none"),ye(n,"text"),()=>{ye(t,e),ye(n,r)}}function ye(n,t){n.style.userSelect=t,n.style.webkitUserSelect=t}function Vi(n){const t=[...globalThis.bitsTextSelectionLayers];if(!t.length)return!1;const e=t.at(-1);return e?e[0]===n:!1}function co(n,t){Ft(t,!0);let e=A(t,"preventOverflowTextSelection",3,!0),r=A(t,"onPointerDown",3,k),i=A(t,"onPointerUp",3,k);mn.create({id:y(()=>t.id),onPointerDown:y(()=>r()),onPointerUp:y(()=>i()),enabled:y(()=>t.enabled&&e()),ref:t.ref});var o=et(),u=nt(o);Dt(u,()=>t.children??kt),rt(n,o),Ot()}globalThis.bitsIdCounter??(globalThis.bitsIdCounter={current:0});function qi(n="bits"){return globalThis.bitsIdCounter.current++,`${n}-${globalThis.bitsIdCounter.current}`}var pe,It,ft,dt,Ze,Gr;class Hi{constructor(t){a(this,Ze);a(this,pe);a(this,It,0);a(this,ft,x());a(this,dt);p(this,pe,t)}get(...t){return p(this,It,s(this,It)+1),b(s(this,ft))===void 0&&p(this,dt,nr(()=>{v(s(this,ft),s(this,pe).call(this,...t),!0)})),bt(()=>()=>{m(this,Ze,Gr).call(this)}),b(s(this,ft))}}pe=new WeakMap,It=new WeakMap,ft=new WeakMap,dt=new WeakMap,Ze=new WeakSet,Gr=function(){p(this,It,s(this,It)-1),s(this,dt)&&s(this,It)<=0&&(s(this,dt).call(this),v(s(this,ft),void 0),p(this,dt,void 0))};const Ce=new nn;let we=x(null),it=null,Bt=null,Wt=!1;const tr=y(()=>{for(const n of Ce.values())if(n)return!0;return!1});let en=null;const ji=new Hi(()=>{function n(){document.body.setAttribute("style",b(we)??""),document.body.style.removeProperty("--scrollbar-width"),Gn&&(it==null||it()),v(we,null)}function t(){Bt!==null&&(window.clearTimeout(Bt),Bt=null)}function e(i,o){t(),Wt=!0,en=Date.now();const u=en,c=()=>{Bt=null,en===u&&(Ur(Ce)?Wt=!1:(Wt=!1,o()))},l=i===null?24:i;Bt=window.setTimeout(c,l)}function r(){b(we)===null&&Ce.size===0&&!Wt&&v(we,document.body.getAttribute("style"),!0)}return D(()=>tr.current,()=>{var g,d;if(!tr.current)return;r(),Wt=!1;const i=getComputedStyle(document.documentElement),o=getComputedStyle(document.body),u=((g=i.scrollbarGutter)==null?void 0:g.includes("stable"))||((d=o.scrollbarGutter)==null?void 0:d.includes("stable")),c=window.innerWidth-document.documentElement.clientWidth,h={padding:Number.parseInt(o.paddingRight??"0",10)+c,margin:Number.parseInt(o.marginRight??"0",10)};c>0&&!u&&(document.body.style.paddingRight=`${h.padding}px`,document.body.style.marginRight=`${h.margin}px`,document.body.style.setProperty("--scrollbar-width",`${c}px`)),document.body.style.overflow="hidden",Gn&&(it=S(document,"touchmove",w=>{w.target===document.documentElement&&(w.touches.length>1||w.preventDefault())},{passive:!1})),q(()=>{document.body.style.pointerEvents="none",document.body.style.overflow="hidden"})}),me(()=>()=>{it==null||it()}),{get lockMap(){return Ce},resetBodyStyle:n,scheduleCleanupIfNoNewLocks:e,cancelPendingCleanup:t,ensureInitialStyleCaptured:r}});var pt,ge,be,N;class Yi{constructor(t,e=()=>null){a(this,pt,qi());a(this,ge);a(this,be,()=>null);a(this,N);f(this,"locked");p(this,ge,t),p(this,be,e),p(this,N,ji.get()),s(this,N)&&(s(this,N).cancelPendingCleanup(),s(this,N).ensureInitialStyleCaptured(),s(this,N).lockMap.set(s(this,pt),s(this,ge)??!1),this.locked=y(()=>s(this,N).lockMap.get(s(this,pt))??!1,r=>s(this,N).lockMap.set(s(this,pt),r)),me(()=>{if(s(this,N).lockMap.delete(s(this,pt)),Ur(s(this,N).lockMap))return;const r=s(this,be).call(this);s(this,N).scheduleCleanupIfNoNewLocks(r,()=>{s(this,N).resetBodyStyle()})}))}}pt=new WeakMap,ge=new WeakMap,be=new WeakMap,N=new WeakMap;function Ur(n){for(const[t,e]of n)if(e)return!0;return!1}function lo(n,t){Ft(t,!0);let e=A(t,"preventScroll",3,!0),r=A(t,"restoreScrollDelay",3,null);e()&&new Yi(e(),()=>r()),Ot()}export{$e as C,vn as D,hr as E,ao as F,Zn as M,Ys as P,Tn as S,co as T,uo as a,oo as b,lo as c,io as d,xs as e,Xn as f,cr as g,Hn as h,so as i,jn as j,Yn as k,Jn as l,k as n,me as o,qi as u,D as w};