tokentracker-cli 0.11.0 → 0.11.1
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.
|
@@ -861,7 +861,7 @@ dashboard.context_breakdown.exec_details.group_by_exit,dashboard,DashboardPage,C
|
|
|
861
861
|
${s.right}px ${s.bottom}px,
|
|
862
862
|
${s.right}px ${s.top}px,
|
|
863
863
|
${s.left}px ${s.top}px
|
|
864
|
-
)`}return p.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})});function gy(t,e){t&&Object.assign(t.style,e)}const Vne={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},Hne={position:"fixed"},Wne=x.forwardRef(function(e,n){const{anchor:r,positionMethod:i="absolute",className:a,render:s,side:o="bottom",align:c="center",sideOffset:u=0,alignOffset:f=0,collisionBoundary:h="clipping-ancestors",collisionPadding:m,arrowPadding:g=5,sticky:v=!1,disableAnchorTracking:w,alignItemWithTrigger:b=!0,collisionAvoidance:_=$J,...E}=e,{store:M,listRef:T,labelsRef:P,alignItemWithTriggerActiveRef:A,selectedItemTextRef:R,valuesRef:k,initialValueRef:N,popupRef:B,setValue:L}=Wl(),z=m5(),I=mn(M,hn.open),V=mn(M,hn.mounted),W=mn(M,hn.modal),X=mn(M,hn.value),J=mn(M,hn.openMethod),F=mn(M,hn.positionerElement),G=mn(M,hn.triggerElement),Y=mn(M,hn.isItemEqualToValue),H=x.useRef(null),te=x.useRef(null),[re,ue]=x.useState(b),ce=V&&re&&J!=="touch";!V&&re!==b&&ue(b),Yt(()=>{V||(hn.scrollUpArrowVisible(M.state)&&M.set("scrollUpArrowVisible",!1),hn.scrollDownArrowVisible(M.state)&&M.set("scrollDownArrowVisible",!1))},[M,V]),x.useImperativeHandle(A,()=>ce),LE((ce||W)&&I&&J!=="touch",G);const ee=E5({anchor:r,floatingRootContext:z,positionMethod:i,mounted:V,side:o,sideOffset:u,align:c,alignOffset:f,arrowPadding:g,collisionBoundary:h,collisionPadding:m,sticky:v,disableAnchorTracking:w??ce,collisionAvoidance:_,keepMounted:!0}),le=ce?"none":ee.side,ve=ce?Hne:ee.positionerStyles,Ne=x.useMemo(()=>{const _e={};return I||(_e.pointerEvents="none"),{role:"presentation",hidden:!V,style:{...ve,..._e}}},[I,V,ve]),be=x.useMemo(()=>({open:I,side:le,align:ee.align,anchorHidden:ee.anchorHidden}),[I,le,ee.align,ee.anchorHidden]),qe=Bt(_e=>{M.set("positionerElement",_e)}),he=Xr("div",e,{ref:[n,qe],state:be,stateAttributesMapping:hu,props:[Ne,E]}),Ue=x.useRef(0),je=Bt(_e=>{if(_e.size===0&&Ue.current===0||k.current.length===0)return;const oe=Ue.current;if(Ue.current=_e.size,_e.size===oe)return;const Q=Mn(iv);if(oe!==0&&!M.state.multiple&&X!==null&&P1(k.current,X,Y)===-1){const Pe=N.current,Le=Pe!=null&&p_(k.current,Pe,Y)?Pe:null;L(Le,Q),Le===null&&(M.set("selectedIndex",null),R.current=null)}if(oe!==0&&M.state.multiple&&Array.isArray(X)){const ze=X.filter(Pe=>p_(k.current,Pe,Y));(ze.length!==X.length||ze.some(Pe=>!p_(X,Pe,Y)))&&(L(ze,Q),ze.length===0&&(M.set("selectedIndex",null),R.current=null))}if(I&&ce){M.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const ze={height:""};gy(F,ze),gy(B.current,ze)}}),et=x.useMemo(()=>({...ee,side:le,alignItemWithTriggerActive:ce,setControlledAlignItemWithTrigger:ue,scrollUpArrowRef:H,scrollDownArrowRef:te}),[ee,le,ce,ue]);return p.jsx(Rne,{elementsRef:T,labelsRef:P,onMapChange:je,children:p.jsxs(M5.Provider,{value:et,children:[V&&W&&p.jsx(IE,{inert:DE(!I),cutout:G}),he]})})});function T5(t){const e=t.currentTarget.getBoundingClientRect();return e.top+1<=t.clientY&&t.clientY<=e.bottom-1&&e.left+1<=t.clientX&&t.clientX<=e.right-1}const Mg="base-ui-disable-scrollbar",iR={className:Mg,getElement(t){return p.jsx("style",{nonce:t,href:Mg,precedence:"base-ui:low",children:`.${Mg}{scrollbar-width:none}.${Mg}::-webkit-scrollbar{display:none}`})}},Gne=x.createContext(void 0);function C5(t){return x.useContext(Gne)}const A5="ArrowUp",P5="ArrowDown",R5="ArrowLeft",N5="ArrowRight",D5="Home",L5="End",$ne=new Set([R5,N5]),Yne=new Set([A5,P5]),qne=new Set([...$ne,...Yne]);[...qne];const OE=new Set([A5,P5,R5,N5,D5,L5]);function FE(t){return t==="starting"?GJ:ei}function Xne(t,e=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(e,Math.min(t,n))}const Kne=x.createContext(void 0),Zne={disableStyleElements:!1};function Jne(){return x.useContext(Kne)??Zne}const Qne={...hu,...df},ere=x.forwardRef(function(e,n){const{render:r,className:i,...a}=e,{store:s,popupRef:o,onOpenChangeComplete:c,setOpen:u,valueRef:f,selectedItemTextRef:h,keyboardActiveRef:m,multiple:g,handleScrollArrowVisibility:v,scrollHandlerRef:w,highlightItemOnHover:b}=Wl(),{side:_,align:E,alignItemWithTriggerActive:M,setControlledAlignItemWithTrigger:T,scrollDownArrowRef:P,scrollUpArrowRef:A}=zne(),R=C5()!=null,k=m5(),{nonce:N,disableStyleElements:B}=Jne(),L=ji(),z=mn(s,hn.id),I=mn(s,hn.open),V=mn(s,hn.mounted),W=mn(s,hn.popupProps),X=mn(s,hn.transitionStatus),J=mn(s,hn.triggerElement),F=mn(s,hn.positionerElement),G=mn(s,hn.listElement),Y=x.useRef(0),H=x.useRef(!1),te=x.useRef(0),re=x.useRef(!1),ue=x.useRef({}),ce=rv(),ee=Bt(be=>{if(!F||!o.current||!re.current)return;if(H.current||!M){v();return}const qe=F.style.top==="0px",he=F.style.bottom==="0px",Ue=F.getBoundingClientRect().height,je=Gs(F),et=getComputedStyle(F),_e=parseFloat(et.marginTop),oe=parseFloat(et.marginBottom),Q=aR(getComputedStyle(o.current)),ze=je.documentElement.clientHeight-_e-oe,Pe=be.scrollTop,De=be.scrollHeight,Le=be.clientHeight,$=De-Le;let U=0,Z=null,pe=!1;if(qe){const Se=$-Pe,xe=Ue+Se,Ie=Math.min(xe,ze);U=Ie,Ie!==ze?Z=$:pe=!0}else if(he){const Se=Pe-0,xe=Ue+Se,Ie=Math.min(xe,ze),He=xe-ze;U=Ie,Ie!==ze?Z=0:(pe=!0,Pe<$&&(Z=Pe-(Se-He)))}U!==0&&(F.style.height=`${U}px`),Z!=null&&(be.scrollTop=Z),(pe||U>=Q)&&(H.current=!0),v()});x.useImperativeHandle(w,()=>ee,[ee]),ff({open:I,ref:o,onComplete(){I&&c?.(!0)}});const le=x.useMemo(()=>({open:I,transitionStatus:X,side:_,align:E}),[I,X,_,E]);Yt(()=>{!F||!o.current||Object.keys(ue.current).length||(ue.current={top:F.style.top||"0",left:F.style.left||"0",right:F.style.right,height:F.style.height,bottom:F.style.bottom,minHeight:F.style.minHeight,maxHeight:F.style.maxHeight,marginTop:F.style.marginTop,marginBottom:F.style.marginBottom})},[o,F]),Yt(()=>{I||M||(re.current=!1,H.current=!1,Y.current=0,te.current=0,gy(F,ue.current))},[I,M,F,o]),Yt(()=>{const be=o.current;if(!(!I||!J||!F||!be||s.state.transitionStatus==="ending")){if(!M){re.current=!0,ce.request(v),be.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const qe=nre(be);be.style.removeProperty("--transform-origin");try{const he=getComputedStyle(F),Ue=getComputedStyle(be),je=Gs(J),et=Rr(F),_e=J.getBoundingClientRect(),oe=F.getBoundingClientRect(),Q=_e.left,ze=_e.height,Pe=G||be,De=Pe.scrollHeight,Le=parseFloat(Ue.borderBottomWidth),$=parseFloat(he.marginTop)||10,U=parseFloat(he.marginBottom)||10,Z=parseFloat(he.minHeight)||100,pe=aR(Ue),Se=5,xe=5,Ie=20,He=je.documentElement.clientHeight-$-U,Ye=je.documentElement.clientWidth,ft=He-_e.bottom+ze,We=h.current,Xe=f.current;let nt,ct=0,Ke=0;if(We&&Xe){const _t=Xe.getBoundingClientRect();nt=We.getBoundingClientRect();const wt=_t.left-Q,un=nt.left-oe.left,xn=_t.top-_e.top+_t.height/2,ie=nt.top-oe.top+nt.height/2;ct=wt-un,Ke=ie-xn}const gt=ft+Ke+U+Le;let ne=Math.min(He,gt);const Be=He-$-U,ke=gt-ne,Ae=Math.max(Se,Q+ct),Ve=Ye-xe,ge=Math.max(0,Ae+oe.width-Ve);F.style.left=`${Ae-ge}px`,F.style.height=`${ne}px`,F.style.maxHeight="auto",F.style.marginTop=`${$}px`,F.style.marginBottom=`${U}px`,be.style.height="100%";const ut=Pe.scrollHeight-Pe.clientHeight,yt=ke>=ut;yt&&(ne=Math.min(He,oe.height)-(ke-ut));const qt=_e.top<Ie||_e.bottom>He-Ie||ne<Math.min(De,Z),Lt=(et.visualViewport?.scale??1)!==1&&_4;if(qt||Lt){re.current=!0,gy(F,ue.current),gi.flushSync(()=>T(!1));return}if(yt){const _t=Math.max(0,He-gt);F.style.top=oe.height>=Be?"0":`${_t}px`,F.style.height=`${ne}px`,Pe.scrollTop=Pe.scrollHeight-Pe.clientHeight,Y.current=Math.max(Z,ne)}else F.style.bottom="0",Y.current=Math.max(Z,ne),Pe.scrollTop=ke;if(nt){const _t=oe.top,wt=oe.height,un=nt.top+nt.height/2,xn=wt>0?(un-_t)/wt*100:50,ie=Xne(xn,0,100);be.style.setProperty("--transform-origin",`50% ${ie}%`)}(Y.current===He||ne>=pe)&&(H.current=!0),v(),setTimeout(()=>{re.current=!0})}finally{qe()}})}},[s,I,F,J,f,h,o,v,M,T,ce,P,A,G]),x.useEffect(()=>{if(!M||!F||!I)return;const be=Rr(F);function qe(he){u(!1,Mn(Cee,he))}return be.addEventListener("resize",qe),()=>{be.removeEventListener("resize",qe)}},[u,M,F,I]);const ve={...G?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":g||void 0,id:`${z}-list`},onKeyDown(be){m.current=!0,R&&OE.has(be.key)&&be.stopPropagation()},onMouseMove(){m.current=!1},onPointerLeave(be){if(!b||T5(be)||be.pointerType==="touch")return;const qe=be.currentTarget;L.start(0,()=>{s.set("activeIndex",null),qe.focus({preventScroll:!0})})},onScroll(be){G||w.current?.(be.currentTarget)},...M&&{style:G?{height:"100%"}:Vne}},Ne=Xr("div",e,{ref:[n,o],state:le,stateAttributesMapping:Qne,props:[W,ve,FE(X),{className:!G&&M?iR.className:void 0},a]});return p.jsxs(x.Fragment,{children:[!B&&iR.getElement(N),p.jsx(ME,{context:k,modal:!1,disabled:!V,restoreFocus:!0,children:Ne})]})});function aR(t){const e=t.maxHeight||"";return e.endsWith("px")&&parseFloat(e)||1/0}const sR={transform:"none",scale:"1",translate:"0 0"};function tre(t,e,n){n?t.setProperty(e,n):t.removeProperty(e)}function nre(t){const{style:e}=t,n={},r=Object.keys(sR);for(const i of r)n[i]=e.getPropertyValue(i),e.setProperty(i,sR[i]);return()=>{for(const i of r)tre(e,i,n[i])}}let I5=(function(t){return t[t.None=0]="None",t[t.GuessFromOrder=1]="GuessFromOrder",t})({});function rre(t={}){const{label:e,metadata:n,textRef:r,indexGuessBehavior:i,index:a}=t,{register:s,unregister:o,subscribeMapChange:c,elementsRef:u,labelsRef:f,nextIndexRef:h}=Pne(),m=x.useRef(-1),[g,v]=x.useState(a??(i===I5.GuessFromOrder?()=>{if(m.current===-1){const _=h.current;h.current+=1,m.current=_}return m.current}:-1)),w=x.useRef(null),b=x.useCallback(_=>{if(w.current=_,g!==-1&&_!==null&&(u.current[g]=_,f)){const E=e!==void 0;f.current[g]=E?e:r?.current?.textContent??_.textContent}},[g,u,f,e,r]);return Yt(()=>{if(a!=null)return;const _=w.current;if(_)return s(_,n),()=>{o(_)}},[a,s,o,n]),Yt(()=>{if(a==null)return c(_=>{const E=w.current?_.get(w.current)?.index:null;E!=null&&v(E)})},[a,c,v]),x.useMemo(()=>({ref:b,index:g}),[g,b])}const O5=x.createContext(void 0);function UE(){const t=x.useContext(O5);if(!t)throw new Error(Wi(57));return t}const oR=x.memo(x.forwardRef(function(e,n){const{render:r,className:i,value:a=null,label:s,disabled:o=!1,nativeButton:c=!1,...u}=e,f=x.useRef(null),h=rre({label:s,textRef:f,indexGuessBehavior:I5.GuessFromOrder}),{store:m,getItemProps:g,setOpen:v,setValue:w,selectionRef:b,typingRef:_,valuesRef:E,keyboardActiveRef:M,multiple:T,highlightItemOnHover:P}=Wl(),A=ji(),R=mn(m,hn.isActive,h.index),k=mn(m,hn.isSelected,h.index,a),N=mn(m,hn.isSelectedByFocus,h.index),B=mn(m,hn.isItemEqualToValue),L=h.index,z=L!==-1,I=x.useRef(null),V=jr(L);Yt(()=>{if(!z)return;const ee=E.current;return ee[L]=a,()=>{delete ee[L]}},[z,L,a,E]),Yt(()=>{if(!z)return;const ee=m.state.value;let le=ee;T&&Array.isArray(ee)&&ee.length>0&&(le=ee[ee.length-1]),le!==void 0&&$d(le,a,B)&&m.set("selectedIndex",L)},[z,L,T,B,m,a]);const W=x.useMemo(()=>({disabled:o,selected:k,highlighted:R}),[o,k,R]),X=g({active:R,selected:k});X.onFocus=void 0,X.id=void 0;const J=x.useRef(null),F=x.useRef("mouse"),G=x.useRef(!1),{getButtonProps:Y,buttonRef:H}=nv({disabled:o,focusableWhenDisabled:!0,native:c});function te(ee){const le=m.state.value;if(T){const ve=Array.isArray(le)?le:[],Ne=k?ene(ve,a,B):[...ve,a];w(Ne,Mn(a_,ee))}else w(a,Mn(a_,ee)),v(!1,Mn(a_,ee))}const re={role:"option","aria-selected":k,tabIndex:R?0:-1,onFocus(){m.set("activeIndex",L)},onMouseEnter(){!M.current&&m.state.selectedIndex===null&&m.set("activeIndex",L)},onMouseMove(){P&&m.set("activeIndex",L)},onMouseLeave(ee){!P||M.current||T5(ee)||A.start(0,()=>{m.state.activeIndex===L&&m.set("activeIndex",null)})},onTouchStart(){b.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(ee){J.current=ee.key,m.set("activeIndex",L)},onClick(ee){G.current=!1,!(ee.type==="keydown"&&J.current===null)&&(o||J.current===" "&&_.current||F.current!=="touch"&&!R||(J.current=null,te(ee.nativeEvent)))},onPointerEnter(ee){F.current=ee.pointerType},onPointerDown(ee){F.current=ee.pointerType,G.current=!0},onMouseUp(ee){if(o)return;if(G.current){G.current=!1;return}const le=!b.current.allowSelectedMouseUp&&k,ve=!b.current.allowUnselectedMouseUp&&!k;le||ve||F.current!=="touch"&&!R||te(ee.nativeEvent)}},ue=Xr("div",e,{ref:[H,n,h.ref,I],state:W,props:[X,re,u,Y]}),ce=x.useMemo(()=>({selected:k,indexRef:V,textRef:f,selectedByFocus:N,hasRegistered:z}),[k,V,f,N,z]);return p.jsx(O5.Provider,{value:ce,children:ue})})),lR=x.forwardRef(function(e,n){const r=e.keepMounted??!1,{selected:i}=UE();return r||i?p.jsx(ire,{...e,ref:n}):null}),ire=x.memo(x.forwardRef((t,e)=>{const{render:n,className:r,keepMounted:i,...a}=t,{selected:s}=UE(),o=x.useRef(null),{transitionStatus:c,setMounted:u}=PE(s),f=x.useMemo(()=>({selected:s,transitionStatus:c}),[s,c]),h=Xr("span",t,{ref:[e,o],state:f,props:[{"aria-hidden":!0,children:"✔️"},a],stateAttributesMapping:df});return ff({open:s,ref:o,onComplete(){s||u(!1)}}),h})),cR=x.memo(x.forwardRef(function(e,n){const{indexRef:r,textRef:i,selectedByFocus:a,hasRegistered:s}=UE(),{selectedItemTextRef:o}=Wl(),{className:c,render:u,...f}=e,h=x.useCallback(g=>{if(!g||!s)return;const v=o.current===null||!o.current.isConnected;(a||v&&r.current===0)&&(o.current=g)},[o,r,a,s]);return Xr("div",e,{ref:[h,n,i],props:f})}));function F5({prefersReducedMotion:t,screenshotCapture:e}){return!(e||t)}function pu({children:t,title:e,subtitle:n,className:r="",bodyClassName:i=""}){return p.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 transition-colors duration-200 ${r}`,children:[(e||n)&&p.jsxs("div",{className:"px-5 py-4 border-b border-oai-gray-200 dark:border-oai-gray-800 transition-colors duration-200",children:[e&&p.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide transition-colors duration-200",children:e}),n&&p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300 mt-1 transition-colors duration-200",children:n})]}),p.jsx("div",{className:`p-5 ${i}`,children:t})]})}function are(){return p.jsxs(Ei,{to:"/landing",className:"flex items-center gap-2.5 no-underline hover:opacity-80 transition-opacity",children:[p.jsx("img",{src:"/app-icon.png",alt:"Token Tracker",width:28,height:28,className:"rounded-md"}),p.jsx("span",{className:"text-base font-semibold text-oai-black dark:text-oai-white leading-tight",children:"Token Tracker"})]})}function sre({children:t,header:e,footer:n,className:r="",hideHeader:i=!1,hideFooter:a=!1,bare:s=!1}){return s?p.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${r}`,children:[p.jsx("main",{className:"flex-1 px-6 py-6",children:t}),!a&&n&&p.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 mt-auto transition-colors duration-200",children:n})]}):p.jsxs("div",{className:`min-h-screen bg-oai-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-sans flex flex-col transition-colors duration-200 ${r}`,children:[!i&&p.jsxs("header",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 flex items-center justify-between transition-colors duration-200",children:[p.jsx(are,{}),p.jsx("div",{className:"flex-1 flex justify-center",children:e})]}),p.jsx("main",{className:"flex-1 px-6 py-6",children:t}),!a&&n&&p.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 mt-auto transition-colors duration-200",children:n})]})}function ore(t){if(!t||typeof t!="object")return null;const e=t.user_metadata&&typeof t.user_metadata=="object"?t.user_metadata:{},n=t.profile&&typeof t.profile=="object"?t.profile:{},r=e.avatar_url||e.picture||n.avatar_url||t.avatar_url;return typeof r=="string"&&r.trim()?r.trim():null}function uR(t){const e=String(t||"").trim();if(!e)return"?";const n=e.split(/\s+/).filter(Boolean);return n.length>=2?(n[0][0]+n[n.length-1][0]).toUpperCase():e.slice(0,2).toUpperCase()}function yy({className:t,variant:e="header",collapsed:n=!1,onAfterAction:r}){lu();const i=e==="sidebar",{enabled:a,loading:s,signedIn:o,user:c,displayName:u}=ls(),{openLoginModal:f}=Cp(),h=tf(),m=x.useMemo(()=>ore(c),[c]);if(!a)return null;if(s)return p.jsx("div",{className:vt("h-9 w-9 shrink-0 rounded-full bg-oai-gray-200 dark:bg-oai-gray-800 animate-pulse",t),"aria-hidden":!0});if(!o)return i?p.jsxs("button",{type:"button",onClick:()=>{f(),r?.()},className:vt("flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px] font-medium text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 min-w-0",n?"h-8 w-8 justify-center px-0":"w-full",t),"aria-label":O("header.auth.sign_in_aria"),title:n?O("header.auth.sign_in_aria"):void 0,children:[p.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:p.jsx("img",{src:"/app-icon.png",alt:"",width:18,height:18,className:"h-[18px] w-[18px] rounded"})}),!n&&p.jsx("span",{className:"truncate flex-1 text-left",children:O("header.auth.sign_in_aria")})]}):p.jsx("button",{type:"button",onClick:f,className:vt("shrink-0 inline-flex h-9 items-center justify-center gap-1.5 rounded-full px-5 text-sm font-medium transition-colors duration-200 ease-out shadow-sm ring-1 ring-oai-gray-200 dark:ring-white/10 bg-oai-gray-900 text-white hover:bg-oai-gray-800 active:bg-oai-gray-950 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 dark:active:bg-oai-gray-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-oai-gray-950",t),"aria-label":O("header.auth.sign_in_aria"),children:O("header.auth.sign_in_aria")});const g=()=>{h("/settings"),r?.()};return p.jsx("div",{className:vt(i?"relative flex w-full shrink-0 items-center":"relative flex shrink-0 items-center",t),children:p.jsxs("button",{type:"button",onClick:g,className:vt(i?vt("flex w-full items-center gap-2 rounded-md px-2 py-1.5 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 transition-colors min-w-0",n&&"justify-center px-0 py-0 h-9 w-9"):"flex items-center gap-2 rounded-full pl-1 pr-2 py-1 border border-transparent hover:bg-oai-gray-100 dark:hover:bg-oai-gray-900/80 hover:border-oai-gray-200 dark:hover:border-oai-gray-800 transition-colors"),"aria-label":O("header.auth.open_settings"),title:i&&n?u:void 0,children:[i?p.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:m?p.jsx("img",{src:m,alt:"",width:20,height:20,className:"h-5 w-5 rounded-full object-cover ring-1 ring-oai-gray-300 dark:ring-oai-gray-700",referrerPolicy:"no-referrer"}):p.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-oai-brand-600 text-[9px] font-semibold text-white ring-1 ring-oai-brand-500/50",children:uR(u)})}):m?p.jsx("img",{src:m,alt:"",width:32,height:32,className:"h-8 w-8 rounded-full object-cover ring-1 ring-oai-gray-300 dark:ring-oai-gray-700 shrink-0",referrerPolicy:"no-referrer"}):p.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-oai-brand-600 text-xs font-semibold text-white ring-1 ring-oai-brand-500/50",children:uR(u)}),i?!n&&p.jsx("span",{className:"truncate text-[13px] font-medium text-oai-gray-900 dark:text-oai-gray-200 flex-1 text-left min-w-0",children:u}):p.jsx("span",{className:"hidden sm:inline truncate text-sm font-medium text-oai-gray-900 dark:text-oai-gray-200 max-w-[120px]",children:u})]})})}const D1="tt.sidebarCollapsed";function lre(){return[{id:"general",label:O("nav.group.general"),items:[{id:"usage",to:"/dashboard",icon:IW,label:O("nav.usage")},{id:"limits",to:"/limits",icon:WW,label:O("nav.limits")},{id:"leaderboard",to:"/leaderboard",icon:SG,label:O("nav.leaderboard")}]},{id:"tools",label:O("nav.group.tools"),items:[{id:"widgets",to:"/widgets",icon:JW,label:O("nav.widgets")},{id:"skills",to:"/skills",icon:fG,label:O("nav.skills")},{id:"ip-check",to:"/ip-check",icon:$W,label:O("nav.ip_check")}]},{id:"account",label:O("nav.group.account"),items:[{id:"settings",to:"/settings",icon:H3,label:O("nav.settings")}]}]}function cre(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(D1)==="1"}catch{return!1}}function ure(){const[t,e]=x.useState(cre),n=x.useCallback(()=>{e(r=>{const i=!r;try{typeof window<"u"&&window.localStorage.setItem(D1,i?"1":"0")}catch{}return i})},[]);return x.useEffect(()=>{if(typeof window>"u")return;const r=i=>{i.key===D1&&e(i.newValue==="1")};return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)},[]),{collapsed:t,toggle:n}}function dre(t,e){const n=t.replace(/\/+$/,"")||"/";return e==="/dashboard"?n==="/dashboard"||n==="/":e==="/leaderboard"?n==="/leaderboard"||n.startsWith("/leaderboard/"):n===e}function fre({label:t,collapsed:e,first:n}){return e?n?null:p.jsx("div",{className:"mx-2 my-2 h-px bg-oai-gray-200/70 dark:bg-oai-gray-800/70","aria-hidden":!0}):p.jsx("div",{className:vt("px-3 pb-1 text-[10px] uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-500",n?"pt-2":"pt-4"),children:t})}function hre({item:t,collapsed:e,active:n,onClick:r}){const i=t.icon;return p.jsxs(Ei,{to:t.to,onClick:r,title:e?t.label:void 0,"aria-current":n?"page":void 0,className:vt("flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px] no-underline transition-colors",e&&"justify-center px-0 py-2",n?"bg-oai-gray-200/70 text-oai-black font-medium dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/50 hover:text-oai-black dark:hover:bg-oai-gray-800/60 dark:hover:text-white"),children:[p.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:p.jsx(i,{className:"h-[15px] w-[15px]","aria-hidden":!0})}),!e&&p.jsx("span",{className:"truncate",children:t.label})]})}function pre({as:t="button",title:e,onClick:n,href:r,children:i,className:a,...s}){const o=vt("flex h-10 w-10 items-center justify-center rounded-lg text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",a);return t==="a"?p.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",title:e,"aria-label":e,className:o,...s,children:i}):p.jsx("button",{type:"button",title:e,"aria-label":e,onClick:n,className:o,...s,children:i})}function mre({repo:t="mm7894215/TokenTracker",glassChrome:e=!1}){const[n,r]=x.useState(null);return x.useEffect(()=>{if(typeof window>"u")return;const i=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;F5({prefersReducedMotion:i,screenshotCapture:!1})&&fetch(`https://api.github.com/repos/${t}`).then(a=>a.json()).then(a=>{a&&typeof a.stargazers_count=="number"&&r(a.stargazers_count)}).catch(()=>{})},[t]),p.jsxs("a",{href:`https://github.com/${t}`,target:"_blank",rel:"noopener noreferrer","aria-label":n!==null?`Star on GitHub (${n})`:"Star on GitHub",className:vt("inline-flex h-7 items-center gap-1.5 rounded-full px-2.5 text-xs font-medium transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"border border-gray-500/20 dark:border-gray-500/30 bg-gray-500/[0.04] dark:bg-gray-500/[0.06] backdrop-blur-[2px] text-oai-gray-700 dark:text-oai-gray-300 hover:bg-gray-500/10 dark:hover:bg-gray-500/12 hover:border-gray-500/30 dark:hover:border-gray-500/40 hover:text-oai-black dark:hover:text-white":"border border-oai-gray-200 dark:border-oai-gray-700 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white hover:border-oai-gray-300 dark:hover:border-oai-gray-600"),children:[p.jsx("svg",{height:"12",viewBox:"0 0 16 16",width:"12",className:"shrink-0 fill-current",children:p.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),p.jsx("span",{children:"Star"}),n!==null&&p.jsx("span",{className:"text-[10px] text-oai-gray-500 dark:text-oai-gray-500 tabular-nums",children:n})]})}const gre=[{value:"light",label:"Light",Icon:Nk},{value:"dark",label:"Dark",Icon:Pk},{value:"system",label:"System",Icon:Wy}];function yre({theme:t,resolvedTheme:e,onSetTheme:n,glassChrome:r=!1}){const[i,a]=x.useState(!1),s=x.useRef(null),o=e==="dark"?Pk:Nk;return x.useEffect(()=>{if(!i)return;const c=f=>{s.current&&!s.current.contains(f.target)&&a(!1)},u=f=>{f.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u)}},[i]),p.jsxs("div",{ref:s,className:"relative",children:[p.jsx("button",{type:"button","aria-label":"Theme","aria-expanded":i,"aria-haspopup":"menu",title:"Theme",onClick:()=>a(c=>!c),className:vt("inline-flex h-7 w-7 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",r?"border border-gray-500/20 dark:border-gray-500/30 bg-gray-500/[0.04] dark:bg-gray-500/[0.06] backdrop-blur-[2px] text-oai-gray-700 dark:text-oai-gray-300 hover:bg-gray-500/10 dark:hover:bg-gray-500/12 hover:border-gray-500/30 dark:hover:border-gray-500/40 hover:text-oai-black dark:hover:text-white":"border border-oai-gray-200 dark:border-oai-gray-700 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white hover:border-oai-gray-300 dark:hover:border-oai-gray-600"),children:p.jsx(o,{className:"h-3.5 w-3.5","aria-hidden":!0})}),i&&p.jsx("div",{role:"menu",className:"absolute bottom-full left-0 mb-2 z-50 min-w-[140px] py-1 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-lg",children:gre.map(({value:c,label:u,Icon:f})=>{const h=t===c;return p.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{n(c),a(!1)},className:vt("flex w-full items-center gap-2.5 px-3 py-1.5 text-[13px] transition-colors",h?"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:[p.jsx(f,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),p.jsx("span",{children:u})]},c)})})]})}function U5({collapsed:t,onToggleCollapsed:e,onItemClick:n,showCloseButton:r=!1,onClose:i,glassChrome:a=!1}){const o=Hi()?.pathname||"/",{theme:c,resolvedTheme:u,setTheme:f}=Op(),{resolvedLocale:h}=lu(),m=x.useMemo(()=>lre(),[h]);return p.jsxs(p.Fragment,{children:[p.jsx("div",{className:vt("px-2 pt-2 pb-2",t&&"flex justify-center"),children:r?p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("div",{className:"flex-1 min-w-0",children:p.jsx(yy,{variant:"sidebar",collapsed:t,onAfterAction:n})}),p.jsx("button",{type:"button",onClick:i,"aria-label":O("nav.close_menu"),title:O("nav.close_menu"),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-500 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-gray-900 dark:hover:text-oai-gray-200 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:p.jsx(Dk,{className:"h-4 w-4",strokeWidth:1.75,"aria-hidden":!0})})]}):p.jsx(yy,{variant:"sidebar",collapsed:t,onAfterAction:n})}),p.jsx("nav",{"aria-label":O("nav.nav_label"),className:"flex-1 px-2 pb-2 flex flex-col overflow-y-auto",children:m.map((g,v)=>p.jsxs("div",{className:"flex flex-col",children:[p.jsx(fre,{label:g.label,collapsed:t,first:v===0}),p.jsx("div",{className:"flex flex-col gap-0.5",children:g.items.map(w=>p.jsx(hre,{item:w,collapsed:t,active:dre(o,w.to),onClick:n},w.id))})]},g.id))}),p.jsxs("div",{className:vt("flex items-center px-2 py-3",t?"flex-col justify-center gap-2":"justify-between gap-2"),children:[p.jsx(yre,{theme:c,resolvedTheme:u,onSetTheme:f,glassChrome:a}),p.jsx("div",{className:"flex items-center gap-1.5",children:!t&&p.jsx(mre,{glassChrome:a})})]})]})}function vre({collapsed:t,onToggleCollapsed:e}){const n=x.useMemo(()=>typeof window>"u"?!1:Ja()||Tk(),[]);return p.jsx("aside",{"aria-label":O("nav.aside_label"),className:vt("hidden lg:flex flex-col shrink-0 h-full min-h-0 transition-[width] duration-200",t?"w-[72px]":"w-[220px]"),children:p.jsx(U5,{collapsed:t,onToggleCollapsed:e,glassChrome:n})})}function xre({open:t,onClose:e}){return x.useEffect(()=>{if(!t)return;const n=r=>{r.key==="Escape"&&e()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[t,e]),x.useEffect(()=>{if(!t)return;const n=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=n}},[t]),t?p.jsxs("div",{className:"lg:hidden fixed inset-0 z-[80] flex",children:[p.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:e,"aria-hidden":!0}),p.jsx("aside",{"aria-label":O("nav.aside_label"),className:"relative w-[260px] max-w-[80vw] flex flex-col bg-oai-white dark:bg-oai-gray-900 border-r border-oai-gray-200 dark:border-oai-gray-800 shadow-2xl",children:p.jsx(U5,{collapsed:!1,showCloseButton:!0,onClose:e,onItemClick:e})})]}):null}function bre({onOpenDrawer:t}){return p.jsxs("div",{className:"lg:hidden flex items-center justify-between gap-2 px-3 h-14 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[p.jsx(pre,{title:O("nav.menu"),onClick:t,children:p.jsx(aG,{className:"h-5 w-5","aria-hidden":!0})}),p.jsxs(Ei,{to:"/landing",className:"flex items-center gap-2 no-underline hover:opacity-80 transition-opacity","aria-label":"Token Tracker",children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white",children:"Token Tracker"})]}),p.jsx("div",{className:"w-10 shrink-0","aria-hidden":!0})]})}function _re({children:t}){const{collapsed:e,toggle:n}=ure(),[r,i]=x.useState(!1),a=x.useCallback(()=>i(!0),[]),s=x.useCallback(()=>i(!1),[]),o=x.useMemo(()=>typeof window>"u"?!1:Ja()||Tk(),[]);return p.jsxs("div",{className:vt("fixed inset-0 flex flex-col text-oai-black dark:text-oai-white font-sans overflow-hidden",o?"bg-transparent":"bg-oai-gray-100 dark:bg-oai-gray-950"),children:[o&&p.jsx("div",{className:"h-7 shrink-0",style:{WebkitAppRegion:"drag"},"aria-hidden":!0}),p.jsxs("div",{className:"flex-1 min-h-0 flex",children:[p.jsx(vre,{collapsed:e,onToggleCollapsed:n}),p.jsx(xre,{open:r,onClose:s}),p.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-2 lg:pl-0 lg:pr-3 lg:pb-3 flex flex-col",children:p.jsxs("div",{className:vt("flex-1 min-h-0 flex flex-col bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",o?"tt-native-main-card":"rounded-2xl",!o&&"shadow-sm"),children:[p.jsx(bre,{onOpenDrawer:a}),p.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:t})]})})]})]})}function wre({children:t,variant:e="info",size:n="md",className:r=""}){const i="inline-flex items-center font-medium",a={success:"bg-oai-brand-100 dark:bg-oai-brand-900/30 text-oai-brand-700 dark:text-oai-brand-400 rounded-full",warning:"bg-oai-amber-50 dark:bg-oai-amber-900/30 text-oai-amber-dark dark:text-oai-amber-400 rounded-full",error:"bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded-full",info:"bg-oai-gray-100 dark:bg-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-300 rounded-full",secondary:"bg-oai-gray-100 dark:bg-oai-gray-800 text-oai-gray-500 dark:text-oai-gray-300 rounded-md"},s={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm"},o=`${i} ${a[e]} ${s[n]} ${r}`.trim();return p.jsx("span",{className:o,children:t})}const j5=x.createContext(void 0);function Gl(t){const e=x.useContext(j5);if(t===!1&&e===void 0)throw new Error(Wi(27));return e}const Sre={...hu,...df},B5=x.forwardRef(function(e,n){const{render:r,className:i,forceRender:a=!1,...s}=e,{store:o}=Gl(),c=o.useState("open"),u=o.useState("nested"),f=o.useState("mounted"),h=o.useState("transitionStatus"),m=x.useMemo(()=>({open:c,transitionStatus:h}),[c,h]);return Xr("div",e,{state:m,ref:[o.context.backdropRef,n],stateAttributesMapping:Sre,props:[{role:"presentation",hidden:!f,style:{userSelect:"none",WebkitUserSelect:"none"}},s],enabled:a||!u})}),kre=x.forwardRef(function(e,n){const{render:r,className:i,disabled:a=!1,nativeButton:s=!0,...o}=e,{store:c}=Gl(),u=c.useState("open");function f(v){u&&c.setOpen(!1,Mn(Mee,v.nativeEvent))}const{getButtonProps:h,buttonRef:m}=nv({disabled:a,native:s}),g=x.useMemo(()=>({disabled:a}),[a]);return Xr("button",e,{state:g,ref:[n,m],props:[{onClick:f},o,h]})}),Ere=x.forwardRef(function(e,n){const{render:r,className:i,id:a,...s}=e,{store:o}=Gl(),c=cv(a);return o.useSyncedValueWithCleanup("descriptionElementId",c),Xr("p",e,{ref:n,props:[{id:c},s]})});let Mre=(function(t){return t.nestedDialogs="--nested-dialogs",t})({}),Tre=(function(t){return t[t.open=Qa.open]="open",t[t.closed=Qa.closed]="closed",t[t.startingStyle=Qa.startingStyle]="startingStyle",t[t.endingStyle=Qa.endingStyle]="endingStyle",t.nested="data-nested",t.nestedDialogOpen="data-nested-dialog-open",t})({});const z5=x.createContext(void 0);function V5(){const t=x.useContext(z5);if(t===void 0)throw new Error(Wi(26));return t}const Cre={...hu,...df,nestedDialogOpen(t){return t?{[Tre.nestedDialogOpen]:""}:null}},H5=x.forwardRef(function(e,n){const{className:r,finalFocus:i,initialFocus:a,render:s,...o}=e,{store:c}=Gl(),u=c.useState("descriptionElementId"),f=c.useState("disablePointerDismissal"),h=c.useState("floatingRootContext"),m=c.useState("popupProps"),g=c.useState("modal"),v=c.useState("mounted"),w=c.useState("nested"),b=c.useState("nestedOpenDialogCount"),_=c.useState("open"),E=c.useState("openMethod"),M=c.useState("titleElementId"),T=c.useState("transitionStatus"),P=c.useState("role");V5(),ff({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});function A(L){return L==="touch"?c.context.popupRef.current:!0}const R=a===void 0?A:a,k=b>0,N=x.useMemo(()=>({open:_,nested:w,transitionStatus:T,nestedDialogOpen:k}),[_,w,T,k]),B=Xr("div",e,{state:N,props:[m,{"aria-labelledby":M??void 0,"aria-describedby":u??void 0,role:P,tabIndex:-1,hidden:!v,onKeyDown(L){OE.has(L.key)&&L.stopPropagation()},style:{[Mre.nestedDialogs]:b}},o],ref:[n,c.context.popupRef,c.useStateSetter("popupElement")],stateAttributesMapping:Cre});return p.jsx(ME,{context:h,openInteractionType:E,disabled:!v,closeOnFocusOut:!f,initialFocus:R,returnFocus:i,modal:g!==!1,restoreFocus:"popup",children:B})}),W5=x.forwardRef(function(e,n){const{keepMounted:r=!1,...i}=e,{store:a}=Gl(),s=a.useState("mounted"),o=a.useState("modal"),c=a.useState("open");return s||r?p.jsx(z5.Provider,{value:r,children:p.jsxs(kE,{ref:n,...i,children:[s&&o===!0&&p.jsx(IE,{ref:a.context.internalBackdropRef,inert:DE(!c)}),e.children]})}):null});function Are(t){const{store:e,parentContext:n,actionsRef:r}=t,i=e.useState("open"),a=e.useState("disablePointerDismissal"),s=e.useState("modal"),o=e.useState("popupElement"),{openMethod:c,triggerProps:u,reset:f}=NE(i);a5(e);const{forceUnmount:h}=s5(i,e,()=>{f()}),m=Bt(B=>{const L=Mn(B);return L.preventUnmountOnClose=()=>{e.set("preventUnmountingOnClose",!0)},L}),g=x.useCallback(()=>{e.setOpen(!1,m(G4))},[e,m]);x.useImperativeHandle(r,()=>({unmount:h,close:g}),[h,g]);const v=u5({popupStore:e,onOpenChange:e.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[w,b]=x.useState(0),_=w===0,E=f5(v),M=CE(v,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:s==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(B){if("button"in B&&B.button!==0||"touches"in B&&B.touches.length!==1)return!1;const L=Fi(B);if(_&&!a){const z=L;return s&&(e.context.internalBackdropRef.current||e.context.backdropRef.current)?e.context.internalBackdropRef.current===z||e.context.backdropRef.current===z||On(z,o)&&!z?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:_});LE(i&&s===!0,o);const{getReferenceProps:T,getFloatingProps:P,getTriggerProps:A}=ov([E,M]);e.useContextCallback("onNestedDialogOpen",B=>{b(B+1)}),e.useContextCallback("onNestedDialogClose",()=>{b(0)}),x.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(w),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,w]);const R=x.useMemo(()=>T(u),[T,u]),k=x.useMemo(()=>A(u),[A,u]),N=x.useMemo(()=>P(),[P]);e.useSyncedValues({openMethod:c,activeTriggerProps:R,inactiveTriggerProps:k,popupProps:N,floatingRootContext:v,nestedOpenDialogCount:w})}const Pre={...l5,modal:Pt(t=>t.modal),nested:Pt(t=>t.nested),nestedOpenDialogCount:Pt(t=>t.nestedOpenDialogCount),disablePointerDismissal:Pt(t=>t.disablePointerDismissal),openMethod:Pt(t=>t.openMethod),descriptionElementId:Pt(t=>t.descriptionElementId),titleElementId:Pt(t=>t.titleElementId),viewportElement:Pt(t=>t.viewportElement),role:Pt(t=>t.role)};class Rre extends gE{constructor(e){super(Nre(e),{popupRef:x.createRef(),backdropRef:x.createRef(),internalBackdropRef:x.createRef(),triggerElements:new sv,onOpenChange:void 0,onOpenChangeComplete:void 0},Pre)}setOpen=(e,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!e&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,n),n.isCanceled)return;const r={open:e,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",r);const i={open:e},a=n.trigger?.id??null;(a||e)&&(i.activeTriggerId=a,i.activeTriggerElement=n.trigger??null),this.update(i)}}function Nre(t={}){return{...o5(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...t}}function G5(t){const{children:e,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:s=!1,modal:o=!0,actionsRef:c,handle:u,triggerId:f,defaultTriggerId:h=null}=t,m=Gl(!0),g=!!m,v=Vi(()=>u?.store??new Rre({open:n??r,activeTriggerId:f!==void 0?f:h,modal:o,disablePointerDismissal:s,nested:g})).current;v.useControlledProp("open",n,r),v.useControlledProp("activeTriggerId",f,h),v.useSyncedValues({disablePointerDismissal:s,nested:g,modal:o}),v.useContextCallback("onOpenChange",i),v.useContextCallback("onOpenChangeComplete",a);const w=v.useState("payload");Are({store:v,actionsRef:c,parentContext:m?.store.context});const b=x.useMemo(()=>({store:v}),[v]);return p.jsx(j5.Provider,{value:b,children:typeof e=="function"?e({payload:w}):e})}let dR=(function(t){return t[t.open=Qa.open]="open",t[t.closed=Qa.closed]="closed",t[t.startingStyle=Qa.startingStyle]="startingStyle",t[t.endingStyle=Qa.endingStyle]="endingStyle",t.nested="data-nested",t.nestedDialogOpen="data-nested-dialog-open",t})({});const Dre={...hu,...df,nested(t){return t?{[dR.nested]:""}:null},nestedDialogOpen(t){return t?{[dR.nestedDialogOpen]:""}:null}},$5=x.forwardRef(function(e,n){const{className:r,render:i,children:a,...s}=e,o=V5(),{store:c}=Gl(),u=c.useState("open"),f=c.useState("nested"),h=c.useState("transitionStatus"),m=c.useState("nestedOpenDialogCount"),g=c.useState("mounted"),v=m>0,w=x.useMemo(()=>({open:u,nested:f,transitionStatus:h,nestedDialogOpen:v}),[u,f,h,v]);return Xr("div",e,{enabled:o||g,state:w,ref:[n,c.useStateSetter("viewportElement")],stateAttributesMapping:Dre,props:[{role:"presentation",hidden:!g,children:a},s]})}),Y5=x.forwardRef(function(e,n){const{render:r,className:i,id:a,...s}=e,{store:o}=Gl(),c=cv(a);return o.useSyncedValueWithCleanup("titleElementId",c),Xr("h2",e,{ref:n,props:[{id:c},s]})});function Lre({open:t,title:e,description:n,confirmLabel:r,cancelLabel:i,destructive:a=!1,busy:s=!1,onConfirm:o,onCancel:c}){return p.jsx(G5,{open:t,onOpenChange:u=>{!u&&!s&&c?.()},children:p.jsxs(W5,{children:[p.jsx(B5,{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-[2px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),p.jsx($5,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:p.jsxs(H5,{className:"relative w-full max-w-md rounded-2xl bg-white p-6 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] ring-1 ring-oai-gray-200 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.96] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0 dark:bg-oai-gray-950 dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] dark:ring-oai-gray-800",children:[p.jsx(Y5,{className:"text-base font-semibold text-oai-black dark:text-white",children:e}),n?p.jsx(Ere,{className:"mt-2 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:n}):null,p.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[p.jsx(Ui,{type:"button",variant:"secondary",size:"sm",disabled:s,onClick:()=>c?.(),children:i}),p.jsx(Ui,{type:"button",size:"sm",disabled:s,onClick:()=>o?.(),className:vt(a&&"!bg-red-600 hover:!bg-red-700 focus-visible:!outline-red-600 dark:!bg-red-600 dark:hover:!bg-red-500"),children:r})]})]})})]})})}function q5({value:t,onChange:e,placeholder:n,disabled:r=!1,type:i="text",label:a,error:s,className:o="",...c}){const m=`w-full bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md text-oai-black dark:text-oai-white placeholder-oai-gray-400 dark:placeholder-oai-gray-500 transition-all duration-200 focus:outline-none focus:border-oai-brand dark:focus:border-oai-brand focus:ring-1 focus:ring-oai-brand/30 ${r?"bg-oai-gray-50 dark:bg-oai-gray-800 text-oai-gray-400 dark:text-oai-gray-400 cursor-not-allowed":""} ${s?"border-oai-error focus:border-oai-error focus:ring-oai-error/30":""} h-10 px-3 text-sm ${o}`;return p.jsxs("div",{className:"w-full",children:[a&&p.jsx("label",{className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5 transition-colors duration-200",children:a}),p.jsx("input",{type:i,value:t,onChange:e,placeholder:n,disabled:r,className:m,...c}),s&&p.jsx("p",{className:"mt-1.5 text-sm text-oai-error",children:s})]})}var Ire={};function Ore(t,e){return t==="."?{width:"0.34ch",justifyContent:"center",marginInline:"-0.04ch"}:t===","?{width:"0.08ch",justifyContent:"center",marginInline:"-0.30ch"}:{width:"0.72ch",justifyContent:"flex-start",paddingLeft:"0.04ch",height:e}}function Fre({mv:t,digit:e,height:n}){const r=IO(t,i=>{const a=(i%10+10)%10,s=(10+e-a)%10;let o=s*n;return s>5&&(o-=10*n),o});return p.jsx(Qn.span,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",y:r},children:e})}function Ure(t){const e=Math.round(t),n=1e-9*Math.max(1,Math.abs(t));return Math.abs(t-e)<n?e:t}function jre(t,e){const n=t/e;return Math.floor(Ure(n))}function Bre(t){const e=String(t??""),n=Array.from(e),r=n.indexOf(".");let i=n.filter((o,c)=>/\d/.test(o)&&(r===-1||c<r)).length,a=0,s=!1;return n.map(o=>{if(!/\d/.test(o))return o==="."&&(s=!0),o;if(!s){const c=10**Math.max(i-1,0);return i-=1,c}return a+=1,10**-a})}function zre({place:t,value:e,height:n,digitStyle:r,shouldReduceMotion:i}){if(typeof t!="number"){const c=Ore(t,n);return p.jsx("span",{"data-counter-token":"static",className:"relative inline-flex items-center justify-center",style:{height:n,...c,...r},children:t})}const a=jre(e,t),s=oE(0),o=OK(s,{stiffness:220,damping:26,mass:.8});return x.useEffect(()=>{s.set(a)},[s,a]),i?p.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex items-center justify-center overflow-hidden",style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...r},children:Math.abs(a)%10}):p.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex overflow-hidden",style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...r},children:Array.from({length:10},(c,u)=>p.jsx(Fre,{mv:o,digit:u,height:n},u))})}function Vre({value:t,displayValue:e,fontSize:n=72,padding:r=0,places:i,gap:a=6,borderRadius:s=4,horizontalPadding:o=0,textColor:c="inherit",fontWeight:u="inherit",containerStyle:f,counterStyle:h,digitStyle:m,gradientHeight:g=14,gradientFrom:v="rgba(255,255,255,0.95)",gradientTo:w="rgba(255,255,255,0)",topGradientStyle:b,bottomGradientStyle:_}){const E=String(e??t??""),M=x.useMemo(()=>Array.isArray(i)&&i.length?i:Bre(E),[i,E]),T=typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent||"")||typeof process<"u"&&Ire?.VITEST==="true",P=cu()||T,A=Number.isFinite(Number(t))?Math.abs(Number(t)):0,R=n+r;return P?p.jsx("span",{"data-counter-root":"true",style:{display:"inline-flex",alignItems:"center",color:c,fontSize:n,fontWeight:u,lineHeight:1,...f,...h},children:E}):p.jsxs("span",{"data-counter-root":"true",style:{position:"relative",display:"inline-block",...f},children:[p.jsx("span",{style:{fontSize:n,display:"flex",gap:a,overflow:"hidden",borderRadius:s,paddingLeft:o,paddingRight:o,lineHeight:1,color:c,fontWeight:u,...h},children:M.map((k,N)=>p.jsx(zre,{place:k,value:A,height:R,digitStyle:m,shouldReduceMotion:P},`${String(k)}-${N}`))}),p.jsxs("span",{style:{pointerEvents:"none",position:"absolute",inset:0,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[p.jsx("span",{style:b??{height:g,background:`linear-gradient(to bottom, ${v}, ${w})`}}),p.jsx("span",{style:_??{height:g,background:`linear-gradient(to top, ${v}, ${w})`}})]})]})}function Hre(t){if(!Number.isFinite(t))return O("shared.placeholder.short");const e=Uy(t.toFixed(2),{decimals:2});return e==="-"?O("shared.placeholder.short"):e}function fR(t){return!Number.isFinite(t)||t<=0?null:t<.01?"<$0.01":Uy(t.toFixed(2),{decimals:2})}function hR(t){const e=Number(t);return!Number.isFinite(e)||e<=0?null:Ma(e,{decimals:1})}const Wre=ot.memo(function({isOpen:e,onClose:n,fleetData:r=[]}){const i=x.useMemo(()=>(Array.isArray(r)?r:[]).map(s=>{const o=ti(s?.usd)??0,c=ti(s?.usage)??0,u=Array.isArray(s?.models)?s.models:[];return{label:s?.label?String(s.label):"",usdValue:o,usdLabel:fR(o),tokensLabel:hR(c),models:u.map(f=>{const h=ti(f?.usage)??0,m=ti(f?.cost)??0;return{id:f?.id?String(f.id):"",name:f?.name?String(f.name):"",tokensLabel:hR(h),costLabel:fR(m),sortCost:m}}).filter(f=>f.costLabel||f.tokensLabel).sort((f,h)=>h.sortCost-f.sortCost)}}).filter(s=>s.usdValue>0||s.models.length>0).sort((s,o)=>o.usdValue-s.usdValue),[r]),a=x.useMemo(()=>{const s=i.reduce((o,c)=>o+c.usdValue,0);return Hre(s)},[i]);return p.jsx(G5,{open:e,onOpenChange:s=>{s||n?.()},children:p.jsxs(W5,{children:[p.jsx(B5,{className:"cost-modal-backdrop","data-cost-analysis-backdrop":"true"}),p.jsx($5,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:p.jsxs(H5,{className:"cost-modal-popup relative w-full max-w-[460px] max-h-[calc(100vh-2rem)] flex flex-col rounded-2xl bg-white dark:bg-oai-gray-950 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 overflow-hidden",children:[p.jsx(Y5,{render:p.jsx("h2",{className:"sr-only"}),children:O("dashboard.cost_breakdown.title")}),p.jsx(kre,{type:"button",className:"absolute top-3 right-3 flex h-9 w-9 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-100 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/50 transition-colors z-10","aria-label":O("dashboard.cost_breakdown.close"),children:p.jsx(Dk,{size:16,strokeWidth:2,"aria-hidden":!0})}),p.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto oai-scrollbar",children:p.jsxs("div",{className:"px-3 py-6",children:[p.jsx("p",{className:"text-label uppercase tracking-[0.12em] text-oai-gray-500 dark:text-oai-gray-400 mb-2",children:O("dashboard.cost_breakdown.total_label")}),p.jsx("p",{className:"font-bold text-oai-brand tabular-nums tracking-tight leading-none mb-6",style:{fontSize:"clamp(24px, 6.5vw, 32px)"},children:a}),i.length===0?p.jsx("p",{className:"text-body-sm text-oai-gray-500 dark:text-oai-gray-400",children:"No spend recorded."}):p.jsxs("div",{role:"table","aria-label":O("dashboard.cost_breakdown.title"),children:[p.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-2 mb-2 border-b border-oai-gray-200 dark:border-oai-gray-800 text-label uppercase text-oai-gray-500 dark:text-oai-gray-400",children:[p.jsx("span",{role:"columnheader",children:"Model"}),p.jsx("span",{role:"columnheader",children:"Cost"})]}),i.map((s,o)=>{const c=`fleet-${o}`;return p.jsxs("div",{role:"rowgroup","aria-labelledby":c,className:o>0?"mt-5":"mt-2",children:[p.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-2",children:[p.jsx("span",{id:c,role:"rowheader",className:"flex-1 min-w-0 text-body-sm font-semibold text-oai-black dark:text-oai-white truncate leading-none",children:s.label}),p.jsx("span",{role:"cell",className:"shrink-0 text-body-sm font-semibold text-oai-black dark:text-oai-white tabular-nums leading-none",children:s.usdLabel||"—"})]}),s.models.map((u,f)=>p.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-[5px]",children:[p.jsx("span",{role:"cell",className:"flex-1 min-w-0 text-caption text-oai-gray-500 dark:text-oai-gray-400 truncate leading-none",title:u.name,children:u.name}),p.jsx("span",{role:"cell",className:"shrink-0 text-caption text-oai-gray-700 dark:text-oai-gray-300 tabular-nums leading-none",children:u.costLabel||""})]},u.id||`${u.name}-${f}`))]},`${s.label}-${o}`)})]})]})})]})})]})})});function Gre({projectEntries:t=[],projectLimit:e=3,onProjectLimitChange:n,copy:r,hasDetailsActual:i,dailyEmptyPrefix:a,installSyncCmd:s,dailyEmptySuffix:o,detailsColumns:c,ariaSortFor:u,toggleSort:f,sortIconFor:h,pagedDetails:m,dailyBreakdownRows:g=[],dailyBreakdownColumns:v=[],dailyBreakdownAriaSortFor:w,dailyBreakdownSortIconFor:b,dailyBreakdownDateKey:_="day",detailsDateKey:E,renderDetailDate:M,renderDailyBreakdownDate:T,renderDetailCell:P,DETAILS_PAGED_PERIODS:A,period:R,detailsPageCount:k,detailsPage:N,setDetailsPage:B}){const[L,z]=x.useState("daily");return p.jsxs(pu,{children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[p.jsxs("div",{role:"tablist","aria-label":"Data view",className:"flex gap-1",children:[p.jsx("button",{role:"tab","aria-selected":L==="daily",type:"button",onClick:()=>z("daily"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${L==="daily"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:r("dashboard.daily.title")}),p.jsx("button",{role:"tab","aria-selected":L==="projects",type:"button",onClick:()=>z("projects"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${L==="projects"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:r("dashboard.projects.title")})]}),L==="projects"&&p.jsxs("select",{"aria-label":"Number of projects to display",value:e,onChange:I=>n?.(Number(I.target.value)),className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded px-2 py-1 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 focus:border-oai-brand dark:focus:border-oai-brand focus:outline-none transition-colors",children:[p.jsx("option",{value:3,children:r("dashboard.projects.limit_top_3")}),p.jsx("option",{value:6,children:r("dashboard.projects.limit_top_6")}),p.jsx("option",{value:10,children:r("dashboard.projects.limit_top_10")})]})]}),L==="projects"&&p.jsx("div",{className:"space-y-1",children:t.slice(0,e).map(I=>p.jsxs("a",{href:I?.project_ref||"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-2 rounded-lg hover:oai-bg-elevated transition-colors",children:[p.jsx("div",{className:"w-8 h-8 rounded-md oai-bg-elevated flex items-center justify-center oai-text-caption font-medium text-oai-gray-500 dark:text-oai-gray-300",children:(I?.project_key?.[0]||"?").toUpperCase()}),p.jsx("div",{className:"min-w-0 flex-1",children:p.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:I?.project_key||I?.project_ref?.split("/")?.pop()||"—"})}),p.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:(()=>{const V=I?.billable_total_tokens??I?.total_tokens,W=Number(V);return Number.isFinite(W)?W.toLocaleString():"—"})()})]},I?.project_key||I?.project_ref))}),L==="daily"&&p.jsxs("div",{children:[g?.length===0?p.jsxs("div",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300 mb-4",children:[a,p.jsx("code",{className:"mx-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 oai-bg-elevated px-1.5 py-0.5 font-mono oai-text-caption",children:s}),o]}):p.jsx("div",{className:"overflow-auto max-h-[384px] -mx-4 oai-scrollbar",children:p.jsxs("table",{className:"w-full border-collapse",children:[p.jsx("thead",{className:"sticky top-0 z-10",children:p.jsx("tr",{className:"border-b border-oai-gray-200 dark:border-oai-gray-700",children:v.map(I=>p.jsx("th",{"aria-sort":w?.(I.key)||"none",className:"text-left p-0 bg-white dark:bg-oai-gray-900",children:p.jsx("button",{type:"button",onClick:()=>f(I.key),className:"flex w-full items-center justify-start px-4 py-2 text-left oai-text-caption font-semibold text-oai-gray-600 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white transition-colors",children:p.jsxs("span",{className:"inline-flex items-center gap-1",children:[p.jsx("span",{children:I.label}),p.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-400",children:b?.(I.key)||""})]})})},I.key))})}),p.jsx("tbody",{children:g.map(I=>p.jsxs("tr",{className:`border-b border-oai-gray-100 dark:border-oai-gray-800 last:border-b-0 hover:bg-oai-gray-50/50 dark:hover:bg-oai-gray-800/50 transition-colors ${I.missing?"text-oai-gray-400 dark:text-oai-gray-400":I.future?"text-oai-gray-300 dark:text-oai-gray-600":"text-oai-black dark:text-oai-white"}`,children:[p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300",children:T?T(I):M(I)}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:P(I,"total_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:P(I,"input_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:P(I,"output_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:P(I,"cached_input_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:P(I,"reasoning_output_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:P(I,"conversation_count")})]},String(I?.[_]||I?.day||I?.hour||I?.month||"")))})]})}),L!=="daily"&&A.has(R)&&k>1?p.jsxs("div",{className:"mt-3 flex items-center justify-between oai-text-caption",children:[p.jsx("button",{type:"button",onClick:()=>B(I=>Math.max(0,I-1)),disabled:N===0,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("details.pagination.prev")}),p.jsxs("span",{className:"oai-text-muted",children:[N+1," / ",k]}),p.jsx("button",{type:"button",onClick:()=>B(I=>Math.min(k-1,I+1)),disabled:N+1>=k,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("details.pagination.next")})]}):null]})]})}function k0(t){return typeof t!="string"?"":t.trim()}function pR(t){const e=k0(t);return e?e.split(/[_\-\s]+/).filter(Boolean).map(n=>n.slice(0,1).toUpperCase()+n.slice(1).toLowerCase()).join(" "):""}function $re(t){if(!Array.isArray(t))return[];const e=new Map;for(const n of t){if(!n||typeof n!="object")continue;const r=k0(n.tool),i=k0(n.planType)||k0(n.plan_type);if(!r||!i)continue;const a=pR(r)||r,s=pR(i)||i;e.set(`${r.toLowerCase()}::${i.toLowerCase()}`,{tool:a,plan:s})}return Array.from(e.values())}function Yre({period:t="month",rankLabel:e,streakDays:n,subscriptions:r=[],periodConversations:i,rolling:a,topModels:s=[],className:o=""}){const c=O("shared.placeholder.short"),u=O("shared.unit.percent"),f=e??O("identity_card.rank_placeholder"),h=Number.isFinite(Number(n))?Number(n):0,m=h?O("identity_card.streak_value",{days:h}):O("identity_card.rank_placeholder"),g=$re(r),v={thousandSuffix:O("shared.unit.thousand_abbrev"),millionSuffix:O("shared.unit.million_abbrev"),billionSuffix:O("shared.unit.billion_abbrev")},w=E=>{if(E==null)return c;const M=Ma(E,v);return M==="-"?c:M},b=(()=>{switch(t){case"day":return O("stats.period.today");case"week":return O("stats.period.week");case"month":return O("stats.period.month");case"total":return O("stats.period.all");default:return O("stats.period.convs")}})(),_=s.slice(0,3);return p.jsxs(pu,{className:`h-full ${o}`,children:[p.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(a?.last_7d?.totals?.billable_total_tokens)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"7d"})]}),p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(a?.last_30d?.totals?.billable_total_tokens)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"30d"})]}),p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(a?.last_30d?.avg_per_active_day)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"avg"})]}),p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(i)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:b})]})]}),_.length>0&&p.jsx("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800",children:_.map((E,M)=>{const T=E?.name?String(E.name):c,P=E?.percent?String(E.percent):"",A=M===_.length-1,R=M+1;return p.jsxs("div",{className:`flex items-center py-2 ${A?"":"border-b border-oai-gray-50 dark:border-oai-gray-800"}`,children:[p.jsx("span",{className:"w-5 h-5 flex items-center justify-center rounded-full bg-oai-gray-100 dark:bg-oai-gray-800 text-[10px] font-semibold text-oai-gray-500 dark:text-oai-gray-300 flex-shrink-0",children:R}),p.jsx("span",{className:"flex-1 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate px-2.5",title:T,children:T}),p.jsxs("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums flex-shrink-0",children:[P,u]})]},E.id||T)})}),g.length>0&&p.jsx("div",{className:"mt-3 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800 flex flex-wrap gap-1.5",children:g.map((E,M)=>p.jsxs(wre,{variant:"secondary",size:"sm",children:[E.tool," ",E.plan]},`${E.tool}:${E.plan}:${M}`))}),p.jsxs("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800 flex items-center justify-between text-xs text-oai-gray-400 dark:text-oai-gray-400",children:[p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("span",{children:O("identity_card.rank_label")}),p.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:f})]}),p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("span",{children:O("identity_card.streak_label")}),p.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:m})]})]})]})}const X5=x.createContext(void 0);function jp(t){const e=x.useContext(X5);if(e===void 0&&!t)throw new Error(Wi(47));return e}function qre(){return{...o5(),disabled:!1,modal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}const Xre={...l5,disabled:Pt(t=>t.disabled),instantType:Pt(t=>t.instantType),openMethod:Pt(t=>t.openMethod),openChangeReason:Pt(t=>t.openChangeReason),modal:Pt(t=>t.modal),stickIfOpen:Pt(t=>t.stickIfOpen),titleElementId:Pt(t=>t.titleElementId),descriptionElementId:Pt(t=>t.descriptionElementId),openOnHover:Pt(t=>t.openOnHover),closeDelay:Pt(t=>t.closeDelay),hasViewport:Pt(t=>t.hasViewport)};class jE extends gE{constructor(e){const n={...qre(),...e};n.open&&e?.mounted===void 0&&(n.mounted=!0),super(n,{popupRef:x.createRef(),backdropRef:x.createRef(),internalBackdropRef:x.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:x.createRef(),beforeContentFocusGuardRef:x.createRef(),stickIfOpenTimeout:new Il,triggerElements:new sv},Xre)}setOpen=(e,n)=>{const r=n.reason===aa,i=n.reason===Rl&&n.event.detail===0,a=!e&&(n.reason===W4||n.reason==null);if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},this.context.onOpenChange?.(e,n),n.isCanceled)return;const s={open:e,nativeEvent:n.event,reason:n.reason,nested:this.state.nested,triggerElement:n.trigger};this.state.floatingRootContext.context.events?.emit("openchange",s);const c=()=>{const u={open:e,openChangeReason:n.reason},f=n.trigger?.id??null;(f||e)&&(u.activeTriggerId=f,u.activeTriggerElement=n.trigger??null),this.update(u)};r?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(WJ,()=>{this.set("stickIfOpen",!1)}),gi.flushSync(c)):c(),i||a?this.set("instantType",i?"click":"dismiss"):n.reason===eu?this.set("instantType","focus"):this.set("instantType",void 0)};static useStore(e,n){const r=Vi(()=>new jE(n)).current,i=e??r;return yE(r.disposeEffect),i}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()}function mR({props:t}){const{children:e,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:s=!1,handle:o,triggerId:c,defaultTriggerId:u=null}=t,f=jE.useStore(o?.store,{open:n??r,modal:s,activeTriggerId:c!==void 0?c:u});f.useControlledProp("open",n,r),f.useControlledProp("activeTriggerId",c,u);const h=f.useState("open"),m=f.useState("positionerElement"),g=f.useState("payload"),v=f.useState("openChangeReason");f.useContextCallback("onOpenChange",i),f.useContextCallback("onOpenChangeComplete",a);const{openMethod:w,triggerProps:b,reset:_}=NE(h);a5(f);const{forceUnmount:E}=s5(h,f,()=>{f.update({stickIfOpen:!0,openChangeReason:null}),_()});LE(h&&s===!0&&v!==aa&&w!=="touch",m),x.useEffect(()=>{h||f.context.stickIfOpenTimeout.clear()},[f,h]);const M=x.useCallback(W=>{const X=Mn(W);return X.preventUnmountOnClose=()=>{f.set("preventUnmountingOnClose",!0)},X},[f]),T=x.useCallback(()=>{f.setOpen(!1,M(G4))},[f,M]);x.useImperativeHandle(t.actionsRef,()=>({unmount:E,close:T}),[E,T]);const P=u5({popupStore:f,onOpenChange:f.setOpen}),A=CE(P,{outsidePressEvent:{mouse:s==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),R=f5(P),{getReferenceProps:k,getFloatingProps:N,getTriggerProps:B}=ov([A,R]),L=x.useMemo(()=>k(b),[k,b]),z=x.useMemo(()=>B(b),[B,b]),I=x.useMemo(()=>N(),[N]);f.useSyncedValues({modal:s,openMethod:w,activeTriggerProps:L,inactiveTriggerProps:z,popupProps:I,floatingRootContext:P,nested:Hl()!=null});const V=x.useMemo(()=>({store:f}),[f]);return p.jsx(X5.Provider,{value:V,children:typeof e=="function"?e({payload:g}):e})}function K5(t){return jp(!0)?p.jsx(mR,{props:t}):p.jsx(Eee,{children:p.jsx(mR,{props:t})})}const Kre=300,Z5=x.forwardRef(function(e,n){const{render:r,className:i,disabled:a=!1,nativeButton:s=!0,handle:o,payload:c,openOnHover:u=!1,delay:f=Kre,closeDelay:h=0,id:m,...g}=e,v=jp(!0),w=o?.store??v?.store;if(!w)throw new Error(Wi(74));const b=cv(m),_=w.useState("isTriggerActive",b),E=w.useState("floatingRootContext"),M=w.useState("isOpenedByTrigger",b),T=x.useRef(null),{registerTrigger:P,isMountedByThisTrigger:A}=Rte(b,T,w,{payload:c,disabled:a,openOnHover:u,closeDelay:h}),R=w.useState("openChangeReason"),k=w.useState("stickIfOpen"),N=w.useState("openMethod"),B=Bte(E,{enabled:E!=null&&u&&(N!=="touch"||R!==Rl),mouseOnly:!0,move:!1,handleClose:qte(),restMs:f,delay:{close:h},triggerElementRef:T,isActiveTrigger:_}),L=X4(E,{enabled:E!=null,stickIfOpen:k}),z=ov([L]),I=w.useState("triggerProps",A),V=x.useMemo(()=>({disabled:a,open:M}),[a,M]),{getButtonProps:W,buttonRef:X}=nv({disabled:a,native:s}),J=x.useMemo(()=>({open(te){return te&&R===Rl?w5.open(te):_5.open(te)}}),[R]),F=Xr("button",e,{state:V,ref:[X,n,P,T],props:[z.getReferenceProps(),B,I,{[h4]:"",id:b},g,W],stateAttributesMapping:J}),G=x.useRef(null),Y=Bt(te=>{gi.flushSync(()=>{w.setOpen(!1,Mn(eu,te.nativeEvent,te.currentTarget))}),vee(G.current)?.focus()}),H=Bt(te=>{const re=w.select("positionerElement");if(re&&Pd(te,re))w.context.beforeContentFocusGuardRef.current?.focus();else{gi.flushSync(()=>{w.setOpen(!1,Mn(eu,te.nativeEvent,te.currentTarget))});let ue=yee(w.context.triggerFocusTargetRef.current||T.current);for(;ue!==null&&On(re,ue);){const ce=ue;if(ue=wE(ue),ue===ce)break}ue?.focus()}});return _?p.jsxs(x.Fragment,{children:[p.jsx(Gd,{ref:G,onFocus:Y}),p.jsx(x.Fragment,{children:F},b),p.jsx(Gd,{ref:w.context.triggerFocusTargetRef,onFocus:H})]}):p.jsx(x.Fragment,{children:F},b)}),J5=x.createContext(void 0);function Zre(){const t=x.useContext(J5);if(t===void 0)throw new Error(Wi(45));return t}const Q5=x.forwardRef(function(e,n){const{keepMounted:r=!1,...i}=e,{store:a}=jp();return a.useState("mounted")||r?p.jsx(J5.Provider,{value:r,children:p.jsx(kE,{ref:n,...i,renderGuards:!1})}):null}),eF=x.createContext(void 0);function Jre(){const t=x.useContext(eF);if(!t)throw new Error(Wi(46));return t}const tF=x.forwardRef(function(e,n){const{render:r,className:i,anchor:a,positionMethod:s="absolute",side:o="bottom",align:c="center",sideOffset:u=0,alignOffset:f=0,collisionBoundary:h="clipping-ancestors",collisionPadding:m=5,arrowPadding:g=5,sticky:v=!1,disableAnchorTracking:w=!1,collisionAvoidance:b=YJ,..._}=e,{store:E}=jp(),M=Zre(),T=See(),P=E.useState("floatingRootContext"),A=E.useState("mounted"),R=E.useState("open"),k=E.useState("openChangeReason"),N=E.useState("activeTriggerElement"),B=E.useState("modal"),L=E.useState("positionerElement"),z=E.useState("instantType"),I=E.useState("transitionStatus"),V=E.useState("hasViewport"),W=x.useRef(null),X=i5(L,!1,!1),J=E5({anchor:a,floatingRootContext:P,positionMethod:s,mounted:A,side:o,sideOffset:u,align:c,alignOffset:f,arrowPadding:g,collisionBoundary:h,collisionPadding:m,sticky:v,disableAnchorTracking:w,keepMounted:M,nodeId:T,collisionAvoidance:b,adaptiveOrigin:V?Bne:void 0}),F=x.useMemo(()=>{const ue={};return R||(ue.pointerEvents="none"),{role:"presentation",hidden:!A,style:{...J.positionerStyles,...ue}}},[R,A,J.positionerStyles]),G=x.useMemo(()=>({props:F,...J}),[F,J]),Y=P?.select("domReferenceElement");Yt(()=>{const ue=Y,ce=W.current;if(ue&&(W.current=ue),ce&&ue&&ue!==ce){E.set("instantType",void 0);const ee=new AbortController;return X(()=>{E.set("instantType","trigger-change")},ee.signal),()=>{ee.abort()}}},[Y,X,E]);const H=x.useMemo(()=>({open:R,side:G.side,align:G.align,anchorHidden:G.anchorHidden,instant:z}),[R,G.side,G.align,G.anchorHidden,z]),te=x.useCallback(ue=>{E.set("positionerElement",ue)},[E]),re=Xr("div",e,{state:H,props:[G.props,FE(I),_],ref:[n,te],stateAttributesMapping:hu});return p.jsxs(eF.Provider,{value:G,children:[A&&B===!0&&k!==aa&&p.jsx(IE,{ref:E.context.internalBackdropRef,inert:DE(!R),cutout:N}),p.jsx(kee,{id:T,children:re})]})}),Qre={...hu,...df},nF=x.forwardRef(function(e,n){const{className:r,render:i,initialFocus:a,finalFocus:s,...o}=e,{store:c}=jp(),u=Jre(),f=C5()!=null,h=c.useState("open"),m=c.useState("openMethod"),g=c.useState("instantType"),v=c.useState("transitionStatus"),w=c.useState("popupProps"),b=c.useState("titleElementId"),_=c.useState("descriptionElementId"),E=c.useState("modal"),M=c.useState("mounted"),T=c.useState("openChangeReason"),P=c.useState("activeTriggerElement"),A=c.useState("floatingRootContext");ff({open:h,ref:c.context.popupRef,onComplete(){h&&c.context.onOpenChangeComplete?.(!0)}});const R=c.useState("disabled"),k=c.useState("openOnHover"),N=c.useState("closeDelay");Fte(A,{enabled:k&&!R,closeDelay:N});function B(W){return W==="touch"?c.context.popupRef.current:!0}const L=a===void 0?B:a,z=x.useMemo(()=>({open:h,side:u.side,align:u.align,instant:g,transitionStatus:v}),[h,u.side,u.align,g,v]),I=x.useCallback(W=>{c.set("popupElement",W)},[c]),V=Xr("div",e,{state:z,ref:[n,c.context.popupRef,I],props:[w,{"aria-labelledby":b,"aria-describedby":_,onKeyDown(W){f&&OE.has(W.key)&&W.stopPropagation()}},FE(v),o],stateAttributesMapping:Qre});return p.jsx(ME,{context:A,openInteractionType:m,modal:E==="trap-focus",disabled:!M||T===aa,initialFocus:L,returnFocus:s,restoreFocus:"popup",previousFocusableElement:Ar(P)?P:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:V})});function eie(t,e,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:t,timeZoneName:n}).format(e).split(/\s/g).slice(2).join(" ")}const tie={},Ah={};function Dc(t,e){try{const r=(tie[t]||=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"longOffset"}).format)(e).split("GMT")[1];return r in Ah?Ah[r]:gR(r,r.split(":"))}catch{if(t in Ah)return Ah[t];const n=t?.match(nie);return n?gR(t,n.slice(1)):NaN}}const nie=/([+-]\d\d):?(\d\d)?/;function gR(t,e){const n=+(e[0]||0),r=+(e[1]||0),i=+(e[2]||0)/60;return Ah[t]=n*60+r>0?n*60+r+i:n*60-r-i}class Rs extends Date{constructor(...e){super(),e.length>1&&typeof e[e.length-1]=="string"&&(this.timeZone=e.pop()),this.internal=new Date,isNaN(Dc(this.timeZone,this))?this.setTime(NaN):e.length?typeof e[0]=="number"&&(e.length===1||e.length===2&&typeof e[1]!="number")?this.setTime(e[0]):typeof e[0]=="string"?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),rF(this),L1(this)):this.setTime(Date.now())}static tz(e,...n){return n.length?new Rs(...n,e):new Rs(Date.now(),e)}withTimeZone(e){return new Rs(+this,e)}getTimezoneOffset(){const e=-Dc(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),L1(this),+this}[Symbol.for("constructDateFrom")](e){return new Rs(+new Date(e),this.timeZone)}}const yR=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(t=>{if(!yR.test(t))return;const e=t.replace(yR,"$1UTC");Rs.prototype[e]&&(t.startsWith("get")?Rs.prototype[t]=function(){return this.internal[e]()}:(Rs.prototype[t]=function(){return Date.prototype[e].apply(this.internal,arguments),rie(this),+this},Rs.prototype[e]=function(){return Date.prototype[e].apply(this,arguments),L1(this),+this}))});function L1(t){t.internal.setTime(+t),t.internal.setUTCSeconds(t.internal.getUTCSeconds()-Math.round(-Dc(t.timeZone,t)*60))}function rie(t){Date.prototype.setFullYear.call(t,t.internal.getUTCFullYear(),t.internal.getUTCMonth(),t.internal.getUTCDate()),Date.prototype.setHours.call(t,t.internal.getUTCHours(),t.internal.getUTCMinutes(),t.internal.getUTCSeconds(),t.internal.getUTCMilliseconds()),rF(t)}function rF(t){const e=Dc(t.timeZone,t),n=e>0?Math.floor(e):Math.ceil(e),r=new Date(+t);r.setUTCHours(r.getUTCHours()-1);const i=-new Date(+t).getTimezoneOffset(),a=-new Date(+r).getTimezoneOffset(),s=i-a,o=Date.prototype.getHours.apply(t)!==t.internal.getUTCHours();s&&o&&t.internal.setUTCMinutes(t.internal.getUTCMinutes()+s);const c=i-n;c&&Date.prototype.setUTCMinutes.call(t,Date.prototype.getUTCMinutes.call(t)+c);const u=new Date(+t);u.setUTCSeconds(0);const f=i>0?u.getSeconds():(u.getSeconds()-60)%60,h=Math.round(-(Dc(t.timeZone,t)*60))%60;(h||f)&&(t.internal.setUTCSeconds(t.internal.getUTCSeconds()+h),Date.prototype.setUTCSeconds.call(t,Date.prototype.getUTCSeconds.call(t)+h+f));const m=Dc(t.timeZone,t),g=m>0?Math.floor(m):Math.ceil(m),w=-new Date(+t).getTimezoneOffset()-g,b=g!==n,_=w-c;if(b&&_){Date.prototype.setUTCMinutes.call(t,Date.prototype.getUTCMinutes.call(t)+_);const E=Dc(t.timeZone,t),M=E>0?Math.floor(E):Math.ceil(E),T=g-M;T&&(t.internal.setUTCMinutes(t.internal.getUTCMinutes()+T),Date.prototype.setUTCMinutes.call(t,Date.prototype.getUTCMinutes.call(t)+T))}}class mi extends Rs{static tz(e,...n){return n.length?new mi(...n,e):new mi(Date.now(),e)}toISOString(){const[e,n,r]=this.tzComponents(),i=`${e}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+i}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[e,n,r,i]=this.internal.toUTCString().split(" ");return`${e?.slice(0,-1)} ${r} ${n} ${i}`}toTimeString(){const e=this.internal.toUTCString().split(" ")[4],[n,r,i]=this.tzComponents();return`${e} GMT${n}${r}${i} (${eie(this.timeZone,this)})`}toLocaleString(e,n){return Date.prototype.toLocaleString.call(this,e,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleDateString(e,n){return Date.prototype.toLocaleDateString.call(this,e,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleTimeString(e,n){return Date.prototype.toLocaleTimeString.call(this,e,{...n,timeZone:n?.timeZone||this.timeZone})}tzComponents(){const e=this.getTimezoneOffset(),n=e>0?"-":"+",r=String(Math.floor(Math.abs(e)/60)).padStart(2,"0"),i=String(Math.abs(e)%60).padStart(2,"0");return[n,r,i]}withTimeZone(e){return new mi(+this,e)}[Symbol.for("constructDateFrom")](e){return new mi(+new Date(e),this.timeZone)}}const iF=6048e5,iie=864e5,vR=Symbol.for("constructDateFrom");function Dr(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&vR in t?t[vR](e):t instanceof Date?new t.constructor(e):new Date(e)}function Jn(t,e){return Dr(e||t,t)}function aF(t,e,n){const r=Jn(t,n?.in);return isNaN(e)?Dr(t,NaN):(e&&r.setDate(r.getDate()+e),r)}function sF(t,e,n){const r=Jn(t,n?.in);if(isNaN(e))return Dr(t,NaN);if(!e)return r;const i=r.getDate(),a=Dr(t,r.getTime());a.setMonth(r.getMonth()+e+1,0);const s=a.getDate();return i>=s?a:(r.setFullYear(a.getFullYear(),a.getMonth(),i),r)}let aie={};function Bp(){return aie}function Yd(t,e){const n=Bp(),r=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Jn(t,e?.in),a=i.getDay(),s=(a<r?7:0)+a-r;return i.setDate(i.getDate()-s),i.setHours(0,0,0,0),i}function cp(t,e){return Yd(t,{...e,weekStartsOn:1})}function oF(t,e){const n=Jn(t,e?.in),r=n.getFullYear(),i=Dr(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const a=cp(i),s=Dr(n,0);s.setFullYear(r,0,4),s.setHours(0,0,0,0);const o=cp(s);return n.getTime()>=a.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function xR(t){const e=Jn(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function hf(t,...e){const n=Dr.bind(null,e.find(r=>typeof r=="object"));return e.map(n)}function up(t,e){const n=Jn(t,e?.in);return n.setHours(0,0,0,0),n}function BE(t,e,n){const[r,i]=hf(n?.in,t,e),a=up(r),s=up(i),o=+a-xR(a),c=+s-xR(s);return Math.round((o-c)/iie)}function sie(t,e){const n=oF(t,e),r=Dr(t,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),cp(r)}function oie(t,e,n){return aF(t,e*7,n)}function lie(t,e,n){return sF(t,e*12,n)}function cie(t,e){let n,r=e?.in;return t.forEach(i=>{!r&&typeof i=="object"&&(r=Dr.bind(null,i));const a=Jn(i,r);(!n||n<a||isNaN(+a))&&(n=a)}),Dr(r,n||NaN)}function uie(t,e){let n,r=e?.in;return t.forEach(i=>{!r&&typeof i=="object"&&(r=Dr.bind(null,i));const a=Jn(i,r);(!n||n>a||isNaN(+a))&&(n=a)}),Dr(r,n||NaN)}function die(t,e,n){const[r,i]=hf(n?.in,t,e);return+up(r)==+up(i)}function lF(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function fie(t){return!(!lF(t)&&typeof t!="number"||isNaN(+Jn(t)))}function cF(t,e,n){const[r,i]=hf(n?.in,t,e),a=r.getFullYear()-i.getFullYear(),s=r.getMonth()-i.getMonth();return a*12+s}function hie(t,e){const n=Jn(t,e?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function uF(t,e){const[n,r]=hf(t,e.start,e.end);return{start:n,end:r}}function pie(t,e){const{start:n,end:r}=uF(e?.in,t);let i=+n>+r;const a=i?+n:+r,s=i?r:n;s.setHours(0,0,0,0),s.setDate(1);let o=1;const c=[];for(;+s<=a;)c.push(Dr(n,s)),s.setMonth(s.getMonth()+o);return i?c.reverse():c}function mie(t,e){const n=Jn(t,e?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function gie(t,e){const n=Jn(t,e?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function dF(t,e){const n=Jn(t,e?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function yie(t,e){const{start:n,end:r}=uF(e?.in,t);let i=+n>+r;const a=i?+n:+r,s=i?r:n;s.setHours(0,0,0,0),s.setMonth(0,1);let o=1;const c=[];for(;+s<=a;)c.push(Dr(n,s)),s.setFullYear(s.getFullYear()+o);return i?c.reverse():c}function fF(t,e){const n=Bp(),r=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Jn(t,e?.in),a=i.getDay(),s=(a<r?-7:0)+6-(a-r);return i.setDate(i.getDate()+s),i.setHours(23,59,59,999),i}function vie(t,e){return fF(t,{...e,weekStartsOn:1})}const xie={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},bie=(t,e,n)=>{let r;const i=xie[t];return typeof i=="string"?r=i:e===1?r=i.one:r=i.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function m_(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const _ie={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},wie={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Sie={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},kie={date:m_({formats:_ie,defaultWidth:"full"}),time:m_({formats:wie,defaultWidth:"full"}),dateTime:m_({formats:Sie,defaultWidth:"full"})},Eie={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Mie=(t,e,n,r)=>Eie[t];function dh(t){return(e,n)=>{const r=n?.context?String(n.context):"standalone";let i;if(r==="formatting"&&t.formattingValues){const s=t.defaultFormattingWidth||t.defaultWidth,o=n?.width?String(n.width):s;i=t.formattingValues[o]||t.formattingValues[s]}else{const s=t.defaultWidth,o=n?.width?String(n.width):t.defaultWidth;i=t.values[o]||t.values[s]}const a=t.argumentCallback?t.argumentCallback(e):e;return i[a]}}const Tie={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Cie={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Aie={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Pie={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Rie={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Nie={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Die=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Lie={ordinalNumber:Die,era:dh({values:Tie,defaultWidth:"wide"}),quarter:dh({values:Cie,defaultWidth:"wide",argumentCallback:t=>t-1}),month:dh({values:Aie,defaultWidth:"wide"}),day:dh({values:Pie,defaultWidth:"wide"}),dayPeriod:dh({values:Rie,defaultWidth:"wide",formattingValues:Nie,defaultFormattingWidth:"wide"})};function fh(t){return(e,n={})=>{const r=n.width,i=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],a=e.match(i);if(!a)return null;const s=a[0],o=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(o)?Oie(o,h=>h.test(s)):Iie(o,h=>h.test(s));let u;u=t.valueCallback?t.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const f=e.slice(s.length);return{value:u,rest:f}}}function Iie(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function Oie(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function Fie(t){return(e,n={})=>{const r=e.match(t.matchPattern);if(!r)return null;const i=r[0],a=e.match(t.parsePattern);if(!a)return null;let s=t.valueCallback?t.valueCallback(a[0]):a[0];s=n.valueCallback?n.valueCallback(s):s;const o=e.slice(i.length);return{value:s,rest:o}}}const Uie=/^(\d+)(th|st|nd|rd)?/i,jie=/\d+/i,Bie={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},zie={any:[/^b/i,/^(a|c)/i]},Vie={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Hie={any:[/1/i,/2/i,/3/i,/4/i]},Wie={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Gie={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},$ie={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Yie={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},qie={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Xie={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Kie={ordinalNumber:Fie({matchPattern:Uie,parsePattern:jie,valueCallback:t=>parseInt(t,10)}),era:fh({matchPatterns:Bie,defaultMatchWidth:"wide",parsePatterns:zie,defaultParseWidth:"any"}),quarter:fh({matchPatterns:Vie,defaultMatchWidth:"wide",parsePatterns:Hie,defaultParseWidth:"any",valueCallback:t=>t+1}),month:fh({matchPatterns:Wie,defaultMatchWidth:"wide",parsePatterns:Gie,defaultParseWidth:"any"}),day:fh({matchPatterns:$ie,defaultMatchWidth:"wide",parsePatterns:Yie,defaultParseWidth:"any"}),dayPeriod:fh({matchPatterns:qie,defaultMatchWidth:"any",parsePatterns:Xie,defaultParseWidth:"any"})},vd={code:"en-US",formatDistance:bie,formatLong:kie,formatRelative:Mie,localize:Lie,match:Kie,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Zie(t,e){const n=Jn(t,e?.in);return BE(n,dF(n))+1}function zE(t,e){const n=Jn(t,e?.in),r=+cp(n)-+sie(n);return Math.round(r/iF)+1}function hF(t,e){const n=Jn(t,e?.in),r=n.getFullYear(),i=Bp(),a=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,s=Dr(e?.in||t,0);s.setFullYear(r+1,0,a),s.setHours(0,0,0,0);const o=Yd(s,e),c=Dr(e?.in||t,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);const u=Yd(c,e);return+n>=+o?r+1:+n>=+u?r:r-1}function Jie(t,e){const n=Bp(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=hF(t,e),a=Dr(e?.in||t,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),Yd(a,e)}function VE(t,e){const n=Jn(t,e?.in),r=+Yd(n,e)-+Jie(n,e);return Math.round(r/iF)+1}function Xn(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const ol={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return Xn(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):Xn(n+1,2)},d(t,e){return Xn(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(t,e){return Xn(t.getHours()%12||12,e.length)},H(t,e){return Xn(t.getHours(),e.length)},m(t,e){return Xn(t.getMinutes(),e.length)},s(t,e){return Xn(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return Xn(i,e.length)}},Zu={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},bR={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const r=t.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return ol.y(t,e)},Y:function(t,e,n,r){const i=hF(t,r),a=i>0?i:1-i;if(e==="YY"){const s=a%100;return Xn(s,2)}return e==="Yo"?n.ordinalNumber(a,{unit:"year"}):Xn(a,e.length)},R:function(t,e){const n=oF(t);return Xn(n,e.length)},u:function(t,e){const n=t.getFullYear();return Xn(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return Xn(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return Xn(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return ol.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return Xn(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){const i=VE(t,r);return e==="wo"?n.ordinalNumber(i,{unit:"week"}):Xn(i,e.length)},I:function(t,e,n){const r=zE(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):Xn(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):ol.d(t,e)},D:function(t,e,n){const r=Zie(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):Xn(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){const i=t.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(a);case"ee":return Xn(a,2);case"eo":return n.ordinalNumber(a,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){const i=t.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(a);case"cc":return Xn(a,e.length);case"co":return n.ordinalNumber(a,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(t,e,n){const r=t.getDay(),i=r===0?7:r;switch(e){case"i":return String(i);case"ii":return Xn(i,e.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){const i=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(t,e,n){const r=t.getHours();let i;switch(r===12?i=Zu.noon:r===0?i=Zu.midnight:i=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(t,e,n){const r=t.getHours();let i;switch(r>=17?i=Zu.evening:r>=12?i=Zu.afternoon:r>=4?i=Zu.morning:i=Zu.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return ol.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):ol.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):Xn(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):Xn(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):ol.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):ol.s(t,e)},S:function(t,e){return ol.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return wR(r);case"XXXX":case"XX":return kc(r);default:return kc(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return wR(r);case"xxxx":case"xx":return kc(r);default:return kc(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+_R(r,":");default:return"GMT"+kc(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+_R(r,":");default:return"GMT"+kc(r,":")}},t:function(t,e,n){const r=Math.trunc(+t/1e3);return Xn(r,e.length)},T:function(t,e,n){return Xn(+t,e.length)}};function _R(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+e+Xn(a,2)}function wR(t,e){return t%60===0?(t>0?"-":"+")+Xn(Math.abs(t)/60,2):kc(t,e)}function kc(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=Xn(Math.trunc(r/60),2),a=Xn(r%60,2);return n+i+e+a}const SR=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},pF=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},Qie=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return SR(t,e);let a;switch(r){case"P":a=e.dateTime({width:"short"});break;case"PP":a=e.dateTime({width:"medium"});break;case"PPP":a=e.dateTime({width:"long"});break;default:a=e.dateTime({width:"full"});break}return a.replace("{{date}}",SR(r,e)).replace("{{time}}",pF(i,e))},eae={p:pF,P:Qie},tae=/^D+$/,nae=/^Y+$/,rae=["D","DD","YY","YYYY"];function iae(t){return tae.test(t)}function aae(t){return nae.test(t)}function sae(t,e,n){const r=oae(t,e,n);if(console.warn(r),rae.includes(t))throw new RangeError(r)}function oae(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const lae=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,cae=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,uae=/^'([^]*?)'?$/,dae=/''/g,fae=/[a-zA-Z]/;function Ns(t,e,n){const r=Bp(),i=n?.locale??r.locale??vd,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,s=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,o=Jn(t,n?.in);if(!fie(o))throw new RangeError("Invalid time value");let c=e.match(cae).map(f=>{const h=f[0];if(h==="p"||h==="P"){const m=eae[h];return m(f,i.formatLong)}return f}).join("").match(lae).map(f=>{if(f==="''")return{isToken:!1,value:"'"};const h=f[0];if(h==="'")return{isToken:!1,value:hae(f)};if(bR[h])return{isToken:!0,value:f};if(h.match(fae))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");return{isToken:!1,value:f}});i.localize.preprocessor&&(c=i.localize.preprocessor(o,c));const u={firstWeekContainsDate:a,weekStartsOn:s,locale:i};return c.map(f=>{if(!f.isToken)return f.value;const h=f.value;(!n?.useAdditionalWeekYearTokens&&aae(h)||!n?.useAdditionalDayOfYearTokens&&iae(h))&&sae(h,e,String(t));const m=bR[h[0]];return m(o,h,i.localize,u)}).join("")}function hae(t){const e=t.match(uae);return e?e[1].replace(dae,"'"):t}function pae(t,e){const n=Jn(t,e?.in),r=n.getFullYear(),i=n.getMonth(),a=Dr(n,0);return a.setFullYear(r,i+1,0),a.setHours(0,0,0,0),a.getDate()}function mae(t,e){return Jn(t,e?.in).getMonth()}function gae(t,e){return Jn(t,e?.in).getFullYear()}function yae(t,e){return+Jn(t)>+Jn(e)}function vae(t,e){return+Jn(t)<+Jn(e)}function xae(t,e,n){const[r,i]=hf(n?.in,t,e);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function bae(t,e,n){const[r,i]=hf(n?.in,t,e);return r.getFullYear()===i.getFullYear()}function _ae(t,e,n){const r=Jn(t,n?.in),i=r.getFullYear(),a=r.getDate(),s=Dr(t,0);s.setFullYear(i,e,15),s.setHours(0,0,0,0);const o=pae(s);return r.setMonth(e,Math.min(a,o)),r}function wae(t,e,n){const r=Jn(t,n?.in);return isNaN(+r)?Dr(t,NaN):(r.setFullYear(e),r)}const kR=5,Sae=4;function kae(t,e){const n=e.startOfMonth(t),r=n.getDay()>0?n.getDay():7,i=e.addDays(t,-r+1),a=e.addDays(i,kR*7-1);return e.getMonth(t)===e.getMonth(a)?kR:Sae}function mF(t,e){const n=e.startOfMonth(t),r=n.getDay();return r===1?n:r===0?e.addDays(n,-6):e.addDays(n,-1*(r-1))}function Eae(t,e){const n=mF(t,e),r=kae(t,e);return e.addDays(n,r*7-1)}const gF={...vd,labels:{labelDayButton:(t,e,n,r)=>{let i;r&&typeof r.format=="function"?i=r.format.bind(r):i=(s,o)=>Ns(s,o,{locale:vd,...n});let a=i(t,"PPPP");return e.today&&(a=`Today, ${a}`),e.selected&&(a=`${a}, selected`),a},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:t=>`Week ${t}`,labelYearDropdown:"Choose the Year",labelGrid:(t,e,n)=>{let r;return n&&typeof n.format=="function"?r=n.format.bind(n):r=(i,a)=>Ns(i,a,{locale:vd,...e}),r(t,"LLLL yyyy")},labelGridcell:(t,e,n,r)=>{let i;r&&typeof r.format=="function"?i=r.format.bind(r):i=(s,o)=>Ns(s,o,{locale:vd,...n});let a=i(t,"PPPP");return e?.today&&(a=`Today, ${a}`),a},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(t,e,n)=>{let r;return n&&typeof n.format=="function"?r=n.format.bind(n):r=(i,a)=>Ns(i,a,{locale:vd,...e}),r(t,"cccc")}}};class ua{constructor(e,n){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?mi.tz(this.options.timeZone):new this.Date,this.newDate=(r,i,a)=>this.overrides?.newDate?this.overrides.newDate(r,i,a):this.options.timeZone?new mi(r,i,a,this.options.timeZone):new Date(r,i,a),this.addDays=(r,i)=>this.overrides?.addDays?this.overrides.addDays(r,i):aF(r,i),this.addMonths=(r,i)=>this.overrides?.addMonths?this.overrides.addMonths(r,i):sF(r,i),this.addWeeks=(r,i)=>this.overrides?.addWeeks?this.overrides.addWeeks(r,i):oie(r,i),this.addYears=(r,i)=>this.overrides?.addYears?this.overrides.addYears(r,i):lie(r,i),this.differenceInCalendarDays=(r,i)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(r,i):BE(r,i),this.differenceInCalendarMonths=(r,i)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(r,i):cF(r,i),this.eachMonthOfInterval=r=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(r):pie(r),this.eachYearOfInterval=r=>{const i=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(r):yie(r),a=new Set(i.map(o=>this.getYear(o)));if(a.size===i.length)return i;const s=[];return a.forEach(o=>{s.push(new Date(o,0,1))}),s},this.endOfBroadcastWeek=r=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(r):Eae(r,this),this.endOfISOWeek=r=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(r):vie(r),this.endOfMonth=r=>this.overrides?.endOfMonth?this.overrides.endOfMonth(r):hie(r),this.endOfWeek=(r,i)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(r,i):fF(r,this.options),this.endOfYear=r=>this.overrides?.endOfYear?this.overrides.endOfYear(r):gie(r),this.format=(r,i,a)=>{const s=this.overrides?.format?this.overrides.format(r,i,this.options):Ns(r,i,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(s):s},this.getISOWeek=r=>this.overrides?.getISOWeek?this.overrides.getISOWeek(r):zE(r),this.getMonth=(r,i)=>this.overrides?.getMonth?this.overrides.getMonth(r,this.options):mae(r,this.options),this.getYear=(r,i)=>this.overrides?.getYear?this.overrides.getYear(r,this.options):gae(r,this.options),this.getWeek=(r,i)=>this.overrides?.getWeek?this.overrides.getWeek(r,this.options):VE(r,this.options),this.isAfter=(r,i)=>this.overrides?.isAfter?this.overrides.isAfter(r,i):yae(r,i),this.isBefore=(r,i)=>this.overrides?.isBefore?this.overrides.isBefore(r,i):vae(r,i),this.isDate=r=>this.overrides?.isDate?this.overrides.isDate(r):lF(r),this.isSameDay=(r,i)=>this.overrides?.isSameDay?this.overrides.isSameDay(r,i):die(r,i),this.isSameMonth=(r,i)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(r,i):xae(r,i),this.isSameYear=(r,i)=>this.overrides?.isSameYear?this.overrides.isSameYear(r,i):bae(r,i),this.max=r=>this.overrides?.max?this.overrides.max(r):cie(r),this.min=r=>this.overrides?.min?this.overrides.min(r):uie(r),this.setMonth=(r,i)=>this.overrides?.setMonth?this.overrides.setMonth(r,i):_ae(r,i),this.setYear=(r,i)=>this.overrides?.setYear?this.overrides.setYear(r,i):wae(r,i),this.startOfBroadcastWeek=(r,i)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(r,this):mF(r,this),this.startOfDay=r=>this.overrides?.startOfDay?this.overrides.startOfDay(r):up(r),this.startOfISOWeek=r=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(r):cp(r),this.startOfMonth=r=>this.overrides?.startOfMonth?this.overrides.startOfMonth(r):mie(r),this.startOfWeek=(r,i)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(r,this.options):Yd(r,this.options),this.startOfYear=r=>this.overrides?.startOfYear?this.overrides.startOfYear(r):dF(r),this.options={locale:gF,...e},this.overrides=n}getDigitMap(){const{numerals:e="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:e}),r={};for(let i=0;i<10;i++)r[i.toString()]=n.format(i);return r}replaceDigits(e){const n=this.getDigitMap();return e.replace(/\d/g,r=>n[r]||r)}formatNumber(e){return this.replaceDigits(e.toString())}getMonthYearOrder(){const e=this.options.locale?.code;return e&&ua.yearFirstLocales.has(e)?"year-first":"month-first"}formatMonthYear(e){const{locale:n,timeZone:r,numerals:i}=this.options,a=n?.code;if(a&&ua.yearFirstLocales.has(a))try{return new Intl.DateTimeFormat(a,{month:"long",year:"numeric",timeZone:r,numberingSystem:i}).format(e)}catch{}const s=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(e,s)}}ua.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const Qs=new ua;class yF{constructor(e,n,r=Qs){this.date=e,this.displayMonth=n,this.outside=!!(n&&!r.isSameMonth(e,n)),this.dateLib=r,this.isoDate=r.format(e,"yyyy-MM-dd"),this.displayMonthId=r.format(n,"yyyy-MM"),this.dateMonthId=r.format(e,"yyyy-MM")}isEqualTo(e){return this.dateLib.isSameDay(e.date,this.date)&&this.dateLib.isSameMonth(e.displayMonth,this.displayMonth)}}class Mae{constructor(e,n){this.date=e,this.weeks=n}}class Tae{constructor(e,n){this.days=n,this.weekNumber=e}}function Cae(t){return ot.createElement("button",{...t})}function Aae(t){return ot.createElement("span",{...t})}function Pae(t){const{size:e=24,orientation:n="left",className:r}=t;return ot.createElement("svg",{className:r,width:e,height:e,viewBox:"0 0 24 24"},n==="up"&&ot.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&ot.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&ot.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&ot.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function Rae(t){const{day:e,modifiers:n,...r}=t;return ot.createElement("td",{...r})}function Nae(t){const{day:e,modifiers:n,...r}=t,i=ot.useRef(null);return ot.useEffect(()=>{n.focused&&i.current?.focus()},[n.focused]),ot.createElement("button",{ref:i,...r})}var Zt;(function(t){t.Root="root",t.Chevron="chevron",t.Day="day",t.DayButton="day_button",t.CaptionLabel="caption_label",t.Dropdowns="dropdowns",t.Dropdown="dropdown",t.DropdownRoot="dropdown_root",t.Footer="footer",t.MonthGrid="month_grid",t.MonthCaption="month_caption",t.MonthsDropdown="months_dropdown",t.Month="month",t.Months="months",t.Nav="nav",t.NextMonthButton="button_next",t.PreviousMonthButton="button_previous",t.Week="week",t.Weeks="weeks",t.Weekday="weekday",t.Weekdays="weekdays",t.WeekNumber="week_number",t.WeekNumberHeader="week_number_header",t.YearsDropdown="years_dropdown"})(Zt||(Zt={}));var fr;(function(t){t.disabled="disabled",t.hidden="hidden",t.outside="outside",t.focused="focused",t.today="today"})(fr||(fr={}));var es;(function(t){t.range_end="range_end",t.range_middle="range_middle",t.range_start="range_start",t.selected="selected"})(es||(es={}));var na;(function(t){t.weeks_before_enter="weeks_before_enter",t.weeks_before_exit="weeks_before_exit",t.weeks_after_enter="weeks_after_enter",t.weeks_after_exit="weeks_after_exit",t.caption_after_enter="caption_after_enter",t.caption_after_exit="caption_after_exit",t.caption_before_enter="caption_before_enter",t.caption_before_exit="caption_before_exit"})(na||(na={}));function Dae(t){const{options:e,className:n,components:r,classNames:i,...a}=t,s=[i[Zt.Dropdown],n].join(" "),o=e?.find(({value:c})=>c===a.value);return ot.createElement("span",{"data-disabled":a.disabled,className:i[Zt.DropdownRoot]},ot.createElement(r.Select,{className:s,...a},e?.map(({value:c,label:u,disabled:f})=>ot.createElement(r.Option,{key:c,value:c,disabled:f},u))),ot.createElement("span",{className:i[Zt.CaptionLabel],"aria-hidden":!0},o?.label,ot.createElement(r.Chevron,{orientation:"down",size:18,className:i[Zt.Chevron]})))}function Lae(t){return ot.createElement("div",{...t})}function Iae(t){return ot.createElement("div",{...t})}function Oae(t){const{calendarMonth:e,displayIndex:n,...r}=t;return ot.createElement("div",{...r},t.children)}function Fae(t){const{calendarMonth:e,displayIndex:n,...r}=t;return ot.createElement("div",{...r})}function Uae(t){return ot.createElement("table",{...t})}function jae(t){return ot.createElement("div",{...t})}const vF=x.createContext(void 0);function zp(){const t=x.useContext(vF);if(t===void 0)throw new Error("useDayPicker() must be used within a custom component.");return t}function Bae(t){const{components:e}=zp();return ot.createElement(e.Dropdown,{...t})}function zae(t){const{onPreviousClick:e,onNextClick:n,previousMonth:r,nextMonth:i,...a}=t,{components:s,classNames:o,labels:{labelPrevious:c,labelNext:u}}=zp(),f=x.useCallback(m=>{i&&n?.(m)},[i,n]),h=x.useCallback(m=>{r&&e?.(m)},[r,e]);return ot.createElement("nav",{...a},ot.createElement(s.PreviousMonthButton,{type:"button",className:o[Zt.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":c(r),onClick:h},ot.createElement(s.Chevron,{disabled:r?void 0:!0,className:o[Zt.Chevron],orientation:"left"})),ot.createElement(s.NextMonthButton,{type:"button",className:o[Zt.NextMonthButton],tabIndex:i?void 0:-1,"aria-disabled":i?void 0:!0,"aria-label":u(i),onClick:f},ot.createElement(s.Chevron,{disabled:i?void 0:!0,orientation:"right",className:o[Zt.Chevron]})))}function Vae(t){const{components:e}=zp();return ot.createElement(e.Button,{...t})}function Hae(t){return ot.createElement("option",{...t})}function Wae(t){const{components:e}=zp();return ot.createElement(e.Button,{...t})}function Gae(t){const{rootRef:e,...n}=t;return ot.createElement("div",{...n,ref:e})}function $ae(t){return ot.createElement("select",{...t})}function Yae(t){const{week:e,...n}=t;return ot.createElement("tr",{...n})}function qae(t){return ot.createElement("th",{...t})}function Xae(t){return ot.createElement("thead",{"aria-hidden":!0},ot.createElement("tr",{...t}))}function Kae(t){const{week:e,...n}=t;return ot.createElement("th",{...n})}function Zae(t){return ot.createElement("th",{...t})}function Jae(t){return ot.createElement("tbody",{...t})}function Qae(t){const{components:e}=zp();return ot.createElement(e.Dropdown,{...t})}const ese=Object.freeze(Object.defineProperty({__proto__:null,Button:Cae,CaptionLabel:Aae,Chevron:Pae,Day:Rae,DayButton:Nae,Dropdown:Dae,DropdownNav:Lae,Footer:Iae,Month:Oae,MonthCaption:Fae,MonthGrid:Uae,Months:jae,MonthsDropdown:Bae,Nav:zae,NextMonthButton:Vae,Option:Hae,PreviousMonthButton:Wae,Root:Gae,Select:$ae,Week:Yae,WeekNumber:Kae,WeekNumberHeader:Zae,Weekday:qae,Weekdays:Xae,Weeks:Jae,YearsDropdown:Qae},Symbol.toStringTag,{value:"Module"}));function ko(t,e,n=!1,r=Qs){let{from:i,to:a}=t;const{differenceInCalendarDays:s,isSameDay:o}=r;return i&&a?(s(a,i)<0&&([i,a]=[a,i]),s(e,i)>=(n?1:0)&&s(a,e)>=(n?1:0)):!n&&a?o(a,e):!n&&i?o(i,e):!1}function HE(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function uv(t){return!!(t&&typeof t=="object"&&"from"in t)}function WE(t){return!!(t&&typeof t=="object"&&"after"in t)}function GE(t){return!!(t&&typeof t=="object"&&"before"in t)}function xF(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function bF(t,e){return Array.isArray(t)&&t.every(e.isDate)}function Eo(t,e,n=Qs){const r=Array.isArray(e)?e:[e],{isSameDay:i,differenceInCalendarDays:a,isAfter:s}=n;return r.some(o=>{if(typeof o=="boolean")return o;if(n.isDate(o))return i(t,o);if(bF(o,n))return o.some(c=>i(t,c));if(uv(o))return ko(o,t,!1,n);if(xF(o))return Array.isArray(o.dayOfWeek)?o.dayOfWeek.includes(t.getDay()):o.dayOfWeek===t.getDay();if(HE(o)){const c=a(o.before,t),u=a(o.after,t),f=c>0,h=u<0;return s(o.before,o.after)?h&&f:f||h}return WE(o)?a(t,o.after)>0:GE(o)?a(o.before,t)>0:typeof o=="function"?o(t):!1})}function tse(t,e,n,r,i){const{disabled:a,hidden:s,modifiers:o,showOutsideDays:c,broadcastCalendar:u,today:f=i.today()}=e,{isSameDay:h,isSameMonth:m,startOfMonth:g,isBefore:v,endOfMonth:w,isAfter:b}=i,_=n&&g(n),E=r&&w(r),M={[fr.focused]:[],[fr.outside]:[],[fr.disabled]:[],[fr.hidden]:[],[fr.today]:[]},T={};for(const P of t){const{date:A,displayMonth:R}=P,k=!!(R&&!m(A,R)),N=!!(_&&v(A,_)),B=!!(E&&b(A,E)),L=!!(a&&Eo(A,a,i)),z=!!(s&&Eo(A,s,i))||N||B||!u&&!c&&k||u&&c===!1&&k,I=h(A,f);k&&M.outside.push(P),L&&M.disabled.push(P),z&&M.hidden.push(P),I&&M.today.push(P),o&&Object.keys(o).forEach(V=>{const W=o?.[V];W&&Eo(A,W,i)&&(T[V]?T[V].push(P):T[V]=[P])})}return P=>{const A={[fr.focused]:!1,[fr.disabled]:!1,[fr.hidden]:!1,[fr.outside]:!1,[fr.today]:!1},R={};for(const k in M){const N=M[k];A[k]=N.some(B=>B===P)}for(const k in T)R[k]=T[k].some(N=>N===P);return{...A,...R}}}function nse(t,e,n={}){return Object.entries(t).filter(([,i])=>i===!0).reduce((i,[a])=>(n[a]?i.push(n[a]):e[fr[a]]?i.push(e[fr[a]]):e[es[a]]&&i.push(e[es[a]]),i),[e[Zt.Day]])}function rse(t){return{...ese,...t}}function ise(t){const e={"data-mode":t.mode??void 0,"data-required":"required"in t?t.required:void 0,"data-multiple-months":t.numberOfMonths&&t.numberOfMonths>1||void 0,"data-week-numbers":t.showWeekNumber||void 0,"data-broadcast-calendar":t.broadcastCalendar||void 0,"data-nav-layout":t.navLayout||void 0};return Object.entries(t).forEach(([n,r])=>{n.startsWith("data-")&&(e[n]=r)}),e}function ase(){const t={};for(const e in Zt)t[Zt[e]]=`rdp-${Zt[e]}`;for(const e in fr)t[fr[e]]=`rdp-${fr[e]}`;for(const e in es)t[es[e]]=`rdp-${es[e]}`;for(const e in na)t[na[e]]=`rdp-${na[e]}`;return t}function _F(t,e,n){return(n??new ua(e)).formatMonthYear(t)}const sse=_F;function ose(t,e,n){return(n??new ua(e)).format(t,"d")}function lse(t,e=Qs){return e.format(t,"LLLL")}function cse(t,e,n){return(n??new ua(e)).format(t,"cccccc")}function use(t,e=Qs){return t<10?e.formatNumber(`0${t.toLocaleString()}`):e.formatNumber(`${t.toLocaleString()}`)}function dse(){return""}function wF(t,e=Qs){return e.format(t,"yyyy")}const fse=wF,hse=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:_F,formatDay:ose,formatMonthCaption:sse,formatMonthDropdown:lse,formatWeekNumber:use,formatWeekNumberHeader:dse,formatWeekdayName:cse,formatYearCaption:fse,formatYearDropdown:wF},Symbol.toStringTag,{value:"Module"}));function pse(t){return t?.formatMonthCaption&&!t.formatCaption&&(t.formatCaption=t.formatMonthCaption),t?.formatYearCaption&&!t.formatYearDropdown&&(t.formatYearDropdown=t.formatYearCaption),{...hse,...t}}function $E(t,e,n,r){let i=(r??new ua(n)).format(t,"PPPP");return e.today&&(i=`Today, ${i}`),e.selected&&(i=`${i}, selected`),i}const mse=$E;function YE(t,e,n){return(n??new ua(e)).formatMonthYear(t)}const gse=YE;function SF(t,e,n,r){let i=(r??new ua(n)).format(t,"PPPP");return e?.today&&(i=`Today, ${i}`),i}function kF(t){return"Choose the Month"}function EF(){return""}const yse="Go to the Next Month";function MF(t,e){return yse}function TF(t){return"Go to the Previous Month"}function CF(t,e,n){return(n??new ua(e)).format(t,"cccc")}function AF(t,e){return`Week ${t}`}function PF(t){return"Week Number"}function RF(t){return"Choose the Year"}const vse=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:gse,labelDay:mse,labelDayButton:$E,labelGrid:YE,labelGridcell:SF,labelMonthDropdown:kF,labelNav:EF,labelNext:MF,labelPrevious:TF,labelWeekNumber:AF,labelWeekNumberHeader:PF,labelWeekday:CF,labelYearDropdown:RF},Symbol.toStringTag,{value:"Module"})),Wa=(t,e,n)=>e||(n?typeof n=="function"?n:(...r)=>n:t);function xse(t,e){const n=e.locale?.labels??{};return{...vse,...t??{},labelDayButton:Wa($E,t?.labelDayButton,n.labelDayButton),labelMonthDropdown:Wa(kF,t?.labelMonthDropdown,n.labelMonthDropdown),labelNext:Wa(MF,t?.labelNext,n.labelNext),labelPrevious:Wa(TF,t?.labelPrevious,n.labelPrevious),labelWeekNumber:Wa(AF,t?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:Wa(RF,t?.labelYearDropdown,n.labelYearDropdown),labelGrid:Wa(YE,t?.labelGrid,n.labelGrid),labelGridcell:Wa(SF,t?.labelGridcell,n.labelGridcell),labelNav:Wa(EF,t?.labelNav,n.labelNav),labelWeekNumberHeader:Wa(PF,t?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:Wa(CF,t?.labelWeekday,n.labelWeekday)}}function bse(t,e,n,r,i){const{startOfMonth:a,startOfYear:s,endOfYear:o,eachMonthOfInterval:c,getMonth:u}=i;return c({start:s(t),end:o(t)}).map(m=>{const g=r.formatMonthDropdown(m,i),v=u(m),w=e&&m<a(e)||n&&m>a(n)||!1;return{value:v,label:g,disabled:w}})}function _se(t,e={},n={}){let r={...e?.[Zt.Day]};return Object.entries(t).filter(([,i])=>i===!0).forEach(([i])=>{r={...r,...n?.[i]}}),r}function wse(t,e,n,r){const i=r??t.today(),a=n?t.startOfBroadcastWeek(i,t):e?t.startOfISOWeek(i):t.startOfWeek(i),s=[];for(let o=0;o<7;o++){const c=t.addDays(a,o);s.push(c)}return s}function Sse(t,e,n,r,i=!1){if(!t||!e)return;const{startOfYear:a,endOfYear:s,eachYearOfInterval:o,getYear:c}=r,u=a(t),f=s(e),h=o({start:u,end:f});return i&&h.reverse(),h.map(m=>{const g=n.formatYearDropdown(m,r);return{value:c(m),label:g,disabled:!1}})}function kse(t,e={}){const{weekStartsOn:n,locale:r}=e,i=n??r?.options?.weekStartsOn??0,a=o=>{const c=typeof o=="number"||typeof o=="string"?new Date(o):o;return new mi(c.getFullYear(),c.getMonth(),c.getDate(),12,0,0,t)},s=o=>{const c=a(o);return new Date(c.getFullYear(),c.getMonth(),c.getDate(),0,0,0,0)};return{today:()=>a(mi.tz(t)),newDate:(o,c,u)=>new mi(o,c,u,12,0,0,t),startOfDay:o=>a(o),startOfWeek:(o,c)=>{const u=a(o),f=c?.weekStartsOn??i,h=(u.getDay()-f+7)%7;return u.setDate(u.getDate()-h),u},startOfISOWeek:o=>{const c=a(o),u=(c.getDay()-1+7)%7;return c.setDate(c.getDate()-u),c},startOfMonth:o=>{const c=a(o);return c.setDate(1),c},startOfYear:o=>{const c=a(o);return c.setMonth(0,1),c},endOfWeek:(o,c)=>{const u=a(o),m=(((c?.weekStartsOn??i)+6)%7-u.getDay()+7)%7;return u.setDate(u.getDate()+m),u},endOfISOWeek:o=>{const c=a(o),u=(7-c.getDay())%7;return c.setDate(c.getDate()+u),c},endOfMonth:o=>{const c=a(o);return c.setMonth(c.getMonth()+1,0),c},endOfYear:o=>{const c=a(o);return c.setMonth(11,31),c},eachMonthOfInterval:o=>{const c=a(o.start),u=a(o.end),f=[],h=new mi(c.getFullYear(),c.getMonth(),1,12,0,0,t),m=u.getFullYear()*12+u.getMonth();for(;h.getFullYear()*12+h.getMonth()<=m;)f.push(new mi(h,t)),h.setMonth(h.getMonth()+1,1);return f},addDays:(o,c)=>{const u=a(o);return u.setDate(u.getDate()+c),u},addWeeks:(o,c)=>{const u=a(o);return u.setDate(u.getDate()+c*7),u},addMonths:(o,c)=>{const u=a(o);return u.setMonth(u.getMonth()+c),u},addYears:(o,c)=>{const u=a(o);return u.setFullYear(u.getFullYear()+c),u},eachYearOfInterval:o=>{const c=a(o.start),u=a(o.end),f=[],h=new mi(c.getFullYear(),0,1,12,0,0,t);for(;h.getFullYear()<=u.getFullYear();)f.push(new mi(h,t)),h.setFullYear(h.getFullYear()+1,0,1);return f},getWeek:(o,c)=>{const u=s(o);return VE(u,{weekStartsOn:c?.weekStartsOn??i,firstWeekContainsDate:c?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1})},getISOWeek:o=>{const c=s(o);return zE(c)},differenceInCalendarDays:(o,c)=>{const u=s(o),f=s(c);return BE(u,f)},differenceInCalendarMonths:(o,c)=>{const u=s(o),f=s(c);return cF(u,f)}}}const Vp=t=>t instanceof HTMLElement?t:null,g_=t=>[...t.querySelectorAll("[data-animated-month]")??[]],Ese=t=>Vp(t.querySelector("[data-animated-month]")),y_=t=>Vp(t.querySelector("[data-animated-caption]")),v_=t=>Vp(t.querySelector("[data-animated-weeks]")),Mse=t=>Vp(t.querySelector("[data-animated-nav]")),Tse=t=>Vp(t.querySelector("[data-animated-weekdays]"));function Cse(t,e,{classNames:n,months:r,focused:i,dateLib:a}){const s=x.useRef(null),o=x.useRef(r),c=x.useRef(!1);x.useLayoutEffect(()=>{const u=o.current;if(o.current=r,!e||!t.current||!(t.current instanceof HTMLElement)||r.length===0||u.length===0||r.length!==u.length)return;const f=a.isSameMonth(r[0].date,u[0].date),h=a.isAfter(r[0].date,u[0].date),m=h?n[na.caption_after_enter]:n[na.caption_before_enter],g=h?n[na.weeks_after_enter]:n[na.weeks_before_enter],v=s.current,w=t.current.cloneNode(!0);if(w instanceof HTMLElement?(g_(w).forEach(M=>{if(!(M instanceof HTMLElement))return;const T=Ese(M);T&&M.contains(T)&&M.removeChild(T);const P=y_(M);P&&P.classList.remove(m);const A=v_(M);A&&A.classList.remove(g)}),s.current=w):s.current=null,c.current||f||i)return;const b=v instanceof HTMLElement?g_(v):[],_=g_(t.current);if(_?.every(E=>E instanceof HTMLElement)&&b&&b.every(E=>E instanceof HTMLElement)){c.current=!0,t.current.style.isolation="isolate";const E=Mse(t.current);E&&(E.style.zIndex="1"),_.forEach((M,T)=>{const P=b[T];if(!P)return;M.style.position="relative",M.style.overflow="hidden";const A=y_(M);A&&A.classList.add(m);const R=v_(M);R&&R.classList.add(g);const k=()=>{c.current=!1,t.current&&(t.current.style.isolation=""),E&&(E.style.zIndex=""),A&&A.classList.remove(m),R&&R.classList.remove(g),M.style.position="",M.style.overflow="",M.contains(P)&&M.removeChild(P)};P.style.pointerEvents="none",P.style.position="absolute",P.style.overflow="hidden",P.setAttribute("aria-hidden","true");const N=Tse(P);N&&(N.style.opacity="0");const B=y_(P);B&&(B.classList.add(h?n[na.caption_before_exit]:n[na.caption_after_exit]),B.addEventListener("animationend",k));const L=v_(P);L&&L.classList.add(h?n[na.weeks_before_exit]:n[na.weeks_after_exit]),M.insertBefore(P,M.firstChild)})}})}function Ase(t,e,n,r){const i=t[0],a=t[t.length-1],{ISOWeek:s,fixedWeeks:o,broadcastCalendar:c}=n??{},{addDays:u,differenceInCalendarDays:f,differenceInCalendarMonths:h,endOfBroadcastWeek:m,endOfISOWeek:g,endOfMonth:v,endOfWeek:w,isAfter:b,startOfBroadcastWeek:_,startOfISOWeek:E,startOfWeek:M}=r,T=c?_(i,r):s?E(i):M(i),P=c?m(a):s?g(v(a)):w(v(a)),A=e&&(c?m(e):s?g(e):w(e)),R=A&&b(P,A)?A:P,k=f(R,T),N=h(a,i)+1,B=[];for(let I=0;I<=k;I++){const V=u(T,I);B.push(V)}const z=(c?35:42)*N;if(o&&B.length<z){const I=z-B.length;for(let V=0;V<I;V++){const W=u(B[B.length-1],1);B.push(W)}}return B}function Pse(t){const e=[];return t.reduce((n,r)=>{const i=r.weeks.reduce((a,s)=>a.concat(s.days.slice()),e.slice());return n.concat(i.slice())},e.slice())}function Rse(t,e,n,r){const{numberOfMonths:i=1}=n,a=[];for(let s=0;s<i;s++){const o=r.addMonths(t,s);if(e&&o>e)break;a.push(o)}return a}function ER(t,e,n,r){const{month:i,defaultMonth:a,today:s=r.today(),numberOfMonths:o=1}=t;let c=i||a||s;const{differenceInCalendarMonths:u,addMonths:f,startOfMonth:h}=r;if(n&&u(n,c)<o-1){const m=-1*(o-1);c=f(n,m)}return e&&u(c,e)<0&&(c=e),h(c)}function Nse(t,e,n,r){const{addDays:i,endOfBroadcastWeek:a,endOfISOWeek:s,endOfMonth:o,endOfWeek:c,getISOWeek:u,getWeek:f,startOfBroadcastWeek:h,startOfISOWeek:m,startOfWeek:g}=r,v=t.reduce((w,b)=>{const _=n.broadcastCalendar?h(b,r):n.ISOWeek?m(b):g(b),E=n.broadcastCalendar?a(b):n.ISOWeek?s(o(b)):c(o(b)),M=e.filter(R=>R>=_&&R<=E),T=n.broadcastCalendar?35:42;if(n.fixedWeeks&&M.length<T){const R=e.filter(k=>{const N=T-M.length;return k>E&&k<=i(E,N)});M.push(...R)}const P=M.reduce((R,k)=>{const N=n.ISOWeek?u(k):f(k),B=R.find(z=>z.weekNumber===N),L=new yF(k,b,r);return B?B.days.push(L):R.push(new Tae(N,[L])),R},[]),A=new Mae(b,P);return w.push(A),w},[]);return n.reverseMonths?v.reverse():v}function Dse(t,e){let{startMonth:n,endMonth:r}=t;const{startOfYear:i,startOfDay:a,startOfMonth:s,endOfMonth:o,addYears:c,endOfYear:u,newDate:f,today:h}=e,{fromYear:m,toYear:g,fromMonth:v,toMonth:w}=t;!n&&v&&(n=v),!n&&m&&(n=e.newDate(m,0,1)),!r&&w&&(r=w),!r&&g&&(r=f(g,11,31));const b=t.captionLayout==="dropdown"||t.captionLayout==="dropdown-years";return n?n=s(n):m?n=f(m,0,1):!n&&b&&(n=i(c(t.today??h(),-100))),r?r=o(r):g?r=f(g,11,31):!r&&b&&(r=u(t.today??h())),[n&&a(n),r&&a(r)]}function Lse(t,e,n,r){if(n.disableNavigation)return;const{pagedNavigation:i,numberOfMonths:a=1}=n,{startOfMonth:s,addMonths:o,differenceInCalendarMonths:c}=r,u=i?a:1,f=s(t);if(!e)return o(f,u);if(!(c(e,t)<a))return o(f,u)}function Ise(t,e,n,r){if(n.disableNavigation)return;const{pagedNavigation:i,numberOfMonths:a}=n,{startOfMonth:s,addMonths:o,differenceInCalendarMonths:c}=r,u=i?a??1:1,f=s(t);if(!e)return o(f,-u);if(!(c(f,e)<=0))return o(f,-u)}function Ose(t){const e=[];return t.reduce((n,r)=>n.concat(r.weeks.slice()),e.slice())}function dv(t,e){const[n,r]=x.useState(t);return[e===void 0?n:e,r]}function Fse(t,e){const[n,r]=Dse(t,e),{startOfMonth:i,endOfMonth:a}=e,s=ER(t,n,r,e),[o,c]=dv(s,t.month?s:void 0);x.useEffect(()=>{const T=ER(t,n,r,e);c(T)},[t.timeZone]);const{months:u,weeks:f,days:h,previousMonth:m,nextMonth:g}=x.useMemo(()=>{const T=Rse(o,r,{numberOfMonths:t.numberOfMonths},e),P=Ase(T,t.endMonth?a(t.endMonth):void 0,{ISOWeek:t.ISOWeek,fixedWeeks:t.fixedWeeks,broadcastCalendar:t.broadcastCalendar},e),A=Nse(T,P,{broadcastCalendar:t.broadcastCalendar,fixedWeeks:t.fixedWeeks,ISOWeek:t.ISOWeek,reverseMonths:t.reverseMonths},e),R=Ose(A),k=Pse(A),N=Ise(o,n,t,e),B=Lse(o,r,t,e);return{months:A,weeks:R,days:k,previousMonth:N,nextMonth:B}},[e,o.getTime(),r?.getTime(),n?.getTime(),t.disableNavigation,t.broadcastCalendar,t.endMonth?.getTime(),t.fixedWeeks,t.ISOWeek,t.numberOfMonths,t.pagedNavigation,t.reverseMonths]),{disableNavigation:v,onMonthChange:w}=t,b=T=>f.some(P=>P.days.some(A=>A.isEqualTo(T))),_=T=>{if(v)return;let P=i(T);n&&P<i(n)&&(P=i(n)),r&&P>i(r)&&(P=i(r)),c(P),w?.(P)};return{months:u,weeks:f,days:h,navStart:n,navEnd:r,previousMonth:m,nextMonth:g,goToMonth:_,goToDay:T=>{b(T)||_(T.date)}}}var Es;(function(t){t[t.Today=0]="Today",t[t.Selected=1]="Selected",t[t.LastFocused=2]="LastFocused",t[t.FocusedModifier=3]="FocusedModifier"})(Es||(Es={}));function MR(t){return!t[fr.disabled]&&!t[fr.hidden]&&!t[fr.outside]}function Use(t,e,n,r){let i,a=-1;for(const s of t){const o=e(s);MR(o)&&(o[fr.focused]&&a<Es.FocusedModifier?(i=s,a=Es.FocusedModifier):r?.isEqualTo(s)&&a<Es.LastFocused?(i=s,a=Es.LastFocused):n(s.date)&&a<Es.Selected?(i=s,a=Es.Selected):o[fr.today]&&a<Es.Today&&(i=s,a=Es.Today))}return i||(i=t.find(s=>MR(e(s)))),i}function jse(t,e,n,r,i,a,s){const{ISOWeek:o,broadcastCalendar:c}=a,{addDays:u,addMonths:f,addWeeks:h,addYears:m,endOfBroadcastWeek:g,endOfISOWeek:v,endOfWeek:w,max:b,min:_,startOfBroadcastWeek:E,startOfISOWeek:M,startOfWeek:T}=s;let A={day:u,week:h,month:f,year:m,startOfWeek:R=>c?E(R,s):o?M(R):T(R),endOfWeek:R=>c?g(R):o?v(R):w(R)}[t](n,e==="after"?1:-1);return e==="before"&&r?A=b([r,A]):e==="after"&&i&&(A=_([i,A])),A}function NF(t,e,n,r,i,a,s,o=0){if(o>365)return;const c=jse(t,e,n.date,r,i,a,s),u=!!(a.disabled&&Eo(c,a.disabled,s)),f=!!(a.hidden&&Eo(c,a.hidden,s)),h=c,m=new yF(c,h,s);return!u&&!f?m:NF(t,e,m,r,i,a,s,o+1)}function Bse(t,e,n,r,i){const{autoFocus:a}=t,[s,o]=x.useState(),c=Use(e.days,n,r||(()=>!1),s),[u,f]=x.useState(a?c:void 0);return{isFocusTarget:w=>!!c?.isEqualTo(w),setFocused:f,focused:u,blur:()=>{o(u),f(void 0)},moveFocus:(w,b)=>{if(!u)return;const _=NF(w,b,u,e.navStart,e.navEnd,t,i);_&&(t.disableNavigation&&!e.days.some(M=>M.isEqualTo(_))||(e.goToDay(_),f(_)))}}}function zse(t,e){const{selected:n,required:r,onSelect:i}=t,[a,s]=dv(n,i?n:void 0),o=i?n:a,{isSameDay:c}=e,u=g=>o?.some(v=>c(v,g))??!1,{min:f,max:h}=t;return{selected:o,select:(g,v,w)=>{let b=[...o??[]];if(u(g)){if(o?.length===f||r&&o?.length===1)return;b=o?.filter(_=>!c(_,g))}else o?.length===h?b=[g]:b=[...b,g];return i||s(b),i?.(b,g,v,w),b},isSelected:u}}function Vse(t,e,n=0,r=0,i=!1,a=Qs){const{from:s,to:o}=e||{},{isSameDay:c,isAfter:u,isBefore:f}=a;let h;if(!s&&!o)h={from:t,to:n>0?void 0:t};else if(s&&!o)c(s,t)?n===0?h={from:s,to:t}:i?h={from:s,to:void 0}:h=void 0:f(t,s)?h={from:t,to:s}:h={from:s,to:t};else if(s&&o)if(c(s,t)&&c(o,t))i?h={from:s,to:o}:h=void 0;else if(c(s,t))h={from:s,to:n>0?void 0:t};else if(c(o,t))h={from:t,to:n>0?void 0:t};else if(f(t,s))h={from:t,to:o};else if(u(t,s))h={from:s,to:t};else if(u(t,o))h={from:s,to:t};else throw new Error("Invalid range");if(h?.from&&h?.to){const m=a.differenceInCalendarDays(h.to,h.from);r>0&&m>r?h={from:t,to:void 0}:n>1&&m<n&&(h={from:t,to:void 0})}return h}function Hse(t,e,n=Qs){const r=Array.isArray(e)?e:[e];let i=t.from;const a=n.differenceInCalendarDays(t.to,t.from),s=Math.min(a,6);for(let o=0;o<=s;o++){if(r.includes(i.getDay()))return!0;i=n.addDays(i,1)}return!1}function TR(t,e,n=Qs){return ko(t,e.from,!1,n)||ko(t,e.to,!1,n)||ko(e,t.from,!1,n)||ko(e,t.to,!1,n)}function Wse(t,e,n=Qs){const r=Array.isArray(e)?e:[e];if(r.filter(o=>typeof o!="function").some(o=>typeof o=="boolean"?o:n.isDate(o)?ko(t,o,!1,n):bF(o,n)?o.some(c=>ko(t,c,!1,n)):uv(o)?o.from&&o.to?TR(t,{from:o.from,to:o.to},n):!1:xF(o)?Hse(t,o.dayOfWeek,n):HE(o)?n.isAfter(o.before,o.after)?TR(t,{from:n.addDays(o.after,1),to:n.addDays(o.before,-1)},n):Eo(t.from,o,n)||Eo(t.to,o,n):WE(o)||GE(o)?Eo(t.from,o,n)||Eo(t.to,o,n):!1))return!0;const s=r.filter(o=>typeof o=="function");if(s.length){let o=t.from;const c=n.differenceInCalendarDays(t.to,t.from);for(let u=0;u<=c;u++){if(s.some(f=>f(o)))return!0;o=n.addDays(o,1)}}return!1}function Gse(t,e){const{disabled:n,excludeDisabled:r,resetOnSelect:i,selected:a,required:s,onSelect:o}=t,[c,u]=dv(a,o?a:void 0),f=o?a:c;return{selected:f,select:(g,v,w)=>{const{min:b,max:_}=t;let E;if(g){const M=f?.from,T=f?.to,P=!!M&&!!T,A=!!M&&!!T&&e.isSameDay(M,T)&&e.isSameDay(g,M);i&&(P||!f?.from)?!s&&A?E=void 0:E={from:g,to:void 0}:E=Vse(g,f,b,_,s,e)}return r&&n&&E?.from&&E.to&&Wse({from:E.from,to:E.to},n,e)&&(E.from=g,E.to=void 0),o||u(E),o?.(E,g,v,w),E},isSelected:g=>f&&ko(f,g,!1,e)}}function $se(t,e){const{selected:n,required:r,onSelect:i}=t,[a,s]=dv(n,i?n:void 0),o=i?n:a,{isSameDay:c}=e;return{selected:o,select:(h,m,g)=>{let v=h;return!r&&o&&o&&c(h,o)&&(v=void 0),i||s(v),i?.(v,h,m,g),v},isSelected:h=>o?c(o,h):!1}}function Yse(t,e){const n=$se(t,e),r=zse(t,e),i=Gse(t,e);switch(t.mode){case"single":return n;case"multiple":return r;case"range":return i;default:return}}function ba(t,e){return t instanceof mi&&t.timeZone===e?t:new mi(t,e)}function Ju(t,e,n){return ba(t,e)}function CR(t,e,n){return typeof t=="boolean"||typeof t=="function"?t:t instanceof Date?Ju(t,e):Array.isArray(t)?t.map(r=>r instanceof Date?Ju(r,e):r):uv(t)?{...t,from:t.from?ba(t.from,e):t.from,to:t.to?ba(t.to,e):t.to}:HE(t)?{before:Ju(t.before,e),after:Ju(t.after,e)}:WE(t)?{after:Ju(t.after,e)}:GE(t)?{before:Ju(t.before,e)}:t}function x_(t,e,n){return t&&(Array.isArray(t)?t.map(r=>CR(r,e)):CR(t,e))}function qse(t){let e=t;const n=e.timeZone;if(n&&(e={...t,timeZone:n},e.today&&(e.today=ba(e.today,n)),e.month&&(e.month=ba(e.month,n)),e.defaultMonth&&(e.defaultMonth=ba(e.defaultMonth,n)),e.startMonth&&(e.startMonth=ba(e.startMonth,n)),e.endMonth&&(e.endMonth=ba(e.endMonth,n)),e.mode==="single"&&e.selected?e.selected=ba(e.selected,n):e.mode==="multiple"&&e.selected?e.selected=e.selected?.map(ne=>ba(ne,n)):e.mode==="range"&&e.selected&&(e.selected={from:e.selected.from?ba(e.selected.from,n):e.selected.from,to:e.selected.to?ba(e.selected.to,n):e.selected.to}),e.disabled!==void 0&&(e.disabled=x_(e.disabled,n)),e.hidden!==void 0&&(e.hidden=x_(e.hidden,n)),e.modifiers)){const ne={};Object.keys(e.modifiers).forEach(Be=>{ne[Be]=x_(e.modifiers?.[Be],n)}),e.modifiers=ne}const{components:r,formatters:i,labels:a,dateLib:s,locale:o,classNames:c}=x.useMemo(()=>{const ne={...gF,...e.locale},Be=e.broadcastCalendar?1:e.weekStartsOn,ke=e.noonSafe&&e.timeZone?kse(e.timeZone,{weekStartsOn:Be,locale:ne}):void 0,Ae=e.dateLib&&ke?{...ke,...e.dateLib}:e.dateLib??ke,Ve=new ua({locale:ne,weekStartsOn:Be,firstWeekContainsDate:e.firstWeekContainsDate,useAdditionalWeekYearTokens:e.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:e.useAdditionalDayOfYearTokens,timeZone:e.timeZone,numerals:e.numerals},Ae);return{dateLib:Ve,components:rse(e.components),formatters:pse(e.formatters),labels:xse(e.labels,Ve.options),locale:ne,classNames:{...ase(),...e.classNames}}},[e.locale,e.broadcastCalendar,e.weekStartsOn,e.firstWeekContainsDate,e.useAdditionalWeekYearTokens,e.useAdditionalDayOfYearTokens,e.timeZone,e.numerals,e.dateLib,e.noonSafe,e.components,e.formatters,e.labels,e.classNames]);e.today||(e={...e,today:s.today()});const{captionLayout:u,mode:f,navLayout:h,numberOfMonths:m=1,onDayBlur:g,onDayClick:v,onDayFocus:w,onDayKeyDown:b,onDayMouseEnter:_,onDayMouseLeave:E,onNextClick:M,onPrevClick:T,showWeekNumber:P,styles:A}=e,{formatCaption:R,formatDay:k,formatMonthDropdown:N,formatWeekNumber:B,formatWeekNumberHeader:L,formatWeekdayName:z,formatYearDropdown:I}=i,V=Fse(e,s),{days:W,months:X,navStart:J,navEnd:F,previousMonth:G,nextMonth:Y,goToMonth:H}=V,te=tse(W,e,J,F,s),{isSelected:re,select:ue,selected:ce}=Yse(e,s)??{},{blur:ee,focused:le,isFocusTarget:ve,moveFocus:Ne,setFocused:be}=Bse(e,V,te,re??(()=>!1),s),{labelDayButton:qe,labelGridcell:he,labelGrid:Ue,labelMonthDropdown:je,labelNav:et,labelPrevious:_e,labelNext:oe,labelWeekday:Q,labelWeekNumber:ze,labelWeekNumberHeader:Pe,labelYearDropdown:De}=a,Le=x.useMemo(()=>wse(s,e.ISOWeek,e.broadcastCalendar,e.today),[s,e.ISOWeek,e.broadcastCalendar,e.today]),$=f!==void 0||v!==void 0,U=x.useCallback(()=>{G&&(H(G),T?.(G))},[G,H,T]),Z=x.useCallback(()=>{Y&&(H(Y),M?.(Y))},[H,Y,M]),pe=x.useCallback((ne,Be)=>ke=>{ke.preventDefault(),ke.stopPropagation(),be(ne),!Be.disabled&&(ue?.(ne.date,Be,ke),v?.(ne.date,Be,ke))},[ue,v,be]),Se=x.useCallback((ne,Be)=>ke=>{be(ne),w?.(ne.date,Be,ke)},[w,be]),xe=x.useCallback((ne,Be)=>ke=>{ee(),g?.(ne.date,Be,ke)},[ee,g]),Ie=x.useCallback((ne,Be)=>ke=>{const Ae={ArrowLeft:[ke.shiftKey?"month":"day",e.dir==="rtl"?"after":"before"],ArrowRight:[ke.shiftKey?"month":"day",e.dir==="rtl"?"before":"after"],ArrowDown:[ke.shiftKey?"year":"week","after"],ArrowUp:[ke.shiftKey?"year":"week","before"],PageUp:[ke.shiftKey?"year":"month","before"],PageDown:[ke.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(Ae[ke.key]){ke.preventDefault(),ke.stopPropagation();const[Ve,ge]=Ae[ke.key];Ne(Ve,ge)}b?.(ne.date,Be,ke)},[Ne,b,e.dir]),He=x.useCallback((ne,Be)=>ke=>{_?.(ne.date,Be,ke)},[_]),Ye=x.useCallback((ne,Be)=>ke=>{E?.(ne.date,Be,ke)},[E]),ft=x.useCallback(ne=>Be=>{const ke=Number(Be.target.value),Ae=s.setMonth(s.startOfMonth(ne),ke);H(Ae)},[s,H]),We=x.useCallback(ne=>Be=>{const ke=Number(Be.target.value),Ae=s.setYear(s.startOfMonth(ne),ke);H(Ae)},[s,H]),{className:Xe,style:nt}=x.useMemo(()=>({className:[c[Zt.Root],e.className].filter(Boolean).join(" "),style:{...A?.[Zt.Root],...e.style}}),[c,e.className,e.style,A]),ct=ise(e),Ke=x.useRef(null);Cse(Ke,!!e.animate,{classNames:c,months:X,focused:le,dateLib:s});const gt={dayPickerProps:e,selected:ce,select:ue,isSelected:re,months:X,nextMonth:Y,previousMonth:G,goToMonth:H,getModifiers:te,components:r,classNames:c,styles:A,labels:a,formatters:i};return ot.createElement(vF.Provider,{value:gt},ot.createElement(r.Root,{rootRef:e.animate?Ke:void 0,className:Xe,style:nt,dir:e.dir,id:e.id,lang:e.lang??o.code,nonce:e.nonce,title:e.title,role:e.role,"aria-label":e["aria-label"],"aria-labelledby":e["aria-labelledby"],...ct},ot.createElement(r.Months,{className:c[Zt.Months],style:A?.[Zt.Months]},!e.hideNavigation&&!h&&ot.createElement(r.Nav,{"data-animated-nav":e.animate?"true":void 0,className:c[Zt.Nav],style:A?.[Zt.Nav],"aria-label":et(),onPreviousClick:U,onNextClick:Z,previousMonth:G,nextMonth:Y}),X.map((ne,Be)=>ot.createElement(r.Month,{"data-animated-month":e.animate?"true":void 0,className:c[Zt.Month],style:A?.[Zt.Month],key:Be,displayIndex:Be,calendarMonth:ne},h==="around"&&!e.hideNavigation&&Be===0&&ot.createElement(r.PreviousMonthButton,{type:"button",className:c[Zt.PreviousMonthButton],tabIndex:G?void 0:-1,"aria-disabled":G?void 0:!0,"aria-label":_e(G),onClick:U,"data-animated-button":e.animate?"true":void 0},ot.createElement(r.Chevron,{disabled:G?void 0:!0,className:c[Zt.Chevron],orientation:e.dir==="rtl"?"right":"left"})),ot.createElement(r.MonthCaption,{"data-animated-caption":e.animate?"true":void 0,className:c[Zt.MonthCaption],style:A?.[Zt.MonthCaption],calendarMonth:ne,displayIndex:Be},u?.startsWith("dropdown")?ot.createElement(r.DropdownNav,{className:c[Zt.Dropdowns],style:A?.[Zt.Dropdowns]},(()=>{const ke=u==="dropdown"||u==="dropdown-months"?ot.createElement(r.MonthsDropdown,{key:"month",className:c[Zt.MonthsDropdown],"aria-label":je(),classNames:c,components:r,disabled:!!e.disableNavigation,onChange:ft(ne.date),options:bse(ne.date,J,F,i,s),style:A?.[Zt.Dropdown],value:s.getMonth(ne.date)}):ot.createElement("span",{key:"month"},N(ne.date,s)),Ae=u==="dropdown"||u==="dropdown-years"?ot.createElement(r.YearsDropdown,{key:"year",className:c[Zt.YearsDropdown],"aria-label":De(s.options),classNames:c,components:r,disabled:!!e.disableNavigation,onChange:We(ne.date),options:Sse(J,F,i,s,!!e.reverseYears),style:A?.[Zt.Dropdown],value:s.getYear(ne.date)}):ot.createElement("span",{key:"year"},I(ne.date,s));return s.getMonthYearOrder()==="year-first"?[Ae,ke]:[ke,Ae]})(),ot.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},R(ne.date,s.options,s))):ot.createElement(r.CaptionLabel,{className:c[Zt.CaptionLabel],role:"status","aria-live":"polite"},R(ne.date,s.options,s))),h==="around"&&!e.hideNavigation&&Be===m-1&&ot.createElement(r.NextMonthButton,{type:"button",className:c[Zt.NextMonthButton],tabIndex:Y?void 0:-1,"aria-disabled":Y?void 0:!0,"aria-label":oe(Y),onClick:Z,"data-animated-button":e.animate?"true":void 0},ot.createElement(r.Chevron,{disabled:Y?void 0:!0,className:c[Zt.Chevron],orientation:e.dir==="rtl"?"left":"right"})),Be===m-1&&h==="after"&&!e.hideNavigation&&ot.createElement(r.Nav,{"data-animated-nav":e.animate?"true":void 0,className:c[Zt.Nav],style:A?.[Zt.Nav],"aria-label":et(),onPreviousClick:U,onNextClick:Z,previousMonth:G,nextMonth:Y}),ot.createElement(r.MonthGrid,{role:"grid","aria-multiselectable":f==="multiple"||f==="range","aria-label":Ue(ne.date,s.options,s)||void 0,className:c[Zt.MonthGrid],style:A?.[Zt.MonthGrid]},!e.hideWeekdays&&ot.createElement(r.Weekdays,{"data-animated-weekdays":e.animate?"true":void 0,className:c[Zt.Weekdays],style:A?.[Zt.Weekdays]},P&&ot.createElement(r.WeekNumberHeader,{"aria-label":Pe(s.options),className:c[Zt.WeekNumberHeader],style:A?.[Zt.WeekNumberHeader],scope:"col"},L()),Le.map(ke=>ot.createElement(r.Weekday,{"aria-label":Q(ke,s.options,s),className:c[Zt.Weekday],key:String(ke),style:A?.[Zt.Weekday],scope:"col"},z(ke,s.options,s)))),ot.createElement(r.Weeks,{"data-animated-weeks":e.animate?"true":void 0,className:c[Zt.Weeks],style:A?.[Zt.Weeks]},ne.weeks.map(ke=>ot.createElement(r.Week,{className:c[Zt.Week],key:ke.weekNumber,style:A?.[Zt.Week],week:ke},P&&ot.createElement(r.WeekNumber,{week:ke,style:A?.[Zt.WeekNumber],"aria-label":ze(ke.weekNumber,{locale:o}),className:c[Zt.WeekNumber],scope:"row",role:"rowheader"},B(ke.weekNumber,s)),ke.days.map(Ae=>{const{date:Ve}=Ae,ge=te(Ae);if(ge[fr.focused]=!ge.hidden&&!!le?.isEqualTo(Ae),ge[es.selected]=re?.(Ve)||ge.selected,uv(ce)){const{from:Lt,to:_t}=ce;ge[es.range_start]=!!(Lt&&_t&&s.isSameDay(Ve,Lt)),ge[es.range_end]=!!(Lt&&_t&&s.isSameDay(Ve,_t)),ge[es.range_middle]=ko(ce,Ve,!0,s)}const ut=_se(ge,A,e.modifiersStyles),yt=nse(ge,c,e.modifiersClassNames),qt=!$&&!ge.hidden?he(Ve,ge,s.options,s):void 0;return ot.createElement(r.Day,{key:`${Ae.isoDate}_${Ae.displayMonthId}`,day:Ae,modifiers:ge,className:yt.join(" "),style:ut,role:"gridcell","aria-selected":ge.selected||void 0,"aria-label":qt,"data-day":Ae.isoDate,"data-month":Ae.outside?Ae.dateMonthId:void 0,"data-selected":ge.selected||void 0,"data-disabled":ge.disabled||void 0,"data-hidden":ge.hidden||void 0,"data-outside":Ae.outside||void 0,"data-focused":ge.focused||void 0,"data-today":ge.today||void 0},!ge.hidden&&$?ot.createElement(r.DayButton,{className:c[Zt.DayButton],style:A?.[Zt.DayButton],type:"button",day:Ae,modifiers:ge,disabled:!ge.focused&&ge.disabled||void 0,"aria-disabled":ge.focused&&ge.disabled||void 0,tabIndex:ve(Ae)?0:-1,"aria-label":qe(Ve,ge,s.options,s),onClick:pe(Ae,ge),onBlur:xe(Ae,ge),onFocus:Se(Ae,ge),onKeyDown:Ie(Ae,ge),onMouseEnter:He(Ae,ge),onMouseLeave:Ye(Ae,ge)},k(Ve,s.options,s)):!ge.hidden&&k(Ae.date,s.options,s))})))))))),e.footer&&ot.createElement(r.Footer,{className:c[Zt.Footer],style:A?.[Zt.Footer],role:"status","aria-live":"polite"},e.footer)))}function AR(t){if(!t)return"";const e=t.split("-");if(e.length!==3)return t;const n=new Date(Number(e[0]),Number(e[1])-1,Number(e[2]));return Number.isFinite(n.getTime())?Ns(n,"MMM d"):t}function Xse({from:t,to:e,onApply:n,onCancel:r}){const i=x.useMemo(()=>{const u={from:void 0,to:void 0};if(t){const f=t.split("-");u.from=new Date(Number(f[0]),Number(f[1])-1,Number(f[2]))}if(e){const f=e.split("-");u.to=new Date(Number(f[0]),Number(f[1])-1,Number(f[2]))}return u},[t,e]),[a,s]=x.useState(i),o=()=>{if(!a?.from)return;const u=Ns(a.from,"yyyy-MM-dd"),f=a.to?Ns(a.to,"yyyy-MM-dd"):u;n?.(u,f)},c=!!a?.from;return p.jsxs("div",{className:"p-4",children:[p.jsx(qse,{mode:"range",selected:a,onSelect:s,numberOfMonths:2,showOutsideDays:!1,classNames:{root:"rdp-oai",months:"flex gap-4",month:"space-y-3",month_caption:"flex justify-center items-center h-8",caption_label:"text-sm font-medium text-oai-black dark:text-oai-white",nav:"flex items-center justify-between absolute inset-x-0 top-0 px-2",button_previous:"inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",button_next:"inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",chevron:"w-4 h-4",month_grid:"border-collapse",weekdays:"flex",weekday:"w-9 text-center text-xs font-medium text-oai-gray-400 dark:text-oai-gray-500 py-1",week:"flex",day:"w-9 h-9 text-center text-sm p-0 relative",day_button:"w-full h-full inline-flex items-center justify-center rounded-md transition-colors hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 text-oai-black dark:text-oai-white cursor-pointer rdp-day-btn",today:"font-bold",selected:"rdp-selected",range_start:"rdp-selected rdp-range-start",range_end:"rdp-selected rdp-range-end",range_middle:"rdp-range-mid",outside:"text-oai-gray-300 dark:text-oai-gray-600",disabled:"text-oai-gray-300 dark:text-oai-gray-600 cursor-not-allowed",hidden:"invisible"},styles:{months:{position:"relative"}}}),p.jsxs("div",{className:"flex items-center justify-end gap-2 mt-4 pt-3 border-t border-oai-gray-200 dark:border-oai-gray-700",children:[c&&a.from&&p.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mr-auto",children:[Ns(a.from,"MMM d, yyyy"),a.to&&a.to.getTime()!==a.from.getTime()?` — ${Ns(a.to,"MMM d, yyyy")}`:""]}),p.jsx(Ui,{variant:"secondary",size:"sm",onClick:r,children:"Cancel"}),p.jsx(Ui,{variant:"primary",size:"sm",onClick:o,disabled:!c,children:"Apply"})]})]})}function Kse({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z"})})}function Zse({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",className:e,children:p.jsx("path",{d:"M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z"})})}function Jse({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M22.106 5.68L12.5.135a.998.998 0 00-.998 0L1.893 5.68a.84.84 0 00-.419.726v11.186c0 .3.16.577.42.727l9.607 5.547a.999.999 0 00.998 0l9.608-5.547a.84.84 0 00.42-.727V6.407a.84.84 0 00-.42-.726zm-.603 1.176L12.228 22.92c-.063.108-.228.064-.228-.061V12.34a.59.59 0 00-.295-.51l-9.11-5.26c-.107-.062-.063-.228.062-.228h18.55c.264 0 .428.286.296.514z"})})}function Qse({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z"})})}function eoe({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 -1 22 28",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M4.125 20.149c-2.69 5.959 3.036 7.453 7.26 3.966 1.24 3.91 5.898.993 7.569-2.036 3.682-6.678 2.195-13.49 1.813-14.895-2.617-9.582-15.699-9.592-17.95.049-.526 1.687-.535 3.606-.833 5.598-.15 1.005-.256 1.646-.645 2.703-.223.607-.53 1.147-1.014 2.056-.75 1.412-.434 4.138 3.434 2.724v.001ZM11.895 11.332c-1.073 0-1.234-1.283-1.234-2.048 0-.69.124-1.239.358-1.586a1 1 0 0 1 .876-.462c.375 0 .697.158.924.47.259.354.395.9.395 1.578 0 1.283-.493 2.048-1.319 2.048Zm4.416 0c-1.073 0-1.234-1.283-1.234-2.048 0-.69.124-1.239.358-1.586a1 1 0 0 1 .876-.462c.375 0 .697.158.924.47.259.354.396.9.396 1.578 0 1.283-.494 2.048-1.32 2.048Z"})})}function toe({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M16 6H8v12h8V6zm4 16H4V2h16v20z"})})}function noe({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:[p.jsx("path",{d:"M21.846 0a1.923 1.923 0 110 3.846H20.15a.226.226 0 01-.227-.226V1.923C19.923.861 20.784 0 21.846 0z"}),p.jsx("path",{d:"M11.065 11.199l7.257-7.2c.137-.136.06-.41-.116-.41H14.3a.164.164 0 00-.117.051l-7.82 7.756c-.122.12-.302.013-.302-.179V3.82c0-.127-.083-.23-.185-.23H3.186c-.103 0-.186.103-.186.23V19.77c0 .128.083.23.186.23h2.69c.103 0 .186-.102.186-.23v-3.25c0-.069.025-.135.069-.178l2.424-2.406a.158.158 0 01.205-.023l6.484 4.772a7.677 7.677 0 003.453 1.283c.108.012.2-.095.2-.23v-3.06c0-.117-.07-.212-.164-.227a5.028 5.028 0 01-2.027-.807l-5.613-4.064c-.117-.078-.132-.279-.028-.381z"})]})}function roe({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M19.245 5.364c1.322 1.36 1.877 3.216 2.11 5.817.622 0 1.2.135 1.592.654l.73.964c.21.278.323.61.323.955v2.62c0 .339-.173.669-.453.868C20.239 19.602 16.157 21.5 12 21.5c-4.6 0-9.205-2.583-11.547-4.258-.28-.2-.452-.53-.453-.868v-2.62c0-.345.113-.679.321-.956l.73-.963c.392-.517.974-.654 1.593-.654l.029-.297c.25-2.446.81-4.213 2.082-5.52 2.461-2.54 5.71-2.851 7.146-2.864h.198c1.436.013 4.685.323 7.146 2.864zm-7.244 4.328c-.284 0-.613.016-.962.05-.123.447-.305.85-.57 1.108-1.05 1.023-2.316 1.18-2.994 1.18-.638 0-1.306-.13-1.851-.464-.516.165-1.012.403-1.044.996a65.882 65.882 0 00-.063 2.884l-.002.48c-.002.563-.005 1.126-.013 1.69.002.326.204.63.51.765 2.482 1.102 4.83 1.657 6.99 1.657 2.156 0 4.504-.555 6.985-1.657a.854.854 0 00.51-.766c.03-1.682.006-3.372-.076-5.053-.031-.596-.528-.83-1.046-.996-.546.333-1.212.464-1.85.464-.677 0-1.942-.157-2.993-1.18-.266-.258-.447-.661-.57-1.108-.32-.032-.64-.049-.96-.05zm-2.525 4.013c.539 0 .976.426.976.95v1.753c0 .525-.437.95-.976.95a.964.964 0 01-.976-.95v-1.752c0-.525.437-.951.976-.951zm5 0c.539 0 .976.426.976.95v1.753c0 .525-.437.95-.976.95a.964.964 0 01-.976-.95v-1.752c0-.525.437-.951.976-.951zM7.635 5.087c-1.05.102-1.935.438-2.385.906-.975 1.037-.765 3.668-.21 4.224.405.394 1.17.657 1.995.657h.09c.649-.013 1.785-.176 2.73-1.11.435-.41.705-1.433.675-2.47-.03-.834-.27-1.52-.63-1.813-.39-.336-1.275-.482-2.265-.394zm6.465.394c-.36.292-.6.98-.63 1.813-.03 1.037.24 2.06.675 2.47.968.957 2.136 1.104 2.776 1.11h.044c.825 0 1.59-.263 1.995-.657.555-.556.765-3.187-.21-4.224-.45-.468-1.335-.804-2.385-.906-.99-.088-1.875.058-2.265.394zM12 7.615c-.24 0-.525.015-.84.044.03.16.045.336.06.526l-.001.159a2.94 2.94 0 01-.014.25c.225-.022.425-.027.612-.028h.366c.187 0 .387.006.612.028-.015-.146-.015-.277-.015-.409.015-.19.03-.365.06-.526a9.29 9.29 0 00-.84-.044z"})})}function ioe({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 64 60",fill:"none",className:e,"aria-hidden":"true",children:[p.jsx("path",{fill:"currentColor",d:"M37.2114 3.75318C37.6821 3.33106 37.7106 3.31457 38.0558 3.29385C38.6149 3.2531 39.1272 3.52199 39.9989 4.31564C42.0356 6.16652 44.8714 9.97183 46.6346 13.2212L47.3163 14.4819L48.2782 14.9605C49.2072 15.4299 50.7308 16.3923 51.3672 16.9085C51.655 17.1464 51.6956 17.1508 51.9947 17.0344C53.3454 16.5084 55.2803 17.206 56.9869 18.8432C58.5231 20.3155 59.9943 22.8312 60.558 24.9308C60.6403 25.2687 60.7493 25.9952 60.7891 26.5362C60.9177 28.4358 60.3092 29.9532 59.1362 30.64C58.8965 30.7784 58.8801 30.8158 58.8868 31.4132C58.9409 34.2583 58.1741 37.0985 56.6335 39.8679C54.8946 42.9773 51.7981 46.1938 47.6074 49.2243C45.357 50.8619 40.0323 53.964 37.6248 55.0532C31.8578 57.6496 27.2346 58.646 23.2188 58.154C20.8236 57.8638 18.1124 56.9287 16.5082 55.8433C16.086 55.5515 16.0191 55.5329 15.6966 55.6251C13.9793 56.1185 11.73 55.1053 9.81931 52.9844C9.05725 52.1366 7.82714 50.0548 7.42839 48.9409C6.50606 46.3339 6.68976 43.9816 7.91836 42.5767C8.23573 42.2149 8.2453 42.1995 8.17598 41.5912C8.06148 40.5951 8.00971 39.1206 8.06202 38.1692L8.10361 37.2803L6.76977 34.9212C4.70378 31.2451 3.3912 28.1582 2.88489 25.7998C2.61762 24.5066 2.63385 23.9324 2.96214 23.5078C3.16198 23.2515 3.81796 22.9866 4.60785 22.8407C6.59665 22.4917 10.9334 22.8076 15.7581 23.6595L16.259 23.7458L17.3608 22.7713C19.1891 21.1519 20.4038 20.244 22.6429 18.8478C24.9768 17.3876 27.6108 16.1858 30.577 15.2346L31.5295 14.9294L32.0526 13.5561C33.9257 8.61146 35.8437 4.96584 37.2114 3.75318ZM21.5208 29.0919C19.404 30.314 18.3453 30.9251 17.5676 31.6099C14.4179 34.3835 13.2414 38.777 14.5823 42.7537C14.9135 43.7357 15.5247 44.7942 16.7469 46.9111C17.9691 49.0279 18.5801 50.0865 19.2649 50.8643C22.0385 54.014 26.4316 55.1918 30.4084 53.8509C31.3904 53.5198 32.4489 52.9085 34.5657 51.6863L46.7442 44.6551C48.8613 43.4328 49.9205 42.8214 50.6983 42.1365C53.8479 39.363 55.0245 34.9695 53.6835 30.9927C53.3524 30.0107 52.7412 28.9522 51.519 26.8354C50.2968 24.7185 49.6858 23.66 49.0009 22.8822C46.2274 19.7325 41.8342 18.5547 37.8575 19.8956C36.8754 20.2267 35.8163 20.8383 33.6993 22.0606L21.5208 29.0919Z"}),p.jsx("g",{transform:"rotate(-30 22.6953 37.6011)",children:p.jsx("rect",{x:"22.6953",y:"37.6011",width:"4.81084",height:"9.99175",rx:"2.40542",fill:"currentColor"})}),p.jsx("g",{transform:"rotate(-30 35.6748 30.1074)",children:p.jsx("rect",{x:"35.6748",y:"30.1074",width:"4.81084",height:"9.99175",rx:"2.40542",fill:"currentColor"})})]})}function aoe({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",className:e,children:p.jsx("path",{d:"M7 2h10a5 5 0 015 5v10a5 5 0 01-5 5H7a5 5 0 01-5-5V7a5 5 0 015-5zm0 4.5v11h2.35v-4.55h5.3V17.5H17v-11h-2.35v4.1h-5.3V6.5H7z"})})}function soe({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"currentColor",className:e,children:p.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})}function ooe({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",className:e,"aria-hidden":"true",children:[p.jsx("rect",{x:"2",y:"2",width:"20",height:"20",rx:"5",stroke:"currentColor",strokeWidth:"1.6"}),p.jsx("path",{d:"M7.2 16.8l4.4-4.4M14.5 9.5l1.8-1.8a1.4 1.4 0 0 1 2 2l-1.8 1.8M9 17.5l-1.5 1.5a1.06 1.06 0 0 1-1.5-1.5L7.5 16M11.6 12.4l3.5-3.5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),p.jsx("circle",{cx:"17",cy:"13",r:"1.2",fill:"currentColor"})]})}function loe({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 120 90",fill:"currentColor",className:e,children:[p.jsx("rect",{x:"10",y:"8",width:"100",height:"12",rx:"2"}),p.jsx("rect",{x:"25",y:"20",width:"12",height:"62",rx:"2"}),p.jsx("rect",{x:"75",y:"20",width:"12",height:"45",rx:"2"}),p.jsx("rect",{x:"71",y:"55",width:"20",height:"16",rx:"3"}),p.jsx("rect",{x:"76",y:"71",width:"3",height:"8",rx:"1"}),p.jsx("rect",{x:"82",y:"71",width:"3",height:"8",rx:"1"})]})}function coe({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 120 90",fill:"currentColor",className:e,children:[p.jsx("rect",{x:"10",y:"8",width:"100",height:"12",rx:"2"}),p.jsx("rect",{x:"25",y:"20",width:"12",height:"62",rx:"2"}),p.jsx("rect",{x:"83",y:"20",width:"12",height:"62",rx:"2"})]})}const uoe={CLAUDE:Kse,CODEBUDDY:ioe,CODEX:Zse,COPILOT:roe,CRAFT:ooe,CURSOR:Jse,GEMINI:Qse,GITHUB:soe,HERMES:aoe,KIMI:noe,KIRO:eoe,OPENCODE:toe,OMP:loe,PI:coe},doe={ANTIGRAVITY:"/brand-logos/antigravity.svg",CLAUDE:"/brand-logos/claude-code.svg",CODEX:"/brand-logos/codex.svg",GEMINI:"/brand-logos/gemini.svg",HERMES:"/brand-logos/hermes.svg",OPENCLAW:"/brand-logos/openclaw.svg",OPENCODE:"/brand-logos/opencode.svg"};function nu({provider:t,size:e=16,color:n,className:r=""}){const i=t?.toUpperCase?.()||"",a=doe[i];if(a)return p.jsx("img",{src:a,alt:"",width:e,height:e,className:r,style:{width:e,height:e,objectFit:"contain"},"aria-hidden":!0});const s=uoe[i];return s?p.jsx(s,{size:e,className:r}):p.jsx("div",{className:"rounded-full shrink-0",style:{width:e*.5,height:e*.5,backgroundColor:n}})}const foe=[{key:"system_prompt",color:"#64748b",from:["system_prefix"]},{key:"messages",color:"#3b82f6",from:["user_input","conversation_history","assistant_response"]},{key:"tool_calls",color:"#8b5cf6",from:["tool_calls"]},{key:"custom_agents",color:"#ec4899",from:["subagents"]},{key:"reasoning",color:"#06b6d4",from:["reasoning"]}],b_=[{key:"system_prompt",color:"#64748b"},{key:"messages",color:"#3b82f6"},{key:"tool_calls",color:"#8b5cf6"},{key:"reasoning",color:"#06b6d4"}],hoe=[["by_type","dashboard.context_breakdown.exec_details.group_by_type"],["by_executable","dashboard.context_breakdown.exec_details.group_by_executable"],["by_command","dashboard.context_breakdown.exec_details.group_by_command"],["by_duration","dashboard.context_breakdown.exec_details.group_by_duration"],["by_output","dashboard.context_breakdown.exec_details.group_by_output"],["by_exit","dashboard.context_breakdown.exec_details.group_by_exit"]],poe={duration:.18,ease:[.4,0,.2,1]},moe={height:0,opacity:0},goe={height:"auto",opacity:1},yoe={height:0,opacity:0};function voe(t){const e=Number(t||0);return Number.isFinite(e)&&e>0?e:0}function xoe(t,e){const n={};for(const r of["input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens","total_tokens"])n[r]=Math.round(Number(t?.[r]||0)*e);return n}function DF(t,e=null){const n=t.reduce((s,o)=>s+Number(o.totals.total_tokens||0),0),r=voe(e),i=r||n,a=r&&n>0?r/n:1;return t.map(s=>{const o=a===1?s.totals:xoe(s.totals,a);return{...s,totals:o,percent:i>0?Number((o.total_tokens/i*100).toFixed(2)):0}}).sort((s,o)=>o.totals.total_tokens-s.totals.total_tokens)}function boe(t,e=null){const n=new Map;for(const i of t||[])n.set(i.key,i);const r=foe.map(i=>{const a={input_tokens:0,cached_input_tokens:0,cache_creation_input_tokens:0,output_tokens:0,reasoning_output_tokens:0,total_tokens:0};for(const s of i.from){const o=n.get(s);if(!o)continue;const c=o.totals||{};a.input_tokens+=c.input_tokens||0,a.cached_input_tokens+=c.cached_input_tokens||0,a.cache_creation_input_tokens+=c.cache_creation_input_tokens||0,a.output_tokens+=c.output_tokens||0,a.reasoning_output_tokens+=c.reasoning_output_tokens||0,a.total_tokens+=c.total_tokens||0}return{key:i.key,color:i.color,totals:a}});return DF(r,e)}function _oe(t,e=null){const n=t?.totals||{},r=Number(n.reasoning_output_tokens||0),i=(t?.tool_calls_breakdown?.categories||[]).reduce((u,f)=>f?.name==="Text Response"?u:u+Number(f?.totals?.total_tokens||0),0),a=Number(n.total_tokens||0),s=Math.min(Math.max(0,i),Math.max(0,a-r)),o=Math.max(0,a-r-s),c=[{key:"messages",color:b_[1].color,totals:{total_tokens:o}},{key:"tool_calls",color:b_[2].color,totals:{total_tokens:s}},{key:"reasoning",color:b_[3].color,totals:{total_tokens:r}}];return DF(c,e)}function __(t){return O(`dashboard.context_breakdown.category.${t}`)}function Lc(t){return!Number.isFinite(Number(t))||Number(t)<=0?"0":Ma(Number(t),{decimals:1})}function woe(t){return typeof t!="string"?"":t.startsWith("mcp__")?t.split("__").slice(2).join("__")||t:t.includes("/")&&t.split("/").pop()||t}function Soe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||null,r=Number(n?n.input_tokens||0:e?.input_tokens||0),i=Number(n?n.output_tokens||0:e?.output_tokens||0),a=Number(n?n.cached_input_tokens||0:e?.cache_read||0),s=Number(n?n.cache_creation_input_tokens||0:e?.cache_creation||0),o=Number(n?n.total_tokens||r+i:e?.total_tokens||i);return{name:woe(e?.name?String(e.name):""),calls:Number(e?.calls||0),input_tokens:r,output_tokens:i,cache_read:a,cache_creation:s,total_tokens:Number(o||0)}}).filter(e=>e.name).sort((e,n)=>(n.total_tokens||0)-(e.total_tokens||0))}function koe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{},r=Array.isArray(e?.tools)?e.tools:[],i=Number(n.input_tokens||0),a=Number(n.output_tokens||0),s=Number(n.cached_input_tokens||0),o=Number(n.cache_creation_input_tokens||0);return{name:e?.name?String(e.name):"",calls:Number(e?.calls||0),totals:{input_tokens:i,output_tokens:a,cached_input_tokens:s,cache_creation_input_tokens:o,total_tokens:Number(n.total_tokens||i+a)},tools:Soe(r),toolCount:r.length}}).filter(e=>e.name).sort((e,n)=>(n.totals.total_tokens||0)-(e.totals.total_tokens||0))}function Eoe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{},r=Number(n.input_tokens||0),i=Number(n.output_tokens||0),a=Number(n.cached_input_tokens||0),s=Number(n.cache_creation_input_tokens||0);return{key:e?.key?String(e.key):"",name:e?.name?String(e.name):"",totals:{input_tokens:r,output_tokens:i,cached_input_tokens:a,cache_creation_input_tokens:s,total_tokens:Number(n.total_tokens||r+i+a+s)}}}).filter(e=>e.key||e.name).sort((e,n)=>(n.totals.total_tokens||0)-(e.totals.total_tokens||0))}function Moe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{};return{name:e?.name?String(e.name):"",calls:Number(e?.calls||0),total_tokens:Number(n.total_tokens||0)}}).filter(e=>e.name).sort((e,n)=>Number(n.total_tokens||0)-Number(e.total_tokens||0))}function Toe(t){if(t?.key){const e=O(`dashboard.context_breakdown.message_details.${t.key}`);if(e&&!e.includes("dashboard.context_breakdown"))return e}return t?.name||""}function Coe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{},r=Number(n.input_tokens||0),i=Number(n.output_tokens||0),a=Number(n.cached_input_tokens||0),s=Number(n.cache_creation_input_tokens||0);return{name:e?.name?String(e.name):"",calls:Number(e?.calls||0),failures:Number(e?.failures||0),duration_ms:Number(e?.duration_ms||0),max_duration_ms:Number(e?.max_duration_ms||0),output_chars:Number(e?.output_chars||0),output_lines:Number(e?.output_lines||0),totals:{input_tokens:r,output_tokens:i,cached_input_tokens:a,cache_creation_input_tokens:s,total_tokens:Number(n.total_tokens||r+i)}}}).filter(e=>e.name).sort((e,n)=>Number(n.totals.total_tokens||0)-Number(e.totals.total_tokens||0))}function PR(t){const e=Number(t||0);return!Number.isFinite(e)||e<=0?"0ms":e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.round(e/1e3)}s`}function Aoe(t,e){return t?e==="by_executable"?t.by_executable||[]:e==="by_command"?t.by_command||[]:e==="by_duration"?t.by_duration||[]:e==="by_output"?t.by_output||[]:e==="by_exit"?t.by_exit||[]:t.by_type||[]:[]}function RR(t){return t==="exec_command"||t==="Bash"}function LF(t){return t==="codex"?"dashboard.context_breakdown.empty_codex":"dashboard.context_breakdown.empty"}function Poe(t){return t==="codex"?"dashboard.context_breakdown.error_codex":"dashboard.context_breakdown.error"}function Roe(t){return t==="codex"?"dashboard.context_breakdown.footnote_codex":"dashboard.context_breakdown.footnote"}const Noe=10;function Md({level:t=0,colorSquare:e=null,label:n,labelSuffix:r=null,labelTone:i="default",hasChevron:a=!1,open:s=!1,onToggle:o,tokens:c,percent:u=null,children:f}){const h=i==="accent"?"text-oai-brand truncate":i==="muted"?"text-oai-gray-500 dark:text-oai-gray-400 truncate":i==="strong"?"font-medium text-oai-black dark:text-oai-white truncate":"text-oai-gray-700 dark:text-oai-gray-300 truncate",m=p.jsx("span",{className:"shrink-0 flex items-center justify-start",style:{width:Noe},"aria-hidden":!e,children:e}),g=p.jsxs(p.Fragment,{children:[m,p.jsx("span",{className:h,children:n}),r,a&&p.jsx(Qn.span,{animate:{rotate:s?90:0},transition:{duration:.15},className:"shrink-0 text-oai-gray-400 dark:text-oai-gray-500 flex items-center","aria-hidden":"true",children:p.jsx(jW,{size:11})})]});return p.jsxs("li",{className:"min-w-0",children:[p.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_64px_48px] items-center gap-2 text-xs py-0.5",children:[a?p.jsx("button",{type:"button",onClick:o,"aria-expanded":s,className:"flex items-center gap-1.5 min-w-0 text-left cursor-pointer hover:opacity-90 focus-visible:outline-none focus-visible:ring-inset focus-visible:ring-2 focus-visible:ring-oai-brand/40 rounded-sm",children:g}):p.jsx("div",{className:"flex items-center gap-1.5 min-w-0",children:g}),p.jsx("span",{className:"text-right tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:c||""}),p.jsx("span",{className:"text-right tabular-nums text-oai-black dark:text-oai-white font-medium",children:u||""})]}),a&&f?p.jsx(Lp,{initial:!1,children:s&&p.jsx(Qn.div,{initial:moe,animate:goe,exit:yoe,transition:poe,style:{overflow:"hidden"},children:f},"content")}):null]})}function NR({execDetails:t,source:e="claude"}){const[n,r]=x.useState("by_type"),i=Coe(Aoe(t,n)),a=e==="codex",s=a?"grid-cols-[minmax(0,1fr)_48px_48px_72px_72px_60px_60px]":"grid-cols-[minmax(0,1fr)_56px_60px]";return p.jsxs("div",{className:"mt-2 ml-4",children:[p.jsx("div",{className:"flex flex-wrap items-center gap-1 rounded-md bg-oai-gray-100 dark:bg-oai-gray-900 p-1 w-fit max-w-full",children:hoe.map(([o,c])=>p.jsx("button",{type:"button",onClick:()=>r(o),className:"h-7 px-2 rounded-md text-[10px] font-medium transition-colors "+(n===o?"bg-oai-white dark:bg-oai-gray-800 text-oai-black dark:text-oai-white shadow-sm":"text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-white/70 dark:hover:bg-oai-gray-800/70"),children:O(c)},o))}),i.length===0?p.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:"—"}):p.jsx("div",{className:"mt-2 overflow-x-auto",children:p.jsxs("div",{role:"table","aria-label":O("dashboard.context_breakdown.exec_details.title"),className:a?"min-w-[420px]":"min-w-[260px]",children:[p.jsxs("div",{role:"row",className:`grid ${s} gap-2 py-1.5 mb-1 border-b border-oai-gray-200 dark:border-oai-gray-800 text-label uppercase text-oai-gray-500 dark:text-oai-gray-400`,children:[p.jsx("span",{role:"columnheader",children:O("dashboard.context_breakdown.exec_details.kind_column")}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.calls_column")}),a&&p.jsxs(p.Fragment,{children:[p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.failures_column")}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.duration_column")}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.max_duration_column")})]}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.tool_details.total_column")}),a&&p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.output_column")})]}),i.map((o,c)=>p.jsxs(Qn.div,{role:"row",className:`grid ${s} gap-2 py-1.5`,title:o.name,initial:{opacity:0},animate:{opacity:1},transition:{duration:.18,delay:c*.02},children:[p.jsx("span",{role:"cell",className:"min-w-0 text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:o.name}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ma(o.calls||0)}),a&&p.jsxs(p.Fragment,{children:[p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ma(o.failures||0)}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:PR(o.duration_ms||0)}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:PR(o.max_duration_ms||0)})]}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Lc(o.totals.total_tokens||0)}),a&&p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ma(o.output_lines||0)})]},o.name))]})})]})}function DR({toolSet:t,execDetails:e,source:n,codexQueueFallback:r}){const[i,a]=x.useState({}),[s,o]=x.useState(!1),c=koe(t?.categories||[]);function u(f){a(h=>({...h,[f]:!h[f]}))}return c.length===0?p.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:O(n==="codex"&&r?"dashboard.context_breakdown.tool_details.unavailable_codex":LF(n))}):p.jsx("ul",{className:"mt-0.5 mb-0.5 space-y-0.5",children:c.map(f=>{const h=f.toolCount>0,m=f.name==="Execution"&&e,g=m&&f.tools.some(w=>RR(w.name)),v=!!i[f.name];return p.jsxs(Md,{level:1,label:f.name,labelTone:"strong",hasChevron:h||m&&!g,open:v||m&&!g&&s,onToggle:()=>{h?u(f.name):m&&!g&&o(w=>!w)},tokens:Lc(f.totals.total_tokens||0),percent:null,children:[h&&p.jsx("ul",{className:"space-y-0.5",children:f.tools.map(w=>{const b=m&&RR(w.name);return p.jsx(Md,{level:2,label:w.name,labelTone:b?"accent":"default",hasChevron:b,open:s,onToggle:()=>o(_=>!_),tokens:Lc(w.total_tokens||0),percent:null,children:b&&p.jsx(NR,{execDetails:e,source:n})},w.name)})}),m&&!g&&p.jsx(NR,{execDetails:e,source:n})]},f.name)})})}function Doe({from:t,to:e,source:n="claude",referenceTotalTokens:r=null,onLoadingChange:i=null}){const[a,s]=x.useState(null),[o,c]=x.useState(!1),[u,f]=x.useState(null),[h,m]=x.useState({});function g(L){m(z=>({...z,[L]:!z[L]}))}if(x.useEffect(()=>{let L=!1;return c(!0),i?.(!0),f(null),S7({from:t,to:e,source:n,timeZone:x3(),tzOffsetMinutes:b3()}).then(z=>{L||s(z)}).catch(z=>{L||f(z?.message||String(z))}).finally(()=>{L||(c(!1),i?.(!1))}),()=>{L=!0}},[t,e,n]),o&&!a)return p.jsxs("div",{children:[p.jsx("div",{className:"h-1 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden animate-pulse"}),p.jsx("div",{className:"mt-3 grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-2",children:[0,1,2,3,4].map(L=>p.jsx("div",{className:"h-3 rounded bg-oai-gray-100 dark:bg-oai-gray-800 animate-pulse",style:{animationDelay:`${L*80}ms`}},L))}),p.jsx("p",{className:"mt-3 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:O("dashboard.context_breakdown.loading_hint")})]});if(u)return p.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O(Poe(n))});if(!a||a.scope!=="supported"||!a.totals?.total_tokens)return p.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O(LF(n))});const v=n==="claude"?boe(a.categories||[],r):_oe(a,r),w=a.tool_calls_breakdown||null,b=a.skills_breakdown||null,_=a.message_breakdown||null,E=a.configured_resources||null,M=a.exec_command_breakdown||null,T=Moe(b?.skills||[]),P=Eoe(_?.categories||[]),A=n==="codex"&&(a?.breakdown_status==="queue_fallback"||a?.fallback==="queue_totals"),R=n==="claude"?w?.tool_calls||null:w||null,k=n==="claude"&&w?.subagents||null,N=k?.categories?.length>0||(E?.custom_agents_count||0)>0,B=[...v].sort((L,z)=>(z.totals?.total_tokens||0)-(L.totals?.total_tokens||0));return p.jsxs("div",{children:[p.jsx("div",{role:"img","aria-label":O("dashboard.context_breakdown.bar_aria",{summary:v.filter(L=>L.percent>0).map(L=>`${__(L.key)} ${L.percent}%`).join(",")}),className:"h-1 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden flex",children:v.map((L,z)=>!L.percent||L.percent<=0?null:p.jsx(Qn.div,{initial:{width:0},animate:{width:`${L.percent}%`},transition:{duration:.5,delay:.1+z*.04,ease:[.16,1,.3,1]},className:"h-full",style:{backgroundColor:L.color},title:`${__(L.key)}: ${L.percent}%`},L.key))}),p.jsxs("ul",{className:"mt-3 space-y-1",children:[B.map(L=>{const z=L.key==="system_prompt",I=L.key==="messages",V=L.key==="tool_calls",W=L.key==="custom_agents";L.key;const X=I&&P.length>0||V&&(R?.categories?.length>0||A)||W&&N&&k,J=!!h[L.key],F=p.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0",style:{backgroundColor:L.color},"aria-hidden":"true"}),G=z?p.jsxs("span",{className:"relative inline-flex shrink-0 group",children:[p.jsx(z3,{size:11,className:"text-oai-gray-400 dark:text-oai-gray-500 cursor-help","aria-hidden":"true"}),p.jsx("span",{role:"tooltip",className:"pointer-events-none absolute left-1/2 bottom-full z-20 mb-1.5 -translate-x-1/2 w-64 rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-white dark:bg-oai-gray-900 px-2.5 py-1.5 text-[11px] leading-snug text-oai-gray-700 dark:text-oai-gray-200 shadow-md opacity-0 group-hover:opacity-100 transition-opacity",children:O("dashboard.context_breakdown.system_prefix_tooltip")})]}):null,Y=L.percent>0?`${L.percent.toFixed(L.percent<.1&&L.percent>0?2:1)}%`:"0.0%";return p.jsxs(Md,{level:0,colorSquare:F,label:__(L.key),labelSuffix:G,tokens:Lc(L.totals?.total_tokens||0),percent:Y,hasChevron:X,open:J,onToggle:()=>g(L.key),children:[I&&p.jsx("ul",{className:"space-y-0.5",children:P.map(H=>p.jsx(Md,{level:1,label:Toe(H),tokens:Lc(H.totals.total_tokens||0),percent:null},H.key||H.name))}),V&&R&&p.jsx(DR,{toolSet:R,execDetails:M,source:n,codexQueueFallback:A}),V&&A&&!R&&p.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:O("dashboard.context_breakdown.tool_details.unavailable_codex")}),W&&k&&p.jsx(DR,{toolSet:k,execDetails:null,source:n,codexQueueFallback:!1})]},L.key)}),T.length>0&&p.jsx(Md,{level:0,colorSquare:p.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:O("dashboard.context_breakdown.category.skills"),tokens:Lc(T.reduce((L,z)=>L+(z.total_tokens||0),0)),percent:null,hasChevron:!0,open:!!h.skills,onToggle:()=>g("skills"),children:p.jsx("ul",{className:"space-y-0.5",children:T.slice(0,12).map(L=>p.jsx(Md,{level:1,label:L.name,tokens:Lc(L.total_tokens),percent:null},L.name))})})]}),p.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:O(Roe(n))}),A?p.jsx("p",{className:"mt-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:O("dashboard.context_breakdown.tool_details.unavailable_codex")}):null,E?p.jsxs("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:[Ma(E.skills_count||0)," skills ·"," ",Ma(E.mcp_servers_count||0)," MCP servers ·"," ",Ma(E.custom_agents_count||0)," agents ·"," ",Ma(E.memory_files_count||0)," memory files"]}):null]})}function IF(t){if(!Number.isFinite(Number(t)))return null;const e=Number(t);return e<=0?null:Ma(e,{decimals:1})}function OF(t){const e=Number(t);return!Number.isFinite(e)||e<=0?null:e<.01?"<$0.01":Uy(e.toFixed(2),{decimals:2})}function Loe(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?{key:e,label:LR(e)}:{key:e.key,label:e.label||LR(e.key)}):[]}function Ioe(t){if(typeof t!="string")return null;const e=t.replace(/,/g,"").match(/-?\d+(?:\.\d+)?/);if(!e)return null;const n=Number(e[0]);return Number.isFinite(n)?n:null}const Ooe={CODEX:"#10b981",CLAUDE:"#8b5cf6",OPENCODE:"#f59e0b",GEMINI:"#3b82f6",KIMI:"#a78bfa"};function w_(t,e){const n=t?.toUpperCase?.()||"";return Ooe[n]||`hsl(${150+e*40}, 60%, 45%)`}function Foe(t){const e=String(t?.source||"").trim().toLowerCase(),n=String(t?.label||"").trim().toLowerCase();return e==="claude"||n==="claude"?"claude":e==="codex"||n==="codex"?"codex":null}const Uoe={day:"usage.period.day",week:"usage.period.week",month:"usage.period.month",total:"usage.period.total",custom:"usage.period.custom"};function LR(t){const e=Uoe[t];return e?O(e):String(t).toUpperCase()}function joe({loading:t,onClick:e}){const n=cu();return p.jsx(Ui,{variant:"secondary",size:"sm",disabled:t,onClick:e,"aria-label":O("usage.button.refresh"),className:"w-8 p-0",children:p.jsx(Qn.span,{"aria-hidden":"true",animate:t?{rotate:360}:{rotate:0},transition:t&&!n?{duration:1,repeat:1/0,ease:"linear"}:{duration:.3},style:{display:"inline-block"},children:"↻"})})}function Boe({period:t,periods:e,onPeriodChange:n,summaryValue:r,summaryLabel:i,summaryCostValue:a,onCostInfo:s,fleetData:o=[],onRefresh:c,loading:u,className:f="",customFrom:h,customTo:m,onCustomRangeApply:g,customRangeOpen:v,onCustomRangeOpenChange:w,onOpenShare:b,from:_,to:E}){const M=Loe(e),T=Ioe(String(r??"")),P=T!=null,[A,R]=x.useState(null),{resolvedTheme:k}=Op(),N=k==="dark",B=N?"rgba(10,10,10,0.98)":"rgba(255,255,255,0.96)",L=N?"rgba(10,10,10,0)":"rgba(255,255,255,0)",z=o.filter(I=>I.models?.length>0);return p.jsxs(pu,{className:f,children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 mb-6",children:[p.jsx("div",{role:"tablist","aria-label":O("usage.overview.tablist_aria"),className:"flex gap-1",children:M.map(I=>{const V=t===I.key,W=`text-xs font-medium px-3 py-1.5 rounded-md transition-colors ${V?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800"}`;if(I.key==="custom"){const X=V&&h&&m?`${AR(h)} — ${AR(m)}`:I.label;return p.jsxs(K5,{open:v,onOpenChange:J=>{J?n?.("custom"):w?.(J)},children:[p.jsx(Z5,{render:p.jsx("button",{role:"tab","aria-selected":V,type:"button",className:W}),children:X}),p.jsx(Q5,{children:p.jsx(tF,{sideOffset:8,side:"bottom",align:"start",className:"!z-[9999]",children:p.jsx(nF,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:p.jsx(Xse,{from:h,to:m,onApply:g,onCancel:()=>w?.(!1)})})})})]},"custom")}return p.jsx("button",{role:"tab","aria-selected":V,type:"button",className:W,onClick:()=>n?.(I.key),children:I.label},I.key)})}),p.jsxs("div",{className:"flex items-center gap-1.5",children:[b?p.jsxs("button",{type:"button",onClick:b,"aria-label":O("share.button.aria"),className:"inline-flex items-center justify-center gap-1.5 h-8 px-3 text-xs font-medium rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-oai-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white hover:border-oai-brand hover:text-oai-brand transition-colors duration-200",children:[p.jsx(yG,{className:"h-3.5 w-3.5",strokeWidth:2}),O("share.button.label")]}):null,c&&p.jsx(joe,{loading:u,onClick:c})]})]}),p.jsxs("div",{className:"text-center mb-8",children:[p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wider mb-3",children:i}),p.jsx("div",{className:"text-6xl md:text-7xl font-bold text-oai-black dark:text-oai-white tracking-tight tabular-nums",children:P?p.jsx(Vre,{value:T,displayValue:r,fontSize:72,padding:6,gap:1,textColor:"var(--oai-black, #111827)",fontWeight:700,gradientHeight:N?0:8,gradientFrom:B,gradientTo:L,counterStyle:{paddingLeft:0,paddingRight:0,gap:0},digitStyle:{width:"0.88ch"}}):r}),a&&p.jsx("div",{className:"flex items-center justify-center gap-2 mt-4",children:s?p.jsxs("button",{type:"button",onClick:s,className:"inline-flex items-center gap-1.5 text-xl font-bold text-oai-brand hover:text-oai-brand-dark dark:hover:text-oai-brand-light transition-colors cursor-pointer","aria-label":O("usage.overview.cost_breakdown_aria"),children:[a,p.jsx(z3,{size:16,strokeWidth:2,className:"opacity-80"})]}):p.jsx("span",{className:"text-xl font-bold text-oai-brand",children:a})})]}),z.length>0&&p.jsxs("div",{className:"space-y-6",children:[p.jsx("div",{role:"img","aria-label":O("usage.overview.distribution_aria",{items:z.map(I=>O("usage.overview.distribution_item",{label:I.label,percent:I.totalPercent})).join(",")}),className:"h-1.5 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden flex",children:z.map((I,V)=>{const W=w_(I.label,V);return p.jsx(Qn.div,{initial:{width:0},animate:{width:`${I.totalPercent}%`},transition:{duration:.5,delay:.45+V*.04,ease:[.16,1,.3,1]},className:"h-full",style:{backgroundColor:W},title:`${I.label}: ${I.totalPercent}%`},I.label)})}),p.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 xl:grid-cols-5 gap-3",children:z.map((I,V)=>{const W=w_(I.label,V),X=A===I.label;return p.jsxs("button",{"aria-expanded":X,"aria-controls":`provider-details-${I.label}`,"aria-label":O("usage.overview.provider_card_aria",{provider:I.label,percent:I.totalPercent,tokens:IF(I.usage)||"0",cost:OF(I.usd)||"$0",action:O(X?"usage.overview.collapse":"usage.overview.expand")}),onClick:()=>R(X?null:I.label),className:`min-w-0 text-left p-3 rounded-lg border transition-colors duration-200 ${X?"border-oai-gray-300 dark:border-oai-gray-600 bg-oai-gray-50 dark:bg-oai-gray-800":"border-oai-gray-200 dark:border-oai-gray-700 hover:border-oai-gray-300 dark:hover:border-oai-gray-600"}`,children:[p.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[p.jsx(nu,{provider:I.label,size:15,color:W,className:"text-oai-gray-700 dark:text-oai-gray-300 shrink-0"}),p.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:I.label})]}),p.jsxs("div",{className:"text-lg font-semibold text-oai-black dark:text-oai-white tabular-nums",children:[I.totalPercent,"%"]}),p.jsx("div",{className:"mt-0.5 text-[11px] text-oai-gray-400 dark:text-oai-gray-400 tabular-nums",children:O("usage.overview.model_count",{count:I.models.length})})]},I.label)})}),A&&p.jsx("div",{id:`provider-details-${A}`,role:"region","aria-label":O("usage.overview.model_details_aria",{provider:A}),className:"mt-2",children:z.filter(I=>I.label===A).map(I=>{const V=w_(I.label,0),W=Foe(I),X=[...I.models].sort((F,G)=>(G.share||0)-(F.share||0)),J=W?`${W==="claude"?"Claude":"Codex"} Context Breakdown`:I.label;return p.jsx(zoe,{provider:I,color:V,providerHeading:J,contextSource:W,from:_,to:E,sortedModels:X},I.label)})})]})]})}function zoe({provider:t,color:e,providerHeading:n,contextSource:r,from:i,to:a,sortedModels:s}){const[o,c]=x.useState(!1);return p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-1.5 mb-3",children:[p.jsx(nu,{provider:t.label,size:14,color:e,className:"shrink-0"}),p.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:n}),r&&o&&p.jsx(Ao,{size:12,className:"text-oai-gray-400 dark:text-oai-gray-500 animate-spin shrink-0","aria-label":O("dashboard.context_breakdown.loading_aria")})]}),r?p.jsx("div",{className:"mb-4 pb-4 border-b border-oai-gray-200 dark:border-oai-gray-700",children:p.jsx(Doe,{from:i,to:a,source:r,referenceTotalTokens:t.usage,onLoadingChange:c})}):null,p.jsx("div",{className:"space-y-3",children:s.map(u=>{const f=IF(u.usage),h=OF(u.cost),m=Math.max(0,Math.min(100,Number(u.share)||0));return p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-baseline gap-4 mb-1.5",children:[p.jsx("span",{className:"flex-1 min-w-0 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate",title:u.name,children:u.name}),p.jsx("span",{className:"shrink-0 w-16 text-right text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:f}),p.jsx("span",{className:"shrink-0 w-16 text-right text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:h}),p.jsxs("span",{className:"shrink-0 w-12 text-right text-sm text-oai-black dark:text-oai-white tabular-nums",children:[u.share,"%"]})]}),p.jsx("div",{className:"h-[3px] bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden",role:"progressbar","aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:p.jsx("div",{className:"h-full transition-[width] duration-500 ease-out",style:{width:`${m}%`,backgroundColor:e,opacity:.45}})})]},u.id||u.name)})})]})}function IR(t,e){if(!Array.isArray(t)||t.length===0)return 0;if(t.length===1)return t[0];const n=(t.length-1)*e,r=Math.floor(n),i=Math.ceil(n);if(r===i)return t[r];const a=n-r;return t[r]+(t[i]-t[r])*a}function Voe(t){const e=Array.isArray(t)?t.filter(i=>Number.isFinite(i)&&i>0).sort((i,a)=>i-a):[];if(e.length===0)return{rawMax:0,effectiveMax:1,clippedValues:Array.isArray(t)?t.map(()=>0):[]};const n=e.at(-1)??0;let r=n;if(e.length>=4){const i=IR(e,.25),a=IR(e,.75),s=Math.max(a-i,0),o=a+s*1.5;n>o&&(r=Math.max(o,a,1))}return{rawMax:n,effectiveMax:Math.max(r,1),clippedValues:Array.isArray(t)?t.map(i=>!Number.isFinite(i)||i<=0?0:Math.min(i,Math.max(r,1))):[]}}function Hoe({value:t,displayValue:e,scale:n,index:r,row:i,totalBars:a}){const s=cu(),o=n.effectiveMax>0?e/n.effectiveMax*100:0,c=`${Math.max(o,2)}%`,u=i?.missing,f=i?.future,h=a<=7?"6px":a<=14?"4px":"3px";return p.jsx(Qn.div,{className:"group relative flex-1 self-stretch",initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},transition:{duration:s?0:.3,delay:s?0:.4+r*.008,ease:[.16,1,.3,1]},style:{originY:1},children:p.jsxs("div",{className:"absolute inset-x-0 bottom-0",style:{height:c},children:[p.jsx("div",{"data-trend-bar":"true",className:"h-full w-full cursor-pointer transition-all duration-200 group-hover:brightness-110",style:{minHeight:t>0?"4px":"2px",opacity:u||f?.2:1,borderRadius:`${h} ${h} 0 0`,background:t>0?"#10b981":"var(--oai-gray-100)"},title:`${t.toLocaleString()}`}),p.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-oai-black text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-20",children:t.toLocaleString()})]})})}function Woe({rows:t,from:e,to:n,period:r,timeZoneLabel:i,showTimeZoneLabel:a=!0,className:s=""}){const o=Array.isArray(t)&&t.length?t:[],c=o.map(f=>{if(f?.missing||f?.future)return 0;const h=f?.billable_total_tokens??f?.total_tokens??f?.value;if(h==null)return 0;const m=Number(h);return Number.isFinite(m)?m:0}),u=Voe(c);return p.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5 ${s}`,children:[p.jsxs("div",{className:"mb-3",children:[p.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:O("trend.monitor.label")}),a&&i&&p.jsx("p",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:i})]}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"relative",children:[p.jsx("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none",children:[0,25,50,75,100].map(f=>p.jsx("div",{className:"w-full border-t border-oai-gray-100 dark:border-oai-gray-800",style:{top:`${100-f}%`}},f))}),p.jsx("div",{className:"h-40 flex items-end gap-1 relative z-0",children:c.length>0?c.map((f,h)=>p.jsx(Hoe,{value:f,displayValue:u.clippedValues[h]??0,scale:u,index:h,row:o[h],totalBars:c.length},h)):p.jsx("div",{className:"flex-1 h-full flex items-center justify-center",children:p.jsx("p",{className:"text-sm text-oai-gray-400 dark:text-oai-gray-400",children:"No data yet"})})})]}),e&&n&&p.jsxs("div",{className:"flex justify-between text-xs text-oai-gray-500 dark:text-oai-gray-300 font-medium pt-2 border-t border-oai-gray-100 dark:border-oai-gray-800",children:[p.jsx("span",{children:e}),p.jsx("span",{children:n})]})]})]})}function _o({children:t,delay:e=0,duration:n=.35,y:r=12,className:i="",once:a=!0}){return cu()?p.jsx("div",{className:i,children:t}):p.jsx(Qn.div,{initial:{opacity:0,y:r},animate:{opacity:1,y:0},transition:{duration:n,delay:e,ease:[.16,1,.3,1]},className:i,children:t})}function Goe({children:t,staggerDelay:e=.1,initialDelay:n=0,className:r=""}){return cu()?p.jsx("div",{className:r,children:t}):p.jsx(Qn.div,{initial:"hidden",animate:"visible",variants:{hidden:{},visible:{transition:{staggerChildren:e,delayChildren:n}}},className:r,children:t})}function $oe({children:t,className:e="",y:n=12}){return cu()?p.jsx("div",{className:e,children:t}):p.jsx(Qn.div,{variants:{hidden:{opacity:0,y:n},visible:{opacity:1,y:0,transition:{duration:.35,ease:[.16,1,.3,1]}}},className:e,children:t})}const OR={"idle-living":"idle/living.svg","idle-doze":"idle/doze.svg","idle-follow":"idle/follow.svg","idle-look":"idle/look.svg","idle-yawn":"idle/yawn.svg","idle-collapse":"idle/collapse.svg","working-building":"working/building.svg","working-carrying":"working/carrying.svg","working-conducting":"working/conducting.svg","working-confused":"working/confused.svg","working-debugger":"working/debugger.svg","working-juggling":"working/juggling.svg","working-overheated":"working/overheated.svg","working-pushing":"working/pushing.svg","working-sweeping":"working/sweeping.svg","working-thinking":"working/thinking.svg","working-typing":"working/typing.svg","working-ultrathink":"working/ultrathink.svg","working-wizard":"working/wizard.svg","mini-alert":"mini/alert.svg","mini-crabwalk":"mini/crabwalk.svg","mini-enter":"mini/enter.svg","mini-enter-sleep":"mini/enter-sleep.svg","mini-happy":"mini/happy.svg","mini-idle":"mini/idle.svg","mini-peek":"mini/peek.svg","mini-sleep":"mini/sleep.svg","react-double":"react/double.svg","react-drag":"react/drag.svg","react-left":"react/left.svg","react-right":"react/right.svg","collapse-sleep":"sleep/collapse-sleep.svg",sleeping:"sleep/sleeping.svg",wake:"sleep/wake.svg",disconnected:"status/disconnected.svg",error:"status/error.svg",notification:"status/notification.svg",happy:"happy.svg","static-base":"static-base.svg"},S_=new Map;async function Yoe(t){if(S_.has(t))return S_.get(t);const e=await fetch(`/clawd/${t}`);if(!e.ok)return null;const r=(await e.text()).replace(/<svg([^>]*)>/,(i,a)=>`<svg${a.replace(/\s+width="[^"]*"/g,"").replace(/\s+height="[^"]*"/g,"")} width="100%" height="100%">`);return S_.set(t,r),r}function qoe({state:t="idle-living",size:e=48,className:n=""}){const[r,i]=x.useState(""),a=x.useRef(null),o=Xoe()?"static-base":t,c=OR[o]||OR["static-base"];return x.useEffect(()=>{let u=!1;return Yoe(c).then(f=>{!u&&f&&i(f)}),()=>{u=!0}},[c]),x.useEffect(()=>{const u=a.current?.querySelector("svg");if(u)try{const f=u.getBBox();f.width>0&&f.height>0&&u.setAttribute("viewBox",`${f.x-2} ${f.y-2} ${f.width+4} ${f.height+4}`)}catch{}},[r]),p.jsx("div",{ref:a,className:`clawd-animated ${n}`,style:{width:e,height:e,display:"inline-flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},dangerouslySetInnerHTML:{__html:r}})}function Xoe(){const[t,e]=x.useState(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return x.useEffect(()=>{const n=window.matchMedia("(prefers-reduced-motion: reduce)"),r=i=>e(i.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}function Koe({todayTokens:t=0,isSyncing:e=!1,hasError:n=!1,isDisconnected:r=!1}={}){return x.useMemo(()=>n?"error":r?"disconnected":e?"working-typing":t===0?"sleeping":t<5e4?"idle-living":t<2e5?"idle-look":t<5e5?"working-ultrathink":t<2e6?"working-typing":"working-ultrathink",[t,e,n,r])}const FR="macAppBannerDismissed",Zoe="leaderboardBannerDismissed",Joe="https://github.com/mm7894215/TokenTracker/releases/latest",UR="tokentracker_native_app",Tg=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(UR,"1"),!0):localStorage.getItem(UR)==="1"}catch{return!1}})();function Qoe({todayTokens:t=0,isSyncing:e=!1,enterDelay:n=0}){const{openLoginModal:r}=Cp(),{signedIn:i}=ls(),a=Koe({todayTokens:t,isSyncing:e}),s=Tg?Zoe:FR,[o,c]=x.useState(()=>{try{return localStorage.getItem(s)==="1"?!0:!Tg&&new URLSearchParams(window.location.search).get("from")==="menubar"?(localStorage.setItem(FR,"1"),!0):!1}catch{return!1}}),u=x.useCallback(()=>{c(!0);try{localStorage.setItem(s,"1")}catch{}},[s]);if(o)return null;let f,h,m,g,v,w;Tg&&i?(f="View the Leaderboard",h="Compare your usage globally",m="Leaderboard",g=p.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:p.jsx("path",{d:"M2 8.5V10h8V8.5M6 1.5v6m0 0L3.5 5M6 7.5l2.5-2.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(180 6 6)"})}),v=()=>{window.location.pathname="/leaderboard"}):Tg?(f="Join the Leaderboard",h="Log in to compare your usage with others",m="Log In",g=p.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:p.jsx("path",{d:"M6.5 1.5h3a1 1 0 011 1v7a1 1 0 01-1 1h-3M5 8.5L7.5 6 5 3.5M7.5 6H1.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),v=r):(f="Try the Menu Bar App",h="Always-on stats with Clawd companion",m="Download",g=p.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:p.jsx("path",{d:"M6 2v6m0 0L3.5 5.5M6 8l2.5-2.5M2 10h8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),w=Joe);const b=w?Qn.a:Qn.button,_=w?{href:w,target:"_blank",rel:"noopener noreferrer"}:{onClick:v};return p.jsx(Qn.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,delay:n,ease:[.16,1,.3,1]},className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4",children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:"flex-shrink-0",children:p.jsx(qoe,{state:a,size:56})}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:"text-sm font-medium text-oai-gray-900 dark:text-oai-white",children:f}),p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-0.5",children:h})]}),p.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[p.jsxs(b,{..._,whileHover:{scale:1.03},whileTap:{scale:.97},className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-oai-gray-900 dark:bg-oai-white dark:text-oai-gray-900 rounded-md hover:opacity-90 transition-opacity",children:[m,g]}),p.jsx("button",{onClick:u,className:"p-1 text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-300 transition-colors","aria-label":"Dismiss",children:p.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:p.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})})]})]})})}const jR="widgetOnboardingDismissed",BR="tokentracker_native_app",ele=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(BR,"1"),!0):localStorage.getItem(BR)==="1"}catch{return!1}})();function tle({enterDelay:t=0}){const[e,n]=x.useState(()=>{try{return localStorage.getItem(jR)==="1"}catch{return!1}}),r=x.useCallback(()=>{n(!0);try{localStorage.setItem(jR,"1")}catch{}},[]);return ele?p.jsx(Lp,{initial:!1,children:!e&&p.jsxs(Qn.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-8,transition:{duration:.2,ease:[.4,0,.2,1]}},transition:{duration:.35,delay:t,ease:[.16,1,.3,1]},className:"relative rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4",children:[p.jsx("button",{type:"button",onClick:r,"aria-label":O("dashboard.widgets.dismiss_aria"),className:"absolute top-2.5 right-2.5 z-10 inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-300 dark:focus-visible:ring-oai-gray-600 transition-colors",children:p.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:p.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}),p.jsx("div",{className:"rounded-lg overflow-hidden ring-1 ring-black/5 dark:ring-white/10 shadow-sm",children:p.jsx("img",{src:"/widgets-overview.png",alt:O("dashboard.widgets.title"),width:734,height:552,className:"w-full h-auto block",loading:"lazy",decoding:"async"})}),p.jsxs("div",{className:"mt-4",children:[p.jsx("div",{className:"text-sm font-medium tracking-tight text-oai-gray-900 dark:text-oai-white",children:O("dashboard.widgets.title")}),p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1 leading-snug",children:O("dashboard.widgets.hint")})]})]},"widget-onboarding-card")}):null}function nle(t){const{copy:e,onOpenShare:n,screenshotMode:r,showExpiredGate:i,showAuthGate:a,screenshotTitleLine1:s,screenshotTitleLine2:o,identityDisplayName:c,identityStartDate:u,activeDays:f,identitySubscriptions:h,identityScrambleDurationMs:m,projectUsageEntries:g,projectUsageLimit:v,setProjectUsageLimit:w,topModels:b,signedIn:_,publicMode:E,isLocalMode:M,shouldShowInstall:T,installPrompt:P,handleCopyInstall:A,installCopied:R,installInitCmdDisplay:k,trendRowsForDisplay:N,trendFromForDisplay:B,trendToForDisplay:L,usageFrom:z,usageTo:I,period:V,trendTimeZoneLabel:W,activityHeatmapBlock:X,isCapturing:J,handleShareToX:F,screenshotTwitterButton:G,screenshotTwitterHint:Y,periodsForDisplay:H,setSelectedPeriod:te,customFrom:re,customTo:ue,onCustomRangeApply:ce,customRangeOpen:ee,onCustomRangeOpenChange:le,summaryLabel:ve,summaryValue:Ne,summaryTotalTokensRaw:be,summaryCostValue:qe,summaryConversationsValue:he,rollingUsage:Ue,costInfoEnabled:je,openCostModal:et,costModalOpen:_e,closeCostModal:oe,allowBreakdownToggle:Q,refreshAll:ze,usageLoadingState:Pe,fleetData:De,hasDetailsActual:Le,dailyEmptyPrefix:$,installSyncCmd:U,dailyEmptySuffix:Z,detailsColumns:pe,ariaSortFor:Se,toggleSort:xe,sortIconFor:Ie,pagedDetails:He,dailyBreakdownRows:Ye,dailyBreakdownColumns:ft,dailyBreakdownAriaSortFor:We,dailyBreakdownSortIconFor:Xe,dailyBreakdownDateKey:nt,detailsDateKey:ct,renderDetailDate:Ke,renderDailyBreakdownDate:gt,renderDetailCell:ne,DETAILS_PAGED_PERIODS:Be,detailsPageCount:ke,detailsPage:Ae,setDetailsPage:Ve}=t,ge=null,ut=null,yt=.06,qt=.05,Lt=.11;let _t=0;const wt=()=>Lt+yt*_t++,un=Lt+yt*5;return p.jsxs(p.Fragment,{children:[p.jsx(sre,{bare:!r,hideHeader:r,header:ge,footer:r?null:ut,className:r?"screenshot-mode":"",children:i||a?null:p.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4",children:[p.jsxs("div",{className:"lg:col-span-4 flex flex-col gap-4 min-w-0 order-2 lg:order-1",children:[r?p.jsx("div",{className:"flex items-start justify-between gap-4",children:p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-3xl md:text-4xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:s}),p.jsx("span",{className:"text-2xl md:text-3xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:o})]})}):null,M?p.jsx(Qoe,{todayTokens:be,isSyncing:Pe,enterDelay:wt()}):null,p.jsx(_o,{delay:wt(),children:p.jsx(Yre,{title:e("dashboard.identity.title"),subtitle:e("dashboard.identity.subtitle"),period:V,rankLabel:u??e("identity_card.rank_placeholder"),streakDays:f,subscriptions:h,periodConversations:he,rolling:Ue,topModels:b})}),M?p.jsx(tle,{enterDelay:wt()}):null,T?p.jsx(_o,{delay:wt(),children:p.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-3",children:[p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 mb-1.5",children:P}),p.jsxs(Qn.button,{onClick:A,whileHover:{scale:1.01},whileTap:{scale:.99},className:"w-full flex items-center justify-between px-3 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-700 rounded-lg transition-colors",children:[p.jsx("code",{className:"text-xs font-mono text-oai-gray-700 dark:text-oai-gray-300",children:k}),p.jsx(Qn.span,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},className:"text-xs text-oai-brand",children:R?"Copied ✓":"Copy"},R?"copied":"copy")]})]})}):null,X&&p.jsx(_o,{delay:wt(),children:X}),r?null:p.jsx(_o,{delay:wt(),children:p.jsx(Woe,{rows:N,from:B,to:L,period:V,timeZoneLabel:W,showTimeZoneLabel:!1})}),r?p.jsxs("div",{className:"mt-4 flex flex-col items-center gap-2","data-screenshot-exclude":"true",style:J?{display:"none"}:void 0,children:[p.jsx(Ui,{type:"button",onClick:F,variant:"primary",size:"lg",disabled:J,children:G}),p.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300",children:Y})]}):null]}),p.jsxs("div",{className:"lg:col-span-8 flex flex-col gap-4 min-w-0 order-1 lg:order-2",children:[p.jsx(_o,{delay:qt,children:p.jsx(Boe,{period:V,periods:H,onPeriodChange:te,summaryLabel:ve,summaryValue:Ne,summaryCostValue:qe,onCostInfo:je?et:null,fleetData:De,onRefresh:r?null:ze,loading:Pe,onOpenShare:r?null:n,customFrom:re,customTo:ue,onCustomRangeApply:ce,customRangeOpen:ee,onCustomRangeOpenChange:le,from:z,to:I})}),r?null:p.jsx(_o,{delay:un,children:p.jsx(Gre,{projectEntries:g,projectLimit:v,onProjectLimitChange:w,copy:e,hasDetailsActual:Le,dailyEmptyPrefix:$,installSyncCmd:U,dailyEmptySuffix:Z,detailsColumns:pe,ariaSortFor:Se,toggleSort:xe,sortIconFor:Ie,pagedDetails:He,dailyBreakdownRows:Ye,dailyBreakdownColumns:ft,dailyBreakdownAriaSortFor:We,dailyBreakdownSortIconFor:Xe,dailyBreakdownDateKey:nt,detailsDateKey:ct,renderDetailDate:Ke,renderDailyBreakdownDate:gt,renderDetailCell:ne,DETAILS_PAGED_PERIODS:Be,period:V,detailsPageCount:ke,detailsPage:Ae,setDetailsPage:Ve})})]})]})}),p.jsx(Wre,{isOpen:_e,onClose:oe,fleetData:De})]})}function FF(){return typeof window>"u"?!1:!!window?.webkit?.messageHandlers?.nativeBridge}const Ic=new Map,Oc=new Map;function UF(){typeof window>"u"||window.__tokentrackerNativeSaveListener||(window.__tokentrackerNativeSaveListener=!0,window.addEventListener("native:saveImageResult",t=>{const e=t?.detail||{},n=typeof e.requestId=="string"?e.requestId:null;if(!n||!Ic.has(n))return;const r=Ic.get(n);Ic.delete(n),r({ok:!!e.ok,path:typeof e.path=="string"?e.path:void 0,error:typeof e.error=="string"?e.error:void 0})}),window.addEventListener("native:copyImageResult",t=>{const e=t?.detail||{},n=typeof e.requestId=="string"?e.requestId:null;if(!n||!Oc.has(n))return;const r=Oc.get(n);Oc.delete(n),r({ok:!!e.ok,error:typeof e.error=="string"?e.error:void 0})}))}async function rle(t){if(!FF()||typeof window>"u")return{ok:!1,error:"native bridge unavailable"};const e=window?.webkit?.messageHandlers?.nativeBridge;if(!e)return{ok:!1,error:"native bridge unavailable"};UF();const n=`copy_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return new Promise(r=>{const i=window.setTimeout(()=>{Oc.has(n)&&(Oc.delete(n),r({ok:!1,error:"timeout"}))},8e3);Oc.set(n,a=>{window.clearTimeout(i),r(a)});try{e.postMessage({type:"action",name:"copyImageToClipboard",requestId:n,dataUrl:t})}catch(a){Oc.delete(n),window.clearTimeout(i),r({ok:!1,error:a?.message||String(a)})}})}async function zR(t,e){if(!FF()||typeof window>"u")return{ok:!1,error:"native bridge unavailable"};const n=window?.webkit?.messageHandlers?.nativeBridge;if(!n)return{ok:!1,error:"native bridge unavailable"};UF();const r=`save_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return new Promise(i=>{const a=window.setTimeout(()=>{Ic.has(r)&&(Ic.delete(r),i({ok:!1,error:"timeout"}))},8e3);Ic.set(r,s=>{window.clearTimeout(a),i(s)});try{n.postMessage({type:"action",name:"saveImageToDownloads",requestId:r,filename:e,dataUrl:t})}catch(s){Ic.delete(r),window.clearTimeout(a),i({ok:!1,error:s?.message||String(s)})}})}const jF=1200,BF=1630,zF={broadsheet:{width:1200,height:1630},"annual-report":{width:1080,height:1865}},ile="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter+Tight:wght@400;500;600;700&family=IBM+Plex+Serif:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&family=Space+Grotesk:wght@500;600;700&display=swap";let k_=!1;function ale(){if(typeof document>"u"||k_)return;if(document.querySelector('link[data-share-card-fonts="true"]')){k_=!0;return}const e=document.createElement("link");e.rel="stylesheet",e.href=ile,e.dataset.shareCardFonts="true",e.crossOrigin="anonymous",document.head.appendChild(e),k_=!0}async function sle(){if(typeof document>"u")return;const t=document.fonts;if(!(!t||typeof t.ready?.then!="function"))try{await t.ready}catch{}}async function ole(t,e={}){if(typeof window>"u"||!t)return null;ale(),await sle(),await new Promise(c=>requestAnimationFrame(()=>c(null)));const{toBlob:n,toPng:r}=await t4(async()=>{const{toBlob:c,toPng:u}=await import("./index-BeoRn2gJ.js");return{toBlob:c,toPng:u}},[]),i=e.pixelRatio??2,a=t.offsetWidth||jF,s=t.offsetHeight||BF,o={pixelRatio:i,cacheBust:!0,width:a,height:s,style:{width:`${a}px`,height:`${s}px`},skipFonts:!1,filter:c=>!(c instanceof HTMLElement)||c.dataset?.screenshotExclude!=="true"};try{const c=await n(t,o);if(c)return c}catch{}try{const c=await r(t,o);return c?await(await fetch(c)).blob():null}catch{return null}}async function E_(t){return new Promise(e=>{const n=new FileReader;n.onload=()=>{const r=typeof n.result=="string"?n.result:null;e(r)},n.onerror=()=>e(null),n.readAsDataURL(t)})}function VR(t,e){if(typeof window>"u"||!t)return!1;try{const n=URL.createObjectURL(t),r=document.createElement("a");return r.href=n,r.download=e,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3),!0}catch{return!1}}function I1(t){const e=ti(t);return Number.isFinite(e)?e:0}function lle(t){return t?I1(t.billable_total_tokens??t.total_tokens):0}function cle(t){const e=Array.isArray(t?.weeks)?t.weeks:[];if(!e.length)return{weeks:[],totalDays:0,activeDays:0};let n=0,r=0;return{weeks:e.map(a=>(Array.isArray(a)?a:[]).slice(0,7).map(o=>{const c=!!o?.future,u=Number.isFinite(o?.level)?Math.max(0,Math.min(4,Math.round(o.level))):0;o?.day&&!c&&(n+=1,u>0&&(r+=1));const f=o?.billable_total_tokens??o?.total_tokens??o?.value??0,h=Number.isFinite(f)?Math.max(0,f):0;return{day:typeof o?.day=="string"?o.day:"",level:u,value:h,future:c}})),totalDays:n,activeDays:r}}function ule(t){const{handle:e,startDate:n,activeDays:r,summary:i,topModels:a,rank:s,period:o,periodFrom:c,periodTo:u,heatmap:f,capturedAt:h}=t,m=lle(i),g=I1(i?.total_cost_usd),v=Array.isArray(a)?a.slice(0,3).map(b=>({id:b?.id??null,name:typeof b?.name=="string"&&b.name?b.name:"—",tokens:I1(b?.tokens),percent:typeof b?.percent=="string"&&b.percent?b.percent:"0.0"})):[],w=cle(f);return{handle:e||"—",startDate:n||null,activeDays:Number.isFinite(r)&&r>0?Math.floor(r):0,totalTokens:m,totalCost:g,period:o,periodFrom:c,periodTo:u,topModels:v,rank:typeof s=="number"&&Number.isFinite(s)&&s>0?Math.floor(s):null,heatmapWeeks:w.weeks,heatmapTotalDays:w.totalDays,heatmapActiveDays:w.activeDays,capturedAt:h||new Date().toISOString()}}const dle=["share.month_short.jan","share.month_short.feb","share.month_short.mar","share.month_short.apr","share.month_short.may","share.month_short.jun","share.month_short.jul","share.month_short.aug","share.month_short.sep","share.month_short.oct","share.month_short.nov","share.month_short.dec"];function fle(t){const e=dle[t];return e?O(e):"—"}function VF(t,e){return O("share.date.month_year",{month:fle(t),year:e})}function hle(t){if(!t)return"—";const e=t.split("-");if(e.length!==3)return t;const[n,r]=e,i=Number(r)-1;return i<0||i>11?t:VF(i,n)}function ple(t){if(t.period==="total")return O("share.issue.all_time");if(t.period==="day"&&t.periodTo)return t.periodTo.replace(/-/g,".");if(t.period==="custom"&&t.periodFrom&&t.periodTo)return`${t.periodFrom.replace(/-/g,".")} — ${t.periodTo.replace(/-/g,".")}`;if(t.periodTo){const e=new Date(`${t.periodTo}T00:00:00Z`);if(!Number.isNaN(e.getTime()))return VF(e.getUTCMonth(),e.getUTCFullYear())}return O(`usage.period.${t.period}`)}function O1(t){return Number.isFinite(t)?Math.round(t).toLocaleString("en-US"):"—"}function HF(t){return!Number.isFinite(t)||t<=0?"$0.00":t>=1e3?`$${Math.round(t).toLocaleString("en-US")}`:`$${t.toFixed(2)}`}function mle(t){const e=t.topModels[0];if(e){const n=parseFloat(e.percent);return Number.isFinite(n)&&n>=60?O("share.hook.top_loyal",{percent:Math.round(n),name:e.name}):t.activeDays>=60?O("share.hook.days_record",{days:t.activeDays}):Number.isFinite(n)&&n>=30?O("share.hook.top_led",{name:e.name,percent:Math.round(n)}):t.topModels.length>1?O("share.hook.multi_models",{count:t.topModels.length,days:t.activeDays}):O("share.hook.days_with_model",{days:t.activeDays,name:e.name})}return t.activeDays>0?O("share.hook.days_record",{days:t.activeDays}):O("share.hook.new_chapter")}function gle(t,e){const n=(t||"").length;if(n<=e.baseChars)return e.baseSize;const r=e.baseSize-(n-e.baseChars)*e.shrinkPerChar;return Math.max(e.minSize,r)}function yle(t){if(!t||t.future)return null;const e=typeof t.level=="number"?t.level:0;return e<0?0:e>4?4:Math.round(e)}function vle({weeks:t,palette:e,width:n,gap:r=3,radius:i=2,emptyColor:a}){if(!Array.isArray(t)||t.length===0||!n||n<=0)return null;const s=e||["#eee","#ccc","#999","#666","#333"],o=a||s[0],c=t.length,u=(c-1)*r,f=Math.max(4,(n-u)/c),h=7*f+6*r;return p.jsx("svg",{width:n,height:h,viewBox:`0 0 ${n} ${h}`,xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,style:{display:"block"},children:t.map((m,g)=>(Array.isArray(m)?m:[]).map((w,b)=>{if(b>=7)return null;const _=yle(w),E=g*(f+r),M=b*(f+r),T=_===null?o:s[_];return p.jsx("rect",{x:E,y:M,width:f,height:f,rx:i,ry:i,fill:T},`${g}-${b}`)}))})}const xle="oklch(0.97 0.01 85)",Ji="oklch(0.18 0.02 85)",ll="oklch(0.38 0.015 85)",HR="oklch(0.55 0.012 85)",mc="oklch(0.55 0.22 25)",gc='"Instrument Serif", "Times New Roman", Georgia, serif',ble='"Inter Tight", "Helvetica Neue", Arial, sans-serif',_le=["oklch(0.93 0.013 80)","oklch(0.87 0.04 55)","oklch(0.78 0.09 45)","oklch(0.67 0.16 35)","oklch(0.55 0.22 25)"];function WF({data:t}){const e=ple(t),n=O1(t.totalTokens),r=HF(t.totalCost),i=hle(t.startDate),a=gle(n,{baseSize:188,baseChars:9,shrinkPerChar:14,minSize:104}),s=mle(t),o=Array.isArray(t.heatmapWeeks)&&t.heatmapWeeks.length>0;return p.jsxs("div",{style:{width:"100%",height:"100%",background:xle,color:Ji,fontFamily:ble,padding:"80px 88px 68px 88px",boxSizing:"border-box",display:"flex",flexDirection:"column",position:"relative"},children:[p.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:24,paddingBottom:14,borderBottom:`1px solid ${HR}`},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,fontSize:14,fontWeight:500,letterSpacing:"0.22em",textTransform:"uppercase",color:Ji},children:[p.jsx("div",{style:{width:10,height:10,borderRadius:"50%",background:mc}}),"The Token Tracker"]}),p.jsxs("div",{style:{fontSize:12,letterSpacing:"0.22em",textTransform:"uppercase",color:ll,textAlign:"right"},children:[O("share.card.broadsheet.issue")," № ",e]})]}),p.jsxs("div",{style:{marginTop:24,display:"flex",justifyContent:"space-between",alignItems:"flex-end",gap:24},children:[p.jsxs("div",{children:[p.jsx("div",{style:{fontSize:12,letterSpacing:"0.2em",textTransform:"uppercase",color:ll,marginBottom:6},children:O("share.card.broadsheet.by")}),p.jsx("div",{style:{fontFamily:gc,fontSize:52,fontStyle:"italic",lineHeight:1,color:Ji,letterSpacing:"-0.01em"},children:t.handle})]}),p.jsxs("div",{style:{fontSize:12,letterSpacing:"0.18em",textTransform:"uppercase",color:ll,textAlign:"right",lineHeight:1.6},children:[O("share.card.broadsheet.tracked_since"),p.jsx("br",{}),p.jsx("span",{style:{color:Ji},children:i})]})]}),p.jsxs("div",{style:{marginTop:40,display:"flex",flexDirection:"column"},children:[p.jsx("div",{style:{fontSize:13,letterSpacing:"0.3em",textTransform:"uppercase",color:mc,marginBottom:10},children:O("share.card.broadsheet.total_tokens")}),p.jsx("div",{style:{fontFamily:gc,fontSize:a,fontWeight:400,lineHeight:.86,letterSpacing:"-0.032em",color:Ji,fontFeatureSettings:'"lnum" 1, "tnum" 1',whiteSpace:"nowrap",overflow:"hidden"},children:n}),p.jsxs("div",{style:{marginTop:14,fontFamily:gc,fontStyle:"italic",fontSize:34,lineHeight:1.15,color:Ji,letterSpacing:"-0.005em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:["“",s,"”"]}),p.jsx("div",{style:{marginTop:14,height:1,background:mc,width:"100%"}}),p.jsxs("div",{style:{marginTop:10,display:"flex",justifyContent:"space-between",fontSize:13,letterSpacing:"0.16em",textTransform:"uppercase",color:ll},children:[p.jsxs("span",{children:[O("share.card.broadsheet.estimated_spend")," · ",r]}),p.jsx("span",{children:O("share.card.broadsheet.billable_days",{days:t.activeDays})})]})]}),o?p.jsxs("section",{style:{marginTop:40},children:[p.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:12},children:[p.jsx("div",{style:{fontSize:12,letterSpacing:"0.3em",textTransform:"uppercase",color:Ji,fontWeight:600},children:O("share.card.broadsheet.heatmap_title")}),p.jsx("div",{style:{fontSize:11,letterSpacing:"0.18em",textTransform:"uppercase",color:ll},children:O("share.card.broadsheet.heatmap_days_on_record",{active:t.heatmapActiveDays,total:t.heatmapTotalDays})})]}),p.jsx(vle,{weeks:t.heatmapWeeks,palette:_le,width:1024,gap:3,radius:2})]}):null,p.jsxs("section",{style:{marginTop:30,flex:1},children:[p.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",borderBottom:`1px solid ${Ji}`,paddingBottom:10,marginBottom:6},children:[p.jsx("div",{style:{fontSize:12,letterSpacing:"0.3em",textTransform:"uppercase",color:Ji,fontWeight:600},children:O("share.card.broadsheet.roster_title")}),p.jsx("div",{style:{fontSize:11,letterSpacing:"0.18em",textTransform:"uppercase",color:ll},children:O("share.card.broadsheet.roster_subtitle")})]}),t.topModels.length===0?p.jsx("div",{style:{fontFamily:gc,fontStyle:"italic",fontSize:26,color:ll,paddingTop:14},children:O("share.card.broadsheet.empty")}):t.topModels.map((c,u)=>p.jsxs("div",{style:{display:"grid",gridTemplateColumns:"52px 1fr auto 68px",alignItems:"baseline",gap:16,padding:"13px 0",borderBottom:`1px solid ${HR}`},children:[p.jsx("div",{style:{fontFamily:gc,fontSize:34,fontStyle:"italic",color:mc,lineHeight:1},children:String(u+1).padStart(2,"0")}),p.jsx("div",{style:{fontFamily:gc,fontSize:32,color:Ji,lineHeight:1.1,letterSpacing:"-0.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c.name}),p.jsx("div",{style:{fontFamily:gc,fontSize:28,color:Ji,fontFeatureSettings:'"lnum" 1, "tnum" 1',whiteSpace:"nowrap"},children:O1(c.tokens)}),p.jsxs("div",{style:{fontSize:13,letterSpacing:"0.1em",color:ll,textAlign:"right",fontFeatureSettings:'"tnum" 1'},children:[c.percent,"%"]})]},c.id||c.name))]}),p.jsxs("footer",{style:{marginTop:18,paddingTop:12,borderTop:`1px solid ${Ji}`,display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:12,letterSpacing:"0.22em",textTransform:"uppercase",color:Ji},children:[p.jsxs("div",{style:{display:"flex",gap:28},children:[p.jsxs("span",{children:[O("share.card.broadsheet.global_rank")," ",p.jsxs("span",{style:{color:mc},children:["№ ",t.rank!=null?t.rank:"—"]})]}),p.jsxs("span",{children:[O("share.card.broadsheet.active_days")," ",p.jsx("span",{style:{color:mc},children:O("share.card.broadsheet.days_count",{days:t.activeDays})})]})]}),p.jsxs("div",{children:[O("share.card.broadsheet.track_yours")," ",p.jsx("span",{style:{color:mc},children:"→ tokentracker.cc"})]})]})]})}const wle=zF["annual-report"].width,Sle="#0a0820",cl="#ffffffee",Ec="rgba(255,255,255,0.45)",M_="#a78bfa",kle={background:"rgba(20,15,50,0.38)",backdropFilter:"blur(40px)",WebkitBackdropFilter:"blur(40px)",border:"1px solid rgba(255,255,255,0.05)",boxShadow:["0 39px 56px -36px rgba(255,255,255,0.10) inset","0 7px 11px -4px rgba(255,255,255,0.06) inset","0 -82px 68px -64px rgba(101,67,149,0.08) inset","0 98px 100px -48px rgba(208,171,255,0.06) inset","0 4px 18px 0 rgba(156,146,215,0.06) inset","0 1px 40px 0 rgba(228,222,255,0.04) inset"].join(", ")},Cg={background:"rgba(20,15,50,0.38)",backdropFilter:"blur(32px)",WebkitBackdropFilter:"blur(32px)",border:"1px solid rgba(255,255,255,0.06)",boxShadow:"0 1px 8px 0 rgba(228,222,255,0.06) inset"},F1='"Space Grotesk", "Inter Tight", sans-serif',T_='"Inter Tight", sans-serif',Ele="rgba(255,255,255,0.06)",GF=[Ele,"#4a3d8f","#6b5cbe","#9060e0","#d946ef"],$F=48,YF=28,vy=4,qF=20,Mle=wle-$F*2-YF*2,Tle=(Mle-qF*2)/3,U1=Math.min(Math.floor((Tle-vy*6)/7),40),Cle=U1*7+vy*6;function Ale(t){if(!Array.isArray(t))return t;const e=[];for(const o of t)if(Array.isArray(o))for(const c of o)c?.day&&!c.future&&c.value>0&&e.push(c.value);if(!e.length)return t;e.sort((o,c)=>o-c);const n=o=>{const c=e.length,u=(c-1)*o,f=Math.floor(u);return Math.round((e[f]??0)+((e[Math.min(c-1,f+1)]??0)-(e[f]??0))*(u-f))},r=n(.5),i=n(.75),a=n(.9),s=o=>!o||o<=0?0:o<=r?1:o<=i?2:o<=a?3:4;return t.map(o=>Array.isArray(o)?o.map(c=>c?.day&&!c.future&&typeof c.value=="number"?{...c,level:s(c.value)}:c):o)}function Ple(t){if(!Array.isArray(t))return[];const e={},n=Ale(t);for(const r of n)if(Array.isArray(r))for(const i of r){if(!i?.day||i.future)continue;const a=i.day.split("-");if(a.length<2)continue;const s=`${a[0]}-${a[1]}`;(e[s]??=[]).push(i)}return Object.entries(e).sort(([r],[i])=>r.localeCompare(i)).slice(-12).map(([r,i])=>({month:parseInt(r.split("-")[1],10),cells:i}))}function Rle(t){if(!t.length)return[];const e=[...t].sort((s,o)=>s.day.localeCompare(o.day));let n=new Date(`${e[0].day}T00:00:00Z`).getUTCDay();const r=Array(n).fill(null).concat(e),i=[];for(let s=0;s<r.length;s+=7)i.push(r.slice(s,s+7));const a=i[i.length-1];for(;a&&a.length<7;)a.push(null);return i.slice(0,6)}const Nle=["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Dle(t){if(!Array.isArray(t))return 0;const e=[];for(const i of t)if(Array.isArray(i))for(const a of i)a?.day&&!a.future&&e.push(a);e.sort((i,a)=>i.day.localeCompare(a.day));let n=0,r=0;for(const i of e)(i.level||0)>0?(r++,r>n&&(n=r)):r=0;return n}function WR(t){const[e,n]=x.useState(null);return x.useEffect(()=>{if(!t){n(null);return}let r=!1;const i=new Image;return i.crossOrigin="anonymous",i.onload=()=>{if(!r)try{const a=document.createElement("canvas");a.width=i.naturalWidth,a.height=i.naturalHeight,a.getContext("2d").drawImage(i,0,0),n(a.toDataURL("image/png"))}catch{n(null)}},i.onerror=()=>{r||n(null)},i.src=t,()=>{r=!0}},[t]),e}function Lle({data:t}){const e=Rle(t.cells);return p.jsxs("div",{children:[p.jsx("div",{style:{fontSize:16,fontWeight:600,color:Ec,fontFamily:F1,marginBottom:4},children:Nle[t.month]}),p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:vy},children:e.map((n,r)=>p.jsx("div",{style:{display:"flex",gap:vy},children:n.map((i,a)=>{const s=i?Math.min(4,Math.max(0,i.level||0)):-1;return p.jsx("div",{style:{width:U1,height:U1,borderRadius:4,background:s<0?"transparent":GF[s]}},a)})},r))})]})}function Ile({data:t}){const e=Ple(t.heatmapWeeks),n=Dle(t.heatmapWeeks),r=t.topModels[0],i=t.avatarUrl||null,a=WR(i),s=WR("/neon_bg.png"),o=(t.handle||"?")[0].toUpperCase(),c=16;return p.jsxs("div",{style:{width:"100%",height:"100%",background:Sle,fontFamily:F1,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[p.jsx("img",{src:s||"/neon_bg.png",alt:"",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none"}}),p.jsxs("div",{style:{position:"relative",zIndex:1,display:"flex",flexDirection:"column",height:"100%",padding:$F,boxSizing:"border-box"},children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:c*3},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:64,height:64,style:{width:64,height:64,borderRadius:16,display:"block"}}),p.jsxs("div",{children:[p.jsx("div",{style:{fontSize:20,fontWeight:500,color:Ec,lineHeight:1.2},children:"Token Tracker"}),p.jsx("div",{style:{fontSize:36,fontWeight:700,lineHeight:1.15,color:cl},children:O("share.card.annual.report_title")})]})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsx("div",{style:{width:48,height:48,borderRadius:"50%",background:"linear-gradient(135deg,#4c1d95,#7c3aed)",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid rgba(255,255,255,0.15)",overflow:"hidden",flexShrink:0},children:a?p.jsx("img",{src:a,alt:"",width:48,height:48,style:{width:48,height:48,objectFit:"cover",display:"block"},crossOrigin:"anonymous",referrerPolicy:"no-referrer"}):p.jsx("span",{style:{fontSize:20,fontWeight:700,color:cl},children:o})}),p.jsx("div",{style:{fontSize:32,fontWeight:700,color:cl},children:t.handle})]})]}),p.jsxs("div",{style:{...kle,borderRadius:22,padding:YF,marginBottom:c},children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:14,color:Ec},children:[p.jsx("span",{children:O("share.card.annual.less")}),GF.map((u,f)=>p.jsx("div",{style:{width:16,height:16,borderRadius:3,background:u}},f)),p.jsx("span",{children:O("share.card.annual.more")})]}),p.jsx("div",{style:{fontSize:16,fontWeight:700,letterSpacing:"0.14em",color:"rgba(255,255,255,0.22)",textTransform:"uppercase"},children:O("share.card.annual.heatmap_title")})]}),p.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(3,${Cle}px)`,gap:`8px ${qF}px`,justifyContent:"center"},children:e.map(u=>p.jsx(Lle,{data:u},u.month))})]}),p.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:c,marginBottom:c},children:[p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"28px 16px",textAlign:"center"},children:[p.jsx("div",{style:{fontFamily:T_,fontSize:52,fontWeight:700,color:cl,letterSpacing:"-0.02em",lineHeight:1},children:O1(t.totalTokens)}),p.jsx("div",{style:{fontSize:22,color:Ec,marginTop:12},children:O("share.card.annual.total_tokens")})]}),p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"28px 16px",textAlign:"center"},children:[p.jsx("div",{style:{fontFamily:T_,fontSize:52,fontWeight:700,color:cl,letterSpacing:"-0.02em",lineHeight:1},children:HF(t.totalCost)}),p.jsx("div",{style:{fontSize:22,color:Ec,marginTop:12},children:O("share.card.annual.estimated_cost")})]})]}),p.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:c},children:[p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"18px 24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:M_,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"M12 2v4m0 12v4M4.93 4.93l2.83 2.83m8.48 8.48 2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48 2.83-2.83"}),p.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),p.jsx("span",{style:{fontSize:20,color:Ec},children:O("share.card.annual.longest_streak")})]}),p.jsx("span",{style:{fontFamily:T_,fontSize:28,fontWeight:700,color:cl},children:O("share.card.annual.days_count",{days:n})})]}),p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"18px 24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:M_,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),p.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),p.jsx("span",{style:{fontSize:20,color:Ec},children:O("share.card.annual.top_model")})]}),p.jsx("span",{style:{fontFamily:F1,fontSize:28,fontWeight:700,color:cl},children:r?r.name:"—"})]})]}),p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"auto"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:44,height:44,style:{width:44,height:44,borderRadius:8,display:"block"}}),p.jsx("span",{style:{fontSize:22,fontWeight:600,color:cl},children:"Token Tracker"})]}),p.jsx("span",{style:{fontSize:22,fontWeight:600,color:M_},children:"tokentracker.cc"})]})]})]})}const XF=[{id:"annual-report",labelKey:"share.variant.neon"},{id:"broadsheet",labelKey:"share.variant.broadsheet"}],Ole={broadsheet:WF,"annual-report":Ile};function KF(t){return zF[t]||{width:jF,height:BF}}function Fle(t){const e=XF.find(n=>n.id===t);return e?.labelKey?O(e.labelKey):t}const GR=x.forwardRef(function({data:e,variant:n},r){const i=Ole[n]||WF,{width:a,height:s}=KF(n);return p.jsx("div",{ref:r,"data-share-card":"true",style:{width:a,height:s,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:p.jsx(i,{data:e})})});function Ag(){return typeof window>"u"?!1:!!window?.webkit?.messageHandlers?.nativeBridge}const Ule=440;function jle(){const[t,e]=x.useState(null),n=x.useRef(null),r=x.useCallback((i,a="info")=>{n.current&&window.clearTimeout(n.current),e({id:Date.now(),kind:a,text:i}),n.current=window.setTimeout(()=>e(null),2800)},[]);return x.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{toast:t,push:r}}function C_({onClick:t,disabled:e,children:n,emphasis:r,ariaLabel:i}){return p.jsx("button",{type:"button",onClick:t,disabled:e,"aria-label":i,className:["group relative flex items-center justify-between gap-3 w-full px-4 py-3 text-left","rounded-lg border transition-colors",r?"border-oai-black dark:border-oai-white bg-oai-black dark:bg-oai-white text-oai-white dark:text-oai-black hover:opacity-90":"border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600",e?"opacity-60 cursor-not-allowed":"cursor-pointer"].join(" "),children:n})}function Ble({open:t,onClose:e,data:n,twitterText:r}){const[i,a]=x.useState(null),[s,o]=x.useState(""),[c,u]=x.useState("annual-report"),f=x.useRef(null),{toast:h,push:m}=jle(),g=ls(),v=x.useMemo(()=>{const k=g?.user;if(!k||typeof k!="object")return null;const N=k.user_metadata||{},B=k.profile||{},L=N.avatar_url||N.picture||B.avatar_url||k.avatar_url;return typeof L=="string"&&L.trim()?L.trim():null},[g?.user]);x.useEffect(()=>{t&&(a(null),o(n?.handle||""))},[t,n?.handle]);const w=n&&{...n,handle:s||n.handle,avatarUrl:v},{width:b,height:_}=KF(c),E=Ule/b;x.useEffect(()=>{if(!t)return;const k=N=>{N.key==="Escape"&&e?.()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[t,e]);const M=x.useCallback(async()=>{const k=f.current;if(!k)return null;try{return await ole(k)}catch(N){return console.warn("[share] capture failed",N),null}},[]),T=x.useCallback(async()=>{if(i)return;a("copy");const k=await M();if(!k){m(O("share.toast.failed"),"error"),a(null);return}let N=!1;if(Ag()){const B=await E_(k);B&&(N=(await rle(B)).ok)}else N=await Vw(k);m(O(N?"share.toast.copied":"share.toast.failed"),N?"success":"error"),a(null)},[i,M,m]),P=x.useCallback(()=>`tokentracker-share-${Date.now()}.png`,[]),A=x.useCallback(async()=>{if(i)return;a("download");const k=await M();if(!k){m(O("share.toast.failed"),"error"),a(null);return}if(Ag()){const B=await E_(k);if(B&&(await zR(B,P())).ok){m(O("share.toast.downloaded"),"success"),a(null);return}}const N=VR(k,P());m(O(N?"share.toast.downloaded":"share.toast.failed"),N?"success":"error"),a(null)},[i,M,P,m]),R=x.useCallback(async()=>{if(i)return;a("x");const k=await M();if(!k){m(O("share.toast.failed"),"error"),a(null);return}if(Ag()){const B=await E_(k);B&&(await zR(B,P()),m(O("share.toast.downloaded"),"success"))}else await Vw(k)?m(O("share.toast.copied"),"success"):VR(k,P());const N=new URL("https://twitter.com/intent/tweet");if(r&&N.searchParams.set("text",r),Ag())try{window.webkit?.messageHandlers?.nativeBridge?.postMessage({type:"action",name:"openURL",value:N.toString()})}catch{window.open(N.toString(),"_blank","noopener,noreferrer")}else window.open(N.toString(),"_blank","noopener,noreferrer");a(null)},[i,M,m,r,P]);return t?p.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":O("share.modal.title"),"data-screenshot-exclude":"true",className:"fixed inset-0 z-[9999] flex items-center justify-center p-4 sm:p-6",style:{background:"rgba(10,10,10,0.72)"},onClick:k=>{k.target===k.currentTarget&&e?.()},children:[p.jsx("div",{"aria-hidden":!0,style:{position:"fixed",left:0,top:0,width:b,height:_,pointerEvents:"none",opacity:0,zIndex:-1,clip:"rect(0,0,0,0)",overflow:"hidden"},children:p.jsx(GR,{ref:f,data:w,variant:c})}),p.jsxs(Qn.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:12},transition:{duration:.18,ease:[.2,.8,.2,1]},className:"relative w-full max-w-[1040px] max-h-[92vh] overflow-hidden rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-black shadow-oai-lg",children:[p.jsxs("div",{className:"flex flex-col lg:flex-row max-h-[92vh]",children:[p.jsx("div",{className:"flex-1 min-w-0 p-4 sm:p-7 bg-oai-gray-50 dark:bg-oai-gray-950 flex items-center justify-center overflow-auto",children:p.jsxs("div",{style:{width:b*E,height:_*E,flexShrink:0,position:"relative"},className:"rounded-xl overflow-hidden shadow-oai-md ring-1 ring-black/5",children:[i?p.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-white/70 dark:bg-black/50",children:p.jsxs("svg",{className:"animate-spin h-6 w-6 text-oai-gray-500",viewBox:"0 0 24 24",fill:"none",children:[p.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),p.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}):null,p.jsx("div",{style:{width:b,height:_,transform:`scale(${E})`,transformOrigin:"top left"},children:p.jsx(GR,{data:w,variant:c})})]})}),p.jsxs("div",{className:"w-full lg:w-[340px] flex-shrink-0 border-t lg:border-t-0 lg:border-l border-oai-gray-200 dark:border-oai-gray-800 p-5 sm:p-6 flex flex-col gap-5 overflow-y-auto",children:[p.jsxs("div",{className:"flex items-start justify-between gap-2",children:[p.jsxs("div",{children:[p.jsx("h2",{className:"text-lg font-semibold text-oai-black dark:text-oai-white",children:O("share.modal.title")}),p.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O("share.modal.subtitle")})]}),p.jsx("button",{type:"button",onClick:e,"aria-label":O("share.modal.close"),className:"p-1.5 -mt-1 -mr-1 rounded-md text-oai-gray-500 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:p.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),p.jsxs("div",{children:[p.jsx("label",{htmlFor:"share-handle",className:"text-[11px] tracking-[0.18em] uppercase text-oai-gray-500 dark:text-oai-gray-400 mb-1.5 block",children:O("share.modal.name_label")}),p.jsx("input",{id:"share-handle",type:"text",value:s,onChange:k=>o(k.target.value),placeholder:O("share.modal.name_placeholder"),className:"w-full px-3 py-2 text-sm rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white placeholder:text-oai-gray-400 dark:placeholder:text-oai-gray-600 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-oai-brand transition-colors"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"text-[11px] tracking-[0.18em] uppercase text-oai-gray-500 dark:text-oai-gray-400 mb-1.5 block",children:O("share.modal.style_label")}),p.jsx("div",{className:"flex gap-2",children:XF.map(k=>p.jsx("button",{type:"button",onClick:()=>u(k.id),className:["flex-1 px-3 py-2 text-sm rounded-lg border transition-colors",c===k.id?"border-oai-black dark:border-oai-white bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white font-medium":"border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-gray-500 dark:text-oai-gray-400 hover:border-oai-gray-400 dark:hover:border-oai-gray-600"].join(" "),children:Fle(k.id)},k.id))})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[p.jsxs(C_,{onClick:R,disabled:!!i,emphasis:!0,children:[p.jsxs("span",{className:"flex items-center gap-3",children:[p.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:p.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),p.jsx("span",{className:"font-medium text-sm",children:O("share.modal.action.x")})]}),p.jsx("span",{className:"text-[11px] opacity-70",children:O(i==="x"?"share.toast.working":"share.modal.hint.x")})]}),p.jsxs(C_,{onClick:A,disabled:!!i,children:[p.jsxs("span",{className:"flex items-center gap-3",children:[p.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[p.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),p.jsx("polyline",{points:"7 10 12 15 17 10"}),p.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),p.jsx("span",{className:"font-medium text-sm",children:O("share.modal.action.download")})]}),p.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:"PNG"})]}),p.jsxs(C_,{onClick:T,disabled:!!i,children:[p.jsxs("span",{className:"flex items-center gap-3",children:[p.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[p.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),p.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),p.jsx("span",{className:"font-medium text-sm",children:O("share.modal.action.copy")})]}),p.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:O("share.modal.hint.copy")})]})]}),p.jsx("div",{className:"mt-auto pt-4 border-t border-oai-gray-200 dark:border-oai-gray-800",children:p.jsx("p",{className:"text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:O("share.modal.footer")})})]})]}),p.jsx(Lp,{children:h?p.jsx(Qn.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},className:"pointer-events-none absolute left-1/2 bottom-4 -translate-x-1/2",children:p.jsx("div",{className:["px-4 py-2 rounded-full text-xs font-medium shadow-oai-md",h.kind==="error"?"bg-red-600 text-white":h.kind==="success"?"bg-oai-black dark:bg-oai-white text-oai-white dark:text-oai-black":"bg-oai-gray-800 text-white"].join(" "),children:h.text})},h.id):null})]})]}):null}function zle(t){const{enabled:e,handle:n,startDate:r,activeDays:i,summary:a,topModels:s,period:o,periodFrom:c,periodTo:u,heatmap:f,accessToken:h,userId:m}=t,[g,v]=x.useState(null);return x.useEffect(()=>{if(!e||!m&&!vr())return;let w=!1;return(async()=>{try{const _=await M3({accessToken:h,userId:m,period:o==="day"||o==="custom"?"week":o,metric:"all",limit:100,offset:0});if(w)return;const M=(Array.isArray(_?.entries)?_.entries:Array.isArray(_)?_:[]).find(P=>P?.is_me===!0),T=typeof M?.rank=="number"?M.rank:null;v(T)}catch{w||v(null)}})(),()=>{w=!0}},[e,h,m,o]),x.useMemo(()=>ule({handle:n,startDate:r,activeDays:i,summary:a,topModels:s,rank:g,period:o,periodFrom:c,periodTo:u,heatmap:f}),[n,r,i,a,s,g,o,c,u,f])}const Vle=["day","week","month","total","custom"],A_=new Set(["day","hour","month"]),hh=new Set(["day","total","custom"]);function P_(t,e){if(typeof e=="number"&&e>0)return!0;if(typeof t=="bigint")return t>0n;if(typeof t=="number")return Number.isFinite(t)&&t>0;if(typeof t=="string"){const n=t.trim();if(!n)return!1;if(/^[0-9]+$/.test(n))try{return BigInt(n)>0n}catch{return!1}const r=Number(n);return Number.isFinite(r)&&r>0}return!1}function Pg(t){return t?t?.billable_total_tokens??t?.total_tokens:null}function $R(t){return t?t?.billable_total_tokens??t?.value??t?.total_tokens:null}function Hle(t){if(typeof t!="string"||!t)return null;const e=t.split("-");if(e.length!==3)return null;const n=Number(e[0]),r=Number(e[1])-1,i=Number(e[2]);if(!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i))return null;const a=new Date(Date.UTC(n,r,i));return Number.isFinite(a.getTime())?a:null}function Wle(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()+e))}function Gle(t){return t?t==="www.tokentracker.cc"||t==="tokentracker.cc":!1}function $le(){if(typeof window>"u")return!1;const t=new URLSearchParams(window.location.search),e=String(t.get("force_install")||"").toLowerCase();return e!=="1"&&e!=="true"?!1:!Gle(window.location.hostname)}function Yle({baseUrl:t,auth:e,signedIn:n,sessionSoftExpired:r,signOut:i,publicMode:a=!1,publicToken:s=null,signInUrl:o="/sign-in",signUpUrl:c="/sign-up"}){const{resolvedLocale:u}=lu(),[f,h]=x.useState(!1),[m,g]=x.useState(null),[v,w]=x.useState(null),[b,_]=x.useState(!1),[E,M]=x.useState(null),[T,P]=x.useState(0),[A,R]=x.useState(0),[k,N]=x.useState(null),[B,L]=x.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(max-width: 640px)").matches),z=x.useMemo(()=>typeof window>"u"?!1:uE(window.location.search),[]),I=x.useMemo(()=>$le(),[]),[V,W]=x.useState(!1),[X,J]=x.useState(!1),F=2200,[G,Y]=x.useState(!0),[H,te]=x.useState(!1),[re,ue]=x.useState(!1),[ce,ee]=x.useState(!1),le=vr(),ve=n&&!r,Ne=x.useMemo(()=>ve&&(typeof e=="function"||typeof e=="string"||e&&typeof e=="object")?e:null,[e,ve]),be=ve?Ne:null,qe=a?wo(s):be,he=n||le||a,Ue=ve&&Fl(be),je=n&&r&&!a;x.useEffect(()=>{if(!n||le){g(null),w(null),_(!1),M(null);return}if(a)return;if(!Ue){g(null),w(null),_(!1),M(null);return}let Ge=!0;const Wt=()=>{g(null),w(null),_(!1),M(null)};return _(!0),M(null),(async()=>{let Kt=null;try{Kt=await Dl(be)}catch{Kt=null}if(Ge){if(!Kt){Wt();return}try{const tn={link_code:null,expires_at:null};if(!Ge)return;g(typeof tn?.link_code=="string"?tn.link_code:null),w(typeof tn?.expires_at=="string"?tn.expires_at:null)}catch(tn){if(!Ge)return;g(null),w(null),M(tn?.message||"Failed to load link code")}finally{if(!Ge)return;_(!1)}}})(),()=>{Ge=!1}},[t,le,n,a,Ue,be,A]);const et=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");x.useEffect(()=>{if(!et&&(!n||le||a)){N(null);return}if(!et&&!Ue){N(null);return}let Ge=!0;return(async()=>{let Wt=null;try{Wt=await Dl(be)}catch{Wt=null}if(Ge){if(!Wt&&!et){N(null);return}try{const Kt=await b7({baseUrl:t,accessToken:Wt});if(!Ge)return;N(Kt&&typeof Kt=="object"?Kt:null)}catch{if(!Ge)return;N(null)}}})(),()=>{Ge=!1}},[Ue,t,be,le,a,n]);const _e=x.useMemo(()=>{if(!v)return!1;const Ge=Date.parse(v);if(!Number.isFinite(Ge))return!1;const Wt=T||Date.now();return Ge<=Wt},[v,T]);x.useEffect(()=>{!n||le||a||!v||!_e||b||(g(null),w(null),M(null),R(Ge=>Ge+1))},[_e,v,b,le,n]),x.useEffect(()=>{if(!v||a)return;const Ge=Date.parse(v);if(!Number.isFinite(Ge))return;const Wt=Date.now();if(P(Wt),Ge<=Wt)return;const Kt=window.setTimeout(()=>P(Date.now()),Ge-Wt),tn=()=>{typeof document>"u"||document.visibilityState==="visible"&&P(Date.now())};return typeof document<"u"&&document.addEventListener("visibilitychange",tn),window.addEventListener("focus",tn),()=>{window.clearTimeout(Kt),typeof document<"u"&&document.removeEventListener("visibilitychange",tn),window.removeEventListener("focus",tn)}},[v]),x.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const Ge=window.matchMedia("(max-width: 640px)"),Wt=()=>L(Ge.matches);return Wt(),Ge.addEventListener?(Ge.addEventListener("change",Wt),()=>Ge.removeEventListener("change",Wt)):(Ge.addListener(Wt),()=>Ge.removeListener(Wt))},[]);const oe=x.useMemo(()=>x3(),[]),Q=x.useMemo(()=>b3(),[]),ze=x.useMemo(()=>ZH(),[]),Pe=a?null:e?.userId||e?.email||"default",[De,Le]=x.useState("month"),[$,U]=x.useState(null),[Z,pe]=x.useState(null),[Se,xe]=x.useState(!1),Ie=z?"total":De,He=x.useMemo(()=>Ie==="custom"&&$&&Z?{from:$,to:Z}:w3(Ie,{timeZone:oe,offsetMinutes:Q,now:ze}),[ze,Ie,oe,Q,$,Z]),Ye=He.from,ft=He.to,We=x.useMemo(()=>jH({timeZone:oe,offsetMinutes:Q}),[oe,Q]),Xe=x.useMemo(()=>BH({timeZone:oe,offsetMinutes:Q}),[oe,Q]),nt=x.useMemo(()=>`Local time (${Xe})`,[Xe]),ct=oe,Ke=Q,gt=We,ne=x.useMemo(()=>wk({timeZone:oe,offsetMinutes:Q,date:ze||new Date}),[ze,oe,Q]),Be=x.useMemo(()=>{const Ge=Hle(ne)||new Date,Wt=Wle(Ge,-29);return{from:Hn(Wt),to:Hn(Ge)}},[ne]),{daily:ke,summary:Ae,rolling:Ve,source:ge,loading:ut,error:yt,refresh:qt}=gP({baseUrl:t,accessToken:qe,guestAllowed:je,from:Ye,to:ft,includeDaily:Ie!=="total",cacheKey:Pe,timeZone:oe,tzOffsetMinutes:Q,now:ze}),{daily:Lt,loading:_t,refresh:wt}=gP({baseUrl:t,accessToken:qe,guestAllowed:je,from:Be.from,to:Be.to,includeDaily:!0,cacheKey:Pe?`${Pe}.daily-breakdown`:"daily-breakdown",timeZone:oe,tzOffsetMinutes:Q,now:ze}),{breakdown:un,loading:xn,refresh:ie}=tJ({baseUrl:t,accessToken:qe,guestAllowed:je,from:Ye,to:ft,cacheKey:Pe,timeZone:oe,tzOffsetMinutes:Q}),[fe,Te]=x.useState(3),{entries:$e,loading:Ze,refresh:At}=$Z({baseUrl:t,accessToken:qe,limit:fe,from:Ye,to:ft,timeZone:oe,tzOffsetMinutes:Q}),St=Ie==="week"||Ie==="month",Rt=Ie==="week"||Ie==="month",xt=x.useMemo(()=>ke.filter(Ge=>Ge?.future?!1:!Ge?.day||!ne?!0:String(Ge.day)<=String(ne)),[ke,ne]),{rows:Tt,from:Xt,to:zt,loading:En,refresh:yn}=qZ({baseUrl:t,accessToken:qe,guestAllowed:je,period:Ie,from:Ye,to:ft,months:24,cacheKey:Pe,timeZone:ct,tzOffsetMinutes:Ke,now:ze,sharedRows:St?ke:null,sharedRange:St?{from:Ye,to:ft}:null}),{daily:Cn,heatmap:In,loading:hr,refresh:An}=GZ({baseUrl:t,accessToken:qe,guestAllowed:je,weeks:52,cacheKey:Pe,timeZone:oe,tzOffsetMinutes:Q,now:ze}),{refresh:K}=r4(),me=x.useMemo(()=>Ie==="day"?"hour":Ie==="total"?"month":"day",[Ie]),Re=x.useMemo(()=>vP(me),[me]),Ee="day",we=x.useMemo(()=>vP(Ee),[]),[st,mt]=x.useState(()=>({key:"day",dir:"desc"}));x.useEffect(()=>{mt(Ge=>!A_.has(Ge.key)||Ge.key===me?Ge:{key:me,dir:Ge.dir})},[me]);const it=x.useMemo(()=>A_.has(st.key)&&st.key!==me?{...st,key:me}:st,[me,st]),pt=x.useMemo(()=>{if(Ie==="day")return Array.isArray(Tt)?Tt.filter(Kt=>Kt?.hour&&!Kt?.future):[];if(Ie==="total"){const Kt=Array.isArray(Tt)?Tt.filter(tn=>tn?.month&&!tn?.future):[];return pJ(Kt)}const Ge=xt;return!Ge.some(Kt=>!Kt?.missing&&!Kt?.future)&&ke.length>0?ke.filter(Kt=>!Kt?.future).slice(-30).filter(Kt=>Kt?.day):Ge},[Ie,Tt,xt,ke]),Et=x.useMemo(()=>xP(pt,it),[pt,it]),dt=x.useMemo(()=>pt.some(Ge=>!Ge?.missing&&!Ge?.future),[pt]),Vt=x.useMemo(()=>{if(!hh.has(Ie))return 1;const Ge=Math.ceil(Et.length/sy);return Ge>0?Ge:1},[Ie,Et.length]),[Ct,dn]=x.useState(0);x.useEffect(()=>{if(!hh.has(Ie)){dn(0);return}dn(Ge=>Math.min(Ge,Vt-1))},[Vt,Ie]),x.useEffect(()=>{hh.has(Ie)&&dn(0)},[Ie,st.dir,st.key]);const en=x.useMemo(()=>hh.has(Ie)?mJ(Et,Ct,sy):Et,[Ct,Ie,Et]),Pn=x.useMemo(()=>Lt.filter(Ge=>!Ge?.future&&Ge?.day).slice(-30),[Lt]),cn=x.useMemo(()=>A_.has(st.key)?{...st,key:Ee}:st,[st]),nr=x.useMemo(()=>xP(Pn,cn),[Pn,cn]),Ut=x.useMemo(()=>Rt?ke:Ie==="day"?Array.isArray(Tt)?Tt.filter(Ge=>Ge?.hour):[]:Tt,[ke,Ie,Tt,Rt]),Kr=Rt?Ye:Xt,wn=Rt?ft:zt;function ri(Ge,Wt){return Ge?.future?"—":Ge?.missing?O("shared.status.unsynced"):Oi(Wt==="total_tokens"?Pg(Ge):Ge?.[Wt])}function ii(Ge){const Wt=Ge?.[me];if(Wt==null)return"";const Kt=String(Wt);if(me==="hour"){const[tn,pr]=Kt.split("T");if(tn&&pr)return`${tn} ${pr.slice(0,5)}`}return Kt}function xi(Ge){const Wt=Ge?.[Ee];return Wt==null?"":String(Wt)}function cs(Ge){mt(Wt=>Wt.key===Ge?{key:Ge,dir:Wt.dir==="asc"?"desc":"asc"}:{key:Ge,dir:"desc"})}function Fn(Ge){return it.key!==Ge?"none":it.dir==="asc"?"ascending":"descending"}function nn(Ge){return it.key!==Ge?"":it.dir==="asc"?"▲":"▼"}function $i(Ge){return cn.key!==Ge?"none":cn.dir==="asc"?"ascending":"descending"}function cr(Ge){return cn.key!==Ge?"":cn.dir==="asc"?"▲":"▼"}const ai=x.useMemo(()=>{if(!n&&!le&&!a&&!et)return 0;const Ge=Number(In?.active_days);if(Number.isFinite(Ge))return Ge;let Wt=0;const Kt=new Set,tn=(Yn,rr,er)=>{typeof Yn!="string"||!Yn||Kt.has(Yn)||P_(rr,er)&&(Kt.add(Yn),Wt+=1)};if(Array.isArray(Cn))for(const Yn of Cn)tn(Yn?.day,Pg(Yn));const pr=Array.isArray(In?.weeks)?In.weeks:[];for(const Yn of pr)for(const rr of Array.isArray(Yn)?Yn:[]){const er=$R(rr);tn(rr?.day,er,rr?.level)}return Wt},[n,le,In?.active_days,In?.weeks,Cn]),[da,Vo]=x.useState("month"),Kp=x.useCallback(Ge=>{Ge==="custom"?(Vo(Wt=>Wt==="custom"?"month":Wt),Le(Wt=>$&&Z?"custom":Wt),xe(!0)):(Le(Ge),Vo(Ge),xe(!1))},[$,Z]),_f=x.useCallback((Ge,Wt)=>{U(Ge),pe(Wt),Le("custom"),xe(!1)},[]),mu=x.useCallback(Ge=>{xe(Ge),!Ge&&De==="custom"&&!$&&Le(da)},[De,$,da]),La=x.useCallback(async()=>{await Promise.all([qt(),An(),yn(),ie(),At(),wt(),K()])},[wt,An,ie,At,yn,qt,K]),us=x.useCallback(async()=>{ee(!0);try{et&&await _7(),await La()}catch(Ge){console.error("[DashboardPage] Refresh failed:",Ge)}finally{ee(!1)}},[et,La]),ds=ce||ut||_t||hr||En||xn||Ze,Yl=x.useMemo(()=>O("shared.data_source",{source:String(ge||"edge").toUpperCase()}),[ge,u]),fs=x.useMemo(()=>typeof e?.name!="string"?"":e.name.trim(),[e?.name]),hs="",Zp=x.useMemo(()=>!fs||fs.includes("@")?O("dashboard.identity.fallback"):fs,[fs]),wf=x.useMemo(()=>Zp.replace(/[^a-zA-Z0-9._-]/g,"_"),[Zp]),Ho=x.useMemo(()=>a?O("dashboard.identity.fallback"):wf,[wf,hs,a]),Jp=x.useMemo(()=>{let Ge=null;const Wt=tn=>{typeof tn!="string"||!tn||(!Ge||tn<Ge)&&(Ge=tn)};if(Array.isArray(Cn))for(const tn of Cn)tn?.day&&P_(Pg(tn))&&Wt(tn.day);const Kt=Array.isArray(In?.weeks)?In.weeks:[];for(const tn of Kt)for(const pr of Array.isArray(tn)?tn:[]){if(!pr?.day)continue;const Yn=$R(pr),rr=pr?.level;P_(Yn,rr)&&Wt(pr.day)}return Ge},[In?.weeks,Cn]),Qp=x.useMemo(()=>a?[]:(Array.isArray(k?.subscriptions?.items)?k.subscriptions.items:[]).map(Kt=>{const tn=typeof Kt?.tool=="string"?Kt.tool.trim():"",Yn=(typeof Kt?.plan_type=="string"?Kt.plan_type:typeof Kt?.planType=="string"?Kt.planType:"").trim();return!tn||!Yn?null:{tool:tn,planType:Yn,provider:typeof Kt?.provider=="string"?Kt.provider.trim():"",product:typeof Kt?.product=="string"?Kt.product.trim():"",rateLimitTier:typeof Kt?.rate_limit_tier=="string"?Kt.rate_limit_tier.trim():typeof Kt?.rateLimitTier=="string"?Kt.rateLimitTier.trim():""}}).filter(Boolean).slice(0,6),[a,k]),gu=p.jsx(sQ,{heatmap:In,timeZoneLabel:We,timeZoneShortLabel:Xe,hideLegend:z,defaultToLatestMonth:z}),em=x.useMemo(()=>`${Ye}..${ft}`,[Ye,Ie,ft]),Sv=O("usage.summary.total"),Yi=Pg(Ae),Wo=O("shared.unit.thousand_abbrev"),to=O("shared.unit.million_abbrev"),ql=O("shared.unit.billion_abbrev"),yu=ti(Yi),tm=B&&yu!=null&&Math.abs(yu)>=1e9,Sf=x.useMemo(()=>tm?Ma(yu,{thousandSuffix:Wo,millionSuffix:to,billionSuffix:ql,decimals:1}):Oi(Yi),[ql,to,Yi,yu,Wo,tm]),vu=O("dashboard.core_index.collapse_label"),kf=O("dashboard.core_index.expand_label"),nm=O("dashboard.core_index.collapse_aria"),ps=O("dashboard.core_index.expand_aria"),Ef=!z,xu=O("dashboard.screenshot.title_line1"),rm=O("dashboard.screenshot.title_line2"),bu=O("dashboard.screenshot.twitter_label"),_u=O("dashboard.screenshot.twitter_button"),im=O("dashboard.screenshot.twitter_hint"),Sr=O("shared.placeholder.short"),ms=x.useMemo(()=>{const Ge=Array.isArray(un?.sources)?un.sources:[];let Wt=null,Kt=0;for(const rr of Ge){const er=ti(rr?.totals?.billable_total_tokens??rr?.totals?.total_tokens);!Number.isFinite(er)||er<=0||er>Kt&&(Kt=er,Wt=rr)}let tn=Sr,pr=Sr,Yn="0.0";if(Wt&&Kt>0){tn=Wt?.source?String(Wt.source).toUpperCase():Sr;const rr=Array.isArray(Wt?.models)?Wt.models:[];let er=0;for(const Ia of rr){const Jl=ti(Ia?.totals?.billable_total_tokens??Ia?.totals?.total_tokens);!Number.isFinite(Jl)||Jl<=0||Jl>er&&(er=Jl,pr=Ia?.model?String(Ia.model):Sr)}er>0&&(Yn=(er/Kt*100).toFixed(1))}return{agentName:tn,modelName:pr,modelPercent:Yn}},[un,Sr]),wu=Oi(Yi),Mf=O("dashboard.screenshot.twitter_text",{total_tokens:wu==="-"?Sr:wu,agent_name:ms.agentName,model_name:ms.modelName,model_percent:ms.modelPercent}),Xl=x.useMemo(()=>{if(typeof window>"u")return"";const Ge=new URL("https://twitter.com/intent/tweet");return Ge.searchParams.set("text",Mf),Ge.toString()},[Mf]),ku=x.useCallback(async()=>{if(typeof window>"u")return null;const Ge=async()=>{const rr=performance.now();for(;performance.now()-rr<2e3;){const er=document.querySelector("[data-heatmap-scroll='true']");if(!er||er.dataset.latestMonthReady==="true")return;await new Promise(Ia=>requestAnimationFrame(Ia))}},Wt=document.querySelector("#root")||document.body,Kt=document.documentElement,{scrollWidth:tn,scrollHeight:pr}=document.documentElement;Kt?.classList.add("screenshot-capture"),document.body?.classList.add("screenshot-capture"),await new Promise(Yn=>requestAnimationFrame(Yn)),await Ge();try{const{toBlob:Yn,toPng:rr}=await t4(async()=>{const{toBlob:no,toPng:cm}=await import("./index-BeoRn2gJ.js");return{toBlob:no,toPng:cm}},[]),er=await Yn(Wt,{backgroundColor:"#050505",pixelRatio:2,cacheBust:!0,width:tn,height:pr,style:{width:`${tn}px`,height:`${pr}px`},filter:no=>!(no instanceof HTMLElement)||no.dataset?.screenshotExclude!=="true"});if(er)return er;const Ia=await rr(Wt,{backgroundColor:"#050505",pixelRatio:2,cacheBust:!0,width:tn,height:pr,style:{width:`${tn}px`,height:`${pr}px`},filter:no=>!(no instanceof HTMLElement)||no.dataset?.screenshotExclude!=="true"});return Ia?await(await fetch(Ia)).blob():null}finally{Kt?.classList.remove("screenshot-capture"),document.body?.classList.remove("screenshot-capture")}},[]),Kl=x.useCallback(async()=>{if(typeof window>"u"||V)return;W(!0);const Ge=navigator?.userAgent||"",Wt=/iP(hone|od|ad)/i.test(Ge),Kt=/Safari/i.test(Ge)&&!/Chrome|Chromium|Edg|OPR|CriOS|FxiOS/i.test(Ge),tn=typeof navigator<"u"&&!!navigator.clipboard?.write&&typeof window<"u"&&!!window.ClipboardItem;let Yn=!tn||Wt||Kt;try{const rr=await ku();rr&&tn&&(typeof document<"u"&&!document.hasFocus()&&window.focus?.(),Yn=await Vw(rr))}catch(rr){console.error("Failed to capture screenshot",rr)}finally{if(W(!1),!Yn){console.warn("Failed to write screenshot to clipboard.");return}Xl&&(window.location.href=Xl)}},[ku,V,Xl]),Eu=x.useMemo(()=>z?[]:Vle,[z]),am=x.useMemo(()=>[{label:O("usage.metric.total"),value:Oi(Yi),valueClassName:"text-white"},{label:O("usage.metric.input"),value:Oi(Ae?.input_tokens)},{label:O("usage.metric.output"),value:Oi(Ae?.output_tokens)},{label:O("usage.metric.cached_input"),value:Oi(Ae?.cached_input_tokens)},{label:O("usage.metric.reasoning_output"),value:Oi(Ae?.reasoning_output_tokens)}],[Ae?.cached_input_tokens,Ae?.input_tokens,Ae?.output_tokens,Ae?.reasoning_output_tokens,Yi]),Tf=x.useMemo(()=>{const Ge=Uy(Ae?.total_cost_usd);return!Ge||Ge==="-"||Ge.startsWith("$")?Ge:`$${Ge}`},[Ae?.total_cost_usd]),kv=x.useMemo(()=>Ae?.conversation_count??null,[Ae?.conversation_count]),sm=x.useMemo(()=>vJ(un,{copyFn:O}),[un]),Mu=x.useMemo(()=>xJ(un,{limit:3,copyFn:O}),[un]),Ev=zle({enabled:X,handle:Ho,startDate:Jp,activeDays:ai,summary:Ae,topModels:Mu,period:Ie,periodFrom:Ye,periodTo:ft,heatmap:In,accessToken:typeof qe=="string"?qe:null,userId:e?.userId||null}),Mv=x.useCallback(()=>J(!0),[]),Tv=x.useCallback(()=>J(!1),[]),Cv=x.useCallback(()=>h(!0),[]),Av=x.useCallback(()=>h(!1),[]),om=Tf&&Tf!=="-"&&sm.length>0,Zl=O("dashboard.install.cmd.init"),Cf=_e?null:m,Af=Cf?O("dashboard.install.cmd.init_link_code",{link_code:Cf}):Zl,Pv=Zl,Pf=O("dashboard.install.cmd.sync"),Rv=O(Cf?"dashboard.install.copy":"dashboard.install.copy_base"),Nv=O("dashboard.install.copied");O("dashboard.session_expired.copy_label"),O("dashboard.session_expired.copied");const Dv=!!(k?.install?.has_active_device_token??k?.install?.hasActiveDeviceToken),lm=gJ({publicMode:a,screenshotMode:z,forceInstall:I,accessEnabled:he,heatmapLoading:hr,activeDays:ai,hasActiveDeviceToken:Dv}),Lv=O("dashboard.install.prompt"),Iv=x.useCallback(async()=>{!Af||!await zw(Af)||(te(!0),window.setTimeout(()=>te(!1),2e3))},[Af]);x.useCallback(async()=>{!Zl||!await zw(Zl)||(ue(!0),window.setTimeout(()=>ue(!1),2e3))},[Zl]);const Rf=x.useMemo(()=>O("dashboard.daily.empty",{cmd:"{{cmd}}"}),[u]),[Ov,Fv]=x.useMemo(()=>{const Ge=Rf.split("{{cmd}}");return Ge.length===1?[Rf,""]:[Ge[0],Ge.slice(1).join("{{cmd}}")]},[Rf]),Uv=r&&!a,Nf=!n&&!le&&!r&&!et&&!a;return p.jsxs(p.Fragment,{children:[p.jsx(nle,{copy:O,onOpenShare:Mv,screenshotMode:z,showExpiredGate:Uv,showAuthGate:Nf,screenshotTitleLine1:xu,screenshotTitleLine2:rm,identityDisplayName:Ho,identityStartDate:Jp,activeDays:ai,identitySubscriptions:Qp,identityScrambleDurationMs:F,projectUsageEntries:$e,projectUsageLimit:fe,setProjectUsageLimit:Te,topModels:Mu,signedIn:n,publicMode:a,isLocalMode:et,shouldShowInstall:lm,installPrompt:Lv,handleCopyInstall:Iv,installCopied:H,installCopiedLabel:Nv,installCopyLabel:Rv,installInitCmdDisplay:Pv,linkCodeLoading:b,linkCodeError:E,trendRowsForDisplay:Ut,trendFromForDisplay:Kr,trendToForDisplay:wn,usageFrom:Ye,usageTo:ft,period:Ie,trendTimeZoneLabel:gt,activityHeatmapBlock:gu,isCapturing:V,handleShareToX:Kl,screenshotTwitterLabel:bu,screenshotTwitterButton:_u,screenshotTwitterHint:im,periodsForDisplay:Eu,setSelectedPeriod:Kp,customFrom:$,customTo:Z,onCustomRangeApply:_f,customRangeOpen:Se,onCustomRangeOpenChange:mu,metricsRows:am,summaryLabel:Sv,summaryValue:Sf,summaryTotalTokensRaw:ti(Yi)||0,summaryCostValue:Tf,summaryConversationsValue:kv,rollingUsage:Ve,costInfoEnabled:om,openCostModal:Cv,allowBreakdownToggle:Ef,coreIndexCollapsed:G,setCoreIndexCollapsed:Y,coreIndexCollapseLabel:vu,coreIndexExpandLabel:kf,coreIndexCollapseAria:nm,coreIndexExpandAria:ps,refreshAll:us,usageLoadingState:ds,usageError:yt,rangeLabel:em,timeZoneRangeLabel:nt,usageSourceLabel:Yl,fleetData:sm,hasDetailsActual:dt,dailyEmptyPrefix:Ov,installSyncCmd:Pf,dailyEmptySuffix:Fv,detailsColumns:Re,ariaSortFor:Fn,toggleSort:cs,sortIconFor:nn,pagedDetails:en,dailyBreakdownRows:nr,dailyBreakdownColumns:we,dailyBreakdownAriaSortFor:$i,dailyBreakdownSortIconFor:cr,dailyBreakdownDateKey:Ee,detailsDateKey:me,renderDetailDate:ii,renderDailyBreakdownDate:xi,renderDetailCell:ri,DETAILS_PAGED_PERIODS:hh,detailsPageCount:Vt,detailsPage:Ct,setDetailsPage:dn,costModalOpen:f,closeCostModal:Av}),p.jsx(Ble,{open:X,onClose:Tv,data:Ev,twitterText:Mf})]})}function qle(){const[t,e]=x.useState(!1);return p.jsxs("div",{className:"h-full relative dark:bg-[#050505]",children:[!t&&p.jsxs("div",{className:"absolute inset-0 p-6 space-y-5 animate-pulse",children:[p.jsx("div",{className:"flex gap-4 justify-center",children:Array.from({length:6}).map((n,r)=>p.jsx("div",{className:"h-4 w-20 rounded bg-oai-gray-200 dark:bg-oai-gray-800"},r))}),p.jsxs("div",{className:"space-y-2 pt-2",children:[p.jsx("div",{className:"h-7 w-72 rounded bg-oai-gray-200 dark:bg-oai-gray-800"}),p.jsx("div",{className:"h-4 w-96 rounded bg-oai-gray-200 dark:bg-oai-gray-800"})]}),p.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:3}).map((n,r)=>p.jsx("div",{className:"h-24 rounded-xl bg-oai-gray-200 dark:bg-oai-gray-800"},r))}),p.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:3}).map((n,r)=>p.jsx("div",{className:"h-40 rounded-xl bg-oai-gray-200 dark:bg-oai-gray-800"},r))}),p.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:3}).map((n,r)=>p.jsx("div",{className:"h-32 rounded-xl bg-oai-gray-200 dark:bg-oai-gray-800"},r))})]}),p.jsx("iframe",{src:"https://ip.net.coffee/claude/",title:"Cloud AI IP Check",className:`w-full h-full dark:invert dark:hue-rotate-180 transition-opacity duration-300 ${t?"opacity-100":"opacity-0"}`,style:{border:"none"},onLoad:()=>e(!0)})]})}function Xle(){if(typeof window>"u")return!1;const t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||t==="::1"}function Kle(){return Xle()?"/":"/dashboard"}function ZF({repo:t="mm7894215/TokenTracker"}){const[e,n]=x.useState(null);return x.useEffect(()=>{if(typeof window>"u")return;const r=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,i=typeof document<"u"&&(document.documentElement?.classList.contains("screenshot-capture")||document.body?.classList.contains("screenshot-capture"));F5({prefersReducedMotion:r,screenshotCapture:i})&&fetch(`https://api.github.com/repos/${t}`).then(a=>a.json()).then(a=>{a&&typeof a.stargazers_count=="number"&&n(a.stargazers_count)}).catch(()=>{})},[t]),p.jsxs("a",{href:`https://github.com/${t}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex shrink-0 items-center gap-2 px-3 py-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-700 transition-colors no-underline",children:[p.jsx("svg",{height:"16",viewBox:"0 0 16 16",width:"16",className:"shrink-0 fill-oai-gray-700 dark:fill-oai-gray-300",children:p.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),p.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 whitespace-nowrap",children:"Star"}),e!==null&&p.jsx("span",{className:"text-xs font-semibold text-oai-gray-900 dark:text-oai-white tabular-nums whitespace-nowrap",children:e})]})}const qE="183",Zle=0,YR=1,Jle=2,E0=1,Qle=2,Ph=3,Ol=0,zi=1,So=2,Ro=0,Hc=1,qR=2,XR=3,KR=4,ece=5,Tc=100,tce=101,nce=102,rce=103,ice=104,ace=200,sce=201,oce=202,lce=203,j1=204,B1=205,cce=206,uce=207,dce=208,fce=209,hce=210,pce=211,mce=212,gce=213,yce=214,z1=0,V1=1,H1=2,qd=3,W1=4,G1=5,$1=6,Y1=7,JF=0,vce=1,xce=2,Us=0,QF=1,eU=2,tU=3,nU=4,rU=5,iU=6,aU=7,sU=300,ru=301,Xd=302,R_=303,N_=304,fv=306,q1=1e3,Mo=1001,X1=1002,ni=1003,bce=1004,Rg=1005,yi=1006,D_=1007,Fc=1008,Ea=1009,oU=1010,lU=1011,dp=1012,XE=1013,$s=1014,Ds=1015,Uo=1016,KE=1017,ZE=1018,fp=1020,cU=35902,uU=35899,dU=1021,fU=1022,ts=1023,jo=1026,Uc=1027,hU=1028,JE=1029,Kd=1030,QE=1031,eM=1033,M0=33776,T0=33777,C0=33778,A0=33779,K1=35840,Z1=35841,J1=35842,Q1=35843,eS=36196,tS=37492,nS=37496,rS=37488,iS=37489,aS=37490,sS=37491,oS=37808,lS=37809,cS=37810,uS=37811,dS=37812,fS=37813,hS=37814,pS=37815,mS=37816,gS=37817,yS=37818,vS=37819,xS=37820,bS=37821,_S=36492,wS=36494,SS=36495,kS=36283,ES=36284,MS=36285,TS=36286,_ce=3200,wce=0,Sce=1,wl="",wa="srgb",iu="srgb-linear",xy="linear",qn="srgb",Qu=7680,ZR=519,kce=512,Ece=513,Mce=514,tM=515,Tce=516,Cce=517,nM=518,Ace=519,JR=35044,QR="300 es",Ls=2e3,by=2001;function Pce(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function _y(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Rce(){const t=_y("canvas");return t.style.display="block",t}const eN={};function tN(...t){const e="THREE."+t.shift();console.log(e,...t)}function pU(t){const e=t[0];if(typeof e=="string"&&e.startsWith("TSL:")){const n=t[1];n&&n.isStackTrace?t[0]+=" "+n.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}function ln(...t){t=pU(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...t)}}function Vn(...t){t=pU(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.error(n.getError(e)):console.error(e,...t)}}function wy(...t){const e=t.join(" ");e in eN||(eN[e]=!0,ln(...t))}function Nce(t,e,n){return new Promise(function(r,i){function a(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}const Dce={[z1]:V1,[H1]:$1,[W1]:Y1,[qd]:G1,[V1]:z1,[$1]:H1,[Y1]:W1,[G1]:qd};class pf{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,s=i.length;a<s;a++)i[a].call(this,e);e.target=null}}}const ui=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],L_=Math.PI/180,CS=180/Math.PI;function Hp(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ui[t&255]+ui[t>>8&255]+ui[t>>16&255]+ui[t>>24&255]+"-"+ui[e&255]+ui[e>>8&255]+"-"+ui[e>>16&15|64]+ui[e>>24&255]+"-"+ui[n&63|128]+ui[n>>8&255]+"-"+ui[n>>16&255]+ui[n>>24&255]+ui[r&255]+ui[r>>8&255]+ui[r>>16&255]+ui[r>>24&255]).toLowerCase()}function Dn(t,e,n){return Math.max(e,Math.min(n,t))}function Lce(t,e){return(t%e+e)%e}function I_(t,e,n){return(1-n)*t+n*e}function ph(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Ii(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}class $n{constructor(e=0,n=0){$n.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Dn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,s=this.y-e.y;return this.x=a*r-s*i+e.x,this.y=a*i+s*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class mf{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,s,o){let c=r[i+0],u=r[i+1],f=r[i+2],h=r[i+3],m=a[s+0],g=a[s+1],v=a[s+2],w=a[s+3];if(h!==w||c!==m||u!==g||f!==v){let b=c*m+u*g+f*v+h*w;b<0&&(m=-m,g=-g,v=-v,w=-w,b=-b);let _=1-o;if(b<.9995){const E=Math.acos(b),M=Math.sin(E);_=Math.sin(_*E)/M,o=Math.sin(o*E)/M,c=c*_+m*o,u=u*_+g*o,f=f*_+v*o,h=h*_+w*o}else{c=c*_+m*o,u=u*_+g*o,f=f*_+v*o,h=h*_+w*o;const E=1/Math.sqrt(c*c+u*u+f*f+h*h);c*=E,u*=E,f*=E,h*=E}}e[n]=c,e[n+1]=u,e[n+2]=f,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,a,s){const o=r[i],c=r[i+1],u=r[i+2],f=r[i+3],h=a[s],m=a[s+1],g=a[s+2],v=a[s+3];return e[n]=o*v+f*h+c*g-u*m,e[n+1]=c*v+f*m+u*h-o*g,e[n+2]=u*v+f*g+o*m-c*h,e[n+3]=f*v-o*h-c*m-u*g,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,a=e._z,s=e._order,o=Math.cos,c=Math.sin,u=o(r/2),f=o(i/2),h=o(a/2),m=c(r/2),g=c(i/2),v=c(a/2);switch(s){case"XYZ":this._x=m*f*h+u*g*v,this._y=u*g*h-m*f*v,this._z=u*f*v+m*g*h,this._w=u*f*h-m*g*v;break;case"YXZ":this._x=m*f*h+u*g*v,this._y=u*g*h-m*f*v,this._z=u*f*v-m*g*h,this._w=u*f*h+m*g*v;break;case"ZXY":this._x=m*f*h-u*g*v,this._y=u*g*h+m*f*v,this._z=u*f*v+m*g*h,this._w=u*f*h-m*g*v;break;case"ZYX":this._x=m*f*h-u*g*v,this._y=u*g*h+m*f*v,this._z=u*f*v-m*g*h,this._w=u*f*h+m*g*v;break;case"YZX":this._x=m*f*h+u*g*v,this._y=u*g*h+m*f*v,this._z=u*f*v-m*g*h,this._w=u*f*h-m*g*v;break;case"XZY":this._x=m*f*h-u*g*v,this._y=u*g*h-m*f*v,this._z=u*f*v+m*g*h,this._w=u*f*h+m*g*v;break;default:ln("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],s=n[1],o=n[5],c=n[9],u=n[2],f=n[6],h=n[10],m=r+o+h;if(m>0){const g=.5/Math.sqrt(m+1);this._w=.25/g,this._x=(f-c)*g,this._y=(a-u)*g,this._z=(s-i)*g}else if(r>o&&r>h){const g=2*Math.sqrt(1+r-o-h);this._w=(f-c)/g,this._x=.25*g,this._y=(i+s)/g,this._z=(a+u)/g}else if(o>h){const g=2*Math.sqrt(1+o-r-h);this._w=(a-u)/g,this._x=(i+s)/g,this._y=.25*g,this._z=(c+f)/g}else{const g=2*Math.sqrt(1+h-r-o);this._w=(s-i)/g,this._x=(a+u)/g,this._y=(c+f)/g,this._z=.25*g}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Dn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,s=e._w,o=n._x,c=n._y,u=n._z,f=n._w;return this._x=r*f+s*o+i*u-a*c,this._y=i*f+s*c+a*o-r*u,this._z=a*f+s*u+r*c-i*o,this._w=s*f-r*o-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){let r=e._x,i=e._y,a=e._z,s=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,a=-a,s=-s,o=-o);let c=1-n;if(o<.9995){const u=Math.acos(o),f=Math.sin(u);c=Math.sin(c*u)/f,n=Math.sin(n*u)/f,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+s*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+s*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),a=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),a*Math.sin(n),a*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Oe{constructor(e=0,n=0,r=0){Oe.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(nN.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(nN.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,s=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*s,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*s,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*s,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,s=e.y,o=e.z,c=e.w,u=2*(s*i-o*r),f=2*(o*n-a*i),h=2*(a*r-s*n);return this.x=n+c*u+s*h-o*f,this.y=r+c*f+o*u-a*h,this.z=i+c*h+a*f-s*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this.z=Dn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this.z=Dn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,s=n.x,o=n.y,c=n.z;return this.x=i*c-a*o,this.y=a*s-r*c,this.z=r*o-i*s,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return O_.copy(this).projectOnVector(e),this.sub(O_)}reflect(e){return this.sub(O_.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Dn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const O_=new Oe,nN=new mf;class pn{constructor(e,n,r,i,a,s,o,c,u){pn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u)}set(e,n,r,i,a,s,o,c,u){const f=this.elements;return f[0]=e,f[1]=i,f[2]=o,f[3]=n,f[4]=a,f[5]=c,f[6]=r,f[7]=s,f[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[3],c=r[6],u=r[1],f=r[4],h=r[7],m=r[2],g=r[5],v=r[8],w=i[0],b=i[3],_=i[6],E=i[1],M=i[4],T=i[7],P=i[2],A=i[5],R=i[8];return a[0]=s*w+o*E+c*P,a[3]=s*b+o*M+c*A,a[6]=s*_+o*T+c*R,a[1]=u*w+f*E+h*P,a[4]=u*b+f*M+h*A,a[7]=u*_+f*T+h*R,a[2]=m*w+g*E+v*P,a[5]=m*b+g*M+v*A,a[8]=m*_+g*T+v*R,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],f=e[8];return n*s*f-n*o*u-r*a*f+r*o*c+i*a*u-i*s*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],f=e[8],h=f*s-o*u,m=o*c-f*a,g=u*a-s*c,v=n*h+r*m+i*g;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const w=1/v;return e[0]=h*w,e[1]=(i*u-f*r)*w,e[2]=(o*r-i*s)*w,e[3]=m*w,e[4]=(f*n-i*c)*w,e[5]=(i*a-o*n)*w,e[6]=g*w,e[7]=(r*c-u*n)*w,e[8]=(s*n-r*a)*w,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,o){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*s+u*o)+s+e,-i*u,i*c,-i*(-u*s+c*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(F_.makeScale(e,n)),this}rotate(e){return this.premultiply(F_.makeRotation(-e)),this}translate(e,n){return this.premultiply(F_.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,r,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const F_=new pn,rN=new pn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),iN=new pn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Ice(){const t={enabled:!0,workingColorSpace:iu,spaces:{},convert:function(i,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===qn&&(i.r=No(i.r),i.g=No(i.g),i.b=No(i.b)),this.spaces[a].primaries!==this.spaces[s].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===qn&&(i.r=Dd(i.r),i.g=Dd(i.g),i.b=Dd(i.b))),i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===wl?xy:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,a=this.workingColorSpace){return i.fromArray(this.spaces[a].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,a,s){return i.copy(this.spaces[a].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,a){return wy("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return wy("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,a)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[iu]:{primaries:e,whitePoint:r,transfer:xy,toXYZ:rN,fromXYZ:iN,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:wa},outputColorSpaceConfig:{drawingBufferColorSpace:wa}},[wa]:{primaries:e,whitePoint:r,transfer:qn,toXYZ:rN,fromXYZ:iN,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:wa}}}),t}const jn=Ice();function No(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Dd(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let ed;class Oce{static getDataURL(e,n="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let r;if(e instanceof HTMLCanvasElement)r=e;else{ed===void 0&&(ed=_y("canvas")),ed.width=e.width,ed.height=e.height;const i=ed.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=ed}return r.toDataURL(n)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=_y("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let s=0;s<a.length;s++)a[s]=No(a[s]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(No(n[r]/255)*255):n[r]=No(n[r]);return{data:n,width:e.width,height:e.height}}else return ln("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Fce=0;class rM{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Fce++}),this.uuid=Hp(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):typeof VideoFrame<"u"&&n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let s=0,o=i.length;s<o;s++)i[s].isDataTexture?a.push(U_(i[s].image)):a.push(U_(i[s]))}else a=U_(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function U_(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Oce.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(ln("Texture: Unable to serialize Texture."),{})}let Uce=0;const j_=new Oe;class Ti extends pf{constructor(e=Ti.DEFAULT_IMAGE,n=Ti.DEFAULT_MAPPING,r=Mo,i=Mo,a=yi,s=Fc,o=ts,c=Ea,u=Ti.DEFAULT_ANISOTROPY,f=wl){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Uce++}),this.uuid=Hp(),this.name="",this.source=new rM(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=s,this.anisotropy=u,this.format=o,this.internalFormat=null,this.type=c,this.offset=new $n(0,0),this.repeat=new $n(1,1),this.center=new $n(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new pn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=f,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(j_).x}get height(){return this.source.getSize(j_).y}get depth(){return this.source.getSize(j_).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const n in e){const r=e[n];if(r===void 0){ln(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){ln(`Texture.setValues(): property '${n}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==sU)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case q1:e.x=e.x-Math.floor(e.x);break;case Mo:e.x=e.x<0?0:1;break;case X1:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case q1:e.y=e.y-Math.floor(e.y);break;case Mo:e.y=e.y<0?0:1;break;case X1:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Ti.DEFAULT_IMAGE=null;Ti.DEFAULT_MAPPING=sU;Ti.DEFAULT_ANISOTROPY=1;class yr{constructor(e=0,n=0,r=0,i=1){yr.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i+s[12]*a,this.y=s[1]*n+s[5]*r+s[9]*i+s[13]*a,this.z=s[2]*n+s[6]*r+s[10]*i+s[14]*a,this.w=s[3]*n+s[7]*r+s[11]*i+s[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],f=c[4],h=c[8],m=c[1],g=c[5],v=c[9],w=c[2],b=c[6],_=c[10];if(Math.abs(f-m)<.01&&Math.abs(h-w)<.01&&Math.abs(v-b)<.01){if(Math.abs(f+m)<.1&&Math.abs(h+w)<.1&&Math.abs(v+b)<.1&&Math.abs(u+g+_-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const M=(u+1)/2,T=(g+1)/2,P=(_+1)/2,A=(f+m)/4,R=(h+w)/4,k=(v+b)/4;return M>T&&M>P?M<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(M),i=A/r,a=R/r):T>P?T<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(T),r=A/i,a=k/i):P<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(P),r=R/a,i=k/a),this.set(r,i,a,n),this}let E=Math.sqrt((b-v)*(b-v)+(h-w)*(h-w)+(m-f)*(m-f));return Math.abs(E)<.001&&(E=1),this.x=(b-v)/E,this.y=(h-w)/E,this.z=(m-f)/E,this.w=Math.acos((u+g+_-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this.z=Dn(this.z,e.z,n.z),this.w=Dn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this.z=Dn(this.z,e,n),this.w=Dn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class jce extends pf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:yi,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=r.depth,this.scissor=new yr(0,0,e,n),this.scissorTest=!1,this.viewport=new yr(0,0,e,n),this.textures=[];const i={width:e,height:n,depth:r.depth},a=new Ti(i),s=r.count;for(let o=0;o<s;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:yi,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,a=this.textures.length;i<a;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new rM(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class js extends jce{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class mU extends Ti{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ni,this.minFilter=ni,this.wrapR=Mo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Bce extends Ti{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ni,this.minFilter=ni,this.wrapR=Mo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Nr{constructor(e,n,r,i,a,s,o,c,u,f,h,m,g,v,w,b){Nr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u,f,h,m,g,v,w,b)}set(e,n,r,i,a,s,o,c,u,f,h,m,g,v,w,b){const _=this.elements;return _[0]=e,_[4]=n,_[8]=r,_[12]=i,_[1]=a,_[5]=s,_[9]=o,_[13]=c,_[2]=u,_[6]=f,_[10]=h,_[14]=m,_[3]=g,_[7]=v,_[11]=w,_[15]=b,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Nr().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return this.determinant()===0?(e.set(1,0,0),n.set(0,1,0),r.set(0,0,1),this):(e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this)}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const n=this.elements,r=e.elements,i=1/td.setFromMatrixColumn(e,0).length(),a=1/td.setFromMatrixColumn(e,1).length(),s=1/td.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*s,n[9]=r[9]*s,n[10]=r[10]*s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,s=Math.cos(r),o=Math.sin(r),c=Math.cos(i),u=Math.sin(i),f=Math.cos(a),h=Math.sin(a);if(e.order==="XYZ"){const m=s*f,g=s*h,v=o*f,w=o*h;n[0]=c*f,n[4]=-c*h,n[8]=u,n[1]=g+v*u,n[5]=m-w*u,n[9]=-o*c,n[2]=w-m*u,n[6]=v+g*u,n[10]=s*c}else if(e.order==="YXZ"){const m=c*f,g=c*h,v=u*f,w=u*h;n[0]=m+w*o,n[4]=v*o-g,n[8]=s*u,n[1]=s*h,n[5]=s*f,n[9]=-o,n[2]=g*o-v,n[6]=w+m*o,n[10]=s*c}else if(e.order==="ZXY"){const m=c*f,g=c*h,v=u*f,w=u*h;n[0]=m-w*o,n[4]=-s*h,n[8]=v+g*o,n[1]=g+v*o,n[5]=s*f,n[9]=w-m*o,n[2]=-s*u,n[6]=o,n[10]=s*c}else if(e.order==="ZYX"){const m=s*f,g=s*h,v=o*f,w=o*h;n[0]=c*f,n[4]=v*u-g,n[8]=m*u+w,n[1]=c*h,n[5]=w*u+m,n[9]=g*u-v,n[2]=-u,n[6]=o*c,n[10]=s*c}else if(e.order==="YZX"){const m=s*c,g=s*u,v=o*c,w=o*u;n[0]=c*f,n[4]=w-m*h,n[8]=v*h+g,n[1]=h,n[5]=s*f,n[9]=-o*f,n[2]=-u*f,n[6]=g*h+v,n[10]=m-w*h}else if(e.order==="XZY"){const m=s*c,g=s*u,v=o*c,w=o*u;n[0]=c*f,n[4]=-h,n[8]=u*f,n[1]=m*h+w,n[5]=s*f,n[9]=g*h-v,n[2]=v*h-g,n[6]=o*f,n[10]=w*h+m}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(zce,e,Vce)}lookAt(e,n,r){const i=this.elements;return Qi.subVectors(e,n),Qi.lengthSq()===0&&(Qi.z=1),Qi.normalize(),ul.crossVectors(r,Qi),ul.lengthSq()===0&&(Math.abs(r.z)===1?Qi.x+=1e-4:Qi.z+=1e-4,Qi.normalize(),ul.crossVectors(r,Qi)),ul.normalize(),Ng.crossVectors(Qi,ul),i[0]=ul.x,i[4]=Ng.x,i[8]=Qi.x,i[1]=ul.y,i[5]=Ng.y,i[9]=Qi.y,i[2]=ul.z,i[6]=Ng.z,i[10]=Qi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[4],c=r[8],u=r[12],f=r[1],h=r[5],m=r[9],g=r[13],v=r[2],w=r[6],b=r[10],_=r[14],E=r[3],M=r[7],T=r[11],P=r[15],A=i[0],R=i[4],k=i[8],N=i[12],B=i[1],L=i[5],z=i[9],I=i[13],V=i[2],W=i[6],X=i[10],J=i[14],F=i[3],G=i[7],Y=i[11],H=i[15];return a[0]=s*A+o*B+c*V+u*F,a[4]=s*R+o*L+c*W+u*G,a[8]=s*k+o*z+c*X+u*Y,a[12]=s*N+o*I+c*J+u*H,a[1]=f*A+h*B+m*V+g*F,a[5]=f*R+h*L+m*W+g*G,a[9]=f*k+h*z+m*X+g*Y,a[13]=f*N+h*I+m*J+g*H,a[2]=v*A+w*B+b*V+_*F,a[6]=v*R+w*L+b*W+_*G,a[10]=v*k+w*z+b*X+_*Y,a[14]=v*N+w*I+b*J+_*H,a[3]=E*A+M*B+T*V+P*F,a[7]=E*R+M*L+T*W+P*G,a[11]=E*k+M*z+T*X+P*Y,a[15]=E*N+M*I+T*J+P*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],s=e[1],o=e[5],c=e[9],u=e[13],f=e[2],h=e[6],m=e[10],g=e[14],v=e[3],w=e[7],b=e[11],_=e[15],E=c*g-u*m,M=o*g-u*h,T=o*m-c*h,P=s*g-u*f,A=s*m-c*f,R=s*h-o*f;return n*(w*E-b*M+_*T)-r*(v*E-b*P+_*A)+i*(v*M-w*P+_*R)-a*(v*T-w*A+b*R)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],f=e[8],h=e[9],m=e[10],g=e[11],v=e[12],w=e[13],b=e[14],_=e[15],E=n*o-r*s,M=n*c-i*s,T=n*u-a*s,P=r*c-i*o,A=r*u-a*o,R=i*u-a*c,k=f*w-h*v,N=f*b-m*v,B=f*_-g*v,L=h*b-m*w,z=h*_-g*w,I=m*_-g*b,V=E*I-M*z+T*L+P*B-A*N+R*k;if(V===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const W=1/V;return e[0]=(o*I-c*z+u*L)*W,e[1]=(i*z-r*I-a*L)*W,e[2]=(w*R-b*A+_*P)*W,e[3]=(m*A-h*R-g*P)*W,e[4]=(c*B-s*I-u*N)*W,e[5]=(n*I-i*B+a*N)*W,e[6]=(b*T-v*R-_*M)*W,e[7]=(f*R-m*T+g*M)*W,e[8]=(s*z-o*B+u*k)*W,e[9]=(r*B-n*z-a*k)*W,e[10]=(v*A-w*T+_*E)*W,e[11]=(h*T-f*A-g*E)*W,e[12]=(o*N-s*L-c*k)*W,e[13]=(n*L-r*N+i*k)*W,e[14]=(w*M-v*P-b*E)*W,e[15]=(f*P-h*M+m*E)*W,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,s=e.x,o=e.y,c=e.z,u=a*s,f=a*o;return this.set(u*s+r,u*o-i*c,u*c+i*o,0,u*o+i*c,f*o+r,f*c-i*s,0,u*c-i*o,f*c+i*s,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,s){return this.set(1,r,a,0,e,1,s,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,s=n._y,o=n._z,c=n._w,u=a+a,f=s+s,h=o+o,m=a*u,g=a*f,v=a*h,w=s*f,b=s*h,_=o*h,E=c*u,M=c*f,T=c*h,P=r.x,A=r.y,R=r.z;return i[0]=(1-(w+_))*P,i[1]=(g+T)*P,i[2]=(v-M)*P,i[3]=0,i[4]=(g-T)*A,i[5]=(1-(m+_))*A,i[6]=(b+E)*A,i[7]=0,i[8]=(v+M)*R,i[9]=(b-E)*R,i[10]=(1-(m+w))*R,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const a=this.determinant();if(a===0)return r.set(1,1,1),n.identity(),this;let s=td.set(i[0],i[1],i[2]).length();const o=td.set(i[4],i[5],i[6]).length(),c=td.set(i[8],i[9],i[10]).length();a<0&&(s=-s),Ga.copy(this);const u=1/s,f=1/o,h=1/c;return Ga.elements[0]*=u,Ga.elements[1]*=u,Ga.elements[2]*=u,Ga.elements[4]*=f,Ga.elements[5]*=f,Ga.elements[6]*=f,Ga.elements[8]*=h,Ga.elements[9]*=h,Ga.elements[10]*=h,n.setFromRotationMatrix(Ga),r.x=s,r.y=o,r.z=c,this}makePerspective(e,n,r,i,a,s,o=Ls,c=!1){const u=this.elements,f=2*a/(n-e),h=2*a/(r-i),m=(n+e)/(n-e),g=(r+i)/(r-i);let v,w;if(c)v=a/(s-a),w=s*a/(s-a);else if(o===Ls)v=-(s+a)/(s-a),w=-2*s*a/(s-a);else if(o===by)v=-s/(s-a),w=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return u[0]=f,u[4]=0,u[8]=m,u[12]=0,u[1]=0,u[5]=h,u[9]=g,u[13]=0,u[2]=0,u[6]=0,u[10]=v,u[14]=w,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,s,o=Ls,c=!1){const u=this.elements,f=2/(n-e),h=2/(r-i),m=-(n+e)/(n-e),g=-(r+i)/(r-i);let v,w;if(c)v=1/(s-a),w=s/(s-a);else if(o===Ls)v=-2/(s-a),w=-(s+a)/(s-a);else if(o===by)v=-1/(s-a),w=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return u[0]=f,u[4]=0,u[8]=0,u[12]=m,u[1]=0,u[5]=h,u[9]=0,u[13]=g,u[2]=0,u[6]=0,u[10]=v,u[14]=w,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const td=new Oe,Ga=new Nr,zce=new Oe(0,0,0),Vce=new Oe(1,1,1),ul=new Oe,Ng=new Oe,Qi=new Oe,aN=new Nr,sN=new mf;let au=class gU{constructor(e=0,n=0,r=0,i=gU.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],s=i[4],o=i[8],c=i[1],u=i[5],f=i[9],h=i[2],m=i[6],g=i[10];switch(n){case"XYZ":this._y=Math.asin(Dn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-f,g),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Dn(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(o,g),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-h,a),this._z=0);break;case"ZXY":this._x=Math.asin(Dn(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-h,g),this._z=Math.atan2(-s,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-Dn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(m,g),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-s,u));break;case"YZX":this._z=Math.asin(Dn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-f,u),this._y=Math.atan2(-h,a)):(this._x=0,this._y=Math.atan2(o,g));break;case"XZY":this._z=Math.asin(-Dn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-f,g),this._y=0);break;default:ln("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return aN.makeRotationFromQuaternion(e),this.setFromRotationMatrix(aN,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return sN.setFromEuler(this),this.setFromQuaternion(sN,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};au.DEFAULT_ORDER="XYZ";class yU{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Hce=0;const oN=new Oe,nd=new mf,ho=new Nr,Dg=new Oe,mh=new Oe,Wce=new Oe,Gce=new mf,lN=new Oe(1,0,0),cN=new Oe(0,1,0),uN=new Oe(0,0,1),dN={type:"added"},$ce={type:"removed"},rd={type:"childadded",child:null},B_={type:"childremoved",child:null};class la extends pf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Hce++}),this.uuid=Hp(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=la.DEFAULT_UP.clone();const e=new Oe,n=new au,r=new mf,i=new Oe(1,1,1);function a(){r.setFromEuler(n,!1)}function s(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Nr},normalMatrix:{value:new pn}}),this.matrix=new Nr,this.matrixWorld=new Nr,this.matrixAutoUpdate=la.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=la.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new yU,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return nd.setFromAxisAngle(e,n),this.quaternion.multiply(nd),this}rotateOnWorldAxis(e,n){return nd.setFromAxisAngle(e,n),this.quaternion.premultiply(nd),this}rotateX(e){return this.rotateOnAxis(lN,e)}rotateY(e){return this.rotateOnAxis(cN,e)}rotateZ(e){return this.rotateOnAxis(uN,e)}translateOnAxis(e,n){return oN.copy(e).applyQuaternion(this.quaternion),this.position.add(oN.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(lN,e)}translateY(e){return this.translateOnAxis(cN,e)}translateZ(e){return this.translateOnAxis(uN,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ho.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Dg.copy(e):Dg.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),mh.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ho.lookAt(mh,Dg,this.up):ho.lookAt(Dg,mh,this.up),this.quaternion.setFromRotationMatrix(ho),i&&(ho.extractRotation(i.matrixWorld),nd.setFromRotationMatrix(ho),this.quaternion.premultiply(nd.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Vn("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(dN),rd.child=e,this.dispatchEvent(rd),rd.child=null):Vn("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent($ce),B_.child=e,this.dispatchEvent(B_),B_.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ho.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ho.multiply(e.parent.matrixWorld)),e.applyMatrix4(ho),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(dN),rd.child=e,this.dispatchEvent(rd),rd.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const s=this.children[r].getObjectByProperty(e,n);if(s!==void 0)return s}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mh,e,Wce),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mh,Gce,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const n=e.x,r=e.y,i=e.z,a=this.matrix.elements;a[12]+=n-a[0]*n-a[4]*r-a[8]*i,a[13]+=r-a[1]*n-a[5]*r-a[9]*i,a[14]+=i-a[2]*n-a[6]*r-a[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function a(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let u=0,f=c.length;u<f;u++){const h=c[u];a(e.shapes,h)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,u=this.material.length;c<u;c++)o.push(a(e.materials,this.material[c]));i.material=o}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(a(e.animations,c))}}if(n){const o=s(e.geometries),c=s(e.materials),u=s(e.textures),f=s(e.images),h=s(e.shapes),m=s(e.skeletons),g=s(e.animations),v=s(e.nodes);o.length>0&&(r.geometries=o),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),f.length>0&&(r.images=f),h.length>0&&(r.shapes=h),m.length>0&&(r.skeletons=m),g.length>0&&(r.animations=g),v.length>0&&(r.nodes=v)}return r.object=i,r;function s(o){const c=[];for(const u in o){const f=o[u];delete f.metadata,c.push(f)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}la.DEFAULT_UP=new Oe(0,1,0);la.DEFAULT_MATRIX_AUTO_UPDATE=!0;la.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Lg extends la{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Yce={type:"move"};class z_{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Lg,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Lg,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Oe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Oe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Lg,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Oe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Oe),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,s=null;const o=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){s=!0;for(const w of e.hand.values()){const b=n.getJointPose(w,r),_=this._getHandJoint(u,w);b!==null&&(_.matrix.fromArray(b.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.matrixWorldNeedsUpdate=!0,_.jointRadius=b.radius),_.visible=b!==null}const f=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],m=f.position.distanceTo(h.position),g=.02,v=.005;u.inputState.pinching&&m>g+v?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=g-v&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Yce)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Lg;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}const vU={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},dl={h:0,s:0,l:0},Ig={h:0,s:0,l:0};function V_(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}class Zn{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=wa){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,jn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=jn.workingColorSpace){return this.r=e,this.g=n,this.b=r,jn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=jn.workingColorSpace){if(e=Lce(e,1),n=Dn(n,0,1),r=Dn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,s=2*r-a;this.r=V_(s,a,e+1/3),this.g=V_(s,a,e),this.b=V_(s,a,e-1/3)}return jn.colorSpaceToWorking(this,i),this}setStyle(e,n=wa){function r(a){a!==void 0&&parseFloat(a)<1&&ln("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:ln("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===6)return this.setHex(parseInt(a,16),n);ln("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=wa){const r=vU[e.toLowerCase()];return r!==void 0?this.setHex(r,n):ln("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=No(e.r),this.g=No(e.g),this.b=No(e.b),this}copyLinearToSRGB(e){return this.r=Dd(e.r),this.g=Dd(e.g),this.b=Dd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=wa){return jn.workingToColorSpace(di.copy(this),e),Math.round(Dn(di.r*255,0,255))*65536+Math.round(Dn(di.g*255,0,255))*256+Math.round(Dn(di.b*255,0,255))}getHexString(e=wa){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=jn.workingColorSpace){jn.workingToColorSpace(di.copy(this),n);const r=di.r,i=di.g,a=di.b,s=Math.max(r,i,a),o=Math.min(r,i,a);let c,u;const f=(o+s)/2;if(o===s)c=0,u=0;else{const h=s-o;switch(u=f<=.5?h/(s+o):h/(2-s-o),s){case r:c=(i-a)/h+(i<a?6:0);break;case i:c=(a-r)/h+2;break;case a:c=(r-i)/h+4;break}c/=6}return e.h=c,e.s=u,e.l=f,e}getRGB(e,n=jn.workingColorSpace){return jn.workingToColorSpace(di.copy(this),n),e.r=di.r,e.g=di.g,e.b=di.b,e}getStyle(e=wa){jn.workingToColorSpace(di.copy(this),e);const n=di.r,r=di.g,i=di.b;return e!==wa?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(dl),this.setHSL(dl.h+e,dl.s+n,dl.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,r){return this.r=e.r+(n.r-e.r)*r,this.g=e.g+(n.g-e.g)*r,this.b=e.b+(n.b-e.b)*r,this}lerpHSL(e,n){this.getHSL(dl),e.getHSL(Ig);const r=I_(dl.h,Ig.h,n),i=I_(dl.s,Ig.s,n),a=I_(dl.l,Ig.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const di=new Zn;Zn.NAMES=vU;class qce extends la{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new au,this.environmentIntensity=1,this.environmentRotation=new au,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(n.object.environmentIntensity=this.environmentIntensity),n.object.environmentRotation=this.environmentRotation.toArray(),n}}const $a=new Oe,po=new Oe,H_=new Oe,mo=new Oe,id=new Oe,ad=new Oe,fN=new Oe,W_=new Oe,G_=new Oe,$_=new Oe,Y_=new yr,q_=new yr,X_=new yr;let gh=class xd{constructor(e=new Oe,n=new Oe,r=new Oe){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),$a.subVectors(e,n),i.cross($a);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){$a.subVectors(i,n),po.subVectors(r,n),H_.subVectors(e,n);const s=$a.dot($a),o=$a.dot(po),c=$a.dot(H_),u=po.dot(po),f=po.dot(H_),h=s*u-o*o;if(h===0)return a.set(0,0,0),null;const m=1/h,g=(u*c-o*f)*m,v=(s*f-o*c)*m;return a.set(1-g-v,v,g)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,mo)===null?!1:mo.x>=0&&mo.y>=0&&mo.x+mo.y<=1}static getInterpolation(e,n,r,i,a,s,o,c){return this.getBarycoord(e,n,r,i,mo)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(a,mo.x),c.addScaledVector(s,mo.y),c.addScaledVector(o,mo.z),c)}static getInterpolatedAttribute(e,n,r,i,a,s){return Y_.setScalar(0),q_.setScalar(0),X_.setScalar(0),Y_.fromBufferAttribute(e,n),q_.fromBufferAttribute(e,r),X_.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Y_,a.x),s.addScaledVector(q_,a.y),s.addScaledVector(X_,a.z),s}static isFrontFacing(e,n,r,i){return $a.subVectors(r,n),po.subVectors(e,n),$a.cross(po).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return $a.subVectors(this.c,this.b),po.subVectors(this.a,this.b),$a.cross(po).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return xd.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return xd.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return xd.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return xd.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return xd.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let s,o;id.subVectors(i,r),ad.subVectors(a,r),W_.subVectors(e,r);const c=id.dot(W_),u=ad.dot(W_);if(c<=0&&u<=0)return n.copy(r);G_.subVectors(e,i);const f=id.dot(G_),h=ad.dot(G_);if(f>=0&&h<=f)return n.copy(i);const m=c*h-f*u;if(m<=0&&c>=0&&f<=0)return s=c/(c-f),n.copy(r).addScaledVector(id,s);$_.subVectors(e,a);const g=id.dot($_),v=ad.dot($_);if(v>=0&&g<=v)return n.copy(a);const w=g*u-c*v;if(w<=0&&u>=0&&v<=0)return o=u/(u-v),n.copy(r).addScaledVector(ad,o);const b=f*v-g*h;if(b<=0&&h-f>=0&&g-v>=0)return fN.subVectors(a,i),o=(h-f)/(h-f+(g-v)),n.copy(i).addScaledVector(fN,o);const _=1/(b+w+m);return s=w*_,o=m*_,n.copy(r).addScaledVector(id,s).addScaledVector(ad,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};class Wp{constructor(e=new Oe(1/0,1/0,1/0),n=new Oe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(Ya.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Ya.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=Ya.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,Ya):Ya.fromBufferAttribute(a,s),Ya.applyMatrix4(e.matrixWorld),this.expandByPoint(Ya);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Og.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Og.copy(r.boundingBox)),Og.applyMatrix4(e.matrixWorld),this.union(Og)}const i=e.children;for(let a=0,s=i.length;a<s;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ya),Ya.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(yh),Fg.subVectors(this.max,yh),sd.subVectors(e.a,yh),od.subVectors(e.b,yh),ld.subVectors(e.c,yh),fl.subVectors(od,sd),hl.subVectors(ld,od),yc.subVectors(sd,ld);let n=[0,-fl.z,fl.y,0,-hl.z,hl.y,0,-yc.z,yc.y,fl.z,0,-fl.x,hl.z,0,-hl.x,yc.z,0,-yc.x,-fl.y,fl.x,0,-hl.y,hl.x,0,-yc.y,yc.x,0];return!K_(n,sd,od,ld,Fg)||(n=[1,0,0,0,1,0,0,0,1],!K_(n,sd,od,ld,Fg))?!1:(Ug.crossVectors(fl,hl),n=[Ug.x,Ug.y,Ug.z],K_(n,sd,od,ld,Fg))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ya).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ya).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(go[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),go[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),go[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),go[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),go[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),go[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),go[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),go[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(go),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const go=[new Oe,new Oe,new Oe,new Oe,new Oe,new Oe,new Oe,new Oe],Ya=new Oe,Og=new Wp,sd=new Oe,od=new Oe,ld=new Oe,fl=new Oe,hl=new Oe,yc=new Oe,yh=new Oe,Fg=new Oe,Ug=new Oe,vc=new Oe;function K_(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){vc.fromArray(t,a);const o=i.x*Math.abs(vc.x)+i.y*Math.abs(vc.y)+i.z*Math.abs(vc.z),c=e.dot(vc),u=n.dot(vc),f=r.dot(vc);if(Math.max(-Math.max(c,u,f),Math.min(c,u,f))>o)return!1}return!0}const Er=new Oe,jg=new $n;let Xce=0;class as{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Xce++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=JR,this.updateRanges=[],this.gpuType=Ds,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)jg.fromBufferAttribute(this,n),jg.applyMatrix3(e),this.setXY(n,jg.x,jg.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.applyMatrix3(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.applyMatrix4(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.applyNormalMatrix(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.transformDirection(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=ph(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Ii(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=ph(n,this.array)),n}setX(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=ph(n,this.array)),n}setY(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=ph(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=ph(n,this.array)),n}setW(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Ii(n,this.array),r=Ii(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=Ii(n,this.array),r=Ii(r,this.array),i=Ii(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=Ii(n,this.array),r=Ii(r,this.array),i=Ii(i,this.array),a=Ii(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==JR&&(e.usage=this.usage),e}}class xU extends as{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class bU extends as{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Do extends as{constructor(e,n,r){super(new Float32Array(e),n,r)}}const Kce=new Wp,vh=new Oe,Z_=new Oe;class iM{constructor(e=new Oe,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):Kce.setFromPoints(e).getCenter(r);let i=0;for(let a=0,s=e.length;a<s;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;vh.subVectors(e,this.center);const n=vh.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(vh,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Z_.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(vh.copy(e.center).add(Z_)),this.expandByPoint(vh.copy(e.center).sub(Z_))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let Zce=0;const va=new Nr,J_=new la,cd=new Oe,ea=new Wp,xh=new Wp,Yr=new Oe;class eo extends pf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Zce++}),this.uuid=Hp(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Pce(e)?bU:xU)(e,1):this.index=e,this}setIndirect(e,n=0){return this.indirect=e,this.indirectOffset=n,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new pn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return va.makeRotationFromQuaternion(e),this.applyMatrix4(va),this}rotateX(e){return va.makeRotationX(e),this.applyMatrix4(va),this}rotateY(e){return va.makeRotationY(e),this.applyMatrix4(va),this}rotateZ(e){return va.makeRotationZ(e),this.applyMatrix4(va),this}translate(e,n,r){return va.makeTranslation(e,n,r),this.applyMatrix4(va),this}scale(e,n,r){return va.makeScale(e,n,r),this.applyMatrix4(va),this}lookAt(e){return J_.lookAt(e),J_.updateMatrix(),this.applyMatrix4(J_.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(cd).negate(),this.translate(cd.x,cd.y,cd.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,a=e.length;i<a;i++){const s=e[i];r.push(s.x,s.y,s.z||0)}this.setAttribute("position",new Do(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const a=e[i];n.setXYZ(i,a.x,a.y,a.z||0)}e.length>n.count&&ln("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Wp);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Vn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Oe(-1/0,-1/0,-1/0),new Oe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];ea.setFromBufferAttribute(a),this.morphTargetsRelative?(Yr.addVectors(this.boundingBox.min,ea.min),this.boundingBox.expandByPoint(Yr),Yr.addVectors(this.boundingBox.max,ea.max),this.boundingBox.expandByPoint(Yr)):(this.boundingBox.expandByPoint(ea.min),this.boundingBox.expandByPoint(ea.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Vn('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new iM);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Vn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Oe,1/0);return}if(e){const r=this.boundingSphere.center;if(ea.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];xh.setFromBufferAttribute(o),this.morphTargetsRelative?(Yr.addVectors(ea.min,xh.min),ea.expandByPoint(Yr),Yr.addVectors(ea.max,xh.max),ea.expandByPoint(Yr)):(ea.expandByPoint(xh.min),ea.expandByPoint(xh.max))}ea.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)Yr.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Yr));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],c=this.morphTargetsRelative;for(let u=0,f=o.count;u<f;u++)Yr.fromBufferAttribute(o,u),c&&(cd.fromBufferAttribute(e,u),Yr.add(cd)),i=Math.max(i,r.distanceToSquared(Yr))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Vn('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){Vn("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,a=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new as(new Float32Array(4*r.count),4));const s=this.getAttribute("tangent"),o=[],c=[];for(let k=0;k<r.count;k++)o[k]=new Oe,c[k]=new Oe;const u=new Oe,f=new Oe,h=new Oe,m=new $n,g=new $n,v=new $n,w=new Oe,b=new Oe;function _(k,N,B){u.fromBufferAttribute(r,k),f.fromBufferAttribute(r,N),h.fromBufferAttribute(r,B),m.fromBufferAttribute(a,k),g.fromBufferAttribute(a,N),v.fromBufferAttribute(a,B),f.sub(u),h.sub(u),g.sub(m),v.sub(m);const L=1/(g.x*v.y-v.x*g.y);isFinite(L)&&(w.copy(f).multiplyScalar(v.y).addScaledVector(h,-g.y).multiplyScalar(L),b.copy(h).multiplyScalar(g.x).addScaledVector(f,-v.x).multiplyScalar(L),o[k].add(w),o[N].add(w),o[B].add(w),c[k].add(b),c[N].add(b),c[B].add(b))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let k=0,N=E.length;k<N;++k){const B=E[k],L=B.start,z=B.count;for(let I=L,V=L+z;I<V;I+=3)_(e.getX(I+0),e.getX(I+1),e.getX(I+2))}const M=new Oe,T=new Oe,P=new Oe,A=new Oe;function R(k){P.fromBufferAttribute(i,k),A.copy(P);const N=o[k];M.copy(N),M.sub(P.multiplyScalar(P.dot(N))).normalize(),T.crossVectors(A,N);const L=T.dot(c[k])<0?-1:1;s.setXYZW(k,M.x,M.y,M.z,L)}for(let k=0,N=E.length;k<N;++k){const B=E[k],L=B.start,z=B.count;for(let I=L,V=L+z;I<V;I+=3)R(e.getX(I+0)),R(e.getX(I+1)),R(e.getX(I+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new as(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,g=r.count;m<g;m++)r.setXYZ(m,0,0,0);const i=new Oe,a=new Oe,s=new Oe,o=new Oe,c=new Oe,u=new Oe,f=new Oe,h=new Oe;if(e)for(let m=0,g=e.count;m<g;m+=3){const v=e.getX(m+0),w=e.getX(m+1),b=e.getX(m+2);i.fromBufferAttribute(n,v),a.fromBufferAttribute(n,w),s.fromBufferAttribute(n,b),f.subVectors(s,a),h.subVectors(i,a),f.cross(h),o.fromBufferAttribute(r,v),c.fromBufferAttribute(r,w),u.fromBufferAttribute(r,b),o.add(f),c.add(f),u.add(f),r.setXYZ(v,o.x,o.y,o.z),r.setXYZ(w,c.x,c.y,c.z),r.setXYZ(b,u.x,u.y,u.z)}else for(let m=0,g=n.count;m<g;m+=3)i.fromBufferAttribute(n,m+0),a.fromBufferAttribute(n,m+1),s.fromBufferAttribute(n,m+2),f.subVectors(s,a),h.subVectors(i,a),f.cross(h),r.setXYZ(m+0,f.x,f.y,f.z),r.setXYZ(m+1,f.x,f.y,f.z),r.setXYZ(m+2,f.x,f.y,f.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Yr.fromBufferAttribute(e,n),Yr.normalize(),e.setXYZ(n,Yr.x,Yr.y,Yr.z)}toNonIndexed(){function e(o,c){const u=o.array,f=o.itemSize,h=o.normalized,m=new u.constructor(c.length*f);let g=0,v=0;for(let w=0,b=c.length;w<b;w++){o.isInterleavedBufferAttribute?g=c[w]*o.data.stride+o.offset:g=c[w]*f;for(let _=0;_<f;_++)m[v++]=u[g++]}return new as(m,f,h)}if(this.index===null)return ln("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new eo,r=this.index.array,i=this.attributes;for(const o in i){const c=i[o],u=e(c,r);n.setAttribute(o,u)}const a=this.morphAttributes;for(const o in a){const c=[],u=a[o];for(let f=0,h=u.length;f<h;f++){const m=u[f],g=e(m,r);c.push(g)}n.morphAttributes[o]=c}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,c=s.length;o<c;o++){const u=s[o];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],f=[];for(let h=0,m=u.length;h<m;h++){const g=u[h];f.push(g.toJSON(e.data))}f.length>0&&(i[c]=f,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const f=i[u];this.setAttribute(u,f.clone(n))}const a=e.morphAttributes;for(const u in a){const f=[],h=a[u];for(let m=0,g=h.length;m<g;m++)f.push(h[m].clone(n));this.morphAttributes[u]=f}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let u=0,f=s.length;u<f;u++){const h=s[u];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}let Jce=0;class hv extends pf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Jce++}),this.uuid=Hp(),this.name="",this.type="Material",this.blending=Hc,this.side=Ol,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=j1,this.blendDst=B1,this.blendEquation=Tc,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Zn(0,0,0),this.blendAlpha=0,this.depthFunc=qd,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ZR,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Qu,this.stencilZFail=Qu,this.stencilZPass=Qu,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const r=e[n];if(r===void 0){ln(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){ln(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Hc&&(r.blending=this.blending),this.side!==Ol&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==j1&&(r.blendSrc=this.blendSrc),this.blendDst!==B1&&(r.blendDst=this.blendDst),this.blendEquation!==Tc&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==qd&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ZR&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Qu&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Qu&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Qu&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.allowOverride===!1&&(r.allowOverride=!1),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const s=[];for(const o in a){const c=a[o];delete c.metadata,s.push(c)}return s}if(n){const a=i(e.textures),s=i(e.images);a.length>0&&(r.textures=a),s.length>0&&(r.images=s)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const yo=new Oe,Q_=new Oe,Bg=new Oe,pl=new Oe,ew=new Oe,zg=new Oe,tw=new Oe;class Qce{constructor(e=new Oe,n=new Oe(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,yo)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=yo.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(yo.copy(this.origin).addScaledVector(this.direction,n),yo.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){Q_.copy(e).add(n).multiplyScalar(.5),Bg.copy(n).sub(e).normalize(),pl.copy(this.origin).sub(Q_);const a=e.distanceTo(n)*.5,s=-this.direction.dot(Bg),o=pl.dot(this.direction),c=-pl.dot(Bg),u=pl.lengthSq(),f=Math.abs(1-s*s);let h,m,g,v;if(f>0)if(h=s*c-o,m=s*o-c,v=a*f,h>=0)if(m>=-v)if(m<=v){const w=1/f;h*=w,m*=w,g=h*(h+s*m+2*o)+m*(s*h+m+2*c)+u}else m=a,h=Math.max(0,-(s*m+o)),g=-h*h+m*(m+2*c)+u;else m=-a,h=Math.max(0,-(s*m+o)),g=-h*h+m*(m+2*c)+u;else m<=-v?(h=Math.max(0,-(-s*a+o)),m=h>0?-a:Math.min(Math.max(-a,-c),a),g=-h*h+m*(m+2*c)+u):m<=v?(h=0,m=Math.min(Math.max(-a,-c),a),g=m*(m+2*c)+u):(h=Math.max(0,-(s*a+o)),m=h>0?a:Math.min(Math.max(-a,-c),a),g=-h*h+m*(m+2*c)+u);else m=s>0?-a:a,h=Math.max(0,-(s*m+o)),g=-h*h+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Q_).addScaledVector(Bg,m),g}intersectSphere(e,n){yo.subVectors(e.center,this.origin);const r=yo.dot(this.direction),i=yo.dot(yo)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),o=r-s,c=r+s;return c<0?null:o<0?this.at(c,n):this.at(o,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,s,o,c;const u=1/this.direction.x,f=1/this.direction.y,h=1/this.direction.z,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),f>=0?(a=(e.min.y-m.y)*f,s=(e.max.y-m.y)*f):(a=(e.max.y-m.y)*f,s=(e.min.y-m.y)*f),r>s||a>i||((a>r||isNaN(r))&&(r=a),(s<i||isNaN(i))&&(i=s),h>=0?(o=(e.min.z-m.z)*h,c=(e.max.z-m.z)*h):(o=(e.max.z-m.z)*h,c=(e.min.z-m.z)*h),r>c||o>i)||((o>r||r!==r)&&(r=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,yo)!==null}intersectTriangle(e,n,r,i,a){ew.subVectors(n,e),zg.subVectors(r,e),tw.crossVectors(ew,zg);let s=this.direction.dot(tw),o;if(s>0){if(i)return null;o=1}else if(s<0)o=-1,s=-s;else return null;pl.subVectors(this.origin,e);const c=o*this.direction.dot(zg.crossVectors(pl,zg));if(c<0)return null;const u=o*this.direction.dot(ew.cross(pl));if(u<0||c+u>s)return null;const f=-o*pl.dot(tw);return f<0?null:this.at(f/s,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class _U extends hv{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Zn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new au,this.combine=JF,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const hN=new Nr,xc=new Qce,Vg=new iM,pN=new Oe,Hg=new Oe,Wg=new Oe,Gg=new Oe,nw=new Oe,$g=new Oe,mN=new Oe,Yg=new Oe;let Ys=class extends la{constructor(e=new eo,n=new _U){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(a&&o){$g.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const f=o[c],h=a[c];f!==0&&(nw.fromBufferAttribute(h,e),s?$g.addScaledVector(nw,f):$g.addScaledVector(nw.sub(n),f))}n.add($g)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),Vg.copy(r.boundingSphere),Vg.applyMatrix4(a),xc.copy(e.ray).recast(e.near),!(Vg.containsPoint(xc.origin)===!1&&(xc.intersectSphere(Vg,pN)===null||xc.origin.distanceToSquared(pN)>(e.far-e.near)**2))&&(hN.copy(a).invert(),xc.copy(e.ray).applyMatrix4(hN),!(r.boundingBox!==null&&xc.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,xc)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,o=a.index,c=a.attributes.position,u=a.attributes.uv,f=a.attributes.uv1,h=a.attributes.normal,m=a.groups,g=a.drawRange;if(o!==null)if(Array.isArray(s))for(let v=0,w=m.length;v<w;v++){const b=m[v],_=s[b.materialIndex],E=Math.max(b.start,g.start),M=Math.min(o.count,Math.min(b.start+b.count,g.start+g.count));for(let T=E,P=M;T<P;T+=3){const A=o.getX(T),R=o.getX(T+1),k=o.getX(T+2);i=qg(this,_,e,r,u,f,h,A,R,k),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const v=Math.max(0,g.start),w=Math.min(o.count,g.start+g.count);for(let b=v,_=w;b<_;b+=3){const E=o.getX(b),M=o.getX(b+1),T=o.getX(b+2);i=qg(this,s,e,r,u,f,h,E,M,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(s))for(let v=0,w=m.length;v<w;v++){const b=m[v],_=s[b.materialIndex],E=Math.max(b.start,g.start),M=Math.min(c.count,Math.min(b.start+b.count,g.start+g.count));for(let T=E,P=M;T<P;T+=3){const A=T,R=T+1,k=T+2;i=qg(this,_,e,r,u,f,h,A,R,k),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const v=Math.max(0,g.start),w=Math.min(c.count,g.start+g.count);for(let b=v,_=w;b<_;b+=3){const E=b,M=b+1,T=b+2;i=qg(this,s,e,r,u,f,h,E,M,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}};function eue(t,e,n,r,i,a,s,o){let c;if(e.side===zi?c=r.intersectTriangle(s,a,i,!0,o):c=r.intersectTriangle(i,a,s,e.side===Ol,o),c===null)return null;Yg.copy(o),Yg.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Yg);return u<n.near||u>n.far?null:{distance:u,point:Yg.clone(),object:t}}function qg(t,e,n,r,i,a,s,o,c,u){t.getVertexPosition(o,Hg),t.getVertexPosition(c,Wg),t.getVertexPosition(u,Gg);const f=eue(t,e,n,r,Hg,Wg,Gg,mN);if(f){const h=new Oe;gh.getBarycoord(mN,Hg,Wg,Gg,h),i&&(f.uv=gh.getInterpolatedAttribute(i,o,c,u,h,new $n)),a&&(f.uv1=gh.getInterpolatedAttribute(a,o,c,u,h,new $n)),s&&(f.normal=gh.getInterpolatedAttribute(s,o,c,u,h,new Oe),f.normal.dot(r.direction)>0&&f.normal.multiplyScalar(-1));const m={a:o,b:c,c:u,normal:new Oe,materialIndex:0};gh.getNormal(Hg,Wg,Gg,m.normal),f.face=m,f.barycoord=h}return f}class tue extends Ti{constructor(e=null,n=1,r=1,i,a,s,o,c,u=ni,f=ni,h,m){super(null,s,o,c,u,f,i,a,h,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const rw=new Oe,nue=new Oe,rue=new pn;class Mc{constructor(e=new Oe(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=rw.subVectors(r,n).cross(nue.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n){const r=e.delta(rw),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||rue.getNormalMatrix(e),i=this.coplanarPoint(rw).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const bc=new iM,iue=new $n(.5,.5),Xg=new Oe;class wU{constructor(e=new Mc,n=new Mc,r=new Mc,i=new Mc,a=new Mc,s=new Mc){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(a),o[5].copy(s),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Ls,r=!1){const i=this.planes,a=e.elements,s=a[0],o=a[1],c=a[2],u=a[3],f=a[4],h=a[5],m=a[6],g=a[7],v=a[8],w=a[9],b=a[10],_=a[11],E=a[12],M=a[13],T=a[14],P=a[15];if(i[0].setComponents(u-s,g-f,_-v,P-E).normalize(),i[1].setComponents(u+s,g+f,_+v,P+E).normalize(),i[2].setComponents(u+o,g+h,_+w,P+M).normalize(),i[3].setComponents(u-o,g-h,_-w,P-M).normalize(),r)i[4].setComponents(c,m,b,T).normalize(),i[5].setComponents(u-c,g-m,_-b,P-T).normalize();else if(i[4].setComponents(u-c,g-m,_-b,P-T).normalize(),n===Ls)i[5].setComponents(u+c,g+m,_+b,P+T).normalize();else if(n===by)i[5].setComponents(c,m,b,T).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),bc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),bc.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(bc)}intersectsSprite(e){bc.center.set(0,0,0);const n=iue.distanceTo(e.center);return bc.radius=.7071067811865476+n,bc.applyMatrix4(e.matrixWorld),this.intersectsSphere(bc)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(Xg.x=i.normal.x>0?e.max.x:e.min.x,Xg.y=i.normal.y>0?e.max.y:e.min.y,Xg.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Xg)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class SU extends Ti{constructor(e=[],n=ru,r,i,a,s,o,c,u,f){super(e,n,r,i,a,s,o,c,u,f),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class hp extends Ti{constructor(e,n,r=$s,i,a,s,o=ni,c=ni,u,f=jo,h=1){if(f!==jo&&f!==Uc)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:n,depth:h};super(m,i,a,s,o,c,f,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new rM(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}class aue extends hp{constructor(e,n=$s,r=ru,i,a,s=ni,o=ni,c,u=jo){const f={width:e,height:e,depth:1},h=[f,f,f,f,f,f];super(e,e,n,r,i,a,s,o,c,u),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class kU extends Ti{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Gp extends eo{constructor(e=1,n=1,r=1,i=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:s};const o=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const c=[],u=[],f=[],h=[];let m=0,g=0;v("z","y","x",-1,-1,r,n,e,s,a,0),v("z","y","x",1,-1,r,n,-e,s,a,1),v("x","z","y",1,1,e,r,n,i,s,2),v("x","z","y",1,-1,e,r,-n,i,s,3),v("x","y","z",1,-1,e,n,r,i,a,4),v("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Do(u,3)),this.setAttribute("normal",new Do(f,3)),this.setAttribute("uv",new Do(h,2));function v(w,b,_,E,M,T,P,A,R,k,N){const B=T/R,L=P/k,z=T/2,I=P/2,V=A/2,W=R+1,X=k+1;let J=0,F=0;const G=new Oe;for(let Y=0;Y<X;Y++){const H=Y*L-I;for(let te=0;te<W;te++){const re=te*B-z;G[w]=re*E,G[b]=H*M,G[_]=V,u.push(G.x,G.y,G.z),G[w]=0,G[b]=0,G[_]=A>0?1:-1,f.push(G.x,G.y,G.z),h.push(te/R),h.push(1-Y/k),J+=1}}for(let Y=0;Y<k;Y++)for(let H=0;H<R;H++){const te=m+H+W*Y,re=m+H+W*(Y+1),ue=m+(H+1)+W*(Y+1),ce=m+(H+1)+W*Y;c.push(te,re,ce),c.push(re,ue,ce),F+=6}o.addGroup(g,F,N),g+=F,m+=J}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Gp(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class pv extends eo{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,s=n/2,o=Math.floor(r),c=Math.floor(i),u=o+1,f=c+1,h=e/o,m=n/c,g=[],v=[],w=[],b=[];for(let _=0;_<f;_++){const E=_*m-s;for(let M=0;M<u;M++){const T=M*h-a;v.push(T,-E,0),w.push(0,0,1),b.push(M/o),b.push(1-_/c)}}for(let _=0;_<c;_++)for(let E=0;E<o;E++){const M=E+u*_,T=E+u*(_+1),P=E+1+u*(_+1),A=E+1+u*_;g.push(M,T,A),g.push(T,P,A)}this.setIndex(g),this.setAttribute("position",new Do(v,3)),this.setAttribute("normal",new Do(w,3)),this.setAttribute("uv",new Do(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pv(e.width,e.height,e.widthSegments,e.heightSegments)}}function Zd(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(ln("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function wi(t){const e={};for(let n=0;n<t.length;n++){const r=Zd(t[n]);for(const i in r)e[i]=r[i]}return e}function sue(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function EU(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:jn.workingColorSpace}const oue={clone:Zd,merge:wi};var lue=`void main() {
|
|
864
|
+
)`}return p.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})});function gy(t,e){t&&Object.assign(t.style,e)}const Vne={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},Hne={position:"fixed"},Wne=x.forwardRef(function(e,n){const{anchor:r,positionMethod:i="absolute",className:a,render:s,side:o="bottom",align:c="center",sideOffset:u=0,alignOffset:f=0,collisionBoundary:h="clipping-ancestors",collisionPadding:m,arrowPadding:g=5,sticky:v=!1,disableAnchorTracking:w,alignItemWithTrigger:b=!0,collisionAvoidance:_=$J,...E}=e,{store:M,listRef:T,labelsRef:P,alignItemWithTriggerActiveRef:A,selectedItemTextRef:R,valuesRef:k,initialValueRef:N,popupRef:B,setValue:L}=Wl(),z=m5(),I=mn(M,hn.open),V=mn(M,hn.mounted),W=mn(M,hn.modal),X=mn(M,hn.value),J=mn(M,hn.openMethod),F=mn(M,hn.positionerElement),G=mn(M,hn.triggerElement),Y=mn(M,hn.isItemEqualToValue),H=x.useRef(null),te=x.useRef(null),[re,ue]=x.useState(b),ce=V&&re&&J!=="touch";!V&&re!==b&&ue(b),Yt(()=>{V||(hn.scrollUpArrowVisible(M.state)&&M.set("scrollUpArrowVisible",!1),hn.scrollDownArrowVisible(M.state)&&M.set("scrollDownArrowVisible",!1))},[M,V]),x.useImperativeHandle(A,()=>ce),LE((ce||W)&&I&&J!=="touch",G);const ee=E5({anchor:r,floatingRootContext:z,positionMethod:i,mounted:V,side:o,sideOffset:u,align:c,alignOffset:f,arrowPadding:g,collisionBoundary:h,collisionPadding:m,sticky:v,disableAnchorTracking:w??ce,collisionAvoidance:_,keepMounted:!0}),le=ce?"none":ee.side,ve=ce?Hne:ee.positionerStyles,Ne=x.useMemo(()=>{const _e={};return I||(_e.pointerEvents="none"),{role:"presentation",hidden:!V,style:{...ve,..._e}}},[I,V,ve]),be=x.useMemo(()=>({open:I,side:le,align:ee.align,anchorHidden:ee.anchorHidden}),[I,le,ee.align,ee.anchorHidden]),qe=Bt(_e=>{M.set("positionerElement",_e)}),he=Xr("div",e,{ref:[n,qe],state:be,stateAttributesMapping:hu,props:[Ne,E]}),Ue=x.useRef(0),je=Bt(_e=>{if(_e.size===0&&Ue.current===0||k.current.length===0)return;const oe=Ue.current;if(Ue.current=_e.size,_e.size===oe)return;const Q=Mn(iv);if(oe!==0&&!M.state.multiple&&X!==null&&P1(k.current,X,Y)===-1){const Pe=N.current,Le=Pe!=null&&p_(k.current,Pe,Y)?Pe:null;L(Le,Q),Le===null&&(M.set("selectedIndex",null),R.current=null)}if(oe!==0&&M.state.multiple&&Array.isArray(X)){const ze=X.filter(Pe=>p_(k.current,Pe,Y));(ze.length!==X.length||ze.some(Pe=>!p_(X,Pe,Y)))&&(L(ze,Q),ze.length===0&&(M.set("selectedIndex",null),R.current=null))}if(I&&ce){M.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const ze={height:""};gy(F,ze),gy(B.current,ze)}}),et=x.useMemo(()=>({...ee,side:le,alignItemWithTriggerActive:ce,setControlledAlignItemWithTrigger:ue,scrollUpArrowRef:H,scrollDownArrowRef:te}),[ee,le,ce,ue]);return p.jsx(Rne,{elementsRef:T,labelsRef:P,onMapChange:je,children:p.jsxs(M5.Provider,{value:et,children:[V&&W&&p.jsx(IE,{inert:DE(!I),cutout:G}),he]})})});function T5(t){const e=t.currentTarget.getBoundingClientRect();return e.top+1<=t.clientY&&t.clientY<=e.bottom-1&&e.left+1<=t.clientX&&t.clientX<=e.right-1}const Mg="base-ui-disable-scrollbar",iR={className:Mg,getElement(t){return p.jsx("style",{nonce:t,href:Mg,precedence:"base-ui:low",children:`.${Mg}{scrollbar-width:none}.${Mg}::-webkit-scrollbar{display:none}`})}},Gne=x.createContext(void 0);function C5(t){return x.useContext(Gne)}const A5="ArrowUp",P5="ArrowDown",R5="ArrowLeft",N5="ArrowRight",D5="Home",L5="End",$ne=new Set([R5,N5]),Yne=new Set([A5,P5]),qne=new Set([...$ne,...Yne]);[...qne];const OE=new Set([A5,P5,R5,N5,D5,L5]);function FE(t){return t==="starting"?GJ:ei}function Xne(t,e=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(e,Math.min(t,n))}const Kne=x.createContext(void 0),Zne={disableStyleElements:!1};function Jne(){return x.useContext(Kne)??Zne}const Qne={...hu,...df},ere=x.forwardRef(function(e,n){const{render:r,className:i,...a}=e,{store:s,popupRef:o,onOpenChangeComplete:c,setOpen:u,valueRef:f,selectedItemTextRef:h,keyboardActiveRef:m,multiple:g,handleScrollArrowVisibility:v,scrollHandlerRef:w,highlightItemOnHover:b}=Wl(),{side:_,align:E,alignItemWithTriggerActive:M,setControlledAlignItemWithTrigger:T,scrollDownArrowRef:P,scrollUpArrowRef:A}=zne(),R=C5()!=null,k=m5(),{nonce:N,disableStyleElements:B}=Jne(),L=ji(),z=mn(s,hn.id),I=mn(s,hn.open),V=mn(s,hn.mounted),W=mn(s,hn.popupProps),X=mn(s,hn.transitionStatus),J=mn(s,hn.triggerElement),F=mn(s,hn.positionerElement),G=mn(s,hn.listElement),Y=x.useRef(0),H=x.useRef(!1),te=x.useRef(0),re=x.useRef(!1),ue=x.useRef({}),ce=rv(),ee=Bt(be=>{if(!F||!o.current||!re.current)return;if(H.current||!M){v();return}const qe=F.style.top==="0px",he=F.style.bottom==="0px",Ue=F.getBoundingClientRect().height,je=Gs(F),et=getComputedStyle(F),_e=parseFloat(et.marginTop),oe=parseFloat(et.marginBottom),Q=aR(getComputedStyle(o.current)),ze=je.documentElement.clientHeight-_e-oe,Pe=be.scrollTop,De=be.scrollHeight,Le=be.clientHeight,$=De-Le;let U=0,Z=null,pe=!1;if(qe){const Se=$-Pe,xe=Ue+Se,Ie=Math.min(xe,ze);U=Ie,Ie!==ze?Z=$:pe=!0}else if(he){const Se=Pe-0,xe=Ue+Se,Ie=Math.min(xe,ze),He=xe-ze;U=Ie,Ie!==ze?Z=0:(pe=!0,Pe<$&&(Z=Pe-(Se-He)))}U!==0&&(F.style.height=`${U}px`),Z!=null&&(be.scrollTop=Z),(pe||U>=Q)&&(H.current=!0),v()});x.useImperativeHandle(w,()=>ee,[ee]),ff({open:I,ref:o,onComplete(){I&&c?.(!0)}});const le=x.useMemo(()=>({open:I,transitionStatus:X,side:_,align:E}),[I,X,_,E]);Yt(()=>{!F||!o.current||Object.keys(ue.current).length||(ue.current={top:F.style.top||"0",left:F.style.left||"0",right:F.style.right,height:F.style.height,bottom:F.style.bottom,minHeight:F.style.minHeight,maxHeight:F.style.maxHeight,marginTop:F.style.marginTop,marginBottom:F.style.marginBottom})},[o,F]),Yt(()=>{I||M||(re.current=!1,H.current=!1,Y.current=0,te.current=0,gy(F,ue.current))},[I,M,F,o]),Yt(()=>{const be=o.current;if(!(!I||!J||!F||!be||s.state.transitionStatus==="ending")){if(!M){re.current=!0,ce.request(v),be.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const qe=nre(be);be.style.removeProperty("--transform-origin");try{const he=getComputedStyle(F),Ue=getComputedStyle(be),je=Gs(J),et=Rr(F),_e=J.getBoundingClientRect(),oe=F.getBoundingClientRect(),Q=_e.left,ze=_e.height,Pe=G||be,De=Pe.scrollHeight,Le=parseFloat(Ue.borderBottomWidth),$=parseFloat(he.marginTop)||10,U=parseFloat(he.marginBottom)||10,Z=parseFloat(he.minHeight)||100,pe=aR(Ue),Se=5,xe=5,Ie=20,He=je.documentElement.clientHeight-$-U,Ye=je.documentElement.clientWidth,ft=He-_e.bottom+ze,We=h.current,Xe=f.current;let nt,ct=0,Ke=0;if(We&&Xe){const _t=Xe.getBoundingClientRect();nt=We.getBoundingClientRect();const wt=_t.left-Q,un=nt.left-oe.left,xn=_t.top-_e.top+_t.height/2,ie=nt.top-oe.top+nt.height/2;ct=wt-un,Ke=ie-xn}const gt=ft+Ke+U+Le;let ne=Math.min(He,gt);const Be=He-$-U,ke=gt-ne,Ae=Math.max(Se,Q+ct),Ve=Ye-xe,ge=Math.max(0,Ae+oe.width-Ve);F.style.left=`${Ae-ge}px`,F.style.height=`${ne}px`,F.style.maxHeight="auto",F.style.marginTop=`${$}px`,F.style.marginBottom=`${U}px`,be.style.height="100%";const ut=Pe.scrollHeight-Pe.clientHeight,yt=ke>=ut;yt&&(ne=Math.min(He,oe.height)-(ke-ut));const qt=_e.top<Ie||_e.bottom>He-Ie||ne<Math.min(De,Z),Lt=(et.visualViewport?.scale??1)!==1&&_4;if(qt||Lt){re.current=!0,gy(F,ue.current),gi.flushSync(()=>T(!1));return}if(yt){const _t=Math.max(0,He-gt);F.style.top=oe.height>=Be?"0":`${_t}px`,F.style.height=`${ne}px`,Pe.scrollTop=Pe.scrollHeight-Pe.clientHeight,Y.current=Math.max(Z,ne)}else F.style.bottom="0",Y.current=Math.max(Z,ne),Pe.scrollTop=ke;if(nt){const _t=oe.top,wt=oe.height,un=nt.top+nt.height/2,xn=wt>0?(un-_t)/wt*100:50,ie=Xne(xn,0,100);be.style.setProperty("--transform-origin",`50% ${ie}%`)}(Y.current===He||ne>=pe)&&(H.current=!0),v(),setTimeout(()=>{re.current=!0})}finally{qe()}})}},[s,I,F,J,f,h,o,v,M,T,ce,P,A,G]),x.useEffect(()=>{if(!M||!F||!I)return;const be=Rr(F);function qe(he){u(!1,Mn(Cee,he))}return be.addEventListener("resize",qe),()=>{be.removeEventListener("resize",qe)}},[u,M,F,I]);const ve={...G?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":g||void 0,id:`${z}-list`},onKeyDown(be){m.current=!0,R&&OE.has(be.key)&&be.stopPropagation()},onMouseMove(){m.current=!1},onPointerLeave(be){if(!b||T5(be)||be.pointerType==="touch")return;const qe=be.currentTarget;L.start(0,()=>{s.set("activeIndex",null),qe.focus({preventScroll:!0})})},onScroll(be){G||w.current?.(be.currentTarget)},...M&&{style:G?{height:"100%"}:Vne}},Ne=Xr("div",e,{ref:[n,o],state:le,stateAttributesMapping:Qne,props:[W,ve,FE(X),{className:!G&&M?iR.className:void 0},a]});return p.jsxs(x.Fragment,{children:[!B&&iR.getElement(N),p.jsx(ME,{context:k,modal:!1,disabled:!V,restoreFocus:!0,children:Ne})]})});function aR(t){const e=t.maxHeight||"";return e.endsWith("px")&&parseFloat(e)||1/0}const sR={transform:"none",scale:"1",translate:"0 0"};function tre(t,e,n){n?t.setProperty(e,n):t.removeProperty(e)}function nre(t){const{style:e}=t,n={},r=Object.keys(sR);for(const i of r)n[i]=e.getPropertyValue(i),e.setProperty(i,sR[i]);return()=>{for(const i of r)tre(e,i,n[i])}}let I5=(function(t){return t[t.None=0]="None",t[t.GuessFromOrder=1]="GuessFromOrder",t})({});function rre(t={}){const{label:e,metadata:n,textRef:r,indexGuessBehavior:i,index:a}=t,{register:s,unregister:o,subscribeMapChange:c,elementsRef:u,labelsRef:f,nextIndexRef:h}=Pne(),m=x.useRef(-1),[g,v]=x.useState(a??(i===I5.GuessFromOrder?()=>{if(m.current===-1){const _=h.current;h.current+=1,m.current=_}return m.current}:-1)),w=x.useRef(null),b=x.useCallback(_=>{if(w.current=_,g!==-1&&_!==null&&(u.current[g]=_,f)){const E=e!==void 0;f.current[g]=E?e:r?.current?.textContent??_.textContent}},[g,u,f,e,r]);return Yt(()=>{if(a!=null)return;const _=w.current;if(_)return s(_,n),()=>{o(_)}},[a,s,o,n]),Yt(()=>{if(a==null)return c(_=>{const E=w.current?_.get(w.current)?.index:null;E!=null&&v(E)})},[a,c,v]),x.useMemo(()=>({ref:b,index:g}),[g,b])}const O5=x.createContext(void 0);function UE(){const t=x.useContext(O5);if(!t)throw new Error(Wi(57));return t}const oR=x.memo(x.forwardRef(function(e,n){const{render:r,className:i,value:a=null,label:s,disabled:o=!1,nativeButton:c=!1,...u}=e,f=x.useRef(null),h=rre({label:s,textRef:f,indexGuessBehavior:I5.GuessFromOrder}),{store:m,getItemProps:g,setOpen:v,setValue:w,selectionRef:b,typingRef:_,valuesRef:E,keyboardActiveRef:M,multiple:T,highlightItemOnHover:P}=Wl(),A=ji(),R=mn(m,hn.isActive,h.index),k=mn(m,hn.isSelected,h.index,a),N=mn(m,hn.isSelectedByFocus,h.index),B=mn(m,hn.isItemEqualToValue),L=h.index,z=L!==-1,I=x.useRef(null),V=jr(L);Yt(()=>{if(!z)return;const ee=E.current;return ee[L]=a,()=>{delete ee[L]}},[z,L,a,E]),Yt(()=>{if(!z)return;const ee=m.state.value;let le=ee;T&&Array.isArray(ee)&&ee.length>0&&(le=ee[ee.length-1]),le!==void 0&&$d(le,a,B)&&m.set("selectedIndex",L)},[z,L,T,B,m,a]);const W=x.useMemo(()=>({disabled:o,selected:k,highlighted:R}),[o,k,R]),X=g({active:R,selected:k});X.onFocus=void 0,X.id=void 0;const J=x.useRef(null),F=x.useRef("mouse"),G=x.useRef(!1),{getButtonProps:Y,buttonRef:H}=nv({disabled:o,focusableWhenDisabled:!0,native:c});function te(ee){const le=m.state.value;if(T){const ve=Array.isArray(le)?le:[],Ne=k?ene(ve,a,B):[...ve,a];w(Ne,Mn(a_,ee))}else w(a,Mn(a_,ee)),v(!1,Mn(a_,ee))}const re={role:"option","aria-selected":k,tabIndex:R?0:-1,onFocus(){m.set("activeIndex",L)},onMouseEnter(){!M.current&&m.state.selectedIndex===null&&m.set("activeIndex",L)},onMouseMove(){P&&m.set("activeIndex",L)},onMouseLeave(ee){!P||M.current||T5(ee)||A.start(0,()=>{m.state.activeIndex===L&&m.set("activeIndex",null)})},onTouchStart(){b.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(ee){J.current=ee.key,m.set("activeIndex",L)},onClick(ee){G.current=!1,!(ee.type==="keydown"&&J.current===null)&&(o||J.current===" "&&_.current||F.current!=="touch"&&!R||(J.current=null,te(ee.nativeEvent)))},onPointerEnter(ee){F.current=ee.pointerType},onPointerDown(ee){F.current=ee.pointerType,G.current=!0},onMouseUp(ee){if(o)return;if(G.current){G.current=!1;return}const le=!b.current.allowSelectedMouseUp&&k,ve=!b.current.allowUnselectedMouseUp&&!k;le||ve||F.current!=="touch"&&!R||te(ee.nativeEvent)}},ue=Xr("div",e,{ref:[H,n,h.ref,I],state:W,props:[X,re,u,Y]}),ce=x.useMemo(()=>({selected:k,indexRef:V,textRef:f,selectedByFocus:N,hasRegistered:z}),[k,V,f,N,z]);return p.jsx(O5.Provider,{value:ce,children:ue})})),lR=x.forwardRef(function(e,n){const r=e.keepMounted??!1,{selected:i}=UE();return r||i?p.jsx(ire,{...e,ref:n}):null}),ire=x.memo(x.forwardRef((t,e)=>{const{render:n,className:r,keepMounted:i,...a}=t,{selected:s}=UE(),o=x.useRef(null),{transitionStatus:c,setMounted:u}=PE(s),f=x.useMemo(()=>({selected:s,transitionStatus:c}),[s,c]),h=Xr("span",t,{ref:[e,o],state:f,props:[{"aria-hidden":!0,children:"✔️"},a],stateAttributesMapping:df});return ff({open:s,ref:o,onComplete(){s||u(!1)}}),h})),cR=x.memo(x.forwardRef(function(e,n){const{indexRef:r,textRef:i,selectedByFocus:a,hasRegistered:s}=UE(),{selectedItemTextRef:o}=Wl(),{className:c,render:u,...f}=e,h=x.useCallback(g=>{if(!g||!s)return;const v=o.current===null||!o.current.isConnected;(a||v&&r.current===0)&&(o.current=g)},[o,r,a,s]);return Xr("div",e,{ref:[h,n,i],props:f})}));function F5({prefersReducedMotion:t,screenshotCapture:e}){return!(e||t)}function are({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z"})})}function sre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",className:e,children:p.jsx("path",{d:"M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z"})})}function ore({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M22.106 5.68L12.5.135a.998.998 0 00-.998 0L1.893 5.68a.84.84 0 00-.419.726v11.186c0 .3.16.577.42.727l9.607 5.547a.999.999 0 00.998 0l9.608-5.547a.84.84 0 00.42-.727V6.407a.84.84 0 00-.42-.726zm-.603 1.176L12.228 22.92c-.063.108-.228.064-.228-.061V12.34a.59.59 0 00-.295-.51l-9.11-5.26c-.107-.062-.063-.228.062-.228h18.55c.264 0 .428.286.296.514z"})})}function lre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z"})})}function cre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 -1 22 28",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M4.125 20.149c-2.69 5.959 3.036 7.453 7.26 3.966 1.24 3.91 5.898.993 7.569-2.036 3.682-6.678 2.195-13.49 1.813-14.895-2.617-9.582-15.699-9.592-17.95.049-.526 1.687-.535 3.606-.833 5.598-.15 1.005-.256 1.646-.645 2.703-.223.607-.53 1.147-1.014 2.056-.75 1.412-.434 4.138 3.434 2.724v.001ZM11.895 11.332c-1.073 0-1.234-1.283-1.234-2.048 0-.69.124-1.239.358-1.586a1 1 0 0 1 .876-.462c.375 0 .697.158.924.47.259.354.395.9.395 1.578 0 1.283-.493 2.048-1.319 2.048Zm4.416 0c-1.073 0-1.234-1.283-1.234-2.048 0-.69.124-1.239.358-1.586a1 1 0 0 1 .876-.462c.375 0 .697.158.924.47.259.354.396.9.396 1.578 0 1.283-.494 2.048-1.32 2.048Z"})})}function ure({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M16 6H8v12h8V6zm4 16H4V2h16v20z"})})}function dre({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:[p.jsx("path",{d:"M21.846 0a1.923 1.923 0 110 3.846H20.15a.226.226 0 01-.227-.226V1.923C19.923.861 20.784 0 21.846 0z"}),p.jsx("path",{d:"M11.065 11.199l7.257-7.2c.137-.136.06-.41-.116-.41H14.3a.164.164 0 00-.117.051l-7.82 7.756c-.122.12-.302.013-.302-.179V3.82c0-.127-.083-.23-.185-.23H3.186c-.103 0-.186.103-.186.23V19.77c0 .128.083.23.186.23h2.69c.103 0 .186-.102.186-.23v-3.25c0-.069.025-.135.069-.178l2.424-2.406a.158.158 0 01.205-.023l6.484 4.772a7.677 7.677 0 003.453 1.283c.108.012.2-.095.2-.23v-3.06c0-.117-.07-.212-.164-.227a5.028 5.028 0 01-2.027-.807l-5.613-4.064c-.117-.078-.132-.279-.028-.381z"})]})}function fre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M19.245 5.364c1.322 1.36 1.877 3.216 2.11 5.817.622 0 1.2.135 1.592.654l.73.964c.21.278.323.61.323.955v2.62c0 .339-.173.669-.453.868C20.239 19.602 16.157 21.5 12 21.5c-4.6 0-9.205-2.583-11.547-4.258-.28-.2-.452-.53-.453-.868v-2.62c0-.345.113-.679.321-.956l.73-.963c.392-.517.974-.654 1.593-.654l.029-.297c.25-2.446.81-4.213 2.082-5.52 2.461-2.54 5.71-2.851 7.146-2.864h.198c1.436.013 4.685.323 7.146 2.864zm-7.244 4.328c-.284 0-.613.016-.962.05-.123.447-.305.85-.57 1.108-1.05 1.023-2.316 1.18-2.994 1.18-.638 0-1.306-.13-1.851-.464-.516.165-1.012.403-1.044.996a65.882 65.882 0 00-.063 2.884l-.002.48c-.002.563-.005 1.126-.013 1.69.002.326.204.63.51.765 2.482 1.102 4.83 1.657 6.99 1.657 2.156 0 4.504-.555 6.985-1.657a.854.854 0 00.51-.766c.03-1.682.006-3.372-.076-5.053-.031-.596-.528-.83-1.046-.996-.546.333-1.212.464-1.85.464-.677 0-1.942-.157-2.993-1.18-.266-.258-.447-.661-.57-1.108-.32-.032-.64-.049-.96-.05zm-2.525 4.013c.539 0 .976.426.976.95v1.753c0 .525-.437.95-.976.95a.964.964 0 01-.976-.95v-1.752c0-.525.437-.951.976-.951zm5 0c.539 0 .976.426.976.95v1.753c0 .525-.437.95-.976.95a.964.964 0 01-.976-.95v-1.752c0-.525.437-.951.976-.951zM7.635 5.087c-1.05.102-1.935.438-2.385.906-.975 1.037-.765 3.668-.21 4.224.405.394 1.17.657 1.995.657h.09c.649-.013 1.785-.176 2.73-1.11.435-.41.705-1.433.675-2.47-.03-.834-.27-1.52-.63-1.813-.39-.336-1.275-.482-2.265-.394zm6.465.394c-.36.292-.6.98-.63 1.813-.03 1.037.24 2.06.675 2.47.968.957 2.136 1.104 2.776 1.11h.044c.825 0 1.59-.263 1.995-.657.555-.556.765-3.187-.21-4.224-.45-.468-1.335-.804-2.385-.906-.99-.088-1.875.058-2.265.394zM12 7.615c-.24 0-.525.015-.84.044.03.16.045.336.06.526l-.001.159a2.94 2.94 0 01-.014.25c.225-.022.425-.027.612-.028h.366c.187 0 .387.006.612.028-.015-.146-.015-.277-.015-.409.015-.19.03-.365.06-.526a9.29 9.29 0 00-.84-.044z"})})}function hre({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 64 60",fill:"none",className:e,"aria-hidden":"true",children:[p.jsx("path",{fill:"currentColor",d:"M37.2114 3.75318C37.6821 3.33106 37.7106 3.31457 38.0558 3.29385C38.6149 3.2531 39.1272 3.52199 39.9989 4.31564C42.0356 6.16652 44.8714 9.97183 46.6346 13.2212L47.3163 14.4819L48.2782 14.9605C49.2072 15.4299 50.7308 16.3923 51.3672 16.9085C51.655 17.1464 51.6956 17.1508 51.9947 17.0344C53.3454 16.5084 55.2803 17.206 56.9869 18.8432C58.5231 20.3155 59.9943 22.8312 60.558 24.9308C60.6403 25.2687 60.7493 25.9952 60.7891 26.5362C60.9177 28.4358 60.3092 29.9532 59.1362 30.64C58.8965 30.7784 58.8801 30.8158 58.8868 31.4132C58.9409 34.2583 58.1741 37.0985 56.6335 39.8679C54.8946 42.9773 51.7981 46.1938 47.6074 49.2243C45.357 50.8619 40.0323 53.964 37.6248 55.0532C31.8578 57.6496 27.2346 58.646 23.2188 58.154C20.8236 57.8638 18.1124 56.9287 16.5082 55.8433C16.086 55.5515 16.0191 55.5329 15.6966 55.6251C13.9793 56.1185 11.73 55.1053 9.81931 52.9844C9.05725 52.1366 7.82714 50.0548 7.42839 48.9409C6.50606 46.3339 6.68976 43.9816 7.91836 42.5767C8.23573 42.2149 8.2453 42.1995 8.17598 41.5912C8.06148 40.5951 8.00971 39.1206 8.06202 38.1692L8.10361 37.2803L6.76977 34.9212C4.70378 31.2451 3.3912 28.1582 2.88489 25.7998C2.61762 24.5066 2.63385 23.9324 2.96214 23.5078C3.16198 23.2515 3.81796 22.9866 4.60785 22.8407C6.59665 22.4917 10.9334 22.8076 15.7581 23.6595L16.259 23.7458L17.3608 22.7713C19.1891 21.1519 20.4038 20.244 22.6429 18.8478C24.9768 17.3876 27.6108 16.1858 30.577 15.2346L31.5295 14.9294L32.0526 13.5561C33.9257 8.61146 35.8437 4.96584 37.2114 3.75318ZM21.5208 29.0919C19.404 30.314 18.3453 30.9251 17.5676 31.6099C14.4179 34.3835 13.2414 38.777 14.5823 42.7537C14.9135 43.7357 15.5247 44.7942 16.7469 46.9111C17.9691 49.0279 18.5801 50.0865 19.2649 50.8643C22.0385 54.014 26.4316 55.1918 30.4084 53.8509C31.3904 53.5198 32.4489 52.9085 34.5657 51.6863L46.7442 44.6551C48.8613 43.4328 49.9205 42.8214 50.6983 42.1365C53.8479 39.363 55.0245 34.9695 53.6835 30.9927C53.3524 30.0107 52.7412 28.9522 51.519 26.8354C50.2968 24.7185 49.6858 23.66 49.0009 22.8822C46.2274 19.7325 41.8342 18.5547 37.8575 19.8956C36.8754 20.2267 35.8163 20.8383 33.6993 22.0606L21.5208 29.0919Z"}),p.jsx("g",{transform:"rotate(-30 22.6953 37.6011)",children:p.jsx("rect",{x:"22.6953",y:"37.6011",width:"4.81084",height:"9.99175",rx:"2.40542",fill:"currentColor"})}),p.jsx("g",{transform:"rotate(-30 35.6748 30.1074)",children:p.jsx("rect",{x:"35.6748",y:"30.1074",width:"4.81084",height:"9.99175",rx:"2.40542",fill:"currentColor"})})]})}function pre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",className:e,children:p.jsx("path",{d:"M7 2h10a5 5 0 015 5v10a5 5 0 01-5 5H7a5 5 0 01-5-5V7a5 5 0 015-5zm0 4.5v11h2.35v-4.55h5.3V17.5H17v-11h-2.35v4.1h-5.3V6.5H7z"})})}function mre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"currentColor",className:e,children:p.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})}function gre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":"true",children:p.jsx("g",{transform:"translate(3.4502, 3)",fill:"#9570BE",children:p.jsx("path",{d:"M3.17890888,3.6 L3.17890888,0 L16,0 L16,3.6 L3.17890888,3.6 Z M9.642,7.2 L9.64218223,10.8 L0,10.8 L0,3.6 L16,3.6 L16,7.2 L9.642,7.2 Z M3.17890888,18 L3.178,14.4 L0,14.4 L0,10.8 L16,10.8 L16,18 L3.17890888,18 Z",fillRule:"nonzero"})})})}function yre({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 120 90",fill:"currentColor",className:e,children:[p.jsx("rect",{x:"10",y:"8",width:"100",height:"12",rx:"2"}),p.jsx("rect",{x:"25",y:"20",width:"12",height:"62",rx:"2"}),p.jsx("rect",{x:"75",y:"20",width:"12",height:"45",rx:"2"}),p.jsx("rect",{x:"71",y:"55",width:"20",height:"16",rx:"3"}),p.jsx("rect",{x:"76",y:"71",width:"3",height:"8",rx:"1"}),p.jsx("rect",{x:"82",y:"71",width:"3",height:"8",rx:"1"})]})}function vre({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 120 90",fill:"currentColor",className:e,children:[p.jsx("rect",{x:"10",y:"8",width:"100",height:"12",rx:"2"}),p.jsx("rect",{x:"25",y:"20",width:"12",height:"62",rx:"2"}),p.jsx("rect",{x:"83",y:"20",width:"12",height:"62",rx:"2"})]})}const xre={CLAUDE:are,CODEBUDDY:hre,CODEX:sre,COPILOT:fre,CRAFT:gre,CURSOR:ore,GEMINI:lre,GITHUB:mre,HERMES:pre,KIMI:dre,KIRO:cre,OPENCODE:ure,OMP:yre,PI:vre},bre={ANTIGRAVITY:"/brand-logos/antigravity.svg",CLAUDE:"/brand-logos/claude-code.svg",CODEX:"/brand-logos/codex.svg",GEMINI:"/brand-logos/gemini.svg",HERMES:"/brand-logos/hermes.svg",OPENCLAW:"/brand-logos/openclaw.svg",OPENCODE:"/brand-logos/opencode.svg"};function nu({provider:t,size:e=16,color:n,className:r=""}){const i=t?.toUpperCase?.()||"",a=bre[i];if(a)return p.jsx("img",{src:a,alt:"",width:e,height:e,className:r,style:{width:e,height:e,objectFit:"contain"},"aria-hidden":!0});const s=xre[i];return s?p.jsx(s,{size:e,className:r}):p.jsx("div",{className:"rounded-full shrink-0",style:{width:e*.5,height:e*.5,backgroundColor:n}})}function pu({children:t,title:e,subtitle:n,className:r="",bodyClassName:i=""}){return p.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 transition-colors duration-200 ${r}`,children:[(e||n)&&p.jsxs("div",{className:"px-5 py-4 border-b border-oai-gray-200 dark:border-oai-gray-800 transition-colors duration-200",children:[e&&p.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide transition-colors duration-200",children:e}),n&&p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300 mt-1 transition-colors duration-200",children:n})]}),p.jsx("div",{className:`p-5 ${i}`,children:t})]})}function _re(){return p.jsxs(Ei,{to:"/landing",className:"flex items-center gap-2.5 no-underline hover:opacity-80 transition-opacity",children:[p.jsx("img",{src:"/app-icon.png",alt:"Token Tracker",width:28,height:28,className:"rounded-md"}),p.jsx("span",{className:"text-base font-semibold text-oai-black dark:text-oai-white leading-tight",children:"Token Tracker"})]})}function wre({children:t,header:e,footer:n,className:r="",hideHeader:i=!1,hideFooter:a=!1,bare:s=!1}){return s?p.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${r}`,children:[p.jsx("main",{className:"flex-1 px-6 py-6",children:t}),!a&&n&&p.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 mt-auto transition-colors duration-200",children:n})]}):p.jsxs("div",{className:`min-h-screen bg-oai-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-sans flex flex-col transition-colors duration-200 ${r}`,children:[!i&&p.jsxs("header",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 flex items-center justify-between transition-colors duration-200",children:[p.jsx(_re,{}),p.jsx("div",{className:"flex-1 flex justify-center",children:e})]}),p.jsx("main",{className:"flex-1 px-6 py-6",children:t}),!a&&n&&p.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 mt-auto transition-colors duration-200",children:n})]})}function Sre(t){if(!t||typeof t!="object")return null;const e=t.user_metadata&&typeof t.user_metadata=="object"?t.user_metadata:{},n=t.profile&&typeof t.profile=="object"?t.profile:{},r=e.avatar_url||e.picture||n.avatar_url||t.avatar_url;return typeof r=="string"&&r.trim()?r.trim():null}function uR(t){const e=String(t||"").trim();if(!e)return"?";const n=e.split(/\s+/).filter(Boolean);return n.length>=2?(n[0][0]+n[n.length-1][0]).toUpperCase():e.slice(0,2).toUpperCase()}function yy({className:t,variant:e="header",collapsed:n=!1,onAfterAction:r}){lu();const i=e==="sidebar",{enabled:a,loading:s,signedIn:o,user:c,displayName:u}=ls(),{openLoginModal:f}=Cp(),h=tf(),m=x.useMemo(()=>Sre(c),[c]);if(!a)return null;if(s)return p.jsx("div",{className:vt("h-9 w-9 shrink-0 rounded-full bg-oai-gray-200 dark:bg-oai-gray-800 animate-pulse",t),"aria-hidden":!0});if(!o)return i?p.jsxs("button",{type:"button",onClick:()=>{f(),r?.()},className:vt("flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px] font-medium text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 min-w-0",n?"h-8 w-8 justify-center px-0":"w-full",t),"aria-label":O("header.auth.sign_in_aria"),title:n?O("header.auth.sign_in_aria"):void 0,children:[p.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:p.jsx("img",{src:"/app-icon.png",alt:"",width:18,height:18,className:"h-[18px] w-[18px] rounded"})}),!n&&p.jsx("span",{className:"truncate flex-1 text-left",children:O("header.auth.sign_in_aria")})]}):p.jsx("button",{type:"button",onClick:f,className:vt("shrink-0 inline-flex h-9 items-center justify-center gap-1.5 rounded-full px-5 text-sm font-medium transition-colors duration-200 ease-out shadow-sm ring-1 ring-oai-gray-200 dark:ring-white/10 bg-oai-gray-900 text-white hover:bg-oai-gray-800 active:bg-oai-gray-950 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 dark:active:bg-oai-gray-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-oai-gray-950",t),"aria-label":O("header.auth.sign_in_aria"),children:O("header.auth.sign_in_aria")});const g=()=>{h("/settings"),r?.()};return p.jsx("div",{className:vt(i?"relative flex w-full shrink-0 items-center":"relative flex shrink-0 items-center",t),children:p.jsxs("button",{type:"button",onClick:g,className:vt(i?vt("flex w-full items-center gap-2 rounded-md px-2 py-1.5 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 transition-colors min-w-0",n&&"justify-center px-0 py-0 h-9 w-9"):"flex items-center gap-2 rounded-full pl-1 pr-2 py-1 border border-transparent hover:bg-oai-gray-100 dark:hover:bg-oai-gray-900/80 hover:border-oai-gray-200 dark:hover:border-oai-gray-800 transition-colors"),"aria-label":O("header.auth.open_settings"),title:i&&n?u:void 0,children:[i?p.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:m?p.jsx("img",{src:m,alt:"",width:20,height:20,className:"h-5 w-5 rounded-full object-cover ring-1 ring-oai-gray-300 dark:ring-oai-gray-700",referrerPolicy:"no-referrer"}):p.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-oai-brand-600 text-[9px] font-semibold text-white ring-1 ring-oai-brand-500/50",children:uR(u)})}):m?p.jsx("img",{src:m,alt:"",width:32,height:32,className:"h-8 w-8 rounded-full object-cover ring-1 ring-oai-gray-300 dark:ring-oai-gray-700 shrink-0",referrerPolicy:"no-referrer"}):p.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-oai-brand-600 text-xs font-semibold text-white ring-1 ring-oai-brand-500/50",children:uR(u)}),i?!n&&p.jsx("span",{className:"truncate text-[13px] font-medium text-oai-gray-900 dark:text-oai-gray-200 flex-1 text-left min-w-0",children:u}):p.jsx("span",{className:"hidden sm:inline truncate text-sm font-medium text-oai-gray-900 dark:text-oai-gray-200 max-w-[120px]",children:u})]})})}const D1="tt.sidebarCollapsed";function kre(){return[{id:"general",label:O("nav.group.general"),items:[{id:"usage",to:"/dashboard",icon:IW,label:O("nav.usage")},{id:"limits",to:"/limits",icon:WW,label:O("nav.limits")},{id:"leaderboard",to:"/leaderboard",icon:SG,label:O("nav.leaderboard")}]},{id:"tools",label:O("nav.group.tools"),items:[{id:"widgets",to:"/widgets",icon:JW,label:O("nav.widgets")},{id:"skills",to:"/skills",icon:fG,label:O("nav.skills")},{id:"ip-check",to:"/ip-check",icon:$W,label:O("nav.ip_check")}]},{id:"account",label:O("nav.group.account"),items:[{id:"settings",to:"/settings",icon:H3,label:O("nav.settings")}]}]}function Ere(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(D1)==="1"}catch{return!1}}function Mre(){const[t,e]=x.useState(Ere),n=x.useCallback(()=>{e(r=>{const i=!r;try{typeof window<"u"&&window.localStorage.setItem(D1,i?"1":"0")}catch{}return i})},[]);return x.useEffect(()=>{if(typeof window>"u")return;const r=i=>{i.key===D1&&e(i.newValue==="1")};return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)},[]),{collapsed:t,toggle:n}}function Tre(t,e){const n=t.replace(/\/+$/,"")||"/";return e==="/dashboard"?n==="/dashboard"||n==="/":e==="/leaderboard"?n==="/leaderboard"||n.startsWith("/leaderboard/"):n===e}function Cre({label:t,collapsed:e,first:n}){return e?n?null:p.jsx("div",{className:"mx-2 my-2 h-px bg-oai-gray-200/70 dark:bg-oai-gray-800/70","aria-hidden":!0}):p.jsx("div",{className:vt("px-3 pb-1 text-[10px] uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-500",n?"pt-2":"pt-4"),children:t})}function Are({item:t,collapsed:e,active:n,onClick:r}){const i=t.icon;return p.jsxs(Ei,{to:t.to,onClick:r,title:e?t.label:void 0,"aria-current":n?"page":void 0,className:vt("flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px] no-underline transition-colors",e&&"justify-center px-0 py-2",n?"bg-oai-gray-200/70 text-oai-black font-medium dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/50 hover:text-oai-black dark:hover:bg-oai-gray-800/60 dark:hover:text-white"),children:[p.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:p.jsx(i,{className:"h-[15px] w-[15px]","aria-hidden":!0})}),!e&&p.jsx("span",{className:"truncate",children:t.label})]})}function Pre({as:t="button",title:e,onClick:n,href:r,children:i,className:a,...s}){const o=vt("flex h-10 w-10 items-center justify-center rounded-lg text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",a);return t==="a"?p.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",title:e,"aria-label":e,className:o,...s,children:i}):p.jsx("button",{type:"button",title:e,"aria-label":e,onClick:n,className:o,...s,children:i})}function Rre({repo:t="mm7894215/TokenTracker",glassChrome:e=!1}){const[n,r]=x.useState(null);return x.useEffect(()=>{if(typeof window>"u")return;const i=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;F5({prefersReducedMotion:i,screenshotCapture:!1})&&fetch(`https://api.github.com/repos/${t}`).then(a=>a.json()).then(a=>{a&&typeof a.stargazers_count=="number"&&r(a.stargazers_count)}).catch(()=>{})},[t]),p.jsxs("a",{href:`https://github.com/${t}`,target:"_blank",rel:"noopener noreferrer","aria-label":n!==null?`Star on GitHub (${n})`:"Star on GitHub",className:vt("inline-flex h-7 items-center gap-1.5 rounded-full px-2.5 text-xs font-medium transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"border border-gray-500/20 dark:border-gray-500/30 bg-gray-500/[0.04] dark:bg-gray-500/[0.06] backdrop-blur-[2px] text-oai-gray-700 dark:text-oai-gray-300 hover:bg-gray-500/10 dark:hover:bg-gray-500/12 hover:border-gray-500/30 dark:hover:border-gray-500/40 hover:text-oai-black dark:hover:text-white":"border border-oai-gray-200 dark:border-oai-gray-700 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white hover:border-oai-gray-300 dark:hover:border-oai-gray-600"),children:[p.jsx("svg",{height:"12",viewBox:"0 0 16 16",width:"12",className:"shrink-0 fill-current",children:p.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),p.jsx("span",{children:"Star"}),n!==null&&p.jsx("span",{className:"text-[10px] text-oai-gray-500 dark:text-oai-gray-500 tabular-nums",children:n})]})}const Nre=[{value:"light",label:"Light",Icon:Nk},{value:"dark",label:"Dark",Icon:Pk},{value:"system",label:"System",Icon:Wy}];function Dre({theme:t,resolvedTheme:e,onSetTheme:n,glassChrome:r=!1}){const[i,a]=x.useState(!1),s=x.useRef(null),o=e==="dark"?Pk:Nk;return x.useEffect(()=>{if(!i)return;const c=f=>{s.current&&!s.current.contains(f.target)&&a(!1)},u=f=>{f.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u)}},[i]),p.jsxs("div",{ref:s,className:"relative",children:[p.jsx("button",{type:"button","aria-label":"Theme","aria-expanded":i,"aria-haspopup":"menu",title:"Theme",onClick:()=>a(c=>!c),className:vt("inline-flex h-7 w-7 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",r?"border border-gray-500/20 dark:border-gray-500/30 bg-gray-500/[0.04] dark:bg-gray-500/[0.06] backdrop-blur-[2px] text-oai-gray-700 dark:text-oai-gray-300 hover:bg-gray-500/10 dark:hover:bg-gray-500/12 hover:border-gray-500/30 dark:hover:border-gray-500/40 hover:text-oai-black dark:hover:text-white":"border border-oai-gray-200 dark:border-oai-gray-700 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white hover:border-oai-gray-300 dark:hover:border-oai-gray-600"),children:p.jsx(o,{className:"h-3.5 w-3.5","aria-hidden":!0})}),i&&p.jsx("div",{role:"menu",className:"absolute bottom-full left-0 mb-2 z-50 min-w-[140px] py-1 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-lg",children:Nre.map(({value:c,label:u,Icon:f})=>{const h=t===c;return p.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{n(c),a(!1)},className:vt("flex w-full items-center gap-2.5 px-3 py-1.5 text-[13px] transition-colors",h?"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:[p.jsx(f,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),p.jsx("span",{children:u})]},c)})})]})}function U5({collapsed:t,onToggleCollapsed:e,onItemClick:n,showCloseButton:r=!1,onClose:i,glassChrome:a=!1}){const o=Hi()?.pathname||"/",{theme:c,resolvedTheme:u,setTheme:f}=Op(),{resolvedLocale:h}=lu(),m=x.useMemo(()=>kre(),[h]);return p.jsxs(p.Fragment,{children:[p.jsx("div",{className:vt("px-2 pt-2 pb-2",t&&"flex justify-center"),children:r?p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("div",{className:"flex-1 min-w-0",children:p.jsx(yy,{variant:"sidebar",collapsed:t,onAfterAction:n})}),p.jsx("button",{type:"button",onClick:i,"aria-label":O("nav.close_menu"),title:O("nav.close_menu"),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-500 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-gray-900 dark:hover:text-oai-gray-200 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:p.jsx(Dk,{className:"h-4 w-4",strokeWidth:1.75,"aria-hidden":!0})})]}):p.jsx(yy,{variant:"sidebar",collapsed:t,onAfterAction:n})}),p.jsx("nav",{"aria-label":O("nav.nav_label"),className:"flex-1 px-2 pb-2 flex flex-col overflow-y-auto",children:m.map((g,v)=>p.jsxs("div",{className:"flex flex-col",children:[p.jsx(Cre,{label:g.label,collapsed:t,first:v===0}),p.jsx("div",{className:"flex flex-col gap-0.5",children:g.items.map(w=>p.jsx(Are,{item:w,collapsed:t,active:Tre(o,w.to),onClick:n},w.id))})]},g.id))}),p.jsxs("div",{className:vt("flex items-center px-2 py-3",t?"flex-col justify-center gap-2":"justify-between gap-2"),children:[p.jsx(Dre,{theme:c,resolvedTheme:u,onSetTheme:f,glassChrome:a}),p.jsx("div",{className:"flex items-center gap-1.5",children:!t&&p.jsx(Rre,{glassChrome:a})})]})]})}function Lre({collapsed:t,onToggleCollapsed:e}){const n=x.useMemo(()=>typeof window>"u"?!1:Ja()||Tk(),[]);return p.jsx("aside",{"aria-label":O("nav.aside_label"),className:vt("hidden lg:flex flex-col shrink-0 h-full min-h-0 transition-[width] duration-200",t?"w-[72px]":"w-[220px]"),children:p.jsx(U5,{collapsed:t,onToggleCollapsed:e,glassChrome:n})})}function Ire({open:t,onClose:e}){return x.useEffect(()=>{if(!t)return;const n=r=>{r.key==="Escape"&&e()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[t,e]),x.useEffect(()=>{if(!t)return;const n=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=n}},[t]),t?p.jsxs("div",{className:"lg:hidden fixed inset-0 z-[80] flex",children:[p.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:e,"aria-hidden":!0}),p.jsx("aside",{"aria-label":O("nav.aside_label"),className:"relative w-[260px] max-w-[80vw] flex flex-col bg-oai-white dark:bg-oai-gray-900 border-r border-oai-gray-200 dark:border-oai-gray-800 shadow-2xl",children:p.jsx(U5,{collapsed:!1,showCloseButton:!0,onClose:e,onItemClick:e})})]}):null}function Ore({onOpenDrawer:t}){return p.jsxs("div",{className:"lg:hidden flex items-center justify-between gap-2 px-3 h-14 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[p.jsx(Pre,{title:O("nav.menu"),onClick:t,children:p.jsx(aG,{className:"h-5 w-5","aria-hidden":!0})}),p.jsxs(Ei,{to:"/landing",className:"flex items-center gap-2 no-underline hover:opacity-80 transition-opacity","aria-label":"Token Tracker",children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white",children:"Token Tracker"})]}),p.jsx("div",{className:"w-10 shrink-0","aria-hidden":!0})]})}function Fre({children:t}){const{collapsed:e,toggle:n}=Mre(),[r,i]=x.useState(!1),a=x.useCallback(()=>i(!0),[]),s=x.useCallback(()=>i(!1),[]),o=x.useMemo(()=>typeof window>"u"?!1:Ja()||Tk(),[]);return p.jsxs("div",{className:vt("fixed inset-0 flex flex-col text-oai-black dark:text-oai-white font-sans overflow-hidden",o?"bg-transparent":"bg-oai-gray-100 dark:bg-oai-gray-950"),children:[o&&p.jsx("div",{className:"h-7 shrink-0",style:{WebkitAppRegion:"drag"},"aria-hidden":!0}),p.jsxs("div",{className:"flex-1 min-h-0 flex",children:[p.jsx(Lre,{collapsed:e,onToggleCollapsed:n}),p.jsx(Ire,{open:r,onClose:s}),p.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-2 lg:pl-0 lg:pr-3 lg:pb-3 flex flex-col",children:p.jsxs("div",{className:vt("flex-1 min-h-0 flex flex-col bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",o?"tt-native-main-card":"rounded-2xl",!o&&"shadow-sm"),children:[p.jsx(Ore,{onOpenDrawer:a}),p.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:t})]})})]})]})}function Ure({children:t,variant:e="info",size:n="md",className:r=""}){const i="inline-flex items-center font-medium",a={success:"bg-oai-brand-100 dark:bg-oai-brand-900/30 text-oai-brand-700 dark:text-oai-brand-400 rounded-full",warning:"bg-oai-amber-50 dark:bg-oai-amber-900/30 text-oai-amber-dark dark:text-oai-amber-400 rounded-full",error:"bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded-full",info:"bg-oai-gray-100 dark:bg-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-300 rounded-full",secondary:"bg-oai-gray-100 dark:bg-oai-gray-800 text-oai-gray-500 dark:text-oai-gray-300 rounded-md"},s={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm"},o=`${i} ${a[e]} ${s[n]} ${r}`.trim();return p.jsx("span",{className:o,children:t})}const j5=x.createContext(void 0);function Gl(t){const e=x.useContext(j5);if(t===!1&&e===void 0)throw new Error(Wi(27));return e}const jre={...hu,...df},B5=x.forwardRef(function(e,n){const{render:r,className:i,forceRender:a=!1,...s}=e,{store:o}=Gl(),c=o.useState("open"),u=o.useState("nested"),f=o.useState("mounted"),h=o.useState("transitionStatus"),m=x.useMemo(()=>({open:c,transitionStatus:h}),[c,h]);return Xr("div",e,{state:m,ref:[o.context.backdropRef,n],stateAttributesMapping:jre,props:[{role:"presentation",hidden:!f,style:{userSelect:"none",WebkitUserSelect:"none"}},s],enabled:a||!u})}),Bre=x.forwardRef(function(e,n){const{render:r,className:i,disabled:a=!1,nativeButton:s=!0,...o}=e,{store:c}=Gl(),u=c.useState("open");function f(v){u&&c.setOpen(!1,Mn(Mee,v.nativeEvent))}const{getButtonProps:h,buttonRef:m}=nv({disabled:a,native:s}),g=x.useMemo(()=>({disabled:a}),[a]);return Xr("button",e,{state:g,ref:[n,m],props:[{onClick:f},o,h]})}),zre=x.forwardRef(function(e,n){const{render:r,className:i,id:a,...s}=e,{store:o}=Gl(),c=cv(a);return o.useSyncedValueWithCleanup("descriptionElementId",c),Xr("p",e,{ref:n,props:[{id:c},s]})});let Vre=(function(t){return t.nestedDialogs="--nested-dialogs",t})({}),Hre=(function(t){return t[t.open=Qa.open]="open",t[t.closed=Qa.closed]="closed",t[t.startingStyle=Qa.startingStyle]="startingStyle",t[t.endingStyle=Qa.endingStyle]="endingStyle",t.nested="data-nested",t.nestedDialogOpen="data-nested-dialog-open",t})({});const z5=x.createContext(void 0);function V5(){const t=x.useContext(z5);if(t===void 0)throw new Error(Wi(26));return t}const Wre={...hu,...df,nestedDialogOpen(t){return t?{[Hre.nestedDialogOpen]:""}:null}},H5=x.forwardRef(function(e,n){const{className:r,finalFocus:i,initialFocus:a,render:s,...o}=e,{store:c}=Gl(),u=c.useState("descriptionElementId"),f=c.useState("disablePointerDismissal"),h=c.useState("floatingRootContext"),m=c.useState("popupProps"),g=c.useState("modal"),v=c.useState("mounted"),w=c.useState("nested"),b=c.useState("nestedOpenDialogCount"),_=c.useState("open"),E=c.useState("openMethod"),M=c.useState("titleElementId"),T=c.useState("transitionStatus"),P=c.useState("role");V5(),ff({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});function A(L){return L==="touch"?c.context.popupRef.current:!0}const R=a===void 0?A:a,k=b>0,N=x.useMemo(()=>({open:_,nested:w,transitionStatus:T,nestedDialogOpen:k}),[_,w,T,k]),B=Xr("div",e,{state:N,props:[m,{"aria-labelledby":M??void 0,"aria-describedby":u??void 0,role:P,tabIndex:-1,hidden:!v,onKeyDown(L){OE.has(L.key)&&L.stopPropagation()},style:{[Vre.nestedDialogs]:b}},o],ref:[n,c.context.popupRef,c.useStateSetter("popupElement")],stateAttributesMapping:Wre});return p.jsx(ME,{context:h,openInteractionType:E,disabled:!v,closeOnFocusOut:!f,initialFocus:R,returnFocus:i,modal:g!==!1,restoreFocus:"popup",children:B})}),W5=x.forwardRef(function(e,n){const{keepMounted:r=!1,...i}=e,{store:a}=Gl(),s=a.useState("mounted"),o=a.useState("modal"),c=a.useState("open");return s||r?p.jsx(z5.Provider,{value:r,children:p.jsxs(kE,{ref:n,...i,children:[s&&o===!0&&p.jsx(IE,{ref:a.context.internalBackdropRef,inert:DE(!c)}),e.children]})}):null});function Gre(t){const{store:e,parentContext:n,actionsRef:r}=t,i=e.useState("open"),a=e.useState("disablePointerDismissal"),s=e.useState("modal"),o=e.useState("popupElement"),{openMethod:c,triggerProps:u,reset:f}=NE(i);a5(e);const{forceUnmount:h}=s5(i,e,()=>{f()}),m=Bt(B=>{const L=Mn(B);return L.preventUnmountOnClose=()=>{e.set("preventUnmountingOnClose",!0)},L}),g=x.useCallback(()=>{e.setOpen(!1,m(G4))},[e,m]);x.useImperativeHandle(r,()=>({unmount:h,close:g}),[h,g]);const v=u5({popupStore:e,onOpenChange:e.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[w,b]=x.useState(0),_=w===0,E=f5(v),M=CE(v,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:s==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(B){if("button"in B&&B.button!==0||"touches"in B&&B.touches.length!==1)return!1;const L=Fi(B);if(_&&!a){const z=L;return s&&(e.context.internalBackdropRef.current||e.context.backdropRef.current)?e.context.internalBackdropRef.current===z||e.context.backdropRef.current===z||On(z,o)&&!z?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:_});LE(i&&s===!0,o);const{getReferenceProps:T,getFloatingProps:P,getTriggerProps:A}=ov([E,M]);e.useContextCallback("onNestedDialogOpen",B=>{b(B+1)}),e.useContextCallback("onNestedDialogClose",()=>{b(0)}),x.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(w),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,w]);const R=x.useMemo(()=>T(u),[T,u]),k=x.useMemo(()=>A(u),[A,u]),N=x.useMemo(()=>P(),[P]);e.useSyncedValues({openMethod:c,activeTriggerProps:R,inactiveTriggerProps:k,popupProps:N,floatingRootContext:v,nestedOpenDialogCount:w})}const $re={...l5,modal:Pt(t=>t.modal),nested:Pt(t=>t.nested),nestedOpenDialogCount:Pt(t=>t.nestedOpenDialogCount),disablePointerDismissal:Pt(t=>t.disablePointerDismissal),openMethod:Pt(t=>t.openMethod),descriptionElementId:Pt(t=>t.descriptionElementId),titleElementId:Pt(t=>t.titleElementId),viewportElement:Pt(t=>t.viewportElement),role:Pt(t=>t.role)};class Yre extends gE{constructor(e){super(qre(e),{popupRef:x.createRef(),backdropRef:x.createRef(),internalBackdropRef:x.createRef(),triggerElements:new sv,onOpenChange:void 0,onOpenChangeComplete:void 0},$re)}setOpen=(e,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!e&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,n),n.isCanceled)return;const r={open:e,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",r);const i={open:e},a=n.trigger?.id??null;(a||e)&&(i.activeTriggerId=a,i.activeTriggerElement=n.trigger??null),this.update(i)}}function qre(t={}){return{...o5(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...t}}function G5(t){const{children:e,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:s=!1,modal:o=!0,actionsRef:c,handle:u,triggerId:f,defaultTriggerId:h=null}=t,m=Gl(!0),g=!!m,v=Vi(()=>u?.store??new Yre({open:n??r,activeTriggerId:f!==void 0?f:h,modal:o,disablePointerDismissal:s,nested:g})).current;v.useControlledProp("open",n,r),v.useControlledProp("activeTriggerId",f,h),v.useSyncedValues({disablePointerDismissal:s,nested:g,modal:o}),v.useContextCallback("onOpenChange",i),v.useContextCallback("onOpenChangeComplete",a);const w=v.useState("payload");Gre({store:v,actionsRef:c,parentContext:m?.store.context});const b=x.useMemo(()=>({store:v}),[v]);return p.jsx(j5.Provider,{value:b,children:typeof e=="function"?e({payload:w}):e})}let dR=(function(t){return t[t.open=Qa.open]="open",t[t.closed=Qa.closed]="closed",t[t.startingStyle=Qa.startingStyle]="startingStyle",t[t.endingStyle=Qa.endingStyle]="endingStyle",t.nested="data-nested",t.nestedDialogOpen="data-nested-dialog-open",t})({});const Xre={...hu,...df,nested(t){return t?{[dR.nested]:""}:null},nestedDialogOpen(t){return t?{[dR.nestedDialogOpen]:""}:null}},$5=x.forwardRef(function(e,n){const{className:r,render:i,children:a,...s}=e,o=V5(),{store:c}=Gl(),u=c.useState("open"),f=c.useState("nested"),h=c.useState("transitionStatus"),m=c.useState("nestedOpenDialogCount"),g=c.useState("mounted"),v=m>0,w=x.useMemo(()=>({open:u,nested:f,transitionStatus:h,nestedDialogOpen:v}),[u,f,h,v]);return Xr("div",e,{enabled:o||g,state:w,ref:[n,c.useStateSetter("viewportElement")],stateAttributesMapping:Xre,props:[{role:"presentation",hidden:!g,children:a},s]})}),Y5=x.forwardRef(function(e,n){const{render:r,className:i,id:a,...s}=e,{store:o}=Gl(),c=cv(a);return o.useSyncedValueWithCleanup("titleElementId",c),Xr("h2",e,{ref:n,props:[{id:c},s]})});function Kre({open:t,title:e,description:n,confirmLabel:r,cancelLabel:i,destructive:a=!1,busy:s=!1,onConfirm:o,onCancel:c}){return p.jsx(G5,{open:t,onOpenChange:u=>{!u&&!s&&c?.()},children:p.jsxs(W5,{children:[p.jsx(B5,{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-[2px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),p.jsx($5,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:p.jsxs(H5,{className:"relative w-full max-w-md rounded-2xl bg-white p-6 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] ring-1 ring-oai-gray-200 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.96] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0 dark:bg-oai-gray-950 dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] dark:ring-oai-gray-800",children:[p.jsx(Y5,{className:"text-base font-semibold text-oai-black dark:text-white",children:e}),n?p.jsx(zre,{className:"mt-2 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:n}):null,p.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[p.jsx(Ui,{type:"button",variant:"secondary",size:"sm",disabled:s,onClick:()=>c?.(),children:i}),p.jsx(Ui,{type:"button",size:"sm",disabled:s,onClick:()=>o?.(),className:vt(a&&"!bg-red-600 hover:!bg-red-700 focus-visible:!outline-red-600 dark:!bg-red-600 dark:hover:!bg-red-500"),children:r})]})]})})]})})}function q5({value:t,onChange:e,placeholder:n,disabled:r=!1,type:i="text",label:a,error:s,className:o="",...c}){const m=`w-full bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md text-oai-black dark:text-oai-white placeholder-oai-gray-400 dark:placeholder-oai-gray-500 transition-all duration-200 focus:outline-none focus:border-oai-brand dark:focus:border-oai-brand focus:ring-1 focus:ring-oai-brand/30 ${r?"bg-oai-gray-50 dark:bg-oai-gray-800 text-oai-gray-400 dark:text-oai-gray-400 cursor-not-allowed":""} ${s?"border-oai-error focus:border-oai-error focus:ring-oai-error/30":""} h-10 px-3 text-sm ${o}`;return p.jsxs("div",{className:"w-full",children:[a&&p.jsx("label",{className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5 transition-colors duration-200",children:a}),p.jsx("input",{type:i,value:t,onChange:e,placeholder:n,disabled:r,className:m,...c}),s&&p.jsx("p",{className:"mt-1.5 text-sm text-oai-error",children:s})]})}var Zre={};function Jre(t,e){return t==="."?{width:"0.34ch",justifyContent:"center",marginInline:"-0.04ch"}:t===","?{width:"0.08ch",justifyContent:"center",marginInline:"-0.30ch"}:{width:"0.72ch",justifyContent:"flex-start",paddingLeft:"0.04ch",height:e}}function Qre({mv:t,digit:e,height:n}){const r=IO(t,i=>{const a=(i%10+10)%10,s=(10+e-a)%10;let o=s*n;return s>5&&(o-=10*n),o});return p.jsx(Qn.span,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",y:r},children:e})}function eie(t){const e=Math.round(t),n=1e-9*Math.max(1,Math.abs(t));return Math.abs(t-e)<n?e:t}function tie(t,e){const n=t/e;return Math.floor(eie(n))}function nie(t){const e=String(t??""),n=Array.from(e),r=n.indexOf(".");let i=n.filter((o,c)=>/\d/.test(o)&&(r===-1||c<r)).length,a=0,s=!1;return n.map(o=>{if(!/\d/.test(o))return o==="."&&(s=!0),o;if(!s){const c=10**Math.max(i-1,0);return i-=1,c}return a+=1,10**-a})}function rie({place:t,value:e,height:n,digitStyle:r,shouldReduceMotion:i}){if(typeof t!="number"){const c=Jre(t,n);return p.jsx("span",{"data-counter-token":"static",className:"relative inline-flex items-center justify-center",style:{height:n,...c,...r},children:t})}const a=tie(e,t),s=oE(0),o=OK(s,{stiffness:220,damping:26,mass:.8});return x.useEffect(()=>{s.set(a)},[s,a]),i?p.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex items-center justify-center overflow-hidden",style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...r},children:Math.abs(a)%10}):p.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex overflow-hidden",style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...r},children:Array.from({length:10},(c,u)=>p.jsx(Qre,{mv:o,digit:u,height:n},u))})}function iie({value:t,displayValue:e,fontSize:n=72,padding:r=0,places:i,gap:a=6,borderRadius:s=4,horizontalPadding:o=0,textColor:c="inherit",fontWeight:u="inherit",containerStyle:f,counterStyle:h,digitStyle:m,gradientHeight:g=14,gradientFrom:v="rgba(255,255,255,0.95)",gradientTo:w="rgba(255,255,255,0)",topGradientStyle:b,bottomGradientStyle:_}){const E=String(e??t??""),M=x.useMemo(()=>Array.isArray(i)&&i.length?i:nie(E),[i,E]),T=typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent||"")||typeof process<"u"&&Zre?.VITEST==="true",P=cu()||T,A=Number.isFinite(Number(t))?Math.abs(Number(t)):0,R=n+r;return P?p.jsx("span",{"data-counter-root":"true",style:{display:"inline-flex",alignItems:"center",color:c,fontSize:n,fontWeight:u,lineHeight:1,...f,...h},children:E}):p.jsxs("span",{"data-counter-root":"true",style:{position:"relative",display:"inline-block",...f},children:[p.jsx("span",{style:{fontSize:n,display:"flex",gap:a,overflow:"hidden",borderRadius:s,paddingLeft:o,paddingRight:o,lineHeight:1,color:c,fontWeight:u,...h},children:M.map((k,N)=>p.jsx(rie,{place:k,value:A,height:R,digitStyle:m,shouldReduceMotion:P},`${String(k)}-${N}`))}),p.jsxs("span",{style:{pointerEvents:"none",position:"absolute",inset:0,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[p.jsx("span",{style:b??{height:g,background:`linear-gradient(to bottom, ${v}, ${w})`}}),p.jsx("span",{style:_??{height:g,background:`linear-gradient(to top, ${v}, ${w})`}})]})]})}function aie(t){if(!Number.isFinite(t))return O("shared.placeholder.short");const e=Uy(t.toFixed(2),{decimals:2});return e==="-"?O("shared.placeholder.short"):e}function fR(t){return!Number.isFinite(t)||t<=0?null:t<.01?"<$0.01":Uy(t.toFixed(2),{decimals:2})}function hR(t){const e=Number(t);return!Number.isFinite(e)||e<=0?null:Ma(e,{decimals:1})}const sie=ot.memo(function({isOpen:e,onClose:n,fleetData:r=[]}){const i=x.useMemo(()=>(Array.isArray(r)?r:[]).map(s=>{const o=ti(s?.usd)??0,c=ti(s?.usage)??0,u=Array.isArray(s?.models)?s.models:[];return{label:s?.label?String(s.label):"",usdValue:o,usdLabel:fR(o),tokensLabel:hR(c),models:u.map(f=>{const h=ti(f?.usage)??0,m=ti(f?.cost)??0;return{id:f?.id?String(f.id):"",name:f?.name?String(f.name):"",tokensLabel:hR(h),costLabel:fR(m),sortCost:m}}).filter(f=>f.costLabel||f.tokensLabel).sort((f,h)=>h.sortCost-f.sortCost)}}).filter(s=>s.usdValue>0||s.models.length>0).sort((s,o)=>o.usdValue-s.usdValue),[r]),a=x.useMemo(()=>{const s=i.reduce((o,c)=>o+c.usdValue,0);return aie(s)},[i]);return p.jsx(G5,{open:e,onOpenChange:s=>{s||n?.()},children:p.jsxs(W5,{children:[p.jsx(B5,{className:"cost-modal-backdrop","data-cost-analysis-backdrop":"true"}),p.jsx($5,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:p.jsxs(H5,{className:"cost-modal-popup relative w-full max-w-[460px] max-h-[calc(100vh-2rem)] flex flex-col rounded-2xl bg-white dark:bg-oai-gray-950 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 overflow-hidden",children:[p.jsx(Y5,{render:p.jsx("h2",{className:"sr-only"}),children:O("dashboard.cost_breakdown.title")}),p.jsx(Bre,{type:"button",className:"absolute top-3 right-3 flex h-9 w-9 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-100 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/50 transition-colors z-10","aria-label":O("dashboard.cost_breakdown.close"),children:p.jsx(Dk,{size:16,strokeWidth:2,"aria-hidden":!0})}),p.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto oai-scrollbar",children:p.jsxs("div",{className:"px-3 py-6",children:[p.jsx("p",{className:"text-label uppercase tracking-[0.12em] text-oai-gray-500 dark:text-oai-gray-400 mb-2",children:O("dashboard.cost_breakdown.total_label")}),p.jsx("p",{className:"font-bold text-oai-brand tabular-nums tracking-tight leading-none mb-6",style:{fontSize:"clamp(24px, 6.5vw, 32px)"},children:a}),i.length===0?p.jsx("p",{className:"text-body-sm text-oai-gray-500 dark:text-oai-gray-400",children:"No spend recorded."}):p.jsxs("div",{role:"table","aria-label":O("dashboard.cost_breakdown.title"),children:[p.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-2 mb-2 border-b border-oai-gray-200 dark:border-oai-gray-800 text-label uppercase text-oai-gray-500 dark:text-oai-gray-400",children:[p.jsx("span",{role:"columnheader",children:"Model"}),p.jsx("span",{role:"columnheader",children:"Cost"})]}),i.map((s,o)=>{const c=`fleet-${o}`;return p.jsxs("div",{role:"rowgroup","aria-labelledby":c,className:o>0?"mt-5":"mt-2",children:[p.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-2",children:[p.jsx("span",{id:c,role:"rowheader",className:"flex-1 min-w-0 text-body-sm font-semibold text-oai-black dark:text-oai-white truncate leading-none",children:s.label}),p.jsx("span",{role:"cell",className:"shrink-0 text-body-sm font-semibold text-oai-black dark:text-oai-white tabular-nums leading-none",children:s.usdLabel||"—"})]}),s.models.map((u,f)=>p.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-[5px]",children:[p.jsx("span",{role:"cell",className:"flex-1 min-w-0 text-caption text-oai-gray-500 dark:text-oai-gray-400 truncate leading-none",title:u.name,children:u.name}),p.jsx("span",{role:"cell",className:"shrink-0 text-caption text-oai-gray-700 dark:text-oai-gray-300 tabular-nums leading-none",children:u.costLabel||""})]},u.id||`${u.name}-${f}`))]},`${s.label}-${o}`)})]})]})})]})})]})})});function oie({projectEntries:t=[],projectLimit:e=3,onProjectLimitChange:n,copy:r,hasDetailsActual:i,dailyEmptyPrefix:a,installSyncCmd:s,dailyEmptySuffix:o,detailsColumns:c,ariaSortFor:u,toggleSort:f,sortIconFor:h,pagedDetails:m,dailyBreakdownRows:g=[],dailyBreakdownColumns:v=[],dailyBreakdownAriaSortFor:w,dailyBreakdownSortIconFor:b,dailyBreakdownDateKey:_="day",detailsDateKey:E,renderDetailDate:M,renderDailyBreakdownDate:T,renderDetailCell:P,DETAILS_PAGED_PERIODS:A,period:R,detailsPageCount:k,detailsPage:N,setDetailsPage:B}){const[L,z]=x.useState("daily");return p.jsxs(pu,{children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[p.jsxs("div",{role:"tablist","aria-label":"Data view",className:"flex gap-1",children:[p.jsx("button",{role:"tab","aria-selected":L==="daily",type:"button",onClick:()=>z("daily"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${L==="daily"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:r("dashboard.daily.title")}),p.jsx("button",{role:"tab","aria-selected":L==="projects",type:"button",onClick:()=>z("projects"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${L==="projects"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:r("dashboard.projects.title")})]}),L==="projects"&&p.jsxs("select",{"aria-label":"Number of projects to display",value:e,onChange:I=>n?.(Number(I.target.value)),className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded px-2 py-1 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 focus:border-oai-brand dark:focus:border-oai-brand focus:outline-none transition-colors",children:[p.jsx("option",{value:3,children:r("dashboard.projects.limit_top_3")}),p.jsx("option",{value:6,children:r("dashboard.projects.limit_top_6")}),p.jsx("option",{value:10,children:r("dashboard.projects.limit_top_10")})]})]}),L==="projects"&&p.jsx("div",{className:"space-y-1",children:t.slice(0,e).map(I=>p.jsxs("a",{href:I?.project_ref||"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-2 rounded-lg hover:oai-bg-elevated transition-colors",children:[p.jsx("div",{className:"w-8 h-8 rounded-md oai-bg-elevated flex items-center justify-center oai-text-caption font-medium text-oai-gray-500 dark:text-oai-gray-300",children:(I?.project_key?.[0]||"?").toUpperCase()}),p.jsx("div",{className:"min-w-0 flex-1",children:p.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:I?.project_key||I?.project_ref?.split("/")?.pop()||"—"})}),p.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:(()=>{const V=I?.billable_total_tokens??I?.total_tokens,W=Number(V);return Number.isFinite(W)?W.toLocaleString():"—"})()})]},I?.project_key||I?.project_ref))}),L==="daily"&&p.jsxs("div",{children:[g?.length===0?p.jsxs("div",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300 mb-4",children:[a,p.jsx("code",{className:"mx-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 oai-bg-elevated px-1.5 py-0.5 font-mono oai-text-caption",children:s}),o]}):p.jsx("div",{className:"overflow-auto max-h-[384px] -mx-4 oai-scrollbar",children:p.jsxs("table",{className:"w-full border-collapse",children:[p.jsx("thead",{className:"sticky top-0 z-10",children:p.jsx("tr",{className:"border-b border-oai-gray-200 dark:border-oai-gray-700",children:v.map(I=>p.jsx("th",{"aria-sort":w?.(I.key)||"none",className:"text-left p-0 bg-white dark:bg-oai-gray-900",children:p.jsx("button",{type:"button",onClick:()=>f(I.key),className:"flex w-full items-center justify-start px-4 py-2 text-left oai-text-caption font-semibold text-oai-gray-600 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white transition-colors",children:p.jsxs("span",{className:"inline-flex items-center gap-1",children:[p.jsx("span",{children:I.label}),p.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-400",children:b?.(I.key)||""})]})})},I.key))})}),p.jsx("tbody",{children:g.map(I=>p.jsxs("tr",{className:`border-b border-oai-gray-100 dark:border-oai-gray-800 last:border-b-0 hover:bg-oai-gray-50/50 dark:hover:bg-oai-gray-800/50 transition-colors ${I.missing?"text-oai-gray-400 dark:text-oai-gray-400":I.future?"text-oai-gray-300 dark:text-oai-gray-600":"text-oai-black dark:text-oai-white"}`,children:[p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300",children:T?T(I):M(I)}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:P(I,"total_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:P(I,"input_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:P(I,"output_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:P(I,"cached_input_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:P(I,"reasoning_output_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:P(I,"conversation_count")})]},String(I?.[_]||I?.day||I?.hour||I?.month||"")))})]})}),L!=="daily"&&A.has(R)&&k>1?p.jsxs("div",{className:"mt-3 flex items-center justify-between oai-text-caption",children:[p.jsx("button",{type:"button",onClick:()=>B(I=>Math.max(0,I-1)),disabled:N===0,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("details.pagination.prev")}),p.jsxs("span",{className:"oai-text-muted",children:[N+1," / ",k]}),p.jsx("button",{type:"button",onClick:()=>B(I=>Math.min(k-1,I+1)),disabled:N+1>=k,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("details.pagination.next")})]}):null]})]})}function k0(t){return typeof t!="string"?"":t.trim()}function pR(t){const e=k0(t);return e?e.split(/[_\-\s]+/).filter(Boolean).map(n=>n.slice(0,1).toUpperCase()+n.slice(1).toLowerCase()).join(" "):""}function lie(t){if(!Array.isArray(t))return[];const e=new Map;for(const n of t){if(!n||typeof n!="object")continue;const r=k0(n.tool),i=k0(n.planType)||k0(n.plan_type);if(!r||!i)continue;const a=pR(r)||r,s=pR(i)||i;e.set(`${r.toLowerCase()}::${i.toLowerCase()}`,{tool:a,plan:s})}return Array.from(e.values())}function cie({period:t="month",rankLabel:e,streakDays:n,subscriptions:r=[],periodConversations:i,rolling:a,topModels:s=[],className:o=""}){const c=O("shared.placeholder.short"),u=O("shared.unit.percent"),f=e??O("identity_card.rank_placeholder"),h=Number.isFinite(Number(n))?Number(n):0,m=h?O("identity_card.streak_value",{days:h}):O("identity_card.rank_placeholder"),g=lie(r),v={thousandSuffix:O("shared.unit.thousand_abbrev"),millionSuffix:O("shared.unit.million_abbrev"),billionSuffix:O("shared.unit.billion_abbrev")},w=E=>{if(E==null)return c;const M=Ma(E,v);return M==="-"?c:M},b=(()=>{switch(t){case"day":return O("stats.period.today");case"week":return O("stats.period.week");case"month":return O("stats.period.month");case"total":return O("stats.period.all");default:return O("stats.period.convs")}})(),_=s.slice(0,3);return p.jsxs(pu,{className:`h-full ${o}`,children:[p.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(a?.last_7d?.totals?.billable_total_tokens)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"7d"})]}),p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(a?.last_30d?.totals?.billable_total_tokens)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"30d"})]}),p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(a?.last_30d?.avg_per_active_day)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"avg"})]}),p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(i)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:b})]})]}),_.length>0&&p.jsx("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800",children:_.map((E,M)=>{const T=E?.name?String(E.name):c,P=E?.percent?String(E.percent):"",A=M===_.length-1,R=M+1;return p.jsxs("div",{className:`flex items-center py-2 ${A?"":"border-b border-oai-gray-50 dark:border-oai-gray-800"}`,children:[p.jsx("span",{className:"w-5 h-5 flex items-center justify-center rounded-full bg-oai-gray-100 dark:bg-oai-gray-800 text-[10px] font-semibold text-oai-gray-500 dark:text-oai-gray-300 flex-shrink-0",children:R}),p.jsx("span",{className:"flex-1 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate px-2.5",title:T,children:T}),p.jsxs("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums flex-shrink-0",children:[P,u]})]},E.id||T)})}),g.length>0&&p.jsx("div",{className:"mt-3 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800 flex flex-wrap gap-1.5",children:g.map((E,M)=>p.jsxs(Ure,{variant:"secondary",size:"sm",children:[E.tool," ",E.plan]},`${E.tool}:${E.plan}:${M}`))}),p.jsxs("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800 flex items-center justify-between text-xs text-oai-gray-400 dark:text-oai-gray-400",children:[p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("span",{children:O("identity_card.rank_label")}),p.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:f})]}),p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("span",{children:O("identity_card.streak_label")}),p.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:m})]})]})]})}const X5=x.createContext(void 0);function jp(t){const e=x.useContext(X5);if(e===void 0&&!t)throw new Error(Wi(47));return e}function uie(){return{...o5(),disabled:!1,modal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}const die={...l5,disabled:Pt(t=>t.disabled),instantType:Pt(t=>t.instantType),openMethod:Pt(t=>t.openMethod),openChangeReason:Pt(t=>t.openChangeReason),modal:Pt(t=>t.modal),stickIfOpen:Pt(t=>t.stickIfOpen),titleElementId:Pt(t=>t.titleElementId),descriptionElementId:Pt(t=>t.descriptionElementId),openOnHover:Pt(t=>t.openOnHover),closeDelay:Pt(t=>t.closeDelay),hasViewport:Pt(t=>t.hasViewport)};class jE extends gE{constructor(e){const n={...uie(),...e};n.open&&e?.mounted===void 0&&(n.mounted=!0),super(n,{popupRef:x.createRef(),backdropRef:x.createRef(),internalBackdropRef:x.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:x.createRef(),beforeContentFocusGuardRef:x.createRef(),stickIfOpenTimeout:new Il,triggerElements:new sv},die)}setOpen=(e,n)=>{const r=n.reason===aa,i=n.reason===Rl&&n.event.detail===0,a=!e&&(n.reason===W4||n.reason==null);if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},this.context.onOpenChange?.(e,n),n.isCanceled)return;const s={open:e,nativeEvent:n.event,reason:n.reason,nested:this.state.nested,triggerElement:n.trigger};this.state.floatingRootContext.context.events?.emit("openchange",s);const c=()=>{const u={open:e,openChangeReason:n.reason},f=n.trigger?.id??null;(f||e)&&(u.activeTriggerId=f,u.activeTriggerElement=n.trigger??null),this.update(u)};r?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(WJ,()=>{this.set("stickIfOpen",!1)}),gi.flushSync(c)):c(),i||a?this.set("instantType",i?"click":"dismiss"):n.reason===eu?this.set("instantType","focus"):this.set("instantType",void 0)};static useStore(e,n){const r=Vi(()=>new jE(n)).current,i=e??r;return yE(r.disposeEffect),i}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()}function mR({props:t}){const{children:e,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:s=!1,handle:o,triggerId:c,defaultTriggerId:u=null}=t,f=jE.useStore(o?.store,{open:n??r,modal:s,activeTriggerId:c!==void 0?c:u});f.useControlledProp("open",n,r),f.useControlledProp("activeTriggerId",c,u);const h=f.useState("open"),m=f.useState("positionerElement"),g=f.useState("payload"),v=f.useState("openChangeReason");f.useContextCallback("onOpenChange",i),f.useContextCallback("onOpenChangeComplete",a);const{openMethod:w,triggerProps:b,reset:_}=NE(h);a5(f);const{forceUnmount:E}=s5(h,f,()=>{f.update({stickIfOpen:!0,openChangeReason:null}),_()});LE(h&&s===!0&&v!==aa&&w!=="touch",m),x.useEffect(()=>{h||f.context.stickIfOpenTimeout.clear()},[f,h]);const M=x.useCallback(W=>{const X=Mn(W);return X.preventUnmountOnClose=()=>{f.set("preventUnmountingOnClose",!0)},X},[f]),T=x.useCallback(()=>{f.setOpen(!1,M(G4))},[f,M]);x.useImperativeHandle(t.actionsRef,()=>({unmount:E,close:T}),[E,T]);const P=u5({popupStore:f,onOpenChange:f.setOpen}),A=CE(P,{outsidePressEvent:{mouse:s==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),R=f5(P),{getReferenceProps:k,getFloatingProps:N,getTriggerProps:B}=ov([A,R]),L=x.useMemo(()=>k(b),[k,b]),z=x.useMemo(()=>B(b),[B,b]),I=x.useMemo(()=>N(),[N]);f.useSyncedValues({modal:s,openMethod:w,activeTriggerProps:L,inactiveTriggerProps:z,popupProps:I,floatingRootContext:P,nested:Hl()!=null});const V=x.useMemo(()=>({store:f}),[f]);return p.jsx(X5.Provider,{value:V,children:typeof e=="function"?e({payload:g}):e})}function K5(t){return jp(!0)?p.jsx(mR,{props:t}):p.jsx(Eee,{children:p.jsx(mR,{props:t})})}const fie=300,Z5=x.forwardRef(function(e,n){const{render:r,className:i,disabled:a=!1,nativeButton:s=!0,handle:o,payload:c,openOnHover:u=!1,delay:f=fie,closeDelay:h=0,id:m,...g}=e,v=jp(!0),w=o?.store??v?.store;if(!w)throw new Error(Wi(74));const b=cv(m),_=w.useState("isTriggerActive",b),E=w.useState("floatingRootContext"),M=w.useState("isOpenedByTrigger",b),T=x.useRef(null),{registerTrigger:P,isMountedByThisTrigger:A}=Rte(b,T,w,{payload:c,disabled:a,openOnHover:u,closeDelay:h}),R=w.useState("openChangeReason"),k=w.useState("stickIfOpen"),N=w.useState("openMethod"),B=Bte(E,{enabled:E!=null&&u&&(N!=="touch"||R!==Rl),mouseOnly:!0,move:!1,handleClose:qte(),restMs:f,delay:{close:h},triggerElementRef:T,isActiveTrigger:_}),L=X4(E,{enabled:E!=null,stickIfOpen:k}),z=ov([L]),I=w.useState("triggerProps",A),V=x.useMemo(()=>({disabled:a,open:M}),[a,M]),{getButtonProps:W,buttonRef:X}=nv({disabled:a,native:s}),J=x.useMemo(()=>({open(te){return te&&R===Rl?w5.open(te):_5.open(te)}}),[R]),F=Xr("button",e,{state:V,ref:[X,n,P,T],props:[z.getReferenceProps(),B,I,{[h4]:"",id:b},g,W],stateAttributesMapping:J}),G=x.useRef(null),Y=Bt(te=>{gi.flushSync(()=>{w.setOpen(!1,Mn(eu,te.nativeEvent,te.currentTarget))}),vee(G.current)?.focus()}),H=Bt(te=>{const re=w.select("positionerElement");if(re&&Pd(te,re))w.context.beforeContentFocusGuardRef.current?.focus();else{gi.flushSync(()=>{w.setOpen(!1,Mn(eu,te.nativeEvent,te.currentTarget))});let ue=yee(w.context.triggerFocusTargetRef.current||T.current);for(;ue!==null&&On(re,ue);){const ce=ue;if(ue=wE(ue),ue===ce)break}ue?.focus()}});return _?p.jsxs(x.Fragment,{children:[p.jsx(Gd,{ref:G,onFocus:Y}),p.jsx(x.Fragment,{children:F},b),p.jsx(Gd,{ref:w.context.triggerFocusTargetRef,onFocus:H})]}):p.jsx(x.Fragment,{children:F},b)}),J5=x.createContext(void 0);function hie(){const t=x.useContext(J5);if(t===void 0)throw new Error(Wi(45));return t}const Q5=x.forwardRef(function(e,n){const{keepMounted:r=!1,...i}=e,{store:a}=jp();return a.useState("mounted")||r?p.jsx(J5.Provider,{value:r,children:p.jsx(kE,{ref:n,...i,renderGuards:!1})}):null}),eF=x.createContext(void 0);function pie(){const t=x.useContext(eF);if(!t)throw new Error(Wi(46));return t}const tF=x.forwardRef(function(e,n){const{render:r,className:i,anchor:a,positionMethod:s="absolute",side:o="bottom",align:c="center",sideOffset:u=0,alignOffset:f=0,collisionBoundary:h="clipping-ancestors",collisionPadding:m=5,arrowPadding:g=5,sticky:v=!1,disableAnchorTracking:w=!1,collisionAvoidance:b=YJ,..._}=e,{store:E}=jp(),M=hie(),T=See(),P=E.useState("floatingRootContext"),A=E.useState("mounted"),R=E.useState("open"),k=E.useState("openChangeReason"),N=E.useState("activeTriggerElement"),B=E.useState("modal"),L=E.useState("positionerElement"),z=E.useState("instantType"),I=E.useState("transitionStatus"),V=E.useState("hasViewport"),W=x.useRef(null),X=i5(L,!1,!1),J=E5({anchor:a,floatingRootContext:P,positionMethod:s,mounted:A,side:o,sideOffset:u,align:c,alignOffset:f,arrowPadding:g,collisionBoundary:h,collisionPadding:m,sticky:v,disableAnchorTracking:w,keepMounted:M,nodeId:T,collisionAvoidance:b,adaptiveOrigin:V?Bne:void 0}),F=x.useMemo(()=>{const ue={};return R||(ue.pointerEvents="none"),{role:"presentation",hidden:!A,style:{...J.positionerStyles,...ue}}},[R,A,J.positionerStyles]),G=x.useMemo(()=>({props:F,...J}),[F,J]),Y=P?.select("domReferenceElement");Yt(()=>{const ue=Y,ce=W.current;if(ue&&(W.current=ue),ce&&ue&&ue!==ce){E.set("instantType",void 0);const ee=new AbortController;return X(()=>{E.set("instantType","trigger-change")},ee.signal),()=>{ee.abort()}}},[Y,X,E]);const H=x.useMemo(()=>({open:R,side:G.side,align:G.align,anchorHidden:G.anchorHidden,instant:z}),[R,G.side,G.align,G.anchorHidden,z]),te=x.useCallback(ue=>{E.set("positionerElement",ue)},[E]),re=Xr("div",e,{state:H,props:[G.props,FE(I),_],ref:[n,te],stateAttributesMapping:hu});return p.jsxs(eF.Provider,{value:G,children:[A&&B===!0&&k!==aa&&p.jsx(IE,{ref:E.context.internalBackdropRef,inert:DE(!R),cutout:N}),p.jsx(kee,{id:T,children:re})]})}),mie={...hu,...df},nF=x.forwardRef(function(e,n){const{className:r,render:i,initialFocus:a,finalFocus:s,...o}=e,{store:c}=jp(),u=pie(),f=C5()!=null,h=c.useState("open"),m=c.useState("openMethod"),g=c.useState("instantType"),v=c.useState("transitionStatus"),w=c.useState("popupProps"),b=c.useState("titleElementId"),_=c.useState("descriptionElementId"),E=c.useState("modal"),M=c.useState("mounted"),T=c.useState("openChangeReason"),P=c.useState("activeTriggerElement"),A=c.useState("floatingRootContext");ff({open:h,ref:c.context.popupRef,onComplete(){h&&c.context.onOpenChangeComplete?.(!0)}});const R=c.useState("disabled"),k=c.useState("openOnHover"),N=c.useState("closeDelay");Fte(A,{enabled:k&&!R,closeDelay:N});function B(W){return W==="touch"?c.context.popupRef.current:!0}const L=a===void 0?B:a,z=x.useMemo(()=>({open:h,side:u.side,align:u.align,instant:g,transitionStatus:v}),[h,u.side,u.align,g,v]),I=x.useCallback(W=>{c.set("popupElement",W)},[c]),V=Xr("div",e,{state:z,ref:[n,c.context.popupRef,I],props:[w,{"aria-labelledby":b,"aria-describedby":_,onKeyDown(W){f&&OE.has(W.key)&&W.stopPropagation()}},FE(v),o],stateAttributesMapping:mie});return p.jsx(ME,{context:A,openInteractionType:m,modal:E==="trap-focus",disabled:!M||T===aa,initialFocus:L,returnFocus:s,restoreFocus:"popup",previousFocusableElement:Ar(P)?P:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:V})});function gie(t,e,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:t,timeZoneName:n}).format(e).split(/\s/g).slice(2).join(" ")}const yie={},Ah={};function Dc(t,e){try{const r=(yie[t]||=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"longOffset"}).format)(e).split("GMT")[1];return r in Ah?Ah[r]:gR(r,r.split(":"))}catch{if(t in Ah)return Ah[t];const n=t?.match(vie);return n?gR(t,n.slice(1)):NaN}}const vie=/([+-]\d\d):?(\d\d)?/;function gR(t,e){const n=+(e[0]||0),r=+(e[1]||0),i=+(e[2]||0)/60;return Ah[t]=n*60+r>0?n*60+r+i:n*60-r-i}class Rs extends Date{constructor(...e){super(),e.length>1&&typeof e[e.length-1]=="string"&&(this.timeZone=e.pop()),this.internal=new Date,isNaN(Dc(this.timeZone,this))?this.setTime(NaN):e.length?typeof e[0]=="number"&&(e.length===1||e.length===2&&typeof e[1]!="number")?this.setTime(e[0]):typeof e[0]=="string"?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),rF(this),L1(this)):this.setTime(Date.now())}static tz(e,...n){return n.length?new Rs(...n,e):new Rs(Date.now(),e)}withTimeZone(e){return new Rs(+this,e)}getTimezoneOffset(){const e=-Dc(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),L1(this),+this}[Symbol.for("constructDateFrom")](e){return new Rs(+new Date(e),this.timeZone)}}const yR=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(t=>{if(!yR.test(t))return;const e=t.replace(yR,"$1UTC");Rs.prototype[e]&&(t.startsWith("get")?Rs.prototype[t]=function(){return this.internal[e]()}:(Rs.prototype[t]=function(){return Date.prototype[e].apply(this.internal,arguments),xie(this),+this},Rs.prototype[e]=function(){return Date.prototype[e].apply(this,arguments),L1(this),+this}))});function L1(t){t.internal.setTime(+t),t.internal.setUTCSeconds(t.internal.getUTCSeconds()-Math.round(-Dc(t.timeZone,t)*60))}function xie(t){Date.prototype.setFullYear.call(t,t.internal.getUTCFullYear(),t.internal.getUTCMonth(),t.internal.getUTCDate()),Date.prototype.setHours.call(t,t.internal.getUTCHours(),t.internal.getUTCMinutes(),t.internal.getUTCSeconds(),t.internal.getUTCMilliseconds()),rF(t)}function rF(t){const e=Dc(t.timeZone,t),n=e>0?Math.floor(e):Math.ceil(e),r=new Date(+t);r.setUTCHours(r.getUTCHours()-1);const i=-new Date(+t).getTimezoneOffset(),a=-new Date(+r).getTimezoneOffset(),s=i-a,o=Date.prototype.getHours.apply(t)!==t.internal.getUTCHours();s&&o&&t.internal.setUTCMinutes(t.internal.getUTCMinutes()+s);const c=i-n;c&&Date.prototype.setUTCMinutes.call(t,Date.prototype.getUTCMinutes.call(t)+c);const u=new Date(+t);u.setUTCSeconds(0);const f=i>0?u.getSeconds():(u.getSeconds()-60)%60,h=Math.round(-(Dc(t.timeZone,t)*60))%60;(h||f)&&(t.internal.setUTCSeconds(t.internal.getUTCSeconds()+h),Date.prototype.setUTCSeconds.call(t,Date.prototype.getUTCSeconds.call(t)+h+f));const m=Dc(t.timeZone,t),g=m>0?Math.floor(m):Math.ceil(m),w=-new Date(+t).getTimezoneOffset()-g,b=g!==n,_=w-c;if(b&&_){Date.prototype.setUTCMinutes.call(t,Date.prototype.getUTCMinutes.call(t)+_);const E=Dc(t.timeZone,t),M=E>0?Math.floor(E):Math.ceil(E),T=g-M;T&&(t.internal.setUTCMinutes(t.internal.getUTCMinutes()+T),Date.prototype.setUTCMinutes.call(t,Date.prototype.getUTCMinutes.call(t)+T))}}class mi extends Rs{static tz(e,...n){return n.length?new mi(...n,e):new mi(Date.now(),e)}toISOString(){const[e,n,r]=this.tzComponents(),i=`${e}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+i}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[e,n,r,i]=this.internal.toUTCString().split(" ");return`${e?.slice(0,-1)} ${r} ${n} ${i}`}toTimeString(){const e=this.internal.toUTCString().split(" ")[4],[n,r,i]=this.tzComponents();return`${e} GMT${n}${r}${i} (${gie(this.timeZone,this)})`}toLocaleString(e,n){return Date.prototype.toLocaleString.call(this,e,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleDateString(e,n){return Date.prototype.toLocaleDateString.call(this,e,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleTimeString(e,n){return Date.prototype.toLocaleTimeString.call(this,e,{...n,timeZone:n?.timeZone||this.timeZone})}tzComponents(){const e=this.getTimezoneOffset(),n=e>0?"-":"+",r=String(Math.floor(Math.abs(e)/60)).padStart(2,"0"),i=String(Math.abs(e)%60).padStart(2,"0");return[n,r,i]}withTimeZone(e){return new mi(+this,e)}[Symbol.for("constructDateFrom")](e){return new mi(+new Date(e),this.timeZone)}}const iF=6048e5,bie=864e5,vR=Symbol.for("constructDateFrom");function Dr(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&vR in t?t[vR](e):t instanceof Date?new t.constructor(e):new Date(e)}function Jn(t,e){return Dr(e||t,t)}function aF(t,e,n){const r=Jn(t,n?.in);return isNaN(e)?Dr(t,NaN):(e&&r.setDate(r.getDate()+e),r)}function sF(t,e,n){const r=Jn(t,n?.in);if(isNaN(e))return Dr(t,NaN);if(!e)return r;const i=r.getDate(),a=Dr(t,r.getTime());a.setMonth(r.getMonth()+e+1,0);const s=a.getDate();return i>=s?a:(r.setFullYear(a.getFullYear(),a.getMonth(),i),r)}let _ie={};function Bp(){return _ie}function Yd(t,e){const n=Bp(),r=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Jn(t,e?.in),a=i.getDay(),s=(a<r?7:0)+a-r;return i.setDate(i.getDate()-s),i.setHours(0,0,0,0),i}function cp(t,e){return Yd(t,{...e,weekStartsOn:1})}function oF(t,e){const n=Jn(t,e?.in),r=n.getFullYear(),i=Dr(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const a=cp(i),s=Dr(n,0);s.setFullYear(r,0,4),s.setHours(0,0,0,0);const o=cp(s);return n.getTime()>=a.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function xR(t){const e=Jn(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function hf(t,...e){const n=Dr.bind(null,e.find(r=>typeof r=="object"));return e.map(n)}function up(t,e){const n=Jn(t,e?.in);return n.setHours(0,0,0,0),n}function BE(t,e,n){const[r,i]=hf(n?.in,t,e),a=up(r),s=up(i),o=+a-xR(a),c=+s-xR(s);return Math.round((o-c)/bie)}function wie(t,e){const n=oF(t,e),r=Dr(t,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),cp(r)}function Sie(t,e,n){return aF(t,e*7,n)}function kie(t,e,n){return sF(t,e*12,n)}function Eie(t,e){let n,r=e?.in;return t.forEach(i=>{!r&&typeof i=="object"&&(r=Dr.bind(null,i));const a=Jn(i,r);(!n||n<a||isNaN(+a))&&(n=a)}),Dr(r,n||NaN)}function Mie(t,e){let n,r=e?.in;return t.forEach(i=>{!r&&typeof i=="object"&&(r=Dr.bind(null,i));const a=Jn(i,r);(!n||n>a||isNaN(+a))&&(n=a)}),Dr(r,n||NaN)}function Tie(t,e,n){const[r,i]=hf(n?.in,t,e);return+up(r)==+up(i)}function lF(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Cie(t){return!(!lF(t)&&typeof t!="number"||isNaN(+Jn(t)))}function cF(t,e,n){const[r,i]=hf(n?.in,t,e),a=r.getFullYear()-i.getFullYear(),s=r.getMonth()-i.getMonth();return a*12+s}function Aie(t,e){const n=Jn(t,e?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function uF(t,e){const[n,r]=hf(t,e.start,e.end);return{start:n,end:r}}function Pie(t,e){const{start:n,end:r}=uF(e?.in,t);let i=+n>+r;const a=i?+n:+r,s=i?r:n;s.setHours(0,0,0,0),s.setDate(1);let o=1;const c=[];for(;+s<=a;)c.push(Dr(n,s)),s.setMonth(s.getMonth()+o);return i?c.reverse():c}function Rie(t,e){const n=Jn(t,e?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Nie(t,e){const n=Jn(t,e?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function dF(t,e){const n=Jn(t,e?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Die(t,e){const{start:n,end:r}=uF(e?.in,t);let i=+n>+r;const a=i?+n:+r,s=i?r:n;s.setHours(0,0,0,0),s.setMonth(0,1);let o=1;const c=[];for(;+s<=a;)c.push(Dr(n,s)),s.setFullYear(s.getFullYear()+o);return i?c.reverse():c}function fF(t,e){const n=Bp(),r=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Jn(t,e?.in),a=i.getDay(),s=(a<r?-7:0)+6-(a-r);return i.setDate(i.getDate()+s),i.setHours(23,59,59,999),i}function Lie(t,e){return fF(t,{...e,weekStartsOn:1})}const Iie={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Oie=(t,e,n)=>{let r;const i=Iie[t];return typeof i=="string"?r=i:e===1?r=i.one:r=i.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function m_(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const Fie={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Uie={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},jie={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Bie={date:m_({formats:Fie,defaultWidth:"full"}),time:m_({formats:Uie,defaultWidth:"full"}),dateTime:m_({formats:jie,defaultWidth:"full"})},zie={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Vie=(t,e,n,r)=>zie[t];function dh(t){return(e,n)=>{const r=n?.context?String(n.context):"standalone";let i;if(r==="formatting"&&t.formattingValues){const s=t.defaultFormattingWidth||t.defaultWidth,o=n?.width?String(n.width):s;i=t.formattingValues[o]||t.formattingValues[s]}else{const s=t.defaultWidth,o=n?.width?String(n.width):t.defaultWidth;i=t.values[o]||t.values[s]}const a=t.argumentCallback?t.argumentCallback(e):e;return i[a]}}const Hie={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Wie={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Gie={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},$ie={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Yie={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},qie={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Xie=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Kie={ordinalNumber:Xie,era:dh({values:Hie,defaultWidth:"wide"}),quarter:dh({values:Wie,defaultWidth:"wide",argumentCallback:t=>t-1}),month:dh({values:Gie,defaultWidth:"wide"}),day:dh({values:$ie,defaultWidth:"wide"}),dayPeriod:dh({values:Yie,defaultWidth:"wide",formattingValues:qie,defaultFormattingWidth:"wide"})};function fh(t){return(e,n={})=>{const r=n.width,i=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],a=e.match(i);if(!a)return null;const s=a[0],o=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(o)?Jie(o,h=>h.test(s)):Zie(o,h=>h.test(s));let u;u=t.valueCallback?t.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const f=e.slice(s.length);return{value:u,rest:f}}}function Zie(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function Jie(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function Qie(t){return(e,n={})=>{const r=e.match(t.matchPattern);if(!r)return null;const i=r[0],a=e.match(t.parsePattern);if(!a)return null;let s=t.valueCallback?t.valueCallback(a[0]):a[0];s=n.valueCallback?n.valueCallback(s):s;const o=e.slice(i.length);return{value:s,rest:o}}}const eae=/^(\d+)(th|st|nd|rd)?/i,tae=/\d+/i,nae={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},rae={any:[/^b/i,/^(a|c)/i]},iae={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},aae={any:[/1/i,/2/i,/3/i,/4/i]},sae={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},oae={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},lae={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},cae={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},uae={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},dae={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},fae={ordinalNumber:Qie({matchPattern:eae,parsePattern:tae,valueCallback:t=>parseInt(t,10)}),era:fh({matchPatterns:nae,defaultMatchWidth:"wide",parsePatterns:rae,defaultParseWidth:"any"}),quarter:fh({matchPatterns:iae,defaultMatchWidth:"wide",parsePatterns:aae,defaultParseWidth:"any",valueCallback:t=>t+1}),month:fh({matchPatterns:sae,defaultMatchWidth:"wide",parsePatterns:oae,defaultParseWidth:"any"}),day:fh({matchPatterns:lae,defaultMatchWidth:"wide",parsePatterns:cae,defaultParseWidth:"any"}),dayPeriod:fh({matchPatterns:uae,defaultMatchWidth:"any",parsePatterns:dae,defaultParseWidth:"any"})},vd={code:"en-US",formatDistance:Oie,formatLong:Bie,formatRelative:Vie,localize:Kie,match:fae,options:{weekStartsOn:0,firstWeekContainsDate:1}};function hae(t,e){const n=Jn(t,e?.in);return BE(n,dF(n))+1}function zE(t,e){const n=Jn(t,e?.in),r=+cp(n)-+wie(n);return Math.round(r/iF)+1}function hF(t,e){const n=Jn(t,e?.in),r=n.getFullYear(),i=Bp(),a=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,s=Dr(e?.in||t,0);s.setFullYear(r+1,0,a),s.setHours(0,0,0,0);const o=Yd(s,e),c=Dr(e?.in||t,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);const u=Yd(c,e);return+n>=+o?r+1:+n>=+u?r:r-1}function pae(t,e){const n=Bp(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=hF(t,e),a=Dr(e?.in||t,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),Yd(a,e)}function VE(t,e){const n=Jn(t,e?.in),r=+Yd(n,e)-+pae(n,e);return Math.round(r/iF)+1}function Xn(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const ol={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return Xn(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):Xn(n+1,2)},d(t,e){return Xn(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(t,e){return Xn(t.getHours()%12||12,e.length)},H(t,e){return Xn(t.getHours(),e.length)},m(t,e){return Xn(t.getMinutes(),e.length)},s(t,e){return Xn(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return Xn(i,e.length)}},Zu={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},bR={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const r=t.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return ol.y(t,e)},Y:function(t,e,n,r){const i=hF(t,r),a=i>0?i:1-i;if(e==="YY"){const s=a%100;return Xn(s,2)}return e==="Yo"?n.ordinalNumber(a,{unit:"year"}):Xn(a,e.length)},R:function(t,e){const n=oF(t);return Xn(n,e.length)},u:function(t,e){const n=t.getFullYear();return Xn(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return Xn(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return Xn(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return ol.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return Xn(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){const i=VE(t,r);return e==="wo"?n.ordinalNumber(i,{unit:"week"}):Xn(i,e.length)},I:function(t,e,n){const r=zE(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):Xn(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):ol.d(t,e)},D:function(t,e,n){const r=hae(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):Xn(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){const i=t.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(a);case"ee":return Xn(a,2);case"eo":return n.ordinalNumber(a,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){const i=t.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(a);case"cc":return Xn(a,e.length);case"co":return n.ordinalNumber(a,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(t,e,n){const r=t.getDay(),i=r===0?7:r;switch(e){case"i":return String(i);case"ii":return Xn(i,e.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){const i=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(t,e,n){const r=t.getHours();let i;switch(r===12?i=Zu.noon:r===0?i=Zu.midnight:i=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(t,e,n){const r=t.getHours();let i;switch(r>=17?i=Zu.evening:r>=12?i=Zu.afternoon:r>=4?i=Zu.morning:i=Zu.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return ol.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):ol.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):Xn(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):Xn(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):ol.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):ol.s(t,e)},S:function(t,e){return ol.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return wR(r);case"XXXX":case"XX":return kc(r);default:return kc(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return wR(r);case"xxxx":case"xx":return kc(r);default:return kc(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+_R(r,":");default:return"GMT"+kc(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+_R(r,":");default:return"GMT"+kc(r,":")}},t:function(t,e,n){const r=Math.trunc(+t/1e3);return Xn(r,e.length)},T:function(t,e,n){return Xn(+t,e.length)}};function _R(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+e+Xn(a,2)}function wR(t,e){return t%60===0?(t>0?"-":"+")+Xn(Math.abs(t)/60,2):kc(t,e)}function kc(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=Xn(Math.trunc(r/60),2),a=Xn(r%60,2);return n+i+e+a}const SR=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},pF=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},mae=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return SR(t,e);let a;switch(r){case"P":a=e.dateTime({width:"short"});break;case"PP":a=e.dateTime({width:"medium"});break;case"PPP":a=e.dateTime({width:"long"});break;default:a=e.dateTime({width:"full"});break}return a.replace("{{date}}",SR(r,e)).replace("{{time}}",pF(i,e))},gae={p:pF,P:mae},yae=/^D+$/,vae=/^Y+$/,xae=["D","DD","YY","YYYY"];function bae(t){return yae.test(t)}function _ae(t){return vae.test(t)}function wae(t,e,n){const r=Sae(t,e,n);if(console.warn(r),xae.includes(t))throw new RangeError(r)}function Sae(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const kae=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Eae=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Mae=/^'([^]*?)'?$/,Tae=/''/g,Cae=/[a-zA-Z]/;function Ns(t,e,n){const r=Bp(),i=n?.locale??r.locale??vd,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,s=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,o=Jn(t,n?.in);if(!Cie(o))throw new RangeError("Invalid time value");let c=e.match(Eae).map(f=>{const h=f[0];if(h==="p"||h==="P"){const m=gae[h];return m(f,i.formatLong)}return f}).join("").match(kae).map(f=>{if(f==="''")return{isToken:!1,value:"'"};const h=f[0];if(h==="'")return{isToken:!1,value:Aae(f)};if(bR[h])return{isToken:!0,value:f};if(h.match(Cae))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");return{isToken:!1,value:f}});i.localize.preprocessor&&(c=i.localize.preprocessor(o,c));const u={firstWeekContainsDate:a,weekStartsOn:s,locale:i};return c.map(f=>{if(!f.isToken)return f.value;const h=f.value;(!n?.useAdditionalWeekYearTokens&&_ae(h)||!n?.useAdditionalDayOfYearTokens&&bae(h))&&wae(h,e,String(t));const m=bR[h[0]];return m(o,h,i.localize,u)}).join("")}function Aae(t){const e=t.match(Mae);return e?e[1].replace(Tae,"'"):t}function Pae(t,e){const n=Jn(t,e?.in),r=n.getFullYear(),i=n.getMonth(),a=Dr(n,0);return a.setFullYear(r,i+1,0),a.setHours(0,0,0,0),a.getDate()}function Rae(t,e){return Jn(t,e?.in).getMonth()}function Nae(t,e){return Jn(t,e?.in).getFullYear()}function Dae(t,e){return+Jn(t)>+Jn(e)}function Lae(t,e){return+Jn(t)<+Jn(e)}function Iae(t,e,n){const[r,i]=hf(n?.in,t,e);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function Oae(t,e,n){const[r,i]=hf(n?.in,t,e);return r.getFullYear()===i.getFullYear()}function Fae(t,e,n){const r=Jn(t,n?.in),i=r.getFullYear(),a=r.getDate(),s=Dr(t,0);s.setFullYear(i,e,15),s.setHours(0,0,0,0);const o=Pae(s);return r.setMonth(e,Math.min(a,o)),r}function Uae(t,e,n){const r=Jn(t,n?.in);return isNaN(+r)?Dr(t,NaN):(r.setFullYear(e),r)}const kR=5,jae=4;function Bae(t,e){const n=e.startOfMonth(t),r=n.getDay()>0?n.getDay():7,i=e.addDays(t,-r+1),a=e.addDays(i,kR*7-1);return e.getMonth(t)===e.getMonth(a)?kR:jae}function mF(t,e){const n=e.startOfMonth(t),r=n.getDay();return r===1?n:r===0?e.addDays(n,-6):e.addDays(n,-1*(r-1))}function zae(t,e){const n=mF(t,e),r=Bae(t,e);return e.addDays(n,r*7-1)}const gF={...vd,labels:{labelDayButton:(t,e,n,r)=>{let i;r&&typeof r.format=="function"?i=r.format.bind(r):i=(s,o)=>Ns(s,o,{locale:vd,...n});let a=i(t,"PPPP");return e.today&&(a=`Today, ${a}`),e.selected&&(a=`${a}, selected`),a},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:t=>`Week ${t}`,labelYearDropdown:"Choose the Year",labelGrid:(t,e,n)=>{let r;return n&&typeof n.format=="function"?r=n.format.bind(n):r=(i,a)=>Ns(i,a,{locale:vd,...e}),r(t,"LLLL yyyy")},labelGridcell:(t,e,n,r)=>{let i;r&&typeof r.format=="function"?i=r.format.bind(r):i=(s,o)=>Ns(s,o,{locale:vd,...n});let a=i(t,"PPPP");return e?.today&&(a=`Today, ${a}`),a},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(t,e,n)=>{let r;return n&&typeof n.format=="function"?r=n.format.bind(n):r=(i,a)=>Ns(i,a,{locale:vd,...e}),r(t,"cccc")}}};class ua{constructor(e,n){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?mi.tz(this.options.timeZone):new this.Date,this.newDate=(r,i,a)=>this.overrides?.newDate?this.overrides.newDate(r,i,a):this.options.timeZone?new mi(r,i,a,this.options.timeZone):new Date(r,i,a),this.addDays=(r,i)=>this.overrides?.addDays?this.overrides.addDays(r,i):aF(r,i),this.addMonths=(r,i)=>this.overrides?.addMonths?this.overrides.addMonths(r,i):sF(r,i),this.addWeeks=(r,i)=>this.overrides?.addWeeks?this.overrides.addWeeks(r,i):Sie(r,i),this.addYears=(r,i)=>this.overrides?.addYears?this.overrides.addYears(r,i):kie(r,i),this.differenceInCalendarDays=(r,i)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(r,i):BE(r,i),this.differenceInCalendarMonths=(r,i)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(r,i):cF(r,i),this.eachMonthOfInterval=r=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(r):Pie(r),this.eachYearOfInterval=r=>{const i=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(r):Die(r),a=new Set(i.map(o=>this.getYear(o)));if(a.size===i.length)return i;const s=[];return a.forEach(o=>{s.push(new Date(o,0,1))}),s},this.endOfBroadcastWeek=r=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(r):zae(r,this),this.endOfISOWeek=r=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(r):Lie(r),this.endOfMonth=r=>this.overrides?.endOfMonth?this.overrides.endOfMonth(r):Aie(r),this.endOfWeek=(r,i)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(r,i):fF(r,this.options),this.endOfYear=r=>this.overrides?.endOfYear?this.overrides.endOfYear(r):Nie(r),this.format=(r,i,a)=>{const s=this.overrides?.format?this.overrides.format(r,i,this.options):Ns(r,i,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(s):s},this.getISOWeek=r=>this.overrides?.getISOWeek?this.overrides.getISOWeek(r):zE(r),this.getMonth=(r,i)=>this.overrides?.getMonth?this.overrides.getMonth(r,this.options):Rae(r,this.options),this.getYear=(r,i)=>this.overrides?.getYear?this.overrides.getYear(r,this.options):Nae(r,this.options),this.getWeek=(r,i)=>this.overrides?.getWeek?this.overrides.getWeek(r,this.options):VE(r,this.options),this.isAfter=(r,i)=>this.overrides?.isAfter?this.overrides.isAfter(r,i):Dae(r,i),this.isBefore=(r,i)=>this.overrides?.isBefore?this.overrides.isBefore(r,i):Lae(r,i),this.isDate=r=>this.overrides?.isDate?this.overrides.isDate(r):lF(r),this.isSameDay=(r,i)=>this.overrides?.isSameDay?this.overrides.isSameDay(r,i):Tie(r,i),this.isSameMonth=(r,i)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(r,i):Iae(r,i),this.isSameYear=(r,i)=>this.overrides?.isSameYear?this.overrides.isSameYear(r,i):Oae(r,i),this.max=r=>this.overrides?.max?this.overrides.max(r):Eie(r),this.min=r=>this.overrides?.min?this.overrides.min(r):Mie(r),this.setMonth=(r,i)=>this.overrides?.setMonth?this.overrides.setMonth(r,i):Fae(r,i),this.setYear=(r,i)=>this.overrides?.setYear?this.overrides.setYear(r,i):Uae(r,i),this.startOfBroadcastWeek=(r,i)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(r,this):mF(r,this),this.startOfDay=r=>this.overrides?.startOfDay?this.overrides.startOfDay(r):up(r),this.startOfISOWeek=r=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(r):cp(r),this.startOfMonth=r=>this.overrides?.startOfMonth?this.overrides.startOfMonth(r):Rie(r),this.startOfWeek=(r,i)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(r,this.options):Yd(r,this.options),this.startOfYear=r=>this.overrides?.startOfYear?this.overrides.startOfYear(r):dF(r),this.options={locale:gF,...e},this.overrides=n}getDigitMap(){const{numerals:e="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:e}),r={};for(let i=0;i<10;i++)r[i.toString()]=n.format(i);return r}replaceDigits(e){const n=this.getDigitMap();return e.replace(/\d/g,r=>n[r]||r)}formatNumber(e){return this.replaceDigits(e.toString())}getMonthYearOrder(){const e=this.options.locale?.code;return e&&ua.yearFirstLocales.has(e)?"year-first":"month-first"}formatMonthYear(e){const{locale:n,timeZone:r,numerals:i}=this.options,a=n?.code;if(a&&ua.yearFirstLocales.has(a))try{return new Intl.DateTimeFormat(a,{month:"long",year:"numeric",timeZone:r,numberingSystem:i}).format(e)}catch{}const s=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(e,s)}}ua.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const Qs=new ua;class yF{constructor(e,n,r=Qs){this.date=e,this.displayMonth=n,this.outside=!!(n&&!r.isSameMonth(e,n)),this.dateLib=r,this.isoDate=r.format(e,"yyyy-MM-dd"),this.displayMonthId=r.format(n,"yyyy-MM"),this.dateMonthId=r.format(e,"yyyy-MM")}isEqualTo(e){return this.dateLib.isSameDay(e.date,this.date)&&this.dateLib.isSameMonth(e.displayMonth,this.displayMonth)}}class Vae{constructor(e,n){this.date=e,this.weeks=n}}class Hae{constructor(e,n){this.days=n,this.weekNumber=e}}function Wae(t){return ot.createElement("button",{...t})}function Gae(t){return ot.createElement("span",{...t})}function $ae(t){const{size:e=24,orientation:n="left",className:r}=t;return ot.createElement("svg",{className:r,width:e,height:e,viewBox:"0 0 24 24"},n==="up"&&ot.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&ot.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&ot.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&ot.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function Yae(t){const{day:e,modifiers:n,...r}=t;return ot.createElement("td",{...r})}function qae(t){const{day:e,modifiers:n,...r}=t,i=ot.useRef(null);return ot.useEffect(()=>{n.focused&&i.current?.focus()},[n.focused]),ot.createElement("button",{ref:i,...r})}var Zt;(function(t){t.Root="root",t.Chevron="chevron",t.Day="day",t.DayButton="day_button",t.CaptionLabel="caption_label",t.Dropdowns="dropdowns",t.Dropdown="dropdown",t.DropdownRoot="dropdown_root",t.Footer="footer",t.MonthGrid="month_grid",t.MonthCaption="month_caption",t.MonthsDropdown="months_dropdown",t.Month="month",t.Months="months",t.Nav="nav",t.NextMonthButton="button_next",t.PreviousMonthButton="button_previous",t.Week="week",t.Weeks="weeks",t.Weekday="weekday",t.Weekdays="weekdays",t.WeekNumber="week_number",t.WeekNumberHeader="week_number_header",t.YearsDropdown="years_dropdown"})(Zt||(Zt={}));var fr;(function(t){t.disabled="disabled",t.hidden="hidden",t.outside="outside",t.focused="focused",t.today="today"})(fr||(fr={}));var es;(function(t){t.range_end="range_end",t.range_middle="range_middle",t.range_start="range_start",t.selected="selected"})(es||(es={}));var na;(function(t){t.weeks_before_enter="weeks_before_enter",t.weeks_before_exit="weeks_before_exit",t.weeks_after_enter="weeks_after_enter",t.weeks_after_exit="weeks_after_exit",t.caption_after_enter="caption_after_enter",t.caption_after_exit="caption_after_exit",t.caption_before_enter="caption_before_enter",t.caption_before_exit="caption_before_exit"})(na||(na={}));function Xae(t){const{options:e,className:n,components:r,classNames:i,...a}=t,s=[i[Zt.Dropdown],n].join(" "),o=e?.find(({value:c})=>c===a.value);return ot.createElement("span",{"data-disabled":a.disabled,className:i[Zt.DropdownRoot]},ot.createElement(r.Select,{className:s,...a},e?.map(({value:c,label:u,disabled:f})=>ot.createElement(r.Option,{key:c,value:c,disabled:f},u))),ot.createElement("span",{className:i[Zt.CaptionLabel],"aria-hidden":!0},o?.label,ot.createElement(r.Chevron,{orientation:"down",size:18,className:i[Zt.Chevron]})))}function Kae(t){return ot.createElement("div",{...t})}function Zae(t){return ot.createElement("div",{...t})}function Jae(t){const{calendarMonth:e,displayIndex:n,...r}=t;return ot.createElement("div",{...r},t.children)}function Qae(t){const{calendarMonth:e,displayIndex:n,...r}=t;return ot.createElement("div",{...r})}function ese(t){return ot.createElement("table",{...t})}function tse(t){return ot.createElement("div",{...t})}const vF=x.createContext(void 0);function zp(){const t=x.useContext(vF);if(t===void 0)throw new Error("useDayPicker() must be used within a custom component.");return t}function nse(t){const{components:e}=zp();return ot.createElement(e.Dropdown,{...t})}function rse(t){const{onPreviousClick:e,onNextClick:n,previousMonth:r,nextMonth:i,...a}=t,{components:s,classNames:o,labels:{labelPrevious:c,labelNext:u}}=zp(),f=x.useCallback(m=>{i&&n?.(m)},[i,n]),h=x.useCallback(m=>{r&&e?.(m)},[r,e]);return ot.createElement("nav",{...a},ot.createElement(s.PreviousMonthButton,{type:"button",className:o[Zt.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":c(r),onClick:h},ot.createElement(s.Chevron,{disabled:r?void 0:!0,className:o[Zt.Chevron],orientation:"left"})),ot.createElement(s.NextMonthButton,{type:"button",className:o[Zt.NextMonthButton],tabIndex:i?void 0:-1,"aria-disabled":i?void 0:!0,"aria-label":u(i),onClick:f},ot.createElement(s.Chevron,{disabled:i?void 0:!0,orientation:"right",className:o[Zt.Chevron]})))}function ise(t){const{components:e}=zp();return ot.createElement(e.Button,{...t})}function ase(t){return ot.createElement("option",{...t})}function sse(t){const{components:e}=zp();return ot.createElement(e.Button,{...t})}function ose(t){const{rootRef:e,...n}=t;return ot.createElement("div",{...n,ref:e})}function lse(t){return ot.createElement("select",{...t})}function cse(t){const{week:e,...n}=t;return ot.createElement("tr",{...n})}function use(t){return ot.createElement("th",{...t})}function dse(t){return ot.createElement("thead",{"aria-hidden":!0},ot.createElement("tr",{...t}))}function fse(t){const{week:e,...n}=t;return ot.createElement("th",{...n})}function hse(t){return ot.createElement("th",{...t})}function pse(t){return ot.createElement("tbody",{...t})}function mse(t){const{components:e}=zp();return ot.createElement(e.Dropdown,{...t})}const gse=Object.freeze(Object.defineProperty({__proto__:null,Button:Wae,CaptionLabel:Gae,Chevron:$ae,Day:Yae,DayButton:qae,Dropdown:Xae,DropdownNav:Kae,Footer:Zae,Month:Jae,MonthCaption:Qae,MonthGrid:ese,Months:tse,MonthsDropdown:nse,Nav:rse,NextMonthButton:ise,Option:ase,PreviousMonthButton:sse,Root:ose,Select:lse,Week:cse,WeekNumber:fse,WeekNumberHeader:hse,Weekday:use,Weekdays:dse,Weeks:pse,YearsDropdown:mse},Symbol.toStringTag,{value:"Module"}));function ko(t,e,n=!1,r=Qs){let{from:i,to:a}=t;const{differenceInCalendarDays:s,isSameDay:o}=r;return i&&a?(s(a,i)<0&&([i,a]=[a,i]),s(e,i)>=(n?1:0)&&s(a,e)>=(n?1:0)):!n&&a?o(a,e):!n&&i?o(i,e):!1}function HE(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function uv(t){return!!(t&&typeof t=="object"&&"from"in t)}function WE(t){return!!(t&&typeof t=="object"&&"after"in t)}function GE(t){return!!(t&&typeof t=="object"&&"before"in t)}function xF(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function bF(t,e){return Array.isArray(t)&&t.every(e.isDate)}function Eo(t,e,n=Qs){const r=Array.isArray(e)?e:[e],{isSameDay:i,differenceInCalendarDays:a,isAfter:s}=n;return r.some(o=>{if(typeof o=="boolean")return o;if(n.isDate(o))return i(t,o);if(bF(o,n))return o.some(c=>i(t,c));if(uv(o))return ko(o,t,!1,n);if(xF(o))return Array.isArray(o.dayOfWeek)?o.dayOfWeek.includes(t.getDay()):o.dayOfWeek===t.getDay();if(HE(o)){const c=a(o.before,t),u=a(o.after,t),f=c>0,h=u<0;return s(o.before,o.after)?h&&f:f||h}return WE(o)?a(t,o.after)>0:GE(o)?a(o.before,t)>0:typeof o=="function"?o(t):!1})}function yse(t,e,n,r,i){const{disabled:a,hidden:s,modifiers:o,showOutsideDays:c,broadcastCalendar:u,today:f=i.today()}=e,{isSameDay:h,isSameMonth:m,startOfMonth:g,isBefore:v,endOfMonth:w,isAfter:b}=i,_=n&&g(n),E=r&&w(r),M={[fr.focused]:[],[fr.outside]:[],[fr.disabled]:[],[fr.hidden]:[],[fr.today]:[]},T={};for(const P of t){const{date:A,displayMonth:R}=P,k=!!(R&&!m(A,R)),N=!!(_&&v(A,_)),B=!!(E&&b(A,E)),L=!!(a&&Eo(A,a,i)),z=!!(s&&Eo(A,s,i))||N||B||!u&&!c&&k||u&&c===!1&&k,I=h(A,f);k&&M.outside.push(P),L&&M.disabled.push(P),z&&M.hidden.push(P),I&&M.today.push(P),o&&Object.keys(o).forEach(V=>{const W=o?.[V];W&&Eo(A,W,i)&&(T[V]?T[V].push(P):T[V]=[P])})}return P=>{const A={[fr.focused]:!1,[fr.disabled]:!1,[fr.hidden]:!1,[fr.outside]:!1,[fr.today]:!1},R={};for(const k in M){const N=M[k];A[k]=N.some(B=>B===P)}for(const k in T)R[k]=T[k].some(N=>N===P);return{...A,...R}}}function vse(t,e,n={}){return Object.entries(t).filter(([,i])=>i===!0).reduce((i,[a])=>(n[a]?i.push(n[a]):e[fr[a]]?i.push(e[fr[a]]):e[es[a]]&&i.push(e[es[a]]),i),[e[Zt.Day]])}function xse(t){return{...gse,...t}}function bse(t){const e={"data-mode":t.mode??void 0,"data-required":"required"in t?t.required:void 0,"data-multiple-months":t.numberOfMonths&&t.numberOfMonths>1||void 0,"data-week-numbers":t.showWeekNumber||void 0,"data-broadcast-calendar":t.broadcastCalendar||void 0,"data-nav-layout":t.navLayout||void 0};return Object.entries(t).forEach(([n,r])=>{n.startsWith("data-")&&(e[n]=r)}),e}function _se(){const t={};for(const e in Zt)t[Zt[e]]=`rdp-${Zt[e]}`;for(const e in fr)t[fr[e]]=`rdp-${fr[e]}`;for(const e in es)t[es[e]]=`rdp-${es[e]}`;for(const e in na)t[na[e]]=`rdp-${na[e]}`;return t}function _F(t,e,n){return(n??new ua(e)).formatMonthYear(t)}const wse=_F;function Sse(t,e,n){return(n??new ua(e)).format(t,"d")}function kse(t,e=Qs){return e.format(t,"LLLL")}function Ese(t,e,n){return(n??new ua(e)).format(t,"cccccc")}function Mse(t,e=Qs){return t<10?e.formatNumber(`0${t.toLocaleString()}`):e.formatNumber(`${t.toLocaleString()}`)}function Tse(){return""}function wF(t,e=Qs){return e.format(t,"yyyy")}const Cse=wF,Ase=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:_F,formatDay:Sse,formatMonthCaption:wse,formatMonthDropdown:kse,formatWeekNumber:Mse,formatWeekNumberHeader:Tse,formatWeekdayName:Ese,formatYearCaption:Cse,formatYearDropdown:wF},Symbol.toStringTag,{value:"Module"}));function Pse(t){return t?.formatMonthCaption&&!t.formatCaption&&(t.formatCaption=t.formatMonthCaption),t?.formatYearCaption&&!t.formatYearDropdown&&(t.formatYearDropdown=t.formatYearCaption),{...Ase,...t}}function $E(t,e,n,r){let i=(r??new ua(n)).format(t,"PPPP");return e.today&&(i=`Today, ${i}`),e.selected&&(i=`${i}, selected`),i}const Rse=$E;function YE(t,e,n){return(n??new ua(e)).formatMonthYear(t)}const Nse=YE;function SF(t,e,n,r){let i=(r??new ua(n)).format(t,"PPPP");return e?.today&&(i=`Today, ${i}`),i}function kF(t){return"Choose the Month"}function EF(){return""}const Dse="Go to the Next Month";function MF(t,e){return Dse}function TF(t){return"Go to the Previous Month"}function CF(t,e,n){return(n??new ua(e)).format(t,"cccc")}function AF(t,e){return`Week ${t}`}function PF(t){return"Week Number"}function RF(t){return"Choose the Year"}const Lse=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:Nse,labelDay:Rse,labelDayButton:$E,labelGrid:YE,labelGridcell:SF,labelMonthDropdown:kF,labelNav:EF,labelNext:MF,labelPrevious:TF,labelWeekNumber:AF,labelWeekNumberHeader:PF,labelWeekday:CF,labelYearDropdown:RF},Symbol.toStringTag,{value:"Module"})),Wa=(t,e,n)=>e||(n?typeof n=="function"?n:(...r)=>n:t);function Ise(t,e){const n=e.locale?.labels??{};return{...Lse,...t??{},labelDayButton:Wa($E,t?.labelDayButton,n.labelDayButton),labelMonthDropdown:Wa(kF,t?.labelMonthDropdown,n.labelMonthDropdown),labelNext:Wa(MF,t?.labelNext,n.labelNext),labelPrevious:Wa(TF,t?.labelPrevious,n.labelPrevious),labelWeekNumber:Wa(AF,t?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:Wa(RF,t?.labelYearDropdown,n.labelYearDropdown),labelGrid:Wa(YE,t?.labelGrid,n.labelGrid),labelGridcell:Wa(SF,t?.labelGridcell,n.labelGridcell),labelNav:Wa(EF,t?.labelNav,n.labelNav),labelWeekNumberHeader:Wa(PF,t?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:Wa(CF,t?.labelWeekday,n.labelWeekday)}}function Ose(t,e,n,r,i){const{startOfMonth:a,startOfYear:s,endOfYear:o,eachMonthOfInterval:c,getMonth:u}=i;return c({start:s(t),end:o(t)}).map(m=>{const g=r.formatMonthDropdown(m,i),v=u(m),w=e&&m<a(e)||n&&m>a(n)||!1;return{value:v,label:g,disabled:w}})}function Fse(t,e={},n={}){let r={...e?.[Zt.Day]};return Object.entries(t).filter(([,i])=>i===!0).forEach(([i])=>{r={...r,...n?.[i]}}),r}function Use(t,e,n,r){const i=r??t.today(),a=n?t.startOfBroadcastWeek(i,t):e?t.startOfISOWeek(i):t.startOfWeek(i),s=[];for(let o=0;o<7;o++){const c=t.addDays(a,o);s.push(c)}return s}function jse(t,e,n,r,i=!1){if(!t||!e)return;const{startOfYear:a,endOfYear:s,eachYearOfInterval:o,getYear:c}=r,u=a(t),f=s(e),h=o({start:u,end:f});return i&&h.reverse(),h.map(m=>{const g=n.formatYearDropdown(m,r);return{value:c(m),label:g,disabled:!1}})}function Bse(t,e={}){const{weekStartsOn:n,locale:r}=e,i=n??r?.options?.weekStartsOn??0,a=o=>{const c=typeof o=="number"||typeof o=="string"?new Date(o):o;return new mi(c.getFullYear(),c.getMonth(),c.getDate(),12,0,0,t)},s=o=>{const c=a(o);return new Date(c.getFullYear(),c.getMonth(),c.getDate(),0,0,0,0)};return{today:()=>a(mi.tz(t)),newDate:(o,c,u)=>new mi(o,c,u,12,0,0,t),startOfDay:o=>a(o),startOfWeek:(o,c)=>{const u=a(o),f=c?.weekStartsOn??i,h=(u.getDay()-f+7)%7;return u.setDate(u.getDate()-h),u},startOfISOWeek:o=>{const c=a(o),u=(c.getDay()-1+7)%7;return c.setDate(c.getDate()-u),c},startOfMonth:o=>{const c=a(o);return c.setDate(1),c},startOfYear:o=>{const c=a(o);return c.setMonth(0,1),c},endOfWeek:(o,c)=>{const u=a(o),m=(((c?.weekStartsOn??i)+6)%7-u.getDay()+7)%7;return u.setDate(u.getDate()+m),u},endOfISOWeek:o=>{const c=a(o),u=(7-c.getDay())%7;return c.setDate(c.getDate()+u),c},endOfMonth:o=>{const c=a(o);return c.setMonth(c.getMonth()+1,0),c},endOfYear:o=>{const c=a(o);return c.setMonth(11,31),c},eachMonthOfInterval:o=>{const c=a(o.start),u=a(o.end),f=[],h=new mi(c.getFullYear(),c.getMonth(),1,12,0,0,t),m=u.getFullYear()*12+u.getMonth();for(;h.getFullYear()*12+h.getMonth()<=m;)f.push(new mi(h,t)),h.setMonth(h.getMonth()+1,1);return f},addDays:(o,c)=>{const u=a(o);return u.setDate(u.getDate()+c),u},addWeeks:(o,c)=>{const u=a(o);return u.setDate(u.getDate()+c*7),u},addMonths:(o,c)=>{const u=a(o);return u.setMonth(u.getMonth()+c),u},addYears:(o,c)=>{const u=a(o);return u.setFullYear(u.getFullYear()+c),u},eachYearOfInterval:o=>{const c=a(o.start),u=a(o.end),f=[],h=new mi(c.getFullYear(),0,1,12,0,0,t);for(;h.getFullYear()<=u.getFullYear();)f.push(new mi(h,t)),h.setFullYear(h.getFullYear()+1,0,1);return f},getWeek:(o,c)=>{const u=s(o);return VE(u,{weekStartsOn:c?.weekStartsOn??i,firstWeekContainsDate:c?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1})},getISOWeek:o=>{const c=s(o);return zE(c)},differenceInCalendarDays:(o,c)=>{const u=s(o),f=s(c);return BE(u,f)},differenceInCalendarMonths:(o,c)=>{const u=s(o),f=s(c);return cF(u,f)}}}const Vp=t=>t instanceof HTMLElement?t:null,g_=t=>[...t.querySelectorAll("[data-animated-month]")??[]],zse=t=>Vp(t.querySelector("[data-animated-month]")),y_=t=>Vp(t.querySelector("[data-animated-caption]")),v_=t=>Vp(t.querySelector("[data-animated-weeks]")),Vse=t=>Vp(t.querySelector("[data-animated-nav]")),Hse=t=>Vp(t.querySelector("[data-animated-weekdays]"));function Wse(t,e,{classNames:n,months:r,focused:i,dateLib:a}){const s=x.useRef(null),o=x.useRef(r),c=x.useRef(!1);x.useLayoutEffect(()=>{const u=o.current;if(o.current=r,!e||!t.current||!(t.current instanceof HTMLElement)||r.length===0||u.length===0||r.length!==u.length)return;const f=a.isSameMonth(r[0].date,u[0].date),h=a.isAfter(r[0].date,u[0].date),m=h?n[na.caption_after_enter]:n[na.caption_before_enter],g=h?n[na.weeks_after_enter]:n[na.weeks_before_enter],v=s.current,w=t.current.cloneNode(!0);if(w instanceof HTMLElement?(g_(w).forEach(M=>{if(!(M instanceof HTMLElement))return;const T=zse(M);T&&M.contains(T)&&M.removeChild(T);const P=y_(M);P&&P.classList.remove(m);const A=v_(M);A&&A.classList.remove(g)}),s.current=w):s.current=null,c.current||f||i)return;const b=v instanceof HTMLElement?g_(v):[],_=g_(t.current);if(_?.every(E=>E instanceof HTMLElement)&&b&&b.every(E=>E instanceof HTMLElement)){c.current=!0,t.current.style.isolation="isolate";const E=Vse(t.current);E&&(E.style.zIndex="1"),_.forEach((M,T)=>{const P=b[T];if(!P)return;M.style.position="relative",M.style.overflow="hidden";const A=y_(M);A&&A.classList.add(m);const R=v_(M);R&&R.classList.add(g);const k=()=>{c.current=!1,t.current&&(t.current.style.isolation=""),E&&(E.style.zIndex=""),A&&A.classList.remove(m),R&&R.classList.remove(g),M.style.position="",M.style.overflow="",M.contains(P)&&M.removeChild(P)};P.style.pointerEvents="none",P.style.position="absolute",P.style.overflow="hidden",P.setAttribute("aria-hidden","true");const N=Hse(P);N&&(N.style.opacity="0");const B=y_(P);B&&(B.classList.add(h?n[na.caption_before_exit]:n[na.caption_after_exit]),B.addEventListener("animationend",k));const L=v_(P);L&&L.classList.add(h?n[na.weeks_before_exit]:n[na.weeks_after_exit]),M.insertBefore(P,M.firstChild)})}})}function Gse(t,e,n,r){const i=t[0],a=t[t.length-1],{ISOWeek:s,fixedWeeks:o,broadcastCalendar:c}=n??{},{addDays:u,differenceInCalendarDays:f,differenceInCalendarMonths:h,endOfBroadcastWeek:m,endOfISOWeek:g,endOfMonth:v,endOfWeek:w,isAfter:b,startOfBroadcastWeek:_,startOfISOWeek:E,startOfWeek:M}=r,T=c?_(i,r):s?E(i):M(i),P=c?m(a):s?g(v(a)):w(v(a)),A=e&&(c?m(e):s?g(e):w(e)),R=A&&b(P,A)?A:P,k=f(R,T),N=h(a,i)+1,B=[];for(let I=0;I<=k;I++){const V=u(T,I);B.push(V)}const z=(c?35:42)*N;if(o&&B.length<z){const I=z-B.length;for(let V=0;V<I;V++){const W=u(B[B.length-1],1);B.push(W)}}return B}function $se(t){const e=[];return t.reduce((n,r)=>{const i=r.weeks.reduce((a,s)=>a.concat(s.days.slice()),e.slice());return n.concat(i.slice())},e.slice())}function Yse(t,e,n,r){const{numberOfMonths:i=1}=n,a=[];for(let s=0;s<i;s++){const o=r.addMonths(t,s);if(e&&o>e)break;a.push(o)}return a}function ER(t,e,n,r){const{month:i,defaultMonth:a,today:s=r.today(),numberOfMonths:o=1}=t;let c=i||a||s;const{differenceInCalendarMonths:u,addMonths:f,startOfMonth:h}=r;if(n&&u(n,c)<o-1){const m=-1*(o-1);c=f(n,m)}return e&&u(c,e)<0&&(c=e),h(c)}function qse(t,e,n,r){const{addDays:i,endOfBroadcastWeek:a,endOfISOWeek:s,endOfMonth:o,endOfWeek:c,getISOWeek:u,getWeek:f,startOfBroadcastWeek:h,startOfISOWeek:m,startOfWeek:g}=r,v=t.reduce((w,b)=>{const _=n.broadcastCalendar?h(b,r):n.ISOWeek?m(b):g(b),E=n.broadcastCalendar?a(b):n.ISOWeek?s(o(b)):c(o(b)),M=e.filter(R=>R>=_&&R<=E),T=n.broadcastCalendar?35:42;if(n.fixedWeeks&&M.length<T){const R=e.filter(k=>{const N=T-M.length;return k>E&&k<=i(E,N)});M.push(...R)}const P=M.reduce((R,k)=>{const N=n.ISOWeek?u(k):f(k),B=R.find(z=>z.weekNumber===N),L=new yF(k,b,r);return B?B.days.push(L):R.push(new Hae(N,[L])),R},[]),A=new Vae(b,P);return w.push(A),w},[]);return n.reverseMonths?v.reverse():v}function Xse(t,e){let{startMonth:n,endMonth:r}=t;const{startOfYear:i,startOfDay:a,startOfMonth:s,endOfMonth:o,addYears:c,endOfYear:u,newDate:f,today:h}=e,{fromYear:m,toYear:g,fromMonth:v,toMonth:w}=t;!n&&v&&(n=v),!n&&m&&(n=e.newDate(m,0,1)),!r&&w&&(r=w),!r&&g&&(r=f(g,11,31));const b=t.captionLayout==="dropdown"||t.captionLayout==="dropdown-years";return n?n=s(n):m?n=f(m,0,1):!n&&b&&(n=i(c(t.today??h(),-100))),r?r=o(r):g?r=f(g,11,31):!r&&b&&(r=u(t.today??h())),[n&&a(n),r&&a(r)]}function Kse(t,e,n,r){if(n.disableNavigation)return;const{pagedNavigation:i,numberOfMonths:a=1}=n,{startOfMonth:s,addMonths:o,differenceInCalendarMonths:c}=r,u=i?a:1,f=s(t);if(!e)return o(f,u);if(!(c(e,t)<a))return o(f,u)}function Zse(t,e,n,r){if(n.disableNavigation)return;const{pagedNavigation:i,numberOfMonths:a}=n,{startOfMonth:s,addMonths:o,differenceInCalendarMonths:c}=r,u=i?a??1:1,f=s(t);if(!e)return o(f,-u);if(!(c(f,e)<=0))return o(f,-u)}function Jse(t){const e=[];return t.reduce((n,r)=>n.concat(r.weeks.slice()),e.slice())}function dv(t,e){const[n,r]=x.useState(t);return[e===void 0?n:e,r]}function Qse(t,e){const[n,r]=Xse(t,e),{startOfMonth:i,endOfMonth:a}=e,s=ER(t,n,r,e),[o,c]=dv(s,t.month?s:void 0);x.useEffect(()=>{const T=ER(t,n,r,e);c(T)},[t.timeZone]);const{months:u,weeks:f,days:h,previousMonth:m,nextMonth:g}=x.useMemo(()=>{const T=Yse(o,r,{numberOfMonths:t.numberOfMonths},e),P=Gse(T,t.endMonth?a(t.endMonth):void 0,{ISOWeek:t.ISOWeek,fixedWeeks:t.fixedWeeks,broadcastCalendar:t.broadcastCalendar},e),A=qse(T,P,{broadcastCalendar:t.broadcastCalendar,fixedWeeks:t.fixedWeeks,ISOWeek:t.ISOWeek,reverseMonths:t.reverseMonths},e),R=Jse(A),k=$se(A),N=Zse(o,n,t,e),B=Kse(o,r,t,e);return{months:A,weeks:R,days:k,previousMonth:N,nextMonth:B}},[e,o.getTime(),r?.getTime(),n?.getTime(),t.disableNavigation,t.broadcastCalendar,t.endMonth?.getTime(),t.fixedWeeks,t.ISOWeek,t.numberOfMonths,t.pagedNavigation,t.reverseMonths]),{disableNavigation:v,onMonthChange:w}=t,b=T=>f.some(P=>P.days.some(A=>A.isEqualTo(T))),_=T=>{if(v)return;let P=i(T);n&&P<i(n)&&(P=i(n)),r&&P>i(r)&&(P=i(r)),c(P),w?.(P)};return{months:u,weeks:f,days:h,navStart:n,navEnd:r,previousMonth:m,nextMonth:g,goToMonth:_,goToDay:T=>{b(T)||_(T.date)}}}var Es;(function(t){t[t.Today=0]="Today",t[t.Selected=1]="Selected",t[t.LastFocused=2]="LastFocused",t[t.FocusedModifier=3]="FocusedModifier"})(Es||(Es={}));function MR(t){return!t[fr.disabled]&&!t[fr.hidden]&&!t[fr.outside]}function eoe(t,e,n,r){let i,a=-1;for(const s of t){const o=e(s);MR(o)&&(o[fr.focused]&&a<Es.FocusedModifier?(i=s,a=Es.FocusedModifier):r?.isEqualTo(s)&&a<Es.LastFocused?(i=s,a=Es.LastFocused):n(s.date)&&a<Es.Selected?(i=s,a=Es.Selected):o[fr.today]&&a<Es.Today&&(i=s,a=Es.Today))}return i||(i=t.find(s=>MR(e(s)))),i}function toe(t,e,n,r,i,a,s){const{ISOWeek:o,broadcastCalendar:c}=a,{addDays:u,addMonths:f,addWeeks:h,addYears:m,endOfBroadcastWeek:g,endOfISOWeek:v,endOfWeek:w,max:b,min:_,startOfBroadcastWeek:E,startOfISOWeek:M,startOfWeek:T}=s;let A={day:u,week:h,month:f,year:m,startOfWeek:R=>c?E(R,s):o?M(R):T(R),endOfWeek:R=>c?g(R):o?v(R):w(R)}[t](n,e==="after"?1:-1);return e==="before"&&r?A=b([r,A]):e==="after"&&i&&(A=_([i,A])),A}function NF(t,e,n,r,i,a,s,o=0){if(o>365)return;const c=toe(t,e,n.date,r,i,a,s),u=!!(a.disabled&&Eo(c,a.disabled,s)),f=!!(a.hidden&&Eo(c,a.hidden,s)),h=c,m=new yF(c,h,s);return!u&&!f?m:NF(t,e,m,r,i,a,s,o+1)}function noe(t,e,n,r,i){const{autoFocus:a}=t,[s,o]=x.useState(),c=eoe(e.days,n,r||(()=>!1),s),[u,f]=x.useState(a?c:void 0);return{isFocusTarget:w=>!!c?.isEqualTo(w),setFocused:f,focused:u,blur:()=>{o(u),f(void 0)},moveFocus:(w,b)=>{if(!u)return;const _=NF(w,b,u,e.navStart,e.navEnd,t,i);_&&(t.disableNavigation&&!e.days.some(M=>M.isEqualTo(_))||(e.goToDay(_),f(_)))}}}function roe(t,e){const{selected:n,required:r,onSelect:i}=t,[a,s]=dv(n,i?n:void 0),o=i?n:a,{isSameDay:c}=e,u=g=>o?.some(v=>c(v,g))??!1,{min:f,max:h}=t;return{selected:o,select:(g,v,w)=>{let b=[...o??[]];if(u(g)){if(o?.length===f||r&&o?.length===1)return;b=o?.filter(_=>!c(_,g))}else o?.length===h?b=[g]:b=[...b,g];return i||s(b),i?.(b,g,v,w),b},isSelected:u}}function ioe(t,e,n=0,r=0,i=!1,a=Qs){const{from:s,to:o}=e||{},{isSameDay:c,isAfter:u,isBefore:f}=a;let h;if(!s&&!o)h={from:t,to:n>0?void 0:t};else if(s&&!o)c(s,t)?n===0?h={from:s,to:t}:i?h={from:s,to:void 0}:h=void 0:f(t,s)?h={from:t,to:s}:h={from:s,to:t};else if(s&&o)if(c(s,t)&&c(o,t))i?h={from:s,to:o}:h=void 0;else if(c(s,t))h={from:s,to:n>0?void 0:t};else if(c(o,t))h={from:t,to:n>0?void 0:t};else if(f(t,s))h={from:t,to:o};else if(u(t,s))h={from:s,to:t};else if(u(t,o))h={from:s,to:t};else throw new Error("Invalid range");if(h?.from&&h?.to){const m=a.differenceInCalendarDays(h.to,h.from);r>0&&m>r?h={from:t,to:void 0}:n>1&&m<n&&(h={from:t,to:void 0})}return h}function aoe(t,e,n=Qs){const r=Array.isArray(e)?e:[e];let i=t.from;const a=n.differenceInCalendarDays(t.to,t.from),s=Math.min(a,6);for(let o=0;o<=s;o++){if(r.includes(i.getDay()))return!0;i=n.addDays(i,1)}return!1}function TR(t,e,n=Qs){return ko(t,e.from,!1,n)||ko(t,e.to,!1,n)||ko(e,t.from,!1,n)||ko(e,t.to,!1,n)}function soe(t,e,n=Qs){const r=Array.isArray(e)?e:[e];if(r.filter(o=>typeof o!="function").some(o=>typeof o=="boolean"?o:n.isDate(o)?ko(t,o,!1,n):bF(o,n)?o.some(c=>ko(t,c,!1,n)):uv(o)?o.from&&o.to?TR(t,{from:o.from,to:o.to},n):!1:xF(o)?aoe(t,o.dayOfWeek,n):HE(o)?n.isAfter(o.before,o.after)?TR(t,{from:n.addDays(o.after,1),to:n.addDays(o.before,-1)},n):Eo(t.from,o,n)||Eo(t.to,o,n):WE(o)||GE(o)?Eo(t.from,o,n)||Eo(t.to,o,n):!1))return!0;const s=r.filter(o=>typeof o=="function");if(s.length){let o=t.from;const c=n.differenceInCalendarDays(t.to,t.from);for(let u=0;u<=c;u++){if(s.some(f=>f(o)))return!0;o=n.addDays(o,1)}}return!1}function ooe(t,e){const{disabled:n,excludeDisabled:r,resetOnSelect:i,selected:a,required:s,onSelect:o}=t,[c,u]=dv(a,o?a:void 0),f=o?a:c;return{selected:f,select:(g,v,w)=>{const{min:b,max:_}=t;let E;if(g){const M=f?.from,T=f?.to,P=!!M&&!!T,A=!!M&&!!T&&e.isSameDay(M,T)&&e.isSameDay(g,M);i&&(P||!f?.from)?!s&&A?E=void 0:E={from:g,to:void 0}:E=ioe(g,f,b,_,s,e)}return r&&n&&E?.from&&E.to&&soe({from:E.from,to:E.to},n,e)&&(E.from=g,E.to=void 0),o||u(E),o?.(E,g,v,w),E},isSelected:g=>f&&ko(f,g,!1,e)}}function loe(t,e){const{selected:n,required:r,onSelect:i}=t,[a,s]=dv(n,i?n:void 0),o=i?n:a,{isSameDay:c}=e;return{selected:o,select:(h,m,g)=>{let v=h;return!r&&o&&o&&c(h,o)&&(v=void 0),i||s(v),i?.(v,h,m,g),v},isSelected:h=>o?c(o,h):!1}}function coe(t,e){const n=loe(t,e),r=roe(t,e),i=ooe(t,e);switch(t.mode){case"single":return n;case"multiple":return r;case"range":return i;default:return}}function ba(t,e){return t instanceof mi&&t.timeZone===e?t:new mi(t,e)}function Ju(t,e,n){return ba(t,e)}function CR(t,e,n){return typeof t=="boolean"||typeof t=="function"?t:t instanceof Date?Ju(t,e):Array.isArray(t)?t.map(r=>r instanceof Date?Ju(r,e):r):uv(t)?{...t,from:t.from?ba(t.from,e):t.from,to:t.to?ba(t.to,e):t.to}:HE(t)?{before:Ju(t.before,e),after:Ju(t.after,e)}:WE(t)?{after:Ju(t.after,e)}:GE(t)?{before:Ju(t.before,e)}:t}function x_(t,e,n){return t&&(Array.isArray(t)?t.map(r=>CR(r,e)):CR(t,e))}function uoe(t){let e=t;const n=e.timeZone;if(n&&(e={...t,timeZone:n},e.today&&(e.today=ba(e.today,n)),e.month&&(e.month=ba(e.month,n)),e.defaultMonth&&(e.defaultMonth=ba(e.defaultMonth,n)),e.startMonth&&(e.startMonth=ba(e.startMonth,n)),e.endMonth&&(e.endMonth=ba(e.endMonth,n)),e.mode==="single"&&e.selected?e.selected=ba(e.selected,n):e.mode==="multiple"&&e.selected?e.selected=e.selected?.map(ne=>ba(ne,n)):e.mode==="range"&&e.selected&&(e.selected={from:e.selected.from?ba(e.selected.from,n):e.selected.from,to:e.selected.to?ba(e.selected.to,n):e.selected.to}),e.disabled!==void 0&&(e.disabled=x_(e.disabled,n)),e.hidden!==void 0&&(e.hidden=x_(e.hidden,n)),e.modifiers)){const ne={};Object.keys(e.modifiers).forEach(Be=>{ne[Be]=x_(e.modifiers?.[Be],n)}),e.modifiers=ne}const{components:r,formatters:i,labels:a,dateLib:s,locale:o,classNames:c}=x.useMemo(()=>{const ne={...gF,...e.locale},Be=e.broadcastCalendar?1:e.weekStartsOn,ke=e.noonSafe&&e.timeZone?Bse(e.timeZone,{weekStartsOn:Be,locale:ne}):void 0,Ae=e.dateLib&&ke?{...ke,...e.dateLib}:e.dateLib??ke,Ve=new ua({locale:ne,weekStartsOn:Be,firstWeekContainsDate:e.firstWeekContainsDate,useAdditionalWeekYearTokens:e.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:e.useAdditionalDayOfYearTokens,timeZone:e.timeZone,numerals:e.numerals},Ae);return{dateLib:Ve,components:xse(e.components),formatters:Pse(e.formatters),labels:Ise(e.labels,Ve.options),locale:ne,classNames:{..._se(),...e.classNames}}},[e.locale,e.broadcastCalendar,e.weekStartsOn,e.firstWeekContainsDate,e.useAdditionalWeekYearTokens,e.useAdditionalDayOfYearTokens,e.timeZone,e.numerals,e.dateLib,e.noonSafe,e.components,e.formatters,e.labels,e.classNames]);e.today||(e={...e,today:s.today()});const{captionLayout:u,mode:f,navLayout:h,numberOfMonths:m=1,onDayBlur:g,onDayClick:v,onDayFocus:w,onDayKeyDown:b,onDayMouseEnter:_,onDayMouseLeave:E,onNextClick:M,onPrevClick:T,showWeekNumber:P,styles:A}=e,{formatCaption:R,formatDay:k,formatMonthDropdown:N,formatWeekNumber:B,formatWeekNumberHeader:L,formatWeekdayName:z,formatYearDropdown:I}=i,V=Qse(e,s),{days:W,months:X,navStart:J,navEnd:F,previousMonth:G,nextMonth:Y,goToMonth:H}=V,te=yse(W,e,J,F,s),{isSelected:re,select:ue,selected:ce}=coe(e,s)??{},{blur:ee,focused:le,isFocusTarget:ve,moveFocus:Ne,setFocused:be}=noe(e,V,te,re??(()=>!1),s),{labelDayButton:qe,labelGridcell:he,labelGrid:Ue,labelMonthDropdown:je,labelNav:et,labelPrevious:_e,labelNext:oe,labelWeekday:Q,labelWeekNumber:ze,labelWeekNumberHeader:Pe,labelYearDropdown:De}=a,Le=x.useMemo(()=>Use(s,e.ISOWeek,e.broadcastCalendar,e.today),[s,e.ISOWeek,e.broadcastCalendar,e.today]),$=f!==void 0||v!==void 0,U=x.useCallback(()=>{G&&(H(G),T?.(G))},[G,H,T]),Z=x.useCallback(()=>{Y&&(H(Y),M?.(Y))},[H,Y,M]),pe=x.useCallback((ne,Be)=>ke=>{ke.preventDefault(),ke.stopPropagation(),be(ne),!Be.disabled&&(ue?.(ne.date,Be,ke),v?.(ne.date,Be,ke))},[ue,v,be]),Se=x.useCallback((ne,Be)=>ke=>{be(ne),w?.(ne.date,Be,ke)},[w,be]),xe=x.useCallback((ne,Be)=>ke=>{ee(),g?.(ne.date,Be,ke)},[ee,g]),Ie=x.useCallback((ne,Be)=>ke=>{const Ae={ArrowLeft:[ke.shiftKey?"month":"day",e.dir==="rtl"?"after":"before"],ArrowRight:[ke.shiftKey?"month":"day",e.dir==="rtl"?"before":"after"],ArrowDown:[ke.shiftKey?"year":"week","after"],ArrowUp:[ke.shiftKey?"year":"week","before"],PageUp:[ke.shiftKey?"year":"month","before"],PageDown:[ke.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(Ae[ke.key]){ke.preventDefault(),ke.stopPropagation();const[Ve,ge]=Ae[ke.key];Ne(Ve,ge)}b?.(ne.date,Be,ke)},[Ne,b,e.dir]),He=x.useCallback((ne,Be)=>ke=>{_?.(ne.date,Be,ke)},[_]),Ye=x.useCallback((ne,Be)=>ke=>{E?.(ne.date,Be,ke)},[E]),ft=x.useCallback(ne=>Be=>{const ke=Number(Be.target.value),Ae=s.setMonth(s.startOfMonth(ne),ke);H(Ae)},[s,H]),We=x.useCallback(ne=>Be=>{const ke=Number(Be.target.value),Ae=s.setYear(s.startOfMonth(ne),ke);H(Ae)},[s,H]),{className:Xe,style:nt}=x.useMemo(()=>({className:[c[Zt.Root],e.className].filter(Boolean).join(" "),style:{...A?.[Zt.Root],...e.style}}),[c,e.className,e.style,A]),ct=bse(e),Ke=x.useRef(null);Wse(Ke,!!e.animate,{classNames:c,months:X,focused:le,dateLib:s});const gt={dayPickerProps:e,selected:ce,select:ue,isSelected:re,months:X,nextMonth:Y,previousMonth:G,goToMonth:H,getModifiers:te,components:r,classNames:c,styles:A,labels:a,formatters:i};return ot.createElement(vF.Provider,{value:gt},ot.createElement(r.Root,{rootRef:e.animate?Ke:void 0,className:Xe,style:nt,dir:e.dir,id:e.id,lang:e.lang??o.code,nonce:e.nonce,title:e.title,role:e.role,"aria-label":e["aria-label"],"aria-labelledby":e["aria-labelledby"],...ct},ot.createElement(r.Months,{className:c[Zt.Months],style:A?.[Zt.Months]},!e.hideNavigation&&!h&&ot.createElement(r.Nav,{"data-animated-nav":e.animate?"true":void 0,className:c[Zt.Nav],style:A?.[Zt.Nav],"aria-label":et(),onPreviousClick:U,onNextClick:Z,previousMonth:G,nextMonth:Y}),X.map((ne,Be)=>ot.createElement(r.Month,{"data-animated-month":e.animate?"true":void 0,className:c[Zt.Month],style:A?.[Zt.Month],key:Be,displayIndex:Be,calendarMonth:ne},h==="around"&&!e.hideNavigation&&Be===0&&ot.createElement(r.PreviousMonthButton,{type:"button",className:c[Zt.PreviousMonthButton],tabIndex:G?void 0:-1,"aria-disabled":G?void 0:!0,"aria-label":_e(G),onClick:U,"data-animated-button":e.animate?"true":void 0},ot.createElement(r.Chevron,{disabled:G?void 0:!0,className:c[Zt.Chevron],orientation:e.dir==="rtl"?"right":"left"})),ot.createElement(r.MonthCaption,{"data-animated-caption":e.animate?"true":void 0,className:c[Zt.MonthCaption],style:A?.[Zt.MonthCaption],calendarMonth:ne,displayIndex:Be},u?.startsWith("dropdown")?ot.createElement(r.DropdownNav,{className:c[Zt.Dropdowns],style:A?.[Zt.Dropdowns]},(()=>{const ke=u==="dropdown"||u==="dropdown-months"?ot.createElement(r.MonthsDropdown,{key:"month",className:c[Zt.MonthsDropdown],"aria-label":je(),classNames:c,components:r,disabled:!!e.disableNavigation,onChange:ft(ne.date),options:Ose(ne.date,J,F,i,s),style:A?.[Zt.Dropdown],value:s.getMonth(ne.date)}):ot.createElement("span",{key:"month"},N(ne.date,s)),Ae=u==="dropdown"||u==="dropdown-years"?ot.createElement(r.YearsDropdown,{key:"year",className:c[Zt.YearsDropdown],"aria-label":De(s.options),classNames:c,components:r,disabled:!!e.disableNavigation,onChange:We(ne.date),options:jse(J,F,i,s,!!e.reverseYears),style:A?.[Zt.Dropdown],value:s.getYear(ne.date)}):ot.createElement("span",{key:"year"},I(ne.date,s));return s.getMonthYearOrder()==="year-first"?[Ae,ke]:[ke,Ae]})(),ot.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},R(ne.date,s.options,s))):ot.createElement(r.CaptionLabel,{className:c[Zt.CaptionLabel],role:"status","aria-live":"polite"},R(ne.date,s.options,s))),h==="around"&&!e.hideNavigation&&Be===m-1&&ot.createElement(r.NextMonthButton,{type:"button",className:c[Zt.NextMonthButton],tabIndex:Y?void 0:-1,"aria-disabled":Y?void 0:!0,"aria-label":oe(Y),onClick:Z,"data-animated-button":e.animate?"true":void 0},ot.createElement(r.Chevron,{disabled:Y?void 0:!0,className:c[Zt.Chevron],orientation:e.dir==="rtl"?"left":"right"})),Be===m-1&&h==="after"&&!e.hideNavigation&&ot.createElement(r.Nav,{"data-animated-nav":e.animate?"true":void 0,className:c[Zt.Nav],style:A?.[Zt.Nav],"aria-label":et(),onPreviousClick:U,onNextClick:Z,previousMonth:G,nextMonth:Y}),ot.createElement(r.MonthGrid,{role:"grid","aria-multiselectable":f==="multiple"||f==="range","aria-label":Ue(ne.date,s.options,s)||void 0,className:c[Zt.MonthGrid],style:A?.[Zt.MonthGrid]},!e.hideWeekdays&&ot.createElement(r.Weekdays,{"data-animated-weekdays":e.animate?"true":void 0,className:c[Zt.Weekdays],style:A?.[Zt.Weekdays]},P&&ot.createElement(r.WeekNumberHeader,{"aria-label":Pe(s.options),className:c[Zt.WeekNumberHeader],style:A?.[Zt.WeekNumberHeader],scope:"col"},L()),Le.map(ke=>ot.createElement(r.Weekday,{"aria-label":Q(ke,s.options,s),className:c[Zt.Weekday],key:String(ke),style:A?.[Zt.Weekday],scope:"col"},z(ke,s.options,s)))),ot.createElement(r.Weeks,{"data-animated-weeks":e.animate?"true":void 0,className:c[Zt.Weeks],style:A?.[Zt.Weeks]},ne.weeks.map(ke=>ot.createElement(r.Week,{className:c[Zt.Week],key:ke.weekNumber,style:A?.[Zt.Week],week:ke},P&&ot.createElement(r.WeekNumber,{week:ke,style:A?.[Zt.WeekNumber],"aria-label":ze(ke.weekNumber,{locale:o}),className:c[Zt.WeekNumber],scope:"row",role:"rowheader"},B(ke.weekNumber,s)),ke.days.map(Ae=>{const{date:Ve}=Ae,ge=te(Ae);if(ge[fr.focused]=!ge.hidden&&!!le?.isEqualTo(Ae),ge[es.selected]=re?.(Ve)||ge.selected,uv(ce)){const{from:Lt,to:_t}=ce;ge[es.range_start]=!!(Lt&&_t&&s.isSameDay(Ve,Lt)),ge[es.range_end]=!!(Lt&&_t&&s.isSameDay(Ve,_t)),ge[es.range_middle]=ko(ce,Ve,!0,s)}const ut=Fse(ge,A,e.modifiersStyles),yt=vse(ge,c,e.modifiersClassNames),qt=!$&&!ge.hidden?he(Ve,ge,s.options,s):void 0;return ot.createElement(r.Day,{key:`${Ae.isoDate}_${Ae.displayMonthId}`,day:Ae,modifiers:ge,className:yt.join(" "),style:ut,role:"gridcell","aria-selected":ge.selected||void 0,"aria-label":qt,"data-day":Ae.isoDate,"data-month":Ae.outside?Ae.dateMonthId:void 0,"data-selected":ge.selected||void 0,"data-disabled":ge.disabled||void 0,"data-hidden":ge.hidden||void 0,"data-outside":Ae.outside||void 0,"data-focused":ge.focused||void 0,"data-today":ge.today||void 0},!ge.hidden&&$?ot.createElement(r.DayButton,{className:c[Zt.DayButton],style:A?.[Zt.DayButton],type:"button",day:Ae,modifiers:ge,disabled:!ge.focused&&ge.disabled||void 0,"aria-disabled":ge.focused&&ge.disabled||void 0,tabIndex:ve(Ae)?0:-1,"aria-label":qe(Ve,ge,s.options,s),onClick:pe(Ae,ge),onBlur:xe(Ae,ge),onFocus:Se(Ae,ge),onKeyDown:Ie(Ae,ge),onMouseEnter:He(Ae,ge),onMouseLeave:Ye(Ae,ge)},k(Ve,s.options,s)):!ge.hidden&&k(Ae.date,s.options,s))})))))))),e.footer&&ot.createElement(r.Footer,{className:c[Zt.Footer],style:A?.[Zt.Footer],role:"status","aria-live":"polite"},e.footer)))}function AR(t){if(!t)return"";const e=t.split("-");if(e.length!==3)return t;const n=new Date(Number(e[0]),Number(e[1])-1,Number(e[2]));return Number.isFinite(n.getTime())?Ns(n,"MMM d"):t}function doe({from:t,to:e,onApply:n,onCancel:r}){const i=x.useMemo(()=>{const u={from:void 0,to:void 0};if(t){const f=t.split("-");u.from=new Date(Number(f[0]),Number(f[1])-1,Number(f[2]))}if(e){const f=e.split("-");u.to=new Date(Number(f[0]),Number(f[1])-1,Number(f[2]))}return u},[t,e]),[a,s]=x.useState(i),o=()=>{if(!a?.from)return;const u=Ns(a.from,"yyyy-MM-dd"),f=a.to?Ns(a.to,"yyyy-MM-dd"):u;n?.(u,f)},c=!!a?.from;return p.jsxs("div",{className:"p-4",children:[p.jsx(uoe,{mode:"range",selected:a,onSelect:s,numberOfMonths:2,showOutsideDays:!1,classNames:{root:"rdp-oai",months:"flex gap-4",month:"space-y-3",month_caption:"flex justify-center items-center h-8",caption_label:"text-sm font-medium text-oai-black dark:text-oai-white",nav:"flex items-center justify-between absolute inset-x-0 top-0 px-2",button_previous:"inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",button_next:"inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",chevron:"w-4 h-4",month_grid:"border-collapse",weekdays:"flex",weekday:"w-9 text-center text-xs font-medium text-oai-gray-400 dark:text-oai-gray-500 py-1",week:"flex",day:"w-9 h-9 text-center text-sm p-0 relative",day_button:"w-full h-full inline-flex items-center justify-center rounded-md transition-colors hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 text-oai-black dark:text-oai-white cursor-pointer rdp-day-btn",today:"font-bold",selected:"rdp-selected",range_start:"rdp-selected rdp-range-start",range_end:"rdp-selected rdp-range-end",range_middle:"rdp-range-mid",outside:"text-oai-gray-300 dark:text-oai-gray-600",disabled:"text-oai-gray-300 dark:text-oai-gray-600 cursor-not-allowed",hidden:"invisible"},styles:{months:{position:"relative"}}}),p.jsxs("div",{className:"flex items-center justify-end gap-2 mt-4 pt-3 border-t border-oai-gray-200 dark:border-oai-gray-700",children:[c&&a.from&&p.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mr-auto",children:[Ns(a.from,"MMM d, yyyy"),a.to&&a.to.getTime()!==a.from.getTime()?` — ${Ns(a.to,"MMM d, yyyy")}`:""]}),p.jsx(Ui,{variant:"secondary",size:"sm",onClick:r,children:"Cancel"}),p.jsx(Ui,{variant:"primary",size:"sm",onClick:o,disabled:!c,children:"Apply"})]})]})}const foe=[{key:"system_prompt",color:"#64748b",from:["system_prefix"]},{key:"messages",color:"#3b82f6",from:["user_input","conversation_history","assistant_response"]},{key:"tool_calls",color:"#8b5cf6",from:["tool_calls"]},{key:"custom_agents",color:"#ec4899",from:["subagents"]},{key:"reasoning",color:"#06b6d4",from:["reasoning"]}],b_=[{key:"system_prompt",color:"#64748b"},{key:"messages",color:"#3b82f6"},{key:"tool_calls",color:"#8b5cf6"},{key:"reasoning",color:"#06b6d4"}],hoe=[["by_type","dashboard.context_breakdown.exec_details.group_by_type"],["by_executable","dashboard.context_breakdown.exec_details.group_by_executable"],["by_command","dashboard.context_breakdown.exec_details.group_by_command"],["by_duration","dashboard.context_breakdown.exec_details.group_by_duration"],["by_output","dashboard.context_breakdown.exec_details.group_by_output"],["by_exit","dashboard.context_breakdown.exec_details.group_by_exit"]],poe={duration:.18,ease:[.4,0,.2,1]},moe={height:0,opacity:0},goe={height:"auto",opacity:1},yoe={height:0,opacity:0};function voe(t){const e=Number(t||0);return Number.isFinite(e)&&e>0?e:0}function xoe(t,e){const n={};for(const r of["input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens","total_tokens"])n[r]=Math.round(Number(t?.[r]||0)*e);return n}function DF(t,e=null){const n=t.reduce((s,o)=>s+Number(o.totals.total_tokens||0),0),r=voe(e),i=r||n,a=r&&n>0?r/n:1;return t.map(s=>{const o=a===1?s.totals:xoe(s.totals,a);return{...s,totals:o,percent:i>0?Number((o.total_tokens/i*100).toFixed(2)):0}}).sort((s,o)=>o.totals.total_tokens-s.totals.total_tokens)}function boe(t,e=null){const n=new Map;for(const i of t||[])n.set(i.key,i);const r=foe.map(i=>{const a={input_tokens:0,cached_input_tokens:0,cache_creation_input_tokens:0,output_tokens:0,reasoning_output_tokens:0,total_tokens:0};for(const s of i.from){const o=n.get(s);if(!o)continue;const c=o.totals||{};a.input_tokens+=c.input_tokens||0,a.cached_input_tokens+=c.cached_input_tokens||0,a.cache_creation_input_tokens+=c.cache_creation_input_tokens||0,a.output_tokens+=c.output_tokens||0,a.reasoning_output_tokens+=c.reasoning_output_tokens||0,a.total_tokens+=c.total_tokens||0}return{key:i.key,color:i.color,totals:a}});return DF(r,e)}function _oe(t,e=null){const n=t?.totals||{},r=Number(n.reasoning_output_tokens||0),i=(t?.tool_calls_breakdown?.categories||[]).reduce((u,f)=>f?.name==="Text Response"?u:u+Number(f?.totals?.total_tokens||0),0),a=Number(n.total_tokens||0),s=Math.min(Math.max(0,i),Math.max(0,a-r)),o=Math.max(0,a-r-s),c=[{key:"messages",color:b_[1].color,totals:{total_tokens:o}},{key:"tool_calls",color:b_[2].color,totals:{total_tokens:s}},{key:"reasoning",color:b_[3].color,totals:{total_tokens:r}}];return DF(c,e)}function __(t){return O(`dashboard.context_breakdown.category.${t}`)}function Lc(t){return!Number.isFinite(Number(t))||Number(t)<=0?"0":Ma(Number(t),{decimals:1})}function woe(t){return typeof t!="string"?"":t.startsWith("mcp__")?t.split("__").slice(2).join("__")||t:t.includes("/")&&t.split("/").pop()||t}function Soe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||null,r=Number(n?n.input_tokens||0:e?.input_tokens||0),i=Number(n?n.output_tokens||0:e?.output_tokens||0),a=Number(n?n.cached_input_tokens||0:e?.cache_read||0),s=Number(n?n.cache_creation_input_tokens||0:e?.cache_creation||0),o=Number(n?n.total_tokens||r+i:e?.total_tokens||i);return{name:woe(e?.name?String(e.name):""),calls:Number(e?.calls||0),input_tokens:r,output_tokens:i,cache_read:a,cache_creation:s,total_tokens:Number(o||0)}}).filter(e=>e.name).sort((e,n)=>(n.total_tokens||0)-(e.total_tokens||0))}function koe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{},r=Array.isArray(e?.tools)?e.tools:[],i=Number(n.input_tokens||0),a=Number(n.output_tokens||0),s=Number(n.cached_input_tokens||0),o=Number(n.cache_creation_input_tokens||0);return{name:e?.name?String(e.name):"",calls:Number(e?.calls||0),totals:{input_tokens:i,output_tokens:a,cached_input_tokens:s,cache_creation_input_tokens:o,total_tokens:Number(n.total_tokens||i+a)},tools:Soe(r),toolCount:r.length}}).filter(e=>e.name).sort((e,n)=>(n.totals.total_tokens||0)-(e.totals.total_tokens||0))}function Eoe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{},r=Number(n.input_tokens||0),i=Number(n.output_tokens||0),a=Number(n.cached_input_tokens||0),s=Number(n.cache_creation_input_tokens||0);return{key:e?.key?String(e.key):"",name:e?.name?String(e.name):"",totals:{input_tokens:r,output_tokens:i,cached_input_tokens:a,cache_creation_input_tokens:s,total_tokens:Number(n.total_tokens||r+i+a+s)}}}).filter(e=>e.key||e.name).sort((e,n)=>(n.totals.total_tokens||0)-(e.totals.total_tokens||0))}function Moe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{};return{name:e?.name?String(e.name):"",calls:Number(e?.calls||0),total_tokens:Number(n.total_tokens||0)}}).filter(e=>e.name).sort((e,n)=>Number(n.total_tokens||0)-Number(e.total_tokens||0))}function Toe(t){if(t?.key){const e=O(`dashboard.context_breakdown.message_details.${t.key}`);if(e&&!e.includes("dashboard.context_breakdown"))return e}return t?.name||""}function Coe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{},r=Number(n.input_tokens||0),i=Number(n.output_tokens||0),a=Number(n.cached_input_tokens||0),s=Number(n.cache_creation_input_tokens||0);return{name:e?.name?String(e.name):"",calls:Number(e?.calls||0),failures:Number(e?.failures||0),duration_ms:Number(e?.duration_ms||0),max_duration_ms:Number(e?.max_duration_ms||0),output_chars:Number(e?.output_chars||0),output_lines:Number(e?.output_lines||0),totals:{input_tokens:r,output_tokens:i,cached_input_tokens:a,cache_creation_input_tokens:s,total_tokens:Number(n.total_tokens||r+i)}}}).filter(e=>e.name).sort((e,n)=>Number(n.totals.total_tokens||0)-Number(e.totals.total_tokens||0))}function PR(t){const e=Number(t||0);return!Number.isFinite(e)||e<=0?"0ms":e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.round(e/1e3)}s`}function Aoe(t,e){return t?e==="by_executable"?t.by_executable||[]:e==="by_command"?t.by_command||[]:e==="by_duration"?t.by_duration||[]:e==="by_output"?t.by_output||[]:e==="by_exit"?t.by_exit||[]:t.by_type||[]:[]}function RR(t){return t==="exec_command"||t==="Bash"}function LF(t){return t==="codex"?"dashboard.context_breakdown.empty_codex":"dashboard.context_breakdown.empty"}function Poe(t){return t==="codex"?"dashboard.context_breakdown.error_codex":"dashboard.context_breakdown.error"}function Roe(t){return t==="codex"?"dashboard.context_breakdown.footnote_codex":"dashboard.context_breakdown.footnote"}const Noe=10;function Md({level:t=0,colorSquare:e=null,label:n,labelSuffix:r=null,labelTone:i="default",hasChevron:a=!1,open:s=!1,onToggle:o,tokens:c,percent:u=null,children:f}){const h=i==="accent"?"text-oai-brand truncate":i==="muted"?"text-oai-gray-500 dark:text-oai-gray-400 truncate":i==="strong"?"font-medium text-oai-black dark:text-oai-white truncate":"text-oai-gray-700 dark:text-oai-gray-300 truncate",m=p.jsx("span",{className:"shrink-0 flex items-center justify-start",style:{width:Noe},"aria-hidden":!e,children:e}),g=p.jsxs(p.Fragment,{children:[m,p.jsx("span",{className:h,children:n}),r,a&&p.jsx(Qn.span,{animate:{rotate:s?90:0},transition:{duration:.15},className:"shrink-0 text-oai-gray-400 dark:text-oai-gray-500 flex items-center","aria-hidden":"true",children:p.jsx(jW,{size:11})})]});return p.jsxs("li",{className:"min-w-0",children:[p.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_64px_48px] items-center gap-2 text-xs py-0.5",children:[a?p.jsx("button",{type:"button",onClick:o,"aria-expanded":s,className:"flex items-center gap-1.5 min-w-0 text-left cursor-pointer hover:opacity-90 focus-visible:outline-none focus-visible:ring-inset focus-visible:ring-2 focus-visible:ring-oai-brand/40 rounded-sm",children:g}):p.jsx("div",{className:"flex items-center gap-1.5 min-w-0",children:g}),p.jsx("span",{className:"text-right tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:c||""}),p.jsx("span",{className:"text-right tabular-nums text-oai-black dark:text-oai-white font-medium",children:u||""})]}),a&&f?p.jsx(Lp,{initial:!1,children:s&&p.jsx(Qn.div,{initial:moe,animate:goe,exit:yoe,transition:poe,style:{overflow:"hidden"},children:f},"content")}):null]})}function NR({execDetails:t,source:e="claude"}){const[n,r]=x.useState("by_type"),i=Coe(Aoe(t,n)),a=e==="codex",s=a?"grid-cols-[minmax(0,1fr)_48px_48px_72px_72px_60px_60px]":"grid-cols-[minmax(0,1fr)_56px_60px]";return p.jsxs("div",{className:"mt-2 ml-4",children:[p.jsx("div",{className:"flex flex-wrap items-center gap-1 rounded-md bg-oai-gray-100 dark:bg-oai-gray-900 p-1 w-fit max-w-full",children:hoe.map(([o,c])=>p.jsx("button",{type:"button",onClick:()=>r(o),className:"h-7 px-2 rounded-md text-[10px] font-medium transition-colors "+(n===o?"bg-oai-white dark:bg-oai-gray-800 text-oai-black dark:text-oai-white shadow-sm":"text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-white/70 dark:hover:bg-oai-gray-800/70"),children:O(c)},o))}),i.length===0?p.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:"—"}):p.jsx("div",{className:"mt-2 overflow-x-auto",children:p.jsxs("div",{role:"table","aria-label":O("dashboard.context_breakdown.exec_details.title"),className:a?"min-w-[420px]":"min-w-[260px]",children:[p.jsxs("div",{role:"row",className:`grid ${s} gap-2 py-1.5 mb-1 border-b border-oai-gray-200 dark:border-oai-gray-800 text-label uppercase text-oai-gray-500 dark:text-oai-gray-400`,children:[p.jsx("span",{role:"columnheader",children:O("dashboard.context_breakdown.exec_details.kind_column")}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.calls_column")}),a&&p.jsxs(p.Fragment,{children:[p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.failures_column")}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.duration_column")}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.max_duration_column")})]}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.tool_details.total_column")}),a&&p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.output_column")})]}),i.map((o,c)=>p.jsxs(Qn.div,{role:"row",className:`grid ${s} gap-2 py-1.5`,title:o.name,initial:{opacity:0},animate:{opacity:1},transition:{duration:.18,delay:c*.02},children:[p.jsx("span",{role:"cell",className:"min-w-0 text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:o.name}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ma(o.calls||0)}),a&&p.jsxs(p.Fragment,{children:[p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ma(o.failures||0)}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:PR(o.duration_ms||0)}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:PR(o.max_duration_ms||0)})]}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Lc(o.totals.total_tokens||0)}),a&&p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ma(o.output_lines||0)})]},o.name))]})})]})}function DR({toolSet:t,execDetails:e,source:n,codexQueueFallback:r}){const[i,a]=x.useState({}),[s,o]=x.useState(!1),c=koe(t?.categories||[]);function u(f){a(h=>({...h,[f]:!h[f]}))}return c.length===0?p.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:O(n==="codex"&&r?"dashboard.context_breakdown.tool_details.unavailable_codex":LF(n))}):p.jsx("ul",{className:"mt-0.5 mb-0.5 space-y-0.5",children:c.map(f=>{const h=f.toolCount>0,m=f.name==="Execution"&&e,g=m&&f.tools.some(w=>RR(w.name)),v=!!i[f.name];return p.jsxs(Md,{level:1,label:f.name,labelTone:"strong",hasChevron:h||m&&!g,open:v||m&&!g&&s,onToggle:()=>{h?u(f.name):m&&!g&&o(w=>!w)},tokens:Lc(f.totals.total_tokens||0),percent:null,children:[h&&p.jsx("ul",{className:"space-y-0.5",children:f.tools.map(w=>{const b=m&&RR(w.name);return p.jsx(Md,{level:2,label:w.name,labelTone:b?"accent":"default",hasChevron:b,open:s,onToggle:()=>o(_=>!_),tokens:Lc(w.total_tokens||0),percent:null,children:b&&p.jsx(NR,{execDetails:e,source:n})},w.name)})}),m&&!g&&p.jsx(NR,{execDetails:e,source:n})]},f.name)})})}function Doe({from:t,to:e,source:n="claude",referenceTotalTokens:r=null,onLoadingChange:i=null}){const[a,s]=x.useState(null),[o,c]=x.useState(!1),[u,f]=x.useState(null),[h,m]=x.useState({});function g(L){m(z=>({...z,[L]:!z[L]}))}if(x.useEffect(()=>{let L=!1;return c(!0),i?.(!0),f(null),S7({from:t,to:e,source:n,timeZone:x3(),tzOffsetMinutes:b3()}).then(z=>{L||s(z)}).catch(z=>{L||f(z?.message||String(z))}).finally(()=>{L||(c(!1),i?.(!1))}),()=>{L=!0}},[t,e,n]),o&&!a)return p.jsxs("div",{children:[p.jsx("div",{className:"h-1 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden animate-pulse"}),p.jsx("div",{className:"mt-3 grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-2",children:[0,1,2,3,4].map(L=>p.jsx("div",{className:"h-3 rounded bg-oai-gray-100 dark:bg-oai-gray-800 animate-pulse",style:{animationDelay:`${L*80}ms`}},L))}),p.jsx("p",{className:"mt-3 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:O("dashboard.context_breakdown.loading_hint")})]});if(u)return p.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O(Poe(n))});if(!a||a.scope!=="supported"||!a.totals?.total_tokens)return p.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O(LF(n))});const v=n==="claude"?boe(a.categories||[],r):_oe(a,r),w=a.tool_calls_breakdown||null,b=a.skills_breakdown||null,_=a.message_breakdown||null,E=a.configured_resources||null,M=a.exec_command_breakdown||null,T=Moe(b?.skills||[]),P=Eoe(_?.categories||[]),A=n==="codex"&&(a?.breakdown_status==="queue_fallback"||a?.fallback==="queue_totals"),R=n==="claude"?w?.tool_calls||null:w||null,k=n==="claude"&&w?.subagents||null,N=k?.categories?.length>0||(E?.custom_agents_count||0)>0,B=[...v].sort((L,z)=>(z.totals?.total_tokens||0)-(L.totals?.total_tokens||0));return p.jsxs("div",{children:[p.jsx("div",{role:"img","aria-label":O("dashboard.context_breakdown.bar_aria",{summary:v.filter(L=>L.percent>0).map(L=>`${__(L.key)} ${L.percent}%`).join(",")}),className:"h-1 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden flex",children:v.map((L,z)=>!L.percent||L.percent<=0?null:p.jsx(Qn.div,{initial:{width:0},animate:{width:`${L.percent}%`},transition:{duration:.5,delay:.1+z*.04,ease:[.16,1,.3,1]},className:"h-full",style:{backgroundColor:L.color},title:`${__(L.key)}: ${L.percent}%`},L.key))}),p.jsxs("ul",{className:"mt-3 space-y-1",children:[B.map(L=>{const z=L.key==="system_prompt",I=L.key==="messages",V=L.key==="tool_calls",W=L.key==="custom_agents";L.key;const X=I&&P.length>0||V&&(R?.categories?.length>0||A)||W&&N&&k,J=!!h[L.key],F=p.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0",style:{backgroundColor:L.color},"aria-hidden":"true"}),G=z?p.jsxs("span",{className:"relative inline-flex shrink-0 group",children:[p.jsx(z3,{size:11,className:"text-oai-gray-400 dark:text-oai-gray-500 cursor-help","aria-hidden":"true"}),p.jsx("span",{role:"tooltip",className:"pointer-events-none absolute left-1/2 bottom-full z-20 mb-1.5 -translate-x-1/2 w-64 rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-white dark:bg-oai-gray-900 px-2.5 py-1.5 text-[11px] leading-snug text-oai-gray-700 dark:text-oai-gray-200 shadow-md opacity-0 group-hover:opacity-100 transition-opacity",children:O("dashboard.context_breakdown.system_prefix_tooltip")})]}):null,Y=L.percent>0?`${L.percent.toFixed(L.percent<.1&&L.percent>0?2:1)}%`:"0.0%";return p.jsxs(Md,{level:0,colorSquare:F,label:__(L.key),labelSuffix:G,tokens:Lc(L.totals?.total_tokens||0),percent:Y,hasChevron:X,open:J,onToggle:()=>g(L.key),children:[I&&p.jsx("ul",{className:"space-y-0.5",children:P.map(H=>p.jsx(Md,{level:1,label:Toe(H),tokens:Lc(H.totals.total_tokens||0),percent:null},H.key||H.name))}),V&&R&&p.jsx(DR,{toolSet:R,execDetails:M,source:n,codexQueueFallback:A}),V&&A&&!R&&p.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:O("dashboard.context_breakdown.tool_details.unavailable_codex")}),W&&k&&p.jsx(DR,{toolSet:k,execDetails:null,source:n,codexQueueFallback:!1})]},L.key)}),T.length>0&&p.jsx(Md,{level:0,colorSquare:p.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:O("dashboard.context_breakdown.category.skills"),tokens:Lc(T.reduce((L,z)=>L+(z.total_tokens||0),0)),percent:null,hasChevron:!0,open:!!h.skills,onToggle:()=>g("skills"),children:p.jsx("ul",{className:"space-y-0.5",children:T.slice(0,12).map(L=>p.jsx(Md,{level:1,label:L.name,tokens:Lc(L.total_tokens),percent:null},L.name))})})]}),p.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:O(Roe(n))}),A?p.jsx("p",{className:"mt-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:O("dashboard.context_breakdown.tool_details.unavailable_codex")}):null,E?p.jsxs("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:[Ma(E.skills_count||0)," skills ·"," ",Ma(E.mcp_servers_count||0)," MCP servers ·"," ",Ma(E.custom_agents_count||0)," agents ·"," ",Ma(E.memory_files_count||0)," memory files"]}):null]})}function IF(t){if(!Number.isFinite(Number(t)))return null;const e=Number(t);return e<=0?null:Ma(e,{decimals:1})}function OF(t){const e=Number(t);return!Number.isFinite(e)||e<=0?null:e<.01?"<$0.01":Uy(e.toFixed(2),{decimals:2})}function Loe(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?{key:e,label:LR(e)}:{key:e.key,label:e.label||LR(e.key)}):[]}function Ioe(t){if(typeof t!="string")return null;const e=t.replace(/,/g,"").match(/-?\d+(?:\.\d+)?/);if(!e)return null;const n=Number(e[0]);return Number.isFinite(n)?n:null}const Ooe={CODEX:"#10b981",CLAUDE:"#8b5cf6",OPENCODE:"#f59e0b",GEMINI:"#3b82f6",KIMI:"#a78bfa"};function w_(t,e){const n=t?.toUpperCase?.()||"";return Ooe[n]||`hsl(${150+e*40}, 60%, 45%)`}function Foe(t){const e=String(t?.source||"").trim().toLowerCase(),n=String(t?.label||"").trim().toLowerCase();return e==="claude"||n==="claude"?"claude":e==="codex"||n==="codex"?"codex":null}const Uoe={day:"usage.period.day",week:"usage.period.week",month:"usage.period.month",total:"usage.period.total",custom:"usage.period.custom"};function LR(t){const e=Uoe[t];return e?O(e):String(t).toUpperCase()}function joe({loading:t,onClick:e}){const n=cu();return p.jsx(Ui,{variant:"secondary",size:"sm",disabled:t,onClick:e,"aria-label":O("usage.button.refresh"),className:"w-8 p-0",children:p.jsx(Qn.span,{"aria-hidden":"true",animate:t?{rotate:360}:{rotate:0},transition:t&&!n?{duration:1,repeat:1/0,ease:"linear"}:{duration:.3},style:{display:"inline-block"},children:"↻"})})}function Boe({period:t,periods:e,onPeriodChange:n,summaryValue:r,summaryLabel:i,summaryCostValue:a,onCostInfo:s,fleetData:o=[],onRefresh:c,loading:u,className:f="",customFrom:h,customTo:m,onCustomRangeApply:g,customRangeOpen:v,onCustomRangeOpenChange:w,onOpenShare:b,from:_,to:E}){const M=Loe(e),T=Ioe(String(r??"")),P=T!=null,[A,R]=x.useState(null),{resolvedTheme:k}=Op(),N=k==="dark",B=N?"rgba(10,10,10,0.98)":"rgba(255,255,255,0.96)",L=N?"rgba(10,10,10,0)":"rgba(255,255,255,0)",z=o.filter(I=>I.models?.length>0);return p.jsxs(pu,{className:f,children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 mb-6",children:[p.jsx("div",{role:"tablist","aria-label":O("usage.overview.tablist_aria"),className:"flex gap-1",children:M.map(I=>{const V=t===I.key,W=`text-xs font-medium px-3 py-1.5 rounded-md transition-colors ${V?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800"}`;if(I.key==="custom"){const X=V&&h&&m?`${AR(h)} — ${AR(m)}`:I.label;return p.jsxs(K5,{open:v,onOpenChange:J=>{J?n?.("custom"):w?.(J)},children:[p.jsx(Z5,{render:p.jsx("button",{role:"tab","aria-selected":V,type:"button",className:W}),children:X}),p.jsx(Q5,{children:p.jsx(tF,{sideOffset:8,side:"bottom",align:"start",className:"!z-[9999]",children:p.jsx(nF,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:p.jsx(doe,{from:h,to:m,onApply:g,onCancel:()=>w?.(!1)})})})})]},"custom")}return p.jsx("button",{role:"tab","aria-selected":V,type:"button",className:W,onClick:()=>n?.(I.key),children:I.label},I.key)})}),p.jsxs("div",{className:"flex items-center gap-1.5",children:[b?p.jsxs("button",{type:"button",onClick:b,"aria-label":O("share.button.aria"),className:"inline-flex items-center justify-center gap-1.5 h-8 px-3 text-xs font-medium rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-oai-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white hover:border-oai-brand hover:text-oai-brand transition-colors duration-200",children:[p.jsx(yG,{className:"h-3.5 w-3.5",strokeWidth:2}),O("share.button.label")]}):null,c&&p.jsx(joe,{loading:u,onClick:c})]})]}),p.jsxs("div",{className:"text-center mb-8",children:[p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wider mb-3",children:i}),p.jsx("div",{className:"text-6xl md:text-7xl font-bold text-oai-black dark:text-oai-white tracking-tight tabular-nums",children:P?p.jsx(iie,{value:T,displayValue:r,fontSize:72,padding:6,gap:1,textColor:"var(--oai-black, #111827)",fontWeight:700,gradientHeight:N?0:8,gradientFrom:B,gradientTo:L,counterStyle:{paddingLeft:0,paddingRight:0,gap:0},digitStyle:{width:"0.88ch"}}):r}),a&&p.jsx("div",{className:"flex items-center justify-center gap-2 mt-4",children:s?p.jsxs("button",{type:"button",onClick:s,className:"inline-flex items-center gap-1.5 text-xl font-bold text-oai-brand hover:text-oai-brand-dark dark:hover:text-oai-brand-light transition-colors cursor-pointer","aria-label":O("usage.overview.cost_breakdown_aria"),children:[a,p.jsx(z3,{size:16,strokeWidth:2,className:"opacity-80"})]}):p.jsx("span",{className:"text-xl font-bold text-oai-brand",children:a})})]}),z.length>0&&p.jsxs("div",{className:"space-y-6",children:[p.jsx("div",{role:"img","aria-label":O("usage.overview.distribution_aria",{items:z.map(I=>O("usage.overview.distribution_item",{label:I.label,percent:I.totalPercent})).join(",")}),className:"h-1.5 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden flex",children:z.map((I,V)=>{const W=w_(I.label,V);return p.jsx(Qn.div,{initial:{width:0},animate:{width:`${I.totalPercent}%`},transition:{duration:.5,delay:.45+V*.04,ease:[.16,1,.3,1]},className:"h-full",style:{backgroundColor:W},title:`${I.label}: ${I.totalPercent}%`},I.label)})}),p.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 xl:grid-cols-5 gap-3",children:z.map((I,V)=>{const W=w_(I.label,V),X=A===I.label;return p.jsxs("button",{"aria-expanded":X,"aria-controls":`provider-details-${I.label}`,"aria-label":O("usage.overview.provider_card_aria",{provider:I.label,percent:I.totalPercent,tokens:IF(I.usage)||"0",cost:OF(I.usd)||"$0",action:O(X?"usage.overview.collapse":"usage.overview.expand")}),onClick:()=>R(X?null:I.label),className:`min-w-0 text-left p-3 rounded-lg border transition-colors duration-200 ${X?"border-oai-gray-300 dark:border-oai-gray-600 bg-oai-gray-50 dark:bg-oai-gray-800":"border-oai-gray-200 dark:border-oai-gray-700 hover:border-oai-gray-300 dark:hover:border-oai-gray-600"}`,children:[p.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[p.jsx(nu,{provider:I.label,size:15,color:W,className:"text-oai-gray-700 dark:text-oai-gray-300 shrink-0"}),p.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:I.label})]}),p.jsxs("div",{className:"text-lg font-semibold text-oai-black dark:text-oai-white tabular-nums",children:[I.totalPercent,"%"]}),p.jsx("div",{className:"mt-0.5 text-[11px] text-oai-gray-400 dark:text-oai-gray-400 tabular-nums",children:O("usage.overview.model_count",{count:I.models.length})})]},I.label)})}),A&&p.jsx("div",{id:`provider-details-${A}`,role:"region","aria-label":O("usage.overview.model_details_aria",{provider:A}),className:"mt-2",children:z.filter(I=>I.label===A).map(I=>{const V=w_(I.label,0),W=Foe(I),X=[...I.models].sort((F,G)=>(G.share||0)-(F.share||0)),J=W?`${W==="claude"?"Claude":"Codex"} Context Breakdown`:I.label;return p.jsx(zoe,{provider:I,color:V,providerHeading:J,contextSource:W,from:_,to:E,sortedModels:X},I.label)})})]})]})}function zoe({provider:t,color:e,providerHeading:n,contextSource:r,from:i,to:a,sortedModels:s}){const[o,c]=x.useState(!1);return p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-1.5 mb-3",children:[p.jsx(nu,{provider:t.label,size:14,color:e,className:"shrink-0"}),p.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:n}),r&&o&&p.jsx(Ao,{size:12,className:"text-oai-gray-400 dark:text-oai-gray-500 animate-spin shrink-0","aria-label":O("dashboard.context_breakdown.loading_aria")})]}),r?p.jsx("div",{className:"mb-4 pb-4 border-b border-oai-gray-200 dark:border-oai-gray-700",children:p.jsx(Doe,{from:i,to:a,source:r,referenceTotalTokens:t.usage,onLoadingChange:c})}):null,p.jsx("div",{className:"space-y-3",children:s.map(u=>{const f=IF(u.usage),h=OF(u.cost),m=Math.max(0,Math.min(100,Number(u.share)||0));return p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-baseline gap-4 mb-1.5",children:[p.jsx("span",{className:"flex-1 min-w-0 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate",title:u.name,children:u.name}),p.jsx("span",{className:"shrink-0 w-16 text-right text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:f}),p.jsx("span",{className:"shrink-0 w-16 text-right text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:h}),p.jsxs("span",{className:"shrink-0 w-12 text-right text-sm text-oai-black dark:text-oai-white tabular-nums",children:[u.share,"%"]})]}),p.jsx("div",{className:"h-[3px] bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden",role:"progressbar","aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:p.jsx("div",{className:"h-full transition-[width] duration-500 ease-out",style:{width:`${m}%`,backgroundColor:e,opacity:.45}})})]},u.id||u.name)})})]})}function IR(t,e){if(!Array.isArray(t)||t.length===0)return 0;if(t.length===1)return t[0];const n=(t.length-1)*e,r=Math.floor(n),i=Math.ceil(n);if(r===i)return t[r];const a=n-r;return t[r]+(t[i]-t[r])*a}function Voe(t){const e=Array.isArray(t)?t.filter(i=>Number.isFinite(i)&&i>0).sort((i,a)=>i-a):[];if(e.length===0)return{rawMax:0,effectiveMax:1,clippedValues:Array.isArray(t)?t.map(()=>0):[]};const n=e.at(-1)??0;let r=n;if(e.length>=4){const i=IR(e,.25),a=IR(e,.75),s=Math.max(a-i,0),o=a+s*1.5;n>o&&(r=Math.max(o,a,1))}return{rawMax:n,effectiveMax:Math.max(r,1),clippedValues:Array.isArray(t)?t.map(i=>!Number.isFinite(i)||i<=0?0:Math.min(i,Math.max(r,1))):[]}}function Hoe({value:t,displayValue:e,scale:n,index:r,row:i,totalBars:a}){const s=cu(),o=n.effectiveMax>0?e/n.effectiveMax*100:0,c=`${Math.max(o,2)}%`,u=i?.missing,f=i?.future,h=a<=7?"6px":a<=14?"4px":"3px";return p.jsx(Qn.div,{className:"group relative flex-1 self-stretch",initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},transition:{duration:s?0:.3,delay:s?0:.4+r*.008,ease:[.16,1,.3,1]},style:{originY:1},children:p.jsxs("div",{className:"absolute inset-x-0 bottom-0",style:{height:c},children:[p.jsx("div",{"data-trend-bar":"true",className:"h-full w-full cursor-pointer transition-all duration-200 group-hover:brightness-110",style:{minHeight:t>0?"4px":"2px",opacity:u||f?.2:1,borderRadius:`${h} ${h} 0 0`,background:t>0?"#10b981":"var(--oai-gray-100)"},title:`${t.toLocaleString()}`}),p.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-oai-black text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-20",children:t.toLocaleString()})]})})}function Woe({rows:t,from:e,to:n,period:r,timeZoneLabel:i,showTimeZoneLabel:a=!0,className:s=""}){const o=Array.isArray(t)&&t.length?t:[],c=o.map(f=>{if(f?.missing||f?.future)return 0;const h=f?.billable_total_tokens??f?.total_tokens??f?.value;if(h==null)return 0;const m=Number(h);return Number.isFinite(m)?m:0}),u=Voe(c);return p.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5 ${s}`,children:[p.jsxs("div",{className:"mb-3",children:[p.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:O("trend.monitor.label")}),a&&i&&p.jsx("p",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:i})]}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"relative",children:[p.jsx("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none",children:[0,25,50,75,100].map(f=>p.jsx("div",{className:"w-full border-t border-oai-gray-100 dark:border-oai-gray-800",style:{top:`${100-f}%`}},f))}),p.jsx("div",{className:"h-40 flex items-end gap-1 relative z-0",children:c.length>0?c.map((f,h)=>p.jsx(Hoe,{value:f,displayValue:u.clippedValues[h]??0,scale:u,index:h,row:o[h],totalBars:c.length},h)):p.jsx("div",{className:"flex-1 h-full flex items-center justify-center",children:p.jsx("p",{className:"text-sm text-oai-gray-400 dark:text-oai-gray-400",children:"No data yet"})})})]}),e&&n&&p.jsxs("div",{className:"flex justify-between text-xs text-oai-gray-500 dark:text-oai-gray-300 font-medium pt-2 border-t border-oai-gray-100 dark:border-oai-gray-800",children:[p.jsx("span",{children:e}),p.jsx("span",{children:n})]})]})]})}function _o({children:t,delay:e=0,duration:n=.35,y:r=12,className:i="",once:a=!0}){return cu()?p.jsx("div",{className:i,children:t}):p.jsx(Qn.div,{initial:{opacity:0,y:r},animate:{opacity:1,y:0},transition:{duration:n,delay:e,ease:[.16,1,.3,1]},className:i,children:t})}function Goe({children:t,staggerDelay:e=.1,initialDelay:n=0,className:r=""}){return cu()?p.jsx("div",{className:r,children:t}):p.jsx(Qn.div,{initial:"hidden",animate:"visible",variants:{hidden:{},visible:{transition:{staggerChildren:e,delayChildren:n}}},className:r,children:t})}function $oe({children:t,className:e="",y:n=12}){return cu()?p.jsx("div",{className:e,children:t}):p.jsx(Qn.div,{variants:{hidden:{opacity:0,y:n},visible:{opacity:1,y:0,transition:{duration:.35,ease:[.16,1,.3,1]}}},className:e,children:t})}const OR={"idle-living":"idle/living.svg","idle-doze":"idle/doze.svg","idle-follow":"idle/follow.svg","idle-look":"idle/look.svg","idle-yawn":"idle/yawn.svg","idle-collapse":"idle/collapse.svg","working-building":"working/building.svg","working-carrying":"working/carrying.svg","working-conducting":"working/conducting.svg","working-confused":"working/confused.svg","working-debugger":"working/debugger.svg","working-juggling":"working/juggling.svg","working-overheated":"working/overheated.svg","working-pushing":"working/pushing.svg","working-sweeping":"working/sweeping.svg","working-thinking":"working/thinking.svg","working-typing":"working/typing.svg","working-ultrathink":"working/ultrathink.svg","working-wizard":"working/wizard.svg","mini-alert":"mini/alert.svg","mini-crabwalk":"mini/crabwalk.svg","mini-enter":"mini/enter.svg","mini-enter-sleep":"mini/enter-sleep.svg","mini-happy":"mini/happy.svg","mini-idle":"mini/idle.svg","mini-peek":"mini/peek.svg","mini-sleep":"mini/sleep.svg","react-double":"react/double.svg","react-drag":"react/drag.svg","react-left":"react/left.svg","react-right":"react/right.svg","collapse-sleep":"sleep/collapse-sleep.svg",sleeping:"sleep/sleeping.svg",wake:"sleep/wake.svg",disconnected:"status/disconnected.svg",error:"status/error.svg",notification:"status/notification.svg",happy:"happy.svg","static-base":"static-base.svg"},S_=new Map;async function Yoe(t){if(S_.has(t))return S_.get(t);const e=await fetch(`/clawd/${t}`);if(!e.ok)return null;const r=(await e.text()).replace(/<svg([^>]*)>/,(i,a)=>`<svg${a.replace(/\s+width="[^"]*"/g,"").replace(/\s+height="[^"]*"/g,"")} width="100%" height="100%">`);return S_.set(t,r),r}function qoe({state:t="idle-living",size:e=48,className:n=""}){const[r,i]=x.useState(""),a=x.useRef(null),o=Xoe()?"static-base":t,c=OR[o]||OR["static-base"];return x.useEffect(()=>{let u=!1;return Yoe(c).then(f=>{!u&&f&&i(f)}),()=>{u=!0}},[c]),x.useEffect(()=>{const u=a.current?.querySelector("svg");if(u)try{const f=u.getBBox();f.width>0&&f.height>0&&u.setAttribute("viewBox",`${f.x-2} ${f.y-2} ${f.width+4} ${f.height+4}`)}catch{}},[r]),p.jsx("div",{ref:a,className:`clawd-animated ${n}`,style:{width:e,height:e,display:"inline-flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},dangerouslySetInnerHTML:{__html:r}})}function Xoe(){const[t,e]=x.useState(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return x.useEffect(()=>{const n=window.matchMedia("(prefers-reduced-motion: reduce)"),r=i=>e(i.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}function Koe({todayTokens:t=0,isSyncing:e=!1,hasError:n=!1,isDisconnected:r=!1}={}){return x.useMemo(()=>n?"error":r?"disconnected":e?"working-typing":t===0?"sleeping":t<5e4?"idle-living":t<2e5?"idle-look":t<5e5?"working-ultrathink":t<2e6?"working-typing":"working-ultrathink",[t,e,n,r])}const FR="macAppBannerDismissed",Zoe="leaderboardBannerDismissed",Joe="https://github.com/mm7894215/TokenTracker/releases/latest",UR="tokentracker_native_app",Tg=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(UR,"1"),!0):localStorage.getItem(UR)==="1"}catch{return!1}})();function Qoe({todayTokens:t=0,isSyncing:e=!1,enterDelay:n=0}){const{openLoginModal:r}=Cp(),{signedIn:i}=ls(),a=Koe({todayTokens:t,isSyncing:e}),s=Tg?Zoe:FR,[o,c]=x.useState(()=>{try{return localStorage.getItem(s)==="1"?!0:!Tg&&new URLSearchParams(window.location.search).get("from")==="menubar"?(localStorage.setItem(FR,"1"),!0):!1}catch{return!1}}),u=x.useCallback(()=>{c(!0);try{localStorage.setItem(s,"1")}catch{}},[s]);if(o)return null;let f,h,m,g,v,w;Tg&&i?(f="View the Leaderboard",h="Compare your usage globally",m="Leaderboard",g=p.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:p.jsx("path",{d:"M2 8.5V10h8V8.5M6 1.5v6m0 0L3.5 5M6 7.5l2.5-2.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(180 6 6)"})}),v=()=>{window.location.pathname="/leaderboard"}):Tg?(f="Join the Leaderboard",h="Log in to compare your usage with others",m="Log In",g=p.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:p.jsx("path",{d:"M6.5 1.5h3a1 1 0 011 1v7a1 1 0 01-1 1h-3M5 8.5L7.5 6 5 3.5M7.5 6H1.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),v=r):(f="Try the Menu Bar App",h="Always-on stats with Clawd companion",m="Download",g=p.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:p.jsx("path",{d:"M6 2v6m0 0L3.5 5.5M6 8l2.5-2.5M2 10h8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),w=Joe);const b=w?Qn.a:Qn.button,_=w?{href:w,target:"_blank",rel:"noopener noreferrer"}:{onClick:v};return p.jsx(Qn.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,delay:n,ease:[.16,1,.3,1]},className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4",children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:"flex-shrink-0",children:p.jsx(qoe,{state:a,size:56})}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:"text-sm font-medium text-oai-gray-900 dark:text-oai-white",children:f}),p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-0.5",children:h})]}),p.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[p.jsxs(b,{..._,whileHover:{scale:1.03},whileTap:{scale:.97},className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-oai-gray-900 dark:bg-oai-white dark:text-oai-gray-900 rounded-md hover:opacity-90 transition-opacity",children:[m,g]}),p.jsx("button",{onClick:u,className:"p-1 text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-300 transition-colors","aria-label":"Dismiss",children:p.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:p.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})})]})]})})}const jR="widgetOnboardingDismissed",BR="tokentracker_native_app",ele=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(BR,"1"),!0):localStorage.getItem(BR)==="1"}catch{return!1}})();function tle({enterDelay:t=0}){const[e,n]=x.useState(()=>{try{return localStorage.getItem(jR)==="1"}catch{return!1}}),r=x.useCallback(()=>{n(!0);try{localStorage.setItem(jR,"1")}catch{}},[]);return ele?p.jsx(Lp,{initial:!1,children:!e&&p.jsxs(Qn.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-8,transition:{duration:.2,ease:[.4,0,.2,1]}},transition:{duration:.35,delay:t,ease:[.16,1,.3,1]},className:"relative rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4",children:[p.jsx("button",{type:"button",onClick:r,"aria-label":O("dashboard.widgets.dismiss_aria"),className:"absolute top-2.5 right-2.5 z-10 inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-300 dark:focus-visible:ring-oai-gray-600 transition-colors",children:p.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:p.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}),p.jsx("div",{className:"rounded-lg overflow-hidden ring-1 ring-black/5 dark:ring-white/10 shadow-sm",children:p.jsx("img",{src:"/widgets-overview.png",alt:O("dashboard.widgets.title"),width:734,height:552,className:"w-full h-auto block",loading:"lazy",decoding:"async"})}),p.jsxs("div",{className:"mt-4",children:[p.jsx("div",{className:"text-sm font-medium tracking-tight text-oai-gray-900 dark:text-oai-white",children:O("dashboard.widgets.title")}),p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1 leading-snug",children:O("dashboard.widgets.hint")})]})]},"widget-onboarding-card")}):null}function nle(t){const{copy:e,onOpenShare:n,screenshotMode:r,showExpiredGate:i,showAuthGate:a,screenshotTitleLine1:s,screenshotTitleLine2:o,identityDisplayName:c,identityStartDate:u,activeDays:f,identitySubscriptions:h,identityScrambleDurationMs:m,projectUsageEntries:g,projectUsageLimit:v,setProjectUsageLimit:w,topModels:b,signedIn:_,publicMode:E,isLocalMode:M,shouldShowInstall:T,installPrompt:P,handleCopyInstall:A,installCopied:R,installInitCmdDisplay:k,trendRowsForDisplay:N,trendFromForDisplay:B,trendToForDisplay:L,usageFrom:z,usageTo:I,period:V,trendTimeZoneLabel:W,activityHeatmapBlock:X,isCapturing:J,handleShareToX:F,screenshotTwitterButton:G,screenshotTwitterHint:Y,periodsForDisplay:H,setSelectedPeriod:te,customFrom:re,customTo:ue,onCustomRangeApply:ce,customRangeOpen:ee,onCustomRangeOpenChange:le,summaryLabel:ve,summaryValue:Ne,summaryTotalTokensRaw:be,summaryCostValue:qe,summaryConversationsValue:he,rollingUsage:Ue,costInfoEnabled:je,openCostModal:et,costModalOpen:_e,closeCostModal:oe,allowBreakdownToggle:Q,refreshAll:ze,usageLoadingState:Pe,fleetData:De,hasDetailsActual:Le,dailyEmptyPrefix:$,installSyncCmd:U,dailyEmptySuffix:Z,detailsColumns:pe,ariaSortFor:Se,toggleSort:xe,sortIconFor:Ie,pagedDetails:He,dailyBreakdownRows:Ye,dailyBreakdownColumns:ft,dailyBreakdownAriaSortFor:We,dailyBreakdownSortIconFor:Xe,dailyBreakdownDateKey:nt,detailsDateKey:ct,renderDetailDate:Ke,renderDailyBreakdownDate:gt,renderDetailCell:ne,DETAILS_PAGED_PERIODS:Be,detailsPageCount:ke,detailsPage:Ae,setDetailsPage:Ve}=t,ge=null,ut=null,yt=.06,qt=.05,Lt=.11;let _t=0;const wt=()=>Lt+yt*_t++,un=Lt+yt*5;return p.jsxs(p.Fragment,{children:[p.jsx(wre,{bare:!r,hideHeader:r,header:ge,footer:r?null:ut,className:r?"screenshot-mode":"",children:i||a?null:p.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4",children:[p.jsxs("div",{className:"lg:col-span-4 flex flex-col gap-4 min-w-0 order-2 lg:order-1",children:[r?p.jsx("div",{className:"flex items-start justify-between gap-4",children:p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-3xl md:text-4xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:s}),p.jsx("span",{className:"text-2xl md:text-3xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:o})]})}):null,M?p.jsx(Qoe,{todayTokens:be,isSyncing:Pe,enterDelay:wt()}):null,p.jsx(_o,{delay:wt(),children:p.jsx(cie,{title:e("dashboard.identity.title"),subtitle:e("dashboard.identity.subtitle"),period:V,rankLabel:u??e("identity_card.rank_placeholder"),streakDays:f,subscriptions:h,periodConversations:he,rolling:Ue,topModels:b})}),M?p.jsx(tle,{enterDelay:wt()}):null,T?p.jsx(_o,{delay:wt(),children:p.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-3",children:[p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 mb-1.5",children:P}),p.jsxs(Qn.button,{onClick:A,whileHover:{scale:1.01},whileTap:{scale:.99},className:"w-full flex items-center justify-between px-3 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-700 rounded-lg transition-colors",children:[p.jsx("code",{className:"text-xs font-mono text-oai-gray-700 dark:text-oai-gray-300",children:k}),p.jsx(Qn.span,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},className:"text-xs text-oai-brand",children:R?"Copied ✓":"Copy"},R?"copied":"copy")]})]})}):null,X&&p.jsx(_o,{delay:wt(),children:X}),r?null:p.jsx(_o,{delay:wt(),children:p.jsx(Woe,{rows:N,from:B,to:L,period:V,timeZoneLabel:W,showTimeZoneLabel:!1})}),r?p.jsxs("div",{className:"mt-4 flex flex-col items-center gap-2","data-screenshot-exclude":"true",style:J?{display:"none"}:void 0,children:[p.jsx(Ui,{type:"button",onClick:F,variant:"primary",size:"lg",disabled:J,children:G}),p.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300",children:Y})]}):null]}),p.jsxs("div",{className:"lg:col-span-8 flex flex-col gap-4 min-w-0 order-1 lg:order-2",children:[p.jsx(_o,{delay:qt,children:p.jsx(Boe,{period:V,periods:H,onPeriodChange:te,summaryLabel:ve,summaryValue:Ne,summaryCostValue:qe,onCostInfo:je?et:null,fleetData:De,onRefresh:r?null:ze,loading:Pe,onOpenShare:r?null:n,customFrom:re,customTo:ue,onCustomRangeApply:ce,customRangeOpen:ee,onCustomRangeOpenChange:le,from:z,to:I})}),r?null:p.jsx(_o,{delay:un,children:p.jsx(oie,{projectEntries:g,projectLimit:v,onProjectLimitChange:w,copy:e,hasDetailsActual:Le,dailyEmptyPrefix:$,installSyncCmd:U,dailyEmptySuffix:Z,detailsColumns:pe,ariaSortFor:Se,toggleSort:xe,sortIconFor:Ie,pagedDetails:He,dailyBreakdownRows:Ye,dailyBreakdownColumns:ft,dailyBreakdownAriaSortFor:We,dailyBreakdownSortIconFor:Xe,dailyBreakdownDateKey:nt,detailsDateKey:ct,renderDetailDate:Ke,renderDailyBreakdownDate:gt,renderDetailCell:ne,DETAILS_PAGED_PERIODS:Be,period:V,detailsPageCount:ke,detailsPage:Ae,setDetailsPage:Ve})})]})]})}),p.jsx(sie,{isOpen:_e,onClose:oe,fleetData:De})]})}function FF(){return typeof window>"u"?!1:!!window?.webkit?.messageHandlers?.nativeBridge}const Ic=new Map,Oc=new Map;function UF(){typeof window>"u"||window.__tokentrackerNativeSaveListener||(window.__tokentrackerNativeSaveListener=!0,window.addEventListener("native:saveImageResult",t=>{const e=t?.detail||{},n=typeof e.requestId=="string"?e.requestId:null;if(!n||!Ic.has(n))return;const r=Ic.get(n);Ic.delete(n),r({ok:!!e.ok,path:typeof e.path=="string"?e.path:void 0,error:typeof e.error=="string"?e.error:void 0})}),window.addEventListener("native:copyImageResult",t=>{const e=t?.detail||{},n=typeof e.requestId=="string"?e.requestId:null;if(!n||!Oc.has(n))return;const r=Oc.get(n);Oc.delete(n),r({ok:!!e.ok,error:typeof e.error=="string"?e.error:void 0})}))}async function rle(t){if(!FF()||typeof window>"u")return{ok:!1,error:"native bridge unavailable"};const e=window?.webkit?.messageHandlers?.nativeBridge;if(!e)return{ok:!1,error:"native bridge unavailable"};UF();const n=`copy_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return new Promise(r=>{const i=window.setTimeout(()=>{Oc.has(n)&&(Oc.delete(n),r({ok:!1,error:"timeout"}))},8e3);Oc.set(n,a=>{window.clearTimeout(i),r(a)});try{e.postMessage({type:"action",name:"copyImageToClipboard",requestId:n,dataUrl:t})}catch(a){Oc.delete(n),window.clearTimeout(i),r({ok:!1,error:a?.message||String(a)})}})}async function zR(t,e){if(!FF()||typeof window>"u")return{ok:!1,error:"native bridge unavailable"};const n=window?.webkit?.messageHandlers?.nativeBridge;if(!n)return{ok:!1,error:"native bridge unavailable"};UF();const r=`save_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return new Promise(i=>{const a=window.setTimeout(()=>{Ic.has(r)&&(Ic.delete(r),i({ok:!1,error:"timeout"}))},8e3);Ic.set(r,s=>{window.clearTimeout(a),i(s)});try{n.postMessage({type:"action",name:"saveImageToDownloads",requestId:r,filename:e,dataUrl:t})}catch(s){Ic.delete(r),window.clearTimeout(a),i({ok:!1,error:s?.message||String(s)})}})}const jF=1200,BF=1630,zF={broadsheet:{width:1200,height:1630},"annual-report":{width:1080,height:1865}},ile="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter+Tight:wght@400;500;600;700&family=IBM+Plex+Serif:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&family=Space+Grotesk:wght@500;600;700&display=swap";let k_=!1;function ale(){if(typeof document>"u"||k_)return;if(document.querySelector('link[data-share-card-fonts="true"]')){k_=!0;return}const e=document.createElement("link");e.rel="stylesheet",e.href=ile,e.dataset.shareCardFonts="true",e.crossOrigin="anonymous",document.head.appendChild(e),k_=!0}async function sle(){if(typeof document>"u")return;const t=document.fonts;if(!(!t||typeof t.ready?.then!="function"))try{await t.ready}catch{}}async function ole(t,e={}){if(typeof window>"u"||!t)return null;ale(),await sle(),await new Promise(c=>requestAnimationFrame(()=>c(null)));const{toBlob:n,toPng:r}=await t4(async()=>{const{toBlob:c,toPng:u}=await import("./index-BeoRn2gJ.js");return{toBlob:c,toPng:u}},[]),i=e.pixelRatio??2,a=t.offsetWidth||jF,s=t.offsetHeight||BF,o={pixelRatio:i,cacheBust:!0,width:a,height:s,style:{width:`${a}px`,height:`${s}px`},skipFonts:!1,filter:c=>!(c instanceof HTMLElement)||c.dataset?.screenshotExclude!=="true"};try{const c=await n(t,o);if(c)return c}catch{}try{const c=await r(t,o);return c?await(await fetch(c)).blob():null}catch{return null}}async function E_(t){return new Promise(e=>{const n=new FileReader;n.onload=()=>{const r=typeof n.result=="string"?n.result:null;e(r)},n.onerror=()=>e(null),n.readAsDataURL(t)})}function VR(t,e){if(typeof window>"u"||!t)return!1;try{const n=URL.createObjectURL(t),r=document.createElement("a");return r.href=n,r.download=e,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3),!0}catch{return!1}}function I1(t){const e=ti(t);return Number.isFinite(e)?e:0}function lle(t){return t?I1(t.billable_total_tokens??t.total_tokens):0}function cle(t){const e=Array.isArray(t?.weeks)?t.weeks:[];if(!e.length)return{weeks:[],totalDays:0,activeDays:0};let n=0,r=0;return{weeks:e.map(a=>(Array.isArray(a)?a:[]).slice(0,7).map(o=>{const c=!!o?.future,u=Number.isFinite(o?.level)?Math.max(0,Math.min(4,Math.round(o.level))):0;o?.day&&!c&&(n+=1,u>0&&(r+=1));const f=o?.billable_total_tokens??o?.total_tokens??o?.value??0,h=Number.isFinite(f)?Math.max(0,f):0;return{day:typeof o?.day=="string"?o.day:"",level:u,value:h,future:c}})),totalDays:n,activeDays:r}}function ule(t){const{handle:e,startDate:n,activeDays:r,summary:i,topModels:a,rank:s,period:o,periodFrom:c,periodTo:u,heatmap:f,capturedAt:h}=t,m=lle(i),g=I1(i?.total_cost_usd),v=Array.isArray(a)?a.slice(0,3).map(b=>({id:b?.id??null,name:typeof b?.name=="string"&&b.name?b.name:"—",tokens:I1(b?.tokens),percent:typeof b?.percent=="string"&&b.percent?b.percent:"0.0"})):[],w=cle(f);return{handle:e||"—",startDate:n||null,activeDays:Number.isFinite(r)&&r>0?Math.floor(r):0,totalTokens:m,totalCost:g,period:o,periodFrom:c,periodTo:u,topModels:v,rank:typeof s=="number"&&Number.isFinite(s)&&s>0?Math.floor(s):null,heatmapWeeks:w.weeks,heatmapTotalDays:w.totalDays,heatmapActiveDays:w.activeDays,capturedAt:h||new Date().toISOString()}}const dle=["share.month_short.jan","share.month_short.feb","share.month_short.mar","share.month_short.apr","share.month_short.may","share.month_short.jun","share.month_short.jul","share.month_short.aug","share.month_short.sep","share.month_short.oct","share.month_short.nov","share.month_short.dec"];function fle(t){const e=dle[t];return e?O(e):"—"}function VF(t,e){return O("share.date.month_year",{month:fle(t),year:e})}function hle(t){if(!t)return"—";const e=t.split("-");if(e.length!==3)return t;const[n,r]=e,i=Number(r)-1;return i<0||i>11?t:VF(i,n)}function ple(t){if(t.period==="total")return O("share.issue.all_time");if(t.period==="day"&&t.periodTo)return t.periodTo.replace(/-/g,".");if(t.period==="custom"&&t.periodFrom&&t.periodTo)return`${t.periodFrom.replace(/-/g,".")} — ${t.periodTo.replace(/-/g,".")}`;if(t.periodTo){const e=new Date(`${t.periodTo}T00:00:00Z`);if(!Number.isNaN(e.getTime()))return VF(e.getUTCMonth(),e.getUTCFullYear())}return O(`usage.period.${t.period}`)}function O1(t){return Number.isFinite(t)?Math.round(t).toLocaleString("en-US"):"—"}function HF(t){return!Number.isFinite(t)||t<=0?"$0.00":t>=1e3?`$${Math.round(t).toLocaleString("en-US")}`:`$${t.toFixed(2)}`}function mle(t){const e=t.topModels[0];if(e){const n=parseFloat(e.percent);return Number.isFinite(n)&&n>=60?O("share.hook.top_loyal",{percent:Math.round(n),name:e.name}):t.activeDays>=60?O("share.hook.days_record",{days:t.activeDays}):Number.isFinite(n)&&n>=30?O("share.hook.top_led",{name:e.name,percent:Math.round(n)}):t.topModels.length>1?O("share.hook.multi_models",{count:t.topModels.length,days:t.activeDays}):O("share.hook.days_with_model",{days:t.activeDays,name:e.name})}return t.activeDays>0?O("share.hook.days_record",{days:t.activeDays}):O("share.hook.new_chapter")}function gle(t,e){const n=(t||"").length;if(n<=e.baseChars)return e.baseSize;const r=e.baseSize-(n-e.baseChars)*e.shrinkPerChar;return Math.max(e.minSize,r)}function yle(t){if(!t||t.future)return null;const e=typeof t.level=="number"?t.level:0;return e<0?0:e>4?4:Math.round(e)}function vle({weeks:t,palette:e,width:n,gap:r=3,radius:i=2,emptyColor:a}){if(!Array.isArray(t)||t.length===0||!n||n<=0)return null;const s=e||["#eee","#ccc","#999","#666","#333"],o=a||s[0],c=t.length,u=(c-1)*r,f=Math.max(4,(n-u)/c),h=7*f+6*r;return p.jsx("svg",{width:n,height:h,viewBox:`0 0 ${n} ${h}`,xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,style:{display:"block"},children:t.map((m,g)=>(Array.isArray(m)?m:[]).map((w,b)=>{if(b>=7)return null;const _=yle(w),E=g*(f+r),M=b*(f+r),T=_===null?o:s[_];return p.jsx("rect",{x:E,y:M,width:f,height:f,rx:i,ry:i,fill:T},`${g}-${b}`)}))})}const xle="oklch(0.97 0.01 85)",Ji="oklch(0.18 0.02 85)",ll="oklch(0.38 0.015 85)",HR="oklch(0.55 0.012 85)",mc="oklch(0.55 0.22 25)",gc='"Instrument Serif", "Times New Roman", Georgia, serif',ble='"Inter Tight", "Helvetica Neue", Arial, sans-serif',_le=["oklch(0.93 0.013 80)","oklch(0.87 0.04 55)","oklch(0.78 0.09 45)","oklch(0.67 0.16 35)","oklch(0.55 0.22 25)"];function WF({data:t}){const e=ple(t),n=O1(t.totalTokens),r=HF(t.totalCost),i=hle(t.startDate),a=gle(n,{baseSize:188,baseChars:9,shrinkPerChar:14,minSize:104}),s=mle(t),o=Array.isArray(t.heatmapWeeks)&&t.heatmapWeeks.length>0;return p.jsxs("div",{style:{width:"100%",height:"100%",background:xle,color:Ji,fontFamily:ble,padding:"80px 88px 68px 88px",boxSizing:"border-box",display:"flex",flexDirection:"column",position:"relative"},children:[p.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:24,paddingBottom:14,borderBottom:`1px solid ${HR}`},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,fontSize:14,fontWeight:500,letterSpacing:"0.22em",textTransform:"uppercase",color:Ji},children:[p.jsx("div",{style:{width:10,height:10,borderRadius:"50%",background:mc}}),"The Token Tracker"]}),p.jsxs("div",{style:{fontSize:12,letterSpacing:"0.22em",textTransform:"uppercase",color:ll,textAlign:"right"},children:[O("share.card.broadsheet.issue")," № ",e]})]}),p.jsxs("div",{style:{marginTop:24,display:"flex",justifyContent:"space-between",alignItems:"flex-end",gap:24},children:[p.jsxs("div",{children:[p.jsx("div",{style:{fontSize:12,letterSpacing:"0.2em",textTransform:"uppercase",color:ll,marginBottom:6},children:O("share.card.broadsheet.by")}),p.jsx("div",{style:{fontFamily:gc,fontSize:52,fontStyle:"italic",lineHeight:1,color:Ji,letterSpacing:"-0.01em"},children:t.handle})]}),p.jsxs("div",{style:{fontSize:12,letterSpacing:"0.18em",textTransform:"uppercase",color:ll,textAlign:"right",lineHeight:1.6},children:[O("share.card.broadsheet.tracked_since"),p.jsx("br",{}),p.jsx("span",{style:{color:Ji},children:i})]})]}),p.jsxs("div",{style:{marginTop:40,display:"flex",flexDirection:"column"},children:[p.jsx("div",{style:{fontSize:13,letterSpacing:"0.3em",textTransform:"uppercase",color:mc,marginBottom:10},children:O("share.card.broadsheet.total_tokens")}),p.jsx("div",{style:{fontFamily:gc,fontSize:a,fontWeight:400,lineHeight:.86,letterSpacing:"-0.032em",color:Ji,fontFeatureSettings:'"lnum" 1, "tnum" 1',whiteSpace:"nowrap",overflow:"hidden"},children:n}),p.jsxs("div",{style:{marginTop:14,fontFamily:gc,fontStyle:"italic",fontSize:34,lineHeight:1.15,color:Ji,letterSpacing:"-0.005em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:["“",s,"”"]}),p.jsx("div",{style:{marginTop:14,height:1,background:mc,width:"100%"}}),p.jsxs("div",{style:{marginTop:10,display:"flex",justifyContent:"space-between",fontSize:13,letterSpacing:"0.16em",textTransform:"uppercase",color:ll},children:[p.jsxs("span",{children:[O("share.card.broadsheet.estimated_spend")," · ",r]}),p.jsx("span",{children:O("share.card.broadsheet.billable_days",{days:t.activeDays})})]})]}),o?p.jsxs("section",{style:{marginTop:40},children:[p.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:12},children:[p.jsx("div",{style:{fontSize:12,letterSpacing:"0.3em",textTransform:"uppercase",color:Ji,fontWeight:600},children:O("share.card.broadsheet.heatmap_title")}),p.jsx("div",{style:{fontSize:11,letterSpacing:"0.18em",textTransform:"uppercase",color:ll},children:O("share.card.broadsheet.heatmap_days_on_record",{active:t.heatmapActiveDays,total:t.heatmapTotalDays})})]}),p.jsx(vle,{weeks:t.heatmapWeeks,palette:_le,width:1024,gap:3,radius:2})]}):null,p.jsxs("section",{style:{marginTop:30,flex:1},children:[p.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",borderBottom:`1px solid ${Ji}`,paddingBottom:10,marginBottom:6},children:[p.jsx("div",{style:{fontSize:12,letterSpacing:"0.3em",textTransform:"uppercase",color:Ji,fontWeight:600},children:O("share.card.broadsheet.roster_title")}),p.jsx("div",{style:{fontSize:11,letterSpacing:"0.18em",textTransform:"uppercase",color:ll},children:O("share.card.broadsheet.roster_subtitle")})]}),t.topModels.length===0?p.jsx("div",{style:{fontFamily:gc,fontStyle:"italic",fontSize:26,color:ll,paddingTop:14},children:O("share.card.broadsheet.empty")}):t.topModels.map((c,u)=>p.jsxs("div",{style:{display:"grid",gridTemplateColumns:"52px 1fr auto 68px",alignItems:"baseline",gap:16,padding:"13px 0",borderBottom:`1px solid ${HR}`},children:[p.jsx("div",{style:{fontFamily:gc,fontSize:34,fontStyle:"italic",color:mc,lineHeight:1},children:String(u+1).padStart(2,"0")}),p.jsx("div",{style:{fontFamily:gc,fontSize:32,color:Ji,lineHeight:1.1,letterSpacing:"-0.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c.name}),p.jsx("div",{style:{fontFamily:gc,fontSize:28,color:Ji,fontFeatureSettings:'"lnum" 1, "tnum" 1',whiteSpace:"nowrap"},children:O1(c.tokens)}),p.jsxs("div",{style:{fontSize:13,letterSpacing:"0.1em",color:ll,textAlign:"right",fontFeatureSettings:'"tnum" 1'},children:[c.percent,"%"]})]},c.id||c.name))]}),p.jsxs("footer",{style:{marginTop:18,paddingTop:12,borderTop:`1px solid ${Ji}`,display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:12,letterSpacing:"0.22em",textTransform:"uppercase",color:Ji},children:[p.jsxs("div",{style:{display:"flex",gap:28},children:[p.jsxs("span",{children:[O("share.card.broadsheet.global_rank")," ",p.jsxs("span",{style:{color:mc},children:["№ ",t.rank!=null?t.rank:"—"]})]}),p.jsxs("span",{children:[O("share.card.broadsheet.active_days")," ",p.jsx("span",{style:{color:mc},children:O("share.card.broadsheet.days_count",{days:t.activeDays})})]})]}),p.jsxs("div",{children:[O("share.card.broadsheet.track_yours")," ",p.jsx("span",{style:{color:mc},children:"→ tokentracker.cc"})]})]})]})}const wle=zF["annual-report"].width,Sle="#0a0820",cl="#ffffffee",Ec="rgba(255,255,255,0.45)",M_="#a78bfa",kle={background:"rgba(20,15,50,0.38)",backdropFilter:"blur(40px)",WebkitBackdropFilter:"blur(40px)",border:"1px solid rgba(255,255,255,0.05)",boxShadow:["0 39px 56px -36px rgba(255,255,255,0.10) inset","0 7px 11px -4px rgba(255,255,255,0.06) inset","0 -82px 68px -64px rgba(101,67,149,0.08) inset","0 98px 100px -48px rgba(208,171,255,0.06) inset","0 4px 18px 0 rgba(156,146,215,0.06) inset","0 1px 40px 0 rgba(228,222,255,0.04) inset"].join(", ")},Cg={background:"rgba(20,15,50,0.38)",backdropFilter:"blur(32px)",WebkitBackdropFilter:"blur(32px)",border:"1px solid rgba(255,255,255,0.06)",boxShadow:"0 1px 8px 0 rgba(228,222,255,0.06) inset"},F1='"Space Grotesk", "Inter Tight", sans-serif',T_='"Inter Tight", sans-serif',Ele="rgba(255,255,255,0.06)",GF=[Ele,"#4a3d8f","#6b5cbe","#9060e0","#d946ef"],$F=48,YF=28,vy=4,qF=20,Mle=wle-$F*2-YF*2,Tle=(Mle-qF*2)/3,U1=Math.min(Math.floor((Tle-vy*6)/7),40),Cle=U1*7+vy*6;function Ale(t){if(!Array.isArray(t))return t;const e=[];for(const o of t)if(Array.isArray(o))for(const c of o)c?.day&&!c.future&&c.value>0&&e.push(c.value);if(!e.length)return t;e.sort((o,c)=>o-c);const n=o=>{const c=e.length,u=(c-1)*o,f=Math.floor(u);return Math.round((e[f]??0)+((e[Math.min(c-1,f+1)]??0)-(e[f]??0))*(u-f))},r=n(.5),i=n(.75),a=n(.9),s=o=>!o||o<=0?0:o<=r?1:o<=i?2:o<=a?3:4;return t.map(o=>Array.isArray(o)?o.map(c=>c?.day&&!c.future&&typeof c.value=="number"?{...c,level:s(c.value)}:c):o)}function Ple(t){if(!Array.isArray(t))return[];const e={},n=Ale(t);for(const r of n)if(Array.isArray(r))for(const i of r){if(!i?.day||i.future)continue;const a=i.day.split("-");if(a.length<2)continue;const s=`${a[0]}-${a[1]}`;(e[s]??=[]).push(i)}return Object.entries(e).sort(([r],[i])=>r.localeCompare(i)).slice(-12).map(([r,i])=>({month:parseInt(r.split("-")[1],10),cells:i}))}function Rle(t){if(!t.length)return[];const e=[...t].sort((s,o)=>s.day.localeCompare(o.day));let n=new Date(`${e[0].day}T00:00:00Z`).getUTCDay();const r=Array(n).fill(null).concat(e),i=[];for(let s=0;s<r.length;s+=7)i.push(r.slice(s,s+7));const a=i[i.length-1];for(;a&&a.length<7;)a.push(null);return i.slice(0,6)}const Nle=["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Dle(t){if(!Array.isArray(t))return 0;const e=[];for(const i of t)if(Array.isArray(i))for(const a of i)a?.day&&!a.future&&e.push(a);e.sort((i,a)=>i.day.localeCompare(a.day));let n=0,r=0;for(const i of e)(i.level||0)>0?(r++,r>n&&(n=r)):r=0;return n}function WR(t){const[e,n]=x.useState(null);return x.useEffect(()=>{if(!t){n(null);return}let r=!1;const i=new Image;return i.crossOrigin="anonymous",i.onload=()=>{if(!r)try{const a=document.createElement("canvas");a.width=i.naturalWidth,a.height=i.naturalHeight,a.getContext("2d").drawImage(i,0,0),n(a.toDataURL("image/png"))}catch{n(null)}},i.onerror=()=>{r||n(null)},i.src=t,()=>{r=!0}},[t]),e}function Lle({data:t}){const e=Rle(t.cells);return p.jsxs("div",{children:[p.jsx("div",{style:{fontSize:16,fontWeight:600,color:Ec,fontFamily:F1,marginBottom:4},children:Nle[t.month]}),p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:vy},children:e.map((n,r)=>p.jsx("div",{style:{display:"flex",gap:vy},children:n.map((i,a)=>{const s=i?Math.min(4,Math.max(0,i.level||0)):-1;return p.jsx("div",{style:{width:U1,height:U1,borderRadius:4,background:s<0?"transparent":GF[s]}},a)})},r))})]})}function Ile({data:t}){const e=Ple(t.heatmapWeeks),n=Dle(t.heatmapWeeks),r=t.topModels[0],i=t.avatarUrl||null,a=WR(i),s=WR("/neon_bg.png"),o=(t.handle||"?")[0].toUpperCase(),c=16;return p.jsxs("div",{style:{width:"100%",height:"100%",background:Sle,fontFamily:F1,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[p.jsx("img",{src:s||"/neon_bg.png",alt:"",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none"}}),p.jsxs("div",{style:{position:"relative",zIndex:1,display:"flex",flexDirection:"column",height:"100%",padding:$F,boxSizing:"border-box"},children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:c*3},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:64,height:64,style:{width:64,height:64,borderRadius:16,display:"block"}}),p.jsxs("div",{children:[p.jsx("div",{style:{fontSize:20,fontWeight:500,color:Ec,lineHeight:1.2},children:"Token Tracker"}),p.jsx("div",{style:{fontSize:36,fontWeight:700,lineHeight:1.15,color:cl},children:O("share.card.annual.report_title")})]})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsx("div",{style:{width:48,height:48,borderRadius:"50%",background:"linear-gradient(135deg,#4c1d95,#7c3aed)",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid rgba(255,255,255,0.15)",overflow:"hidden",flexShrink:0},children:a?p.jsx("img",{src:a,alt:"",width:48,height:48,style:{width:48,height:48,objectFit:"cover",display:"block"},crossOrigin:"anonymous",referrerPolicy:"no-referrer"}):p.jsx("span",{style:{fontSize:20,fontWeight:700,color:cl},children:o})}),p.jsx("div",{style:{fontSize:32,fontWeight:700,color:cl},children:t.handle})]})]}),p.jsxs("div",{style:{...kle,borderRadius:22,padding:YF,marginBottom:c},children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:14,color:Ec},children:[p.jsx("span",{children:O("share.card.annual.less")}),GF.map((u,f)=>p.jsx("div",{style:{width:16,height:16,borderRadius:3,background:u}},f)),p.jsx("span",{children:O("share.card.annual.more")})]}),p.jsx("div",{style:{fontSize:16,fontWeight:700,letterSpacing:"0.14em",color:"rgba(255,255,255,0.22)",textTransform:"uppercase"},children:O("share.card.annual.heatmap_title")})]}),p.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(3,${Cle}px)`,gap:`8px ${qF}px`,justifyContent:"center"},children:e.map(u=>p.jsx(Lle,{data:u},u.month))})]}),p.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:c,marginBottom:c},children:[p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"28px 16px",textAlign:"center"},children:[p.jsx("div",{style:{fontFamily:T_,fontSize:52,fontWeight:700,color:cl,letterSpacing:"-0.02em",lineHeight:1},children:O1(t.totalTokens)}),p.jsx("div",{style:{fontSize:22,color:Ec,marginTop:12},children:O("share.card.annual.total_tokens")})]}),p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"28px 16px",textAlign:"center"},children:[p.jsx("div",{style:{fontFamily:T_,fontSize:52,fontWeight:700,color:cl,letterSpacing:"-0.02em",lineHeight:1},children:HF(t.totalCost)}),p.jsx("div",{style:{fontSize:22,color:Ec,marginTop:12},children:O("share.card.annual.estimated_cost")})]})]}),p.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:c},children:[p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"18px 24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:M_,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"M12 2v4m0 12v4M4.93 4.93l2.83 2.83m8.48 8.48 2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48 2.83-2.83"}),p.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),p.jsx("span",{style:{fontSize:20,color:Ec},children:O("share.card.annual.longest_streak")})]}),p.jsx("span",{style:{fontFamily:T_,fontSize:28,fontWeight:700,color:cl},children:O("share.card.annual.days_count",{days:n})})]}),p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"18px 24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:M_,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),p.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),p.jsx("span",{style:{fontSize:20,color:Ec},children:O("share.card.annual.top_model")})]}),p.jsx("span",{style:{fontFamily:F1,fontSize:28,fontWeight:700,color:cl},children:r?r.name:"—"})]})]}),p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"auto"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:44,height:44,style:{width:44,height:44,borderRadius:8,display:"block"}}),p.jsx("span",{style:{fontSize:22,fontWeight:600,color:cl},children:"Token Tracker"})]}),p.jsx("span",{style:{fontSize:22,fontWeight:600,color:M_},children:"tokentracker.cc"})]})]})]})}const XF=[{id:"annual-report",labelKey:"share.variant.neon"},{id:"broadsheet",labelKey:"share.variant.broadsheet"}],Ole={broadsheet:WF,"annual-report":Ile};function KF(t){return zF[t]||{width:jF,height:BF}}function Fle(t){const e=XF.find(n=>n.id===t);return e?.labelKey?O(e.labelKey):t}const GR=x.forwardRef(function({data:e,variant:n},r){const i=Ole[n]||WF,{width:a,height:s}=KF(n);return p.jsx("div",{ref:r,"data-share-card":"true",style:{width:a,height:s,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:p.jsx(i,{data:e})})});function Ag(){return typeof window>"u"?!1:!!window?.webkit?.messageHandlers?.nativeBridge}const Ule=440;function jle(){const[t,e]=x.useState(null),n=x.useRef(null),r=x.useCallback((i,a="info")=>{n.current&&window.clearTimeout(n.current),e({id:Date.now(),kind:a,text:i}),n.current=window.setTimeout(()=>e(null),2800)},[]);return x.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{toast:t,push:r}}function C_({onClick:t,disabled:e,children:n,emphasis:r,ariaLabel:i}){return p.jsx("button",{type:"button",onClick:t,disabled:e,"aria-label":i,className:["group relative flex items-center justify-between gap-3 w-full px-4 py-3 text-left","rounded-lg border transition-colors",r?"border-oai-black dark:border-oai-white bg-oai-black dark:bg-oai-white text-oai-white dark:text-oai-black hover:opacity-90":"border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600",e?"opacity-60 cursor-not-allowed":"cursor-pointer"].join(" "),children:n})}function Ble({open:t,onClose:e,data:n,twitterText:r}){const[i,a]=x.useState(null),[s,o]=x.useState(""),[c,u]=x.useState("annual-report"),f=x.useRef(null),{toast:h,push:m}=jle(),g=ls(),v=x.useMemo(()=>{const k=g?.user;if(!k||typeof k!="object")return null;const N=k.user_metadata||{},B=k.profile||{},L=N.avatar_url||N.picture||B.avatar_url||k.avatar_url;return typeof L=="string"&&L.trim()?L.trim():null},[g?.user]);x.useEffect(()=>{t&&(a(null),o(n?.handle||""))},[t,n?.handle]);const w=n&&{...n,handle:s||n.handle,avatarUrl:v},{width:b,height:_}=KF(c),E=Ule/b;x.useEffect(()=>{if(!t)return;const k=N=>{N.key==="Escape"&&e?.()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[t,e]);const M=x.useCallback(async()=>{const k=f.current;if(!k)return null;try{return await ole(k)}catch(N){return console.warn("[share] capture failed",N),null}},[]),T=x.useCallback(async()=>{if(i)return;a("copy");const k=await M();if(!k){m(O("share.toast.failed"),"error"),a(null);return}let N=!1;if(Ag()){const B=await E_(k);B&&(N=(await rle(B)).ok)}else N=await Vw(k);m(O(N?"share.toast.copied":"share.toast.failed"),N?"success":"error"),a(null)},[i,M,m]),P=x.useCallback(()=>`tokentracker-share-${Date.now()}.png`,[]),A=x.useCallback(async()=>{if(i)return;a("download");const k=await M();if(!k){m(O("share.toast.failed"),"error"),a(null);return}if(Ag()){const B=await E_(k);if(B&&(await zR(B,P())).ok){m(O("share.toast.downloaded"),"success"),a(null);return}}const N=VR(k,P());m(O(N?"share.toast.downloaded":"share.toast.failed"),N?"success":"error"),a(null)},[i,M,P,m]),R=x.useCallback(async()=>{if(i)return;a("x");const k=await M();if(!k){m(O("share.toast.failed"),"error"),a(null);return}if(Ag()){const B=await E_(k);B&&(await zR(B,P()),m(O("share.toast.downloaded"),"success"))}else await Vw(k)?m(O("share.toast.copied"),"success"):VR(k,P());const N=new URL("https://twitter.com/intent/tweet");if(r&&N.searchParams.set("text",r),Ag())try{window.webkit?.messageHandlers?.nativeBridge?.postMessage({type:"action",name:"openURL",value:N.toString()})}catch{window.open(N.toString(),"_blank","noopener,noreferrer")}else window.open(N.toString(),"_blank","noopener,noreferrer");a(null)},[i,M,m,r,P]);return t?p.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":O("share.modal.title"),"data-screenshot-exclude":"true",className:"fixed inset-0 z-[9999] flex items-center justify-center p-4 sm:p-6",style:{background:"rgba(10,10,10,0.72)"},onClick:k=>{k.target===k.currentTarget&&e?.()},children:[p.jsx("div",{"aria-hidden":!0,style:{position:"fixed",left:0,top:0,width:b,height:_,pointerEvents:"none",opacity:0,zIndex:-1,clip:"rect(0,0,0,0)",overflow:"hidden"},children:p.jsx(GR,{ref:f,data:w,variant:c})}),p.jsxs(Qn.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:12},transition:{duration:.18,ease:[.2,.8,.2,1]},className:"relative w-full max-w-[1040px] max-h-[92vh] overflow-hidden rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-black shadow-oai-lg",children:[p.jsxs("div",{className:"flex flex-col lg:flex-row max-h-[92vh]",children:[p.jsx("div",{className:"flex-1 min-w-0 p-4 sm:p-7 bg-oai-gray-50 dark:bg-oai-gray-950 flex items-center justify-center overflow-auto",children:p.jsxs("div",{style:{width:b*E,height:_*E,flexShrink:0,position:"relative"},className:"rounded-xl overflow-hidden shadow-oai-md ring-1 ring-black/5",children:[i?p.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-white/70 dark:bg-black/50",children:p.jsxs("svg",{className:"animate-spin h-6 w-6 text-oai-gray-500",viewBox:"0 0 24 24",fill:"none",children:[p.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),p.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}):null,p.jsx("div",{style:{width:b,height:_,transform:`scale(${E})`,transformOrigin:"top left"},children:p.jsx(GR,{data:w,variant:c})})]})}),p.jsxs("div",{className:"w-full lg:w-[340px] flex-shrink-0 border-t lg:border-t-0 lg:border-l border-oai-gray-200 dark:border-oai-gray-800 p-5 sm:p-6 flex flex-col gap-5 overflow-y-auto",children:[p.jsxs("div",{className:"flex items-start justify-between gap-2",children:[p.jsxs("div",{children:[p.jsx("h2",{className:"text-lg font-semibold text-oai-black dark:text-oai-white",children:O("share.modal.title")}),p.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O("share.modal.subtitle")})]}),p.jsx("button",{type:"button",onClick:e,"aria-label":O("share.modal.close"),className:"p-1.5 -mt-1 -mr-1 rounded-md text-oai-gray-500 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:p.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),p.jsxs("div",{children:[p.jsx("label",{htmlFor:"share-handle",className:"text-[11px] tracking-[0.18em] uppercase text-oai-gray-500 dark:text-oai-gray-400 mb-1.5 block",children:O("share.modal.name_label")}),p.jsx("input",{id:"share-handle",type:"text",value:s,onChange:k=>o(k.target.value),placeholder:O("share.modal.name_placeholder"),className:"w-full px-3 py-2 text-sm rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white placeholder:text-oai-gray-400 dark:placeholder:text-oai-gray-600 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-oai-brand transition-colors"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"text-[11px] tracking-[0.18em] uppercase text-oai-gray-500 dark:text-oai-gray-400 mb-1.5 block",children:O("share.modal.style_label")}),p.jsx("div",{className:"flex gap-2",children:XF.map(k=>p.jsx("button",{type:"button",onClick:()=>u(k.id),className:["flex-1 px-3 py-2 text-sm rounded-lg border transition-colors",c===k.id?"border-oai-black dark:border-oai-white bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white font-medium":"border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-gray-500 dark:text-oai-gray-400 hover:border-oai-gray-400 dark:hover:border-oai-gray-600"].join(" "),children:Fle(k.id)},k.id))})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[p.jsxs(C_,{onClick:R,disabled:!!i,emphasis:!0,children:[p.jsxs("span",{className:"flex items-center gap-3",children:[p.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:p.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),p.jsx("span",{className:"font-medium text-sm",children:O("share.modal.action.x")})]}),p.jsx("span",{className:"text-[11px] opacity-70",children:O(i==="x"?"share.toast.working":"share.modal.hint.x")})]}),p.jsxs(C_,{onClick:A,disabled:!!i,children:[p.jsxs("span",{className:"flex items-center gap-3",children:[p.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[p.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),p.jsx("polyline",{points:"7 10 12 15 17 10"}),p.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),p.jsx("span",{className:"font-medium text-sm",children:O("share.modal.action.download")})]}),p.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:"PNG"})]}),p.jsxs(C_,{onClick:T,disabled:!!i,children:[p.jsxs("span",{className:"flex items-center gap-3",children:[p.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[p.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),p.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),p.jsx("span",{className:"font-medium text-sm",children:O("share.modal.action.copy")})]}),p.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:O("share.modal.hint.copy")})]})]}),p.jsx("div",{className:"mt-auto pt-4 border-t border-oai-gray-200 dark:border-oai-gray-800",children:p.jsx("p",{className:"text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:O("share.modal.footer")})})]})]}),p.jsx(Lp,{children:h?p.jsx(Qn.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},className:"pointer-events-none absolute left-1/2 bottom-4 -translate-x-1/2",children:p.jsx("div",{className:["px-4 py-2 rounded-full text-xs font-medium shadow-oai-md",h.kind==="error"?"bg-red-600 text-white":h.kind==="success"?"bg-oai-black dark:bg-oai-white text-oai-white dark:text-oai-black":"bg-oai-gray-800 text-white"].join(" "),children:h.text})},h.id):null})]})]}):null}function zle(t){const{enabled:e,handle:n,startDate:r,activeDays:i,summary:a,topModels:s,period:o,periodFrom:c,periodTo:u,heatmap:f,accessToken:h,userId:m}=t,[g,v]=x.useState(null);return x.useEffect(()=>{if(!e||!m&&!vr())return;let w=!1;return(async()=>{try{const _=await M3({accessToken:h,userId:m,period:o==="day"||o==="custom"?"week":o,metric:"all",limit:100,offset:0});if(w)return;const M=(Array.isArray(_?.entries)?_.entries:Array.isArray(_)?_:[]).find(P=>P?.is_me===!0),T=typeof M?.rank=="number"?M.rank:null;v(T)}catch{w||v(null)}})(),()=>{w=!0}},[e,h,m,o]),x.useMemo(()=>ule({handle:n,startDate:r,activeDays:i,summary:a,topModels:s,rank:g,period:o,periodFrom:c,periodTo:u,heatmap:f}),[n,r,i,a,s,g,o,c,u,f])}const Vle=["day","week","month","total","custom"],A_=new Set(["day","hour","month"]),hh=new Set(["day","total","custom"]);function P_(t,e){if(typeof e=="number"&&e>0)return!0;if(typeof t=="bigint")return t>0n;if(typeof t=="number")return Number.isFinite(t)&&t>0;if(typeof t=="string"){const n=t.trim();if(!n)return!1;if(/^[0-9]+$/.test(n))try{return BigInt(n)>0n}catch{return!1}const r=Number(n);return Number.isFinite(r)&&r>0}return!1}function Pg(t){return t?t?.billable_total_tokens??t?.total_tokens:null}function $R(t){return t?t?.billable_total_tokens??t?.value??t?.total_tokens:null}function Hle(t){if(typeof t!="string"||!t)return null;const e=t.split("-");if(e.length!==3)return null;const n=Number(e[0]),r=Number(e[1])-1,i=Number(e[2]);if(!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i))return null;const a=new Date(Date.UTC(n,r,i));return Number.isFinite(a.getTime())?a:null}function Wle(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()+e))}function Gle(t){return t?t==="www.tokentracker.cc"||t==="tokentracker.cc":!1}function $le(){if(typeof window>"u")return!1;const t=new URLSearchParams(window.location.search),e=String(t.get("force_install")||"").toLowerCase();return e!=="1"&&e!=="true"?!1:!Gle(window.location.hostname)}function Yle({baseUrl:t,auth:e,signedIn:n,sessionSoftExpired:r,signOut:i,publicMode:a=!1,publicToken:s=null,signInUrl:o="/sign-in",signUpUrl:c="/sign-up"}){const{resolvedLocale:u}=lu(),[f,h]=x.useState(!1),[m,g]=x.useState(null),[v,w]=x.useState(null),[b,_]=x.useState(!1),[E,M]=x.useState(null),[T,P]=x.useState(0),[A,R]=x.useState(0),[k,N]=x.useState(null),[B,L]=x.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(max-width: 640px)").matches),z=x.useMemo(()=>typeof window>"u"?!1:uE(window.location.search),[]),I=x.useMemo(()=>$le(),[]),[V,W]=x.useState(!1),[X,J]=x.useState(!1),F=2200,[G,Y]=x.useState(!0),[H,te]=x.useState(!1),[re,ue]=x.useState(!1),[ce,ee]=x.useState(!1),le=vr(),ve=n&&!r,Ne=x.useMemo(()=>ve&&(typeof e=="function"||typeof e=="string"||e&&typeof e=="object")?e:null,[e,ve]),be=ve?Ne:null,qe=a?wo(s):be,he=n||le||a,Ue=ve&&Fl(be),je=n&&r&&!a;x.useEffect(()=>{if(!n||le){g(null),w(null),_(!1),M(null);return}if(a)return;if(!Ue){g(null),w(null),_(!1),M(null);return}let Ge=!0;const Wt=()=>{g(null),w(null),_(!1),M(null)};return _(!0),M(null),(async()=>{let Kt=null;try{Kt=await Dl(be)}catch{Kt=null}if(Ge){if(!Kt){Wt();return}try{const tn={link_code:null,expires_at:null};if(!Ge)return;g(typeof tn?.link_code=="string"?tn.link_code:null),w(typeof tn?.expires_at=="string"?tn.expires_at:null)}catch(tn){if(!Ge)return;g(null),w(null),M(tn?.message||"Failed to load link code")}finally{if(!Ge)return;_(!1)}}})(),()=>{Ge=!1}},[t,le,n,a,Ue,be,A]);const et=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");x.useEffect(()=>{if(!et&&(!n||le||a)){N(null);return}if(!et&&!Ue){N(null);return}let Ge=!0;return(async()=>{let Wt=null;try{Wt=await Dl(be)}catch{Wt=null}if(Ge){if(!Wt&&!et){N(null);return}try{const Kt=await b7({baseUrl:t,accessToken:Wt});if(!Ge)return;N(Kt&&typeof Kt=="object"?Kt:null)}catch{if(!Ge)return;N(null)}}})(),()=>{Ge=!1}},[Ue,t,be,le,a,n]);const _e=x.useMemo(()=>{if(!v)return!1;const Ge=Date.parse(v);if(!Number.isFinite(Ge))return!1;const Wt=T||Date.now();return Ge<=Wt},[v,T]);x.useEffect(()=>{!n||le||a||!v||!_e||b||(g(null),w(null),M(null),R(Ge=>Ge+1))},[_e,v,b,le,n]),x.useEffect(()=>{if(!v||a)return;const Ge=Date.parse(v);if(!Number.isFinite(Ge))return;const Wt=Date.now();if(P(Wt),Ge<=Wt)return;const Kt=window.setTimeout(()=>P(Date.now()),Ge-Wt),tn=()=>{typeof document>"u"||document.visibilityState==="visible"&&P(Date.now())};return typeof document<"u"&&document.addEventListener("visibilitychange",tn),window.addEventListener("focus",tn),()=>{window.clearTimeout(Kt),typeof document<"u"&&document.removeEventListener("visibilitychange",tn),window.removeEventListener("focus",tn)}},[v]),x.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const Ge=window.matchMedia("(max-width: 640px)"),Wt=()=>L(Ge.matches);return Wt(),Ge.addEventListener?(Ge.addEventListener("change",Wt),()=>Ge.removeEventListener("change",Wt)):(Ge.addListener(Wt),()=>Ge.removeListener(Wt))},[]);const oe=x.useMemo(()=>x3(),[]),Q=x.useMemo(()=>b3(),[]),ze=x.useMemo(()=>ZH(),[]),Pe=a?null:e?.userId||e?.email||"default",[De,Le]=x.useState("month"),[$,U]=x.useState(null),[Z,pe]=x.useState(null),[Se,xe]=x.useState(!1),Ie=z?"total":De,He=x.useMemo(()=>Ie==="custom"&&$&&Z?{from:$,to:Z}:w3(Ie,{timeZone:oe,offsetMinutes:Q,now:ze}),[ze,Ie,oe,Q,$,Z]),Ye=He.from,ft=He.to,We=x.useMemo(()=>jH({timeZone:oe,offsetMinutes:Q}),[oe,Q]),Xe=x.useMemo(()=>BH({timeZone:oe,offsetMinutes:Q}),[oe,Q]),nt=x.useMemo(()=>`Local time (${Xe})`,[Xe]),ct=oe,Ke=Q,gt=We,ne=x.useMemo(()=>wk({timeZone:oe,offsetMinutes:Q,date:ze||new Date}),[ze,oe,Q]),Be=x.useMemo(()=>{const Ge=Hle(ne)||new Date,Wt=Wle(Ge,-29);return{from:Hn(Wt),to:Hn(Ge)}},[ne]),{daily:ke,summary:Ae,rolling:Ve,source:ge,loading:ut,error:yt,refresh:qt}=gP({baseUrl:t,accessToken:qe,guestAllowed:je,from:Ye,to:ft,includeDaily:Ie!=="total",cacheKey:Pe,timeZone:oe,tzOffsetMinutes:Q,now:ze}),{daily:Lt,loading:_t,refresh:wt}=gP({baseUrl:t,accessToken:qe,guestAllowed:je,from:Be.from,to:Be.to,includeDaily:!0,cacheKey:Pe?`${Pe}.daily-breakdown`:"daily-breakdown",timeZone:oe,tzOffsetMinutes:Q,now:ze}),{breakdown:un,loading:xn,refresh:ie}=tJ({baseUrl:t,accessToken:qe,guestAllowed:je,from:Ye,to:ft,cacheKey:Pe,timeZone:oe,tzOffsetMinutes:Q}),[fe,Te]=x.useState(3),{entries:$e,loading:Ze,refresh:At}=$Z({baseUrl:t,accessToken:qe,limit:fe,from:Ye,to:ft,timeZone:oe,tzOffsetMinutes:Q}),St=Ie==="week"||Ie==="month",Rt=Ie==="week"||Ie==="month",xt=x.useMemo(()=>ke.filter(Ge=>Ge?.future?!1:!Ge?.day||!ne?!0:String(Ge.day)<=String(ne)),[ke,ne]),{rows:Tt,from:Xt,to:zt,loading:En,refresh:yn}=qZ({baseUrl:t,accessToken:qe,guestAllowed:je,period:Ie,from:Ye,to:ft,months:24,cacheKey:Pe,timeZone:ct,tzOffsetMinutes:Ke,now:ze,sharedRows:St?ke:null,sharedRange:St?{from:Ye,to:ft}:null}),{daily:Cn,heatmap:In,loading:hr,refresh:An}=GZ({baseUrl:t,accessToken:qe,guestAllowed:je,weeks:52,cacheKey:Pe,timeZone:oe,tzOffsetMinutes:Q,now:ze}),{refresh:K}=r4(),me=x.useMemo(()=>Ie==="day"?"hour":Ie==="total"?"month":"day",[Ie]),Re=x.useMemo(()=>vP(me),[me]),Ee="day",we=x.useMemo(()=>vP(Ee),[]),[st,mt]=x.useState(()=>({key:"day",dir:"desc"}));x.useEffect(()=>{mt(Ge=>!A_.has(Ge.key)||Ge.key===me?Ge:{key:me,dir:Ge.dir})},[me]);const it=x.useMemo(()=>A_.has(st.key)&&st.key!==me?{...st,key:me}:st,[me,st]),pt=x.useMemo(()=>{if(Ie==="day")return Array.isArray(Tt)?Tt.filter(Kt=>Kt?.hour&&!Kt?.future):[];if(Ie==="total"){const Kt=Array.isArray(Tt)?Tt.filter(tn=>tn?.month&&!tn?.future):[];return pJ(Kt)}const Ge=xt;return!Ge.some(Kt=>!Kt?.missing&&!Kt?.future)&&ke.length>0?ke.filter(Kt=>!Kt?.future).slice(-30).filter(Kt=>Kt?.day):Ge},[Ie,Tt,xt,ke]),Et=x.useMemo(()=>xP(pt,it),[pt,it]),dt=x.useMemo(()=>pt.some(Ge=>!Ge?.missing&&!Ge?.future),[pt]),Vt=x.useMemo(()=>{if(!hh.has(Ie))return 1;const Ge=Math.ceil(Et.length/sy);return Ge>0?Ge:1},[Ie,Et.length]),[Ct,dn]=x.useState(0);x.useEffect(()=>{if(!hh.has(Ie)){dn(0);return}dn(Ge=>Math.min(Ge,Vt-1))},[Vt,Ie]),x.useEffect(()=>{hh.has(Ie)&&dn(0)},[Ie,st.dir,st.key]);const en=x.useMemo(()=>hh.has(Ie)?mJ(Et,Ct,sy):Et,[Ct,Ie,Et]),Pn=x.useMemo(()=>Lt.filter(Ge=>!Ge?.future&&Ge?.day).slice(-30),[Lt]),cn=x.useMemo(()=>A_.has(st.key)?{...st,key:Ee}:st,[st]),nr=x.useMemo(()=>xP(Pn,cn),[Pn,cn]),Ut=x.useMemo(()=>Rt?ke:Ie==="day"?Array.isArray(Tt)?Tt.filter(Ge=>Ge?.hour):[]:Tt,[ke,Ie,Tt,Rt]),Kr=Rt?Ye:Xt,wn=Rt?ft:zt;function ri(Ge,Wt){return Ge?.future?"—":Ge?.missing?O("shared.status.unsynced"):Oi(Wt==="total_tokens"?Pg(Ge):Ge?.[Wt])}function ii(Ge){const Wt=Ge?.[me];if(Wt==null)return"";const Kt=String(Wt);if(me==="hour"){const[tn,pr]=Kt.split("T");if(tn&&pr)return`${tn} ${pr.slice(0,5)}`}return Kt}function xi(Ge){const Wt=Ge?.[Ee];return Wt==null?"":String(Wt)}function cs(Ge){mt(Wt=>Wt.key===Ge?{key:Ge,dir:Wt.dir==="asc"?"desc":"asc"}:{key:Ge,dir:"desc"})}function Fn(Ge){return it.key!==Ge?"none":it.dir==="asc"?"ascending":"descending"}function nn(Ge){return it.key!==Ge?"":it.dir==="asc"?"▲":"▼"}function $i(Ge){return cn.key!==Ge?"none":cn.dir==="asc"?"ascending":"descending"}function cr(Ge){return cn.key!==Ge?"":cn.dir==="asc"?"▲":"▼"}const ai=x.useMemo(()=>{if(!n&&!le&&!a&&!et)return 0;const Ge=Number(In?.active_days);if(Number.isFinite(Ge))return Ge;let Wt=0;const Kt=new Set,tn=(Yn,rr,er)=>{typeof Yn!="string"||!Yn||Kt.has(Yn)||P_(rr,er)&&(Kt.add(Yn),Wt+=1)};if(Array.isArray(Cn))for(const Yn of Cn)tn(Yn?.day,Pg(Yn));const pr=Array.isArray(In?.weeks)?In.weeks:[];for(const Yn of pr)for(const rr of Array.isArray(Yn)?Yn:[]){const er=$R(rr);tn(rr?.day,er,rr?.level)}return Wt},[n,le,In?.active_days,In?.weeks,Cn]),[da,Vo]=x.useState("month"),Kp=x.useCallback(Ge=>{Ge==="custom"?(Vo(Wt=>Wt==="custom"?"month":Wt),Le(Wt=>$&&Z?"custom":Wt),xe(!0)):(Le(Ge),Vo(Ge),xe(!1))},[$,Z]),_f=x.useCallback((Ge,Wt)=>{U(Ge),pe(Wt),Le("custom"),xe(!1)},[]),mu=x.useCallback(Ge=>{xe(Ge),!Ge&&De==="custom"&&!$&&Le(da)},[De,$,da]),La=x.useCallback(async()=>{await Promise.all([qt(),An(),yn(),ie(),At(),wt(),K()])},[wt,An,ie,At,yn,qt,K]),us=x.useCallback(async()=>{ee(!0);try{et&&await _7(),await La()}catch(Ge){console.error("[DashboardPage] Refresh failed:",Ge)}finally{ee(!1)}},[et,La]),ds=ce||ut||_t||hr||En||xn||Ze,Yl=x.useMemo(()=>O("shared.data_source",{source:String(ge||"edge").toUpperCase()}),[ge,u]),fs=x.useMemo(()=>typeof e?.name!="string"?"":e.name.trim(),[e?.name]),hs="",Zp=x.useMemo(()=>!fs||fs.includes("@")?O("dashboard.identity.fallback"):fs,[fs]),wf=x.useMemo(()=>Zp.replace(/[^a-zA-Z0-9._-]/g,"_"),[Zp]),Ho=x.useMemo(()=>a?O("dashboard.identity.fallback"):wf,[wf,hs,a]),Jp=x.useMemo(()=>{let Ge=null;const Wt=tn=>{typeof tn!="string"||!tn||(!Ge||tn<Ge)&&(Ge=tn)};if(Array.isArray(Cn))for(const tn of Cn)tn?.day&&P_(Pg(tn))&&Wt(tn.day);const Kt=Array.isArray(In?.weeks)?In.weeks:[];for(const tn of Kt)for(const pr of Array.isArray(tn)?tn:[]){if(!pr?.day)continue;const Yn=$R(pr),rr=pr?.level;P_(Yn,rr)&&Wt(pr.day)}return Ge},[In?.weeks,Cn]),Qp=x.useMemo(()=>a?[]:(Array.isArray(k?.subscriptions?.items)?k.subscriptions.items:[]).map(Kt=>{const tn=typeof Kt?.tool=="string"?Kt.tool.trim():"",Yn=(typeof Kt?.plan_type=="string"?Kt.plan_type:typeof Kt?.planType=="string"?Kt.planType:"").trim();return!tn||!Yn?null:{tool:tn,planType:Yn,provider:typeof Kt?.provider=="string"?Kt.provider.trim():"",product:typeof Kt?.product=="string"?Kt.product.trim():"",rateLimitTier:typeof Kt?.rate_limit_tier=="string"?Kt.rate_limit_tier.trim():typeof Kt?.rateLimitTier=="string"?Kt.rateLimitTier.trim():""}}).filter(Boolean).slice(0,6),[a,k]),gu=p.jsx(sQ,{heatmap:In,timeZoneLabel:We,timeZoneShortLabel:Xe,hideLegend:z,defaultToLatestMonth:z}),em=x.useMemo(()=>`${Ye}..${ft}`,[Ye,Ie,ft]),Sv=O("usage.summary.total"),Yi=Pg(Ae),Wo=O("shared.unit.thousand_abbrev"),to=O("shared.unit.million_abbrev"),ql=O("shared.unit.billion_abbrev"),yu=ti(Yi),tm=B&&yu!=null&&Math.abs(yu)>=1e9,Sf=x.useMemo(()=>tm?Ma(yu,{thousandSuffix:Wo,millionSuffix:to,billionSuffix:ql,decimals:1}):Oi(Yi),[ql,to,Yi,yu,Wo,tm]),vu=O("dashboard.core_index.collapse_label"),kf=O("dashboard.core_index.expand_label"),nm=O("dashboard.core_index.collapse_aria"),ps=O("dashboard.core_index.expand_aria"),Ef=!z,xu=O("dashboard.screenshot.title_line1"),rm=O("dashboard.screenshot.title_line2"),bu=O("dashboard.screenshot.twitter_label"),_u=O("dashboard.screenshot.twitter_button"),im=O("dashboard.screenshot.twitter_hint"),Sr=O("shared.placeholder.short"),ms=x.useMemo(()=>{const Ge=Array.isArray(un?.sources)?un.sources:[];let Wt=null,Kt=0;for(const rr of Ge){const er=ti(rr?.totals?.billable_total_tokens??rr?.totals?.total_tokens);!Number.isFinite(er)||er<=0||er>Kt&&(Kt=er,Wt=rr)}let tn=Sr,pr=Sr,Yn="0.0";if(Wt&&Kt>0){tn=Wt?.source?String(Wt.source).toUpperCase():Sr;const rr=Array.isArray(Wt?.models)?Wt.models:[];let er=0;for(const Ia of rr){const Jl=ti(Ia?.totals?.billable_total_tokens??Ia?.totals?.total_tokens);!Number.isFinite(Jl)||Jl<=0||Jl>er&&(er=Jl,pr=Ia?.model?String(Ia.model):Sr)}er>0&&(Yn=(er/Kt*100).toFixed(1))}return{agentName:tn,modelName:pr,modelPercent:Yn}},[un,Sr]),wu=Oi(Yi),Mf=O("dashboard.screenshot.twitter_text",{total_tokens:wu==="-"?Sr:wu,agent_name:ms.agentName,model_name:ms.modelName,model_percent:ms.modelPercent}),Xl=x.useMemo(()=>{if(typeof window>"u")return"";const Ge=new URL("https://twitter.com/intent/tweet");return Ge.searchParams.set("text",Mf),Ge.toString()},[Mf]),ku=x.useCallback(async()=>{if(typeof window>"u")return null;const Ge=async()=>{const rr=performance.now();for(;performance.now()-rr<2e3;){const er=document.querySelector("[data-heatmap-scroll='true']");if(!er||er.dataset.latestMonthReady==="true")return;await new Promise(Ia=>requestAnimationFrame(Ia))}},Wt=document.querySelector("#root")||document.body,Kt=document.documentElement,{scrollWidth:tn,scrollHeight:pr}=document.documentElement;Kt?.classList.add("screenshot-capture"),document.body?.classList.add("screenshot-capture"),await new Promise(Yn=>requestAnimationFrame(Yn)),await Ge();try{const{toBlob:Yn,toPng:rr}=await t4(async()=>{const{toBlob:no,toPng:cm}=await import("./index-BeoRn2gJ.js");return{toBlob:no,toPng:cm}},[]),er=await Yn(Wt,{backgroundColor:"#050505",pixelRatio:2,cacheBust:!0,width:tn,height:pr,style:{width:`${tn}px`,height:`${pr}px`},filter:no=>!(no instanceof HTMLElement)||no.dataset?.screenshotExclude!=="true"});if(er)return er;const Ia=await rr(Wt,{backgroundColor:"#050505",pixelRatio:2,cacheBust:!0,width:tn,height:pr,style:{width:`${tn}px`,height:`${pr}px`},filter:no=>!(no instanceof HTMLElement)||no.dataset?.screenshotExclude!=="true"});return Ia?await(await fetch(Ia)).blob():null}finally{Kt?.classList.remove("screenshot-capture"),document.body?.classList.remove("screenshot-capture")}},[]),Kl=x.useCallback(async()=>{if(typeof window>"u"||V)return;W(!0);const Ge=navigator?.userAgent||"",Wt=/iP(hone|od|ad)/i.test(Ge),Kt=/Safari/i.test(Ge)&&!/Chrome|Chromium|Edg|OPR|CriOS|FxiOS/i.test(Ge),tn=typeof navigator<"u"&&!!navigator.clipboard?.write&&typeof window<"u"&&!!window.ClipboardItem;let Yn=!tn||Wt||Kt;try{const rr=await ku();rr&&tn&&(typeof document<"u"&&!document.hasFocus()&&window.focus?.(),Yn=await Vw(rr))}catch(rr){console.error("Failed to capture screenshot",rr)}finally{if(W(!1),!Yn){console.warn("Failed to write screenshot to clipboard.");return}Xl&&(window.location.href=Xl)}},[ku,V,Xl]),Eu=x.useMemo(()=>z?[]:Vle,[z]),am=x.useMemo(()=>[{label:O("usage.metric.total"),value:Oi(Yi),valueClassName:"text-white"},{label:O("usage.metric.input"),value:Oi(Ae?.input_tokens)},{label:O("usage.metric.output"),value:Oi(Ae?.output_tokens)},{label:O("usage.metric.cached_input"),value:Oi(Ae?.cached_input_tokens)},{label:O("usage.metric.reasoning_output"),value:Oi(Ae?.reasoning_output_tokens)}],[Ae?.cached_input_tokens,Ae?.input_tokens,Ae?.output_tokens,Ae?.reasoning_output_tokens,Yi]),Tf=x.useMemo(()=>{const Ge=Uy(Ae?.total_cost_usd);return!Ge||Ge==="-"||Ge.startsWith("$")?Ge:`$${Ge}`},[Ae?.total_cost_usd]),kv=x.useMemo(()=>Ae?.conversation_count??null,[Ae?.conversation_count]),sm=x.useMemo(()=>vJ(un,{copyFn:O}),[un]),Mu=x.useMemo(()=>xJ(un,{limit:3,copyFn:O}),[un]),Ev=zle({enabled:X,handle:Ho,startDate:Jp,activeDays:ai,summary:Ae,topModels:Mu,period:Ie,periodFrom:Ye,periodTo:ft,heatmap:In,accessToken:typeof qe=="string"?qe:null,userId:e?.userId||null}),Mv=x.useCallback(()=>J(!0),[]),Tv=x.useCallback(()=>J(!1),[]),Cv=x.useCallback(()=>h(!0),[]),Av=x.useCallback(()=>h(!1),[]),om=Tf&&Tf!=="-"&&sm.length>0,Zl=O("dashboard.install.cmd.init"),Cf=_e?null:m,Af=Cf?O("dashboard.install.cmd.init_link_code",{link_code:Cf}):Zl,Pv=Zl,Pf=O("dashboard.install.cmd.sync"),Rv=O(Cf?"dashboard.install.copy":"dashboard.install.copy_base"),Nv=O("dashboard.install.copied");O("dashboard.session_expired.copy_label"),O("dashboard.session_expired.copied");const Dv=!!(k?.install?.has_active_device_token??k?.install?.hasActiveDeviceToken),lm=gJ({publicMode:a,screenshotMode:z,forceInstall:I,accessEnabled:he,heatmapLoading:hr,activeDays:ai,hasActiveDeviceToken:Dv}),Lv=O("dashboard.install.prompt"),Iv=x.useCallback(async()=>{!Af||!await zw(Af)||(te(!0),window.setTimeout(()=>te(!1),2e3))},[Af]);x.useCallback(async()=>{!Zl||!await zw(Zl)||(ue(!0),window.setTimeout(()=>ue(!1),2e3))},[Zl]);const Rf=x.useMemo(()=>O("dashboard.daily.empty",{cmd:"{{cmd}}"}),[u]),[Ov,Fv]=x.useMemo(()=>{const Ge=Rf.split("{{cmd}}");return Ge.length===1?[Rf,""]:[Ge[0],Ge.slice(1).join("{{cmd}}")]},[Rf]),Uv=r&&!a,Nf=!n&&!le&&!r&&!et&&!a;return p.jsxs(p.Fragment,{children:[p.jsx(nle,{copy:O,onOpenShare:Mv,screenshotMode:z,showExpiredGate:Uv,showAuthGate:Nf,screenshotTitleLine1:xu,screenshotTitleLine2:rm,identityDisplayName:Ho,identityStartDate:Jp,activeDays:ai,identitySubscriptions:Qp,identityScrambleDurationMs:F,projectUsageEntries:$e,projectUsageLimit:fe,setProjectUsageLimit:Te,topModels:Mu,signedIn:n,publicMode:a,isLocalMode:et,shouldShowInstall:lm,installPrompt:Lv,handleCopyInstall:Iv,installCopied:H,installCopiedLabel:Nv,installCopyLabel:Rv,installInitCmdDisplay:Pv,linkCodeLoading:b,linkCodeError:E,trendRowsForDisplay:Ut,trendFromForDisplay:Kr,trendToForDisplay:wn,usageFrom:Ye,usageTo:ft,period:Ie,trendTimeZoneLabel:gt,activityHeatmapBlock:gu,isCapturing:V,handleShareToX:Kl,screenshotTwitterLabel:bu,screenshotTwitterButton:_u,screenshotTwitterHint:im,periodsForDisplay:Eu,setSelectedPeriod:Kp,customFrom:$,customTo:Z,onCustomRangeApply:_f,customRangeOpen:Se,onCustomRangeOpenChange:mu,metricsRows:am,summaryLabel:Sv,summaryValue:Sf,summaryTotalTokensRaw:ti(Yi)||0,summaryCostValue:Tf,summaryConversationsValue:kv,rollingUsage:Ve,costInfoEnabled:om,openCostModal:Cv,allowBreakdownToggle:Ef,coreIndexCollapsed:G,setCoreIndexCollapsed:Y,coreIndexCollapseLabel:vu,coreIndexExpandLabel:kf,coreIndexCollapseAria:nm,coreIndexExpandAria:ps,refreshAll:us,usageLoadingState:ds,usageError:yt,rangeLabel:em,timeZoneRangeLabel:nt,usageSourceLabel:Yl,fleetData:sm,hasDetailsActual:dt,dailyEmptyPrefix:Ov,installSyncCmd:Pf,dailyEmptySuffix:Fv,detailsColumns:Re,ariaSortFor:Fn,toggleSort:cs,sortIconFor:nn,pagedDetails:en,dailyBreakdownRows:nr,dailyBreakdownColumns:we,dailyBreakdownAriaSortFor:$i,dailyBreakdownSortIconFor:cr,dailyBreakdownDateKey:Ee,detailsDateKey:me,renderDetailDate:ii,renderDailyBreakdownDate:xi,renderDetailCell:ri,DETAILS_PAGED_PERIODS:hh,detailsPageCount:Vt,detailsPage:Ct,setDetailsPage:dn,costModalOpen:f,closeCostModal:Av}),p.jsx(Ble,{open:X,onClose:Tv,data:Ev,twitterText:Mf})]})}function qle(){const[t,e]=x.useState(!1);return p.jsxs("div",{className:"h-full relative dark:bg-[#050505]",children:[!t&&p.jsxs("div",{className:"absolute inset-0 p-6 space-y-5 animate-pulse",children:[p.jsx("div",{className:"flex gap-4 justify-center",children:Array.from({length:6}).map((n,r)=>p.jsx("div",{className:"h-4 w-20 rounded bg-oai-gray-200 dark:bg-oai-gray-800"},r))}),p.jsxs("div",{className:"space-y-2 pt-2",children:[p.jsx("div",{className:"h-7 w-72 rounded bg-oai-gray-200 dark:bg-oai-gray-800"}),p.jsx("div",{className:"h-4 w-96 rounded bg-oai-gray-200 dark:bg-oai-gray-800"})]}),p.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:3}).map((n,r)=>p.jsx("div",{className:"h-24 rounded-xl bg-oai-gray-200 dark:bg-oai-gray-800"},r))}),p.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:3}).map((n,r)=>p.jsx("div",{className:"h-40 rounded-xl bg-oai-gray-200 dark:bg-oai-gray-800"},r))}),p.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:3}).map((n,r)=>p.jsx("div",{className:"h-32 rounded-xl bg-oai-gray-200 dark:bg-oai-gray-800"},r))})]}),p.jsx("iframe",{src:"https://ip.net.coffee/claude/",title:"Cloud AI IP Check",className:`w-full h-full dark:invert dark:hue-rotate-180 transition-opacity duration-300 ${t?"opacity-100":"opacity-0"}`,style:{border:"none"},onLoad:()=>e(!0)})]})}function Xle(){if(typeof window>"u")return!1;const t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||t==="::1"}function Kle(){return Xle()?"/":"/dashboard"}function ZF({repo:t="mm7894215/TokenTracker"}){const[e,n]=x.useState(null);return x.useEffect(()=>{if(typeof window>"u")return;const r=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,i=typeof document<"u"&&(document.documentElement?.classList.contains("screenshot-capture")||document.body?.classList.contains("screenshot-capture"));F5({prefersReducedMotion:r,screenshotCapture:i})&&fetch(`https://api.github.com/repos/${t}`).then(a=>a.json()).then(a=>{a&&typeof a.stargazers_count=="number"&&n(a.stargazers_count)}).catch(()=>{})},[t]),p.jsxs("a",{href:`https://github.com/${t}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex shrink-0 items-center gap-2 px-3 py-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-700 transition-colors no-underline",children:[p.jsx("svg",{height:"16",viewBox:"0 0 16 16",width:"16",className:"shrink-0 fill-oai-gray-700 dark:fill-oai-gray-300",children:p.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),p.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 whitespace-nowrap",children:"Star"}),e!==null&&p.jsx("span",{className:"text-xs font-semibold text-oai-gray-900 dark:text-oai-white tabular-nums whitespace-nowrap",children:e})]})}const qE="183",Zle=0,YR=1,Jle=2,E0=1,Qle=2,Ph=3,Ol=0,zi=1,So=2,Ro=0,Hc=1,qR=2,XR=3,KR=4,ece=5,Tc=100,tce=101,nce=102,rce=103,ice=104,ace=200,sce=201,oce=202,lce=203,j1=204,B1=205,cce=206,uce=207,dce=208,fce=209,hce=210,pce=211,mce=212,gce=213,yce=214,z1=0,V1=1,H1=2,qd=3,W1=4,G1=5,$1=6,Y1=7,JF=0,vce=1,xce=2,Us=0,QF=1,eU=2,tU=3,nU=4,rU=5,iU=6,aU=7,sU=300,ru=301,Xd=302,R_=303,N_=304,fv=306,q1=1e3,Mo=1001,X1=1002,ni=1003,bce=1004,Rg=1005,yi=1006,D_=1007,Fc=1008,Ea=1009,oU=1010,lU=1011,dp=1012,XE=1013,$s=1014,Ds=1015,Uo=1016,KE=1017,ZE=1018,fp=1020,cU=35902,uU=35899,dU=1021,fU=1022,ts=1023,jo=1026,Uc=1027,hU=1028,JE=1029,Kd=1030,QE=1031,eM=1033,M0=33776,T0=33777,C0=33778,A0=33779,K1=35840,Z1=35841,J1=35842,Q1=35843,eS=36196,tS=37492,nS=37496,rS=37488,iS=37489,aS=37490,sS=37491,oS=37808,lS=37809,cS=37810,uS=37811,dS=37812,fS=37813,hS=37814,pS=37815,mS=37816,gS=37817,yS=37818,vS=37819,xS=37820,bS=37821,_S=36492,wS=36494,SS=36495,kS=36283,ES=36284,MS=36285,TS=36286,_ce=3200,wce=0,Sce=1,wl="",wa="srgb",iu="srgb-linear",xy="linear",qn="srgb",Qu=7680,ZR=519,kce=512,Ece=513,Mce=514,tM=515,Tce=516,Cce=517,nM=518,Ace=519,JR=35044,QR="300 es",Ls=2e3,by=2001;function Pce(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function _y(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Rce(){const t=_y("canvas");return t.style.display="block",t}const eN={};function tN(...t){const e="THREE."+t.shift();console.log(e,...t)}function pU(t){const e=t[0];if(typeof e=="string"&&e.startsWith("TSL:")){const n=t[1];n&&n.isStackTrace?t[0]+=" "+n.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}function ln(...t){t=pU(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...t)}}function Vn(...t){t=pU(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.error(n.getError(e)):console.error(e,...t)}}function wy(...t){const e=t.join(" ");e in eN||(eN[e]=!0,ln(...t))}function Nce(t,e,n){return new Promise(function(r,i){function a(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}const Dce={[z1]:V1,[H1]:$1,[W1]:Y1,[qd]:G1,[V1]:z1,[$1]:H1,[Y1]:W1,[G1]:qd};class pf{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,s=i.length;a<s;a++)i[a].call(this,e);e.target=null}}}const ui=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],L_=Math.PI/180,CS=180/Math.PI;function Hp(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ui[t&255]+ui[t>>8&255]+ui[t>>16&255]+ui[t>>24&255]+"-"+ui[e&255]+ui[e>>8&255]+"-"+ui[e>>16&15|64]+ui[e>>24&255]+"-"+ui[n&63|128]+ui[n>>8&255]+"-"+ui[n>>16&255]+ui[n>>24&255]+ui[r&255]+ui[r>>8&255]+ui[r>>16&255]+ui[r>>24&255]).toLowerCase()}function Dn(t,e,n){return Math.max(e,Math.min(n,t))}function Lce(t,e){return(t%e+e)%e}function I_(t,e,n){return(1-n)*t+n*e}function ph(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Ii(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}class $n{constructor(e=0,n=0){$n.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Dn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,s=this.y-e.y;return this.x=a*r-s*i+e.x,this.y=a*i+s*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class mf{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,s,o){let c=r[i+0],u=r[i+1],f=r[i+2],h=r[i+3],m=a[s+0],g=a[s+1],v=a[s+2],w=a[s+3];if(h!==w||c!==m||u!==g||f!==v){let b=c*m+u*g+f*v+h*w;b<0&&(m=-m,g=-g,v=-v,w=-w,b=-b);let _=1-o;if(b<.9995){const E=Math.acos(b),M=Math.sin(E);_=Math.sin(_*E)/M,o=Math.sin(o*E)/M,c=c*_+m*o,u=u*_+g*o,f=f*_+v*o,h=h*_+w*o}else{c=c*_+m*o,u=u*_+g*o,f=f*_+v*o,h=h*_+w*o;const E=1/Math.sqrt(c*c+u*u+f*f+h*h);c*=E,u*=E,f*=E,h*=E}}e[n]=c,e[n+1]=u,e[n+2]=f,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,a,s){const o=r[i],c=r[i+1],u=r[i+2],f=r[i+3],h=a[s],m=a[s+1],g=a[s+2],v=a[s+3];return e[n]=o*v+f*h+c*g-u*m,e[n+1]=c*v+f*m+u*h-o*g,e[n+2]=u*v+f*g+o*m-c*h,e[n+3]=f*v-o*h-c*m-u*g,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,a=e._z,s=e._order,o=Math.cos,c=Math.sin,u=o(r/2),f=o(i/2),h=o(a/2),m=c(r/2),g=c(i/2),v=c(a/2);switch(s){case"XYZ":this._x=m*f*h+u*g*v,this._y=u*g*h-m*f*v,this._z=u*f*v+m*g*h,this._w=u*f*h-m*g*v;break;case"YXZ":this._x=m*f*h+u*g*v,this._y=u*g*h-m*f*v,this._z=u*f*v-m*g*h,this._w=u*f*h+m*g*v;break;case"ZXY":this._x=m*f*h-u*g*v,this._y=u*g*h+m*f*v,this._z=u*f*v+m*g*h,this._w=u*f*h-m*g*v;break;case"ZYX":this._x=m*f*h-u*g*v,this._y=u*g*h+m*f*v,this._z=u*f*v-m*g*h,this._w=u*f*h+m*g*v;break;case"YZX":this._x=m*f*h+u*g*v,this._y=u*g*h+m*f*v,this._z=u*f*v-m*g*h,this._w=u*f*h-m*g*v;break;case"XZY":this._x=m*f*h-u*g*v,this._y=u*g*h-m*f*v,this._z=u*f*v+m*g*h,this._w=u*f*h+m*g*v;break;default:ln("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],s=n[1],o=n[5],c=n[9],u=n[2],f=n[6],h=n[10],m=r+o+h;if(m>0){const g=.5/Math.sqrt(m+1);this._w=.25/g,this._x=(f-c)*g,this._y=(a-u)*g,this._z=(s-i)*g}else if(r>o&&r>h){const g=2*Math.sqrt(1+r-o-h);this._w=(f-c)/g,this._x=.25*g,this._y=(i+s)/g,this._z=(a+u)/g}else if(o>h){const g=2*Math.sqrt(1+o-r-h);this._w=(a-u)/g,this._x=(i+s)/g,this._y=.25*g,this._z=(c+f)/g}else{const g=2*Math.sqrt(1+h-r-o);this._w=(s-i)/g,this._x=(a+u)/g,this._y=(c+f)/g,this._z=.25*g}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Dn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,s=e._w,o=n._x,c=n._y,u=n._z,f=n._w;return this._x=r*f+s*o+i*u-a*c,this._y=i*f+s*c+a*o-r*u,this._z=a*f+s*u+r*c-i*o,this._w=s*f-r*o-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){let r=e._x,i=e._y,a=e._z,s=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,a=-a,s=-s,o=-o);let c=1-n;if(o<.9995){const u=Math.acos(o),f=Math.sin(u);c=Math.sin(c*u)/f,n=Math.sin(n*u)/f,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+s*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+s*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),a=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),a*Math.sin(n),a*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Oe{constructor(e=0,n=0,r=0){Oe.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(nN.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(nN.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,s=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*s,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*s,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*s,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,s=e.y,o=e.z,c=e.w,u=2*(s*i-o*r),f=2*(o*n-a*i),h=2*(a*r-s*n);return this.x=n+c*u+s*h-o*f,this.y=r+c*f+o*u-a*h,this.z=i+c*h+a*f-s*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this.z=Dn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this.z=Dn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,s=n.x,o=n.y,c=n.z;return this.x=i*c-a*o,this.y=a*s-r*c,this.z=r*o-i*s,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return O_.copy(this).projectOnVector(e),this.sub(O_)}reflect(e){return this.sub(O_.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Dn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const O_=new Oe,nN=new mf;class pn{constructor(e,n,r,i,a,s,o,c,u){pn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u)}set(e,n,r,i,a,s,o,c,u){const f=this.elements;return f[0]=e,f[1]=i,f[2]=o,f[3]=n,f[4]=a,f[5]=c,f[6]=r,f[7]=s,f[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[3],c=r[6],u=r[1],f=r[4],h=r[7],m=r[2],g=r[5],v=r[8],w=i[0],b=i[3],_=i[6],E=i[1],M=i[4],T=i[7],P=i[2],A=i[5],R=i[8];return a[0]=s*w+o*E+c*P,a[3]=s*b+o*M+c*A,a[6]=s*_+o*T+c*R,a[1]=u*w+f*E+h*P,a[4]=u*b+f*M+h*A,a[7]=u*_+f*T+h*R,a[2]=m*w+g*E+v*P,a[5]=m*b+g*M+v*A,a[8]=m*_+g*T+v*R,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],f=e[8];return n*s*f-n*o*u-r*a*f+r*o*c+i*a*u-i*s*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],f=e[8],h=f*s-o*u,m=o*c-f*a,g=u*a-s*c,v=n*h+r*m+i*g;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const w=1/v;return e[0]=h*w,e[1]=(i*u-f*r)*w,e[2]=(o*r-i*s)*w,e[3]=m*w,e[4]=(f*n-i*c)*w,e[5]=(i*a-o*n)*w,e[6]=g*w,e[7]=(r*c-u*n)*w,e[8]=(s*n-r*a)*w,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,o){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*s+u*o)+s+e,-i*u,i*c,-i*(-u*s+c*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(F_.makeScale(e,n)),this}rotate(e){return this.premultiply(F_.makeRotation(-e)),this}translate(e,n){return this.premultiply(F_.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,r,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const F_=new pn,rN=new pn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),iN=new pn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Ice(){const t={enabled:!0,workingColorSpace:iu,spaces:{},convert:function(i,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===qn&&(i.r=No(i.r),i.g=No(i.g),i.b=No(i.b)),this.spaces[a].primaries!==this.spaces[s].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===qn&&(i.r=Dd(i.r),i.g=Dd(i.g),i.b=Dd(i.b))),i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===wl?xy:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,a=this.workingColorSpace){return i.fromArray(this.spaces[a].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,a,s){return i.copy(this.spaces[a].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,a){return wy("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return wy("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,a)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[iu]:{primaries:e,whitePoint:r,transfer:xy,toXYZ:rN,fromXYZ:iN,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:wa},outputColorSpaceConfig:{drawingBufferColorSpace:wa}},[wa]:{primaries:e,whitePoint:r,transfer:qn,toXYZ:rN,fromXYZ:iN,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:wa}}}),t}const jn=Ice();function No(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Dd(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let ed;class Oce{static getDataURL(e,n="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let r;if(e instanceof HTMLCanvasElement)r=e;else{ed===void 0&&(ed=_y("canvas")),ed.width=e.width,ed.height=e.height;const i=ed.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=ed}return r.toDataURL(n)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=_y("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let s=0;s<a.length;s++)a[s]=No(a[s]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(No(n[r]/255)*255):n[r]=No(n[r]);return{data:n,width:e.width,height:e.height}}else return ln("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Fce=0;class rM{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Fce++}),this.uuid=Hp(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):typeof VideoFrame<"u"&&n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let s=0,o=i.length;s<o;s++)i[s].isDataTexture?a.push(U_(i[s].image)):a.push(U_(i[s]))}else a=U_(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function U_(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Oce.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(ln("Texture: Unable to serialize Texture."),{})}let Uce=0;const j_=new Oe;class Ti extends pf{constructor(e=Ti.DEFAULT_IMAGE,n=Ti.DEFAULT_MAPPING,r=Mo,i=Mo,a=yi,s=Fc,o=ts,c=Ea,u=Ti.DEFAULT_ANISOTROPY,f=wl){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Uce++}),this.uuid=Hp(),this.name="",this.source=new rM(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=s,this.anisotropy=u,this.format=o,this.internalFormat=null,this.type=c,this.offset=new $n(0,0),this.repeat=new $n(1,1),this.center=new $n(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new pn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=f,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(j_).x}get height(){return this.source.getSize(j_).y}get depth(){return this.source.getSize(j_).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const n in e){const r=e[n];if(r===void 0){ln(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){ln(`Texture.setValues(): property '${n}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==sU)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case q1:e.x=e.x-Math.floor(e.x);break;case Mo:e.x=e.x<0?0:1;break;case X1:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case q1:e.y=e.y-Math.floor(e.y);break;case Mo:e.y=e.y<0?0:1;break;case X1:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Ti.DEFAULT_IMAGE=null;Ti.DEFAULT_MAPPING=sU;Ti.DEFAULT_ANISOTROPY=1;class yr{constructor(e=0,n=0,r=0,i=1){yr.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i+s[12]*a,this.y=s[1]*n+s[5]*r+s[9]*i+s[13]*a,this.z=s[2]*n+s[6]*r+s[10]*i+s[14]*a,this.w=s[3]*n+s[7]*r+s[11]*i+s[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],f=c[4],h=c[8],m=c[1],g=c[5],v=c[9],w=c[2],b=c[6],_=c[10];if(Math.abs(f-m)<.01&&Math.abs(h-w)<.01&&Math.abs(v-b)<.01){if(Math.abs(f+m)<.1&&Math.abs(h+w)<.1&&Math.abs(v+b)<.1&&Math.abs(u+g+_-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const M=(u+1)/2,T=(g+1)/2,P=(_+1)/2,A=(f+m)/4,R=(h+w)/4,k=(v+b)/4;return M>T&&M>P?M<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(M),i=A/r,a=R/r):T>P?T<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(T),r=A/i,a=k/i):P<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(P),r=R/a,i=k/a),this.set(r,i,a,n),this}let E=Math.sqrt((b-v)*(b-v)+(h-w)*(h-w)+(m-f)*(m-f));return Math.abs(E)<.001&&(E=1),this.x=(b-v)/E,this.y=(h-w)/E,this.z=(m-f)/E,this.w=Math.acos((u+g+_-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this.z=Dn(this.z,e.z,n.z),this.w=Dn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this.z=Dn(this.z,e,n),this.w=Dn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class jce extends pf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:yi,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=r.depth,this.scissor=new yr(0,0,e,n),this.scissorTest=!1,this.viewport=new yr(0,0,e,n),this.textures=[];const i={width:e,height:n,depth:r.depth},a=new Ti(i),s=r.count;for(let o=0;o<s;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:yi,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,a=this.textures.length;i<a;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new rM(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class js extends jce{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class mU extends Ti{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ni,this.minFilter=ni,this.wrapR=Mo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Bce extends Ti{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ni,this.minFilter=ni,this.wrapR=Mo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Nr{constructor(e,n,r,i,a,s,o,c,u,f,h,m,g,v,w,b){Nr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u,f,h,m,g,v,w,b)}set(e,n,r,i,a,s,o,c,u,f,h,m,g,v,w,b){const _=this.elements;return _[0]=e,_[4]=n,_[8]=r,_[12]=i,_[1]=a,_[5]=s,_[9]=o,_[13]=c,_[2]=u,_[6]=f,_[10]=h,_[14]=m,_[3]=g,_[7]=v,_[11]=w,_[15]=b,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Nr().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return this.determinant()===0?(e.set(1,0,0),n.set(0,1,0),r.set(0,0,1),this):(e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this)}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const n=this.elements,r=e.elements,i=1/td.setFromMatrixColumn(e,0).length(),a=1/td.setFromMatrixColumn(e,1).length(),s=1/td.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*s,n[9]=r[9]*s,n[10]=r[10]*s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,s=Math.cos(r),o=Math.sin(r),c=Math.cos(i),u=Math.sin(i),f=Math.cos(a),h=Math.sin(a);if(e.order==="XYZ"){const m=s*f,g=s*h,v=o*f,w=o*h;n[0]=c*f,n[4]=-c*h,n[8]=u,n[1]=g+v*u,n[5]=m-w*u,n[9]=-o*c,n[2]=w-m*u,n[6]=v+g*u,n[10]=s*c}else if(e.order==="YXZ"){const m=c*f,g=c*h,v=u*f,w=u*h;n[0]=m+w*o,n[4]=v*o-g,n[8]=s*u,n[1]=s*h,n[5]=s*f,n[9]=-o,n[2]=g*o-v,n[6]=w+m*o,n[10]=s*c}else if(e.order==="ZXY"){const m=c*f,g=c*h,v=u*f,w=u*h;n[0]=m-w*o,n[4]=-s*h,n[8]=v+g*o,n[1]=g+v*o,n[5]=s*f,n[9]=w-m*o,n[2]=-s*u,n[6]=o,n[10]=s*c}else if(e.order==="ZYX"){const m=s*f,g=s*h,v=o*f,w=o*h;n[0]=c*f,n[4]=v*u-g,n[8]=m*u+w,n[1]=c*h,n[5]=w*u+m,n[9]=g*u-v,n[2]=-u,n[6]=o*c,n[10]=s*c}else if(e.order==="YZX"){const m=s*c,g=s*u,v=o*c,w=o*u;n[0]=c*f,n[4]=w-m*h,n[8]=v*h+g,n[1]=h,n[5]=s*f,n[9]=-o*f,n[2]=-u*f,n[6]=g*h+v,n[10]=m-w*h}else if(e.order==="XZY"){const m=s*c,g=s*u,v=o*c,w=o*u;n[0]=c*f,n[4]=-h,n[8]=u*f,n[1]=m*h+w,n[5]=s*f,n[9]=g*h-v,n[2]=v*h-g,n[6]=o*f,n[10]=w*h+m}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(zce,e,Vce)}lookAt(e,n,r){const i=this.elements;return Qi.subVectors(e,n),Qi.lengthSq()===0&&(Qi.z=1),Qi.normalize(),ul.crossVectors(r,Qi),ul.lengthSq()===0&&(Math.abs(r.z)===1?Qi.x+=1e-4:Qi.z+=1e-4,Qi.normalize(),ul.crossVectors(r,Qi)),ul.normalize(),Ng.crossVectors(Qi,ul),i[0]=ul.x,i[4]=Ng.x,i[8]=Qi.x,i[1]=ul.y,i[5]=Ng.y,i[9]=Qi.y,i[2]=ul.z,i[6]=Ng.z,i[10]=Qi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[4],c=r[8],u=r[12],f=r[1],h=r[5],m=r[9],g=r[13],v=r[2],w=r[6],b=r[10],_=r[14],E=r[3],M=r[7],T=r[11],P=r[15],A=i[0],R=i[4],k=i[8],N=i[12],B=i[1],L=i[5],z=i[9],I=i[13],V=i[2],W=i[6],X=i[10],J=i[14],F=i[3],G=i[7],Y=i[11],H=i[15];return a[0]=s*A+o*B+c*V+u*F,a[4]=s*R+o*L+c*W+u*G,a[8]=s*k+o*z+c*X+u*Y,a[12]=s*N+o*I+c*J+u*H,a[1]=f*A+h*B+m*V+g*F,a[5]=f*R+h*L+m*W+g*G,a[9]=f*k+h*z+m*X+g*Y,a[13]=f*N+h*I+m*J+g*H,a[2]=v*A+w*B+b*V+_*F,a[6]=v*R+w*L+b*W+_*G,a[10]=v*k+w*z+b*X+_*Y,a[14]=v*N+w*I+b*J+_*H,a[3]=E*A+M*B+T*V+P*F,a[7]=E*R+M*L+T*W+P*G,a[11]=E*k+M*z+T*X+P*Y,a[15]=E*N+M*I+T*J+P*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],s=e[1],o=e[5],c=e[9],u=e[13],f=e[2],h=e[6],m=e[10],g=e[14],v=e[3],w=e[7],b=e[11],_=e[15],E=c*g-u*m,M=o*g-u*h,T=o*m-c*h,P=s*g-u*f,A=s*m-c*f,R=s*h-o*f;return n*(w*E-b*M+_*T)-r*(v*E-b*P+_*A)+i*(v*M-w*P+_*R)-a*(v*T-w*A+b*R)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],f=e[8],h=e[9],m=e[10],g=e[11],v=e[12],w=e[13],b=e[14],_=e[15],E=n*o-r*s,M=n*c-i*s,T=n*u-a*s,P=r*c-i*o,A=r*u-a*o,R=i*u-a*c,k=f*w-h*v,N=f*b-m*v,B=f*_-g*v,L=h*b-m*w,z=h*_-g*w,I=m*_-g*b,V=E*I-M*z+T*L+P*B-A*N+R*k;if(V===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const W=1/V;return e[0]=(o*I-c*z+u*L)*W,e[1]=(i*z-r*I-a*L)*W,e[2]=(w*R-b*A+_*P)*W,e[3]=(m*A-h*R-g*P)*W,e[4]=(c*B-s*I-u*N)*W,e[5]=(n*I-i*B+a*N)*W,e[6]=(b*T-v*R-_*M)*W,e[7]=(f*R-m*T+g*M)*W,e[8]=(s*z-o*B+u*k)*W,e[9]=(r*B-n*z-a*k)*W,e[10]=(v*A-w*T+_*E)*W,e[11]=(h*T-f*A-g*E)*W,e[12]=(o*N-s*L-c*k)*W,e[13]=(n*L-r*N+i*k)*W,e[14]=(w*M-v*P-b*E)*W,e[15]=(f*P-h*M+m*E)*W,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,s=e.x,o=e.y,c=e.z,u=a*s,f=a*o;return this.set(u*s+r,u*o-i*c,u*c+i*o,0,u*o+i*c,f*o+r,f*c-i*s,0,u*c-i*o,f*c+i*s,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,s){return this.set(1,r,a,0,e,1,s,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,s=n._y,o=n._z,c=n._w,u=a+a,f=s+s,h=o+o,m=a*u,g=a*f,v=a*h,w=s*f,b=s*h,_=o*h,E=c*u,M=c*f,T=c*h,P=r.x,A=r.y,R=r.z;return i[0]=(1-(w+_))*P,i[1]=(g+T)*P,i[2]=(v-M)*P,i[3]=0,i[4]=(g-T)*A,i[5]=(1-(m+_))*A,i[6]=(b+E)*A,i[7]=0,i[8]=(v+M)*R,i[9]=(b-E)*R,i[10]=(1-(m+w))*R,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const a=this.determinant();if(a===0)return r.set(1,1,1),n.identity(),this;let s=td.set(i[0],i[1],i[2]).length();const o=td.set(i[4],i[5],i[6]).length(),c=td.set(i[8],i[9],i[10]).length();a<0&&(s=-s),Ga.copy(this);const u=1/s,f=1/o,h=1/c;return Ga.elements[0]*=u,Ga.elements[1]*=u,Ga.elements[2]*=u,Ga.elements[4]*=f,Ga.elements[5]*=f,Ga.elements[6]*=f,Ga.elements[8]*=h,Ga.elements[9]*=h,Ga.elements[10]*=h,n.setFromRotationMatrix(Ga),r.x=s,r.y=o,r.z=c,this}makePerspective(e,n,r,i,a,s,o=Ls,c=!1){const u=this.elements,f=2*a/(n-e),h=2*a/(r-i),m=(n+e)/(n-e),g=(r+i)/(r-i);let v,w;if(c)v=a/(s-a),w=s*a/(s-a);else if(o===Ls)v=-(s+a)/(s-a),w=-2*s*a/(s-a);else if(o===by)v=-s/(s-a),w=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return u[0]=f,u[4]=0,u[8]=m,u[12]=0,u[1]=0,u[5]=h,u[9]=g,u[13]=0,u[2]=0,u[6]=0,u[10]=v,u[14]=w,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,s,o=Ls,c=!1){const u=this.elements,f=2/(n-e),h=2/(r-i),m=-(n+e)/(n-e),g=-(r+i)/(r-i);let v,w;if(c)v=1/(s-a),w=s/(s-a);else if(o===Ls)v=-2/(s-a),w=-(s+a)/(s-a);else if(o===by)v=-1/(s-a),w=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return u[0]=f,u[4]=0,u[8]=0,u[12]=m,u[1]=0,u[5]=h,u[9]=0,u[13]=g,u[2]=0,u[6]=0,u[10]=v,u[14]=w,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const td=new Oe,Ga=new Nr,zce=new Oe(0,0,0),Vce=new Oe(1,1,1),ul=new Oe,Ng=new Oe,Qi=new Oe,aN=new Nr,sN=new mf;let au=class gU{constructor(e=0,n=0,r=0,i=gU.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],s=i[4],o=i[8],c=i[1],u=i[5],f=i[9],h=i[2],m=i[6],g=i[10];switch(n){case"XYZ":this._y=Math.asin(Dn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-f,g),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Dn(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(o,g),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-h,a),this._z=0);break;case"ZXY":this._x=Math.asin(Dn(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-h,g),this._z=Math.atan2(-s,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-Dn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(m,g),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-s,u));break;case"YZX":this._z=Math.asin(Dn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-f,u),this._y=Math.atan2(-h,a)):(this._x=0,this._y=Math.atan2(o,g));break;case"XZY":this._z=Math.asin(-Dn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-f,g),this._y=0);break;default:ln("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return aN.makeRotationFromQuaternion(e),this.setFromRotationMatrix(aN,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return sN.setFromEuler(this),this.setFromQuaternion(sN,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};au.DEFAULT_ORDER="XYZ";class yU{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Hce=0;const oN=new Oe,nd=new mf,ho=new Nr,Dg=new Oe,mh=new Oe,Wce=new Oe,Gce=new mf,lN=new Oe(1,0,0),cN=new Oe(0,1,0),uN=new Oe(0,0,1),dN={type:"added"},$ce={type:"removed"},rd={type:"childadded",child:null},B_={type:"childremoved",child:null};class la extends pf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Hce++}),this.uuid=Hp(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=la.DEFAULT_UP.clone();const e=new Oe,n=new au,r=new mf,i=new Oe(1,1,1);function a(){r.setFromEuler(n,!1)}function s(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Nr},normalMatrix:{value:new pn}}),this.matrix=new Nr,this.matrixWorld=new Nr,this.matrixAutoUpdate=la.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=la.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new yU,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return nd.setFromAxisAngle(e,n),this.quaternion.multiply(nd),this}rotateOnWorldAxis(e,n){return nd.setFromAxisAngle(e,n),this.quaternion.premultiply(nd),this}rotateX(e){return this.rotateOnAxis(lN,e)}rotateY(e){return this.rotateOnAxis(cN,e)}rotateZ(e){return this.rotateOnAxis(uN,e)}translateOnAxis(e,n){return oN.copy(e).applyQuaternion(this.quaternion),this.position.add(oN.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(lN,e)}translateY(e){return this.translateOnAxis(cN,e)}translateZ(e){return this.translateOnAxis(uN,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ho.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Dg.copy(e):Dg.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),mh.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ho.lookAt(mh,Dg,this.up):ho.lookAt(Dg,mh,this.up),this.quaternion.setFromRotationMatrix(ho),i&&(ho.extractRotation(i.matrixWorld),nd.setFromRotationMatrix(ho),this.quaternion.premultiply(nd.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Vn("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(dN),rd.child=e,this.dispatchEvent(rd),rd.child=null):Vn("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent($ce),B_.child=e,this.dispatchEvent(B_),B_.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ho.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ho.multiply(e.parent.matrixWorld)),e.applyMatrix4(ho),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(dN),rd.child=e,this.dispatchEvent(rd),rd.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const s=this.children[r].getObjectByProperty(e,n);if(s!==void 0)return s}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mh,e,Wce),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mh,Gce,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const n=e.x,r=e.y,i=e.z,a=this.matrix.elements;a[12]+=n-a[0]*n-a[4]*r-a[8]*i,a[13]+=r-a[1]*n-a[5]*r-a[9]*i,a[14]+=i-a[2]*n-a[6]*r-a[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function a(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let u=0,f=c.length;u<f;u++){const h=c[u];a(e.shapes,h)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,u=this.material.length;c<u;c++)o.push(a(e.materials,this.material[c]));i.material=o}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(a(e.animations,c))}}if(n){const o=s(e.geometries),c=s(e.materials),u=s(e.textures),f=s(e.images),h=s(e.shapes),m=s(e.skeletons),g=s(e.animations),v=s(e.nodes);o.length>0&&(r.geometries=o),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),f.length>0&&(r.images=f),h.length>0&&(r.shapes=h),m.length>0&&(r.skeletons=m),g.length>0&&(r.animations=g),v.length>0&&(r.nodes=v)}return r.object=i,r;function s(o){const c=[];for(const u in o){const f=o[u];delete f.metadata,c.push(f)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}la.DEFAULT_UP=new Oe(0,1,0);la.DEFAULT_MATRIX_AUTO_UPDATE=!0;la.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Lg extends la{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Yce={type:"move"};class z_{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Lg,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Lg,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Oe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Oe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Lg,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Oe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Oe),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,s=null;const o=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){s=!0;for(const w of e.hand.values()){const b=n.getJointPose(w,r),_=this._getHandJoint(u,w);b!==null&&(_.matrix.fromArray(b.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.matrixWorldNeedsUpdate=!0,_.jointRadius=b.radius),_.visible=b!==null}const f=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],m=f.position.distanceTo(h.position),g=.02,v=.005;u.inputState.pinching&&m>g+v?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=g-v&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Yce)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Lg;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}const vU={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},dl={h:0,s:0,l:0},Ig={h:0,s:0,l:0};function V_(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}class Zn{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=wa){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,jn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=jn.workingColorSpace){return this.r=e,this.g=n,this.b=r,jn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=jn.workingColorSpace){if(e=Lce(e,1),n=Dn(n,0,1),r=Dn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,s=2*r-a;this.r=V_(s,a,e+1/3),this.g=V_(s,a,e),this.b=V_(s,a,e-1/3)}return jn.colorSpaceToWorking(this,i),this}setStyle(e,n=wa){function r(a){a!==void 0&&parseFloat(a)<1&&ln("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:ln("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===6)return this.setHex(parseInt(a,16),n);ln("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=wa){const r=vU[e.toLowerCase()];return r!==void 0?this.setHex(r,n):ln("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=No(e.r),this.g=No(e.g),this.b=No(e.b),this}copyLinearToSRGB(e){return this.r=Dd(e.r),this.g=Dd(e.g),this.b=Dd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=wa){return jn.workingToColorSpace(di.copy(this),e),Math.round(Dn(di.r*255,0,255))*65536+Math.round(Dn(di.g*255,0,255))*256+Math.round(Dn(di.b*255,0,255))}getHexString(e=wa){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=jn.workingColorSpace){jn.workingToColorSpace(di.copy(this),n);const r=di.r,i=di.g,a=di.b,s=Math.max(r,i,a),o=Math.min(r,i,a);let c,u;const f=(o+s)/2;if(o===s)c=0,u=0;else{const h=s-o;switch(u=f<=.5?h/(s+o):h/(2-s-o),s){case r:c=(i-a)/h+(i<a?6:0);break;case i:c=(a-r)/h+2;break;case a:c=(r-i)/h+4;break}c/=6}return e.h=c,e.s=u,e.l=f,e}getRGB(e,n=jn.workingColorSpace){return jn.workingToColorSpace(di.copy(this),n),e.r=di.r,e.g=di.g,e.b=di.b,e}getStyle(e=wa){jn.workingToColorSpace(di.copy(this),e);const n=di.r,r=di.g,i=di.b;return e!==wa?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(dl),this.setHSL(dl.h+e,dl.s+n,dl.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,r){return this.r=e.r+(n.r-e.r)*r,this.g=e.g+(n.g-e.g)*r,this.b=e.b+(n.b-e.b)*r,this}lerpHSL(e,n){this.getHSL(dl),e.getHSL(Ig);const r=I_(dl.h,Ig.h,n),i=I_(dl.s,Ig.s,n),a=I_(dl.l,Ig.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const di=new Zn;Zn.NAMES=vU;class qce extends la{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new au,this.environmentIntensity=1,this.environmentRotation=new au,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(n.object.environmentIntensity=this.environmentIntensity),n.object.environmentRotation=this.environmentRotation.toArray(),n}}const $a=new Oe,po=new Oe,H_=new Oe,mo=new Oe,id=new Oe,ad=new Oe,fN=new Oe,W_=new Oe,G_=new Oe,$_=new Oe,Y_=new yr,q_=new yr,X_=new yr;let gh=class xd{constructor(e=new Oe,n=new Oe,r=new Oe){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),$a.subVectors(e,n),i.cross($a);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){$a.subVectors(i,n),po.subVectors(r,n),H_.subVectors(e,n);const s=$a.dot($a),o=$a.dot(po),c=$a.dot(H_),u=po.dot(po),f=po.dot(H_),h=s*u-o*o;if(h===0)return a.set(0,0,0),null;const m=1/h,g=(u*c-o*f)*m,v=(s*f-o*c)*m;return a.set(1-g-v,v,g)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,mo)===null?!1:mo.x>=0&&mo.y>=0&&mo.x+mo.y<=1}static getInterpolation(e,n,r,i,a,s,o,c){return this.getBarycoord(e,n,r,i,mo)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(a,mo.x),c.addScaledVector(s,mo.y),c.addScaledVector(o,mo.z),c)}static getInterpolatedAttribute(e,n,r,i,a,s){return Y_.setScalar(0),q_.setScalar(0),X_.setScalar(0),Y_.fromBufferAttribute(e,n),q_.fromBufferAttribute(e,r),X_.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(Y_,a.x),s.addScaledVector(q_,a.y),s.addScaledVector(X_,a.z),s}static isFrontFacing(e,n,r,i){return $a.subVectors(r,n),po.subVectors(e,n),$a.cross(po).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return $a.subVectors(this.c,this.b),po.subVectors(this.a,this.b),$a.cross(po).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return xd.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return xd.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return xd.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return xd.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return xd.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let s,o;id.subVectors(i,r),ad.subVectors(a,r),W_.subVectors(e,r);const c=id.dot(W_),u=ad.dot(W_);if(c<=0&&u<=0)return n.copy(r);G_.subVectors(e,i);const f=id.dot(G_),h=ad.dot(G_);if(f>=0&&h<=f)return n.copy(i);const m=c*h-f*u;if(m<=0&&c>=0&&f<=0)return s=c/(c-f),n.copy(r).addScaledVector(id,s);$_.subVectors(e,a);const g=id.dot($_),v=ad.dot($_);if(v>=0&&g<=v)return n.copy(a);const w=g*u-c*v;if(w<=0&&u>=0&&v<=0)return o=u/(u-v),n.copy(r).addScaledVector(ad,o);const b=f*v-g*h;if(b<=0&&h-f>=0&&g-v>=0)return fN.subVectors(a,i),o=(h-f)/(h-f+(g-v)),n.copy(i).addScaledVector(fN,o);const _=1/(b+w+m);return s=w*_,o=m*_,n.copy(r).addScaledVector(id,s).addScaledVector(ad,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};class Wp{constructor(e=new Oe(1/0,1/0,1/0),n=new Oe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(Ya.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Ya.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=Ya.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,Ya):Ya.fromBufferAttribute(a,s),Ya.applyMatrix4(e.matrixWorld),this.expandByPoint(Ya);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Og.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Og.copy(r.boundingBox)),Og.applyMatrix4(e.matrixWorld),this.union(Og)}const i=e.children;for(let a=0,s=i.length;a<s;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ya),Ya.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(yh),Fg.subVectors(this.max,yh),sd.subVectors(e.a,yh),od.subVectors(e.b,yh),ld.subVectors(e.c,yh),fl.subVectors(od,sd),hl.subVectors(ld,od),yc.subVectors(sd,ld);let n=[0,-fl.z,fl.y,0,-hl.z,hl.y,0,-yc.z,yc.y,fl.z,0,-fl.x,hl.z,0,-hl.x,yc.z,0,-yc.x,-fl.y,fl.x,0,-hl.y,hl.x,0,-yc.y,yc.x,0];return!K_(n,sd,od,ld,Fg)||(n=[1,0,0,0,1,0,0,0,1],!K_(n,sd,od,ld,Fg))?!1:(Ug.crossVectors(fl,hl),n=[Ug.x,Ug.y,Ug.z],K_(n,sd,od,ld,Fg))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ya).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ya).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(go[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),go[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),go[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),go[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),go[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),go[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),go[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),go[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(go),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const go=[new Oe,new Oe,new Oe,new Oe,new Oe,new Oe,new Oe,new Oe],Ya=new Oe,Og=new Wp,sd=new Oe,od=new Oe,ld=new Oe,fl=new Oe,hl=new Oe,yc=new Oe,yh=new Oe,Fg=new Oe,Ug=new Oe,vc=new Oe;function K_(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){vc.fromArray(t,a);const o=i.x*Math.abs(vc.x)+i.y*Math.abs(vc.y)+i.z*Math.abs(vc.z),c=e.dot(vc),u=n.dot(vc),f=r.dot(vc);if(Math.max(-Math.max(c,u,f),Math.min(c,u,f))>o)return!1}return!0}const Er=new Oe,jg=new $n;let Xce=0;class as{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Xce++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=JR,this.updateRanges=[],this.gpuType=Ds,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)jg.fromBufferAttribute(this,n),jg.applyMatrix3(e),this.setXY(n,jg.x,jg.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.applyMatrix3(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.applyMatrix4(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.applyNormalMatrix(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.transformDirection(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=ph(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Ii(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=ph(n,this.array)),n}setX(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=ph(n,this.array)),n}setY(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=ph(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=ph(n,this.array)),n}setW(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Ii(n,this.array),r=Ii(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=Ii(n,this.array),r=Ii(r,this.array),i=Ii(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=Ii(n,this.array),r=Ii(r,this.array),i=Ii(i,this.array),a=Ii(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==JR&&(e.usage=this.usage),e}}class xU extends as{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class bU extends as{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Do extends as{constructor(e,n,r){super(new Float32Array(e),n,r)}}const Kce=new Wp,vh=new Oe,Z_=new Oe;class iM{constructor(e=new Oe,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):Kce.setFromPoints(e).getCenter(r);let i=0;for(let a=0,s=e.length;a<s;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;vh.subVectors(e,this.center);const n=vh.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(vh,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Z_.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(vh.copy(e.center).add(Z_)),this.expandByPoint(vh.copy(e.center).sub(Z_))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let Zce=0;const va=new Nr,J_=new la,cd=new Oe,ea=new Wp,xh=new Wp,Yr=new Oe;class eo extends pf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Zce++}),this.uuid=Hp(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Pce(e)?bU:xU)(e,1):this.index=e,this}setIndirect(e,n=0){return this.indirect=e,this.indirectOffset=n,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new pn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return va.makeRotationFromQuaternion(e),this.applyMatrix4(va),this}rotateX(e){return va.makeRotationX(e),this.applyMatrix4(va),this}rotateY(e){return va.makeRotationY(e),this.applyMatrix4(va),this}rotateZ(e){return va.makeRotationZ(e),this.applyMatrix4(va),this}translate(e,n,r){return va.makeTranslation(e,n,r),this.applyMatrix4(va),this}scale(e,n,r){return va.makeScale(e,n,r),this.applyMatrix4(va),this}lookAt(e){return J_.lookAt(e),J_.updateMatrix(),this.applyMatrix4(J_.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(cd).negate(),this.translate(cd.x,cd.y,cd.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,a=e.length;i<a;i++){const s=e[i];r.push(s.x,s.y,s.z||0)}this.setAttribute("position",new Do(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const a=e[i];n.setXYZ(i,a.x,a.y,a.z||0)}e.length>n.count&&ln("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Wp);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Vn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Oe(-1/0,-1/0,-1/0),new Oe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];ea.setFromBufferAttribute(a),this.morphTargetsRelative?(Yr.addVectors(this.boundingBox.min,ea.min),this.boundingBox.expandByPoint(Yr),Yr.addVectors(this.boundingBox.max,ea.max),this.boundingBox.expandByPoint(Yr)):(this.boundingBox.expandByPoint(ea.min),this.boundingBox.expandByPoint(ea.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Vn('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new iM);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Vn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Oe,1/0);return}if(e){const r=this.boundingSphere.center;if(ea.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];xh.setFromBufferAttribute(o),this.morphTargetsRelative?(Yr.addVectors(ea.min,xh.min),ea.expandByPoint(Yr),Yr.addVectors(ea.max,xh.max),ea.expandByPoint(Yr)):(ea.expandByPoint(xh.min),ea.expandByPoint(xh.max))}ea.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)Yr.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Yr));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],c=this.morphTargetsRelative;for(let u=0,f=o.count;u<f;u++)Yr.fromBufferAttribute(o,u),c&&(cd.fromBufferAttribute(e,u),Yr.add(cd)),i=Math.max(i,r.distanceToSquared(Yr))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Vn('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){Vn("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,a=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new as(new Float32Array(4*r.count),4));const s=this.getAttribute("tangent"),o=[],c=[];for(let k=0;k<r.count;k++)o[k]=new Oe,c[k]=new Oe;const u=new Oe,f=new Oe,h=new Oe,m=new $n,g=new $n,v=new $n,w=new Oe,b=new Oe;function _(k,N,B){u.fromBufferAttribute(r,k),f.fromBufferAttribute(r,N),h.fromBufferAttribute(r,B),m.fromBufferAttribute(a,k),g.fromBufferAttribute(a,N),v.fromBufferAttribute(a,B),f.sub(u),h.sub(u),g.sub(m),v.sub(m);const L=1/(g.x*v.y-v.x*g.y);isFinite(L)&&(w.copy(f).multiplyScalar(v.y).addScaledVector(h,-g.y).multiplyScalar(L),b.copy(h).multiplyScalar(g.x).addScaledVector(f,-v.x).multiplyScalar(L),o[k].add(w),o[N].add(w),o[B].add(w),c[k].add(b),c[N].add(b),c[B].add(b))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let k=0,N=E.length;k<N;++k){const B=E[k],L=B.start,z=B.count;for(let I=L,V=L+z;I<V;I+=3)_(e.getX(I+0),e.getX(I+1),e.getX(I+2))}const M=new Oe,T=new Oe,P=new Oe,A=new Oe;function R(k){P.fromBufferAttribute(i,k),A.copy(P);const N=o[k];M.copy(N),M.sub(P.multiplyScalar(P.dot(N))).normalize(),T.crossVectors(A,N);const L=T.dot(c[k])<0?-1:1;s.setXYZW(k,M.x,M.y,M.z,L)}for(let k=0,N=E.length;k<N;++k){const B=E[k],L=B.start,z=B.count;for(let I=L,V=L+z;I<V;I+=3)R(e.getX(I+0)),R(e.getX(I+1)),R(e.getX(I+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new as(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,g=r.count;m<g;m++)r.setXYZ(m,0,0,0);const i=new Oe,a=new Oe,s=new Oe,o=new Oe,c=new Oe,u=new Oe,f=new Oe,h=new Oe;if(e)for(let m=0,g=e.count;m<g;m+=3){const v=e.getX(m+0),w=e.getX(m+1),b=e.getX(m+2);i.fromBufferAttribute(n,v),a.fromBufferAttribute(n,w),s.fromBufferAttribute(n,b),f.subVectors(s,a),h.subVectors(i,a),f.cross(h),o.fromBufferAttribute(r,v),c.fromBufferAttribute(r,w),u.fromBufferAttribute(r,b),o.add(f),c.add(f),u.add(f),r.setXYZ(v,o.x,o.y,o.z),r.setXYZ(w,c.x,c.y,c.z),r.setXYZ(b,u.x,u.y,u.z)}else for(let m=0,g=n.count;m<g;m+=3)i.fromBufferAttribute(n,m+0),a.fromBufferAttribute(n,m+1),s.fromBufferAttribute(n,m+2),f.subVectors(s,a),h.subVectors(i,a),f.cross(h),r.setXYZ(m+0,f.x,f.y,f.z),r.setXYZ(m+1,f.x,f.y,f.z),r.setXYZ(m+2,f.x,f.y,f.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Yr.fromBufferAttribute(e,n),Yr.normalize(),e.setXYZ(n,Yr.x,Yr.y,Yr.z)}toNonIndexed(){function e(o,c){const u=o.array,f=o.itemSize,h=o.normalized,m=new u.constructor(c.length*f);let g=0,v=0;for(let w=0,b=c.length;w<b;w++){o.isInterleavedBufferAttribute?g=c[w]*o.data.stride+o.offset:g=c[w]*f;for(let _=0;_<f;_++)m[v++]=u[g++]}return new as(m,f,h)}if(this.index===null)return ln("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new eo,r=this.index.array,i=this.attributes;for(const o in i){const c=i[o],u=e(c,r);n.setAttribute(o,u)}const a=this.morphAttributes;for(const o in a){const c=[],u=a[o];for(let f=0,h=u.length;f<h;f++){const m=u[f],g=e(m,r);c.push(g)}n.morphAttributes[o]=c}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,c=s.length;o<c;o++){const u=s[o];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],f=[];for(let h=0,m=u.length;h<m;h++){const g=u[h];f.push(g.toJSON(e.data))}f.length>0&&(i[c]=f,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const f=i[u];this.setAttribute(u,f.clone(n))}const a=e.morphAttributes;for(const u in a){const f=[],h=a[u];for(let m=0,g=h.length;m<g;m++)f.push(h[m].clone(n));this.morphAttributes[u]=f}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let u=0,f=s.length;u<f;u++){const h=s[u];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}let Jce=0;class hv extends pf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Jce++}),this.uuid=Hp(),this.name="",this.type="Material",this.blending=Hc,this.side=Ol,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=j1,this.blendDst=B1,this.blendEquation=Tc,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Zn(0,0,0),this.blendAlpha=0,this.depthFunc=qd,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ZR,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Qu,this.stencilZFail=Qu,this.stencilZPass=Qu,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const r=e[n];if(r===void 0){ln(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){ln(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Hc&&(r.blending=this.blending),this.side!==Ol&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==j1&&(r.blendSrc=this.blendSrc),this.blendDst!==B1&&(r.blendDst=this.blendDst),this.blendEquation!==Tc&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==qd&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ZR&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Qu&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Qu&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Qu&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.allowOverride===!1&&(r.allowOverride=!1),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const s=[];for(const o in a){const c=a[o];delete c.metadata,s.push(c)}return s}if(n){const a=i(e.textures),s=i(e.images);a.length>0&&(r.textures=a),s.length>0&&(r.images=s)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const yo=new Oe,Q_=new Oe,Bg=new Oe,pl=new Oe,ew=new Oe,zg=new Oe,tw=new Oe;class Qce{constructor(e=new Oe,n=new Oe(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,yo)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=yo.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(yo.copy(this.origin).addScaledVector(this.direction,n),yo.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){Q_.copy(e).add(n).multiplyScalar(.5),Bg.copy(n).sub(e).normalize(),pl.copy(this.origin).sub(Q_);const a=e.distanceTo(n)*.5,s=-this.direction.dot(Bg),o=pl.dot(this.direction),c=-pl.dot(Bg),u=pl.lengthSq(),f=Math.abs(1-s*s);let h,m,g,v;if(f>0)if(h=s*c-o,m=s*o-c,v=a*f,h>=0)if(m>=-v)if(m<=v){const w=1/f;h*=w,m*=w,g=h*(h+s*m+2*o)+m*(s*h+m+2*c)+u}else m=a,h=Math.max(0,-(s*m+o)),g=-h*h+m*(m+2*c)+u;else m=-a,h=Math.max(0,-(s*m+o)),g=-h*h+m*(m+2*c)+u;else m<=-v?(h=Math.max(0,-(-s*a+o)),m=h>0?-a:Math.min(Math.max(-a,-c),a),g=-h*h+m*(m+2*c)+u):m<=v?(h=0,m=Math.min(Math.max(-a,-c),a),g=m*(m+2*c)+u):(h=Math.max(0,-(s*a+o)),m=h>0?a:Math.min(Math.max(-a,-c),a),g=-h*h+m*(m+2*c)+u);else m=s>0?-a:a,h=Math.max(0,-(s*m+o)),g=-h*h+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Q_).addScaledVector(Bg,m),g}intersectSphere(e,n){yo.subVectors(e.center,this.origin);const r=yo.dot(this.direction),i=yo.dot(yo)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),o=r-s,c=r+s;return c<0?null:o<0?this.at(c,n):this.at(o,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,s,o,c;const u=1/this.direction.x,f=1/this.direction.y,h=1/this.direction.z,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),f>=0?(a=(e.min.y-m.y)*f,s=(e.max.y-m.y)*f):(a=(e.max.y-m.y)*f,s=(e.min.y-m.y)*f),r>s||a>i||((a>r||isNaN(r))&&(r=a),(s<i||isNaN(i))&&(i=s),h>=0?(o=(e.min.z-m.z)*h,c=(e.max.z-m.z)*h):(o=(e.max.z-m.z)*h,c=(e.min.z-m.z)*h),r>c||o>i)||((o>r||r!==r)&&(r=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,yo)!==null}intersectTriangle(e,n,r,i,a){ew.subVectors(n,e),zg.subVectors(r,e),tw.crossVectors(ew,zg);let s=this.direction.dot(tw),o;if(s>0){if(i)return null;o=1}else if(s<0)o=-1,s=-s;else return null;pl.subVectors(this.origin,e);const c=o*this.direction.dot(zg.crossVectors(pl,zg));if(c<0)return null;const u=o*this.direction.dot(ew.cross(pl));if(u<0||c+u>s)return null;const f=-o*pl.dot(tw);return f<0?null:this.at(f/s,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class _U extends hv{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Zn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new au,this.combine=JF,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const hN=new Nr,xc=new Qce,Vg=new iM,pN=new Oe,Hg=new Oe,Wg=new Oe,Gg=new Oe,nw=new Oe,$g=new Oe,mN=new Oe,Yg=new Oe;let Ys=class extends la{constructor(e=new eo,n=new _U){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(a&&o){$g.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const f=o[c],h=a[c];f!==0&&(nw.fromBufferAttribute(h,e),s?$g.addScaledVector(nw,f):$g.addScaledVector(nw.sub(n),f))}n.add($g)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),Vg.copy(r.boundingSphere),Vg.applyMatrix4(a),xc.copy(e.ray).recast(e.near),!(Vg.containsPoint(xc.origin)===!1&&(xc.intersectSphere(Vg,pN)===null||xc.origin.distanceToSquared(pN)>(e.far-e.near)**2))&&(hN.copy(a).invert(),xc.copy(e.ray).applyMatrix4(hN),!(r.boundingBox!==null&&xc.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,xc)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,o=a.index,c=a.attributes.position,u=a.attributes.uv,f=a.attributes.uv1,h=a.attributes.normal,m=a.groups,g=a.drawRange;if(o!==null)if(Array.isArray(s))for(let v=0,w=m.length;v<w;v++){const b=m[v],_=s[b.materialIndex],E=Math.max(b.start,g.start),M=Math.min(o.count,Math.min(b.start+b.count,g.start+g.count));for(let T=E,P=M;T<P;T+=3){const A=o.getX(T),R=o.getX(T+1),k=o.getX(T+2);i=qg(this,_,e,r,u,f,h,A,R,k),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const v=Math.max(0,g.start),w=Math.min(o.count,g.start+g.count);for(let b=v,_=w;b<_;b+=3){const E=o.getX(b),M=o.getX(b+1),T=o.getX(b+2);i=qg(this,s,e,r,u,f,h,E,M,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(s))for(let v=0,w=m.length;v<w;v++){const b=m[v],_=s[b.materialIndex],E=Math.max(b.start,g.start),M=Math.min(c.count,Math.min(b.start+b.count,g.start+g.count));for(let T=E,P=M;T<P;T+=3){const A=T,R=T+1,k=T+2;i=qg(this,_,e,r,u,f,h,A,R,k),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const v=Math.max(0,g.start),w=Math.min(c.count,g.start+g.count);for(let b=v,_=w;b<_;b+=3){const E=b,M=b+1,T=b+2;i=qg(this,s,e,r,u,f,h,E,M,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}};function eue(t,e,n,r,i,a,s,o){let c;if(e.side===zi?c=r.intersectTriangle(s,a,i,!0,o):c=r.intersectTriangle(i,a,s,e.side===Ol,o),c===null)return null;Yg.copy(o),Yg.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Yg);return u<n.near||u>n.far?null:{distance:u,point:Yg.clone(),object:t}}function qg(t,e,n,r,i,a,s,o,c,u){t.getVertexPosition(o,Hg),t.getVertexPosition(c,Wg),t.getVertexPosition(u,Gg);const f=eue(t,e,n,r,Hg,Wg,Gg,mN);if(f){const h=new Oe;gh.getBarycoord(mN,Hg,Wg,Gg,h),i&&(f.uv=gh.getInterpolatedAttribute(i,o,c,u,h,new $n)),a&&(f.uv1=gh.getInterpolatedAttribute(a,o,c,u,h,new $n)),s&&(f.normal=gh.getInterpolatedAttribute(s,o,c,u,h,new Oe),f.normal.dot(r.direction)>0&&f.normal.multiplyScalar(-1));const m={a:o,b:c,c:u,normal:new Oe,materialIndex:0};gh.getNormal(Hg,Wg,Gg,m.normal),f.face=m,f.barycoord=h}return f}class tue extends Ti{constructor(e=null,n=1,r=1,i,a,s,o,c,u=ni,f=ni,h,m){super(null,s,o,c,u,f,i,a,h,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const rw=new Oe,nue=new Oe,rue=new pn;class Mc{constructor(e=new Oe(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=rw.subVectors(r,n).cross(nue.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n){const r=e.delta(rw),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||rue.getNormalMatrix(e),i=this.coplanarPoint(rw).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const bc=new iM,iue=new $n(.5,.5),Xg=new Oe;class wU{constructor(e=new Mc,n=new Mc,r=new Mc,i=new Mc,a=new Mc,s=new Mc){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(a),o[5].copy(s),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Ls,r=!1){const i=this.planes,a=e.elements,s=a[0],o=a[1],c=a[2],u=a[3],f=a[4],h=a[5],m=a[6],g=a[7],v=a[8],w=a[9],b=a[10],_=a[11],E=a[12],M=a[13],T=a[14],P=a[15];if(i[0].setComponents(u-s,g-f,_-v,P-E).normalize(),i[1].setComponents(u+s,g+f,_+v,P+E).normalize(),i[2].setComponents(u+o,g+h,_+w,P+M).normalize(),i[3].setComponents(u-o,g-h,_-w,P-M).normalize(),r)i[4].setComponents(c,m,b,T).normalize(),i[5].setComponents(u-c,g-m,_-b,P-T).normalize();else if(i[4].setComponents(u-c,g-m,_-b,P-T).normalize(),n===Ls)i[5].setComponents(u+c,g+m,_+b,P+T).normalize();else if(n===by)i[5].setComponents(c,m,b,T).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),bc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),bc.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(bc)}intersectsSprite(e){bc.center.set(0,0,0);const n=iue.distanceTo(e.center);return bc.radius=.7071067811865476+n,bc.applyMatrix4(e.matrixWorld),this.intersectsSphere(bc)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(Xg.x=i.normal.x>0?e.max.x:e.min.x,Xg.y=i.normal.y>0?e.max.y:e.min.y,Xg.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Xg)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class SU extends Ti{constructor(e=[],n=ru,r,i,a,s,o,c,u,f){super(e,n,r,i,a,s,o,c,u,f),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class hp extends Ti{constructor(e,n,r=$s,i,a,s,o=ni,c=ni,u,f=jo,h=1){if(f!==jo&&f!==Uc)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:n,depth:h};super(m,i,a,s,o,c,f,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new rM(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}class aue extends hp{constructor(e,n=$s,r=ru,i,a,s=ni,o=ni,c,u=jo){const f={width:e,height:e,depth:1},h=[f,f,f,f,f,f];super(e,e,n,r,i,a,s,o,c,u),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class kU extends Ti{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Gp extends eo{constructor(e=1,n=1,r=1,i=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:s};const o=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const c=[],u=[],f=[],h=[];let m=0,g=0;v("z","y","x",-1,-1,r,n,e,s,a,0),v("z","y","x",1,-1,r,n,-e,s,a,1),v("x","z","y",1,1,e,r,n,i,s,2),v("x","z","y",1,-1,e,r,-n,i,s,3),v("x","y","z",1,-1,e,n,r,i,a,4),v("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Do(u,3)),this.setAttribute("normal",new Do(f,3)),this.setAttribute("uv",new Do(h,2));function v(w,b,_,E,M,T,P,A,R,k,N){const B=T/R,L=P/k,z=T/2,I=P/2,V=A/2,W=R+1,X=k+1;let J=0,F=0;const G=new Oe;for(let Y=0;Y<X;Y++){const H=Y*L-I;for(let te=0;te<W;te++){const re=te*B-z;G[w]=re*E,G[b]=H*M,G[_]=V,u.push(G.x,G.y,G.z),G[w]=0,G[b]=0,G[_]=A>0?1:-1,f.push(G.x,G.y,G.z),h.push(te/R),h.push(1-Y/k),J+=1}}for(let Y=0;Y<k;Y++)for(let H=0;H<R;H++){const te=m+H+W*Y,re=m+H+W*(Y+1),ue=m+(H+1)+W*(Y+1),ce=m+(H+1)+W*Y;c.push(te,re,ce),c.push(re,ue,ce),F+=6}o.addGroup(g,F,N),g+=F,m+=J}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Gp(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class pv extends eo{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,s=n/2,o=Math.floor(r),c=Math.floor(i),u=o+1,f=c+1,h=e/o,m=n/c,g=[],v=[],w=[],b=[];for(let _=0;_<f;_++){const E=_*m-s;for(let M=0;M<u;M++){const T=M*h-a;v.push(T,-E,0),w.push(0,0,1),b.push(M/o),b.push(1-_/c)}}for(let _=0;_<c;_++)for(let E=0;E<o;E++){const M=E+u*_,T=E+u*(_+1),P=E+1+u*(_+1),A=E+1+u*_;g.push(M,T,A),g.push(T,P,A)}this.setIndex(g),this.setAttribute("position",new Do(v,3)),this.setAttribute("normal",new Do(w,3)),this.setAttribute("uv",new Do(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pv(e.width,e.height,e.widthSegments,e.heightSegments)}}function Zd(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(ln("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function wi(t){const e={};for(let n=0;n<t.length;n++){const r=Zd(t[n]);for(const i in r)e[i]=r[i]}return e}function sue(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function EU(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:jn.workingColorSpace}const oue={clone:Zd,merge:wi};var lue=`void main() {
|
|
865
865
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
866
866
|
}`,cue=`void main() {
|
|
867
867
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
@@ -5221,4 +5221,4 @@ void main() {
|
|
|
5221
5221
|
While dragging, use the arrow keys to move the item.
|
|
5222
5222
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
5223
5223
|
`},l0e={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 c0e(t){let{announcements:e=l0e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=o0e}=t;const{announce:a,announcement:s}=i0e(),o=qp("DndLiveRegion"),[c,u]=x.useState(!1);if(x.useEffect(()=>{u(!0)},[]),a0e(x.useMemo(()=>({onDragStart(h){let{active:m}=h;a(e.onDragStart({active:m}))},onDragMove(h){let{active:m,over:g}=h;e.onDragMove&&a(e.onDragMove({active:m,over:g}))},onDragOver(h){let{active:m,over:g}=h;a(e.onDragOver({active:m,over:g}))},onDragEnd(h){let{active:m,over:g}=h;a(e.onDragEnd({active:m,over:g}))},onDragCancel(h){let{active:m,over:g}=h;a(e.onDragCancel({active:m,over:g}))}}),[a,e])),!c)return null;const f=ot.createElement(ot.Fragment,null,ot.createElement(n0e,{id:r,value:i.draggable}),ot.createElement(r0e,{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 Ey(){}function lD(t,e){return x.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function u0e(){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 ss=Object.freeze({x:0,y:0});function zU(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function VU(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function d0e(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function cD(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 HU(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function uD(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 f0e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=uD(e,e.left,e.top),a=[];for(const s of r){const{id:o}=s,c=n.get(o);if(c){const u=zU(uD(c),i);a.push({id:o,data:{droppableContainer:s,value:u}})}}return a.sort(VU)},h0e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=cD(e),a=[];for(const s of r){const{id:o}=s,c=n.get(o);if(c){const u=cD(c),f=i.reduce((m,g,v)=>m+zU(u[v],g),0),h=Number((f/4).toFixed(4));a.push({id:o,data:{droppableContainer:s,value:h}})}}return a.sort(VU)};function p0e(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 m0e=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=p0e(o,e);c>0&&i.push({id:s,data:{droppableContainer:a,value:c}})}}return i.sort(d0e)};function g0e(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function WU(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:ss}function y0e(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 v0e=y0e(1);function x0e(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 b0e(t,e,n){const r=x0e(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 _0e={ignoreTransform:!1};function xf(t,e){e===void 0&&(e=_0e);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:f}=Gi(t).getComputedStyle(t);u&&(n=b0e(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 dD(t){return xf(t,{ignoreTransform:!0})}function w0e(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function S0e(t,e){return e===void 0&&(e=Gi(t).getComputedStyle(t)),e.position==="fixed"}function k0e(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 vv(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(oM(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!$p(i)||UU(i)||n.includes(i))return n;const a=Gi(t).getComputedStyle(i);return i!==t&&k0e(i,a)&&n.push(i),S0e(i,a)?n:r(i.parentNode)}return t?r(t):n}function GU(t){const[e]=vv(t,1);return e??null}function mw(t){return!yv||!t?null:yf(t)?t:sM(t)?oM(t)||t===vf(t).scrollingElement?window:$p(t)?t:null:null}function $U(t){return yf(t)?t.scrollX:t.scrollLeft}function YU(t){return yf(t)?t.scrollY:t.scrollTop}function IS(t){return{x:$U(t),y:YU(t)}}var qr;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(qr||(qr={}));function qU(t){return!yv||!t?!1:t===document.scrollingElement}function XU(t){const e={x:0,y:0},n=qU(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 E0e={x:.2,y:.2};function M0e(t,e,n,r,i){let{top:a,left:s,right:o,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=E0e);const{isTop:u,isBottom:f,isLeft:h,isRight:m}=XU(t),g={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?(g.y=qr.Backward,v.y=r*Math.abs((e.top+w.height-a)/w.height)):!f&&c>=e.bottom-w.height&&(g.y=qr.Forward,v.y=r*Math.abs((e.bottom-w.height-c)/w.height)),!m&&o>=e.right-w.width?(g.x=qr.Forward,v.x=r*Math.abs((e.right-w.width-o)/w.width)):!h&&s<=e.left+w.width&&(g.x=qr.Backward,v.x=r*Math.abs((e.left+w.width-s)/w.width)),{direction:g,speed:v}}function T0e(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 KU(t){return t.reduce((e,n)=>Ld(e,IS(n)),ss)}function C0e(t){return t.reduce((e,n)=>e+$U(n),0)}function A0e(t){return t.reduce((e,n)=>e+YU(n),0)}function P0e(t,e){if(e===void 0&&(e=xf),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);GU(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const R0e=[["x",["left","right"],C0e],["y",["top","bottom"],A0e]];class uM{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=vv(n),i=KU(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,s,o]of R0e)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 Wh{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 N0e(t){const{EventTarget:e}=Gi(t);return t instanceof e?t:vf(t)}function gw(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 fD(t){t.preventDefault()}function D0e(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 ZU={start:[Nn.Space,Nn.Enter],cancel:[Nn.Esc],end:[Nn.Space,Nn.Enter,Nn.Tab]},L0e=(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 dM{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 Wh(vf(n)),this.windowListeners=new Wh(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&&P0e(r),n(ss)}handleKeyDown(e){if(cM(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=ZU,coordinateGetter:s=L0e,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}:ss;this.referenceCoordinates||(this.referenceCoordinates=f);const h=s(e,{active:n,context:r.current,currentCoordinates:f});if(h){const m=mp(h,f),g={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:P,minScroll:A}=XU(w),R=T0e(w),k={x:Math.min(b===Nn.Right?R.right-R.width/2:R.right,Math.max(b===Nn.Right?R.left:R.left+R.width/2,h.x)),y:Math.min(b===Nn.Down?R.bottom-R.height/2:R.bottom,Math.max(b===Nn.Down?R.top:R.top+R.height/2,h.y))},N=b===Nn.Right&&!E||b===Nn.Left&&!M,B=b===Nn.Down&&!T||b===Nn.Up&&!_;if(N&&k.x!==h.x){const L=w.scrollLeft+m.x,z=b===Nn.Right&&L<=P.x||b===Nn.Left&&L>=A.x;if(z&&!m.y){w.scrollTo({left:L,behavior:o});return}z?g.x=w.scrollLeft-L:g.x=b===Nn.Right?w.scrollLeft-P.x:w.scrollLeft-A.x,g.x&&w.scrollBy({left:-g.x,behavior:o});break}else if(B&&k.y!==h.y){const L=w.scrollTop+m.y,z=b===Nn.Down&&L<=P.y||b===Nn.Up&&L>=A.y;if(z&&!m.x){w.scrollTo({top:L,behavior:o});return}z?g.y=w.scrollTop-L:g.y=b===Nn.Down?w.scrollTop-P.y:w.scrollTop-A.y,g.y&&w.scrollBy({top:-g.y,behavior:o});break}}this.handleMove(e,Ld(mp(h,this.referenceCoordinates),g))}}}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()}}dM.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=ZU,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 hD(t){return!!(t&&"distance"in t)}function pD(t){return!!(t&&"delay"in t)}class fM{constructor(e,n,r){var i;r===void 0&&(r=N0e(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=vf(s),this.documentListeners=new Wh(this.document),this.listeners=new Wh(r),this.windowListeners=new Wh(Gi(s)),this.initialCoordinates=(i=LS(a))!=null?i:ss,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,fD),this.windowListeners.add(Sa.VisibilityChange,this.handleCancel),this.windowListeners.add(Sa.ContextMenu,fD),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(pD(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(hD(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,D0e,{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=LS(e))!=null?n:ss,u=mp(i,c);if(!r&&o){if(hD(o)){if(o.tolerance!=null&&gw(u,o.tolerance))return this.handleCancel();if(gw(u,o.distance))return this.handleStart()}if(pD(o)&&gw(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 I0e={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class hM extends fM{constructor(e){const{event:n}=e,r=vf(n.target);super(e,I0e,r)}}hM.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 O0e={move:{name:"mousemove"},end:{name:"mouseup"}};var OS;(function(t){t[t.RightClick=2]="RightClick"})(OS||(OS={}));class F0e extends fM{constructor(e){super(e,O0e,vf(e.event.target))}}F0e.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===OS.RightClick?!1:(r?.({event:n}),!0)}}];const yw={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class U0e extends fM{constructor(e){super(e,yw)}static setup(){return window.addEventListener(yw.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(yw.move.name,e)};function e(){}}}U0e.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 Gh;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Gh||(Gh={}));var My;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(My||(My={}));function j0e(t){let{acceleration:e,activator:n=Gh.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:s=5,order:o=My.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:f,delta:h,threshold:m}=t;const g=z0e({delta:h,disabled:!a}),[v,w]=Zge(),b=x.useRef({x:0,y:0}),_=x.useRef({x:0,y:0}),E=x.useMemo(()=>{switch(n){case Gh.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Gh.DraggableRect:return i}},[n,i,c]),M=x.useRef(null),T=x.useCallback(()=>{const A=M.current;if(!A)return;const R=b.current.x*_.current.x,k=b.current.y*_.current.y;A.scrollBy(R,k)},[]),P=x.useMemo(()=>o===My.TreeOrder?[...u].reverse():u,[o,u]);x.useEffect(()=>{if(!a||!u.length||!E){w();return}for(const A of P){if(r?.(A)===!1)continue;const R=u.indexOf(A),k=f[R];if(!k)continue;const{direction:N,speed:B}=M0e(A,k,E,e,m);for(const L of["x","y"])g[L][N[L]]||(B[L]=0,N[L]=0);if(B.x>0||B.y>0){w(),M.current=A,v(T,s),b.current=B,_.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(g),v,u,P,f,JSON.stringify(m)])}const B0e={x:{[qr.Backward]:!1,[qr.Forward]:!1},y:{[qr.Backward]:!1,[qr.Forward]:!1}};function z0e(t){let{delta:e,disabled:n}=t;const r=DS(e);return Yp(i=>{if(n||!r||!i)return B0e;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 V0e(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Yp(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function H0e(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 yp;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(yp||(yp={}));var FS;(function(t){t.Optimized="optimized"})(FS||(FS={}));const mD=new Map;function W0e(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(),m=pp(h),g=x.useCallback(function(_){_===void 0&&(_=[]),!m.current&&s(E=>E===null?_:E.concat(_.filter(M=>!E.includes(M))))},[m]),v=x.useRef(null),w=Yp(_=>{if(h&&!n)return mD;if(!_||_===mD||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,P=T?new uM(c(T),T):null;M.rect.current=P,P&&E.set(M.id,P)}return E}return _},[t,a,n,h,c]);return x.useEffect(()=>{f.current=t},[t]),x.useEffect(()=>{h||g()},[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(()=>{g(),v.current=null},o))},[o,h,g,...r]),{droppableRects:w,measureDroppableContainers:g,measuringScheduled:a!=null};function b(){switch(u){case yp.Always:return!1;case yp.BeforeDragging:return n;default:return!n}}}function JU(t,e){return Yp(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function G0e(t,e){return JU(t,e)}function $0e(t){let{callback:e,disabled:n}=t;const r=lM(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 xv(t){let{callback:e,disabled:n}=t;const r=lM(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 Y0e(t){return new uM(xf(t),t)}function gD(t,e,n){e===void 0&&(e=Y0e);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=$0e({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=xv({callback:a});return Xs(()=>{a(),t?(o?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),s?.disconnect())},[t]),r}function q0e(t){const e=JU(t);return WU(t,e)}const yD=[];function X0e(t){const e=x.useRef(t),n=Yp(r=>t?r&&r!==yD&&t&&e.current&&t.parentNode===e.current.parentNode?r:vv(t):yD,[t]);return x.useEffect(()=>{e.current=t},[t]),n}function K0e(t){const[e,n]=x.useState(null),r=x.useRef(t),i=x.useCallback(a=>{const s=mw(a.target);s&&n(o=>o?(o.set(s,IS(s)),new Map(o)):null)},[]);return x.useEffect(()=>{const a=r.current;if(t!==a){s(a);const o=t.map(c=>{const u=mw(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,IS(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=mw(c);u?.removeEventListener("scroll",i)})}},[i,t]),x.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,s)=>Ld(a,s),ss):KU(t):ss,[t,e])}function vD(t,e){e===void 0&&(e=[]);const n=x.useRef(null);return x.useEffect(()=>{n.current=null},e),x.useEffect(()=>{const r=t!==ss;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?mp(t,n.current):ss}function Z0e(t){x.useEffect(()=>{if(!yv)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 J0e(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 QU(t){return x.useMemo(()=>t?w0e(t):null,[t])}const xD=[];function Q0e(t,e){e===void 0&&(e=xf);const[n]=t,r=QU(n?Gi(n):null),[i,a]=x.useState(xD);function s(){a(()=>t.length?t.map(c=>qU(c)?r:new uM(e(c),c)):xD)}const o=xv({callback:s});return Xs(()=>{o?.disconnect(),s(),t.forEach(c=>o?.observe(c))},[t]),i}function eye(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return $p(e)?e:t}function tye(t){let{measure:e}=t;const[n,r]=x.useState(null),i=x.useCallback(u=>{for(const{target:f}of u)if($p(f)){r(h=>{const m=e(f);return h?{...h,width:m.width,height:m.height}:m});break}},[e]),a=xv({callback:i}),s=x.useCallback(u=>{const f=eye(u);a?.disconnect(),f&&a?.observe(f),r(f?e(f):null)},[e,a]),[o,c]=ky(s);return x.useMemo(()=>({nodeRef:o,rect:n,setRef:c}),[n,o,c])}const nye=[{sensor:hM,options:{}},{sensor:dM,options:{}}],rye={current:{}},R0={draggable:{measure:dD},droppable:{measure:dD,strategy:yp.WhileDragging,frequency:FS.Optimized},dragOverlay:{measure:xf}};class $h 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 iye={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new $h,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ey},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:R0,measureDroppableContainers:Ey,windowRect:null,measuringScheduled:!1},aye={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Ey,draggableNodes:new Map,over:null,measureDroppableContainers:Ey},bv=x.createContext(aye),ej=x.createContext(iye);function sye(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new $h}}}function oye(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 $h(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 $h(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 $h(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function lye(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=x.useContext(bv),a=DS(r),s=DS(n?.id);return x.useEffect(()=>{if(!e&&!r&&a&&s!=null){if(!cM(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=e0e(f);if(h){h.focus();break}}})}},[r,e,i,s,a]),null}function cye(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function uye(t){return x.useMemo(()=>({draggable:{...R0.draggable,...t?.draggable},droppable:{...R0.droppable,...t?.droppable},dragOverlay:{...R0.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function dye(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;Xs(()=>{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=WU(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 m=GU(u);m&&m.scrollBy({top:h.y,left:h.x})}},[e,s,o,r,n])}const tj=x.createContext({...ss,scaleX:1,scaleY:1});var vl;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(vl||(vl={}));const fye=x.memo(function(e){var n,r,i,a;let{id:s,accessibility:o,autoScroll:c=!0,children:u,sensors:f=nye,collisionDetection:h=m0e,measuring:m,modifiers:g,...v}=e;const w=x.useReducer(oye,void 0,sye),[b,_]=w,[E,M]=s0e(),[T,P]=x.useState(vl.Uninitialized),A=T===vl.Initialized,{draggable:{active:R,nodes:k,translate:N},droppable:{containers:B}}=b,L=R!=null?k.get(R):null,z=x.useRef({initial:null,translated:null}),I=x.useMemo(()=>{var Ae;return R!=null?{id:R,data:(Ae=L?.data)!=null?Ae:rye,rect:z}:null},[R,L]),V=x.useRef(null),[W,X]=x.useState(null),[J,F]=x.useState(null),G=pp(v,Object.values(v)),Y=qp("DndDescribedBy",s),H=x.useMemo(()=>B.getEnabled(),[B]),te=uye(m),{droppableRects:re,measureDroppableContainers:ue,measuringScheduled:ce}=W0e(H,{dragging:A,dependencies:[N.x,N.y],config:te.droppable}),ee=V0e(k,R),le=x.useMemo(()=>J?LS(J):null,[J]),ve=ke(),Ne=G0e(ee,te.draggable.measure);dye({activeNode:R!=null?k.get(R):null,config:ve.layoutShiftCompensation,initialRect:Ne,measure:te.draggable.measure});const be=gD(ee,te.draggable.measure,Ne),qe=gD(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:B,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ue=B.getNodeFor((n=he.current.over)==null?void 0:n.id),je=tye({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),Q=q0e(oe?null:be),ze=QU(et?Gi(et):null),Pe=X0e(A?Ue??ee:null),De=Q0e(Pe),Le=cye(g,{transform:{x:N.x-Q.x,y:N.y-Q.y,scaleX:1,scaleY:1},activatorEvent:J,active:I,activeNodeRect:be,containerNodeRect:qe,draggingNodeRect:_e,over:he.current.over,overlayNodeRect:je.rect,scrollableAncestors:Pe,scrollableAncestorRects:De,windowRect:ze}),$=le?Ld(le,N):null,U=K0e(Pe),Z=vD(U),pe=vD(U,[be]),Se=Ld(Le,Z),xe=_e?v0e(_e,Le):null,Ie=I&&xe?h({active:I,collisionRect:xe,droppableRects:re,droppableContainers:H,pointerCoordinates:$}):null,He=HU(Ie,"id"),[Ye,ft]=x.useState(null),We=oe?Le:Ld(Le,pe),Xe=g0e(We,(a=Ye?.rect)!=null?a:null,be),nt=x.useRef(null),ct=x.useCallback((Ae,Ve)=>{let{sensor:ge,options:ut}=Ve;if(V.current==null)return;const yt=k.get(V.current);if(!yt)return;const qt=Ae.nativeEvent,Lt=new ge({active:V.current,activeNode:yt,event:qt,options:ut,context:he,onAbort(wt){if(!k.get(wt))return;const{onDragAbort:xn}=G.current,ie={id:wt};xn?.(ie),E({type:"onDragAbort",event:ie})},onPending(wt,un,xn,ie){if(!k.get(wt))return;const{onDragPending:Te}=G.current,$e={id:wt,constraint:un,initialCoordinates:xn,offset:ie};Te?.($e),E({type:"onDragPending",event:$e})},onStart(wt){const un=V.current;if(un==null)return;const xn=k.get(un);if(!xn)return;const{onDragStart:ie}=G.current,fe={activatorEvent:qt,active:{id:un,data:xn.data,rect:z}};gi.unstable_batchedUpdates(()=>{ie?.(fe),P(vl.Initializing),_({type:Ur.DragStart,initialCoordinates:wt,active:un}),E({type:"onDragStart",event:fe}),X(nt.current),F(qt)})},onMove(wt){_({type:Ur.DragMove,coordinates:wt})},onEnd:_t(Ur.DragEnd),onCancel:_t(Ur.DragCancel)});nt.current=Lt;function _t(wt){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},wt===Ur.DragEnd&&typeof Ze=="function"&&await Promise.resolve(Ze($e))&&(wt=Ur.DragCancel)}V.current=null,gi.unstable_batchedUpdates(()=>{_({type:wt}),P(vl.Uninitialized),ft(null),X(null),F(null),nt.current=null;const Ze=wt===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(V.current!==null||!qt||yt.dndKit||yt.defaultPrevented)return;const Lt={active:qt};Ae(ge,Ve.options,Lt)===!0&&(yt.dndKit={capturedBy:Ve.sensor},V.current=ut,ct(ge,Ve))},[k,ct]),gt=H0e(f,Ke);Z0e(f),Xs(()=>{be&&T===vl.Initializing&&P(vl.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||V.current==null||!Ve||!yt)return;const{onDragOver:qt}=G.current,Lt=ut.get(He),_t=Lt&&Lt.rect.current?{id:Lt.id,rect:Lt.rect.current,data:Lt.data,disabled:Lt.disabled}:null,wt={active:Ae,activatorEvent:Ve,collisions:ge,delta:{x:yt.x,y:yt.y},over:_t};gi.unstable_batchedUpdates(()=>{ft(_t),qt?.(wt),E({type:"onDragOver",event:wt})})},[He]),Xs(()=>{he.current={activatorEvent:J,active:I,activeNode:ee,collisionRect:xe,collisions:Ie,droppableRects:re,draggableNodes:k,draggingNode:et,draggingNodeRect:_e,droppableContainers:B,over:Ye,scrollableAncestors:Pe,scrollAdjustedTranslate:Se},z.current={initial:_e,translated:xe}},[I,ee,Ie,xe,k,et,_e,re,B,Ye,Pe,Se]),j0e({...ve,delta:N,draggingRect:xe,pointerCoordinates:$,scrollableAncestors:Pe,scrollableAncestorRects:De});const ne=x.useMemo(()=>({active:I,activeNode:ee,activeNodeRect:be,activatorEvent:J,collisions:Ie,containerNodeRect:qe,dragOverlay:je,draggableNodes:k,droppableContainers:B,droppableRects:re,over:Ye,measureDroppableContainers:ue,scrollableAncestors:Pe,scrollableAncestorRects:De,measuringConfiguration:te,measuringScheduled:ce,windowRect:ze}),[I,ee,be,J,Ie,qe,je,k,B,re,Ye,ue,Pe,De,te,ce,ze]),Be=x.useMemo(()=>({activatorEvent:J,activators:gt,active:I,activeNodeRect:be,ariaDescribedById:{draggable:Y},dispatch:_,draggableNodes:k,over:Ye,measureDroppableContainers:ue}),[J,gt,I,be,_,Y,k,Ye,ue]);return ot.createElement(BU.Provider,{value:M},ot.createElement(bv.Provider,{value:Be},ot.createElement(ej.Provider,{value:ne},ot.createElement(tj.Provider,{value:Xe},u)),ot.createElement(lye,{disabled:o?.restoreFocus===!1})),ot.createElement(c0e,{...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}}}),hye=x.createContext(null),bD="button",pye="Draggable";function mye(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=qp(pye),{activators:s,activatorEvent:o,active:c,activeNodeRect:u,ariaDescribedById:f,draggableNodes:h,over:m}=x.useContext(bv),{role:g=bD,roleDescription:v="draggable",tabIndex:w=0}=i??{},b=c?.id===e,_=x.useContext(b?tj:hye),[E,M]=ky(),[T,P]=ky(),A=J0e(s,e),R=pp(n);Xs(()=>(h.set(e,{id:e,key:a,node:E,activatorNode:T,data:R}),()=>{const N=h.get(e);N&&N.key===a&&h.delete(e)}),[h,e]);const k=x.useMemo(()=>({role:g,tabIndex:w,"aria-disabled":r,"aria-pressed":b&&g===bD?!0:void 0,"aria-roledescription":v,"aria-describedby":f.draggable}),[r,g,w,b,v,f.draggable]);return{active:c,activatorEvent:o,activeNodeRect:u,attributes:k,isDragging:b,listeners:r?void 0:A,node:E,over:m,setNodeRef:M,setActivatorNodeRef:P,transform:_}}function gye(){return x.useContext(ej)}const yye="Droppable",vye={timeout:25};function xye(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=qp(yye),{active:s,dispatch:o,over:c,measureDroppableContainers:u}=x.useContext(bv),f=x.useRef({disabled:n}),h=x.useRef(!1),m=x.useRef(null),g=x.useRef(null),{disabled:v,updateMeasurementsFor:w,timeout:b}={...vye,...i},_=pp(w??r),E=x.useCallback(()=>{if(!h.current){h.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{u(Array.isArray(_.current)?_.current:[_.current]),g.current=null},b)},[b]),M=xv({callback:E,disabled:v||!s}),T=x.useCallback((k,N)=>{M&&(N&&(M.unobserve(N),h.current=!1),k&&M.observe(k))},[M]),[P,A]=ky(T),R=pp(e);return x.useEffect(()=>{!M||!P.current||(M.disconnect(),h.current=!1,M.observe(P.current))},[P,M]),x.useEffect(()=>(o({type:Ur.RegisterDroppable,element:{id:r,key:a,disabled:n,node:P,rect:m,data:R}}),()=>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:m,isOver:c?.id===r,node:P,over:c,setNodeRef:A}}const bye=t=>{let{transform:e}=t;return{...e,y:0}};function nj(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function _ye(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function e0(t){return t!==null&&t>=0}function wye(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 Sye(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const t0={scaleX:1,scaleY:1},kye=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=Eye(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,...t0}:null}return s>i&&s<=a?{x:-o.width-c,y:0,...t0}:s<i&&s>=a?{x:o.width+c,y:0,...t0}:{x:0,y:0,...t0}};function Eye(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 rj=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=nj(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}},ij="Sortable",aj=ot.createContext({activeIndex:-1,containerId:ij,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:rj,disabled:{draggable:!1,droppable:!1}});function Mye(t){let{children:e,id:n,items:r,strategy:i=rj,disabled:a=!1}=t;const{active:s,dragOverlay:o,droppableRects:c,over:u,measureDroppableContainers:f}=gye(),h=qp(ij,n),m=o.rect!==null,g=x.useMemo(()=>r.map(A=>typeof A=="object"&&"id"in A?A.id:A),[r]),v=s!=null,w=s?g.indexOf(s.id):-1,b=u?g.indexOf(u.id):-1,_=x.useRef(g),E=!wye(g,_.current),M=b!==-1&&w===-1||E,T=Sye(a);Xs(()=>{E&&v&&f(g)},[E,g,v,f]),x.useEffect(()=>{_.current=g},[g]);const P=x.useMemo(()=>({activeIndex:w,containerId:h,disabled:T,disableTransforms:M,items:g,overIndex:b,useDragOverlay:m,sortedRects:_ye(g,c),strategy:i}),[w,h,T.draggable,T.droppable,M,g,b,c,m,i]);return ot.createElement(aj.Provider,{value:P},e)}const Tye=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return nj(n,r,i).indexOf(e)},Cye=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},Aye={duration:200,easing:"ease"},sj="transform",Pye=gp.Transition.toString({property:sj,duration:0,easing:"linear"}),Rye={roleDescription:"sortable"};function Nye(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,s]=x.useState(null),o=x.useRef(n);return Xs(()=>{if(!e&&n!==o.current&&r.current){const c=i.current;if(c){const u=xf(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 Dye(t){let{animateLayoutChanges:e=Cye,attributes:n,disabled:r,data:i,getNewIndex:a=Tye,id:s,strategy:o,resizeObserverConfig:c,transition:u=Aye}=t;const{items:f,containerId:h,activeIndex:m,disabled:g,disableTransforms:v,sortedRects:w,overIndex:b,useDragOverlay:_,strategy:E}=x.useContext(aj),M=Lye(r,g),T=f.indexOf(s),P=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:R,node:k,isOver:N,setNodeRef:B}=xye({id:s,data:P,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:A,...c}}),{active:L,activatorEvent:z,activeNodeRect:I,attributes:V,setNodeRef:W,listeners:X,isDragging:J,over:F,setActivatorNodeRef:G,transform:Y}=mye({id:s,data:P,attributes:{...Rye,...n},disabled:M.draggable}),H=Kge(B,W),te=!!L,re=te&&!v&&e0(m)&&e0(b),ue=!_&&J,ce=ue&&re?Y:null,le=re?ce??(o??E)({rects:w,activeNodeRect:I,activeIndex:m,overIndex:b,index:T}):null,ve=e0(m)&&e0(b)?a({id:s,items:f,activeIndex:m,overIndex:b}):T,Ne=L?.id,be=x.useRef({activeId:Ne,items:f,newIndex:ve,containerId:h}),qe=f!==be.current.items,he=e({active:L,containerId:h,isDragging:J,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=Nye({disabled:!he,index:T,node:k,rect:R});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(Ne===be.current.activeId)return;if(Ne&&!be.current.activeId){be.current.activeId=Ne;return}const et=setTimeout(()=>{be.current.activeId=Ne},50);return()=>clearTimeout(et)},[Ne]),{active:L,activeIndex:m,attributes:V,data:P,rect:R,index:T,newIndex:ve,items:f,isOver:N,isSorting:te,isDragging:J,listeners:X,node:k,overIndex:b,over:F,setNodeRef:H,setActivatorNodeRef:G,setDroppableNodeRef:B,setDraggableNodeRef:W,transform:Ue??le,transition:je()};function je(){if(Ue||qe&&be.current.newIndex===T)return Pye;if(!(ue&&!cM(z)||!u)&&(te||he))return gp.Transition.toString({...u,property:sj})}}function Lye(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 Ty(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 Iye=[Nn.Down,Nn.Right,Nn.Up,Nn.Left],Oye=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:s,scrollableAncestors:o}}=e;if(Iye.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const m=i.get(h.id);if(m)switch(t.code){case Nn.Down:r.top<m.top&&c.push(h);break;case Nn.Up:r.top>m.top&&c.push(h);break;case Nn.Left:r.left>m.left&&c.push(h);break;case Nn.Right:r.left<m.left&&c.push(h);break}});const u=h0e({collisionRect:r,droppableRects:i,droppableContainers:c});let f=HU(u,"id");if(f===s?.id&&u.length>1&&(f=u[1].id),f!=null){const h=a.get(n.id),m=a.get(f),g=m?i.get(m.id):null,v=m?.node.current;if(v&&g&&h&&m){const b=vv(v).some((A,R)=>o[R]!==A),_=oj(h,m),E=Fye(h,m),M=b||!_?{x:0,y:0}:{x:E?r.width-g.width:0,y:E?r.height-g.height:0},T={x:g.left,y:g.top};return M.x&&M.y?T:mp(T,M)}}}};function oj(t,e){return!Ty(t)||!Ty(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function Fye(t,e){return!Ty(t)||!Ty(e)||!oj(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function Jd(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 Uye(t,e){const n=Jd(e,{min:0,max:1e6,fallback:0}),r=Jd(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 jye({page:t,totalPages:e}){const n=typeof e=="number"&&Number.isFinite(e)&&e>=0,r=n?Jd(e,{min:0,max:1e6,fallback:0}):null,i=Jd(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 Bye({entries:t,me:e,meLabel:n,limit:r}){const i=Jd(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 zye(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 Vye(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 _D={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 US({avatarUrl:t,displayName:e,seed:n,size:r="md",className:i}){const a=_D[r]||_D.md,s=zye(n??e??""),o=typeof t=="string"?t.trim():"",[c,u]=ot.useState(!1);return ot.useEffect(()=>{u(!1)},[o]),o&&!c?p.jsx("img",{src:o,alt:"",referrerPolicy:"no-referrer",onError:()=>u(!0),className:vt("rounded-full object-cover ring-1 ring-white/10",a,i)}):p.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:Vye(e)})}const Hye=new Set(["/brand-logos/cursor.svg","/brand-logos/kiro.svg","/brand-logos/copilot.svg"]);function lj({iconSrc:t,label:e}){return p.jsxs("span",{className:"inline-flex items-center gap-3",children:[t?p.jsx("img",{src:t,alt:"",width:16,height:16,className:`h-4 w-4 shrink-0 object-contain opacity-90 ${Hye.has(t)?"dark:invert":""}`}):null,p.jsx("span",{className:"whitespace-nowrap",children:e})]})}const Qd=[{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}],pM="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",cj="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",Wye="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 Cy(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 jS(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 Gye(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 Za({className:t}){return p.jsx("div",{className:vt("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function $ye({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 p.jsxs("tr",{className:"group",children:[p.jsx("td",{className:vt(Cy(!1),"!group-hover:bg-transparent"),children:p.jsx(Za,{className:"h-4 w-6"})}),p.jsx("td",{className:vt(jS(!1),"!group-hover:bg-transparent"),children:p.jsxs("div",{className:"flex items-center gap-4",children:[p.jsx(Za,{className:"h-8 w-8 min-w-8 rounded-full"}),p.jsx(Za,{className:vt("h-4",e)})]})}),p.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:p.jsx(Za,{className:vt("h-4",n)})}),p.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:p.jsx(Za,{className:"h-4 w-12"})}),Qd.map(i=>p.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:p.jsx(Za,{className:vt("h-4",r)})},i.key))]})}function Yye({rows:t=10}){return p.jsx("div",{className:"w-full overflow-x-auto",children:p.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[p.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:p.jsxs("tr",{children:[p.jsx("th",{className:vt(pM,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:p.jsx(Za,{className:"h-3.5 w-6"})}),p.jsx("th",{className:vt(cj,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:p.jsx(Za,{className:"h-3.5 w-12"})}),p.jsx("th",{className:"px-4 py-4",children:p.jsx(Za,{className:"h-3.5 w-10"})}),p.jsx("th",{className:"px-4 py-4",children:p.jsx(Za,{className:"h-3.5 w-14"})}),Qd.map(e=>p.jsx("th",{className:"px-4 py-4",children:p.jsx(Za,{className:"h-3.5 w-12"})},e.key))]})}),p.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:Array.from({length:t},(e,n)=>p.jsx($ye,{index:n},n))})]})})}function qye({id:t,thClassName:e,children:n}){const{attributes:r,listeners:i,setNodeRef:a,transform:s,transition:o,isDragging:c}=Dye({id:t}),u=gp.Transform.toString(s)||"";x.useLayoutEffect(()=>{const h=document.querySelectorAll(`td[data-column-key="${t}"]`),m="0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)";return h.forEach(g=>{g.style.transform=u,g.style.transition=o||"",g.style.zIndex=c?"20":"",g.style.position=u?"relative":"",g.style.boxShadow=c?m:""}),()=>{h.forEach(g=>{g.style.transform="",g.style.transition="",g.style.zIndex="",g.style.position="",g.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 p.jsx("th",{ref:a,style:f,className:vt(e,"group/col select-none cursor-grab active:cursor-grabbing touch-none"),...r,...i,children:p.jsxs("div",{className:"flex items-center justify-end gap-2",children:[p.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:p.jsxs("svg",{viewBox:"0 0 8 14",width:"8",height:"14",fill:"currentColor","aria-hidden":"true",children:[p.jsx("circle",{cx:"2",cy:"2",r:"1"}),p.jsx("circle",{cx:"6",cy:"2",r:"1"}),p.jsx("circle",{cx:"2",cy:"7",r:"1"}),p.jsx("circle",{cx:"6",cy:"7",r:"1"}),p.jsx("circle",{cx:"2",cy:"12",r:"1"}),p.jsx("circle",{cx:"6",cy:"12",r:"1"})]})}),n]})})}const uj="tokentracker.leaderboard.columnOrder.v1";function Xye(){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(uj);if(!t)return null;const e=JSON.parse(t);return Array.isArray(e)?e.filter(n=>typeof n=="string"):null}catch{return null}}function vw(t){if(!(typeof window>"u"))try{window.localStorage.setItem(uj,JSON.stringify(t))}catch{}}function wD(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 Kye(t){const e=x.useMemo(()=>t.join("|"),[t]),[n,r]=x.useState(()=>wD(Xye(),t));x.useEffect(()=>{r(s=>{const o=wD(s,t);return o.length===s.length&&o.every((u,f)=>u===s[f])?s:(vw(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(),[m]=h.splice(u,1);return h.splice(f,0,m),vw(h),h})},[]),a=x.useCallback(()=>{vw(t),r(t)},[t]);return{order:n,reorder:i,reset:a}}const BS=[10,20,50,100],zS=20,dj="tokentracker:leaderboard:pageSize";function Zye(){if(typeof window>"u")return zS;try{const t=window.localStorage.getItem(dj),e=Number(t);if(BS.includes(e))return e}catch{}return zS}function SD(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 kD(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=>p.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 Jye={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 ED({rank:t,placeholder:e}){const n=Jye[t];return n?p.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}):p.jsx("span",{className:"inline-flex items-center justify-center h-7 w-7 text-sm",children:t??e})}function VS(t){if(typeof t!="string")return null;const e=t.trim().toLowerCase();return e==="week"||e==="month"||e==="total"?e:null}function Qye(t){if(!t)return O("shared.error.prefix",{error:O("leaderboard.error.unknown")});const e=t?.message||String(t),n=String(e||"").trim()||O("leaderboard.error.unknown");return O("shared.error.prefix",{error:n})}function fj(t){return typeof t!="string"?"":t.trim()}function eve(t){const e=fj(t);return e?e.toLowerCase()==="anonymous":!0}function tve(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=VS(r.get("period")),a=i?`?period=${i}`:"";return`/share/pv1-${n}${a}`}function MD(t,e){const n=typeof t?.user_id=="string"?t.user_id.trim():"";return n||`${t?.rank??""}:${e}`}function TD({githubUrl:t}){return p.jsxs("span",{className:"relative inline-flex items-center group/gh shrink-0",children:[p.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),"aria-label":O("leaderboard.github.aria"),className:"text-oai-black hover:text-oai-gray-500 dark:text-white dark:hover:text-oai-gray-400 transition-colors",children:p.jsx(nu,{provider:"GITHUB",size:16})}),p.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:[p.jsx("span",{className:"block",children:O("leaderboard.github.tooltipAction")}),p.jsxs("span",{className:"block text-oai-gray-300 dark:text-oai-gray-400",children:[O("leaderboard.github.tooltipPrefix")," ",p.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:O("leaderboard.github.tooltipSettingsLink")}),O("leaderboard.github.tooltipSuffix")]})]})]})}function nve({auth:t,signedIn:e,sessionSoftExpired:n}){const r=Hi(),i=tf(),{openLoginModal:a}=Cp(),{signedIn:s,loading:o,user:c}=ls(),u=x.useMemo(()=>ZO(),[]),f=vr(),h=e&&!n,m=x.useMemo(()=>h&&(typeof t=="function"||typeof t=="string"||t&&typeof t=="object")?t:null,[t,h]),g=h?m:null,v=h&&Fl(g),w=O("shared.placeholder.short"),b=x.useMemo(()=>Qd.map(Z=>Z.key),[]),{order:_,reorder:E}=Kye(b),M=x.useMemo(()=>{const Z=new Map;for(const pe of Qd)Z.set(pe.key,pe);return Z},[]),T=x.useMemo(()=>_.map(Z=>M.get(Z)).filter(Boolean),[_,M]),P=u0e(lD(hM,{activationConstraint:{distance:6}}),lD(dM,{coordinateGetter:Oye})),A=x.useCallback(Z=>{const{active:pe,over:Se}=Z;!Se||pe.id===Se.id||E(String(pe.id),String(Se.id))},[E]),[R,k]=x.useState(1),[N,B]=x.useState(Zye),L=x.useCallback(Z=>{const pe=BS.includes(Z)?Z:zS;B(pe),k(1);try{window.localStorage.setItem(dj,String(pe))}catch{}},[]),[z,I]=x.useState(0),[V,W]=x.useState(()=>({loading:!1,error:null,data:null})),[X,J]=x.useState(()=>_k()),[F,G]=x.useState(!1),Y=x.useMemo(()=>{const Z=new URLSearchParams(r?.search||"");return VS(Z.get("period"))||"total"},[r?.search]),H=r?.search||"",te=Z=>{const pe=VS(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(()=>(Jd(R,{min:1,max:1e6,fallback:1})-1)*N,[R,N]);x.useEffect(()=>{if(!u&&!f)return;let Z=!0;return W(pe=>({...pe,loading:!0,error:null})),(async()=>{const pe=await M3({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:Qye(pe),data:null})}),()=>{Z=!1}},[u,c?.id,re,z,f,Y,N]);const ue=V.data,ce=ue?.total_pages??null,ee=ue?.page??R,le=x.useMemo(()=>Uye(ee,ce),[ee,ce]),ve=ue?.from||null,Ne=ue?.to||null,be=ue?.generated_at||null,qe=ue?.me||null,he=O("leaderboard.me_label"),Ue=O("leaderboard.anon_label"),je=O("leaderboard.period.week"),et=O("leaderboard.period.month"),_e=O("leaderboard.period.total"),oe=Y==="month"?et:Y==="total"?_e:je,Q=x.useMemo(()=>{const Z=Array.isArray(ue?.entries)?ue.entries:[];return ee!==1?Z:Bye({entries:Z,me:qe,meLabel:he,limit:N})},[ee,ue?.entries,qe,he,N]),ze=async()=>{G(!0);try{m3(!0),J(!0),await e4(()=>Zh(g));const Z=await Zh(g);Z&&await v7({accessToken:Z,period:Y,source:"leaderboard-enable-sync"}),I(pe=>pe+1)}catch(Z){console.warn("[tokentracker] sync:",Z)}finally{G(!1)}},{canPrev:Pe,canNext:De}=jye({page:ee,totalPages:ce}),Le=Array.isArray(Q)&&Q.length!==0;let $=null;V.loading?$=p.jsx(Yye,{rows:N}):V.error?$=p.jsx("div",{className:"px-6 py-12 text-center",children:p.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:V.error})}):Le?$=p.jsx(fye,{sensors:P,collisionDetection:f0e,modifiers:[bye],onDragEnd:A,children:p.jsx("div",{className:"w-full overflow-x-auto",children:p.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[p.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:p.jsxs("tr",{children:[p.jsx("th",{className:vt(pM,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:O("leaderboard.column.rank")}),p.jsx("th",{className:vt(cj,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:O("leaderboard.column.user")}),p.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:O("leaderboard.column.total")}),p.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:O("leaderboard.column.est_cost")}),p.jsx(Mye,{items:_,strategy:kye,children:T.map(Z=>p.jsx(qye,{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:p.jsx(lj,{iconSrc:Z.icon,label:O(Z.copyKey)})},Z.key))})]})}),p.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:Q.map((Z,pe)=>{if(Z?.is_ellipsis){const We=4+T.length;return p.jsx("tr",{"aria-hidden":"true",children:p.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=fj(Z?.display_name),He=eve(Ie)?Ue:Ie,Ye=Se?he:He;return!!xe&&!Se&&!!Z?.is_public&&tve(xe,H),Se?p.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:[p.jsx("td",{className:vt(Cy(!0),"font-semibold text-oai-brand-600 dark:text-oai-brand-400"),children:p.jsx(ED,{rank:Z?.rank,placeholder:w})}),p.jsx("td",{className:jS(!0),children:p.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[p.jsx(US,{avatarUrl:Z?.avatar_url,displayName:Ye,seed:MD(Z,Ye)}),p.jsx("span",{className:"truncate font-semibold text-oai-black dark:text-oai-white",children:Ye}),Z?.github_url&&p.jsx(TD,{githubUrl:Z.github_url})]})}),p.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)}),p.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:SD(Z?.estimated_cost_usd)}),kD(Z,!0,T)]},`row-${Z?.rank}-${Ye}`):p.jsxs("tr",{className:"group transition-colors",children:[p.jsx("td",{className:vt(Cy(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:p.jsx(ED,{rank:Z?.rank,placeholder:w})}),p.jsx("td",{className:jS(!1),children:p.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[p.jsx(US,{avatarUrl:Z?.avatar_url,displayName:Ye,seed:MD(Z,Ye)}),p.jsx("span",{className:"truncate font-medium text-oai-gray-800 dark:text-oai-gray-200",children:Ye}),Z?.github_url&&p.jsx(TD,{githubUrl:Z.github_url})]})}),p.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)}),p.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:SD(Z?.estimated_cost_usd)}),kD(Z,!1,T)]},`row-${Z?.rank}-${Ye}`)})})]})})}):$=p.jsx("div",{className:"px-6 py-12 text-center",children:p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:O("leaderboard.empty")})});let U=null;return typeof ce=="number"?U=le.map((Z,pe)=>Z==null?p.jsx("span",{className:"px-2 text-oai-gray-400 dark:text-oai-gray-500",children:O("leaderboard.pagination.ellipsis")},`ellipsis-${pe}`):p.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:V.loading,children:String(Z)},`page-${Z}`)):U=p.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:O("leaderboard.pagination.page_unknown",{page:String(ee)})}),p.jsxs("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:[p.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:p.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[p.jsxs("div",{className:"flex flex-col md:flex-row md:items-end justify-between gap-6 mb-8",children:[p.jsxs("div",{children:[p.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:O("leaderboard.title")}),p.jsxs("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:[Y==="total"?O("leaderboard.range.total"):ve&&Ne?O("leaderboard.range",{period:oe,from:ve,to:Ne}):O("leaderboard.range_loading",{period:oe}),be&&p.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:O("leaderboard.generated_at",{ts:be})})]})]}),p.jsx("div",{className:"flex items-center gap-2",children:p.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=>p.jsx("button",{onClick:()=>te(Z),disabled:V.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&&p.jsxs("div",{className:"mb-6 flex items-center justify-between text-sm",children:[p.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:O("leaderboard.signin_prompt")}),p.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:O("leaderboard.signin_button")})]}),h&&v&&!X&&p.jsxs("div",{className:"mb-6 flex items-center justify-between text-sm",children:[p.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:O("leaderboard.sync_prompt")}),p.jsx("button",{onClick:ze,disabled:F,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:O(F?"leaderboard.sync_button.busy":"leaderboard.sync_button.idle")})]}),p.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",children:[$,p.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:[p.jsxs("div",{className:"flex items-center gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[p.jsx("label",{htmlFor:"leaderboard-page-size",className:"whitespace-nowrap",children:O("leaderboard.pagination.page_size_label")}),p.jsxs("div",{className:"relative",children:[p.jsx("select",{id:"leaderboard-page-size",value:N,onChange:Z=>L(Number(Z.target.value)),disabled:V.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:BS.map(Z=>p.jsx("option",{value:Z,children:Z},Z))}),p.jsx(Hy,{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"})]})]}),p.jsx("div",{className:"h-5 w-px bg-oai-gray-200 dark:bg-oai-gray-800","aria-hidden":"true"}),p.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",Pe&&!V.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:!Pe||V.loading,children:O("leaderboard.pagination.prev")}),p.jsx("div",{className:"flex flex-wrap items-center gap-1",children:U}),p.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&&!V.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||V.loading,children:O("leaderboard.pagination.next")})]})]})]})}),p.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 transition-colors duration-200",children:p.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:[p.jsx("p",{children:O("landing.v2.footer.line")}),p.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:O("landing.v2.nav.github")})]})})]})}const ef=18;function hj(){return p.jsxs("svg",{"aria-hidden":!0,width:ef,height:ef,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"4"}),p.jsx("path",{d:"M12 2v2"}),p.jsx("path",{d:"M12 20v2"}),p.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),p.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),p.jsx("path",{d:"M2 12h2"}),p.jsx("path",{d:"M20 12h2"}),p.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),p.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})}function pj(){return p.jsx("svg",{"aria-hidden":!0,width:ef,height:ef,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function rve(){return p.jsxs("svg",{"aria-hidden":!0,width:ef,height:ef,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),p.jsx("path",{d:"M8 21h8"}),p.jsx("path",{d:"M12 17v4"})]})}const ive=[{value:"light",label:"Light",Icon:hj},{value:"dark",label:"Dark",Icon:pj},{value:"system",label:"System",Icon:rve}];function ave(t){return t==="dark"?pj:hj}function sve({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=m=>{c.current&&!c.current.contains(m.target)&&u()};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[s,u]),x.useEffect(()=>{if(!s)return;const h=m=>{m.key==="Escape"&&u()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[s,u]);const f=ave(e);return p.jsxs("div",{ref:c,className:`relative ${r}`,children:[p.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:p.jsx(f,{})}),s&&p.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:ive.map(({value:h,label:m,Icon:g})=>{const v=t===h;return p.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:[p.jsx(g,{}),p.jsx("span",{children:m})]},h)})})]})}function ove(t){if(!t)return O("shared.error.prefix",{error:O("leaderboard.error.unknown")});const e=t?.message||String(t),n=String(e||"").trim()||O("leaderboard.error.unknown");return O("shared.error.prefix",{error:n})}function lve(t){return typeof t!="string"?"":t.trim()}function cve(t){if(typeof t!="string")return null;const e=t.trim().toLowerCase();return e==="week"||e==="month"||e==="total"?e:null}function uve({auth:t,signedIn:e,sessionSoftExpired:n,userId:r}){const i=Hi(),{theme:a,resolvedTheme:s,setTheme:o}=Op(),c=x.useMemo(()=>ZO(),[]),u=vr(),f=e&&!n,h=x.useMemo(()=>f&&(typeof t=="function"||typeof t=="string"||t&&typeof t=="object")?t:null,[t,f]),m=f?h:null,g=f&&Fl(m),v=x.useMemo(()=>{const I=new URLSearchParams(i?.search||"");return cve(I.get("period"))||"week"},[i?.search]),w=i?.search||"",[b,_]=x.useState(()=>({loading:!1,error:null,data:null}));x.useEffect(()=>{if(!c&&!u||!r||f&&!g)return;let I=!0;return _(V=>({...V,loading:!0,error:null})),(async()=>{const V=f?await Zh(m):null;if(!I)return;const W=await x7({accessToken:V,userId:r,period:v});I&&_({loading:!1,error:null,data:W})})().catch(V=>{if(I){if(V?.status===404){_({loading:!1,error:null,data:null});return}_({loading:!1,error:ove(V),data:null})}}),()=>{I=!1}},[f,g,c,m,u,v,r]);const E=b.data,M=E?.from||null,T=E?.to||null,P=E?.generated_at||null,A=E?.entry||null,R=lve(A?.display_name)||O("leaderboard.anon_label"),k=O("leaderboard.period.week"),N=O("leaderboard.period.month"),B=O("leaderboard.period.total"),L=v==="month"?N:v==="total"?B:k;let z=null;return r?b.loading?z=p.jsx("div",{className:"px-6 py-12 text-center",children:p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:O("leaderboard.loading")})}):b.error?z=p.jsx("div",{className:"px-6 py-12 text-center",children:p.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:b.error})}):A?z=p.jsx("div",{className:"w-full overflow-x-auto",children:p.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[p.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:p.jsxs("tr",{children:[p.jsx("th",{className:vt(pM,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:O("leaderboard.column.rank")}),p.jsx("th",{className:vt(Wye,"font-medium text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap"),children:O("leaderboard.column.total")}),Qd.map(I=>p.jsx("th",{className:"px-4 py-4 font-medium text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap",children:p.jsx(lj,{iconSrc:I.icon,label:O(I.copyKey)})},I.key))]})}),p.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:p.jsxs("tr",{className:"transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/60",children:[p.jsx("td",{className:vt(Cy(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:A?.rank??O("shared.placeholder.short")}),p.jsx("td",{className:vt(Gye(),"text-oai-gray-700 dark:text-oai-gray-300"),children:Oi(A?.total_tokens)}),Qd.map(I=>p.jsx("td",{className:"px-4 py-4 text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap",children:Oi(A?.[I.key])},I.key))]})})]})}):z=p.jsx("div",{className:"px-6 py-12 text-center",children:p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:O("leaderboard.empty")})}):z=p.jsx("div",{className:"px-6 py-12 text-center",children:p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:O("leaderboard.empty")})}),p.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:[p.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:p.jsxs("div",{className:"mx-auto flex h-14 max-w-6xl items-center justify-between px-4 sm:px-6",children:[p.jsxs("div",{className:"flex items-center gap-5",children:[p.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:[p.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),p.jsx("span",{className:"text-sm font-semibold tracking-wide text-oai-black dark:text-white uppercase",children:"Token Tracker"})]}),p.jsx("div",{className:"hidden sm:block",children:p.jsx(ZF,{})})]}),p.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[p.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:O("leaderboard.profile.nav.back")}),p.jsx(sve,{theme:a,resolvedTheme:s,onSetTheme:o}),p.jsx(yy,{})]})]})}),p.jsx("main",{className:"flex-1 py-12 sm:py-16",children:p.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[p.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-6 mb-10",children:[p.jsx(US,{avatarUrl:A?.avatar_url,displayName:R,seed:typeof r=="string"?r:R,size:"lg",className:"shrink-0 ring-2 ring-oai-gray-200 dark:ring-oai-gray-800"}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:R}),p.jsxs("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:[v==="total"?O("leaderboard.range.total"):M&&T?O("leaderboard.range",{period:L,from:M,to:T}):O("leaderboard.range_loading",{period:L}),P&&p.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:O("leaderboard.generated_at",{ts:P})})]})]})]}),p.jsx("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",children:z})]})}),p.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 transition-colors duration-200",children:p.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:[p.jsx("p",{children:O("landing.v2.footer.line")}),p.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:O("leaderboard.profile.nav.back")})]})})]})}const As=["claude","codex","cursor","gemini","kimi","kiro","copilot","antigravity"],CD={claude:"Claude",codex:"Codex",cursor:"Cursor",gemini:"Gemini",kimi:"Kimi",kiro:"Kiro",copilot:"GitHub Copilot",antigravity:"Antigravity"},dve={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"},HS="tt.limits.providerOrder",WS="tt.limits.providerVisibility";function AD(){if(typeof window>"u")return[...As];try{const t=window.localStorage.getItem(HS);if(!t)return[...As];const e=JSON.parse(t);if(!Array.isArray(e))return[...As];const n=e.filter(r=>As.includes(r));for(const r of As)n.includes(r)||n.push(r);return n}catch{return[...As]}}function PD(){const t=Object.fromEntries(As.map(e=>[e,!0]));if(typeof window>"u")return t;try{const e=window.localStorage.getItem(WS);if(!e)return t;const n=JSON.parse(e);if(!n||typeof n!="object")return t;const r={...t};for(const i of As)typeof n[i]=="boolean"&&(r[i]=n[i]);return r}catch{return t}}function mj(){const[t,e]=x.useState(AD),[n,r]=x.useState(PD);x.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(HS,JSON.stringify(t))}catch{}},[t]),x.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(WS,JSON.stringify(n))}catch{}},[n]),x.useEffect(()=>{if(typeof window>"u")return;const f=h=>{h.key===HS&&e(AD()),h.key===WS&&r(PD())};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 m=h.indexOf(f);if(m<=0)return h;const g=[...h];return[g[m-1],g[m]]=[g[m],g[m-1]],g})},[]),s=x.useCallback(f=>{e(h=>{const m=h.indexOf(f);if(m<0||m>=h.length-1)return h;const g=[...h];return[g[m],g[m+1]]=[g[m+1],g[m]],g})},[]),o=x.useCallback((f,h)=>{f!==h&&e(m=>{const g=m.indexOf(f),v=m.indexOf(h);if(g<0||v<0)return m;const w=[...m],[b]=w.splice(g,1);return w.splice(v,0,b),w})},[]),c=x.useCallback(()=>{e([...As]),r(Object.fromEntries(As.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 fve=[3,2,3,3,2,2,3];function jc({className:t}){return p.jsx("div",{className:vt("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function hve(){return p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(jc,{className:"h-3 w-12 shrink-0"}),p.jsx(jc,{className:"flex-1 h-1.5 rounded-full min-w-0"}),p.jsx(jc,{className:"h-3 w-[30px] shrink-0"}),p.jsx(jc,{className:"h-3 w-6 shrink-0"})]})}function pve({bars:t,index:e}){const n=e%3===0?"w-24":e%3===1?"w-20":"w-[4.5rem]";return p.jsxs("div",{className:"flex flex-col gap-1.5",children:[p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx(jc,{className:"h-[14px] w-[14px] rounded shrink-0"}),p.jsx(jc,{className:vt("h-4",n)})]}),Array.from({length:t},(r,i)=>p.jsx(hve,{},i))]})}function mve(){return p.jsx(pu,{children:p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(jc,{className:"h-3.5 w-28"}),fve.map((t,e)=>p.jsx(pve,{bars:t,index:e},e))]})})}function br(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 O("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 gve(t){return t>=90?"bg-red-500":t>=70?"bg-amber-500":"bg-emerald-500"}function _r({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 p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 w-12 shrink-0",children:t}),p.jsx("div",{className:"flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:p.jsx("div",{className:`${gve(i)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${a}%`,minWidth:r>0?"3px":0}})}),p.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?p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:n}):null]})}function ws({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 p.jsxs("div",{className:"flex flex-col gap-1.5",children:[p.jsxs("div",{className:"flex items-center gap-1.5",children:[e?p.jsx("img",{src:e,alt:"",className:i}):null,p.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:t})]}),n]})}const yve=["claude","codex","cursor","gemini","kimi","kiro","copilot","antigravity"],vve={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 p.jsx("div",{className:`text-[11px] leading-snug ${n}`,children:t})}function xve(t,e){const n=vve[t];if(!n)return null;if(!e?.configured)return p.jsx(ws,{name:n.name,icon:n.icon,children:p.jsx(xa,{children:O("limits.status.not_connected")})},t);if(e.error)return p.jsx(ws,{name:n.name,icon:n.icon,children:p.jsx(xa,{tone:"error",children:O("shared.error.prefix",{error:e.error})})},t);switch(t){case"claude":return p.jsxs(ws,{name:n.name,icon:n.icon,children:[e.five_hour?p.jsx(_r,{label:"5h",pct:e.five_hour.utilization,reset:br(e.five_hour.resets_at)}):null,e.seven_day?p.jsx(_r,{label:"7d",pct:e.seven_day.utilization,reset:br(e.seven_day.resets_at)}):null,e.seven_day_opus?p.jsx(_r,{label:"Opus",pct:e.seven_day_opus.utilization,reset:br(e.seven_day_opus.resets_at)}):null,!e.five_hour&&!e.seven_day&&!e.seven_day_opus?p.jsx(xa,{children:O("limits.status.no_data")}):null]},"claude");case"codex":return p.jsxs(ws,{name:n.name,icon:n.icon,children:[e.primary_window?p.jsx(_r,{label:"5h",pct:e.primary_window.used_percent,reset:br(e.primary_window.reset_at)}):null,e.secondary_window?p.jsx(_r,{label:"7d",pct:e.secondary_window.used_percent,reset:br(e.secondary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window?p.jsx(xa,{children:O("limits.status.no_data")}):null]},"codex");case"cursor":return p.jsxs(ws,{name:n.name,icon:n.icon,children:[e.primary_window?p.jsx(_r,{label:O("limits.label.cursor_plan"),pct:e.primary_window.used_percent,reset:br(e.primary_window.reset_at)}):null,e.secondary_window?p.jsx(_r,{label:O("limits.label.cursor_auto"),pct:e.secondary_window.used_percent,reset:br(e.secondary_window.reset_at)}):null,e.tertiary_window?p.jsx(_r,{label:O("limits.label.cursor_api"),pct:e.tertiary_window.used_percent,reset:br(e.tertiary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window&&!e.tertiary_window?p.jsx(xa,{children:O("limits.status.no_data")}):null]},"cursor");case"gemini":return p.jsxs(ws,{name:n.name,icon:n.icon,children:[e.primary_window?p.jsx(_r,{label:"Pro",pct:e.primary_window.used_percent,reset:br(e.primary_window.reset_at)}):null,e.secondary_window?p.jsx(_r,{label:"Flash",pct:e.secondary_window.used_percent,reset:br(e.secondary_window.reset_at)}):null,e.tertiary_window?p.jsx(_r,{label:"Lite",pct:e.tertiary_window.used_percent,reset:br(e.tertiary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window&&!e.tertiary_window?p.jsx(xa,{children:O("limits.status.no_data")}):null]},"gemini");case"kimi":return p.jsxs(ws,{name:n.name,icon:n.icon,children:[e.primary_window?p.jsx(_r,{label:O("limits.label.kimi_weekly"),pct:e.primary_window.used_percent,reset:br(e.primary_window.reset_at)}):null,e.secondary_window?p.jsx(_r,{label:O("limits.label.kimi_5h"),pct:e.secondary_window.used_percent,reset:br(e.secondary_window.reset_at)}):null,e.tertiary_window?p.jsx(_r,{label:O("limits.label.kimi_total"),pct:e.tertiary_window.used_percent,reset:br(e.tertiary_window.reset_at)}):null,e.parallel_limit?p.jsx(xa,{children:O("limits.label.kimi_parallel",{count:e.parallel_limit})}):null,!e.primary_window&&!e.secondary_window&&!e.tertiary_window?p.jsx(xa,{children:O("limits.status.no_data")}):null]},"kimi");case"kiro":return p.jsxs(ws,{name:n.name,icon:n.icon,children:[e.primary_window?p.jsx(_r,{label:O("limits.label.kiro_month"),pct:e.primary_window.used_percent,reset:br(e.primary_window.reset_at)}):null,e.secondary_window?p.jsx(_r,{label:O("limits.label.kiro_bonus"),pct:e.secondary_window.used_percent,reset:br(e.secondary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window?p.jsx(xa,{children:O("limits.status.no_data")}):null]},"kiro");case"antigravity":return p.jsxs(ws,{name:n.name,icon:n.icon,children:[e.primary_window?p.jsx(_r,{label:"Claude",pct:e.primary_window.used_percent,reset:br(e.primary_window.reset_at)}):null,e.secondary_window?p.jsx(_r,{label:"G Pro",pct:e.secondary_window.used_percent,reset:br(e.secondary_window.reset_at)}):null,e.tertiary_window?p.jsx(_r,{label:"Flash",pct:e.tertiary_window.used_percent,reset:br(e.tertiary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window&&!e.tertiary_window?p.jsx(xa,{children:O("limits.status.no_data")}):null]},"antigravity");case"copilot":return p.jsxs(ws,{name:n.name,icon:n.icon,children:[e.primary_window?p.jsx(_r,{label:O("limits.label.copilot_premium"),pct:e.primary_window.used_percent,reset:br(e.primary_window.reset_at)}):null,e.secondary_window?p.jsx(_r,{label:O("limits.label.copilot_chat"),pct:e.secondary_window.used_percent,reset:br(e.secondary_window.reset_at)}):null,!e.primary_window&&!e.secondary_window?p.jsx(xa,{children:O("limits.status.no_data")}):null,e.otel_has_files||e.otel_enabled?null:p.jsx(bve,{defaultDir:e.otel_default_dir})]},"copilot");default:return null}}function bve({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(`
|
|
5224
|
-
`),a=async()=>{try{await navigator.clipboard.writeText(i),n(!0),setTimeout(()=>n(!1),1600)}catch{}};return p.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:[p.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:O("limits.copilot.otelHint.title")}),p.jsx("div",{className:"mt-0.5 leading-snug",children:O("limits.copilot.otelHint.body")}),p.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}),p.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:O(e?"limits.copilot.otelHint.copied":"limits.copilot.otelHint.copy")})]})}function _ve({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},m=(Array.isArray(c)&&c.length>0?c:yve).filter(g=>!u||u[g]!==!1).map(g=>xve(g,f[g])).filter(Boolean);return p.jsx(_o,{delay:.15,children:p.jsx(pu,{children:p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:O("limits.panel.title")}),m.length>0?m:p.jsx(xa,{children:O("limits.status.all_hidden")})]})})})}function wve(){const{data:t,error:e,isLoading:n}=r4({initialRefresh:!0}),r=mj();return p.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:p.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:p.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[p.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:O("nav.limits")}),p.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:O("limits.page.subtitle")})]}),p.jsx(Ei,{to:"/settings","aria-label":O("limits.page.openSettings"),title:O("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:p.jsx(H3,{className:"h-4 w-4","aria-hidden":!0})})]}),n?p.jsx(mve,{}):p.jsxs(p.Fragment,{children:[e?p.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:O("shared.error.prefix",{error:e})}):null,p.jsx(_ve,{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 Sve(t){const e=new URLSearchParams(t).get("next");return typeof e!="string"||e.length===0||!e.startsWith("/")||e.startsWith("//")?"/dashboard":e}const RD={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",linkedin:"LinkedIn",facebook:"Facebook",instagram:"Instagram",tiktok:"TikTok",apple:"Apple",x:"X",spotify:"Spotify"};function ND(t){const e=String(t||"").trim();return RD[e]?RD[e]:e.replace(/-/g," ")}function kve(){const t=tf(),[e,n]=K8(),{enabled:r,loading:i,signedIn:a,refreshUser:s,signInWithPassword:o,signUp:c,signInWithOAuth:u,getPublicAuthConfig:f}=ls(),h=x.useMemo(()=>Sve(e.toString()),[e]),[m,g]=x.useState("signin"),[v,w]=x.useState(""),[b,_]=x.useState(""),[E,M]=x.useState(""),[T,P]=x.useState(!1),[A,R]=x.useState(null),[k,N]=x.useState(null),[B,L]=x.useState(!0),[z,I]=x.useState([]),[V,W]=x.useState([]),[X,J]=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(O("login.verify_email_success")):ce==="error"&&ee==="verify_email"&&le&&N(O("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?(I(["google","github"]),W([])):(I(Array.isArray(ee.oAuthProviders)?ee.oAuthProviders:[]),W(Array.isArray(ee.customOAuthProviders)?ee.customOAuthProviders:[]),typeof ee.passwordMinLength=="number"&&ee.passwordMinLength>0&&J(ee.passwordMinLength)),L(!1))})(),()=>{ce=!1}},[r,f]);const F=x.useMemo(()=>e.get("native")==="1",[e]),G=x.useMemo(()=>e.get("provider")||null,[e]);x.useEffect(()=>{if(!(!r||i)&&a){if(F){window.location.href="/auth/native-callback";return}t(h,{replace:!0})}},[r,i,a,t,h,F]),x.useEffect(()=>{r&&s()},[r,s]);const Y=x.useMemo(()=>typeof window>"u"||F?"":`${window.location.origin}/`,[F]),H=x.useMemo(()=>typeof window>"u"?"":`${window.location.origin}/`,[]),te=x.useCallback(async ce=>{ce.preventDefault(),R(null),P(!0);try{if(m==="signup"){const{data:le,error:ve}=await c({email:v.trim(),password:b,name:E.trim()||void 0,redirectTo:H});if(ve){R(ve.message||String(ve));return}if(le?.requireEmailVerification){N(O("login.verify_email_pending")),g("signin");return}t(h,{replace:!0});return}const{error:ee}=await o({email:v.trim(),password:b});if(ee){R(ee.message||String(ee));return}t(h,{replace:!0})}finally{P(!1)}},[m,v,b,E,c,o,t,h,H]),re=x.useCallback(async ce=>{R(null),P(!0);try{const{error:ee}=await u(ce,Y);ee&&R(ee.message||String(ee))}finally{P(!1)}},[u,Y]);x.useEffect(()=>{if(F&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[F]),x.useEffect(()=>{if(!r||i||a||B||!F||!G)return;[...z,...V].includes(G)&&re(G)},[r,i,a,B,F,G,z,V,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?p.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[p.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:p.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:O("login.back_home")})}),p.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:p.jsxs("div",{className:"w-full max-w-md space-y-8",children:[p.jsxs("div",{className:"text-center",children:[p.jsx("h1",{className:"text-2xl font-semibold text-white tracking-tight",children:O("login.title")}),p.jsx("p",{className:"mt-2 text-sm text-oai-gray-500",children:O("login.subtitle")})]}),k?p.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:[p.jsx("span",{children:k}),p.jsx("button",{type:"button",onClick:ue,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:O("login.dismiss")})]}):null,A?p.jsx("p",{className:"text-sm text-red-400",role:"alert",children:O("shared.error.prefix",{error:A})}):null,p.jsx("div",{className:"space-y-3",children:B?p.jsx("div",{className:"h-11 rounded-lg bg-oai-gray-900 animate-pulse","aria-hidden":!0}):p.jsxs(p.Fragment,{children:[z.map(ce=>p.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:O("login.oauth.continue",{provider:ND(ce)})},ce)),V.map(ce=>p.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:O("login.oauth.continue",{provider:ND(ce)})},ce))]})}),p.jsxs("div",{className:"relative",children:[p.jsx("div",{className:"absolute inset-0 flex items-center","aria-hidden":!0,children:p.jsx("span",{className:"w-full border-t border-oai-gray-800"})}),p.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:p.jsx("span",{className:"bg-oai-gray-950 px-3 text-oai-gray-600",children:O("login.divider")})})]}),p.jsxs("div",{className:"flex rounded-lg border border-oai-gray-800 p-0.5 bg-oai-gray-900/50",children:[p.jsx("button",{type:"button",className:vt("flex-1 py-2 text-sm font-medium rounded-md transition-colors",m==="signin"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{g("signin"),R(null)},children:O("login.tab.sign_in")}),p.jsx("button",{type:"button",className:vt("flex-1 py-2 text-sm font-medium rounded-md transition-colors",m==="signup"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{g("signup"),R(null)},children:O("login.tab.sign_up")})]}),p.jsxs("form",{onSubmit:te,className:"space-y-4",children:[m==="signup"?p.jsxs("div",{children:[p.jsx("label",{htmlFor:"login-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:O("login.field.name")}),p.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:O("login.field.name_placeholder")})]}):null,p.jsxs("div",{children:[p.jsx("label",{htmlFor:"login-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:O("login.field.email")}),p.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"})]}),p.jsxs("div",{children:[p.jsx("label",{htmlFor:"login-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:O("login.field.password")}),p.jsx("input",{id:"login-password",type:"password",autoComplete:m==="signup"?"new-password":"current-password",required:!0,minLength:m==="signup"?X: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"}),m==="signup"?p.jsx("p",{className:"mt-1 text-xs text-oai-gray-600",children:O("login.password_hint",{min:String(X)})}):null]}),p.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:O(m==="signup"?"login.submit.sign_up":"login.submit.sign_in")})]})]})})]}):p.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[p.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:p.jsx(Ei,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:O("login.back_home")})}),p.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:p.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",children:O("login.cloud_only")})})]})}const Eve=typeof window<"u"?window.location.search:"",DD=new URLSearchParams(Eve),n0=DD.get("insforge_code")||DD.get("code")||null;function Mve(){lu();const{loading:t,signedIn:e}=ls(),n=tf(),[r,i]=x.useState("processing"),[a,s]=x.useState(null),o=x.useRef(!1);return x.useEffect(()=>{!n0||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||!n0)return;i("redirecting");const c=setTimeout(()=>{window.location.href=`tokentracker://auth/callback?insforge_code=${encodeURIComponent(n0)}`},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(!n0&&a===null){const c=setTimeout(()=>i("failed"),3e3);return()=>clearTimeout(c)}},[a]),r==="processing"&&a!==!0&&(a===null||a===!1&&t)?p.jsx("div",{className:"min-h-screen bg-oai-gray-950"}):p.jsx("div",{className:"min-h-screen bg-oai-gray-950 text-white font-oai antialiased dark flex items-center justify-center",children:p.jsxs("div",{className:"text-center space-y-4 max-w-sm px-4",children:[r==="processing"&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"w-8 h-8 border-2 border-oai-gray-600 border-t-white rounded-full animate-spin mx-auto"}),p.jsx("p",{className:"text-oai-gray-400 text-sm",children:O("auth.callback.processing")})]}),r==="redirecting"&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"w-12 h-12 mx-auto rounded-full bg-green-500/15 flex items-center justify-center",children:p.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:p.jsx("path",{d:"M20 6 9 17l-5-5"})})}),p.jsx("p",{className:"text-white text-sm font-medium",children:O("auth.callback.success")}),p.jsx("p",{className:"text-oai-gray-500 text-xs",children:O("auth.callback.redirecting")})]}),r==="failed"&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("p",{className:"text-oai-gray-300 text-sm",children:O("auth.callback.failed")}),p.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:O("auth.callback.close")})]})]})})}const Tve=new Set(["cursor","kiro","copilot","kimi"]);function Cve({checked:t,onChange:e,ariaLabel:n}){return p.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:p.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 Ave({prefs:t}){const{order:e,visibility:n,toggle:r,moveToward:i}=t,[a,s]=x.useState(null),[o,c]=x.useState(null),u=g=>v=>{s(g),v.dataTransfer.effectAllowed="move",v.dataTransfer.setData("text/plain",g)},f=g=>v=>{v.preventDefault(),v.dataTransfer.dropEffect="move",a&&a!==g&&o!==g&&(c(g),i(a,g))},h=()=>{s(null),c(null)},m=g=>{g.preventDefault(),s(null),c(null)};return p.jsx(MX,{children:p.jsx("div",{className:"flex flex-col",children:e.map(g=>{const v=n[g]!==!1,w=a===g;return p.jsxs(Qn.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:u(g),onDragOver:f(g),onDragEnd:h,onDrop:m,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:[p.jsx(qW,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),p.jsx("img",{src:dve[g],alt:"",width:18,height:18,className:vt("h-[18px] w-[18px] shrink-0 pointer-events-none",Tve.has(g)&&"dark:invert"),draggable:!1}),p.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:CD[g]}),p.jsx("div",{onMouseDown:b=>b.stopPropagation(),draggable:!1,children:p.jsx(Cve,{checked:v,onChange:()=>r(g),ariaLabel:`${O("limits.settings.toggle_visible")}: ${CD[g]}`})})]},g)})})})}function Pve(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 Rve(t){return!t||typeof t!="object"?"":typeof t.email=="string"?t.email.trim():""}function Nve(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 mM(t,e){console.warn(`[tokentracker] settings ${t}:`,e)}function Dve(t,e,n){const[r,i]=x.useState(()=>_k()),a=e&&n&&p3(),s=x.useCallback(async()=>{const o=!r;if(m3(o),i(o),!!o)try{await e4(()=>t())}catch(c){mM("cloud sync",c)}},[r,t]);return{cloudSyncOn:r,handleCloudSyncToggle:s,showLocalCloudSync:a}}function Lve(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,m]=x.useState(!1),[g,v]=x.useState(""),[w,b]=x.useState(!1),[_,E]=x.useState(""),[M,T]=x.useState(""),[P,A]=x.useState(!1),[R,k]=x.useState(null),N=x.useMemo(()=>Pve(t),[t]),B=x.useMemo(()=>Rve(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:P,editingName:h,email:B,githubError:R,githubInput:M,githubUrl:_,loadSetters:L,nameInput:g,profileLoading:a,profileSaving:o,publicProfileOn:e,setAnonymousOn:i,setCustomDisplayName:f,setEditingGithub:A,setEditingName:m,setGithubError:k,setGithubInput:T,setGithubUrl:E,setNameInput:v,setProfileLoading:s,setProfileSaving:c,setPublicProfileOn:n,setShowGithubOn:b,showGithubOn:w}}function Ive(t,e,n){x.useEffect(()=>{if(!e)return;let r=!0;return n.setProfileLoading(!0),(async()=>{try{const i=await Zh({getAccessToken:t});if(!r||!i)return;const a=await Bw({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){mM("load public profile",i)}finally{r&&n.setProfileLoading(!1)}})(),()=>{r=!1}},[t,e,n])}function Ove(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 Zh({getAccessToken:t});if(!s)return!1;const o=await y7({accessToken:s,...n});return a?.(o),!0}catch(s){return i?i(s):mM(r||"mutate profile",s),!1}finally{e.setProfileSaving(!1)}},[t,e])}function Fve(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 Uve(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 jve(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 Bve(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 zve(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=Nve(t.githubInput);if(t.githubInput.trim()&&!a){t.setGithubError(O("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||O("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 Vve(){const t=ls(),e=Lve(t.user),n=Dve(t.getAccessToken,t.enabled,t.signedIn);Ive(t.getAccessToken,t.signedIn,e.loadSetters);const r=Ove(t.getAccessToken,e),i=jve(e,r),a=Bve(e,r),s=zve(e,r);return{...t,...n,email:e.email,handlePublicProfileToggle:i.handlePublicProfileToggle,name:Fve(e,{...i,...a}),github:Uve(e,s),profileLoading:e.profileLoading,profileSaving:e.profileSaving,publicProfileOn:e.publicProfileOn}}function bf({checked:t,onChange:e,disabled:n,ariaLabel:r}){return p.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:p.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 Wc({label:t,hint:e,control:n}){return p.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:t}),e?p.jsx("div",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e}):null]}),p.jsx("div",{className:"shrink-0",children:n})]})}function Xp({title:t,subtitle:e,action:n,children:r}){return p.jsxs(pu,{children:[p.jsxs("div",{className:"mb-3 flex items-start justify-between gap-4",children:[p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("h2",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:t}),e?p.jsx("p",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e}):null]}),n?p.jsx("div",{className:"shrink-0",children:n}):null]}),p.jsx("div",{className:"-mb-3 divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:r})]})}function LD({options:t,value:e,onChange:n}){return p.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 p.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?p.jsx(a,{className:"h-3.5 w-3.5","aria-hidden":!0}):null,p.jsx("span",{children:i})]},r)})})}function gj({disabled:t,onCancel:e,onSave:n,saveLabel:r=O("settings.account.save")}){return p.jsxs(p.Fragment,{children:[p.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}),p.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:O("settings.account.cancel")})]})}function Hve({nameInput:t,setEditingName:e,setNameInput:n,profileSaving:r,handleSaveName:i}){return p.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[p.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:O("settings.account.displayName")}),p.jsx(gj,{disabled:r||!t.trim(),onCancel:()=>e(!1),onSave:i,saveLabel:r?O("settings.account.saving"):void 0})]})}function Wve({githubError:t,githubInput:e,handleSaveGithub:n,profileSaving:r,setEditingGithub:i,setGithubError:a,setGithubInput:s}){return p.jsxs("div",{className:"mt-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.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:O("settings.account.githubUrlPlaceholder")}),p.jsx(gj,{disabled:r,onCancel:()=>{i(!1),a(null)},onSave:n,saveLabel:r?O("settings.account.saving"):void 0})]}),t?p.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:t}):null]})}function yj({disabled:t=!1,label:e,onClick:n,title:r}){return p.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:[p.jsx(cG,{className:"h-3.5 w-3.5","aria-hidden":!0}),e]})}function vj({actions:t,editing:e,editor:n,hint:r,label:i}){return p.jsx("div",{className:"py-3",children:p.jsxs("div",{className:"flex items-start justify-between gap-4",children:[p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:i}),e?n:p.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r})]}),e?null:t]})})}function Gve({name:t}){const e=t.anonymousOn?O("settings.account.displayNameDisabledWhileAnon"):void 0;return p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[p.jsx(yj,{disabled:t.anonymousOn,label:O("settings.account.edit"),onClick:t.startEditingName,title:e}),p.jsx(bf,{checked:!t.anonymousOn,onChange:t.handleAnonymousToggle,disabled:t.profileLoading||t.profileSaving,ariaLabel:O("settings.account.displayName")})]})}function $ve({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:m}=t,g=e?O("settings.account.displayNameAnonymousHint"):n||r;return p.jsx(vj,{label:O("settings.account.displayName"),editing:i,hint:g,editor:p.jsx(Hve,{nameInput:o,setEditingName:f,setNameInput:h,profileSaving:u,handleSaveName:s}),actions:p.jsx(Gve,{name:t})})}function Yve({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:m,startEditingGithub:g}=t;return p.jsx(vj,{label:O("settings.account.githubUrl"),editing:e,hint:i||O("settings.account.githubUrlHint"),editor:p.jsx(Wve,{githubError:n,githubInput:r,handleSaveGithub:a,profileSaving:c,setEditingGithub:u,setGithubError:f,setGithubInput:h}),actions:p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[p.jsx(yj,{label:O("settings.account.edit"),onClick:g}),p.jsx(bf,{checked:m,onChange:s,disabled:o||c,ariaLabel:O("settings.account.githubUrl")})]})})}function qve(){const{openLoginModal:t}=Cp();return p.jsx(Xp,{title:O("settings.section.account"),children:p.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:O("settings.account.signedOutHint")}),p.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:O("settings.account.signIn")})]})})}function Xve({name:t,github:e}){return p.jsxs(p.Fragment,{children:[p.jsx($ve,{name:t}),p.jsx(Yve,{github:e})]})}function Kve(){const t=Vve();return t.enabled?t.signedIn?p.jsxs(Xp,{title:O("settings.section.account"),subtitle:t.email||t.name.customDisplayName||t.name.displayName,action:p.jsx(Zve,{onSignOut:t.signOut}),children:[p.jsx(Jve,{settings:t}),p.jsx(Qve,{checked:t.publicProfileOn,disabled:t.profileLoading||t.profileSaving,onChange:t.handlePublicProfileToggle}),p.jsx(exe,{visible:t.publicProfileOn,name:t.name,github:t.github})]}):p.jsx(qve,{}):null}function Zve({onSignOut:t}){return p.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:[p.jsx(tG,{className:"h-3.5 w-3.5","aria-hidden":!0}),O("settings.account.signOut")]})}function Jve({settings:t}){return t.showLocalCloudSync?p.jsx(Wc,{label:O("settings.account.cloudSync"),hint:O("settings.account.cloudSyncHint"),control:p.jsx(bf,{checked:t.cloudSyncOn,onChange:t.handleCloudSyncToggle,ariaLabel:O("settings.account.cloudSync")})}):null}function Qve({checked:t,disabled:e,onChange:n}){return p.jsx(Wc,{label:O("settings.account.publicProfile"),hint:O("settings.account.publicProfileHint"),control:p.jsx(bf,{checked:t,onChange:n,disabled:e,ariaLabel:O("settings.account.publicProfile")})})}function exe({visible:t,name:e,github:n}){return p.jsx(Lp,{initial:!1,children:t?p.jsx(Qn.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:p.jsx(Xve,{name:e,github:n})},"public-profile-fields"):null})}function txe(){return[{value:"light",label:O("settings.appearance.theme.light"),Icon:Nk},{value:"dark",label:O("settings.appearance.theme.dark"),Icon:Pk},{value:"system",label:O("settings.appearance.theme.system"),Icon:Wy}]}function nxe(){return[{value:Jc,label:O("settings.appearance.language.system"),Icon:Wy},{value:Qh,label:O("settings.appearance.language.english"),Icon:B2},{value:zy,label:O("settings.appearance.language.chinese"),Icon:B2}]}function rxe(){const{theme:t,setTheme:e}=Op(),{locale:n,setLocale:r}=lu();return p.jsxs(Xp,{title:O("settings.section.appearance"),children:[p.jsx(Wc,{label:O("settings.appearance.theme.label"),hint:O("settings.appearance.theme.hint"),control:p.jsx(LD,{options:txe(),value:t,onChange:e})}),p.jsx(Wc,{label:O("settings.appearance.language.label"),hint:O("settings.appearance.language.hint"),control:p.jsx(LD,{options:nxe(),value:n,onChange:r})})]})}function gM(){const[t,e]=x.useState(null),n=Tk()&&K7();x.useEffect(()=>{if(!n)return;const s=Q7(o=>e(o));return F2(),s},[n]);const r=x.useCallback((s,o)=>{n&&(e(c=>c&&{...c,[s]:o}),Ww(s,o))},[n]),i=x.useCallback(s=>{n&&I3(s)},[n]),a=x.useCallback(()=>{n&&F2()},[n]);return{available:n,settings:t,setSetting:r,runAction:i,refresh:a}}function ixe(){const{available:t,settings:e,setSetting:n,runAction:r}=gM();if(!t)return null;const i=!!e?.launchAtLogin,a=e?.launchAtLoginSupported!==!1,s=e?.updateStatus||null,o=!!e?.updateBusy,c=!!e?.isSyncing;return p.jsxs(Xp,{title:O("settings.section.menubar"),children:[a?p.jsx(Wc,{label:O("settings.menubar.launchAtLogin"),hint:O("settings.menubar.launchAtLoginHint"),control:p.jsx(bf,{checked:i,onChange:()=>n("launchAtLogin",!i),ariaLabel:O("settings.menubar.launchAtLogin")})}):null,p.jsx(Wc,{label:O("settings.menubar.syncNow"),hint:O("settings.menubar.syncNowHint"),control:p.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:[p.jsx(Rk,{className:vt("h-3.5 w-3.5",c&&"animate-spin"),"aria-hidden":!0}),O(c?"settings.menubar.syncing":"settings.menubar.syncNow")]})}),p.jsx(Wc,{label:O("settings.menubar.updates"),hint:s||void 0,control:p.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:[p.jsx(Ak,{className:"h-3.5 w-3.5","aria-hidden":!0}),O("settings.menubar.checkUpdates")]})})]})}function axe(){const{available:t,settings:e,runAction:n}=gM();return!t||!e?.version?null:p.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-500",children:[p.jsxs("span",{children:["TokenTrackerBar v",e.version]}),p.jsx("span",{"aria-hidden":!0,children:"·"}),p.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 sxe(){const t=mj();return p.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:p.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:p.jsxs("div",{className:"mx-auto max-w-3xl px-4 sm:px-6",children:[p.jsxs("div",{className:"mb-8",children:[p.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:O("settings.page.title")}),p.jsx("p",{className:"mt-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:O("settings.page.subtitle")})]}),p.jsxs("div",{className:"space-y-4",children:[p.jsx(rxe,{}),p.jsx(ixe,{}),p.jsx(Kve,{}),p.jsx(Xp,{title:O("settings.section.limits"),children:p.jsx(Ave,{prefs:t})})]}),p.jsx(axe,{})]})})})}const xj="tokentracker-skills";async function _v(t){const e=new URL(`/functions/${xj}`,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 $l(t){const e=await By(),n=await fetch(`/functions/${xj}`,{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 oxe(){return _v({mode:"installed"})}function lxe(t={}){return _v({mode:"discover",...t.force?{force:1}:{}})}function cxe(t,e=0,n=20){return _v({mode:"search",q:t,offset:e,limit:n})}function uxe(){return _v({mode:"repos"})}function dxe(t,e){return $l({action:"install",skill:t,targets:e})}function fxe(t){return $l({action:"uninstall",id:t})}function hxe(t){return $l({action:"restore",id:t})}function pxe(t,e){return $l({action:"set_targets",id:t,targets:e})}function mxe(t,e){return $l({action:"import_local",directory:t,targets:e})}function gxe(t,e){return $l({action:"delete_local",directory:t,targets:e||[]})}function yxe(t){return $l({action:"add_repo",repo:t})}function vxe(t,e){return $l({action:"remove_repo",owner:t,name:e})}const ID=["claude","codex"],xxe={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"},hd="all",ta="skillssh";function N0(t){return`${t.repoOwner||"local"}/${t.repoName||"local"}:${t.directory}`}function OD(t){return`install:${N0(t)}`}function GS(t){return`remove:${t.id||t.directory}`}function bj(t,e){return`target:${t}:${e}`}function bxe({skill:t,targets:e,busyKey:n,onToggleTarget:r}){const i=new Set(t.targets||[]);return p.jsx("div",{className:"flex flex-wrap gap-1",children:e.map(a=>{const s=i.has(a.id),o=n===bj(t.id,a.id),c=s?"skills.target.remove_title":"skills.target.sync_title";return p.jsx("button",{type:"button","aria-pressed":s,"aria-label":O("skills.target.toggle_aria",{target:a.label}),title:O(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?xxe[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?p.jsx(Ao,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):p.jsx(nu,{provider:a.id,size:16})},a.id)})})}function _xe({skill:t,targets:e,busyKey:n,onToggleTarget:r,onRemove:i}){const a=n===GS(t),s=t.repoOwner&&t.repoName?`${t.repoOwner}/${t.repoName}`:null,o=s?`${t.directory} · ${s}`:t.directory;return p.jsxs("div",{className:"group grid gap-4 px-1 py-3 lg:grid-cols-[minmax(0,1fr)_auto_auto] lg:items-center",children:[p.jsxs("div",{className:"min-w-0",title:o,children:[p.jsx("h2",{className:"truncate text-sm font-semibold text-oai-black dark:text-white",children:t.name||t.directory}),t.description?p.jsx("p",{className:"mt-0.5 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t.description}):null]}),p.jsx(bxe,{skill:t,targets:e,busyKey:n,onToggleTarget:r}),p.jsx("button",{type:"button","aria-label":O("skills.action.remove"),title:O("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?p.jsx(Ao,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):p.jsx(W3,{className:"h-4 w-4","aria-hidden":!0})})]})}function wxe({items:t,targets:e,busyKey:n,onToggleTarget:r,onRemove:i}){return p.jsxs("div",{children:[p.jsx("div",{className:"px-1 pb-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O("skills.my.count",{count:t.length})}),p.jsx("div",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:t.map(a=>p.jsx(_xe,{skill:a,targets:e,busyKey:n,onToggleTarget:r,onRemove:i},a.id||a.key))})]})}const Sxe={contentVisibility:"auto",containIntrinsicSize:"0 240px"},kxe=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?O("skills.card.installs",{count:Number(e.installs||0).toLocaleString()}):null,m=[f,h].filter(Boolean).join(" · "),g=o.length?o.map(v=>i.find(w=>w.id===v)?.label||v).join(", "):O("skills.action.choose_targets");return p.jsxs(pu,{className:"h-full rounded-lg",bodyClassName:"flex h-full flex-col",children:[p.jsxs("div",{className:"flex items-start justify-between gap-3",children:[p.jsxs("div",{className:"min-w-0",children:[e.readmeUrl?p.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:[p.jsx("span",{className:"truncate",children:e.name||e.directory}),p.jsx(VW,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400 opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":!0})]}):p.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:e.name||e.directory}),m?p.jsx("div",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:m}):null]}),n?p.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:[p.jsx(Lh,{className:"h-3 w-3","aria-hidden":!0}),O("skills.card.installed")]}):null]}),e.description?p.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,p.jsx("div",{className:"mt-auto pt-5",children:n?p.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:[p.jsx(Lh,{className:"h-3.5 w-3.5","aria-hidden":!0}),O("skills.card.installed")]}):p.jsxs("div",{className:"flex",children:[p.jsxs(Ui,{type:"button",size:"sm",onClick:()=>s(e,o),disabled:r||o.length===0,className:"flex-1 !rounded-r-none",title:g,children:[r?p.jsx(Ao,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):p.jsx(Ak,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),o.length>1?O("skills.action.install_to",{count:o.length}):O("skills.action.install")]}),p.jsxs(K5,{children:[p.jsx(Z5,{disabled:r,"aria-label":O("skills.action.choose_targets"),title:g,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:p.jsx(Hy,{className:"h-3.5 w-3.5","aria-hidden":!0})}),p.jsx(Q5,{children:p.jsx(tF,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:p.jsxs(nF,{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:[p.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:O("skills.target.menu_label")}),i.map(v=>{const w=o.includes(v.id);return p.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:[p.jsx(nu,{provider:v.id,size:16,className:w?"":"grayscale opacity-40"}),p.jsx("span",{className:"flex-1 text-left",children:v.label}),w?p.jsx(Lh,{className:"h-3.5 w-3.5 text-emerald-500","aria-hidden":!0}):null]},v.id)})]})})})]})]})})]})});function Exe({repos:t,repoInput:e,onRepoInput:n,busyKey:r,onAdd:i,onRemove:a}){return p.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:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[p.jsx(q5,{value:e,onChange:s=>n(s.target.value),placeholder:O("skills.repo.placeholder"),className:"min-w-0 flex-1"}),p.jsxs(Ui,{type:"button",variant:"secondary",size:"md",onClick:i,disabled:r==="repo:add",className:"shrink-0 whitespace-nowrap",children:[r==="repo:add"?p.jsx(Ao,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):p.jsx(V3,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),O("skills.repo.add")]})]}),t.length?p.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 p.jsxs("div",{className:"flex items-center justify-between gap-3 py-2",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"truncate text-sm font-medium text-oai-black dark:text-white",children:[s.owner,"/",s.name]}),p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s.branch})]}),p.jsxs(Ui,{type:"button",variant:"ghost",size:"sm",disabled:o,onClick:()=>a(s),className:"shrink-0",children:[o?p.jsx(Ao,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):p.jsx(W3,{className:"h-3.5 w-3.5","aria-hidden":!0}),p.jsx("span",{className:"sr-only",children:O("skills.repo.remove")})]})]},`${s.owner}/${s.name}`)})}):null]})}function Mxe(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Txe(){const[t,e]=x.useState(Mxe),[n,r]=x.useState({skills:[],targets:[]}),[i,a]=x.useState([]),[s,o]=x.useState([]),[c,u]=x.useState([]),[f,h]=x.useState(hd),[m,g]=x.useState(""),[v,w]=x.useState(""),[b,_]=x.useState(""),[E,M]=x.useState(!1),[T,P]=x.useState(""),[A,R]=x.useState(!0),[k,N]=x.useState(!1),[B,L]=x.useState(""),[z,I]=x.useState(null),[V,W]=x.useState(null),X=x.useMemo(()=>{const oe=new Set;for(const Q of n.skills||[]){oe.add(N0(Q).toLowerCase()),Q.repoOwner&&Q.repoName&&oe.add(`${Q.repoOwner}/${Q.repoName}:${Q.sourceDirectory||Q.directory}`.toLowerCase());const ze=String(Q.directory||"").split(/[\\/]/).pop().toLowerCase();ze&&oe.add(`dir:${ze}`)}return oe},[n.skills]),J=x.useCallback(async()=>{const oe=await oxe();r({skills:oe.skills||[],targets:oe.targets||[]})},[]),F=x.useCallback(async()=>{const oe=await uxe();u(oe.repos||[])},[]),G=x.useCallback(async({force:oe=!1}={})=>{N(!0);try{const Q=await lxe({force:oe});a(Q.skills||[])}finally{N(!1)}},[]),Y=x.useCallback(async()=>{R(!0),L("");try{await Promise.all([J(),F()])}catch(oe){L(oe?.message||O("skills.error.generic"))}finally{R(!1)}},[J,F]),H=x.useCallback(async()=>{await Y(),t==="browse"&&f!==ta&&G({force:!0}).catch(oe=>L(oe?.message||O("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||O("skills.error.generic")))},[i.length,G,f,t]),x.useEffect(()=>{if(!V)return;const oe=setTimeout(()=>W(Q=>Q?.key===V.key?null:Q),V.ttlMs||5e3);return()=>clearTimeout(oe)},[V]),x.useEffect(()=>{const oe=setTimeout(()=>w(m),200);return()=>clearTimeout(oe)},[m]),x.useEffect(()=>{if(typeof window>"u")return;const oe=new URLSearchParams(window.location.search),Q=oe.get("tab");if(t==="my"){if(!Q)return;oe.delete("tab")}else{if(Q===t)return;oe.set("tab",t)}const ze=oe.toString(),Pe=`${window.location.pathname}${ze?`?${ze}`:""}${window.location.hash}`;window.history.replaceState({},"",Pe)},[t]);const te=async(oe,Q)=>{P(oe),L("");try{await Q(),await J()}catch(ze){L(ze?.message||O("skills.error.generic"))}finally{P("")}},re=(oe,Q)=>{const ze=(Q&&Q.length?Q:ID).filter(Pe=>(n.targets||[]).some(De=>De.id===Pe));te(OD(oe),async()=>{await dxe(oe,ze);const Pe=ze.map(De=>(n.targets||[]).find(Le=>Le.id===De)?.label||De).join(", ");W({key:`${Date.now()}:install:${N0(oe)}`,message:O("skills.toast.installed",{name:oe.name||oe.directory,targets:Pe||O("skills.target.none")}),ttlMs:4e3})})},ue=oe=>{I(oe)},ce=()=>{const oe=z;oe&&(I(null),te(GS(oe),async()=>{let Q=null;oe.managed?Q=await fxe(oe.id):await gxe(oe.directory,oe.targets||[]);const ze=!!(Q?.trashed&&oe.managed&&oe.id);W({key:`${Date.now()}:${oe.id||oe.directory}`,message:O("skills.toast.removed",{name:oe.name||oe.directory}),undo:ze?async()=>{try{await hxe(oe.id),await J(),W(null)}catch(Pe){L(Pe?.message||O("skills.error.generic"))}}:null,ttlMs:5e3})}))},ee=(oe,Q,ze)=>te(bj(oe.id,Q),async()=>{const Pe=new Set(oe.targets||[]);ze?Pe.add(Q):Pe.delete(Q),oe.managed?await pxe(oe.id,Array.from(Pe)):await mxe(oe.directory,Array.from(Pe))}),le=async()=>{const oe=m.trim();if(!(oe.length<2)){P("search"),L("");try{const Q=await cxe(oe);o(Q.skills||[])}catch(Q){L(Q?.message||O("skills.error.generic"))}finally{P("")}}},ve=async()=>{const oe=b.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[Q,ze]=oe.split("/");if(!Q||!ze){L(O("skills.repo.invalid"));return}await te("repo:add",async()=>{await yxe({owner:Q,name:ze,branch:"main",enabled:!0}),_(""),await F(),await G()})},Ne=async oe=>{await te(`repo:${oe.owner}/${oe.name}`,async()=>{await vxe(oe.owner,oe.name),await F(),await G()})},be=n.targets||[],qe=n.skills||[],he=x.useMemo(()=>{const oe=f===ta?s:i,Q=f===ta||f===hd?oe:oe.filter(De=>`${De.repoOwner}/${De.repoName}`===f),ze=v.trim().toLowerCase();return(f===ta||!ze?Q:Q.filter(De=>(De.name||"").toLowerCase().includes(ze)||(De.directory||"").toLowerCase().includes(ze)||(De.description||"").toLowerCase().includes(ze))).map(De=>{const Le=N0(De).toLowerCase(),$=String(De.directory||"").split(/[\\/]/).pop().toLowerCase(),U=$?`dir:${$}`:"";return{...De,installed:X.has(Le)||U&&X.has(U)}})},[v,i,X,s,f]),Ue=p.jsx("div",{className:"flex h-64 items-center justify-center",children:p.jsx(Ao,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),je=p.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[p.jsx(Ao,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0}),p.jsx("p",{className:"max-w-md text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O("skills.browse.loading_hint")})]}),et=(oe,Q=null)=>p.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:[p.jsx("p",{children:O(oe)}),Q]});let _e;if(A)_e=Ue;else if(t==="my")_e=qe.length?p.jsx(wxe,{items:qe,targets:be,busyKey:T,onToggleTarget:ee,onRemove:ue}):p.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?p.jsxs("div",{className:"relative h-11 w-80 overflow-hidden","aria-hidden":!0,children:[p.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:p.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,Q)=>p.jsx("span",{className:"shrink-0 px-3",children:p.jsx(nu,{provider:oe.id,size:30})},`b-${Q}`))})}),p.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:p.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",children:[...be,...be].map((oe,Q)=>p.jsx("span",{className:"shrink-0 px-3",children:p.jsx(nu,{provider:oe.id,size:30})},`c-${Q}`))})}),p.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"}),p.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,p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:O("skills.empty.my")}),p.jsx(Ui,{type:"button",size:"sm",onClick:()=>e("browse"),children:O("skills.empty.my_cta")})]});else{const oe=f===ta,Q=c.length===0&&!oe;let ze;Q?ze=p.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 p-6 text-center dark:border-oai-gray-800",children:p.jsx("p",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:O("skills.browse.empty_sources")})}):k&&!oe?ze=je:oe&&m.trim().length<2?ze=p.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:O("skills.browse.hint_skillssh")}):he.length?ze=p.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:he.map(De=>p.jsx("div",{style:Sxe,children:p.jsx(kxe,{skill:De,installed:!!De.installed,installing:T===OD(De),allTargets:be,defaultTargets:ID,onInstall:re})},De.id||De.key))}):oe?ze=et("skills.empty.search"):ze=et("skills.empty.browse");const Pe=Q||E?p.jsx("div",{className:"mb-5",children:p.jsx(Exe,{repos:c,repoInput:b,onRepoInput:_,busyKey:T,onAdd:ve,onRemove:Ne})}):null;_e=p.jsxs(p.Fragment,{children:[Pe,ze]})}return p.jsxs("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:[p.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:p.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[p.jsxs("div",{className:"mb-6 flex items-end justify-between gap-4",children:[p.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:O("skills.page.title")}),p.jsxs(Ui,{type:"button",variant:"secondary",size:"sm",onClick:H,disabled:A||k,children:[p.jsx(Rk,{className:vt("mr-1.5 h-3.5 w-3.5",(A||k)&&"animate-spin"),"aria-hidden":!0}),O("skills.action.refresh")]})]}),p.jsx("div",{className:"mb-5 flex gap-6 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[["my",O("skills.tab.my")],["browse",O("skills.tab.browse")]].map(([oe,Q])=>p.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:Q},oe))}),B?p.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:B}):null,t==="browse"?p.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[p.jsx("div",{role:"tablist","aria-label":O("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",O("skills.mode.repo")],["skillssh",O("skills.mode.skillssh")]].map(([oe,Q])=>{const ze=oe==="skillssh"==(f===ta);return p.jsx("button",{type:"button",role:"tab","aria-selected":ze,onClick:()=>{oe==="skillssh"?h(ta):f===ta&&h(hd)},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:Q},oe)})}),f!==ta?p.jsxs(cne,{value:f,onValueChange:h,children:[p.jsxs(vne,{"aria-label":O("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:[p.jsx(bne,{children:oe=>oe===hd?O("skills.source.all"):oe}),p.jsx(_ne,{className:"text-oai-gray-400",children:p.jsx(Hy,{className:"h-4 w-4","aria-hidden":!0})})]}),p.jsx(Sne,{children:p.jsx(Wne,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:p.jsxs(ere,{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:[p.jsxs(oR,{value:hd,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:[p.jsx(cR,{children:O("skills.source.all")}),p.jsx(lR,{children:p.jsx(Lh,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),c.map(oe=>{const Q=`${oe.owner}/${oe.name}`;return p.jsxs(oR,{value:Q,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:[p.jsx(cR,{children:Q}),p.jsx(lR,{children:p.jsx(Lh,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},Q)})]})})})]}):null,p.jsxs("div",{className:"relative flex-1",children:[p.jsx(z2,{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}),p.jsx(q5,{value:m,onChange:oe=>g(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&f===ta&&le()},placeholder:f===ta?O("skills.browse.placeholder_skillssh"):f===hd?O("skills.browse.placeholder_all"):O("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?p.jsxs(Ui,{type:"button",onClick:le,disabled:m.trim().length<2||T==="search",className:"focus:!ring-oai-gray-400/30",children:[T==="search"?p.jsx(Ao,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):p.jsx(z2,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),O("skills.action.search")]}):p.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:[p.jsx(V3,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),O("skills.browse.manage_sources"),p.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]})}),p.jsx(Lre,{open:!!z,title:O("skills.confirm.remove_title",{name:z?.name||z?.directory||""}),description:z?z.managed?O("skills.confirm.remove_managed"):O("skills.confirm.remove_local"):"",confirmLabel:O("skills.action.remove"),cancelLabel:O("shared.action.cancel"),destructive:!0,busy:T===GS(z||{}),onCancel:()=>I(null),onConfirm:ce}),V?p.jsx("div",{className:"pointer-events-none fixed inset-x-0 bottom-6 z-[90] flex justify-center px-4",children:p.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:[p.jsx("span",{children:V.message}),V.undo?p.jsx("button",{type:"button",onClick:V.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:O("shared.action.undo")}):null]})}):null]})}const Cxe=["todayTokens","todayCost"],_j=[{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 FD(t,e=_j,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:Cxe).slice(0,Math.max(1,Number(n)||2))}const Axe=264,Pxe=124,To="ui-rounded, -apple-system, system-ui",UD=["#5A8CF2","#9973E6","#4DB8A6","#E68C59"],Rxe={claude:"#C77DFF",codex:"#34C759",cursor:"#FFCC00",gemini:"#0A84FF"};function Nxe(t){return t>=.9?"#E64D4D":t>=.7?"#D9A633":"#33B866"}function wv({size:t="sm",children:e}){const n=t==="lg",r=n?560:264,i=n?32:22;return p.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:p.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:`${Axe} / ${Pxe}`,borderRadius:i},children:e})})}function Dxe({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 p.jsx(wv,{size:t,children:p.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[p.jsx("defs",{children:p.jsxs("linearGradient",{id:r,x1:"0",y1:"0",x2:"0",y2:"1",children:[p.jsx("stop",{offset:"0%",stopColor:"#0A84FF",stopOpacity:"0.18"}),p.jsx("stop",{offset:"100%",stopColor:"#0A84FF",stopOpacity:"0"})]})}),p.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"}),p.jsx("text",{x:"14",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:To,children:"203.2M"}),p.jsx("text",{x:"14",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:To,children:"$129.56 ±0%"}),p.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"}),p.jsx("text",{x:"134",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:To,children:"880.9M"}),p.jsx("text",{x:"134",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:To,children:"$673.61"}),p.jsx("path",{d:n,fill:`url(#${r})`,stroke:"none"}),p.jsx("path",{d:e,fill:"none",stroke:"#0A84FF",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const jD=(()=>{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 BD(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 Lxe(){return p.jsx(wv,{children:p.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[p.jsx("g",{transform:`translate(${19.5}, 10)`,className:"hidden dark:inline",children:jD.map(a=>p.jsx("rect",{x:a.w*(7.5+1.2),y:a.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:BD(a.v,!0)},`d-${a.w}-${a.d}`))}),p.jsx("g",{transform:`translate(${19.5}, 10)`,className:"dark:hidden",children:jD.map(a=>p.jsx("rect",{x:a.w*(7.5+1.2),y:a.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:BD(a.v,!1)},`l-${a.w}-${a.d}`))}),p.jsx("text",{x:19.5,y:"102",className:"fill-oai-black dark:fill-white",fontSize:"10",fontWeight:"700",fontFamily:To,children:"10.3B"}),p.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 Ixe(){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 p.jsx(wv,{children:p.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=UD[s%UD.length];return p.jsxs("g",{children:[p.jsx("circle",{cx:"18",cy:o-3,r:"2.5",fill:c}),p.jsx("text",{x:"26",y:o,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:a.name}),p.jsx("text",{x:"218",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"600",fontFamily:To,children:a.value}),p.jsxs("text",{x:"250",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"600",fontFamily:To,children:[a.pct,"%"]}),p.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"}),p.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 Oxe(){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 p.jsx(wv,{children:p.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=Rxe[a.source],u=Nxe(a.pct/100);return p.jsxs("g",{children:[p.jsx("circle",{cx:"18",cy:o-3,r:"2.5",fill:c}),p.jsx("text",{x:"26",y:o,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:a.label}),p.jsx("text",{x:"218",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:To,children:a.reset}),p.jsxs("text",{x:"250",y:o,textAnchor:"end",className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"700",fontFamily:To,children:[a.pct,"%"]}),p.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"}),p.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 Fxe(t){switch(t.category){case"cost":return"$8.42";case"limits":return"62%";default:return t.id==="last7dTokens"?"1.8B":"203M"}}function Uxe(t,e){switch(t){case"todayTokens":return O("menubar.metric.today_tokens");case"todayCost":return O("menubar.metric.today_cost");case"last7dTokens":return O("menubar.metric.last_7d_tokens");case"totalTokens":return O("menubar.metric.total_tokens");case"totalCost":return O("menubar.metric.total_cost");case"claude5h":return O("menubar.metric.claude_5h");case"claude7d":return O("menubar.metric.claude_7d");case"codex5h":return O("menubar.metric.codex_5h");case"codex7d":return O("menubar.metric.codex_7d");default:return e}}function jxe(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 Bxe({slotConfigs:t,showStats:e}){return p.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:p.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:[p.jsx("div",{className:"flex items-center pl-2 pr-1 py-2.5",children:p.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)=>p.jsxs(ot.Fragment,{children:[i>0?p.jsx("span",{className:"my-1 w-px bg-white/20","aria-hidden":"true"}):null,p.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:[p.jsx("span",{className:"text-[13px] font-semibold leading-none tabular-nums text-white",children:r?.previewValue||"--"}),p.jsx("span",{className:"mt-[2px] text-[6px] font-semibold uppercase leading-none text-white/75",children:r?.shortLabel||"Metric"})]})]},n)):null]})})}function zxe({slot:t,value:e,options:n,disabled:r,onChange:i}){const a=O(t===0?"menubar.slot.primary":"menubar.slot.secondary");return p.jsxs("label",{className:"flex min-w-0 flex-col gap-1.5",children:[p.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400",children:a}),p.jsxs("div",{className:"relative",children:[p.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=>p.jsx("option",{value:s.id,children:s.displayLabel},s.id))}),p.jsx(Hy,{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 zD({label:t,hint:e,checked:n,disabled:r,onChange:i}){return p.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:t}),e?p.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e}):null]}),p.jsx(bf,{checked:n,disabled:r,onChange:i,ariaLabel:t})]})}function Vxe(){const{available:t,settings:e,setSetting:n}=gM(),r=x.useMemo(()=>(Array.isArray(e?.menuBarAvailableItems)?e.menuBarAvailableItems:_j).map(g=>({...g,displayLabel:Uxe(g.id,g.label),previewValue:Fxe(g)})),[e?.menuBarAvailableItems]),i=Number(e?.menuBarMaxItems)||2,a=x.useMemo(()=>FD(e?.menuBarItems,r,i),[r,i,e?.menuBarItems]),s=x.useMemo(()=>jxe(a,r),[r,a]),o=e?.showStats!==!1,c=m=>{n("menuBarItems",FD(m,r,i))},u=(m,g)=>{const v=[...s];v[m===0?1:0]!==g&&(v[m]=g,c(v))},f=[0,1].map(m=>{const g=s[m]||r[m]?.id||"",w=s[m===0?1:0],b=r.filter(E=>E.id===g||E.id!==w),_=r.find(E=>E.id===g);return{slot:m,currentValue:g,options:b,item:_}}),h=e?.animatedIcon!==!1;return p.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:[p.jsx(Bxe,{slotConfigs:f,showStats:o}),p.jsx("div",{className:"mt-5 grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4",children:f.map(({slot:m,currentValue:g,options:v})=>p.jsx(zxe,{slot:m,value:g,options:v,disabled:!t||!o,onChange:u},m))}),p.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:[p.jsx(zD,{label:O("settings.menubar.showStats"),hint:O(t?"settings.menubar.showStatsHint":"menubar.native_only"),checked:o,disabled:!t,onChange:()=>n("showStats",!o)}),p.jsx(zD,{label:O("settings.menubar.animatedIcon"),hint:O("settings.menubar.animatedIconHint"),checked:h,disabled:!t,onChange:()=>n("animatedIcon",!h)})]})]})}function Hxe(){const[t,e]=x.useState("loading");return x.useEffect(()=>{if(typeof window>"u")return;if(Ja()){e("native");return}const n=(navigator.userAgent||"").toLowerCase(),r=/mac/.test(n)&&!/iphone|ipad/.test(n);e(r?"mac-web":"other")},[]),t}function Wxe(){const t=Hxe();return t==="loading"?p.jsx("div",{className:"h-10 w-40","aria-hidden":"true"}):t==="native"?p.jsxs("button",{type:"button",onClick:()=>I3("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:[O("widgets.cta.open_gallery"),p.jsx(DW,{className:"h-4 w-4","aria-hidden":"true"})]}):t==="mac-web"?p.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:[p.jsx(Ak,{className:"h-4 w-4","aria-hidden":"true"}),O("widgets.cta.download")]}):p.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:[p.jsx(Wy,{className:"h-4 w-4","aria-hidden":"true"}),O("widgets.cta.macos_only")]})}const Gxe=[{id:"summary",Preview:Dxe,nameKey:"widgets.summary.name",descKey:"widgets.summary.description"},{id:"heatmap",Preview:Lxe,nameKey:"widgets.heatmap.name",descKey:"widgets.heatmap.description"},{id:"topModels",Preview:Ixe,nameKey:"widgets.topModels.name",descKey:"widgets.topModels.description"},{id:"limits",Preview:Oxe,nameKey:"widgets.limits.name",descKey:"widgets.limits.description"}];function $xe({Preview:t,nameKey:e,descKey:n}){return p.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:[p.jsx(t,{}),p.jsxs("div",{className:"mt-4",children:[p.jsx("h3",{className:"text-[15px] font-semibold text-oai-black dark:text-white",children:O(e)}),p.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:O(n)})]})]})}function VD({titleKey:t}){return p.jsx("h2",{className:"mb-4 text-xl font-semibold tracking-tight text-oai-black dark:text-white sm:mb-5 sm:text-2xl",children:O(t)})}function Yxe(){return p.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:p.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:p.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[p.jsx(_o,{y:12,children:p.jsxs("header",{className:"mb-10 flex items-start justify-between gap-4 sm:mb-12",children:[p.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:O("widgets.page.title")}),p.jsx("div",{className:"shrink-0",children:p.jsx(Wxe,{})})]})}),p.jsx(_o,{y:12,delay:.06,children:p.jsxs("section",{"aria-label":O("widgets.menubar.section.title"),className:"mb-12 sm:mb-14",children:[p.jsx(VD,{titleKey:"widgets.menubar.section.title"}),p.jsx(Vxe,{})]})}),p.jsxs("section",{"aria-label":O("widgets.gallery.section.title"),children:[p.jsx(VD,{titleKey:"widgets.gallery.section.title"}),p.jsx(Goe,{staggerDelay:.08,initialDelay:.04,children:p.jsx("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2 lg:gap-5",children:Gxe.map(({id:t,Preview:e,nameKey:n,descKey:r})=>p.jsx($oe,{children:p.jsx($xe,{Preview:e,nameKey:n,descKey:r})},t))})})]})]})})})}function qxe(){const{resolvedLocale:t}=lu(),e=Hi(),n=ls();VZ();const r=vr(),i=x.useMemo(()=>typeof window>"u"?!1:uE(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,m=o==="/share"||o==="/share.html"||o.startsWith("/share/"),g=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=g||E,T=!1,P=LZ(),A=x.useMemo(()=>!n.enabled||!E?null:{getAccessToken:()=>n.getAccessToken(),name:n.displayName||"",userId:n.user?.id||null},[E,n]);let R=g||r||i?"dashboard":"landing";v==="/landing"&&(R="landing"),v==="/dashboard"&&(R="dashboard"),_&&(R="dashboard");const k=v==="/limits",N=v==="/settings",B=v==="/skills",L=v==="/widgets",z=v==="/ip-check";(k||N||B||L||z)&&(R="dashboard");let I=Yle;b?I=uve:v==="/leaderboard"?I=nve:k?I=wve:N?I=sxe:B?I=Txe:L?I=Yxe:z&&(I=qle);const W=!m&&(v==="/dashboard"||v==="/"||v==="/leaderboard"||k||N||B||L||z);let X=null;if(v==="/auth/callback"||v==="/auth/native-callback")X=p.jsx(Mve,{});else if(v==="/login")X=p.jsx(kve,{});else if(R==="landing")X=p.jsx(Xge,{signInUrl:"/login",signUpUrl:"/login"});else{const J=p.jsx(I,{baseUrl:P,auth:A,signedIn:M,sessionSoftExpired:T,signOut:()=>n.enabled?n.signOut():Promise.resolve(),publicMode:m,publicToken:h,userId:b,signInUrl:"/login",signUpUrl:"/login"},t);W?X=p.jsx(_re,{children:J}):X=J}return p.jsx(EG,{children:p.jsx(CG,{children:p.jsxs(AG,{children:[X,p.jsx(NZ,{}),p.jsx(pW,{}),p.jsx(EW,{})]})})})}const Xxe=H8([{path:"*",element:p.jsx(qxe,{})}]);RB.createRoot(document.getElementById("root")).render(p.jsx(ot.StrictMode,{children:p.jsx(nW,{children:p.jsx(C7,{children:p.jsx(nz,{router:Xxe})})})}));
|
|
5224
|
+
`),a=async()=>{try{await navigator.clipboard.writeText(i),n(!0),setTimeout(()=>n(!1),1600)}catch{}};return p.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:[p.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:O("limits.copilot.otelHint.title")}),p.jsx("div",{className:"mt-0.5 leading-snug",children:O("limits.copilot.otelHint.body")}),p.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}),p.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:O(e?"limits.copilot.otelHint.copied":"limits.copilot.otelHint.copy")})]})}function _ve({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},m=(Array.isArray(c)&&c.length>0?c:yve).filter(g=>!u||u[g]!==!1).map(g=>xve(g,f[g])).filter(Boolean);return p.jsx(_o,{delay:.15,children:p.jsx(pu,{children:p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:O("limits.panel.title")}),m.length>0?m:p.jsx(xa,{children:O("limits.status.all_hidden")})]})})})}function wve(){const{data:t,error:e,isLoading:n}=r4({initialRefresh:!0}),r=mj();return p.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:p.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:p.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[p.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:O("nav.limits")}),p.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:O("limits.page.subtitle")})]}),p.jsx(Ei,{to:"/settings","aria-label":O("limits.page.openSettings"),title:O("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:p.jsx(H3,{className:"h-4 w-4","aria-hidden":!0})})]}),n?p.jsx(mve,{}):p.jsxs(p.Fragment,{children:[e?p.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:O("shared.error.prefix",{error:e})}):null,p.jsx(_ve,{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 Sve(t){const e=new URLSearchParams(t).get("next");return typeof e!="string"||e.length===0||!e.startsWith("/")||e.startsWith("//")?"/dashboard":e}const RD={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",linkedin:"LinkedIn",facebook:"Facebook",instagram:"Instagram",tiktok:"TikTok",apple:"Apple",x:"X",spotify:"Spotify"};function ND(t){const e=String(t||"").trim();return RD[e]?RD[e]:e.replace(/-/g," ")}function kve(){const t=tf(),[e,n]=K8(),{enabled:r,loading:i,signedIn:a,refreshUser:s,signInWithPassword:o,signUp:c,signInWithOAuth:u,getPublicAuthConfig:f}=ls(),h=x.useMemo(()=>Sve(e.toString()),[e]),[m,g]=x.useState("signin"),[v,w]=x.useState(""),[b,_]=x.useState(""),[E,M]=x.useState(""),[T,P]=x.useState(!1),[A,R]=x.useState(null),[k,N]=x.useState(null),[B,L]=x.useState(!0),[z,I]=x.useState([]),[V,W]=x.useState([]),[X,J]=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(O("login.verify_email_success")):ce==="error"&&ee==="verify_email"&&le&&N(O("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?(I(["google","github"]),W([])):(I(Array.isArray(ee.oAuthProviders)?ee.oAuthProviders:[]),W(Array.isArray(ee.customOAuthProviders)?ee.customOAuthProviders:[]),typeof ee.passwordMinLength=="number"&&ee.passwordMinLength>0&&J(ee.passwordMinLength)),L(!1))})(),()=>{ce=!1}},[r,f]);const F=x.useMemo(()=>e.get("native")==="1",[e]),G=x.useMemo(()=>e.get("provider")||null,[e]);x.useEffect(()=>{if(!(!r||i)&&a){if(F){window.location.href="/auth/native-callback";return}t(h,{replace:!0})}},[r,i,a,t,h,F]),x.useEffect(()=>{r&&s()},[r,s]);const Y=x.useMemo(()=>typeof window>"u"||F?"":`${window.location.origin}/`,[F]),H=x.useMemo(()=>typeof window>"u"?"":`${window.location.origin}/`,[]),te=x.useCallback(async ce=>{ce.preventDefault(),R(null),P(!0);try{if(m==="signup"){const{data:le,error:ve}=await c({email:v.trim(),password:b,name:E.trim()||void 0,redirectTo:H});if(ve){R(ve.message||String(ve));return}if(le?.requireEmailVerification){N(O("login.verify_email_pending")),g("signin");return}t(h,{replace:!0});return}const{error:ee}=await o({email:v.trim(),password:b});if(ee){R(ee.message||String(ee));return}t(h,{replace:!0})}finally{P(!1)}},[m,v,b,E,c,o,t,h,H]),re=x.useCallback(async ce=>{R(null),P(!0);try{const{error:ee}=await u(ce,Y);ee&&R(ee.message||String(ee))}finally{P(!1)}},[u,Y]);x.useEffect(()=>{if(F&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[F]),x.useEffect(()=>{if(!r||i||a||B||!F||!G)return;[...z,...V].includes(G)&&re(G)},[r,i,a,B,F,G,z,V,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?p.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[p.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:p.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:O("login.back_home")})}),p.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:p.jsxs("div",{className:"w-full max-w-md space-y-8",children:[p.jsxs("div",{className:"text-center",children:[p.jsx("h1",{className:"text-2xl font-semibold text-white tracking-tight",children:O("login.title")}),p.jsx("p",{className:"mt-2 text-sm text-oai-gray-500",children:O("login.subtitle")})]}),k?p.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:[p.jsx("span",{children:k}),p.jsx("button",{type:"button",onClick:ue,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:O("login.dismiss")})]}):null,A?p.jsx("p",{className:"text-sm text-red-400",role:"alert",children:O("shared.error.prefix",{error:A})}):null,p.jsx("div",{className:"space-y-3",children:B?p.jsx("div",{className:"h-11 rounded-lg bg-oai-gray-900 animate-pulse","aria-hidden":!0}):p.jsxs(p.Fragment,{children:[z.map(ce=>p.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:O("login.oauth.continue",{provider:ND(ce)})},ce)),V.map(ce=>p.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:O("login.oauth.continue",{provider:ND(ce)})},ce))]})}),p.jsxs("div",{className:"relative",children:[p.jsx("div",{className:"absolute inset-0 flex items-center","aria-hidden":!0,children:p.jsx("span",{className:"w-full border-t border-oai-gray-800"})}),p.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:p.jsx("span",{className:"bg-oai-gray-950 px-3 text-oai-gray-600",children:O("login.divider")})})]}),p.jsxs("div",{className:"flex rounded-lg border border-oai-gray-800 p-0.5 bg-oai-gray-900/50",children:[p.jsx("button",{type:"button",className:vt("flex-1 py-2 text-sm font-medium rounded-md transition-colors",m==="signin"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{g("signin"),R(null)},children:O("login.tab.sign_in")}),p.jsx("button",{type:"button",className:vt("flex-1 py-2 text-sm font-medium rounded-md transition-colors",m==="signup"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{g("signup"),R(null)},children:O("login.tab.sign_up")})]}),p.jsxs("form",{onSubmit:te,className:"space-y-4",children:[m==="signup"?p.jsxs("div",{children:[p.jsx("label",{htmlFor:"login-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:O("login.field.name")}),p.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:O("login.field.name_placeholder")})]}):null,p.jsxs("div",{children:[p.jsx("label",{htmlFor:"login-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:O("login.field.email")}),p.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"})]}),p.jsxs("div",{children:[p.jsx("label",{htmlFor:"login-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:O("login.field.password")}),p.jsx("input",{id:"login-password",type:"password",autoComplete:m==="signup"?"new-password":"current-password",required:!0,minLength:m==="signup"?X: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"}),m==="signup"?p.jsx("p",{className:"mt-1 text-xs text-oai-gray-600",children:O("login.password_hint",{min:String(X)})}):null]}),p.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:O(m==="signup"?"login.submit.sign_up":"login.submit.sign_in")})]})]})})]}):p.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[p.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:p.jsx(Ei,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:O("login.back_home")})}),p.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:p.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",children:O("login.cloud_only")})})]})}const Eve=typeof window<"u"?window.location.search:"",DD=new URLSearchParams(Eve),n0=DD.get("insforge_code")||DD.get("code")||null;function Mve(){lu();const{loading:t,signedIn:e}=ls(),n=tf(),[r,i]=x.useState("processing"),[a,s]=x.useState(null),o=x.useRef(!1);return x.useEffect(()=>{!n0||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||!n0)return;i("redirecting");const c=setTimeout(()=>{window.location.href=`tokentracker://auth/callback?insforge_code=${encodeURIComponent(n0)}`},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(!n0&&a===null){const c=setTimeout(()=>i("failed"),3e3);return()=>clearTimeout(c)}},[a]),r==="processing"&&a!==!0&&(a===null||a===!1&&t)?p.jsx("div",{className:"min-h-screen bg-oai-gray-950"}):p.jsx("div",{className:"min-h-screen bg-oai-gray-950 text-white font-oai antialiased dark flex items-center justify-center",children:p.jsxs("div",{className:"text-center space-y-4 max-w-sm px-4",children:[r==="processing"&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"w-8 h-8 border-2 border-oai-gray-600 border-t-white rounded-full animate-spin mx-auto"}),p.jsx("p",{className:"text-oai-gray-400 text-sm",children:O("auth.callback.processing")})]}),r==="redirecting"&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"w-12 h-12 mx-auto rounded-full bg-green-500/15 flex items-center justify-center",children:p.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:p.jsx("path",{d:"M20 6 9 17l-5-5"})})}),p.jsx("p",{className:"text-white text-sm font-medium",children:O("auth.callback.success")}),p.jsx("p",{className:"text-oai-gray-500 text-xs",children:O("auth.callback.redirecting")})]}),r==="failed"&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("p",{className:"text-oai-gray-300 text-sm",children:O("auth.callback.failed")}),p.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:O("auth.callback.close")})]})]})})}const Tve=new Set(["cursor","kiro","copilot","kimi"]);function Cve({checked:t,onChange:e,ariaLabel:n}){return p.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:p.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 Ave({prefs:t}){const{order:e,visibility:n,toggle:r,moveToward:i}=t,[a,s]=x.useState(null),[o,c]=x.useState(null),u=g=>v=>{s(g),v.dataTransfer.effectAllowed="move",v.dataTransfer.setData("text/plain",g)},f=g=>v=>{v.preventDefault(),v.dataTransfer.dropEffect="move",a&&a!==g&&o!==g&&(c(g),i(a,g))},h=()=>{s(null),c(null)},m=g=>{g.preventDefault(),s(null),c(null)};return p.jsx(MX,{children:p.jsx("div",{className:"flex flex-col",children:e.map(g=>{const v=n[g]!==!1,w=a===g;return p.jsxs(Qn.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:u(g),onDragOver:f(g),onDragEnd:h,onDrop:m,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:[p.jsx(qW,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),p.jsx("img",{src:dve[g],alt:"",width:18,height:18,className:vt("h-[18px] w-[18px] shrink-0 pointer-events-none",Tve.has(g)&&"dark:invert"),draggable:!1}),p.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:CD[g]}),p.jsx("div",{onMouseDown:b=>b.stopPropagation(),draggable:!1,children:p.jsx(Cve,{checked:v,onChange:()=>r(g),ariaLabel:`${O("limits.settings.toggle_visible")}: ${CD[g]}`})})]},g)})})})}function Pve(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 Rve(t){return!t||typeof t!="object"?"":typeof t.email=="string"?t.email.trim():""}function Nve(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 mM(t,e){console.warn(`[tokentracker] settings ${t}:`,e)}function Dve(t,e,n){const[r,i]=x.useState(()=>_k()),a=e&&n&&p3(),s=x.useCallback(async()=>{const o=!r;if(m3(o),i(o),!!o)try{await e4(()=>t())}catch(c){mM("cloud sync",c)}},[r,t]);return{cloudSyncOn:r,handleCloudSyncToggle:s,showLocalCloudSync:a}}function Lve(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,m]=x.useState(!1),[g,v]=x.useState(""),[w,b]=x.useState(!1),[_,E]=x.useState(""),[M,T]=x.useState(""),[P,A]=x.useState(!1),[R,k]=x.useState(null),N=x.useMemo(()=>Pve(t),[t]),B=x.useMemo(()=>Rve(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:P,editingName:h,email:B,githubError:R,githubInput:M,githubUrl:_,loadSetters:L,nameInput:g,profileLoading:a,profileSaving:o,publicProfileOn:e,setAnonymousOn:i,setCustomDisplayName:f,setEditingGithub:A,setEditingName:m,setGithubError:k,setGithubInput:T,setGithubUrl:E,setNameInput:v,setProfileLoading:s,setProfileSaving:c,setPublicProfileOn:n,setShowGithubOn:b,showGithubOn:w}}function Ive(t,e,n){x.useEffect(()=>{if(!e)return;let r=!0;return n.setProfileLoading(!0),(async()=>{try{const i=await Zh({getAccessToken:t});if(!r||!i)return;const a=await Bw({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){mM("load public profile",i)}finally{r&&n.setProfileLoading(!1)}})(),()=>{r=!1}},[t,e,n])}function Ove(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 Zh({getAccessToken:t});if(!s)return!1;const o=await y7({accessToken:s,...n});return a?.(o),!0}catch(s){return i?i(s):mM(r||"mutate profile",s),!1}finally{e.setProfileSaving(!1)}},[t,e])}function Fve(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 Uve(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 jve(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 Bve(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 zve(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=Nve(t.githubInput);if(t.githubInput.trim()&&!a){t.setGithubError(O("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||O("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 Vve(){const t=ls(),e=Lve(t.user),n=Dve(t.getAccessToken,t.enabled,t.signedIn);Ive(t.getAccessToken,t.signedIn,e.loadSetters);const r=Ove(t.getAccessToken,e),i=jve(e,r),a=Bve(e,r),s=zve(e,r);return{...t,...n,email:e.email,handlePublicProfileToggle:i.handlePublicProfileToggle,name:Fve(e,{...i,...a}),github:Uve(e,s),profileLoading:e.profileLoading,profileSaving:e.profileSaving,publicProfileOn:e.publicProfileOn}}function bf({checked:t,onChange:e,disabled:n,ariaLabel:r}){return p.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:p.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 Wc({label:t,hint:e,control:n}){return p.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:t}),e?p.jsx("div",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e}):null]}),p.jsx("div",{className:"shrink-0",children:n})]})}function Xp({title:t,subtitle:e,action:n,children:r}){return p.jsxs(pu,{children:[p.jsxs("div",{className:"mb-3 flex items-start justify-between gap-4",children:[p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("h2",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:t}),e?p.jsx("p",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e}):null]}),n?p.jsx("div",{className:"shrink-0",children:n}):null]}),p.jsx("div",{className:"-mb-3 divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:r})]})}function LD({options:t,value:e,onChange:n}){return p.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 p.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?p.jsx(a,{className:"h-3.5 w-3.5","aria-hidden":!0}):null,p.jsx("span",{children:i})]},r)})})}function gj({disabled:t,onCancel:e,onSave:n,saveLabel:r=O("settings.account.save")}){return p.jsxs(p.Fragment,{children:[p.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}),p.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:O("settings.account.cancel")})]})}function Hve({nameInput:t,setEditingName:e,setNameInput:n,profileSaving:r,handleSaveName:i}){return p.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[p.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:O("settings.account.displayName")}),p.jsx(gj,{disabled:r||!t.trim(),onCancel:()=>e(!1),onSave:i,saveLabel:r?O("settings.account.saving"):void 0})]})}function Wve({githubError:t,githubInput:e,handleSaveGithub:n,profileSaving:r,setEditingGithub:i,setGithubError:a,setGithubInput:s}){return p.jsxs("div",{className:"mt-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.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:O("settings.account.githubUrlPlaceholder")}),p.jsx(gj,{disabled:r,onCancel:()=>{i(!1),a(null)},onSave:n,saveLabel:r?O("settings.account.saving"):void 0})]}),t?p.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:t}):null]})}function yj({disabled:t=!1,label:e,onClick:n,title:r}){return p.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:[p.jsx(cG,{className:"h-3.5 w-3.5","aria-hidden":!0}),e]})}function vj({actions:t,editing:e,editor:n,hint:r,label:i}){return p.jsx("div",{className:"py-3",children:p.jsxs("div",{className:"flex items-start justify-between gap-4",children:[p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:i}),e?n:p.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r})]}),e?null:t]})})}function Gve({name:t}){const e=t.anonymousOn?O("settings.account.displayNameDisabledWhileAnon"):void 0;return p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[p.jsx(yj,{disabled:t.anonymousOn,label:O("settings.account.edit"),onClick:t.startEditingName,title:e}),p.jsx(bf,{checked:!t.anonymousOn,onChange:t.handleAnonymousToggle,disabled:t.profileLoading||t.profileSaving,ariaLabel:O("settings.account.displayName")})]})}function $ve({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:m}=t,g=e?O("settings.account.displayNameAnonymousHint"):n||r;return p.jsx(vj,{label:O("settings.account.displayName"),editing:i,hint:g,editor:p.jsx(Hve,{nameInput:o,setEditingName:f,setNameInput:h,profileSaving:u,handleSaveName:s}),actions:p.jsx(Gve,{name:t})})}function Yve({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:m,startEditingGithub:g}=t;return p.jsx(vj,{label:O("settings.account.githubUrl"),editing:e,hint:i||O("settings.account.githubUrlHint"),editor:p.jsx(Wve,{githubError:n,githubInput:r,handleSaveGithub:a,profileSaving:c,setEditingGithub:u,setGithubError:f,setGithubInput:h}),actions:p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[p.jsx(yj,{label:O("settings.account.edit"),onClick:g}),p.jsx(bf,{checked:m,onChange:s,disabled:o||c,ariaLabel:O("settings.account.githubUrl")})]})})}function qve(){const{openLoginModal:t}=Cp();return p.jsx(Xp,{title:O("settings.section.account"),children:p.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:O("settings.account.signedOutHint")}),p.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:O("settings.account.signIn")})]})})}function Xve({name:t,github:e}){return p.jsxs(p.Fragment,{children:[p.jsx($ve,{name:t}),p.jsx(Yve,{github:e})]})}function Kve(){const t=Vve();return t.enabled?t.signedIn?p.jsxs(Xp,{title:O("settings.section.account"),subtitle:t.email||t.name.customDisplayName||t.name.displayName,action:p.jsx(Zve,{onSignOut:t.signOut}),children:[p.jsx(Jve,{settings:t}),p.jsx(Qve,{checked:t.publicProfileOn,disabled:t.profileLoading||t.profileSaving,onChange:t.handlePublicProfileToggle}),p.jsx(exe,{visible:t.publicProfileOn,name:t.name,github:t.github})]}):p.jsx(qve,{}):null}function Zve({onSignOut:t}){return p.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:[p.jsx(tG,{className:"h-3.5 w-3.5","aria-hidden":!0}),O("settings.account.signOut")]})}function Jve({settings:t}){return t.showLocalCloudSync?p.jsx(Wc,{label:O("settings.account.cloudSync"),hint:O("settings.account.cloudSyncHint"),control:p.jsx(bf,{checked:t.cloudSyncOn,onChange:t.handleCloudSyncToggle,ariaLabel:O("settings.account.cloudSync")})}):null}function Qve({checked:t,disabled:e,onChange:n}){return p.jsx(Wc,{label:O("settings.account.publicProfile"),hint:O("settings.account.publicProfileHint"),control:p.jsx(bf,{checked:t,onChange:n,disabled:e,ariaLabel:O("settings.account.publicProfile")})})}function exe({visible:t,name:e,github:n}){return p.jsx(Lp,{initial:!1,children:t?p.jsx(Qn.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:p.jsx(Xve,{name:e,github:n})},"public-profile-fields"):null})}function txe(){return[{value:"light",label:O("settings.appearance.theme.light"),Icon:Nk},{value:"dark",label:O("settings.appearance.theme.dark"),Icon:Pk},{value:"system",label:O("settings.appearance.theme.system"),Icon:Wy}]}function nxe(){return[{value:Jc,label:O("settings.appearance.language.system"),Icon:Wy},{value:Qh,label:O("settings.appearance.language.english"),Icon:B2},{value:zy,label:O("settings.appearance.language.chinese"),Icon:B2}]}function rxe(){const{theme:t,setTheme:e}=Op(),{locale:n,setLocale:r}=lu();return p.jsxs(Xp,{title:O("settings.section.appearance"),children:[p.jsx(Wc,{label:O("settings.appearance.theme.label"),hint:O("settings.appearance.theme.hint"),control:p.jsx(LD,{options:txe(),value:t,onChange:e})}),p.jsx(Wc,{label:O("settings.appearance.language.label"),hint:O("settings.appearance.language.hint"),control:p.jsx(LD,{options:nxe(),value:n,onChange:r})})]})}function gM(){const[t,e]=x.useState(null),n=Tk()&&K7();x.useEffect(()=>{if(!n)return;const s=Q7(o=>e(o));return F2(),s},[n]);const r=x.useCallback((s,o)=>{n&&(e(c=>c&&{...c,[s]:o}),Ww(s,o))},[n]),i=x.useCallback(s=>{n&&I3(s)},[n]),a=x.useCallback(()=>{n&&F2()},[n]);return{available:n,settings:t,setSetting:r,runAction:i,refresh:a}}function ixe(){const{available:t,settings:e,setSetting:n,runAction:r}=gM();if(!t)return null;const i=!!e?.launchAtLogin,a=e?.launchAtLoginSupported!==!1,s=e?.updateStatus||null,o=!!e?.updateBusy,c=!!e?.isSyncing;return p.jsxs(Xp,{title:O("settings.section.menubar"),children:[a?p.jsx(Wc,{label:O("settings.menubar.launchAtLogin"),hint:O("settings.menubar.launchAtLoginHint"),control:p.jsx(bf,{checked:i,onChange:()=>n("launchAtLogin",!i),ariaLabel:O("settings.menubar.launchAtLogin")})}):null,p.jsx(Wc,{label:O("settings.menubar.syncNow"),hint:O("settings.menubar.syncNowHint"),control:p.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:[p.jsx(Rk,{className:vt("h-3.5 w-3.5",c&&"animate-spin"),"aria-hidden":!0}),O(c?"settings.menubar.syncing":"settings.menubar.syncNow")]})}),p.jsx(Wc,{label:O("settings.menubar.updates"),hint:s||void 0,control:p.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:[p.jsx(Ak,{className:"h-3.5 w-3.5","aria-hidden":!0}),O("settings.menubar.checkUpdates")]})})]})}function axe(){const{available:t,settings:e,runAction:n}=gM();return!t||!e?.version?null:p.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-500",children:[p.jsxs("span",{children:["TokenTrackerBar v",e.version]}),p.jsx("span",{"aria-hidden":!0,children:"·"}),p.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 sxe(){const t=mj();return p.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:p.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:p.jsxs("div",{className:"mx-auto max-w-3xl px-4 sm:px-6",children:[p.jsxs("div",{className:"mb-8",children:[p.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:O("settings.page.title")}),p.jsx("p",{className:"mt-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:O("settings.page.subtitle")})]}),p.jsxs("div",{className:"space-y-4",children:[p.jsx(rxe,{}),p.jsx(ixe,{}),p.jsx(Kve,{}),p.jsx(Xp,{title:O("settings.section.limits"),children:p.jsx(Ave,{prefs:t})})]}),p.jsx(axe,{})]})})})}const xj="tokentracker-skills";async function _v(t){const e=new URL(`/functions/${xj}`,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 $l(t){const e=await By(),n=await fetch(`/functions/${xj}`,{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 oxe(){return _v({mode:"installed"})}function lxe(t={}){return _v({mode:"discover",...t.force?{force:1}:{}})}function cxe(t,e=0,n=20){return _v({mode:"search",q:t,offset:e,limit:n})}function uxe(){return _v({mode:"repos"})}function dxe(t,e){return $l({action:"install",skill:t,targets:e})}function fxe(t){return $l({action:"uninstall",id:t})}function hxe(t){return $l({action:"restore",id:t})}function pxe(t,e){return $l({action:"set_targets",id:t,targets:e})}function mxe(t,e){return $l({action:"import_local",directory:t,targets:e})}function gxe(t,e){return $l({action:"delete_local",directory:t,targets:e||[]})}function yxe(t){return $l({action:"add_repo",repo:t})}function vxe(t,e){return $l({action:"remove_repo",owner:t,name:e})}const ID=["claude","codex"],xxe={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"},hd="all",ta="skillssh";function N0(t){return`${t.repoOwner||"local"}/${t.repoName||"local"}:${t.directory}`}function OD(t){return`install:${N0(t)}`}function GS(t){return`remove:${t.id||t.directory}`}function bj(t,e){return`target:${t}:${e}`}function bxe({skill:t,targets:e,busyKey:n,onToggleTarget:r}){const i=new Set(t.targets||[]);return p.jsx("div",{className:"flex flex-wrap gap-1",children:e.map(a=>{const s=i.has(a.id),o=n===bj(t.id,a.id),c=s?"skills.target.remove_title":"skills.target.sync_title";return p.jsx("button",{type:"button","aria-pressed":s,"aria-label":O("skills.target.toggle_aria",{target:a.label}),title:O(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?xxe[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?p.jsx(Ao,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):p.jsx(nu,{provider:a.id,size:16})},a.id)})})}function _xe({skill:t,targets:e,busyKey:n,onToggleTarget:r,onRemove:i}){const a=n===GS(t),s=t.repoOwner&&t.repoName?`${t.repoOwner}/${t.repoName}`:null,o=s?`${t.directory} · ${s}`:t.directory;return p.jsxs("div",{className:"group grid gap-4 px-1 py-3 lg:grid-cols-[minmax(0,1fr)_auto_auto] lg:items-center",children:[p.jsxs("div",{className:"min-w-0",title:o,children:[p.jsx("h2",{className:"truncate text-sm font-semibold text-oai-black dark:text-white",children:t.name||t.directory}),t.description?p.jsx("p",{className:"mt-0.5 line-clamp-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t.description}):null]}),p.jsx(bxe,{skill:t,targets:e,busyKey:n,onToggleTarget:r}),p.jsx("button",{type:"button","aria-label":O("skills.action.remove"),title:O("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?p.jsx(Ao,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):p.jsx(W3,{className:"h-4 w-4","aria-hidden":!0})})]})}function wxe({items:t,targets:e,busyKey:n,onToggleTarget:r,onRemove:i}){return p.jsxs("div",{children:[p.jsx("div",{className:"px-1 pb-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O("skills.my.count",{count:t.length})}),p.jsx("div",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:t.map(a=>p.jsx(_xe,{skill:a,targets:e,busyKey:n,onToggleTarget:r,onRemove:i},a.id||a.key))})]})}const Sxe={contentVisibility:"auto",containIntrinsicSize:"0 240px"},kxe=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?O("skills.card.installs",{count:Number(e.installs||0).toLocaleString()}):null,m=[f,h].filter(Boolean).join(" · "),g=o.length?o.map(v=>i.find(w=>w.id===v)?.label||v).join(", "):O("skills.action.choose_targets");return p.jsxs(pu,{className:"h-full rounded-lg",bodyClassName:"flex h-full flex-col",children:[p.jsxs("div",{className:"flex items-start justify-between gap-3",children:[p.jsxs("div",{className:"min-w-0",children:[e.readmeUrl?p.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:[p.jsx("span",{className:"truncate",children:e.name||e.directory}),p.jsx(VW,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400 opacity-0 transition-opacity group-hover:opacity-100","aria-hidden":!0})]}):p.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:e.name||e.directory}),m?p.jsx("div",{className:"mt-1 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:m}):null]}),n?p.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:[p.jsx(Lh,{className:"h-3 w-3","aria-hidden":!0}),O("skills.card.installed")]}):null]}),e.description?p.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,p.jsx("div",{className:"mt-auto pt-5",children:n?p.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:[p.jsx(Lh,{className:"h-3.5 w-3.5","aria-hidden":!0}),O("skills.card.installed")]}):p.jsxs("div",{className:"flex",children:[p.jsxs(Ui,{type:"button",size:"sm",onClick:()=>s(e,o),disabled:r||o.length===0,className:"flex-1 !rounded-r-none",title:g,children:[r?p.jsx(Ao,{className:"mr-1.5 h-3.5 w-3.5 animate-spin","aria-hidden":!0}):p.jsx(Ak,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),o.length>1?O("skills.action.install_to",{count:o.length}):O("skills.action.install")]}),p.jsxs(K5,{children:[p.jsx(Z5,{disabled:r,"aria-label":O("skills.action.choose_targets"),title:g,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:p.jsx(Hy,{className:"h-3.5 w-3.5","aria-hidden":!0})}),p.jsx(Q5,{children:p.jsx(tF,{sideOffset:6,side:"bottom",align:"end",className:"!z-[80]",children:p.jsxs(nF,{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:[p.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:O("skills.target.menu_label")}),i.map(v=>{const w=o.includes(v.id);return p.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:[p.jsx(nu,{provider:v.id,size:16,className:w?"":"grayscale opacity-40"}),p.jsx("span",{className:"flex-1 text-left",children:v.label}),w?p.jsx(Lh,{className:"h-3.5 w-3.5 text-emerald-500","aria-hidden":!0}):null]},v.id)})]})})})]})]})})]})});function Exe({repos:t,repoInput:e,onRepoInput:n,busyKey:r,onAdd:i,onRemove:a}){return p.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:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[p.jsx(q5,{value:e,onChange:s=>n(s.target.value),placeholder:O("skills.repo.placeholder"),className:"min-w-0 flex-1"}),p.jsxs(Ui,{type:"button",variant:"secondary",size:"md",onClick:i,disabled:r==="repo:add",className:"shrink-0 whitespace-nowrap",children:[r==="repo:add"?p.jsx(Ao,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):p.jsx(V3,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),O("skills.repo.add")]})]}),t.length?p.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 p.jsxs("div",{className:"flex items-center justify-between gap-3 py-2",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"truncate text-sm font-medium text-oai-black dark:text-white",children:[s.owner,"/",s.name]}),p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s.branch})]}),p.jsxs(Ui,{type:"button",variant:"ghost",size:"sm",disabled:o,onClick:()=>a(s),className:"shrink-0",children:[o?p.jsx(Ao,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):p.jsx(W3,{className:"h-3.5 w-3.5","aria-hidden":!0}),p.jsx("span",{className:"sr-only",children:O("skills.repo.remove")})]})]},`${s.owner}/${s.name}`)})}):null]})}function Mxe(){return typeof window>"u"?"my":new URLSearchParams(window.location.search).get("tab")==="browse"?"browse":"my"}function Txe(){const[t,e]=x.useState(Mxe),[n,r]=x.useState({skills:[],targets:[]}),[i,a]=x.useState([]),[s,o]=x.useState([]),[c,u]=x.useState([]),[f,h]=x.useState(hd),[m,g]=x.useState(""),[v,w]=x.useState(""),[b,_]=x.useState(""),[E,M]=x.useState(!1),[T,P]=x.useState(""),[A,R]=x.useState(!0),[k,N]=x.useState(!1),[B,L]=x.useState(""),[z,I]=x.useState(null),[V,W]=x.useState(null),X=x.useMemo(()=>{const oe=new Set;for(const Q of n.skills||[]){oe.add(N0(Q).toLowerCase()),Q.repoOwner&&Q.repoName&&oe.add(`${Q.repoOwner}/${Q.repoName}:${Q.sourceDirectory||Q.directory}`.toLowerCase());const ze=String(Q.directory||"").split(/[\\/]/).pop().toLowerCase();ze&&oe.add(`dir:${ze}`)}return oe},[n.skills]),J=x.useCallback(async()=>{const oe=await oxe();r({skills:oe.skills||[],targets:oe.targets||[]})},[]),F=x.useCallback(async()=>{const oe=await uxe();u(oe.repos||[])},[]),G=x.useCallback(async({force:oe=!1}={})=>{N(!0);try{const Q=await lxe({force:oe});a(Q.skills||[])}finally{N(!1)}},[]),Y=x.useCallback(async()=>{R(!0),L("");try{await Promise.all([J(),F()])}catch(oe){L(oe?.message||O("skills.error.generic"))}finally{R(!1)}},[J,F]),H=x.useCallback(async()=>{await Y(),t==="browse"&&f!==ta&&G({force:!0}).catch(oe=>L(oe?.message||O("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||O("skills.error.generic")))},[i.length,G,f,t]),x.useEffect(()=>{if(!V)return;const oe=setTimeout(()=>W(Q=>Q?.key===V.key?null:Q),V.ttlMs||5e3);return()=>clearTimeout(oe)},[V]),x.useEffect(()=>{const oe=setTimeout(()=>w(m),200);return()=>clearTimeout(oe)},[m]),x.useEffect(()=>{if(typeof window>"u")return;const oe=new URLSearchParams(window.location.search),Q=oe.get("tab");if(t==="my"){if(!Q)return;oe.delete("tab")}else{if(Q===t)return;oe.set("tab",t)}const ze=oe.toString(),Pe=`${window.location.pathname}${ze?`?${ze}`:""}${window.location.hash}`;window.history.replaceState({},"",Pe)},[t]);const te=async(oe,Q)=>{P(oe),L("");try{await Q(),await J()}catch(ze){L(ze?.message||O("skills.error.generic"))}finally{P("")}},re=(oe,Q)=>{const ze=(Q&&Q.length?Q:ID).filter(Pe=>(n.targets||[]).some(De=>De.id===Pe));te(OD(oe),async()=>{await dxe(oe,ze);const Pe=ze.map(De=>(n.targets||[]).find(Le=>Le.id===De)?.label||De).join(", ");W({key:`${Date.now()}:install:${N0(oe)}`,message:O("skills.toast.installed",{name:oe.name||oe.directory,targets:Pe||O("skills.target.none")}),ttlMs:4e3})})},ue=oe=>{I(oe)},ce=()=>{const oe=z;oe&&(I(null),te(GS(oe),async()=>{let Q=null;oe.managed?Q=await fxe(oe.id):await gxe(oe.directory,oe.targets||[]);const ze=!!(Q?.trashed&&oe.managed&&oe.id);W({key:`${Date.now()}:${oe.id||oe.directory}`,message:O("skills.toast.removed",{name:oe.name||oe.directory}),undo:ze?async()=>{try{await hxe(oe.id),await J(),W(null)}catch(Pe){L(Pe?.message||O("skills.error.generic"))}}:null,ttlMs:5e3})}))},ee=(oe,Q,ze)=>te(bj(oe.id,Q),async()=>{const Pe=new Set(oe.targets||[]);ze?Pe.add(Q):Pe.delete(Q),oe.managed?await pxe(oe.id,Array.from(Pe)):await mxe(oe.directory,Array.from(Pe))}),le=async()=>{const oe=m.trim();if(!(oe.length<2)){P("search"),L("");try{const Q=await cxe(oe);o(Q.skills||[])}catch(Q){L(Q?.message||O("skills.error.generic"))}finally{P("")}}},ve=async()=>{const oe=b.trim().replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,""),[Q,ze]=oe.split("/");if(!Q||!ze){L(O("skills.repo.invalid"));return}await te("repo:add",async()=>{await yxe({owner:Q,name:ze,branch:"main",enabled:!0}),_(""),await F(),await G()})},Ne=async oe=>{await te(`repo:${oe.owner}/${oe.name}`,async()=>{await vxe(oe.owner,oe.name),await F(),await G()})},be=n.targets||[],qe=n.skills||[],he=x.useMemo(()=>{const oe=f===ta?s:i,Q=f===ta||f===hd?oe:oe.filter(De=>`${De.repoOwner}/${De.repoName}`===f),ze=v.trim().toLowerCase();return(f===ta||!ze?Q:Q.filter(De=>(De.name||"").toLowerCase().includes(ze)||(De.directory||"").toLowerCase().includes(ze)||(De.description||"").toLowerCase().includes(ze))).map(De=>{const Le=N0(De).toLowerCase(),$=String(De.directory||"").split(/[\\/]/).pop().toLowerCase(),U=$?`dir:${$}`:"";return{...De,installed:X.has(Le)||U&&X.has(U)}})},[v,i,X,s,f]),Ue=p.jsx("div",{className:"flex h-64 items-center justify-center",children:p.jsx(Ao,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0})}),je=p.jsxs("div",{className:"flex h-64 flex-col items-center justify-center gap-3 px-6 text-center",children:[p.jsx(Ao,{className:"h-8 w-8 animate-spin text-oai-gray-400","aria-hidden":!0}),p.jsx("p",{className:"max-w-md text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O("skills.browse.loading_hint")})]}),et=(oe,Q=null)=>p.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:[p.jsx("p",{children:O(oe)}),Q]});let _e;if(A)_e=Ue;else if(t==="my")_e=qe.length?p.jsx(wxe,{items:qe,targets:be,busyKey:T,onToggleTarget:ee,onRemove:ue}):p.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?p.jsxs("div",{className:"relative h-11 w-80 overflow-hidden","aria-hidden":!0,children:[p.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:p.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,Q)=>p.jsx("span",{className:"shrink-0 px-3",children:p.jsx(nu,{provider:oe.id,size:30})},`b-${Q}`))})}),p.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:p.jsx("div",{className:"absolute inset-y-0 left-0 flex w-max items-center animate-marquee-x",children:[...be,...be].map((oe,Q)=>p.jsx("span",{className:"shrink-0 px-3",children:p.jsx(nu,{provider:oe.id,size:30})},`c-${Q}`))})}),p.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"}),p.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,p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:O("skills.empty.my")}),p.jsx(Ui,{type:"button",size:"sm",onClick:()=>e("browse"),children:O("skills.empty.my_cta")})]});else{const oe=f===ta,Q=c.length===0&&!oe;let ze;Q?ze=p.jsx("div",{className:"rounded-lg border border-dashed border-oai-gray-200 p-6 text-center dark:border-oai-gray-800",children:p.jsx("p",{className:"text-sm text-oai-gray-600 dark:text-oai-gray-300",children:O("skills.browse.empty_sources")})}):k&&!oe?ze=je:oe&&m.trim().length<2?ze=p.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:O("skills.browse.hint_skillssh")}):he.length?ze=p.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:he.map(De=>p.jsx("div",{style:Sxe,children:p.jsx(kxe,{skill:De,installed:!!De.installed,installing:T===OD(De),allTargets:be,defaultTargets:ID,onInstall:re})},De.id||De.key))}):oe?ze=et("skills.empty.search"):ze=et("skills.empty.browse");const Pe=Q||E?p.jsx("div",{className:"mb-5",children:p.jsx(Exe,{repos:c,repoInput:b,onRepoInput:_,busyKey:T,onAdd:ve,onRemove:Ne})}):null;_e=p.jsxs(p.Fragment,{children:[Pe,ze]})}return p.jsxs("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:[p.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:p.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[p.jsxs("div",{className:"mb-6 flex items-end justify-between gap-4",children:[p.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:O("skills.page.title")}),p.jsxs(Ui,{type:"button",variant:"secondary",size:"sm",onClick:H,disabled:A||k,children:[p.jsx(Rk,{className:vt("mr-1.5 h-3.5 w-3.5",(A||k)&&"animate-spin"),"aria-hidden":!0}),O("skills.action.refresh")]})]}),p.jsx("div",{className:"mb-5 flex gap-6 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[["my",O("skills.tab.my")],["browse",O("skills.tab.browse")]].map(([oe,Q])=>p.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:Q},oe))}),B?p.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:B}):null,t==="browse"?p.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center",children:[p.jsx("div",{role:"tablist","aria-label":O("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",O("skills.mode.repo")],["skillssh",O("skills.mode.skillssh")]].map(([oe,Q])=>{const ze=oe==="skillssh"==(f===ta);return p.jsx("button",{type:"button",role:"tab","aria-selected":ze,onClick:()=>{oe==="skillssh"?h(ta):f===ta&&h(hd)},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:Q},oe)})}),f!==ta?p.jsxs(cne,{value:f,onValueChange:h,children:[p.jsxs(vne,{"aria-label":O("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:[p.jsx(bne,{children:oe=>oe===hd?O("skills.source.all"):oe}),p.jsx(_ne,{className:"text-oai-gray-400",children:p.jsx(Hy,{className:"h-4 w-4","aria-hidden":!0})})]}),p.jsx(Sne,{children:p.jsx(Wne,{sideOffset:4,alignItemWithTrigger:!1,className:"z-[60]",children:p.jsxs(ere,{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:[p.jsxs(oR,{value:hd,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:[p.jsx(cR,{children:O("skills.source.all")}),p.jsx(lR,{children:p.jsx(Lh,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),c.map(oe=>{const Q=`${oe.owner}/${oe.name}`;return p.jsxs(oR,{value:Q,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:[p.jsx(cR,{children:Q}),p.jsx(lR,{children:p.jsx(Lh,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},Q)})]})})})]}):null,p.jsxs("div",{className:"relative flex-1",children:[p.jsx(z2,{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}),p.jsx(q5,{value:m,onChange:oe=>g(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&f===ta&&le()},placeholder:f===ta?O("skills.browse.placeholder_skillssh"):f===hd?O("skills.browse.placeholder_all"):O("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?p.jsxs(Ui,{type:"button",onClick:le,disabled:m.trim().length<2||T==="search",className:"focus:!ring-oai-gray-400/30",children:[T==="search"?p.jsx(Ao,{className:"mr-1.5 h-4 w-4 animate-spin","aria-hidden":!0}):p.jsx(z2,{className:"mr-1.5 h-4 w-4","aria-hidden":!0}),O("skills.action.search")]}):p.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:[p.jsx(V3,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":!0}),O("skills.browse.manage_sources"),p.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]})}),p.jsx(Kre,{open:!!z,title:O("skills.confirm.remove_title",{name:z?.name||z?.directory||""}),description:z?z.managed?O("skills.confirm.remove_managed"):O("skills.confirm.remove_local"):"",confirmLabel:O("skills.action.remove"),cancelLabel:O("shared.action.cancel"),destructive:!0,busy:T===GS(z||{}),onCancel:()=>I(null),onConfirm:ce}),V?p.jsx("div",{className:"pointer-events-none fixed inset-x-0 bottom-6 z-[90] flex justify-center px-4",children:p.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:[p.jsx("span",{children:V.message}),V.undo?p.jsx("button",{type:"button",onClick:V.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:O("shared.action.undo")}):null]})}):null]})}const Cxe=["todayTokens","todayCost"],_j=[{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 FD(t,e=_j,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:Cxe).slice(0,Math.max(1,Number(n)||2))}const Axe=264,Pxe=124,To="ui-rounded, -apple-system, system-ui",UD=["#5A8CF2","#9973E6","#4DB8A6","#E68C59"],Rxe={claude:"#C77DFF",codex:"#34C759",cursor:"#FFCC00",gemini:"#0A84FF"};function Nxe(t){return t>=.9?"#E64D4D":t>=.7?"#D9A633":"#33B866"}function wv({size:t="sm",children:e}){const n=t==="lg",r=n?560:264,i=n?32:22;return p.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:p.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:`${Axe} / ${Pxe}`,borderRadius:i},children:e})})}function Dxe({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 p.jsx(wv,{size:t,children:p.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[p.jsx("defs",{children:p.jsxs("linearGradient",{id:r,x1:"0",y1:"0",x2:"0",y2:"1",children:[p.jsx("stop",{offset:"0%",stopColor:"#0A84FF",stopOpacity:"0.18"}),p.jsx("stop",{offset:"100%",stopColor:"#0A84FF",stopOpacity:"0"})]})}),p.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"}),p.jsx("text",{x:"14",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:To,children:"203.2M"}),p.jsx("text",{x:"14",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:To,children:"$129.56 ±0%"}),p.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"}),p.jsx("text",{x:"134",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:To,children:"880.9M"}),p.jsx("text",{x:"134",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:To,children:"$673.61"}),p.jsx("path",{d:n,fill:`url(#${r})`,stroke:"none"}),p.jsx("path",{d:e,fill:"none",stroke:"#0A84FF",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const jD=(()=>{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 BD(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 Lxe(){return p.jsx(wv,{children:p.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[p.jsx("g",{transform:`translate(${19.5}, 10)`,className:"hidden dark:inline",children:jD.map(a=>p.jsx("rect",{x:a.w*(7.5+1.2),y:a.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:BD(a.v,!0)},`d-${a.w}-${a.d}`))}),p.jsx("g",{transform:`translate(${19.5}, 10)`,className:"dark:hidden",children:jD.map(a=>p.jsx("rect",{x:a.w*(7.5+1.2),y:a.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:BD(a.v,!1)},`l-${a.w}-${a.d}`))}),p.jsx("text",{x:19.5,y:"102",className:"fill-oai-black dark:fill-white",fontSize:"10",fontWeight:"700",fontFamily:To,children:"10.3B"}),p.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 Ixe(){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 p.jsx(wv,{children:p.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=UD[s%UD.length];return p.jsxs("g",{children:[p.jsx("circle",{cx:"18",cy:o-3,r:"2.5",fill:c}),p.jsx("text",{x:"26",y:o,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:a.name}),p.jsx("text",{x:"218",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"600",fontFamily:To,children:a.value}),p.jsxs("text",{x:"250",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"600",fontFamily:To,children:[a.pct,"%"]}),p.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"}),p.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 Oxe(){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 p.jsx(wv,{children:p.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=Rxe[a.source],u=Nxe(a.pct/100);return p.jsxs("g",{children:[p.jsx("circle",{cx:"18",cy:o-3,r:"2.5",fill:c}),p.jsx("text",{x:"26",y:o,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:a.label}),p.jsx("text",{x:"218",y:o,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:To,children:a.reset}),p.jsxs("text",{x:"250",y:o,textAnchor:"end",className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"700",fontFamily:To,children:[a.pct,"%"]}),p.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"}),p.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 Fxe(t){switch(t.category){case"cost":return"$8.42";case"limits":return"62%";default:return t.id==="last7dTokens"?"1.8B":"203M"}}function Uxe(t,e){switch(t){case"todayTokens":return O("menubar.metric.today_tokens");case"todayCost":return O("menubar.metric.today_cost");case"last7dTokens":return O("menubar.metric.last_7d_tokens");case"totalTokens":return O("menubar.metric.total_tokens");case"totalCost":return O("menubar.metric.total_cost");case"claude5h":return O("menubar.metric.claude_5h");case"claude7d":return O("menubar.metric.claude_7d");case"codex5h":return O("menubar.metric.codex_5h");case"codex7d":return O("menubar.metric.codex_7d");default:return e}}function jxe(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 Bxe({slotConfigs:t,showStats:e}){return p.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:p.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:[p.jsx("div",{className:"flex items-center pl-2 pr-1 py-2.5",children:p.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)=>p.jsxs(ot.Fragment,{children:[i>0?p.jsx("span",{className:"my-1 w-px bg-white/20","aria-hidden":"true"}):null,p.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:[p.jsx("span",{className:"text-[13px] font-semibold leading-none tabular-nums text-white",children:r?.previewValue||"--"}),p.jsx("span",{className:"mt-[2px] text-[6px] font-semibold uppercase leading-none text-white/75",children:r?.shortLabel||"Metric"})]})]},n)):null]})})}function zxe({slot:t,value:e,options:n,disabled:r,onChange:i}){const a=O(t===0?"menubar.slot.primary":"menubar.slot.secondary");return p.jsxs("label",{className:"flex min-w-0 flex-col gap-1.5",children:[p.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400",children:a}),p.jsxs("div",{className:"relative",children:[p.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=>p.jsx("option",{value:s.id,children:s.displayLabel},s.id))}),p.jsx(Hy,{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 zD({label:t,hint:e,checked:n,disabled:r,onChange:i}){return p.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:t}),e?p.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e}):null]}),p.jsx(bf,{checked:n,disabled:r,onChange:i,ariaLabel:t})]})}function Vxe(){const{available:t,settings:e,setSetting:n}=gM(),r=x.useMemo(()=>(Array.isArray(e?.menuBarAvailableItems)?e.menuBarAvailableItems:_j).map(g=>({...g,displayLabel:Uxe(g.id,g.label),previewValue:Fxe(g)})),[e?.menuBarAvailableItems]),i=Number(e?.menuBarMaxItems)||2,a=x.useMemo(()=>FD(e?.menuBarItems,r,i),[r,i,e?.menuBarItems]),s=x.useMemo(()=>jxe(a,r),[r,a]),o=e?.showStats!==!1,c=m=>{n("menuBarItems",FD(m,r,i))},u=(m,g)=>{const v=[...s];v[m===0?1:0]!==g&&(v[m]=g,c(v))},f=[0,1].map(m=>{const g=s[m]||r[m]?.id||"",w=s[m===0?1:0],b=r.filter(E=>E.id===g||E.id!==w),_=r.find(E=>E.id===g);return{slot:m,currentValue:g,options:b,item:_}}),h=e?.animatedIcon!==!1;return p.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:[p.jsx(Bxe,{slotConfigs:f,showStats:o}),p.jsx("div",{className:"mt-5 grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4",children:f.map(({slot:m,currentValue:g,options:v})=>p.jsx(zxe,{slot:m,value:g,options:v,disabled:!t||!o,onChange:u},m))}),p.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:[p.jsx(zD,{label:O("settings.menubar.showStats"),hint:O(t?"settings.menubar.showStatsHint":"menubar.native_only"),checked:o,disabled:!t,onChange:()=>n("showStats",!o)}),p.jsx(zD,{label:O("settings.menubar.animatedIcon"),hint:O("settings.menubar.animatedIconHint"),checked:h,disabled:!t,onChange:()=>n("animatedIcon",!h)})]})]})}function Hxe(){const[t,e]=x.useState("loading");return x.useEffect(()=>{if(typeof window>"u")return;if(Ja()){e("native");return}const n=(navigator.userAgent||"").toLowerCase(),r=/mac/.test(n)&&!/iphone|ipad/.test(n);e(r?"mac-web":"other")},[]),t}function Wxe(){const t=Hxe();return t==="loading"?p.jsx("div",{className:"h-10 w-40","aria-hidden":"true"}):t==="native"?p.jsxs("button",{type:"button",onClick:()=>I3("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:[O("widgets.cta.open_gallery"),p.jsx(DW,{className:"h-4 w-4","aria-hidden":"true"})]}):t==="mac-web"?p.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:[p.jsx(Ak,{className:"h-4 w-4","aria-hidden":"true"}),O("widgets.cta.download")]}):p.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:[p.jsx(Wy,{className:"h-4 w-4","aria-hidden":"true"}),O("widgets.cta.macos_only")]})}const Gxe=[{id:"summary",Preview:Dxe,nameKey:"widgets.summary.name",descKey:"widgets.summary.description"},{id:"heatmap",Preview:Lxe,nameKey:"widgets.heatmap.name",descKey:"widgets.heatmap.description"},{id:"topModels",Preview:Ixe,nameKey:"widgets.topModels.name",descKey:"widgets.topModels.description"},{id:"limits",Preview:Oxe,nameKey:"widgets.limits.name",descKey:"widgets.limits.description"}];function $xe({Preview:t,nameKey:e,descKey:n}){return p.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:[p.jsx(t,{}),p.jsxs("div",{className:"mt-4",children:[p.jsx("h3",{className:"text-[15px] font-semibold text-oai-black dark:text-white",children:O(e)}),p.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:O(n)})]})]})}function VD({titleKey:t}){return p.jsx("h2",{className:"mb-4 text-xl font-semibold tracking-tight text-oai-black dark:text-white sm:mb-5 sm:text-2xl",children:O(t)})}function Yxe(){return p.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:p.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:p.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[p.jsx(_o,{y:12,children:p.jsxs("header",{className:"mb-10 flex items-start justify-between gap-4 sm:mb-12",children:[p.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:O("widgets.page.title")}),p.jsx("div",{className:"shrink-0",children:p.jsx(Wxe,{})})]})}),p.jsx(_o,{y:12,delay:.06,children:p.jsxs("section",{"aria-label":O("widgets.menubar.section.title"),className:"mb-12 sm:mb-14",children:[p.jsx(VD,{titleKey:"widgets.menubar.section.title"}),p.jsx(Vxe,{})]})}),p.jsxs("section",{"aria-label":O("widgets.gallery.section.title"),children:[p.jsx(VD,{titleKey:"widgets.gallery.section.title"}),p.jsx(Goe,{staggerDelay:.08,initialDelay:.04,children:p.jsx("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2 lg:gap-5",children:Gxe.map(({id:t,Preview:e,nameKey:n,descKey:r})=>p.jsx($oe,{children:p.jsx($xe,{Preview:e,nameKey:n,descKey:r})},t))})})]})]})})})}function qxe(){const{resolvedLocale:t}=lu(),e=Hi(),n=ls();VZ();const r=vr(),i=x.useMemo(()=>typeof window>"u"?!1:uE(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,m=o==="/share"||o==="/share.html"||o.startsWith("/share/"),g=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=g||E,T=!1,P=LZ(),A=x.useMemo(()=>!n.enabled||!E?null:{getAccessToken:()=>n.getAccessToken(),name:n.displayName||"",userId:n.user?.id||null},[E,n]);let R=g||r||i?"dashboard":"landing";v==="/landing"&&(R="landing"),v==="/dashboard"&&(R="dashboard"),_&&(R="dashboard");const k=v==="/limits",N=v==="/settings",B=v==="/skills",L=v==="/widgets",z=v==="/ip-check";(k||N||B||L||z)&&(R="dashboard");let I=Yle;b?I=uve:v==="/leaderboard"?I=nve:k?I=wve:N?I=sxe:B?I=Txe:L?I=Yxe:z&&(I=qle);const W=!m&&(v==="/dashboard"||v==="/"||v==="/leaderboard"||k||N||B||L||z);let X=null;if(v==="/auth/callback"||v==="/auth/native-callback")X=p.jsx(Mve,{});else if(v==="/login")X=p.jsx(kve,{});else if(R==="landing")X=p.jsx(Xge,{signInUrl:"/login",signUpUrl:"/login"});else{const J=p.jsx(I,{baseUrl:P,auth:A,signedIn:M,sessionSoftExpired:T,signOut:()=>n.enabled?n.signOut():Promise.resolve(),publicMode:m,publicToken:h,userId:b,signInUrl:"/login",signUpUrl:"/login"},t);W?X=p.jsx(Fre,{children:J}):X=J}return p.jsx(EG,{children:p.jsx(CG,{children:p.jsxs(AG,{children:[X,p.jsx(NZ,{}),p.jsx(pW,{}),p.jsx(EW,{})]})})})}const Xxe=H8([{path:"*",element:p.jsx(qxe,{})}]);RB.createRoot(document.getElementById("root")).render(p.jsx(ot.StrictMode,{children:p.jsx(nW,{children:p.jsx(C7,{children:p.jsx(nz,{router:Xxe})})})}));
|