@ipv9/tokentracker-cli 0.39.0 → 0.39.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +22 -139
  2. package/dashboard/dist/assets/{ActivityHeatmap-BxBGHY1z.js → ActivityHeatmap-DMiLcNdW.js} +1 -1
  3. package/dashboard/dist/assets/{Card-GROxUc_6.js → Card-BYF4fWvv.js} +1 -1
  4. package/dashboard/dist/assets/DashboardPage-JTMHUROG.js +19 -0
  5. package/dashboard/dist/assets/{DevicePage-CQts7ivB.js → DevicePage-DJ-H8_Oz.js} +1 -1
  6. package/dashboard/dist/assets/{DialogTitle-DqFsk26U.js → DialogTitle-BXPsx9HW.js} +1 -1
  7. package/dashboard/dist/assets/{FadeIn-HBBXW_3q.js → FadeIn-DDGzwGrv.js} +1 -1
  8. package/dashboard/dist/assets/{HeaderGithubStar-COD2HfaF.js → HeaderGithubStar-dbSUVZih.js} +1 -1
  9. package/dashboard/dist/assets/{IpCheckPage-Cn0l8-BQ.js → IpCheckPage-DIvpHrqI.js} +1 -1
  10. package/dashboard/dist/assets/{LandingPage-CmV1BMU4.js → LandingPage-BoNG4hkr.js} +1 -1
  11. package/dashboard/dist/assets/{LeaderboardAvatar-CiIpWZwb.js → LeaderboardAvatar-DRBoSOut.js} +1 -1
  12. package/dashboard/dist/assets/{LeaderboardPage-BU0mlR3g.js → LeaderboardPage-DAr4EXrF.js} +3 -3
  13. package/dashboard/dist/assets/{LeaderboardProfileModal-C49_3Xm9.js → LeaderboardProfileModal-DX4KnQBi.js} +3 -3
  14. package/dashboard/dist/assets/{LeaderboardProfilePage-Bh1n0BAM.js → LeaderboardProfilePage-DU7kjPuZ.js} +1 -1
  15. package/dashboard/dist/assets/{LimitsPage-fZAmwLWT.js → LimitsPage-2nakPy0e.js} +2 -2
  16. package/dashboard/dist/assets/{LocalOnlyNotice-D3rQdA-P.js → LocalOnlyNotice-BKzBNE-a.js} +1 -1
  17. package/dashboard/dist/assets/{LoginPage-enO4XP-c.js → LoginPage-FSNMPJhA.js} +1 -1
  18. package/dashboard/dist/assets/PopoverPopup-BCQmdc9t.js +1 -0
  19. package/dashboard/dist/assets/{Select-tT9x4ntD.js → Select-CGpkLtRU.js} +1 -1
  20. package/dashboard/dist/assets/{SelectItemText-C7F7eIm0.js → SelectItemText-CN5ejq4k.js} +1 -1
  21. package/dashboard/dist/assets/{SettingsPage-pDasZNU2.js → SettingsPage-244I2HMy.js} +1 -1
  22. package/dashboard/dist/assets/{SkillsPage-DEu7FY-2.js → SkillsPage-VtbiObMq.js} +1 -1
  23. package/dashboard/dist/assets/{WidgetsPage-DGcO7rbp.js → WidgetsPage-CWpeeZUH.js} +1 -1
  24. package/dashboard/dist/assets/{WrappedPage-D_1ID213.js → WrappedPage-Cr94-EYR.js} +1 -1
  25. package/dashboard/dist/assets/{agent-logos-DXQVg1xy.js → agent-logos-BlOvCoRm.js} +1 -1
  26. package/dashboard/dist/assets/{arrow-up-right-DNLo92Ba.js → arrow-up-right-DYB5rzeo.js} +1 -1
  27. package/dashboard/dist/assets/{download-DbBBBpJF.js → download-BIqrLJf0.js} +1 -1
  28. package/dashboard/dist/assets/{info-Bh5qTz6k.js → info-DoWx4rUB.js} +1 -1
  29. package/dashboard/dist/assets/{main-BIY3Nj6I.js → main-BN2u8ODm.js} +12 -10
  30. package/dashboard/dist/assets/{use-limits-display-prefs-B4iJ-bBc.js → use-limits-display-prefs-DY7luKuV.js} +1 -1
  31. package/dashboard/dist/assets/{use-native-settings-DHjPFDv8.js → use-native-settings-BEniEaPB.js} +1 -1
  32. package/dashboard/dist/assets/{use-usage-limits-odqe9OY7.js → use-usage-limits-BJ-7YuWn.js} +1 -1
  33. package/dashboard/dist/assets/{useCurrency-BsSZiZMP.js → useCurrency-CrsGLZiC.js} +1 -1
  34. package/dashboard/dist/assets/{useOpenInteractionType-BQhgq4rv.js → useOpenInteractionType-BqOY0u5X.js} +2 -2
  35. package/dashboard/dist/index.html +1 -1
  36. package/dashboard/dist/share.html +1 -1
  37. package/package.json +15 -7
  38. package/scripts/install-local-service.sh +2 -1
  39. package/src/lib/pricing/seed-snapshot.json +1 -1
  40. package/dashboard/dist/assets/DashboardPage-BZ5VFoBk.js +0 -19
  41. package/dashboard/dist/assets/PopoverPopup-pitJEpN1.js +0 -1
