tokentracker-cli 0.5.21 → 0.5.24

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.
@@ -0,0 +1,12 @@
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(
2
+ 0% 0%,
3
+ 100% 0%,
4
+ 100% 100%,
5
+ 0% 100%,
6
+ 0% 0%,
7
+ ${a.left}px ${a.top}px,
8
+ ${a.left}px ${a.bottom}px,
9
+ ${a.right}px ${a.bottom}px,
10
+ ${a.right}px ${a.top}px,
11
+ ${a.left}px ${a.top}px
12
+ )`}return m.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...o,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:s}})}),gg=f.createContext(void 0);function pg(e){return f.useContext(gg)}const Ol="ArrowUp",Nl="ArrowDown",Rl="ArrowLeft",Dl="ArrowRight",_l="Home",Pl="End",yg=new Set([Rl,Dl]),bg=new Set([Ol,Nl]),xg=new Set([...yg,...bg]);[...xg];const jl=new Set([Ol,Nl,Rl,Dl,_l,Pl]);function Al(e){return e==="starting"?dd:Yt}function tr({children:e,variant:t="primary",size:n="md",onClick:r,disabled:o=!1,className:s="",as:a="button",...i}){const l="inline-flex items-center justify-center font-medium transition-all duration-200 rounded-md focus:outline-none focus:ring-2 focus:ring-oai-blue/30 active:scale-[0.98] active:duration-100",c={primary:"bg-oai-black dark:bg-oai-white text-white dark:text-oai-black border border-transparent hover:bg-oai-gray-800 dark:hover:bg-oai-gray-200 active:bg-oai-gray-900 dark:active:bg-oai-gray-300 disabled:bg-oai-gray-300 dark:disabled:bg-oai-gray-700 disabled:text-oai-gray-500 dark:disabled:text-oai-gray-400 focus:ring-oai-brand/30 transition-colors duration-200",secondary:"bg-oai-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white border border-oai-gray-300 dark:border-oai-gray-700 hover:border-oai-brand hover:text-oai-brand active:bg-oai-gray-50 dark:active:bg-oai-gray-800 active:border-oai-brand-dark disabled:text-oai-gray-400 dark:disabled:text-oai-gray-500 disabled:border-oai-gray-200 dark:disabled:border-oai-gray-700 focus:ring-oai-brand/30 transition-colors duration-200",ghost:"bg-transparent text-oai-gray-600 dark:text-oai-gray-300 border border-transparent hover:text-oai-brand hover:bg-oai-brand-50/50 dark:hover:bg-oai-brand-950/30 active:bg-oai-brand-50 dark:active:bg-oai-brand-900/50 disabled:text-oai-gray-400 dark:disabled:text-oai-gray-500 focus:ring-oai-brand/30 transition-colors duration-200"},u={sm:"h-8 px-3 text-sm",md:"h-10 px-4 text-sm",lg:"h-12 px-6 text-base"},d=o?"cursor-not-allowed opacity-60":"cursor-pointer",h=`${l} ${c[t]} ${u[n]} ${d} ${s}`;return m.jsx(a,{className:h,onClick:r,disabled:o,...i,children:e})}function zr({children:e,title:t,subtitle:n,className:r="",bodyClassName:o=""}){return m.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 transition-colors duration-200 ${r}`,children:[(t||n)&&m.jsxs("div",{className:"px-5 py-4 border-b border-oai-gray-200 dark:border-oai-gray-800 transition-colors duration-200",children:[t&&m.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide transition-colors duration-200",children:t}),n&&m.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300 mt-1 transition-colors duration-200",children:n})]}),m.jsx("div",{className:`p-5 ${o}`,children:e})]})}function wg(){return m.jsxs(mi,{to:"/landing",className:"flex items-center gap-2.5 no-underline hover:opacity-80 transition-opacity",children:[m.jsx("img",{src:"/app-icon.png",alt:"Token Tracker",width:28,height:28,className:"rounded-md"}),m.jsx("span",{className:"text-base font-semibold text-oai-black dark:text-oai-white leading-tight",children:"Token Tracker"})]})}function vg({repo:e="mm7894215/TokenTracker"}){const[t,n]=f.useState(null);return f.useEffect(()=>{if(typeof window>"u")return;const r=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,o=typeof document<"u"&&(document.documentElement?.classList.contains("screenshot-capture")||document.body?.classList.contains("screenshot-capture"));Gu({prefersReducedMotion:r,screenshotCapture:o})&&fetch(`https://api.github.com/repos/${e}`).then(s=>s.json()).then(s=>{s&&typeof s.stargazers_count=="number"&&n(s.stargazers_count)}).catch(()=>{})},[e]),m.jsxs("a",{href:`https://github.com/${e}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-700 transition-colors no-underline",children:[m.jsx("svg",{height:"16",viewBox:"0 0 16 16",width:"16",className:"fill-oai-gray-700 dark:fill-oai-gray-300",children:m.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),m.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300",children:"Star"}),t!==null&&m.jsx("span",{className:"text-xs font-semibold text-oai-gray-900 dark:text-oai-white tabular-nums",children:t})]})}function kg({children:e,header:t,footer:n,className:r="",hideHeader:o=!1,hideFooter:s=!1}){const{theme:a,resolvedTheme:i,setTheme:l}=ts();return m.jsxs("div",{className:`min-h-screen bg-oai-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-sans flex flex-col transition-colors duration-200 ${r}`,children:[!o&&m.jsxs("header",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 flex items-center justify-between transition-colors duration-200",children:[m.jsx(wg,{}),m.jsx("div",{className:"flex-1 flex justify-center",children:t}),m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(vg,{}),m.jsx(cd,{theme:a,resolvedTheme:i,onSetTheme:l}),m.jsx(qu,{})]})]}),m.jsx("main",{className:"flex-1 px-6 py-6",children:e}),!s&&n&&m.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 mt-auto transition-colors duration-200",children:n})]})}function Sg({children:e,variant:t="info",size:n="md",className:r=""}){const o="inline-flex items-center font-medium",s={success:"bg-oai-brand-100 dark:bg-oai-brand-900/30 text-oai-brand-700 dark:text-oai-brand-400 rounded-full",warning:"bg-oai-amber-50 dark:bg-oai-amber-900/30 text-oai-amber-dark dark:text-oai-amber-400 rounded-full",error:"bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded-full",info:"bg-oai-gray-100 dark:bg-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-300 rounded-full",secondary:"bg-oai-gray-100 dark:bg-oai-gray-800 text-oai-gray-500 dark:text-oai-gray-300 rounded-md"},a={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm"},i=`${o} ${s[t]} ${a[n]} ${r}`.trim();return m.jsx("span",{className:i,children:e})}var Cg={};function Eg(e,t){return e==="."?{width:"0.34ch",justifyContent:"center",marginInline:"-0.04ch"}:e===","?{width:"0.08ch",justifyContent:"center",marginInline:"-0.30ch"}:{width:"0.72ch",justifyContent:"flex-start",paddingLeft:"0.04ch",height:t}}function Mg({mv:e,digit:t,height:n}){const r=bi(e,o=>{const s=(o%10+10)%10,a=(10+t-s)%10;let i=a*n;return a>5&&(i-=10*n),i});return m.jsx(vt.span,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",y:r},children:t})}function Tg(e){const t=Math.round(e),n=1e-9*Math.max(1,Math.abs(e));return Math.abs(e-t)<n?t:e}function Og(e,t){const n=e/t;return Math.floor(Tg(n))}function Ng(e){const t=String(e??""),n=Array.from(t),r=n.indexOf(".");let o=n.filter((i,l)=>/\d/.test(i)&&(r===-1||l<r)).length,s=0,a=!1;return n.map(i=>{if(!/\d/.test(i))return i==="."&&(a=!0),i;if(!a){const l=10**Math.max(o-1,0);return o-=1,l}return s+=1,10**-s})}function Rg({place:e,value:t,height:n,digitStyle:r,shouldReduceMotion:o}){if(typeof e!="number"){const l=Eg(e,n);return m.jsx("span",{"data-counter-token":"static",className:"relative inline-flex items-center justify-center",style:{height:n,...l,...r},children:e})}const s=Og(t,e),a=ns(0),i=bd(a,{stiffness:220,damping:26,mass:.8});return f.useEffect(()=>{a.set(s)},[a,s]),o?m.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex items-center justify-center overflow-hidden",style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...r},children:Math.abs(s)%10}):m.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex overflow-hidden",style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...r},children:Array.from({length:10},(l,c)=>m.jsx(Mg,{mv:i,digit:c,height:n},c))})}function Dg({value:e,displayValue:t,fontSize:n=72,padding:r=0,places:o,gap:s=6,borderRadius:a=4,horizontalPadding:i=0,textColor:l="inherit",fontWeight:c="inherit",containerStyle:u,counterStyle:d,digitStyle:h,gradientHeight:g=14,gradientFrom:p="rgba(255,255,255,0.95)",gradientTo:y="rgba(255,255,255,0)",topGradientStyle:x,bottomGradientStyle:v}){const b=String(t??e??""),w=f.useMemo(()=>Array.isArray(o)&&o.length?o:Ng(b),[o,b]),S=typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent||"")||typeof process<"u"&&Cg?.VITEST==="true",C=Ur()||S,k=Number.isFinite(Number(e))?Math.abs(Number(e)):0,T=n+r;return C?m.jsx("span",{"data-counter-root":"true",style:{display:"inline-flex",alignItems:"center",color:l,fontSize:n,fontWeight:c,lineHeight:1,...u,...d},children:b}):m.jsxs("span",{"data-counter-root":"true",style:{position:"relative",display:"inline-block",...u},children:[m.jsx("span",{style:{fontSize:n,display:"flex",gap:s,overflow:"hidden",borderRadius:a,paddingLeft:i,paddingRight:i,lineHeight:1,color:l,fontWeight:c,...d},children:w.map((N,I)=>m.jsx(Rg,{place:N,value:k,height:T,digitStyle:h,shouldReduceMotion:C},`${String(N)}-${I}`))}),m.jsxs("span",{style:{pointerEvents:"none",position:"absolute",inset:0,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[m.jsx("span",{style:x??{height:g,background:`linear-gradient(to bottom, ${p}, ${y})`}}),m.jsx("span",{style:v??{height:g,background:`linear-gradient(to top, ${p}, ${y})`}})]})]})}const Il=f.createContext(void 0);function un(e){const t=f.useContext(Il);if(e===!1&&t===void 0)throw new Error(an(27));return t}const _g={...ir,...qr},Pg=f.forwardRef(function(t,n){const{render:r,className:o,forceRender:s=!1,...a}=t,{store:i}=un(),l=i.useState("open"),c=i.useState("nested"),u=i.useState("mounted"),d=i.useState("transitionStatus"),h=f.useMemo(()=>({open:l,transitionStatus:d}),[l,d]);return jt("div",t,{state:h,ref:[i.context.backdropRef,n],stateAttributesMapping:_g,props:[{role:"presentation",hidden:!u,style:{userSelect:"none",WebkitUserSelect:"none"}},a],enabled:s||!c})}),Pa=f.forwardRef(function(t,n){const{render:r,className:o,disabled:s=!1,nativeButton:a=!0,...i}=t,{store:l}=un(),c=l.useState("open");function u(p){c&&l.setOpen(!1,Pe(Nm,p.nativeEvent))}const{getButtonProps:d,buttonRef:h}=hi({disabled:s,native:a}),g=f.useMemo(()=>({disabled:s}),[s]);return jt("button",t,{state:g,ref:[n,h],props:[{onClick:u},i,d]})});let jg=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),Ag=(function(e){return e[e.open=ft.open]="open",e[e.closed=ft.closed]="closed",e[e.startingStyle=ft.startingStyle]="startingStyle",e[e.endingStyle=ft.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const Fl=f.createContext(void 0);function Ll(){const e=f.useContext(Fl);if(e===void 0)throw new Error(an(26));return e}const Ig={...ir,...qr,nestedDialogOpen(e){return e?{[Ag.nestedDialogOpen]:""}:null}},Fg=f.forwardRef(function(t,n){const{className:r,finalFocus:o,initialFocus:s,render:a,...i}=t,{store:l}=un(),c=l.useState("descriptionElementId"),u=l.useState("disablePointerDismissal"),d=l.useState("floatingRootContext"),h=l.useState("popupProps"),g=l.useState("modal"),p=l.useState("mounted"),y=l.useState("nested"),x=l.useState("nestedOpenDialogCount"),v=l.useState("open"),b=l.useState("openMethod"),w=l.useState("titleElementId"),S=l.useState("transitionStatus"),C=l.useState("role");Ll(),ms({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}});function k(R){return R==="touch"?l.context.popupRef.current:!0}const T=s===void 0?k:s,N=x>0,I=f.useMemo(()=>({open:v,nested:y,transitionStatus:S,nestedDialogOpen:N}),[v,y,S,N]),M=jt("div",t,{state:I,props:[h,{"aria-labelledby":w??void 0,"aria-describedby":c??void 0,role:C,tabIndex:-1,hidden:!p,onKeyDown(R){jl.has(R.key)&&R.stopPropagation()},style:{[jg.nestedDialogs]:x}},i],ref:[n,l.context.popupRef,l.useStateSetter("popupElement")],stateAttributesMapping:Ig});return m.jsx(ol,{context:d,openInteractionType:b,disabled:!p,closeOnFocusOut:!u,initialFocus:T,returnFocus:o,modal:g!==!1,restoreFocus:"popup",children:M})}),Lg=f.forwardRef(function(t,n){const{keepMounted:r=!1,...o}=t,{store:s}=un(),a=s.useState("mounted"),i=s.useState("modal"),l=s.useState("open");return a||r?m.jsx(Fl.Provider,{value:r,children:m.jsxs(rl,{ref:n,...o,children:[a&&i===!0&&m.jsx(Tl,{ref:s.context.internalBackdropRef,inert:Cl(!l)}),t.children]})}):null});function Wg(e){const{store:t,parentContext:n,actionsRef:r}=e,o=t.useState("open"),s=t.useState("disablePointerDismissal"),a=t.useState("modal"),i=t.useState("popupElement"),{openMethod:l,triggerProps:c,reset:u}=Sl(o);gl(t);const{forceUnmount:d}=pl(o,t,()=>{u()}),h=me(M=>{const R=Pe(M);return R.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},R}),g=f.useCallback(()=>{t.setOpen(!1,h(Zi))},[t,h]);f.useImperativeHandle(r,()=>({unmount:d,close:g}),[d,g]);const p=xl({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[y,x]=f.useState(0),v=y===0,b=vl(p),w=ml(p,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:a==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(M){if("button"in M&&M.button!==0||"touches"in M&&M.touches.length!==1)return!1;const R=Ze(M);if(v&&!s){const j=R;return a&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===j||t.context.backdropRef.current===j||ve(j,i)&&!j?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:v});El(o&&a===!0,i);const{getReferenceProps:S,getFloatingProps:C,getTriggerProps:k}=hs([b,w]);t.useContextCallback("onNestedDialogOpen",M=>{x(M+1)}),t.useContextCallback("onNestedDialogClose",()=>{x(0)}),f.useEffect(()=>(n?.onNestedDialogOpen&&o&&n.onNestedDialogOpen(y),n?.onNestedDialogClose&&!o&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&o&&n.onNestedDialogClose()}),[o,n,y]);const T=f.useMemo(()=>S(c),[S,c]),N=f.useMemo(()=>k(c),[k,c]),I=f.useMemo(()=>C(),[C]);t.useSyncedValues({openMethod:l,activeTriggerProps:T,inactiveTriggerProps:N,popupProps:I,floatingRootContext:p,nestedOpenDialogCount:y})}const $g={...bl,modal:ge(e=>e.modal),nested:ge(e=>e.nested),nestedOpenDialogCount:ge(e=>e.nestedOpenDialogCount),disablePointerDismissal:ge(e=>e.disablePointerDismissal),openMethod:ge(e=>e.openMethod),descriptionElementId:ge(e=>e.descriptionElementId),titleElementId:ge(e=>e.titleElementId),viewportElement:ge(e=>e.viewportElement),role:ge(e=>e.role)};class Bg extends rs{constructor(t){super(Yg(t),{popupRef:f.createRef(),backdropRef:f.createRef(),internalBackdropRef:f.createRef(),triggerElements:new Gr,onOpenChange:void 0,onOpenChangeComplete:void 0},$g)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;const r={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",r);const o={open:t},s=n.trigger?.id??null;(s||t)&&(o.activeTriggerId=s,o.activeTriggerElement=n.trigger??null),this.update(o)}}function Yg(e={}){return{...yl(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...e}}function Hg(e){const{children:t,open:n,defaultOpen:r=!1,onOpenChange:o,onOpenChangeComplete:s,disablePointerDismissal:a=!1,modal:i=!0,actionsRef:l,handle:c,triggerId:u,defaultTriggerId:d=null}=e,h=un(!0),g=!!h,p=qt(()=>c?.store??new Bg({open:n??r,activeTriggerId:u!==void 0?u:d,modal:i,disablePointerDismissal:a,nested:g})).current;p.useControlledProp("open",n,r),p.useControlledProp("activeTriggerId",u,d),p.useSyncedValues({disablePointerDismissal:a,nested:g,modal:i}),p.useContextCallback("onOpenChange",o),p.useContextCallback("onOpenChangeComplete",s);const y=p.useState("payload");Wg({store:p,actionsRef:l,parentContext:h?.store.context});const x=f.useMemo(()=>({store:p}),[p]);return m.jsx(Il.Provider,{value:x,children:typeof t=="function"?t({payload:y}):t})}let ja=(function(e){return e[e.open=ft.open]="open",e[e.closed=ft.closed]="closed",e[e.startingStyle=ft.startingStyle]="startingStyle",e[e.endingStyle=ft.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const Ug={...ir,...qr,nested(e){return e?{[ja.nested]:""}:null},nestedDialogOpen(e){return e?{[ja.nestedDialogOpen]:""}:null}},Vg=f.forwardRef(function(t,n){const{className:r,render:o,children:s,...a}=t,i=Ll(),{store:l}=un(),c=l.useState("open"),u=l.useState("nested"),d=l.useState("transitionStatus"),h=l.useState("nestedOpenDialogCount"),g=l.useState("mounted"),p=h>0,y=f.useMemo(()=>({open:c,nested:u,transitionStatus:d,nestedDialogOpen:p}),[c,u,d,p]);return jt("div",t,{enabled:i||g,state:y,ref:[n,l.useStateSetter("viewportElement")],stateAttributesMapping:Ug,props:[{role:"presentation",hidden:!g,children:s},a]})}),qg=f.forwardRef(function(t,n){const{render:r,className:o,id:s,...a}=t,{store:i}=un(),l=kl(s);return i.useSyncedValueWithCleanup("titleElementId",l),jt("h2",t,{ref:n,props:[{id:l},a]})});function Aa(e){if(!Number.isFinite(e))return W("shared.placeholder.short");const t=es(e.toFixed(6));return t==="-"?W("shared.placeholder.short"):t}function Gg(e){return!Number.isFinite(e)||e<=0?null:e<.01?"<$0.01":es(e.toFixed(2))}const zg=G.memo(function({isOpen:t,onClose:n,fleetData:r=[]}){if(!t)return null;const o=W("shared.unit.percent"),s=(Array.isArray(r)?r:[]).map(l=>{const c=nt(l?.usd),u=Number.isFinite(c)?c:0,d=Array.isArray(l?.models)?l.models:[];return{label:l?.label?String(l.label):"",usdValue:u,usdLabel:Aa(u),models:d.map(h=>{const g=nt(h?.share),p=Number.isFinite(g)?`${g}${o}`:W("shared.placeholder.short"),y=nt(h?.cost),x=Gg(y);return{id:h?.id?String(h.id):"",name:h?.name?String(h.name):"",shareLabel:p,costLabel:x}})}}),a=s.reduce((l,c)=>l+c.usdValue,0),i=Aa(a);return m.jsx(Hg,{open:t,onOpenChange:l=>{l||n?.()},children:m.jsxs(Lg,{children:[m.jsx(Pg,{className:"cost-modal-backdrop","data-cost-analysis-backdrop":"true"}),m.jsx(Vg,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:m.jsxs(Fg,{className:"cost-modal-popup w-full max-w-xl rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-oai-lg overflow-hidden",children:[m.jsxs("div",{className:"px-6 py-4 border-b border-oai-gray-200 dark:border-oai-gray-800 flex items-center justify-between",children:[m.jsx(qg,{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:W("dashboard.cost_breakdown.title")}),m.jsx(Pa,{type:"button",className:"w-7 h-7 flex items-center justify-center rounded-md text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-gray-600 dark:hover:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors","aria-label":W("dashboard.cost_breakdown.close"),children:"✕"})]}),m.jsxs("div",{className:"px-6 py-6 text-center border-b border-oai-gray-100 dark:border-oai-gray-800",children:[m.jsx("div",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400 uppercase tracking-wide mb-2",children:W("dashboard.cost_breakdown.total_label")}),m.jsx("div",{className:"text-3xl font-bold text-oai-brand tabular-nums tracking-tight",children:i})]}),m.jsx("div",{className:"px-6 py-4 max-h-[45vh] overflow-y-auto oai-scrollbar",children:m.jsx("div",{className:"space-y-5",children:s.map((l,c)=>m.jsxs("div",{children:[m.jsxs("div",{className:"flex justify-between items-baseline pb-2 mb-2 border-b border-oai-gray-100 dark:border-oai-gray-800",children:[m.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white",children:l.label}),m.jsx("span",{className:"text-sm font-semibold text-oai-brand tabular-nums",children:l.usdLabel})]}),m.jsx("div",{className:"space-y-1",children:l.models.map((u,d)=>{const h=u?.id||`${u.name}-${d}`;return m.jsxs("div",{className:"flex justify-between items-center py-1 text-xs",children:[m.jsxs("span",{className:"text-oai-gray-600 dark:text-oai-gray-300",children:[u.name,m.jsx("span",{className:"ml-1.5 text-oai-gray-400 dark:text-oai-gray-500 tabular-nums",children:u.shareLabel})]}),u.costLabel?m.jsx("span",{className:"text-oai-gray-600 dark:text-oai-gray-300 font-medium tabular-nums",children:u.costLabel}):null]},h)})})]},`${l.label}-${c}`))})}),m.jsxs("div",{className:"px-6 py-4 border-t border-oai-gray-200 dark:border-oai-gray-800 flex justify-between items-center",children:[m.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500",children:W("dashboard.cost_breakdown.footer")}),m.jsx(Pa,{render:m.jsx(tr,{variant:"secondary",size:"sm"}),children:W("dashboard.cost_breakdown.close")})]})]})})]})})});function Kg({projectEntries:e=[],projectLimit:t=3,onProjectLimitChange:n,copy:r,hasDetailsActual:o,dailyEmptyPrefix:s,installSyncCmd:a,dailyEmptySuffix:i,detailsColumns:l,ariaSortFor:c,toggleSort:u,sortIconFor:d,pagedDetails:h,dailyBreakdownRows:g=[],dailyBreakdownColumns:p=[],dailyBreakdownAriaSortFor:y,dailyBreakdownSortIconFor:x,dailyBreakdownDateKey:v="day",detailsDateKey:b,renderDetailDate:w,renderDailyBreakdownDate:S,renderDetailCell:C,DETAILS_PAGED_PERIODS:k,period:T,detailsPageCount:N,detailsPage:I,setDetailsPage:M}){const[R,j]=f.useState("daily");return m.jsxs(zr,{className:"flex-1 flex flex-col min-h-0 overflow-hidden",bodyClassName:"flex-1 flex flex-col min-h-0",children:[m.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[m.jsxs("div",{role:"tablist","aria-label":"Data view",className:"flex gap-1",children:[m.jsx("button",{role:"tab","aria-selected":R==="daily",type:"button",onClick:()=>j("daily"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${R==="daily"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:r("dashboard.daily.title")}),m.jsx("button",{role:"tab","aria-selected":R==="projects",type:"button",onClick:()=>j("projects"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${R==="projects"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:r("dashboard.projects.title")})]}),R==="projects"&&m.jsxs("select",{"aria-label":"Number of projects to display",value:t,onChange:E=>n?.(Number(E.target.value)),className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded px-2 py-1 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 focus:border-oai-brand dark:focus:border-oai-brand focus:outline-none transition-colors",children:[m.jsx("option",{value:3,children:r("dashboard.projects.limit_top_3")}),m.jsx("option",{value:6,children:r("dashboard.projects.limit_top_6")}),m.jsx("option",{value:10,children:r("dashboard.projects.limit_top_10")})]})]}),R==="projects"&&m.jsx("div",{className:"space-y-1",children:e.slice(0,t).map(E=>m.jsxs("a",{href:E?.project_ref||"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-2 rounded-lg hover:oai-bg-elevated transition-colors",children:[m.jsx("div",{className:"w-8 h-8 rounded-md oai-bg-elevated flex items-center justify-center oai-text-caption font-medium text-oai-gray-500 dark:text-oai-gray-300",children:(E?.project_key?.[0]||"?").toUpperCase()}),m.jsx("div",{className:"min-w-0 flex-1",children:m.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:E?.project_key||E?.project_ref?.split("/")?.pop()||"—"})}),m.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:E?.billable_total_tokens?.toLocaleString?.()||E?.total_tokens?.toLocaleString?.()||"—"})]},E?.project_key||E?.project_ref))}),R==="daily"&&m.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[g?.length===0?m.jsxs("div",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300 mb-4",children:[s,m.jsx("code",{className:"mx-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 oai-bg-elevated px-1.5 py-0.5 font-mono oai-text-caption",children:a}),i]}):m.jsx("div",{className:"overflow-auto flex-1 min-h-0 -mx-4 oai-scrollbar",children:m.jsxs("table",{className:"w-full border-collapse",children:[m.jsx("thead",{className:"sticky top-0 z-10",children:m.jsx("tr",{className:"border-b border-oai-gray-200 dark:border-oai-gray-700",children:p.map(E=>m.jsx("th",{"aria-sort":y?.(E.key)||"none",className:"text-left p-0 bg-white dark:bg-oai-gray-900",children:m.jsx("button",{type:"button",onClick:()=>u(E.key),className:"flex w-full items-center justify-start px-4 py-2 text-left oai-text-caption font-semibold text-oai-gray-600 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white transition-colors",children:m.jsxs("span",{className:"inline-flex items-center gap-1",children:[m.jsx("span",{children:E.label}),m.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-400",children:x?.(E.key)||""})]})})},E.key))})}),m.jsx("tbody",{children:g.map(E=>m.jsxs("tr",{className:`border-b border-oai-gray-100 dark:border-oai-gray-800 last:border-b-0 hover:bg-oai-gray-50/50 dark:hover:bg-oai-gray-800/50 transition-colors ${E.missing?"text-oai-gray-400 dark:text-oai-gray-400":E.future?"text-oai-gray-300 dark:text-oai-gray-600":"text-oai-black dark:text-oai-white"}`,children:[m.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300",children:S?S(E):w(E)}),m.jsx("td",{className:"px-4 py-2 oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:C(E,"total_tokens")}),m.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:C(E,"input_tokens")}),m.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:C(E,"output_tokens")}),m.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:C(E,"cached_input_tokens")}),m.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:C(E,"reasoning_output_tokens")}),m.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:C(E,"conversation_count")})]},String(E?.[v]||E?.day||E?.hour||E?.month||"")))})]})}),R!=="daily"&&k.has(T)&&N>1?m.jsxs("div",{className:"mt-3 flex items-center justify-between oai-text-caption",children:[m.jsx("button",{type:"button",onClick:()=>M(E=>Math.max(0,E-1)),disabled:I===0,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("details.pagination.prev")}),m.jsxs("span",{className:"oai-text-muted",children:[I+1," / ",N]}),m.jsx("button",{type:"button",onClick:()=>M(E=>Math.min(N-1,E+1)),disabled:I+1>=N,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("details.pagination.next")})]}):null]})]})}function Mn({children:e,delay:t=0,duration:n=.4,y:r=20,className:o="",once:s=!0}){return Ur()?m.jsx("div",{className:o,children:e}):m.jsx(vt.div,{initial:{opacity:0,y:r},animate:{opacity:1,y:0},transition:{duration:n,delay:t,ease:[.25,.1,.25,1]},className:o,children:e})}function Dr(e){return typeof e!="string"?"":e.trim()}function Ia(e){const t=Dr(e);return t?t.split(/[_\-\s]+/).filter(Boolean).map(n=>n.slice(0,1).toUpperCase()+n.slice(1).toLowerCase()).join(" "):""}function Xg(e){if(!Array.isArray(e))return[];const t=new Map;for(const n of e){if(!n||typeof n!="object")continue;const r=Dr(n.tool),o=Dr(n.planType)||Dr(n.plan_type);if(!r||!o)continue;const s=Ia(r)||r,a=Ia(o)||o;t.set(`${r.toLowerCase()}::${o.toLowerCase()}`,{tool:s,plan:a})}return Array.from(t.values())}function Jg({period:e="month",rankLabel:t,streakDays:n,subscriptions:r=[],periodConversations:o,rolling:s,topModels:a=[],className:i=""}){const l=W("shared.placeholder.short"),c=W("shared.unit.percent"),u=t??W("identity_card.rank_placeholder"),d=Number.isFinite(Number(n))?Number(n):0,h=d?W("identity_card.streak_value",{days:d}):W("identity_card.rank_placeholder"),g=Xg(r),p={thousandSuffix:W("shared.unit.thousand_abbrev"),millionSuffix:W("shared.unit.million_abbrev"),billionSuffix:W("shared.unit.billion_abbrev")},y=b=>{if(b==null)return l;const w=gi(b,p);return w==="-"?l:w},x=(()=>{switch(e){case"day":return"today convs";case"week":return"week convs";case"month":return"month convs";case"total":return"all convs";default:return"convs"}})(),v=a.slice(0,3);return m.jsx(Mn,{delay:.1,children:m.jsxs(zr,{className:`h-full ${i}`,children:[m.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[m.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[m.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:y(s?.last_7d?.totals?.billable_total_tokens)}),m.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:"7d"})]}),m.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[m.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:y(s?.last_30d?.totals?.billable_total_tokens)}),m.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:"30d"})]}),m.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[m.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:y(s?.last_30d?.avg_per_active_day)}),m.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:"avg"})]}),m.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[m.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:y(o)}),m.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:x})]})]}),v.length>0&&m.jsx("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800",children:v.map((b,w)=>{const S=b?.name?String(b.name):l,C=b?.percent?String(b.percent):"",k=w===v.length-1,T=w+1;return m.jsxs("div",{className:`flex items-center py-2 ${k?"":"border-b border-oai-gray-50 dark:border-oai-gray-800"}`,children:[m.jsx("span",{className:"w-5 h-5 flex items-center justify-center rounded-full bg-oai-gray-100 dark:bg-oai-gray-800 text-[10px] font-semibold text-oai-gray-500 dark:text-oai-gray-300 flex-shrink-0",children:T}),m.jsx("span",{className:"flex-1 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate px-2.5",title:S,children:S}),m.jsxs("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums flex-shrink-0",children:[C,c]})]},b.id||S)})}),g.length>0&&m.jsx("div",{className:"mt-3 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800 flex flex-wrap gap-1.5",children:g.map((b,w)=>m.jsxs(Sg,{variant:"secondary",size:"sm",children:[b.tool," ",b.plan]},`${b.tool}:${b.plan}:${w}`))}),m.jsxs("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800 flex items-center justify-between text-xs text-oai-gray-400 dark:text-oai-gray-400",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx("span",{children:W("identity_card.rank_label")}),m.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:u})]}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{children:W("identity_card.streak_label")}),m.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:h})]})]})]})})}const Wl=f.createContext(void 0);function lr(e){const t=f.useContext(Wl);if(t===void 0&&!e)throw new Error(an(47));return t}function Qg(){return{...yl(),disabled:!1,modal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}const Zg={...bl,disabled:ge(e=>e.disabled),instantType:ge(e=>e.instantType),openMethod:ge(e=>e.openMethod),openChangeReason:ge(e=>e.openChangeReason),modal:ge(e=>e.modal),stickIfOpen:ge(e=>e.stickIfOpen),titleElementId:ge(e=>e.titleElementId),descriptionElementId:ge(e=>e.descriptionElementId),openOnHover:ge(e=>e.openOnHover),closeDelay:ge(e=>e.closeDelay),hasViewport:ge(e=>e.hasViewport)};class gs extends rs{constructor(t){const n={...Qg(),...t};n.open&&t?.mounted===void 0&&(n.mounted=!0),super(n,{popupRef:f.createRef(),backdropRef:f.createRef(),internalBackdropRef:f.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:f.createRef(),beforeContentFocusGuardRef:f.createRef(),stickIfOpenTimeout:new Vt,triggerElements:new Gr},Zg)}setOpen=(t,n)=>{const r=n.reason===tt,o=n.reason===Ht&&n.event.detail===0,s=!t&&(n.reason===Qi||n.reason==null);if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},this.context.onOpenChange?.(t,n),n.isCanceled)return;const a={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested,triggerElement:n.trigger};this.state.floatingRootContext.context.events?.emit("openchange",a);const l=()=>{const c={open:t,openChangeReason:n.reason},u=n.trigger?.id??null;(u||t)&&(c.activeTriggerId=u,c.activeTriggerElement=n.trigger??null),this.update(c)};r?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(ud,()=>{this.set("stickIfOpen",!1)}),Ut.flushSync(l)):l(),o||s?this.set("instantType",o?"click":"dismiss"):n.reason===Qn?this.set("instantType","focus"):this.set("instantType",void 0)};static useStore(t,n){const r=qt(()=>new gs(n)).current,o=t??r;return os(r.disposeEffect),o}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()}function Fa({props:e}){const{children:t,open:n,defaultOpen:r=!1,onOpenChange:o,onOpenChangeComplete:s,modal:a=!1,handle:i,triggerId:l,defaultTriggerId:c=null}=e,u=gs.useStore(i?.store,{open:n??r,modal:a,activeTriggerId:l!==void 0?l:c});u.useControlledProp("open",n,r),u.useControlledProp("activeTriggerId",l,c);const d=u.useState("open"),h=u.useState("positionerElement"),g=u.useState("payload"),p=u.useState("openChangeReason");u.useContextCallback("onOpenChange",o),u.useContextCallback("onOpenChangeComplete",s);const{openMethod:y,triggerProps:x,reset:v}=Sl(d);gl(u);const{forceUnmount:b}=pl(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null}),v()});El(d&&a===!0&&p!==tt&&y!=="touch",h),f.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]);const w=f.useCallback(_=>{const B=Pe(_);return B.preventUnmountOnClose=()=>{u.set("preventUnmountingOnClose",!0)},B},[u]),S=f.useCallback(()=>{u.setOpen(!1,w(Zi))},[u,w]);f.useImperativeHandle(e.actionsRef,()=>({unmount:b,close:S}),[b,S]);const C=xl({popupStore:u,onOpenChange:u.setOpen}),k=ml(C,{outsidePressEvent:{mouse:a==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),T=vl(C),{getReferenceProps:N,getFloatingProps:I,getTriggerProps:M}=hs([k,T]),R=f.useMemo(()=>N(x),[N,x]),j=f.useMemo(()=>M(x),[M,x]),E=f.useMemo(()=>I(),[I]);u.useSyncedValues({modal:a,openMethod:y,activeTriggerProps:R,inactiveTriggerProps:j,popupProps:E,floatingRootContext:C,nested:ln()!=null});const F=f.useMemo(()=>({store:u}),[u]);return m.jsx(Wl.Provider,{value:F,children:typeof t=="function"?t({payload:g}):t})}function ep(e){return lr(!0)?m.jsx(Fa,{props:e}):m.jsx(Tm,{children:m.jsx(Fa,{props:e})})}const tp=300,np=f.forwardRef(function(t,n){const{render:r,className:o,disabled:s=!1,nativeButton:a=!0,handle:i,payload:l,openOnHover:c=!1,delay:u=tp,closeDelay:d=0,id:h,...g}=t,p=lr(!0),y=i?.store??p?.store;if(!y)throw new Error(an(74));const x=kl(h),v=y.useState("isTriggerActive",x),b=y.useState("floatingRootContext"),w=y.useState("isOpenedByTrigger",x),S=f.useRef(null),{registerTrigger:C,isMountedByThisTrigger:k}=jh(x,S,y,{payload:l,disabled:s,openOnHover:c,closeDelay:d}),T=y.useState("openChangeReason"),N=y.useState("stickIfOpen"),I=y.useState("openMethod"),M=Uh(b,{enabled:b!=null&&c&&(I!=="touch"||T!==Ht),mouseOnly:!0,move:!1,handleClose:Gh(),restMs:u,delay:{close:d},triggerElementRef:S,isActiveTrigger:v}),R=Wm(b,{enabled:b!=null,stickIfOpen:N}),j=hs([R]),E=y.useState("triggerProps",k),F=f.useMemo(()=>({disabled:s,open:w}),[s,w]),{getButtonProps:_,buttonRef:B}=hi({disabled:s,native:a}),V=f.useMemo(()=>({open(ee){return ee&&T===Ht?tg.open(ee):eg.open(ee)}}),[T]),O=jt("button",t,{state:F,ref:[B,n,C,S],props:[j.getReferenceProps(),M,E,{[pi]:"",id:x},g,_],stateAttributesMapping:V}),P=f.useRef(null),U=me(ee=>{Ut.flushSync(()=>{y.setOpen(!1,Pe(Qn,ee.nativeEvent,ee.currentTarget))}),wm(P.current)?.focus()}),Y=me(ee=>{const H=y.select("positionerElement");if(H&&Sn(ee,H))y.context.beforeContentFocusGuardRef.current?.focus();else{Ut.flushSync(()=>{y.setOpen(!1,Pe(Qn,ee.nativeEvent,ee.currentTarget))});let L=xm(y.context.triggerFocusTargetRef.current||S.current);for(;L!==null&&ve(H,L);){const z=L;if(L=cs(L),L===z)break}L?.focus()}});return v?m.jsxs(f.Fragment,{children:[m.jsx(_n,{ref:P,onFocus:U}),m.jsx(f.Fragment,{children:O},x),m.jsx(_n,{ref:y.context.triggerFocusTargetRef,onFocus:Y})]}):m.jsx(f.Fragment,{children:O},x)}),$l=f.createContext(void 0);function rp(){const e=f.useContext($l);if(e===void 0)throw new Error(an(45));return e}const op=f.forwardRef(function(t,n){const{keepMounted:r=!1,...o}=t,{store:s}=lr();return s.useState("mounted")||r?m.jsx($l.Provider,{value:r,children:m.jsx(rl,{ref:n,...o,renderGuards:!1})}):null}),Bl=f.createContext(void 0);function sp(){const e=f.useContext(Bl);if(!e)throw new Error(an(46));return e}const ap=f.forwardRef(function(t,n){const{render:r,className:o,anchor:s,positionMethod:a="absolute",side:i="bottom",align:l="center",sideOffset:c=0,alignOffset:u=0,collisionBoundary:d="clipping-ancestors",collisionPadding:h=5,arrowPadding:g=5,sticky:p=!1,disableAnchorTracking:y=!1,collisionAvoidance:x=fd,...v}=t,{store:b}=lr(),w=rp(),S=Em(),C=b.useState("floatingRootContext"),k=b.useState("mounted"),T=b.useState("open"),N=b.useState("openChangeReason"),I=b.useState("activeTriggerElement"),M=b.useState("modal"),R=b.useState("positionerElement"),j=b.useState("instantType"),E=b.useState("transitionStatus"),F=b.useState("hasViewport"),_=f.useRef(null),B=hl(R,!1,!1),V=hg({anchor:s,floatingRootContext:C,positionMethod:a,mounted:k,side:i,sideOffset:c,align:l,alignOffset:u,arrowPadding:g,collisionBoundary:d,collisionPadding:h,sticky:p,disableAnchorTracking:y,keepMounted:w,nodeId:S,collisionAvoidance:x,adaptiveOrigin:F?mg:void 0}),O=f.useMemo(()=>{const L={};return T||(L.pointerEvents="none"),{role:"presentation",hidden:!k,style:{...V.positionerStyles,...L}}},[T,k,V.positionerStyles]),P=f.useMemo(()=>({props:O,...V}),[O,V]),U=C?.select("domReferenceElement");Ee(()=>{const L=U,z=_.current;if(L&&(_.current=L),z&&L&&L!==z){b.set("instantType",void 0);const X=new AbortController;return B(()=>{b.set("instantType","trigger-change")},X.signal),()=>{X.abort()}}},[U,B,b]);const Y=f.useMemo(()=>({open:T,side:P.side,align:P.align,anchorHidden:P.anchorHidden,instant:j}),[T,P.side,P.align,P.anchorHidden,j]),ee=f.useCallback(L=>{b.set("positionerElement",L)},[b]),H=jt("div",t,{state:Y,props:[P.props,Al(E),v],ref:[n,ee],stateAttributesMapping:ir});return m.jsxs(Bl.Provider,{value:P,children:[k&&M===!0&&N!==tt&&m.jsx(Tl,{ref:b.context.internalBackdropRef,inert:Cl(!T),cutout:I}),m.jsx(Mm,{id:S,children:H})]})}),ip={...ir,...qr},lp=f.forwardRef(function(t,n){const{className:r,render:o,initialFocus:s,finalFocus:a,...i}=t,{store:l}=lr(),c=sp(),u=pg()!=null,d=l.useState("open"),h=l.useState("openMethod"),g=l.useState("instantType"),p=l.useState("transitionStatus"),y=l.useState("popupProps"),x=l.useState("titleElementId"),v=l.useState("descriptionElementId"),b=l.useState("modal"),w=l.useState("mounted"),S=l.useState("openChangeReason"),C=l.useState("activeTriggerElement"),k=l.useState("floatingRootContext");ms({open:d,ref:l.context.popupRef,onComplete(){d&&l.context.onOpenChangeComplete?.(!0)}});const T=l.useState("disabled"),N=l.useState("openOnHover"),I=l.useState("closeDelay");Bh(k,{enabled:N&&!T,closeDelay:I});function M(_){return _==="touch"?l.context.popupRef.current:!0}const R=s===void 0?M:s,j=f.useMemo(()=>({open:d,side:c.side,align:c.align,instant:g,transitionStatus:p}),[d,c.side,c.align,g,p]),E=f.useCallback(_=>{l.set("popupElement",_)},[l]),F=jt("div",t,{state:j,ref:[n,l.context.popupRef,E],props:[y,{"aria-labelledby":x,"aria-describedby":v,onKeyDown(_){u&&jl.has(_.key)&&_.stopPropagation()}},Al(p),i],stateAttributesMapping:ip});return m.jsx(ol,{context:k,openInteractionType:h,modal:b==="trap-focus",disabled:!w||S===tt,initialFocus:R,returnFocus:a,restoreFocus:"popup",previousFocusableElement:Ke(C)?C:void 0,nextFocusableElement:l.context.triggerFocusTargetRef,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:F})});function cp(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const up={},Xn={};function en(e,t){try{const r=(up[e]||=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format)(t).split("GMT")[1];return r in Xn?Xn[r]:La(r,r.split(":"))}catch{if(e in Xn)return Xn[e];const n=e?.match(dp);return n?La(e,n.slice(1)):NaN}}const dp=/([+-]\d\d):?(\d\d)?/;function La(e,t){const n=+(t[0]||0),r=+(t[1]||0),o=+(t[2]||0)/60;return Xn[e]=n*60+r>0?n*60+r+o:n*60-r-o}class xt extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(en(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),Yl(this),Ko(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new xt(...n,t):new xt(Date.now(),t)}withTimeZone(t){return new xt(+this,t)}getTimezoneOffset(){const t=-en(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),Ko(this),+this}[Symbol.for("constructDateFrom")](t){return new xt(+new Date(t),this.timeZone)}}const Wa=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!Wa.test(e))return;const t=e.replace(Wa,"$1UTC");xt.prototype[t]&&(e.startsWith("get")?xt.prototype[e]=function(){return this.internal[t]()}:(xt.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),fp(this),+this},xt.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),Ko(this),+this}))});function Ko(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-en(e.timeZone,e)*60))}function fp(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),Yl(e)}function Yl(e){const t=en(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);const o=-new Date(+e).getTimezoneOffset(),s=-new Date(+r).getTimezoneOffset(),a=o-s,i=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();a&&i&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+a);const l=o-n;l&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+l);const c=new Date(+e);c.setUTCSeconds(0);const u=o>0?c.getSeconds():(c.getSeconds()-60)%60,d=Math.round(-(en(e.timeZone,e)*60))%60;(d||u)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+d),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+d+u));const h=en(e.timeZone,e),g=h>0?Math.floor(h):Math.ceil(h),y=-new Date(+e).getTimezoneOffset()-g,x=g!==n,v=y-l;if(x&&v){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+v);const b=en(e.timeZone,e),w=b>0?Math.floor(b):Math.ceil(b),S=g-w;S&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+S),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+S))}}class ze extends xt{static tz(t,...n){return n.length?new ze(...n,t):new ze(Date.now(),t)}toISOString(){const[t,n,r]=this.tzComponents(),o=`${t}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+o}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,r,o]=this.internal.toUTCString().split(" ");return`${t?.slice(0,-1)} ${r} ${n} ${o}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,r,o]=this.tzComponents();return`${t} GMT${n}${r}${o} (${cp(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",r=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),o=String(Math.abs(t)%60).padStart(2,"0");return[n,r,o]}withTimeZone(t){return new ze(+this,t)}[Symbol.for("constructDateFrom")](t){return new ze(+new Date(t),this.timeZone)}}const Hl=6048e5,mp=864e5,$a=Symbol.for("constructDateFrom");function Le(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&$a in e?e[$a](t):e instanceof Date?new e.constructor(t):new Date(t)}function Me(e,t){return Le(t||e,e)}function Ul(e,t,n){const r=Me(e,n?.in);return isNaN(t)?Le(e,NaN):(t&&r.setDate(r.getDate()+t),r)}function Vl(e,t,n){const r=Me(e,n?.in);if(isNaN(t))return Le(e,NaN);if(!t)return r;const o=r.getDate(),s=Le(e,r.getTime());s.setMonth(r.getMonth()+t+1,0);const a=s.getDate();return o>=a?s:(r.setFullYear(s.getFullYear(),s.getMonth(),o),r)}let hp={};function cr(){return hp}function Pn(e,t){const n=cr(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,o=Me(e,t?.in),s=o.getDay(),a=(s<r?7:0)+s-r;return o.setDate(o.getDate()-a),o.setHours(0,0,0,0),o}function nr(e,t){return Pn(e,{...t,weekStartsOn:1})}function ql(e,t){const n=Me(e,t?.in),r=n.getFullYear(),o=Le(n,0);o.setFullYear(r+1,0,4),o.setHours(0,0,0,0);const s=nr(o),a=Le(n,0);a.setFullYear(r,0,4),a.setHours(0,0,0,0);const i=nr(a);return n.getTime()>=s.getTime()?r+1:n.getTime()>=i.getTime()?r:r-1}function Ba(e){const t=Me(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function $n(e,...t){const n=Le.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function rr(e,t){const n=Me(e,t?.in);return n.setHours(0,0,0,0),n}function ps(e,t,n){const[r,o]=$n(n?.in,e,t),s=rr(r),a=rr(o),i=+s-Ba(s),l=+a-Ba(a);return Math.round((i-l)/mp)}function gp(e,t){const n=ql(e,t),r=Le(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),nr(r)}function pp(e,t,n){return Ul(e,t*7,n)}function yp(e,t,n){return Vl(e,t*12,n)}function bp(e,t){let n,r=t?.in;return e.forEach(o=>{!r&&typeof o=="object"&&(r=Le.bind(null,o));const s=Me(o,r);(!n||n<s||isNaN(+s))&&(n=s)}),Le(r,n||NaN)}function xp(e,t){let n,r=t?.in;return e.forEach(o=>{!r&&typeof o=="object"&&(r=Le.bind(null,o));const s=Me(o,r);(!n||n>s||isNaN(+s))&&(n=s)}),Le(r,n||NaN)}function wp(e,t,n){const[r,o]=$n(n?.in,e,t);return+rr(r)==+rr(o)}function Gl(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function vp(e){return!(!Gl(e)&&typeof e!="number"||isNaN(+Me(e)))}function zl(e,t,n){const[r,o]=$n(n?.in,e,t),s=r.getFullYear()-o.getFullYear(),a=r.getMonth()-o.getMonth();return s*12+a}function kp(e,t){const n=Me(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Kl(e,t){const[n,r]=$n(e,t.start,t.end);return{start:n,end:r}}function Sp(e,t){const{start:n,end:r}=Kl(t?.in,e);let o=+n>+r;const s=o?+n:+r,a=o?r:n;a.setHours(0,0,0,0),a.setDate(1);let i=1;const l=[];for(;+a<=s;)l.push(Le(n,a)),a.setMonth(a.getMonth()+i);return o?l.reverse():l}function Cp(e,t){const n=Me(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Ep(e,t){const n=Me(e,t?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function Xl(e,t){const n=Me(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Mp(e,t){const{start:n,end:r}=Kl(t?.in,e);let o=+n>+r;const s=o?+n:+r,a=o?r:n;a.setHours(0,0,0,0),a.setMonth(0,1);let i=1;const l=[];for(;+a<=s;)l.push(Le(n,a)),a.setFullYear(a.getFullYear()+i);return o?l.reverse():l}function Jl(e,t){const n=cr(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,o=Me(e,t?.in),s=o.getDay(),a=(s<r?-7:0)+6-(s-r);return o.setDate(o.getDate()+a),o.setHours(23,59,59,999),o}function Tp(e,t){return Jl(e,{...t,weekStartsOn:1})}const Op={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Np=(e,t,n)=>{let r;const o=Op[e];return typeof o=="string"?r=o:t===1?r=o.one:r=o.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function Ro(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Rp={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Dp={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},_p={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Pp={date:Ro({formats:Rp,defaultWidth:"full"}),time:Ro({formats:Dp,defaultWidth:"full"}),dateTime:Ro({formats:_p,defaultWidth:"full"})},jp={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ap=(e,t,n,r)=>jp[e];function Gn(e){return(t,n)=>{const r=n?.context?String(n.context):"standalone";let o;if(r==="formatting"&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,i=n?.width?String(n.width):a;o=e.formattingValues[i]||e.formattingValues[a]}else{const a=e.defaultWidth,i=n?.width?String(n.width):e.defaultWidth;o=e.values[i]||e.values[a]}const s=e.argumentCallback?e.argumentCallback(t):t;return o[s]}}const Ip={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Fp={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Lp={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Wp={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},$p={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Bp={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Yp=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Hp={ordinalNumber:Yp,era:Gn({values:Ip,defaultWidth:"wide"}),quarter:Gn({values:Fp,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Gn({values:Lp,defaultWidth:"wide"}),day:Gn({values:Wp,defaultWidth:"wide"}),dayPeriod:Gn({values:$p,defaultWidth:"wide",formattingValues:Bp,defaultFormattingWidth:"wide"})};function zn(e){return(t,n={})=>{const r=n.width,o=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(o);if(!s)return null;const a=s[0],i=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?Vp(i,d=>d.test(a)):Up(i,d=>d.test(a));let c;c=e.valueCallback?e.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;const u=t.slice(a.length);return{value:c,rest:u}}}function Up(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function Vp(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function qp(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const o=r[0],s=t.match(e.parsePattern);if(!s)return null;let a=e.valueCallback?e.valueCallback(s[0]):s[0];a=n.valueCallback?n.valueCallback(a):a;const i=t.slice(o.length);return{value:a,rest:i}}}const Gp=/^(\d+)(th|st|nd|rd)?/i,zp=/\d+/i,Kp={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Xp={any:[/^b/i,/^(a|c)/i]},Jp={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Qp={any:[/1/i,/2/i,/3/i,/4/i]},Zp={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},ey={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},ty={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},ny={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},ry={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},oy={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},sy={ordinalNumber:qp({matchPattern:Gp,parsePattern:zp,valueCallback:e=>parseInt(e,10)}),era:zn({matchPatterns:Kp,defaultMatchWidth:"wide",parsePatterns:Xp,defaultParseWidth:"any"}),quarter:zn({matchPatterns:Jp,defaultMatchWidth:"wide",parsePatterns:Qp,defaultParseWidth:"any",valueCallback:e=>e+1}),month:zn({matchPatterns:Zp,defaultMatchWidth:"wide",parsePatterns:ey,defaultParseWidth:"any"}),day:zn({matchPatterns:ty,defaultMatchWidth:"wide",parsePatterns:ny,defaultParseWidth:"any"}),dayPeriod:zn({matchPatterns:ry,defaultMatchWidth:"any",parsePatterns:oy,defaultParseWidth:"any"})},vn={code:"en-US",formatDistance:Np,formatLong:Pp,formatRelative:Ap,localize:Hp,match:sy,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ay(e,t){const n=Me(e,t?.in);return ps(n,Xl(n))+1}function ys(e,t){const n=Me(e,t?.in),r=+nr(n)-+gp(n);return Math.round(r/Hl)+1}function Ql(e,t){const n=Me(e,t?.in),r=n.getFullYear(),o=cr(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,a=Le(t?.in||e,0);a.setFullYear(r+1,0,s),a.setHours(0,0,0,0);const i=Pn(a,t),l=Le(t?.in||e,0);l.setFullYear(r,0,s),l.setHours(0,0,0,0);const c=Pn(l,t);return+n>=+i?r+1:+n>=+c?r:r-1}function iy(e,t){const n=cr(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,o=Ql(e,t),s=Le(t?.in||e,0);return s.setFullYear(o,0,r),s.setHours(0,0,0,0),Pn(s,t)}function bs(e,t){const n=Me(e,t?.in),r=+Pn(n,t)-+iy(n,t);return Math.round(r/Hl)+1}function we(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const $t={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return we(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):we(n+1,2)},d(e,t){return we(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(e,t){return we(e.getHours()%12||12,t.length)},H(e,t){return we(e.getHours(),t.length)},m(e,t){return we(e.getMinutes(),t.length)},s(e,t){return we(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),o=Math.trunc(r*Math.pow(10,n-3));return we(o,t.length)}},yn={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Ya={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),o=r>0?r:1-r;return n.ordinalNumber(o,{unit:"year"})}return $t.y(e,t)},Y:function(e,t,n,r){const o=Ql(e,r),s=o>0?o:1-o;if(t==="YY"){const a=s%100;return we(a,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):we(s,t.length)},R:function(e,t){const n=ql(e);return we(n,t.length)},u:function(e,t){const n=e.getFullYear();return we(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return we(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return we(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return $t.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return we(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const o=bs(e,r);return t==="wo"?n.ordinalNumber(o,{unit:"week"}):we(o,t.length)},I:function(e,t,n){const r=ys(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):we(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):$t.d(e,t)},D:function(e,t,n){const r=ay(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):we(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const o=e.getDay(),s=(o-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return we(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(o,{width:"short",context:"formatting"});default:return n.day(o,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const o=e.getDay(),s=(o-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return we(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(o,{width:"narrow",context:"standalone"});case"cccccc":return n.day(o,{width:"short",context:"standalone"});default:return n.day(o,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),o=r===0?7:r;switch(t){case"i":return String(o);case"ii":return we(o,t.length);case"io":return n.ordinalNumber(o,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const o=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(o,{width:"narrow",context:"formatting"});default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let o;switch(r===12?o=yn.noon:r===0?o=yn.midnight:o=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(o,{width:"narrow",context:"formatting"});default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let o;switch(r>=17?o=yn.evening:r>=12?o=yn.afternoon:r>=4?o=yn.morning:o=yn.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(o,{width:"narrow",context:"formatting"});default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return $t.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):$t.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):we(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):we(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):$t.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):$t.s(e,t)},S:function(e,t){return $t.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return Ua(r);case"XXXX":case"XX":return Zt(r);default:return Zt(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return Ua(r);case"xxxx":case"xx":return Zt(r);default:return Zt(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Ha(r,":");default:return"GMT"+Zt(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Ha(r,":");default:return"GMT"+Zt(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return we(r,t.length)},T:function(e,t,n){return we(+e,t.length)}};function Ha(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),o=Math.trunc(r/60),s=r%60;return s===0?n+String(o):n+String(o)+t+we(s,2)}function Ua(e,t){return e%60===0?(e>0?"-":"+")+we(Math.abs(e)/60,2):Zt(e,t)}function Zt(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),o=we(Math.trunc(r/60),2),s=we(r%60,2);return n+o+t+s}const Va=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},Zl=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},ly=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],o=n[2];if(!o)return Va(e,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",Va(r,t)).replace("{{time}}",Zl(o,t))},cy={p:Zl,P:ly},uy=/^D+$/,dy=/^Y+$/,fy=["D","DD","YY","YYYY"];function my(e){return uy.test(e)}function hy(e){return dy.test(e)}function gy(e,t,n){const r=py(e,t,n);if(console.warn(r),fy.includes(e))throw new RangeError(r)}function py(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const yy=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,by=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,xy=/^'([^]*?)'?$/,wy=/''/g,vy=/[a-zA-Z]/;function wt(e,t,n){const r=cr(),o=n?.locale??r.locale??vn,s=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,i=Me(e,n?.in);if(!vp(i))throw new RangeError("Invalid time value");let l=t.match(by).map(u=>{const d=u[0];if(d==="p"||d==="P"){const h=cy[d];return h(u,o.formatLong)}return u}).join("").match(yy).map(u=>{if(u==="''")return{isToken:!1,value:"'"};const d=u[0];if(d==="'")return{isToken:!1,value:ky(u)};if(Ya[d])return{isToken:!0,value:u};if(d.match(vy))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:u}});o.localize.preprocessor&&(l=o.localize.preprocessor(i,l));const c={firstWeekContainsDate:s,weekStartsOn:a,locale:o};return l.map(u=>{if(!u.isToken)return u.value;const d=u.value;(!n?.useAdditionalWeekYearTokens&&hy(d)||!n?.useAdditionalDayOfYearTokens&&my(d))&&gy(d,t,String(e));const h=Ya[d[0]];return h(i,d,o.localize,c)}).join("")}function ky(e){const t=e.match(xy);return t?t[1].replace(wy,"'"):e}function Sy(e,t){const n=Me(e,t?.in),r=n.getFullYear(),o=n.getMonth(),s=Le(n,0);return s.setFullYear(r,o+1,0),s.setHours(0,0,0,0),s.getDate()}function Cy(e,t){return Me(e,t?.in).getMonth()}function Ey(e,t){return Me(e,t?.in).getFullYear()}function My(e,t){return+Me(e)>+Me(t)}function Ty(e,t){return+Me(e)<+Me(t)}function Oy(e,t,n){const[r,o]=$n(n?.in,e,t);return r.getFullYear()===o.getFullYear()&&r.getMonth()===o.getMonth()}function Ny(e,t,n){const[r,o]=$n(n?.in,e,t);return r.getFullYear()===o.getFullYear()}function Ry(e,t,n){const r=Me(e,n?.in),o=r.getFullYear(),s=r.getDate(),a=Le(e,0);a.setFullYear(o,t,15),a.setHours(0,0,0,0);const i=Sy(a);return r.setMonth(t,Math.min(s,i)),r}function Dy(e,t,n){const r=Me(e,n?.in);return isNaN(+r)?Le(e,NaN):(r.setFullYear(t),r)}const qa=5,_y=4;function Py(e,t){const n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,o=t.addDays(e,-r+1),s=t.addDays(o,qa*7-1);return t.getMonth(e)===t.getMonth(s)?qa:_y}function ec(e,t){const n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-6):t.addDays(n,-1*(r-1))}function jy(e,t){const n=ec(e,t),r=Py(e,t);return t.addDays(n,r*7-1)}const tc={...vn,labels:{labelDayButton:(e,t,n,r)=>{let o;r&&typeof r.format=="function"?o=r.format.bind(r):o=(a,i)=>wt(a,i,{locale:vn,...n});let s=o(e,"PPPP");return t.today&&(s=`Today, ${s}`),t.selected&&(s=`${s}, selected`),s},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:"Choose the Year",labelGrid:(e,t,n)=>{let r;return n&&typeof n.format=="function"?r=n.format.bind(n):r=(o,s)=>wt(o,s,{locale:vn,...t}),r(e,"LLLL yyyy")},labelGridcell:(e,t,n,r)=>{let o;r&&typeof r.format=="function"?o=r.format.bind(r):o=(a,i)=>wt(a,i,{locale:vn,...n});let s=o(e,"PPPP");return t?.today&&(s=`Today, ${s}`),s},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(e,t,n)=>{let r;return n&&typeof n.format=="function"?r=n.format.bind(n):r=(o,s)=>wt(o,s,{locale:vn,...t}),r(e,"cccc")}}};class rt{constructor(t,n){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?ze.tz(this.options.timeZone):new this.Date,this.newDate=(r,o,s)=>this.overrides?.newDate?this.overrides.newDate(r,o,s):this.options.timeZone?new ze(r,o,s,this.options.timeZone):new Date(r,o,s),this.addDays=(r,o)=>this.overrides?.addDays?this.overrides.addDays(r,o):Ul(r,o),this.addMonths=(r,o)=>this.overrides?.addMonths?this.overrides.addMonths(r,o):Vl(r,o),this.addWeeks=(r,o)=>this.overrides?.addWeeks?this.overrides.addWeeks(r,o):pp(r,o),this.addYears=(r,o)=>this.overrides?.addYears?this.overrides.addYears(r,o):yp(r,o),this.differenceInCalendarDays=(r,o)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(r,o):ps(r,o),this.differenceInCalendarMonths=(r,o)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(r,o):zl(r,o),this.eachMonthOfInterval=r=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(r):Sp(r),this.eachYearOfInterval=r=>{const o=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(r):Mp(r),s=new Set(o.map(i=>this.getYear(i)));if(s.size===o.length)return o;const a=[];return s.forEach(i=>{a.push(new Date(i,0,1))}),a},this.endOfBroadcastWeek=r=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(r):jy(r,this),this.endOfISOWeek=r=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(r):Tp(r),this.endOfMonth=r=>this.overrides?.endOfMonth?this.overrides.endOfMonth(r):kp(r),this.endOfWeek=(r,o)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(r,o):Jl(r,this.options),this.endOfYear=r=>this.overrides?.endOfYear?this.overrides.endOfYear(r):Ep(r),this.format=(r,o,s)=>{const a=this.overrides?.format?this.overrides.format(r,o,this.options):wt(r,o,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(a):a},this.getISOWeek=r=>this.overrides?.getISOWeek?this.overrides.getISOWeek(r):ys(r),this.getMonth=(r,o)=>this.overrides?.getMonth?this.overrides.getMonth(r,this.options):Cy(r,this.options),this.getYear=(r,o)=>this.overrides?.getYear?this.overrides.getYear(r,this.options):Ey(r,this.options),this.getWeek=(r,o)=>this.overrides?.getWeek?this.overrides.getWeek(r,this.options):bs(r,this.options),this.isAfter=(r,o)=>this.overrides?.isAfter?this.overrides.isAfter(r,o):My(r,o),this.isBefore=(r,o)=>this.overrides?.isBefore?this.overrides.isBefore(r,o):Ty(r,o),this.isDate=r=>this.overrides?.isDate?this.overrides.isDate(r):Gl(r),this.isSameDay=(r,o)=>this.overrides?.isSameDay?this.overrides.isSameDay(r,o):wp(r,o),this.isSameMonth=(r,o)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(r,o):Oy(r,o),this.isSameYear=(r,o)=>this.overrides?.isSameYear?this.overrides.isSameYear(r,o):Ny(r,o),this.max=r=>this.overrides?.max?this.overrides.max(r):bp(r),this.min=r=>this.overrides?.min?this.overrides.min(r):xp(r),this.setMonth=(r,o)=>this.overrides?.setMonth?this.overrides.setMonth(r,o):Ry(r,o),this.setYear=(r,o)=>this.overrides?.setYear?this.overrides.setYear(r,o):Dy(r,o),this.startOfBroadcastWeek=(r,o)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(r,this):ec(r,this),this.startOfDay=r=>this.overrides?.startOfDay?this.overrides.startOfDay(r):rr(r),this.startOfISOWeek=r=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(r):nr(r),this.startOfMonth=r=>this.overrides?.startOfMonth?this.overrides.startOfMonth(r):Cp(r),this.startOfWeek=(r,o)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(r,this.options):Pn(r,this.options),this.startOfYear=r=>this.overrides?.startOfYear?this.overrides.startOfYear(r):Xl(r),this.options={locale:tc,...t},this.overrides=n}getDigitMap(){const{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),r={};for(let o=0;o<10;o++)r[o.toString()]=n.format(o);return r}replaceDigits(t){const n=this.getDigitMap();return t.replace(/\d/g,r=>n[r]||r)}formatNumber(t){return this.replaceDigits(t.toString())}getMonthYearOrder(){const t=this.options.locale?.code;return t&&rt.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){const{locale:n,timeZone:r,numerals:o}=this.options,s=n?.code;if(s&&rt.yearFirstLocales.has(s))try{return new Intl.DateTimeFormat(s,{month:"long",year:"numeric",timeZone:r,numberingSystem:o}).format(t)}catch{}const a=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(t,a)}}rt.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const St=new rt;class nc{constructor(t,n,r=St){this.date=t,this.displayMonth=n,this.outside=!!(n&&!r.isSameMonth(t,n)),this.dateLib=r,this.isoDate=r.format(t,"yyyy-MM-dd"),this.displayMonthId=r.format(n,"yyyy-MM"),this.dateMonthId=r.format(t,"yyyy-MM")}isEqualTo(t){return this.dateLib.isSameDay(t.date,this.date)&&this.dateLib.isSameMonth(t.displayMonth,this.displayMonth)}}class Ay{constructor(t,n){this.date=t,this.weeks=n}}class Iy{constructor(t,n){this.days=n,this.weekNumber=t}}function Fy(e){return G.createElement("button",{...e})}function Ly(e){return G.createElement("span",{...e})}function Wy(e){const{size:t=24,orientation:n="left",className:r}=e;return G.createElement("svg",{className:r,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&G.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&G.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&G.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&G.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function $y(e){const{day:t,modifiers:n,...r}=e;return G.createElement("td",{...r})}function By(e){const{day:t,modifiers:n,...r}=e,o=G.useRef(null);return G.useEffect(()=>{n.focused&&o.current?.focus()},[n.focused]),G.createElement("button",{ref:o,...r})}var re;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(re||(re={}));var _e;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(_e||(_e={}));var mt;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(mt||(mt={}));var Qe;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(Qe||(Qe={}));function Yy(e){const{options:t,className:n,components:r,classNames:o,...s}=e,a=[o[re.Dropdown],n].join(" "),i=t?.find(({value:l})=>l===s.value);return G.createElement("span",{"data-disabled":s.disabled,className:o[re.DropdownRoot]},G.createElement(r.Select,{className:a,...s},t?.map(({value:l,label:c,disabled:u})=>G.createElement(r.Option,{key:l,value:l,disabled:u},c))),G.createElement("span",{className:o[re.CaptionLabel],"aria-hidden":!0},i?.label,G.createElement(r.Chevron,{orientation:"down",size:18,className:o[re.Chevron]})))}function Hy(e){return G.createElement("div",{...e})}function Uy(e){return G.createElement("div",{...e})}function Vy(e){const{calendarMonth:t,displayIndex:n,...r}=e;return G.createElement("div",{...r},e.children)}function qy(e){const{calendarMonth:t,displayIndex:n,...r}=e;return G.createElement("div",{...r})}function Gy(e){return G.createElement("table",{...e})}function zy(e){return G.createElement("div",{...e})}const rc=f.createContext(void 0);function ur(){const e=f.useContext(rc);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function Ky(e){const{components:t}=ur();return G.createElement(t.Dropdown,{...e})}function Xy(e){const{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:o,...s}=e,{components:a,classNames:i,labels:{labelPrevious:l,labelNext:c}}=ur(),u=f.useCallback(h=>{o&&n?.(h)},[o,n]),d=f.useCallback(h=>{r&&t?.(h)},[r,t]);return G.createElement("nav",{...s},G.createElement(a.PreviousMonthButton,{type:"button",className:i[re.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":l(r),onClick:d},G.createElement(a.Chevron,{disabled:r?void 0:!0,className:i[re.Chevron],orientation:"left"})),G.createElement(a.NextMonthButton,{type:"button",className:i[re.NextMonthButton],tabIndex:o?void 0:-1,"aria-disabled":o?void 0:!0,"aria-label":c(o),onClick:u},G.createElement(a.Chevron,{disabled:o?void 0:!0,orientation:"right",className:i[re.Chevron]})))}function Jy(e){const{components:t}=ur();return G.createElement(t.Button,{...e})}function Qy(e){return G.createElement("option",{...e})}function Zy(e){const{components:t}=ur();return G.createElement(t.Button,{...e})}function eb(e){const{rootRef:t,...n}=e;return G.createElement("div",{...n,ref:t})}function tb(e){return G.createElement("select",{...e})}function nb(e){const{week:t,...n}=e;return G.createElement("tr",{...n})}function rb(e){return G.createElement("th",{...e})}function ob(e){return G.createElement("thead",{"aria-hidden":!0},G.createElement("tr",{...e}))}function sb(e){const{week:t,...n}=e;return G.createElement("th",{...n})}function ab(e){return G.createElement("th",{...e})}function ib(e){return G.createElement("tbody",{...e})}function lb(e){const{components:t}=ur();return G.createElement(t.Dropdown,{...e})}const cb=Object.freeze(Object.defineProperty({__proto__:null,Button:Fy,CaptionLabel:Ly,Chevron:Wy,Day:$y,DayButton:By,Dropdown:Yy,DropdownNav:Hy,Footer:Uy,Month:Vy,MonthCaption:qy,MonthGrid:Gy,Months:zy,MonthsDropdown:Ky,Nav:Xy,NextMonthButton:Jy,Option:Qy,PreviousMonthButton:Zy,Root:eb,Select:tb,Week:nb,WeekNumber:sb,WeekNumberHeader:ab,Weekday:rb,Weekdays:ob,Weeks:ib,YearsDropdown:lb},Symbol.toStringTag,{value:"Module"}));function Dt(e,t,n=!1,r=St){let{from:o,to:s}=e;const{differenceInCalendarDays:a,isSameDay:i}=r;return o&&s?(a(s,o)<0&&([o,s]=[s,o]),a(t,o)>=(n?1:0)&&a(s,t)>=(n?1:0)):!n&&s?i(s,t):!n&&o?i(o,t):!1}function xs(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function Kr(e){return!!(e&&typeof e=="object"&&"from"in e)}function ws(e){return!!(e&&typeof e=="object"&&"after"in e)}function vs(e){return!!(e&&typeof e=="object"&&"before"in e)}function oc(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function sc(e,t){return Array.isArray(e)&&e.every(t.isDate)}function _t(e,t,n=St){const r=Array.isArray(t)?t:[t],{isSameDay:o,differenceInCalendarDays:s,isAfter:a}=n;return r.some(i=>{if(typeof i=="boolean")return i;if(n.isDate(i))return o(e,i);if(sc(i,n))return i.some(l=>o(e,l));if(Kr(i))return Dt(i,e,!1,n);if(oc(i))return Array.isArray(i.dayOfWeek)?i.dayOfWeek.includes(e.getDay()):i.dayOfWeek===e.getDay();if(xs(i)){const l=s(i.before,e),c=s(i.after,e),u=l>0,d=c<0;return a(i.before,i.after)?d&&u:u||d}return ws(i)?s(e,i.after)>0:vs(i)?s(i.before,e)>0:typeof i=="function"?i(e):!1})}function ub(e,t,n,r,o){const{disabled:s,hidden:a,modifiers:i,showOutsideDays:l,broadcastCalendar:c,today:u=o.today()}=t,{isSameDay:d,isSameMonth:h,startOfMonth:g,isBefore:p,endOfMonth:y,isAfter:x}=o,v=n&&g(n),b=r&&y(r),w={[_e.focused]:[],[_e.outside]:[],[_e.disabled]:[],[_e.hidden]:[],[_e.today]:[]},S={};for(const C of e){const{date:k,displayMonth:T}=C,N=!!(T&&!h(k,T)),I=!!(v&&p(k,v)),M=!!(b&&x(k,b)),R=!!(s&&_t(k,s,o)),j=!!(a&&_t(k,a,o))||I||M||!c&&!l&&N||c&&l===!1&&N,E=d(k,u);N&&w.outside.push(C),R&&w.disabled.push(C),j&&w.hidden.push(C),E&&w.today.push(C),i&&Object.keys(i).forEach(F=>{const _=i?.[F];_&&_t(k,_,o)&&(S[F]?S[F].push(C):S[F]=[C])})}return C=>{const k={[_e.focused]:!1,[_e.disabled]:!1,[_e.hidden]:!1,[_e.outside]:!1,[_e.today]:!1},T={};for(const N in w){const I=w[N];k[N]=I.some(M=>M===C)}for(const N in S)T[N]=S[N].some(I=>I===C);return{...k,...T}}}function db(e,t,n={}){return Object.entries(e).filter(([,o])=>o===!0).reduce((o,[s])=>(n[s]?o.push(n[s]):t[_e[s]]?o.push(t[_e[s]]):t[mt[s]]&&o.push(t[mt[s]]),o),[t[re.Day]])}function fb(e){return{...cb,...e}}function mb(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,r])=>{n.startsWith("data-")&&(t[n]=r)}),t}function hb(){const e={};for(const t in re)e[re[t]]=`rdp-${re[t]}`;for(const t in _e)e[_e[t]]=`rdp-${_e[t]}`;for(const t in mt)e[mt[t]]=`rdp-${mt[t]}`;for(const t in Qe)e[Qe[t]]=`rdp-${Qe[t]}`;return e}function ac(e,t,n){return(n??new rt(t)).formatMonthYear(e)}const gb=ac;function pb(e,t,n){return(n??new rt(t)).format(e,"d")}function yb(e,t=St){return t.format(e,"LLLL")}function bb(e,t,n){return(n??new rt(t)).format(e,"cccccc")}function xb(e,t=St){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function wb(){return""}function ic(e,t=St){return t.format(e,"yyyy")}const vb=ic,kb=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:ac,formatDay:pb,formatMonthCaption:gb,formatMonthDropdown:yb,formatWeekNumber:xb,formatWeekNumberHeader:wb,formatWeekdayName:bb,formatYearCaption:vb,formatYearDropdown:ic},Symbol.toStringTag,{value:"Module"}));function Sb(e){return e?.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e?.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...kb,...e}}function ks(e,t,n,r){let o=(r??new rt(n)).format(e,"PPPP");return t.today&&(o=`Today, ${o}`),t.selected&&(o=`${o}, selected`),o}const Cb=ks;function Ss(e,t,n){return(n??new rt(t)).formatMonthYear(e)}const Eb=Ss;function lc(e,t,n,r){let o=(r??new rt(n)).format(e,"PPPP");return t?.today&&(o=`Today, ${o}`),o}function cc(e){return"Choose the Month"}function uc(){return""}const Mb="Go to the Next Month";function dc(e,t){return Mb}function fc(e){return"Go to the Previous Month"}function mc(e,t,n){return(n??new rt(t)).format(e,"cccc")}function hc(e,t){return`Week ${e}`}function gc(e){return"Week Number"}function pc(e){return"Choose the Year"}const Tb=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:Eb,labelDay:Cb,labelDayButton:ks,labelGrid:Ss,labelGridcell:lc,labelMonthDropdown:cc,labelNav:uc,labelNext:dc,labelPrevious:fc,labelWeekNumber:hc,labelWeekNumberHeader:gc,labelWeekday:mc,labelYearDropdown:pc},Symbol.toStringTag,{value:"Module"})),dt=(e,t,n)=>t||(n?typeof n=="function"?n:(...r)=>n:e);function Ob(e,t){const n=t.locale?.labels??{};return{...Tb,...e??{},labelDayButton:dt(ks,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:dt(cc,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:dt(dc,e?.labelNext,n.labelNext),labelPrevious:dt(fc,e?.labelPrevious,n.labelPrevious),labelWeekNumber:dt(hc,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:dt(pc,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:dt(Ss,e?.labelGrid,n.labelGrid),labelGridcell:dt(lc,e?.labelGridcell,n.labelGridcell),labelNav:dt(uc,e?.labelNav,n.labelNav),labelWeekNumberHeader:dt(gc,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:dt(mc,e?.labelWeekday,n.labelWeekday)}}function Nb(e,t,n,r,o){const{startOfMonth:s,startOfYear:a,endOfYear:i,eachMonthOfInterval:l,getMonth:c}=o;return l({start:a(e),end:i(e)}).map(h=>{const g=r.formatMonthDropdown(h,o),p=c(h),y=t&&h<s(t)||n&&h>s(n)||!1;return{value:p,label:g,disabled:y}})}function Rb(e,t={},n={}){let r={...t?.[re.Day]};return Object.entries(e).filter(([,o])=>o===!0).forEach(([o])=>{r={...r,...n?.[o]}}),r}function Db(e,t,n,r){const o=r??e.today(),s=n?e.startOfBroadcastWeek(o,e):t?e.startOfISOWeek(o):e.startOfWeek(o),a=[];for(let i=0;i<7;i++){const l=e.addDays(s,i);a.push(l)}return a}function _b(e,t,n,r,o=!1){if(!e||!t)return;const{startOfYear:s,endOfYear:a,eachYearOfInterval:i,getYear:l}=r,c=s(e),u=a(t),d=i({start:c,end:u});return o&&d.reverse(),d.map(h=>{const g=n.formatYearDropdown(h,r);return{value:l(h),label:g,disabled:!1}})}function Pb(e,t={}){const{weekStartsOn:n,locale:r}=t,o=n??r?.options?.weekStartsOn??0,s=i=>{const l=typeof i=="number"||typeof i=="string"?new Date(i):i;return new ze(l.getFullYear(),l.getMonth(),l.getDate(),12,0,0,e)},a=i=>{const l=s(i);return new Date(l.getFullYear(),l.getMonth(),l.getDate(),0,0,0,0)};return{today:()=>s(ze.tz(e)),newDate:(i,l,c)=>new ze(i,l,c,12,0,0,e),startOfDay:i=>s(i),startOfWeek:(i,l)=>{const c=s(i),u=l?.weekStartsOn??o,d=(c.getDay()-u+7)%7;return c.setDate(c.getDate()-d),c},startOfISOWeek:i=>{const l=s(i),c=(l.getDay()-1+7)%7;return l.setDate(l.getDate()-c),l},startOfMonth:i=>{const l=s(i);return l.setDate(1),l},startOfYear:i=>{const l=s(i);return l.setMonth(0,1),l},endOfWeek:(i,l)=>{const c=s(i),h=(((l?.weekStartsOn??o)+6)%7-c.getDay()+7)%7;return c.setDate(c.getDate()+h),c},endOfISOWeek:i=>{const l=s(i),c=(7-l.getDay())%7;return l.setDate(l.getDate()+c),l},endOfMonth:i=>{const l=s(i);return l.setMonth(l.getMonth()+1,0),l},endOfYear:i=>{const l=s(i);return l.setMonth(11,31),l},eachMonthOfInterval:i=>{const l=s(i.start),c=s(i.end),u=[],d=new ze(l.getFullYear(),l.getMonth(),1,12,0,0,e),h=c.getFullYear()*12+c.getMonth();for(;d.getFullYear()*12+d.getMonth()<=h;)u.push(new ze(d,e)),d.setMonth(d.getMonth()+1,1);return u},addDays:(i,l)=>{const c=s(i);return c.setDate(c.getDate()+l),c},addWeeks:(i,l)=>{const c=s(i);return c.setDate(c.getDate()+l*7),c},addMonths:(i,l)=>{const c=s(i);return c.setMonth(c.getMonth()+l),c},addYears:(i,l)=>{const c=s(i);return c.setFullYear(c.getFullYear()+l),c},eachYearOfInterval:i=>{const l=s(i.start),c=s(i.end),u=[],d=new ze(l.getFullYear(),0,1,12,0,0,e);for(;d.getFullYear()<=c.getFullYear();)u.push(new ze(d,e)),d.setFullYear(d.getFullYear()+1,0,1);return u},getWeek:(i,l)=>{const c=a(i);return bs(c,{weekStartsOn:l?.weekStartsOn??o,firstWeekContainsDate:l?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1})},getISOWeek:i=>{const l=a(i);return ys(l)},differenceInCalendarDays:(i,l)=>{const c=a(i),u=a(l);return ps(c,u)},differenceInCalendarMonths:(i,l)=>{const c=a(i),u=a(l);return zl(c,u)}}}const dr=e=>e instanceof HTMLElement?e:null,Do=e=>[...e.querySelectorAll("[data-animated-month]")??[]],jb=e=>dr(e.querySelector("[data-animated-month]")),_o=e=>dr(e.querySelector("[data-animated-caption]")),Po=e=>dr(e.querySelector("[data-animated-weeks]")),Ab=e=>dr(e.querySelector("[data-animated-nav]")),Ib=e=>dr(e.querySelector("[data-animated-weekdays]"));function Fb(e,t,{classNames:n,months:r,focused:o,dateLib:s}){const a=f.useRef(null),i=f.useRef(r),l=f.useRef(!1);f.useLayoutEffect(()=>{const c=i.current;if(i.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||c.length===0||r.length!==c.length)return;const u=s.isSameMonth(r[0].date,c[0].date),d=s.isAfter(r[0].date,c[0].date),h=d?n[Qe.caption_after_enter]:n[Qe.caption_before_enter],g=d?n[Qe.weeks_after_enter]:n[Qe.weeks_before_enter],p=a.current,y=e.current.cloneNode(!0);if(y instanceof HTMLElement?(Do(y).forEach(w=>{if(!(w instanceof HTMLElement))return;const S=jb(w);S&&w.contains(S)&&w.removeChild(S);const C=_o(w);C&&C.classList.remove(h);const k=Po(w);k&&k.classList.remove(g)}),a.current=y):a.current=null,l.current||u||o)return;const x=p instanceof HTMLElement?Do(p):[],v=Do(e.current);if(v?.every(b=>b instanceof HTMLElement)&&x&&x.every(b=>b instanceof HTMLElement)){l.current=!0,e.current.style.isolation="isolate";const b=Ab(e.current);b&&(b.style.zIndex="1"),v.forEach((w,S)=>{const C=x[S];if(!C)return;w.style.position="relative",w.style.overflow="hidden";const k=_o(w);k&&k.classList.add(h);const T=Po(w);T&&T.classList.add(g);const N=()=>{l.current=!1,e.current&&(e.current.style.isolation=""),b&&(b.style.zIndex=""),k&&k.classList.remove(h),T&&T.classList.remove(g),w.style.position="",w.style.overflow="",w.contains(C)&&w.removeChild(C)};C.style.pointerEvents="none",C.style.position="absolute",C.style.overflow="hidden",C.setAttribute("aria-hidden","true");const I=Ib(C);I&&(I.style.opacity="0");const M=_o(C);M&&(M.classList.add(d?n[Qe.caption_before_exit]:n[Qe.caption_after_exit]),M.addEventListener("animationend",N));const R=Po(C);R&&R.classList.add(d?n[Qe.weeks_before_exit]:n[Qe.weeks_after_exit]),w.insertBefore(C,w.firstChild)})}})}function Lb(e,t,n,r){const o=e[0],s=e[e.length-1],{ISOWeek:a,fixedWeeks:i,broadcastCalendar:l}=n??{},{addDays:c,differenceInCalendarDays:u,differenceInCalendarMonths:d,endOfBroadcastWeek:h,endOfISOWeek:g,endOfMonth:p,endOfWeek:y,isAfter:x,startOfBroadcastWeek:v,startOfISOWeek:b,startOfWeek:w}=r,S=l?v(o,r):a?b(o):w(o),C=l?h(s):a?g(p(s)):y(p(s)),k=t&&(l?h(t):a?g(t):y(t)),T=k&&x(C,k)?k:C,N=u(T,S),I=d(s,o)+1,M=[];for(let E=0;E<=N;E++){const F=c(S,E);M.push(F)}const j=(l?35:42)*I;if(i&&M.length<j){const E=j-M.length;for(let F=0;F<E;F++){const _=c(M[M.length-1],1);M.push(_)}}return M}function Wb(e){const t=[];return e.reduce((n,r)=>{const o=r.weeks.reduce((s,a)=>s.concat(a.days.slice()),t.slice());return n.concat(o.slice())},t.slice())}function $b(e,t,n,r){const{numberOfMonths:o=1}=n,s=[];for(let a=0;a<o;a++){const i=r.addMonths(e,a);if(t&&i>t)break;s.push(i)}return s}function Ga(e,t,n,r){const{month:o,defaultMonth:s,today:a=r.today(),numberOfMonths:i=1}=e;let l=o||s||a;const{differenceInCalendarMonths:c,addMonths:u,startOfMonth:d}=r;if(n&&c(n,l)<i-1){const h=-1*(i-1);l=u(n,h)}return t&&c(l,t)<0&&(l=t),d(l)}function Bb(e,t,n,r){const{addDays:o,endOfBroadcastWeek:s,endOfISOWeek:a,endOfMonth:i,endOfWeek:l,getISOWeek:c,getWeek:u,startOfBroadcastWeek:d,startOfISOWeek:h,startOfWeek:g}=r,p=e.reduce((y,x)=>{const v=n.broadcastCalendar?d(x,r):n.ISOWeek?h(x):g(x),b=n.broadcastCalendar?s(x):n.ISOWeek?a(i(x)):l(i(x)),w=t.filter(T=>T>=v&&T<=b),S=n.broadcastCalendar?35:42;if(n.fixedWeeks&&w.length<S){const T=t.filter(N=>{const I=S-w.length;return N>b&&N<=o(b,I)});w.push(...T)}const C=w.reduce((T,N)=>{const I=n.ISOWeek?c(N):u(N),M=T.find(j=>j.weekNumber===I),R=new nc(N,x,r);return M?M.days.push(R):T.push(new Iy(I,[R])),T},[]),k=new Ay(x,C);return y.push(k),y},[]);return n.reverseMonths?p.reverse():p}function Yb(e,t){let{startMonth:n,endMonth:r}=e;const{startOfYear:o,startOfDay:s,startOfMonth:a,endOfMonth:i,addYears:l,endOfYear:c,newDate:u,today:d}=t,{fromYear:h,toYear:g,fromMonth:p,toMonth:y}=e;!n&&p&&(n=p),!n&&h&&(n=t.newDate(h,0,1)),!r&&y&&(r=y),!r&&g&&(r=u(g,11,31));const x=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=a(n):h?n=u(h,0,1):!n&&x&&(n=o(l(e.today??d(),-100))),r?r=i(r):g?r=u(g,11,31):!r&&x&&(r=c(e.today??d())),[n&&s(n),r&&s(r)]}function Hb(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:o,numberOfMonths:s=1}=n,{startOfMonth:a,addMonths:i,differenceInCalendarMonths:l}=r,c=o?s:1,u=a(e);if(!t)return i(u,c);if(!(l(t,e)<s))return i(u,c)}function Ub(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:o,numberOfMonths:s}=n,{startOfMonth:a,addMonths:i,differenceInCalendarMonths:l}=r,c=o?s??1:1,u=a(e);if(!t)return i(u,-c);if(!(l(u,t)<=0))return i(u,-c)}function Vb(e){const t=[];return e.reduce((n,r)=>n.concat(r.weeks.slice()),t.slice())}function Xr(e,t){const[n,r]=f.useState(e);return[t===void 0?n:t,r]}function qb(e,t){const[n,r]=Yb(e,t),{startOfMonth:o,endOfMonth:s}=t,a=Ga(e,n,r,t),[i,l]=Xr(a,e.month?a:void 0);f.useEffect(()=>{const S=Ga(e,n,r,t);l(S)},[e.timeZone]);const{months:c,weeks:u,days:d,previousMonth:h,nextMonth:g}=f.useMemo(()=>{const S=$b(i,r,{numberOfMonths:e.numberOfMonths},t),C=Lb(S,e.endMonth?s(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),k=Bb(S,C,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),T=Vb(k),N=Wb(k),I=Ub(i,n,e,t),M=Hb(i,r,e,t);return{months:k,weeks:T,days:N,previousMonth:I,nextMonth:M}},[t,i.getTime(),r?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:p,onMonthChange:y}=e,x=S=>u.some(C=>C.days.some(k=>k.isEqualTo(S))),v=S=>{if(p)return;let C=o(S);n&&C<o(n)&&(C=o(n)),r&&C>o(r)&&(C=o(r)),l(C),y?.(C)};return{months:c,weeks:u,days:d,navStart:n,navEnd:r,previousMonth:h,nextMonth:g,goToMonth:v,goToDay:S=>{x(S)||v(S.date)}}}var pt;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(pt||(pt={}));function za(e){return!e[_e.disabled]&&!e[_e.hidden]&&!e[_e.outside]}function Gb(e,t,n,r){let o,s=-1;for(const a of e){const i=t(a);za(i)&&(i[_e.focused]&&s<pt.FocusedModifier?(o=a,s=pt.FocusedModifier):r?.isEqualTo(a)&&s<pt.LastFocused?(o=a,s=pt.LastFocused):n(a.date)&&s<pt.Selected?(o=a,s=pt.Selected):i[_e.today]&&s<pt.Today&&(o=a,s=pt.Today))}return o||(o=e.find(a=>za(t(a)))),o}function zb(e,t,n,r,o,s,a){const{ISOWeek:i,broadcastCalendar:l}=s,{addDays:c,addMonths:u,addWeeks:d,addYears:h,endOfBroadcastWeek:g,endOfISOWeek:p,endOfWeek:y,max:x,min:v,startOfBroadcastWeek:b,startOfISOWeek:w,startOfWeek:S}=a;let k={day:c,week:d,month:u,year:h,startOfWeek:T=>l?b(T,a):i?w(T):S(T),endOfWeek:T=>l?g(T):i?p(T):y(T)}[e](n,t==="after"?1:-1);return t==="before"&&r?k=x([r,k]):t==="after"&&o&&(k=v([o,k])),k}function yc(e,t,n,r,o,s,a,i=0){if(i>365)return;const l=zb(e,t,n.date,r,o,s,a),c=!!(s.disabled&&_t(l,s.disabled,a)),u=!!(s.hidden&&_t(l,s.hidden,a)),d=l,h=new nc(l,d,a);return!c&&!u?h:yc(e,t,h,r,o,s,a,i+1)}function Kb(e,t,n,r,o){const{autoFocus:s}=e,[a,i]=f.useState(),l=Gb(t.days,n,r||(()=>!1),a),[c,u]=f.useState(s?l:void 0);return{isFocusTarget:y=>!!l?.isEqualTo(y),setFocused:u,focused:c,blur:()=>{i(c),u(void 0)},moveFocus:(y,x)=>{if(!c)return;const v=yc(y,x,c,t.navStart,t.navEnd,e,o);v&&(e.disableNavigation&&!t.days.some(w=>w.isEqualTo(v))||(t.goToDay(v),u(v)))}}}function Xb(e,t){const{selected:n,required:r,onSelect:o}=e,[s,a]=Xr(n,o?n:void 0),i=o?n:s,{isSameDay:l}=t,c=g=>i?.some(p=>l(p,g))??!1,{min:u,max:d}=e;return{selected:i,select:(g,p,y)=>{let x=[...i??[]];if(c(g)){if(i?.length===u||r&&i?.length===1)return;x=i?.filter(v=>!l(v,g))}else i?.length===d?x=[g]:x=[...x,g];return o||a(x),o?.(x,g,p,y),x},isSelected:c}}function Jb(e,t,n=0,r=0,o=!1,s=St){const{from:a,to:i}=t||{},{isSameDay:l,isAfter:c,isBefore:u}=s;let d;if(!a&&!i)d={from:e,to:n>0?void 0:e};else if(a&&!i)l(a,e)?n===0?d={from:a,to:e}:o?d={from:a,to:void 0}:d=void 0:u(e,a)?d={from:e,to:a}:d={from:a,to:e};else if(a&&i)if(l(a,e)&&l(i,e))o?d={from:a,to:i}:d=void 0;else if(l(a,e))d={from:a,to:n>0?void 0:e};else if(l(i,e))d={from:e,to:n>0?void 0:e};else if(u(e,a))d={from:e,to:i};else if(c(e,a))d={from:a,to:e};else if(c(e,i))d={from:a,to:e};else throw new Error("Invalid range");if(d?.from&&d?.to){const h=s.differenceInCalendarDays(d.to,d.from);r>0&&h>r?d={from:e,to:void 0}:n>1&&h<n&&(d={from:e,to:void 0})}return d}function Qb(e,t,n=St){const r=Array.isArray(t)?t:[t];let o=e.from;const s=n.differenceInCalendarDays(e.to,e.from),a=Math.min(s,6);for(let i=0;i<=a;i++){if(r.includes(o.getDay()))return!0;o=n.addDays(o,1)}return!1}function Ka(e,t,n=St){return Dt(e,t.from,!1,n)||Dt(e,t.to,!1,n)||Dt(t,e.from,!1,n)||Dt(t,e.to,!1,n)}function Zb(e,t,n=St){const r=Array.isArray(t)?t:[t];if(r.filter(i=>typeof i!="function").some(i=>typeof i=="boolean"?i:n.isDate(i)?Dt(e,i,!1,n):sc(i,n)?i.some(l=>Dt(e,l,!1,n)):Kr(i)?i.from&&i.to?Ka(e,{from:i.from,to:i.to},n):!1:oc(i)?Qb(e,i.dayOfWeek,n):xs(i)?n.isAfter(i.before,i.after)?Ka(e,{from:n.addDays(i.after,1),to:n.addDays(i.before,-1)},n):_t(e.from,i,n)||_t(e.to,i,n):ws(i)||vs(i)?_t(e.from,i,n)||_t(e.to,i,n):!1))return!0;const a=r.filter(i=>typeof i=="function");if(a.length){let i=e.from;const l=n.differenceInCalendarDays(e.to,e.from);for(let c=0;c<=l;c++){if(a.some(u=>u(i)))return!0;i=n.addDays(i,1)}}return!1}function e0(e,t){const{disabled:n,excludeDisabled:r,resetOnSelect:o,selected:s,required:a,onSelect:i}=e,[l,c]=Xr(s,i?s:void 0),u=i?s:l;return{selected:u,select:(g,p,y)=>{const{min:x,max:v}=e;let b;if(g){const w=u?.from,S=u?.to,C=!!w&&!!S,k=!!w&&!!S&&t.isSameDay(w,S)&&t.isSameDay(g,w);o&&(C||!u?.from)?!a&&k?b=void 0:b={from:g,to:void 0}:b=Jb(g,u,x,v,a,t)}return r&&n&&b?.from&&b.to&&Zb({from:b.from,to:b.to},n,t)&&(b.from=g,b.to=void 0),i||c(b),i?.(b,g,p,y),b},isSelected:g=>u&&Dt(u,g,!1,t)}}function t0(e,t){const{selected:n,required:r,onSelect:o}=e,[s,a]=Xr(n,o?n:void 0),i=o?n:s,{isSameDay:l}=t;return{selected:i,select:(d,h,g)=>{let p=d;return!r&&i&&i&&l(d,i)&&(p=void 0),o||a(p),o?.(p,d,h,g),p},isSelected:d=>i?l(i,d):!1}}function n0(e,t){const n=t0(e,t),r=Xb(e,t),o=e0(e,t);switch(e.mode){case"single":return n;case"multiple":return r;case"range":return o;default:return}}function st(e,t){return e instanceof ze&&e.timeZone===t?e:new ze(e,t)}function bn(e,t,n){return st(e,t)}function Xa(e,t,n){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?bn(e,t):Array.isArray(e)?e.map(r=>r instanceof Date?bn(r,t):r):Kr(e)?{...e,from:e.from?st(e.from,t):e.from,to:e.to?st(e.to,t):e.to}:xs(e)?{before:bn(e.before,t),after:bn(e.after,t)}:ws(e)?{after:bn(e.after,t)}:vs(e)?{before:bn(e.before,t)}:e}function jo(e,t,n){return e&&(Array.isArray(e)?e.map(r=>Xa(r,t)):Xa(e,t))}function r0(e){let t=e;const n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=st(t.today,n)),t.month&&(t.month=st(t.month,n)),t.defaultMonth&&(t.defaultMonth=st(t.defaultMonth,n)),t.startMonth&&(t.startMonth=st(t.startMonth,n)),t.endMonth&&(t.endMonth=st(t.endMonth,n)),t.mode==="single"&&t.selected?t.selected=st(t.selected,n):t.mode==="multiple"&&t.selected?t.selected=t.selected?.map(K=>st(K,n)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?st(t.selected.from,n):t.selected.from,to:t.selected.to?st(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=jo(t.disabled,n)),t.hidden!==void 0&&(t.hidden=jo(t.hidden,n)),t.modifiers)){const K={};Object.keys(t.modifiers).forEach(le=>{K[le]=jo(t.modifiers?.[le],n)}),t.modifiers=K}const{components:r,formatters:o,labels:s,dateLib:a,locale:i,classNames:l}=f.useMemo(()=>{const K={...tc,...t.locale},le=t.broadcastCalendar?1:t.weekStartsOn,Q=t.noonSafe&&t.timeZone?Pb(t.timeZone,{weekStartsOn:le,locale:K}):void 0,fe=t.dateLib&&Q?{...Q,...t.dateLib}:t.dateLib??Q,je=new rt({locale:K,weekStartsOn:le,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},fe);return{dateLib:je,components:fb(t.components),formatters:Sb(t.formatters),labels:Ob(t.labels,je.options),locale:K,classNames:{...hb(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:a.today()});const{captionLayout:c,mode:u,navLayout:d,numberOfMonths:h=1,onDayBlur:g,onDayClick:p,onDayFocus:y,onDayKeyDown:x,onDayMouseEnter:v,onDayMouseLeave:b,onNextClick:w,onPrevClick:S,showWeekNumber:C,styles:k}=t,{formatCaption:T,formatDay:N,formatMonthDropdown:I,formatWeekNumber:M,formatWeekNumberHeader:R,formatWeekdayName:j,formatYearDropdown:E}=o,F=qb(t,a),{days:_,months:B,navStart:V,navEnd:O,previousMonth:P,nextMonth:U,goToMonth:Y}=F,ee=ub(_,t,V,O,a),{isSelected:H,select:L,selected:z}=n0(t,a)??{},{blur:X,focused:oe,isFocusTarget:be,moveFocus:Oe,setFocused:xe}=Kb(t,F,ee,H??(()=>!1),a),{labelDayButton:We,labelGridcell:D,labelGrid:ae,labelMonthDropdown:q,labelNav:ye,labelPrevious:$,labelNext:J,labelWeekday:ie,labelWeekNumber:he,labelWeekNumberHeader:de,labelYearDropdown:se}=s,Z=f.useMemo(()=>Db(a,t.ISOWeek,t.broadcastCalendar,t.today),[a,t.ISOWeek,t.broadcastCalendar,t.today]),De=u!==void 0||p!==void 0,ke=f.useCallback(()=>{P&&(Y(P),S?.(P))},[P,Y,S]),Ie=f.useCallback(()=>{U&&(Y(U),w?.(U))},[Y,U,w]),pe=f.useCallback((K,le)=>Q=>{Q.preventDefault(),Q.stopPropagation(),xe(K),!le.disabled&&(L?.(K.date,le,Q),p?.(K.date,le,Q))},[L,p,xe]),Je=f.useCallback((K,le)=>Q=>{xe(K),y?.(K.date,le,Q)},[y,xe]),Fe=f.useCallback((K,le)=>Q=>{X(),g?.(K.date,le,Q)},[X,g]),Se=f.useCallback((K,le)=>Q=>{const fe={ArrowLeft:[Q.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[Q.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[Q.shiftKey?"year":"week","after"],ArrowUp:[Q.shiftKey?"year":"week","before"],PageUp:[Q.shiftKey?"year":"month","before"],PageDown:[Q.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(fe[Q.key]){Q.preventDefault(),Q.stopPropagation();const[je,ue]=fe[Q.key];Oe(je,ue)}x?.(K.date,le,Q)},[Oe,x,t.dir]),Ue=f.useCallback((K,le)=>Q=>{v?.(K.date,le,Q)},[v]),He=f.useCallback((K,le)=>Q=>{b?.(K.date,le,Q)},[b]),It=f.useCallback(K=>le=>{const Q=Number(le.target.value),fe=a.setMonth(a.startOfMonth(K),Q);Y(fe)},[a,Y]),Ft=f.useCallback(K=>le=>{const Q=Number(le.target.value),fe=a.setYear(a.startOfMonth(K),Q);Y(fe)},[a,Y]),{className:Lt,style:Wt}=f.useMemo(()=>({className:[l[re.Root],t.className].filter(Boolean).join(" "),style:{...k?.[re.Root],...t.style}}),[l,t.className,t.style,k]),ot=mb(t),Ce=f.useRef(null);Fb(Ce,!!t.animate,{classNames:l,months:B,focused:oe,dateLib:a});const Te={dayPickerProps:t,selected:z,select:L,isSelected:H,months:B,nextMonth:U,previousMonth:P,goToMonth:Y,getModifiers:ee,components:r,classNames:l,styles:k,labels:s,formatters:o};return G.createElement(rc.Provider,{value:Te},G.createElement(r.Root,{rootRef:t.animate?Ce:void 0,className:Lt,style:Wt,dir:t.dir,id:t.id,lang:t.lang??i.code,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...ot},G.createElement(r.Months,{className:l[re.Months],style:k?.[re.Months]},!t.hideNavigation&&!d&&G.createElement(r.Nav,{"data-animated-nav":t.animate?"true":void 0,className:l[re.Nav],style:k?.[re.Nav],"aria-label":ye(),onPreviousClick:ke,onNextClick:Ie,previousMonth:P,nextMonth:U}),B.map((K,le)=>G.createElement(r.Month,{"data-animated-month":t.animate?"true":void 0,className:l[re.Month],style:k?.[re.Month],key:le,displayIndex:le,calendarMonth:K},d==="around"&&!t.hideNavigation&&le===0&&G.createElement(r.PreviousMonthButton,{type:"button",className:l[re.PreviousMonthButton],tabIndex:P?void 0:-1,"aria-disabled":P?void 0:!0,"aria-label":$(P),onClick:ke,"data-animated-button":t.animate?"true":void 0},G.createElement(r.Chevron,{disabled:P?void 0:!0,className:l[re.Chevron],orientation:t.dir==="rtl"?"right":"left"})),G.createElement(r.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:l[re.MonthCaption],style:k?.[re.MonthCaption],calendarMonth:K,displayIndex:le},c?.startsWith("dropdown")?G.createElement(r.DropdownNav,{className:l[re.Dropdowns],style:k?.[re.Dropdowns]},(()=>{const Q=c==="dropdown"||c==="dropdown-months"?G.createElement(r.MonthsDropdown,{key:"month",className:l[re.MonthsDropdown],"aria-label":q(),classNames:l,components:r,disabled:!!t.disableNavigation,onChange:It(K.date),options:Nb(K.date,V,O,o,a),style:k?.[re.Dropdown],value:a.getMonth(K.date)}):G.createElement("span",{key:"month"},I(K.date,a)),fe=c==="dropdown"||c==="dropdown-years"?G.createElement(r.YearsDropdown,{key:"year",className:l[re.YearsDropdown],"aria-label":se(a.options),classNames:l,components:r,disabled:!!t.disableNavigation,onChange:Ft(K.date),options:_b(V,O,o,a,!!t.reverseYears),style:k?.[re.Dropdown],value:a.getYear(K.date)}):G.createElement("span",{key:"year"},E(K.date,a));return a.getMonthYearOrder()==="year-first"?[fe,Q]:[Q,fe]})(),G.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},T(K.date,a.options,a))):G.createElement(r.CaptionLabel,{className:l[re.CaptionLabel],role:"status","aria-live":"polite"},T(K.date,a.options,a))),d==="around"&&!t.hideNavigation&&le===h-1&&G.createElement(r.NextMonthButton,{type:"button",className:l[re.NextMonthButton],tabIndex:U?void 0:-1,"aria-disabled":U?void 0:!0,"aria-label":J(U),onClick:Ie,"data-animated-button":t.animate?"true":void 0},G.createElement(r.Chevron,{disabled:U?void 0:!0,className:l[re.Chevron],orientation:t.dir==="rtl"?"left":"right"})),le===h-1&&d==="after"&&!t.hideNavigation&&G.createElement(r.Nav,{"data-animated-nav":t.animate?"true":void 0,className:l[re.Nav],style:k?.[re.Nav],"aria-label":ye(),onPreviousClick:ke,onNextClick:Ie,previousMonth:P,nextMonth:U}),G.createElement(r.MonthGrid,{role:"grid","aria-multiselectable":u==="multiple"||u==="range","aria-label":ae(K.date,a.options,a)||void 0,className:l[re.MonthGrid],style:k?.[re.MonthGrid]},!t.hideWeekdays&&G.createElement(r.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:l[re.Weekdays],style:k?.[re.Weekdays]},C&&G.createElement(r.WeekNumberHeader,{"aria-label":de(a.options),className:l[re.WeekNumberHeader],style:k?.[re.WeekNumberHeader],scope:"col"},R()),Z.map(Q=>G.createElement(r.Weekday,{"aria-label":ie(Q,a.options,a),className:l[re.Weekday],key:String(Q),style:k?.[re.Weekday],scope:"col"},j(Q,a.options,a)))),G.createElement(r.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:l[re.Weeks],style:k?.[re.Weeks]},K.weeks.map(Q=>G.createElement(r.Week,{className:l[re.Week],key:Q.weekNumber,style:k?.[re.Week],week:Q},C&&G.createElement(r.WeekNumber,{week:Q,style:k?.[re.WeekNumber],"aria-label":he(Q.weekNumber,{locale:i}),className:l[re.WeekNumber],scope:"row",role:"rowheader"},M(Q.weekNumber,a)),Q.days.map(fe=>{const{date:je}=fe,ue=ee(fe);if(ue[_e.focused]=!ue.hidden&&!!oe?.isEqualTo(fe),ue[mt.selected]=H?.(je)||ue.selected,Kr(z)){const{from:Ve,to:Et}=z;ue[mt.range_start]=!!(Ve&&Et&&a.isSameDay(je,Ve)),ue[mt.range_end]=!!(Ve&&Et&&a.isSameDay(je,Et)),ue[mt.range_middle]=Dt(z,je,!0,a)}const gt=Rb(ue,k,t.modifiersStyles),zt=db(ue,l,t.modifiersClassNames),Ct=!De&&!ue.hidden?D(je,ue,a.options,a):void 0;return G.createElement(r.Day,{key:`${fe.isoDate}_${fe.displayMonthId}`,day:fe,modifiers:ue,className:zt.join(" "),style:gt,role:"gridcell","aria-selected":ue.selected||void 0,"aria-label":Ct,"data-day":fe.isoDate,"data-month":fe.outside?fe.dateMonthId:void 0,"data-selected":ue.selected||void 0,"data-disabled":ue.disabled||void 0,"data-hidden":ue.hidden||void 0,"data-outside":fe.outside||void 0,"data-focused":ue.focused||void 0,"data-today":ue.today||void 0},!ue.hidden&&De?G.createElement(r.DayButton,{className:l[re.DayButton],style:k?.[re.DayButton],type:"button",day:fe,modifiers:ue,disabled:!ue.focused&&ue.disabled||void 0,"aria-disabled":ue.focused&&ue.disabled||void 0,tabIndex:be(fe)?0:-1,"aria-label":We(je,ue,a.options,a),onClick:pe(fe,ue),onBlur:Fe(fe,ue),onFocus:Je(fe,ue),onKeyDown:Se(fe,ue),onMouseEnter:Ue(fe,ue),onMouseLeave:He(fe,ue)},N(je,a.options,a)):!ue.hidden&&N(fe.date,a.options,a))})))))))),t.footer&&G.createElement(r.Footer,{className:l[re.Footer],style:k?.[re.Footer],role:"status","aria-live":"polite"},t.footer)))}function Ja(e){if(!e)return"";const t=e.split("-");if(t.length!==3)return e;const n=new Date(Number(t[0]),Number(t[1])-1,Number(t[2]));return Number.isFinite(n.getTime())?wt(n,"MMM d"):e}function o0({from:e,to:t,onApply:n,onCancel:r}){const o=f.useMemo(()=>{const c={from:void 0,to:void 0};if(e){const u=e.split("-");c.from=new Date(Number(u[0]),Number(u[1])-1,Number(u[2]))}if(t){const u=t.split("-");c.to=new Date(Number(u[0]),Number(u[1])-1,Number(u[2]))}return c},[e,t]),[s,a]=f.useState(o),i=()=>{if(!s?.from)return;const c=wt(s.from,"yyyy-MM-dd"),u=s.to?wt(s.to,"yyyy-MM-dd"):c;n?.(c,u)},l=!!s?.from;return m.jsxs("div",{className:"p-4",children:[m.jsx(r0,{mode:"range",selected:s,onSelect:a,numberOfMonths:2,showOutsideDays:!1,classNames:{root:"rdp-oai",months:"flex gap-4",month:"space-y-3",month_caption:"flex justify-center items-center h-8",caption_label:"text-sm font-medium text-oai-black dark:text-oai-white",nav:"flex items-center justify-between absolute inset-x-0 top-0 px-2",button_previous:"inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",button_next:"inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",chevron:"w-4 h-4",month_grid:"border-collapse",weekdays:"flex",weekday:"w-9 text-center text-xs font-medium text-oai-gray-400 dark:text-oai-gray-500 py-1",week:"flex",day:"w-9 h-9 text-center text-sm p-0 relative",day_button:"w-full h-full inline-flex items-center justify-center rounded-md transition-colors hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 text-oai-black dark:text-oai-white cursor-pointer rdp-day-btn",today:"font-bold",selected:"rdp-selected",range_start:"rdp-selected rdp-range-start",range_end:"rdp-selected rdp-range-end",range_middle:"rdp-range-mid",outside:"text-oai-gray-300 dark:text-oai-gray-600",disabled:"text-oai-gray-300 dark:text-oai-gray-600 cursor-not-allowed",hidden:"invisible"},styles:{months:{position:"relative"}}}),m.jsxs("div",{className:"flex items-center justify-end gap-2 mt-4 pt-3 border-t border-oai-gray-200 dark:border-oai-gray-700",children:[l&&s.from&&m.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mr-auto",children:[wt(s.from,"MMM d, yyyy"),s.to&&s.to.getTime()!==s.from.getTime()?` — ${wt(s.to,"MMM d, yyyy")}`:""]}),m.jsx(tr,{variant:"secondary",size:"sm",onClick:r,children:"Cancel"}),m.jsx(tr,{variant:"primary",size:"sm",onClick:i,disabled:!l,children:"Apply"})]})]})}function s0({size:e=16,className:t=""}){return m.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:t,children:m.jsx("path",{d:"M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z"})})}function a0({size:e=16,className:t=""}){return m.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",className:t,children:m.jsx("path",{d:"M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z"})})}function i0({size:e=16,className:t=""}){return m.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:t,children:m.jsx("path",{d:"M22.106 5.68L12.5.135a.998.998 0 00-.998 0L1.893 5.68a.84.84 0 00-.419.726v11.186c0 .3.16.577.42.727l9.607 5.547a.999.999 0 00.998 0l9.608-5.547a.84.84 0 00.42-.727V6.407a.84.84 0 00-.42-.726zm-.603 1.176L12.228 22.92c-.063.108-.228.064-.228-.061V12.34a.59.59 0 00-.295-.51l-9.11-5.26c-.107-.062-.063-.228.062-.228h18.55c.264 0 .428.286.296.514z"})})}function l0({size:e=16,className:t=""}){return m.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:t,children:m.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z"})})}function c0({size:e=16,className:t=""}){return m.jsx("svg",{width:e,height:e,viewBox:"0 -1 22 28",fill:"currentColor",fillRule:"evenodd",className:t,children:m.jsx("path",{d:"M4.125 20.149c-2.69 5.959 3.036 7.453 7.26 3.966 1.24 3.91 5.898.993 7.569-2.036 3.682-6.678 2.195-13.49 1.813-14.895-2.617-9.582-15.699-9.592-17.95.049-.526 1.687-.535 3.606-.833 5.598-.15 1.005-.256 1.646-.645 2.703-.223.607-.53 1.147-1.014 2.056-.75 1.412-.434 4.138 3.434 2.724v.001ZM11.895 11.332c-1.073 0-1.234-1.283-1.234-2.048 0-.69.124-1.239.358-1.586a1 1 0 0 1 .876-.462c.375 0 .697.158.924.47.259.354.395.9.395 1.578 0 1.283-.493 2.048-1.319 2.048Zm4.416 0c-1.073 0-1.234-1.283-1.234-2.048 0-.69.124-1.239.358-1.586a1 1 0 0 1 .876-.462c.375 0 .697.158.924.47.259.354.396.9.396 1.578 0 1.283-.494 2.048-1.32 2.048Z"})})}function u0({size:e=16,className:t=""}){return m.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:t,children:m.jsx("path",{d:"M16 6H8v12h8V6zm4 16H4V2h16v20z"})})}const d0={CLAUDE:s0,CODEX:a0,CURSOR:i0,GEMINI:l0,KIRO:c0,OPENCODE:u0};function Qa({provider:e,size:t=16,color:n,className:r=""}){const o=e?.toUpperCase?.()||"",s=d0[o];return s?m.jsx(s,{size:t,className:r}):m.jsx("div",{className:"rounded-full shrink-0",style:{width:t*.5,height:t*.5,backgroundColor:n}})}function f0(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?{key:t,label:t.toUpperCase()}:{key:t.key,label:t.label||String(t.key).toUpperCase()}):[]}function m0(e){if(typeof e!="string")return null;const t=e.replace(/,/g,"").match(/-?\d+(?:\.\d+)?/);if(!t)return null;const n=Number(t[0]);return Number.isFinite(n)?n:null}const h0={CODEX:"#10b981",CLAUDE:"#8b5cf6",OPENCODE:"#f59e0b",GEMINI:"#3b82f6"};function Ao(e,t){const n=e?.toUpperCase?.()||"";return h0[n]||`hsl(${150+t*40}, 60%, 45%)`}function g0({loading:e,onClick:t}){const n=Ur();return m.jsx(tr,{variant:"secondary",size:"sm",disabled:e,onClick:t,"aria-label":"Refresh data",className:"w-8 p-0",children:m.jsx(vt.span,{"aria-hidden":"true",animate:e?{rotate:360}:{rotate:0},transition:e&&!n?{duration:1,repeat:1/0,ease:"linear"}:{duration:.3},style:{display:"inline-block"},children:"↻"})})}function p0({period:e,periods:t,onPeriodChange:n,summaryValue:r,summaryLabel:o,summaryCostValue:s,onCostInfo:a,fleetData:i=[],onRefresh:l,loading:c,className:u="",customFrom:d,customTo:h,onCustomRangeApply:g,customRangeOpen:p,onCustomRangeOpenChange:y}){const x=f0(t),v=m0(String(r??"")),b=v!=null,[w,S]=f.useState(null),{resolvedTheme:C}=ts(),k=C==="dark",T=k?"rgba(10,10,10,0.98)":"rgba(255,255,255,0.96)",N=k?"rgba(10,10,10,0)":"rgba(255,255,255,0)",I=i.filter(M=>M.models?.length>0);return m.jsx(Mn,{delay:.2,children:m.jsxs(zr,{className:u,children:[m.jsxs("div",{className:"flex items-center justify-between gap-3 mb-6",children:[m.jsx("div",{role:"tablist","aria-label":"Time period",className:"flex gap-1",children:x.map(M=>{const R=e===M.key,j=`text-xs font-medium px-3 py-1.5 rounded-md transition-colors ${R?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800"}`;if(M.key==="custom"){const E=R&&d&&h?`${Ja(d)} — ${Ja(h)}`:M.label;return m.jsxs(ep,{open:p,onOpenChange:F=>{F?n?.("custom"):y?.(F)},children:[m.jsx(np,{render:m.jsx("button",{role:"tab","aria-selected":R,type:"button",className:j}),children:E}),m.jsx(op,{children:m.jsx(ap,{sideOffset:8,side:"bottom",align:"start",className:"!z-[9999]",children:m.jsx(lp,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:m.jsx(o0,{from:d,to:h,onApply:g,onCancel:()=>y?.(!1)})})})})]},"custom")}return m.jsx("button",{role:"tab","aria-selected":R,type:"button",className:j,onClick:()=>n?.(M.key),children:M.label},M.key)})}),m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsxs(mi,{to:"/leaderboard",className:"inline-flex items-center justify-center gap-1.5 h-8 px-3 text-xs font-medium rounded-md no-underline border border-oai-gray-300 dark:border-oai-gray-700 bg-oai-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white hover:border-oai-brand hover:text-oai-brand transition-colors duration-200",children:[m.jsx(kd,{className:"h-3.5 w-3.5",strokeWidth:2}),"Leaderboard"]}),l&&m.jsx(g0,{loading:c,onClick:l})]})]}),m.jsxs("div",{className:"text-center mb-8",children:[m.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wider mb-3",children:o}),m.jsx("div",{className:"text-6xl md:text-7xl font-bold text-oai-black dark:text-oai-white tracking-tight tabular-nums",children:b?m.jsx(Dg,{value:v,displayValue:r,fontSize:72,padding:6,gap:1,textColor:"var(--oai-black, #111827)",fontWeight:700,gradientHeight:k?0:8,gradientFrom:T,gradientTo:N,counterStyle:{paddingLeft:0,paddingRight:0,gap:0},digitStyle:{width:"0.88ch"}}):r}),s&&m.jsx("div",{className:"flex items-center justify-center gap-2 mt-4",children:a?m.jsxs("button",{type:"button",onClick:a,className:"inline-flex items-center gap-1.5 text-xl font-bold text-oai-brand hover:text-oai-brand-dark dark:hover:text-oai-brand-light transition-colors cursor-pointer","aria-label":"View cost breakdown",children:[s,m.jsx(wd,{size:16,strokeWidth:2,className:"text-oai-gray-400 dark:text-oai-gray-500"})]}):m.jsx("span",{className:"text-xl font-bold text-oai-brand",children:s})})]}),I.length>0&&m.jsxs("div",{className:"space-y-6",children:[m.jsx("div",{role:"img","aria-label":`Provider distribution: ${I.map(M=>`${M.label} ${M.totalPercent}%`).join(", ")}`,className:"h-1.5 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden flex",children:I.map((M,R)=>{const j=Ao(M.label,R);return m.jsx(vt.div,{initial:{width:0},animate:{width:`${M.totalPercent}%`},transition:{duration:.6,delay:.3+R*.1},className:"h-full",style:{backgroundColor:j},title:`${M.label}: ${M.totalPercent}%`},M.label)})}),m.jsx("div",{className:"flex flex-wrap gap-3",children:I.map((M,R)=>{const j=Ao(M.label,R),E=w===M.label;return m.jsxs("button",{"aria-expanded":E,"aria-controls":`provider-details-${M.label}`,"aria-label":`${M.label}: ${M.totalPercent}%. Click to ${E?"collapse":"expand"} details`,onClick:()=>S(E?null:M.label),className:`flex-1 min-w-[140px] text-left p-3 rounded-lg border transition-colors duration-200 ${E?"border-oai-gray-300 dark:border-oai-gray-600 bg-oai-gray-50 dark:bg-oai-gray-800":"border-oai-gray-200 dark:border-oai-gray-700 hover:border-oai-gray-300 dark:hover:border-oai-gray-600"}`,children:[m.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[m.jsx(Qa,{provider:M.label,size:15,color:j,className:"text-oai-gray-700 dark:text-oai-gray-300 shrink-0"}),m.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:M.label})]}),m.jsxs("div",{className:"text-lg font-semibold text-oai-black dark:text-oai-white tabular-nums",children:[M.totalPercent,"%"]}),m.jsxs("div",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:[M.models.length," models"]})]},M.label)})}),w&&m.jsx("div",{id:`provider-details-${w}`,role:"region","aria-label":`${w} model details`,className:"border border-oai-gray-200 dark:border-oai-gray-700 rounded-lg p-4 bg-oai-gray-50/30 dark:bg-oai-gray-800/30 overflow-hidden",children:I.filter(M=>M.label===w).map(M=>{const R=Ao(M.label,0),j=[...M.models].sort((E,F)=>(F.share||0)-(E.share||0));return m.jsxs("div",{children:[m.jsxs("div",{className:"flex items-center gap-1.5 mb-3",children:[m.jsx(Qa,{provider:M.label,size:15,color:R,className:"text-oai-gray-700 dark:text-oai-gray-300 shrink-0"}),m.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:M.label}),m.jsxs("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400",children:[M.totalPercent,"%"]})]}),m.jsx("div",{className:"space-y-2",children:j.map(E=>m.jsx("div",{className:"flex items-center gap-3",children:m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[m.jsx("span",{className:"text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate",children:E.name}),m.jsxs("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white tabular-nums shrink-0",children:[E.share,"%"]})]}),m.jsx("div",{className:"h-1 bg-oai-gray-200 dark:bg-oai-gray-700 rounded-full overflow-hidden",children:m.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${E.share}%`,backgroundColor:R,opacity:.7}})})]})},E.id||E.name))})]},M.label)})})]})]})})}function Za(e,t){if(!Array.isArray(e)||e.length===0)return 0;if(e.length===1)return e[0];const n=(e.length-1)*t,r=Math.floor(n),o=Math.ceil(n);if(r===o)return e[r];const s=n-r;return e[r]+(e[o]-e[r])*s}function y0(e){const t=Array.isArray(e)?e.filter(o=>Number.isFinite(o)&&o>0).sort((o,s)=>o-s):[];if(t.length===0)return{rawMax:0,effectiveMax:1,clippedValues:Array.isArray(e)?e.map(()=>0):[]};const n=t.at(-1)??0;let r=n;if(t.length>=4){const o=Za(t,.25),s=Za(t,.75),a=Math.max(s-o,0),i=s+a*1.5;n>i&&(r=Math.max(i,s,1))}return{rawMax:n,effectiveMax:Math.max(r,1),clippedValues:Array.isArray(e)?e.map(o=>!Number.isFinite(o)||o<=0?0:Math.min(o,Math.max(r,1))):[]}}function b0({value:e,displayValue:t,scale:n,index:r,row:o,totalBars:s}){const a=Ur(),i=n.effectiveMax>0?t/n.effectiveMax*100:0,l=`${Math.max(i,2)}%`,c=o?.missing,u=o?.future,d=s<=7?"6px":s<=14?"4px":"3px";return m.jsx(vt.div,{className:"group relative flex-1 self-stretch",initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},transition:{duration:a?0:.3,delay:a?0:r*.02,ease:[.25,.1,.25,1]},style:{originY:1},children:m.jsxs("div",{className:"absolute inset-x-0 bottom-0",style:{height:l},children:[m.jsx("div",{"data-trend-bar":"true",className:"h-full w-full cursor-pointer transition-all duration-200 group-hover:brightness-110",style:{minHeight:e>0?"4px":"2px",opacity:c||u?.2:1,borderRadius:`${d} ${d} 0 0`,background:e>0?"#10b981":"var(--oai-gray-100)"},title:`${e.toLocaleString()}`}),m.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-oai-black text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-20",children:e.toLocaleString()})]})})}function x0({rows:e,from:t,to:n,period:r,timeZoneLabel:o,showTimeZoneLabel:s=!0,className:a=""}){const i=Array.isArray(e)&&e.length?e:[],l=i.map(u=>{if(u?.missing||u?.future)return 0;const d=u?.billable_total_tokens??u?.total_tokens??u?.value;if(d==null)return 0;const h=Number(d);return Number.isFinite(h)?h:0}),c=y0(l);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 ${a}`,children:[m.jsxs("div",{className:"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("trend.monitor.label")}),s&&o&&m.jsx("p",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:o})]}),m.jsxs("div",{className:"space-y-3",children:[m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none",children:[0,25,50,75,100].map(u=>m.jsx("div",{className:"w-full border-t border-oai-gray-100 dark:border-oai-gray-800",style:{top:`${100-u}%`}},u))}),m.jsx("div",{className:"h-40 flex items-end gap-1 relative z-0",children:l.length>0?l.map((u,d)=>m.jsx(b0,{value:u,displayValue:c.clippedValues[d]??0,scale:c,index:d,row:i[d],totalBars:l.length},d)):m.jsx("div",{className:"flex-1 h-full flex items-center justify-center",children:m.jsx("p",{className:"text-sm text-oai-gray-400 dark:text-oai-gray-400",children:"No data yet"})})})]}),t&&n&&m.jsxs("div",{className:"flex justify-between text-xs text-oai-gray-500 dark:text-oai-gray-300 font-medium pt-2 border-t border-oai-gray-100 dark:border-oai-gray-800",children:[m.jsx("span",{children:t}),m.jsx("span",{children:n})]})]})]})}const ei={"idle-living":"idle/living.svg","idle-doze":"idle/doze.svg","idle-follow":"idle/follow.svg","idle-look":"idle/look.svg","idle-yawn":"idle/yawn.svg","idle-collapse":"idle/collapse.svg","working-building":"working/building.svg","working-carrying":"working/carrying.svg","working-conducting":"working/conducting.svg","working-confused":"working/confused.svg","working-debugger":"working/debugger.svg","working-juggling":"working/juggling.svg","working-overheated":"working/overheated.svg","working-pushing":"working/pushing.svg","working-sweeping":"working/sweeping.svg","working-thinking":"working/thinking.svg","working-typing":"working/typing.svg","working-ultrathink":"working/ultrathink.svg","working-wizard":"working/wizard.svg","mini-alert":"mini/alert.svg","mini-crabwalk":"mini/crabwalk.svg","mini-enter":"mini/enter.svg","mini-enter-sleep":"mini/enter-sleep.svg","mini-happy":"mini/happy.svg","mini-idle":"mini/idle.svg","mini-peek":"mini/peek.svg","mini-sleep":"mini/sleep.svg","react-double":"react/double.svg","react-drag":"react/drag.svg","react-left":"react/left.svg","react-right":"react/right.svg","collapse-sleep":"sleep/collapse-sleep.svg",sleeping:"sleep/sleeping.svg",wake:"sleep/wake.svg",disconnected:"status/disconnected.svg",error:"status/error.svg",notification:"status/notification.svg",happy:"happy.svg","static-base":"static-base.svg"},Io=new Map;async function w0(e){if(Io.has(e))return Io.get(e);const t=await fetch(`/clawd/${e}`);if(!t.ok)return null;const r=(await t.text()).replace(/<svg([^>]*)>/,(o,s)=>`<svg${s.replace(/\s+width="[^"]*"/g,"").replace(/\s+height="[^"]*"/g,"")} width="100%" height="100%">`);return Io.set(e,r),r}function v0({state:e="idle-living",size:t=48,className:n=""}){const[r,o]=f.useState(""),s=f.useRef(null),i=k0()?"static-base":e,l=ei[i]||ei["static-base"];return f.useEffect(()=>{let c=!1;return w0(l).then(u=>{!c&&u&&o(u)}),()=>{c=!0}},[l]),f.useEffect(()=>{const c=s.current?.querySelector("svg");if(c)try{const u=c.getBBox();u.width>0&&u.height>0&&c.setAttribute("viewBox",`${u.x-2} ${u.y-2} ${u.width+4} ${u.height+4}`)}catch{}},[r]),m.jsx("div",{ref:s,className:`clawd-animated ${n}`,style:{width:t,height:t,display:"inline-flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},dangerouslySetInnerHTML:{__html:r}})}function k0(){const[e,t]=f.useState(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return f.useEffect(()=>{const n=window.matchMedia("(prefers-reduced-motion: reduce)"),r=o=>t(o.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function S0({todayTokens:e=0,isSyncing:t=!1,hasError:n=!1,isDisconnected:r=!1}={}){return f.useMemo(()=>n?"error":r?"disconnected":t?"working-typing":e===0?"sleeping":e<5e4?"idle-living":e<2e5?"idle-look":e<5e5?"working-ultrathink":e<2e6?"working-typing":"working-ultrathink",[e,t,n,r])}const ti="macAppBannerDismissed",C0="leaderboardBannerDismissed",E0="https://github.com/mm7894215/TokenTracker/releases/latest",ni="tokentracker_native_app",Tr=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(ni,"1"),!0):localStorage.getItem(ni)==="1"}catch{return!1}})();function M0({todayTokens:e=0,isSyncing:t=!1}){const{openLoginModal:n}=zu(),{signedIn:r}=Ku(),o=S0({todayTokens:e,isSyncing:t}),s=Tr?C0:ti,[a,i]=f.useState(()=>{try{return localStorage.getItem(s)==="1"?!0:!Tr&&new URLSearchParams(window.location.search).get("from")==="menubar"?(localStorage.setItem(ti,"1"),!0):!1}catch{return!1}}),l=f.useCallback(()=>{i(!0);try{localStorage.setItem(s,"1")}catch{}},[s]);if(a)return null;let c,u,d,h,g,p;Tr&&r?(c="View the Leaderboard",u="Compare your usage globally",d="Leaderboard",h=m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:m.jsx("path",{d:"M2 8.5V10h8V8.5M6 1.5v6m0 0L3.5 5M6 7.5l2.5-2.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(180 6 6)"})}),g=()=>{window.location.pathname="/leaderboard"}):Tr?(c="Join the Leaderboard",u="Log in to compare your usage with others",d="Log In",h=m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:m.jsx("path",{d:"M6.5 1.5h3a1 1 0 011 1v7a1 1 0 01-1 1h-3M5 8.5L7.5 6 5 3.5M7.5 6H1.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),g=n):(c="Try the Menu Bar App",u="Always-on stats with Clawd companion",d="Download",h=m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:m.jsx("path",{d:"M6 2v6m0 0L3.5 5.5M6 8l2.5-2.5M2 10h8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),p=E0);const y=p?vt.a:vt.button,x=p?{href:p,target:"_blank",rel:"noopener noreferrer"}:{onClick:g};return m.jsx(Xu,{children:m.jsx(vt.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.3},className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4",children:m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"flex-shrink-0",children:m.jsx(v0,{state:o,size:56})}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:"text-sm font-medium text-oai-gray-900 dark:text-oai-white",children:c}),m.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-0.5",children:u})]}),m.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m.jsxs(y,{...x,whileHover:{scale:1.03},whileTap:{scale:.97},className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-oai-gray-900 dark:bg-oai-white dark:text-oai-gray-900 rounded-md hover:opacity-90 transition-opacity",children:[d,h]}),m.jsx("button",{onClick:l,className:"p-1 text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-300 transition-colors","aria-label":"Dismiss",children:m.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:m.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})})]})]})})})}function qe(e){if(!e)return null;const t=typeof e=="number"?e*1e3:Date.parse(e);if(!Number.isFinite(t))return null;const n=t-Date.now();if(n<=0)return"now";const r=Math.floor(n/6e4);if(r<60)return`${r}m`;const o=Math.floor(r/60);return o<24?`${o}h`:`${Math.floor(o/24)}d`}function T0(e){return e>=90?"bg-red-500":e>=70?"bg-amber-500":"bg-emerald-500"}function Ge({label:e,pct:t,reset:n}){const r=Math.max(0,Math.min(100,Math.round(t)));return m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 w-12 shrink-0",children:e}),m.jsx("div",{className:"flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:m.jsx("div",{className:`${T0(r)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${r}%`,minWidth:r>0?"3px":0}})}),m.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-[30px] text-right shrink-0",children:[r,"%"]}),n?m.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:n}):null]})}function xn({name:e,icon:t,children:n}){const o=t==="/brand-logos/cursor.svg"||t==="/brand-logos/kiro.svg"?"w-[14px] h-[14px] dark:invert":"w-[14px] h-[14px]";return m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[t?m.jsx("img",{src:t,alt:"",className:o}):null,m.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:e})]}),n]})}function O0({claude:e,codex:t,cursor:n,gemini:r,kiro:o,antigravity:s}){const a=l=>l?.configured&&!l.error,i=[];return a(e)&&i.push(m.jsxs(xn,{name:"Claude",icon:"/brand-logos/claude-code.svg",children:[e.five_hour?m.jsx(Ge,{label:"5h",pct:e.five_hour.utilization,reset:qe(e.five_hour.resets_at)}):null,e.seven_day?m.jsx(Ge,{label:"7d",pct:e.seven_day.utilization,reset:qe(e.seven_day.resets_at)}):null,e.seven_day_opus?m.jsx(Ge,{label:"Opus",pct:e.seven_day_opus.utilization,reset:qe(e.seven_day_opus.resets_at)}):null]},"claude")),a(t)&&i.push(m.jsxs(xn,{name:"Codex",icon:"/brand-logos/codex.svg",children:[t.primary_window?m.jsx(Ge,{label:"5h",pct:t.primary_window.used_percent,reset:qe(t.primary_window.reset_at)}):null,t.secondary_window?m.jsx(Ge,{label:"7d",pct:t.secondary_window.used_percent,reset:qe(t.secondary_window.reset_at)}):null]},"codex")),a(n)&&i.push(m.jsxs(xn,{name:"Cursor",icon:"/brand-logos/cursor.svg",children:[n.primary_window?m.jsx(Ge,{label:"Plan",pct:n.primary_window.used_percent,reset:qe(n.primary_window.reset_at)}):null,n.secondary_window?m.jsx(Ge,{label:"Auto",pct:n.secondary_window.used_percent,reset:qe(n.secondary_window.reset_at)}):null,n.tertiary_window?m.jsx(Ge,{label:"API",pct:n.tertiary_window.used_percent,reset:qe(n.tertiary_window.reset_at)}):null]},"cursor")),a(r)&&i.push(m.jsxs(xn,{name:"Gemini",icon:"/brand-logos/gemini.svg",children:[r.primary_window?m.jsx(Ge,{label:"Pro",pct:r.primary_window.used_percent,reset:qe(r.primary_window.reset_at)}):null,r.secondary_window?m.jsx(Ge,{label:"Flash",pct:r.secondary_window.used_percent,reset:qe(r.secondary_window.reset_at)}):null,r.tertiary_window?m.jsx(Ge,{label:"Lite",pct:r.tertiary_window.used_percent,reset:qe(r.tertiary_window.reset_at)}):null]},"gemini")),a(o)&&i.push(m.jsxs(xn,{name:"Kiro",icon:"/brand-logos/kiro.svg",children:[o.primary_window?m.jsx(Ge,{label:"Month",pct:o.primary_window.used_percent,reset:qe(o.primary_window.reset_at)}):null,o.secondary_window?m.jsx(Ge,{label:"Bonus",pct:o.secondary_window.used_percent,reset:qe(o.secondary_window.reset_at)}):null]},"kiro")),a(s)&&i.push(m.jsxs(xn,{name:"Antigravity",icon:"/brand-logos/antigravity.svg",children:[s.primary_window?m.jsx(Ge,{label:"Claude",pct:s.primary_window.used_percent,reset:qe(s.primary_window.reset_at)}):null,s.secondary_window?m.jsx(Ge,{label:"G Pro",pct:s.secondary_window.used_percent,reset:qe(s.secondary_window.reset_at)}):null,s.tertiary_window?m.jsx(Ge,{label:"Flash",pct:s.tertiary_window.used_percent,reset:qe(s.tertiary_window.reset_at)}):null]},"antigravity")),i.length===0?null:m.jsx(Mn,{delay:.15,children:m.jsx(zr,{children:m.jsxs("div",{className:"flex flex-col gap-3",children:[m.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:"Usage Limits"}),i]})})})}function N0(e){const{copy:t,screenshotMode:n,showExpiredGate:r,showAuthGate:o,screenshotTitleLine1:s,screenshotTitleLine2:a,identityDisplayName:i,identityStartDate:l,activeDays:c,identitySubscriptions:u,identityScrambleDurationMs:d,projectUsageEntries:h,projectUsageLimit:g,setProjectUsageLimit:p,topModels:y,signedIn:x,publicMode:v,isLocalMode:b,shouldShowInstall:w,installPrompt:S,handleCopyInstall:C,installCopied:k,installInitCmdDisplay:T,trendRowsForDisplay:N,trendFromForDisplay:I,trendToForDisplay:M,period:R,trendTimeZoneLabel:j,activityHeatmapBlock:E,isCapturing:F,handleShareToX:_,screenshotTwitterButton:B,screenshotTwitterHint:V,periodsForDisplay:O,setSelectedPeriod:P,customFrom:U,customTo:Y,onCustomRangeApply:ee,customRangeOpen:H,onCustomRangeOpenChange:L,summaryLabel:z,summaryValue:X,summaryTotalTokensRaw:oe,summaryCostValue:be,summaryConversationsValue:Oe,rollingUsage:xe,costInfoEnabled:We,openCostModal:D,costModalOpen:ae,closeCostModal:q,allowBreakdownToggle:ye,refreshAll:$,usageLoadingState:J,fleetData:ie,hasDetailsActual:he,dailyEmptyPrefix:de,installSyncCmd:se,dailyEmptySuffix:Z,detailsColumns:De,ariaSortFor:ke,toggleSort:Ie,sortIconFor:pe,pagedDetails:Je,dailyBreakdownRows:Fe,dailyBreakdownColumns:Se,dailyBreakdownAriaSortFor:Ue,dailyBreakdownSortIconFor:He,dailyBreakdownDateKey:It,detailsDateKey:Ft,renderDetailDate:Lt,renderDailyBreakdownDate:Wt,renderDetailCell:ot,DETAILS_PAGED_PERIODS:Ce,detailsPageCount:Te,detailsPage:K,setDetailsPage:le,usageLimits:Q}=e,fe=null,je=null,ue=f.useRef(null),[gt,zt]=f.useState(0);return f.useEffect(()=>{const Ct=ue.current;if(!Ct)return;const Ve=new ResizeObserver(([Et])=>{zt(Et.contentRect.height)});return Ve.observe(Ct),()=>Ve.disconnect()},[]),m.jsxs(m.Fragment,{children:[m.jsx(kg,{hideHeader:n,header:fe,footer:n?null:je,className:n?"screenshot-mode":"",children:r||o?null:m.jsx(m.Fragment,{children:m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4",children:[m.jsxs("div",{ref:ue,className:"lg:col-span-4 flex flex-col gap-4 min-w-0",children:[n?m.jsx("div",{className:"flex items-start justify-between gap-4",children:m.jsxs("div",{className:"flex flex-col gap-1",children:[m.jsx("span",{className:"text-3xl md:text-4xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:s}),m.jsx("span",{className:"text-2xl md:text-3xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:a})]})}):null,b?m.jsx(M0,{todayTokens:oe,isSyncing:J}):null,m.jsx(Jg,{title:t("dashboard.identity.title"),subtitle:t("dashboard.identity.subtitle"),period:R,rankLabel:l??t("identity_card.rank_placeholder"),streakDays:c,subscriptions:u,periodConversations:Oe,rolling:xe,topModels:y}),m.jsx(O0,{claude:Q?.claude,codex:Q?.codex,cursor:Q?.cursor,gemini:Q?.gemini,kiro:Q?.kiro,antigravity:Q?.antigravity}),w?m.jsx(Mn,{delay:.25,children:m.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-3",children:[m.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 mb-1.5",children:S}),m.jsxs(vt.button,{onClick:C,whileHover:{scale:1.01},whileTap:{scale:.99},className:"w-full flex items-center justify-between px-3 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-700 rounded-lg transition-colors",children:[m.jsx("code",{className:"text-xs font-mono text-oai-gray-700 dark:text-oai-gray-300",children:T}),m.jsx(vt.span,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},className:"text-xs text-oai-brand",children:k?"Copied ✓":"Copy"},k?"copied":"copy")]})]})}):null,E&&m.jsx(Mn,{delay:.4,children:E}),n?null:m.jsx(x0,{rows:N,from:I,to:M,period:R,timeZoneLabel:j,showTimeZoneLabel:!1}),n?m.jsxs("div",{className:"mt-4 flex flex-col items-center gap-2","data-screenshot-exclude":"true",style:F?{display:"none"}:void 0,children:[m.jsx(tr,{type:"button",onClick:_,variant:"primary",size:"lg",disabled:F,children:B}),m.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300",children:V})]}):null]}),m.jsxs("div",{className:"lg:col-span-8 flex flex-col gap-4 min-w-0",style:gt?{maxHeight:gt}:void 0,children:[m.jsx(p0,{period:R,periods:O,onPeriodChange:P,summaryLabel:z,summaryValue:X,summaryCostValue:be,onCostInfo:We?D:null,fleetData:ie,onRefresh:n?null:$,loading:J,customFrom:U,customTo:Y,onCustomRangeApply:ee,customRangeOpen:H,onCustomRangeOpenChange:L}),n?null:m.jsx(Mn,{delay:.5,className:"flex-1 flex flex-col min-h-0",children:m.jsx(Kg,{projectEntries:h,projectLimit:g,onProjectLimitChange:p,copy:t,hasDetailsActual:he,dailyEmptyPrefix:de,installSyncCmd:se,dailyEmptySuffix:Z,detailsColumns:De,ariaSortFor:ke,toggleSort:Ie,sortIconFor:pe,pagedDetails:Je,dailyBreakdownRows:Fe,dailyBreakdownColumns:Se,dailyBreakdownAriaSortFor:Ue,dailyBreakdownSortIconFor:He,dailyBreakdownDateKey:It,detailsDateKey:Ft,renderDetailDate:Lt,renderDailyBreakdownDate:Wt,renderDetailCell:ot,DETAILS_PAGED_PERIODS:Ce,period:R,detailsPageCount:Te,detailsPage:K,setDetailsPage:le})})]})]})})}),m.jsx(zg,{isOpen:ae,onClose:q,fleetData:ie})]})}const R0=["day","week","month","total","custom"],Fo=new Set(["day","hour","month"]),Kn=new Set(["day","total","custom"]);function Lo(e,t){if(typeof t=="number"&&t>0)return!0;if(typeof e=="bigint")return e>0n;if(typeof e=="number")return Number.isFinite(e)&&e>0;if(typeof e=="string"){const n=e.trim();if(!n)return!1;if(/^[0-9]+$/.test(n))try{return BigInt(n)>0n}catch{return!1}const r=Number(n);return Number.isFinite(r)&&r>0}return!1}function Or(e){return e?e?.billable_total_tokens??e?.total_tokens:null}function ri(e){return e?e?.billable_total_tokens??e?.value??e?.total_tokens:null}function D0(e){if(typeof e!="string"||!e)return null;const t=e.split("-");if(t.length!==3)return null;const n=Number(t[0]),r=Number(t[1])-1,o=Number(t[2]);if(!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(o))return null;const s=new Date(Date.UTC(n,r,o));return Number.isFinite(s.getTime())?s:null}function _0(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function P0(e){return e?e==="token.rynn.me":!1}function j0(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search),t=String(e.get("force_install")||"").toLowerCase();return t!=="1"&&t!=="true"?!1:!P0(window.location.hostname)}function W0({baseUrl:e,auth:t,signedIn:n,sessionSoftExpired:r,signOut:o,publicMode:s=!1,publicToken:a=null,signInUrl:i="/sign-in",signUpUrl:l="/sign-up"}){const[c,u]=f.useState(!1),[d,h]=f.useState(null),[g,p]=f.useState(null),[y,x]=f.useState(!1),[v,b]=f.useState(null),[w,S]=f.useState(0),[C,k]=f.useState(0),[T,N]=f.useState(null),[I,M]=f.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(max-width: 640px)").matches),R=f.useMemo(()=>typeof window>"u"?!1:Ju(window.location.search),[]),j=f.useMemo(()=>j0(),[]),[E,F]=f.useState(!1),_=2200,[B,V]=f.useState(!0),[O,P]=f.useState(!1),[U,Y]=f.useState(!1),[ee,H]=f.useState(!1),L=jn(),z=n&&!r,X=f.useMemo(()=>z&&(typeof t=="function"||typeof t=="string"||t&&typeof t=="object")?t:null,[t,z]),oe=z?X:null,be=s?Qu(a):oe,Oe=n||L||s,xe=z&&An(oe),We=n&&r&&!s;f.useEffect(()=>{if(!n||L){h(null),p(null),x(!1),b(null);return}if(s)return;if(!xe){h(null),p(null),x(!1),b(null);return}let A=!0;const te=()=>{h(null),p(null),x(!1),b(null)};return x(!0),b(null),(async()=>{let ne=null;try{ne=await rn(oe)}catch{ne=null}if(A){if(!ne){te();return}try{const ce={link_code:null,expires_at:null};if(!A)return;h(typeof ce?.link_code=="string"?ce.link_code:null),p(typeof ce?.expires_at=="string"?ce.expires_at:null)}catch(ce){if(!A)return;h(null),p(null),b(ce?.message||"Failed to load link code")}finally{if(!A)return;x(!1)}}})(),()=>{A=!1}},[e,L,n,s,xe,oe,C]);const D=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");f.useEffect(()=>{if(!D&&(!n||L||s)){N(null);return}if(!D&&!xe){N(null);return}let A=!0;return(async()=>{let te=null;try{te=await rn(oe)}catch{te=null}if(A){if(!te&&!D){N(null);return}try{const ne=await Zu({baseUrl:e,accessToken:te});if(!A)return;N(ne&&typeof ne=="object"?ne:null)}catch{if(!A)return;N(null)}}})(),()=>{A=!1}},[xe,e,oe,L,s,n]);const ae=f.useMemo(()=>{if(!g)return!1;const A=Date.parse(g);if(!Number.isFinite(A))return!1;const te=w||Date.now();return A<=te},[g,w]);f.useEffect(()=>{!n||L||s||!g||!ae||y||(h(null),p(null),b(null),k(A=>A+1))},[ae,g,y,L,n]),f.useEffect(()=>{if(!g||s)return;const A=Date.parse(g);if(!Number.isFinite(A))return;const te=Date.now();if(S(te),A<=te)return;const ne=window.setTimeout(()=>S(Date.now()),A-te),ce=()=>{typeof document>"u"||document.visibilityState==="visible"&&S(Date.now())};return typeof document<"u"&&document.addEventListener("visibilitychange",ce),window.addEventListener("focus",ce),()=>{window.clearTimeout(ne),typeof document<"u"&&document.removeEventListener("visibilitychange",ce),window.removeEventListener("focus",ce)}},[g]),f.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const A=window.matchMedia("(max-width: 640px)"),te=()=>M(A.matches);return te(),A.addEventListener?(A.addEventListener("change",te),()=>A.removeEventListener("change",te)):(A.addListener(te),()=>A.removeListener(te))},[]);const q=f.useMemo(()=>ed(),[]),ye=f.useMemo(()=>td(),[]),$=f.useMemo(()=>nd(),[]),J=s?null:t?.userId||t?.email||"default",[ie,he]=f.useState("month"),[de,se]=f.useState(null),[Z,De]=f.useState(null),[ke,Ie]=f.useState(!1),pe=R?"total":ie,Je=f.useMemo(()=>pe==="custom"&&de&&Z?{from:de,to:Z}:rd(pe,{timeZone:q,offsetMinutes:ye,now:$}),[$,pe,q,ye,de,Z]),Fe=Je.from,Se=Je.to,Ue=f.useMemo(()=>od({timeZone:q,offsetMinutes:ye}),[q,ye]),He=f.useMemo(()=>sd({timeZone:q,offsetMinutes:ye}),[q,ye]),It=f.useMemo(()=>`Local time (${He})`,[He]),Ft=q,Lt=ye,Wt=Ue,ot=f.useMemo(()=>Jo({timeZone:q,offsetMinutes:ye,date:$||new Date}),[$,q,ye]),Ce=f.useMemo(()=>{const A=D0(ot)||new Date,te=_0(A,-29);return{from:Tn(te),to:Tn(A)}},[ot]),{daily:Te,summary:K,rolling:le,source:Q,loading:fe,error:je,refresh:ue}=Xs({baseUrl:e,accessToken:be,guestAllowed:We,from:Fe,to:Se,includeDaily:pe!=="total",cacheKey:J,timeZone:q,tzOffsetMinutes:ye,now:$}),{daily:gt,loading:zt,refresh:Ct}=Xs({baseUrl:e,accessToken:be,guestAllowed:We,from:Ce.from,to:Ce.to,includeDaily:!0,cacheKey:J?`${J}.daily-breakdown`:"daily-breakdown",timeZone:q,tzOffsetMinutes:ye,now:$}),{breakdown:Ve,loading:Et,refresh:dn}=jd({baseUrl:e,accessToken:be,guestAllowed:We,from:Fe,to:Se,cacheKey:J,timeZone:q,tzOffsetMinutes:ye}),[Bn,Jr]=f.useState(3),{entries:Qr,loading:Kt,refresh:fr}=Cd({baseUrl:e,accessToken:be,limit:Bn,from:Fe,to:Se,timeZone:q,tzOffsetMinutes:ye}),mr=pe==="week"||pe==="month",fn=pe==="week"||pe==="month",Cs=f.useMemo(()=>Te.filter(A=>A?.future?!1:!A?.day||!ot?!0:String(A.day)<=String(ot)),[Te,ot]),{rows:Mt,from:bc,to:xc,loading:wc,refresh:Es}=Md({baseUrl:e,accessToken:be,guestAllowed:We,period:pe,from:Fe,to:Se,months:24,cacheKey:J,timeZone:Ft,tzOffsetMinutes:Lt,now:$,sharedRows:mr?Te:null,sharedRange:mr?{from:Fe,to:Se}:null}),{daily:mn,heatmap:Tt,loading:Ms,refresh:Ts}=Sd({baseUrl:e,accessToken:be,guestAllowed:We,weeks:52,cacheKey:J,timeZone:q,tzOffsetMinutes:ye,now:$}),{data:vc,refresh:Os}=Pd(),lt=f.useMemo(()=>pe==="day"?"hour":pe==="total"?"month":"day",[pe]),kc=f.useMemo(()=>Qs(lt),[lt]),hr="day",Sc=f.useMemo(()=>Qs(hr),[]),[ct,Ns]=f.useState(()=>({key:"day",dir:"desc"}));f.useEffect(()=>{Ns(A=>!Fo.has(A.key)||A.key===lt?A:{key:lt,dir:A.dir})},[lt]);const hn=f.useMemo(()=>Fo.has(ct.key)&&ct.key!==lt?{...ct,key:lt}:ct,[lt,ct]),gr=f.useMemo(()=>{if(pe==="day")return Array.isArray(Mt)?Mt.filter(ne=>ne?.hour&&!ne?.future):[];if(pe==="total"){const ne=Array.isArray(Mt)?Mt.filter(ce=>ce?.month&&!ce?.future):[];return Gd(ne)}const A=Cs;return!A.some(ne=>!ne?.missing&&!ne?.future)&&Te.length>0?Te.filter(ne=>!ne?.future).slice(-30).filter(ne=>ne?.day):A},[pe,Mt,Cs,Te]),Yn=f.useMemo(()=>Zs(gr,hn),[gr,hn]),Cc=f.useMemo(()=>gr.some(A=>!A?.missing&&!A?.future),[gr]),Zr=f.useMemo(()=>{if(!Kn.has(pe))return 1;const A=Math.ceil(Yn.length/_r);return A>0?A:1},[pe,Yn.length]),[eo,pr]=f.useState(0);f.useEffect(()=>{if(!Kn.has(pe)){pr(0);return}pr(A=>Math.min(A,Zr-1))},[Zr,pe]),f.useEffect(()=>{Kn.has(pe)&&pr(0)},[pe,ct.dir,ct.key]);const Ec=f.useMemo(()=>Kn.has(pe)?zd(Yn,eo,_r):Yn,[eo,pe,Yn]),Rs=f.useMemo(()=>gt.filter(A=>!A?.future&&A?.day).slice(-30),[gt]),gn=f.useMemo(()=>Fo.has(ct.key)?{...ct,key:hr}:ct,[ct]),Mc=f.useMemo(()=>Zs(Rs,gn),[Rs,gn]),Tc=f.useMemo(()=>fn?Te:pe==="day"?Array.isArray(Mt)?Mt.filter(A=>A?.hour):[]:Mt,[Te,pe,Mt,fn]),Oc=fn?Fe:bc,Nc=fn?Se:xc;function Rc(A,te){return A?.future?"—":A?.missing?W("shared.status.unsynced"):te==="total_tokens"?Nt(Or(A)):Nt(A?.[te])}function Dc(A){const te=A?.[lt];if(te==null)return"";const ne=String(te);if(lt==="hour"){const[ce,$e]=ne.split("T");if(ce&&$e)return`${ce} ${$e.slice(0,5)}`}return ne}function _c(A){const te=A?.[hr];return te==null?"":String(te)}function Pc(A){Ns(te=>te.key===A?{key:A,dir:te.dir==="asc"?"desc":"asc"}:{key:A,dir:"desc"})}function jc(A){return hn.key!==A?"none":hn.dir==="asc"?"ascending":"descending"}function Ac(A){return hn.key!==A?"":hn.dir==="asc"?"▲":"▼"}function Ic(A){return gn.key!==A?"none":gn.dir==="asc"?"ascending":"descending"}function Fc(A){return gn.key!==A?"":gn.dir==="asc"?"▲":"▼"}const Ds=f.useMemo(()=>{if(!n&&!L&&!s&&!D)return 0;const A=Number(Tt?.active_days);if(Number.isFinite(A))return A;let te=0;const ne=new Set,ce=(Ne,Ae,Be)=>{typeof Ne!="string"||!Ne||ne.has(Ne)||Lo(Ae,Be)&&(ne.add(Ne),te+=1)};if(Array.isArray(mn))for(const Ne of mn)ce(Ne?.day,Or(Ne));const $e=Array.isArray(Tt?.weeks)?Tt.weeks:[];for(const Ne of $e)for(const Ae of Array.isArray(Ne)?Ne:[]){const Be=ri(Ae);ce(Ae?.day,Be,Ae?.level)}return te},[n,L,Tt?.active_days,Tt?.weeks,mn]),[_s,Ps]=f.useState("month"),Lc=f.useCallback(A=>{A==="custom"?(Ps(te=>te==="custom"?"month":te),he(te=>de&&Z?"custom":te),Ie(!0)):(he(A),Ps(A),Ie(!1))},[de,Z]),Wc=f.useCallback((A,te)=>{se(A),De(te),he("custom"),Ie(!1)},[]),$c=f.useCallback(A=>{Ie(A),!A&&ie==="custom"&&!de&&he(_s)},[ie,de,_s]),js=f.useCallback(async()=>{await Promise.all([ue(),Ts(),Es(),dn(),fr(),Ct(),Os()])},[Ct,Ts,dn,fr,Es,ue,Os]),Bc=f.useCallback(async()=>{H(!0);try{D&&await ad(),await js()}catch(A){console.error("[DashboardPage] Refresh failed:",A)}finally{H(!1)}},[D,js]),Yc=ee||fe||zt||Ms||wc||Et||Kt,Hc=f.useMemo(()=>W("shared.data_source",{source:String(Q||"edge").toUpperCase()}),[Q]),yr=f.useMemo(()=>typeof t?.name!="string"?"":t.name.trim(),[t?.name]),Uc="",As=f.useMemo(()=>!yr||yr.includes("@")?W("dashboard.identity.fallback"):yr,[yr]),Is=f.useMemo(()=>As.replace(/[^a-zA-Z0-9._-]/g,"_"),[As]),Vc=f.useMemo(()=>s?W("dashboard.identity.fallback"):Is,[Is,Uc,s]),qc=f.useMemo(()=>{let A=null;const te=ce=>{typeof ce!="string"||!ce||(!A||ce<A)&&(A=ce)};if(Array.isArray(mn))for(const ce of mn)ce?.day&&Lo(Or(ce))&&te(ce.day);const ne=Array.isArray(Tt?.weeks)?Tt.weeks:[];for(const ce of ne)for(const $e of Array.isArray(ce)?ce:[]){if(!$e?.day)continue;const Ne=ri($e),Ae=$e?.level;Lo(Ne,Ae)&&te($e.day)}return A},[Tt?.weeks,mn]),Gc=f.useMemo(()=>s?[]:(Array.isArray(T?.subscriptions?.items)?T.subscriptions.items:[]).map(ne=>{const ce=typeof ne?.tool=="string"?ne.tool.trim():"",Ne=(typeof ne?.plan_type=="string"?ne.plan_type:typeof ne?.planType=="string"?ne.planType:"").trim();return!ce||!Ne?null:{tool:ce,planType:Ne,provider:typeof ne?.provider=="string"?ne.provider.trim():"",product:typeof ne?.product=="string"?ne.product.trim():"",rateLimitTier:typeof ne?.rate_limit_tier=="string"?ne.rate_limit_tier.trim():typeof ne?.rateLimitTier=="string"?ne.rateLimitTier.trim():""}}).filter(Boolean).slice(0,6),[s,T]),zc=m.jsx(lf,{heatmap:Tt,timeZoneLabel:Ue,timeZoneShortLabel:He,hideLegend:R,defaultToLatestMonth:R}),Kc=f.useMemo(()=>`${Fe}..${Se}`,[Fe,pe,Se]),Xc=W("usage.summary.total"),Xt=Or(K),Fs=W("shared.unit.thousand_abbrev"),Ls=W("shared.unit.million_abbrev"),Ws=W("shared.unit.billion_abbrev"),br=nt(Xt),$s=I&&br!=null&&Math.abs(br)>=1e9,Jc=f.useMemo(()=>$s?gi(br,{thousandSuffix:Fs,millionSuffix:Ls,billionSuffix:Ws,decimals:1}):Nt(Xt),[Ws,Ls,Xt,br,Fs,$s]),Qc=W("dashboard.core_index.collapse_label"),Zc=W("dashboard.core_index.expand_label"),eu=W("dashboard.core_index.collapse_aria"),tu=W("dashboard.core_index.expand_aria"),nu=!R,ru=W("dashboard.screenshot.title_line1"),ou=W("dashboard.screenshot.title_line2"),su=W("dashboard.screenshot.twitter_label"),au=W("dashboard.screenshot.twitter_button"),iu=W("dashboard.screenshot.twitter_hint"),pn=W("shared.placeholder.short"),to=f.useMemo(()=>{const A=Array.isArray(Ve?.sources)?Ve.sources:[];let te=null,ne=0;for(const Ae of A){const Be=nt(Ae?.totals?.billable_total_tokens??Ae?.totals?.total_tokens);!Number.isFinite(Be)||Be<=0||Be>ne&&(ne=Be,te=Ae)}let ce=pn,$e=pn,Ne="0.0";if(te&&ne>0){ce=te?.source?String(te.source).toUpperCase():pn;const Ae=Array.isArray(te?.models)?te.models:[];let Be=0;for(const Ot of Ae){const Un=nt(Ot?.totals?.billable_total_tokens??Ot?.totals?.total_tokens);!Number.isFinite(Un)||Un<=0||Un>Be&&(Be=Un,$e=Ot?.model?String(Ot.model):pn)}Be>0&&(Ne=(Be/ne*100).toFixed(1))}return{agentName:ce,modelName:$e,modelPercent:Ne}},[Ve,pn]),Bs=Nt(Xt),Ys=W("dashboard.screenshot.twitter_text",{total_tokens:Bs==="-"?pn:Bs,agent_name:to.agentName,model_name:to.modelName,model_percent:to.modelPercent}),no=f.useMemo(()=>{if(typeof window>"u")return"";const A=new URL("https://twitter.com/intent/tweet");return A.searchParams.set("text",Ys),A.toString()},[Ys]),Hs=f.useCallback(async()=>{if(typeof window>"u")return null;const A=async()=>{const Ae=performance.now();for(;performance.now()-Ae<2e3;){const Be=document.querySelector("[data-heatmap-scroll='true']");if(!Be||Be.dataset.latestMonthReady==="true")return;await new Promise(Ot=>requestAnimationFrame(Ot))}},te=document.querySelector("#root")||document.body,ne=document.documentElement,{scrollWidth:ce,scrollHeight:$e}=document.documentElement;ne?.classList.add("screenshot-capture"),document.body?.classList.add("screenshot-capture"),await new Promise(Ne=>requestAnimationFrame(Ne)),await A();try{const{toBlob:Ne,toPng:Ae}=await id(async()=>{const{toBlob:Jt,toPng:Ou}=await import("./index-BeoRn2gJ.js");return{toBlob:Jt,toPng:Ou}},[]),Be=await Ne(te,{backgroundColor:"#050505",pixelRatio:2,cacheBust:!0,width:ce,height:$e,style:{width:`${ce}px`,height:`${$e}px`},filter:Jt=>!(Jt instanceof HTMLElement)||Jt.dataset?.screenshotExclude!=="true"});if(Be)return Be;const Ot=await Ae(te,{backgroundColor:"#050505",pixelRatio:2,cacheBust:!0,width:ce,height:$e,style:{width:`${ce}px`,height:`${$e}px`},filter:Jt=>!(Jt instanceof HTMLElement)||Jt.dataset?.screenshotExclude!=="true"});return Ot?await(await fetch(Ot)).blob():null}finally{ne?.classList.remove("screenshot-capture"),document.body?.classList.remove("screenshot-capture")}},[]),lu=f.useCallback(async()=>{if(typeof window>"u"||E)return;F(!0);const A=navigator?.userAgent||"",te=/iP(hone|od|ad)/i.test(A),ne=/Safari/i.test(A)&&!/Chrome|Chromium|Edg|OPR|CriOS|FxiOS/i.test(A),ce=typeof navigator<"u"&&!!navigator.clipboard?.write&&typeof window<"u"&&!!window.ClipboardItem;let Ne=!ce||te||ne;try{const Ae=await Hs();Ae&&ce&&(typeof document<"u"&&!document.hasFocus()&&window.focus?.(),Ne=await ld(Ae))}catch(Ae){console.error("Failed to capture screenshot",Ae)}finally{if(F(!1),!Ne){console.warn("Failed to write screenshot to clipboard.");return}no&&(window.location.href=no)}},[Hs,E,no]),cu=f.useMemo(()=>R?[]:R0,[R]),uu=f.useMemo(()=>[{label:W("usage.metric.total"),value:Nt(Xt),valueClassName:"text-white"},{label:W("usage.metric.input"),value:Nt(K?.input_tokens)},{label:W("usage.metric.output"),value:Nt(K?.output_tokens)},{label:W("usage.metric.cached_input"),value:Nt(K?.cached_input_tokens)},{label:W("usage.metric.reasoning_output"),value:Nt(K?.reasoning_output_tokens)}],[K?.cached_input_tokens,K?.input_tokens,K?.output_tokens,K?.reasoning_output_tokens,Xt]),ro=f.useMemo(()=>{const A=es(K?.total_cost_usd);return!A||A==="-"||A.startsWith("$")?A:`$${A}`},[K?.total_cost_usd]),du=f.useMemo(()=>K?.conversation_count??null,[K?.conversation_count]),Us=f.useMemo(()=>Jd(Ve,{copyFn:W}),[Ve]),fu=f.useMemo(()=>Qd(Ve,{limit:3,copyFn:W}),[Ve]),mu=f.useCallback(()=>u(!0),[]),hu=f.useCallback(()=>u(!1),[]),gu=ro&&ro!=="-"&&Us.length>0,Hn=W("dashboard.install.cmd.init"),oo=ae?null:d,so=oo?W("dashboard.install.cmd.init_link_code",{link_code:oo}):Hn,pu=Hn,yu=W("dashboard.install.cmd.sync"),bu=oo?W("dashboard.install.copy"):W("dashboard.install.copy_base"),xu=W("dashboard.install.copied");W("dashboard.session_expired.copy_label"),W("dashboard.session_expired.copied");const wu=!!(T?.install?.has_active_device_token??T?.install?.hasActiveDeviceToken),vu=Kd({publicMode:s,screenshotMode:R,forceInstall:j,accessEnabled:Oe,heatmapLoading:Ms,activeDays:Ds,hasActiveDeviceToken:wu}),ku=W("dashboard.install.prompt"),Su=f.useCallback(async()=>{!so||!await Gs(so)||(P(!0),window.setTimeout(()=>P(!1),2e3))},[so]);f.useCallback(async()=>{!Hn||!await Gs(Hn)||(Y(!0),window.setTimeout(()=>Y(!1),2e3))},[Hn]);const ao=f.useMemo(()=>W("dashboard.daily.empty",{cmd:"{{cmd}}"}),[]),[Cu,Eu]=f.useMemo(()=>{const A=ao.split("{{cmd}}");return A.length===1?[ao,""]:[A[0],A.slice(1).join("{{cmd}}")]},[ao]),Mu=r&&!s,Tu=!n&&!L&&!r&&!D&&!s;return m.jsx(N0,{copy:W,screenshotMode:R,showExpiredGate:Mu,showAuthGate:Tu,screenshotTitleLine1:ru,screenshotTitleLine2:ou,identityDisplayName:Vc,identityStartDate:qc,activeDays:Ds,identitySubscriptions:Gc,identityScrambleDurationMs:_,projectUsageEntries:Qr,projectUsageLimit:Bn,setProjectUsageLimit:Jr,topModels:fu,signedIn:n,publicMode:s,isLocalMode:D,shouldShowInstall:vu,installPrompt:ku,handleCopyInstall:Su,installCopied:O,installCopiedLabel:xu,installCopyLabel:bu,installInitCmdDisplay:pu,linkCodeLoading:y,linkCodeError:v,trendRowsForDisplay:Tc,trendFromForDisplay:Oc,trendToForDisplay:Nc,period:pe,trendTimeZoneLabel:Wt,activityHeatmapBlock:zc,isCapturing:E,handleShareToX:lu,screenshotTwitterLabel:su,screenshotTwitterButton:au,screenshotTwitterHint:iu,periodsForDisplay:cu,setSelectedPeriod:Lc,customFrom:de,customTo:Z,onCustomRangeApply:Wc,customRangeOpen:ke,onCustomRangeOpenChange:$c,metricsRows:uu,summaryLabel:Xc,summaryValue:Jc,summaryTotalTokensRaw:nt(Xt)||0,summaryCostValue:ro,summaryConversationsValue:du,rollingUsage:le,costInfoEnabled:gu,openCostModal:mu,allowBreakdownToggle:nu,coreIndexCollapsed:B,setCoreIndexCollapsed:V,coreIndexCollapseLabel:Qc,coreIndexExpandLabel:Zc,coreIndexCollapseAria:eu,coreIndexExpandAria:tu,refreshAll:Bc,usageLoadingState:Yc,usageError:je,rangeLabel:Kc,timeZoneRangeLabel:It,usageSourceLabel:Hc,fleetData:Us,hasDetailsActual:Cc,dailyEmptyPrefix:Cu,installSyncCmd:yu,dailyEmptySuffix:Eu,detailsColumns:kc,ariaSortFor:jc,toggleSort:Pc,sortIconFor:Ac,pagedDetails:Ec,dailyBreakdownRows:Mc,dailyBreakdownColumns:Sc,dailyBreakdownAriaSortFor:Ic,dailyBreakdownSortIconFor:Fc,dailyBreakdownDateKey:hr,detailsDateKey:lt,renderDetailDate:Dc,renderDailyBreakdownDate:_c,renderDetailCell:Rc,DETAILS_PAGED_PERIODS:Kn,detailsPageCount:Zr,detailsPage:eo,setDetailsPage:pr,costModalOpen:c,closeCostModal:hu,usageLimits:vc})}export{W0 as DashboardPage};