tokentracker-cli 0.5.74 → 0.5.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/dashboard/dist/assets/{Card-D_q1XGfK.js → Card-D-EuRzLE.js} +1 -1
  2. package/dashboard/dist/assets/DashboardPage-DP4h327m.js +12 -0
  3. package/dashboard/dist/assets/{FadeIn-ClpHby-T.js → FadeIn-Nqb2FeSu.js} +1 -1
  4. package/dashboard/dist/assets/{IpCheckPage-B5TpHE6G.js → IpCheckPage-DKErP77B.js} +1 -1
  5. package/dashboard/dist/assets/LeaderboardPage-D_DqH7v4.js +5 -0
  6. package/dashboard/dist/assets/{LeaderboardProfilePage-C8xexZ08.js → LeaderboardProfilePage-B4U6R6TW.js} +1 -1
  7. package/dashboard/dist/assets/{LimitsPage-CERWQyIU.js → LimitsPage-WP9IFHnS.js} +1 -1
  8. package/dashboard/dist/assets/ProviderIcon-CiAX7O9R.js +1 -0
  9. package/dashboard/dist/assets/SettingsPage-BzWrP1qX.js +1 -0
  10. package/dashboard/dist/assets/{WidgetsPage-Cmr2tbD7.js → WidgetsPage-BbV32pxZ.js} +1 -1
  11. package/dashboard/dist/assets/{download-M8e1PJC-.js → download-CXIEU-zL.js} +1 -1
  12. package/dashboard/dist/assets/{leaderboard-columns-Dcg9r7R2.js → leaderboard-columns-DIsoAppd.js} +1 -1
  13. package/dashboard/dist/assets/main-DRf20yyJ.css +1 -0
  14. package/dashboard/dist/assets/{main-D1VdJk4V.js → main-_yO2TZgj.js} +12 -3
  15. package/dashboard/dist/assets/{use-limits-display-prefs-CSj55sfK.js → use-limits-display-prefs-CogaUGYH.js} +1 -1
  16. package/dashboard/dist/assets/{use-usage-limits-BuWINUAm.js → use-usage-limits-Didh7hvY.js} +1 -1
  17. package/dashboard/dist/index.html +2 -2
  18. package/dashboard/dist/share.html +2 -2
  19. package/package.json +1 -1
  20. package/dashboard/dist/assets/DashboardPage-CuBSoNgI.js +0 -12
  21. package/dashboard/dist/assets/LeaderboardPage-BOrtGeIf.js +0 -5
  22. package/dashboard/dist/assets/SettingsPage-DUwt4x-H.js +0 -1
  23. package/dashboard/dist/assets/main-CNzfq4Ln.css +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage-CuBSoNgI.js","assets/use-usage-limits-BuWINUAm.js","assets/Card-D_q1XGfK.js","assets/FadeIn-ClpHby-T.js","assets/LeaderboardPage-BOrtGeIf.js","assets/leaderboard-columns-Dcg9r7R2.js","assets/LeaderboardProfilePage-C8xexZ08.js","assets/LimitsPage-CERWQyIU.js","assets/use-limits-display-prefs-CSj55sfK.js","assets/SettingsPage-DUwt4x-H.js","assets/download-M8e1PJC-.js","assets/WidgetsPage-Cmr2tbD7.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage-DP4h327m.js","assets/use-usage-limits-Didh7hvY.js","assets/Card-D-EuRzLE.js","assets/FadeIn-Nqb2FeSu.js","assets/ProviderIcon-CiAX7O9R.js","assets/LeaderboardPage-D_DqH7v4.js","assets/leaderboard-columns-DIsoAppd.js","assets/LeaderboardProfilePage-B4U6R6TW.js","assets/LimitsPage-WP9IFHnS.js","assets/use-limits-display-prefs-CogaUGYH.js","assets/SettingsPage-BzWrP1qX.js","assets/download-CXIEU-zL.js","assets/WidgetsPage-BbV32pxZ.js"])))=>i.map(i=>d[i]);
