tokentracker-cli 0.5.86 → 0.5.87

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 (22) hide show
  1. package/dashboard/dist/assets/{Card-D4LPt5pl.js → Card-BbXzY-fw.js} +1 -1
  2. package/dashboard/dist/assets/{DashboardPage-B-2PxAXT.js → DashboardPage-B_Yvna3-.js} +1 -1
  3. package/dashboard/dist/assets/{FadeIn-Bw7pQont.js → FadeIn-Dz3MVtMG.js} +1 -1
  4. package/dashboard/dist/assets/{IpCheckPage-BN6f0ZOs.js → IpCheckPage-FulDeMPC.js} +1 -1
  5. package/dashboard/dist/assets/LeaderboardPage-BQSqJVlP.js +5 -0
  6. package/dashboard/dist/assets/{LeaderboardProfilePage-DQMr9vjY.js → LeaderboardProfilePage-DP8bewz7.js} +1 -1
  7. package/dashboard/dist/assets/{LimitsPage-BKaitxPe.js → LimitsPage-BXDoE-jU.js} +1 -1
  8. package/dashboard/dist/assets/{ProviderIcon-CTwz2lc9.js → ProviderIcon-DChRpzX_.js} +1 -1
  9. package/dashboard/dist/assets/{SettingsPage-CYpMYSR7.js → SettingsPage-XFSmA7VB.js} +1 -1
  10. package/dashboard/dist/assets/{WidgetsPage-C-VjXvcB.js → WidgetsPage-D5guzG01.js} +1 -1
  11. package/dashboard/dist/assets/{download-B8q-pUg6.js → download-w3j__M5u.js} +1 -1
  12. package/dashboard/dist/assets/leaderboard-columns-ChIW6uNZ.js +1 -0
  13. package/dashboard/dist/assets/{main-Ry0vayW2.js → main-CJeNIc4Q.js} +4 -3
  14. package/dashboard/dist/assets/main-Cyta3wIj.css +1 -0
  15. package/dashboard/dist/assets/{use-limits-display-prefs-mlXe4VuM.js → use-limits-display-prefs-BzI5WJEo.js} +1 -1
  16. package/dashboard/dist/assets/{use-usage-limits-CxmDpqkS.js → use-usage-limits-CuoJnC-V.js} +1 -1
  17. package/dashboard/dist/index.html +2 -2
  18. package/dashboard/dist/share.html +2 -2
  19. package/package.json +1 -1
  20. package/dashboard/dist/assets/LeaderboardPage-DazS-BOp.js +0 -5
  21. package/dashboard/dist/assets/leaderboard-columns-BUl7-rVO.js +0 -1
  22. package/dashboard/dist/assets/main-BP_tVIcC.css +0 -1
