e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),on="eexxaacctt",ln=/\p{P}/gu,un=["en",{numeric:!0,sensitivity:"base"}],dn=(e,t,n)=>e.replace("A-Z",t).replace("a-z",n),cn={unicode:!1,alpha:null,interSplit:"[^A-Za-z\\d']+",intraSplit:"[a-z][A-Z]",interBound:"[^A-Za-z\\d]",intraBound:"[A-Za-z]\\d|\\d[A-Za-z]|[a-z][A-Z]",interLft:0,interRgt:0,interChars:".",interIns:an,intraChars:"[a-z\\d']",intraIns:null,intraContr:"'[a-z]{1,2}\\b",intraMode:0,intraSlice:[1,an],intraSub:null,intraTrn:null,intraDel:null,intraFilt:(e,t,n)=>!0,toUpper:e=>e.toLocaleUpperCase(),toLower:e=>e.toLocaleLowerCase(),compare:null,sort:(e,t,n,r=rn)=>{let{idx:a,chars:i,terms:s,interLft2:o,interLft1:l,start:u,intraIns:d,interIns:c,cases:h}=e;return a.map(((e,t)=>t)).sort(((e,n)=>i[n]-i[e]||d[e]-d[n]||s[n]+o[n]+.5*l[n]-(s[e]+o[e]+.5*l[e])||c[e]-c[n]||u[e]-u[n]||h[n]-h[e]||r(t[a[e]],t[a[n]])))}},hn=(e,t)=>0==t?"":1==t?e+"??":t==an?e+"*?":e+`{0,${t}}?`,mn="(?:\\b|_)";function pn(e){e=Object.assign({},cn,e);let{unicode:t,interLft:n,interRgt:r,intraMode:a,intraSlice:i,intraIns:s,intraSub:o,intraTrn:l,intraDel:u,intraContr:d,intraSplit:c,interSplit:h,intraBound:m,interBound:p,intraChars:f,toUpper:_,toLower:y,compare:g}=e;s??=a,o??=a,l??=a,u??=a,g??="undefined"==typeof Intl?rn:new Intl.Collator(...un).compare;let v=e.letters??e.alpha;if(null!=v){let e=_(v),t=y(v);h=dn(h,e,t),c=dn(c,e,t),p=dn(p,e,t),m=dn(m,e,t),f=dn(f,e,t),d=dn(d,e,t)}let b=t?"u":"";const M='".+?"',w=new RegExp(M,"gi"+b),L=new RegExp(`(?:\\s+|^)-(?:${f}+|${M})`,"gi"+b);let{intraRules:k}=e;null==k&&(k=e=>{let t=cn.intraSlice,n=0,r=0,a=0,d=0;if(/[^\d]/.test(e)){let c=e.length;c<=4?c>=3&&(a=Math.min(l,1),4==c&&(n=Math.min(s,1))):(t=i,n=s,r=o,a=l,d=u)}return{intraSlice:t,intraIns:n,intraSub:r,intraTrn:a,intraDel:d}});let S=!!c,D=new RegExp(c,"g"+b),Y=new RegExp(h,"g"+b),T=new RegExp("^"+h+"|"+h+"$","g"+b),x=new RegExp(d,"gi"+b);const O=(e,t=!1)=>{let n=[];e=(e=e.replace(w,(e=>(n.push(e),on)))).replace(T,""),t||(e=y(e)),S&&(e=e.replace(D,(e=>e[0]+" "+e[1])));let r=0;return e.split(Y).filter((e=>""!=e)).map((e=>e===on?n[r++]:e))},j=/[^\d]+|\d+/g,P=(t,i=0,o=!1)=>{let l=O(t);if(0==l.length)return[];let u,d=Array(l.length).fill("");if(l=l.map(((e,t)=>e.replace(x,(e=>(d[t]=e,""))))),1==a)u=l.map(((e,t)=>{if('"'===e[0])return sn(e.slice(1,-1));let n="";for(let r of e.matchAll(j)){let e=r[0],{intraSlice:a,intraIns:i,intraSub:s,intraTrn:o,intraDel:l}=k(e);if(i+s+o+l==0)n+=e+d[t];else{let[r,u]=a,c=e.slice(0,r),h=e.slice(u),m=e.slice(r,u);1==i&&1==c.length&&c!=m[0]&&(c+="(?!"+c+")");let p=m.length,_=[e];if(s)for(let e=0;e0&&(e=")("+e+")("),u=l.map(((t,n)=>'"'===t[0]?sn(t.slice(1,-1)):t.split("").map(((e,t,n)=>(1==s&&0==t&&n.length>1&&e!=n[t+1]&&(e+="(?!"+e+")"),e))).join(e)+d[n]))}let c=2==n?mn:"",h=2==r?mn:"",m=h+hn(e.interChars,e.interIns)+c;return i>0?o?u=c+"("+u.join(")"+h+"|"+c+"(")+")"+h:(u="("+u.join(")("+m+")(")+")",u="(.??"+c+")"+u+"("+h+".*)"):(u=u.join(m),u=c+u+h),[new RegExp(u,"i"+b),l,d]},E=(e,t,n)=>{let[r]=P(t);if(null==r)return null;let a=[];if(null!=n)for(let t=0;t{let[s,o,l]=P(i,1),u=O(i,!0),[d]=P(i,2),c=o.length,h=Array(c),m=Array(c);for(let e=0;e=_){let e=y(l[a+1]).indexOf(s);e>-1&&(O.push(p,v,e,_),p+=I(l,a,e,_),i=s,v=_,j=!0,0==t&&(u=p))}if(g||j){let e=p-1,d=p+v,c=!1,h=!1;if(-1==e||H.test(o[e]))j&&M++,c=!0;else{if(2==n){f=!0;break}if(C&&R.test(o[e]+o[e+1]))j&&w++,c=!0;else if(1==n){let e=l[a+1],n=p+v;if(e.length>=_){let r,d=0,h=!1,m=new RegExp(s,"ig"+b);for(;r=m.exec(e);){d=r.index;let e=n+d,t=e-1;if(-1==t||H.test(o[t])){M++,h=!0;break}if(R.test(o[t]+o[e])){w++,h=!0;break}}h&&(c=!0,O.push(p,v,d,_),p+=I(l,a,d,_),i=s,v=_,j=!0,0==t&&(u=p))}if(!c){f=!0;break}}}if(d==o.length||H.test(o[d]))j&&L++,h=!0;else{if(2==r){f=!0;break}if(C&&R.test(o[d-1]+o[d]))j&&k++,h=!0;else if(1==r){f=!0;break}}j&&(S+=_,c&&h&&D++)}if(v>_&&(x+=v-_),t>0&&(T+=l[a-1].length),!e.intraFilt(s,i,p)){f=!0;break}t0?0:1/0,s=r-4;for(let t=2;t0&&(l.push(c,h),c=h=n)}h>c&&l.push(c,h),v++}}if(v{let a=e[t]+e[t+1].slice(0,n);return e[t-1]+=a,e[t]=e[t+1].slice(n,n+r),e[t+1]=e[t+1].slice(n+r),a.length};return{search:(...t)=>{let n=((t,n,r,a=1e3,i)=>{r=r?!0===r?5:r:0;let s=null,o=null,l=[];n=n.replace(L,(e=>{let t=e.trim().slice(1);return t='"'===t[0]?sn(t.slice(1,-1)):t.replace(ln,""),""!=t&&l.push(t),""}));let u,d=O(n);if(l.length>0){if(u=new RegExp(l.join("|"),"i"+b),0==d.length){let e=[];for(let n=0;n0){let e=O(n);if(e.length>1){let n=e.slice().sort(((e,t)=>t.length-e.length));for(let e=0;er)return[i,null,null];s=_n(e).map((e=>e.join(" "))),o=[];let a=new Set;for(let e=0;e!a.has(e))),r=E(t,s[e],n);for(let e=0;e0?i:E(t,n)]);let c=null,h=null;if(l.length>0&&(o=o.map((e=>e.filter((e=>!u.test(t[e])))))),o.reduce(((e,t)=>e+t.length),0)<=a){c={},h=[];for(let n=0;n0)for(let e=0;e{let e={A:"ÁÀÃÂÄĄ",a:"áàãâäą",E:"ÉÈÊËĖ",e:"éèêëę",I:"ÍÌÎÏĮ",i:"íìîïį",O:"ÓÒÔÕÖ",o:"óòôõö",U:"ÚÙÛÜŪŲ",u:"úùûüūų",C:"ÇČĆ",c:"çčć",L:"Ł",l:"ł",N:"ÑŃ",n:"ñń",S:"ŠŚ",s:"šś",Z:"ŻŹ",z:"żź"},t=new Map,n="";for(let r in e)e[r].split("").forEach((e=>{n+=e,t.set(e,r)}));let r=new RegExp(`[${n}]`,"g"),a=e=>t.get(e);return e=>{if("string"==typeof e)return e.replace(r,a);let t=Array(e.length);for(let n=0;nt?`${e}`:e,gn=(e,t)=>e+t;pn.latinize=fn,pn.permute=e=>_n([...Array(e.length).keys()]).sort(((e,t)=>{for(let n=0;nt.map((t=>e[t])))),pn.highlight=function(e,t,n=yn,r="",a=gn){r=a(r,n(e.substring(0,t[0]),!1))??r;for(let i=0;i25||Mn.split(n).length>5)for(let a=0;ae[i.idx[t]])):a.map((t=>e[t])))}return r}function Ln(e,t=!1){let n=e;t&&(n=[{value:et,label:Xe},...n]);const r=n.map((e=>e.label));return e=>wn(n,r,e)}var kn=Object.defineProperty,Sn=Object.defineProperties,Dn=Object.getOwnPropertyDescriptors,Yn=Object.getOwnPropertySymbols,Tn=Object.prototype.hasOwnProperty,xn=Object.prototype.propertyIsEnumerable,On=(e,t,n)=>t in e?kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;const jn=()=>!0,Pn=e=>"$__all"!==e.value,En=(e,t)=>e.length===t.filter(Pn).length?Xt.ToggleAllState.allSelected:0===e.length||1===e.length&&e[0]&&"$__all"===e[0].value?Xt.ToggleAllState.noneSelected:Xt.ToggleAllState.indeterminate;function Cn({model:e}){const{value:t,text:n,key:r,options:a,includeAll:i,isReadOnly:s,allowCustomValue:o=!0}=e.useState(),[l,u]=(0,w.useState)(""),[d,c]=(0,w.useState)(!1),h=function(e,t){return{value:e,label:null!=t?t:String(e)}}(t,String(n)),m=Lu.getQueryController(e),p=(0,w.useMemo)((()=>Ln(a,i)),[a,i])(l);return k().createElement(Xt.Select,{id:r,isValidNewOption:e=>e.trim().length>0,placeholder:"Select value",width:"auto",disabled:s,value:h,inputValue:l,allowCustomValue:o,virtualized:!0,filterOption:jn,tabSelectsValue:!1,onInputChange:(t,{action:n})=>"input-change"===n?(u(t),e.onSearchChange&&e.onSearchChange(t),t):t,onOpenMenu:()=>{d&&u(String(n))},onCloseMenu:()=>{u("")},options:p,"data-testid":tn.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${t}`),onChange:t=>{e.changeValueTo(t.value,t.label,!0),null==m||m.startProfile("VariableValueSelect"),d!==t.__isNew__&&c(t.__isNew__)}})}function Hn({model:e}){const{value:t,options:n,key:r,maxVisibleValues:a,noValueOnClear:i,includeAll:s,isReadOnly:o,allowCustomValue:l=!0}=e.useState(),u=(0,w.useMemo)((()=>(0,te.isArray)(t)?t:[t]),[t]),[d,c]=(0,w.useState)(u),[h,m]=(0,w.useState)(""),p=Lu.getQueryController(e),f=(0,w.useMemo)((()=>Ln(n,s)),[n,s]);(0,w.useEffect)((()=>{c(u)}),[u]);const _=n.length>0?"Select value":"",y=f(h);return k().createElement(Xt.MultiSelect,{id:r,placeholder:_,width:"auto",inputValue:h,disabled:o,value:d,noMultiValueWrap:!0,maxVisibleValues:null!=a?a:5,tabSelectsValue:!1,virtualized:!0,allowCustomValue:l,toggleAllOptions:{enabled:!0,optionsFilter:Pn,determineToggleAllState:En},options:y,closeMenuOnSelect:!1,components:{Option:Rn},isClearable:!0,hideSelectedOptions:!1,onInputChange:(t,{action:n})=>"input-change"===n?(m(t),e.onSearchChange&&e.onSearchChange(t),t):"input-blur"===n?(m(""),""):h,onBlur:()=>{e.changeValueTo(d,void 0,!0),null==p||p.startProfile("VariableValueSelectMulti")},filterOption:jn,"data-testid":tn.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${d}`),onChange:(t,n)=>{"clear"===n.action&&i&&e.changeValueTo([],void 0,!0),c(t.map((e=>e.value)))}})}const Rn=({children:e,data:t,innerProps:n,innerRef:r,isFocused:a,isSelected:i,indeterminate:s,renderOptionLabel:o})=>{var l;const u=((e,t)=>{var n={};for(var r in e)Tn.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&Yn)for(var r of Yn(e))t.indexOf(r)<0&&xn.call(e,r)&&(n[r]=e[r]);return n})(n,["onMouseMove","onMouseOver"]),d=(0,Xt.useTheme2)(),c=(0,Xt.getSelectStyles)(d),h=(0,Xt.useStyles2)(An);return k().createElement("div",(m=((e,t)=>{for(var n in t||(t={}))Tn.call(t,n)&&On(e,n,t[n]);if(Yn)for(var n of Yn(t))xn.call(t,n)&&On(e,n,t[n]);return e})({ref:r,className:(0,nn.cx)(c.option,a&&c.optionFocused)},u),p={"data-testid":"data-testid Select option",title:t.title},Sn(m,Dn(p))),k().createElement("div",{className:h.checkbox},k().createElement(Xt.Checkbox,{indeterminate:s,value:i})),k().createElement("div",{className:c.optionBody,"data-testid":tn.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts(null!=(l=t.label)?l:String(t.value))},k().createElement("span",null,e)));var m,p};Rn.displayName="SelectMenuOptions";const An=e=>({checkbox:(0,nn.css)({marginRight:e.spacing(2)})});function In(e){return e.state.isMulti?k().createElement(Hn,{model:e}):k().createElement(Cn,{model:e})}class Fn{constructor(e){this._sceneObject=e}getKey(){return`var-${this._sceneObject.state.name}`}getKeys(){return this._sceneObject.state.skipUrlSync?[]:[this.getKey()]}getUrlState(){return this._sceneObject.state.skipUrlSync?{}:{[this.getKey()]:(e=this._sceneObject.state.value,t=this._sceneObject.state.text,e=Array.isArray(e)?e:[e],t=Array.isArray(t)?t:[t],e.map(((e,n)=>{if(null==e)return"";e=String(e);let r=t[n];return r=null==r?e:String(r),Ol(e,r)})))};var e,t}updateFromUrl(e){let t=e[this.getKey()];if(null!=t){this._sceneObject.isActive||(this._sceneObject.skipNextValidation=!0);const{values:e,texts:r}=(n=t,(n=Array.isArray(n)?n:[n]).reduce(((e,t)=>{const[n,r]=(null!=t?t:"").split(",");return e.values.push(xl(n)),e.texts.push(xl(null!=r?r:n)),e}),{values:[],texts:[]}));this._sceneObject.changeValueTo(e,r)}var n}}function Nn(e){const t=e.getRoot();return"enrichFiltersRequest"in t?t.enrichFiltersRequest(e):null}var Wn,zn=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};class Vn{constructor(e){((e,t)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,void 0)})(this,Wn),this.text="__sceneObject",this.valueOf=()=>{return zn(this,e=Wn,"read from private field"),e.get(this);var e},((e,t,n)=>{zn(e,t,"write to private field"),t.set(e,n)})(this,Wn,e)}toString(){}get value(){return this}}function Bn(e){return function(e){const t=e.match(/^(\d+)\.(\d+)\.(\d+)/);if(!t)return!1;const n=parseInt(t[1],10),r=parseInt(t[2],10),a=parseInt(t[3],10);return 11===n?0===r&&a>=4||1===r&&a>=2||r>1:10===n?4===r&&a>=8||r>=5:n>11}(s.config.buildInfo.version)?new Vn(e):{value:e,text:"__sceneObject"}}Wn=new WeakMap;var Un=Object.defineProperty,$n=Object.defineProperties,qn=Object.getOwnPropertyDescriptors,Gn=Object.getOwnPropertySymbols,Zn=Object.prototype.hasOwnProperty,Jn=Object.prototype.propertyIsEnumerable,Qn=(e,t,n)=>t in e?Un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Kn=(e,t)=>{for(var n in t||(t={}))Zn.call(t,n)&&Qn(e,n,t[n]);if(Gn)for(var n of Gn(t))Jn.call(t,n)&&Qn(e,n,t[n]);return e};class Xn extends lt{constructor(e){var t;super((t=Kn({isMulti:!0,name:"",value:[],text:[],options:[],datasource:null,baseFilters:[],applyMode:"auto",layout:"horizontal",type:"groupby"},e),$n(t,qn({noValueOnClear:!0})))),this.isLazy=!0,this._urlSync=new Fn(this),this._getKeys=async e=>{var t,n,r,a;const i=await(null==(n=(t=this.state).getTagKeysProvider)?void 0:n.call(t,this,null));if(i&&i.replace)return i.values;if(this.state.defaultOptions)return this.state.defaultOptions.concat(jl(null!=(r=null==i?void 0:i.values)?r:[]));if(!e.getTagKeys)return[];const s=Sl(this),o=this.state.baseFilters||[],l=Lu.getTimeRange(this).state.value,u=await e.getTagKeys(Kn({filters:o,queries:s,timeRange:l,scopes:null==(a=this._scopesBridge)?void 0:a.getValue()},Nn(this)));Pl(u)&&this.setState({error:u.error.message});let d=jl(u);i&&(d=d.concat(jl(i.values)));const c=this.state.tagKeyRegexFilter;return c&&(d=d.filter((e=>e.text.match(c)))),d},"auto"===this.state.applyMode&&this.addActivationHandler((()=>(Kt.add(this),()=>Kt.delete(this))))}validateAndUpdate(){return this.getValueOptions({}).pipe((0,S.map)((e=>(this._updateValueGivenNewOptions(e),{}))))}_updateValueGivenNewOptions(e){const{value:t,text:n}=this.state,r={options:e,loading:!1,value:null!=t?t:[],text:null!=n?n:[]};this.setState(r)}getValueOptions(e){return this.state.defaultOptions?(0,S.of)(this.state.defaultOptions.map((e=>({label:e.text,value:String(e.value),group:e.group})))):(this.setState({loading:!0,error:null}),(0,S.from)(Tt(this.state.datasource,{__sceneObject:Bn(this)})).pipe((0,S.mergeMap)((e=>(0,S.from)(this._getKeys(e)).pipe((0,S.tap)((e=>{Pl(e)&&this.setState({error:e.error.message})})),(0,S.map)((e=>jl(e))),(0,S.take)(1),(0,S.mergeMap)((e=>{const t=e.map((e=>({label:e.text,value:e.value?String(e.value):e.text,group:e.group})));return(0,S.of)(t)})))))))}getDefaultMultiState(e){return{value:[],text:[]}}}Xn.Component=function({model:e}){const{value:t,text:n,key:r,isMulti:a=!0,maxVisibleValues:i,noValueOnClear:s,options:o,includeAll:l,allowCustomValue:u=!0}=e.useState(),d=(0,w.useMemo)((()=>{const e=(0,te.isArray)(t)?t:[t],r=(0,te.isArray)(n)?n:[n];return e.map(((e,t)=>{var n;return{value:e,label:String(null!=(n=r[t])?n:e)}}))}),[t,n]),[c,h]=(0,w.useState)(!1),[m,p]=(0,w.useState)(!1),[f,_]=(0,w.useState)(""),[y,g]=(0,w.useState)(d),v=(0,w.useMemo)((()=>Ln(o,l)),[o,l]);(0,w.useEffect)((()=>{g(d)}),[d]);const b=(t,{action:n})=>"input-change"===n?(_(t),e.onSearchChange&&e.onSearchChange(t),t):"input-blur"===n?(_(""),""):f,M=(0,w.useMemo)((()=>El(v(f).map(tr))),[v,f]);return a?k().createElement(Xt.MultiSelect,{"aria-label":"Group by selector","data-testid":`GroupBySelect-${r}`,id:r,placeholder:"Select value",width:"auto",allowCustomValue:u,inputValue:f,value:y,noMultiValueWrap:!0,maxVisibleValues:null!=i?i:5,tabSelectsValue:!1,virtualized:!0,options:M,filterOption:er,closeMenuOnSelect:!1,isOpen:m,isClearable:!0,hideSelectedOptions:!1,isLoading:c,components:{Option:Rn},onInputChange:b,onBlur:()=>{e.changeValueTo(y.map((e=>e.value)),y.map((e=>e.label)),!0)},onChange:(t,n)=>{"clear"===n.action&&s&&e.changeValueTo([],void 0,!0),g(t)},onOpenMenu:async()=>{h(!0),await(0,S.lastValueFrom)(e.validateAndUpdate()),h(!1),p(!0)},onCloseMenu:()=>{p(!1)}}):k().createElement(Xt.Select,{"aria-label":"Group by selector","data-testid":`GroupBySelect-${r}`,id:r,placeholder:"Select value",width:"auto",inputValue:f,value:y,allowCustomValue:u,noMultiValueWrap:!0,maxVisibleValues:null!=i?i:5,tabSelectsValue:!1,virtualized:!0,options:M,filterOption:er,closeMenuOnSelect:!0,isOpen:m,isClearable:!0,hideSelectedOptions:!1,noValueOnClear:!0,isLoading:c,onInputChange:b,onChange:(t,n)=>{if("clear"===n.action)return g([]),void(s&&e.changeValueTo([]));(null==t?void 0:t.value)&&(g([t]),e.changeValueTo([t.value],t.label?[t.label]:void 0))},onOpenMenu:async()=>{h(!0),await(0,S.lastValueFrom)(e.validateAndUpdate()),h(!1),p(!0)},onCloseMenu:()=>{p(!1)}})};const er=()=>!0;function tr(e){const{label:t,value:n,group:r}=e,a={label:t,value:n};return r&&(a.group=r),a}function nr(e){return k().createElement(Xt.Tooltip,{content:"Cancel query"},k().createElement(Xt.Icon,{className:"spin-clockwise",name:"sync",size:"xs",role:"button",onMouseDown:t=>{e.onCancel(t)}}))}function rr(e){const t=(0,Xt.useStyles2)(ar),n=(0,Xt.useTheme2)(),r="vertical"===e.layout,a=Boolean(e.isLoading)?k().createElement("div",{style:{marginLeft:n.spacing(1),marginTop:"-1px"},"aria-label":tn.components.LoadingIndicator.icon},k().createElement(nr,{onCancel:t=>{var n;t.preventDefault(),t.stopPropagation(),null==(n=e.onCancel)||n.call(e)}})):null;let i=null;e.error&&(i=k().createElement(Xt.Tooltip,{content:e.error,placement:"bottom"},k().createElement(Xt.Icon,{className:t.errorIcon,name:"exclamation-triangle"})));let s=null;e.description&&(s=k().createElement(Xt.Tooltip,{content:e.description,placement:r?"top":"bottom"},k().createElement(Xt.Icon,{className:t.normalIcon,name:"info-circle"})));const o="string"==typeof e.label?tn.pages.Dashboard.SubMenu.submenuItemLabels(e.label):"";let l;return l=r?k().createElement("label",{className:t.verticalLabel,"data-testid":o,htmlFor:e.htmlFor},e.label,s,i,e.icon&&k().createElement(Xt.Icon,{name:e.icon,className:t.normalIcon}),a,e.onRemove&&k().createElement(Xt.IconButton,{variant:"secondary",size:"xs",name:"times",onClick:e.onRemove,tooltip:"Remove"})):k().createElement("label",{className:t.horizontalLabel,"data-testid":o,htmlFor:e.htmlFor},i,e.icon&&k().createElement(Xt.Icon,{name:e.icon,className:t.normalIcon}),e.label,s,a),l}const ar=e=>({horizontalLabel:(0,nn.css)({background:e.isDark?e.colors.background.primary:e.colors.background.secondary,display:"flex",alignItems:"center",padding:e.spacing(0,1),fontWeight:e.typography.fontWeightMedium,fontSize:e.typography.bodySmall.fontSize,height:e.spacing(e.components.height.md),lineHeight:e.spacing(e.components.height.md),borderRadius:`${e.shape.radius.default} 0 0 ${e.shape.radius.default}`,border:`1px solid ${e.components.input.borderColor}`,position:"relative",right:-1,whiteSpace:"nowrap",gap:e.spacing(.5)}),verticalLabel:(0,nn.css)({display:"flex",alignItems:"center",fontWeight:e.typography.fontWeightMedium,fontSize:e.typography.bodySmall.fontSize,lineHeight:e.typography.bodySmall.lineHeight,whiteSpace:"nowrap",marginBottom:e.spacing(.5),gap:e.spacing(1)}),errorIcon:(0,nn.css)({color:e.colors.error.text}),normalIcon:(0,nn.css)({color:e.colors.text.secondary})});function ir(e){const t=e.map((e=>{var t;return null!=(t=e.label)?t:String(e.value)}));return n=>wn(e,t,n)}var sr=Object.defineProperty,or=Object.getOwnPropertySymbols,lr=Object.prototype.hasOwnProperty,ur=Object.prototype.propertyIsEnumerable,dr=(e,t,n)=>t in e?sr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function cr(e,t){return""!==e?{value:e,label:t||e}:null}const hr=()=>!0;function mr({filter:e,model:t}){var n,r,a,i,s;const o=(0,Xt.useStyles2)(pr),[l,u]=(0,w.useState)([]),[d,c]=(0,w.useState)([]),[h,m]=(0,w.useState)(!1),[p,f]=(0,w.useState)(!1),[_,y]=(0,w.useState)(!1),[g,v]=(0,w.useState)(!1),[b,M]=(0,w.useState)(!1),[L,S]=(0,w.useState)(""),[D,Y]=(0,w.useState)(!1),[T,x]=(0,w.useState)(e.values?e.values.map(((t,n)=>{var r;return cr(t,null==(r=e.valueLabels)?void 0:r[n])})):[]),O=rl(e.operator),j=cr(e.key,e.keyLabel),P=cr(e.value,null==(n=e.valueLabels)?void 0:n[0]),E=(0,w.useMemo)((()=>ir(d)),[d]),C=t.state.onAddCustomValue,H=(0,w.useMemo)((()=>El(E(L))),[E,L]),R={isMulti:!0,value:T,components:{Option:Rn},hideSelectedOptions:!1,closeMenuOnSelect:!1,openMenuOnFocus:!1,onChange:e=>{x(e),e.some((e=>e.__isNew__))&&S("")},onBlur:()=>{var n,r;t._updateFilter(e,{value:null!=(r=null==(n=T[0])?void 0:n.value)?r:"",values:T.map((e=>e.value)),valueLabels:T.map((e=>e.label))})}},A=k().createElement(Xt.Select,((e,t)=>{for(var n in t||(t={}))lr.call(t,n)&&dr(e,n,t[n]);if(or)for(var n of or(t))ur.call(t,n)&&dr(e,n,t[n]);return e})({virtualized:!0,allowCustomValue:null==(r=t.state.allowCustomValue)||r,isValidNewOption:e=>e.trim().length>0,allowCreateWhileLoading:!0,formatCreateLabel:e=>`Use custom value: ${e}`,disabled:t.state.readOnly,className:(0,nn.cx)(o.value,g?o.widthWhenOpen:void 0),width:"auto",value:P,filterOption:hr,placeholder:"Select value",options:H,inputValue:L,onInputChange:(e,{action:t})=>("input-change"===t&&S(e),e),onChange:n=>{C&&n.__isNew__?t._updateFilter(e,C(n,e)):t._updateFilter(e,{value:n.value,valueLabels:n.label?[n.label]:[n.value]}),D!==n.__isNew__&&Y(n.__isNew__)},isOpen:g&&!p,isLoading:p,openMenuOnFocus:!0,onOpenMenu:async()=>{var n;f(!0),v(!0);const r=await t._getValuesFor(e);f(!1),c(r),D&&S(null!=(n=null==P?void 0:P.label)?n:"")},onCloseMenu:()=>{v(!1),S("")}},O&&R)),I=k().createElement(Xt.Select,{key:p?"loading":"loaded",disabled:t.state.readOnly,className:(0,nn.cx)(o.key,_?o.widthWhenOpen:void 0),width:"auto",allowCustomValue:null==(a=t.state.allowCustomValue)||a,value:j,placeholder:"Select label",options:El(l),onChange:n=>{t._updateFilter(e,{key:n.value,keyLabel:n.label,value:"",valueLabels:[""],values:void 0}),x([])},autoFocus:""===e.key,isOpen:_&&!h,isLoading:h,onOpenMenu:async()=>{y(!0),m(!0);const n=await t._getKeys(e.key);m(!1),u(n)},onCloseMenu:()=>{y(!1)},onBlur:()=>{""===e.key&&t._removeFilter(e)},openMenuOnFocus:!0}),F=k().createElement(Xt.Select,{className:(0,nn.cx)(o.operator,{[o.widthWhenOpen]:b}),value:e.operator,disabled:t.state.readOnly,options:t._getOperators(),onChange:n=>{var r,a;const i=e.operator,s=n.value,o={operator:s};rl(i)&&!rl(s)?(o.value="",o.valueLabels=[""],o.values=void 0,x([])):!rl(i)&&rl(s)&&e.value&&(o.values=[e.value],x([{value:e.value,label:null!=(a=null==(r=e.valueLabels)?void 0:r[0])?a:e.value}])),t._updateFilter(e,o)},onOpenMenu:()=>{M(!0)},onCloseMenu:()=>{M(!1)}});if("vertical"===t.state.layout){if(e.key){const n=k().createElement(rr,{layout:"vertical",label:null!=(i=e.key)?i:"",onRemove:()=>t._removeFilter(e)});return k().createElement(Xt.Field,{label:n,"data-testid":`AdHocFilter-${e.key}`,className:o.field},k().createElement("div",{className:o.wrapper},F,A))}return k().createElement(Xt.Field,{label:"Select label","data-testid":`AdHocFilter-${e.key}`,className:o.field},I)}return k().createElement("div",{className:o.wrapper,"data-testid":`AdHocFilter-${e.key}`},I,F,A,k().createElement(Xt.Button,{variant:"secondary","aria-label":"Remove filter",title:"Remove filter",className:o.removeButton,icon:"times","data-testid":`AdHocFilter-remove-${null!=(s=e.key)?s:""}`,onClick:()=>t._removeFilter(e)}))}const pr=e=>({field:(0,nn.css)({marginBottom:0}),wrapper:(0,nn.css)({display:"flex","> *":{"&:not(:first-child)":{marginLeft:-1},"&:first-child":{borderTopRightRadius:0,borderBottomRightRadius:0},"&:last-child":{borderTopLeftRadius:0,borderBottomLeftRadius:0},"&:not(:first-child):not(:last-child)":{borderRadius:0},position:"relative",zIndex:0,"&:hover":{zIndex:1},"&:focus-within":{zIndex:2}}}),widthWhenOpen:(0,nn.css)({minWidth:e.spacing(16)}),value:(0,nn.css)({flexBasis:"content",flexShrink:1,minWidth:"90px"}),key:(0,nn.css)({flexBasis:"content",minWidth:"90px",flexShrink:1}),operator:(0,nn.css)({flexShrink:0,flexBasis:"content"}),removeButton:(0,nn.css)({paddingLeft:e.spacing(1.5),paddingRight:e.spacing(1.5),borderLeft:"none",width:e.spacing(3),marginRight:e.spacing(1),boxSizing:"border-box",position:"relative",left:"1px"})});function fr({model:e,addFilterButtonText:t}){const{_wip:n}=e.useState();return n?k().createElement(mr,{filter:n,model:e}):k().createElement(Xt.Button,{variant:"secondary",icon:"plus",title:"Add filter","aria-label":"Add filter","data-testid":"AdHocFilter-add",onClick:()=>e._addWip()},t)}class _r{constructor(e){this._variable=e}getKey(){return`var-${this._variable.state.name}`}getKeys(){return[this.getKey()]}getUrlState(){const e=this._variable.state.filters,t=this._variable.state.baseFilters;let n=[];return 0===e.length&&0===(null==t?void 0:t.length)?{[this.getKey()]:[""]}:(e.length&&n.push(...e.filter(nl).filter((e=>!e.hidden)).map((e=>yr(e).map(Dl).join("|")))),(null==t?void 0:t.length)&&n.push(...null==t?void 0:t.filter(nl).filter((e=>!e.hidden&&e.origin&&e.originalValue)).map((e=>{var t,n;return yr(e).map(Tl).join("|").concat(`#${null!=(n=null==(t=e.originalValue)?void 0:t.map(Tl).join("|"))?n:""}#${e.origin}`)}))),{[this.getKey()]:n.length?n:[""]})}updateFromUrl(e){const t=e[this.getKey()];if(null!=t&&t){const e=function(e){if(Array.isArray(e))return e.map(gr).filter(vr);const t=gr(e);return null===t?[]:[t]}(t);this._variable.setState({filters:e.filter((e=>!e.origin)),baseFilters:e.filter((e=>e.origin))})}}}function yr(e){var t;const n=[Ol(e.key,e.keyLabel),e.operator];return rl(e.operator)?e.values.forEach(((t,r)=>{var a;n.push(Ol(t,null==(a=e.valueLabels)?void 0:a[r]))})):n.push(Ol(e.value,null==(t=e.valueLabels)?void 0:t[0])),n}function gr(e){var t;if("string"!=typeof e||0===e.length)return null;const[n,r,a]=e.split("#"),[i,s,o,l,...u]=n.split("|").reduce(((e,t)=>{const[n,r]=t.split(",");return e.push(n,null!=r?r:n),e}),[]).map(xl);return{key:i,keyLabel:s,operator:o,value:u[0],values:rl(o)?u.filter(((e,t)=>t%2==0)):void 0,valueLabels:u.filter(((e,t)=>t%2==1)),condition:"",origin:(d=a,d===Jo.Scopes||d===Jo.Dashboards?a:void 0),originalValue:r&&r.length?null!=(t=r.split("|"))?t:[r]:void 0};var d}function vr(e){return null!==e&&"string"==typeof e.key&&"string"==typeof e.value}function br(){return"undefined"!=typeof window}function Mr(e){return kr(e)?(e.nodeName||"").toLowerCase():"#document"}function wr(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Lr(e){var t;return null==(t=(kr(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function kr(e){return!!br()&&(e instanceof Node||e instanceof wr(e).Node)}function Sr(e){return!!br()&&(e instanceof Element||e instanceof wr(e).Element)}function Dr(e){return!!br()&&(e instanceof HTMLElement||e instanceof wr(e).HTMLElement)}function Yr(e){return!(!br()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof wr(e).ShadowRoot)}function Tr(e){const{overflow:t,overflowX:n,overflowY:r,display:a}=Cr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(a)}function xr(e){return["table","td","th"].includes(Mr(e))}function Or(e){return[":popover-open",":modal"].some((t=>{try{return e.matches(t)}catch(e){return!1}}))}function jr(e){const t=Pr(),n=Sr(e)?Cr(e):e;return["transform","translate","scale","rotate","perspective"].some((e=>!!n[e]&&"none"!==n[e]))||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||["transform","translate","scale","rotate","perspective","filter"].some((e=>(n.willChange||"").includes(e)))||["paint","layout","strict","content"].some((e=>(n.contain||"").includes(e)))}function Pr(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function Er(e){return["html","body","#document"].includes(Mr(e))}function Cr(e){return wr(e).getComputedStyle(e)}function Hr(e){return Sr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Rr(e){if("html"===Mr(e))return e;const t=e.assignedSlot||e.parentNode||Yr(e)&&e.host||Lr(e);return Yr(t)?t.host:t}function Ar(e){const t=Rr(e);return Er(t)?e.ownerDocument?e.ownerDocument.body:e.body:Dr(t)&&Tr(t)?t:Ar(t)}function Ir(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const a=Ar(e),i=a===(null==(r=e.ownerDocument)?void 0:r.body),s=wr(a);if(i){const e=Fr(s);return t.concat(s,s.visualViewport||[],Tr(a)?a:[],e&&n?Ir(e):[])}return t.concat(a,Ir(a,[],n))}function Fr(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Nr(e){let t=e.activeElement;for(;null!=(null==(n=t)||null==(n=n.shadowRoot)?void 0:n.activeElement);){var n;t=t.shadowRoot.activeElement}return t}function Wr(e,t){if(!e||!t)return!1;const n=null==t.getRootNode?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&Yr(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function zr(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}function Vr(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map((e=>{let{brand:t,version:n}=e;return t+"/"+n})).join(" "):navigator.userAgent}function Br(e){return!(0!==e.mozInputSource||!e.isTrusted)||(qr()&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType)}function Ur(e){return!Vr().includes("jsdom/")&&(!qr()&&0===e.width&&0===e.height||qr()&&1===e.width&&1===e.height&&0===e.pressure&&0===e.detail&&"mouse"===e.pointerType||e.width<1&&e.height<1&&0===e.pressure&&0===e.detail&&"touch"===e.pointerType)}function $r(){return/apple/i.test(navigator.vendor)}function qr(){const e=/android/i;return e.test(zr())||e.test(Vr())}function Gr(e){return(null==e?void 0:e.ownerDocument)||document}function Zr(e,t){if(null==t)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return null!=n.target&&t.contains(n.target)}function Jr(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Qr(e){e.preventDefault(),e.stopPropagation()}function Kr(e){return!!e&&"combobox"===e.getAttribute("role")&&function(e){return Dr(e)&&e.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}(e)}const Xr=Math.min,ea=Math.max,ta=Math.round,na=Math.floor,ra=e=>({x:e,y:e}),aa={left:"right",right:"left",bottom:"top",top:"bottom"},ia={start:"end",end:"start"};function sa(e,t){return"function"==typeof e?e(t):e}function oa(e){return e.split("-")[0]}function la(e){return e.split("-")[1]}function ua(e){return"y"===e?"height":"width"}function da(e){return["top","bottom"].includes(oa(e))?"y":"x"}function ca(e){return"x"===da(e)?"y":"x"}function ha(e){return e.replace(/start|end/g,(e=>ia[e]))}function ma(e){return e.replace(/left|right|bottom|top/g,(e=>aa[e]))}function pa(e){const{x:t,y:n,width:r,height:a}=e;return{width:r,height:a,top:n,left:t,right:t+r,bottom:n+a,x:t,y:n}}var fa=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"].join(","),_a="undefined"==typeof Element,ya=_a?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,ga=!_a&&Element.prototype.getRootNode?function(e){var t;return null==e||null===(t=e.getRootNode)||void 0===t?void 0:t.call(e)}:function(e){return null==e?void 0:e.ownerDocument},va=function e(t,n){var r;void 0===n&&(n=!0);var a=null==t||null===(r=t.getAttribute)||void 0===r?void 0:r.call(t,"inert");return""===a||"true"===a||n&&t&&e(t.parentNode)},ba=function e(t,n,r){for(var a=[],i=Array.from(t);i.length;){var s=i.shift();if(!va(s,!1))if("SLOT"===s.tagName){var o=s.assignedElements(),l=e(o.length?o:s.children,!0,r);r.flatten?a.push.apply(a,l):a.push({scopeParent:s,candidates:l})}else{ya.call(s,fa)&&r.filter(s)&&(n||!t.includes(s))&&a.push(s);var u=s.shadowRoot||"function"==typeof r.getShadowRoot&&r.getShadowRoot(s),d=!va(u,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(s));if(u&&d){var c=e(!0===u?s.children:u.children,!0,r);r.flatten?a.push.apply(a,c):a.push({scopeParent:s,candidates:c})}else i.unshift.apply(i,s.children)}}return a},Ma=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},wa=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||function(e){var t,n=null==e||null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return""===n||"true"===n}(e))&&!Ma(e)?0:e.tabIndex},La=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},ka=function(e){return"INPUT"===e.tagName},Sa=function(e){var t=e.getBoundingClientRect(),n=t.width,r=t.height;return 0===n&&0===r},Da=function(e,t){return!(t.disabled||va(t)||function(e){return ka(e)&&"hidden"===e.type}(t)||function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var a=ya.call(e,"details>summary:first-of-type")?e.parentElement:e;if(ya.call(a,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return Sa(e)}else{if("function"==typeof r){for(var i=e;e;){var s=e.parentElement,o=ga(e);if(s&&!s.shadowRoot&&!0===r(s))return Sa(e);e=e.assignedSlot?e.assignedSlot:s||o===e.ownerDocument?s:o.host}e=i}if(function(e){var t,n,r,a,i=e&&ga(e),s=null===(t=i)||void 0===t?void 0:t.host,o=!1;if(i&&i!==e)for(o=!!(null!==(n=s)&&void 0!==n&&null!==(r=n.ownerDocument)&&void 0!==r&&r.contains(s)||null!=e&&null!==(a=e.ownerDocument)&&void 0!==a&&a.contains(e));!o&&s;){var l,u,d;o=!(null===(u=s=null===(l=i=ga(s))||void 0===l?void 0:l.host)||void 0===u||null===(d=u.ownerDocument)||void 0===d||!d.contains(s))}return o}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1}(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n=0)},xa=function e(t){var n=[],r=[];return t.forEach((function(t,a){var i=!!t.scopeParent,s=i?t.scopeParent:t,o=function(e,t){var n=wa(e);return n<0&&t&&!Ma(e)?0:n}(s,i),l=i?e(t.candidates):s;0===o?i?n.push.apply(n,l):n.push(s):r.push({documentOrder:a,tabIndex:o,item:t,isScope:i,content:l})})),r.sort(La).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)},Oa=function(e,t){var n;return n=(t=t||{}).getShadowRoot?ba([e],t.includeContainer,{filter:Ya.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:Ta}):function(e,t,n){if(va(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(fa));return t&&ya.call(e,fa)&&r.unshift(e),r.filter(n)}(e,t.includeContainer,Ya.bind(null,t)),xa(n)},ja=n(8398);function Pa(e,t,n){let{reference:r,floating:a}=e;const i=da(t),s=ca(t),o=ua(s),l=oa(t),u="y"===i,d=r.x+r.width/2-a.width/2,c=r.y+r.height/2-a.height/2,h=r[o]/2-a[o]/2;let m;switch(l){case"top":m={x:d,y:r.y-a.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:c};break;case"left":m={x:r.x-a.width,y:c};break;default:m={x:r.x,y:r.y}}switch(la(t)){case"start":m[s]-=h*(n&&u?-1:1);break;case"end":m[s]+=h*(n&&u?-1:1)}return m}async function Ea(e,t){var n;void 0===t&&(t={});const{x:r,y:a,platform:i,rects:s,elements:o,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:c="floating",altBoundary:h=!1,padding:m=0}=sa(t,e),p=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(m),f=o[h?"floating"===c?"reference":"floating":c],_=pa(await i.getClippingRect({element:null==(n=await(null==i.isElement?void 0:i.isElement(f)))||n?f:f.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(o.floating)),boundary:u,rootBoundary:d,strategy:l})),y="floating"===c?{x:r,y:a,width:s.floating.width,height:s.floating.height}:s.reference,g=await(null==i.getOffsetParent?void 0:i.getOffsetParent(o.floating)),v=await(null==i.isElement?void 0:i.isElement(g))&&await(null==i.getScale?void 0:i.getScale(g))||{x:1,y:1},b=pa(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:y,offsetParent:g,strategy:l}):y);return{top:(_.top-b.top+p.top)/v.y,bottom:(b.bottom-_.bottom+p.bottom)/v.y,left:(_.left-b.left+p.left)/v.x,right:(b.right-_.right+p.right)/v.x}}function Ca(e){const t=Cr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const a=Dr(e),i=a?e.offsetWidth:n,s=a?e.offsetHeight:r,o=ta(n)!==i||ta(r)!==s;return o&&(n=i,r=s),{width:n,height:r,$:o}}function Ha(e){return Sr(e)?e:e.contextElement}function Ra(e){const t=Ha(e);if(!Dr(t))return ra(1);const n=t.getBoundingClientRect(),{width:r,height:a,$:i}=Ca(t);let s=(i?ta(n.width):n.width)/r,o=(i?ta(n.height):n.height)/a;return s&&Number.isFinite(s)||(s=1),o&&Number.isFinite(o)||(o=1),{x:s,y:o}}const Aa=ra(0);function Ia(e){const t=wr(e);return Pr()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Aa}function Fa(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const a=e.getBoundingClientRect(),i=Ha(e);let s=ra(1);t&&(r?Sr(r)&&(s=Ra(r)):s=Ra(e));const o=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==wr(e))&&t}(i,n,r)?Ia(i):ra(0);let l=(a.left+o.x)/s.x,u=(a.top+o.y)/s.y,d=a.width/s.x,c=a.height/s.y;if(i){const e=wr(i),t=r&&Sr(r)?wr(r):r;let n=e,a=Fr(n);for(;a&&r&&t!==n;){const e=Ra(a),t=a.getBoundingClientRect(),r=Cr(a),i=t.left+(a.clientLeft+parseFloat(r.paddingLeft))*e.x,s=t.top+(a.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,u*=e.y,d*=e.x,c*=e.y,l+=i,u+=s,n=wr(a),a=Fr(n)}}return pa({width:d,height:c,x:l,y:u})}function Na(e,t){const n=Hr(e).scrollLeft;return t?t.left+n:Fa(Lr(e)).left+n}function Wa(e,t,n){void 0===n&&(n=!1);const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-(n?0:Na(e,r)),y:r.top+t.scrollTop}}function za(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=wr(e),r=Lr(e),a=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,o=0,l=0;if(a){i=a.width,s=a.height;const e=Pr();(!e||e&&"fixed"===t)&&(o=a.offsetLeft,l=a.offsetTop)}return{width:i,height:s,x:o,y:l}}(e,n);else if("document"===t)r=function(e){const t=Lr(e),n=Hr(e),r=e.ownerDocument.body,a=ea(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=ea(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+Na(e);const o=-n.scrollTop;return"rtl"===Cr(r).direction&&(s+=ea(t.clientWidth,r.clientWidth)-a),{width:a,height:i,x:s,y:o}}(Lr(e));else if(Sr(t))r=function(e,t){const n=Fa(e,!0,"fixed"===t),r=n.top+e.clientTop,a=n.left+e.clientLeft,i=Dr(e)?Ra(e):ra(1);return{width:e.clientWidth*i.x,height:e.clientHeight*i.y,x:a*i.x,y:r*i.y}}(t,n);else{const n=Ia(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return pa(r)}function Va(e,t){const n=Rr(e);return!(n===t||!Sr(n)||Er(n))&&("fixed"===Cr(n).position||Va(n,t))}function Ba(e,t,n){const r=Dr(t),a=Lr(t),i="fixed"===n,s=Fa(e,!0,i,t);let o={scrollLeft:0,scrollTop:0};const l=ra(0);if(r||!r&&!i)if(("body"!==Mr(t)||Tr(a))&&(o=Hr(t)),r){const e=Fa(t,!0,i,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else a&&(l.x=Na(a));const u=!a||r||i?ra(0):Wa(a,o);return{x:s.left+o.scrollLeft-l.x-u.x,y:s.top+o.scrollTop-l.y-u.y,width:s.width,height:s.height}}function Ua(e){return"static"===Cr(e).position}function $a(e,t){if(!Dr(e)||"fixed"===Cr(e).position)return null;if(t)return t(e);let n=e.offsetParent;return Lr(e)===n&&(n=n.ownerDocument.body),n}function qa(e,t){const n=wr(e);if(Or(e))return n;if(!Dr(e)){let t=Rr(e);for(;t&&!Er(t);){if(Sr(t)&&!Ua(t))return t;t=Rr(t)}return n}let r=$a(e,t);for(;r&&xr(r)&&Ua(r);)r=$a(r,t);return r&&Er(r)&&Ua(r)&&!jr(r)?n:r||function(e){let t=Rr(e);for(;Dr(t)&&!Er(t);){if(jr(t))return t;if(Or(t))return null;t=Rr(t)}return null}(e)||n}const Ga={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:a}=e;const i="fixed"===a,s=Lr(r),o=!!t&&Or(t.floating);if(r===s||o&&i)return n;let l={scrollLeft:0,scrollTop:0},u=ra(1);const d=ra(0),c=Dr(r);if((c||!c&&!i)&&(("body"!==Mr(r)||Tr(s))&&(l=Hr(r)),Dr(r))){const e=Fa(r);u=Ra(r),d.x=e.x+r.clientLeft,d.y=e.y+r.clientTop}const h=!s||c||i?ra(0):Wa(s,l,!0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}},getDocumentElement:Lr,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:a}=e;const i=[..."clippingAncestors"===n?Or(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=Ir(e,[],!1).filter((e=>Sr(e)&&"body"!==Mr(e))),a=null;const i="fixed"===Cr(e).position;let s=i?Rr(e):e;for(;Sr(s)&&!Er(s);){const t=Cr(s),n=jr(s);n||"fixed"!==t.position||(a=null),(i?!n&&!a:!n&&"static"===t.position&&a&&["absolute","fixed"].includes(a.position)||Tr(s)&&!n&&Va(e,s))?r=r.filter((e=>e!==s)):a=t,s=Rr(s)}return t.set(e,r),r}(t,this._c):[].concat(n),r],s=i[0],o=i.reduce(((e,n)=>{const r=za(t,n,a);return e.top=ea(r.top,e.top),e.right=Xr(r.right,e.right),e.bottom=Xr(r.bottom,e.bottom),e.left=ea(r.left,e.left),e}),za(t,s,a));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}},getOffsetParent:qa,getElementRects:async function(e){const t=this.getOffsetParent||qa,n=this.getDimensions,r=await n(e.floating);return{reference:Ba(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=Ca(e);return{width:t,height:n}},getScale:Ra,isElement:Sr,isRTL:function(e){return"rtl"===Cr(e).direction}};function Za(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ja(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:o="function"==typeof IntersectionObserver,animationFrame:l=!1}=r,u=Ha(e),d=a||i?[...u?Ir(u):[],...Ir(t)]:[];d.forEach((e=>{a&&e.addEventListener("scroll",n,{passive:!0}),i&&e.addEventListener("resize",n)}));const c=u&&o?function(e,t){let n,r=null;const a=Lr(e);function i(){var e;clearTimeout(n),null==(e=r)||e.disconnect(),r=null}return function s(o,l){void 0===o&&(o=!1),void 0===l&&(l=1),i();const u=e.getBoundingClientRect(),{left:d,top:c,width:h,height:m}=u;if(o||t(),!h||!m)return;const p={rootMargin:-na(c)+"px "+-na(a.clientWidth-(d+h))+"px "+-na(a.clientHeight-(c+m))+"px "+-na(d)+"px",threshold:ea(0,Xr(1,l))||1};let f=!0;function _(t){const r=t[0].intersectionRatio;if(r!==l){if(!f)return s();r?s(!1,r):n=setTimeout((()=>{s(!1,1e-7)}),1e3)}1!==r||Za(u,e.getBoundingClientRect())||s(),f=!1}try{r=new IntersectionObserver(_,{...p,root:a.ownerDocument})}catch(e){r=new IntersectionObserver(_,p)}r.observe(e)}(!0),i}(u,n):null;let h,m=-1,p=null;s&&(p=new ResizeObserver((e=>{let[r]=e;r&&r.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{var e;null==(e=p)||e.observe(t)}))),n()})),u&&!l&&p.observe(u),p.observe(t));let f=l?Fa(e):null;return l&&function t(){const r=Fa(e);f&&!Za(f,r)&&n(),f=r,h=requestAnimationFrame(t)}(),n(),()=>{var e;d.forEach((e=>{a&&e.removeEventListener("scroll",n),i&&e.removeEventListener("resize",n)})),null==c||c(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(h)}}const Qa=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:a,y:i,placement:s,middlewareData:o}=t,l=await async function(e,t){const{placement:n,platform:r,elements:a}=e,i=await(null==r.isRTL?void 0:r.isRTL(a.floating)),s=oa(n),o=la(n),l="y"===da(n),u=["left","top"].includes(s)?-1:1,d=i&&l?-1:1,c=sa(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:p}="number"==typeof c?{mainAxis:c,crossAxis:0,alignmentAxis:null}:{mainAxis:c.mainAxis||0,crossAxis:c.crossAxis||0,alignmentAxis:c.alignmentAxis};return o&&"number"==typeof p&&(m="end"===o?-1*p:p),l?{x:m*d,y:h*u}:{x:h*u,y:m*d}}(t,e);return s===(null==(n=o.offset)?void 0:n.placement)&&null!=(r=o.arrow)&&r.alignmentOffset?{}:{x:a+l.x,y:i+l.y,data:{...l,placement:s}}}}},Ka=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:a,middlewareData:i,rects:s,initialPlacement:o,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:c=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:f=!0,..._}=sa(e,t);if(null!=(n=i.arrow)&&n.alignmentOffset)return{};const y=oa(a),g=da(o),v=oa(o)===o,b=await(null==l.isRTL?void 0:l.isRTL(u.floating)),M=h||(v||!f?[ma(o)]:function(e){const t=ma(e);return[ha(e),t,ha(t)]}(o)),w="none"!==p;!h&&w&&M.push(...function(e,t,n,r){const a=la(e);let i=function(e,t,n){const r=["left","right"],a=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?a:r:t?r:a;case"left":case"right":return t?i:s;default:return[]}}(oa(e),"start"===n,r);return a&&(i=i.map((e=>e+"-"+a)),t&&(i=i.concat(i.map(ha)))),i}(o,f,p,b));const L=[o,...M],k=await Ea(t,_),S=[];let D=(null==(r=i.flip)?void 0:r.overflows)||[];if(d&&S.push(k[y]),c){const e=function(e,t,n){void 0===n&&(n=!1);const r=la(e),a=ca(e),i=ua(a);let s="x"===a?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=ma(s)),[s,ma(s)]}(a,s,b);S.push(k[e[0]],k[e[1]])}if(D=[...D,{placement:a,overflows:S}],!S.every((e=>e<=0))){var Y,T;const e=((null==(Y=i.flip)?void 0:Y.index)||0)+1,t=L[e];if(t)return{data:{index:e,overflows:D},reset:{placement:t}};let n=null==(T=D.filter((e=>e.overflows[0]<=0)).sort(((e,t)=>e.overflows[1]-t.overflows[1]))[0])?void 0:T.placement;if(!n)switch(m){case"bestFit":{var x;const e=null==(x=D.filter((e=>{if(w){const t=da(e.placement);return t===g||"y"===t}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])?void 0:x[0];e&&(n=e);break}case"initialPlacement":n=o}if(a!==n)return{reset:{placement:n}}}return{}}}},Xa=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:a,rects:i,platform:s,elements:o}=t,{apply:l=()=>{},...u}=sa(e,t),d=await Ea(t,u),c=oa(a),h=la(a),m="y"===da(a),{width:p,height:f}=i.floating;let _,y;"top"===c||"bottom"===c?(_=c,y=h===(await(null==s.isRTL?void 0:s.isRTL(o.floating))?"start":"end")?"left":"right"):(y=c,_="end"===h?"top":"bottom");const g=f-d.top-d.bottom,v=p-d.left-d.right,b=Xr(f-d[_],g),M=Xr(p-d[y],v),w=!t.middlewareData.shift;let L=b,k=M;if(null!=(n=t.middlewareData.shift)&&n.enabled.x&&(k=v),null!=(r=t.middlewareData.shift)&&r.enabled.y&&(L=g),w&&!h){const e=ea(d.left,0),t=ea(d.right,0),n=ea(d.top,0),r=ea(d.bottom,0);m?k=p-2*(0!==e||0!==t?e+t:ea(d.left,d.right)):L=f-2*(0!==n||0!==r?n+r:ea(d.top,d.bottom))}await l({...t,availableWidth:k,availableHeight:L});const S=await s.getDimensions(o.floating);return p!==S.width||f!==S.height?{reset:{rects:!0}}:{}}}},ei=(e,t,n)=>{const r=new Map,a={platform:Ga,...n},i={...a.platform,_c:r};return(async(e,t,n)=>{const{placement:r="bottom",strategy:a="absolute",middleware:i=[],platform:s}=n,o=i.filter(Boolean),l=await(null==s.isRTL?void 0:s.isRTL(t));let u=await s.getElementRects({reference:e,floating:t,strategy:a}),{x:d,y:c}=Pa(u,r,l),h=r,m={},p=0;for(let n=0;n{t.current=e})),t}const si=(e,t)=>({...Ka(e),options:[e,t]}),oi=(e,t)=>({...Xa(e),options:[e,t]}),li={...L},ui=li.useInsertionEffect||(e=>e());function di(e){const t=w.useRef((()=>{}));return ui((()=>{t.current=e})),w.useCallback((function(){for(var e=arguments.length,n=new Array(e),r=0;r=e.current.length}function yi(e,t){return vi(e,{disabledIndices:t})}function gi(e,t){return vi(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function vi(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:a,amount:i=1}=void 0===t?{}:t;const s=e.current;let o=n;do{o+=r?-i:i}while(o>=0&&o<=s.length-1&&wi(s,o,a));return o}function bi(e,t,n,r,a){if(-1===e)return-1;const i=n.indexOf(e),s=t[e];switch(a){case"tl":return i;case"tr":return s?i+s.width-1:i;case"bl":return s?i+(s.height-1)*r:i;case"br":return n.lastIndexOf(e)}}function Mi(e,t){return t.flatMap(((t,n)=>e.includes(t)?[n]:[]))}function wi(e,t,n){if(n)return n.includes(t);const r=e[t];return null==r||r.hasAttribute("disabled")||"true"===r.getAttribute("aria-disabled")}var Li="undefined"!=typeof document?w.useLayoutEffect:w.useEffect;function ki(){return ki=Object.assign?Object.assign.bind():function(e){for(var t=1;t"floating-ui-"+Math.random().toString(36).slice(2,6)+Di++,Ti=li.useId||function(){const[e,t]=w.useState((()=>Si?Yi():void 0));return Li((()=>{null==e&&t(Yi())}),[]),w.useEffect((()=>{Si=!0}),[]),e};const xi=w.createContext(null),Oi=w.createContext(null),ji=()=>{var e;return(null==(e=w.useContext(xi))?void 0:e.id)||null},Pi=()=>w.useContext(Oi);function Ei(e){return"data-floating-ui-"+e}function Ci(e){const t=(0,w.useRef)(e);return Li((()=>{t.current=e})),t}let Hi=0;function Ri(e,t){void 0===t&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:a=!1}=t;r&&cancelAnimationFrame(Hi);const i=()=>null==e?void 0:e.focus({preventScroll:n});a?i():Hi=requestAnimationFrame(i)}function Ai(e,t){let n=e.filter((e=>{var n;return e.parentId===t&&(null==(n=e.context)?void 0:n.open)})),r=n;for(;r.length;)r=e.filter((e=>{var t;return null==(t=r)?void 0:t.some((t=>{var n;return e.parentId===t.id&&(null==(n=e.context)?void 0:n.open)}))})),n=n.concat(r);return n}let Ii=new WeakMap,Fi=new WeakSet,Ni={},Wi=0;const zi=e=>e&&(e.host||zi(e.parentNode));function Vi(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1);const r=Gr(e[0]).body;return function(e,t,n,r){const a="data-floating-ui-inert",i=r?"inert":n?"aria-hidden":null,s=(o=t,e.map((e=>{if(o.contains(e))return e;const t=zi(e);return o.contains(t)?t:null})).filter((e=>null!=e)));var o;const l=new Set,u=new Set(s),d=[];Ni[a]||(Ni[a]=new WeakMap);const c=Ni[a];return s.forEach((function e(t){t&&!l.has(t)&&(l.add(t),t.parentNode&&e(t.parentNode))})),function e(t){t&&!u.has(t)&&[].forEach.call(t.children,(t=>{if("script"!==Mr(t))if(l.has(t))e(t);else{const e=i?t.getAttribute(i):null,n=null!==e&&"false"!==e,r=(Ii.get(t)||0)+1,s=(c.get(t)||0)+1;Ii.set(t,r),c.set(t,s),d.push(t),1===r&&n&&Fi.add(t),1===s&&t.setAttribute(a,""),!n&&i&&t.setAttribute(i,"true")}}))}(t),l.clear(),Wi++,()=>{d.forEach((e=>{const t=(Ii.get(e)||0)-1,n=(c.get(e)||0)-1;Ii.set(e,t),c.set(e,n),t||(!Fi.has(e)&&i&&e.removeAttribute(i),Fi.delete(e)),n||e.removeAttribute(a)})),Wi--,Wi||(Ii=new WeakMap,Ii=new WeakMap,Fi=new WeakSet,Ni={})}}(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const Bi=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Ui(e,t){const n=Oa(e,Bi());"prev"===t&&n.reverse();const r=n.indexOf(Nr(Gr(e)));return n.slice(r+1)[0]}function $i(){return Ui(document.body,"next")}function qi(){return Ui(document.body,"prev")}function Gi(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!Wr(n,r)}function Zi(e){Oa(e,Bi()).forEach((e=>{e.dataset.tabindex=e.getAttribute("tabindex")||"",e.setAttribute("tabindex","-1")}))}function Ji(e){e.querySelectorAll("[data-tabindex]").forEach((e=>{const t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")}))}const Qi={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0};function Ki(e){"Tab"===e.key&&(e.target,clearTimeout(void 0))}const Xi=w.forwardRef((function(e,t){const[n,r]=w.useState();Li((()=>($r()&&r("button"),document.addEventListener("keydown",Ki),()=>{document.removeEventListener("keydown",Ki)})),[]);const a={ref:t,tabIndex:0,role:n,"aria-hidden":!n||void 0,[Ei("focus-guard")]:"",style:Qi};return w.createElement("span",ki({},e,a))})),es=w.createContext(null),ts=Ei("portal");function ns(e){const{children:t,id:n,root:r,preserveTabOrder:a=!0}=e,i=function(e){void 0===e&&(e={});const{id:t,root:n}=e,r=Ti(),a=rs(),[i,s]=w.useState(null),o=w.useRef(null);return Li((()=>()=>{null==i||i.remove(),queueMicrotask((()=>{o.current=null}))}),[i]),Li((()=>{if(!r)return;if(o.current)return;const e=t?document.getElementById(t):null;if(!e)return;const n=document.createElement("div");n.id=r,n.setAttribute(ts,""),e.appendChild(n),o.current=n,s(n)}),[t,r]),Li((()=>{if(null===n)return;if(!r)return;if(o.current)return;let e=n||(null==a?void 0:a.portalNode);e&&!Sr(e)&&(e=e.current),e=e||document.body;let i=null;t&&(i=document.createElement("div"),i.id=t,e.appendChild(i));const l=document.createElement("div");l.id=r,l.setAttribute(ts,""),e=i||e,e.appendChild(l),o.current=l,s(l)}),[t,n,r,a]),i}({id:n,root:r}),[s,o]=w.useState(null),l=w.useRef(null),u=w.useRef(null),d=w.useRef(null),c=w.useRef(null),h=null==s?void 0:s.modal,m=null==s?void 0:s.open,p=!!s&&!s.modal&&s.open&&a&&!(!r&&!i);return w.useEffect((()=>{if(i&&a&&!h)return i.addEventListener("focusin",e,!0),i.addEventListener("focusout",e,!0),()=>{i.removeEventListener("focusin",e,!0),i.removeEventListener("focusout",e,!0)};function e(e){i&&Gi(e)&&("focusin"===e.type?Ji:Zi)(i)}}),[i,a,h]),w.useEffect((()=>{i&&(m||Ji(i))}),[m,i]),w.createElement(es.Provider,{value:w.useMemo((()=>({preserveTabOrder:a,beforeOutsideRef:l,afterOutsideRef:u,beforeInsideRef:d,afterInsideRef:c,portalNode:i,setFocusManagerState:o})),[a,i])},p&&i&&w.createElement(Xi,{"data-type":"outside",ref:l,onFocus:e=>{if(Gi(e,i)){var t;null==(t=d.current)||t.focus()}else{const e=qi()||(null==s?void 0:s.refs.domReference.current);null==e||e.focus()}}}),p&&i&&w.createElement("span",{"aria-owns":i.id,style:Qi}),i&&ja.createPortal(t,i),p&&i&&w.createElement(Xi,{"data-type":"outside",ref:u,onFocus:e=>{if(Gi(e,i)){var t;null==(t=c.current)||t.focus()}else{const t=$i()||(null==s?void 0:s.refs.domReference.current);null==t||t.focus(),(null==s?void 0:s.closeOnFocusOut)&&(null==s||s.onOpenChange(!1,e.nativeEvent,"focus-out"))}}}))}const rs=()=>w.useContext(es),as="data-floating-ui-focusable";function is(e){return e?e.hasAttribute(as)?e:e.querySelector("["+as+"]")||e:null}let ss=[];function os(e){ss=ss.filter((e=>e.isConnected));let t=e;if(t&&"body"!==Mr(t)){if(!function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==ya.call(e,fa)&&Ya(t,e)}(t,Bi())){const e=Oa(t,Bi())[0];e&&(t=e)}ss.push(t),ss.length>20&&(ss=ss.slice(-20))}}function ls(){return ss.slice().reverse().find((e=>e.isConnected))}const us=w.forwardRef((function(e,t){return w.createElement("button",ki({},e,{type:"button",ref:t,tabIndex:-1,style:Qi}))}));function ds(e){const{context:t,children:n,disabled:r=!1,order:a=["content"],guards:i=!0,initialFocus:s=0,returnFocus:o=!0,restoreFocus:l=!1,modal:u=!0,visuallyHiddenDismiss:d=!1,closeOnFocusOut:c=!0}=e,{open:h,refs:m,nodeId:p,onOpenChange:f,events:_,dataRef:y,floatingId:g,elements:{domReference:v,floating:b}}=t,M="number"==typeof s&&s<0,L=Kr(v)&&M,k="undefined"==typeof HTMLElement||!("inert"in HTMLElement.prototype)||i,S=Ci(a),D=Ci(s),Y=Ci(o),T=Pi(),x=rs(),O=w.useRef(null),j=w.useRef(null),P=w.useRef(!1),E=w.useRef(!1),C=w.useRef(-1),H=null!=x,R=is(b),A=di((function(e){return void 0===e&&(e=R),e?Oa(e,Bi()):[]})),I=di((e=>{const t=A(e);return S.current.map((e=>v&&"reference"===e?v:R&&"floating"===e?R:t)).filter(Boolean).flat()}));function F(e){return!r&&d&&u?w.createElement(us,{ref:"start"===e?O:j,onClick:e=>f(!1,e.nativeEvent)},"string"==typeof d?d:"Dismiss"):null}w.useEffect((()=>{if(r)return;if(!u)return;function e(e){if("Tab"===e.key){Wr(R,Nr(Gr(R)))&&0===A().length&&!L&&Qr(e);const t=I(),n=Jr(e);"reference"===S.current[0]&&n===v&&(Qr(e),e.shiftKey?Ri(t[t.length-1]):Ri(t[1])),"floating"===S.current[1]&&n===R&&e.shiftKey&&(Qr(e),Ri(t[0]))}}const t=Gr(R);return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[r,v,R,u,S,L,A,I]),w.useEffect((()=>{if(!r&&b)return b.addEventListener("focusin",e),()=>{b.removeEventListener("focusin",e)};function e(e){const t=Jr(e),n=A().indexOf(t);-1!==n&&(C.current=n)}}),[r,b,A]),w.useEffect((()=>{if(!r&&c)return b&&Dr(v)?(v.addEventListener("focusout",t),v.addEventListener("pointerdown",e),b.addEventListener("focusout",t),()=>{v.removeEventListener("focusout",t),v.removeEventListener("pointerdown",e),b.removeEventListener("focusout",t)}):void 0;function e(){E.current=!0,setTimeout((()=>{E.current=!1}))}function t(e){const t=e.relatedTarget;queueMicrotask((()=>{const n=!(Wr(v,t)||Wr(b,t)||Wr(t,b)||Wr(null==x?void 0:x.portalNode,t)||null!=t&&t.hasAttribute(Ei("focus-guard"))||T&&(Ai(T.nodesRef.current,p).find((e=>{var n,r;return Wr(null==(n=e.context)?void 0:n.elements.floating,t)||Wr(null==(r=e.context)?void 0:r.elements.domReference,t)}))||function(e,t){var n;let r=[],a=null==(n=e.find((e=>e.id===t)))?void 0:n.parentId;for(;a;){const t=e.find((e=>e.id===a));a=null==t?void 0:t.parentId,t&&(r=r.concat(t))}return r}(T.nodesRef.current,p).find((e=>{var n,r;return(null==(n=e.context)?void 0:n.elements.floating)===t||(null==(r=e.context)?void 0:r.elements.domReference)===t}))));if(l&&n&&Nr(Gr(R))===Gr(R).body){Dr(R)&&R.focus();const e=C.current,t=A(),n=t[e]||t[t.length-1]||R;Dr(n)&&n.focus()}!L&&u||!t||!n||E.current||t===ls()||(P.current=!0,f(!1,e,"focus-out"))}))}}),[r,v,b,R,u,p,T,x,f,c,l,A,L]),w.useEffect((()=>{var e;if(r)return;const t=Array.from((null==x||null==(e=x.portalNode)?void 0:e.querySelectorAll("["+Ei("portal")+"]"))||[]);if(b){const e=[b,...t,O.current,j.current,S.current.includes("reference")||L?v:null].filter((e=>null!=e)),n=u||L?Vi(e,k,!k):Vi(e);return()=>{n()}}}),[r,v,b,u,S,x,L,k]),Li((()=>{if(r||!Dr(R))return;const e=Nr(Gr(R));queueMicrotask((()=>{const t=I(R),n=D.current,r=("number"==typeof n?t[n]:n.current)||R,a=Wr(R,e);M||a||!h||Ri(r,{preventScroll:r===R})}))}),[r,h,R,M,I,D]),Li((()=>{if(r||!R)return;let e=!1;const t=Gr(R),n=Nr(t);let a=y.current.openEvent;function i(t){let{open:n,reason:r,event:i,nested:s}=t;n&&(a=i),"escape-key"===r&&m.domReference.current&&os(m.domReference.current),"hover"===r&&"mouseleave"===i.type&&(P.current=!0),"outside-press"===r&&(s?(P.current=!1,e=!0):P.current=!(Br(i)||Ur(i)))}os(n),_.on("openchange",i);const s=t.createElement("span");return s.setAttribute("tabindex","-1"),s.setAttribute("aria-hidden","true"),Object.assign(s.style,Qi),H&&v&&v.insertAdjacentElement("afterend",s),()=>{_.off("openchange",i);const n=Nr(t),r=Wr(b,n)||T&&Ai(T.nodesRef.current,p).some((e=>{var t;return Wr(null==(t=e.context)?void 0:t.elements.floating,n)}));(r||a&&["click","mousedown"].includes(a.type))&&m.domReference.current&&os(m.domReference.current);const o="boolean"==typeof Y.current?ls()||s:Y.current.current||s;queueMicrotask((()=>{Y.current&&!P.current&&Dr(o)&&(o===n||n===t.body||r)&&o.focus({preventScroll:e}),s.remove()}))}}),[r,b,R,Y,y,m,_,T,p,H,v]),w.useEffect((()=>{queueMicrotask((()=>{P.current=!1}))}),[r]),Li((()=>{if(!r&&x)return x.setFocusManagerState({modal:u,closeOnFocusOut:c,open:h,onOpenChange:f,refs:m}),()=>{x.setFocusManagerState(null)}}),[r,x,u,h,f,m,c]),Li((()=>{if(r)return;if(!R)return;if("function"!=typeof MutationObserver)return;if(M)return;const e=()=>{const e=R.getAttribute("tabindex"),t=A(),n=Nr(Gr(b)),r=t.indexOf(n);-1!==r&&(C.current=r),S.current.includes("floating")||n!==m.domReference.current&&0===t.length?"0"!==e&&R.setAttribute("tabindex","0"):"-1"!==e&&R.setAttribute("tabindex","-1")};e();const t=new MutationObserver(e);return t.observe(R,{childList:!0,subtree:!0,attributes:!0}),()=>{t.disconnect()}}),[r,b,R,m,S,A,M]);const N=!r&&k&&(!u||!L)&&(H||u);return w.createElement(w.Fragment,null,N&&w.createElement(Xi,{"data-type":"inside",ref:null==x?void 0:x.beforeInsideRef,onFocus:e=>{if(u){const e=I();Ri("reference"===a[0]?e[0]:e[e.length-1])}else if(null!=x&&x.preserveTabOrder&&x.portalNode)if(P.current=!1,Gi(e,x.portalNode)){const e=$i()||v;null==e||e.focus()}else{var t;null==(t=x.beforeOutsideRef.current)||t.focus()}}}),!L&&F("start"),n,F("end"),N&&w.createElement(Xi,{"data-type":"inside",ref:null==x?void 0:x.afterInsideRef,onFocus:e=>{if(u)Ri(I()[0]);else if(null!=x&&x.preserveTabOrder&&x.portalNode)if(c&&(P.current=!0),Gi(e,x.portalNode)){const e=qi()||v;null==e||e.focus()}else{var t;null==(t=x.afterOutsideRef.current)||t.focus()}}}))}const cs={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},hs={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},ms=e=>{var t,n;return{escapeKey:"boolean"==typeof e?e:null!=(t=null==e?void 0:e.escapeKey)&&t,outsidePress:"boolean"==typeof e?e:null==(n=null==e?void 0:e.outsidePress)||n}};function ps(e){void 0===e&&(e={});const{nodeId:t}=e,n=function(e){const{open:t=!1,onOpenChange:n,elements:r}=e,a=Ti(),i=w.useRef({}),[s]=w.useState((()=>function(){const e=new Map;return{emit(t,n){var r;null==(r=e.get(t))||r.forEach((e=>e(n)))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,(null==(r=e.get(t))?void 0:r.filter((e=>e!==n)))||[])}}}())),o=null!=ji(),[l,u]=w.useState(r.reference),d=di(((e,t,r)=>{i.current.openEvent=e?t:void 0,s.emit("openchange",{open:e,event:t,reason:r,nested:o}),null==n||n(e,t,r)})),c=w.useMemo((()=>({setPositionReference:u})),[]),h=w.useMemo((()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference})),[l,r.reference,r.floating]);return w.useMemo((()=>({dataRef:i,open:t,onOpenChange:d,elements:h,events:s,floatingId:a,refs:c})),[t,d,h,s,a,c])}({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,a=r.elements,[i,s]=w.useState(null),[o,l]=w.useState(null),u=(null==a?void 0:a.domReference)||i,d=w.useRef(null),c=Pi();Li((()=>{u&&(d.current=u)}),[u]);const h=function(e){void 0===e&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:a,elements:{reference:i,floating:s}={},transform:o=!0,whileElementsMounted:l,open:u}=e,[d,c]=w.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=w.useState(r);ni(h,r)||m(r);const[p,f]=w.useState(null),[_,y]=w.useState(null),g=w.useCallback((e=>{e!==L.current&&(L.current=e,f(e))}),[]),v=w.useCallback((e=>{e!==k.current&&(k.current=e,y(e))}),[]),b=i||p,M=s||_,L=w.useRef(null),k=w.useRef(null),S=w.useRef(d),D=null!=l,Y=ii(l),T=ii(a),x=ii(u),O=w.useCallback((()=>{if(!L.current||!k.current)return;const e={placement:t,strategy:n,middleware:h};T.current&&(e.platform=T.current),ei(L.current,k.current,e).then((e=>{const t={...e,isPositioned:!1!==x.current};j.current&&!ni(S.current,t)&&(S.current=t,ja.flushSync((()=>{c(t)})))}))}),[h,t,n,T,x]);ti((()=>{!1===u&&S.current.isPositioned&&(S.current.isPositioned=!1,c((e=>({...e,isPositioned:!1}))))}),[u]);const j=w.useRef(!1);ti((()=>(j.current=!0,()=>{j.current=!1})),[]),ti((()=>{if(b&&(L.current=b),M&&(k.current=M),b&&M){if(Y.current)return Y.current(b,M,O);O()}}),[b,M,O,Y,D]);const P=w.useMemo((()=>({reference:L,floating:k,setReference:g,setFloating:v})),[g,v]),E=w.useMemo((()=>({reference:b,floating:M})),[b,M]),C=w.useMemo((()=>{const e={position:n,left:0,top:0};if(!E.floating)return e;const t=ai(E.floating,d.x),r=ai(E.floating,d.y);return o?{...e,transform:"translate("+t+"px, "+r+"px)",...ri(E.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:t,top:r}}),[n,o,E.floating,d.x,d.y]);return w.useMemo((()=>({...d,update:O,refs:P,elements:E,floatingStyles:C})),[d,O,P,E,C])}({...e,elements:{...a,...o&&{reference:o}}}),m=w.useCallback((e=>{const t=Sr(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),contextElement:e}:e;l(t),h.refs.setReference(t)}),[h.refs]),p=w.useCallback((e=>{(Sr(e)||null===e)&&(d.current=e,s(e)),(Sr(h.refs.reference.current)||null===h.refs.reference.current||null!==e&&!Sr(e))&&h.refs.setReference(e)}),[h.refs]),f=w.useMemo((()=>({...h.refs,setReference:p,setPositionReference:m,domReference:d})),[h.refs,p,m]),_=w.useMemo((()=>({...h.elements,domReference:u})),[h.elements,u]),y=w.useMemo((()=>({...h,...r,refs:f,elements:_,nodeId:t})),[h,f,_,t,r]);return Li((()=>{r.dataRef.current.floatingContext=y;const e=null==c?void 0:c.nodesRef.current.find((e=>e.id===t));e&&(e.context=y)})),w.useMemo((()=>({...h,context:y,refs:f,elements:_})),[h,f,_,y])}const fs="active",_s="selected";function ys(e,t,n){const r=new Map,a="item"===n;let i=e;if(a&&e){const{[fs]:t,[_s]:n,...r}=e;i=r}return{..."floating"===n&&{tabIndex:-1,[as]:""},...i,...t.map((t=>{const r=t?t[n]:null;return"function"==typeof r?e?r(e):null:r})).concat(e).reduce(((e,t)=>t?(Object.entries(t).forEach((t=>{let[n,i]=t;var s;a&&[fs,_s].includes(n)||(0===n.indexOf("on")?(r.has(n)||r.set(n,[]),"function"==typeof i&&(null==(s=r.get(n))||s.push(i),e[n]=function(){for(var e,t=arguments.length,a=new Array(t),i=0;ie(...a))).find((e=>void 0!==e))})):e[n]=i)})),e):e),{})}}let gs=!1;function vs(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function bs(e,t){return vs(t,e===ci||e===hi,e===mi||e===pi)}function Ms(e,t,n){return vs(t,e===hi,n?e===mi:e===pi)||"Enter"===e||" "===e||""===e}function ws(e,t,n){return vs(t,n?e===pi:e===mi,e===ci)}function Ls(e,t){const{open:n,onOpenChange:r,elements:a}=e,{listRef:i,activeIndex:s,onNavigate:o=()=>{},enabled:l=!0,selectedIndex:u=null,allowEscape:d=!1,loop:c=!1,nested:h=!1,rtl:m=!1,virtual:p=!1,focusItemOnOpen:f="auto",focusItemOnHover:_=!0,openOnArrowKeyDown:y=!0,disabledIndices:g,orientation:v="vertical",cols:b=1,scrollItemIntoView:M=!0,virtualItemRef:L,itemSizes:k,dense:S=!1}=t,D=Ci(is(a.floating)),Y=ji(),T=Pi(),x=di(o),O=Kr(a.domReference),j=w.useRef(f),P=w.useRef(null!=u?u:-1),E=w.useRef(null),C=w.useRef(!0),H=w.useRef(x),R=w.useRef(!!a.floating),A=w.useRef(n),I=w.useRef(!1),F=w.useRef(!1),N=Ci(g),W=Ci(n),z=Ci(M),V=Ci(u),[B,U]=w.useState(),[$,q]=w.useState(),G=di((function(e,t,n){function r(e){p?(U(e.id),null==T||T.events.emit("virtualfocus",e),L&&(L.current=e)):Ri(e,{preventScroll:!0,sync:!(!zr().toLowerCase().startsWith("mac")||navigator.maxTouchPoints||!$r())&&(gs||I.current)})}void 0===n&&(n=!1);const a=e.current[t.current];a&&r(a),requestAnimationFrame((()=>{const i=e.current[t.current]||a;if(!i)return;a||r(i);const s=z.current;s&&J&&(n||!C.current)&&(null==i.scrollIntoView||i.scrollIntoView("boolean"==typeof s?{block:"nearest",inline:"nearest"}:s))}))}));Li((()=>{document.createElement("div").focus({get preventScroll(){return gs=!0,!1}})}),[]),Li((()=>{l&&(n&&a.floating?j.current&&null!=u&&(F.current=!0,P.current=u,x(u)):R.current&&(P.current=-1,H.current(null)))}),[l,n,a.floating,u,x]),Li((()=>{if(l&&n&&a.floating)if(null==s){if(I.current=!1,null!=V.current)return;if(R.current&&(P.current=-1,G(i,P)),(!A.current||!R.current)&&j.current&&(null!=E.current||!0===j.current&&null==E.current)){let e=0;const t=()=>{null==i.current[0]?(e<2&&(e?requestAnimationFrame:queueMicrotask)(t),e++):(P.current=null==E.current||Ms(E.current,v,m)||h?yi(i,N.current):gi(i,N.current),E.current=null,x(P.current))};t()}}else _i(i,s)||(P.current=s,G(i,P,F.current),F.current=!1)}),[l,n,a.floating,s,V,h,i,v,m,x,G,N]),Li((()=>{var e;if(!l||a.floating||!T||p||!R.current)return;const t=T.nodesRef.current,n=null==(e=t.find((e=>e.id===Y)))||null==(e=e.context)?void 0:e.elements.floating,r=Nr(Gr(a.floating)),i=t.some((e=>e.context&&Wr(e.context.elements.floating,r)));n&&!i&&C.current&&n.focus({preventScroll:!0})}),[l,a.floating,T,Y,p]),Li((()=>{if(l&&T&&p&&!Y)return T.events.on("virtualfocus",e),()=>{T.events.off("virtualfocus",e)};function e(e){q(e.id),L&&(L.current=e)}}),[l,T,p,Y,L]),Li((()=>{H.current=x,R.current=!!a.floating})),Li((()=>{n||(E.current=null)}),[n]),Li((()=>{A.current=n}),[n]);const Z=null!=s,J=w.useMemo((()=>{function e(e){if(!n)return;const t=i.current.indexOf(e);-1!==t&&x(t)}const t={onFocus(t){let{currentTarget:n}=t;e(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},..._&&{onMouseMove(t){let{currentTarget:n}=t;e(n)},onPointerLeave(e){let{pointerType:t}=e;C.current&&"touch"!==t&&(P.current=-1,G(i,P),x(null),p||Ri(D.current,{preventScroll:!0}))}}};return t}),[n,D,G,_,i,x,p]),Q=di((e=>{if(C.current=!1,I.current=!0,229===e.which)return;if(!W.current&&e.currentTarget===D.current)return;if(h&&ws(e.key,v,m))return Qr(e),r(!1,e.nativeEvent,"list-navigation"),void(Dr(a.domReference)&&(p?null==T||T.events.emit("virtualfocus",a.domReference):a.domReference.focus()));const t=P.current,s=yi(i,g),o=gi(i,g);if(O||("Home"===e.key&&(Qr(e),P.current=s,x(P.current)),"End"===e.key&&(Qr(e),P.current=o,x(P.current))),b>1){const t=k||Array.from({length:i.current.length},(()=>({width:1,height:1}))),n=function(e,t,n){const r=[];let a=0;return e.forEach(((e,i)=>{let{width:s,height:o}=e,l=!1;for(n&&(a=0);!l;){const e=[];for(let n=0;nnull==r[e]))?(e.forEach((e=>{r[e]=i})),l=!0):a++}})),[...r]}(t,b,S),r=n.findIndex((e=>null!=e&&!wi(i.current,e,g))),a=n.reduce(((e,t,n)=>null==t||wi(i.current,t,g)?e:n),-1),l=n[function(e,t){let{event:n,orientation:r,loop:a,rtl:i,cols:s,disabledIndices:o,minIndex:l,maxIndex:u,prevIndex:d,stopEvent:c=!1}=t,h=d;if(n.key===ci){if(c&&Qr(n),-1===d)h=u;else if(h=vi(e,{startingIndex:h,amount:s,decrement:!0,disabledIndices:o}),a&&(d-se?n:n-s}_i(e,h)&&(h=d)}if(n.key===hi&&(c&&Qr(n),-1===d?h=l:(h=vi(e,{startingIndex:d,amount:s,disabledIndices:o}),a&&d+s>u&&(h=vi(e,{startingIndex:d%s-s,amount:s,disabledIndices:o}))),_i(e,h)&&(h=d)),"both"===r){const t=na(d/s);n.key===(i?mi:pi)&&(c&&Qr(n),d%s!=s-1?(h=vi(e,{startingIndex:d,disabledIndices:o}),a&&fi(h,s,t)&&(h=vi(e,{startingIndex:d-d%s-1,disabledIndices:o}))):a&&(h=vi(e,{startingIndex:d-d%s-1,disabledIndices:o})),fi(h,s,t)&&(h=d)),n.key===(i?pi:mi)&&(c&&Qr(n),d%s!=0?(h=vi(e,{startingIndex:d,decrement:!0,disabledIndices:o}),a&&fi(h,s,t)&&(h=vi(e,{startingIndex:d+(s-d%s),decrement:!0,disabledIndices:o}))):a&&(h=vi(e,{startingIndex:d+(s-d%s),decrement:!0,disabledIndices:o})),fi(h,s,t)&&(h=d));const r=na(u/s)===t;_i(e,h)&&(h=a&&r?n.key===(i?pi:mi)?u:vi(e,{startingIndex:d-d%s-1,disabledIndices:o}):d)}return h}({current:n.map((e=>null!=e?i.current[e]:null))},{event:e,orientation:v,loop:c,rtl:m,cols:b,disabledIndices:Mi([...g||i.current.map(((e,t)=>wi(i.current,t)?t:void 0)),void 0],n),minIndex:r,maxIndex:a,prevIndex:bi(P.current>o?s:P.current,t,n,b,e.key===hi?"bl":e.key===(m?mi:pi)?"tr":"tl"),stopEvent:!0})];if(null!=l&&(P.current=l,x(P.current)),"both"===v)return}if(bs(e.key,v)){if(Qr(e),n&&!p&&Nr(e.currentTarget.ownerDocument)===e.currentTarget)return P.current=Ms(e.key,v,m)?s:o,void x(P.current);Ms(e.key,v,m)?P.current=c?t>=o?d&&t!==i.current.length?-1:s:vi(i,{startingIndex:t,disabledIndices:g}):Math.min(o,vi(i,{startingIndex:t,disabledIndices:g})):P.current=c?t<=s?d&&-1!==t?i.current.length:o:vi(i,{startingIndex:t,decrement:!0,disabledIndices:g}):Math.max(s,vi(i,{startingIndex:t,decrement:!0,disabledIndices:g})),_i(i,P.current)?x(null):x(P.current)}})),K=w.useMemo((()=>p&&n&&Z&&{"aria-activedescendant":$||B}),[p,n,Z,$,B]),X=w.useMemo((()=>({"aria-orientation":"both"===v?void 0:v,...!Kr(a.domReference)&&K,onKeyDown:Q,onPointerMove(){C.current=!0}})),[K,Q,a.domReference,v]),ee=w.useMemo((()=>{function e(e){"auto"===f&&Br(e.nativeEvent)&&(j.current=!0)}return{...K,onKeyDown(e){C.current=!1;const t=e.key.startsWith("Arrow"),a=["Home","End"].includes(e.key),s=t||a,o=function(e,t,n){return vs(t,n?e===mi:e===pi,e===hi)}(e.key,v,m),l=ws(e.key,v,m),d=bs(e.key,v),c=(h?o:d)||"Enter"===e.key||""===e.key.trim();if(p&&n){const t=null==T?void 0:T.nodesRef.current.find((e=>null==e.parentId)),n=T&&t?function(e,t){let n,r=-1;return function t(a,i){i>r&&(n=a,r=i),Ai(e,a).forEach((e=>{t(e.id,i+1)}))}(t,0),e.find((e=>e.id===n))}(T.nodesRef.current,t.id):null;if(s&&n&&L){const t=new KeyboardEvent("keydown",{key:e.key,bubbles:!0});if(o||l){var f,_;const r=(null==(f=n.context)?void 0:f.elements.domReference)===e.currentTarget,a=l&&!r?null==(_=n.context)?void 0:_.elements.domReference:o?i.current.find((e=>(null==e?void 0:e.id)===B)):null;a&&(Qr(e),a.dispatchEvent(t),q(void 0))}var g;if((d||a)&&n.context&&n.context.open&&n.parentId&&e.currentTarget!==n.context.elements.domReference)return Qr(e),void(null==(g=n.context.elements.domReference)||g.dispatchEvent(t))}return Q(e)}(n||y||!t)&&(c&&(E.current=h&&d?null:e.key),h?o&&(Qr(e),n?(P.current=yi(i,N.current),x(P.current)):r(!0,e.nativeEvent,"list-navigation")):d&&(null!=u&&(P.current=u),Qr(e),!n&&y?r(!0,e.nativeEvent,"list-navigation"):Q(e),n&&x(P.current)))},onFocus(){n&&!p&&x(null)},onPointerDown:function(e){j.current=f,"auto"===f&&Ur(e.nativeEvent)&&(j.current=!0)},onMouseDown:e,onClick:e}}),[B,K,Q,N,f,i,h,x,r,n,y,v,m,u,T,p,L]);return w.useMemo((()=>l?{reference:ee,floating:X,item:J}:{}),[l,ee,X,J])}const ks=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function Ss(e,t,n){let r,a=n.initialDeps??[];function i(){var i,s,o,l;let u;n.key&&(null==(i=n.debug)?void 0:i.call(n))&&(u=Date.now());const d=e(),c=d.length!==a.length||d.some(((e,t)=>a[t]!==e));if(!c)return r;let h;if(a=d,n.key&&(null==(s=n.debug)?void 0:s.call(n))&&(h=Date.now()),r=t(...d),n.key&&(null==(o=n.debug)?void 0:o.call(n))){const e=Math.round(100*(Date.now()-u))/100,t=Math.round(100*(Date.now()-h))/100,r=t/16,a=(e,t)=>{for(e=String(e);e.length{a=e},i}function Ds(e,t){if(void 0===e)throw new Error("Unexpected undefined"+(t?`: ${t}`:""));return e}const Ys=(e,t,n)=>{let r;return function(...a){e.clearTimeout(r),r=e.setTimeout((()=>t.apply(this,a)),n)}},Ts=e=>e,xs=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},Os=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const a=e=>{const{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(a(n.getBoundingClientRect()),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver((t=>{const r=()=>{const e=t[0];if(null==e?void 0:e.borderBoxSize){const t=e.borderBoxSize[0];if(t)return void a({width:t.inlineSize,height:t.blockSize})}a(n.getBoundingClientRect())};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()}));return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},js={passive:!0},Ps="undefined"==typeof window||"onscrollend"in window,Es=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let a=0;const i=e.options.useScrollendEvent&&Ps?()=>{}:Ys(r,(()=>{t(a,!1)}),e.options.isScrollingResetDelay),s=r=>()=>{const{horizontal:s,isRtl:o}=e.options;a=s?n.scrollLeft*(o?-1:1):n.scrollTop,i(),t(a,r)},o=s(!0),l=s(!1);l(),n.addEventListener("scroll",o,js);const u=e.options.useScrollendEvent&&Ps;return u&&n.addEventListener("scrollend",l,js),()=>{n.removeEventListener("scroll",o),u&&n.removeEventListener("scrollend",l)}},Cs=(e,t,n)=>{if(null==t?void 0:t.borderBoxSize){const e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?"inlineSize":"blockSize"])}return Math.round(e.getBoundingClientRect()[n.options.horizontal?"width":"height"])},Hs=(e,{adjustments:t=0,behavior:n},r)=>{var a,i;const s=e+t;null==(i=null==(a=r.scrollElement)?void 0:a.scrollTo)||i.call(a,{[r.options.horizontal?"left":"top"]:s,behavior:n})};class Rs{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let e=null;const t=()=>e||(this.targetWindow&&this.targetWindow.ResizeObserver?e=new this.targetWindow.ResizeObserver((e=>{e.forEach((e=>{const t=()=>{this._measureElement(e.target,e)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()}))})):null);return{disconnect:()=>{var n;null==(n=t())||n.disconnect(),e=null},observe:e=>{var n;return null==(n=t())?void 0:n.observe(e,{box:"border-box"})},unobserve:e=>{var n;return null==(n=t())?void 0:n.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach((([t,n])=>{void 0===n&&delete e[t]})),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Ts,rangeExtractor:xs,onChange:()=>{},measureElement:Cs,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;null==(n=(t=this.options).onChange)||n.call(t,this,e)},this.maybeNotify=Ss((()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null])),(e=>{this.notify(e)}),{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach((e=>e())),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;const t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t)return void this.maybeNotify();this.scrollElement=t,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=(null==(e=this.scrollElement)?void 0:e.window)??null,this.elementsCache.forEach((e=>{this.observer.observe(e)})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,(e=>{this.scrollRect=e,this.maybeNotify()}))),this.unsubs.push(this.options.observeElementOffset(this,((e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??("function"==typeof this.options.initialOffset?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{const n=new Map,r=new Map;for(let a=t-1;a>=0;a--){const t=e[a];if(n.has(t.lane))continue;const i=r.get(t.lane);if(null==i||t.end>i.end?r.set(t.lane,t):t.ende.end===t.end?e.index-t.index:e.end-t.end))[0]:void 0},this.getMeasurementOptions=Ss((()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled]),((e,t,n,r,a)=>(this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:a})),{key:!1}),this.getMeasurements=Ss((()=>[this.getMeasurementOptions(),this.itemSizeCache]),(({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:a},i)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),[];0===this.measurementsCache.length&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach((e=>{this.itemSizeCache.set(e.key,e.size)})));const s=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const o=this.measurementsCache.slice(0,s);for(let a=s;athis.options.debug}),this.calculateRange=Ss((()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes]),((e,t,n,r)=>this.range=e.length>0&&t>0?function({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const a=e.length-1;let i=As(0,a,(t=>e[t].start),n),s=i;if(1===r)for(;s