@@ -1 +1 @@
1
- import{c as Sr,bT as tn,bU as St,bV as nt,bW as rt,r as u,bX as Nn,bn as tt,b as Me,bw as Wt,bY as Er,b0 as Rt,bZ as Xt,bt as Ce,b_ as et,b$ as qe,c0 as pn,c1 as Je,bN as Ze,c2 as Bn,c3 as nn,c4 as bt,c5 as Pt,c6 as Cr,c7 as Un,c8 as Mr,c9 as rn,ca as on,cb as Nt,ak as sn,cc as Ar,bA as Lt,aY as X,cd as Wn,ce as Or,aX as xe,cf as xn,br as Tr,bu as xt,cg as _t,bs as Ir,bz as _n,ch as Gt,ci as vt,aW as Et,aZ as je,j as Ae,b4 as cn,a$ as $n,a_ as zn,b1 as Pr,b2 as Lr,b3 as ln,cj as Dr,u as jn,a as ct,ck as Vr,bJ as kr,cl as Fr,bM as Hr,cm as Nr,cn as Br,co as Ur,b5 as Yn,cp as $t}from"./main-BIY3Nj6I.js";import{s as Le,i as yn,v as Wr,d as qn,w as _r,P as $r,c as Kn,e as $e,x as zr,y as jr,z as Yr,u as qr,f as oe,b as Xn,h as Kr,a as j,k as Xr,l as Gr,S as Jr,p as Zr,j as Qr,I as eo,o as Gn,q as to,r as no}from"./useOpenInteractionType-BQhgq4rv.js";const ro=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],si=Sr("chevron-down",ro),oo=["top","right","bottom","left"],gt=Math.min,We=Math.max,Dt=Math.round,ft=Math.floor,Ke=e=>({x:e,y:e}),so={left:"right",right:"left",bottom:"top",top:"bottom"};function Jt(e,t,n){return We(e,gt(t,n))}function Qe(e,t){return typeof e=="function"?e(t):e}function Fe(e){return e.split("-")[0]}function ot(e){return e.split("-")[1]}function an(e){return e==="x"?"y":"x"}function un(e){return e==="y"?"height":"width"}function ze(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function fn(e){return an(ze(e))}function io(e,t,n){n===void 0&&(n=!1);const r=ot(e),s=fn(e),o=un(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(i=Vt(i)),[i,Vt(i)]}function co(e){const t=Vt(e);return[Zt(e),t,Zt(t)]}function Zt(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const wn=["left","right"],Rn=["right","left"],lo=["top","bottom"],ao=["bottom","top"];function uo(e,t,n){switch(e){case"top":case"bottom":return n?t?Rn:wn:t?wn:Rn;case"left":case"right":return t?lo:ao;default:return[]}}function fo(e,t,n,r){const s=ot(e);let o=uo(Fe(e),n==="start",r);return s&&(o=o.map(i=>i+"-"+s),t&&(o=o.concat(o.map(Zt)))),o}function Vt(e){const t=Fe(e);return so[t]+e.slice(t.length)}function go(e){return{top:0,right:0,bottom:0,left:0,...e}}function Jn(e){return typeof e!="number"?go(e):{top:e,right:e,bottom:e,left:e}}function kt(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function Ct(e,t,n){return Math.floor(e/t)!==n}function yt(e,t){return t<0||t>=e.current.length}function zt(e,t){return Ee(e,{disabledIndices:t})}function bn(e,t){return Ee(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Ee(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:s=1}={}){let o=t;do o+=n?-s:s;while(o>=0&&o<=e.current.length-1&&wt(e,o,r));return o}function mo(e,{event:t,orientation:n,loopFocus:r,rtl:s,cols:o,disabledIndices:i,minIndex:c,maxIndex:m,prevIndex:d,stopEvent:l=!1}){let a=d;const g=[],x={};let h=!1;{let f=null,b=-1;e.current.forEach((p,w)=>{if(p==null)return;const E=p.closest('[role="row"]');E&&(h=!0),(E!==f||b===-1)&&(f=E,b+=1,g[b]=[]),g[b].push(w),x[w]=b})}const y=h&&g.length>0&&g.some(f=>f.length!==o);function v(f){if(!y||d===-1)return;const b=x[d];if(b==null)return;const p=g[b].indexOf(d);let w=f==="up"?b-1:b+1;r&&(w<0?w=g.length-1:w>=g.length&&(w=0));const E=new Set;for(;w>=0&&w<g.length&&!E.has(w);){E.add(w);const M=g[w];if(M.length===0){w=f==="up"?w-1:w+1;continue}const C=Math.min(p,M.length-1);for(let O=C;O>=0;O-=1){const Y=M[O];if(!wt(e,Y,i))return Y}w=f==="up"?w-1:w+1,r&&(w<0?w=g.length-1:w>=g.length&&(w=0))}}if(t.key===tn){const f=v("up");if(f!==void 0)l&&Le(t),a=f;else{if(l&&Le(t),d===-1)a=m;else if(a=Ee(e,{startingIndex:a,amount:o,decrement:!0,disabledIndices:i}),r&&(d-o<c||a<0)){const b=d%o,p=m%o,w=m-(p-b);p===b?a=m:a=p>b?w:w-o}yt(e,a)&&(a=d)}}if(t.key===St){const f=v("down");f!==void 0?(l&&Le(t),a=f):(l&&Le(t),d===-1?a=c:(a=Ee(e,{startingIndex:d,amount:o,disabledIndices:i}),r&&d+o>m&&(a=Ee(e,{startingIndex:d%o-o,amount:o,disabledIndices:i}))),yt(e,a)&&(a=d))}if(n==="both"){const f=ft(d/o);t.key===(s?nt:rt)&&(l&&Le(t),d%o!==o-1?(a=Ee(e,{startingIndex:d,disabledIndices:i}),r&&Ct(a,o,f)&&(a=Ee(e,{startingIndex:d-d%o-1,disabledIndices:i}))):r&&(a=Ee(e,{startingIndex:d-d%o-1,disabledIndices:i})),Ct(a,o,f)&&(a=d)),t.key===(s?rt:nt)&&(l&&Le(t),d%o!==0?(a=Ee(e,{startingIndex:d,decrement:!0,disabledIndices:i}),r&&Ct(a,o,f)&&(a=Ee(e,{startingIndex:d+(o-d%o),decrement:!0,disabledIndices:i}))):r&&(a=Ee(e,{startingIndex:d+(o-d%o),decrement:!0,disabledIndices:i})),Ct(a,o,f)&&(a=d));const b=ft(m/o)===f;yt(e,a)&&(r&&b?a=t.key===(s?rt:nt)?m:Ee(e,{startingIndex:d-d%o-1,disabledIndices:i}):a=d)}return a}function ho(e,t,n){const r=[];let s=0;return e.forEach(({width:o,height:i},c)=>{let m=!1;for(n&&(s=0);!m;){const d=[];for(let l=0;l<o;l+=1)for(let a=0;a<i;a+=1)d.push(s+l+a*t);s%t+o<=t&&d.every(l=>r[l]==null)?(d.forEach(l=>{r[l]=c}),m=!0):s+=1}}),[...r]}function po(e,t,n,r,s){if(e===-1)return-1;const o=n.indexOf(e),i=t[e];switch(s){case"tl":return o;case"tr":return i?o+i.width-1:o;case"bl":return i?o+(i.height-1)*r:o;case"br":return n.lastIndexOf(e);default:return-1}}function xo(e,t){return t.flatMap((n,r)=>e.includes(n)?[r]:[])}function wt(e,t,n){if(typeof n=="function")return n(t);if(n)return n.includes(t);const r=e.current[t];return r?r.hasAttribute("disabled")||r.getAttribute("aria-disabled")==="true":!1}function yo(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.context.dataRef,{enabled:s=!0,event:o="click",toggle:i=!0,ignoreMouse:c=!1,stickIfOpen:m=!0,touchOpenDelay:d=0}=t,l=u.useRef(void 0),a=Nn(),g=tt(),x=u.useMemo(()=>({onPointerDown(h){l.current=h.pointerType},onMouseDown(h){const y=l.current,v=h.nativeEvent,f=n.select("open");if(h.button!==0||o==="click"||yn(y,!0)&&c)return;const b=r.current.openEvent,p=b?.type,w=n.select("domReferenceElement")!==h.currentTarget,E=f&&w||!(f&&i&&(!(b&&m)||p==="click"||p==="mousedown"));if(Er(v.target)){const C=Me(Wt,v,v.target);E&&y==="touch"&&d>0?g.start(d,()=>{n.setOpen(!0,C)}):n.setOpen(E,C);return}const M=h.currentTarget;a.request(()=>{const C=Me(Wt,v,M);E&&y==="touch"&&d>0?g.start(d,()=>{n.setOpen(!0,C)}):n.setOpen(E,C)})},onClick(h){if(o==="mousedown-only")return;const y=l.current;if(o==="mousedown"&&y){l.current=void 0;return}if(yn(y,!0)&&c)return;const v=n.select("open"),f=r.current.openEvent,b=n.select("domReferenceElement")!==h.currentTarget,p=v&&b||!(v&&i&&(!(f&&m)||Wr(f))),w=Me(Wt,h.nativeEvent,h.currentTarget);p&&y==="touch"&&d>0?g.start(d,()=>{n.setOpen(!0,w)}):n.setOpen(p,w)},onKeyDown(){l.current=void 0}}),[r,o,c,n,m,i,a,g,d]);return u.useMemo(()=>s?{reference:x}:Rt,[s,x])}function vn(e,t,n){let{reference:r,floating:s}=e;const o=ze(t),i=fn(t),c=un(i),m=Fe(t),d=o==="y",l=r.x+r.width/2-s.width/2,a=r.y+r.height/2-s.height/2,g=r[c]/2-s[c]/2;let x;switch(m){case"top":x={x:l,y:r.y-s.height};break;case"bottom":x={x:l,y:r.y+r.height};break;case"right":x={x:r.x+r.width,y:a};break;case"left":x={x:r.x-s.width,y:a};break;default:x={x:r.x,y:r.y}}switch(ot(t)){case"start":x[i]-=g*(n&&d?-1:1);break;case"end":x[i]+=g*(n&&d?-1:1);break}return x}async function wo(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:o,rects:i,elements:c,strategy:m}=e,{boundary:d="clippingAncestors",rootBoundary:l="viewport",elementContext:a="floating",altBoundary:g=!1,padding:x=0}=Qe(t,e),h=Jn(x),v=c[g?a==="floating"?"reference":"floating":a],f=kt(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(v)))==null||n?v:v.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(c.floating)),boundary:d,rootBoundary:l,strategy:m})),b=a==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,p=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c.floating)),w=await(o.isElement==null?void 0:o.isElement(p))?await(o.getScale==null?void 0:o.getScale(p))||{x:1,y:1}:{x:1,y:1},E=kt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:b,offsetParent:p,strategy:m}):b);return{top:(f.top-E.top+h.top)/w.y,bottom:(E.bottom-f.bottom+h.bottom)/w.y,left:(f.left-E.left+h.left)/w.x,right:(E.right-f.right+h.right)/w.x}}const Ro=50,bo=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,c=i.detectOverflow?i:{...i,detectOverflow:wo},m=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:s}),{x:l,y:a}=vn(d,r,m),g=r,x=0;const h={};for(let y=0;y<o.length;y++){const v=o[y];if(!v)continue;const{name:f,fn:b}=v,{x:p,y:w,data:E,reset:M}=await b({x:l,y:a,initialPlacement:r,placement:g,strategy:s,middlewareData:h,rects:d,platform:c,elements:{reference:e,floating:t}});l=p??l,a=w??a,h[f]={...h[f],...E},M&&x<Ro&&(x++,typeof M=="object"&&(M.placement&&(g=M.placement),M.rects&&(d=M.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:s}):M.rects),{x:l,y:a}=vn(d,g,m)),y=-1)}return{x:l,y:a,placement:g,strategy:s,middlewareData:h}},vo=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:o,rects:i,initialPlacement:c,platform:m,elements:d}=t,{mainAxis:l=!0,crossAxis:a=!0,fallbackPlacements:g,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:y=!0,...v}=Qe(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const f=Fe(s),b=ze(c),p=Fe(c)===c,w=await(m.isRTL==null?void 0:m.isRTL(d.floating)),E=g||(p||!y?[Vt(c)]:co(c)),M=h!=="none";!g&&M&&E.push(...fo(c,y,h,w));const C=[c,...E],O=await m.detectOverflow(t,v),Y=[];let q=((r=o.flip)==null?void 0:r.overflows)||[];if(l&&Y.push(O[f]),a){const K=io(s,i,w);Y.push(O[K[0]],O[K[1]])}if(q=[...q,{placement:s,overflows:Y}],!Y.every(K=>K<=0)){var N,W;const K=(((N=o.flip)==null?void 0:N.index)||0)+1,H=C[K];if(H&&(!(a==="alignment"?b!==ze(H):!1)||q.every(R=>ze(R.placement)===b?R.overflows[0]>0:!0)))return{data:{index:K,overflows:q},reset:{placement:H}};let P=(W=q.filter(B=>B.overflows[0]<=0).sort((B,R)=>B.overflows[1]-R.overflows[1])[0])==null?void 0:W.placement;if(!P)switch(x){case"bestFit":{var D;const B=(D=q.filter(R=>{if(M){const L=ze(R.placement);return L===b||L==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(L=>L>0).reduce((L,A)=>L+A,0)]).sort((R,L)=>R[1]-L[1])[0])==null?void 0:D[0];B&&(P=B);break}case"initialPlacement":P=c;break}if(s!==P)return{reset:{placement:P}}}return{}}}};function Sn(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function En(e){return oo.some(t=>e[t]>=0)}const So=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:s="referenceHidden",...o}=Qe(e,t);switch(s){case"referenceHidden":{const i=await r.detectOverflow(t,{...o,elementContext:"reference"}),c=Sn(i,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:En(c)}}}case"escaped":{const i=await r.detectOverflow(t,{...o,altBoundary:!0}),c=Sn(i,n.floating);return{data:{escapedOffsets:c,escaped:En(c)}}}default:return{}}}}},Zn=new Set(["left","top"]);async function Eo(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=Fe(n),c=ot(n),m=ze(n)==="y",d=Zn.has(i)?-1:1,l=o&&m?-1:1,a=Qe(t,e);let{mainAxis:g,crossAxis:x,alignmentAxis:h}=typeof a=="number"?{mainAxis:a,crossAxis:0,alignmentAxis:null}:{mainAxis:a.mainAxis||0,crossAxis:a.crossAxis||0,alignmentAxis:a.alignmentAxis};return c&&typeof h=="number"&&(x=c==="end"?h*-1:h),m?{x:x*l,y:g*d}:{x:g*d,y:x*l}}const Co=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:o,placement:i,middlewareData:c}=t,m=await Eo(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:s+m.x,y:o+m.y,data:{...m,placement:i}}}}},Mo=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:o}=t,{mainAxis:i=!0,crossAxis:c=!1,limiter:m={fn:f=>{let{x:b,y:p}=f;return{x:b,y:p}}},...d}=Qe(e,t),l={x:n,y:r},a=await o.detectOverflow(t,d),g=ze(Fe(s)),x=an(g);let h=l[x],y=l[g];if(i){const f=x==="y"?"top":"left",b=x==="y"?"bottom":"right",p=h+a[f],w=h-a[b];h=Jt(p,h,w)}if(c){const f=g==="y"?"top":"left",b=g==="y"?"bottom":"right",p=y+a[f],w=y-a[b];y=Jt(p,y,w)}const v=m.fn({...t,[x]:h,[g]:y});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[x]:i,[g]:c}}}}}},Ao=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:s,rects:o,middlewareData:i}=t,{offset:c=0,mainAxis:m=!0,crossAxis:d=!0}=Qe(e,t),l={x:n,y:r},a=ze(s),g=an(a);let x=l[g],h=l[a];const y=Qe(c,t),v=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(m){const p=g==="y"?"height":"width",w=o.reference[g]-o.floating[p]+v.mainAxis,E=o.reference[g]+o.reference[p]-v.mainAxis;x<w?x=w:x>E&&(x=E)}if(d){var f,b;const p=g==="y"?"width":"height",w=Zn.has(Fe(s)),E=o.reference[a]-o.floating[p]+(w&&((f=i.offset)==null?void 0:f[a])||0)+(w?0:v.crossAxis),M=o.reference[a]+o.reference[p]+(w?0:((b=i.offset)==null?void 0:b[a])||0)-(w?v.crossAxis:0);h<E?h=E:h>M&&(h=M)}return{[g]:x,[a]:h}}}},Oo=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:s,rects:o,platform:i,elements:c}=t,{apply:m=()=>{},...d}=Qe(e,t),l=await i.detectOverflow(t,d),a=Fe(s),g=ot(s),x=ze(s)==="y",{width:h,height:y}=o.floating;let v,f;a==="top"||a==="bottom"?(v=a,f=g===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(f=a,v=g==="end"?"top":"bottom");const b=y-l.top-l.bottom,p=h-l.left-l.right,w=gt(y-l[v],b),E=gt(h-l[f],p),M=!t.middlewareData.shift;let C=w,O=E;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(O=p),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=b),M&&!g){const q=We(l.left,0),N=We(l.right,0),W=We(l.top,0),D=We(l.bottom,0);x?O=h-2*(q!==0||N!==0?q+N:We(l.left,l.right)):C=y-2*(W!==0||D!==0?W+D:We(l.top,l.bottom))}await m({...t,availableWidth:O,availableHeight:C});const Y=await i.getDimensions(c.floating);return h!==Y.width||y!==Y.height?{reset:{rects:!0}}:{}}}};function Qn(e){const t=Je(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=Ze(e),o=s?e.offsetWidth:n,i=s?e.offsetHeight:r,c=Dt(n)!==o||Dt(r)!==i;return c&&(n=o,r=i),{width:n,height:r,$:c}}function dn(e){return Ce(e)?e:e.contextElement}function dt(e){const t=dn(e);if(!Ze(t))return Ke(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=Qn(t);let i=(o?Dt(n.width):n.width)/r,c=(o?Dt(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const To=Ke(0);function er(e){const t=qe(e);return!Bn()||!t.visualViewport?To:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Io(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==qe(e)?!1:t}function it(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=dn(e);let i=Ke(1);t&&(r?Ce(r)&&(i=dt(r)):i=dt(e));const c=Io(o,n,r)?er(o):Ke(0);let m=(s.left+c.x)/i.x,d=(s.top+c.y)/i.y,l=s.width/i.x,a=s.height/i.y;if(o){const g=qe(o),x=r&&Ce(r)?qe(r):r;let h=g,y=pn(h);for(;y&&r&&x!==h;){const v=dt(y),f=y.getBoundingClientRect(),b=Je(y),p=f.left+(y.clientLeft+parseFloat(b.paddingLeft))*v.x,w=f.top+(y.clientTop+parseFloat(b.paddingTop))*v.y;m*=v.x,d*=v.y,l*=v.x,a*=v.y,m+=p,d+=w,h=qe(y),y=pn(h)}}return kt({width:l,height:a,x:m,y:d})}function Bt(e,t){const n=Nt(e).scrollLeft;return t?t.left+n:it(et(e)).left+n}function tr(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Bt(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function Po(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",i=et(r),c=t?nn(t.floating):!1;if(r===i||c&&o)return n;let m={scrollLeft:0,scrollTop:0},d=Ke(1);const l=Ke(0),a=Ze(r);if((a||!a&&!o)&&((rn(r)!=="body"||on(i))&&(m=Nt(r)),a)){const x=it(r);d=dt(r),l.x=x.x+r.clientLeft,l.y=x.y+r.clientTop}const g=i&&!a&&!o?tr(i,m):Ke(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-m.scrollLeft*d.x+l.x+g.x,y:n.y*d.y-m.scrollTop*d.y+l.y+g.y}}function Lo(e){return Array.from(e.getClientRects())}function Do(e){const t=et(e),n=Nt(e),r=e.ownerDocument.body,s=We(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=We(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Bt(e);const c=-n.scrollTop;return Je(r).direction==="rtl"&&(i+=We(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:i,y:c}}const Cn=25;function Vo(e,t){const n=qe(e),r=et(e),s=n.visualViewport;let o=r.clientWidth,i=r.clientHeight,c=0,m=0;if(s){o=s.width,i=s.height;const l=Bn();(!l||l&&t==="fixed")&&(c=s.offsetLeft,m=s.offsetTop)}const d=Bt(r);if(d<=0){const l=r.ownerDocument,a=l.body,g=getComputedStyle(a),x=l.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,h=Math.abs(r.clientWidth-a.clientWidth-x);h<=Cn&&(o-=h)}else d<=Cn&&(o+=d);return{width:o,height:i,x:c,y:m}}function ko(e,t){const n=it(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=Ze(e)?dt(e):Ke(1),i=e.clientWidth*o.x,c=e.clientHeight*o.y,m=s*o.x,d=r*o.y;return{width:i,height:c,x:m,y:d}}function Mn(e,t,n){let r;if(t==="viewport")r=Vo(e,n);else if(t==="document")r=Do(et(e));else if(Ce(t))r=ko(t,n);else{const s=er(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return kt(r)}function nr(e,t){const n=bt(e);return n===t||!Ce(n)||Pt(n)?!1:Je(n).position==="fixed"||nr(n,t)}function Fo(e,t){const n=t.get(e);if(n)return n;let r=Xt(e,[],!1).filter(c=>Ce(c)&&rn(c)!=="body"),s=null;const o=Je(e).position==="fixed";let i=o?bt(e):e;for(;Ce(i)&&!Pt(i);){const c=Je(i),m=Un(i);!m&&c.position==="fixed"&&(s=null),(o?!m&&!s:!m&&c.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||on(i)&&!m&&nr(e,i))?r=r.filter(l=>l!==i):s=c,i=bt(i)}return t.set(e,r),r}function Ho(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const i=[...n==="clippingAncestors"?nn(t)?[]:Fo(t,this._c):[].concat(n),r],c=Mn(t,i[0],s);let m=c.top,d=c.right,l=c.bottom,a=c.left;for(let g=1;g<i.length;g++){const x=Mn(t,i[g],s);m=We(x.top,m),d=gt(x.right,d),l=gt(x.bottom,l),a=We(x.left,a)}return{width:d-a,height:l-m,x:a,y:m}}function No(e){const{width:t,height:n}=Qn(e);return{width:t,height:n}}function Bo(e,t,n){const r=Ze(t),s=et(t),o=n==="fixed",i=it(e,!0,o,t);let c={scrollLeft:0,scrollTop:0};const m=Ke(0);function d(){m.x=Bt(s)}if(r||!r&&!o)if((rn(t)!=="body"||on(s))&&(c=Nt(t)),r){const x=it(t,!0,o,t);m.x=x.x+t.clientLeft,m.y=x.y+t.clientTop}else s&&d();o&&!r&&s&&d();const l=s&&!r&&!o?tr(s,c):Ke(0),a=i.left+c.scrollLeft-m.x-l.x,g=i.top+c.scrollTop-m.y-l.y;return{x:a,y:g,width:i.width,height:i.height}}function jt(e){return Je(e).position==="static"}function An(e,t){if(!Ze(e)||Je(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return et(e)===n&&(n=n.ownerDocument.body),n}function rr(e,t){const n=qe(e);if(nn(e))return n;if(!Ze(e)){let s=bt(e);for(;s&&!Pt(s);){if(Ce(s)&&!jt(s))return s;s=bt(s)}return n}let r=An(e,t);for(;r&&Cr(r)&&jt(r);)r=An(r,t);return r&&Pt(r)&&jt(r)&&!Un(r)?n:r||Mr(e)||n}const Uo=async function(e){const t=this.getOffsetParent||rr,n=this.getDimensions,r=await n(e.floating);return{reference:Bo(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Wo(e){return Je(e).direction==="rtl"}const _o={convertOffsetParentRelativeRectToViewportRelativeRect:Po,getDocumentElement:et,getClippingRect:Ho,getOffsetParent:rr,getElementRects:Uo,getClientRects:Lo,getDimensions:No,getScale:dt,isElement:Ce,isRTL:Wo};function or(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function $o(e,t){let n=null,r;const s=et(e);function o(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function i(c,m){c===void 0&&(c=!1),m===void 0&&(m=1),o();const d=e.getBoundingClientRect(),{left:l,top:a,width:g,height:x}=d;if(c||t(),!g||!x)return;const h=ft(a),y=ft(s.clientWidth-(l+g)),v=ft(s.clientHeight-(a+x)),f=ft(l),p={rootMargin:-h+"px "+-y+"px "+-v+"px "+-f+"px",threshold:We(0,gt(1,m))||1};let w=!0;function E(M){const C=M[0].intersectionRatio;if(C!==m){if(!w)return i();C?i(!1,C):r=setTimeout(()=>{i(!1,1e-7)},1e3)}C===1&&!or(d,e.getBoundingClientRect())&&i(),w=!1}try{n=new IntersectionObserver(E,{...p,root:s.ownerDocument})}catch{n=new IntersectionObserver(E,p)}n.observe(e)}return i(!0),o}function On(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:m=!1}=r,d=dn(e),l=s||o?[...d?Xt(d):[],...t?Xt(t):[]]:[];l.forEach(f=>{s&&f.addEventListener("scroll",n,{passive:!0}),o&&f.addEventListener("resize",n)});const a=d&&c?$o(d,n):null;let g=-1,x=null;i&&(x=new ResizeObserver(f=>{let[b]=f;b&&b.target===d&&x&&t&&(x.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var p;(p=x)==null||p.observe(t)})),n()}),d&&!m&&x.observe(d),t&&x.observe(t));let h,y=m?it(e):null;m&&v();function v(){const f=it(e);y&&!or(y,f)&&n(),y=f,h=requestAnimationFrame(v)}return n(),()=>{var f;l.forEach(b=>{s&&b.removeEventListener("scroll",n),o&&b.removeEventListener("resize",n)}),a?.(),(f=x)==null||f.disconnect(),x=null,m&&cancelAnimationFrame(h)}}const zo=Co,jo=Mo,Yo=vo,qo=Oo,Ko=So,Xo=Ao,Go=(e,t,n)=>{const r=new Map,s={platform:_o,...n},o={...s.platform,_c:r};return bo(e,t,{...s,platform:o})};var Jo=typeof document<"u",Zo=function(){},Tt=Jo?u.useLayoutEffect:Zo;function Ft(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Ft(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const o=s[r];if(!(o==="_owner"&&e.$$typeof)&&!Ft(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function sr(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Tn(e,t){const n=sr(e);return Math.round(t*n)/n}function Yt(e){const t=u.useRef(e);return Tt(()=>{t.current=e}),t}function Qo(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:o,floating:i}={},transform:c=!0,whileElementsMounted:m,open:d}=e,[l,a]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,x]=u.useState(r);Ft(g,r)||x(r);const[h,y]=u.useState(null),[v,f]=u.useState(null),b=u.useCallback(R=>{R!==M.current&&(M.current=R,y(R))},[]),p=u.useCallback(R=>{R!==C.current&&(C.current=R,f(R))},[]),w=o||h,E=i||v,M=u.useRef(null),C=u.useRef(null),O=u.useRef(l),Y=m!=null,q=Yt(m),N=Yt(s),W=Yt(d),D=u.useCallback(()=>{if(!M.current||!C.current)return;const R={placement:t,strategy:n,middleware:g};N.current&&(R.platform=N.current),Go(M.current,C.current,R).then(L=>{const A={...L,isPositioned:W.current!==!1};K.current&&!Ft(O.current,A)&&(O.current=A,sn.flushSync(()=>{a(A)}))})},[g,t,n,N,W]);Tt(()=>{d===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,a(R=>({...R,isPositioned:!1})))},[d]);const K=u.useRef(!1);Tt(()=>(K.current=!0,()=>{K.current=!1}),[]),Tt(()=>{if(w&&(M.current=w),E&&(C.current=E),w&&E){if(q.current)return q.current(w,E,D);D()}},[w,E,D,q,Y]);const H=u.useMemo(()=>({reference:M,floating:C,setReference:b,setFloating:p}),[b,p]),P=u.useMemo(()=>({reference:w,floating:E}),[w,E]),B=u.useMemo(()=>{const R={position:n,left:0,top:0};if(!P.floating)return R;const L=Tn(P.floating,l.x),A=Tn(P.floating,l.y);return c?{...R,transform:"translate("+L+"px, "+A+"px)",...sr(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:L,top:A}},[n,c,P.floating,l.x,l.y]);return u.useMemo(()=>({...l,update:D,refs:H,elements:P,floatingStyles:B}),[l,D,H,P,B])}const es=(e,t)=>{const n=zo(e);return{name:n.name,fn:n.fn,options:[e,t]}},ts=(e,t)=>{const n=jo(e);return{name:n.name,fn:n.fn,options:[e,t]}},ns=(e,t)=>({fn:Xo(e).fn,options:[e,t]}),rs=(e,t)=>{const n=Yo(e);return{name:n.name,fn:n.fn,options:[e,t]}},os=(e,t)=>{const n=qo(e);return{name:n.name,fn:n.fn,options:[e,t]}},ss=(e,t)=>{const n=Ko(e);return{name:n.name,fn:n.fn,options:[e,t]}};function ir(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,s=Ar(),o=qn()!=null,i=Lt(()=>new _r({open:t,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:r.triggers??new $r,floatingId:s,nested:o,noEmit:e.noEmit||!1})).current;return X(()=>{const c={open:t,floatingId:s};r.reference!==void 0&&(c.referenceElement=r.reference,c.domReferenceElement=Ce(r.reference)?r.reference:null),r.floating!==void 0&&(c.floatingElement=r.floating),i.update(c)},[t,s,r.reference,r.floating,i]),i.context.onOpenChange=n,i.context.nested=o,i.context.noEmit=e.noEmit||!1,i}function is(e={}){const{nodeId:t,externalTree:n}=e,r=ir(e),s=e.rootContext||r,o={reference:s.useState("referenceElement"),floating:s.useState("floatingElement"),domReference:s.useState("domReferenceElement")},[i,c]=u.useState(null),m=u.useRef(null),d=Kn(n);X(()=>{o.domReference&&(m.current=o.domReference)},[o.domReference]);const l=Qo({...e,elements:{...o,...i&&{reference:i}}}),a=u.useCallback(C=>{const O=Ce(C)?{getBoundingClientRect:()=>C.getBoundingClientRect(),getClientRects:()=>C.getClientRects(),contextElement:C}:C;c(O),l.refs.setReference(O)},[l.refs]),[g,x]=u.useState(null),[h,y]=u.useState(null);s.useSyncedValue("referenceElement",g),s.useSyncedValue("domReferenceElement",Ce(g)?g:null),s.useSyncedValue("floatingElement",h);const v=u.useCallback(C=>{(Ce(C)||C===null)&&(m.current=C,x(C)),(Ce(l.refs.reference.current)||l.refs.reference.current===null||C!==null&&!Ce(C))&&l.refs.setReference(C)},[l.refs,x]),f=u.useCallback(C=>{y(C),l.refs.setFloating(C)},[l.refs]),b=u.useMemo(()=>({...l.refs,setReference:v,setFloating:f,setPositionReference:a,domReference:m}),[l.refs,v,f,a]),p=u.useMemo(()=>({...l.elements,domReference:o.domReference}),[l.elements,o.domReference]),w=s.useState("open"),E=s.useState("floatingId"),M=u.useMemo(()=>({...l,dataRef:s.context.dataRef,open:w,onOpenChange:s.setOpen,events:s.context.events,floatingId:E,refs:b,elements:p,nodeId:t,rootStore:s}),[l,b,p,t,s,w,E]);return X(()=>{s.context.dataRef.current.floatingContext=M;const C=d?.nodesRef.current.find(O=>O.id===t);C&&(C.context=M)}),u.useMemo(()=>({...l,context:M,refs:b,elements:p,rootStore:s}),[l,b,p,M,s])}const cs="Escape";function Ut(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Mt(e,t){return Ut(t,e===tn||e===St,e===nt||e===rt)}function qt(e,t,n){return Ut(t,e===St,n?e===nt:e===rt)||e==="Enter"||e===" "||e===""}function ls(e,t,n){return Ut(t,n?e===nt:e===rt,e===St)}function as(e,t,n,r){const s=n?e===rt:e===nt,o=e===tn;return t==="both"||t==="horizontal"&&r&&r>1?e===cs:Ut(t,s,o)}function us(e,t){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),s=n.useState("floatingElement"),o=n.useState("domReferenceElement"),i=n.context.dataRef,{listRef:c,activeIndex:m,onNavigate:d=()=>{},enabled:l=!0,selectedIndex:a=null,allowEscape:g=!1,loopFocus:x=!1,nested:h=!1,rtl:y=!1,virtual:v=!1,focusItemOnOpen:f="auto",focusItemOnHover:b=!0,openOnArrowKeyDown:p=!0,disabledIndices:w=void 0,orientation:E="vertical",parentOrientation:M,cols:C=1,scrollItemIntoView:O=!0,itemSizes:Y,dense:q=!1,id:N,resetOnPointerLeave:W=!0,externalTree:D}=t,K=Wn(s),H=$e(K),P=qn(),B=Kn(D);X(()=>{i.current.orientation=E},[i,E]);const R=Or(o),L=u.useRef(f),A=u.useRef(a??-1),I=u.useRef(null),ge=u.useRef(!0),k=xe(S=>{d(A.current===-1?null:A.current,S)}),ae=u.useRef(k),Q=u.useRef(!!s),V=u.useRef(r),z=u.useRef(!1),fe=u.useRef(!1),De=$e(w),U=$e(r),le=$e(O),te=$e(a),me=$e(W),Re=xe(()=>{function S(ne){v?B?.events.emit("virtualfocus",ne):zr(ne,{sync:z.current,preventScroll:!0})}const F=c.current[A.current],T=fe.current;F&&S(F),(z.current?ne=>ne():requestAnimationFrame)(()=>{const ne=c.current[A.current]||F;if(!ne)return;F||S(ne);const se=le.current;se&&G&&(T||!ge.current)&&ne.scrollIntoView?.(typeof se=="boolean"?{block:"nearest",inline:"nearest"}:se)})});X(()=>{l&&(r&&s?(A.current=a??-1,L.current&&a!=null&&(fe.current=!0,k())):Q.current&&(A.current=-1,ae.current()))},[l,r,s,a,k]),X(()=>{if(l){if(!r){z.current=!1;return}if(s)if(m==null){if(z.current=!1,te.current!=null)return;if(Q.current&&(A.current=-1,Re()),(!V.current||!Q.current)&&L.current&&(I.current!=null||L.current===!0&&I.current==null)){let S=0;const F=()=>{c.current[0]==null?(S<2&&(S?requestAnimationFrame:queueMicrotask)(F),S+=1):(A.current=I.current==null||qt(I.current,E,y)||h?zt(c):bn(c),I.current=null,k())};F()}}else yt(c,m)||(A.current=m,Re(),fe.current=!1)}},[l,r,s,m,te,h,c,E,y,k,Re,De]),X(()=>{if(!l||s||!B||v||!Q.current)return;const S=B.nodesRef.current,F=S.find(ne=>ne.id===P)?.context?.elements.floating,T=xn(Tr(s)),ee=S.some(ne=>ne.context&&xt(ne.context.elements.floating,T));F&&!ee&&ge.current&&F.focus({preventScroll:!0})},[l,s,B,P,v]),X(()=>{ae.current=k,V.current=r,Q.current=!!s}),X(()=>{r||(I.current=null,L.current=f)},[r,f]);const ue=m!=null,G=u.useMemo(()=>{function S(T){if(!U.current)return;const ee=c.current.indexOf(T.currentTarget);ee!==-1&&A.current!==ee&&(A.current=ee,k(T))}return{onFocus(T){z.current=!0,S(T)},onClick:({currentTarget:T})=>T.focus({preventScroll:!0}),onMouseMove(T){z.current=!0,fe.current=!1,b&&S(T)},onPointerLeave(T){if(!U.current||!ge.current||T.pointerType==="touch")return;z.current=!0;const ee=T.relatedTarget;!b||c.current.includes(ee)||me.current&&(A.current=-1,k(T),v||H.current?.focus({preventScroll:!0}))}}},[U,H,b,c,k,me,v]),J=u.useCallback(()=>M??B?.nodesRef.current.find(S=>S.id===P)?.context?.dataRef?.current.orientation,[P,B,M]),we=xe(S=>{if(ge.current=!1,z.current=!0,S.which===229||!U.current&&S.currentTarget===H.current)return;if(h&&as(S.key,E,y,C)){Mt(S.key,J())||Le(S),n.setOpen(!1,Me(_t,S.nativeEvent)),Ze(o)&&(v?B?.events.emit("virtualfocus",o):o.focus());return}const F=A.current,T=zt(c,w),ee=bn(c,w);if(R||(S.key==="Home"&&(Le(S),A.current=T,k(S)),S.key==="End"&&(Le(S),A.current=ee,k(S))),C>1){const ne=Y||Array.from({length:c.current.length},()=>({width:1,height:1})),se=ho(ne,C,q),ye=se.findIndex(ve=>ve!=null&&!wt(c,ve,w)),he=se.reduce((ve,Te,_e)=>Te!=null&&!wt(c,Te,w)?_e:ve,-1),Oe=se[mo({current:se.map(ve=>ve!=null?c.current[ve]:null)},{event:S,orientation:E,loopFocus:x,rtl:y,cols:C,disabledIndices:xo([...(typeof w!="function"?w:null)||c.current.map((ve,Te)=>wt(c,Te,w)?Te:void 0),void 0],se),minIndex:ye,maxIndex:he,prevIndex:po(A.current>ee?T:A.current,ne,se,C,S.key===St?"bl":S.key===(y?nt:rt)?"tr":"tl"),stopEvent:!0})];if(Oe!=null&&(A.current=Oe,k(S)),E==="both")return}if(Mt(S.key,E)){if(Le(S),r&&!v&&xn(S.currentTarget.ownerDocument)===S.currentTarget){A.current=qt(S.key,E,y)?T:ee,k(S);return}qt(S.key,E,y)?x?F>=ee?g&&F!==c.current.length?A.current=-1:(z.current=!1,A.current=T):A.current=Ee(c,{startingIndex:F,disabledIndices:w}):A.current=Math.min(ee,Ee(c,{startingIndex:F,disabledIndices:w})):x?F<=T?g&&F!==-1?A.current=c.current.length:(z.current=!1,A.current=ee):A.current=Ee(c,{startingIndex:F,decrement:!0,disabledIndices:w}):A.current=Math.max(T,Ee(c,{startingIndex:F,decrement:!0,disabledIndices:w})),yt(c,A.current)&&(A.current=-1),k(S)}}),re=u.useMemo(()=>v&&r&&ue&&{"aria-activedescendant":`${N}-${m}`},[v,r,ue,N,m]),Z=u.useMemo(()=>({"aria-orientation":E==="both"?void 0:E,...R?{}:re,onKeyDown(S){if(S.key==="Tab"&&S.shiftKey&&r&&!v){const F=Ir(S.nativeEvent);if(F&&!xt(H.current,F))return;Le(S),n.setOpen(!1,Me(_n,S.nativeEvent)),Ze(o)&&o.focus();return}we(S)},onPointerMove(){ge.current=!0}}),[re,we,H,E,R,n,r,v,o]),be=u.useMemo(()=>{function S(T){f==="auto"&&jr(T.nativeEvent)&&(L.current=!v)}function F(T){L.current=f,f==="auto"&&Yr(T.nativeEvent)&&(L.current=!0)}return{onKeyDown(T){const ee=n.select("open");ge.current=!1;const ne=T.key.startsWith("Arrow"),se=ls(T.key,J(),y),ye=Mt(T.key,E),he=(h?se:ye)||T.key==="Enter"||T.key.trim()==="";if(v&&ee)return we(T);if(!(!ee&&!p&&ne)){if(he){const Oe=Mt(T.key,J());I.current=h&&Oe?null:T.key}if(h){se&&(Le(T),ee?(A.current=zt(c,De.current),k(T)):n.setOpen(!0,Me(_t,T.nativeEvent,T.currentTarget)));return}ye&&(te.current!=null&&(A.current=te.current),Le(T),!ee&&p?n.setOpen(!0,Me(_t,T.nativeEvent,T.currentTarget)):we(T),ee&&k(T))}},onFocus(T){n.select("open")&&!v&&(A.current=-1,k(T))},onPointerDown:F,onPointerEnter:F,onMouseDown:S,onClick:S}},[we,De,f,c,h,k,n,p,E,J,y,te,v]),Ve=u.useMemo(()=>({...re,...be}),[re,be]);return u.useMemo(()=>l?{reference:Ve,floating:Z,item:G,trigger:be}:{},[l,Ve,Z,be,G])}function fs(e,t){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),s=n.context.dataRef,{listRef:o,activeIndex:i,onMatch:c,onTypingChange:m,enabled:d=!0,findMatch:l=null,resetMs:a=750,ignoreKeys:g=Gt,selectedIndex:x=null}=t,h=tt(),y=u.useRef(""),v=u.useRef(x??i??-1),f=u.useRef(null);X(()=>{r&&(h.clear(),f.current=null,y.current="")},[r,h]),X(()=>{r&&y.current===""&&(v.current=x??i??-1)},[r,x,i]);const b=xe(M=>{M?s.current.typing||(s.current.typing=M,m?.(M)):s.current.typing&&(s.current.typing=M,m?.(M))}),p=xe(M=>{function C(W,D,K){const H=l?l(D,K):D.find(P=>P?.toLocaleLowerCase().indexOf(K.toLocaleLowerCase())===0);return H?W.indexOf(H):-1}const O=o.current;if(y.current.length>0&&y.current[0]!==" "&&(C(O,O,y.current)===-1?b(!1):M.key===" "&&Le(M)),O==null||g.includes(M.key)||M.key.length!==1||M.ctrlKey||M.metaKey||M.altKey)return;r&&M.key!==" "&&(Le(M),b(!0)),O.every(W=>W?W[0]?.toLocaleLowerCase()!==W[1]?.toLocaleLowerCase():!0)&&y.current===M.key&&(y.current="",v.current=f.current),y.current+=M.key,h.start(a,()=>{y.current="",v.current=f.current,b(!1)});const q=v.current,N=C(O,[...O.slice((q||0)+1),...O.slice(0,(q||0)+1)],y.current);N!==-1?(c?.(N),f.current=N):M.key!==" "&&(y.current="",b(!1))}),w=u.useMemo(()=>({onKeyDown:p}),[p]),E=u.useMemo(()=>({onKeyDown:p,onKeyUp(M){M.key===" "&&b(!1)}}),[p,b]);return u.useMemo(()=>d?{reference:w,floating:E}:{},[d,w,E])}const ds=u.createContext(void 0);function gs(){return u.useContext(ds)?.direction??"ltr"}const ms=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:o,platform:i,elements:c,middlewareData:m}=t,{element:d,padding:l=0,offsetParent:a="real"}=Qe(e,t)||{};if(d==null)return{};const g=Jn(l),x={x:n,y:r},h=fn(s),y=un(h),v=await i.getDimensions(d),f=h==="y",b=f?"top":"left",p=f?"bottom":"right",w=f?"clientHeight":"clientWidth",E=o.reference[y]+o.reference[h]-x[h]-o.floating[y],M=x[h]-o.reference[h],C=a==="real"?await i.getOffsetParent?.(d):c.floating;let O=c.floating[w]||o.floating[y];(!O||!await i.isElement?.(C))&&(O=c.floating[w]||o.floating[y]);const Y=E/2-M/2,q=O/2-v[y]/2-1,N=Math.min(g[b],q),W=Math.min(g[p],q),D=N,K=O-v[y]-W,H=O/2-v[y]/2+Y,P=Jt(D,H,K),B=!m.arrow&&ot(s)!=null&&H!==P&&o.reference[y]/2-(H<D?N:W)-v[y]/2<0,R=B?H<D?H-D:H-K:0;return{[h]:x[h]+R,data:{[h]:P,centerOffset:H-P-R,...B&&{alignmentOffset:R}},reset:B}}}),hs=(e,t)=>({...ms(e),options:[e,t]}),ps={name:"hide",async fn(e){const{width:t,height:n,x:r,y:s}=e.rects.reference,o=t===0&&n===0&&r===0&&s===0;return{data:{referenceHidden:(await ss().fn(e)).data?.referenceHidden||o}}}},It={sideX:"left",sideY:"top"},ii={name:"adaptiveOrigin",async fn(e){const{x:t,y:n,rects:{floating:r},elements:{floating:s},platform:o,strategy:i,placement:c}=e,m=qe(s),d=m.getComputedStyle(s);if(!(d.transitionDuration!=="0s"&&d.transitionDuration!==""))return{x:t,y:n,data:It};const a=await o.getOffsetParent?.(s);let g={width:0,height:0};if(i==="fixed"&&m?.visualViewport)g={width:m.visualViewport.width,height:m.visualViewport.height};else if(a===m){const b=vt(s);g={width:b.documentElement.clientWidth,height:b.documentElement.clientHeight}}else await o.isElement?.(a)&&(g=await o.getDimensions(a));const x=Fe(c);let h=t,y=n;x==="left"&&(h=g.width-(t+r.width)),x==="top"&&(y=g.height-(n+r.height));const v=x==="left"?"right":It.sideX,f=x==="top"?"bottom":It.sideY;return{x:h,y,data:{sideX:v,sideY:f}}}};function cr(e,t,n){const r=e==="inline-start"||e==="inline-end";return{top:"top",right:r?n?"inline-start":"inline-end":"right",bottom:"bottom",left:r?n?"inline-end":"inline-start":"left"}[t]}function In(e,t,n){const{rects:r,placement:s}=e;return{side:cr(t,Fe(s),n),align:ot(s)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function xs(e){const{anchor:t,positionMethod:n="absolute",side:r="bottom",sideOffset:s=0,align:o="center",alignOffset:i=0,collisionBoundary:c,collisionPadding:m=5,sticky:d=!1,arrowPadding:l=5,disableAnchorTracking:a=!1,keepMounted:g=!1,floatingRootContext:x,mounted:h,collisionAvoidance:y,shiftCrossAxis:v=!1,nodeId:f,adaptiveOrigin:b,lazyFlip:p=!1,externalTree:w}=e,[E,M]=u.useState(null);!h&&E!==null&&M(null);const C=y.side||"flip",O=y.align||"flip",Y=y.fallbackAxisSide||"end",q=typeof t=="function"?t:void 0,N=xe(q),W=q?N:t,D=$e(t),H=gs()==="rtl",P=E||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":H?"left":"right","inline-start":H?"right":"left"}[r],B=o==="center"?P:`${P}-${o}`;let R=m;const L=1,A=r==="bottom"?L:0,I=r==="top"?L:0,ge=r==="right"?L:0,k=r==="left"?L:0;typeof R=="number"?R={top:R+A,right:R+k,bottom:R+I,left:R+ge}:R&&(R={top:(R.top||0)+A,right:(R.right||0)+k,bottom:(R.bottom||0)+I,left:(R.left||0)+ge});const ae={boundary:c==="clipping-ancestors"?"clippingAncestors":c,padding:R},Q=u.useRef(null),V=$e(s),z=$e(i),U=[es(ce=>{const pe=In(ce,r,H),de=typeof V.current=="function"?V.current(pe):V.current,Se=typeof z.current=="function"?z.current(pe):z.current;return{mainAxis:de,crossAxis:Se,alignmentAxis:Se}},[typeof s!="function"?s:0,typeof i!="function"?i:0,H,r])],le=O==="none"&&C!=="shift",te=!le&&(d||v||C==="shift"),me=C==="none"?null:rs({...ae,padding:{top:R.top+L,right:R.right+L,bottom:R.bottom+L,left:R.left+L},mainAxis:!v&&C==="flip",crossAxis:O==="flip"?"alignment":!1,fallbackAxisSideDirection:Y}),Re=le?null:ts(ce=>{const pe=vt(ce.elements.floating).documentElement;return{...ae,rootBoundary:v?{x:0,y:0,width:pe.clientWidth,height:pe.clientHeight}:void 0,mainAxis:O!=="none",crossAxis:te,limiter:d||v?void 0:ns(de=>{if(!Q.current)return{};const{width:Se,height:Be}=Q.current.getBoundingClientRect(),Ue=ze(Fe(de.placement)),Xe=Ue==="y"?Se:Be,Ge=Ue==="y"?R.left+R.right:R.top+R.bottom;return{offset:Xe/2+Ge/2}})}},[ae,d,v,R,O]);C==="shift"||O==="shift"||o==="center"?U.push(Re,me):U.push(me,Re),U.push(os({...ae,apply({elements:{floating:ce},rects:{reference:pe},availableWidth:de,availableHeight:Se}){Object.entries({"--available-width":`${de}px`,"--available-height":`${Se}px`,"--anchor-width":`${pe.width}px`,"--anchor-height":`${pe.height}px`}).forEach(([Be,Ue])=>{ce.style.setProperty(Be,Ue)})}}),hs(()=>({element:Q.current||document.createElement("div"),padding:l,offsetParent:"floating"}),[l]),{name:"transformOrigin",fn(ce){const{elements:pe,middlewareData:de,placement:Se,rects:Be,y:Ue}=ce,Xe=Fe(Se),Ge=ze(Xe),st=Q.current,at=de.arrow?.x||0,ht=de.arrow?.y||0,pt=st?.clientWidth||0,$=st?.clientHeight||0,ie=at+pt/2,Ie=ht+$/2,ke=Math.abs(de.shift?.y||0),Pe=Be.reference.height/2,Ye=typeof s=="function"?s(In(ce,r,H)):s,hn=ke>Ye,br={top:`${ie}px calc(100% + ${Ye}px)`,bottom:`${ie}px ${-Ye}px`,left:`calc(100% + ${Ye}px) ${Ie}px`,right:`${-Ye}px ${Ie}px`}[Xe],vr=`${ie}px ${Be.reference.y+Pe-Ue}px`;return pe.floating.style.setProperty("--transform-origin",te&&Ge==="y"&&hn?vr:br),{}}},ps,b),X(()=>{!h&&x&&x.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[h,x]);const ue=u.useMemo(()=>({elementResize:!a&&typeof ResizeObserver<"u",layoutShift:!a&&typeof IntersectionObserver<"u"}),[a]),{refs:G,elements:J,x:we,y:re,middlewareData:Z,update:be,placement:Ve,context:S,isPositioned:F,floatingStyles:T}=is({rootContext:x,placement:B,middleware:U,strategy:n,whileElementsMounted:g?void 0:(...ce)=>On(...ce,ue),nodeId:f,externalTree:w}),{sideX:ee,sideY:ne}=Z.adaptiveOrigin||It,se=F?n:"fixed",ye=u.useMemo(()=>b?{position:se,[ee]:we,[ne]:re}:{position:se,...T},[b,se,ee,we,ne,re,T]),he=u.useRef(null);X(()=>{if(!h)return;const ce=D.current,pe=typeof ce=="function"?ce():ce,Se=(Pn(pe)?pe.current:pe)||null||null;Se!==he.current&&(G.setPositionReference(Se),he.current=Se)},[h,G,W,D]),u.useEffect(()=>{if(!h)return;const ce=D.current;typeof ce!="function"&&Pn(ce)&&ce.current!==he.current&&(G.setPositionReference(ce.current),he.current=ce.current)},[h,G,W,D]),u.useEffect(()=>{if(g&&h&&J.domReference&&J.floating)return On(J.domReference,J.floating,be,ue)},[g,h,J,be,ue]);const Oe=Fe(Ve),ve=cr(r,Oe,H),Te=ot(Ve)||"center",_e=!!Z.hide?.referenceHidden;X(()=>{p&&h&&F&&M(Oe)},[p,h,F,Oe]);const He=u.useMemo(()=>({position:"absolute",top:Z.arrow?.y,left:Z.arrow?.x}),[Z.arrow]),Ne=Z.arrow?.centerOffset!==0;return u.useMemo(()=>({positionerStyles:ye,arrowStyles:He,arrowRef:Q,arrowUncentered:Ne,side:ve,align:Te,physicalSide:Oe,anchorHidden:_e,refs:G,context:S,isPositioned:F,update:be}),[ye,He,Q,Ne,ve,Te,Oe,_e,G,S,F,be])}function Pn(e){return e!=null&&"current"in e}function ys(e){const t=u.useRef(!0);t.current&&(t.current=!1,e())}function Ln({controlled:e,default:t,name:n,state:r="value"}){const{current:s}=u.useRef(e!==void 0),[o,i]=u.useState(t),c=s?e:o,m=u.useCallback(d=>{s||i(d)},[]);return[c,m]}const lr=u.createContext(null),ar=u.createContext(null);function lt(){const e=u.useContext(lr);if(e===null)throw new Error(Et(60));return e}function ur(){const e=u.useContext(ar);if(e===null)throw new Error(Et(61));return e}let Dn=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const ws={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Rs={valid(e){return e===null?null:e?{[Dn.valid]:""}:{[Dn.invalid]:""}}},bs=u.createContext({invalid:void 0,name:void 0,validityData:{state:ws,errors:[],error:"",value:"",initialValue:null},setValidityData:je,disabled:void 0,touched:!1,setTouched:je,dirty:!1,setDirty:je,filled:!1,setFilled:je,focused:!1,setFocused:je,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:{disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},markedDirtyRef:{current:!1},validation:{getValidationProps:(e=Rt)=>e,getInputValidationProps:(e=Rt)=>e,inputRef:{current:null},commit:async()=>{}}});function gn(e=!0){const t=u.useContext(bs);if(t.setValidityData===je&&!e)throw new Error(Et(28));return t}const vs=u.createContext({controlId:void 0,setControlId:je,labelId:void 0,setLabelId:je,messageIds:[],setMessageIds:je,getDescriptionProps:e=>e});function fr(){return u.useContext(vs)}function dr(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:s,setControlId:o}=fr(),i=qr(t);return X(()=>{if(!(!n&&!t||o===je)){if(n){const c=r?.current;Ce(c)&&c.closest("label")!=null?o(t??null):o(s??i)}else t&&o(t);return()=>{t&&o(void 0)}}},[t,r,s,o,n,i]),s??i}const Ss=(e,t)=>Object.is(e,t);function mt(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Kt(e,t,n){return!e||e.length===0?!1:e.some(r=>r===void 0?!1:mt(r,t,n))}function Qt(e,t,n){return!e||e.length===0?-1:e.findIndex(r=>r===void 0?!1:mt(r,t,n))}function Es(e,t,n){return e.filter(r=>!mt(r,t,n))}function en(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function gr(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Cs(e){if(!Array.isArray(e))return e!=null&&!("null"in e);if(gr(e)){for(const t of e)for(const n of t.items)if(n&&n.value==null&&n.label!=null)return!0;return!1}for(const t of e)if(t&&t.value==null&&t.label!=null)return!0;return!1}function Ms(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return en(e)}function ut(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?en(e.value):en(e)}function mr(e,t,n){function r(){return Ms(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){const s=gr(t)?t.flatMap(o=>o.items):t;if(e==null||typeof e!="object"){const o=s.find(i=>i.value===e);return o&&o.label!=null?o.label:r()}if("value"in e){const o=s.find(i=>i&&i.value===e.value);if(o&&o.label!=null)return o.label}}return r()}function As(e,t,n){return e.reduce((r,s,o)=>(o>0&&r.push(", "),r.push(Ae.jsx(u.Fragment,{children:mr(s,t,n)},o)),r),[])}const _={id:oe(e=>e.id),modal:oe(e=>e.modal),multiple:oe(e=>e.multiple),items:oe(e=>e.items),itemToStringLabel:oe(e=>e.itemToStringLabel),itemToStringValue:oe(e=>e.itemToStringValue),isItemEqualToValue:oe(e=>e.isItemEqualToValue),value:oe(e=>e.value),hasSelectedValue:oe(e=>{const{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:ut(t,r)!==""}),hasNullItemLabel:oe((e,t)=>t?Cs(e.items):!1),open:oe(e=>e.open),mounted:oe(e=>e.mounted),forceMount:oe(e=>e.forceMount),transitionStatus:oe(e=>e.transitionStatus),openMethod:oe(e=>e.openMethod),activeIndex:oe(e=>e.activeIndex),selectedIndex:oe(e=>e.selectedIndex),isActive:oe((e,t)=>e.activeIndex===t),isSelected:oe((e,t,n)=>{const r=e.isItemEqualToValue,s=e.value;return e.multiple?Array.isArray(s)&&s.some(o=>mt(o,n,r)):e.selectedIndex===t&&e.selectedIndex!==null?!0:mt(s,n,r)}),isSelectedByFocus:oe((e,t)=>e.selectedIndex===t),popupProps:oe(e=>e.popupProps),triggerProps:oe(e=>e.triggerProps),triggerElement:oe(e=>e.triggerElement),positionerElement:oe(e=>e.positionerElement),listElement:oe(e=>e.listElement),scrollUpArrowVisible:oe(e=>e.scrollUpArrowVisible),scrollDownArrowVisible:oe(e=>e.scrollDownArrowVisible),hasScrollArrows:oe(e=>e.hasScrollArrows)},Os=u.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:je,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function hr(){return u.useContext(Os)}function Ts(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}function Is(e){const{enabled:t=!0,value:n,id:r,name:s,controlRef:o,commit:i}=e,{formRef:c}=hr(),{invalid:m,markedDirtyRef:d,validityData:l,setValidityData:a}=gn(),g=xe(e.getValue);X(()=>{if(!t)return;let x=n;x===void 0&&(x=g()),l.initialValue===null&&x!==null&&a(h=>({...h,initialValue:x}))},[t,a,n,l.initialValue,g]),X(()=>{!t||!r||c.current.fields.set(r,{getValue:g,name:s,controlRef:o,validityData:Ts(l,m),validate(x=!0){let h=n;h===void 0&&(h=g()),d.current=!0,x?sn.flushSync(()=>i(h)):i(h)}})},[i,o,t,c,g,r,m,d,s,l,n]),X(()=>{const x=c.current.fields;return()=>{r&&x.delete(r)}},[c,r])}function Ps(e,t){const n=u.useRef(e),r=xe(t);X(()=>{n.current!==e&&r(n.current)},[e,r]),X(()=>{n.current=e},[e])}function ci(e){const{id:t,value:n,defaultValue:r=null,onValueChange:s,open:o,defaultOpen:i=!1,onOpenChange:c,name:m,disabled:d=!1,readOnly:l=!1,required:a=!1,modal:g=!0,actionsRef:x,inputRef:h,onOpenChangeComplete:y,items:v,multiple:f=!1,itemToStringLabel:b,itemToStringValue:p,isItemEqualToValue:w=Ss,highlightItemOnHover:E=!0,children:M}=e,{clearErrors:C}=hr(),{setDirty:O,setTouched:Y,setFocused:q,shouldValidateOnChange:N,validityData:W,setFilled:D,name:K,disabled:H,validation:P,validationMode:B}=gn(),R=dr({id:t}),L=H||d,A=K??m,[I,ge]=Ln({controlled:n,default:f?r??Gt:r,name:"Select",state:"value"}),[k,ae]=Ln({controlled:o,default:i,name:"Select",state:"open"}),Q=u.useRef([]),V=u.useRef([]),z=u.useRef(null),fe=u.useRef(null),De=u.useRef(0),U=u.useRef(null),le=u.useRef([]),te=u.useRef(!1),me=u.useRef(!1),Re=u.useRef(null),ue=u.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}),G=u.useRef(!1),{mounted:J,setMounted:we,transitionStatus:re}=Xn(k),{openMethod:Z,triggerProps:be,reset:Ve}=Kr(k),S=Lt(()=>new Jr({id:R,modal:g,multiple:f,itemToStringLabel:b,itemToStringValue:p,isItemEqualToValue:w,value:I,open:k,mounted:J,transitionStatus:re,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,F=j(S,_.activeIndex),T=j(S,_.selectedIndex),ee=j(S,_.triggerElement),ne=j(S,_.positionerElement),se=u.useMemo(()=>f&&Array.isArray(I)&&I.length===0?"":ut(I,p),[f,I,p]),ye=u.useMemo(()=>f&&Array.isArray(I)?I.map($=>ut($,p)):ut(I,p),[f,I,p]),he=$e(S.state.triggerElement);Is({id:R,commit:P.commit,value:I,controlRef:he,name:A,getValue:()=>ye});const Oe=u.useRef(I);X(()=>{I!==Oe.current&&S.set("forceMount",!0)},[S,I]),X(()=>{D(f?Array.isArray(I)&&I.length>0:I!=null)},[f,I,D]),X(function(){if(k)return;const ie=le.current;if(f){const ke=Array.isArray(I)?I:[];if(ke.length===0){S.set("selectedIndex",null);return}const Pe=ke[ke.length-1],Ye=Qt(ie,Pe,w);S.set("selectedIndex",Ye===-1?null:Ye);return}const Ie=Qt(ie,I,w);S.set("selectedIndex",Ie===-1?null:Ie)},[f,k,I,le,w,S]),Ps(I,()=>{C(A),O(I!==W.initialValue),N()?P.commit(I):P.commit(I,!0)});const ve=xe(($,ie)=>{if(c?.($,ie),!ie.isCanceled&&(ae($),!$&&(ie.reason===_n||ie.reason===Dr)&&(Y(!0),q(!1),B==="onBlur"&&P.commit(I)),!$&&S.state.activeIndex!==null)){const Ie=Q.current[S.state.activeIndex];queueMicrotask(()=>{Ie?.setAttribute("tabindex","-1")})}}),Te=xe(()=>{we(!1),S.set("activeIndex",null),Ve(),y?.(!1)});cn({enabled:!x,open:k,ref:z,onComplete(){k||Te()}}),u.useImperativeHandle(x,()=>({unmount:Te}),[Te]);const _e=xe(($,ie)=>{s?.($,ie),!ie.isCanceled&&ge($)}),He=xe(()=>{const $=S.state.listElement||z.current;if(!$)return;const ie=$.scrollTop,Ie=$.scrollTop+$.clientHeight,ke=ie>1,Pe=Ie<$.scrollHeight-1;S.state.scrollUpArrowVisible!==ke&&S.set("scrollUpArrowVisible",ke),S.state.scrollDownArrowVisible!==Pe&&S.set("scrollDownArrowVisible",Pe)}),Ne=ir({open:k,onOpenChange:ve,elements:{reference:ee,floating:ne}}),ce=yo(Ne,{enabled:!l&&!L,event:"mousedown"}),pe=Xr(Ne,{bubbles:!1}),de=us(Ne,{enabled:!l&&!L,listRef:Q,activeIndex:F,selectedIndex:T,disabledIndices:Gt,onNavigate($){$===null&&!k||S.set("activeIndex",$)},focusItemOnHover:!1}),Se=fs(Ne,{enabled:!l&&!L&&(k||!f),listRef:V,activeIndex:F,selectedIndex:T,onMatch($){k?S.set("activeIndex",$):_e(le.current[$],Me("none"))},onTypingChange($){te.current=$}}),{getReferenceProps:Be,getFloatingProps:Ue,getItemProps:Xe}=Gr([ce,pe,de,Se]),Ge=u.useMemo(()=>$n(Be(),be,R?{id:R}:Rt),[Be,be,R]);ys(()=>{S.update({popupProps:Ue(),triggerProps:Ge})}),X(()=>{S.update({id:R,modal:g,multiple:f,value:I,open:k,mounted:J,transitionStatus:re,popupProps:Ue(),triggerProps:Ge,items:v,itemToStringLabel:b,itemToStringValue:p,isItemEqualToValue:w,openMethod:Z})},[S,R,g,f,I,k,J,re,Ue,Ge,v,b,p,w,Z]);const st=u.useMemo(()=>({store:S,name:A,required:a,disabled:L,readOnly:l,multiple:f,itemToStringLabel:b,itemToStringValue:p,highlightItemOnHover:E,setValue:_e,setOpen:ve,listRef:Q,popupRef:z,scrollHandlerRef:fe,handleScrollArrowVisibility:He,scrollArrowsMountedCountRef:De,getItemProps:Xe,events:Ne.context.events,valueRef:U,valuesRef:le,labelsRef:V,typingRef:te,selectionRef:ue,selectedItemTextRef:Re,validation:P,onOpenChangeComplete:y,keyboardActiveRef:me,alignItemWithTriggerActiveRef:G,initialValueRef:Oe}),[S,A,a,L,l,f,b,p,E,_e,ve,Xe,Ne.context.events,P,y,He]),at=zn(h,P.inputRef),ht=f&&Array.isArray(I)&&I.length>0,pt=u.useMemo(()=>!f||!Array.isArray(I)||!A?null:I.map($=>{const ie=ut($,p);return Ae.jsx("input",{type:"hidden",name:A,value:ie},ie)}),[f,I,A,p]);return Ae.jsx(lr.Provider,{value:st,children:Ae.jsxs(ar.Provider,{value:Ne,children:[M,Ae.jsx("input",{...P.getInputValidationProps({onFocus(){S.state.triggerElement?.focus({focusVisible:!0})},onChange($){if($.nativeEvent.defaultPrevented)return;const ie=$.target.value,Ie=Me(ln,$.nativeEvent);function ke(){if(f)return;const Pe=le.current.find(Ye=>ut(Ye,p).toLowerCase()===ie.toLowerCase());Pe!=null&&(O(Pe!==W.initialValue),_e(Pe,Ie),N()&&P.commit(Pe))}S.set("forceMount",!0),queueMicrotask(ke)}}),name:f?void 0:A,value:se,disabled:L,required:a&&!ht,readOnly:l,ref:at,style:A?Pr:Lr,tabIndex:-1,"aria-hidden":!0}),pt]})})}function Ls(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e,"::before"),r=window.getComputedStyle(e,"::after");if(!(n.content!=="none"||r.content!=="none"))return t;const o=parseFloat(n.width)||0,i=parseFloat(n.height)||0,c=parseFloat(r.width)||0,m=parseFloat(r.height)||0,d=Math.max(t.width,o,c),l=Math.max(t.height,i,m),a=d-t.width,g=l-t.height;return{left:t.left-a/2,right:t.right+a/2,top:t.top-g/2,bottom:t.bottom+g/2}}const At=2,Ds=400,Vn=200,Vs={...Zr,...Rs,value:()=>null},li=u.forwardRef(function(t,n){const{render:r,className:s,id:o,disabled:i=!1,nativeButton:c=!0,...m}=t,{setTouched:d,setFocused:l,validationMode:a,state:g,disabled:x}=gn(),{labelId:h}=fr(),{store:y,setOpen:v,selectionRef:f,validation:b,readOnly:p,required:w,alignItemWithTriggerActiveRef:E,disabled:M,keyboardActiveRef:C}=lt(),O=x||M||i,Y=j(y,_.open),q=j(y,_.value),N=j(y,_.triggerProps),W=j(y,_.positionerElement),D=j(y,_.listElement),K=j(y,_.id),H=j(y,_.hasSelectedValue),P=!H&&Y,B=j(y,_.hasNullItemLabel,P),R=o??K;dr({id:R});const L=$e(W),A=u.useRef(null),{getButtonProps:I,buttonRef:ge}=jn({disabled:O,native:c}),k=xe(te=>{y.set("triggerElement",te)}),ae=zn(n,A,ge,k),Q=tt(),V=tt(),z=tt(),fe=tt();u.useEffect(()=>{if(Y)return!(H||B)?z.start(Ds,()=>{f.current.allowUnselectedMouseUp=!0,f.current.allowSelectedMouseUp=!0}):fe.start(Vn,()=>{f.current.allowUnselectedMouseUp=!0,z.start(Vn,()=>{f.current.allowSelectedMouseUp=!0})}),()=>{z.clear(),fe.clear()};f.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1},V.clear()},[Y,H,B,f,V,z,fe]);const De=u.useMemo(()=>D?.id??Wn(W)?.id,[D,W]),U=$n(N,{id:R,role:"combobox","aria-expanded":Y?"true":"false","aria-haspopup":"listbox","aria-controls":Y?De:void 0,"aria-labelledby":h,"aria-readonly":p||void 0,"aria-required":w||void 0,tabIndex:O?-1:0,ref:ae,onFocus(te){l(!0),Y&&E.current&&v(!1,Me(ln,te.nativeEvent)),Q.start(0,()=>{y.set("forceMount",!0)})},onBlur(te){xt(W,te.relatedTarget)||(d(!0),l(!1),a==="onBlur"&&b.commit(q))},onPointerMove(){C.current=!1},onKeyDown(){C.current=!0},onMouseDown(te){if(Y)return;const me=vt(te.currentTarget);function Re(ue){if(!A.current)return;const G=ue.target;if(xt(A.current,G)||xt(L.current,G)||G===A.current)return;const J=Ls(A.current);ue.clientX>=J.left-At&&ue.clientX<=J.right+At&&ue.clientY>=J.top-At&&ue.clientY<=J.bottom+At||v(!1,Me(Vr,ue))}V.start(0,()=>{me.addEventListener("mouseup",Re,{once:!0})})}},b.getValidationProps,m,I);U.role="combobox";const le=u.useMemo(()=>({...g,open:Y,disabled:O,value:q,readOnly:p,placeholder:!H}),[g,Y,O,q,p,H]);return ct("button",t,{ref:[n,A],state:le,stateAttributesMapping:Vs,props:U})}),ks={value:()=>null},ai=u.forwardRef(function(t,n){const{className:r,render:s,children:o,placeholder:i,...c}=t,{store:m,valueRef:d}=lt(),l=j(m,_.value),a=j(m,_.items),g=j(m,_.itemToStringLabel),x=j(m,_.hasSelectedValue),h=!x&&i!=null&&o==null,y=j(m,_.hasNullItemLabel,h),v=u.useMemo(()=>({value:l,placeholder:!x}),[l,x]);let f=null;return typeof o=="function"?f=o(l):o!=null?f=o:!x&&i!=null&&!y?f=i:Array.isArray(l)?f=As(l,a,g):f=mr(l,a,g),ct("span",t,{state:v,ref:[n,d],props:[{children:f},c],stateAttributesMapping:ks})}),Fs=u.createContext(void 0),ui=u.forwardRef(function(t,n){const{store:r}=lt(),s=j(r,_.mounted),o=j(r,_.forceMount);return s||o?Ae.jsx(Fs.Provider,{value:!0,children:Ae.jsx(kr,{ref:n,...t})}):null}),pr=u.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function Hs(){return u.useContext(pr)}function Ns(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:s}=e,o=xe(s),i=u.useRef(0),c=Lt(Us).current,m=Lt(Bs).current,[d,l]=u.useState(0),a=u.useRef(d),g=xe((f,b)=>{m.set(f,b??null),a.current+=1,l(a.current)}),x=xe(f=>{m.delete(f),a.current+=1,l(a.current)}),h=u.useMemo(()=>{const f=new Map;return Array.from(m.keys()).filter(p=>p.isConnected).sort(Ws).forEach((p,w)=>{const E=m.get(p)??{};f.set(p,{...E,index:w})}),f},[m,d]);X(()=>{if(typeof MutationObserver!="function"||h.size===0)return;const f=new MutationObserver(b=>{const p=new Set,w=E=>p.has(E)?p.delete(E):p.add(E);b.forEach(E=>{E.removedNodes.forEach(w),E.addedNodes.forEach(w)}),p.size===0&&(a.current+=1,l(a.current))});return h.forEach((b,p)=>{p.parentElement&&f.observe(p.parentElement,{childList:!0})}),()=>{f.disconnect()}},[h]),X(()=>{a.current===d&&(n.current.length!==h.size&&(n.current.length=h.size),r&&r.current.length!==h.size&&(r.current.length=h.size),i.current=h.size),o(h)},[o,h,n,r,d]),X(()=>()=>{n.current=[]},[n]),X(()=>()=>{r&&(r.current=[])},[r]);const y=xe(f=>(c.add(f),()=>{c.delete(f)}));X(()=>{c.forEach(f=>f(h))},[c,h]);const v=u.useMemo(()=>({register:g,unregister:x,subscribeMapChange:y,elementsRef:n,labelsRef:r,nextIndexRef:i}),[g,x,y,n,r,i]);return Ae.jsx(pr.Provider,{value:v,children:t})}function Bs(){return new Map}function Us(){return new Set}function Ws(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const xr=u.createContext(void 0);function _s(){const e=u.useContext(xr);if(!e)throw new Error(Et(59));return e}function Ht(e,t){e&&Object.assign(e.style,t)}const $s={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},zs={position:"fixed"},fi=u.forwardRef(function(t,n){const{anchor:r,positionMethod:s="absolute",className:o,render:i,side:c="bottom",align:m="center",sideOffset:d=0,alignOffset:l=0,collisionBoundary:a="clipping-ancestors",collisionPadding:g,arrowPadding:x=5,sticky:h=!1,disableAnchorTracking:y,alignItemWithTrigger:v=!0,collisionAvoidance:f=Fr,...b}=t,{store:p,listRef:w,labelsRef:E,alignItemWithTriggerActiveRef:M,selectedItemTextRef:C,valuesRef:O,initialValueRef:Y,popupRef:q,setValue:N}=lt(),W=ur(),D=j(p,_.open),K=j(p,_.mounted),H=j(p,_.modal),P=j(p,_.value),B=j(p,_.openMethod),R=j(p,_.positionerElement),L=j(p,_.triggerElement),A=j(p,_.isItemEqualToValue),I=u.useRef(null),ge=u.useRef(null),[k,ae]=u.useState(v),Q=K&&k&&B!=="touch";!K&&k!==v&&ae(v),X(()=>{K||(_.scrollUpArrowVisible(p.state)&&p.set("scrollUpArrowVisible",!1),_.scrollDownArrowVisible(p.state)&&p.set("scrollDownArrowVisible",!1))},[p,K]),u.useImperativeHandle(M,()=>Q),Qr((Q||H)&&D&&B!=="touch",L);const V=xs({anchor:r,floatingRootContext:W,positionMethod:s,mounted:K,side:c,sideOffset:d,align:m,alignOffset:l,arrowPadding:x,collisionBoundary:a,collisionPadding:g,sticky:h,disableAnchorTracking:y??Q,collisionAvoidance:f,keepMounted:!0}),z=Q?"none":V.side,fe=Q?zs:V.positionerStyles,De=u.useMemo(()=>{const G={};return D||(G.pointerEvents="none"),{role:"presentation",hidden:!K,style:{...fe,...G}}},[D,K,fe]),U=u.useMemo(()=>({open:D,side:z,align:V.align,anchorHidden:V.anchorHidden}),[D,z,V.align,V.anchorHidden]),le=xe(G=>{p.set("positionerElement",G)}),te=ct("div",t,{ref:[n,le],state:U,stateAttributesMapping:Gn,props:[De,b]}),me=u.useRef(0),Re=xe(G=>{if(G.size===0&&me.current===0||O.current.length===0)return;const J=me.current;if(me.current=G.size,G.size===J)return;const we=Me(ln);if(J!==0&&!p.state.multiple&&P!==null&&Qt(O.current,P,A)===-1){const Z=Y.current,Ve=Z!=null&&Kt(O.current,Z,A)?Z:null;N(Ve,we),Ve===null&&(p.set("selectedIndex",null),C.current=null)}if(J!==0&&p.state.multiple&&Array.isArray(P)){const re=P.filter(Z=>Kt(O.current,Z,A));(re.length!==P.length||re.some(Z=>!Kt(P,Z,A)))&&(N(re,we),re.length===0&&(p.set("selectedIndex",null),C.current=null))}if(D&&Q){p.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const re={height:""};Ht(R,re),Ht(q.current,re)}}),ue=u.useMemo(()=>({...V,side:z,alignItemWithTriggerActive:Q,setControlledAlignItemWithTrigger:ae,scrollUpArrowRef:I,scrollDownArrowRef:ge}),[V,z,Q,ae]);return Ae.jsx(Ns,{elementsRef:w,labelsRef:E,onMapChange:Re,children:Ae.jsxs(xr.Provider,{value:ue,children:[K&&H&&Ae.jsx(eo,{inert:Hr(!D),cutout:L}),te]})})});function yr(e){const t=e.currentTarget.getBoundingClientRect();return t.top+1<=e.clientY&&e.clientY<=t.bottom-1&&t.left+1<=e.clientX&&e.clientX<=t.right-1}const Ot="base-ui-disable-scrollbar",kn={className:Ot,getElement(e){return Ae.jsx("style",{nonce:e,href:Ot,precedence:"base-ui:low",children:`.${Ot}{scrollbar-width:none}.${Ot}::-webkit-scrollbar{display:none}`})}},js=u.createContext(void 0);function Ys(e){return u.useContext(js)}function qs(e){return e==="starting"?Nr:Rt}function Ks(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const Xs=u.createContext(void 0),Gs={disableStyleElements:!1};function Js(){return u.useContext(Xs)??Gs}const Zs={...Gn,...Yn},di=u.forwardRef(function(t,n){const{render:r,className:s,...o}=t,{store:i,popupRef:c,onOpenChangeComplete:m,setOpen:d,valueRef:l,selectedItemTextRef:a,keyboardActiveRef:g,multiple:x,handleScrollArrowVisibility:h,scrollHandlerRef:y,highlightItemOnHover:v}=lt(),{side:f,align:b,alignItemWithTriggerActive:p,setControlledAlignItemWithTrigger:w,scrollDownArrowRef:E,scrollUpArrowRef:M}=_s(),C=Ys()!=null,O=ur(),{nonce:Y,disableStyleElements:q}=Js(),N=tt(),W=j(i,_.id),D=j(i,_.open),K=j(i,_.mounted),H=j(i,_.popupProps),P=j(i,_.transitionStatus),B=j(i,_.triggerElement),R=j(i,_.positionerElement),L=j(i,_.listElement),A=u.useRef(0),I=u.useRef(!1),ge=u.useRef(0),k=u.useRef(!1),ae=u.useRef({}),Q=Nn(),V=xe(U=>{if(!R||!c.current||!k.current)return;if(I.current||!p){h();return}const le=R.style.top==="0px",te=R.style.bottom==="0px",me=R.getBoundingClientRect().height,Re=vt(R),ue=getComputedStyle(R),G=parseFloat(ue.marginTop),J=parseFloat(ue.marginBottom),we=Fn(getComputedStyle(c.current)),re=Re.documentElement.clientHeight-G-J,Z=U.scrollTop,be=U.scrollHeight,Ve=U.clientHeight,S=be-Ve;let F=0,T=null,ee=!1;if(le){const ne=S-Z,se=me+ne,ye=Math.min(se,re);F=ye,ye!==re?T=S:ee=!0}else if(te){const ne=Z-0,se=me+ne,ye=Math.min(se,re),he=se-re;F=ye,ye!==re?T=0:(ee=!0,Z<S&&(T=Z-(ne-he)))}F!==0&&(R.style.height=`${F}px`),T!=null&&(U.scrollTop=T),(ee||F>=we)&&(I.current=!0),h()});u.useImperativeHandle(y,()=>V,[V]),cn({open:D,ref:c,onComplete(){D&&m?.(!0)}});const z=u.useMemo(()=>({open:D,transitionStatus:P,side:f,align:b}),[D,P,f,b]);X(()=>{!R||!c.current||Object.keys(ae.current).length||(ae.current={top:R.style.top||"0",left:R.style.left||"0",right:R.style.right,height:R.style.height,bottom:R.style.bottom,minHeight:R.style.minHeight,maxHeight:R.style.maxHeight,marginTop:R.style.marginTop,marginBottom:R.style.marginBottom})},[c,R]),X(()=>{D||p||(k.current=!1,I.current=!1,A.current=0,ge.current=0,Ht(R,ae.current))},[D,p,R,c]),X(()=>{const U=c.current;if(!(!D||!B||!R||!U||i.state.transitionStatus==="ending")){if(!p){k.current=!0,Q.request(h),U.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const le=ei(U);U.style.removeProperty("--transform-origin");try{const te=getComputedStyle(R),me=getComputedStyle(U),Re=vt(B),ue=qe(R),G=B.getBoundingClientRect(),J=R.getBoundingClientRect(),we=G.left,re=G.height,Z=L||U,be=Z.scrollHeight,Ve=parseFloat(me.borderBottomWidth),S=parseFloat(te.marginTop)||10,F=parseFloat(te.marginBottom)||10,T=parseFloat(te.minHeight)||100,ee=Fn(me),ne=5,se=5,ye=20,he=Re.documentElement.clientHeight-S-F,Oe=Re.documentElement.clientWidth,ve=he-G.bottom+re,Te=a.current,_e=l.current;let He,Ne=0,ce=0;if(Te&&_e){const $=_e.getBoundingClientRect();He=Te.getBoundingClientRect();const ie=$.left-we,Ie=He.left-J.left,ke=$.top-G.top+$.height/2,Pe=He.top-J.top+He.height/2;Ne=ie-Ie,ce=Pe-ke}const pe=ve+ce+F+Ve;let de=Math.min(he,pe);const Se=he-S-F,Be=pe-de,Ue=Math.max(ne,we+Ne),Xe=Oe-se,Ge=Math.max(0,Ue+J.width-Xe);R.style.left=`${Ue-Ge}px`,R.style.height=`${de}px`,R.style.maxHeight="auto",R.style.marginTop=`${S}px`,R.style.marginBottom=`${F}px`,U.style.height="100%";const st=Z.scrollHeight-Z.clientHeight,at=Be>=st;at&&(de=Math.min(he,J.height)-(Be-st));const ht=G.top<ye||G.bottom>he-ye||de<Math.min(be,T),pt=(ue.visualViewport?.scale??1)!==1&&Br;if(ht||pt){k.current=!0,Ht(R,ae.current),sn.flushSync(()=>w(!1));return}if(at){const $=Math.max(0,he-pe);R.style.top=J.height>=Se?"0":`${$}px`,R.style.height=`${de}px`,Z.scrollTop=Z.scrollHeight-Z.clientHeight,A.current=Math.max(T,de)}else R.style.bottom="0",A.current=Math.max(T,de),Z.scrollTop=Be;if(He){const $=J.top,ie=J.height,Ie=He.top+He.height/2,ke=ie>0?(Ie-$)/ie*100:50,Pe=Ks(ke,0,100);U.style.setProperty("--transform-origin",`50% ${Pe}%`)}(A.current===he||de>=ee)&&(I.current=!0),h(),setTimeout(()=>{k.current=!0})}finally{le()}})}},[i,D,R,B,l,a,c,h,p,w,Q,E,M,L]),u.useEffect(()=>{if(!p||!R||!D)return;const U=qe(R);function le(te){d(!1,Me(Ur,te))}return U.addEventListener("resize",le),()=>{U.removeEventListener("resize",le)}},[d,p,R,D]);const fe={...L?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":x||void 0,id:`${W}-list`},onKeyDown(U){g.current=!0,C&&no.has(U.key)&&U.stopPropagation()},onMouseMove(){g.current=!1},onPointerLeave(U){if(!v||yr(U)||U.pointerType==="touch")return;const le=U.currentTarget;N.start(0,()=>{i.set("activeIndex",null),le.focus({preventScroll:!0})})},onScroll(U){L||y.current?.(U.currentTarget)},...p&&{style:L?{height:"100%"}:$s}},De=ct("div",t,{ref:[n,c],state:z,stateAttributesMapping:Zs,props:[H,fe,qs(P),{className:!L&&p?kn.className:void 0},o]});return Ae.jsxs(u.Fragment,{children:[!q&&kn.getElement(Y),Ae.jsx(to,{context:O,modal:!1,disabled:!K,restoreFocus:!0,children:De})]})});function Fn(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}const Hn={transform:"none",scale:"1",translate:"0 0"};function Qs(e,t,n){n?e.setProperty(t,n):e.removeProperty(t)}function ei(e){const{style:t}=e,n={},r=Object.keys(Hn);for(const s of r)n[s]=t.getPropertyValue(s),t.setProperty(s,Hn[s]);return()=>{for(const s of r)Qs(t,s,n[s])}}let wr=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function ti(e={}){const{label:t,metadata:n,textRef:r,indexGuessBehavior:s,index:o}=e,{register:i,unregister:c,subscribeMapChange:m,elementsRef:d,labelsRef:l,nextIndexRef:a}=Hs(),g=u.useRef(-1),[x,h]=u.useState(o??(s===wr.GuessFromOrder?()=>{if(g.current===-1){const f=a.current;a.current+=1,g.current=f}return g.current}:-1)),y=u.useRef(null),v=u.useCallback(f=>{if(y.current=f,x!==-1&&f!==null&&(d.current[x]=f,l)){const b=t!==void 0;l.current[x]=b?t:r?.current?.textContent??f.textContent}},[x,d,l,t,r]);return X(()=>{if(o!=null)return;const f=y.current;if(f)return i(f,n),()=>{c(f)}},[o,i,c,n]),X(()=>{if(o==null)return m(f=>{const b=y.current?f.get(y.current)?.index:null;b!=null&&h(b)})},[o,m,h]),u.useMemo(()=>({ref:v,index:x}),[x,v])}const Rr=u.createContext(void 0);function mn(){const e=u.useContext(Rr);if(!e)throw new Error(Et(57));return e}const gi=u.memo(u.forwardRef(function(t,n){const{render:r,className:s,value:o=null,label:i,disabled:c=!1,nativeButton:m=!1,...d}=t,l=u.useRef(null),a=ti({label:i,textRef:l,indexGuessBehavior:wr.GuessFromOrder}),{store:g,getItemProps:x,setOpen:h,setValue:y,selectionRef:v,typingRef:f,valuesRef:b,keyboardActiveRef:p,multiple:w,highlightItemOnHover:E}=lt(),M=tt(),C=j(g,_.isActive,a.index),O=j(g,_.isSelected,a.index,o),Y=j(g,_.isSelectedByFocus,a.index),q=j(g,_.isItemEqualToValue),N=a.index,W=N!==-1,D=u.useRef(null),K=$e(N);X(()=>{if(!W)return;const V=b.current;return V[N]=o,()=>{delete V[N]}},[W,N,o,b]),X(()=>{if(!W)return;const V=g.state.value;let z=V;w&&Array.isArray(V)&&V.length>0&&(z=V[V.length-1]),z!==void 0&&mt(z,o,q)&&g.set("selectedIndex",N)},[W,N,w,q,g,o]);const H=u.useMemo(()=>({disabled:c,selected:O,highlighted:C}),[c,O,C]),P=x({active:C,selected:O});P.onFocus=void 0,P.id=void 0;const B=u.useRef(null),R=u.useRef("mouse"),L=u.useRef(!1),{getButtonProps:A,buttonRef:I}=jn({disabled:c,focusableWhenDisabled:!0,native:m});function ge(V){const z=g.state.value;if(w){const fe=Array.isArray(z)?z:[],De=O?Es(fe,o,q):[...fe,o];y(De,Me($t,V))}else y(o,Me($t,V)),h(!1,Me($t,V))}const k={role:"option","aria-selected":O,tabIndex:C?0:-1,onFocus(){g.set("activeIndex",N)},onMouseEnter(){!p.current&&g.state.selectedIndex===null&&g.set("activeIndex",N)},onMouseMove(){E&&g.set("activeIndex",N)},onMouseLeave(V){!E||p.current||yr(V)||M.start(0,()=>{g.state.activeIndex===N&&g.set("activeIndex",null)})},onTouchStart(){v.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(V){B.current=V.key,g.set("activeIndex",N)},onClick(V){L.current=!1,!(V.type==="keydown"&&B.current===null)&&(c||B.current===" "&&f.current||R.current!=="touch"&&!C||(B.current=null,ge(V.nativeEvent)))},onPointerEnter(V){R.current=V.pointerType},onPointerDown(V){R.current=V.pointerType,L.current=!0},onMouseUp(V){if(c)return;if(L.current){L.current=!1;return}const z=!v.current.allowSelectedMouseUp&&O,fe=!v.current.allowUnselectedMouseUp&&!O;z||fe||R.current!=="touch"&&!C||ge(V.nativeEvent)}},ae=ct("div",t,{ref:[I,n,a.ref,D],state:H,props:[P,k,d,A]}),Q=u.useMemo(()=>({selected:O,indexRef:K,textRef:l,selectedByFocus:Y,hasRegistered:W}),[O,K,l,Y,W]);return Ae.jsx(Rr.Provider,{value:Q,children:ae})})),mi=u.forwardRef(function(t,n){const r=t.keepMounted??!1,{selected:s}=mn();return r||s?Ae.jsx(ni,{...t,ref:n}):null}),ni=u.memo(u.forwardRef((e,t)=>{const{render:n,className:r,keepMounted:s,...o}=e,{selected:i}=mn(),c=u.useRef(null),{transitionStatus:m,setMounted:d}=Xn(i),l=u.useMemo(()=>({selected:i,transitionStatus:m}),[i,m]),a=ct("span",e,{ref:[t,c],state:l,props:[{"aria-hidden":!0,children:"✔️"},o],stateAttributesMapping:Yn});return cn({open:i,ref:c,onComplete(){i||d(!1)}}),a})),hi=u.memo(u.forwardRef(function(t,n){const{indexRef:r,textRef:s,selectedByFocus:o,hasRegistered:i}=mn(),{selectedItemTextRef:c}=lt(),{className:m,render:d,...l}=t,a=u.useCallback(x=>{if(!x||!i)return;const h=c.current===null||!c.current.isConnected;(o||h&&r.current===0)&&(c.current=x)},[c,r,o,i]);return ct("div",t,{ref:[a,n,s],props:l})}));export{si as C,$s as L,ci as S,hr as a,gn as b,fr as c,Ln as d,Is as e,Rs as f,Ps as g,li as h,ai as i,ui as j,fi as k,di as l,gi as m,hi as n,mi as o,yo as p,xs as q,qs as r,_ as s,ii as t,lt as u,Ys as v,_s as w,kn as x};
1
+ import{c as Sr,bV as tn,bW as St,bX as nt,bY as rt,r as u,bZ as Nn,bp as tt,b as Me,by as _t,b_ as Cr,b2 as Rt,b$ as Xt,bv as Ee,c0 as et,c1 as qe,c2 as pn,c3 as Ze,bP as Je,c4 as Bn,c5 as nn,c6 as bt,c7 as Pt,c8 as Er,c9 as Un,ca as Mr,cb as rn,cc as on,cd as Nt,am as sn,ce as Ar,bC as Lt,a_ as X,cf as _n,cg as Or,aZ as xe,ch as xn,bt as Tr,bw as xt,ci as Wt,bu as Ir,bB as Wn,cj as Gt,ck as vt,aY as Ct,a$ as je,j as Ae,b6 as cn,b1 as $n,b0 as zn,b3 as Pr,b4 as Lr,b5 as ln,cl as Dr,u as jn,a as ct,cm as Vr,bL as kr,cn as Fr,bO as Hr,co as Nr,cp as Br,cq as Ur,b7 as Yn,cr as $t}from"./main-BN2u8ODm.js";import{s as Le,i as yn,v as _r,d as qn,w as Wr,P as $r,c as Kn,e as $e,x as zr,y as jr,z as Yr,u as qr,f as oe,b as Xn,h as Kr,a as j,k as Xr,l as Gr,S as Zr,p as Jr,j as Qr,I as eo,o as Gn,q as to,r as no}from"./useOpenInteractionType-BqOY0u5X.js";const ro=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],si=Sr("chevron-down",ro),oo=["top","right","bottom","left"],gt=Math.min,_e=Math.max,Dt=Math.round,ft=Math.floor,Ke=e=>({x:e,y:e}),so={left:"right",right:"left",bottom:"top",top:"bottom"};function Zt(e,t,n){return _e(e,gt(t,n))}function Qe(e,t){return typeof e=="function"?e(t):e}function Fe(e){return e.split("-")[0]}function ot(e){return e.split("-")[1]}function an(e){return e==="x"?"y":"x"}function un(e){return e==="y"?"height":"width"}function ze(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function fn(e){return an(ze(e))}function io(e,t,n){n===void 0&&(n=!1);const r=ot(e),s=fn(e),o=un(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(i=Vt(i)),[i,Vt(i)]}function co(e){const t=Vt(e);return[Jt(e),t,Jt(t)]}function Jt(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const wn=["left","right"],Rn=["right","left"],lo=["top","bottom"],ao=["bottom","top"];function uo(e,t,n){switch(e){case"top":case"bottom":return n?t?Rn:wn:t?wn:Rn;case"left":case"right":return t?lo:ao;default:return[]}}function fo(e,t,n,r){const s=ot(e);let o=uo(Fe(e),n==="start",r);return s&&(o=o.map(i=>i+"-"+s),t&&(o=o.concat(o.map(Jt)))),o}function Vt(e){const t=Fe(e);return so[t]+e.slice(t.length)}function go(e){return{top:0,right:0,bottom:0,left:0,...e}}function Zn(e){return typeof e!="number"?go(e):{top:e,right:e,bottom:e,left:e}}function kt(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function Et(e,t,n){return Math.floor(e/t)!==n}function yt(e,t){return t<0||t>=e.current.length}function zt(e,t){return Ce(e,{disabledIndices:t})}function bn(e,t){return Ce(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Ce(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:s=1}={}){let o=t;do o+=n?-s:s;while(o>=0&&o<=e.current.length-1&&wt(e,o,r));return o}function mo(e,{event:t,orientation:n,loopFocus:r,rtl:s,cols:o,disabledIndices:i,minIndex:c,maxIndex:m,prevIndex:d,stopEvent:l=!1}){let a=d;const g=[],x={};let h=!1;{let f=null,b=-1;e.current.forEach((p,w)=>{if(p==null)return;const C=p.closest('[role="row"]');C&&(h=!0),(C!==f||b===-1)&&(f=C,b+=1,g[b]=[]),g[b].push(w),x[w]=b})}const y=h&&g.length>0&&g.some(f=>f.length!==o);function v(f){if(!y||d===-1)return;const b=x[d];if(b==null)return;const p=g[b].indexOf(d);let w=f==="up"?b-1:b+1;r&&(w<0?w=g.length-1:w>=g.length&&(w=0));const C=new Set;for(;w>=0&&w<g.length&&!C.has(w);){C.add(w);const M=g[w];if(M.length===0){w=f==="up"?w-1:w+1;continue}const E=Math.min(p,M.length-1);for(let O=E;O>=0;O-=1){const Y=M[O];if(!wt(e,Y,i))return Y}w=f==="up"?w-1:w+1,r&&(w<0?w=g.length-1:w>=g.length&&(w=0))}}if(t.key===tn){const f=v("up");if(f!==void 0)l&&Le(t),a=f;else{if(l&&Le(t),d===-1)a=m;else if(a=Ce(e,{startingIndex:a,amount:o,decrement:!0,disabledIndices:i}),r&&(d-o<c||a<0)){const b=d%o,p=m%o,w=m-(p-b);p===b?a=m:a=p>b?w:w-o}yt(e,a)&&(a=d)}}if(t.key===St){const f=v("down");f!==void 0?(l&&Le(t),a=f):(l&&Le(t),d===-1?a=c:(a=Ce(e,{startingIndex:d,amount:o,disabledIndices:i}),r&&d+o>m&&(a=Ce(e,{startingIndex:d%o-o,amount:o,disabledIndices:i}))),yt(e,a)&&(a=d))}if(n==="both"){const f=ft(d/o);t.key===(s?nt:rt)&&(l&&Le(t),d%o!==o-1?(a=Ce(e,{startingIndex:d,disabledIndices:i}),r&&Et(a,o,f)&&(a=Ce(e,{startingIndex:d-d%o-1,disabledIndices:i}))):r&&(a=Ce(e,{startingIndex:d-d%o-1,disabledIndices:i})),Et(a,o,f)&&(a=d)),t.key===(s?rt:nt)&&(l&&Le(t),d%o!==0?(a=Ce(e,{startingIndex:d,decrement:!0,disabledIndices:i}),r&&Et(a,o,f)&&(a=Ce(e,{startingIndex:d+(o-d%o),decrement:!0,disabledIndices:i}))):r&&(a=Ce(e,{startingIndex:d+(o-d%o),decrement:!0,disabledIndices:i})),Et(a,o,f)&&(a=d));const b=ft(m/o)===f;yt(e,a)&&(r&&b?a=t.key===(s?rt:nt)?m:Ce(e,{startingIndex:d-d%o-1,disabledIndices:i}):a=d)}return a}function ho(e,t,n){const r=[];let s=0;return e.forEach(({width:o,height:i},c)=>{let m=!1;for(n&&(s=0);!m;){const d=[];for(let l=0;l<o;l+=1)for(let a=0;a<i;a+=1)d.push(s+l+a*t);s%t+o<=t&&d.every(l=>r[l]==null)?(d.forEach(l=>{r[l]=c}),m=!0):s+=1}}),[...r]}function po(e,t,n,r,s){if(e===-1)return-1;const o=n.indexOf(e),i=t[e];switch(s){case"tl":return o;case"tr":return i?o+i.width-1:o;case"bl":return i?o+(i.height-1)*r:o;case"br":return n.lastIndexOf(e);default:return-1}}function xo(e,t){return t.flatMap((n,r)=>e.includes(n)?[r]:[])}function wt(e,t,n){if(typeof n=="function")return n(t);if(n)return n.includes(t);const r=e.current[t];return r?r.hasAttribute("disabled")||r.getAttribute("aria-disabled")==="true":!1}function yo(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.context.dataRef,{enabled:s=!0,event:o="click",toggle:i=!0,ignoreMouse:c=!1,stickIfOpen:m=!0,touchOpenDelay:d=0}=t,l=u.useRef(void 0),a=Nn(),g=tt(),x=u.useMemo(()=>({onPointerDown(h){l.current=h.pointerType},onMouseDown(h){const y=l.current,v=h.nativeEvent,f=n.select("open");if(h.button!==0||o==="click"||yn(y,!0)&&c)return;const b=r.current.openEvent,p=b?.type,w=n.select("domReferenceElement")!==h.currentTarget,C=f&&w||!(f&&i&&(!(b&&m)||p==="click"||p==="mousedown"));if(Cr(v.target)){const E=Me(_t,v,v.target);C&&y==="touch"&&d>0?g.start(d,()=>{n.setOpen(!0,E)}):n.setOpen(C,E);return}const M=h.currentTarget;a.request(()=>{const E=Me(_t,v,M);C&&y==="touch"&&d>0?g.start(d,()=>{n.setOpen(!0,E)}):n.setOpen(C,E)})},onClick(h){if(o==="mousedown-only")return;const y=l.current;if(o==="mousedown"&&y){l.current=void 0;return}if(yn(y,!0)&&c)return;const v=n.select("open"),f=r.current.openEvent,b=n.select("domReferenceElement")!==h.currentTarget,p=v&&b||!(v&&i&&(!(f&&m)||_r(f))),w=Me(_t,h.nativeEvent,h.currentTarget);p&&y==="touch"&&d>0?g.start(d,()=>{n.setOpen(!0,w)}):n.setOpen(p,w)},onKeyDown(){l.current=void 0}}),[r,o,c,n,m,i,a,g,d]);return u.useMemo(()=>s?{reference:x}:Rt,[s,x])}function vn(e,t,n){let{reference:r,floating:s}=e;const o=ze(t),i=fn(t),c=un(i),m=Fe(t),d=o==="y",l=r.x+r.width/2-s.width/2,a=r.y+r.height/2-s.height/2,g=r[c]/2-s[c]/2;let x;switch(m){case"top":x={x:l,y:r.y-s.height};break;case"bottom":x={x:l,y:r.y+r.height};break;case"right":x={x:r.x+r.width,y:a};break;case"left":x={x:r.x-s.width,y:a};break;default:x={x:r.x,y:r.y}}switch(ot(t)){case"start":x[i]-=g*(n&&d?-1:1);break;case"end":x[i]+=g*(n&&d?-1:1);break}return x}async function wo(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:o,rects:i,elements:c,strategy:m}=e,{boundary:d="clippingAncestors",rootBoundary:l="viewport",elementContext:a="floating",altBoundary:g=!1,padding:x=0}=Qe(t,e),h=Zn(x),v=c[g?a==="floating"?"reference":"floating":a],f=kt(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(v)))==null||n?v:v.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(c.floating)),boundary:d,rootBoundary:l,strategy:m})),b=a==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,p=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c.floating)),w=await(o.isElement==null?void 0:o.isElement(p))?await(o.getScale==null?void 0:o.getScale(p))||{x:1,y:1}:{x:1,y:1},C=kt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:b,offsetParent:p,strategy:m}):b);return{top:(f.top-C.top+h.top)/w.y,bottom:(C.bottom-f.bottom+h.bottom)/w.y,left:(f.left-C.left+h.left)/w.x,right:(C.right-f.right+h.right)/w.x}}const Ro=50,bo=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,c=i.detectOverflow?i:{...i,detectOverflow:wo},m=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:s}),{x:l,y:a}=vn(d,r,m),g=r,x=0;const h={};for(let y=0;y<o.length;y++){const v=o[y];if(!v)continue;const{name:f,fn:b}=v,{x:p,y:w,data:C,reset:M}=await b({x:l,y:a,initialPlacement:r,placement:g,strategy:s,middlewareData:h,rects:d,platform:c,elements:{reference:e,floating:t}});l=p??l,a=w??a,h[f]={...h[f],...C},M&&x<Ro&&(x++,typeof M=="object"&&(M.placement&&(g=M.placement),M.rects&&(d=M.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:s}):M.rects),{x:l,y:a}=vn(d,g,m)),y=-1)}return{x:l,y:a,placement:g,strategy:s,middlewareData:h}},vo=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:o,rects:i,initialPlacement:c,platform:m,elements:d}=t,{mainAxis:l=!0,crossAxis:a=!0,fallbackPlacements:g,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:y=!0,...v}=Qe(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const f=Fe(s),b=ze(c),p=Fe(c)===c,w=await(m.isRTL==null?void 0:m.isRTL(d.floating)),C=g||(p||!y?[Vt(c)]:co(c)),M=h!=="none";!g&&M&&C.push(...fo(c,y,h,w));const E=[c,...C],O=await m.detectOverflow(t,v),Y=[];let q=((r=o.flip)==null?void 0:r.overflows)||[];if(l&&Y.push(O[f]),a){const K=io(s,i,w);Y.push(O[K[0]],O[K[1]])}if(q=[...q,{placement:s,overflows:Y}],!Y.every(K=>K<=0)){var N,_;const K=(((N=o.flip)==null?void 0:N.index)||0)+1,H=E[K];if(H&&(!(a==="alignment"?b!==ze(H):!1)||q.every(R=>ze(R.placement)===b?R.overflows[0]>0:!0)))return{data:{index:K,overflows:q},reset:{placement:H}};let P=(_=q.filter(B=>B.overflows[0]<=0).sort((B,R)=>B.overflows[1]-R.overflows[1])[0])==null?void 0:_.placement;if(!P)switch(x){case"bestFit":{var D;const B=(D=q.filter(R=>{if(M){const L=ze(R.placement);return L===b||L==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(L=>L>0).reduce((L,A)=>L+A,0)]).sort((R,L)=>R[1]-L[1])[0])==null?void 0:D[0];B&&(P=B);break}case"initialPlacement":P=c;break}if(s!==P)return{reset:{placement:P}}}return{}}}};function Sn(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Cn(e){return oo.some(t=>e[t]>=0)}const So=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:s="referenceHidden",...o}=Qe(e,t);switch(s){case"referenceHidden":{const i=await r.detectOverflow(t,{...o,elementContext:"reference"}),c=Sn(i,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Cn(c)}}}case"escaped":{const i=await r.detectOverflow(t,{...o,altBoundary:!0}),c=Sn(i,n.floating);return{data:{escapedOffsets:c,escaped:Cn(c)}}}default:return{}}}}},Jn=new Set(["left","top"]);async function Co(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=Fe(n),c=ot(n),m=ze(n)==="y",d=Jn.has(i)?-1:1,l=o&&m?-1:1,a=Qe(t,e);let{mainAxis:g,crossAxis:x,alignmentAxis:h}=typeof a=="number"?{mainAxis:a,crossAxis:0,alignmentAxis:null}:{mainAxis:a.mainAxis||0,crossAxis:a.crossAxis||0,alignmentAxis:a.alignmentAxis};return c&&typeof h=="number"&&(x=c==="end"?h*-1:h),m?{x:x*l,y:g*d}:{x:g*d,y:x*l}}const Eo=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:o,placement:i,middlewareData:c}=t,m=await Co(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:s+m.x,y:o+m.y,data:{...m,placement:i}}}}},Mo=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:o}=t,{mainAxis:i=!0,crossAxis:c=!1,limiter:m={fn:f=>{let{x:b,y:p}=f;return{x:b,y:p}}},...d}=Qe(e,t),l={x:n,y:r},a=await o.detectOverflow(t,d),g=ze(Fe(s)),x=an(g);let h=l[x],y=l[g];if(i){const f=x==="y"?"top":"left",b=x==="y"?"bottom":"right",p=h+a[f],w=h-a[b];h=Zt(p,h,w)}if(c){const f=g==="y"?"top":"left",b=g==="y"?"bottom":"right",p=y+a[f],w=y-a[b];y=Zt(p,y,w)}const v=m.fn({...t,[x]:h,[g]:y});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[x]:i,[g]:c}}}}}},Ao=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:s,rects:o,middlewareData:i}=t,{offset:c=0,mainAxis:m=!0,crossAxis:d=!0}=Qe(e,t),l={x:n,y:r},a=ze(s),g=an(a);let x=l[g],h=l[a];const y=Qe(c,t),v=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(m){const p=g==="y"?"height":"width",w=o.reference[g]-o.floating[p]+v.mainAxis,C=o.reference[g]+o.reference[p]-v.mainAxis;x<w?x=w:x>C&&(x=C)}if(d){var f,b;const p=g==="y"?"width":"height",w=Jn.has(Fe(s)),C=o.reference[a]-o.floating[p]+(w&&((f=i.offset)==null?void 0:f[a])||0)+(w?0:v.crossAxis),M=o.reference[a]+o.reference[p]+(w?0:((b=i.offset)==null?void 0:b[a])||0)-(w?v.crossAxis:0);h<C?h=C:h>M&&(h=M)}return{[g]:x,[a]:h}}}},Oo=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:s,rects:o,platform:i,elements:c}=t,{apply:m=()=>{},...d}=Qe(e,t),l=await i.detectOverflow(t,d),a=Fe(s),g=ot(s),x=ze(s)==="y",{width:h,height:y}=o.floating;let v,f;a==="top"||a==="bottom"?(v=a,f=g===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(f=a,v=g==="end"?"top":"bottom");const b=y-l.top-l.bottom,p=h-l.left-l.right,w=gt(y-l[v],b),C=gt(h-l[f],p),M=!t.middlewareData.shift;let E=w,O=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(O=p),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),M&&!g){const q=_e(l.left,0),N=_e(l.right,0),_=_e(l.top,0),D=_e(l.bottom,0);x?O=h-2*(q!==0||N!==0?q+N:_e(l.left,l.right)):E=y-2*(_!==0||D!==0?_+D:_e(l.top,l.bottom))}await m({...t,availableWidth:O,availableHeight:E});const Y=await i.getDimensions(c.floating);return h!==Y.width||y!==Y.height?{reset:{rects:!0}}:{}}}};function Qn(e){const t=Ze(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=Je(e),o=s?e.offsetWidth:n,i=s?e.offsetHeight:r,c=Dt(n)!==o||Dt(r)!==i;return c&&(n=o,r=i),{width:n,height:r,$:c}}function dn(e){return Ee(e)?e:e.contextElement}function dt(e){const t=dn(e);if(!Je(t))return Ke(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=Qn(t);let i=(o?Dt(n.width):n.width)/r,c=(o?Dt(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const To=Ke(0);function er(e){const t=qe(e);return!Bn()||!t.visualViewport?To:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Io(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==qe(e)?!1:t}function it(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=dn(e);let i=Ke(1);t&&(r?Ee(r)&&(i=dt(r)):i=dt(e));const c=Io(o,n,r)?er(o):Ke(0);let m=(s.left+c.x)/i.x,d=(s.top+c.y)/i.y,l=s.width/i.x,a=s.height/i.y;if(o){const g=qe(o),x=r&&Ee(r)?qe(r):r;let h=g,y=pn(h);for(;y&&r&&x!==h;){const v=dt(y),f=y.getBoundingClientRect(),b=Ze(y),p=f.left+(y.clientLeft+parseFloat(b.paddingLeft))*v.x,w=f.top+(y.clientTop+parseFloat(b.paddingTop))*v.y;m*=v.x,d*=v.y,l*=v.x,a*=v.y,m+=p,d+=w,h=qe(y),y=pn(h)}}return kt({width:l,height:a,x:m,y:d})}function Bt(e,t){const n=Nt(e).scrollLeft;return t?t.left+n:it(et(e)).left+n}function tr(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Bt(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function Po(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",i=et(r),c=t?nn(t.floating):!1;if(r===i||c&&o)return n;let m={scrollLeft:0,scrollTop:0},d=Ke(1);const l=Ke(0),a=Je(r);if((a||!a&&!o)&&((rn(r)!=="body"||on(i))&&(m=Nt(r)),a)){const x=it(r);d=dt(r),l.x=x.x+r.clientLeft,l.y=x.y+r.clientTop}const g=i&&!a&&!o?tr(i,m):Ke(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-m.scrollLeft*d.x+l.x+g.x,y:n.y*d.y-m.scrollTop*d.y+l.y+g.y}}function Lo(e){return Array.from(e.getClientRects())}function Do(e){const t=et(e),n=Nt(e),r=e.ownerDocument.body,s=_e(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=_e(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Bt(e);const c=-n.scrollTop;return Ze(r).direction==="rtl"&&(i+=_e(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:i,y:c}}const En=25;function Vo(e,t){const n=qe(e),r=et(e),s=n.visualViewport;let o=r.clientWidth,i=r.clientHeight,c=0,m=0;if(s){o=s.width,i=s.height;const l=Bn();(!l||l&&t==="fixed")&&(c=s.offsetLeft,m=s.offsetTop)}const d=Bt(r);if(d<=0){const l=r.ownerDocument,a=l.body,g=getComputedStyle(a),x=l.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,h=Math.abs(r.clientWidth-a.clientWidth-x);h<=En&&(o-=h)}else d<=En&&(o+=d);return{width:o,height:i,x:c,y:m}}function ko(e,t){const n=it(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=Je(e)?dt(e):Ke(1),i=e.clientWidth*o.x,c=e.clientHeight*o.y,m=s*o.x,d=r*o.y;return{width:i,height:c,x:m,y:d}}function Mn(e,t,n){let r;if(t==="viewport")r=Vo(e,n);else if(t==="document")r=Do(et(e));else if(Ee(t))r=ko(t,n);else{const s=er(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return kt(r)}function nr(e,t){const n=bt(e);return n===t||!Ee(n)||Pt(n)?!1:Ze(n).position==="fixed"||nr(n,t)}function Fo(e,t){const n=t.get(e);if(n)return n;let r=Xt(e,[],!1).filter(c=>Ee(c)&&rn(c)!=="body"),s=null;const o=Ze(e).position==="fixed";let i=o?bt(e):e;for(;Ee(i)&&!Pt(i);){const c=Ze(i),m=Un(i);!m&&c.position==="fixed"&&(s=null),(o?!m&&!s:!m&&c.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||on(i)&&!m&&nr(e,i))?r=r.filter(l=>l!==i):s=c,i=bt(i)}return t.set(e,r),r}function Ho(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const i=[...n==="clippingAncestors"?nn(t)?[]:Fo(t,this._c):[].concat(n),r],c=Mn(t,i[0],s);let m=c.top,d=c.right,l=c.bottom,a=c.left;for(let g=1;g<i.length;g++){const x=Mn(t,i[g],s);m=_e(x.top,m),d=gt(x.right,d),l=gt(x.bottom,l),a=_e(x.left,a)}return{width:d-a,height:l-m,x:a,y:m}}function No(e){const{width:t,height:n}=Qn(e);return{width:t,height:n}}function Bo(e,t,n){const r=Je(t),s=et(t),o=n==="fixed",i=it(e,!0,o,t);let c={scrollLeft:0,scrollTop:0};const m=Ke(0);function d(){m.x=Bt(s)}if(r||!r&&!o)if((rn(t)!=="body"||on(s))&&(c=Nt(t)),r){const x=it(t,!0,o,t);m.x=x.x+t.clientLeft,m.y=x.y+t.clientTop}else s&&d();o&&!r&&s&&d();const l=s&&!r&&!o?tr(s,c):Ke(0),a=i.left+c.scrollLeft-m.x-l.x,g=i.top+c.scrollTop-m.y-l.y;return{x:a,y:g,width:i.width,height:i.height}}function jt(e){return Ze(e).position==="static"}function An(e,t){if(!Je(e)||Ze(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return et(e)===n&&(n=n.ownerDocument.body),n}function rr(e,t){const n=qe(e);if(nn(e))return n;if(!Je(e)){let s=bt(e);for(;s&&!Pt(s);){if(Ee(s)&&!jt(s))return s;s=bt(s)}return n}let r=An(e,t);for(;r&&Er(r)&&jt(r);)r=An(r,t);return r&&Pt(r)&&jt(r)&&!Un(r)?n:r||Mr(e)||n}const Uo=async function(e){const t=this.getOffsetParent||rr,n=this.getDimensions,r=await n(e.floating);return{reference:Bo(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function _o(e){return Ze(e).direction==="rtl"}const Wo={convertOffsetParentRelativeRectToViewportRelativeRect:Po,getDocumentElement:et,getClippingRect:Ho,getOffsetParent:rr,getElementRects:Uo,getClientRects:Lo,getDimensions:No,getScale:dt,isElement:Ee,isRTL:_o};function or(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function $o(e,t){let n=null,r;const s=et(e);function o(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function i(c,m){c===void 0&&(c=!1),m===void 0&&(m=1),o();const d=e.getBoundingClientRect(),{left:l,top:a,width:g,height:x}=d;if(c||t(),!g||!x)return;const h=ft(a),y=ft(s.clientWidth-(l+g)),v=ft(s.clientHeight-(a+x)),f=ft(l),p={rootMargin:-h+"px "+-y+"px "+-v+"px "+-f+"px",threshold:_e(0,gt(1,m))||1};let w=!0;function C(M){const E=M[0].intersectionRatio;if(E!==m){if(!w)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!or(d,e.getBoundingClientRect())&&i(),w=!1}try{n=new IntersectionObserver(C,{...p,root:s.ownerDocument})}catch{n=new IntersectionObserver(C,p)}n.observe(e)}return i(!0),o}function On(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:m=!1}=r,d=dn(e),l=s||o?[...d?Xt(d):[],...t?Xt(t):[]]:[];l.forEach(f=>{s&&f.addEventListener("scroll",n,{passive:!0}),o&&f.addEventListener("resize",n)});const a=d&&c?$o(d,n):null;let g=-1,x=null;i&&(x=new ResizeObserver(f=>{let[b]=f;b&&b.target===d&&x&&t&&(x.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var p;(p=x)==null||p.observe(t)})),n()}),d&&!m&&x.observe(d),t&&x.observe(t));let h,y=m?it(e):null;m&&v();function v(){const f=it(e);y&&!or(y,f)&&n(),y=f,h=requestAnimationFrame(v)}return n(),()=>{var f;l.forEach(b=>{s&&b.removeEventListener("scroll",n),o&&b.removeEventListener("resize",n)}),a?.(),(f=x)==null||f.disconnect(),x=null,m&&cancelAnimationFrame(h)}}const zo=Eo,jo=Mo,Yo=vo,qo=Oo,Ko=So,Xo=Ao,Go=(e,t,n)=>{const r=new Map,s={platform:Wo,...n},o={...s.platform,_c:r};return bo(e,t,{...s,platform:o})};var Zo=typeof document<"u",Jo=function(){},Tt=Zo?u.useLayoutEffect:Jo;function Ft(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Ft(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const o=s[r];if(!(o==="_owner"&&e.$$typeof)&&!Ft(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function sr(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Tn(e,t){const n=sr(e);return Math.round(t*n)/n}function Yt(e){const t=u.useRef(e);return Tt(()=>{t.current=e}),t}function Qo(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:o,floating:i}={},transform:c=!0,whileElementsMounted:m,open:d}=e,[l,a]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,x]=u.useState(r);Ft(g,r)||x(r);const[h,y]=u.useState(null),[v,f]=u.useState(null),b=u.useCallback(R=>{R!==M.current&&(M.current=R,y(R))},[]),p=u.useCallback(R=>{R!==E.current&&(E.current=R,f(R))},[]),w=o||h,C=i||v,M=u.useRef(null),E=u.useRef(null),O=u.useRef(l),Y=m!=null,q=Yt(m),N=Yt(s),_=Yt(d),D=u.useCallback(()=>{if(!M.current||!E.current)return;const R={placement:t,strategy:n,middleware:g};N.current&&(R.platform=N.current),Go(M.current,E.current,R).then(L=>{const A={...L,isPositioned:_.current!==!1};K.current&&!Ft(O.current,A)&&(O.current=A,sn.flushSync(()=>{a(A)}))})},[g,t,n,N,_]);Tt(()=>{d===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,a(R=>({...R,isPositioned:!1})))},[d]);const K=u.useRef(!1);Tt(()=>(K.current=!0,()=>{K.current=!1}),[]),Tt(()=>{if(w&&(M.current=w),C&&(E.current=C),w&&C){if(q.current)return q.current(w,C,D);D()}},[w,C,D,q,Y]);const H=u.useMemo(()=>({reference:M,floating:E,setReference:b,setFloating:p}),[b,p]),P=u.useMemo(()=>({reference:w,floating:C}),[w,C]),B=u.useMemo(()=>{const R={position:n,left:0,top:0};if(!P.floating)return R;const L=Tn(P.floating,l.x),A=Tn(P.floating,l.y);return c?{...R,transform:"translate("+L+"px, "+A+"px)",...sr(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:L,top:A}},[n,c,P.floating,l.x,l.y]);return u.useMemo(()=>({...l,update:D,refs:H,elements:P,floatingStyles:B}),[l,D,H,P,B])}const es=(e,t)=>{const n=zo(e);return{name:n.name,fn:n.fn,options:[e,t]}},ts=(e,t)=>{const n=jo(e);return{name:n.name,fn:n.fn,options:[e,t]}},ns=(e,t)=>({fn:Xo(e).fn,options:[e,t]}),rs=(e,t)=>{const n=Yo(e);return{name:n.name,fn:n.fn,options:[e,t]}},os=(e,t)=>{const n=qo(e);return{name:n.name,fn:n.fn,options:[e,t]}},ss=(e,t)=>{const n=Ko(e);return{name:n.name,fn:n.fn,options:[e,t]}};function ir(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,s=Ar(),o=qn()!=null,i=Lt(()=>new Wr({open:t,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:r.triggers??new $r,floatingId:s,nested:o,noEmit:e.noEmit||!1})).current;return X(()=>{const c={open:t,floatingId:s};r.reference!==void 0&&(c.referenceElement=r.reference,c.domReferenceElement=Ee(r.reference)?r.reference:null),r.floating!==void 0&&(c.floatingElement=r.floating),i.update(c)},[t,s,r.reference,r.floating,i]),i.context.onOpenChange=n,i.context.nested=o,i.context.noEmit=e.noEmit||!1,i}function is(e={}){const{nodeId:t,externalTree:n}=e,r=ir(e),s=e.rootContext||r,o={reference:s.useState("referenceElement"),floating:s.useState("floatingElement"),domReference:s.useState("domReferenceElement")},[i,c]=u.useState(null),m=u.useRef(null),d=Kn(n);X(()=>{o.domReference&&(m.current=o.domReference)},[o.domReference]);const l=Qo({...e,elements:{...o,...i&&{reference:i}}}),a=u.useCallback(E=>{const O=Ee(E)?{getBoundingClientRect:()=>E.getBoundingClientRect(),getClientRects:()=>E.getClientRects(),contextElement:E}:E;c(O),l.refs.setReference(O)},[l.refs]),[g,x]=u.useState(null),[h,y]=u.useState(null);s.useSyncedValue("referenceElement",g),s.useSyncedValue("domReferenceElement",Ee(g)?g:null),s.useSyncedValue("floatingElement",h);const v=u.useCallback(E=>{(Ee(E)||E===null)&&(m.current=E,x(E)),(Ee(l.refs.reference.current)||l.refs.reference.current===null||E!==null&&!Ee(E))&&l.refs.setReference(E)},[l.refs,x]),f=u.useCallback(E=>{y(E),l.refs.setFloating(E)},[l.refs]),b=u.useMemo(()=>({...l.refs,setReference:v,setFloating:f,setPositionReference:a,domReference:m}),[l.refs,v,f,a]),p=u.useMemo(()=>({...l.elements,domReference:o.domReference}),[l.elements,o.domReference]),w=s.useState("open"),C=s.useState("floatingId"),M=u.useMemo(()=>({...l,dataRef:s.context.dataRef,open:w,onOpenChange:s.setOpen,events:s.context.events,floatingId:C,refs:b,elements:p,nodeId:t,rootStore:s}),[l,b,p,t,s,w,C]);return X(()=>{s.context.dataRef.current.floatingContext=M;const E=d?.nodesRef.current.find(O=>O.id===t);E&&(E.context=M)}),u.useMemo(()=>({...l,context:M,refs:b,elements:p,rootStore:s}),[l,b,p,M,s])}const cs="Escape";function Ut(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Mt(e,t){return Ut(t,e===tn||e===St,e===nt||e===rt)}function qt(e,t,n){return Ut(t,e===St,n?e===nt:e===rt)||e==="Enter"||e===" "||e===""}function ls(e,t,n){return Ut(t,n?e===nt:e===rt,e===St)}function as(e,t,n,r){const s=n?e===rt:e===nt,o=e===tn;return t==="both"||t==="horizontal"&&r&&r>1?e===cs:Ut(t,s,o)}function us(e,t){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),s=n.useState("floatingElement"),o=n.useState("domReferenceElement"),i=n.context.dataRef,{listRef:c,activeIndex:m,onNavigate:d=()=>{},enabled:l=!0,selectedIndex:a=null,allowEscape:g=!1,loopFocus:x=!1,nested:h=!1,rtl:y=!1,virtual:v=!1,focusItemOnOpen:f="auto",focusItemOnHover:b=!0,openOnArrowKeyDown:p=!0,disabledIndices:w=void 0,orientation:C="vertical",parentOrientation:M,cols:E=1,scrollItemIntoView:O=!0,itemSizes:Y,dense:q=!1,id:N,resetOnPointerLeave:_=!0,externalTree:D}=t,K=_n(s),H=$e(K),P=qn(),B=Kn(D);X(()=>{i.current.orientation=C},[i,C]);const R=Or(o),L=u.useRef(f),A=u.useRef(a??-1),I=u.useRef(null),ge=u.useRef(!0),k=xe(S=>{d(A.current===-1?null:A.current,S)}),ae=u.useRef(k),Q=u.useRef(!!s),V=u.useRef(r),z=u.useRef(!1),fe=u.useRef(!1),De=$e(w),U=$e(r),le=$e(O),te=$e(a),me=$e(_),Re=xe(()=>{function S(ne){v?B?.events.emit("virtualfocus",ne):zr(ne,{sync:z.current,preventScroll:!0})}const F=c.current[A.current],T=fe.current;F&&S(F),(z.current?ne=>ne():requestAnimationFrame)(()=>{const ne=c.current[A.current]||F;if(!ne)return;F||S(ne);const se=le.current;se&&G&&(T||!ge.current)&&ne.scrollIntoView?.(typeof se=="boolean"?{block:"nearest",inline:"nearest"}:se)})});X(()=>{l&&(r&&s?(A.current=a??-1,L.current&&a!=null&&(fe.current=!0,k())):Q.current&&(A.current=-1,ae.current()))},[l,r,s,a,k]),X(()=>{if(l){if(!r){z.current=!1;return}if(s)if(m==null){if(z.current=!1,te.current!=null)return;if(Q.current&&(A.current=-1,Re()),(!V.current||!Q.current)&&L.current&&(I.current!=null||L.current===!0&&I.current==null)){let S=0;const F=()=>{c.current[0]==null?(S<2&&(S?requestAnimationFrame:queueMicrotask)(F),S+=1):(A.current=I.current==null||qt(I.current,C,y)||h?zt(c):bn(c),I.current=null,k())};F()}}else yt(c,m)||(A.current=m,Re(),fe.current=!1)}},[l,r,s,m,te,h,c,C,y,k,Re,De]),X(()=>{if(!l||s||!B||v||!Q.current)return;const S=B.nodesRef.current,F=S.find(ne=>ne.id===P)?.context?.elements.floating,T=xn(Tr(s)),ee=S.some(ne=>ne.context&&xt(ne.context.elements.floating,T));F&&!ee&&ge.current&&F.focus({preventScroll:!0})},[l,s,B,P,v]),X(()=>{ae.current=k,V.current=r,Q.current=!!s}),X(()=>{r||(I.current=null,L.current=f)},[r,f]);const ue=m!=null,G=u.useMemo(()=>{function S(T){if(!U.current)return;const ee=c.current.indexOf(T.currentTarget);ee!==-1&&A.current!==ee&&(A.current=ee,k(T))}return{onFocus(T){z.current=!0,S(T)},onClick:({currentTarget:T})=>T.focus({preventScroll:!0}),onMouseMove(T){z.current=!0,fe.current=!1,b&&S(T)},onPointerLeave(T){if(!U.current||!ge.current||T.pointerType==="touch")return;z.current=!0;const ee=T.relatedTarget;!b||c.current.includes(ee)||me.current&&(A.current=-1,k(T),v||H.current?.focus({preventScroll:!0}))}}},[U,H,b,c,k,me,v]),Z=u.useCallback(()=>M??B?.nodesRef.current.find(S=>S.id===P)?.context?.dataRef?.current.orientation,[P,B,M]),we=xe(S=>{if(ge.current=!1,z.current=!0,S.which===229||!U.current&&S.currentTarget===H.current)return;if(h&&as(S.key,C,y,E)){Mt(S.key,Z())||Le(S),n.setOpen(!1,Me(Wt,S.nativeEvent)),Je(o)&&(v?B?.events.emit("virtualfocus",o):o.focus());return}const F=A.current,T=zt(c,w),ee=bn(c,w);if(R||(S.key==="Home"&&(Le(S),A.current=T,k(S)),S.key==="End"&&(Le(S),A.current=ee,k(S))),E>1){const ne=Y||Array.from({length:c.current.length},()=>({width:1,height:1})),se=ho(ne,E,q),ye=se.findIndex(ve=>ve!=null&&!wt(c,ve,w)),he=se.reduce((ve,Te,We)=>Te!=null&&!wt(c,Te,w)?We:ve,-1),Oe=se[mo({current:se.map(ve=>ve!=null?c.current[ve]:null)},{event:S,orientation:C,loopFocus:x,rtl:y,cols:E,disabledIndices:xo([...(typeof w!="function"?w:null)||c.current.map((ve,Te)=>wt(c,Te,w)?Te:void 0),void 0],se),minIndex:ye,maxIndex:he,prevIndex:po(A.current>ee?T:A.current,ne,se,E,S.key===St?"bl":S.key===(y?nt:rt)?"tr":"tl"),stopEvent:!0})];if(Oe!=null&&(A.current=Oe,k(S)),C==="both")return}if(Mt(S.key,C)){if(Le(S),r&&!v&&xn(S.currentTarget.ownerDocument)===S.currentTarget){A.current=qt(S.key,C,y)?T:ee,k(S);return}qt(S.key,C,y)?x?F>=ee?g&&F!==c.current.length?A.current=-1:(z.current=!1,A.current=T):A.current=Ce(c,{startingIndex:F,disabledIndices:w}):A.current=Math.min(ee,Ce(c,{startingIndex:F,disabledIndices:w})):x?F<=T?g&&F!==-1?A.current=c.current.length:(z.current=!1,A.current=ee):A.current=Ce(c,{startingIndex:F,decrement:!0,disabledIndices:w}):A.current=Math.max(T,Ce(c,{startingIndex:F,decrement:!0,disabledIndices:w})),yt(c,A.current)&&(A.current=-1),k(S)}}),re=u.useMemo(()=>v&&r&&ue&&{"aria-activedescendant":`${N}-${m}`},[v,r,ue,N,m]),J=u.useMemo(()=>({"aria-orientation":C==="both"?void 0:C,...R?{}:re,onKeyDown(S){if(S.key==="Tab"&&S.shiftKey&&r&&!v){const F=Ir(S.nativeEvent);if(F&&!xt(H.current,F))return;Le(S),n.setOpen(!1,Me(Wn,S.nativeEvent)),Je(o)&&o.focus();return}we(S)},onPointerMove(){ge.current=!0}}),[re,we,H,C,R,n,r,v,o]),be=u.useMemo(()=>{function S(T){f==="auto"&&jr(T.nativeEvent)&&(L.current=!v)}function F(T){L.current=f,f==="auto"&&Yr(T.nativeEvent)&&(L.current=!0)}return{onKeyDown(T){const ee=n.select("open");ge.current=!1;const ne=T.key.startsWith("Arrow"),se=ls(T.key,Z(),y),ye=Mt(T.key,C),he=(h?se:ye)||T.key==="Enter"||T.key.trim()==="";if(v&&ee)return we(T);if(!(!ee&&!p&&ne)){if(he){const Oe=Mt(T.key,Z());I.current=h&&Oe?null:T.key}if(h){se&&(Le(T),ee?(A.current=zt(c,De.current),k(T)):n.setOpen(!0,Me(Wt,T.nativeEvent,T.currentTarget)));return}ye&&(te.current!=null&&(A.current=te.current),Le(T),!ee&&p?n.setOpen(!0,Me(Wt,T.nativeEvent,T.currentTarget)):we(T),ee&&k(T))}},onFocus(T){n.select("open")&&!v&&(A.current=-1,k(T))},onPointerDown:F,onPointerEnter:F,onMouseDown:S,onClick:S}},[we,De,f,c,h,k,n,p,C,Z,y,te,v]),Ve=u.useMemo(()=>({...re,...be}),[re,be]);return u.useMemo(()=>l?{reference:Ve,floating:J,item:G,trigger:be}:{},[l,Ve,J,be,G])}function fs(e,t){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),s=n.context.dataRef,{listRef:o,activeIndex:i,onMatch:c,onTypingChange:m,enabled:d=!0,findMatch:l=null,resetMs:a=750,ignoreKeys:g=Gt,selectedIndex:x=null}=t,h=tt(),y=u.useRef(""),v=u.useRef(x??i??-1),f=u.useRef(null);X(()=>{r&&(h.clear(),f.current=null,y.current="")},[r,h]),X(()=>{r&&y.current===""&&(v.current=x??i??-1)},[r,x,i]);const b=xe(M=>{M?s.current.typing||(s.current.typing=M,m?.(M)):s.current.typing&&(s.current.typing=M,m?.(M))}),p=xe(M=>{function E(_,D,K){const H=l?l(D,K):D.find(P=>P?.toLocaleLowerCase().indexOf(K.toLocaleLowerCase())===0);return H?_.indexOf(H):-1}const O=o.current;if(y.current.length>0&&y.current[0]!==" "&&(E(O,O,y.current)===-1?b(!1):M.key===" "&&Le(M)),O==null||g.includes(M.key)||M.key.length!==1||M.ctrlKey||M.metaKey||M.altKey)return;r&&M.key!==" "&&(Le(M),b(!0)),O.every(_=>_?_[0]?.toLocaleLowerCase()!==_[1]?.toLocaleLowerCase():!0)&&y.current===M.key&&(y.current="",v.current=f.current),y.current+=M.key,h.start(a,()=>{y.current="",v.current=f.current,b(!1)});const q=v.current,N=E(O,[...O.slice((q||0)+1),...O.slice(0,(q||0)+1)],y.current);N!==-1?(c?.(N),f.current=N):M.key!==" "&&(y.current="",b(!1))}),w=u.useMemo(()=>({onKeyDown:p}),[p]),C=u.useMemo(()=>({onKeyDown:p,onKeyUp(M){M.key===" "&&b(!1)}}),[p,b]);return u.useMemo(()=>d?{reference:w,floating:C}:{},[d,w,C])}const ds=u.createContext(void 0);function gs(){return u.useContext(ds)?.direction??"ltr"}const ms=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:o,platform:i,elements:c,middlewareData:m}=t,{element:d,padding:l=0,offsetParent:a="real"}=Qe(e,t)||{};if(d==null)return{};const g=Zn(l),x={x:n,y:r},h=fn(s),y=un(h),v=await i.getDimensions(d),f=h==="y",b=f?"top":"left",p=f?"bottom":"right",w=f?"clientHeight":"clientWidth",C=o.reference[y]+o.reference[h]-x[h]-o.floating[y],M=x[h]-o.reference[h],E=a==="real"?await i.getOffsetParent?.(d):c.floating;let O=c.floating[w]||o.floating[y];(!O||!await i.isElement?.(E))&&(O=c.floating[w]||o.floating[y]);const Y=C/2-M/2,q=O/2-v[y]/2-1,N=Math.min(g[b],q),_=Math.min(g[p],q),D=N,K=O-v[y]-_,H=O/2-v[y]/2+Y,P=Zt(D,H,K),B=!m.arrow&&ot(s)!=null&&H!==P&&o.reference[y]/2-(H<D?N:_)-v[y]/2<0,R=B?H<D?H-D:H-K:0;return{[h]:x[h]+R,data:{[h]:P,centerOffset:H-P-R,...B&&{alignmentOffset:R}},reset:B}}}),hs=(e,t)=>({...ms(e),options:[e,t]}),ps={name:"hide",async fn(e){const{width:t,height:n,x:r,y:s}=e.rects.reference,o=t===0&&n===0&&r===0&&s===0;return{data:{referenceHidden:(await ss().fn(e)).data?.referenceHidden||o}}}},It={sideX:"left",sideY:"top"},ii={name:"adaptiveOrigin",async fn(e){const{x:t,y:n,rects:{floating:r},elements:{floating:s},platform:o,strategy:i,placement:c}=e,m=qe(s),d=m.getComputedStyle(s);if(!(d.transitionDuration!=="0s"&&d.transitionDuration!==""))return{x:t,y:n,data:It};const a=await o.getOffsetParent?.(s);let g={width:0,height:0};if(i==="fixed"&&m?.visualViewport)g={width:m.visualViewport.width,height:m.visualViewport.height};else if(a===m){const b=vt(s);g={width:b.documentElement.clientWidth,height:b.documentElement.clientHeight}}else await o.isElement?.(a)&&(g=await o.getDimensions(a));const x=Fe(c);let h=t,y=n;x==="left"&&(h=g.width-(t+r.width)),x==="top"&&(y=g.height-(n+r.height));const v=x==="left"?"right":It.sideX,f=x==="top"?"bottom":It.sideY;return{x:h,y,data:{sideX:v,sideY:f}}}};function cr(e,t,n){const r=e==="inline-start"||e==="inline-end";return{top:"top",right:r?n?"inline-start":"inline-end":"right",bottom:"bottom",left:r?n?"inline-end":"inline-start":"left"}[t]}function In(e,t,n){const{rects:r,placement:s}=e;return{side:cr(t,Fe(s),n),align:ot(s)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function xs(e){const{anchor:t,positionMethod:n="absolute",side:r="bottom",sideOffset:s=0,align:o="center",alignOffset:i=0,collisionBoundary:c,collisionPadding:m=5,sticky:d=!1,arrowPadding:l=5,disableAnchorTracking:a=!1,keepMounted:g=!1,floatingRootContext:x,mounted:h,collisionAvoidance:y,shiftCrossAxis:v=!1,nodeId:f,adaptiveOrigin:b,lazyFlip:p=!1,externalTree:w}=e,[C,M]=u.useState(null);!h&&C!==null&&M(null);const E=y.side||"flip",O=y.align||"flip",Y=y.fallbackAxisSide||"end",q=typeof t=="function"?t:void 0,N=xe(q),_=q?N:t,D=$e(t),H=gs()==="rtl",P=C||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":H?"left":"right","inline-start":H?"right":"left"}[r],B=o==="center"?P:`${P}-${o}`;let R=m;const L=1,A=r==="bottom"?L:0,I=r==="top"?L:0,ge=r==="right"?L:0,k=r==="left"?L:0;typeof R=="number"?R={top:R+A,right:R+k,bottom:R+I,left:R+ge}:R&&(R={top:(R.top||0)+A,right:(R.right||0)+k,bottom:(R.bottom||0)+I,left:(R.left||0)+ge});const ae={boundary:c==="clipping-ancestors"?"clippingAncestors":c,padding:R},Q=u.useRef(null),V=$e(s),z=$e(i),U=[es(ce=>{const pe=In(ce,r,H),de=typeof V.current=="function"?V.current(pe):V.current,Se=typeof z.current=="function"?z.current(pe):z.current;return{mainAxis:de,crossAxis:Se,alignmentAxis:Se}},[typeof s!="function"?s:0,typeof i!="function"?i:0,H,r])],le=O==="none"&&E!=="shift",te=!le&&(d||v||E==="shift"),me=E==="none"?null:rs({...ae,padding:{top:R.top+L,right:R.right+L,bottom:R.bottom+L,left:R.left+L},mainAxis:!v&&E==="flip",crossAxis:O==="flip"?"alignment":!1,fallbackAxisSideDirection:Y}),Re=le?null:ts(ce=>{const pe=vt(ce.elements.floating).documentElement;return{...ae,rootBoundary:v?{x:0,y:0,width:pe.clientWidth,height:pe.clientHeight}:void 0,mainAxis:O!=="none",crossAxis:te,limiter:d||v?void 0:ns(de=>{if(!Q.current)return{};const{width:Se,height:Be}=Q.current.getBoundingClientRect(),Ue=ze(Fe(de.placement)),Xe=Ue==="y"?Se:Be,Ge=Ue==="y"?R.left+R.right:R.top+R.bottom;return{offset:Xe/2+Ge/2}})}},[ae,d,v,R,O]);E==="shift"||O==="shift"||o==="center"?U.push(Re,me):U.push(me,Re),U.push(os({...ae,apply({elements:{floating:ce},rects:{reference:pe},availableWidth:de,availableHeight:Se}){Object.entries({"--available-width":`${de}px`,"--available-height":`${Se}px`,"--anchor-width":`${pe.width}px`,"--anchor-height":`${pe.height}px`}).forEach(([Be,Ue])=>{ce.style.setProperty(Be,Ue)})}}),hs(()=>({element:Q.current||document.createElement("div"),padding:l,offsetParent:"floating"}),[l]),{name:"transformOrigin",fn(ce){const{elements:pe,middlewareData:de,placement:Se,rects:Be,y:Ue}=ce,Xe=Fe(Se),Ge=ze(Xe),st=Q.current,at=de.arrow?.x||0,ht=de.arrow?.y||0,pt=st?.clientWidth||0,$=st?.clientHeight||0,ie=at+pt/2,Ie=ht+$/2,ke=Math.abs(de.shift?.y||0),Pe=Be.reference.height/2,Ye=typeof s=="function"?s(In(ce,r,H)):s,hn=ke>Ye,br={top:`${ie}px calc(100% + ${Ye}px)`,bottom:`${ie}px ${-Ye}px`,left:`calc(100% + ${Ye}px) ${Ie}px`,right:`${-Ye}px ${Ie}px`}[Xe],vr=`${ie}px ${Be.reference.y+Pe-Ue}px`;return pe.floating.style.setProperty("--transform-origin",te&&Ge==="y"&&hn?vr:br),{}}},ps,b),X(()=>{!h&&x&&x.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[h,x]);const ue=u.useMemo(()=>({elementResize:!a&&typeof ResizeObserver<"u",layoutShift:!a&&typeof IntersectionObserver<"u"}),[a]),{refs:G,elements:Z,x:we,y:re,middlewareData:J,update:be,placement:Ve,context:S,isPositioned:F,floatingStyles:T}=is({rootContext:x,placement:B,middleware:U,strategy:n,whileElementsMounted:g?void 0:(...ce)=>On(...ce,ue),nodeId:f,externalTree:w}),{sideX:ee,sideY:ne}=J.adaptiveOrigin||It,se=F?n:"fixed",ye=u.useMemo(()=>b?{position:se,[ee]:we,[ne]:re}:{position:se,...T},[b,se,ee,we,ne,re,T]),he=u.useRef(null);X(()=>{if(!h)return;const ce=D.current,pe=typeof ce=="function"?ce():ce,Se=(Pn(pe)?pe.current:pe)||null||null;Se!==he.current&&(G.setPositionReference(Se),he.current=Se)},[h,G,_,D]),u.useEffect(()=>{if(!h)return;const ce=D.current;typeof ce!="function"&&Pn(ce)&&ce.current!==he.current&&(G.setPositionReference(ce.current),he.current=ce.current)},[h,G,_,D]),u.useEffect(()=>{if(g&&h&&Z.domReference&&Z.floating)return On(Z.domReference,Z.floating,be,ue)},[g,h,Z,be,ue]);const Oe=Fe(Ve),ve=cr(r,Oe,H),Te=ot(Ve)||"center",We=!!J.hide?.referenceHidden;X(()=>{p&&h&&F&&M(Oe)},[p,h,F,Oe]);const He=u.useMemo(()=>({position:"absolute",top:J.arrow?.y,left:J.arrow?.x}),[J.arrow]),Ne=J.arrow?.centerOffset!==0;return u.useMemo(()=>({positionerStyles:ye,arrowStyles:He,arrowRef:Q,arrowUncentered:Ne,side:ve,align:Te,physicalSide:Oe,anchorHidden:We,refs:G,context:S,isPositioned:F,update:be}),[ye,He,Q,Ne,ve,Te,Oe,We,G,S,F,be])}function Pn(e){return e!=null&&"current"in e}function ys(e){const t=u.useRef(!0);t.current&&(t.current=!1,e())}function Ln({controlled:e,default:t,name:n,state:r="value"}){const{current:s}=u.useRef(e!==void 0),[o,i]=u.useState(t),c=s?e:o,m=u.useCallback(d=>{s||i(d)},[]);return[c,m]}const lr=u.createContext(null),ar=u.createContext(null);function lt(){const e=u.useContext(lr);if(e===null)throw new Error(Ct(60));return e}function ur(){const e=u.useContext(ar);if(e===null)throw new Error(Ct(61));return e}let Dn=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const ws={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Rs={valid(e){return e===null?null:e?{[Dn.valid]:""}:{[Dn.invalid]:""}}},bs=u.createContext({invalid:void 0,name:void 0,validityData:{state:ws,errors:[],error:"",value:"",initialValue:null},setValidityData:je,disabled:void 0,touched:!1,setTouched:je,dirty:!1,setDirty:je,filled:!1,setFilled:je,focused:!1,setFocused:je,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:{disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},markedDirtyRef:{current:!1},validation:{getValidationProps:(e=Rt)=>e,getInputValidationProps:(e=Rt)=>e,inputRef:{current:null},commit:async()=>{}}});function gn(e=!0){const t=u.useContext(bs);if(t.setValidityData===je&&!e)throw new Error(Ct(28));return t}const vs=u.createContext({controlId:void 0,setControlId:je,labelId:void 0,setLabelId:je,messageIds:[],setMessageIds:je,getDescriptionProps:e=>e});function fr(){return u.useContext(vs)}function dr(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:s,setControlId:o}=fr(),i=qr(t);return X(()=>{if(!(!n&&!t||o===je)){if(n){const c=r?.current;Ee(c)&&c.closest("label")!=null?o(t??null):o(s??i)}else t&&o(t);return()=>{t&&o(void 0)}}},[t,r,s,o,n,i]),s??i}const Ss=(e,t)=>Object.is(e,t);function mt(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Kt(e,t,n){return!e||e.length===0?!1:e.some(r=>r===void 0?!1:mt(r,t,n))}function Qt(e,t,n){return!e||e.length===0?-1:e.findIndex(r=>r===void 0?!1:mt(r,t,n))}function Cs(e,t,n){return e.filter(r=>!mt(r,t,n))}function en(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function gr(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Es(e){if(!Array.isArray(e))return e!=null&&!("null"in e);if(gr(e)){for(const t of e)for(const n of t.items)if(n&&n.value==null&&n.label!=null)return!0;return!1}for(const t of e)if(t&&t.value==null&&t.label!=null)return!0;return!1}function Ms(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return en(e)}function ut(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?en(e.value):en(e)}function mr(e,t,n){function r(){return Ms(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){const s=gr(t)?t.flatMap(o=>o.items):t;if(e==null||typeof e!="object"){const o=s.find(i=>i.value===e);return o&&o.label!=null?o.label:r()}if("value"in e){const o=s.find(i=>i&&i.value===e.value);if(o&&o.label!=null)return o.label}}return r()}function As(e,t,n){return e.reduce((r,s,o)=>(o>0&&r.push(", "),r.push(Ae.jsx(u.Fragment,{children:mr(s,t,n)},o)),r),[])}const W={id:oe(e=>e.id),modal:oe(e=>e.modal),multiple:oe(e=>e.multiple),items:oe(e=>e.items),itemToStringLabel:oe(e=>e.itemToStringLabel),itemToStringValue:oe(e=>e.itemToStringValue),isItemEqualToValue:oe(e=>e.isItemEqualToValue),value:oe(e=>e.value),hasSelectedValue:oe(e=>{const{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:ut(t,r)!==""}),hasNullItemLabel:oe((e,t)=>t?Es(e.items):!1),open:oe(e=>e.open),mounted:oe(e=>e.mounted),forceMount:oe(e=>e.forceMount),transitionStatus:oe(e=>e.transitionStatus),openMethod:oe(e=>e.openMethod),activeIndex:oe(e=>e.activeIndex),selectedIndex:oe(e=>e.selectedIndex),isActive:oe((e,t)=>e.activeIndex===t),isSelected:oe((e,t,n)=>{const r=e.isItemEqualToValue,s=e.value;return e.multiple?Array.isArray(s)&&s.some(o=>mt(o,n,r)):e.selectedIndex===t&&e.selectedIndex!==null?!0:mt(s,n,r)}),isSelectedByFocus:oe((e,t)=>e.selectedIndex===t),popupProps:oe(e=>e.popupProps),triggerProps:oe(e=>e.triggerProps),triggerElement:oe(e=>e.triggerElement),positionerElement:oe(e=>e.positionerElement),listElement:oe(e=>e.listElement),scrollUpArrowVisible:oe(e=>e.scrollUpArrowVisible),scrollDownArrowVisible:oe(e=>e.scrollDownArrowVisible),hasScrollArrows:oe(e=>e.hasScrollArrows)},Os=u.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:je,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function hr(){return u.useContext(Os)}function Ts(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}function Is(e){const{enabled:t=!0,value:n,id:r,name:s,controlRef:o,commit:i}=e,{formRef:c}=hr(),{invalid:m,markedDirtyRef:d,validityData:l,setValidityData:a}=gn(),g=xe(e.getValue);X(()=>{if(!t)return;let x=n;x===void 0&&(x=g()),l.initialValue===null&&x!==null&&a(h=>({...h,initialValue:x}))},[t,a,n,l.initialValue,g]),X(()=>{!t||!r||c.current.fields.set(r,{getValue:g,name:s,controlRef:o,validityData:Ts(l,m),validate(x=!0){let h=n;h===void 0&&(h=g()),d.current=!0,x?sn.flushSync(()=>i(h)):i(h)}})},[i,o,t,c,g,r,m,d,s,l,n]),X(()=>{const x=c.current.fields;return()=>{r&&x.delete(r)}},[c,r])}function Ps(e,t){const n=u.useRef(e),r=xe(t);X(()=>{n.current!==e&&r(n.current)},[e,r]),X(()=>{n.current=e},[e])}function ci(e){const{id:t,value:n,defaultValue:r=null,onValueChange:s,open:o,defaultOpen:i=!1,onOpenChange:c,name:m,disabled:d=!1,readOnly:l=!1,required:a=!1,modal:g=!0,actionsRef:x,inputRef:h,onOpenChangeComplete:y,items:v,multiple:f=!1,itemToStringLabel:b,itemToStringValue:p,isItemEqualToValue:w=Ss,highlightItemOnHover:C=!0,children:M}=e,{clearErrors:E}=hr(),{setDirty:O,setTouched:Y,setFocused:q,shouldValidateOnChange:N,validityData:_,setFilled:D,name:K,disabled:H,validation:P,validationMode:B}=gn(),R=dr({id:t}),L=H||d,A=K??m,[I,ge]=Ln({controlled:n,default:f?r??Gt:r,name:"Select",state:"value"}),[k,ae]=Ln({controlled:o,default:i,name:"Select",state:"open"}),Q=u.useRef([]),V=u.useRef([]),z=u.useRef(null),fe=u.useRef(null),De=u.useRef(0),U=u.useRef(null),le=u.useRef([]),te=u.useRef(!1),me=u.useRef(!1),Re=u.useRef(null),ue=u.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}),G=u.useRef(!1),{mounted:Z,setMounted:we,transitionStatus:re}=Xn(k),{openMethod:J,triggerProps:be,reset:Ve}=Kr(k),S=Lt(()=>new Zr({id:R,modal:g,multiple:f,itemToStringLabel:b,itemToStringValue:p,isItemEqualToValue:w,value:I,open:k,mounted:Z,transitionStatus:re,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,F=j(S,W.activeIndex),T=j(S,W.selectedIndex),ee=j(S,W.triggerElement),ne=j(S,W.positionerElement),se=u.useMemo(()=>f&&Array.isArray(I)&&I.length===0?"":ut(I,p),[f,I,p]),ye=u.useMemo(()=>f&&Array.isArray(I)?I.map($=>ut($,p)):ut(I,p),[f,I,p]),he=$e(S.state.triggerElement);Is({id:R,commit:P.commit,value:I,controlRef:he,name:A,getValue:()=>ye});const Oe=u.useRef(I);X(()=>{I!==Oe.current&&S.set("forceMount",!0)},[S,I]),X(()=>{D(f?Array.isArray(I)&&I.length>0:I!=null)},[f,I,D]),X(function(){if(k)return;const ie=le.current;if(f){const ke=Array.isArray(I)?I:[];if(ke.length===0){S.set("selectedIndex",null);return}const Pe=ke[ke.length-1],Ye=Qt(ie,Pe,w);S.set("selectedIndex",Ye===-1?null:Ye);return}const Ie=Qt(ie,I,w);S.set("selectedIndex",Ie===-1?null:Ie)},[f,k,I,le,w,S]),Ps(I,()=>{E(A),O(I!==_.initialValue),N()?P.commit(I):P.commit(I,!0)});const ve=xe(($,ie)=>{if(c?.($,ie),!ie.isCanceled&&(ae($),!$&&(ie.reason===Wn||ie.reason===Dr)&&(Y(!0),q(!1),B==="onBlur"&&P.commit(I)),!$&&S.state.activeIndex!==null)){const Ie=Q.current[S.state.activeIndex];queueMicrotask(()=>{Ie?.setAttribute("tabindex","-1")})}}),Te=xe(()=>{we(!1),S.set("activeIndex",null),Ve(),y?.(!1)});cn({enabled:!x,open:k,ref:z,onComplete(){k||Te()}}),u.useImperativeHandle(x,()=>({unmount:Te}),[Te]);const We=xe(($,ie)=>{s?.($,ie),!ie.isCanceled&&ge($)}),He=xe(()=>{const $=S.state.listElement||z.current;if(!$)return;const ie=$.scrollTop,Ie=$.scrollTop+$.clientHeight,ke=ie>1,Pe=Ie<$.scrollHeight-1;S.state.scrollUpArrowVisible!==ke&&S.set("scrollUpArrowVisible",ke),S.state.scrollDownArrowVisible!==Pe&&S.set("scrollDownArrowVisible",Pe)}),Ne=ir({open:k,onOpenChange:ve,elements:{reference:ee,floating:ne}}),ce=yo(Ne,{enabled:!l&&!L,event:"mousedown"}),pe=Xr(Ne,{bubbles:!1}),de=us(Ne,{enabled:!l&&!L,listRef:Q,activeIndex:F,selectedIndex:T,disabledIndices:Gt,onNavigate($){$===null&&!k||S.set("activeIndex",$)},focusItemOnHover:!1}),Se=fs(Ne,{enabled:!l&&!L&&(k||!f),listRef:V,activeIndex:F,selectedIndex:T,onMatch($){k?S.set("activeIndex",$):We(le.current[$],Me("none"))},onTypingChange($){te.current=$}}),{getReferenceProps:Be,getFloatingProps:Ue,getItemProps:Xe}=Gr([ce,pe,de,Se]),Ge=u.useMemo(()=>$n(Be(),be,R?{id:R}:Rt),[Be,be,R]);ys(()=>{S.update({popupProps:Ue(),triggerProps:Ge})}),X(()=>{S.update({id:R,modal:g,multiple:f,value:I,open:k,mounted:Z,transitionStatus:re,popupProps:Ue(),triggerProps:Ge,items:v,itemToStringLabel:b,itemToStringValue:p,isItemEqualToValue:w,openMethod:J})},[S,R,g,f,I,k,Z,re,Ue,Ge,v,b,p,w,J]);const st=u.useMemo(()=>({store:S,name:A,required:a,disabled:L,readOnly:l,multiple:f,itemToStringLabel:b,itemToStringValue:p,highlightItemOnHover:C,setValue:We,setOpen:ve,listRef:Q,popupRef:z,scrollHandlerRef:fe,handleScrollArrowVisibility:He,scrollArrowsMountedCountRef:De,getItemProps:Xe,events:Ne.context.events,valueRef:U,valuesRef:le,labelsRef:V,typingRef:te,selectionRef:ue,selectedItemTextRef:Re,validation:P,onOpenChangeComplete:y,keyboardActiveRef:me,alignItemWithTriggerActiveRef:G,initialValueRef:Oe}),[S,A,a,L,l,f,b,p,C,We,ve,Xe,Ne.context.events,P,y,He]),at=zn(h,P.inputRef),ht=f&&Array.isArray(I)&&I.length>0,pt=u.useMemo(()=>!f||!Array.isArray(I)||!A?null:I.map($=>{const ie=ut($,p);return Ae.jsx("input",{type:"hidden",name:A,value:ie},ie)}),[f,I,A,p]);return Ae.jsx(lr.Provider,{value:st,children:Ae.jsxs(ar.Provider,{value:Ne,children:[M,Ae.jsx("input",{...P.getInputValidationProps({onFocus(){S.state.triggerElement?.focus({focusVisible:!0})},onChange($){if($.nativeEvent.defaultPrevented)return;const ie=$.target.value,Ie=Me(ln,$.nativeEvent);function ke(){if(f)return;const Pe=le.current.find(Ye=>ut(Ye,p).toLowerCase()===ie.toLowerCase());Pe!=null&&(O(Pe!==_.initialValue),We(Pe,Ie),N()&&P.commit(Pe))}S.set("forceMount",!0),queueMicrotask(ke)}}),name:f?void 0:A,value:se,disabled:L,required:a&&!ht,readOnly:l,ref:at,style:A?Pr:Lr,tabIndex:-1,"aria-hidden":!0}),pt]})})}function Ls(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e,"::before"),r=window.getComputedStyle(e,"::after");if(!(n.content!=="none"||r.content!=="none"))return t;const o=parseFloat(n.width)||0,i=parseFloat(n.height)||0,c=parseFloat(r.width)||0,m=parseFloat(r.height)||0,d=Math.max(t.width,o,c),l=Math.max(t.height,i,m),a=d-t.width,g=l-t.height;return{left:t.left-a/2,right:t.right+a/2,top:t.top-g/2,bottom:t.bottom+g/2}}const At=2,Ds=400,Vn=200,Vs={...Jr,...Rs,value:()=>null},li=u.forwardRef(function(t,n){const{render:r,className:s,id:o,disabled:i=!1,nativeButton:c=!0,...m}=t,{setTouched:d,setFocused:l,validationMode:a,state:g,disabled:x}=gn(),{labelId:h}=fr(),{store:y,setOpen:v,selectionRef:f,validation:b,readOnly:p,required:w,alignItemWithTriggerActiveRef:C,disabled:M,keyboardActiveRef:E}=lt(),O=x||M||i,Y=j(y,W.open),q=j(y,W.value),N=j(y,W.triggerProps),_=j(y,W.positionerElement),D=j(y,W.listElement),K=j(y,W.id),H=j(y,W.hasSelectedValue),P=!H&&Y,B=j(y,W.hasNullItemLabel,P),R=o??K;dr({id:R});const L=$e(_),A=u.useRef(null),{getButtonProps:I,buttonRef:ge}=jn({disabled:O,native:c}),k=xe(te=>{y.set("triggerElement",te)}),ae=zn(n,A,ge,k),Q=tt(),V=tt(),z=tt(),fe=tt();u.useEffect(()=>{if(Y)return!(H||B)?z.start(Ds,()=>{f.current.allowUnselectedMouseUp=!0,f.current.allowSelectedMouseUp=!0}):fe.start(Vn,()=>{f.current.allowUnselectedMouseUp=!0,z.start(Vn,()=>{f.current.allowSelectedMouseUp=!0})}),()=>{z.clear(),fe.clear()};f.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1},V.clear()},[Y,H,B,f,V,z,fe]);const De=u.useMemo(()=>D?.id??_n(_)?.id,[D,_]),U=$n(N,{id:R,role:"combobox","aria-expanded":Y?"true":"false","aria-haspopup":"listbox","aria-controls":Y?De:void 0,"aria-labelledby":h,"aria-readonly":p||void 0,"aria-required":w||void 0,tabIndex:O?-1:0,ref:ae,onFocus(te){l(!0),Y&&C.current&&v(!1,Me(ln,te.nativeEvent)),Q.start(0,()=>{y.set("forceMount",!0)})},onBlur(te){xt(_,te.relatedTarget)||(d(!0),l(!1),a==="onBlur"&&b.commit(q))},onPointerMove(){E.current=!1},onKeyDown(){E.current=!0},onMouseDown(te){if(Y)return;const me=vt(te.currentTarget);function Re(ue){if(!A.current)return;const G=ue.target;if(xt(A.current,G)||xt(L.current,G)||G===A.current)return;const Z=Ls(A.current);ue.clientX>=Z.left-At&&ue.clientX<=Z.right+At&&ue.clientY>=Z.top-At&&ue.clientY<=Z.bottom+At||v(!1,Me(Vr,ue))}V.start(0,()=>{me.addEventListener("mouseup",Re,{once:!0})})}},b.getValidationProps,m,I);U.role="combobox";const le=u.useMemo(()=>({...g,open:Y,disabled:O,value:q,readOnly:p,placeholder:!H}),[g,Y,O,q,p,H]);return ct("button",t,{ref:[n,A],state:le,stateAttributesMapping:Vs,props:U})}),ks={value:()=>null},ai=u.forwardRef(function(t,n){const{className:r,render:s,children:o,placeholder:i,...c}=t,{store:m,valueRef:d}=lt(),l=j(m,W.value),a=j(m,W.items),g=j(m,W.itemToStringLabel),x=j(m,W.hasSelectedValue),h=!x&&i!=null&&o==null,y=j(m,W.hasNullItemLabel,h),v=u.useMemo(()=>({value:l,placeholder:!x}),[l,x]);let f=null;return typeof o=="function"?f=o(l):o!=null?f=o:!x&&i!=null&&!y?f=i:Array.isArray(l)?f=As(l,a,g):f=mr(l,a,g),ct("span",t,{state:v,ref:[n,d],props:[{children:f},c],stateAttributesMapping:ks})}),Fs=u.createContext(void 0),ui=u.forwardRef(function(t,n){const{store:r}=lt(),s=j(r,W.mounted),o=j(r,W.forceMount);return s||o?Ae.jsx(Fs.Provider,{value:!0,children:Ae.jsx(kr,{ref:n,...t})}):null}),pr=u.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function Hs(){return u.useContext(pr)}function Ns(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:s}=e,o=xe(s),i=u.useRef(0),c=Lt(Us).current,m=Lt(Bs).current,[d,l]=u.useState(0),a=u.useRef(d),g=xe((f,b)=>{m.set(f,b??null),a.current+=1,l(a.current)}),x=xe(f=>{m.delete(f),a.current+=1,l(a.current)}),h=u.useMemo(()=>{const f=new Map;return Array.from(m.keys()).filter(p=>p.isConnected).sort(_s).forEach((p,w)=>{const C=m.get(p)??{};f.set(p,{...C,index:w})}),f},[m,d]);X(()=>{if(typeof MutationObserver!="function"||h.size===0)return;const f=new MutationObserver(b=>{const p=new Set,w=C=>p.has(C)?p.delete(C):p.add(C);b.forEach(C=>{C.removedNodes.forEach(w),C.addedNodes.forEach(w)}),p.size===0&&(a.current+=1,l(a.current))});return h.forEach((b,p)=>{p.parentElement&&f.observe(p.parentElement,{childList:!0})}),()=>{f.disconnect()}},[h]),X(()=>{a.current===d&&(n.current.length!==h.size&&(n.current.length=h.size),r&&r.current.length!==h.size&&(r.current.length=h.size),i.current=h.size),o(h)},[o,h,n,r,d]),X(()=>()=>{n.current=[]},[n]),X(()=>()=>{r&&(r.current=[])},[r]);const y=xe(f=>(c.add(f),()=>{c.delete(f)}));X(()=>{c.forEach(f=>f(h))},[c,h]);const v=u.useMemo(()=>({register:g,unregister:x,subscribeMapChange:y,elementsRef:n,labelsRef:r,nextIndexRef:i}),[g,x,y,n,r,i]);return Ae.jsx(pr.Provider,{value:v,children:t})}function Bs(){return new Map}function Us(){return new Set}function _s(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const xr=u.createContext(void 0);function Ws(){const e=u.useContext(xr);if(!e)throw new Error(Ct(59));return e}function Ht(e,t){e&&Object.assign(e.style,t)}const $s={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},zs={position:"fixed"},fi=u.forwardRef(function(t,n){const{anchor:r,positionMethod:s="absolute",className:o,render:i,side:c="bottom",align:m="center",sideOffset:d=0,alignOffset:l=0,collisionBoundary:a="clipping-ancestors",collisionPadding:g,arrowPadding:x=5,sticky:h=!1,disableAnchorTracking:y,alignItemWithTrigger:v=!0,collisionAvoidance:f=Fr,...b}=t,{store:p,listRef:w,labelsRef:C,alignItemWithTriggerActiveRef:M,selectedItemTextRef:E,valuesRef:O,initialValueRef:Y,popupRef:q,setValue:N}=lt(),_=ur(),D=j(p,W.open),K=j(p,W.mounted),H=j(p,W.modal),P=j(p,W.value),B=j(p,W.openMethod),R=j(p,W.positionerElement),L=j(p,W.triggerElement),A=j(p,W.isItemEqualToValue),I=u.useRef(null),ge=u.useRef(null),[k,ae]=u.useState(v),Q=K&&k&&B!=="touch";!K&&k!==v&&ae(v),X(()=>{K||(W.scrollUpArrowVisible(p.state)&&p.set("scrollUpArrowVisible",!1),W.scrollDownArrowVisible(p.state)&&p.set("scrollDownArrowVisible",!1))},[p,K]),u.useImperativeHandle(M,()=>Q),Qr((Q||H)&&D&&B!=="touch",L);const V=xs({anchor:r,floatingRootContext:_,positionMethod:s,mounted:K,side:c,sideOffset:d,align:m,alignOffset:l,arrowPadding:x,collisionBoundary:a,collisionPadding:g,sticky:h,disableAnchorTracking:y??Q,collisionAvoidance:f,keepMounted:!0}),z=Q?"none":V.side,fe=Q?zs:V.positionerStyles,De=u.useMemo(()=>{const G={};return D||(G.pointerEvents="none"),{role:"presentation",hidden:!K,style:{...fe,...G}}},[D,K,fe]),U=u.useMemo(()=>({open:D,side:z,align:V.align,anchorHidden:V.anchorHidden}),[D,z,V.align,V.anchorHidden]),le=xe(G=>{p.set("positionerElement",G)}),te=ct("div",t,{ref:[n,le],state:U,stateAttributesMapping:Gn,props:[De,b]}),me=u.useRef(0),Re=xe(G=>{if(G.size===0&&me.current===0||O.current.length===0)return;const Z=me.current;if(me.current=G.size,G.size===Z)return;const we=Me(ln);if(Z!==0&&!p.state.multiple&&P!==null&&Qt(O.current,P,A)===-1){const J=Y.current,Ve=J!=null&&Kt(O.current,J,A)?J:null;N(Ve,we),Ve===null&&(p.set("selectedIndex",null),E.current=null)}if(Z!==0&&p.state.multiple&&Array.isArray(P)){const re=P.filter(J=>Kt(O.current,J,A));(re.length!==P.length||re.some(J=>!Kt(P,J,A)))&&(N(re,we),re.length===0&&(p.set("selectedIndex",null),E.current=null))}if(D&&Q){p.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const re={height:""};Ht(R,re),Ht(q.current,re)}}),ue=u.useMemo(()=>({...V,side:z,alignItemWithTriggerActive:Q,setControlledAlignItemWithTrigger:ae,scrollUpArrowRef:I,scrollDownArrowRef:ge}),[V,z,Q,ae]);return Ae.jsx(Ns,{elementsRef:w,labelsRef:C,onMapChange:Re,children:Ae.jsxs(xr.Provider,{value:ue,children:[K&&H&&Ae.jsx(eo,{inert:Hr(!D),cutout:L}),te]})})});function yr(e){const t=e.currentTarget.getBoundingClientRect();return t.top+1<=e.clientY&&e.clientY<=t.bottom-1&&t.left+1<=e.clientX&&e.clientX<=t.right-1}const Ot="base-ui-disable-scrollbar",kn={className:Ot,getElement(e){return Ae.jsx("style",{nonce:e,href:Ot,precedence:"base-ui:low",children:`.${Ot}{scrollbar-width:none}.${Ot}::-webkit-scrollbar{display:none}`})}},js=u.createContext(void 0);function Ys(e){return u.useContext(js)}function qs(e){return e==="starting"?Nr:Rt}function Ks(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const Xs=u.createContext(void 0),Gs={disableStyleElements:!1};function Zs(){return u.useContext(Xs)??Gs}const Js={...Gn,...Yn},di=u.forwardRef(function(t,n){const{render:r,className:s,...o}=t,{store:i,popupRef:c,onOpenChangeComplete:m,setOpen:d,valueRef:l,selectedItemTextRef:a,keyboardActiveRef:g,multiple:x,handleScrollArrowVisibility:h,scrollHandlerRef:y,highlightItemOnHover:v}=lt(),{side:f,align:b,alignItemWithTriggerActive:p,setControlledAlignItemWithTrigger:w,scrollDownArrowRef:C,scrollUpArrowRef:M}=Ws(),E=Ys()!=null,O=ur(),{nonce:Y,disableStyleElements:q}=Zs(),N=tt(),_=j(i,W.id),D=j(i,W.open),K=j(i,W.mounted),H=j(i,W.popupProps),P=j(i,W.transitionStatus),B=j(i,W.triggerElement),R=j(i,W.positionerElement),L=j(i,W.listElement),A=u.useRef(0),I=u.useRef(!1),ge=u.useRef(0),k=u.useRef(!1),ae=u.useRef({}),Q=Nn(),V=xe(U=>{if(!R||!c.current||!k.current)return;if(I.current||!p){h();return}const le=R.style.top==="0px",te=R.style.bottom==="0px",me=R.getBoundingClientRect().height,Re=vt(R),ue=getComputedStyle(R),G=parseFloat(ue.marginTop),Z=parseFloat(ue.marginBottom),we=Fn(getComputedStyle(c.current)),re=Re.documentElement.clientHeight-G-Z,J=U.scrollTop,be=U.scrollHeight,Ve=U.clientHeight,S=be-Ve;let F=0,T=null,ee=!1;if(le){const ne=S-J,se=me+ne,ye=Math.min(se,re);F=ye,ye!==re?T=S:ee=!0}else if(te){const ne=J-0,se=me+ne,ye=Math.min(se,re),he=se-re;F=ye,ye!==re?T=0:(ee=!0,J<S&&(T=J-(ne-he)))}F!==0&&(R.style.height=`${F}px`),T!=null&&(U.scrollTop=T),(ee||F>=we)&&(I.current=!0),h()});u.useImperativeHandle(y,()=>V,[V]),cn({open:D,ref:c,onComplete(){D&&m?.(!0)}});const z=u.useMemo(()=>({open:D,transitionStatus:P,side:f,align:b}),[D,P,f,b]);X(()=>{!R||!c.current||Object.keys(ae.current).length||(ae.current={top:R.style.top||"0",left:R.style.left||"0",right:R.style.right,height:R.style.height,bottom:R.style.bottom,minHeight:R.style.minHeight,maxHeight:R.style.maxHeight,marginTop:R.style.marginTop,marginBottom:R.style.marginBottom})},[c,R]),X(()=>{D||p||(k.current=!1,I.current=!1,A.current=0,ge.current=0,Ht(R,ae.current))},[D,p,R,c]),X(()=>{const U=c.current;if(!(!D||!B||!R||!U||i.state.transitionStatus==="ending")){if(!p){k.current=!0,Q.request(h),U.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const le=ei(U);U.style.removeProperty("--transform-origin");try{const te=getComputedStyle(R),me=getComputedStyle(U),Re=vt(B),ue=qe(R),G=B.getBoundingClientRect(),Z=R.getBoundingClientRect(),we=G.left,re=G.height,J=L||U,be=J.scrollHeight,Ve=parseFloat(me.borderBottomWidth),S=parseFloat(te.marginTop)||10,F=parseFloat(te.marginBottom)||10,T=parseFloat(te.minHeight)||100,ee=Fn(me),ne=5,se=5,ye=20,he=Re.documentElement.clientHeight-S-F,Oe=Re.documentElement.clientWidth,ve=he-G.bottom+re,Te=a.current,We=l.current;let He,Ne=0,ce=0;if(Te&&We){const $=We.getBoundingClientRect();He=Te.getBoundingClientRect();const ie=$.left-we,Ie=He.left-Z.left,ke=$.top-G.top+$.height/2,Pe=He.top-Z.top+He.height/2;Ne=ie-Ie,ce=Pe-ke}const pe=ve+ce+F+Ve;let de=Math.min(he,pe);const Se=he-S-F,Be=pe-de,Ue=Math.max(ne,we+Ne),Xe=Oe-se,Ge=Math.max(0,Ue+Z.width-Xe);R.style.left=`${Ue-Ge}px`,R.style.height=`${de}px`,R.style.maxHeight="auto",R.style.marginTop=`${S}px`,R.style.marginBottom=`${F}px`,U.style.height="100%";const st=J.scrollHeight-J.clientHeight,at=Be>=st;at&&(de=Math.min(he,Z.height)-(Be-st));const ht=G.top<ye||G.bottom>he-ye||de<Math.min(be,T),pt=(ue.visualViewport?.scale??1)!==1&&Br;if(ht||pt){k.current=!0,Ht(R,ae.current),sn.flushSync(()=>w(!1));return}if(at){const $=Math.max(0,he-pe);R.style.top=Z.height>=Se?"0":`${$}px`,R.style.height=`${de}px`,J.scrollTop=J.scrollHeight-J.clientHeight,A.current=Math.max(T,de)}else R.style.bottom="0",A.current=Math.max(T,de),J.scrollTop=Be;if(He){const $=Z.top,ie=Z.height,Ie=He.top+He.height/2,ke=ie>0?(Ie-$)/ie*100:50,Pe=Ks(ke,0,100);U.style.setProperty("--transform-origin",`50% ${Pe}%`)}(A.current===he||de>=ee)&&(I.current=!0),h(),setTimeout(()=>{k.current=!0})}finally{le()}})}},[i,D,R,B,l,a,c,h,p,w,Q,C,M,L]),u.useEffect(()=>{if(!p||!R||!D)return;const U=qe(R);function le(te){d(!1,Me(Ur,te))}return U.addEventListener("resize",le),()=>{U.removeEventListener("resize",le)}},[d,p,R,D]);const fe={...L?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":x||void 0,id:`${_}-list`},onKeyDown(U){g.current=!0,E&&no.has(U.key)&&U.stopPropagation()},onMouseMove(){g.current=!1},onPointerLeave(U){if(!v||yr(U)||U.pointerType==="touch")return;const le=U.currentTarget;N.start(0,()=>{i.set("activeIndex",null),le.focus({preventScroll:!0})})},onScroll(U){L||y.current?.(U.currentTarget)},...p&&{style:L?{height:"100%"}:$s}},De=ct("div",t,{ref:[n,c],state:z,stateAttributesMapping:Js,props:[H,fe,qs(P),{className:!L&&p?kn.className:void 0},o]});return Ae.jsxs(u.Fragment,{children:[!q&&kn.getElement(Y),Ae.jsx(to,{context:O,modal:!1,disabled:!K,restoreFocus:!0,children:De})]})});function Fn(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}const Hn={transform:"none",scale:"1",translate:"0 0"};function Qs(e,t,n){n?e.setProperty(t,n):e.removeProperty(t)}function ei(e){const{style:t}=e,n={},r=Object.keys(Hn);for(const s of r)n[s]=t.getPropertyValue(s),t.setProperty(s,Hn[s]);return()=>{for(const s of r)Qs(t,s,n[s])}}let wr=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function ti(e={}){const{label:t,metadata:n,textRef:r,indexGuessBehavior:s,index:o}=e,{register:i,unregister:c,subscribeMapChange:m,elementsRef:d,labelsRef:l,nextIndexRef:a}=Hs(),g=u.useRef(-1),[x,h]=u.useState(o??(s===wr.GuessFromOrder?()=>{if(g.current===-1){const f=a.current;a.current+=1,g.current=f}return g.current}:-1)),y=u.useRef(null),v=u.useCallback(f=>{if(y.current=f,x!==-1&&f!==null&&(d.current[x]=f,l)){const b=t!==void 0;l.current[x]=b?t:r?.current?.textContent??f.textContent}},[x,d,l,t,r]);return X(()=>{if(o!=null)return;const f=y.current;if(f)return i(f,n),()=>{c(f)}},[o,i,c,n]),X(()=>{if(o==null)return m(f=>{const b=y.current?f.get(y.current)?.index:null;b!=null&&h(b)})},[o,m,h]),u.useMemo(()=>({ref:v,index:x}),[x,v])}const Rr=u.createContext(void 0);function mn(){const e=u.useContext(Rr);if(!e)throw new Error(Ct(57));return e}const gi=u.memo(u.forwardRef(function(t,n){const{render:r,className:s,value:o=null,label:i,disabled:c=!1,nativeButton:m=!1,...d}=t,l=u.useRef(null),a=ti({label:i,textRef:l,indexGuessBehavior:wr.GuessFromOrder}),{store:g,getItemProps:x,setOpen:h,setValue:y,selectionRef:v,typingRef:f,valuesRef:b,keyboardActiveRef:p,multiple:w,highlightItemOnHover:C}=lt(),M=tt(),E=j(g,W.isActive,a.index),O=j(g,W.isSelected,a.index,o),Y=j(g,W.isSelectedByFocus,a.index),q=j(g,W.isItemEqualToValue),N=a.index,_=N!==-1,D=u.useRef(null),K=$e(N);X(()=>{if(!_)return;const V=b.current;return V[N]=o,()=>{delete V[N]}},[_,N,o,b]),X(()=>{if(!_)return;const V=g.state.value;let z=V;w&&Array.isArray(V)&&V.length>0&&(z=V[V.length-1]),z!==void 0&&mt(z,o,q)&&g.set("selectedIndex",N)},[_,N,w,q,g,o]);const H=u.useMemo(()=>({disabled:c,selected:O,highlighted:E}),[c,O,E]),P=x({active:E,selected:O});P.onFocus=void 0,P.id=void 0;const B=u.useRef(null),R=u.useRef("mouse"),L=u.useRef(!1),{getButtonProps:A,buttonRef:I}=jn({disabled:c,focusableWhenDisabled:!0,native:m});function ge(V){const z=g.state.value;if(w){const fe=Array.isArray(z)?z:[],De=O?Cs(fe,o,q):[...fe,o];y(De,Me($t,V))}else y(o,Me($t,V)),h(!1,Me($t,V))}const k={role:"option","aria-selected":O,tabIndex:E?0:-1,onFocus(){g.set("activeIndex",N)},onMouseEnter(){!p.current&&g.state.selectedIndex===null&&g.set("activeIndex",N)},onMouseMove(){C&&g.set("activeIndex",N)},onMouseLeave(V){!C||p.current||yr(V)||M.start(0,()=>{g.state.activeIndex===N&&g.set("activeIndex",null)})},onTouchStart(){v.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(V){B.current=V.key,g.set("activeIndex",N)},onClick(V){L.current=!1,!(V.type==="keydown"&&B.current===null)&&(c||B.current===" "&&f.current||R.current!=="touch"&&!E||(B.current=null,ge(V.nativeEvent)))},onPointerEnter(V){R.current=V.pointerType},onPointerDown(V){R.current=V.pointerType,L.current=!0},onMouseUp(V){if(c)return;if(L.current){L.current=!1;return}const z=!v.current.allowSelectedMouseUp&&O,fe=!v.current.allowUnselectedMouseUp&&!O;z||fe||R.current!=="touch"&&!E||ge(V.nativeEvent)}},ae=ct("div",t,{ref:[I,n,a.ref,D],state:H,props:[P,k,d,A]}),Q=u.useMemo(()=>({selected:O,indexRef:K,textRef:l,selectedByFocus:Y,hasRegistered:_}),[O,K,l,Y,_]);return Ae.jsx(Rr.Provider,{value:Q,children:ae})})),mi=u.forwardRef(function(t,n){const r=t.keepMounted??!1,{selected:s}=mn();return r||s?Ae.jsx(ni,{...t,ref:n}):null}),ni=u.memo(u.forwardRef((e,t)=>{const{render:n,className:r,keepMounted:s,...o}=e,{selected:i}=mn(),c=u.useRef(null),{transitionStatus:m,setMounted:d}=Xn(i),l=u.useMemo(()=>({selected:i,transitionStatus:m}),[i,m]),a=ct("span",e,{ref:[t,c],state:l,props:[{"aria-hidden":!0,children:"✔️"},o],stateAttributesMapping:Yn});return cn({open:i,ref:c,onComplete(){i||d(!1)}}),a})),hi=u.memo(u.forwardRef(function(t,n){const{indexRef:r,textRef:s,selectedByFocus:o,hasRegistered:i}=mn(),{selectedItemTextRef:c}=lt(),{className:m,render:d,...l}=t,a=u.useCallback(x=>{if(!x||!i)return;const h=c.current===null||!c.current.isConnected;(o||h&&r.current===0)&&(c.current=x)},[c,r,o,i]);return ct("div",t,{ref:[a,n,s],props:l})}));export{si as C,$s as L,ci as S,hr as a,gn as b,fr as c,Ln as d,Is as e,Rs as f,Ps as g,li as h,ai as i,ui as j,fi as k,di as l,gi as m,hi as n,mi as o,yo as p,xs as q,qs as r,W as s,ii as t,lt as u,Ys as v,Ws as w,kn as x};
@@ -1 +1 @@
1
- import{c as y,r as l,ah as Q,ab as q,aE as L,j as n,m as A,N as v,A as s,Q as X,ao as ee,at as te,au as ne,av as O,aF as ae,aG as ie,as as se,O as oe,R as re,K as le,M as ce,W as ue,aH as de,aI as ge,aJ as he,aK as pe,E as me,aL as be,aM as fe,aN as xe,aO as ye,aP as ve,aQ as je,aR as ke,a9 as Ne}from"./main-BIY3Nj6I.js";import{a as Se,b as E,u as we,L as G}from"./use-limits-display-prefs-B4iJ-bBc.js";import{S as j,T as k,a as b,b as _,u as P}from"./use-native-settings-DHjPFDv8.js";import{C as Ce}from"./useOpenInteractionType-BQhgq4rv.js";import{u as Le}from"./useCurrency-BsSZiZMP.js";import{S as D}from"./Select-tT9x4ntD.js";import{I as Ee}from"./info-Bh5qTz6k.js";import{D as Ge}from"./download-DbBBBpJF.js";import"./Card-GROxUc_6.js";import"./SelectItemText-C7F7eIm0.js";const Ie=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ae=y("activity",Ie);const Oe=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],_e=y("copy",Oe);const Pe=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],De=y("grip-vertical",Pe);const Te=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],Me=y("languages",Te);const Ue=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Re=y("log-out",Ue);const Fe=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],He=y("pencil",Fe),$e=e=>!e.isLayoutDirty&&e.willUpdate(!1);function I(){const e=new Set,t=new WeakMap,a=()=>e.forEach($e);return{add:i=>{e.add(i),t.set(i,i.addEventListener("willUpdate",a))},remove:i=>{e.delete(i);const o=t.get(i);o&&(o(),t.delete(i)),a()},dirty:a}}const Be=l.createContext(null);function ze(){const e=l.useRef(!1);return Q(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function Ve(){const e=ze(),[t,a]=l.useState(0),i=l.useCallback(()=>{e.current&&a(t+1)},[t]);return[l.useCallback(()=>q.postRender(i),[i]),t]}const T=e=>e===!0,Ke=e=>T(e===!0)||e==="id",We=({children:e,id:t,inherit:a=!0})=>{const i=l.useContext(L),o=l.useContext(Be),[r,c]=Ve(),u=l.useRef(null),g=i.id||o;u.current===null&&(Ke(a)&&g&&(t=t?g+"-"+t:g),u.current={id:t,group:T(a)&&i.group||I()});const h=l.useMemo(()=>({...u.current,forceRender:r}),[c]);return n.jsx(L.Provider,{value:h,children:e})},Ze=new Set(["cursor","kiro","copilot","kimi"]);function Ye({checked:e,onChange:t,ariaLabel:a}){return n.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":a,onClick:t,className:v("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:n.jsx("span",{className:v("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function Je({prefs:e}){const{order:t,visibility:a,toggle:i,moveToward:o}=e,[r,c]=l.useState(null),[u,g]=l.useState(null),h=d=>p=>{c(d),p.dataTransfer.effectAllowed="move",p.dataTransfer.setData("text/plain",d)},m=d=>p=>{p.preventDefault(),p.dataTransfer.dropEffect="move",r&&r!==d&&u!==d&&(g(d),o(r,d))},f=()=>{c(null),g(null)},x=d=>{d.preventDefault(),c(null),g(null)};return n.jsx(We,{children:n.jsx("div",{className:"flex flex-col",children:t.map(d=>{const p=a[d]!==!1,N=r===d;return n.jsxs(A.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:h(d),onDragOver:m(d),onDragEnd:f,onDrop:x,className:v("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",N&&"opacity-40"),style:{cursor:N?"grabbing":"grab"},children:[n.jsx(De,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),n.jsx("img",{src:Se[d],alt:"",width:18,height:18,className:v("h-[18px] w-[18px] shrink-0 pointer-events-none",Ze.has(d)&&"dark:invert"),draggable:!1}),n.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:E[d]}),n.jsx("div",{onMouseDown:S=>S.stopPropagation(),draggable:!1,children:n.jsx(Ye,{checked:p,onChange:()=>i(d),ariaLabel:`${s("limits.settings.toggle_visible")}: ${E[d]}`})})]},d)})})})}function Qe(e){if(!e||typeof e!="object")return"";const t=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},a=e.profile&&typeof e.profile=="object"?e.profile:{},i=t.full_name||t.name||a.name||t.user_name||t.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function qe(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function Xe(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const a=t.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=t.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=a?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function w(e,t){console.warn(`[tokentracker] settings ${e}:`,t)}function et(e,t,a){const[i,o]=l.useState(()=>ee()),r=t&&a&&se(),c=l.useCallback(async()=>{const u=!i;if(te(u),o(u),!!u)try{await ne(()=>e())}catch(g){w("cloud sync",g)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:c,showLocalCloudSync:r}}function tt(e){const[t,a]=l.useState(!1),[i,o]=l.useState(!1),[r,c]=l.useState(!1),[u,g]=l.useState(!1),[h,m]=l.useState(null),[f,x]=l.useState(!1),[d,p]=l.useState(""),[N,S]=l.useState(!1),[F,C]=l.useState(""),[H,$]=l.useState(""),[B,z]=l.useState(!1),[V,K]=l.useState(null),W=l.useMemo(()=>Qe(e),[e]),Z=l.useMemo(()=>qe(e),[e]),Y=l.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),J=l.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:m,setGithubUrl:C,setProfileLoading:c,setPublicProfileOn:a,setShowGithubOn:S}),[]);return{anonymousOn:i,customDisplayName:h,displayName:W,editingGithub:B,editingName:f,email:Z,githubError:V,githubInput:H,githubUrl:F,loadSetters:J,nameInput:d,profileLoading:r,profileSaving:u,publicProfileOn:t,setAnonymousOn:o,setCustomDisplayName:m,setEditingGithub:z,setEditingName:x,setGithubError:K,setGithubInput:$,setGithubUrl:C,setNameInput:p,setProfileLoading:c,setProfileSaving:g,setPublicProfileOn:a,setShowGithubOn:S,showGithubOn:N,userId:Y}}function nt(e,t,a){l.useEffect(()=>{if(!t)return;let i=!0;return a.setProfileLoading(!0),(async()=>{try{const o=await O({getAccessToken:e});if(!i||!o)return;const r=await ae({accessToken:o});if(!i)return;a.setPublicProfileOn(!!r?.enabled),a.setAnonymousOn(!!r?.anonymous),r?.display_name&&a.setCustomDisplayName(r.display_name),a.setShowGithubOn(!!r?.show_github_url),a.setGithubUrl(r?.github_url||"")}catch(o){w("load public profile",o)}finally{i&&a.setProfileLoading(!1)}})(),()=>{i=!1}},[e,t,a])}function at(e,t){return l.useCallback(async(a,{label:i,onError:o,onSuccess:r}={})=>{if(t.profileSaving)return!1;t.setProfileSaving(!0);try{const c=await O({getAccessToken:e});if(!c)return!1;const u=await ie({accessToken:c,...a});return r?.(u),!0}catch(c){return o?o(c):w(i||"mutate profile",c),!1}finally{t.setProfileSaving(!1)}},[e,t])}function it(e,t){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:t.handleAnonymousToggle,handleSaveName:t.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:t.startEditingName}}function st(e,t){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:t.handleSaveGithub,handleShowGithubToggle:t.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:t.startEditingGithub}}function ot(e,t){const a=l.useCallback(async()=>{const o=!e.publicProfileOn;await t({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[t,e]);return{handleAnonymousToggle:l.useCallback(async()=>{const o=!e.anonymousOn;await t({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[t,e]),handlePublicProfileToggle:a}}function rt(e,t,a){const i=l.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await t({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),a?.()}})},[t,e,a]),o=l.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function lt(e,t){const a=l.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await t({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[t,e]),i=l.useCallback(async()=>{const r=Xe(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(s("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await t({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:c=>e.setGithubError(c?.message||s("settings.account.githubUrlInvalid")),onSuccess:c=>{e.setGithubUrl(c?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[t,e]),o=l.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:a,startEditingGithub:o}}function ct(){const e=X(),t=tt(e.user),a=et(e.getAccessToken,e.enabled,e.signedIn);nt(e.getAccessToken,e.signedIn,t.loadSetters);const i=at(e.getAccessToken,t),o=ot(t,i),r=rt(t,i,e.refreshDisplayName),c=lt(t,i);return{...e,...a,email:t.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:t.userId,name:it(t,{...o,...r}),github:st(t,c),profileLoading:t.profileLoading,profileSaving:t.profileSaving,publicProfileOn:t.publicProfileOn}}function M({disabled:e,onCancel:t,onSave:a,saveLabel:i=s("settings.account.save")}){return n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",onClick:a,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:i}),n.jsx("button",{type:"button",onClick:t,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:s("settings.account.cancel")})]})}function ut({nameInput:e,setEditingName:t,setNameInput:a,profileSaving:i,handleSaveName:o}){return n.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[n.jsx("input",{type:"text",value:e,onChange:r=>a(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&t(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:s("settings.account.displayName")}),n.jsx(M,{disabled:i||!e.trim(),onCancel:()=>t(!1),onSave:o,saveLabel:i?s("settings.account.saving"):void 0})]})}function dt({githubError:e,githubInput:t,handleSaveGithub:a,profileSaving:i,setEditingGithub:o,setGithubError:r,setGithubInput:c}){return n.jsxs("div",{className:"mt-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"text",value:t,onChange:u=>{c(u.target.value),e&&r(null)},onKeyDown:u=>{u.key==="Enter"&&a(),u.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:s("settings.account.githubUrlPlaceholder")}),n.jsx(M,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:a,saveLabel:i?s("settings.account.saving"):void 0})]}),e?n.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function U({disabled:e=!1,label:t,onClick:a,title:i}){return n.jsxs("button",{type:"button",onClick:a,disabled:e,title:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[n.jsx(He,{className:"h-3.5 w-3.5","aria-hidden":!0}),t]})}function R({actions:e,editing:t,editor:a,hint:i,label:o}){return n.jsx("div",{className:"py-3",children:n.jsxs("div",{className:"flex items-start justify-between gap-4",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),t?a:n.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),t?null:e]})})}function gt({name:e}){const t=e.anonymousOn?s("settings.account.displayNameDisabledWhileAnon"):void 0;return n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(U,{disabled:e.anonymousOn,label:s("settings.account.edit"),onClick:e.startEditingName,title:t}),n.jsx(k,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:s("settings.account.displayName")})]})}function ht({name:e}){const{anonymousOn:t,customDisplayName:a,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:c,nameInput:u,profileLoading:g,profileSaving:h,setEditingName:m,setNameInput:f,startEditingName:x}=e,d=t?s("settings.account.displayNameAnonymousHint"):a||i;return n.jsx(R,{label:s("settings.account.displayName"),editing:o,hint:d,editor:n.jsx(ut,{nameInput:u,setEditingName:m,setNameInput:f,profileSaving:h,handleSaveName:c}),actions:n.jsx(gt,{name:e})})}function pt({github:e}){const{editingGithub:t,githubError:a,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:c,profileLoading:u,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:f,showGithubOn:x,startEditingGithub:d}=e;return n.jsx(R,{label:s("settings.account.githubUrl"),editing:t,hint:o||s("settings.account.githubUrlHint"),editor:n.jsx(dt,{githubError:a,githubInput:i,handleSaveGithub:r,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:f}),actions:n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(U,{label:s("settings.account.edit"),onClick:d}),n.jsx(k,{checked:x,onChange:c,disabled:u||g,ariaLabel:s("settings.account.githubUrl")})]})})}function mt(){const{openLoginModal:e}=oe();return n.jsx(j,{title:s("settings.section.account"),children:n.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[n.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("settings.account.signedOutHint")}),n.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:s("settings.account.signIn")})]})})}function bt({name:e,github:t}){return n.jsxs(n.Fragment,{children:[n.jsx(ht,{name:e}),n.jsx(pt,{github:t})]})}function ft(){const e=ct();return e.enabled?e.signedIn?n.jsxs(j,{title:s("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:n.jsx(yt,{onSignOut:e.signOut}),children:[n.jsx(xt,{userId:e.userId}),n.jsx(vt,{settings:e}),n.jsx(jt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),n.jsx(kt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):n.jsx(mt,{}):null}function xt({userId:e}){const[t,a]=re.useState(!1);if(!e)return null;const i=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),a(!0),globalThis.setTimeout(()=>a(!1),1200)}catch{a(!1)}};return n.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:s("settings.account.userId")}),n.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),n.jsxs("button",{type:"button",onClick:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":s("settings.account.copyUserId"),children:[t?n.jsx(Ce,{className:"h-3.5 w-3.5","aria-hidden":!0}):n.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0}),t?s("settings.account.copied"):s("settings.account.copy")]})]})}function yt({onSignOut:e}){return n.jsxs("button",{type:"button",onClick:()=>e(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[n.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.account.signOut")]})}function vt({settings:e}){return e.showLocalCloudSync?n.jsx(b,{label:s("settings.account.cloudSync"),hint:s("settings.account.cloudSyncHint"),control:n.jsx(k,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:s("settings.account.cloudSync")})}):null}function jt({checked:e,disabled:t,onChange:a}){return n.jsx(b,{label:s("settings.account.publicProfile"),hint:s("settings.account.publicProfileHint"),control:n.jsx(k,{checked:e,onChange:a,disabled:t,ariaLabel:s("settings.account.publicProfile")})})}function kt({visible:e,name:t,github:a}){return n.jsx(le,{initial:!1,children:e?n.jsx(A.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:n.jsx(bt,{name:t,github:a})},"public-profile-fields"):null})}function Nt(){return[{value:"light",label:s("settings.appearance.theme.light"),Icon:de},{value:"dark",label:s("settings.appearance.theme.dark"),Icon:ge},{value:"system",label:s("settings.appearance.theme.system"),Icon:he}]}function St(){return[{value:be,label:s("settings.appearance.language.system")},{value:fe,label:s("settings.appearance.language.english")},{value:xe,label:s("settings.appearance.language.chinese")},{value:ye,label:s("settings.appearance.language.traditional_chinese")},{value:ve,label:s("settings.appearance.language.japanese")},{value:je,label:s("settings.appearance.language.korean")}]}function wt(e){if(!e)return null;try{const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleString()}catch{return null}}function Ct(e,t){const a=s(`settings.appearance.currency.rate_source.${e}`),i=wt(t),o=i?s("settings.appearance.currency.rate_updated",{when:i}):s("settings.appearance.currency.rate_never");return`${a} · ${o}`}function Lt({locale:e,setLocale:t}){const a=St();return n.jsx(D,{value:e,onValueChange:t,options:a,ariaLabel:s("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:n.jsx(Me,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function Et({currency:e,setCurrency:t}){const a=pe().map(i=>({value:i.code,label:s(i.labelKey)}));return n.jsx(D,{value:e,onValueChange:t,options:a,ariaLabel:s("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function Gt({currency:e,rate:t,rateSource:a,rateFetchedAt:i}){if(e===me)return n.jsx(n.Fragment,{children:s("settings.appearance.currency.hint")});const o=Ct(a,i);return n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{children:`1 USD = ${t.toFixed(4)} ${e}`}),n.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:n.jsx(Ee,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function It(){const{theme:e,setTheme:t}=ce(),{locale:a,setLocale:i}=ue(),{currency:o,rate:r,rateSource:c,rateFetchedAt:u,setCurrency:g}=Le();return n.jsxs(j,{title:s("settings.section.appearance"),children:[n.jsx(b,{label:s("settings.appearance.theme.label"),hint:s("settings.appearance.theme.hint"),control:n.jsx(_,{options:Nt(),value:e,onChange:t})}),n.jsx(b,{label:s("settings.appearance.language.label"),hint:s("settings.appearance.language.hint"),control:n.jsx(Lt,{locale:a,setLocale:i})}),n.jsx(b,{label:s("settings.appearance.currency.label"),hint:n.jsx(Gt,{currency:o,rate:r,rateSource:c,rateFetchedAt:u}),control:n.jsx(Et,{currency:o,setCurrency:g})})]})}function At(){const{available:e,settings:t,setSetting:a,runAction:i}=P();if(!e)return null;const o=!!t?.launchAtLogin,r=t?.launchAtLoginSupported!==!1,c=t?.updateStatus||null,u=!!t?.updateBusy,g=!!t?.isSyncing;return n.jsxs(j,{title:s("settings.section.menubar"),children:[r?n.jsx(b,{label:s("settings.menubar.launchAtLogin"),hint:s("settings.menubar.launchAtLoginHint"),control:n.jsx(k,{checked:o,onChange:()=>a("launchAtLogin",!o),ariaLabel:s("settings.menubar.launchAtLogin")})}):null,n.jsx(b,{label:s("settings.menubar.syncNow"),hint:s("settings.menubar.syncNowHint"),control:n.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:g,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[n.jsx(ke,{className:v("h-3.5 w-3.5",g&&"animate-spin"),"aria-hidden":!0}),g?s("settings.menubar.syncing"):s("settings.menubar.syncNow")]})}),n.jsx(b,{label:s("settings.menubar.updates"),hint:c||void 0,control:n.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:u,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[n.jsx(Ge,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.menubar.checkUpdates")]})})]})}function Ot(){const{available:e,settings:t,runAction:a}=P(),i=e&&t?.version;return n.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-2 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[i?n.jsxs(n.Fragment,{children:[n.jsxs("span",{children:["TokenTrackerBar v",t.version]}),n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsx("button",{type:"button",onClick:()=>a("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),n.jsx("span",{"aria-hidden":!0,children:"·"})]}):null,n.jsxs("a",{href:Ne,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:[n.jsx(Ae,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.footer.statusPage")]})]})}function _t({prefs:e}){return n.jsx(_,{options:[{value:G.USED,label:s("limits.settings.display_mode_used")},{value:G.REMAINING,label:s("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function zt(){const e=we();return n.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:n.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:n.jsxs("div",{className:"mx-auto max-w-3xl px-4 sm:px-6",children:[n.jsxs("div",{className:"mb-8",children:[n.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:s("settings.page.title")}),n.jsx("p",{className:"mt-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("settings.page.subtitle")})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsx(It,{}),n.jsx(At,{}),n.jsx(ft,{}),n.jsx(j,{title:s("settings.section.limits"),action:n.jsx(_t,{prefs:e}),children:n.jsx(Je,{prefs:e})})]}),n.jsx(Ot,{})]})})})}export{zt as SettingsPage};
1
+ import{c as y,r as l,aj as q,ad as Q,aG as L,j as n,m as A,O as v,A as s,T as X,aq as ee,av as te,aw as ne,ax as O,aH as ae,aI as ie,au as se,S as oe,R as re,M as le,N as ce,Z as ue,aJ as de,aK as ge,aL as he,aM as pe,E as me,aN as be,aO as fe,aP as xe,aQ as ye,aR as ve,aS as je,aT as ke,ab as Ne}from"./main-BN2u8ODm.js";import{a as Se,b as E,u as we,L as G}from"./use-limits-display-prefs-DY7luKuV.js";import{S as j,T as k,a as b,b as _,u as P}from"./use-native-settings-BEniEaPB.js";import{C as Ce}from"./useOpenInteractionType-BqOY0u5X.js";import{u as Le}from"./useCurrency-CrsGLZiC.js";import{S as D}from"./Select-CGpkLtRU.js";import{I as Ee}from"./info-DoWx4rUB.js";import{D as Ge}from"./download-BIqrLJf0.js";import"./Card-BYF4fWvv.js";import"./SelectItemText-CN5ejq4k.js";const Ie=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ae=y("activity",Ie);const Oe=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],_e=y("copy",Oe);const Pe=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],De=y("grip-vertical",Pe);const Te=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],Me=y("languages",Te);const Ue=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Re=y("log-out",Ue);const Fe=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],He=y("pencil",Fe),$e=e=>!e.isLayoutDirty&&e.willUpdate(!1);function I(){const e=new Set,t=new WeakMap,a=()=>e.forEach($e);return{add:i=>{e.add(i),t.set(i,i.addEventListener("willUpdate",a))},remove:i=>{e.delete(i);const o=t.get(i);o&&(o(),t.delete(i)),a()},dirty:a}}const Be=l.createContext(null);function ze(){const e=l.useRef(!1);return q(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function Ve(){const e=ze(),[t,a]=l.useState(0),i=l.useCallback(()=>{e.current&&a(t+1)},[t]);return[l.useCallback(()=>Q.postRender(i),[i]),t]}const T=e=>e===!0,Ze=e=>T(e===!0)||e==="id",Ke=({children:e,id:t,inherit:a=!0})=>{const i=l.useContext(L),o=l.useContext(Be),[r,c]=Ve(),u=l.useRef(null),g=i.id||o;u.current===null&&(Ze(a)&&g&&(t=t?g+"-"+t:g),u.current={id:t,group:T(a)&&i.group||I()});const h=l.useMemo(()=>({...u.current,forceRender:r}),[c]);return n.jsx(L.Provider,{value:h,children:e})},We=new Set(["cursor","kiro","copilot","kimi"]);function Ye({checked:e,onChange:t,ariaLabel:a}){return n.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":a,onClick:t,className:v("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:n.jsx("span",{className:v("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function Je({prefs:e}){const{order:t,visibility:a,toggle:i,moveToward:o}=e,[r,c]=l.useState(null),[u,g]=l.useState(null),h=d=>p=>{c(d),p.dataTransfer.effectAllowed="move",p.dataTransfer.setData("text/plain",d)},m=d=>p=>{p.preventDefault(),p.dataTransfer.dropEffect="move",r&&r!==d&&u!==d&&(g(d),o(r,d))},f=()=>{c(null),g(null)},x=d=>{d.preventDefault(),c(null),g(null)};return n.jsx(Ke,{children:n.jsx("div",{className:"flex flex-col",children:t.map(d=>{const p=a[d]!==!1,N=r===d;return n.jsxs(A.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:h(d),onDragOver:m(d),onDragEnd:f,onDrop:x,className:v("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",N&&"opacity-40"),style:{cursor:N?"grabbing":"grab"},children:[n.jsx(De,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),n.jsx("img",{src:Se[d],alt:"",width:18,height:18,className:v("h-[18px] w-[18px] shrink-0 pointer-events-none",We.has(d)&&"dark:invert"),draggable:!1}),n.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:E[d]}),n.jsx("div",{onMouseDown:S=>S.stopPropagation(),draggable:!1,children:n.jsx(Ye,{checked:p,onChange:()=>i(d),ariaLabel:`${s("limits.settings.toggle_visible")}: ${E[d]}`})})]},d)})})})}function qe(e){if(!e||typeof e!="object")return"";const t=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},a=e.profile&&typeof e.profile=="object"?e.profile:{},i=t.full_name||t.name||a.name||t.user_name||t.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function Qe(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function Xe(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const a=t.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=t.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=a?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function w(e,t){console.warn(`[tokentracker] settings ${e}:`,t)}function et(e,t,a){const[i,o]=l.useState(()=>ee()),r=t&&a&&se(),c=l.useCallback(async()=>{const u=!i;if(te(u),o(u),!!u)try{await ne(()=>e())}catch(g){w("cloud sync",g)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:c,showLocalCloudSync:r}}function tt(e){const[t,a]=l.useState(!1),[i,o]=l.useState(!1),[r,c]=l.useState(!1),[u,g]=l.useState(!1),[h,m]=l.useState(null),[f,x]=l.useState(!1),[d,p]=l.useState(""),[N,S]=l.useState(!1),[F,C]=l.useState(""),[H,$]=l.useState(""),[B,z]=l.useState(!1),[V,Z]=l.useState(null),K=l.useMemo(()=>qe(e),[e]),W=l.useMemo(()=>Qe(e),[e]),Y=l.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),J=l.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:m,setGithubUrl:C,setProfileLoading:c,setPublicProfileOn:a,setShowGithubOn:S}),[]);return{anonymousOn:i,customDisplayName:h,displayName:K,editingGithub:B,editingName:f,email:W,githubError:V,githubInput:H,githubUrl:F,loadSetters:J,nameInput:d,profileLoading:r,profileSaving:u,publicProfileOn:t,setAnonymousOn:o,setCustomDisplayName:m,setEditingGithub:z,setEditingName:x,setGithubError:Z,setGithubInput:$,setGithubUrl:C,setNameInput:p,setProfileLoading:c,setProfileSaving:g,setPublicProfileOn:a,setShowGithubOn:S,showGithubOn:N,userId:Y}}function nt(e,t,a){l.useEffect(()=>{if(!t)return;let i=!0;return a.setProfileLoading(!0),(async()=>{try{const o=await O({getAccessToken:e});if(!i||!o)return;const r=await ae({accessToken:o});if(!i)return;a.setPublicProfileOn(!!r?.enabled),a.setAnonymousOn(!!r?.anonymous),r?.display_name&&a.setCustomDisplayName(r.display_name),a.setShowGithubOn(!!r?.show_github_url),a.setGithubUrl(r?.github_url||"")}catch(o){w("load public profile",o)}finally{i&&a.setProfileLoading(!1)}})(),()=>{i=!1}},[e,t,a])}function at(e,t){return l.useCallback(async(a,{label:i,onError:o,onSuccess:r}={})=>{if(t.profileSaving)return!1;t.setProfileSaving(!0);try{const c=await O({getAccessToken:e});if(!c)return!1;const u=await ie({accessToken:c,...a});return r?.(u),!0}catch(c){return o?o(c):w(i||"mutate profile",c),!1}finally{t.setProfileSaving(!1)}},[e,t])}function it(e,t){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:t.handleAnonymousToggle,handleSaveName:t.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:t.startEditingName}}function st(e,t){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:t.handleSaveGithub,handleShowGithubToggle:t.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:t.startEditingGithub}}function ot(e,t){const a=l.useCallback(async()=>{const o=!e.publicProfileOn;await t({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[t,e]);return{handleAnonymousToggle:l.useCallback(async()=>{const o=!e.anonymousOn;await t({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[t,e]),handlePublicProfileToggle:a}}function rt(e,t,a){const i=l.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await t({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),a?.()}})},[t,e,a]),o=l.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function lt(e,t){const a=l.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await t({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[t,e]),i=l.useCallback(async()=>{const r=Xe(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(s("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await t({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:c=>e.setGithubError(c?.message||s("settings.account.githubUrlInvalid")),onSuccess:c=>{e.setGithubUrl(c?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[t,e]),o=l.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:a,startEditingGithub:o}}function ct(){const e=X(),t=tt(e.user),a=et(e.getAccessToken,e.enabled,e.signedIn);nt(e.getAccessToken,e.signedIn,t.loadSetters);const i=at(e.getAccessToken,t),o=ot(t,i),r=rt(t,i,e.refreshDisplayName),c=lt(t,i);return{...e,...a,email:t.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:t.userId,name:it(t,{...o,...r}),github:st(t,c),profileLoading:t.profileLoading,profileSaving:t.profileSaving,publicProfileOn:t.publicProfileOn}}function M({disabled:e,onCancel:t,onSave:a,saveLabel:i=s("settings.account.save")}){return n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",onClick:a,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:i}),n.jsx("button",{type:"button",onClick:t,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:s("settings.account.cancel")})]})}function ut({nameInput:e,setEditingName:t,setNameInput:a,profileSaving:i,handleSaveName:o}){return n.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[n.jsx("input",{type:"text",value:e,onChange:r=>a(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&t(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:s("settings.account.displayName")}),n.jsx(M,{disabled:i||!e.trim(),onCancel:()=>t(!1),onSave:o,saveLabel:i?s("settings.account.saving"):void 0})]})}function dt({githubError:e,githubInput:t,handleSaveGithub:a,profileSaving:i,setEditingGithub:o,setGithubError:r,setGithubInput:c}){return n.jsxs("div",{className:"mt-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"text",value:t,onChange:u=>{c(u.target.value),e&&r(null)},onKeyDown:u=>{u.key==="Enter"&&a(),u.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:s("settings.account.githubUrlPlaceholder")}),n.jsx(M,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:a,saveLabel:i?s("settings.account.saving"):void 0})]}),e?n.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function U({disabled:e=!1,label:t,onClick:a,title:i}){return n.jsxs("button",{type:"button",onClick:a,disabled:e,title:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[n.jsx(He,{className:"h-3.5 w-3.5","aria-hidden":!0}),t]})}function R({actions:e,editing:t,editor:a,hint:i,label:o}){return n.jsx("div",{className:"py-3",children:n.jsxs("div",{className:"flex items-start justify-between gap-4",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),t?a:n.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),t?null:e]})})}function gt({name:e}){const t=e.anonymousOn?s("settings.account.displayNameDisabledWhileAnon"):void 0;return n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(U,{disabled:e.anonymousOn,label:s("settings.account.edit"),onClick:e.startEditingName,title:t}),n.jsx(k,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:s("settings.account.displayName")})]})}function ht({name:e}){const{anonymousOn:t,customDisplayName:a,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:c,nameInput:u,profileLoading:g,profileSaving:h,setEditingName:m,setNameInput:f,startEditingName:x}=e,d=t?s("settings.account.displayNameAnonymousHint"):a||i;return n.jsx(R,{label:s("settings.account.displayName"),editing:o,hint:d,editor:n.jsx(ut,{nameInput:u,setEditingName:m,setNameInput:f,profileSaving:h,handleSaveName:c}),actions:n.jsx(gt,{name:e})})}function pt({github:e}){const{editingGithub:t,githubError:a,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:c,profileLoading:u,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:f,showGithubOn:x,startEditingGithub:d}=e;return n.jsx(R,{label:s("settings.account.githubUrl"),editing:t,hint:o||s("settings.account.githubUrlHint"),editor:n.jsx(dt,{githubError:a,githubInput:i,handleSaveGithub:r,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:f}),actions:n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(U,{label:s("settings.account.edit"),onClick:d}),n.jsx(k,{checked:x,onChange:c,disabled:u||g,ariaLabel:s("settings.account.githubUrl")})]})})}function mt(){const{openLoginModal:e}=oe();return n.jsx(j,{title:s("settings.section.account"),children:n.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[n.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("settings.account.signedOutHint")}),n.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:s("settings.account.signIn")})]})})}function bt({name:e,github:t}){return n.jsxs(n.Fragment,{children:[n.jsx(ht,{name:e}),n.jsx(pt,{github:t})]})}function ft(){const e=ct();return e.enabled?e.signedIn?n.jsxs(j,{title:s("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:n.jsx(yt,{onSignOut:e.signOut}),children:[n.jsx(xt,{userId:e.userId}),n.jsx(vt,{settings:e}),n.jsx(jt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),n.jsx(kt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):n.jsx(mt,{}):null}function xt({userId:e}){const[t,a]=re.useState(!1);if(!e)return null;const i=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),a(!0),globalThis.setTimeout(()=>a(!1),1200)}catch{a(!1)}};return n.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:s("settings.account.userId")}),n.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),n.jsxs("button",{type:"button",onClick:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":s("settings.account.copyUserId"),children:[t?n.jsx(Ce,{className:"h-3.5 w-3.5","aria-hidden":!0}):n.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0}),t?s("settings.account.copied"):s("settings.account.copy")]})]})}function yt({onSignOut:e}){return n.jsxs("button",{type:"button",onClick:()=>e(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[n.jsx(Re,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.account.signOut")]})}function vt({settings:e}){return e.showLocalCloudSync?n.jsx(b,{label:s("settings.account.cloudSync"),hint:s("settings.account.cloudSyncHint"),control:n.jsx(k,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:s("settings.account.cloudSync")})}):null}function jt({checked:e,disabled:t,onChange:a}){return n.jsx(b,{label:s("settings.account.publicProfile"),hint:s("settings.account.publicProfileHint"),control:n.jsx(k,{checked:e,onChange:a,disabled:t,ariaLabel:s("settings.account.publicProfile")})})}function kt({visible:e,name:t,github:a}){return n.jsx(le,{initial:!1,children:e?n.jsx(A.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:n.jsx(bt,{name:t,github:a})},"public-profile-fields"):null})}function Nt(){return[{value:"light",label:s("settings.appearance.theme.light"),Icon:de},{value:"dark",label:s("settings.appearance.theme.dark"),Icon:ge},{value:"system",label:s("settings.appearance.theme.system"),Icon:he}]}function St(){return[{value:be,label:s("settings.appearance.language.system")},{value:fe,label:s("settings.appearance.language.english")},{value:xe,label:s("settings.appearance.language.chinese")},{value:ye,label:s("settings.appearance.language.traditional_chinese")},{value:ve,label:s("settings.appearance.language.japanese")},{value:je,label:s("settings.appearance.language.korean")}]}function wt(e){if(!e)return null;try{const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleString()}catch{return null}}function Ct(e,t){const a=s(`settings.appearance.currency.rate_source.${e}`),i=wt(t),o=i?s("settings.appearance.currency.rate_updated",{when:i}):s("settings.appearance.currency.rate_never");return`${a} · ${o}`}function Lt({locale:e,setLocale:t}){const a=St();return n.jsx(D,{value:e,onValueChange:t,options:a,ariaLabel:s("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:n.jsx(Me,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function Et({currency:e,setCurrency:t}){const a=pe().map(i=>({value:i.code,label:s(i.labelKey)}));return n.jsx(D,{value:e,onValueChange:t,options:a,ariaLabel:s("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function Gt({currency:e,rate:t,rateSource:a,rateFetchedAt:i}){if(e===me)return n.jsx(n.Fragment,{children:s("settings.appearance.currency.hint")});const o=Ct(a,i);return n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{children:`1 USD = ${t.toFixed(4)} ${e}`}),n.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:n.jsx(Ee,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function It(){const{theme:e,setTheme:t}=ce(),{locale:a,setLocale:i}=ue(),{currency:o,rate:r,rateSource:c,rateFetchedAt:u,setCurrency:g}=Le();return n.jsxs(j,{title:s("settings.section.appearance"),children:[n.jsx(b,{label:s("settings.appearance.theme.label"),hint:s("settings.appearance.theme.hint"),control:n.jsx(_,{options:Nt(),value:e,onChange:t})}),n.jsx(b,{label:s("settings.appearance.language.label"),hint:s("settings.appearance.language.hint"),control:n.jsx(Lt,{locale:a,setLocale:i})}),n.jsx(b,{label:s("settings.appearance.currency.label"),hint:n.jsx(Gt,{currency:o,rate:r,rateSource:c,rateFetchedAt:u}),control:n.jsx(Et,{currency:o,setCurrency:g})})]})}function At(){const{available:e,settings:t,setSetting:a,runAction:i}=P();if(!e)return null;const o=!!t?.launchAtLogin,r=t?.launchAtLoginSupported!==!1,c=t?.updateStatus||null,u=!!t?.updateBusy,g=!!t?.isSyncing;return n.jsxs(j,{title:s("settings.section.menubar"),children:[r?n.jsx(b,{label:s("settings.menubar.launchAtLogin"),hint:s("settings.menubar.launchAtLoginHint"),control:n.jsx(k,{checked:o,onChange:()=>a("launchAtLogin",!o),ariaLabel:s("settings.menubar.launchAtLogin")})}):null,n.jsx(b,{label:s("settings.menubar.syncNow"),hint:s("settings.menubar.syncNowHint"),control:n.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:g,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[n.jsx(ke,{className:v("h-3.5 w-3.5",g&&"animate-spin"),"aria-hidden":!0}),g?s("settings.menubar.syncing"):s("settings.menubar.syncNow")]})}),n.jsx(b,{label:s("settings.menubar.updates"),hint:c||void 0,control:n.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:u,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[n.jsx(Ge,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.menubar.checkUpdates")]})})]})}function Ot(){const{available:e,settings:t,runAction:a}=P(),i=e&&t?.version;return n.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-2 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[i?n.jsxs(n.Fragment,{children:[n.jsxs("span",{children:["TokenTrackerBar v",t.version]}),n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsx("button",{type:"button",onClick:()=>a("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),n.jsx("span",{"aria-hidden":!0,children:"·"})]}):null,n.jsxs("a",{href:Ne,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:[n.jsx(Ae,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("settings.footer.statusPage")]})]})}function _t({prefs:e}){return n.jsx(_,{options:[{value:G.USED,label:s("limits.settings.display_mode_used")},{value:G.REMAINING,label:s("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function zt(){const e=we();return n.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:n.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:n.jsxs("div",{className:"mx-auto max-w-3xl px-4 sm:px-6",children:[n.jsxs("div",{className:"mb-8",children:[n.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:s("settings.page.title")}),n.jsx("p",{className:"mt-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s("settings.page.subtitle")})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsx(It,{}),n.jsx(At,{}),n.jsx(ft,{}),n.jsx(j,{title:s("settings.section.limits"),action:n.jsx(_t,{prefs:e}),children:n.jsx(Je,{prefs:e})})]}),n.jsx(Ot,{})]})})})}export{zt as SettingsPage};