tokentracker-cli 0.8.0 → 0.9.0

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.
@@ -5165,4 +5165,4 @@ void main() {
5165
5165
  While dragging, use the arrow keys to move the item.
5166
5166
  Press space again to drop the item in its new position, or press escape to cancel.
5167
5167
  `},kge={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function Ege(t){let{announcements:e=kge,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Sge}=t;const{announce:a,announcement:s}=bge(),o=Wp("DndLiveRegion"),[c,u]=x.useState(!1);if(x.useEffect(()=>{u(!0)},[]),_ge(x.useMemo(()=>({onDragStart(h){let{active:p}=h;a(e.onDragStart({active:p}))},onDragMove(h){let{active:p,over:y}=h;e.onDragMove&&a(e.onDragMove({active:p,over:y}))},onDragOver(h){let{active:p,over:y}=h;a(e.onDragOver({active:p,over:y}))},onDragEnd(h){let{active:p,over:y}=h;a(e.onDragEnd({active:p,over:y}))},onDragCancel(h){let{active:p,over:y}=h;a(e.onDragCancel({active:p,over:y}))}}),[a,e])),!c)return null;const f=ot.createElement(ot.Fragment,null,ot.createElement(vge,{id:r,value:i.draggable}),ot.createElement(xge,{id:o,announcement:s}));return n?gi.createPortal(f,n):f}var Ur;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Ur||(Ur={}));function _y(){}function nD(t,e){return x.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Mge(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return x.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const as=Object.freeze({x:0,y:0});function CU(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function AU(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function Tge(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function rD(t){let{left:e,top:n,height:r,width:i}=t;return[{x:e,y:n},{x:e+i,y:n},{x:e,y:n+r},{x:e+i,y:n+r}]}function RU(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function iD(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+t.width*.5,y:n+t.height*.5}}const Cge=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=iD(e,e.left,e.top),a=[];for(const s of r){const{id:o}=s,c=n.get(o);if(c){const u=CU(iD(c),i);a.push({id:o,data:{droppableContainer:s,value:u}})}}return a.sort(AU)},Age=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=rD(e),a=[];for(const s of r){const{id:o}=s,c=n.get(o);if(c){const u=rD(c),f=i.reduce((p,y,v)=>p+CU(u[v],y),0),h=Number((f/4).toFixed(4));a.push({id:o,data:{droppableContainer:s,value:h}})}}return a.sort(AU)};function Rge(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height),s=i-r,o=a-n;if(r<i&&n<a){const c=e.width*e.height,u=t.width*t.height,f=s*o,h=f/(c+u-f);return Number(h.toFixed(4))}return 0}const Pge=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const a of r){const{id:s}=a,o=n.get(s);if(o){const c=Rge(o,e);c>0&&i.push({id:s,data:{droppableContainer:a,value:c}})}}return i.sort(Tge)};function Nge(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function PU(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:as}function Dge(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return i.reduce((s,o)=>({...s,top:s.top+t*o.y,bottom:s.bottom+t*o.y,left:s.left+t*o.x,right:s.right+t*o.x}),{...n})}}const Lge=Dge(1);function Ige(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function Oge(t,e,n){const r=Ige(e);if(!r)return t;const{scaleX:i,scaleY:a,x:s,y:o}=r,c=t.left-s-(1-i)*parseFloat(n),u=t.top-o-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),f=i?t.width/i:t.width,h=a?t.height/a:t.height;return{width:f,height:h,top:u,right:c+f,bottom:u+h,left:c}}const Fge={ignoreTransform:!1};function gf(t,e){e===void 0&&(e=Fge);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:f}=Gi(t).getComputedStyle(t);u&&(n=Oge(n,u,f))}const{top:r,left:i,width:a,height:s,bottom:o,right:c}=n;return{top:r,left:i,width:a,height:s,bottom:o,right:c}}function aD(t){return gf(t,{ignoreTransform:!0})}function Uge(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function jge(t,e){return e===void 0&&(e=Gi(t).getComputedStyle(t)),e.position==="fixed"}function Bge(t,e){e===void 0&&(e=Gi(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const a=e[i];return typeof a=="string"?n.test(a):!1})}function gv(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(rM(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Vp(i)||EU(i)||n.includes(i))return n;const a=Gi(t).getComputedStyle(i);return i!==t&&Bge(i,a)&&n.push(i),jge(i,a)?n:r(i.parentNode)}return t?r(t):n}function NU(t){const[e]=gv(t,1);return e??null}function dw(t){return!mv||!t?null:pf(t)?t:nM(t)?rM(t)||t===mf(t).scrollingElement?window:Vp(t)?t:null:null}function DU(t){return pf(t)?t.scrollX:t.scrollLeft}function LU(t){return pf(t)?t.scrollY:t.scrollTop}function PS(t){return{x:DU(t),y:LU(t)}}var qr;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(qr||(qr={}));function IU(t){return!mv||!t?!1:t===document.scrollingElement}function OU(t){const e={x:0,y:0},n=IU(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,a=t.scrollLeft<=e.x,s=t.scrollTop>=r.y,o=t.scrollLeft>=r.x;return{isTop:i,isLeft:a,isBottom:s,isRight:o,maxScroll:r,minScroll:e}}const zge={x:.2,y:.2};function Vge(t,e,n,r,i){let{top:a,left:s,right:o,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=zge);const{isTop:u,isBottom:f,isLeft:h,isRight:p}=OU(t),y={x:0,y:0},v={x:0,y:0},w={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+w.height?(y.y=qr.Backward,v.y=r*Math.abs((e.top+w.height-a)/w.height)):!f&&c>=e.bottom-w.height&&(y.y=qr.Forward,v.y=r*Math.abs((e.bottom-w.height-c)/w.height)),!p&&o>=e.right-w.width?(y.x=qr.Forward,v.x=r*Math.abs((e.right-w.width-o)/w.width)):!h&&s<=e.left+w.width&&(y.x=qr.Backward,v.x=r*Math.abs((e.left+w.width-s)/w.width)),{direction:y,speed:v}}function Hge(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:s}=window;return{top:0,left:0,right:a,bottom:s,width:a,height:s}}const{top:e,left:n,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function FU(t){return t.reduce((e,n)=>Pd(e,PS(n)),as)}function Wge(t){return t.reduce((e,n)=>e+DU(n),0)}function Gge(t){return t.reduce((e,n)=>e+LU(n),0)}function $ge(t,e){if(e===void 0&&(e=gf),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);NU(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const Yge=[["x",["left","right"],Wge],["y",["top","bottom"],Gge]];class sM{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=gv(n),i=FU(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,s,o]of Yge)for(const c of s)Object.defineProperty(this,c,{get:()=>{const u=o(r),f=i[a]-u;return this.rect[c]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class zh{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var i;(i=this.target)==null||i.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function qge(t){const{EventTarget:e}=Gi(t);return t instanceof e?t:mf(t)}function fw(t,e){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+r**2)>e:"x"in e&&"y"in e?n>e.x&&r>e.y:"x"in e?n>e.x:"y"in e?r>e.y:!1}var Sa;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Sa||(Sa={}));function sD(t){t.preventDefault()}function Xge(t){t.stopPropagation()}var Nn;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Nn||(Nn={}));const UU={start:[Nn.Space,Nn.Enter],cancel:[Nn.Esc],end:[Nn.Space,Nn.Enter,Nn.Tab]},Kge=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Nn.Right:return{...n,x:n.x+25};case Nn.Left:return{...n,x:n.x-25};case Nn.Down:return{...n,y:n.y+25};case Nn.Up:return{...n,y:n.y-25}}};class oM{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new zh(mf(n)),this.windowListeners=new zh(Gi(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Sa.Resize,this.handleCancel),this.windowListeners.add(Sa.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Sa.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&$ge(r),n(as)}handleKeyDown(e){if(aM(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=UU,coordinateGetter:s=Kge,scrollBehavior:o="smooth"}=i,{code:c}=e;if(a.end.includes(c)){this.handleEnd(e);return}if(a.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,f=u?{x:u.left,y:u.top}:as;this.referenceCoordinates||(this.referenceCoordinates=f);const h=s(e,{active:n,context:r.current,currentCoordinates:f});if(h){const p=fp(h,f),y={x:0,y:0},{scrollableAncestors:v}=r.current;for(const w of v){const b=e.code,{isTop:_,isRight:E,isLeft:M,isBottom:T,maxScroll:R,minScroll:A}=OU(w),P=Hge(w),k={x:Math.min(b===Nn.Right?P.right-P.width/2:P.right,Math.max(b===Nn.Right?P.left:P.left+P.width/2,h.x)),y:Math.min(b===Nn.Down?P.bottom-P.height/2:P.bottom,Math.max(b===Nn.Down?P.top:P.top+P.height/2,h.y))},N=b===Nn.Right&&!E||b===Nn.Left&&!M,j=b===Nn.Down&&!T||b===Nn.Up&&!_;if(N&&k.x!==h.x){const L=w.scrollLeft+p.x,V=b===Nn.Right&&L<=R.x||b===Nn.Left&&L>=A.x;if(V&&!p.y){w.scrollTo({left:L,behavior:o});return}V?y.x=w.scrollLeft-L:y.x=b===Nn.Right?w.scrollLeft-R.x:w.scrollLeft-A.x,y.x&&w.scrollBy({left:-y.x,behavior:o});break}else if(j&&k.y!==h.y){const L=w.scrollTop+p.y,V=b===Nn.Down&&L<=R.y||b===Nn.Up&&L>=A.y;if(V&&!p.x){w.scrollTo({top:L,behavior:o});return}V?y.y=w.scrollTop-L:y.y=b===Nn.Down?w.scrollTop-R.y:w.scrollTop-A.y,y.y&&w.scrollBy({top:-y.y,behavior:o});break}}this.handleMove(e,Pd(fp(h,this.referenceCoordinates),y))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}oM.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=UU,onActivation:i}=e,{active:a}=n;const{code:s}=t.nativeEvent;if(r.start.includes(s)){const o=a.activatorNode.current;return o&&t.target!==o?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function oD(t){return!!(t&&"distance"in t)}function lD(t){return!!(t&&"delay"in t)}class lM{constructor(e,n,r){var i;r===void 0&&(r=qge(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:a}=e,{target:s}=a;this.props=e,this.events=n,this.document=mf(s),this.documentListeners=new zh(this.document),this.listeners=new zh(r),this.windowListeners=new zh(Gi(s)),this.initialCoordinates=(i=RS(a))!=null?i:as,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Sa.Resize,this.handleCancel),this.windowListeners.add(Sa.DragStart,sD),this.windowListeners.add(Sa.VisibilityChange,this.handleCancel),this.windowListeners.add(Sa.ContextMenu,sD),this.documentListeners.add(Sa.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(lD(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(oD(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:r,onPending:i}=this.props;i(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(Sa.Click,Xge,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Sa.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:s,options:{activationConstraint:o}}=a;if(!i)return;const c=(n=RS(e))!=null?n:as,u=fp(i,c);if(!r&&o){if(oD(o)){if(o.tolerance!=null&&fw(u,o.tolerance))return this.handleCancel();if(fw(u,o.distance))return this.handleStart()}if(lD(o)&&fw(u,o.tolerance))return this.handleCancel();this.handlePending(o,u);return}e.cancelable&&e.preventDefault(),s(c)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===Nn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const Zge={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class cM extends lM{constructor(e){const{event:n}=e,r=mf(n.target);super(e,Zge,r)}}cM.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const Jge={move:{name:"mousemove"},end:{name:"mouseup"}};var NS;(function(t){t[t.RightClick=2]="RightClick"})(NS||(NS={}));class Qge extends lM{constructor(e){super(e,Jge,mf(e.event.target))}}Qge.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===NS.RightClick?!1:(r?.({event:n}),!0)}}];const hw={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class e0e extends lM{constructor(e){super(e,hw)}static setup(){return window.addEventListener(hw.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(hw.move.name,e)};function e(){}}}e0e.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;const{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Vh;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Vh||(Vh={}));var wy;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(wy||(wy={}));function t0e(t){let{acceleration:e,activator:n=Vh.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:s=5,order:o=wy.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:f,delta:h,threshold:p}=t;const y=r0e({delta:h,disabled:!a}),[v,w]=hge(),b=x.useRef({x:0,y:0}),_=x.useRef({x:0,y:0}),E=x.useMemo(()=>{switch(n){case Vh.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Vh.DraggableRect:return i}},[n,i,c]),M=x.useRef(null),T=x.useCallback(()=>{const A=M.current;if(!A)return;const P=b.current.x*_.current.x,k=b.current.y*_.current.y;A.scrollBy(P,k)},[]),R=x.useMemo(()=>o===wy.TreeOrder?[...u].reverse():u,[o,u]);x.useEffect(()=>{if(!a||!u.length||!E){w();return}for(const A of R){if(r?.(A)===!1)continue;const P=u.indexOf(A),k=f[P];if(!k)continue;const{direction:N,speed:j}=Vge(A,k,E,e,p);for(const L of["x","y"])y[L][N[L]]||(j[L]=0,N[L]=0);if(j.x>0||j.y>0){w(),M.current=A,v(T,s),b.current=j,_.current=N;return}}b.current={x:0,y:0},_.current={x:0,y:0},w()},[e,T,r,w,a,s,JSON.stringify(E),JSON.stringify(y),v,u,R,f,JSON.stringify(p)])}const n0e={x:{[qr.Backward]:!1,[qr.Forward]:!1},y:{[qr.Backward]:!1,[qr.Forward]:!1}};function r0e(t){let{delta:e,disabled:n}=t;const r=AS(e);return Hp(i=>{if(n||!r||!i)return n0e;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[qr.Backward]:i.x[qr.Backward]||a.x===-1,[qr.Forward]:i.x[qr.Forward]||a.x===1},y:{[qr.Backward]:i.y[qr.Backward]||a.y===-1,[qr.Forward]:i.y[qr.Forward]||a.y===1}}},[n,e,r])}function i0e(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Hp(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function a0e(t,e){return x.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,a=i.activators.map(s=>({eventName:s.eventName,handler:e(s.handler,r)}));return[...n,...a]},[]),[t,e])}var pp;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(pp||(pp={}));var DS;(function(t){t.Optimized="optimized"})(DS||(DS={}));const cD=new Map;function s0e(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,s]=x.useState(null),{frequency:o,measure:c,strategy:u}=i,f=x.useRef(t),h=b(),p=dp(h),y=x.useCallback(function(_){_===void 0&&(_=[]),!p.current&&s(E=>E===null?_:E.concat(_.filter(M=>!E.includes(M))))},[p]),v=x.useRef(null),w=Hp(_=>{if(h&&!n)return cD;if(!_||_===cD||f.current!==t||a!=null){const E=new Map;for(let M of t){if(!M)continue;if(a&&a.length>0&&!a.includes(M.id)&&M.rect.current){E.set(M.id,M.rect.current);continue}const T=M.node.current,R=T?new sM(c(T),T):null;M.rect.current=R,R&&E.set(M.id,R)}return E}return _},[t,a,n,h,c]);return x.useEffect(()=>{f.current=t},[t]),x.useEffect(()=>{h||y()},[n,h]),x.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),x.useEffect(()=>{h||typeof o!="number"||v.current!==null||(v.current=setTimeout(()=>{y(),v.current=null},o))},[o,h,y,...r]),{droppableRects:w,measureDroppableContainers:y,measuringScheduled:a!=null};function b(){switch(u){case pp.Always:return!1;case pp.BeforeDragging:return n;default:return!n}}}function jU(t,e){return Hp(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function o0e(t,e){return jU(t,e)}function l0e(t){let{callback:e,disabled:n}=t;const r=iM(e),i=x.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return x.useEffect(()=>()=>i?.disconnect(),[i]),i}function yv(t){let{callback:e,disabled:n}=t;const r=iM(e),i=x.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return x.useEffect(()=>()=>i?.disconnect(),[i]),i}function c0e(t){return new sM(gf(t),t)}function uD(t,e,n){e===void 0&&(e=c0e);const[r,i]=x.useState(null);function a(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const f=e(t);return JSON.stringify(c)===JSON.stringify(f)?c:f})}const s=l0e({callback(c){if(t)for(const u of c){const{type:f,target:h}=u;if(f==="childList"&&h instanceof HTMLElement&&h.contains(t)){a();break}}}}),o=yv({callback:a});return Ys(()=>{a(),t?(o?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),s?.disconnect())},[t]),r}function u0e(t){const e=jU(t);return PU(t,e)}const dD=[];function d0e(t){const e=x.useRef(t),n=Hp(r=>t?r&&r!==dD&&t&&e.current&&t.parentNode===e.current.parentNode?r:gv(t):dD,[t]);return x.useEffect(()=>{e.current=t},[t]),n}function f0e(t){const[e,n]=x.useState(null),r=x.useRef(t),i=x.useCallback(a=>{const s=dw(a.target);s&&n(o=>o?(o.set(s,PS(s)),new Map(o)):null)},[]);return x.useEffect(()=>{const a=r.current;if(t!==a){s(a);const o=t.map(c=>{const u=dw(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,PS(u)]):null}).filter(c=>c!=null);n(o.length?new Map(o):null),r.current=t}return()=>{s(t),s(a)};function s(o){o.forEach(c=>{const u=dw(c);u?.removeEventListener("scroll",i)})}},[i,t]),x.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,s)=>Pd(a,s),as):FU(t):as,[t,e])}function fD(t,e){e===void 0&&(e=[]);const n=x.useRef(null);return x.useEffect(()=>{n.current=null},e),x.useEffect(()=>{const r=t!==as;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?fp(t,n.current):as}function h0e(t){x.useEffect(()=>{if(!mv)return;const e=t.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of e)n?.()}},t.map(e=>{let{sensor:n}=e;return n}))}function p0e(t,e){return x.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=s=>{a(s,e)},n},{}),[t,e])}function BU(t){return x.useMemo(()=>t?Uge(t):null,[t])}const hD=[];function m0e(t,e){e===void 0&&(e=gf);const[n]=t,r=BU(n?Gi(n):null),[i,a]=x.useState(hD);function s(){a(()=>t.length?t.map(c=>IU(c)?r:new sM(e(c),c)):hD)}const o=yv({callback:s});return Ys(()=>{o?.disconnect(),s(),t.forEach(c=>o?.observe(c))},[t]),i}function g0e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Vp(e)?e:t}function y0e(t){let{measure:e}=t;const[n,r]=x.useState(null),i=x.useCallback(u=>{for(const{target:f}of u)if(Vp(f)){r(h=>{const p=e(f);return h?{...h,width:p.width,height:p.height}:p});break}},[e]),a=yv({callback:i}),s=x.useCallback(u=>{const f=g0e(u);a?.disconnect(),f&&a?.observe(f),r(f?e(f):null)},[e,a]),[o,c]=by(s);return x.useMemo(()=>({nodeRef:o,rect:n,setRef:c}),[n,o,c])}const v0e=[{sensor:cM,options:{}},{sensor:oM,options:{}}],x0e={current:{}},T0={draggable:{measure:aD},droppable:{measure:aD,strategy:pp.WhileDragging,frequency:DS.Optimized},dragOverlay:{measure:gf}};class Hh extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const b0e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Hh,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:_y},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:T0,measureDroppableContainers:_y,windowRect:null,measuringScheduled:!1},_0e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:_y,draggableNodes:new Map,over:null,measureDroppableContainers:_y},vv=x.createContext(_0e),zU=x.createContext(b0e);function w0e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Hh}}}function S0e(t,e){switch(e.type){case Ur.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Ur.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case Ur.DragEnd:case Ur.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ur.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new Hh(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case Ur.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const s=new Hh(t.droppable.containers);return s.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:s}}}case Ur.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new Hh(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function k0e(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=x.useContext(vv),a=AS(r),s=AS(n?.id);return x.useEffect(()=>{if(!e&&!r&&a&&s!=null){if(!aM(a)||document.activeElement===a.target)return;const o=i.get(s);if(!o)return;const{activatorNode:c,node:u}=o;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const f of[c.current,u.current]){if(!f)continue;const h=gge(f);if(h){h.focus();break}}})}},[r,e,i,s,a]),null}function E0e(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function M0e(t){return x.useMemo(()=>({draggable:{...T0.draggable,...t?.draggable},droppable:{...T0.droppable,...t?.droppable},dragOverlay:{...T0.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function T0e(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=x.useRef(!1),{x:s,y:o}=typeof i=="boolean"?{x:i,y:i}:i;Ys(()=>{if(!s&&!o||!e){a.current=!1;return}if(a.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const f=n(u),h=PU(f,r);if(s||(h.x=0),o||(h.y=0),a.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const p=NU(u);p&&p.scrollBy({top:h.y,left:h.x})}},[e,s,o,r,n])}const VU=x.createContext({...as,scaleX:1,scaleY:1});var gl;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(gl||(gl={}));const C0e=x.memo(function(e){var n,r,i,a;let{id:s,accessibility:o,autoScroll:c=!0,children:u,sensors:f=v0e,collisionDetection:h=Pge,measuring:p,modifiers:y,...v}=e;const w=x.useReducer(S0e,void 0,w0e),[b,_]=w,[E,M]=wge(),[T,R]=x.useState(gl.Uninitialized),A=T===gl.Initialized,{draggable:{active:P,nodes:k,translate:N},droppable:{containers:j}}=b,L=P!=null?k.get(P):null,V=x.useRef({initial:null,translated:null}),U=x.useMemo(()=>{var Ae;return P!=null?{id:P,data:(Ae=L?.data)!=null?Ae:x0e,rect:V}:null},[P,L]),z=x.useRef(null),[W,K]=x.useState(null),[Q,O]=x.useState(null),G=dp(v,Object.values(v)),Y=Wp("DndDescribedBy",s),H=x.useMemo(()=>j.getEnabled(),[j]),te=M0e(p),{droppableRects:re,measureDroppableContainers:ue,measuringScheduled:ce}=s0e(H,{dragging:A,dependencies:[N.x,N.y],config:te.droppable}),ee=i0e(k,P),le=x.useMemo(()=>Q?RS(Q):null,[Q]),ve=ke(),Pe=o0e(ee,te.draggable.measure);T0e({activeNode:P!=null?k.get(P):null,config:ve.layoutShiftCompensation,initialRect:Pe,measure:te.draggable.measure});const be=uD(ee,te.draggable.measure,Pe),Ye=uD(ee?ee.parentElement:null),he=x.useRef({activatorEvent:null,active:null,activeNode:ee,collisionRect:null,collisions:null,droppableRects:re,draggableNodes:k,draggingNode:null,draggingNodeRect:null,droppableContainers:j,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ue=j.getNodeFor((n=he.current.over)==null?void 0:n.id),je=y0e({measure:te.dragOverlay.measure}),et=(r=je.nodeRef.current)!=null?r:ee,_e=A?(i=je.rect)!=null?i:be:null,oe=!!(je.nodeRef.current&&je.rect),J=u0e(oe?null:be),ze=BU(et?Gi(et):null),Ne=d0e(A?Ue??ee:null),De=m0e(Ne),Le=E0e(y,{transform:{x:N.x-J.x,y:N.y-J.y,scaleX:1,scaleY:1},activatorEvent:Q,active:U,activeNodeRect:be,containerNodeRect:Ye,draggingNodeRect:_e,over:he.current.over,overlayNodeRect:je.rect,scrollableAncestors:Ne,scrollableAncestorRects:De,windowRect:ze}),$=le?Pd(le,N):null,I=f0e(Ne),Z=fD(I),pe=fD(I,[be]),Se=Pd(Le,Z),xe=_e?Lge(_e,Le):null,Ie=U&&xe?h({active:U,collisionRect:xe,droppableRects:re,droppableContainers:H,pointerCoordinates:$}):null,He=RU(Ie,"id"),[qe,ht]=x.useState(null),We=oe?Le:Pd(Le,pe),Xe=Nge(We,(a=qe?.rect)!=null?a:null,be),nt=x.useRef(null),ct=x.useCallback((Ae,Ve)=>{let{sensor:ge,options:ut}=Ve;if(z.current==null)return;const yt=k.get(z.current);if(!yt)return;const qt=Ae.nativeEvent,Mt=new ge({active:z.current,activeNode:yt,event:qt,options:ut,context:he,onAbort(Pt){if(!k.get(Pt))return;const{onDragAbort:xn}=G.current,ie={id:Pt};xn?.(ie),E({type:"onDragAbort",event:ie})},onPending(Pt,hn,xn,ie){if(!k.get(Pt))return;const{onDragPending:Te}=G.current,$e={id:Pt,constraint:hn,initialCoordinates:xn,offset:ie};Te?.($e),E({type:"onDragPending",event:$e})},onStart(Pt){const hn=z.current;if(hn==null)return;const xn=k.get(hn);if(!xn)return;const{onDragStart:ie}=G.current,fe={activatorEvent:qt,active:{id:hn,data:xn.data,rect:V}};gi.unstable_batchedUpdates(()=>{ie?.(fe),R(gl.Initializing),_({type:Ur.DragStart,initialCoordinates:Pt,active:hn}),E({type:"onDragStart",event:fe}),K(nt.current),O(qt)})},onMove(Pt){_({type:Ur.DragMove,coordinates:Pt})},onEnd:_t(Ur.DragEnd),onCancel:_t(Ur.DragCancel)});nt.current=Mt;function _t(Pt){return async function(){const{active:xn,collisions:ie,over:fe,scrollAdjustedTranslate:Te}=he.current;let $e=null;if(xn&&Te){const{cancelDrop:Ze}=G.current;$e={activatorEvent:qt,active:xn,collisions:ie,delta:Te,over:fe},Pt===Ur.DragEnd&&typeof Ze=="function"&&await Promise.resolve(Ze($e))&&(Pt=Ur.DragCancel)}z.current=null,gi.unstable_batchedUpdates(()=>{_({type:Pt}),R(gl.Uninitialized),ht(null),K(null),O(null),nt.current=null;const Ze=Pt===Ur.DragEnd?"onDragEnd":"onDragCancel";if($e){const At=G.current[Ze];At?.($e),E({type:Ze,event:$e})}})}}},[k]),Ke=x.useCallback((Ae,Ve)=>(ge,ut)=>{const yt=ge.nativeEvent,qt=k.get(ut);if(z.current!==null||!qt||yt.dndKit||yt.defaultPrevented)return;const Mt={active:qt};Ae(ge,Ve.options,Mt)===!0&&(yt.dndKit={capturedBy:Ve.sensor},z.current=ut,ct(ge,Ve))},[k,ct]),gt=a0e(f,Ke);h0e(f),Ys(()=>{be&&T===gl.Initializing&&R(gl.Initialized)},[be,T]),x.useEffect(()=>{const{onDragMove:Ae}=G.current,{active:Ve,activatorEvent:ge,collisions:ut,over:yt}=he.current;if(!Ve||!ge)return;const qt={active:Ve,activatorEvent:ge,collisions:ut,delta:{x:Se.x,y:Se.y},over:yt};gi.unstable_batchedUpdates(()=>{Ae?.(qt),E({type:"onDragMove",event:qt})})},[Se.x,Se.y]),x.useEffect(()=>{const{active:Ae,activatorEvent:Ve,collisions:ge,droppableContainers:ut,scrollAdjustedTranslate:yt}=he.current;if(!Ae||z.current==null||!Ve||!yt)return;const{onDragOver:qt}=G.current,Mt=ut.get(He),_t=Mt&&Mt.rect.current?{id:Mt.id,rect:Mt.rect.current,data:Mt.data,disabled:Mt.disabled}:null,Pt={active:Ae,activatorEvent:Ve,collisions:ge,delta:{x:yt.x,y:yt.y},over:_t};gi.unstable_batchedUpdates(()=>{ht(_t),qt?.(Pt),E({type:"onDragOver",event:Pt})})},[He]),Ys(()=>{he.current={activatorEvent:Q,active:U,activeNode:ee,collisionRect:xe,collisions:Ie,droppableRects:re,draggableNodes:k,draggingNode:et,draggingNodeRect:_e,droppableContainers:j,over:qe,scrollableAncestors:Ne,scrollAdjustedTranslate:Se},V.current={initial:_e,translated:xe}},[U,ee,Ie,xe,k,et,_e,re,j,qe,Ne,Se]),t0e({...ve,delta:N,draggingRect:xe,pointerCoordinates:$,scrollableAncestors:Ne,scrollableAncestorRects:De});const ne=x.useMemo(()=>({active:U,activeNode:ee,activeNodeRect:be,activatorEvent:Q,collisions:Ie,containerNodeRect:Ye,dragOverlay:je,draggableNodes:k,droppableContainers:j,droppableRects:re,over:qe,measureDroppableContainers:ue,scrollableAncestors:Ne,scrollableAncestorRects:De,measuringConfiguration:te,measuringScheduled:ce,windowRect:ze}),[U,ee,be,Q,Ie,Ye,je,k,j,re,qe,ue,Ne,De,te,ce,ze]),Be=x.useMemo(()=>({activatorEvent:Q,activators:gt,active:U,activeNodeRect:be,ariaDescribedById:{draggable:Y},dispatch:_,draggableNodes:k,over:qe,measureDroppableContainers:ue}),[Q,gt,U,be,_,Y,k,qe,ue]);return ot.createElement(TU.Provider,{value:M},ot.createElement(vv.Provider,{value:Be},ot.createElement(zU.Provider,{value:ne},ot.createElement(VU.Provider,{value:Xe},u)),ot.createElement(k0e,{disabled:o?.restoreFocus===!1})),ot.createElement(Ege,{...o,hiddenTextDescribedById:Y}));function ke(){const Ae=W?.autoScrollEnabled===!1,Ve=typeof c=="object"?c.enabled===!1:c===!1,ge=A&&!Ae&&!Ve;return typeof c=="object"?{...c,enabled:ge}:{enabled:ge}}}),A0e=x.createContext(null),pD="button",R0e="Draggable";function P0e(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=Wp(R0e),{activators:s,activatorEvent:o,active:c,activeNodeRect:u,ariaDescribedById:f,draggableNodes:h,over:p}=x.useContext(vv),{role:y=pD,roleDescription:v="draggable",tabIndex:w=0}=i??{},b=c?.id===e,_=x.useContext(b?VU:A0e),[E,M]=by(),[T,R]=by(),A=p0e(s,e),P=dp(n);Ys(()=>(h.set(e,{id:e,key:a,node:E,activatorNode:T,data:P}),()=>{const N=h.get(e);N&&N.key===a&&h.delete(e)}),[h,e]);const k=x.useMemo(()=>({role:y,tabIndex:w,"aria-disabled":r,"aria-pressed":b&&y===pD?!0:void 0,"aria-roledescription":v,"aria-describedby":f.draggable}),[r,y,w,b,v,f.draggable]);return{active:c,activatorEvent:o,activeNodeRect:u,attributes:k,isDragging:b,listeners:r?void 0:A,node:E,over:p,setNodeRef:M,setActivatorNodeRef:R,transform:_}}function N0e(){return x.useContext(zU)}const D0e="Droppable",L0e={timeout:25};function I0e(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=Wp(D0e),{active:s,dispatch:o,over:c,measureDroppableContainers:u}=x.useContext(vv),f=x.useRef({disabled:n}),h=x.useRef(!1),p=x.useRef(null),y=x.useRef(null),{disabled:v,updateMeasurementsFor:w,timeout:b}={...L0e,...i},_=dp(w??r),E=x.useCallback(()=>{if(!h.current){h.current=!0;return}y.current!=null&&clearTimeout(y.current),y.current=setTimeout(()=>{u(Array.isArray(_.current)?_.current:[_.current]),y.current=null},b)},[b]),M=yv({callback:E,disabled:v||!s}),T=x.useCallback((k,N)=>{M&&(N&&(M.unobserve(N),h.current=!1),k&&M.observe(k))},[M]),[R,A]=by(T),P=dp(e);return x.useEffect(()=>{!M||!R.current||(M.disconnect(),h.current=!1,M.observe(R.current))},[R,M]),x.useEffect(()=>(o({type:Ur.RegisterDroppable,element:{id:r,key:a,disabled:n,node:R,rect:p,data:P}}),()=>o({type:Ur.UnregisterDroppable,key:a,id:r})),[r]),x.useEffect(()=>{n!==f.current.disabled&&(o({type:Ur.SetDroppableDisabled,id:r,key:a,disabled:n}),f.current.disabled=n)},[r,a,n,o]),{active:s,rect:p,isOver:c?.id===r,node:R,over:c,setNodeRef:A}}const O0e=t=>{let{transform:e}=t;return{...e,y:0}};function HU(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function F0e(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function Kg(t){return t!==null&&t>=0}function U0e(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function j0e(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const Zg={scaleX:1,scaleY:1},B0e=t=>{var e;let{rects:n,activeNodeRect:r,activeIndex:i,overIndex:a,index:s}=t;const o=(e=n[i])!=null?e:r;if(!o)return null;const c=z0e(n,s,i);if(s===i){const u=n[a];return u?{x:i<a?u.left+u.width-(o.left+o.width):u.left-o.left,y:0,...Zg}:null}return s>i&&s<=a?{x:-o.width-c,y:0,...Zg}:s<i&&s>=a?{x:o.width+c,y:0,...Zg}:{x:0,y:0,...Zg}};function z0e(t,e,n){const r=t[e],i=t[e-1],a=t[e+1];return!r||!i&&!a?0:n<e?i?r.left-(i.left+i.width):a.left-(r.left+r.width):a?a.left-(r.left+r.width):r.left-(i.left+i.width)}const WU=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=HU(e,r,n),s=e[i],o=a[i];return!o||!s?null:{x:o.left-s.left,y:o.top-s.top,scaleX:o.width/s.width,scaleY:o.height/s.height}},GU="Sortable",$U=ot.createContext({activeIndex:-1,containerId:GU,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:WU,disabled:{draggable:!1,droppable:!1}});function V0e(t){let{children:e,id:n,items:r,strategy:i=WU,disabled:a=!1}=t;const{active:s,dragOverlay:o,droppableRects:c,over:u,measureDroppableContainers:f}=N0e(),h=Wp(GU,n),p=o.rect!==null,y=x.useMemo(()=>r.map(A=>typeof A=="object"&&"id"in A?A.id:A),[r]),v=s!=null,w=s?y.indexOf(s.id):-1,b=u?y.indexOf(u.id):-1,_=x.useRef(y),E=!U0e(y,_.current),M=b!==-1&&w===-1||E,T=j0e(a);Ys(()=>{E&&v&&f(y)},[E,y,v,f]),x.useEffect(()=>{_.current=y},[y]);const R=x.useMemo(()=>({activeIndex:w,containerId:h,disabled:T,disableTransforms:M,items:y,overIndex:b,useDragOverlay:p,sortedRects:F0e(y,c),strategy:i}),[w,h,T.draggable,T.droppable,M,y,b,c,p,i]);return ot.createElement($U.Provider,{value:R},e)}const H0e=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return HU(n,r,i).indexOf(e)},W0e=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:a,newIndex:s,previousItems:o,previousContainerId:c,transition:u}=t;return!u||!r||o!==a&&i===s?!1:n?!0:s!==i&&e===c},G0e={duration:200,easing:"ease"},YU="transform",$0e=hp.Transition.toString({property:YU,duration:0,easing:"linear"}),Y0e={roleDescription:"sortable"};function q0e(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,s]=x.useState(null),o=x.useRef(n);return Ys(()=>{if(!e&&n!==o.current&&r.current){const c=i.current;if(c){const u=gf(r.current,{ignoreTransform:!0}),f={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(f.x||f.y)&&s(f)}}n!==o.current&&(o.current=n)},[e,n,r,i]),x.useEffect(()=>{a&&s(null)},[a]),a}function X0e(t){let{animateLayoutChanges:e=W0e,attributes:n,disabled:r,data:i,getNewIndex:a=H0e,id:s,strategy:o,resizeObserverConfig:c,transition:u=G0e}=t;const{items:f,containerId:h,activeIndex:p,disabled:y,disableTransforms:v,sortedRects:w,overIndex:b,useDragOverlay:_,strategy:E}=x.useContext($U),M=K0e(r,y),T=f.indexOf(s),R=x.useMemo(()=>({sortable:{containerId:h,index:T,items:f},...i}),[h,i,T,f]),A=x.useMemo(()=>f.slice(f.indexOf(s)),[f,s]),{rect:P,node:k,isOver:N,setNodeRef:j}=I0e({id:s,data:R,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:A,...c}}),{active:L,activatorEvent:V,activeNodeRect:U,attributes:z,setNodeRef:W,listeners:K,isDragging:Q,over:O,setActivatorNodeRef:G,transform:Y}=P0e({id:s,data:R,attributes:{...Y0e,...n},disabled:M.draggable}),H=fge(j,W),te=!!L,re=te&&!v&&Kg(p)&&Kg(b),ue=!_&&Q,ce=ue&&re?Y:null,le=re?ce??(o??E)({rects:w,activeNodeRect:U,activeIndex:p,overIndex:b,index:T}):null,ve=Kg(p)&&Kg(b)?a({id:s,items:f,activeIndex:p,overIndex:b}):T,Pe=L?.id,be=x.useRef({activeId:Pe,items:f,newIndex:ve,containerId:h}),Ye=f!==be.current.items,he=e({active:L,containerId:h,isDragging:Q,isSorting:te,id:s,index:T,items:f,newIndex:be.current.newIndex,previousItems:be.current.items,previousContainerId:be.current.containerId,transition:u,wasDragging:be.current.activeId!=null}),Ue=q0e({disabled:!he,index:T,node:k,rect:P});return x.useEffect(()=>{te&&be.current.newIndex!==ve&&(be.current.newIndex=ve),h!==be.current.containerId&&(be.current.containerId=h),f!==be.current.items&&(be.current.items=f)},[te,ve,h,f]),x.useEffect(()=>{if(Pe===be.current.activeId)return;if(Pe&&!be.current.activeId){be.current.activeId=Pe;return}const et=setTimeout(()=>{be.current.activeId=Pe},50);return()=>clearTimeout(et)},[Pe]),{active:L,activeIndex:p,attributes:z,data:R,rect:P,index:T,newIndex:ve,items:f,isOver:N,isSorting:te,isDragging:Q,listeners:K,node:k,overIndex:b,over:O,setNodeRef:H,setActivatorNodeRef:G,setDroppableNodeRef:j,setDraggableNodeRef:W,transform:Ue??le,transition:je()};function je(){if(Ue||Ye&&be.current.newIndex===T)return $0e;if(!(ue&&!aM(V)||!u)&&(te||he))return hp.Transition.toString({...u,property:YU})}}function K0e(t,e){var n,r;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t?.draggable)!=null?n:e.draggable,droppable:(r=t?.droppable)!=null?r:e.droppable}}function Sy(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const Z0e=[Nn.Down,Nn.Right,Nn.Up,Nn.Left],J0e=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:s,scrollableAncestors:o}}=e;if(Z0e.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const p=i.get(h.id);if(p)switch(t.code){case Nn.Down:r.top<p.top&&c.push(h);break;case Nn.Up:r.top>p.top&&c.push(h);break;case Nn.Left:r.left>p.left&&c.push(h);break;case Nn.Right:r.left<p.left&&c.push(h);break}});const u=Age({collisionRect:r,droppableRects:i,droppableContainers:c});let f=RU(u,"id");if(f===s?.id&&u.length>1&&(f=u[1].id),f!=null){const h=a.get(n.id),p=a.get(f),y=p?i.get(p.id):null,v=p?.node.current;if(v&&y&&h&&p){const b=gv(v).some((A,P)=>o[P]!==A),_=qU(h,p),E=Q0e(h,p),M=b||!_?{x:0,y:0}:{x:E?r.width-y.width:0,y:E?r.height-y.height:0},T={x:y.left,y:y.top};return M.x&&M.y?T:fp(T,M)}}}};function qU(t,e){return!Sy(t)||!Sy(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function Q0e(t,e){return!Sy(t)||!Sy(e)||!qU(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function Xd(t,{min:e,max:n,fallback:r}){const i=Number(t);if(!Number.isFinite(i))return r;const a=Math.floor(i);return a<e?e:a>n?n:a}function eye(t,e){const n=Xd(e,{min:0,max:1e6,fallback:0}),r=Xd(t,{min:1,max:Math.max(1,n||1),fallback:1});if(n<=1)return[1];const i=new Set([1,n,r-2,r-1,r,r+1,r+2]),a=Array.from(i).filter(c=>Number.isInteger(c)&&c>=1&&c<=n).sort((c,u)=>c-u),s=[];let o=null;for(const c of a)o!=null&&c-o>1&&s.push(null),s.push(c),o=c;return s}function tye({page:t,totalPages:e}){const n=typeof e=="number"&&Number.isFinite(e)&&e>=0,r=n?Xd(e,{min:0,max:1e6,fallback:0}):null,i=Xd(t,{min:1,max:n?Math.max(1,r||1):1e6,fallback:1}),a=i>1,s=n?i<r:!0;return{canPrev:a,canNext:s,safePage:i,safeTotal:r}}function nye({entries:t,me:e,meLabel:n,limit:r}){const i=Xd(r,{min:1,max:1e3,fallback:20}),a=Array.isArray(t)?t.slice(0,i):[],s=e&&typeof e.rank=="number"?e.rank:null,o=a.some(v=>!!v?.is_me);if(!s||o)return a;const c={rank:s,is_me:!0,display_name:n,avatar_url:null,gpt_tokens:e?.gpt_tokens??"0",claude_tokens:e?.claude_tokens??"0",gemini_tokens:e?.gemini_tokens??"0",cursor_tokens:e?.cursor_tokens??"0",opencode_tokens:e?.opencode_tokens??"0",openclaw_tokens:e?.openclaw_tokens??"0",hermes_tokens:e?.hermes_tokens??"0",kiro_tokens:e?.kiro_tokens??"0",copilot_tokens:e?.copilot_tokens??"0",kimi_tokens:e?.kimi_tokens??"0",other_tokens:e?.other_tokens??"0",total_tokens:e?.total_tokens??"0"},u=a.filter(v=>!v?.is_me),f=u[u.length-1],h=f&&typeof f.rank=="number"?f.rank:0;return s>h+1?[...u.slice(0,Math.max(0,i-2)),{is_ellipsis:!0,rank:null,display_name:""},c]:[...u.slice(0,Math.max(0,i-1)),c]}function rye(t){let e=0;const n=String(t??"");for(let r=0;r<n.length;r+=1)e=Math.imul(31,e)+n.charCodeAt(r)|0;return Math.abs(e)%360}function iye(t){const e=String(t??"").trim();if(!e)return"?";const n=e.split(/\s+/).filter(Boolean);if(n.length>=2){const r=n[0][0]||"",i=n[1][0]||"";return`${r}${i}`.toUpperCase()}return e.slice(0,2).toUpperCase()}const mD={sm:"h-7 w-7 min-h-7 min-w-7 text-[10px]",md:"h-8 w-8 min-h-8 min-w-8 text-[11px]",lg:"h-14 w-14 min-h-14 min-w-14 text-base"};function LS({avatarUrl:t,displayName:e,seed:n,size:r="md",className:i}){const a=mD[r]||mD.md,s=rye(n??e??""),o=typeof t=="string"?t.trim():"",[c,u]=ot.useState(!1);return ot.useEffect(()=>{u(!1)},[o]),o&&!c?m.jsx("img",{src:o,alt:"",referrerPolicy:"no-referrer",onError:()=>u(!0),className:vt("rounded-full object-cover ring-1 ring-white/10",a,i)}):m.jsx("div",{className:vt("flex shrink-0 items-center justify-center rounded-full font-semibold text-white ring-1 ring-white/10",a,i),style:{backgroundColor:`hsl(${s} 42% 34%)`},"aria-hidden":!0,children:iye(e)})}const aye=new Set(["/brand-logos/cursor.svg","/brand-logos/kiro.svg","/brand-logos/copilot.svg"]);function XU({iconSrc:t,label:e}){return m.jsxs("span",{className:"inline-flex items-center gap-3",children:[t?m.jsx("img",{src:t,alt:"",width:16,height:16,className:`h-4 w-4 shrink-0 object-contain opacity-90 ${aye.has(t)?"dark:invert":""}`}):null,m.jsx("span",{className:"whitespace-nowrap",children:e})]})}const Kd=[{key:"gpt_tokens",copyKey:"leaderboard.column.codex",icon:"/brand-logos/codex.svg"},{key:"claude_tokens",copyKey:"leaderboard.column.claude",icon:"/brand-logos/claude-code.svg"},{key:"gemini_tokens",copyKey:"leaderboard.column.gemini",icon:"/brand-logos/gemini.svg"},{key:"cursor_tokens",copyKey:"leaderboard.column.cursor",icon:"/brand-logos/cursor.svg"},{key:"kiro_tokens",copyKey:"leaderboard.column.kiro",icon:"/brand-logos/kiro.svg"},{key:"copilot_tokens",copyKey:"leaderboard.column.copilot",icon:"/brand-logos/copilot.svg"},{key:"kimi_tokens",copyKey:"leaderboard.column.kimi",icon:"/brand-logos/kimi.svg"},{key:"opencode_tokens",copyKey:"leaderboard.column.opencode",icon:"/brand-logos/opencode.svg"},{key:"openclaw_tokens",copyKey:"leaderboard.column.openclaw",icon:"/brand-logos/openclaw.svg"},{key:"hermes_tokens",copyKey:"leaderboard.column.hermes",icon:null},{key:"other_tokens",copyKey:"leaderboard.column.supplemental",icon:null}],uM="sticky left-0 z-40 w-[72px] min-w-[72px] max-w-[72px] bg-white dark:bg-oai-gray-950 px-4 py-4 align-middle",KU="sticky left-[71px] z-40 min-w-[200px] max-w-[min(260px,45vw)] border-l border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-4 py-4 align-middle",sye="sticky left-[71px] z-40 min-w-[6rem] border-l border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-4 py-4";function ky(t){return vt("sticky left-0 z-30 w-[72px] min-w-[72px] max-w-[72px] px-4 py-4 whitespace-nowrap",t?"bg-oai-brand-50 dark:bg-emerald-950":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60")}function IS(t){return vt("sticky left-[71px] z-30 hover:z-50 min-w-[200px] max-w-[min(260px,45vw)] border-l border-r border-oai-gray-200 dark:border-oai-gray-800 px-4 py-4 min-w-0",t?"bg-oai-brand-50 dark:bg-emerald-950":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60")}function oye(t){return vt("sticky left-[71px] z-30 min-w-[6rem] border-l border-r border-oai-gray-200 dark:border-oai-gray-800 px-4 py-4 whitespace-nowrap","bg-white dark:bg-oai-gray-950")}function Ka({className:t}){return m.jsx("div",{className:vt("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function lye({index:t}){const e=t<3?"w-24":t<8?"w-20":"w-16",n=t<3?"w-16":"w-12",r=t<5?"w-14":"w-10";return m.jsxs("tr",{className:"group",children:[m.jsx("td",{className:vt(ky(!1),"!group-hover:bg-transparent"),children:m.jsx(Ka,{className:"h-4 w-6"})}),m.jsx("td",{className:vt(IS(!1),"!group-hover:bg-transparent"),children:m.jsxs("div",{className:"flex items-center gap-4",children:[m.jsx(Ka,{className:"h-8 w-8 min-w-8 rounded-full"}),m.jsx(Ka,{className:vt("h-4",e)})]})}),m.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:m.jsx(Ka,{className:vt("h-4",n)})}),m.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:m.jsx(Ka,{className:"h-4 w-12"})}),Kd.map(i=>m.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:m.jsx(Ka,{className:vt("h-4",r)})},i.key))]})}function cye({rows:t=10}){return m.jsx("div",{className:"w-full overflow-x-auto",children:m.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[m.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:m.jsxs("tr",{children:[m.jsx("th",{className:vt(uM,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:m.jsx(Ka,{className:"h-3.5 w-6"})}),m.jsx("th",{className:vt(KU,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:m.jsx(Ka,{className:"h-3.5 w-12"})}),m.jsx("th",{className:"px-4 py-4",children:m.jsx(Ka,{className:"h-3.5 w-10"})}),m.jsx("th",{className:"px-4 py-4",children:m.jsx(Ka,{className:"h-3.5 w-14"})}),Kd.map(e=>m.jsx("th",{className:"px-4 py-4",children:m.jsx(Ka,{className:"h-3.5 w-12"})},e.key))]})}),m.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:Array.from({length:t},(e,n)=>m.jsx(lye,{index:n},n))})]})})}function uye({id:t,thClassName:e,children:n}){const{attributes:r,listeners:i,setNodeRef:a,transform:s,transition:o,isDragging:c}=X0e({id:t}),u=hp.Transform.toString(s)||"";x.useLayoutEffect(()=>{const h=document.querySelectorAll(`td[data-column-key="${t}"]`),p="0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)";return h.forEach(y=>{y.style.transform=u,y.style.transition=o||"",y.style.zIndex=c?"20":"",y.style.position=u?"relative":"",y.style.boxShadow=c?p:""}),()=>{h.forEach(y=>{y.style.transform="",y.style.transition="",y.style.zIndex="",y.style.position="",y.style.boxShadow=""})}},[t,u,o,c]);const f={transform:u,transition:o,position:u?"relative":void 0,zIndex:c?20:void 0,boxShadow:c?"0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)":void 0};return m.jsx("th",{ref:a,style:f,className:vt(e,"group/col select-none cursor-grab active:cursor-grabbing touch-none"),...r,...i,children:m.jsxs("div",{className:"flex items-center justify-end gap-2",children:[m.jsx("span",{"aria-hidden":"true",className:vt("-mr-1 inline-flex h-4 w-3 shrink-0 items-center justify-center text-oai-gray-400 dark:text-oai-gray-600","opacity-0 transition-opacity duration-150 group-hover/col:opacity-100",c&&"opacity-100"),children:m.jsxs("svg",{viewBox:"0 0 8 14",width:"8",height:"14",fill:"currentColor","aria-hidden":"true",children:[m.jsx("circle",{cx:"2",cy:"2",r:"1"}),m.jsx("circle",{cx:"6",cy:"2",r:"1"}),m.jsx("circle",{cx:"2",cy:"7",r:"1"}),m.jsx("circle",{cx:"6",cy:"7",r:"1"}),m.jsx("circle",{cx:"2",cy:"12",r:"1"}),m.jsx("circle",{cx:"6",cy:"12",r:"1"})]})}),n]})})}const ZU="tokentracker.leaderboard.columnOrder.v1";function dye(){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(ZU);if(!t)return null;const e=JSON.parse(t);return Array.isArray(e)?e.filter(n=>typeof n=="string"):null}catch{return null}}function pw(t){if(!(typeof window>"u"))try{window.localStorage.setItem(ZU,JSON.stringify(t))}catch{}}function gD(t,e){if(!t)return e;const n=new Set(e),r=t.filter(a=>n.has(a)),i=e.filter(a=>!r.includes(a));return[...r,...i]}function fye(t){const e=x.useMemo(()=>t.join("|"),[t]),[n,r]=x.useState(()=>gD(dye(),t));x.useEffect(()=>{r(s=>{const o=gD(s,t);return o.length===s.length&&o.every((u,f)=>u===s[f])?s:(pw(o),o)})},[e,t]);const i=x.useCallback((s,o)=>{!s||!o||s===o||r(c=>{const u=c.indexOf(s),f=c.indexOf(o);if(u===-1||f===-1)return c;const h=c.slice(),[p]=h.splice(u,1);return h.splice(f,0,p),pw(h),h})},[]),a=x.useCallback(()=>{pw(t),r(t)},[t]);return{order:n,reorder:i,reset:a}}const OS=[10,20,50,100],FS=20,JU="tokentracker:leaderboard:pageSize";function hye(){if(typeof window>"u")return FS;try{const t=window.localStorage.getItem(JU),e=Number(t);if(OS.includes(e))return e}catch{}return FS}function yD(t){const e=Number(t);return!Number.isFinite(e)||e<=0?"-":e>=1e3?`$${Math.round(e).toLocaleString()}`:e>=10?`$${Math.round(e)}`:`$${e.toFixed(2)}`}function vD(t,e,n){const r=e?"text-oai-gray-700 dark:text-oai-gray-300":"text-oai-gray-500 dark:text-oai-gray-400",i=e?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60";return n.map(a=>m.jsx("td",{"data-column-key":a.key,className:vt("px-4 py-4 whitespace-nowrap text-right tabular-nums",r,i),children:Oi(t?.[a.key])},a.key))}const pye={1:{text:"text-amber-600 dark:text-amber-400",badge:"bg-amber-50 dark:bg-amber-900/20"},2:{text:"text-gray-500 dark:text-gray-300",badge:"bg-gray-50 dark:bg-gray-800/40"},3:{text:"text-orange-700 dark:text-orange-400",badge:"bg-orange-50 dark:bg-orange-900/20"}};function xD({rank:t,placeholder:e}){const n=pye[t];return n?m.jsx("span",{className:vt("inline-flex items-center justify-center h-7 w-7 rounded-full text-xs font-bold",n.text,n.badge),children:t}):m.jsx("span",{className:"inline-flex items-center justify-center h-7 w-7 text-sm",children:t??e})}function US(t){if(typeof t!="string")return null;const e=t.trim().toLowerCase();return e==="week"||e==="month"||e==="total"?e:null}function mye(t){if(!t)return F("shared.error.prefix",{error:F("leaderboard.error.unknown")});const e=t?.message||String(t),n=String(e||"").trim()||F("leaderboard.error.unknown");return F("shared.error.prefix",{error:n})}function QU(t){return typeof t!="string"?"":t.trim()}function gye(t){const e=QU(t);return e?e.toLowerCase()==="anonymous":!0}function yye(t,e=""){if(typeof t!="string")return null;const n=t.trim().toLowerCase();if(!n)return null;const r=new URLSearchParams(typeof e=="string"?e:""),i=US(r.get("period")),a=i?`?period=${i}`:"";return`/share/pv1-${n}${a}`}function bD(t,e){const n=typeof t?.user_id=="string"?t.user_id.trim():"";return n||`${t?.rank??""}:${e}`}function _D({githubUrl:t}){return m.jsxs("span",{className:"relative inline-flex items-center group/gh shrink-0",children:[m.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),"aria-label":F("leaderboard.github.aria"),className:"text-oai-black hover:text-oai-gray-500 dark:text-white dark:hover:text-oai-gray-400 transition-colors",children:m.jsx(Qc,{provider:"GITHUB",size:16})}),m.jsxs("span",{role:"tooltip",className:"invisible opacity-0 group-hover/gh:visible group-hover/gh:opacity-100 absolute right-0 bottom-full mb-2 whitespace-nowrap rounded-md bg-oai-black dark:bg-oai-gray-700 px-2.5 py-1.5 text-[11px] leading-relaxed text-white shadow-lg transition-opacity duration-150 z-50 before:content-[''] before:absolute before:inset-x-0 before:top-full before:h-2.5",children:[m.jsx("span",{className:"block",children:F("leaderboard.github.tooltipAction")}),m.jsxs("span",{className:"block text-oai-gray-300 dark:text-oai-gray-400",children:[F("leaderboard.github.tooltipPrefix")," ",m.jsx(Ei,{to:"/settings",onClick:e=>e.stopPropagation(),className:"text-white underline underline-offset-2 decoration-oai-gray-400 hover:text-oai-brand-300 hover:decoration-oai-brand-300",children:F("leaderboard.github.tooltipSettingsLink")}),F("leaderboard.github.tooltipSuffix")]})]})]})}function vye({auth:t,signedIn:e,sessionSoftExpired:n}){const r=Hi(),i=Jd(),{openLoginModal:a}=Ep(),{signedIn:s,loading:o,user:c}=ss(),u=x.useMemo(()=>VO(),[]),f=wr(),h=e&&!n,p=x.useMemo(()=>h&&(typeof t=="function"||typeof t=="string"||t&&typeof t=="object")?t:null,[t,h]),y=h?p:null,v=h&&Ol(y),w=F("shared.placeholder.short"),b=x.useMemo(()=>Kd.map(Z=>Z.key),[]),{order:_,reorder:E}=fye(b),M=x.useMemo(()=>{const Z=new Map;for(const pe of Kd)Z.set(pe.key,pe);return Z},[]),T=x.useMemo(()=>_.map(Z=>M.get(Z)).filter(Boolean),[_,M]),R=Mge(nD(cM,{activationConstraint:{distance:6}}),nD(oM,{coordinateGetter:J0e})),A=x.useCallback(Z=>{const{active:pe,over:Se}=Z;!Se||pe.id===Se.id||E(String(pe.id),String(Se.id))},[E]),[P,k]=x.useState(1),[N,j]=x.useState(hye),L=x.useCallback(Z=>{const pe=OS.includes(Z)?Z:FS;j(pe),k(1);try{window.localStorage.setItem(JU,String(pe))}catch{}},[]),[V,U]=x.useState(0),[z,W]=x.useState(()=>({loading:!1,error:null,data:null})),[K,Q]=x.useState(()=>yk()),[O,G]=x.useState(!1),Y=x.useMemo(()=>{const Z=new URLSearchParams(r?.search||"");return US(Z.get("period"))||"total"},[r?.search]),H=r?.search||"",te=Z=>{const pe=US(Z);if(!pe||pe===Y)return;const Se=new URLSearchParams(r?.search||"");Se.set("period",pe),k(1),i(`${r?.pathname||"/leaderboard"}?${Se.toString()}`,{replace:!0})};x.useEffect(()=>{o||f||s||a()},[s,o,f,a]),x.useEffect(()=>{k(1)},[Y]);const re=x.useMemo(()=>(Xd(P,{min:1,max:1e6,fallback:1})-1)*N,[P,N]);x.useEffect(()=>{if(!u&&!f)return;let Z=!0;return W(pe=>({...pe,loading:!0,error:null})),(async()=>{const pe=await v3({userId:c?.id||null,period:Y,limit:N,offset:re});Z&&W({loading:!1,error:null,data:pe})})().catch(pe=>{Z&&W({loading:!1,error:mye(pe),data:null})}),()=>{Z=!1}},[u,c?.id,re,V,f,Y,N]);const ue=z.data,ce=ue?.total_pages??null,ee=ue?.page??P,le=x.useMemo(()=>eye(ee,ce),[ee,ce]),ve=ue?.from||null,Pe=ue?.to||null,be=ue?.generated_at||null,Ye=ue?.me||null,he=F("leaderboard.me_label"),Ue=F("leaderboard.anon_label"),je=F("leaderboard.period.week"),et=F("leaderboard.period.month"),_e=F("leaderboard.period.total"),oe=Y==="month"?et:Y==="total"?_e:je,J=x.useMemo(()=>{const Z=Array.isArray(ue?.entries)?ue.entries:[];return ee!==1?Z:nye({entries:Z,me:Ye,meLabel:he,limit:N})},[ee,ue?.entries,Ye,he,N]),ze=async()=>{G(!0);try{c3(!0),Q(!0),await GO(()=>qh(y));const Z=await qh(y);Z&&await sW({accessToken:Z,period:Y,source:"leaderboard-enable-sync"}),U(pe=>pe+1)}catch(Z){console.warn("[tokentracker] sync:",Z)}finally{G(!1)}},{canPrev:Ne,canNext:De}=tye({page:ee,totalPages:ce}),Le=Array.isArray(J)&&J.length!==0;let $=null;z.loading?$=m.jsx(cye,{rows:N}):z.error?$=m.jsx("div",{className:"px-6 py-12 text-center",children:m.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:z.error})}):Le?$=m.jsx(C0e,{sensors:R,collisionDetection:Cge,modifiers:[O0e],onDragEnd:A,children:m.jsx("div",{className:"w-full overflow-x-auto",children:m.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[m.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:m.jsxs("tr",{children:[m.jsx("th",{className:vt(uM,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:F("leaderboard.column.rank")}),m.jsx("th",{className:vt(KU,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:F("leaderboard.column.user")}),m.jsx("th",{className:"px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap text-right align-middle",children:F("leaderboard.column.total")}),m.jsx("th",{className:"px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap text-right align-middle",title:"Based on estimated API pricing, not actual billing",children:F("leaderboard.column.est_cost")}),m.jsx(V0e,{items:_,strategy:B0e,children:T.map(Z=>m.jsx(uye,{id:Z.key,thClassName:"px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap align-middle",children:m.jsx(XU,{iconSrc:Z.icon,label:F(Z.copyKey)})},Z.key))})]})}),m.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:J.map((Z,pe)=>{if(Z?.is_ellipsis){const We=4+T.length;return m.jsx("tr",{"aria-hidden":"true",children:m.jsx("td",{colSpan:We,className:"px-4 py-2 text-center text-oai-gray-400 dark:text-oai-gray-600 bg-white dark:bg-oai-gray-950 select-none tracking-[0.4em] text-xs",children:"···"})},`ellipsis-${pe}`)}const Se=!!Z?.is_me,xe=typeof Z?.user_id=="string"?Z.user_id:null,Ie=QU(Z?.display_name),He=gye(Ie)?Ue:Ie,qe=Se?he:He;return!!xe&&!Se&&!!Z?.is_public&&yye(xe,H),Se?m.jsxs("tr",{className:"border-y border-oai-brand-300/40 dark:border-oai-brand-500/30 bg-oai-brand-50 dark:bg-oai-brand-900/10 transition-colors",children:[m.jsx("td",{className:vt(ky(!0),"font-semibold text-oai-brand-600 dark:text-oai-brand-400"),children:m.jsx(xD,{rank:Z?.rank,placeholder:w})}),m.jsx("td",{className:IS(!0),children:m.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[m.jsx(LS,{avatarUrl:Z?.avatar_url,displayName:qe,seed:bD(Z,qe)}),m.jsx("span",{className:"truncate font-semibold text-oai-black dark:text-oai-white",children:qe}),Z?.github_url&&m.jsx(_D,{githubUrl:Z.github_url})]})}),m.jsx("td",{className:"px-4 py-4 font-medium text-oai-black dark:text-oai-white whitespace-nowrap text-right tabular-nums bg-oai-brand-50 dark:bg-oai-brand-900/10",children:Oi(Z?.total_tokens)}),m.jsx("td",{className:"px-4 py-4 font-medium text-oai-brand-600 dark:text-oai-brand-400 whitespace-nowrap text-right tabular-nums bg-oai-brand-50 dark:bg-oai-brand-900/10",title:"Based on estimated API pricing, not actual billing",children:yD(Z?.estimated_cost_usd)}),vD(Z,!0,T)]},`row-${Z?.rank}-${qe}`):m.jsxs("tr",{className:"group transition-colors",children:[m.jsx("td",{className:vt(ky(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:m.jsx(xD,{rank:Z?.rank,placeholder:w})}),m.jsx("td",{className:IS(!1),children:m.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[m.jsx(LS,{avatarUrl:Z?.avatar_url,displayName:qe,seed:bD(Z,qe)}),m.jsx("span",{className:"truncate font-medium text-oai-gray-800 dark:text-oai-gray-200",children:qe}),Z?.github_url&&m.jsx(_D,{githubUrl:Z.github_url})]})}),m.jsx("td",{className:"px-4 py-4 font-semibold text-oai-gray-800 dark:text-oai-gray-200 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",children:Oi(Z?.total_tokens)}),m.jsx("td",{className:"px-4 py-4 text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",title:"Based on estimated API pricing, not actual billing",children:yD(Z?.estimated_cost_usd)}),vD(Z,!1,T)]},`row-${Z?.rank}-${qe}`)})})]})})}):$=m.jsx("div",{className:"px-6 py-12 text-center",children:m.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:F("leaderboard.empty")})});let I=null;return typeof ce=="number"?I=le.map((Z,pe)=>Z==null?m.jsx("span",{className:"px-2 text-oai-gray-400 dark:text-oai-gray-500",children:F("leaderboard.pagination.ellipsis")},`ellipsis-${pe}`):m.jsx("button",{className:vt("flex h-8 w-8 items-center justify-center rounded-md text-sm font-medium transition-colors",Z===ee?"bg-oai-gray-200 dark:bg-oai-gray-800 text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white"),onClick:()=>k(Z),disabled:z.loading,children:String(Z)},`page-${Z}`)):I=m.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:F("leaderboard.pagination.page_unknown",{page:String(ee)})}),m.jsxs("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:[m.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:m.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[m.jsxs("div",{className:"flex flex-col md:flex-row md:items-end justify-between gap-6 mb-8",children:[m.jsxs("div",{children:[m.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:F("leaderboard.title")}),m.jsxs("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:[Y==="total"?F("leaderboard.range.total"):ve&&Pe?F("leaderboard.range",{period:oe,from:ve,to:Pe}):F("leaderboard.range_loading",{period:oe}),be&&m.jsx("span",{className:"ml-2 pl-2 border-l border-oai-gray-200 dark:border-oai-gray-800 inline-block text-oai-gray-400 dark:text-oai-gray-500 text-xs",children:F("leaderboard.generated_at",{ts:be})})]})]}),m.jsx("div",{className:"flex items-center gap-2",children:m.jsx("div",{className:"inline-flex p-1 border border-oai-gray-200 dark:border-oai-gray-800 rounded-lg",children:["week","month","total"].map(Z=>m.jsx("button",{onClick:()=>te(Z),disabled:z.loading,className:vt("px-4 py-1.5 text-sm font-medium rounded-md transition-colors",Y===Z?"bg-oai-gray-200 dark:bg-oai-gray-800 text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-200"),children:Z==="week"?je:Z==="month"?et:_e},Z))})})]}),!e&&m.jsxs("div",{className:"mb-6 flex items-center justify-between text-sm",children:[m.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:F("leaderboard.signin_prompt")}),m.jsx("button",{onClick:a,className:"px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 transition-colors",children:F("leaderboard.signin_button")})]}),h&&v&&!K&&m.jsxs("div",{className:"mb-6 flex items-center justify-between text-sm",children:[m.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:F("leaderboard.sync_prompt")}),m.jsx("button",{onClick:ze,disabled:O,className:"px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 disabled:opacity-50 transition-colors",children:F(O?"leaderboard.sync_button.busy":"leaderboard.sync_button.idle")})]}),m.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",children:[$,m.jsxs("div",{className:"px-6 py-3 border-t border-oai-gray-200 dark:border-oai-gray-800 flex flex-wrap items-center justify-end gap-x-4 gap-y-2",children:[m.jsxs("div",{className:"flex items-center gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[m.jsx("label",{htmlFor:"leaderboard-page-size",className:"whitespace-nowrap",children:F("leaderboard.pagination.page_size_label")}),m.jsxs("div",{className:"relative",children:[m.jsx("select",{id:"leaderboard-page-size",value:N,onChange:Z=>L(Number(Z.target.value)),disabled:z.loading,className:"appearance-none pl-3 pr-8 py-1 rounded-md bg-white dark:bg-oai-gray-950 border border-oai-gray-300 dark:border-oai-gray-700 text-oai-gray-700 dark:text-oai-gray-300 hover:border-oai-gray-400 dark:hover:border-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500 disabled:opacity-50 transition-colors",children:OS.map(Z=>m.jsx("option",{value:Z,children:Z},Z))}),m.jsx(By,{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:2,"aria-hidden":"true"})]})]}),m.jsx("div",{className:"h-5 w-px bg-oai-gray-200 dark:bg-oai-gray-800","aria-hidden":"true"}),m.jsx("button",{className:vt("px-3 py-1.5 text-sm font-medium text-oai-gray-500 dark:text-oai-gray-400 rounded-md transition-colors",Ne&&!z.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>k(Z=>Math.max(1,Z-1)),disabled:!Ne||z.loading,children:F("leaderboard.pagination.prev")}),m.jsx("div",{className:"flex flex-wrap items-center gap-1",children:I}),m.jsx("button",{className:vt("px-3 py-1.5 text-sm font-medium text-oai-gray-500 dark:text-oai-gray-400 rounded-md transition-colors",De&&!z.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>k(Z=>Z+1),disabled:!De||z.loading,children:F("leaderboard.pagination.next")})]})]})]})}),m.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 transition-colors duration-200",children:m.jsxs("div",{className:"mx-auto flex max-w-6xl items-center justify-between px-4 sm:px-6 text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[m.jsx("p",{children:F("landing.v2.footer.line")}),m.jsx("a",{href:"https://github.com/mm7894215/TokenTracker",className:"text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",target:"_blank",rel:"noopener noreferrer",children:F("landing.v2.nav.github")})]})})]})}const Zd=18;function ej(){return m.jsxs("svg",{"aria-hidden":!0,width:Zd,height:Zd,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("circle",{cx:"12",cy:"12",r:"4"}),m.jsx("path",{d:"M12 2v2"}),m.jsx("path",{d:"M12 20v2"}),m.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),m.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),m.jsx("path",{d:"M2 12h2"}),m.jsx("path",{d:"M20 12h2"}),m.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),m.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})}function tj(){return m.jsx("svg",{"aria-hidden":!0,width:Zd,height:Zd,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:m.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function xye(){return m.jsxs("svg",{"aria-hidden":!0,width:Zd,height:Zd,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[m.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),m.jsx("path",{d:"M8 21h8"}),m.jsx("path",{d:"M12 17v4"})]})}const bye=[{value:"light",label:"Light",Icon:ej},{value:"dark",label:"Dark",Icon:tj},{value:"system",label:"System",Icon:xye}];function _ye(t){return t==="dark"?tj:ej}function wye({theme:t,resolvedTheme:e,onSetTheme:n,className:r="",direction:i="down",align:a="right"}){const[s,o]=x.useState(!1),c=x.useRef(null),u=x.useCallback(()=>o(!1),[]);x.useEffect(()=>{if(!s)return;const h=p=>{c.current&&!c.current.contains(p.target)&&u()};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s,u]),x.useEffect(()=>{if(!s)return;const h=p=>{p.key==="Escape"&&u()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[s,u]);const f=_ye(e);return m.jsxs("div",{ref:c,className:`relative ${r}`,children:[m.jsx("button",{type:"button","aria-label":"Theme","aria-expanded":s,onClick:()=>o(h=>!h),className:"flex items-center justify-center w-9 h-9 rounded-lg text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors",children:m.jsx(f,{})}),s&&m.jsx("div",{className:`absolute 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 ${i==="up"?"bottom-full mb-1":"top-full mt-1"} ${a==="left"?"left-0":"right-0"}`,children:bye.map(({value:h,label:p,Icon:y})=>{const v=t===h;return m.jsxs("button",{type:"button",onClick:()=>{n(h),u()},className:`flex w-full items-center gap-2.5 px-3 py-2 text-sm transition-colors ${v?"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:[m.jsx(y,{}),m.jsx("span",{children:p})]},h)})})]})}function Sye(t){if(!t)return F("shared.error.prefix",{error:F("leaderboard.error.unknown")});const e=t?.message||String(t),n=String(e||"").trim()||F("leaderboard.error.unknown");return F("shared.error.prefix",{error:n})}function kye(t){return typeof t!="string"?"":t.trim()}function Eye(t){if(typeof t!="string")return null;const e=t.trim().toLowerCase();return e==="week"||e==="month"||e==="total"?e:null}function Mye({auth:t,signedIn:e,sessionSoftExpired:n,userId:r}){const i=Hi(),{theme:a,resolvedTheme:s,setTheme:o}=Np(),c=x.useMemo(()=>VO(),[]),u=wr(),f=e&&!n,h=x.useMemo(()=>f&&(typeof t=="function"||typeof t=="string"||t&&typeof t=="object")?t:null,[t,f]),p=f?h:null,y=f&&Ol(p),v=x.useMemo(()=>{const U=new URLSearchParams(i?.search||"");return Eye(U.get("period"))||"week"},[i?.search]),w=i?.search||"",[b,_]=x.useState(()=>({loading:!1,error:null,data:null}));x.useEffect(()=>{if(!c&&!u||!r||f&&!y)return;let U=!0;return _(z=>({...z,loading:!0,error:null})),(async()=>{const z=f?await qh(p):null;if(!U)return;const W=await oW({accessToken:z,userId:r,period:v});U&&_({loading:!1,error:null,data:W})})().catch(z=>{if(U){if(z?.status===404){_({loading:!1,error:null,data:null});return}_({loading:!1,error:Sye(z),data:null})}}),()=>{U=!1}},[f,y,c,p,u,v,r]);const E=b.data,M=E?.from||null,T=E?.to||null,R=E?.generated_at||null,A=E?.entry||null,P=kye(A?.display_name)||F("leaderboard.anon_label"),k=F("leaderboard.period.week"),N=F("leaderboard.period.month"),j=F("leaderboard.period.total"),L=v==="month"?N:v==="total"?j:k;let V=null;return r?b.loading?V=m.jsx("div",{className:"px-6 py-12 text-center",children:m.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:F("leaderboard.loading")})}):b.error?V=m.jsx("div",{className:"px-6 py-12 text-center",children:m.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:b.error})}):A?V=m.jsx("div",{className:"w-full overflow-x-auto",children:m.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[m.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:m.jsxs("tr",{children:[m.jsx("th",{className:vt(uM,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:F("leaderboard.column.rank")}),m.jsx("th",{className:vt(sye,"font-medium text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap"),children:F("leaderboard.column.total")}),Kd.map(U=>m.jsx("th",{className:"px-4 py-4 font-medium text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap",children:m.jsx(XU,{iconSrc:U.icon,label:F(U.copyKey)})},U.key))]})}),m.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:m.jsxs("tr",{className:"transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/60",children:[m.jsx("td",{className:vt(ky(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:A?.rank??F("shared.placeholder.short")}),m.jsx("td",{className:vt(oye(),"text-oai-gray-700 dark:text-oai-gray-300"),children:Oi(A?.total_tokens)}),Kd.map(U=>m.jsx("td",{className:"px-4 py-4 text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap",children:Oi(A?.[U.key])},U.key))]})})]})}):V=m.jsx("div",{className:"px-6 py-12 text-center",children:m.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:F("leaderboard.empty")})}):V=m.jsx("div",{className:"px-6 py-12 text-center",children:m.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:F("leaderboard.empty")})}),m.jsxs("div",{className:"flex flex-col min-h-screen bg-oai-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-oai antialiased transition-colors duration-200",children:[m.jsx("header",{className:"sticky top-0 z-50 bg-white/80 dark:bg-oai-gray-950/80 backdrop-blur-md border-b border-oai-gray-200 dark:border-oai-gray-900 transition-colors duration-200",children:m.jsxs("div",{className:"mx-auto flex h-14 max-w-6xl items-center justify-between px-4 sm:px-6",children:[m.jsxs("div",{className:"flex items-center gap-5",children:[m.jsxs(Ei,{to:"/",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:[m.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),m.jsx("span",{className:"text-sm font-semibold tracking-wide text-oai-black dark:text-white uppercase",children:"Token Tracker"})]}),m.jsx("div",{className:"hidden sm:block",children:m.jsx(U5,{})})]}),m.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[m.jsx(Ei,{to:`/leaderboard${w}`,className:"no-underline inline-flex items-center justify-center h-9 px-5 text-sm font-medium rounded-full shadow-sm ring-1 ring-oai-gray-200 dark:ring-white/10 bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-900 hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors",children:F("leaderboard.profile.nav.back")}),m.jsx(wye,{theme:a,resolvedTheme:s,onSetTheme:o}),m.jsx(hy,{})]})]})}),m.jsx("main",{className:"flex-1 py-12 sm:py-16",children:m.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[m.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-6 mb-10",children:[m.jsx(LS,{avatarUrl:A?.avatar_url,displayName:P,seed:typeof r=="string"?r:P,size:"lg",className:"shrink-0 ring-2 ring-oai-gray-200 dark:ring-oai-gray-800"}),m.jsxs("div",{className:"min-w-0",children:[m.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:P}),m.jsxs("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:[v==="total"?F("leaderboard.range.total"):M&&T?F("leaderboard.range",{period:L,from:M,to:T}):F("leaderboard.range_loading",{period:L}),R&&m.jsx("span",{className:"ml-2 pl-2 border-l border-oai-gray-200 dark:border-oai-gray-800 inline-block text-oai-gray-400 dark:text-oai-gray-500 text-xs",children:F("leaderboard.generated_at",{ts:R})})]})]})]}),m.jsx("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",children:V})]})}),m.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 transition-colors duration-200",children:m.jsxs("div",{className:"mx-auto flex max-w-6xl items-center justify-between px-4 sm:px-6 text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[m.jsx("p",{children:F("landing.v2.footer.line")}),m.jsx(Ei,{to:`/leaderboard${w}`,className:"text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",children:F("leaderboard.profile.nav.back")})]})})]})}const Ts=["claude","codex","cursor","gemini","kimi","kiro","copilot","antigravity"],wD={claude:"Claude",codex:"Codex",cursor:"Cursor",gemini:"Gemini",kimi:"Kimi",kiro:"Kiro",copilot:"GitHub Copilot",antigravity:"Antigravity"},Tye={claude:"/brand-logos/claude-code.svg",codex:"/brand-logos/codex.svg",cursor:"/brand-logos/cursor.svg",gemini:"/brand-logos/gemini.svg",kimi:"/brand-logos/kimi.svg",kiro:"/brand-logos/kiro.svg",copilot:"/brand-logos/copilot.svg",antigravity:"/brand-logos/antigravity.svg"},jS="tt.limits.providerOrder",BS="tt.limits.providerVisibility";function SD(){if(typeof window>"u")return[...Ts];try{const t=window.localStorage.getItem(jS);if(!t)return[...Ts];const e=JSON.parse(t);if(!Array.isArray(e))return[...Ts];const n=e.filter(r=>Ts.includes(r));for(const r of Ts)n.includes(r)||n.push(r);return n}catch{return[...Ts]}}function kD(){const t=Object.fromEntries(Ts.map(e=>[e,!0]));if(typeof window>"u")return t;try{const e=window.localStorage.getItem(BS);if(!e)return t;const n=JSON.parse(e);if(!n||typeof n!="object")return t;const r={...t};for(const i of Ts)typeof n[i]=="boolean"&&(r[i]=n[i]);return r}catch{return t}}function nj(){const[t,e]=x.useState(SD),[n,r]=x.useState(kD);x.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(jS,JSON.stringify(t))}catch{}},[t]),x.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(BS,JSON.stringify(n))}catch{}},[n]),x.useEffect(()=>{if(typeof window>"u")return;const f=h=>{h.key===jS&&e(SD()),h.key===BS&&r(kD())};return window.addEventListener("storage",f),()=>window.removeEventListener("storage",f)},[]);const i=x.useCallback(f=>{r(h=>({...h,[f]:!h[f]}))},[]),a=x.useCallback(f=>{e(h=>{const p=h.indexOf(f);if(p<=0)return h;const y=[...h];return[y[p-1],y[p]]=[y[p],y[p-1]],y})},[]),s=x.useCallback(f=>{e(h=>{const p=h.indexOf(f);if(p<0||p>=h.length-1)return h;const y=[...h];return[y[p],y[p+1]]=[y[p+1],y[p]],y})},[]),o=x.useCallback((f,h)=>{f!==h&&e(p=>{const y=p.indexOf(f),v=p.indexOf(h);if(y<0||v<0)return p;const w=[...p],[b]=w.splice(y,1);return w.splice(v,0,b),w})},[]),c=x.useCallback(()=>{e([...Ts]),r(Object.fromEntries(Ts.map(f=>[f,!0])))},[]),u=x.useMemo(()=>t.filter(f=>n[f]!==!1),[t,n]);return{order:t,visibility:n,visibleOrdered:u,toggle:i,moveUp:a,moveDown:s,moveToward:o,reset:c}}const Cye=[3,2,3,3,2,2,3];function Oc({className:t}){return m.jsx("div",{className:vt("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function Aye(){return m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Oc,{className:"h-3 w-12 shrink-0"}),m.jsx(Oc,{className:"flex-1 h-1.5 rounded-full min-w-0"}),m.jsx(Oc,{className:"h-3 w-[30px] shrink-0"}),m.jsx(Oc,{className:"h-3 w-6 shrink-0"})]})}function Rye({bars:t,index:e}){const n=e%3===0?"w-24":e%3===1?"w-20":"w-[4.5rem]";return m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Oc,{className:"h-[14px] w-[14px] rounded shrink-0"}),m.jsx(Oc,{className:vt("h-4",n)})]}),Array.from({length:t},(r,i)=>m.jsx(Aye,{},i))]})}function Pye(){return m.jsx(fu,{children:m.jsxs("div",{className:"flex flex-col gap-3",children:[m.jsx(Oc,{className:"h-3.5 w-28"}),Cye.map((t,e)=>m.jsx(Rye,{bars:t,index:e},e))]})})}function xr(t){if(!t)return null;const e=typeof t=="number"?t*1e3:Date.parse(t);if(!Number.isFinite(e))return null;const n=e-Date.now();if(n<=0)return F("shared.time.now");const r=Math.floor(n/6e4);if(r<60)return`${r}m`;const i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function Nye(t){return t>=90?"bg-red-500":t>=70?"bg-amber-500":"bg-emerald-500"}function br({label:t,pct:e,reset:n}){const r=Math.max(0,Math.min(100,Number(e)||0)),i=Math.round(r),a=r>0&&i===0?Math.max(r,.35):r,s=r>0&&i===0?"<1":String(i);return m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 w-12 shrink-0",children:t}),m.jsx("div",{className:"flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:m.jsx("div",{className:`${Nye(i)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${a}%`,minWidth:r>0?"3px":0}})}),m.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-[30px] text-right shrink-0",children:[s,"%"]}),n?m.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:n}):null]})}function bs({name:t,icon:e,children:n}){const i=e==="/brand-logos/cursor.svg"||e==="/brand-logos/kiro.svg"||e==="/brand-logos/copilot.svg"||e==="/brand-logos/kimi.svg"?"w-[14px] h-[14px] dark:invert":"w-[14px] h-[14px]";return m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[e?m.jsx("img",{src:e,alt:"",className:i}):null,m.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:t})]}),n]})}const Dye=["claude","codex","cursor","gemini","kimi","kiro","copilot","antigravity"],Lye={claude:{name:"Claude",icon:"/brand-logos/claude-code.svg"},codex:{name:"Codex",icon:"/brand-logos/codex.svg"},cursor:{name:"Cursor",icon:"/brand-logos/cursor.svg"},gemini:{name:"Gemini",icon:"/brand-logos/gemini.svg"},kimi:{name:"Kimi",icon:"/brand-logos/kimi.svg"},kiro:{name:"Kiro",icon:"/brand-logos/kiro.svg"},copilot:{name:"GitHub Copilot",icon:"/brand-logos/copilot.svg"},antigravity:{name:"Antigravity",icon:"/brand-logos/antigravity.svg"}};function xa({children:t,tone:e="neutral"}){const n=e==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400";return m.jsx("div",{className:`text-[11px] leading-snug ${n}`,children:t})}function Iye(t,e){const n=Lye[t];if(!n)return null;if(!e?.configured)return m.jsx(bs,{name:n.name,icon:n.icon,children:m.jsx(xa,{children:F("limits.status.not_connected")})},t);if(e.error)return m.jsx(bs,{name:n.name,icon:n.icon,children:m.jsx(xa,{tone:"error",children:F("shared.error.prefix",{error:e.error})})},t);switch(t){case"claude":return m.jsxs(bs,{name:n.name,icon:n.icon,children:[e.five_hour?m.jsx(br,{label:"5h",pct:e.five_hour.utilization,reset:xr(e.five_hour.resets_at)}):null,e.seven_day?m.jsx(br,{label:"7d",pct:e.seven_day.utilization,reset:xr(e.seven_day.resets_at)}):null,e.seven_day_opus?m.jsx(br,{label:"Opus",pct:e.seven_day_opus.utilization,reset:xr(e.seven_day_opus.resets_at)}):null,!e.five_hour&&!e.seven_day&&!e.seven_day_opus?m.jsx(xa,{children:F("limits.status.no_data")}):null]},"claude");case"codex":return m.jsxs(bs,{name:n.name,icon:n.icon,children:[e.primary_window?m.jsx(br,{label:"5h",pct:e.primary_window.used_percent,reset:xr(e.primary_window.reset_at)}):null,e.secondary_window?m.jsx(br,{label:"7d",pct:e.secondary_window.used_percent,reset:xr(e.secondary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window?m.jsx(xa,{children:F("limits.status.no_data")}):null]},"codex");case"cursor":return m.jsxs(bs,{name:n.name,icon:n.icon,children:[e.primary_window?m.jsx(br,{label:F("limits.label.cursor_plan"),pct:e.primary_window.used_percent,reset:xr(e.primary_window.reset_at)}):null,e.secondary_window?m.jsx(br,{label:F("limits.label.cursor_auto"),pct:e.secondary_window.used_percent,reset:xr(e.secondary_window.reset_at)}):null,e.tertiary_window?m.jsx(br,{label:F("limits.label.cursor_api"),pct:e.tertiary_window.used_percent,reset:xr(e.tertiary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window&&!e.tertiary_window?m.jsx(xa,{children:F("limits.status.no_data")}):null]},"cursor");case"gemini":return m.jsxs(bs,{name:n.name,icon:n.icon,children:[e.primary_window?m.jsx(br,{label:"Pro",pct:e.primary_window.used_percent,reset:xr(e.primary_window.reset_at)}):null,e.secondary_window?m.jsx(br,{label:"Flash",pct:e.secondary_window.used_percent,reset:xr(e.secondary_window.reset_at)}):null,e.tertiary_window?m.jsx(br,{label:"Lite",pct:e.tertiary_window.used_percent,reset:xr(e.tertiary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window&&!e.tertiary_window?m.jsx(xa,{children:F("limits.status.no_data")}):null]},"gemini");case"kimi":return m.jsxs(bs,{name:n.name,icon:n.icon,children:[e.primary_window?m.jsx(br,{label:F("limits.label.kimi_weekly"),pct:e.primary_window.used_percent,reset:xr(e.primary_window.reset_at)}):null,e.secondary_window?m.jsx(br,{label:F("limits.label.kimi_5h"),pct:e.secondary_window.used_percent,reset:xr(e.secondary_window.reset_at)}):null,e.tertiary_window?m.jsx(br,{label:F("limits.label.kimi_total"),pct:e.tertiary_window.used_percent,reset:xr(e.tertiary_window.reset_at)}):null,e.parallel_limit?m.jsx(xa,{children:F("limits.label.kimi_parallel",{count:e.parallel_limit})}):null,!e.primary_window&&!e.secondary_window&&!e.tertiary_window?m.jsx(xa,{children:F("limits.status.no_data")}):null]},"kimi");case"kiro":return m.jsxs(bs,{name:n.name,icon:n.icon,children:[e.primary_window?m.jsx(br,{label:F("limits.label.kiro_month"),pct:e.primary_window.used_percent,reset:xr(e.primary_window.reset_at)}):null,e.secondary_window?m.jsx(br,{label:F("limits.label.kiro_bonus"),pct:e.secondary_window.used_percent,reset:xr(e.secondary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window?m.jsx(xa,{children:F("limits.status.no_data")}):null]},"kiro");case"antigravity":return m.jsxs(bs,{name:n.name,icon:n.icon,children:[e.primary_window?m.jsx(br,{label:"Claude",pct:e.primary_window.used_percent,reset:xr(e.primary_window.reset_at)}):null,e.secondary_window?m.jsx(br,{label:"G Pro",pct:e.secondary_window.used_percent,reset:xr(e.secondary_window.reset_at)}):null,e.tertiary_window?m.jsx(br,{label:"Flash",pct:e.tertiary_window.used_percent,reset:xr(e.tertiary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window&&!e.tertiary_window?m.jsx(xa,{children:F("limits.status.no_data")}):null]},"antigravity");case"copilot":return m.jsxs(bs,{name:n.name,icon:n.icon,children:[e.primary_window?m.jsx(br,{label:F("limits.label.copilot_premium"),pct:e.primary_window.used_percent,reset:xr(e.primary_window.reset_at)}):null,e.secondary_window?m.jsx(br,{label:F("limits.label.copilot_chat"),pct:e.secondary_window.used_percent,reset:xr(e.secondary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window?m.jsx(xa,{children:F("limits.status.no_data")}):null,e.otel_has_files||e.otel_enabled?null:m.jsx(Oye,{defaultDir:e.otel_default_dir})]},"copilot");default:return null}}function Oye({defaultDir:t}){const[e,n]=x.useState(!1),i=["export COPILOT_OTEL_ENABLED=true","export COPILOT_OTEL_EXPORTER_TYPE=file",`export COPILOT_OTEL_FILE_EXPORTER_PATH="${t||"$HOME/.copilot/otel"}/copilot-otel-$(date +%Y%m%d).jsonl"`].join(`
5168
- `),a=async()=>{try{await navigator.clipboard.writeText(i),n(!0),setTimeout(()=>n(!1),1600)}catch{}};return m.jsxs("div",{className:"mt-1 rounded-md border border-amber-300/60 dark:border-amber-700/40 bg-amber-50/50 dark:bg-amber-900/10 px-2.5 py-2 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[m.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:F("limits.copilot.otelHint.title")}),m.jsx("div",{className:"mt-0.5 leading-snug",children:F("limits.copilot.otelHint.body")}),m.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-tight whitespace-pre",children:i}),m.jsx("button",{type:"button",onClick:a,className:"mt-1 inline-flex items-center gap-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 px-1.5 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:F(e?"limits.copilot.otelHint.copied":"limits.copilot.otelHint.copy")})]})}function Fye({claude:t,codex:e,cursor:n,gemini:r,kimi:i,kiro:a,antigravity:s,copilot:o,order:c,visibility:u}){const f={claude:t,codex:e,cursor:n,gemini:r,kimi:i,kiro:a,antigravity:s,copilot:o},p=(Array.isArray(c)&&c.length>0?c:Dye).filter(y=>!u||u[y]!==!1).map(y=>Iye(y,f[y])).filter(Boolean);return m.jsx(xo,{delay:.15,children:m.jsx(fu,{children:m.jsxs("div",{className:"flex flex-col gap-3",children:[m.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:F("limits.panel.title")}),p.length>0?p:m.jsx(xa,{children:F("limits.status.all_hidden")})]})})})}function Uye(){const{data:t,error:e,isLoading:n}=qO({initialRefresh:!0}),r=nj();return m.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:m.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:m.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[m.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:F("nav.limits")}),m.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:F("limits.page.subtitle")})]}),m.jsx(Ei,{to:"/settings","aria-label":F("limits.page.openSettings"),title:F("limits.page.openSettings"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 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",children:m.jsx(L3,{className:"h-4 w-4","aria-hidden":!0})})]}),n?m.jsx(Pye,{}):m.jsxs(m.Fragment,{children:[e?m.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:F("shared.error.prefix",{error:e})}):null,m.jsx(Fye,{claude:t?.claude,codex:t?.codex,cursor:t?.cursor,gemini:t?.gemini,kimi:t?.kimi,kiro:t?.kiro,antigravity:t?.antigravity,copilot:t?.copilot,order:r.order,visibility:r.visibility})]})]})})})}function jye(t){const e=new URLSearchParams(t).get("next");return typeof e!="string"||e.length===0||!e.startsWith("/")||e.startsWith("//")?"/dashboard":e}const ED={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",linkedin:"LinkedIn",facebook:"Facebook",instagram:"Instagram",tiktok:"TikTok",apple:"Apple",x:"X",spotify:"Spotify"};function MD(t){const e=String(t||"").trim();return ED[e]?ED[e]:e.replace(/-/g," ")}function Bye(){const t=Jd(),[e,n]=F8(),{enabled:r,loading:i,signedIn:a,refreshUser:s,signInWithPassword:o,signUp:c,signInWithOAuth:u,getPublicAuthConfig:f}=ss(),h=x.useMemo(()=>jye(e.toString()),[e]),[p,y]=x.useState("signin"),[v,w]=x.useState(""),[b,_]=x.useState(""),[E,M]=x.useState(""),[T,R]=x.useState(!1),[A,P]=x.useState(null),[k,N]=x.useState(null),[j,L]=x.useState(!0),[V,U]=x.useState([]),[z,W]=x.useState([]),[K,Q]=x.useState(8);x.useEffect(()=>{const ce=e.get("insforge_status"),ee=e.get("insforge_type"),le=e.get("insforge_error");ce==="success"&&ee==="verify_email"?N(F("login.verify_email_success")):ce==="error"&&ee==="verify_email"&&le&&N(F("shared.error.prefix",{error:le}))},[e]),x.useEffect(()=>{if(!r){L(!1);return}let ce=!0;return(async()=>{const{data:ee,error:le}=await f();ce&&(le||!ee?(U(["google","github"]),W([])):(U(Array.isArray(ee.oAuthProviders)?ee.oAuthProviders:[]),W(Array.isArray(ee.customOAuthProviders)?ee.customOAuthProviders:[]),typeof ee.passwordMinLength=="number"&&ee.passwordMinLength>0&&Q(ee.passwordMinLength)),L(!1))})(),()=>{ce=!1}},[r,f]);const O=x.useMemo(()=>e.get("native")==="1",[e]),G=x.useMemo(()=>e.get("provider")||null,[e]);x.useEffect(()=>{if(!(!r||i)&&a){if(O){window.location.href="/auth/native-callback";return}t(h,{replace:!0})}},[r,i,a,t,h,O]),x.useEffect(()=>{r&&s()},[r,s]);const Y=x.useMemo(()=>typeof window>"u"||O?"":`${window.location.origin}/`,[O]),H=x.useMemo(()=>typeof window>"u"?"":`${window.location.origin}/`,[]),te=x.useCallback(async ce=>{ce.preventDefault(),P(null),R(!0);try{if(p==="signup"){const{data:le,error:ve}=await c({email:v.trim(),password:b,name:E.trim()||void 0,redirectTo:H});if(ve){P(ve.message||String(ve));return}if(le?.requireEmailVerification){N(F("login.verify_email_pending")),y("signin");return}t(h,{replace:!0});return}const{error:ee}=await o({email:v.trim(),password:b});if(ee){P(ee.message||String(ee));return}t(h,{replace:!0})}finally{R(!1)}},[p,v,b,E,c,o,t,h,H]),re=x.useCallback(async ce=>{P(null),R(!0);try{const{error:ee}=await u(ce,Y);ee&&P(ee.message||String(ee))}finally{R(!1)}},[u,Y]);x.useEffect(()=>{if(O&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[O]),x.useEffect(()=>{if(!r||i||a||j||!O||!G)return;[...V,...z].includes(G)&&re(G)},[r,i,a,j,O,G,V,z,re]);const ue=x.useCallback(()=>{n(ce=>{const ee=new URLSearchParams(ce);return ee.delete("insforge_status"),ee.delete("insforge_type"),ee.delete("insforge_error"),ee},{replace:!0}),N(null)},[n]);return r?m.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[m.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:m.jsx(Ei,{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:F("login.back_home")})}),m.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:m.jsxs("div",{className:"w-full max-w-md space-y-8",children:[m.jsxs("div",{className:"text-center",children:[m.jsx("h1",{className:"text-2xl font-semibold text-white tracking-tight",children:F("login.title")}),m.jsx("p",{className:"mt-2 text-sm text-oai-gray-500",children:F("login.subtitle")})]}),k?m.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:[m.jsx("span",{children:k}),m.jsx("button",{type:"button",onClick:ue,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:F("login.dismiss")})]}):null,A?m.jsx("p",{className:"text-sm text-red-400",role:"alert",children:F("shared.error.prefix",{error:A})}):null,m.jsx("div",{className:"space-y-3",children:j?m.jsx("div",{className:"h-11 rounded-lg bg-oai-gray-900 animate-pulse","aria-hidden":!0}):m.jsxs(m.Fragment,{children:[V.map(ce=>m.jsx("button",{type:"button",disabled:T,onClick:()=>re(ce),className:vt("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:F("login.oauth.continue",{provider:MD(ce)})},ce)),z.map(ce=>m.jsx("button",{type:"button",disabled:T,onClick:()=>re(ce),className:vt("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:F("login.oauth.continue",{provider:MD(ce)})},ce))]})}),m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"absolute inset-0 flex items-center","aria-hidden":!0,children:m.jsx("span",{className:"w-full border-t border-oai-gray-800"})}),m.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:m.jsx("span",{className:"bg-oai-gray-950 px-3 text-oai-gray-600",children:F("login.divider")})})]}),m.jsxs("div",{className:"flex rounded-lg border border-oai-gray-800 p-0.5 bg-oai-gray-900/50",children:[m.jsx("button",{type:"button",className:vt("flex-1 py-2 text-sm font-medium rounded-md transition-colors",p==="signin"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{y("signin"),P(null)},children:F("login.tab.sign_in")}),m.jsx("button",{type:"button",className:vt("flex-1 py-2 text-sm font-medium rounded-md transition-colors",p==="signup"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{y("signup"),P(null)},children:F("login.tab.sign_up")})]}),m.jsxs("form",{onSubmit:te,className:"space-y-4",children:[p==="signup"?m.jsxs("div",{children:[m.jsx("label",{htmlFor:"login-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:F("login.field.name")}),m.jsx("input",{id:"login-name",type:"text",autoComplete:"name",value:E,onChange:ce=>M(ce.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:F("login.field.name_placeholder")})]}):null,m.jsxs("div",{children:[m.jsx("label",{htmlFor:"login-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:F("login.field.email")}),m.jsx("input",{id:"login-email",type:"email",autoComplete:"email",required:!0,value:v,onChange:ce=>w(ce.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.jsxs("div",{children:[m.jsx("label",{htmlFor:"login-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:F("login.field.password")}),m.jsx("input",{id:"login-password",type:"password",autoComplete:p==="signup"?"new-password":"current-password",required:!0,minLength:p==="signup"?K:void 0,value:b,onChange:ce=>_(ce.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"}),p==="signup"?m.jsx("p",{className:"mt-1 text-xs text-oai-gray-600",children:F("login.password_hint",{min:String(K)})}):null]}),m.jsx("button",{type:"submit",disabled:T||i,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:F(p==="signup"?"login.submit.sign_up":"login.submit.sign_in")})]})]})})]}):m.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[m.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:m.jsx(Ei,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:F("login.back_home")})}),m.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:m.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",children:F("login.cloud_only")})})]})}const zye=typeof window<"u"?window.location.search:"",TD=new URLSearchParams(zye),Jg=TD.get("insforge_code")||TD.get("code")||null;function Vye(){su();const{loading:t,signedIn:e}=ss(),n=Jd(),[r,i]=x.useState("processing"),[a,s]=x.useState(null),o=x.useRef(!1);return x.useEffect(()=>{!Jg||o.current||(o.current=!0,(async()=>{try{const u=await(await fetch("/api/auth-bridge/verifier")).json();s(!!u?.native)}catch{s(!1)}})())},[]),x.useEffect(()=>{if(a!==!0||!Jg)return;i("redirecting");const c=setTimeout(()=>{window.location.href=`tokentracker://auth/callback?insforge_code=${encodeURIComponent(Jg)}`},200);return()=>clearTimeout(c)},[a]),x.useEffect(()=>{if(a!==!1||t)return;if(e){n("/dashboard",{replace:!0});return}const c=setTimeout(()=>{e||i("failed")},5e3);return()=>clearTimeout(c)},[a,t,e,n]),x.useEffect(()=>{if(!Jg&&a===null){const c=setTimeout(()=>i("failed"),3e3);return()=>clearTimeout(c)}},[a]),r==="processing"&&a!==!0&&(a===null||a===!1&&t)?m.jsx("div",{className:"min-h-screen bg-oai-gray-950"}):m.jsx("div",{className:"min-h-screen bg-oai-gray-950 text-white font-oai antialiased dark flex items-center justify-center",children:m.jsxs("div",{className:"text-center space-y-4 max-w-sm px-4",children:[r==="processing"&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"w-8 h-8 border-2 border-oai-gray-600 border-t-white rounded-full animate-spin mx-auto"}),m.jsx("p",{className:"text-oai-gray-400 text-sm",children:F("auth.callback.processing")})]}),r==="redirecting"&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"w-12 h-12 mx-auto rounded-full bg-green-500/15 flex items-center justify-center",children:m.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:m.jsx("path",{d:"M20 6 9 17l-5-5"})})}),m.jsx("p",{className:"text-white text-sm font-medium",children:F("auth.callback.success")}),m.jsx("p",{className:"text-oai-gray-500 text-xs",children:F("auth.callback.redirecting")})]}),r==="failed"&&m.jsxs("div",{className:"space-y-3",children:[m.jsx("p",{className:"text-oai-gray-300 text-sm",children:F("auth.callback.failed")}),m.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:F("auth.callback.close")})]})]})})}const Hye=new Set(["cursor","kiro","copilot","kimi"]);function Wye({checked:t,onChange:e,ariaLabel:n}){return m.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":n,onClick:e,className:vt("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",t?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:m.jsx("span",{className:vt("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",t?"translate-x-[18px]":"translate-x-[3px]")})})}function Gye({prefs:t}){const{order:e,visibility:n,toggle:r,moveToward:i}=t,[a,s]=x.useState(null),[o,c]=x.useState(null),u=y=>v=>{s(y),v.dataTransfer.effectAllowed="move",v.dataTransfer.setData("text/plain",y)},f=y=>v=>{v.preventDefault(),v.dataTransfer.dropEffect="move",a&&a!==y&&o!==y&&(c(y),i(a,y))},h=()=>{s(null),c(null)},p=y=>{y.preventDefault(),s(null),c(null)};return m.jsx(fX,{children:m.jsx("div",{className:"flex flex-col",children:e.map(y=>{const v=n[y]!==!1,w=a===y;return m.jsxs(fr.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:u(y),onDragOver:f(y),onDragEnd:h,onDrop:p,className:vt("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",w&&"opacity-40"),style:{cursor:w?"grabbing":"grab"},children:[m.jsx(D7,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),m.jsx("img",{src:Tye[y],alt:"",width:18,height:18,className:vt("h-[18px] w-[18px] shrink-0 pointer-events-none",Hye.has(y)&&"dark:invert"),draggable:!1}),m.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:wD[y]}),m.jsx("div",{onMouseDown:b=>b.stopPropagation(),draggable:!1,children:m.jsx(Wye,{checked:v,onChange:()=>r(y),ariaLabel:`${F("limits.settings.toggle_visible")}: ${wD[y]}`})})]},y)})})})}function $ye(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:{},r=e.full_name||e.name||n.name||e.user_name||e.preferred_username;return typeof r=="string"&&r.trim()?r.trim():typeof t.email=="string"&&t.email.includes("@")?t.email.split("@")[0].trim()||t.email.trim():typeof t.email=="string"?t.email.trim():""}function Yye(t){return!t||typeof t!="object"?"":typeof t.email=="string"?t.email.trim():""}function qye(t){const e=typeof t=="string"?t.trim():"";if(!e)return null;const n=e.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),r=e.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),i=n?.[1]||r?.[1];return i?`https://github.com/${i}`:null}function dM(t,e){console.warn(`[tokentracker] settings ${t}:`,e)}function Xye(t,e,n){const[r,i]=x.useState(()=>yk()),a=e&&n&&l3(),s=x.useCallback(async()=>{const o=!r;if(c3(o),i(o),!!o)try{await GO(()=>t())}catch(c){dM("cloud sync",c)}},[r,t]);return{cloudSyncOn:r,handleCloudSyncToggle:s,showLocalCloudSync:a}}function Kye(t){const[e,n]=x.useState(!1),[r,i]=x.useState(!1),[a,s]=x.useState(!1),[o,c]=x.useState(!1),[u,f]=x.useState(null),[h,p]=x.useState(!1),[y,v]=x.useState(""),[w,b]=x.useState(!1),[_,E]=x.useState(""),[M,T]=x.useState(""),[R,A]=x.useState(!1),[P,k]=x.useState(null),N=x.useMemo(()=>$ye(t),[t]),j=x.useMemo(()=>Yye(t),[t]),L=x.useMemo(()=>({setAnonymousOn:i,setCustomDisplayName:f,setGithubUrl:E,setProfileLoading:s,setPublicProfileOn:n,setShowGithubOn:b}),[]);return{anonymousOn:r,customDisplayName:u,displayName:N,editingGithub:R,editingName:h,email:j,githubError:P,githubInput:M,githubUrl:_,loadSetters:L,nameInput:y,profileLoading:a,profileSaving:o,publicProfileOn:e,setAnonymousOn:i,setCustomDisplayName:f,setEditingGithub:A,setEditingName:p,setGithubError:k,setGithubInput:T,setGithubUrl:E,setNameInput:v,setProfileLoading:s,setProfileSaving:c,setPublicProfileOn:n,setShowGithubOn:b,showGithubOn:w}}function Zye(t,e,n){x.useEffect(()=>{if(!e)return;let r=!0;return n.setProfileLoading(!0),(async()=>{try{const i=await qh({getAccessToken:t});if(!r||!i)return;const a=await Ow({accessToken:i});if(!r)return;n.setPublicProfileOn(!!a?.enabled),n.setAnonymousOn(!!a?.anonymous),a?.display_name&&n.setCustomDisplayName(a.display_name),n.setShowGithubOn(!!a?.show_github_url),n.setGithubUrl(a?.github_url||"")}catch(i){dM("load public profile",i)}finally{r&&n.setProfileLoading(!1)}})(),()=>{r=!1}},[t,e,n])}function Jye(t,e){return x.useCallback(async(n,{label:r,onError:i,onSuccess:a}={})=>{if(e.profileSaving)return!1;e.setProfileSaving(!0);try{const s=await qh({getAccessToken:t});if(!s)return!1;const o=await aW({accessToken:s,...n});return a?.(o),!0}catch(s){return i?i(s):dM(r||"mutate profile",s),!1}finally{e.setProfileSaving(!1)}},[t,e])}function Qye(t,e){return{anonymousOn:t.anonymousOn,customDisplayName:t.customDisplayName,displayName:t.displayName,editingName:t.editingName,handleAnonymousToggle:e.handleAnonymousToggle,handleSaveName:e.handleSaveName,nameInput:t.nameInput,profileLoading:t.profileLoading,profileSaving:t.profileSaving,setEditingName:t.setEditingName,setNameInput:t.setNameInput,startEditingName:e.startEditingName}}function eve(t,e){return{editingGithub:t.editingGithub,githubError:t.githubError,githubInput:t.githubInput,githubUrl:t.githubUrl,handleSaveGithub:e.handleSaveGithub,handleShowGithubToggle:e.handleShowGithubToggle,profileLoading:t.profileLoading,profileSaving:t.profileSaving,setEditingGithub:t.setEditingGithub,setGithubError:t.setGithubError,setGithubInput:t.setGithubInput,showGithubOn:t.showGithubOn,startEditingGithub:e.startEditingGithub}}function tve(t,e){const n=x.useCallback(async()=>{const i=!t.publicProfileOn;await e({enabled:i},{label:"toggle public profile",onSuccess:()=>t.setPublicProfileOn(i)})},[e,t]);return{handleAnonymousToggle:x.useCallback(async()=>{const i=!t.anonymousOn;await e({anonymous:i},{label:"toggle anonymous",onSuccess:()=>t.setAnonymousOn(i)})},[e,t]),handlePublicProfileToggle:n}}function nve(t,e){const n=x.useCallback(async()=>{const i=t.nameInput.trim().slice(0,50);i&&await e({display_name:i},{label:"save display name",onSuccess:()=>{t.setCustomDisplayName(i),t.setEditingName(!1)}})},[e,t]),r=x.useCallback(()=>{t.setNameInput(t.customDisplayName||t.displayName),t.setEditingName(!0)},[t]);return{handleSaveName:n,startEditingName:r}}function rve(t,e){const n=x.useCallback(async()=>{if(!t.showGithubOn&&!t.githubUrl){t.setEditingGithub(!0),t.setGithubInput(""),t.setGithubError(null);return}const a=!t.showGithubOn;await e({show_github_url:a},{label:"toggle GitHub profile",onSuccess:()=>t.setShowGithubOn(a)})},[e,t]),r=x.useCallback(async()=>{const a=qye(t.githubInput);if(t.githubInput.trim()&&!a){t.setGithubError(F("settings.account.githubUrlInvalid"));return}t.setGithubError(null),await e({github_url:a,show_github_url:!!a},{label:"save GitHub profile",onError:s=>t.setGithubError(s?.message||F("settings.account.githubUrlInvalid")),onSuccess:s=>{t.setGithubUrl(s?.github_url||a||""),t.setShowGithubOn(!!a),t.setEditingGithub(!1)}})},[e,t]),i=x.useCallback(()=>{t.setGithubInput(t.githubUrl),t.setGithubError(null),t.setEditingGithub(!0)},[t]);return{handleSaveGithub:r,handleShowGithubToggle:n,startEditingGithub:i}}function ive(){const t=ss(),e=Kye(t.user),n=Xye(t.getAccessToken,t.enabled,t.signedIn);Zye(t.getAccessToken,t.signedIn,e.loadSetters);const r=Jye(t.getAccessToken,e),i=tve(e,r),a=nve(e,r),s=rve(e,r);return{...t,...n,email:e.email,handlePublicProfileToggle:i.handlePublicProfileToggle,name:Qye(e,{...i,...a}),github:eve(e,s),profileLoading:e.profileLoading,profileSaving:e.profileSaving,publicProfileOn:e.publicProfileOn}}function yf({checked:t,onChange:e,disabled:n,ariaLabel:r}){return m.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":r,onClick:e,disabled:n,className:vt("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 disabled:cursor-not-allowed",t?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:m.jsx("span",{className:vt("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",t?"translate-x-[18px]":"translate-x-[3px]")})})}function zc({label:t,hint:e,control:n}){return m.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:t}),e?m.jsx("div",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e}):null]}),m.jsx("div",{className:"shrink-0",children:n})]})}function Gp({title:t,subtitle:e,action:n,children:r}){return m.jsxs(fu,{children:[m.jsxs("div",{className:"mb-3 flex items-start justify-between gap-4",children:[m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("h2",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:t}),e?m.jsx("p",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e}):null]}),n?m.jsx("div",{className:"shrink-0",children:n}):null]}),m.jsx("div",{className:"-mb-3 divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:r})]})}function CD({options:t,value:e,onChange:n}){return m.jsx("div",{className:"inline-flex items-center rounded-lg border border-oai-gray-200 bg-oai-gray-50 p-0.5 dark:border-oai-gray-800 dark:bg-oai-gray-900",children:t.map(({value:r,label:i,Icon:a})=>{const s=e===r;return m.jsxs("button",{type:"button",onClick:()=>n(r),"aria-pressed":s,className:vt("inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",s?"bg-white text-oai-black shadow-sm dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:[a?m.jsx(a,{className:"h-3.5 w-3.5","aria-hidden":!0}):null,m.jsx("span",{children:i})]},r)})})}function rj({disabled:t,onCancel:e,onSave:n,saveLabel:r=F("settings.account.save")}){return m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",onClick:n,disabled:t,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:r}),m.jsx("button",{type:"button",onClick:e,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:F("settings.account.cancel")})]})}function ave({nameInput:t,setEditingName:e,setNameInput:n,profileSaving:r,handleSaveName:i}){return m.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[m.jsx("input",{type:"text",value:t,onChange:a=>n(a.target.value),onKeyDown:a=>{a.key==="Enter"&&i(),a.key==="Escape"&&e(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:F("settings.account.displayName")}),m.jsx(rj,{disabled:r||!t.trim(),onCancel:()=>e(!1),onSave:i,saveLabel:r?F("settings.account.saving"):void 0})]})}function sve({githubError:t,githubInput:e,handleSaveGithub:n,profileSaving:r,setEditingGithub:i,setGithubError:a,setGithubInput:s}){return m.jsxs("div",{className:"mt-2",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("input",{type:"text",value:e,onChange:o=>{s(o.target.value),t&&a(null)},onKeyDown:o=>{o.key==="Enter"&&n(),o.key==="Escape"&&(i(!1),a(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:F("settings.account.githubUrlPlaceholder")}),m.jsx(rj,{disabled:r,onCancel:()=>{i(!1),a(null)},onSave:n,saveLabel:r?F("settings.account.saving"):void 0})]}),t?m.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:t}):null]})}function ij({disabled:t=!1,label:e,onClick:n,title:r}){return m.jsxs("button",{type:"button",onClick:n,disabled:t,title:r,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[m.jsx(X7,{className:"h-3.5 w-3.5","aria-hidden":!0}),e]})}function aj({actions:t,editing:e,editor:n,hint:r,label:i}){return m.jsx("div",{className:"py-3",children:m.jsxs("div",{className:"flex items-start justify-between gap-4",children:[m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:i}),e?n:m.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r})]}),e?null:t]})})}function ove({name:t}){const e=t.anonymousOn?F("settings.account.displayNameDisabledWhileAnon"):void 0;return m.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[m.jsx(ij,{disabled:t.anonymousOn,label:F("settings.account.edit"),onClick:t.startEditingName,title:e}),m.jsx(yf,{checked:!t.anonymousOn,onChange:t.handleAnonymousToggle,disabled:t.profileLoading||t.profileSaving,ariaLabel:F("settings.account.displayName")})]})}function lve({name:t}){const{anonymousOn:e,customDisplayName:n,displayName:r,editingName:i,handleAnonymousToggle:a,handleSaveName:s,nameInput:o,profileLoading:c,profileSaving:u,setEditingName:f,setNameInput:h,startEditingName:p}=t,y=e?F("settings.account.displayNameAnonymousHint"):n||r;return m.jsx(aj,{label:F("settings.account.displayName"),editing:i,hint:y,editor:m.jsx(ave,{nameInput:o,setEditingName:f,setNameInput:h,profileSaving:u,handleSaveName:s}),actions:m.jsx(ove,{name:t})})}function cve({github:t}){const{editingGithub:e,githubError:n,githubInput:r,githubUrl:i,handleSaveGithub:a,handleShowGithubToggle:s,profileLoading:o,profileSaving:c,setEditingGithub:u,setGithubError:f,setGithubInput:h,showGithubOn:p,startEditingGithub:y}=t;return m.jsx(aj,{label:F("settings.account.githubUrl"),editing:e,hint:i||F("settings.account.githubUrlHint"),editor:m.jsx(sve,{githubError:n,githubInput:r,handleSaveGithub:a,profileSaving:c,setEditingGithub:u,setGithubError:f,setGithubInput:h}),actions:m.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[m.jsx(ij,{label:F("settings.account.edit"),onClick:y}),m.jsx(yf,{checked:p,onChange:s,disabled:o||c,ariaLabel:F("settings.account.githubUrl")})]})})}function uve(){const{openLoginModal:t}=Ep();return m.jsx(Gp,{title:F("settings.section.account"),children:m.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[m.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:F("settings.account.signedOutHint")}),m.jsx("button",{type:"button",onClick:t,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:F("settings.account.signIn")})]})})}function dve({name:t,github:e}){return m.jsxs(m.Fragment,{children:[m.jsx(lve,{name:t}),m.jsx(cve,{github:e})]})}function fve(){const t=ive();return t.enabled?t.signedIn?m.jsxs(Gp,{title:F("settings.section.account"),subtitle:t.email||t.name.customDisplayName||t.name.displayName,action:m.jsx(hve,{onSignOut:t.signOut}),children:[m.jsx(pve,{settings:t}),m.jsx(mve,{checked:t.publicProfileOn,disabled:t.profileLoading||t.profileSaving,onChange:t.handlePublicProfileToggle}),m.jsx(gve,{visible:t.publicProfileOn,name:t.name,github:t.github})]}):m.jsx(uve,{}):null}function hve({onSignOut:t}){return m.jsxs("button",{type:"button",onClick:()=>t(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[m.jsx(z7,{className:"h-3.5 w-3.5","aria-hidden":!0}),F("settings.account.signOut")]})}function pve({settings:t}){return t.showLocalCloudSync?m.jsx(zc,{label:F("settings.account.cloudSync"),hint:F("settings.account.cloudSyncHint"),control:m.jsx(yf,{checked:t.cloudSyncOn,onChange:t.handleCloudSyncToggle,ariaLabel:F("settings.account.cloudSync")})}):null}function mve({checked:t,disabled:e,onChange:n}){return m.jsx(zc,{label:F("settings.account.publicProfile"),hint:F("settings.account.publicProfileHint"),control:m.jsx(yf,{checked:t,onChange:n,disabled:e,ariaLabel:F("settings.account.publicProfile")})})}function gve({visible:t,name:e,github:n}){return m.jsx(Yy,{initial:!1,children:t?m.jsx(fr.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:m.jsx(dve,{name:e,github:n})},"public-profile-fields"):null})}function yve(){return[{value:"light",label:F("settings.appearance.theme.light"),Icon:Ck},{value:"dark",label:F("settings.appearance.theme.dark"),Icon:Mk},{value:"system",label:F("settings.appearance.theme.system"),Icon:zy}]}function vve(){return[{value:Xc,label:F("settings.appearance.language.system"),Icon:zy},{value:Kh,label:F("settings.appearance.language.english"),Icon:O2},{value:Uy,label:F("settings.appearance.language.chinese"),Icon:O2}]}function xve(){const{theme:t,setTheme:e}=Np(),{locale:n,setLocale:r}=su();return m.jsxs(Gp,{title:F("settings.section.appearance"),children:[m.jsx(zc,{label:F("settings.appearance.theme.label"),hint:F("settings.appearance.theme.hint"),control:m.jsx(CD,{options:yve(),value:t,onChange:e})}),m.jsx(zc,{label:F("settings.appearance.language.label"),hint:F("settings.appearance.language.hint"),control:m.jsx(CD,{options:vve(),value:n,onChange:r})})]})}function fM(){const[t,e]=x.useState(null),n=Sk()&&FW();x.useEffect(()=>{if(!n)return;const s=BW(o=>e(o));return D2(),s},[n]);const r=x.useCallback((s,o)=>{n&&(e(c=>c&&{...c,[s]:o}),Bw(s,o))},[n]),i=x.useCallback(s=>{n&&T3(s)},[n]),a=x.useCallback(()=>{n&&D2()},[n]);return{available:n,settings:t,setSetting:r,runAction:i,refresh:a}}function bve(){const{available:t,settings:e,setSetting:n,runAction:r}=fM();if(!t)return null;const i=!!e?.launchAtLogin,a=e?.launchAtLoginSupported!==!1,s=e?.updateStatus||null,o=!!e?.updateBusy,c=!!e?.isSyncing;return m.jsxs(Gp,{title:F("settings.section.menubar"),children:[a?m.jsx(zc,{label:F("settings.menubar.launchAtLogin"),hint:F("settings.menubar.launchAtLoginHint"),control:m.jsx(yf,{checked:i,onChange:()=>n("launchAtLogin",!i),ariaLabel:F("settings.menubar.launchAtLogin")})}):null,m.jsx(zc,{label:F("settings.menubar.syncNow"),hint:F("settings.menubar.syncNowHint"),control:m.jsxs("button",{type:"button",onClick:()=>r("syncNow"),disabled:c,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[m.jsx(Tk,{className:vt("h-3.5 w-3.5",c&&"animate-spin"),"aria-hidden":!0}),F(c?"settings.menubar.syncing":"settings.menubar.syncNow")]})}),m.jsx(zc,{label:F("settings.menubar.updates"),hint:s||void 0,control:m.jsxs("button",{type:"button",onClick:()=>r("checkForUpdates"),disabled:o,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[m.jsx(Ek,{className:"h-3.5 w-3.5","aria-hidden":!0}),F("settings.menubar.checkUpdates")]})})]})}function _ve(){const{available:t,settings:e,runAction:n}=fM();return!t||!e?.version?null:m.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-500",children:[m.jsxs("span",{children:["TokenTrackerBar v",e.version]}),m.jsx("span",{"aria-hidden":!0,children:"·"}),m.jsx("button",{type:"button",onClick:()=>n("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"})]})}function wve(){const t=nj();return m.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:m.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:m.jsxs("div",{className:"mx-auto max-w-3xl px-4 sm:px-6",children:[m.jsxs("div",{className:"mb-8",children:[m.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:F("settings.page.title")}),m.jsx("p",{className:"mt-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:F("settings.page.subtitle")})]}),m.jsxs("div",{className:"space-y-4",children:[m.jsx(xve,{}),m.jsx(bve,{}),m.jsx(fve,{}),m.jsx(Gp,{title:F("settings.section.limits"),children:m.jsx(Gye,{prefs:t})})]}),m.jsx(_ve,{})]})})})}const sj="tokentracker-skills";async function xv(t){const e=new URL(`/functions/${sj}`,window.location.origin);if(t)for(const[i,a]of Object.entries(t))a!=null&&a!==""&&e.searchParams.set(i,String(a));const n=await fetch(e.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),r=await n.json().catch(()=>null);if(!n.ok)throw new Error(r?.error||`Request failed with HTTP ${n.status}`);return r}async function Wl(t){const e=await Fy(),n=await fetch(`/functions/${sj}`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...e},cache:"no-store",body:JSON.stringify(t)}),r=await n.json().catch(()=>null);if(!n.ok||r?.ok===!1)throw new Error(r?.error||`Request failed with HTTP ${n.status}`);return r}function Sve(){return xv({mode:"installed"})}function kve(t={}){return xv({mode:"discover",...t.force?{force:1}:{}})}function Eve(t,e=0,n=20){return xv({mode:"search",q:t,offset:e,limit:n})}function Mve(){return xv({mode:"repos"})}function Tve(t,e){return Wl({action:"install",skill:t,targets:e})}function Cve(t){return Wl({action:"uninstall",id:t})}function Ave(t){return Wl({action:"restore",id:t})}function Rve(t,e){return Wl({action:"set_targets",id:t,targets:e})}function Pve(t,e){return Wl({action:"import_local",directory:t,targets:e})}function Nve(t,e){return Wl({action:"delete_local",directory:t,targets:e||[]})}function Dve(t){return Wl({action:"add_repo",repo:t})}function Lve(t,e){return Wl({action:"remove_repo",owner:t,name:e})}const AD=["claude","codex"],Ive={claude:"bg-orange-500/10 ring-1 ring-orange-500/20 hover:bg-orange-500/20",codex:"bg-emerald-500/10 ring-1 ring-emerald-500/20 hover:bg-emerald-500/20",gemini:"bg-sky-500/10 ring-1 ring-sky-500/20 hover:bg-sky-500/20",opencode:"bg-amber-500/10 ring-1 ring-amber-500/20 hover:bg-amber-500/20",hermes:"bg-indigo-500/10 ring-1 ring-indigo-500/20 hover:bg-indigo-500/20"},dd="all",ta="skillssh";function C0(t){return`${t.repoOwner||"local"}/${t.repoName||"local"}:${t.directory}`}function RD(t){return`install:${C0(t)}`}function zS(t){return`remove:${t.id||t.directory}`}function oj(t,e){return`target:${t}:${e}`}function Ove({skill:t,targets:e,busyKey:n,onToggleTarget:r}){const i=new Set(t.targets||[]);return m.jsx("div",{className:"flex flex-wrap gap-1",children:e.map(a=>{const s=i.has(a.id),o=n===oj(t.id,a.id),c=s?"skills.target.remove_title":"skills.target.sync_title";return m.jsx("button",{type:"button","aria-pressed":s,"aria-label":F("skills.target.toggle_aria",{target:a.label}),title:F(c,{target:a.label}),disabled:o,onClick:()=>r(t,a.id,!s),className:vt("inline-flex h-8 w-8 items-center justify-center rounded-md transition disabled:cursor-wait disabled:opacity-70",s?Ive[a.id]||"bg-oai-gray-100 dark:bg-oai-gray-800":"opacity-40 grayscale hover:bg-oai-gray-100 hover:opacity-100 hover:grayscale-0 dark:hover:bg-oai-gray-800"),children:o?m.jsx(Ml,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):m.jsx(Qc,{provider:a.id,size:16})},a.id)})})}function Fve({skill:t,targets:e,busyKey:n,onToggleTarget:r,onRemove:i}){const a=n===zS(t),s=t.repoOwner&&t.repoName?`${t.repoOwner}/${t.repoName}`:null,o=s?`${t.directory} · ${s}`:t.directory;return m.jsxs("div",{className:"group grid gap-4 px-1 py-3 lg:grid-cols-[minmax(0,1fr)_auto_auto] lg:items-center",children:[m.jsxs("div",{className:"min-w-0",title:o,children:[m.jsx("h2",{className:"truncate text-sm font-semibold text-oai-black dark:text-white",children:t.name||t.directory}),t.description?m.jsx("p",{className:"mt-0.5 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t.description}):null]}),m.jsx(Ove,{skill:t,targets:e,busyKey:n,onToggleTarget:r}),m.jsx("button",{type:"button","aria-label":F("skills.action.remove"),title:F("skills.action.remove"),disabled:a,onClick:()=>i(t),className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-oai-gray-400 opacity-0 transition duration-200 hover:bg-red-50 hover:text-red-600 group-hover:opacity-100 focus:opacity-100 disabled:cursor-wait disabled:opacity-100 dark:hover:bg-red-950/30 dark:hover:text-red-300 lg:justify-self-end",children:a?m.jsx(Ml,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):m.jsx(I3,{className:"h-4 w-4","aria-hidden":!0})})]})}function Uve({items:t,targets:e,busyKey:n,onToggleTarget:r,onRemove:i}){return m.jsxs("div",{children:[m.jsx("div",{className:"px-1 pb-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:F("skills.my.count",{count:t.length})}),m.jsx("div",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:t.map(a=>m.jsx(Fve,{skill:a,targets:e,busyKey:n,onToggleTarget:r,onRemove:i},a.id||a.key))})]})}const jve={contentVisibility:"auto",containIntrinsicSize:"0 240px"},Bve=ot.memo(function({skill:e,installed:n,installing:r,allTargets:i,defaultTargets:a,onInstall:s}){const[o,c]=x.useState(()=>(a||[]).filter(v=>i.some(w=>w.id===v))),u=v=>{c(w=>w.includes(v)?w.filter(b=>b!==v):[...w,v])},f=e.repoOwner&&e.repoName?`${e.repoOwner}/${e.repoName}`:null,h=e.installs!=null?F("skills.card.installs",{count:Number(e.installs||0).toLocaleString()}):null,p=[f,h].filter(Boolean).join(" · "),y=o.length?o.map(v=>i.find(w=>w.id===v)?.label||v).join(", "):F("skills.action.choose_targets");return m.jsxs(fu,{className:"h-full rounded-lg",bodyClassName:"flex h-full flex-col",children:[m.jsxs("div",{className:"flex items-start justify-between gap-3",children:[m.jsxs("div",{className:"min-w-0",children:[e.readmeUrl?m.jsxs("a",{href:e.readmeUrl,target:"_blank",rel:"noopener noreferrer",className:"group inline-flex max-w-full items-center gap-1 truncate text-base font-semibold text-oai-black hover:underline dark:text-white",title:e.readmeUrl,children:[m.jsx("span",{className:"truncate",children:e.name||e.directory}),m.jsx(T7,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400 opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":!0})]}):m.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:e.name||e.directory}),p?m.jsx("div",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:p}):null]}),n?m.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-md bg-oai-black/[0.06] px-2 py-1 text-xs font-medium text-oai-gray-700 ring-1 ring-oai-black/10 dark:bg-white/[0.08] dark:text-oai-gray-200 dark:ring-white/10",children:[m.jsx(Ph,{className:"h-3 w-3","aria-hidden":!0}),F("skills.card.installed")]}):null]}),e.description?m.jsx("p",{className:"mt-3 line-clamp-3 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:e.description}):null,m.jsx("div",{className:"mt-auto pt-5",children:n?m.jsxs("div",{className:"inline-flex h-8 w-full items-center justify-center gap-1.5 rounded-md bg-oai-black/[0.04] text-sm font-medium text-oai-gray-700 ring-1 ring-inset ring-oai-black/[0.08] dark:bg-white/[0.05] dark:text-oai-gray-200 dark:ring-white/[0.08]",children:[m.jsx(Ph,{className:"h-3.5 w-3.5","aria-hidden":!0}),F("skills.card.installed")]}):m.jsxs("div",{className:"flex",children:[m.jsxs(Ui,{type:"button",size:"sm",onClick:()=>s(e,o),disabled:r||o.length===0,className:"flex-1 !rounded-r-none",title:y,children:[r?m.jsx(Ml,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):m.jsx(Ek,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),o.length>1?F("skills.action.install_to",{count:o.length}):F("skills.action.install")]}),m.jsxs(zF,{children:[m.jsx(VF,{disabled:r,"aria-label":F("skills.action.choose_targets"),title:y,className:"inline-flex h-8 items-center justify-center rounded-r-md border-l border-white/20 bg-oai-black px-2 text-white hover:bg-oai-gray-800 disabled:cursor-not-allowed disabled:opacity-60 dark:border-oai-black/20 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:m.jsx(By,{className:"h-3.5 w-3.5","aria-hidden":!0})}),m.jsx(WF,{children:m.jsx($F,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:m.jsxs(YF,{className:"min-w-[200px] rounded-lg bg-white p-1.5 shadow-lg ring-1 ring-oai-gray-200 dark:bg-oai-gray-950 dark:ring-oai-gray-800",children:[m.jsx("div",{className:"px-2 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:F("skills.target.menu_label")}),i.map(v=>{const w=o.includes(v.id);return m.jsxs("button",{type:"button",onClick:()=>u(v.id),className:vt("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm",w?"bg-oai-gray-100 dark:bg-oai-gray-800":"hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900"),children:[m.jsx(Qc,{provider:v.id,size:16,className:w?"":"grayscale opacity-40"}),m.jsx("span",{className:"flex-1 text-left",children:v.label}),w?m.jsx(Ph,{className:"h-3.5 w-3.5 text-emerald-500","aria-hidden":!0}):null]},v.id)})]})})})]})]})})]})});function zve({repos:t,repoInput:e,onRepoInput:n,busyKey:r,onAdd:i,onRemove:a}){return m.jsxs("div",{className:"rounded-lg border border-oai-gray-200 bg-white p-4 dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[m.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[m.jsx(jF,{value:e,onChange:s=>n(s.target.value),placeholder:F("skills.repo.placeholder"),className:"min-w-0 flex-1"}),m.jsxs(Ui,{type:"button",variant:"secondary",size:"md",onClick:i,disabled:r==="repo:add",className:"shrink-0 whitespace-nowrap",children:[r==="repo:add"?m.jsx(Ml,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):m.jsx(D3,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),F("skills.repo.add")]})]}),t.length?m.jsx("div",{className:"mt-3 divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:t.map(s=>{const o=r===`repo:${s.owner}/${s.name}`;return m.jsxs("div",{className:"flex items-center justify-between gap-3 py-2",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsxs("div",{className:"truncate text-sm font-medium text-oai-black dark:text-white",children:[s.owner,"/",s.name]}),m.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s.branch})]}),m.jsxs(Ui,{type:"button",variant:"ghost",size:"sm",disabled:o,onClick:()=>a(s),className:"shrink-0",children:[o?m.jsx(Ml,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):m.jsx(I3,{className:"h-3.5 w-3.5","aria-hidden":!0}),m.jsx("span",{className:"sr-only",children:F("skills.repo.remove")})]})]},`${s.owner}/${s.name}`)})}):null]})}function Vve(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Hve(){const[t,e]=x.useState(Vve),[n,r]=x.useState({skills:[],targets:[]}),[i,a]=x.useState([]),[s,o]=x.useState([]),[c,u]=x.useState([]),[f,h]=x.useState(dd),[p,y]=x.useState(""),[v,w]=x.useState(""),[b,_]=x.useState(""),[E,M]=x.useState(!1),[T,R]=x.useState(""),[A,P]=x.useState(!0),[k,N]=x.useState(!1),[j,L]=x.useState(""),[V,U]=x.useState(null),[z,W]=x.useState(null),K=x.useMemo(()=>{const oe=new Set;for(const J of n.skills||[]){oe.add(C0(J).toLowerCase()),J.repoOwner&&J.repoName&&oe.add(`${J.repoOwner}/${J.repoName}:${J.sourceDirectory||J.directory}`.toLowerCase());const ze=String(J.directory||"").split(/[\\/]/).pop().toLowerCase();ze&&oe.add(`dir:${ze}`)}return oe},[n.skills]),Q=x.useCallback(async()=>{const oe=await Sve();r({skills:oe.skills||[],targets:oe.targets||[]})},[]),O=x.useCallback(async()=>{const oe=await Mve();u(oe.repos||[])},[]),G=x.useCallback(async({force:oe=!1}={})=>{N(!0);try{const J=await kve({force:oe});a(J.skills||[])}finally{N(!1)}},[]),Y=x.useCallback(async()=>{P(!0),L("");try{await Promise.all([Q(),O()])}catch(oe){L(oe?.message||F("skills.error.generic"))}finally{P(!1)}},[Q,O]),H=x.useCallback(async()=>{await Y(),t==="browse"&&f!==ta&&G({force:!0}).catch(oe=>L(oe?.message||F("skills.error.generic")))},[G,Y,f,t]);x.useEffect(()=>{Y()},[Y]),x.useEffect(()=>{t==="browse"&&f!==ta&&i.length===0&&G().catch(oe=>L(oe?.message||F("skills.error.generic")))},[i.length,G,f,t]),x.useEffect(()=>{if(!z)return;const oe=setTimeout(()=>W(J=>J?.key===z.key?null:J),z.ttlMs||5e3);return()=>clearTimeout(oe)},[z]),x.useEffect(()=>{const oe=setTimeout(()=>w(p),200);return()=>clearTimeout(oe)},[p]),x.useEffect(()=>{if(typeof window>"u")return;const oe=new URLSearchParams(window.location.search),J=oe.get("tab");if(t==="my"){if(!J)return;oe.delete("tab")}else{if(J===t)return;oe.set("tab",t)}const ze=oe.toString(),Ne=`${window.location.pathname}${ze?`?${ze}`:""}${window.location.hash}`;window.history.replaceState({},"",Ne)},[t]);const te=async(oe,J)=>{R(oe),L("");try{await J(),await Q()}catch(ze){L(ze?.message||F("skills.error.generic"))}finally{R("")}},re=(oe,J)=>{const ze=(J&&J.length?J:AD).filter(Ne=>(n.targets||[]).some(De=>De.id===Ne));te(RD(oe),async()=>{await Tve(oe,ze);const Ne=ze.map(De=>(n.targets||[]).find(Le=>Le.id===De)?.label||De).join(", ");W({key:`${Date.now()}:install:${C0(oe)}`,message:F("skills.toast.installed",{name:oe.name||oe.directory,targets:Ne||F("skills.target.none")}),ttlMs:4e3})})},ue=oe=>{U(oe)},ce=()=>{const oe=V;oe&&(U(null),te(zS(oe),async()=>{let J=null;oe.managed?J=await Cve(oe.id):await Nve(oe.directory,oe.targets||[]);const ze=!!(J?.trashed&&oe.managed&&oe.id);W({key:`${Date.now()}:${oe.id||oe.directory}`,message:F("skills.toast.removed",{name:oe.name||oe.directory}),undo:ze?async()=>{try{await Ave(oe.id),await Q(),W(null)}catch(Ne){L(Ne?.message||F("skills.error.generic"))}}:null,ttlMs:5e3})}))},ee=(oe,J,ze)=>te(oj(oe.id,J),async()=>{const Ne=new Set(oe.targets||[]);ze?Ne.add(J):Ne.delete(J),oe.managed?await Rve(oe.id,Array.from(Ne)):await Pve(oe.directory,Array.from(Ne))}),le=async()=>{const oe=p.trim();if(!(oe.length<2)){R("search"),L("");try{const J=await Eve(oe);o(J.skills||[])}catch(J){L(J?.message||F("skills.error.generic"))}finally{R("")}}},ve=async()=>{const oe=b.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[J,ze]=oe.split("/");if(!J||!ze){L(F("skills.repo.invalid"));return}await te("repo:add",async()=>{await Dve({owner:J,name:ze,branch:"main",enabled:!0}),_(""),await O(),await G()})},Pe=async oe=>{await te(`repo:${oe.owner}/${oe.name}`,async()=>{await Lve(oe.owner,oe.name),await O(),await G()})},be=n.targets||[],Ye=n.skills||[],he=x.useMemo(()=>{const oe=f===ta?s:i,J=f===ta||f===dd?oe:oe.filter(De=>`${De.repoOwner}/${De.repoName}`===f),ze=v.trim().toLowerCase();return(f===ta||!ze?J:J.filter(De=>(De.name||"").toLowerCase().includes(ze)||(De.directory||"").toLowerCase().includes(ze)||(De.description||"").toLowerCase().includes(ze))).map(De=>{const Le=C0(De).toLowerCase(),$=String(De.directory||"").split(/[\\/]/).pop().toLowerCase(),I=$?`dir:${$}`:"";return{...De,installed:K.has(Le)||I&&K.has(I)}})},[v,i,K,s,f]),Ue=m.jsx("div",{className:"flex h-64 items-center justify-center",children:m.jsx(Ml,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),je=m.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[m.jsx(Ml,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0}),m.jsx("p",{className:"max-w-md text-xs text-oai-gray-500 dark:text-oai-gray-400",children:F("skills.browse.loading_hint")})]}),et=(oe,J=null)=>m.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[m.jsx("p",{children:F(oe)}),J]});let _e;if(A)_e=Ue;else if(t==="my")_e=Ye.length?m.jsx(Uve,{items:Ye,targets:be,busyKey:T,onToggleTarget:ee,onRemove:ue}):m.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-800",children:[be.length>0?m.jsxs("div",{className:"relative h-11 w-80 overflow-hidden","aria-hidden":!0,children:[m.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)",WebkitMaskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)"},children:m.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",style:{filter:"blur(2.5px)"},children:[...be,...be].map((oe,J)=>m.jsx("span",{className:"shrink-0 px-3",children:m.jsx(Qc,{provider:oe.id,size:30})},`b-${J}`))})}),m.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)",WebkitMaskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)"},children:m.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",children:[...be,...be].map((oe,J)=>m.jsx("span",{className:"shrink-0 px-3",children:m.jsx(Qc,{provider:oe.id,size:30})},`c-${J}`))})}),m.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 w-20 bg-gradient-to-r from-oai-white to-transparent dark:from-oai-gray-900"}),m.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 w-20 bg-gradient-to-l from-oai-white to-transparent dark:from-oai-gray-900"})]}):null,m.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:F("skills.empty.my")}),m.jsx(Ui,{type:"button",size:"sm",onClick:()=>e("browse"),children:F("skills.empty.my_cta")})]});else{const oe=f===ta,J=c.length===0&&!oe;let ze;J?ze=m.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 p-6 text-center dark:border-oai-gray-800",children:m.jsx("p",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:F("skills.browse.empty_sources")})}):k&&!oe?ze=je:oe&&p.trim().length<2?ze=m.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 px-4 py-6 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:F("skills.browse.hint_skillssh")}):he.length?ze=m.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:he.map(De=>m.jsx("div",{style:jve,children:m.jsx(Bve,{skill:De,installed:!!De.installed,installing:T===RD(De),allTargets:be,defaultTargets:AD,onInstall:re})},De.id||De.key))}):oe?ze=et("skills.empty.search"):ze=et("skills.empty.browse");const Ne=J||E?m.jsx("div",{className:"mb-5",children:m.jsx(zve,{repos:c,repoInput:b,onRepoInput:_,busyKey:T,onAdd:ve,onRemove:Pe})}):null;_e=m.jsxs(m.Fragment,{children:[Ne,ze]})}return m.jsxs("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:[m.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:m.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[m.jsxs("div",{className:"mb-6 flex items-end justify-between gap-4",children:[m.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:F("skills.page.title")}),m.jsxs(Ui,{type:"button",variant:"secondary",size:"sm",onClick:H,disabled:A||k,children:[m.jsx(Tk,{className:vt("mr-1.5 h-3.5 w-3.5",(A||k)&&"animate-spin"),"aria-hidden":!0}),F("skills.action.refresh")]})]}),m.jsx("div",{className:"mb-5 flex gap-6 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[["my",F("skills.tab.my")],["browse",F("skills.tab.browse")]].map(([oe,J])=>m.jsx("button",{type:"button","aria-pressed":t===oe,onClick:()=>e(oe),className:vt("-mb-px border-b-2 pb-2 text-sm font-medium transition-colors",t===oe?"border-oai-black text-oai-black dark:border-white dark:text-white":"border-transparent text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:J},oe))}),j?m.jsx("div",{className:"mb-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-200",children:j}):null,t==="browse"?m.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[m.jsx("div",{role:"tablist","aria-label":F("skills.source.label"),className:"inline-flex h-10 shrink-0 items-center rounded-md border border-oai-gray-200 bg-oai-white p-1 dark:border-oai-gray-800 dark:bg-oai-gray-900",children:[["repo",F("skills.mode.repo")],["skillssh",F("skills.mode.skillssh")]].map(([oe,J])=>{const ze=oe==="skillssh"==(f===ta);return m.jsx("button",{type:"button",role:"tab","aria-selected":ze,onClick:()=>{oe==="skillssh"?h(ta):f===ta&&h(dd)},className:vt("rounded px-3 py-1 text-sm font-medium transition-colors",ze?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-700 dark:text-white":"text-oai-gray-500 hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200"),children:J},oe)})}),f!==ta?m.jsxs(Xte,{value:f,onValueChange:h,children:[m.jsxs(ine,{"aria-label":F("skills.source.label"),className:"inline-flex h-10 w-44 shrink-0 items-center justify-between gap-2 rounded-md border border-oai-gray-200 bg-oai-white px-3 text-sm text-oai-black focus:outline-none data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:data-[popup-open]:border-oai-gray-700",children:[m.jsx(sne,{children:oe=>oe===dd?F("skills.source.all"):oe}),m.jsx(one,{className:"text-oai-gray-400",children:m.jsx(By,{className:"h-4 w-4","aria-hidden":!0})})]}),m.jsx(cne,{children:m.jsx(Rne,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:m.jsxs(Bne,{className:"min-w-[var(--anchor-width)] overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none transition-[opacity,transform] duration-150 ease-out data-[ending-style]:scale-[0.97] data-[ending-style]:opacity-0 data-[starting-style]:scale-[0.97] data-[starting-style]:opacity-0 dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[m.jsxs(rP,{value:dd,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[m.jsx(aP,{children:F("skills.source.all")}),m.jsx(iP,{children:m.jsx(Ph,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),c.map(oe=>{const J=`${oe.owner}/${oe.name}`;return m.jsxs(rP,{value:J,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[m.jsx(aP,{children:J}),m.jsx(iP,{children:m.jsx(Ph,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},J)})]})})})]}):null,m.jsxs("div",{className:"relative flex-1",children:[m.jsx(F2,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),m.jsx(jF,{value:p,onChange:oe=>y(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&f===ta&&le()},placeholder:f===ta?F("skills.browse.placeholder_skillssh"):f===dd?F("skills.browse.placeholder_all"):F("skills.browse.placeholder_repo",{repo:f}),className:"pl-9 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20"})]}),f===ta?m.jsxs(Ui,{type:"button",onClick:le,disabled:p.trim().length<2||T==="search",className:"focus:!ring-oai-gray-400/30",children:[T==="search"?m.jsx(Ml,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):m.jsx(F2,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),F("skills.action.search")]}):m.jsxs(Ui,{type:"button",variant:"secondary",size:"sm",onClick:()=>M(oe=>!oe),"aria-expanded":E,className:"!h-10 shrink-0 whitespace-nowrap !border-oai-gray-200 dark:!border-oai-gray-800 hover:!border-oai-gray-300 dark:hover:!border-oai-gray-700 hover:!text-oai-black dark:hover:!text-white focus:!ring-oai-gray-400/30",children:[m.jsx(D3,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),F("skills.browse.manage_sources"),m.jsx("span",{className:"ml-1.5 rounded bg-oai-gray-100 px-1.5 py-0.5 text-xs font-medium text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:c.length})]})]}):null,_e]})}),m.jsx(bre,{open:!!V,title:F("skills.confirm.remove_title",{name:V?.name||V?.directory||""}),description:V?V.managed?F("skills.confirm.remove_managed"):F("skills.confirm.remove_local"):"",confirmLabel:F("skills.action.remove"),cancelLabel:F("shared.action.cancel"),destructive:!0,busy:T===zS(V||{}),onCancel:()=>U(null),onConfirm:ce}),z?m.jsx("div",{className:"pointer-events-none fixed inset-x-0 bottom-6 z-[90] flex justify-center px-4",children:m.jsxs("div",{className:"pointer-events-auto flex max-w-md items-center gap-3 rounded-full bg-oai-black px-4 py-2 text-sm text-white shadow-lg dark:bg-white dark:text-oai-black",children:[m.jsx("span",{children:z.message}),z.undo?m.jsx("button",{type:"button",onClick:z.undo,className:"rounded-full px-2 py-0.5 text-xs font-semibold uppercase tracking-wide hover:bg-white/10 dark:hover:bg-oai-black/10",children:F("shared.action.undo")}):null]})}):null]})}const Wve=["todayTokens","todayCost"],lj=[{id:"todayTokens",label:"Today Tokens",shortLabel:"Tokens",category:"tokens"},{id:"todayCost",label:"Today Cost",shortLabel:"Cost",category:"cost"},{id:"last7dTokens",label:"Last 7 Days",shortLabel:"7d",category:"tokens"},{id:"totalTokens",label:"Total Tokens",shortLabel:"Total",category:"tokens"},{id:"totalCost",label:"Total Cost",shortLabel:"All $",category:"cost"},{id:"claude5h",label:"Claude 5h Limit",shortLabel:"Cl 5h",category:"limits"},{id:"claude7d",label:"Claude 7d Limit",shortLabel:"Cl 7d",category:"limits"},{id:"codex5h",label:"Codex 5h Limit",shortLabel:"Cx 5h",category:"limits"},{id:"codex7d",label:"Codex 7d Limit",shortLabel:"Cx 7d",category:"limits"}];function PD(t,e=lj,n=2){const r=new Set(e.map(o=>o.id)),i=new Set,a=Array.isArray(t)?t.filter(o=>!r.has(o)||i.has(o)?!1:(i.add(o),!0)):[];return(a.length>0?a:Wve).slice(0,Math.max(1,Number(n)||2))}const Gve=264,$ve=124,Eo="ui-rounded, -apple-system, system-ui",ND=["#5A8CF2","#9973E6","#4DB8A6","#E68C59"],Yve={claude:"#C77DFF",codex:"#34C759",cursor:"#FFCC00",gemini:"#0A84FF"};function qve(t){return t>=.9?"#E64D4D":t>=.7?"#D9A633":"#33B866"}function bv({size:t="sm",children:e}){const n=t==="lg",r=n?560:264,i=n?32:22;return m.jsx("div",{className:vt("flex w-full items-center justify-center rounded-xl bg-oai-gray-100 dark:bg-oai-gray-950/60",n?"py-10 sm:py-14 px-6":"py-6 px-4"),children:m.jsx("div",{className:"overflow-hidden bg-white dark:bg-oai-gray-800 shadow-oai-md dark:shadow-[0_2px_4px_rgba(0,0,0,0.4),0_8px_24px_rgba(0,0,0,0.5)]",style:{width:"100%",maxWidth:r,aspectRatio:`${Gve} / ${$ve}`,borderRadius:i},children:e})})}function Xve({size:t="sm"}){const e="M0,104 L14,104 C26,98 34,100 44,96 S58,88 68,92 80,100 90,94 102,80 112,82 126,92 136,88 150,74 162,76 178,88 188,86 204,72 216,74 236,84 250,80 L264,80",n=`${e} L264,124 L0,124 Z`,r=`sparkArea-${t}`;return m.jsx(bv,{size:t,children:m.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[m.jsx("defs",{children:m.jsxs("linearGradient",{id:r,x1:"0",y1:"0",x2:"0",y2:"1",children:[m.jsx("stop",{offset:"0%",stopColor:"#0A84FF",stopOpacity:"0.18"}),m.jsx("stop",{offset:"100%",stopColor:"#0A84FF",stopOpacity:"0"})]})}),m.jsx("text",{x:"14",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"TODAY"}),m.jsx("text",{x:"14",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:Eo,children:"203.2M"}),m.jsx("text",{x:"14",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:Eo,children:"$129.56 ±0%"}),m.jsx("text",{x:"134",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"7 DAYS"}),m.jsx("text",{x:"134",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:Eo,children:"880.9M"}),m.jsx("text",{x:"134",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:Eo,children:"$673.61"}),m.jsx("path",{d:n,fill:`url(#${r})`,stroke:"none"}),m.jsx("path",{d:e,fill:"none",stroke:"#0A84FF",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const DD=(()=>{const n=[];for(let r=0;r<26;r++)for(let i=0;i<7;i++){const a=Math.sin((r+1)*12.9898+(i+1)*78.233+17)*43758.5453,s=Math.floor(Math.abs(a-Math.floor(a))*100);n.push({w:r,d:i,v:s})}return n})();function LD(t,e){return t<18?e?"#262626":"#e5e5e5":t<38?"rgba(10, 132, 255, 0.28)":t<58?"rgba(10, 132, 255, 0.50)":t<80?"rgba(10, 132, 255, 0.75)":"#0A84FF"}function Kve(){return m.jsx(bv,{children:m.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[m.jsx("g",{transform:`translate(${19.5}, 10)`,className:"hidden dark:inline",children:DD.map(a=>m.jsx("rect",{x:a.w*(7.5+1.2),y:a.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:LD(a.v,!0)},`d-${a.w}-${a.d}`))}),m.jsx("g",{transform:`translate(${19.5}, 10)`,className:"dark:hidden",children:DD.map(a=>m.jsx("rect",{x:a.w*(7.5+1.2),y:a.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:LD(a.v,!1)},`l-${a.w}-${a.d}`))}),m.jsx("text",{x:19.5,y:"102",className:"fill-oai-black dark:fill-white",fontSize:"10",fontWeight:"700",fontFamily:Eo,children:"10.3B"}),m.jsx("text",{x:19.5+30,y:"102",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"500",children:"tokens · 202 active days"})]})})}function Zve(){const t=[{name:"claude-opus-4-6",value:"586.4M",pct:59},{name:"claude-sonnet-4-5-20250929",value:"218.7M",pct:22},{name:"gpt-5.4",value:"80.6M",pct:8},{name:"composer-2-fast",value:"52.1M",pct:5}],e=22,n=28,r=14,i=236;return m.jsx(bv,{children:m.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((a,s)=>{const o=n+s*e,c=ND[s%ND.length];return m.jsxs("g",{children:[m.jsx("circle",{cx:"18",cy:o-3,r:"2.5",fill:c}),m.jsx("text",{x:"26",y:o,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:a.name}),m.jsx("text",{x:"218",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"600",fontFamily:Eo,children:a.value}),m.jsxs("text",{x:"250",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"600",fontFamily:Eo,children:[a.pct,"%"]}),m.jsx("rect",{x:r,y:o+4,width:i,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),m.jsx("rect",{x:r,y:o+4,width:Math.max(i*(a.pct/100),4),height:"2.8",rx:"1.4",fill:c})]},a.name)})})})}function Jve(){const t=[{label:"Claude · 7d",source:"claude",reset:"in 1d",pct:61},{label:"Claude · 5h",source:"claude",reset:"in 4h 28m",pct:4},{label:"Cursor",source:"cursor",reset:"in 25d",pct:51},{label:"Codex · weekly",source:"codex",reset:"in 1d",pct:32}],e=22,n=28,r=14,i=236;return m.jsx(bv,{children:m.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((a,s)=>{const o=n+s*e,c=Yve[a.source],u=qve(a.pct/100);return m.jsxs("g",{children:[m.jsx("circle",{cx:"18",cy:o-3,r:"2.5",fill:c}),m.jsx("text",{x:"26",y:o,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:a.label}),m.jsx("text",{x:"218",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:Eo,children:a.reset}),m.jsxs("text",{x:"250",y:o,textAnchor:"end",className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"700",fontFamily:Eo,children:[a.pct,"%"]}),m.jsx("rect",{x:r,y:o+4,width:i,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),m.jsx("rect",{x:r,y:o+4,width:Math.max(i*(a.pct/100),4),height:"2.8",rx:"1.4",fill:u})]},a.label)})})})}function Qve(t){switch(t.category){case"cost":return"$8.42";case"limits":return"62%";default:return t.id==="last7dTokens"?"1.8B":"203M"}}function exe(t,e){switch(t){case"todayTokens":return F("menubar.metric.today_tokens");case"todayCost":return F("menubar.metric.today_cost");case"last7dTokens":return F("menubar.metric.last_7d_tokens");case"totalTokens":return F("menubar.metric.total_tokens");case"totalCost":return F("menubar.metric.total_cost");case"claude5h":return F("menubar.metric.claude_5h");case"claude7d":return F("menubar.metric.claude_7d");case"codex5h":return F("menubar.metric.codex_5h");case"codex7d":return F("menubar.metric.codex_7d");default:return e}}function txe(t,e){const n=new Set(e.map(i=>i.id)),r=t.filter(i=>n.has(i));for(const i of e){if(r.length>=2)break;r.includes(i.id)||r.push(i.id)}return r.slice(0,2)}function nxe({slotConfigs:t,showStats:e}){return m.jsx("div",{className:"flex justify-center rounded-xl bg-gradient-to-b from-oai-gray-100 to-oai-gray-200 px-6 py-8 dark:from-oai-gray-950/80 dark:to-oai-gray-900/80",children:m.jsxs("div",{className:"inline-flex items-stretch rounded-md shadow-[0_1px_3px_rgba(0,0,0,0.18)] ring-1 ring-black/10 dark:ring-white/10 px-3",style:{background:"linear-gradient(180deg, #2c2c2e 0%, #1c1c1e 100%)"},children:[m.jsx("div",{className:"flex items-center pl-2 pr-1 py-2.5",children:m.jsx("img",{src:"/clawd/mini/idle-tight.svg",alt:"","aria-hidden":"true",className:"block shrink-0",style:{height:22,width:"auto"},draggable:"false"})}),e?t.map(({slot:n,item:r},i)=>m.jsxs(ot.Fragment,{children:[i>0?m.jsx("span",{className:"my-1 w-px bg-white/20","aria-hidden":"true"}):null,m.jsxs("div",{className:vt("flex min-w-[52px] flex-col items-center justify-center py-1.5",i===0?"pl-1 pr-2":"px-2"),children:[m.jsx("span",{className:"text-[13px] font-semibold leading-none tabular-nums text-white",children:r?.previewValue||"--"}),m.jsx("span",{className:"mt-[2px] text-[6px] font-semibold uppercase leading-none text-white/75",children:r?.shortLabel||"Metric"})]})]},n)):null]})})}function rxe({slot:t,value:e,options:n,disabled:r,onChange:i}){const a=F(t===0?"menubar.slot.primary":"menubar.slot.secondary");return m.jsxs("label",{className:"flex min-w-0 flex-col gap-1.5",children:[m.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400",children:a}),m.jsxs("div",{className:"relative",children:[m.jsx("select",{value:e,disabled:r,"aria-label":a,onChange:s=>i(t,s.target.value),className:vt("w-full appearance-none rounded-lg border border-oai-gray-200 bg-white px-3 py-2 pr-9 text-sm font-medium text-oai-black transition-colors hover:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:hover:border-oai-gray-700",r&&"cursor-not-allowed opacity-50 hover:border-oai-gray-200 dark:hover:border-oai-gray-800"),children:n.map(s=>m.jsx("option",{value:s.id,children:s.displayLabel},s.id))}),m.jsx(By,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":"true"})]})]})}function ID({label:t,hint:e,checked:n,disabled:r,onChange:i}){return m.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:t}),e?m.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e}):null]}),m.jsx(yf,{checked:n,disabled:r,onChange:i,ariaLabel:t})]})}function ixe(){const{available:t,settings:e,setSetting:n}=fM(),r=x.useMemo(()=>(Array.isArray(e?.menuBarAvailableItems)?e.menuBarAvailableItems:lj).map(y=>({...y,displayLabel:exe(y.id,y.label),previewValue:Qve(y)})),[e?.menuBarAvailableItems]),i=Number(e?.menuBarMaxItems)||2,a=x.useMemo(()=>PD(e?.menuBarItems,r,i),[r,i,e?.menuBarItems]),s=x.useMemo(()=>txe(a,r),[r,a]),o=e?.showStats!==!1,c=p=>{n("menuBarItems",PD(p,r,i))},u=(p,y)=>{const v=[...s];v[p===0?1:0]!==y&&(v[p]=y,c(v))},f=[0,1].map(p=>{const y=s[p]||r[p]?.id||"",w=s[p===0?1:0],b=r.filter(E=>E.id===y||E.id!==w),_=r.find(E=>E.id===y);return{slot:p,currentValue:y,options:b,item:_}}),h=e?.animatedIcon!==!1;return m.jsxs("article",{className:"rounded-xl border border-oai-gray-200 bg-white p-5 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-6",children:[m.jsx(nxe,{slotConfigs:f,showStats:o}),m.jsx("div",{className:"mt-5 grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4",children:f.map(({slot:p,currentValue:y,options:v})=>m.jsx(rxe,{slot:p,value:y,options:v,disabled:!t||!o,onChange:u},p))}),m.jsxs("div",{className:"mt-5 divide-y divide-oai-gray-100 border-t border-oai-gray-100 dark:divide-oai-gray-800 dark:border-oai-gray-800",children:[m.jsx(ID,{label:F("settings.menubar.showStats"),hint:F(t?"settings.menubar.showStatsHint":"menubar.native_only"),checked:o,disabled:!t,onChange:()=>n("showStats",!o)}),m.jsx(ID,{label:F("settings.menubar.animatedIcon"),hint:F("settings.menubar.animatedIconHint"),checked:h,disabled:!t,onChange:()=>n("animatedIcon",!h)})]})]})}function axe(){const[t,e]=x.useState("loading");return x.useEffect(()=>{if(typeof window>"u")return;if(Za()){e("native");return}const n=(navigator.userAgent||"").toLowerCase(),r=/mac/.test(n)&&!/iphone|ipad/.test(n);e(r?"mac-web":"other")},[]),t}function sxe(){const t=axe();return t==="loading"?m.jsx("div",{className:"h-10 w-40","aria-hidden":"true"}):t==="native"?m.jsxs("button",{type:"button",onClick:()=>T3("openWidgetGallery"),className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[F("widgets.cta.open_gallery"),m.jsx(b7,{className:"h-4 w-4","aria-hidden":"true"})]}):t==="mac-web"?m.jsxs("a",{href:"https://github.com/mm7894215/TokenTracker/releases/latest",target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white no-underline transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[m.jsx(Ek,{className:"h-4 w-4","aria-hidden":"true"}),F("widgets.cta.download")]}):m.jsxs("span",{className:"inline-flex h-10 items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 text-sm font-medium text-oai-gray-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-400",children:[m.jsx(zy,{className:"h-4 w-4","aria-hidden":"true"}),F("widgets.cta.macos_only")]})}const oxe=[{id:"summary",Preview:Xve,nameKey:"widgets.summary.name",descKey:"widgets.summary.description"},{id:"heatmap",Preview:Kve,nameKey:"widgets.heatmap.name",descKey:"widgets.heatmap.description"},{id:"topModels",Preview:Zve,nameKey:"widgets.topModels.name",descKey:"widgets.topModels.description"},{id:"limits",Preview:Jve,nameKey:"widgets.limits.name",descKey:"widgets.limits.description"}];function lxe({Preview:t,nameKey:e,descKey:n}){return m.jsxs("article",{className:"flex h-full flex-col rounded-xl border border-oai-gray-200 bg-white p-4 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-5",children:[m.jsx(t,{}),m.jsxs("div",{className:"mt-4",children:[m.jsx("h3",{className:"text-[15px] font-semibold text-oai-black dark:text-white",children:F(e)}),m.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:F(n)})]})]})}function OD({titleKey:t}){return m.jsx("h2",{className:"mb-4 text-xl font-semibold tracking-tight text-oai-black dark:text-white sm:mb-5 sm:text-2xl",children:F(t)})}function cxe(){return m.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:m.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:m.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[m.jsx(xo,{y:12,children:m.jsxs("header",{className:"mb-10 flex items-start justify-between gap-4 sm:mb-12",children:[m.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:F("widgets.page.title")}),m.jsx("div",{className:"shrink-0",children:m.jsx(sxe,{})})]})}),m.jsx(xo,{y:12,delay:.06,children:m.jsxs("section",{"aria-label":F("widgets.menubar.section.title"),className:"mb-12 sm:mb-14",children:[m.jsx(OD,{titleKey:"widgets.menubar.section.title"}),m.jsx(ixe,{})]})}),m.jsxs("section",{"aria-label":F("widgets.gallery.section.title"),children:[m.jsx(OD,{titleKey:"widgets.gallery.section.title"}),m.jsx(ooe,{staggerDelay:.08,initialDelay:.04,children:m.jsx("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2 lg:gap-5",children:oxe.map(({id:t,Preview:e,nameKey:n,descKey:r})=>m.jsx(loe,{children:m.jsx(lxe,{Preview:e,nameKey:n,descKey:r})},t))})})]})]})})})}function uxe(){const{resolvedLocale:t}=su(),e=Hi(),n=ss();CZ();const r=wr(),i=x.useMemo(()=>typeof window>"u"?!1:sE(window.location.search),[]),a=e?.pathname||"/",s=new URL(window.location.href),o=s.pathname.replace(/\/+$/,"")||"/",u=o.match(/^\/share\/([^/?#]+)$/i)?.[1]||null,f=s.searchParams.get("token")||null,h=u||f,p=o==="/share"||o==="/share.html"||o.startsWith("/share/"),y=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),v=a.replace(/\/+$/,"")||"/",w=v.match(/^\/leaderboard\/u\/([^/]+)$/i),b=w?w[1]:null,_=v==="/leaderboard"||!!b,E=!!(n.enabled&&n.signedIn),M=y||E,T=!1,R=bZ(),A=x.useMemo(()=>!n.enabled||!E?null:{getAccessToken:()=>n.getAccessToken(),name:n.displayName||"",userId:n.user?.id||null},[E,n]);let P=y||r||i?"dashboard":"landing";v==="/landing"&&(P="landing"),v==="/dashboard"&&(P="dashboard"),_&&(P="dashboard");const k=v==="/limits",N=v==="/settings",j=v==="/skills",L=v==="/widgets",V=v==="/ip-check";(k||N||j||L||V)&&(P="dashboard");let U=cle;b?U=Mye:v==="/leaderboard"?U=vye:k?U=Uye:N?U=wve:j?U=Hve:L?U=cxe:V&&(U=ule);const W=!p&&(v==="/dashboard"||v==="/"||v==="/leaderboard"||k||N||j||L||V);let K=null;if(v==="/auth/callback"||v==="/auth/native-callback")K=m.jsx(Vye,{});else if(v==="/login")K=m.jsx(Bye,{});else if(P==="landing")K=m.jsx(dge,{signInUrl:"/login",signUpUrl:"/login"});else{const Q=m.jsx(U,{baseUrl:R,auth:A,signedIn:M,sessionSoftExpired:T,signOut:()=>n.enabled?n.signOut():Promise.resolve(),publicMode:p,publicToken:h,userId:b,signInUrl:"/login",signUpUrl:"/login"},t);W?K=m.jsx(ore,{children:Q}):K=Q}return m.jsx(dG,{children:m.jsx(pG,{children:m.jsxs(mG,{children:[K,m.jsx(vZ,{}),m.jsx(t7,{}),m.jsx(f7,{})]})})})}const dxe=R8([{path:"*",element:m.jsx(uxe,{})}]);vB.createRoot(document.getElementById("root")).render(m.jsx(ot.StrictMode,{children:m.jsx(HW,{children:m.jsx(mW,{children:m.jsx(H8,{router:dxe})})})}));
5168
+ `),a=async()=>{try{await navigator.clipboard.writeText(i),n(!0),setTimeout(()=>n(!1),1600)}catch{}};return m.jsxs("div",{className:"mt-1 rounded-md border border-amber-300/60 dark:border-amber-700/40 bg-amber-50/50 dark:bg-amber-900/10 px-2.5 py-2 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[m.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:F("limits.copilot.otelHint.title")}),m.jsx("div",{className:"mt-0.5 leading-snug",children:F("limits.copilot.otelHint.body")}),m.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-tight whitespace-pre",children:i}),m.jsx("button",{type:"button",onClick:a,className:"mt-1 inline-flex items-center gap-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 px-1.5 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:F(e?"limits.copilot.otelHint.copied":"limits.copilot.otelHint.copy")})]})}function Fye({claude:t,codex:e,cursor:n,gemini:r,kimi:i,kiro:a,antigravity:s,copilot:o,order:c,visibility:u}){const f={claude:t,codex:e,cursor:n,gemini:r,kimi:i,kiro:a,antigravity:s,copilot:o},p=(Array.isArray(c)&&c.length>0?c:Dye).filter(y=>!u||u[y]!==!1).map(y=>Iye(y,f[y])).filter(Boolean);return m.jsx(xo,{delay:.15,children:m.jsx(fu,{children:m.jsxs("div",{className:"flex flex-col gap-3",children:[m.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:F("limits.panel.title")}),p.length>0?p:m.jsx(xa,{children:F("limits.status.all_hidden")})]})})})}function Uye(){const{data:t,error:e,isLoading:n}=qO({initialRefresh:!0}),r=nj();return m.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:m.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:m.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[m.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:F("nav.limits")}),m.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:F("limits.page.subtitle")})]}),m.jsx(Ei,{to:"/settings","aria-label":F("limits.page.openSettings"),title:F("limits.page.openSettings"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 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",children:m.jsx(L3,{className:"h-4 w-4","aria-hidden":!0})})]}),n?m.jsx(Pye,{}):m.jsxs(m.Fragment,{children:[e?m.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:F("shared.error.prefix",{error:e})}):null,m.jsx(Fye,{claude:t?.claude,codex:t?.codex,cursor:t?.cursor,gemini:t?.gemini,kimi:t?.kimi,kiro:t?.kiro,antigravity:t?.antigravity,copilot:t?.copilot,order:r.order,visibility:r.visibility})]})]})})})}function jye(t){const e=new URLSearchParams(t).get("next");return typeof e!="string"||e.length===0||!e.startsWith("/")||e.startsWith("//")?"/dashboard":e}const ED={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",linkedin:"LinkedIn",facebook:"Facebook",instagram:"Instagram",tiktok:"TikTok",apple:"Apple",x:"X",spotify:"Spotify"};function MD(t){const e=String(t||"").trim();return ED[e]?ED[e]:e.replace(/-/g," ")}function Bye(){const t=Jd(),[e,n]=F8(),{enabled:r,loading:i,signedIn:a,refreshUser:s,signInWithPassword:o,signUp:c,signInWithOAuth:u,getPublicAuthConfig:f}=ss(),h=x.useMemo(()=>jye(e.toString()),[e]),[p,y]=x.useState("signin"),[v,w]=x.useState(""),[b,_]=x.useState(""),[E,M]=x.useState(""),[T,R]=x.useState(!1),[A,P]=x.useState(null),[k,N]=x.useState(null),[j,L]=x.useState(!0),[V,U]=x.useState([]),[z,W]=x.useState([]),[K,Q]=x.useState(8);x.useEffect(()=>{const ce=e.get("insforge_status"),ee=e.get("insforge_type"),le=e.get("insforge_error");ce==="success"&&ee==="verify_email"?N(F("login.verify_email_success")):ce==="error"&&ee==="verify_email"&&le&&N(F("shared.error.prefix",{error:le}))},[e]),x.useEffect(()=>{if(!r){L(!1);return}let ce=!0;return(async()=>{const{data:ee,error:le}=await f();ce&&(le||!ee?(U(["google","github"]),W([])):(U(Array.isArray(ee.oAuthProviders)?ee.oAuthProviders:[]),W(Array.isArray(ee.customOAuthProviders)?ee.customOAuthProviders:[]),typeof ee.passwordMinLength=="number"&&ee.passwordMinLength>0&&Q(ee.passwordMinLength)),L(!1))})(),()=>{ce=!1}},[r,f]);const O=x.useMemo(()=>e.get("native")==="1",[e]),G=x.useMemo(()=>e.get("provider")||null,[e]);x.useEffect(()=>{if(!(!r||i)&&a){if(O){window.location.href="/auth/native-callback";return}t(h,{replace:!0})}},[r,i,a,t,h,O]),x.useEffect(()=>{r&&s()},[r,s]);const Y=x.useMemo(()=>typeof window>"u"||O?"":`${window.location.origin}/`,[O]),H=x.useMemo(()=>typeof window>"u"?"":`${window.location.origin}/`,[]),te=x.useCallback(async ce=>{ce.preventDefault(),P(null),R(!0);try{if(p==="signup"){const{data:le,error:ve}=await c({email:v.trim(),password:b,name:E.trim()||void 0,redirectTo:H});if(ve){P(ve.message||String(ve));return}if(le?.requireEmailVerification){N(F("login.verify_email_pending")),y("signin");return}t(h,{replace:!0});return}const{error:ee}=await o({email:v.trim(),password:b});if(ee){P(ee.message||String(ee));return}t(h,{replace:!0})}finally{R(!1)}},[p,v,b,E,c,o,t,h,H]),re=x.useCallback(async ce=>{P(null),R(!0);try{const{error:ee}=await u(ce,Y);ee&&P(ee.message||String(ee))}finally{R(!1)}},[u,Y]);x.useEffect(()=>{if(O&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[O]),x.useEffect(()=>{if(!r||i||a||j||!O||!G)return;[...V,...z].includes(G)&&re(G)},[r,i,a,j,O,G,V,z,re]);const ue=x.useCallback(()=>{n(ce=>{const ee=new URLSearchParams(ce);return ee.delete("insforge_status"),ee.delete("insforge_type"),ee.delete("insforge_error"),ee},{replace:!0}),N(null)},[n]);return r?m.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[m.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:m.jsx(Ei,{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:F("login.back_home")})}),m.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:m.jsxs("div",{className:"w-full max-w-md space-y-8",children:[m.jsxs("div",{className:"text-center",children:[m.jsx("h1",{className:"text-2xl font-semibold text-white tracking-tight",children:F("login.title")}),m.jsx("p",{className:"mt-2 text-sm text-oai-gray-500",children:F("login.subtitle")})]}),k?m.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:[m.jsx("span",{children:k}),m.jsx("button",{type:"button",onClick:ue,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:F("login.dismiss")})]}):null,A?m.jsx("p",{className:"text-sm text-red-400",role:"alert",children:F("shared.error.prefix",{error:A})}):null,m.jsx("div",{className:"space-y-3",children:j?m.jsx("div",{className:"h-11 rounded-lg bg-oai-gray-900 animate-pulse","aria-hidden":!0}):m.jsxs(m.Fragment,{children:[V.map(ce=>m.jsx("button",{type:"button",disabled:T,onClick:()=>re(ce),className:vt("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:F("login.oauth.continue",{provider:MD(ce)})},ce)),z.map(ce=>m.jsx("button",{type:"button",disabled:T,onClick:()=>re(ce),className:vt("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:F("login.oauth.continue",{provider:MD(ce)})},ce))]})}),m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"absolute inset-0 flex items-center","aria-hidden":!0,children:m.jsx("span",{className:"w-full border-t border-oai-gray-800"})}),m.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:m.jsx("span",{className:"bg-oai-gray-950 px-3 text-oai-gray-600",children:F("login.divider")})})]}),m.jsxs("div",{className:"flex rounded-lg border border-oai-gray-800 p-0.5 bg-oai-gray-900/50",children:[m.jsx("button",{type:"button",className:vt("flex-1 py-2 text-sm font-medium rounded-md transition-colors",p==="signin"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{y("signin"),P(null)},children:F("login.tab.sign_in")}),m.jsx("button",{type:"button",className:vt("flex-1 py-2 text-sm font-medium rounded-md transition-colors",p==="signup"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{y("signup"),P(null)},children:F("login.tab.sign_up")})]}),m.jsxs("form",{onSubmit:te,className:"space-y-4",children:[p==="signup"?m.jsxs("div",{children:[m.jsx("label",{htmlFor:"login-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:F("login.field.name")}),m.jsx("input",{id:"login-name",type:"text",autoComplete:"name",value:E,onChange:ce=>M(ce.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:F("login.field.name_placeholder")})]}):null,m.jsxs("div",{children:[m.jsx("label",{htmlFor:"login-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:F("login.field.email")}),m.jsx("input",{id:"login-email",type:"email",autoComplete:"email",required:!0,value:v,onChange:ce=>w(ce.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.jsxs("div",{children:[m.jsx("label",{htmlFor:"login-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:F("login.field.password")}),m.jsx("input",{id:"login-password",type:"password",autoComplete:p==="signup"?"new-password":"current-password",required:!0,minLength:p==="signup"?K:void 0,value:b,onChange:ce=>_(ce.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"}),p==="signup"?m.jsx("p",{className:"mt-1 text-xs text-oai-gray-600",children:F("login.password_hint",{min:String(K)})}):null]}),m.jsx("button",{type:"submit",disabled:T||i,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:F(p==="signup"?"login.submit.sign_up":"login.submit.sign_in")})]})]})})]}):m.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[m.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:m.jsx(Ei,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:F("login.back_home")})}),m.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:m.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",children:F("login.cloud_only")})})]})}const zye=typeof window<"u"?window.location.search:"",TD=new URLSearchParams(zye),Jg=TD.get("insforge_code")||TD.get("code")||null;function Vye(){su();const{loading:t,signedIn:e}=ss(),n=Jd(),[r,i]=x.useState("processing"),[a,s]=x.useState(null),o=x.useRef(!1);return x.useEffect(()=>{!Jg||o.current||(o.current=!0,(async()=>{try{const u=await(await fetch("/api/auth-bridge/verifier")).json();s(!!u?.native)}catch{s(!1)}})())},[]),x.useEffect(()=>{if(a!==!0||!Jg)return;i("redirecting");const c=setTimeout(()=>{window.location.href=`tokentracker://auth/callback?insforge_code=${encodeURIComponent(Jg)}`},200);return()=>clearTimeout(c)},[a]),x.useEffect(()=>{if(a!==!1||t)return;if(e){n("/dashboard",{replace:!0});return}const c=setTimeout(()=>{e||i("failed")},5e3);return()=>clearTimeout(c)},[a,t,e,n]),x.useEffect(()=>{if(!Jg&&a===null){const c=setTimeout(()=>i("failed"),3e3);return()=>clearTimeout(c)}},[a]),r==="processing"&&a!==!0&&(a===null||a===!1&&t)?m.jsx("div",{className:"min-h-screen bg-oai-gray-950"}):m.jsx("div",{className:"min-h-screen bg-oai-gray-950 text-white font-oai antialiased dark flex items-center justify-center",children:m.jsxs("div",{className:"text-center space-y-4 max-w-sm px-4",children:[r==="processing"&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"w-8 h-8 border-2 border-oai-gray-600 border-t-white rounded-full animate-spin mx-auto"}),m.jsx("p",{className:"text-oai-gray-400 text-sm",children:F("auth.callback.processing")})]}),r==="redirecting"&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"w-12 h-12 mx-auto rounded-full bg-green-500/15 flex items-center justify-center",children:m.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:m.jsx("path",{d:"M20 6 9 17l-5-5"})})}),m.jsx("p",{className:"text-white text-sm font-medium",children:F("auth.callback.success")}),m.jsx("p",{className:"text-oai-gray-500 text-xs",children:F("auth.callback.redirecting")})]}),r==="failed"&&m.jsxs("div",{className:"space-y-3",children:[m.jsx("p",{className:"text-oai-gray-300 text-sm",children:F("auth.callback.failed")}),m.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:F("auth.callback.close")})]})]})})}const Hye=new Set(["cursor","kiro","copilot","kimi"]);function Wye({checked:t,onChange:e,ariaLabel:n}){return m.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":n,onClick:e,className:vt("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",t?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:m.jsx("span",{className:vt("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",t?"translate-x-[18px]":"translate-x-[3px]")})})}function Gye({prefs:t}){const{order:e,visibility:n,toggle:r,moveToward:i}=t,[a,s]=x.useState(null),[o,c]=x.useState(null),u=y=>v=>{s(y),v.dataTransfer.effectAllowed="move",v.dataTransfer.setData("text/plain",y)},f=y=>v=>{v.preventDefault(),v.dataTransfer.dropEffect="move",a&&a!==y&&o!==y&&(c(y),i(a,y))},h=()=>{s(null),c(null)},p=y=>{y.preventDefault(),s(null),c(null)};return m.jsx(fX,{children:m.jsx("div",{className:"flex flex-col",children:e.map(y=>{const v=n[y]!==!1,w=a===y;return m.jsxs(fr.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:u(y),onDragOver:f(y),onDragEnd:h,onDrop:p,className:vt("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",w&&"opacity-40"),style:{cursor:w?"grabbing":"grab"},children:[m.jsx(D7,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),m.jsx("img",{src:Tye[y],alt:"",width:18,height:18,className:vt("h-[18px] w-[18px] shrink-0 pointer-events-none",Hye.has(y)&&"dark:invert"),draggable:!1}),m.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:wD[y]}),m.jsx("div",{onMouseDown:b=>b.stopPropagation(),draggable:!1,children:m.jsx(Wye,{checked:v,onChange:()=>r(y),ariaLabel:`${F("limits.settings.toggle_visible")}: ${wD[y]}`})})]},y)})})})}function $ye(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:{},r=e.full_name||e.name||n.name||e.user_name||e.preferred_username;return typeof r=="string"&&r.trim()?r.trim():typeof t.email=="string"&&t.email.includes("@")?t.email.split("@")[0].trim()||t.email.trim():typeof t.email=="string"?t.email.trim():""}function Yye(t){return!t||typeof t!="object"?"":typeof t.email=="string"?t.email.trim():""}function qye(t){const e=typeof t=="string"?t.trim():"";if(!e)return null;const n=e.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),r=e.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),i=n?.[1]||r?.[1];return i?`https://github.com/${i}`:null}function dM(t,e){console.warn(`[tokentracker] settings ${t}:`,e)}function Xye(t,e,n){const[r,i]=x.useState(()=>yk()),a=e&&n&&l3(),s=x.useCallback(async()=>{const o=!r;if(c3(o),i(o),!!o)try{await GO(()=>t())}catch(c){dM("cloud sync",c)}},[r,t]);return{cloudSyncOn:r,handleCloudSyncToggle:s,showLocalCloudSync:a}}function Kye(t){const[e,n]=x.useState(!1),[r,i]=x.useState(!1),[a,s]=x.useState(!1),[o,c]=x.useState(!1),[u,f]=x.useState(null),[h,p]=x.useState(!1),[y,v]=x.useState(""),[w,b]=x.useState(!1),[_,E]=x.useState(""),[M,T]=x.useState(""),[R,A]=x.useState(!1),[P,k]=x.useState(null),N=x.useMemo(()=>$ye(t),[t]),j=x.useMemo(()=>Yye(t),[t]),L=x.useMemo(()=>({setAnonymousOn:i,setCustomDisplayName:f,setGithubUrl:E,setProfileLoading:s,setPublicProfileOn:n,setShowGithubOn:b}),[]);return{anonymousOn:r,customDisplayName:u,displayName:N,editingGithub:R,editingName:h,email:j,githubError:P,githubInput:M,githubUrl:_,loadSetters:L,nameInput:y,profileLoading:a,profileSaving:o,publicProfileOn:e,setAnonymousOn:i,setCustomDisplayName:f,setEditingGithub:A,setEditingName:p,setGithubError:k,setGithubInput:T,setGithubUrl:E,setNameInput:v,setProfileLoading:s,setProfileSaving:c,setPublicProfileOn:n,setShowGithubOn:b,showGithubOn:w}}function Zye(t,e,n){x.useEffect(()=>{if(!e)return;let r=!0;return n.setProfileLoading(!0),(async()=>{try{const i=await qh({getAccessToken:t});if(!r||!i)return;const a=await Ow({accessToken:i});if(!r)return;n.setPublicProfileOn(!!a?.enabled),n.setAnonymousOn(!!a?.anonymous),a?.display_name&&n.setCustomDisplayName(a.display_name),n.setShowGithubOn(!!a?.show_github_url),n.setGithubUrl(a?.github_url||"")}catch(i){dM("load public profile",i)}finally{r&&n.setProfileLoading(!1)}})(),()=>{r=!1}},[t,e,n])}function Jye(t,e){return x.useCallback(async(n,{label:r,onError:i,onSuccess:a}={})=>{if(e.profileSaving)return!1;e.setProfileSaving(!0);try{const s=await qh({getAccessToken:t});if(!s)return!1;const o=await aW({accessToken:s,...n});return a?.(o),!0}catch(s){return i?i(s):dM(r||"mutate profile",s),!1}finally{e.setProfileSaving(!1)}},[t,e])}function Qye(t,e){return{anonymousOn:t.anonymousOn,customDisplayName:t.customDisplayName,displayName:t.displayName,editingName:t.editingName,handleAnonymousToggle:e.handleAnonymousToggle,handleSaveName:e.handleSaveName,nameInput:t.nameInput,profileLoading:t.profileLoading,profileSaving:t.profileSaving,setEditingName:t.setEditingName,setNameInput:t.setNameInput,startEditingName:e.startEditingName}}function eve(t,e){return{editingGithub:t.editingGithub,githubError:t.githubError,githubInput:t.githubInput,githubUrl:t.githubUrl,handleSaveGithub:e.handleSaveGithub,handleShowGithubToggle:e.handleShowGithubToggle,profileLoading:t.profileLoading,profileSaving:t.profileSaving,setEditingGithub:t.setEditingGithub,setGithubError:t.setGithubError,setGithubInput:t.setGithubInput,showGithubOn:t.showGithubOn,startEditingGithub:e.startEditingGithub}}function tve(t,e){const n=x.useCallback(async()=>{const i=!t.publicProfileOn;await e({enabled:i},{label:"toggle public profile",onSuccess:()=>t.setPublicProfileOn(i)})},[e,t]);return{handleAnonymousToggle:x.useCallback(async()=>{const i=!t.anonymousOn;await e({anonymous:i},{label:"toggle anonymous",onSuccess:()=>t.setAnonymousOn(i)})},[e,t]),handlePublicProfileToggle:n}}function nve(t,e){const n=x.useCallback(async()=>{const i=t.nameInput.trim().slice(0,50);i&&await e({display_name:i},{label:"save display name",onSuccess:()=>{t.setCustomDisplayName(i),t.setEditingName(!1)}})},[e,t]),r=x.useCallback(()=>{t.setNameInput(t.customDisplayName||t.displayName),t.setEditingName(!0)},[t]);return{handleSaveName:n,startEditingName:r}}function rve(t,e){const n=x.useCallback(async()=>{if(!t.showGithubOn&&!t.githubUrl){t.setEditingGithub(!0),t.setGithubInput(""),t.setGithubError(null);return}const a=!t.showGithubOn;await e({show_github_url:a},{label:"toggle GitHub profile",onSuccess:()=>t.setShowGithubOn(a)})},[e,t]),r=x.useCallback(async()=>{const a=qye(t.githubInput);if(t.githubInput.trim()&&!a){t.setGithubError(F("settings.account.githubUrlInvalid"));return}t.setGithubError(null),await e({github_url:a,show_github_url:!!a},{label:"save GitHub profile",onError:s=>t.setGithubError(s?.message||F("settings.account.githubUrlInvalid")),onSuccess:s=>{t.setGithubUrl(s?.github_url||a||""),t.setShowGithubOn(!!a),t.setEditingGithub(!1)}})},[e,t]),i=x.useCallback(()=>{t.setGithubInput(t.githubUrl),t.setGithubError(null),t.setEditingGithub(!0)},[t]);return{handleSaveGithub:r,handleShowGithubToggle:n,startEditingGithub:i}}function ive(){const t=ss(),e=Kye(t.user),n=Xye(t.getAccessToken,t.enabled,t.signedIn);Zye(t.getAccessToken,t.signedIn,e.loadSetters);const r=Jye(t.getAccessToken,e),i=tve(e,r),a=nve(e,r),s=rve(e,r);return{...t,...n,email:e.email,handlePublicProfileToggle:i.handlePublicProfileToggle,name:Qye(e,{...i,...a}),github:eve(e,s),profileLoading:e.profileLoading,profileSaving:e.profileSaving,publicProfileOn:e.publicProfileOn}}function yf({checked:t,onChange:e,disabled:n,ariaLabel:r}){return m.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":r,onClick:e,disabled:n,className:vt("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 disabled:cursor-not-allowed",t?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:m.jsx("span",{className:vt("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",t?"translate-x-[18px]":"translate-x-[3px]")})})}function zc({label:t,hint:e,control:n}){return m.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:t}),e?m.jsx("div",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e}):null]}),m.jsx("div",{className:"shrink-0",children:n})]})}function Gp({title:t,subtitle:e,action:n,children:r}){return m.jsxs(fu,{children:[m.jsxs("div",{className:"mb-3 flex items-start justify-between gap-4",children:[m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("h2",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:t}),e?m.jsx("p",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e}):null]}),n?m.jsx("div",{className:"shrink-0",children:n}):null]}),m.jsx("div",{className:"-mb-3 divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:r})]})}function CD({options:t,value:e,onChange:n}){return m.jsx("div",{className:"inline-flex items-center rounded-lg border border-oai-gray-200 bg-oai-gray-50 p-0.5 dark:border-oai-gray-800 dark:bg-oai-gray-900",children:t.map(({value:r,label:i,Icon:a})=>{const s=e===r;return m.jsxs("button",{type:"button",onClick:()=>n(r),"aria-pressed":s,className:vt("inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",s?"bg-white text-oai-black shadow-sm dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:[a?m.jsx(a,{className:"h-3.5 w-3.5","aria-hidden":!0}):null,m.jsx("span",{children:i})]},r)})})}function rj({disabled:t,onCancel:e,onSave:n,saveLabel:r=F("settings.account.save")}){return m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",onClick:n,disabled:t,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:r}),m.jsx("button",{type:"button",onClick:e,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:F("settings.account.cancel")})]})}function ave({nameInput:t,setEditingName:e,setNameInput:n,profileSaving:r,handleSaveName:i}){return m.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[m.jsx("input",{type:"text",value:t,onChange:a=>n(a.target.value),onKeyDown:a=>{a.key==="Enter"&&i(),a.key==="Escape"&&e(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:F("settings.account.displayName")}),m.jsx(rj,{disabled:r||!t.trim(),onCancel:()=>e(!1),onSave:i,saveLabel:r?F("settings.account.saving"):void 0})]})}function sve({githubError:t,githubInput:e,handleSaveGithub:n,profileSaving:r,setEditingGithub:i,setGithubError:a,setGithubInput:s}){return m.jsxs("div",{className:"mt-2",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("input",{type:"text",value:e,onChange:o=>{s(o.target.value),t&&a(null)},onKeyDown:o=>{o.key==="Enter"&&n(),o.key==="Escape"&&(i(!1),a(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:F("settings.account.githubUrlPlaceholder")}),m.jsx(rj,{disabled:r,onCancel:()=>{i(!1),a(null)},onSave:n,saveLabel:r?F("settings.account.saving"):void 0})]}),t?m.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:t}):null]})}function ij({disabled:t=!1,label:e,onClick:n,title:r}){return m.jsxs("button",{type:"button",onClick:n,disabled:t,title:r,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[m.jsx(X7,{className:"h-3.5 w-3.5","aria-hidden":!0}),e]})}function aj({actions:t,editing:e,editor:n,hint:r,label:i}){return m.jsx("div",{className:"py-3",children:m.jsxs("div",{className:"flex items-start justify-between gap-4",children:[m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:i}),e?n:m.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r})]}),e?null:t]})})}function ove({name:t}){const e=t.anonymousOn?F("settings.account.displayNameDisabledWhileAnon"):void 0;return m.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[m.jsx(ij,{disabled:t.anonymousOn,label:F("settings.account.edit"),onClick:t.startEditingName,title:e}),m.jsx(yf,{checked:!t.anonymousOn,onChange:t.handleAnonymousToggle,disabled:t.profileLoading||t.profileSaving,ariaLabel:F("settings.account.displayName")})]})}function lve({name:t}){const{anonymousOn:e,customDisplayName:n,displayName:r,editingName:i,handleAnonymousToggle:a,handleSaveName:s,nameInput:o,profileLoading:c,profileSaving:u,setEditingName:f,setNameInput:h,startEditingName:p}=t,y=e?F("settings.account.displayNameAnonymousHint"):n||r;return m.jsx(aj,{label:F("settings.account.displayName"),editing:i,hint:y,editor:m.jsx(ave,{nameInput:o,setEditingName:f,setNameInput:h,profileSaving:u,handleSaveName:s}),actions:m.jsx(ove,{name:t})})}function cve({github:t}){const{editingGithub:e,githubError:n,githubInput:r,githubUrl:i,handleSaveGithub:a,handleShowGithubToggle:s,profileLoading:o,profileSaving:c,setEditingGithub:u,setGithubError:f,setGithubInput:h,showGithubOn:p,startEditingGithub:y}=t;return m.jsx(aj,{label:F("settings.account.githubUrl"),editing:e,hint:i||F("settings.account.githubUrlHint"),editor:m.jsx(sve,{githubError:n,githubInput:r,handleSaveGithub:a,profileSaving:c,setEditingGithub:u,setGithubError:f,setGithubInput:h}),actions:m.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[m.jsx(ij,{label:F("settings.account.edit"),onClick:y}),m.jsx(yf,{checked:p,onChange:s,disabled:o||c,ariaLabel:F("settings.account.githubUrl")})]})})}function uve(){const{openLoginModal:t}=Ep();return m.jsx(Gp,{title:F("settings.section.account"),children:m.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[m.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:F("settings.account.signedOutHint")}),m.jsx("button",{type:"button",onClick:t,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:F("settings.account.signIn")})]})})}function dve({name:t,github:e}){return m.jsxs(m.Fragment,{children:[m.jsx(lve,{name:t}),m.jsx(cve,{github:e})]})}function fve(){const t=ive();return t.enabled?t.signedIn?m.jsxs(Gp,{title:F("settings.section.account"),subtitle:t.email||t.name.customDisplayName||t.name.displayName,action:m.jsx(hve,{onSignOut:t.signOut}),children:[m.jsx(pve,{settings:t}),m.jsx(mve,{checked:t.publicProfileOn,disabled:t.profileLoading||t.profileSaving,onChange:t.handlePublicProfileToggle}),m.jsx(gve,{visible:t.publicProfileOn,name:t.name,github:t.github})]}):m.jsx(uve,{}):null}function hve({onSignOut:t}){return m.jsxs("button",{type:"button",onClick:()=>t(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[m.jsx(z7,{className:"h-3.5 w-3.5","aria-hidden":!0}),F("settings.account.signOut")]})}function pve({settings:t}){return t.showLocalCloudSync?m.jsx(zc,{label:F("settings.account.cloudSync"),hint:F("settings.account.cloudSyncHint"),control:m.jsx(yf,{checked:t.cloudSyncOn,onChange:t.handleCloudSyncToggle,ariaLabel:F("settings.account.cloudSync")})}):null}function mve({checked:t,disabled:e,onChange:n}){return m.jsx(zc,{label:F("settings.account.publicProfile"),hint:F("settings.account.publicProfileHint"),control:m.jsx(yf,{checked:t,onChange:n,disabled:e,ariaLabel:F("settings.account.publicProfile")})})}function gve({visible:t,name:e,github:n}){return m.jsx(Yy,{initial:!1,children:t?m.jsx(fr.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:m.jsx(dve,{name:e,github:n})},"public-profile-fields"):null})}function yve(){return[{value:"light",label:F("settings.appearance.theme.light"),Icon:Ck},{value:"dark",label:F("settings.appearance.theme.dark"),Icon:Mk},{value:"system",label:F("settings.appearance.theme.system"),Icon:zy}]}function vve(){return[{value:Xc,label:F("settings.appearance.language.system"),Icon:zy},{value:Kh,label:F("settings.appearance.language.english"),Icon:O2},{value:Uy,label:F("settings.appearance.language.chinese"),Icon:O2}]}function xve(){const{theme:t,setTheme:e}=Np(),{locale:n,setLocale:r}=su();return m.jsxs(Gp,{title:F("settings.section.appearance"),children:[m.jsx(zc,{label:F("settings.appearance.theme.label"),hint:F("settings.appearance.theme.hint"),control:m.jsx(CD,{options:yve(),value:t,onChange:e})}),m.jsx(zc,{label:F("settings.appearance.language.label"),hint:F("settings.appearance.language.hint"),control:m.jsx(CD,{options:vve(),value:n,onChange:r})})]})}function fM(){const[t,e]=x.useState(null),n=Sk()&&FW();x.useEffect(()=>{if(!n)return;const s=BW(o=>e(o));return D2(),s},[n]);const r=x.useCallback((s,o)=>{n&&(e(c=>c&&{...c,[s]:o}),Bw(s,o))},[n]),i=x.useCallback(s=>{n&&T3(s)},[n]),a=x.useCallback(()=>{n&&D2()},[n]);return{available:n,settings:t,setSetting:r,runAction:i,refresh:a}}function bve(){const{available:t,settings:e,setSetting:n,runAction:r}=fM();if(!t)return null;const i=!!e?.launchAtLogin,a=e?.launchAtLoginSupported!==!1,s=e?.updateStatus||null,o=!!e?.updateBusy,c=!!e?.isSyncing;return m.jsxs(Gp,{title:F("settings.section.menubar"),children:[a?m.jsx(zc,{label:F("settings.menubar.launchAtLogin"),hint:F("settings.menubar.launchAtLoginHint"),control:m.jsx(yf,{checked:i,onChange:()=>n("launchAtLogin",!i),ariaLabel:F("settings.menubar.launchAtLogin")})}):null,m.jsx(zc,{label:F("settings.menubar.syncNow"),hint:F("settings.menubar.syncNowHint"),control:m.jsxs("button",{type:"button",onClick:()=>r("syncNow"),disabled:c,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[m.jsx(Tk,{className:vt("h-3.5 w-3.5",c&&"animate-spin"),"aria-hidden":!0}),F(c?"settings.menubar.syncing":"settings.menubar.syncNow")]})}),m.jsx(zc,{label:F("settings.menubar.updates"),hint:s||void 0,control:m.jsxs("button",{type:"button",onClick:()=>r("checkForUpdates"),disabled:o,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[m.jsx(Ek,{className:"h-3.5 w-3.5","aria-hidden":!0}),F("settings.menubar.checkUpdates")]})})]})}function _ve(){const{available:t,settings:e,runAction:n}=fM();return!t||!e?.version?null:m.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-500",children:[m.jsxs("span",{children:["TokenTrackerBar v",e.version]}),m.jsx("span",{"aria-hidden":!0,children:"·"}),m.jsx("button",{type:"button",onClick:()=>n("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"})]})}function wve(){const t=nj();return m.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:m.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:m.jsxs("div",{className:"mx-auto max-w-3xl px-4 sm:px-6",children:[m.jsxs("div",{className:"mb-8",children:[m.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:F("settings.page.title")}),m.jsx("p",{className:"mt-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:F("settings.page.subtitle")})]}),m.jsxs("div",{className:"space-y-4",children:[m.jsx(xve,{}),m.jsx(bve,{}),m.jsx(fve,{}),m.jsx(Gp,{title:F("settings.section.limits"),children:m.jsx(Gye,{prefs:t})})]}),m.jsx(_ve,{})]})})})}const sj="tokentracker-skills";async function xv(t){const e=new URL(`/functions/${sj}`,window.location.origin);if(t)for(const[i,a]of Object.entries(t))a!=null&&a!==""&&e.searchParams.set(i,String(a));const n=await fetch(e.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),r=await n.json().catch(()=>null);if(!n.ok)throw new Error(r?.error||`Request failed with HTTP ${n.status}`);return r}async function Wl(t){const e=await Fy(),n=await fetch(`/functions/${sj}`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...e},cache:"no-store",body:JSON.stringify(t)}),r=await n.json().catch(()=>null);if(!n.ok||r?.ok===!1)throw new Error(r?.error||`Request failed with HTTP ${n.status}`);return r}function Sve(){return xv({mode:"installed"})}function kve(t={}){return xv({mode:"discover",...t.force?{force:1}:{}})}function Eve(t,e=0,n=20){return xv({mode:"search",q:t,offset:e,limit:n})}function Mve(){return xv({mode:"repos"})}function Tve(t,e){return Wl({action:"install",skill:t,targets:e})}function Cve(t){return Wl({action:"uninstall",id:t})}function Ave(t){return Wl({action:"restore",id:t})}function Rve(t,e){return Wl({action:"set_targets",id:t,targets:e})}function Pve(t,e){return Wl({action:"import_local",directory:t,targets:e})}function Nve(t,e){return Wl({action:"delete_local",directory:t,targets:e||[]})}function Dve(t){return Wl({action:"add_repo",repo:t})}function Lve(t,e){return Wl({action:"remove_repo",owner:t,name:e})}const AD=["claude","codex"],Ive={claude:"bg-orange-500/10 ring-1 ring-orange-500/20 hover:bg-orange-500/20",codex:"bg-emerald-500/10 ring-1 ring-emerald-500/20 hover:bg-emerald-500/20",gemini:"bg-sky-500/10 ring-1 ring-sky-500/20 hover:bg-sky-500/20",opencode:"bg-amber-500/10 ring-1 ring-amber-500/20 hover:bg-amber-500/20",hermes:"bg-indigo-500/10 ring-1 ring-indigo-500/20 hover:bg-indigo-500/20"},dd="all",ta="skillssh";function C0(t){return`${t.repoOwner||"local"}/${t.repoName||"local"}:${t.directory}`}function RD(t){return`install:${C0(t)}`}function zS(t){return`remove:${t.id||t.directory}`}function oj(t,e){return`target:${t}:${e}`}function Ove({skill:t,targets:e,busyKey:n,onToggleTarget:r}){const i=new Set(t.targets||[]);return m.jsx("div",{className:"flex flex-wrap gap-1",children:e.map(a=>{const s=i.has(a.id),o=n===oj(t.id,a.id),c=s?"skills.target.remove_title":"skills.target.sync_title";return m.jsx("button",{type:"button","aria-pressed":s,"aria-label":F("skills.target.toggle_aria",{target:a.label}),title:F(c,{target:a.label}),disabled:o,onClick:()=>r(t,a.id,!s),className:vt("inline-flex h-8 w-8 items-center justify-center rounded-md transition disabled:cursor-wait disabled:opacity-70",s?Ive[a.id]||"bg-oai-gray-100 dark:bg-oai-gray-800":"opacity-40 grayscale hover:bg-oai-gray-100 hover:opacity-100 hover:grayscale-0 dark:hover:bg-oai-gray-800"),children:o?m.jsx(Ml,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):m.jsx(Qc,{provider:a.id,size:16})},a.id)})})}function Fve({skill:t,targets:e,busyKey:n,onToggleTarget:r,onRemove:i}){const a=n===zS(t),s=t.repoOwner&&t.repoName?`${t.repoOwner}/${t.repoName}`:null,o=s?`${t.directory} · ${s}`:t.directory;return m.jsxs("div",{className:"group grid gap-4 px-1 py-3 lg:grid-cols-[minmax(0,1fr)_auto_auto] lg:items-center",children:[m.jsxs("div",{className:"min-w-0",title:o,children:[m.jsx("h2",{className:"truncate text-sm font-semibold text-oai-black dark:text-white",children:t.name||t.directory}),t.description?m.jsx("p",{className:"mt-0.5 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t.description}):null]}),m.jsx(Ove,{skill:t,targets:e,busyKey:n,onToggleTarget:r}),m.jsx("button",{type:"button","aria-label":F("skills.action.remove"),title:F("skills.action.remove"),disabled:a,onClick:()=>i(t),className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-oai-gray-400 opacity-0 transition duration-200 hover:bg-red-50 hover:text-red-600 group-hover:opacity-100 focus:opacity-100 disabled:cursor-wait disabled:opacity-100 dark:hover:bg-red-950/30 dark:hover:text-red-300 lg:justify-self-end",children:a?m.jsx(Ml,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):m.jsx(I3,{className:"h-4 w-4","aria-hidden":!0})})]})}function Uve({items:t,targets:e,busyKey:n,onToggleTarget:r,onRemove:i}){return m.jsxs("div",{children:[m.jsx("div",{className:"px-1 pb-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:F("skills.my.count",{count:t.length})}),m.jsx("div",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:t.map(a=>m.jsx(Fve,{skill:a,targets:e,busyKey:n,onToggleTarget:r,onRemove:i},a.id||a.key))})]})}const jve={contentVisibility:"auto",containIntrinsicSize:"0 240px"},Bve=ot.memo(function({skill:e,installed:n,installing:r,allTargets:i,defaultTargets:a,onInstall:s}){const[o,c]=x.useState(()=>(a||[]).filter(v=>i.some(w=>w.id===v))),u=v=>{c(w=>w.includes(v)?w.filter(b=>b!==v):[...w,v])},f=e.repoOwner&&e.repoName?`${e.repoOwner}/${e.repoName}`:null,h=e.installs!=null?F("skills.card.installs",{count:Number(e.installs||0).toLocaleString()}):null,p=[f,h].filter(Boolean).join(" · "),y=o.length?o.map(v=>i.find(w=>w.id===v)?.label||v).join(", "):F("skills.action.choose_targets");return m.jsxs(fu,{className:"h-full rounded-lg",bodyClassName:"flex h-full flex-col",children:[m.jsxs("div",{className:"flex items-start justify-between gap-3",children:[m.jsxs("div",{className:"min-w-0",children:[e.readmeUrl?m.jsxs("a",{href:e.readmeUrl,target:"_blank",rel:"noopener noreferrer",className:"group inline-flex max-w-full items-center gap-1 truncate text-base font-semibold text-oai-black hover:underline dark:text-white",title:e.readmeUrl,children:[m.jsx("span",{className:"truncate",children:e.name||e.directory}),m.jsx(T7,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400 opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":!0})]}):m.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:e.name||e.directory}),p?m.jsx("div",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:p}):null]}),n?m.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-md bg-oai-black/[0.06] px-2 py-1 text-xs font-medium text-oai-gray-700 ring-1 ring-oai-black/10 dark:bg-white/[0.08] dark:text-oai-gray-200 dark:ring-white/10",children:[m.jsx(Ph,{className:"h-3 w-3","aria-hidden":!0}),F("skills.card.installed")]}):null]}),e.description?m.jsx("p",{className:"mt-3 line-clamp-3 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:e.description}):null,m.jsx("div",{className:"mt-auto pt-5",children:n?m.jsxs("div",{className:"inline-flex h-8 w-full items-center justify-center gap-1.5 rounded-md bg-oai-black/[0.04] text-sm font-medium text-oai-gray-700 ring-1 ring-inset ring-oai-black/[0.08] dark:bg-white/[0.05] dark:text-oai-gray-200 dark:ring-white/[0.08]",children:[m.jsx(Ph,{className:"h-3.5 w-3.5","aria-hidden":!0}),F("skills.card.installed")]}):m.jsxs("div",{className:"flex",children:[m.jsxs(Ui,{type:"button",size:"sm",onClick:()=>s(e,o),disabled:r||o.length===0,className:"flex-1 !rounded-r-none",title:y,children:[r?m.jsx(Ml,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):m.jsx(Ek,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),o.length>1?F("skills.action.install_to",{count:o.length}):F("skills.action.install")]}),m.jsxs(zF,{children:[m.jsx(VF,{disabled:r,"aria-label":F("skills.action.choose_targets"),title:y,className:"inline-flex h-8 items-center justify-center rounded-r-md border-l border-white/20 bg-oai-black px-2 text-white hover:bg-oai-gray-800 disabled:cursor-not-allowed disabled:opacity-60 dark:border-oai-black/20 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:m.jsx(By,{className:"h-3.5 w-3.5","aria-hidden":!0})}),m.jsx(WF,{children:m.jsx($F,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:m.jsxs(YF,{className:"min-w-[200px] rounded-lg bg-white p-1.5 shadow-lg ring-1 ring-oai-gray-200 dark:bg-oai-gray-950 dark:ring-oai-gray-800",children:[m.jsx("div",{className:"px-2 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:F("skills.target.menu_label")}),i.map(v=>{const w=o.includes(v.id);return m.jsxs("button",{type:"button",onClick:()=>u(v.id),className:vt("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm",w?"bg-oai-gray-100 dark:bg-oai-gray-800":"hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900"),children:[m.jsx(Qc,{provider:v.id,size:16,className:w?"":"grayscale opacity-40"}),m.jsx("span",{className:"flex-1 text-left",children:v.label}),w?m.jsx(Ph,{className:"h-3.5 w-3.5 text-emerald-500","aria-hidden":!0}):null]},v.id)})]})})})]})]})})]})});function zve({repos:t,repoInput:e,onRepoInput:n,busyKey:r,onAdd:i,onRemove:a}){return m.jsxs("div",{className:"rounded-lg border border-oai-gray-200 bg-white p-4 dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[m.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[m.jsx(jF,{value:e,onChange:s=>n(s.target.value),placeholder:F("skills.repo.placeholder"),className:"min-w-0 flex-1"}),m.jsxs(Ui,{type:"button",variant:"secondary",size:"md",onClick:i,disabled:r==="repo:add",className:"shrink-0 whitespace-nowrap",children:[r==="repo:add"?m.jsx(Ml,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):m.jsx(D3,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),F("skills.repo.add")]})]}),t.length?m.jsx("div",{className:"mt-3 divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:t.map(s=>{const o=r===`repo:${s.owner}/${s.name}`;return m.jsxs("div",{className:"flex items-center justify-between gap-3 py-2",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsxs("div",{className:"truncate text-sm font-medium text-oai-black dark:text-white",children:[s.owner,"/",s.name]}),m.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s.branch})]}),m.jsxs(Ui,{type:"button",variant:"ghost",size:"sm",disabled:o,onClick:()=>a(s),className:"shrink-0",children:[o?m.jsx(Ml,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):m.jsx(I3,{className:"h-3.5 w-3.5","aria-hidden":!0}),m.jsx("span",{className:"sr-only",children:F("skills.repo.remove")})]})]},`${s.owner}/${s.name}`)})}):null]})}function Vve(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Hve(){const[t,e]=x.useState(Vve),[n,r]=x.useState({skills:[],targets:[]}),[i,a]=x.useState([]),[s,o]=x.useState([]),[c,u]=x.useState([]),[f,h]=x.useState(dd),[p,y]=x.useState(""),[v,w]=x.useState(""),[b,_]=x.useState(""),[E,M]=x.useState(!1),[T,R]=x.useState(""),[A,P]=x.useState(!0),[k,N]=x.useState(!1),[j,L]=x.useState(""),[V,U]=x.useState(null),[z,W]=x.useState(null),K=x.useMemo(()=>{const oe=new Set;for(const J of n.skills||[]){oe.add(C0(J).toLowerCase()),J.repoOwner&&J.repoName&&oe.add(`${J.repoOwner}/${J.repoName}:${J.sourceDirectory||J.directory}`.toLowerCase());const ze=String(J.directory||"").split(/[\\/]/).pop().toLowerCase();ze&&oe.add(`dir:${ze}`)}return oe},[n.skills]),Q=x.useCallback(async()=>{const oe=await Sve();r({skills:oe.skills||[],targets:oe.targets||[]})},[]),O=x.useCallback(async()=>{const oe=await Mve();u(oe.repos||[])},[]),G=x.useCallback(async({force:oe=!1}={})=>{N(!0);try{const J=await kve({force:oe});a(J.skills||[])}finally{N(!1)}},[]),Y=x.useCallback(async()=>{P(!0),L("");try{await Promise.all([Q(),O()])}catch(oe){L(oe?.message||F("skills.error.generic"))}finally{P(!1)}},[Q,O]),H=x.useCallback(async()=>{await Y(),t==="browse"&&f!==ta&&G({force:!0}).catch(oe=>L(oe?.message||F("skills.error.generic")))},[G,Y,f,t]);x.useEffect(()=>{Y()},[Y]),x.useEffect(()=>{t==="browse"&&f!==ta&&i.length===0&&G().catch(oe=>L(oe?.message||F("skills.error.generic")))},[i.length,G,f,t]),x.useEffect(()=>{if(!z)return;const oe=setTimeout(()=>W(J=>J?.key===z.key?null:J),z.ttlMs||5e3);return()=>clearTimeout(oe)},[z]),x.useEffect(()=>{const oe=setTimeout(()=>w(p),200);return()=>clearTimeout(oe)},[p]),x.useEffect(()=>{if(typeof window>"u")return;const oe=new URLSearchParams(window.location.search),J=oe.get("tab");if(t==="my"){if(!J)return;oe.delete("tab")}else{if(J===t)return;oe.set("tab",t)}const ze=oe.toString(),Ne=`${window.location.pathname}${ze?`?${ze}`:""}${window.location.hash}`;window.history.replaceState({},"",Ne)},[t]);const te=async(oe,J)=>{R(oe),L("");try{await J(),await Q()}catch(ze){L(ze?.message||F("skills.error.generic"))}finally{R("")}},re=(oe,J)=>{const ze=(J&&J.length?J:AD).filter(Ne=>(n.targets||[]).some(De=>De.id===Ne));te(RD(oe),async()=>{await Tve(oe,ze);const Ne=ze.map(De=>(n.targets||[]).find(Le=>Le.id===De)?.label||De).join(", ");W({key:`${Date.now()}:install:${C0(oe)}`,message:F("skills.toast.installed",{name:oe.name||oe.directory,targets:Ne||F("skills.target.none")}),ttlMs:4e3})})},ue=oe=>{U(oe)},ce=()=>{const oe=V;oe&&(U(null),te(zS(oe),async()=>{let J=null;oe.managed?J=await Cve(oe.id):await Nve(oe.directory,oe.targets||[]);const ze=!!(J?.trashed&&oe.managed&&oe.id);W({key:`${Date.now()}:${oe.id||oe.directory}`,message:F("skills.toast.removed",{name:oe.name||oe.directory}),undo:ze?async()=>{try{await Ave(oe.id),await Q(),W(null)}catch(Ne){L(Ne?.message||F("skills.error.generic"))}}:null,ttlMs:5e3})}))},ee=(oe,J,ze)=>te(oj(oe.id,J),async()=>{const Ne=new Set(oe.targets||[]);ze?Ne.add(J):Ne.delete(J),oe.managed?await Rve(oe.id,Array.from(Ne)):await Pve(oe.directory,Array.from(Ne))}),le=async()=>{const oe=p.trim();if(!(oe.length<2)){R("search"),L("");try{const J=await Eve(oe);o(J.skills||[])}catch(J){L(J?.message||F("skills.error.generic"))}finally{R("")}}},ve=async()=>{const oe=b.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[J,ze]=oe.split("/");if(!J||!ze){L(F("skills.repo.invalid"));return}await te("repo:add",async()=>{await Dve({owner:J,name:ze,branch:"main",enabled:!0}),_(""),await O(),await G()})},Pe=async oe=>{await te(`repo:${oe.owner}/${oe.name}`,async()=>{await Lve(oe.owner,oe.name),await O(),await G()})},be=n.targets||[],Ye=n.skills||[],he=x.useMemo(()=>{const oe=f===ta?s:i,J=f===ta||f===dd?oe:oe.filter(De=>`${De.repoOwner}/${De.repoName}`===f),ze=v.trim().toLowerCase();return(f===ta||!ze?J:J.filter(De=>(De.name||"").toLowerCase().includes(ze)||(De.directory||"").toLowerCase().includes(ze)||(De.description||"").toLowerCase().includes(ze))).map(De=>{const Le=C0(De).toLowerCase(),$=String(De.directory||"").split(/[\\/]/).pop().toLowerCase(),I=$?`dir:${$}`:"";return{...De,installed:K.has(Le)||I&&K.has(I)}})},[v,i,K,s,f]),Ue=m.jsx("div",{className:"flex h-64 items-center justify-center",children:m.jsx(Ml,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),je=m.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[m.jsx(Ml,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0}),m.jsx("p",{className:"max-w-md text-xs text-oai-gray-500 dark:text-oai-gray-400",children:F("skills.browse.loading_hint")})]}),et=(oe,J=null)=>m.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:[m.jsx("p",{children:F(oe)}),J]});let _e;if(A)_e=Ue;else if(t==="my")_e=Ye.length?m.jsx(Uve,{items:Ye,targets:be,busyKey:T,onToggleTarget:ee,onRemove:ue}):m.jsxs("div",{className:"flex flex-col items-center gap-4 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-800",children:[be.length>0?m.jsxs("div",{className:"relative h-11 w-80 overflow-hidden","aria-hidden":!0,children:[m.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)",WebkitMaskImage:"linear-gradient(to right, transparent 8%, black 20%, black 32%, transparent 44%, transparent 56%, black 68%, black 80%, transparent 92%)"},children:m.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",style:{filter:"blur(2.5px)"},children:[...be,...be].map((oe,J)=>m.jsx("span",{className:"shrink-0 px-3",children:m.jsx(Qc,{provider:oe.id,size:30})},`b-${J}`))})}),m.jsx("div",{className:"pointer-events-none absolute inset-0",style:{maskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)",WebkitMaskImage:"linear-gradient(to right, transparent 28%, black 42%, black 58%, transparent 72%)"},children:m.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",children:[...be,...be].map((oe,J)=>m.jsx("span",{className:"shrink-0 px-3",children:m.jsx(Qc,{provider:oe.id,size:30})},`c-${J}`))})}),m.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 w-20 bg-gradient-to-r from-oai-white to-transparent dark:from-oai-gray-900"}),m.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 w-20 bg-gradient-to-l from-oai-white to-transparent dark:from-oai-gray-900"})]}):null,m.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:F("skills.empty.my")}),m.jsx(Ui,{type:"button",size:"sm",onClick:()=>e("browse"),children:F("skills.empty.my_cta")})]});else{const oe=f===ta,J=c.length===0&&!oe;let ze;J?ze=m.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 p-6 text-center dark:border-oai-gray-800",children:m.jsx("p",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:F("skills.browse.empty_sources")})}):k&&!oe?ze=je:oe&&p.trim().length<2?ze=m.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 px-4 py-6 text-center text-sm text-oai-gray-500 dark:border-oai-gray-800 dark:text-oai-gray-400",children:F("skills.browse.hint_skillssh")}):he.length?ze=m.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:he.map(De=>m.jsx("div",{style:jve,children:m.jsx(Bve,{skill:De,installed:!!De.installed,installing:T===RD(De),allTargets:be,defaultTargets:AD,onInstall:re})},De.id||De.key))}):oe?ze=et("skills.empty.search"):ze=et("skills.empty.browse");const Ne=J||E?m.jsx("div",{className:"mb-5",children:m.jsx(zve,{repos:c,repoInput:b,onRepoInput:_,busyKey:T,onAdd:ve,onRemove:Pe})}):null;_e=m.jsxs(m.Fragment,{children:[Ne,ze]})}return m.jsxs("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:[m.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:m.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[m.jsxs("div",{className:"mb-6 flex items-end justify-between gap-4",children:[m.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:F("skills.page.title")}),m.jsxs(Ui,{type:"button",variant:"secondary",size:"sm",onClick:H,disabled:A||k,children:[m.jsx(Tk,{className:vt("mr-1.5 h-3.5 w-3.5",(A||k)&&"animate-spin"),"aria-hidden":!0}),F("skills.action.refresh")]})]}),m.jsx("div",{className:"mb-5 flex gap-6 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[["my",F("skills.tab.my")],["browse",F("skills.tab.browse")]].map(([oe,J])=>m.jsx("button",{type:"button","aria-pressed":t===oe,onClick:()=>e(oe),className:vt("-mb-px border-b-2 pb-2 text-sm font-medium transition-colors",t===oe?"border-oai-black text-oai-black dark:border-white dark:text-white":"border-transparent text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:J},oe))}),j?m.jsx("div",{className:"mb-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-200",children:j}):null,t==="browse"?m.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[m.jsx("div",{role:"tablist","aria-label":F("skills.source.label"),className:"inline-flex h-10 shrink-0 items-center rounded-md border border-oai-gray-200 bg-oai-white p-1 dark:border-oai-gray-800 dark:bg-oai-gray-900",children:[["repo",F("skills.mode.repo")],["skillssh",F("skills.mode.skillssh")]].map(([oe,J])=>{const ze=oe==="skillssh"==(f===ta);return m.jsx("button",{type:"button",role:"tab","aria-selected":ze,onClick:()=>{oe==="skillssh"?h(ta):f===ta&&h(dd)},className:vt("rounded px-3 py-1 text-sm font-medium transition-colors",ze?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-700 dark:text-white":"text-oai-gray-500 hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200"),children:J},oe)})}),f!==ta?m.jsxs(Xte,{value:f,onValueChange:h,children:[m.jsxs(ine,{"aria-label":F("skills.source.label"),className:"inline-flex h-10 w-44 shrink-0 items-center justify-between gap-2 rounded-md border border-oai-gray-200 bg-oai-white px-3 text-sm text-oai-black focus:outline-none data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:data-[popup-open]:border-oai-gray-700",children:[m.jsx(sne,{children:oe=>oe===dd?F("skills.source.all"):oe}),m.jsx(one,{className:"text-oai-gray-400",children:m.jsx(By,{className:"h-4 w-4","aria-hidden":!0})})]}),m.jsx(cne,{children:m.jsx(Rne,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:m.jsxs(Bne,{className:"min-w-[var(--anchor-width)] overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none transition-[opacity,transform] duration-150 ease-out data-[ending-style]:scale-[0.97] data-[ending-style]:opacity-0 data-[starting-style]:scale-[0.97] data-[starting-style]:opacity-0 dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[m.jsxs(rP,{value:dd,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[m.jsx(aP,{children:F("skills.source.all")}),m.jsx(iP,{children:m.jsx(Ph,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),c.map(oe=>{const J=`${oe.owner}/${oe.name}`;return m.jsxs(rP,{value:J,className:"flex cursor-default select-none items-center justify-between gap-2 rounded px-3 py-1.5 text-sm text-oai-black outline-none data-[highlighted]:bg-oai-gray-100 dark:text-white dark:data-[highlighted]:bg-oai-gray-800",children:[m.jsx(aP,{children:J}),m.jsx(iP,{children:m.jsx(Ph,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},J)})]})})})]}):null,m.jsxs("div",{className:"relative flex-1",children:[m.jsx(F2,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),m.jsx(jF,{value:p,onChange:oe=>y(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&f===ta&&le()},placeholder:f===ta?F("skills.browse.placeholder_skillssh"):f===dd?F("skills.browse.placeholder_all"):F("skills.browse.placeholder_repo",{repo:f}),className:"pl-9 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20"})]}),f===ta?m.jsxs(Ui,{type:"button",onClick:le,disabled:p.trim().length<2||T==="search",className:"focus:!ring-oai-gray-400/30",children:[T==="search"?m.jsx(Ml,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):m.jsx(F2,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),F("skills.action.search")]}):m.jsxs(Ui,{type:"button",variant:"secondary",size:"sm",onClick:()=>M(oe=>!oe),"aria-expanded":E,className:"!h-10 shrink-0 whitespace-nowrap !border-oai-gray-200 dark:!border-oai-gray-800 hover:!border-oai-gray-300 dark:hover:!border-oai-gray-700 hover:!text-oai-black dark:hover:!text-white focus:!ring-oai-gray-400/30",children:[m.jsx(D3,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),F("skills.browse.manage_sources"),m.jsx("span",{className:"ml-1.5 rounded bg-oai-gray-100 px-1.5 py-0.5 text-xs font-medium text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:c.length})]})]}):null,_e]})}),m.jsx(bre,{open:!!V,title:F("skills.confirm.remove_title",{name:V?.name||V?.directory||""}),description:V?V.managed?F("skills.confirm.remove_managed"):F("skills.confirm.remove_local"):"",confirmLabel:F("skills.action.remove"),cancelLabel:F("shared.action.cancel"),destructive:!0,busy:T===zS(V||{}),onCancel:()=>U(null),onConfirm:ce}),z?m.jsx("div",{className:"pointer-events-none fixed inset-x-0 bottom-6 z-[90] flex justify-center px-4",children:m.jsxs("div",{className:"pointer-events-auto flex max-w-md items-center gap-3 rounded-full bg-oai-black px-4 py-2 text-sm text-white shadow-lg dark:bg-white dark:text-oai-black",children:[m.jsx("span",{children:z.message}),z.undo?m.jsx("button",{type:"button",onClick:z.undo,className:"rounded-full px-2 py-0.5 text-xs font-semibold uppercase tracking-wide hover:bg-white/10 dark:hover:bg-oai-black/10",children:F("shared.action.undo")}):null]})}):null]})}const Wve=["todayTokens","todayCost"],lj=[{id:"todayTokens",label:"Today Tokens",shortLabel:"Tokens",category:"tokens"},{id:"todayCost",label:"Today Cost",shortLabel:"Cost",category:"cost"},{id:"last7dTokens",label:"Last 7 Days",shortLabel:"7d",category:"tokens"},{id:"totalTokens",label:"Total Tokens",shortLabel:"Total",category:"tokens"},{id:"totalCost",label:"Total Cost",shortLabel:"All $",category:"cost"},{id:"claude5h",label:"Claude 5h Limit",shortLabel:"Cl 5h",category:"limits"},{id:"claude7d",label:"Claude 7d Limit",shortLabel:"Cl 7d",category:"limits"},{id:"codex5h",label:"Codex 5h Limit",shortLabel:"Cx 5h",category:"limits"},{id:"codex7d",label:"Codex 7d Limit",shortLabel:"Cx 7d",category:"limits"},{id:"cursorPlan",label:"Cursor Plan Limit",shortLabel:"Cu Plan",category:"limits"},{id:"cursorAuto",label:"Cursor Auto Limit",shortLabel:"Cu Auto",category:"limits"},{id:"cursorAPI",label:"Cursor API Limit",shortLabel:"Cu API",category:"limits"},{id:"geminiPro",label:"Gemini Pro Limit",shortLabel:"Gm Pro",category:"limits"},{id:"geminiFlash",label:"Gemini Flash Limit",shortLabel:"Gm Flash",category:"limits"},{id:"geminiLite",label:"Gemini Lite Limit",shortLabel:"Gm Lite",category:"limits"},{id:"kimiWeekly",label:"Kimi Weekly Limit",shortLabel:"Km Wk",category:"limits"},{id:"kimi5h",label:"Kimi 5h Limit",shortLabel:"Km 5h",category:"limits"},{id:"kimiTotal",label:"Kimi Total Limit",shortLabel:"Km Tot",category:"limits"},{id:"kiroMonth",label:"Kiro Monthly Limit",shortLabel:"Kr Mo",category:"limits"},{id:"kiroBonus",label:"Kiro Bonus Limit",shortLabel:"Kr Bn",category:"limits"},{id:"copilotPremium",label:"Copilot Premium Limit",shortLabel:"Co Prem",category:"limits"},{id:"copilotChat",label:"Copilot Chat Limit",shortLabel:"Co Chat",category:"limits"},{id:"antigravityClaude",label:"Antigravity Claude Limit",shortLabel:"Ag Cl",category:"limits"},{id:"antigravityGPro",label:"Antigravity Gemini Pro Limit",shortLabel:"Ag GPro",category:"limits"},{id:"antigravityFlash",label:"Antigravity Flash Limit",shortLabel:"Ag Fl",category:"limits"}];function PD(t,e=lj,n=2){const r=new Set(e.map(o=>o.id)),i=new Set,a=Array.isArray(t)?t.filter(o=>!r.has(o)||i.has(o)?!1:(i.add(o),!0)):[];return(a.length>0?a:Wve).slice(0,Math.max(1,Number(n)||2))}const Gve=264,$ve=124,Eo="ui-rounded, -apple-system, system-ui",ND=["#5A8CF2","#9973E6","#4DB8A6","#E68C59"],Yve={claude:"#C77DFF",codex:"#34C759",cursor:"#FFCC00",gemini:"#0A84FF"};function qve(t){return t>=.9?"#E64D4D":t>=.7?"#D9A633":"#33B866"}function bv({size:t="sm",children:e}){const n=t==="lg",r=n?560:264,i=n?32:22;return m.jsx("div",{className:vt("flex w-full items-center justify-center rounded-xl bg-oai-gray-100 dark:bg-oai-gray-950/60",n?"py-10 sm:py-14 px-6":"py-6 px-4"),children:m.jsx("div",{className:"overflow-hidden bg-white dark:bg-oai-gray-800 shadow-oai-md dark:shadow-[0_2px_4px_rgba(0,0,0,0.4),0_8px_24px_rgba(0,0,0,0.5)]",style:{width:"100%",maxWidth:r,aspectRatio:`${Gve} / ${$ve}`,borderRadius:i},children:e})})}function Xve({size:t="sm"}){const e="M0,104 L14,104 C26,98 34,100 44,96 S58,88 68,92 80,100 90,94 102,80 112,82 126,92 136,88 150,74 162,76 178,88 188,86 204,72 216,74 236,84 250,80 L264,80",n=`${e} L264,124 L0,124 Z`,r=`sparkArea-${t}`;return m.jsx(bv,{size:t,children:m.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[m.jsx("defs",{children:m.jsxs("linearGradient",{id:r,x1:"0",y1:"0",x2:"0",y2:"1",children:[m.jsx("stop",{offset:"0%",stopColor:"#0A84FF",stopOpacity:"0.18"}),m.jsx("stop",{offset:"100%",stopColor:"#0A84FF",stopOpacity:"0"})]})}),m.jsx("text",{x:"14",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"TODAY"}),m.jsx("text",{x:"14",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:Eo,children:"203.2M"}),m.jsx("text",{x:"14",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:Eo,children:"$129.56 ±0%"}),m.jsx("text",{x:"134",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:"7 DAYS"}),m.jsx("text",{x:"134",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:Eo,children:"880.9M"}),m.jsx("text",{x:"134",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:Eo,children:"$673.61"}),m.jsx("path",{d:n,fill:`url(#${r})`,stroke:"none"}),m.jsx("path",{d:e,fill:"none",stroke:"#0A84FF",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const DD=(()=>{const n=[];for(let r=0;r<26;r++)for(let i=0;i<7;i++){const a=Math.sin((r+1)*12.9898+(i+1)*78.233+17)*43758.5453,s=Math.floor(Math.abs(a-Math.floor(a))*100);n.push({w:r,d:i,v:s})}return n})();function LD(t,e){return t<18?e?"#262626":"#e5e5e5":t<38?"rgba(10, 132, 255, 0.28)":t<58?"rgba(10, 132, 255, 0.50)":t<80?"rgba(10, 132, 255, 0.75)":"#0A84FF"}function Kve(){return m.jsx(bv,{children:m.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[m.jsx("g",{transform:`translate(${19.5}, 10)`,className:"hidden dark:inline",children:DD.map(a=>m.jsx("rect",{x:a.w*(7.5+1.2),y:a.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:LD(a.v,!0)},`d-${a.w}-${a.d}`))}),m.jsx("g",{transform:`translate(${19.5}, 10)`,className:"dark:hidden",children:DD.map(a=>m.jsx("rect",{x:a.w*(7.5+1.2),y:a.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:LD(a.v,!1)},`l-${a.w}-${a.d}`))}),m.jsx("text",{x:19.5,y:"102",className:"fill-oai-black dark:fill-white",fontSize:"10",fontWeight:"700",fontFamily:Eo,children:"10.3B"}),m.jsx("text",{x:19.5+30,y:"102",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"500",children:"tokens · 202 active days"})]})})}function Zve(){const t=[{name:"claude-opus-4-6",value:"586.4M",pct:59},{name:"claude-sonnet-4-5-20250929",value:"218.7M",pct:22},{name:"gpt-5.4",value:"80.6M",pct:8},{name:"composer-2-fast",value:"52.1M",pct:5}],e=22,n=28,r=14,i=236;return m.jsx(bv,{children:m.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((a,s)=>{const o=n+s*e,c=ND[s%ND.length];return m.jsxs("g",{children:[m.jsx("circle",{cx:"18",cy:o-3,r:"2.5",fill:c}),m.jsx("text",{x:"26",y:o,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:a.name}),m.jsx("text",{x:"218",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"600",fontFamily:Eo,children:a.value}),m.jsxs("text",{x:"250",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"600",fontFamily:Eo,children:[a.pct,"%"]}),m.jsx("rect",{x:r,y:o+4,width:i,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),m.jsx("rect",{x:r,y:o+4,width:Math.max(i*(a.pct/100),4),height:"2.8",rx:"1.4",fill:c})]},a.name)})})})}function Jve(){const t=[{label:"Claude · 7d",source:"claude",reset:"in 1d",pct:61},{label:"Claude · 5h",source:"claude",reset:"in 4h 28m",pct:4},{label:"Cursor",source:"cursor",reset:"in 25d",pct:51},{label:"Codex · weekly",source:"codex",reset:"in 1d",pct:32}],e=22,n=28,r=14,i=236;return m.jsx(bv,{children:m.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((a,s)=>{const o=n+s*e,c=Yve[a.source],u=qve(a.pct/100);return m.jsxs("g",{children:[m.jsx("circle",{cx:"18",cy:o-3,r:"2.5",fill:c}),m.jsx("text",{x:"26",y:o,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:a.label}),m.jsx("text",{x:"218",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:Eo,children:a.reset}),m.jsxs("text",{x:"250",y:o,textAnchor:"end",className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"700",fontFamily:Eo,children:[a.pct,"%"]}),m.jsx("rect",{x:r,y:o+4,width:i,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),m.jsx("rect",{x:r,y:o+4,width:Math.max(i*(a.pct/100),4),height:"2.8",rx:"1.4",fill:u})]},a.label)})})})}function Qve(t){switch(t.category){case"cost":return"$8.42";case"limits":return"62%";default:return t.id==="last7dTokens"?"1.8B":"203M"}}function exe(t,e){switch(t){case"todayTokens":return F("menubar.metric.today_tokens");case"todayCost":return F("menubar.metric.today_cost");case"last7dTokens":return F("menubar.metric.last_7d_tokens");case"totalTokens":return F("menubar.metric.total_tokens");case"totalCost":return F("menubar.metric.total_cost");case"claude5h":return F("menubar.metric.claude_5h");case"claude7d":return F("menubar.metric.claude_7d");case"codex5h":return F("menubar.metric.codex_5h");case"codex7d":return F("menubar.metric.codex_7d");default:return e}}function txe(t,e){const n=new Set(e.map(i=>i.id)),r=t.filter(i=>n.has(i));for(const i of e){if(r.length>=2)break;r.includes(i.id)||r.push(i.id)}return r.slice(0,2)}function nxe({slotConfigs:t,showStats:e}){return m.jsx("div",{className:"flex justify-center rounded-xl bg-gradient-to-b from-oai-gray-100 to-oai-gray-200 px-6 py-8 dark:from-oai-gray-950/80 dark:to-oai-gray-900/80",children:m.jsxs("div",{className:"inline-flex items-stretch rounded-md shadow-[0_1px_3px_rgba(0,0,0,0.18)] ring-1 ring-black/10 dark:ring-white/10 px-3",style:{background:"linear-gradient(180deg, #2c2c2e 0%, #1c1c1e 100%)"},children:[m.jsx("div",{className:"flex items-center pl-2 pr-1 py-2.5",children:m.jsx("img",{src:"/clawd/mini/idle-tight.svg",alt:"","aria-hidden":"true",className:"block shrink-0",style:{height:22,width:"auto"},draggable:"false"})}),e?t.map(({slot:n,item:r},i)=>m.jsxs(ot.Fragment,{children:[i>0?m.jsx("span",{className:"my-1 w-px bg-white/20","aria-hidden":"true"}):null,m.jsxs("div",{className:vt("flex min-w-[52px] flex-col items-center justify-center py-1.5",i===0?"pl-1 pr-2":"px-2"),children:[m.jsx("span",{className:"text-[13px] font-semibold leading-none tabular-nums text-white",children:r?.previewValue||"--"}),m.jsx("span",{className:"mt-[2px] text-[6px] font-semibold uppercase leading-none text-white/75",children:r?.shortLabel||"Metric"})]})]},n)):null]})})}function rxe({slot:t,value:e,options:n,disabled:r,onChange:i}){const a=F(t===0?"menubar.slot.primary":"menubar.slot.secondary");return m.jsxs("label",{className:"flex min-w-0 flex-col gap-1.5",children:[m.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400",children:a}),m.jsxs("div",{className:"relative",children:[m.jsx("select",{value:e,disabled:r,"aria-label":a,onChange:s=>i(t,s.target.value),className:vt("w-full appearance-none rounded-lg border border-oai-gray-200 bg-white px-3 py-2 pr-9 text-sm font-medium text-oai-black transition-colors hover:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-white dark:hover:border-oai-gray-700",r&&"cursor-not-allowed opacity-50 hover:border-oai-gray-200 dark:hover:border-oai-gray-800"),children:n.map(s=>m.jsx("option",{value:s.id,children:s.displayLabel},s.id))}),m.jsx(By,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":"true"})]})]})}function ID({label:t,hint:e,checked:n,disabled:r,onChange:i}){return m.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:t}),e?m.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e}):null]}),m.jsx(yf,{checked:n,disabled:r,onChange:i,ariaLabel:t})]})}function ixe(){const{available:t,settings:e,setSetting:n}=fM(),r=x.useMemo(()=>(Array.isArray(e?.menuBarAvailableItems)?e.menuBarAvailableItems:lj).map(y=>({...y,displayLabel:exe(y.id,y.label),previewValue:Qve(y)})),[e?.menuBarAvailableItems]),i=Number(e?.menuBarMaxItems)||2,a=x.useMemo(()=>PD(e?.menuBarItems,r,i),[r,i,e?.menuBarItems]),s=x.useMemo(()=>txe(a,r),[r,a]),o=e?.showStats!==!1,c=p=>{n("menuBarItems",PD(p,r,i))},u=(p,y)=>{const v=[...s];v[p===0?1:0]!==y&&(v[p]=y,c(v))},f=[0,1].map(p=>{const y=s[p]||r[p]?.id||"",w=s[p===0?1:0],b=r.filter(E=>E.id===y||E.id!==w),_=r.find(E=>E.id===y);return{slot:p,currentValue:y,options:b,item:_}}),h=e?.animatedIcon!==!1;return m.jsxs("article",{className:"rounded-xl border border-oai-gray-200 bg-white p-5 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-6",children:[m.jsx(nxe,{slotConfigs:f,showStats:o}),m.jsx("div",{className:"mt-5 grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4",children:f.map(({slot:p,currentValue:y,options:v})=>m.jsx(rxe,{slot:p,value:y,options:v,disabled:!t||!o,onChange:u},p))}),m.jsxs("div",{className:"mt-5 divide-y divide-oai-gray-100 border-t border-oai-gray-100 dark:divide-oai-gray-800 dark:border-oai-gray-800",children:[m.jsx(ID,{label:F("settings.menubar.showStats"),hint:F(t?"settings.menubar.showStatsHint":"menubar.native_only"),checked:o,disabled:!t,onChange:()=>n("showStats",!o)}),m.jsx(ID,{label:F("settings.menubar.animatedIcon"),hint:F("settings.menubar.animatedIconHint"),checked:h,disabled:!t,onChange:()=>n("animatedIcon",!h)})]})]})}function axe(){const[t,e]=x.useState("loading");return x.useEffect(()=>{if(typeof window>"u")return;if(Za()){e("native");return}const n=(navigator.userAgent||"").toLowerCase(),r=/mac/.test(n)&&!/iphone|ipad/.test(n);e(r?"mac-web":"other")},[]),t}function sxe(){const t=axe();return t==="loading"?m.jsx("div",{className:"h-10 w-40","aria-hidden":"true"}):t==="native"?m.jsxs("button",{type:"button",onClick:()=>T3("openWidgetGallery"),className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[F("widgets.cta.open_gallery"),m.jsx(b7,{className:"h-4 w-4","aria-hidden":"true"})]}):t==="mac-web"?m.jsxs("a",{href:"https://github.com/mm7894215/TokenTracker/releases/latest",target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white no-underline transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[m.jsx(Ek,{className:"h-4 w-4","aria-hidden":"true"}),F("widgets.cta.download")]}):m.jsxs("span",{className:"inline-flex h-10 items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 text-sm font-medium text-oai-gray-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-400",children:[m.jsx(zy,{className:"h-4 w-4","aria-hidden":"true"}),F("widgets.cta.macos_only")]})}const oxe=[{id:"summary",Preview:Xve,nameKey:"widgets.summary.name",descKey:"widgets.summary.description"},{id:"heatmap",Preview:Kve,nameKey:"widgets.heatmap.name",descKey:"widgets.heatmap.description"},{id:"topModels",Preview:Zve,nameKey:"widgets.topModels.name",descKey:"widgets.topModels.description"},{id:"limits",Preview:Jve,nameKey:"widgets.limits.name",descKey:"widgets.limits.description"}];function lxe({Preview:t,nameKey:e,descKey:n}){return m.jsxs("article",{className:"flex h-full flex-col rounded-xl border border-oai-gray-200 bg-white p-4 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-5",children:[m.jsx(t,{}),m.jsxs("div",{className:"mt-4",children:[m.jsx("h3",{className:"text-[15px] font-semibold text-oai-black dark:text-white",children:F(e)}),m.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:F(n)})]})]})}function OD({titleKey:t}){return m.jsx("h2",{className:"mb-4 text-xl font-semibold tracking-tight text-oai-black dark:text-white sm:mb-5 sm:text-2xl",children:F(t)})}function cxe(){return m.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:m.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:m.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[m.jsx(xo,{y:12,children:m.jsxs("header",{className:"mb-10 flex items-start justify-between gap-4 sm:mb-12",children:[m.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:F("widgets.page.title")}),m.jsx("div",{className:"shrink-0",children:m.jsx(sxe,{})})]})}),m.jsx(xo,{y:12,delay:.06,children:m.jsxs("section",{"aria-label":F("widgets.menubar.section.title"),className:"mb-12 sm:mb-14",children:[m.jsx(OD,{titleKey:"widgets.menubar.section.title"}),m.jsx(ixe,{})]})}),m.jsxs("section",{"aria-label":F("widgets.gallery.section.title"),children:[m.jsx(OD,{titleKey:"widgets.gallery.section.title"}),m.jsx(ooe,{staggerDelay:.08,initialDelay:.04,children:m.jsx("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2 lg:gap-5",children:oxe.map(({id:t,Preview:e,nameKey:n,descKey:r})=>m.jsx(loe,{children:m.jsx(lxe,{Preview:e,nameKey:n,descKey:r})},t))})})]})]})})})}function uxe(){const{resolvedLocale:t}=su(),e=Hi(),n=ss();CZ();const r=wr(),i=x.useMemo(()=>typeof window>"u"?!1:sE(window.location.search),[]),a=e?.pathname||"/",s=new URL(window.location.href),o=s.pathname.replace(/\/+$/,"")||"/",u=o.match(/^\/share\/([^/?#]+)$/i)?.[1]||null,f=s.searchParams.get("token")||null,h=u||f,p=o==="/share"||o==="/share.html"||o.startsWith("/share/"),y=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),v=a.replace(/\/+$/,"")||"/",w=v.match(/^\/leaderboard\/u\/([^/]+)$/i),b=w?w[1]:null,_=v==="/leaderboard"||!!b,E=!!(n.enabled&&n.signedIn),M=y||E,T=!1,R=bZ(),A=x.useMemo(()=>!n.enabled||!E?null:{getAccessToken:()=>n.getAccessToken(),name:n.displayName||"",userId:n.user?.id||null},[E,n]);let P=y||r||i?"dashboard":"landing";v==="/landing"&&(P="landing"),v==="/dashboard"&&(P="dashboard"),_&&(P="dashboard");const k=v==="/limits",N=v==="/settings",j=v==="/skills",L=v==="/widgets",V=v==="/ip-check";(k||N||j||L||V)&&(P="dashboard");let U=cle;b?U=Mye:v==="/leaderboard"?U=vye:k?U=Uye:N?U=wve:j?U=Hve:L?U=cxe:V&&(U=ule);const W=!p&&(v==="/dashboard"||v==="/"||v==="/leaderboard"||k||N||j||L||V);let K=null;if(v==="/auth/callback"||v==="/auth/native-callback")K=m.jsx(Vye,{});else if(v==="/login")K=m.jsx(Bye,{});else if(P==="landing")K=m.jsx(dge,{signInUrl:"/login",signUpUrl:"/login"});else{const Q=m.jsx(U,{baseUrl:R,auth:A,signedIn:M,sessionSoftExpired:T,signOut:()=>n.enabled?n.signOut():Promise.resolve(),publicMode:p,publicToken:h,userId:b,signInUrl:"/login",signUpUrl:"/login"},t);W?K=m.jsx(ore,{children:Q}):K=Q}return m.jsx(dG,{children:m.jsx(pG,{children:m.jsxs(mG,{children:[K,m.jsx(vZ,{}),m.jsx(t7,{}),m.jsx(f7,{})]})})})}const dxe=R8([{path:"*",element:m.jsx(uxe,{})}]);vB.createRoot(document.getElementById("root")).render(m.jsx(ot.StrictMode,{children:m.jsx(HW,{children:m.jsx(mW,{children:m.jsx(H8,{router:dxe})})})}));