2
2
  function v2(t,e){for(var n=0;n<e.length;n++){const i=e[n];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in t)){const s=Object.getOwnPropertyDescriptor(i,r);s&&Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();function OE(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function y2(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function i(){var r=!1;try{r=this instanceof i}catch{}return r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}),n}var Sm={exports:{}},Ic={},wm={exports:{}},Jt={};var Tb;function _2(){if(Tb)return Jt;Tb=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),o=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.iterator;function m(z){return z===null||typeof z!="object"?null:(z=p&&z[p]||z["@@iterator"],typeof z=="function"?z:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,w={};function y(z,ie,we){this.props=z,this.context=ie,this.refs=w,this.updater=we||v}y.prototype.isReactComponent={},y.prototype.setState=function(z,ie){if(typeof z!="object"&&typeof z!="function"&&z!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,z,ie,"setState")},y.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function b(){}b.prototype=y.prototype;function T(z,ie,we){this.props=z,this.context=ie,this.refs=w,this.updater=we||v}var A=T.prototype=new b;A.constructor=T,_(A,y.prototype),A.isPureReactComponent=!0;var M=Array.isArray,I=Object.prototype.hasOwnProperty,k={current:null},U={key:!0,ref:!0,__self:!0,__source:!0};function S(z,ie,we){var He,Se={},ne=null,ye=null;if(ie!=null)for(He in ie.ref!==void 0&&(ye=ie.ref),ie.key!==void 0&&(ne=""+ie.key),ie)I.call(ie,He)&&!U.hasOwnProperty(He)&&(Se[He]=ie[He]);var be=arguments.length-2;if(be===1)Se.children=we;else if(1<be){for(var Ne=Array(be),et=0;et<be;et++)Ne[et]=arguments[et+2];Se.children=Ne}if(z&&z.defaultProps)for(He in be=z.defaultProps,be)Se[He]===void 0&&(Se[He]=be[He]);return{$$typeof:t,type:z,key:ne,ref:ye,props:Se,_owner:k.current}}function P(z,ie){return{$$typeof:t,type:z.type,key:ie,ref:z.ref,props:z.props,_owner:z._owner}}function V(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function O(z){var ie={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(we){return ie[we]})}var G=/\/+/g;function J(z,ie){return typeof z=="object"&&z!==null&&z.key!=null?O(""+z.key):ie.toString(36)}function H(z,ie,we,He,Se){var ne=typeof z;(ne==="undefined"||ne==="boolean")&&(z=null);var ye=!1;if(z===null)ye=!0;else switch(ne){case"string":case"number":ye=!0;break;case"object":switch(z.$$typeof){case t:case e:ye=!0}}if(ye)return ye=z,Se=Se(ye),z=He===""?"."+J(ye,0):He,M(Se)?(we="",z!=null&&(we=z.replace(G,"$&/")+"/"),H(Se,ie,we,"",function(et){return et})):Se!=null&&(V(Se)&&(Se=P(Se,we+(!Se.key||ye&&ye.key===Se.key?"":(""+Se.key).replace(G,"$&/")+"/")+z)),ie.push(Se)),1;if(ye=0,He=He===""?".":He+":",M(z))for(var be=0;be<z.length;be++){ne=z[be];var Ne=He+J(ne,be);ye+=H(ne,ie,we,Ne,Se)}else if(Ne=m(z),typeof Ne=="function")for(z=Ne.call(z),be=0;!(ne=z.next()).done;)ne=ne.value,Ne=He+J(ne,be++),ye+=H(ne,ie,we,Ne,Se);else if(ne==="object")throw ie=String(z),Error("Objects are not valid as a React child (found: "+(ie==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":ie)+"). If you meant to render a collection of children, use an array instead.");return ye}function X(z,ie,we){if(z==null)return z;var He=[],Se=0;return H(z,He,"","",function(ne){return ie.call(we,ne,Se++)}),He}function K(z){if(z._status===-1){var ie=z._result;ie=ie(),ie.then(function(we){(z._status===0||z._status===-1)&&(z._status=1,z._result=we)},function(we){(z._status===0||z._status===-1)&&(z._status=2,z._result=we)}),z._status===-1&&(z._status=0,z._result=ie)}if(z._status===1)return z._result.default;throw z._result}var Q={current:null},W={transition:null},q={ReactCurrentDispatcher:Q,ReactCurrentBatchConfig:W,ReactCurrentOwner:k};function Z(){throw Error("act(...) is not supported in production builds of React.")}return Jt.Children={map:X,forEach:function(z,ie,we){X(z,function(){ie.apply(this,arguments)},we)},count:function(z){var ie=0;return X(z,function(){ie++}),ie},toArray:function(z){return X(z,function(ie){return ie})||[]},only:function(z){if(!V(z))throw Error("React.Children.only expected to receive a single React element child.");return z}},Jt.Component=y,Jt.Fragment=n,Jt.Profiler=r,Jt.PureComponent=T,Jt.StrictMode=i,Jt.Suspense=u,Jt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=q,Jt.act=Z,Jt.cloneElement=function(z,ie,we){if(z==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+z+".");var He=_({},z.props),Se=z.key,ne=z.ref,ye=z._owner;if(ie!=null){if(ie.ref!==void 0&&(ne=ie.ref,ye=k.current),ie.key!==void 0&&(Se=""+ie.key),z.type&&z.type.defaultProps)var be=z.type.defaultProps;for(Ne in ie)I.call(ie,Ne)&&!U.hasOwnProperty(Ne)&&(He[Ne]=ie[Ne]===void 0&&be!==void 0?be[Ne]:ie[Ne])}var Ne=arguments.length-2;if(Ne===1)He.children=we;else if(1<Ne){be=Array(Ne);for(var et=0;et<Ne;et++)be[et]=arguments[et+2];He.children=be}return{$$typeof:t,type:z.type,key:Se,ref:ne,props:He,_owner:ye}},Jt.createContext=function(z){return z={$$typeof:o,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},z.Provider={$$typeof:s,_context:z},z.Consumer=z},Jt.createElement=S,Jt.createFactory=function(z){var ie=S.bind(null,z);return ie.type=z,ie},Jt.createRef=function(){return{current:null}},Jt.forwardRef=function(z){return{$$typeof:c,render:z}},Jt.isValidElement=V,Jt.lazy=function(z){return{$$typeof:h,_payload:{_status:-1,_result:z},_init:K}},Jt.memo=function(z,ie){return{$$typeof:d,type:z,compare:ie===void 0?null:ie}},Jt.startTransition=function(z){var ie=W.transition;W.transition={};try{z()}finally{W.transition=ie}},Jt.unstable_act=Z,Jt.useCallback=function(z,ie){return Q.current.useCallback(z,ie)},Jt.useContext=function(z){return Q.current.useContext(z)},Jt.useDebugValue=function(){},Jt.useDeferredValue=function(z){return Q.current.useDeferredValue(z)},Jt.useEffect=function(z,ie){return Q.current.useEffect(z,ie)},Jt.useId=function(){return Q.current.useId()},Jt.useImperativeHandle=function(z,ie,we){return Q.current.useImperativeHandle(z,ie,we)},Jt.useInsertionEffect=function(z,ie){return Q.current.useInsertionEffect(z,ie)},Jt.useLayoutEffect=function(z,ie){return Q.current.useLayoutEffect(z,ie)},Jt.useMemo=function(z,ie){return Q.current.useMemo(z,ie)},Jt.useReducer=function(z,ie,we){return Q.current.useReducer(z,ie,we)},Jt.useRef=function(z){return Q.current.useRef(z)},Jt.useState=function(z){return Q.current.useState(z)},Jt.useSyncExternalStore=function(z,ie,we){return Q.current.useSyncExternalStore(z,ie,we)},Jt.useTransition=function(){return Q.current.useTransition()},Jt.version="18.3.1",Jt}var Ab;function Ov(){return Ab||(Ab=1,wm.exports=_2()),wm.exports}var Cb;function x2(){if(Cb)return Ic;Cb=1;var t=Ov(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(c,u,d){var h,p={},m=null,v=null;d!==void 0&&(m=""+d),u.key!==void 0&&(m=""+u.key),u.ref!==void 0&&(v=u.ref);for(h in u)i.call(u,h)&&!s.hasOwnProperty(h)&&(p[h]=u[h]);if(c&&c.defaultProps)for(h in u=c.defaultProps,u)p[h]===void 0&&(p[h]=u[h]);return{$$typeof:e,type:c,key:m,ref:v,props:p,_owner:r.current}}return Ic.Fragment=n,Ic.jsx=o,Ic.jsxs=o,Ic}var Pb;function b2(){return Pb||(Pb=1,Sm.exports=x2()),Sm.exports}var F=b2(),L=Ov();const hs=OE(L),BE=v2({__proto__:null,default:hs},[L]);var zd={},Em={exports:{}},Vi={},Mm={exports:{}},Tm={};var Rb;function S2(){return Rb||(Rb=1,(function(t){function e(W,q){var Z=W.length;W.push(q);e:for(;0<Z;){var z=Z-1>>>1,ie=W[z];if(0<r(ie,q))W[z]=q,W[Z]=ie,Z=z;else break e}}function n(W){return W.length===0?null:W[0]}function i(W){if(W.length===0)return null;var q=W[0],Z=W.pop();if(Z!==q){W[0]=Z;e:for(var z=0,ie=W.length,we=ie>>>1;z<we;){var He=2*(z+1)-1,Se=W[He],ne=He+1,ye=W[ne];if(0>r(Se,Z))ne<ie&&0>r(ye,Se)?(W[z]=ye,W[ne]=Z,z=ne):(W[z]=Se,W[He]=Z,z=He);else if(ne<ie&&0>r(ye,Z))W[z]=ye,W[ne]=Z,z=ne;else break e}}return q}function r(W,q){var Z=W.sortIndex-q.sortIndex;return Z!==0?Z:W.id-q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,c=o.now();t.unstable_now=function(){return o.now()-c}}var u=[],d=[],h=1,p=null,m=3,v=!1,_=!1,w=!1,y=typeof setTimeout=="function"?setTimeout:null,b=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function A(W){for(var q=n(d);q!==null;){if(q.callback===null)i(d);else if(q.startTime<=W)i(d),q.sortIndex=q.expirationTime,e(u,q);else break;q=n(d)}}function M(W){if(w=!1,A(W),!_)if(n(u)!==null)_=!0,K(I);else{var q=n(d);q!==null&&Q(M,q.startTime-W)}}function I(W,q){_=!1,w&&(w=!1,b(S),S=-1),v=!0;var Z=m;try{for(A(q),p=n(u);p!==null&&(!(p.expirationTime>q)||W&&!O());){var z=p.callback;if(typeof z=="function"){p.callback=null,m=p.priorityLevel;var ie=z(p.expirationTime<=q);q=t.unstable_now(),typeof ie=="function"?p.callback=ie:p===n(u)&&i(u),A(q)}else i(u);p=n(u)}if(p!==null)var we=!0;else{var He=n(d);He!==null&&Q(M,He.startTime-q),we=!1}return we}finally{p=null,m=Z,v=!1}}var k=!1,U=null,S=-1,P=5,V=-1;function O(){return!(t.unstable_now()-V<P)}function G(){if(U!==null){var W=t.unstable_now();V=W;var q=!0;try{q=U(!0,W)}finally{q?J():(k=!1,U=null)}}else k=!1}var J;if(typeof T=="function")J=function(){T(G)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,X=H.port2;H.port1.onmessage=G,J=function(){X.postMessage(null)}}else J=function(){y(G,0)};function K(W){U=W,k||(k=!0,J())}function Q(W,q){S=y(function(){W(t.unstable_now())},q)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(W){W.callback=null},t.unstable_continueExecution=function(){_||v||(_=!0,K(I))},t.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<W?Math.floor(1e3/W):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_getFirstCallbackNode=function(){return n(u)},t.unstable_next=function(W){switch(m){case 1:case 2:case 3:var q=3;break;default:q=m}var Z=m;m=q;try{return W()}finally{m=Z}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(W,q){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var Z=m;m=W;try{return q()}finally{m=Z}},t.unstable_scheduleCallback=function(W,q,Z){var z=t.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?z+Z:z):Z=z,W){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=Z+ie,W={id:h++,callback:q,priorityLevel:W,startTime:Z,expirationTime:ie,sortIndex:-1},Z>z?(W.sortIndex=Z,e(d,W),n(u)===null&&W===n(d)&&(w?(b(S),S=-1):w=!0,Q(M,Z-z))):(W.sortIndex=ie,e(u,W),_||v||(_=!0,K(I))),W},t.unstable_shouldYield=O,t.unstable_wrapCallback=function(W){var q=m;return function(){var Z=m;m=q;try{return W.apply(this,arguments)}finally{m=Z}}}})(Tm)),Tm}var kb;function w2(){return kb||(kb=1,Mm.exports=S2()),Mm.exports}var Lb;function E2(){if(Lb)return Vi;Lb=1;var t=Ov(),e=w2();function n(a){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+a,f=1;f<arguments.length;f++)l+="&args[]="+encodeURIComponent(arguments[f]);return"Minified React error #"+a+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=new Set,r={};function s(a,l){o(a,l),o(a+"Capture",l)}function o(a,l){for(r[a]=l,a=0;a<l.length;a++)i.add(l[a])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,h={},p={};function m(a){return u.call(p,a)?!0:u.call(h,a)?!1:d.test(a)?p[a]=!0:(h[a]=!0,!1)}function v(a,l,f,g){if(f!==null&&f.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return g?!1:f!==null?!f.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function _(a,l,f,g){if(l===null||typeof l>"u"||v(a,l,f,g))return!0;if(g)return!1;if(f!==null)switch(f.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function w(a,l,f,g,x,E,D){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=g,this.attributeNamespace=x,this.mustUseProperty=f,this.propertyName=a,this.type=l,this.sanitizeURL=E,this.removeEmptyString=D}var y={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){y[a]=new w(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var l=a[0];y[l]=new w(l,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){y[a]=new w(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){y[a]=new w(a,2,!1,a,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a){y[a]=new w(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){y[a]=new w(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){y[a]=new w(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){y[a]=new w(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){y[a]=new w(a,5,!1,a.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function T(a){return a[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a){var l=a.replace(b,T);y[l]=new w(l,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var l=a.replace(b,T);y[l]=new w(l,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var l=a.replace(b,T);y[l]=new w(l,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){y[a]=new w(a,1,!1,a.toLowerCase(),null,!1,!1)}),y.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){y[a]=new w(a,1,!1,a.toLowerCase(),null,!0,!0)});function A(a,l,f,g){var x=y.hasOwnProperty(l)?y[l]:null;(x!==null?x.type!==0:g||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(_(l,f,x,g)&&(f=null),g||x===null?m(l)&&(f===null?a.removeAttribute(l):a.setAttribute(l,""+f)):x.mustUseProperty?a[x.propertyName]=f===null?x.type===3?!1:"":f:(l=x.attributeName,g=x.attributeNamespace,f===null?a.removeAttribute(l):(x=x.type,f=x===3||x===4&&f===!0?"":""+f,g?a.setAttributeNS(g,l,f):a.setAttribute(l,f))))}var M=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,I=Symbol.for("react.element"),k=Symbol.for("react.portal"),U=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),V=Symbol.for("react.provider"),O=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),H=Symbol.for("react.suspense_list"),X=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),Q=Symbol.for("react.offscreen"),W=Symbol.iterator;function q(a){return a===null||typeof a!="object"?null:(a=W&&a[W]||a["@@iterator"],typeof a=="function"?a:null)}var Z=Object.assign,z;function ie(a){if(z===void 0)try{throw Error()}catch(f){var l=f.stack.trim().match(/\n( *(at )?)/);z=l&&l[1]||""}return`
3
3
  `+z+a}var we=!1;function He(a,l){if(!a||we)return"";we=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(ge){var g=ge}Reflect.construct(a,[],l)}else{try{l.call()}catch(ge){g=ge}a.call(l.prototype)}else{try{throw Error()}catch(ge){g=ge}a()}}catch(ge){if(ge&&g&&typeof ge.stack=="string"){for(var x=ge.stack.split(`
4
4
  `),E=g.stack.split(`
@@ -39,7 +39,7 @@ Please change the parent <Route path="${y}"> to <Route path="${y==="/"?"*":`${y}
39
39
  `))}logResponse(t,e,n,i,r){if(!this.enabled)return;const s=[`← ${t} ${e} ${n} (${i}ms)`],o=DS(ru(r));if(o){const c=o.length>1e3?o.slice(0,1e3)+"... [truncated]":o;s.push(` Body: ${c}`)}n>=400?this.error(s.join(`
40
40
  `)):this.log(s.join(`
41
41
  `))}},ly="insforge_csrf_token";function nT(){if(typeof document>"u")return null;const t=document.cookie.split(";").find(e=>e.trim().startsWith(`${ly}=`));return t&&t.split("=")[1]||null}function iT(t){if(typeof document>"u")return;const e=10080*60,n=typeof window<"u"&&window.location.protocol==="https:"?"; Secure":"";document.cookie=`${ly}=${encodeURIComponent(t)}; path=/; max-age=${e}; SameSite=Lax${n}`}function rT(){if(typeof document>"u")return;const t=typeof window<"u"&&window.location.protocol==="https:"?"; Secure":"";document.cookie=`${ly}=; path=/; max-age=0; SameSite=Lax${t}`}var sT=class{constructor(){this.accessToken=null,this.user=null,this.onTokenChange=null}saveSession(t){const e=t.accessToken!==this.accessToken;this.accessToken=t.accessToken,this.user=t.user,e&&this.onTokenChange&&this.onTokenChange()}getSession(){return!this.accessToken||!this.user?null:{accessToken:this.accessToken,user:this.user}}getAccessToken(){return this.accessToken}setAccessToken(t){const e=t!==this.accessToken;this.accessToken=t,e&&this.onTokenChange&&this.onTokenChange()}getUser(){return this.user}setUser(t){this.user=t}clearSession(){const t=this.accessToken!==null;this.accessToken=null,this.user=null,t&&this.onTokenChange&&this.onTokenChange()}},aI=new Set([500,502,503,504]),oI=new Set(["GET","HEAD","PUT","DELETE","OPTIONS"]),lI=class{constructor(t,e,n){if(this.userToken=null,this.autoRefreshToken=!0,this.isRefreshing=!1,this.refreshPromise=null,this.refreshToken=null,this.baseUrl=t.baseUrl||"http://localhost:7130",this.autoRefreshToken=t.autoRefreshToken??!0,this.fetch=t.fetch||(globalThis.fetch?globalThis.fetch.bind(globalThis):void 0),this.anonKey=t.anonKey,this.defaultHeaders={...t.headers},this.tokenManager=e??new sT,this.logger=n||new tT(!1),this.timeout=t.timeout??3e4,this.retryCount=t.retryCount??3,this.retryDelay=t.retryDelay??500,!this.fetch)throw new Error("Fetch is not available. Please provide a fetch implementation in the config.")}buildUrl(t,e){const n=new URL(t,this.baseUrl);return e&&Object.entries(e).forEach(([i,r])=>{if(i==="select"){let s=r.replace(/\s+/g," ").trim();s=s.replace(/\s*\(\s*/g,"(").replace(/\s*\)\s*/g,")").replace(/\(\s+/g,"(").replace(/\s+\)/g,")").replace(/,\s+(?=[^()]*\))/g,","),n.searchParams.append(i,s)}else n.searchParams.append(i,r)}),n.toString()}isRetryableStatus(t){return aI.has(t)}computeRetryDelay(t){const n=this.retryDelay*Math.pow(2,t-1)*(.85+Math.random()*.3);return Math.round(n)}async handleRequest(t,e,n={}){const{params:i,headers:r={},body:s,signal:o,...c}=n,u=this.buildUrl(e,i),d=Date.now(),p=oI.has(t.toUpperCase())||n.idempotent===!0?this.retryCount:0,m={...this.defaultHeaders},v=this.userToken||this.anonKey;v&&(m.Authorization=`Bearer ${v}`);let _;s!==void 0&&(typeof FormData<"u"&&s instanceof FormData?_=s:(t!=="GET"&&(m["Content-Type"]="application/json;charset=UTF-8"),_=JSON.stringify(s))),r instanceof Headers?r.forEach((y,b)=>{m[b]=y}):Array.isArray(r)?r.forEach(([y,b])=>{m[y]=b}):Object.assign(m,r),this.logger.logRequest(t,u,m,_);let w;for(let y=0;y<=p;y++){if(y>0){const A=this.computeRetryDelay(y);if(this.logger.warn(`Retry ${y}/${p} for ${t} ${u} in ${A}ms`),o?.aborted)throw o.reason;await new Promise((M,I)=>{const k=()=>{clearTimeout(U),I(o.reason)},U=setTimeout(()=>{o&&o.removeEventListener("abort",k),M()},A);o&&o.addEventListener("abort",k,{once:!0})})}let b,T;if((this.timeout>0||o)&&(b=new AbortController,this.timeout>0&&(T=setTimeout(()=>b.abort(),this.timeout)),o))if(o.aborted)b.abort(o.reason);else{const A=()=>b.abort(o.reason);o.addEventListener("abort",A,{once:!0}),b.signal.addEventListener("abort",()=>{o.removeEventListener("abort",A)},{once:!0})}try{const A=await this.fetch(u,{method:t,headers:m,body:_,...c,...b?{signal:b.signal}:{}});if(this.isRetryableStatus(A.status)&&y<p){T!==void 0&&clearTimeout(T),await A.body?.cancel(),w=new jt(`Server error: ${A.status} ${A.statusText}`,A.status,"SERVER_ERROR");continue}if(A.status===204){T!==void 0&&clearTimeout(T);return}let M;const I=A.headers.get("content-type");try{I?.includes("json")?M=await A.json():M=await A.text()}catch(k){throw T!==void 0&&clearTimeout(T),new jt(`Failed to parse response body: ${k?.message||"Unknown error"}`,A.status,A.ok?"PARSE_ERROR":"REQUEST_FAILED")}if(T!==void 0&&clearTimeout(T),!A.ok){if(this.logger.logResponse(t,u,A.status,Date.now()-d,M),M&&typeof M=="object"&&"error"in M){!M.statusCode&&!M.status&&(M.statusCode=A.status);const k=jt.fromApiError(M);throw Object.keys(M).forEach(U=>{U!=="error"&&U!=="message"&&U!=="statusCode"&&(k[U]=M[U])}),k}throw new jt(`Request failed: ${A.statusText}`,A.status,"REQUEST_FAILED")}return this.logger.logResponse(t,u,A.status,Date.now()-d,M),M}catch(A){if(T!==void 0&&clearTimeout(T),A?.name==="AbortError")throw b&&b.signal.aborted&&this.timeout>0&&!o?.aborted?new jt(`Request timed out after ${this.timeout}ms`,408,"REQUEST_TIMEOUT"):A;if(A instanceof jt)throw A;if(y<p){w=A;continue}throw new jt(`Network request failed: ${A?.message||"Unknown error"}`,0,"NETWORK_ERROR")}}throw w||new jt("Request failed after all retry attempts",0,"NETWORK_ERROR")}async request(t,e,n={}){try{return await this.handleRequest(t,e,{...n})}catch(i){if(i instanceof jt&&i.statusCode===401&&i.error==="INVALID_TOKEN"&&this.autoRefreshToken)try{const r=await this.handleTokenRefresh();return this.setAuthToken(r.accessToken),this.tokenManager.saveSession(r),r.csrfToken&&iT(r.csrfToken),r.refreshToken&&this.setRefreshToken(r.refreshToken),await this.handleRequest(t,e,{...n})}catch(r){throw this.tokenManager.clearSession(),this.userToken=null,this.refreshToken=null,rT(),r}throw i}}get(t,e){return this.request("GET",t,e)}post(t,e,n){return this.request("POST",t,{...n,body:e})}put(t,e,n){return this.request("PUT",t,{...n,body:e})}patch(t,e,n){return this.request("PATCH",t,{...n,body:e})}delete(t,e){return this.request("DELETE",t,e)}setAuthToken(t){this.userToken=t}setRefreshToken(t){this.refreshToken=t}getHeaders(){const t={...this.defaultHeaders},e=this.userToken||this.anonKey;return e&&(t.Authorization=`Bearer ${e}`),t}async handleTokenRefresh(){return this.isRefreshing?this.refreshPromise:(this.isRefreshing=!0,this.refreshPromise=(async()=>{try{const t=nT(),e=this.refreshToken?{refreshToken:this.refreshToken}:void 0;return await this.handleRequest("POST","/api/auth/sessions/current",{body:e,headers:t?{"X-CSRF-Token":t}:{},credentials:"include"})}finally{this.isRefreshing=!1,this.refreshPromise=null}})(),this.refreshPromise)}},c0="insforge_pkce_verifier";function aT(t){return btoa(String.fromCharCode(...t)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function cI(){const t=new Uint8Array(32);return crypto.getRandomValues(t),aT(t)}async function uI(t){const n=new TextEncoder().encode(t),i=await crypto.subtle.digest("SHA-256",n);return aT(new Uint8Array(i))}function dI(t){typeof sessionStorage<"u"&&sessionStorage.setItem(c0,t)}function fI(){if(typeof sessionStorage>"u")return null;const t=sessionStorage.getItem(c0);return t&&sessionStorage.removeItem(c0),t}function Yi(t,e){return t instanceof jt?{data:null,error:t}:{data:null,error:new jt(t instanceof Error?t.message:e,500,"UNEXPECTED_ERROR")}}function NS(...t){if(typeof window>"u")return;const e=new URL(window.location.href);t.forEach(n=>e.searchParams.delete(n)),window.history.replaceState({},document.title,e.toString())}var hI=class{constructor(t,e,n={}){this.http=t,this.tokenManager=e,this.options=n,this.authCallbackHandled=this.detectAuthCallback()}isServerMode(){return!!this.options.isServerMode}saveSessionFromResponse(t){if(!t.accessToken||!t.user)return!1;const e={accessToken:t.accessToken,user:t.user};return!this.isServerMode()&&t.csrfToken&&iT(t.csrfToken),this.isServerMode()||this.tokenManager.saveSession(e),this.http.setAuthToken(t.accessToken),this.http.setRefreshToken(t.refreshToken??null),!0}async detectAuthCallback(){if(!(this.isServerMode()||typeof window>"u"))try{const t=new URLSearchParams(window.location.search),e=t.get("error");if(e){NS("error"),console.debug("OAuth callback error:",e);return}const n=t.get("insforge_code");if(n){NS("insforge_code");const{error:i}=await this.exchangeOAuthCode(n);i&&console.debug("OAuth code exchange failed:",i.message);return}}catch(t){console.debug("OAuth callback detection skipped:",t)}}async signUp(t){try{const e=await this.http.post(this.isServerMode()?"/api/auth/users?client_type=mobile":"/api/auth/users",t,{credentials:"include"});return e.accessToken&&e.user&&this.saveSessionFromResponse(e),e.refreshToken&&this.http.setRefreshToken(e.refreshToken),{data:e,error:null}}catch(e){return Yi(e,"An unexpected error occurred during sign up")}}async signInWithPassword(t){try{const e=await this.http.post(this.isServerMode()?"/api/auth/sessions?client_type=mobile":"/api/auth/sessions",t,{credentials:"include"});return this.saveSessionFromResponse(e),e.refreshToken&&this.http.setRefreshToken(e.refreshToken),{data:e,error:null}}catch(e){return Yi(e,"An unexpected error occurred during sign in")}}async signOut(){try{try{await this.http.post(this.isServerMode()?"/api/auth/logout?client_type=mobile":"/api/auth/logout",void 0,{credentials:"include"})}catch{}return this.tokenManager.clearSession(),this.http.setAuthToken(null),this.http.setRefreshToken(null),this.isServerMode()||rT(),{error:null}}catch{return{error:new jt("Failed to sign out",500,"SIGNOUT_ERROR")}}}async signInWithOAuth(t){try{const{provider:e,redirectTo:n,skipBrowserRedirect:i}=t,r=encodeURIComponent(e.toLowerCase()),s=cI(),o=await uI(s);dI(s);const c={code_challenge:o};n&&(c.redirect_uri=n);const d=kh.options.includes(r)?`/api/auth/oauth/${r}`:`/api/auth/oauth/custom/${r}`,h=await this.http.get(d,{params:c});return!this.isServerMode()&&typeof window<"u"&&!i?(window.location.href=h.authUrl,{data:{},error:null}):{data:{url:h.authUrl,provider:r,codeVerifier:s},error:null}}catch(e){return e instanceof jt?{data:{},error:e}:{data:{},error:new jt("An unexpected error occurred during OAuth initialization",500,"UNEXPECTED_ERROR")}}}async exchangeOAuthCode(t,e){try{const n=e??fI();if(!n)return{data:null,error:new jt("PKCE code verifier not found. Ensure signInWithOAuth was called in the same browser session.",400,"PKCE_VERIFIER_MISSING")};const i={code:t,code_verifier:n},r=await this.http.post(this.isServerMode()?"/api/auth/oauth/exchange?client_type=mobile":"/api/auth/oauth/exchange",i,{credentials:"include"});return this.saveSessionFromResponse(r),{data:r,error:null}}catch(n){return Yi(n,"An unexpected error occurred during OAuth code exchange")}}async signInWithIdToken(t){try{const{provider:e,token:n}=t,i=await this.http.post("/api/auth/id-token?client_type=mobile",{provider:e,token:n},{credentials:"include"});return this.saveSessionFromResponse(i),i.refreshToken&&this.http.setRefreshToken(i.refreshToken),{data:i,error:null}}catch(e){return Yi(e,"An unexpected error occurred during ID token sign in")}}async refreshSession(t){try{if(this.isServerMode()&&!t?.refreshToken)return{data:null,error:new jt("refreshToken is required when refreshing session in server mode",400,"REFRESH_TOKEN_REQUIRED")};const e=this.isServerMode()?null:nT(),n=await this.http.post(this.isServerMode()?"/api/auth/refresh?client_type=mobile":"/api/auth/refresh",this.isServerMode()?{refresh_token:t?.refreshToken}:void 0,{headers:e?{"X-CSRF-Token":e}:{},credentials:"include"});return n.accessToken&&this.saveSessionFromResponse(n),{data:n,error:null}}catch(e){return Yi(e,"An unexpected error occurred during session refresh")}}async getCurrentUser(){await this.authCallbackHandled;try{if(this.isServerMode()){const e=this.tokenManager.getAccessToken();return e?(this.http.setAuthToken(e),{data:{user:(await this.http.get("/api/auth/sessions/current")).user??null},error:null}):{data:{user:null},error:null}}const t=this.tokenManager.getSession();if(t)return this.http.setAuthToken(t.accessToken),{data:{user:t.user},error:null};if(typeof window<"u"){const{data:e,error:n}=await this.refreshSession();if(n)return{data:{user:null},error:n};if(e?.accessToken)return{data:{user:e.user??null},error:null}}return{data:{user:null},error:null}}catch(t){return t instanceof jt?{data:{user:null},error:t}:{data:{user:null},error:new jt("An unexpected error occurred while getting user",500,"UNEXPECTED_ERROR")}}}async getProfile(t){try{return{data:await this.http.get(`/api/auth/profiles/${t}`),error:null}}catch(e){return Yi(e,"An unexpected error occurred while fetching user profile")}}async setProfile(t){try{const e=await this.http.patch("/api/auth/profiles/current",{profile:t}),n=this.tokenManager.getUser();return!this.isServerMode()&&n&&e.profile!==void 0&&this.tokenManager.setUser({...n,profile:e.profile}),{data:e,error:null}}catch(e){return Yi(e,"An unexpected error occurred while updating user profile")}}async resendVerificationEmail(t){try{return{data:await this.http.post("/api/auth/email/send-verification",t),error:null}}catch(e){return Yi(e,"An unexpected error occurred while sending verification email")}}async verifyEmail(t){try{const e=await this.http.post(this.isServerMode()?"/api/auth/email/verify?client_type=mobile":"/api/auth/email/verify",t,{credentials:"include"});return this.saveSessionFromResponse(e),e.refreshToken&&this.http.setRefreshToken(e.refreshToken),{data:e,error:null}}catch(e){return Yi(e,"An unexpected error occurred while verifying email")}}async sendResetPasswordEmail(t){try{return{data:await this.http.post("/api/auth/email/send-reset-password",t),error:null}}catch(e){return Yi(e,"An unexpected error occurred while sending password reset email")}}async exchangeResetPasswordToken(t){try{return{data:await this.http.post("/api/auth/email/exchange-reset-password-token",t),error:null}}catch(e){return Yi(e,"An unexpected error occurred while verifying reset code")}}async resetPassword(t){try{return{data:await this.http.post("/api/auth/email/reset-password",t),error:null}}catch(e){return Yi(e,"An unexpected error occurred while resetting password")}}async getPublicAuthConfig(){try{return{data:await this.http.get("/api/auth/public-config"),error:null}}catch(t){return Yi(t,"An unexpected error occurred while fetching auth configuration")}}};function pI(t,e){return async(n,i)=>{const r=typeof n=="string"?n:n.toString(),s=new URL(r),o=s.pathname.slice(1),c=o.match(/^rpc\/(.+)$/),u=c?`/api/database/rpc/${c[1]}`:`/api/database/records/${o}`,d=`${t.baseUrl}${u}${s.search}`,h=e.getAccessToken(),p=t.getHeaders(),m=h||p.Authorization?.replace("Bearer ",""),v=new Headers(i?.headers);return m&&!v.has("Authorization")&&v.set("Authorization",`Bearer ${m}`),await fetch(d,{...i,headers:v})}}var mI=class{constructor(t,e){this.postgrest=new cN("http://dummy",{fetch:pI(t,e),headers:{}})}from(t){return this.postgrest.from(t)}rpc(t,e,n){return this.postgrest.rpc(t,e,n)}},gI=class{constructor(t,e){this.bucketName=t,this.http=e}async upload(t,e){try{const n=await this.http.post(`/api/storage/buckets/${this.bucketName}/upload-strategy`,{filename:t,contentType:e.type||"application/octet-stream",size:e.size});if(n.method==="presigned")return await this.uploadWithPresignedUrl(n,e);if(n.method==="direct"){const i=new FormData;return i.append("file",e),{data:await this.http.request("PUT",`/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(t)}`,{body:i,headers:{}}),error:null}}throw new jt(`Unsupported upload method: ${n.method}`,500,"STORAGE_ERROR")}catch(n){return{data:null,error:n instanceof jt?n:new jt("Upload failed",500,"STORAGE_ERROR")}}}async uploadAuto(t){try{const e=t instanceof File?t.name:"file",n=await this.http.post(`/api/storage/buckets/${this.bucketName}/upload-strategy`,{filename:e,contentType:t.type||"application/octet-stream",size:t.size});if(n.method==="presigned")return await this.uploadWithPresignedUrl(n,t);if(n.method==="direct"){const i=new FormData;return i.append("file",t),{data:await this.http.request("POST",`/api/storage/buckets/${this.bucketName}/objects`,{body:i,headers:{}}),error:null}}throw new jt(`Unsupported upload method: ${n.method}`,500,"STORAGE_ERROR")}catch(e){return{data:null,error:e instanceof jt?e:new jt("Upload failed",500,"STORAGE_ERROR")}}}async uploadWithPresignedUrl(t,e){try{const n=new FormData;t.fields&&Object.entries(t.fields).forEach(([r,s])=>{n.append(r,s)}),n.append("file",e);const i=await fetch(t.uploadUrl,{method:"POST",body:n});if(!i.ok)throw new jt(`Upload to storage failed: ${i.statusText}`,i.status,"STORAGE_ERROR");return t.confirmRequired&&t.confirmUrl?{data:await this.http.post(t.confirmUrl,{size:e.size,contentType:e.type||"application/octet-stream"}),error:null}:{data:{key:t.key,bucket:this.bucketName,size:e.size,mimeType:e.type||"application/octet-stream",uploadedAt:new Date().toISOString(),url:this.getPublicUrl(t.key)},error:null}}catch(n){throw n instanceof jt?n:new jt("Presigned upload failed",500,"STORAGE_ERROR")}}async download(t){try{const e=await this.http.post(`/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(t)}/download-strategy`,{expiresIn:3600}),n=e.url,i={};e.method==="direct"&&Object.assign(i,this.http.getHeaders());const r=await fetch(n,{method:"GET",headers:i});if(!r.ok)try{const o=await r.json();throw jt.fromApiError(o)}catch{throw new jt(`Download failed: ${r.statusText}`,r.status,"STORAGE_ERROR")}return{data:await r.blob(),error:null}}catch(e){return{data:null,error:e instanceof jt?e:new jt("Download failed",500,"STORAGE_ERROR")}}}getPublicUrl(t){return`${this.http.baseUrl}/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(t)}`}async list(t){try{const e={};return t?.prefix&&(e.prefix=t.prefix),t?.search&&(e.search=t.search),t?.limit&&(e.limit=t.limit.toString()),t?.offset&&(e.offset=t.offset.toString()),{data:await this.http.get(`/api/storage/buckets/${this.bucketName}/objects`,{params:e}),error:null}}catch(e){return{data:null,error:e instanceof jt?e:new jt("List failed",500,"STORAGE_ERROR")}}}async remove(t){try{return{data:await this.http.delete(`/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(t)}`),error:null}}catch(e){return{data:null,error:e instanceof jt?e:new jt("Delete failed",500,"STORAGE_ERROR")}}}},vI=class{constructor(t){this.http=t}from(t){return new gI(t,this.http)}},yI=class{constructor(t){this.http=t,this.chat=new _I(t),this.images=new SI(t),this.embeddings=new bI(t)}},_I=class{constructor(t){this.completions=new xI(t)}},xI=class{constructor(t){this.http=t}async create(t){const e={model:t.model,messages:t.messages,temperature:t.temperature,maxTokens:t.maxTokens,topP:t.topP,stream:t.stream,webSearch:t.webSearch,fileParser:t.fileParser,thinking:t.thinking,tools:t.tools,toolChoice:t.toolChoice,parallelToolCalls:t.parallelToolCalls};if(t.stream){const r=this.http.getHeaders();r["Content-Type"]="application/json";const s=await this.http.fetch(`${this.http.baseUrl}/api/ai/chat/completion`,{method:"POST",headers:r,body:JSON.stringify(e)});if(!s.ok){const o=await s.json();throw new Error(o.error||"Stream request failed")}return this.parseSSEStream(s,t.model)}const n=await this.http.post("/api/ai/chat/completion",e),i=n.text||"";return{id:`chatcmpl-${Date.now()}`,object:"chat.completion",created:Math.floor(Date.now()/1e3),model:n.metadata?.model,choices:[{index:0,message:{role:"assistant",content:i,...n.tool_calls?.length&&{tool_calls:n.tool_calls},...n.annotations?.length&&{annotations:n.annotations}},finish_reason:n.tool_calls?.length?"tool_calls":"stop"}],usage:n.metadata?.usage||{prompt_tokens:0,completion_tokens:0,total_tokens:0}}}async*parseSSEStream(t,e){const n=t.body.getReader(),i=new TextDecoder;let r="";try{for(;;){const{done:s,value:o}=await n.read();if(s)break;r+=i.decode(o,{stream:!0});const c=r.split(`
42
- `);r=c.pop()||"";for(const u of c)if(u.startsWith("data: ")){const d=u.slice(6).trim();if(d)try{const h=JSON.parse(d);if((h.chunk||h.content)&&(yield{id:`chatcmpl-${Date.now()}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:e,choices:[{index:0,delta:{content:h.chunk||h.content},finish_reason:null}]}),h.tool_calls?.length&&(yield{id:`chatcmpl-${Date.now()}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:e,choices:[{index:0,delta:{tool_calls:h.tool_calls},finish_reason:"tool_calls"}]}),h.done){n.releaseLock();return}}catch{console.warn("Failed to parse SSE data:",d)}}}}finally{n.releaseLock()}}},bI=class{constructor(t){this.http=t}async create(t){const e=await this.http.post("/api/ai/embeddings",t);return{object:e.object,data:e.data,model:e.metadata?.model,usage:e.metadata?.usage?{prompt_tokens:e.metadata.usage.promptTokens||0,total_tokens:e.metadata.usage.totalTokens||0}:{prompt_tokens:0,total_tokens:0}}}},SI=class{constructor(t){this.http=t}async generate(t){const e=await this.http.post("/api/ai/image/generation",t);let n=[];return e.images&&e.images.length>0?n=e.images.map(i=>({b64_json:i.imageUrl.replace(/^data:image\/\w+;base64,/,""),content:e.text})):e.text&&(n=[{content:e.text}]),{created:Math.floor(Date.now()/1e3),data:n,...e.metadata?.usage&&{usage:{total_tokens:e.metadata.usage.totalTokens||0,input_tokens:e.metadata.usage.promptTokens||0,output_tokens:e.metadata.usage.completionTokens||0}}}}},wI=class oT{constructor(e,n){this.http=e,this.functionsUrl=n||oT.deriveSubhostingUrl(e.baseUrl)}static deriveSubhostingUrl(e){try{const{hostname:n}=new URL(e);return n.endsWith(".insforge.app")?`https://${n.split(".")[0]}.functions.insforge.app`:void 0}catch{return}}async invoke(e,n={}){const{method:i="POST",body:r,headers:s={}}=n;if(this.functionsUrl)try{return{data:await this.http.request(i,`${this.functionsUrl}/${e}`,{body:r,headers:s}),error:null}}catch(o){if(o instanceof Error&&o.name==="AbortError")throw o;if(!(o instanceof jt&&o.statusCode===404))return{data:null,error:o instanceof jt?o:new jt(o instanceof Error?o.message:"Function invocation failed",500,"FUNCTION_ERROR")}}try{const o=`/functions/${e}`;return{data:await this.http.request(i,o,{body:r,headers:s}),error:null}}catch(o){if(o instanceof Error&&o.name==="AbortError")throw o;return{data:null,error:o instanceof jt?o:new jt(o instanceof Error?o.message:"Function invocation failed",500,"FUNCTION_ERROR")}}}},IS=1e4,EI=class{constructor(t,e,n){this.socket=null,this.connectPromise=null,this.subscribedChannels=new Set,this.eventListeners=new Map,this.baseUrl=t,this.tokenManager=e,this.anonKey=n,this.tokenManager.onTokenChange=()=>this.onTokenChange()}notifyListeners(t,e){const n=this.eventListeners.get(t);if(n)for(const i of n)try{i(e)}catch(r){console.error(`Error in ${t} callback:`,r)}}connect(){return this.socket?.connected?Promise.resolve():this.connectPromise?this.connectPromise:(this.connectPromise=new Promise((t,e)=>{const n=this.tokenManager.getAccessToken()??this.anonKey;this.socket=Df(this.baseUrl,{transports:["websocket"],auth:n?{token:n}:void 0});let i=!0,r=null;const s=()=>{r&&(clearTimeout(r),r=null)};r=setTimeout(()=>{i&&(i=!1,this.connectPromise=null,this.socket?.disconnect(),this.socket=null,e(new Error(`Connection timeout after ${IS}ms`)))},IS),this.socket.on("connect",()=>{s();for(const o of this.subscribedChannels)this.socket.emit("realtime:subscribe",{channel:o});this.notifyListeners("connect"),i&&(i=!1,this.connectPromise=null,t())}),this.socket.on("connect_error",o=>{s(),this.notifyListeners("connect_error",o),i&&(i=!1,this.connectPromise=null,e(o))}),this.socket.on("disconnect",o=>{this.notifyListeners("disconnect",o)}),this.socket.on("realtime:error",o=>{this.notifyListeners("error",o)}),this.socket.onAny((o,c)=>{o!=="realtime:error"&&this.notifyListeners(o,c)})}),this.connectPromise)}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null),this.subscribedChannels.clear()}onTokenChange(){const t=this.tokenManager.getAccessToken()??this.anonKey;this.socket&&(this.socket.auth=t?{token:t}:{}),this.socket&&(this.socket.connected||this.connectPromise)&&(this.socket.disconnect(),this.socket.connect())}get isConnected(){return this.socket?.connected??!1}get connectionState(){return this.socket?this.socket.connected?"connected":"connecting":"disconnected"}get socketId(){return this.socket?.id}async subscribe(t){if(this.subscribedChannels.has(t))return{ok:!0,channel:t};if(!this.socket?.connected)try{await this.connect()}catch(e){const n=e instanceof Error?e.message:"Connection failed";return{ok:!1,channel:t,error:{code:"CONNECTION_FAILED",message:n}}}return new Promise(e=>{this.socket.emit("realtime:subscribe",{channel:t},n=>{n.ok&&this.subscribedChannels.add(t),e(n)})})}unsubscribe(t){this.subscribedChannels.delete(t),this.socket?.connected&&this.socket.emit("realtime:unsubscribe",{channel:t})}async publish(t,e,n){if(!this.socket?.connected)throw new Error("Not connected to realtime server. Call connect() first.");this.socket.emit("realtime:publish",{channel:t,event:e,payload:n})}on(t,e){this.eventListeners.has(t)||this.eventListeners.set(t,new Set),this.eventListeners.get(t).add(e)}off(t,e){const n=this.eventListeners.get(t);n&&(n.delete(e),n.size===0&&this.eventListeners.delete(t))}once(t,e){const n=i=>{this.off(t,n),e(i)};this.on(t,n)}getSubscribedChannels(){return Array.from(this.subscribedChannels)}},MI=class{constructor(t){this.http=t}async send(t){try{return{data:await this.http.post("/api/email/send-raw",t),error:null}}catch(e){if(e instanceof Error&&e.name==="AbortError")throw e;return{data:null,error:e instanceof jt?e:new jt(e instanceof Error?e.message:"Email send failed",500,"EMAIL_ERROR")}}}},TI=class{constructor(t={}){const e=new tT(t.debug);this.tokenManager=new sT,this.http=new lI(t,this.tokenManager,e),t.edgeFunctionToken&&(this.http.setAuthToken(t.edgeFunctionToken),this.tokenManager.setAccessToken(t.edgeFunctionToken)),this.auth=new hI(this.http,this.tokenManager,{isServerMode:t.isServerMode??!1}),this.database=new mI(this.http,this.tokenManager),this.storage=new vI(this.http),this.ai=new yI(this.http),this.functions=new wI(this.http,t.functionsUrl),this.realtime=new EI(this.http.baseUrl,this.tokenManager,t.anonKey),this.emails=new MI(this.http)}getHttpClient(){return this.http}};function AI(t){return new TI(t)}const cy={VITE_INSFORGE_ANON_KEY:"ik_9f35735991b684f7cf57fa00bb4d0487",VITE_INSFORGE_BASE_URL:"https://srctyff5.us-east.insforge.app"};function Ro(){const t=typeof import.meta<"u"?cy:void 0;return(t?.VITE_INSFORGE_BASE_URL||t?.VITE_TOKENTRACKER_BACKEND_BASE_URL||"").trim()}function lT(){if(typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"))return window.location.origin;const e=typeof import.meta<"u"?cy:void 0;return(e?.VITE_INSFORGE_BASE_URL||e?.VITE_TOKENTRACKER_BACKEND_BASE_URL||"").trim()}function Nh(){const t=typeof import.meta<"u"?cy:void 0;return(t?.VITE_INSFORGE_ANON_KEY||t?.VITE_TOKENTRACKER_BACKEND_ANON_KEY||"").trim()}function u0(){return!!lT()}let Om=null;function CI(){return u0()?(Om||(Om=AI({baseUrl:lT(),anonKey:Nh()||void 0,autoRefreshToken:!0})),Om):null}const cT="tokentracker_cloud_sync_enabled",uy="tokentracker_cloud_device_session_v1",dy="tokentracker_cloud_last_sync_ts";function PI(){if(typeof window>"u")return!1;const t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"}function RI(){try{const t=localStorage.getItem(cT);return t===null||t===""?!1:t==="1"||t==="true"}catch{return!1}}function q$(t){try{localStorage.setItem(cT,t?"1":"0")}catch{}}function uT(){try{const t=localStorage.getItem(uy);if(!t)return null;const e=JSON.parse(t);if(typeof e?.token=="string"&&e.token&&typeof e.deviceId=="string")return e}catch{}return null}function dT(t){try{localStorage.setItem(uy,JSON.stringify(t))}catch{}}function kI(){try{localStorage.removeItem(uy),localStorage.removeItem(dy)}catch{}}function LI(){try{const t=Number(localStorage.getItem(dy));return Number.isFinite(t)?t:0}catch{return 0}}function fT(t){try{localStorage.setItem(dy,String(t))}catch{}}function Ta(t){if(typeof t!="string")return null;const e=t.trim();return e.length>0?e:null}function DI(t){const e=Ta(t);if(!e)return null;const n=e.split(".");if(n.length<2)return null;const i=n[1];try{const r=i.replace(/-/g,"+").replace(/_/g,"/").padEnd(i.length+(4-i.length%4)%4,"="),s=typeof atob=="function"?atob(r):Buffer.from(r,"base64").toString("utf8"),c=JSON.parse(s)?.exp;return typeof c!="number"||!Number.isFinite(c)||c<=0?null:Math.floor(c*1e3)}catch{return null}}function NI(t){const e=Ta(t);if(!e)return!1;const n=e.split(".");if(n.length!==3)return!1;try{for(let i=0;i<2;i++){const r=n[i];if(!/^[A-Za-z0-9_-]+$/.test(r))return!1;const s=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=typeof atob=="function"?atob(s):Buffer.from(s,"base64").toString("utf8");i===1&&JSON.parse(o)}return!0}catch{return!1}}function II(t,e=3e4){const n=DI(t);return n?n<=Date.now()+Math.max(0,Number(e)||0):!1}async function UI(t){if(!t)return null;if(typeof t=="string")return Ta(t);if(typeof t=="function")try{const e=await t();return Ta(e)}catch{return null}if(typeof t=="object"){if(typeof t.getAccessToken=="function"){try{const e=await t.getAccessToken(),n=Ta(e);if(n)return n}catch{}return Ta(t.accessToken)}return null}return Ta(t)}async function Y$(t,e={}){const n=Math.max(1,Math.min(12,Math.floor(Number(e.maxAttempts)||8))),i=Math.max(20,Math.floor(Number(e.baseDelayMs)||50));for(let r=0;r<n;r++){const s=await UI(t);if(s)return s;r<n-1&&await new Promise(o=>setTimeout(o,i*(r+1)))}return null}function K$(t){return typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1")||typeof t=="function"||t&&typeof t=="object"&&typeof t.getAccessToken=="function"?!0:!!Ta(t)}function Z$(){if(typeof Intl>"u"||!Intl.DateTimeFormat)return null;try{return Intl.DateTimeFormat().resolvedOptions().timeZone||null}catch{return null}}function J$(t=new Date){const e=t instanceof Date?t:new Date(t);if(!Number.isFinite(e.getTime()))return 0;const n=e.getTimezoneOffset();return Number.isFinite(n)?-n:0}function hT(t){if(!Number.isFinite(t)||t===0)return"UTC";const e=t>=0?"+":"-",n=Math.abs(t),i=String(Math.floor(n/60)).padStart(2,"0"),r=String(n%60).padStart(2,"0");return`UTC${e}${i}:${r}`}function Q$({timeZone:t,offsetMinutes:e}={}){const n=hT(e);return t&&t!=="UTC"?`${t} (${n})`:n}function eX({timeZone:t,offsetMinutes:e}={}){return Number.isFinite(e)?hT(e):t||"UTC"}function tX({timeZone:t,offsetMinutes:e,date:n=new Date}={}){const i=n instanceof Date?n:new Date(n);if(!Number.isFinite(i.getTime()))return"";if(t&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const o=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i).reduce((h,p)=>(p.type&&p.value&&(h[p.type]=p.value),h),{}),c=o.year,u=o.month,d=o.day;if(c&&u&&d)return`${c}-${u}-${d}`}catch{}if(typeof e=="number"&&Number.isFinite(e)){const r=new Date(i.getTime()+e*6e4);return OI(r)}return BI(i)}function FI({timeZone:t,offsetMinutes:e,date:n=new Date}={}){const i=n instanceof Date?n:new Date(n);if(!Number.isFinite(i.getTime()))return null;if(t&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const o=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i).reduce((h,p)=>(p.type&&p.value&&(h[p.type]=p.value),h),{}),c=Number(o.year),u=Number(o.month),d=Number(o.day);if(Number.isFinite(c)&&Number.isFinite(u)&&Number.isFinite(d))return{year:c,month:u,day:d}}catch{}if(typeof e=="number"&&Number.isFinite(e)){const r=new Date(i.getTime()+e*6e4);return{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate()}}return{year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()}}function nX({timeZone:t,offsetMinutes:e}={}){return t?`tz:${t}`:typeof e=="number"&&Number.isFinite(e)?`offset:${Math.trunc(e)}`:"utc"}function OI(t){const e=t.getUTCFullYear(),n=String(t.getUTCMonth()+1).padStart(2,"0"),i=String(t.getUTCDate()).padStart(2,"0");return`${e}-${n}-${i}`}function BI(t){const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${i}`}function kn(t){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())).toISOString().slice(0,10)}function ps(t){const e=t instanceof Date?t:new Date(t);if(!Number.isFinite(e.getTime()))return"";const n=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${n}-${i}-${r}`}function zI(t){if(!t)return null;const e=String(t).trim(),n=e.split("-");if(n.length!==3)return null;const i=Number(n[0]),r=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(s))return null;const o=new Date(Date.UTC(i,r,s));return Number.isFinite(o.getTime())&&kn(o)===e?o:null}function VI(t){if(!t)return"";const e=t.year,n=String(t.month).padStart(2,"0"),i=String(t.day).padStart(2,"0");return!e||!n||!i?"":`${e}-${n}-${i}`}function HI(t,{timeZone:e,offsetMinutes:n,now:i}={}){const r=i instanceof Date&&Number.isFinite(i.getTime())?i:new Date,s=FI({timeZone:e,offsetMinutes:n,date:r});if(!s){const u=ps(new Date);return{from:u,to:u}}const o=VI(s),c=zI(o);if(!c)return{from:o,to:o};if(t==="day")return{from:o,to:o};if(t==="week"){const u=new Date(c),h=(u.getUTCDay()+6)%7;u.setUTCDate(u.getUTCDate()-h);const p=new Date(u);return p.setUTCDate(p.getUTCDate()+6),{from:kn(u),to:kn(p)}}if(t==="month"){const u=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth(),1)),d=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth()+1,0));return{from:kn(u),to:kn(d)}}if(t==="total"){const u=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth()-23,1));return{from:kn(u),to:o}}return HI("week")}function iX(t){if(t==null)return"-";try{if(typeof t=="bigint")return new Intl.NumberFormat().format(t);if(typeof t=="number")return new Intl.NumberFormat().format(t);const e=String(t).trim();return/^[0-9]+$/.test(e)?new Intl.NumberFormat().format(BigInt(e)):e}catch{return String(t)}}function rX(t,{thousandSuffix:e="K",millionSuffix:n="M",billionSuffix:i="B",decimals:r=1}={}){const s=Number(String(t));if(!Number.isFinite(s))return"-";const o=s<0?"-":"",c=Math.abs(s),u=Math.max(0,Math.min(6,Math.floor(r)));if(c<1e3)return`${o}${String(c)}`;const d=(v,_)=>{const w=v.toFixed(u),y=Number(w).toString();return`${o}${y}${_}`},h=(v,_,w)=>{const y=v.toFixed(u),b=Number(y);return w&&b>=1e3?d(b/1e3,w):`${o}${b.toString()}${_}`};if(c>=1e9)return d(c/1e9,i);if(c>=1e6)return h(c/1e6,n,i);const p=c/1e3,m=Number(p.toFixed(u));return m>=1e3?d(m/1e3,n):d(m,e)}function pT(t){const e=Number(String(t));return Number.isFinite(e)?e:null}function sX(t,{decimals:e=2}={}){if(t==null)return"-";const n=String(t).trim();if(!n)return"-";const i=n.match(/^(-?\d+)(?:\.(\d+))?$/);if(!i)return n;const r=i[1],s=i[2]||"";let o=r;try{o=new Intl.NumberFormat().format(BigInt(r))}catch{o=r}const c=Math.max(0,Math.min(6,Math.floor(e))),u=c?s.slice(0,c).padEnd(c,"0"):"",d=r.startsWith("-")?"-":"",h=c?`${o.replace("-","")}.${u}`:o.replace("-","");return`${d}$${h}`}function oh(t){if(typeof t!="string")return null;const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.trim());if(!e)return null;const n=Number(e[1]),i=Number(e[2])-1,r=Number(e[3]),s=new Date(Date.UTC(n,i,r));return Number.isFinite(s.getTime())&&kn(s)===t.trim()?s:null}function fo(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()+e))}function GI(t,e){const n=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())-Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate());return Math.floor(n/864e5)}function Bm(t,e){if(!Array.isArray(t)||t.length===0)return 0;const n=t.length,i=(n-1)*e,r=Math.floor(i),s=i-r,o=t[r]??t[n-1],c=t[Math.min(n-1,r+1)]??t[n-1];return Math.round(o+(c-o)*s)}function jI(t){return t<=0?0:t>=4?4:t}function mT({weeks:t=52,now:e,weekStartsOn:n="sun"}={}){const i=e instanceof Date&&Number.isFinite(e.getTime())?e:new Date,r=ps(i),s=oh(r)||new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),o=n==="mon"?1:0,c=s.getUTCDay(),u=fo(s,-((c-o+7)%7)),d=fo(u,-7*(Math.max(1,t)-1));return{from:kn(d),to:r}}function WI({dailyRows:t,weeks:e=52,to:n,weekStartsOn:i="sun"}={}){const r=oh(n)||new Date(Date.UTC(new Date().getFullYear(),new Date().getMonth(),new Date().getDate())),{from:s}=mT({weeks:e,now:r,weekStartsOn:i}),o=oh(s)||fo(r,-(e*7-1)),c=(()=>{const M=(o.getUTCDay()-(i==="mon"?1:0)+7)%7;return fo(o,-M)})(),u=new Map;for(const T of Array.isArray(t)?t:[]){const A=typeof T?.day=="string"?T.day:null;if(!A)continue;const M=pT(T?.billable_total_tokens??T?.total_tokens)??0;u.set(A,Math.max(0,M))}const d=GI(c,r)+1,h=Math.ceil(d/7),p=[];for(let T=0;T<d;T++){const A=fo(c,T),M=kn(A),I=u.get(M)??0;I>0&&p.push(I)}p.sort((T,A)=>T-A);const m=Bm(p,.5),v=Bm(p,.75),_=Bm(p,.9);function w(T){return!T||T<=0?0:T<=m?1:T<=v?2:T<=_?3:4}const y=[];for(let T=0;T<h;T++){const A=[];for(let M=0;M<7;M++){const I=T*7+M,k=fo(c,I);if(k.getTime()>r.getTime()){A.push(null);continue}const U=kn(k),S=u.get(U)??0;A.push({day:U,value:S,level:jI(w(S))})}y.push(A)}const b=y.length>e?y.slice(y.length-e):y;return{from:s,to:kn(r),weeks:b,thresholds:{t1:m,t2:v,t3:_}}}function $I({dailyRows:t,to:e}={}){const n=oh(e)||new Date(Date.UTC(new Date().getFullYear(),new Date().getMonth(),new Date().getDate())),i=new Map;for(const s of Array.isArray(t)?t:[]){const o=typeof s?.day=="string"?s.day:null;if(!o)continue;const c=pT(s?.billable_total_tokens??s?.total_tokens)??0;i.set(o,Math.max(0,c))}let r=0;for(let s=0;s<370;s++){const o=kn(fo(n,-s));if((i.get(o)??0)>0){r+=1;continue}break}return r}const Ih={},gT="tokentracker",XI=["victorgpt/tokentracker","spacedriveapp/spacedrive","acme/alpha","acme/beta","neo/nebula","signal/flux","matrix/terminal","orbit/atlas","lumen/core","delta/horizon"],US=["NEO","TRINITY","MORPHEUS","ORACLE","CYPHER","SWITCH","APOC","TANK","SMITH","SERAPH","NIOBE","MOUSE","DOZER","LINK","BLADE"];function xr(){if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock")||"").toLowerCase();if(e==="0"||e==="false"||e==="off"||e==="no")return!1;if(e==="1"||e==="true"||e==="on"||e==="yes")return!0}if(typeof import.meta<"u"&&Ih){const t="".toLowerCase();if(t==="1"||t==="true")return!0}return!1}function qI(){if(typeof import.meta<"u"&&Ih){const t="".trim();if(t)return t;const e="".trim();if(e)return e}if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock_now")||"").trim();if(e)return e;const n=String(t.get("mock_today")||"").trim();if(n)return n}return""}function YI(t){if(!t)return null;const e=String(t).trim();if(!e)return null;if(/^\d{4}-\d{2}-\d{2}$/.test(e)){const[i,r,s]=e.split("-").map(Number);if(!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(s))return null;const o=new Date(i,r-1,s,12,0,0);return Number.isFinite(o.getTime())?o:null}const n=new Date(e);return Number.isFinite(n.getTime())?n:null}function aX(){return xr()?YI(qI()):null}function KI(){if(typeof import.meta<"u"&&Ih){const t="".trim();if(t)return t}if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock_seed")||"").trim();if(e)return e}return gT}function ZI(){if(typeof import.meta<"u"&&Ih){const t="".trim(),e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock_missing")||"").trim(),n=Number(e);if(Number.isFinite(n)&&n>0)return Math.floor(n)}return 0}function Pu(t){return(t==null?KI():String(t)).trim()||gT}function Ru(t){let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function ki(t){if(typeof t!="string")return null;const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.trim());if(!e)return null;const n=Number(e[1]),i=Number(e[2])-1,r=Number(e[3]),s=new Date(Date.UTC(n,i,r));return Number.isFinite(s.getTime())&&kn(s)===t.trim()?s:null}function mu(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()+e))}function vT(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+e,1))}function JI(t){return`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,"0")}`}function Vl({from:t,to:e,seed:n}){const i=ki(ps(new Date))||new Date,r=ki(t)||i,s=ki(e)||r,o=[],c=Pu(n),u=Math.floor((Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())-Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate()))/864e5)+1;for(let d=0;d<u;d+=1){const h=mu(r,d),p=kn(h),m=Ru(`${c}:${p}`),v=m%1e3/1e3,_=.6+.4*Math.sin(d/6*Math.PI*.5),w=h.getUTCDay()===0||h.getUTCDay()===6?.65:1,y=18e3+Math.round(12e3*v),b=Math.max(0,Math.round(y*_*w)),T=Math.round(b*.46),A=Math.round(b*.34),M=Math.round(b*.14),I=Math.max(0,b-T-A-M);o.push({day:p,total_tokens:b,billable_total_tokens:b,input_tokens:T,output_tokens:A,cached_input_tokens:M,reasoning_output_tokens:I,conversation_count:1+m%5})}return o}function QI({day:t,seed:e}){const n=ki(t)||ki(ps(new Date))||new Date,i=kn(n),r=Pu(e),s=Array.from({length:48},(c,u)=>{const d=Math.floor(u/2),h=u%2===0?0:30,m=Ru(`${r}:${i}:${d}:${h}`)%1e3/1e3,v=(d+h/60)/24,_=.4+.6*Math.sin(v*Math.PI*2),w=900+Math.round(700*m),y=Math.max(0,Math.round(w*_)),b=Math.round(y*.46),T=Math.round(y*.34),A=Math.round(y*.14),M=Math.max(0,y-b-T-A);return{hour:`${i}T${String(d).padStart(2,"0")}:${String(h).padStart(2,"0")}:00`,total_tokens:y,billable_total_tokens:y,input_tokens:b,output_tokens:T,cached_input_tokens:A,reasoning_output_tokens:M}}),o=Math.max(0,Math.min(48,ZI()));if(o>0){const c=Date.now(),u=s.map((p,m)=>{const v=Date.parse(p.hour);return Number.isFinite(v)&&v<=c?{index:m,ts:v}:null}).filter(Boolean),d=Math.max(0,u.length-o),h=u.slice(d);for(const p of h){const m=s[p.index];m&&(s[p.index]={...m,missing:!0})}}return s}function eU({months:t=24,to:e,seed:n}){const i=ki(e)||ki(ps(new Date))||new Date,r=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1)),s=Pu(n),o=[];for(let c=t-1;c>=0;c-=1){const u=vT(r,-c),d=JI(u),p=Ru(`${s}:${d}`)%1e3/1e3,m=.7+.3*Math.sin(o.length/6*Math.PI*.5),v=36e4+Math.round(2e5*p),_=Math.max(0,Math.round(v*m)),w=Math.round(_*.46),y=Math.round(_*.34),b=Math.round(_*.14),T=Math.max(0,_-w-y-b);o.push({month:d,total_tokens:_,billable_total_tokens:_,input_tokens:w,output_tokens:y,cached_input_tokens:b,reasoning_output_tokens:T})}return o}function fy(t){return t.reduce((e,n)=>(e.total_tokens+=Number(n.total_tokens||0),e.billable_total_tokens+=Number(n.billable_total_tokens||n.total_tokens||0),e.input_tokens+=Number(n.input_tokens||0),e.output_tokens+=Number(n.output_tokens||0),e.cached_input_tokens+=Number(n.cached_input_tokens||0),e.reasoning_output_tokens+=Number(n.reasoning_output_tokens||0),e.conversation_count+=Number(n.conversation_count||0),e),{total_tokens:0,billable_total_tokens:0,input_tokens:0,output_tokens:0,cached_input_tokens:0,reasoning_output_tokens:0,conversation_count:0})}function tU(t,e=1.75){const n=Number(t||0);return!Number.isFinite(n)||n<=0?"0.000000":(n*e/1e6).toFixed(6)}function FS(t,e){const n=Number.isFinite(e)?e:0;return{total_tokens:Math.max(0,Math.round(t.total_tokens*n)),billable_total_tokens:Math.max(0,Math.round((t.billable_total_tokens??t.total_tokens)*n)),input_tokens:Math.max(0,Math.round(t.input_tokens*n)),output_tokens:Math.max(0,Math.round(t.output_tokens*n)),cached_input_tokens:Math.max(0,Math.round(t.cached_input_tokens*n)),reasoning_output_tokens:Math.max(0,Math.round(t.reasoning_output_tokens*n))}}function d0(t){return{...t,total_cost_usd:tU(t.total_tokens)}}function nU({from:t,to:e,seed:n}={}){const i=Vl({from:t,to:e,seed:n});return{from:t,to:e,data:i}}function iU({day:t,seed:e}={}){const n=ki(t)||new Date,i=kn(n),r=QI({day:i,seed:e});return{day:i,data:r}}function rU({months:t=24,to:e,seed:n}={}){const i=ki(e)||ki(ps(new Date))||new Date,r=kn(i),s=eU({months:t,to:r,seed:n}),o=vT(new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1)),-(t-1));return{from:kn(o),to:r,months:t,data:s}}function sU({from:t,to:e,seed:n,rolling:i=!0}={}){const r=Vl({from:t,to:e,seed:n}),s=fy(r),o=d0(s),c=i?aU({to:e,seed:n}):null;return{from:t,to:e,days:r.length,totals:o,...c?{rolling:c}:{}}}function aU({to:t,seed:e}={}){const n=ki(t)||ki(ps(new Date))||new Date,i=kn(n),r=kn(mu(n,-6)),s=kn(mu(n,-29)),o=Vl({from:r,to:i,seed:e}),c=Vl({from:s,to:i,seed:e});return{last_7d:OS({rows:o,from:r,to:i}),last_30d:OS({rows:c,from:s,to:i})}}function OS({rows:t,from:e,to:n}={}){const i=fy(t||[]),r=(t||[]).filter(o=>Number(o.billable_total_tokens??o.total_tokens)>0).length,s=r>0?Math.floor(i.billable_total_tokens/r):0;return{from:e,to:n,totals:{billable_total_tokens:i.billable_total_tokens,conversation_count:i.conversation_count},active_days:r,avg_per_active_day:s}}function oU({seed:t,limit:e=3}={}){const n=Pu(t),i=XI.map((r,s)=>{const c=12e4+Ru(`${n}:${r}`)%9e5,u=s%4*4200,d=Math.max(0,c+u),h=Math.max(0,Math.round(d*.96));return{project_key:r,project_ref:`https://github.com/${r}`,total_tokens:String(d),billable_total_tokens:String(h)}}).sort((r,s)=>Number(s.billable_total_tokens)-Number(r.billable_total_tokens)).slice(0,Math.max(1,Math.min(10,Math.floor(Number(e)||3))));return{generated_at:new Date().toISOString(),entries:i}}function lU(t){const e=ki(ps(new Date))||new Date,n=String(t).trim().toLowerCase()||"week";if(n==="total")return{from:"1970-01-01",to:"9999-12-31"};if(n==="month"){const o=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)),c=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+1,0));return{from:kn(o),to:kn(c)}}const i=e.getUTCDay(),r=kn(mu(e,-i)),s=kn(mu(e,-i+6));return{from:r,to:s}}function yT({seed:t,period:e,metric:n,limit:i=20,offset:r=0}={}){const s=Pu(t),o=Math.max(1,Math.min(100,Math.floor(Number(i)||20))),c=Math.max(0,Math.min(1e4,Math.floor(Number(r)||0))),u=String(n||"all").trim().toLowerCase()||"all",d=String(e||"week").trim().toLowerCase()||"week",h=d==="month"||d==="total"||d==="week"?d:"week",{from:p,to:m}=lU(h),v=250,_=v>0?Math.ceil(v/o):0,w=Math.floor(c/o)+1,y=Array.from({length:v},(U,S)=>{const P=S+1,V=`00000000-0000-0000-0000-${String(P).padStart(12,"0")}`,O=US[P%US.length],J=18e4+Ru(`${s}:${O}:${P}`)%9e5,H=Math.max(0,J+P*1200),X=Math.floor(H*.28),K=Math.floor(H*.18),Q=Math.floor(H*.1),W=Math.floor(H*.1),q=Math.floor(H*.08),Z=Math.floor(H*.03),z=Math.floor(H*.02),ie=Math.floor(H*.04),we=Math.floor(H*.03),He=Math.max(0,H-X-K-Q-W-q-Z-z-ie-we),Se=P%7!==0;return{id:P,user_id:V,is_public:Se,is_me:!1,display_name:Se?O:"Anonymous",avatar_url:null,gpt_tokens:X,claude_tokens:K,gemini_tokens:Q,cursor_tokens:W,opencode_tokens:q,openclaw_tokens:He,hermes_tokens:Z,kiro_tokens:z,copilot_tokens:ie,kimi_tokens:we,other_tokens:0,total_tokens:H}}),b=Math.max(0,Math.min(v-1,Math.floor(v*.8)));y[b]&&(y[b].is_me=!0);const T=u==="gpt"||u==="codex"?"gpt_tokens":u==="claude"?"claude_tokens":u==="gemini"?"gemini_tokens":u==="cursor"?"cursor_tokens":u==="opencode"?"opencode_tokens":u==="openclaw"?"openclaw_tokens":u==="hermes"?"hermes_tokens":u==="kiro"?"kiro_tokens":u==="copilot"?"copilot_tokens":u==="kimi"?"kimi_tokens":"total_tokens",A=y.slice().sort((U,S)=>Number(S[T])-Number(U[T])||U.id-S.id).map((U,S)=>({user_id:U.is_public?U.user_id:null,rank:S+1,is_me:!!U.is_me,display_name:U.display_name,avatar_url:U.avatar_url,gpt_tokens:String(U.gpt_tokens),claude_tokens:String(U.claude_tokens),gemini_tokens:String(U.gemini_tokens),cursor_tokens:String(U.cursor_tokens),opencode_tokens:String(U.opencode_tokens),openclaw_tokens:String(U.openclaw_tokens),hermes_tokens:String(U.hermes_tokens??0),kiro_tokens:String(U.kiro_tokens??0),copilot_tokens:String(U.copilot_tokens??0),kimi_tokens:String(U.kimi_tokens??0),other_tokens:String(U.other_tokens??0),total_tokens:String(U.total_tokens),is_public:!!U.is_public})),M=A.find(U=>U?.is_me)||null,I=M?{rank:M.rank,gpt_tokens:M.gpt_tokens,claude_tokens:M.claude_tokens,gemini_tokens:M.gemini_tokens,cursor_tokens:M.cursor_tokens,opencode_tokens:M.opencode_tokens,openclaw_tokens:M.openclaw_tokens,hermes_tokens:M.hermes_tokens,kiro_tokens:M.kiro_tokens,copilot_tokens:M.copilot_tokens,kimi_tokens:M.kimi_tokens,other_tokens:M.other_tokens,total_tokens:M.total_tokens}:{rank:null,gpt_tokens:"0",claude_tokens:"0",gemini_tokens:"0",cursor_tokens:"0",opencode_tokens:"0",openclaw_tokens:"0",hermes_tokens:"0",kiro_tokens:"0",copilot_tokens:"0",kimi_tokens:"0",other_tokens:"0",total_tokens:"0"},k=A.slice(c,c+o);return{period:h,metric:u,from:p,to:m,generated_at:new Date().toISOString(),page:w,limit:o,offset:c,total_entries:v,total_pages:_,entries:k,me:I}}function cU({weeks:t=52,to:e,weekStartsOn:n="sun",seed:i}={}){const r=mT({weeks:t,now:ki(e)||ki(ps(new Date))||new Date,weekStartsOn:n}),s=Vl({from:r.from,to:r.to,seed:i});return{...WI({dailyRows:s,weeks:t,to:r.to,weekStartsOn:n}),week_starts_on:n,active_days:s.filter(c=>Number(c.billable_total_tokens??c.total_tokens)>0).length,streak_days:$I({dailyRows:s,to:r.to})}}function uU({from:t,to:e,seed:n}={}){const i=Vl({from:t,to:e,seed:n}),r=fy(i),o=[{source:"codex",weight:.7,models:[{model:"gpt-5.2-codex",model_id:"gpt-5.2-codex",weight:.2},{model:"unknown",model_id:"unknown",weight:.8}]},{source:"claude",weight:.2,models:[{model:"claude-3.5",model_id:"claude-3.5",weight:.3},{model:"unknown",model_id:"unknown",weight:.7}]},{source:"every-code",weight:.1,models:[{model:"unknown",model_id:"unknown",weight:1}]}].map(c=>{const u=FS(r,c.weight),d=c.models.map(h=>{const p=FS(u,h.weight);return{model:h.model,model_id:h.model_id||h.model,totals:d0(p)}});return{source:c.source,totals:d0(u),models:d}});return{from:t,to:e,days:i.length,sources:o,pricing:{model:"mock",pricing_mode:"add",source:"mock",effective_from:ps(new Date),rates_per_million_usd:{input:"1.750000",cached_input:"0.175000",output:"14.000000",reasoning_output:"14.000000"}}}}const ms={usageSummary:"tokentracker-usage-summary",usageDaily:"tokentracker-usage-daily",usageHourly:"tokentracker-usage-hourly",usageMonthly:"tokentracker-usage-monthly",usageHeatmap:"tokentracker-usage-heatmap",usageModelBreakdown:"tokentracker-usage-model-breakdown",projectUsageSummary:"tokentracker-project-usage-summary",userStatus:"tokentracker-user-status",localSync:"tokentracker-local-sync",usageLimits:"tokentracker-usage-limits"};async function $s(t,e,n){const i=new URL(`/functions/${t}`,window.location.origin);if(e)for(const[s,o]of Object.entries(e))o!=null&&o!==""&&i.searchParams.set(s,String(o));const r=await fetch(i.toString(),{headers:{Accept:"application/json"},cache:"no-store",...n});if(!r.ok){const s=new Error(`Request failed with HTTP ${r.status}`);throw s.status=r.status,s}return r.json()}function ko({timeZone:t,tzOffsetMinutes:e}={}){const n={},i=typeof t=="string"?t.trim():"";return i&&(n.tz=i),Number.isFinite(e)&&(n.tz_offset_minutes=String(Math.trunc(e))),n}function Lo({source:t,model:e}={}){const n={},i=typeof t=="string"?t.trim().toLowerCase():"";i&&(n.source=i);const r=typeof e=="string"?e.trim():"";return r&&(n.model=r),n}async function oX({from:t,to:e,source:n,model:i,timeZone:r,tzOffsetMinutes:s,rolling:o=!1,accessToken:c}={}){if(xr())return sU({from:t,to:e,seed:c,rolling:o});const u=ko({timeZone:r,tzOffsetMinutes:s}),d=Lo({source:n,model:i}),h=o?{rolling:"1"}:{};return $s(ms.usageSummary,{from:t,to:e,...d,...u,...h})}async function lX({from:t,to:e,source:n,limit:i,timeZone:r,tzOffsetMinutes:s,accessToken:o}={}){if(xr())return oU({seed:o,limit:i});const c=ko({timeZone:r,tzOffsetMinutes:s}),d={...Lo({source:n}),...c};return t&&(d.from=t),e&&(d.to=e),i!=null&&(d.limit=String(i)),$s(ms.projectUsageSummary,d)}async function ku(t,e={}){const n=Ro();if(!n)throw new Error("InsForge base URL not configured");const i=n.replace(/\/$/,""),r=new URL(`${i}/functions/${t}`);if(e.params)for(const[u,d]of Object.entries(e.params))d!=null&&d!==""&&r.searchParams.set(u,String(d));const s={Accept:"application/json","Content-Type":"application/json"},o=Nh();o&&(s.apikey=o),e.accessToken&&NI(e.accessToken)&&(s.Authorization=`Bearer ${e.accessToken}`);const c=await fetch(r.toString(),{method:e.method||"GET",headers:s,...e.body!=null?{body:JSON.stringify(e.body)}:{}});if(!c.ok){const u=new Error(`Request failed with HTTP ${c.status}`);throw u.status=c.status,u}return c.json()}async function cX({accessToken:t,userId:e,period:n,metric:i,limit:r,offset:s}={}){return xr()?yT({seed:t||e,period:n,metric:i,limit:r,offset:s}):ku("tokentracker-leaderboard",{params:{period:n,limit:r,offset:s,user_id:e}})}async function BS({accessToken:t}={}){return ku("tokentracker-public-visibility",{accessToken:t,method:"GET"})}async function uX({accessToken:t,enabled:e,anonymous:n,display_name:i}={}){const r={};return e!==void 0&&(r.enabled=!!e),n!==void 0&&(r.anonymous=!!n),i!==void 0&&(r.display_name=String(i)),ku("tokentracker-public-visibility",{accessToken:t,method:"POST",body:r})}async function dX({accessToken:t,period:e}={}){return ku("tokentracker-leaderboard-refresh",{accessToken:t,method:"POST",body:e?{period:e}:{}})}async function fX({accessToken:t,userId:e,period:n}={}){if(xr()){const i=yT({seed:t,period:n,metric:"all",limit:250,offset:0}),s=(Array.isArray(i?.entries)?i.entries:[]).find(o=>o?.user_id===e)||null;return{period:i?.period??"week",from:i?.from??null,to:i?.to??null,generated_at:i?.generated_at??new Date().toISOString(),entry:s}}return ku("tokentracker-leaderboard-profile",{accessToken:t,params:{user_id:e,period:n}})}async function hX(t={}){if(xr()){const e=new Date().toISOString();return{user_id:"local-user",created_at:e,pro:{active:!1,sources:[],expires_at:null,partial:!1,as_of:e},subscriptions:{partial:!1,as_of:e,items:[]},install:{partial:!1,as_of:e,has_active_device_token:!1,has_active_device:!1,active_device_tokens:0,active_devices:0,latest_token_activity_at:null,latest_device_seen_at:null}}}return $s(ms.userStatus)}async function pX({signal:t}={}){const e=await fetch(`/functions/${ms.localSync}`,{method:"POST",headers:{Accept:"application/json"},cache:"no-store",signal:t}),n=await e.json().catch(()=>({ok:!1,error:`Local sync request failed with HTTP ${e.status}`}));if(!e.ok||n?.ok===!1){const i=n?.error||n?.message||`Local sync request failed with HTTP ${e.status}`,r=new Error(i);throw r.status=e.status,r}return n}async function mX({from:t,to:e,source:n,timeZone:i,tzOffsetMinutes:r,accessToken:s}={}){if(xr())return uU({from:t,to:e,seed:s});const o=ko({timeZone:i,tzOffsetMinutes:r}),c=Lo({source:n});return $s(ms.usageModelBreakdown,{from:t,to:e,...c,...o})}async function gX({from:t,to:e,source:n,model:i,timeZone:r,tzOffsetMinutes:s,accessToken:o}={}){if(xr())return nU({from:t,to:e,seed:o});const c=ko({timeZone:r,tzOffsetMinutes:s}),u=Lo({source:n,model:i});return $s(ms.usageDaily,{from:t,to:e,...u,...c})}async function vX({day:t,source:e,model:n,timeZone:i,tzOffsetMinutes:r,accessToken:s}={}){if(xr())return iU({day:t,seed:s});const o=ko({timeZone:i,tzOffsetMinutes:r}),c=Lo({source:e,model:n}),u=t?{day:t,...c,...o}:{...c,...o};return $s(ms.usageHourly,u)}async function yX({months:t,to:e,source:n,model:i,timeZone:r,tzOffsetMinutes:s,accessToken:o}={}){if(xr())return rU({months:t,to:e,seed:o});const c=ko({timeZone:r,tzOffsetMinutes:s}),u=Lo({source:n,model:i});return $s(ms.usageMonthly,{...t?{months:String(t)}:{},...e?{to:e}:{},...u,...c})}async function _X(t={}){const e=t?.refresh?{refresh:"1"}:void 0;return $s(ms.usageLimits,e)}async function xX({weeks:t,to:e,weekStartsOn:n,source:i,model:r,timeZone:s,tzOffsetMinutes:o,accessToken:c}={}){if(xr())return cU({weeks:t,to:e,weekStartsOn:n,seed:c});const u=ko({timeZone:s,tzOffsetMinutes:o}),d=Lo({source:i,model:r});return $s(ms.usageHeatmap,{weeks:String(t),to:e,week_starts_on:n,...d,...u})}const _T=L.createContext(null);function dU(t){if(!t||typeof t!="object")return"";const e=t.user_metadata&&typeof t.user_metadata=="object"?t.user_metadata:{},n=t.profile&&typeof t.profile=="object"?t.profile:{},i=e.full_name||e.name||n.name||e.user_name||e.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof t.email=="string"&&t.email.includes("@")?t.email.split("@")[0].trim()||t.email.trim():typeof t.email=="string"?t.email.trim():""}function zS(t){if(!t||typeof t!="object")return null;const e=t,n=e.session&&typeof e.session=="object"?e.session:null,i=typeof e.accessToken=="string"&&e.accessToken||typeof e.access_token=="string"&&e.access_token||n&&typeof n.accessToken=="string"&&n.accessToken||n&&typeof n.access_token=="string"&&n.access_token||null;return i&&i.length>0?i:null}async function zm(t,e={}){if(!t)return null;const n=Math.max(0,Math.floor(Number(e.skewMs)||6e4)),i=t.tokenManager,r=()=>i?.getAccessToken?.()??i?.getSession?.()?.accessToken??null;let s=r();if(!s||II(s,n)){const{data:o}=await t.auth.refreshSession();if(s=r()??zS(o)??null,!s&&typeof t.auth.getCurrentUser=="function")try{await t.auth.getCurrentUser(),s=r()??zS(o)??null}catch{}}return s||null}function fU({children:t}){const[e,n]=L.useState(null),[i,r]=L.useState(null),[s,o]=L.useState(!0);L.useEffect(()=>{if(!u0()){n(null),r(null),o(!1);return}n(CI())},[]),L.useEffect(()=>{if(!e)return;let k=!0;return o(!0),(async()=>{try{let{data:U,error:S}=await e.auth.getCurrentUser();if(!k)return;if(!S&&!U?.user){if(await new Promise(V=>setTimeout(V,150)),!k)return;const P=await e.auth.getCurrentUser();U=P.data,S=P.error}if(S){r(null);return}r(U?.user??null)}catch{k&&r(null)}finally{k&&o(!1)}})(),()=>{k=!1}},[e]);const c=L.useCallback(async()=>{if(e)try{let{data:k,error:U}=await e.auth.getCurrentUser();if(!U&&!k?.user){await new Promise(P=>setTimeout(P,150));const S=await e.auth.getCurrentUser();k=S.data,U=S.error}if(U){r(null);return}r(k?.user??null)}catch{r(null)}},[e]),u=L.useCallback(async(k,U)=>{if(!e)return{error:new Error("InsForge client not configured")};const S=typeof window<"u"&&window.webkit?.messageHandlers?.nativeOAuth;if(S){const O=typeof U=="string"&&U.trim()?U.trim():`${window.location.origin}/auth/callback`,G=await e.auth.signInWithOAuth({provider:k,redirectTo:O,skipBrowserRedirect:!0});if(G.data?.url){try{await fetch("/api/auth-bridge/verifier",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({native:!0})})}catch{}S.postMessage(G.data.url)}return G}const P=typeof U=="string"&&U.trim()?U.trim():typeof window<"u"?`${window.location.origin}/dashboard`:void 0;return await e.auth.signInWithOAuth({provider:k,redirectTo:P})},[e]),d=L.useCallback(async k=>{if(!e)return{data:null,error:new Error("InsForge client not configured")};const{data:U,error:S}=await e.auth.signInWithPassword(k);return U?.user&&r(U.user),{data:U,error:S}},[e]),h=L.useCallback(async k=>{if(!e)return{data:null,error:new Error("InsForge client not configured")};const{data:U,error:S}=await e.auth.signUp(k);return U?.user&&U?.accessToken&&r(U.user),{data:U,error:S}},[e]),p=L.useCallback(async()=>e?e.auth.getPublicAuthConfig():{data:null,error:new Error("InsForge client not configured")},[e]),m=L.useCallback(async()=>{e&&(await e.auth.signOut(),kI(),r(null))},[e]),v=L.useCallback(async()=>zm(e),[e]),[_,w]=L.useState(null),[y,b]=L.useState(!1),T=L.useMemo(()=>dU(i),[i]);L.useEffect(()=>{if(!i||!e){w(null),b(!1);return}let k=!0;return(async()=>{try{const U=await zm(e);if(!k||!U){k&&b(!0);return}const S=await BS({accessToken:U});k&&S?.display_name&&w(S.display_name)}catch{}k&&b(!0)})(),()=>{k=!1}},[i,e]);const A=y?_||T:"",M=L.useCallback(async()=>{if(e)try{const k=await zm(e);if(!k)return;const U=await BS({accessToken:k});U?.display_name&&w(U.display_name)}catch{}},[e]),I=L.useMemo(()=>!u0()||!e?{enabled:!1,client:null,user:null,signedIn:!1,loading:!1,displayName:"",refreshUser:async()=>{},refreshDisplayName:async()=>{},signInWithOAuth:async()=>({error:new Error("InsForge not configured")}),signInWithPassword:async()=>({data:null,error:new Error("InsForge not configured")}),signUp:async()=>({data:null,error:new Error("InsForge not configured")}),getPublicAuthConfig:async()=>({data:null,error:new Error("InsForge not configured")}),signOut:async()=>{},getAccessToken:async()=>null}:{enabled:!0,client:e,user:i,signedIn:!!i,loading:s,displayName:A,refreshUser:c,refreshDisplayName:M,signInWithOAuth:u,signInWithPassword:d,signUp:h,getPublicAuthConfig:p,signOut:m,getAccessToken:v},[e,i,s,A,c,M,u,d,h,p,m,v]);return F.jsx(_T.Provider,{value:I,children:t})}function Do(){return L.useContext(_T)}const hU="modulepreload",pU=function(t){return"/"+t},VS={},No=function(e,n,i){let r=Promise.resolve();if(n&&n.length>0){let u=function(d){return Promise.all(d.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),c=o?.nonce||o?.getAttribute("nonce");r=u(n.map(d=>{if(d=pU(d),d in VS)return;VS[d]=!0;const h=d.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":hU,h||(m.as="script"),m.crossOrigin="",m.href=d,c&&m.setAttribute("nonce",c),document.head.appendChild(m),h)return new Promise((v,_)=>{m.addEventListener("load",v),m.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${d}`)))})}))}function s(o){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=o,window.dispatchEvent(c),!c.defaultPrevented)throw o}return r.then(o=>{for(const c of o||[])c.status==="rejected"&&s(c.reason);return e().catch(s)})};var lh={},mU=()=>{window.va||(window.va=function(...e){window.vaq||(window.vaq=[]),window.vaq.push(e)})},gU="@vercel/analytics",vU="2.0.1";function xT(){return typeof window<"u"}function bT(){try{const t="production"}catch{}return"production"}function yU(t="auto"){if(t==="auto"){window.vam=bT();return}window.vam=t}function _U(){return(xT()?window.vam:bT())||"production"}function hy(){return _U()==="development"}function xU(t){return t.scriptSrc?Pl(t.scriptSrc):hy()?"https://va.vercel-scripts.com/v1/script.debug.js":t.basePath?Pl(`${t.basePath}/insights/script.js`):"/_vercel/insights/script.js"}function bU(t,e){var n;let i=t;if(e)try{i={...(n=JSON.parse(e))==null?void 0:n.analytics,...t}}catch{}yU(i.mode);const r={sdkn:gU+(i.framework?`/${i.framework}`:""),sdkv:vU};return i.disableAutoTrack&&(r.disableAutoTrack="1"),i.viewEndpoint&&(r.viewEndpoint=Pl(i.viewEndpoint)),i.eventEndpoint&&(r.eventEndpoint=Pl(i.eventEndpoint)),i.sessionEndpoint&&(r.sessionEndpoint=Pl(i.sessionEndpoint)),hy()&&i.debug===!1&&(r.debug="false"),i.dsn&&(r.dsn=i.dsn),i.endpoint?r.endpoint=i.endpoint:i.basePath&&(r.endpoint=Pl(`${i.basePath}/insights`)),{beforeSend:i.beforeSend,src:xU(i),dataset:r}}function Pl(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")?t:`/${t}`}function SU(t={debug:!0},e){var n;if(!xT())return;const{beforeSend:i,src:r,dataset:s}=bU(t,e);if(mU(),i&&((n=window.va)==null||n.call(window,"beforeSend",i)),document.head.querySelector(`script[src*="${r}"]`))return;const o=document.createElement("script");o.src=r;for(const[c,u]of Object.entries(s))o.dataset[c]=u;o.defer=!0,o.onerror=()=>{const c=hy()?"Please check if any ad blockers are enabled and try again.":"Be sure to enable Web Analytics for your project and deploy again. See https://vercel.com/docs/analytics/quickstart for more information.";console.log(`[Vercel Web Analytics] Failed to load script from ${r}. ${c}`)},document.head.appendChild(o)}function wU({route:t,path:e}){var n;(n=window.va)==null||n.call(window,"pageview",{route:t,path:e})}function EU(){if(!(typeof process>"u"||typeof lh>"u"))return lh.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH}function MU(){if(!(typeof process>"u"||typeof lh>"u"))return lh.REACT_APP_VERCEL_OBSERVABILITY_CLIENT_CONFIG}function TU(t){return L.useEffect(()=>{var e;t.beforeSend&&((e=window.va)==null||e.call(window,"beforeSend",t.beforeSend))},[t.beforeSend]),L.useEffect(()=>{SU({framework:t.framework||"react",basePath:t.basePath??EU(),...t.route!==void 0&&{disableAutoTrack:!0},...t},t.configString??MU())},[]),L.useEffect(()=>{t.route&&t.path&&wU({route:t.route,path:t.path})},[t.route,t.path]),null}var ch={},AU=()=>{window.si||(window.si=function(...e){window.siq=window.siq||[],window.siq.push(e)})},CU="@vercel/speed-insights",PU="2.0.0";function RU(){return typeof window<"u"}function kU(){try{const t="production"}catch{}return"production"}function ST(){return kU()==="development"}function LU(t){return t.scriptSrc?uh(t.scriptSrc):ST()?"https://va.vercel-scripts.com/v1/speed-insights/script.debug.js":t.dsn?"https://va.vercel-scripts.com/v1/speed-insights/script.js":t.basePath?uh(`${t.basePath}/speed-insights/script.js`):"/_vercel/speed-insights/script.js"}function DU(t,e){var n;let i=t;if(e)try{i={...(n=JSON.parse(e))==null?void 0:n.speedInsights,...t}}catch{}const r={sdkn:CU+(i.framework?`/${i.framework}`:""),sdkv:PU};return i.sampleRate&&(r.sampleRate=i.sampleRate.toString()),i.route&&(r.route=i.route),ST()&&i.debug===!1&&(r.debug="false"),i.dsn&&(r.dsn=i.dsn),i.endpoint?r.endpoint=uh(i.endpoint):i.basePath&&(r.endpoint=uh(`${i.basePath}/speed-insights/vitals`)),{src:LU(i),beforeSend:i.beforeSend,dataset:r}}function uh(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")?t:`/${t}`}function NU(t={},e){var n;if(!RU()||t.route===null)return null;AU();const{beforeSend:i,src:r,dataset:s}=DU(t,e);if(document.head.querySelector(`script[src*="${r}"]`))return null;i&&((n=window.si)==null||n.call(window,"beforeSend",i));const o=document.createElement("script");o.src=r,o.defer=!0;for(const[c,u]of Object.entries(s))o.dataset[c]=u;return o.onerror=()=>{console.log(`[Vercel Speed Insights] Failed to load script from ${r}. Please check if any content blockers are enabled and try again.`)},document.head.appendChild(o),{setRoute:c=>{o.dataset.route=c??void 0}}}function IU(){if(!(typeof process>"u"||typeof ch>"u"))return ch.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH}function UU(){if(!(typeof process>"u"||typeof ch>"u"))return ch.REACT_APP_VERCEL_OBSERVABILITY_CLIENT_CONFIG}function FU(t){L.useEffect(()=>{var n;t.beforeSend&&((n=window.si)==null||n.call(window,"beforeSend",t.beforeSend))},[t.beforeSend]);const e=L.useRef(null);return L.useEffect(()=>{if(!e.current){const n=NU({framework:t.framework??"react",basePath:t.basePath??IU(),...t},t.configString??UU());n&&(e.current=n.setRoute)}},[t]),L.useEffect(()=>{e.current&&t.route&&e.current(t.route)},[t.route]),null}function Uh(){return typeof window<"u"}function py(t){return wT(t)?(t.nodeName||"").toLowerCase():"#document"}function Kl(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function OU(t){var e;return(e=(wT(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function wT(t){return Uh()?t instanceof Node||t instanceof Kl(t).Node:!1}function ET(t){return Uh()?t instanceof Element||t instanceof Kl(t).Element:!1}function my(t){return Uh()?t instanceof HTMLElement||t instanceof Kl(t).HTMLElement:!1}function HS(t){return!Uh()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Kl(t).ShadowRoot}function MT(t){const{overflow:e,overflowX:n,overflowY:i,display:r}=AT(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&r!=="inline"&&r!=="contents"}function bX(t){return/^(table|td|th)$/.test(py(t))}function BU(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const zU=/transform|translate|scale|rotate|perspective|filter/,VU=/paint|layout|strict|content/,Za=t=>!!t&&t!=="none";let Vm;function HU(t){const e=ET(t)?AT(t):t;return Za(e.transform)||Za(e.translate)||Za(e.scale)||Za(e.rotate)||Za(e.perspective)||!GU()&&(Za(e.backdropFilter)||Za(e.filter))||zU.test(e.willChange||"")||VU.test(e.contain||"")}function SX(t){let e=f0(t);for(;my(e)&&!TT(e);){if(HU(e))return e;if(BU(e))return null;e=f0(e)}return null}function GU(){return Vm==null&&(Vm=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Vm}function TT(t){return/^(html|body|#document)$/.test(py(t))}function AT(t){return Kl(t).getComputedStyle(t)}function wX(t){return ET(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function f0(t){if(py(t)==="html")return t;const e=t.assignedSlot||t.parentNode||HS(t)&&t.host||OU(t);return HS(e)?e.host:e}function CT(t){const e=f0(t);return TT(e)?t.ownerDocument?t.ownerDocument.body:t.body:my(e)&&MT(e)?e:CT(e)}function GS(t,e,n){var i;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=CT(t),s=r===((i=t.ownerDocument)==null?void 0:i.body),o=Kl(r);if(s){const c=jU(o);return e.concat(o,o.visualViewport||[],MT(r)?r:[],c&&n?GS(c):[])}else return e.concat(r,GS(r,[],n))}function jU(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}const jS={};function gy(t,e){const n=L.useRef(jS);return n.current===jS&&(n.current=t(e)),n}const Hm=BE[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],WU=Hm&&Hm!==L.useLayoutEffect?Hm:t=>t();function WS(t){const e=gy($U).current;return e.next=t,WU(e.effect),e.trampoline}function $U(){const t={next:void 0,callback:XU,trampoline:(...e)=>t.callback?.(...e),effect:()=>{t.callback=t.next}};return t}function XU(){}const qU=()=>{},YU=typeof document<"u"?L.useLayoutEffect:qU;function h0(t,e){if(t&&!e)return t;if(!t&&e)return e;if(t||e)return{...t,...e}}const su={};function PT(t,e,n,i,r){let s={...p0(t,su)};return e&&(s=Nf(s,e)),n&&(s=Nf(s,n)),i&&(s=Nf(s,i)),s}function KU(t){if(t.length===0)return su;if(t.length===1)return p0(t[0],su);let e={...p0(t[0],su)};for(let n=1;n<t.length;n+=1)e=Nf(e,t[n]);return e}function Nf(t,e){return RT(e)?e(t):ZU(t,e)}function ZU(t,e){if(!e)return t;for(const n in e){const i=e[n];switch(n){case"style":{t[n]=h0(t.style,i);break}case"className":{t[n]=kT(t.className,i);break}default:JU(n,i)?t[n]=QU(t[n],i):t[n]=i}}return t}function JU(t,e){const n=t.charCodeAt(0),i=t.charCodeAt(1),r=t.charCodeAt(2);return n===111&&i===110&&r>=65&&r<=90&&(typeof e=="function"||typeof e>"u")}function RT(t){return typeof t=="function"}function p0(t,e){return RT(t)?t(e):t??su}function QU(t,e){return e?t?n=>{if(eF(n)){const r=n;m0(r);const s=e(r);return r.baseUIHandlerPrevented||t?.(r),s}const i=e(n);return t?.(n),i}:e:t}function m0(t){return t.preventBaseUIHandler=()=>{t.baseUIHandlerPrevented=!0},t}function kT(t,e){return e?t?e+" "+t:e:t}function eF(t){return t!=null&&typeof t=="object"&&"nativeEvent"in t}function LT(t,...e){const n=new URL("https://base-ui.com/production-error");return n.searchParams.set("code",t.toString()),e.forEach(i=>n.searchParams.append("args[]",i)),`Base UI error #${t}; visit ${n} for the full message.`}const tF=L.createContext(void 0);function nF(t=!1){const e=L.useContext(tF);if(e===void 0&&!t)throw new Error(LT(16));return e}function iF(t){const{focusableWhenDisabled:e,disabled:n,composite:i=!1,tabIndex:r=0,isNativeButton:s}=t,o=i&&e!==!1,c=i&&e===!1;return{props:L.useMemo(()=>{const d={onKeyDown(h){n&&e&&h.key!=="Tab"&&h.preventDefault()}};return i||(d.tabIndex=r,!s&&n&&(d.tabIndex=e?r:-1)),(s&&(e||o)||!s&&n)&&(d["aria-disabled"]=n),s&&(!e||c)&&(d.disabled=n),d},[i,n,e,o,c,s,r])}}function rF(t={}){const{disabled:e=!1,focusableWhenDisabled:n,tabIndex:i=0,native:r=!0}=t,s=L.useRef(null),o=nF(!0)!==void 0,c=WS(()=>{const m=s.current;return!!(m?.tagName==="A"&&m?.href)}),{props:u}=iF({focusableWhenDisabled:n,disabled:e,composite:o,tabIndex:i,isNativeButton:r}),d=L.useCallback(()=>{const m=s.current;sF(m)&&o&&e&&u.disabled===void 0&&m.disabled&&(m.disabled=!1)},[e,u.disabled,o]);YU(d,[d]);const h=L.useCallback((m={})=>{const{onClick:v,onMouseDown:_,onKeyUp:w,onKeyDown:y,onPointerDown:b,...T}=m;return PT({type:r?"button":void 0,onClick(M){if(e){M.preventDefault();return}v?.(M)},onMouseDown(M){e||_?.(M)},onKeyDown(M){if(e||(m0(M),y?.(M)),M.baseUIHandlerPrevented)return;const I=M.target===M.currentTarget&&!r&&!c()&&!e,k=M.key==="Enter",U=M.key===" ";I&&((U||k)&&M.preventDefault(),k&&v?.(M))},onKeyUp(M){e||(m0(M),w?.(M)),!M.baseUIHandlerPrevented&&M.target===M.currentTarget&&!r&&!e&&M.key===" "&&v?.(M)},onPointerDown(M){if(e){M.preventDefault();return}b?.(M)}},r?void 0:{role:"button"},u,T)},[e,u,r,c]),p=WS(m=>{s.current=m,d()});return{getButtonProps:h,buttonRef:p}}function sF(t){return my(t)&&t.tagName==="BUTTON"}function $S(t,e,n,i){const r=gy(DT).current;return oF(r,t,e,n,i)&&NT(r,[t,e,n,i]),r.callback}function aF(t){const e=gy(DT).current;return lF(e,t)&&NT(e,t),e.callback}function DT(){return{callback:null,cleanup:null,refs:[]}}function oF(t,e,n,i,r){return t.refs[0]!==e||t.refs[1]!==n||t.refs[2]!==i||t.refs[3]!==r}function lF(t,e){return t.refs.length!==e.length||t.refs.some((n,i)=>n!==e[i])}function NT(t,e){if(t.refs=e,e.every(n=>n==null)){t.callback=null;return}t.callback=n=>{if(t.cleanup&&(t.cleanup(),t.cleanup=null),n!=null){const i=Array(e.length).fill(null);for(let r=0;r<e.length;r+=1){const s=e[r];if(s!=null)switch(typeof s){case"function":{const o=s(n);typeof o=="function"&&(i[r]=o);break}case"object":{s.current=n;break}}}t.cleanup=()=>{for(let r=0;r<e.length;r+=1){const s=e[r];if(s!=null)switch(typeof s){case"function":{const o=i[r];typeof o=="function"?o():s(null);break}case"object":{s.current=null;break}}}}}}}const cF=parseInt(L.version,10);function uF(t){return cF>=t}function XS(t){if(!L.isValidElement(t))return null;const e=t,n=e.props;return(uF(19)?n?.ref:e.ref)??null}function dF(t,e){const n={};for(const i in t){const r=t[i];if(e?.hasOwnProperty(i)){const s=e[i](r);s!=null&&Object.assign(n,s);continue}r===!0?n[`data-${i.toLowerCase()}`]="":r&&(n[`data-${i.toLowerCase()}`]=r.toString())}return n}function fF(t,e){return typeof t=="function"?t(e):t}function hF(t,e){return typeof t=="function"?t(e):t}function EX(){}const Ml=Object.freeze({});function pF(t,e,n={}){const i=e.render,r=mF(e,n);if(n.enabled===!1)return null;const s=n.state??Ml;return gF(t,i,r,s)}function mF(t,e={}){const{className:n,style:i,render:r}=t,{state:s=Ml,ref:o,props:c,stateAttributesMapping:u,enabled:d=!0}=e,h=d?fF(n,s):void 0,p=d?hF(i,s):void 0,m=d?dF(s,u):Ml,v=d?h0(m,Array.isArray(c)?KU(c):c)??Ml:Ml;return typeof document<"u"&&(d?Array.isArray(o)?v.ref=aF([v.ref,XS(r),...o]):v.ref=$S(v.ref,XS(r),o):$S(null,null)),d?(h!==void 0&&(v.className=kT(v.className,h)),p!==void 0&&(v.style=h0(v.style,p)),v):Ml}function gF(t,e,n,i){if(e){if(typeof e=="function")return e(n,i);const r=PT(n,e.props);return r.ref=n.ref,L.cloneElement(e,r)}if(t&&typeof t=="string")return vF(t,n);throw new Error(LT(8))}function vF(t,e){return t==="button"?L.createElement("button",{type:"button",...e,key:e.key}):t==="img"?L.createElement("img",{alt:"",...e,key:e.key}):L.createElement(t,e)}const yF=L.forwardRef(function(e,n){const{render:i,className:r,disabled:s=!1,focusableWhenDisabled:o=!1,nativeButton:c=!0,...u}=e,{getButtonProps:d,buttonRef:h}=rF({disabled:s,focusableWhenDisabled:o,native:c}),p=L.useMemo(()=>({disabled:s}),[s]);return pF("button",e,{state:p,ref:[n,h],props:[u,d]})}),_F=`key,module,page,component,slot,text,notes,status
42
+ `);r=c.pop()||"";for(const u of c)if(u.startsWith("data: ")){const d=u.slice(6).trim();if(d)try{const h=JSON.parse(d);if((h.chunk||h.content)&&(yield{id:`chatcmpl-${Date.now()}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:e,choices:[{index:0,delta:{content:h.chunk||h.content},finish_reason:null}]}),h.tool_calls?.length&&(yield{id:`chatcmpl-${Date.now()}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:e,choices:[{index:0,delta:{tool_calls:h.tool_calls},finish_reason:"tool_calls"}]}),h.done){n.releaseLock();return}}catch{console.warn("Failed to parse SSE data:",d)}}}}finally{n.releaseLock()}}},bI=class{constructor(t){this.http=t}async create(t){const e=await this.http.post("/api/ai/embeddings",t);return{object:e.object,data:e.data,model:e.metadata?.model,usage:e.metadata?.usage?{prompt_tokens:e.metadata.usage.promptTokens||0,total_tokens:e.metadata.usage.totalTokens||0}:{prompt_tokens:0,total_tokens:0}}}},SI=class{constructor(t){this.http=t}async generate(t){const e=await this.http.post("/api/ai/image/generation",t);let n=[];return e.images&&e.images.length>0?n=e.images.map(i=>({b64_json:i.imageUrl.replace(/^data:image\/\w+;base64,/,""),content:e.text})):e.text&&(n=[{content:e.text}]),{created:Math.floor(Date.now()/1e3),data:n,...e.metadata?.usage&&{usage:{total_tokens:e.metadata.usage.totalTokens||0,input_tokens:e.metadata.usage.promptTokens||0,output_tokens:e.metadata.usage.completionTokens||0}}}}},wI=class oT{constructor(e,n){this.http=e,this.functionsUrl=n||oT.deriveSubhostingUrl(e.baseUrl)}static deriveSubhostingUrl(e){try{const{hostname:n}=new URL(e);return n.endsWith(".insforge.app")?`https://${n.split(".")[0]}.functions.insforge.app`:void 0}catch{return}}async invoke(e,n={}){const{method:i="POST",body:r,headers:s={}}=n;if(this.functionsUrl)try{return{data:await this.http.request(i,`${this.functionsUrl}/${e}`,{body:r,headers:s}),error:null}}catch(o){if(o instanceof Error&&o.name==="AbortError")throw o;if(!(o instanceof jt&&o.statusCode===404))return{data:null,error:o instanceof jt?o:new jt(o instanceof Error?o.message:"Function invocation failed",500,"FUNCTION_ERROR")}}try{const o=`/functions/${e}`;return{data:await this.http.request(i,o,{body:r,headers:s}),error:null}}catch(o){if(o instanceof Error&&o.name==="AbortError")throw o;return{data:null,error:o instanceof jt?o:new jt(o instanceof Error?o.message:"Function invocation failed",500,"FUNCTION_ERROR")}}}},IS=1e4,EI=class{constructor(t,e,n){this.socket=null,this.connectPromise=null,this.subscribedChannels=new Set,this.eventListeners=new Map,this.baseUrl=t,this.tokenManager=e,this.anonKey=n,this.tokenManager.onTokenChange=()=>this.onTokenChange()}notifyListeners(t,e){const n=this.eventListeners.get(t);if(n)for(const i of n)try{i(e)}catch(r){console.error(`Error in ${t} callback:`,r)}}connect(){return this.socket?.connected?Promise.resolve():this.connectPromise?this.connectPromise:(this.connectPromise=new Promise((t,e)=>{const n=this.tokenManager.getAccessToken()??this.anonKey;this.socket=Df(this.baseUrl,{transports:["websocket"],auth:n?{token:n}:void 0});let i=!0,r=null;const s=()=>{r&&(clearTimeout(r),r=null)};r=setTimeout(()=>{i&&(i=!1,this.connectPromise=null,this.socket?.disconnect(),this.socket=null,e(new Error(`Connection timeout after ${IS}ms`)))},IS),this.socket.on("connect",()=>{s();for(const o of this.subscribedChannels)this.socket.emit("realtime:subscribe",{channel:o});this.notifyListeners("connect"),i&&(i=!1,this.connectPromise=null,t())}),this.socket.on("connect_error",o=>{s(),this.notifyListeners("connect_error",o),i&&(i=!1,this.connectPromise=null,e(o))}),this.socket.on("disconnect",o=>{this.notifyListeners("disconnect",o)}),this.socket.on("realtime:error",o=>{this.notifyListeners("error",o)}),this.socket.onAny((o,c)=>{o!=="realtime:error"&&this.notifyListeners(o,c)})}),this.connectPromise)}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null),this.subscribedChannels.clear()}onTokenChange(){const t=this.tokenManager.getAccessToken()??this.anonKey;this.socket&&(this.socket.auth=t?{token:t}:{}),this.socket&&(this.socket.connected||this.connectPromise)&&(this.socket.disconnect(),this.socket.connect())}get isConnected(){return this.socket?.connected??!1}get connectionState(){return this.socket?this.socket.connected?"connected":"connecting":"disconnected"}get socketId(){return this.socket?.id}async subscribe(t){if(this.subscribedChannels.has(t))return{ok:!0,channel:t};if(!this.socket?.connected)try{await this.connect()}catch(e){const n=e instanceof Error?e.message:"Connection failed";return{ok:!1,channel:t,error:{code:"CONNECTION_FAILED",message:n}}}return new Promise(e=>{this.socket.emit("realtime:subscribe",{channel:t},n=>{n.ok&&this.subscribedChannels.add(t),e(n)})})}unsubscribe(t){this.subscribedChannels.delete(t),this.socket?.connected&&this.socket.emit("realtime:unsubscribe",{channel:t})}async publish(t,e,n){if(!this.socket?.connected)throw new Error("Not connected to realtime server. Call connect() first.");this.socket.emit("realtime:publish",{channel:t,event:e,payload:n})}on(t,e){this.eventListeners.has(t)||this.eventListeners.set(t,new Set),this.eventListeners.get(t).add(e)}off(t,e){const n=this.eventListeners.get(t);n&&(n.delete(e),n.size===0&&this.eventListeners.delete(t))}once(t,e){const n=i=>{this.off(t,n),e(i)};this.on(t,n)}getSubscribedChannels(){return Array.from(this.subscribedChannels)}},MI=class{constructor(t){this.http=t}async send(t){try{return{data:await this.http.post("/api/email/send-raw",t),error:null}}catch(e){if(e instanceof Error&&e.name==="AbortError")throw e;return{data:null,error:e instanceof jt?e:new jt(e instanceof Error?e.message:"Email send failed",500,"EMAIL_ERROR")}}}},TI=class{constructor(t={}){const e=new tT(t.debug);this.tokenManager=new sT,this.http=new lI(t,this.tokenManager,e),t.edgeFunctionToken&&(this.http.setAuthToken(t.edgeFunctionToken),this.tokenManager.setAccessToken(t.edgeFunctionToken)),this.auth=new hI(this.http,this.tokenManager,{isServerMode:t.isServerMode??!1}),this.database=new mI(this.http,this.tokenManager),this.storage=new vI(this.http),this.ai=new yI(this.http),this.functions=new wI(this.http,t.functionsUrl),this.realtime=new EI(this.http.baseUrl,this.tokenManager,t.anonKey),this.emails=new MI(this.http)}getHttpClient(){return this.http}};function AI(t){return new TI(t)}const cy={VITE_INSFORGE_ANON_KEY:"ik_9f35735991b684f7cf57fa00bb4d0487",VITE_INSFORGE_BASE_URL:"https://srctyff5.us-east.insforge.app"};function Ro(){const t=typeof import.meta<"u"?cy:void 0;return(t?.VITE_INSFORGE_BASE_URL||t?.VITE_TOKENTRACKER_BACKEND_BASE_URL||"").trim()}function lT(){if(typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"))return window.location.origin;const e=typeof import.meta<"u"?cy:void 0;return(e?.VITE_INSFORGE_BASE_URL||e?.VITE_TOKENTRACKER_BACKEND_BASE_URL||"").trim()}function Nh(){const t=typeof import.meta<"u"?cy:void 0;return(t?.VITE_INSFORGE_ANON_KEY||t?.VITE_TOKENTRACKER_BACKEND_ANON_KEY||"").trim()}function u0(){return!!lT()}let Om=null;function CI(){return u0()?(Om||(Om=AI({baseUrl:lT(),anonKey:Nh()||void 0,autoRefreshToken:!0})),Om):null}const cT="tokentracker_cloud_sync_enabled",uy="tokentracker_cloud_device_session_v1",dy="tokentracker_cloud_last_sync_ts";function PI(){if(typeof window>"u")return!1;const t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"}function RI(){try{const t=localStorage.getItem(cT);return t===null||t===""?!1:t==="1"||t==="true"}catch{return!1}}function q$(t){try{localStorage.setItem(cT,t?"1":"0")}catch{}}function uT(){try{const t=localStorage.getItem(uy);if(!t)return null;const e=JSON.parse(t);if(typeof e?.token=="string"&&e.token&&typeof e.deviceId=="string")return e}catch{}return null}function dT(t){try{localStorage.setItem(uy,JSON.stringify(t))}catch{}}function kI(){try{localStorage.removeItem(uy),localStorage.removeItem(dy)}catch{}}function LI(){try{const t=Number(localStorage.getItem(dy));return Number.isFinite(t)?t:0}catch{return 0}}function fT(t){try{localStorage.setItem(dy,String(t))}catch{}}function Ta(t){if(typeof t!="string")return null;const e=t.trim();return e.length>0?e:null}function DI(t){const e=Ta(t);if(!e)return null;const n=e.split(".");if(n.length<2)return null;const i=n[1];try{const r=i.replace(/-/g,"+").replace(/_/g,"/").padEnd(i.length+(4-i.length%4)%4,"="),s=typeof atob=="function"?atob(r):Buffer.from(r,"base64").toString("utf8"),c=JSON.parse(s)?.exp;return typeof c!="number"||!Number.isFinite(c)||c<=0?null:Math.floor(c*1e3)}catch{return null}}function NI(t){const e=Ta(t);if(!e)return!1;const n=e.split(".");if(n.length!==3)return!1;try{for(let i=0;i<2;i++){const r=n[i];if(!/^[A-Za-z0-9_-]+$/.test(r))return!1;const s=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=typeof atob=="function"?atob(s):Buffer.from(s,"base64").toString("utf8");i===1&&JSON.parse(o)}return!0}catch{return!1}}function II(t,e=3e4){const n=DI(t);return n?n<=Date.now()+Math.max(0,Number(e)||0):!1}async function UI(t){if(!t)return null;if(typeof t=="string")return Ta(t);if(typeof t=="function")try{const e=await t();return Ta(e)}catch{return null}if(typeof t=="object"){if(typeof t.getAccessToken=="function"){try{const e=await t.getAccessToken(),n=Ta(e);if(n)return n}catch{}return Ta(t.accessToken)}return null}return Ta(t)}async function Y$(t,e={}){const n=Math.max(1,Math.min(12,Math.floor(Number(e.maxAttempts)||8))),i=Math.max(20,Math.floor(Number(e.baseDelayMs)||50));for(let r=0;r<n;r++){const s=await UI(t);if(s)return s;r<n-1&&await new Promise(o=>setTimeout(o,i*(r+1)))}return null}function K$(t){return typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1")||typeof t=="function"||t&&typeof t=="object"&&typeof t.getAccessToken=="function"?!0:!!Ta(t)}function Z$(){if(typeof Intl>"u"||!Intl.DateTimeFormat)return null;try{return Intl.DateTimeFormat().resolvedOptions().timeZone||null}catch{return null}}function J$(t=new Date){const e=t instanceof Date?t:new Date(t);if(!Number.isFinite(e.getTime()))return 0;const n=e.getTimezoneOffset();return Number.isFinite(n)?-n:0}function hT(t){if(!Number.isFinite(t)||t===0)return"UTC";const e=t>=0?"+":"-",n=Math.abs(t),i=String(Math.floor(n/60)).padStart(2,"0"),r=String(n%60).padStart(2,"0");return`UTC${e}${i}:${r}`}function Q$({timeZone:t,offsetMinutes:e}={}){const n=hT(e);return t&&t!=="UTC"?`${t} (${n})`:n}function eX({timeZone:t,offsetMinutes:e}={}){return Number.isFinite(e)?hT(e):t||"UTC"}function tX({timeZone:t,offsetMinutes:e,date:n=new Date}={}){const i=n instanceof Date?n:new Date(n);if(!Number.isFinite(i.getTime()))return"";if(t&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const o=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i).reduce((h,p)=>(p.type&&p.value&&(h[p.type]=p.value),h),{}),c=o.year,u=o.month,d=o.day;if(c&&u&&d)return`${c}-${u}-${d}`}catch{}if(typeof e=="number"&&Number.isFinite(e)){const r=new Date(i.getTime()+e*6e4);return OI(r)}return BI(i)}function FI({timeZone:t,offsetMinutes:e,date:n=new Date}={}){const i=n instanceof Date?n:new Date(n);if(!Number.isFinite(i.getTime()))return null;if(t&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const o=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i).reduce((h,p)=>(p.type&&p.value&&(h[p.type]=p.value),h),{}),c=Number(o.year),u=Number(o.month),d=Number(o.day);if(Number.isFinite(c)&&Number.isFinite(u)&&Number.isFinite(d))return{year:c,month:u,day:d}}catch{}if(typeof e=="number"&&Number.isFinite(e)){const r=new Date(i.getTime()+e*6e4);return{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate()}}return{year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()}}function nX({timeZone:t,offsetMinutes:e}={}){return t?`tz:${t}`:typeof e=="number"&&Number.isFinite(e)?`offset:${Math.trunc(e)}`:"utc"}function OI(t){const e=t.getUTCFullYear(),n=String(t.getUTCMonth()+1).padStart(2,"0"),i=String(t.getUTCDate()).padStart(2,"0");return`${e}-${n}-${i}`}function BI(t){const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${i}`}function kn(t){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())).toISOString().slice(0,10)}function ps(t){const e=t instanceof Date?t:new Date(t);if(!Number.isFinite(e.getTime()))return"";const n=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${n}-${i}-${r}`}function zI(t){if(!t)return null;const e=String(t).trim(),n=e.split("-");if(n.length!==3)return null;const i=Number(n[0]),r=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(s))return null;const o=new Date(Date.UTC(i,r,s));return Number.isFinite(o.getTime())&&kn(o)===e?o:null}function VI(t){if(!t)return"";const e=t.year,n=String(t.month).padStart(2,"0"),i=String(t.day).padStart(2,"0");return!e||!n||!i?"":`${e}-${n}-${i}`}function HI(t,{timeZone:e,offsetMinutes:n,now:i}={}){const r=i instanceof Date&&Number.isFinite(i.getTime())?i:new Date,s=FI({timeZone:e,offsetMinutes:n,date:r});if(!s){const u=ps(new Date);return{from:u,to:u}}const o=VI(s),c=zI(o);if(!c)return{from:o,to:o};if(t==="day")return{from:o,to:o};if(t==="week"){const u=new Date(c),h=(u.getUTCDay()+6)%7;u.setUTCDate(u.getUTCDate()-h);const p=new Date(u);return p.setUTCDate(p.getUTCDate()+6),{from:kn(u),to:kn(p)}}if(t==="month"){const u=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth(),1)),d=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth()+1,0));return{from:kn(u),to:kn(d)}}if(t==="total"){const u=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth()-23,1));return{from:kn(u),to:o}}return HI("week")}function iX(t){if(t==null)return"-";try{if(typeof t=="bigint")return new Intl.NumberFormat().format(t);if(typeof t=="number")return new Intl.NumberFormat().format(t);const e=String(t).trim();return/^[0-9]+$/.test(e)?new Intl.NumberFormat().format(BigInt(e)):e}catch{return String(t)}}function rX(t,{thousandSuffix:e="K",millionSuffix:n="M",billionSuffix:i="B",decimals:r=1}={}){const s=Number(String(t));if(!Number.isFinite(s))return"-";const o=s<0?"-":"",c=Math.abs(s),u=Math.max(0,Math.min(6,Math.floor(r)));if(c<1e3)return`${o}${String(c)}`;const d=(v,_)=>{const w=v.toFixed(u),y=Number(w).toString();return`${o}${y}${_}`},h=(v,_,w)=>{const y=v.toFixed(u),b=Number(y);return w&&b>=1e3?d(b/1e3,w):`${o}${b.toString()}${_}`};if(c>=1e9)return d(c/1e9,i);if(c>=1e6)return h(c/1e6,n,i);const p=c/1e3,m=Number(p.toFixed(u));return m>=1e3?d(m/1e3,n):d(m,e)}function pT(t){const e=Number(String(t));return Number.isFinite(e)?e:null}function sX(t,{decimals:e=2}={}){if(t==null)return"-";const n=String(t).trim();if(!n)return"-";const i=n.match(/^(-?\d+)(?:\.(\d+))?$/);if(!i)return n;const r=i[1],s=i[2]||"";let o=r;try{o=new Intl.NumberFormat().format(BigInt(r))}catch{o=r}const c=Math.max(0,Math.min(6,Math.floor(e))),u=c?s.slice(0,c).padEnd(c,"0"):"",d=r.startsWith("-")?"-":"",h=c?`${o.replace("-","")}.${u}`:o.replace("-","");return`${d}$${h}`}function oh(t){if(typeof t!="string")return null;const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.trim());if(!e)return null;const n=Number(e[1]),i=Number(e[2])-1,r=Number(e[3]),s=new Date(Date.UTC(n,i,r));return Number.isFinite(s.getTime())&&kn(s)===t.trim()?s:null}function fo(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()+e))}function GI(t,e){const n=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())-Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate());return Math.floor(n/864e5)}function Bm(t,e){if(!Array.isArray(t)||t.length===0)return 0;const n=t.length,i=(n-1)*e,r=Math.floor(i),s=i-r,o=t[r]??t[n-1],c=t[Math.min(n-1,r+1)]??t[n-1];return Math.round(o+(c-o)*s)}function jI(t){return t<=0?0:t>=4?4:t}function mT({weeks:t=52,now:e,weekStartsOn:n="sun"}={}){const i=e instanceof Date&&Number.isFinite(e.getTime())?e:new Date,r=ps(i),s=oh(r)||new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),o=n==="mon"?1:0,c=s.getUTCDay(),u=fo(s,-((c-o+7)%7)),d=fo(u,-7*(Math.max(1,t)-1));return{from:kn(d),to:r}}function WI({dailyRows:t,weeks:e=52,to:n,weekStartsOn:i="sun"}={}){const r=oh(n)||new Date(Date.UTC(new Date().getFullYear(),new Date().getMonth(),new Date().getDate())),{from:s}=mT({weeks:e,now:r,weekStartsOn:i}),o=oh(s)||fo(r,-(e*7-1)),c=(()=>{const M=(o.getUTCDay()-(i==="mon"?1:0)+7)%7;return fo(o,-M)})(),u=new Map;for(const T of Array.isArray(t)?t:[]){const A=typeof T?.day=="string"?T.day:null;if(!A)continue;const M=pT(T?.billable_total_tokens??T?.total_tokens)??0;u.set(A,Math.max(0,M))}const d=GI(c,r)+1,h=Math.ceil(d/7),p=[];for(let T=0;T<d;T++){const A=fo(c,T),M=kn(A),I=u.get(M)??0;I>0&&p.push(I)}p.sort((T,A)=>T-A);const m=Bm(p,.5),v=Bm(p,.75),_=Bm(p,.9);function w(T){return!T||T<=0?0:T<=m?1:T<=v?2:T<=_?3:4}const y=[];for(let T=0;T<h;T++){const A=[];for(let M=0;M<7;M++){const I=T*7+M,k=fo(c,I);if(k.getTime()>r.getTime()){A.push(null);continue}const U=kn(k),S=u.get(U)??0;A.push({day:U,value:S,level:jI(w(S))})}y.push(A)}const b=y.length>e?y.slice(y.length-e):y;return{from:s,to:kn(r),weeks:b,thresholds:{t1:m,t2:v,t3:_}}}function $I({dailyRows:t,to:e}={}){const n=oh(e)||new Date(Date.UTC(new Date().getFullYear(),new Date().getMonth(),new Date().getDate())),i=new Map;for(const s of Array.isArray(t)?t:[]){const o=typeof s?.day=="string"?s.day:null;if(!o)continue;const c=pT(s?.billable_total_tokens??s?.total_tokens)??0;i.set(o,Math.max(0,c))}let r=0;for(let s=0;s<370;s++){const o=kn(fo(n,-s));if((i.get(o)??0)>0){r+=1;continue}break}return r}const Ih={},gT="tokentracker",XI=["victorgpt/tokentracker","spacedriveapp/spacedrive","acme/alpha","acme/beta","neo/nebula","signal/flux","matrix/terminal","orbit/atlas","lumen/core","delta/horizon"],US=["NEO","TRINITY","MORPHEUS","ORACLE","CYPHER","SWITCH","APOC","TANK","SMITH","SERAPH","NIOBE","MOUSE","DOZER","LINK","BLADE"];function xr(){if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock")||"").toLowerCase();if(e==="0"||e==="false"||e==="off"||e==="no")return!1;if(e==="1"||e==="true"||e==="on"||e==="yes")return!0}if(typeof import.meta<"u"&&Ih){const t="".toLowerCase();if(t==="1"||t==="true")return!0}return!1}function qI(){if(typeof import.meta<"u"&&Ih){const t="".trim();if(t)return t;const e="".trim();if(e)return e}if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock_now")||"").trim();if(e)return e;const n=String(t.get("mock_today")||"").trim();if(n)return n}return""}function YI(t){if(!t)return null;const e=String(t).trim();if(!e)return null;if(/^\d{4}-\d{2}-\d{2}$/.test(e)){const[i,r,s]=e.split("-").map(Number);if(!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(s))return null;const o=new Date(i,r-1,s,12,0,0);return Number.isFinite(o.getTime())?o:null}const n=new Date(e);return Number.isFinite(n.getTime())?n:null}function aX(){return xr()?YI(qI()):null}function KI(){if(typeof import.meta<"u"&&Ih){const t="".trim();if(t)return t}if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock_seed")||"").trim();if(e)return e}return gT}function ZI(){if(typeof import.meta<"u"&&Ih){const t="".trim(),e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock_missing")||"").trim(),n=Number(e);if(Number.isFinite(n)&&n>0)return Math.floor(n)}return 0}function Pu(t){return(t==null?KI():String(t)).trim()||gT}function Ru(t){let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function ki(t){if(typeof t!="string")return null;const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.trim());if(!e)return null;const n=Number(e[1]),i=Number(e[2])-1,r=Number(e[3]),s=new Date(Date.UTC(n,i,r));return Number.isFinite(s.getTime())&&kn(s)===t.trim()?s:null}function mu(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()+e))}function vT(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+e,1))}function JI(t){return`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,"0")}`}function Vl({from:t,to:e,seed:n}){const i=ki(ps(new Date))||new Date,r=ki(t)||i,s=ki(e)||r,o=[],c=Pu(n),u=Math.floor((Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())-Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate()))/864e5)+1;for(let d=0;d<u;d+=1){const h=mu(r,d),p=kn(h),m=Ru(`${c}:${p}`),v=m%1e3/1e3,_=.6+.4*Math.sin(d/6*Math.PI*.5),w=h.getUTCDay()===0||h.getUTCDay()===6?.65:1,y=18e3+Math.round(12e3*v),b=Math.max(0,Math.round(y*_*w)),T=Math.round(b*.46),A=Math.round(b*.34),M=Math.round(b*.14),I=Math.max(0,b-T-A-M);o.push({day:p,total_tokens:b,billable_total_tokens:b,input_tokens:T,output_tokens:A,cached_input_tokens:M,reasoning_output_tokens:I,conversation_count:1+m%5})}return o}function QI({day:t,seed:e}){const n=ki(t)||ki(ps(new Date))||new Date,i=kn(n),r=Pu(e),s=Array.from({length:48},(c,u)=>{const d=Math.floor(u/2),h=u%2===0?0:30,m=Ru(`${r}:${i}:${d}:${h}`)%1e3/1e3,v=(d+h/60)/24,_=.4+.6*Math.sin(v*Math.PI*2),w=900+Math.round(700*m),y=Math.max(0,Math.round(w*_)),b=Math.round(y*.46),T=Math.round(y*.34),A=Math.round(y*.14),M=Math.max(0,y-b-T-A);return{hour:`${i}T${String(d).padStart(2,"0")}:${String(h).padStart(2,"0")}:00`,total_tokens:y,billable_total_tokens:y,input_tokens:b,output_tokens:T,cached_input_tokens:A,reasoning_output_tokens:M}}),o=Math.max(0,Math.min(48,ZI()));if(o>0){const c=Date.now(),u=s.map((p,m)=>{const v=Date.parse(p.hour);return Number.isFinite(v)&&v<=c?{index:m,ts:v}:null}).filter(Boolean),d=Math.max(0,u.length-o),h=u.slice(d);for(const p of h){const m=s[p.index];m&&(s[p.index]={...m,missing:!0})}}return s}function eU({months:t=24,to:e,seed:n}){const i=ki(e)||ki(ps(new Date))||new Date,r=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1)),s=Pu(n),o=[];for(let c=t-1;c>=0;c-=1){const u=vT(r,-c),d=JI(u),p=Ru(`${s}:${d}`)%1e3/1e3,m=.7+.3*Math.sin(o.length/6*Math.PI*.5),v=36e4+Math.round(2e5*p),_=Math.max(0,Math.round(v*m)),w=Math.round(_*.46),y=Math.round(_*.34),b=Math.round(_*.14),T=Math.max(0,_-w-y-b);o.push({month:d,total_tokens:_,billable_total_tokens:_,input_tokens:w,output_tokens:y,cached_input_tokens:b,reasoning_output_tokens:T})}return o}function fy(t){return t.reduce((e,n)=>(e.total_tokens+=Number(n.total_tokens||0),e.billable_total_tokens+=Number(n.billable_total_tokens||n.total_tokens||0),e.input_tokens+=Number(n.input_tokens||0),e.output_tokens+=Number(n.output_tokens||0),e.cached_input_tokens+=Number(n.cached_input_tokens||0),e.reasoning_output_tokens+=Number(n.reasoning_output_tokens||0),e.conversation_count+=Number(n.conversation_count||0),e),{total_tokens:0,billable_total_tokens:0,input_tokens:0,output_tokens:0,cached_input_tokens:0,reasoning_output_tokens:0,conversation_count:0})}function tU(t,e=1.75){const n=Number(t||0);return!Number.isFinite(n)||n<=0?"0.000000":(n*e/1e6).toFixed(6)}function FS(t,e){const n=Number.isFinite(e)?e:0;return{total_tokens:Math.max(0,Math.round(t.total_tokens*n)),billable_total_tokens:Math.max(0,Math.round((t.billable_total_tokens??t.total_tokens)*n)),input_tokens:Math.max(0,Math.round(t.input_tokens*n)),output_tokens:Math.max(0,Math.round(t.output_tokens*n)),cached_input_tokens:Math.max(0,Math.round(t.cached_input_tokens*n)),reasoning_output_tokens:Math.max(0,Math.round(t.reasoning_output_tokens*n))}}function d0(t){return{...t,total_cost_usd:tU(t.total_tokens)}}function nU({from:t,to:e,seed:n}={}){const i=Vl({from:t,to:e,seed:n});return{from:t,to:e,data:i}}function iU({day:t,seed:e}={}){const n=ki(t)||new Date,i=kn(n),r=QI({day:i,seed:e});return{day:i,data:r}}function rU({months:t=24,to:e,seed:n}={}){const i=ki(e)||ki(ps(new Date))||new Date,r=kn(i),s=eU({months:t,to:r,seed:n}),o=vT(new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1)),-(t-1));return{from:kn(o),to:r,months:t,data:s}}function sU({from:t,to:e,seed:n,rolling:i=!0}={}){const r=Vl({from:t,to:e,seed:n}),s=fy(r),o=d0(s),c=i?aU({to:e,seed:n}):null;return{from:t,to:e,days:r.length,totals:o,...c?{rolling:c}:{}}}function aU({to:t,seed:e}={}){const n=ki(t)||ki(ps(new Date))||new Date,i=kn(n),r=kn(mu(n,-6)),s=kn(mu(n,-29)),o=Vl({from:r,to:i,seed:e}),c=Vl({from:s,to:i,seed:e});return{last_7d:OS({rows:o,from:r,to:i}),last_30d:OS({rows:c,from:s,to:i})}}function OS({rows:t,from:e,to:n}={}){const i=fy(t||[]),r=(t||[]).filter(o=>Number(o.billable_total_tokens??o.total_tokens)>0).length,s=r>0?Math.floor(i.billable_total_tokens/r):0;return{from:e,to:n,totals:{billable_total_tokens:i.billable_total_tokens,conversation_count:i.conversation_count},active_days:r,avg_per_active_day:s}}function oU({seed:t,limit:e=3}={}){const n=Pu(t),i=XI.map((r,s)=>{const c=12e4+Ru(`${n}:${r}`)%9e5,u=s%4*4200,d=Math.max(0,c+u),h=Math.max(0,Math.round(d*.96));return{project_key:r,project_ref:`https://github.com/${r}`,total_tokens:String(d),billable_total_tokens:String(h)}}).sort((r,s)=>Number(s.billable_total_tokens)-Number(r.billable_total_tokens)).slice(0,Math.max(1,Math.min(10,Math.floor(Number(e)||3))));return{generated_at:new Date().toISOString(),entries:i}}function lU(t){const e=ki(ps(new Date))||new Date,n=String(t).trim().toLowerCase()||"week";if(n==="total")return{from:"1970-01-01",to:"9999-12-31"};if(n==="month"){const o=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)),c=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+1,0));return{from:kn(o),to:kn(c)}}const i=e.getUTCDay(),r=kn(mu(e,-i)),s=kn(mu(e,-i+6));return{from:r,to:s}}function yT({seed:t,period:e,metric:n,limit:i=20,offset:r=0}={}){const s=Pu(t),o=Math.max(1,Math.min(100,Math.floor(Number(i)||20))),c=Math.max(0,Math.min(1e4,Math.floor(Number(r)||0))),u=String(n||"all").trim().toLowerCase()||"all",d=String(e||"week").trim().toLowerCase()||"week",h=d==="month"||d==="total"||d==="week"?d:"week",{from:p,to:m}=lU(h),v=250,_=v>0?Math.ceil(v/o):0,w=Math.floor(c/o)+1,y=Array.from({length:v},(U,S)=>{const P=S+1,V=`00000000-0000-0000-0000-${String(P).padStart(12,"0")}`,O=US[P%US.length],J=18e4+Ru(`${s}:${O}:${P}`)%9e5,H=Math.max(0,J+P*1200),X=Math.floor(H*.28),K=Math.floor(H*.18),Q=Math.floor(H*.1),W=Math.floor(H*.1),q=Math.floor(H*.08),Z=Math.floor(H*.03),z=Math.floor(H*.02),ie=Math.floor(H*.04),we=Math.floor(H*.03),He=Math.max(0,H-X-K-Q-W-q-Z-z-ie-we),Se=P%7!==0;return{id:P,user_id:V,is_public:Se,is_me:!1,display_name:Se?O:"Anonymous",avatar_url:null,gpt_tokens:X,claude_tokens:K,gemini_tokens:Q,cursor_tokens:W,opencode_tokens:q,openclaw_tokens:He,hermes_tokens:Z,kiro_tokens:z,copilot_tokens:ie,kimi_tokens:we,other_tokens:0,total_tokens:H}}),b=Math.max(0,Math.min(v-1,Math.floor(v*.8)));y[b]&&(y[b].is_me=!0);const T=u==="gpt"||u==="codex"?"gpt_tokens":u==="claude"?"claude_tokens":u==="gemini"?"gemini_tokens":u==="cursor"?"cursor_tokens":u==="opencode"?"opencode_tokens":u==="openclaw"?"openclaw_tokens":u==="hermes"?"hermes_tokens":u==="kiro"?"kiro_tokens":u==="copilot"?"copilot_tokens":u==="kimi"?"kimi_tokens":"total_tokens",A=y.slice().sort((U,S)=>Number(S[T])-Number(U[T])||U.id-S.id).map((U,S)=>({user_id:U.is_public?U.user_id:null,rank:S+1,is_me:!!U.is_me,display_name:U.display_name,avatar_url:U.avatar_url,gpt_tokens:String(U.gpt_tokens),claude_tokens:String(U.claude_tokens),gemini_tokens:String(U.gemini_tokens),cursor_tokens:String(U.cursor_tokens),opencode_tokens:String(U.opencode_tokens),openclaw_tokens:String(U.openclaw_tokens),hermes_tokens:String(U.hermes_tokens??0),kiro_tokens:String(U.kiro_tokens??0),copilot_tokens:String(U.copilot_tokens??0),kimi_tokens:String(U.kimi_tokens??0),other_tokens:String(U.other_tokens??0),total_tokens:String(U.total_tokens),is_public:!!U.is_public})),M=A.find(U=>U?.is_me)||null,I=M?{rank:M.rank,gpt_tokens:M.gpt_tokens,claude_tokens:M.claude_tokens,gemini_tokens:M.gemini_tokens,cursor_tokens:M.cursor_tokens,opencode_tokens:M.opencode_tokens,openclaw_tokens:M.openclaw_tokens,hermes_tokens:M.hermes_tokens,kiro_tokens:M.kiro_tokens,copilot_tokens:M.copilot_tokens,kimi_tokens:M.kimi_tokens,other_tokens:M.other_tokens,total_tokens:M.total_tokens}:{rank:null,gpt_tokens:"0",claude_tokens:"0",gemini_tokens:"0",cursor_tokens:"0",opencode_tokens:"0",openclaw_tokens:"0",hermes_tokens:"0",kiro_tokens:"0",copilot_tokens:"0",kimi_tokens:"0",other_tokens:"0",total_tokens:"0"},k=A.slice(c,c+o);return{period:h,metric:u,from:p,to:m,generated_at:new Date().toISOString(),page:w,limit:o,offset:c,total_entries:v,total_pages:_,entries:k,me:I}}function cU({weeks:t=52,to:e,weekStartsOn:n="sun",seed:i}={}){const r=mT({weeks:t,now:ki(e)||ki(ps(new Date))||new Date,weekStartsOn:n}),s=Vl({from:r.from,to:r.to,seed:i});return{...WI({dailyRows:s,weeks:t,to:r.to,weekStartsOn:n}),week_starts_on:n,active_days:s.filter(c=>Number(c.billable_total_tokens??c.total_tokens)>0).length,streak_days:$I({dailyRows:s,to:r.to})}}function uU({from:t,to:e,seed:n}={}){const i=Vl({from:t,to:e,seed:n}),r=fy(i),o=[{source:"codex",weight:.7,models:[{model:"gpt-5.2-codex",model_id:"gpt-5.2-codex",weight:.2},{model:"unknown",model_id:"unknown",weight:.8}]},{source:"claude",weight:.2,models:[{model:"claude-3.5",model_id:"claude-3.5",weight:.3},{model:"unknown",model_id:"unknown",weight:.7}]},{source:"every-code",weight:.1,models:[{model:"unknown",model_id:"unknown",weight:1}]}].map(c=>{const u=FS(r,c.weight),d=c.models.map(h=>{const p=FS(u,h.weight);return{model:h.model,model_id:h.model_id||h.model,totals:d0(p)}});return{source:c.source,totals:d0(u),models:d}});return{from:t,to:e,days:i.length,sources:o,pricing:{model:"mock",pricing_mode:"add",source:"mock",effective_from:ps(new Date),rates_per_million_usd:{input:"1.750000",cached_input:"0.175000",output:"14.000000",reasoning_output:"14.000000"}}}}const ms={usageSummary:"tokentracker-usage-summary",usageDaily:"tokentracker-usage-daily",usageHourly:"tokentracker-usage-hourly",usageMonthly:"tokentracker-usage-monthly",usageHeatmap:"tokentracker-usage-heatmap",usageModelBreakdown:"tokentracker-usage-model-breakdown",projectUsageSummary:"tokentracker-project-usage-summary",userStatus:"tokentracker-user-status",localSync:"tokentracker-local-sync",usageLimits:"tokentracker-usage-limits"};async function $s(t,e,n){const i=new URL(`/functions/${t}`,window.location.origin);if(e)for(const[s,o]of Object.entries(e))o!=null&&o!==""&&i.searchParams.set(s,String(o));const r=await fetch(i.toString(),{headers:{Accept:"application/json"},cache:"no-store",...n});if(!r.ok){const s=new Error(`Request failed with HTTP ${r.status}`);throw s.status=r.status,s}return r.json()}function ko({timeZone:t,tzOffsetMinutes:e}={}){const n={},i=typeof t=="string"?t.trim():"";return i&&(n.tz=i),Number.isFinite(e)&&(n.tz_offset_minutes=String(Math.trunc(e))),n}function Lo({source:t,model:e}={}){const n={},i=typeof t=="string"?t.trim().toLowerCase():"";i&&(n.source=i);const r=typeof e=="string"?e.trim():"";return r&&(n.model=r),n}async function oX({from:t,to:e,source:n,model:i,timeZone:r,tzOffsetMinutes:s,rolling:o=!1,accessToken:c}={}){if(xr())return sU({from:t,to:e,seed:c,rolling:o});const u=ko({timeZone:r,tzOffsetMinutes:s}),d=Lo({source:n,model:i}),h=o?{rolling:"1"}:{};return $s(ms.usageSummary,{from:t,to:e,...d,...u,...h})}async function lX({from:t,to:e,source:n,limit:i,timeZone:r,tzOffsetMinutes:s,accessToken:o}={}){if(xr())return oU({seed:o,limit:i});const c=ko({timeZone:r,tzOffsetMinutes:s}),d={...Lo({source:n}),...c};return t&&(d.from=t),e&&(d.to=e),i!=null&&(d.limit=String(i)),$s(ms.projectUsageSummary,d)}async function ku(t,e={}){const n=Ro();if(!n)throw new Error("InsForge base URL not configured");const i=n.replace(/\/$/,""),r=new URL(`${i}/functions/${t}`);if(e.params)for(const[u,d]of Object.entries(e.params))d!=null&&d!==""&&r.searchParams.set(u,String(d));const s={Accept:"application/json","Content-Type":"application/json"},o=Nh();o&&(s.apikey=o),e.accessToken&&NI(e.accessToken)&&(s.Authorization=`Bearer ${e.accessToken}`);const c=await fetch(r.toString(),{method:e.method||"GET",headers:s,...e.body!=null?{body:JSON.stringify(e.body)}:{}});if(!c.ok){const u=new Error(`Request failed with HTTP ${c.status}`);throw u.status=c.status,u}return c.json()}async function cX({accessToken:t,userId:e,period:n,metric:i,limit:r,offset:s}={}){return xr()?yT({seed:t||e,period:n,metric:i,limit:r,offset:s}):ku("tokentracker-leaderboard",{params:{period:n,limit:r,offset:s,user_id:e}})}async function BS({accessToken:t}={}){return ku("tokentracker-public-visibility",{accessToken:t,method:"GET"})}async function uX({accessToken:t,enabled:e,anonymous:n,display_name:i,github_url:r,show_github_url:s}={}){const o={};return e!==void 0&&(o.enabled=!!e),n!==void 0&&(o.anonymous=!!n),i!==void 0&&(o.display_name=String(i)),r!==void 0&&(o.github_url=r===null?null:String(r)),s!==void 0&&(o.show_github_url=!!s),ku("tokentracker-public-visibility",{accessToken:t,method:"POST",body:o})}async function dX({accessToken:t,period:e}={}){return ku("tokentracker-leaderboard-refresh",{accessToken:t,method:"POST",body:e?{period:e}:{}})}async function fX({accessToken:t,userId:e,period:n}={}){if(xr()){const i=yT({seed:t,period:n,metric:"all",limit:250,offset:0}),s=(Array.isArray(i?.entries)?i.entries:[]).find(o=>o?.user_id===e)||null;return{period:i?.period??"week",from:i?.from??null,to:i?.to??null,generated_at:i?.generated_at??new Date().toISOString(),entry:s}}return ku("tokentracker-leaderboard-profile",{accessToken:t,params:{user_id:e,period:n}})}async function hX(t={}){if(xr()){const e=new Date().toISOString();return{user_id:"local-user",created_at:e,pro:{active:!1,sources:[],expires_at:null,partial:!1,as_of:e},subscriptions:{partial:!1,as_of:e,items:[]},install:{partial:!1,as_of:e,has_active_device_token:!1,has_active_device:!1,active_device_tokens:0,active_devices:0,latest_token_activity_at:null,latest_device_seen_at:null}}}return $s(ms.userStatus)}async function pX({signal:t}={}){const e=await fetch(`/functions/${ms.localSync}`,{method:"POST",headers:{Accept:"application/json"},cache:"no-store",signal:t}),n=await e.json().catch(()=>({ok:!1,error:`Local sync request failed with HTTP ${e.status}`}));if(!e.ok||n?.ok===!1){const i=n?.error||n?.message||`Local sync request failed with HTTP ${e.status}`,r=new Error(i);throw r.status=e.status,r}return n}async function mX({from:t,to:e,source:n,timeZone:i,tzOffsetMinutes:r,accessToken:s}={}){if(xr())return uU({from:t,to:e,seed:s});const o=ko({timeZone:i,tzOffsetMinutes:r}),c=Lo({source:n});return $s(ms.usageModelBreakdown,{from:t,to:e,...c,...o})}async function gX({from:t,to:e,source:n,model:i,timeZone:r,tzOffsetMinutes:s,accessToken:o}={}){if(xr())return nU({from:t,to:e,seed:o});const c=ko({timeZone:r,tzOffsetMinutes:s}),u=Lo({source:n,model:i});return $s(ms.usageDaily,{from:t,to:e,...u,...c})}async function vX({day:t,source:e,model:n,timeZone:i,tzOffsetMinutes:r,accessToken:s}={}){if(xr())return iU({day:t,seed:s});const o=ko({timeZone:i,tzOffsetMinutes:r}),c=Lo({source:e,model:n}),u=t?{day:t,...c,...o}:{...c,...o};return $s(ms.usageHourly,u)}async function yX({months:t,to:e,source:n,model:i,timeZone:r,tzOffsetMinutes:s,accessToken:o}={}){if(xr())return rU({months:t,to:e,seed:o});const c=ko({timeZone:r,tzOffsetMinutes:s}),u=Lo({source:n,model:i});return $s(ms.usageMonthly,{...t?{months:String(t)}:{},...e?{to:e}:{},...u,...c})}async function _X(t={}){const e=t?.refresh?{refresh:"1"}:void 0;return $s(ms.usageLimits,e)}async function xX({weeks:t,to:e,weekStartsOn:n,source:i,model:r,timeZone:s,tzOffsetMinutes:o,accessToken:c}={}){if(xr())return cU({weeks:t,to:e,weekStartsOn:n,seed:c});const u=ko({timeZone:s,tzOffsetMinutes:o}),d=Lo({source:i,model:r});return $s(ms.usageHeatmap,{weeks:String(t),to:e,week_starts_on:n,...d,...u})}const _T=L.createContext(null);function dU(t){if(!t||typeof t!="object")return"";const e=t.user_metadata&&typeof t.user_metadata=="object"?t.user_metadata:{},n=t.profile&&typeof t.profile=="object"?t.profile:{},i=e.full_name||e.name||n.name||e.user_name||e.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof t.email=="string"&&t.email.includes("@")?t.email.split("@")[0].trim()||t.email.trim():typeof t.email=="string"?t.email.trim():""}function zS(t){if(!t||typeof t!="object")return null;const e=t,n=e.session&&typeof e.session=="object"?e.session:null,i=typeof e.accessToken=="string"&&e.accessToken||typeof e.access_token=="string"&&e.access_token||n&&typeof n.accessToken=="string"&&n.accessToken||n&&typeof n.access_token=="string"&&n.access_token||null;return i&&i.length>0?i:null}async function zm(t,e={}){if(!t)return null;const n=Math.max(0,Math.floor(Number(e.skewMs)||6e4)),i=t.tokenManager,r=()=>i?.getAccessToken?.()??i?.getSession?.()?.accessToken??null;let s=r();if(!s||II(s,n)){const{data:o}=await t.auth.refreshSession();if(s=r()??zS(o)??null,!s&&typeof t.auth.getCurrentUser=="function")try{await t.auth.getCurrentUser(),s=r()??zS(o)??null}catch{}}return s||null}function fU({children:t}){const[e,n]=L.useState(null),[i,r]=L.useState(null),[s,o]=L.useState(!0);L.useEffect(()=>{if(!u0()){n(null),r(null),o(!1);return}n(CI())},[]),L.useEffect(()=>{if(!e)return;let k=!0;return o(!0),(async()=>{try{let{data:U,error:S}=await e.auth.getCurrentUser();if(!k)return;if(!S&&!U?.user){if(await new Promise(V=>setTimeout(V,150)),!k)return;const P=await e.auth.getCurrentUser();U=P.data,S=P.error}if(S){r(null);return}r(U?.user??null)}catch{k&&r(null)}finally{k&&o(!1)}})(),()=>{k=!1}},[e]);const c=L.useCallback(async()=>{if(e)try{let{data:k,error:U}=await e.auth.getCurrentUser();if(!U&&!k?.user){await new Promise(P=>setTimeout(P,150));const S=await e.auth.getCurrentUser();k=S.data,U=S.error}if(U){r(null);return}r(k?.user??null)}catch{r(null)}},[e]),u=L.useCallback(async(k,U)=>{if(!e)return{error:new Error("InsForge client not configured")};const S=typeof window<"u"&&window.webkit?.messageHandlers?.nativeOAuth;if(S){const O=typeof U=="string"&&U.trim()?U.trim():`${window.location.origin}/auth/callback`,G=await e.auth.signInWithOAuth({provider:k,redirectTo:O,skipBrowserRedirect:!0});if(G.data?.url){try{await fetch("/api/auth-bridge/verifier",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({native:!0})})}catch{}S.postMessage(G.data.url)}return G}const P=typeof U=="string"&&U.trim()?U.trim():typeof window<"u"?`${window.location.origin}/dashboard`:void 0;return await e.auth.signInWithOAuth({provider:k,redirectTo:P})},[e]),d=L.useCallback(async k=>{if(!e)return{data:null,error:new Error("InsForge client not configured")};const{data:U,error:S}=await e.auth.signInWithPassword(k);return U?.user&&r(U.user),{data:U,error:S}},[e]),h=L.useCallback(async k=>{if(!e)return{data:null,error:new Error("InsForge client not configured")};const{data:U,error:S}=await e.auth.signUp(k);return U?.user&&U?.accessToken&&r(U.user),{data:U,error:S}},[e]),p=L.useCallback(async()=>e?e.auth.getPublicAuthConfig():{data:null,error:new Error("InsForge client not configured")},[e]),m=L.useCallback(async()=>{e&&(await e.auth.signOut(),kI(),r(null))},[e]),v=L.useCallback(async()=>zm(e),[e]),[_,w]=L.useState(null),[y,b]=L.useState(!1),T=L.useMemo(()=>dU(i),[i]);L.useEffect(()=>{if(!i||!e){w(null),b(!1);return}let k=!0;return(async()=>{try{const U=await zm(e);if(!k||!U){k&&b(!0);return}const S=await BS({accessToken:U});k&&S?.display_name&&w(S.display_name)}catch{}k&&b(!0)})(),()=>{k=!1}},[i,e]);const A=y?_||T:"",M=L.useCallback(async()=>{if(e)try{const k=await zm(e);if(!k)return;const U=await BS({accessToken:k});U?.display_name&&w(U.display_name)}catch{}},[e]),I=L.useMemo(()=>!u0()||!e?{enabled:!1,client:null,user:null,signedIn:!1,loading:!1,displayName:"",refreshUser:async()=>{},refreshDisplayName:async()=>{},signInWithOAuth:async()=>({error:new Error("InsForge not configured")}),signInWithPassword:async()=>({data:null,error:new Error("InsForge not configured")}),signUp:async()=>({data:null,error:new Error("InsForge not configured")}),getPublicAuthConfig:async()=>({data:null,error:new Error("InsForge not configured")}),signOut:async()=>{},getAccessToken:async()=>null}:{enabled:!0,client:e,user:i,signedIn:!!i,loading:s,displayName:A,refreshUser:c,refreshDisplayName:M,signInWithOAuth:u,signInWithPassword:d,signUp:h,getPublicAuthConfig:p,signOut:m,getAccessToken:v},[e,i,s,A,c,M,u,d,h,p,m,v]);return F.jsx(_T.Provider,{value:I,children:t})}function Do(){return L.useContext(_T)}const hU="modulepreload",pU=function(t){return"/"+t},VS={},No=function(e,n,i){let r=Promise.resolve();if(n&&n.length>0){let u=function(d){return Promise.all(d.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),c=o?.nonce||o?.getAttribute("nonce");r=u(n.map(d=>{if(d=pU(d),d in VS)return;VS[d]=!0;const h=d.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":hU,h||(m.as="script"),m.crossOrigin="",m.href=d,c&&m.setAttribute("nonce",c),document.head.appendChild(m),h)return new Promise((v,_)=>{m.addEventListener("load",v),m.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${d}`)))})}))}function s(o){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=o,window.dispatchEvent(c),!c.defaultPrevented)throw o}return r.then(o=>{for(const c of o||[])c.status==="rejected"&&s(c.reason);return e().catch(s)})};var lh={},mU=()=>{window.va||(window.va=function(...e){window.vaq||(window.vaq=[]),window.vaq.push(e)})},gU="@vercel/analytics",vU="2.0.1";function xT(){return typeof window<"u"}function bT(){try{const t="production"}catch{}return"production"}function yU(t="auto"){if(t==="auto"){window.vam=bT();return}window.vam=t}function _U(){return(xT()?window.vam:bT())||"production"}function hy(){return _U()==="development"}function xU(t){return t.scriptSrc?Pl(t.scriptSrc):hy()?"https://va.vercel-scripts.com/v1/script.debug.js":t.basePath?Pl(`${t.basePath}/insights/script.js`):"/_vercel/insights/script.js"}function bU(t,e){var n;let i=t;if(e)try{i={...(n=JSON.parse(e))==null?void 0:n.analytics,...t}}catch{}yU(i.mode);const r={sdkn:gU+(i.framework?`/${i.framework}`:""),sdkv:vU};return i.disableAutoTrack&&(r.disableAutoTrack="1"),i.viewEndpoint&&(r.viewEndpoint=Pl(i.viewEndpoint)),i.eventEndpoint&&(r.eventEndpoint=Pl(i.eventEndpoint)),i.sessionEndpoint&&(r.sessionEndpoint=Pl(i.sessionEndpoint)),hy()&&i.debug===!1&&(r.debug="false"),i.dsn&&(r.dsn=i.dsn),i.endpoint?r.endpoint=i.endpoint:i.basePath&&(r.endpoint=Pl(`${i.basePath}/insights`)),{beforeSend:i.beforeSend,src:xU(i),dataset:r}}function Pl(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")?t:`/${t}`}function SU(t={debug:!0},e){var n;if(!xT())return;const{beforeSend:i,src:r,dataset:s}=bU(t,e);if(mU(),i&&((n=window.va)==null||n.call(window,"beforeSend",i)),document.head.querySelector(`script[src*="${r}"]`))return;const o=document.createElement("script");o.src=r;for(const[c,u]of Object.entries(s))o.dataset[c]=u;o.defer=!0,o.onerror=()=>{const c=hy()?"Please check if any ad blockers are enabled and try again.":"Be sure to enable Web Analytics for your project and deploy again. See https://vercel.com/docs/analytics/quickstart for more information.";console.log(`[Vercel Web Analytics] Failed to load script from ${r}. ${c}`)},document.head.appendChild(o)}function wU({route:t,path:e}){var n;(n=window.va)==null||n.call(window,"pageview",{route:t,path:e})}function EU(){if(!(typeof process>"u"||typeof lh>"u"))return lh.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH}function MU(){if(!(typeof process>"u"||typeof lh>"u"))return lh.REACT_APP_VERCEL_OBSERVABILITY_CLIENT_CONFIG}function TU(t){return L.useEffect(()=>{var e;t.beforeSend&&((e=window.va)==null||e.call(window,"beforeSend",t.beforeSend))},[t.beforeSend]),L.useEffect(()=>{SU({framework:t.framework||"react",basePath:t.basePath??EU(),...t.route!==void 0&&{disableAutoTrack:!0},...t},t.configString??MU())},[]),L.useEffect(()=>{t.route&&t.path&&wU({route:t.route,path:t.path})},[t.route,t.path]),null}var ch={},AU=()=>{window.si||(window.si=function(...e){window.siq=window.siq||[],window.siq.push(e)})},CU="@vercel/speed-insights",PU="2.0.0";function RU(){return typeof window<"u"}function kU(){try{const t="production"}catch{}return"production"}function ST(){return kU()==="development"}function LU(t){return t.scriptSrc?uh(t.scriptSrc):ST()?"https://va.vercel-scripts.com/v1/speed-insights/script.debug.js":t.dsn?"https://va.vercel-scripts.com/v1/speed-insights/script.js":t.basePath?uh(`${t.basePath}/speed-insights/script.js`):"/_vercel/speed-insights/script.js"}function DU(t,e){var n;let i=t;if(e)try{i={...(n=JSON.parse(e))==null?void 0:n.speedInsights,...t}}catch{}const r={sdkn:CU+(i.framework?`/${i.framework}`:""),sdkv:PU};return i.sampleRate&&(r.sampleRate=i.sampleRate.toString()),i.route&&(r.route=i.route),ST()&&i.debug===!1&&(r.debug="false"),i.dsn&&(r.dsn=i.dsn),i.endpoint?r.endpoint=uh(i.endpoint):i.basePath&&(r.endpoint=uh(`${i.basePath}/speed-insights/vitals`)),{src:LU(i),beforeSend:i.beforeSend,dataset:r}}function uh(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")?t:`/${t}`}function NU(t={},e){var n;if(!RU()||t.route===null)return null;AU();const{beforeSend:i,src:r,dataset:s}=DU(t,e);if(document.head.querySelector(`script[src*="${r}"]`))return null;i&&((n=window.si)==null||n.call(window,"beforeSend",i));const o=document.createElement("script");o.src=r,o.defer=!0;for(const[c,u]of Object.entries(s))o.dataset[c]=u;return o.onerror=()=>{console.log(`[Vercel Speed Insights] Failed to load script from ${r}. Please check if any content blockers are enabled and try again.`)},document.head.appendChild(o),{setRoute:c=>{o.dataset.route=c??void 0}}}function IU(){if(!(typeof process>"u"||typeof ch>"u"))return ch.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH}function UU(){if(!(typeof process>"u"||typeof ch>"u"))return ch.REACT_APP_VERCEL_OBSERVABILITY_CLIENT_CONFIG}function FU(t){L.useEffect(()=>{var n;t.beforeSend&&((n=window.si)==null||n.call(window,"beforeSend",t.beforeSend))},[t.beforeSend]);const e=L.useRef(null);return L.useEffect(()=>{if(!e.current){const n=NU({framework:t.framework??"react",basePath:t.basePath??IU(),...t},t.configString??UU());n&&(e.current=n.setRoute)}},[t]),L.useEffect(()=>{e.current&&t.route&&e.current(t.route)},[t.route]),null}function Uh(){return typeof window<"u"}function py(t){return wT(t)?(t.nodeName||"").toLowerCase():"#document"}function Kl(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function OU(t){var e;return(e=(wT(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function wT(t){return Uh()?t instanceof Node||t instanceof Kl(t).Node:!1}function ET(t){return Uh()?t instanceof Element||t instanceof Kl(t).Element:!1}function my(t){return Uh()?t instanceof HTMLElement||t instanceof Kl(t).HTMLElement:!1}function HS(t){return!Uh()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Kl(t).ShadowRoot}function MT(t){const{overflow:e,overflowX:n,overflowY:i,display:r}=AT(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&r!=="inline"&&r!=="contents"}function bX(t){return/^(table|td|th)$/.test(py(t))}function BU(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const zU=/transform|translate|scale|rotate|perspective|filter/,VU=/paint|layout|strict|content/,Za=t=>!!t&&t!=="none";let Vm;function HU(t){const e=ET(t)?AT(t):t;return Za(e.transform)||Za(e.translate)||Za(e.scale)||Za(e.rotate)||Za(e.perspective)||!GU()&&(Za(e.backdropFilter)||Za(e.filter))||zU.test(e.willChange||"")||VU.test(e.contain||"")}function SX(t){let e=f0(t);for(;my(e)&&!TT(e);){if(HU(e))return e;if(BU(e))return null;e=f0(e)}return null}function GU(){return Vm==null&&(Vm=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Vm}function TT(t){return/^(html|body|#document)$/.test(py(t))}function AT(t){return Kl(t).getComputedStyle(t)}function wX(t){return ET(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function f0(t){if(py(t)==="html")return t;const e=t.assignedSlot||t.parentNode||HS(t)&&t.host||OU(t);return HS(e)?e.host:e}function CT(t){const e=f0(t);return TT(e)?t.ownerDocument?t.ownerDocument.body:t.body:my(e)&&MT(e)?e:CT(e)}function GS(t,e,n){var i;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=CT(t),s=r===((i=t.ownerDocument)==null?void 0:i.body),o=Kl(r);if(s){const c=jU(o);return e.concat(o,o.visualViewport||[],MT(r)?r:[],c&&n?GS(c):[])}else return e.concat(r,GS(r,[],n))}function jU(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}const jS={};function gy(t,e){const n=L.useRef(jS);return n.current===jS&&(n.current=t(e)),n}const Hm=BE[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],WU=Hm&&Hm!==L.useLayoutEffect?Hm:t=>t();function WS(t){const e=gy($U).current;return e.next=t,WU(e.effect),e.trampoline}function $U(){const t={next:void 0,callback:XU,trampoline:(...e)=>t.callback?.(...e),effect:()=>{t.callback=t.next}};return t}function XU(){}const qU=()=>{},YU=typeof document<"u"?L.useLayoutEffect:qU;function h0(t,e){if(t&&!e)return t;if(!t&&e)return e;if(t||e)return{...t,...e}}const su={};function PT(t,e,n,i,r){let s={...p0(t,su)};return e&&(s=Nf(s,e)),n&&(s=Nf(s,n)),i&&(s=Nf(s,i)),s}function KU(t){if(t.length===0)return su;if(t.length===1)return p0(t[0],su);let e={...p0(t[0],su)};for(let n=1;n<t.length;n+=1)e=Nf(e,t[n]);return e}function Nf(t,e){return RT(e)?e(t):ZU(t,e)}function ZU(t,e){if(!e)return t;for(const n in e){const i=e[n];switch(n){case"style":{t[n]=h0(t.style,i);break}case"className":{t[n]=kT(t.className,i);break}default:JU(n,i)?t[n]=QU(t[n],i):t[n]=i}}return t}function JU(t,e){const n=t.charCodeAt(0),i=t.charCodeAt(1),r=t.charCodeAt(2);return n===111&&i===110&&r>=65&&r<=90&&(typeof e=="function"||typeof e>"u")}function RT(t){return typeof t=="function"}function p0(t,e){return RT(t)?t(e):t??su}function QU(t,e){return e?t?n=>{if(eF(n)){const r=n;m0(r);const s=e(r);return r.baseUIHandlerPrevented||t?.(r),s}const i=e(n);return t?.(n),i}:e:t}function m0(t){return t.preventBaseUIHandler=()=>{t.baseUIHandlerPrevented=!0},t}function kT(t,e){return e?t?e+" "+t:e:t}function eF(t){return t!=null&&typeof t=="object"&&"nativeEvent"in t}function LT(t,...e){const n=new URL("https://base-ui.com/production-error");return n.searchParams.set("code",t.toString()),e.forEach(i=>n.searchParams.append("args[]",i)),`Base UI error #${t}; visit ${n} for the full message.`}const tF=L.createContext(void 0);function nF(t=!1){const e=L.useContext(tF);if(e===void 0&&!t)throw new Error(LT(16));return e}function iF(t){const{focusableWhenDisabled:e,disabled:n,composite:i=!1,tabIndex:r=0,isNativeButton:s}=t,o=i&&e!==!1,c=i&&e===!1;return{props:L.useMemo(()=>{const d={onKeyDown(h){n&&e&&h.key!=="Tab"&&h.preventDefault()}};return i||(d.tabIndex=r,!s&&n&&(d.tabIndex=e?r:-1)),(s&&(e||o)||!s&&n)&&(d["aria-disabled"]=n),s&&(!e||c)&&(d.disabled=n),d},[i,n,e,o,c,s,r])}}function rF(t={}){const{disabled:e=!1,focusableWhenDisabled:n,tabIndex:i=0,native:r=!0}=t,s=L.useRef(null),o=nF(!0)!==void 0,c=WS(()=>{const m=s.current;return!!(m?.tagName==="A"&&m?.href)}),{props:u}=iF({focusableWhenDisabled:n,disabled:e,composite:o,tabIndex:i,isNativeButton:r}),d=L.useCallback(()=>{const m=s.current;sF(m)&&o&&e&&u.disabled===void 0&&m.disabled&&(m.disabled=!1)},[e,u.disabled,o]);YU(d,[d]);const h=L.useCallback((m={})=>{const{onClick:v,onMouseDown:_,onKeyUp:w,onKeyDown:y,onPointerDown:b,...T}=m;return PT({type:r?"button":void 0,onClick(M){if(e){M.preventDefault();return}v?.(M)},onMouseDown(M){e||_?.(M)},onKeyDown(M){if(e||(m0(M),y?.(M)),M.baseUIHandlerPrevented)return;const I=M.target===M.currentTarget&&!r&&!c()&&!e,k=M.key==="Enter",U=M.key===" ";I&&((U||k)&&M.preventDefault(),k&&v?.(M))},onKeyUp(M){e||(m0(M),w?.(M)),!M.baseUIHandlerPrevented&&M.target===M.currentTarget&&!r&&!e&&M.key===" "&&v?.(M)},onPointerDown(M){if(e){M.preventDefault();return}b?.(M)}},r?void 0:{role:"button"},u,T)},[e,u,r,c]),p=WS(m=>{s.current=m,d()});return{getButtonProps:h,buttonRef:p}}function sF(t){return my(t)&&t.tagName==="BUTTON"}function $S(t,e,n,i){const r=gy(DT).current;return oF(r,t,e,n,i)&&NT(r,[t,e,n,i]),r.callback}function aF(t){const e=gy(DT).current;return lF(e,t)&&NT(e,t),e.callback}function DT(){return{callback:null,cleanup:null,refs:[]}}function oF(t,e,n,i,r){return t.refs[0]!==e||t.refs[1]!==n||t.refs[2]!==i||t.refs[3]!==r}function lF(t,e){return t.refs.length!==e.length||t.refs.some((n,i)=>n!==e[i])}function NT(t,e){if(t.refs=e,e.every(n=>n==null)){t.callback=null;return}t.callback=n=>{if(t.cleanup&&(t.cleanup(),t.cleanup=null),n!=null){const i=Array(e.length).fill(null);for(let r=0;r<e.length;r+=1){const s=e[r];if(s!=null)switch(typeof s){case"function":{const o=s(n);typeof o=="function"&&(i[r]=o);break}case"object":{s.current=n;break}}}t.cleanup=()=>{for(let r=0;r<e.length;r+=1){const s=e[r];if(s!=null)switch(typeof s){case"function":{const o=i[r];typeof o=="function"?o():s(null);break}case"object":{s.current=null;break}}}}}}}const cF=parseInt(L.version,10);function uF(t){return cF>=t}function XS(t){if(!L.isValidElement(t))return null;const e=t,n=e.props;return(uF(19)?n?.ref:e.ref)??null}function dF(t,e){const n={};for(const i in t){const r=t[i];if(e?.hasOwnProperty(i)){const s=e[i](r);s!=null&&Object.assign(n,s);continue}r===!0?n[`data-${i.toLowerCase()}`]="":r&&(n[`data-${i.toLowerCase()}`]=r.toString())}return n}function fF(t,e){return typeof t=="function"?t(e):t}function hF(t,e){return typeof t=="function"?t(e):t}function EX(){}const Ml=Object.freeze({});function pF(t,e,n={}){const i=e.render,r=mF(e,n);if(n.enabled===!1)return null;const s=n.state??Ml;return gF(t,i,r,s)}function mF(t,e={}){const{className:n,style:i,render:r}=t,{state:s=Ml,ref:o,props:c,stateAttributesMapping:u,enabled:d=!0}=e,h=d?fF(n,s):void 0,p=d?hF(i,s):void 0,m=d?dF(s,u):Ml,v=d?h0(m,Array.isArray(c)?KU(c):c)??Ml:Ml;return typeof document<"u"&&(d?Array.isArray(o)?v.ref=aF([v.ref,XS(r),...o]):v.ref=$S(v.ref,XS(r),o):$S(null,null)),d?(h!==void 0&&(v.className=kT(v.className,h)),p!==void 0&&(v.style=h0(v.style,p)),v):Ml}function gF(t,e,n,i){if(e){if(typeof e=="function")return e(n,i);const r=PT(n,e.props);return r.ref=n.ref,L.cloneElement(e,r)}if(t&&typeof t=="string")return vF(t,n);throw new Error(LT(8))}function vF(t,e){return t==="button"?L.createElement("button",{type:"button",...e,key:e.key}):t==="img"?L.createElement("img",{alt:"",...e,key:e.key}):L.createElement(t,e)}const yF=L.forwardRef(function(e,n){const{render:i,className:r,disabled:s=!1,focusableWhenDisabled:o=!1,nativeButton:c=!0,...u}=e,{getButtonProps:d,buttonRef:h}=rF({disabled:s,focusableWhenDisabled:o,native:c}),p=L.useMemo(()=>({disabled:s}),[s]);return pF("button",e,{state:p,ref:[n,h],props:[u,d]})}),_F=`key,module,page,component,slot,text,notes,status
43
43
  header.auth.sign_in_aria,shared,*,InsforgeUserHeaderControls,sign_in_aria,"Sign in",,active
44
44
  header.auth.user_fallback,shared,*,InsforgeUserHeaderControls,user_fallback,"User",,active
45
45
  header.cloud_sync.label,shared,*,InsforgeUserHeaderControls,cloud_sync_label,"Sync local usage to cloud",,active
@@ -564,6 +564,15 @@ settings.account.publicProfile,ui,SettingsPage,SettingsPage,public_profile,"Publ
564
564
  settings.account.publicProfileHint,ui,SettingsPage,SettingsPage,public_profile_hint,"Show your usage on the public leaderboard.",,active
565
565
  settings.account.anonymous,ui,SettingsPage,SettingsPage,anonymous,"Anonymous",,active
566
566
  settings.account.anonymousHint,ui,SettingsPage,SettingsPage,anonymous_hint,"Hide your name and avatar from the leaderboard.",,active
567
+ settings.account.displayNameAnonymousHint,ui,SettingsPage,SettingsPage,display_name_anon_hint,"Anonymous — your name and avatar are hidden on the leaderboard",,active
568
+ settings.account.displayNameDisabledWhileAnon,ui,SettingsPage,SettingsPage,display_name_disabled,"Turn on the switch first to edit your name",,active
569
+ settings.account.githubUrl,ui,SettingsPage,SettingsPage,github_url,"GitHub profile",,active
570
+ settings.account.githubUrlHint,ui,SettingsPage,SettingsPage,github_url_hint,"Show a GitHub link next to your name on the leaderboard.",,active
571
+ settings.account.githubUrlPlaceholder,ui,SettingsPage,SettingsPage,github_url_placeholder,"username or https://github.com/username",,active
572
+ settings.account.githubUrlInvalid,ui,SettingsPage,SettingsPage,github_url_invalid,"Use a GitHub username or https://github.com/username URL.",,active
573
+ leaderboard.github.aria,ui,LeaderboardPage,LeaderboardPage,github_aria,"Open GitHub profile",,active
574
+ leaderboard.github.tooltipPrefix,ui,LeaderboardPage,LeaderboardPage,github_tooltip_prefix,"Add yours in",,active
575
+ leaderboard.github.tooltipSettingsLink,ui,LeaderboardPage,LeaderboardPage,github_tooltip_link,"Settings",,active
567
576
  settings.account.signOut,ui,SettingsPage,SettingsPage,sign_out,"Sign out",,active
568
577
  settings.account.signIn,ui,SettingsPage,SettingsPage,sign_in,"Sign in",,active
569
578
  settings.account.signedOutHint,ui,SettingsPage,SettingsPage,signed_out_hint,"Sign in to manage cloud sync and leaderboard preferences.",,active
@@ -4963,4 +4972,4 @@ void main() {
4963
4972
  vec4 color;
4964
4973
  mainImage(color, gl_FragCoord.xy);
4965
4974
  gl_FragColor = color;
4966
- }`;function n$({raysOrigin:t="top-center",raysColor:e="#ffffff",raysSpeed:n=1,lightSpread:i=1,rayLength:r=2,pulsating:s=!1,fadeDistance:o=1,saturation:c=1,followMouse:u=!0,mouseInfluence:d=.1,noiseAmount:h=0,distortion:p=0,className:m=""}){const v=L.useRef(null),_=L.useRef(null),w=L.useRef(null),y=L.useRef({x:.5,y:.5}),b=L.useRef({x:.5,y:.5}),T=L.useRef(null),A=L.useRef(null),M=L.useRef(null),[I,k]=L.useState(!1),U=L.useRef(null);return L.useEffect(()=>{if(v.current)return U.current=new IntersectionObserver(S=>{k(S[0].isIntersecting)},{threshold:.1}),U.current.observe(v.current),()=>{U.current&&(U.current.disconnect(),U.current=null)}},[]),L.useEffect(()=>!I||!v.current?void 0:(M.current&&(M.current(),M.current=null),(async()=>{if(!v.current||(await new Promise(Q=>setTimeout(Q,10)),!v.current))return;const P=new e7({dpr:Math.min(window.devicePixelRatio,2),alpha:!0});w.current=P;const V=P.gl;for(V.canvas.style.width="100%",V.canvas.style.height="100%";v.current.firstChild;)v.current.removeChild(v.current.firstChild);v.current.appendChild(V.canvas);const O={iTime:{value:0},iResolution:{value:[1,1]},rayPos:{value:[0,0]},rayDir:{value:[0,1]},raysColor:{value:LE(e)},raysSpeed:{value:n},lightSpread:{value:i},rayLength:{value:r},pulsating:{value:s?1:0},fadeDistance:{value:o},saturation:{value:c},mousePos:{value:[.5,.5]},mouseInfluence:{value:d},noiseAmount:{value:h},distortion:{value:p}};_.current=O;const G=new Q7(V),J=new YW(V,{vertex:e$,fragment:t$,uniforms:O}),H=new J7(V,{geometry:G,program:J});A.current=H;const X=()=>{if(!v.current||!P)return;P.dpr=Math.min(window.devicePixelRatio,2);const{clientWidth:Q,clientHeight:W}=v.current;P.setSize(Q,W);const q=P.dpr,Z=Q*q,z=W*q;O.iResolution.value=[Z,z];const{anchor:ie,dir:we}=DE(t,Z,z);O.rayPos.value=ie,O.rayDir.value=we},K=Q=>{if(!(!w.current||!_.current||!A.current)){O.iTime.value=Q*.001,u&&d>0&&(b.current.x=b.current.x*.92+y.current.x*(1-.92),b.current.y=b.current.y*.92+y.current.y*(1-.92),O.mousePos.value=[b.current.x,b.current.y]);try{P.render({scene:H}),T.current=requestAnimationFrame(K)}catch(W){console.warn("WebGL rendering error:",W)}}};window.addEventListener("resize",X),X(),T.current=requestAnimationFrame(K),M.current=()=>{if(T.current&&(cancelAnimationFrame(T.current),T.current=null),window.removeEventListener("resize",X),P)try{const Q=P.gl.getExtension("WEBGL_lose_context");Q&&Q.loseContext();const W=P.gl.canvas;W&&W.parentNode&&W.parentNode.removeChild(W)}catch(Q){console.warn("Error during WebGL cleanup:",Q)}w.current=null,_.current=null,A.current=null}})(),()=>{M.current&&(M.current(),M.current=null)}),[I,t,e,n,i,r,s,o,c,u,d,h,p]),L.useEffect(()=>{if(!_.current||!v.current||!w.current)return;const S=_.current,P=w.current;S.raysColor.value=LE(e),S.raysSpeed.value=n,S.lightSpread.value=i,S.rayLength.value=r,S.pulsating.value=s?1:0,S.fadeDistance.value=o,S.saturation.value=c,S.mouseInfluence.value=d,S.noiseAmount.value=h,S.distortion.value=p;const{clientWidth:V,clientHeight:O}=v.current,G=P.dpr,{anchor:J,dir:H}=DE(t,V*G,O*G);S.rayPos.value=J,S.rayDir.value=H},[e,n,i,t,r,s,o,c,d,h,p]),L.useEffect(()=>{if(!u)return;const S=P=>{if(!v.current)return;const V=v.current.getBoundingClientRect();y.current={x:(P.clientX-V.left)/V.width,y:(P.clientY-V.top)/V.height}};return window.addEventListener("mousemove",S),()=>window.removeEventListener("mousemove",S)},[u]),F.jsx("div",{ref:v,className:`w-full h-full pointer-events-none z-[3] overflow-hidden relative ${m}`.trim()})}function i$({className:t}){return F.jsx("svg",{viewBox:"0 0 384 512",className:t,fill:"currentColor",children:F.jsx("path",{d:"M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"})})}function r$({className:t}){return F.jsx("svg",{viewBox:"0 0 16 16",className:t,fill:"currentColor",children:F.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"})})}function s$({className:t}){return F.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[F.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),F.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function a$({className:t}){return F.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:F.jsx("polyline",{points:"20 6 9 17 4 12"})})}const NE="https://github.com/mm7894215/TokenTracker",o$="https://github.com/mm7894215/TokenTracker/releases/latest";function l$(t="default",e="md",n){const i="inline-flex items-center justify-center rounded font-medium transition-colors duration-200 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-oai-gray-950",r={default:"bg-oai-gray-900 text-white hover:bg-oai-gray-800 active:bg-oai-gray-950 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 dark:active:bg-oai-gray-200",ghost:"text-oai-gray-600 hover:text-oai-gray-900 hover:bg-oai-gray-100 active:bg-oai-gray-200 dark:text-oai-gray-400 dark:hover:text-white dark:hover:bg-oai-gray-800 dark:active:bg-oai-gray-700"},s={sm:"h-9 px-4 text-sm",md:"h-11 px-6 text-sm",lg:"h-12 px-8 text-base"};return Mn(i,r[t],s[e],n)}function c$({copy:t,signInUrl:e,signUpUrl:n,installCommand:i,installCopied:r,onCopyInstallCommand:s}){const o=Lz(),[c,u]=L.useState(!1);L.useEffect(()=>{const w=()=>u(window.scrollY>10);return window.addEventListener("scroll",w,{passive:!0}),()=>window.removeEventListener("scroll",w)},[]);const d=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),{signedIn:h,loading:p}=Do(),m=L.useMemo(()=>({codex:t("landing.v2.models.agent.codex"),claude_code:t("landing.v2.models.agent.claude_code"),cursor:t("landing.v2.models.agent.cursor"),gemini:t("landing.v2.models.agent.gemini"),opencode:t("landing.v2.models.agent.opencode"),openclaw:t("landing.v2.models.agent.openclaw")}),[t]),v=L.useMemo(()=>[{id:"codex",icon:"/brand-logos/codex.svg"},{id:"claude_code",icon:"/brand-logos/claude-code.svg"},{id:"cursor",icon:"/brand-logos/cursor.svg"},{id:"gemini",icon:"/brand-logos/gemini.svg"},{id:"opencode",icon:"/brand-logos/opencode.svg"},{id:"openclaw",icon:"/brand-logos/openclaw.svg"}],[]),_=o?{duration:0}:void 0;return F.jsxs("div",{className:"relative min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark",children:[F.jsx("div",{className:"absolute inset-0 z-0 pointer-events-none",style:{height:"100vh"},children:F.jsx(n$,{raysOrigin:"top-center",raysColor:"#b8b3ff",raysSpeed:1,lightSpread:.5,rayLength:3,pulsating:!1,fadeDistance:1,saturation:1,followMouse:!0,mouseInfluence:.1,noiseAmount:0,distortion:0})}),F.jsx("header",{className:Mn("sticky top-0 z-50 transition-all duration-300",c?"bg-oai-gray-950/80 backdrop-blur-md border-b border-oai-gray-900":"bg-transparent border-b border-transparent"),children:F.jsxs("div",{className:"mx-auto flex h-14 max-w-7xl items-center justify-between px-4 sm:px-6",children:[F.jsxs("div",{className:"flex items-center gap-5",children:[F.jsxs(Us,{to:n||"/",className:"flex items-center gap-3 no-underline outline-none rounded focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:ring-offset-oai-gray-950 transition-opacity hover:opacity-80",children:[F.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),F.jsx("span",{className:"text-sm font-semibold tracking-wide text-white uppercase",children:"Token Tracker"})]}),F.jsx("div",{className:"hidden sm:block",children:F.jsx(hH,{})})]}),d&&F.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 sm:gap-3",children:[F.jsxs(Us,{to:fH(),className:Mn(l$(h||p?"default":"ghost","sm"),"no-underline px-5 rounded-full group",h||p?"shadow-sm ring-1 ring-white/10":"ring-1 ring-oai-gray-700"),children:[t("landing.v2.cta.primary"),F.jsx("span",{className:"ml-2 inline-block transition-transform duration-200 group-hover:translate-x-0.5",children:"→"})]}),F.jsx(H0,{})]})]})}),F.jsxs("main",{children:[F.jsx("section",{className:"relative py-16 sm:py-24 lg:py-32 overflow-hidden",children:F.jsxs("div",{className:"relative z-10 mx-auto max-w-7xl px-4 sm:px-6 flex flex-col items-center text-center gap-20 lg:gap-36",children:[F.jsxs(Il.div,{initial:o?!1:{opacity:0,y:20},animate:{opacity:1,y:0},transition:_||{duration:.5},className:"w-full max-w-3xl relative z-20",children:[F.jsxs("h1",{className:"text-balance text-5xl font-semibold tracking-tight text-white sm:text-6xl lg:text-[4rem] lg:leading-[1.05]",children:[t("landing.v2.hero.title_line1"),F.jsx("br",{}),F.jsx("span",{className:"bg-gradient-to-b from-white via-oai-gray-200 to-oai-gray-500 bg-clip-text text-transparent font-bold tracking-tight",style:{WebkitTextStroke:"1px rgba(255, 255, 255, 0.15)"},children:t("landing.v2.hero.title_line2")})]}),F.jsx("p",{className:"mt-6 text-lg leading-relaxed text-oai-gray-400",children:t("landing.v2.hero.subtagline")}),F.jsxs("div",{className:"mt-8 w-full max-w-lg mx-auto",children:[F.jsxs(Il.div,{whileHover:{scale:1.01,y:-1},transition:{type:"spring",stiffness:400,damping:25},className:"group relative inline-block w-full overflow-hidden rounded-2xl",style:{padding:"1.5px 0"},children:[F.jsx("div",{className:"absolute w-[300%] h-[50%] opacity-70 bottom-[-11px] right-[-250%] rounded-full animate-star-movement-bottom z-0",style:{background:"radial-gradient(circle, #fbdfff, transparent 10%)",animationDuration:"6s"}}),F.jsx("div",{className:"absolute w-[300%] h-[50%] opacity-70 top-[-10px] left-[-250%] rounded-full animate-star-movement-top z-0",style:{background:"radial-gradient(circle, #fbdfff, transparent 10%)",animationDuration:"6s"}}),F.jsxs("div",{className:"relative z-[1] flex items-center justify-between w-full bg-[#0a0a0a] border border-oai-gray-800 rounded-2xl p-1.5 pl-5 shadow-2xl shadow-black/50",children:[F.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[F.jsx("span",{className:"text-oai-gray-600 font-mono select-none","aria-hidden":"true",children:"›"}),F.jsx("code",{className:"font-mono text-sm text-oai-gray-200 overflow-x-auto whitespace-nowrap py-2 [scrollbar-width:none]",children:i?i.split(" ").map((w,y)=>F.jsxs("span",{className:w==="npx"||w==="tokentracker-cli"?"text-white font-medium":w==="--yes"?"text-oai-gray-500":"text-oai-brand-400",children:[w," "]},y)):null})]}),F.jsx("button",{type:"button",onClick:s,"aria-label":t(r?"landing.install.action.copied":"landing.install.action.copy"),className:"shrink-0 flex h-9 w-9 items-center justify-center text-oai-gray-200 bg-oai-gray-900 border border-oai-gray-700 rounded-lg hover:bg-oai-gray-800 hover:text-white active:scale-95 transition-all duration-200 shadow-sm",children:r?F.jsx(a$,{className:"h-4 w-4 text-green-400","aria-hidden":!0}):F.jsx(s$,{className:"h-4 w-4 opacity-70","aria-hidden":!0})})]})]}),F.jsxs("div",{className:"mt-8 flex flex-wrap items-center justify-center gap-x-6 gap-y-4",children:[F.jsxs("a",{href:o$,target:"_blank",rel:"noopener noreferrer",className:"group flex items-center gap-2 text-sm font-medium text-oai-gray-400 hover:text-white transition-colors",children:[F.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-oai-gray-800 group-hover:bg-oai-gray-700 transition-colors",children:F.jsx(i$,{className:"h-4 w-4 text-oai-gray-400 group-hover:text-white"})}),t("landing.v2.install.mac_cta")]}),F.jsxs("a",{href:NE,target:"_blank",rel:"noopener noreferrer",className:"group flex items-center gap-2 text-sm font-medium text-oai-gray-400 hover:text-white transition-colors",children:[F.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-oai-gray-800 group-hover:bg-oai-gray-700 transition-colors",children:F.jsx(r$,{className:"h-4 w-4 text-oai-gray-400 group-hover:text-white"})}),t("landing.cta.secondary")]})]}),F.jsx("span",{className:"sr-only","aria-live":"polite",children:r?t("landing.install.action.copied"):""})]})]}),F.jsx("div",{className:"relative group w-full",children:F.jsxs(Il.div,{initial:o?!1:{opacity:0,y:24},animate:{opacity:1,y:0},transition:_||{duration:.6,delay:.1},className:"relative w-full",children:[F.jsx("div",{style:{position:"absolute",top:"-256px",left:0,right:0,height:"510px",zIndex:3,pointerEvents:"none"},children:F.jsx(PW,{color:"#8a7aff",wispDensity:2,flowSpeed:.28,verticalSizing:2.2,horizontalSizing:1.22,fogIntensity:4,fogScale:.1,wispSpeed:18,wispIntensity:10,flowStrength:.12,decay:1.1,falloffStart:1.1,fogFallSpeed:.5,horizontalBeamOffset:.22,verticalBeamOffset:0,style:{width:"100%",height:"100%"}})}),F.jsx("div",{className:"relative rounded-xl p-[1px] shadow-2xl bg-gradient-to-b from-[rgba(138,122,255,0.6)] via-[rgba(138,122,255,0.15)] to-[rgba(138,122,255,0.05)]",style:{position:"relative",zIndex:10,boxShadow:"0 20px 60px -10px rgba(138,122,255,0.15), 0 4px 20px rgba(0,0,0,0.4)"},children:F.jsxs("div",{className:"relative rounded-[11px] overflow-hidden bg-oai-gray-950",children:[F.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"180px",background:"linear-gradient(to bottom, rgba(138,122,255,0.35) 0%, rgba(138,122,255,0.12) 40%, transparent 100%)",mixBlendMode:"screen",zIndex:20,pointerEvents:"none"}}),F.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"1px",background:"linear-gradient(90deg, transparent 0%, rgba(138,122,255,0.9) 30%, rgba(180,168,255,1) 50%, rgba(138,122,255,0.9) 70%, transparent 100%)",zIndex:25,pointerEvents:"none"}}),F.jsx("img",{src:"/dashboard-dark.png",alt:t("landing.screenshot.alt"),className:"block h-auto w-full object-cover",style:{position:"relative",zIndex:10},loading:"eager",decoding:"async"})]})})]})})]})}),F.jsx("section",{className:"border-y border-oai-gray-900 bg-oai-gray-950/50 py-12 lg:py-16",children:F.jsx("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:F.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-8",children:[F.jsx("p",{className:"text-sm font-semibold uppercase tracking-wider text-oai-gray-400 shrink-0",children:t("landing.v2.models.title")}),F.jsx("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-6 opacity-60 hover:opacity-100 transition-opacity duration-500 grayscale hover:grayscale-0",children:v.map(w=>F.jsxs("div",{className:"flex items-center gap-2.5 transition-transform hover:-translate-y-0.5 duration-300",children:[F.jsx("img",{src:w.icon,alt:"",width:20,height:20,className:`h-5 w-5 object-contain ${w.id==="cursor"?"dark:invert":""}`,loading:"lazy"}),F.jsx("span",{className:"text-sm font-medium text-oai-gray-300",children:m[w.id]})]},w.id))})]})})}),F.jsx("section",{className:"py-20 lg:py-32",children:F.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6 grid grid-cols-1 md:grid-cols-2 gap-16 lg:gap-24 items-start",children:[F.jsxs("div",{className:"max-w-md",children:[F.jsx("p",{className:"text-xs font-bold tracking-widest uppercase text-oai-brand-500 mb-4",children:t("landing.v2.compare.kicker")}),F.jsx("h2",{className:"text-3xl font-semibold tracking-tight text-white sm:text-4xl text-balance",children:t("landing.v2.compare.title")}),F.jsx("p",{className:"mt-6 text-lg leading-relaxed text-oai-gray-400",children:t("landing.v2.compare.subtitle")}),F.jsx("p",{className:"mt-6 text-base leading-relaxed text-oai-gray-500",children:t("landing.v2.distill.body")})]}),F.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-10",children:[F.jsxs("div",{className:"space-y-4",children:[F.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-white border-b border-oai-gray-800 pb-3",children:t("landing.v2.compare.with.title")}),F.jsxs("ul",{className:"space-y-3 text-sm text-oai-gray-400",children:[F.jsxs("li",{className:"flex gap-2",children:[F.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),F.jsx("span",{children:t("landing.v2.compare.with.p1")})]}),F.jsxs("li",{className:"flex gap-2",children:[F.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),F.jsx("span",{children:t("landing.v2.compare.with.p2")})]}),F.jsxs("li",{className:"flex gap-2",children:[F.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),F.jsx("span",{children:t("landing.v2.compare.with.p3")})]})]})]}),F.jsxs("div",{className:"space-y-4",children:[F.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-oai-gray-500 border-b border-oai-gray-800/50 pb-3",children:t("landing.v2.compare.without.title")}),F.jsxs("ul",{className:"space-y-3 text-sm text-oai-gray-500",children:[F.jsxs("li",{className:"flex gap-2",children:[F.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),F.jsx("span",{children:t("landing.v2.compare.without.p1")})]}),F.jsxs("li",{className:"flex gap-2",children:[F.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),F.jsx("span",{children:t("landing.v2.compare.without.p2")})]}),F.jsxs("li",{className:"flex gap-2",children:[F.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),F.jsx("span",{children:t("landing.v2.compare.without.p3")})]})]})]})]})]})})]}),F.jsx("footer",{className:"border-t border-oai-gray-900 bg-oai-gray-950 py-12",children:F.jsxs("div",{className:"mx-auto flex max-w-6xl flex-col items-center justify-between gap-6 px-4 sm:px-6 text-sm text-oai-gray-400 sm:flex-row",children:[F.jsx("p",{children:t("landing.v2.footer.line")}),F.jsxs("div",{className:"flex items-center gap-6",children:[F.jsx("a",{href:NE,className:"font-medium text-oai-gray-400 hover:text-white transition-colors",target:"_blank",rel:"noopener noreferrer",children:t("landing.v2.nav.github")}),d&&F.jsxs(Us,{to:e,className:"font-medium text-oai-brand-500 hover:text-oai-brand-400 transition-colors",children:[t("landing.cta.primary")," →"]})]})]})})]})}function u$({prefersReducedMotion:t,screenshotMode:e}){return!(e||t)}function d$(){return L.useMemo(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function f$(t=0,e=!0){const[n,i]=L.useState(()=>!e);return L.useEffect(()=>{if(!e){i(!0);return}let r=null,s=null;const o=()=>i(!0);return typeof window<"u"&&"requestIdleCallback"in window?(s=window.requestIdleCallback(o,{timeout:t||200}),()=>{typeof window.cancelIdleCallback=="function"&&s!=null&&window.cancelIdleCallback(s)}):(r=window.setTimeout(o,t),()=>{r!=null&&window.clearTimeout(r)})},[t,e]),n}function h$({signInUrl:t,signUpUrl:e}){const n=Ct("landing.handle.special"),i=Ct("landing.handle.default");Ct("landing.nav.login"),Ct("landing.nav.signup");const[r,s]=L.useState(i),o=d$(),c=L.useMemo(()=>typeof window>"u"?!1:$C(window.location.search),[]),u=u$({prefersReducedMotion:o,screenshotMode:c});f$(250,u);const d="tokentracker.dashboard.from_landing.v1";L.useEffect(()=>{if(!(typeof window>"u"))try{window.sessionStorage.setItem(d,"1")}catch{}},[d]),L.useMemo(()=>Ct("landing.handle.placeholder",{handle:n}),[n]),L.useMemo(()=>{const _=Ct(r===n?"landing.rank.singularity":"landing.rank.unranked");return Ct("landing.rank.expectation",{rank:_})},[r,n]);const h=Ct("landing.install.command"),[p,m]=L.useState(!1),v=async()=>{await uH(h)&&(m(!0),window.setTimeout(()=>m(!1),2e3))};return F.jsx(c$,{copy:Ct,reduceMotion:o,signInUrl:t,signUpUrl:e,installCommand:h,installCopied:p,onCopyInstallCommand:v})}function p$(t){const e=new URLSearchParams(t).get("next");return typeof e!="string"||e.length===0||!e.startsWith("/")||e.startsWith("//")?"/dashboard":e}const IE={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",linkedin:"LinkedIn",facebook:"Facebook",instagram:"Instagram",tiktok:"TikTok",apple:"Apple",x:"X",spotify:"Spotify"};function UE(t){const e=String(t||"").trim();return IE[e]?IE[e]:e.replace(/-/g," ")}function m$(){const t=Au(),[e,n]=WL(),{enabled:i,loading:r,signedIn:s,refreshUser:o,signInWithPassword:c,signUp:u,signInWithOAuth:d,getPublicAuthConfig:h}=Do(),p=L.useMemo(()=>p$(e.toString()),[e]),[m,v]=L.useState("signin"),[_,w]=L.useState(""),[y,b]=L.useState(""),[T,A]=L.useState(""),[M,I]=L.useState(!1),[k,U]=L.useState(null),[S,P]=L.useState(null),[V,O]=L.useState(!0),[G,J]=L.useState([]),[H,X]=L.useState([]),[K,Q]=L.useState(8);L.useEffect(()=>{const Se=e.get("insforge_status"),ne=e.get("insforge_type"),ye=e.get("insforge_error");Se==="success"&&ne==="verify_email"?P(Ct("login.verify_email_success")):Se==="error"&&ne==="verify_email"&&ye&&P(Ct("shared.error.prefix",{error:ye}))},[e]),L.useEffect(()=>{if(!i){O(!1);return}let Se=!0;return(async()=>{const{data:ne,error:ye}=await h();Se&&(ye||!ne?(J(["google","github"]),X([])):(J(Array.isArray(ne.oAuthProviders)?ne.oAuthProviders:[]),X(Array.isArray(ne.customOAuthProviders)?ne.customOAuthProviders:[]),typeof ne.passwordMinLength=="number"&&ne.passwordMinLength>0&&Q(ne.passwordMinLength)),O(!1))})(),()=>{Se=!1}},[i,h]),L.useEffect(()=>{if(!(!i||r)&&s){if(W){window.location.href="/auth/native-callback";return}t(p,{replace:!0})}},[i,r,s,t,p,W]),L.useEffect(()=>{i&&o()},[i,o]);const W=L.useMemo(()=>e.get("native")==="1",[e]),q=L.useMemo(()=>e.get("provider")||null,[e]),Z=L.useMemo(()=>typeof window>"u"||W?"":`${window.location.origin}/`,[W]),z=L.useMemo(()=>typeof window>"u"?"":`${window.location.origin}/`,[]),ie=L.useCallback(async Se=>{Se.preventDefault(),U(null),I(!0);try{if(m==="signup"){const{data:ye,error:be}=await u({email:_.trim(),password:y,name:T.trim()||void 0,redirectTo:z});if(be){U(be.message||String(be));return}if(ye?.requireEmailVerification){P(Ct("login.verify_email_pending")),v("signin");return}t(p,{replace:!0});return}const{error:ne}=await c({email:_.trim(),password:y});if(ne){U(ne.message||String(ne));return}t(p,{replace:!0})}finally{I(!1)}},[m,_,y,T,u,c,t,p,z]),we=L.useCallback(async Se=>{U(null),I(!0);try{const{error:ne}=await d(Se,Z);ne&&U(ne.message||String(ne))}finally{I(!1)}},[d,Z]);L.useEffect(()=>{if(W&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[W]),L.useEffect(()=>{if(!i||r||s||V||!W||!q)return;[...G,...H].includes(q)&&we(q)},[i,r,s,V,W,q,G,H,we]);const He=L.useCallback(()=>{n(Se=>{const ne=new URLSearchParams(Se);return ne.delete("insforge_status"),ne.delete("insforge_type"),ne.delete("insforge_error"),ne},{replace:!0}),P(null)},[n]);return i?F.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[F.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:F.jsx(Us,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 rounded",children:Ct("login.back_home")})}),F.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:F.jsxs("div",{className:"w-full max-w-md space-y-8",children:[F.jsxs("div",{className:"text-center",children:[F.jsx("h1",{className:"text-2xl font-semibold text-white tracking-tight",children:Ct("login.title")}),F.jsx("p",{className:"mt-2 text-sm text-oai-gray-500",children:Ct("login.subtitle")})]}),S?F.jsxs("div",{className:"rounded-lg border border-oai-gray-800 bg-oai-gray-900/50 px-4 py-3 text-sm text-oai-gray-300 flex justify-between gap-3 items-start",role:"status",children:[F.jsx("span",{children:S}),F.jsx("button",{type:"button",onClick:He,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:Ct("login.dismiss")})]}):null,k?F.jsx("p",{className:"text-sm text-red-400",role:"alert",children:Ct("shared.error.prefix",{error:k})}):null,F.jsx("div",{className:"space-y-3",children:V?F.jsx("div",{className:"h-11 rounded-lg bg-oai-gray-900 animate-pulse","aria-hidden":!0}):F.jsxs(F.Fragment,{children:[G.map(Se=>F.jsx("button",{type:"button",disabled:M,onClick:()=>we(Se),className:Mn("w-full h-11 rounded-lg border border-oai-gray-700 bg-oai-gray-900 text-sm font-medium text-white","hover:bg-oai-gray-800 transition-colors disabled:opacity-50"),children:Ct("login.oauth.continue",{provider:UE(Se)})},Se)),H.map(Se=>F.jsx("button",{type:"button",disabled:M,onClick:()=>we(Se),className:Mn("w-full h-11 rounded-lg border border-oai-gray-700 bg-oai-gray-900 text-sm font-medium text-white","hover:bg-oai-gray-800 transition-colors disabled:opacity-50"),children:Ct("login.oauth.continue",{provider:UE(Se)})},Se))]})}),F.jsxs("div",{className:"relative",children:[F.jsx("div",{className:"absolute inset-0 flex items-center","aria-hidden":!0,children:F.jsx("span",{className:"w-full border-t border-oai-gray-800"})}),F.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:F.jsx("span",{className:"bg-oai-gray-950 px-3 text-oai-gray-600",children:Ct("login.divider")})})]}),F.jsxs("div",{className:"flex rounded-lg border border-oai-gray-800 p-0.5 bg-oai-gray-900/50",children:[F.jsx("button",{type:"button",className:Mn("flex-1 py-2 text-sm font-medium rounded-md transition-colors",m==="signin"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{v("signin"),U(null)},children:Ct("login.tab.sign_in")}),F.jsx("button",{type:"button",className:Mn("flex-1 py-2 text-sm font-medium rounded-md transition-colors",m==="signup"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{v("signup"),U(null)},children:Ct("login.tab.sign_up")})]}),F.jsxs("form",{onSubmit:ie,className:"space-y-4",children:[m==="signup"?F.jsxs("div",{children:[F.jsx("label",{htmlFor:"login-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:Ct("login.field.name")}),F.jsx("input",{id:"login-name",type:"text",autoComplete:"name",value:T,onChange:Se=>A(Se.target.value),className:"w-full h-11 rounded-lg border border-oai-gray-800 bg-oai-gray-900 px-3 text-sm text-white placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500",placeholder:Ct("login.field.name_placeholder")})]}):null,F.jsxs("div",{children:[F.jsx("label",{htmlFor:"login-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:Ct("login.field.email")}),F.jsx("input",{id:"login-email",type:"email",autoComplete:"email",required:!0,value:_,onChange:Se=>w(Se.target.value),className:"w-full h-11 rounded-lg border border-oai-gray-800 bg-oai-gray-900 px-3 text-sm text-white placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),F.jsxs("div",{children:[F.jsx("label",{htmlFor:"login-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:Ct("login.field.password")}),F.jsx("input",{id:"login-password",type:"password",autoComplete:m==="signup"?"new-password":"current-password",required:!0,minLength:m==="signup"?K:void 0,value:y,onChange:Se=>b(Se.target.value),className:"w-full h-11 rounded-lg border border-oai-gray-800 bg-oai-gray-900 px-3 text-sm text-white placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"}),m==="signup"?F.jsx("p",{className:"mt-1 text-xs text-oai-gray-600",children:Ct("login.password_hint",{min:String(K)})}):null]}),F.jsx("button",{type:"submit",disabled:M||r,className:"w-full h-11 rounded-lg bg-white text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:Ct(m==="signup"?"login.submit.sign_up":"login.submit.sign_in")})]})]})})]}):F.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[F.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:F.jsx(Us,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:Ct("login.back_home")})}),F.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:F.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",children:Ct("login.cloud_only")})})]})}const g$=typeof window<"u"?window.location.search:"",FE=new URLSearchParams(g$),Mf=FE.get("insforge_code")||FE.get("code")||null;function v$(){const{loading:t,signedIn:e}=Do(),n=Au(),[i,r]=L.useState("processing"),[s,o]=L.useState(null),c=L.useRef(!1);return L.useEffect(()=>{!Mf||c.current||(c.current=!0,(async()=>{try{const d=await(await fetch("/api/auth-bridge/verifier")).json();o(!!d?.native)}catch{o(!1)}})())},[]),L.useEffect(()=>{if(s!==!0||!Mf)return;r("redirecting");const u=setTimeout(()=>{window.location.href=`tokentracker://auth/callback?insforge_code=${encodeURIComponent(Mf)}`},200);return()=>clearTimeout(u)},[s]),L.useEffect(()=>{if(s!==!1||t)return;if(e){n("/dashboard",{replace:!0});return}const u=setTimeout(()=>{e||r("failed")},5e3);return()=>clearTimeout(u)},[s,t,e,n]),L.useEffect(()=>{if(!Mf&&s===null){const u=setTimeout(()=>r("failed"),3e3);return()=>clearTimeout(u)}},[s]),i==="processing"&&s!==!0&&(s===null||s===!1&&t)?F.jsx("div",{className:"min-h-screen bg-oai-gray-950"}):F.jsx("div",{className:"min-h-screen bg-oai-gray-950 text-white font-oai antialiased dark flex items-center justify-center",children:F.jsxs("div",{className:"text-center space-y-4 max-w-sm px-4",children:[i==="processing"&&F.jsxs(F.Fragment,{children:[F.jsx("div",{className:"w-8 h-8 border-2 border-oai-gray-600 border-t-white rounded-full animate-spin mx-auto"}),F.jsx("p",{className:"text-oai-gray-400 text-sm",children:"Processing…"})]}),i==="redirecting"&&F.jsxs(F.Fragment,{children:[F.jsx("div",{className:"w-12 h-12 mx-auto rounded-full bg-green-500/15 flex items-center justify-center",children:F.jsx("svg",{className:"w-6 h-6 text-green-400",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:F.jsx("path",{d:"M20 6 9 17l-5-5"})})}),F.jsx("p",{className:"text-white text-sm font-medium",children:"Signed in successfully"}),F.jsx("p",{className:"text-oai-gray-500 text-xs",children:"Returning to TokenTracker…"})]}),i==="failed"&&F.jsxs("div",{className:"space-y-3",children:[F.jsx("p",{className:"text-oai-gray-300 text-sm",children:"Sign-in incomplete. Please try again."}),F.jsx("button",{type:"button",onClick:()=>window.close(),className:"px-4 py-2 rounded-lg bg-oai-gray-800 text-sm text-white hover:bg-oai-gray-700 transition-colors",children:"Close this page"})]})]})})}function y$(){const t=L.useContext(OT);if(t===null)throw new Error("useTheme must be used within a ThemeProvider");return t}const Fv="tt.sidebarCollapsed";function _$(){return[{id:"general",label:Ct("nav.group.general"),items:[{id:"usage",to:"/dashboard",icon:zz,label:Ct("nav.usage")},{id:"limits",to:"/limits",icon:Hz,label:Ct("nav.limits")},{id:"leaderboard",to:"/leaderboard",icon:rV,label:Ct("nav.leaderboard")}]},{id:"tools",label:Ct("nav.group.tools"),items:[{id:"widgets",to:"/widgets",icon:$z,label:Ct("nav.widgets")},{id:"ip-check",to:"/ip-check",icon:jz,label:"Claude IP Check"}]},{id:"account",label:Ct("nav.group.account"),items:[{id:"settings",to:"/settings",icon:tV,label:Ct("nav.settings")}]}]}function x$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Fv)==="1"}catch{return!1}}function b$(){const[t,e]=L.useState(x$),n=L.useCallback(()=>{e(i=>{const r=!i;try{typeof window<"u"&&window.localStorage.setItem(Fv,r?"1":"0")}catch{}return r})},[]);return L.useEffect(()=>{if(typeof window>"u")return;const i=r=>{r.key===Fv&&e(r.newValue==="1")};return window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[]),{collapsed:t,toggle:n}}function S$(t,e){const n=t.replace(/\/+$/,"")||"/";return e==="/dashboard"?n==="/dashboard"||n==="/":e==="/leaderboard"?n==="/leaderboard"||n.startsWith("/leaderboard/"):n===e}function w$({label:t,collapsed:e,first:n}){return e?n?null:F.jsx("div",{className:"mx-2 my-2 h-px bg-oai-gray-200/70 dark:bg-oai-gray-800/70","aria-hidden":!0}):F.jsx("div",{className:Mn("px-3 pb-1 text-[10px] uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-500",n?"pt-2":"pt-4"),children:t})}function E$({item:t,collapsed:e,active:n,onClick:i}){const r=t.icon;return F.jsxs(Us,{to:t.to,onClick:i,title:e?t.label:void 0,"aria-current":n?"page":void 0,className:Mn("flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px] no-underline transition-colors",e&&"justify-center px-0 py-2",n?"bg-oai-gray-200/70 text-oai-black font-medium dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/50 hover:text-oai-black dark:hover:bg-oai-gray-800/60 dark:hover:text-white"),children:[F.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:F.jsx(r,{className:"h-[15px] w-[15px]","aria-hidden":!0})}),!e&&F.jsx("span",{className:"truncate",children:t.label})]})}function M$({as:t="button",title:e,onClick:n,href:i,children:r,className:s,...o}){const c=Mn("flex h-10 w-10 items-center justify-center rounded-lg text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",s);return t==="a"?F.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",title:e,"aria-label":e,className:c,...o,children:r}):F.jsx("button",{type:"button",title:e,"aria-label":e,onClick:n,className:c,...o,children:r})}function T$({repo:t="mm7894215/TokenTracker",glassChrome:e=!1}){const[n,i]=L.useState(null);return L.useEffect(()=>{if(typeof window>"u")return;const r=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;ZC({prefersReducedMotion:r,screenshotCapture:!1})&&fetch(`https://api.github.com/repos/${t}`).then(s=>s.json()).then(s=>{s&&typeof s.stargazers_count=="number"&&i(s.stargazers_count)}).catch(()=>{})},[t]),F.jsxs("a",{href:`https://github.com/${t}`,target:"_blank",rel:"noopener noreferrer","aria-label":n!==null?`Star on GitHub (${n})`:"Star on GitHub",className:Mn("inline-flex h-7 items-center gap-1.5 rounded-full px-2.5 text-xs font-medium transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"border border-gray-500/20 dark:border-gray-500/30 bg-gray-500/[0.04] dark:bg-gray-500/[0.06] backdrop-blur-[2px] text-oai-gray-700 dark:text-oai-gray-300 hover:bg-gray-500/10 dark:hover:bg-gray-500/12 hover:border-gray-500/30 dark:hover:border-gray-500/40 hover:text-oai-black dark:hover:text-white":"border border-oai-gray-200 dark:border-oai-gray-700 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white hover:border-oai-gray-300 dark:hover:border-oai-gray-600"),children:[F.jsx("svg",{height:"12",viewBox:"0 0 16 16",width:"12",className:"shrink-0 fill-current",children:F.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"})}),F.jsx("span",{children:"Star"}),n!==null&&F.jsx("span",{className:"text-[10px] text-oai-gray-500 dark:text-oai-gray-500 tabular-nums",children:n})]})}const A$=[{value:"light",label:"Light",Icon:PC},{value:"dark",label:"Dark",Icon:CC},{value:"system",label:"System",Icon:Jz}];function C$({theme:t,resolvedTheme:e,onSetTheme:n,glassChrome:i=!1}){const[r,s]=L.useState(!1),o=L.useRef(null),c=e==="dark"?CC:PC;return L.useEffect(()=>{if(!r)return;const u=h=>{o.current&&!o.current.contains(h.target)&&s(!1)},d=h=>{h.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",d)}},[r]),F.jsxs("div",{ref:o,className:"relative",children:[F.jsx("button",{type:"button","aria-label":"Theme","aria-expanded":r,"aria-haspopup":"menu",title:"Theme",onClick:()=>s(u=>!u),className:Mn("inline-flex h-7 w-7 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",i?"border border-gray-500/20 dark:border-gray-500/30 bg-gray-500/[0.04] dark:bg-gray-500/[0.06] backdrop-blur-[2px] text-oai-gray-700 dark:text-oai-gray-300 hover:bg-gray-500/10 dark:hover:bg-gray-500/12 hover:border-gray-500/30 dark:hover:border-gray-500/40 hover:text-oai-black dark:hover:text-white":"border border-oai-gray-200 dark:border-oai-gray-700 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white hover:border-oai-gray-300 dark:hover:border-oai-gray-600"),children:F.jsx(c,{className:"h-3.5 w-3.5","aria-hidden":!0})}),r&&F.jsx("div",{role:"menu",className:"absolute bottom-full left-0 mb-2 z-50 min-w-[140px] py-1 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-lg",children:A$.map(({value:u,label:d,Icon:h})=>{const p=t===u;return F.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{n(u),s(!1)},className:Mn("flex w-full items-center gap-2.5 px-3 py-1.5 text-[13px] transition-colors",p?"text-oai-black dark:text-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 hover:text-oai-black dark:hover:text-white"),children:[F.jsx(h,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),F.jsx("span",{children:d})]},u)})})]})}function OP({collapsed:t,onToggleCollapsed:e,onItemClick:n,showCloseButton:i=!1,onClose:r,glassChrome:s=!1}){const c=vr()?.pathname||"/",{theme:u,resolvedTheme:d,setTheme:h}=y$(),p=L.useMemo(()=>_$(),[]);return F.jsxs(F.Fragment,{children:[F.jsx("div",{className:Mn("px-2 pt-2 pb-2",t&&"flex justify-center"),children:i?F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx("div",{className:"flex-1 min-w-0",children:F.jsx(H0,{variant:"sidebar",collapsed:t,onAfterAction:n})}),F.jsx("button",{type:"button",onClick:r,"aria-label":Ct("nav.close_menu"),title:Ct("nav.close_menu"),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-500 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-gray-900 dark:hover:text-oai-gray-200 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:F.jsx(RC,{className:"h-4 w-4",strokeWidth:1.75,"aria-hidden":!0})})]}):F.jsx(H0,{variant:"sidebar",collapsed:t,onAfterAction:n})}),F.jsx("nav",{"aria-label":Ct("nav.nav_label"),className:"flex-1 px-2 pb-2 flex flex-col overflow-y-auto",children:p.map((m,v)=>F.jsxs("div",{className:"flex flex-col",children:[F.jsx(w$,{label:m.label,collapsed:t,first:v===0}),F.jsx("div",{className:"flex flex-col gap-0.5",children:m.items.map(_=>F.jsx(E$,{item:_,collapsed:t,active:S$(c,_.to),onClick:n},_.id))})]},m.id))}),F.jsxs("div",{className:Mn("flex items-center px-2 py-3",t?"flex-col justify-center gap-2":"justify-between gap-2"),children:[F.jsx(C$,{theme:u,resolvedTheme:d,onSetTheme:h,glassChrome:s}),F.jsx("div",{className:"flex items-center gap-1.5",children:!t&&F.jsx(T$,{glassChrome:s})})]})]})}function P$({collapsed:t,onToggleCollapsed:e}){const n=L.useMemo(()=>typeof window>"u"?!1:Aa()||UT(),[]);return F.jsx("aside",{"aria-label":Ct("nav.aside_label"),className:Mn("hidden lg:flex flex-col shrink-0 h-full min-h-0 transition-[width] duration-200",t?"w-[72px]":"w-[220px]"),children:F.jsx(OP,{collapsed:t,onToggleCollapsed:e,glassChrome:n})})}function R$({open:t,onClose:e}){return L.useEffect(()=>{if(!t)return;const n=i=>{i.key==="Escape"&&e()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[t,e]),L.useEffect(()=>{if(!t)return;const n=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=n}},[t]),t?F.jsxs("div",{className:"lg:hidden fixed inset-0 z-[80] flex",children:[F.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:e,"aria-hidden":!0}),F.jsx("aside",{"aria-label":Ct("nav.aside_label"),className:"relative w-[260px] max-w-[80vw] flex flex-col bg-oai-white dark:bg-oai-gray-900 border-r border-oai-gray-200 dark:border-oai-gray-800 shadow-2xl",children:F.jsx(OP,{collapsed:!1,showCloseButton:!0,onClose:e,onItemClick:e})})]}):null}function k$({onOpenDrawer:t}){return F.jsxs("div",{className:"lg:hidden flex items-center justify-between gap-2 px-3 h-14 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[F.jsx(M$,{title:Ct("nav.menu"),onClick:t,children:F.jsx(Kz,{className:"h-5 w-5","aria-hidden":!0})}),F.jsxs(Us,{to:"/landing",className:"flex items-center gap-2 no-underline hover:opacity-80 transition-opacity","aria-label":"Token Tracker",children:[F.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),F.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white",children:"Token Tracker"})]}),F.jsx("div",{className:"w-10 shrink-0","aria-hidden":!0})]})}function L$({children:t}){const{collapsed:e,toggle:n}=b$(),[i,r]=L.useState(!1),s=L.useCallback(()=>r(!0),[]),o=L.useCallback(()=>r(!1),[]),c=L.useMemo(()=>typeof window>"u"?!1:Aa()||UT(),[]);return F.jsxs("div",{className:Mn("fixed inset-0 flex flex-col text-oai-black dark:text-oai-white font-sans overflow-hidden",c?"bg-transparent":"bg-oai-gray-100 dark:bg-oai-gray-950"),children:[c&&F.jsx("div",{className:"h-7 shrink-0",style:{WebkitAppRegion:"drag"},"aria-hidden":!0}),F.jsxs("div",{className:"flex-1 min-h-0 flex",children:[F.jsx(P$,{collapsed:e,onToggleCollapsed:n}),F.jsx(R$,{open:i,onClose:o}),F.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-2 lg:pl-0 lg:pr-3 lg:pb-3 flex flex-col",children:F.jsxs("div",{className:Mn("flex-1 min-h-0 flex flex-col bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",c?"tt-native-main-card":"rounded-2xl",!c&&"shadow-sm"),children:[F.jsx(k$,{onOpenDrawer:s}),F.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:t})]})})]})]})}const D$=hs.lazy(()=>No(()=>import("./DashboardPage-CuBSoNgI.js"),__vite__mapDeps([0,1,2,3])).then(t=>({default:t.DashboardPage}))),N$=hs.lazy(()=>No(()=>import("./LeaderboardPage-BOrtGeIf.js"),__vite__mapDeps([4,5])).then(t=>({default:t.LeaderboardPage}))),I$=hs.lazy(()=>No(()=>import("./LeaderboardProfilePage-C8xexZ08.js"),__vite__mapDeps([6,5])).then(t=>({default:t.LeaderboardProfilePage}))),U$=hs.lazy(()=>No(()=>import("./LimitsPage-CERWQyIU.js"),__vite__mapDeps([7,1,8,2,3])).then(t=>({default:t.LimitsPage}))),F$=hs.lazy(()=>No(()=>import("./SettingsPage-DUwt4x-H.js"),__vite__mapDeps([9,8,2,10])).then(t=>({default:t.SettingsPage}))),O$=hs.lazy(()=>No(()=>import("./WidgetsPage-Cmr2tbD7.js"),__vite__mapDeps([11,3,10])).then(t=>({default:t.WidgetsPage}))),B$=hs.lazy(()=>No(()=>import("./IpCheckPage-B5TpHE6G.js"),[]));function z$(){const t=vr(),e=Do();lH();const n=xr(),i=L.useMemo(()=>typeof window>"u"?!1:$C(window.location.search),[]),r=t?.pathname||"/",s=new URL(window.location.href),o=s.pathname.replace(/\/+$/,"")||"/",u=o.match(/^\/share\/([^/?#]+)$/i)?.[1]||null,d=s.searchParams.get("token")||null,h=u||d,p=o==="/share"||o==="/share.html"||o.startsWith("/share/"),m=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),v=r.replace(/\/+$/,"")||"/",_=v.match(/^\/leaderboard\/u\/([^/]+)$/i),w=_?_[1]:null,y=v==="/leaderboard"||!!w,b=!!(e.enabled&&e.signedIn),T=m||b,A=!1,M=iH(),I=L.useMemo(()=>!e.enabled||!b?null:{getAccessToken:()=>e.getAccessToken(),name:e.displayName||"",userId:e.user?.id||null},[e,b]);let k=m||n||i?"dashboard":"landing";v==="/landing"&&(k="landing"),v==="/dashboard"&&(k="dashboard"),y&&(k="dashboard");const U=v==="/limits";U&&(k="dashboard");const S=v==="/settings";S&&(k="dashboard");const P=v==="/widgets";P&&(k="dashboard");const V=v==="/ip-check";V&&(k="dashboard");const O=w?I$:v==="/leaderboard"?N$:U?U$:S?F$:P?O$:V?B$:D$,J=!p&&(v==="/dashboard"||v==="/"||v==="/leaderboard"||U||S||P||V),H=F.jsx("div",{className:"min-h-screen bg-oai-white dark:bg-[#050505]"});let X=null;if(v==="/auth/callback"||v==="/auth/native-callback")X=F.jsx(v$,{});else if(v==="/login")X=F.jsx(m$,{});else if(k==="landing")X=F.jsx(h$,{signInUrl:"/login",signUpUrl:"/login"});else{const K=F.jsx(L.Suspense,{fallback:H,children:F.jsx(O,{baseUrl:M,auth:I,signedIn:T,sessionSoftExpired:A,signOut:()=>e.enabled?e.signOut():Promise.resolve(),publicMode:p,publicToken:h,userId:w,signInUrl:"/login",signUpUrl:"/login"})});X=J?F.jsx(L$,{children:K}):K}return F.jsx(TF,{children:F.jsx(LF,{children:F.jsxs(DF,{children:[X,F.jsx(tH,{}),F.jsx(TU,{}),F.jsx(FU,{})]})})})}const V$=OL([{path:"*",element:F.jsx(z$,{})}]);T2.createRoot(document.getElementById("root")).render(F.jsx(hs.StrictMode,{children:F.jsx(fU,{children:F.jsx(JL,{router:V$})})}));export{jU as $,pT as A,Ct as B,y$ as C,F as D,gy as E,YU as F,LT as G,Ov as H,uF as I,mh as J,WS as K,HS as L,jy as M,EX as N,my as O,Ml as P,py as Q,BE as R,ZL as S,wT as T,pF as U,$S as V,Kl as W,AT as X,GS as Y,ET as Z,OU as _,pi as a,GU as a0,BU as a1,f0 as a2,TT as a3,bX as a4,HU as a5,SX as a6,MT as a7,wX as a8,Us as a9,vr as aA,Au as aB,kX as aC,RI as aD,Y$ as aE,LX as aF,dX as aG,q$ as aH,fX as aI,hH as aJ,H0 as aK,tV as aL,_X as aM,vy as aN,UT as aO,MX as aP,PX as aQ,TX as aR,AX as aS,CX as aT,PC as aU,CC as aV,Jz as aW,BS as aX,uX as aY,PI as aZ,Aa as a_,Lz as aa,Il as ab,rF as ac,hs as ad,RC as ae,sX as af,rX as ag,zT as ah,Do as ai,E5 as aj,No as ak,DX as al,cX as am,$C as an,Ta as ao,hX as ap,Z$ as aq,J$ as ar,aX as as,HI as at,Q$ as au,eX as av,pX as aw,iX as ax,uH as ay,Mn as az,VT as b,Ia as c,dw as d,br as e,An as f,mT as g,xr as h,PO as i,K$ as j,UI as k,xX as l,Gl as m,WI as n,$I as o,gX as p,nX as q,L as r,lX as s,vX as t,yy as u,yX as v,tX as w,kn as x,oX as y,mX as z};
4975
+ }`;function n$({raysOrigin:t="top-center",raysColor:e="#ffffff",raysSpeed:n=1,lightSpread:i=1,rayLength:r=2,pulsating:s=!1,fadeDistance:o=1,saturation:c=1,followMouse:u=!0,mouseInfluence:d=.1,noiseAmount:h=0,distortion:p=0,className:m=""}){const v=L.useRef(null),_=L.useRef(null),w=L.useRef(null),y=L.useRef({x:.5,y:.5}),b=L.useRef({x:.5,y:.5}),T=L.useRef(null),A=L.useRef(null),M=L.useRef(null),[I,k]=L.useState(!1),U=L.useRef(null);return L.useEffect(()=>{if(v.current)return U.current=new IntersectionObserver(S=>{k(S[0].isIntersecting)},{threshold:.1}),U.current.observe(v.current),()=>{U.current&&(U.current.disconnect(),U.current=null)}},[]),L.useEffect(()=>!I||!v.current?void 0:(M.current&&(M.current(),M.current=null),(async()=>{if(!v.current||(await new Promise(Q=>setTimeout(Q,10)),!v.current))return;const P=new e7({dpr:Math.min(window.devicePixelRatio,2),alpha:!0});w.current=P;const V=P.gl;for(V.canvas.style.width="100%",V.canvas.style.height="100%";v.current.firstChild;)v.current.removeChild(v.current.firstChild);v.current.appendChild(V.canvas);const O={iTime:{value:0},iResolution:{value:[1,1]},rayPos:{value:[0,0]},rayDir:{value:[0,1]},raysColor:{value:LE(e)},raysSpeed:{value:n},lightSpread:{value:i},rayLength:{value:r},pulsating:{value:s?1:0},fadeDistance:{value:o},saturation:{value:c},mousePos:{value:[.5,.5]},mouseInfluence:{value:d},noiseAmount:{value:h},distortion:{value:p}};_.current=O;const G=new Q7(V),J=new YW(V,{vertex:e$,fragment:t$,uniforms:O}),H=new J7(V,{geometry:G,program:J});A.current=H;const X=()=>{if(!v.current||!P)return;P.dpr=Math.min(window.devicePixelRatio,2);const{clientWidth:Q,clientHeight:W}=v.current;P.setSize(Q,W);const q=P.dpr,Z=Q*q,z=W*q;O.iResolution.value=[Z,z];const{anchor:ie,dir:we}=DE(t,Z,z);O.rayPos.value=ie,O.rayDir.value=we},K=Q=>{if(!(!w.current||!_.current||!A.current)){O.iTime.value=Q*.001,u&&d>0&&(b.current.x=b.current.x*.92+y.current.x*(1-.92),b.current.y=b.current.y*.92+y.current.y*(1-.92),O.mousePos.value=[b.current.x,b.current.y]);try{P.render({scene:H}),T.current=requestAnimationFrame(K)}catch(W){console.warn("WebGL rendering error:",W)}}};window.addEventListener("resize",X),X(),T.current=requestAnimationFrame(K),M.current=()=>{if(T.current&&(cancelAnimationFrame(T.current),T.current=null),window.removeEventListener("resize",X),P)try{const Q=P.gl.getExtension("WEBGL_lose_context");Q&&Q.loseContext();const W=P.gl.canvas;W&&W.parentNode&&W.parentNode.removeChild(W)}catch(Q){console.warn("Error during WebGL cleanup:",Q)}w.current=null,_.current=null,A.current=null}})(),()=>{M.current&&(M.current(),M.current=null)}),[I,t,e,n,i,r,s,o,c,u,d,h,p]),L.useEffect(()=>{if(!_.current||!v.current||!w.current)return;const S=_.current,P=w.current;S.raysColor.value=LE(e),S.raysSpeed.value=n,S.lightSpread.value=i,S.rayLength.value=r,S.pulsating.value=s?1:0,S.fadeDistance.value=o,S.saturation.value=c,S.mouseInfluence.value=d,S.noiseAmount.value=h,S.distortion.value=p;const{clientWidth:V,clientHeight:O}=v.current,G=P.dpr,{anchor:J,dir:H}=DE(t,V*G,O*G);S.rayPos.value=J,S.rayDir.value=H},[e,n,i,t,r,s,o,c,d,h,p]),L.useEffect(()=>{if(!u)return;const S=P=>{if(!v.current)return;const V=v.current.getBoundingClientRect();y.current={x:(P.clientX-V.left)/V.width,y:(P.clientY-V.top)/V.height}};return window.addEventListener("mousemove",S),()=>window.removeEventListener("mousemove",S)},[u]),F.jsx("div",{ref:v,className:`w-full h-full pointer-events-none z-[3] overflow-hidden relative ${m}`.trim()})}function i$({className:t}){return F.jsx("svg",{viewBox:"0 0 384 512",className:t,fill:"currentColor",children:F.jsx("path",{d:"M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"})})}function r$({className:t}){return F.jsx("svg",{viewBox:"0 0 16 16",className:t,fill:"currentColor",children:F.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"})})}function s$({className:t}){return F.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[F.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),F.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function a$({className:t}){return F.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:F.jsx("polyline",{points:"20 6 9 17 4 12"})})}const NE="https://github.com/mm7894215/TokenTracker",o$="https://github.com/mm7894215/TokenTracker/releases/latest";function l$(t="default",e="md",n){const i="inline-flex items-center justify-center rounded font-medium transition-colors duration-200 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-oai-gray-950",r={default:"bg-oai-gray-900 text-white hover:bg-oai-gray-800 active:bg-oai-gray-950 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 dark:active:bg-oai-gray-200",ghost:"text-oai-gray-600 hover:text-oai-gray-900 hover:bg-oai-gray-100 active:bg-oai-gray-200 dark:text-oai-gray-400 dark:hover:text-white dark:hover:bg-oai-gray-800 dark:active:bg-oai-gray-700"},s={sm:"h-9 px-4 text-sm",md:"h-11 px-6 text-sm",lg:"h-12 px-8 text-base"};return Mn(i,r[t],s[e],n)}function c$({copy:t,signInUrl:e,signUpUrl:n,installCommand:i,installCopied:r,onCopyInstallCommand:s}){const o=Lz(),[c,u]=L.useState(!1);L.useEffect(()=>{const w=()=>u(window.scrollY>10);return window.addEventListener("scroll",w,{passive:!0}),()=>window.removeEventListener("scroll",w)},[]);const d=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),{signedIn:h,loading:p}=Do(),m=L.useMemo(()=>({codex:t("landing.v2.models.agent.codex"),claude_code:t("landing.v2.models.agent.claude_code"),cursor:t("landing.v2.models.agent.cursor"),gemini:t("landing.v2.models.agent.gemini"),opencode:t("landing.v2.models.agent.opencode"),openclaw:t("landing.v2.models.agent.openclaw")}),[t]),v=L.useMemo(()=>[{id:"codex",icon:"/brand-logos/codex.svg"},{id:"claude_code",icon:"/brand-logos/claude-code.svg"},{id:"cursor",icon:"/brand-logos/cursor.svg"},{id:"gemini",icon:"/brand-logos/gemini.svg"},{id:"opencode",icon:"/brand-logos/opencode.svg"},{id:"openclaw",icon:"/brand-logos/openclaw.svg"}],[]),_=o?{duration:0}:void 0;return F.jsxs("div",{className:"relative min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark",children:[F.jsx("div",{className:"absolute inset-0 z-0 pointer-events-none",style:{height:"100vh"},children:F.jsx(n$,{raysOrigin:"top-center",raysColor:"#b8b3ff",raysSpeed:1,lightSpread:.5,rayLength:3,pulsating:!1,fadeDistance:1,saturation:1,followMouse:!0,mouseInfluence:.1,noiseAmount:0,distortion:0})}),F.jsx("header",{className:Mn("sticky top-0 z-50 transition-all duration-300",c?"bg-oai-gray-950/80 backdrop-blur-md border-b border-oai-gray-900":"bg-transparent border-b border-transparent"),children:F.jsxs("div",{className:"mx-auto flex h-14 max-w-7xl items-center justify-between px-4 sm:px-6",children:[F.jsxs("div",{className:"flex items-center gap-5",children:[F.jsxs(Us,{to:n||"/",className:"flex items-center gap-3 no-underline outline-none rounded focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:ring-offset-oai-gray-950 transition-opacity hover:opacity-80",children:[F.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),F.jsx("span",{className:"text-sm font-semibold tracking-wide text-white uppercase",children:"Token Tracker"})]}),F.jsx("div",{className:"hidden sm:block",children:F.jsx(hH,{})})]}),d&&F.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 sm:gap-3",children:[F.jsxs(Us,{to:fH(),className:Mn(l$(h||p?"default":"ghost","sm"),"no-underline px-5 rounded-full group",h||p?"shadow-sm ring-1 ring-white/10":"ring-1 ring-oai-gray-700"),children:[t("landing.v2.cta.primary"),F.jsx("span",{className:"ml-2 inline-block transition-transform duration-200 group-hover:translate-x-0.5",children:"→"})]}),F.jsx(H0,{})]})]})}),F.jsxs("main",{children:[F.jsx("section",{className:"relative py-16 sm:py-24 lg:py-32 overflow-hidden",children:F.jsxs("div",{className:"relative z-10 mx-auto max-w-7xl px-4 sm:px-6 flex flex-col items-center text-center gap-20 lg:gap-36",children:[F.jsxs(Il.div,{initial:o?!1:{opacity:0,y:20},animate:{opacity:1,y:0},transition:_||{duration:.5},className:"w-full max-w-3xl relative z-20",children:[F.jsxs("h1",{className:"text-balance text-5xl font-semibold tracking-tight text-white sm:text-6xl lg:text-[4rem] lg:leading-[1.05]",children:[t("landing.v2.hero.title_line1"),F.jsx("br",{}),F.jsx("span",{className:"bg-gradient-to-b from-white via-oai-gray-200 to-oai-gray-500 bg-clip-text text-transparent font-bold tracking-tight",style:{WebkitTextStroke:"1px rgba(255, 255, 255, 0.15)"},children:t("landing.v2.hero.title_line2")})]}),F.jsx("p",{className:"mt-6 text-lg leading-relaxed text-oai-gray-400",children:t("landing.v2.hero.subtagline")}),F.jsxs("div",{className:"mt-8 w-full max-w-lg mx-auto",children:[F.jsxs(Il.div,{whileHover:{scale:1.01,y:-1},transition:{type:"spring",stiffness:400,damping:25},className:"group relative inline-block w-full overflow-hidden rounded-2xl",style:{padding:"1.5px 0"},children:[F.jsx("div",{className:"absolute w-[300%] h-[50%] opacity-70 bottom-[-11px] right-[-250%] rounded-full animate-star-movement-bottom z-0",style:{background:"radial-gradient(circle, #fbdfff, transparent 10%)",animationDuration:"6s"}}),F.jsx("div",{className:"absolute w-[300%] h-[50%] opacity-70 top-[-10px] left-[-250%] rounded-full animate-star-movement-top z-0",style:{background:"radial-gradient(circle, #fbdfff, transparent 10%)",animationDuration:"6s"}}),F.jsxs("div",{className:"relative z-[1] flex items-center justify-between w-full bg-[#0a0a0a] border border-oai-gray-800 rounded-2xl p-1.5 pl-5 shadow-2xl shadow-black/50",children:[F.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[F.jsx("span",{className:"text-oai-gray-600 font-mono select-none","aria-hidden":"true",children:"›"}),F.jsx("code",{className:"font-mono text-sm text-oai-gray-200 overflow-x-auto whitespace-nowrap py-2 [scrollbar-width:none]",children:i?i.split(" ").map((w,y)=>F.jsxs("span",{className:w==="npx"||w==="tokentracker-cli"?"text-white font-medium":w==="--yes"?"text-oai-gray-500":"text-oai-brand-400",children:[w," "]},y)):null})]}),F.jsx("button",{type:"button",onClick:s,"aria-label":t(r?"landing.install.action.copied":"landing.install.action.copy"),className:"shrink-0 flex h-9 w-9 items-center justify-center text-oai-gray-200 bg-oai-gray-900 border border-oai-gray-700 rounded-lg hover:bg-oai-gray-800 hover:text-white active:scale-95 transition-all duration-200 shadow-sm",children:r?F.jsx(a$,{className:"h-4 w-4 text-green-400","aria-hidden":!0}):F.jsx(s$,{className:"h-4 w-4 opacity-70","aria-hidden":!0})})]})]}),F.jsxs("div",{className:"mt-8 flex flex-wrap items-center justify-center gap-x-6 gap-y-4",children:[F.jsxs("a",{href:o$,target:"_blank",rel:"noopener noreferrer",className:"group flex items-center gap-2 text-sm font-medium text-oai-gray-400 hover:text-white transition-colors",children:[F.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-oai-gray-800 group-hover:bg-oai-gray-700 transition-colors",children:F.jsx(i$,{className:"h-4 w-4 text-oai-gray-400 group-hover:text-white"})}),t("landing.v2.install.mac_cta")]}),F.jsxs("a",{href:NE,target:"_blank",rel:"noopener noreferrer",className:"group flex items-center gap-2 text-sm font-medium text-oai-gray-400 hover:text-white transition-colors",children:[F.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-oai-gray-800 group-hover:bg-oai-gray-700 transition-colors",children:F.jsx(r$,{className:"h-4 w-4 text-oai-gray-400 group-hover:text-white"})}),t("landing.cta.secondary")]})]}),F.jsx("span",{className:"sr-only","aria-live":"polite",children:r?t("landing.install.action.copied"):""})]})]}),F.jsx("div",{className:"relative group w-full",children:F.jsxs(Il.div,{initial:o?!1:{opacity:0,y:24},animate:{opacity:1,y:0},transition:_||{duration:.6,delay:.1},className:"relative w-full",children:[F.jsx("div",{style:{position:"absolute",top:"-256px",left:0,right:0,height:"510px",zIndex:3,pointerEvents:"none"},children:F.jsx(PW,{color:"#8a7aff",wispDensity:2,flowSpeed:.28,verticalSizing:2.2,horizontalSizing:1.22,fogIntensity:4,fogScale:.1,wispSpeed:18,wispIntensity:10,flowStrength:.12,decay:1.1,falloffStart:1.1,fogFallSpeed:.5,horizontalBeamOffset:.22,verticalBeamOffset:0,style:{width:"100%",height:"100%"}})}),F.jsx("div",{className:"relative rounded-xl p-[1px] shadow-2xl bg-gradient-to-b from-[rgba(138,122,255,0.6)] via-[rgba(138,122,255,0.15)] to-[rgba(138,122,255,0.05)]",style:{position:"relative",zIndex:10,boxShadow:"0 20px 60px -10px rgba(138,122,255,0.15), 0 4px 20px rgba(0,0,0,0.4)"},children:F.jsxs("div",{className:"relative rounded-[11px] overflow-hidden bg-oai-gray-950",children:[F.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"180px",background:"linear-gradient(to bottom, rgba(138,122,255,0.35) 0%, rgba(138,122,255,0.12) 40%, transparent 100%)",mixBlendMode:"screen",zIndex:20,pointerEvents:"none"}}),F.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"1px",background:"linear-gradient(90deg, transparent 0%, rgba(138,122,255,0.9) 30%, rgba(180,168,255,1) 50%, rgba(138,122,255,0.9) 70%, transparent 100%)",zIndex:25,pointerEvents:"none"}}),F.jsx("img",{src:"/dashboard-dark.png",alt:t("landing.screenshot.alt"),className:"block h-auto w-full object-cover",style:{position:"relative",zIndex:10},loading:"eager",decoding:"async"})]})})]})})]})}),F.jsx("section",{className:"border-y border-oai-gray-900 bg-oai-gray-950/50 py-12 lg:py-16",children:F.jsx("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:F.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-8",children:[F.jsx("p",{className:"text-sm font-semibold uppercase tracking-wider text-oai-gray-400 shrink-0",children:t("landing.v2.models.title")}),F.jsx("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-6 opacity-60 hover:opacity-100 transition-opacity duration-500 grayscale hover:grayscale-0",children:v.map(w=>F.jsxs("div",{className:"flex items-center gap-2.5 transition-transform hover:-translate-y-0.5 duration-300",children:[F.jsx("img",{src:w.icon,alt:"",width:20,height:20,className:`h-5 w-5 object-contain ${w.id==="cursor"?"dark:invert":""}`,loading:"lazy"}),F.jsx("span",{className:"text-sm font-medium text-oai-gray-300",children:m[w.id]})]},w.id))})]})})}),F.jsx("section",{className:"py-20 lg:py-32",children:F.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6 grid grid-cols-1 md:grid-cols-2 gap-16 lg:gap-24 items-start",children:[F.jsxs("div",{className:"max-w-md",children:[F.jsx("p",{className:"text-xs font-bold tracking-widest uppercase text-oai-brand-500 mb-4",children:t("landing.v2.compare.kicker")}),F.jsx("h2",{className:"text-3xl font-semibold tracking-tight text-white sm:text-4xl text-balance",children:t("landing.v2.compare.title")}),F.jsx("p",{className:"mt-6 text-lg leading-relaxed text-oai-gray-400",children:t("landing.v2.compare.subtitle")}),F.jsx("p",{className:"mt-6 text-base leading-relaxed text-oai-gray-500",children:t("landing.v2.distill.body")})]}),F.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-10",children:[F.jsxs("div",{className:"space-y-4",children:[F.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-white border-b border-oai-gray-800 pb-3",children:t("landing.v2.compare.with.title")}),F.jsxs("ul",{className:"space-y-3 text-sm text-oai-gray-400",children:[F.jsxs("li",{className:"flex gap-2",children:[F.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),F.jsx("span",{children:t("landing.v2.compare.with.p1")})]}),F.jsxs("li",{className:"flex gap-2",children:[F.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),F.jsx("span",{children:t("landing.v2.compare.with.p2")})]}),F.jsxs("li",{className:"flex gap-2",children:[F.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),F.jsx("span",{children:t("landing.v2.compare.with.p3")})]})]})]}),F.jsxs("div",{className:"space-y-4",children:[F.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-oai-gray-500 border-b border-oai-gray-800/50 pb-3",children:t("landing.v2.compare.without.title")}),F.jsxs("ul",{className:"space-y-3 text-sm text-oai-gray-500",children:[F.jsxs("li",{className:"flex gap-2",children:[F.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),F.jsx("span",{children:t("landing.v2.compare.without.p1")})]}),F.jsxs("li",{className:"flex gap-2",children:[F.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),F.jsx("span",{children:t("landing.v2.compare.without.p2")})]}),F.jsxs("li",{className:"flex gap-2",children:[F.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),F.jsx("span",{children:t("landing.v2.compare.without.p3")})]})]})]})]})]})})]}),F.jsx("footer",{className:"border-t border-oai-gray-900 bg-oai-gray-950 py-12",children:F.jsxs("div",{className:"mx-auto flex max-w-6xl flex-col items-center justify-between gap-6 px-4 sm:px-6 text-sm text-oai-gray-400 sm:flex-row",children:[F.jsx("p",{children:t("landing.v2.footer.line")}),F.jsxs("div",{className:"flex items-center gap-6",children:[F.jsx("a",{href:NE,className:"font-medium text-oai-gray-400 hover:text-white transition-colors",target:"_blank",rel:"noopener noreferrer",children:t("landing.v2.nav.github")}),d&&F.jsxs(Us,{to:e,className:"font-medium text-oai-brand-500 hover:text-oai-brand-400 transition-colors",children:[t("landing.cta.primary")," →"]})]})]})})]})}function u$({prefersReducedMotion:t,screenshotMode:e}){return!(e||t)}function d$(){return L.useMemo(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function f$(t=0,e=!0){const[n,i]=L.useState(()=>!e);return L.useEffect(()=>{if(!e){i(!0);return}let r=null,s=null;const o=()=>i(!0);return typeof window<"u"&&"requestIdleCallback"in window?(s=window.requestIdleCallback(o,{timeout:t||200}),()=>{typeof window.cancelIdleCallback=="function"&&s!=null&&window.cancelIdleCallback(s)}):(r=window.setTimeout(o,t),()=>{r!=null&&window.clearTimeout(r)})},[t,e]),n}function h$({signInUrl:t,signUpUrl:e}){const n=Ct("landing.handle.special"),i=Ct("landing.handle.default");Ct("landing.nav.login"),Ct("landing.nav.signup");const[r,s]=L.useState(i),o=d$(),c=L.useMemo(()=>typeof window>"u"?!1:$C(window.location.search),[]),u=u$({prefersReducedMotion:o,screenshotMode:c});f$(250,u);const d="tokentracker.dashboard.from_landing.v1";L.useEffect(()=>{if(!(typeof window>"u"))try{window.sessionStorage.setItem(d,"1")}catch{}},[d]),L.useMemo(()=>Ct("landing.handle.placeholder",{handle:n}),[n]),L.useMemo(()=>{const _=Ct(r===n?"landing.rank.singularity":"landing.rank.unranked");return Ct("landing.rank.expectation",{rank:_})},[r,n]);const h=Ct("landing.install.command"),[p,m]=L.useState(!1),v=async()=>{await uH(h)&&(m(!0),window.setTimeout(()=>m(!1),2e3))};return F.jsx(c$,{copy:Ct,reduceMotion:o,signInUrl:t,signUpUrl:e,installCommand:h,installCopied:p,onCopyInstallCommand:v})}function p$(t){const e=new URLSearchParams(t).get("next");return typeof e!="string"||e.length===0||!e.startsWith("/")||e.startsWith("//")?"/dashboard":e}const IE={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",linkedin:"LinkedIn",facebook:"Facebook",instagram:"Instagram",tiktok:"TikTok",apple:"Apple",x:"X",spotify:"Spotify"};function UE(t){const e=String(t||"").trim();return IE[e]?IE[e]:e.replace(/-/g," ")}function m$(){const t=Au(),[e,n]=WL(),{enabled:i,loading:r,signedIn:s,refreshUser:o,signInWithPassword:c,signUp:u,signInWithOAuth:d,getPublicAuthConfig:h}=Do(),p=L.useMemo(()=>p$(e.toString()),[e]),[m,v]=L.useState("signin"),[_,w]=L.useState(""),[y,b]=L.useState(""),[T,A]=L.useState(""),[M,I]=L.useState(!1),[k,U]=L.useState(null),[S,P]=L.useState(null),[V,O]=L.useState(!0),[G,J]=L.useState([]),[H,X]=L.useState([]),[K,Q]=L.useState(8);L.useEffect(()=>{const Se=e.get("insforge_status"),ne=e.get("insforge_type"),ye=e.get("insforge_error");Se==="success"&&ne==="verify_email"?P(Ct("login.verify_email_success")):Se==="error"&&ne==="verify_email"&&ye&&P(Ct("shared.error.prefix",{error:ye}))},[e]),L.useEffect(()=>{if(!i){O(!1);return}let Se=!0;return(async()=>{const{data:ne,error:ye}=await h();Se&&(ye||!ne?(J(["google","github"]),X([])):(J(Array.isArray(ne.oAuthProviders)?ne.oAuthProviders:[]),X(Array.isArray(ne.customOAuthProviders)?ne.customOAuthProviders:[]),typeof ne.passwordMinLength=="number"&&ne.passwordMinLength>0&&Q(ne.passwordMinLength)),O(!1))})(),()=>{Se=!1}},[i,h]);const W=L.useMemo(()=>e.get("native")==="1",[e]),q=L.useMemo(()=>e.get("provider")||null,[e]);L.useEffect(()=>{if(!(!i||r)&&s){if(W){window.location.href="/auth/native-callback";return}t(p,{replace:!0})}},[i,r,s,t,p,W]),L.useEffect(()=>{i&&o()},[i,o]);const Z=L.useMemo(()=>typeof window>"u"||W?"":`${window.location.origin}/`,[W]),z=L.useMemo(()=>typeof window>"u"?"":`${window.location.origin}/`,[]),ie=L.useCallback(async Se=>{Se.preventDefault(),U(null),I(!0);try{if(m==="signup"){const{data:ye,error:be}=await u({email:_.trim(),password:y,name:T.trim()||void 0,redirectTo:z});if(be){U(be.message||String(be));return}if(ye?.requireEmailVerification){P(Ct("login.verify_email_pending")),v("signin");return}t(p,{replace:!0});return}const{error:ne}=await c({email:_.trim(),password:y});if(ne){U(ne.message||String(ne));return}t(p,{replace:!0})}finally{I(!1)}},[m,_,y,T,u,c,t,p,z]),we=L.useCallback(async Se=>{U(null),I(!0);try{const{error:ne}=await d(Se,Z);ne&&U(ne.message||String(ne))}finally{I(!1)}},[d,Z]);L.useEffect(()=>{if(W&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[W]),L.useEffect(()=>{if(!i||r||s||V||!W||!q)return;[...G,...H].includes(q)&&we(q)},[i,r,s,V,W,q,G,H,we]);const He=L.useCallback(()=>{n(Se=>{const ne=new URLSearchParams(Se);return ne.delete("insforge_status"),ne.delete("insforge_type"),ne.delete("insforge_error"),ne},{replace:!0}),P(null)},[n]);return i?F.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[F.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:F.jsx(Us,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 rounded",children:Ct("login.back_home")})}),F.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:F.jsxs("div",{className:"w-full max-w-md space-y-8",children:[F.jsxs("div",{className:"text-center",children:[F.jsx("h1",{className:"text-2xl font-semibold text-white tracking-tight",children:Ct("login.title")}),F.jsx("p",{className:"mt-2 text-sm text-oai-gray-500",children:Ct("login.subtitle")})]}),S?F.jsxs("div",{className:"rounded-lg border border-oai-gray-800 bg-oai-gray-900/50 px-4 py-3 text-sm text-oai-gray-300 flex justify-between gap-3 items-start",role:"status",children:[F.jsx("span",{children:S}),F.jsx("button",{type:"button",onClick:He,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:Ct("login.dismiss")})]}):null,k?F.jsx("p",{className:"text-sm text-red-400",role:"alert",children:Ct("shared.error.prefix",{error:k})}):null,F.jsx("div",{className:"space-y-3",children:V?F.jsx("div",{className:"h-11 rounded-lg bg-oai-gray-900 animate-pulse","aria-hidden":!0}):F.jsxs(F.Fragment,{children:[G.map(Se=>F.jsx("button",{type:"button",disabled:M,onClick:()=>we(Se),className:Mn("w-full h-11 rounded-lg border border-oai-gray-700 bg-oai-gray-900 text-sm font-medium text-white","hover:bg-oai-gray-800 transition-colors disabled:opacity-50"),children:Ct("login.oauth.continue",{provider:UE(Se)})},Se)),H.map(Se=>F.jsx("button",{type:"button",disabled:M,onClick:()=>we(Se),className:Mn("w-full h-11 rounded-lg border border-oai-gray-700 bg-oai-gray-900 text-sm font-medium text-white","hover:bg-oai-gray-800 transition-colors disabled:opacity-50"),children:Ct("login.oauth.continue",{provider:UE(Se)})},Se))]})}),F.jsxs("div",{className:"relative",children:[F.jsx("div",{className:"absolute inset-0 flex items-center","aria-hidden":!0,children:F.jsx("span",{className:"w-full border-t border-oai-gray-800"})}),F.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:F.jsx("span",{className:"bg-oai-gray-950 px-3 text-oai-gray-600",children:Ct("login.divider")})})]}),F.jsxs("div",{className:"flex rounded-lg border border-oai-gray-800 p-0.5 bg-oai-gray-900/50",children:[F.jsx("button",{type:"button",className:Mn("flex-1 py-2 text-sm font-medium rounded-md transition-colors",m==="signin"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{v("signin"),U(null)},children:Ct("login.tab.sign_in")}),F.jsx("button",{type:"button",className:Mn("flex-1 py-2 text-sm font-medium rounded-md transition-colors",m==="signup"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{v("signup"),U(null)},children:Ct("login.tab.sign_up")})]}),F.jsxs("form",{onSubmit:ie,className:"space-y-4",children:[m==="signup"?F.jsxs("div",{children:[F.jsx("label",{htmlFor:"login-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:Ct("login.field.name")}),F.jsx("input",{id:"login-name",type:"text",autoComplete:"name",value:T,onChange:Se=>A(Se.target.value),className:"w-full h-11 rounded-lg border border-oai-gray-800 bg-oai-gray-900 px-3 text-sm text-white placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500",placeholder:Ct("login.field.name_placeholder")})]}):null,F.jsxs("div",{children:[F.jsx("label",{htmlFor:"login-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:Ct("login.field.email")}),F.jsx("input",{id:"login-email",type:"email",autoComplete:"email",required:!0,value:_,onChange:Se=>w(Se.target.value),className:"w-full h-11 rounded-lg border border-oai-gray-800 bg-oai-gray-900 px-3 text-sm text-white placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),F.jsxs("div",{children:[F.jsx("label",{htmlFor:"login-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:Ct("login.field.password")}),F.jsx("input",{id:"login-password",type:"password",autoComplete:m==="signup"?"new-password":"current-password",required:!0,minLength:m==="signup"?K:void 0,value:y,onChange:Se=>b(Se.target.value),className:"w-full h-11 rounded-lg border border-oai-gray-800 bg-oai-gray-900 px-3 text-sm text-white placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"}),m==="signup"?F.jsx("p",{className:"mt-1 text-xs text-oai-gray-600",children:Ct("login.password_hint",{min:String(K)})}):null]}),F.jsx("button",{type:"submit",disabled:M||r,className:"w-full h-11 rounded-lg bg-white text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:Ct(m==="signup"?"login.submit.sign_up":"login.submit.sign_in")})]})]})})]}):F.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[F.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:F.jsx(Us,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:Ct("login.back_home")})}),F.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:F.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",children:Ct("login.cloud_only")})})]})}const g$=typeof window<"u"?window.location.search:"",FE=new URLSearchParams(g$),Mf=FE.get("insforge_code")||FE.get("code")||null;function v$(){const{loading:t,signedIn:e}=Do(),n=Au(),[i,r]=L.useState("processing"),[s,o]=L.useState(null),c=L.useRef(!1);return L.useEffect(()=>{!Mf||c.current||(c.current=!0,(async()=>{try{const d=await(await fetch("/api/auth-bridge/verifier")).json();o(!!d?.native)}catch{o(!1)}})())},[]),L.useEffect(()=>{if(s!==!0||!Mf)return;r("redirecting");const u=setTimeout(()=>{window.location.href=`tokentracker://auth/callback?insforge_code=${encodeURIComponent(Mf)}`},200);return()=>clearTimeout(u)},[s]),L.useEffect(()=>{if(s!==!1||t)return;if(e){n("/dashboard",{replace:!0});return}const u=setTimeout(()=>{e||r("failed")},5e3);return()=>clearTimeout(u)},[s,t,e,n]),L.useEffect(()=>{if(!Mf&&s===null){const u=setTimeout(()=>r("failed"),3e3);return()=>clearTimeout(u)}},[s]),i==="processing"&&s!==!0&&(s===null||s===!1&&t)?F.jsx("div",{className:"min-h-screen bg-oai-gray-950"}):F.jsx("div",{className:"min-h-screen bg-oai-gray-950 text-white font-oai antialiased dark flex items-center justify-center",children:F.jsxs("div",{className:"text-center space-y-4 max-w-sm px-4",children:[i==="processing"&&F.jsxs(F.Fragment,{children:[F.jsx("div",{className:"w-8 h-8 border-2 border-oai-gray-600 border-t-white rounded-full animate-spin mx-auto"}),F.jsx("p",{className:"text-oai-gray-400 text-sm",children:"Processing…"})]}),i==="redirecting"&&F.jsxs(F.Fragment,{children:[F.jsx("div",{className:"w-12 h-12 mx-auto rounded-full bg-green-500/15 flex items-center justify-center",children:F.jsx("svg",{className:"w-6 h-6 text-green-400",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:F.jsx("path",{d:"M20 6 9 17l-5-5"})})}),F.jsx("p",{className:"text-white text-sm font-medium",children:"Signed in successfully"}),F.jsx("p",{className:"text-oai-gray-500 text-xs",children:"Returning to TokenTracker…"})]}),i==="failed"&&F.jsxs("div",{className:"space-y-3",children:[F.jsx("p",{className:"text-oai-gray-300 text-sm",children:"Sign-in incomplete. Please try again."}),F.jsx("button",{type:"button",onClick:()=>window.close(),className:"px-4 py-2 rounded-lg bg-oai-gray-800 text-sm text-white hover:bg-oai-gray-700 transition-colors",children:"Close this page"})]})]})})}function y$(){const t=L.useContext(OT);if(t===null)throw new Error("useTheme must be used within a ThemeProvider");return t}const Fv="tt.sidebarCollapsed";function _$(){return[{id:"general",label:Ct("nav.group.general"),items:[{id:"usage",to:"/dashboard",icon:zz,label:Ct("nav.usage")},{id:"limits",to:"/limits",icon:Hz,label:Ct("nav.limits")},{id:"leaderboard",to:"/leaderboard",icon:rV,label:Ct("nav.leaderboard")}]},{id:"tools",label:Ct("nav.group.tools"),items:[{id:"widgets",to:"/widgets",icon:$z,label:Ct("nav.widgets")},{id:"ip-check",to:"/ip-check",icon:jz,label:"Claude IP Check"}]},{id:"account",label:Ct("nav.group.account"),items:[{id:"settings",to:"/settings",icon:tV,label:Ct("nav.settings")}]}]}function x$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Fv)==="1"}catch{return!1}}function b$(){const[t,e]=L.useState(x$),n=L.useCallback(()=>{e(i=>{const r=!i;try{typeof window<"u"&&window.localStorage.setItem(Fv,r?"1":"0")}catch{}return r})},[]);return L.useEffect(()=>{if(typeof window>"u")return;const i=r=>{r.key===Fv&&e(r.newValue==="1")};return window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[]),{collapsed:t,toggle:n}}function S$(t,e){const n=t.replace(/\/+$/,"")||"/";return e==="/dashboard"?n==="/dashboard"||n==="/":e==="/leaderboard"?n==="/leaderboard"||n.startsWith("/leaderboard/"):n===e}function w$({label:t,collapsed:e,first:n}){return e?n?null:F.jsx("div",{className:"mx-2 my-2 h-px bg-oai-gray-200/70 dark:bg-oai-gray-800/70","aria-hidden":!0}):F.jsx("div",{className:Mn("px-3 pb-1 text-[10px] uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-500",n?"pt-2":"pt-4"),children:t})}function E$({item:t,collapsed:e,active:n,onClick:i}){const r=t.icon;return F.jsxs(Us,{to:t.to,onClick:i,title:e?t.label:void 0,"aria-current":n?"page":void 0,className:Mn("flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px] no-underline transition-colors",e&&"justify-center px-0 py-2",n?"bg-oai-gray-200/70 text-oai-black font-medium dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/50 hover:text-oai-black dark:hover:bg-oai-gray-800/60 dark:hover:text-white"),children:[F.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:F.jsx(r,{className:"h-[15px] w-[15px]","aria-hidden":!0})}),!e&&F.jsx("span",{className:"truncate",children:t.label})]})}function M$({as:t="button",title:e,onClick:n,href:i,children:r,className:s,...o}){const c=Mn("flex h-10 w-10 items-center justify-center rounded-lg text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",s);return t==="a"?F.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",title:e,"aria-label":e,className:c,...o,children:r}):F.jsx("button",{type:"button",title:e,"aria-label":e,onClick:n,className:c,...o,children:r})}function T$({repo:t="mm7894215/TokenTracker",glassChrome:e=!1}){const[n,i]=L.useState(null);return L.useEffect(()=>{if(typeof window>"u")return;const r=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;ZC({prefersReducedMotion:r,screenshotCapture:!1})&&fetch(`https://api.github.com/repos/${t}`).then(s=>s.json()).then(s=>{s&&typeof s.stargazers_count=="number"&&i(s.stargazers_count)}).catch(()=>{})},[t]),F.jsxs("a",{href:`https://github.com/${t}`,target:"_blank",rel:"noopener noreferrer","aria-label":n!==null?`Star on GitHub (${n})`:"Star on GitHub",className:Mn("inline-flex h-7 items-center gap-1.5 rounded-full px-2.5 text-xs font-medium transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"border border-gray-500/20 dark:border-gray-500/30 bg-gray-500/[0.04] dark:bg-gray-500/[0.06] backdrop-blur-[2px] text-oai-gray-700 dark:text-oai-gray-300 hover:bg-gray-500/10 dark:hover:bg-gray-500/12 hover:border-gray-500/30 dark:hover:border-gray-500/40 hover:text-oai-black dark:hover:text-white":"border border-oai-gray-200 dark:border-oai-gray-700 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white hover:border-oai-gray-300 dark:hover:border-oai-gray-600"),children:[F.jsx("svg",{height:"12",viewBox:"0 0 16 16",width:"12",className:"shrink-0 fill-current",children:F.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"})}),F.jsx("span",{children:"Star"}),n!==null&&F.jsx("span",{className:"text-[10px] text-oai-gray-500 dark:text-oai-gray-500 tabular-nums",children:n})]})}const A$=[{value:"light",label:"Light",Icon:PC},{value:"dark",label:"Dark",Icon:CC},{value:"system",label:"System",Icon:Jz}];function C$({theme:t,resolvedTheme:e,onSetTheme:n,glassChrome:i=!1}){const[r,s]=L.useState(!1),o=L.useRef(null),c=e==="dark"?CC:PC;return L.useEffect(()=>{if(!r)return;const u=h=>{o.current&&!o.current.contains(h.target)&&s(!1)},d=h=>{h.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",d)}},[r]),F.jsxs("div",{ref:o,className:"relative",children:[F.jsx("button",{type:"button","aria-label":"Theme","aria-expanded":r,"aria-haspopup":"menu",title:"Theme",onClick:()=>s(u=>!u),className:Mn("inline-flex h-7 w-7 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",i?"border border-gray-500/20 dark:border-gray-500/30 bg-gray-500/[0.04] dark:bg-gray-500/[0.06] backdrop-blur-[2px] text-oai-gray-700 dark:text-oai-gray-300 hover:bg-gray-500/10 dark:hover:bg-gray-500/12 hover:border-gray-500/30 dark:hover:border-gray-500/40 hover:text-oai-black dark:hover:text-white":"border border-oai-gray-200 dark:border-oai-gray-700 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white hover:border-oai-gray-300 dark:hover:border-oai-gray-600"),children:F.jsx(c,{className:"h-3.5 w-3.5","aria-hidden":!0})}),r&&F.jsx("div",{role:"menu",className:"absolute bottom-full left-0 mb-2 z-50 min-w-[140px] py-1 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-lg",children:A$.map(({value:u,label:d,Icon:h})=>{const p=t===u;return F.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{n(u),s(!1)},className:Mn("flex w-full items-center gap-2.5 px-3 py-1.5 text-[13px] transition-colors",p?"text-oai-black dark:text-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 hover:text-oai-black dark:hover:text-white"),children:[F.jsx(h,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),F.jsx("span",{children:d})]},u)})})]})}function OP({collapsed:t,onToggleCollapsed:e,onItemClick:n,showCloseButton:i=!1,onClose:r,glassChrome:s=!1}){const c=vr()?.pathname||"/",{theme:u,resolvedTheme:d,setTheme:h}=y$(),p=L.useMemo(()=>_$(),[]);return F.jsxs(F.Fragment,{children:[F.jsx("div",{className:Mn("px-2 pt-2 pb-2",t&&"flex justify-center"),children:i?F.jsxs("div",{className:"flex items-center gap-2",children:[F.jsx("div",{className:"flex-1 min-w-0",children:F.jsx(H0,{variant:"sidebar",collapsed:t,onAfterAction:n})}),F.jsx("button",{type:"button",onClick:r,"aria-label":Ct("nav.close_menu"),title:Ct("nav.close_menu"),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-500 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-gray-900 dark:hover:text-oai-gray-200 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:F.jsx(RC,{className:"h-4 w-4",strokeWidth:1.75,"aria-hidden":!0})})]}):F.jsx(H0,{variant:"sidebar",collapsed:t,onAfterAction:n})}),F.jsx("nav",{"aria-label":Ct("nav.nav_label"),className:"flex-1 px-2 pb-2 flex flex-col overflow-y-auto",children:p.map((m,v)=>F.jsxs("div",{className:"flex flex-col",children:[F.jsx(w$,{label:m.label,collapsed:t,first:v===0}),F.jsx("div",{className:"flex flex-col gap-0.5",children:m.items.map(_=>F.jsx(E$,{item:_,collapsed:t,active:S$(c,_.to),onClick:n},_.id))})]},m.id))}),F.jsxs("div",{className:Mn("flex items-center px-2 py-3",t?"flex-col justify-center gap-2":"justify-between gap-2"),children:[F.jsx(C$,{theme:u,resolvedTheme:d,onSetTheme:h,glassChrome:s}),F.jsx("div",{className:"flex items-center gap-1.5",children:!t&&F.jsx(T$,{glassChrome:s})})]})]})}function P$({collapsed:t,onToggleCollapsed:e}){const n=L.useMemo(()=>typeof window>"u"?!1:Aa()||UT(),[]);return F.jsx("aside",{"aria-label":Ct("nav.aside_label"),className:Mn("hidden lg:flex flex-col shrink-0 h-full min-h-0 transition-[width] duration-200",t?"w-[72px]":"w-[220px]"),children:F.jsx(OP,{collapsed:t,onToggleCollapsed:e,glassChrome:n})})}function R$({open:t,onClose:e}){return L.useEffect(()=>{if(!t)return;const n=i=>{i.key==="Escape"&&e()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[t,e]),L.useEffect(()=>{if(!t)return;const n=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=n}},[t]),t?F.jsxs("div",{className:"lg:hidden fixed inset-0 z-[80] flex",children:[F.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:e,"aria-hidden":!0}),F.jsx("aside",{"aria-label":Ct("nav.aside_label"),className:"relative w-[260px] max-w-[80vw] flex flex-col bg-oai-white dark:bg-oai-gray-900 border-r border-oai-gray-200 dark:border-oai-gray-800 shadow-2xl",children:F.jsx(OP,{collapsed:!1,showCloseButton:!0,onClose:e,onItemClick:e})})]}):null}function k$({onOpenDrawer:t}){return F.jsxs("div",{className:"lg:hidden flex items-center justify-between gap-2 px-3 h-14 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[F.jsx(M$,{title:Ct("nav.menu"),onClick:t,children:F.jsx(Kz,{className:"h-5 w-5","aria-hidden":!0})}),F.jsxs(Us,{to:"/landing",className:"flex items-center gap-2 no-underline hover:opacity-80 transition-opacity","aria-label":"Token Tracker",children:[F.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),F.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white",children:"Token Tracker"})]}),F.jsx("div",{className:"w-10 shrink-0","aria-hidden":!0})]})}function L$({children:t}){const{collapsed:e,toggle:n}=b$(),[i,r]=L.useState(!1),s=L.useCallback(()=>r(!0),[]),o=L.useCallback(()=>r(!1),[]),c=L.useMemo(()=>typeof window>"u"?!1:Aa()||UT(),[]);return F.jsxs("div",{className:Mn("fixed inset-0 flex flex-col text-oai-black dark:text-oai-white font-sans overflow-hidden",c?"bg-transparent":"bg-oai-gray-100 dark:bg-oai-gray-950"),children:[c&&F.jsx("div",{className:"h-7 shrink-0",style:{WebkitAppRegion:"drag"},"aria-hidden":!0}),F.jsxs("div",{className:"flex-1 min-h-0 flex",children:[F.jsx(P$,{collapsed:e,onToggleCollapsed:n}),F.jsx(R$,{open:i,onClose:o}),F.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-2 lg:pl-0 lg:pr-3 lg:pb-3 flex flex-col",children:F.jsxs("div",{className:Mn("flex-1 min-h-0 flex flex-col bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",c?"tt-native-main-card":"rounded-2xl",!c&&"shadow-sm"),children:[F.jsx(k$,{onOpenDrawer:s}),F.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:t})]})})]})]})}const D$=hs.lazy(()=>No(()=>import("./DashboardPage-DP4h327m.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.DashboardPage}))),N$=hs.lazy(()=>No(()=>import("./LeaderboardPage-D_DqH7v4.js"),__vite__mapDeps([5,4,6])).then(t=>({default:t.LeaderboardPage}))),I$=hs.lazy(()=>No(()=>import("./LeaderboardProfilePage-B4U6R6TW.js"),__vite__mapDeps([7,6])).then(t=>({default:t.LeaderboardProfilePage}))),U$=hs.lazy(()=>No(()=>import("./LimitsPage-WP9IFHnS.js"),__vite__mapDeps([8,1,9,2,3])).then(t=>({default:t.LimitsPage}))),F$=hs.lazy(()=>No(()=>import("./SettingsPage-BzWrP1qX.js"),__vite__mapDeps([10,9,2,11])).then(t=>({default:t.SettingsPage}))),O$=hs.lazy(()=>No(()=>import("./WidgetsPage-BbV32pxZ.js"),__vite__mapDeps([12,3,11])).then(t=>({default:t.WidgetsPage}))),B$=hs.lazy(()=>No(()=>import("./IpCheckPage-DKErP77B.js"),[]));function z$(){const t=vr(),e=Do();lH();const n=xr(),i=L.useMemo(()=>typeof window>"u"?!1:$C(window.location.search),[]),r=t?.pathname||"/",s=new URL(window.location.href),o=s.pathname.replace(/\/+$/,"")||"/",u=o.match(/^\/share\/([^/?#]+)$/i)?.[1]||null,d=s.searchParams.get("token")||null,h=u||d,p=o==="/share"||o==="/share.html"||o.startsWith("/share/"),m=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),v=r.replace(/\/+$/,"")||"/",_=v.match(/^\/leaderboard\/u\/([^/]+)$/i),w=_?_[1]:null,y=v==="/leaderboard"||!!w,b=!!(e.enabled&&e.signedIn),T=m||b,A=!1,M=iH(),I=L.useMemo(()=>!e.enabled||!b?null:{getAccessToken:()=>e.getAccessToken(),name:e.displayName||"",userId:e.user?.id||null},[e,b]);let k=m||n||i?"dashboard":"landing";v==="/landing"&&(k="landing"),v==="/dashboard"&&(k="dashboard"),y&&(k="dashboard");const U=v==="/limits";U&&(k="dashboard");const S=v==="/settings";S&&(k="dashboard");const P=v==="/widgets";P&&(k="dashboard");const V=v==="/ip-check";V&&(k="dashboard");const O=w?I$:v==="/leaderboard"?N$:U?U$:S?F$:P?O$:V?B$:D$,J=!p&&(v==="/dashboard"||v==="/"||v==="/leaderboard"||U||S||P||V),H=F.jsx("div",{className:"min-h-screen bg-oai-white dark:bg-[#050505]"});let X=null;if(v==="/auth/callback"||v==="/auth/native-callback")X=F.jsx(v$,{});else if(v==="/login")X=F.jsx(m$,{});else if(k==="landing")X=F.jsx(h$,{signInUrl:"/login",signUpUrl:"/login"});else{const K=F.jsx(L.Suspense,{fallback:H,children:F.jsx(O,{baseUrl:M,auth:I,signedIn:T,sessionSoftExpired:A,signOut:()=>e.enabled?e.signOut():Promise.resolve(),publicMode:p,publicToken:h,userId:w,signInUrl:"/login",signUpUrl:"/login"})});X=J?F.jsx(L$,{children:K}):K}return F.jsx(TF,{children:F.jsx(LF,{children:F.jsxs(DF,{children:[X,F.jsx(tH,{}),F.jsx(TU,{}),F.jsx(FU,{})]})})})}const V$=OL([{path:"*",element:F.jsx(z$,{})}]);T2.createRoot(document.getElementById("root")).render(F.jsx(hs.StrictMode,{children:F.jsx(fU,{children:F.jsx(JL,{router:V$})})}));export{jU as $,pT as A,Ct as B,y$ as C,F as D,gy as E,YU as F,LT as G,Ov as H,uF as I,mh as J,WS as K,HS as L,jy as M,EX as N,my as O,Ml as P,py as Q,BE as R,ZL as S,wT as T,pF as U,$S as V,Kl as W,AT as X,GS as Y,ET as Z,OU as _,pi as a,GU as a0,BU as a1,f0 as a2,TT as a3,bX as a4,HU as a5,SX as a6,MT as a7,wX as a8,Us as a9,vr as aA,Au as aB,kX as aC,RI as aD,Y$ as aE,LX as aF,dX as aG,q$ as aH,fX as aI,hH as aJ,H0 as aK,tV as aL,_X as aM,vy as aN,UT as aO,MX as aP,PX as aQ,TX as aR,AX as aS,CX as aT,PC as aU,CC as aV,Jz as aW,BS as aX,uX as aY,PI as aZ,Aa as a_,Lz as aa,Il as ab,rF as ac,hs as ad,RC as ae,sX as af,rX as ag,zT as ah,Do as ai,E5 as aj,No as ak,DX as al,cX as am,$C as an,Ta as ao,hX as ap,Z$ as aq,J$ as ar,aX as as,HI as at,Q$ as au,eX as av,pX as aw,iX as ax,uH as ay,Mn as az,VT as b,Ia as c,dw as d,br as e,An as f,mT as g,xr as h,PO as i,K$ as j,UI as k,xX as l,Gl as m,WI as n,$I as o,gX as p,nX as q,L as r,lX as s,vX as t,yy as u,yX as v,tX as w,kn as x,oX as y,mX as z};