tokentracker-cli 0.5.24 → 0.5.25
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.
- package/dashboard/dist/assets/{DashboardPage-vIxKP44Z.js → DashboardPage-Bv4UcOEZ.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-VXJBiwkB.js → LeaderboardPage-CbvvPyY_.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfilePage-DPeOBsNk.js → LeaderboardProfilePage-Co4mAr4h.js} +1 -1
- package/dashboard/dist/assets/{ThemeToggle-8m6pW0Kd.js → ThemeToggle-Qn_pvy0M.js} +1 -1
- package/dashboard/dist/assets/{leaderboard-columns-BtZZjmrK.js → leaderboard-columns-QXmWCpyM.js} +1 -1
- package/dashboard/dist/assets/{main-uLnyEwnj.js → main-C7szutiJ.js} +4 -4
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as Nu,f as oi,a as si,J as Ru,u as ai,m as Du,r as f,M as ii,b as _u,c as Pu,d as io,e as li,g as ju,h as jn,j as An,k as rn,l as Au,n as Wo,o as xr,p as Xo,q as Yr,s as Iu,t as Fu,v as Lu,w as Jo,x as Tn,y as lo,z as Wu,A as $u,B as nt,C as W,D as m,E as qt,F as Ee,G as an,H as ci,I as ui,K as me,N as di,L as Bu,O as Ke,R as Yu,P as Yt,Q as or,S as Ut,T as Hu,U as jt,V as Vs,W as it,X as ht,Y as kn,Z as Re,_ as At,$ as qs,a0 as Qo,a1 as Zo,a2 as On,a3 as tn,a4 as Uu,a5 as fi,a6 as Vu,a7 as sr,a8 as Hr,a9 as qu,aa as mi,ab as Gu,ac as Ur,ad as vt,ae as hi,af as G,ag as es,ah as gi,ai as zu,aj as Ku,ak as Xu,al as Ju,am as Qu,an as Zu,ao as ed,ap as td,aq as nd,ar as rd,as as od,at as sd,au as ad,av as Nt,aw as id,ax as ld,ay as Gs}from"./main-uLnyEwnj.js";import{u as ts,T as cd}from"./ThemeToggle-8m6pW0Kd.js";const ud=500,dd={style:{transition:"none"}},pi="data-base-ui-click-trigger",fd={fallbackAxisSide:"end"},md={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function hd(...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=Nu(o,s,a);return t?i(r):i}function gd(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 d=zs(e.get()),h=zs(s);if(d===h){l();return}const g=o?o.getGeneratorVelocity():e.getVelocity();l(),o=new Ru({keyframes:[d,h],velocity:g,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((d,h)=>{s=d,a=g=>h(co(g,i)),oi.postRender(u)},l),si(t)){let d=n.skipInitialAnimation===!0;const h=t.on("change",p=>{d?(d=!1,e.jump(co(p,i),!1)):e.set(co(p,i))}),g=e.on("destroy",h);return()=>{h(),g()}}return l}function co(e,t){return t?e+t:e}function zs(e){return typeof e=="number"?e:parseFloat(e)}function ns(e){const t=ai(()=>Du(e)),{isStatic:n}=f.useContext(ii);if(n){const[,r]=f.useState(e);f.useEffect(()=>t.on("change",r),[])}return t}function yi(e,t){const n=ns(t()),r=()=>n.set(t());return r(),_u(()=>{const o=()=>oi.preRender(r,!1,!0),s=e.map(a=>a.on("change",o));return()=>{s.forEach(a=>a()),Pu(r)}}),n}function pd(e){io.current=[],e();const t=yi(io.current,e);return io.current=void 0,t}function bi(e,t,n,r){if(typeof e=="function")return pd(e);const s=typeof t=="function"?t:hd(t,n,r),a=Array.isArray(e)?Ks(e,s):Ks([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 Ks(e,t){const n=ai(()=>[]);return yi(e,()=>{n.length=0;const r=e.length;for(let o=0;o<r;o++)n[o]=e[o].get();return t(n)})}function yd(e,t={}){const{isStatic:n}=f.useContext(ii),r=()=>si(e)?e.get():e;if(n)return bi(r);const o=ns(r());return f.useInsertionEffect(()=>gd(o,e,t),[o,JSON.stringify(t)]),o}function bd(e,t={}){return yd(e,{type:"spring",...t})}const xd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],wd=li("info",xd);const vd=[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]],kd=li("trophy",vd);function Sd({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:r=52,weekStartsOn:o="sun",cacheKey:s,timeZone:a,tzOffsetMinutes:i,now:l}={}){const c=f.useMemo(()=>ju({weeks:r,weekStartsOn:o,now:l}),[l,r,o]),[u,d]=f.useState([]),[h,g]=f.useState(null),[p,y]=f.useState("edge"),[x,v]=f.useState(!1),[b,w]=f.useState(null),S=jn(),C=An(t),k=!n,T=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),N=f.useMemo(()=>{if(!s)return null;const F=Yr({timeZone:a,offsetMinutes:i});return`tokentracker.heatmap.${s}.${r}.${o}.${F}`},[s,a,i,r,o]),I=f.useCallback(()=>{if(!N||typeof window>"u")return null;try{const F=window.localStorage.getItem(N);if(!F)return null;const _=JSON.parse(F);return!_||!_.heatmap?null:_}catch{return null}},[N]),M=f.useCallback(F=>{if(!(!N||typeof window>"u"))try{window.localStorage.setItem(N,JSON.stringify(F))}catch{}},[N]),R=f.useCallback(()=>{if(!(!N||typeof window>"u"))try{window.localStorage.removeItem(N)}catch{}},[N]),j=f.useCallback(async()=>{const F=await rn(t);if(!(!F&&!S&&!T)){v(!0),w(null);try{try{const O=await Au({baseUrl:e,accessToken:F,weeks:r,to:c.to,weekStartsOn:o,timeZone:a,tzOffsetMinutes:i}),P=Array.isArray(O?.weeks)?O.weeks:[];if(!P.length&&k){const Y=I();if(Y?.heatmap){g(Y.heatmap),d(Y.daily||[]),y("cache");return}}if(!P.some(Y=>(Array.isArray(Y)?Y:[]).some(ee=>ee&&Number.isFinite(Number(ee.level))))&&P.length){const Y=[];for(const H of P)for(const L of Array.isArray(H)?H:[])L?.day&&Y.push({day:L.day,total_tokens:L.total_tokens??L.value??0,billable_total_tokens:L.billable_total_tokens??L.value??L.total_tokens??0});const ee=Wo({dailyRows:Y,weeks:r,to:O?.to||c.to,weekStartsOn:o});d(Y),g({...ee,week_starts_on:o,active_days:Y.filter(H=>Number(H?.billable_total_tokens??H?.total_tokens)>0).length,streak_days:xr({dailyRows:Y,to:O?.to||c.to})}),y("client"),k?M({heatmap:{...ee,week_starts_on:o,active_days:Y.filter(H=>Number(H?.billable_total_tokens??H?.total_tokens)>0).length,streak_days:xr({dailyRows:Y,to:O?.to||c.to})},daily:Y,fetchedAt:new Date().toISOString()}):R();return}g(O||null),d([]),y("edge"),O&&k?M({heatmap:O,daily:[],fetchedAt:new Date().toISOString()}):k||R();return}catch(O){const P=O,U=P?.status??P?.statusCode;if(U===401||U===403)throw O}const _=await Xo({baseUrl:e,accessToken:F,from:c.from,to:c.to,timeZone:a,tzOffsetMinutes:i}),B=Array.isArray(_?.data)?_.data:[];d(B);const V=Wo({dailyRows:B,weeks:r,to:c.to,weekStartsOn:o});g({...V,week_starts_on:o,active_days:B.filter(O=>Number(O?.billable_total_tokens??O?.total_tokens)>0).length,streak_days:xr({dailyRows:B,to:c.to})}),y("client"),k?M({heatmap:{...V,week_starts_on:o,active_days:B.filter(O=>Number(O?.billable_total_tokens??O?.total_tokens)>0).length,streak_days:xr({dailyRows:B,to:c.to})},daily:B,fetchedAt:new Date().toISOString()}):R()}catch(_){if(k){const B=I();if(B?.heatmap)g(B.heatmap),d(B.daily||[]),y("cache"),w(null);else{const V=_;w(V?.message||String(V)),d([]),g(null),y("edge")}}else{const B=_;w(B?.message||String(B)),d([]),g(null),y("edge")}}finally{v(!1)}}},[t,e,S,n,k,c.from,c.to,I,C,a,i,o,r,R,M,T]);return f.useEffect(()=>{if(!C&&!n&&!S&&!T){d([]),v(!1),w(null),g(null),y("edge");return}if(!k)R(),d([]),w(null),g(null),y("edge");else{const F=I();F?.heatmap&&(g(F.heatmap),d(F.daily||[]),y("cache"))}j()},[t,S,I,j,C,n,k,R,T]),{range:c,daily:u,heatmap:h,source:S?"mock":p==="client"?"edge":p,loading:x,error:b,refresh:j}}function Cd({baseUrl:e,accessToken:t,limit:n=3,from:r,to:o,source:s,timeZone:a,tzOffsetMinutes:i}={}){const[l,c]=f.useState([]),[u,d]=f.useState(!1),[h,g]=f.useState(null),p=jn(),y=An(t),x=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),v=f.useCallback(async()=>{const b=await rn(t);if(!b&&!p&&!x){c([]),g(null),d(!1);return}d(!0),g(null);try{const w=await Iu({baseUrl:e,accessToken:b,limit:n,from:r,to:o,source:s,timeZone:a,tzOffsetMinutes:i});c(Array.isArray(w?.entries)?w.entries:[])}catch(w){const S=w?.message||String(w);g(S),c([])}finally{d(!1)}},[t,e,r,n,p,s,a,o,i,x]);return f.useEffect(()=>{if(!y&&!p&&!x){c([]),g(null),d(!1);return}v()},[p,v,y,x]),{entries:l,loading:u,error:h,refresh:v}}const Ed=24;function Md({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:r,from:o,to:s,months:a=Ed,cacheKey:i,timeZone:l,tzOffsetMinutes:c,now:u,sharedRows:d,sharedRange:h}={}){const[g,p]=f.useState([]),[y,x]=f.useState(()=>({from:o,to:s})),[v,b]=f.useState("edge"),[w,S]=f.useState(null),[C,k]=f.useState(!1),[T,N]=f.useState(null),I=jn(),M=An(t),R=!n,j=Array.isArray(d),E=h?.from||o,F=h?.to||s,_=f.useMemo(()=>r==="day"?"hourly":r==="total"?"monthly":"daily",[r]),B=(()=>{if(!i)return null;const H=Td(e)||"default",L=Yr({timeZone:l,offsetMinutes:c});if(_==="hourly")return`tokentracker.trend.${i}.${H}.hourly.${s||o||"day"}.${L}`;if(_==="monthly")return`tokentracker.trend.${i}.${H}.monthly.${a}.${s||"today"}.${L}`;const z=`${o||""}.${s||""}`;return`tokentracker.trend.${i}.${H}.daily.${z}.${L}`})(),V=f.useCallback(()=>{if(!B||typeof window>"u")return null;try{const H=window.localStorage.getItem(B);if(!H)return null;const L=JSON.parse(H);return!L||!Array.isArray(L.rows)?null:L}catch{return null}},[B]),O=f.useCallback(H=>{if(!(!B||typeof window>"u"))try{window.localStorage.setItem(B,JSON.stringify(H))}catch{}},[B]),P=f.useCallback(()=>{if(!(!B||typeof window>"u"))try{window.localStorage.removeItem(B)}catch{}},[B]),U=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),Y=f.useCallback(async()=>{if(j){p(Array.isArray(d)?d:[]),x({from:E,to:F}),b("shared"),S(null),k(!1),N(null);return}const H=await rn(t);if(!(!H&&!I&&!U)){k(!0),N(null);try{let L;_==="hourly"?L=await Fu({baseUrl:e,accessToken:H,day:s||o,timeZone:l,tzOffsetMinutes:c}):_==="monthly"?L=await Lu({baseUrl:e,accessToken:H,months:a,to:s,timeZone:l,tzOffsetMinutes:c}):L=await Xo({baseUrl:e,accessToken:H,from:o,to:s,timeZone:l,tzOffsetMinutes:c});const z=L?.from||o||L?.day||null,X=L?.to||s||L?.day||null;let oe=Array.isArray(L?.data)?L.data:[];_==="daily"?oe=fo(oe,z||o,X||s,{timeZone:l,offsetMinutes:c,now:u}):_==="hourly"?oe=mo(oe,{timeZone:l,offsetMinutes:c,now:u}):_==="monthly"&&(oe=ho(oe,{timeZone:l,offsetMinutes:c,now:u}));const be=new Date().toISOString();p(oe),x({from:z,to:X}),b("edge"),S(be),R?O({rows:oe,from:z,to:X,mode:_,fetchedAt:be}):P()}catch(L){if(R){const z=V();if(z?.rows){let X=_==="daily"?fo(z.rows||[],z.from||o,z.to||s,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(z.rows)?z.rows:[];_==="hourly"?X=mo(X,{timeZone:l,offsetMinutes:c,now:u}):_==="monthly"&&(X=ho(X,{timeZone:l,offsetMinutes:c,now:u})),p(X),x({from:z.from||o,to:z.to||s}),b("cache"),S(z.fetchedAt||null),N(null)}else{p([]),x({from:o,to:s}),b("edge"),S(null);const X=L;N(X?.message||String(X))}}else{p([]),x({from:o,to:s}),b("edge"),S(null);const z=L;N(z?.message||String(z))}}finally{k(!1)}}},[t,e,o,I,n,R,_,a,V,M,j,E,d,F,l,s,c,u,P,O,U]);f.useEffect(()=>{if(j){p(Array.isArray(d)?d:[]),x({from:E,to:F}),b("shared"),S(null),k(!1),N(null);return}if(!M&&!n&&!I&&!U){p([]),x({from:o,to:s}),N(null),k(!1),b("edge"),S(null);return}if(!R)P(),p([]),x({from:o,to:s}),N(null),b("edge"),S(null);else{const H=V();if(H?.rows){let L=_==="daily"?fo(H.rows||[],H.from||o,H.to||s,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(H.rows)?H.rows:[];_==="hourly"?L=mo(L,{timeZone:l,offsetMinutes:c,now:u}):_==="monthly"&&(L=ho(L,{timeZone:l,offsetMinutes:c,now:u})),p(L),x({from:H.from||o,to:H.to||s}),b("cache"),S(H.fetchedAt||null)}}Y()},[t,I,V,Y,j,E,d,F,M,n,R,P,U]);const ee=I?"mock":v;return{rows:g,from:y.from||o,to:y.to||s,source:ee,fetchedAt:w,loading:C,error:T,refresh:Y}}function Td(e){try{return new URL(e).host}catch{return null}}function uo(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())&&Tn(a)===t?a:null}function Od(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function fo(e,t,n,{timeZone:r,offsetMinutes:o,now:s}={}){const a=uo(t),i=uo(n);if(!a||!i||i<a)return Array.isArray(e)?e:[];const l=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,c=Jo({timeZone:r,offsetMinutes:o,date:l}),u=uo(c),d=u?u.getTime():l.getTime(),h=new Map;for(const p of e||[])p?.day&&h.set(p.day,p);const g=[];for(let p=a;p<=i;p=Od(p,1)){const y=Tn(p),x=h.get(y),v=p.getTime()>d;if(x){g.push({...x,missing:!1,future:v});continue}g.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 g}function mo(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const o=xi({timeZone:t,offsetMinutes:n,now:r});return o?e.map(s=>{const a=s?.hour||s?.label||"",i=Nd(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 ho(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const o=xi({timeZone:t,offsetMinutes:n,now:r});return o?e.map(s=>{const a=s?.month||s?.label||"",i=Rd(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 xi({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 h=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((b,w)=>(w.type&&w.value&&(b[w.type]=w.value),b),{}),g=Number(h.year),p=Number(h.month),y=Number(h.day),x=Number(h.hour),v=Number(h.minute);if(Number.isFinite(g)&&Number.isFinite(p)&&Number.isFinite(y)&&Number.isFinite(x)&&Number.isFinite(v)){const b=x*2+(v>=30?1:0);return{year:g,month:p,day:y,hour:x,minute:v,dayNum:g*1e4+p*100+y,slot:b}}}catch{}if(Number.isFinite(t)){const u=new Date(r.getTime()+t*60*1e3),d=u.getUTCFullYear(),h=u.getUTCMonth()+1,g=u.getUTCDate(),p=u.getUTCHours(),y=u.getUTCMinutes(),x=p*2+(y>=30?1:0);return{year:d,month:h,day:g,hour:p,minute:y,dayNum:d*1e4+h*100+g,slot:x}}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 Nd(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 d=c*2+(u>=30?1:0);return{dayNum:s*1e4+a*100+i,slot:d}}function Rd(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 Xs({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:o,includeDaily:s=!0,cacheKey:a,timeZone:i,tzOffsetMinutes:l,now:c}={}){const[u,d]=f.useState([]),[h,g]=f.useState(null),[p,y]=f.useState(null),[x,v]=f.useState("edge"),[b,w]=f.useState(null),[S,C]=f.useState(!1),[k,T]=f.useState(null),N=jn(),I=An(t),M=!n,R=(()=>{if(!a)return null;const O=Dd(e)||"default",P=s?"daily":"summary",U=Yr({timeZone:i,offsetMinutes:l});return`tokentracker.usage.${a}.${O}.${r}.${o}.${P}.${U}`})(),j=f.useCallback(()=>{if(!R||typeof window>"u")return null;try{const O=window.localStorage.getItem(R);if(!O)return null;const P=JSON.parse(O);return!P||!P.summary?null:P}catch{return null}},[R]),E=f.useCallback(O=>{if(!(!R||typeof window>"u"))try{window.localStorage.setItem(R,JSON.stringify(O))}catch{}},[R]),F=f.useCallback(()=>{if(!(!R||typeof window>"u"))try{window.localStorage.removeItem(R)}catch{}},[R]),_=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),B=f.useCallback(async()=>{const O=await rn(t);if(!(!O&&!N&&!_)){C(!0),T(null);try{let P=null,U=null;if(s){const[z,X]=await Promise.allSettled([Xo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l}),lo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l,rolling:!0})]);if(z.status==="rejected")throw z.reason;P=z.value,U=X.status==="fulfilled"?X.value:null}else U=await lo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l,rolling:!0});let Y=s&&Array.isArray(P?.data)?P.data:[];s&&(Y=po(Y,r,o,{timeZone:i,offsetMinutes:l,now:c}));let ee=U?.totals||P?.summary?.totals||null,H=U?.rolling||P?.summary?.rolling||null;if(s&&!ee&&!U)try{const z=await lo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l,rolling:!0});ee=z?.totals||null,H=z?.rolling||H}catch{}const L=new Date().toISOString();d(Y),g(ee),y(H),v("edge"),w(L),ee&&M?E({summary:ee,rolling:H,daily:Y,from:r,to:o,includeDaily:s,fetchedAt:L}):M||F()}catch(P){if(M){const U=j();if(U?.summary){g(U.summary),y(U.rolling||null);const Y=Array.isArray(U.daily)?U.daily:[],ee=s?po(Y,U.from||r,U.to||o,{timeZone:i,offsetMinutes:l,now:c}):Y;d(ee),v("cache"),w(U.fetchedAt||null),T(null)}else{const Y=P;T(Y?.message||String(Y)),d([]),g(null),y(null),v("edge"),w(null)}}else{const U=P;T(U?.message||String(U)),d([]),g(null),y(null),v("edge"),w(null)}}finally{C(!1)}}},[t,e,r,s,N,n,M,c,j,I,i,o,l,F,E,_]);return f.useEffect(()=>{const O=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!I&&!n&&!N&&!O){d([]),g(null),y(null),T(null),C(!1),v("edge"),w(null);return}if(!M)F(),d([]),g(null),y(null),T(null),v("edge"),w(null);else{const P=j();if(P?.summary){g(P.summary),y(P.rolling||null);const U=Array.isArray(P.daily)?P.daily:[],Y=s?po(U,P.from||r,P.to||o,{timeZone:i,offsetMinutes:l,now:c}):U;d(Y),v("cache"),w(P.fetchedAt||null)}}B()},[t,N,j,B,I,n,M,F,_]),{daily:u,summary:h,rolling:p,source:N?"mock":x,fetchedAt:b,loading:S,error:k,refresh:B}}function Dd(e){try{return new URL(e).host}catch{return null}}function go(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())&&Tn(a)===t?a:null}function _d(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function po(e,t,n,{timeZone:r,offsetMinutes:o,now:s}={}){const a=go(t),i=go(n);if(!a||!i||i<a)return Array.isArray(e)?e:[];const l=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,c=Jo({timeZone:r,offsetMinutes:o,date:l}),u=go(c),d=u?u.getTime():l.getTime(),h=new Map;for(const p of e||[])p?.day&&h.set(p.day,p);const g=[];for(let p=a;p<=i;p=_d(p,1)){const y=Tn(p),x=h.get(y),v=p.getTime()>d;if(x){g.push({...x,missing:!1,future:v});continue}g.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 g}function Pd(){const[e,t]=f.useState(null),[n,r]=f.useState(null),o=f.useCallback(async()=>{try{const s=await Wu();t(s&&typeof s=="object"?s:null),r(null)}catch(s){r(s?.message||String(s))}},[]);return f.useEffect(()=>{o()},[o]),{data:e,error:n,refresh:o}}function jd({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:o,cacheKey:s,timeZone:a,tzOffsetMinutes:i}={}){const[l,c]=f.useState(null),[u,d]=f.useState("edge"),[h,g]=f.useState(!1),[p,y]=f.useState(null),x=jn(),v=An(t),b=!n,w=f.useMemo(()=>{if(!s)return null;const M=Ad(e)||"default",R=Yr({timeZone:a,offsetMinutes:i});return`tokentracker.modelBreakdown.${s}.${M}.${r}.${o}.${R}`},[e,s,r,a,o,i]),S=f.useCallback(()=>{if(!w||typeof window>"u")return null;try{const M=window.localStorage.getItem(w);if(!M)return null;const R=JSON.parse(M);return!R||!R.breakdown?null:R}catch{return null}},[w]),C=f.useCallback(M=>{if(!(!w||typeof window>"u"))try{window.localStorage.setItem(w,JSON.stringify(M))}catch{}},[w]),k=f.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"),N=f.useCallback(async()=>{const M=await rn(t);if(!(!M&&!x&&!T)){g(!0),y(null);try{const R=await $u({baseUrl:e,accessToken:M,from:r,to:o,timeZone:a,tzOffsetMinutes:i});c(R||null),d("edge"),R&&b?C({breakdown:R,fetchedAt:new Date().toISOString()}):b||k()}catch(R){if(b){const j=S();if(j?.breakdown)c(j.breakdown),d("cache"),y(null);else{c(null),d("edge");const E=R;y(E?.message||String(E))}}else{c(null),d("edge");const j=R;y(j?.message||String(j))}}finally{g(!1)}}},[t,e,r,x,n,b,S,a,o,v,i,k,C,T]);return f.useEffect(()=>{if(!v&&!n&&!x&&!T){c(null),d("edge"),y(null),g(!1);return}if(!b)k(),c(null),d("edge"),y(null);else{const M=S();M?.breakdown&&(c(M.breakdown),d("cache"))}N()},[t,x,S,N,v,n,b,k,T]),{breakdown:l,source:x?"mock":u,loading:h,error:p,refresh:N}}function Ad(e){try{return new URL(e).host}catch{return null}}const wi=new Set(["day","hour","month"]);function Id(e){return wi.has(e)}function Js(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 Fd(e,t){const n=Js(e),r=Js(t);if(n&&r)return n.length!==r.length?n.length<r.length?-1:1:n===r?0:n<r?-1:1;const o=nt(e),s=nt(t);return o==null&&s==null?0:o==null?1:s==null?-1:o===s?0:o<s?-1:1}function Ld(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 Wd(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 $d(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 Bd(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 Yd(e,t,n){const r=n==="hour"?Bd:n==="month"?$d:Wd,o=r(e),s=r(t);return o!=null&&s!=null?o===s?0:o<s?-1:1:Ld(e,t)}function vi(e,{key:t,dir:n}){const r=n==="asc"?1:-1,o=Array.isArray(e)?e:[],s=wi.has(t)?(i,l)=>Yd(i,l,t):Fd,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),d=c==null,h=u==null;if(d&&h)return i.index-l.index;if(d)return 1;if(h)return-1;const g=s(c,u);return g!==0?g*r:i.index-l.index}).map(i=>i.row)}const Hd=[{key:"day",label:W("daily.sort.date.label"),title:W("daily.sort.date.title")},{key:"total_tokens",label:W("daily.sort.total.label"),title:W("daily.sort.total.title")},{key:"input_tokens",label:W("daily.sort.input.label"),title:W("daily.sort.input.title")},{key:"output_tokens",label:W("daily.sort.output.label"),title:W("daily.sort.output.title")},{key:"cached_input_tokens",label:W("daily.sort.cached.label"),title:W("daily.sort.cached.title")},{key:"reasoning_output_tokens",label:W("daily.sort.reasoning.label"),title:W("daily.sort.reasoning.title")},{key:"conversation_count",label:W("daily.sort.conversations.label"),title:W("daily.sort.conversations.title")}];function Qs(e){const t=Id(e)?e:"day";return Hd.map((n,r)=>r===0?{...n,key:t}:n)}function Zs(e,{key:t,dir:n}){return vi(e,{key:t,dir:n})}const _r=12,Ud=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function Vd(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 qd(e){return Ud.some(t=>Vd(e?.[t]))}function Gd(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=vi(t,{key:"month",dir:"asc"}),r=n.findIndex(o=>o?.month&&qd(o));return r===-1?t:n.slice(r)}function zd(e,t,n=_r){const r=Array.isArray(e)?e:[],o=Number.isFinite(n)&&n>0?n:_r,a=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*o;return r.slice(a,a+o)}function Kd({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 ki(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function Xd(e){const t=ki(e?.model_id);return t||null}function Si(e,t){return e?.model?String(e.model):t}function Jd(e,{copyFn:t}={}){const n=typeof t=="function"?t:a=>a,o=(Array.isArray(e?.sources)?e.sources:[]).map(a=>{const i=nt(a?.totals?.billable_total_tokens??a?.totals?.total_tokens)??0,l=nt(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(d=>{const h=nt(d?.totals?.billable_total_tokens??d?.totals?.total_tokens)??0;if(!Number.isFinite(h)||h<=0)return null;const g=a.totalTokens>0?Math.round(h/a.totalTokens*1e3)/10:0,p=Si(d,n("shared.placeholder.short")),y=Xd(d),x=a.totalCost>0&&a.totalTokens>0?h/a.totalTokens*a.totalCost:null;return{id:y,name:p,share:g,usage:h,cost:x}}).filter(Boolean);return{label:i,totalPercent:String(c),usd:a.totalCost,usage:a.totalTokens,models:u}})}function Qd(e,{limit:t=3,copyFn:n}={}){const r=typeof n=="function"?n:h=>h,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 h of o){const g=Array.isArray(h?.models)?h.models:[];for(const p of g){const y=nt(p?.totals?.billable_total_tokens)??0;if(!Number.isFinite(y)||y<=0)continue;l+=y;const x=Si(p,r("shared.placeholder.short")),v=ki(x);if(!v)continue;s.set(v,(s.get(v)||0)+y);const b=i.get(v)||0;y>=b&&(i.set(v,y),a.set(v,x))}}if(!s.size)return[];const c=Array.from(s.values()).reduce((h,g)=>h+g,0),u=l>0?l:c,d=Number.isFinite(t)?Math.max(0,Math.floor(t)):3;return Array.from(s.entries()).map(([h,g])=>{const p=u>0?(g/u*100).toFixed(1):"0.0";return{id:h,name:a.get(h)||r("shared.placeholder.short"),tokens:g,percent:String(p)}}).sort((h,g)=>g.tokens!==h.tokens?g.tokens-h.tokens:String(h.name).localeCompare(String(g.name))).slice(0,d)}const Qt=12,Vn=3,yo=26,Zd=["#ecfdf5","#a7f3d0","#6ee7b7","#34d399","#10b981"],ef=["#064e3b","#065f46","#059669","#10b981","#34d399"],tf=[W("heatmap.month.jan"),W("heatmap.month.feb"),W("heatmap.month.mar"),W("heatmap.month.apr"),W("heatmap.month.may"),W("heatmap.month.jun"),W("heatmap.month.jul"),W("heatmap.month.aug"),W("heatmap.month.sep"),W("heatmap.month.oct"),W("heatmap.month.nov"),W("heatmap.month.dec")];function nf(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 rf(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 Ci(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function of(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function sf(e,t){const n=t==="mon"?1:0,r=e.getUTCDay();return Ci(e,-((r-n+7)%7))}function af(e,t,n){if(!e)return[];const r=rf(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=sf(r,n),a=Ci(s,-(e-1)*7),i=[],l=new Set;for(const c of o){const u=Math.floor(of(a,c)/7);u<0||u>=e||l.has(u)||(l.add(u),i.push({label:tf[c.getUTCMonth()],index:u}))}return i}function lf({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:r=!1}){const{resolvedTheme:o}=ts(),a=o==="dark"?ef:Zd,i=f.useRef(null);f.useEffect(()=>{const p=i.current;p&&(p.scrollLeft=p.scrollWidth)},[e?.weeks]);const l=e?.week_starts_on==="mon"?"mon":"sun",c=f.useMemo(()=>{const p=Array.isArray(e?.weeks)?e.weeks:[];if(!p.length)return{weeks:[]};const y=[];for(const x of p)for(const v of Array.isArray(x)?x:[])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 Wo({dailyRows:y,weeks:Math.max(52,p.length),to:e?.to,weekStartsOn:l})},[e?.to,e?.weeks,l]),u=c?.weeks||[],d=l==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(p=>W(`heatmap.day.${p.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(p=>W(`heatmap.day.${p.toLowerCase()}`)),h=f.useMemo(()=>af(u.length,c?.to,l),[c?.to,u.length,l]);if(!u.length)return m.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:W("heatmap.empty")});const g=yo+u.length*Qt+Math.max(0,u.length-1)*Vn;return m.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:[m.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[m.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:W("heatmap.title")}),m.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400",children:n||W("heatmap.legend.utc")})]}),m.jsx("div",{ref:i,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:m.jsxs("div",{style:{minWidth:g},children:[m.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:`${yo}px repeat(${u.length}, ${Qt}px)`,columnGap:Vn},children:[m.jsx("span",{}),h.map(p=>m.jsx("span",{style:{gridColumnStart:p.index+2},className:"whitespace-nowrap",children:p.label},`${p.label}-${p.index}`))]}),m.jsxs("div",{className:"grid",style:{gridTemplateColumns:`${yo}px repeat(${u.length}, ${Qt}px)`,columnGap:Vn},children:[m.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, ${Qt}px)`,rowGap:Vn},children:d.map(p=>m.jsx("span",{className:"leading-none",children:p},p))}),m.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${Qt}px)`,gap:Vn},children:u.map((p,y)=>(Array.isArray(p)?p:[]).map((x,v)=>{if(!x)return null;const b=x.day||`e-${y}-${v}`,w=Number(x.level)||0,S=a[w]||a[0],C=t||n||W("heatmap.legend.utc");return m.jsx("span",{title:W("heatmap.tooltip",{day:x.day,value:nf(x.value),unit:W("heatmap.unit.tokens"),tz:C}),className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10",style:{width:Qt,height:Qt,background:S}},b)}))})]})]})}),!r&&m.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[m.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:W("heatmap.legend.less")}),m.jsx("div",{className:"flex gap-0.5",children:a.map((p,y)=>m.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:p}},y))}),m.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:W("heatmap.legend.more")})]})]})}const cf={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},Ei={...cf,position:"fixed",top:0,left:0};function bt(e){const t=qt(uf,e).current;return t.next=e,Ee(t.effect),t}function uf(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Pr=Symbol("NOT_FOUND");function df(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function ff(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function mf(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 ea=e=>Array.isArray(e)?e:[e];function hf(e){const t=Array.isArray(e[0])?e[0]:e;return mf(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function gf(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}function pf(e){let t;return{get(n){return t&&e(t.key,n)?t.value:Pr},put(n,r){t={key:n,value:r}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function yf(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 Pr}function o(i,l){r(i)===Pr&&(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 bf=(e,t)=>e===t;function xf(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 wf(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:r=bf,maxSize:o=1,resultEqualityCheck:s}=n,a=xf(r);let i=0;const l=o<=1?pf(a):yf(o,a);function c(){let u=l.get(arguments);if(u===Pr){if(u=e.apply(null,arguments),i++,s){const h=l.getEntries().find(g=>s(g.value,u));h&&(u=h.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 vf=class{constructor(e){this.value=e}deref(){return this.value}},kf=typeof WeakRef<"u"?WeakRef:vf,Sf=0,ta=1;function wr(){return{s:Sf,v:void 0,o:null,p:null}}function Mi(e,t={}){let n=wr();const{resultEqualityCheck:r}=t;let o,s=0;function a(){let i=n;const{length:l}=arguments;for(let d=0,h=l;d<h;d++){const g=arguments[d];if(typeof g=="function"||typeof g=="object"&&g!==null){let p=i.o;p===null&&(i.o=p=new WeakMap);const y=p.get(g);y===void 0?(i=wr(),p.set(g,i)):i=y}else{let p=i.p;p===null&&(i.p=p=new Map);const y=p.get(g);y===void 0?(i=wr(),p.set(g,i)):i=y}}const c=i;let u;if(i.s===ta)u=i.v;else if(u=e.apply(null,arguments),s++,r){const d=o?.deref?.()??o;d!=null&&r(d,u)&&(u=d,s!==0&&s--),o=typeof u=="object"&&u!==null||typeof u=="function"?new kf(u):u}return c.s=ta,c.v=u,u}return a.clearCache=()=>{n=wr(),a.resetResultsCount()},a.resultsCount=()=>s,a.resetResultsCount=()=>{s=0},a}function Ti(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()),df(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const u={...n,...l},{memoize:d,memoizeOptions:h=[],argsMemoize:g=Mi,argsMemoizeOptions:p=[]}=u,y=ea(h),x=ea(p),v=hf(o),b=d(function(){return s++,c.apply(null,arguments)},...y),w=g(function(){a++;const C=gf(v,arguments);return i=b.apply(null,C),i},...x);return Object.assign(w,{resultFunc:c,memoizedResultFunc:b,dependencies:v,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>i,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:d,argsMemoize:g})};return Object.assign(r,{withTypes:()=>r}),r}var Cf=Ti(Mi),Ef=Object.assign((e,t=Cf)=>{ff(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:()=>Ef});Ti({memoize:wf,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const ge=(e,t,n,r,o,s,...a)=>{if(a.length>0)throw new Error(an(1));let i;if(e)i=e;else throw new Error("Missing arguments");return i};var bo={exports:{}},xo={};var na;function Mf(){if(na)return xo;na=1;var e=ci();function t(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,a=e.useDebugValue;function i(d,h){var g=h(),p=r({inst:{value:g,getSnapshot:h}}),y=p[0].inst,x=p[1];return s(function(){y.value=g,y.getSnapshot=h,l(y)&&x({inst:y})},[d,g,h]),o(function(){return l(y)&&x({inst:y}),d(function(){l(y)&&x({inst:y})})},[d]),a(g),g}function l(d){var h=d.getSnapshot;d=d.value;try{var g=h();return!n(d,g)}catch{return!0}}function c(d,h){return h()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:i;return xo.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,xo}var ra;function Oi(){return ra||(ra=1,bo.exports=Mf()),bo.exports}var Tf=Oi(),wo={exports:{}},vo={};var oa;function Of(){if(oa)return vo;oa=1;var e=ci(),t=Oi();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 vo.useSyncExternalStoreWithSelector=function(c,u,d,h,g){var p=s(null);if(p.current===null){var y={hasValue:!1,value:null};p.current=y}else y=p.current;p=i(function(){function v(k){if(!b){if(b=!0,w=k,k=h(k),g!==void 0&&y.hasValue){var T=y.value;if(g(T,k))return S=T}return S=k}if(T=S,r(w,k))return T;var N=h(k);return g!==void 0&&g(T,N)?(w=k,T):(w=k,S=N)}var b=!1,w,S,C=d===void 0?null:d;return[function(){return v(u())},C===null?void 0:function(){return v(C())}]},[u,d,h,g]);var x=o(c,p[0],p[1]);return a(function(){y.hasValue=!0,y.value=x},[x]),l(x),x},vo}var sa;function Nf(){return sa||(sa=1,wo.exports=Of()),wo.exports}var Rf=Nf();const Df=ui(19),_f=Df?jf:Af;function Pf(e,t,n,r,o){return _f(e,t,n,r,o)}function jf(e,t,n,r,o){const s=f.useCallback(()=>t(e.getSnapshot(),n,r,o),[e,t,n,r,o]);return Tf.useSyncExternalStore(e.subscribe,s,s)}function Af(e,t,n,r,o){return Rf.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,s=>t(s,n,r,o))}class Jn{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])){Jn.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||Jn.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};Jn.prototype.setState.call(this,t)}}class rs extends Jn{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}controlledValues=new Map;useSyncedValue(t,n){f.useDebugValue(t),Ee(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){const r=this;Ee(()=>(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);Ee(()=>{n.update(t)},[n,...r])}useControlledProp(t,n,r){f.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})),Ee(()=>{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)=>{f.useDebugValue(t);const s=this.selectors[t];return Pf(this,s,n,r,o)};useContextCallback(t,n){f.useDebugValue(t);const r=me(n??di);this.context[t]=r}useStateSetter(t){const n=f.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 If=[];function os(e){f.useEffect(e,If)}const vr=null;class Ff{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 kr=new Ff;class yt{static create(){return new yt}static request(t){return kr.request(t)}static cancel(t){return kr.cancel(t)}currentId=vr;request(t){this.cancel(),this.currentId=kr.request(()=>{this.currentId=vr,t()})}cancel=()=>{this.currentId!==vr&&(kr.cancel(this.currentId),this.currentId=vr)};disposeEffect=()=>this.cancel}function ss(){const e=qt(yt.create).current;return os(e.disposeEffect),e}const qn=0;class Vt{static create(){return new Vt}currentId=qn;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=qn,n()},t)}isStarted(){return this.currentId!==qn}clear=()=>{this.currentId!==qn&&(clearTimeout(this.currentId),this.currentId=qn)};disposeEffect=()=>this.clear}function on(){const e=qt(Vt.create).current;return os(e.disposeEffect),e}const In=typeof navigator<"u",ko=Bf(),Ni=Hf(),Ri=Yf(),Lf=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),Di=ko.platform==="MacIntel"&&ko.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(ko.platform),Wf=In&&/apple/i.test(navigator.vendor),$o=In&&/android/i.test(Ni)||/android/i.test(Ri);In&&Ni.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const $f=Ri.includes("jsdom/");function Bf(){if(!In)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 Yf(){if(!In)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function Hf(){if(!In)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const Bo="data-base-ui-focusable",_i="active",Pi="selected",ji="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function wn(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function ve(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Bu(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function Ze(e){return"composedPath"in e?e.composedPath()[0]:e.target}function ut(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 Uf(e){return e.matches("html,body")}function Ye(e){return e?.ownerDocument||document}function Ai(e){return Ke(e)&&e.matches(ji)}function aa(e){return e?e.getAttribute("role")==="combobox"&&Ai(e):!1}function Yo(e){return e?e.hasAttribute(Bo)?e:e.querySelector(`[${Bo}]`)||e:null}function nn(e,t,n=!0){return e.filter(o=>o.parentId===t&&(!n||o.context?.open)).flatMap(o=>[o,...nn(e,o.id,n)])}function ia(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 Vf(e){e.preventDefault(),e.stopPropagation()}function qf(e){return"nativeEvent"in e}function Gf(e){return e.mozInputSource===0&&e.isTrusted?!0:$o&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function zf(e){return $f?!1:!$o&&e.width===0&&e.height===0||$o&&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 Nn(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function Ii(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const Kf=["top","right","bottom","left"],Rn=Math.min,et=Math.max,jr=Math.round,Sr=Math.floor,kt=e=>({x:e,y:e}),Xf={left:"right",right:"left",bottom:"top",top:"bottom"};function Ho(e,t,n){return et(e,Rn(t,n))}function Pt(e,t){return typeof e=="function"?e(t):e}function Xe(e){return e.split("-")[0]}function Gt(e){return e.split("-")[1]}function as(e){return e==="x"?"y":"x"}function is(e){return e==="y"?"height":"width"}function at(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ls(e){return as(at(e))}function Jf(e,t,n){n===void 0&&(n=!1);const r=Gt(e),o=ls(e),s=is(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Ar(a)),[a,Ar(a)]}function Qf(e){const t=Ar(e);return[Uo(e),t,Uo(t)]}function Uo(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const la=["left","right"],ca=["right","left"],Zf=["top","bottom"],em=["bottom","top"];function tm(e,t,n){switch(e){case"top":case"bottom":return n?t?ca:la:t?la:ca;case"left":case"right":return t?Zf:em;default:return[]}}function nm(e,t,n,r){const o=Gt(e);let s=tm(Xe(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(Uo)))),s}function Ar(e){const t=Xe(e);return Xf[t]+e.slice(t.length)}function rm(e){return{top:0,right:0,bottom:0,left:0,...e}}function Fi(e){return typeof e!="number"?rm(e):{top:e,right:e,bottom:e,left:e}}function Ir(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 om=["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] *)"],Fr=om.join(","),Li=typeof Element>"u",Dn=Li?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Lr=!Li&&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},Wr=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]"):Wr(t.parentNode));return a},sm=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},Wi=function(t,n,r){if(Wr(t))return[];var o=Array.prototype.slice.apply(t.querySelectorAll(Fr));return n&&Dn.call(t,Fr)&&o.unshift(t),o=o.filter(r),o},$r=function(t,n,r){for(var o=[],s=Array.from(t);s.length;){var a=s.shift();if(!Wr(a,!1))if(a.tagName==="SLOT"){var i=a.assignedElements(),l=i.length?i:a.children,c=$r(l,!0,r);r.flatten?o.push.apply(o,c):o.push({scopeParent:a,candidates:c})}else{var u=Dn.call(a,Fr);u&&r.filter(a)&&(n||!t.includes(a))&&o.push(a);var d=a.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(a),h=!Wr(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(a));if(d&&h){var g=$r(d===!0?a.children:d.children,!0,r);r.flatten?o.push.apply(o,g):o.push({scopeParent:a,candidates:g})}else s.unshift.apply(s,a.children)}}return o},$i=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Bi=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||sm(t))&&!$i(t)?0:t.tabIndex},am=function(t,n){var r=Bi(t);return r<0&&n&&!$i(t)?0:r},im=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Yi=function(t){return t.tagName==="INPUT"},lm=function(t){return Yi(t)&&t.type==="hidden"},cm=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},um=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},dm=function(t){if(!t.name)return!0;var n=t.form||Lr(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=um(o,t.form);return!s||s===t},fm=function(t){return Yi(t)&&t.type==="radio"},mm=function(t){return fm(t)&&!dm(t)},hm=function(t){var n,r=t&&Lr(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,d;r=Lr(o),o=(c=r)===null||c===void 0?void 0:c.host,s=!!((u=o)!==null&&u!==void 0&&(d=u.ownerDocument)!==null&&d!==void 0&&d.contains(o))}}return s},ua=function(t){var n=t.getBoundingClientRect(),r=n.width,o=n.height;return r===0&&o===0},gm=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=Dn.call(t,"details>summary:first-of-type"),i=a?t.parentElement:t;if(Dn.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=Lr(t);if(c&&!c.shadowRoot&&o(c)===!0)return ua(t);t.assignedSlot?t=t.assignedSlot:!c&&u!==t.ownerDocument?t=u.host:t=c}t=l}if(hm(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return ua(t);return!1},pm=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 Dn.call(n,"fieldset[disabled] *")?!0:!o.contains(t)}return!0}n=n.parentElement}return!1},Vo=function(t,n){return!(n.disabled||lm(n)||gm(n,t)||cm(n)||pm(n))},qo=function(t,n){return!(mm(n)||Bi(n)<0||!Vo(t,n))},ym=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Hi=function(t){var n=[],r=[];return t.forEach(function(o,s){var a=!!o.scopeParent,i=a?o.scopeParent:o,l=am(i,a),c=a?Hi(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(im).reduce(function(o,s){return s.isScope?o.push.apply(o,s.content):o.push(s.content),o},[]).concat(n)},ar=function(t,n){n=n||{};var r;return n.getShadowRoot?r=$r([t],n.includeContainer,{filter:qo.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:ym}):r=Wi(t,n.includeContainer,qo.bind(null,n)),Hi(r)},bm=function(t,n){n=n||{};var r;return n.getShadowRoot?r=$r([t],n.includeContainer,{filter:Vo.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=Wi(t,n.includeContainer,Vo.bind(null,n)),r},Ui=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return Dn.call(t,Fr)===!1?!1:qo(n,t)};const Fn=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Vi(e,t){const n=ar(e,Fn()),r=n.length;if(r===0)return;const o=wn(Ye(e)),s=n.indexOf(o),a=s===-1?t===1?0:r-1:s+t;return n[a]}function cs(e){return Vi(Ye(e).body,1)||e}function qi(e){return Vi(Ye(e).body,-1)||e}function Gi(e,t){if(!e)return null;const n=ar(Ye(e).body,Fn()),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 xm(e){return Gi(e,1)}function wm(e){return Gi(e,-1)}function Sn(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!ve(n,r)}function vm(e){ar(e,Fn()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function da(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 km={...Yu};let fa=0;function Sm(e,t="mui"){const[n,r]=f.useState(e),o=e||n;return f.useEffect(()=>{n==null&&(fa+=1,r(`${t}-${fa}`))},[n,t]),o}const ma=km.useId;function Ln(e,t){if(ma!==void 0){const n=ma();return e??(t?`${t}-${n}`:n)}return Sm(e,t)}function zi(){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 Cm{nodesRef={current:[]};events=zi();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 Ki=f.createContext(null),Xi=f.createContext(null),ln=()=>f.useContext(Ki)?.id||null,Wn=e=>{const t=f.useContext(Xi);return e??t};function Em(e){const t=Ln(),n=Wn(e),r=ln();return Ee(()=>{if(!t)return;const o={id:t,parentId:r};return n?.addNode(o),()=>{n?.removeNode(o)}},[n,t,r]),t}function Mm(e){const{children:t,id:n}=e,r=ln();return m.jsx(Ki.Provider,{value:f.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Tm(e){const{children:t,externalTree:n}=e,r=qt(()=>n??new Cm).current;return m.jsx(Xi.Provider,{value:r,children:t})}const Om="none",Ht="trigger-press",tt="trigger-hover",Ji="outside-press",Nm="close-press",Qn="focus-out",Qi="escape-key",Zi="imperative-action";function Pe(e,t,n,r){let o=!1,s=!1;const a=Yt;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 Zn(e){return`data-base-ui-${e}`}function So(e,t,n){if(n&&!Nn(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 cn(e){return e?.ownerDocument||document}const _n=f.forwardRef(function(t,n){const[r,o]=f.useState();Ee(()=>{Wf&&o("button")},[]);const s={tabIndex:0,role:r};return m.jsx("span",{...t,ref:n,style:Ei,"aria-hidden":r?void 0:!0,...s,"data-base-ui-focus-guard":""})});let ha=0;function Co(e,t={}){const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(ha);const s=()=>e?.focus({preventScroll:n});o?s():ha=requestAnimationFrame(s)}const Cn={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function ga(e){return e==="inert"?Cn.inert:e==="aria-hidden"?Cn["aria-hidden"]:Cn.none}let Cr=new WeakSet,Er={},Eo=0;const el=e=>e&&(e.host||el(e.parentNode)),Rm=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=el(n);return e.contains(r)?r:null}).filter(n=>n!=null);function Dm(e,t,n,r){const o="data-base-ui-inert",s=r?"inert":n?"aria-hidden":null,a=Rm(t,e),i=new Set,l=new Set(a),c=[];Er[o]||(Er[o]=new WeakMap);const u=Er[o];a.forEach(d),h(t),i.clear();function d(g){!g||i.has(g)||(i.add(g),g.parentNode&&d(g.parentNode))}function h(g){!g||l.has(g)||[].forEach.call(g.children,p=>{if(or(p)!=="script")if(i.has(p))h(p);else{const y=s?p.getAttribute(s):null,x=y!==null&&y!=="false",v=ga(s),b=(v.get(p)||0)+1,w=(u.get(p)||0)+1;v.set(p,b),u.set(p,w),c.push(p),b===1&&x&&Cr.add(p),w===1&&p.setAttribute(o,""),!x&&s&&p.setAttribute(s,s==="inert"?"":"true")}})}return Eo+=1,()=>{c.forEach(g=>{const p=ga(s),x=(p.get(g)||0)-1,v=(u.get(g)||0)-1;p.set(g,x),u.set(g,v),x||(!Cr.has(g)&&s&&g.removeAttribute(s),Cr.delete(g)),v||g.removeAttribute(o)}),Eo-=1,Eo||(Cn.inert=new WeakMap,Cn["aria-hidden"]=new WeakMap,Cn.none=new WeakMap,Cr=new WeakSet,Er={})}}function _m(e,t=!1,n=!1){const r=Ye(e[0]).body;return Dm(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const tl=f.createContext(null),nl=()=>f.useContext(tl),Pm=Zn("portal");function jm(e={}){const{ref:t,container:n,componentProps:r=Yt,elementProps:o,elementState:s}=e,a=Ln(),l=nl()?.portalNode,[c,u]=f.useState(null),[d,h]=f.useState(null),g=me(v=>{v!==null&&h(v)}),p=f.useRef(null);Ee(()=>{if(n===null){p.current&&(p.current=null,h(null),u(null));return}if(a==null)return;const v=(n&&(Hu(n)?n:n.current))??l??document.body;if(v==null){p.current&&(p.current=null,h(null),u(null));return}p.current!==v&&(p.current=v,h(null),u(v))},[n,l,a]);const y=jt("div",r,{ref:[t,g],state:s,props:[{id:a,[Pm]:""},o]});return{portalNode:d,portalSubtree:c&&y?Ut.createPortal(y,c):null}}const rl=f.forwardRef(function(t,n){const{children:r,container:o,className:s,render:a,renderGuards:i,...l}=t,{portalNode:c,portalSubtree:u}=jm({container:o,ref:n,componentProps:t,elementProps:l}),d=f.useRef(null),h=f.useRef(null),g=f.useRef(null),p=f.useRef(null),[y,x]=f.useState(null),v=y?.modal,b=y?.open,w=typeof i=="boolean"?i:!!y&&!y.modal&&y.open&&!!c;f.useEffect(()=>{if(!c||v)return;function C(k){c&&k.relatedTarget&&Sn(k)&&(k.type==="focusin"?da:vm)(c)}return c.addEventListener("focusin",C,!0),c.addEventListener("focusout",C,!0),()=>{c.removeEventListener("focusin",C,!0),c.removeEventListener("focusout",C,!0)}},[c,v]),f.useEffect(()=>{!c||b||da(c)},[b,c]);const S=f.useMemo(()=>({beforeOutsideRef:d,afterOutsideRef:h,beforeInsideRef:g,afterInsideRef:p,portalNode:c,setFocusManagerState:x}),[c]);return m.jsxs(f.Fragment,{children:[u,m.jsxs(tl.Provider,{value:S,children:[w&&c&&m.jsx(_n,{"data-type":"outside",ref:d,onFocus:C=>{if(Sn(C,c))g.current?.focus();else{const k=y?y.domReference:null;qi(k)?.focus()}}}),w&&c&&m.jsx("span",{"aria-owns":c.id,style:md}),c&&Ut.createPortal(r,c),w&&c&&m.jsx(_n,{"data-type":"outside",ref:h,onFocus:C=>{if(Sn(C,c))p.current?.focus();else{const k=y?y.domReference:null;cs(k)?.focus(),y?.closeOnFocusOut&&y?.onOpenChange(!1,Pe(Qn,C.nativeEvent))}}})]})]})});function Rt(e){return e==null?e:"current"in e?e.current:e}function Am(e,t){const n=it(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 pa=20;let Bt=[];function us(){Bt=Bt.filter(e=>e.isConnected)}function Im(e){us(),e&&or(e)!=="body"&&(Bt.push(e),Bt.length>pa&&(Bt=Bt.slice(-pa)))}function Mo(){return us(),Bt[Bt.length-1]}function Fm(e){if(!e)return null;const t=Fn();return Ui(e,t)?e:ar(e,t)[0]||e}function Lm(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():ht(e).display!=="none"}function ya(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=Fn(),o=bm(e,n).filter(a=>{const i=a.getAttribute("data-tabindex")||"";return Ui(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 ol(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:d=()=>[],nextFocusableElement:h,previousFocusableElement:g,beforeContentFocusGuardRef:p,externalTree:y}=e,x="rootStore"in t?t.rootStore:t,v=x.useState("open"),b=x.useState("domReferenceElement"),w=x.useState("floatingElement"),{events:S,dataRef:C}=x.context,k=me(()=>C.current.floatingContext?.nodeId),T=me(d),N=s===!1,I=aa(b)&&N,M=bt(o),R=bt(s),j=bt(a),E=bt(u),F=Wn(y),_=nl(),B=f.useRef(null),V=f.useRef(null),O=f.useRef(!1),P=f.useRef(!1),U=f.useRef(!1),Y=f.useRef(-1),ee=f.useRef(""),H=f.useRef(""),L=f.useRef(null),z=f.useRef(null),X=Vs(L,p,_?.beforeInsideRef),oe=Vs(z,_?.afterInsideRef),be=on(),Oe=on(),xe=ss(),We=_!=null,D=Yo(w),ae=me(($=D)=>$?ar($,Fn()):[]),q=me($=>{const J=ae($);return M.current.map(()=>J).filter(Boolean).flat()});f.useEffect(()=>{if(r||!l)return;function $(ie){ie.key==="Tab"&&ve(D,wn(Ye(D)))&&ae().length===0&&!I&&Vf(ie)}const J=Ye(D);return J.addEventListener("keydown",$),()=>{J.removeEventListener("keydown",$)}},[r,b,D,l,M,I,ae,q]),f.useEffect(()=>{if(r||!w)return;function $(J){const ie=Ze(J),de=ae().indexOf(ie);de!==-1&&(Y.current=de)}return w.addEventListener("focusin",$),()=>{w.removeEventListener("focusin",$)}},[r,w,ae]),f.useEffect(()=>{if(r||!v)return;const $=Ye(D);function J(){U.current=!1}function ie(de){const se=Ze(de),Z=ve(w,se)||ve(b,se)||ve(_?.portalNode,se);U.current=!Z,H.current=de.pointerType||"keyboard"}function he(){H.current="keyboard"}return $.addEventListener("pointerdown",ie,!0),$.addEventListener("pointerup",J,!0),$.addEventListener("pointercancel",J,!0),$.addEventListener("keydown",he,!0),()=>{$.removeEventListener("pointerdown",ie,!0),$.removeEventListener("pointerup",J,!0),$.removeEventListener("pointercancel",J,!0),$.removeEventListener("keydown",he,!0)}},[r,w,b,D,v,_]),f.useEffect(()=>{if(r||!c)return;function $(){P.current=!0,Oe.start(0,()=>{P.current=!1})}function J(se){const Z=se.relatedTarget,De=se.currentTarget,ke=Ze(se);queueMicrotask(()=>{const Ie=k(),pe=x.context.triggerElements,Je=Z?.hasAttribute(Zn("focus-guard"))&&[L.current,z.current,_?.beforeInsideRef.current,_?.afterInsideRef.current,_?.beforeOutsideRef.current,_?.afterOutsideRef.current,Rt(g),Rt(h)].includes(Z),Fe=!(ve(b,Z)||ve(w,Z)||ve(Z,w)||ve(_?.portalNode,Z)||Z!=null&&pe.hasElement(Z)||pe.hasMatchingElement(Se=>ve(Se,Z))||Je||F&&(nn(F.nodesRef.current,Ie).find(Se=>ve(Se.context?.elements.floating,Z)||ve(Se.context?.elements.domReference,Z))||ia(F.nodesRef.current,Ie).find(Se=>[Se.context?.elements.floating,Yo(Se.context?.elements.floating)].includes(Z)||Se.context?.elements.domReference===Z)));if(De===b&&D&&ya(D,M),i&&De!==b&&!Lm(ke)&&wn(Ye(D))===Ye(D).body){if(Ke(D)&&(D.focus(),i==="popup")){xe.request(()=>{D.focus()});return}const Se=Y.current,Ue=ae(),He=Ue[Se]||Ue[Ue.length-1]||D;Ke(He)&&He.focus()}if(C.current.insideReactTree){C.current.insideReactTree=!1;return}(I||!l)&&Z&&Fe&&!P.current&&(I||Z!==Mo())&&(O.current=!0,x.setOpen(!1,Pe(Qn,se)))})}function ie(){U.current||(C.current.insideReactTree=!0,be.start(0,()=>{C.current.insideReactTree=!1}))}const he=Ke(b)?b:null,de=[];if(!(!w&&!he))return he&&(he.addEventListener("focusout",J),he.addEventListener("pointerdown",$),de.push(()=>{he.removeEventListener("focusout",J),he.removeEventListener("pointerdown",$)})),w&&(w.addEventListener("focusout",J),_&&(w.addEventListener("focusout",ie,!0),de.push(()=>{w.removeEventListener("focusout",ie,!0)})),de.push(()=>{w.removeEventListener("focusout",J)})),()=>{de.forEach(se=>{se()})}},[r,b,w,D,l,F,_,x,c,i,ae,I,k,M,C,be,Oe,xe,h,g]),f.useEffect(()=>{if(r||!w||!v)return;const $=Array.from(_?.portalNode?.querySelectorAll(`[${Zn("portal")}]`)||[]),ie=(F?ia(F.nodesRef.current,k()):[]).find(se=>aa(se.context?.elements.domReference||null))?.context?.elements.domReference,he=[w,ie,...$,...T(),B.current,V.current,L.current,z.current,_?.beforeOutsideRef.current,_?.afterOutsideRef.current,Rt(g),Rt(h),I?b:null].filter(se=>se!=null),de=_m(he,l||I);return()=>{de()}},[v,r,b,w,l,M,_,I,F,k,T,h,g]),Ee(()=>{if(!v||r||!Ke(D))return;const $=Ye(D),J=wn($);queueMicrotask(()=>{const ie=q(D),he=R.current,de=typeof he=="function"?he(E.current||""):he;if(de===void 0||de===!1)return;let se;de===!0||de===null?se=ie[0]||D:se=Rt(de),se=se||ie[0]||D,!ve(D,J)&&Co(se,{preventScroll:se===D})})},[r,v,D,N,q,R,E]),Ee(()=>{if(r||!D)return;const $=Ye(D),J=wn($);Im(J);function ie(se){if(se.open||(ee.current=Am(se.nativeEvent,H.current)),se.reason===tt&&se.nativeEvent.type==="mouseleave"&&(O.current=!0),se.reason===Ji)if(se.nested)O.current=!1;else if(Gf(se.nativeEvent)||zf(se.nativeEvent))O.current=!1;else{let Z=!1;document.createElement("div").focus({get preventScroll(){return Z=!0,!1}}),Z?O.current=!1:O.current=!0}}S.on("openchange",ie);const he=$.createElement("span");he.setAttribute("tabindex","-1"),he.setAttribute("aria-hidden","true"),Object.assign(he.style,Ei),We&&b&&b.insertAdjacentElement("afterend",he);function de(){const se=j.current;let Z=typeof se=="function"?se(ee.current):se;if(Z===void 0||Z===!1)return null;if(Z===null&&(Z=!0),typeof Z=="boolean"){const ke=b||Mo();return ke&&ke.isConnected?ke:he}const De=b||Mo()||he;return Rt(Z)||De}return()=>{S.off("openchange",ie);const se=wn($),Z=ve(w,se)||F&&nn(F.nodesRef.current,k(),!1).some(ke=>ve(ke.context?.elements.floating,se)),De=de();queueMicrotask(()=>{const ke=Fm(De),Ie=typeof j.current!="boolean";j.current&&!O.current&&Ke(ke)&&(!(!Ie&&ke!==se&&se!==$.body)||Z)&&ke.focus({preventScroll:!0}),he.remove()})}},[r,w,D,j,C,S,F,We,b,k]),f.useEffect(()=>{queueMicrotask(()=>{O.current=!1})},[r]),f.useEffect(()=>{if(r||!v)return;function $(ie){Ze(ie)?.closest(`[${pi}]`)&&(P.current=!0)}const J=Ye(D);return J.addEventListener("pointerdown",$,!0),()=>{J.removeEventListener("pointerdown",$,!0)}},[r,v,D]),Ee(()=>{if(!r&&_)return _.setFocusManagerState({modal:l,closeOnFocusOut:c,open:v,onOpenChange:x.setOpen,domReference:b}),()=>{_.setFocusManagerState(null)}},[r,_,l,v,x,c,b]),Ee(()=>{if(!(r||!D))return ya(D,M),()=>{queueMicrotask(us)}},[r,D,M]);const ye=!r&&(l?!I:!0)&&(We||l);return m.jsxs(f.Fragment,{children:[ye&&m.jsx(_n,{"data-type":"inside",ref:X,onFocus:$=>{if(l){const J=q();Co(J[J.length-1])}else _?.portalNode&&(O.current=!1,Sn($,_.portalNode)?cs(b)?.focus():Rt(g??_.beforeOutsideRef)?.focus())}}),n,ye&&m.jsx(_n,{"data-type":"inside",ref:oe,onFocus:$=>{l?Co(q()[0]):_?.portalNode&&(c&&(O.current=!0),Sn($,_.portalNode)?qi(b)?.focus():Rt(h??_.afterOutsideRef)?.focus())}})]})}function Wm(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=f.useRef(void 0),d=ss(),h=on(),g=f.useMemo(()=>({onPointerDown(p){u.current=p.pointerType},onMouseDown(p){const y=u.current,x=p.nativeEvent,v=n.select("open");if(p.button!==0||s==="click"||Nn(y,!0)&&i)return;const b=r.current.openEvent,w=b?.type,S=n.select("domReferenceElement")!==p.currentTarget,C=v&&S||!(v&&a&&(!(b&&l)||w==="click"||w==="mousedown"));if(Ai(x.target)){const T=Pe(Ht,x,x.target);C&&y==="touch"&&c>0?h.start(c,()=>{n.setOpen(!0,T)}):n.setOpen(C,T);return}const k=p.currentTarget;d.request(()=>{const T=Pe(Ht,x,k);C&&y==="touch"&&c>0?h.start(c,()=>{n.setOpen(!0,T)}):n.setOpen(C,T)})},onClick(p){if(s==="mousedown-only")return;const y=u.current;if(s==="mousedown"&&y){u.current=void 0;return}if(Nn(y,!0)&&i)return;const x=n.select("open"),v=r.current.openEvent,b=n.select("domReferenceElement")!==p.currentTarget,w=x&&b||!(x&&a&&(!(v&&l)||Ii(v))),S=Pe(Ht,p.nativeEvent,p.currentTarget);w&&y==="touch"&&c>0?h.start(c,()=>{n.setOpen(!0,S)}):n.setOpen(w,S)},onKeyDown(){u.current=void 0}}),[r,s,i,n,l,a,d,h,c]);return f.useMemo(()=>o?{reference:g}:Yt,[o,g])}function ba(e,t,n){let{reference:r,floating:o}=e;const s=at(t),a=ls(t),i=is(a),l=Xe(t),c=s==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,h=r[i]/2-o[i]/2;let g;switch(l){case"top":g={x:u,y:r.y-o.height};break;case"bottom":g={x:u,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:d};break;case"left":g={x:r.x-o.width,y:d};break;default:g={x:r.x,y:r.y}}switch(Gt(t)){case"start":g[a]-=h*(n&&c?-1:1);break;case"end":g[a]+=h*(n&&c?-1:1);break}return g}async function $m(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:d="floating",altBoundary:h=!1,padding:g=0}=Pt(t,e),p=Fi(g),x=i[h?d==="floating"?"reference":"floating":d],v=Ir(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(i.floating)),boundary:c,rootBoundary:u,strategy:l})),b=d==="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)),S=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=Ir(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:b,offsetParent:w,strategy:l}):b);return{top:(v.top-C.top+p.top)/S.y,bottom:(C.bottom-v.bottom+p.bottom)/S.y,left:(v.left-C.left+p.left)/S.x,right:(C.right-v.right+p.right)/S.x}}const Bm=50,Ym=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:a}=n,i=a.detectOverflow?a:{...a,detectOverflow:$m},l=await(a.isRTL==null?void 0:a.isRTL(t));let c=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=ba(c,r,l),h=r,g=0;const p={};for(let y=0;y<s.length;y++){const x=s[y];if(!x)continue;const{name:v,fn:b}=x,{x:w,y:S,data:C,reset:k}=await b({x:u,y:d,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});u=w??u,d=S??d,p[v]={...p[v],...C},k&&g<Bm&&(g++,typeof k=="object"&&(k.placement&&(h=k.placement),k.rects&&(c=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):k.rects),{x:u,y:d}=ba(c,h,l)),y=-1)}return{x:u,y:d,placement:h,strategy:o,middlewareData:p}},Hm=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:d=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:y=!0,...x}=Pt(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=Xe(o),b=at(i),w=Xe(i)===i,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=h||(w||!y?[Ar(i)]:Qf(i)),k=p!=="none";!h&&k&&C.push(...nm(i,y,p,S));const T=[i,...C],N=await l.detectOverflow(t,x),I=[];let M=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&I.push(N[v]),d){const F=Jf(o,a,S);I.push(N[F[0]],N[F[1]])}if(M=[...M,{placement:o,overflows:I}],!I.every(F=>F<=0)){var R,j;const F=(((R=s.flip)==null?void 0:R.index)||0)+1,_=T[F];if(_&&(!(d==="alignment"?b!==at(_):!1)||M.every(O=>at(O.placement)===b?O.overflows[0]>0:!0)))return{data:{index:F,overflows:M},reset:{placement:_}};let B=(j=M.filter(V=>V.overflows[0]<=0).sort((V,O)=>V.overflows[1]-O.overflows[1])[0])==null?void 0:j.placement;if(!B)switch(g){case"bestFit":{var E;const V=(E=M.filter(O=>{if(k){const P=at(O.placement);return P===b||P==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(P=>P>0).reduce((P,U)=>P+U,0)]).sort((O,P)=>O[1]-P[1])[0])==null?void 0:E[0];V&&(B=V);break}case"initialPlacement":B=i;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function xa(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function wa(e){return Kf.some(t=>e[t]>=0)}const Um=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=xa(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:wa(i)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),i=xa(a,n.floating);return{data:{escapedOffsets:i,escaped:wa(i)}}}default:return{}}}}},sl=new Set(["left","top"]);async function Vm(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Xe(n),i=Gt(n),l=at(n)==="y",c=sl.has(a)?-1:1,u=s&&l?-1:1,d=Pt(t,e);let{mainAxis:h,crossAxis:g,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return i&&typeof p=="number"&&(g=i==="end"?p*-1:p),l?{x:g*u,y:h*c}:{x:h*c,y:g*u}}const qm=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 Vm(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}}}}},Gm=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:b,y:w}=v;return{x:b,y:w}}},...c}=Pt(e,t),u={x:n,y:r},d=await s.detectOverflow(t,c),h=at(Xe(o)),g=as(h);let p=u[g],y=u[h];if(a){const v=g==="y"?"top":"left",b=g==="y"?"bottom":"right",w=p+d[v],S=p-d[b];p=Ho(w,p,S)}if(i){const v=h==="y"?"top":"left",b=h==="y"?"bottom":"right",w=y+d[v],S=y-d[b];y=Ho(w,y,S)}const x=l.fn({...t,[g]:p,[h]:y});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[g]:a,[h]:i}}}}}},zm=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},d=at(o),h=as(d);let g=u[h],p=u[d];const y=Pt(i,t),x=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(l){const w=h==="y"?"height":"width",S=s.reference[h]-s.floating[w]+x.mainAxis,C=s.reference[h]+s.reference[w]-x.mainAxis;g<S?g=S:g>C&&(g=C)}if(c){var v,b;const w=h==="y"?"width":"height",S=sl.has(Xe(o)),C=s.reference[d]-s.floating[w]+(S&&((v=a.offset)==null?void 0:v[d])||0)+(S?0:x.crossAxis),k=s.reference[d]+s.reference[w]+(S?0:((b=a.offset)==null?void 0:b[d])||0)-(S?x.crossAxis:0);p<C?p=C:p>k&&(p=k)}return{[h]:g,[d]:p}}}},Km=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),d=Xe(o),h=Gt(o),g=at(o)==="y",{width:p,height:y}=s.floating;let x,v;d==="top"||d==="bottom"?(x=d,v=h===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(v=d,x=h==="end"?"top":"bottom");const b=y-u.top-u.bottom,w=p-u.left-u.right,S=Rn(y-u[x],b),C=Rn(p-u[v],w),k=!t.middlewareData.shift;let T=S,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(T=b),k&&!h){const M=et(u.left,0),R=et(u.right,0),j=et(u.top,0),E=et(u.bottom,0);g?N=p-2*(M!==0||R!==0?M+R:et(u.left,u.right)):T=y-2*(j!==0||E!==0?j+E:et(u.top,u.bottom))}await l({...t,availableWidth:N,availableHeight:T});const I=await a.getDimensions(i.floating);return p!==I.width||y!==I.height?{reset:{rects:!0}}:{}}}};function al(e){const t=ht(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ke(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,i=jr(n)!==s||jr(r)!==a;return i&&(n=s,r=a),{width:n,height:r,$:i}}function ds(e){return Re(e)?e:e.contextElement}function En(e){const t=ds(e);if(!Ke(t))return kt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=al(t);let a=(s?jr(n.width):n.width)/r,i=(s?jr(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const Xm=kt(0);function il(e){const t=it(e);return!Qo()||!t.visualViewport?Xm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Jm(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==it(e)?!1:t}function sn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ds(e);let a=kt(1);t&&(r?Re(r)&&(a=En(r)):a=En(e));const i=Jm(s,n,r)?il(s):kt(0);let l=(o.left+i.x)/a.x,c=(o.top+i.y)/a.y,u=o.width/a.x,d=o.height/a.y;if(s){const h=it(s),g=r&&Re(r)?it(r):r;let p=h,y=qs(p);for(;y&&r&&g!==p;){const x=En(y),v=y.getBoundingClientRect(),b=ht(y),w=v.left+(y.clientLeft+parseFloat(b.paddingLeft))*x.x,S=v.top+(y.clientTop+parseFloat(b.paddingTop))*x.y;l*=x.x,c*=x.y,u*=x.x,d*=x.y,l+=w,c+=S,p=it(y),y=qs(p)}}return Ir({width:u,height:d,x:l,y:c})}function Vr(e,t){const n=Hr(e).scrollLeft;return t?t.left+n:sn(At(e)).left+n}function ll(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Vr(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Qm(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=At(r),i=t?Zo(t.floating):!1;if(r===a||i&&s)return n;let l={scrollLeft:0,scrollTop:0},c=kt(1);const u=kt(0),d=Ke(r);if((d||!d&&!s)&&((or(r)!=="body"||sr(a))&&(l=Hr(r)),d)){const g=sn(r);c=En(r),u.x=g.x+r.clientLeft,u.y=g.y+r.clientTop}const h=a&&!d&&!s?ll(a,l):kt(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function Zm(e){return Array.from(e.getClientRects())}function eh(e){const t=At(e),n=Hr(e),r=e.ownerDocument.body,o=et(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=et(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Vr(e);const i=-n.scrollTop;return ht(r).direction==="rtl"&&(a+=et(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:i}}const va=25;function th(e,t){const n=it(e),r=At(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=Qo();(!u||u&&t==="fixed")&&(i=o.offsetLeft,l=o.offsetTop)}const c=Vr(r);if(c<=0){const u=r.ownerDocument,d=u.body,h=getComputedStyle(d),g=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-g);p<=va&&(s-=p)}else c<=va&&(s+=c);return{width:s,height:a,x:i,y:l}}function nh(e,t){const n=sn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Ke(e)?En(e):kt(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 ka(e,t,n){let r;if(t==="viewport")r=th(e,n);else if(t==="document")r=eh(At(e));else if(Re(t))r=nh(t,n);else{const o=il(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ir(r)}function cl(e,t){const n=On(e);return n===t||!Re(n)||tn(n)?!1:ht(n).position==="fixed"||cl(n,t)}function rh(e,t){const n=t.get(e);if(n)return n;let r=kn(e,[],!1).filter(i=>Re(i)&&or(i)!=="body"),o=null;const s=ht(e).position==="fixed";let a=s?On(e):e;for(;Re(a)&&!tn(a);){const i=ht(a),l=fi(a);!l&&i.position==="fixed"&&(o=null),(s?!l&&!o:!l&&i.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||sr(a)&&!l&&cl(e,a))?r=r.filter(u=>u!==a):o=i,a=On(a)}return t.set(e,r),r}function oh(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?Zo(t)?[]:rh(t,this._c):[].concat(n),r],i=ka(t,a[0],o);let l=i.top,c=i.right,u=i.bottom,d=i.left;for(let h=1;h<a.length;h++){const g=ka(t,a[h],o);l=et(g.top,l),c=Rn(g.right,c),u=Rn(g.bottom,u),d=et(g.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function sh(e){const{width:t,height:n}=al(e);return{width:t,height:n}}function ah(e,t,n){const r=Ke(t),o=At(t),s=n==="fixed",a=sn(e,!0,s,t);let i={scrollLeft:0,scrollTop:0};const l=kt(0);function c(){l.x=Vr(o)}if(r||!r&&!s)if((or(t)!=="body"||sr(o))&&(i=Hr(t)),r){const g=sn(t,!0,s,t);l.x=g.x+t.clientLeft,l.y=g.y+t.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?ll(o,i):kt(0),d=a.left+i.scrollLeft-l.x-u.x,h=a.top+i.scrollTop-l.y-u.y;return{x:d,y:h,width:a.width,height:a.height}}function To(e){return ht(e).position==="static"}function Sa(e,t){if(!Ke(e)||ht(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return At(e)===n&&(n=n.ownerDocument.body),n}function ul(e,t){const n=it(e);if(Zo(e))return n;if(!Ke(e)){let o=On(e);for(;o&&!tn(o);){if(Re(o)&&!To(o))return o;o=On(o)}return n}let r=Sa(e,t);for(;r&&Uu(r)&&To(r);)r=Sa(r,t);return r&&tn(r)&&To(r)&&!fi(r)?n:r||Vu(e)||n}const ih=async function(e){const t=this.getOffsetParent||ul,n=this.getDimensions,r=await n(e.floating);return{reference:ah(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function lh(e){return ht(e).direction==="rtl"}const ch={convertOffsetParentRelativeRectToViewportRelativeRect:Qm,getDocumentElement:At,getClippingRect:oh,getOffsetParent:ul,getElementRects:ih,getClientRects:Zm,getDimensions:sh,getScale:En,isElement:Re,isRTL:lh};function dl(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function uh(e,t){let n=null,r;const o=At(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:d,width:h,height:g}=c;if(i||t(),!h||!g)return;const p=Sr(d),y=Sr(o.clientWidth-(u+h)),x=Sr(o.clientHeight-(d+g)),v=Sr(u),w={rootMargin:-p+"px "+-y+"px "+-x+"px "+-v+"px",threshold:et(0,Rn(1,l))||1};let S=!0;function C(k){const T=k[0].intersectionRatio;if(T!==l){if(!S)return a();T?a(!1,T):r=setTimeout(()=>{a(!1,1e-7)},1e3)}T===1&&!dl(c,e.getBoundingClientRect())&&a(),S=!1}try{n=new IntersectionObserver(C,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,w)}n.observe(e)}return a(!0),s}function Ca(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=ds(e),u=o||s?[...c?kn(c):[],...t?kn(t):[]]:[];u.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const d=c&&i?uh(c,n):null;let h=-1,g=null;a&&(g=new ResizeObserver(v=>{let[b]=v;b&&b.target===c&&g&&t&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=g)==null||w.observe(t)})),n()}),c&&!l&&g.observe(c),t&&g.observe(t));let p,y=l?sn(e):null;l&&x();function x(){const v=sn(e);y&&!dl(y,v)&&n(),y=v,p=requestAnimationFrame(x)}return n(),()=>{var v;u.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),d?.(),(v=g)==null||v.disconnect(),g=null,l&&cancelAnimationFrame(p)}}const dh=qm,fh=Gm,mh=Hm,hh=Km,gh=Um,ph=zm,yh=(e,t,n)=>{const r=new Map,o={platform:ch,...n},s={...o.platform,_c:r};return Ym(e,t,{...o,platform:s})};var bh=typeof document<"u",xh=function(){},Nr=bh?f.useLayoutEffect:xh;function Br(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(!Br(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)&&!Br(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function fl(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ea(e,t){const n=fl(e);return Math.round(t*n)/n}function Oo(e){const t=f.useRef(e);return Nr(()=>{t.current=e}),t}function wh(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,d]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,g]=f.useState(r);Br(h,r)||g(r);const[p,y]=f.useState(null),[x,v]=f.useState(null),b=f.useCallback(O=>{O!==k.current&&(k.current=O,y(O))},[]),w=f.useCallback(O=>{O!==T.current&&(T.current=O,v(O))},[]),S=s||p,C=a||x,k=f.useRef(null),T=f.useRef(null),N=f.useRef(u),I=l!=null,M=Oo(l),R=Oo(o),j=Oo(c),E=f.useCallback(()=>{if(!k.current||!T.current)return;const O={placement:t,strategy:n,middleware:h};R.current&&(O.platform=R.current),yh(k.current,T.current,O).then(P=>{const U={...P,isPositioned:j.current!==!1};F.current&&!Br(N.current,U)&&(N.current=U,Ut.flushSync(()=>{d(U)}))})},[h,t,n,R,j]);Nr(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,d(O=>({...O,isPositioned:!1})))},[c]);const F=f.useRef(!1);Nr(()=>(F.current=!0,()=>{F.current=!1}),[]),Nr(()=>{if(S&&(k.current=S),C&&(T.current=C),S&&C){if(M.current)return M.current(S,C,E);E()}},[S,C,E,M,I]);const _=f.useMemo(()=>({reference:k,floating:T,setReference:b,setFloating:w}),[b,w]),B=f.useMemo(()=>({reference:S,floating:C}),[S,C]),V=f.useMemo(()=>{const O={position:n,left:0,top:0};if(!B.floating)return O;const P=Ea(B.floating,u.x),U=Ea(B.floating,u.y);return i?{...O,transform:"translate("+P+"px, "+U+"px)",...fl(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:P,top:U}},[n,i,B.floating,u.x,u.y]);return f.useMemo(()=>({...u,update:E,refs:_,elements:B,floatingStyles:V}),[u,E,_,B,V])}const vh=(e,t)=>{const n=dh(e);return{name:n.name,fn:n.fn,options:[e,t]}},kh=(e,t)=>{const n=fh(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sh=(e,t)=>({fn:ph(e).fn,options:[e,t]}),Ch=(e,t)=>{const n=mh(e);return{name:n.name,fn:n.fn,options:[e,t]}},Eh=(e,t)=>{const n=hh(e);return{name:n.name,fn:n.fn,options:[e,t]}},Mh=(e,t)=>{const n=gh(e);return{name:n.name,fn:n.fn,options:[e,t]}},Th={intentional:"onClick",sloppy:"onPointerDown"};function Oh(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function ml(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:d=!0,outsidePressEvent:h="sloppy",referencePress:g=!1,referencePressEvent:p="sloppy",ancestorScroll:y=!1,bubbles:x,externalTree:v}=t,b=Wn(v),w=me(typeof d=="function"?d:()=>!1),S=typeof d=="function"?w:d,C=f.useRef(!1),{escapeKey:k,outsidePress:T}=Oh(x),N=f.useRef(null),I=on(),M=on(),R=me(()=>{M.clear(),l.current.insideReactTree=!1}),j=f.useRef(!1),E=f.useRef(""),F=me(D=>{E.current=D.pointerType}),_=me(()=>{const D=E.current,ae=D==="pen"||!D?"mouse":D,q=typeof h=="function"?h():h;return typeof q=="string"?q:q[ae]}),B=me(D=>{if(!r||!c||!u||D.key!=="Escape"||j.current)return;const ae=l.current.floatingContext?.nodeId,q=b?nn(b.nodesRef.current,ae):[];if(!k&&q.length>0){let J=!0;if(q.forEach(ie=>{ie.context?.open&&!ie.context.dataRef.current.__escapeKeyBubbles&&(J=!1)}),!J)return}const ye=qf(D)?D.nativeEvent:D,$=Pe(Qi,ye);n.setOpen(!1,$),!k&&!$.isPropagationAllowed&&D.stopPropagation()}),V=me(D=>{const ae=_();return ae==="intentional"&&D.type!=="click"||ae==="sloppy"&&D.type==="click"}),O=me(()=>{l.current.insideReactTree=!0,M.start(0,R)}),P=me((D,ae=!1)=>{if(V(D)){R();return}if(l.current.insideReactTree){R();return}if(_()==="intentional"&&ae||typeof S=="function"&&!S(D))return;const q=Ze(D),ye=`[${Zn("inert")}]`,$=Ye(n.select("floatingElement")).querySelectorAll(ye),J=n.context.triggerElements;if(q&&(J.hasElement(q)||J.hasMatchingElement(Z=>ve(Z,q))))return;let ie=Re(q)?q:null;for(;ie&&!tn(ie);){const Z=On(ie);if(tn(Z)||!Re(Z))break;ie=Z}if($.length&&Re(q)&&!Uf(q)&&!ve(q,n.select("floatingElement"))&&Array.from($).every(Z=>!ve(ie,Z)))return;if(Ke(q)&&!("touches"in D)){const Z=tn(q),De=ht(q),ke=/auto|scroll/,Ie=Z||ke.test(De.overflowX),pe=Z||ke.test(De.overflowY),Je=Ie&&q.clientWidth>0&&q.scrollWidth>q.clientWidth,Fe=pe&&q.clientHeight>0&&q.scrollHeight>q.clientHeight,Se=De.direction==="rtl",Ue=Fe&&(Se?D.offsetX<=q.offsetWidth-q.clientWidth:D.offsetX>q.clientWidth),He=Je&&D.offsetY>q.clientHeight;if(Ue||He)return}const he=l.current.floatingContext?.nodeId,de=b&&nn(b.nodesRef.current,he).some(Z=>ut(D,Z.context?.elements.floating));if(ut(D,n.select("floatingElement"))||ut(D,n.select("domReferenceElement"))||de)return;const se=b?nn(b.nodesRef.current,he):[];if(se.length>0){let Z=!0;if(se.forEach(De=>{De.context?.open&&!De.context.dataRef.current.__outsidePressBubbles&&(Z=!1)}),!Z)return}n.setOpen(!1,Pe(Ji,D)),R()}),U=me(D=>{_()!=="sloppy"||D.pointerType==="touch"||!n.select("open")||!c||ut(D,n.select("floatingElement"))||ut(D,n.select("domReferenceElement"))||P(D)}),Y=me(D=>{if(_()!=="sloppy"||!n.select("open")||!c||ut(D,n.select("floatingElement"))||ut(D,n.select("domReferenceElement")))return;const ae=D.touches[0];ae&&(N.current={startTime:Date.now(),startX:ae.clientX,startY:ae.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},I.start(1e3,()=>{N.current&&(N.current.dismissOnTouchEnd=!1,N.current.dismissOnMouseDown=!1)}))}),ee=me(D=>{const ae=Ze(D);function q(){Y(D),ae?.removeEventListener(D.type,q)}ae?.addEventListener(D.type,q)}),H=me(D=>{const ae=C.current;if(C.current=!1,I.clear(),D.type==="mousedown"&&N.current&&!N.current.dismissOnMouseDown)return;const q=Ze(D);function ye(){D.type==="pointerdown"?U(D):P(D,ae),q?.removeEventListener(D.type,ye)}q?.addEventListener(D.type,ye)}),L=me(D=>{if(_()!=="sloppy"||!N.current||ut(D,n.select("floatingElement"))||ut(D,n.select("domReferenceElement")))return;const ae=D.touches[0];if(!ae)return;const q=Math.abs(ae.clientX-N.current.startX),ye=Math.abs(ae.clientY-N.current.startY),$=Math.sqrt(q*q+ye*ye);$>5&&(N.current.dismissOnTouchEnd=!0),$>10&&(P(D),I.clear(),N.current=null)}),z=me(D=>{const ae=Ze(D);function q(){L(D),ae?.removeEventListener(D.type,q)}ae?.addEventListener(D.type,q)}),X=me(D=>{_()!=="sloppy"||!N.current||ut(D,n.select("floatingElement"))||ut(D,n.select("domReferenceElement"))||(N.current.dismissOnTouchEnd&&P(D),I.clear(),N.current=null)}),oe=me(D=>{const ae=Ze(D);function q(){X(D),ae?.removeEventListener(D.type,q)}ae?.addEventListener(D.type,q)});f.useEffect(()=>{if(!r||!c)return;l.current.__escapeKeyBubbles=k,l.current.__outsidePressBubbles=T;const D=new Vt;function ae(ie){n.setOpen(!1,Pe(Om,ie))}function q(){D.clear(),j.current=!0}function ye(){D.start(Qo()?5:0,()=>{j.current=!1})}const $=Ye(o);$.addEventListener("pointerdown",F,!0),u&&($.addEventListener("keydown",B),$.addEventListener("compositionstart",q),$.addEventListener("compositionend",ye)),S&&($.addEventListener("click",H,!0),$.addEventListener("pointerdown",H,!0),$.addEventListener("touchstart",ee,!0),$.addEventListener("touchmove",z,!0),$.addEventListener("touchend",oe,!0),$.addEventListener("mousedown",H,!0));let J=[];return y&&(Re(a)&&(J=kn(a)),Re(o)&&(J=J.concat(kn(o))),!Re(s)&&s&&s.contextElement&&(J=J.concat(kn(s.contextElement)))),J=J.filter(ie=>ie!==$.defaultView?.visualViewport),J.forEach(ie=>{ie.addEventListener("scroll",ae,{passive:!0})}),()=>{$.removeEventListener("pointerdown",F,!0),u&&($.removeEventListener("keydown",B),$.removeEventListener("compositionstart",q),$.removeEventListener("compositionend",ye)),S&&($.removeEventListener("click",H,!0),$.removeEventListener("pointerdown",H,!0),$.removeEventListener("touchstart",ee,!0),$.removeEventListener("touchmove",z,!0),$.removeEventListener("touchend",oe,!0),$.removeEventListener("mousedown",H,!0)),J.forEach(ie=>{ie.removeEventListener("scroll",ae)}),D.clear(),C.current=!1}},[l,o,s,a,u,S,r,i,y,c,k,T,B,P,H,U,ee,z,oe,F,n]),f.useEffect(R,[S,R]);const be=f.useMemo(()=>({onKeyDown:B,...g&&{[Th[p]]:D=>{n.setOpen(!1,Pe(Ht,D.nativeEvent))},...p!=="intentional"&&{onClick(D){n.setOpen(!1,Pe(Ht,D.nativeEvent))}}}}),[B,n,g,p]),Oe=me(D=>{const ae=Ze(D.nativeEvent);!ve(n.select("floatingElement"),ae)||D.button!==0||(C.current=!0)}),xe=me(D=>{!r||!c||D.button!==0||(C.current=!0)}),We=f.useMemo(()=>({onKeyDown:B,onPointerDown:Oe,onMouseDown:Oe,onMouseUp:Oe,onClickCapture:O,onMouseDownCapture(D){O(),xe(D)},onPointerDownCapture(D){O(),xe(D)},onMouseUpCapture:O,onTouchEndCapture:O,onTouchMoveCapture:O}),[B,Oe,O,xe]);return f.useMemo(()=>c?{reference:be,floating:We,trigger:be}:{},[c,be,We])}const Nh={open:ge(e=>e.open),domReferenceElement:ge(e=>e.domReferenceElement),referenceElement:ge(e=>e.positionReference??e.referenceElement),floatingElement:ge(e=>e.floatingElement),floatingId:ge(e=>e.floatingId)};class fs extends rs{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:zi(),nested:n,noEmit:r,triggerElements:s},Nh)}setOpen=(t,n)=>{if((!t||!this.state.open||Ii(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 Rh(e,t=!1,n=!1){const[r,o]=f.useState(e&&t?"idle":void 0),[s,a]=f.useState(e);return e&&!s&&(a(!0),o("starting")),!e&&s&&r!=="ending"&&!n&&o("ending"),!e&&!s&&r==="ending"&&o(void 0),Ee(()=>{if(!e&&s&&r!=="ending"&&n){const i=yt.request(()=>{o("ending")});return()=>{yt.cancel(i)}}},[e,s,r,n]),Ee(()=>{if(!e||t)return;const i=yt.request(()=>{o(void 0)});return()=>{yt.cancel(i)}},[t,e]),Ee(()=>{if(!e||!t)return;e&&s&&r!=="idle"&&o("starting");const i=yt.request(()=>{o("idle")});return()=>{yt.cancel(i)}},[t,e,s,o,r]),f.useMemo(()=>({mounted:s,setMounted:a,transitionStatus:r}),[s,r])}let er=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const Dh={[er.startingStyle]:""},_h={[er.endingStyle]:""},qr={transitionStatus(e){return e==="starting"?Dh:e==="ending"?_h:null}};function hl(e,t=!1,n=!0){const r=ss();return me((o,s=null)=>{r.cancel();function a(){Ut.flushSync(o)}const i=Rt(e);if(i==null)return;const l=i;if(typeof l.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)o();else{let c=function(){const d=er.startingStyle;if(!l.hasAttribute(d)){r.request(u);return}const h=new MutationObserver(()=>{l.hasAttribute(d)||(h.disconnect(),u())});h.observe(l,{attributes:!0,attributeFilter:[d]}),s?.addEventListener("abort",()=>h.disconnect(),{once:!0})},u=function(){Promise.all(l.getAnimations().map(d=>d.finished)).then(()=>{s?.aborted||a()}).catch(()=>{const d=l.getAnimations();if(n){if(s?.aborted)return;a()}else d.length>0&&d.some(h=>h.pending||h.playState!=="finished")&&u()})};if(t){c();return}r.request(u)}})}function ms(e){const{enabled:t=!0,open:n,ref:r,onComplete:o}=e,s=me(o),a=hl(r,n,!1);f.useEffect(()=>{if(!t)return;const i=new AbortController;return a(s,i.signal),()=>{i.abort()}},[t,n,s,a])}function Ph(e,t){const n=f.useRef(null),r=f.useRef(null);return f.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 jh(e,t,n,r){const o=n.useState("isMountedByTrigger",e),s=Ph(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 Ee(()=>{o&&n.update({activeTriggerElement:t.current,...r})},[o,n,t,...Object.values(r)]),{registerTrigger:a,isMountedByThisTrigger:o}}function gl(e){const t=e.useState("open");Ee(()=>{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 pl(e,t,n){const{mounted:r,setMounted:o,transitionStatus:s}=Rh(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 ms({enabled:!i,open:e,ref:t.context.popupRef,onComplete(){e||a()}}),{forceUnmount:a,transitionStatus:s}}class Gr{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 Ah(){return new fs({open:!1,floatingElement:null,referenceElement:null,triggerElements:new Gr,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function yl(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:Ah(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:Yt,inactiveTriggerProps:Yt,popupProps:Yt}}const bl={open:ge(e=>e.open),mounted:ge(e=>e.mounted),transitionStatus:ge(e=>e.transitionStatus),floatingRootContext:ge(e=>e.floatingRootContext),preventUnmountingOnClose:ge(e=>e.preventUnmountingOnClose),payload:ge(e=>e.payload),activeTriggerId:ge(e=>e.activeTriggerId),activeTriggerElement:ge(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:ge((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:ge((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:ge((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:ge((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:ge(e=>e.popupProps),popupElement:ge(e=>e.popupElement),positionerElement:ge(e=>e.positionerElement)};function Ih(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,o=Ln(),s=ln()!=null,a=qt(()=>new fs({open:t,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:r.triggers??new Gr,floatingId:o,nested:s,noEmit:e.noEmit||!1})).current;return Ee(()=>{const i={open:t,floatingId:o};r.reference!==void 0&&(i.referenceElement=r.reference,i.domReferenceElement=Re(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 Fh(e={}){const{nodeId:t,externalTree:n}=e,r=Ih(e),o=e.rootContext||r,s={reference:o.useState("referenceElement"),floating:o.useState("floatingElement"),domReference:o.useState("domReferenceElement")},[a,i]=f.useState(null),l=f.useRef(null),c=Wn(n);Ee(()=>{s.domReference&&(l.current=s.domReference)},[s.domReference]);const u=wh({...e,elements:{...s,...a&&{reference:a}}}),d=f.useCallback(T=>{const N=Re(T)?{getBoundingClientRect:()=>T.getBoundingClientRect(),getClientRects:()=>T.getClientRects(),contextElement:T}:T;i(N),u.refs.setReference(N)},[u.refs]),[h,g]=f.useState(null),[p,y]=f.useState(null);o.useSyncedValue("referenceElement",h),o.useSyncedValue("domReferenceElement",Re(h)?h:null),o.useSyncedValue("floatingElement",p);const x=f.useCallback(T=>{(Re(T)||T===null)&&(l.current=T,g(T)),(Re(u.refs.reference.current)||u.refs.reference.current===null||T!==null&&!Re(T))&&u.refs.setReference(T)},[u.refs,g]),v=f.useCallback(T=>{y(T),u.refs.setFloating(T)},[u.refs]),b=f.useMemo(()=>({...u.refs,setReference:x,setFloating:v,setPositionReference:d,domReference:l}),[u.refs,x,v,d]),w=f.useMemo(()=>({...u.elements,domReference:s.domReference}),[u.elements,s.domReference]),S=o.useState("open"),C=o.useState("floatingId"),k=f.useMemo(()=>({...u,dataRef:o.context.dataRef,open:S,onOpenChange:o.setOpen,events:o.context.events,floatingId:C,refs:b,elements:w,nodeId:t,rootStore:o}),[u,b,w,t,o,S,C]);return Ee(()=>{o.context.dataRef.current.floatingContext=k;const T=c?.nodesRef.current.find(N=>N.id===t);T&&(T.context=k)}),f.useMemo(()=>({...u,context:k,refs:b,elements:w,rootStore:o}),[u,b,w,k,o])}function xl(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:r=!1,onOpenChange:o}=e,s=Ln(),a=ln()!=null,i=t.useState("open"),l=t.useState("activeTriggerElement"),c=t.useState(r?"popupElement":"positionerElement"),u=t.context.triggerElements,d=qt(()=>new fs({open:i,referenceElement:l,floatingElement:c,triggerElements:u,onOpenChange:o,floatingId:s,nested:a,noEmit:n})).current;return Ee(()=>{const h={open:i,floatingId:s,referenceElement:l,floatingElement:c};Re(l)&&(h.domReferenceElement=l),d.state.positionReference===d.state.referenceElement&&(h.positionReference=l),d.update(h)},[i,s,l,c,d]),d.context.onOpenChange=o,d.context.nested=a,d.context.noEmit=n,d}const Go=Zn("safe-polygon"),Lh=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${ji}`;function Wh(e){return e?!!e.closest(Lh):!1}function wl(e){const t=f.useRef(void 0),n=f.useRef(!1),r=f.useRef(void 0),o=f.useRef(!0),s=f.useRef(!1),a=f.useRef(()=>{}),i=f.useRef(!1),l=on(),c=on(),u=f.useRef(void 0);return f.useMemo(()=>{const d=e.context.dataRef.current;return d.hoverInteractionState||(d.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:r,blockMouseMoveRef:o,performedPointerEventsMutationRef:s,unbindMouseMoveRef:a,restTimeoutPendingRef:i,openChangeTimeout:l,restTimeout:c,handleCloseOptionsRef:u}),d.hoverInteractionState},[e,t,n,r,o,s,a,i,l,c,u])}const $h=new Set(["click","mousedown"]);function Bh(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:d,handlerRef:h,performedPointerEventsMutationRef:g,unbindMouseMoveRef:p,restTimeoutPendingRef:y,openChangeTimeout:x,handleCloseOptionsRef:v}=wl(n),b=Wn(c),w=ln(),S=me(()=>d.current?!0:a.current.openEvent?$h.has(a.current.openEvent.type):!1),C=me(()=>{const M=a.current.openEvent?.type;return M?.includes("mouse")&&M!=="mousedown"}),k=f.useCallback((M,R=!0)=>{const j=Yh(l,u.current);j&&!h.current?x.start(j,()=>n.setOpen(!1,Pe(tt,M))):R&&(x.clear(),n.setOpen(!1,Pe(tt,M)))},[l,h,n,u,x]),T=me(()=>{p.current(),h.current=void 0}),N=me(()=>{if(g.current){const M=Ye(o).body;M.style.pointerEvents="",M.removeAttribute(Go),g.current=!1}}),I=me(M=>{const R=Ze(M);if(!Wh(R)){d.current=!1;return}d.current=!0});Ee(()=>{r||(u.current=void 0,y.current=!1,d.current=!1,T(),N())},[r,u,y,d,T,N]),f.useEffect(()=>()=>{T()},[T]),f.useEffect(()=>N,[N]),Ee(()=>{if(i&&r&&v.current?.blockPointerEvents&&C()&&Re(s)&&o){g.current=!0;const M=Ye(o).body;M.setAttribute(Go,"");const R=s,j=o,E=b?.nodesRef.current.find(F=>F.id===w)?.context?.elements.floating;return E&&(E.style.pointerEvents=""),M.style.pointerEvents="none",R.style.pointerEvents="auto",j.style.pointerEvents="auto",()=>{M.style.pointerEvents="",R.style.pointerEvents="",j.style.pointerEvents=""}}},[i,r,s,o,v,C,b,w,g]),f.useEffect(()=>{if(!i)return;function M(F){if(S()||!a.current.floatingContext||!n.select("open"))return;const _=n.context.triggerElements;F.relatedTarget&&_.hasElement(F.relatedTarget)||(N(),T(),S()||k(F))}function R(F){x.clear(),N(),h.current?.(F),T()}function j(F){S()||k(F,!1)}const E=o;return E&&(E.addEventListener("mouseleave",M),E.addEventListener("mouseenter",R),E.addEventListener("mouseleave",j),E.addEventListener("pointerdown",I,!0)),()=>{E&&(E.removeEventListener("mouseleave",M),E.removeEventListener("mouseenter",R),E.removeEventListener("mouseleave",j),E.removeEventListener("pointerdown",I,!0))}})}function Yh(e,t){return t&&!Nn(t)?0:typeof e=="function"?e():e}function No(e){return typeof e=="function"?e():e}const Hh={current:null};function Uh(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:d=Hh,externalTree:h,isActiveTrigger:g=!0}=t,p=Wn(h),{pointerTypeRef:y,interactedInsideRef:x,handlerRef:v,blockMouseMoveRef:b,performedPointerEventsMutationRef:w,unbindMouseMoveRef:S,restTimeoutPendingRef:C,openChangeTimeout:k,restTimeout:T,handleCloseOptionsRef:N}=wl(n),I=bt(i),M=bt(a),R=bt(c);g&&(N.current=I.current?.__options);const j=me(()=>x.current?!0:r.current.openEvent?["click","mousedown"].includes(r.current.openEvent.type):!1),E=f.useCallback((V,O=!0)=>{const P=So(M.current,"close",y.current);P&&!v.current?k.start(P,()=>n.setOpen(!1,Pe(tt,V))):O&&(k.clear(),n.setOpen(!1,Pe(tt,V)))},[M,v,n,y,k]),F=me(()=>{S.current(),v.current=void 0}),_=me(()=>{if(w.current){const V=Ye(n.select("domReferenceElement")).body;V.style.pointerEvents="",V.removeAttribute(Go),w.current=!1}});f.useEffect(()=>{if(!s)return;function V(O){O.open||(k.clear(),T.clear(),b.current=!0,C.current=!1)}return o.on("openchange",V),()=>{o.off("openchange",V)}},[s,o,k,T,b,C]);const B=me(V=>{if(j()||!r.current.floatingContext)return;const O=n.context.triggerElements;if(V.relatedTarget&&O.hasElement(V.relatedTarget))return;const P=d.current;I.current?.({...r.current.floatingContext,tree:p,x:V.clientX,y:V.clientY,onClose(){_(),F(),!j()&&P===n.select("domReferenceElement")&&E(V)}})(V)});return f.useEffect(()=>{if(!s)return;const V=d.current??(g?n.select("domReferenceElement"):null);if(!Re(V))return;function O(Y){if(k.clear(),b.current=!1,l&&!Nn(y.current)||No(R.current)>0&&!So(M.current,"open"))return;const ee=So(M.current,"open",y.current),H=n.select("domReferenceElement"),L=n.context.triggerElements,z=(L.hasElement(Y.target)||L.hasMatchingElement(Oe=>ve(Oe,Y.target)))&&(!H||!ve(H,Y.target)),X=Y.currentTarget??null,oe=n.select("open"),be=!oe||z;z&&oe?n.setOpen(!0,Pe(tt,Y,X)):ee?k.start(ee,()=>{be&&n.setOpen(!0,Pe(tt,Y,X))}):be&&n.setOpen(!0,Pe(tt,Y,X))}function P(Y){if(j()){_();return}S.current();const ee=n.select("domReferenceElement"),H=Ye(ee);T.clear(),C.current=!1;const L=n.context.triggerElements;if(Y.relatedTarget&&L.hasElement(Y.relatedTarget))return;if(I.current&&r.current.floatingContext){n.select("open")||k.clear();const X=d.current;v.current=I.current({...r.current.floatingContext,tree:p,x:Y.clientX,y:Y.clientY,onClose(){_(),F(),!j()&&X===n.select("domReferenceElement")&&E(Y,!0)}});const oe=v.current;oe(Y),H.addEventListener("mousemove",oe),S.current=()=>{H.removeEventListener("mousemove",oe)};return}(y.current!=="touch"||!ve(n.select("floatingElement"),Y.relatedTarget))&&E(Y)}function U(Y){B(Y)}return n.select("open")&&V.addEventListener("mouseleave",U),u&&V.addEventListener("mousemove",O,{once:!0}),V.addEventListener("mouseenter",O),V.addEventListener("mouseleave",P),()=>{V.removeEventListener("mouseleave",U),u&&V.removeEventListener("mousemove",O),V.removeEventListener("mouseenter",O),V.removeEventListener("mouseleave",P)}},[F,_,b,r,M,E,n,s,I,B,g,j,l,u,y,R,T,C,k,d,p,S,v]),f.useMemo(()=>{function V(O){y.current=O.pointerType}return{onPointerDown:V,onPointerEnter:V,onMouseMove(O){const{nativeEvent:P}=O,U=O.currentTarget,Y=n.select("domReferenceElement"),ee=n.context.triggerElements,H=n.select("open"),L=(ee.hasElement(O.target)||ee.hasMatchingElement(X=>ve(X,O.target)))&&(!Y||!ve(Y,O.target));if(l&&!Nn(y.current)||H&&!L||No(R.current)===0||!L&&C.current&&O.movementX**2+O.movementY**2<2)return;T.clear();function z(){if(C.current=!1,j())return;const X=n.select("open");!b.current&&(!X||L)&&n.setOpen(!0,Pe(tt,P,U))}y.current==="touch"?Ut.flushSync(()=>{z()}):L&&H?z():(C.current=!0,T.start(No(R.current),z))}}},[b,j,l,n,y,R,T,C])}function hs(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=f.useCallback(c=>Mr(c,e,"reference"),t),a=f.useCallback(c=>Mr(c,e,"floating"),n),i=f.useCallback(c=>Mr(c,e,"item"),r),l=f.useCallback(c=>Mr(c,e,"trigger"),o);return f.useMemo(()=>({getReferenceProps:s,getFloatingProps:a,getItemProps:i,getTriggerProps:l}),[s,a,i,l])}function Mr(e,t,n){const r=new Map,o=n==="item",s={};n==="floating"&&(s.tabIndex=-1,s[Bo]="");for(const a in e)o&&e&&(a===_i||a===Pi)||(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&&Ma(s,i,o,r)}return Ma(s,e,o,r),s}function Ma(e,t,n,r){for(const o in t){const s=t[o];n&&(o===_i||o===Pi)||(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 Vh=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function vl(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=Ln(),u=s?.id||c,d=f.useMemo(()=>Yo(a)?.id||o,[a,o]),h=Vh.get(l)??l,p=ln()!=null,y=f.useMemo(()=>h==="tooltip"||l==="label"?Yt:{"aria-haspopup":h==="alertdialog"?"dialog":h,"aria-expanded":"false",...h==="listbox"&&{role:"combobox"},...h==="menu"&&p&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[h,p,l]),x=f.useMemo(()=>h==="tooltip"||l==="label"?{[`aria-${l==="label"?"labelledby":"describedby"}`]:r?d:void 0}:{...y,"aria-expanded":r?"true":"false","aria-controls":r?d:void 0,...h==="menu"&&{id:u}},[h,d,r,u,l,y]),v=f.useMemo(()=>{const w={id:d,...h&&{role:h}};return h==="tooltip"||l==="label"?w:{...w,...h==="menu"&&{"aria-labelledby":u}}},[h,d,u,l]),b=f.useCallback(({active:w,selected:S})=>{const C={role:"option",...w&&{id:`${d}-fui-option`}};switch(l){case"select":case"combobox":return{...C,"aria-selected":S}}return{}},[d,l]);return f.useMemo(()=>i?{reference:x,floating:v,item:b,trigger:y}:{},[i,x,v,y,b])}function Ta(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,d]=t[i]||[0,0];c>=r!=d>=r&&n<=(u-l)*(r-c)/(d-c)+l&&(o=!o)}return o}function qh(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function Gh(e={}){const{buffer:t=.5,blockPointerEvents:n=!1,requireIntent:r=!0}=e,o=new Vt;let s=!1,a=null,i=null,l=typeof performance<"u"?performance.now():0;function c(d,h){const g=performance.now(),p=g-l;if(a===null||i===null||p===0)return a=d,i=h,l=g,null;const y=d-a,x=h-i,b=Math.sqrt(y*y+x*x)/p;return a=d,i=h,l=g,b}const u=({x:d,y:h,placement:g,elements:p,onClose:y,nodeId:x,tree:v})=>function(w){function S(){o.clear(),y()}if(o.clear(),!p.domReference||!p.floating||g==null||d==null||h==null)return;const{clientX:C,clientY:k}=w,T=[C,k],N=Ze(w),I=w.type==="mouseleave",M=ve(p.floating,N),R=ve(p.domReference,N),j=p.domReference.getBoundingClientRect(),E=p.floating.getBoundingClientRect(),F=g.split("-")[0],_=d>E.right-E.width/2,B=h>E.bottom-E.height/2,V=qh(T,j),O=E.width>j.width,P=E.height>j.height,U=(O?j:E).left,Y=(O?j:E).right,ee=(P?j:E).top,H=(P?j:E).bottom;if(M&&(s=!0,!I))return;if(R&&(s=!1),R&&!I){s=!0;return}if(I&&Re(w.relatedTarget)&&ve(p.floating,w.relatedTarget)||v&&nn(v.nodesRef.current,x).some(({context:X})=>X?.open))return;if(F==="top"&&h>=j.bottom-1||F==="bottom"&&h<=j.top+1||F==="left"&&d>=j.right-1||F==="right"&&d<=j.left+1)return S();let L=[];switch(F){case"top":L=[[U,j.top+1],[U,E.bottom-1],[Y,E.bottom-1],[Y,j.top+1]];break;case"bottom":L=[[U,E.top+1],[U,j.bottom-1],[Y,j.bottom-1],[Y,E.top+1]];break;case"left":L=[[E.right-1,H],[E.right-1,ee],[j.left+1,ee],[j.left+1,H]];break;case"right":L=[[j.right-1,H],[j.right-1,ee],[E.left+1,ee],[E.left+1,H]];break}function z([X,oe]){switch(F){case"top":{const be=[O?X+t/2:_?X+t*4:X-t*4,oe+t+1],Oe=[O?X-t/2:_?X+t*4:X-t*4,oe+t+1],xe=[[E.left,_||O?E.bottom-t:E.top],[E.right,_?O?E.bottom-t:E.top:E.bottom-t]];return[be,Oe,...xe]}case"bottom":{const be=[O?X+t/2:_?X+t*4:X-t*4,oe-t],Oe=[O?X-t/2:_?X+t*4:X-t*4,oe-t],xe=[[E.left,_||O?E.top+t:E.bottom],[E.right,_?O?E.top+t:E.bottom:E.top+t]];return[be,Oe,...xe]}case"left":{const be=[X+t+1,P?oe+t/2:B?oe+t*4:oe-t*4],Oe=[X+t+1,P?oe-t/2:B?oe+t*4:oe-t*4];return[...[[B||P?E.right-t:E.left,E.top],[B?P?E.right-t:E.left:E.right-t,E.bottom]],be,Oe]}case"right":{const be=[X-t,P?oe+t/2:B?oe+t*4:oe-t*4],Oe=[X-t,P?oe-t/2:B?oe+t*4:oe-t*4],xe=[[B||P?E.left+t:E.right,E.top],[B?P?E.left+t:E.right:E.left+t,E.bottom]];return[be,Oe,...xe]}default:return[]}}if(!Ta([C,k],L)){if(s&&!V)return S();if(!I&&r){const X=c(w.clientX,w.clientY);if(X!==null&&X<.1)return S()}Ta([C,k],z([d,h]))?!s&&r&&o.start(40,S):S()}};return u.__options={blockPointerEvents:n},u}function kl(e){return Ln(e,"base-ui")}function zh(e){const t=f.useRef(""),n=f.useCallback(o=>{o.defaultPrevented||(t.current=o.pointerType,e(o,o.pointerType))},[e]);return{onClick:f.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 Sl(e){const[t,n]=f.useState(null),r=me((i,l)=>{e||n(l||(Di?"touch":""))}),o=f.useCallback(()=>{n(null)},[]),{onClick:s,onPointerDown:a}=zh(r);return f.useMemo(()=>({openMethod:t,reset:o,triggerProps:{onClick:s,onPointerDown:a}}),[t,o,s,a])}let ft=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=er.startingStyle]="startingStyle",e[e.endingStyle=er.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),zo=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const Kh={[zo.popupOpen]:""},Xh={[zo.popupOpen]:"",[zo.pressed]:""},Jh={[ft.open]:""},Qh={[ft.closed]:""},Zh={[ft.anchorHidden]:""},eg={open(e){return e?Kh:null}},tg={open(e){return e?Xh:null}},ir={open(e){return e?Jh:Qh},anchorHidden(e){return e?Zh:null}};function Cl(e){return ui(19)?e:e?"true":void 0}let Oa={},Na={},Ra="";function ng(e){if(typeof document>"u")return!1;const t=cn(e);return it(t).innerWidth-t.documentElement.clientWidth>0}function rg(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const r=cn(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 og(e){const t=cn(e),n=t.documentElement,r=t.body,o=sr(n)?n:r,s=o.style.overflow;return o.style.overflow="hidden",()=>{o.style.overflow=s}}function sg(e){const t=cn(e),n=t.documentElement,r=t.body,o=it(n);let s=0,a=0,i=!1;const l=yt.create();if(Lf&&(o.visualViewport?.scale??1)!==1)return()=>{};function c(){const h=o.getComputedStyle(n),g=o.getComputedStyle(r),x=(h.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";s=n.scrollTop,a=n.scrollLeft,Oa={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Ra=n.style.scrollBehavior,Na={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,b=n.scrollWidth>n.clientWidth,w=h.overflowY==="scroll"||g.overflowY==="scroll",S=h.overflowX==="scroll"||g.overflowX==="scroll",C=Math.max(0,o.innerWidth-r.clientWidth),k=Math.max(0,o.innerHeight-r.clientHeight),T=parseFloat(g.marginTop)+parseFloat(g.marginBottom),N=parseFloat(g.marginLeft)+parseFloat(g.marginRight),I=sr(n)?n:r;if(i=rg(e),i){n.style.scrollbarGutter=x,I.style.overflowY="hidden",I.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:x,overflowY:"hidden",overflowX:"hidden"}),(v||w)&&(n.style.overflowY="scroll"),(b||S)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:T||k?`calc(100dvh - ${T+k}px)`:"100dvh",width:N||C?`calc(100vw - ${N+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,Oa),Object.assign(r.style,Na),i||(n.scrollTop=s,n.scrollLeft=a,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=Ra)}function d(){u(),l.request(c)}return c(),o.addEventListener("resize",d),()=>{l.cancel(),u(),typeof o.removeEventListener=="function"&&o.removeEventListener("resize",d)}}class ag{lockCount=0;restore=null;timeoutLock=Vt.create();timeoutUnlock=Vt.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=cn(t).documentElement,o=it(r).getComputedStyle(r).overflowY;if(o==="hidden"||o==="clip"){this.restore=di;return}const s=Di||!ng(t);this.restore=s?og(t):sg(t)}}const ig=new ag;function El(e=!0,t=null){Ee(()=>{if(e)return ig.acquire(t)},[e,t])}const lg=f.createContext(void 0);function cg(){return f.useContext(lg)?.direction??"ltr"}const ug=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:d="real"}=Pt(e,t)||{};if(c==null)return{};const h=Fi(u),g={x:n,y:r},p=ls(o),y=is(p),x=await a.getDimensions(c),v=p==="y",b=v?"top":"left",w=v?"bottom":"right",S=v?"clientHeight":"clientWidth",C=s.reference[y]+s.reference[p]-g[p]-s.floating[y],k=g[p]-s.reference[p],T=d==="real"?await a.getOffsetParent?.(c):i.floating;let N=i.floating[S]||s.floating[y];(!N||!await a.isElement?.(T))&&(N=i.floating[S]||s.floating[y]);const I=C/2-k/2,M=N/2-x[y]/2-1,R=Math.min(h[b],M),j=Math.min(h[w],M),E=R,F=N-x[y]-j,_=N/2-x[y]/2+I,B=Ho(E,_,F),V=!l.arrow&&Gt(o)!=null&&_!==B&&s.reference[y]/2-(_<E?R:j)-x[y]/2<0,O=V?_<E?_-E:_-F:0;return{[p]:g[p]+O,data:{[p]:B,centerOffset:_-B-O,...V&&{alignmentOffset:O}},reset:V}}}),dg=(e,t)=>({...ug(e),options:[e,t]}),fg={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 Mh().fn(e)).data?.referenceHidden||s}}}},Rr={sideX:"left",sideY:"top"},mg={name:"adaptiveOrigin",async fn(e){const{x:t,y:n,rects:{floating:r},elements:{floating:o},platform:s,strategy:a,placement:i}=e,l=it(o),c=l.getComputedStyle(o);if(!(c.transitionDuration!=="0s"&&c.transitionDuration!==""))return{x:t,y:n,data:Rr};const d=await s.getOffsetParent?.(o);let h={width:0,height:0};if(a==="fixed"&&l?.visualViewport)h={width:l.visualViewport.width,height:l.visualViewport.height};else if(d===l){const b=cn(o);h={width:b.documentElement.clientWidth,height:b.documentElement.clientHeight}}else await s.isElement?.(d)&&(h=await s.getDimensions(d));const g=Xe(i);let p=t,y=n;g==="left"&&(p=h.width-(t+r.width)),g==="top"&&(y=h.height-(n+r.height));const x=g==="left"?"right":Rr.sideX,v=g==="top"?"bottom":Rr.sideY;return{x:p,y,data:{sideX:x,sideY:v}}}};function Ml(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 Da(e,t,n){const{rects:r,placement:o}=e;return{side:Ml(t,Xe(o),n),align:Gt(o)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function hg(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:d=!1,keepMounted:h=!1,floatingRootContext:g,mounted:p,collisionAvoidance:y,shiftCrossAxis:x=!1,nodeId:v,adaptiveOrigin:b,lazyFlip:w=!1,externalTree:S}=e,[C,k]=f.useState(null);!p&&C!==null&&k(null);const T=y.side||"flip",N=y.align||"flip",I=y.fallbackAxisSide||"end",M=typeof t=="function"?t:void 0,R=me(M),j=M?R:t,E=bt(t),_=cg()==="rtl",B=C||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":_?"left":"right","inline-start":_?"right":"left"}[r],V=s==="center"?B:`${B}-${s}`;let O=l;const P=1,U=r==="bottom"?P:0,Y=r==="top"?P:0,ee=r==="right"?P:0,H=r==="left"?P:0;typeof O=="number"?O={top:O+U,right:O+H,bottom:O+Y,left:O+ee}:O&&(O={top:(O.top||0)+U,right:(O.right||0)+H,bottom:(O.bottom||0)+Y,left:(O.left||0)+ee});const L={boundary:i==="clipping-ancestors"?"clippingAncestors":i,padding:O},z=f.useRef(null),X=bt(o),oe=bt(a),xe=[vh(Ce=>{const Te=Da(Ce,r,_),K=typeof X.current=="function"?X.current(Te):X.current,le=typeof oe.current=="function"?oe.current(Te):oe.current;return{mainAxis:K,crossAxis:le,alignmentAxis:le}},[typeof o!="function"?o:0,typeof a!="function"?a:0,_,r])],We=N==="none"&&T!=="shift",D=!We&&(c||x||T==="shift"),ae=T==="none"?null:Ch({...L,padding:{top:O.top+P,right:O.right+P,bottom:O.bottom+P,left:O.left+P},mainAxis:!x&&T==="flip",crossAxis:N==="flip"?"alignment":!1,fallbackAxisSideDirection:I}),q=We?null:kh(Ce=>{const Te=cn(Ce.elements.floating).documentElement;return{...L,rootBoundary:x?{x:0,y:0,width:Te.clientWidth,height:Te.clientHeight}:void 0,mainAxis:N!=="none",crossAxis:D,limiter:c||x?void 0:Sh(K=>{if(!z.current)return{};const{width:le,height:Q}=z.current.getBoundingClientRect(),fe=at(Xe(K.placement)),je=fe==="y"?le:Q,ue=fe==="y"?O.left+O.right:O.top+O.bottom;return{offset:je/2+ue/2}})}},[L,c,x,O,N]);T==="shift"||N==="shift"||s==="center"?xe.push(q,ae):xe.push(ae,q),xe.push(Eh({...L,apply({elements:{floating:Ce},rects:{reference:Te},availableWidth:K,availableHeight:le}){Object.entries({"--available-width":`${K}px`,"--available-height":`${le}px`,"--anchor-width":`${Te.width}px`,"--anchor-height":`${Te.height}px`}).forEach(([Q,fe])=>{Ce.style.setProperty(Q,fe)})}}),dg(()=>({element:z.current||document.createElement("div"),padding:u,offsetParent:"floating"}),[u]),{name:"transformOrigin",fn(Ce){const{elements:Te,middlewareData:K,placement:le,rects:Q,y:fe}=Ce,je=Xe(le),ue=at(je),gt=z.current,zt=K.arrow?.x||0,Ct=K.arrow?.y||0,Ve=gt?.clientWidth||0,Et=gt?.clientHeight||0,dn=zt+Ve/2,Bn=Ct+Et/2,Jr=Math.abs(K.shift?.y||0),Qr=Q.reference.height/2,Kt=typeof o=="function"?o(Da(Ce,r,_)):o,fr=Jr>Kt,mr={top:`${dn}px calc(100% + ${Kt}px)`,bottom:`${dn}px ${-Kt}px`,left:`calc(100% + ${Kt}px) ${Bn}px`,right:`${-Kt}px ${Bn}px`}[je],fn=`${dn}px ${Q.reference.y+Qr-fe}px`;return Te.floating.style.setProperty("--transform-origin",D&&ue==="y"&&fr?fn:mr),{}}},fg,b),Ee(()=>{!p&&g&&g.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[p,g]);const ye=f.useMemo(()=>({elementResize:!d&&typeof ResizeObserver<"u",layoutShift:!d&&typeof IntersectionObserver<"u"}),[d]),{refs:$,elements:J,x:ie,y:he,middlewareData:de,update:se,placement:Z,context:De,isPositioned:ke,floatingStyles:Ie}=Fh({rootContext:g,placement:V,middleware:xe,strategy:n,whileElementsMounted:h?void 0:(...Ce)=>Ca(...Ce,ye),nodeId:v,externalTree:S}),{sideX:pe,sideY:Je}=de.adaptiveOrigin||Rr,Fe=ke?n:"fixed",Se=f.useMemo(()=>b?{position:Fe,[pe]:ie,[Je]:he}:{position:Fe,...Ie},[b,Fe,pe,ie,Je,he,Ie]),Ue=f.useRef(null);Ee(()=>{if(!p)return;const Ce=E.current,Te=typeof Ce=="function"?Ce():Ce,le=(_a(Te)?Te.current:Te)||null||null;le!==Ue.current&&($.setPositionReference(le),Ue.current=le)},[p,$,j,E]),f.useEffect(()=>{if(!p)return;const Ce=E.current;typeof Ce!="function"&&_a(Ce)&&Ce.current!==Ue.current&&($.setPositionReference(Ce.current),Ue.current=Ce.current)},[p,$,j,E]),f.useEffect(()=>{if(h&&p&&J.domReference&&J.floating)return Ca(J.domReference,J.floating,se,ye)},[h,p,J,se,ye]);const He=Xe(Z),It=Ml(r,He,_),Ft=Gt(Z)||"center",Lt=!!de.hide?.referenceHidden;Ee(()=>{w&&p&&ke&&k(He)},[w,p,ke,He]);const Wt=f.useMemo(()=>({position:"absolute",top:de.arrow?.y,left:de.arrow?.x}),[de.arrow]),ot=de.arrow?.centerOffset!==0;return f.useMemo(()=>({positionerStyles:Se,arrowStyles:Wt,arrowRef:z,arrowUncentered:ot,side:It,align:Ft,physicalSide:He,anchorHidden:Lt,refs:$,context:De,isPositioned:ke,update:se}),[Se,Wt,z,ot,It,Ft,He,Lt,$,De,ke,se])}function _a(e){return e!=null&&"current"in e}const Tl=f.forwardRef(function(t,n){const{cutout:r,...o}=t;let s;if(r){const a=r?.getBoundingClientRect();s=`polygon(
|
|
1
|
+
import{i as Nu,f as oi,a as si,J as Ru,u as ai,m as Du,r as f,M as ii,b as _u,c as Pu,d as io,e as li,g as ju,h as jn,j as An,k as rn,l as Au,n as Wo,o as xr,p as Xo,q as Yr,s as Iu,t as Fu,v as Lu,w as Jo,x as Tn,y as lo,z as Wu,A as $u,B as nt,C as W,D as m,E as qt,F as Ee,G as an,H as ci,I as ui,K as me,N as di,L as Bu,O as Ke,R as Yu,P as Yt,Q as or,S as Ut,T as Hu,U as jt,V as Vs,W as it,X as ht,Y as kn,Z as Re,_ as At,$ as qs,a0 as Qo,a1 as Zo,a2 as On,a3 as tn,a4 as Uu,a5 as fi,a6 as Vu,a7 as sr,a8 as Hr,a9 as qu,aa as mi,ab as Gu,ac as Ur,ad as vt,ae as hi,af as G,ag as es,ah as gi,ai as zu,aj as Ku,ak as Xu,al as Ju,am as Qu,an as Zu,ao as ed,ap as td,aq as nd,ar as rd,as as od,at as sd,au as ad,av as Nt,aw as id,ax as ld,ay as Gs}from"./main-C7szutiJ.js";import{u as ts,T as cd}from"./ThemeToggle-Qn_pvy0M.js";const ud=500,dd={style:{transition:"none"}},pi="data-base-ui-click-trigger",fd={fallbackAxisSide:"end"},md={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function hd(...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=Nu(o,s,a);return t?i(r):i}function gd(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 d=zs(e.get()),h=zs(s);if(d===h){l();return}const g=o?o.getGeneratorVelocity():e.getVelocity();l(),o=new Ru({keyframes:[d,h],velocity:g,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((d,h)=>{s=d,a=g=>h(co(g,i)),oi.postRender(u)},l),si(t)){let d=n.skipInitialAnimation===!0;const h=t.on("change",p=>{d?(d=!1,e.jump(co(p,i),!1)):e.set(co(p,i))}),g=e.on("destroy",h);return()=>{h(),g()}}return l}function co(e,t){return t?e+t:e}function zs(e){return typeof e=="number"?e:parseFloat(e)}function ns(e){const t=ai(()=>Du(e)),{isStatic:n}=f.useContext(ii);if(n){const[,r]=f.useState(e);f.useEffect(()=>t.on("change",r),[])}return t}function yi(e,t){const n=ns(t()),r=()=>n.set(t());return r(),_u(()=>{const o=()=>oi.preRender(r,!1,!0),s=e.map(a=>a.on("change",o));return()=>{s.forEach(a=>a()),Pu(r)}}),n}function pd(e){io.current=[],e();const t=yi(io.current,e);return io.current=void 0,t}function bi(e,t,n,r){if(typeof e=="function")return pd(e);const s=typeof t=="function"?t:hd(t,n,r),a=Array.isArray(e)?Ks(e,s):Ks([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 Ks(e,t){const n=ai(()=>[]);return yi(e,()=>{n.length=0;const r=e.length;for(let o=0;o<r;o++)n[o]=e[o].get();return t(n)})}function yd(e,t={}){const{isStatic:n}=f.useContext(ii),r=()=>si(e)?e.get():e;if(n)return bi(r);const o=ns(r());return f.useInsertionEffect(()=>gd(o,e,t),[o,JSON.stringify(t)]),o}function bd(e,t={}){return yd(e,{type:"spring",...t})}const xd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],wd=li("info",xd);const vd=[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]],kd=li("trophy",vd);function Sd({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:r=52,weekStartsOn:o="sun",cacheKey:s,timeZone:a,tzOffsetMinutes:i,now:l}={}){const c=f.useMemo(()=>ju({weeks:r,weekStartsOn:o,now:l}),[l,r,o]),[u,d]=f.useState([]),[h,g]=f.useState(null),[p,y]=f.useState("edge"),[x,v]=f.useState(!1),[b,w]=f.useState(null),S=jn(),C=An(t),k=!n,T=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),N=f.useMemo(()=>{if(!s)return null;const F=Yr({timeZone:a,offsetMinutes:i});return`tokentracker.heatmap.${s}.${r}.${o}.${F}`},[s,a,i,r,o]),I=f.useCallback(()=>{if(!N||typeof window>"u")return null;try{const F=window.localStorage.getItem(N);if(!F)return null;const _=JSON.parse(F);return!_||!_.heatmap?null:_}catch{return null}},[N]),M=f.useCallback(F=>{if(!(!N||typeof window>"u"))try{window.localStorage.setItem(N,JSON.stringify(F))}catch{}},[N]),R=f.useCallback(()=>{if(!(!N||typeof window>"u"))try{window.localStorage.removeItem(N)}catch{}},[N]),j=f.useCallback(async()=>{const F=await rn(t);if(!(!F&&!S&&!T)){v(!0),w(null);try{try{const O=await Au({baseUrl:e,accessToken:F,weeks:r,to:c.to,weekStartsOn:o,timeZone:a,tzOffsetMinutes:i}),P=Array.isArray(O?.weeks)?O.weeks:[];if(!P.length&&k){const Y=I();if(Y?.heatmap){g(Y.heatmap),d(Y.daily||[]),y("cache");return}}if(!P.some(Y=>(Array.isArray(Y)?Y:[]).some(ee=>ee&&Number.isFinite(Number(ee.level))))&&P.length){const Y=[];for(const H of P)for(const L of Array.isArray(H)?H:[])L?.day&&Y.push({day:L.day,total_tokens:L.total_tokens??L.value??0,billable_total_tokens:L.billable_total_tokens??L.value??L.total_tokens??0});const ee=Wo({dailyRows:Y,weeks:r,to:O?.to||c.to,weekStartsOn:o});d(Y),g({...ee,week_starts_on:o,active_days:Y.filter(H=>Number(H?.billable_total_tokens??H?.total_tokens)>0).length,streak_days:xr({dailyRows:Y,to:O?.to||c.to})}),y("client"),k?M({heatmap:{...ee,week_starts_on:o,active_days:Y.filter(H=>Number(H?.billable_total_tokens??H?.total_tokens)>0).length,streak_days:xr({dailyRows:Y,to:O?.to||c.to})},daily:Y,fetchedAt:new Date().toISOString()}):R();return}g(O||null),d([]),y("edge"),O&&k?M({heatmap:O,daily:[],fetchedAt:new Date().toISOString()}):k||R();return}catch(O){const P=O,U=P?.status??P?.statusCode;if(U===401||U===403)throw O}const _=await Xo({baseUrl:e,accessToken:F,from:c.from,to:c.to,timeZone:a,tzOffsetMinutes:i}),B=Array.isArray(_?.data)?_.data:[];d(B);const V=Wo({dailyRows:B,weeks:r,to:c.to,weekStartsOn:o});g({...V,week_starts_on:o,active_days:B.filter(O=>Number(O?.billable_total_tokens??O?.total_tokens)>0).length,streak_days:xr({dailyRows:B,to:c.to})}),y("client"),k?M({heatmap:{...V,week_starts_on:o,active_days:B.filter(O=>Number(O?.billable_total_tokens??O?.total_tokens)>0).length,streak_days:xr({dailyRows:B,to:c.to})},daily:B,fetchedAt:new Date().toISOString()}):R()}catch(_){if(k){const B=I();if(B?.heatmap)g(B.heatmap),d(B.daily||[]),y("cache"),w(null);else{const V=_;w(V?.message||String(V)),d([]),g(null),y("edge")}}else{const B=_;w(B?.message||String(B)),d([]),g(null),y("edge")}}finally{v(!1)}}},[t,e,S,n,k,c.from,c.to,I,C,a,i,o,r,R,M,T]);return f.useEffect(()=>{if(!C&&!n&&!S&&!T){d([]),v(!1),w(null),g(null),y("edge");return}if(!k)R(),d([]),w(null),g(null),y("edge");else{const F=I();F?.heatmap&&(g(F.heatmap),d(F.daily||[]),y("cache"))}j()},[t,S,I,j,C,n,k,R,T]),{range:c,daily:u,heatmap:h,source:S?"mock":p==="client"?"edge":p,loading:x,error:b,refresh:j}}function Cd({baseUrl:e,accessToken:t,limit:n=3,from:r,to:o,source:s,timeZone:a,tzOffsetMinutes:i}={}){const[l,c]=f.useState([]),[u,d]=f.useState(!1),[h,g]=f.useState(null),p=jn(),y=An(t),x=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),v=f.useCallback(async()=>{const b=await rn(t);if(!b&&!p&&!x){c([]),g(null),d(!1);return}d(!0),g(null);try{const w=await Iu({baseUrl:e,accessToken:b,limit:n,from:r,to:o,source:s,timeZone:a,tzOffsetMinutes:i});c(Array.isArray(w?.entries)?w.entries:[])}catch(w){const S=w?.message||String(w);g(S),c([])}finally{d(!1)}},[t,e,r,n,p,s,a,o,i,x]);return f.useEffect(()=>{if(!y&&!p&&!x){c([]),g(null),d(!1);return}v()},[p,v,y,x]),{entries:l,loading:u,error:h,refresh:v}}const Ed=24;function Md({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:r,from:o,to:s,months:a=Ed,cacheKey:i,timeZone:l,tzOffsetMinutes:c,now:u,sharedRows:d,sharedRange:h}={}){const[g,p]=f.useState([]),[y,x]=f.useState(()=>({from:o,to:s})),[v,b]=f.useState("edge"),[w,S]=f.useState(null),[C,k]=f.useState(!1),[T,N]=f.useState(null),I=jn(),M=An(t),R=!n,j=Array.isArray(d),E=h?.from||o,F=h?.to||s,_=f.useMemo(()=>r==="day"?"hourly":r==="total"?"monthly":"daily",[r]),B=(()=>{if(!i)return null;const H=Td(e)||"default",L=Yr({timeZone:l,offsetMinutes:c});if(_==="hourly")return`tokentracker.trend.${i}.${H}.hourly.${s||o||"day"}.${L}`;if(_==="monthly")return`tokentracker.trend.${i}.${H}.monthly.${a}.${s||"today"}.${L}`;const z=`${o||""}.${s||""}`;return`tokentracker.trend.${i}.${H}.daily.${z}.${L}`})(),V=f.useCallback(()=>{if(!B||typeof window>"u")return null;try{const H=window.localStorage.getItem(B);if(!H)return null;const L=JSON.parse(H);return!L||!Array.isArray(L.rows)?null:L}catch{return null}},[B]),O=f.useCallback(H=>{if(!(!B||typeof window>"u"))try{window.localStorage.setItem(B,JSON.stringify(H))}catch{}},[B]),P=f.useCallback(()=>{if(!(!B||typeof window>"u"))try{window.localStorage.removeItem(B)}catch{}},[B]),U=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),Y=f.useCallback(async()=>{if(j){p(Array.isArray(d)?d:[]),x({from:E,to:F}),b("shared"),S(null),k(!1),N(null);return}const H=await rn(t);if(!(!H&&!I&&!U)){k(!0),N(null);try{let L;_==="hourly"?L=await Fu({baseUrl:e,accessToken:H,day:s||o,timeZone:l,tzOffsetMinutes:c}):_==="monthly"?L=await Lu({baseUrl:e,accessToken:H,months:a,to:s,timeZone:l,tzOffsetMinutes:c}):L=await Xo({baseUrl:e,accessToken:H,from:o,to:s,timeZone:l,tzOffsetMinutes:c});const z=L?.from||o||L?.day||null,X=L?.to||s||L?.day||null;let oe=Array.isArray(L?.data)?L.data:[];_==="daily"?oe=fo(oe,z||o,X||s,{timeZone:l,offsetMinutes:c,now:u}):_==="hourly"?oe=mo(oe,{timeZone:l,offsetMinutes:c,now:u}):_==="monthly"&&(oe=ho(oe,{timeZone:l,offsetMinutes:c,now:u}));const be=new Date().toISOString();p(oe),x({from:z,to:X}),b("edge"),S(be),R?O({rows:oe,from:z,to:X,mode:_,fetchedAt:be}):P()}catch(L){if(R){const z=V();if(z?.rows){let X=_==="daily"?fo(z.rows||[],z.from||o,z.to||s,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(z.rows)?z.rows:[];_==="hourly"?X=mo(X,{timeZone:l,offsetMinutes:c,now:u}):_==="monthly"&&(X=ho(X,{timeZone:l,offsetMinutes:c,now:u})),p(X),x({from:z.from||o,to:z.to||s}),b("cache"),S(z.fetchedAt||null),N(null)}else{p([]),x({from:o,to:s}),b("edge"),S(null);const X=L;N(X?.message||String(X))}}else{p([]),x({from:o,to:s}),b("edge"),S(null);const z=L;N(z?.message||String(z))}}finally{k(!1)}}},[t,e,o,I,n,R,_,a,V,M,j,E,d,F,l,s,c,u,P,O,U]);f.useEffect(()=>{if(j){p(Array.isArray(d)?d:[]),x({from:E,to:F}),b("shared"),S(null),k(!1),N(null);return}if(!M&&!n&&!I&&!U){p([]),x({from:o,to:s}),N(null),k(!1),b("edge"),S(null);return}if(!R)P(),p([]),x({from:o,to:s}),N(null),b("edge"),S(null);else{const H=V();if(H?.rows){let L=_==="daily"?fo(H.rows||[],H.from||o,H.to||s,{timeZone:l,offsetMinutes:c,now:u}):Array.isArray(H.rows)?H.rows:[];_==="hourly"?L=mo(L,{timeZone:l,offsetMinutes:c,now:u}):_==="monthly"&&(L=ho(L,{timeZone:l,offsetMinutes:c,now:u})),p(L),x({from:H.from||o,to:H.to||s}),b("cache"),S(H.fetchedAt||null)}}Y()},[t,I,V,Y,j,E,d,F,M,n,R,P,U]);const ee=I?"mock":v;return{rows:g,from:y.from||o,to:y.to||s,source:ee,fetchedAt:w,loading:C,error:T,refresh:Y}}function Td(e){try{return new URL(e).host}catch{return null}}function uo(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())&&Tn(a)===t?a:null}function Od(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function fo(e,t,n,{timeZone:r,offsetMinutes:o,now:s}={}){const a=uo(t),i=uo(n);if(!a||!i||i<a)return Array.isArray(e)?e:[];const l=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,c=Jo({timeZone:r,offsetMinutes:o,date:l}),u=uo(c),d=u?u.getTime():l.getTime(),h=new Map;for(const p of e||[])p?.day&&h.set(p.day,p);const g=[];for(let p=a;p<=i;p=Od(p,1)){const y=Tn(p),x=h.get(y),v=p.getTime()>d;if(x){g.push({...x,missing:!1,future:v});continue}g.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 g}function mo(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const o=xi({timeZone:t,offsetMinutes:n,now:r});return o?e.map(s=>{const a=s?.hour||s?.label||"",i=Nd(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 ho(e,{timeZone:t,offsetMinutes:n,now:r}={}){if(!Array.isArray(e))return[];const o=xi({timeZone:t,offsetMinutes:n,now:r});return o?e.map(s=>{const a=s?.month||s?.label||"",i=Rd(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 xi({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 h=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((b,w)=>(w.type&&w.value&&(b[w.type]=w.value),b),{}),g=Number(h.year),p=Number(h.month),y=Number(h.day),x=Number(h.hour),v=Number(h.minute);if(Number.isFinite(g)&&Number.isFinite(p)&&Number.isFinite(y)&&Number.isFinite(x)&&Number.isFinite(v)){const b=x*2+(v>=30?1:0);return{year:g,month:p,day:y,hour:x,minute:v,dayNum:g*1e4+p*100+y,slot:b}}}catch{}if(Number.isFinite(t)){const u=new Date(r.getTime()+t*60*1e3),d=u.getUTCFullYear(),h=u.getUTCMonth()+1,g=u.getUTCDate(),p=u.getUTCHours(),y=u.getUTCMinutes(),x=p*2+(y>=30?1:0);return{year:d,month:h,day:g,hour:p,minute:y,dayNum:d*1e4+h*100+g,slot:x}}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 Nd(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 d=c*2+(u>=30?1:0);return{dayNum:s*1e4+a*100+i,slot:d}}function Rd(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 Xs({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:o,includeDaily:s=!0,cacheKey:a,timeZone:i,tzOffsetMinutes:l,now:c}={}){const[u,d]=f.useState([]),[h,g]=f.useState(null),[p,y]=f.useState(null),[x,v]=f.useState("edge"),[b,w]=f.useState(null),[S,C]=f.useState(!1),[k,T]=f.useState(null),N=jn(),I=An(t),M=!n,R=(()=>{if(!a)return null;const O=Dd(e)||"default",P=s?"daily":"summary",U=Yr({timeZone:i,offsetMinutes:l});return`tokentracker.usage.${a}.${O}.${r}.${o}.${P}.${U}`})(),j=f.useCallback(()=>{if(!R||typeof window>"u")return null;try{const O=window.localStorage.getItem(R);if(!O)return null;const P=JSON.parse(O);return!P||!P.summary?null:P}catch{return null}},[R]),E=f.useCallback(O=>{if(!(!R||typeof window>"u"))try{window.localStorage.setItem(R,JSON.stringify(O))}catch{}},[R]),F=f.useCallback(()=>{if(!(!R||typeof window>"u"))try{window.localStorage.removeItem(R)}catch{}},[R]),_=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),B=f.useCallback(async()=>{const O=await rn(t);if(!(!O&&!N&&!_)){C(!0),T(null);try{let P=null,U=null;if(s){const[z,X]=await Promise.allSettled([Xo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l}),lo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l,rolling:!0})]);if(z.status==="rejected")throw z.reason;P=z.value,U=X.status==="fulfilled"?X.value:null}else U=await lo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l,rolling:!0});let Y=s&&Array.isArray(P?.data)?P.data:[];s&&(Y=po(Y,r,o,{timeZone:i,offsetMinutes:l,now:c}));let ee=U?.totals||P?.summary?.totals||null,H=U?.rolling||P?.summary?.rolling||null;if(s&&!ee&&!U)try{const z=await lo({baseUrl:e,accessToken:O,from:r,to:o,timeZone:i,tzOffsetMinutes:l,rolling:!0});ee=z?.totals||null,H=z?.rolling||H}catch{}const L=new Date().toISOString();d(Y),g(ee),y(H),v("edge"),w(L),ee&&M?E({summary:ee,rolling:H,daily:Y,from:r,to:o,includeDaily:s,fetchedAt:L}):M||F()}catch(P){if(M){const U=j();if(U?.summary){g(U.summary),y(U.rolling||null);const Y=Array.isArray(U.daily)?U.daily:[],ee=s?po(Y,U.from||r,U.to||o,{timeZone:i,offsetMinutes:l,now:c}):Y;d(ee),v("cache"),w(U.fetchedAt||null),T(null)}else{const Y=P;T(Y?.message||String(Y)),d([]),g(null),y(null),v("edge"),w(null)}}else{const U=P;T(U?.message||String(U)),d([]),g(null),y(null),v("edge"),w(null)}}finally{C(!1)}}},[t,e,r,s,N,n,M,c,j,I,i,o,l,F,E,_]);return f.useEffect(()=>{const O=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!I&&!n&&!N&&!O){d([]),g(null),y(null),T(null),C(!1),v("edge"),w(null);return}if(!M)F(),d([]),g(null),y(null),T(null),v("edge"),w(null);else{const P=j();if(P?.summary){g(P.summary),y(P.rolling||null);const U=Array.isArray(P.daily)?P.daily:[],Y=s?po(U,P.from||r,P.to||o,{timeZone:i,offsetMinutes:l,now:c}):U;d(Y),v("cache"),w(P.fetchedAt||null)}}B()},[t,N,j,B,I,n,M,F,_]),{daily:u,summary:h,rolling:p,source:N?"mock":x,fetchedAt:b,loading:S,error:k,refresh:B}}function Dd(e){try{return new URL(e).host}catch{return null}}function go(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())&&Tn(a)===t?a:null}function _d(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function po(e,t,n,{timeZone:r,offsetMinutes:o,now:s}={}){const a=go(t),i=go(n);if(!a||!i||i<a)return Array.isArray(e)?e:[];const l=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,c=Jo({timeZone:r,offsetMinutes:o,date:l}),u=go(c),d=u?u.getTime():l.getTime(),h=new Map;for(const p of e||[])p?.day&&h.set(p.day,p);const g=[];for(let p=a;p<=i;p=_d(p,1)){const y=Tn(p),x=h.get(y),v=p.getTime()>d;if(x){g.push({...x,missing:!1,future:v});continue}g.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 g}function Pd(){const[e,t]=f.useState(null),[n,r]=f.useState(null),o=f.useCallback(async()=>{try{const s=await Wu();t(s&&typeof s=="object"?s:null),r(null)}catch(s){r(s?.message||String(s))}},[]);return f.useEffect(()=>{o()},[o]),{data:e,error:n,refresh:o}}function jd({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:r,to:o,cacheKey:s,timeZone:a,tzOffsetMinutes:i}={}){const[l,c]=f.useState(null),[u,d]=f.useState("edge"),[h,g]=f.useState(!1),[p,y]=f.useState(null),x=jn(),v=An(t),b=!n,w=f.useMemo(()=>{if(!s)return null;const M=Ad(e)||"default",R=Yr({timeZone:a,offsetMinutes:i});return`tokentracker.modelBreakdown.${s}.${M}.${r}.${o}.${R}`},[e,s,r,a,o,i]),S=f.useCallback(()=>{if(!w||typeof window>"u")return null;try{const M=window.localStorage.getItem(w);if(!M)return null;const R=JSON.parse(M);return!R||!R.breakdown?null:R}catch{return null}},[w]),C=f.useCallback(M=>{if(!(!w||typeof window>"u"))try{window.localStorage.setItem(w,JSON.stringify(M))}catch{}},[w]),k=f.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"),N=f.useCallback(async()=>{const M=await rn(t);if(!(!M&&!x&&!T)){g(!0),y(null);try{const R=await $u({baseUrl:e,accessToken:M,from:r,to:o,timeZone:a,tzOffsetMinutes:i});c(R||null),d("edge"),R&&b?C({breakdown:R,fetchedAt:new Date().toISOString()}):b||k()}catch(R){if(b){const j=S();if(j?.breakdown)c(j.breakdown),d("cache"),y(null);else{c(null),d("edge");const E=R;y(E?.message||String(E))}}else{c(null),d("edge");const j=R;y(j?.message||String(j))}}finally{g(!1)}}},[t,e,r,x,n,b,S,a,o,v,i,k,C,T]);return f.useEffect(()=>{if(!v&&!n&&!x&&!T){c(null),d("edge"),y(null),g(!1);return}if(!b)k(),c(null),d("edge"),y(null);else{const M=S();M?.breakdown&&(c(M.breakdown),d("cache"))}N()},[t,x,S,N,v,n,b,k,T]),{breakdown:l,source:x?"mock":u,loading:h,error:p,refresh:N}}function Ad(e){try{return new URL(e).host}catch{return null}}const wi=new Set(["day","hour","month"]);function Id(e){return wi.has(e)}function Js(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 Fd(e,t){const n=Js(e),r=Js(t);if(n&&r)return n.length!==r.length?n.length<r.length?-1:1:n===r?0:n<r?-1:1;const o=nt(e),s=nt(t);return o==null&&s==null?0:o==null?1:s==null?-1:o===s?0:o<s?-1:1}function Ld(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 Wd(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 $d(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 Bd(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 Yd(e,t,n){const r=n==="hour"?Bd:n==="month"?$d:Wd,o=r(e),s=r(t);return o!=null&&s!=null?o===s?0:o<s?-1:1:Ld(e,t)}function vi(e,{key:t,dir:n}){const r=n==="asc"?1:-1,o=Array.isArray(e)?e:[],s=wi.has(t)?(i,l)=>Yd(i,l,t):Fd,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),d=c==null,h=u==null;if(d&&h)return i.index-l.index;if(d)return 1;if(h)return-1;const g=s(c,u);return g!==0?g*r:i.index-l.index}).map(i=>i.row)}const Hd=[{key:"day",label:W("daily.sort.date.label"),title:W("daily.sort.date.title")},{key:"total_tokens",label:W("daily.sort.total.label"),title:W("daily.sort.total.title")},{key:"input_tokens",label:W("daily.sort.input.label"),title:W("daily.sort.input.title")},{key:"output_tokens",label:W("daily.sort.output.label"),title:W("daily.sort.output.title")},{key:"cached_input_tokens",label:W("daily.sort.cached.label"),title:W("daily.sort.cached.title")},{key:"reasoning_output_tokens",label:W("daily.sort.reasoning.label"),title:W("daily.sort.reasoning.title")},{key:"conversation_count",label:W("daily.sort.conversations.label"),title:W("daily.sort.conversations.title")}];function Qs(e){const t=Id(e)?e:"day";return Hd.map((n,r)=>r===0?{...n,key:t}:n)}function Zs(e,{key:t,dir:n}){return vi(e,{key:t,dir:n})}const _r=12,Ud=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function Vd(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 qd(e){return Ud.some(t=>Vd(e?.[t]))}function Gd(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=vi(t,{key:"month",dir:"asc"}),r=n.findIndex(o=>o?.month&&qd(o));return r===-1?t:n.slice(r)}function zd(e,t,n=_r){const r=Array.isArray(e)?e:[],o=Number.isFinite(n)&&n>0?n:_r,a=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*o;return r.slice(a,a+o)}function Kd({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 ki(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function Xd(e){const t=ki(e?.model_id);return t||null}function Si(e,t){return e?.model?String(e.model):t}function Jd(e,{copyFn:t}={}){const n=typeof t=="function"?t:a=>a,o=(Array.isArray(e?.sources)?e.sources:[]).map(a=>{const i=nt(a?.totals?.billable_total_tokens??a?.totals?.total_tokens)??0,l=nt(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(d=>{const h=nt(d?.totals?.billable_total_tokens??d?.totals?.total_tokens)??0;if(!Number.isFinite(h)||h<=0)return null;const g=a.totalTokens>0?Math.round(h/a.totalTokens*1e3)/10:0,p=Si(d,n("shared.placeholder.short")),y=Xd(d),x=a.totalCost>0&&a.totalTokens>0?h/a.totalTokens*a.totalCost:null;return{id:y,name:p,share:g,usage:h,cost:x}}).filter(Boolean);return{label:i,totalPercent:String(c),usd:a.totalCost,usage:a.totalTokens,models:u}})}function Qd(e,{limit:t=3,copyFn:n}={}){const r=typeof n=="function"?n:h=>h,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 h of o){const g=Array.isArray(h?.models)?h.models:[];for(const p of g){const y=nt(p?.totals?.billable_total_tokens)??0;if(!Number.isFinite(y)||y<=0)continue;l+=y;const x=Si(p,r("shared.placeholder.short")),v=ki(x);if(!v)continue;s.set(v,(s.get(v)||0)+y);const b=i.get(v)||0;y>=b&&(i.set(v,y),a.set(v,x))}}if(!s.size)return[];const c=Array.from(s.values()).reduce((h,g)=>h+g,0),u=l>0?l:c,d=Number.isFinite(t)?Math.max(0,Math.floor(t)):3;return Array.from(s.entries()).map(([h,g])=>{const p=u>0?(g/u*100).toFixed(1):"0.0";return{id:h,name:a.get(h)||r("shared.placeholder.short"),tokens:g,percent:String(p)}}).sort((h,g)=>g.tokens!==h.tokens?g.tokens-h.tokens:String(h.name).localeCompare(String(g.name))).slice(0,d)}const Qt=12,Vn=3,yo=26,Zd=["#ecfdf5","#a7f3d0","#6ee7b7","#34d399","#10b981"],ef=["#064e3b","#065f46","#059669","#10b981","#34d399"],tf=[W("heatmap.month.jan"),W("heatmap.month.feb"),W("heatmap.month.mar"),W("heatmap.month.apr"),W("heatmap.month.may"),W("heatmap.month.jun"),W("heatmap.month.jul"),W("heatmap.month.aug"),W("heatmap.month.sep"),W("heatmap.month.oct"),W("heatmap.month.nov"),W("heatmap.month.dec")];function nf(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 rf(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 Ci(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function of(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function sf(e,t){const n=t==="mon"?1:0,r=e.getUTCDay();return Ci(e,-((r-n+7)%7))}function af(e,t,n){if(!e)return[];const r=rf(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=sf(r,n),a=Ci(s,-(e-1)*7),i=[],l=new Set;for(const c of o){const u=Math.floor(of(a,c)/7);u<0||u>=e||l.has(u)||(l.add(u),i.push({label:tf[c.getUTCMonth()],index:u}))}return i}function lf({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:r=!1}){const{resolvedTheme:o}=ts(),a=o==="dark"?ef:Zd,i=f.useRef(null);f.useEffect(()=>{const p=i.current;p&&(p.scrollLeft=p.scrollWidth)},[e?.weeks]);const l=e?.week_starts_on==="mon"?"mon":"sun",c=f.useMemo(()=>{const p=Array.isArray(e?.weeks)?e.weeks:[];if(!p.length)return{weeks:[]};const y=[];for(const x of p)for(const v of Array.isArray(x)?x:[])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 Wo({dailyRows:y,weeks:Math.max(52,p.length),to:e?.to,weekStartsOn:l})},[e?.to,e?.weeks,l]),u=c?.weeks||[],d=l==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(p=>W(`heatmap.day.${p.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(p=>W(`heatmap.day.${p.toLowerCase()}`)),h=f.useMemo(()=>af(u.length,c?.to,l),[c?.to,u.length,l]);if(!u.length)return m.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:W("heatmap.empty")});const g=yo+u.length*Qt+Math.max(0,u.length-1)*Vn;return m.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:[m.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[m.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:W("heatmap.title")}),m.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400",children:n||W("heatmap.legend.utc")})]}),m.jsx("div",{ref:i,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:m.jsxs("div",{style:{minWidth:g},children:[m.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:`${yo}px repeat(${u.length}, ${Qt}px)`,columnGap:Vn},children:[m.jsx("span",{}),h.map(p=>m.jsx("span",{style:{gridColumnStart:p.index+2},className:"whitespace-nowrap",children:p.label},`${p.label}-${p.index}`))]}),m.jsxs("div",{className:"grid",style:{gridTemplateColumns:`${yo}px repeat(${u.length}, ${Qt}px)`,columnGap:Vn},children:[m.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, ${Qt}px)`,rowGap:Vn},children:d.map(p=>m.jsx("span",{className:"leading-none",children:p},p))}),m.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${Qt}px)`,gap:Vn},children:u.map((p,y)=>(Array.isArray(p)?p:[]).map((x,v)=>{if(!x)return null;const b=x.day||`e-${y}-${v}`,w=Number(x.level)||0,S=a[w]||a[0],C=t||n||W("heatmap.legend.utc");return m.jsx("span",{title:W("heatmap.tooltip",{day:x.day,value:nf(x.value),unit:W("heatmap.unit.tokens"),tz:C}),className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10",style:{width:Qt,height:Qt,background:S}},b)}))})]})]})}),!r&&m.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[m.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:W("heatmap.legend.less")}),m.jsx("div",{className:"flex gap-0.5",children:a.map((p,y)=>m.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:p}},y))}),m.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:W("heatmap.legend.more")})]})]})}const cf={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},Ei={...cf,position:"fixed",top:0,left:0};function bt(e){const t=qt(uf,e).current;return t.next=e,Ee(t.effect),t}function uf(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Pr=Symbol("NOT_FOUND");function df(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function ff(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function mf(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 ea=e=>Array.isArray(e)?e:[e];function hf(e){const t=Array.isArray(e[0])?e[0]:e;return mf(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function gf(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}function pf(e){let t;return{get(n){return t&&e(t.key,n)?t.value:Pr},put(n,r){t={key:n,value:r}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function yf(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 Pr}function o(i,l){r(i)===Pr&&(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 bf=(e,t)=>e===t;function xf(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 wf(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:r=bf,maxSize:o=1,resultEqualityCheck:s}=n,a=xf(r);let i=0;const l=o<=1?pf(a):yf(o,a);function c(){let u=l.get(arguments);if(u===Pr){if(u=e.apply(null,arguments),i++,s){const h=l.getEntries().find(g=>s(g.value,u));h&&(u=h.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 vf=class{constructor(e){this.value=e}deref(){return this.value}},kf=typeof WeakRef<"u"?WeakRef:vf,Sf=0,ta=1;function wr(){return{s:Sf,v:void 0,o:null,p:null}}function Mi(e,t={}){let n=wr();const{resultEqualityCheck:r}=t;let o,s=0;function a(){let i=n;const{length:l}=arguments;for(let d=0,h=l;d<h;d++){const g=arguments[d];if(typeof g=="function"||typeof g=="object"&&g!==null){let p=i.o;p===null&&(i.o=p=new WeakMap);const y=p.get(g);y===void 0?(i=wr(),p.set(g,i)):i=y}else{let p=i.p;p===null&&(i.p=p=new Map);const y=p.get(g);y===void 0?(i=wr(),p.set(g,i)):i=y}}const c=i;let u;if(i.s===ta)u=i.v;else if(u=e.apply(null,arguments),s++,r){const d=o?.deref?.()??o;d!=null&&r(d,u)&&(u=d,s!==0&&s--),o=typeof u=="object"&&u!==null||typeof u=="function"?new kf(u):u}return c.s=ta,c.v=u,u}return a.clearCache=()=>{n=wr(),a.resetResultsCount()},a.resultsCount=()=>s,a.resetResultsCount=()=>{s=0},a}function Ti(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()),df(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const u={...n,...l},{memoize:d,memoizeOptions:h=[],argsMemoize:g=Mi,argsMemoizeOptions:p=[]}=u,y=ea(h),x=ea(p),v=hf(o),b=d(function(){return s++,c.apply(null,arguments)},...y),w=g(function(){a++;const C=gf(v,arguments);return i=b.apply(null,C),i},...x);return Object.assign(w,{resultFunc:c,memoizedResultFunc:b,dependencies:v,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>i,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:d,argsMemoize:g})};return Object.assign(r,{withTypes:()=>r}),r}var Cf=Ti(Mi),Ef=Object.assign((e,t=Cf)=>{ff(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:()=>Ef});Ti({memoize:wf,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const ge=(e,t,n,r,o,s,...a)=>{if(a.length>0)throw new Error(an(1));let i;if(e)i=e;else throw new Error("Missing arguments");return i};var bo={exports:{}},xo={};var na;function Mf(){if(na)return xo;na=1;var e=ci();function t(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,a=e.useDebugValue;function i(d,h){var g=h(),p=r({inst:{value:g,getSnapshot:h}}),y=p[0].inst,x=p[1];return s(function(){y.value=g,y.getSnapshot=h,l(y)&&x({inst:y})},[d,g,h]),o(function(){return l(y)&&x({inst:y}),d(function(){l(y)&&x({inst:y})})},[d]),a(g),g}function l(d){var h=d.getSnapshot;d=d.value;try{var g=h();return!n(d,g)}catch{return!0}}function c(d,h){return h()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:i;return xo.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,xo}var ra;function Oi(){return ra||(ra=1,bo.exports=Mf()),bo.exports}var Tf=Oi(),wo={exports:{}},vo={};var oa;function Of(){if(oa)return vo;oa=1;var e=ci(),t=Oi();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 vo.useSyncExternalStoreWithSelector=function(c,u,d,h,g){var p=s(null);if(p.current===null){var y={hasValue:!1,value:null};p.current=y}else y=p.current;p=i(function(){function v(k){if(!b){if(b=!0,w=k,k=h(k),g!==void 0&&y.hasValue){var T=y.value;if(g(T,k))return S=T}return S=k}if(T=S,r(w,k))return T;var N=h(k);return g!==void 0&&g(T,N)?(w=k,T):(w=k,S=N)}var b=!1,w,S,C=d===void 0?null:d;return[function(){return v(u())},C===null?void 0:function(){return v(C())}]},[u,d,h,g]);var x=o(c,p[0],p[1]);return a(function(){y.hasValue=!0,y.value=x},[x]),l(x),x},vo}var sa;function Nf(){return sa||(sa=1,wo.exports=Of()),wo.exports}var Rf=Nf();const Df=ui(19),_f=Df?jf:Af;function Pf(e,t,n,r,o){return _f(e,t,n,r,o)}function jf(e,t,n,r,o){const s=f.useCallback(()=>t(e.getSnapshot(),n,r,o),[e,t,n,r,o]);return Tf.useSyncExternalStore(e.subscribe,s,s)}function Af(e,t,n,r,o){return Rf.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,s=>t(s,n,r,o))}class Jn{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])){Jn.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||Jn.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};Jn.prototype.setState.call(this,t)}}class rs extends Jn{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}controlledValues=new Map;useSyncedValue(t,n){f.useDebugValue(t),Ee(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){const r=this;Ee(()=>(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);Ee(()=>{n.update(t)},[n,...r])}useControlledProp(t,n,r){f.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})),Ee(()=>{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)=>{f.useDebugValue(t);const s=this.selectors[t];return Pf(this,s,n,r,o)};useContextCallback(t,n){f.useDebugValue(t);const r=me(n??di);this.context[t]=r}useStateSetter(t){const n=f.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 If=[];function os(e){f.useEffect(e,If)}const vr=null;class Ff{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 kr=new Ff;class yt{static create(){return new yt}static request(t){return kr.request(t)}static cancel(t){return kr.cancel(t)}currentId=vr;request(t){this.cancel(),this.currentId=kr.request(()=>{this.currentId=vr,t()})}cancel=()=>{this.currentId!==vr&&(kr.cancel(this.currentId),this.currentId=vr)};disposeEffect=()=>this.cancel}function ss(){const e=qt(yt.create).current;return os(e.disposeEffect),e}const qn=0;class Vt{static create(){return new Vt}currentId=qn;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=qn,n()},t)}isStarted(){return this.currentId!==qn}clear=()=>{this.currentId!==qn&&(clearTimeout(this.currentId),this.currentId=qn)};disposeEffect=()=>this.clear}function on(){const e=qt(Vt.create).current;return os(e.disposeEffect),e}const In=typeof navigator<"u",ko=Bf(),Ni=Hf(),Ri=Yf(),Lf=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),Di=ko.platform==="MacIntel"&&ko.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(ko.platform),Wf=In&&/apple/i.test(navigator.vendor),$o=In&&/android/i.test(Ni)||/android/i.test(Ri);In&&Ni.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const $f=Ri.includes("jsdom/");function Bf(){if(!In)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 Yf(){if(!In)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function Hf(){if(!In)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const Bo="data-base-ui-focusable",_i="active",Pi="selected",ji="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function wn(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function ve(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Bu(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function Ze(e){return"composedPath"in e?e.composedPath()[0]:e.target}function ut(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 Uf(e){return e.matches("html,body")}function Ye(e){return e?.ownerDocument||document}function Ai(e){return Ke(e)&&e.matches(ji)}function aa(e){return e?e.getAttribute("role")==="combobox"&&Ai(e):!1}function Yo(e){return e?e.hasAttribute(Bo)?e:e.querySelector(`[${Bo}]`)||e:null}function nn(e,t,n=!0){return e.filter(o=>o.parentId===t&&(!n||o.context?.open)).flatMap(o=>[o,...nn(e,o.id,n)])}function ia(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 Vf(e){e.preventDefault(),e.stopPropagation()}function qf(e){return"nativeEvent"in e}function Gf(e){return e.mozInputSource===0&&e.isTrusted?!0:$o&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function zf(e){return $f?!1:!$o&&e.width===0&&e.height===0||$o&&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 Nn(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function Ii(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const Kf=["top","right","bottom","left"],Rn=Math.min,et=Math.max,jr=Math.round,Sr=Math.floor,kt=e=>({x:e,y:e}),Xf={left:"right",right:"left",bottom:"top",top:"bottom"};function Ho(e,t,n){return et(e,Rn(t,n))}function Pt(e,t){return typeof e=="function"?e(t):e}function Xe(e){return e.split("-")[0]}function Gt(e){return e.split("-")[1]}function as(e){return e==="x"?"y":"x"}function is(e){return e==="y"?"height":"width"}function at(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ls(e){return as(at(e))}function Jf(e,t,n){n===void 0&&(n=!1);const r=Gt(e),o=ls(e),s=is(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Ar(a)),[a,Ar(a)]}function Qf(e){const t=Ar(e);return[Uo(e),t,Uo(t)]}function Uo(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const la=["left","right"],ca=["right","left"],Zf=["top","bottom"],em=["bottom","top"];function tm(e,t,n){switch(e){case"top":case"bottom":return n?t?ca:la:t?la:ca;case"left":case"right":return t?Zf:em;default:return[]}}function nm(e,t,n,r){const o=Gt(e);let s=tm(Xe(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(Uo)))),s}function Ar(e){const t=Xe(e);return Xf[t]+e.slice(t.length)}function rm(e){return{top:0,right:0,bottom:0,left:0,...e}}function Fi(e){return typeof e!="number"?rm(e):{top:e,right:e,bottom:e,left:e}}function Ir(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 om=["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] *)"],Fr=om.join(","),Li=typeof Element>"u",Dn=Li?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Lr=!Li&&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},Wr=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]"):Wr(t.parentNode));return a},sm=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},Wi=function(t,n,r){if(Wr(t))return[];var o=Array.prototype.slice.apply(t.querySelectorAll(Fr));return n&&Dn.call(t,Fr)&&o.unshift(t),o=o.filter(r),o},$r=function(t,n,r){for(var o=[],s=Array.from(t);s.length;){var a=s.shift();if(!Wr(a,!1))if(a.tagName==="SLOT"){var i=a.assignedElements(),l=i.length?i:a.children,c=$r(l,!0,r);r.flatten?o.push.apply(o,c):o.push({scopeParent:a,candidates:c})}else{var u=Dn.call(a,Fr);u&&r.filter(a)&&(n||!t.includes(a))&&o.push(a);var d=a.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(a),h=!Wr(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(a));if(d&&h){var g=$r(d===!0?a.children:d.children,!0,r);r.flatten?o.push.apply(o,g):o.push({scopeParent:a,candidates:g})}else s.unshift.apply(s,a.children)}}return o},$i=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Bi=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||sm(t))&&!$i(t)?0:t.tabIndex},am=function(t,n){var r=Bi(t);return r<0&&n&&!$i(t)?0:r},im=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Yi=function(t){return t.tagName==="INPUT"},lm=function(t){return Yi(t)&&t.type==="hidden"},cm=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},um=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},dm=function(t){if(!t.name)return!0;var n=t.form||Lr(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=um(o,t.form);return!s||s===t},fm=function(t){return Yi(t)&&t.type==="radio"},mm=function(t){return fm(t)&&!dm(t)},hm=function(t){var n,r=t&&Lr(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,d;r=Lr(o),o=(c=r)===null||c===void 0?void 0:c.host,s=!!((u=o)!==null&&u!==void 0&&(d=u.ownerDocument)!==null&&d!==void 0&&d.contains(o))}}return s},ua=function(t){var n=t.getBoundingClientRect(),r=n.width,o=n.height;return r===0&&o===0},gm=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=Dn.call(t,"details>summary:first-of-type"),i=a?t.parentElement:t;if(Dn.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=Lr(t);if(c&&!c.shadowRoot&&o(c)===!0)return ua(t);t.assignedSlot?t=t.assignedSlot:!c&&u!==t.ownerDocument?t=u.host:t=c}t=l}if(hm(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return ua(t);return!1},pm=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 Dn.call(n,"fieldset[disabled] *")?!0:!o.contains(t)}return!0}n=n.parentElement}return!1},Vo=function(t,n){return!(n.disabled||lm(n)||gm(n,t)||cm(n)||pm(n))},qo=function(t,n){return!(mm(n)||Bi(n)<0||!Vo(t,n))},ym=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Hi=function(t){var n=[],r=[];return t.forEach(function(o,s){var a=!!o.scopeParent,i=a?o.scopeParent:o,l=am(i,a),c=a?Hi(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(im).reduce(function(o,s){return s.isScope?o.push.apply(o,s.content):o.push(s.content),o},[]).concat(n)},ar=function(t,n){n=n||{};var r;return n.getShadowRoot?r=$r([t],n.includeContainer,{filter:qo.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:ym}):r=Wi(t,n.includeContainer,qo.bind(null,n)),Hi(r)},bm=function(t,n){n=n||{};var r;return n.getShadowRoot?r=$r([t],n.includeContainer,{filter:Vo.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=Wi(t,n.includeContainer,Vo.bind(null,n)),r},Ui=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return Dn.call(t,Fr)===!1?!1:qo(n,t)};const Fn=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Vi(e,t){const n=ar(e,Fn()),r=n.length;if(r===0)return;const o=wn(Ye(e)),s=n.indexOf(o),a=s===-1?t===1?0:r-1:s+t;return n[a]}function cs(e){return Vi(Ye(e).body,1)||e}function qi(e){return Vi(Ye(e).body,-1)||e}function Gi(e,t){if(!e)return null;const n=ar(Ye(e).body,Fn()),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 xm(e){return Gi(e,1)}function wm(e){return Gi(e,-1)}function Sn(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!ve(n,r)}function vm(e){ar(e,Fn()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function da(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 km={...Yu};let fa=0;function Sm(e,t="mui"){const[n,r]=f.useState(e),o=e||n;return f.useEffect(()=>{n==null&&(fa+=1,r(`${t}-${fa}`))},[n,t]),o}const ma=km.useId;function Ln(e,t){if(ma!==void 0){const n=ma();return e??(t?`${t}-${n}`:n)}return Sm(e,t)}function zi(){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 Cm{nodesRef={current:[]};events=zi();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 Ki=f.createContext(null),Xi=f.createContext(null),ln=()=>f.useContext(Ki)?.id||null,Wn=e=>{const t=f.useContext(Xi);return e??t};function Em(e){const t=Ln(),n=Wn(e),r=ln();return Ee(()=>{if(!t)return;const o={id:t,parentId:r};return n?.addNode(o),()=>{n?.removeNode(o)}},[n,t,r]),t}function Mm(e){const{children:t,id:n}=e,r=ln();return m.jsx(Ki.Provider,{value:f.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Tm(e){const{children:t,externalTree:n}=e,r=qt(()=>n??new Cm).current;return m.jsx(Xi.Provider,{value:r,children:t})}const Om="none",Ht="trigger-press",tt="trigger-hover",Ji="outside-press",Nm="close-press",Qn="focus-out",Qi="escape-key",Zi="imperative-action";function Pe(e,t,n,r){let o=!1,s=!1;const a=Yt;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 Zn(e){return`data-base-ui-${e}`}function So(e,t,n){if(n&&!Nn(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 cn(e){return e?.ownerDocument||document}const _n=f.forwardRef(function(t,n){const[r,o]=f.useState();Ee(()=>{Wf&&o("button")},[]);const s={tabIndex:0,role:r};return m.jsx("span",{...t,ref:n,style:Ei,"aria-hidden":r?void 0:!0,...s,"data-base-ui-focus-guard":""})});let ha=0;function Co(e,t={}){const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(ha);const s=()=>e?.focus({preventScroll:n});o?s():ha=requestAnimationFrame(s)}const Cn={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function ga(e){return e==="inert"?Cn.inert:e==="aria-hidden"?Cn["aria-hidden"]:Cn.none}let Cr=new WeakSet,Er={},Eo=0;const el=e=>e&&(e.host||el(e.parentNode)),Rm=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=el(n);return e.contains(r)?r:null}).filter(n=>n!=null);function Dm(e,t,n,r){const o="data-base-ui-inert",s=r?"inert":n?"aria-hidden":null,a=Rm(t,e),i=new Set,l=new Set(a),c=[];Er[o]||(Er[o]=new WeakMap);const u=Er[o];a.forEach(d),h(t),i.clear();function d(g){!g||i.has(g)||(i.add(g),g.parentNode&&d(g.parentNode))}function h(g){!g||l.has(g)||[].forEach.call(g.children,p=>{if(or(p)!=="script")if(i.has(p))h(p);else{const y=s?p.getAttribute(s):null,x=y!==null&&y!=="false",v=ga(s),b=(v.get(p)||0)+1,w=(u.get(p)||0)+1;v.set(p,b),u.set(p,w),c.push(p),b===1&&x&&Cr.add(p),w===1&&p.setAttribute(o,""),!x&&s&&p.setAttribute(s,s==="inert"?"":"true")}})}return Eo+=1,()=>{c.forEach(g=>{const p=ga(s),x=(p.get(g)||0)-1,v=(u.get(g)||0)-1;p.set(g,x),u.set(g,v),x||(!Cr.has(g)&&s&&g.removeAttribute(s),Cr.delete(g)),v||g.removeAttribute(o)}),Eo-=1,Eo||(Cn.inert=new WeakMap,Cn["aria-hidden"]=new WeakMap,Cn.none=new WeakMap,Cr=new WeakSet,Er={})}}function _m(e,t=!1,n=!1){const r=Ye(e[0]).body;return Dm(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}const tl=f.createContext(null),nl=()=>f.useContext(tl),Pm=Zn("portal");function jm(e={}){const{ref:t,container:n,componentProps:r=Yt,elementProps:o,elementState:s}=e,a=Ln(),l=nl()?.portalNode,[c,u]=f.useState(null),[d,h]=f.useState(null),g=me(v=>{v!==null&&h(v)}),p=f.useRef(null);Ee(()=>{if(n===null){p.current&&(p.current=null,h(null),u(null));return}if(a==null)return;const v=(n&&(Hu(n)?n:n.current))??l??document.body;if(v==null){p.current&&(p.current=null,h(null),u(null));return}p.current!==v&&(p.current=v,h(null),u(v))},[n,l,a]);const y=jt("div",r,{ref:[t,g],state:s,props:[{id:a,[Pm]:""},o]});return{portalNode:d,portalSubtree:c&&y?Ut.createPortal(y,c):null}}const rl=f.forwardRef(function(t,n){const{children:r,container:o,className:s,render:a,renderGuards:i,...l}=t,{portalNode:c,portalSubtree:u}=jm({container:o,ref:n,componentProps:t,elementProps:l}),d=f.useRef(null),h=f.useRef(null),g=f.useRef(null),p=f.useRef(null),[y,x]=f.useState(null),v=y?.modal,b=y?.open,w=typeof i=="boolean"?i:!!y&&!y.modal&&y.open&&!!c;f.useEffect(()=>{if(!c||v)return;function C(k){c&&k.relatedTarget&&Sn(k)&&(k.type==="focusin"?da:vm)(c)}return c.addEventListener("focusin",C,!0),c.addEventListener("focusout",C,!0),()=>{c.removeEventListener("focusin",C,!0),c.removeEventListener("focusout",C,!0)}},[c,v]),f.useEffect(()=>{!c||b||da(c)},[b,c]);const S=f.useMemo(()=>({beforeOutsideRef:d,afterOutsideRef:h,beforeInsideRef:g,afterInsideRef:p,portalNode:c,setFocusManagerState:x}),[c]);return m.jsxs(f.Fragment,{children:[u,m.jsxs(tl.Provider,{value:S,children:[w&&c&&m.jsx(_n,{"data-type":"outside",ref:d,onFocus:C=>{if(Sn(C,c))g.current?.focus();else{const k=y?y.domReference:null;qi(k)?.focus()}}}),w&&c&&m.jsx("span",{"aria-owns":c.id,style:md}),c&&Ut.createPortal(r,c),w&&c&&m.jsx(_n,{"data-type":"outside",ref:h,onFocus:C=>{if(Sn(C,c))p.current?.focus();else{const k=y?y.domReference:null;cs(k)?.focus(),y?.closeOnFocusOut&&y?.onOpenChange(!1,Pe(Qn,C.nativeEvent))}}})]})]})});function Rt(e){return e==null?e:"current"in e?e.current:e}function Am(e,t){const n=it(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 pa=20;let Bt=[];function us(){Bt=Bt.filter(e=>e.isConnected)}function Im(e){us(),e&&or(e)!=="body"&&(Bt.push(e),Bt.length>pa&&(Bt=Bt.slice(-pa)))}function Mo(){return us(),Bt[Bt.length-1]}function Fm(e){if(!e)return null;const t=Fn();return Ui(e,t)?e:ar(e,t)[0]||e}function Lm(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():ht(e).display!=="none"}function ya(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=Fn(),o=bm(e,n).filter(a=>{const i=a.getAttribute("data-tabindex")||"";return Ui(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 ol(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:d=()=>[],nextFocusableElement:h,previousFocusableElement:g,beforeContentFocusGuardRef:p,externalTree:y}=e,x="rootStore"in t?t.rootStore:t,v=x.useState("open"),b=x.useState("domReferenceElement"),w=x.useState("floatingElement"),{events:S,dataRef:C}=x.context,k=me(()=>C.current.floatingContext?.nodeId),T=me(d),N=s===!1,I=aa(b)&&N,M=bt(o),R=bt(s),j=bt(a),E=bt(u),F=Wn(y),_=nl(),B=f.useRef(null),V=f.useRef(null),O=f.useRef(!1),P=f.useRef(!1),U=f.useRef(!1),Y=f.useRef(-1),ee=f.useRef(""),H=f.useRef(""),L=f.useRef(null),z=f.useRef(null),X=Vs(L,p,_?.beforeInsideRef),oe=Vs(z,_?.afterInsideRef),be=on(),Oe=on(),xe=ss(),We=_!=null,D=Yo(w),ae=me(($=D)=>$?ar($,Fn()):[]),q=me($=>{const J=ae($);return M.current.map(()=>J).filter(Boolean).flat()});f.useEffect(()=>{if(r||!l)return;function $(ie){ie.key==="Tab"&&ve(D,wn(Ye(D)))&&ae().length===0&&!I&&Vf(ie)}const J=Ye(D);return J.addEventListener("keydown",$),()=>{J.removeEventListener("keydown",$)}},[r,b,D,l,M,I,ae,q]),f.useEffect(()=>{if(r||!w)return;function $(J){const ie=Ze(J),de=ae().indexOf(ie);de!==-1&&(Y.current=de)}return w.addEventListener("focusin",$),()=>{w.removeEventListener("focusin",$)}},[r,w,ae]),f.useEffect(()=>{if(r||!v)return;const $=Ye(D);function J(){U.current=!1}function ie(de){const se=Ze(de),Z=ve(w,se)||ve(b,se)||ve(_?.portalNode,se);U.current=!Z,H.current=de.pointerType||"keyboard"}function he(){H.current="keyboard"}return $.addEventListener("pointerdown",ie,!0),$.addEventListener("pointerup",J,!0),$.addEventListener("pointercancel",J,!0),$.addEventListener("keydown",he,!0),()=>{$.removeEventListener("pointerdown",ie,!0),$.removeEventListener("pointerup",J,!0),$.removeEventListener("pointercancel",J,!0),$.removeEventListener("keydown",he,!0)}},[r,w,b,D,v,_]),f.useEffect(()=>{if(r||!c)return;function $(){P.current=!0,Oe.start(0,()=>{P.current=!1})}function J(se){const Z=se.relatedTarget,De=se.currentTarget,ke=Ze(se);queueMicrotask(()=>{const Ie=k(),pe=x.context.triggerElements,Je=Z?.hasAttribute(Zn("focus-guard"))&&[L.current,z.current,_?.beforeInsideRef.current,_?.afterInsideRef.current,_?.beforeOutsideRef.current,_?.afterOutsideRef.current,Rt(g),Rt(h)].includes(Z),Fe=!(ve(b,Z)||ve(w,Z)||ve(Z,w)||ve(_?.portalNode,Z)||Z!=null&&pe.hasElement(Z)||pe.hasMatchingElement(Se=>ve(Se,Z))||Je||F&&(nn(F.nodesRef.current,Ie).find(Se=>ve(Se.context?.elements.floating,Z)||ve(Se.context?.elements.domReference,Z))||ia(F.nodesRef.current,Ie).find(Se=>[Se.context?.elements.floating,Yo(Se.context?.elements.floating)].includes(Z)||Se.context?.elements.domReference===Z)));if(De===b&&D&&ya(D,M),i&&De!==b&&!Lm(ke)&&wn(Ye(D))===Ye(D).body){if(Ke(D)&&(D.focus(),i==="popup")){xe.request(()=>{D.focus()});return}const Se=Y.current,Ue=ae(),He=Ue[Se]||Ue[Ue.length-1]||D;Ke(He)&&He.focus()}if(C.current.insideReactTree){C.current.insideReactTree=!1;return}(I||!l)&&Z&&Fe&&!P.current&&(I||Z!==Mo())&&(O.current=!0,x.setOpen(!1,Pe(Qn,se)))})}function ie(){U.current||(C.current.insideReactTree=!0,be.start(0,()=>{C.current.insideReactTree=!1}))}const he=Ke(b)?b:null,de=[];if(!(!w&&!he))return he&&(he.addEventListener("focusout",J),he.addEventListener("pointerdown",$),de.push(()=>{he.removeEventListener("focusout",J),he.removeEventListener("pointerdown",$)})),w&&(w.addEventListener("focusout",J),_&&(w.addEventListener("focusout",ie,!0),de.push(()=>{w.removeEventListener("focusout",ie,!0)})),de.push(()=>{w.removeEventListener("focusout",J)})),()=>{de.forEach(se=>{se()})}},[r,b,w,D,l,F,_,x,c,i,ae,I,k,M,C,be,Oe,xe,h,g]),f.useEffect(()=>{if(r||!w||!v)return;const $=Array.from(_?.portalNode?.querySelectorAll(`[${Zn("portal")}]`)||[]),ie=(F?ia(F.nodesRef.current,k()):[]).find(se=>aa(se.context?.elements.domReference||null))?.context?.elements.domReference,he=[w,ie,...$,...T(),B.current,V.current,L.current,z.current,_?.beforeOutsideRef.current,_?.afterOutsideRef.current,Rt(g),Rt(h),I?b:null].filter(se=>se!=null),de=_m(he,l||I);return()=>{de()}},[v,r,b,w,l,M,_,I,F,k,T,h,g]),Ee(()=>{if(!v||r||!Ke(D))return;const $=Ye(D),J=wn($);queueMicrotask(()=>{const ie=q(D),he=R.current,de=typeof he=="function"?he(E.current||""):he;if(de===void 0||de===!1)return;let se;de===!0||de===null?se=ie[0]||D:se=Rt(de),se=se||ie[0]||D,!ve(D,J)&&Co(se,{preventScroll:se===D})})},[r,v,D,N,q,R,E]),Ee(()=>{if(r||!D)return;const $=Ye(D),J=wn($);Im(J);function ie(se){if(se.open||(ee.current=Am(se.nativeEvent,H.current)),se.reason===tt&&se.nativeEvent.type==="mouseleave"&&(O.current=!0),se.reason===Ji)if(se.nested)O.current=!1;else if(Gf(se.nativeEvent)||zf(se.nativeEvent))O.current=!1;else{let Z=!1;document.createElement("div").focus({get preventScroll(){return Z=!0,!1}}),Z?O.current=!1:O.current=!0}}S.on("openchange",ie);const he=$.createElement("span");he.setAttribute("tabindex","-1"),he.setAttribute("aria-hidden","true"),Object.assign(he.style,Ei),We&&b&&b.insertAdjacentElement("afterend",he);function de(){const se=j.current;let Z=typeof se=="function"?se(ee.current):se;if(Z===void 0||Z===!1)return null;if(Z===null&&(Z=!0),typeof Z=="boolean"){const ke=b||Mo();return ke&&ke.isConnected?ke:he}const De=b||Mo()||he;return Rt(Z)||De}return()=>{S.off("openchange",ie);const se=wn($),Z=ve(w,se)||F&&nn(F.nodesRef.current,k(),!1).some(ke=>ve(ke.context?.elements.floating,se)),De=de();queueMicrotask(()=>{const ke=Fm(De),Ie=typeof j.current!="boolean";j.current&&!O.current&&Ke(ke)&&(!(!Ie&&ke!==se&&se!==$.body)||Z)&&ke.focus({preventScroll:!0}),he.remove()})}},[r,w,D,j,C,S,F,We,b,k]),f.useEffect(()=>{queueMicrotask(()=>{O.current=!1})},[r]),f.useEffect(()=>{if(r||!v)return;function $(ie){Ze(ie)?.closest(`[${pi}]`)&&(P.current=!0)}const J=Ye(D);return J.addEventListener("pointerdown",$,!0),()=>{J.removeEventListener("pointerdown",$,!0)}},[r,v,D]),Ee(()=>{if(!r&&_)return _.setFocusManagerState({modal:l,closeOnFocusOut:c,open:v,onOpenChange:x.setOpen,domReference:b}),()=>{_.setFocusManagerState(null)}},[r,_,l,v,x,c,b]),Ee(()=>{if(!(r||!D))return ya(D,M),()=>{queueMicrotask(us)}},[r,D,M]);const ye=!r&&(l?!I:!0)&&(We||l);return m.jsxs(f.Fragment,{children:[ye&&m.jsx(_n,{"data-type":"inside",ref:X,onFocus:$=>{if(l){const J=q();Co(J[J.length-1])}else _?.portalNode&&(O.current=!1,Sn($,_.portalNode)?cs(b)?.focus():Rt(g??_.beforeOutsideRef)?.focus())}}),n,ye&&m.jsx(_n,{"data-type":"inside",ref:oe,onFocus:$=>{l?Co(q()[0]):_?.portalNode&&(c&&(O.current=!0),Sn($,_.portalNode)?qi(b)?.focus():Rt(h??_.afterOutsideRef)?.focus())}})]})}function Wm(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=f.useRef(void 0),d=ss(),h=on(),g=f.useMemo(()=>({onPointerDown(p){u.current=p.pointerType},onMouseDown(p){const y=u.current,x=p.nativeEvent,v=n.select("open");if(p.button!==0||s==="click"||Nn(y,!0)&&i)return;const b=r.current.openEvent,w=b?.type,S=n.select("domReferenceElement")!==p.currentTarget,C=v&&S||!(v&&a&&(!(b&&l)||w==="click"||w==="mousedown"));if(Ai(x.target)){const T=Pe(Ht,x,x.target);C&&y==="touch"&&c>0?h.start(c,()=>{n.setOpen(!0,T)}):n.setOpen(C,T);return}const k=p.currentTarget;d.request(()=>{const T=Pe(Ht,x,k);C&&y==="touch"&&c>0?h.start(c,()=>{n.setOpen(!0,T)}):n.setOpen(C,T)})},onClick(p){if(s==="mousedown-only")return;const y=u.current;if(s==="mousedown"&&y){u.current=void 0;return}if(Nn(y,!0)&&i)return;const x=n.select("open"),v=r.current.openEvent,b=n.select("domReferenceElement")!==p.currentTarget,w=x&&b||!(x&&a&&(!(v&&l)||Ii(v))),S=Pe(Ht,p.nativeEvent,p.currentTarget);w&&y==="touch"&&c>0?h.start(c,()=>{n.setOpen(!0,S)}):n.setOpen(w,S)},onKeyDown(){u.current=void 0}}),[r,s,i,n,l,a,d,h,c]);return f.useMemo(()=>o?{reference:g}:Yt,[o,g])}function ba(e,t,n){let{reference:r,floating:o}=e;const s=at(t),a=ls(t),i=is(a),l=Xe(t),c=s==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,h=r[i]/2-o[i]/2;let g;switch(l){case"top":g={x:u,y:r.y-o.height};break;case"bottom":g={x:u,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:d};break;case"left":g={x:r.x-o.width,y:d};break;default:g={x:r.x,y:r.y}}switch(Gt(t)){case"start":g[a]-=h*(n&&c?-1:1);break;case"end":g[a]+=h*(n&&c?-1:1);break}return g}async function $m(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:d="floating",altBoundary:h=!1,padding:g=0}=Pt(t,e),p=Fi(g),x=i[h?d==="floating"?"reference":"floating":d],v=Ir(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(i.floating)),boundary:c,rootBoundary:u,strategy:l})),b=d==="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)),S=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=Ir(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:b,offsetParent:w,strategy:l}):b);return{top:(v.top-C.top+p.top)/S.y,bottom:(C.bottom-v.bottom+p.bottom)/S.y,left:(v.left-C.left+p.left)/S.x,right:(C.right-v.right+p.right)/S.x}}const Bm=50,Ym=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:a}=n,i=a.detectOverflow?a:{...a,detectOverflow:$m},l=await(a.isRTL==null?void 0:a.isRTL(t));let c=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=ba(c,r,l),h=r,g=0;const p={};for(let y=0;y<s.length;y++){const x=s[y];if(!x)continue;const{name:v,fn:b}=x,{x:w,y:S,data:C,reset:k}=await b({x:u,y:d,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});u=w??u,d=S??d,p[v]={...p[v],...C},k&&g<Bm&&(g++,typeof k=="object"&&(k.placement&&(h=k.placement),k.rects&&(c=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):k.rects),{x:u,y:d}=ba(c,h,l)),y=-1)}return{x:u,y:d,placement:h,strategy:o,middlewareData:p}},Hm=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:d=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:y=!0,...x}=Pt(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=Xe(o),b=at(i),w=Xe(i)===i,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=h||(w||!y?[Ar(i)]:Qf(i)),k=p!=="none";!h&&k&&C.push(...nm(i,y,p,S));const T=[i,...C],N=await l.detectOverflow(t,x),I=[];let M=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&I.push(N[v]),d){const F=Jf(o,a,S);I.push(N[F[0]],N[F[1]])}if(M=[...M,{placement:o,overflows:I}],!I.every(F=>F<=0)){var R,j;const F=(((R=s.flip)==null?void 0:R.index)||0)+1,_=T[F];if(_&&(!(d==="alignment"?b!==at(_):!1)||M.every(O=>at(O.placement)===b?O.overflows[0]>0:!0)))return{data:{index:F,overflows:M},reset:{placement:_}};let B=(j=M.filter(V=>V.overflows[0]<=0).sort((V,O)=>V.overflows[1]-O.overflows[1])[0])==null?void 0:j.placement;if(!B)switch(g){case"bestFit":{var E;const V=(E=M.filter(O=>{if(k){const P=at(O.placement);return P===b||P==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(P=>P>0).reduce((P,U)=>P+U,0)]).sort((O,P)=>O[1]-P[1])[0])==null?void 0:E[0];V&&(B=V);break}case"initialPlacement":B=i;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function xa(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function wa(e){return Kf.some(t=>e[t]>=0)}const Um=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=xa(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:wa(i)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),i=xa(a,n.floating);return{data:{escapedOffsets:i,escaped:wa(i)}}}default:return{}}}}},sl=new Set(["left","top"]);async function Vm(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Xe(n),i=Gt(n),l=at(n)==="y",c=sl.has(a)?-1:1,u=s&&l?-1:1,d=Pt(t,e);let{mainAxis:h,crossAxis:g,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return i&&typeof p=="number"&&(g=i==="end"?p*-1:p),l?{x:g*u,y:h*c}:{x:h*c,y:g*u}}const qm=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 Vm(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}}}}},Gm=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:b,y:w}=v;return{x:b,y:w}}},...c}=Pt(e,t),u={x:n,y:r},d=await s.detectOverflow(t,c),h=at(Xe(o)),g=as(h);let p=u[g],y=u[h];if(a){const v=g==="y"?"top":"left",b=g==="y"?"bottom":"right",w=p+d[v],S=p-d[b];p=Ho(w,p,S)}if(i){const v=h==="y"?"top":"left",b=h==="y"?"bottom":"right",w=y+d[v],S=y-d[b];y=Ho(w,y,S)}const x=l.fn({...t,[g]:p,[h]:y});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[g]:a,[h]:i}}}}}},zm=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},d=at(o),h=as(d);let g=u[h],p=u[d];const y=Pt(i,t),x=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(l){const w=h==="y"?"height":"width",S=s.reference[h]-s.floating[w]+x.mainAxis,C=s.reference[h]+s.reference[w]-x.mainAxis;g<S?g=S:g>C&&(g=C)}if(c){var v,b;const w=h==="y"?"width":"height",S=sl.has(Xe(o)),C=s.reference[d]-s.floating[w]+(S&&((v=a.offset)==null?void 0:v[d])||0)+(S?0:x.crossAxis),k=s.reference[d]+s.reference[w]+(S?0:((b=a.offset)==null?void 0:b[d])||0)-(S?x.crossAxis:0);p<C?p=C:p>k&&(p=k)}return{[h]:g,[d]:p}}}},Km=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),d=Xe(o),h=Gt(o),g=at(o)==="y",{width:p,height:y}=s.floating;let x,v;d==="top"||d==="bottom"?(x=d,v=h===(await(a.isRTL==null?void 0:a.isRTL(i.floating))?"start":"end")?"left":"right"):(v=d,x=h==="end"?"top":"bottom");const b=y-u.top-u.bottom,w=p-u.left-u.right,S=Rn(y-u[x],b),C=Rn(p-u[v],w),k=!t.middlewareData.shift;let T=S,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(T=b),k&&!h){const M=et(u.left,0),R=et(u.right,0),j=et(u.top,0),E=et(u.bottom,0);g?N=p-2*(M!==0||R!==0?M+R:et(u.left,u.right)):T=y-2*(j!==0||E!==0?j+E:et(u.top,u.bottom))}await l({...t,availableWidth:N,availableHeight:T});const I=await a.getDimensions(i.floating);return p!==I.width||y!==I.height?{reset:{rects:!0}}:{}}}};function al(e){const t=ht(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ke(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,i=jr(n)!==s||jr(r)!==a;return i&&(n=s,r=a),{width:n,height:r,$:i}}function ds(e){return Re(e)?e:e.contextElement}function En(e){const t=ds(e);if(!Ke(t))return kt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=al(t);let a=(s?jr(n.width):n.width)/r,i=(s?jr(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const Xm=kt(0);function il(e){const t=it(e);return!Qo()||!t.visualViewport?Xm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Jm(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==it(e)?!1:t}function sn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ds(e);let a=kt(1);t&&(r?Re(r)&&(a=En(r)):a=En(e));const i=Jm(s,n,r)?il(s):kt(0);let l=(o.left+i.x)/a.x,c=(o.top+i.y)/a.y,u=o.width/a.x,d=o.height/a.y;if(s){const h=it(s),g=r&&Re(r)?it(r):r;let p=h,y=qs(p);for(;y&&r&&g!==p;){const x=En(y),v=y.getBoundingClientRect(),b=ht(y),w=v.left+(y.clientLeft+parseFloat(b.paddingLeft))*x.x,S=v.top+(y.clientTop+parseFloat(b.paddingTop))*x.y;l*=x.x,c*=x.y,u*=x.x,d*=x.y,l+=w,c+=S,p=it(y),y=qs(p)}}return Ir({width:u,height:d,x:l,y:c})}function Vr(e,t){const n=Hr(e).scrollLeft;return t?t.left+n:sn(At(e)).left+n}function ll(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Vr(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Qm(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=At(r),i=t?Zo(t.floating):!1;if(r===a||i&&s)return n;let l={scrollLeft:0,scrollTop:0},c=kt(1);const u=kt(0),d=Ke(r);if((d||!d&&!s)&&((or(r)!=="body"||sr(a))&&(l=Hr(r)),d)){const g=sn(r);c=En(r),u.x=g.x+r.clientLeft,u.y=g.y+r.clientTop}const h=a&&!d&&!s?ll(a,l):kt(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function Zm(e){return Array.from(e.getClientRects())}function eh(e){const t=At(e),n=Hr(e),r=e.ownerDocument.body,o=et(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=et(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Vr(e);const i=-n.scrollTop;return ht(r).direction==="rtl"&&(a+=et(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:i}}const va=25;function th(e,t){const n=it(e),r=At(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=Qo();(!u||u&&t==="fixed")&&(i=o.offsetLeft,l=o.offsetTop)}const c=Vr(r);if(c<=0){const u=r.ownerDocument,d=u.body,h=getComputedStyle(d),g=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-g);p<=va&&(s-=p)}else c<=va&&(s+=c);return{width:s,height:a,x:i,y:l}}function nh(e,t){const n=sn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Ke(e)?En(e):kt(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 ka(e,t,n){let r;if(t==="viewport")r=th(e,n);else if(t==="document")r=eh(At(e));else if(Re(t))r=nh(t,n);else{const o=il(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ir(r)}function cl(e,t){const n=On(e);return n===t||!Re(n)||tn(n)?!1:ht(n).position==="fixed"||cl(n,t)}function rh(e,t){const n=t.get(e);if(n)return n;let r=kn(e,[],!1).filter(i=>Re(i)&&or(i)!=="body"),o=null;const s=ht(e).position==="fixed";let a=s?On(e):e;for(;Re(a)&&!tn(a);){const i=ht(a),l=fi(a);!l&&i.position==="fixed"&&(o=null),(s?!l&&!o:!l&&i.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||sr(a)&&!l&&cl(e,a))?r=r.filter(u=>u!==a):o=i,a=On(a)}return t.set(e,r),r}function oh(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?Zo(t)?[]:rh(t,this._c):[].concat(n),r],i=ka(t,a[0],o);let l=i.top,c=i.right,u=i.bottom,d=i.left;for(let h=1;h<a.length;h++){const g=ka(t,a[h],o);l=et(g.top,l),c=Rn(g.right,c),u=Rn(g.bottom,u),d=et(g.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function sh(e){const{width:t,height:n}=al(e);return{width:t,height:n}}function ah(e,t,n){const r=Ke(t),o=At(t),s=n==="fixed",a=sn(e,!0,s,t);let i={scrollLeft:0,scrollTop:0};const l=kt(0);function c(){l.x=Vr(o)}if(r||!r&&!s)if((or(t)!=="body"||sr(o))&&(i=Hr(t)),r){const g=sn(t,!0,s,t);l.x=g.x+t.clientLeft,l.y=g.y+t.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?ll(o,i):kt(0),d=a.left+i.scrollLeft-l.x-u.x,h=a.top+i.scrollTop-l.y-u.y;return{x:d,y:h,width:a.width,height:a.height}}function To(e){return ht(e).position==="static"}function Sa(e,t){if(!Ke(e)||ht(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return At(e)===n&&(n=n.ownerDocument.body),n}function ul(e,t){const n=it(e);if(Zo(e))return n;if(!Ke(e)){let o=On(e);for(;o&&!tn(o);){if(Re(o)&&!To(o))return o;o=On(o)}return n}let r=Sa(e,t);for(;r&&Uu(r)&&To(r);)r=Sa(r,t);return r&&tn(r)&&To(r)&&!fi(r)?n:r||Vu(e)||n}const ih=async function(e){const t=this.getOffsetParent||ul,n=this.getDimensions,r=await n(e.floating);return{reference:ah(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function lh(e){return ht(e).direction==="rtl"}const ch={convertOffsetParentRelativeRectToViewportRelativeRect:Qm,getDocumentElement:At,getClippingRect:oh,getOffsetParent:ul,getElementRects:ih,getClientRects:Zm,getDimensions:sh,getScale:En,isElement:Re,isRTL:lh};function dl(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function uh(e,t){let n=null,r;const o=At(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:d,width:h,height:g}=c;if(i||t(),!h||!g)return;const p=Sr(d),y=Sr(o.clientWidth-(u+h)),x=Sr(o.clientHeight-(d+g)),v=Sr(u),w={rootMargin:-p+"px "+-y+"px "+-x+"px "+-v+"px",threshold:et(0,Rn(1,l))||1};let S=!0;function C(k){const T=k[0].intersectionRatio;if(T!==l){if(!S)return a();T?a(!1,T):r=setTimeout(()=>{a(!1,1e-7)},1e3)}T===1&&!dl(c,e.getBoundingClientRect())&&a(),S=!1}try{n=new IntersectionObserver(C,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,w)}n.observe(e)}return a(!0),s}function Ca(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=ds(e),u=o||s?[...c?kn(c):[],...t?kn(t):[]]:[];u.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const d=c&&i?uh(c,n):null;let h=-1,g=null;a&&(g=new ResizeObserver(v=>{let[b]=v;b&&b.target===c&&g&&t&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=g)==null||w.observe(t)})),n()}),c&&!l&&g.observe(c),t&&g.observe(t));let p,y=l?sn(e):null;l&&x();function x(){const v=sn(e);y&&!dl(y,v)&&n(),y=v,p=requestAnimationFrame(x)}return n(),()=>{var v;u.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),d?.(),(v=g)==null||v.disconnect(),g=null,l&&cancelAnimationFrame(p)}}const dh=qm,fh=Gm,mh=Hm,hh=Km,gh=Um,ph=zm,yh=(e,t,n)=>{const r=new Map,o={platform:ch,...n},s={...o.platform,_c:r};return Ym(e,t,{...o,platform:s})};var bh=typeof document<"u",xh=function(){},Nr=bh?f.useLayoutEffect:xh;function Br(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(!Br(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)&&!Br(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function fl(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ea(e,t){const n=fl(e);return Math.round(t*n)/n}function Oo(e){const t=f.useRef(e);return Nr(()=>{t.current=e}),t}function wh(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,d]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,g]=f.useState(r);Br(h,r)||g(r);const[p,y]=f.useState(null),[x,v]=f.useState(null),b=f.useCallback(O=>{O!==k.current&&(k.current=O,y(O))},[]),w=f.useCallback(O=>{O!==T.current&&(T.current=O,v(O))},[]),S=s||p,C=a||x,k=f.useRef(null),T=f.useRef(null),N=f.useRef(u),I=l!=null,M=Oo(l),R=Oo(o),j=Oo(c),E=f.useCallback(()=>{if(!k.current||!T.current)return;const O={placement:t,strategy:n,middleware:h};R.current&&(O.platform=R.current),yh(k.current,T.current,O).then(P=>{const U={...P,isPositioned:j.current!==!1};F.current&&!Br(N.current,U)&&(N.current=U,Ut.flushSync(()=>{d(U)}))})},[h,t,n,R,j]);Nr(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,d(O=>({...O,isPositioned:!1})))},[c]);const F=f.useRef(!1);Nr(()=>(F.current=!0,()=>{F.current=!1}),[]),Nr(()=>{if(S&&(k.current=S),C&&(T.current=C),S&&C){if(M.current)return M.current(S,C,E);E()}},[S,C,E,M,I]);const _=f.useMemo(()=>({reference:k,floating:T,setReference:b,setFloating:w}),[b,w]),B=f.useMemo(()=>({reference:S,floating:C}),[S,C]),V=f.useMemo(()=>{const O={position:n,left:0,top:0};if(!B.floating)return O;const P=Ea(B.floating,u.x),U=Ea(B.floating,u.y);return i?{...O,transform:"translate("+P+"px, "+U+"px)",...fl(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:P,top:U}},[n,i,B.floating,u.x,u.y]);return f.useMemo(()=>({...u,update:E,refs:_,elements:B,floatingStyles:V}),[u,E,_,B,V])}const vh=(e,t)=>{const n=dh(e);return{name:n.name,fn:n.fn,options:[e,t]}},kh=(e,t)=>{const n=fh(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sh=(e,t)=>({fn:ph(e).fn,options:[e,t]}),Ch=(e,t)=>{const n=mh(e);return{name:n.name,fn:n.fn,options:[e,t]}},Eh=(e,t)=>{const n=hh(e);return{name:n.name,fn:n.fn,options:[e,t]}},Mh=(e,t)=>{const n=gh(e);return{name:n.name,fn:n.fn,options:[e,t]}},Th={intentional:"onClick",sloppy:"onPointerDown"};function Oh(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function ml(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:d=!0,outsidePressEvent:h="sloppy",referencePress:g=!1,referencePressEvent:p="sloppy",ancestorScroll:y=!1,bubbles:x,externalTree:v}=t,b=Wn(v),w=me(typeof d=="function"?d:()=>!1),S=typeof d=="function"?w:d,C=f.useRef(!1),{escapeKey:k,outsidePress:T}=Oh(x),N=f.useRef(null),I=on(),M=on(),R=me(()=>{M.clear(),l.current.insideReactTree=!1}),j=f.useRef(!1),E=f.useRef(""),F=me(D=>{E.current=D.pointerType}),_=me(()=>{const D=E.current,ae=D==="pen"||!D?"mouse":D,q=typeof h=="function"?h():h;return typeof q=="string"?q:q[ae]}),B=me(D=>{if(!r||!c||!u||D.key!=="Escape"||j.current)return;const ae=l.current.floatingContext?.nodeId,q=b?nn(b.nodesRef.current,ae):[];if(!k&&q.length>0){let J=!0;if(q.forEach(ie=>{ie.context?.open&&!ie.context.dataRef.current.__escapeKeyBubbles&&(J=!1)}),!J)return}const ye=qf(D)?D.nativeEvent:D,$=Pe(Qi,ye);n.setOpen(!1,$),!k&&!$.isPropagationAllowed&&D.stopPropagation()}),V=me(D=>{const ae=_();return ae==="intentional"&&D.type!=="click"||ae==="sloppy"&&D.type==="click"}),O=me(()=>{l.current.insideReactTree=!0,M.start(0,R)}),P=me((D,ae=!1)=>{if(V(D)){R();return}if(l.current.insideReactTree){R();return}if(_()==="intentional"&&ae||typeof S=="function"&&!S(D))return;const q=Ze(D),ye=`[${Zn("inert")}]`,$=Ye(n.select("floatingElement")).querySelectorAll(ye),J=n.context.triggerElements;if(q&&(J.hasElement(q)||J.hasMatchingElement(Z=>ve(Z,q))))return;let ie=Re(q)?q:null;for(;ie&&!tn(ie);){const Z=On(ie);if(tn(Z)||!Re(Z))break;ie=Z}if($.length&&Re(q)&&!Uf(q)&&!ve(q,n.select("floatingElement"))&&Array.from($).every(Z=>!ve(ie,Z)))return;if(Ke(q)&&!("touches"in D)){const Z=tn(q),De=ht(q),ke=/auto|scroll/,Ie=Z||ke.test(De.overflowX),pe=Z||ke.test(De.overflowY),Je=Ie&&q.clientWidth>0&&q.scrollWidth>q.clientWidth,Fe=pe&&q.clientHeight>0&&q.scrollHeight>q.clientHeight,Se=De.direction==="rtl",Ue=Fe&&(Se?D.offsetX<=q.offsetWidth-q.clientWidth:D.offsetX>q.clientWidth),He=Je&&D.offsetY>q.clientHeight;if(Ue||He)return}const he=l.current.floatingContext?.nodeId,de=b&&nn(b.nodesRef.current,he).some(Z=>ut(D,Z.context?.elements.floating));if(ut(D,n.select("floatingElement"))||ut(D,n.select("domReferenceElement"))||de)return;const se=b?nn(b.nodesRef.current,he):[];if(se.length>0){let Z=!0;if(se.forEach(De=>{De.context?.open&&!De.context.dataRef.current.__outsidePressBubbles&&(Z=!1)}),!Z)return}n.setOpen(!1,Pe(Ji,D)),R()}),U=me(D=>{_()!=="sloppy"||D.pointerType==="touch"||!n.select("open")||!c||ut(D,n.select("floatingElement"))||ut(D,n.select("domReferenceElement"))||P(D)}),Y=me(D=>{if(_()!=="sloppy"||!n.select("open")||!c||ut(D,n.select("floatingElement"))||ut(D,n.select("domReferenceElement")))return;const ae=D.touches[0];ae&&(N.current={startTime:Date.now(),startX:ae.clientX,startY:ae.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},I.start(1e3,()=>{N.current&&(N.current.dismissOnTouchEnd=!1,N.current.dismissOnMouseDown=!1)}))}),ee=me(D=>{const ae=Ze(D);function q(){Y(D),ae?.removeEventListener(D.type,q)}ae?.addEventListener(D.type,q)}),H=me(D=>{const ae=C.current;if(C.current=!1,I.clear(),D.type==="mousedown"&&N.current&&!N.current.dismissOnMouseDown)return;const q=Ze(D);function ye(){D.type==="pointerdown"?U(D):P(D,ae),q?.removeEventListener(D.type,ye)}q?.addEventListener(D.type,ye)}),L=me(D=>{if(_()!=="sloppy"||!N.current||ut(D,n.select("floatingElement"))||ut(D,n.select("domReferenceElement")))return;const ae=D.touches[0];if(!ae)return;const q=Math.abs(ae.clientX-N.current.startX),ye=Math.abs(ae.clientY-N.current.startY),$=Math.sqrt(q*q+ye*ye);$>5&&(N.current.dismissOnTouchEnd=!0),$>10&&(P(D),I.clear(),N.current=null)}),z=me(D=>{const ae=Ze(D);function q(){L(D),ae?.removeEventListener(D.type,q)}ae?.addEventListener(D.type,q)}),X=me(D=>{_()!=="sloppy"||!N.current||ut(D,n.select("floatingElement"))||ut(D,n.select("domReferenceElement"))||(N.current.dismissOnTouchEnd&&P(D),I.clear(),N.current=null)}),oe=me(D=>{const ae=Ze(D);function q(){X(D),ae?.removeEventListener(D.type,q)}ae?.addEventListener(D.type,q)});f.useEffect(()=>{if(!r||!c)return;l.current.__escapeKeyBubbles=k,l.current.__outsidePressBubbles=T;const D=new Vt;function ae(ie){n.setOpen(!1,Pe(Om,ie))}function q(){D.clear(),j.current=!0}function ye(){D.start(Qo()?5:0,()=>{j.current=!1})}const $=Ye(o);$.addEventListener("pointerdown",F,!0),u&&($.addEventListener("keydown",B),$.addEventListener("compositionstart",q),$.addEventListener("compositionend",ye)),S&&($.addEventListener("click",H,!0),$.addEventListener("pointerdown",H,!0),$.addEventListener("touchstart",ee,!0),$.addEventListener("touchmove",z,!0),$.addEventListener("touchend",oe,!0),$.addEventListener("mousedown",H,!0));let J=[];return y&&(Re(a)&&(J=kn(a)),Re(o)&&(J=J.concat(kn(o))),!Re(s)&&s&&s.contextElement&&(J=J.concat(kn(s.contextElement)))),J=J.filter(ie=>ie!==$.defaultView?.visualViewport),J.forEach(ie=>{ie.addEventListener("scroll",ae,{passive:!0})}),()=>{$.removeEventListener("pointerdown",F,!0),u&&($.removeEventListener("keydown",B),$.removeEventListener("compositionstart",q),$.removeEventListener("compositionend",ye)),S&&($.removeEventListener("click",H,!0),$.removeEventListener("pointerdown",H,!0),$.removeEventListener("touchstart",ee,!0),$.removeEventListener("touchmove",z,!0),$.removeEventListener("touchend",oe,!0),$.removeEventListener("mousedown",H,!0)),J.forEach(ie=>{ie.removeEventListener("scroll",ae)}),D.clear(),C.current=!1}},[l,o,s,a,u,S,r,i,y,c,k,T,B,P,H,U,ee,z,oe,F,n]),f.useEffect(R,[S,R]);const be=f.useMemo(()=>({onKeyDown:B,...g&&{[Th[p]]:D=>{n.setOpen(!1,Pe(Ht,D.nativeEvent))},...p!=="intentional"&&{onClick(D){n.setOpen(!1,Pe(Ht,D.nativeEvent))}}}}),[B,n,g,p]),Oe=me(D=>{const ae=Ze(D.nativeEvent);!ve(n.select("floatingElement"),ae)||D.button!==0||(C.current=!0)}),xe=me(D=>{!r||!c||D.button!==0||(C.current=!0)}),We=f.useMemo(()=>({onKeyDown:B,onPointerDown:Oe,onMouseDown:Oe,onMouseUp:Oe,onClickCapture:O,onMouseDownCapture(D){O(),xe(D)},onPointerDownCapture(D){O(),xe(D)},onMouseUpCapture:O,onTouchEndCapture:O,onTouchMoveCapture:O}),[B,Oe,O,xe]);return f.useMemo(()=>c?{reference:be,floating:We,trigger:be}:{},[c,be,We])}const Nh={open:ge(e=>e.open),domReferenceElement:ge(e=>e.domReferenceElement),referenceElement:ge(e=>e.positionReference??e.referenceElement),floatingElement:ge(e=>e.floatingElement),floatingId:ge(e=>e.floatingId)};class fs extends rs{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:zi(),nested:n,noEmit:r,triggerElements:s},Nh)}setOpen=(t,n)=>{if((!t||!this.state.open||Ii(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 Rh(e,t=!1,n=!1){const[r,o]=f.useState(e&&t?"idle":void 0),[s,a]=f.useState(e);return e&&!s&&(a(!0),o("starting")),!e&&s&&r!=="ending"&&!n&&o("ending"),!e&&!s&&r==="ending"&&o(void 0),Ee(()=>{if(!e&&s&&r!=="ending"&&n){const i=yt.request(()=>{o("ending")});return()=>{yt.cancel(i)}}},[e,s,r,n]),Ee(()=>{if(!e||t)return;const i=yt.request(()=>{o(void 0)});return()=>{yt.cancel(i)}},[t,e]),Ee(()=>{if(!e||!t)return;e&&s&&r!=="idle"&&o("starting");const i=yt.request(()=>{o("idle")});return()=>{yt.cancel(i)}},[t,e,s,o,r]),f.useMemo(()=>({mounted:s,setMounted:a,transitionStatus:r}),[s,r])}let er=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const Dh={[er.startingStyle]:""},_h={[er.endingStyle]:""},qr={transitionStatus(e){return e==="starting"?Dh:e==="ending"?_h:null}};function hl(e,t=!1,n=!0){const r=ss();return me((o,s=null)=>{r.cancel();function a(){Ut.flushSync(o)}const i=Rt(e);if(i==null)return;const l=i;if(typeof l.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)o();else{let c=function(){const d=er.startingStyle;if(!l.hasAttribute(d)){r.request(u);return}const h=new MutationObserver(()=>{l.hasAttribute(d)||(h.disconnect(),u())});h.observe(l,{attributes:!0,attributeFilter:[d]}),s?.addEventListener("abort",()=>h.disconnect(),{once:!0})},u=function(){Promise.all(l.getAnimations().map(d=>d.finished)).then(()=>{s?.aborted||a()}).catch(()=>{const d=l.getAnimations();if(n){if(s?.aborted)return;a()}else d.length>0&&d.some(h=>h.pending||h.playState!=="finished")&&u()})};if(t){c();return}r.request(u)}})}function ms(e){const{enabled:t=!0,open:n,ref:r,onComplete:o}=e,s=me(o),a=hl(r,n,!1);f.useEffect(()=>{if(!t)return;const i=new AbortController;return a(s,i.signal),()=>{i.abort()}},[t,n,s,a])}function Ph(e,t){const n=f.useRef(null),r=f.useRef(null);return f.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 jh(e,t,n,r){const o=n.useState("isMountedByTrigger",e),s=Ph(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 Ee(()=>{o&&n.update({activeTriggerElement:t.current,...r})},[o,n,t,...Object.values(r)]),{registerTrigger:a,isMountedByThisTrigger:o}}function gl(e){const t=e.useState("open");Ee(()=>{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 pl(e,t,n){const{mounted:r,setMounted:o,transitionStatus:s}=Rh(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 ms({enabled:!i,open:e,ref:t.context.popupRef,onComplete(){e||a()}}),{forceUnmount:a,transitionStatus:s}}class Gr{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 Ah(){return new fs({open:!1,floatingElement:null,referenceElement:null,triggerElements:new Gr,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function yl(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:Ah(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:Yt,inactiveTriggerProps:Yt,popupProps:Yt}}const bl={open:ge(e=>e.open),mounted:ge(e=>e.mounted),transitionStatus:ge(e=>e.transitionStatus),floatingRootContext:ge(e=>e.floatingRootContext),preventUnmountingOnClose:ge(e=>e.preventUnmountingOnClose),payload:ge(e=>e.payload),activeTriggerId:ge(e=>e.activeTriggerId),activeTriggerElement:ge(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:ge((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:ge((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:ge((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:ge((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:ge(e=>e.popupProps),popupElement:ge(e=>e.popupElement),positionerElement:ge(e=>e.positionerElement)};function Ih(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,o=Ln(),s=ln()!=null,a=qt(()=>new fs({open:t,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:r.triggers??new Gr,floatingId:o,nested:s,noEmit:e.noEmit||!1})).current;return Ee(()=>{const i={open:t,floatingId:o};r.reference!==void 0&&(i.referenceElement=r.reference,i.domReferenceElement=Re(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 Fh(e={}){const{nodeId:t,externalTree:n}=e,r=Ih(e),o=e.rootContext||r,s={reference:o.useState("referenceElement"),floating:o.useState("floatingElement"),domReference:o.useState("domReferenceElement")},[a,i]=f.useState(null),l=f.useRef(null),c=Wn(n);Ee(()=>{s.domReference&&(l.current=s.domReference)},[s.domReference]);const u=wh({...e,elements:{...s,...a&&{reference:a}}}),d=f.useCallback(T=>{const N=Re(T)?{getBoundingClientRect:()=>T.getBoundingClientRect(),getClientRects:()=>T.getClientRects(),contextElement:T}:T;i(N),u.refs.setReference(N)},[u.refs]),[h,g]=f.useState(null),[p,y]=f.useState(null);o.useSyncedValue("referenceElement",h),o.useSyncedValue("domReferenceElement",Re(h)?h:null),o.useSyncedValue("floatingElement",p);const x=f.useCallback(T=>{(Re(T)||T===null)&&(l.current=T,g(T)),(Re(u.refs.reference.current)||u.refs.reference.current===null||T!==null&&!Re(T))&&u.refs.setReference(T)},[u.refs,g]),v=f.useCallback(T=>{y(T),u.refs.setFloating(T)},[u.refs]),b=f.useMemo(()=>({...u.refs,setReference:x,setFloating:v,setPositionReference:d,domReference:l}),[u.refs,x,v,d]),w=f.useMemo(()=>({...u.elements,domReference:s.domReference}),[u.elements,s.domReference]),S=o.useState("open"),C=o.useState("floatingId"),k=f.useMemo(()=>({...u,dataRef:o.context.dataRef,open:S,onOpenChange:o.setOpen,events:o.context.events,floatingId:C,refs:b,elements:w,nodeId:t,rootStore:o}),[u,b,w,t,o,S,C]);return Ee(()=>{o.context.dataRef.current.floatingContext=k;const T=c?.nodesRef.current.find(N=>N.id===t);T&&(T.context=k)}),f.useMemo(()=>({...u,context:k,refs:b,elements:w,rootStore:o}),[u,b,w,k,o])}function xl(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:r=!1,onOpenChange:o}=e,s=Ln(),a=ln()!=null,i=t.useState("open"),l=t.useState("activeTriggerElement"),c=t.useState(r?"popupElement":"positionerElement"),u=t.context.triggerElements,d=qt(()=>new fs({open:i,referenceElement:l,floatingElement:c,triggerElements:u,onOpenChange:o,floatingId:s,nested:a,noEmit:n})).current;return Ee(()=>{const h={open:i,floatingId:s,referenceElement:l,floatingElement:c};Re(l)&&(h.domReferenceElement=l),d.state.positionReference===d.state.referenceElement&&(h.positionReference=l),d.update(h)},[i,s,l,c,d]),d.context.onOpenChange=o,d.context.nested=a,d.context.noEmit=n,d}const Go=Zn("safe-polygon"),Lh=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${ji}`;function Wh(e){return e?!!e.closest(Lh):!1}function wl(e){const t=f.useRef(void 0),n=f.useRef(!1),r=f.useRef(void 0),o=f.useRef(!0),s=f.useRef(!1),a=f.useRef(()=>{}),i=f.useRef(!1),l=on(),c=on(),u=f.useRef(void 0);return f.useMemo(()=>{const d=e.context.dataRef.current;return d.hoverInteractionState||(d.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:r,blockMouseMoveRef:o,performedPointerEventsMutationRef:s,unbindMouseMoveRef:a,restTimeoutPendingRef:i,openChangeTimeout:l,restTimeout:c,handleCloseOptionsRef:u}),d.hoverInteractionState},[e,t,n,r,o,s,a,i,l,c,u])}const $h=new Set(["click","mousedown"]);function Bh(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:d,handlerRef:h,performedPointerEventsMutationRef:g,unbindMouseMoveRef:p,restTimeoutPendingRef:y,openChangeTimeout:x,handleCloseOptionsRef:v}=wl(n),b=Wn(c),w=ln(),S=me(()=>d.current?!0:a.current.openEvent?$h.has(a.current.openEvent.type):!1),C=me(()=>{const M=a.current.openEvent?.type;return M?.includes("mouse")&&M!=="mousedown"}),k=f.useCallback((M,R=!0)=>{const j=Yh(l,u.current);j&&!h.current?x.start(j,()=>n.setOpen(!1,Pe(tt,M))):R&&(x.clear(),n.setOpen(!1,Pe(tt,M)))},[l,h,n,u,x]),T=me(()=>{p.current(),h.current=void 0}),N=me(()=>{if(g.current){const M=Ye(o).body;M.style.pointerEvents="",M.removeAttribute(Go),g.current=!1}}),I=me(M=>{const R=Ze(M);if(!Wh(R)){d.current=!1;return}d.current=!0});Ee(()=>{r||(u.current=void 0,y.current=!1,d.current=!1,T(),N())},[r,u,y,d,T,N]),f.useEffect(()=>()=>{T()},[T]),f.useEffect(()=>N,[N]),Ee(()=>{if(i&&r&&v.current?.blockPointerEvents&&C()&&Re(s)&&o){g.current=!0;const M=Ye(o).body;M.setAttribute(Go,"");const R=s,j=o,E=b?.nodesRef.current.find(F=>F.id===w)?.context?.elements.floating;return E&&(E.style.pointerEvents=""),M.style.pointerEvents="none",R.style.pointerEvents="auto",j.style.pointerEvents="auto",()=>{M.style.pointerEvents="",R.style.pointerEvents="",j.style.pointerEvents=""}}},[i,r,s,o,v,C,b,w,g]),f.useEffect(()=>{if(!i)return;function M(F){if(S()||!a.current.floatingContext||!n.select("open"))return;const _=n.context.triggerElements;F.relatedTarget&&_.hasElement(F.relatedTarget)||(N(),T(),S()||k(F))}function R(F){x.clear(),N(),h.current?.(F),T()}function j(F){S()||k(F,!1)}const E=o;return E&&(E.addEventListener("mouseleave",M),E.addEventListener("mouseenter",R),E.addEventListener("mouseleave",j),E.addEventListener("pointerdown",I,!0)),()=>{E&&(E.removeEventListener("mouseleave",M),E.removeEventListener("mouseenter",R),E.removeEventListener("mouseleave",j),E.removeEventListener("pointerdown",I,!0))}})}function Yh(e,t){return t&&!Nn(t)?0:typeof e=="function"?e():e}function No(e){return typeof e=="function"?e():e}const Hh={current:null};function Uh(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:d=Hh,externalTree:h,isActiveTrigger:g=!0}=t,p=Wn(h),{pointerTypeRef:y,interactedInsideRef:x,handlerRef:v,blockMouseMoveRef:b,performedPointerEventsMutationRef:w,unbindMouseMoveRef:S,restTimeoutPendingRef:C,openChangeTimeout:k,restTimeout:T,handleCloseOptionsRef:N}=wl(n),I=bt(i),M=bt(a),R=bt(c);g&&(N.current=I.current?.__options);const j=me(()=>x.current?!0:r.current.openEvent?["click","mousedown"].includes(r.current.openEvent.type):!1),E=f.useCallback((V,O=!0)=>{const P=So(M.current,"close",y.current);P&&!v.current?k.start(P,()=>n.setOpen(!1,Pe(tt,V))):O&&(k.clear(),n.setOpen(!1,Pe(tt,V)))},[M,v,n,y,k]),F=me(()=>{S.current(),v.current=void 0}),_=me(()=>{if(w.current){const V=Ye(n.select("domReferenceElement")).body;V.style.pointerEvents="",V.removeAttribute(Go),w.current=!1}});f.useEffect(()=>{if(!s)return;function V(O){O.open||(k.clear(),T.clear(),b.current=!0,C.current=!1)}return o.on("openchange",V),()=>{o.off("openchange",V)}},[s,o,k,T,b,C]);const B=me(V=>{if(j()||!r.current.floatingContext)return;const O=n.context.triggerElements;if(V.relatedTarget&&O.hasElement(V.relatedTarget))return;const P=d.current;I.current?.({...r.current.floatingContext,tree:p,x:V.clientX,y:V.clientY,onClose(){_(),F(),!j()&&P===n.select("domReferenceElement")&&E(V)}})(V)});return f.useEffect(()=>{if(!s)return;const V=d.current??(g?n.select("domReferenceElement"):null);if(!Re(V))return;function O(Y){if(k.clear(),b.current=!1,l&&!Nn(y.current)||No(R.current)>0&&!So(M.current,"open"))return;const ee=So(M.current,"open",y.current),H=n.select("domReferenceElement"),L=n.context.triggerElements,z=(L.hasElement(Y.target)||L.hasMatchingElement(Oe=>ve(Oe,Y.target)))&&(!H||!ve(H,Y.target)),X=Y.currentTarget??null,oe=n.select("open"),be=!oe||z;z&&oe?n.setOpen(!0,Pe(tt,Y,X)):ee?k.start(ee,()=>{be&&n.setOpen(!0,Pe(tt,Y,X))}):be&&n.setOpen(!0,Pe(tt,Y,X))}function P(Y){if(j()){_();return}S.current();const ee=n.select("domReferenceElement"),H=Ye(ee);T.clear(),C.current=!1;const L=n.context.triggerElements;if(Y.relatedTarget&&L.hasElement(Y.relatedTarget))return;if(I.current&&r.current.floatingContext){n.select("open")||k.clear();const X=d.current;v.current=I.current({...r.current.floatingContext,tree:p,x:Y.clientX,y:Y.clientY,onClose(){_(),F(),!j()&&X===n.select("domReferenceElement")&&E(Y,!0)}});const oe=v.current;oe(Y),H.addEventListener("mousemove",oe),S.current=()=>{H.removeEventListener("mousemove",oe)};return}(y.current!=="touch"||!ve(n.select("floatingElement"),Y.relatedTarget))&&E(Y)}function U(Y){B(Y)}return n.select("open")&&V.addEventListener("mouseleave",U),u&&V.addEventListener("mousemove",O,{once:!0}),V.addEventListener("mouseenter",O),V.addEventListener("mouseleave",P),()=>{V.removeEventListener("mouseleave",U),u&&V.removeEventListener("mousemove",O),V.removeEventListener("mouseenter",O),V.removeEventListener("mouseleave",P)}},[F,_,b,r,M,E,n,s,I,B,g,j,l,u,y,R,T,C,k,d,p,S,v]),f.useMemo(()=>{function V(O){y.current=O.pointerType}return{onPointerDown:V,onPointerEnter:V,onMouseMove(O){const{nativeEvent:P}=O,U=O.currentTarget,Y=n.select("domReferenceElement"),ee=n.context.triggerElements,H=n.select("open"),L=(ee.hasElement(O.target)||ee.hasMatchingElement(X=>ve(X,O.target)))&&(!Y||!ve(Y,O.target));if(l&&!Nn(y.current)||H&&!L||No(R.current)===0||!L&&C.current&&O.movementX**2+O.movementY**2<2)return;T.clear();function z(){if(C.current=!1,j())return;const X=n.select("open");!b.current&&(!X||L)&&n.setOpen(!0,Pe(tt,P,U))}y.current==="touch"?Ut.flushSync(()=>{z()}):L&&H?z():(C.current=!0,T.start(No(R.current),z))}}},[b,j,l,n,y,R,T,C])}function hs(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=f.useCallback(c=>Mr(c,e,"reference"),t),a=f.useCallback(c=>Mr(c,e,"floating"),n),i=f.useCallback(c=>Mr(c,e,"item"),r),l=f.useCallback(c=>Mr(c,e,"trigger"),o);return f.useMemo(()=>({getReferenceProps:s,getFloatingProps:a,getItemProps:i,getTriggerProps:l}),[s,a,i,l])}function Mr(e,t,n){const r=new Map,o=n==="item",s={};n==="floating"&&(s.tabIndex=-1,s[Bo]="");for(const a in e)o&&e&&(a===_i||a===Pi)||(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&&Ma(s,i,o,r)}return Ma(s,e,o,r),s}function Ma(e,t,n,r){for(const o in t){const s=t[o];n&&(o===_i||o===Pi)||(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 Vh=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function vl(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=Ln(),u=s?.id||c,d=f.useMemo(()=>Yo(a)?.id||o,[a,o]),h=Vh.get(l)??l,p=ln()!=null,y=f.useMemo(()=>h==="tooltip"||l==="label"?Yt:{"aria-haspopup":h==="alertdialog"?"dialog":h,"aria-expanded":"false",...h==="listbox"&&{role:"combobox"},...h==="menu"&&p&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[h,p,l]),x=f.useMemo(()=>h==="tooltip"||l==="label"?{[`aria-${l==="label"?"labelledby":"describedby"}`]:r?d:void 0}:{...y,"aria-expanded":r?"true":"false","aria-controls":r?d:void 0,...h==="menu"&&{id:u}},[h,d,r,u,l,y]),v=f.useMemo(()=>{const w={id:d,...h&&{role:h}};return h==="tooltip"||l==="label"?w:{...w,...h==="menu"&&{"aria-labelledby":u}}},[h,d,u,l]),b=f.useCallback(({active:w,selected:S})=>{const C={role:"option",...w&&{id:`${d}-fui-option`}};switch(l){case"select":case"combobox":return{...C,"aria-selected":S}}return{}},[d,l]);return f.useMemo(()=>i?{reference:x,floating:v,item:b,trigger:y}:{},[i,x,v,y,b])}function Ta(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,d]=t[i]||[0,0];c>=r!=d>=r&&n<=(u-l)*(r-c)/(d-c)+l&&(o=!o)}return o}function qh(e,t){return e[0]>=t.x&&e[0]<=t.x+t.width&&e[1]>=t.y&&e[1]<=t.y+t.height}function Gh(e={}){const{buffer:t=.5,blockPointerEvents:n=!1,requireIntent:r=!0}=e,o=new Vt;let s=!1,a=null,i=null,l=typeof performance<"u"?performance.now():0;function c(d,h){const g=performance.now(),p=g-l;if(a===null||i===null||p===0)return a=d,i=h,l=g,null;const y=d-a,x=h-i,b=Math.sqrt(y*y+x*x)/p;return a=d,i=h,l=g,b}const u=({x:d,y:h,placement:g,elements:p,onClose:y,nodeId:x,tree:v})=>function(w){function S(){o.clear(),y()}if(o.clear(),!p.domReference||!p.floating||g==null||d==null||h==null)return;const{clientX:C,clientY:k}=w,T=[C,k],N=Ze(w),I=w.type==="mouseleave",M=ve(p.floating,N),R=ve(p.domReference,N),j=p.domReference.getBoundingClientRect(),E=p.floating.getBoundingClientRect(),F=g.split("-")[0],_=d>E.right-E.width/2,B=h>E.bottom-E.height/2,V=qh(T,j),O=E.width>j.width,P=E.height>j.height,U=(O?j:E).left,Y=(O?j:E).right,ee=(P?j:E).top,H=(P?j:E).bottom;if(M&&(s=!0,!I))return;if(R&&(s=!1),R&&!I){s=!0;return}if(I&&Re(w.relatedTarget)&&ve(p.floating,w.relatedTarget)||v&&nn(v.nodesRef.current,x).some(({context:X})=>X?.open))return;if(F==="top"&&h>=j.bottom-1||F==="bottom"&&h<=j.top+1||F==="left"&&d>=j.right-1||F==="right"&&d<=j.left+1)return S();let L=[];switch(F){case"top":L=[[U,j.top+1],[U,E.bottom-1],[Y,E.bottom-1],[Y,j.top+1]];break;case"bottom":L=[[U,E.top+1],[U,j.bottom-1],[Y,j.bottom-1],[Y,E.top+1]];break;case"left":L=[[E.right-1,H],[E.right-1,ee],[j.left+1,ee],[j.left+1,H]];break;case"right":L=[[j.right-1,H],[j.right-1,ee],[E.left+1,ee],[E.left+1,H]];break}function z([X,oe]){switch(F){case"top":{const be=[O?X+t/2:_?X+t*4:X-t*4,oe+t+1],Oe=[O?X-t/2:_?X+t*4:X-t*4,oe+t+1],xe=[[E.left,_||O?E.bottom-t:E.top],[E.right,_?O?E.bottom-t:E.top:E.bottom-t]];return[be,Oe,...xe]}case"bottom":{const be=[O?X+t/2:_?X+t*4:X-t*4,oe-t],Oe=[O?X-t/2:_?X+t*4:X-t*4,oe-t],xe=[[E.left,_||O?E.top+t:E.bottom],[E.right,_?O?E.top+t:E.bottom:E.top+t]];return[be,Oe,...xe]}case"left":{const be=[X+t+1,P?oe+t/2:B?oe+t*4:oe-t*4],Oe=[X+t+1,P?oe-t/2:B?oe+t*4:oe-t*4];return[...[[B||P?E.right-t:E.left,E.top],[B?P?E.right-t:E.left:E.right-t,E.bottom]],be,Oe]}case"right":{const be=[X-t,P?oe+t/2:B?oe+t*4:oe-t*4],Oe=[X-t,P?oe-t/2:B?oe+t*4:oe-t*4],xe=[[B||P?E.left+t:E.right,E.top],[B?P?E.left+t:E.right:E.left+t,E.bottom]];return[be,Oe,...xe]}default:return[]}}if(!Ta([C,k],L)){if(s&&!V)return S();if(!I&&r){const X=c(w.clientX,w.clientY);if(X!==null&&X<.1)return S()}Ta([C,k],z([d,h]))?!s&&r&&o.start(40,S):S()}};return u.__options={blockPointerEvents:n},u}function kl(e){return Ln(e,"base-ui")}function zh(e){const t=f.useRef(""),n=f.useCallback(o=>{o.defaultPrevented||(t.current=o.pointerType,e(o,o.pointerType))},[e]);return{onClick:f.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 Sl(e){const[t,n]=f.useState(null),r=me((i,l)=>{e||n(l||(Di?"touch":""))}),o=f.useCallback(()=>{n(null)},[]),{onClick:s,onPointerDown:a}=zh(r);return f.useMemo(()=>({openMethod:t,reset:o,triggerProps:{onClick:s,onPointerDown:a}}),[t,o,s,a])}let ft=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=er.startingStyle]="startingStyle",e[e.endingStyle=er.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),zo=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const Kh={[zo.popupOpen]:""},Xh={[zo.popupOpen]:"",[zo.pressed]:""},Jh={[ft.open]:""},Qh={[ft.closed]:""},Zh={[ft.anchorHidden]:""},eg={open(e){return e?Kh:null}},tg={open(e){return e?Xh:null}},ir={open(e){return e?Jh:Qh},anchorHidden(e){return e?Zh:null}};function Cl(e){return ui(19)?e:e?"true":void 0}let Oa={},Na={},Ra="";function ng(e){if(typeof document>"u")return!1;const t=cn(e);return it(t).innerWidth-t.documentElement.clientWidth>0}function rg(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const r=cn(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 og(e){const t=cn(e),n=t.documentElement,r=t.body,o=sr(n)?n:r,s=o.style.overflow;return o.style.overflow="hidden",()=>{o.style.overflow=s}}function sg(e){const t=cn(e),n=t.documentElement,r=t.body,o=it(n);let s=0,a=0,i=!1;const l=yt.create();if(Lf&&(o.visualViewport?.scale??1)!==1)return()=>{};function c(){const h=o.getComputedStyle(n),g=o.getComputedStyle(r),x=(h.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";s=n.scrollTop,a=n.scrollLeft,Oa={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Ra=n.style.scrollBehavior,Na={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,b=n.scrollWidth>n.clientWidth,w=h.overflowY==="scroll"||g.overflowY==="scroll",S=h.overflowX==="scroll"||g.overflowX==="scroll",C=Math.max(0,o.innerWidth-r.clientWidth),k=Math.max(0,o.innerHeight-r.clientHeight),T=parseFloat(g.marginTop)+parseFloat(g.marginBottom),N=parseFloat(g.marginLeft)+parseFloat(g.marginRight),I=sr(n)?n:r;if(i=rg(e),i){n.style.scrollbarGutter=x,I.style.overflowY="hidden",I.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:x,overflowY:"hidden",overflowX:"hidden"}),(v||w)&&(n.style.overflowY="scroll"),(b||S)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:T||k?`calc(100dvh - ${T+k}px)`:"100dvh",width:N||C?`calc(100vw - ${N+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,Oa),Object.assign(r.style,Na),i||(n.scrollTop=s,n.scrollLeft=a,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=Ra)}function d(){u(),l.request(c)}return c(),o.addEventListener("resize",d),()=>{l.cancel(),u(),typeof o.removeEventListener=="function"&&o.removeEventListener("resize",d)}}class ag{lockCount=0;restore=null;timeoutLock=Vt.create();timeoutUnlock=Vt.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=cn(t).documentElement,o=it(r).getComputedStyle(r).overflowY;if(o==="hidden"||o==="clip"){this.restore=di;return}const s=Di||!ng(t);this.restore=s?og(t):sg(t)}}const ig=new ag;function El(e=!0,t=null){Ee(()=>{if(e)return ig.acquire(t)},[e,t])}const lg=f.createContext(void 0);function cg(){return f.useContext(lg)?.direction??"ltr"}const ug=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:d="real"}=Pt(e,t)||{};if(c==null)return{};const h=Fi(u),g={x:n,y:r},p=ls(o),y=is(p),x=await a.getDimensions(c),v=p==="y",b=v?"top":"left",w=v?"bottom":"right",S=v?"clientHeight":"clientWidth",C=s.reference[y]+s.reference[p]-g[p]-s.floating[y],k=g[p]-s.reference[p],T=d==="real"?await a.getOffsetParent?.(c):i.floating;let N=i.floating[S]||s.floating[y];(!N||!await a.isElement?.(T))&&(N=i.floating[S]||s.floating[y]);const I=C/2-k/2,M=N/2-x[y]/2-1,R=Math.min(h[b],M),j=Math.min(h[w],M),E=R,F=N-x[y]-j,_=N/2-x[y]/2+I,B=Ho(E,_,F),V=!l.arrow&&Gt(o)!=null&&_!==B&&s.reference[y]/2-(_<E?R:j)-x[y]/2<0,O=V?_<E?_-E:_-F:0;return{[p]:g[p]+O,data:{[p]:B,centerOffset:_-B-O,...V&&{alignmentOffset:O}},reset:V}}}),dg=(e,t)=>({...ug(e),options:[e,t]}),fg={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 Mh().fn(e)).data?.referenceHidden||s}}}},Rr={sideX:"left",sideY:"top"},mg={name:"adaptiveOrigin",async fn(e){const{x:t,y:n,rects:{floating:r},elements:{floating:o},platform:s,strategy:a,placement:i}=e,l=it(o),c=l.getComputedStyle(o);if(!(c.transitionDuration!=="0s"&&c.transitionDuration!==""))return{x:t,y:n,data:Rr};const d=await s.getOffsetParent?.(o);let h={width:0,height:0};if(a==="fixed"&&l?.visualViewport)h={width:l.visualViewport.width,height:l.visualViewport.height};else if(d===l){const b=cn(o);h={width:b.documentElement.clientWidth,height:b.documentElement.clientHeight}}else await s.isElement?.(d)&&(h=await s.getDimensions(d));const g=Xe(i);let p=t,y=n;g==="left"&&(p=h.width-(t+r.width)),g==="top"&&(y=h.height-(n+r.height));const x=g==="left"?"right":Rr.sideX,v=g==="top"?"bottom":Rr.sideY;return{x:p,y,data:{sideX:x,sideY:v}}}};function Ml(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 Da(e,t,n){const{rects:r,placement:o}=e;return{side:Ml(t,Xe(o),n),align:Gt(o)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function hg(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:d=!1,keepMounted:h=!1,floatingRootContext:g,mounted:p,collisionAvoidance:y,shiftCrossAxis:x=!1,nodeId:v,adaptiveOrigin:b,lazyFlip:w=!1,externalTree:S}=e,[C,k]=f.useState(null);!p&&C!==null&&k(null);const T=y.side||"flip",N=y.align||"flip",I=y.fallbackAxisSide||"end",M=typeof t=="function"?t:void 0,R=me(M),j=M?R:t,E=bt(t),_=cg()==="rtl",B=C||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":_?"left":"right","inline-start":_?"right":"left"}[r],V=s==="center"?B:`${B}-${s}`;let O=l;const P=1,U=r==="bottom"?P:0,Y=r==="top"?P:0,ee=r==="right"?P:0,H=r==="left"?P:0;typeof O=="number"?O={top:O+U,right:O+H,bottom:O+Y,left:O+ee}:O&&(O={top:(O.top||0)+U,right:(O.right||0)+H,bottom:(O.bottom||0)+Y,left:(O.left||0)+ee});const L={boundary:i==="clipping-ancestors"?"clippingAncestors":i,padding:O},z=f.useRef(null),X=bt(o),oe=bt(a),xe=[vh(Ce=>{const Te=Da(Ce,r,_),K=typeof X.current=="function"?X.current(Te):X.current,le=typeof oe.current=="function"?oe.current(Te):oe.current;return{mainAxis:K,crossAxis:le,alignmentAxis:le}},[typeof o!="function"?o:0,typeof a!="function"?a:0,_,r])],We=N==="none"&&T!=="shift",D=!We&&(c||x||T==="shift"),ae=T==="none"?null:Ch({...L,padding:{top:O.top+P,right:O.right+P,bottom:O.bottom+P,left:O.left+P},mainAxis:!x&&T==="flip",crossAxis:N==="flip"?"alignment":!1,fallbackAxisSideDirection:I}),q=We?null:kh(Ce=>{const Te=cn(Ce.elements.floating).documentElement;return{...L,rootBoundary:x?{x:0,y:0,width:Te.clientWidth,height:Te.clientHeight}:void 0,mainAxis:N!=="none",crossAxis:D,limiter:c||x?void 0:Sh(K=>{if(!z.current)return{};const{width:le,height:Q}=z.current.getBoundingClientRect(),fe=at(Xe(K.placement)),je=fe==="y"?le:Q,ue=fe==="y"?O.left+O.right:O.top+O.bottom;return{offset:je/2+ue/2}})}},[L,c,x,O,N]);T==="shift"||N==="shift"||s==="center"?xe.push(q,ae):xe.push(ae,q),xe.push(Eh({...L,apply({elements:{floating:Ce},rects:{reference:Te},availableWidth:K,availableHeight:le}){Object.entries({"--available-width":`${K}px`,"--available-height":`${le}px`,"--anchor-width":`${Te.width}px`,"--anchor-height":`${Te.height}px`}).forEach(([Q,fe])=>{Ce.style.setProperty(Q,fe)})}}),dg(()=>({element:z.current||document.createElement("div"),padding:u,offsetParent:"floating"}),[u]),{name:"transformOrigin",fn(Ce){const{elements:Te,middlewareData:K,placement:le,rects:Q,y:fe}=Ce,je=Xe(le),ue=at(je),gt=z.current,zt=K.arrow?.x||0,Ct=K.arrow?.y||0,Ve=gt?.clientWidth||0,Et=gt?.clientHeight||0,dn=zt+Ve/2,Bn=Ct+Et/2,Jr=Math.abs(K.shift?.y||0),Qr=Q.reference.height/2,Kt=typeof o=="function"?o(Da(Ce,r,_)):o,fr=Jr>Kt,mr={top:`${dn}px calc(100% + ${Kt}px)`,bottom:`${dn}px ${-Kt}px`,left:`calc(100% + ${Kt}px) ${Bn}px`,right:`${-Kt}px ${Bn}px`}[je],fn=`${dn}px ${Q.reference.y+Qr-fe}px`;return Te.floating.style.setProperty("--transform-origin",D&&ue==="y"&&fr?fn:mr),{}}},fg,b),Ee(()=>{!p&&g&&g.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[p,g]);const ye=f.useMemo(()=>({elementResize:!d&&typeof ResizeObserver<"u",layoutShift:!d&&typeof IntersectionObserver<"u"}),[d]),{refs:$,elements:J,x:ie,y:he,middlewareData:de,update:se,placement:Z,context:De,isPositioned:ke,floatingStyles:Ie}=Fh({rootContext:g,placement:V,middleware:xe,strategy:n,whileElementsMounted:h?void 0:(...Ce)=>Ca(...Ce,ye),nodeId:v,externalTree:S}),{sideX:pe,sideY:Je}=de.adaptiveOrigin||Rr,Fe=ke?n:"fixed",Se=f.useMemo(()=>b?{position:Fe,[pe]:ie,[Je]:he}:{position:Fe,...Ie},[b,Fe,pe,ie,Je,he,Ie]),Ue=f.useRef(null);Ee(()=>{if(!p)return;const Ce=E.current,Te=typeof Ce=="function"?Ce():Ce,le=(_a(Te)?Te.current:Te)||null||null;le!==Ue.current&&($.setPositionReference(le),Ue.current=le)},[p,$,j,E]),f.useEffect(()=>{if(!p)return;const Ce=E.current;typeof Ce!="function"&&_a(Ce)&&Ce.current!==Ue.current&&($.setPositionReference(Ce.current),Ue.current=Ce.current)},[p,$,j,E]),f.useEffect(()=>{if(h&&p&&J.domReference&&J.floating)return Ca(J.domReference,J.floating,se,ye)},[h,p,J,se,ye]);const He=Xe(Z),It=Ml(r,He,_),Ft=Gt(Z)||"center",Lt=!!de.hide?.referenceHidden;Ee(()=>{w&&p&&ke&&k(He)},[w,p,ke,He]);const Wt=f.useMemo(()=>({position:"absolute",top:de.arrow?.y,left:de.arrow?.x}),[de.arrow]),ot=de.arrow?.centerOffset!==0;return f.useMemo(()=>({positionerStyles:Se,arrowStyles:Wt,arrowRef:z,arrowUncentered:ot,side:It,align:Ft,physicalSide:He,anchorHidden:Lt,refs:$,context:De,isPositioned:ke,update:se}),[Se,Wt,z,ot,It,Ft,He,Lt,$,De,ke,se])}function _a(e){return e!=null&&"current"in e}const Tl=f.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%,
|