@@ -1,4 +1,4 @@
1
- import{i as Cd,f as Wi,a as Bi,J as Md,u as $i,m as Td,r as h,M as Yi,b as Ed,c as Nd,d as xo,e as Hi,g as Dd,h as gn,j as Wn,k as fn,l as Od,n as ts,o as kr,p as ys,q as Kr,s as Rd,t as jd,v as _d,w as bs,x as jn,y as wo,z as Ad,A as qe,B as N,C as Ui,D as d,E as Xt,F as Ce,G as pn,H as Vi,I as zi,K as me,N as qi,L as Pd,O as ze,R as Id,P as zt,Q as ir,S as Gt,T as Fd,U as It,V as pa,W as lt,X as pt,Y as Nn,Z as De,_ as Ft,$ as ya,a0 as xs,a1 as ws,a2 as _n,a3 as un,a4 as Ld,a5 as Gi,a6 as Wd,a7 as lr,a8 as Xr,a9 as Bd,aa as vs,ab as ct,ac as Ki,ad as q,ae as $d,af as Jr,ag as Qr,ah as Yd,ai as Xi,aj as ks,ak as Ji,al as ns,am as Hd,an as Ud,ao as Vd,ap as zd,aq as qd,ar as Gd,as as Kd,at as Xd,au as Jd,av as Qd,aw as Zd,ax as ef,ay as Rt,az as ba}from"./main-Ry0vayW2.js";import{u as tf}from"./use-usage-limits-CxmDpqkS.js";import{C as Ss}from"./Card-D4LPt5pl.js";import{F as er}from"./FadeIn-Bw7pQont.js";import{P as xa}from"./ProviderIcon-CTwz2lc9.js";const nf=500,rf={style:{transition:"none"}},Qi="data-base-ui-click-trigger",of={fallbackAxisSide:"end"},sf={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function af(...e){const t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],o=e[1+n],s=e[2+n],a=e[3+n],i=Cd(o,s,a);return t?i(r):i}function lf(e,t,n={}){const r=e.get();let o=null,s=r,a;const i=typeof r=="string"?r.replace(/[\d.-]/g,""):void 0,l=()=>{o&&(o.stop(),o=null),e.animation=void 0},c=()=>{const f=wa(e.get()),m=wa(s);if(f===m){l();return}const p=o?o.getGeneratorVelocity():e.getVelocity();l(),o=new Md({keyframes:[f,m],velocity:p,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:a})},u=()=>{c(),e.animation=o??void 0,e.events.animationStart?.notify(),o?.then(()=>{e.animation=void 0,e.events.animationComplete?.notify()})};if(e.attach((f,m)=>{s=f,a=p=>m(vo(p,i)),Wi.postRender(u)},l),Bi(t)){let f=n.skipInitialAnimation===!0;const m=t.on("change",g=>{f?(f=!1,e.jump(vo(g,i),!1)):e.set(vo(g,i))}),p=e.on("destroy",m);return()=>{m(),p()}}return l}function vo(e,t){return t?e+t:e}function wa(e){return typeof e=="number"?e:parseFloat(e)}function Cs(e){const t=$i(()=>Td(e)),{isStatic:n}=h.useContext(Yi);if(n){const[,r]=h.useState(e);h.useEffect(()=>t.on("change",r),[])}return t}function Zi(e,t){const n=Cs(t()),r=()=>n.set(t());return r(),Ed(()=>{const o=()=>Wi.preRender(r,!1,!0),s=e.map(a=>a.on("change",o));return()=>{s.forEach(a=>a()),Nd(r)}}),n}function cf(e){xo.current=[],e();const t=Zi(xo.current,e);return xo.current=void 0,t}function el(e,t,n,r){if(typeof e=="function")return cf(e);const s=typeof t=="function"?t:af(t,n,r),a=Array.isArray(e)?va(e,s):va([e],([l])=>s(l)),i=Array.isArray(e)?void 0:e.accelerate;return i&&!i.isTransformed&&typeof t!="function"&&Array.isArray(n)&&r?.clamp!==!1&&(a.accelerate={...i,times:t,keyframes:n,isTransformed:!0}),a}function va(e,t){const n=$i(()=>[]);return Zi(e,()=>{n.length=0;const r=e.length;for(let o=0;o<r;o++)n[o]=e[o].get();return t(n)})}function uf(e,t={}){const{isStatic:n}=h.useContext(Yi),r=()=>Bi(e)?e.get():e;if(n)return el(r);const o=Cs(r());return h.useInsertionEffect(()=>lf(o,e,t),[o,JSON.stringify(t)]),o}function df(e,t={}){return uf(e,{type:"spring",...t})}const ff=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],hf=Hi("info",ff);const mf=[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]],gf=Hi("square-arrow-out-up-right",mf);function pf({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:r=52,weekStartsOn:o="sun",cacheKey:s,timeZone:a,tzOffsetMinutes:i,now:l}={}){const c=h.useMemo(()=>Dd({weeks:r,weekStartsOn:o,now:l}),[l,r,o]),[u,f]=h.useState([]),[m,p]=h.useState(null),[g,y]=h.useState("edge"),[b,v]=h.useState(!1),[x,w]=h.useState(null),k=gn(),C=Wn(t),S=!n,T=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),M=h.useMemo(()=>{if(!s)return null;const I=Kr({timeZone:a,offsetMinutes:i});return`tokentracker.heatmap.${s}.${r}.${o}.${I}`},[s,a,i,r,o]),A=h.useCallback(()=>{if(!M||typeof window>"u")return null;try{const I=window.localStorage.getItem(M);if(!I)return null;const j=JSON.parse(I);return!j||!j.heatmap?null:j}catch{return null}},[M]),R=h.useCallback(I=>{if(!(!M||typeof window>"u"))try{window.localStorage.setItem(M,JSON.stringify(I))}catch{}},[M]),D=h.useCallback(()=>{if(!(!M||typeof window>"u"))try{window.localStorage.removeItem(M)}catch{}},[M]),_=h.useCallback(async()=>{const I=await fn(t);if(!(!I&&!k&&!T)){v(!0),w(null);try{try{const O=await Od({baseUrl:e,accessToken:I,weeks:r,to:c.to,weekStartsOn:o,timeZone:a,tzOffsetMinutes:i}),F=Array.isArray(O?.weeks)?O.weeks:[];if(!F.length&&S){const $=A();if($?.heatmap){p($.heatmap),f($.daily||[]),y("cache");return}}if(!F.some($=>(Array.isArray($)?$:[]).some(Q=>Q&&Number.isFinite(Number(Q.level))))&&F.length){const $=[];for(const U of F)for(const W of Array.isArray(U)?U:[])W?.day&&$.push({day:W.day,total_tokens:W.total_tokens??W.value??0,billable_total_tokens:W.billable_total_tokens??W.value??W.total_tokens??0});const Q=ts({dailyRows:$,weeks:r,to:O?.to||c.to,weekStartsOn:o});f($),p({...Q,week_starts_on:o,active_days:$.filter(U=>Number(U?.billable_total_tokens??U?.total_tokens)>0).length,streak_days:kr({dailyRows:$,to:O?.to||c.to})}),y("client"),S?R({heatmap:{...Q,week_starts_on:o,active_days:$.filter(U=>Number(U?.billable_total_tokens??U?.total_tokens)>0).length,streak_days:kr({dailyRows:$,to:O?.to||c.to})},daily:$,fetchedAt:new Date().toISOString()}):D();return}p(O||null),f([]),y("edge"),O&&S?R({heatmap:O,daily:[],fetchedAt:new Date().toISOString()}):S||D();return}catch(O){const F=O,V=F?.status??F?.statusCode;if(V===401||V===403)throw O}const j=await ys({baseUrl:e,accessToken:I,from:c.from,to:c.to,timeZone:a,tzOffsetMinutes:i}),B=Array.isArray(j?.data)?j.data:[];f(B);const H=ts({dailyRows:B,weeks:r,to:c.to,weekStartsOn:o});p({...H,week_starts_on:o,active_days:B.filter(O=>Number(O?.billable_total_tokens??O?.total_tokens)>0).length,streak_days:kr({dailyRows:B,to:c.to})}),y("client"),S?R({heatmap:{...H,week_starts_on:o,active_days:B.filter(O=>Number(O?.billable_total_tokens??O?.total_tokens)>0).length,streak_days:kr({dailyRows:B,to:c.to})},daily:B,fetchedAt:new Date().toISOString()}):D()}catch(j){if(S){const B=A();if(B?.heatmap)p(B.heatmap),f(B.daily||[]),y("cache"),w(null);else{const H=j;w(H?.message||String(H)),f([]),p(null),y("edge")}}else{const B=j;w(B?.message||String(B)),f([]),p(null),y("edge")}}finally{v(!1)}}},[t,e,k,n,S,c.from,c.to,A,C,a,i,o,r,D,R,T]);return h.useEffect(()=>{if(!C&&!n&&!k&&!T){f([]),v(!1),w(null),p(null),y("edge");return}if(!S)D(),f([]),w(null),p(null),y("edge");else{const I=A();I?.heatmap&&(p(I.heatmap),f(I.daily||[]),y("cache"))}_()},[t,k,A,_,C,n,S,D,T]),{range:c,daily:u,heatmap:m,source:k?"mock":g==="client"?"edge":g,loading:b,error:x,refresh:_}}function yf({baseUrl:e,accessToken:t,limit:n=3,from:r,to:o,source:s,timeZone:a,tzOffsetMinutes:i}={}){const[l,c]=h.useState([]),[u,f]=h.useState(!1),[m,p]=h.useState(null),g=gn(),y=Wn(t),b=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),v=h.useCallback(async()=>{const x=await fn(t);if(!x&&!g&&!b){c([]),p(null),f(!1);return}f(!0),p(null);try{const w=await Rd({baseUrl:e,accessToken:x,limit:n,from:r,to:o,source:s,timeZone:a,tzOffsetMinutes:i});c(Array.isArray(w?.entries)?w.entries:[])}catch(w){const k=w?.message||String(w);p(k),c([])}finally{f(!1)}},[t,e,r,n,g,s,a,o,i,b]);return h.useEffect(()=>{if(!y&&!g&&!b){c([]),p(null),f(!1);return}v()},[g,v,y,b]),{entries:l,loading:u,error:m,refresh:v}}const bf=24;function xf({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:r,from:o,to:s,months:a=bf,cacheKey:i,timeZone:l,tzOffsetMinutes:c,now:u,sharedRows:f,sharedRange:m}={}){const[p,g]=h.useState([]),[y,b]=h.useState(()=>({from:o,to:s})),[v,x]=h.useState("edge"),[w,k]=h.useState(null),[C,S]=h.useState(!1),[T,M]=h.useState(null),A=gn(),R=Wn(t),D=!n,_=Array.isArray(f),E=m?.from||o,I=m?.to||s,j=h.useMemo(()=>r==="day"?"hourly":r==="total"?"monthly":"daily",[r]),B=(()=>{if(!i)return null;const U=wf(e)||"default",W=Kr({timeZone:l,offsetMinutes:c});if(j==="hourly")return`tokentracker.trend.${i}.${U}.hourly.${s||o||"day"}.${W}`;if(j==="monthly")return`tokentracker.trend.${i}.${U}.monthly.${a}.${s||"today"}.${W}`;const K=`${o||""}.${s||""}`;return`tokentracker.trend.${i}.${U}.daily.${K}.${W}`})(),H=h.useCallback(()=>{if(!B||typeof window>"u")return null;try{const U=window.localStorage.getItem(B);if(!U)return null;const W=JSON.parse(U);return!W||!Array.isArray(W.rows)?null:W}catch{return null}},[B]),O=h.useCallback(U=>{if(!(!B||typeof window>"u"))try{window.localStorage.setItem(B,JSON.stringify(U))}catch{}},[B]),F=h.useCallback(()=>{if(!(!B||typeof window>"u"))try{window.localStorage.removeItem(B)}catch{}},[B]),V=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),$=h.useCallback(async()=>{if(_){g(Array.isArray(f)?f:[]),b({from:E,to:I}),x("shared"),k(null),S(!1),M(null);return}const U=await fn(t);if(!(!U&&!A&&!V)){S(!0),M(null);try{let W;j==="hourly"?W=await jd({baseUrl:e,accessToken:U,day:s||o,timeZone:l,tzOffsetMinutes:c}):j==="monthly"?W=await _d({baseUrl:e,accessToken:U,months:a,to:s,timeZone:l,tzOffsetMinutes:c}):W=await ys({baseUrl:e,accessToken:U,from:o,to:s,timeZone:l,tzOffsetMinutes:c});const K=W?.from||o||W?.day||null,G=W?.to||s||W?.day||null;let te=Array.isArray(W?.data)?W.data:[];j==="daily"?te=So(te,K||o,G||s,{timeZone:l,offsetMinutes:c,now:u}):j==="hourly"?te=Co(te,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&(te=Mo(te,{timeZone:l,offsetMinutes:c,now:u}));const xe=new Date().toISOString();g(te),b({from:K,to:G}),x("edge"),k(xe),D?O({rows:te,from:K,to:G,mode:j,fetchedAt:xe}):F()}catch(W){if(D){const K=H();if(K?.rows){let G=j==="daily"?So(K.rows||[],K.from||o,K.to||s,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(K.rows)?K.rows:[];j==="hourly"?G=Co(G,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&(G=Mo(G,{timeZone:l,offsetMinutes:c,now:u})),g(G),b({from:K.from||o,to:K.to||s}),x("cache"),k(K.fetchedAt||null),M(null)}else{g([]),b({from:o,to:s}),x("edge"),k(null);const G=W;M(G?.message||String(G))}}else{g([]),b({from:o,to:s}),x("edge"),k(null);const K=W;M(K?.message||String(K))}}finally{S(!1)}}},[t,e,o,A,n,D,j,a,H,R,_,E,f,I,l,s,c,u,F,O,V]);h.useEffect(()=>{if(_){g(Array.isArray(f)?f:[]),b({from:E,to:I}),x("shared"),k(null),S(!1),M(null);return}if(!R&&!n&&!A&&!V){g([]),b({from:o,to:s}),M(null),S(!1),x("edge"),k(null);return}if(!D)F(),g([]),b({from:o,to:s}),M(null),x("edge"),k(null);else{const U=H();if(U?.rows){let W=j==="daily"?So(U.rows||[],U.from||o,U.to||s,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(U.rows)?U.rows:[];j==="hourly"?W=Co(W,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&(W=Mo(W,{timeZone:l,offsetMinutes:c,now:u})),g(W),b({from:U.from||o,to:U.to||s}),x("cache"),k(U.fetchedAt||null)}}$()},[t,A,H,$,_,E,f,I,R,n,D,F,V]);const Q=A?"mock":v;return{rows:p,from:y.from||o,to:y.to||s,source:Q,fetchedAt:w,loading:C,error:T,refresh:$}}function wf(e){try{return new URL(e).host}catch{return null}}function ko(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const r=Number(n[0]),o=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s))return null;const a=new Date(Date.UTC(r,o,s));return Number.isFinite(a.getTime())&&jn(a)===t?a:null}function vf(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function So(e,t,n,{timeZone:r,offsetMinutes:o,now:s}={}){const a=ko(t),i=ko(n);if(!a||!i||i<a)return Array.isArray(e)?e:[];const l=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,c=bs({timeZone:r,offsetMinutes:o,date:l}),u=ko(c),f=u?u.getTime():l.getTime(),m=new Map;for(const g of e||[])g?.day&&m.set(g.day,g);const p=[];for(let g=a;g<=i;g=vf(g,1)){const y=jn(g),b=m.get(y),v=g.getTime()>f;if(b){p.push({...b,missing:!1,future:v});continue}p.push({day:y,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!v,future:v})}return p}function Co(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const o=tl({timeZone:t,offsetMinutes:n,now:r});return o?e.map(s=>{const a=s?.hour||s?.label||"",i=kf(a);if(!i)return{...s,future:!1};const l=i.dayNum>o.dayNum||i.dayNum===o.dayNum&&i.slot>o.slot;return{...s,future:l}}):e}function Mo(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const o=tl({timeZone:t,offsetMinutes:n,now:r});return o?e.map(s=>{const a=s?.month||s?.label||"",i=Sf(a);if(!i)return{...s,future:!1};const l=i.year>o.year||i.year===o.year&&i.month>o.month;return{...s,future:l}}):e}function tl({timeZone:e,offsetMinutes:t,now:n}={}){const r=n instanceof Date&&Number.isFinite(n.getTime())?n:new Date;if(e&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const m=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(r).reduce((x,w)=>(w.type&&w.value&&(x[w.type]=w.value),x),{}),p=Number(m.year),g=Number(m.month),y=Number(m.day),b=Number(m.hour),v=Number(m.minute);if(Number.isFinite(p)&&Number.isFinite(g)&&Number.isFinite(y)&&Number.isFinite(b)&&Number.isFinite(v)){const x=b*2+(v>=30?1:0);return{year:p,month:g,day:y,hour:b,minute:v,dayNum:p*1e4+g*100+y,slot:x}}}catch{}if(Number.isFinite(t)){const u=new Date(r.getTime()+t*60*1e3),f=u.getUTCFullYear(),m=u.getUTCMonth()+1,p=u.getUTCDate(),g=u.getUTCHours(),y=u.getUTCMinutes(),b=g*2+(y>=30?1:0);return{year:f,month:m,day:p,hour:g,minute:y,dayNum:f*1e4+m*100+p,slot:b}}const o=r.getFullYear(),s=r.getMonth()+1,a=r.getDate(),i=r.getHours(),l=r.getMinutes(),c=i*2+(l>=30?1:0);return{year:o,month:s,day:a,hour:i,minute:l,dayNum:o*1e4+s*100+a,slot:c}}function kf(e){if(!e)return null;const t=String(e).trim(),[n,r]=t.split("T");if(!n||!r)return null;const o=n.split("-");if(o.length!==3)return null;const s=Number(o[0]),a=Number(o[1]),i=Number(o[2]);if(!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(i))return null;const l=r.split(":"),c=Number(l[0]),u=Number(l[1]);if(!Number.isFinite(c)||c<0||c>23||!Number.isFinite(u)||u<0||u>59)return null;const f=c*2+(u>=30?1:0);return{dayNum:s*1e4+a*100+i,slot:f}}function Sf(e){if(!e)return null;const n=String(e).trim().split("-");if(n.length!==2)return null;const r=Number(n[0]),o=Number(n[1]);return!Number.isFinite(r)||!Number.isFinite(o)||o<1||o>12?null:{year:r,month:o}}function ka({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:o,includeDaily:s=!0,cacheKey:a,timeZone:i,tzOffsetMinutes:l,now:c}={}){const[u,f]=h.useState([]),[m,p]=h.useState(null),[g,y]=h.useState(null),[b,v]=h.useState("edge"),[x,w]=h.useState(null),[k,C]=h.useState(!1),[S,T]=h.useState(null),M=gn(),A=Wn(t),R=!n,D=(()=>{if(!a)return null;const O=Cf(e)||"default",F=s?"daily":"summary",V=Kr({timeZone:i,offsetMinutes:l});return`tokentracker.usage.${a}.${O}.${r}.${o}.${F}.${V}`})(),_=h.useCallback(()=>{if(!D||typeof window>"u")return null;try{const O=window.localStorage.getItem(D);if(!O)return null;const F=JSON.parse(O);return!F||!F.summary?null:F}catch{return null}},[D]),E=h.useCallback(O=>{if(!(!D||typeof window>"u"))try{window.localStorage.setItem(D,JSON.stringify(O))}catch{}},[D]),I=h.useCallback(()=>{if(!(!D||typeof window>"u"))try{window.localStorage.removeItem(D)}catch{}},[D]),j=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),B=h.useCallback(async()=>{const O=await fn(t);if(!(!O&&!M&&!j)){C(!0),T(null);try{let F=null,V=null;if(s){const[K,G]=await Promise.allSettled([ys({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l}),wo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l,rolling:!0})]);if(K.status==="rejected")throw K.reason;F=K.value,V=G.status==="fulfilled"?G.value:null}else V=await wo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l,rolling:!0});let $=s&&Array.isArray(F?.data)?F.data:[];s&&($=Eo($,r,o,{timeZone:i,offsetMinutes:l,now:c}));let Q=V?.totals||F?.summary?.totals||null,U=V?.rolling||F?.summary?.rolling||null;if(s&&!Q&&!V)try{const K=await wo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l,rolling:!0});Q=K?.totals||null,U=K?.rolling||U}catch{}const W=new Date().toISOString();f($),p(Q),y(U),v("edge"),w(W),Q&&R?E({summary:Q,rolling:U,daily:$,from:r,to:o,includeDaily:s,fetchedAt:W}):R||I()}catch(F){if(R){const V=_();if(V?.summary){p(V.summary),y(V.rolling||null);const $=Array.isArray(V.daily)?V.daily:[],Q=s?Eo($,V.from||r,V.to||o,{timeZone:i,offsetMinutes:l,now:c}):$;f(Q),v("cache"),w(V.fetchedAt||null),T(null)}else{const $=F;T($?.message||String($)),f([]),p(null),y(null),v("edge"),w(null)}}else{const V=F;T(V?.message||String(V)),f([]),p(null),y(null),v("edge"),w(null)}}finally{C(!1)}}},[t,e,r,s,M,n,R,c,_,A,i,o,l,I,E,j]);return h.useEffect(()=>{const O=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!A&&!n&&!M&&!O){f([]),p(null),y(null),T(null),C(!1),v("edge"),w(null);return}if(!R)I(),f([]),p(null),y(null),T(null),v("edge"),w(null);else{const F=_();if(F?.summary){p(F.summary),y(F.rolling||null);const V=Array.isArray(F.daily)?F.daily:[],$=s?Eo(V,F.from||r,F.to||o,{timeZone:i,offsetMinutes:l,now:c}):V;f($),v("cache"),w(F.fetchedAt||null)}}B()},[t,M,_,B,A,n,R,I,j]),{daily:u,summary:m,rolling:g,source:M?"mock":b,fetchedAt:x,loading:k,error:S,refresh:B}}function Cf(e){try{return new URL(e).host}catch{return null}}function To(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const r=Number(n[0]),o=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s))return null;const a=new Date(Date.UTC(r,o,s));return Number.isFinite(a.getTime())&&jn(a)===t?a:null}function Mf(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Eo(e,t,n,{timeZone:r,offsetMinutes:o,now:s}={}){const a=To(t),i=To(n);if(!a||!i||i<a)return Array.isArray(e)?e:[];const l=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,c=bs({timeZone:r,offsetMinutes:o,date:l}),u=To(c),f=u?u.getTime():l.getTime(),m=new Map;for(const g of e||[])g?.day&&m.set(g.day,g);const p=[];for(let g=a;g<=i;g=Mf(g,1)){const y=jn(g),b=m.get(y),v=g.getTime()>f;if(b){p.push({...b,missing:!1,future:v});continue}p.push({day:y,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!v,future:v})}return p}function Tf({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:o,cacheKey:s,timeZone:a,tzOffsetMinutes:i}={}){const[l,c]=h.useState(null),[u,f]=h.useState("edge"),[m,p]=h.useState(!1),[g,y]=h.useState(null),b=gn(),v=Wn(t),x=!n,w=h.useMemo(()=>{if(!s)return null;const R=Ef(e)||"default",D=Kr({timeZone:a,offsetMinutes:i});return`tokentracker.modelBreakdown.${s}.${R}.${r}.${o}.${D}`},[e,s,r,a,o,i]),k=h.useCallback(()=>{if(!w||typeof window>"u")return null;try{const R=window.localStorage.getItem(w);if(!R)return null;const D=JSON.parse(R);return!D||!D.breakdown?null:D}catch{return null}},[w]),C=h.useCallback(R=>{if(!(!w||typeof window>"u"))try{window.localStorage.setItem(w,JSON.stringify(R))}catch{}},[w]),S=h.useCallback(()=>{if(!(!w||typeof window>"u"))try{window.localStorage.removeItem(w)}catch{}},[w]),T=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),M=h.useCallback(async()=>{const R=await fn(t);if(!(!R&&!b&&!T)){p(!0),y(null);try{const D=await Ad({baseUrl:e,accessToken:R,from:r,to:o,timeZone:a,tzOffsetMinutes:i});c(D||null),f("edge"),D&&x?C({breakdown:D,fetchedAt:new Date().toISOString()}):x||S()}catch(D){if(x){const _=k();if(_?.breakdown)c(_.breakdown),f("cache"),y(null);else{c(null),f("edge");const E=D;y(E?.message||String(E))}}else{c(null),f("edge");const _=D;y(_?.message||String(_))}}finally{p(!1)}}},[t,e,r,b,n,x,k,a,o,v,i,S,C,T]);return h.useEffect(()=>{if(!v&&!n&&!b&&!T){c(null),f("edge"),y(null),p(!1);return}if(!x)S(),c(null),f("edge"),y(null);else{const R=k();R?.breakdown&&(c(R.breakdown),f("cache"))}M()},[t,b,k,M,v,n,x,S,T]),{breakdown:l,source:b?"mock":u,loading:m,error:g,refresh:M}}function Ef(e){try{return new URL(e).host}catch{return null}}const nl=new Set(["day","hour","month"]);function Nf(e){return nl.has(e)}function Sa(e){if(e==null)return null;const t=String(e).trim();if(!/^[0-9]+$/.test(t))return null;const n=t.replace(/^0+/,"");return n.length===0?"0":n}function Df(e,t){const n=Sa(e),r=Sa(t);if(n&&r)return n.length!==r.length?n.length<r.length?-1:1:n===r?0:n<r?-1:1;const o=qe(e),s=qe(t);return o==null&&s==null?0:o==null?1:s==null?-1:o===s?0:o<s?-1:1}function Of(e,t){const n=typeof e=="string"?e:String(e||""),r=typeof t=="string"?t:String(t||"");return n===r?0:n<r?-1:1}function Rf(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!n)return null;const r=Number(n[1]),o=Number(n[2]),s=Number(n[3]);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s))return null;const a=new Date(Date.UTC(r,o-1,s));return!Number.isFinite(a.getTime())||a.getUTCFullYear()!==r||a.getUTCMonth()+1!==o||a.getUTCDate()!==s?null:a.getTime()}function jf(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})$/);if(!n)return null;const r=Number(n[1]),o=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(o)||o<1||o>12)return null;const s=new Date(Date.UTC(r,o-1,1));return Number.isFinite(s.getTime())?s.getTime():null}function _f(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?Z?$/);if(!n)return null;const r=Number(n[1]),o=Number(n[2]),s=Number(n[3]),a=Number(n[4]),i=Number(n[5]),l=Number(n[6]||0);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(i)||!Number.isFinite(l)||o<1||o>12||s<1||s>31||a<0||a>23||i<0||i>59||l<0||l>59)return null;const c=new Date(Date.UTC(r,o-1,s,a,i,l));return Number.isFinite(c.getTime())?c.getTime():null}function Af(e,t,n){const r=n==="hour"?_f:n==="month"?jf:Rf,o=r(e),s=r(t);return o!=null&&s!=null?o===s?0:o<s?-1:1:Of(e,t)}function rl(e,{key:t,dir:n}){const r=n==="asc"?1:-1,o=Array.isArray(e)?e:[],s=nl.has(t)?(i,l)=>Af(i,l,t):Df,a=i=>t==="total_tokens"&&i?.billable_total_tokens!=null?i.billable_total_tokens:i?.[t];return o.map((i,l)=>({row:i,index:l})).sort((i,l)=>{const c=a(i.row),u=a(l.row),f=c==null,m=u==null;if(f&&m)return i.index-l.index;if(f)return 1;if(m)return-1;const p=s(c,u);return p!==0?p*r:i.index-l.index}).map(i=>i.row)}function Pf(){return[{key:"day",label:N("daily.sort.date.label"),title:N("daily.sort.date.title")},{key:"total_tokens",label:N("daily.sort.total.label"),title:N("daily.sort.total.title")},{key:"input_tokens",label:N("daily.sort.input.label"),title:N("daily.sort.input.title")},{key:"output_tokens",label:N("daily.sort.output.label"),title:N("daily.sort.output.title")},{key:"cached_input_tokens",label:N("daily.sort.cached.label"),title:N("daily.sort.cached.title")},{key:"reasoning_output_tokens",label:N("daily.sort.reasoning.label"),title:N("daily.sort.reasoning.title")},{key:"conversation_count",label:N("daily.sort.conversations.label"),title:N("daily.sort.conversations.title")}]}function Ca(e){const t=Nf(e)?e:"day";return Pf().map((n,r)=>r===0?{...n,key:t}:n)}function Ma(e,{key:t,dir:n}){return rl(e,{key:t,dir:n})}const Fr=12,If=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function Ff(e){if(typeof e=="bigint")return e!==0n;if(typeof e=="number")return Number.isFinite(e)&&e!==0;if(e==null)return!1;const t=String(e).trim();if(!t||!/^-?\d+$/.test(t))return!1;const n=t.startsWith("-")?t.slice(1):t;return/[1-9]/.test(n)}function Lf(e){return If.some(t=>Ff(e?.[t]))}function Wf(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=rl(t,{key:"month",dir:"asc"}),r=n.findIndex(o=>o?.month&&Lf(o));return r===-1?t:n.slice(r)}function Bf(e,t,n=Fr){const r=Array.isArray(e)?e:[],o=Number.isFinite(n)&&n>0?n:Fr,a=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*o;return r.slice(a,a+o)}function $f({publicMode:e,screenshotMode:t,forceInstall:n,accessEnabled:r,heatmapLoading:o,activeDays:s,hasActiveDeviceToken:a}={}){return e||t?!1:n?!0:r&&!o&&s===0&&!a}function ol(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function Yf(e){const t=ol(e?.model_id);return t||null}function sl(e,t){return e?.model?String(e.model):t}function Hf(e,{copyFn:t}={}){const n=typeof t=="function"?t:a=>a,o=(Array.isArray(e?.sources)?e.sources:[]).map(a=>{const i=qe(a?.totals?.billable_total_tokens??a?.totals?.total_tokens)??0,l=qe(a?.totals?.total_cost_usd)??0;return{source:a?.source,totalTokens:Number.isFinite(i)?i:0,totalCost:Number.isFinite(l)?l:0,models:Array.isArray(a?.models)?a.models:[]}}).filter(a=>a.totalTokens>0);if(!o.length)return[];const s=o.reduce((a,i)=>a+i.totalTokens,0);return typeof e?.pricing?.pricing_mode=="string"&&e.pricing.pricing_mode.toUpperCase(),o.slice().sort((a,i)=>i.totalTokens-a.totalTokens).map(a=>{const i=a.source?String(a.source).toUpperCase():n("shared.placeholder.short"),l=s>0?a.totalTokens/s*100:0,c=Number.isFinite(l)?l.toFixed(1):"0.0",u=a.models.map(f=>{const m=qe(f?.totals?.billable_total_tokens??f?.totals?.total_tokens)??0;if(!Number.isFinite(m)||m<=0)return null;const p=a.totalTokens>0?Math.round(m/a.totalTokens*1e3)/10:0,g=sl(f,n("shared.placeholder.short")),y=Yf(f),b=a.totalCost>0&&a.totalTokens>0?m/a.totalTokens*a.totalCost:null;return{id:y,name:g,share:p,usage:m,cost:b}}).filter(Boolean);return{label:i,totalPercent:String(c),usd:a.totalCost,usage:a.totalTokens,models:u}})}function Uf(e,{limit:t=3,copyFn:n}={}){const r=typeof n=="function"?n:m=>m,o=Array.isArray(e?.sources)?e.sources:[];if(!o.length)return[];const s=new Map,a=new Map,i=new Map;let l=0;for(const m of o){const p=Array.isArray(m?.models)?m.models:[];for(const g of p){const y=qe(g?.totals?.billable_total_tokens)??0;if(!Number.isFinite(y)||y<=0)continue;l+=y;const b=sl(g,r("shared.placeholder.short")),v=ol(b);if(!v)continue;s.set(v,(s.get(v)||0)+y);const x=i.get(v)||0;y>=x&&(i.set(v,y),a.set(v,b))}}if(!s.size)return[];const c=Array.from(s.values()).reduce((m,p)=>m+p,0),u=l>0?l:c,f=Number.isFinite(t)?Math.max(0,Math.floor(t)):3;return Array.from(s.entries()).map(([m,p])=>{const g=u>0?(p/u*100).toFixed(1):"0.0";return{id:m,name:a.get(m)||r("shared.placeholder.short"),tokens:p,percent:String(g)}}).sort((m,p)=>p.tokens!==m.tokens?p.tokens-m.tokens:String(m.name).localeCompare(String(p.name))).slice(0,f)}const tn=12,Gn=3,No=26,Vf=["#ecfdf5","#a7f3d0","#6ee7b7","#34d399","#10b981"],zf=["#064e3b","#065f46","#059669","#10b981","#34d399"],qf=[N("heatmap.month.jan"),N("heatmap.month.feb"),N("heatmap.month.mar"),N("heatmap.month.apr"),N("heatmap.month.may"),N("heatmap.month.jun"),N("heatmap.month.jul"),N("heatmap.month.aug"),N("heatmap.month.sep"),N("heatmap.month.oct"),N("heatmap.month.nov"),N("heatmap.month.dec")];function Gf(e){if(typeof e=="bigint")return e.toLocaleString();if(typeof e=="number")return Number.isFinite(e)?Math.round(e).toLocaleString():"0";if(typeof e=="string"){const t=Number(e);return Number.isFinite(t)?Math.round(t).toLocaleString():e}return"0"}function Kf(e){if(typeof e!="string")return null;const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e.trim());if(!t)return null;const n=new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3])));return Number.isFinite(n.getTime())?n:null}function al(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Xf(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function Jf(e,t){const n=t==="mon"?1:0,r=e.getUTCDay();return al(e,-((r-n+7)%7))}function Qf(e,t,n){if(!e)return[];const r=Kf(t)||new Date,o=[];for(let c=11;c>=0;c-=1)o.push(new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()-c,1)));const s=Jf(r,n),a=al(s,-(e-1)*7),i=[],l=new Set;for(const c of o){const u=Math.floor(Xf(a,c)/7);u<0||u>=e||l.has(u)||(l.add(u),i.push({label:qf[c.getUTCMonth()],index:u}))}return i}function Zf({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:r=!1}){const{resolvedTheme:o}=Ui(),a=o==="dark"?zf:Vf,i=h.useRef(null);h.useEffect(()=>{const g=i.current;g&&(g.scrollLeft=g.scrollWidth)},[e?.weeks]);const l=e?.week_starts_on==="mon"?"mon":"sun",c=h.useMemo(()=>{const g=Array.isArray(e?.weeks)?e.weeks:[];if(!g.length)return{weeks:[]};const y=[];for(const b of g)for(const v of Array.isArray(b)?b:[])v?.day&&y.push({day:v.day,total_tokens:v.total_tokens??v.value??0,billable_total_tokens:v.billable_total_tokens??v.value??v.total_tokens??0});return ts({dailyRows:y,weeks:Math.max(52,g.length),to:e?.to,weekStartsOn:l})},[e?.to,e?.weeks,l]),u=c?.weeks||[],f=l==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(g=>N(`heatmap.day.${g.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(g=>N(`heatmap.day.${g.toLowerCase()}`)),m=h.useMemo(()=>Qf(u.length,c?.to,l),[c?.to,u.length,l]);if(!u.length)return d.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:N("heatmap.empty")});const p=No+u.length*tn+Math.max(0,u.length-1)*Gn;return d.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5",children:[d.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[d.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:N("heatmap.title")}),d.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400",children:n||N("heatmap.legend.utc")})]}),d.jsx("div",{ref:i,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:d.jsxs("div",{style:{minWidth:p},children:[d.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:`${No}px repeat(${u.length}, ${tn}px)`,columnGap:Gn},children:[d.jsx("span",{}),m.map(g=>d.jsx("span",{style:{gridColumnStart:g.index+2},className:"whitespace-nowrap",children:g.label},`${g.label}-${g.index}`))]}),d.jsxs("div",{className:"grid",style:{gridTemplateColumns:`${No}px repeat(${u.length}, ${tn}px)`,columnGap:Gn},children:[d.jsx("div",{className:"grid text-[10px] text-oai-gray-400 dark:text-oai-gray-400 sticky left-0 bg-white dark:bg-oai-gray-900 pr-2",style:{gridTemplateRows:`repeat(7, ${tn}px)`,rowGap:Gn},children:f.map(g=>d.jsx("span",{className:"leading-none",children:g},g))}),d.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${tn}px)`,gap:Gn},children:u.map((g,y)=>(Array.isArray(g)?g:[]).map((b,v)=>{if(!b)return null;const x=b.day||`e-${y}-${v}`,w=Number(b.level)||0,k=a[w]||a[0],C=t||n||N("heatmap.legend.utc");return d.jsx("span",{title:N("heatmap.tooltip",{day:b.day,value:Gf(b.value),unit:N("heatmap.unit.tokens"),tz:C}),className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10",style:{width:tn,height:tn,background:k}},x)}))})]})]})}),!r&&d.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[d.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:N("heatmap.legend.less")}),d.jsx("div",{className:"flex gap-0.5",children:a.map((g,y)=>d.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:g}},y))}),d.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:N("heatmap.legend.more")})]})]})}const eh={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},il={...eh,position:"fixed",top:0,left:0};function kt(e){const t=Xt(th,e).current;return t.next=e,Ce(t.effect),t}function th(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Lr=Symbol("NOT_FOUND");function nh(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function rh(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function oh(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var Ta=e=>Array.isArray(e)?e:[e];function sh(e){const t=Array.isArray(e[0])?e[0]:e;return oh(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function ah(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}function ih(e){let t;return{get(n){return t&&e(t.key,n)?t.value:Lr},put(n,r){t={key:n,value:r}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function lh(e,t){let n=[];function r(i){const l=n.findIndex(c=>t(i,c.key));if(l>-1){const c=n[l];return l>0&&(n.splice(l,1),n.unshift(c)),c.value}return Lr}function o(i,l){r(i)===Lr&&(n.unshift({key:i,value:l}),n.length>e&&n.pop())}function s(){return n}function a(){n=[]}return{get:r,put:o,getEntries:s,clear:a}}var ch=(e,t)=>e===t;function uh(e){return function(n,r){if(n===null||r===null||n.length!==r.length)return!1;const{length:o}=n;for(let s=0;s<o;s++)if(!e(n[s],r[s]))return!1;return!0}}function dh(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:r=ch,maxSize:o=1,resultEqualityCheck:s}=n,a=uh(r);let i=0;const l=o<=1?ih(a):lh(o,a);function c(){let u=l.get(arguments);if(u===Lr){if(u=e.apply(null,arguments),i++,s){const m=l.getEntries().find(p=>s(p.value,u));m&&(u=m.value,i!==0&&i--)}l.put(arguments,u)}return u}return c.clearCache=()=>{l.clear(),c.resetResultsCount()},c.resultsCount=()=>i,c.resetResultsCount=()=>{i=0},c}var fh=class{constructor(e){this.value=e}deref(){return this.value}},hh=typeof WeakRef<"u"?WeakRef:fh,mh=0,Ea=1;function Sr(){return{s:mh,v:void 0,o:null,p:null}}function ll(e,t={}){let n=Sr();const{resultEqualityCheck:r}=t;let o,s=0;function a(){let i=n;const{length:l}=arguments;for(let f=0,m=l;f<m;f++){const p=arguments[f];if(typeof p=="function"||typeof p=="object"&&p!==null){let g=i.o;g===null&&(i.o=g=new WeakMap);const y=g.get(p);y===void 0?(i=Sr(),g.set(p,i)):i=y}else{let g=i.p;g===null&&(i.p=g=new Map);const y=g.get(p);y===void 0?(i=Sr(),g.set(p,i)):i=y}}const c=i;let u;if(i.s===Ea)u=i.v;else if(u=e.apply(null,arguments),s++,r){const f=o?.deref?.()??o;f!=null&&r(f,u)&&(u=f,s!==0&&s--),o=typeof u=="object"&&u!==null||typeof u=="function"?new hh(u):u}return c.s=Ea,c.v=u,u}return a.clearCache=()=>{n=Sr(),a.resetResultsCount()},a.resultsCount=()=>s,a.resetResultsCount=()=>{s=0},a}function cl(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...o)=>{let s=0,a=0,i,l={},c=o.pop();typeof c=="object"&&(l=c,c=o.pop()),nh(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const u={...n,...l},{memoize:f,memoizeOptions:m=[],argsMemoize:p=ll,argsMemoizeOptions:g=[]}=u,y=Ta(m),b=Ta(g),v=sh(o),x=f(function(){return s++,c.apply(null,arguments)},...y),w=p(function(){a++;const C=ah(v,arguments);return i=x.apply(null,C),i},...b);return Object.assign(w,{resultFunc:c,memoizedResultFunc:x,dependencies:v,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>i,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var gh=cl(ll),ph=Object.assign((e,t=gh)=>{rh(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const n=Object.keys(e),r=n.map(s=>e[s]);return t(r,(...s)=>s.reduce((a,i,l)=>(a[n[l]]=i,a),{}))},{withTypes:()=>ph});cl({memoize:dh,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const pe=(e,t,n,r,o,s,...a)=>{if(a.length>0)throw new Error(pn(1));let i;if(e)i=e;else throw new Error("Missing arguments");return i};var Do={exports:{}},Oo={};var Na;function yh(){if(Na)return Oo;Na=1;var e=Vi();function t(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,a=e.useDebugValue;function i(f,m){var p=m(),g=r({inst:{value:p,getSnapshot:m}}),y=g[0].inst,b=g[1];return s(function(){y.value=p,y.getSnapshot=m,l(y)&&b({inst:y})},[f,p,m]),o(function(){return l(y)&&b({inst:y}),f(function(){l(y)&&b({inst:y})})},[f]),a(p),p}function l(f){var m=f.getSnapshot;f=f.value;try{var p=m();return!n(f,p)}catch{return!0}}function c(f,m){return m()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:i;return Oo.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Oo}var Da;function ul(){return Da||(Da=1,Do.exports=yh()),Do.exports}var bh=ul(),Ro={exports:{}},jo={};var Oa;function xh(){if(Oa)return jo;Oa=1;var e=Vi(),t=ul();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,a=e.useEffect,i=e.useMemo,l=e.useDebugValue;return jo.useSyncExternalStoreWithSelector=function(c,u,f,m,p){var g=s(null);if(g.current===null){var y={hasValue:!1,value:null};g.current=y}else y=g.current;g=i(function(){function v(S){if(!x){if(x=!0,w=S,S=m(S),p!==void 0&&y.hasValue){var T=y.value;if(p(T,S))return k=T}return k=S}if(T=k,r(w,S))return T;var M=m(S);return p!==void 0&&p(T,M)?(w=S,T):(w=S,k=M)}var x=!1,w,k,C=f===void 0?null:f;return[function(){return v(u())},C===null?void 0:function(){return v(C())}]},[u,f,m,p]);var b=o(c,g[0],g[1]);return a(function(){y.hasValue=!0,y.value=b},[b]),l(b),b},jo}var Ra;function wh(){return Ra||(Ra=1,Ro.exports=xh()),Ro.exports}var vh=wh();const kh=zi(19),Sh=kh?Mh:Th;function Ch(e,t,n,r,o){return Sh(e,t,n,r,o)}function Mh(e,t,n,r,o){const s=h.useCallback(()=>t(e.getSnapshot(),n,r,o),[e,t,n,r,o]);return bh.useSyncExternalStore(e.subscribe,s,s)}function Th(e,t,n,r,o){return vh.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,s=>t(s,n,r,o))}class tr{constructor(t){this.state=t,this.listeners=new Set,this.updateTick=0}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});getSnapshot=()=>this.state;setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const r of this.listeners){if(n!==this.updateTick)return;r(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){tr.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||tr.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};tr.prototype.setState.call(this,t)}}class Ms extends tr{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}controlledValues=new Map;useSyncedValue(t,n){h.useDebugValue(t),Ce(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){const r=this;Ce(()=>(r.state[t]!==n&&r.set(t,n),()=>{r.set(t,void 0)}),[r,t,n])}useSyncedValues(t){const n=this,r=Object.values(t);Ce(()=>{n.update(t)},[n,...r])}useControlledProp(t,n,r){h.useDebugValue(t);const o=this,s=n!==void 0;this.controlledValues.has(t)||(this.controlledValues.set(t,s),!s&&!Object.is(this.state[t],r)&&super.setState({...this.state,[t]:r})),Ce(()=>{s&&!Object.is(o.state[t],n)&&super.setState({...o.state,[t]:n})},[o,t,n,r,s])}set(t,n){this.controlledValues.get(t)!==!0&&super.set(t,n)}update(t){const n={...t};for(const r in n)if(Object.hasOwn(n,r)&&this.controlledValues.get(r)===!0){delete n[r];continue}super.update(n)}setState(t){const n={...t};for(const r in n)if(Object.hasOwn(n,r)&&this.controlledValues.get(r)===!0){delete n[r];continue}super.setState({...this.state,...n})}select=(t,n,r,o)=>{const s=this.selectors[t];return s(this.state,n,r,o)};useState=(t,n,r,o)=>{h.useDebugValue(t);const s=this.selectors[t];return Ch(this,s,n,r,o)};useContextCallback(t,n){h.useDebugValue(t);const r=me(n??qi);this.context[t]=r}useStateSetter(t){const n=h.useRef(void 0);return n.current===void 0&&(n.current=r=>{this.set(t,r)}),n.current}observe(t,n){let r;typeof t=="function"?r=t:r=this.selectors[t];let o=r(this.state);return n(o,o,this),this.subscribe(s=>{const a=r(s);if(!Object.is(o,a)){const i=o;o=a,n(a,i,this)}})}}const Eh=[];function Ts(e){h.useEffect(e,Eh)}const Cr=null;class Nh{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=t=>{this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let o=0;o<n.length;o+=1)n[o]?.(t)};request(t){const n=this.nextId;return this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1,!this.isScheduled&&(requestAnimationFrame(this.tick),this.isScheduled=!0),n}cancel(t){const n=t-this.startId;n<0||n>=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}}const Mr=new Nh;class vt{static create(){return new vt}static request(t){return Mr.request(t)}static cancel(t){return Mr.cancel(t)}currentId=Cr;request(t){this.cancel(),this.currentId=Mr.request(()=>{this.currentId=Cr,t()})}cancel=()=>{this.currentId!==Cr&&(Mr.cancel(this.currentId),this.currentId=Cr)};disposeEffect=()=>this.cancel}function Es(){const e=Xt(vt.create).current;return Ts(e.disposeEffect),e}const Kn=0;class Kt{static create(){return new Kt}currentId=Kn;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Kn,n()},t)}isStarted(){return this.currentId!==Kn}clear=()=>{this.currentId!==Kn&&(clearTimeout(this.currentId),this.currentId=Kn)};disposeEffect=()=>this.clear}function hn(){const e=Xt(Kt.create).current;return Ts(e.disposeEffect),e}const Bn=typeof navigator<"u",_o=jh(),dl=Ah(),fl=_h(),Dh=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),hl=_o.platform==="MacIntel"&&_o.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(_o.platform),Oh=Bn&&/apple/i.test(navigator.vendor),rs=Bn&&/android/i.test(dl)||/android/i.test(fl);Bn&&dl.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const Rh=fl.includes("jsdom/");function jh(){if(!Bn)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function _h(){if(!Bn)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function Ah(){if(!Bn)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const os="data-base-ui-focusable",ml="active",gl="selected",pl="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function Tn(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function ke(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Pd(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function et(e){return"composedPath"in e?e.composedPath()[0]:e.target}function ft(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function Ph(e){return e.matches("html,body")}function $e(e){return e?.ownerDocument||document}function yl(e){return ze(e)&&e.matches(pl)}function ja(e){return e?e.getAttribute("role")==="combobox"&&yl(e):!1}function ss(e){return e?e.hasAttribute(os)?e:e.querySelector(`[${os}]`)||e:null}function dn(e,t,n=!0){return e.filter(o=>o.parentId===t&&(!n||o.context?.open)).flatMap(o=>[o,...dn(e,o.id,n)])}function _a(e,t){let n=[],r=e.find(o=>o.id===t)?.parentId;for(;r;){const o=e.find(s=>s.id===r);r=o?.parentId,o&&(n=n.concat(o))}return n}function Ih(e){e.preventDefault(),e.stopPropagation()}function Fh(e){return"nativeEvent"in e}function Lh(e){return e.mozInputSource===0&&e.isTrusted?!0:rs&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Wh(e){return Rh?!1:!rs&&e.width===0&&e.height===0||rs&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function An(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function bl(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const Bh=["top","right","bottom","left"],Pn=Math.min,tt=Math.max,Wr=Math.round,Tr=Math.floor,Mt=e=>({x:e,y:e}),$h={left:"right",right:"left",bottom:"top",top:"bottom"};function as(e,t,n){return tt(e,Pn(t,n))}function Pt(e,t){return typeof e=="function"?e(t):e}function Ke(e){return e.split("-")[0]}function Jt(e){return e.split("-")[1]}function Ns(e){return e==="x"?"y":"x"}function Ds(e){return e==="y"?"height":"width"}function it(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Os(e){return Ns(it(e))}function Yh(e,t,n){n===void 0&&(n=!1);const r=Jt(e),o=Os(e),s=Ds(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Br(a)),[a,Br(a)]}function Hh(e){const t=Br(e);return[is(e),t,is(t)]}function is(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Aa=["left","right"],Pa=["right","left"],Uh=["top","bottom"],Vh=["bottom","top"];function zh(e,t,n){switch(e){case"top":case"bottom":return n?t?Pa:Aa:t?Aa:Pa;case"left":case"right":return t?Uh:Vh;default:return[]}}function qh(e,t,n,r){const o=Jt(e);let s=zh(Ke(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(is)))),s}function Br(e){const t=Ke(e);return $h[t]+e.slice(t.length)}function Gh(e){return{top:0,right:0,bottom:0,left:0,...e}}function xl(e){return typeof e!="number"?Gh(e):{top:e,right:e,bottom:e,left:e}}function $r(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}var Kh=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Yr=Kh.join(","),wl=typeof Element>"u",In=wl?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Hr=!wl&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e?.ownerDocument},Ur=function(t,n){var r;n===void 0&&(n=!0);var o=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),s=o===""||o==="true",a=s||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):Ur(t.parentNode));return a},Xh=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},vl=function(t,n,r){if(Ur(t))return[];var o=Array.prototype.slice.apply(t.querySelectorAll(Yr));return n&&In.call(t,Yr)&&o.unshift(t),o=o.filter(r),o},Vr=function(t,n,r){for(var o=[],s=Array.from(t);s.length;){var a=s.shift();if(!Ur(a,!1))if(a.tagName==="SLOT"){var i=a.assignedElements(),l=i.length?i:a.children,c=Vr(l,!0,r);r.flatten?o.push.apply(o,c):o.push({scopeParent:a,candidates:c})}else{var u=In.call(a,Yr);u&&r.filter(a)&&(n||!t.includes(a))&&o.push(a);var f=a.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(a),m=!Ur(f,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(a));if(f&&m){var p=Vr(f===!0?a.children:f.children,!0,r);r.flatten?o.push.apply(o,p):o.push({scopeParent:a,candidates:p})}else s.unshift.apply(s,a.children)}}return o},kl=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Sl=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||Xh(t))&&!kl(t)?0:t.tabIndex},Jh=function(t,n){var r=Sl(t);return r<0&&n&&!kl(t)?0:r},Qh=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Cl=function(t){return t.tagName==="INPUT"},Zh=function(t){return Cl(t)&&t.type==="hidden"},em=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},tm=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},nm=function(t){if(!t.name)return!0;var n=t.form||Hr(t),r=function(i){return n.querySelectorAll('input[type="radio"][name="'+i+'"]')},o;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")o=r(window.CSS.escape(t.name));else try{o=r(t.name)}catch(a){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",a.message),!1}var s=tm(o,t.form);return!s||s===t},rm=function(t){return Cl(t)&&t.type==="radio"},om=function(t){return rm(t)&&!nm(t)},sm=function(t){var n,r=t&&Hr(t),o=(n=r)===null||n===void 0?void 0:n.host,s=!1;if(r&&r!==t){var a,i,l;for(s=!!((a=o)!==null&&a!==void 0&&(i=a.ownerDocument)!==null&&i!==void 0&&i.contains(o)||t!=null&&(l=t.ownerDocument)!==null&&l!==void 0&&l.contains(t));!s&&o;){var c,u,f;r=Hr(o),o=(c=r)===null||c===void 0?void 0:c.host,s=!!((u=o)!==null&&u!==void 0&&(f=u.ownerDocument)!==null&&f!==void 0&&f.contains(o))}}return s},Ia=function(t){var n=t.getBoundingClientRect(),r=n.width,o=n.height;return r===0&&o===0},am=function(t,n){var r=n.displayCheck,o=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in t){var s=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!s}if(getComputedStyle(t).visibility==="hidden")return!0;var a=In.call(t,"details>summary:first-of-type"),i=a?t.parentElement:t;if(In.call(i,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof o=="function"){for(var l=t;t;){var c=t.parentElement,u=Hr(t);if(c&&!c.shadowRoot&&o(c)===!0)return Ia(t);t.assignedSlot?t=t.assignedSlot:!c&&u!==t.ownerDocument?t=u.host:t=c}t=l}if(sm(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return Ia(t);return!1},im=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var o=n.children.item(r);if(o.tagName==="LEGEND")return In.call(n,"fieldset[disabled] *")?!0:!o.contains(t)}return!0}n=n.parentElement}return!1},ls=function(t,n){return!(n.disabled||Zh(n)||am(n,t)||em(n)||im(n))},cs=function(t,n){return!(om(n)||Sl(n)<0||!ls(t,n))},lm=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Ml=function(t){var n=[],r=[];return t.forEach(function(o,s){var a=!!o.scopeParent,i=a?o.scopeParent:o,l=Jh(i,a),c=a?Ml(o.candidates):i;l===0?a?n.push.apply(n,c):n.push(i):r.push({documentOrder:s,tabIndex:l,item:o,isScope:a,content:c})}),r.sort(Qh).reduce(function(o,s){return s.isScope?o.push.apply(o,s.content):o.push(s.content),o},[]).concat(n)},cr=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Vr([t],n.includeContainer,{filter:cs.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:lm}):r=vl(t,n.includeContainer,cs.bind(null,n)),Ml(r)},cm=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Vr([t],n.includeContainer,{filter:ls.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=vl(t,n.includeContainer,ls.bind(null,n)),r},Tl=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return In.call(t,Yr)===!1?!1:cs(n,t)};const $n=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function El(e,t){const n=cr(e,$n()),r=n.length;if(r===0)return;const o=Tn($e(e)),s=n.indexOf(o),a=s===-1?t===1?0:r-1:s+t;return n[a]}function Rs(e){return El($e(e).body,1)||e}function Nl(e){return El($e(e).body,-1)||e}function Dl(e,t){if(!e)return null;const n=cr($e(e).body,$n()),r=n.length;if(r===0)return null;const o=n.indexOf(e);if(o===-1)return null;const s=(o+t+r)%r;return n[s]}function um(e){return Dl(e,1)}function dm(e){return Dl(e,-1)}function Dn(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!ke(n,r)}function fm(e){cr(e,$n()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Fa(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}const hm={...Id};let La=0;function mm(e,t="mui"){const[n,r]=h.useState(e),o=e||n;return h.useEffect(()=>{n==null&&(La+=1,r(`${t}-${La}`))},[n,t]),o}const Wa=hm.useId;function Yn(e,t){if(Wa!==void 0){const n=Wa();return e??(t?`${t}-${n}`:n)}return mm(e,t)}function Ol(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(r=>r(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}class gm{nodesRef={current:[]};events=Ol();addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(r=>r===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const Rl=h.createContext(null),jl=h.createContext(null),yn=()=>h.useContext(Rl)?.id||null,Hn=e=>{const t=h.useContext(jl);return e??t};function pm(e){const t=Yn(),n=Hn(e),r=yn();return Ce(()=>{if(!t)return;const o={id:t,parentId:r};return n?.addNode(o),()=>{n?.removeNode(o)}},[n,t,r]),t}function ym(e){const{children:t,id:n}=e,r=yn();return d.jsx(Rl.Provider,{value:h.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function bm(e){const{children:t,externalTree:n}=e,r=Xt(()=>n??new gm).current;return d.jsx(jl.Provider,{value:r,children:t})}const xm="none",qt="trigger-press",nt="trigger-hover",_l="outside-press",wm="close-press",nr="focus-out",Al="escape-key",Pl="imperative-action";function je(e,t,n,r){let o=!1,s=!1;const a=zt;return{reason:e,event:t??new Event("base-ui"),cancel(){o=!0},allowPropagation(){s=!0},get isCanceled(){return o},get isPropagationAllowed(){return s},trigger:n,...a}}function rr(e){return`data-base-ui-${e}`}function Ao(e,t,n){if(n&&!An(n))return 0;if(typeof e=="number")return e;if(typeof e=="function"){const r=e();return typeof r=="number"?r:r?.[t]}return e?.[t]}function bn(e){return e?.ownerDocument||document}const Fn=h.forwardRef(function(t,n){const[r,o]=h.useState();Ce(()=>{Oh&&o("button")},[]);const s={tabIndex:0,role:r};return d.jsx("span",{...t,ref:n,style:il,"aria-hidden":r?void 0:!0,...s,"data-base-ui-focus-guard":""})});let Ba=0;function Po(e,t={}){const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(Ba);const s=()=>e?.focus({preventScroll:n});o?s():Ba=requestAnimationFrame(s)}const On={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function $a(e){return e==="inert"?On.inert:e==="aria-hidden"?On["aria-hidden"]:On.none}let Er=new WeakSet,Nr={},Io=0;const Il=e=>e&&(e.host||Il(e.parentNode)),vm=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=Il(n);return e.contains(r)?r:null}).filter(n=>n!=null);function km(e,t,n,r){const o="data-base-ui-inert",s=r?"inert":n?"aria-hidden":null,a=vm(t,e),i=new Set,l=new Set(a),c=[];Nr[o]||(Nr[o]=new WeakMap);const u=Nr[o];a.forEach(f),m(t),i.clear();function f(p){!p||i.has(p)||(i.add(p),p.parentNode&&f(p.parentNode))}function m(p){!p||l.has(p)||[].forEach.call(p.children,g=>{if(ir(g)!=="script")if(i.has(g))m(g);else{const y=s?g.getAttribute(s):null,b=y!==null&&y!=="false",v=$a(s),x=(v.get(g)||0)+1,w=(u.get(g)||0)+1;v.set(g,x),u.set(g,w),c.push(g),x===1&&b&&Er.add(g),w===1&&g.setAttribute(o,""),!b&&s&&g.setAttribute(s,s==="inert"?"":"true")}})}return Io+=1,()=>{c.forEach(p=>{const g=$a(s),b=(g.get(p)||0)-1,v=(u.get(p)||0)-1;g.set(p,b),u.set(p,v),b||(!Er.has(p)&&s&&p.removeAttribute(s),Er.delete(p)),v||p.removeAttribute(o)}),Io-=1,Io||(On.inert=new WeakMap,On["aria-hidden"]=new WeakMap,On.none=new WeakMap,Er=new WeakSet,Nr={})}}function Sm(e,t=!1,n=!1){const r=$e(e[0]).body;return km(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const Fl=h.createContext(null),Ll=()=>h.useContext(Fl),Cm=rr("portal");function Mm(e={}){const{ref:t,container:n,componentProps:r=zt,elementProps:o,elementState:s}=e,a=Yn(),l=Ll()?.portalNode,[c,u]=h.useState(null),[f,m]=h.useState(null),p=me(v=>{v!==null&&m(v)}),g=h.useRef(null);Ce(()=>{if(n===null){g.current&&(g.current=null,m(null),u(null));return}if(a==null)return;const v=(n&&(Fd(n)?n:n.current))??l??document.body;if(v==null){g.current&&(g.current=null,m(null),u(null));return}g.current!==v&&(g.current=v,m(null),u(v))},[n,l,a]);const y=It("div",r,{ref:[t,p],state:s,props:[{id:a,[Cm]:""},o]});return{portalNode:f,portalSubtree:c&&y?Gt.createPortal(y,c):null}}const Wl=h.forwardRef(function(t,n){const{children:r,container:o,className:s,render:a,renderGuards:i,...l}=t,{portalNode:c,portalSubtree:u}=Mm({container:o,ref:n,componentProps:t,elementProps:l}),f=h.useRef(null),m=h.useRef(null),p=h.useRef(null),g=h.useRef(null),[y,b]=h.useState(null),v=y?.modal,x=y?.open,w=typeof i=="boolean"?i:!!y&&!y.modal&&y.open&&!!c;h.useEffect(()=>{if(!c||v)return;function C(S){c&&S.relatedTarget&&Dn(S)&&(S.type==="focusin"?Fa:fm)(c)}return c.addEventListener("focusin",C,!0),c.addEventListener("focusout",C,!0),()=>{c.removeEventListener("focusin",C,!0),c.removeEventListener("focusout",C,!0)}},[c,v]),h.useEffect(()=>{!c||x||Fa(c)},[x,c]);const k=h.useMemo(()=>({beforeOutsideRef:f,afterOutsideRef:m,beforeInsideRef:p,afterInsideRef:g,portalNode:c,setFocusManagerState:b}),[c]);return d.jsxs(h.Fragment,{children:[u,d.jsxs(Fl.Provider,{value:k,children:[w&&c&&d.jsx(Fn,{"data-type":"outside",ref:f,onFocus:C=>{if(Dn(C,c))p.current?.focus();else{const S=y?y.domReference:null;Nl(S)?.focus()}}}),w&&c&&d.jsx("span",{"aria-owns":c.id,style:sf}),c&&Gt.createPortal(r,c),w&&c&&d.jsx(Fn,{"data-type":"outside",ref:m,onFocus:C=>{if(Dn(C,c))g.current?.focus();else{const S=y?y.domReference:null;Rs(S)?.focus(),y?.closeOnFocusOut&&y?.onOpenChange(!1,je(nr,C.nativeEvent))}}})]})]})});function jt(e){return e==null?e:"current"in e?e.current:e}function Tm(e,t){const n=lt(e.target);return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const Ya=20;let Vt=[];function js(){Vt=Vt.filter(e=>e.isConnected)}function Em(e){js(),e&&ir(e)!=="body"&&(Vt.push(e),Vt.length>Ya&&(Vt=Vt.slice(-Ya)))}function Fo(){return js(),Vt[Vt.length-1]}function Nm(e){if(!e)return null;const t=$n();return Tl(e,t)?e:cr(e,t)[0]||e}function Dm(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():pt(e).display!=="none"}function Ha(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=$n(),o=cm(e,n).filter(a=>{const i=a.getAttribute("data-tabindex")||"";return Tl(a,n)||a.hasAttribute("data-tabindex")&&!i.startsWith("-")}),s=e.getAttribute("tabindex");t.current.includes("floating")||o.length===0?s!=="0"&&e.setAttribute("tabindex","0"):(s!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function Bl(e){const{context:t,children:n,disabled:r=!1,order:o=["content"],initialFocus:s=!0,returnFocus:a=!0,restoreFocus:i=!1,modal:l=!0,closeOnFocusOut:c=!0,openInteractionType:u="",getInsideElements:f=()=>[],nextFocusableElement:m,previousFocusableElement:p,beforeContentFocusGuardRef:g,externalTree:y}=e,b="rootStore"in t?t.rootStore:t,v=b.useState("open"),x=b.useState("domReferenceElement"),w=b.useState("floatingElement"),{events:k,dataRef:C}=b.context,S=me(()=>C.current.floatingContext?.nodeId),T=me(f),M=s===!1,A=ja(x)&&M,R=kt(o),D=kt(s),_=kt(a),E=kt(u),I=Hn(y),j=Ll(),B=h.useRef(null),H=h.useRef(null),O=h.useRef(!1),F=h.useRef(!1),V=h.useRef(!1),$=h.useRef(-1),Q=h.useRef(""),U=h.useRef(""),W=h.useRef(null),K=h.useRef(null),G=pa(W,g,j?.beforeInsideRef),te=pa(K,j?.afterInsideRef),xe=hn(),Ee=hn(),be=Es(),_e=j!=null,P=ss(w),le=me((Y=P)=>Y?cr(Y,$n()):[]),X=me(Y=>{const z=le(Y);return R.current.map(()=>z).filter(Boolean).flat()});h.useEffect(()=>{if(r||!l)return;function Y(Z){Z.key==="Tab"&&ke(P,Tn($e(P)))&&le().length===0&&!A&&Ih(Z)}const z=$e(P);return z.addEventListener("keydown",Y),()=>{z.removeEventListener("keydown",Y)}},[r,x,P,l,R,A,le,X]),h.useEffect(()=>{if(r||!w)return;function Y(z){const Z=et(z),ge=le().indexOf(Z);ge!==-1&&($.current=ge)}return w.addEventListener("focusin",Y),()=>{w.removeEventListener("focusin",Y)}},[r,w,le]),h.useEffect(()=>{if(r||!v)return;const Y=$e(P);function z(){V.current=!1}function Z(ge){const ae=et(ge),re=ke(w,ae)||ke(x,ae)||ke(j?.portalNode,ae);V.current=!re,U.current=ge.pointerType||"keyboard"}function fe(){U.current="keyboard"}return Y.addEventListener("pointerdown",Z,!0),Y.addEventListener("pointerup",z,!0),Y.addEventListener("pointercancel",z,!0),Y.addEventListener("keydown",fe,!0),()=>{Y.removeEventListener("pointerdown",Z,!0),Y.removeEventListener("pointerup",z,!0),Y.removeEventListener("pointercancel",z,!0),Y.removeEventListener("keydown",fe,!0)}},[r,w,x,P,v,j]),h.useEffect(()=>{if(r||!c)return;function Y(){F.current=!0,Ee.start(0,()=>{F.current=!1})}function z(ae){const re=ae.relatedTarget,we=ae.currentTarget,Se=et(ae);queueMicrotask(()=>{const Ae=S(),Xe=b.context.triggerElements,ot=re?.hasAttribute(rr("focus-guard"))&&[W.current,K.current,j?.beforeInsideRef.current,j?.afterInsideRef.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,jt(p),jt(m)].includes(re),He=!(ke(x,re)||ke(w,re)||ke(re,w)||ke(j?.portalNode,re)||re!=null&&Xe.hasElement(re)||Xe.hasMatchingElement(ce=>ke(ce,re))||ot||I&&(dn(I.nodesRef.current,Ae).find(ce=>ke(ce.context?.elements.floating,re)||ke(ce.context?.elements.domReference,re))||_a(I.nodesRef.current,Ae).find(ce=>[ce.context?.elements.floating,ss(ce.context?.elements.floating)].includes(re)||ce.context?.elements.domReference===re)));if(we===x&&P&&Ha(P,R),i&&we!==x&&!Dm(Se)&&Tn($e(P))===$e(P).body){if(ze(P)&&(P.focus(),i==="popup")){be.request(()=>{P.focus()});return}const ce=$.current,Ye=le(),Oe=Ye[ce]||Ye[Ye.length-1]||P;ze(Oe)&&Oe.focus()}if(C.current.insideReactTree){C.current.insideReactTree=!1;return}(A||!l)&&re&&He&&!F.current&&(A||re!==Fo())&&(O.current=!0,b.setOpen(!1,je(nr,ae)))})}function Z(){V.current||(C.current.insideReactTree=!0,xe.start(0,()=>{C.current.insideReactTree=!1}))}const fe=ze(x)?x:null,ge=[];if(!(!w&&!fe))return fe&&(fe.addEventListener("focusout",z),fe.addEventListener("pointerdown",Y),ge.push(()=>{fe.removeEventListener("focusout",z),fe.removeEventListener("pointerdown",Y)})),w&&(w.addEventListener("focusout",z),j&&(w.addEventListener("focusout",Z,!0),ge.push(()=>{w.removeEventListener("focusout",Z,!0)})),ge.push(()=>{w.removeEventListener("focusout",z)})),()=>{ge.forEach(ae=>{ae()})}},[r,x,w,P,l,I,j,b,c,i,le,A,S,R,C,xe,Ee,be,m,p]),h.useEffect(()=>{if(r||!w||!v)return;const Y=Array.from(j?.portalNode?.querySelectorAll(`[${rr("portal")}]`)||[]),Z=(I?_a(I.nodesRef.current,S()):[]).find(ae=>ja(ae.context?.elements.domReference||null))?.context?.elements.domReference,fe=[w,Z,...Y,...T(),B.current,H.current,W.current,K.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,jt(p),jt(m),A?x:null].filter(ae=>ae!=null),ge=Sm(fe,l||A);return()=>{ge()}},[v,r,x,w,l,R,j,A,I,S,T,m,p]),Ce(()=>{if(!v||r||!ze(P))return;const Y=$e(P),z=Tn(Y);queueMicrotask(()=>{const Z=X(P),fe=D.current,ge=typeof fe=="function"?fe(E.current||""):fe;if(ge===void 0||ge===!1)return;let ae;ge===!0||ge===null?ae=Z[0]||P:ae=jt(ge),ae=ae||Z[0]||P,!ke(P,z)&&Po(ae,{preventScroll:ae===P})})},[r,v,P,M,X,D,E]),Ce(()=>{if(r||!P)return;const Y=$e(P),z=Tn(Y);Em(z);function Z(ae){if(ae.open||(Q.current=Tm(ae.nativeEvent,U.current)),ae.reason===nt&&ae.nativeEvent.type==="mouseleave"&&(O.current=!0),ae.reason===_l)if(ae.nested)O.current=!1;else if(Lh(ae.nativeEvent)||Wh(ae.nativeEvent))O.current=!1;else{let re=!1;document.createElement("div").focus({get preventScroll(){return re=!0,!1}}),re?O.current=!1:O.current=!0}}k.on("openchange",Z);const fe=Y.createElement("span");fe.setAttribute("tabindex","-1"),fe.setAttribute("aria-hidden","true"),Object.assign(fe.style,il),_e&&x&&x.insertAdjacentElement("afterend",fe);function ge(){const ae=_.current;let re=typeof ae=="function"?ae(Q.current):ae;if(re===void 0||re===!1)return null;if(re===null&&(re=!0),typeof re=="boolean"){const Se=x||Fo();return Se&&Se.isConnected?Se:fe}const we=x||Fo()||fe;return jt(re)||we}return()=>{k.off("openchange",Z);const ae=Tn(Y),re=ke(w,ae)||I&&dn(I.nodesRef.current,S(),!1).some(Se=>ke(Se.context?.elements.floating,ae)),we=ge();queueMicrotask(()=>{const Se=Nm(we),Ae=typeof _.current!="boolean";_.current&&!O.current&&ze(Se)&&(!(!Ae&&Se!==ae&&ae!==Y.body)||re)&&Se.focus({preventScroll:!0}),fe.remove()})}},[r,w,P,_,C,k,I,_e,x,S]),h.useEffect(()=>{queueMicrotask(()=>{O.current=!1})},[r]),h.useEffect(()=>{if(r||!v)return;function Y(Z){et(Z)?.closest(`[${Qi}]`)&&(F.current=!0)}const z=$e(P);return z.addEventListener("pointerdown",Y,!0),()=>{z.removeEventListener("pointerdown",Y,!0)}},[r,v,P]),Ce(()=>{if(!r&&j)return j.setFocusManagerState({modal:l,closeOnFocusOut:c,open:v,onOpenChange:b.setOpen,domReference:x}),()=>{j.setFocusManagerState(null)}},[r,j,l,v,b,c,x]),Ce(()=>{if(!(r||!P))return Ha(P,R),()=>{queueMicrotask(js)}},[r,P,R]);const ye=!r&&(l?!A:!0)&&(_e||l);return d.jsxs(h.Fragment,{children:[ye&&d.jsx(Fn,{"data-type":"inside",ref:G,onFocus:Y=>{if(l){const z=X();Po(z[z.length-1])}else j?.portalNode&&(O.current=!1,Dn(Y,j.portalNode)?Rs(x)?.focus():jt(p??j.beforeOutsideRef)?.focus())}}),n,ye&&d.jsx(Fn,{"data-type":"inside",ref:te,onFocus:Y=>{l?Po(X()[0]):j?.portalNode&&(c&&(O.current=!0),Dn(Y,j.portalNode)?Nl(x)?.focus():jt(m??j.afterOutsideRef)?.focus())}})]})}function Om(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.context.dataRef,{enabled:o=!0,event:s="click",toggle:a=!0,ignoreMouse:i=!1,stickIfOpen:l=!0,touchOpenDelay:c=0}=t,u=h.useRef(void 0),f=Es(),m=hn(),p=h.useMemo(()=>({onPointerDown(g){u.current=g.pointerType},onMouseDown(g){const y=u.current,b=g.nativeEvent,v=n.select("open");if(g.button!==0||s==="click"||An(y,!0)&&i)return;const x=r.current.openEvent,w=x?.type,k=n.select("domReferenceElement")!==g.currentTarget,C=v&&k||!(v&&a&&(!(x&&l)||w==="click"||w==="mousedown"));if(yl(b.target)){const T=je(qt,b,b.target);C&&y==="touch"&&c>0?m.start(c,()=>{n.setOpen(!0,T)}):n.setOpen(C,T);return}const S=g.currentTarget;f.request(()=>{const T=je(qt,b,S);C&&y==="touch"&&c>0?m.start(c,()=>{n.setOpen(!0,T)}):n.setOpen(C,T)})},onClick(g){if(s==="mousedown-only")return;const y=u.current;if(s==="mousedown"&&y){u.current=void 0;return}if(An(y,!0)&&i)return;const b=n.select("open"),v=r.current.openEvent,x=n.select("domReferenceElement")!==g.currentTarget,w=b&&x||!(b&&a&&(!(v&&l)||bl(v))),k=je(qt,g.nativeEvent,g.currentTarget);w&&y==="touch"&&c>0?m.start(c,()=>{n.setOpen(!0,k)}):n.setOpen(w,k)},onKeyDown(){u.current=void 0}}),[r,s,i,n,l,a,f,m,c]);return h.useMemo(()=>o?{reference:p}:zt,[o,p])}function Ua(e,t,n){let{reference:r,floating:o}=e;const s=it(t),a=Os(t),i=Ds(a),l=Ke(t),c=s==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,m=r[i]/2-o[i]/2;let p;switch(l){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Jt(t)){case"start":p[a]-=m*(n&&c?-1:1);break;case"end":p[a]+=m*(n&&c?-1:1);break}return p}async function Rm(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:a,elements:i,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:m=!1,padding:p=0}=Pt(t,e),g=xl(p),b=i[m?f==="floating"?"reference":"floating":f],v=$r(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(i.floating)),boundary:c,rootBoundary:u,strategy:l})),x=f==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,w=await(s.getOffsetParent==null?void 0:s.getOffsetParent(i.floating)),k=await(s.isElement==null?void 0:s.isElement(w))?await(s.getScale==null?void 0:s.getScale(w))||{x:1,y:1}:{x:1,y:1},C=$r(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:x,offsetParent:w,strategy:l}):x);return{top:(v.top-C.top+g.top)/k.y,bottom:(C.bottom-v.bottom+g.bottom)/k.y,left:(v.left-C.left+g.left)/k.x,right:(C.right-v.right+g.right)/k.x}}const jm=50,_m=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:a}=n,i=a.detectOverflow?a:{...a,detectOverflow:Rm},l=await(a.isRTL==null?void 0:a.isRTL(t));let c=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:f}=Ua(c,r,l),m=r,p=0;const g={};for(let y=0;y<s.length;y++){const b=s[y];if(!b)continue;const{name:v,fn:x}=b,{x:w,y:k,data:C,reset:S}=await x({x:u,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:g,rects:c,platform:i,elements:{reference:e,floating:t}});u=w??u,f=k??f,g[v]={...g[v],...C},S&&p<jm&&(p++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(c=S.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:u,y:f}=Ua(c,m,l)),y=-1)}return{x:u,y:f,placement:m,strategy:o,middlewareData:g}},Am=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:a,initialPlacement:i,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...b}=Pt(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=Ke(o),x=it(i),w=Ke(i)===i,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(w||!y?[Br(i)]:Hh(i)),S=g!=="none";!m&&S&&C.push(...qh(i,y,g,k));const T=[i,...C],M=await l.detectOverflow(t,b),A=[];let R=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&A.push(M[v]),f){const I=Yh(o,a,k);A.push(M[I[0]],M[I[1]])}if(R=[...R,{placement:o,overflows:A}],!A.every(I=>I<=0)){var D,_;const I=(((D=s.flip)==null?void 0:D.index)||0)+1,j=T[I];if(j&&(!(f==="alignment"?x!==it(j):!1)||R.every(O=>it(O.placement)===x?O.overflows[0]>0:!0)))return{data:{index:I,overflows:R},reset:{placement:j}};let B=(_=R.filter(H=>H.overflows[0]<=0).sort((H,O)=>H.overflows[1]-O.overflows[1])[0])==null?void 0:_.placement;if(!B)switch(p){case"bestFit":{var E;const H=(E=R.filter(O=>{if(S){const F=it(O.placement);return F===x||F==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(F=>F>0).reduce((F,V)=>F+V,0)]).sort((O,F)=>O[1]-F[1])[0])==null?void 0:E[0];H&&(B=H);break}case"initialPlacement":B=i;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function Va(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function za(e){return Bh.some(t=>e[t]>=0)}const Pm=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...s}=Pt(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),i=Va(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:za(i)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),i=Va(a,n.floating);return{data:{escapedOffsets:i,escaped:za(i)}}}default:return{}}}}},$l=new Set(["left","top"]);async function Im(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Ke(n),i=Jt(n),l=it(n)==="y",c=$l.has(a)?-1:1,u=s&&l?-1:1,f=Pt(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return i&&typeof g=="number"&&(p=i==="end"?g*-1:g),l?{x:p*u,y:m*c}:{x:m*c,y:p*u}}const Fm=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:a,middlewareData:i}=t,l=await Im(t,e);return a===((n=i.offset)==null?void 0:n.placement)&&(r=i.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:a}}}}},Lm=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:s}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:l={fn:v=>{let{x,y:w}=v;return{x,y:w}}},...c}=Pt(e,t),u={x:n,y:r},f=await s.detectOverflow(t,c),m=it(Ke(o)),p=Ns(m);let g=u[p],y=u[m];if(a){const v=p==="y"?"top":"left",x=p==="y"?"bottom":"right",w=g+f[v],k=g-f[x];g=as(w,g,k)}if(i){const v=m==="y"?"top":"left",x=m==="y"?"bottom":"right",w=y+f[v],k=y-f[x];y=as(w,y,k)}const b=l.fn({...t,[p]:g,[m]:y});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[p]:a,[m]:i}}}}}},Wm=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:a}=t,{offset:i=0,mainAxis:l=!0,crossAxis:c=!0}=Pt(e,t),u={x:n,y:r},f=it(o),m=Ns(f);let p=u[m],g=u[f];const y=Pt(i,t),b=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(l){const w=m==="y"?"height":"width",k=s.reference[m]-s.floating[w]+b.mainAxis,C=s.reference[m]+s.reference[w]-b.mainAxis;p<k?p=k:p>C&&(p=C)}if(c){var v,x;const w=m==="y"?"width":"height",k=$l.has(Ke(o)),C=s.reference[f]-s.floating[w]+(k&&((v=a.offset)==null?void 0:v[f])||0)+(k?0:b.crossAxis),S=s.reference[f]+s.reference[w]+(k?0:((x=a.offset)==null?void 0:x[f])||0)-(k?b.crossAxis:0);g<C?g=C:g>S&&(g=S)}return{[m]:p,[f]:g}}}},Bm=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:a,elements:i}=t,{apply:l=()=>{},...c}=Pt(e,t),u=await a.detectOverflow(t,c),f=Ke(o),m=Jt(o),p=it(o)==="y",{width:g,height:y}=s.floating;let b,v;f==="top"||f==="bottom"?(b=f,v=m===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(v=f,b=m==="end"?"top":"bottom");const x=y-u.top-u.bottom,w=g-u.left-u.right,k=Pn(y-u[b],x),C=Pn(g-u[v],w),S=!t.middlewareData.shift;let T=k,M=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(M=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(T=x),S&&!m){const R=tt(u.left,0),D=tt(u.right,0),_=tt(u.top,0),E=tt(u.bottom,0);p?M=g-2*(R!==0||D!==0?R+D:tt(u.left,u.right)):T=y-2*(_!==0||E!==0?_+E:tt(u.top,u.bottom))}await l({...t,availableWidth:M,availableHeight:T});const A=await a.getDimensions(i.floating);return g!==A.width||y!==A.height?{reset:{rects:!0}}:{}}}};function Yl(e){const t=pt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=ze(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,i=Wr(n)!==s||Wr(r)!==a;return i&&(n=s,r=a),{width:n,height:r,$:i}}function _s(e){return De(e)?e:e.contextElement}function Rn(e){const t=_s(e);if(!ze(t))return Mt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Yl(t);let a=(s?Wr(n.width):n.width)/r,i=(s?Wr(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const $m=Mt(0);function Hl(e){const t=lt(e);return!xs()||!t.visualViewport?$m:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ym(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==lt(e)?!1:t}function mn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=_s(e);let a=Mt(1);t&&(r?De(r)&&(a=Rn(r)):a=Rn(e));const i=Ym(s,n,r)?Hl(s):Mt(0);let l=(o.left+i.x)/a.x,c=(o.top+i.y)/a.y,u=o.width/a.x,f=o.height/a.y;if(s){const m=lt(s),p=r&&De(r)?lt(r):r;let g=m,y=ya(g);for(;y&&r&&p!==g;){const b=Rn(y),v=y.getBoundingClientRect(),x=pt(y),w=v.left+(y.clientLeft+parseFloat(x.paddingLeft))*b.x,k=v.top+(y.clientTop+parseFloat(x.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,f*=b.y,l+=w,c+=k,g=lt(y),y=ya(g)}}return $r({width:u,height:f,x:l,y:c})}function Zr(e,t){const n=Xr(e).scrollLeft;return t?t.left+n:mn(Ft(e)).left+n}function Ul(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Zr(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Hm(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=Ft(r),i=t?ws(t.floating):!1;if(r===a||i&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Mt(1);const u=Mt(0),f=ze(r);if((f||!f&&!s)&&((ir(r)!=="body"||lr(a))&&(l=Xr(r)),f)){const p=mn(r);c=Rn(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const m=a&&!f&&!s?Ul(a,l):Mt(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+m.x,y:n.y*c.y-l.scrollTop*c.y+u.y+m.y}}function Um(e){return Array.from(e.getClientRects())}function Vm(e){const t=Ft(e),n=Xr(e),r=e.ownerDocument.body,o=tt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=tt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Zr(e);const i=-n.scrollTop;return pt(r).direction==="rtl"&&(a+=tt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:i}}const qa=25;function zm(e,t){const n=lt(e),r=Ft(e),o=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,i=0,l=0;if(o){s=o.width,a=o.height;const u=xs();(!u||u&&t==="fixed")&&(i=o.offsetLeft,l=o.offsetTop)}const c=Zr(r);if(c<=0){const u=r.ownerDocument,f=u.body,m=getComputedStyle(f),p=u.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(r.clientWidth-f.clientWidth-p);g<=qa&&(s-=g)}else c<=qa&&(s+=c);return{width:s,height:a,x:i,y:l}}function qm(e,t){const n=mn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=ze(e)?Rn(e):Mt(1),a=e.clientWidth*s.x,i=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:a,height:i,x:l,y:c}}function Ga(e,t,n){let r;if(t==="viewport")r=zm(e,n);else if(t==="document")r=Vm(Ft(e));else if(De(t))r=qm(t,n);else{const o=Hl(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return $r(r)}function Vl(e,t){const n=_n(e);return n===t||!De(n)||un(n)?!1:pt(n).position==="fixed"||Vl(n,t)}function Gm(e,t){const n=t.get(e);if(n)return n;let r=Nn(e,[],!1).filter(i=>De(i)&&ir(i)!=="body"),o=null;const s=pt(e).position==="fixed";let a=s?_n(e):e;for(;De(a)&&!un(a);){const i=pt(a),l=Gi(a);!l&&i.position==="fixed"&&(o=null),(s?!l&&!o:!l&&i.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||lr(a)&&!l&&Vl(e,a))?r=r.filter(u=>u!==a):o=i,a=_n(a)}return t.set(e,r),r}function Km(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?ws(t)?[]:Gm(t,this._c):[].concat(n),r],i=Ga(t,a[0],o);let l=i.top,c=i.right,u=i.bottom,f=i.left;for(let m=1;m<a.length;m++){const p=Ga(t,a[m],o);l=tt(p.top,l),c=Pn(p.right,c),u=Pn(p.bottom,u),f=tt(p.left,f)}return{width:c-f,height:u-l,x:f,y:l}}function Xm(e){const{width:t,height:n}=Yl(e);return{width:t,height:n}}function Jm(e,t,n){const r=ze(t),o=Ft(t),s=n==="fixed",a=mn(e,!0,s,t);let i={scrollLeft:0,scrollTop:0};const l=Mt(0);function c(){l.x=Zr(o)}if(r||!r&&!s)if((ir(t)!=="body"||lr(o))&&(i=Xr(t)),r){const p=mn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?Ul(o,i):Mt(0),f=a.left+i.scrollLeft-l.x-u.x,m=a.top+i.scrollTop-l.y-u.y;return{x:f,y:m,width:a.width,height:a.height}}function Lo(e){return pt(e).position==="static"}function Ka(e,t){if(!ze(e)||pt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ft(e)===n&&(n=n.ownerDocument.body),n}function zl(e,t){const n=lt(e);if(ws(e))return n;if(!ze(e)){let o=_n(e);for(;o&&!un(o);){if(De(o)&&!Lo(o))return o;o=_n(o)}return n}let r=Ka(e,t);for(;r&&Ld(r)&&Lo(r);)r=Ka(r,t);return r&&un(r)&&Lo(r)&&!Gi(r)?n:r||Wd(e)||n}const Qm=async function(e){const t=this.getOffsetParent||zl,n=this.getDimensions,r=await n(e.floating);return{reference:Jm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Zm(e){return pt(e).direction==="rtl"}const eg={convertOffsetParentRelativeRectToViewportRelativeRect:Hm,getDocumentElement:Ft,getClippingRect:Km,getOffsetParent:zl,getElementRects:Qm,getClientRects:Um,getDimensions:Xm,getScale:Rn,isElement:De,isRTL:Zm};function ql(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function tg(e,t){let n=null,r;const o=Ft(e);function s(){var i;clearTimeout(r),(i=n)==null||i.disconnect(),n=null}function a(i,l){i===void 0&&(i=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:u,top:f,width:m,height:p}=c;if(i||t(),!m||!p)return;const g=Tr(f),y=Tr(o.clientWidth-(u+m)),b=Tr(o.clientHeight-(f+p)),v=Tr(u),w={rootMargin:-g+"px "+-y+"px "+-b+"px "+-v+"px",threshold:tt(0,Pn(1,l))||1};let k=!0;function C(S){const T=S[0].intersectionRatio;if(T!==l){if(!k)return a();T?a(!1,T):r=setTimeout(()=>{a(!1,1e-7)},1e3)}T===1&&!ql(c,e.getBoundingClientRect())&&a(),k=!1}try{n=new IntersectionObserver(C,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,w)}n.observe(e)}return a(!0),s}function Xa(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=_s(e),u=o||s?[...c?Nn(c):[],...t?Nn(t):[]]:[];u.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const f=c&&i?tg(c,n):null;let m=-1,p=null;a&&(p=new ResizeObserver(v=>{let[x]=v;x&&x.target===c&&p&&t&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var w;(w=p)==null||w.observe(t)})),n()}),c&&!l&&p.observe(c),t&&p.observe(t));let g,y=l?mn(e):null;l&&b();function b(){const v=mn(e);y&&!ql(y,v)&&n(),y=v,g=requestAnimationFrame(b)}return n(),()=>{var v;u.forEach(x=>{o&&x.removeEventListener("scroll",n),s&&x.removeEventListener("resize",n)}),f?.(),(v=p)==null||v.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const ng=Fm,rg=Lm,og=Am,sg=Bm,ag=Pm,ig=Wm,lg=(e,t,n)=>{const r=new Map,o={platform:eg,...n},s={...o.platform,_c:r};return _m(e,t,{...o,platform:s})};var cg=typeof document<"u",ug=function(){},Ar=cg?h.useLayoutEffect:ug;function zr(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,o;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(!zr(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!zr(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Gl(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ja(e,t){const n=Gl(e);return Math.round(t*n)/n}function Wo(e){const t=h.useRef(e);return Ar(()=>{t.current=e}),t}function dg(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:a}={},transform:i=!0,whileElementsMounted:l,open:c}=e,[u,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=h.useState(r);zr(m,r)||p(r);const[g,y]=h.useState(null),[b,v]=h.useState(null),x=h.useCallback(O=>{O!==S.current&&(S.current=O,y(O))},[]),w=h.useCallback(O=>{O!==T.current&&(T.current=O,v(O))},[]),k=s||g,C=a||b,S=h.useRef(null),T=h.useRef(null),M=h.useRef(u),A=l!=null,R=Wo(l),D=Wo(o),_=Wo(c),E=h.useCallback(()=>{if(!S.current||!T.current)return;const O={placement:t,strategy:n,middleware:m};D.current&&(O.platform=D.current),lg(S.current,T.current,O).then(F=>{const V={...F,isPositioned:_.current!==!1};I.current&&!zr(M.current,V)&&(M.current=V,Gt.flushSync(()=>{f(V)}))})},[m,t,n,D,_]);Ar(()=>{c===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,f(O=>({...O,isPositioned:!1})))},[c]);const I=h.useRef(!1);Ar(()=>(I.current=!0,()=>{I.current=!1}),[]),Ar(()=>{if(k&&(S.current=k),C&&(T.current=C),k&&C){if(R.current)return R.current(k,C,E);E()}},[k,C,E,R,A]);const j=h.useMemo(()=>({reference:S,floating:T,setReference:x,setFloating:w}),[x,w]),B=h.useMemo(()=>({reference:k,floating:C}),[k,C]),H=h.useMemo(()=>{const O={position:n,left:0,top:0};if(!B.floating)return O;const F=Ja(B.floating,u.x),V=Ja(B.floating,u.y);return i?{...O,transform:"translate("+F+"px, "+V+"px)",...Gl(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:V}},[n,i,B.floating,u.x,u.y]);return h.useMemo(()=>({...u,update:E,refs:j,elements:B,floatingStyles:H}),[u,E,j,B,H])}const fg=(e,t)=>{const n=ng(e);return{name:n.name,fn:n.fn,options:[e,t]}},hg=(e,t)=>{const n=rg(e);return{name:n.name,fn:n.fn,options:[e,t]}},mg=(e,t)=>({fn:ig(e).fn,options:[e,t]}),gg=(e,t)=>{const n=og(e);return{name:n.name,fn:n.fn,options:[e,t]}},pg=(e,t)=>{const n=sg(e);return{name:n.name,fn:n.fn,options:[e,t]}},yg=(e,t)=>{const n=ag(e);return{name:n.name,fn:n.fn,options:[e,t]}},bg={intentional:"onClick",sloppy:"onPointerDown"};function xg(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function Kl(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),o=n.useState("floatingElement"),s=n.useState("referenceElement"),a=n.useState("domReferenceElement"),{onOpenChange:i,dataRef:l}=n.context,{enabled:c=!0,escapeKey:u=!0,outsidePress:f=!0,outsidePressEvent:m="sloppy",referencePress:p=!1,referencePressEvent:g="sloppy",ancestorScroll:y=!1,bubbles:b,externalTree:v}=t,x=Hn(v),w=me(typeof f=="function"?f:()=>!1),k=typeof f=="function"?w:f,C=h.useRef(!1),{escapeKey:S,outsidePress:T}=xg(b),M=h.useRef(null),A=hn(),R=hn(),D=me(()=>{R.clear(),l.current.insideReactTree=!1}),_=h.useRef(!1),E=h.useRef(""),I=me(P=>{E.current=P.pointerType}),j=me(()=>{const P=E.current,le=P==="pen"||!P?"mouse":P,X=typeof m=="function"?m():m;return typeof X=="string"?X:X[le]}),B=me(P=>{if(!r||!c||!u||P.key!=="Escape"||_.current)return;const le=l.current.floatingContext?.nodeId,X=x?dn(x.nodesRef.current,le):[];if(!S&&X.length>0){let z=!0;if(X.forEach(Z=>{Z.context?.open&&!Z.context.dataRef.current.__escapeKeyBubbles&&(z=!1)}),!z)return}const ye=Fh(P)?P.nativeEvent:P,Y=je(Al,ye);n.setOpen(!1,Y),!S&&!Y.isPropagationAllowed&&P.stopPropagation()}),H=me(P=>{const le=j();return le==="intentional"&&P.type!=="click"||le==="sloppy"&&P.type==="click"}),O=me(()=>{l.current.insideReactTree=!0,R.start(0,D)}),F=me((P,le=!1)=>{if(H(P)){D();return}if(l.current.insideReactTree){D();return}if(j()==="intentional"&&le||typeof k=="function"&&!k(P))return;const X=et(P),ye=`[${rr("inert")}]`,Y=$e(n.select("floatingElement")).querySelectorAll(ye),z=n.context.triggerElements;if(X&&(z.hasElement(X)||z.hasMatchingElement(re=>ke(re,X))))return;let Z=De(X)?X:null;for(;Z&&!un(Z);){const re=_n(Z);if(un(re)||!De(re))break;Z=re}if(Y.length&&De(X)&&!Ph(X)&&!ke(X,n.select("floatingElement"))&&Array.from(Y).every(re=>!ke(Z,re)))return;if(ze(X)&&!("touches"in P)){const re=un(X),we=pt(X),Se=/auto|scroll/,Ae=re||Se.test(we.overflowX),Xe=re||Se.test(we.overflowY),ot=Ae&&X.clientWidth>0&&X.scrollWidth>X.clientWidth,He=Xe&&X.clientHeight>0&&X.scrollHeight>X.clientHeight,ce=we.direction==="rtl",Ye=He&&(ce?P.offsetX<=X.offsetWidth-X.clientWidth:P.offsetX>X.clientWidth),Oe=ot&&P.offsetY>X.clientHeight;if(Ye||Oe)return}const fe=l.current.floatingContext?.nodeId,ge=x&&dn(x.nodesRef.current,fe).some(re=>ft(P,re.context?.elements.floating));if(ft(P,n.select("floatingElement"))||ft(P,n.select("domReferenceElement"))||ge)return;const ae=x?dn(x.nodesRef.current,fe):[];if(ae.length>0){let re=!0;if(ae.forEach(we=>{we.context?.open&&!we.context.dataRef.current.__outsidePressBubbles&&(re=!1)}),!re)return}n.setOpen(!1,je(_l,P)),D()}),V=me(P=>{j()!=="sloppy"||P.pointerType==="touch"||!n.select("open")||!c||ft(P,n.select("floatingElement"))||ft(P,n.select("domReferenceElement"))||F(P)}),$=me(P=>{if(j()!=="sloppy"||!n.select("open")||!c||ft(P,n.select("floatingElement"))||ft(P,n.select("domReferenceElement")))return;const le=P.touches[0];le&&(M.current={startTime:Date.now(),startX:le.clientX,startY:le.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},A.start(1e3,()=>{M.current&&(M.current.dismissOnTouchEnd=!1,M.current.dismissOnMouseDown=!1)}))}),Q=me(P=>{const le=et(P);function X(){$(P),le?.removeEventListener(P.type,X)}le?.addEventListener(P.type,X)}),U=me(P=>{const le=C.current;if(C.current=!1,A.clear(),P.type==="mousedown"&&M.current&&!M.current.dismissOnMouseDown)return;const X=et(P);function ye(){P.type==="pointerdown"?V(P):F(P,le),X?.removeEventListener(P.type,ye)}X?.addEventListener(P.type,ye)}),W=me(P=>{if(j()!=="sloppy"||!M.current||ft(P,n.select("floatingElement"))||ft(P,n.select("domReferenceElement")))return;const le=P.touches[0];if(!le)return;const X=Math.abs(le.clientX-M.current.startX),ye=Math.abs(le.clientY-M.current.startY),Y=Math.sqrt(X*X+ye*ye);Y>5&&(M.current.dismissOnTouchEnd=!0),Y>10&&(F(P),A.clear(),M.current=null)}),K=me(P=>{const le=et(P);function X(){W(P),le?.removeEventListener(P.type,X)}le?.addEventListener(P.type,X)}),G=me(P=>{j()!=="sloppy"||!M.current||ft(P,n.select("floatingElement"))||ft(P,n.select("domReferenceElement"))||(M.current.dismissOnTouchEnd&&F(P),A.clear(),M.current=null)}),te=me(P=>{const le=et(P);function X(){G(P),le?.removeEventListener(P.type,X)}le?.addEventListener(P.type,X)});h.useEffect(()=>{if(!r||!c)return;l.current.__escapeKeyBubbles=S,l.current.__outsidePressBubbles=T;const P=new Kt;function le(Z){n.setOpen(!1,je(xm,Z))}function X(){P.clear(),_.current=!0}function ye(){P.start(xs()?5:0,()=>{_.current=!1})}const Y=$e(o);Y.addEventListener("pointerdown",I,!0),u&&(Y.addEventListener("keydown",B),Y.addEventListener("compositionstart",X),Y.addEventListener("compositionend",ye)),k&&(Y.addEventListener("click",U,!0),Y.addEventListener("pointerdown",U,!0),Y.addEventListener("touchstart",Q,!0),Y.addEventListener("touchmove",K,!0),Y.addEventListener("touchend",te,!0),Y.addEventListener("mousedown",U,!0));let z=[];return y&&(De(a)&&(z=Nn(a)),De(o)&&(z=z.concat(Nn(o))),!De(s)&&s&&s.contextElement&&(z=z.concat(Nn(s.contextElement)))),z=z.filter(Z=>Z!==Y.defaultView?.visualViewport),z.forEach(Z=>{Z.addEventListener("scroll",le,{passive:!0})}),()=>{Y.removeEventListener("pointerdown",I,!0),u&&(Y.removeEventListener("keydown",B),Y.removeEventListener("compositionstart",X),Y.removeEventListener("compositionend",ye)),k&&(Y.removeEventListener("click",U,!0),Y.removeEventListener("pointerdown",U,!0),Y.removeEventListener("touchstart",Q,!0),Y.removeEventListener("touchmove",K,!0),Y.removeEventListener("touchend",te,!0),Y.removeEventListener("mousedown",U,!0)),z.forEach(Z=>{Z.removeEventListener("scroll",le)}),P.clear(),C.current=!1}},[l,o,s,a,u,k,r,i,y,c,S,T,B,F,U,V,Q,K,te,I,n]),h.useEffect(D,[k,D]);const xe=h.useMemo(()=>({onKeyDown:B,...p&&{[bg[g]]:P=>{n.setOpen(!1,je(qt,P.nativeEvent))},...g!=="intentional"&&{onClick(P){n.setOpen(!1,je(qt,P.nativeEvent))}}}}),[B,n,p,g]),Ee=me(P=>{const le=et(P.nativeEvent);!ke(n.select("floatingElement"),le)||P.button!==0||(C.current=!0)}),be=me(P=>{!r||!c||P.button!==0||(C.current=!0)}),_e=h.useMemo(()=>({onKeyDown:B,onPointerDown:Ee,onMouseDown:Ee,onMouseUp:Ee,onClickCapture:O,onMouseDownCapture(P){O(),be(P)},onPointerDownCapture(P){O(),be(P)},onMouseUpCapture:O,onTouchEndCapture:O,onTouchMoveCapture:O}),[B,Ee,O,be]);return h.useMemo(()=>c?{reference:xe,floating:_e,trigger:xe}:{},[c,xe,_e])}const wg={open:pe(e=>e.open),domReferenceElement:pe(e=>e.domReferenceElement),referenceElement:pe(e=>e.positionReference??e.referenceElement),floatingElement:pe(e=>e.floatingElement),floatingId:pe(e=>e.floatingId)};class As extends Ms{constructor(t){const{nested:n,noEmit:r,onOpenChange:o,triggerElements:s,...a}=t;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:o,dataRef:{current:{}},events:Ol(),nested:n,noEmit:r,triggerElements:s},wg)}setOpen=(t,n)=>{if((!t||!this.state.open||bl(n.event))&&(this.context.dataRef.current.openEvent=t?n.event:void 0),!this.context.noEmit){const r={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",r)}this.context.onOpenChange?.(t,n)}}function vg(e,t=!1,n=!1){const[r,o]=h.useState(e&&t?"idle":void 0),[s,a]=h.useState(e);return e&&!s&&(a(!0),o("starting")),!e&&s&&r!=="ending"&&!n&&o("ending"),!e&&!s&&r==="ending"&&o(void 0),Ce(()=>{if(!e&&s&&r!=="ending"&&n){const i=vt.request(()=>{o("ending")});return()=>{vt.cancel(i)}}},[e,s,r,n]),Ce(()=>{if(!e||t)return;const i=vt.request(()=>{o(void 0)});return()=>{vt.cancel(i)}},[t,e]),Ce(()=>{if(!e||!t)return;e&&s&&r!=="idle"&&o("starting");const i=vt.request(()=>{o("idle")});return()=>{vt.cancel(i)}},[t,e,s,o,r]),h.useMemo(()=>({mounted:s,setMounted:a,transitionStatus:r}),[s,r])}let or=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const kg={[or.startingStyle]:""},Sg={[or.endingStyle]:""},eo={transitionStatus(e){return e==="starting"?kg:e==="ending"?Sg:null}};function Xl(e,t=!1,n=!0){const r=Es();return me((o,s=null)=>{r.cancel();function a(){Gt.flushSync(o)}const i=jt(e);if(i==null)return;const l=i;if(typeof l.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)o();else{let c=function(){const f=or.startingStyle;if(!l.hasAttribute(f)){r.request(u);return}const m=new MutationObserver(()=>{l.hasAttribute(f)||(m.disconnect(),u())});m.observe(l,{attributes:!0,attributeFilter:[f]}),s?.addEventListener("abort",()=>m.disconnect(),{once:!0})},u=function(){Promise.all(l.getAnimations().map(f=>f.finished)).then(()=>{s?.aborted||a()}).catch(()=>{const f=l.getAnimations();if(n){if(s?.aborted)return;a()}else f.length>0&&f.some(m=>m.pending||m.playState!=="finished")&&u()})};if(t){c();return}r.request(u)}})}function Ps(e){const{enabled:t=!0,open:n,ref:r,onComplete:o}=e,s=me(o),a=Xl(r,n,!1);h.useEffect(()=>{if(!t)return;const i=new AbortController;return a(s,i.signal),()=>{i.abort()}},[t,n,s,a])}function Cg(e,t){const n=h.useRef(null),r=h.useRef(null);return h.useCallback(o=>{if(e!==void 0){if(n.current!==null){const s=n.current,a=r.current,i=t.context.triggerElements.getById(s);a&&i===a&&t.context.triggerElements.delete(s),n.current=null,r.current=null}o!==null&&(n.current=e,r.current=o,t.context.triggerElements.add(e,o))}},[t,e])}function Mg(e,t,n,r){const o=n.useState("isMountedByTrigger",e),s=Cg(e,n),a=me(i=>{if(s(i),!i||!n.select("open"))return;const l=n.select("activeTriggerId");if(l===e){n.update({activeTriggerElement:i,...r});return}l==null&&n.update({activeTriggerId:e,activeTriggerElement:i,...r})});return Ce(()=>{o&&n.update({activeTriggerElement:t.current,...r})},[o,n,t,...Object.values(r)]),{registerTrigger:a,isMountedByThisTrigger:o}}function Jl(e){const t=e.useState("open");Ce(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[r,o]=n.value;e.update({activeTriggerId:r,activeTriggerElement:o})}}},[t,e])}function Ql(e,t,n){const{mounted:r,setMounted:o,transitionStatus:s}=vg(e);t.useSyncedValues({mounted:r,transitionStatus:s});const a=me(()=>{o(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),i=t.useState("preventUnmountingOnClose");return Ps({enabled:!i,open:e,ref:t.context.popupRef,onComplete(){e||a()}}),{forceUnmount:a,transitionStatus:s}}class to{constructor(){this.elements=new Set,this.idMap=new Map}add(t,n){const r=this.idMap.get(t);r!==n&&(r!==void 0&&this.elements.delete(r),this.elements.add(n),this.idMap.set(t,n))}delete(t){const n=this.idMap.get(t);n&&(this.elements.delete(n),this.idMap.delete(t))}hasElement(t){return this.elements.has(t)}hasMatchingElement(t){for(const n of this.elements)if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}get size(){return this.idMap.size}}function Tg(){return new As({open:!1,floatingElement:null,referenceElement:null,triggerElements:new to,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function Zl(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:Tg(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:zt,inactiveTriggerProps:zt,popupProps:zt}}const ec={open:pe(e=>e.open),mounted:pe(e=>e.mounted),transitionStatus:pe(e=>e.transitionStatus),floatingRootContext:pe(e=>e.floatingRootContext),preventUnmountingOnClose:pe(e=>e.preventUnmountingOnClose),payload:pe(e=>e.payload),activeTriggerId:pe(e=>e.activeTriggerId),activeTriggerElement:pe(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:pe((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:pe((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:pe((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:pe((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:pe(e=>e.popupProps),popupElement:pe(e=>e.popupElement),positionerElement:pe(e=>e.positionerElement)};function Eg(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,o=Yn(),s=yn()!=null,a=Xt(()=>new As({open:t,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:r.triggers??new to,floatingId:o,nested:s,noEmit:e.noEmit||!1})).current;return Ce(()=>{const i={open:t,floatingId:o};r.reference!==void 0&&(i.referenceElement=r.reference,i.domReferenceElement=De(r.reference)?r.reference:null),r.floating!==void 0&&(i.floatingElement=r.floating),a.update(i)},[t,o,r.reference,r.floating,a]),a.context.onOpenChange=n,a.context.nested=s,a.context.noEmit=e.noEmit||!1,a}function Ng(e={}){const{nodeId:t,externalTree:n}=e,r=Eg(e),o=e.rootContext||r,s={reference:o.useState("referenceElement"),floating:o.useState("floatingElement"),domReference:o.useState("domReferenceElement")},[a,i]=h.useState(null),l=h.useRef(null),c=Hn(n);Ce(()=>{s.domReference&&(l.current=s.domReference)},[s.domReference]);const u=dg({...e,elements:{...s,...a&&{reference:a}}}),f=h.useCallback(T=>{const M=De(T)?{getBoundingClientRect:()=>T.getBoundingClientRect(),getClientRects:()=>T.getClientRects(),contextElement:T}:T;i(M),u.refs.setReference(M)},[u.refs]),[m,p]=h.useState(null),[g,y]=h.useState(null);o.useSyncedValue("referenceElement",m),o.useSyncedValue("domReferenceElement",De(m)?m:null),o.useSyncedValue("floatingElement",g);const b=h.useCallback(T=>{(De(T)||T===null)&&(l.current=T,p(T)),(De(u.refs.reference.current)||u.refs.reference.current===null||T!==null&&!De(T))&&u.refs.setReference(T)},[u.refs,p]),v=h.useCallback(T=>{y(T),u.refs.setFloating(T)},[u.refs]),x=h.useMemo(()=>({...u.refs,setReference:b,setFloating:v,setPositionReference:f,domReference:l}),[u.refs,b,v,f]),w=h.useMemo(()=>({...u.elements,domReference:s.domReference}),[u.elements,s.domReference]),k=o.useState("open"),C=o.useState("floatingId"),S=h.useMemo(()=>({...u,dataRef:o.context.dataRef,open:k,onOpenChange:o.setOpen,events:o.context.events,floatingId:C,refs:x,elements:w,nodeId:t,rootStore:o}),[u,x,w,t,o,k,C]);return Ce(()=>{o.context.dataRef.current.floatingContext=S;const T=c?.nodesRef.current.find(M=>M.id===t);T&&(T.context=S)}),h.useMemo(()=>({...u,context:S,refs:x,elements:w,rootStore:o}),[u,x,w,S,o])}function tc(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:r=!1,onOpenChange:o}=e,s=Yn(),a=yn()!=null,i=t.useState("open"),l=t.useState("activeTriggerElement"),c=t.useState(r?"popupElement":"positionerElement"),u=t.context.triggerElements,f=Xt(()=>new As({open:i,referenceElement:l,floatingElement:c,triggerElements:u,onOpenChange:o,floatingId:s,nested:a,noEmit:n})).current;return Ce(()=>{const m={open:i,floatingId:s,referenceElement:l,floatingElement:c};De(l)&&(m.domReferenceElement=l),f.state.positionReference===f.state.referenceElement&&(m.positionReference=l),f.update(m)},[i,s,l,c,f]),f.context.onOpenChange=o,f.context.nested=a,f.context.noEmit=n,f}const us=rr("safe-polygon"),Dg=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${pl}`;function Og(e){return e?!!e.closest(Dg):!1}function nc(e){const t=h.useRef(void 0),n=h.useRef(!1),r=h.useRef(void 0),o=h.useRef(!0),s=h.useRef(!1),a=h.useRef(()=>{}),i=h.useRef(!1),l=hn(),c=hn(),u=h.useRef(void 0);return h.useMemo(()=>{const f=e.context.dataRef.current;return f.hoverInteractionState||(f.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:r,blockMouseMoveRef:o,performedPointerEventsMutationRef:s,unbindMouseMoveRef:a,restTimeoutPendingRef:i,openChangeTimeout:l,restTimeout:c,handleCloseOptionsRef:u}),f.hoverInteractionState},[e,t,n,r,o,s,a,i,l,c,u])}const Rg=new Set(["click","mousedown"]);function jg(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),o=n.useState("floatingElement"),s=n.useState("domReferenceElement"),{dataRef:a}=n.context,{enabled:i=!0,closeDelay:l=0,externalTree:c}=t,{pointerTypeRef:u,interactedInsideRef:f,handlerRef:m,performedPointerEventsMutationRef:p,unbindMouseMoveRef:g,restTimeoutPendingRef:y,openChangeTimeout:b,handleCloseOptionsRef:v}=nc(n),x=Hn(c),w=yn(),k=me(()=>f.current?!0:a.current.openEvent?Rg.has(a.current.openEvent.type):!1),C=me(()=>{const R=a.current.openEvent?.type;return R?.includes("mouse")&&R!=="mousedown"}),S=h.useCallback((R,D=!0)=>{const _=_g(l,u.current);_&&!m.current?b.start(_,()=>n.setOpen(!1,je(nt,R))):D&&(b.clear(),n.setOpen(!1,je(nt,R)))},[l,m,n,u,b]),T=me(()=>{g.current(),m.current=void 0}),M=me(()=>{if(p.current){const R=$e(o).body;R.style.pointerEvents="",R.removeAttribute(us),p.current=!1}}),A=me(R=>{const D=et(R);if(!Og(D)){f.current=!1;return}f.current=!0});Ce(()=>{r||(u.current=void 0,y.current=!1,f.current=!1,T(),M())},[r,u,y,f,T,M]),h.useEffect(()=>()=>{T()},[T]),h.useEffect(()=>M,[M]),Ce(()=>{if(i&&r&&v.current?.blockPointerEvents&&C()&&De(s)&&o){p.current=!0;const R=$e(o).body;R.setAttribute(us,"");const D=s,_=o,E=x?.nodesRef.current.find(I=>I.id===w)?.context?.elements.floating;return E&&(E.style.pointerEvents=""),R.style.pointerEvents="none",D.style.pointerEvents="auto",_.style.pointerEvents="auto",()=>{R.style.pointerEvents="",D.style.pointerEvents="",_.style.pointerEvents=""}}},[i,r,s,o,v,C,x,w,p]),h.useEffect(()=>{if(!i)return;function R(I){if(k()||!a.current.floatingContext||!n.select("open"))return;const j=n.context.triggerElements;I.relatedTarget&&j.hasElement(I.relatedTarget)||(M(),T(),k()||S(I))}function D(I){b.clear(),M(),m.current?.(I),T()}function _(I){k()||S(I,!1)}const E=o;return E&&(E.addEventListener("mouseleave",R),E.addEventListener("mouseenter",D),E.addEventListener("mouseleave",_),E.addEventListener("pointerdown",A,!0)),()=>{E&&(E.removeEventListener("mouseleave",R),E.removeEventListener("mouseenter",D),E.removeEventListener("mouseleave",_),E.removeEventListener("pointerdown",A,!0))}})}function _g(e,t){return t&&!An(t)?0:typeof e=="function"?e():e}function Bo(e){return typeof e=="function"?e():e}const Ag={current:null};function Pg(e,t={}){const n="rootStore"in e?e.rootStore:e,{dataRef:r,events:o}=n.context,{enabled:s=!0,delay:a=0,handleClose:i=null,mouseOnly:l=!1,restMs:c=0,move:u=!0,triggerElementRef:f=Ag,externalTree:m,isActiveTrigger:p=!0}=t,g=Hn(m),{pointerTypeRef:y,interactedInsideRef:b,handlerRef:v,blockMouseMoveRef:x,performedPointerEventsMutationRef:w,unbindMouseMoveRef:k,restTimeoutPendingRef:C,openChangeTimeout:S,restTimeout:T,handleCloseOptionsRef:M}=nc(n),A=kt(i),R=kt(a),D=kt(c);p&&(M.current=A.current?.__options);const _=me(()=>b.current?!0:r.current.openEvent?["click","mousedown"].includes(r.current.openEvent.type):!1),E=h.useCallback((H,O=!0)=>{const F=Ao(R.current,"close",y.current);F&&!v.current?S.start(F,()=>n.setOpen(!1,je(nt,H))):O&&(S.clear(),n.setOpen(!1,je(nt,H)))},[R,v,n,y,S]),I=me(()=>{k.current(),v.current=void 0}),j=me(()=>{if(w.current){const H=$e(n.select("domReferenceElement")).body;H.style.pointerEvents="",H.removeAttribute(us),w.current=!1}});h.useEffect(()=>{if(!s)return;function H(O){O.open||(S.clear(),T.clear(),x.current=!0,C.current=!1)}return o.on("openchange",H),()=>{o.off("openchange",H)}},[s,o,S,T,x,C]);const B=me(H=>{if(_()||!r.current.floatingContext)return;const O=n.context.triggerElements;if(H.relatedTarget&&O.hasElement(H.relatedTarget))return;const F=f.current;A.current?.({...r.current.floatingContext,tree:g,x:H.clientX,y:H.clientY,onClose(){j(),I(),!_()&&F===n.select("domReferenceElement")&&E(H)}})(H)});return h.useEffect(()=>{if(!s)return;const H=f.current??(p?n.select("domReferenceElement"):null);if(!De(H))return;function O($){if(S.clear(),x.current=!1,l&&!An(y.current)||Bo(D.current)>0&&!Ao(R.current,"open"))return;const Q=Ao(R.current,"open",y.current),U=n.select("domReferenceElement"),W=n.context.triggerElements,K=(W.hasElement($.target)||W.hasMatchingElement(Ee=>ke(Ee,$.target)))&&(!U||!ke(U,$.target)),G=$.currentTarget??null,te=n.select("open"),xe=!te||K;K&&te?n.setOpen(!0,je(nt,$,G)):Q?S.start(Q,()=>{xe&&n.setOpen(!0,je(nt,$,G))}):xe&&n.setOpen(!0,je(nt,$,G))}function F($){if(_()){j();return}k.current();const Q=n.select("domReferenceElement"),U=$e(Q);T.clear(),C.current=!1;const W=n.context.triggerElements;if($.relatedTarget&&W.hasElement($.relatedTarget))return;if(A.current&&r.current.floatingContext){n.select("open")||S.clear();const G=f.current;v.current=A.current({...r.current.floatingContext,tree:g,x:$.clientX,y:$.clientY,onClose(){j(),I(),!_()&&G===n.select("domReferenceElement")&&E($,!0)}});const te=v.current;te($),U.addEventListener("mousemove",te),k.current=()=>{U.removeEventListener("mousemove",te)};return}(y.current!=="touch"||!ke(n.select("floatingElement"),$.relatedTarget))&&E($)}function V($){B($)}return n.select("open")&&H.addEventListener("mouseleave",V),u&&H.addEventListener("mousemove",O,{once:!0}),H.addEventListener("mouseenter",O),H.addEventListener("mouseleave",F),()=>{H.removeEventListener("mouseleave",V),u&&H.removeEventListener("mousemove",O),H.removeEventListener("mouseenter",O),H.removeEventListener("mouseleave",F)}},[I,j,x,r,R,E,n,s,A,B,p,_,l,u,y,D,T,C,S,f,g,k,v]),h.useMemo(()=>{function H(O){y.current=O.pointerType}return{onPointerDown:H,onPointerEnter:H,onMouseMove(O){const{nativeEvent:F}=O,V=O.currentTarget,$=n.select("domReferenceElement"),Q=n.context.triggerElements,U=n.select("open"),W=(Q.hasElement(O.target)||Q.hasMatchingElement(G=>ke(G,O.target)))&&(!$||!ke($,O.target));if(l&&!An(y.current)||U&&!W||Bo(D.current)===0||!W&&C.current&&O.movementX**2+O.movementY**2<2)return;T.clear();function K(){if(C.current=!1,_())return;const G=n.select("open");!x.current&&(!G||W)&&n.setOpen(!0,je(nt,F,V))}y.current==="touch"?Gt.flushSync(()=>{K()}):W&&U?K():(C.current=!0,T.start(Bo(D.current),K))}}},[x,_,l,n,y,D,T,C])}function Is(e=[]){const t=e.map(c=>c?.reference),n=e.map(c=>c?.floating),r=e.map(c=>c?.item),o=e.map(c=>c?.trigger),s=h.useCallback(c=>Dr(c,e,"reference"),t),a=h.useCallback(c=>Dr(c,e,"floating"),n),i=h.useCallback(c=>Dr(c,e,"item"),r),l=h.useCallback(c=>Dr(c,e,"trigger"),o);return h.useMemo(()=>({getReferenceProps:s,getFloatingProps:a,getItemProps:i,getTriggerProps:l}),[s,a,i,l])}function Dr(e,t,n){const r=new Map,o=n==="item",s={};n==="floating"&&(s.tabIndex=-1,s[os]="");for(const a in e)o&&e&&(a===ml||a===gl)||(s[a]=e[a]);for(let a=0;a<t.length;a+=1){let i;const l=t[a]?.[n];typeof l=="function"?i=e?l(e):null:i=l,i&&Qa(s,i,o,r)}return Qa(s,e,o,r),s}function Qa(e,t,n,r){for(const o in t){const s=t[o];n&&(o===ml||o===gl)||(o.startsWith("on")?(r.has(o)||r.set(o,[]),typeof s=="function"&&(r.get(o)?.push(s),e[o]=(...a)=>r.get(o)?.map(i=>i(...a)).find(i=>i!==void 0))):e[o]=s)}}const Ig=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function rc(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),o=n.useState("floatingId"),s=n.useState("domReferenceElement"),a=n.useState("floatingElement"),{enabled:i=!0,role:l="dialog"}=t,c=Yn(),u=s?.id||c,f=h.useMemo(()=>ss(a)?.id||o,[a,o]),m=Ig.get(l)??l,g=yn()!=null,y=h.useMemo(()=>m==="tooltip"||l==="label"?zt:{"aria-haspopup":m==="alertdialog"?"dialog":m,"aria-expanded":"false",...m==="listbox"&&{role:"combobox"},...m==="menu"&&g&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[m,g,l]),b=h.useMemo(()=>m==="tooltip"||l==="label"?{[`aria-${l==="label"?"labelledby":"describedby"}`]:r?f:void 0}:{...y,"aria-expanded":r?"true":"false","aria-controls":r?f:void 0,...m==="menu"&&{id:u}},[m,f,r,u,l,y]),v=h.useMemo(()=>{const w={id:f,...m&&{role:m}};return m==="tooltip"||l==="label"?w:{...w,...m==="menu"&&{"aria-labelledby":u}}},[m,f,u,l]),x=h.useCallback(({active:w,selected:k})=>{const C={role:"option",...w&&{id:`${f}-fui-option`}};switch(l){case"select":case"combobox":return{...C,"aria-selected":k}}return{}},[f,l]);return h.useMemo(()=>i?{reference:b,floating:v,item:x,trigger:y}:{},[i,b,v,y,x])}function Za(e,t){const[n,r]=e;let o=!1;const s=t.length;for(let a=0,i=s-1;a<s;i=a++){const[l,c]=t[a]||[0,0],[u,f]=t[i]||[0,0];c>=r!=f>=r&&n<=(u-l)*(r-c)/(f-c)+l&&(o=!o)}return o}function Fg(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function Lg(e={}){const{buffer:t=.5,blockPointerEvents:n=!1,requireIntent:r=!0}=e,o=new Kt;let s=!1,a=null,i=null,l=typeof performance<"u"?performance.now():0;function c(f,m){const p=performance.now(),g=p-l;if(a===null||i===null||g===0)return a=f,i=m,l=p,null;const y=f-a,b=m-i,x=Math.sqrt(y*y+b*b)/g;return a=f,i=m,l=p,x}const u=({x:f,y:m,placement:p,elements:g,onClose:y,nodeId:b,tree:v})=>function(w){function k(){o.clear(),y()}if(o.clear(),!g.domReference||!g.floating||p==null||f==null||m==null)return;const{clientX:C,clientY:S}=w,T=[C,S],M=et(w),A=w.type==="mouseleave",R=ke(g.floating,M),D=ke(g.domReference,M),_=g.domReference.getBoundingClientRect(),E=g.floating.getBoundingClientRect(),I=p.split("-")[0],j=f>E.right-E.width/2,B=m>E.bottom-E.height/2,H=Fg(T,_),O=E.width>_.width,F=E.height>_.height,V=(O?_:E).left,$=(O?_:E).right,Q=(F?_:E).top,U=(F?_:E).bottom;if(R&&(s=!0,!A))return;if(D&&(s=!1),D&&!A){s=!0;return}if(A&&De(w.relatedTarget)&&ke(g.floating,w.relatedTarget)||v&&dn(v.nodesRef.current,b).some(({context:G})=>G?.open))return;if(I==="top"&&m>=_.bottom-1||I==="bottom"&&m<=_.top+1||I==="left"&&f>=_.right-1||I==="right"&&f<=_.left+1)return k();let W=[];switch(I){case"top":W=[[V,_.top+1],[V,E.bottom-1],[$,E.bottom-1],[$,_.top+1]];break;case"bottom":W=[[V,E.top+1],[V,_.bottom-1],[$,_.bottom-1],[$,E.top+1]];break;case"left":W=[[E.right-1,U],[E.right-1,Q],[_.left+1,Q],[_.left+1,U]];break;case"right":W=[[_.right-1,U],[_.right-1,Q],[E.left+1,Q],[E.left+1,U]];break}function K([G,te]){switch(I){case"top":{const xe=[O?G+t/2:j?G+t*4:G-t*4,te+t+1],Ee=[O?G-t/2:j?G+t*4:G-t*4,te+t+1],be=[[E.left,j||O?E.bottom-t:E.top],[E.right,j?O?E.bottom-t:E.top:E.bottom-t]];return[xe,Ee,...be]}case"bottom":{const xe=[O?G+t/2:j?G+t*4:G-t*4,te-t],Ee=[O?G-t/2:j?G+t*4:G-t*4,te-t],be=[[E.left,j||O?E.top+t:E.bottom],[E.right,j?O?E.top+t:E.bottom:E.top+t]];return[xe,Ee,...be]}case"left":{const xe=[G+t+1,F?te+t/2:B?te+t*4:te-t*4],Ee=[G+t+1,F?te-t/2:B?te+t*4:te-t*4];return[...[[B||F?E.right-t:E.left,E.top],[B?F?E.right-t:E.left:E.right-t,E.bottom]],xe,Ee]}case"right":{const xe=[G-t,F?te+t/2:B?te+t*4:te-t*4],Ee=[G-t,F?te-t/2:B?te+t*4:te-t*4],be=[[B||F?E.left+t:E.right,E.top],[B?F?E.left+t:E.right:E.left+t,E.bottom]];return[xe,Ee,...be]}default:return[]}}if(!Za([C,S],W)){if(s&&!H)return k();if(!A&&r){const G=c(w.clientX,w.clientY);if(G!==null&&G<.1)return k()}Za([C,S],K([f,m]))?!s&&r&&o.start(40,k):k()}};return u.__options={blockPointerEvents:n},u}function oc(e){return Yn(e,"base-ui")}function Wg(e){const t=h.useRef(""),n=h.useCallback(o=>{o.defaultPrevented||(t.current=o.pointerType,e(o,o.pointerType))},[e]);return{onClick:h.useCallback(o=>{if(o.detail===0){e(o,"keyboard");return}"pointerType"in o&&e(o,o.pointerType),e(o,t.current),t.current=""},[e]),onPointerDown:n}}function sc(e){const[t,n]=h.useState(null),r=me((i,l)=>{e||n(l||(hl?"touch":""))}),o=h.useCallback(()=>{n(null)},[]),{onClick:s,onPointerDown:a}=Wg(r);return h.useMemo(()=>({openMethod:t,reset:o,triggerProps:{onClick:s,onPointerDown:a}}),[t,o,s,a])}let mt=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=or.startingStyle]="startingStyle",e[e.endingStyle=or.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),ds=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const Bg={[ds.popupOpen]:""},$g={[ds.popupOpen]:"",[ds.pressed]:""},Yg={[mt.open]:""},Hg={[mt.closed]:""},Ug={[mt.anchorHidden]:""},Vg={open(e){return e?Bg:null}},zg={open(e){return e?$g:null}},ur={open(e){return e?Yg:Hg},anchorHidden(e){return e?Ug:null}};function ac(e){return zi(19)?e:e?"true":void 0}let ei={},ti={},ni="";function qg(e){if(typeof document>"u")return!1;const t=bn(e);return lt(t).innerWidth-t.documentElement.clientWidth>0}function Gg(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const r=bn(e).documentElement,o={scrollbarGutter:r.style.scrollbarGutter,overflowY:r.style.overflowY};r.style.scrollbarGutter="stable",r.style.overflowY="scroll";const s=r.offsetWidth;r.style.overflowY="hidden";const a=r.offsetWidth;return Object.assign(r.style,o),s===a}function Kg(e){const t=bn(e),n=t.documentElement,r=t.body,o=lr(n)?n:r,s=o.style.overflow;return o.style.overflow="hidden",()=>{o.style.overflow=s}}function Xg(e){const t=bn(e),n=t.documentElement,r=t.body,o=lt(n);let s=0,a=0,i=!1;const l=vt.create();if(Dh&&(o.visualViewport?.scale??1)!==1)return()=>{};function c(){const m=o.getComputedStyle(n),p=o.getComputedStyle(r),b=(m.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";s=n.scrollTop,a=n.scrollLeft,ei={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},ni=n.style.scrollBehavior,ti={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const v=n.scrollHeight>n.clientHeight,x=n.scrollWidth>n.clientWidth,w=m.overflowY==="scroll"||p.overflowY==="scroll",k=m.overflowX==="scroll"||p.overflowX==="scroll",C=Math.max(0,o.innerWidth-r.clientWidth),S=Math.max(0,o.innerHeight-r.clientHeight),T=parseFloat(p.marginTop)+parseFloat(p.marginBottom),M=parseFloat(p.marginLeft)+parseFloat(p.marginRight),A=lr(n)?n:r;if(i=Gg(e),i){n.style.scrollbarGutter=b,A.style.overflowY="hidden",A.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:b,overflowY:"hidden",overflowX:"hidden"}),(v||w)&&(n.style.overflowY="scroll"),(x||k)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:T||S?`calc(100dvh - ${T+S}px)`:"100dvh",width:M||C?`calc(100vw - ${M+C}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=s,r.scrollLeft=a,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function u(){Object.assign(n.style,ei),Object.assign(r.style,ti),i||(n.scrollTop=s,n.scrollLeft=a,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=ni)}function f(){u(),l.request(c)}return c(),o.addEventListener("resize",f),()=>{l.cancel(),u(),typeof o.removeEventListener=="function"&&o.removeEventListener("resize",f)}}class Jg{lockCount=0;restore=null;timeoutLock=Kt.create();timeoutUnlock=Kt.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const r=bn(t).documentElement,o=lt(r).getComputedStyle(r).overflowY;if(o==="hidden"||o==="clip"){this.restore=qi;return}const s=hl||!qg(t);this.restore=s?Kg(t):Xg(t)}}const Qg=new Jg;function ic(e=!0,t=null){Ce(()=>{if(e)return Qg.acquire(t)},[e,t])}const Zg=h.createContext(void 0);function ep(){return h.useContext(Zg)?.direction??"ltr"}const tp=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:a,elements:i,middlewareData:l}=t,{element:c,padding:u=0,offsetParent:f="real"}=Pt(e,t)||{};if(c==null)return{};const m=xl(u),p={x:n,y:r},g=Os(o),y=Ds(g),b=await a.getDimensions(c),v=g==="y",x=v?"top":"left",w=v?"bottom":"right",k=v?"clientHeight":"clientWidth",C=s.reference[y]+s.reference[g]-p[g]-s.floating[y],S=p[g]-s.reference[g],T=f==="real"?await a.getOffsetParent?.(c):i.floating;let M=i.floating[k]||s.floating[y];(!M||!await a.isElement?.(T))&&(M=i.floating[k]||s.floating[y]);const A=C/2-S/2,R=M/2-b[y]/2-1,D=Math.min(m[x],R),_=Math.min(m[w],R),E=D,I=M-b[y]-_,j=M/2-b[y]/2+A,B=as(E,j,I),H=!l.arrow&&Jt(o)!=null&&j!==B&&s.reference[y]/2-(j<E?D:_)-b[y]/2<0,O=H?j<E?j-E:j-I:0;return{[g]:p[g]+O,data:{[g]:B,centerOffset:j-B-O,...H&&{alignmentOffset:O}},reset:H}}}),np=(e,t)=>({...tp(e),options:[e,t]}),rp={name:"hide",async fn(e){const{width:t,height:n,x:r,y:o}=e.rects.reference,s=t===0&&n===0&&r===0&&o===0;return{data:{referenceHidden:(await yg().fn(e)).data?.referenceHidden||s}}}},Pr={sideX:"left",sideY:"top"},op={name:"adaptiveOrigin",async fn(e){const{x:t,y:n,rects:{floating:r},elements:{floating:o},platform:s,strategy:a,placement:i}=e,l=lt(o),c=l.getComputedStyle(o);if(!(c.transitionDuration!=="0s"&&c.transitionDuration!==""))return{x:t,y:n,data:Pr};const f=await s.getOffsetParent?.(o);let m={width:0,height:0};if(a==="fixed"&&l?.visualViewport)m={width:l.visualViewport.width,height:l.visualViewport.height};else if(f===l){const x=bn(o);m={width:x.documentElement.clientWidth,height:x.documentElement.clientHeight}}else await s.isElement?.(f)&&(m=await s.getDimensions(f));const p=Ke(i);let g=t,y=n;p==="left"&&(g=m.width-(t+r.width)),p==="top"&&(y=m.height-(n+r.height));const b=p==="left"?"right":Pr.sideX,v=p==="top"?"bottom":Pr.sideY;return{x:g,y,data:{sideX:b,sideY:v}}}};function lc(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 ri(e,t,n){const{rects:r,placement:o}=e;return{side:lc(t,Ke(o),n),align:Jt(o)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function sp(e){const{anchor:t,positionMethod:n="absolute",side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,collisionBoundary:i,collisionPadding:l=5,sticky:c=!1,arrowPadding:u=5,disableAnchorTracking:f=!1,keepMounted:m=!1,floatingRootContext:p,mounted:g,collisionAvoidance:y,shiftCrossAxis:b=!1,nodeId:v,adaptiveOrigin:x,lazyFlip:w=!1,externalTree:k}=e,[C,S]=h.useState(null);!g&&C!==null&&S(null);const T=y.side||"flip",M=y.align||"flip",A=y.fallbackAxisSide||"end",R=typeof t=="function"?t:void 0,D=me(R),_=R?D:t,E=kt(t),j=ep()==="rtl",B=C||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":j?"left":"right","inline-start":j?"right":"left"}[r],H=s==="center"?B:`${B}-${s}`;let O=l;const F=1,V=r==="bottom"?F:0,$=r==="top"?F:0,Q=r==="right"?F:0,U=r==="left"?F:0;typeof O=="number"?O={top:O+V,right:O+U,bottom:O+$,left:O+Q}:O&&(O={top:(O.top||0)+V,right:(O.right||0)+U,bottom:(O.bottom||0)+$,left:(O.left||0)+Q});const W={boundary:i==="clipping-ancestors"?"clippingAncestors":i,padding:O},K=h.useRef(null),G=kt(o),te=kt(a),be=[fg(Te=>{const Fe=ri(Te,r,j),ee=typeof G.current=="function"?G.current(Fe):G.current,ue=typeof te.current=="function"?te.current(Fe):te.current;return{mainAxis:ee,crossAxis:ue,alignmentAxis:ue}},[typeof o!="function"?o:0,typeof a!="function"?a:0,j,r])],_e=M==="none"&&T!=="shift",P=!_e&&(c||b||T==="shift"),le=T==="none"?null:gg({...W,padding:{top:O.top+F,right:O.right+F,bottom:O.bottom+F,left:O.left+F},mainAxis:!b&&T==="flip",crossAxis:M==="flip"?"alignment":!1,fallbackAxisSideDirection:A}),X=_e?null:hg(Te=>{const Fe=bn(Te.elements.floating).documentElement;return{...W,rootBoundary:b?{x:0,y:0,width:Fe.clientWidth,height:Fe.clientHeight}:void 0,mainAxis:M!=="none",crossAxis:P,limiter:c||b?void 0:mg(ee=>{if(!K.current)return{};const{width:ue,height:J}=K.current.getBoundingClientRect(),ie=it(Ke(ee.placement)),Pe=ie==="y"?ue:J,he=ie==="y"?O.left+O.right:O.top+O.bottom;return{offset:Pe/2+he/2}})}},[W,c,b,O,M]);T==="shift"||M==="shift"||s==="center"?be.push(X,le):be.push(le,X),be.push(pg({...W,apply({elements:{floating:Te},rects:{reference:Fe},availableWidth:ee,availableHeight:ue}){Object.entries({"--available-width":`${ee}px`,"--available-height":`${ue}px`,"--anchor-width":`${Fe.width}px`,"--anchor-height":`${Fe.height}px`}).forEach(([J,ie])=>{Te.style.setProperty(J,ie)})}}),np(()=>({element:K.current||document.createElement("div"),padding:u,offsetParent:"floating"}),[u]),{name:"transformOrigin",fn(Te){const{elements:Fe,middlewareData:ee,placement:ue,rects:J,y:ie}=Te,Pe=Ke(ue),he=it(Pe),Nt=K.current,Qt=ee.arrow?.x||0,Bt=ee.arrow?.y||0,bt=Nt?.clientWidth||0,Ge=Nt?.clientHeight||0,Je=Qt+bt/2,st=Bt+Ge/2,oo=Math.abs(ee.shift?.y||0),gr=J.reference.height/2,$t=typeof o=="function"?o(ri(Te,r,j)):o,so=oo>$t,ao={top:`${Je}px calc(100% + ${$t}px)`,bottom:`${Je}px ${-$t}px`,left:`calc(100% + ${$t}px) ${st}px`,right:`${-$t}px ${st}px`}[Pe],io=`${Je}px ${J.reference.y+gr-ie}px`;return Fe.floating.style.setProperty("--transform-origin",P&&he==="y"&&so?io:ao),{}}},rp,x),Ce(()=>{!g&&p&&p.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[g,p]);const ye=h.useMemo(()=>({elementResize:!f&&typeof ResizeObserver<"u",layoutShift:!f&&typeof IntersectionObserver<"u"}),[f]),{refs:Y,elements:z,x:Z,y:fe,middlewareData:ge,update:ae,placement:re,context:we,isPositioned:Se,floatingStyles:Ae}=Ng({rootContext:p,placement:H,middleware:be,strategy:n,whileElementsMounted:m?void 0:(...Te)=>Xa(...Te,ye),nodeId:v,externalTree:k}),{sideX:Xe,sideY:ot}=ge.adaptiveOrigin||Pr,He=Se?n:"fixed",ce=h.useMemo(()=>x?{position:He,[Xe]:Z,[ot]:fe}:{position:He,...Ae},[x,He,Xe,Z,ot,fe,Ae]),Ye=h.useRef(null);Ce(()=>{if(!g)return;const Te=E.current,Fe=typeof Te=="function"?Te():Te,ue=(oi(Fe)?Fe.current:Fe)||null||null;ue!==Ye.current&&(Y.setPositionReference(ue),Ye.current=ue)},[g,Y,_,E]),h.useEffect(()=>{if(!g)return;const Te=E.current;typeof Te!="function"&&oi(Te)&&Te.current!==Ye.current&&(Y.setPositionReference(Te.current),Ye.current=Te.current)},[g,Y,_,E]),h.useEffect(()=>{if(m&&g&&z.domReference&&z.floating)return Xa(z.domReference,z.floating,ae,ye)},[m,g,z,ae,ye]);const Oe=Ke(re),Ue=lc(r,Oe,j),Et=Jt(re)||"center",yt=!!ge.hide?.referenceHidden;Ce(()=>{w&&g&&Se&&S(Oe)},[w,g,Se,Oe]);const Lt=h.useMemo(()=>({position:"absolute",top:ge.arrow?.y,left:ge.arrow?.x}),[ge.arrow]),Wt=ge.arrow?.centerOffset!==0;return h.useMemo(()=>({positionerStyles:ce,arrowStyles:Lt,arrowRef:K,arrowUncentered:Wt,side:Ue,align:Et,physicalSide:Oe,anchorHidden:yt,refs:Y,context:we,isPositioned:Se,update:ae}),[ce,Lt,K,Wt,Ue,Et,Oe,yt,Y,we,Se,ae])}function oi(e){return e!=null&&"current"in e}const cc=h.forwardRef(function(t,n){const{cutout:r,...o}=t;let s;if(r){const a=r?.getBoundingClientRect();s=`polygon(
1
+ import{i as Cd,f as Wi,a as Bi,J as Md,u as $i,m as Td,r as h,M as Yi,b as Ed,c as Nd,d as xo,e as Hi,g as Dd,h as gn,j as Wn,k as fn,l as Od,n as ts,o as kr,p as ys,q as Kr,s as Rd,t as jd,v as _d,w as bs,x as jn,y as wo,z as Ad,A as qe,B as N,C as Ui,D as d,E as Xt,F as Ce,G as pn,H as Vi,I as zi,K as me,N as qi,L as Pd,O as ze,R as Id,P as zt,Q as ir,S as Gt,T as Fd,U as It,V as pa,W as lt,X as pt,Y as Nn,Z as De,_ as Ft,$ as ya,a0 as xs,a1 as ws,a2 as _n,a3 as un,a4 as Ld,a5 as Gi,a6 as Wd,a7 as lr,a8 as Xr,a9 as Bd,aa as vs,ab as ct,ac as Ki,ad as q,ae as $d,af as Jr,ag as Qr,ah as Yd,ai as Xi,aj as ks,ak as Ji,al as ns,am as Hd,an as Ud,ao as Vd,ap as zd,aq as qd,ar as Gd,as as Kd,at as Xd,au as Jd,av as Qd,aw as Zd,ax as ef,ay as Rt,az as ba}from"./main-CJeNIc4Q.js";import{u as tf}from"./use-usage-limits-CuoJnC-V.js";import{C as Ss}from"./Card-BbXzY-fw.js";import{F as er}from"./FadeIn-Dz3MVtMG.js";import{P as xa}from"./ProviderIcon-DChRpzX_.js";const nf=500,rf={style:{transition:"none"}},Qi="data-base-ui-click-trigger",of={fallbackAxisSide:"end"},sf={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function af(...e){const t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],o=e[1+n],s=e[2+n],a=e[3+n],i=Cd(o,s,a);return t?i(r):i}function lf(e,t,n={}){const r=e.get();let o=null,s=r,a;const i=typeof r=="string"?r.replace(/[\d.-]/g,""):void 0,l=()=>{o&&(o.stop(),o=null),e.animation=void 0},c=()=>{const f=wa(e.get()),m=wa(s);if(f===m){l();return}const p=o?o.getGeneratorVelocity():e.getVelocity();l(),o=new Md({keyframes:[f,m],velocity:p,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:a})},u=()=>{c(),e.animation=o??void 0,e.events.animationStart?.notify(),o?.then(()=>{e.animation=void 0,e.events.animationComplete?.notify()})};if(e.attach((f,m)=>{s=f,a=p=>m(vo(p,i)),Wi.postRender(u)},l),Bi(t)){let f=n.skipInitialAnimation===!0;const m=t.on("change",g=>{f?(f=!1,e.jump(vo(g,i),!1)):e.set(vo(g,i))}),p=e.on("destroy",m);return()=>{m(),p()}}return l}function vo(e,t){return t?e+t:e}function wa(e){return typeof e=="number"?e:parseFloat(e)}function Cs(e){const t=$i(()=>Td(e)),{isStatic:n}=h.useContext(Yi);if(n){const[,r]=h.useState(e);h.useEffect(()=>t.on("change",r),[])}return t}function Zi(e,t){const n=Cs(t()),r=()=>n.set(t());return r(),Ed(()=>{const o=()=>Wi.preRender(r,!1,!0),s=e.map(a=>a.on("change",o));return()=>{s.forEach(a=>a()),Nd(r)}}),n}function cf(e){xo.current=[],e();const t=Zi(xo.current,e);return xo.current=void 0,t}function el(e,t,n,r){if(typeof e=="function")return cf(e);const s=typeof t=="function"?t:af(t,n,r),a=Array.isArray(e)?va(e,s):va([e],([l])=>s(l)),i=Array.isArray(e)?void 0:e.accelerate;return i&&!i.isTransformed&&typeof t!="function"&&Array.isArray(n)&&r?.clamp!==!1&&(a.accelerate={...i,times:t,keyframes:n,isTransformed:!0}),a}function va(e,t){const n=$i(()=>[]);return Zi(e,()=>{n.length=0;const r=e.length;for(let o=0;o<r;o++)n[o]=e[o].get();return t(n)})}function uf(e,t={}){const{isStatic:n}=h.useContext(Yi),r=()=>Bi(e)?e.get():e;if(n)return el(r);const o=Cs(r());return h.useInsertionEffect(()=>lf(o,e,t),[o,JSON.stringify(t)]),o}function df(e,t={}){return uf(e,{type:"spring",...t})}const ff=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],hf=Hi("info",ff);const mf=[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]],gf=Hi("square-arrow-out-up-right",mf);function pf({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:r=52,weekStartsOn:o="sun",cacheKey:s,timeZone:a,tzOffsetMinutes:i,now:l}={}){const c=h.useMemo(()=>Dd({weeks:r,weekStartsOn:o,now:l}),[l,r,o]),[u,f]=h.useState([]),[m,p]=h.useState(null),[g,y]=h.useState("edge"),[b,v]=h.useState(!1),[x,w]=h.useState(null),k=gn(),C=Wn(t),S=!n,T=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),M=h.useMemo(()=>{if(!s)return null;const I=Kr({timeZone:a,offsetMinutes:i});return`tokentracker.heatmap.${s}.${r}.${o}.${I}`},[s,a,i,r,o]),A=h.useCallback(()=>{if(!M||typeof window>"u")return null;try{const I=window.localStorage.getItem(M);if(!I)return null;const j=JSON.parse(I);return!j||!j.heatmap?null:j}catch{return null}},[M]),R=h.useCallback(I=>{if(!(!M||typeof window>"u"))try{window.localStorage.setItem(M,JSON.stringify(I))}catch{}},[M]),D=h.useCallback(()=>{if(!(!M||typeof window>"u"))try{window.localStorage.removeItem(M)}catch{}},[M]),_=h.useCallback(async()=>{const I=await fn(t);if(!(!I&&!k&&!T)){v(!0),w(null);try{try{const O=await Od({baseUrl:e,accessToken:I,weeks:r,to:c.to,weekStartsOn:o,timeZone:a,tzOffsetMinutes:i}),F=Array.isArray(O?.weeks)?O.weeks:[];if(!F.length&&S){const $=A();if($?.heatmap){p($.heatmap),f($.daily||[]),y("cache");return}}if(!F.some($=>(Array.isArray($)?$:[]).some(Q=>Q&&Number.isFinite(Number(Q.level))))&&F.length){const $=[];for(const U of F)for(const W of Array.isArray(U)?U:[])W?.day&&$.push({day:W.day,total_tokens:W.total_tokens??W.value??0,billable_total_tokens:W.billable_total_tokens??W.value??W.total_tokens??0});const Q=ts({dailyRows:$,weeks:r,to:O?.to||c.to,weekStartsOn:o});f($),p({...Q,week_starts_on:o,active_days:$.filter(U=>Number(U?.billable_total_tokens??U?.total_tokens)>0).length,streak_days:kr({dailyRows:$,to:O?.to||c.to})}),y("client"),S?R({heatmap:{...Q,week_starts_on:o,active_days:$.filter(U=>Number(U?.billable_total_tokens??U?.total_tokens)>0).length,streak_days:kr({dailyRows:$,to:O?.to||c.to})},daily:$,fetchedAt:new Date().toISOString()}):D();return}p(O||null),f([]),y("edge"),O&&S?R({heatmap:O,daily:[],fetchedAt:new Date().toISOString()}):S||D();return}catch(O){const F=O,V=F?.status??F?.statusCode;if(V===401||V===403)throw O}const j=await ys({baseUrl:e,accessToken:I,from:c.from,to:c.to,timeZone:a,tzOffsetMinutes:i}),B=Array.isArray(j?.data)?j.data:[];f(B);const H=ts({dailyRows:B,weeks:r,to:c.to,weekStartsOn:o});p({...H,week_starts_on:o,active_days:B.filter(O=>Number(O?.billable_total_tokens??O?.total_tokens)>0).length,streak_days:kr({dailyRows:B,to:c.to})}),y("client"),S?R({heatmap:{...H,week_starts_on:o,active_days:B.filter(O=>Number(O?.billable_total_tokens??O?.total_tokens)>0).length,streak_days:kr({dailyRows:B,to:c.to})},daily:B,fetchedAt:new Date().toISOString()}):D()}catch(j){if(S){const B=A();if(B?.heatmap)p(B.heatmap),f(B.daily||[]),y("cache"),w(null);else{const H=j;w(H?.message||String(H)),f([]),p(null),y("edge")}}else{const B=j;w(B?.message||String(B)),f([]),p(null),y("edge")}}finally{v(!1)}}},[t,e,k,n,S,c.from,c.to,A,C,a,i,o,r,D,R,T]);return h.useEffect(()=>{if(!C&&!n&&!k&&!T){f([]),v(!1),w(null),p(null),y("edge");return}if(!S)D(),f([]),w(null),p(null),y("edge");else{const I=A();I?.heatmap&&(p(I.heatmap),f(I.daily||[]),y("cache"))}_()},[t,k,A,_,C,n,S,D,T]),{range:c,daily:u,heatmap:m,source:k?"mock":g==="client"?"edge":g,loading:b,error:x,refresh:_}}function yf({baseUrl:e,accessToken:t,limit:n=3,from:r,to:o,source:s,timeZone:a,tzOffsetMinutes:i}={}){const[l,c]=h.useState([]),[u,f]=h.useState(!1),[m,p]=h.useState(null),g=gn(),y=Wn(t),b=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),v=h.useCallback(async()=>{const x=await fn(t);if(!x&&!g&&!b){c([]),p(null),f(!1);return}f(!0),p(null);try{const w=await Rd({baseUrl:e,accessToken:x,limit:n,from:r,to:o,source:s,timeZone:a,tzOffsetMinutes:i});c(Array.isArray(w?.entries)?w.entries:[])}catch(w){const k=w?.message||String(w);p(k),c([])}finally{f(!1)}},[t,e,r,n,g,s,a,o,i,b]);return h.useEffect(()=>{if(!y&&!g&&!b){c([]),p(null),f(!1);return}v()},[g,v,y,b]),{entries:l,loading:u,error:m,refresh:v}}const bf=24;function xf({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:r,from:o,to:s,months:a=bf,cacheKey:i,timeZone:l,tzOffsetMinutes:c,now:u,sharedRows:f,sharedRange:m}={}){const[p,g]=h.useState([]),[y,b]=h.useState(()=>({from:o,to:s})),[v,x]=h.useState("edge"),[w,k]=h.useState(null),[C,S]=h.useState(!1),[T,M]=h.useState(null),A=gn(),R=Wn(t),D=!n,_=Array.isArray(f),E=m?.from||o,I=m?.to||s,j=h.useMemo(()=>r==="day"?"hourly":r==="total"?"monthly":"daily",[r]),B=(()=>{if(!i)return null;const U=wf(e)||"default",W=Kr({timeZone:l,offsetMinutes:c});if(j==="hourly")return`tokentracker.trend.${i}.${U}.hourly.${s||o||"day"}.${W}`;if(j==="monthly")return`tokentracker.trend.${i}.${U}.monthly.${a}.${s||"today"}.${W}`;const K=`${o||""}.${s||""}`;return`tokentracker.trend.${i}.${U}.daily.${K}.${W}`})(),H=h.useCallback(()=>{if(!B||typeof window>"u")return null;try{const U=window.localStorage.getItem(B);if(!U)return null;const W=JSON.parse(U);return!W||!Array.isArray(W.rows)?null:W}catch{return null}},[B]),O=h.useCallback(U=>{if(!(!B||typeof window>"u"))try{window.localStorage.setItem(B,JSON.stringify(U))}catch{}},[B]),F=h.useCallback(()=>{if(!(!B||typeof window>"u"))try{window.localStorage.removeItem(B)}catch{}},[B]),V=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),$=h.useCallback(async()=>{if(_){g(Array.isArray(f)?f:[]),b({from:E,to:I}),x("shared"),k(null),S(!1),M(null);return}const U=await fn(t);if(!(!U&&!A&&!V)){S(!0),M(null);try{let W;j==="hourly"?W=await jd({baseUrl:e,accessToken:U,day:s||o,timeZone:l,tzOffsetMinutes:c}):j==="monthly"?W=await _d({baseUrl:e,accessToken:U,months:a,to:s,timeZone:l,tzOffsetMinutes:c}):W=await ys({baseUrl:e,accessToken:U,from:o,to:s,timeZone:l,tzOffsetMinutes:c});const K=W?.from||o||W?.day||null,G=W?.to||s||W?.day||null;let te=Array.isArray(W?.data)?W.data:[];j==="daily"?te=So(te,K||o,G||s,{timeZone:l,offsetMinutes:c,now:u}):j==="hourly"?te=Co(te,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&(te=Mo(te,{timeZone:l,offsetMinutes:c,now:u}));const xe=new Date().toISOString();g(te),b({from:K,to:G}),x("edge"),k(xe),D?O({rows:te,from:K,to:G,mode:j,fetchedAt:xe}):F()}catch(W){if(D){const K=H();if(K?.rows){let G=j==="daily"?So(K.rows||[],K.from||o,K.to||s,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(K.rows)?K.rows:[];j==="hourly"?G=Co(G,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&(G=Mo(G,{timeZone:l,offsetMinutes:c,now:u})),g(G),b({from:K.from||o,to:K.to||s}),x("cache"),k(K.fetchedAt||null),M(null)}else{g([]),b({from:o,to:s}),x("edge"),k(null);const G=W;M(G?.message||String(G))}}else{g([]),b({from:o,to:s}),x("edge"),k(null);const K=W;M(K?.message||String(K))}}finally{S(!1)}}},[t,e,o,A,n,D,j,a,H,R,_,E,f,I,l,s,c,u,F,O,V]);h.useEffect(()=>{if(_){g(Array.isArray(f)?f:[]),b({from:E,to:I}),x("shared"),k(null),S(!1),M(null);return}if(!R&&!n&&!A&&!V){g([]),b({from:o,to:s}),M(null),S(!1),x("edge"),k(null);return}if(!D)F(),g([]),b({from:o,to:s}),M(null),x("edge"),k(null);else{const U=H();if(U?.rows){let W=j==="daily"?So(U.rows||[],U.from||o,U.to||s,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(U.rows)?U.rows:[];j==="hourly"?W=Co(W,{timeZone:l,offsetMinutes:c,now:u}):j==="monthly"&&(W=Mo(W,{timeZone:l,offsetMinutes:c,now:u})),g(W),b({from:U.from||o,to:U.to||s}),x("cache"),k(U.fetchedAt||null)}}$()},[t,A,H,$,_,E,f,I,R,n,D,F,V]);const Q=A?"mock":v;return{rows:p,from:y.from||o,to:y.to||s,source:Q,fetchedAt:w,loading:C,error:T,refresh:$}}function wf(e){try{return new URL(e).host}catch{return null}}function ko(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const r=Number(n[0]),o=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s))return null;const a=new Date(Date.UTC(r,o,s));return Number.isFinite(a.getTime())&&jn(a)===t?a:null}function vf(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function So(e,t,n,{timeZone:r,offsetMinutes:o,now:s}={}){const a=ko(t),i=ko(n);if(!a||!i||i<a)return Array.isArray(e)?e:[];const l=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,c=bs({timeZone:r,offsetMinutes:o,date:l}),u=ko(c),f=u?u.getTime():l.getTime(),m=new Map;for(const g of e||[])g?.day&&m.set(g.day,g);const p=[];for(let g=a;g<=i;g=vf(g,1)){const y=jn(g),b=m.get(y),v=g.getTime()>f;if(b){p.push({...b,missing:!1,future:v});continue}p.push({day:y,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!v,future:v})}return p}function Co(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const o=tl({timeZone:t,offsetMinutes:n,now:r});return o?e.map(s=>{const a=s?.hour||s?.label||"",i=kf(a);if(!i)return{...s,future:!1};const l=i.dayNum>o.dayNum||i.dayNum===o.dayNum&&i.slot>o.slot;return{...s,future:l}}):e}function Mo(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const o=tl({timeZone:t,offsetMinutes:n,now:r});return o?e.map(s=>{const a=s?.month||s?.label||"",i=Sf(a);if(!i)return{...s,future:!1};const l=i.year>o.year||i.year===o.year&&i.month>o.month;return{...s,future:l}}):e}function tl({timeZone:e,offsetMinutes:t,now:n}={}){const r=n instanceof Date&&Number.isFinite(n.getTime())?n:new Date;if(e&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const m=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(r).reduce((x,w)=>(w.type&&w.value&&(x[w.type]=w.value),x),{}),p=Number(m.year),g=Number(m.month),y=Number(m.day),b=Number(m.hour),v=Number(m.minute);if(Number.isFinite(p)&&Number.isFinite(g)&&Number.isFinite(y)&&Number.isFinite(b)&&Number.isFinite(v)){const x=b*2+(v>=30?1:0);return{year:p,month:g,day:y,hour:b,minute:v,dayNum:p*1e4+g*100+y,slot:x}}}catch{}if(Number.isFinite(t)){const u=new Date(r.getTime()+t*60*1e3),f=u.getUTCFullYear(),m=u.getUTCMonth()+1,p=u.getUTCDate(),g=u.getUTCHours(),y=u.getUTCMinutes(),b=g*2+(y>=30?1:0);return{year:f,month:m,day:p,hour:g,minute:y,dayNum:f*1e4+m*100+p,slot:b}}const o=r.getFullYear(),s=r.getMonth()+1,a=r.getDate(),i=r.getHours(),l=r.getMinutes(),c=i*2+(l>=30?1:0);return{year:o,month:s,day:a,hour:i,minute:l,dayNum:o*1e4+s*100+a,slot:c}}function kf(e){if(!e)return null;const t=String(e).trim(),[n,r]=t.split("T");if(!n||!r)return null;const o=n.split("-");if(o.length!==3)return null;const s=Number(o[0]),a=Number(o[1]),i=Number(o[2]);if(!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(i))return null;const l=r.split(":"),c=Number(l[0]),u=Number(l[1]);if(!Number.isFinite(c)||c<0||c>23||!Number.isFinite(u)||u<0||u>59)return null;const f=c*2+(u>=30?1:0);return{dayNum:s*1e4+a*100+i,slot:f}}function Sf(e){if(!e)return null;const n=String(e).trim().split("-");if(n.length!==2)return null;const r=Number(n[0]),o=Number(n[1]);return!Number.isFinite(r)||!Number.isFinite(o)||o<1||o>12?null:{year:r,month:o}}function ka({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:o,includeDaily:s=!0,cacheKey:a,timeZone:i,tzOffsetMinutes:l,now:c}={}){const[u,f]=h.useState([]),[m,p]=h.useState(null),[g,y]=h.useState(null),[b,v]=h.useState("edge"),[x,w]=h.useState(null),[k,C]=h.useState(!1),[S,T]=h.useState(null),M=gn(),A=Wn(t),R=!n,D=(()=>{if(!a)return null;const O=Cf(e)||"default",F=s?"daily":"summary",V=Kr({timeZone:i,offsetMinutes:l});return`tokentracker.usage.${a}.${O}.${r}.${o}.${F}.${V}`})(),_=h.useCallback(()=>{if(!D||typeof window>"u")return null;try{const O=window.localStorage.getItem(D);if(!O)return null;const F=JSON.parse(O);return!F||!F.summary?null:F}catch{return null}},[D]),E=h.useCallback(O=>{if(!(!D||typeof window>"u"))try{window.localStorage.setItem(D,JSON.stringify(O))}catch{}},[D]),I=h.useCallback(()=>{if(!(!D||typeof window>"u"))try{window.localStorage.removeItem(D)}catch{}},[D]),j=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),B=h.useCallback(async()=>{const O=await fn(t);if(!(!O&&!M&&!j)){C(!0),T(null);try{let F=null,V=null;if(s){const[K,G]=await Promise.allSettled([ys({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l}),wo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l,rolling:!0})]);if(K.status==="rejected")throw K.reason;F=K.value,V=G.status==="fulfilled"?G.value:null}else V=await wo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l,rolling:!0});let $=s&&Array.isArray(F?.data)?F.data:[];s&&($=Eo($,r,o,{timeZone:i,offsetMinutes:l,now:c}));let Q=V?.totals||F?.summary?.totals||null,U=V?.rolling||F?.summary?.rolling||null;if(s&&!Q&&!V)try{const K=await wo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l,rolling:!0});Q=K?.totals||null,U=K?.rolling||U}catch{}const W=new Date().toISOString();f($),p(Q),y(U),v("edge"),w(W),Q&&R?E({summary:Q,rolling:U,daily:$,from:r,to:o,includeDaily:s,fetchedAt:W}):R||I()}catch(F){if(R){const V=_();if(V?.summary){p(V.summary),y(V.rolling||null);const $=Array.isArray(V.daily)?V.daily:[],Q=s?Eo($,V.from||r,V.to||o,{timeZone:i,offsetMinutes:l,now:c}):$;f(Q),v("cache"),w(V.fetchedAt||null),T(null)}else{const $=F;T($?.message||String($)),f([]),p(null),y(null),v("edge"),w(null)}}else{const V=F;T(V?.message||String(V)),f([]),p(null),y(null),v("edge"),w(null)}}finally{C(!1)}}},[t,e,r,s,M,n,R,c,_,A,i,o,l,I,E,j]);return h.useEffect(()=>{const O=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!A&&!n&&!M&&!O){f([]),p(null),y(null),T(null),C(!1),v("edge"),w(null);return}if(!R)I(),f([]),p(null),y(null),T(null),v("edge"),w(null);else{const F=_();if(F?.summary){p(F.summary),y(F.rolling||null);const V=Array.isArray(F.daily)?F.daily:[],$=s?Eo(V,F.from||r,F.to||o,{timeZone:i,offsetMinutes:l,now:c}):V;f($),v("cache"),w(F.fetchedAt||null)}}B()},[t,M,_,B,A,n,R,I,j]),{daily:u,summary:m,rolling:g,source:M?"mock":b,fetchedAt:x,loading:k,error:S,refresh:B}}function Cf(e){try{return new URL(e).host}catch{return null}}function To(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const r=Number(n[0]),o=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s))return null;const a=new Date(Date.UTC(r,o,s));return Number.isFinite(a.getTime())&&jn(a)===t?a:null}function Mf(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Eo(e,t,n,{timeZone:r,offsetMinutes:o,now:s}={}){const a=To(t),i=To(n);if(!a||!i||i<a)return Array.isArray(e)?e:[];const l=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,c=bs({timeZone:r,offsetMinutes:o,date:l}),u=To(c),f=u?u.getTime():l.getTime(),m=new Map;for(const g of e||[])g?.day&&m.set(g.day,g);const p=[];for(let g=a;g<=i;g=Mf(g,1)){const y=jn(g),b=m.get(y),v=g.getTime()>f;if(b){p.push({...b,missing:!1,future:v});continue}p.push({day:y,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!v,future:v})}return p}function Tf({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:o,cacheKey:s,timeZone:a,tzOffsetMinutes:i}={}){const[l,c]=h.useState(null),[u,f]=h.useState("edge"),[m,p]=h.useState(!1),[g,y]=h.useState(null),b=gn(),v=Wn(t),x=!n,w=h.useMemo(()=>{if(!s)return null;const R=Ef(e)||"default",D=Kr({timeZone:a,offsetMinutes:i});return`tokentracker.modelBreakdown.${s}.${R}.${r}.${o}.${D}`},[e,s,r,a,o,i]),k=h.useCallback(()=>{if(!w||typeof window>"u")return null;try{const R=window.localStorage.getItem(w);if(!R)return null;const D=JSON.parse(R);return!D||!D.breakdown?null:D}catch{return null}},[w]),C=h.useCallback(R=>{if(!(!w||typeof window>"u"))try{window.localStorage.setItem(w,JSON.stringify(R))}catch{}},[w]),S=h.useCallback(()=>{if(!(!w||typeof window>"u"))try{window.localStorage.removeItem(w)}catch{}},[w]),T=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),M=h.useCallback(async()=>{const R=await fn(t);if(!(!R&&!b&&!T)){p(!0),y(null);try{const D=await Ad({baseUrl:e,accessToken:R,from:r,to:o,timeZone:a,tzOffsetMinutes:i});c(D||null),f("edge"),D&&x?C({breakdown:D,fetchedAt:new Date().toISOString()}):x||S()}catch(D){if(x){const _=k();if(_?.breakdown)c(_.breakdown),f("cache"),y(null);else{c(null),f("edge");const E=D;y(E?.message||String(E))}}else{c(null),f("edge");const _=D;y(_?.message||String(_))}}finally{p(!1)}}},[t,e,r,b,n,x,k,a,o,v,i,S,C,T]);return h.useEffect(()=>{if(!v&&!n&&!b&&!T){c(null),f("edge"),y(null),p(!1);return}if(!x)S(),c(null),f("edge"),y(null);else{const R=k();R?.breakdown&&(c(R.breakdown),f("cache"))}M()},[t,b,k,M,v,n,x,S,T]),{breakdown:l,source:b?"mock":u,loading:m,error:g,refresh:M}}function Ef(e){try{return new URL(e).host}catch{return null}}const nl=new Set(["day","hour","month"]);function Nf(e){return nl.has(e)}function Sa(e){if(e==null)return null;const t=String(e).trim();if(!/^[0-9]+$/.test(t))return null;const n=t.replace(/^0+/,"");return n.length===0?"0":n}function Df(e,t){const n=Sa(e),r=Sa(t);if(n&&r)return n.length!==r.length?n.length<r.length?-1:1:n===r?0:n<r?-1:1;const o=qe(e),s=qe(t);return o==null&&s==null?0:o==null?1:s==null?-1:o===s?0:o<s?-1:1}function Of(e,t){const n=typeof e=="string"?e:String(e||""),r=typeof t=="string"?t:String(t||"");return n===r?0:n<r?-1:1}function Rf(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!n)return null;const r=Number(n[1]),o=Number(n[2]),s=Number(n[3]);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s))return null;const a=new Date(Date.UTC(r,o-1,s));return!Number.isFinite(a.getTime())||a.getUTCFullYear()!==r||a.getUTCMonth()+1!==o||a.getUTCDate()!==s?null:a.getTime()}function jf(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})$/);if(!n)return null;const r=Number(n[1]),o=Number(n[2]);if(!Number.isFinite(r)||!Number.isFinite(o)||o<1||o>12)return null;const s=new Date(Date.UTC(r,o-1,1));return Number.isFinite(s.getTime())?s.getTime():null}function _f(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?Z?$/);if(!n)return null;const r=Number(n[1]),o=Number(n[2]),s=Number(n[3]),a=Number(n[4]),i=Number(n[5]),l=Number(n[6]||0);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(i)||!Number.isFinite(l)||o<1||o>12||s<1||s>31||a<0||a>23||i<0||i>59||l<0||l>59)return null;const c=new Date(Date.UTC(r,o-1,s,a,i,l));return Number.isFinite(c.getTime())?c.getTime():null}function Af(e,t,n){const r=n==="hour"?_f:n==="month"?jf:Rf,o=r(e),s=r(t);return o!=null&&s!=null?o===s?0:o<s?-1:1:Of(e,t)}function rl(e,{key:t,dir:n}){const r=n==="asc"?1:-1,o=Array.isArray(e)?e:[],s=nl.has(t)?(i,l)=>Af(i,l,t):Df,a=i=>t==="total_tokens"&&i?.billable_total_tokens!=null?i.billable_total_tokens:i?.[t];return o.map((i,l)=>({row:i,index:l})).sort((i,l)=>{const c=a(i.row),u=a(l.row),f=c==null,m=u==null;if(f&&m)return i.index-l.index;if(f)return 1;if(m)return-1;const p=s(c,u);return p!==0?p*r:i.index-l.index}).map(i=>i.row)}function Pf(){return[{key:"day",label:N("daily.sort.date.label"),title:N("daily.sort.date.title")},{key:"total_tokens",label:N("daily.sort.total.label"),title:N("daily.sort.total.title")},{key:"input_tokens",label:N("daily.sort.input.label"),title:N("daily.sort.input.title")},{key:"output_tokens",label:N("daily.sort.output.label"),title:N("daily.sort.output.title")},{key:"cached_input_tokens",label:N("daily.sort.cached.label"),title:N("daily.sort.cached.title")},{key:"reasoning_output_tokens",label:N("daily.sort.reasoning.label"),title:N("daily.sort.reasoning.title")},{key:"conversation_count",label:N("daily.sort.conversations.label"),title:N("daily.sort.conversations.title")}]}function Ca(e){const t=Nf(e)?e:"day";return Pf().map((n,r)=>r===0?{...n,key:t}:n)}function Ma(e,{key:t,dir:n}){return rl(e,{key:t,dir:n})}const Fr=12,If=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function Ff(e){if(typeof e=="bigint")return e!==0n;if(typeof e=="number")return Number.isFinite(e)&&e!==0;if(e==null)return!1;const t=String(e).trim();if(!t||!/^-?\d+$/.test(t))return!1;const n=t.startsWith("-")?t.slice(1):t;return/[1-9]/.test(n)}function Lf(e){return If.some(t=>Ff(e?.[t]))}function Wf(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=rl(t,{key:"month",dir:"asc"}),r=n.findIndex(o=>o?.month&&Lf(o));return r===-1?t:n.slice(r)}function Bf(e,t,n=Fr){const r=Array.isArray(e)?e:[],o=Number.isFinite(n)&&n>0?n:Fr,a=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*o;return r.slice(a,a+o)}function $f({publicMode:e,screenshotMode:t,forceInstall:n,accessEnabled:r,heatmapLoading:o,activeDays:s,hasActiveDeviceToken:a}={}){return e||t?!1:n?!0:r&&!o&&s===0&&!a}function ol(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function Yf(e){const t=ol(e?.model_id);return t||null}function sl(e,t){return e?.model?String(e.model):t}function Hf(e,{copyFn:t}={}){const n=typeof t=="function"?t:a=>a,o=(Array.isArray(e?.sources)?e.sources:[]).map(a=>{const i=qe(a?.totals?.billable_total_tokens??a?.totals?.total_tokens)??0,l=qe(a?.totals?.total_cost_usd)??0;return{source:a?.source,totalTokens:Number.isFinite(i)?i:0,totalCost:Number.isFinite(l)?l:0,models:Array.isArray(a?.models)?a.models:[]}}).filter(a=>a.totalTokens>0);if(!o.length)return[];const s=o.reduce((a,i)=>a+i.totalTokens,0);return typeof e?.pricing?.pricing_mode=="string"&&e.pricing.pricing_mode.toUpperCase(),o.slice().sort((a,i)=>i.totalTokens-a.totalTokens).map(a=>{const i=a.source?String(a.source).toUpperCase():n("shared.placeholder.short"),l=s>0?a.totalTokens/s*100:0,c=Number.isFinite(l)?l.toFixed(1):"0.0",u=a.models.map(f=>{const m=qe(f?.totals?.billable_total_tokens??f?.totals?.total_tokens)??0;if(!Number.isFinite(m)||m<=0)return null;const p=a.totalTokens>0?Math.round(m/a.totalTokens*1e3)/10:0,g=sl(f,n("shared.placeholder.short")),y=Yf(f),b=a.totalCost>0&&a.totalTokens>0?m/a.totalTokens*a.totalCost:null;return{id:y,name:g,share:p,usage:m,cost:b}}).filter(Boolean);return{label:i,totalPercent:String(c),usd:a.totalCost,usage:a.totalTokens,models:u}})}function Uf(e,{limit:t=3,copyFn:n}={}){const r=typeof n=="function"?n:m=>m,o=Array.isArray(e?.sources)?e.sources:[];if(!o.length)return[];const s=new Map,a=new Map,i=new Map;let l=0;for(const m of o){const p=Array.isArray(m?.models)?m.models:[];for(const g of p){const y=qe(g?.totals?.billable_total_tokens)??0;if(!Number.isFinite(y)||y<=0)continue;l+=y;const b=sl(g,r("shared.placeholder.short")),v=ol(b);if(!v)continue;s.set(v,(s.get(v)||0)+y);const x=i.get(v)||0;y>=x&&(i.set(v,y),a.set(v,b))}}if(!s.size)return[];const c=Array.from(s.values()).reduce((m,p)=>m+p,0),u=l>0?l:c,f=Number.isFinite(t)?Math.max(0,Math.floor(t)):3;return Array.from(s.entries()).map(([m,p])=>{const g=u>0?(p/u*100).toFixed(1):"0.0";return{id:m,name:a.get(m)||r("shared.placeholder.short"),tokens:p,percent:String(g)}}).sort((m,p)=>p.tokens!==m.tokens?p.tokens-m.tokens:String(m.name).localeCompare(String(p.name))).slice(0,f)}const tn=12,Gn=3,No=26,Vf=["#ecfdf5","#a7f3d0","#6ee7b7","#34d399","#10b981"],zf=["#064e3b","#065f46","#059669","#10b981","#34d399"],qf=[N("heatmap.month.jan"),N("heatmap.month.feb"),N("heatmap.month.mar"),N("heatmap.month.apr"),N("heatmap.month.may"),N("heatmap.month.jun"),N("heatmap.month.jul"),N("heatmap.month.aug"),N("heatmap.month.sep"),N("heatmap.month.oct"),N("heatmap.month.nov"),N("heatmap.month.dec")];function Gf(e){if(typeof e=="bigint")return e.toLocaleString();if(typeof e=="number")return Number.isFinite(e)?Math.round(e).toLocaleString():"0";if(typeof e=="string"){const t=Number(e);return Number.isFinite(t)?Math.round(t).toLocaleString():e}return"0"}function Kf(e){if(typeof e!="string")return null;const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e.trim());if(!t)return null;const n=new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3])));return Number.isFinite(n.getTime())?n:null}function al(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Xf(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function Jf(e,t){const n=t==="mon"?1:0,r=e.getUTCDay();return al(e,-((r-n+7)%7))}function Qf(e,t,n){if(!e)return[];const r=Kf(t)||new Date,o=[];for(let c=11;c>=0;c-=1)o.push(new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()-c,1)));const s=Jf(r,n),a=al(s,-(e-1)*7),i=[],l=new Set;for(const c of o){const u=Math.floor(Xf(a,c)/7);u<0||u>=e||l.has(u)||(l.add(u),i.push({label:qf[c.getUTCMonth()],index:u}))}return i}function Zf({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:r=!1}){const{resolvedTheme:o}=Ui(),a=o==="dark"?zf:Vf,i=h.useRef(null);h.useEffect(()=>{const g=i.current;g&&(g.scrollLeft=g.scrollWidth)},[e?.weeks]);const l=e?.week_starts_on==="mon"?"mon":"sun",c=h.useMemo(()=>{const g=Array.isArray(e?.weeks)?e.weeks:[];if(!g.length)return{weeks:[]};const y=[];for(const b of g)for(const v of Array.isArray(b)?b:[])v?.day&&y.push({day:v.day,total_tokens:v.total_tokens??v.value??0,billable_total_tokens:v.billable_total_tokens??v.value??v.total_tokens??0});return ts({dailyRows:y,weeks:Math.max(52,g.length),to:e?.to,weekStartsOn:l})},[e?.to,e?.weeks,l]),u=c?.weeks||[],f=l==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(g=>N(`heatmap.day.${g.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(g=>N(`heatmap.day.${g.toLowerCase()}`)),m=h.useMemo(()=>Qf(u.length,c?.to,l),[c?.to,u.length,l]);if(!u.length)return d.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:N("heatmap.empty")});const p=No+u.length*tn+Math.max(0,u.length-1)*Gn;return d.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5",children:[d.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[d.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:N("heatmap.title")}),d.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400",children:n||N("heatmap.legend.utc")})]}),d.jsx("div",{ref:i,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:d.jsxs("div",{style:{minWidth:p},children:[d.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:`${No}px repeat(${u.length}, ${tn}px)`,columnGap:Gn},children:[d.jsx("span",{}),m.map(g=>d.jsx("span",{style:{gridColumnStart:g.index+2},className:"whitespace-nowrap",children:g.label},`${g.label}-${g.index}`))]}),d.jsxs("div",{className:"grid",style:{gridTemplateColumns:`${No}px repeat(${u.length}, ${tn}px)`,columnGap:Gn},children:[d.jsx("div",{className:"grid text-[10px] text-oai-gray-400 dark:text-oai-gray-400 sticky left-0 bg-white dark:bg-oai-gray-900 pr-2",style:{gridTemplateRows:`repeat(7, ${tn}px)`,rowGap:Gn},children:f.map(g=>d.jsx("span",{className:"leading-none",children:g},g))}),d.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${tn}px)`,gap:Gn},children:u.map((g,y)=>(Array.isArray(g)?g:[]).map((b,v)=>{if(!b)return null;const x=b.day||`e-${y}-${v}`,w=Number(b.level)||0,k=a[w]||a[0],C=t||n||N("heatmap.legend.utc");return d.jsx("span",{title:N("heatmap.tooltip",{day:b.day,value:Gf(b.value),unit:N("heatmap.unit.tokens"),tz:C}),className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10",style:{width:tn,height:tn,background:k}},x)}))})]})]})}),!r&&d.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[d.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:N("heatmap.legend.less")}),d.jsx("div",{className:"flex gap-0.5",children:a.map((g,y)=>d.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:g}},y))}),d.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:N("heatmap.legend.more")})]})]})}const eh={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},il={...eh,position:"fixed",top:0,left:0};function kt(e){const t=Xt(th,e).current;return t.next=e,Ce(t.effect),t}function th(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Lr=Symbol("NOT_FOUND");function nh(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function rh(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function oh(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var Ta=e=>Array.isArray(e)?e:[e];function sh(e){const t=Array.isArray(e[0])?e[0]:e;return oh(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function ah(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}function ih(e){let t;return{get(n){return t&&e(t.key,n)?t.value:Lr},put(n,r){t={key:n,value:r}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function lh(e,t){let n=[];function r(i){const l=n.findIndex(c=>t(i,c.key));if(l>-1){const c=n[l];return l>0&&(n.splice(l,1),n.unshift(c)),c.value}return Lr}function o(i,l){r(i)===Lr&&(n.unshift({key:i,value:l}),n.length>e&&n.pop())}function s(){return n}function a(){n=[]}return{get:r,put:o,getEntries:s,clear:a}}var ch=(e,t)=>e===t;function uh(e){return function(n,r){if(n===null||r===null||n.length!==r.length)return!1;const{length:o}=n;for(let s=0;s<o;s++)if(!e(n[s],r[s]))return!1;return!0}}function dh(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:r=ch,maxSize:o=1,resultEqualityCheck:s}=n,a=uh(r);let i=0;const l=o<=1?ih(a):lh(o,a);function c(){let u=l.get(arguments);if(u===Lr){if(u=e.apply(null,arguments),i++,s){const m=l.getEntries().find(p=>s(p.value,u));m&&(u=m.value,i!==0&&i--)}l.put(arguments,u)}return u}return c.clearCache=()=>{l.clear(),c.resetResultsCount()},c.resultsCount=()=>i,c.resetResultsCount=()=>{i=0},c}var fh=class{constructor(e){this.value=e}deref(){return this.value}},hh=typeof WeakRef<"u"?WeakRef:fh,mh=0,Ea=1;function Sr(){return{s:mh,v:void 0,o:null,p:null}}function ll(e,t={}){let n=Sr();const{resultEqualityCheck:r}=t;let o,s=0;function a(){let i=n;const{length:l}=arguments;for(let f=0,m=l;f<m;f++){const p=arguments[f];if(typeof p=="function"||typeof p=="object"&&p!==null){let g=i.o;g===null&&(i.o=g=new WeakMap);const y=g.get(p);y===void 0?(i=Sr(),g.set(p,i)):i=y}else{let g=i.p;g===null&&(i.p=g=new Map);const y=g.get(p);y===void 0?(i=Sr(),g.set(p,i)):i=y}}const c=i;let u;if(i.s===Ea)u=i.v;else if(u=e.apply(null,arguments),s++,r){const f=o?.deref?.()??o;f!=null&&r(f,u)&&(u=f,s!==0&&s--),o=typeof u=="object"&&u!==null||typeof u=="function"?new hh(u):u}return c.s=Ea,c.v=u,u}return a.clearCache=()=>{n=Sr(),a.resetResultsCount()},a.resultsCount=()=>s,a.resetResultsCount=()=>{s=0},a}function cl(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...o)=>{let s=0,a=0,i,l={},c=o.pop();typeof c=="object"&&(l=c,c=o.pop()),nh(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const u={...n,...l},{memoize:f,memoizeOptions:m=[],argsMemoize:p=ll,argsMemoizeOptions:g=[]}=u,y=Ta(m),b=Ta(g),v=sh(o),x=f(function(){return s++,c.apply(null,arguments)},...y),w=p(function(){a++;const C=ah(v,arguments);return i=x.apply(null,C),i},...b);return Object.assign(w,{resultFunc:c,memoizedResultFunc:x,dependencies:v,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>i,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var gh=cl(ll),ph=Object.assign((e,t=gh)=>{rh(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const n=Object.keys(e),r=n.map(s=>e[s]);return t(r,(...s)=>s.reduce((a,i,l)=>(a[n[l]]=i,a),{}))},{withTypes:()=>ph});cl({memoize:dh,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const pe=(e,t,n,r,o,s,...a)=>{if(a.length>0)throw new Error(pn(1));let i;if(e)i=e;else throw new Error("Missing arguments");return i};var Do={exports:{}},Oo={};var Na;function yh(){if(Na)return Oo;Na=1;var e=Vi();function t(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,a=e.useDebugValue;function i(f,m){var p=m(),g=r({inst:{value:p,getSnapshot:m}}),y=g[0].inst,b=g[1];return s(function(){y.value=p,y.getSnapshot=m,l(y)&&b({inst:y})},[f,p,m]),o(function(){return l(y)&&b({inst:y}),f(function(){l(y)&&b({inst:y})})},[f]),a(p),p}function l(f){var m=f.getSnapshot;f=f.value;try{var p=m();return!n(f,p)}catch{return!0}}function c(f,m){return m()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:i;return Oo.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Oo}var Da;function ul(){return Da||(Da=1,Do.exports=yh()),Do.exports}var bh=ul(),Ro={exports:{}},jo={};var Oa;function xh(){if(Oa)return jo;Oa=1;var e=Vi(),t=ul();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,a=e.useEffect,i=e.useMemo,l=e.useDebugValue;return jo.useSyncExternalStoreWithSelector=function(c,u,f,m,p){var g=s(null);if(g.current===null){var y={hasValue:!1,value:null};g.current=y}else y=g.current;g=i(function(){function v(S){if(!x){if(x=!0,w=S,S=m(S),p!==void 0&&y.hasValue){var T=y.value;if(p(T,S))return k=T}return k=S}if(T=k,r(w,S))return T;var M=m(S);return p!==void 0&&p(T,M)?(w=S,T):(w=S,k=M)}var x=!1,w,k,C=f===void 0?null:f;return[function(){return v(u())},C===null?void 0:function(){return v(C())}]},[u,f,m,p]);var b=o(c,g[0],g[1]);return a(function(){y.hasValue=!0,y.value=b},[b]),l(b),b},jo}var Ra;function wh(){return Ra||(Ra=1,Ro.exports=xh()),Ro.exports}var vh=wh();const kh=zi(19),Sh=kh?Mh:Th;function Ch(e,t,n,r,o){return Sh(e,t,n,r,o)}function Mh(e,t,n,r,o){const s=h.useCallback(()=>t(e.getSnapshot(),n,r,o),[e,t,n,r,o]);return bh.useSyncExternalStore(e.subscribe,s,s)}function Th(e,t,n,r,o){return vh.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,s=>t(s,n,r,o))}class tr{constructor(t){this.state=t,this.listeners=new Set,this.updateTick=0}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});getSnapshot=()=>this.state;setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const r of this.listeners){if(n!==this.updateTick)return;r(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){tr.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||tr.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};tr.prototype.setState.call(this,t)}}class Ms extends tr{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}controlledValues=new Map;useSyncedValue(t,n){h.useDebugValue(t),Ce(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){const r=this;Ce(()=>(r.state[t]!==n&&r.set(t,n),()=>{r.set(t,void 0)}),[r,t,n])}useSyncedValues(t){const n=this,r=Object.values(t);Ce(()=>{n.update(t)},[n,...r])}useControlledProp(t,n,r){h.useDebugValue(t);const o=this,s=n!==void 0;this.controlledValues.has(t)||(this.controlledValues.set(t,s),!s&&!Object.is(this.state[t],r)&&super.setState({...this.state,[t]:r})),Ce(()=>{s&&!Object.is(o.state[t],n)&&super.setState({...o.state,[t]:n})},[o,t,n,r,s])}set(t,n){this.controlledValues.get(t)!==!0&&super.set(t,n)}update(t){const n={...t};for(const r in n)if(Object.hasOwn(n,r)&&this.controlledValues.get(r)===!0){delete n[r];continue}super.update(n)}setState(t){const n={...t};for(const r in n)if(Object.hasOwn(n,r)&&this.controlledValues.get(r)===!0){delete n[r];continue}super.setState({...this.state,...n})}select=(t,n,r,o)=>{const s=this.selectors[t];return s(this.state,n,r,o)};useState=(t,n,r,o)=>{h.useDebugValue(t);const s=this.selectors[t];return Ch(this,s,n,r,o)};useContextCallback(t,n){h.useDebugValue(t);const r=me(n??qi);this.context[t]=r}useStateSetter(t){const n=h.useRef(void 0);return n.current===void 0&&(n.current=r=>{this.set(t,r)}),n.current}observe(t,n){let r;typeof t=="function"?r=t:r=this.selectors[t];let o=r(this.state);return n(o,o,this),this.subscribe(s=>{const a=r(s);if(!Object.is(o,a)){const i=o;o=a,n(a,i,this)}})}}const Eh=[];function Ts(e){h.useEffect(e,Eh)}const Cr=null;class Nh{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=t=>{this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let o=0;o<n.length;o+=1)n[o]?.(t)};request(t){const n=this.nextId;return this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1,!this.isScheduled&&(requestAnimationFrame(this.tick),this.isScheduled=!0),n}cancel(t){const n=t-this.startId;n<0||n>=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}}const Mr=new Nh;class vt{static create(){return new vt}static request(t){return Mr.request(t)}static cancel(t){return Mr.cancel(t)}currentId=Cr;request(t){this.cancel(),this.currentId=Mr.request(()=>{this.currentId=Cr,t()})}cancel=()=>{this.currentId!==Cr&&(Mr.cancel(this.currentId),this.currentId=Cr)};disposeEffect=()=>this.cancel}function Es(){const e=Xt(vt.create).current;return Ts(e.disposeEffect),e}const Kn=0;class Kt{static create(){return new Kt}currentId=Kn;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Kn,n()},t)}isStarted(){return this.currentId!==Kn}clear=()=>{this.currentId!==Kn&&(clearTimeout(this.currentId),this.currentId=Kn)};disposeEffect=()=>this.clear}function hn(){const e=Xt(Kt.create).current;return Ts(e.disposeEffect),e}const Bn=typeof navigator<"u",_o=jh(),dl=Ah(),fl=_h(),Dh=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),hl=_o.platform==="MacIntel"&&_o.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(_o.platform),Oh=Bn&&/apple/i.test(navigator.vendor),rs=Bn&&/android/i.test(dl)||/android/i.test(fl);Bn&&dl.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const Rh=fl.includes("jsdom/");function jh(){if(!Bn)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function _h(){if(!Bn)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function Ah(){if(!Bn)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const os="data-base-ui-focusable",ml="active",gl="selected",pl="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function Tn(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function ke(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Pd(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function et(e){return"composedPath"in e?e.composedPath()[0]:e.target}function ft(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function Ph(e){return e.matches("html,body")}function $e(e){return e?.ownerDocument||document}function yl(e){return ze(e)&&e.matches(pl)}function ja(e){return e?e.getAttribute("role")==="combobox"&&yl(e):!1}function ss(e){return e?e.hasAttribute(os)?e:e.querySelector(`[${os}]`)||e:null}function dn(e,t,n=!0){return e.filter(o=>o.parentId===t&&(!n||o.context?.open)).flatMap(o=>[o,...dn(e,o.id,n)])}function _a(e,t){let n=[],r=e.find(o=>o.id===t)?.parentId;for(;r;){const o=e.find(s=>s.id===r);r=o?.parentId,o&&(n=n.concat(o))}return n}function Ih(e){e.preventDefault(),e.stopPropagation()}function Fh(e){return"nativeEvent"in e}function Lh(e){return e.mozInputSource===0&&e.isTrusted?!0:rs&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Wh(e){return Rh?!1:!rs&&e.width===0&&e.height===0||rs&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function An(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function bl(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const Bh=["top","right","bottom","left"],Pn=Math.min,tt=Math.max,Wr=Math.round,Tr=Math.floor,Mt=e=>({x:e,y:e}),$h={left:"right",right:"left",bottom:"top",top:"bottom"};function as(e,t,n){return tt(e,Pn(t,n))}function Pt(e,t){return typeof e=="function"?e(t):e}function Ke(e){return e.split("-")[0]}function Jt(e){return e.split("-")[1]}function Ns(e){return e==="x"?"y":"x"}function Ds(e){return e==="y"?"height":"width"}function it(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Os(e){return Ns(it(e))}function Yh(e,t,n){n===void 0&&(n=!1);const r=Jt(e),o=Os(e),s=Ds(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Br(a)),[a,Br(a)]}function Hh(e){const t=Br(e);return[is(e),t,is(t)]}function is(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Aa=["left","right"],Pa=["right","left"],Uh=["top","bottom"],Vh=["bottom","top"];function zh(e,t,n){switch(e){case"top":case"bottom":return n?t?Pa:Aa:t?Aa:Pa;case"left":case"right":return t?Uh:Vh;default:return[]}}function qh(e,t,n,r){const o=Jt(e);let s=zh(Ke(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(is)))),s}function Br(e){const t=Ke(e);return $h[t]+e.slice(t.length)}function Gh(e){return{top:0,right:0,bottom:0,left:0,...e}}function xl(e){return typeof e!="number"?Gh(e):{top:e,right:e,bottom:e,left:e}}function $r(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}var Kh=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Yr=Kh.join(","),wl=typeof Element>"u",In=wl?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Hr=!wl&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e?.ownerDocument},Ur=function(t,n){var r;n===void 0&&(n=!0);var o=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),s=o===""||o==="true",a=s||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):Ur(t.parentNode));return a},Xh=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},vl=function(t,n,r){if(Ur(t))return[];var o=Array.prototype.slice.apply(t.querySelectorAll(Yr));return n&&In.call(t,Yr)&&o.unshift(t),o=o.filter(r),o},Vr=function(t,n,r){for(var o=[],s=Array.from(t);s.length;){var a=s.shift();if(!Ur(a,!1))if(a.tagName==="SLOT"){var i=a.assignedElements(),l=i.length?i:a.children,c=Vr(l,!0,r);r.flatten?o.push.apply(o,c):o.push({scopeParent:a,candidates:c})}else{var u=In.call(a,Yr);u&&r.filter(a)&&(n||!t.includes(a))&&o.push(a);var f=a.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(a),m=!Ur(f,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(a));if(f&&m){var p=Vr(f===!0?a.children:f.children,!0,r);r.flatten?o.push.apply(o,p):o.push({scopeParent:a,candidates:p})}else s.unshift.apply(s,a.children)}}return o},kl=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Sl=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||Xh(t))&&!kl(t)?0:t.tabIndex},Jh=function(t,n){var r=Sl(t);return r<0&&n&&!kl(t)?0:r},Qh=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Cl=function(t){return t.tagName==="INPUT"},Zh=function(t){return Cl(t)&&t.type==="hidden"},em=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},tm=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},nm=function(t){if(!t.name)return!0;var n=t.form||Hr(t),r=function(i){return n.querySelectorAll('input[type="radio"][name="'+i+'"]')},o;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")o=r(window.CSS.escape(t.name));else try{o=r(t.name)}catch(a){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",a.message),!1}var s=tm(o,t.form);return!s||s===t},rm=function(t){return Cl(t)&&t.type==="radio"},om=function(t){return rm(t)&&!nm(t)},sm=function(t){var n,r=t&&Hr(t),o=(n=r)===null||n===void 0?void 0:n.host,s=!1;if(r&&r!==t){var a,i,l;for(s=!!((a=o)!==null&&a!==void 0&&(i=a.ownerDocument)!==null&&i!==void 0&&i.contains(o)||t!=null&&(l=t.ownerDocument)!==null&&l!==void 0&&l.contains(t));!s&&o;){var c,u,f;r=Hr(o),o=(c=r)===null||c===void 0?void 0:c.host,s=!!((u=o)!==null&&u!==void 0&&(f=u.ownerDocument)!==null&&f!==void 0&&f.contains(o))}}return s},Ia=function(t){var n=t.getBoundingClientRect(),r=n.width,o=n.height;return r===0&&o===0},am=function(t,n){var r=n.displayCheck,o=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in t){var s=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!s}if(getComputedStyle(t).visibility==="hidden")return!0;var a=In.call(t,"details>summary:first-of-type"),i=a?t.parentElement:t;if(In.call(i,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof o=="function"){for(var l=t;t;){var c=t.parentElement,u=Hr(t);if(c&&!c.shadowRoot&&o(c)===!0)return Ia(t);t.assignedSlot?t=t.assignedSlot:!c&&u!==t.ownerDocument?t=u.host:t=c}t=l}if(sm(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return Ia(t);return!1},im=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var o=n.children.item(r);if(o.tagName==="LEGEND")return In.call(n,"fieldset[disabled] *")?!0:!o.contains(t)}return!0}n=n.parentElement}return!1},ls=function(t,n){return!(n.disabled||Zh(n)||am(n,t)||em(n)||im(n))},cs=function(t,n){return!(om(n)||Sl(n)<0||!ls(t,n))},lm=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Ml=function(t){var n=[],r=[];return t.forEach(function(o,s){var a=!!o.scopeParent,i=a?o.scopeParent:o,l=Jh(i,a),c=a?Ml(o.candidates):i;l===0?a?n.push.apply(n,c):n.push(i):r.push({documentOrder:s,tabIndex:l,item:o,isScope:a,content:c})}),r.sort(Qh).reduce(function(o,s){return s.isScope?o.push.apply(o,s.content):o.push(s.content),o},[]).concat(n)},cr=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Vr([t],n.includeContainer,{filter:cs.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:lm}):r=vl(t,n.includeContainer,cs.bind(null,n)),Ml(r)},cm=function(t,n){n=n||{};var r;return n.getShadowRoot?r=Vr([t],n.includeContainer,{filter:ls.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=vl(t,n.includeContainer,ls.bind(null,n)),r},Tl=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return In.call(t,Yr)===!1?!1:cs(n,t)};const $n=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function El(e,t){const n=cr(e,$n()),r=n.length;if(r===0)return;const o=Tn($e(e)),s=n.indexOf(o),a=s===-1?t===1?0:r-1:s+t;return n[a]}function Rs(e){return El($e(e).body,1)||e}function Nl(e){return El($e(e).body,-1)||e}function Dl(e,t){if(!e)return null;const n=cr($e(e).body,$n()),r=n.length;if(r===0)return null;const o=n.indexOf(e);if(o===-1)return null;const s=(o+t+r)%r;return n[s]}function um(e){return Dl(e,1)}function dm(e){return Dl(e,-1)}function Dn(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!ke(n,r)}function fm(e){cr(e,$n()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Fa(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}const hm={...Id};let La=0;function mm(e,t="mui"){const[n,r]=h.useState(e),o=e||n;return h.useEffect(()=>{n==null&&(La+=1,r(`${t}-${La}`))},[n,t]),o}const Wa=hm.useId;function Yn(e,t){if(Wa!==void 0){const n=Wa();return e??(t?`${t}-${n}`:n)}return mm(e,t)}function Ol(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(r=>r(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}class gm{nodesRef={current:[]};events=Ol();addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(r=>r===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const Rl=h.createContext(null),jl=h.createContext(null),yn=()=>h.useContext(Rl)?.id||null,Hn=e=>{const t=h.useContext(jl);return e??t};function pm(e){const t=Yn(),n=Hn(e),r=yn();return Ce(()=>{if(!t)return;const o={id:t,parentId:r};return n?.addNode(o),()=>{n?.removeNode(o)}},[n,t,r]),t}function ym(e){const{children:t,id:n}=e,r=yn();return d.jsx(Rl.Provider,{value:h.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function bm(e){const{children:t,externalTree:n}=e,r=Xt(()=>n??new gm).current;return d.jsx(jl.Provider,{value:r,children:t})}const xm="none",qt="trigger-press",nt="trigger-hover",_l="outside-press",wm="close-press",nr="focus-out",Al="escape-key",Pl="imperative-action";function je(e,t,n,r){let o=!1,s=!1;const a=zt;return{reason:e,event:t??new Event("base-ui"),cancel(){o=!0},allowPropagation(){s=!0},get isCanceled(){return o},get isPropagationAllowed(){return s},trigger:n,...a}}function rr(e){return`data-base-ui-${e}`}function Ao(e,t,n){if(n&&!An(n))return 0;if(typeof e=="number")return e;if(typeof e=="function"){const r=e();return typeof r=="number"?r:r?.[t]}return e?.[t]}function bn(e){return e?.ownerDocument||document}const Fn=h.forwardRef(function(t,n){const[r,o]=h.useState();Ce(()=>{Oh&&o("button")},[]);const s={tabIndex:0,role:r};return d.jsx("span",{...t,ref:n,style:il,"aria-hidden":r?void 0:!0,...s,"data-base-ui-focus-guard":""})});let Ba=0;function Po(e,t={}){const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(Ba);const s=()=>e?.focus({preventScroll:n});o?s():Ba=requestAnimationFrame(s)}const On={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function $a(e){return e==="inert"?On.inert:e==="aria-hidden"?On["aria-hidden"]:On.none}let Er=new WeakSet,Nr={},Io=0;const Il=e=>e&&(e.host||Il(e.parentNode)),vm=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=Il(n);return e.contains(r)?r:null}).filter(n=>n!=null);function km(e,t,n,r){const o="data-base-ui-inert",s=r?"inert":n?"aria-hidden":null,a=vm(t,e),i=new Set,l=new Set(a),c=[];Nr[o]||(Nr[o]=new WeakMap);const u=Nr[o];a.forEach(f),m(t),i.clear();function f(p){!p||i.has(p)||(i.add(p),p.parentNode&&f(p.parentNode))}function m(p){!p||l.has(p)||[].forEach.call(p.children,g=>{if(ir(g)!=="script")if(i.has(g))m(g);else{const y=s?g.getAttribute(s):null,b=y!==null&&y!=="false",v=$a(s),x=(v.get(g)||0)+1,w=(u.get(g)||0)+1;v.set(g,x),u.set(g,w),c.push(g),x===1&&b&&Er.add(g),w===1&&g.setAttribute(o,""),!b&&s&&g.setAttribute(s,s==="inert"?"":"true")}})}return Io+=1,()=>{c.forEach(p=>{const g=$a(s),b=(g.get(p)||0)-1,v=(u.get(p)||0)-1;g.set(p,b),u.set(p,v),b||(!Er.has(p)&&s&&p.removeAttribute(s),Er.delete(p)),v||p.removeAttribute(o)}),Io-=1,Io||(On.inert=new WeakMap,On["aria-hidden"]=new WeakMap,On.none=new WeakMap,Er=new WeakSet,Nr={})}}function Sm(e,t=!1,n=!1){const r=$e(e[0]).body;return km(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const Fl=h.createContext(null),Ll=()=>h.useContext(Fl),Cm=rr("portal");function Mm(e={}){const{ref:t,container:n,componentProps:r=zt,elementProps:o,elementState:s}=e,a=Yn(),l=Ll()?.portalNode,[c,u]=h.useState(null),[f,m]=h.useState(null),p=me(v=>{v!==null&&m(v)}),g=h.useRef(null);Ce(()=>{if(n===null){g.current&&(g.current=null,m(null),u(null));return}if(a==null)return;const v=(n&&(Fd(n)?n:n.current))??l??document.body;if(v==null){g.current&&(g.current=null,m(null),u(null));return}g.current!==v&&(g.current=v,m(null),u(v))},[n,l,a]);const y=It("div",r,{ref:[t,p],state:s,props:[{id:a,[Cm]:""},o]});return{portalNode:f,portalSubtree:c&&y?Gt.createPortal(y,c):null}}const Wl=h.forwardRef(function(t,n){const{children:r,container:o,className:s,render:a,renderGuards:i,...l}=t,{portalNode:c,portalSubtree:u}=Mm({container:o,ref:n,componentProps:t,elementProps:l}),f=h.useRef(null),m=h.useRef(null),p=h.useRef(null),g=h.useRef(null),[y,b]=h.useState(null),v=y?.modal,x=y?.open,w=typeof i=="boolean"?i:!!y&&!y.modal&&y.open&&!!c;h.useEffect(()=>{if(!c||v)return;function C(S){c&&S.relatedTarget&&Dn(S)&&(S.type==="focusin"?Fa:fm)(c)}return c.addEventListener("focusin",C,!0),c.addEventListener("focusout",C,!0),()=>{c.removeEventListener("focusin",C,!0),c.removeEventListener("focusout",C,!0)}},[c,v]),h.useEffect(()=>{!c||x||Fa(c)},[x,c]);const k=h.useMemo(()=>({beforeOutsideRef:f,afterOutsideRef:m,beforeInsideRef:p,afterInsideRef:g,portalNode:c,setFocusManagerState:b}),[c]);return d.jsxs(h.Fragment,{children:[u,d.jsxs(Fl.Provider,{value:k,children:[w&&c&&d.jsx(Fn,{"data-type":"outside",ref:f,onFocus:C=>{if(Dn(C,c))p.current?.focus();else{const S=y?y.domReference:null;Nl(S)?.focus()}}}),w&&c&&d.jsx("span",{"aria-owns":c.id,style:sf}),c&&Gt.createPortal(r,c),w&&c&&d.jsx(Fn,{"data-type":"outside",ref:m,onFocus:C=>{if(Dn(C,c))g.current?.focus();else{const S=y?y.domReference:null;Rs(S)?.focus(),y?.closeOnFocusOut&&y?.onOpenChange(!1,je(nr,C.nativeEvent))}}})]})]})});function jt(e){return e==null?e:"current"in e?e.current:e}function Tm(e,t){const n=lt(e.target);return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const Ya=20;let Vt=[];function js(){Vt=Vt.filter(e=>e.isConnected)}function Em(e){js(),e&&ir(e)!=="body"&&(Vt.push(e),Vt.length>Ya&&(Vt=Vt.slice(-Ya)))}function Fo(){return js(),Vt[Vt.length-1]}function Nm(e){if(!e)return null;const t=$n();return Tl(e,t)?e:cr(e,t)[0]||e}function Dm(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():pt(e).display!=="none"}function Ha(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=$n(),o=cm(e,n).filter(a=>{const i=a.getAttribute("data-tabindex")||"";return Tl(a,n)||a.hasAttribute("data-tabindex")&&!i.startsWith("-")}),s=e.getAttribute("tabindex");t.current.includes("floating")||o.length===0?s!=="0"&&e.setAttribute("tabindex","0"):(s!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function Bl(e){const{context:t,children:n,disabled:r=!1,order:o=["content"],initialFocus:s=!0,returnFocus:a=!0,restoreFocus:i=!1,modal:l=!0,closeOnFocusOut:c=!0,openInteractionType:u="",getInsideElements:f=()=>[],nextFocusableElement:m,previousFocusableElement:p,beforeContentFocusGuardRef:g,externalTree:y}=e,b="rootStore"in t?t.rootStore:t,v=b.useState("open"),x=b.useState("domReferenceElement"),w=b.useState("floatingElement"),{events:k,dataRef:C}=b.context,S=me(()=>C.current.floatingContext?.nodeId),T=me(f),M=s===!1,A=ja(x)&&M,R=kt(o),D=kt(s),_=kt(a),E=kt(u),I=Hn(y),j=Ll(),B=h.useRef(null),H=h.useRef(null),O=h.useRef(!1),F=h.useRef(!1),V=h.useRef(!1),$=h.useRef(-1),Q=h.useRef(""),U=h.useRef(""),W=h.useRef(null),K=h.useRef(null),G=pa(W,g,j?.beforeInsideRef),te=pa(K,j?.afterInsideRef),xe=hn(),Ee=hn(),be=Es(),_e=j!=null,P=ss(w),le=me((Y=P)=>Y?cr(Y,$n()):[]),X=me(Y=>{const z=le(Y);return R.current.map(()=>z).filter(Boolean).flat()});h.useEffect(()=>{if(r||!l)return;function Y(Z){Z.key==="Tab"&&ke(P,Tn($e(P)))&&le().length===0&&!A&&Ih(Z)}const z=$e(P);return z.addEventListener("keydown",Y),()=>{z.removeEventListener("keydown",Y)}},[r,x,P,l,R,A,le,X]),h.useEffect(()=>{if(r||!w)return;function Y(z){const Z=et(z),ge=le().indexOf(Z);ge!==-1&&($.current=ge)}return w.addEventListener("focusin",Y),()=>{w.removeEventListener("focusin",Y)}},[r,w,le]),h.useEffect(()=>{if(r||!v)return;const Y=$e(P);function z(){V.current=!1}function Z(ge){const ae=et(ge),re=ke(w,ae)||ke(x,ae)||ke(j?.portalNode,ae);V.current=!re,U.current=ge.pointerType||"keyboard"}function fe(){U.current="keyboard"}return Y.addEventListener("pointerdown",Z,!0),Y.addEventListener("pointerup",z,!0),Y.addEventListener("pointercancel",z,!0),Y.addEventListener("keydown",fe,!0),()=>{Y.removeEventListener("pointerdown",Z,!0),Y.removeEventListener("pointerup",z,!0),Y.removeEventListener("pointercancel",z,!0),Y.removeEventListener("keydown",fe,!0)}},[r,w,x,P,v,j]),h.useEffect(()=>{if(r||!c)return;function Y(){F.current=!0,Ee.start(0,()=>{F.current=!1})}function z(ae){const re=ae.relatedTarget,we=ae.currentTarget,Se=et(ae);queueMicrotask(()=>{const Ae=S(),Xe=b.context.triggerElements,ot=re?.hasAttribute(rr("focus-guard"))&&[W.current,K.current,j?.beforeInsideRef.current,j?.afterInsideRef.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,jt(p),jt(m)].includes(re),He=!(ke(x,re)||ke(w,re)||ke(re,w)||ke(j?.portalNode,re)||re!=null&&Xe.hasElement(re)||Xe.hasMatchingElement(ce=>ke(ce,re))||ot||I&&(dn(I.nodesRef.current,Ae).find(ce=>ke(ce.context?.elements.floating,re)||ke(ce.context?.elements.domReference,re))||_a(I.nodesRef.current,Ae).find(ce=>[ce.context?.elements.floating,ss(ce.context?.elements.floating)].includes(re)||ce.context?.elements.domReference===re)));if(we===x&&P&&Ha(P,R),i&&we!==x&&!Dm(Se)&&Tn($e(P))===$e(P).body){if(ze(P)&&(P.focus(),i==="popup")){be.request(()=>{P.focus()});return}const ce=$.current,Ye=le(),Oe=Ye[ce]||Ye[Ye.length-1]||P;ze(Oe)&&Oe.focus()}if(C.current.insideReactTree){C.current.insideReactTree=!1;return}(A||!l)&&re&&He&&!F.current&&(A||re!==Fo())&&(O.current=!0,b.setOpen(!1,je(nr,ae)))})}function Z(){V.current||(C.current.insideReactTree=!0,xe.start(0,()=>{C.current.insideReactTree=!1}))}const fe=ze(x)?x:null,ge=[];if(!(!w&&!fe))return fe&&(fe.addEventListener("focusout",z),fe.addEventListener("pointerdown",Y),ge.push(()=>{fe.removeEventListener("focusout",z),fe.removeEventListener("pointerdown",Y)})),w&&(w.addEventListener("focusout",z),j&&(w.addEventListener("focusout",Z,!0),ge.push(()=>{w.removeEventListener("focusout",Z,!0)})),ge.push(()=>{w.removeEventListener("focusout",z)})),()=>{ge.forEach(ae=>{ae()})}},[r,x,w,P,l,I,j,b,c,i,le,A,S,R,C,xe,Ee,be,m,p]),h.useEffect(()=>{if(r||!w||!v)return;const Y=Array.from(j?.portalNode?.querySelectorAll(`[${rr("portal")}]`)||[]),Z=(I?_a(I.nodesRef.current,S()):[]).find(ae=>ja(ae.context?.elements.domReference||null))?.context?.elements.domReference,fe=[w,Z,...Y,...T(),B.current,H.current,W.current,K.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,jt(p),jt(m),A?x:null].filter(ae=>ae!=null),ge=Sm(fe,l||A);return()=>{ge()}},[v,r,x,w,l,R,j,A,I,S,T,m,p]),Ce(()=>{if(!v||r||!ze(P))return;const Y=$e(P),z=Tn(Y);queueMicrotask(()=>{const Z=X(P),fe=D.current,ge=typeof fe=="function"?fe(E.current||""):fe;if(ge===void 0||ge===!1)return;let ae;ge===!0||ge===null?ae=Z[0]||P:ae=jt(ge),ae=ae||Z[0]||P,!ke(P,z)&&Po(ae,{preventScroll:ae===P})})},[r,v,P,M,X,D,E]),Ce(()=>{if(r||!P)return;const Y=$e(P),z=Tn(Y);Em(z);function Z(ae){if(ae.open||(Q.current=Tm(ae.nativeEvent,U.current)),ae.reason===nt&&ae.nativeEvent.type==="mouseleave"&&(O.current=!0),ae.reason===_l)if(ae.nested)O.current=!1;else if(Lh(ae.nativeEvent)||Wh(ae.nativeEvent))O.current=!1;else{let re=!1;document.createElement("div").focus({get preventScroll(){return re=!0,!1}}),re?O.current=!1:O.current=!0}}k.on("openchange",Z);const fe=Y.createElement("span");fe.setAttribute("tabindex","-1"),fe.setAttribute("aria-hidden","true"),Object.assign(fe.style,il),_e&&x&&x.insertAdjacentElement("afterend",fe);function ge(){const ae=_.current;let re=typeof ae=="function"?ae(Q.current):ae;if(re===void 0||re===!1)return null;if(re===null&&(re=!0),typeof re=="boolean"){const Se=x||Fo();return Se&&Se.isConnected?Se:fe}const we=x||Fo()||fe;return jt(re)||we}return()=>{k.off("openchange",Z);const ae=Tn(Y),re=ke(w,ae)||I&&dn(I.nodesRef.current,S(),!1).some(Se=>ke(Se.context?.elements.floating,ae)),we=ge();queueMicrotask(()=>{const Se=Nm(we),Ae=typeof _.current!="boolean";_.current&&!O.current&&ze(Se)&&(!(!Ae&&Se!==ae&&ae!==Y.body)||re)&&Se.focus({preventScroll:!0}),fe.remove()})}},[r,w,P,_,C,k,I,_e,x,S]),h.useEffect(()=>{queueMicrotask(()=>{O.current=!1})},[r]),h.useEffect(()=>{if(r||!v)return;function Y(Z){et(Z)?.closest(`[${Qi}]`)&&(F.current=!0)}const z=$e(P);return z.addEventListener("pointerdown",Y,!0),()=>{z.removeEventListener("pointerdown",Y,!0)}},[r,v,P]),Ce(()=>{if(!r&&j)return j.setFocusManagerState({modal:l,closeOnFocusOut:c,open:v,onOpenChange:b.setOpen,domReference:x}),()=>{j.setFocusManagerState(null)}},[r,j,l,v,b,c,x]),Ce(()=>{if(!(r||!P))return Ha(P,R),()=>{queueMicrotask(js)}},[r,P,R]);const ye=!r&&(l?!A:!0)&&(_e||l);return d.jsxs(h.Fragment,{children:[ye&&d.jsx(Fn,{"data-type":"inside",ref:G,onFocus:Y=>{if(l){const z=X();Po(z[z.length-1])}else j?.portalNode&&(O.current=!1,Dn(Y,j.portalNode)?Rs(x)?.focus():jt(p??j.beforeOutsideRef)?.focus())}}),n,ye&&d.jsx(Fn,{"data-type":"inside",ref:te,onFocus:Y=>{l?Po(X()[0]):j?.portalNode&&(c&&(O.current=!0),Dn(Y,j.portalNode)?Nl(x)?.focus():jt(m??j.afterOutsideRef)?.focus())}})]})}function Om(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.context.dataRef,{enabled:o=!0,event:s="click",toggle:a=!0,ignoreMouse:i=!1,stickIfOpen:l=!0,touchOpenDelay:c=0}=t,u=h.useRef(void 0),f=Es(),m=hn(),p=h.useMemo(()=>({onPointerDown(g){u.current=g.pointerType},onMouseDown(g){const y=u.current,b=g.nativeEvent,v=n.select("open");if(g.button!==0||s==="click"||An(y,!0)&&i)return;const x=r.current.openEvent,w=x?.type,k=n.select("domReferenceElement")!==g.currentTarget,C=v&&k||!(v&&a&&(!(x&&l)||w==="click"||w==="mousedown"));if(yl(b.target)){const T=je(qt,b,b.target);C&&y==="touch"&&c>0?m.start(c,()=>{n.setOpen(!0,T)}):n.setOpen(C,T);return}const S=g.currentTarget;f.request(()=>{const T=je(qt,b,S);C&&y==="touch"&&c>0?m.start(c,()=>{n.setOpen(!0,T)}):n.setOpen(C,T)})},onClick(g){if(s==="mousedown-only")return;const y=u.current;if(s==="mousedown"&&y){u.current=void 0;return}if(An(y,!0)&&i)return;const b=n.select("open"),v=r.current.openEvent,x=n.select("domReferenceElement")!==g.currentTarget,w=b&&x||!(b&&a&&(!(v&&l)||bl(v))),k=je(qt,g.nativeEvent,g.currentTarget);w&&y==="touch"&&c>0?m.start(c,()=>{n.setOpen(!0,k)}):n.setOpen(w,k)},onKeyDown(){u.current=void 0}}),[r,s,i,n,l,a,f,m,c]);return h.useMemo(()=>o?{reference:p}:zt,[o,p])}function Ua(e,t,n){let{reference:r,floating:o}=e;const s=it(t),a=Os(t),i=Ds(a),l=Ke(t),c=s==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,m=r[i]/2-o[i]/2;let p;switch(l){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Jt(t)){case"start":p[a]-=m*(n&&c?-1:1);break;case"end":p[a]+=m*(n&&c?-1:1);break}return p}async function Rm(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:a,elements:i,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:m=!1,padding:p=0}=Pt(t,e),g=xl(p),b=i[m?f==="floating"?"reference":"floating":f],v=$r(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(i.floating)),boundary:c,rootBoundary:u,strategy:l})),x=f==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,w=await(s.getOffsetParent==null?void 0:s.getOffsetParent(i.floating)),k=await(s.isElement==null?void 0:s.isElement(w))?await(s.getScale==null?void 0:s.getScale(w))||{x:1,y:1}:{x:1,y:1},C=$r(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:x,offsetParent:w,strategy:l}):x);return{top:(v.top-C.top+g.top)/k.y,bottom:(C.bottom-v.bottom+g.bottom)/k.y,left:(v.left-C.left+g.left)/k.x,right:(C.right-v.right+g.right)/k.x}}const jm=50,_m=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:a}=n,i=a.detectOverflow?a:{...a,detectOverflow:Rm},l=await(a.isRTL==null?void 0:a.isRTL(t));let c=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:f}=Ua(c,r,l),m=r,p=0;const g={};for(let y=0;y<s.length;y++){const b=s[y];if(!b)continue;const{name:v,fn:x}=b,{x:w,y:k,data:C,reset:S}=await x({x:u,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:g,rects:c,platform:i,elements:{reference:e,floating:t}});u=w??u,f=k??f,g[v]={...g[v],...C},S&&p<jm&&(p++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(c=S.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:u,y:f}=Ua(c,m,l)),y=-1)}return{x:u,y:f,placement:m,strategy:o,middlewareData:g}},Am=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:a,initialPlacement:i,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...b}=Pt(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=Ke(o),x=it(i),w=Ke(i)===i,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(w||!y?[Br(i)]:Hh(i)),S=g!=="none";!m&&S&&C.push(...qh(i,y,g,k));const T=[i,...C],M=await l.detectOverflow(t,b),A=[];let R=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&A.push(M[v]),f){const I=Yh(o,a,k);A.push(M[I[0]],M[I[1]])}if(R=[...R,{placement:o,overflows:A}],!A.every(I=>I<=0)){var D,_;const I=(((D=s.flip)==null?void 0:D.index)||0)+1,j=T[I];if(j&&(!(f==="alignment"?x!==it(j):!1)||R.every(O=>it(O.placement)===x?O.overflows[0]>0:!0)))return{data:{index:I,overflows:R},reset:{placement:j}};let B=(_=R.filter(H=>H.overflows[0]<=0).sort((H,O)=>H.overflows[1]-O.overflows[1])[0])==null?void 0:_.placement;if(!B)switch(p){case"bestFit":{var E;const H=(E=R.filter(O=>{if(S){const F=it(O.placement);return F===x||F==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(F=>F>0).reduce((F,V)=>F+V,0)]).sort((O,F)=>O[1]-F[1])[0])==null?void 0:E[0];H&&(B=H);break}case"initialPlacement":B=i;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function Va(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function za(e){return Bh.some(t=>e[t]>=0)}const Pm=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...s}=Pt(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),i=Va(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:za(i)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),i=Va(a,n.floating);return{data:{escapedOffsets:i,escaped:za(i)}}}default:return{}}}}},$l=new Set(["left","top"]);async function Im(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Ke(n),i=Jt(n),l=it(n)==="y",c=$l.has(a)?-1:1,u=s&&l?-1:1,f=Pt(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return i&&typeof g=="number"&&(p=i==="end"?g*-1:g),l?{x:p*u,y:m*c}:{x:m*c,y:p*u}}const Fm=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:a,middlewareData:i}=t,l=await Im(t,e);return a===((n=i.offset)==null?void 0:n.placement)&&(r=i.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:a}}}}},Lm=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:s}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:l={fn:v=>{let{x,y:w}=v;return{x,y:w}}},...c}=Pt(e,t),u={x:n,y:r},f=await s.detectOverflow(t,c),m=it(Ke(o)),p=Ns(m);let g=u[p],y=u[m];if(a){const v=p==="y"?"top":"left",x=p==="y"?"bottom":"right",w=g+f[v],k=g-f[x];g=as(w,g,k)}if(i){const v=m==="y"?"top":"left",x=m==="y"?"bottom":"right",w=y+f[v],k=y-f[x];y=as(w,y,k)}const b=l.fn({...t,[p]:g,[m]:y});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[p]:a,[m]:i}}}}}},Wm=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:a}=t,{offset:i=0,mainAxis:l=!0,crossAxis:c=!0}=Pt(e,t),u={x:n,y:r},f=it(o),m=Ns(f);let p=u[m],g=u[f];const y=Pt(i,t),b=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(l){const w=m==="y"?"height":"width",k=s.reference[m]-s.floating[w]+b.mainAxis,C=s.reference[m]+s.reference[w]-b.mainAxis;p<k?p=k:p>C&&(p=C)}if(c){var v,x;const w=m==="y"?"width":"height",k=$l.has(Ke(o)),C=s.reference[f]-s.floating[w]+(k&&((v=a.offset)==null?void 0:v[f])||0)+(k?0:b.crossAxis),S=s.reference[f]+s.reference[w]+(k?0:((x=a.offset)==null?void 0:x[f])||0)-(k?b.crossAxis:0);g<C?g=C:g>S&&(g=S)}return{[m]:p,[f]:g}}}},Bm=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:a,elements:i}=t,{apply:l=()=>{},...c}=Pt(e,t),u=await a.detectOverflow(t,c),f=Ke(o),m=Jt(o),p=it(o)==="y",{width:g,height:y}=s.floating;let b,v;f==="top"||f==="bottom"?(b=f,v=m===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(v=f,b=m==="end"?"top":"bottom");const x=y-u.top-u.bottom,w=g-u.left-u.right,k=Pn(y-u[b],x),C=Pn(g-u[v],w),S=!t.middlewareData.shift;let T=k,M=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(M=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(T=x),S&&!m){const R=tt(u.left,0),D=tt(u.right,0),_=tt(u.top,0),E=tt(u.bottom,0);p?M=g-2*(R!==0||D!==0?R+D:tt(u.left,u.right)):T=y-2*(_!==0||E!==0?_+E:tt(u.top,u.bottom))}await l({...t,availableWidth:M,availableHeight:T});const A=await a.getDimensions(i.floating);return g!==A.width||y!==A.height?{reset:{rects:!0}}:{}}}};function Yl(e){const t=pt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=ze(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,i=Wr(n)!==s||Wr(r)!==a;return i&&(n=s,r=a),{width:n,height:r,$:i}}function _s(e){return De(e)?e:e.contextElement}function Rn(e){const t=_s(e);if(!ze(t))return Mt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Yl(t);let a=(s?Wr(n.width):n.width)/r,i=(s?Wr(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const $m=Mt(0);function Hl(e){const t=lt(e);return!xs()||!t.visualViewport?$m:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ym(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==lt(e)?!1:t}function mn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=_s(e);let a=Mt(1);t&&(r?De(r)&&(a=Rn(r)):a=Rn(e));const i=Ym(s,n,r)?Hl(s):Mt(0);let l=(o.left+i.x)/a.x,c=(o.top+i.y)/a.y,u=o.width/a.x,f=o.height/a.y;if(s){const m=lt(s),p=r&&De(r)?lt(r):r;let g=m,y=ya(g);for(;y&&r&&p!==g;){const b=Rn(y),v=y.getBoundingClientRect(),x=pt(y),w=v.left+(y.clientLeft+parseFloat(x.paddingLeft))*b.x,k=v.top+(y.clientTop+parseFloat(x.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,f*=b.y,l+=w,c+=k,g=lt(y),y=ya(g)}}return $r({width:u,height:f,x:l,y:c})}function Zr(e,t){const n=Xr(e).scrollLeft;return t?t.left+n:mn(Ft(e)).left+n}function Ul(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Zr(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Hm(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=Ft(r),i=t?ws(t.floating):!1;if(r===a||i&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Mt(1);const u=Mt(0),f=ze(r);if((f||!f&&!s)&&((ir(r)!=="body"||lr(a))&&(l=Xr(r)),f)){const p=mn(r);c=Rn(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const m=a&&!f&&!s?Ul(a,l):Mt(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+m.x,y:n.y*c.y-l.scrollTop*c.y+u.y+m.y}}function Um(e){return Array.from(e.getClientRects())}function Vm(e){const t=Ft(e),n=Xr(e),r=e.ownerDocument.body,o=tt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=tt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Zr(e);const i=-n.scrollTop;return pt(r).direction==="rtl"&&(a+=tt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:i}}const qa=25;function zm(e,t){const n=lt(e),r=Ft(e),o=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,i=0,l=0;if(o){s=o.width,a=o.height;const u=xs();(!u||u&&t==="fixed")&&(i=o.offsetLeft,l=o.offsetTop)}const c=Zr(r);if(c<=0){const u=r.ownerDocument,f=u.body,m=getComputedStyle(f),p=u.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(r.clientWidth-f.clientWidth-p);g<=qa&&(s-=g)}else c<=qa&&(s+=c);return{width:s,height:a,x:i,y:l}}function qm(e,t){const n=mn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=ze(e)?Rn(e):Mt(1),a=e.clientWidth*s.x,i=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:a,height:i,x:l,y:c}}function Ga(e,t,n){let r;if(t==="viewport")r=zm(e,n);else if(t==="document")r=Vm(Ft(e));else if(De(t))r=qm(t,n);else{const o=Hl(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return $r(r)}function Vl(e,t){const n=_n(e);return n===t||!De(n)||un(n)?!1:pt(n).position==="fixed"||Vl(n,t)}function Gm(e,t){const n=t.get(e);if(n)return n;let r=Nn(e,[],!1).filter(i=>De(i)&&ir(i)!=="body"),o=null;const s=pt(e).position==="fixed";let a=s?_n(e):e;for(;De(a)&&!un(a);){const i=pt(a),l=Gi(a);!l&&i.position==="fixed"&&(o=null),(s?!l&&!o:!l&&i.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||lr(a)&&!l&&Vl(e,a))?r=r.filter(u=>u!==a):o=i,a=_n(a)}return t.set(e,r),r}function Km(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?ws(t)?[]:Gm(t,this._c):[].concat(n),r],i=Ga(t,a[0],o);let l=i.top,c=i.right,u=i.bottom,f=i.left;for(let m=1;m<a.length;m++){const p=Ga(t,a[m],o);l=tt(p.top,l),c=Pn(p.right,c),u=Pn(p.bottom,u),f=tt(p.left,f)}return{width:c-f,height:u-l,x:f,y:l}}function Xm(e){const{width:t,height:n}=Yl(e);return{width:t,height:n}}function Jm(e,t,n){const r=ze(t),o=Ft(t),s=n==="fixed",a=mn(e,!0,s,t);let i={scrollLeft:0,scrollTop:0};const l=Mt(0);function c(){l.x=Zr(o)}if(r||!r&&!s)if((ir(t)!=="body"||lr(o))&&(i=Xr(t)),r){const p=mn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?Ul(o,i):Mt(0),f=a.left+i.scrollLeft-l.x-u.x,m=a.top+i.scrollTop-l.y-u.y;return{x:f,y:m,width:a.width,height:a.height}}function Lo(e){return pt(e).position==="static"}function Ka(e,t){if(!ze(e)||pt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ft(e)===n&&(n=n.ownerDocument.body),n}function zl(e,t){const n=lt(e);if(ws(e))return n;if(!ze(e)){let o=_n(e);for(;o&&!un(o);){if(De(o)&&!Lo(o))return o;o=_n(o)}return n}let r=Ka(e,t);for(;r&&Ld(r)&&Lo(r);)r=Ka(r,t);return r&&un(r)&&Lo(r)&&!Gi(r)?n:r||Wd(e)||n}const Qm=async function(e){const t=this.getOffsetParent||zl,n=this.getDimensions,r=await n(e.floating);return{reference:Jm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Zm(e){return pt(e).direction==="rtl"}const eg={convertOffsetParentRelativeRectToViewportRelativeRect:Hm,getDocumentElement:Ft,getClippingRect:Km,getOffsetParent:zl,getElementRects:Qm,getClientRects:Um,getDimensions:Xm,getScale:Rn,isElement:De,isRTL:Zm};function ql(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function tg(e,t){let n=null,r;const o=Ft(e);function s(){var i;clearTimeout(r),(i=n)==null||i.disconnect(),n=null}function a(i,l){i===void 0&&(i=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:u,top:f,width:m,height:p}=c;if(i||t(),!m||!p)return;const g=Tr(f),y=Tr(o.clientWidth-(u+m)),b=Tr(o.clientHeight-(f+p)),v=Tr(u),w={rootMargin:-g+"px "+-y+"px "+-b+"px "+-v+"px",threshold:tt(0,Pn(1,l))||1};let k=!0;function C(S){const T=S[0].intersectionRatio;if(T!==l){if(!k)return a();T?a(!1,T):r=setTimeout(()=>{a(!1,1e-7)},1e3)}T===1&&!ql(c,e.getBoundingClientRect())&&a(),k=!1}try{n=new IntersectionObserver(C,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,w)}n.observe(e)}return a(!0),s}function Xa(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=_s(e),u=o||s?[...c?Nn(c):[],...t?Nn(t):[]]:[];u.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const f=c&&i?tg(c,n):null;let m=-1,p=null;a&&(p=new ResizeObserver(v=>{let[x]=v;x&&x.target===c&&p&&t&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var w;(w=p)==null||w.observe(t)})),n()}),c&&!l&&p.observe(c),t&&p.observe(t));let g,y=l?mn(e):null;l&&b();function b(){const v=mn(e);y&&!ql(y,v)&&n(),y=v,g=requestAnimationFrame(b)}return n(),()=>{var v;u.forEach(x=>{o&&x.removeEventListener("scroll",n),s&&x.removeEventListener("resize",n)}),f?.(),(v=p)==null||v.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const ng=Fm,rg=Lm,og=Am,sg=Bm,ag=Pm,ig=Wm,lg=(e,t,n)=>{const r=new Map,o={platform:eg,...n},s={...o.platform,_c:r};return _m(e,t,{...o,platform:s})};var cg=typeof document<"u",ug=function(){},Ar=cg?h.useLayoutEffect:ug;function zr(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,o;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(!zr(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!zr(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Gl(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ja(e,t){const n=Gl(e);return Math.round(t*n)/n}function Wo(e){const t=h.useRef(e);return Ar(()=>{t.current=e}),t}function dg(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:a}={},transform:i=!0,whileElementsMounted:l,open:c}=e,[u,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=h.useState(r);zr(m,r)||p(r);const[g,y]=h.useState(null),[b,v]=h.useState(null),x=h.useCallback(O=>{O!==S.current&&(S.current=O,y(O))},[]),w=h.useCallback(O=>{O!==T.current&&(T.current=O,v(O))},[]),k=s||g,C=a||b,S=h.useRef(null),T=h.useRef(null),M=h.useRef(u),A=l!=null,R=Wo(l),D=Wo(o),_=Wo(c),E=h.useCallback(()=>{if(!S.current||!T.current)return;const O={placement:t,strategy:n,middleware:m};D.current&&(O.platform=D.current),lg(S.current,T.current,O).then(F=>{const V={...F,isPositioned:_.current!==!1};I.current&&!zr(M.current,V)&&(M.current=V,Gt.flushSync(()=>{f(V)}))})},[m,t,n,D,_]);Ar(()=>{c===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,f(O=>({...O,isPositioned:!1})))},[c]);const I=h.useRef(!1);Ar(()=>(I.current=!0,()=>{I.current=!1}),[]),Ar(()=>{if(k&&(S.current=k),C&&(T.current=C),k&&C){if(R.current)return R.current(k,C,E);E()}},[k,C,E,R,A]);const j=h.useMemo(()=>({reference:S,floating:T,setReference:x,setFloating:w}),[x,w]),B=h.useMemo(()=>({reference:k,floating:C}),[k,C]),H=h.useMemo(()=>{const O={position:n,left:0,top:0};if(!B.floating)return O;const F=Ja(B.floating,u.x),V=Ja(B.floating,u.y);return i?{...O,transform:"translate("+F+"px, "+V+"px)",...Gl(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:V}},[n,i,B.floating,u.x,u.y]);return h.useMemo(()=>({...u,update:E,refs:j,elements:B,floatingStyles:H}),[u,E,j,B,H])}const fg=(e,t)=>{const n=ng(e);return{name:n.name,fn:n.fn,options:[e,t]}},hg=(e,t)=>{const n=rg(e);return{name:n.name,fn:n.fn,options:[e,t]}},mg=(e,t)=>({fn:ig(e).fn,options:[e,t]}),gg=(e,t)=>{const n=og(e);return{name:n.name,fn:n.fn,options:[e,t]}},pg=(e,t)=>{const n=sg(e);return{name:n.name,fn:n.fn,options:[e,t]}},yg=(e,t)=>{const n=ag(e);return{name:n.name,fn:n.fn,options:[e,t]}},bg={intentional:"onClick",sloppy:"onPointerDown"};function xg(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function Kl(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),o=n.useState("floatingElement"),s=n.useState("referenceElement"),a=n.useState("domReferenceElement"),{onOpenChange:i,dataRef:l}=n.context,{enabled:c=!0,escapeKey:u=!0,outsidePress:f=!0,outsidePressEvent:m="sloppy",referencePress:p=!1,referencePressEvent:g="sloppy",ancestorScroll:y=!1,bubbles:b,externalTree:v}=t,x=Hn(v),w=me(typeof f=="function"?f:()=>!1),k=typeof f=="function"?w:f,C=h.useRef(!1),{escapeKey:S,outsidePress:T}=xg(b),M=h.useRef(null),A=hn(),R=hn(),D=me(()=>{R.clear(),l.current.insideReactTree=!1}),_=h.useRef(!1),E=h.useRef(""),I=me(P=>{E.current=P.pointerType}),j=me(()=>{const P=E.current,le=P==="pen"||!P?"mouse":P,X=typeof m=="function"?m():m;return typeof X=="string"?X:X[le]}),B=me(P=>{if(!r||!c||!u||P.key!=="Escape"||_.current)return;const le=l.current.floatingContext?.nodeId,X=x?dn(x.nodesRef.current,le):[];if(!S&&X.length>0){let z=!0;if(X.forEach(Z=>{Z.context?.open&&!Z.context.dataRef.current.__escapeKeyBubbles&&(z=!1)}),!z)return}const ye=Fh(P)?P.nativeEvent:P,Y=je(Al,ye);n.setOpen(!1,Y),!S&&!Y.isPropagationAllowed&&P.stopPropagation()}),H=me(P=>{const le=j();return le==="intentional"&&P.type!=="click"||le==="sloppy"&&P.type==="click"}),O=me(()=>{l.current.insideReactTree=!0,R.start(0,D)}),F=me((P,le=!1)=>{if(H(P)){D();return}if(l.current.insideReactTree){D();return}if(j()==="intentional"&&le||typeof k=="function"&&!k(P))return;const X=et(P),ye=`[${rr("inert")}]`,Y=$e(n.select("floatingElement")).querySelectorAll(ye),z=n.context.triggerElements;if(X&&(z.hasElement(X)||z.hasMatchingElement(re=>ke(re,X))))return;let Z=De(X)?X:null;for(;Z&&!un(Z);){const re=_n(Z);if(un(re)||!De(re))break;Z=re}if(Y.length&&De(X)&&!Ph(X)&&!ke(X,n.select("floatingElement"))&&Array.from(Y).every(re=>!ke(Z,re)))return;if(ze(X)&&!("touches"in P)){const re=un(X),we=pt(X),Se=/auto|scroll/,Ae=re||Se.test(we.overflowX),Xe=re||Se.test(we.overflowY),ot=Ae&&X.clientWidth>0&&X.scrollWidth>X.clientWidth,He=Xe&&X.clientHeight>0&&X.scrollHeight>X.clientHeight,ce=we.direction==="rtl",Ye=He&&(ce?P.offsetX<=X.offsetWidth-X.clientWidth:P.offsetX>X.clientWidth),Oe=ot&&P.offsetY>X.clientHeight;if(Ye||Oe)return}const fe=l.current.floatingContext?.nodeId,ge=x&&dn(x.nodesRef.current,fe).some(re=>ft(P,re.context?.elements.floating));if(ft(P,n.select("floatingElement"))||ft(P,n.select("domReferenceElement"))||ge)return;const ae=x?dn(x.nodesRef.current,fe):[];if(ae.length>0){let re=!0;if(ae.forEach(we=>{we.context?.open&&!we.context.dataRef.current.__outsidePressBubbles&&(re=!1)}),!re)return}n.setOpen(!1,je(_l,P)),D()}),V=me(P=>{j()!=="sloppy"||P.pointerType==="touch"||!n.select("open")||!c||ft(P,n.select("floatingElement"))||ft(P,n.select("domReferenceElement"))||F(P)}),$=me(P=>{if(j()!=="sloppy"||!n.select("open")||!c||ft(P,n.select("floatingElement"))||ft(P,n.select("domReferenceElement")))return;const le=P.touches[0];le&&(M.current={startTime:Date.now(),startX:le.clientX,startY:le.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},A.start(1e3,()=>{M.current&&(M.current.dismissOnTouchEnd=!1,M.current.dismissOnMouseDown=!1)}))}),Q=me(P=>{const le=et(P);function X(){$(P),le?.removeEventListener(P.type,X)}le?.addEventListener(P.type,X)}),U=me(P=>{const le=C.current;if(C.current=!1,A.clear(),P.type==="mousedown"&&M.current&&!M.current.dismissOnMouseDown)return;const X=et(P);function ye(){P.type==="pointerdown"?V(P):F(P,le),X?.removeEventListener(P.type,ye)}X?.addEventListener(P.type,ye)}),W=me(P=>{if(j()!=="sloppy"||!M.current||ft(P,n.select("floatingElement"))||ft(P,n.select("domReferenceElement")))return;const le=P.touches[0];if(!le)return;const X=Math.abs(le.clientX-M.current.startX),ye=Math.abs(le.clientY-M.current.startY),Y=Math.sqrt(X*X+ye*ye);Y>5&&(M.current.dismissOnTouchEnd=!0),Y>10&&(F(P),A.clear(),M.current=null)}),K=me(P=>{const le=et(P);function X(){W(P),le?.removeEventListener(P.type,X)}le?.addEventListener(P.type,X)}),G=me(P=>{j()!=="sloppy"||!M.current||ft(P,n.select("floatingElement"))||ft(P,n.select("domReferenceElement"))||(M.current.dismissOnTouchEnd&&F(P),A.clear(),M.current=null)}),te=me(P=>{const le=et(P);function X(){G(P),le?.removeEventListener(P.type,X)}le?.addEventListener(P.type,X)});h.useEffect(()=>{if(!r||!c)return;l.current.__escapeKeyBubbles=S,l.current.__outsidePressBubbles=T;const P=new Kt;function le(Z){n.setOpen(!1,je(xm,Z))}function X(){P.clear(),_.current=!0}function ye(){P.start(xs()?5:0,()=>{_.current=!1})}const Y=$e(o);Y.addEventListener("pointerdown",I,!0),u&&(Y.addEventListener("keydown",B),Y.addEventListener("compositionstart",X),Y.addEventListener("compositionend",ye)),k&&(Y.addEventListener("click",U,!0),Y.addEventListener("pointerdown",U,!0),Y.addEventListener("touchstart",Q,!0),Y.addEventListener("touchmove",K,!0),Y.addEventListener("touchend",te,!0),Y.addEventListener("mousedown",U,!0));let z=[];return y&&(De(a)&&(z=Nn(a)),De(o)&&(z=z.concat(Nn(o))),!De(s)&&s&&s.contextElement&&(z=z.concat(Nn(s.contextElement)))),z=z.filter(Z=>Z!==Y.defaultView?.visualViewport),z.forEach(Z=>{Z.addEventListener("scroll",le,{passive:!0})}),()=>{Y.removeEventListener("pointerdown",I,!0),u&&(Y.removeEventListener("keydown",B),Y.removeEventListener("compositionstart",X),Y.removeEventListener("compositionend",ye)),k&&(Y.removeEventListener("click",U,!0),Y.removeEventListener("pointerdown",U,!0),Y.removeEventListener("touchstart",Q,!0),Y.removeEventListener("touchmove",K,!0),Y.removeEventListener("touchend",te,!0),Y.removeEventListener("mousedown",U,!0)),z.forEach(Z=>{Z.removeEventListener("scroll",le)}),P.clear(),C.current=!1}},[l,o,s,a,u,k,r,i,y,c,S,T,B,F,U,V,Q,K,te,I,n]),h.useEffect(D,[k,D]);const xe=h.useMemo(()=>({onKeyDown:B,...p&&{[bg[g]]:P=>{n.setOpen(!1,je(qt,P.nativeEvent))},...g!=="intentional"&&{onClick(P){n.setOpen(!1,je(qt,P.nativeEvent))}}}}),[B,n,p,g]),Ee=me(P=>{const le=et(P.nativeEvent);!ke(n.select("floatingElement"),le)||P.button!==0||(C.current=!0)}),be=me(P=>{!r||!c||P.button!==0||(C.current=!0)}),_e=h.useMemo(()=>({onKeyDown:B,onPointerDown:Ee,onMouseDown:Ee,onMouseUp:Ee,onClickCapture:O,onMouseDownCapture(P){O(),be(P)},onPointerDownCapture(P){O(),be(P)},onMouseUpCapture:O,onTouchEndCapture:O,onTouchMoveCapture:O}),[B,Ee,O,be]);return h.useMemo(()=>c?{reference:xe,floating:_e,trigger:xe}:{},[c,xe,_e])}const wg={open:pe(e=>e.open),domReferenceElement:pe(e=>e.domReferenceElement),referenceElement:pe(e=>e.positionReference??e.referenceElement),floatingElement:pe(e=>e.floatingElement),floatingId:pe(e=>e.floatingId)};class As extends Ms{constructor(t){const{nested:n,noEmit:r,onOpenChange:o,triggerElements:s,...a}=t;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:o,dataRef:{current:{}},events:Ol(),nested:n,noEmit:r,triggerElements:s},wg)}setOpen=(t,n)=>{if((!t||!this.state.open||bl(n.event))&&(this.context.dataRef.current.openEvent=t?n.event:void 0),!this.context.noEmit){const r={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",r)}this.context.onOpenChange?.(t,n)}}function vg(e,t=!1,n=!1){const[r,o]=h.useState(e&&t?"idle":void 0),[s,a]=h.useState(e);return e&&!s&&(a(!0),o("starting")),!e&&s&&r!=="ending"&&!n&&o("ending"),!e&&!s&&r==="ending"&&o(void 0),Ce(()=>{if(!e&&s&&r!=="ending"&&n){const i=vt.request(()=>{o("ending")});return()=>{vt.cancel(i)}}},[e,s,r,n]),Ce(()=>{if(!e||t)return;const i=vt.request(()=>{o(void 0)});return()=>{vt.cancel(i)}},[t,e]),Ce(()=>{if(!e||!t)return;e&&s&&r!=="idle"&&o("starting");const i=vt.request(()=>{o("idle")});return()=>{vt.cancel(i)}},[t,e,s,o,r]),h.useMemo(()=>({mounted:s,setMounted:a,transitionStatus:r}),[s,r])}let or=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const kg={[or.startingStyle]:""},Sg={[or.endingStyle]:""},eo={transitionStatus(e){return e==="starting"?kg:e==="ending"?Sg:null}};function Xl(e,t=!1,n=!0){const r=Es();return me((o,s=null)=>{r.cancel();function a(){Gt.flushSync(o)}const i=jt(e);if(i==null)return;const l=i;if(typeof l.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)o();else{let c=function(){const f=or.startingStyle;if(!l.hasAttribute(f)){r.request(u);return}const m=new MutationObserver(()=>{l.hasAttribute(f)||(m.disconnect(),u())});m.observe(l,{attributes:!0,attributeFilter:[f]}),s?.addEventListener("abort",()=>m.disconnect(),{once:!0})},u=function(){Promise.all(l.getAnimations().map(f=>f.finished)).then(()=>{s?.aborted||a()}).catch(()=>{const f=l.getAnimations();if(n){if(s?.aborted)return;a()}else f.length>0&&f.some(m=>m.pending||m.playState!=="finished")&&u()})};if(t){c();return}r.request(u)}})}function Ps(e){const{enabled:t=!0,open:n,ref:r,onComplete:o}=e,s=me(o),a=Xl(r,n,!1);h.useEffect(()=>{if(!t)return;const i=new AbortController;return a(s,i.signal),()=>{i.abort()}},[t,n,s,a])}function Cg(e,t){const n=h.useRef(null),r=h.useRef(null);return h.useCallback(o=>{if(e!==void 0){if(n.current!==null){const s=n.current,a=r.current,i=t.context.triggerElements.getById(s);a&&i===a&&t.context.triggerElements.delete(s),n.current=null,r.current=null}o!==null&&(n.current=e,r.current=o,t.context.triggerElements.add(e,o))}},[t,e])}function Mg(e,t,n,r){const o=n.useState("isMountedByTrigger",e),s=Cg(e,n),a=me(i=>{if(s(i),!i||!n.select("open"))return;const l=n.select("activeTriggerId");if(l===e){n.update({activeTriggerElement:i,...r});return}l==null&&n.update({activeTriggerId:e,activeTriggerElement:i,...r})});return Ce(()=>{o&&n.update({activeTriggerElement:t.current,...r})},[o,n,t,...Object.values(r)]),{registerTrigger:a,isMountedByThisTrigger:o}}function Jl(e){const t=e.useState("open");Ce(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[r,o]=n.value;e.update({activeTriggerId:r,activeTriggerElement:o})}}},[t,e])}function Ql(e,t,n){const{mounted:r,setMounted:o,transitionStatus:s}=vg(e);t.useSyncedValues({mounted:r,transitionStatus:s});const a=me(()=>{o(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),i=t.useState("preventUnmountingOnClose");return Ps({enabled:!i,open:e,ref:t.context.popupRef,onComplete(){e||a()}}),{forceUnmount:a,transitionStatus:s}}class to{constructor(){this.elements=new Set,this.idMap=new Map}add(t,n){const r=this.idMap.get(t);r!==n&&(r!==void 0&&this.elements.delete(r),this.elements.add(n),this.idMap.set(t,n))}delete(t){const n=this.idMap.get(t);n&&(this.elements.delete(n),this.idMap.delete(t))}hasElement(t){return this.elements.has(t)}hasMatchingElement(t){for(const n of this.elements)if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}get size(){return this.idMap.size}}function Tg(){return new As({open:!1,floatingElement:null,referenceElement:null,triggerElements:new to,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function Zl(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:Tg(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:zt,inactiveTriggerProps:zt,popupProps:zt}}const ec={open:pe(e=>e.open),mounted:pe(e=>e.mounted),transitionStatus:pe(e=>e.transitionStatus),floatingRootContext:pe(e=>e.floatingRootContext),preventUnmountingOnClose:pe(e=>e.preventUnmountingOnClose),payload:pe(e=>e.payload),activeTriggerId:pe(e=>e.activeTriggerId),activeTriggerElement:pe(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:pe((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:pe((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:pe((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:pe((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:pe(e=>e.popupProps),popupElement:pe(e=>e.popupElement),positionerElement:pe(e=>e.positionerElement)};function Eg(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,o=Yn(),s=yn()!=null,a=Xt(()=>new As({open:t,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:r.triggers??new to,floatingId:o,nested:s,noEmit:e.noEmit||!1})).current;return Ce(()=>{const i={open:t,floatingId:o};r.reference!==void 0&&(i.referenceElement=r.reference,i.domReferenceElement=De(r.reference)?r.reference:null),r.floating!==void 0&&(i.floatingElement=r.floating),a.update(i)},[t,o,r.reference,r.floating,a]),a.context.onOpenChange=n,a.context.nested=s,a.context.noEmit=e.noEmit||!1,a}function Ng(e={}){const{nodeId:t,externalTree:n}=e,r=Eg(e),o=e.rootContext||r,s={reference:o.useState("referenceElement"),floating:o.useState("floatingElement"),domReference:o.useState("domReferenceElement")},[a,i]=h.useState(null),l=h.useRef(null),c=Hn(n);Ce(()=>{s.domReference&&(l.current=s.domReference)},[s.domReference]);const u=dg({...e,elements:{...s,...a&&{reference:a}}}),f=h.useCallback(T=>{const M=De(T)?{getBoundingClientRect:()=>T.getBoundingClientRect(),getClientRects:()=>T.getClientRects(),contextElement:T}:T;i(M),u.refs.setReference(M)},[u.refs]),[m,p]=h.useState(null),[g,y]=h.useState(null);o.useSyncedValue("referenceElement",m),o.useSyncedValue("domReferenceElement",De(m)?m:null),o.useSyncedValue("floatingElement",g);const b=h.useCallback(T=>{(De(T)||T===null)&&(l.current=T,p(T)),(De(u.refs.reference.current)||u.refs.reference.current===null||T!==null&&!De(T))&&u.refs.setReference(T)},[u.refs,p]),v=h.useCallback(T=>{y(T),u.refs.setFloating(T)},[u.refs]),x=h.useMemo(()=>({...u.refs,setReference:b,setFloating:v,setPositionReference:f,domReference:l}),[u.refs,b,v,f]),w=h.useMemo(()=>({...u.elements,domReference:s.domReference}),[u.elements,s.domReference]),k=o.useState("open"),C=o.useState("floatingId"),S=h.useMemo(()=>({...u,dataRef:o.context.dataRef,open:k,onOpenChange:o.setOpen,events:o.context.events,floatingId:C,refs:x,elements:w,nodeId:t,rootStore:o}),[u,x,w,t,o,k,C]);return Ce(()=>{o.context.dataRef.current.floatingContext=S;const T=c?.nodesRef.current.find(M=>M.id===t);T&&(T.context=S)}),h.useMemo(()=>({...u,context:S,refs:x,elements:w,rootStore:o}),[u,x,w,S,o])}function tc(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:r=!1,onOpenChange:o}=e,s=Yn(),a=yn()!=null,i=t.useState("open"),l=t.useState("activeTriggerElement"),c=t.useState(r?"popupElement":"positionerElement"),u=t.context.triggerElements,f=Xt(()=>new As({open:i,referenceElement:l,floatingElement:c,triggerElements:u,onOpenChange:o,floatingId:s,nested:a,noEmit:n})).current;return Ce(()=>{const m={open:i,floatingId:s,referenceElement:l,floatingElement:c};De(l)&&(m.domReferenceElement=l),f.state.positionReference===f.state.referenceElement&&(m.positionReference=l),f.update(m)},[i,s,l,c,f]),f.context.onOpenChange=o,f.context.nested=a,f.context.noEmit=n,f}const us=rr("safe-polygon"),Dg=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${pl}`;function Og(e){return e?!!e.closest(Dg):!1}function nc(e){const t=h.useRef(void 0),n=h.useRef(!1),r=h.useRef(void 0),o=h.useRef(!0),s=h.useRef(!1),a=h.useRef(()=>{}),i=h.useRef(!1),l=hn(),c=hn(),u=h.useRef(void 0);return h.useMemo(()=>{const f=e.context.dataRef.current;return f.hoverInteractionState||(f.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:r,blockMouseMoveRef:o,performedPointerEventsMutationRef:s,unbindMouseMoveRef:a,restTimeoutPendingRef:i,openChangeTimeout:l,restTimeout:c,handleCloseOptionsRef:u}),f.hoverInteractionState},[e,t,n,r,o,s,a,i,l,c,u])}const Rg=new Set(["click","mousedown"]);function jg(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),o=n.useState("floatingElement"),s=n.useState("domReferenceElement"),{dataRef:a}=n.context,{enabled:i=!0,closeDelay:l=0,externalTree:c}=t,{pointerTypeRef:u,interactedInsideRef:f,handlerRef:m,performedPointerEventsMutationRef:p,unbindMouseMoveRef:g,restTimeoutPendingRef:y,openChangeTimeout:b,handleCloseOptionsRef:v}=nc(n),x=Hn(c),w=yn(),k=me(()=>f.current?!0:a.current.openEvent?Rg.has(a.current.openEvent.type):!1),C=me(()=>{const R=a.current.openEvent?.type;return R?.includes("mouse")&&R!=="mousedown"}),S=h.useCallback((R,D=!0)=>{const _=_g(l,u.current);_&&!m.current?b.start(_,()=>n.setOpen(!1,je(nt,R))):D&&(b.clear(),n.setOpen(!1,je(nt,R)))},[l,m,n,u,b]),T=me(()=>{g.current(),m.current=void 0}),M=me(()=>{if(p.current){const R=$e(o).body;R.style.pointerEvents="",R.removeAttribute(us),p.current=!1}}),A=me(R=>{const D=et(R);if(!Og(D)){f.current=!1;return}f.current=!0});Ce(()=>{r||(u.current=void 0,y.current=!1,f.current=!1,T(),M())},[r,u,y,f,T,M]),h.useEffect(()=>()=>{T()},[T]),h.useEffect(()=>M,[M]),Ce(()=>{if(i&&r&&v.current?.blockPointerEvents&&C()&&De(s)&&o){p.current=!0;const R=$e(o).body;R.setAttribute(us,"");const D=s,_=o,E=x?.nodesRef.current.find(I=>I.id===w)?.context?.elements.floating;return E&&(E.style.pointerEvents=""),R.style.pointerEvents="none",D.style.pointerEvents="auto",_.style.pointerEvents="auto",()=>{R.style.pointerEvents="",D.style.pointerEvents="",_.style.pointerEvents=""}}},[i,r,s,o,v,C,x,w,p]),h.useEffect(()=>{if(!i)return;function R(I){if(k()||!a.current.floatingContext||!n.select("open"))return;const j=n.context.triggerElements;I.relatedTarget&&j.hasElement(I.relatedTarget)||(M(),T(),k()||S(I))}function D(I){b.clear(),M(),m.current?.(I),T()}function _(I){k()||S(I,!1)}const E=o;return E&&(E.addEventListener("mouseleave",R),E.addEventListener("mouseenter",D),E.addEventListener("mouseleave",_),E.addEventListener("pointerdown",A,!0)),()=>{E&&(E.removeEventListener("mouseleave",R),E.removeEventListener("mouseenter",D),E.removeEventListener("mouseleave",_),E.removeEventListener("pointerdown",A,!0))}})}function _g(e,t){return t&&!An(t)?0:typeof e=="function"?e():e}function Bo(e){return typeof e=="function"?e():e}const Ag={current:null};function Pg(e,t={}){const n="rootStore"in e?e.rootStore:e,{dataRef:r,events:o}=n.context,{enabled:s=!0,delay:a=0,handleClose:i=null,mouseOnly:l=!1,restMs:c=0,move:u=!0,triggerElementRef:f=Ag,externalTree:m,isActiveTrigger:p=!0}=t,g=Hn(m),{pointerTypeRef:y,interactedInsideRef:b,handlerRef:v,blockMouseMoveRef:x,performedPointerEventsMutationRef:w,unbindMouseMoveRef:k,restTimeoutPendingRef:C,openChangeTimeout:S,restTimeout:T,handleCloseOptionsRef:M}=nc(n),A=kt(i),R=kt(a),D=kt(c);p&&(M.current=A.current?.__options);const _=me(()=>b.current?!0:r.current.openEvent?["click","mousedown"].includes(r.current.openEvent.type):!1),E=h.useCallback((H,O=!0)=>{const F=Ao(R.current,"close",y.current);F&&!v.current?S.start(F,()=>n.setOpen(!1,je(nt,H))):O&&(S.clear(),n.setOpen(!1,je(nt,H)))},[R,v,n,y,S]),I=me(()=>{k.current(),v.current=void 0}),j=me(()=>{if(w.current){const H=$e(n.select("domReferenceElement")).body;H.style.pointerEvents="",H.removeAttribute(us),w.current=!1}});h.useEffect(()=>{if(!s)return;function H(O){O.open||(S.clear(),T.clear(),x.current=!0,C.current=!1)}return o.on("openchange",H),()=>{o.off("openchange",H)}},[s,o,S,T,x,C]);const B=me(H=>{if(_()||!r.current.floatingContext)return;const O=n.context.triggerElements;if(H.relatedTarget&&O.hasElement(H.relatedTarget))return;const F=f.current;A.current?.({...r.current.floatingContext,tree:g,x:H.clientX,y:H.clientY,onClose(){j(),I(),!_()&&F===n.select("domReferenceElement")&&E(H)}})(H)});return h.useEffect(()=>{if(!s)return;const H=f.current??(p?n.select("domReferenceElement"):null);if(!De(H))return;function O($){if(S.clear(),x.current=!1,l&&!An(y.current)||Bo(D.current)>0&&!Ao(R.current,"open"))return;const Q=Ao(R.current,"open",y.current),U=n.select("domReferenceElement"),W=n.context.triggerElements,K=(W.hasElement($.target)||W.hasMatchingElement(Ee=>ke(Ee,$.target)))&&(!U||!ke(U,$.target)),G=$.currentTarget??null,te=n.select("open"),xe=!te||K;K&&te?n.setOpen(!0,je(nt,$,G)):Q?S.start(Q,()=>{xe&&n.setOpen(!0,je(nt,$,G))}):xe&&n.setOpen(!0,je(nt,$,G))}function F($){if(_()){j();return}k.current();const Q=n.select("domReferenceElement"),U=$e(Q);T.clear(),C.current=!1;const W=n.context.triggerElements;if($.relatedTarget&&W.hasElement($.relatedTarget))return;if(A.current&&r.current.floatingContext){n.select("open")||S.clear();const G=f.current;v.current=A.current({...r.current.floatingContext,tree:g,x:$.clientX,y:$.clientY,onClose(){j(),I(),!_()&&G===n.select("domReferenceElement")&&E($,!0)}});const te=v.current;te($),U.addEventListener("mousemove",te),k.current=()=>{U.removeEventListener("mousemove",te)};return}(y.current!=="touch"||!ke(n.select("floatingElement"),$.relatedTarget))&&E($)}function V($){B($)}return n.select("open")&&H.addEventListener("mouseleave",V),u&&H.addEventListener("mousemove",O,{once:!0}),H.addEventListener("mouseenter",O),H.addEventListener("mouseleave",F),()=>{H.removeEventListener("mouseleave",V),u&&H.removeEventListener("mousemove",O),H.removeEventListener("mouseenter",O),H.removeEventListener("mouseleave",F)}},[I,j,x,r,R,E,n,s,A,B,p,_,l,u,y,D,T,C,S,f,g,k,v]),h.useMemo(()=>{function H(O){y.current=O.pointerType}return{onPointerDown:H,onPointerEnter:H,onMouseMove(O){const{nativeEvent:F}=O,V=O.currentTarget,$=n.select("domReferenceElement"),Q=n.context.triggerElements,U=n.select("open"),W=(Q.hasElement(O.target)||Q.hasMatchingElement(G=>ke(G,O.target)))&&(!$||!ke($,O.target));if(l&&!An(y.current)||U&&!W||Bo(D.current)===0||!W&&C.current&&O.movementX**2+O.movementY**2<2)return;T.clear();function K(){if(C.current=!1,_())return;const G=n.select("open");!x.current&&(!G||W)&&n.setOpen(!0,je(nt,F,V))}y.current==="touch"?Gt.flushSync(()=>{K()}):W&&U?K():(C.current=!0,T.start(Bo(D.current),K))}}},[x,_,l,n,y,D,T,C])}function Is(e=[]){const t=e.map(c=>c?.reference),n=e.map(c=>c?.floating),r=e.map(c=>c?.item),o=e.map(c=>c?.trigger),s=h.useCallback(c=>Dr(c,e,"reference"),t),a=h.useCallback(c=>Dr(c,e,"floating"),n),i=h.useCallback(c=>Dr(c,e,"item"),r),l=h.useCallback(c=>Dr(c,e,"trigger"),o);return h.useMemo(()=>({getReferenceProps:s,getFloatingProps:a,getItemProps:i,getTriggerProps:l}),[s,a,i,l])}function Dr(e,t,n){const r=new Map,o=n==="item",s={};n==="floating"&&(s.tabIndex=-1,s[os]="");for(const a in e)o&&e&&(a===ml||a===gl)||(s[a]=e[a]);for(let a=0;a<t.length;a+=1){let i;const l=t[a]?.[n];typeof l=="function"?i=e?l(e):null:i=l,i&&Qa(s,i,o,r)}return Qa(s,e,o,r),s}function Qa(e,t,n,r){for(const o in t){const s=t[o];n&&(o===ml||o===gl)||(o.startsWith("on")?(r.has(o)||r.set(o,[]),typeof s=="function"&&(r.get(o)?.push(s),e[o]=(...a)=>r.get(o)?.map(i=>i(...a)).find(i=>i!==void 0))):e[o]=s)}}const Ig=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function rc(e,t={}){const n="rootStore"in e?e.rootStore:e,r=n.useState("open"),o=n.useState("floatingId"),s=n.useState("domReferenceElement"),a=n.useState("floatingElement"),{enabled:i=!0,role:l="dialog"}=t,c=Yn(),u=s?.id||c,f=h.useMemo(()=>ss(a)?.id||o,[a,o]),m=Ig.get(l)??l,g=yn()!=null,y=h.useMemo(()=>m==="tooltip"||l==="label"?zt:{"aria-haspopup":m==="alertdialog"?"dialog":m,"aria-expanded":"false",...m==="listbox"&&{role:"combobox"},...m==="menu"&&g&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[m,g,l]),b=h.useMemo(()=>m==="tooltip"||l==="label"?{[`aria-${l==="label"?"labelledby":"describedby"}`]:r?f:void 0}:{...y,"aria-expanded":r?"true":"false","aria-controls":r?f:void 0,...m==="menu"&&{id:u}},[m,f,r,u,l,y]),v=h.useMemo(()=>{const w={id:f,...m&&{role:m}};return m==="tooltip"||l==="label"?w:{...w,...m==="menu"&&{"aria-labelledby":u}}},[m,f,u,l]),x=h.useCallback(({active:w,selected:k})=>{const C={role:"option",...w&&{id:`${f}-fui-option`}};switch(l){case"select":case"combobox":return{...C,"aria-selected":k}}return{}},[f,l]);return h.useMemo(()=>i?{reference:b,floating:v,item:x,trigger:y}:{},[i,b,v,y,x])}function Za(e,t){const[n,r]=e;let o=!1;const s=t.length;for(let a=0,i=s-1;a<s;i=a++){const[l,c]=t[a]||[0,0],[u,f]=t[i]||[0,0];c>=r!=f>=r&&n<=(u-l)*(r-c)/(f-c)+l&&(o=!o)}return o}function Fg(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function Lg(e={}){const{buffer:t=.5,blockPointerEvents:n=!1,requireIntent:r=!0}=e,o=new Kt;let s=!1,a=null,i=null,l=typeof performance<"u"?performance.now():0;function c(f,m){const p=performance.now(),g=p-l;if(a===null||i===null||g===0)return a=f,i=m,l=p,null;const y=f-a,b=m-i,x=Math.sqrt(y*y+b*b)/g;return a=f,i=m,l=p,x}const u=({x:f,y:m,placement:p,elements:g,onClose:y,nodeId:b,tree:v})=>function(w){function k(){o.clear(),y()}if(o.clear(),!g.domReference||!g.floating||p==null||f==null||m==null)return;const{clientX:C,clientY:S}=w,T=[C,S],M=et(w),A=w.type==="mouseleave",R=ke(g.floating,M),D=ke(g.domReference,M),_=g.domReference.getBoundingClientRect(),E=g.floating.getBoundingClientRect(),I=p.split("-")[0],j=f>E.right-E.width/2,B=m>E.bottom-E.height/2,H=Fg(T,_),O=E.width>_.width,F=E.height>_.height,V=(O?_:E).left,$=(O?_:E).right,Q=(F?_:E).top,U=(F?_:E).bottom;if(R&&(s=!0,!A))return;if(D&&(s=!1),D&&!A){s=!0;return}if(A&&De(w.relatedTarget)&&ke(g.floating,w.relatedTarget)||v&&dn(v.nodesRef.current,b).some(({context:G})=>G?.open))return;if(I==="top"&&m>=_.bottom-1||I==="bottom"&&m<=_.top+1||I==="left"&&f>=_.right-1||I==="right"&&f<=_.left+1)return k();let W=[];switch(I){case"top":W=[[V,_.top+1],[V,E.bottom-1],[$,E.bottom-1],[$,_.top+1]];break;case"bottom":W=[[V,E.top+1],[V,_.bottom-1],[$,_.bottom-1],[$,E.top+1]];break;case"left":W=[[E.right-1,U],[E.right-1,Q],[_.left+1,Q],[_.left+1,U]];break;case"right":W=[[_.right-1,U],[_.right-1,Q],[E.left+1,Q],[E.left+1,U]];break}function K([G,te]){switch(I){case"top":{const xe=[O?G+t/2:j?G+t*4:G-t*4,te+t+1],Ee=[O?G-t/2:j?G+t*4:G-t*4,te+t+1],be=[[E.left,j||O?E.bottom-t:E.top],[E.right,j?O?E.bottom-t:E.top:E.bottom-t]];return[xe,Ee,...be]}case"bottom":{const xe=[O?G+t/2:j?G+t*4:G-t*4,te-t],Ee=[O?G-t/2:j?G+t*4:G-t*4,te-t],be=[[E.left,j||O?E.top+t:E.bottom],[E.right,j?O?E.top+t:E.bottom:E.top+t]];return[xe,Ee,...be]}case"left":{const xe=[G+t+1,F?te+t/2:B?te+t*4:te-t*4],Ee=[G+t+1,F?te-t/2:B?te+t*4:te-t*4];return[...[[B||F?E.right-t:E.left,E.top],[B?F?E.right-t:E.left:E.right-t,E.bottom]],xe,Ee]}case"right":{const xe=[G-t,F?te+t/2:B?te+t*4:te-t*4],Ee=[G-t,F?te-t/2:B?te+t*4:te-t*4],be=[[B||F?E.left+t:E.right,E.top],[B?F?E.left+t:E.right:E.left+t,E.bottom]];return[xe,Ee,...be]}default:return[]}}if(!Za([C,S],W)){if(s&&!H)return k();if(!A&&r){const G=c(w.clientX,w.clientY);if(G!==null&&G<.1)return k()}Za([C,S],K([f,m]))?!s&&r&&o.start(40,k):k()}};return u.__options={blockPointerEvents:n},u}function oc(e){return Yn(e,"base-ui")}function Wg(e){const t=h.useRef(""),n=h.useCallback(o=>{o.defaultPrevented||(t.current=o.pointerType,e(o,o.pointerType))},[e]);return{onClick:h.useCallback(o=>{if(o.detail===0){e(o,"keyboard");return}"pointerType"in o&&e(o,o.pointerType),e(o,t.current),t.current=""},[e]),onPointerDown:n}}function sc(e){const[t,n]=h.useState(null),r=me((i,l)=>{e||n(l||(hl?"touch":""))}),o=h.useCallback(()=>{n(null)},[]),{onClick:s,onPointerDown:a}=Wg(r);return h.useMemo(()=>({openMethod:t,reset:o,triggerProps:{onClick:s,onPointerDown:a}}),[t,o,s,a])}let mt=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=or.startingStyle]="startingStyle",e[e.endingStyle=or.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),ds=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const Bg={[ds.popupOpen]:""},$g={[ds.popupOpen]:"",[ds.pressed]:""},Yg={[mt.open]:""},Hg={[mt.closed]:""},Ug={[mt.anchorHidden]:""},Vg={open(e){return e?Bg:null}},zg={open(e){return e?$g:null}},ur={open(e){return e?Yg:Hg},anchorHidden(e){return e?Ug:null}};function ac(e){return zi(19)?e:e?"true":void 0}let ei={},ti={},ni="";function qg(e){if(typeof document>"u")return!1;const t=bn(e);return lt(t).innerWidth-t.documentElement.clientWidth>0}function Gg(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const r=bn(e).documentElement,o={scrollbarGutter:r.style.scrollbarGutter,overflowY:r.style.overflowY};r.style.scrollbarGutter="stable",r.style.overflowY="scroll";const s=r.offsetWidth;r.style.overflowY="hidden";const a=r.offsetWidth;return Object.assign(r.style,o),s===a}function Kg(e){const t=bn(e),n=t.documentElement,r=t.body,o=lr(n)?n:r,s=o.style.overflow;return o.style.overflow="hidden",()=>{o.style.overflow=s}}function Xg(e){const t=bn(e),n=t.documentElement,r=t.body,o=lt(n);let s=0,a=0,i=!1;const l=vt.create();if(Dh&&(o.visualViewport?.scale??1)!==1)return()=>{};function c(){const m=o.getComputedStyle(n),p=o.getComputedStyle(r),b=(m.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";s=n.scrollTop,a=n.scrollLeft,ei={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},ni=n.style.scrollBehavior,ti={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const v=n.scrollHeight>n.clientHeight,x=n.scrollWidth>n.clientWidth,w=m.overflowY==="scroll"||p.overflowY==="scroll",k=m.overflowX==="scroll"||p.overflowX==="scroll",C=Math.max(0,o.innerWidth-r.clientWidth),S=Math.max(0,o.innerHeight-r.clientHeight),T=parseFloat(p.marginTop)+parseFloat(p.marginBottom),M=parseFloat(p.marginLeft)+parseFloat(p.marginRight),A=lr(n)?n:r;if(i=Gg(e),i){n.style.scrollbarGutter=b,A.style.overflowY="hidden",A.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:b,overflowY:"hidden",overflowX:"hidden"}),(v||w)&&(n.style.overflowY="scroll"),(x||k)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:T||S?`calc(100dvh - ${T+S}px)`:"100dvh",width:M||C?`calc(100vw - ${M+C}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=s,r.scrollLeft=a,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function u(){Object.assign(n.style,ei),Object.assign(r.style,ti),i||(n.scrollTop=s,n.scrollLeft=a,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=ni)}function f(){u(),l.request(c)}return c(),o.addEventListener("resize",f),()=>{l.cancel(),u(),typeof o.removeEventListener=="function"&&o.removeEventListener("resize",f)}}class Jg{lockCount=0;restore=null;timeoutLock=Kt.create();timeoutUnlock=Kt.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const r=bn(t).documentElement,o=lt(r).getComputedStyle(r).overflowY;if(o==="hidden"||o==="clip"){this.restore=qi;return}const s=hl||!qg(t);this.restore=s?Kg(t):Xg(t)}}const Qg=new Jg;function ic(e=!0,t=null){Ce(()=>{if(e)return Qg.acquire(t)},[e,t])}const Zg=h.createContext(void 0);function ep(){return h.useContext(Zg)?.direction??"ltr"}const tp=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:a,elements:i,middlewareData:l}=t,{element:c,padding:u=0,offsetParent:f="real"}=Pt(e,t)||{};if(c==null)return{};const m=xl(u),p={x:n,y:r},g=Os(o),y=Ds(g),b=await a.getDimensions(c),v=g==="y",x=v?"top":"left",w=v?"bottom":"right",k=v?"clientHeight":"clientWidth",C=s.reference[y]+s.reference[g]-p[g]-s.floating[y],S=p[g]-s.reference[g],T=f==="real"?await a.getOffsetParent?.(c):i.floating;let M=i.floating[k]||s.floating[y];(!M||!await a.isElement?.(T))&&(M=i.floating[k]||s.floating[y]);const A=C/2-S/2,R=M/2-b[y]/2-1,D=Math.min(m[x],R),_=Math.min(m[w],R),E=D,I=M-b[y]-_,j=M/2-b[y]/2+A,B=as(E,j,I),H=!l.arrow&&Jt(o)!=null&&j!==B&&s.reference[y]/2-(j<E?D:_)-b[y]/2<0,O=H?j<E?j-E:j-I:0;return{[g]:p[g]+O,data:{[g]:B,centerOffset:j-B-O,...H&&{alignmentOffset:O}},reset:H}}}),np=(e,t)=>({...tp(e),options:[e,t]}),rp={name:"hide",async fn(e){const{width:t,height:n,x:r,y:o}=e.rects.reference,s=t===0&&n===0&&r===0&&o===0;return{data:{referenceHidden:(await yg().fn(e)).data?.referenceHidden||s}}}},Pr={sideX:"left",sideY:"top"},op={name:"adaptiveOrigin",async fn(e){const{x:t,y:n,rects:{floating:r},elements:{floating:o},platform:s,strategy:a,placement:i}=e,l=lt(o),c=l.getComputedStyle(o);if(!(c.transitionDuration!=="0s"&&c.transitionDuration!==""))return{x:t,y:n,data:Pr};const f=await s.getOffsetParent?.(o);let m={width:0,height:0};if(a==="fixed"&&l?.visualViewport)m={width:l.visualViewport.width,height:l.visualViewport.height};else if(f===l){const x=bn(o);m={width:x.documentElement.clientWidth,height:x.documentElement.clientHeight}}else await s.isElement?.(f)&&(m=await s.getDimensions(f));const p=Ke(i);let g=t,y=n;p==="left"&&(g=m.width-(t+r.width)),p==="top"&&(y=m.height-(n+r.height));const b=p==="left"?"right":Pr.sideX,v=p==="top"?"bottom":Pr.sideY;return{x:g,y,data:{sideX:b,sideY:v}}}};function lc(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 ri(e,t,n){const{rects:r,placement:o}=e;return{side:lc(t,Ke(o),n),align:Jt(o)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function sp(e){const{anchor:t,positionMethod:n="absolute",side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,collisionBoundary:i,collisionPadding:l=5,sticky:c=!1,arrowPadding:u=5,disableAnchorTracking:f=!1,keepMounted:m=!1,floatingRootContext:p,mounted:g,collisionAvoidance:y,shiftCrossAxis:b=!1,nodeId:v,adaptiveOrigin:x,lazyFlip:w=!1,externalTree:k}=e,[C,S]=h.useState(null);!g&&C!==null&&S(null);const T=y.side||"flip",M=y.align||"flip",A=y.fallbackAxisSide||"end",R=typeof t=="function"?t:void 0,D=me(R),_=R?D:t,E=kt(t),j=ep()==="rtl",B=C||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":j?"left":"right","inline-start":j?"right":"left"}[r],H=s==="center"?B:`${B}-${s}`;let O=l;const F=1,V=r==="bottom"?F:0,$=r==="top"?F:0,Q=r==="right"?F:0,U=r==="left"?F:0;typeof O=="number"?O={top:O+V,right:O+U,bottom:O+$,left:O+Q}:O&&(O={top:(O.top||0)+V,right:(O.right||0)+U,bottom:(O.bottom||0)+$,left:(O.left||0)+Q});const W={boundary:i==="clipping-ancestors"?"clippingAncestors":i,padding:O},K=h.useRef(null),G=kt(o),te=kt(a),be=[fg(Te=>{const Fe=ri(Te,r,j),ee=typeof G.current=="function"?G.current(Fe):G.current,ue=typeof te.current=="function"?te.current(Fe):te.current;return{mainAxis:ee,crossAxis:ue,alignmentAxis:ue}},[typeof o!="function"?o:0,typeof a!="function"?a:0,j,r])],_e=M==="none"&&T!=="shift",P=!_e&&(c||b||T==="shift"),le=T==="none"?null:gg({...W,padding:{top:O.top+F,right:O.right+F,bottom:O.bottom+F,left:O.left+F},mainAxis:!b&&T==="flip",crossAxis:M==="flip"?"alignment":!1,fallbackAxisSideDirection:A}),X=_e?null:hg(Te=>{const Fe=bn(Te.elements.floating).documentElement;return{...W,rootBoundary:b?{x:0,y:0,width:Fe.clientWidth,height:Fe.clientHeight}:void 0,mainAxis:M!=="none",crossAxis:P,limiter:c||b?void 0:mg(ee=>{if(!K.current)return{};const{width:ue,height:J}=K.current.getBoundingClientRect(),ie=it(Ke(ee.placement)),Pe=ie==="y"?ue:J,he=ie==="y"?O.left+O.right:O.top+O.bottom;return{offset:Pe/2+he/2}})}},[W,c,b,O,M]);T==="shift"||M==="shift"||s==="center"?be.push(X,le):be.push(le,X),be.push(pg({...W,apply({elements:{floating:Te},rects:{reference:Fe},availableWidth:ee,availableHeight:ue}){Object.entries({"--available-width":`${ee}px`,"--available-height":`${ue}px`,"--anchor-width":`${Fe.width}px`,"--anchor-height":`${Fe.height}px`}).forEach(([J,ie])=>{Te.style.setProperty(J,ie)})}}),np(()=>({element:K.current||document.createElement("div"),padding:u,offsetParent:"floating"}),[u]),{name:"transformOrigin",fn(Te){const{elements:Fe,middlewareData:ee,placement:ue,rects:J,y:ie}=Te,Pe=Ke(ue),he=it(Pe),Nt=K.current,Qt=ee.arrow?.x||0,Bt=ee.arrow?.y||0,bt=Nt?.clientWidth||0,Ge=Nt?.clientHeight||0,Je=Qt+bt/2,st=Bt+Ge/2,oo=Math.abs(ee.shift?.y||0),gr=J.reference.height/2,$t=typeof o=="function"?o(ri(Te,r,j)):o,so=oo>$t,ao={top:`${Je}px calc(100% + ${$t}px)`,bottom:`${Je}px ${-$t}px`,left:`calc(100% + ${$t}px) ${st}px`,right:`${-$t}px ${st}px`}[Pe],io=`${Je}px ${J.reference.y+gr-ie}px`;return Fe.floating.style.setProperty("--transform-origin",P&&he==="y"&&so?io:ao),{}}},rp,x),Ce(()=>{!g&&p&&p.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[g,p]);const ye=h.useMemo(()=>({elementResize:!f&&typeof ResizeObserver<"u",layoutShift:!f&&typeof IntersectionObserver<"u"}),[f]),{refs:Y,elements:z,x:Z,y:fe,middlewareData:ge,update:ae,placement:re,context:we,isPositioned:Se,floatingStyles:Ae}=Ng({rootContext:p,placement:H,middleware:be,strategy:n,whileElementsMounted:m?void 0:(...Te)=>Xa(...Te,ye),nodeId:v,externalTree:k}),{sideX:Xe,sideY:ot}=ge.adaptiveOrigin||Pr,He=Se?n:"fixed",ce=h.useMemo(()=>x?{position:He,[Xe]:Z,[ot]:fe}:{position:He,...Ae},[x,He,Xe,Z,ot,fe,Ae]),Ye=h.useRef(null);Ce(()=>{if(!g)return;const Te=E.current,Fe=typeof Te=="function"?Te():Te,ue=(oi(Fe)?Fe.current:Fe)||null||null;ue!==Ye.current&&(Y.setPositionReference(ue),Ye.current=ue)},[g,Y,_,E]),h.useEffect(()=>{if(!g)return;const Te=E.current;typeof Te!="function"&&oi(Te)&&Te.current!==Ye.current&&(Y.setPositionReference(Te.current),Ye.current=Te.current)},[g,Y,_,E]),h.useEffect(()=>{if(m&&g&&z.domReference&&z.floating)return Xa(z.domReference,z.floating,ae,ye)},[m,g,z,ae,ye]);const Oe=Ke(re),Ue=lc(r,Oe,j),Et=Jt(re)||"center",yt=!!ge.hide?.referenceHidden;Ce(()=>{w&&g&&Se&&S(Oe)},[w,g,Se,Oe]);const Lt=h.useMemo(()=>({position:"absolute",top:ge.arrow?.y,left:ge.arrow?.x}),[ge.arrow]),Wt=ge.arrow?.centerOffset!==0;return h.useMemo(()=>({positionerStyles:ce,arrowStyles:Lt,arrowRef:K,arrowUncentered:Wt,side:Ue,align:Et,physicalSide:Oe,anchorHidden:yt,refs:Y,context:we,isPositioned:Se,update:ae}),[ce,Lt,K,Wt,Ue,Et,Oe,yt,Y,we,Se,ae])}function oi(e){return e!=null&&"current"in e}const cc=h.forwardRef(function(t,n){const{cutout:r,...o}=t;let s;if(r){const a=r?.getBoundingClientRect();s=`polygon(
2
2
  0% 0%,
3
3
  100% 0%,
4
4
  100% 100%,