tokentracker-cli 0.53.2 → 0.53.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/dist/assets/{ActivityHeatmap-CoVxkSjr.js → ActivityHeatmap-CZasqY2H.js} +1 -1
- package/dashboard/dist/assets/{Card-CJiPCvnj.js → Card-Cjd-ZKzN.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-CrdiIz7q.js → DashboardPage-BCa11vC2.js} +1 -1
- package/dashboard/dist/assets/{DevicePage-DBjdZA2N.js → DevicePage-BFCRnDcz.js} +1 -1
- package/dashboard/dist/assets/{DialogTitle--jWfmv_b.js → DialogTitle-Btt5G5wB.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-BrYhLQwK.js → FadeIn-gIH1bR94.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-DGtt-L8c.js → HeaderGithubStar-BuzgYTZ5.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-ToZsVEOj.js → IpCheckPage-Cn4cjpf4.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-DgB2CT3R.js → LandingPage-BaPLcNme.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardAvatar-94z-hs6u.js → LeaderboardAvatar-DMaYoU7B.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-hXIlg-XS.js → LeaderboardPage-D-qMCc2C.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfileModal-BcppEyBi.js → LeaderboardProfileModal-CYzcdwRb.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfilePage-BfZVW6cn.js → LeaderboardProfilePage-CQCqbWZE.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-CdcWyyh0.js → LimitsPage-M7a-TKW5.js} +1 -1
- package/dashboard/dist/assets/{LocalOnlyNotice-CBRDpg-i.js → LocalOnlyNotice-k-0-ORjj.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-DLkWQvC1.js → LoginPage-BxAbRsn_.js} +1 -1
- package/dashboard/dist/assets/{PopoverPopup-DMl0dwMU.js → PopoverPopup-C4YO4_N-.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-CwwTPCTr.js → ResetPasswordPage-Dqd9baMc.js} +1 -1
- package/dashboard/dist/assets/{Select-D3gMIEdB.js → Select-DXD3JLWK.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-GvEnESYK.js → SelectItemText-CTgRQ8ND.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-B3v6IkYh.js → SettingsPage-B2HxneYg.js} +1 -1
- package/dashboard/dist/assets/{SkillsPage-DX_mIIl8.js → SkillsPage-DEFIbkAX.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-DgqWQ9EA.js → WidgetsPage-DObILWDk.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-CR02q4cO.js → WrappedPage-CHKlz7Tc.js} +1 -1
- package/dashboard/dist/assets/{agent-logos-B3gxKbbb.js → agent-logos-CO0k-UGZ.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-DJo_-PxX.js → arrow-up-right-B_p-ZPxR.js} +1 -1
- package/dashboard/dist/assets/{download-BwsW6vug.js → download-zHPmUqi6.js} +1 -1
- package/dashboard/dist/assets/{info-C-aAjjA6.js → info-Cje0RF1w.js} +1 -1
- package/dashboard/dist/assets/{main-BbEXIjk8.js → main-DADupgLA.js} +2 -2
- package/dashboard/dist/assets/{use-limits-display-prefs-BUrvvpbW.js → use-limits-display-prefs-DIfRSzm0.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-SsQX6gzC.js → use-native-settings-BuBDLdTx.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-LOfhEW65.js → use-usage-limits-CFd1PQLO.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-CVVJYL2V.js → useCurrency-CIJjQNSk.js} +1 -1
- package/dashboard/dist/assets/{useScrollLock-Dm_66oFo.js → useScrollLock-DO1uWkvz.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
- package/src/commands/sync.js +198 -0
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +50 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{G as u,r as a,a_ as M,a$ as j,b0 as G,b1 as J}from"./main-
|
|
1
|
+
import{G as u,r as a,a_ as M,a$ as j,b0 as G,b1 as J}from"./main-DADupgLA.js";const B=["claude","codex","cursor","gemini","kimi","kiro","grok","copilot","antigravity"],q={claude:"CLAUDE",codex:"CODEX",cursor:"CURSOR",gemini:"GEMINI",kimi:"KIMI",kiro:"KIRO",grok:"GROK",copilot:"COPILOT",antigravity:"ANTIGRAVITY"};function se(e){return q[e]||null}function ae(e){switch(e){case"claude":return u("limits.provider.claude");case"codex":return u("limits.provider.codex");case"cursor":return u("limits.provider.cursor");case"gemini":return u("limits.provider.gemini");case"kimi":return u("limits.provider.kimi");case"kiro":return u("limits.provider.kiro");case"grok":return u("limits.provider.grok");case"copilot":return u("limits.provider.copilot");case"antigravity":return u("limits.provider.antigravity");default:return String(e||"")}}const y=B,A="tt.limits.providerOrder",E="tt.limits.providerVisibility",h="tt.limits.displayMode",O="tt.limits.updatedAt",V="limitsPreferences",F="limitsDisplayMode",v=Object.freeze({USED:"used",REMAINING:"remaining"}),g=new Set(Object.values(v)),L=new Set([A,E,h,O]);function I(){return[...y]}function b(){return Object.fromEntries(y.map(e=>[e,!0]))}function _(e){const r=[];if(Array.isArray(e))for(const n of e)y.includes(n)&&!r.includes(n)&&r.push(n);for(const n of y)r.includes(n)||r.push(n);return r}function N(e){const r=b();if(!e||typeof e!="object"||Array.isArray(e))return r;for(const n of y)typeof e[n]=="boolean"&&(r[n]=e[n]);return r}function X(e){return g.has(e)?e:v.USED}function m(e){if(e!=null){if(typeof e=="number")return Number.isSafeInteger(e)?e:void 0;if(typeof e=="string"){const r=e.trim();if(r==="")return;const n=Number(r);return Number.isSafeInteger(n)?n:void 0}}}function w(e={}){const r=e&&typeof e=="object"?e:{};return{displayMode:X(r.displayMode),providerOrder:_(r.providerOrder),providerVisibility:N(r.providerVisibility),updatedAt:m(r.updatedAt)}}function $(){if(typeof window>"u")return I();try{const e=window.localStorage.getItem(A);return _(e?JSON.parse(e):void 0)}catch{return I()}}function H(){if(typeof window>"u")return b();try{const e=window.localStorage.getItem(E);return N(e?JSON.parse(e):void 0)}catch{return b()}}function Q(){if(typeof window>"u")return v.USED;try{const e=window.localStorage.getItem(h);return g.has(e)?e:v.USED}catch{return v.USED}}function W(){if(!(typeof window>"u"))try{return m(window.localStorage.getItem(O))}catch{return}}function Z(){if(typeof window>"u")return!1;try{for(const e of L)if(window.localStorage.getItem(e)!==null)return!0}catch{return!1}return!1}function S(){return w({displayMode:Q(),providerOrder:$(),providerVisibility:H(),updatedAt:W()})}function ee(e){if(typeof window>"u")return;const r=w(e);try{window.localStorage.setItem(A,JSON.stringify(r.providerOrder)),window.localStorage.setItem(E,JSON.stringify(r.providerVisibility)),window.localStorage.setItem(h,r.displayMode),r.updatedAt===void 0?window.localStorage.removeItem(O):window.localStorage.setItem(O,String(r.updatedAt))}catch(n){console.warn("[tokentracker] limits preferences localStorage write failed:",n)}}function re(e){const r=w(e);return{displayMode:r.displayMode,providerOrder:[...r.providerOrder],providerVisibility:{...r.providerVisibility},updatedAt:r.updatedAt??null}}function te(...e){let r;for(const s of e){const l=m(s);l!==void 0&&(r=r===void 0?l:Math.max(r,l))}const n=Date.now();return r!==void 0&&n<=r?r+1:n}function ie(e,r){return e.length===r.length&&e.every((n,s)=>n===r[s])}function ne(e,r){return y.every(n=>e[n]===r[n])}function R(e,r){return e.displayMode===r.displayMode&&ie(e.providerOrder,r.providerOrder)&&ne(e.providerVisibility,r.providerVisibility)}function oe(e,r){return R(e,r)&&m(e.updatedAt)===m(r.updatedAt)}function k(e,r){const n=m(e.updatedAt),s=m(r.updatedAt);return n!==void 0&&(s===void 0||n>s)}function ce(){const[e,r]=a.useState(S),n=a.useRef(e),s=a.useCallback((o,t={})=>{const i=w(o);return n.current=i,r(i),t.writeLocal&&ee(i),i},[]),l=a.useCallback(o=>{M()&&j(V,re(o))},[]),c=a.useCallback(o=>{const t=S(),i=k(t,n.current)?s(t):n.current,d=w(o(i));if(R(i,d))return;const f=te(t.updatedAt,i.updatedAt),p=s({...d,updatedAt:f},{writeLocal:!0});l(p)},[s,l]),P=a.useCallback(o=>{g.has(o)&&c(t=>({...t,displayMode:o}))},[c]),D=a.useCallback(o=>{if(!g.has(o))return;const t=S();if(t.updatedAt!==void 0){s(t);return}s({...t,displayMode:o,updatedAt:void 0},{writeLocal:!0})},[s]);a.useEffect(()=>{if(!M())return;const o=G(t=>{const i=t?.[V];if(i&&typeof i=="object"){const d=w(i);if(!Z()){s(d,{writeLocal:!0});return}const f=S();if(k(d,f))s(d,{writeLocal:!0});else{const p=s(f);oe(d,f)||l(p)}return}D(t?.[F])});return J(),o},[D,s,l]),a.useEffect(()=>{if(typeof window>"u")return;const o=t=>{(t.key===null||L.has(t.key))&&s(S())};return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[s]);const x=a.useCallback(o=>{y.includes(o)&&c(t=>({...t,providerVisibility:{...t.providerVisibility,[o]:!t.providerVisibility[o]}}))},[c]),C=a.useCallback(o=>{c(t=>{const i=t.providerOrder.indexOf(o);if(i<=0)return t;const d=[...t.providerOrder];return[d[i-1],d[i]]=[d[i],d[i-1]],{...t,providerOrder:d}})},[c]),U=a.useCallback(o=>{c(t=>{const i=t.providerOrder.indexOf(o);if(i<0||i>=t.providerOrder.length-1)return t;const d=[...t.providerOrder];return[d[i],d[i+1]]=[d[i+1],d[i]],{...t,providerOrder:d}})},[c]),T=a.useCallback((o,t)=>{o!==t&&c(i=>{const d=i.providerOrder.indexOf(o),f=i.providerOrder.indexOf(t);if(d<0||f<0)return i;const p=[...i.providerOrder],[z]=p.splice(d,1);return p.splice(f,0,z),{...i,providerOrder:p}})},[c]),Y=a.useCallback(()=>{c(()=>({displayMode:v.USED,providerOrder:I(),providerVisibility:b()}))},[c]),K=a.useMemo(()=>e.providerOrder.filter(o=>e.providerVisibility[o]!==!1),[e.providerOrder,e.providerVisibility]);return{order:e.providerOrder,visibility:e.providerVisibility,displayMode:e.displayMode,setDisplayMode:P,visibleOrdered:K,toggle:x,moveUp:C,moveDown:U,moveToward:T,reset:Y}}export{v as L,B as a,se as b,ae as l,ce as u};
|
package/dashboard/dist/assets/{use-native-settings-SsQX6gzC.js → use-native-settings-BuBDLdTx.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a,V as x,r as n,aD as g,c4 as m,b0 as b,b1 as u,a$ as f,c3 as h}from"./main-
|
|
1
|
+
import{j as a,V as x,r as n,aD as g,c4 as m,b0 as b,b1 as u,a$ as f,c3 as h}from"./main-DADupgLA.js";import{C as y}from"./Card-Cjd-ZKzN.js";function k({checked:s,onChange:t,disabled:e,ariaLabel:i}){return a.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":i,onClick:t,disabled:e,className:x("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 disabled:cursor-not-allowed",s?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:a.jsx("span",{className:x("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",s?"translate-x-[18px]":"translate-x-[3px]")})})}function p({label:s,hint:t,control:e}){return a.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:s}),t?a.jsx("div",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t}):null]}),a.jsx("div",{className:"shrink-0",children:e})]})}function N({title:s,subtitle:t,action:e,children:i}){return a.jsxs(y,{children:[a.jsxs("div",{className:"mb-3 flex items-start justify-between gap-4",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("h2",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:s}),t?a.jsx("p",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t}):null]}),e?a.jsx("div",{className:"shrink-0",children:e}):null]}),a.jsx("div",{className:"-mb-3 divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:i})]})}function w({options:s,value:t,onChange:e}){return a.jsx("div",{className:"inline-flex items-center rounded-lg border border-oai-gray-200 bg-oai-gray-50 p-0.5 dark:border-oai-gray-800 dark:bg-oai-gray-900",children:s.map(({value:i,label:d,Icon:l})=>{const r=t===i;return a.jsxs("button",{type:"button",onClick:()=>e(i),"aria-pressed":r,className:x("inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",r?"bg-white text-oai-black shadow-sm dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:[l?a.jsx(l,{className:"h-3.5 w-3.5","aria-hidden":!0}):null,a.jsx("span",{children:d})]},i)})})}function S(){const[s,t]=n.useState(null),e=g()&&m();n.useEffect(()=>{if(!e)return;const r=b(o=>t(o));return u(),r},[e]);const i=n.useCallback((r,o)=>{e&&(t(c=>c&&{...c,[r]:o}),f(r,o))},[e]),d=n.useCallback(r=>{e&&h(r)},[e]),l=n.useCallback(()=>{e&&u()},[e]);return{available:e,settings:s,setSetting:i,runAction:d,refresh:l}}export{N as S,k as T,p as a,w as b,S as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,ab as w,aI as c}from"./main-
|
|
1
|
+
import{r as a,ab as w,aI as c}from"./main-DADupgLA.js";function v(i){const o=!!i?.initialState,[b,l]=a.useState(()=>o?i?.initialState?.data??null:null),[m,s]=a.useState(()=>o?i?.initialState?.error??null:null),[y,g]=a.useState(!o),u=!!i?.initialRefresh,f=!!i?.publishToPreloadCache,r=a.useCallback((e,t)=>{!f||!e||typeof e!="object"||w(e,{source:t})},[f]),S=a.useCallback(async()=>{try{const e=await c({refresh:!0}),t=e&&typeof e=="object"?e:null;l(t),s(null),r(t,"manual-refresh")}catch(e){s(e?.message||String(e))}},[r]),d=a.useCallback(async()=>{try{const e=await c(),t=e&&typeof e=="object"?e:null;l(t),s(null),r(t,"page-load")}catch(e){s(e?.message||String(e))}},[r]);return a.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const e=15e3;let t=Date.now();const n=()=>{if(document.visibilityState!=="visible")return;const h=Date.now();h-t<e||(t=h,d())};return window.addEventListener("focus",n),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("focus",n),document.removeEventListener("visibilitychange",n)}},[d]),a.useEffect(()=>{if(o&&!u)return;let e=!1;return(async()=>{try{const t=await c();if(e)return;const n=t&&typeof t=="object"?t:null;l(n),s(null),r(n,"page-load")}catch(t){if(e)return;s(t?.message||String(t))}finally{e||g(!1)}})(),()=>{e=!0}},[o,u,r]),{data:b,error:m,isLoading:y,refresh:S}}export{v as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,c1 as t,c2 as r,K as c}from"./main-
|
|
1
|
+
import{r as e,c1 as t,c2 as r,K as c}from"./main-DADupgLA.js";const s=Object.freeze({currency:c,rate:1,symbol:"$",rates:{...r},rateSource:"default",rateFetchedAt:null,setCurrency:()=>{}});function a(){return e.useContext(t)??s}export{a as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as _t,b5 as St,b3 as G,b6 as Tt,bD as D,d9 as vt,cz as Ot,j as Te,cF as ze,r as f,bB as U,cH as ot,da as Bt,b7 as ct,bA as Ae,c5 as Gt,cG as it,db as wt,bF as x,bE as xe,c0 as Ee,dc as $e,dd as le,cL as ae,bJ as C,bK as Kt,d3 as Ct,cX as Dt,cY as Xt,d6 as xt,c6 as Vt,bX as ut,bS as lt,bU as Ut,de as $t,cM as qt,bG as Re,bW as jt,c_ as zt,b as Me,bP as Jt,df as Je,ba as We,dg as Qt,dh as He,bM as Zt,di as en,bz as Ne,bN as tn,cE as nn,bC as Ce,cv as _e,cu as rn,dj as sn,cs as on,bL as cn,dk as un,bQ as Se,dl as ye,be as ln,b9 as Be,dm as an,dn as at,d0 as fn,cA as Qe}from"./main-BbEXIjk8.js";const dn=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],jn=_t("check",dn);function Ie(e,t,n=!0){return e.filter(s=>s.parentId===t).flatMap(s=>[...!n||s.context?.open?[s]:[],...Ie(e,s.id,n)])}function ft(e,t){let n=[],r=e.find(s=>s.id===t)?.parentId;for(;r;){const s=e.find(c=>c.id===r);r=s?.parentId,s&&(n=n.concat(s))}return n}function Ge(e){const t=St(pn,e).current;return t.next=e,G(t.effect),t}function pn(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}let Fe=0;function Ke(e,t={}){const{preventScroll:n=!1,sync:r=!1,shouldFocus:s}=t;cancelAnimationFrame(Fe);function c(){s&&!s()||e?.focus({preventScroll:n})}if(r)return c(),Tt;const o=requestAnimationFrame(c);return Fe=o,()=>{Fe===o&&(cancelAnimationFrame(o),Fe=0)}}const De={inert:new WeakMap,"aria-hidden":new WeakMap},dt="data-base-ui-inert",qe={inert:new WeakSet,"aria-hidden":new WeakSet};let we=new WeakMap,Xe=0;function gn(e){return qe[e]}function It(e){return e?vt(e)?e.host:It(e.parentNode):null}const Ve=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=It(n);return e.contains(r)?r:null}).filter(n=>n!=null),pt=e=>{const t=new Set;return e.forEach(n=>{let r=n;for(;r&&!t.has(r);)t.add(r),r=r.parentNode}),t},gt=(e,t,n)=>{const r=[],s=c=>{!c||n.has(c)||Array.from(c.children).forEach(o=>{Ot(o)!=="script"&&(t.has(o)?s(o):r.push(o))})};return s(e),r};function hn(e,t,n,r,{mark:s=!0,markerIgnoreElements:c=[]}){const o=r?"inert":n?"aria-hidden":null;let u=null,v=null;const M=Ve(t,e),O=s?Ve(t,c):[],A=new Set(O),z=s?gt(t,pt(M),new Set(M)).filter(m=>!A.has(m)):[],w=[],k=[];if(o){const m=De[o],y=gn(o);v=y,u=m;const b=Ve(t,Array.from(t.querySelectorAll("[aria-live]"))),E=M.concat(b);gt(t,pt(E),new Set(E)).forEach(N=>{const Y=N.getAttribute(o),J=Y!==null&&Y!=="false",I=(m.get(N)||0)+1;m.set(N,I),w.push(N),I===1&&J&&y.add(N),J||N.setAttribute(o,o==="inert"?"":"true")})}return s&&z.forEach(m=>{const y=(we.get(m)||0)+1;we.set(m,y),k.push(m),y===1&&m.setAttribute(dt,"")}),Xe+=1,()=>{u&&w.forEach(m=>{const b=(u.get(m)||0)-1;u.set(m,b),b||(!v?.has(m)&&o&&m.removeAttribute(o),v?.delete(m))}),s&&k.forEach(m=>{const y=(we.get(m)||0)-1;we.set(m,y),y||m.removeAttribute(dt)}),Xe-=1,Xe||(De.inert=new WeakMap,De["aria-hidden"]=new WeakMap,qe.inert=new WeakSet,qe["aria-hidden"]=new WeakSet,we=new WeakMap)}}function ht(e,t={}){const{ariaHidden:n=!1,inert:r=!1,mark:s=!0,markerIgnoreElements:c=[]}=t,o=D(e[0]).body;return hn(e,o,n,r,{mark:s,markerIgnoreElements:c})}function kt(){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 mn{nodesRef={current:[]};events=kt();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 Pt=f.createContext(null),Ft=f.createContext(null),Ze=()=>f.useContext(Pt)?.id||null,et=e=>{const t=f.useContext(Ft);return e??t};function zn(e){const t=ze(),n=et(e),r=Ze();return G(()=>{if(!t)return;const s={id:t,parentId:r};return n?.addNode(s),()=>{n?.removeNode(s)}},[n,t,r]),t}function Jn(e){const{children:t,id:n}=e,r=Ze();return Te.jsx(Pt.Provider,{value:f.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Qn(e){const{children:t,externalTree:n}=e,r=St(()=>n??new mn).current;return Te.jsx(Ft.Provider,{value:r,children:t})}function bn(e,t){const n=We(Re(e));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 mt=20;let fe=[];function tt(){fe=fe.filter(e=>e.deref()?.isConnected)}function En(e){tt(),e&&Ot(e)!=="body"&&(fe.push(new WeakRef(e)),fe.length>mt&&(fe=fe.slice(-mt)))}function Ue(){return tt(),fe[fe.length-1]?.deref()}function yn(e){return e?Je(e)?e:wt(e)[0]||e:null}function bt(e,t){if(e.hasAttribute("tabindex")&&!e.hasAttribute("data-tabindex")||!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const r=Qt(e).filter(c=>{const o=c.getAttribute("data-tabindex")||"";return Je(c)||c.hasAttribute("data-tabindex")&&!o.startsWith("-")}),s=e.getAttribute("tabindex");t.current.includes("floating")||r.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 Zn(e){const{context:t,children:n,disabled:r=!1,initialFocus:s=!0,returnFocus:c=!0,restoreFocus:o=!1,modal:u=!0,closeOnFocusOut:v=!0,openInteractionType:M="",nextFocusableElement:O,previousFocusableElement:A,beforeContentFocusGuardRef:z,externalTree:w,getInsideElements:k}=e,m="rootStore"in t?t.rootStore:t,y=m.useState("open"),b=m.useState("domReferenceElement"),E=m.useState("floatingElement"),{events:Z,dataRef:N}=m.context,Y=U(()=>N.current.floatingContext?.nodeId),J=s===!1,I=ot(b)&&J,ee=f.useRef(["content"]),se=Ge(s),P=Ge(c),ie=Ge(M),j=et(w),p=Bt(),$=f.useRef(!1),Q=f.useRef(!1),de=f.useRef(!1),oe=f.useRef(null),te=f.useRef(""),pe=f.useRef(""),ge=f.useRef(null),he=f.useRef(null),ke=ct(ge,z,p?.beforeInsideRef),R=ct(he,p?.afterInsideRef),q=Ae(),ce=Ae(),me=Gt(),Pe=p!=null,g=it(E),K=U((a=g)=>a?wt(a):[]),ne=U(()=>k?.().filter(a=>a!=null)??[]);f.useEffect(()=>{if(r||!u)return;function a(H){H.key==="Tab"&&C(g,ae(D(g)))&&K().length===0&&!I&&qt(H)}const W=D(g);return x(W,"keydown",a)},[r,g,u,I,K]),f.useEffect(()=>{if(r||!y)return;const a=D(g);function W(){de.current=!1}function H(S){const h=Re(S),F=ne(),d=C(E,h)||C(b,h)||C(p?.portalNode,h)||F.some(_=>_===h||C(_,h));de.current=!d,pe.current=S.pointerType||"keyboard",h?.closest(`[${jt}]`)&&(Q.current=!0)}function L(){pe.current="keyboard"}return xe(x(a,"pointerdown",H,!0),x(a,"pointerup",W,!0),x(a,"pointercancel",W,!0),x(a,"keydown",L,!0))},[r,E,b,g,y,p,ne]),f.useEffect(()=>{if(r||!v)return;const a=D(g);function W(){Q.current=!0,ce.start(0,()=>{Q.current=!1})}function H(F){const d=Re(F);Je(d)&&(oe.current=d)}function L(F){const d=F.relatedTarget,_=F.currentTarget,X=Re(F);queueMicrotask(()=>{const be=Y(),V=m.context.triggerElements,Le=ne(),i=d?.hasAttribute($e("focus-guard"))&&[ge.current,he.current,p?.beforeInsideRef.current,p?.afterInsideRef.current,p?.beforeOutsideRef.current,p?.afterOutsideRef.current,le(A),le(O)].includes(d),l=!(C(b,d)||C(E,d)||C(d,E)||C(p?.portalNode,d)||Le.some(T=>T===d||C(T,d))||d!=null&&V.hasElement(d)||V.hasMatchingElement(T=>C(T,d))||i||j&&(Ie(j.nodesRef.current,be).find(T=>C(T.context?.elements.floating,d)||C(T.context?.elements.domReference,d))||ft(j.nodesRef.current,be).find(T=>[T.context?.elements.floating,it(T.context?.elements.floating)].includes(d)||T.context?.elements.domReference===d)));if(_===b&&g&&bt(g,ee),o&&_!==b&&!zt(X)&&ae(a)===a.body){if(Ee(g)&&(g.focus(),o==="popup")){me.request(()=>{g.focus()});return}const T=K(),B=oe.current,ue=(B&&T.includes(B)?B:null)||T[T.length-1]||g;Ee(ue)&&ue.focus()}if(N.current.insideReactTree){N.current.insideReactTree=!1;return}(I||!u)&&d&&l&&!Q.current&&(I||d!==Ue())&&($.current=!0,m.setOpen(!1,Me(Jt,F)))})}function S(){de.current||(N.current.insideReactTree=!0,q.start(0,()=>{N.current.insideReactTree=!1}))}const h=Ee(b)?b:null;if(!(!E&&!h))return xe(h&&x(h,"focusout",L),h&&x(h,"pointerdown",W),E&&x(E,"focusin",H),E&&x(E,"focusout",L),E&&p&&x(E,"focusout",S,!0))},[r,b,E,g,u,j,p,m,v,o,K,I,Y,ee,N,q,ce,me,O,A,ne]),f.useEffect(()=>{if(r||!E||!y)return;const a=Array.from(p?.portalNode?.querySelectorAll(`[${$e("portal")}]`)||[]),H=(j?ft(j.nodesRef.current,Y()):[]).find(_=>ot(_.context?.elements.domReference||null))?.context?.elements.domReference,S=[...[E,...a,ge.current,he.current,p?.beforeOutsideRef.current,p?.afterOutsideRef.current,...ne()],H,le(A),le(O),I?b:null].filter(_=>_!=null),h=ht(S,{ariaHidden:u||I,mark:!1}),F=[E,...a].filter(_=>_!=null),d=ht(F);return()=>{d(),h()}},[y,r,b,E,u,p,I,j,Y,O,A,ne]),G(()=>{if(!y||r||!Ee(g))return;const a=D(g),W=ae(a);queueMicrotask(()=>{const H=se.current,L=typeof H=="function"?H(ie.current||""):H;if(L===void 0||L===!1||C(g,W))return;let h=null;const F=()=>(h==null&&(h=K(g)),h[0]||g);let d;L===!0||L===null?d=F():d=le(L),d=d||F();const _=C(g,ae(a));Ke(d,{preventScroll:d===g,shouldFocus(){if(_)return!0;const X=ae(a);return!(X!==d&&C(g,X))}})})},[r,y,g,K,se,ie]),G(()=>{if(r||!g)return;const a=D(g),W=ae(a);En(W);function H(S){if(S.open||(te.current=bn(S.nativeEvent,pe.current)),S.reason===Kt&&S.nativeEvent.type==="mouseleave"&&($.current=!0),S.reason===Ct)if(S.nested)$.current=!1;else if(Dt(S.nativeEvent)||Xt(S.nativeEvent))$.current=!1;else{let h=!1;D(g).createElement("div").focus({get preventScroll(){return h=!0,!1}}),h?$.current=!1:$.current=!0}}Z.on("openchange",H);function L(){const S=P.current;let h=typeof S=="function"?S(te.current):S;if(h===void 0||h===!1)return null;if(h===null&&(h=!0),typeof h=="boolean")return b?.isConnected?b:Ue()||null;const F=b?.isConnected?b:Ue();return le(h)||F||null}return()=>{Z.off("openchange",H);const S=ae(a),h=ne(),F=C(E,S)||h.some(X=>X===S||C(X,S))||j&&Ie(j.nodesRef.current,Y(),!1).some(X=>C(X.context?.elements.floating,S)),d=P.current,_=L();queueMicrotask(()=>{const X=yn(_),be=typeof d!="boolean";d&&!$.current&&Ee(X)&&(!(!be&&X!==S&&S!==a.body)||F)&&X.focus({preventScroll:!0}),$.current=!1})}},[r,E,g,P,Z,j,b,Y,ne]),G(()=>{if(!xt||y||!E)return;const a=ae(D(E));!Ee(a)||!Vt(a)||C(E,a)&&a.blur()},[y,E]),G(()=>{if(!(r||!p))return p.setFocusManagerState({modal:u,closeOnFocusOut:v,open:y,onOpenChange:m.setOpen,domReference:b}),()=>{p.setFocusManagerState(null)}},[r,p,u,y,m,v,b]),G(()=>{if(!(r||!g))return bt(g,ee),()=>{queueMicrotask(tt)}},[r,g,ee]);const ve=!r&&(u?!I:!0)&&(Pe||u);return Te.jsxs(f.Fragment,{children:[ve&&Te.jsx(ut,{"data-type":"inside",ref:ke,onFocus:a=>{if(u){const W=K();Ke(W[W.length-1])}else p?.portalNode&&($.current=!1,lt(a,p.portalNode)?Ut(b)?.focus():le(A??p.beforeOutsideRef)?.focus())}}),n,ve&&Te.jsx(ut,{"data-type":"inside",ref:R,onFocus:a=>{u?Ke(K()[0]):p?.portalNode&&(v&&($.current=!0),lt(a,p.portalNode)?$t(b)?.focus():le(O??p.afterOutsideRef)?.focus())}})]})}const Rn={intentional:"onClick",sloppy:"onPointerDown"};function Sn(){return!1}function Tn(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function er(e,t={}){const{enabled:n=!0,escapeKey:r=!0,outsidePress:s=!0,outsidePressEvent:c="sloppy",referencePress:o=Sn,referencePressEvent:u="sloppy",bubbles:v,externalTree:M}=t,O="rootStore"in e?e.rootStore:e,A=O.useState("open"),z=O.useState("floatingElement"),{dataRef:w}=O.context,k=et(M),m=U(typeof s=="function"?s:()=>!1),y=typeof s=="function"?m:s,b=y!==!1,E=U(()=>c),{escapeKey:Z,outsidePress:N}=Tn(v),Y=f.useRef(!1),J=f.useRef(!1),I=f.useRef(!1),ee=f.useRef(!1),se=f.useRef(""),P=f.useRef(null),ie=Ae(),j=Ae(),p=U(()=>{j.clear(),w.current.insideReactTree=!1}),$=U(R=>{const q=w.current.floatingContext?.nodeId;return(k?Ie(k.nodesRef.current,q):[]).some(me=>me.context?.open&&!me.context.dataRef.current[R])}),Q=U(R=>He(R,O.select("floatingElement"))||He(R,O.select("domReferenceElement"))),de=U(R=>{o()&&O.setOpen(!1,Me(Zt,R.nativeEvent))}),oe=U(R=>{if(!A||!n||!r||R.key!=="Escape"||ee.current||!Z&&$("__escapeKeyBubbles"))return;const q=en(R)?R.nativeEvent:R,ce=Me(tn,q);O.setOpen(!1,ce),ce.isCanceled||R.preventDefault(),!Z&&!ce.isPropagationAllowed&&R.stopPropagation()}),te=U(()=>{w.current.insideReactTree=!0,j.start(0,p)}),pe=U(R=>{if(!A||!n||R.button!==0)return;const q=Re(R.nativeEvent);C(O.select("floatingElement"),q)&&(Y.current||(Y.current=!0,J.current=!1))}),ge=U(R=>{!A||!n||(R.defaultPrevented||R.nativeEvent.defaultPrevented)&&Y.current&&(J.current=!0)});f.useEffect(()=>{if(!A||!n)return;w.current.__escapeKeyBubbles=Z,w.current.__outsidePressBubbles=N;const R=new Ne,q=new Ne;function ce(){R.clear(),ee.current=!0}function me(){R.start(nn()?5:0,()=>{ee.current=!1})}function Pe(){I.current=!0,q.start(0,()=>{I.current=!1})}function g(){Y.current=!1,J.current=!1}function K(){const i=se.current,l=i==="pen"||!i?"mouse":i,T=E(),B=typeof T=="function"?T():T;return typeof B=="string"?B:B[l]}function ne(i){const l=K();return l==="intentional"&&i.type!=="click"||l==="sloppy"&&i.type==="click"}function ve(i){const l=w.current.floatingContext?.nodeId,T=k&&Ie(k.nodesRef.current,l).some(B=>He(i,B.context?.elements.floating));return Q(i)||T}function a(i){if(ne(i)){i.type!=="click"&&!Q(i)&&(q.clear(),I.current=!1),p();return}if(w.current.insideReactTree){p();return}const l=Re(i),T=`[${$e("inert")}]`,B=Ce(l)?l.getRootNode():null,ue=Array.from((vt(B)?B:D(O.select("floatingElement"))).querySelectorAll(T)),rt=O.context.triggerElements;if(l&&(rt.hasElement(l)||rt.hasMatchingElement(re=>C(re,l))))return;let Oe=Ce(l)?l:null;for(;Oe&&!_e(Oe);){const re=rn(Oe);if(_e(re)||!Ce(re))break;Oe=re}if(!(ue.length&&Ce(l)&&!sn(l)&&!C(l,O.select("floatingElement"))&&ue.every(re=>!C(Oe,re)))){if(Ee(l)&&!("touches"in i)){const re=_e(l),Ye=on(l),st=/auto|scroll/,Mt=re||st.test(Ye.overflowX),At=re||st.test(Ye.overflowY),Nt=Mt&&l.clientWidth>0&&l.scrollWidth>l.clientWidth,Wt=At&&l.clientHeight>0&&l.scrollHeight>l.clientHeight,Lt=Ye.direction==="rtl",Yt=Wt&&(Lt?i.offsetX<=l.offsetWidth-l.clientWidth:i.offsetX>l.clientWidth),Ht=Nt&&i.offsetY>l.clientHeight;if(Yt||Ht)return}if(!ve(i)){if(K()==="intentional"&&I.current){q.clear(),I.current=!1;return}typeof y=="function"&&!y(i)||$("__outsidePressBubbles")||(O.setOpen(!1,Me(Ct,i)),p())}}}function W(i){K()!=="sloppy"||i.pointerType==="touch"||!O.select("open")||!n||Q(i)||a(i)}function H(i){if(K()!=="sloppy"||!O.select("open")||!n||Q(i))return;const l=i.touches[0];l&&(P.current={startTime:Date.now(),startX:l.clientX,startY:l.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},ie.start(1e3,()=>{P.current&&(P.current.dismissOnTouchEnd=!1,P.current.dismissOnMouseDown=!1)}))}function L(i,l){const T=Re(i);if(!T)return;const B=x(T,i.type,()=>{l(i),B()})}function S(i){se.current="touch",L(i,H)}function h(i){ie.clear(),i.type==="pointerdown"&&(se.current=i.pointerType),!(i.type==="mousedown"&&P.current&&!P.current.dismissOnMouseDown)&&L(i,l=>{l.type==="pointerdown"?W(l):a(l)})}function F(i){if(!Y.current)return;const l=J.current;if(g(),K()==="intentional"){if(i.type==="pointercancel"){l&&Pe();return}if(!ve(i)){if(l){Pe();return}typeof y=="function"&&!y(i)||(q.clear(),I.current=!0,p())}}}function d(i){if(K()!=="sloppy"||!P.current||Q(i))return;const l=i.touches[0];if(!l)return;const T=Math.abs(l.clientX-P.current.startX),B=Math.abs(l.clientY-P.current.startY),ue=Math.sqrt(T*T+B*B);ue>5&&(P.current.dismissOnTouchEnd=!0),ue>10&&(a(i),ie.clear(),P.current=null)}function _(i){L(i,d)}function X(i){K()!=="sloppy"||!P.current||Q(i)||(P.current.dismissOnTouchEnd&&a(i),ie.clear(),P.current=null)}function be(i){L(i,X)}const V=D(z),Le=xe(r&&xe(x(V,"keydown",oe),x(V,"compositionstart",ce),x(V,"compositionend",me)),b&&xe(x(V,"click",h,!0),x(V,"pointerdown",h,!0),x(V,"pointerup",F,!0),x(V,"pointercancel",F,!0),x(V,"mousedown",h,!0),x(V,"mouseup",F,!0),x(V,"touchstart",S,!0),x(V,"touchmove",_,!0),x(V,"touchend",be,!0)));return()=>{Le(),R.clear(),q.clear(),g(),I.current=!1}},[w,z,r,b,y,A,n,Z,N,oe,p,E,$,Q,k,O,ie]),f.useEffect(p,[y,p]);const he=f.useMemo(()=>({onKeyDown:oe,[Rn[u]]:de,...u!=="intentional"&&{onClick:de}}),[oe,de,u]),ke=f.useMemo(()=>({onKeyDown:oe,onPointerDown:ge,onMouseDown:ge,onClickCapture:te,onMouseDownCapture(R){te(),pe(R)},onPointerDownCapture(R){te(),pe(R)},onMouseUpCapture:te,onTouchEndCapture:te,onTouchMoveCapture:te}),[oe,te,pe,ge]);return f.useMemo(()=>n?{reference:he,floating:ke,trigger:he}:{},[n,he,ke])}const vn={open:Se(e=>e.open),transitionStatus:Se(e=>e.transitionStatus),domReferenceElement:Se(e=>e.domReferenceElement),referenceElement:Se(e=>e.positionReference??e.referenceElement),floatingElement:Se(e=>e.floatingElement),floatingId:Se(e=>e.floatingId)};class On extends cn{constructor(t){const{syncOnly:n,nested:r,onOpenChange:s,triggerElements:c,...o}=t;super({...o,positionReference:o.referenceElement,domReferenceElement:o.referenceElement},{onOpenChange:s,dataRef:{current:{}},events:kt(),nested:r,triggerElements:c},vn),this.syncOnly=n}syncOpenEvent=(t,n)=>{(!t||!this.state.open||n!=null&&un(n))&&(this.context.dataRef.current.openEvent=t?n:void 0)};dispatchOpenChange=(t,n)=>{this.syncOpenEvent(t,n.event);const r={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",r)};setOpen=(t,n)=>{if(this.syncOnly){this.context.onOpenChange?.(t,n);return}this.dispatchOpenChange(t,n),this.context.onOpenChange?.(t,n)}}function wn(e){const{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:s,nested:c,onOpenChange:o}=e,u=t.useState("open"),v=t.useState("activeTriggerElement"),M=t.useState(n?"popupElement":"positionerElement"),O=t.context.triggerElements,A=o,z=f.useRef(null);r===void 0&&z.current===null&&(z.current=new On({open:u,transitionStatus:void 0,referenceElement:v,floatingElement:M,triggerElements:O,onOpenChange:A,floatingId:s,syncOnly:!0,nested:c}));const w=r??z.current;return t.useSyncedValue("floatingId",s),G(()=>{const k={open:u,floatingId:s,referenceElement:v,floatingElement:M};Ce(v)&&(k.domReferenceElement=v),w.state.positionReference===w.state.referenceElement&&(k.positionReference=v),w.update(k)},[u,s,v,M,w]),w.context.onOpenChange=A,w.context.nested=c,w}function Cn(e,t=!1,n=!1){const[r,s]=f.useState(e&&t?"idle":void 0),[c,o]=f.useState(e);return e&&!c&&(o(!0),s("starting")),!e&&c&&r!=="ending"&&!n&&s("ending"),!e&&!c&&r==="ending"&&s(void 0),G(()=>{if(!e&&c&&r!=="ending"&&n){const u=ye.request(()=>{s("ending")});return()=>{ye.cancel(u)}}},[e,c,r,n]),G(()=>{if(!e||t)return;const u=ye.request(()=>{s(void 0)});return()=>{ye.cancel(u)}},[t,e]),G(()=>{if(!e||!t)return;e&&c&&r!=="idle"&&s("starting");const u=ye.request(()=>{s("idle")});return()=>{ye.cancel(u)}},[t,e,c,r]),{mounted:c,setMounted:o,transitionStatus:r}}const tr={tabIndex:-1,[an]:""};function nr(e,t,n=!1){const r=ze(),s=Ze()!=null,c=f.useRef(null);e===void 0&&c.current===null&&(c.current=t(r,s));const o=e??c.current;return wn({popupStore:o,treatPopupAsFloatingElement:n,floatingRootContext:o.state.floatingRootContext,floatingId:r,nested:s,onOpenChange:o.setOpen}),{store:o,internalStore:c.current}}function xn(e,t){const n=f.useRef(null),r=f.useRef(null);return f.useCallback(s=>{if(e===void 0)return;let c=!1;if(n.current!==null){const o=n.current,u=r.current,v=t.context.triggerElements.getById(o);u&&v===u&&(t.context.triggerElements.delete(o),c=!0),n.current=null,r.current=null}if(s!==null&&(n.current=e,r.current=s,t.context.triggerElements.add(e,s),c=!0),c){const o=t.context.triggerElements.size;t.select("open")&&t.state.triggerCount!==o&&t.set("triggerCount",o)}},[t,e])}function rr(e,t,n){const r=n?.id??null;(r||t)&&(e.activeTriggerId=r,e.activeTriggerElement=n??null)}function sr(e,t,n,r){const s=n.useState("isMountedByTrigger",e),c=xn(e,n),o=U(u=>{if(c(u),!u)return;const v=n.select("open"),M=n.select("activeTriggerId");if(M===e){n.update({activeTriggerElement:u,...v?r:null});return}M==null&&v&&n.update({activeTriggerId:e,activeTriggerElement:u,...r})});return G(()=>{s&&n.update({activeTriggerElement:t.current,...r})},[s,n,t,...Object.values(r)]),{registerTrigger:o,isMountedByThisTrigger:s}}function or(e){const t=e.useState("open"),n=e.useState("triggerCount");G(()=>{if(!t){e.state.triggerCount!==0&&e.set("triggerCount",0);return}const r=e.context.triggerElements.size,s={};if(e.state.triggerCount!==r&&(s.triggerCount=r),!e.select("activeTriggerId")&&r===1){const c=e.context.triggerElements.entries().next();if(!c.done){const[o,u]=c.value;s.activeTriggerId=o,s.activeTriggerElement=u}}(s.triggerCount!==void 0||s.activeTriggerId!==void 0)&&e.update(s)},[t,e,n])}function cr(e,t,n){const{mounted:r,setMounted:s,transitionStatus:c}=Cn(e);t.useSyncedValues({mounted:r,transitionStatus:c});const o=U(()=>{s(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),u=t.useState("preventUnmountingOnClose");return ln({enabled:r&&!e&&!u,open:e,ref:t.context.popupRef,onComplete(){e||o()}}),{forceUnmount:o,transitionStatus:c}}function ir(e,t){e.useSyncedValues(t),G(()=>()=>{e.update({activeTriggerProps:Be,inactiveTriggerProps:Be,popupProps:Be})},[e])}function ur(e,t){G(()=>{!t&&e.state.openMethod!==null&&e.set("openMethod",null)},[t,e]),G(()=>()=>{e.state.openMethod!==null&&e.set("openMethod",null)},[e])}class lr{constructor(){this.elementsSet=new Set,this.idMap=new Map}add(t,n){const r=this.idMap.get(t);r!==n&&(r!==void 0&&this.elementsSet.delete(r),this.elementsSet.add(n),this.idMap.set(t,n))}delete(t){const n=this.idMap.get(t);n&&(this.elementsSet.delete(n),this.idMap.delete(t))}hasElement(t){return this.elementsSet.has(t)}hasMatchingElement(t){for(const n of this.elementsSet)if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}elements(){return this.elementsSet.values()}get size(){return this.idMap.size}}let nt=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=at.startingStyle]="startingStyle",e[e.endingStyle=at.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e.side="data-side",e.align="data-align",e})({}),je=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const In={[je.popupOpen]:""},kn={[je.popupOpen]:"",[je.pressed]:""},Pn={[nt.open]:""},Fn={[nt.closed]:""},Mn={[nt.anchorHidden]:""},ar={open(e){return e?In:null}},fr={open(e){return e?kn:null}},dr={open(e){return e?Pn:Fn},anchorHidden(e){return e?Mn:null}};function pr(e){return ze(e,"base-ui")}const An="ArrowUp",Nn="ArrowDown",Wn="ArrowLeft",Ln="ArrowRight",Yn="Home",Hn="End",_n=new Set([Wn,Ln]),Bn=new Set([An,Nn]),Gn=new Set([..._n,...Bn]),gr=new Set([...Gn,Yn,Hn]),hr=f.forwardRef(function(t,n){const{cutout:r,...s}=t;let c;if(r){const o=r.getBoundingClientRect();c=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${o.left}px ${o.top}px,${o.left}px ${o.bottom}px,${o.right}px ${o.bottom}px,${o.right}px ${o.top}px,${o.left}px ${o.top}px)`}return Te.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...s,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:c}})});function mr(e){const t=f.useRef(!0);t.current&&(t.current=!1,e())}let Et={},yt={},Rt="";function Kn(e){if(typeof document>"u")return!1;const t=D(e);return We(t).innerWidth-t.documentElement.clientWidth>0}function Dn(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=D(e),r=n.documentElement,s=n.body,c=Qe(r)?r:s,o=c.style.overflowY,u=r.style.scrollbarGutter;r.style.scrollbarGutter="stable",c.style.overflowY="scroll";const v=c.offsetWidth;c.style.overflowY="hidden";const M=c.offsetWidth;return c.style.overflowY=o,r.style.scrollbarGutter=u,v===M}function Xn(e){const t=D(e),n=t.documentElement,r=t.body,s=Qe(n)?n:r,c={overflowY:s.style.overflowY,overflowX:s.style.overflowX};return Object.assign(s.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(s.style,c)}}function Vn(e){const t=D(e),n=t.documentElement,r=t.body,s=We(n);let c=0,o=0,u=!1;const v=ye.create();if(xt&&(s.visualViewport?.scale??1)!==1)return()=>{};function M(){const w=s.getComputedStyle(n),k=s.getComputedStyle(r),b=(w.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";c=n.scrollTop,o=n.scrollLeft,Et={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Rt=n.style.scrollBehavior,yt={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 E=n.scrollHeight>n.clientHeight,Z=n.scrollWidth>n.clientWidth,N=w.overflowY==="scroll"||k.overflowY==="scroll",Y=w.overflowX==="scroll"||k.overflowX==="scroll",J=Math.max(0,s.innerWidth-r.clientWidth),I=Math.max(0,s.innerHeight-r.clientHeight),ee=parseFloat(k.marginTop)+parseFloat(k.marginBottom),se=parseFloat(k.marginLeft)+parseFloat(k.marginRight),P=Qe(n)?n:r;if(u=Dn(e),u){n.style.scrollbarGutter=b,P.style.overflowY="hidden",P.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:b,overflowY:"hidden",overflowX:"hidden"}),(E||N)&&(n.style.overflowY="scroll"),(Z||Y)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:ee||I?`calc(100dvh - ${ee+I}px)`:"100dvh",width:se||J?`calc(100vw - ${se+J}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=c,r.scrollLeft=o,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function O(){Object.assign(n.style,Et),Object.assign(r.style,yt),u||(n.scrollTop=c,n.scrollLeft=o,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=Rt)}function A(){O(),v.request(M)}M();const z=x(s,"resize",A);return()=>{v.cancel(),O(),typeof s.removeEventListener=="function"&&z()}}class Un{lockCount=0;restore=null;timeoutLock=Ne.create();timeoutUnlock=Ne.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=D(t).documentElement,s=We(r).getComputedStyle(r).overflowY;if(s==="hidden"||s==="clip"){this.restore=Tt;return}const c=fn||!Kn(t);this.restore=c?Xn(t):Vn(t)}}const $n=new Un;function br(e=!0,t=null){G(()=>{if(e)return $n.acquire(t)},[e,t])}export{nt as A,jn as C,Qn as F,hr as I,lr as P,Cn as a,et as b,Ze as c,Ge as d,nr as e,mr as f,Ie as g,ur as h,or as i,cr as j,er as k,tr as l,ir as m,sr as n,zn as o,fr as p,Jn as q,Zn as r,rr as s,ar as t,pr as u,gr as v,dr as w,On as x,Ke as y,br as z};
|
|
1
|
+
import{c as _t,b5 as St,b3 as G,b6 as Tt,bD as D,d9 as vt,cz as Ot,j as Te,cF as ze,r as f,bB as U,cH as ot,da as Bt,b7 as ct,bA as Ae,c5 as Gt,cG as it,db as wt,bF as x,bE as xe,c0 as Ee,dc as $e,dd as le,cL as ae,bJ as C,bK as Kt,d3 as Ct,cX as Dt,cY as Xt,d6 as xt,c6 as Vt,bX as ut,bS as lt,bU as Ut,de as $t,cM as qt,bG as Re,bW as jt,c_ as zt,b as Me,bP as Jt,df as Je,ba as We,dg as Qt,dh as He,bM as Zt,di as en,bz as Ne,bN as tn,cE as nn,bC as Ce,cv as _e,cu as rn,dj as sn,cs as on,bL as cn,dk as un,bQ as Se,dl as ye,be as ln,b9 as Be,dm as an,dn as at,d0 as fn,cA as Qe}from"./main-DADupgLA.js";const dn=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],jn=_t("check",dn);function Ie(e,t,n=!0){return e.filter(s=>s.parentId===t).flatMap(s=>[...!n||s.context?.open?[s]:[],...Ie(e,s.id,n)])}function ft(e,t){let n=[],r=e.find(s=>s.id===t)?.parentId;for(;r;){const s=e.find(c=>c.id===r);r=s?.parentId,s&&(n=n.concat(s))}return n}function Ge(e){const t=St(pn,e).current;return t.next=e,G(t.effect),t}function pn(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}let Fe=0;function Ke(e,t={}){const{preventScroll:n=!1,sync:r=!1,shouldFocus:s}=t;cancelAnimationFrame(Fe);function c(){s&&!s()||e?.focus({preventScroll:n})}if(r)return c(),Tt;const o=requestAnimationFrame(c);return Fe=o,()=>{Fe===o&&(cancelAnimationFrame(o),Fe=0)}}const De={inert:new WeakMap,"aria-hidden":new WeakMap},dt="data-base-ui-inert",qe={inert:new WeakSet,"aria-hidden":new WeakSet};let we=new WeakMap,Xe=0;function gn(e){return qe[e]}function It(e){return e?vt(e)?e.host:It(e.parentNode):null}const Ve=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=It(n);return e.contains(r)?r:null}).filter(n=>n!=null),pt=e=>{const t=new Set;return e.forEach(n=>{let r=n;for(;r&&!t.has(r);)t.add(r),r=r.parentNode}),t},gt=(e,t,n)=>{const r=[],s=c=>{!c||n.has(c)||Array.from(c.children).forEach(o=>{Ot(o)!=="script"&&(t.has(o)?s(o):r.push(o))})};return s(e),r};function hn(e,t,n,r,{mark:s=!0,markerIgnoreElements:c=[]}){const o=r?"inert":n?"aria-hidden":null;let u=null,v=null;const M=Ve(t,e),O=s?Ve(t,c):[],A=new Set(O),z=s?gt(t,pt(M),new Set(M)).filter(m=>!A.has(m)):[],w=[],k=[];if(o){const m=De[o],y=gn(o);v=y,u=m;const b=Ve(t,Array.from(t.querySelectorAll("[aria-live]"))),E=M.concat(b);gt(t,pt(E),new Set(E)).forEach(N=>{const Y=N.getAttribute(o),J=Y!==null&&Y!=="false",I=(m.get(N)||0)+1;m.set(N,I),w.push(N),I===1&&J&&y.add(N),J||N.setAttribute(o,o==="inert"?"":"true")})}return s&&z.forEach(m=>{const y=(we.get(m)||0)+1;we.set(m,y),k.push(m),y===1&&m.setAttribute(dt,"")}),Xe+=1,()=>{u&&w.forEach(m=>{const b=(u.get(m)||0)-1;u.set(m,b),b||(!v?.has(m)&&o&&m.removeAttribute(o),v?.delete(m))}),s&&k.forEach(m=>{const y=(we.get(m)||0)-1;we.set(m,y),y||m.removeAttribute(dt)}),Xe-=1,Xe||(De.inert=new WeakMap,De["aria-hidden"]=new WeakMap,qe.inert=new WeakSet,qe["aria-hidden"]=new WeakSet,we=new WeakMap)}}function ht(e,t={}){const{ariaHidden:n=!1,inert:r=!1,mark:s=!0,markerIgnoreElements:c=[]}=t,o=D(e[0]).body;return hn(e,o,n,r,{mark:s,markerIgnoreElements:c})}function kt(){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 mn{nodesRef={current:[]};events=kt();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 Pt=f.createContext(null),Ft=f.createContext(null),Ze=()=>f.useContext(Pt)?.id||null,et=e=>{const t=f.useContext(Ft);return e??t};function zn(e){const t=ze(),n=et(e),r=Ze();return G(()=>{if(!t)return;const s={id:t,parentId:r};return n?.addNode(s),()=>{n?.removeNode(s)}},[n,t,r]),t}function Jn(e){const{children:t,id:n}=e,r=Ze();return Te.jsx(Pt.Provider,{value:f.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Qn(e){const{children:t,externalTree:n}=e,r=St(()=>n??new mn).current;return Te.jsx(Ft.Provider,{value:r,children:t})}function bn(e,t){const n=We(Re(e));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 mt=20;let fe=[];function tt(){fe=fe.filter(e=>e.deref()?.isConnected)}function En(e){tt(),e&&Ot(e)!=="body"&&(fe.push(new WeakRef(e)),fe.length>mt&&(fe=fe.slice(-mt)))}function Ue(){return tt(),fe[fe.length-1]?.deref()}function yn(e){return e?Je(e)?e:wt(e)[0]||e:null}function bt(e,t){if(e.hasAttribute("tabindex")&&!e.hasAttribute("data-tabindex")||!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const r=Qt(e).filter(c=>{const o=c.getAttribute("data-tabindex")||"";return Je(c)||c.hasAttribute("data-tabindex")&&!o.startsWith("-")}),s=e.getAttribute("tabindex");t.current.includes("floating")||r.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 Zn(e){const{context:t,children:n,disabled:r=!1,initialFocus:s=!0,returnFocus:c=!0,restoreFocus:o=!1,modal:u=!0,closeOnFocusOut:v=!0,openInteractionType:M="",nextFocusableElement:O,previousFocusableElement:A,beforeContentFocusGuardRef:z,externalTree:w,getInsideElements:k}=e,m="rootStore"in t?t.rootStore:t,y=m.useState("open"),b=m.useState("domReferenceElement"),E=m.useState("floatingElement"),{events:Z,dataRef:N}=m.context,Y=U(()=>N.current.floatingContext?.nodeId),J=s===!1,I=ot(b)&&J,ee=f.useRef(["content"]),se=Ge(s),P=Ge(c),ie=Ge(M),j=et(w),p=Bt(),$=f.useRef(!1),Q=f.useRef(!1),de=f.useRef(!1),oe=f.useRef(null),te=f.useRef(""),pe=f.useRef(""),ge=f.useRef(null),he=f.useRef(null),ke=ct(ge,z,p?.beforeInsideRef),R=ct(he,p?.afterInsideRef),q=Ae(),ce=Ae(),me=Gt(),Pe=p!=null,g=it(E),K=U((a=g)=>a?wt(a):[]),ne=U(()=>k?.().filter(a=>a!=null)??[]);f.useEffect(()=>{if(r||!u)return;function a(H){H.key==="Tab"&&C(g,ae(D(g)))&&K().length===0&&!I&&qt(H)}const W=D(g);return x(W,"keydown",a)},[r,g,u,I,K]),f.useEffect(()=>{if(r||!y)return;const a=D(g);function W(){de.current=!1}function H(S){const h=Re(S),F=ne(),d=C(E,h)||C(b,h)||C(p?.portalNode,h)||F.some(_=>_===h||C(_,h));de.current=!d,pe.current=S.pointerType||"keyboard",h?.closest(`[${jt}]`)&&(Q.current=!0)}function L(){pe.current="keyboard"}return xe(x(a,"pointerdown",H,!0),x(a,"pointerup",W,!0),x(a,"pointercancel",W,!0),x(a,"keydown",L,!0))},[r,E,b,g,y,p,ne]),f.useEffect(()=>{if(r||!v)return;const a=D(g);function W(){Q.current=!0,ce.start(0,()=>{Q.current=!1})}function H(F){const d=Re(F);Je(d)&&(oe.current=d)}function L(F){const d=F.relatedTarget,_=F.currentTarget,X=Re(F);queueMicrotask(()=>{const be=Y(),V=m.context.triggerElements,Le=ne(),i=d?.hasAttribute($e("focus-guard"))&&[ge.current,he.current,p?.beforeInsideRef.current,p?.afterInsideRef.current,p?.beforeOutsideRef.current,p?.afterOutsideRef.current,le(A),le(O)].includes(d),l=!(C(b,d)||C(E,d)||C(d,E)||C(p?.portalNode,d)||Le.some(T=>T===d||C(T,d))||d!=null&&V.hasElement(d)||V.hasMatchingElement(T=>C(T,d))||i||j&&(Ie(j.nodesRef.current,be).find(T=>C(T.context?.elements.floating,d)||C(T.context?.elements.domReference,d))||ft(j.nodesRef.current,be).find(T=>[T.context?.elements.floating,it(T.context?.elements.floating)].includes(d)||T.context?.elements.domReference===d)));if(_===b&&g&&bt(g,ee),o&&_!==b&&!zt(X)&&ae(a)===a.body){if(Ee(g)&&(g.focus(),o==="popup")){me.request(()=>{g.focus()});return}const T=K(),B=oe.current,ue=(B&&T.includes(B)?B:null)||T[T.length-1]||g;Ee(ue)&&ue.focus()}if(N.current.insideReactTree){N.current.insideReactTree=!1;return}(I||!u)&&d&&l&&!Q.current&&(I||d!==Ue())&&($.current=!0,m.setOpen(!1,Me(Jt,F)))})}function S(){de.current||(N.current.insideReactTree=!0,q.start(0,()=>{N.current.insideReactTree=!1}))}const h=Ee(b)?b:null;if(!(!E&&!h))return xe(h&&x(h,"focusout",L),h&&x(h,"pointerdown",W),E&&x(E,"focusin",H),E&&x(E,"focusout",L),E&&p&&x(E,"focusout",S,!0))},[r,b,E,g,u,j,p,m,v,o,K,I,Y,ee,N,q,ce,me,O,A,ne]),f.useEffect(()=>{if(r||!E||!y)return;const a=Array.from(p?.portalNode?.querySelectorAll(`[${$e("portal")}]`)||[]),H=(j?ft(j.nodesRef.current,Y()):[]).find(_=>ot(_.context?.elements.domReference||null))?.context?.elements.domReference,S=[...[E,...a,ge.current,he.current,p?.beforeOutsideRef.current,p?.afterOutsideRef.current,...ne()],H,le(A),le(O),I?b:null].filter(_=>_!=null),h=ht(S,{ariaHidden:u||I,mark:!1}),F=[E,...a].filter(_=>_!=null),d=ht(F);return()=>{d(),h()}},[y,r,b,E,u,p,I,j,Y,O,A,ne]),G(()=>{if(!y||r||!Ee(g))return;const a=D(g),W=ae(a);queueMicrotask(()=>{const H=se.current,L=typeof H=="function"?H(ie.current||""):H;if(L===void 0||L===!1||C(g,W))return;let h=null;const F=()=>(h==null&&(h=K(g)),h[0]||g);let d;L===!0||L===null?d=F():d=le(L),d=d||F();const _=C(g,ae(a));Ke(d,{preventScroll:d===g,shouldFocus(){if(_)return!0;const X=ae(a);return!(X!==d&&C(g,X))}})})},[r,y,g,K,se,ie]),G(()=>{if(r||!g)return;const a=D(g),W=ae(a);En(W);function H(S){if(S.open||(te.current=bn(S.nativeEvent,pe.current)),S.reason===Kt&&S.nativeEvent.type==="mouseleave"&&($.current=!0),S.reason===Ct)if(S.nested)$.current=!1;else if(Dt(S.nativeEvent)||Xt(S.nativeEvent))$.current=!1;else{let h=!1;D(g).createElement("div").focus({get preventScroll(){return h=!0,!1}}),h?$.current=!1:$.current=!0}}Z.on("openchange",H);function L(){const S=P.current;let h=typeof S=="function"?S(te.current):S;if(h===void 0||h===!1)return null;if(h===null&&(h=!0),typeof h=="boolean")return b?.isConnected?b:Ue()||null;const F=b?.isConnected?b:Ue();return le(h)||F||null}return()=>{Z.off("openchange",H);const S=ae(a),h=ne(),F=C(E,S)||h.some(X=>X===S||C(X,S))||j&&Ie(j.nodesRef.current,Y(),!1).some(X=>C(X.context?.elements.floating,S)),d=P.current,_=L();queueMicrotask(()=>{const X=yn(_),be=typeof d!="boolean";d&&!$.current&&Ee(X)&&(!(!be&&X!==S&&S!==a.body)||F)&&X.focus({preventScroll:!0}),$.current=!1})}},[r,E,g,P,Z,j,b,Y,ne]),G(()=>{if(!xt||y||!E)return;const a=ae(D(E));!Ee(a)||!Vt(a)||C(E,a)&&a.blur()},[y,E]),G(()=>{if(!(r||!p))return p.setFocusManagerState({modal:u,closeOnFocusOut:v,open:y,onOpenChange:m.setOpen,domReference:b}),()=>{p.setFocusManagerState(null)}},[r,p,u,y,m,v,b]),G(()=>{if(!(r||!g))return bt(g,ee),()=>{queueMicrotask(tt)}},[r,g,ee]);const ve=!r&&(u?!I:!0)&&(Pe||u);return Te.jsxs(f.Fragment,{children:[ve&&Te.jsx(ut,{"data-type":"inside",ref:ke,onFocus:a=>{if(u){const W=K();Ke(W[W.length-1])}else p?.portalNode&&($.current=!1,lt(a,p.portalNode)?Ut(b)?.focus():le(A??p.beforeOutsideRef)?.focus())}}),n,ve&&Te.jsx(ut,{"data-type":"inside",ref:R,onFocus:a=>{u?Ke(K()[0]):p?.portalNode&&(v&&($.current=!0),lt(a,p.portalNode)?$t(b)?.focus():le(O??p.afterOutsideRef)?.focus())}})]})}const Rn={intentional:"onClick",sloppy:"onPointerDown"};function Sn(){return!1}function Tn(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function er(e,t={}){const{enabled:n=!0,escapeKey:r=!0,outsidePress:s=!0,outsidePressEvent:c="sloppy",referencePress:o=Sn,referencePressEvent:u="sloppy",bubbles:v,externalTree:M}=t,O="rootStore"in e?e.rootStore:e,A=O.useState("open"),z=O.useState("floatingElement"),{dataRef:w}=O.context,k=et(M),m=U(typeof s=="function"?s:()=>!1),y=typeof s=="function"?m:s,b=y!==!1,E=U(()=>c),{escapeKey:Z,outsidePress:N}=Tn(v),Y=f.useRef(!1),J=f.useRef(!1),I=f.useRef(!1),ee=f.useRef(!1),se=f.useRef(""),P=f.useRef(null),ie=Ae(),j=Ae(),p=U(()=>{j.clear(),w.current.insideReactTree=!1}),$=U(R=>{const q=w.current.floatingContext?.nodeId;return(k?Ie(k.nodesRef.current,q):[]).some(me=>me.context?.open&&!me.context.dataRef.current[R])}),Q=U(R=>He(R,O.select("floatingElement"))||He(R,O.select("domReferenceElement"))),de=U(R=>{o()&&O.setOpen(!1,Me(Zt,R.nativeEvent))}),oe=U(R=>{if(!A||!n||!r||R.key!=="Escape"||ee.current||!Z&&$("__escapeKeyBubbles"))return;const q=en(R)?R.nativeEvent:R,ce=Me(tn,q);O.setOpen(!1,ce),ce.isCanceled||R.preventDefault(),!Z&&!ce.isPropagationAllowed&&R.stopPropagation()}),te=U(()=>{w.current.insideReactTree=!0,j.start(0,p)}),pe=U(R=>{if(!A||!n||R.button!==0)return;const q=Re(R.nativeEvent);C(O.select("floatingElement"),q)&&(Y.current||(Y.current=!0,J.current=!1))}),ge=U(R=>{!A||!n||(R.defaultPrevented||R.nativeEvent.defaultPrevented)&&Y.current&&(J.current=!0)});f.useEffect(()=>{if(!A||!n)return;w.current.__escapeKeyBubbles=Z,w.current.__outsidePressBubbles=N;const R=new Ne,q=new Ne;function ce(){R.clear(),ee.current=!0}function me(){R.start(nn()?5:0,()=>{ee.current=!1})}function Pe(){I.current=!0,q.start(0,()=>{I.current=!1})}function g(){Y.current=!1,J.current=!1}function K(){const i=se.current,l=i==="pen"||!i?"mouse":i,T=E(),B=typeof T=="function"?T():T;return typeof B=="string"?B:B[l]}function ne(i){const l=K();return l==="intentional"&&i.type!=="click"||l==="sloppy"&&i.type==="click"}function ve(i){const l=w.current.floatingContext?.nodeId,T=k&&Ie(k.nodesRef.current,l).some(B=>He(i,B.context?.elements.floating));return Q(i)||T}function a(i){if(ne(i)){i.type!=="click"&&!Q(i)&&(q.clear(),I.current=!1),p();return}if(w.current.insideReactTree){p();return}const l=Re(i),T=`[${$e("inert")}]`,B=Ce(l)?l.getRootNode():null,ue=Array.from((vt(B)?B:D(O.select("floatingElement"))).querySelectorAll(T)),rt=O.context.triggerElements;if(l&&(rt.hasElement(l)||rt.hasMatchingElement(re=>C(re,l))))return;let Oe=Ce(l)?l:null;for(;Oe&&!_e(Oe);){const re=rn(Oe);if(_e(re)||!Ce(re))break;Oe=re}if(!(ue.length&&Ce(l)&&!sn(l)&&!C(l,O.select("floatingElement"))&&ue.every(re=>!C(Oe,re)))){if(Ee(l)&&!("touches"in i)){const re=_e(l),Ye=on(l),st=/auto|scroll/,Mt=re||st.test(Ye.overflowX),At=re||st.test(Ye.overflowY),Nt=Mt&&l.clientWidth>0&&l.scrollWidth>l.clientWidth,Wt=At&&l.clientHeight>0&&l.scrollHeight>l.clientHeight,Lt=Ye.direction==="rtl",Yt=Wt&&(Lt?i.offsetX<=l.offsetWidth-l.clientWidth:i.offsetX>l.clientWidth),Ht=Nt&&i.offsetY>l.clientHeight;if(Yt||Ht)return}if(!ve(i)){if(K()==="intentional"&&I.current){q.clear(),I.current=!1;return}typeof y=="function"&&!y(i)||$("__outsidePressBubbles")||(O.setOpen(!1,Me(Ct,i)),p())}}}function W(i){K()!=="sloppy"||i.pointerType==="touch"||!O.select("open")||!n||Q(i)||a(i)}function H(i){if(K()!=="sloppy"||!O.select("open")||!n||Q(i))return;const l=i.touches[0];l&&(P.current={startTime:Date.now(),startX:l.clientX,startY:l.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},ie.start(1e3,()=>{P.current&&(P.current.dismissOnTouchEnd=!1,P.current.dismissOnMouseDown=!1)}))}function L(i,l){const T=Re(i);if(!T)return;const B=x(T,i.type,()=>{l(i),B()})}function S(i){se.current="touch",L(i,H)}function h(i){ie.clear(),i.type==="pointerdown"&&(se.current=i.pointerType),!(i.type==="mousedown"&&P.current&&!P.current.dismissOnMouseDown)&&L(i,l=>{l.type==="pointerdown"?W(l):a(l)})}function F(i){if(!Y.current)return;const l=J.current;if(g(),K()==="intentional"){if(i.type==="pointercancel"){l&&Pe();return}if(!ve(i)){if(l){Pe();return}typeof y=="function"&&!y(i)||(q.clear(),I.current=!0,p())}}}function d(i){if(K()!=="sloppy"||!P.current||Q(i))return;const l=i.touches[0];if(!l)return;const T=Math.abs(l.clientX-P.current.startX),B=Math.abs(l.clientY-P.current.startY),ue=Math.sqrt(T*T+B*B);ue>5&&(P.current.dismissOnTouchEnd=!0),ue>10&&(a(i),ie.clear(),P.current=null)}function _(i){L(i,d)}function X(i){K()!=="sloppy"||!P.current||Q(i)||(P.current.dismissOnTouchEnd&&a(i),ie.clear(),P.current=null)}function be(i){L(i,X)}const V=D(z),Le=xe(r&&xe(x(V,"keydown",oe),x(V,"compositionstart",ce),x(V,"compositionend",me)),b&&xe(x(V,"click",h,!0),x(V,"pointerdown",h,!0),x(V,"pointerup",F,!0),x(V,"pointercancel",F,!0),x(V,"mousedown",h,!0),x(V,"mouseup",F,!0),x(V,"touchstart",S,!0),x(V,"touchmove",_,!0),x(V,"touchend",be,!0)));return()=>{Le(),R.clear(),q.clear(),g(),I.current=!1}},[w,z,r,b,y,A,n,Z,N,oe,p,E,$,Q,k,O,ie]),f.useEffect(p,[y,p]);const he=f.useMemo(()=>({onKeyDown:oe,[Rn[u]]:de,...u!=="intentional"&&{onClick:de}}),[oe,de,u]),ke=f.useMemo(()=>({onKeyDown:oe,onPointerDown:ge,onMouseDown:ge,onClickCapture:te,onMouseDownCapture(R){te(),pe(R)},onPointerDownCapture(R){te(),pe(R)},onMouseUpCapture:te,onTouchEndCapture:te,onTouchMoveCapture:te}),[oe,te,pe,ge]);return f.useMemo(()=>n?{reference:he,floating:ke,trigger:he}:{},[n,he,ke])}const vn={open:Se(e=>e.open),transitionStatus:Se(e=>e.transitionStatus),domReferenceElement:Se(e=>e.domReferenceElement),referenceElement:Se(e=>e.positionReference??e.referenceElement),floatingElement:Se(e=>e.floatingElement),floatingId:Se(e=>e.floatingId)};class On extends cn{constructor(t){const{syncOnly:n,nested:r,onOpenChange:s,triggerElements:c,...o}=t;super({...o,positionReference:o.referenceElement,domReferenceElement:o.referenceElement},{onOpenChange:s,dataRef:{current:{}},events:kt(),nested:r,triggerElements:c},vn),this.syncOnly=n}syncOpenEvent=(t,n)=>{(!t||!this.state.open||n!=null&&un(n))&&(this.context.dataRef.current.openEvent=t?n:void 0)};dispatchOpenChange=(t,n)=>{this.syncOpenEvent(t,n.event);const r={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",r)};setOpen=(t,n)=>{if(this.syncOnly){this.context.onOpenChange?.(t,n);return}this.dispatchOpenChange(t,n),this.context.onOpenChange?.(t,n)}}function wn(e){const{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:s,nested:c,onOpenChange:o}=e,u=t.useState("open"),v=t.useState("activeTriggerElement"),M=t.useState(n?"popupElement":"positionerElement"),O=t.context.triggerElements,A=o,z=f.useRef(null);r===void 0&&z.current===null&&(z.current=new On({open:u,transitionStatus:void 0,referenceElement:v,floatingElement:M,triggerElements:O,onOpenChange:A,floatingId:s,syncOnly:!0,nested:c}));const w=r??z.current;return t.useSyncedValue("floatingId",s),G(()=>{const k={open:u,floatingId:s,referenceElement:v,floatingElement:M};Ce(v)&&(k.domReferenceElement=v),w.state.positionReference===w.state.referenceElement&&(k.positionReference=v),w.update(k)},[u,s,v,M,w]),w.context.onOpenChange=A,w.context.nested=c,w}function Cn(e,t=!1,n=!1){const[r,s]=f.useState(e&&t?"idle":void 0),[c,o]=f.useState(e);return e&&!c&&(o(!0),s("starting")),!e&&c&&r!=="ending"&&!n&&s("ending"),!e&&!c&&r==="ending"&&s(void 0),G(()=>{if(!e&&c&&r!=="ending"&&n){const u=ye.request(()=>{s("ending")});return()=>{ye.cancel(u)}}},[e,c,r,n]),G(()=>{if(!e||t)return;const u=ye.request(()=>{s(void 0)});return()=>{ye.cancel(u)}},[t,e]),G(()=>{if(!e||!t)return;e&&c&&r!=="idle"&&s("starting");const u=ye.request(()=>{s("idle")});return()=>{ye.cancel(u)}},[t,e,c,r]),{mounted:c,setMounted:o,transitionStatus:r}}const tr={tabIndex:-1,[an]:""};function nr(e,t,n=!1){const r=ze(),s=Ze()!=null,c=f.useRef(null);e===void 0&&c.current===null&&(c.current=t(r,s));const o=e??c.current;return wn({popupStore:o,treatPopupAsFloatingElement:n,floatingRootContext:o.state.floatingRootContext,floatingId:r,nested:s,onOpenChange:o.setOpen}),{store:o,internalStore:c.current}}function xn(e,t){const n=f.useRef(null),r=f.useRef(null);return f.useCallback(s=>{if(e===void 0)return;let c=!1;if(n.current!==null){const o=n.current,u=r.current,v=t.context.triggerElements.getById(o);u&&v===u&&(t.context.triggerElements.delete(o),c=!0),n.current=null,r.current=null}if(s!==null&&(n.current=e,r.current=s,t.context.triggerElements.add(e,s),c=!0),c){const o=t.context.triggerElements.size;t.select("open")&&t.state.triggerCount!==o&&t.set("triggerCount",o)}},[t,e])}function rr(e,t,n){const r=n?.id??null;(r||t)&&(e.activeTriggerId=r,e.activeTriggerElement=n??null)}function sr(e,t,n,r){const s=n.useState("isMountedByTrigger",e),c=xn(e,n),o=U(u=>{if(c(u),!u)return;const v=n.select("open"),M=n.select("activeTriggerId");if(M===e){n.update({activeTriggerElement:u,...v?r:null});return}M==null&&v&&n.update({activeTriggerId:e,activeTriggerElement:u,...r})});return G(()=>{s&&n.update({activeTriggerElement:t.current,...r})},[s,n,t,...Object.values(r)]),{registerTrigger:o,isMountedByThisTrigger:s}}function or(e){const t=e.useState("open"),n=e.useState("triggerCount");G(()=>{if(!t){e.state.triggerCount!==0&&e.set("triggerCount",0);return}const r=e.context.triggerElements.size,s={};if(e.state.triggerCount!==r&&(s.triggerCount=r),!e.select("activeTriggerId")&&r===1){const c=e.context.triggerElements.entries().next();if(!c.done){const[o,u]=c.value;s.activeTriggerId=o,s.activeTriggerElement=u}}(s.triggerCount!==void 0||s.activeTriggerId!==void 0)&&e.update(s)},[t,e,n])}function cr(e,t,n){const{mounted:r,setMounted:s,transitionStatus:c}=Cn(e);t.useSyncedValues({mounted:r,transitionStatus:c});const o=U(()=>{s(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),u=t.useState("preventUnmountingOnClose");return ln({enabled:r&&!e&&!u,open:e,ref:t.context.popupRef,onComplete(){e||o()}}),{forceUnmount:o,transitionStatus:c}}function ir(e,t){e.useSyncedValues(t),G(()=>()=>{e.update({activeTriggerProps:Be,inactiveTriggerProps:Be,popupProps:Be})},[e])}function ur(e,t){G(()=>{!t&&e.state.openMethod!==null&&e.set("openMethod",null)},[t,e]),G(()=>()=>{e.state.openMethod!==null&&e.set("openMethod",null)},[e])}class lr{constructor(){this.elementsSet=new Set,this.idMap=new Map}add(t,n){const r=this.idMap.get(t);r!==n&&(r!==void 0&&this.elementsSet.delete(r),this.elementsSet.add(n),this.idMap.set(t,n))}delete(t){const n=this.idMap.get(t);n&&(this.elementsSet.delete(n),this.idMap.delete(t))}hasElement(t){return this.elementsSet.has(t)}hasMatchingElement(t){for(const n of this.elementsSet)if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}elements(){return this.elementsSet.values()}get size(){return this.idMap.size}}let nt=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=at.startingStyle]="startingStyle",e[e.endingStyle=at.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e.side="data-side",e.align="data-align",e})({}),je=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const In={[je.popupOpen]:""},kn={[je.popupOpen]:"",[je.pressed]:""},Pn={[nt.open]:""},Fn={[nt.closed]:""},Mn={[nt.anchorHidden]:""},ar={open(e){return e?In:null}},fr={open(e){return e?kn:null}},dr={open(e){return e?Pn:Fn},anchorHidden(e){return e?Mn:null}};function pr(e){return ze(e,"base-ui")}const An="ArrowUp",Nn="ArrowDown",Wn="ArrowLeft",Ln="ArrowRight",Yn="Home",Hn="End",_n=new Set([Wn,Ln]),Bn=new Set([An,Nn]),Gn=new Set([..._n,...Bn]),gr=new Set([...Gn,Yn,Hn]),hr=f.forwardRef(function(t,n){const{cutout:r,...s}=t;let c;if(r){const o=r.getBoundingClientRect();c=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${o.left}px ${o.top}px,${o.left}px ${o.bottom}px,${o.right}px ${o.bottom}px,${o.right}px ${o.top}px,${o.left}px ${o.top}px)`}return Te.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...s,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:c}})});function mr(e){const t=f.useRef(!0);t.current&&(t.current=!1,e())}let Et={},yt={},Rt="";function Kn(e){if(typeof document>"u")return!1;const t=D(e);return We(t).innerWidth-t.documentElement.clientWidth>0}function Dn(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=D(e),r=n.documentElement,s=n.body,c=Qe(r)?r:s,o=c.style.overflowY,u=r.style.scrollbarGutter;r.style.scrollbarGutter="stable",c.style.overflowY="scroll";const v=c.offsetWidth;c.style.overflowY="hidden";const M=c.offsetWidth;return c.style.overflowY=o,r.style.scrollbarGutter=u,v===M}function Xn(e){const t=D(e),n=t.documentElement,r=t.body,s=Qe(n)?n:r,c={overflowY:s.style.overflowY,overflowX:s.style.overflowX};return Object.assign(s.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(s.style,c)}}function Vn(e){const t=D(e),n=t.documentElement,r=t.body,s=We(n);let c=0,o=0,u=!1;const v=ye.create();if(xt&&(s.visualViewport?.scale??1)!==1)return()=>{};function M(){const w=s.getComputedStyle(n),k=s.getComputedStyle(r),b=(w.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";c=n.scrollTop,o=n.scrollLeft,Et={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Rt=n.style.scrollBehavior,yt={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 E=n.scrollHeight>n.clientHeight,Z=n.scrollWidth>n.clientWidth,N=w.overflowY==="scroll"||k.overflowY==="scroll",Y=w.overflowX==="scroll"||k.overflowX==="scroll",J=Math.max(0,s.innerWidth-r.clientWidth),I=Math.max(0,s.innerHeight-r.clientHeight),ee=parseFloat(k.marginTop)+parseFloat(k.marginBottom),se=parseFloat(k.marginLeft)+parseFloat(k.marginRight),P=Qe(n)?n:r;if(u=Dn(e),u){n.style.scrollbarGutter=b,P.style.overflowY="hidden",P.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:b,overflowY:"hidden",overflowX:"hidden"}),(E||N)&&(n.style.overflowY="scroll"),(Z||Y)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:ee||I?`calc(100dvh - ${ee+I}px)`:"100dvh",width:se||J?`calc(100vw - ${se+J}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=c,r.scrollLeft=o,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function O(){Object.assign(n.style,Et),Object.assign(r.style,yt),u||(n.scrollTop=c,n.scrollLeft=o,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=Rt)}function A(){O(),v.request(M)}M();const z=x(s,"resize",A);return()=>{v.cancel(),O(),typeof s.removeEventListener=="function"&&z()}}class Un{lockCount=0;restore=null;timeoutLock=Ne.create();timeoutUnlock=Ne.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=D(t).documentElement,s=We(r).getComputedStyle(r).overflowY;if(s==="hidden"||s==="clip"){this.restore=Tt;return}const c=fn||!Kn(t);this.restore=c?Xn(t):Vn(t)}}const $n=new Un;function br(e=!0,t=null){G(()=>{if(e)return $n.acquire(t)},[e,t])}export{nt as A,jn as C,Qn as F,hr as I,lr as P,Cn as a,et as b,Ze as c,Ge as d,nr as e,mr as f,Ie as g,ur as h,or as i,cr as j,er as k,tr as l,ir as m,sr as n,zn as o,fr as p,Jn as q,Zn as r,rr as s,ar as t,pr as u,gr as v,dr as w,On as x,Ke as y,br as z};
|
|
@@ -235,7 +235,7 @@
|
|
|
235
235
|
]
|
|
236
236
|
}
|
|
237
237
|
</script>
|
|
238
|
-
<script type="module" crossorigin src="/assets/main-
|
|
238
|
+
<script type="module" crossorigin src="/assets/main-DADupgLA.js"></script>
|
|
239
239
|
<link rel="stylesheet" crossorigin href="/assets/main-DCfktJsK.css">
|
|
240
240
|
</head>
|
|
241
241
|
<body>
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"description": "Shareable Token Tracker dashboard snapshot."
|
|
76
76
|
}
|
|
77
77
|
</script>
|
|
78
|
-
<script type="module" crossorigin src="/assets/main-
|
|
78
|
+
<script type="module" crossorigin src="/assets/main-DADupgLA.js"></script>
|
|
79
79
|
<link rel="stylesheet" crossorigin href="/assets/main-DCfktJsK.css">
|
|
80
80
|
</head>
|
|
81
81
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokentracker-cli",
|
|
3
|
-
"version": "0.53.
|
|
3
|
+
"version": "0.53.3",
|
|
4
4
|
"description": "Token usage tracker for AI agent CLIs (Claude Code, Codex, Cursor, Gemini, Kiro, OpenCode, OpenClaw, Every Code, Hermes, GitHub Copilot, Kimi Code, CodeBuddy, Grok Build, oh-my-pi, pi, Craft Agents, Kilo CLI, Kilo Code, Roo Code, Zed Agent, Goose)",
|
|
5
5
|
"main": "src/cli.js",
|
|
6
6
|
"bin": {
|
package/src/commands/sync.js
CHANGED
|
@@ -131,6 +131,17 @@ const CLAUDE_GROUND_TRUTH_REPAIR_KEY = "claudeGroundTruthRepair_2026_05_v4";
|
|
|
131
131
|
// (token columns replay to the same final values: last emission per key wins,
|
|
132
132
|
// exactly how the cloud rows were built the first time).
|
|
133
133
|
const CLOUD_CONVERSATIONS_BACKFILL_KEY = "cloudConversationsBackfill_2026_06";
|
|
134
|
+
// One-time repair (#187): until the codexHashes event-dedup landed, a Codex
|
|
135
|
+
// session file rewritten with a new inode (Codex-Manager atomically rewrites
|
|
136
|
+
// sessions/ files to patch the provider on every account switch) was re-scanned
|
|
137
|
+
// from offset 0 and its tokens re-added to the persistent hourly buckets. This
|
|
138
|
+
// rebuilds the codex buckets from disk (event-deduped), atomically drops the
|
|
139
|
+
// inflated codex rows from queue.jsonl, and resets the upload offset so the
|
|
140
|
+
// corrected values overwrite the cloud. GUARDED: skips if any codex session
|
|
141
|
+
// file that previously contributed is no longer on disk (deleted, or moved to
|
|
142
|
+
// ~/.codex/archived_sessions/ which sync does not scan) — clearing its bucket
|
|
143
|
+
// would lose that history (ref the v6 ground-truth-repair data-loss incident).
|
|
144
|
+
const CODEX_RESCAN_DEDUP_REPAIR_KEY = "codexRescanDedupRepair_2026_06";
|
|
134
145
|
|
|
135
146
|
function warnProviderParseFailure(label, err, opts) {
|
|
136
147
|
if (opts?.auto) return;
|
|
@@ -213,6 +224,7 @@ async function cmdSync(argv) {
|
|
|
213
224
|
}
|
|
214
225
|
|
|
215
226
|
await migrateRolloutCumulativeDeltaBuckets({ cursors, queuePath, rolloutFiles });
|
|
227
|
+
await repairCodexRescanInflation({ cursors, queuePath, queueStatePath, rolloutFiles });
|
|
216
228
|
|
|
217
229
|
const openclawFiles = openclawSignal?.sessionFile
|
|
218
230
|
? [{ path: openclawSignal.sessionFile, source: "openclaw" }]
|
|
@@ -1217,11 +1229,13 @@ module.exports = {
|
|
|
1217
1229
|
cmdSync,
|
|
1218
1230
|
migrateCursorUnknownBuckets,
|
|
1219
1231
|
migrateRolloutCumulativeDeltaBuckets,
|
|
1232
|
+
repairCodexRescanInflation,
|
|
1220
1233
|
reincludeClaudeMemObserverFiles,
|
|
1221
1234
|
repairGrokQueueFromSessionSnapshots,
|
|
1222
1235
|
applyCloudConversationsBackfill,
|
|
1223
1236
|
CURSOR_UNKNOWN_MIGRATION_KEY,
|
|
1224
1237
|
ROLLOUT_CUMULATIVE_DELTA_MIGRATION_KEY,
|
|
1238
|
+
CODEX_RESCAN_DEDUP_REPAIR_KEY,
|
|
1225
1239
|
CLAUDE_MEM_OBSERVER_REINCLUDE_KEY,
|
|
1226
1240
|
GROK_APPEND_ONLY_REPAIR_MIGRATION_KEY,
|
|
1227
1241
|
CLOUD_CONVERSATIONS_BACKFILL_KEY,
|
|
@@ -2071,6 +2085,190 @@ async function migrateRolloutCumulativeDeltaBuckets({ cursors, queuePath, rollou
|
|
|
2071
2085
|
cursors.migrations[ROLLOUT_CUMULATIVE_DELTA_MIGRATION_KEY] = new Date().toISOString();
|
|
2072
2086
|
}
|
|
2073
2087
|
|
|
2088
|
+
// One-time repair (#187): rebuild codex hourly buckets that the inode-keyed
|
|
2089
|
+
// re-scan double-counted before the codexHashes event-dedup landed, and push
|
|
2090
|
+
// the corrected values to the cloud. Runs BEFORE the codex parse in the same
|
|
2091
|
+
// sync: it clears codex hourly state + codexHashes so the parse rebuilds clean,
|
|
2092
|
+
// atomically strips the inflated codex rows from queue.jsonl, and resets the
|
|
2093
|
+
// upload offset so the re-uploaded clean rows overwrite the cloud (with no
|
|
2094
|
+
// stale-high codex rows left in the queue, the ingest's within-batch MAX keeps
|
|
2095
|
+
// nothing larger, so its overwrite-upsert replaces the inflated cloud rows).
|
|
2096
|
+
//
|
|
2097
|
+
// GUARDED against the v6 ground-truth-repair data-loss incident: a clear+reparse
|
|
2098
|
+
// rebuilds codex buckets ONLY from sessions/ files the sync re-parses, so if any
|
|
2099
|
+
// codex file that previously contributed is gone from disk (deleted, or moved by
|
|
2100
|
+
// Codex-Manager to ~/.codex/archived_sessions/, which sync does not scan) the
|
|
2101
|
+
// migration is skipped entirely — the forward dedup fix still prevents new
|
|
2102
|
+
// double-counting; only this historical correction is deferred.
|
|
2103
|
+
async function repairCodexRescanInflation({ cursors, queuePath, queueStatePath, rolloutFiles }) {
|
|
2104
|
+
if (!cursors || typeof cursors !== "object") return false;
|
|
2105
|
+
const migrations = (cursors.migrations ||= {});
|
|
2106
|
+
if (migrations[CODEX_RESCAN_DEDUP_REPAIR_KEY]) return false;
|
|
2107
|
+
|
|
2108
|
+
// Codex session files THIS sync discovered (source === "codex").
|
|
2109
|
+
const codexFiles = [];
|
|
2110
|
+
for (const entry of Array.isArray(rolloutFiles) ? rolloutFiles : []) {
|
|
2111
|
+
const fp = typeof entry === "string" ? entry : entry?.path;
|
|
2112
|
+
const src = typeof entry === "string" ? "codex" : String(entry?.source || "codex");
|
|
2113
|
+
if (fp && src === "codex") codexFiles.push(fp);
|
|
2114
|
+
}
|
|
2115
|
+
const codexFileSet = new Set(codexFiles);
|
|
2116
|
+
|
|
2117
|
+
// GUARD (data-loss prevention, ref the v6 ground-truth-repair incident): the
|
|
2118
|
+
// rebuild can only reproduce buckets from the files this sync re-parses
|
|
2119
|
+
// (codexFiles). If any codex session file that previously contributed (has a
|
|
2120
|
+
// cursor) is gone from disk OR not in this sync's scan — deleted, or moved by
|
|
2121
|
+
// Codex-Manager to ~/.codex/archived_sessions/ which listRolloutFiles does not
|
|
2122
|
+
// scan — skip entirely. The forward dedup fix still stops NEW double-counting;
|
|
2123
|
+
// only this historical correction defers.
|
|
2124
|
+
if (cursors.files && typeof cursors.files === "object") {
|
|
2125
|
+
for (const fp of Object.keys(cursors.files)) {
|
|
2126
|
+
if (!/\/\.codex\/sessions\//.test(fp)) continue;
|
|
2127
|
+
if (!fssync.existsSync(fp) || !codexFileSet.has(fp)) {
|
|
2128
|
+
migrations[CODEX_RESCAN_DEDUP_REPAIR_KEY] = {
|
|
2129
|
+
skipped: true,
|
|
2130
|
+
reason: "codex_session_file_missing_or_unscanned",
|
|
2131
|
+
at: new Date().toISOString(),
|
|
2132
|
+
};
|
|
2133
|
+
return false;
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
// ATOMIC REBUILD into a THROWAWAY cursors + queue: never touch the live
|
|
2139
|
+
// buckets/queue until the rebuild has fully succeeded. If anything throws we
|
|
2140
|
+
// return WITHOUT mutating any persistent state and the migration retries next
|
|
2141
|
+
// sync (the key is not set). This is the crucial difference from a
|
|
2142
|
+
// "clear-then-rely-on-the-later-parse" design: the later parse's failure is
|
|
2143
|
+
// swallowed (warnProviderParseFailure) and cursors are saved regardless, which
|
|
2144
|
+
// would permanently zero a user's codex history.
|
|
2145
|
+
let rebuilt;
|
|
2146
|
+
const tmpQueue = `${queuePath}.codexrebuild.${process.pid}.${Date.now()}`;
|
|
2147
|
+
try {
|
|
2148
|
+
const tmpCursors = {
|
|
2149
|
+
version: 1,
|
|
2150
|
+
files: {},
|
|
2151
|
+
hourly: { buckets: {}, groupQueued: {} },
|
|
2152
|
+
codexHashes: [],
|
|
2153
|
+
};
|
|
2154
|
+
await parseRolloutIncremental({
|
|
2155
|
+
rolloutFiles: codexFiles.map((p) => ({ path: p, source: "codex" })),
|
|
2156
|
+
cursors: tmpCursors,
|
|
2157
|
+
queuePath: tmpQueue,
|
|
2158
|
+
});
|
|
2159
|
+
let tmpRaw = "";
|
|
2160
|
+
try {
|
|
2161
|
+
tmpRaw = await fs.readFile(tmpQueue, "utf8");
|
|
2162
|
+
} catch (e) {
|
|
2163
|
+
if (e?.code !== "ENOENT") throw e;
|
|
2164
|
+
}
|
|
2165
|
+
rebuilt = {
|
|
2166
|
+
buckets: tmpCursors.hourly.buckets || {},
|
|
2167
|
+
groupQueued: tmpCursors.hourly.groupQueued || {},
|
|
2168
|
+
codexHashes: Array.isArray(tmpCursors.codexHashes) ? tmpCursors.codexHashes : [],
|
|
2169
|
+
files: tmpCursors.files || {},
|
|
2170
|
+
queueRows: tmpRaw.split("\n").filter((l) => l.trim()),
|
|
2171
|
+
};
|
|
2172
|
+
} catch (e) {
|
|
2173
|
+
console.error(
|
|
2174
|
+
"[sync] codex rescan repair: rebuild failed, leaving all data untouched:",
|
|
2175
|
+
e?.message || e,
|
|
2176
|
+
);
|
|
2177
|
+
return false;
|
|
2178
|
+
} finally {
|
|
2179
|
+
await fs.rm(tmpQueue, { force: true }).catch(() => {});
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
// SANITY: codex files exist on disk but the rebuild produced no codex buckets
|
|
2183
|
+
// → treat as a failed rebuild and skip (do NOT clear live data, do NOT set the
|
|
2184
|
+
// key — retry next sync).
|
|
2185
|
+
const rebuiltCodexKeys = Object.keys(rebuilt.buckets).filter((k) => k.startsWith("codex|"));
|
|
2186
|
+
if (codexFiles.length > 0 && rebuiltCodexKeys.length === 0) {
|
|
2187
|
+
console.error(
|
|
2188
|
+
`[sync] codex rescan repair: rebuild produced 0 codex buckets from ${codexFiles.length} files — skipping to avoid data loss`,
|
|
2189
|
+
);
|
|
2190
|
+
return false;
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
// COMMIT (only after a verified rebuild). A crash partway just leaves the
|
|
2194
|
+
// migration to re-run next sync — re-rebuild + re-strip + re-commit converges.
|
|
2195
|
+
//
|
|
2196
|
+
// 1. queue.jsonl: drop the inflated codex rows, append the clean rebuilt ones
|
|
2197
|
+
// (atomic tmp+rename). With no old-high codex rows left, the cloud ingest's
|
|
2198
|
+
// within-batch MAX keeps nothing larger and its overwrite-upsert replaces
|
|
2199
|
+
// the inflated cloud rows on the next upload.
|
|
2200
|
+
if (typeof queuePath === "string" && queuePath) {
|
|
2201
|
+
let raw = "";
|
|
2202
|
+
try {
|
|
2203
|
+
raw = await fs.readFile(queuePath, "utf8");
|
|
2204
|
+
} catch (e) {
|
|
2205
|
+
if (e?.code !== "ENOENT") throw e;
|
|
2206
|
+
}
|
|
2207
|
+
const kept = [];
|
|
2208
|
+
for (const line of raw.split("\n")) {
|
|
2209
|
+
if (!line.trim()) continue;
|
|
2210
|
+
let row;
|
|
2211
|
+
try {
|
|
2212
|
+
row = JSON.parse(line);
|
|
2213
|
+
} catch (_e) {
|
|
2214
|
+
kept.push(line);
|
|
2215
|
+
continue;
|
|
2216
|
+
}
|
|
2217
|
+
if (row?.source === "codex") continue;
|
|
2218
|
+
kept.push(line);
|
|
2219
|
+
}
|
|
2220
|
+
await ensureDir(path.dirname(queuePath));
|
|
2221
|
+
const tmp = `${queuePath}.tmp.${process.pid}.${Date.now()}`;
|
|
2222
|
+
await fs.writeFile(tmp, kept.concat(rebuilt.queueRows).join("\n") + "\n", "utf8");
|
|
2223
|
+
await fs.rename(tmp, queuePath);
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
// 2. Swap the live codex hourly state for the rebuilt one, and install the
|
|
2227
|
+
// rebuilt per-file cursors (offset at EOF) so the later parse in THIS sync
|
|
2228
|
+
// does not re-read codex (which would re-inflate project buckets).
|
|
2229
|
+
const hourly = (cursors.hourly ||= { buckets: {}, groupQueued: {} });
|
|
2230
|
+
hourly.buckets ||= {};
|
|
2231
|
+
hourly.groupQueued ||= {};
|
|
2232
|
+
for (const k of Object.keys(hourly.buckets)) {
|
|
2233
|
+
if (k.startsWith("codex|")) delete hourly.buckets[k];
|
|
2234
|
+
}
|
|
2235
|
+
for (const k of Object.keys(hourly.groupQueued)) {
|
|
2236
|
+
if (k.startsWith("codex|")) delete hourly.groupQueued[k];
|
|
2237
|
+
}
|
|
2238
|
+
for (const [k, v] of Object.entries(rebuilt.buckets)) {
|
|
2239
|
+
if (k.startsWith("codex|")) hourly.buckets[k] = v;
|
|
2240
|
+
}
|
|
2241
|
+
for (const [k, v] of Object.entries(rebuilt.groupQueued)) {
|
|
2242
|
+
if (k.startsWith("codex|")) hourly.groupQueued[k] = v;
|
|
2243
|
+
}
|
|
2244
|
+
cursors.files ||= {};
|
|
2245
|
+
for (const fp of Object.keys(cursors.files)) {
|
|
2246
|
+
if (/\/\.codex\/sessions\//.test(fp)) delete cursors.files[fp];
|
|
2247
|
+
}
|
|
2248
|
+
for (const [fp, v] of Object.entries(rebuilt.files)) {
|
|
2249
|
+
cursors.files[fp] = v;
|
|
2250
|
+
}
|
|
2251
|
+
cursors.codexHashes = rebuilt.codexHashes;
|
|
2252
|
+
|
|
2253
|
+
// 3. Reset the cloud upload offset so the corrected queue re-uploads. Other
|
|
2254
|
+
// sources re-upsert idempotently (last emission per key wins).
|
|
2255
|
+
if (typeof queueStatePath === "string" && queueStatePath) {
|
|
2256
|
+
let uploadState = {};
|
|
2257
|
+
try {
|
|
2258
|
+
uploadState = JSON.parse(await fs.readFile(queueStatePath, "utf8"));
|
|
2259
|
+
} catch (_e) {
|
|
2260
|
+
uploadState = {};
|
|
2261
|
+
}
|
|
2262
|
+
uploadState.offset = 0;
|
|
2263
|
+
uploadState.updatedAt = new Date().toISOString();
|
|
2264
|
+
uploadState.note = "reset_after_codex_rescan_dedup_2026_06";
|
|
2265
|
+
await fs.writeFile(queueStatePath, JSON.stringify(uploadState));
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
migrations[CODEX_RESCAN_DEDUP_REPAIR_KEY] = new Date().toISOString();
|
|
2269
|
+
return true;
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2074
2272
|
// One-time repair migration: rebuild source=claude rows in queue.jsonl from
|
|
2075
2273
|
// the actual jsonl files using ccusage's algorithm (msgId+reqId global
|
|
2076
2274
|
// dedup). Earlier `reincludeClaudeMemObserverFiles` versions (v1/v2/v3) each
|