tokentracker-cli 0.5.24 → 0.5.25

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage-vIxKP44Z.js","assets/ThemeToggle-8m6pW0Kd.js","assets/LeaderboardPage-VXJBiwkB.js","assets/leaderboard-columns-BtZZjmrK.js","assets/LeaderboardProfilePage-DPeOBsNk.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage-Bv4UcOEZ.js","assets/ThemeToggle-Qn_pvy0M.js","assets/LeaderboardPage-CbvvPyY_.js","assets/leaderboard-columns-QXmWCpyM.js","assets/LeaderboardProfilePage-Co4mAr4h.js"])))=>i.map(i=>d[i]);
2
2
  function s2(t,e){for(var n=0;n<e.length;n++){const i=e[n];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in t)){const s=Object.getOwnPropertyDescriptor(i,r);s&&Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();function D1(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function a2(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function i(){var r=!1;try{r=this instanceof i}catch{}return r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}),n}var _m={exports:{}},Lc={},xm={exports:{}},Jt={};var wb;function o2(){if(wb)return Jt;wb=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),o=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.iterator;function m(B){return B===null||typeof B!="object"?null:(B=p&&B[p]||B["@@iterator"],typeof B=="function"?B:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,w={};function y(B,ie,ve){this.props=B,this.context=ie,this.refs=w,this.updater=ve||v}y.prototype.isReactComponent={},y.prototype.setState=function(B,ie){if(typeof B!="object"&&typeof B!="function"&&B!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,B,ie,"setState")},y.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function x(){}x.prototype=y.prototype;function M(B,ie,ve){this.props=B,this.context=ie,this.refs=w,this.updater=ve||v}var A=M.prototype=new x;A.constructor=M,_(A,y.prototype),A.isPureReactComponent=!0;var T=Array.isArray,D=Object.prototype.hasOwnProperty,I={current:null},U={key:!0,ref:!0,__self:!0,__source:!0};function S(B,ie,ve){var Ce,we={},ne=null,_e=null;if(ie!=null)for(Ce in ie.ref!==void 0&&(_e=ie.ref),ie.key!==void 0&&(ne=""+ie.key),ie)D.call(ie,Ce)&&!U.hasOwnProperty(Ce)&&(we[Ce]=ie[Ce]);var Se=arguments.length-2;if(Se===1)we.children=ve;else if(1<Se){for(var Ie=Array(Se),et=0;et<Se;et++)Ie[et]=arguments[et+2];we.children=Ie}if(B&&B.defaultProps)for(Ce in Se=B.defaultProps,Se)we[Ce]===void 0&&(we[Ce]=Se[Ce]);return{$$typeof:t,type:B,key:ne,ref:_e,props:we,_owner:I.current}}function R(B,ie){return{$$typeof:t,type:B.type,key:ie,ref:B.ref,props:B.props,_owner:B._owner}}function V(B){return typeof B=="object"&&B!==null&&B.$$typeof===t}function F(B){var ie={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(ve){return ie[ve]})}var j=/\/+/g;function Z(B,ie){return typeof B=="object"&&B!==null&&B.key!=null?F(""+B.key):ie.toString(36)}function H(B,ie,ve,Ce,we){var ne=typeof B;(ne==="undefined"||ne==="boolean")&&(B=null);var _e=!1;if(B===null)_e=!0;else switch(ne){case"string":case"number":_e=!0;break;case"object":switch(B.$$typeof){case t:case e:_e=!0}}if(_e)return _e=B,we=we(_e),B=Ce===""?"."+Z(_e,0):Ce,T(we)?(ve="",B!=null&&(ve=B.replace(j,"$&/")+"/"),H(we,ie,ve,"",function(et){return et})):we!=null&&(V(we)&&(we=R(we,ve+(!we.key||_e&&_e.key===we.key?"":(""+we.key).replace(j,"$&/")+"/")+B)),ie.push(we)),1;if(_e=0,Ce=Ce===""?".":Ce+":",T(B))for(var Se=0;Se<B.length;Se++){ne=B[Se];var Ie=Ce+Z(ne,Se);_e+=H(ne,ie,ve,Ie,we)}else if(Ie=m(B),typeof Ie=="function")for(B=Ie.call(B),Se=0;!(ne=B.next()).done;)ne=ne.value,Ie=Ce+Z(ne,Se++),_e+=H(ne,ie,ve,Ie,we);else if(ne==="object")throw ie=String(B),Error("Objects are not valid as a React child (found: "+(ie==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":ie)+"). If you meant to render a collection of children, use an array instead.");return _e}function q(B,ie,ve){if(B==null)return B;var Ce=[],we=0;return H(B,Ce,"","",function(ne){return ie.call(ve,ne,we++)}),Ce}function J(B){if(B._status===-1){var ie=B._result;ie=ie(),ie.then(function(ve){(B._status===0||B._status===-1)&&(B._status=1,B._result=ve)},function(ve){(B._status===0||B._status===-1)&&(B._status=2,B._result=ve)}),B._status===-1&&(B._status=0,B._result=ie)}if(B._status===1)return B._result.default;throw B._result}var Q={current:null},W={transition:null},X={ReactCurrentDispatcher:Q,ReactCurrentBatchConfig:W,ReactCurrentOwner:I};function K(){throw Error("act(...) is not supported in production builds of React.")}return Jt.Children={map:q,forEach:function(B,ie,ve){q(B,function(){ie.apply(this,arguments)},ve)},count:function(B){var ie=0;return q(B,function(){ie++}),ie},toArray:function(B){return q(B,function(ie){return ie})||[]},only:function(B){if(!V(B))throw Error("React.Children.only expected to receive a single React element child.");return B}},Jt.Component=y,Jt.Fragment=n,Jt.Profiler=r,Jt.PureComponent=M,Jt.StrictMode=i,Jt.Suspense=u,Jt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=X,Jt.act=K,Jt.cloneElement=function(B,ie,ve){if(B==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+B+".");var Ce=_({},B.props),we=B.key,ne=B.ref,_e=B._owner;if(ie!=null){if(ie.ref!==void 0&&(ne=ie.ref,_e=I.current),ie.key!==void 0&&(we=""+ie.key),B.type&&B.type.defaultProps)var Se=B.type.defaultProps;for(Ie in ie)D.call(ie,Ie)&&!U.hasOwnProperty(Ie)&&(Ce[Ie]=ie[Ie]===void 0&&Se!==void 0?Se[Ie]:ie[Ie])}var Ie=arguments.length-2;if(Ie===1)Ce.children=ve;else if(1<Ie){Se=Array(Ie);for(var et=0;et<Ie;et++)Se[et]=arguments[et+2];Ce.children=Se}return{$$typeof:t,type:B.type,key:we,ref:ne,props:Ce,_owner:_e}},Jt.createContext=function(B){return B={$$typeof:o,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},B.Provider={$$typeof:s,_context:B},B.Consumer=B},Jt.createElement=S,Jt.createFactory=function(B){var ie=S.bind(null,B);return ie.type=B,ie},Jt.createRef=function(){return{current:null}},Jt.forwardRef=function(B){return{$$typeof:c,render:B}},Jt.isValidElement=V,Jt.lazy=function(B){return{$$typeof:h,_payload:{_status:-1,_result:B},_init:J}},Jt.memo=function(B,ie){return{$$typeof:f,type:B,compare:ie===void 0?null:ie}},Jt.startTransition=function(B){var ie=W.transition;W.transition={};try{B()}finally{W.transition=ie}},Jt.unstable_act=K,Jt.useCallback=function(B,ie){return Q.current.useCallback(B,ie)},Jt.useContext=function(B){return Q.current.useContext(B)},Jt.useDebugValue=function(){},Jt.useDeferredValue=function(B){return Q.current.useDeferredValue(B)},Jt.useEffect=function(B,ie){return Q.current.useEffect(B,ie)},Jt.useId=function(){return Q.current.useId()},Jt.useImperativeHandle=function(B,ie,ve){return Q.current.useImperativeHandle(B,ie,ve)},Jt.useInsertionEffect=function(B,ie){return Q.current.useInsertionEffect(B,ie)},Jt.useLayoutEffect=function(B,ie){return Q.current.useLayoutEffect(B,ie)},Jt.useMemo=function(B,ie){return Q.current.useMemo(B,ie)},Jt.useReducer=function(B,ie,ve){return Q.current.useReducer(B,ie,ve)},Jt.useRef=function(B){return Q.current.useRef(B)},Jt.useState=function(B){return Q.current.useState(B)},Jt.useSyncExternalStore=function(B,ie,ve){return Q.current.useSyncExternalStore(B,ie,ve)},Jt.useTransition=function(){return Q.current.useTransition()},Jt.version="18.3.1",Jt}var Eb;function Nv(){return Eb||(Eb=1,xm.exports=o2()),xm.exports}var Mb;function l2(){if(Mb)return Lc;Mb=1;var t=Nv(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(c,u,f){var h,p={},m=null,v=null;f!==void 0&&(m=""+f),u.key!==void 0&&(m=""+u.key),u.ref!==void 0&&(v=u.ref);for(h in u)i.call(u,h)&&!s.hasOwnProperty(h)&&(p[h]=u[h]);if(c&&c.defaultProps)for(h in u=c.defaultProps,u)p[h]===void 0&&(p[h]=u[h]);return{$$typeof:e,type:c,key:m,ref:v,props:p,_owner:r.current}}return Lc.Fragment=n,Lc.jsx=o,Lc.jsxs=o,Lc}var Tb;function c2(){return Tb||(Tb=1,_m.exports=l2()),_m.exports}var O=c2(),k=Nv();const jl=D1(k),N1=s2({__proto__:null,default:jl},[k]);var Id={},bm={exports:{}},Vi={},Sm={exports:{}},wm={};var Ab;function u2(){return Ab||(Ab=1,(function(t){function e(W,X){var K=W.length;W.push(X);e:for(;0<K;){var B=K-1>>>1,ie=W[B];if(0<r(ie,X))W[B]=X,W[K]=ie,K=B;else break e}}function n(W){return W.length===0?null:W[0]}function i(W){if(W.length===0)return null;var X=W[0],K=W.pop();if(K!==X){W[0]=K;e:for(var B=0,ie=W.length,ve=ie>>>1;B<ve;){var Ce=2*(B+1)-1,we=W[Ce],ne=Ce+1,_e=W[ne];if(0>r(we,K))ne<ie&&0>r(_e,we)?(W[B]=_e,W[ne]=K,B=ne):(W[B]=we,W[Ce]=K,B=Ce);else if(ne<ie&&0>r(_e,K))W[B]=_e,W[ne]=K,B=ne;else break e}}return X}function r(W,X){var K=W.sortIndex-X.sortIndex;return K!==0?K:W.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,c=o.now();t.unstable_now=function(){return o.now()-c}}var u=[],f=[],h=1,p=null,m=3,v=!1,_=!1,w=!1,y=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function A(W){for(var X=n(f);X!==null;){if(X.callback===null)i(f);else if(X.startTime<=W)i(f),X.sortIndex=X.expirationTime,e(u,X);else break;X=n(f)}}function T(W){if(w=!1,A(W),!_)if(n(u)!==null)_=!0,J(D);else{var X=n(f);X!==null&&Q(T,X.startTime-W)}}function D(W,X){_=!1,w&&(w=!1,x(S),S=-1),v=!0;var K=m;try{for(A(X),p=n(u);p!==null&&(!(p.expirationTime>X)||W&&!F());){var B=p.callback;if(typeof B=="function"){p.callback=null,m=p.priorityLevel;var ie=B(p.expirationTime<=X);X=t.unstable_now(),typeof ie=="function"?p.callback=ie:p===n(u)&&i(u),A(X)}else i(u);p=n(u)}if(p!==null)var ve=!0;else{var Ce=n(f);Ce!==null&&Q(T,Ce.startTime-X),ve=!1}return ve}finally{p=null,m=K,v=!1}}var I=!1,U=null,S=-1,R=5,V=-1;function F(){return!(t.unstable_now()-V<R)}function j(){if(U!==null){var W=t.unstable_now();V=W;var X=!0;try{X=U(!0,W)}finally{X?Z():(I=!1,U=null)}}else I=!1}var Z;if(typeof M=="function")Z=function(){M(j)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,q=H.port2;H.port1.onmessage=j,Z=function(){q.postMessage(null)}}else Z=function(){y(j,0)};function J(W){U=W,I||(I=!0,Z())}function Q(W,X){S=y(function(){W(t.unstable_now())},X)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(W){W.callback=null},t.unstable_continueExecution=function(){_||v||(_=!0,J(D))},t.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<W?Math.floor(1e3/W):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_getFirstCallbackNode=function(){return n(u)},t.unstable_next=function(W){switch(m){case 1:case 2:case 3:var X=3;break;default:X=m}var K=m;m=X;try{return W()}finally{m=K}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(W,X){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var K=m;m=W;try{return X()}finally{m=K}},t.unstable_scheduleCallback=function(W,X,K){var B=t.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?B+K:B):K=B,W){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=K+ie,W={id:h++,callback:X,priorityLevel:W,startTime:K,expirationTime:ie,sortIndex:-1},K>B?(W.sortIndex=K,e(f,W),n(u)===null&&W===n(f)&&(w?(x(S),S=-1):w=!0,Q(T,K-B))):(W.sortIndex=ie,e(u,W),_||v||(_=!0,J(D))),W},t.unstable_shouldYield=F,t.unstable_wrapCallback=function(W){var X=m;return function(){var K=m;m=X;try{return W.apply(this,arguments)}finally{m=K}}}})(wm)),wm}var Cb;function d2(){return Cb||(Cb=1,Sm.exports=u2()),Sm.exports}var Rb;function f2(){if(Rb)return Vi;Rb=1;var t=Nv(),e=d2();function n(a){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+a,d=1;d<arguments.length;d++)l+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+a+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=new Set,r={};function s(a,l){o(a,l),o(a+"Capture",l)}function o(a,l){for(r[a]=l,a=0;a<l.length;a++)i.add(l[a])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,h={},p={};function m(a){return u.call(p,a)?!0:u.call(h,a)?!1:f.test(a)?p[a]=!0:(h[a]=!0,!1)}function v(a,l,d,g){if(d!==null&&d.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return g?!1:d!==null?!d.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function _(a,l,d,g){if(l===null||typeof l>"u"||v(a,l,d,g))return!0;if(g)return!1;if(d!==null)switch(d.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function w(a,l,d,g,b,E,L){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=g,this.attributeNamespace=b,this.mustUseProperty=d,this.propertyName=a,this.type=l,this.sanitizeURL=E,this.removeEmptyString=L}var y={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){y[a]=new w(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var l=a[0];y[l]=new w(l,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){y[a]=new w(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){y[a]=new w(a,2,!1,a,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a){y[a]=new w(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){y[a]=new w(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){y[a]=new w(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){y[a]=new w(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){y[a]=new w(a,5,!1,a.toLowerCase(),null,!1,!1)});var x=/[\-:]([a-z])/g;function M(a){return a[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a){var l=a.replace(x,M);y[l]=new w(l,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var l=a.replace(x,M);y[l]=new w(l,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var l=a.replace(x,M);y[l]=new w(l,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){y[a]=new w(a,1,!1,a.toLowerCase(),null,!1,!1)}),y.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){y[a]=new w(a,1,!1,a.toLowerCase(),null,!0,!0)});function A(a,l,d,g){var b=y.hasOwnProperty(l)?y[l]:null;(b!==null?b.type!==0:g||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(_(l,d,b,g)&&(d=null),g||b===null?m(l)&&(d===null?a.removeAttribute(l):a.setAttribute(l,""+d)):b.mustUseProperty?a[b.propertyName]=d===null?b.type===3?!1:"":d:(l=b.attributeName,g=b.attributeNamespace,d===null?a.removeAttribute(l):(b=b.type,d=b===3||b===4&&d===!0?"":""+d,g?a.setAttributeNS(g,l,d):a.setAttribute(l,d))))}var T=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,D=Symbol.for("react.element"),I=Symbol.for("react.portal"),U=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),V=Symbol.for("react.provider"),F=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),Z=Symbol.for("react.suspense"),H=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),Q=Symbol.for("react.offscreen"),W=Symbol.iterator;function X(a){return a===null||typeof a!="object"?null:(a=W&&a[W]||a["@@iterator"],typeof a=="function"?a:null)}var K=Object.assign,B;function ie(a){if(B===void 0)try{throw Error()}catch(d){var l=d.stack.trim().match(/\n( *(at )?)/);B=l&&l[1]||""}return`
3
3
  `+B+a}var ve=!1;function Ce(a,l){if(!a||ve)return"";ve=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(ge){var g=ge}Reflect.construct(a,[],l)}else{try{l.call()}catch(ge){g=ge}a.call(l.prototype)}else{try{throw Error()}catch(ge){g=ge}a()}}catch(ge){if(ge&&g&&typeof ge.stack=="string"){for(var b=ge.stack.split(`
4
4
  `),E=g.stack.split(`
@@ -39,7 +39,7 @@ Please change the parent <Route path="${y}"> to <Route path="${y==="/"?"*":`${y}
39
39
  `))}logResponse(t,e,n,i,r){if(!this.enabled)return;const s=[`← ${t} ${e} ${n} (${i}ms)`],o=PS(tu(r));if(o){const c=o.length>1e3?o.slice(0,1e3)+"... [truncated]":o;s.push(` Body: ${c}`)}n>=400?this.error(s.join(`
40
40
  `)):this.log(s.join(`
41
41
  `))}},ry="insforge_csrf_token";function ZM(){if(typeof document>"u")return null;const t=document.cookie.split(";").find(e=>e.trim().startsWith(`${ry}=`));return t&&t.split("=")[1]||null}function JM(t){if(typeof document>"u")return;const e=10080*60,n=typeof window<"u"&&window.location.protocol==="https:"?"; Secure":"";document.cookie=`${ry}=${encodeURIComponent(t)}; path=/; max-age=${e}; SameSite=Lax${n}`}function QM(){if(typeof document>"u")return;const t=typeof window<"u"&&window.location.protocol==="https:"?"; Secure":"";document.cookie=`${ry}=; path=/; max-age=0; SameSite=Lax${t}`}var eT=class{constructor(){this.accessToken=null,this.user=null,this.onTokenChange=null}saveSession(t){const e=t.accessToken!==this.accessToken;this.accessToken=t.accessToken,this.user=t.user,e&&this.onTokenChange&&this.onTokenChange()}getSession(){return!this.accessToken||!this.user?null:{accessToken:this.accessToken,user:this.user}}getAccessToken(){return this.accessToken}setAccessToken(t){const e=t!==this.accessToken;this.accessToken=t,e&&this.onTokenChange&&this.onTokenChange()}getUser(){return this.user}setUser(t){this.user=t}clearSession(){const t=this.accessToken!==null;this.accessToken=null,this.user=null,t&&this.onTokenChange&&this.onTokenChange()}},qN=new Set([500,502,503,504]),YN=new Set(["GET","HEAD","PUT","DELETE","OPTIONS"]),KN=class{constructor(t,e,n){if(this.userToken=null,this.autoRefreshToken=!0,this.isRefreshing=!1,this.refreshPromise=null,this.refreshToken=null,this.baseUrl=t.baseUrl||"http://localhost:7130",this.autoRefreshToken=t.autoRefreshToken??!0,this.fetch=t.fetch||(globalThis.fetch?globalThis.fetch.bind(globalThis):void 0),this.anonKey=t.anonKey,this.defaultHeaders={...t.headers},this.tokenManager=e??new eT,this.logger=n||new KM(!1),this.timeout=t.timeout??3e4,this.retryCount=t.retryCount??3,this.retryDelay=t.retryDelay??500,!this.fetch)throw new Error("Fetch is not available. Please provide a fetch implementation in the config.")}buildUrl(t,e){const n=new URL(t,this.baseUrl);return e&&Object.entries(e).forEach(([i,r])=>{if(i==="select"){let s=r.replace(/\s+/g," ").trim();s=s.replace(/\s*\(\s*/g,"(").replace(/\s*\)\s*/g,")").replace(/\(\s+/g,"(").replace(/\s+\)/g,")").replace(/,\s+(?=[^()]*\))/g,","),n.searchParams.append(i,s)}else n.searchParams.append(i,r)}),n.toString()}isRetryableStatus(t){return qN.has(t)}computeRetryDelay(t){const n=this.retryDelay*Math.pow(2,t-1)*(.85+Math.random()*.3);return Math.round(n)}async handleRequest(t,e,n={}){const{params:i,headers:r={},body:s,signal:o,...c}=n,u=this.buildUrl(e,i),f=Date.now(),p=YN.has(t.toUpperCase())||n.idempotent===!0?this.retryCount:0,m={...this.defaultHeaders},v=this.userToken||this.anonKey;v&&(m.Authorization=`Bearer ${v}`);let _;s!==void 0&&(typeof FormData<"u"&&s instanceof FormData?_=s:(t!=="GET"&&(m["Content-Type"]="application/json;charset=UTF-8"),_=JSON.stringify(s))),r instanceof Headers?r.forEach((y,x)=>{m[x]=y}):Array.isArray(r)?r.forEach(([y,x])=>{m[y]=x}):Object.assign(m,r),this.logger.logRequest(t,u,m,_);let w;for(let y=0;y<=p;y++){if(y>0){const A=this.computeRetryDelay(y);if(this.logger.warn(`Retry ${y}/${p} for ${t} ${u} in ${A}ms`),o?.aborted)throw o.reason;await new Promise((T,D)=>{const I=()=>{clearTimeout(U),D(o.reason)},U=setTimeout(()=>{o&&o.removeEventListener("abort",I),T()},A);o&&o.addEventListener("abort",I,{once:!0})})}let x,M;if((this.timeout>0||o)&&(x=new AbortController,this.timeout>0&&(M=setTimeout(()=>x.abort(),this.timeout)),o))if(o.aborted)x.abort(o.reason);else{const A=()=>x.abort(o.reason);o.addEventListener("abort",A,{once:!0}),x.signal.addEventListener("abort",()=>{o.removeEventListener("abort",A)},{once:!0})}try{const A=await this.fetch(u,{method:t,headers:m,body:_,...c,...x?{signal:x.signal}:{}});if(this.isRetryableStatus(A.status)&&y<p){M!==void 0&&clearTimeout(M),await A.body?.cancel(),w=new Gt(`Server error: ${A.status} ${A.statusText}`,A.status,"SERVER_ERROR");continue}if(A.status===204){M!==void 0&&clearTimeout(M);return}let T;const D=A.headers.get("content-type");try{D?.includes("json")?T=await A.json():T=await A.text()}catch(I){throw M!==void 0&&clearTimeout(M),new Gt(`Failed to parse response body: ${I?.message||"Unknown error"}`,A.status,A.ok?"PARSE_ERROR":"REQUEST_FAILED")}if(M!==void 0&&clearTimeout(M),!A.ok){if(this.logger.logResponse(t,u,A.status,Date.now()-f,T),T&&typeof T=="object"&&"error"in T){!T.statusCode&&!T.status&&(T.statusCode=A.status);const I=Gt.fromApiError(T);throw Object.keys(T).forEach(U=>{U!=="error"&&U!=="message"&&U!=="statusCode"&&(I[U]=T[U])}),I}throw new Gt(`Request failed: ${A.statusText}`,A.status,"REQUEST_FAILED")}return this.logger.logResponse(t,u,A.status,Date.now()-f,T),T}catch(A){if(M!==void 0&&clearTimeout(M),A?.name==="AbortError")throw x&&x.signal.aborted&&this.timeout>0&&!o?.aborted?new Gt(`Request timed out after ${this.timeout}ms`,408,"REQUEST_TIMEOUT"):A;if(A instanceof Gt)throw A;if(y<p){w=A;continue}throw new Gt(`Network request failed: ${A?.message||"Unknown error"}`,0,"NETWORK_ERROR")}}throw w||new Gt("Request failed after all retry attempts",0,"NETWORK_ERROR")}async request(t,e,n={}){try{return await this.handleRequest(t,e,{...n})}catch(i){if(i instanceof Gt&&i.statusCode===401&&i.error==="INVALID_TOKEN"&&this.autoRefreshToken)try{const r=await this.handleTokenRefresh();return this.setAuthToken(r.accessToken),this.tokenManager.saveSession(r),r.csrfToken&&JM(r.csrfToken),r.refreshToken&&this.setRefreshToken(r.refreshToken),await this.handleRequest(t,e,{...n})}catch(r){throw this.tokenManager.clearSession(),this.userToken=null,this.refreshToken=null,QM(),r}throw i}}get(t,e){return this.request("GET",t,e)}post(t,e,n){return this.request("POST",t,{...n,body:e})}put(t,e,n){return this.request("PUT",t,{...n,body:e})}patch(t,e,n){return this.request("PATCH",t,{...n,body:e})}delete(t,e){return this.request("DELETE",t,e)}setAuthToken(t){this.userToken=t}setRefreshToken(t){this.refreshToken=t}getHeaders(){const t={...this.defaultHeaders},e=this.userToken||this.anonKey;return e&&(t.Authorization=`Bearer ${e}`),t}async handleTokenRefresh(){return this.isRefreshing?this.refreshPromise:(this.isRefreshing=!0,this.refreshPromise=(async()=>{try{const t=ZM(),e=this.refreshToken?{refreshToken:this.refreshToken}:void 0;return await this.handleRequest("POST","/api/auth/sessions/current",{body:e,headers:t?{"X-CSRF-Token":t}:{},credentials:"include"})}finally{this.isRefreshing=!1,this.refreshPromise=null}})(),this.refreshPromise)}},o0="insforge_pkce_verifier";function tT(t){return btoa(String.fromCharCode(...t)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function ZN(){const t=new Uint8Array(32);return crypto.getRandomValues(t),tT(t)}async function JN(t){const n=new TextEncoder().encode(t),i=await crypto.subtle.digest("SHA-256",n);return tT(new Uint8Array(i))}function QN(t){typeof sessionStorage<"u"&&sessionStorage.setItem(o0,t)}function eI(){if(typeof sessionStorage>"u")return null;const t=sessionStorage.getItem(o0);return t&&sessionStorage.removeItem(o0),t}function Yi(t,e){return t instanceof Gt?{data:null,error:t}:{data:null,error:new Gt(t instanceof Error?t.message:e,500,"UNEXPECTED_ERROR")}}function kS(...t){if(typeof window>"u")return;const e=new URL(window.location.href);t.forEach(n=>e.searchParams.delete(n)),window.history.replaceState({},document.title,e.toString())}var tI=class{constructor(t,e,n={}){this.http=t,this.tokenManager=e,this.options=n,this.authCallbackHandled=this.detectAuthCallback()}isServerMode(){return!!this.options.isServerMode}saveSessionFromResponse(t){if(!t.accessToken||!t.user)return!1;const e={accessToken:t.accessToken,user:t.user};return!this.isServerMode()&&t.csrfToken&&JM(t.csrfToken),this.isServerMode()||this.tokenManager.saveSession(e),this.http.setAuthToken(t.accessToken),this.http.setRefreshToken(t.refreshToken??null),!0}async detectAuthCallback(){if(!(this.isServerMode()||typeof window>"u"))try{const t=new URLSearchParams(window.location.search),e=t.get("error");if(e){kS("error"),console.debug("OAuth callback error:",e);return}const n=t.get("insforge_code");if(n){kS("insforge_code");const{error:i}=await this.exchangeOAuthCode(n);i&&console.debug("OAuth code exchange failed:",i.message);return}}catch(t){console.debug("OAuth callback detection skipped:",t)}}async signUp(t){try{const e=await this.http.post(this.isServerMode()?"/api/auth/users?client_type=mobile":"/api/auth/users",t,{credentials:"include"});return e.accessToken&&e.user&&this.saveSessionFromResponse(e),e.refreshToken&&this.http.setRefreshToken(e.refreshToken),{data:e,error:null}}catch(e){return Yi(e,"An unexpected error occurred during sign up")}}async signInWithPassword(t){try{const e=await this.http.post(this.isServerMode()?"/api/auth/sessions?client_type=mobile":"/api/auth/sessions",t,{credentials:"include"});return this.saveSessionFromResponse(e),e.refreshToken&&this.http.setRefreshToken(e.refreshToken),{data:e,error:null}}catch(e){return Yi(e,"An unexpected error occurred during sign in")}}async signOut(){try{try{await this.http.post(this.isServerMode()?"/api/auth/logout?client_type=mobile":"/api/auth/logout",void 0,{credentials:"include"})}catch{}return this.tokenManager.clearSession(),this.http.setAuthToken(null),this.http.setRefreshToken(null),this.isServerMode()||QM(),{error:null}}catch{return{error:new Gt("Failed to sign out",500,"SIGNOUT_ERROR")}}}async signInWithOAuth(t){try{const{provider:e,redirectTo:n,skipBrowserRedirect:i}=t,r=encodeURIComponent(e.toLowerCase()),s=ZN(),o=await JN(s);QN(s);const c={code_challenge:o};n&&(c.redirect_uri=n);const f=Ah.options.includes(r)?`/api/auth/oauth/${r}`:`/api/auth/oauth/custom/${r}`,h=await this.http.get(f,{params:c});return!this.isServerMode()&&typeof window<"u"&&!i?(window.location.href=h.authUrl,{data:{},error:null}):{data:{url:h.authUrl,provider:r,codeVerifier:s},error:null}}catch(e){return e instanceof Gt?{data:{},error:e}:{data:{},error:new Gt("An unexpected error occurred during OAuth initialization",500,"UNEXPECTED_ERROR")}}}async exchangeOAuthCode(t,e){try{const n=e??eI();if(!n)return{data:null,error:new Gt("PKCE code verifier not found. Ensure signInWithOAuth was called in the same browser session.",400,"PKCE_VERIFIER_MISSING")};const i={code:t,code_verifier:n},r=await this.http.post(this.isServerMode()?"/api/auth/oauth/exchange?client_type=mobile":"/api/auth/oauth/exchange",i,{credentials:"include"});return this.saveSessionFromResponse(r),{data:r,error:null}}catch(n){return Yi(n,"An unexpected error occurred during OAuth code exchange")}}async signInWithIdToken(t){try{const{provider:e,token:n}=t,i=await this.http.post("/api/auth/id-token?client_type=mobile",{provider:e,token:n},{credentials:"include"});return this.saveSessionFromResponse(i),i.refreshToken&&this.http.setRefreshToken(i.refreshToken),{data:i,error:null}}catch(e){return Yi(e,"An unexpected error occurred during ID token sign in")}}async refreshSession(t){try{if(this.isServerMode()&&!t?.refreshToken)return{data:null,error:new Gt("refreshToken is required when refreshing session in server mode",400,"REFRESH_TOKEN_REQUIRED")};const e=this.isServerMode()?null:ZM(),n=await this.http.post(this.isServerMode()?"/api/auth/refresh?client_type=mobile":"/api/auth/refresh",this.isServerMode()?{refresh_token:t?.refreshToken}:void 0,{headers:e?{"X-CSRF-Token":e}:{},credentials:"include"});return n.accessToken&&this.saveSessionFromResponse(n),{data:n,error:null}}catch(e){return Yi(e,"An unexpected error occurred during session refresh")}}async getCurrentUser(){await this.authCallbackHandled;try{if(this.isServerMode()){const e=this.tokenManager.getAccessToken();return e?(this.http.setAuthToken(e),{data:{user:(await this.http.get("/api/auth/sessions/current")).user??null},error:null}):{data:{user:null},error:null}}const t=this.tokenManager.getSession();if(t)return this.http.setAuthToken(t.accessToken),{data:{user:t.user},error:null};if(typeof window<"u"){const{data:e,error:n}=await this.refreshSession();if(n)return{data:{user:null},error:n};if(e?.accessToken)return{data:{user:e.user??null},error:null}}return{data:{user:null},error:null}}catch(t){return t instanceof Gt?{data:{user:null},error:t}:{data:{user:null},error:new Gt("An unexpected error occurred while getting user",500,"UNEXPECTED_ERROR")}}}async getProfile(t){try{return{data:await this.http.get(`/api/auth/profiles/${t}`),error:null}}catch(e){return Yi(e,"An unexpected error occurred while fetching user profile")}}async setProfile(t){try{const e=await this.http.patch("/api/auth/profiles/current",{profile:t}),n=this.tokenManager.getUser();return!this.isServerMode()&&n&&e.profile!==void 0&&this.tokenManager.setUser({...n,profile:e.profile}),{data:e,error:null}}catch(e){return Yi(e,"An unexpected error occurred while updating user profile")}}async resendVerificationEmail(t){try{return{data:await this.http.post("/api/auth/email/send-verification",t),error:null}}catch(e){return Yi(e,"An unexpected error occurred while sending verification email")}}async verifyEmail(t){try{const e=await this.http.post(this.isServerMode()?"/api/auth/email/verify?client_type=mobile":"/api/auth/email/verify",t,{credentials:"include"});return this.saveSessionFromResponse(e),e.refreshToken&&this.http.setRefreshToken(e.refreshToken),{data:e,error:null}}catch(e){return Yi(e,"An unexpected error occurred while verifying email")}}async sendResetPasswordEmail(t){try{return{data:await this.http.post("/api/auth/email/send-reset-password",t),error:null}}catch(e){return Yi(e,"An unexpected error occurred while sending password reset email")}}async exchangeResetPasswordToken(t){try{return{data:await this.http.post("/api/auth/email/exchange-reset-password-token",t),error:null}}catch(e){return Yi(e,"An unexpected error occurred while verifying reset code")}}async resetPassword(t){try{return{data:await this.http.post("/api/auth/email/reset-password",t),error:null}}catch(e){return Yi(e,"An unexpected error occurred while resetting password")}}async getPublicAuthConfig(){try{return{data:await this.http.get("/api/auth/public-config"),error:null}}catch(t){return Yi(t,"An unexpected error occurred while fetching auth configuration")}}};function nI(t,e){return async(n,i)=>{const r=typeof n=="string"?n:n.toString(),s=new URL(r),o=s.pathname.slice(1),c=o.match(/^rpc\/(.+)$/),u=c?`/api/database/rpc/${c[1]}`:`/api/database/records/${o}`,f=`${t.baseUrl}${u}${s.search}`,h=e.getAccessToken(),p=t.getHeaders(),m=h||p.Authorization?.replace("Bearer ",""),v=new Headers(i?.headers);return m&&!v.has("Authorization")&&v.set("Authorization",`Bearer ${m}`),await fetch(f,{...i,headers:v})}}var iI=class{constructor(t,e){this.postgrest=new Z3("http://dummy",{fetch:nI(t,e),headers:{}})}from(t){return this.postgrest.from(t)}rpc(t,e,n){return this.postgrest.rpc(t,e,n)}},rI=class{constructor(t,e){this.bucketName=t,this.http=e}async upload(t,e){try{const n=await this.http.post(`/api/storage/buckets/${this.bucketName}/upload-strategy`,{filename:t,contentType:e.type||"application/octet-stream",size:e.size});if(n.method==="presigned")return await this.uploadWithPresignedUrl(n,e);if(n.method==="direct"){const i=new FormData;return i.append("file",e),{data:await this.http.request("PUT",`/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(t)}`,{body:i,headers:{}}),error:null}}throw new Gt(`Unsupported upload method: ${n.method}`,500,"STORAGE_ERROR")}catch(n){return{data:null,error:n instanceof Gt?n:new Gt("Upload failed",500,"STORAGE_ERROR")}}}async uploadAuto(t){try{const e=t instanceof File?t.name:"file",n=await this.http.post(`/api/storage/buckets/${this.bucketName}/upload-strategy`,{filename:e,contentType:t.type||"application/octet-stream",size:t.size});if(n.method==="presigned")return await this.uploadWithPresignedUrl(n,t);if(n.method==="direct"){const i=new FormData;return i.append("file",t),{data:await this.http.request("POST",`/api/storage/buckets/${this.bucketName}/objects`,{body:i,headers:{}}),error:null}}throw new Gt(`Unsupported upload method: ${n.method}`,500,"STORAGE_ERROR")}catch(e){return{data:null,error:e instanceof Gt?e:new Gt("Upload failed",500,"STORAGE_ERROR")}}}async uploadWithPresignedUrl(t,e){try{const n=new FormData;t.fields&&Object.entries(t.fields).forEach(([r,s])=>{n.append(r,s)}),n.append("file",e);const i=await fetch(t.uploadUrl,{method:"POST",body:n});if(!i.ok)throw new Gt(`Upload to storage failed: ${i.statusText}`,i.status,"STORAGE_ERROR");return t.confirmRequired&&t.confirmUrl?{data:await this.http.post(t.confirmUrl,{size:e.size,contentType:e.type||"application/octet-stream"}),error:null}:{data:{key:t.key,bucket:this.bucketName,size:e.size,mimeType:e.type||"application/octet-stream",uploadedAt:new Date().toISOString(),url:this.getPublicUrl(t.key)},error:null}}catch(n){throw n instanceof Gt?n:new Gt("Presigned upload failed",500,"STORAGE_ERROR")}}async download(t){try{const e=await this.http.post(`/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(t)}/download-strategy`,{expiresIn:3600}),n=e.url,i={};e.method==="direct"&&Object.assign(i,this.http.getHeaders());const r=await fetch(n,{method:"GET",headers:i});if(!r.ok)try{const o=await r.json();throw Gt.fromApiError(o)}catch{throw new Gt(`Download failed: ${r.statusText}`,r.status,"STORAGE_ERROR")}return{data:await r.blob(),error:null}}catch(e){return{data:null,error:e instanceof Gt?e:new Gt("Download failed",500,"STORAGE_ERROR")}}}getPublicUrl(t){return`${this.http.baseUrl}/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(t)}`}async list(t){try{const e={};return t?.prefix&&(e.prefix=t.prefix),t?.search&&(e.search=t.search),t?.limit&&(e.limit=t.limit.toString()),t?.offset&&(e.offset=t.offset.toString()),{data:await this.http.get(`/api/storage/buckets/${this.bucketName}/objects`,{params:e}),error:null}}catch(e){return{data:null,error:e instanceof Gt?e:new Gt("List failed",500,"STORAGE_ERROR")}}}async remove(t){try{return{data:await this.http.delete(`/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(t)}`),error:null}}catch(e){return{data:null,error:e instanceof Gt?e:new Gt("Delete failed",500,"STORAGE_ERROR")}}}},sI=class{constructor(t){this.http=t}from(t){return new rI(t,this.http)}},aI=class{constructor(t){this.http=t,this.chat=new oI(t),this.images=new uI(t),this.embeddings=new cI(t)}},oI=class{constructor(t){this.completions=new lI(t)}},lI=class{constructor(t){this.http=t}async create(t){const e={model:t.model,messages:t.messages,temperature:t.temperature,maxTokens:t.maxTokens,topP:t.topP,stream:t.stream,webSearch:t.webSearch,fileParser:t.fileParser,thinking:t.thinking,tools:t.tools,toolChoice:t.toolChoice,parallelToolCalls:t.parallelToolCalls};if(t.stream){const r=this.http.getHeaders();r["Content-Type"]="application/json";const s=await this.http.fetch(`${this.http.baseUrl}/api/ai/chat/completion`,{method:"POST",headers:r,body:JSON.stringify(e)});if(!s.ok){const o=await s.json();throw new Error(o.error||"Stream request failed")}return this.parseSSEStream(s,t.model)}const n=await this.http.post("/api/ai/chat/completion",e),i=n.text||"";return{id:`chatcmpl-${Date.now()}`,object:"chat.completion",created:Math.floor(Date.now()/1e3),model:n.metadata?.model,choices:[{index:0,message:{role:"assistant",content:i,...n.tool_calls?.length&&{tool_calls:n.tool_calls},...n.annotations?.length&&{annotations:n.annotations}},finish_reason:n.tool_calls?.length?"tool_calls":"stop"}],usage:n.metadata?.usage||{prompt_tokens:0,completion_tokens:0,total_tokens:0}}}async*parseSSEStream(t,e){const n=t.body.getReader(),i=new TextDecoder;let r="";try{for(;;){const{done:s,value:o}=await n.read();if(s)break;r+=i.decode(o,{stream:!0});const c=r.split(`
42
- `);r=c.pop()||"";for(const u of c)if(u.startsWith("data: ")){const f=u.slice(6).trim();if(f)try{const h=JSON.parse(f);if((h.chunk||h.content)&&(yield{id:`chatcmpl-${Date.now()}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:e,choices:[{index:0,delta:{content:h.chunk||h.content},finish_reason:null}]}),h.tool_calls?.length&&(yield{id:`chatcmpl-${Date.now()}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:e,choices:[{index:0,delta:{tool_calls:h.tool_calls},finish_reason:"tool_calls"}]}),h.done){n.releaseLock();return}}catch{console.warn("Failed to parse SSE data:",f)}}}}finally{n.releaseLock()}}},cI=class{constructor(t){this.http=t}async create(t){const e=await this.http.post("/api/ai/embeddings",t);return{object:e.object,data:e.data,model:e.metadata?.model,usage:e.metadata?.usage?{prompt_tokens:e.metadata.usage.promptTokens||0,total_tokens:e.metadata.usage.totalTokens||0}:{prompt_tokens:0,total_tokens:0}}}},uI=class{constructor(t){this.http=t}async generate(t){const e=await this.http.post("/api/ai/image/generation",t);let n=[];return e.images&&e.images.length>0?n=e.images.map(i=>({b64_json:i.imageUrl.replace(/^data:image\/\w+;base64,/,""),content:e.text})):e.text&&(n=[{content:e.text}]),{created:Math.floor(Date.now()/1e3),data:n,...e.metadata?.usage&&{usage:{total_tokens:e.metadata.usage.totalTokens||0,input_tokens:e.metadata.usage.promptTokens||0,output_tokens:e.metadata.usage.completionTokens||0}}}}},dI=class nT{constructor(e,n){this.http=e,this.functionsUrl=n||nT.deriveSubhostingUrl(e.baseUrl)}static deriveSubhostingUrl(e){try{const{hostname:n}=new URL(e);return n.endsWith(".insforge.app")?`https://${n.split(".")[0]}.functions.insforge.app`:void 0}catch{return}}async invoke(e,n={}){const{method:i="POST",body:r,headers:s={}}=n;if(this.functionsUrl)try{return{data:await this.http.request(i,`${this.functionsUrl}/${e}`,{body:r,headers:s}),error:null}}catch(o){if(o instanceof Error&&o.name==="AbortError")throw o;if(!(o instanceof Gt&&o.statusCode===404))return{data:null,error:o instanceof Gt?o:new Gt(o instanceof Error?o.message:"Function invocation failed",500,"FUNCTION_ERROR")}}try{const o=`/functions/${e}`;return{data:await this.http.request(i,o,{body:r,headers:s}),error:null}}catch(o){if(o instanceof Error&&o.name==="AbortError")throw o;return{data:null,error:o instanceof Gt?o:new Gt(o instanceof Error?o.message:"Function invocation failed",500,"FUNCTION_ERROR")}}}},LS=1e4,fI=class{constructor(t,e,n){this.socket=null,this.connectPromise=null,this.subscribedChannels=new Set,this.eventListeners=new Map,this.baseUrl=t,this.tokenManager=e,this.anonKey=n,this.tokenManager.onTokenChange=()=>this.onTokenChange()}notifyListeners(t,e){const n=this.eventListeners.get(t);if(n)for(const i of n)try{i(e)}catch(r){console.error(`Error in ${t} callback:`,r)}}connect(){return this.socket?.connected?Promise.resolve():this.connectPromise?this.connectPromise:(this.connectPromise=new Promise((t,e)=>{const n=this.tokenManager.getAccessToken()??this.anonKey;this.socket=Cf(this.baseUrl,{transports:["websocket"],auth:n?{token:n}:void 0});let i=!0,r=null;const s=()=>{r&&(clearTimeout(r),r=null)};r=setTimeout(()=>{i&&(i=!1,this.connectPromise=null,this.socket?.disconnect(),this.socket=null,e(new Error(`Connection timeout after ${LS}ms`)))},LS),this.socket.on("connect",()=>{s();for(const o of this.subscribedChannels)this.socket.emit("realtime:subscribe",{channel:o});this.notifyListeners("connect"),i&&(i=!1,this.connectPromise=null,t())}),this.socket.on("connect_error",o=>{s(),this.notifyListeners("connect_error",o),i&&(i=!1,this.connectPromise=null,e(o))}),this.socket.on("disconnect",o=>{this.notifyListeners("disconnect",o)}),this.socket.on("realtime:error",o=>{this.notifyListeners("error",o)}),this.socket.onAny((o,c)=>{o!=="realtime:error"&&this.notifyListeners(o,c)})}),this.connectPromise)}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null),this.subscribedChannels.clear()}onTokenChange(){const t=this.tokenManager.getAccessToken()??this.anonKey;this.socket&&(this.socket.auth=t?{token:t}:{}),this.socket&&(this.socket.connected||this.connectPromise)&&(this.socket.disconnect(),this.socket.connect())}get isConnected(){return this.socket?.connected??!1}get connectionState(){return this.socket?this.socket.connected?"connected":"connecting":"disconnected"}get socketId(){return this.socket?.id}async subscribe(t){if(this.subscribedChannels.has(t))return{ok:!0,channel:t};if(!this.socket?.connected)try{await this.connect()}catch(e){const n=e instanceof Error?e.message:"Connection failed";return{ok:!1,channel:t,error:{code:"CONNECTION_FAILED",message:n}}}return new Promise(e=>{this.socket.emit("realtime:subscribe",{channel:t},n=>{n.ok&&this.subscribedChannels.add(t),e(n)})})}unsubscribe(t){this.subscribedChannels.delete(t),this.socket?.connected&&this.socket.emit("realtime:unsubscribe",{channel:t})}async publish(t,e,n){if(!this.socket?.connected)throw new Error("Not connected to realtime server. Call connect() first.");this.socket.emit("realtime:publish",{channel:t,event:e,payload:n})}on(t,e){this.eventListeners.has(t)||this.eventListeners.set(t,new Set),this.eventListeners.get(t).add(e)}off(t,e){const n=this.eventListeners.get(t);n&&(n.delete(e),n.size===0&&this.eventListeners.delete(t))}once(t,e){const n=i=>{this.off(t,n),e(i)};this.on(t,n)}getSubscribedChannels(){return Array.from(this.subscribedChannels)}},hI=class{constructor(t){this.http=t}async send(t){try{return{data:await this.http.post("/api/email/send-raw",t),error:null}}catch(e){if(e instanceof Error&&e.name==="AbortError")throw e;return{data:null,error:e instanceof Gt?e:new Gt(e instanceof Error?e.message:"Email send failed",500,"EMAIL_ERROR")}}}},pI=class{constructor(t={}){const e=new KM(t.debug);this.tokenManager=new eT,this.http=new KN(t,this.tokenManager,e),t.edgeFunctionToken&&(this.http.setAuthToken(t.edgeFunctionToken),this.tokenManager.setAccessToken(t.edgeFunctionToken)),this.auth=new tI(this.http,this.tokenManager,{isServerMode:t.isServerMode??!1}),this.database=new iI(this.http,this.tokenManager),this.storage=new sI(this.http),this.ai=new aI(this.http),this.functions=new dI(this.http,t.functionsUrl),this.realtime=new fI(this.http.baseUrl,this.tokenManager,t.anonKey),this.emails=new hI(this.http)}getHttpClient(){return this.http}};function mI(t){return new pI(t)}const sy={VITE_INSFORGE_ANON_KEY:"ik_68e892cf2095c194c6a3e35d1960bc84",VITE_INSFORGE_BASE_URL:"https://b46ug8xu.us-east.insforge.app"};function Co(){const t=typeof import.meta<"u"?sy:void 0;return(t?.VITE_INSFORGE_BASE_URL||t?.VITE_TOKENTRACKER_BACKEND_BASE_URL||"").trim()}function iT(){if(typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"))return window.location.origin;const e=typeof import.meta<"u"?sy:void 0;return(e?.VITE_INSFORGE_BASE_URL||e?.VITE_TOKENTRACKER_BACKEND_BASE_URL||"").trim()}function Ph(){const t=typeof import.meta<"u"?sy:void 0;return(t?.VITE_INSFORGE_ANON_KEY||t?.VITE_TOKENTRACKER_BACKEND_ANON_KEY||"").trim()}function l0(){return!!iT()}let Im=null;function gI(){return l0()?(Im||(Im=mI({baseUrl:iT(),anonKey:Ph()||void 0,autoRefreshToken:!0})),Im):null}const rT="tokentracker_cloud_sync_enabled",ay="tokentracker_cloud_device_session_v1",oy="tokentracker_cloud_last_sync_ts";function sT(){if(typeof window>"u")return!1;const t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"}function aT(){try{const t=localStorage.getItem(rT);return t===null||t===""?!1:t==="1"||t==="true"}catch{return!1}}function vI(t){try{localStorage.setItem(rT,t?"1":"0")}catch{}}function oT(){try{const t=localStorage.getItem(ay);if(!t)return null;const e=JSON.parse(t);if(typeof e?.token=="string"&&e.token&&typeof e.deviceId=="string")return e}catch{}return null}function lT(t){try{localStorage.setItem(ay,JSON.stringify(t))}catch{}}function yI(){try{localStorage.removeItem(ay),localStorage.removeItem(oy)}catch{}}function _I(){try{const t=Number(localStorage.getItem(oy));return Number.isFinite(t)?t:0}catch{return 0}}function cT(t){try{localStorage.setItem(oy,String(t))}catch{}}function ro(t){if(typeof t!="string")return null;const e=t.trim();return e.length>0?e:null}function xI(t){const e=ro(t);if(!e)return null;const n=e.split(".");if(n.length<2)return null;const i=n[1];try{const r=i.replace(/-/g,"+").replace(/_/g,"/").padEnd(i.length+(4-i.length%4)%4,"="),s=typeof atob=="function"?atob(r):Buffer.from(r,"base64").toString("utf8"),c=JSON.parse(s)?.exp;return typeof c!="number"||!Number.isFinite(c)||c<=0?null:Math.floor(c*1e3)}catch{return null}}function bI(t,e=3e4){const n=xI(t);return n?n<=Date.now()+Math.max(0,Number(e)||0):!1}async function SI(t){if(!t)return null;if(typeof t=="string")return ro(t);if(typeof t=="function")try{const e=await t();return ro(e)}catch{return null}if(typeof t=="object"){if(typeof t.getAccessToken=="function"){try{const e=await t.getAccessToken(),n=ro(e);if(n)return n}catch{}return ro(t.accessToken)}return null}return ro(t)}async function Hd(t,e={}){const n=Math.max(1,Math.min(12,Math.floor(Number(e.maxAttempts)||8))),i=Math.max(20,Math.floor(Number(e.baseDelayMs)||50));for(let r=0;r<n;r++){const s=await SI(t);if(s)return s;r<n-1&&await new Promise(o=>setTimeout(o,i*(r+1)))}return null}function a$(t){return typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1")||typeof t=="function"||t&&typeof t=="object"&&typeof t.getAccessToken=="function"?!0:!!ro(t)}const uT=k.createContext(null);function DS(t){if(!t||typeof t!="object")return null;const e=t,n=e.session&&typeof e.session=="object"?e.session:null,i=typeof e.accessToken=="string"&&e.accessToken||typeof e.access_token=="string"&&e.access_token||n&&typeof n.accessToken=="string"&&n.accessToken||n&&typeof n.access_token=="string"&&n.access_token||null;return i&&i.length>0?i:null}async function wI(t,e={}){if(!t)return null;const n=Math.max(0,Math.floor(Number(e.skewMs)||6e4)),i=t.tokenManager,r=()=>i?.getAccessToken?.()??i?.getSession?.()?.accessToken??null;let s=r();if(!s||bI(s,n)){const{data:o}=await t.auth.refreshSession();if(s=r()??DS(o)??null,!s&&typeof t.auth.getCurrentUser=="function")try{await t.auth.getCurrentUser(),s=r()??DS(o)??null}catch{}}return s||null}function EI({children:t}){const[e,n]=k.useState(null),[i,r]=k.useState(null),[s,o]=k.useState(!0);k.useEffect(()=>{if(!l0()){n(null),r(null),o(!1);return}n(gI())},[]),k.useEffect(()=>{if(!e)return;let w=!0;return o(!0),(async()=>{try{let{data:y,error:x}=await e.auth.getCurrentUser();if(!w)return;if(!x&&!y?.user){if(await new Promise(A=>setTimeout(A,150)),!w)return;const M=await e.auth.getCurrentUser();y=M.data,x=M.error}if(x){r(null);return}r(y?.user??null)}catch{w&&r(null)}finally{w&&o(!1)}})(),()=>{w=!1}},[e]);const c=k.useCallback(async()=>{if(e)try{let{data:w,error:y}=await e.auth.getCurrentUser();if(!y&&!w?.user){await new Promise(M=>setTimeout(M,150));const x=await e.auth.getCurrentUser();w=x.data,y=x.error}if(y){r(null);return}r(w?.user??null)}catch{r(null)}},[e]),u=k.useCallback(async(w,y)=>{if(!e)return{error:new Error("InsForge client not configured")};const x=typeof window<"u"&&window.webkit?.messageHandlers?.nativeOAuth;if(x){const T=typeof y=="string"&&y.trim()?y.trim():`${window.location.origin}/auth/callback`,D=await e.auth.signInWithOAuth({provider:w,redirectTo:T,skipBrowserRedirect:!0});if(D.data?.url){try{await fetch("/api/auth-bridge/verifier",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({native:!0})})}catch{}x.postMessage(D.data.url)}return D}const M=typeof y=="string"&&y.trim()?y.trim():typeof window<"u"?`${window.location.origin}/dashboard`:void 0;return await e.auth.signInWithOAuth({provider:w,redirectTo:M})},[e]),f=k.useCallback(async w=>{if(!e)return{data:null,error:new Error("InsForge client not configured")};const{data:y,error:x}=await e.auth.signInWithPassword(w);return y?.user&&r(y.user),{data:y,error:x}},[e]),h=k.useCallback(async w=>{if(!e)return{data:null,error:new Error("InsForge client not configured")};const{data:y,error:x}=await e.auth.signUp(w);return y?.user&&y?.accessToken&&r(y.user),{data:y,error:x}},[e]),p=k.useCallback(async()=>e?e.auth.getPublicAuthConfig():{data:null,error:new Error("InsForge client not configured")},[e]),m=k.useCallback(async()=>{e&&(await e.auth.signOut(),yI(),r(null))},[e]),v=k.useCallback(async()=>wI(e),[e]),_=k.useMemo(()=>!l0()||!e?{enabled:!1,client:null,user:null,signedIn:!1,loading:!1,refreshUser:async()=>{},signInWithOAuth:async()=>({error:new Error("InsForge not configured")}),signInWithPassword:async()=>({data:null,error:new Error("InsForge not configured")}),signUp:async()=>({data:null,error:new Error("InsForge not configured")}),getPublicAuthConfig:async()=>({data:null,error:new Error("InsForge not configured")}),signOut:async()=>{},getAccessToken:async()=>null}:{enabled:!0,client:e,user:i,signedIn:!!i,loading:s,refreshUser:c,signInWithOAuth:u,signInWithPassword:f,signUp:h,getPublicAuthConfig:p,signOut:m,getAccessToken:v},[e,i,s,c,u,f,h,p,m,v]);return O.jsx(uT.Provider,{value:_,children:t})}function Ro(){return k.useContext(uT)}const MI="modulepreload",TI=function(t){return"/"+t},NS={},ly=function(e,n,i){let r=Promise.resolve();if(n&&n.length>0){let u=function(f){return Promise.all(f.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),c=o?.nonce||o?.getAttribute("nonce");r=u(n.map(f=>{if(f=TI(f),f in NS)return;NS[f]=!0;const h=f.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${p}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":MI,h||(m.as="script"),m.crossOrigin="",m.href=f,c&&m.setAttribute("nonce",c),document.head.appendChild(m),h)return new Promise((v,_)=>{m.addEventListener("load",v),m.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${f}`)))})}))}function s(o){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=o,window.dispatchEvent(c),!c.defaultPrevented)throw o}return r.then(o=>{for(const c of o||[])c.status==="rejected"&&s(c.reason);return e().catch(s)})};var nh={},AI=()=>{window.va||(window.va=function(...e){window.vaq||(window.vaq=[]),window.vaq.push(e)})},CI="@vercel/analytics",RI="2.0.1";function dT(){return typeof window<"u"}function fT(){try{const t="production"}catch{}return"production"}function PI(t="auto"){if(t==="auto"){window.vam=fT();return}window.vam=t}function kI(){return(dT()?window.vam:fT())||"production"}function cy(){return kI()==="development"}function LI(t){return t.scriptSrc?Tl(t.scriptSrc):cy()?"https://va.vercel-scripts.com/v1/script.debug.js":t.basePath?Tl(`${t.basePath}/insights/script.js`):"/_vercel/insights/script.js"}function DI(t,e){var n;let i=t;if(e)try{i={...(n=JSON.parse(e))==null?void 0:n.analytics,...t}}catch{}PI(i.mode);const r={sdkn:CI+(i.framework?`/${i.framework}`:""),sdkv:RI};return i.disableAutoTrack&&(r.disableAutoTrack="1"),i.viewEndpoint&&(r.viewEndpoint=Tl(i.viewEndpoint)),i.eventEndpoint&&(r.eventEndpoint=Tl(i.eventEndpoint)),i.sessionEndpoint&&(r.sessionEndpoint=Tl(i.sessionEndpoint)),cy()&&i.debug===!1&&(r.debug="false"),i.dsn&&(r.dsn=i.dsn),i.endpoint?r.endpoint=i.endpoint:i.basePath&&(r.endpoint=Tl(`${i.basePath}/insights`)),{beforeSend:i.beforeSend,src:LI(i),dataset:r}}function Tl(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")?t:`/${t}`}function NI(t={debug:!0},e){var n;if(!dT())return;const{beforeSend:i,src:r,dataset:s}=DI(t,e);if(AI(),i&&((n=window.va)==null||n.call(window,"beforeSend",i)),document.head.querySelector(`script[src*="${r}"]`))return;const o=document.createElement("script");o.src=r;for(const[c,u]of Object.entries(s))o.dataset[c]=u;o.defer=!0,o.onerror=()=>{const c=cy()?"Please check if any ad blockers are enabled and try again.":"Be sure to enable Web Analytics for your project and deploy again. See https://vercel.com/docs/analytics/quickstart for more information.";console.log(`[Vercel Web Analytics] Failed to load script from ${r}. ${c}`)},document.head.appendChild(o)}function II({route:t,path:e}){var n;(n=window.va)==null||n.call(window,"pageview",{route:t,path:e})}function UI(){if(!(typeof process>"u"||typeof nh>"u"))return nh.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH}function FI(){if(!(typeof process>"u"||typeof nh>"u"))return nh.REACT_APP_VERCEL_OBSERVABILITY_CLIENT_CONFIG}function OI(t){return k.useEffect(()=>{var e;t.beforeSend&&((e=window.va)==null||e.call(window,"beforeSend",t.beforeSend))},[t.beforeSend]),k.useEffect(()=>{NI({framework:t.framework||"react",basePath:t.basePath??UI(),...t.route!==void 0&&{disableAutoTrack:!0},...t},t.configString??FI())},[]),k.useEffect(()=>{t.route&&t.path&&II({route:t.route,path:t.path})},[t.route,t.path]),null}var ih={},BI=()=>{window.si||(window.si=function(...e){window.siq=window.siq||[],window.siq.push(e)})},zI="@vercel/speed-insights",VI="2.0.0";function HI(){return typeof window<"u"}function GI(){try{const t="production"}catch{}return"production"}function hT(){return GI()==="development"}function jI(t){return t.scriptSrc?rh(t.scriptSrc):hT()?"https://va.vercel-scripts.com/v1/speed-insights/script.debug.js":t.dsn?"https://va.vercel-scripts.com/v1/speed-insights/script.js":t.basePath?rh(`${t.basePath}/speed-insights/script.js`):"/_vercel/speed-insights/script.js"}function WI(t,e){var n;let i=t;if(e)try{i={...(n=JSON.parse(e))==null?void 0:n.speedInsights,...t}}catch{}const r={sdkn:zI+(i.framework?`/${i.framework}`:""),sdkv:VI};return i.sampleRate&&(r.sampleRate=i.sampleRate.toString()),i.route&&(r.route=i.route),hT()&&i.debug===!1&&(r.debug="false"),i.dsn&&(r.dsn=i.dsn),i.endpoint?r.endpoint=rh(i.endpoint):i.basePath&&(r.endpoint=rh(`${i.basePath}/speed-insights/vitals`)),{src:jI(i),beforeSend:i.beforeSend,dataset:r}}function rh(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")?t:`/${t}`}function $I(t={},e){var n;if(!HI()||t.route===null)return null;BI();const{beforeSend:i,src:r,dataset:s}=WI(t,e);if(document.head.querySelector(`script[src*="${r}"]`))return null;i&&((n=window.si)==null||n.call(window,"beforeSend",i));const o=document.createElement("script");o.src=r,o.defer=!0;for(const[c,u]of Object.entries(s))o.dataset[c]=u;return o.onerror=()=>{console.log(`[Vercel Speed Insights] Failed to load script from ${r}. Please check if any content blockers are enabled and try again.`)},document.head.appendChild(o),{setRoute:c=>{o.dataset.route=c??void 0}}}function XI(){if(!(typeof process>"u"||typeof ih>"u"))return ih.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH}function qI(){if(!(typeof process>"u"||typeof ih>"u"))return ih.REACT_APP_VERCEL_OBSERVABILITY_CLIENT_CONFIG}function YI(t){k.useEffect(()=>{var n;t.beforeSend&&((n=window.si)==null||n.call(window,"beforeSend",t.beforeSend))},[t.beforeSend]);const e=k.useRef(null);return k.useEffect(()=>{if(!e.current){const n=$I({framework:t.framework??"react",basePath:t.basePath??XI(),...t},t.configString??qI());n&&(e.current=n.setRoute)}},[t]),k.useEffect(()=>{e.current&&t.route&&e.current(t.route)},[t.route]),null}function kh(){return typeof window<"u"}function uy(t){return pT(t)?(t.nodeName||"").toLowerCase():"#document"}function Xl(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function KI(t){var e;return(e=(pT(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function pT(t){return kh()?t instanceof Node||t instanceof Xl(t).Node:!1}function mT(t){return kh()?t instanceof Element||t instanceof Xl(t).Element:!1}function dy(t){return kh()?t instanceof HTMLElement||t instanceof Xl(t).HTMLElement:!1}function IS(t){return!kh()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Xl(t).ShadowRoot}function gT(t){const{overflow:e,overflowX:n,overflowY:i,display:r}=yT(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&r!=="inline"&&r!=="contents"}function o$(t){return/^(table|td|th)$/.test(uy(t))}function ZI(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const JI=/transform|translate|scale|rotate|perspective|filter/,QI=/paint|layout|strict|content/,Xa=t=>!!t&&t!=="none";let Um;function eU(t){const e=mT(t)?yT(t):t;return Xa(e.transform)||Xa(e.translate)||Xa(e.scale)||Xa(e.rotate)||Xa(e.perspective)||!tU()&&(Xa(e.backdropFilter)||Xa(e.filter))||JI.test(e.willChange||"")||QI.test(e.contain||"")}function l$(t){let e=c0(t);for(;dy(e)&&!vT(e);){if(eU(e))return e;if(ZI(e))return null;e=c0(e)}return null}function tU(){return Um==null&&(Um=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Um}function vT(t){return/^(html|body|#document)$/.test(uy(t))}function yT(t){return Xl(t).getComputedStyle(t)}function c$(t){return mT(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function c0(t){if(uy(t)==="html")return t;const e=t.assignedSlot||t.parentNode||IS(t)&&t.host||KI(t);return IS(e)?e.host:e}function _T(t){const e=c0(t);return vT(e)?t.ownerDocument?t.ownerDocument.body:t.body:dy(e)&&gT(e)?e:_T(e)}function US(t,e,n){var i;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=_T(t),s=r===((i=t.ownerDocument)==null?void 0:i.body),o=Xl(r);if(s){const c=nU(o);return e.concat(o,o.visualViewport||[],gT(r)?r:[],c&&n?US(c):[])}else return e.concat(r,US(r,[],n))}function nU(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}const FS={};function fy(t,e){const n=k.useRef(FS);return n.current===FS&&(n.current=t(e)),n}const Fm=N1[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],iU=Fm&&Fm!==k.useLayoutEffect?Fm:t=>t();function OS(t){const e=fy(rU).current;return e.next=t,iU(e.effect),e.trampoline}function rU(){const t={next:void 0,callback:sU,trampoline:(...e)=>t.callback?.(...e),effect:()=>{t.callback=t.next}};return t}function sU(){}const aU=()=>{},oU=typeof document<"u"?k.useLayoutEffect:aU;function u0(t,e){if(t&&!e)return t;if(!t&&e)return e;if(t||e)return{...t,...e}}const nu={};function xT(t,e,n,i,r){let s={...d0(t,nu)};return e&&(s=Rf(s,e)),n&&(s=Rf(s,n)),i&&(s=Rf(s,i)),s}function lU(t){if(t.length===0)return nu;if(t.length===1)return d0(t[0],nu);let e={...d0(t[0],nu)};for(let n=1;n<t.length;n+=1)e=Rf(e,t[n]);return e}function Rf(t,e){return bT(e)?e(t):cU(t,e)}function cU(t,e){if(!e)return t;for(const n in e){const i=e[n];switch(n){case"style":{t[n]=u0(t.style,i);break}case"className":{t[n]=ST(t.className,i);break}default:uU(n,i)?t[n]=dU(t[n],i):t[n]=i}}return t}function uU(t,e){const n=t.charCodeAt(0),i=t.charCodeAt(1),r=t.charCodeAt(2);return n===111&&i===110&&r>=65&&r<=90&&(typeof e=="function"||typeof e>"u")}function bT(t){return typeof t=="function"}function d0(t,e){return bT(t)?t(e):t??nu}function dU(t,e){return e?t?n=>{if(fU(n)){const r=n;f0(r);const s=e(r);return r.baseUIHandlerPrevented||t?.(r),s}const i=e(n);return t?.(n),i}:e:t}function f0(t){return t.preventBaseUIHandler=()=>{t.baseUIHandlerPrevented=!0},t}function ST(t,e){return e?t?e+" "+t:e:t}function fU(t){return t!=null&&typeof t=="object"&&"nativeEvent"in t}function wT(t,...e){const n=new URL("https://base-ui.com/production-error");return n.searchParams.set("code",t.toString()),e.forEach(i=>n.searchParams.append("args[]",i)),`Base UI error #${t}; visit ${n} for the full message.`}const hU=k.createContext(void 0);function pU(t=!1){const e=k.useContext(hU);if(e===void 0&&!t)throw new Error(wT(16));return e}function mU(t){const{focusableWhenDisabled:e,disabled:n,composite:i=!1,tabIndex:r=0,isNativeButton:s}=t,o=i&&e!==!1,c=i&&e===!1;return{props:k.useMemo(()=>{const f={onKeyDown(h){n&&e&&h.key!=="Tab"&&h.preventDefault()}};return i||(f.tabIndex=r,!s&&n&&(f.tabIndex=e?r:-1)),(s&&(e||o)||!s&&n)&&(f["aria-disabled"]=n),s&&(!e||c)&&(f.disabled=n),f},[i,n,e,o,c,s,r])}}function gU(t={}){const{disabled:e=!1,focusableWhenDisabled:n,tabIndex:i=0,native:r=!0}=t,s=k.useRef(null),o=pU(!0)!==void 0,c=OS(()=>{const m=s.current;return!!(m?.tagName==="A"&&m?.href)}),{props:u}=mU({focusableWhenDisabled:n,disabled:e,composite:o,tabIndex:i,isNativeButton:r}),f=k.useCallback(()=>{const m=s.current;vU(m)&&o&&e&&u.disabled===void 0&&m.disabled&&(m.disabled=!1)},[e,u.disabled,o]);oU(f,[f]);const h=k.useCallback((m={})=>{const{onClick:v,onMouseDown:_,onKeyUp:w,onKeyDown:y,onPointerDown:x,...M}=m;return xT({type:r?"button":void 0,onClick(T){if(e){T.preventDefault();return}v?.(T)},onMouseDown(T){e||_?.(T)},onKeyDown(T){if(e||(f0(T),y?.(T)),T.baseUIHandlerPrevented)return;const D=T.target===T.currentTarget&&!r&&!c()&&!e,I=T.key==="Enter",U=T.key===" ";D&&((U||I)&&T.preventDefault(),I&&v?.(T))},onKeyUp(T){e||(f0(T),w?.(T)),!T.baseUIHandlerPrevented&&T.target===T.currentTarget&&!r&&!e&&T.key===" "&&v?.(T)},onPointerDown(T){if(e){T.preventDefault();return}x?.(T)}},r?void 0:{role:"button"},u,M)},[e,u,r,c]),p=OS(m=>{s.current=m,f()});return{getButtonProps:h,buttonRef:p}}function vU(t){return dy(t)&&t.tagName==="BUTTON"}function BS(t,e,n,i){const r=fy(ET).current;return _U(r,t,e,n,i)&&MT(r,[t,e,n,i]),r.callback}function yU(t){const e=fy(ET).current;return xU(e,t)&&MT(e,t),e.callback}function ET(){return{callback:null,cleanup:null,refs:[]}}function _U(t,e,n,i,r){return t.refs[0]!==e||t.refs[1]!==n||t.refs[2]!==i||t.refs[3]!==r}function xU(t,e){return t.refs.length!==e.length||t.refs.some((n,i)=>n!==e[i])}function MT(t,e){if(t.refs=e,e.every(n=>n==null)){t.callback=null;return}t.callback=n=>{if(t.cleanup&&(t.cleanup(),t.cleanup=null),n!=null){const i=Array(e.length).fill(null);for(let r=0;r<e.length;r+=1){const s=e[r];if(s!=null)switch(typeof s){case"function":{const o=s(n);typeof o=="function"&&(i[r]=o);break}case"object":{s.current=n;break}}}t.cleanup=()=>{for(let r=0;r<e.length;r+=1){const s=e[r];if(s!=null)switch(typeof s){case"function":{const o=i[r];typeof o=="function"?o():s(null);break}case"object":{s.current=null;break}}}}}}}const bU=parseInt(k.version,10);function SU(t){return bU>=t}function zS(t){if(!k.isValidElement(t))return null;const e=t,n=e.props;return(SU(19)?n?.ref:e.ref)??null}function wU(t,e){const n={};for(const i in t){const r=t[i];if(e?.hasOwnProperty(i)){const s=e[i](r);s!=null&&Object.assign(n,s);continue}r===!0?n[`data-${i.toLowerCase()}`]="":r&&(n[`data-${i.toLowerCase()}`]=r.toString())}return n}function EU(t,e){return typeof t=="function"?t(e):t}function MU(t,e){return typeof t=="function"?t(e):t}function u$(){}const Sl=Object.freeze({});function TU(t,e,n={}){const i=e.render,r=AU(e,n);if(n.enabled===!1)return null;const s=n.state??Sl;return CU(t,i,r,s)}function AU(t,e={}){const{className:n,style:i,render:r}=t,{state:s=Sl,ref:o,props:c,stateAttributesMapping:u,enabled:f=!0}=e,h=f?EU(n,s):void 0,p=f?MU(i,s):void 0,m=f?wU(s,u):Sl,v=f?u0(m,Array.isArray(c)?lU(c):c)??Sl:Sl;return typeof document<"u"&&(f?Array.isArray(o)?v.ref=yU([v.ref,zS(r),...o]):v.ref=BS(v.ref,zS(r),o):BS(null,null)),f?(h!==void 0&&(v.className=ST(v.className,h)),p!==void 0&&(v.style=u0(v.style,p)),v):Sl}function CU(t,e,n,i){if(e){if(typeof e=="function")return e(n,i);const r=xT(n,e.props);return r.ref=n.ref,k.cloneElement(e,r)}if(t&&typeof t=="string")return RU(t,n);throw new Error(wT(8))}function RU(t,e){return t==="button"?k.createElement("button",{type:"button",...e,key:e.key}):t==="img"?k.createElement("img",{alt:"",...e,key:e.key}):k.createElement(t,e)}const PU=k.forwardRef(function(e,n){const{render:i,className:r,disabled:s=!1,focusableWhenDisabled:o=!1,nativeButton:c=!0,...u}=e,{getButtonProps:f,buttonRef:h}=gU({disabled:s,focusableWhenDisabled:o,native:c}),p=k.useMemo(()=>({disabled:s}),[s]);return TU("button",e,{state:p,ref:[n,h],props:[u,f]})}),kU=`key,module,page,component,slot,text,notes,status
42
+ `);r=c.pop()||"";for(const u of c)if(u.startsWith("data: ")){const f=u.slice(6).trim();if(f)try{const h=JSON.parse(f);if((h.chunk||h.content)&&(yield{id:`chatcmpl-${Date.now()}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:e,choices:[{index:0,delta:{content:h.chunk||h.content},finish_reason:null}]}),h.tool_calls?.length&&(yield{id:`chatcmpl-${Date.now()}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:e,choices:[{index:0,delta:{tool_calls:h.tool_calls},finish_reason:"tool_calls"}]}),h.done){n.releaseLock();return}}catch{console.warn("Failed to parse SSE data:",f)}}}}finally{n.releaseLock()}}},cI=class{constructor(t){this.http=t}async create(t){const e=await this.http.post("/api/ai/embeddings",t);return{object:e.object,data:e.data,model:e.metadata?.model,usage:e.metadata?.usage?{prompt_tokens:e.metadata.usage.promptTokens||0,total_tokens:e.metadata.usage.totalTokens||0}:{prompt_tokens:0,total_tokens:0}}}},uI=class{constructor(t){this.http=t}async generate(t){const e=await this.http.post("/api/ai/image/generation",t);let n=[];return e.images&&e.images.length>0?n=e.images.map(i=>({b64_json:i.imageUrl.replace(/^data:image\/\w+;base64,/,""),content:e.text})):e.text&&(n=[{content:e.text}]),{created:Math.floor(Date.now()/1e3),data:n,...e.metadata?.usage&&{usage:{total_tokens:e.metadata.usage.totalTokens||0,input_tokens:e.metadata.usage.promptTokens||0,output_tokens:e.metadata.usage.completionTokens||0}}}}},dI=class nT{constructor(e,n){this.http=e,this.functionsUrl=n||nT.deriveSubhostingUrl(e.baseUrl)}static deriveSubhostingUrl(e){try{const{hostname:n}=new URL(e);return n.endsWith(".insforge.app")?`https://${n.split(".")[0]}.functions.insforge.app`:void 0}catch{return}}async invoke(e,n={}){const{method:i="POST",body:r,headers:s={}}=n;if(this.functionsUrl)try{return{data:await this.http.request(i,`${this.functionsUrl}/${e}`,{body:r,headers:s}),error:null}}catch(o){if(o instanceof Error&&o.name==="AbortError")throw o;if(!(o instanceof Gt&&o.statusCode===404))return{data:null,error:o instanceof Gt?o:new Gt(o instanceof Error?o.message:"Function invocation failed",500,"FUNCTION_ERROR")}}try{const o=`/functions/${e}`;return{data:await this.http.request(i,o,{body:r,headers:s}),error:null}}catch(o){if(o instanceof Error&&o.name==="AbortError")throw o;return{data:null,error:o instanceof Gt?o:new Gt(o instanceof Error?o.message:"Function invocation failed",500,"FUNCTION_ERROR")}}}},LS=1e4,fI=class{constructor(t,e,n){this.socket=null,this.connectPromise=null,this.subscribedChannels=new Set,this.eventListeners=new Map,this.baseUrl=t,this.tokenManager=e,this.anonKey=n,this.tokenManager.onTokenChange=()=>this.onTokenChange()}notifyListeners(t,e){const n=this.eventListeners.get(t);if(n)for(const i of n)try{i(e)}catch(r){console.error(`Error in ${t} callback:`,r)}}connect(){return this.socket?.connected?Promise.resolve():this.connectPromise?this.connectPromise:(this.connectPromise=new Promise((t,e)=>{const n=this.tokenManager.getAccessToken()??this.anonKey;this.socket=Cf(this.baseUrl,{transports:["websocket"],auth:n?{token:n}:void 0});let i=!0,r=null;const s=()=>{r&&(clearTimeout(r),r=null)};r=setTimeout(()=>{i&&(i=!1,this.connectPromise=null,this.socket?.disconnect(),this.socket=null,e(new Error(`Connection timeout after ${LS}ms`)))},LS),this.socket.on("connect",()=>{s();for(const o of this.subscribedChannels)this.socket.emit("realtime:subscribe",{channel:o});this.notifyListeners("connect"),i&&(i=!1,this.connectPromise=null,t())}),this.socket.on("connect_error",o=>{s(),this.notifyListeners("connect_error",o),i&&(i=!1,this.connectPromise=null,e(o))}),this.socket.on("disconnect",o=>{this.notifyListeners("disconnect",o)}),this.socket.on("realtime:error",o=>{this.notifyListeners("error",o)}),this.socket.onAny((o,c)=>{o!=="realtime:error"&&this.notifyListeners(o,c)})}),this.connectPromise)}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null),this.subscribedChannels.clear()}onTokenChange(){const t=this.tokenManager.getAccessToken()??this.anonKey;this.socket&&(this.socket.auth=t?{token:t}:{}),this.socket&&(this.socket.connected||this.connectPromise)&&(this.socket.disconnect(),this.socket.connect())}get isConnected(){return this.socket?.connected??!1}get connectionState(){return this.socket?this.socket.connected?"connected":"connecting":"disconnected"}get socketId(){return this.socket?.id}async subscribe(t){if(this.subscribedChannels.has(t))return{ok:!0,channel:t};if(!this.socket?.connected)try{await this.connect()}catch(e){const n=e instanceof Error?e.message:"Connection failed";return{ok:!1,channel:t,error:{code:"CONNECTION_FAILED",message:n}}}return new Promise(e=>{this.socket.emit("realtime:subscribe",{channel:t},n=>{n.ok&&this.subscribedChannels.add(t),e(n)})})}unsubscribe(t){this.subscribedChannels.delete(t),this.socket?.connected&&this.socket.emit("realtime:unsubscribe",{channel:t})}async publish(t,e,n){if(!this.socket?.connected)throw new Error("Not connected to realtime server. Call connect() first.");this.socket.emit("realtime:publish",{channel:t,event:e,payload:n})}on(t,e){this.eventListeners.has(t)||this.eventListeners.set(t,new Set),this.eventListeners.get(t).add(e)}off(t,e){const n=this.eventListeners.get(t);n&&(n.delete(e),n.size===0&&this.eventListeners.delete(t))}once(t,e){const n=i=>{this.off(t,n),e(i)};this.on(t,n)}getSubscribedChannels(){return Array.from(this.subscribedChannels)}},hI=class{constructor(t){this.http=t}async send(t){try{return{data:await this.http.post("/api/email/send-raw",t),error:null}}catch(e){if(e instanceof Error&&e.name==="AbortError")throw e;return{data:null,error:e instanceof Gt?e:new Gt(e instanceof Error?e.message:"Email send failed",500,"EMAIL_ERROR")}}}},pI=class{constructor(t={}){const e=new KM(t.debug);this.tokenManager=new eT,this.http=new KN(t,this.tokenManager,e),t.edgeFunctionToken&&(this.http.setAuthToken(t.edgeFunctionToken),this.tokenManager.setAccessToken(t.edgeFunctionToken)),this.auth=new tI(this.http,this.tokenManager,{isServerMode:t.isServerMode??!1}),this.database=new iI(this.http,this.tokenManager),this.storage=new sI(this.http),this.ai=new aI(this.http),this.functions=new dI(this.http,t.functionsUrl),this.realtime=new fI(this.http.baseUrl,this.tokenManager,t.anonKey),this.emails=new hI(this.http)}getHttpClient(){return this.http}};function mI(t){return new pI(t)}const sy={};function Co(){const t=typeof import.meta<"u"?sy:void 0;return(t?.VITE_INSFORGE_BASE_URL||t?.VITE_TOKENTRACKER_BACKEND_BASE_URL||"").trim()}function iT(){if(typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"))return window.location.origin;const e=typeof import.meta<"u"?sy:void 0;return(e?.VITE_INSFORGE_BASE_URL||e?.VITE_TOKENTRACKER_BACKEND_BASE_URL||"").trim()}function Ph(){const t=typeof import.meta<"u"?sy:void 0;return(t?.VITE_INSFORGE_ANON_KEY||t?.VITE_TOKENTRACKER_BACKEND_ANON_KEY||"").trim()}function l0(){return!!iT()}let Im=null;function gI(){return l0()?(Im||(Im=mI({baseUrl:iT(),anonKey:Ph()||void 0,autoRefreshToken:!0})),Im):null}const rT="tokentracker_cloud_sync_enabled",ay="tokentracker_cloud_device_session_v1",oy="tokentracker_cloud_last_sync_ts";function sT(){if(typeof window>"u")return!1;const t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"}function aT(){try{const t=localStorage.getItem(rT);return t===null||t===""?!1:t==="1"||t==="true"}catch{return!1}}function vI(t){try{localStorage.setItem(rT,t?"1":"0")}catch{}}function oT(){try{const t=localStorage.getItem(ay);if(!t)return null;const e=JSON.parse(t);if(typeof e?.token=="string"&&e.token&&typeof e.deviceId=="string")return e}catch{}return null}function lT(t){try{localStorage.setItem(ay,JSON.stringify(t))}catch{}}function yI(){try{localStorage.removeItem(ay),localStorage.removeItem(oy)}catch{}}function _I(){try{const t=Number(localStorage.getItem(oy));return Number.isFinite(t)?t:0}catch{return 0}}function cT(t){try{localStorage.setItem(oy,String(t))}catch{}}function ro(t){if(typeof t!="string")return null;const e=t.trim();return e.length>0?e:null}function xI(t){const e=ro(t);if(!e)return null;const n=e.split(".");if(n.length<2)return null;const i=n[1];try{const r=i.replace(/-/g,"+").replace(/_/g,"/").padEnd(i.length+(4-i.length%4)%4,"="),s=typeof atob=="function"?atob(r):Buffer.from(r,"base64").toString("utf8"),c=JSON.parse(s)?.exp;return typeof c!="number"||!Number.isFinite(c)||c<=0?null:Math.floor(c*1e3)}catch{return null}}function bI(t,e=3e4){const n=xI(t);return n?n<=Date.now()+Math.max(0,Number(e)||0):!1}async function SI(t){if(!t)return null;if(typeof t=="string")return ro(t);if(typeof t=="function")try{const e=await t();return ro(e)}catch{return null}if(typeof t=="object"){if(typeof t.getAccessToken=="function"){try{const e=await t.getAccessToken(),n=ro(e);if(n)return n}catch{}return ro(t.accessToken)}return null}return ro(t)}async function Hd(t,e={}){const n=Math.max(1,Math.min(12,Math.floor(Number(e.maxAttempts)||8))),i=Math.max(20,Math.floor(Number(e.baseDelayMs)||50));for(let r=0;r<n;r++){const s=await SI(t);if(s)return s;r<n-1&&await new Promise(o=>setTimeout(o,i*(r+1)))}return null}function a$(t){return typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1")||typeof t=="function"||t&&typeof t=="object"&&typeof t.getAccessToken=="function"?!0:!!ro(t)}const uT=k.createContext(null);function DS(t){if(!t||typeof t!="object")return null;const e=t,n=e.session&&typeof e.session=="object"?e.session:null,i=typeof e.accessToken=="string"&&e.accessToken||typeof e.access_token=="string"&&e.access_token||n&&typeof n.accessToken=="string"&&n.accessToken||n&&typeof n.access_token=="string"&&n.access_token||null;return i&&i.length>0?i:null}async function wI(t,e={}){if(!t)return null;const n=Math.max(0,Math.floor(Number(e.skewMs)||6e4)),i=t.tokenManager,r=()=>i?.getAccessToken?.()??i?.getSession?.()?.accessToken??null;let s=r();if(!s||bI(s,n)){const{data:o}=await t.auth.refreshSession();if(s=r()??DS(o)??null,!s&&typeof t.auth.getCurrentUser=="function")try{await t.auth.getCurrentUser(),s=r()??DS(o)??null}catch{}}return s||null}function EI({children:t}){const[e,n]=k.useState(null),[i,r]=k.useState(null),[s,o]=k.useState(!0);k.useEffect(()=>{if(!l0()){n(null),r(null),o(!1);return}n(gI())},[]),k.useEffect(()=>{if(!e)return;let w=!0;return o(!0),(async()=>{try{let{data:y,error:x}=await e.auth.getCurrentUser();if(!w)return;if(!x&&!y?.user){if(await new Promise(A=>setTimeout(A,150)),!w)return;const M=await e.auth.getCurrentUser();y=M.data,x=M.error}if(x){r(null);return}r(y?.user??null)}catch{w&&r(null)}finally{w&&o(!1)}})(),()=>{w=!1}},[e]);const c=k.useCallback(async()=>{if(e)try{let{data:w,error:y}=await e.auth.getCurrentUser();if(!y&&!w?.user){await new Promise(M=>setTimeout(M,150));const x=await e.auth.getCurrentUser();w=x.data,y=x.error}if(y){r(null);return}r(w?.user??null)}catch{r(null)}},[e]),u=k.useCallback(async(w,y)=>{if(!e)return{error:new Error("InsForge client not configured")};const x=typeof window<"u"&&window.webkit?.messageHandlers?.nativeOAuth;if(x){const T=typeof y=="string"&&y.trim()?y.trim():`${window.location.origin}/auth/callback`,D=await e.auth.signInWithOAuth({provider:w,redirectTo:T,skipBrowserRedirect:!0});if(D.data?.url){try{await fetch("/api/auth-bridge/verifier",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({native:!0})})}catch{}x.postMessage(D.data.url)}return D}const M=typeof y=="string"&&y.trim()?y.trim():typeof window<"u"?`${window.location.origin}/dashboard`:void 0;return await e.auth.signInWithOAuth({provider:w,redirectTo:M})},[e]),f=k.useCallback(async w=>{if(!e)return{data:null,error:new Error("InsForge client not configured")};const{data:y,error:x}=await e.auth.signInWithPassword(w);return y?.user&&r(y.user),{data:y,error:x}},[e]),h=k.useCallback(async w=>{if(!e)return{data:null,error:new Error("InsForge client not configured")};const{data:y,error:x}=await e.auth.signUp(w);return y?.user&&y?.accessToken&&r(y.user),{data:y,error:x}},[e]),p=k.useCallback(async()=>e?e.auth.getPublicAuthConfig():{data:null,error:new Error("InsForge client not configured")},[e]),m=k.useCallback(async()=>{e&&(await e.auth.signOut(),yI(),r(null))},[e]),v=k.useCallback(async()=>wI(e),[e]),_=k.useMemo(()=>!l0()||!e?{enabled:!1,client:null,user:null,signedIn:!1,loading:!1,refreshUser:async()=>{},signInWithOAuth:async()=>({error:new Error("InsForge not configured")}),signInWithPassword:async()=>({data:null,error:new Error("InsForge not configured")}),signUp:async()=>({data:null,error:new Error("InsForge not configured")}),getPublicAuthConfig:async()=>({data:null,error:new Error("InsForge not configured")}),signOut:async()=>{},getAccessToken:async()=>null}:{enabled:!0,client:e,user:i,signedIn:!!i,loading:s,refreshUser:c,signInWithOAuth:u,signInWithPassword:f,signUp:h,getPublicAuthConfig:p,signOut:m,getAccessToken:v},[e,i,s,c,u,f,h,p,m,v]);return O.jsx(uT.Provider,{value:_,children:t})}function Ro(){return k.useContext(uT)}const MI="modulepreload",TI=function(t){return"/"+t},NS={},ly=function(e,n,i){let r=Promise.resolve();if(n&&n.length>0){let u=function(f){return Promise.all(f.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),c=o?.nonce||o?.getAttribute("nonce");r=u(n.map(f=>{if(f=TI(f),f in NS)return;NS[f]=!0;const h=f.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${p}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":MI,h||(m.as="script"),m.crossOrigin="",m.href=f,c&&m.setAttribute("nonce",c),document.head.appendChild(m),h)return new Promise((v,_)=>{m.addEventListener("load",v),m.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${f}`)))})}))}function s(o){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=o,window.dispatchEvent(c),!c.defaultPrevented)throw o}return r.then(o=>{for(const c of o||[])c.status==="rejected"&&s(c.reason);return e().catch(s)})};var nh={},AI=()=>{window.va||(window.va=function(...e){window.vaq||(window.vaq=[]),window.vaq.push(e)})},CI="@vercel/analytics",RI="2.0.1";function dT(){return typeof window<"u"}function fT(){try{const t="production"}catch{}return"production"}function PI(t="auto"){if(t==="auto"){window.vam=fT();return}window.vam=t}function kI(){return(dT()?window.vam:fT())||"production"}function cy(){return kI()==="development"}function LI(t){return t.scriptSrc?Tl(t.scriptSrc):cy()?"https://va.vercel-scripts.com/v1/script.debug.js":t.basePath?Tl(`${t.basePath}/insights/script.js`):"/_vercel/insights/script.js"}function DI(t,e){var n;let i=t;if(e)try{i={...(n=JSON.parse(e))==null?void 0:n.analytics,...t}}catch{}PI(i.mode);const r={sdkn:CI+(i.framework?`/${i.framework}`:""),sdkv:RI};return i.disableAutoTrack&&(r.disableAutoTrack="1"),i.viewEndpoint&&(r.viewEndpoint=Tl(i.viewEndpoint)),i.eventEndpoint&&(r.eventEndpoint=Tl(i.eventEndpoint)),i.sessionEndpoint&&(r.sessionEndpoint=Tl(i.sessionEndpoint)),cy()&&i.debug===!1&&(r.debug="false"),i.dsn&&(r.dsn=i.dsn),i.endpoint?r.endpoint=i.endpoint:i.basePath&&(r.endpoint=Tl(`${i.basePath}/insights`)),{beforeSend:i.beforeSend,src:LI(i),dataset:r}}function Tl(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")?t:`/${t}`}function NI(t={debug:!0},e){var n;if(!dT())return;const{beforeSend:i,src:r,dataset:s}=DI(t,e);if(AI(),i&&((n=window.va)==null||n.call(window,"beforeSend",i)),document.head.querySelector(`script[src*="${r}"]`))return;const o=document.createElement("script");o.src=r;for(const[c,u]of Object.entries(s))o.dataset[c]=u;o.defer=!0,o.onerror=()=>{const c=cy()?"Please check if any ad blockers are enabled and try again.":"Be sure to enable Web Analytics for your project and deploy again. See https://vercel.com/docs/analytics/quickstart for more information.";console.log(`[Vercel Web Analytics] Failed to load script from ${r}. ${c}`)},document.head.appendChild(o)}function II({route:t,path:e}){var n;(n=window.va)==null||n.call(window,"pageview",{route:t,path:e})}function UI(){if(!(typeof process>"u"||typeof nh>"u"))return nh.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH}function FI(){if(!(typeof process>"u"||typeof nh>"u"))return nh.REACT_APP_VERCEL_OBSERVABILITY_CLIENT_CONFIG}function OI(t){return k.useEffect(()=>{var e;t.beforeSend&&((e=window.va)==null||e.call(window,"beforeSend",t.beforeSend))},[t.beforeSend]),k.useEffect(()=>{NI({framework:t.framework||"react",basePath:t.basePath??UI(),...t.route!==void 0&&{disableAutoTrack:!0},...t},t.configString??FI())},[]),k.useEffect(()=>{t.route&&t.path&&II({route:t.route,path:t.path})},[t.route,t.path]),null}var ih={},BI=()=>{window.si||(window.si=function(...e){window.siq=window.siq||[],window.siq.push(e)})},zI="@vercel/speed-insights",VI="2.0.0";function HI(){return typeof window<"u"}function GI(){try{const t="production"}catch{}return"production"}function hT(){return GI()==="development"}function jI(t){return t.scriptSrc?rh(t.scriptSrc):hT()?"https://va.vercel-scripts.com/v1/speed-insights/script.debug.js":t.dsn?"https://va.vercel-scripts.com/v1/speed-insights/script.js":t.basePath?rh(`${t.basePath}/speed-insights/script.js`):"/_vercel/speed-insights/script.js"}function WI(t,e){var n;let i=t;if(e)try{i={...(n=JSON.parse(e))==null?void 0:n.speedInsights,...t}}catch{}const r={sdkn:zI+(i.framework?`/${i.framework}`:""),sdkv:VI};return i.sampleRate&&(r.sampleRate=i.sampleRate.toString()),i.route&&(r.route=i.route),hT()&&i.debug===!1&&(r.debug="false"),i.dsn&&(r.dsn=i.dsn),i.endpoint?r.endpoint=rh(i.endpoint):i.basePath&&(r.endpoint=rh(`${i.basePath}/speed-insights/vitals`)),{src:jI(i),beforeSend:i.beforeSend,dataset:r}}function rh(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")?t:`/${t}`}function $I(t={},e){var n;if(!HI()||t.route===null)return null;BI();const{beforeSend:i,src:r,dataset:s}=WI(t,e);if(document.head.querySelector(`script[src*="${r}"]`))return null;i&&((n=window.si)==null||n.call(window,"beforeSend",i));const o=document.createElement("script");o.src=r,o.defer=!0;for(const[c,u]of Object.entries(s))o.dataset[c]=u;return o.onerror=()=>{console.log(`[Vercel Speed Insights] Failed to load script from ${r}. Please check if any content blockers are enabled and try again.`)},document.head.appendChild(o),{setRoute:c=>{o.dataset.route=c??void 0}}}function XI(){if(!(typeof process>"u"||typeof ih>"u"))return ih.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH}function qI(){if(!(typeof process>"u"||typeof ih>"u"))return ih.REACT_APP_VERCEL_OBSERVABILITY_CLIENT_CONFIG}function YI(t){k.useEffect(()=>{var n;t.beforeSend&&((n=window.si)==null||n.call(window,"beforeSend",t.beforeSend))},[t.beforeSend]);const e=k.useRef(null);return k.useEffect(()=>{if(!e.current){const n=$I({framework:t.framework??"react",basePath:t.basePath??XI(),...t},t.configString??qI());n&&(e.current=n.setRoute)}},[t]),k.useEffect(()=>{e.current&&t.route&&e.current(t.route)},[t.route]),null}function kh(){return typeof window<"u"}function uy(t){return pT(t)?(t.nodeName||"").toLowerCase():"#document"}function Xl(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function KI(t){var e;return(e=(pT(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function pT(t){return kh()?t instanceof Node||t instanceof Xl(t).Node:!1}function mT(t){return kh()?t instanceof Element||t instanceof Xl(t).Element:!1}function dy(t){return kh()?t instanceof HTMLElement||t instanceof Xl(t).HTMLElement:!1}function IS(t){return!kh()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Xl(t).ShadowRoot}function gT(t){const{overflow:e,overflowX:n,overflowY:i,display:r}=yT(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&r!=="inline"&&r!=="contents"}function o$(t){return/^(table|td|th)$/.test(uy(t))}function ZI(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const JI=/transform|translate|scale|rotate|perspective|filter/,QI=/paint|layout|strict|content/,Xa=t=>!!t&&t!=="none";let Um;function eU(t){const e=mT(t)?yT(t):t;return Xa(e.transform)||Xa(e.translate)||Xa(e.scale)||Xa(e.rotate)||Xa(e.perspective)||!tU()&&(Xa(e.backdropFilter)||Xa(e.filter))||JI.test(e.willChange||"")||QI.test(e.contain||"")}function l$(t){let e=c0(t);for(;dy(e)&&!vT(e);){if(eU(e))return e;if(ZI(e))return null;e=c0(e)}return null}function tU(){return Um==null&&(Um=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Um}function vT(t){return/^(html|body|#document)$/.test(uy(t))}function yT(t){return Xl(t).getComputedStyle(t)}function c$(t){return mT(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function c0(t){if(uy(t)==="html")return t;const e=t.assignedSlot||t.parentNode||IS(t)&&t.host||KI(t);return IS(e)?e.host:e}function _T(t){const e=c0(t);return vT(e)?t.ownerDocument?t.ownerDocument.body:t.body:dy(e)&&gT(e)?e:_T(e)}function US(t,e,n){var i;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=_T(t),s=r===((i=t.ownerDocument)==null?void 0:i.body),o=Xl(r);if(s){const c=nU(o);return e.concat(o,o.visualViewport||[],gT(r)?r:[],c&&n?US(c):[])}else return e.concat(r,US(r,[],n))}function nU(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}const FS={};function fy(t,e){const n=k.useRef(FS);return n.current===FS&&(n.current=t(e)),n}const Fm=N1[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],iU=Fm&&Fm!==k.useLayoutEffect?Fm:t=>t();function OS(t){const e=fy(rU).current;return e.next=t,iU(e.effect),e.trampoline}function rU(){const t={next:void 0,callback:sU,trampoline:(...e)=>t.callback?.(...e),effect:()=>{t.callback=t.next}};return t}function sU(){}const aU=()=>{},oU=typeof document<"u"?k.useLayoutEffect:aU;function u0(t,e){if(t&&!e)return t;if(!t&&e)return e;if(t||e)return{...t,...e}}const nu={};function xT(t,e,n,i,r){let s={...d0(t,nu)};return e&&(s=Rf(s,e)),n&&(s=Rf(s,n)),i&&(s=Rf(s,i)),s}function lU(t){if(t.length===0)return nu;if(t.length===1)return d0(t[0],nu);let e={...d0(t[0],nu)};for(let n=1;n<t.length;n+=1)e=Rf(e,t[n]);return e}function Rf(t,e){return bT(e)?e(t):cU(t,e)}function cU(t,e){if(!e)return t;for(const n in e){const i=e[n];switch(n){case"style":{t[n]=u0(t.style,i);break}case"className":{t[n]=ST(t.className,i);break}default:uU(n,i)?t[n]=dU(t[n],i):t[n]=i}}return t}function uU(t,e){const n=t.charCodeAt(0),i=t.charCodeAt(1),r=t.charCodeAt(2);return n===111&&i===110&&r>=65&&r<=90&&(typeof e=="function"||typeof e>"u")}function bT(t){return typeof t=="function"}function d0(t,e){return bT(t)?t(e):t??nu}function dU(t,e){return e?t?n=>{if(fU(n)){const r=n;f0(r);const s=e(r);return r.baseUIHandlerPrevented||t?.(r),s}const i=e(n);return t?.(n),i}:e:t}function f0(t){return t.preventBaseUIHandler=()=>{t.baseUIHandlerPrevented=!0},t}function ST(t,e){return e?t?e+" "+t:e:t}function fU(t){return t!=null&&typeof t=="object"&&"nativeEvent"in t}function wT(t,...e){const n=new URL("https://base-ui.com/production-error");return n.searchParams.set("code",t.toString()),e.forEach(i=>n.searchParams.append("args[]",i)),`Base UI error #${t}; visit ${n} for the full message.`}const hU=k.createContext(void 0);function pU(t=!1){const e=k.useContext(hU);if(e===void 0&&!t)throw new Error(wT(16));return e}function mU(t){const{focusableWhenDisabled:e,disabled:n,composite:i=!1,tabIndex:r=0,isNativeButton:s}=t,o=i&&e!==!1,c=i&&e===!1;return{props:k.useMemo(()=>{const f={onKeyDown(h){n&&e&&h.key!=="Tab"&&h.preventDefault()}};return i||(f.tabIndex=r,!s&&n&&(f.tabIndex=e?r:-1)),(s&&(e||o)||!s&&n)&&(f["aria-disabled"]=n),s&&(!e||c)&&(f.disabled=n),f},[i,n,e,o,c,s,r])}}function gU(t={}){const{disabled:e=!1,focusableWhenDisabled:n,tabIndex:i=0,native:r=!0}=t,s=k.useRef(null),o=pU(!0)!==void 0,c=OS(()=>{const m=s.current;return!!(m?.tagName==="A"&&m?.href)}),{props:u}=mU({focusableWhenDisabled:n,disabled:e,composite:o,tabIndex:i,isNativeButton:r}),f=k.useCallback(()=>{const m=s.current;vU(m)&&o&&e&&u.disabled===void 0&&m.disabled&&(m.disabled=!1)},[e,u.disabled,o]);oU(f,[f]);const h=k.useCallback((m={})=>{const{onClick:v,onMouseDown:_,onKeyUp:w,onKeyDown:y,onPointerDown:x,...M}=m;return xT({type:r?"button":void 0,onClick(T){if(e){T.preventDefault();return}v?.(T)},onMouseDown(T){e||_?.(T)},onKeyDown(T){if(e||(f0(T),y?.(T)),T.baseUIHandlerPrevented)return;const D=T.target===T.currentTarget&&!r&&!c()&&!e,I=T.key==="Enter",U=T.key===" ";D&&((U||I)&&T.preventDefault(),I&&v?.(T))},onKeyUp(T){e||(f0(T),w?.(T)),!T.baseUIHandlerPrevented&&T.target===T.currentTarget&&!r&&!e&&T.key===" "&&v?.(T)},onPointerDown(T){if(e){T.preventDefault();return}x?.(T)}},r?void 0:{role:"button"},u,M)},[e,u,r,c]),p=OS(m=>{s.current=m,f()});return{getButtonProps:h,buttonRef:p}}function vU(t){return dy(t)&&t.tagName==="BUTTON"}function BS(t,e,n,i){const r=fy(ET).current;return _U(r,t,e,n,i)&&MT(r,[t,e,n,i]),r.callback}function yU(t){const e=fy(ET).current;return xU(e,t)&&MT(e,t),e.callback}function ET(){return{callback:null,cleanup:null,refs:[]}}function _U(t,e,n,i,r){return t.refs[0]!==e||t.refs[1]!==n||t.refs[2]!==i||t.refs[3]!==r}function xU(t,e){return t.refs.length!==e.length||t.refs.some((n,i)=>n!==e[i])}function MT(t,e){if(t.refs=e,e.every(n=>n==null)){t.callback=null;return}t.callback=n=>{if(t.cleanup&&(t.cleanup(),t.cleanup=null),n!=null){const i=Array(e.length).fill(null);for(let r=0;r<e.length;r+=1){const s=e[r];if(s!=null)switch(typeof s){case"function":{const o=s(n);typeof o=="function"&&(i[r]=o);break}case"object":{s.current=n;break}}}t.cleanup=()=>{for(let r=0;r<e.length;r+=1){const s=e[r];if(s!=null)switch(typeof s){case"function":{const o=i[r];typeof o=="function"?o():s(null);break}case"object":{s.current=null;break}}}}}}}const bU=parseInt(k.version,10);function SU(t){return bU>=t}function zS(t){if(!k.isValidElement(t))return null;const e=t,n=e.props;return(SU(19)?n?.ref:e.ref)??null}function wU(t,e){const n={};for(const i in t){const r=t[i];if(e?.hasOwnProperty(i)){const s=e[i](r);s!=null&&Object.assign(n,s);continue}r===!0?n[`data-${i.toLowerCase()}`]="":r&&(n[`data-${i.toLowerCase()}`]=r.toString())}return n}function EU(t,e){return typeof t=="function"?t(e):t}function MU(t,e){return typeof t=="function"?t(e):t}function u$(){}const Sl=Object.freeze({});function TU(t,e,n={}){const i=e.render,r=AU(e,n);if(n.enabled===!1)return null;const s=n.state??Sl;return CU(t,i,r,s)}function AU(t,e={}){const{className:n,style:i,render:r}=t,{state:s=Sl,ref:o,props:c,stateAttributesMapping:u,enabled:f=!0}=e,h=f?EU(n,s):void 0,p=f?MU(i,s):void 0,m=f?wU(s,u):Sl,v=f?u0(m,Array.isArray(c)?lU(c):c)??Sl:Sl;return typeof document<"u"&&(f?Array.isArray(o)?v.ref=yU([v.ref,zS(r),...o]):v.ref=BS(v.ref,zS(r),o):BS(null,null)),f?(h!==void 0&&(v.className=ST(v.className,h)),p!==void 0&&(v.style=u0(v.style,p)),v):Sl}function CU(t,e,n,i){if(e){if(typeof e=="function")return e(n,i);const r=xT(n,e.props);return r.ref=n.ref,k.cloneElement(e,r)}if(t&&typeof t=="string")return RU(t,n);throw new Error(wT(8))}function RU(t,e){return t==="button"?k.createElement("button",{type:"button",...e,key:e.key}):t==="img"?k.createElement("img",{alt:"",...e,key:e.key}):k.createElement(t,e)}const PU=k.forwardRef(function(e,n){const{render:i,className:r,disabled:s=!1,focusableWhenDisabled:o=!1,nativeButton:c=!0,...u}=e,{getButtonProps:f,buttonRef:h}=gU({disabled:s,focusableWhenDisabled:o,native:c}),p=k.useMemo(()=>({disabled:s}),[s]);return TU("button",e,{state:p,ref:[n,h],props:[u,f]})}),kU=`key,module,page,component,slot,text,notes,status
43
43
  header.auth.sign_in_aria,shared,*,InsforgeUserHeaderControls,sign_in_aria,"Sign in",,active
44
44
  header.auth.user_fallback,shared,*,InsforgeUserHeaderControls,user_fallback,"User",,active
45
45
  header.cloud_sync.label,shared,*,InsforgeUserHeaderControls,cloud_sync_label,"Sync local usage to cloud",,active
@@ -505,7 +505,7 @@ live_sniffer.event.capture,ui,LiveSniffer,LiveSniffer,event,"> CAPTURE: +128 NEU
505
505
  ${M}px !important;
506
506
  ${A}px !important;
507
507
  }
508
- `),()=>{c.current?.removeAttribute("data-motion-pop-id"),D.contains(T)&&D.removeChild(T)}},[e]),O.jsx(P4,{isPresent:e,childRef:c,sizeRef:u,pop:s,children:s===!1?t:k.cloneElement(t,{ref:p})})}const L4=({children:t,initial:e,isPresent:n,onExitComplete:i,custom:r,presenceAffectsLayout:s,mode:o,anchorX:c,anchorY:u,root:f})=>{const h=py(D4),p=k.useId();let m=!0,v=k.useMemo(()=>(m=!1,{id:p,initial:e,isPresent:n,custom:r,onExitComplete:_=>{h.set(_,!0);for(const w of h.values())if(!w)return;i&&i()},register:_=>(h.set(_,!1),()=>h.delete(_))}),[n,h,i]);return s&&m&&(v={...v}),k.useMemo(()=>{h.forEach((_,w)=>h.set(w,!1))},[n]),k.useEffect(()=>{!n&&!h.size&&i&&i()},[n]),t=O.jsx(k4,{pop:o==="popLayout",isPresent:n,anchorX:c,anchorY:u,root:f,children:t}),O.jsx(Lh.Provider,{value:v,children:t})};function D4(){return new Map}function tC(t=!0){const e=k.useContext(Lh);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:r}=e,s=k.useId();k.useEffect(()=>{if(t)return r(s)},[t]);const o=k.useCallback(()=>t&&i&&i(s),[s,i,t]);return!n&&i?[!1,o]:[!0]}const Wd=t=>t.key||"";function Ww(t){const e=[];return k.Children.forEach(t,n=>{k.isValidElement(n)&&e.push(n)}),e}const I0=({children:t,custom:e,initial:n=!0,onExitComplete:i,presenceAffectsLayout:r=!0,mode:s="sync",propagate:o=!1,anchorX:c="left",anchorY:u="top",root:f})=>{const[h,p]=tC(o),m=k.useMemo(()=>Ww(t),[t]),v=o&&!h?[]:m.map(Wd),_=k.useRef(!0),w=k.useRef(m),y=py(()=>new Map),x=k.useRef(new Set),[M,A]=k.useState(m),[T,D]=k.useState(m);CT(()=>{_.current=!1,w.current=m;for(let S=0;S<T.length;S++){const R=Wd(T[S]);v.includes(R)?(y.delete(R),x.current.delete(R)):y.get(R)!==!0&&y.set(R,!1)}},[T,v.length,v.join("-")]);const I=[];if(m!==M){let S=[...m];for(let R=0;R<T.length;R++){const V=T[R],F=Wd(V);v.includes(F)||(S.splice(R,0,V),I.push(V))}return s==="wait"&&I.length&&(S=I),D(Ww(S)),A(m),null}const{forceRender:U}=k.useContext(hy);return O.jsx(O.Fragment,{children:T.map(S=>{const R=Wd(S),V=o&&!h?!1:m===T||v.includes(R),F=()=>{if(x.current.has(R))return;if(y.has(R))x.current.add(R),y.set(R,!0);else return;let j=!0;y.forEach(Z=>{Z||(j=!1)}),j&&(U?.(),D(w.current),o&&p?.(),i&&i())};return O.jsx(L4,{isPresent:V,initial:!_.current||n?void 0:!1,custom:e,presenceAffectsLayout:r,mode:s,root:f,onExitComplete:V?void 0:F,anchorX:c,anchorY:u,children:S},R)})})},nC=k.createContext({strict:!1}),$w={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let Xw=!1;function N4(){if(Xw)return;const t={};for(const e in $w)t[e]={isEnabled:n=>$w[e].some(i=>!!n[i])};kA(t),Xw=!0}function iC(){return N4(),yB()}function I4(t){const e=iC();for(const n in t)e[n]={...e[n],...t[n]};kA(e)}const U4=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function ph(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||U4.has(t)}let rC=t=>!ph(t);function F4(t){typeof t=="function"&&(rC=e=>e.startsWith("on")?!ph(e):t(e))}try{F4(require("@emotion/is-prop-valid").default)}catch{}function O4(t,e,n){const i={};for(const r in t)r==="values"&&typeof t.values=="object"||hi(t[r])||(rC(r)||n===!0&&ph(r)||!e&&!ph(r)||t.draggable&&r.startsWith("onDrag"))&&(i[r]=t[r]);return i}const Uh=k.createContext({});function B4(t,e){if(Ih(t)){const{initial:n,animate:i}=t;return{initial:n===!1||pu(n)?n:void 0,animate:pu(i)?i:void 0}}return t.inherit!==!1?e:{}}function z4(t){const{initial:e,animate:n}=B4(t,k.useContext(Uh));return k.useMemo(()=>({initial:e,animate:n}),[qw(e),qw(n)])}function qw(t){return Array.isArray(t)?t.join(" "):t}const Vy=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function sC(t,e,n){for(const i in e)!hi(e[i])&&!OA(i,n)&&(t[i]=e[i])}function V4({transformTemplate:t},e){return k.useMemo(()=>{const n=Vy();return Oy(n,e,t),Object.assign({},n.vars,n.style)},[e])}function H4(t,e){const n=t.style||{},i={};return sC(i,n,t),Object.assign(i,V4(t,e)),i}function G4(t,e){const n={},i=H4(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=i,n}const aC=()=>({...Vy(),attrs:{}});function j4(t,e,n,i){const r=k.useMemo(()=>{const s=aC();return BA(s,e,VA(i),t.transformTemplate,t.style),{...s.attrs,style:{...s.style}}},[e]);if(t.style){const s={};sC(s,t.style,t),r.style={...s,...r.style}}return r}const W4=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Hy(t){return typeof t!="string"||t.includes("-")?!1:!!(W4.indexOf(t)>-1||/[A-Z]/u.test(t))}function $4(t,e,n,{latestValues:i},r,s=!1,o){const u=(o??Hy(t)?j4:G4)(e,i,r,t),f=O4(e,typeof t=="string",s),h=t!==k.Fragment?{...f,...u,ref:n}:{},{children:p}=e,m=k.useMemo(()=>hi(p)?p.get():p,[p]);return k.createElement(t,{...h,children:m})}function X4({scrapeMotionValuesFromProps:t,createRenderState:e},n,i,r){return{latestValues:q4(n,i,r,t),renderState:e()}}function q4(t,e,n,i){const r={},s=i(t,{});for(const m in s)r[m]=Ff(s[m]);let{initial:o,animate:c}=t;const u=Ih(t),f=RA(t);e&&f&&!u&&t.inherit!==!1&&(o===void 0&&(o=e.initial),c===void 0&&(c=e.animate));let h=n?n.initial===!1:!1;h=h||o===!1;const p=h?c:o;if(p&&typeof p!="boolean"&&!Nh(p)){const m=Array.isArray(p)?p:[p];for(let v=0;v<m.length;v++){const _=Ry(t,m[v]);if(_){const{transitionEnd:w,transition:y,...x}=_;for(const M in x){let A=x[M];if(Array.isArray(A)){const T=h?A.length-1:0;A=A[T]}A!==null&&(r[M]=A)}for(const M in w)r[M]=w[M]}}}return r}const oC=t=>(e,n)=>{const i=k.useContext(Uh),r=k.useContext(Lh),s=()=>X4(t,e,i,r);return n?s():py(s)},Y4=oC({scrapeMotionValuesFromProps:By,createRenderState:Vy}),K4=oC({scrapeMotionValuesFromProps:HA,createRenderState:aC}),Z4=Symbol.for("motionComponentSymbol");function J4(t,e,n){const i=k.useRef(n);k.useInsertionEffect(()=>{i.current=n});const r=k.useRef(null);return k.useCallback(s=>{s&&t.onMount?.(s);const o=i.current;if(typeof o=="function")if(s){const c=o(s);typeof c=="function"&&(r.current=c)}else r.current?(r.current(),r.current=null):o(s);else o&&(o.current=s);e&&(s?e.mount(s):e.unmount())},[e])}const lC=k.createContext({});function wl(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Q4(t,e,n,i,r,s){const{visualElement:o}=k.useContext(Uh),c=k.useContext(nC),u=k.useContext(Lh),f=k.useContext(zy),h=f.reducedMotion,p=f.skipAnimations,m=k.useRef(null),v=k.useRef(!1);i=i||c.renderer,!m.current&&i&&(m.current=i(t,{visualState:e,parent:o,props:n,presenceContext:u,blockInitialAnimation:u?u.initial===!1:!1,reducedMotionConfig:h,skipAnimations:p,isSVG:s}),v.current&&m.current&&(m.current.manuallyAnimateOnMount=!0));const _=m.current,w=k.useContext(lC);_&&!_.projection&&r&&(_.type==="html"||_.type==="svg")&&e5(m.current,n,r,w);const y=k.useRef(!1);k.useInsertionEffect(()=>{_&&y.current&&_.update(n,u)});const x=n[gA],M=k.useRef(!!x&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(x)&&window.MotionHasOptimisedAnimation?.(x));return CT(()=>{v.current=!0,_&&(y.current=!0,window.MotionIsMounted=!0,_.updateFeatures(),_.scheduleRenderMicrotask(),M.current&&_.animationState&&_.animationState.animateChanges())}),k.useEffect(()=>{_&&(!M.current&&_.animationState&&_.animationState.animateChanges(),M.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(x)}),M.current=!1),_.enteringChildren=void 0)}),_}function e5(t,e,n,i){const{layoutId:r,layout:s,drag:o,dragConstraints:c,layoutScroll:u,layoutRoot:f,layoutAnchor:h,layoutCrossfade:p}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:cC(t.parent)),t.projection.setOptions({layoutId:r,layout:s,alwaysMeasureLayout:!!o||c&&wl(c),visualElement:t,animationType:typeof s=="string"?s:"both",initialPromotionConfig:i,crossfade:p,layoutScroll:u,layoutRoot:f,layoutAnchor:h})}function cC(t){if(t)return t.options.allowProjection!==!1?t.projection:cC(t.parent)}function Km(t,{forwardMotionProps:e=!1,type:n}={},i,r){i&&I4(i);const s=n?n==="svg":Hy(t),o=s?K4:Y4;function c(f,h){let p;const m={...k.useContext(zy),...f,layoutId:t5(f)},{isStatic:v}=m,_=z4(f),w=o(f,v);if(!v&&typeof window<"u"){n5();const y=i5(m);p=y.MeasureLayout,_.visualElement=Q4(t,w,m,r,y.ProjectionNode,s)}return O.jsxs(Uh.Provider,{value:_,children:[p&&_.visualElement?O.jsx(p,{visualElement:_.visualElement,...m}):null,$4(t,f,J4(w,_.visualElement,h),w,v,e,s)]})}c.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const u=k.forwardRef(c);return u[Z4]=t,u}function t5({layoutId:t}){const e=k.useContext(hy).id;return e&&t!==void 0?e+"-"+t:t}function n5(t,e){k.useContext(nC).strict}function i5(t){const e=iC(),{drag:n,layout:i}=e;if(!n&&!i)return{};const r={...n,...i};return{MeasureLayout:n?.isEnabled(t)||i?.isEnabled(t)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function r5(t,e){if(typeof Proxy>"u")return Km;const n=new Map,i=(s,o)=>Km(s,o,t,e),r=(s,o)=>i(s,o);return new Proxy(r,{get:(s,o)=>o==="create"?i:(n.has(o)||n.set(o,Km(o,void 0,t,e)),n.get(o))})}const s5=(t,e)=>e.isSVG??Hy(t)?new IB(e):new RB(e,{allowProjection:t!==k.Fragment});class a5 extends Da{constructor(e){super(e),e.animationState||(e.animationState=zB(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Nh(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let o5=0;class l5 extends Da{constructor(){super(...arguments),this.id=o5++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===i)return;if(e&&i===!1){if(this.isExitComplete){const{initial:s,custom:o}=this.node.getProps();if(typeof s=="string"){const c=go(this.node,s,o);if(c){const{transition:u,transitionEnd:f,...h}=c;for(const p in h)this.node.getValue(p)?.jump(h[p])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!e);n&&!e&&r.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const c5={animation:{Feature:a5},exit:{Feature:l5}};function Cu(t){return{point:{x:t.pageX,y:t.pageY}}}const u5=t=>e=>Dy(e)&&t(e,Cu(e));function au(t,e,n,i){return mu(t,e,u5(n),i)}const uC=({current:t})=>t?t.ownerDocument.defaultView:null,Yw=(t,e)=>Math.abs(t-e);function d5(t,e){const n=Yw(t.x,e.x),i=Yw(t.y,e.y);return Math.sqrt(n**2+i**2)}const Kw=new Set(["auto","scroll"]);class dC{constructor(e,n,{transformPagePoint:i,contextWindow:r=window,dragSnapToOrigin:s=!1,distanceThreshold:o=3,element:c}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=v=>{this.handleScroll(v.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=$d(this.lastRawMoveEventInfo,this.transformPagePoint));const v=Zm(this.lastMoveEventInfo,this.history),_=this.startEvent!==null,w=d5(v.offset,{x:0,y:0})>=this.distanceThreshold;if(!_&&!w)return;const{point:y}=v,{timestamp:x}=fi;this.history.push({...y,timestamp:x});const{onStart:M,onMove:A}=this.handlers;_||(M&&M(this.lastMoveEvent,v),this.startEvent=this.lastMoveEvent),A&&A(this.lastMoveEvent,v)},this.handlePointerMove=(v,_)=>{this.lastMoveEvent=v,this.lastRawMoveEventInfo=_,this.lastMoveEventInfo=$d(_,this.transformPagePoint),Tn.update(this.updatePoint,!0)},this.handlePointerUp=(v,_)=>{this.end();const{onEnd:w,onSessionEnd:y,resumeAnimation:x}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&x&&x(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const M=Zm(v.type==="pointercancel"?this.lastMoveEventInfo:$d(_,this.transformPagePoint),this.history);this.startEvent&&w&&w(v,M),y&&y(v,M)},!Dy(e))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=i,this.distanceThreshold=o,this.contextWindow=r||window;const u=Cu(e),f=$d(u,this.transformPagePoint),{point:h}=f,{timestamp:p}=fi;this.history=[{...h,timestamp:p}];const{onSessionStart:m}=n;m&&m(e,Zm(f,this.history)),this.removeListeners=Mu(au(this.contextWindow,"pointermove",this.handlePointerMove),au(this.contextWindow,"pointerup",this.handlePointerUp),au(this.contextWindow,"pointercancel",this.handlePointerUp)),c&&this.startScrollTracking(c)}startScrollTracking(e){let n=e.parentElement;for(;n;){const i=getComputedStyle(n);(Kw.has(i.overflowX)||Kw.has(i.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const n=this.scrollPositions.get(e);if(!n)return;const i=e===window,r=i?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},s={x:r.x-n.x,y:r.y-n.y};s.x===0&&s.y===0||(i?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=s.x,this.lastMoveEventInfo.point.y+=s.y):this.history.length>0&&(this.history[0].x-=s.x,this.history[0].y-=s.y),this.scrollPositions.set(e,r),Tn.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ka(this.updatePoint)}}function $d(t,e){return e?{point:e(t.point)}:t}function Zw(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Zm({point:t},e){return{point:t,delta:Zw(t,fC(e)),offset:Zw(t,f5(e)),velocity:h5(e,.1)}}function f5(t){return t[0]}function fC(t){return t[t.length-1]}function h5(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,i=null;const r=fC(t);for(;n>=0&&(i=t[n],!(r.timestamp-i.timestamp>Qi(e)));)n--;if(!i)return{x:0,y:0};i===t[0]&&t.length>2&&r.timestamp-i.timestamp>Qi(e)*2&&(i=t[1]);const s=hr(r.timestamp-i.timestamp);if(s===0)return{x:0,y:0};const o={x:(r.x-i.x)/s,y:(r.y-i.y)/s};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function p5(t,{min:e,max:n},i){return e!==void 0&&t<e?t=i?Pn(e,t,i.min):Math.max(t,e):n!==void 0&&t>n&&(t=i?Pn(n,t,i.max):Math.min(t,n)),t}function Jw(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function m5(t,{top:e,left:n,bottom:i,right:r}){return{x:Jw(t.x,n,r),y:Jw(t.y,e,i)}}function Qw(t,e){let n=e.min-t.min,i=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,i]=[i,n]),{min:n,max:i}}function g5(t,e){return{x:Qw(t.x,e.x),y:Qw(t.y,e.y)}}function v5(t,e){let n=.5;const i=Pi(t),r=Pi(e);return r>i?n=fu(e.min,e.max-i,t.min):i>r&&(n=fu(t.min,t.max-r,e.min)),ls(0,1,n)}function y5(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const U0=.35;function _5(t=U0){return t===!1?t=0:t===!0&&(t=U0),{x:eE(t,"left","right"),y:eE(t,"top","bottom")}}function eE(t,e,n){return{min:tE(t,e),max:tE(t,n)}}function tE(t,e){return typeof t=="number"?t:t[e]||0}const x5=new WeakMap;class b5{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ei(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:i}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const s=p=>{n&&this.snapToCursor(Cu(p).point),this.stopAnimation()},o=(p,m)=>{const{drag:v,dragPropagation:_,onDragStart:w}=this.getProps();if(v&&!_&&(this.openDragLock&&this.openDragLock(),this.openDragLock=YO(v),!this.openDragLock))return;this.latestPointerEvent=p,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),qr(x=>{let M=this.getAxisMotionValue(x).get()||0;if(ts.test(M)){const{projection:A}=this.visualElement;if(A&&A.layout){const T=A.layout.layoutBox[x];T&&(M=Pi(T)*(parseFloat(M)/100))}}this.originPoint[x]=M}),w&&Tn.update(()=>w(p,m),!1,!0),A0(this.visualElement,"transform");const{animationState:y}=this.visualElement;y&&y.setActive("whileDrag",!0)},c=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m;const{dragPropagation:v,dragDirectionLock:_,onDirectionLock:w,onDrag:y}=this.getProps();if(!v&&!this.openDragLock)return;const{offset:x}=m;if(_&&this.currentDirection===null){this.currentDirection=w5(x),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",m.point,x),this.updateAxis("y",m.point,x),this.visualElement.render(),y&&Tn.update(()=>y(p,m),!1,!0)},u=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m,this.stop(p,m),this.latestPointerEvent=null,this.latestPanInfo=null},f=()=>{const{dragSnapToOrigin:p}=this.getProps();(p||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:h}=this.getProps();this.panSession=new dC(e,{onSessionStart:s,onStart:o,onMove:c,onSessionEnd:u,resumeAnimation:f},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,distanceThreshold:i,contextWindow:uC(this.visualElement),element:this.visualElement.current})}stop(e,n){const i=e||this.latestPointerEvent,r=n||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!r||!i)return;const{velocity:o}=r;this.startAnimation(o);const{onDragEnd:c}=this.getProps();c&&Tn.postRender(()=>c(i,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,n,i){const{drag:r}=this.getProps();if(!i||!Xd(e,r,this.currentDirection))return;const s=this.getAxisMotionValue(e);let o=this.originPoint[e]+i[e];this.constraints&&this.constraints[e]&&(o=p5(o,this.constraints[e],this.elastic[e])),s.set(o)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&wl(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&i?this.constraints=m5(i.layoutBox,e):this.constraints=!1,this.elastic=_5(n),r!==this.constraints&&!wl(e)&&i&&this.constraints&&!this.hasMutatedConstraints&&qr(s=>{this.constraints!==!1&&this.getAxisMotionValue(s)&&(this.constraints[s]=y5(i.layoutBox[s],this.constraints[s]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!wl(e))return!1;const i=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const s=wB(i,r.root,this.visualElement.getTransformPagePoint());let o=g5(r.layout.layoutBox,s);if(n){const c=n(xB(o));this.hasMutatedConstraints=!!c,c&&(o=DA(c))}return o}startAnimation(e){const{drag:n,dragMomentum:i,dragElastic:r,dragTransition:s,dragSnapToOrigin:o,onDragTransitionEnd:c}=this.getProps(),u=this.constraints||{},f=qr(h=>{if(!Xd(h,n,this.currentDirection))return;let p=u&&u[h]||{};(o===!0||o===h)&&(p={min:0,max:0});const m=r?200:1e6,v=r?40:1e7,_={type:"inertia",velocity:i?e[h]:0,bounceStiffness:m,bounceDamping:v,timeConstant:750,restDelta:1,restSpeed:10,...s,...p};return this.startAxisValueAnimation(h,_)});return Promise.all(f).then(c)}startAxisValueAnimation(e,n){const i=this.getAxisMotionValue(e);return A0(this.visualElement,e),i.start(Cy(e,i,0,n,this.visualElement,!1))}stopAnimation(){qr(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,i=this.visualElement.getProps(),r=i[n];return r||this.visualElement.getValue(e,(i.initial?i.initial[e]:void 0)||0)}snapToCursor(e){qr(n=>{const{drag:i}=this.getProps();if(!Xd(n,i,this.currentDirection))return;const{projection:r}=this.visualElement,s=this.getAxisMotionValue(n);if(r&&r.layout){const{min:o,max:c}=r.layout.layoutBox[n],u=s.get()||0;s.set(e[n]-Pn(o,c,.5)+u)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:i}=this.visualElement;if(!wl(n)||!i||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};qr(o=>{const c=this.getAxisMotionValue(o);if(c&&this.constraints!==!1){const u=c.get();r[o]=v5({min:u,max:u},this.constraints[o])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.constraints=!1,this.resolveConstraints(),qr(o=>{if(!Xd(o,e,null))return;const c=this.getAxisMotionValue(o),{min:u,max:f}=this.constraints[o];c.set(Pn(u,f,r[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;x5.set(this.visualElement,this);const e=this.visualElement.current,n=au(e,"pointerdown",f=>{const{drag:h,dragListener:p=!0}=this.getProps(),m=f.target,v=m!==e&&tB(m);h&&p&&!v&&this.start(f)});let i;const r=()=>{const{dragConstraints:f}=this.getProps();wl(f)&&f.current&&(this.constraints=this.resolveRefConstraints(),i||(i=S5(e,f.current,()=>this.scalePositionWithinConstraints())))},{projection:s}=this.visualElement,o=s.addEventListener("measure",r);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),Tn.read(r);const c=mu(window,"resize",()=>this.scalePositionWithinConstraints()),u=s.addEventListener("didUpdate",(({delta:f,hasLayoutChanged:h})=>{this.isDragging&&h&&(qr(p=>{const m=this.getAxisMotionValue(p);m&&(this.originPoint[p]+=f[p].translate,m.set(m.get()+f[p].translate))}),this.visualElement.render())}));return()=>{c(),n(),o(),u&&u(),i&&i()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:i=!1,dragPropagation:r=!1,dragConstraints:s=!1,dragElastic:o=U0,dragMomentum:c=!0}=e;return{...e,drag:n,dragDirectionLock:i,dragPropagation:r,dragConstraints:s,dragElastic:o,dragMomentum:c}}}function nE(t){let e=!0;return()=>{if(e){e=!1;return}t()}}function S5(t,e,n){const i=cw(t,nE(n)),r=cw(e,nE(n));return()=>{i(),r()}}function Xd(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function w5(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class E5 extends Da{constructor(e){super(e),this.removeGroupControls=pr,this.removeListeners=pr,this.controls=new b5(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||pr}update(){const{dragControls:e}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const Jm=t=>(e,n)=>{t&&Tn.update(()=>t(e,n),!1,!0)};class M5 extends Da{constructor(){super(...arguments),this.removePointerDownListener=pr}onPointerDown(e){this.session=new dC(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:uC(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:i,onPanEnd:r}=this.node.getProps();return{onSessionStart:Jm(e),onStart:Jm(n),onMove:Jm(i),onEnd:(s,o)=>{delete this.session,r&&Tn.postRender(()=>r(s,o))}}}mount(){this.removePointerDownListener=au(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Qm=!1;class T5 extends k.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:i,layoutId:r}=this.props,{projection:s}=e;s&&(n.group&&n.group.add(s),i&&i.register&&r&&i.register(s),Qm&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Of.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:i,drag:r,isPresent:s}=this.props,{projection:o}=i;return o&&(o.isPresent=s,e.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),Qm=!0,r||e.layoutDependency!==n||n===void 0||e.isPresent!==s?o.willUpdate():this.safeToRemove(),e.isPresent!==s&&(s?o.promote():o.relegate()||Tn.postRender(()=>{const c=o.getStack();(!c||!c.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:e,layoutAnchor:n}=this.props,{projection:i}=e;i&&(i.options.layoutAnchor=n,i.root.didUpdate(),Ly.postRender(()=>{!i.currentAnimation&&i.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:r}=e;Qm=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),i&&i.deregister&&i.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function hC(t){const[e,n]=tC(),i=k.useContext(hy);return O.jsx(T5,{...t,layoutGroup:i,switchLayoutGroup:k.useContext(lC),isPresent:e,safeToRemove:n})}const A5={pan:{Feature:M5},drag:{Feature:E5,ProjectionNode:eC,MeasureLayout:hC}};function iE(t,e,n){const{props:i}=t;t.animationState&&i.whileHover&&t.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,s=i[r];s&&Tn.postRender(()=>s(e,Cu(e)))}class C5 extends Da{mount(){const{current:e}=this.node;e&&(this.unmount=ZO(e,(n,i)=>(iE(this.node,i,"Start"),r=>iE(this.node,r,"End"))))}unmount(){}}class R5 extends Da{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Mu(mu(this.node.current,"focus",()=>this.onFocus()),mu(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function rE(t,e,n){const{props:i}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&i.whileTap&&t.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),s=i[r];s&&Tn.postRender(()=>s(e,Cu(e)))}class P5 extends Da{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:n,propagate:i}=this.node.props;this.unmount=iB(e,(r,s)=>(rE(this.node,s,"Start"),(o,{success:c})=>rE(this.node,o,c?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:i?.tap===!1})}unmount(){}}const F0=new WeakMap,eg=new WeakMap,k5=t=>{const e=F0.get(t.target);e&&e(t)},L5=t=>{t.forEach(k5)};function D5({root:t,...e}){const n=t||document;eg.has(n)||eg.set(n,{});const i=eg.get(n),r=JSON.stringify(e);return i[r]||(i[r]=new IntersectionObserver(L5,{root:t,...e})),i[r]}function N5(t,e,n){const i=D5(e);return F0.set(t,n),i.observe(t),()=>{F0.delete(t),i.unobserve(t)}}const I5={some:0,all:1};class U5 extends Da{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:e={}}=this.node.getProps(),{root:n,margin:i,amount:r="some",once:s}=e,o={root:n?n.current:void 0,rootMargin:i,threshold:typeof r=="number"?r:I5[r]},c=u=>{const{isIntersecting:f}=u;if(this.isInView===f||(this.isInView=f,s&&!f&&this.hasEnteredView))return;f&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",f);const{onViewportEnter:h,onViewportLeave:p}=this.node.getProps(),m=f?h:p;m&&m(u)};this.stopObserver=N5(this.node.current,o,c)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(F5(e,n))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}function F5({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const O5={inView:{Feature:U5},tap:{Feature:P5},focus:{Feature:R5},hover:{Feature:C5}},B5={layout:{ProjectionNode:eC,MeasureLayout:hC}},z5={...c5,...O5,...A5,...B5},Is=r5(z5,s5);function V5(){!Fy.current&&PA();const[t]=k.useState(uh.current);return t}const pC=(...t)=>t.filter((e,n,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===n).join(" ").trim();const H5=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const G5=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,i)=>i?i.toUpperCase():n.toLowerCase());const sE=t=>{const e=G5(t);return e.charAt(0).toUpperCase()+e.slice(1)};var tg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const j5=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},W5=k.createContext({}),$5=()=>k.useContext(W5),X5=k.forwardRef(({color:t,size:e,strokeWidth:n,absoluteStrokeWidth:i,className:r="",children:s,iconNode:o,...c},u)=>{const{size:f=24,strokeWidth:h=2,absoluteStrokeWidth:p=!1,color:m="currentColor",className:v=""}=$5()??{},_=i??p?Number(n??h)*24/Number(e??f):n??h;return k.createElement("svg",{ref:u,...tg,width:e??f??tg.width,height:e??f??tg.height,stroke:t??m,strokeWidth:_,className:pC("lucide",v,r),...!s&&!j5(c)&&{"aria-hidden":"true"},...c},[...o.map(([w,y])=>k.createElement(w,y)),...Array.isArray(s)?s:[s]])});const Fh=(t,e)=>{const n=k.forwardRef(({className:i,...r},s)=>k.createElement(X5,{ref:s,iconNode:e,className:pC(`lucide-${H5(sE(t))}`,`lucide-${t}`,i),...r}));return n.displayName=sE(t),n};const q5=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Y5=Fh("log-out",q5);const K5=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Z5=Fh("mail",K5);const J5=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Q5=Fh("pencil",J5);const ez=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],tz=Fh("x",ez);function mC(t){var e,n,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(e=0;e<r;e++)t[e]&&(n=mC(t[e]))&&(i&&(i+=" "),i+=n)}else for(n in t)t[n]&&(i&&(i+=" "),i+=n);return i}function nz(){for(var t,e,n=0,i="",r=arguments.length;n<r;n++)(t=arguments[n])&&(e=mC(t))&&(i&&(i+=" "),i+=e);return i}const iz=(t,e)=>{const n=new Array(t.length+e.length);for(let i=0;i<t.length;i++)n[i]=t[i];for(let i=0;i<e.length;i++)n[t.length+i]=e[i];return n},rz=(t,e)=>({classGroupId:t,validator:e}),gC=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),mh="-",aE=[],sz="arbitrary..",az=t=>{const e=lz(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:i}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return oz(o);const c=o.split(mh),u=c[0]===""&&c.length>1?1:0;return vC(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=i[o],f=n[o];return u?f?iz(f,u):u:f||aE}return n[o]||aE}}},vC=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const r=t[e],s=n.nextPart.get(r);if(s){const f=vC(t,e+1,s);if(f)return f}const o=n.validators;if(o===null)return;const c=e===0?t.join(mh):t.slice(e).join(mh),u=o.length;for(let f=0;f<u;f++){const h=o[f];if(h.validator(c))return h.classGroupId}},oz=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),i=e.slice(0,n);return i?sz+i:void 0})(),lz=t=>{const{theme:e,classGroups:n}=t;return cz(n,e)},cz=(t,e)=>{const n=gC();for(const i in t){const r=t[i];Gy(r,n,i,e)}return n},Gy=(t,e,n,i)=>{const r=t.length;for(let s=0;s<r;s++){const o=t[s];uz(o,e,n,i)}},uz=(t,e,n,i)=>{if(typeof t=="string"){dz(t,e,n);return}if(typeof t=="function"){fz(t,e,n,i);return}hz(t,e,n,i)},dz=(t,e,n)=>{const i=t===""?e:yC(e,t);i.classGroupId=n},fz=(t,e,n,i)=>{if(pz(t)){Gy(t(i),e,n,i);return}e.validators===null&&(e.validators=[]),e.validators.push(rz(n,t))},hz=(t,e,n,i)=>{const r=Object.entries(t),s=r.length;for(let o=0;o<s;o++){const[c,u]=r[o];Gy(u,yC(e,c),n,i)}},yC=(t,e)=>{let n=t;const i=e.split(mh),r=i.length;for(let s=0;s<r;s++){const o=i[s];let c=n.nextPart.get(o);c||(c=gC(),n.nextPart.set(o,c)),n=c}return n},pz=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,mz=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),i=Object.create(null);const r=(s,o)=>{n[s]=o,e++,e>t&&(e=0,i=n,n=Object.create(null))};return{get(s){let o=n[s];if(o!==void 0)return o;if((o=i[s])!==void 0)return r(s,o),o},set(s,o){s in n?n[s]=o:r(s,o)}}},O0="!",oE=":",gz=[],lE=(t,e,n,i,r)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:i,isExternal:r}),vz=t=>{const{prefix:e,experimentalParseClassName:n}=t;let i=r=>{const s=[];let o=0,c=0,u=0,f;const h=r.length;for(let w=0;w<h;w++){const y=r[w];if(o===0&&c===0){if(y===oE){s.push(r.slice(u,w)),u=w+1;continue}if(y==="/"){f=w;continue}}y==="["?o++:y==="]"?o--:y==="("?c++:y===")"&&c--}const p=s.length===0?r:r.slice(u);let m=p,v=!1;p.endsWith(O0)?(m=p.slice(0,-1),v=!0):p.startsWith(O0)&&(m=p.slice(1),v=!0);const _=f&&f>u?f-u:void 0;return lE(s,v,m,_)};if(e){const r=e+oE,s=i;i=o=>o.startsWith(r)?s(o.slice(r.length)):lE(gz,!1,o,void 0,!0)}if(n){const r=i;i=s=>n({className:s,parseClassName:r})}return i},yz=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,i)=>{e.set(n,1e6+i)}),n=>{const i=[];let r=[];for(let s=0;s<n.length;s++){const o=n[s],c=o[0]==="[",u=e.has(o);c||u?(r.length>0&&(r.sort(),i.push(...r),r=[]),i.push(o)):r.push(o)}return r.length>0&&(r.sort(),i.push(...r)),i}},_z=t=>({cache:mz(t.cacheSize),parseClassName:vz(t),sortModifiers:yz(t),...az(t)}),xz=/\s+/,bz=(t,e)=>{const{parseClassName:n,getClassGroupId:i,getConflictingClassGroupIds:r,sortModifiers:s}=e,o=[],c=t.trim().split(xz);let u="";for(let f=c.length-1;f>=0;f-=1){const h=c[f],{isExternal:p,modifiers:m,hasImportantModifier:v,baseClassName:_,maybePostfixModifierPosition:w}=n(h);if(p){u=h+(u.length>0?" "+u:u);continue}let y=!!w,x=i(y?_.substring(0,w):_);if(!x){if(!y){u=h+(u.length>0?" "+u:u);continue}if(x=i(_),!x){u=h+(u.length>0?" "+u:u);continue}y=!1}const M=m.length===0?"":m.length===1?m[0]:s(m).join(":"),A=v?M+O0:M,T=A+x;if(o.indexOf(T)>-1)continue;o.push(T);const D=r(x,y);for(let I=0;I<D.length;++I){const U=D[I];o.push(A+U)}u=h+(u.length>0?" "+u:u)}return u},Sz=(...t)=>{let e=0,n,i,r="";for(;e<t.length;)(n=t[e++])&&(i=_C(n))&&(r&&(r+=" "),r+=i);return r},_C=t=>{if(typeof t=="string")return t;let e,n="";for(let i=0;i<t.length;i++)t[i]&&(e=_C(t[i]))&&(n&&(n+=" "),n+=e);return n},wz=(t,...e)=>{let n,i,r,s;const o=u=>{const f=e.reduce((h,p)=>p(h),t());return n=_z(f),i=n.cache.get,r=n.cache.set,s=c,c(u)},c=u=>{const f=i(u);if(f)return f;const h=bz(u,n);return r(u,h),h};return s=o,(...u)=>s(Sz(...u))},Ez=[],Qn=t=>{const e=n=>n[t]||Ez;return e.isThemeGetter=!0,e},xC=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,bC=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Mz=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Tz=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Az=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Cz=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Rz=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Pz=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,fa=t=>Mz.test(t),Xt=t=>!!t&&!Number.isNaN(Number(t)),ha=t=>!!t&&Number.isInteger(Number(t)),ng=t=>t.endsWith("%")&&Xt(t.slice(0,-1)),Es=t=>Tz.test(t),SC=()=>!0,kz=t=>Az.test(t)&&!Cz.test(t),jy=()=>!1,Lz=t=>Rz.test(t),Dz=t=>Pz.test(t),Nz=t=>!dt(t)&&!mt(t),Iz=t=>Na(t,MC,jy),dt=t=>xC.test(t),Ya=t=>Na(t,TC,kz),cE=t=>Na(t,Gz,Xt),Uz=t=>Na(t,CC,SC),Fz=t=>Na(t,AC,jy),uE=t=>Na(t,wC,jy),Oz=t=>Na(t,EC,Dz),qd=t=>Na(t,RC,Lz),mt=t=>bC.test(t),Oc=t=>Po(t,TC),Bz=t=>Po(t,AC),dE=t=>Po(t,wC),zz=t=>Po(t,MC),Vz=t=>Po(t,EC),Yd=t=>Po(t,RC,!0),Hz=t=>Po(t,CC,!0),Na=(t,e,n)=>{const i=xC.exec(t);return i?i[1]?e(i[1]):n(i[2]):!1},Po=(t,e,n=!1)=>{const i=bC.exec(t);return i?i[1]?e(i[1]):n:!1},wC=t=>t==="position"||t==="percentage",EC=t=>t==="image"||t==="url",MC=t=>t==="length"||t==="size"||t==="bg-size",TC=t=>t==="length",Gz=t=>t==="number",AC=t=>t==="family-name",CC=t=>t==="number"||t==="weight",RC=t=>t==="shadow",jz=()=>{const t=Qn("color"),e=Qn("font"),n=Qn("text"),i=Qn("font-weight"),r=Qn("tracking"),s=Qn("leading"),o=Qn("breakpoint"),c=Qn("container"),u=Qn("spacing"),f=Qn("radius"),h=Qn("shadow"),p=Qn("inset-shadow"),m=Qn("text-shadow"),v=Qn("drop-shadow"),_=Qn("blur"),w=Qn("perspective"),y=Qn("aspect"),x=Qn("ease"),M=Qn("animate"),A=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],D=()=>[...T(),mt,dt],I=()=>["auto","hidden","clip","visible","scroll"],U=()=>["auto","contain","none"],S=()=>[mt,dt,u],R=()=>[fa,"full","auto",...S()],V=()=>[ha,"none","subgrid",mt,dt],F=()=>["auto",{span:["full",ha,mt,dt]},ha,mt,dt],j=()=>[ha,"auto",mt,dt],Z=()=>["auto","min","max","fr",mt,dt],H=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],q=()=>["start","end","center","stretch","center-safe","end-safe"],J=()=>["auto",...S()],Q=()=>[fa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...S()],W=()=>[fa,"screen","full","dvw","lvw","svw","min","max","fit",...S()],X=()=>[fa,"screen","full","lh","dvh","lvh","svh","min","max","fit",...S()],K=()=>[t,mt,dt],B=()=>[...T(),dE,uE,{position:[mt,dt]}],ie=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ve=()=>["auto","cover","contain",zz,Iz,{size:[mt,dt]}],Ce=()=>[ng,Oc,Ya],we=()=>["","none","full",f,mt,dt],ne=()=>["",Xt,Oc,Ya],_e=()=>["solid","dashed","dotted","double"],Se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ie=()=>[Xt,ng,dE,uE],et=()=>["","none",_,mt,dt],xt=()=>["none",Xt,mt,dt],pn=()=>["none",Xt,mt,dt],ht=()=>[Xt,mt,dt],Ut=()=>[fa,"full",...S()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Es],breakpoint:[Es],color:[SC],container:[Es],"drop-shadow":[Es],ease:["in","out","in-out"],font:[Nz],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Es],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Es],shadow:[Es],spacing:["px",Xt],text:[Es],"text-shadow":[Es],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",fa,dt,mt,y]}],container:["container"],columns:[{columns:[Xt,dt,mt,c]}],"break-after":[{"break-after":A()}],"break-before":[{"break-before":A()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:D()}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:U()}],"overscroll-x":[{"overscroll-x":U()}],"overscroll-y":[{"overscroll-y":U()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{"inset-s":R(),start:R()}],end:[{"inset-e":R(),end:R()}],"inset-bs":[{"inset-bs":R()}],"inset-be":[{"inset-be":R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[ha,"auto",mt,dt]}],basis:[{basis:[fa,"full","auto",c,...S()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Xt,fa,"auto","initial","none",dt]}],grow:[{grow:["",Xt,mt,dt]}],shrink:[{shrink:["",Xt,mt,dt]}],order:[{order:[ha,"first","last","none",mt,dt]}],"grid-cols":[{"grid-cols":V()}],"col-start-end":[{col:F()}],"col-start":[{"col-start":j()}],"col-end":[{"col-end":j()}],"grid-rows":[{"grid-rows":V()}],"row-start-end":[{row:F()}],"row-start":[{"row-start":j()}],"row-end":[{"row-end":j()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Z()}],"auto-rows":[{"auto-rows":Z()}],gap:[{gap:S()}],"gap-x":[{"gap-x":S()}],"gap-y":[{"gap-y":S()}],"justify-content":[{justify:[...H(),"normal"]}],"justify-items":[{"justify-items":[...q(),"normal"]}],"justify-self":[{"justify-self":["auto",...q()]}],"align-content":[{content:["normal",...H()]}],"align-items":[{items:[...q(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...q(),{baseline:["","last"]}]}],"place-content":[{"place-content":H()}],"place-items":[{"place-items":[...q(),"baseline"]}],"place-self":[{"place-self":["auto",...q()]}],p:[{p:S()}],px:[{px:S()}],py:[{py:S()}],ps:[{ps:S()}],pe:[{pe:S()}],pbs:[{pbs:S()}],pbe:[{pbe:S()}],pt:[{pt:S()}],pr:[{pr:S()}],pb:[{pb:S()}],pl:[{pl:S()}],m:[{m:J()}],mx:[{mx:J()}],my:[{my:J()}],ms:[{ms:J()}],me:[{me:J()}],mbs:[{mbs:J()}],mbe:[{mbe:J()}],mt:[{mt:J()}],mr:[{mr:J()}],mb:[{mb:J()}],ml:[{ml:J()}],"space-x":[{"space-x":S()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":S()}],"space-y-reverse":["space-y-reverse"],size:[{size:Q()}],"inline-size":[{inline:["auto",...W()]}],"min-inline-size":[{"min-inline":["auto",...W()]}],"max-inline-size":[{"max-inline":["none",...W()]}],"block-size":[{block:["auto",...X()]}],"min-block-size":[{"min-block":["auto",...X()]}],"max-block-size":[{"max-block":["none",...X()]}],w:[{w:[c,"screen",...Q()]}],"min-w":[{"min-w":[c,"screen","none",...Q()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...Q()]}],h:[{h:["screen","lh",...Q()]}],"min-h":[{"min-h":["screen","lh","none",...Q()]}],"max-h":[{"max-h":["screen","lh",...Q()]}],"font-size":[{text:["base",n,Oc,Ya]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,Hz,Uz]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ng,dt]}],"font-family":[{font:[Bz,Fz,e]}],"font-features":[{"font-features":[dt]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[r,mt,dt]}],"line-clamp":[{"line-clamp":[Xt,"none",mt,cE]}],leading:[{leading:[s,...S()]}],"list-image":[{"list-image":["none",mt,dt]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",mt,dt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:K()}],"text-color":[{text:K()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[..._e(),"wavy"]}],"text-decoration-thickness":[{decoration:[Xt,"from-font","auto",mt,Ya]}],"text-decoration-color":[{decoration:K()}],"underline-offset":[{"underline-offset":[Xt,"auto",mt,dt]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:S()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",mt,dt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",mt,dt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:B()}],"bg-repeat":[{bg:ie()}],"bg-size":[{bg:ve()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ha,mt,dt],radial:["",mt,dt],conic:[ha,mt,dt]},Vz,Oz]}],"bg-color":[{bg:K()}],"gradient-from-pos":[{from:Ce()}],"gradient-via-pos":[{via:Ce()}],"gradient-to-pos":[{to:Ce()}],"gradient-from":[{from:K()}],"gradient-via":[{via:K()}],"gradient-to":[{to:K()}],rounded:[{rounded:we()}],"rounded-s":[{"rounded-s":we()}],"rounded-e":[{"rounded-e":we()}],"rounded-t":[{"rounded-t":we()}],"rounded-r":[{"rounded-r":we()}],"rounded-b":[{"rounded-b":we()}],"rounded-l":[{"rounded-l":we()}],"rounded-ss":[{"rounded-ss":we()}],"rounded-se":[{"rounded-se":we()}],"rounded-ee":[{"rounded-ee":we()}],"rounded-es":[{"rounded-es":we()}],"rounded-tl":[{"rounded-tl":we()}],"rounded-tr":[{"rounded-tr":we()}],"rounded-br":[{"rounded-br":we()}],"rounded-bl":[{"rounded-bl":we()}],"border-w":[{border:ne()}],"border-w-x":[{"border-x":ne()}],"border-w-y":[{"border-y":ne()}],"border-w-s":[{"border-s":ne()}],"border-w-e":[{"border-e":ne()}],"border-w-bs":[{"border-bs":ne()}],"border-w-be":[{"border-be":ne()}],"border-w-t":[{"border-t":ne()}],"border-w-r":[{"border-r":ne()}],"border-w-b":[{"border-b":ne()}],"border-w-l":[{"border-l":ne()}],"divide-x":[{"divide-x":ne()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ne()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[..._e(),"hidden","none"]}],"divide-style":[{divide:[..._e(),"hidden","none"]}],"border-color":[{border:K()}],"border-color-x":[{"border-x":K()}],"border-color-y":[{"border-y":K()}],"border-color-s":[{"border-s":K()}],"border-color-e":[{"border-e":K()}],"border-color-bs":[{"border-bs":K()}],"border-color-be":[{"border-be":K()}],"border-color-t":[{"border-t":K()}],"border-color-r":[{"border-r":K()}],"border-color-b":[{"border-b":K()}],"border-color-l":[{"border-l":K()}],"divide-color":[{divide:K()}],"outline-style":[{outline:[..._e(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Xt,mt,dt]}],"outline-w":[{outline:["",Xt,Oc,Ya]}],"outline-color":[{outline:K()}],shadow:[{shadow:["","none",h,Yd,qd]}],"shadow-color":[{shadow:K()}],"inset-shadow":[{"inset-shadow":["none",p,Yd,qd]}],"inset-shadow-color":[{"inset-shadow":K()}],"ring-w":[{ring:ne()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:K()}],"ring-offset-w":[{"ring-offset":[Xt,Ya]}],"ring-offset-color":[{"ring-offset":K()}],"inset-ring-w":[{"inset-ring":ne()}],"inset-ring-color":[{"inset-ring":K()}],"text-shadow":[{"text-shadow":["none",m,Yd,qd]}],"text-shadow-color":[{"text-shadow":K()}],opacity:[{opacity:[Xt,mt,dt]}],"mix-blend":[{"mix-blend":[...Se(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Se()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Xt]}],"mask-image-linear-from-pos":[{"mask-linear-from":Ie()}],"mask-image-linear-to-pos":[{"mask-linear-to":Ie()}],"mask-image-linear-from-color":[{"mask-linear-from":K()}],"mask-image-linear-to-color":[{"mask-linear-to":K()}],"mask-image-t-from-pos":[{"mask-t-from":Ie()}],"mask-image-t-to-pos":[{"mask-t-to":Ie()}],"mask-image-t-from-color":[{"mask-t-from":K()}],"mask-image-t-to-color":[{"mask-t-to":K()}],"mask-image-r-from-pos":[{"mask-r-from":Ie()}],"mask-image-r-to-pos":[{"mask-r-to":Ie()}],"mask-image-r-from-color":[{"mask-r-from":K()}],"mask-image-r-to-color":[{"mask-r-to":K()}],"mask-image-b-from-pos":[{"mask-b-from":Ie()}],"mask-image-b-to-pos":[{"mask-b-to":Ie()}],"mask-image-b-from-color":[{"mask-b-from":K()}],"mask-image-b-to-color":[{"mask-b-to":K()}],"mask-image-l-from-pos":[{"mask-l-from":Ie()}],"mask-image-l-to-pos":[{"mask-l-to":Ie()}],"mask-image-l-from-color":[{"mask-l-from":K()}],"mask-image-l-to-color":[{"mask-l-to":K()}],"mask-image-x-from-pos":[{"mask-x-from":Ie()}],"mask-image-x-to-pos":[{"mask-x-to":Ie()}],"mask-image-x-from-color":[{"mask-x-from":K()}],"mask-image-x-to-color":[{"mask-x-to":K()}],"mask-image-y-from-pos":[{"mask-y-from":Ie()}],"mask-image-y-to-pos":[{"mask-y-to":Ie()}],"mask-image-y-from-color":[{"mask-y-from":K()}],"mask-image-y-to-color":[{"mask-y-to":K()}],"mask-image-radial":[{"mask-radial":[mt,dt]}],"mask-image-radial-from-pos":[{"mask-radial-from":Ie()}],"mask-image-radial-to-pos":[{"mask-radial-to":Ie()}],"mask-image-radial-from-color":[{"mask-radial-from":K()}],"mask-image-radial-to-color":[{"mask-radial-to":K()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":T()}],"mask-image-conic-pos":[{"mask-conic":[Xt]}],"mask-image-conic-from-pos":[{"mask-conic-from":Ie()}],"mask-image-conic-to-pos":[{"mask-conic-to":Ie()}],"mask-image-conic-from-color":[{"mask-conic-from":K()}],"mask-image-conic-to-color":[{"mask-conic-to":K()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:B()}],"mask-repeat":[{mask:ie()}],"mask-size":[{mask:ve()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",mt,dt]}],filter:[{filter:["","none",mt,dt]}],blur:[{blur:et()}],brightness:[{brightness:[Xt,mt,dt]}],contrast:[{contrast:[Xt,mt,dt]}],"drop-shadow":[{"drop-shadow":["","none",v,Yd,qd]}],"drop-shadow-color":[{"drop-shadow":K()}],grayscale:[{grayscale:["",Xt,mt,dt]}],"hue-rotate":[{"hue-rotate":[Xt,mt,dt]}],invert:[{invert:["",Xt,mt,dt]}],saturate:[{saturate:[Xt,mt,dt]}],sepia:[{sepia:["",Xt,mt,dt]}],"backdrop-filter":[{"backdrop-filter":["","none",mt,dt]}],"backdrop-blur":[{"backdrop-blur":et()}],"backdrop-brightness":[{"backdrop-brightness":[Xt,mt,dt]}],"backdrop-contrast":[{"backdrop-contrast":[Xt,mt,dt]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Xt,mt,dt]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Xt,mt,dt]}],"backdrop-invert":[{"backdrop-invert":["",Xt,mt,dt]}],"backdrop-opacity":[{"backdrop-opacity":[Xt,mt,dt]}],"backdrop-saturate":[{"backdrop-saturate":[Xt,mt,dt]}],"backdrop-sepia":[{"backdrop-sepia":["",Xt,mt,dt]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":S()}],"border-spacing-x":[{"border-spacing-x":S()}],"border-spacing-y":[{"border-spacing-y":S()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",mt,dt]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Xt,"initial",mt,dt]}],ease:[{ease:["linear","initial",x,mt,dt]}],delay:[{delay:[Xt,mt,dt]}],animate:[{animate:["none",M,mt,dt]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,mt,dt]}],"perspective-origin":[{"perspective-origin":D()}],rotate:[{rotate:xt()}],"rotate-x":[{"rotate-x":xt()}],"rotate-y":[{"rotate-y":xt()}],"rotate-z":[{"rotate-z":xt()}],scale:[{scale:pn()}],"scale-x":[{"scale-x":pn()}],"scale-y":[{"scale-y":pn()}],"scale-z":[{"scale-z":pn()}],"scale-3d":["scale-3d"],skew:[{skew:ht()}],"skew-x":[{"skew-x":ht()}],"skew-y":[{"skew-y":ht()}],transform:[{transform:[mt,dt,"","none","gpu","cpu"]}],"transform-origin":[{origin:D()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ut()}],"translate-x":[{"translate-x":Ut()}],"translate-y":[{"translate-y":Ut()}],"translate-z":[{"translate-z":Ut()}],"translate-none":["translate-none"],accent:[{accent:K()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:K()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",mt,dt]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":S()}],"scroll-mx":[{"scroll-mx":S()}],"scroll-my":[{"scroll-my":S()}],"scroll-ms":[{"scroll-ms":S()}],"scroll-me":[{"scroll-me":S()}],"scroll-mbs":[{"scroll-mbs":S()}],"scroll-mbe":[{"scroll-mbe":S()}],"scroll-mt":[{"scroll-mt":S()}],"scroll-mr":[{"scroll-mr":S()}],"scroll-mb":[{"scroll-mb":S()}],"scroll-ml":[{"scroll-ml":S()}],"scroll-p":[{"scroll-p":S()}],"scroll-px":[{"scroll-px":S()}],"scroll-py":[{"scroll-py":S()}],"scroll-ps":[{"scroll-ps":S()}],"scroll-pe":[{"scroll-pe":S()}],"scroll-pbs":[{"scroll-pbs":S()}],"scroll-pbe":[{"scroll-pbe":S()}],"scroll-pt":[{"scroll-pt":S()}],"scroll-pr":[{"scroll-pr":S()}],"scroll-pb":[{"scroll-pb":S()}],"scroll-pl":[{"scroll-pl":S()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",mt,dt]}],fill:[{fill:["none",...K()]}],"stroke-w":[{stroke:[Xt,Oc,Ya,cE]}],stroke:[{stroke:["none",...K()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Wz=wz(jz);function Si(...t){return Wz(nz(t))}const $z=O.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",children:[O.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1Z",fill:"#4285F4"}),O.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23Z",fill:"#34A853"}),O.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18A10.96 10.96 0 0 0 1 12c0 1.77.42 3.44 1.18 4.93l3.66-2.84Z",fill:"#FBBC05"}),O.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53Z",fill:"#EA4335"})]}),Xz=O.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:O.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12Z"})}),qz={google:$z,github:Xz},Yz={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",apple:"Apple"};function Kz(t){return Yz[t]||String(t||"").replace(/-/g," ")}function Zz(){const{isOpen:t,closeLoginModal:e}=AT(),{enabled:n,signedIn:i,refreshUser:r,signInWithPassword:s,signUp:o,signInWithOAuth:c,getPublicAuthConfig:u}=Ro(),[f,h]=k.useState("signin"),[p,m]=k.useState(""),[v,_]=k.useState(""),[w,y]=k.useState(""),[x,M]=k.useState(!1),[A,T]=k.useState(null),[D,I]=k.useState(null),[U,S]=k.useState(!1),[R,V]=k.useState(!0),[F,j]=k.useState([]),[Z,H]=k.useState(8);k.useEffect(()=>{t&&(T(null),I(null),h("signin"),m(""),_(""),y(""),S(!1))},[t]),k.useEffect(()=>{if(!t||!n){V(!1);return}let W=!0;return(async()=>{const{data:X,error:K}=await u();if(W){if(K||!X)j(["google","github"]);else{const B=Array.isArray(X.oAuthProviders)?X.oAuthProviders:[],ie=Array.isArray(X.customOAuthProviders)?X.customOAuthProviders:[];j([...B,...ie]),typeof X.passwordMinLength=="number"&&X.passwordMinLength>0&&H(X.passwordMinLength)}V(!1)}})(),()=>{W=!1}},[t,n,u]),k.useEffect(()=>{t&&i&&e()},[t,i,e]);const q=k.useMemo(()=>typeof window>"u"?"":window.location.origin+"/",[]),J=k.useCallback(async W=>{T(null),M(!0);try{const{error:X}=await c(W,q);X&&T(X.message||String(X))}finally{M(!1)}},[c,q]),Q=k.useCallback(async W=>{W.preventDefault(),T(null),M(!0);try{if(f==="signup"){const{data:K,error:B}=await o({email:p.trim(),password:v,name:w.trim()||void 0});if(B){T(B.message||String(B));return}if(K?.requireEmailVerification){I("Check your email for a verification link."),h("signin");return}await r();return}const{error:X}=await s({email:p.trim(),password:v});if(X){T(X.message||String(X));return}await r()}finally{M(!1)}},[f,p,v,w,o,s,r]);return k.useEffect(()=>{if(!t)return;const W=X=>{X.key==="Escape"&&e()};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[t,e]),n?O.jsx(I0,{children:t&&O.jsxs(Is.div,{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[O.jsx(Is.div,{className:"absolute inset-0 bg-black/40 dark:bg-black/60 ",onClick:e,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}}),O.jsxs(Is.div,{className:"relative w-full max-w-[420px] rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 p-6 shadow-2xl",initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:{duration:.2},onClick:W=>W.stopPropagation(),children:[O.jsx("button",{type:"button",onClick:e,className:"absolute right-4 top-4 text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",children:O.jsx(tz,{className:"h-5 w-5"})}),O.jsxs("div",{className:"text-center mb-6",children:[O.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[O.jsx("img",{src:"/app-icon.png",alt:"",width:28,height:28,className:"rounded-md"}),O.jsx("span",{className:"text-lg font-semibold text-oai-black dark:text-white",children:"Token Tracker"})]}),O.jsx("p",{className:"text-sm text-oai-gray-500",children:"Sign in to join the leaderboard"})]}),D&&O.jsx("div",{className:"mb-4 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900/50 px-3 py-2 text-xs text-oai-gray-700 dark:text-oai-gray-300",children:D}),A&&O.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",role:"alert",children:A}),O.jsx("div",{className:"space-y-2.5 mb-5",children:R?O.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900 animate-pulse"}):F.map(W=>O.jsxs("button",{type:"button",disabled:x,onClick:()=>J(W),className:Si("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors disabled:opacity-50","flex items-center justify-center gap-2.5"),children:[qz[W]||null,"Continue with ",Kz(W)]},W))}),U?O.jsxs(O.Fragment,{children:[O.jsxs("div",{className:"relative mb-5",children:[O.jsx("div",{className:"absolute inset-0 flex items-center",children:O.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),O.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:O.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:"email"})})]}),O.jsxs("div",{className:"flex rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 bg-oai-gray-50 dark:bg-oai-gray-900/50 mb-4",children:[O.jsx("button",{type:"button",className:Si("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",f==="signin"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{h("signin"),T(null)},children:"Sign In"}),O.jsx("button",{type:"button",className:Si("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",f==="signup"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{h("signup"),T(null)},children:"Sign Up"})]}),O.jsxs("form",{onSubmit:Q,className:"space-y-3",children:[f==="signup"&&O.jsxs("div",{children:[O.jsx("label",{htmlFor:"modal-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:"Name"}),O.jsx("input",{id:"modal-name",type:"text",autoComplete:"name",value:w,onChange:W=>y(W.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500",placeholder:"Optional"})]}),O.jsxs("div",{children:[O.jsx("label",{htmlFor:"modal-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:"Email"}),O.jsx("input",{id:"modal-email",type:"email",autoComplete:"email",required:!0,value:p,onChange:W=>m(W.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),O.jsxs("div",{children:[O.jsx("label",{htmlFor:"modal-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:"Password"}),O.jsx("input",{id:"modal-password",type:"password",autoComplete:f==="signup"?"new-password":"current-password",required:!0,minLength:f==="signup"?Z:void 0,value:v,onChange:W=>_(W.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"}),f==="signup"&&O.jsxs("p",{className:"mt-1 text-xs text-oai-gray-400 dark:text-oai-gray-600",children:["At least ",Z," characters"]})]}),O.jsx("button",{type:"submit",disabled:x,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:f==="signup"?"Create Account":"Sign In"})]})]}):O.jsxs(O.Fragment,{children:[O.jsxs("div",{className:"relative mb-5",children:[O.jsx("div",{className:"absolute inset-0 flex items-center",children:O.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),O.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:O.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:"or"})})]}),O.jsxs("button",{type:"button",onClick:()=>S(!0),className:Si("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors","flex items-center justify-center gap-2.5"),children:[O.jsx(Z5,{className:"h-[18px] w-[18px] text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75}),"Continue with Email"]})]})]})]})}):null}const Jz={VITE_INSFORGE_BASE_URL:"https://b46ug8xu.us-east.insforge.app"};function Qz(){if(typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"))return"";const e=typeof import.meta<"u"?Jz:void 0;return(e?.VITE_TOKENTRACKER_BACKEND_BASE_URL||e?.VITE_INSFORGE_BASE_URL||"").trim()}function f$(){return Co()}function h$(){if(typeof Intl>"u"||!Intl.DateTimeFormat)return null;try{return Intl.DateTimeFormat().resolvedOptions().timeZone||null}catch{return null}}function p$(t=new Date){const e=t instanceof Date?t:new Date(t);if(!Number.isFinite(e.getTime()))return 0;const n=e.getTimezoneOffset();return Number.isFinite(n)?-n:0}function PC(t){if(!Number.isFinite(t)||t===0)return"UTC";const e=t>=0?"+":"-",n=Math.abs(t),i=String(Math.floor(n/60)).padStart(2,"0"),r=String(n%60).padStart(2,"0");return`UTC${e}${i}:${r}`}function m$({timeZone:t,offsetMinutes:e}={}){const n=PC(e);return t&&t!=="UTC"?`${t} (${n})`:n}function g$({timeZone:t,offsetMinutes:e}={}){return Number.isFinite(e)?PC(e):t||"UTC"}function v$({timeZone:t,offsetMinutes:e,date:n=new Date}={}){const i=n instanceof Date?n:new Date(n);if(!Number.isFinite(i.getTime()))return"";if(t&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const o=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i).reduce((h,p)=>(p.type&&p.value&&(h[p.type]=p.value),h),{}),c=o.year,u=o.month,f=o.day;if(c&&u&&f)return`${c}-${u}-${f}`}catch{}if(typeof e=="number"&&Number.isFinite(e)){const r=new Date(i.getTime()+e*6e4);return tV(r)}return nV(i)}function eV({timeZone:t,offsetMinutes:e,date:n=new Date}={}){const i=n instanceof Date?n:new Date(n);if(!Number.isFinite(i.getTime()))return null;if(t&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const o=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i).reduce((h,p)=>(p.type&&p.value&&(h[p.type]=p.value),h),{}),c=Number(o.year),u=Number(o.month),f=Number(o.day);if(Number.isFinite(c)&&Number.isFinite(u)&&Number.isFinite(f))return{year:c,month:u,day:f}}catch{}if(typeof e=="number"&&Number.isFinite(e)){const r=new Date(i.getTime()+e*6e4);return{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate()}}return{year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()}}function y$({timeZone:t,offsetMinutes:e}={}){return t?`tz:${t}`:typeof e=="number"&&Number.isFinite(e)?`offset:${Math.trunc(e)}`:"utc"}function tV(t){const e=t.getUTCFullYear(),n=String(t.getUTCMonth()+1).padStart(2,"0"),i=String(t.getUTCDate()).padStart(2,"0");return`${e}-${n}-${i}`}function nV(t){const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${i}`}function kn(t){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())).toISOString().slice(0,10)}function fs(t){const e=t instanceof Date?t:new Date(t);if(!Number.isFinite(e.getTime()))return"";const n=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${n}-${i}-${r}`}function iV(t){if(!t)return null;const e=String(t).trim(),n=e.split("-");if(n.length!==3)return null;const i=Number(n[0]),r=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(s))return null;const o=new Date(Date.UTC(i,r,s));return Number.isFinite(o.getTime())&&kn(o)===e?o:null}function rV(t){if(!t)return"";const e=t.year,n=String(t.month).padStart(2,"0"),i=String(t.day).padStart(2,"0");return!e||!n||!i?"":`${e}-${n}-${i}`}function sV(t,{timeZone:e,offsetMinutes:n,now:i}={}){const r=i instanceof Date&&Number.isFinite(i.getTime())?i:new Date,s=eV({timeZone:e,offsetMinutes:n,date:r});if(!s){const u=fs(new Date);return{from:u,to:u}}const o=rV(s),c=iV(o);if(!c)return{from:o,to:o};if(t==="day")return{from:o,to:o};if(t==="week"){const u=new Date(c),h=(u.getUTCDay()+6)%7;u.setUTCDate(u.getUTCDate()-h);const p=new Date(u);return p.setUTCDate(p.getUTCDate()+6),{from:kn(u),to:kn(p)}}if(t==="month"){const u=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth(),1)),f=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth()+1,0));return{from:kn(u),to:kn(f)}}if(t==="total"){const u=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth()-23,1));return{from:kn(u),to:o}}return sV("week")}function _$(t){if(t==null)return"-";try{if(typeof t=="bigint")return new Intl.NumberFormat().format(t);if(typeof t=="number")return new Intl.NumberFormat().format(t);const e=String(t).trim();return/^[0-9]+$/.test(e)?new Intl.NumberFormat().format(BigInt(e)):e}catch{return String(t)}}function x$(t,{thousandSuffix:e="K",millionSuffix:n="M",billionSuffix:i="B",decimals:r=1}={}){const s=Number(String(t));if(!Number.isFinite(s))return"-";const o=s<0?"-":"",c=Math.abs(s),u=Math.max(0,Math.min(6,Math.floor(r)));if(c<1e3)return`${o}${String(c)}`;const f=(v,_)=>{const w=v.toFixed(u),y=Number(w).toString();return`${o}${y}${_}`},h=(v,_,w)=>{const y=v.toFixed(u),x=Number(y);return w&&x>=1e3?f(x/1e3,w):`${o}${x.toString()}${_}`};if(c>=1e9)return f(c/1e9,i);if(c>=1e6)return h(c/1e6,n,i);const p=c/1e3,m=Number(p.toFixed(u));return m>=1e3?f(m/1e3,n):f(m,e)}function kC(t){const e=Number(String(t));return Number.isFinite(e)?e:null}function b$(t,{decimals:e=2}={}){if(t==null)return"-";const n=String(t).trim();if(!n)return"-";const i=n.match(/^(-?\d+)(?:\.(\d+))?$/);if(!i)return n;const r=i[1],s=i[2]||"";let o=r;try{o=new Intl.NumberFormat().format(BigInt(r))}catch{o=r}const c=Math.max(0,Math.min(6,Math.floor(e))),u=c?s.slice(0,c).padEnd(c,"0"):"",f=r.startsWith("-")?"-":"",h=c?`${o.replace("-","")}.${u}`:o.replace("-","");return`${f}$${h}`}function gh(t){if(typeof t!="string")return null;const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.trim());if(!e)return null;const n=Number(e[1]),i=Number(e[2])-1,r=Number(e[3]),s=new Date(Date.UTC(n,i,r));return Number.isFinite(s.getTime())&&kn(s)===t.trim()?s:null}function uo(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()+e))}function aV(t,e){const n=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())-Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate());return Math.floor(n/864e5)}function ig(t,e){if(!Array.isArray(t)||t.length===0)return 0;const n=t.length,i=(n-1)*e,r=Math.floor(i),s=i-r,o=t[r]??t[n-1],c=t[Math.min(n-1,r+1)]??t[n-1];return Math.round(o+(c-o)*s)}function oV(t){return t<=0?0:t>=4?4:t}function LC({weeks:t=52,now:e,weekStartsOn:n="sun"}={}){const i=e instanceof Date&&Number.isFinite(e.getTime())?e:new Date,r=fs(i),s=gh(r)||new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),o=n==="mon"?1:0,c=s.getUTCDay(),u=uo(s,-((c-o+7)%7)),f=uo(u,-7*(Math.max(1,t)-1));return{from:kn(f),to:r}}function lV({dailyRows:t,weeks:e=52,to:n,weekStartsOn:i="sun"}={}){const r=gh(n)||new Date(Date.UTC(new Date().getFullYear(),new Date().getMonth(),new Date().getDate())),{from:s}=LC({weeks:e,now:r,weekStartsOn:i}),o=gh(s)||uo(r,-(e*7-1)),c=(()=>{const T=(o.getUTCDay()-(i==="mon"?1:0)+7)%7;return uo(o,-T)})(),u=new Map;for(const M of Array.isArray(t)?t:[]){const A=typeof M?.day=="string"?M.day:null;if(!A)continue;const T=kC(M?.billable_total_tokens??M?.total_tokens)??0;u.set(A,Math.max(0,T))}const f=aV(c,r)+1,h=Math.ceil(f/7),p=[];for(let M=0;M<f;M++){const A=uo(c,M),T=kn(A),D=u.get(T)??0;D>0&&p.push(D)}p.sort((M,A)=>M-A);const m=ig(p,.5),v=ig(p,.75),_=ig(p,.9);function w(M){return!M||M<=0?0:M<=m?1:M<=v?2:M<=_?3:4}const y=[];for(let M=0;M<h;M++){const A=[];for(let T=0;T<7;T++){const D=M*7+T,I=uo(c,D);if(I.getTime()>r.getTime()){A.push(null);continue}const U=kn(I),S=u.get(U)??0;A.push({day:U,value:S,level:oV(w(S))})}y.push(A)}const x=y.length>e?y.slice(y.length-e):y;return{from:s,to:kn(r),weeks:x,thresholds:{t1:m,t2:v,t3:_}}}function cV({dailyRows:t,to:e}={}){const n=gh(e)||new Date(Date.UTC(new Date().getFullYear(),new Date().getMonth(),new Date().getDate())),i=new Map;for(const s of Array.isArray(t)?t:[]){const o=typeof s?.day=="string"?s.day:null;if(!o)continue;const c=kC(s?.billable_total_tokens??s?.total_tokens)??0;i.set(o,Math.max(0,c))}let r=0;for(let s=0;s<370;s++){const o=kn(uo(n,-s));if((i.get(o)??0)>0){r+=1;continue}break}return r}const Oh={},DC="tokentracker",uV=["victorgpt/tokentracker","spacedriveapp/spacedrive","acme/alpha","acme/beta","neo/nebula","signal/flux","matrix/terminal","orbit/atlas","lumen/core","delta/horizon"],fE=["NEO","TRINITY","MORPHEUS","ORACLE","CYPHER","SWITCH","APOC","TANK","SMITH","SERAPH","NIOBE","MOUSE","DOZER","LINK","BLADE"];function _r(){if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock")||"").toLowerCase();if(e==="0"||e==="false"||e==="off"||e==="no")return!1;if(e==="1"||e==="true"||e==="on"||e==="yes")return!0}if(typeof import.meta<"u"&&Oh){const t="".toLowerCase();if(t==="1"||t==="true")return!0}return!1}function dV(){if(typeof import.meta<"u"&&Oh){const t="".trim();if(t)return t;const e="".trim();if(e)return e}if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock_now")||"").trim();if(e)return e;const n=String(t.get("mock_today")||"").trim();if(n)return n}return""}function fV(t){if(!t)return null;const e=String(t).trim();if(!e)return null;if(/^\d{4}-\d{2}-\d{2}$/.test(e)){const[i,r,s]=e.split("-").map(Number);if(!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(s))return null;const o=new Date(i,r-1,s,12,0,0);return Number.isFinite(o.getTime())?o:null}const n=new Date(e);return Number.isFinite(n.getTime())?n:null}function S$(){return _r()?fV(dV()):null}function hV(){if(typeof import.meta<"u"&&Oh){const t="".trim();if(t)return t}if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock_seed")||"").trim();if(e)return e}return DC}function pV(){if(typeof import.meta<"u"&&Oh){const t="".trim(),e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock_missing")||"").trim(),n=Number(e);if(Number.isFinite(n)&&n>0)return Math.floor(n)}return 0}function Ru(t){return(t==null?hV():String(t)).trim()||DC}function Pu(t){let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function ki(t){if(typeof t!="string")return null;const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.trim());if(!e)return null;const n=Number(e[1]),i=Number(e[2])-1,r=Number(e[3]),s=new Date(Date.UTC(n,i,r));return Number.isFinite(s.getTime())&&kn(s)===t.trim()?s:null}function gu(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()+e))}function NC(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+e,1))}function mV(t){return`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,"0")}`}function Bl({from:t,to:e,seed:n}){const i=ki(fs(new Date))||new Date,r=ki(t)||i,s=ki(e)||r,o=[],c=Ru(n),u=Math.floor((Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())-Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate()))/864e5)+1;for(let f=0;f<u;f+=1){const h=gu(r,f),p=kn(h),m=Pu(`${c}:${p}`),v=m%1e3/1e3,_=.6+.4*Math.sin(f/6*Math.PI*.5),w=h.getUTCDay()===0||h.getUTCDay()===6?.65:1,y=18e3+Math.round(12e3*v),x=Math.max(0,Math.round(y*_*w)),M=Math.round(x*.46),A=Math.round(x*.34),T=Math.round(x*.14),D=Math.max(0,x-M-A-T);o.push({day:p,total_tokens:x,billable_total_tokens:x,input_tokens:M,output_tokens:A,cached_input_tokens:T,reasoning_output_tokens:D,conversation_count:1+m%5})}return o}function gV({day:t,seed:e}){const n=ki(t)||ki(fs(new Date))||new Date,i=kn(n),r=Ru(e),s=Array.from({length:48},(c,u)=>{const f=Math.floor(u/2),h=u%2===0?0:30,m=Pu(`${r}:${i}:${f}:${h}`)%1e3/1e3,v=(f+h/60)/24,_=.4+.6*Math.sin(v*Math.PI*2),w=900+Math.round(700*m),y=Math.max(0,Math.round(w*_)),x=Math.round(y*.46),M=Math.round(y*.34),A=Math.round(y*.14),T=Math.max(0,y-x-M-A);return{hour:`${i}T${String(f).padStart(2,"0")}:${String(h).padStart(2,"0")}:00`,total_tokens:y,billable_total_tokens:y,input_tokens:x,output_tokens:M,cached_input_tokens:A,reasoning_output_tokens:T}}),o=Math.max(0,Math.min(48,pV()));if(o>0){const c=Date.now(),u=s.map((p,m)=>{const v=Date.parse(p.hour);return Number.isFinite(v)&&v<=c?{index:m,ts:v}:null}).filter(Boolean),f=Math.max(0,u.length-o),h=u.slice(f);for(const p of h){const m=s[p.index];m&&(s[p.index]={...m,missing:!0})}}return s}function vV({months:t=24,to:e,seed:n}){const i=ki(e)||ki(fs(new Date))||new Date,r=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1)),s=Ru(n),o=[];for(let c=t-1;c>=0;c-=1){const u=NC(r,-c),f=mV(u),p=Pu(`${s}:${f}`)%1e3/1e3,m=.7+.3*Math.sin(o.length/6*Math.PI*.5),v=36e4+Math.round(2e5*p),_=Math.max(0,Math.round(v*m)),w=Math.round(_*.46),y=Math.round(_*.34),x=Math.round(_*.14),M=Math.max(0,_-w-y-x);o.push({month:f,total_tokens:_,billable_total_tokens:_,input_tokens:w,output_tokens:y,cached_input_tokens:x,reasoning_output_tokens:M})}return o}function Wy(t){return t.reduce((e,n)=>(e.total_tokens+=Number(n.total_tokens||0),e.billable_total_tokens+=Number(n.billable_total_tokens||n.total_tokens||0),e.input_tokens+=Number(n.input_tokens||0),e.output_tokens+=Number(n.output_tokens||0),e.cached_input_tokens+=Number(n.cached_input_tokens||0),e.reasoning_output_tokens+=Number(n.reasoning_output_tokens||0),e.conversation_count+=Number(n.conversation_count||0),e),{total_tokens:0,billable_total_tokens:0,input_tokens:0,output_tokens:0,cached_input_tokens:0,reasoning_output_tokens:0,conversation_count:0})}function yV(t,e=1.75){const n=Number(t||0);return!Number.isFinite(n)||n<=0?"0.000000":(n*e/1e6).toFixed(6)}function hE(t,e){const n=Number.isFinite(e)?e:0;return{total_tokens:Math.max(0,Math.round(t.total_tokens*n)),billable_total_tokens:Math.max(0,Math.round((t.billable_total_tokens??t.total_tokens)*n)),input_tokens:Math.max(0,Math.round(t.input_tokens*n)),output_tokens:Math.max(0,Math.round(t.output_tokens*n)),cached_input_tokens:Math.max(0,Math.round(t.cached_input_tokens*n)),reasoning_output_tokens:Math.max(0,Math.round(t.reasoning_output_tokens*n))}}function B0(t){return{...t,total_cost_usd:yV(t.total_tokens)}}function _V({from:t,to:e,seed:n}={}){const i=Bl({from:t,to:e,seed:n});return{from:t,to:e,data:i}}function xV({day:t,seed:e}={}){const n=ki(t)||new Date,i=kn(n),r=gV({day:i,seed:e});return{day:i,data:r}}function bV({months:t=24,to:e,seed:n}={}){const i=ki(e)||ki(fs(new Date))||new Date,r=kn(i),s=vV({months:t,to:r,seed:n}),o=NC(new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1)),-(t-1));return{from:kn(o),to:r,months:t,data:s}}function SV({from:t,to:e,seed:n,rolling:i=!0}={}){const r=Bl({from:t,to:e,seed:n}),s=Wy(r),o=B0(s),c=i?wV({to:e,seed:n}):null;return{from:t,to:e,days:r.length,totals:o,...c?{rolling:c}:{}}}function wV({to:t,seed:e}={}){const n=ki(t)||ki(fs(new Date))||new Date,i=kn(n),r=kn(gu(n,-6)),s=kn(gu(n,-29)),o=Bl({from:r,to:i,seed:e}),c=Bl({from:s,to:i,seed:e});return{last_7d:pE({rows:o,from:r,to:i}),last_30d:pE({rows:c,from:s,to:i})}}function pE({rows:t,from:e,to:n}={}){const i=Wy(t||[]),r=(t||[]).filter(o=>Number(o.billable_total_tokens??o.total_tokens)>0).length,s=r>0?Math.floor(i.billable_total_tokens/r):0;return{from:e,to:n,totals:{billable_total_tokens:i.billable_total_tokens,conversation_count:i.conversation_count},active_days:r,avg_per_active_day:s}}function EV({seed:t,limit:e=3}={}){const n=Ru(t),i=uV.map((r,s)=>{const c=12e4+Pu(`${n}:${r}`)%9e5,u=s%4*4200,f=Math.max(0,c+u),h=Math.max(0,Math.round(f*.96));return{project_key:r,project_ref:`https://github.com/${r}`,total_tokens:String(f),billable_total_tokens:String(h)}}).sort((r,s)=>Number(s.billable_total_tokens)-Number(r.billable_total_tokens)).slice(0,Math.max(1,Math.min(10,Math.floor(Number(e)||3))));return{generated_at:new Date().toISOString(),entries:i}}function MV(t){const e=ki(fs(new Date))||new Date,n=String(t).trim().toLowerCase()||"week";if(n==="total")return{from:"1970-01-01",to:"9999-12-31"};if(n==="month"){const o=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)),c=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+1,0));return{from:kn(o),to:kn(c)}}const i=e.getUTCDay(),r=kn(gu(e,-i)),s=kn(gu(e,-i+6));return{from:r,to:s}}function IC({seed:t,period:e,metric:n,limit:i=20,offset:r=0}={}){const s=Ru(t),o=Math.max(1,Math.min(100,Math.floor(Number(i)||20))),c=Math.max(0,Math.min(1e4,Math.floor(Number(r)||0))),u=String(n||"all").trim().toLowerCase()||"all",f=String(e||"week").trim().toLowerCase()||"week",h=f==="month"||f==="total"||f==="week"?f:"week",{from:p,to:m}=MV(h),v=250,_=v>0?Math.ceil(v/o):0,w=Math.floor(c/o)+1,y=Array.from({length:v},(U,S)=>{const R=S+1,V=`00000000-0000-0000-0000-${String(R).padStart(12,"0")}`,F=fE[R%fE.length],Z=18e4+Pu(`${s}:${F}:${R}`)%9e5,H=Math.max(0,Z+R*1200),q=Math.floor(H*.28),J=Math.floor(H*.18),Q=Math.floor(H*.12),W=Math.floor(H*.12),X=Math.floor(H*.1),K=Math.max(0,H-q-J-Q-W-X),B=R%7!==0;return{id:R,user_id:V,is_public:B,is_me:!1,display_name:B?F:"Anonymous",avatar_url:null,gpt_tokens:q,claude_tokens:J,gemini_tokens:Q,cursor_tokens:W,opencode_tokens:X,openclaw_tokens:K,other_tokens:0,total_tokens:H}}),x=Math.max(0,Math.min(v-1,Math.floor(v*.8)));y[x]&&(y[x].is_me=!0);const M=u==="gpt"||u==="codex"?"gpt_tokens":u==="claude"?"claude_tokens":u==="gemini"?"gemini_tokens":u==="cursor"?"cursor_tokens":u==="opencode"?"opencode_tokens":u==="openclaw"?"openclaw_tokens":"total_tokens",A=y.slice().sort((U,S)=>Number(S[M])-Number(U[M])||U.id-S.id).map((U,S)=>({user_id:U.is_public?U.user_id:null,rank:S+1,is_me:!!U.is_me,display_name:U.display_name,avatar_url:U.avatar_url,gpt_tokens:String(U.gpt_tokens),claude_tokens:String(U.claude_tokens),gemini_tokens:String(U.gemini_tokens),cursor_tokens:String(U.cursor_tokens),opencode_tokens:String(U.opencode_tokens),openclaw_tokens:String(U.openclaw_tokens),other_tokens:String(U.other_tokens??0),total_tokens:String(U.total_tokens),is_public:!!U.is_public})),T=A.find(U=>U?.is_me)||null,D=T?{rank:T.rank,gpt_tokens:T.gpt_tokens,claude_tokens:T.claude_tokens,gemini_tokens:T.gemini_tokens,cursor_tokens:T.cursor_tokens,opencode_tokens:T.opencode_tokens,openclaw_tokens:T.openclaw_tokens,other_tokens:T.other_tokens,total_tokens:T.total_tokens}:{rank:null,gpt_tokens:"0",claude_tokens:"0",gemini_tokens:"0",cursor_tokens:"0",opencode_tokens:"0",openclaw_tokens:"0",other_tokens:"0",total_tokens:"0"},I=A.slice(c,c+o);return{period:h,metric:u,from:p,to:m,generated_at:new Date().toISOString(),page:w,limit:o,offset:c,total_entries:v,total_pages:_,entries:I,me:D}}function TV({weeks:t=52,to:e,weekStartsOn:n="sun",seed:i}={}){const r=LC({weeks:t,now:ki(e)||ki(fs(new Date))||new Date,weekStartsOn:n}),s=Bl({from:r.from,to:r.to,seed:i});return{...lV({dailyRows:s,weeks:t,to:r.to,weekStartsOn:n}),week_starts_on:n,active_days:s.filter(c=>Number(c.billable_total_tokens??c.total_tokens)>0).length,streak_days:cV({dailyRows:s,to:r.to})}}function AV({from:t,to:e,seed:n}={}){const i=Bl({from:t,to:e,seed:n}),r=Wy(i),o=[{source:"codex",weight:.7,models:[{model:"gpt-5.2-codex",model_id:"gpt-5.2-codex",weight:.2},{model:"unknown",model_id:"unknown",weight:.8}]},{source:"claude",weight:.2,models:[{model:"claude-3.5",model_id:"claude-3.5",weight:.3},{model:"unknown",model_id:"unknown",weight:.7}]},{source:"every-code",weight:.1,models:[{model:"unknown",model_id:"unknown",weight:1}]}].map(c=>{const u=hE(r,c.weight),f=c.models.map(h=>{const p=hE(u,h.weight);return{model:h.model,model_id:h.model_id||h.model,totals:B0(p)}});return{source:c.source,totals:B0(u),models:f}});return{from:t,to:e,days:i.length,sources:o,pricing:{model:"mock",pricing_mode:"add",source:"mock",effective_from:fs(new Date),rates_per_million_usd:{input:"1.750000",cached_input:"0.175000",output:"14.000000",reasoning_output:"14.000000"}}}}function UC(t=""){if(typeof t!="string"||t.length===0)return!1;const e=new URLSearchParams(t),n=String(e.get("screenshot")||"").toLowerCase();return n==="1"||n==="true"}const CV=300*1e3;function $y(t){return typeof t=="string"&&/^https?:\/\//i.test(t.trim())}async function FC(t){const e=Co();if(!$y(e)||!t)return;const n=e.replace(/\/$/,""),i=Ph(),r={Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${t}`};i&&(r.apikey=i);try{await fetch(`${n}/functions/tokentracker-leaderboard-refresh`,{method:"POST",headers:r,body:"{}"})}catch{}}async function OC(t){const e=Co();if(!$y(e)||!t)return null;const n=e.replace(/\/$/,""),i=Ph(),r={Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${t}`};i&&(r.apikey=i);const s=typeof navigator<"u"&&typeof navigator.platform=="string"?navigator.platform:"web",o=await fetch(`${n}/functions/tokentracker-device-token-issue`,{method:"POST",headers:r,body:JSON.stringify({device_name:"Token Tracker (dashboard)",platform:s})});if(!o.ok)return null;const c=await o.json().catch(()=>null),u=typeof c?.token=="string"?c.token:null,f=typeof c?.device_id=="string"?c.device_id:null;return!u||!f?null:{token:u,deviceId:f,issuedAt:typeof c?.created_at=="string"?c.created_at:new Date().toISOString()}}async function BC(t){const{deviceToken:e,insforgeBaseUrl:n}=t,i={deviceToken:e},r=n||Co();$y(r)&&(i.insforgeBaseUrl=r.trim());const s=await fetch("/functions/tokentracker-local-sync",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(i)}),o=await s.json().catch(()=>({}));if(!s.ok){const c=typeof o.error=="string"?o.error:`HTTP ${s.status}`;throw new Error(c)}return o}async function RV(t){const e=_I();if(Date.now()-e<CV)return;const n=await t();if(!n)return;let i=oT();if(!i){const r=await OC(n);if(!r)return;lT(r),i=r}await BC({deviceToken:i.token,insforgeBaseUrl:Co()}),cT(Date.now()),await FC(n)}async function PV(t){const e=await t();if(!e)return;let n=oT();if(!n){const i=await OC(e);if(!i)return;lT(i),n=i}await BC({deviceToken:n.token,insforgeBaseUrl:Co()}),cT(Date.now()),await FC(e)}function kV(t){const e=t.replace(/\/+$/,"")||"/";return e==="/share"||e==="/share.html"||e.startsWith("/share/")}function LV(t){const e=t.replace(/\/+$/,"")||"/";return e==="/login"||e==="/landing"||kV(e)?!1:e==="/"||e==="/dashboard"||e.startsWith("/leaderboard")}function DV(){const t=zr(),e=Ro(),n=k.useRef(!1);k.useEffect(()=>{if(!sT()||!LV(t.pathname||"/")||!e.enabled||!e.signedIn||e.loading||!aT())return;let i=!1;const r=window.setTimeout(()=>{(async()=>{if(!(i||n.current)){n.current=!0;try{await RV(()=>e.getAccessToken())}catch(s){console.warn("[tokentracker] cloud usage sync:",s)}finally{n.current=!1}}})()},2500);return()=>{i=!0,window.clearTimeout(r)}},[t.pathname,e.enabled,e.signedIn,e.loading,e.getAccessToken])}function zC(){return typeof navigator>"u"?null:navigator.clipboard||null}function NV(){return typeof window>"u"?null:window.ClipboardItem||null}async function IV(t,{clipboard:e}={}){const n=e??zC();if(!n||typeof n.writeText!="function")return!1;try{return await n.writeText(t),!0}catch{return!1}}async function w$(t,{clipboard:e}={}){const n=e??zC(),i=NV();if(!t||!n||typeof n.write!="function"||!i)return!1;try{const r=t.type||"image/png",s=t.type&&t.type!==r?t.slice(0,t.size,r):t.type?t:t.slice(0,t.size,r),o=new i({[r]:s});return await n.write([o]),!0}catch{return!1}}function UV(){if(typeof window>"u")return!1;const t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||t==="::1"}function FV(){return UV()?"/":"/dashboard"}function OV({prefersReducedMotion:t,screenshotCapture:e}){return!(e||t)}function BV({repo:t="mm7894215/TokenTracker"}){const[e,n]=k.useState(null);return k.useEffect(()=>{if(typeof window>"u")return;const i=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,r=typeof document<"u"&&(document.documentElement?.classList.contains("screenshot-capture")||document.body?.classList.contains("screenshot-capture"));OV({prefersReducedMotion:i,screenshotCapture:r})&&fetch(`https://api.github.com/repos/${t}`).then(s=>s.json()).then(s=>{s&&typeof s.stargazers_count=="number"&&n(s.stargazers_count)}).catch(()=>{})},[t]),O.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:[O.jsx("svg",{height:"16",viewBox:"0 0 16 16",width:"16",className:"shrink-0 fill-oai-gray-700 dark:fill-oai-gray-300",children:O.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"})}),O.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 whitespace-nowrap",children:"Star"}),e!==null&&O.jsx("span",{className:"text-xs font-semibold text-oai-gray-900 dark:text-oai-white tabular-nums whitespace-nowrap",children:e})]})}const hs={usageSummary:"tokentracker-usage-summary",usageDaily:"tokentracker-usage-daily",usageHourly:"tokentracker-usage-hourly",usageMonthly:"tokentracker-usage-monthly",usageHeatmap:"tokentracker-usage-heatmap",usageModelBreakdown:"tokentracker-usage-model-breakdown",projectUsageSummary:"tokentracker-project-usage-summary",userStatus:"tokentracker-user-status",localSync:"tokentracker-local-sync",usageLimits:"tokentracker-usage-limits"};async function js(t,e,n){const i=new URL(`/functions/${t}`,window.location.origin);if(e)for(const[s,o]of Object.entries(e))o!=null&&o!==""&&i.searchParams.set(s,String(o));const r=await fetch(i.toString(),{headers:{Accept:"application/json"},cache:"no-store",...n});if(!r.ok){const s=new Error(`Request failed with HTTP ${r.status}`);throw s.status=r.status,s}return r.json()}function ko({timeZone:t,tzOffsetMinutes:e}={}){const n={},i=typeof t=="string"?t.trim():"";return i&&(n.tz=i),Number.isFinite(e)&&(n.tz_offset_minutes=String(Math.trunc(e))),n}function Lo({source:t,model:e}={}){const n={},i=typeof t=="string"?t.trim().toLowerCase():"";i&&(n.source=i);const r=typeof e=="string"?e.trim():"";return r&&(n.model=r),n}async function E$({from:t,to:e,source:n,model:i,timeZone:r,tzOffsetMinutes:s,rolling:o=!1,accessToken:c}={}){if(_r())return SV({from:t,to:e,seed:c,rolling:o});const u=ko({timeZone:r,tzOffsetMinutes:s}),f=Lo({source:n,model:i}),h=o?{rolling:"1"}:{};return js(hs.usageSummary,{from:t,to:e,...f,...u,...h})}async function M$({from:t,to:e,source:n,limit:i,timeZone:r,tzOffsetMinutes:s,accessToken:o}={}){if(_r())return EV({seed:o,limit:i});const c=ko({timeZone:r,tzOffsetMinutes:s}),f={...Lo({source:n}),...c};return t&&(f.from=t),e&&(f.to=e),i!=null&&(f.limit=String(i)),js(hs.projectUsageSummary,f)}async function ku(t,e={}){const n=Co();if(!n)throw new Error("InsForge base URL not configured");const i=n.replace(/\/$/,""),r=new URL(`${i}/functions/${t}`);if(e.params)for(const[u,f]of Object.entries(e.params))f!=null&&f!==""&&r.searchParams.set(u,String(f));const s={Accept:"application/json","Content-Type":"application/json"},o=Ph();o&&(s.apikey=o),e.accessToken&&(s.Authorization=`Bearer ${e.accessToken}`);const c=await fetch(r.toString(),{method:e.method||"GET",headers:s,...e.body!=null?{body:JSON.stringify(e.body)}:{}});if(!c.ok){const u=new Error(`Request failed with HTTP ${c.status}`);throw u.status=c.status,u}return c.json()}async function T$({accessToken:t,period:e,metric:n,limit:i,offset:r}={}){return _r()?IC({seed:t,period:e,metric:n,limit:i,offset:r}):ku("tokentracker-leaderboard",{accessToken:t,params:{period:e,limit:i,offset:r}})}async function zV({accessToken:t}={}){return ku("tokentracker-public-visibility",{accessToken:t,method:"GET"})}async function rg({accessToken:t,enabled:e,anonymous:n,display_name:i}={}){const r={};return e!==void 0&&(r.enabled=!!e),n!==void 0&&(r.anonymous=!!n),i!==void 0&&(r.display_name=String(i)),ku("tokentracker-public-visibility",{accessToken:t,method:"POST",body:r})}async function A$({accessToken:t,period:e}={}){return ku("tokentracker-leaderboard-refresh",{accessToken:t,method:"POST",body:e?{period:e}:{}})}async function C$({accessToken:t,userId:e,period:n}={}){if(_r()){const i=IC({seed:t,period:n,metric:"all",limit:250,offset:0}),s=(Array.isArray(i?.entries)?i.entries:[]).find(o=>o?.user_id===e)||null;return{period:i?.period??"week",from:i?.from??null,to:i?.to??null,generated_at:i?.generated_at??new Date().toISOString(),entry:s}}return ku("tokentracker-leaderboard-profile",{accessToken:t,params:{user_id:e,period:n}})}async function R$(t={}){if(_r()){const e=new Date().toISOString();return{user_id:"local-user",created_at:e,pro:{active:!1,sources:[],expires_at:null,partial:!1,as_of:e},subscriptions:{partial:!1,as_of:e,items:[]},install:{partial:!1,as_of:e,has_active_device_token:!1,has_active_device:!1,active_device_tokens:0,active_devices:0,latest_token_activity_at:null,latest_device_seen_at:null}}}return js(hs.userStatus)}async function P$({signal:t}={}){const e=await fetch(`/functions/${hs.localSync}`,{method:"POST",headers:{Accept:"application/json"},cache:"no-store",signal:t}),n=await e.json().catch(()=>({ok:!1,error:`Local sync request failed with HTTP ${e.status}`}));if(!e.ok||n?.ok===!1){const i=n?.error||n?.message||`Local sync request failed with HTTP ${e.status}`,r=new Error(i);throw r.status=e.status,r}return n}async function k$({from:t,to:e,source:n,timeZone:i,tzOffsetMinutes:r,accessToken:s}={}){if(_r())return AV({from:t,to:e,seed:s});const o=ko({timeZone:i,tzOffsetMinutes:r}),c=Lo({source:n});return js(hs.usageModelBreakdown,{from:t,to:e,...c,...o})}async function L$({from:t,to:e,source:n,model:i,timeZone:r,tzOffsetMinutes:s,accessToken:o}={}){if(_r())return _V({from:t,to:e,seed:o});const c=ko({timeZone:r,tzOffsetMinutes:s}),u=Lo({source:n,model:i});return js(hs.usageDaily,{from:t,to:e,...u,...c})}async function D$({day:t,source:e,model:n,timeZone:i,tzOffsetMinutes:r,accessToken:s}={}){if(_r())return xV({day:t,seed:s});const o=ko({timeZone:i,tzOffsetMinutes:r}),c=Lo({source:e,model:n}),u=t?{day:t,...c,...o}:{...c,...o};return js(hs.usageHourly,u)}async function N$({months:t,to:e,source:n,model:i,timeZone:r,tzOffsetMinutes:s,accessToken:o}={}){if(_r())return bV({months:t,to:e,seed:o});const c=ko({timeZone:r,tzOffsetMinutes:s}),u=Lo({source:n,model:i});return js(hs.usageMonthly,{...t?{months:String(t)}:{},...e?{to:e}:{},...u,...c})}async function I$(t={}){return js(hs.usageLimits)}async function U$({weeks:t,to:e,weekStartsOn:n,source:i,model:r,timeZone:s,tzOffsetMinutes:o,accessToken:c}={}){if(_r())return TV({weeks:t,to:e,weekStartsOn:n,seed:c});const u=ko({timeZone:s,tzOffsetMinutes:o}),f=Lo({source:i,model:r});return js(hs.usageHeatmap,{weeks:String(t),to:e,week_starts_on:n,...f,...u})}function VV(t){if(!t||typeof t!="object")return"";const e=t.user_metadata&&typeof t.user_metadata=="object"?t.user_metadata:{},n=t.profile&&typeof t.profile=="object"?t.profile:{},i=e.full_name||e.name||n.name||e.user_name||e.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof t.email=="string"&&t.email.includes("@")?t.email.split("@")[0].trim()||t.email.trim():typeof t.email=="string"?t.email.trim():""}function HV(t){return!t||typeof t!="object"?"":typeof t.email=="string"?t.email.trim():""}function GV(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:{},i=e.avatar_url||e.picture||n.avatar_url||t.avatar_url;return typeof i=="string"&&i.trim()?i.trim():null}function mE(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 jV({checked:t,onChange:e,disabled:n,ariaLabel:i}){return O.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":i,onClick:e,disabled:n,className:Si("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:O.jsx("span",{className:Si("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",t?"translate-x-[18px]":"translate-x-[3px]")})})}function sg({label:t,checked:e,onChange:n,disabled:i}){return O.jsxs("div",{className:"flex items-center justify-between py-2",children:[O.jsx("span",{className:"text-sm text-oai-gray-700 dark:text-oai-gray-300",children:t}),O.jsx(jV,{checked:e,onChange:n,disabled:i,ariaLabel:t})]})}function WV({className:t}){const{enabled:e,loading:n,signedIn:i,user:r,signOut:s,getAccessToken:o}=Ro(),{openLoginModal:c}=AT(),[u,f]=k.useState(!1),[h,p]=k.useState(()=>aT()),[m,v]=k.useState(!1),[_,w]=k.useState(!1),[y,x]=k.useState(!1),[M,A]=k.useState(!1),[T,D]=k.useState(!1),[I,U]=k.useState(null),[S,R]=k.useState(""),V=k.useRef(null),F=k.useRef(null),j=e&&i&&sT(),Z=k.useMemo(()=>VV(r),[r]),H=k.useMemo(()=>HV(r),[r]),q=k.useMemo(()=>GV(r),[r]);k.useEffect(()=>{if(!u)return;const ve=Ce=>{F.current&&!F.current.contains(Ce.target)&&f(!1)};return document.addEventListener("mousedown",ve),()=>document.removeEventListener("mousedown",ve)},[u]),k.useEffect(()=>{if(!u||!i)return;let ve=!0;return x(!0),(async()=>{try{const Ce=await Hd({getAccessToken:o});if(!ve||!Ce)return;const we=await zV({accessToken:Ce});if(!ve)return;v(!!we?.enabled),w(!!we?.anonymous),we?.display_name&&U(we.display_name)}catch{}finally{ve&&x(!1)}})(),()=>{ve=!1}},[u,i,o]);const J=k.useCallback(async()=>{f(!1),await s()},[s]),Q=k.useCallback(async()=>{const ve=!h;if(vI(ve),p(ve),ve)try{await PV(()=>o())}catch(Ce){console.warn("[tokentracker] cloud sync:",Ce)}},[h,o]),W=k.useCallback(async()=>{if(!M){A(!0);try{const ve=await Hd({getAccessToken:o});if(!ve)return;const Ce=!m;await rg({accessToken:ve,enabled:Ce}),v(Ce)}catch{}finally{A(!1)}}},[m,M,o]),X=k.useCallback(()=>{f(!1),R(I||Z),D(!0),setTimeout(()=>V.current?.focus(),50)},[I,Z]),K=k.useCallback(()=>{D(!1),R("")},[]),B=k.useCallback(async()=>{if(M)return;const ve=S.trim().slice(0,50);if(ve){A(!0);try{const Ce=await Hd({getAccessToken:o});if(!Ce)return;await rg({accessToken:Ce,display_name:ve}),U(ve),D(!1)}catch{}finally{A(!1)}}},[S,M,o]),ie=k.useCallback(async()=>{if(!M){A(!0);try{const ve=await Hd({getAccessToken:o});if(!ve)return;const Ce=!_;await rg({accessToken:ve,anonymous:Ce}),w(Ce)}catch{}finally{A(!1)}}},[_,M,o]);return e?n?O.jsx("div",{className:Si("h-9 w-9 shrink-0 rounded-full bg-oai-gray-200 dark:bg-oai-gray-800 animate-pulse",t),"aria-hidden":!0}):i?O.jsxs("div",{ref:F,className:Si("relative flex shrink-0 items-center",t),children:[O.jsxs("button",{type:"button",onClick:()=>f(ve=>!ve),className:"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-expanded":u,"aria-haspopup":"menu",children:[q?O.jsx("img",{src:q,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",referrerPolicy:"no-referrer"}):O.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:mE(Z)}),O.jsx("span",{className:"hidden sm:inline truncate text-sm font-medium text-oai-gray-900 dark:text-oai-gray-200 max-w-[120px]",children:I||Z})]}),O.jsx(I0,{children:T&&O.jsx(Is.div,{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/40",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},onClick:K,children:O.jsxs(Is.div,{className:"w-[340px] rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-2xl p-5",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15},onClick:ve=>ve.stopPropagation(),children:[O.jsx("h3",{className:"text-base font-semibold text-oai-black dark:text-white mb-3",children:"Edit Display Name"}),O.jsx("input",{ref:V,type:"text",value:S,onChange:ve=>R(ve.target.value),onKeyDown:ve=>{ve.key==="Enter"&&B(),ve.key==="Escape"&&K()},maxLength:50,className:"w-full rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-transparent px-3 py-2 text-sm text-oai-black dark:text-white outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-oai-brand-500",placeholder:"Display name"}),O.jsx("p",{className:"mt-1.5 text-xs text-oai-gray-400",children:"This name will be shown on the leaderboard."}),O.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[O.jsx("button",{type:"button",onClick:K,className:"rounded-md px-3 py-1.5 text-sm text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300 transition-colors",children:"Cancel"}),O.jsx("button",{type:"button",onClick:B,disabled:M||!S.trim(),className:"rounded-md bg-oai-brand-500 px-4 py-1.5 text-sm font-medium text-white hover:bg-oai-brand-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:M?"Saving...":"Save"})]})]})})}),O.jsx(I0,{children:u&&O.jsxs(Is.div,{className:"absolute right-0 top-full z-[60] mt-2 w-[280px] rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-2xl overflow-hidden",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:[O.jsxs("div",{className:"px-4 py-3 border-b border-oai-gray-200 dark:border-oai-gray-800 flex items-center gap-3",children:[q?O.jsx("img",{src:q,alt:"",width:36,height:36,className:"h-9 w-9 rounded-full object-cover ring-1 ring-oai-gray-200 dark:ring-oai-gray-700",referrerPolicy:"no-referrer"}):O.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-oai-brand-600 text-xs font-semibold text-white",children:mE(I||Z)}),O.jsxs("div",{className:"min-w-0",children:[O.jsx("div",{className:"text-sm font-medium text-oai-black dark:text-white truncate",children:I||Z}),H&&O.jsx("div",{className:"text-xs text-oai-gray-500 truncate",children:H})]})]}),O.jsxs("div",{className:"px-4 py-2 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[j&&O.jsx(sg,{label:"Cloud Sync",checked:h,onChange:Q}),O.jsx(sg,{label:"Public Profile",checked:m,onChange:W,disabled:y||M}),O.jsx(sg,{label:"Anonymous",checked:_,onChange:ie,disabled:y||M})]}),O.jsxs("div",{children:[O.jsxs("button",{type:"button",onClick:X,className:"flex w-full items-center gap-2 px-4 py-2.5 text-left text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors",children:[O.jsx(Q5,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Edit Name"]}),O.jsxs("button",{type:"button",onClick:J,className:"flex w-full items-center gap-2 px-4 py-2.5 text-left text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors",children:[O.jsx(Y5,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Sign Out"]})]})]})})]}):O.jsx("button",{type:"button",onClick:c,className:Si("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":qt("header.auth.sign_in_aria"),children:"Sign In"}):null}const Xy="183",$V=0,gE=1,XV=2,Bf=1,qV=2,Jc=3,La=0,Gi=1,Ls=2,Us=0,vo=1,vE=2,yE=3,_E=4,YV=5,so=100,KV=101,ZV=102,JV=103,QV=104,eH=200,tH=201,nH=202,iH=203,z0=204,V0=205,rH=206,sH=207,aH=208,oH=209,lH=210,cH=211,uH=212,dH=213,fH=214,H0=0,G0=1,j0=2,zl=3,W0=4,$0=5,X0=6,q0=7,VC=0,hH=1,pH=2,ns=0,HC=1,GC=2,jC=3,WC=4,$C=5,XC=6,qC=7,YC=300,Eo=301,Vl=302,ag=303,og=304,Bh=306,Y0=1e3,Ds=1001,K0=1002,pi=1003,mH=1004,Kd=1005,wi=1006,lg=1007,fo=1008,fr=1009,KC=1010,ZC=1011,vu=1012,qy=1013,cs=1014,Jr=1015,zs=1016,Yy=1017,Ky=1018,yu=1020,JC=35902,QC=35899,eR=1021,tR=1022,Ir=1023,Vs=1026,ho=1027,nR=1028,Zy=1029,Hl=1030,Jy=1031,Qy=1033,zf=33776,Vf=33777,Hf=33778,Gf=33779,Z0=35840,J0=35841,Q0=35842,ev=35843,tv=36196,nv=37492,iv=37496,rv=37488,sv=37489,av=37490,ov=37491,lv=37808,cv=37809,uv=37810,dv=37811,fv=37812,hv=37813,pv=37814,mv=37815,gv=37816,vv=37817,yv=37818,_v=37819,xv=37820,bv=37821,Sv=36492,wv=36494,Ev=36495,Mv=36283,Tv=36284,Av=36285,Cv=36286,gH=3200,vH=0,yH=1,Ea="",ur="srgb",Mo="srgb-linear",vh="linear",wn="srgb",al=7680,xE=519,_H=512,xH=513,bH=514,e_=515,SH=516,wH=517,t_=518,EH=519,bE=35044,SE="300 es",Qr=2e3,yh=2001;function MH(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function _h(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function TH(){const t=_h("canvas");return t.style.display="block",t}const wE={};function EE(...t){const e="THREE."+t.shift();console.log(e,...t)}function iR(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 Ht(...t){t=iR(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...t)}}function _n(...t){t=iR(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.error(n.getError(e)):console.error(e,...t)}}function xh(...t){const e=t.join(" ");e in wE||(wE[e]=!0,Ht(...t))}function AH(t,e,n){return new Promise(function(i,r){function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}const CH={[H0]:G0,[j0]:X0,[W0]:q0,[zl]:$0,[G0]:H0,[X0]:j0,[q0]:W0,[$0]:zl};class Zl{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(n)===-1&&i[e].push(n)}hasEventListener(e,n){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(n)!==-1}removeEventListener(e,n){const i=this._listeners;if(i===void 0)return;const r=i[e];if(r!==void 0){const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const i=n[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}}const _i=["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"],cg=Math.PI/180,Rv=180/Math.PI;function Lu(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(_i[t&255]+_i[t>>8&255]+_i[t>>16&255]+_i[t>>24&255]+"-"+_i[e&255]+_i[e>>8&255]+"-"+_i[e>>16&15|64]+_i[e>>24&255]+"-"+_i[n&63|128]+_i[n>>8&255]+"-"+_i[n>>16&255]+_i[n>>24&255]+_i[i&255]+_i[i>>8&255]+_i[i>>16&255]+_i[i>>24&255]).toLowerCase()}function ln(t,e,n){return Math.max(e,Math.min(n,t))}function RH(t,e){return(t%e+e)%e}function ug(t,e,n){return(1-n)*t+n*e}function Bc(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 Hi(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 bn{constructor(e=0,n=0){bn.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,i=this.y,r=e.elements;return this.x=r[0]*n+r[3]*i+r[6],this.y=r[1]*n+r[4]*i+r[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=ln(this.x,e.x,n.x),this.y=ln(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=ln(this.x,e,n),this.y=ln(this.y,e,n),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ln(i,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 i=this.dot(e)/n;return Math.acos(ln(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,i=this.y-e.y;return n*n+i*i}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,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,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 i=Math.cos(n),r=Math.sin(n),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Jl{constructor(e=0,n=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=i,this._w=r}static slerpFlat(e,n,i,r,s,o,c){let u=i[r+0],f=i[r+1],h=i[r+2],p=i[r+3],m=s[o+0],v=s[o+1],_=s[o+2],w=s[o+3];if(p!==w||u!==m||f!==v||h!==_){let y=u*m+f*v+h*_+p*w;y<0&&(m=-m,v=-v,_=-_,w=-w,y=-y);let x=1-c;if(y<.9995){const M=Math.acos(y),A=Math.sin(M);x=Math.sin(x*M)/A,c=Math.sin(c*M)/A,u=u*x+m*c,f=f*x+v*c,h=h*x+_*c,p=p*x+w*c}else{u=u*x+m*c,f=f*x+v*c,h=h*x+_*c,p=p*x+w*c;const M=1/Math.sqrt(u*u+f*f+h*h+p*p);u*=M,f*=M,h*=M,p*=M}}e[n]=u,e[n+1]=f,e[n+2]=h,e[n+3]=p}static multiplyQuaternionsFlat(e,n,i,r,s,o){const c=i[r],u=i[r+1],f=i[r+2],h=i[r+3],p=s[o],m=s[o+1],v=s[o+2],_=s[o+3];return e[n]=c*_+h*p+u*v-f*m,e[n+1]=u*_+h*m+f*p-c*v,e[n+2]=f*_+h*v+c*m-u*p,e[n+3]=h*_-c*p-u*m-f*v,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,i,r){return this._x=e,this._y=n,this._z=i,this._w=r,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 i=e._x,r=e._y,s=e._z,o=e._order,c=Math.cos,u=Math.sin,f=c(i/2),h=c(r/2),p=c(s/2),m=u(i/2),v=u(r/2),_=u(s/2);switch(o){case"XYZ":this._x=m*h*p+f*v*_,this._y=f*v*p-m*h*_,this._z=f*h*_+m*v*p,this._w=f*h*p-m*v*_;break;case"YXZ":this._x=m*h*p+f*v*_,this._y=f*v*p-m*h*_,this._z=f*h*_-m*v*p,this._w=f*h*p+m*v*_;break;case"ZXY":this._x=m*h*p-f*v*_,this._y=f*v*p+m*h*_,this._z=f*h*_+m*v*p,this._w=f*h*p-m*v*_;break;case"ZYX":this._x=m*h*p-f*v*_,this._y=f*v*p+m*h*_,this._z=f*h*_-m*v*p,this._w=f*h*p+m*v*_;break;case"YZX":this._x=m*h*p+f*v*_,this._y=f*v*p+m*h*_,this._z=f*h*_-m*v*p,this._w=f*h*p-m*v*_;break;case"XZY":this._x=m*h*p-f*v*_,this._y=f*v*p-m*h*_,this._z=f*h*_+m*v*p,this._w=f*h*p+m*v*_;break;default:Ht("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const i=n/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,i=n[0],r=n[4],s=n[8],o=n[1],c=n[5],u=n[9],f=n[2],h=n[6],p=n[10],m=i+c+p;if(m>0){const v=.5/Math.sqrt(m+1);this._w=.25/v,this._x=(h-u)*v,this._y=(s-f)*v,this._z=(o-r)*v}else if(i>c&&i>p){const v=2*Math.sqrt(1+i-c-p);this._w=(h-u)/v,this._x=.25*v,this._y=(r+o)/v,this._z=(s+f)/v}else if(c>p){const v=2*Math.sqrt(1+c-i-p);this._w=(s-f)/v,this._x=(r+o)/v,this._y=.25*v,this._z=(u+h)/v}else{const v=2*Math.sqrt(1+p-i-c);this._w=(o-r)/v,this._x=(s+f)/v,this._y=(u+h)/v,this._z=.25*v}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let i=e.dot(n)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(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=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ln(this.dot(e),-1,1)))}rotateTowards(e,n){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,n/i);return this.slerp(e,r),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 i=e._x,r=e._y,s=e._z,o=e._w,c=n._x,u=n._y,f=n._z,h=n._w;return this._x=i*h+o*c+r*f-s*u,this._y=r*h+o*u+s*c-i*f,this._z=s*h+o*f+i*u-r*c,this._w=o*h-i*c-r*u-s*f,this._onChangeCallback(),this}slerp(e,n){let i=e._x,r=e._y,s=e._z,o=e._w,c=this.dot(e);c<0&&(i=-i,r=-r,s=-s,o=-o,c=-c);let u=1-n;if(c<.9995){const f=Math.acos(c),h=Math.sin(f);u=Math.sin(u*f)/h,n=Math.sin(n*f)/h,this._x=this._x*u+i*n,this._y=this._y*u+r*n,this._z=this._z*u+s*n,this._w=this._w*u+o*n,this._onChangeCallback()}else this._x=this._x*u+i*n,this._y=this._y*u+r*n,this._z=this._z*u+s*n,this._w=this._w*u+o*n,this.normalize();return this}slerpQuaternions(e,n,i){return this.copy(e).slerp(n,i)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(n),s*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 me{constructor(e=0,n=0,i=0){me.prototype.isVector3=!0,this.x=e,this.y=n,this.z=i}set(e,n,i){return i===void 0&&(i=this.z),this.x=e,this.y=n,this.z=i,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(ME.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(ME.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*n+s[3]*i+s[6]*r,this.y=s[1]*n+s[4]*i+s[7]*r,this.z=s[2]*n+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*n+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*n+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*n+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*n+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){const n=this.x,i=this.y,r=this.z,s=e.x,o=e.y,c=e.z,u=e.w,f=2*(o*r-c*i),h=2*(c*n-s*r),p=2*(s*i-o*n);return this.x=n+u*f+o*p-c*h,this.y=i+u*h+c*f-s*p,this.z=r+u*p+s*h-o*f,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,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*n+s[4]*i+s[8]*r,this.y=s[1]*n+s[5]*i+s[9]*r,this.z=s[2]*n+s[6]*i+s[10]*r,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=ln(this.x,e.x,n.x),this.y=ln(this.y,e.y,n.y),this.z=ln(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=ln(this.x,e,n),this.y=ln(this.y,e,n),this.z=ln(this.z,e,n),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ln(i,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,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this.z=e.z+(n.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const i=e.x,r=e.y,s=e.z,o=n.x,c=n.y,u=n.z;return this.x=r*u-s*c,this.y=s*o-i*u,this.z=i*c-r*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const i=e.dot(this)/n;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return dg.copy(this).projectOnVector(e),this.sub(dg)}reflect(e){return this.sub(dg.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 i=this.dot(e)/n;return Math.acos(ln(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return n*n+i*i+r*r}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,i){const r=Math.sin(n)*e;return this.x=r*Math.sin(i),this.y=Math.cos(n)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,i){return this.x=e*Math.sin(n),this.y=i,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(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=i,this.z=r,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,i=Math.sqrt(1-n*n);return this.x=i*Math.cos(e),this.y=n,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const dg=new me,ME=new Jl;class jt{constructor(e,n,i,r,s,o,c,u,f){jt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,i,r,s,o,c,u,f)}set(e,n,i,r,s,o,c,u,f){const h=this.elements;return h[0]=e,h[1]=r,h[2]=c,h[3]=n,h[4]=s,h[5]=u,h[6]=i,h[7]=o,h[8]=f,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],this}extractBasis(e,n,i){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),i.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 i=e.elements,r=n.elements,s=this.elements,o=i[0],c=i[3],u=i[6],f=i[1],h=i[4],p=i[7],m=i[2],v=i[5],_=i[8],w=r[0],y=r[3],x=r[6],M=r[1],A=r[4],T=r[7],D=r[2],I=r[5],U=r[8];return s[0]=o*w+c*M+u*D,s[3]=o*y+c*A+u*I,s[6]=o*x+c*T+u*U,s[1]=f*w+h*M+p*D,s[4]=f*y+h*A+p*I,s[7]=f*x+h*T+p*U,s[2]=m*w+v*M+_*D,s[5]=m*y+v*A+_*I,s[8]=m*x+v*T+_*U,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],i=e[1],r=e[2],s=e[3],o=e[4],c=e[5],u=e[6],f=e[7],h=e[8];return n*o*h-n*c*f-i*s*h+i*c*u+r*s*f-r*o*u}invert(){const e=this.elements,n=e[0],i=e[1],r=e[2],s=e[3],o=e[4],c=e[5],u=e[6],f=e[7],h=e[8],p=h*o-c*f,m=c*u-h*s,v=f*s-o*u,_=n*p+i*m+r*v;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const w=1/_;return e[0]=p*w,e[1]=(r*f-h*i)*w,e[2]=(c*i-r*o)*w,e[3]=m*w,e[4]=(h*n-r*u)*w,e[5]=(r*s-c*n)*w,e[6]=v*w,e[7]=(i*u-f*n)*w,e[8]=(o*n-i*s)*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,i,r,s,o,c){const u=Math.cos(s),f=Math.sin(s);return this.set(i*u,i*f,-i*(u*o+f*c)+o+e,-r*f,r*u,-r*(-f*o+u*c)+c+n,0,0,1),this}scale(e,n){return this.premultiply(fg.makeScale(e,n)),this}rotate(e){return this.premultiply(fg.makeRotation(-e)),this}translate(e,n){return this.premultiply(fg.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),i=Math.sin(e);return this.set(n,-i,0,i,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,i=e.elements;for(let r=0;r<9;r++)if(n[r]!==i[r])return!1;return!0}fromArray(e,n=0){for(let i=0;i<9;i++)this.elements[i]=e[i+n];return this}toArray(e=[],n=0){const i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const fg=new jt,TE=new jt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),AE=new jt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function PH(){const t={enabled:!0,workingColorSpace:Mo,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===wn&&(r.r=Fs(r.r),r.g=Fs(r.g),r.b=Fs(r.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===wn&&(r.r=Ll(r.r),r.g=Ll(r.g),r.b=Ll(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Ea?vh:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return xh("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return xh("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[Mo]:{primaries:e,whitePoint:i,transfer:vh,toXYZ:TE,fromXYZ:AE,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:ur},outputColorSpaceConfig:{drawingBufferColorSpace:ur}},[ur]:{primaries:e,whitePoint:i,transfer:wn,toXYZ:TE,fromXYZ:AE,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:ur}}}),t}const fn=PH();function Fs(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Ll(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let ol;class kH{static getDataURL(e,n="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{ol===void 0&&(ol=_h("canvas")),ol.width=e.width,ol.height=e.height;const r=ol.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=ol}return i.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=_h("canvas");n.width=e.width,n.height=e.height;const i=n.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=Fs(s[o]/255)*255;return i.putImageData(r,0,0),n}else if(e.data){const n=e.data.slice(0);for(let i=0;i<n.length;i++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[i]=Math.floor(Fs(n[i]/255)*255):n[i]=Fs(n[i]);return{data:n,width:e.width,height:e.height}}else return Ht("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let LH=0;class n_{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:LH++}),this.uuid=Lu(),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 i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,c=r.length;o<c;o++)r[o].isDataTexture?s.push(hg(r[o].image)):s.push(hg(r[o]))}else s=hg(r);i.url=s}return n||(e.images[this.uuid]=i),i}}function hg(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?kH.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Ht("Texture: Unable to serialize Texture."),{})}let DH=0;const pg=new me;class Li extends Zl{constructor(e=Li.DEFAULT_IMAGE,n=Li.DEFAULT_MAPPING,i=Ds,r=Ds,s=wi,o=fo,c=Ir,u=fr,f=Li.DEFAULT_ANISOTROPY,h=Ea){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:DH++}),this.uuid=Lu(),this.name="",this.source=new n_(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=f,this.format=c,this.internalFormat=null,this.type=u,this.offset=new bn(0,0),this.repeat=new bn(1,1),this.center=new bn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new jt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,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(pg).x}get height(){return this.source.getSize(pg).y}get depth(){return this.source.getSize(pg).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 i=e[n];if(i===void 0){Ht(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const r=this[n];if(r===void 0){Ht(`Texture.setValues(): property '${n}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[n]=i}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={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&&(i.userData=this.userData),n||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==YC)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Y0:e.x=e.x-Math.floor(e.x);break;case Ds:e.x=e.x<0?0:1;break;case K0: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 Y0:e.y=e.y-Math.floor(e.y);break;case Ds:e.y=e.y<0?0:1;break;case K0: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++}}Li.DEFAULT_IMAGE=null;Li.DEFAULT_MAPPING=YC;Li.DEFAULT_ANISOTROPY=1;class zn{constructor(e=0,n=0,i=0,r=1){zn.prototype.isVector4=!0,this.x=e,this.y=n,this.z=i,this.w=r}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,i,r){return this.x=e,this.y=n,this.z=i,this.w=r,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,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*n+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*n+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*n+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*n+o[7]*i+o[11]*r+o[15]*s,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,i,r,s;const u=e.elements,f=u[0],h=u[4],p=u[8],m=u[1],v=u[5],_=u[9],w=u[2],y=u[6],x=u[10];if(Math.abs(h-m)<.01&&Math.abs(p-w)<.01&&Math.abs(_-y)<.01){if(Math.abs(h+m)<.1&&Math.abs(p+w)<.1&&Math.abs(_+y)<.1&&Math.abs(f+v+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const A=(f+1)/2,T=(v+1)/2,D=(x+1)/2,I=(h+m)/4,U=(p+w)/4,S=(_+y)/4;return A>T&&A>D?A<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(A),r=I/i,s=U/i):T>D?T<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(T),i=I/r,s=S/r):D<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(D),i=U/s,r=S/s),this.set(i,r,s,n),this}let M=Math.sqrt((y-_)*(y-_)+(p-w)*(p-w)+(m-h)*(m-h));return Math.abs(M)<.001&&(M=1),this.x=(y-_)/M,this.y=(p-w)/M,this.z=(m-h)/M,this.w=Math.acos((f+v+x-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=ln(this.x,e.x,n.x),this.y=ln(this.y,e.y,n.y),this.z=ln(this.z,e.z,n.z),this.w=ln(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=ln(this.x,e,n),this.y=ln(this.y,e,n),this.z=ln(this.z,e,n),this.w=ln(this.w,e,n),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ln(i,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,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this.z=e.z+(n.z-e.z)*i,this.w=e.w+(n.w-e.w)*i,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 NH extends Zl{constructor(e=1,n=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:wi,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=i.depth,this.scissor=new zn(0,0,e,n),this.scissorTest=!1,this.viewport=new zn(0,0,e,n),this.textures=[];const r={width:e,height:n,depth:i.depth},s=new Li(r),o=i.count;for(let c=0;c<o;c++)this.textures[c]=s.clone(),this.textures[c].isRenderTargetTexture=!0,this.textures[c].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const n={minFilter:wi,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 i=0;i<this.textures.length;i++)this.textures[i].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,i=1){if(this.width!==e||this.height!==n||this.depth!==i){this.width=e,this.height=n,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=n,this.textures[r].image.depth=i,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].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,i=e.textures.length;n<i;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const r=Object.assign({},e.textures[n].image);this.textures[n].source=new n_(r)}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 is extends NH{constructor(e=1,n=1,i={}){super(e,n,i),this.isWebGLRenderTarget=!0}}class rR extends Li{constructor(e=null,n=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:i,depth:r},this.magFilter=pi,this.minFilter=pi,this.wrapR=Ds,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class IH extends Li{constructor(e=null,n=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:i,depth:r},this.magFilter=pi,this.minFilter=pi,this.wrapR=Ds,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Yn{constructor(e,n,i,r,s,o,c,u,f,h,p,m,v,_,w,y){Yn.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,i,r,s,o,c,u,f,h,p,m,v,_,w,y)}set(e,n,i,r,s,o,c,u,f,h,p,m,v,_,w,y){const x=this.elements;return x[0]=e,x[4]=n,x[8]=i,x[12]=r,x[1]=s,x[5]=o,x[9]=c,x[13]=u,x[2]=f,x[6]=h,x[10]=p,x[14]=m,x[3]=v,x[7]=_,x[11]=w,x[15]=y,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 Yn().fromArray(this.elements)}copy(e){const n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],n[9]=i[9],n[10]=i[10],n[11]=i[11],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15],this}copyPosition(e){const n=this.elements,i=e.elements;return n[12]=i[12],n[13]=i[13],n[14]=i[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,i){return this.determinant()===0?(e.set(1,0,0),n.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,n,i){return this.set(e.x,n.x,i.x,0,e.y,n.y,i.y,0,e.z,n.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const n=this.elements,i=e.elements,r=1/ll.setFromMatrixColumn(e,0).length(),s=1/ll.setFromMatrixColumn(e,1).length(),o=1/ll.setFromMatrixColumn(e,2).length();return n[0]=i[0]*r,n[1]=i[1]*r,n[2]=i[2]*r,n[3]=0,n[4]=i[4]*s,n[5]=i[5]*s,n[6]=i[6]*s,n[7]=0,n[8]=i[8]*o,n[9]=i[9]*o,n[10]=i[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),c=Math.sin(i),u=Math.cos(r),f=Math.sin(r),h=Math.cos(s),p=Math.sin(s);if(e.order==="XYZ"){const m=o*h,v=o*p,_=c*h,w=c*p;n[0]=u*h,n[4]=-u*p,n[8]=f,n[1]=v+_*f,n[5]=m-w*f,n[9]=-c*u,n[2]=w-m*f,n[6]=_+v*f,n[10]=o*u}else if(e.order==="YXZ"){const m=u*h,v=u*p,_=f*h,w=f*p;n[0]=m+w*c,n[4]=_*c-v,n[8]=o*f,n[1]=o*p,n[5]=o*h,n[9]=-c,n[2]=v*c-_,n[6]=w+m*c,n[10]=o*u}else if(e.order==="ZXY"){const m=u*h,v=u*p,_=f*h,w=f*p;n[0]=m-w*c,n[4]=-o*p,n[8]=_+v*c,n[1]=v+_*c,n[5]=o*h,n[9]=w-m*c,n[2]=-o*f,n[6]=c,n[10]=o*u}else if(e.order==="ZYX"){const m=o*h,v=o*p,_=c*h,w=c*p;n[0]=u*h,n[4]=_*f-v,n[8]=m*f+w,n[1]=u*p,n[5]=w*f+m,n[9]=v*f-_,n[2]=-f,n[6]=c*u,n[10]=o*u}else if(e.order==="YZX"){const m=o*u,v=o*f,_=c*u,w=c*f;n[0]=u*h,n[4]=w-m*p,n[8]=_*p+v,n[1]=p,n[5]=o*h,n[9]=-c*h,n[2]=-f*h,n[6]=v*p+_,n[10]=m-w*p}else if(e.order==="XZY"){const m=o*u,v=o*f,_=c*u,w=c*f;n[0]=u*h,n[4]=-p,n[8]=f*h,n[1]=m*p+w,n[5]=o*h,n[9]=v*p-_,n[2]=_*p-v,n[6]=c*h,n[10]=w*p+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(UH,e,FH)}lookAt(e,n,i){const r=this.elements;return Ki.subVectors(e,n),Ki.lengthSq()===0&&(Ki.z=1),Ki.normalize(),pa.crossVectors(i,Ki),pa.lengthSq()===0&&(Math.abs(i.z)===1?Ki.x+=1e-4:Ki.z+=1e-4,Ki.normalize(),pa.crossVectors(i,Ki)),pa.normalize(),Zd.crossVectors(Ki,pa),r[0]=pa.x,r[4]=Zd.x,r[8]=Ki.x,r[1]=pa.y,r[5]=Zd.y,r[9]=Ki.y,r[2]=pa.z,r[6]=Zd.z,r[10]=Ki.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const i=e.elements,r=n.elements,s=this.elements,o=i[0],c=i[4],u=i[8],f=i[12],h=i[1],p=i[5],m=i[9],v=i[13],_=i[2],w=i[6],y=i[10],x=i[14],M=i[3],A=i[7],T=i[11],D=i[15],I=r[0],U=r[4],S=r[8],R=r[12],V=r[1],F=r[5],j=r[9],Z=r[13],H=r[2],q=r[6],J=r[10],Q=r[14],W=r[3],X=r[7],K=r[11],B=r[15];return s[0]=o*I+c*V+u*H+f*W,s[4]=o*U+c*F+u*q+f*X,s[8]=o*S+c*j+u*J+f*K,s[12]=o*R+c*Z+u*Q+f*B,s[1]=h*I+p*V+m*H+v*W,s[5]=h*U+p*F+m*q+v*X,s[9]=h*S+p*j+m*J+v*K,s[13]=h*R+p*Z+m*Q+v*B,s[2]=_*I+w*V+y*H+x*W,s[6]=_*U+w*F+y*q+x*X,s[10]=_*S+w*j+y*J+x*K,s[14]=_*R+w*Z+y*Q+x*B,s[3]=M*I+A*V+T*H+D*W,s[7]=M*U+A*F+T*q+D*X,s[11]=M*S+A*j+T*J+D*K,s[15]=M*R+A*Z+T*Q+D*B,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],i=e[4],r=e[8],s=e[12],o=e[1],c=e[5],u=e[9],f=e[13],h=e[2],p=e[6],m=e[10],v=e[14],_=e[3],w=e[7],y=e[11],x=e[15],M=u*v-f*m,A=c*v-f*p,T=c*m-u*p,D=o*v-f*h,I=o*m-u*h,U=o*p-c*h;return n*(w*M-y*A+x*T)-i*(_*M-y*D+x*I)+r*(_*A-w*D+x*U)-s*(_*T-w*I+y*U)}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,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=n,r[14]=i),this}invert(){const e=this.elements,n=e[0],i=e[1],r=e[2],s=e[3],o=e[4],c=e[5],u=e[6],f=e[7],h=e[8],p=e[9],m=e[10],v=e[11],_=e[12],w=e[13],y=e[14],x=e[15],M=n*c-i*o,A=n*u-r*o,T=n*f-s*o,D=i*u-r*c,I=i*f-s*c,U=r*f-s*u,S=h*w-p*_,R=h*y-m*_,V=h*x-v*_,F=p*y-m*w,j=p*x-v*w,Z=m*x-v*y,H=M*Z-A*j+T*F+D*V-I*R+U*S;if(H===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const q=1/H;return e[0]=(c*Z-u*j+f*F)*q,e[1]=(r*j-i*Z-s*F)*q,e[2]=(w*U-y*I+x*D)*q,e[3]=(m*I-p*U-v*D)*q,e[4]=(u*V-o*Z-f*R)*q,e[5]=(n*Z-r*V+s*R)*q,e[6]=(y*T-_*U-x*A)*q,e[7]=(h*U-m*T+v*A)*q,e[8]=(o*j-c*V+f*S)*q,e[9]=(i*V-n*j-s*S)*q,e[10]=(_*I-w*T+x*M)*q,e[11]=(p*T-h*I-v*M)*q,e[12]=(c*R-o*F-u*S)*q,e[13]=(n*F-i*R+r*S)*q,e[14]=(w*A-_*D-y*M)*q,e[15]=(h*D-p*A+m*M)*q,this}scale(e){const n=this.elements,i=e.x,r=e.y,s=e.z;return n[0]*=i,n[4]*=r,n[8]*=s,n[1]*=i,n[5]*=r,n[9]*=s,n[2]*=i,n[6]*=r,n[10]*=s,n[3]*=i,n[7]*=r,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,i,r))}makeTranslation(e,n,i){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,i,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,n,-i,0,0,i,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),i=Math.sin(e);return this.set(n,0,i,0,0,1,0,0,-i,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),i=Math.sin(e);return this.set(n,-i,0,0,i,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const i=Math.cos(n),r=Math.sin(n),s=1-i,o=e.x,c=e.y,u=e.z,f=s*o,h=s*c;return this.set(f*o+i,f*c-r*u,f*u+r*c,0,f*c+r*u,h*c+i,h*u-r*o,0,f*u-r*c,h*u+r*o,s*u*u+i,0,0,0,0,1),this}makeScale(e,n,i){return this.set(e,0,0,0,0,n,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,n,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,n,r,1,0,0,0,0,1),this}compose(e,n,i){const r=this.elements,s=n._x,o=n._y,c=n._z,u=n._w,f=s+s,h=o+o,p=c+c,m=s*f,v=s*h,_=s*p,w=o*h,y=o*p,x=c*p,M=u*f,A=u*h,T=u*p,D=i.x,I=i.y,U=i.z;return r[0]=(1-(w+x))*D,r[1]=(v+T)*D,r[2]=(_-A)*D,r[3]=0,r[4]=(v-T)*I,r[5]=(1-(m+x))*I,r[6]=(y+M)*I,r[7]=0,r[8]=(_+A)*U,r[9]=(y-M)*U,r[10]=(1-(m+w))*U,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,n,i){const r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];const s=this.determinant();if(s===0)return i.set(1,1,1),n.identity(),this;let o=ll.set(r[0],r[1],r[2]).length();const c=ll.set(r[4],r[5],r[6]).length(),u=ll.set(r[8],r[9],r[10]).length();s<0&&(o=-o),Rr.copy(this);const f=1/o,h=1/c,p=1/u;return Rr.elements[0]*=f,Rr.elements[1]*=f,Rr.elements[2]*=f,Rr.elements[4]*=h,Rr.elements[5]*=h,Rr.elements[6]*=h,Rr.elements[8]*=p,Rr.elements[9]*=p,Rr.elements[10]*=p,n.setFromRotationMatrix(Rr),i.x=o,i.y=c,i.z=u,this}makePerspective(e,n,i,r,s,o,c=Qr,u=!1){const f=this.elements,h=2*s/(n-e),p=2*s/(i-r),m=(n+e)/(n-e),v=(i+r)/(i-r);let _,w;if(u)_=s/(o-s),w=o*s/(o-s);else if(c===Qr)_=-(o+s)/(o-s),w=-2*o*s/(o-s);else if(c===yh)_=-o/(o-s),w=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+c);return f[0]=h,f[4]=0,f[8]=m,f[12]=0,f[1]=0,f[5]=p,f[9]=v,f[13]=0,f[2]=0,f[6]=0,f[10]=_,f[14]=w,f[3]=0,f[7]=0,f[11]=-1,f[15]=0,this}makeOrthographic(e,n,i,r,s,o,c=Qr,u=!1){const f=this.elements,h=2/(n-e),p=2/(i-r),m=-(n+e)/(n-e),v=-(i+r)/(i-r);let _,w;if(u)_=1/(o-s),w=o/(o-s);else if(c===Qr)_=-2/(o-s),w=-(o+s)/(o-s);else if(c===yh)_=-1/(o-s),w=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+c);return f[0]=h,f[4]=0,f[8]=0,f[12]=m,f[1]=0,f[5]=p,f[9]=0,f[13]=v,f[2]=0,f[6]=0,f[10]=_,f[14]=w,f[3]=0,f[7]=0,f[11]=0,f[15]=1,this}equals(e){const n=this.elements,i=e.elements;for(let r=0;r<16;r++)if(n[r]!==i[r])return!1;return!0}fromArray(e,n=0){for(let i=0;i<16;i++)this.elements[i]=e[i+n];return this}toArray(e=[],n=0){const i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e[n+9]=i[9],e[n+10]=i[10],e[n+11]=i[11],e[n+12]=i[12],e[n+13]=i[13],e[n+14]=i[14],e[n+15]=i[15],e}}const ll=new me,Rr=new Yn,UH=new me(0,0,0),FH=new me(1,1,1),pa=new me,Zd=new me,Ki=new me,CE=new Yn,RE=new Jl;let To=class sR{constructor(e=0,n=0,i=0,r=sR.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=i,this._order=r}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,i,r=this._order){return this._x=e,this._y=n,this._z=i,this._order=r,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,i=!0){const r=e.elements,s=r[0],o=r[4],c=r[8],u=r[1],f=r[5],h=r[9],p=r[2],m=r[6],v=r[10];switch(n){case"XYZ":this._y=Math.asin(ln(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,v),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(m,f),this._z=0);break;case"YXZ":this._x=Math.asin(-ln(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(c,v),this._z=Math.atan2(u,f)):(this._y=Math.atan2(-p,s),this._z=0);break;case"ZXY":this._x=Math.asin(ln(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-p,v),this._z=Math.atan2(-o,f)):(this._y=0,this._z=Math.atan2(u,s));break;case"ZYX":this._y=Math.asin(-ln(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(m,v),this._z=Math.atan2(u,s)):(this._x=0,this._z=Math.atan2(-o,f));break;case"YZX":this._z=Math.asin(ln(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-h,f),this._y=Math.atan2(-p,s)):(this._x=0,this._y=Math.atan2(c,v));break;case"XZY":this._z=Math.asin(-ln(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,f),this._y=Math.atan2(c,s)):(this._x=Math.atan2(-h,v),this._y=0);break;default:Ht("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,i){return CE.makeRotationFromQuaternion(e),this.setFromRotationMatrix(CE,n,i)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return RE.setFromEuler(this),this.setFromQuaternion(RE,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}};To.DEFAULT_ORDER="XYZ";class aR{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 OH=0;const PE=new me,cl=new Jl,Ms=new Yn,Jd=new me,zc=new me,BH=new me,zH=new Jl,kE=new me(1,0,0),LE=new me(0,1,0),DE=new me(0,0,1),NE={type:"added"},VH={type:"removed"},ul={type:"childadded",child:null},mg={type:"childremoved",child:null};class er extends Zl{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:OH++}),this.uuid=Lu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=er.DEFAULT_UP.clone();const e=new me,n=new To,i=new Jl,r=new me(1,1,1);function s(){i.setFromEuler(n,!1)}function o(){n.setFromQuaternion(i,void 0,!1)}n._onChange(s),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Yn},normalMatrix:{value:new jt}}),this.matrix=new Yn,this.matrixWorld=new Yn,this.matrixAutoUpdate=er.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=er.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new aR,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 cl.setFromAxisAngle(e,n),this.quaternion.multiply(cl),this}rotateOnWorldAxis(e,n){return cl.setFromAxisAngle(e,n),this.quaternion.premultiply(cl),this}rotateX(e){return this.rotateOnAxis(kE,e)}rotateY(e){return this.rotateOnAxis(LE,e)}rotateZ(e){return this.rotateOnAxis(DE,e)}translateOnAxis(e,n){return PE.copy(e).applyQuaternion(this.quaternion),this.position.add(PE.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(kE,e)}translateY(e){return this.translateOnAxis(LE,e)}translateZ(e){return this.translateOnAxis(DE,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ms.copy(this.matrixWorld).invert())}lookAt(e,n,i){e.isVector3?Jd.copy(e):Jd.set(e,n,i);const r=this.parent;this.updateWorldMatrix(!0,!1),zc.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ms.lookAt(zc,Jd,this.up):Ms.lookAt(Jd,zc,this.up),this.quaternion.setFromRotationMatrix(Ms),r&&(Ms.extractRotation(r.matrixWorld),cl.setFromRotationMatrix(Ms),this.quaternion.premultiply(cl.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(_n("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(NE),ul.child=e,this.dispatchEvent(ul),ul.child=null):_n("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(VH),mg.child=e,this.dispatchEvent(mg),mg.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),Ms.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ms.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ms),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(NE),ul.child=e,this.dispatchEvent(ul),ul.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 i=0,r=this.children.length;i<r;i++){const o=this.children[i].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,i=[]){this[e]===n&&i.push(this);const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(e,n,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(zc,e,BH),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(zc,zH,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 i=0,r=n.length;i<r;i++)n[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let i=0,r=n.length;i<r;i++)n[i].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,i=e.y,r=e.z,s=this.matrix.elements;s[12]+=n-s[0]*n-s[4]*i-s[8]*r,s[13]+=i-s[1]*n-s[5]*i-s[9]*r,s[14]+=r-s[2]*n-s[6]*i-s[10]*r}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 i=0,r=n.length;i<r;i++)n[i].updateMatrixWorld(e)}updateWorldMatrix(e,n){const i=this.parent;if(e===!0&&i!==null&&i.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 r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",i={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(c=>({...c,boundingBox:c.boundingBox?c.boundingBox.toJSON():void 0,boundingSphere:c.boundingSphere?c.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(c=>({...c})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(c,u){return c[u.uuid]===void 0&&(c[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const c=this.geometry.parameters;if(c!==void 0&&c.shapes!==void 0){const u=c.shapes;if(Array.isArray(u))for(let f=0,h=u.length;f<h;f++){const p=u[f];s(e.shapes,p)}else s(e.shapes,u)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const c=[];for(let u=0,f=this.material.length;u<f;u++)c.push(s(e.materials,this.material[u]));r.material=c}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let c=0;c<this.children.length;c++)r.children.push(this.children[c].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let c=0;c<this.animations.length;c++){const u=this.animations[c];r.animations.push(s(e.animations,u))}}if(n){const c=o(e.geometries),u=o(e.materials),f=o(e.textures),h=o(e.images),p=o(e.shapes),m=o(e.skeletons),v=o(e.animations),_=o(e.nodes);c.length>0&&(i.geometries=c),u.length>0&&(i.materials=u),f.length>0&&(i.textures=f),h.length>0&&(i.images=h),p.length>0&&(i.shapes=p),m.length>0&&(i.skeletons=m),v.length>0&&(i.animations=v),_.length>0&&(i.nodes=_)}return i.object=r,i;function o(c){const u=[];for(const f in c){const h=c[f];delete h.metadata,u.push(h)}return u}}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 i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}er.DEFAULT_UP=new me(0,1,0);er.DEFAULT_MATRIX_AUTO_UPDATE=!0;er.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Qd extends er{constructor(){super(),this.isGroup=!0,this.type="Group"}}const HH={type:"move"};class gg{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Qd,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 Qd,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new me,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new me),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Qd,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new me,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new me),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 i of e.hand.values())this._getHandJoint(n,i)}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,i){let r=null,s=null,o=null;const c=this._targetRay,u=this._grip,f=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(f&&e.hand){o=!0;for(const w of e.hand.values()){const y=n.getJointPose(w,i),x=this._getHandJoint(f,w);y!==null&&(x.matrix.fromArray(y.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=y.radius),x.visible=y!==null}const h=f.joints["index-finger-tip"],p=f.joints["thumb-tip"],m=h.position.distanceTo(p.position),v=.02,_=.005;f.inputState.pinching&&m>v+_?(f.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!f.inputState.pinching&&m<=v-_&&(f.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,i),s!==null&&(u.matrix.fromArray(s.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,s.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(s.linearVelocity)):u.hasLinearVelocity=!1,s.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(s.angularVelocity)):u.hasAngularVelocity=!1));c!==null&&(r=n.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,this.dispatchEvent(HH)))}return c!==null&&(c.visible=r!==null),u!==null&&(u.visible=s!==null),f!==null&&(f.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const i=new Qd;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[n.jointName]=i,e.add(i)}return e.joints[n.jointName]}}const oR={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},ma={h:0,s:0,l:0},ef={h:0,s:0,l:0};function vg(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 Mn{constructor(e,n,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,i)}set(e,n,i){if(n===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,n,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=ur){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,fn.colorSpaceToWorking(this,n),this}setRGB(e,n,i,r=fn.workingColorSpace){return this.r=e,this.g=n,this.b=i,fn.colorSpaceToWorking(this,r),this}setHSL(e,n,i,r=fn.workingColorSpace){if(e=RH(e,1),n=ln(n,0,1),i=ln(i,0,1),n===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+n):i+n-i*n,o=2*i-s;this.r=vg(o,s,e+1/3),this.g=vg(o,s,e),this.b=vg(o,s,e-1/3)}return fn.colorSpaceToWorking(this,r),this}setStyle(e,n=ur){function i(s){s!==void 0&&parseFloat(s)<1&&Ht("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=r[1],c=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:Ht("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(s,16),n);Ht("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=ur){const i=oR[e.toLowerCase()];return i!==void 0?this.setHex(i,n):Ht("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=Fs(e.r),this.g=Fs(e.g),this.b=Fs(e.b),this}copyLinearToSRGB(e){return this.r=Ll(e.r),this.g=Ll(e.g),this.b=Ll(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ur){return fn.workingToColorSpace(xi.copy(this),e),Math.round(ln(xi.r*255,0,255))*65536+Math.round(ln(xi.g*255,0,255))*256+Math.round(ln(xi.b*255,0,255))}getHexString(e=ur){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=fn.workingColorSpace){fn.workingToColorSpace(xi.copy(this),n);const i=xi.r,r=xi.g,s=xi.b,o=Math.max(i,r,s),c=Math.min(i,r,s);let u,f;const h=(c+o)/2;if(c===o)u=0,f=0;else{const p=o-c;switch(f=h<=.5?p/(o+c):p/(2-o-c),o){case i:u=(r-s)/p+(r<s?6:0);break;case r:u=(s-i)/p+2;break;case s:u=(i-r)/p+4;break}u/=6}return e.h=u,e.s=f,e.l=h,e}getRGB(e,n=fn.workingColorSpace){return fn.workingToColorSpace(xi.copy(this),n),e.r=xi.r,e.g=xi.g,e.b=xi.b,e}getStyle(e=ur){fn.workingToColorSpace(xi.copy(this),e);const n=xi.r,i=xi.g,r=xi.b;return e!==ur?`color(${e} ${n.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,n,i){return this.getHSL(ma),this.setHSL(ma.h+e,ma.s+n,ma.l+i)}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,i){return this.r=e.r+(n.r-e.r)*i,this.g=e.g+(n.g-e.g)*i,this.b=e.b+(n.b-e.b)*i,this}lerpHSL(e,n){this.getHSL(ma),e.getHSL(ef);const i=ug(ma.h,ef.h,n),r=ug(ma.s,ef.s,n),s=ug(ma.l,ef.l,n);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*n+s[3]*i+s[6]*r,this.g=s[1]*n+s[4]*i+s[7]*r,this.b=s[2]*n+s[5]*i+s[8]*r,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 xi=new Mn;Mn.NAMES=oR;class GH extends er{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 To,this.environmentIntensity=1,this.environmentRotation=new To,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 Pr=new me,Ts=new me,yg=new me,As=new me,dl=new me,fl=new me,IE=new me,_g=new me,xg=new me,bg=new me,Sg=new zn,wg=new zn,Eg=new zn;let Vc=class El{constructor(e=new me,n=new me,i=new me){this.a=e,this.b=n,this.c=i}static getNormal(e,n,i,r){r.subVectors(i,n),Pr.subVectors(e,n),r.cross(Pr);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,n,i,r,s){Pr.subVectors(r,n),Ts.subVectors(i,n),yg.subVectors(e,n);const o=Pr.dot(Pr),c=Pr.dot(Ts),u=Pr.dot(yg),f=Ts.dot(Ts),h=Ts.dot(yg),p=o*f-c*c;if(p===0)return s.set(0,0,0),null;const m=1/p,v=(f*u-c*h)*m,_=(o*h-c*u)*m;return s.set(1-v-_,_,v)}static containsPoint(e,n,i,r){return this.getBarycoord(e,n,i,r,As)===null?!1:As.x>=0&&As.y>=0&&As.x+As.y<=1}static getInterpolation(e,n,i,r,s,o,c,u){return this.getBarycoord(e,n,i,r,As)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(s,As.x),u.addScaledVector(o,As.y),u.addScaledVector(c,As.z),u)}static getInterpolatedAttribute(e,n,i,r,s,o){return Sg.setScalar(0),wg.setScalar(0),Eg.setScalar(0),Sg.fromBufferAttribute(e,n),wg.fromBufferAttribute(e,i),Eg.fromBufferAttribute(e,r),o.setScalar(0),o.addScaledVector(Sg,s.x),o.addScaledVector(wg,s.y),o.addScaledVector(Eg,s.z),o}static isFrontFacing(e,n,i,r){return Pr.subVectors(i,n),Ts.subVectors(e,n),Pr.cross(Ts).dot(r)<0}set(e,n,i){return this.a.copy(e),this.b.copy(n),this.c.copy(i),this}setFromPointsAndIndices(e,n,i,r){return this.a.copy(e[n]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,n,i,r){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),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 Pr.subVectors(this.c,this.b),Ts.subVectors(this.a,this.b),Pr.cross(Ts).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return El.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return El.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,i,r,s){return El.getInterpolation(e,this.a,this.b,this.c,n,i,r,s)}containsPoint(e){return El.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return El.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const i=this.a,r=this.b,s=this.c;let o,c;dl.subVectors(r,i),fl.subVectors(s,i),_g.subVectors(e,i);const u=dl.dot(_g),f=fl.dot(_g);if(u<=0&&f<=0)return n.copy(i);xg.subVectors(e,r);const h=dl.dot(xg),p=fl.dot(xg);if(h>=0&&p<=h)return n.copy(r);const m=u*p-h*f;if(m<=0&&u>=0&&h<=0)return o=u/(u-h),n.copy(i).addScaledVector(dl,o);bg.subVectors(e,s);const v=dl.dot(bg),_=fl.dot(bg);if(_>=0&&v<=_)return n.copy(s);const w=v*f-u*_;if(w<=0&&f>=0&&_<=0)return c=f/(f-_),n.copy(i).addScaledVector(fl,c);const y=h*_-v*p;if(y<=0&&p-h>=0&&v-_>=0)return IE.subVectors(s,r),c=(p-h)/(p-h+(v-_)),n.copy(r).addScaledVector(IE,c);const x=1/(y+w+m);return o=w*x,c=m*x,n.copy(i).addScaledVector(dl,o).addScaledVector(fl,c)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};class Du{constructor(e=new me(1/0,1/0,1/0),n=new me(-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,i=e.length;n<i;n+=3)this.expandByPoint(kr.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,i=e.count;n<i;n++)this.expandByPoint(kr.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,i=e.length;n<i;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const i=kr.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),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 i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,c=s.count;o<c;o++)e.isMesh===!0?e.getVertexPosition(o,kr):kr.fromBufferAttribute(s,o),kr.applyMatrix4(e.matrixWorld),this.expandByPoint(kr);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),tf.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),tf.copy(i.boundingBox)),tf.applyMatrix4(e.matrixWorld),this.union(tf)}const r=e.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],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,kr),kr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,i;return e.normal.x>0?(n=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),n<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Hc),nf.subVectors(this.max,Hc),hl.subVectors(e.a,Hc),pl.subVectors(e.b,Hc),ml.subVectors(e.c,Hc),ga.subVectors(pl,hl),va.subVectors(ml,pl),Ka.subVectors(hl,ml);let n=[0,-ga.z,ga.y,0,-va.z,va.y,0,-Ka.z,Ka.y,ga.z,0,-ga.x,va.z,0,-va.x,Ka.z,0,-Ka.x,-ga.y,ga.x,0,-va.y,va.x,0,-Ka.y,Ka.x,0];return!Mg(n,hl,pl,ml,nf)||(n=[1,0,0,0,1,0,0,0,1],!Mg(n,hl,pl,ml,nf))?!1:(rf.crossVectors(ga,va),n=[rf.x,rf.y,rf.z],Mg(n,hl,pl,ml,nf))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,kr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(kr).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:(Cs[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Cs[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Cs[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Cs[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Cs[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Cs[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Cs[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Cs[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Cs),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 Cs=[new me,new me,new me,new me,new me,new me,new me,new me],kr=new me,tf=new Du,hl=new me,pl=new me,ml=new me,ga=new me,va=new me,Ka=new me,Hc=new me,nf=new me,rf=new me,Za=new me;function Mg(t,e,n,i,r){for(let s=0,o=t.length-3;s<=o;s+=3){Za.fromArray(t,s);const c=r.x*Math.abs(Za.x)+r.y*Math.abs(Za.y)+r.z*Math.abs(Za.z),u=e.dot(Za),f=n.dot(Za),h=i.dot(Za);if(Math.max(-Math.max(u,f,h),Math.min(u,f,h))>c)return!1}return!0}const Wn=new me,sf=new bn;let jH=0;class Br{constructor(e,n,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:jH++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=i,this.usage=bE,this.updateRanges=[],this.gpuType=Jr,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,i){e*=this.itemSize,i*=n.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=n.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,i=this.count;n<i;n++)sf.fromBufferAttribute(this,n),sf.applyMatrix3(e),this.setXY(n,sf.x,sf.y);else if(this.itemSize===3)for(let n=0,i=this.count;n<i;n++)Wn.fromBufferAttribute(this,n),Wn.applyMatrix3(e),this.setXYZ(n,Wn.x,Wn.y,Wn.z);return this}applyMatrix4(e){for(let n=0,i=this.count;n<i;n++)Wn.fromBufferAttribute(this,n),Wn.applyMatrix4(e),this.setXYZ(n,Wn.x,Wn.y,Wn.z);return this}applyNormalMatrix(e){for(let n=0,i=this.count;n<i;n++)Wn.fromBufferAttribute(this,n),Wn.applyNormalMatrix(e),this.setXYZ(n,Wn.x,Wn.y,Wn.z);return this}transformDirection(e){for(let n=0,i=this.count;n<i;n++)Wn.fromBufferAttribute(this,n),Wn.transformDirection(e),this.setXYZ(n,Wn.x,Wn.y,Wn.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let i=this.array[e*this.itemSize+n];return this.normalized&&(i=Bc(i,this.array)),i}setComponent(e,n,i){return this.normalized&&(i=Hi(i,this.array)),this.array[e*this.itemSize+n]=i,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Bc(n,this.array)),n}setX(e,n){return this.normalized&&(n=Hi(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Bc(n,this.array)),n}setY(e,n){return this.normalized&&(n=Hi(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=Bc(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Hi(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=Bc(n,this.array)),n}setW(e,n){return this.normalized&&(n=Hi(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,i){return e*=this.itemSize,this.normalized&&(n=Hi(n,this.array),i=Hi(i,this.array)),this.array[e+0]=n,this.array[e+1]=i,this}setXYZ(e,n,i,r){return e*=this.itemSize,this.normalized&&(n=Hi(n,this.array),i=Hi(i,this.array),r=Hi(r,this.array)),this.array[e+0]=n,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,n,i,r,s){return e*=this.itemSize,this.normalized&&(n=Hi(n,this.array),i=Hi(i,this.array),r=Hi(r,this.array),s=Hi(s,this.array)),this.array[e+0]=n,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,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!==bE&&(e.usage=this.usage),e}}class lR extends Br{constructor(e,n,i){super(new Uint16Array(e),n,i)}}class cR extends Br{constructor(e,n,i){super(new Uint32Array(e),n,i)}}class Os extends Br{constructor(e,n,i){super(new Float32Array(e),n,i)}}const WH=new Du,Gc=new me,Tg=new me;class i_{constructor(e=new me,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 i=this.center;n!==void 0?i.copy(n):WH.setFromPoints(e).getCenter(i);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),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 i=this.center.distanceToSquared(e);return n.copy(e),i>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;Gc.subVectors(e,this.center);const n=Gc.lengthSq();if(n>this.radius*this.radius){const i=Math.sqrt(n),r=(i-this.radius)*.5;this.center.addScaledVector(Gc,r/i),this.radius+=r}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):(Tg.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Gc.copy(e.center).add(Tg)),this.expandByPoint(Gc.copy(e.center).sub(Tg))),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 $H=0;const lr=new Yn,Ag=new er,gl=new me,Zi=new Du,jc=new Du,li=new me;class ps extends Zl{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$H++}),this.uuid=Lu(),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(MH(e)?cR:lR)(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,i=0){this.groups.push({start:e,count:n,materialIndex:i})}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 i=this.attributes.normal;if(i!==void 0){const s=new jt().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return lr.makeRotationFromQuaternion(e),this.applyMatrix4(lr),this}rotateX(e){return lr.makeRotationX(e),this.applyMatrix4(lr),this}rotateY(e){return lr.makeRotationY(e),this.applyMatrix4(lr),this}rotateZ(e){return lr.makeRotationZ(e),this.applyMatrix4(lr),this}translate(e,n,i){return lr.makeTranslation(e,n,i),this.applyMatrix4(lr),this}scale(e,n,i){return lr.makeScale(e,n,i),this.applyMatrix4(lr),this}lookAt(e){return Ag.lookAt(e),Ag.updateMatrix(),this.applyMatrix4(Ag.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(gl).negate(),this.translate(gl.x,gl.y,gl.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const i=[];for(let r=0,s=e.length;r<s;r++){const o=e[r];i.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Os(i,3))}else{const i=Math.min(e.length,n.count);for(let r=0;r<i;r++){const s=e[r];n.setXYZ(r,s.x,s.y,s.z||0)}e.length>n.count&&Ht("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 Du);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){_n("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new me(-1/0,-1/0,-1/0),new me(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let i=0,r=n.length;i<r;i++){const s=n[i];Zi.setFromBufferAttribute(s),this.morphTargetsRelative?(li.addVectors(this.boundingBox.min,Zi.min),this.boundingBox.expandByPoint(li),li.addVectors(this.boundingBox.max,Zi.max),this.boundingBox.expandByPoint(li)):(this.boundingBox.expandByPoint(Zi.min),this.boundingBox.expandByPoint(Zi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&_n('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 i_);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){_n("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new me,1/0);return}if(e){const i=this.boundingSphere.center;if(Zi.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const c=n[s];jc.setFromBufferAttribute(c),this.morphTargetsRelative?(li.addVectors(Zi.min,jc.min),Zi.expandByPoint(li),li.addVectors(Zi.max,jc.max),Zi.expandByPoint(li)):(Zi.expandByPoint(jc.min),Zi.expandByPoint(jc.max))}Zi.getCenter(i);let r=0;for(let s=0,o=e.count;s<o;s++)li.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(li));if(n)for(let s=0,o=n.length;s<o;s++){const c=n[s],u=this.morphTargetsRelative;for(let f=0,h=c.count;f<h;f++)li.fromBufferAttribute(c,f),u&&(gl.fromBufferAttribute(e,f),li.add(gl)),r=Math.max(r,i.distanceToSquared(li))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&_n('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){_n("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=n.position,r=n.normal,s=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Br(new Float32Array(4*i.count),4));const o=this.getAttribute("tangent"),c=[],u=[];for(let S=0;S<i.count;S++)c[S]=new me,u[S]=new me;const f=new me,h=new me,p=new me,m=new bn,v=new bn,_=new bn,w=new me,y=new me;function x(S,R,V){f.fromBufferAttribute(i,S),h.fromBufferAttribute(i,R),p.fromBufferAttribute(i,V),m.fromBufferAttribute(s,S),v.fromBufferAttribute(s,R),_.fromBufferAttribute(s,V),h.sub(f),p.sub(f),v.sub(m),_.sub(m);const F=1/(v.x*_.y-_.x*v.y);isFinite(F)&&(w.copy(h).multiplyScalar(_.y).addScaledVector(p,-v.y).multiplyScalar(F),y.copy(p).multiplyScalar(v.x).addScaledVector(h,-_.x).multiplyScalar(F),c[S].add(w),c[R].add(w),c[V].add(w),u[S].add(y),u[R].add(y),u[V].add(y))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let S=0,R=M.length;S<R;++S){const V=M[S],F=V.start,j=V.count;for(let Z=F,H=F+j;Z<H;Z+=3)x(e.getX(Z+0),e.getX(Z+1),e.getX(Z+2))}const A=new me,T=new me,D=new me,I=new me;function U(S){D.fromBufferAttribute(r,S),I.copy(D);const R=c[S];A.copy(R),A.sub(D.multiplyScalar(D.dot(R))).normalize(),T.crossVectors(I,R);const F=T.dot(u[S])<0?-1:1;o.setXYZW(S,A.x,A.y,A.z,F)}for(let S=0,R=M.length;S<R;++S){const V=M[S],F=V.start,j=V.count;for(let Z=F,H=F+j;Z<H;Z+=3)U(e.getX(Z+0)),U(e.getX(Z+1)),U(e.getX(Z+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Br(new Float32Array(n.count*3),3),this.setAttribute("normal",i);else for(let m=0,v=i.count;m<v;m++)i.setXYZ(m,0,0,0);const r=new me,s=new me,o=new me,c=new me,u=new me,f=new me,h=new me,p=new me;if(e)for(let m=0,v=e.count;m<v;m+=3){const _=e.getX(m+0),w=e.getX(m+1),y=e.getX(m+2);r.fromBufferAttribute(n,_),s.fromBufferAttribute(n,w),o.fromBufferAttribute(n,y),h.subVectors(o,s),p.subVectors(r,s),h.cross(p),c.fromBufferAttribute(i,_),u.fromBufferAttribute(i,w),f.fromBufferAttribute(i,y),c.add(h),u.add(h),f.add(h),i.setXYZ(_,c.x,c.y,c.z),i.setXYZ(w,u.x,u.y,u.z),i.setXYZ(y,f.x,f.y,f.z)}else for(let m=0,v=n.count;m<v;m+=3)r.fromBufferAttribute(n,m+0),s.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),h.subVectors(o,s),p.subVectors(r,s),h.cross(p),i.setXYZ(m+0,h.x,h.y,h.z),i.setXYZ(m+1,h.x,h.y,h.z),i.setXYZ(m+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,i=e.count;n<i;n++)li.fromBufferAttribute(e,n),li.normalize(),e.setXYZ(n,li.x,li.y,li.z)}toNonIndexed(){function e(c,u){const f=c.array,h=c.itemSize,p=c.normalized,m=new f.constructor(u.length*h);let v=0,_=0;for(let w=0,y=u.length;w<y;w++){c.isInterleavedBufferAttribute?v=u[w]*c.data.stride+c.offset:v=u[w]*h;for(let x=0;x<h;x++)m[_++]=f[v++]}return new Br(m,h,p)}if(this.index===null)return Ht("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new ps,i=this.index.array,r=this.attributes;for(const c in r){const u=r[c],f=e(u,i);n.setAttribute(c,f)}const s=this.morphAttributes;for(const c in s){const u=[],f=s[c];for(let h=0,p=f.length;h<p;h++){const m=f[h],v=e(m,i);u.push(v)}n.morphAttributes[c]=u}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let c=0,u=o.length;c<u;c++){const f=o[c];n.addGroup(f.start,f.count,f.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 u=this.parameters;for(const f in u)u[f]!==void 0&&(e[f]=u[f]);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 i=this.attributes;for(const u in i){const f=i[u];e.data.attributes[u]=f.toJSON(e.data)}const r={};let s=!1;for(const u in this.morphAttributes){const f=this.morphAttributes[u],h=[];for(let p=0,m=f.length;p<m;p++){const v=f[p];h.push(v.toJSON(e.data))}h.length>0&&(r[u]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const c=this.boundingSphere;return c!==null&&(e.data.boundingSphere=c.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 i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const f in r){const h=r[f];this.setAttribute(f,h.clone(n))}const s=e.morphAttributes;for(const f in s){const h=[],p=s[f];for(let m=0,v=p.length;m<v;m++)h.push(p[m].clone(n));this.morphAttributes[f]=h}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let f=0,h=o.length;f<h;f++){const p=o[f];this.addGroup(p.start,p.count,p.materialIndex)}const c=e.boundingBox;c!==null&&(this.boundingBox=c.clone());const u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}let XH=0;class zh extends Zl{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:XH++}),this.uuid=Lu(),this.name="",this.type="Material",this.blending=vo,this.side=La,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=z0,this.blendDst=V0,this.blendEquation=so,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Mn(0,0,0),this.blendAlpha=0,this.depthFunc=zl,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=xE,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=al,this.stencilZFail=al,this.stencilZPass=al,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 i=e[n];if(i===void 0){Ht(`Material: parameter '${n}' has value of undefined.`);continue}const r=this[n];if(r===void 0){Ht(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[n]=i}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==vo&&(i.blending=this.blending),this.side!==La&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==z0&&(i.blendSrc=this.blendSrc),this.blendDst!==V0&&(i.blendDst=this.blendDst),this.blendEquation!==so&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==zl&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==xE&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==al&&(i.stencilFail=this.stencilFail),this.stencilZFail!==al&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==al&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){const o=[];for(const c in s){const u=s[c];delete u.metadata,o.push(u)}return o}if(n){const s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}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 i=null;if(n!==null){const r=n.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=n[s].clone()}return this.clippingPlanes=i,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 Rs=new me,Cg=new me,af=new me,ya=new me,Rg=new me,of=new me,Pg=new me;class qH{constructor(e=new me,n=new me(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,Rs)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const i=n.dot(this.direction);return i<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=Rs.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Rs.copy(this.origin).addScaledVector(this.direction,n),Rs.distanceToSquared(e))}distanceSqToSegment(e,n,i,r){Cg.copy(e).add(n).multiplyScalar(.5),af.copy(n).sub(e).normalize(),ya.copy(this.origin).sub(Cg);const s=e.distanceTo(n)*.5,o=-this.direction.dot(af),c=ya.dot(this.direction),u=-ya.dot(af),f=ya.lengthSq(),h=Math.abs(1-o*o);let p,m,v,_;if(h>0)if(p=o*u-c,m=o*c-u,_=s*h,p>=0)if(m>=-_)if(m<=_){const w=1/h;p*=w,m*=w,v=p*(p+o*m+2*c)+m*(o*p+m+2*u)+f}else m=s,p=Math.max(0,-(o*m+c)),v=-p*p+m*(m+2*u)+f;else m=-s,p=Math.max(0,-(o*m+c)),v=-p*p+m*(m+2*u)+f;else m<=-_?(p=Math.max(0,-(-o*s+c)),m=p>0?-s:Math.min(Math.max(-s,-u),s),v=-p*p+m*(m+2*u)+f):m<=_?(p=0,m=Math.min(Math.max(-s,-u),s),v=m*(m+2*u)+f):(p=Math.max(0,-(o*s+c)),m=p>0?s:Math.min(Math.max(-s,-u),s),v=-p*p+m*(m+2*u)+f);else m=o>0?-s:s,p=Math.max(0,-(o*m+c)),v=-p*p+m*(m+2*u)+f;return i&&i.copy(this.origin).addScaledVector(this.direction,p),r&&r.copy(Cg).addScaledVector(af,m),v}intersectSphere(e,n){Rs.subVectors(e.center,this.origin);const i=Rs.dot(this.direction),r=Rs.dot(Rs)-i*i,s=e.radius*e.radius;if(r>s)return null;const o=Math.sqrt(s-r),c=i-o,u=i+o;return u<0?null:c<0?this.at(u,n):this.at(c,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 i=-(this.origin.dot(e.normal)+e.constant)/n;return i>=0?i:null}intersectPlane(e,n){const i=this.distanceToPlane(e);return i===null?null:this.at(i,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let i,r,s,o,c,u;const f=1/this.direction.x,h=1/this.direction.y,p=1/this.direction.z,m=this.origin;return f>=0?(i=(e.min.x-m.x)*f,r=(e.max.x-m.x)*f):(i=(e.max.x-m.x)*f,r=(e.min.x-m.x)*f),h>=0?(s=(e.min.y-m.y)*h,o=(e.max.y-m.y)*h):(s=(e.max.y-m.y)*h,o=(e.min.y-m.y)*h),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o<r||isNaN(r))&&(r=o),p>=0?(c=(e.min.z-m.z)*p,u=(e.max.z-m.z)*p):(c=(e.max.z-m.z)*p,u=(e.min.z-m.z)*p),i>u||c>r)||((c>i||i!==i)&&(i=c),(u<r||r!==r)&&(r=u),r<0)?null:this.at(i>=0?i:r,n)}intersectsBox(e){return this.intersectBox(e,Rs)!==null}intersectTriangle(e,n,i,r,s){Rg.subVectors(n,e),of.subVectors(i,e),Pg.crossVectors(Rg,of);let o=this.direction.dot(Pg),c;if(o>0){if(r)return null;c=1}else if(o<0)c=-1,o=-o;else return null;ya.subVectors(this.origin,e);const u=c*this.direction.dot(of.crossVectors(ya,of));if(u<0)return null;const f=c*this.direction.dot(Rg.cross(ya));if(f<0||u+f>o)return null;const h=-c*ya.dot(Pg);return h<0?null:this.at(h/o,s)}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 uR extends zh{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Mn(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 To,this.combine=VC,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 UE=new Yn,Ja=new qH,lf=new i_,FE=new me,cf=new me,uf=new me,df=new me,kg=new me,ff=new me,OE=new me,hf=new me;let us=class extends er{constructor(e=new ps,n=new uR){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,i=Object.keys(n);if(i.length>0){const r=n[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const c=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=s}}}}getVertexPosition(e,n){const i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,o=i.morphTargetsRelative;n.fromBufferAttribute(r,e);const c=this.morphTargetInfluences;if(s&&c){ff.set(0,0,0);for(let u=0,f=s.length;u<f;u++){const h=c[u],p=s[u];h!==0&&(kg.fromBufferAttribute(p,e),o?ff.addScaledVector(kg,h):ff.addScaledVector(kg.sub(n),h))}n.add(ff)}return n}raycast(e,n){const i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),lf.copy(i.boundingSphere),lf.applyMatrix4(s),Ja.copy(e.ray).recast(e.near),!(lf.containsPoint(Ja.origin)===!1&&(Ja.intersectSphere(lf,FE)===null||Ja.origin.distanceToSquared(FE)>(e.far-e.near)**2))&&(UE.copy(s).invert(),Ja.copy(e.ray).applyMatrix4(UE),!(i.boundingBox!==null&&Ja.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,n,Ja)))}_computeIntersections(e,n,i){let r;const s=this.geometry,o=this.material,c=s.index,u=s.attributes.position,f=s.attributes.uv,h=s.attributes.uv1,p=s.attributes.normal,m=s.groups,v=s.drawRange;if(c!==null)if(Array.isArray(o))for(let _=0,w=m.length;_<w;_++){const y=m[_],x=o[y.materialIndex],M=Math.max(y.start,v.start),A=Math.min(c.count,Math.min(y.start+y.count,v.start+v.count));for(let T=M,D=A;T<D;T+=3){const I=c.getX(T),U=c.getX(T+1),S=c.getX(T+2);r=pf(this,x,e,i,f,h,p,I,U,S),r&&(r.faceIndex=Math.floor(T/3),r.face.materialIndex=y.materialIndex,n.push(r))}}else{const _=Math.max(0,v.start),w=Math.min(c.count,v.start+v.count);for(let y=_,x=w;y<x;y+=3){const M=c.getX(y),A=c.getX(y+1),T=c.getX(y+2);r=pf(this,o,e,i,f,h,p,M,A,T),r&&(r.faceIndex=Math.floor(y/3),n.push(r))}}else if(u!==void 0)if(Array.isArray(o))for(let _=0,w=m.length;_<w;_++){const y=m[_],x=o[y.materialIndex],M=Math.max(y.start,v.start),A=Math.min(u.count,Math.min(y.start+y.count,v.start+v.count));for(let T=M,D=A;T<D;T+=3){const I=T,U=T+1,S=T+2;r=pf(this,x,e,i,f,h,p,I,U,S),r&&(r.faceIndex=Math.floor(T/3),r.face.materialIndex=y.materialIndex,n.push(r))}}else{const _=Math.max(0,v.start),w=Math.min(u.count,v.start+v.count);for(let y=_,x=w;y<x;y+=3){const M=y,A=y+1,T=y+2;r=pf(this,o,e,i,f,h,p,M,A,T),r&&(r.faceIndex=Math.floor(y/3),n.push(r))}}}};function YH(t,e,n,i,r,s,o,c){let u;if(e.side===Gi?u=i.intersectTriangle(o,s,r,!0,c):u=i.intersectTriangle(r,s,o,e.side===La,c),u===null)return null;hf.copy(c),hf.applyMatrix4(t.matrixWorld);const f=n.ray.origin.distanceTo(hf);return f<n.near||f>n.far?null:{distance:f,point:hf.clone(),object:t}}function pf(t,e,n,i,r,s,o,c,u,f){t.getVertexPosition(c,cf),t.getVertexPosition(u,uf),t.getVertexPosition(f,df);const h=YH(t,e,n,i,cf,uf,df,OE);if(h){const p=new me;Vc.getBarycoord(OE,cf,uf,df,p),r&&(h.uv=Vc.getInterpolatedAttribute(r,c,u,f,p,new bn)),s&&(h.uv1=Vc.getInterpolatedAttribute(s,c,u,f,p,new bn)),o&&(h.normal=Vc.getInterpolatedAttribute(o,c,u,f,p,new me),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const m={a:c,b:u,c:f,normal:new me,materialIndex:0};Vc.getNormal(cf,uf,df,m.normal),h.face=m,h.barycoord=p}return h}class KH extends Li{constructor(e=null,n=1,i=1,r,s,o,c,u,f=pi,h=pi,p,m){super(null,o,c,u,f,h,r,s,p,m),this.isDataTexture=!0,this.image={data:e,width:n,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Lg=new me,ZH=new me,JH=new jt;class io{constructor(e=new me(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,i,r){return this.normal.set(e,n,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,i){const r=Lg.subVectors(i,n).cross(ZH.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(r,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 i=e.delta(Lg),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:n.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const n=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return n<0&&i>0||i<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 i=n||JH.getNormalMatrix(e),r=this.coplanarPoint(Lg).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),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 Qa=new i_,QH=new bn(.5,.5),mf=new me;class dR{constructor(e=new io,n=new io,i=new io,r=new io,s=new io,o=new io){this.planes=[e,n,i,r,s,o]}set(e,n,i,r,s,o){const c=this.planes;return c[0].copy(e),c[1].copy(n),c[2].copy(i),c[3].copy(r),c[4].copy(s),c[5].copy(o),this}copy(e){const n=this.planes;for(let i=0;i<6;i++)n[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,n=Qr,i=!1){const r=this.planes,s=e.elements,o=s[0],c=s[1],u=s[2],f=s[3],h=s[4],p=s[5],m=s[6],v=s[7],_=s[8],w=s[9],y=s[10],x=s[11],M=s[12],A=s[13],T=s[14],D=s[15];if(r[0].setComponents(f-o,v-h,x-_,D-M).normalize(),r[1].setComponents(f+o,v+h,x+_,D+M).normalize(),r[2].setComponents(f+c,v+p,x+w,D+A).normalize(),r[3].setComponents(f-c,v-p,x-w,D-A).normalize(),i)r[4].setComponents(u,m,y,T).normalize(),r[5].setComponents(f-u,v-m,x-y,D-T).normalize();else if(r[4].setComponents(f-u,v-m,x-y,D-T).normalize(),n===Qr)r[5].setComponents(f+u,v+m,x+y,D+T).normalize();else if(n===yh)r[5].setComponents(u,m,y,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(),Qa.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Qa.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Qa)}intersectsSprite(e){Qa.center.set(0,0,0);const n=QH.distanceTo(e.center);return Qa.radius=.7071067811865476+n,Qa.applyMatrix4(e.matrixWorld),this.intersectsSphere(Qa)}intersectsSphere(e){const n=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const n=this.planes;for(let i=0;i<6;i++){const r=n[i];if(mf.x=r.normal.x>0?e.max.x:e.min.x,mf.y=r.normal.y>0?e.max.y:e.min.y,mf.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(mf)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let i=0;i<6;i++)if(n[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class fR extends Li{constructor(e=[],n=Eo,i,r,s,o,c,u,f,h){super(e,n,i,r,s,o,c,u,f,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class _u extends Li{constructor(e,n,i=cs,r,s,o,c=pi,u=pi,f,h=Vs,p=1){if(h!==Vs&&h!==ho)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:n,depth:p};super(m,r,s,o,c,u,h,i,f),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new n_(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 eG extends _u{constructor(e,n=cs,i=Eo,r,s,o=pi,c=pi,u,f=Vs){const h={width:e,height:e,depth:1},p=[h,h,h,h,h,h];super(e,e,n,i,r,s,o,c,u,f),this.image=p,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class hR extends Li{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Nu extends ps{constructor(e=1,n=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};const c=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const u=[],f=[],h=[],p=[];let m=0,v=0;_("z","y","x",-1,-1,i,n,e,o,s,0),_("z","y","x",1,-1,i,n,-e,o,s,1),_("x","z","y",1,1,e,i,n,r,o,2),_("x","z","y",1,-1,e,i,-n,r,o,3),_("x","y","z",1,-1,e,n,i,r,s,4),_("x","y","z",-1,-1,e,n,-i,r,s,5),this.setIndex(u),this.setAttribute("position",new Os(f,3)),this.setAttribute("normal",new Os(h,3)),this.setAttribute("uv",new Os(p,2));function _(w,y,x,M,A,T,D,I,U,S,R){const V=T/U,F=D/S,j=T/2,Z=D/2,H=I/2,q=U+1,J=S+1;let Q=0,W=0;const X=new me;for(let K=0;K<J;K++){const B=K*F-Z;for(let ie=0;ie<q;ie++){const ve=ie*V-j;X[w]=ve*M,X[y]=B*A,X[x]=H,f.push(X.x,X.y,X.z),X[w]=0,X[y]=0,X[x]=I>0?1:-1,h.push(X.x,X.y,X.z),p.push(ie/U),p.push(1-K/S),Q+=1}}for(let K=0;K<S;K++)for(let B=0;B<U;B++){const ie=m+B+q*K,ve=m+B+q*(K+1),Ce=m+(B+1)+q*(K+1),we=m+(B+1)+q*K;u.push(ie,ve,we),u.push(ve,Ce,we),W+=6}c.addGroup(v,W,R),v+=W,m+=Q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Nu(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Vh extends ps{constructor(e=1,n=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:i,heightSegments:r};const s=e/2,o=n/2,c=Math.floor(i),u=Math.floor(r),f=c+1,h=u+1,p=e/c,m=n/u,v=[],_=[],w=[],y=[];for(let x=0;x<h;x++){const M=x*m-o;for(let A=0;A<f;A++){const T=A*p-s;_.push(T,-M,0),w.push(0,0,1),y.push(A/c),y.push(1-x/u)}}for(let x=0;x<u;x++)for(let M=0;M<c;M++){const A=M+f*x,T=M+f*(x+1),D=M+1+f*(x+1),I=M+1+f*x;v.push(A,T,I),v.push(T,D,I)}this.setIndex(v),this.setAttribute("position",new Os(_,3)),this.setAttribute("normal",new Os(w,3)),this.setAttribute("uv",new Os(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vh(e.width,e.height,e.widthSegments,e.heightSegments)}}function Gl(t){const e={};for(const n in t){e[n]={};for(const i in t[n]){const r=t[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(Ht("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null):e[n][i]=r.clone():Array.isArray(r)?e[n][i]=r.slice():e[n][i]=r}}return e}function Ci(t){const e={};for(let n=0;n<t.length;n++){const i=Gl(t[n]);for(const r in i)e[r]=i[r]}return e}function tG(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function pR(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:fn.workingColorSpace}const nG={clone:Gl,merge:Ci};var iG=`void main() {
508
+ `),()=>{c.current?.removeAttribute("data-motion-pop-id"),D.contains(T)&&D.removeChild(T)}},[e]),O.jsx(P4,{isPresent:e,childRef:c,sizeRef:u,pop:s,children:s===!1?t:k.cloneElement(t,{ref:p})})}const L4=({children:t,initial:e,isPresent:n,onExitComplete:i,custom:r,presenceAffectsLayout:s,mode:o,anchorX:c,anchorY:u,root:f})=>{const h=py(D4),p=k.useId();let m=!0,v=k.useMemo(()=>(m=!1,{id:p,initial:e,isPresent:n,custom:r,onExitComplete:_=>{h.set(_,!0);for(const w of h.values())if(!w)return;i&&i()},register:_=>(h.set(_,!1),()=>h.delete(_))}),[n,h,i]);return s&&m&&(v={...v}),k.useMemo(()=>{h.forEach((_,w)=>h.set(w,!1))},[n]),k.useEffect(()=>{!n&&!h.size&&i&&i()},[n]),t=O.jsx(k4,{pop:o==="popLayout",isPresent:n,anchorX:c,anchorY:u,root:f,children:t}),O.jsx(Lh.Provider,{value:v,children:t})};function D4(){return new Map}function tC(t=!0){const e=k.useContext(Lh);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:r}=e,s=k.useId();k.useEffect(()=>{if(t)return r(s)},[t]);const o=k.useCallback(()=>t&&i&&i(s),[s,i,t]);return!n&&i?[!1,o]:[!0]}const Wd=t=>t.key||"";function Ww(t){const e=[];return k.Children.forEach(t,n=>{k.isValidElement(n)&&e.push(n)}),e}const I0=({children:t,custom:e,initial:n=!0,onExitComplete:i,presenceAffectsLayout:r=!0,mode:s="sync",propagate:o=!1,anchorX:c="left",anchorY:u="top",root:f})=>{const[h,p]=tC(o),m=k.useMemo(()=>Ww(t),[t]),v=o&&!h?[]:m.map(Wd),_=k.useRef(!0),w=k.useRef(m),y=py(()=>new Map),x=k.useRef(new Set),[M,A]=k.useState(m),[T,D]=k.useState(m);CT(()=>{_.current=!1,w.current=m;for(let S=0;S<T.length;S++){const R=Wd(T[S]);v.includes(R)?(y.delete(R),x.current.delete(R)):y.get(R)!==!0&&y.set(R,!1)}},[T,v.length,v.join("-")]);const I=[];if(m!==M){let S=[...m];for(let R=0;R<T.length;R++){const V=T[R],F=Wd(V);v.includes(F)||(S.splice(R,0,V),I.push(V))}return s==="wait"&&I.length&&(S=I),D(Ww(S)),A(m),null}const{forceRender:U}=k.useContext(hy);return O.jsx(O.Fragment,{children:T.map(S=>{const R=Wd(S),V=o&&!h?!1:m===T||v.includes(R),F=()=>{if(x.current.has(R))return;if(y.has(R))x.current.add(R),y.set(R,!0);else return;let j=!0;y.forEach(Z=>{Z||(j=!1)}),j&&(U?.(),D(w.current),o&&p?.(),i&&i())};return O.jsx(L4,{isPresent:V,initial:!_.current||n?void 0:!1,custom:e,presenceAffectsLayout:r,mode:s,root:f,onExitComplete:V?void 0:F,anchorX:c,anchorY:u,children:S},R)})})},nC=k.createContext({strict:!1}),$w={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let Xw=!1;function N4(){if(Xw)return;const t={};for(const e in $w)t[e]={isEnabled:n=>$w[e].some(i=>!!n[i])};kA(t),Xw=!0}function iC(){return N4(),yB()}function I4(t){const e=iC();for(const n in t)e[n]={...e[n],...t[n]};kA(e)}const U4=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function ph(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||U4.has(t)}let rC=t=>!ph(t);function F4(t){typeof t=="function"&&(rC=e=>e.startsWith("on")?!ph(e):t(e))}try{F4(require("@emotion/is-prop-valid").default)}catch{}function O4(t,e,n){const i={};for(const r in t)r==="values"&&typeof t.values=="object"||hi(t[r])||(rC(r)||n===!0&&ph(r)||!e&&!ph(r)||t.draggable&&r.startsWith("onDrag"))&&(i[r]=t[r]);return i}const Uh=k.createContext({});function B4(t,e){if(Ih(t)){const{initial:n,animate:i}=t;return{initial:n===!1||pu(n)?n:void 0,animate:pu(i)?i:void 0}}return t.inherit!==!1?e:{}}function z4(t){const{initial:e,animate:n}=B4(t,k.useContext(Uh));return k.useMemo(()=>({initial:e,animate:n}),[qw(e),qw(n)])}function qw(t){return Array.isArray(t)?t.join(" "):t}const Vy=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function sC(t,e,n){for(const i in e)!hi(e[i])&&!OA(i,n)&&(t[i]=e[i])}function V4({transformTemplate:t},e){return k.useMemo(()=>{const n=Vy();return Oy(n,e,t),Object.assign({},n.vars,n.style)},[e])}function H4(t,e){const n=t.style||{},i={};return sC(i,n,t),Object.assign(i,V4(t,e)),i}function G4(t,e){const n={},i=H4(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=i,n}const aC=()=>({...Vy(),attrs:{}});function j4(t,e,n,i){const r=k.useMemo(()=>{const s=aC();return BA(s,e,VA(i),t.transformTemplate,t.style),{...s.attrs,style:{...s.style}}},[e]);if(t.style){const s={};sC(s,t.style,t),r.style={...s,...r.style}}return r}const W4=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Hy(t){return typeof t!="string"||t.includes("-")?!1:!!(W4.indexOf(t)>-1||/[A-Z]/u.test(t))}function $4(t,e,n,{latestValues:i},r,s=!1,o){const u=(o??Hy(t)?j4:G4)(e,i,r,t),f=O4(e,typeof t=="string",s),h=t!==k.Fragment?{...f,...u,ref:n}:{},{children:p}=e,m=k.useMemo(()=>hi(p)?p.get():p,[p]);return k.createElement(t,{...h,children:m})}function X4({scrapeMotionValuesFromProps:t,createRenderState:e},n,i,r){return{latestValues:q4(n,i,r,t),renderState:e()}}function q4(t,e,n,i){const r={},s=i(t,{});for(const m in s)r[m]=Ff(s[m]);let{initial:o,animate:c}=t;const u=Ih(t),f=RA(t);e&&f&&!u&&t.inherit!==!1&&(o===void 0&&(o=e.initial),c===void 0&&(c=e.animate));let h=n?n.initial===!1:!1;h=h||o===!1;const p=h?c:o;if(p&&typeof p!="boolean"&&!Nh(p)){const m=Array.isArray(p)?p:[p];for(let v=0;v<m.length;v++){const _=Ry(t,m[v]);if(_){const{transitionEnd:w,transition:y,...x}=_;for(const M in x){let A=x[M];if(Array.isArray(A)){const T=h?A.length-1:0;A=A[T]}A!==null&&(r[M]=A)}for(const M in w)r[M]=w[M]}}}return r}const oC=t=>(e,n)=>{const i=k.useContext(Uh),r=k.useContext(Lh),s=()=>X4(t,e,i,r);return n?s():py(s)},Y4=oC({scrapeMotionValuesFromProps:By,createRenderState:Vy}),K4=oC({scrapeMotionValuesFromProps:HA,createRenderState:aC}),Z4=Symbol.for("motionComponentSymbol");function J4(t,e,n){const i=k.useRef(n);k.useInsertionEffect(()=>{i.current=n});const r=k.useRef(null);return k.useCallback(s=>{s&&t.onMount?.(s);const o=i.current;if(typeof o=="function")if(s){const c=o(s);typeof c=="function"&&(r.current=c)}else r.current?(r.current(),r.current=null):o(s);else o&&(o.current=s);e&&(s?e.mount(s):e.unmount())},[e])}const lC=k.createContext({});function wl(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Q4(t,e,n,i,r,s){const{visualElement:o}=k.useContext(Uh),c=k.useContext(nC),u=k.useContext(Lh),f=k.useContext(zy),h=f.reducedMotion,p=f.skipAnimations,m=k.useRef(null),v=k.useRef(!1);i=i||c.renderer,!m.current&&i&&(m.current=i(t,{visualState:e,parent:o,props:n,presenceContext:u,blockInitialAnimation:u?u.initial===!1:!1,reducedMotionConfig:h,skipAnimations:p,isSVG:s}),v.current&&m.current&&(m.current.manuallyAnimateOnMount=!0));const _=m.current,w=k.useContext(lC);_&&!_.projection&&r&&(_.type==="html"||_.type==="svg")&&e5(m.current,n,r,w);const y=k.useRef(!1);k.useInsertionEffect(()=>{_&&y.current&&_.update(n,u)});const x=n[gA],M=k.useRef(!!x&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(x)&&window.MotionHasOptimisedAnimation?.(x));return CT(()=>{v.current=!0,_&&(y.current=!0,window.MotionIsMounted=!0,_.updateFeatures(),_.scheduleRenderMicrotask(),M.current&&_.animationState&&_.animationState.animateChanges())}),k.useEffect(()=>{_&&(!M.current&&_.animationState&&_.animationState.animateChanges(),M.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(x)}),M.current=!1),_.enteringChildren=void 0)}),_}function e5(t,e,n,i){const{layoutId:r,layout:s,drag:o,dragConstraints:c,layoutScroll:u,layoutRoot:f,layoutAnchor:h,layoutCrossfade:p}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:cC(t.parent)),t.projection.setOptions({layoutId:r,layout:s,alwaysMeasureLayout:!!o||c&&wl(c),visualElement:t,animationType:typeof s=="string"?s:"both",initialPromotionConfig:i,crossfade:p,layoutScroll:u,layoutRoot:f,layoutAnchor:h})}function cC(t){if(t)return t.options.allowProjection!==!1?t.projection:cC(t.parent)}function Km(t,{forwardMotionProps:e=!1,type:n}={},i,r){i&&I4(i);const s=n?n==="svg":Hy(t),o=s?K4:Y4;function c(f,h){let p;const m={...k.useContext(zy),...f,layoutId:t5(f)},{isStatic:v}=m,_=z4(f),w=o(f,v);if(!v&&typeof window<"u"){n5();const y=i5(m);p=y.MeasureLayout,_.visualElement=Q4(t,w,m,r,y.ProjectionNode,s)}return O.jsxs(Uh.Provider,{value:_,children:[p&&_.visualElement?O.jsx(p,{visualElement:_.visualElement,...m}):null,$4(t,f,J4(w,_.visualElement,h),w,v,e,s)]})}c.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const u=k.forwardRef(c);return u[Z4]=t,u}function t5({layoutId:t}){const e=k.useContext(hy).id;return e&&t!==void 0?e+"-"+t:t}function n5(t,e){k.useContext(nC).strict}function i5(t){const e=iC(),{drag:n,layout:i}=e;if(!n&&!i)return{};const r={...n,...i};return{MeasureLayout:n?.isEnabled(t)||i?.isEnabled(t)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function r5(t,e){if(typeof Proxy>"u")return Km;const n=new Map,i=(s,o)=>Km(s,o,t,e),r=(s,o)=>i(s,o);return new Proxy(r,{get:(s,o)=>o==="create"?i:(n.has(o)||n.set(o,Km(o,void 0,t,e)),n.get(o))})}const s5=(t,e)=>e.isSVG??Hy(t)?new IB(e):new RB(e,{allowProjection:t!==k.Fragment});class a5 extends Da{constructor(e){super(e),e.animationState||(e.animationState=zB(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Nh(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let o5=0;class l5 extends Da{constructor(){super(...arguments),this.id=o5++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===i)return;if(e&&i===!1){if(this.isExitComplete){const{initial:s,custom:o}=this.node.getProps();if(typeof s=="string"){const c=go(this.node,s,o);if(c){const{transition:u,transitionEnd:f,...h}=c;for(const p in h)this.node.getValue(p)?.jump(h[p])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!e);n&&!e&&r.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const c5={animation:{Feature:a5},exit:{Feature:l5}};function Cu(t){return{point:{x:t.pageX,y:t.pageY}}}const u5=t=>e=>Dy(e)&&t(e,Cu(e));function au(t,e,n,i){return mu(t,e,u5(n),i)}const uC=({current:t})=>t?t.ownerDocument.defaultView:null,Yw=(t,e)=>Math.abs(t-e);function d5(t,e){const n=Yw(t.x,e.x),i=Yw(t.y,e.y);return Math.sqrt(n**2+i**2)}const Kw=new Set(["auto","scroll"]);class dC{constructor(e,n,{transformPagePoint:i,contextWindow:r=window,dragSnapToOrigin:s=!1,distanceThreshold:o=3,element:c}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=v=>{this.handleScroll(v.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=$d(this.lastRawMoveEventInfo,this.transformPagePoint));const v=Zm(this.lastMoveEventInfo,this.history),_=this.startEvent!==null,w=d5(v.offset,{x:0,y:0})>=this.distanceThreshold;if(!_&&!w)return;const{point:y}=v,{timestamp:x}=fi;this.history.push({...y,timestamp:x});const{onStart:M,onMove:A}=this.handlers;_||(M&&M(this.lastMoveEvent,v),this.startEvent=this.lastMoveEvent),A&&A(this.lastMoveEvent,v)},this.handlePointerMove=(v,_)=>{this.lastMoveEvent=v,this.lastRawMoveEventInfo=_,this.lastMoveEventInfo=$d(_,this.transformPagePoint),Tn.update(this.updatePoint,!0)},this.handlePointerUp=(v,_)=>{this.end();const{onEnd:w,onSessionEnd:y,resumeAnimation:x}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&x&&x(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const M=Zm(v.type==="pointercancel"?this.lastMoveEventInfo:$d(_,this.transformPagePoint),this.history);this.startEvent&&w&&w(v,M),y&&y(v,M)},!Dy(e))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=i,this.distanceThreshold=o,this.contextWindow=r||window;const u=Cu(e),f=$d(u,this.transformPagePoint),{point:h}=f,{timestamp:p}=fi;this.history=[{...h,timestamp:p}];const{onSessionStart:m}=n;m&&m(e,Zm(f,this.history)),this.removeListeners=Mu(au(this.contextWindow,"pointermove",this.handlePointerMove),au(this.contextWindow,"pointerup",this.handlePointerUp),au(this.contextWindow,"pointercancel",this.handlePointerUp)),c&&this.startScrollTracking(c)}startScrollTracking(e){let n=e.parentElement;for(;n;){const i=getComputedStyle(n);(Kw.has(i.overflowX)||Kw.has(i.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const n=this.scrollPositions.get(e);if(!n)return;const i=e===window,r=i?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},s={x:r.x-n.x,y:r.y-n.y};s.x===0&&s.y===0||(i?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=s.x,this.lastMoveEventInfo.point.y+=s.y):this.history.length>0&&(this.history[0].x-=s.x,this.history[0].y-=s.y),this.scrollPositions.set(e,r),Tn.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ka(this.updatePoint)}}function $d(t,e){return e?{point:e(t.point)}:t}function Zw(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Zm({point:t},e){return{point:t,delta:Zw(t,fC(e)),offset:Zw(t,f5(e)),velocity:h5(e,.1)}}function f5(t){return t[0]}function fC(t){return t[t.length-1]}function h5(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,i=null;const r=fC(t);for(;n>=0&&(i=t[n],!(r.timestamp-i.timestamp>Qi(e)));)n--;if(!i)return{x:0,y:0};i===t[0]&&t.length>2&&r.timestamp-i.timestamp>Qi(e)*2&&(i=t[1]);const s=hr(r.timestamp-i.timestamp);if(s===0)return{x:0,y:0};const o={x:(r.x-i.x)/s,y:(r.y-i.y)/s};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function p5(t,{min:e,max:n},i){return e!==void 0&&t<e?t=i?Pn(e,t,i.min):Math.max(t,e):n!==void 0&&t>n&&(t=i?Pn(n,t,i.max):Math.min(t,n)),t}function Jw(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function m5(t,{top:e,left:n,bottom:i,right:r}){return{x:Jw(t.x,n,r),y:Jw(t.y,e,i)}}function Qw(t,e){let n=e.min-t.min,i=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,i]=[i,n]),{min:n,max:i}}function g5(t,e){return{x:Qw(t.x,e.x),y:Qw(t.y,e.y)}}function v5(t,e){let n=.5;const i=Pi(t),r=Pi(e);return r>i?n=fu(e.min,e.max-i,t.min):i>r&&(n=fu(t.min,t.max-r,e.min)),ls(0,1,n)}function y5(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const U0=.35;function _5(t=U0){return t===!1?t=0:t===!0&&(t=U0),{x:eE(t,"left","right"),y:eE(t,"top","bottom")}}function eE(t,e,n){return{min:tE(t,e),max:tE(t,n)}}function tE(t,e){return typeof t=="number"?t:t[e]||0}const x5=new WeakMap;class b5{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ei(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:i}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const s=p=>{n&&this.snapToCursor(Cu(p).point),this.stopAnimation()},o=(p,m)=>{const{drag:v,dragPropagation:_,onDragStart:w}=this.getProps();if(v&&!_&&(this.openDragLock&&this.openDragLock(),this.openDragLock=YO(v),!this.openDragLock))return;this.latestPointerEvent=p,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),qr(x=>{let M=this.getAxisMotionValue(x).get()||0;if(ts.test(M)){const{projection:A}=this.visualElement;if(A&&A.layout){const T=A.layout.layoutBox[x];T&&(M=Pi(T)*(parseFloat(M)/100))}}this.originPoint[x]=M}),w&&Tn.update(()=>w(p,m),!1,!0),A0(this.visualElement,"transform");const{animationState:y}=this.visualElement;y&&y.setActive("whileDrag",!0)},c=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m;const{dragPropagation:v,dragDirectionLock:_,onDirectionLock:w,onDrag:y}=this.getProps();if(!v&&!this.openDragLock)return;const{offset:x}=m;if(_&&this.currentDirection===null){this.currentDirection=w5(x),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",m.point,x),this.updateAxis("y",m.point,x),this.visualElement.render(),y&&Tn.update(()=>y(p,m),!1,!0)},u=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m,this.stop(p,m),this.latestPointerEvent=null,this.latestPanInfo=null},f=()=>{const{dragSnapToOrigin:p}=this.getProps();(p||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:h}=this.getProps();this.panSession=new dC(e,{onSessionStart:s,onStart:o,onMove:c,onSessionEnd:u,resumeAnimation:f},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,distanceThreshold:i,contextWindow:uC(this.visualElement),element:this.visualElement.current})}stop(e,n){const i=e||this.latestPointerEvent,r=n||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!r||!i)return;const{velocity:o}=r;this.startAnimation(o);const{onDragEnd:c}=this.getProps();c&&Tn.postRender(()=>c(i,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,n,i){const{drag:r}=this.getProps();if(!i||!Xd(e,r,this.currentDirection))return;const s=this.getAxisMotionValue(e);let o=this.originPoint[e]+i[e];this.constraints&&this.constraints[e]&&(o=p5(o,this.constraints[e],this.elastic[e])),s.set(o)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&wl(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&i?this.constraints=m5(i.layoutBox,e):this.constraints=!1,this.elastic=_5(n),r!==this.constraints&&!wl(e)&&i&&this.constraints&&!this.hasMutatedConstraints&&qr(s=>{this.constraints!==!1&&this.getAxisMotionValue(s)&&(this.constraints[s]=y5(i.layoutBox[s],this.constraints[s]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!wl(e))return!1;const i=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const s=wB(i,r.root,this.visualElement.getTransformPagePoint());let o=g5(r.layout.layoutBox,s);if(n){const c=n(xB(o));this.hasMutatedConstraints=!!c,c&&(o=DA(c))}return o}startAnimation(e){const{drag:n,dragMomentum:i,dragElastic:r,dragTransition:s,dragSnapToOrigin:o,onDragTransitionEnd:c}=this.getProps(),u=this.constraints||{},f=qr(h=>{if(!Xd(h,n,this.currentDirection))return;let p=u&&u[h]||{};(o===!0||o===h)&&(p={min:0,max:0});const m=r?200:1e6,v=r?40:1e7,_={type:"inertia",velocity:i?e[h]:0,bounceStiffness:m,bounceDamping:v,timeConstant:750,restDelta:1,restSpeed:10,...s,...p};return this.startAxisValueAnimation(h,_)});return Promise.all(f).then(c)}startAxisValueAnimation(e,n){const i=this.getAxisMotionValue(e);return A0(this.visualElement,e),i.start(Cy(e,i,0,n,this.visualElement,!1))}stopAnimation(){qr(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,i=this.visualElement.getProps(),r=i[n];return r||this.visualElement.getValue(e,(i.initial?i.initial[e]:void 0)||0)}snapToCursor(e){qr(n=>{const{drag:i}=this.getProps();if(!Xd(n,i,this.currentDirection))return;const{projection:r}=this.visualElement,s=this.getAxisMotionValue(n);if(r&&r.layout){const{min:o,max:c}=r.layout.layoutBox[n],u=s.get()||0;s.set(e[n]-Pn(o,c,.5)+u)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:i}=this.visualElement;if(!wl(n)||!i||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};qr(o=>{const c=this.getAxisMotionValue(o);if(c&&this.constraints!==!1){const u=c.get();r[o]=v5({min:u,max:u},this.constraints[o])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.constraints=!1,this.resolveConstraints(),qr(o=>{if(!Xd(o,e,null))return;const c=this.getAxisMotionValue(o),{min:u,max:f}=this.constraints[o];c.set(Pn(u,f,r[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;x5.set(this.visualElement,this);const e=this.visualElement.current,n=au(e,"pointerdown",f=>{const{drag:h,dragListener:p=!0}=this.getProps(),m=f.target,v=m!==e&&tB(m);h&&p&&!v&&this.start(f)});let i;const r=()=>{const{dragConstraints:f}=this.getProps();wl(f)&&f.current&&(this.constraints=this.resolveRefConstraints(),i||(i=S5(e,f.current,()=>this.scalePositionWithinConstraints())))},{projection:s}=this.visualElement,o=s.addEventListener("measure",r);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),Tn.read(r);const c=mu(window,"resize",()=>this.scalePositionWithinConstraints()),u=s.addEventListener("didUpdate",(({delta:f,hasLayoutChanged:h})=>{this.isDragging&&h&&(qr(p=>{const m=this.getAxisMotionValue(p);m&&(this.originPoint[p]+=f[p].translate,m.set(m.get()+f[p].translate))}),this.visualElement.render())}));return()=>{c(),n(),o(),u&&u(),i&&i()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:i=!1,dragPropagation:r=!1,dragConstraints:s=!1,dragElastic:o=U0,dragMomentum:c=!0}=e;return{...e,drag:n,dragDirectionLock:i,dragPropagation:r,dragConstraints:s,dragElastic:o,dragMomentum:c}}}function nE(t){let e=!0;return()=>{if(e){e=!1;return}t()}}function S5(t,e,n){const i=cw(t,nE(n)),r=cw(e,nE(n));return()=>{i(),r()}}function Xd(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function w5(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class E5 extends Da{constructor(e){super(e),this.removeGroupControls=pr,this.removeListeners=pr,this.controls=new b5(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||pr}update(){const{dragControls:e}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const Jm=t=>(e,n)=>{t&&Tn.update(()=>t(e,n),!1,!0)};class M5 extends Da{constructor(){super(...arguments),this.removePointerDownListener=pr}onPointerDown(e){this.session=new dC(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:uC(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:i,onPanEnd:r}=this.node.getProps();return{onSessionStart:Jm(e),onStart:Jm(n),onMove:Jm(i),onEnd:(s,o)=>{delete this.session,r&&Tn.postRender(()=>r(s,o))}}}mount(){this.removePointerDownListener=au(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Qm=!1;class T5 extends k.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:i,layoutId:r}=this.props,{projection:s}=e;s&&(n.group&&n.group.add(s),i&&i.register&&r&&i.register(s),Qm&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Of.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:i,drag:r,isPresent:s}=this.props,{projection:o}=i;return o&&(o.isPresent=s,e.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),Qm=!0,r||e.layoutDependency!==n||n===void 0||e.isPresent!==s?o.willUpdate():this.safeToRemove(),e.isPresent!==s&&(s?o.promote():o.relegate()||Tn.postRender(()=>{const c=o.getStack();(!c||!c.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:e,layoutAnchor:n}=this.props,{projection:i}=e;i&&(i.options.layoutAnchor=n,i.root.didUpdate(),Ly.postRender(()=>{!i.currentAnimation&&i.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:r}=e;Qm=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),i&&i.deregister&&i.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function hC(t){const[e,n]=tC(),i=k.useContext(hy);return O.jsx(T5,{...t,layoutGroup:i,switchLayoutGroup:k.useContext(lC),isPresent:e,safeToRemove:n})}const A5={pan:{Feature:M5},drag:{Feature:E5,ProjectionNode:eC,MeasureLayout:hC}};function iE(t,e,n){const{props:i}=t;t.animationState&&i.whileHover&&t.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,s=i[r];s&&Tn.postRender(()=>s(e,Cu(e)))}class C5 extends Da{mount(){const{current:e}=this.node;e&&(this.unmount=ZO(e,(n,i)=>(iE(this.node,i,"Start"),r=>iE(this.node,r,"End"))))}unmount(){}}class R5 extends Da{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Mu(mu(this.node.current,"focus",()=>this.onFocus()),mu(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function rE(t,e,n){const{props:i}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&i.whileTap&&t.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),s=i[r];s&&Tn.postRender(()=>s(e,Cu(e)))}class P5 extends Da{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:n,propagate:i}=this.node.props;this.unmount=iB(e,(r,s)=>(rE(this.node,s,"Start"),(o,{success:c})=>rE(this.node,o,c?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:i?.tap===!1})}unmount(){}}const F0=new WeakMap,eg=new WeakMap,k5=t=>{const e=F0.get(t.target);e&&e(t)},L5=t=>{t.forEach(k5)};function D5({root:t,...e}){const n=t||document;eg.has(n)||eg.set(n,{});const i=eg.get(n),r=JSON.stringify(e);return i[r]||(i[r]=new IntersectionObserver(L5,{root:t,...e})),i[r]}function N5(t,e,n){const i=D5(e);return F0.set(t,n),i.observe(t),()=>{F0.delete(t),i.unobserve(t)}}const I5={some:0,all:1};class U5 extends Da{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:e={}}=this.node.getProps(),{root:n,margin:i,amount:r="some",once:s}=e,o={root:n?n.current:void 0,rootMargin:i,threshold:typeof r=="number"?r:I5[r]},c=u=>{const{isIntersecting:f}=u;if(this.isInView===f||(this.isInView=f,s&&!f&&this.hasEnteredView))return;f&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",f);const{onViewportEnter:h,onViewportLeave:p}=this.node.getProps(),m=f?h:p;m&&m(u)};this.stopObserver=N5(this.node.current,o,c)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(F5(e,n))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}function F5({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const O5={inView:{Feature:U5},tap:{Feature:P5},focus:{Feature:R5},hover:{Feature:C5}},B5={layout:{ProjectionNode:eC,MeasureLayout:hC}},z5={...c5,...O5,...A5,...B5},Is=r5(z5,s5);function V5(){!Fy.current&&PA();const[t]=k.useState(uh.current);return t}const pC=(...t)=>t.filter((e,n,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===n).join(" ").trim();const H5=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const G5=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,i)=>i?i.toUpperCase():n.toLowerCase());const sE=t=>{const e=G5(t);return e.charAt(0).toUpperCase()+e.slice(1)};var tg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const j5=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},W5=k.createContext({}),$5=()=>k.useContext(W5),X5=k.forwardRef(({color:t,size:e,strokeWidth:n,absoluteStrokeWidth:i,className:r="",children:s,iconNode:o,...c},u)=>{const{size:f=24,strokeWidth:h=2,absoluteStrokeWidth:p=!1,color:m="currentColor",className:v=""}=$5()??{},_=i??p?Number(n??h)*24/Number(e??f):n??h;return k.createElement("svg",{ref:u,...tg,width:e??f??tg.width,height:e??f??tg.height,stroke:t??m,strokeWidth:_,className:pC("lucide",v,r),...!s&&!j5(c)&&{"aria-hidden":"true"},...c},[...o.map(([w,y])=>k.createElement(w,y)),...Array.isArray(s)?s:[s]])});const Fh=(t,e)=>{const n=k.forwardRef(({className:i,...r},s)=>k.createElement(X5,{ref:s,iconNode:e,className:pC(`lucide-${H5(sE(t))}`,`lucide-${t}`,i),...r}));return n.displayName=sE(t),n};const q5=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Y5=Fh("log-out",q5);const K5=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Z5=Fh("mail",K5);const J5=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Q5=Fh("pencil",J5);const ez=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],tz=Fh("x",ez);function mC(t){var e,n,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(e=0;e<r;e++)t[e]&&(n=mC(t[e]))&&(i&&(i+=" "),i+=n)}else for(n in t)t[n]&&(i&&(i+=" "),i+=n);return i}function nz(){for(var t,e,n=0,i="",r=arguments.length;n<r;n++)(t=arguments[n])&&(e=mC(t))&&(i&&(i+=" "),i+=e);return i}const iz=(t,e)=>{const n=new Array(t.length+e.length);for(let i=0;i<t.length;i++)n[i]=t[i];for(let i=0;i<e.length;i++)n[t.length+i]=e[i];return n},rz=(t,e)=>({classGroupId:t,validator:e}),gC=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),mh="-",aE=[],sz="arbitrary..",az=t=>{const e=lz(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:i}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return oz(o);const c=o.split(mh),u=c[0]===""&&c.length>1?1:0;return vC(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=i[o],f=n[o];return u?f?iz(f,u):u:f||aE}return n[o]||aE}}},vC=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const r=t[e],s=n.nextPart.get(r);if(s){const f=vC(t,e+1,s);if(f)return f}const o=n.validators;if(o===null)return;const c=e===0?t.join(mh):t.slice(e).join(mh),u=o.length;for(let f=0;f<u;f++){const h=o[f];if(h.validator(c))return h.classGroupId}},oz=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),i=e.slice(0,n);return i?sz+i:void 0})(),lz=t=>{const{theme:e,classGroups:n}=t;return cz(n,e)},cz=(t,e)=>{const n=gC();for(const i in t){const r=t[i];Gy(r,n,i,e)}return n},Gy=(t,e,n,i)=>{const r=t.length;for(let s=0;s<r;s++){const o=t[s];uz(o,e,n,i)}},uz=(t,e,n,i)=>{if(typeof t=="string"){dz(t,e,n);return}if(typeof t=="function"){fz(t,e,n,i);return}hz(t,e,n,i)},dz=(t,e,n)=>{const i=t===""?e:yC(e,t);i.classGroupId=n},fz=(t,e,n,i)=>{if(pz(t)){Gy(t(i),e,n,i);return}e.validators===null&&(e.validators=[]),e.validators.push(rz(n,t))},hz=(t,e,n,i)=>{const r=Object.entries(t),s=r.length;for(let o=0;o<s;o++){const[c,u]=r[o];Gy(u,yC(e,c),n,i)}},yC=(t,e)=>{let n=t;const i=e.split(mh),r=i.length;for(let s=0;s<r;s++){const o=i[s];let c=n.nextPart.get(o);c||(c=gC(),n.nextPart.set(o,c)),n=c}return n},pz=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,mz=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),i=Object.create(null);const r=(s,o)=>{n[s]=o,e++,e>t&&(e=0,i=n,n=Object.create(null))};return{get(s){let o=n[s];if(o!==void 0)return o;if((o=i[s])!==void 0)return r(s,o),o},set(s,o){s in n?n[s]=o:r(s,o)}}},O0="!",oE=":",gz=[],lE=(t,e,n,i,r)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:i,isExternal:r}),vz=t=>{const{prefix:e,experimentalParseClassName:n}=t;let i=r=>{const s=[];let o=0,c=0,u=0,f;const h=r.length;for(let w=0;w<h;w++){const y=r[w];if(o===0&&c===0){if(y===oE){s.push(r.slice(u,w)),u=w+1;continue}if(y==="/"){f=w;continue}}y==="["?o++:y==="]"?o--:y==="("?c++:y===")"&&c--}const p=s.length===0?r:r.slice(u);let m=p,v=!1;p.endsWith(O0)?(m=p.slice(0,-1),v=!0):p.startsWith(O0)&&(m=p.slice(1),v=!0);const _=f&&f>u?f-u:void 0;return lE(s,v,m,_)};if(e){const r=e+oE,s=i;i=o=>o.startsWith(r)?s(o.slice(r.length)):lE(gz,!1,o,void 0,!0)}if(n){const r=i;i=s=>n({className:s,parseClassName:r})}return i},yz=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,i)=>{e.set(n,1e6+i)}),n=>{const i=[];let r=[];for(let s=0;s<n.length;s++){const o=n[s],c=o[0]==="[",u=e.has(o);c||u?(r.length>0&&(r.sort(),i.push(...r),r=[]),i.push(o)):r.push(o)}return r.length>0&&(r.sort(),i.push(...r)),i}},_z=t=>({cache:mz(t.cacheSize),parseClassName:vz(t),sortModifiers:yz(t),...az(t)}),xz=/\s+/,bz=(t,e)=>{const{parseClassName:n,getClassGroupId:i,getConflictingClassGroupIds:r,sortModifiers:s}=e,o=[],c=t.trim().split(xz);let u="";for(let f=c.length-1;f>=0;f-=1){const h=c[f],{isExternal:p,modifiers:m,hasImportantModifier:v,baseClassName:_,maybePostfixModifierPosition:w}=n(h);if(p){u=h+(u.length>0?" "+u:u);continue}let y=!!w,x=i(y?_.substring(0,w):_);if(!x){if(!y){u=h+(u.length>0?" "+u:u);continue}if(x=i(_),!x){u=h+(u.length>0?" "+u:u);continue}y=!1}const M=m.length===0?"":m.length===1?m[0]:s(m).join(":"),A=v?M+O0:M,T=A+x;if(o.indexOf(T)>-1)continue;o.push(T);const D=r(x,y);for(let I=0;I<D.length;++I){const U=D[I];o.push(A+U)}u=h+(u.length>0?" "+u:u)}return u},Sz=(...t)=>{let e=0,n,i,r="";for(;e<t.length;)(n=t[e++])&&(i=_C(n))&&(r&&(r+=" "),r+=i);return r},_C=t=>{if(typeof t=="string")return t;let e,n="";for(let i=0;i<t.length;i++)t[i]&&(e=_C(t[i]))&&(n&&(n+=" "),n+=e);return n},wz=(t,...e)=>{let n,i,r,s;const o=u=>{const f=e.reduce((h,p)=>p(h),t());return n=_z(f),i=n.cache.get,r=n.cache.set,s=c,c(u)},c=u=>{const f=i(u);if(f)return f;const h=bz(u,n);return r(u,h),h};return s=o,(...u)=>s(Sz(...u))},Ez=[],Qn=t=>{const e=n=>n[t]||Ez;return e.isThemeGetter=!0,e},xC=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,bC=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Mz=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Tz=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Az=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Cz=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Rz=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Pz=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,fa=t=>Mz.test(t),Xt=t=>!!t&&!Number.isNaN(Number(t)),ha=t=>!!t&&Number.isInteger(Number(t)),ng=t=>t.endsWith("%")&&Xt(t.slice(0,-1)),Es=t=>Tz.test(t),SC=()=>!0,kz=t=>Az.test(t)&&!Cz.test(t),jy=()=>!1,Lz=t=>Rz.test(t),Dz=t=>Pz.test(t),Nz=t=>!dt(t)&&!mt(t),Iz=t=>Na(t,MC,jy),dt=t=>xC.test(t),Ya=t=>Na(t,TC,kz),cE=t=>Na(t,Gz,Xt),Uz=t=>Na(t,CC,SC),Fz=t=>Na(t,AC,jy),uE=t=>Na(t,wC,jy),Oz=t=>Na(t,EC,Dz),qd=t=>Na(t,RC,Lz),mt=t=>bC.test(t),Oc=t=>Po(t,TC),Bz=t=>Po(t,AC),dE=t=>Po(t,wC),zz=t=>Po(t,MC),Vz=t=>Po(t,EC),Yd=t=>Po(t,RC,!0),Hz=t=>Po(t,CC,!0),Na=(t,e,n)=>{const i=xC.exec(t);return i?i[1]?e(i[1]):n(i[2]):!1},Po=(t,e,n=!1)=>{const i=bC.exec(t);return i?i[1]?e(i[1]):n:!1},wC=t=>t==="position"||t==="percentage",EC=t=>t==="image"||t==="url",MC=t=>t==="length"||t==="size"||t==="bg-size",TC=t=>t==="length",Gz=t=>t==="number",AC=t=>t==="family-name",CC=t=>t==="number"||t==="weight",RC=t=>t==="shadow",jz=()=>{const t=Qn("color"),e=Qn("font"),n=Qn("text"),i=Qn("font-weight"),r=Qn("tracking"),s=Qn("leading"),o=Qn("breakpoint"),c=Qn("container"),u=Qn("spacing"),f=Qn("radius"),h=Qn("shadow"),p=Qn("inset-shadow"),m=Qn("text-shadow"),v=Qn("drop-shadow"),_=Qn("blur"),w=Qn("perspective"),y=Qn("aspect"),x=Qn("ease"),M=Qn("animate"),A=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],D=()=>[...T(),mt,dt],I=()=>["auto","hidden","clip","visible","scroll"],U=()=>["auto","contain","none"],S=()=>[mt,dt,u],R=()=>[fa,"full","auto",...S()],V=()=>[ha,"none","subgrid",mt,dt],F=()=>["auto",{span:["full",ha,mt,dt]},ha,mt,dt],j=()=>[ha,"auto",mt,dt],Z=()=>["auto","min","max","fr",mt,dt],H=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],q=()=>["start","end","center","stretch","center-safe","end-safe"],J=()=>["auto",...S()],Q=()=>[fa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...S()],W=()=>[fa,"screen","full","dvw","lvw","svw","min","max","fit",...S()],X=()=>[fa,"screen","full","lh","dvh","lvh","svh","min","max","fit",...S()],K=()=>[t,mt,dt],B=()=>[...T(),dE,uE,{position:[mt,dt]}],ie=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ve=()=>["auto","cover","contain",zz,Iz,{size:[mt,dt]}],Ce=()=>[ng,Oc,Ya],we=()=>["","none","full",f,mt,dt],ne=()=>["",Xt,Oc,Ya],_e=()=>["solid","dashed","dotted","double"],Se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ie=()=>[Xt,ng,dE,uE],et=()=>["","none",_,mt,dt],xt=()=>["none",Xt,mt,dt],pn=()=>["none",Xt,mt,dt],ht=()=>[Xt,mt,dt],Ut=()=>[fa,"full",...S()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Es],breakpoint:[Es],color:[SC],container:[Es],"drop-shadow":[Es],ease:["in","out","in-out"],font:[Nz],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Es],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Es],shadow:[Es],spacing:["px",Xt],text:[Es],"text-shadow":[Es],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",fa,dt,mt,y]}],container:["container"],columns:[{columns:[Xt,dt,mt,c]}],"break-after":[{"break-after":A()}],"break-before":[{"break-before":A()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:D()}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:U()}],"overscroll-x":[{"overscroll-x":U()}],"overscroll-y":[{"overscroll-y":U()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{"inset-s":R(),start:R()}],end:[{"inset-e":R(),end:R()}],"inset-bs":[{"inset-bs":R()}],"inset-be":[{"inset-be":R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[ha,"auto",mt,dt]}],basis:[{basis:[fa,"full","auto",c,...S()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Xt,fa,"auto","initial","none",dt]}],grow:[{grow:["",Xt,mt,dt]}],shrink:[{shrink:["",Xt,mt,dt]}],order:[{order:[ha,"first","last","none",mt,dt]}],"grid-cols":[{"grid-cols":V()}],"col-start-end":[{col:F()}],"col-start":[{"col-start":j()}],"col-end":[{"col-end":j()}],"grid-rows":[{"grid-rows":V()}],"row-start-end":[{row:F()}],"row-start":[{"row-start":j()}],"row-end":[{"row-end":j()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Z()}],"auto-rows":[{"auto-rows":Z()}],gap:[{gap:S()}],"gap-x":[{"gap-x":S()}],"gap-y":[{"gap-y":S()}],"justify-content":[{justify:[...H(),"normal"]}],"justify-items":[{"justify-items":[...q(),"normal"]}],"justify-self":[{"justify-self":["auto",...q()]}],"align-content":[{content:["normal",...H()]}],"align-items":[{items:[...q(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...q(),{baseline:["","last"]}]}],"place-content":[{"place-content":H()}],"place-items":[{"place-items":[...q(),"baseline"]}],"place-self":[{"place-self":["auto",...q()]}],p:[{p:S()}],px:[{px:S()}],py:[{py:S()}],ps:[{ps:S()}],pe:[{pe:S()}],pbs:[{pbs:S()}],pbe:[{pbe:S()}],pt:[{pt:S()}],pr:[{pr:S()}],pb:[{pb:S()}],pl:[{pl:S()}],m:[{m:J()}],mx:[{mx:J()}],my:[{my:J()}],ms:[{ms:J()}],me:[{me:J()}],mbs:[{mbs:J()}],mbe:[{mbe:J()}],mt:[{mt:J()}],mr:[{mr:J()}],mb:[{mb:J()}],ml:[{ml:J()}],"space-x":[{"space-x":S()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":S()}],"space-y-reverse":["space-y-reverse"],size:[{size:Q()}],"inline-size":[{inline:["auto",...W()]}],"min-inline-size":[{"min-inline":["auto",...W()]}],"max-inline-size":[{"max-inline":["none",...W()]}],"block-size":[{block:["auto",...X()]}],"min-block-size":[{"min-block":["auto",...X()]}],"max-block-size":[{"max-block":["none",...X()]}],w:[{w:[c,"screen",...Q()]}],"min-w":[{"min-w":[c,"screen","none",...Q()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...Q()]}],h:[{h:["screen","lh",...Q()]}],"min-h":[{"min-h":["screen","lh","none",...Q()]}],"max-h":[{"max-h":["screen","lh",...Q()]}],"font-size":[{text:["base",n,Oc,Ya]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,Hz,Uz]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ng,dt]}],"font-family":[{font:[Bz,Fz,e]}],"font-features":[{"font-features":[dt]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[r,mt,dt]}],"line-clamp":[{"line-clamp":[Xt,"none",mt,cE]}],leading:[{leading:[s,...S()]}],"list-image":[{"list-image":["none",mt,dt]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",mt,dt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:K()}],"text-color":[{text:K()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[..._e(),"wavy"]}],"text-decoration-thickness":[{decoration:[Xt,"from-font","auto",mt,Ya]}],"text-decoration-color":[{decoration:K()}],"underline-offset":[{"underline-offset":[Xt,"auto",mt,dt]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:S()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",mt,dt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",mt,dt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:B()}],"bg-repeat":[{bg:ie()}],"bg-size":[{bg:ve()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ha,mt,dt],radial:["",mt,dt],conic:[ha,mt,dt]},Vz,Oz]}],"bg-color":[{bg:K()}],"gradient-from-pos":[{from:Ce()}],"gradient-via-pos":[{via:Ce()}],"gradient-to-pos":[{to:Ce()}],"gradient-from":[{from:K()}],"gradient-via":[{via:K()}],"gradient-to":[{to:K()}],rounded:[{rounded:we()}],"rounded-s":[{"rounded-s":we()}],"rounded-e":[{"rounded-e":we()}],"rounded-t":[{"rounded-t":we()}],"rounded-r":[{"rounded-r":we()}],"rounded-b":[{"rounded-b":we()}],"rounded-l":[{"rounded-l":we()}],"rounded-ss":[{"rounded-ss":we()}],"rounded-se":[{"rounded-se":we()}],"rounded-ee":[{"rounded-ee":we()}],"rounded-es":[{"rounded-es":we()}],"rounded-tl":[{"rounded-tl":we()}],"rounded-tr":[{"rounded-tr":we()}],"rounded-br":[{"rounded-br":we()}],"rounded-bl":[{"rounded-bl":we()}],"border-w":[{border:ne()}],"border-w-x":[{"border-x":ne()}],"border-w-y":[{"border-y":ne()}],"border-w-s":[{"border-s":ne()}],"border-w-e":[{"border-e":ne()}],"border-w-bs":[{"border-bs":ne()}],"border-w-be":[{"border-be":ne()}],"border-w-t":[{"border-t":ne()}],"border-w-r":[{"border-r":ne()}],"border-w-b":[{"border-b":ne()}],"border-w-l":[{"border-l":ne()}],"divide-x":[{"divide-x":ne()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ne()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[..._e(),"hidden","none"]}],"divide-style":[{divide:[..._e(),"hidden","none"]}],"border-color":[{border:K()}],"border-color-x":[{"border-x":K()}],"border-color-y":[{"border-y":K()}],"border-color-s":[{"border-s":K()}],"border-color-e":[{"border-e":K()}],"border-color-bs":[{"border-bs":K()}],"border-color-be":[{"border-be":K()}],"border-color-t":[{"border-t":K()}],"border-color-r":[{"border-r":K()}],"border-color-b":[{"border-b":K()}],"border-color-l":[{"border-l":K()}],"divide-color":[{divide:K()}],"outline-style":[{outline:[..._e(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Xt,mt,dt]}],"outline-w":[{outline:["",Xt,Oc,Ya]}],"outline-color":[{outline:K()}],shadow:[{shadow:["","none",h,Yd,qd]}],"shadow-color":[{shadow:K()}],"inset-shadow":[{"inset-shadow":["none",p,Yd,qd]}],"inset-shadow-color":[{"inset-shadow":K()}],"ring-w":[{ring:ne()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:K()}],"ring-offset-w":[{"ring-offset":[Xt,Ya]}],"ring-offset-color":[{"ring-offset":K()}],"inset-ring-w":[{"inset-ring":ne()}],"inset-ring-color":[{"inset-ring":K()}],"text-shadow":[{"text-shadow":["none",m,Yd,qd]}],"text-shadow-color":[{"text-shadow":K()}],opacity:[{opacity:[Xt,mt,dt]}],"mix-blend":[{"mix-blend":[...Se(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Se()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Xt]}],"mask-image-linear-from-pos":[{"mask-linear-from":Ie()}],"mask-image-linear-to-pos":[{"mask-linear-to":Ie()}],"mask-image-linear-from-color":[{"mask-linear-from":K()}],"mask-image-linear-to-color":[{"mask-linear-to":K()}],"mask-image-t-from-pos":[{"mask-t-from":Ie()}],"mask-image-t-to-pos":[{"mask-t-to":Ie()}],"mask-image-t-from-color":[{"mask-t-from":K()}],"mask-image-t-to-color":[{"mask-t-to":K()}],"mask-image-r-from-pos":[{"mask-r-from":Ie()}],"mask-image-r-to-pos":[{"mask-r-to":Ie()}],"mask-image-r-from-color":[{"mask-r-from":K()}],"mask-image-r-to-color":[{"mask-r-to":K()}],"mask-image-b-from-pos":[{"mask-b-from":Ie()}],"mask-image-b-to-pos":[{"mask-b-to":Ie()}],"mask-image-b-from-color":[{"mask-b-from":K()}],"mask-image-b-to-color":[{"mask-b-to":K()}],"mask-image-l-from-pos":[{"mask-l-from":Ie()}],"mask-image-l-to-pos":[{"mask-l-to":Ie()}],"mask-image-l-from-color":[{"mask-l-from":K()}],"mask-image-l-to-color":[{"mask-l-to":K()}],"mask-image-x-from-pos":[{"mask-x-from":Ie()}],"mask-image-x-to-pos":[{"mask-x-to":Ie()}],"mask-image-x-from-color":[{"mask-x-from":K()}],"mask-image-x-to-color":[{"mask-x-to":K()}],"mask-image-y-from-pos":[{"mask-y-from":Ie()}],"mask-image-y-to-pos":[{"mask-y-to":Ie()}],"mask-image-y-from-color":[{"mask-y-from":K()}],"mask-image-y-to-color":[{"mask-y-to":K()}],"mask-image-radial":[{"mask-radial":[mt,dt]}],"mask-image-radial-from-pos":[{"mask-radial-from":Ie()}],"mask-image-radial-to-pos":[{"mask-radial-to":Ie()}],"mask-image-radial-from-color":[{"mask-radial-from":K()}],"mask-image-radial-to-color":[{"mask-radial-to":K()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":T()}],"mask-image-conic-pos":[{"mask-conic":[Xt]}],"mask-image-conic-from-pos":[{"mask-conic-from":Ie()}],"mask-image-conic-to-pos":[{"mask-conic-to":Ie()}],"mask-image-conic-from-color":[{"mask-conic-from":K()}],"mask-image-conic-to-color":[{"mask-conic-to":K()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:B()}],"mask-repeat":[{mask:ie()}],"mask-size":[{mask:ve()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",mt,dt]}],filter:[{filter:["","none",mt,dt]}],blur:[{blur:et()}],brightness:[{brightness:[Xt,mt,dt]}],contrast:[{contrast:[Xt,mt,dt]}],"drop-shadow":[{"drop-shadow":["","none",v,Yd,qd]}],"drop-shadow-color":[{"drop-shadow":K()}],grayscale:[{grayscale:["",Xt,mt,dt]}],"hue-rotate":[{"hue-rotate":[Xt,mt,dt]}],invert:[{invert:["",Xt,mt,dt]}],saturate:[{saturate:[Xt,mt,dt]}],sepia:[{sepia:["",Xt,mt,dt]}],"backdrop-filter":[{"backdrop-filter":["","none",mt,dt]}],"backdrop-blur":[{"backdrop-blur":et()}],"backdrop-brightness":[{"backdrop-brightness":[Xt,mt,dt]}],"backdrop-contrast":[{"backdrop-contrast":[Xt,mt,dt]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Xt,mt,dt]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Xt,mt,dt]}],"backdrop-invert":[{"backdrop-invert":["",Xt,mt,dt]}],"backdrop-opacity":[{"backdrop-opacity":[Xt,mt,dt]}],"backdrop-saturate":[{"backdrop-saturate":[Xt,mt,dt]}],"backdrop-sepia":[{"backdrop-sepia":["",Xt,mt,dt]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":S()}],"border-spacing-x":[{"border-spacing-x":S()}],"border-spacing-y":[{"border-spacing-y":S()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",mt,dt]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Xt,"initial",mt,dt]}],ease:[{ease:["linear","initial",x,mt,dt]}],delay:[{delay:[Xt,mt,dt]}],animate:[{animate:["none",M,mt,dt]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,mt,dt]}],"perspective-origin":[{"perspective-origin":D()}],rotate:[{rotate:xt()}],"rotate-x":[{"rotate-x":xt()}],"rotate-y":[{"rotate-y":xt()}],"rotate-z":[{"rotate-z":xt()}],scale:[{scale:pn()}],"scale-x":[{"scale-x":pn()}],"scale-y":[{"scale-y":pn()}],"scale-z":[{"scale-z":pn()}],"scale-3d":["scale-3d"],skew:[{skew:ht()}],"skew-x":[{"skew-x":ht()}],"skew-y":[{"skew-y":ht()}],transform:[{transform:[mt,dt,"","none","gpu","cpu"]}],"transform-origin":[{origin:D()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ut()}],"translate-x":[{"translate-x":Ut()}],"translate-y":[{"translate-y":Ut()}],"translate-z":[{"translate-z":Ut()}],"translate-none":["translate-none"],accent:[{accent:K()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:K()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",mt,dt]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":S()}],"scroll-mx":[{"scroll-mx":S()}],"scroll-my":[{"scroll-my":S()}],"scroll-ms":[{"scroll-ms":S()}],"scroll-me":[{"scroll-me":S()}],"scroll-mbs":[{"scroll-mbs":S()}],"scroll-mbe":[{"scroll-mbe":S()}],"scroll-mt":[{"scroll-mt":S()}],"scroll-mr":[{"scroll-mr":S()}],"scroll-mb":[{"scroll-mb":S()}],"scroll-ml":[{"scroll-ml":S()}],"scroll-p":[{"scroll-p":S()}],"scroll-px":[{"scroll-px":S()}],"scroll-py":[{"scroll-py":S()}],"scroll-ps":[{"scroll-ps":S()}],"scroll-pe":[{"scroll-pe":S()}],"scroll-pbs":[{"scroll-pbs":S()}],"scroll-pbe":[{"scroll-pbe":S()}],"scroll-pt":[{"scroll-pt":S()}],"scroll-pr":[{"scroll-pr":S()}],"scroll-pb":[{"scroll-pb":S()}],"scroll-pl":[{"scroll-pl":S()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",mt,dt]}],fill:[{fill:["none",...K()]}],"stroke-w":[{stroke:[Xt,Oc,Ya,cE]}],stroke:[{stroke:["none",...K()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Wz=wz(jz);function Si(...t){return Wz(nz(t))}const $z=O.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",children:[O.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1Z",fill:"#4285F4"}),O.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23Z",fill:"#34A853"}),O.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18A10.96 10.96 0 0 0 1 12c0 1.77.42 3.44 1.18 4.93l3.66-2.84Z",fill:"#FBBC05"}),O.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53Z",fill:"#EA4335"})]}),Xz=O.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:O.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12Z"})}),qz={google:$z,github:Xz},Yz={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",apple:"Apple"};function Kz(t){return Yz[t]||String(t||"").replace(/-/g," ")}function Zz(){const{isOpen:t,closeLoginModal:e}=AT(),{enabled:n,signedIn:i,refreshUser:r,signInWithPassword:s,signUp:o,signInWithOAuth:c,getPublicAuthConfig:u}=Ro(),[f,h]=k.useState("signin"),[p,m]=k.useState(""),[v,_]=k.useState(""),[w,y]=k.useState(""),[x,M]=k.useState(!1),[A,T]=k.useState(null),[D,I]=k.useState(null),[U,S]=k.useState(!1),[R,V]=k.useState(!0),[F,j]=k.useState([]),[Z,H]=k.useState(8);k.useEffect(()=>{t&&(T(null),I(null),h("signin"),m(""),_(""),y(""),S(!1))},[t]),k.useEffect(()=>{if(!t||!n){V(!1);return}let W=!0;return(async()=>{const{data:X,error:K}=await u();if(W){if(K||!X)j(["google","github"]);else{const B=Array.isArray(X.oAuthProviders)?X.oAuthProviders:[],ie=Array.isArray(X.customOAuthProviders)?X.customOAuthProviders:[];j([...B,...ie]),typeof X.passwordMinLength=="number"&&X.passwordMinLength>0&&H(X.passwordMinLength)}V(!1)}})(),()=>{W=!1}},[t,n,u]),k.useEffect(()=>{t&&i&&e()},[t,i,e]);const q=k.useMemo(()=>typeof window>"u"?"":window.location.origin+"/",[]),J=k.useCallback(async W=>{T(null),M(!0);try{const{error:X}=await c(W,q);X&&T(X.message||String(X))}finally{M(!1)}},[c,q]),Q=k.useCallback(async W=>{W.preventDefault(),T(null),M(!0);try{if(f==="signup"){const{data:K,error:B}=await o({email:p.trim(),password:v,name:w.trim()||void 0});if(B){T(B.message||String(B));return}if(K?.requireEmailVerification){I("Check your email for a verification link."),h("signin");return}await r();return}const{error:X}=await s({email:p.trim(),password:v});if(X){T(X.message||String(X));return}await r()}finally{M(!1)}},[f,p,v,w,o,s,r]);return k.useEffect(()=>{if(!t)return;const W=X=>{X.key==="Escape"&&e()};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[t,e]),n?O.jsx(I0,{children:t&&O.jsxs(Is.div,{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[O.jsx(Is.div,{className:"absolute inset-0 bg-black/40 dark:bg-black/60 ",onClick:e,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}}),O.jsxs(Is.div,{className:"relative w-full max-w-[420px] rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 p-6 shadow-2xl",initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:{duration:.2},onClick:W=>W.stopPropagation(),children:[O.jsx("button",{type:"button",onClick:e,className:"absolute right-4 top-4 text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",children:O.jsx(tz,{className:"h-5 w-5"})}),O.jsxs("div",{className:"text-center mb-6",children:[O.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[O.jsx("img",{src:"/app-icon.png",alt:"",width:28,height:28,className:"rounded-md"}),O.jsx("span",{className:"text-lg font-semibold text-oai-black dark:text-white",children:"Token Tracker"})]}),O.jsx("p",{className:"text-sm text-oai-gray-500",children:"Sign in to join the leaderboard"})]}),D&&O.jsx("div",{className:"mb-4 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900/50 px-3 py-2 text-xs text-oai-gray-700 dark:text-oai-gray-300",children:D}),A&&O.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",role:"alert",children:A}),O.jsx("div",{className:"space-y-2.5 mb-5",children:R?O.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900 animate-pulse"}):F.map(W=>O.jsxs("button",{type:"button",disabled:x,onClick:()=>J(W),className:Si("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors disabled:opacity-50","flex items-center justify-center gap-2.5"),children:[qz[W]||null,"Continue with ",Kz(W)]},W))}),U?O.jsxs(O.Fragment,{children:[O.jsxs("div",{className:"relative mb-5",children:[O.jsx("div",{className:"absolute inset-0 flex items-center",children:O.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),O.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:O.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:"email"})})]}),O.jsxs("div",{className:"flex rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 bg-oai-gray-50 dark:bg-oai-gray-900/50 mb-4",children:[O.jsx("button",{type:"button",className:Si("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",f==="signin"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{h("signin"),T(null)},children:"Sign In"}),O.jsx("button",{type:"button",className:Si("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",f==="signup"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{h("signup"),T(null)},children:"Sign Up"})]}),O.jsxs("form",{onSubmit:Q,className:"space-y-3",children:[f==="signup"&&O.jsxs("div",{children:[O.jsx("label",{htmlFor:"modal-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:"Name"}),O.jsx("input",{id:"modal-name",type:"text",autoComplete:"name",value:w,onChange:W=>y(W.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500",placeholder:"Optional"})]}),O.jsxs("div",{children:[O.jsx("label",{htmlFor:"modal-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:"Email"}),O.jsx("input",{id:"modal-email",type:"email",autoComplete:"email",required:!0,value:p,onChange:W=>m(W.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),O.jsxs("div",{children:[O.jsx("label",{htmlFor:"modal-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:"Password"}),O.jsx("input",{id:"modal-password",type:"password",autoComplete:f==="signup"?"new-password":"current-password",required:!0,minLength:f==="signup"?Z:void 0,value:v,onChange:W=>_(W.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"}),f==="signup"&&O.jsxs("p",{className:"mt-1 text-xs text-oai-gray-400 dark:text-oai-gray-600",children:["At least ",Z," characters"]})]}),O.jsx("button",{type:"submit",disabled:x,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:f==="signup"?"Create Account":"Sign In"})]})]}):O.jsxs(O.Fragment,{children:[O.jsxs("div",{className:"relative mb-5",children:[O.jsx("div",{className:"absolute inset-0 flex items-center",children:O.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),O.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:O.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:"or"})})]}),O.jsxs("button",{type:"button",onClick:()=>S(!0),className:Si("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors","flex items-center justify-center gap-2.5"),children:[O.jsx(Z5,{className:"h-[18px] w-[18px] text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75}),"Continue with Email"]})]})]})]})}):null}const Jz={};function Qz(){if(typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"))return"";const e=typeof import.meta<"u"?Jz:void 0;return(e?.VITE_TOKENTRACKER_BACKEND_BASE_URL||e?.VITE_INSFORGE_BASE_URL||"").trim()}function f$(){return Co()}function h$(){if(typeof Intl>"u"||!Intl.DateTimeFormat)return null;try{return Intl.DateTimeFormat().resolvedOptions().timeZone||null}catch{return null}}function p$(t=new Date){const e=t instanceof Date?t:new Date(t);if(!Number.isFinite(e.getTime()))return 0;const n=e.getTimezoneOffset();return Number.isFinite(n)?-n:0}function PC(t){if(!Number.isFinite(t)||t===0)return"UTC";const e=t>=0?"+":"-",n=Math.abs(t),i=String(Math.floor(n/60)).padStart(2,"0"),r=String(n%60).padStart(2,"0");return`UTC${e}${i}:${r}`}function m$({timeZone:t,offsetMinutes:e}={}){const n=PC(e);return t&&t!=="UTC"?`${t} (${n})`:n}function g$({timeZone:t,offsetMinutes:e}={}){return Number.isFinite(e)?PC(e):t||"UTC"}function v$({timeZone:t,offsetMinutes:e,date:n=new Date}={}){const i=n instanceof Date?n:new Date(n);if(!Number.isFinite(i.getTime()))return"";if(t&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const o=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i).reduce((h,p)=>(p.type&&p.value&&(h[p.type]=p.value),h),{}),c=o.year,u=o.month,f=o.day;if(c&&u&&f)return`${c}-${u}-${f}`}catch{}if(typeof e=="number"&&Number.isFinite(e)){const r=new Date(i.getTime()+e*6e4);return tV(r)}return nV(i)}function eV({timeZone:t,offsetMinutes:e,date:n=new Date}={}){const i=n instanceof Date?n:new Date(n);if(!Number.isFinite(i.getTime()))return null;if(t&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const o=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i).reduce((h,p)=>(p.type&&p.value&&(h[p.type]=p.value),h),{}),c=Number(o.year),u=Number(o.month),f=Number(o.day);if(Number.isFinite(c)&&Number.isFinite(u)&&Number.isFinite(f))return{year:c,month:u,day:f}}catch{}if(typeof e=="number"&&Number.isFinite(e)){const r=new Date(i.getTime()+e*6e4);return{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate()}}return{year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()}}function y$({timeZone:t,offsetMinutes:e}={}){return t?`tz:${t}`:typeof e=="number"&&Number.isFinite(e)?`offset:${Math.trunc(e)}`:"utc"}function tV(t){const e=t.getUTCFullYear(),n=String(t.getUTCMonth()+1).padStart(2,"0"),i=String(t.getUTCDate()).padStart(2,"0");return`${e}-${n}-${i}`}function nV(t){const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${i}`}function kn(t){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())).toISOString().slice(0,10)}function fs(t){const e=t instanceof Date?t:new Date(t);if(!Number.isFinite(e.getTime()))return"";const n=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${n}-${i}-${r}`}function iV(t){if(!t)return null;const e=String(t).trim(),n=e.split("-");if(n.length!==3)return null;const i=Number(n[0]),r=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(s))return null;const o=new Date(Date.UTC(i,r,s));return Number.isFinite(o.getTime())&&kn(o)===e?o:null}function rV(t){if(!t)return"";const e=t.year,n=String(t.month).padStart(2,"0"),i=String(t.day).padStart(2,"0");return!e||!n||!i?"":`${e}-${n}-${i}`}function sV(t,{timeZone:e,offsetMinutes:n,now:i}={}){const r=i instanceof Date&&Number.isFinite(i.getTime())?i:new Date,s=eV({timeZone:e,offsetMinutes:n,date:r});if(!s){const u=fs(new Date);return{from:u,to:u}}const o=rV(s),c=iV(o);if(!c)return{from:o,to:o};if(t==="day")return{from:o,to:o};if(t==="week"){const u=new Date(c),h=(u.getUTCDay()+6)%7;u.setUTCDate(u.getUTCDate()-h);const p=new Date(u);return p.setUTCDate(p.getUTCDate()+6),{from:kn(u),to:kn(p)}}if(t==="month"){const u=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth(),1)),f=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth()+1,0));return{from:kn(u),to:kn(f)}}if(t==="total"){const u=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth()-23,1));return{from:kn(u),to:o}}return sV("week")}function _$(t){if(t==null)return"-";try{if(typeof t=="bigint")return new Intl.NumberFormat().format(t);if(typeof t=="number")return new Intl.NumberFormat().format(t);const e=String(t).trim();return/^[0-9]+$/.test(e)?new Intl.NumberFormat().format(BigInt(e)):e}catch{return String(t)}}function x$(t,{thousandSuffix:e="K",millionSuffix:n="M",billionSuffix:i="B",decimals:r=1}={}){const s=Number(String(t));if(!Number.isFinite(s))return"-";const o=s<0?"-":"",c=Math.abs(s),u=Math.max(0,Math.min(6,Math.floor(r)));if(c<1e3)return`${o}${String(c)}`;const f=(v,_)=>{const w=v.toFixed(u),y=Number(w).toString();return`${o}${y}${_}`},h=(v,_,w)=>{const y=v.toFixed(u),x=Number(y);return w&&x>=1e3?f(x/1e3,w):`${o}${x.toString()}${_}`};if(c>=1e9)return f(c/1e9,i);if(c>=1e6)return h(c/1e6,n,i);const p=c/1e3,m=Number(p.toFixed(u));return m>=1e3?f(m/1e3,n):f(m,e)}function kC(t){const e=Number(String(t));return Number.isFinite(e)?e:null}function b$(t,{decimals:e=2}={}){if(t==null)return"-";const n=String(t).trim();if(!n)return"-";const i=n.match(/^(-?\d+)(?:\.(\d+))?$/);if(!i)return n;const r=i[1],s=i[2]||"";let o=r;try{o=new Intl.NumberFormat().format(BigInt(r))}catch{o=r}const c=Math.max(0,Math.min(6,Math.floor(e))),u=c?s.slice(0,c).padEnd(c,"0"):"",f=r.startsWith("-")?"-":"",h=c?`${o.replace("-","")}.${u}`:o.replace("-","");return`${f}$${h}`}function gh(t){if(typeof t!="string")return null;const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.trim());if(!e)return null;const n=Number(e[1]),i=Number(e[2])-1,r=Number(e[3]),s=new Date(Date.UTC(n,i,r));return Number.isFinite(s.getTime())&&kn(s)===t.trim()?s:null}function uo(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()+e))}function aV(t,e){const n=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())-Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate());return Math.floor(n/864e5)}function ig(t,e){if(!Array.isArray(t)||t.length===0)return 0;const n=t.length,i=(n-1)*e,r=Math.floor(i),s=i-r,o=t[r]??t[n-1],c=t[Math.min(n-1,r+1)]??t[n-1];return Math.round(o+(c-o)*s)}function oV(t){return t<=0?0:t>=4?4:t}function LC({weeks:t=52,now:e,weekStartsOn:n="sun"}={}){const i=e instanceof Date&&Number.isFinite(e.getTime())?e:new Date,r=fs(i),s=gh(r)||new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),o=n==="mon"?1:0,c=s.getUTCDay(),u=uo(s,-((c-o+7)%7)),f=uo(u,-7*(Math.max(1,t)-1));return{from:kn(f),to:r}}function lV({dailyRows:t,weeks:e=52,to:n,weekStartsOn:i="sun"}={}){const r=gh(n)||new Date(Date.UTC(new Date().getFullYear(),new Date().getMonth(),new Date().getDate())),{from:s}=LC({weeks:e,now:r,weekStartsOn:i}),o=gh(s)||uo(r,-(e*7-1)),c=(()=>{const T=(o.getUTCDay()-(i==="mon"?1:0)+7)%7;return uo(o,-T)})(),u=new Map;for(const M of Array.isArray(t)?t:[]){const A=typeof M?.day=="string"?M.day:null;if(!A)continue;const T=kC(M?.billable_total_tokens??M?.total_tokens)??0;u.set(A,Math.max(0,T))}const f=aV(c,r)+1,h=Math.ceil(f/7),p=[];for(let M=0;M<f;M++){const A=uo(c,M),T=kn(A),D=u.get(T)??0;D>0&&p.push(D)}p.sort((M,A)=>M-A);const m=ig(p,.5),v=ig(p,.75),_=ig(p,.9);function w(M){return!M||M<=0?0:M<=m?1:M<=v?2:M<=_?3:4}const y=[];for(let M=0;M<h;M++){const A=[];for(let T=0;T<7;T++){const D=M*7+T,I=uo(c,D);if(I.getTime()>r.getTime()){A.push(null);continue}const U=kn(I),S=u.get(U)??0;A.push({day:U,value:S,level:oV(w(S))})}y.push(A)}const x=y.length>e?y.slice(y.length-e):y;return{from:s,to:kn(r),weeks:x,thresholds:{t1:m,t2:v,t3:_}}}function cV({dailyRows:t,to:e}={}){const n=gh(e)||new Date(Date.UTC(new Date().getFullYear(),new Date().getMonth(),new Date().getDate())),i=new Map;for(const s of Array.isArray(t)?t:[]){const o=typeof s?.day=="string"?s.day:null;if(!o)continue;const c=kC(s?.billable_total_tokens??s?.total_tokens)??0;i.set(o,Math.max(0,c))}let r=0;for(let s=0;s<370;s++){const o=kn(uo(n,-s));if((i.get(o)??0)>0){r+=1;continue}break}return r}const Oh={},DC="tokentracker",uV=["victorgpt/tokentracker","spacedriveapp/spacedrive","acme/alpha","acme/beta","neo/nebula","signal/flux","matrix/terminal","orbit/atlas","lumen/core","delta/horizon"],fE=["NEO","TRINITY","MORPHEUS","ORACLE","CYPHER","SWITCH","APOC","TANK","SMITH","SERAPH","NIOBE","MOUSE","DOZER","LINK","BLADE"];function _r(){if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock")||"").toLowerCase();if(e==="0"||e==="false"||e==="off"||e==="no")return!1;if(e==="1"||e==="true"||e==="on"||e==="yes")return!0}if(typeof import.meta<"u"&&Oh){const t="".toLowerCase();if(t==="1"||t==="true")return!0}return!1}function dV(){if(typeof import.meta<"u"&&Oh){const t="".trim();if(t)return t;const e="".trim();if(e)return e}if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock_now")||"").trim();if(e)return e;const n=String(t.get("mock_today")||"").trim();if(n)return n}return""}function fV(t){if(!t)return null;const e=String(t).trim();if(!e)return null;if(/^\d{4}-\d{2}-\d{2}$/.test(e)){const[i,r,s]=e.split("-").map(Number);if(!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(s))return null;const o=new Date(i,r-1,s,12,0,0);return Number.isFinite(o.getTime())?o:null}const n=new Date(e);return Number.isFinite(n.getTime())?n:null}function S$(){return _r()?fV(dV()):null}function hV(){if(typeof import.meta<"u"&&Oh){const t="".trim();if(t)return t}if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock_seed")||"").trim();if(e)return e}return DC}function pV(){if(typeof import.meta<"u"&&Oh){const t="".trim(),e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=String(t.get("mock_missing")||"").trim(),n=Number(e);if(Number.isFinite(n)&&n>0)return Math.floor(n)}return 0}function Ru(t){return(t==null?hV():String(t)).trim()||DC}function Pu(t){let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function ki(t){if(typeof t!="string")return null;const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.trim());if(!e)return null;const n=Number(e[1]),i=Number(e[2])-1,r=Number(e[3]),s=new Date(Date.UTC(n,i,r));return Number.isFinite(s.getTime())&&kn(s)===t.trim()?s:null}function gu(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()+e))}function NC(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+e,1))}function mV(t){return`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,"0")}`}function Bl({from:t,to:e,seed:n}){const i=ki(fs(new Date))||new Date,r=ki(t)||i,s=ki(e)||r,o=[],c=Ru(n),u=Math.floor((Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())-Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate()))/864e5)+1;for(let f=0;f<u;f+=1){const h=gu(r,f),p=kn(h),m=Pu(`${c}:${p}`),v=m%1e3/1e3,_=.6+.4*Math.sin(f/6*Math.PI*.5),w=h.getUTCDay()===0||h.getUTCDay()===6?.65:1,y=18e3+Math.round(12e3*v),x=Math.max(0,Math.round(y*_*w)),M=Math.round(x*.46),A=Math.round(x*.34),T=Math.round(x*.14),D=Math.max(0,x-M-A-T);o.push({day:p,total_tokens:x,billable_total_tokens:x,input_tokens:M,output_tokens:A,cached_input_tokens:T,reasoning_output_tokens:D,conversation_count:1+m%5})}return o}function gV({day:t,seed:e}){const n=ki(t)||ki(fs(new Date))||new Date,i=kn(n),r=Ru(e),s=Array.from({length:48},(c,u)=>{const f=Math.floor(u/2),h=u%2===0?0:30,m=Pu(`${r}:${i}:${f}:${h}`)%1e3/1e3,v=(f+h/60)/24,_=.4+.6*Math.sin(v*Math.PI*2),w=900+Math.round(700*m),y=Math.max(0,Math.round(w*_)),x=Math.round(y*.46),M=Math.round(y*.34),A=Math.round(y*.14),T=Math.max(0,y-x-M-A);return{hour:`${i}T${String(f).padStart(2,"0")}:${String(h).padStart(2,"0")}:00`,total_tokens:y,billable_total_tokens:y,input_tokens:x,output_tokens:M,cached_input_tokens:A,reasoning_output_tokens:T}}),o=Math.max(0,Math.min(48,pV()));if(o>0){const c=Date.now(),u=s.map((p,m)=>{const v=Date.parse(p.hour);return Number.isFinite(v)&&v<=c?{index:m,ts:v}:null}).filter(Boolean),f=Math.max(0,u.length-o),h=u.slice(f);for(const p of h){const m=s[p.index];m&&(s[p.index]={...m,missing:!0})}}return s}function vV({months:t=24,to:e,seed:n}){const i=ki(e)||ki(fs(new Date))||new Date,r=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1)),s=Ru(n),o=[];for(let c=t-1;c>=0;c-=1){const u=NC(r,-c),f=mV(u),p=Pu(`${s}:${f}`)%1e3/1e3,m=.7+.3*Math.sin(o.length/6*Math.PI*.5),v=36e4+Math.round(2e5*p),_=Math.max(0,Math.round(v*m)),w=Math.round(_*.46),y=Math.round(_*.34),x=Math.round(_*.14),M=Math.max(0,_-w-y-x);o.push({month:f,total_tokens:_,billable_total_tokens:_,input_tokens:w,output_tokens:y,cached_input_tokens:x,reasoning_output_tokens:M})}return o}function Wy(t){return t.reduce((e,n)=>(e.total_tokens+=Number(n.total_tokens||0),e.billable_total_tokens+=Number(n.billable_total_tokens||n.total_tokens||0),e.input_tokens+=Number(n.input_tokens||0),e.output_tokens+=Number(n.output_tokens||0),e.cached_input_tokens+=Number(n.cached_input_tokens||0),e.reasoning_output_tokens+=Number(n.reasoning_output_tokens||0),e.conversation_count+=Number(n.conversation_count||0),e),{total_tokens:0,billable_total_tokens:0,input_tokens:0,output_tokens:0,cached_input_tokens:0,reasoning_output_tokens:0,conversation_count:0})}function yV(t,e=1.75){const n=Number(t||0);return!Number.isFinite(n)||n<=0?"0.000000":(n*e/1e6).toFixed(6)}function hE(t,e){const n=Number.isFinite(e)?e:0;return{total_tokens:Math.max(0,Math.round(t.total_tokens*n)),billable_total_tokens:Math.max(0,Math.round((t.billable_total_tokens??t.total_tokens)*n)),input_tokens:Math.max(0,Math.round(t.input_tokens*n)),output_tokens:Math.max(0,Math.round(t.output_tokens*n)),cached_input_tokens:Math.max(0,Math.round(t.cached_input_tokens*n)),reasoning_output_tokens:Math.max(0,Math.round(t.reasoning_output_tokens*n))}}function B0(t){return{...t,total_cost_usd:yV(t.total_tokens)}}function _V({from:t,to:e,seed:n}={}){const i=Bl({from:t,to:e,seed:n});return{from:t,to:e,data:i}}function xV({day:t,seed:e}={}){const n=ki(t)||new Date,i=kn(n),r=gV({day:i,seed:e});return{day:i,data:r}}function bV({months:t=24,to:e,seed:n}={}){const i=ki(e)||ki(fs(new Date))||new Date,r=kn(i),s=vV({months:t,to:r,seed:n}),o=NC(new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1)),-(t-1));return{from:kn(o),to:r,months:t,data:s}}function SV({from:t,to:e,seed:n,rolling:i=!0}={}){const r=Bl({from:t,to:e,seed:n}),s=Wy(r),o=B0(s),c=i?wV({to:e,seed:n}):null;return{from:t,to:e,days:r.length,totals:o,...c?{rolling:c}:{}}}function wV({to:t,seed:e}={}){const n=ki(t)||ki(fs(new Date))||new Date,i=kn(n),r=kn(gu(n,-6)),s=kn(gu(n,-29)),o=Bl({from:r,to:i,seed:e}),c=Bl({from:s,to:i,seed:e});return{last_7d:pE({rows:o,from:r,to:i}),last_30d:pE({rows:c,from:s,to:i})}}function pE({rows:t,from:e,to:n}={}){const i=Wy(t||[]),r=(t||[]).filter(o=>Number(o.billable_total_tokens??o.total_tokens)>0).length,s=r>0?Math.floor(i.billable_total_tokens/r):0;return{from:e,to:n,totals:{billable_total_tokens:i.billable_total_tokens,conversation_count:i.conversation_count},active_days:r,avg_per_active_day:s}}function EV({seed:t,limit:e=3}={}){const n=Ru(t),i=uV.map((r,s)=>{const c=12e4+Pu(`${n}:${r}`)%9e5,u=s%4*4200,f=Math.max(0,c+u),h=Math.max(0,Math.round(f*.96));return{project_key:r,project_ref:`https://github.com/${r}`,total_tokens:String(f),billable_total_tokens:String(h)}}).sort((r,s)=>Number(s.billable_total_tokens)-Number(r.billable_total_tokens)).slice(0,Math.max(1,Math.min(10,Math.floor(Number(e)||3))));return{generated_at:new Date().toISOString(),entries:i}}function MV(t){const e=ki(fs(new Date))||new Date,n=String(t).trim().toLowerCase()||"week";if(n==="total")return{from:"1970-01-01",to:"9999-12-31"};if(n==="month"){const o=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)),c=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+1,0));return{from:kn(o),to:kn(c)}}const i=e.getUTCDay(),r=kn(gu(e,-i)),s=kn(gu(e,-i+6));return{from:r,to:s}}function IC({seed:t,period:e,metric:n,limit:i=20,offset:r=0}={}){const s=Ru(t),o=Math.max(1,Math.min(100,Math.floor(Number(i)||20))),c=Math.max(0,Math.min(1e4,Math.floor(Number(r)||0))),u=String(n||"all").trim().toLowerCase()||"all",f=String(e||"week").trim().toLowerCase()||"week",h=f==="month"||f==="total"||f==="week"?f:"week",{from:p,to:m}=MV(h),v=250,_=v>0?Math.ceil(v/o):0,w=Math.floor(c/o)+1,y=Array.from({length:v},(U,S)=>{const R=S+1,V=`00000000-0000-0000-0000-${String(R).padStart(12,"0")}`,F=fE[R%fE.length],Z=18e4+Pu(`${s}:${F}:${R}`)%9e5,H=Math.max(0,Z+R*1200),q=Math.floor(H*.28),J=Math.floor(H*.18),Q=Math.floor(H*.12),W=Math.floor(H*.12),X=Math.floor(H*.1),K=Math.max(0,H-q-J-Q-W-X),B=R%7!==0;return{id:R,user_id:V,is_public:B,is_me:!1,display_name:B?F:"Anonymous",avatar_url:null,gpt_tokens:q,claude_tokens:J,gemini_tokens:Q,cursor_tokens:W,opencode_tokens:X,openclaw_tokens:K,other_tokens:0,total_tokens:H}}),x=Math.max(0,Math.min(v-1,Math.floor(v*.8)));y[x]&&(y[x].is_me=!0);const M=u==="gpt"||u==="codex"?"gpt_tokens":u==="claude"?"claude_tokens":u==="gemini"?"gemini_tokens":u==="cursor"?"cursor_tokens":u==="opencode"?"opencode_tokens":u==="openclaw"?"openclaw_tokens":"total_tokens",A=y.slice().sort((U,S)=>Number(S[M])-Number(U[M])||U.id-S.id).map((U,S)=>({user_id:U.is_public?U.user_id:null,rank:S+1,is_me:!!U.is_me,display_name:U.display_name,avatar_url:U.avatar_url,gpt_tokens:String(U.gpt_tokens),claude_tokens:String(U.claude_tokens),gemini_tokens:String(U.gemini_tokens),cursor_tokens:String(U.cursor_tokens),opencode_tokens:String(U.opencode_tokens),openclaw_tokens:String(U.openclaw_tokens),other_tokens:String(U.other_tokens??0),total_tokens:String(U.total_tokens),is_public:!!U.is_public})),T=A.find(U=>U?.is_me)||null,D=T?{rank:T.rank,gpt_tokens:T.gpt_tokens,claude_tokens:T.claude_tokens,gemini_tokens:T.gemini_tokens,cursor_tokens:T.cursor_tokens,opencode_tokens:T.opencode_tokens,openclaw_tokens:T.openclaw_tokens,other_tokens:T.other_tokens,total_tokens:T.total_tokens}:{rank:null,gpt_tokens:"0",claude_tokens:"0",gemini_tokens:"0",cursor_tokens:"0",opencode_tokens:"0",openclaw_tokens:"0",other_tokens:"0",total_tokens:"0"},I=A.slice(c,c+o);return{period:h,metric:u,from:p,to:m,generated_at:new Date().toISOString(),page:w,limit:o,offset:c,total_entries:v,total_pages:_,entries:I,me:D}}function TV({weeks:t=52,to:e,weekStartsOn:n="sun",seed:i}={}){const r=LC({weeks:t,now:ki(e)||ki(fs(new Date))||new Date,weekStartsOn:n}),s=Bl({from:r.from,to:r.to,seed:i});return{...lV({dailyRows:s,weeks:t,to:r.to,weekStartsOn:n}),week_starts_on:n,active_days:s.filter(c=>Number(c.billable_total_tokens??c.total_tokens)>0).length,streak_days:cV({dailyRows:s,to:r.to})}}function AV({from:t,to:e,seed:n}={}){const i=Bl({from:t,to:e,seed:n}),r=Wy(i),o=[{source:"codex",weight:.7,models:[{model:"gpt-5.2-codex",model_id:"gpt-5.2-codex",weight:.2},{model:"unknown",model_id:"unknown",weight:.8}]},{source:"claude",weight:.2,models:[{model:"claude-3.5",model_id:"claude-3.5",weight:.3},{model:"unknown",model_id:"unknown",weight:.7}]},{source:"every-code",weight:.1,models:[{model:"unknown",model_id:"unknown",weight:1}]}].map(c=>{const u=hE(r,c.weight),f=c.models.map(h=>{const p=hE(u,h.weight);return{model:h.model,model_id:h.model_id||h.model,totals:B0(p)}});return{source:c.source,totals:B0(u),models:f}});return{from:t,to:e,days:i.length,sources:o,pricing:{model:"mock",pricing_mode:"add",source:"mock",effective_from:fs(new Date),rates_per_million_usd:{input:"1.750000",cached_input:"0.175000",output:"14.000000",reasoning_output:"14.000000"}}}}function UC(t=""){if(typeof t!="string"||t.length===0)return!1;const e=new URLSearchParams(t),n=String(e.get("screenshot")||"").toLowerCase();return n==="1"||n==="true"}const CV=300*1e3;function $y(t){return typeof t=="string"&&/^https?:\/\//i.test(t.trim())}async function FC(t){const e=Co();if(!$y(e)||!t)return;const n=e.replace(/\/$/,""),i=Ph(),r={Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${t}`};i&&(r.apikey=i);try{await fetch(`${n}/functions/tokentracker-leaderboard-refresh`,{method:"POST",headers:r,body:"{}"})}catch{}}async function OC(t){const e=Co();if(!$y(e)||!t)return null;const n=e.replace(/\/$/,""),i=Ph(),r={Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${t}`};i&&(r.apikey=i);const s=typeof navigator<"u"&&typeof navigator.platform=="string"?navigator.platform:"web",o=await fetch(`${n}/functions/tokentracker-device-token-issue`,{method:"POST",headers:r,body:JSON.stringify({device_name:"Token Tracker (dashboard)",platform:s})});if(!o.ok)return null;const c=await o.json().catch(()=>null),u=typeof c?.token=="string"?c.token:null,f=typeof c?.device_id=="string"?c.device_id:null;return!u||!f?null:{token:u,deviceId:f,issuedAt:typeof c?.created_at=="string"?c.created_at:new Date().toISOString()}}async function BC(t){const{deviceToken:e,insforgeBaseUrl:n}=t,i={deviceToken:e},r=n||Co();$y(r)&&(i.insforgeBaseUrl=r.trim());const s=await fetch("/functions/tokentracker-local-sync",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(i)}),o=await s.json().catch(()=>({}));if(!s.ok){const c=typeof o.error=="string"?o.error:`HTTP ${s.status}`;throw new Error(c)}return o}async function RV(t){const e=_I();if(Date.now()-e<CV)return;const n=await t();if(!n)return;let i=oT();if(!i){const r=await OC(n);if(!r)return;lT(r),i=r}await BC({deviceToken:i.token,insforgeBaseUrl:Co()}),cT(Date.now()),await FC(n)}async function PV(t){const e=await t();if(!e)return;let n=oT();if(!n){const i=await OC(e);if(!i)return;lT(i),n=i}await BC({deviceToken:n.token,insforgeBaseUrl:Co()}),cT(Date.now()),await FC(e)}function kV(t){const e=t.replace(/\/+$/,"")||"/";return e==="/share"||e==="/share.html"||e.startsWith("/share/")}function LV(t){const e=t.replace(/\/+$/,"")||"/";return e==="/login"||e==="/landing"||kV(e)?!1:e==="/"||e==="/dashboard"||e.startsWith("/leaderboard")}function DV(){const t=zr(),e=Ro(),n=k.useRef(!1);k.useEffect(()=>{if(!sT()||!LV(t.pathname||"/")||!e.enabled||!e.signedIn||e.loading||!aT())return;let i=!1;const r=window.setTimeout(()=>{(async()=>{if(!(i||n.current)){n.current=!0;try{await RV(()=>e.getAccessToken())}catch(s){console.warn("[tokentracker] cloud usage sync:",s)}finally{n.current=!1}}})()},2500);return()=>{i=!0,window.clearTimeout(r)}},[t.pathname,e.enabled,e.signedIn,e.loading,e.getAccessToken])}function zC(){return typeof navigator>"u"?null:navigator.clipboard||null}function NV(){return typeof window>"u"?null:window.ClipboardItem||null}async function IV(t,{clipboard:e}={}){const n=e??zC();if(!n||typeof n.writeText!="function")return!1;try{return await n.writeText(t),!0}catch{return!1}}async function w$(t,{clipboard:e}={}){const n=e??zC(),i=NV();if(!t||!n||typeof n.write!="function"||!i)return!1;try{const r=t.type||"image/png",s=t.type&&t.type!==r?t.slice(0,t.size,r):t.type?t:t.slice(0,t.size,r),o=new i({[r]:s});return await n.write([o]),!0}catch{return!1}}function UV(){if(typeof window>"u")return!1;const t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||t==="::1"}function FV(){return UV()?"/":"/dashboard"}function OV({prefersReducedMotion:t,screenshotCapture:e}){return!(e||t)}function BV({repo:t="mm7894215/TokenTracker"}){const[e,n]=k.useState(null);return k.useEffect(()=>{if(typeof window>"u")return;const i=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,r=typeof document<"u"&&(document.documentElement?.classList.contains("screenshot-capture")||document.body?.classList.contains("screenshot-capture"));OV({prefersReducedMotion:i,screenshotCapture:r})&&fetch(`https://api.github.com/repos/${t}`).then(s=>s.json()).then(s=>{s&&typeof s.stargazers_count=="number"&&n(s.stargazers_count)}).catch(()=>{})},[t]),O.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:[O.jsx("svg",{height:"16",viewBox:"0 0 16 16",width:"16",className:"shrink-0 fill-oai-gray-700 dark:fill-oai-gray-300",children:O.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"})}),O.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 whitespace-nowrap",children:"Star"}),e!==null&&O.jsx("span",{className:"text-xs font-semibold text-oai-gray-900 dark:text-oai-white tabular-nums whitespace-nowrap",children:e})]})}const hs={usageSummary:"tokentracker-usage-summary",usageDaily:"tokentracker-usage-daily",usageHourly:"tokentracker-usage-hourly",usageMonthly:"tokentracker-usage-monthly",usageHeatmap:"tokentracker-usage-heatmap",usageModelBreakdown:"tokentracker-usage-model-breakdown",projectUsageSummary:"tokentracker-project-usage-summary",userStatus:"tokentracker-user-status",localSync:"tokentracker-local-sync",usageLimits:"tokentracker-usage-limits"};async function js(t,e,n){const i=new URL(`/functions/${t}`,window.location.origin);if(e)for(const[s,o]of Object.entries(e))o!=null&&o!==""&&i.searchParams.set(s,String(o));const r=await fetch(i.toString(),{headers:{Accept:"application/json"},cache:"no-store",...n});if(!r.ok){const s=new Error(`Request failed with HTTP ${r.status}`);throw s.status=r.status,s}return r.json()}function ko({timeZone:t,tzOffsetMinutes:e}={}){const n={},i=typeof t=="string"?t.trim():"";return i&&(n.tz=i),Number.isFinite(e)&&(n.tz_offset_minutes=String(Math.trunc(e))),n}function Lo({source:t,model:e}={}){const n={},i=typeof t=="string"?t.trim().toLowerCase():"";i&&(n.source=i);const r=typeof e=="string"?e.trim():"";return r&&(n.model=r),n}async function E$({from:t,to:e,source:n,model:i,timeZone:r,tzOffsetMinutes:s,rolling:o=!1,accessToken:c}={}){if(_r())return SV({from:t,to:e,seed:c,rolling:o});const u=ko({timeZone:r,tzOffsetMinutes:s}),f=Lo({source:n,model:i}),h=o?{rolling:"1"}:{};return js(hs.usageSummary,{from:t,to:e,...f,...u,...h})}async function M$({from:t,to:e,source:n,limit:i,timeZone:r,tzOffsetMinutes:s,accessToken:o}={}){if(_r())return EV({seed:o,limit:i});const c=ko({timeZone:r,tzOffsetMinutes:s}),f={...Lo({source:n}),...c};return t&&(f.from=t),e&&(f.to=e),i!=null&&(f.limit=String(i)),js(hs.projectUsageSummary,f)}async function ku(t,e={}){const n=Co();if(!n)throw new Error("InsForge base URL not configured");const i=n.replace(/\/$/,""),r=new URL(`${i}/functions/${t}`);if(e.params)for(const[u,f]of Object.entries(e.params))f!=null&&f!==""&&r.searchParams.set(u,String(f));const s={Accept:"application/json","Content-Type":"application/json"},o=Ph();o&&(s.apikey=o),e.accessToken&&(s.Authorization=`Bearer ${e.accessToken}`);const c=await fetch(r.toString(),{method:e.method||"GET",headers:s,...e.body!=null?{body:JSON.stringify(e.body)}:{}});if(!c.ok){const u=new Error(`Request failed with HTTP ${c.status}`);throw u.status=c.status,u}return c.json()}async function T$({accessToken:t,period:e,metric:n,limit:i,offset:r}={}){return _r()?IC({seed:t,period:e,metric:n,limit:i,offset:r}):ku("tokentracker-leaderboard",{accessToken:t,params:{period:e,limit:i,offset:r}})}async function zV({accessToken:t}={}){return ku("tokentracker-public-visibility",{accessToken:t,method:"GET"})}async function rg({accessToken:t,enabled:e,anonymous:n,display_name:i}={}){const r={};return e!==void 0&&(r.enabled=!!e),n!==void 0&&(r.anonymous=!!n),i!==void 0&&(r.display_name=String(i)),ku("tokentracker-public-visibility",{accessToken:t,method:"POST",body:r})}async function A$({accessToken:t,period:e}={}){return ku("tokentracker-leaderboard-refresh",{accessToken:t,method:"POST",body:e?{period:e}:{}})}async function C$({accessToken:t,userId:e,period:n}={}){if(_r()){const i=IC({seed:t,period:n,metric:"all",limit:250,offset:0}),s=(Array.isArray(i?.entries)?i.entries:[]).find(o=>o?.user_id===e)||null;return{period:i?.period??"week",from:i?.from??null,to:i?.to??null,generated_at:i?.generated_at??new Date().toISOString(),entry:s}}return ku("tokentracker-leaderboard-profile",{accessToken:t,params:{user_id:e,period:n}})}async function R$(t={}){if(_r()){const e=new Date().toISOString();return{user_id:"local-user",created_at:e,pro:{active:!1,sources:[],expires_at:null,partial:!1,as_of:e},subscriptions:{partial:!1,as_of:e,items:[]},install:{partial:!1,as_of:e,has_active_device_token:!1,has_active_device:!1,active_device_tokens:0,active_devices:0,latest_token_activity_at:null,latest_device_seen_at:null}}}return js(hs.userStatus)}async function P$({signal:t}={}){const e=await fetch(`/functions/${hs.localSync}`,{method:"POST",headers:{Accept:"application/json"},cache:"no-store",signal:t}),n=await e.json().catch(()=>({ok:!1,error:`Local sync request failed with HTTP ${e.status}`}));if(!e.ok||n?.ok===!1){const i=n?.error||n?.message||`Local sync request failed with HTTP ${e.status}`,r=new Error(i);throw r.status=e.status,r}return n}async function k$({from:t,to:e,source:n,timeZone:i,tzOffsetMinutes:r,accessToken:s}={}){if(_r())return AV({from:t,to:e,seed:s});const o=ko({timeZone:i,tzOffsetMinutes:r}),c=Lo({source:n});return js(hs.usageModelBreakdown,{from:t,to:e,...c,...o})}async function L$({from:t,to:e,source:n,model:i,timeZone:r,tzOffsetMinutes:s,accessToken:o}={}){if(_r())return _V({from:t,to:e,seed:o});const c=ko({timeZone:r,tzOffsetMinutes:s}),u=Lo({source:n,model:i});return js(hs.usageDaily,{from:t,to:e,...u,...c})}async function D$({day:t,source:e,model:n,timeZone:i,tzOffsetMinutes:r,accessToken:s}={}){if(_r())return xV({day:t,seed:s});const o=ko({timeZone:i,tzOffsetMinutes:r}),c=Lo({source:e,model:n}),u=t?{day:t,...c,...o}:{...c,...o};return js(hs.usageHourly,u)}async function N$({months:t,to:e,source:n,model:i,timeZone:r,tzOffsetMinutes:s,accessToken:o}={}){if(_r())return bV({months:t,to:e,seed:o});const c=ko({timeZone:r,tzOffsetMinutes:s}),u=Lo({source:n,model:i});return js(hs.usageMonthly,{...t?{months:String(t)}:{},...e?{to:e}:{},...u,...c})}async function I$(t={}){return js(hs.usageLimits)}async function U$({weeks:t,to:e,weekStartsOn:n,source:i,model:r,timeZone:s,tzOffsetMinutes:o,accessToken:c}={}){if(_r())return TV({weeks:t,to:e,weekStartsOn:n,seed:c});const u=ko({timeZone:s,tzOffsetMinutes:o}),f=Lo({source:i,model:r});return js(hs.usageHeatmap,{weeks:String(t),to:e,week_starts_on:n,...f,...u})}function VV(t){if(!t||typeof t!="object")return"";const e=t.user_metadata&&typeof t.user_metadata=="object"?t.user_metadata:{},n=t.profile&&typeof t.profile=="object"?t.profile:{},i=e.full_name||e.name||n.name||e.user_name||e.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof t.email=="string"&&t.email.includes("@")?t.email.split("@")[0].trim()||t.email.trim():typeof t.email=="string"?t.email.trim():""}function HV(t){return!t||typeof t!="object"?"":typeof t.email=="string"?t.email.trim():""}function GV(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:{},i=e.avatar_url||e.picture||n.avatar_url||t.avatar_url;return typeof i=="string"&&i.trim()?i.trim():null}function mE(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 jV({checked:t,onChange:e,disabled:n,ariaLabel:i}){return O.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":i,onClick:e,disabled:n,className:Si("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:O.jsx("span",{className:Si("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",t?"translate-x-[18px]":"translate-x-[3px]")})})}function sg({label:t,checked:e,onChange:n,disabled:i}){return O.jsxs("div",{className:"flex items-center justify-between py-2",children:[O.jsx("span",{className:"text-sm text-oai-gray-700 dark:text-oai-gray-300",children:t}),O.jsx(jV,{checked:e,onChange:n,disabled:i,ariaLabel:t})]})}function WV({className:t}){const{enabled:e,loading:n,signedIn:i,user:r,signOut:s,getAccessToken:o}=Ro(),{openLoginModal:c}=AT(),[u,f]=k.useState(!1),[h,p]=k.useState(()=>aT()),[m,v]=k.useState(!1),[_,w]=k.useState(!1),[y,x]=k.useState(!1),[M,A]=k.useState(!1),[T,D]=k.useState(!1),[I,U]=k.useState(null),[S,R]=k.useState(""),V=k.useRef(null),F=k.useRef(null),j=e&&i&&sT(),Z=k.useMemo(()=>VV(r),[r]),H=k.useMemo(()=>HV(r),[r]),q=k.useMemo(()=>GV(r),[r]);k.useEffect(()=>{if(!u)return;const ve=Ce=>{F.current&&!F.current.contains(Ce.target)&&f(!1)};return document.addEventListener("mousedown",ve),()=>document.removeEventListener("mousedown",ve)},[u]),k.useEffect(()=>{if(!u||!i)return;let ve=!0;return x(!0),(async()=>{try{const Ce=await Hd({getAccessToken:o});if(!ve||!Ce)return;const we=await zV({accessToken:Ce});if(!ve)return;v(!!we?.enabled),w(!!we?.anonymous),we?.display_name&&U(we.display_name)}catch{}finally{ve&&x(!1)}})(),()=>{ve=!1}},[u,i,o]);const J=k.useCallback(async()=>{f(!1),await s()},[s]),Q=k.useCallback(async()=>{const ve=!h;if(vI(ve),p(ve),ve)try{await PV(()=>o())}catch(Ce){console.warn("[tokentracker] cloud sync:",Ce)}},[h,o]),W=k.useCallback(async()=>{if(!M){A(!0);try{const ve=await Hd({getAccessToken:o});if(!ve)return;const Ce=!m;await rg({accessToken:ve,enabled:Ce}),v(Ce)}catch{}finally{A(!1)}}},[m,M,o]),X=k.useCallback(()=>{f(!1),R(I||Z),D(!0),setTimeout(()=>V.current?.focus(),50)},[I,Z]),K=k.useCallback(()=>{D(!1),R("")},[]),B=k.useCallback(async()=>{if(M)return;const ve=S.trim().slice(0,50);if(ve){A(!0);try{const Ce=await Hd({getAccessToken:o});if(!Ce)return;await rg({accessToken:Ce,display_name:ve}),U(ve),D(!1)}catch{}finally{A(!1)}}},[S,M,o]),ie=k.useCallback(async()=>{if(!M){A(!0);try{const ve=await Hd({getAccessToken:o});if(!ve)return;const Ce=!_;await rg({accessToken:ve,anonymous:Ce}),w(Ce)}catch{}finally{A(!1)}}},[_,M,o]);return e?n?O.jsx("div",{className:Si("h-9 w-9 shrink-0 rounded-full bg-oai-gray-200 dark:bg-oai-gray-800 animate-pulse",t),"aria-hidden":!0}):i?O.jsxs("div",{ref:F,className:Si("relative flex shrink-0 items-center",t),children:[O.jsxs("button",{type:"button",onClick:()=>f(ve=>!ve),className:"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-expanded":u,"aria-haspopup":"menu",children:[q?O.jsx("img",{src:q,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",referrerPolicy:"no-referrer"}):O.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:mE(Z)}),O.jsx("span",{className:"hidden sm:inline truncate text-sm font-medium text-oai-gray-900 dark:text-oai-gray-200 max-w-[120px]",children:I||Z})]}),O.jsx(I0,{children:T&&O.jsx(Is.div,{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/40",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},onClick:K,children:O.jsxs(Is.div,{className:"w-[340px] rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-2xl p-5",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15},onClick:ve=>ve.stopPropagation(),children:[O.jsx("h3",{className:"text-base font-semibold text-oai-black dark:text-white mb-3",children:"Edit Display Name"}),O.jsx("input",{ref:V,type:"text",value:S,onChange:ve=>R(ve.target.value),onKeyDown:ve=>{ve.key==="Enter"&&B(),ve.key==="Escape"&&K()},maxLength:50,className:"w-full rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-transparent px-3 py-2 text-sm text-oai-black dark:text-white outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-oai-brand-500",placeholder:"Display name"}),O.jsx("p",{className:"mt-1.5 text-xs text-oai-gray-400",children:"This name will be shown on the leaderboard."}),O.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[O.jsx("button",{type:"button",onClick:K,className:"rounded-md px-3 py-1.5 text-sm text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300 transition-colors",children:"Cancel"}),O.jsx("button",{type:"button",onClick:B,disabled:M||!S.trim(),className:"rounded-md bg-oai-brand-500 px-4 py-1.5 text-sm font-medium text-white hover:bg-oai-brand-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:M?"Saving...":"Save"})]})]})})}),O.jsx(I0,{children:u&&O.jsxs(Is.div,{className:"absolute right-0 top-full z-[60] mt-2 w-[280px] rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-2xl overflow-hidden",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:[O.jsxs("div",{className:"px-4 py-3 border-b border-oai-gray-200 dark:border-oai-gray-800 flex items-center gap-3",children:[q?O.jsx("img",{src:q,alt:"",width:36,height:36,className:"h-9 w-9 rounded-full object-cover ring-1 ring-oai-gray-200 dark:ring-oai-gray-700",referrerPolicy:"no-referrer"}):O.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-oai-brand-600 text-xs font-semibold text-white",children:mE(I||Z)}),O.jsxs("div",{className:"min-w-0",children:[O.jsx("div",{className:"text-sm font-medium text-oai-black dark:text-white truncate",children:I||Z}),H&&O.jsx("div",{className:"text-xs text-oai-gray-500 truncate",children:H})]})]}),O.jsxs("div",{className:"px-4 py-2 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[j&&O.jsx(sg,{label:"Cloud Sync",checked:h,onChange:Q}),O.jsx(sg,{label:"Public Profile",checked:m,onChange:W,disabled:y||M}),O.jsx(sg,{label:"Anonymous",checked:_,onChange:ie,disabled:y||M})]}),O.jsxs("div",{children:[O.jsxs("button",{type:"button",onClick:X,className:"flex w-full items-center gap-2 px-4 py-2.5 text-left text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors",children:[O.jsx(Q5,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Edit Name"]}),O.jsxs("button",{type:"button",onClick:J,className:"flex w-full items-center gap-2 px-4 py-2.5 text-left text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors",children:[O.jsx(Y5,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Sign Out"]})]})]})})]}):O.jsx("button",{type:"button",onClick:c,className:Si("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":qt("header.auth.sign_in_aria"),children:"Sign In"}):null}const Xy="183",$V=0,gE=1,XV=2,Bf=1,qV=2,Jc=3,La=0,Gi=1,Ls=2,Us=0,vo=1,vE=2,yE=3,_E=4,YV=5,so=100,KV=101,ZV=102,JV=103,QV=104,eH=200,tH=201,nH=202,iH=203,z0=204,V0=205,rH=206,sH=207,aH=208,oH=209,lH=210,cH=211,uH=212,dH=213,fH=214,H0=0,G0=1,j0=2,zl=3,W0=4,$0=5,X0=6,q0=7,VC=0,hH=1,pH=2,ns=0,HC=1,GC=2,jC=3,WC=4,$C=5,XC=6,qC=7,YC=300,Eo=301,Vl=302,ag=303,og=304,Bh=306,Y0=1e3,Ds=1001,K0=1002,pi=1003,mH=1004,Kd=1005,wi=1006,lg=1007,fo=1008,fr=1009,KC=1010,ZC=1011,vu=1012,qy=1013,cs=1014,Jr=1015,zs=1016,Yy=1017,Ky=1018,yu=1020,JC=35902,QC=35899,eR=1021,tR=1022,Ir=1023,Vs=1026,ho=1027,nR=1028,Zy=1029,Hl=1030,Jy=1031,Qy=1033,zf=33776,Vf=33777,Hf=33778,Gf=33779,Z0=35840,J0=35841,Q0=35842,ev=35843,tv=36196,nv=37492,iv=37496,rv=37488,sv=37489,av=37490,ov=37491,lv=37808,cv=37809,uv=37810,dv=37811,fv=37812,hv=37813,pv=37814,mv=37815,gv=37816,vv=37817,yv=37818,_v=37819,xv=37820,bv=37821,Sv=36492,wv=36494,Ev=36495,Mv=36283,Tv=36284,Av=36285,Cv=36286,gH=3200,vH=0,yH=1,Ea="",ur="srgb",Mo="srgb-linear",vh="linear",wn="srgb",al=7680,xE=519,_H=512,xH=513,bH=514,e_=515,SH=516,wH=517,t_=518,EH=519,bE=35044,SE="300 es",Qr=2e3,yh=2001;function MH(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function _h(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function TH(){const t=_h("canvas");return t.style.display="block",t}const wE={};function EE(...t){const e="THREE."+t.shift();console.log(e,...t)}function iR(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 Ht(...t){t=iR(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...t)}}function _n(...t){t=iR(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.error(n.getError(e)):console.error(e,...t)}}function xh(...t){const e=t.join(" ");e in wE||(wE[e]=!0,Ht(...t))}function AH(t,e,n){return new Promise(function(i,r){function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:i()}}setTimeout(s,n)})}const CH={[H0]:G0,[j0]:X0,[W0]:q0,[zl]:$0,[G0]:H0,[X0]:j0,[q0]:W0,[$0]:zl};class Zl{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(n)===-1&&i[e].push(n)}hasEventListener(e,n){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(n)!==-1}removeEventListener(e,n){const i=this._listeners;if(i===void 0)return;const r=i[e];if(r!==void 0){const s=r.indexOf(n);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const i=n[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}}const _i=["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"],cg=Math.PI/180,Rv=180/Math.PI;function Lu(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(_i[t&255]+_i[t>>8&255]+_i[t>>16&255]+_i[t>>24&255]+"-"+_i[e&255]+_i[e>>8&255]+"-"+_i[e>>16&15|64]+_i[e>>24&255]+"-"+_i[n&63|128]+_i[n>>8&255]+"-"+_i[n>>16&255]+_i[n>>24&255]+_i[i&255]+_i[i>>8&255]+_i[i>>16&255]+_i[i>>24&255]).toLowerCase()}function ln(t,e,n){return Math.max(e,Math.min(n,t))}function RH(t,e){return(t%e+e)%e}function ug(t,e,n){return(1-n)*t+n*e}function Bc(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 Hi(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 bn{constructor(e=0,n=0){bn.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,i=this.y,r=e.elements;return this.x=r[0]*n+r[3]*i+r[6],this.y=r[1]*n+r[4]*i+r[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=ln(this.x,e.x,n.x),this.y=ln(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=ln(this.x,e,n),this.y=ln(this.y,e,n),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ln(i,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 i=this.dot(e)/n;return Math.acos(ln(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,i=this.y-e.y;return n*n+i*i}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,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,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 i=Math.cos(n),r=Math.sin(n),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Jl{constructor(e=0,n=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=i,this._w=r}static slerpFlat(e,n,i,r,s,o,c){let u=i[r+0],f=i[r+1],h=i[r+2],p=i[r+3],m=s[o+0],v=s[o+1],_=s[o+2],w=s[o+3];if(p!==w||u!==m||f!==v||h!==_){let y=u*m+f*v+h*_+p*w;y<0&&(m=-m,v=-v,_=-_,w=-w,y=-y);let x=1-c;if(y<.9995){const M=Math.acos(y),A=Math.sin(M);x=Math.sin(x*M)/A,c=Math.sin(c*M)/A,u=u*x+m*c,f=f*x+v*c,h=h*x+_*c,p=p*x+w*c}else{u=u*x+m*c,f=f*x+v*c,h=h*x+_*c,p=p*x+w*c;const M=1/Math.sqrt(u*u+f*f+h*h+p*p);u*=M,f*=M,h*=M,p*=M}}e[n]=u,e[n+1]=f,e[n+2]=h,e[n+3]=p}static multiplyQuaternionsFlat(e,n,i,r,s,o){const c=i[r],u=i[r+1],f=i[r+2],h=i[r+3],p=s[o],m=s[o+1],v=s[o+2],_=s[o+3];return e[n]=c*_+h*p+u*v-f*m,e[n+1]=u*_+h*m+f*p-c*v,e[n+2]=f*_+h*v+c*m-u*p,e[n+3]=h*_-c*p-u*m-f*v,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,i,r){return this._x=e,this._y=n,this._z=i,this._w=r,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 i=e._x,r=e._y,s=e._z,o=e._order,c=Math.cos,u=Math.sin,f=c(i/2),h=c(r/2),p=c(s/2),m=u(i/2),v=u(r/2),_=u(s/2);switch(o){case"XYZ":this._x=m*h*p+f*v*_,this._y=f*v*p-m*h*_,this._z=f*h*_+m*v*p,this._w=f*h*p-m*v*_;break;case"YXZ":this._x=m*h*p+f*v*_,this._y=f*v*p-m*h*_,this._z=f*h*_-m*v*p,this._w=f*h*p+m*v*_;break;case"ZXY":this._x=m*h*p-f*v*_,this._y=f*v*p+m*h*_,this._z=f*h*_+m*v*p,this._w=f*h*p-m*v*_;break;case"ZYX":this._x=m*h*p-f*v*_,this._y=f*v*p+m*h*_,this._z=f*h*_-m*v*p,this._w=f*h*p+m*v*_;break;case"YZX":this._x=m*h*p+f*v*_,this._y=f*v*p+m*h*_,this._z=f*h*_-m*v*p,this._w=f*h*p-m*v*_;break;case"XZY":this._x=m*h*p-f*v*_,this._y=f*v*p-m*h*_,this._z=f*h*_+m*v*p,this._w=f*h*p+m*v*_;break;default:Ht("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const i=n/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,i=n[0],r=n[4],s=n[8],o=n[1],c=n[5],u=n[9],f=n[2],h=n[6],p=n[10],m=i+c+p;if(m>0){const v=.5/Math.sqrt(m+1);this._w=.25/v,this._x=(h-u)*v,this._y=(s-f)*v,this._z=(o-r)*v}else if(i>c&&i>p){const v=2*Math.sqrt(1+i-c-p);this._w=(h-u)/v,this._x=.25*v,this._y=(r+o)/v,this._z=(s+f)/v}else if(c>p){const v=2*Math.sqrt(1+c-i-p);this._w=(s-f)/v,this._x=(r+o)/v,this._y=.25*v,this._z=(u+h)/v}else{const v=2*Math.sqrt(1+p-i-c);this._w=(o-r)/v,this._x=(s+f)/v,this._y=(u+h)/v,this._z=.25*v}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let i=e.dot(n)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(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=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ln(this.dot(e),-1,1)))}rotateTowards(e,n){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,n/i);return this.slerp(e,r),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 i=e._x,r=e._y,s=e._z,o=e._w,c=n._x,u=n._y,f=n._z,h=n._w;return this._x=i*h+o*c+r*f-s*u,this._y=r*h+o*u+s*c-i*f,this._z=s*h+o*f+i*u-r*c,this._w=o*h-i*c-r*u-s*f,this._onChangeCallback(),this}slerp(e,n){let i=e._x,r=e._y,s=e._z,o=e._w,c=this.dot(e);c<0&&(i=-i,r=-r,s=-s,o=-o,c=-c);let u=1-n;if(c<.9995){const f=Math.acos(c),h=Math.sin(f);u=Math.sin(u*f)/h,n=Math.sin(n*f)/h,this._x=this._x*u+i*n,this._y=this._y*u+r*n,this._z=this._z*u+s*n,this._w=this._w*u+o*n,this._onChangeCallback()}else this._x=this._x*u+i*n,this._y=this._y*u+r*n,this._z=this._z*u+s*n,this._w=this._w*u+o*n,this.normalize();return this}slerpQuaternions(e,n,i){return this.copy(e).slerp(n,i)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(n),s*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 me{constructor(e=0,n=0,i=0){me.prototype.isVector3=!0,this.x=e,this.y=n,this.z=i}set(e,n,i){return i===void 0&&(i=this.z),this.x=e,this.y=n,this.z=i,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(ME.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(ME.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*n+s[3]*i+s[6]*r,this.y=s[1]*n+s[4]*i+s[7]*r,this.z=s[2]*n+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*n+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*n+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*n+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*n+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){const n=this.x,i=this.y,r=this.z,s=e.x,o=e.y,c=e.z,u=e.w,f=2*(o*r-c*i),h=2*(c*n-s*r),p=2*(s*i-o*n);return this.x=n+u*f+o*p-c*h,this.y=i+u*h+c*f-s*p,this.z=r+u*p+s*h-o*f,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,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*n+s[4]*i+s[8]*r,this.y=s[1]*n+s[5]*i+s[9]*r,this.z=s[2]*n+s[6]*i+s[10]*r,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=ln(this.x,e.x,n.x),this.y=ln(this.y,e.y,n.y),this.z=ln(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=ln(this.x,e,n),this.y=ln(this.y,e,n),this.z=ln(this.z,e,n),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ln(i,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,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this.z=e.z+(n.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const i=e.x,r=e.y,s=e.z,o=n.x,c=n.y,u=n.z;return this.x=r*u-s*c,this.y=s*o-i*u,this.z=i*c-r*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const i=e.dot(this)/n;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return dg.copy(this).projectOnVector(e),this.sub(dg)}reflect(e){return this.sub(dg.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 i=this.dot(e)/n;return Math.acos(ln(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return n*n+i*i+r*r}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,i){const r=Math.sin(n)*e;return this.x=r*Math.sin(i),this.y=Math.cos(n)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,i){return this.x=e*Math.sin(n),this.y=i,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(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=i,this.z=r,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,i=Math.sqrt(1-n*n);return this.x=i*Math.cos(e),this.y=n,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const dg=new me,ME=new Jl;class jt{constructor(e,n,i,r,s,o,c,u,f){jt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,i,r,s,o,c,u,f)}set(e,n,i,r,s,o,c,u,f){const h=this.elements;return h[0]=e,h[1]=r,h[2]=c,h[3]=n,h[4]=s,h[5]=u,h[6]=i,h[7]=o,h[8]=f,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],this}extractBasis(e,n,i){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),i.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 i=e.elements,r=n.elements,s=this.elements,o=i[0],c=i[3],u=i[6],f=i[1],h=i[4],p=i[7],m=i[2],v=i[5],_=i[8],w=r[0],y=r[3],x=r[6],M=r[1],A=r[4],T=r[7],D=r[2],I=r[5],U=r[8];return s[0]=o*w+c*M+u*D,s[3]=o*y+c*A+u*I,s[6]=o*x+c*T+u*U,s[1]=f*w+h*M+p*D,s[4]=f*y+h*A+p*I,s[7]=f*x+h*T+p*U,s[2]=m*w+v*M+_*D,s[5]=m*y+v*A+_*I,s[8]=m*x+v*T+_*U,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],i=e[1],r=e[2],s=e[3],o=e[4],c=e[5],u=e[6],f=e[7],h=e[8];return n*o*h-n*c*f-i*s*h+i*c*u+r*s*f-r*o*u}invert(){const e=this.elements,n=e[0],i=e[1],r=e[2],s=e[3],o=e[4],c=e[5],u=e[6],f=e[7],h=e[8],p=h*o-c*f,m=c*u-h*s,v=f*s-o*u,_=n*p+i*m+r*v;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const w=1/_;return e[0]=p*w,e[1]=(r*f-h*i)*w,e[2]=(c*i-r*o)*w,e[3]=m*w,e[4]=(h*n-r*u)*w,e[5]=(r*s-c*n)*w,e[6]=v*w,e[7]=(i*u-f*n)*w,e[8]=(o*n-i*s)*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,i,r,s,o,c){const u=Math.cos(s),f=Math.sin(s);return this.set(i*u,i*f,-i*(u*o+f*c)+o+e,-r*f,r*u,-r*(-f*o+u*c)+c+n,0,0,1),this}scale(e,n){return this.premultiply(fg.makeScale(e,n)),this}rotate(e){return this.premultiply(fg.makeRotation(-e)),this}translate(e,n){return this.premultiply(fg.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),i=Math.sin(e);return this.set(n,-i,0,i,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,i=e.elements;for(let r=0;r<9;r++)if(n[r]!==i[r])return!1;return!0}fromArray(e,n=0){for(let i=0;i<9;i++)this.elements[i]=e[i+n];return this}toArray(e=[],n=0){const i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const fg=new jt,TE=new jt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),AE=new jt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function PH(){const t={enabled:!0,workingColorSpace:Mo,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===wn&&(r.r=Fs(r.r),r.g=Fs(r.g),r.b=Fs(r.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===wn&&(r.r=Ll(r.r),r.g=Ll(r.g),r.b=Ll(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Ea?vh:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return xh("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return xh("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[Mo]:{primaries:e,whitePoint:i,transfer:vh,toXYZ:TE,fromXYZ:AE,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:ur},outputColorSpaceConfig:{drawingBufferColorSpace:ur}},[ur]:{primaries:e,whitePoint:i,transfer:wn,toXYZ:TE,fromXYZ:AE,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:ur}}}),t}const fn=PH();function Fs(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Ll(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let ol;class kH{static getDataURL(e,n="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{ol===void 0&&(ol=_h("canvas")),ol.width=e.width,ol.height=e.height;const r=ol.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=ol}return i.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=_h("canvas");n.width=e.width,n.height=e.height;const i=n.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=Fs(s[o]/255)*255;return i.putImageData(r,0,0),n}else if(e.data){const n=e.data.slice(0);for(let i=0;i<n.length;i++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[i]=Math.floor(Fs(n[i]/255)*255):n[i]=Fs(n[i]);return{data:n,width:e.width,height:e.height}}else return Ht("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let LH=0;class n_{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:LH++}),this.uuid=Lu(),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 i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,c=r.length;o<c;o++)r[o].isDataTexture?s.push(hg(r[o].image)):s.push(hg(r[o]))}else s=hg(r);i.url=s}return n||(e.images[this.uuid]=i),i}}function hg(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?kH.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Ht("Texture: Unable to serialize Texture."),{})}let DH=0;const pg=new me;class Li extends Zl{constructor(e=Li.DEFAULT_IMAGE,n=Li.DEFAULT_MAPPING,i=Ds,r=Ds,s=wi,o=fo,c=Ir,u=fr,f=Li.DEFAULT_ANISOTROPY,h=Ea){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:DH++}),this.uuid=Lu(),this.name="",this.source=new n_(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=f,this.format=c,this.internalFormat=null,this.type=u,this.offset=new bn(0,0),this.repeat=new bn(1,1),this.center=new bn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new jt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,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(pg).x}get height(){return this.source.getSize(pg).y}get depth(){return this.source.getSize(pg).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 i=e[n];if(i===void 0){Ht(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const r=this[n];if(r===void 0){Ht(`Texture.setValues(): property '${n}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[n]=i}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={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&&(i.userData=this.userData),n||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==YC)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Y0:e.x=e.x-Math.floor(e.x);break;case Ds:e.x=e.x<0?0:1;break;case K0: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 Y0:e.y=e.y-Math.floor(e.y);break;case Ds:e.y=e.y<0?0:1;break;case K0: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++}}Li.DEFAULT_IMAGE=null;Li.DEFAULT_MAPPING=YC;Li.DEFAULT_ANISOTROPY=1;class zn{constructor(e=0,n=0,i=0,r=1){zn.prototype.isVector4=!0,this.x=e,this.y=n,this.z=i,this.w=r}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,i,r){return this.x=e,this.y=n,this.z=i,this.w=r,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,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*n+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*n+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*n+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*n+o[7]*i+o[11]*r+o[15]*s,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,i,r,s;const u=e.elements,f=u[0],h=u[4],p=u[8],m=u[1],v=u[5],_=u[9],w=u[2],y=u[6],x=u[10];if(Math.abs(h-m)<.01&&Math.abs(p-w)<.01&&Math.abs(_-y)<.01){if(Math.abs(h+m)<.1&&Math.abs(p+w)<.1&&Math.abs(_+y)<.1&&Math.abs(f+v+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const A=(f+1)/2,T=(v+1)/2,D=(x+1)/2,I=(h+m)/4,U=(p+w)/4,S=(_+y)/4;return A>T&&A>D?A<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(A),r=I/i,s=U/i):T>D?T<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(T),i=I/r,s=S/r):D<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(D),i=U/s,r=S/s),this.set(i,r,s,n),this}let M=Math.sqrt((y-_)*(y-_)+(p-w)*(p-w)+(m-h)*(m-h));return Math.abs(M)<.001&&(M=1),this.x=(y-_)/M,this.y=(p-w)/M,this.z=(m-h)/M,this.w=Math.acos((f+v+x-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=ln(this.x,e.x,n.x),this.y=ln(this.y,e.y,n.y),this.z=ln(this.z,e.z,n.z),this.w=ln(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=ln(this.x,e,n),this.y=ln(this.y,e,n),this.z=ln(this.z,e,n),this.w=ln(this.w,e,n),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(ln(i,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,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this.z=e.z+(n.z-e.z)*i,this.w=e.w+(n.w-e.w)*i,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 NH extends Zl{constructor(e=1,n=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:wi,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=i.depth,this.scissor=new zn(0,0,e,n),this.scissorTest=!1,this.viewport=new zn(0,0,e,n),this.textures=[];const r={width:e,height:n,depth:i.depth},s=new Li(r),o=i.count;for(let c=0;c<o;c++)this.textures[c]=s.clone(),this.textures[c].isRenderTargetTexture=!0,this.textures[c].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const n={minFilter:wi,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 i=0;i<this.textures.length;i++)this.textures[i].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,i=1){if(this.width!==e||this.height!==n||this.depth!==i){this.width=e,this.height=n,this.depth=i;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=n,this.textures[r].image.depth=i,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].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,i=e.textures.length;n<i;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const r=Object.assign({},e.textures[n].image);this.textures[n].source=new n_(r)}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 is extends NH{constructor(e=1,n=1,i={}){super(e,n,i),this.isWebGLRenderTarget=!0}}class rR extends Li{constructor(e=null,n=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:i,depth:r},this.magFilter=pi,this.minFilter=pi,this.wrapR=Ds,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class IH extends Li{constructor(e=null,n=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:i,depth:r},this.magFilter=pi,this.minFilter=pi,this.wrapR=Ds,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Yn{constructor(e,n,i,r,s,o,c,u,f,h,p,m,v,_,w,y){Yn.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,i,r,s,o,c,u,f,h,p,m,v,_,w,y)}set(e,n,i,r,s,o,c,u,f,h,p,m,v,_,w,y){const x=this.elements;return x[0]=e,x[4]=n,x[8]=i,x[12]=r,x[1]=s,x[5]=o,x[9]=c,x[13]=u,x[2]=f,x[6]=h,x[10]=p,x[14]=m,x[3]=v,x[7]=_,x[11]=w,x[15]=y,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 Yn().fromArray(this.elements)}copy(e){const n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],n[9]=i[9],n[10]=i[10],n[11]=i[11],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15],this}copyPosition(e){const n=this.elements,i=e.elements;return n[12]=i[12],n[13]=i[13],n[14]=i[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,i){return this.determinant()===0?(e.set(1,0,0),n.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,n,i){return this.set(e.x,n.x,i.x,0,e.y,n.y,i.y,0,e.z,n.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const n=this.elements,i=e.elements,r=1/ll.setFromMatrixColumn(e,0).length(),s=1/ll.setFromMatrixColumn(e,1).length(),o=1/ll.setFromMatrixColumn(e,2).length();return n[0]=i[0]*r,n[1]=i[1]*r,n[2]=i[2]*r,n[3]=0,n[4]=i[4]*s,n[5]=i[5]*s,n[6]=i[6]*s,n[7]=0,n[8]=i[8]*o,n[9]=i[9]*o,n[10]=i[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),c=Math.sin(i),u=Math.cos(r),f=Math.sin(r),h=Math.cos(s),p=Math.sin(s);if(e.order==="XYZ"){const m=o*h,v=o*p,_=c*h,w=c*p;n[0]=u*h,n[4]=-u*p,n[8]=f,n[1]=v+_*f,n[5]=m-w*f,n[9]=-c*u,n[2]=w-m*f,n[6]=_+v*f,n[10]=o*u}else if(e.order==="YXZ"){const m=u*h,v=u*p,_=f*h,w=f*p;n[0]=m+w*c,n[4]=_*c-v,n[8]=o*f,n[1]=o*p,n[5]=o*h,n[9]=-c,n[2]=v*c-_,n[6]=w+m*c,n[10]=o*u}else if(e.order==="ZXY"){const m=u*h,v=u*p,_=f*h,w=f*p;n[0]=m-w*c,n[4]=-o*p,n[8]=_+v*c,n[1]=v+_*c,n[5]=o*h,n[9]=w-m*c,n[2]=-o*f,n[6]=c,n[10]=o*u}else if(e.order==="ZYX"){const m=o*h,v=o*p,_=c*h,w=c*p;n[0]=u*h,n[4]=_*f-v,n[8]=m*f+w,n[1]=u*p,n[5]=w*f+m,n[9]=v*f-_,n[2]=-f,n[6]=c*u,n[10]=o*u}else if(e.order==="YZX"){const m=o*u,v=o*f,_=c*u,w=c*f;n[0]=u*h,n[4]=w-m*p,n[8]=_*p+v,n[1]=p,n[5]=o*h,n[9]=-c*h,n[2]=-f*h,n[6]=v*p+_,n[10]=m-w*p}else if(e.order==="XZY"){const m=o*u,v=o*f,_=c*u,w=c*f;n[0]=u*h,n[4]=-p,n[8]=f*h,n[1]=m*p+w,n[5]=o*h,n[9]=v*p-_,n[2]=_*p-v,n[6]=c*h,n[10]=w*p+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(UH,e,FH)}lookAt(e,n,i){const r=this.elements;return Ki.subVectors(e,n),Ki.lengthSq()===0&&(Ki.z=1),Ki.normalize(),pa.crossVectors(i,Ki),pa.lengthSq()===0&&(Math.abs(i.z)===1?Ki.x+=1e-4:Ki.z+=1e-4,Ki.normalize(),pa.crossVectors(i,Ki)),pa.normalize(),Zd.crossVectors(Ki,pa),r[0]=pa.x,r[4]=Zd.x,r[8]=Ki.x,r[1]=pa.y,r[5]=Zd.y,r[9]=Ki.y,r[2]=pa.z,r[6]=Zd.z,r[10]=Ki.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const i=e.elements,r=n.elements,s=this.elements,o=i[0],c=i[4],u=i[8],f=i[12],h=i[1],p=i[5],m=i[9],v=i[13],_=i[2],w=i[6],y=i[10],x=i[14],M=i[3],A=i[7],T=i[11],D=i[15],I=r[0],U=r[4],S=r[8],R=r[12],V=r[1],F=r[5],j=r[9],Z=r[13],H=r[2],q=r[6],J=r[10],Q=r[14],W=r[3],X=r[7],K=r[11],B=r[15];return s[0]=o*I+c*V+u*H+f*W,s[4]=o*U+c*F+u*q+f*X,s[8]=o*S+c*j+u*J+f*K,s[12]=o*R+c*Z+u*Q+f*B,s[1]=h*I+p*V+m*H+v*W,s[5]=h*U+p*F+m*q+v*X,s[9]=h*S+p*j+m*J+v*K,s[13]=h*R+p*Z+m*Q+v*B,s[2]=_*I+w*V+y*H+x*W,s[6]=_*U+w*F+y*q+x*X,s[10]=_*S+w*j+y*J+x*K,s[14]=_*R+w*Z+y*Q+x*B,s[3]=M*I+A*V+T*H+D*W,s[7]=M*U+A*F+T*q+D*X,s[11]=M*S+A*j+T*J+D*K,s[15]=M*R+A*Z+T*Q+D*B,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],i=e[4],r=e[8],s=e[12],o=e[1],c=e[5],u=e[9],f=e[13],h=e[2],p=e[6],m=e[10],v=e[14],_=e[3],w=e[7],y=e[11],x=e[15],M=u*v-f*m,A=c*v-f*p,T=c*m-u*p,D=o*v-f*h,I=o*m-u*h,U=o*p-c*h;return n*(w*M-y*A+x*T)-i*(_*M-y*D+x*I)+r*(_*A-w*D+x*U)-s*(_*T-w*I+y*U)}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,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=n,r[14]=i),this}invert(){const e=this.elements,n=e[0],i=e[1],r=e[2],s=e[3],o=e[4],c=e[5],u=e[6],f=e[7],h=e[8],p=e[9],m=e[10],v=e[11],_=e[12],w=e[13],y=e[14],x=e[15],M=n*c-i*o,A=n*u-r*o,T=n*f-s*o,D=i*u-r*c,I=i*f-s*c,U=r*f-s*u,S=h*w-p*_,R=h*y-m*_,V=h*x-v*_,F=p*y-m*w,j=p*x-v*w,Z=m*x-v*y,H=M*Z-A*j+T*F+D*V-I*R+U*S;if(H===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const q=1/H;return e[0]=(c*Z-u*j+f*F)*q,e[1]=(r*j-i*Z-s*F)*q,e[2]=(w*U-y*I+x*D)*q,e[3]=(m*I-p*U-v*D)*q,e[4]=(u*V-o*Z-f*R)*q,e[5]=(n*Z-r*V+s*R)*q,e[6]=(y*T-_*U-x*A)*q,e[7]=(h*U-m*T+v*A)*q,e[8]=(o*j-c*V+f*S)*q,e[9]=(i*V-n*j-s*S)*q,e[10]=(_*I-w*T+x*M)*q,e[11]=(p*T-h*I-v*M)*q,e[12]=(c*R-o*F-u*S)*q,e[13]=(n*F-i*R+r*S)*q,e[14]=(w*A-_*D-y*M)*q,e[15]=(h*D-p*A+m*M)*q,this}scale(e){const n=this.elements,i=e.x,r=e.y,s=e.z;return n[0]*=i,n[4]*=r,n[8]*=s,n[1]*=i,n[5]*=r,n[9]*=s,n[2]*=i,n[6]*=r,n[10]*=s,n[3]*=i,n[7]*=r,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,i,r))}makeTranslation(e,n,i){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,i,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,n,-i,0,0,i,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),i=Math.sin(e);return this.set(n,0,i,0,0,1,0,0,-i,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),i=Math.sin(e);return this.set(n,-i,0,0,i,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const i=Math.cos(n),r=Math.sin(n),s=1-i,o=e.x,c=e.y,u=e.z,f=s*o,h=s*c;return this.set(f*o+i,f*c-r*u,f*u+r*c,0,f*c+r*u,h*c+i,h*u-r*o,0,f*u-r*c,h*u+r*o,s*u*u+i,0,0,0,0,1),this}makeScale(e,n,i){return this.set(e,0,0,0,0,n,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,n,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,n,r,1,0,0,0,0,1),this}compose(e,n,i){const r=this.elements,s=n._x,o=n._y,c=n._z,u=n._w,f=s+s,h=o+o,p=c+c,m=s*f,v=s*h,_=s*p,w=o*h,y=o*p,x=c*p,M=u*f,A=u*h,T=u*p,D=i.x,I=i.y,U=i.z;return r[0]=(1-(w+x))*D,r[1]=(v+T)*D,r[2]=(_-A)*D,r[3]=0,r[4]=(v-T)*I,r[5]=(1-(m+x))*I,r[6]=(y+M)*I,r[7]=0,r[8]=(_+A)*U,r[9]=(y-M)*U,r[10]=(1-(m+w))*U,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,n,i){const r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];const s=this.determinant();if(s===0)return i.set(1,1,1),n.identity(),this;let o=ll.set(r[0],r[1],r[2]).length();const c=ll.set(r[4],r[5],r[6]).length(),u=ll.set(r[8],r[9],r[10]).length();s<0&&(o=-o),Rr.copy(this);const f=1/o,h=1/c,p=1/u;return Rr.elements[0]*=f,Rr.elements[1]*=f,Rr.elements[2]*=f,Rr.elements[4]*=h,Rr.elements[5]*=h,Rr.elements[6]*=h,Rr.elements[8]*=p,Rr.elements[9]*=p,Rr.elements[10]*=p,n.setFromRotationMatrix(Rr),i.x=o,i.y=c,i.z=u,this}makePerspective(e,n,i,r,s,o,c=Qr,u=!1){const f=this.elements,h=2*s/(n-e),p=2*s/(i-r),m=(n+e)/(n-e),v=(i+r)/(i-r);let _,w;if(u)_=s/(o-s),w=o*s/(o-s);else if(c===Qr)_=-(o+s)/(o-s),w=-2*o*s/(o-s);else if(c===yh)_=-o/(o-s),w=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+c);return f[0]=h,f[4]=0,f[8]=m,f[12]=0,f[1]=0,f[5]=p,f[9]=v,f[13]=0,f[2]=0,f[6]=0,f[10]=_,f[14]=w,f[3]=0,f[7]=0,f[11]=-1,f[15]=0,this}makeOrthographic(e,n,i,r,s,o,c=Qr,u=!1){const f=this.elements,h=2/(n-e),p=2/(i-r),m=-(n+e)/(n-e),v=-(i+r)/(i-r);let _,w;if(u)_=1/(o-s),w=o/(o-s);else if(c===Qr)_=-2/(o-s),w=-(o+s)/(o-s);else if(c===yh)_=-1/(o-s),w=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+c);return f[0]=h,f[4]=0,f[8]=0,f[12]=m,f[1]=0,f[5]=p,f[9]=0,f[13]=v,f[2]=0,f[6]=0,f[10]=_,f[14]=w,f[3]=0,f[7]=0,f[11]=0,f[15]=1,this}equals(e){const n=this.elements,i=e.elements;for(let r=0;r<16;r++)if(n[r]!==i[r])return!1;return!0}fromArray(e,n=0){for(let i=0;i<16;i++)this.elements[i]=e[i+n];return this}toArray(e=[],n=0){const i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e[n+9]=i[9],e[n+10]=i[10],e[n+11]=i[11],e[n+12]=i[12],e[n+13]=i[13],e[n+14]=i[14],e[n+15]=i[15],e}}const ll=new me,Rr=new Yn,UH=new me(0,0,0),FH=new me(1,1,1),pa=new me,Zd=new me,Ki=new me,CE=new Yn,RE=new Jl;let To=class sR{constructor(e=0,n=0,i=0,r=sR.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=i,this._order=r}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,i,r=this._order){return this._x=e,this._y=n,this._z=i,this._order=r,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,i=!0){const r=e.elements,s=r[0],o=r[4],c=r[8],u=r[1],f=r[5],h=r[9],p=r[2],m=r[6],v=r[10];switch(n){case"XYZ":this._y=Math.asin(ln(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,v),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(m,f),this._z=0);break;case"YXZ":this._x=Math.asin(-ln(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(c,v),this._z=Math.atan2(u,f)):(this._y=Math.atan2(-p,s),this._z=0);break;case"ZXY":this._x=Math.asin(ln(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-p,v),this._z=Math.atan2(-o,f)):(this._y=0,this._z=Math.atan2(u,s));break;case"ZYX":this._y=Math.asin(-ln(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(m,v),this._z=Math.atan2(u,s)):(this._x=0,this._z=Math.atan2(-o,f));break;case"YZX":this._z=Math.asin(ln(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-h,f),this._y=Math.atan2(-p,s)):(this._x=0,this._y=Math.atan2(c,v));break;case"XZY":this._z=Math.asin(-ln(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,f),this._y=Math.atan2(c,s)):(this._x=Math.atan2(-h,v),this._y=0);break;default:Ht("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,i){return CE.makeRotationFromQuaternion(e),this.setFromRotationMatrix(CE,n,i)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return RE.setFromEuler(this),this.setFromQuaternion(RE,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}};To.DEFAULT_ORDER="XYZ";class aR{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 OH=0;const PE=new me,cl=new Jl,Ms=new Yn,Jd=new me,zc=new me,BH=new me,zH=new Jl,kE=new me(1,0,0),LE=new me(0,1,0),DE=new me(0,0,1),NE={type:"added"},VH={type:"removed"},ul={type:"childadded",child:null},mg={type:"childremoved",child:null};class er extends Zl{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:OH++}),this.uuid=Lu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=er.DEFAULT_UP.clone();const e=new me,n=new To,i=new Jl,r=new me(1,1,1);function s(){i.setFromEuler(n,!1)}function o(){n.setFromQuaternion(i,void 0,!1)}n._onChange(s),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Yn},normalMatrix:{value:new jt}}),this.matrix=new Yn,this.matrixWorld=new Yn,this.matrixAutoUpdate=er.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=er.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new aR,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 cl.setFromAxisAngle(e,n),this.quaternion.multiply(cl),this}rotateOnWorldAxis(e,n){return cl.setFromAxisAngle(e,n),this.quaternion.premultiply(cl),this}rotateX(e){return this.rotateOnAxis(kE,e)}rotateY(e){return this.rotateOnAxis(LE,e)}rotateZ(e){return this.rotateOnAxis(DE,e)}translateOnAxis(e,n){return PE.copy(e).applyQuaternion(this.quaternion),this.position.add(PE.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(kE,e)}translateY(e){return this.translateOnAxis(LE,e)}translateZ(e){return this.translateOnAxis(DE,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ms.copy(this.matrixWorld).invert())}lookAt(e,n,i){e.isVector3?Jd.copy(e):Jd.set(e,n,i);const r=this.parent;this.updateWorldMatrix(!0,!1),zc.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ms.lookAt(zc,Jd,this.up):Ms.lookAt(Jd,zc,this.up),this.quaternion.setFromRotationMatrix(Ms),r&&(Ms.extractRotation(r.matrixWorld),cl.setFromRotationMatrix(Ms),this.quaternion.premultiply(cl.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(_n("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(NE),ul.child=e,this.dispatchEvent(ul),ul.child=null):_n("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(VH),mg.child=e,this.dispatchEvent(mg),mg.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),Ms.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ms.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ms),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(NE),ul.child=e,this.dispatchEvent(ul),ul.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 i=0,r=this.children.length;i<r;i++){const o=this.children[i].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,i=[]){this[e]===n&&i.push(this);const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(e,n,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(zc,e,BH),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(zc,zH,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 i=0,r=n.length;i<r;i++)n[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let i=0,r=n.length;i<r;i++)n[i].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,i=e.y,r=e.z,s=this.matrix.elements;s[12]+=n-s[0]*n-s[4]*i-s[8]*r,s[13]+=i-s[1]*n-s[5]*i-s[9]*r,s[14]+=r-s[2]*n-s[6]*i-s[10]*r}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 i=0,r=n.length;i<r;i++)n[i].updateMatrixWorld(e)}updateWorldMatrix(e,n){const i=this.parent;if(e===!0&&i!==null&&i.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 r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",i={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(c=>({...c,boundingBox:c.boundingBox?c.boundingBox.toJSON():void 0,boundingSphere:c.boundingSphere?c.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(c=>({...c})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(c,u){return c[u.uuid]===void 0&&(c[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const c=this.geometry.parameters;if(c!==void 0&&c.shapes!==void 0){const u=c.shapes;if(Array.isArray(u))for(let f=0,h=u.length;f<h;f++){const p=u[f];s(e.shapes,p)}else s(e.shapes,u)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const c=[];for(let u=0,f=this.material.length;u<f;u++)c.push(s(e.materials,this.material[u]));r.material=c}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let c=0;c<this.children.length;c++)r.children.push(this.children[c].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let c=0;c<this.animations.length;c++){const u=this.animations[c];r.animations.push(s(e.animations,u))}}if(n){const c=o(e.geometries),u=o(e.materials),f=o(e.textures),h=o(e.images),p=o(e.shapes),m=o(e.skeletons),v=o(e.animations),_=o(e.nodes);c.length>0&&(i.geometries=c),u.length>0&&(i.materials=u),f.length>0&&(i.textures=f),h.length>0&&(i.images=h),p.length>0&&(i.shapes=p),m.length>0&&(i.skeletons=m),v.length>0&&(i.animations=v),_.length>0&&(i.nodes=_)}return i.object=r,i;function o(c){const u=[];for(const f in c){const h=c[f];delete h.metadata,u.push(h)}return u}}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 i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}er.DEFAULT_UP=new me(0,1,0);er.DEFAULT_MATRIX_AUTO_UPDATE=!0;er.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Qd extends er{constructor(){super(),this.isGroup=!0,this.type="Group"}}const HH={type:"move"};class gg{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Qd,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 Qd,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new me,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new me),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Qd,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new me,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new me),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 i of e.hand.values())this._getHandJoint(n,i)}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,i){let r=null,s=null,o=null;const c=this._targetRay,u=this._grip,f=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(f&&e.hand){o=!0;for(const w of e.hand.values()){const y=n.getJointPose(w,i),x=this._getHandJoint(f,w);y!==null&&(x.matrix.fromArray(y.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=y.radius),x.visible=y!==null}const h=f.joints["index-finger-tip"],p=f.joints["thumb-tip"],m=h.position.distanceTo(p.position),v=.02,_=.005;f.inputState.pinching&&m>v+_?(f.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!f.inputState.pinching&&m<=v-_&&(f.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,i),s!==null&&(u.matrix.fromArray(s.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,s.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(s.linearVelocity)):u.hasLinearVelocity=!1,s.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(s.angularVelocity)):u.hasAngularVelocity=!1));c!==null&&(r=n.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,this.dispatchEvent(HH)))}return c!==null&&(c.visible=r!==null),u!==null&&(u.visible=s!==null),f!==null&&(f.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const i=new Qd;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[n.jointName]=i,e.add(i)}return e.joints[n.jointName]}}const oR={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},ma={h:0,s:0,l:0},ef={h:0,s:0,l:0};function vg(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 Mn{constructor(e,n,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,i)}set(e,n,i){if(n===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,n,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=ur){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,fn.colorSpaceToWorking(this,n),this}setRGB(e,n,i,r=fn.workingColorSpace){return this.r=e,this.g=n,this.b=i,fn.colorSpaceToWorking(this,r),this}setHSL(e,n,i,r=fn.workingColorSpace){if(e=RH(e,1),n=ln(n,0,1),i=ln(i,0,1),n===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+n):i+n-i*n,o=2*i-s;this.r=vg(o,s,e+1/3),this.g=vg(o,s,e),this.b=vg(o,s,e-1/3)}return fn.colorSpaceToWorking(this,r),this}setStyle(e,n=ur){function i(s){s!==void 0&&parseFloat(s)<1&&Ht("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=r[1],c=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:Ht("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(s,16),n);Ht("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=ur){const i=oR[e.toLowerCase()];return i!==void 0?this.setHex(i,n):Ht("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=Fs(e.r),this.g=Fs(e.g),this.b=Fs(e.b),this}copyLinearToSRGB(e){return this.r=Ll(e.r),this.g=Ll(e.g),this.b=Ll(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ur){return fn.workingToColorSpace(xi.copy(this),e),Math.round(ln(xi.r*255,0,255))*65536+Math.round(ln(xi.g*255,0,255))*256+Math.round(ln(xi.b*255,0,255))}getHexString(e=ur){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=fn.workingColorSpace){fn.workingToColorSpace(xi.copy(this),n);const i=xi.r,r=xi.g,s=xi.b,o=Math.max(i,r,s),c=Math.min(i,r,s);let u,f;const h=(c+o)/2;if(c===o)u=0,f=0;else{const p=o-c;switch(f=h<=.5?p/(o+c):p/(2-o-c),o){case i:u=(r-s)/p+(r<s?6:0);break;case r:u=(s-i)/p+2;break;case s:u=(i-r)/p+4;break}u/=6}return e.h=u,e.s=f,e.l=h,e}getRGB(e,n=fn.workingColorSpace){return fn.workingToColorSpace(xi.copy(this),n),e.r=xi.r,e.g=xi.g,e.b=xi.b,e}getStyle(e=ur){fn.workingToColorSpace(xi.copy(this),e);const n=xi.r,i=xi.g,r=xi.b;return e!==ur?`color(${e} ${n.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,n,i){return this.getHSL(ma),this.setHSL(ma.h+e,ma.s+n,ma.l+i)}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,i){return this.r=e.r+(n.r-e.r)*i,this.g=e.g+(n.g-e.g)*i,this.b=e.b+(n.b-e.b)*i,this}lerpHSL(e,n){this.getHSL(ma),e.getHSL(ef);const i=ug(ma.h,ef.h,n),r=ug(ma.s,ef.s,n),s=ug(ma.l,ef.l,n);return this.setHSL(i,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*n+s[3]*i+s[6]*r,this.g=s[1]*n+s[4]*i+s[7]*r,this.b=s[2]*n+s[5]*i+s[8]*r,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 xi=new Mn;Mn.NAMES=oR;class GH extends er{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 To,this.environmentIntensity=1,this.environmentRotation=new To,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 Pr=new me,Ts=new me,yg=new me,As=new me,dl=new me,fl=new me,IE=new me,_g=new me,xg=new me,bg=new me,Sg=new zn,wg=new zn,Eg=new zn;let Vc=class El{constructor(e=new me,n=new me,i=new me){this.a=e,this.b=n,this.c=i}static getNormal(e,n,i,r){r.subVectors(i,n),Pr.subVectors(e,n),r.cross(Pr);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,n,i,r,s){Pr.subVectors(r,n),Ts.subVectors(i,n),yg.subVectors(e,n);const o=Pr.dot(Pr),c=Pr.dot(Ts),u=Pr.dot(yg),f=Ts.dot(Ts),h=Ts.dot(yg),p=o*f-c*c;if(p===0)return s.set(0,0,0),null;const m=1/p,v=(f*u-c*h)*m,_=(o*h-c*u)*m;return s.set(1-v-_,_,v)}static containsPoint(e,n,i,r){return this.getBarycoord(e,n,i,r,As)===null?!1:As.x>=0&&As.y>=0&&As.x+As.y<=1}static getInterpolation(e,n,i,r,s,o,c,u){return this.getBarycoord(e,n,i,r,As)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(s,As.x),u.addScaledVector(o,As.y),u.addScaledVector(c,As.z),u)}static getInterpolatedAttribute(e,n,i,r,s,o){return Sg.setScalar(0),wg.setScalar(0),Eg.setScalar(0),Sg.fromBufferAttribute(e,n),wg.fromBufferAttribute(e,i),Eg.fromBufferAttribute(e,r),o.setScalar(0),o.addScaledVector(Sg,s.x),o.addScaledVector(wg,s.y),o.addScaledVector(Eg,s.z),o}static isFrontFacing(e,n,i,r){return Pr.subVectors(i,n),Ts.subVectors(e,n),Pr.cross(Ts).dot(r)<0}set(e,n,i){return this.a.copy(e),this.b.copy(n),this.c.copy(i),this}setFromPointsAndIndices(e,n,i,r){return this.a.copy(e[n]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,n,i,r){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),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 Pr.subVectors(this.c,this.b),Ts.subVectors(this.a,this.b),Pr.cross(Ts).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return El.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return El.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,i,r,s){return El.getInterpolation(e,this.a,this.b,this.c,n,i,r,s)}containsPoint(e){return El.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return El.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const i=this.a,r=this.b,s=this.c;let o,c;dl.subVectors(r,i),fl.subVectors(s,i),_g.subVectors(e,i);const u=dl.dot(_g),f=fl.dot(_g);if(u<=0&&f<=0)return n.copy(i);xg.subVectors(e,r);const h=dl.dot(xg),p=fl.dot(xg);if(h>=0&&p<=h)return n.copy(r);const m=u*p-h*f;if(m<=0&&u>=0&&h<=0)return o=u/(u-h),n.copy(i).addScaledVector(dl,o);bg.subVectors(e,s);const v=dl.dot(bg),_=fl.dot(bg);if(_>=0&&v<=_)return n.copy(s);const w=v*f-u*_;if(w<=0&&f>=0&&_<=0)return c=f/(f-_),n.copy(i).addScaledVector(fl,c);const y=h*_-v*p;if(y<=0&&p-h>=0&&v-_>=0)return IE.subVectors(s,r),c=(p-h)/(p-h+(v-_)),n.copy(r).addScaledVector(IE,c);const x=1/(y+w+m);return o=w*x,c=m*x,n.copy(i).addScaledVector(dl,o).addScaledVector(fl,c)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};class Du{constructor(e=new me(1/0,1/0,1/0),n=new me(-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,i=e.length;n<i;n+=3)this.expandByPoint(kr.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,i=e.count;n<i;n++)this.expandByPoint(kr.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,i=e.length;n<i;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const i=kr.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),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 i=e.geometry;if(i!==void 0){const s=i.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,c=s.count;o<c;o++)e.isMesh===!0?e.getVertexPosition(o,kr):kr.fromBufferAttribute(s,o),kr.applyMatrix4(e.matrixWorld),this.expandByPoint(kr);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),tf.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),tf.copy(i.boundingBox)),tf.applyMatrix4(e.matrixWorld),this.union(tf)}const r=e.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],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,kr),kr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,i;return e.normal.x>0?(n=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),n<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Hc),nf.subVectors(this.max,Hc),hl.subVectors(e.a,Hc),pl.subVectors(e.b,Hc),ml.subVectors(e.c,Hc),ga.subVectors(pl,hl),va.subVectors(ml,pl),Ka.subVectors(hl,ml);let n=[0,-ga.z,ga.y,0,-va.z,va.y,0,-Ka.z,Ka.y,ga.z,0,-ga.x,va.z,0,-va.x,Ka.z,0,-Ka.x,-ga.y,ga.x,0,-va.y,va.x,0,-Ka.y,Ka.x,0];return!Mg(n,hl,pl,ml,nf)||(n=[1,0,0,0,1,0,0,0,1],!Mg(n,hl,pl,ml,nf))?!1:(rf.crossVectors(ga,va),n=[rf.x,rf.y,rf.z],Mg(n,hl,pl,ml,nf))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,kr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(kr).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:(Cs[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Cs[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Cs[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Cs[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Cs[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Cs[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Cs[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Cs[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Cs),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 Cs=[new me,new me,new me,new me,new me,new me,new me,new me],kr=new me,tf=new Du,hl=new me,pl=new me,ml=new me,ga=new me,va=new me,Ka=new me,Hc=new me,nf=new me,rf=new me,Za=new me;function Mg(t,e,n,i,r){for(let s=0,o=t.length-3;s<=o;s+=3){Za.fromArray(t,s);const c=r.x*Math.abs(Za.x)+r.y*Math.abs(Za.y)+r.z*Math.abs(Za.z),u=e.dot(Za),f=n.dot(Za),h=i.dot(Za);if(Math.max(-Math.max(u,f,h),Math.min(u,f,h))>c)return!1}return!0}const Wn=new me,sf=new bn;let jH=0;class Br{constructor(e,n,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:jH++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=i,this.usage=bE,this.updateRanges=[],this.gpuType=Jr,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,i){e*=this.itemSize,i*=n.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=n.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,i=this.count;n<i;n++)sf.fromBufferAttribute(this,n),sf.applyMatrix3(e),this.setXY(n,sf.x,sf.y);else if(this.itemSize===3)for(let n=0,i=this.count;n<i;n++)Wn.fromBufferAttribute(this,n),Wn.applyMatrix3(e),this.setXYZ(n,Wn.x,Wn.y,Wn.z);return this}applyMatrix4(e){for(let n=0,i=this.count;n<i;n++)Wn.fromBufferAttribute(this,n),Wn.applyMatrix4(e),this.setXYZ(n,Wn.x,Wn.y,Wn.z);return this}applyNormalMatrix(e){for(let n=0,i=this.count;n<i;n++)Wn.fromBufferAttribute(this,n),Wn.applyNormalMatrix(e),this.setXYZ(n,Wn.x,Wn.y,Wn.z);return this}transformDirection(e){for(let n=0,i=this.count;n<i;n++)Wn.fromBufferAttribute(this,n),Wn.transformDirection(e),this.setXYZ(n,Wn.x,Wn.y,Wn.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let i=this.array[e*this.itemSize+n];return this.normalized&&(i=Bc(i,this.array)),i}setComponent(e,n,i){return this.normalized&&(i=Hi(i,this.array)),this.array[e*this.itemSize+n]=i,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Bc(n,this.array)),n}setX(e,n){return this.normalized&&(n=Hi(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Bc(n,this.array)),n}setY(e,n){return this.normalized&&(n=Hi(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=Bc(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Hi(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=Bc(n,this.array)),n}setW(e,n){return this.normalized&&(n=Hi(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,i){return e*=this.itemSize,this.normalized&&(n=Hi(n,this.array),i=Hi(i,this.array)),this.array[e+0]=n,this.array[e+1]=i,this}setXYZ(e,n,i,r){return e*=this.itemSize,this.normalized&&(n=Hi(n,this.array),i=Hi(i,this.array),r=Hi(r,this.array)),this.array[e+0]=n,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,n,i,r,s){return e*=this.itemSize,this.normalized&&(n=Hi(n,this.array),i=Hi(i,this.array),r=Hi(r,this.array),s=Hi(s,this.array)),this.array[e+0]=n,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,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!==bE&&(e.usage=this.usage),e}}class lR extends Br{constructor(e,n,i){super(new Uint16Array(e),n,i)}}class cR extends Br{constructor(e,n,i){super(new Uint32Array(e),n,i)}}class Os extends Br{constructor(e,n,i){super(new Float32Array(e),n,i)}}const WH=new Du,Gc=new me,Tg=new me;class i_{constructor(e=new me,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 i=this.center;n!==void 0?i.copy(n):WH.setFromPoints(e).getCenter(i);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),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 i=this.center.distanceToSquared(e);return n.copy(e),i>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;Gc.subVectors(e,this.center);const n=Gc.lengthSq();if(n>this.radius*this.radius){const i=Math.sqrt(n),r=(i-this.radius)*.5;this.center.addScaledVector(Gc,r/i),this.radius+=r}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):(Tg.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Gc.copy(e.center).add(Tg)),this.expandByPoint(Gc.copy(e.center).sub(Tg))),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 $H=0;const lr=new Yn,Ag=new er,gl=new me,Zi=new Du,jc=new Du,li=new me;class ps extends Zl{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$H++}),this.uuid=Lu(),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(MH(e)?cR:lR)(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,i=0){this.groups.push({start:e,count:n,materialIndex:i})}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 i=this.attributes.normal;if(i!==void 0){const s=new jt().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return lr.makeRotationFromQuaternion(e),this.applyMatrix4(lr),this}rotateX(e){return lr.makeRotationX(e),this.applyMatrix4(lr),this}rotateY(e){return lr.makeRotationY(e),this.applyMatrix4(lr),this}rotateZ(e){return lr.makeRotationZ(e),this.applyMatrix4(lr),this}translate(e,n,i){return lr.makeTranslation(e,n,i),this.applyMatrix4(lr),this}scale(e,n,i){return lr.makeScale(e,n,i),this.applyMatrix4(lr),this}lookAt(e){return Ag.lookAt(e),Ag.updateMatrix(),this.applyMatrix4(Ag.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(gl).negate(),this.translate(gl.x,gl.y,gl.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const i=[];for(let r=0,s=e.length;r<s;r++){const o=e[r];i.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Os(i,3))}else{const i=Math.min(e.length,n.count);for(let r=0;r<i;r++){const s=e[r];n.setXYZ(r,s.x,s.y,s.z||0)}e.length>n.count&&Ht("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 Du);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){_n("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new me(-1/0,-1/0,-1/0),new me(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let i=0,r=n.length;i<r;i++){const s=n[i];Zi.setFromBufferAttribute(s),this.morphTargetsRelative?(li.addVectors(this.boundingBox.min,Zi.min),this.boundingBox.expandByPoint(li),li.addVectors(this.boundingBox.max,Zi.max),this.boundingBox.expandByPoint(li)):(this.boundingBox.expandByPoint(Zi.min),this.boundingBox.expandByPoint(Zi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&_n('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 i_);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){_n("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new me,1/0);return}if(e){const i=this.boundingSphere.center;if(Zi.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const c=n[s];jc.setFromBufferAttribute(c),this.morphTargetsRelative?(li.addVectors(Zi.min,jc.min),Zi.expandByPoint(li),li.addVectors(Zi.max,jc.max),Zi.expandByPoint(li)):(Zi.expandByPoint(jc.min),Zi.expandByPoint(jc.max))}Zi.getCenter(i);let r=0;for(let s=0,o=e.count;s<o;s++)li.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(li));if(n)for(let s=0,o=n.length;s<o;s++){const c=n[s],u=this.morphTargetsRelative;for(let f=0,h=c.count;f<h;f++)li.fromBufferAttribute(c,f),u&&(gl.fromBufferAttribute(e,f),li.add(gl)),r=Math.max(r,i.distanceToSquared(li))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&_n('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){_n("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=n.position,r=n.normal,s=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Br(new Float32Array(4*i.count),4));const o=this.getAttribute("tangent"),c=[],u=[];for(let S=0;S<i.count;S++)c[S]=new me,u[S]=new me;const f=new me,h=new me,p=new me,m=new bn,v=new bn,_=new bn,w=new me,y=new me;function x(S,R,V){f.fromBufferAttribute(i,S),h.fromBufferAttribute(i,R),p.fromBufferAttribute(i,V),m.fromBufferAttribute(s,S),v.fromBufferAttribute(s,R),_.fromBufferAttribute(s,V),h.sub(f),p.sub(f),v.sub(m),_.sub(m);const F=1/(v.x*_.y-_.x*v.y);isFinite(F)&&(w.copy(h).multiplyScalar(_.y).addScaledVector(p,-v.y).multiplyScalar(F),y.copy(p).multiplyScalar(v.x).addScaledVector(h,-_.x).multiplyScalar(F),c[S].add(w),c[R].add(w),c[V].add(w),u[S].add(y),u[R].add(y),u[V].add(y))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let S=0,R=M.length;S<R;++S){const V=M[S],F=V.start,j=V.count;for(let Z=F,H=F+j;Z<H;Z+=3)x(e.getX(Z+0),e.getX(Z+1),e.getX(Z+2))}const A=new me,T=new me,D=new me,I=new me;function U(S){D.fromBufferAttribute(r,S),I.copy(D);const R=c[S];A.copy(R),A.sub(D.multiplyScalar(D.dot(R))).normalize(),T.crossVectors(I,R);const F=T.dot(u[S])<0?-1:1;o.setXYZW(S,A.x,A.y,A.z,F)}for(let S=0,R=M.length;S<R;++S){const V=M[S],F=V.start,j=V.count;for(let Z=F,H=F+j;Z<H;Z+=3)U(e.getX(Z+0)),U(e.getX(Z+1)),U(e.getX(Z+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Br(new Float32Array(n.count*3),3),this.setAttribute("normal",i);else for(let m=0,v=i.count;m<v;m++)i.setXYZ(m,0,0,0);const r=new me,s=new me,o=new me,c=new me,u=new me,f=new me,h=new me,p=new me;if(e)for(let m=0,v=e.count;m<v;m+=3){const _=e.getX(m+0),w=e.getX(m+1),y=e.getX(m+2);r.fromBufferAttribute(n,_),s.fromBufferAttribute(n,w),o.fromBufferAttribute(n,y),h.subVectors(o,s),p.subVectors(r,s),h.cross(p),c.fromBufferAttribute(i,_),u.fromBufferAttribute(i,w),f.fromBufferAttribute(i,y),c.add(h),u.add(h),f.add(h),i.setXYZ(_,c.x,c.y,c.z),i.setXYZ(w,u.x,u.y,u.z),i.setXYZ(y,f.x,f.y,f.z)}else for(let m=0,v=n.count;m<v;m+=3)r.fromBufferAttribute(n,m+0),s.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),h.subVectors(o,s),p.subVectors(r,s),h.cross(p),i.setXYZ(m+0,h.x,h.y,h.z),i.setXYZ(m+1,h.x,h.y,h.z),i.setXYZ(m+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,i=e.count;n<i;n++)li.fromBufferAttribute(e,n),li.normalize(),e.setXYZ(n,li.x,li.y,li.z)}toNonIndexed(){function e(c,u){const f=c.array,h=c.itemSize,p=c.normalized,m=new f.constructor(u.length*h);let v=0,_=0;for(let w=0,y=u.length;w<y;w++){c.isInterleavedBufferAttribute?v=u[w]*c.data.stride+c.offset:v=u[w]*h;for(let x=0;x<h;x++)m[_++]=f[v++]}return new Br(m,h,p)}if(this.index===null)return Ht("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new ps,i=this.index.array,r=this.attributes;for(const c in r){const u=r[c],f=e(u,i);n.setAttribute(c,f)}const s=this.morphAttributes;for(const c in s){const u=[],f=s[c];for(let h=0,p=f.length;h<p;h++){const m=f[h],v=e(m,i);u.push(v)}n.morphAttributes[c]=u}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let c=0,u=o.length;c<u;c++){const f=o[c];n.addGroup(f.start,f.count,f.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 u=this.parameters;for(const f in u)u[f]!==void 0&&(e[f]=u[f]);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 i=this.attributes;for(const u in i){const f=i[u];e.data.attributes[u]=f.toJSON(e.data)}const r={};let s=!1;for(const u in this.morphAttributes){const f=this.morphAttributes[u],h=[];for(let p=0,m=f.length;p<m;p++){const v=f[p];h.push(v.toJSON(e.data))}h.length>0&&(r[u]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const c=this.boundingSphere;return c!==null&&(e.data.boundingSphere=c.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 i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const f in r){const h=r[f];this.setAttribute(f,h.clone(n))}const s=e.morphAttributes;for(const f in s){const h=[],p=s[f];for(let m=0,v=p.length;m<v;m++)h.push(p[m].clone(n));this.morphAttributes[f]=h}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let f=0,h=o.length;f<h;f++){const p=o[f];this.addGroup(p.start,p.count,p.materialIndex)}const c=e.boundingBox;c!==null&&(this.boundingBox=c.clone());const u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}let XH=0;class zh extends Zl{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:XH++}),this.uuid=Lu(),this.name="",this.type="Material",this.blending=vo,this.side=La,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=z0,this.blendDst=V0,this.blendEquation=so,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Mn(0,0,0),this.blendAlpha=0,this.depthFunc=zl,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=xE,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=al,this.stencilZFail=al,this.stencilZPass=al,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 i=e[n];if(i===void 0){Ht(`Material: parameter '${n}' has value of undefined.`);continue}const r=this[n];if(r===void 0){Ht(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[n]=i}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==vo&&(i.blending=this.blending),this.side!==La&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==z0&&(i.blendSrc=this.blendSrc),this.blendDst!==V0&&(i.blendDst=this.blendDst),this.blendEquation!==so&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==zl&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==xE&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==al&&(i.stencilFail=this.stencilFail),this.stencilZFail!==al&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==al&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){const o=[];for(const c in s){const u=s[c];delete u.metadata,o.push(u)}return o}if(n){const s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}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 i=null;if(n!==null){const r=n.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=n[s].clone()}return this.clippingPlanes=i,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 Rs=new me,Cg=new me,af=new me,ya=new me,Rg=new me,of=new me,Pg=new me;class qH{constructor(e=new me,n=new me(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,Rs)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const i=n.dot(this.direction);return i<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=Rs.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Rs.copy(this.origin).addScaledVector(this.direction,n),Rs.distanceToSquared(e))}distanceSqToSegment(e,n,i,r){Cg.copy(e).add(n).multiplyScalar(.5),af.copy(n).sub(e).normalize(),ya.copy(this.origin).sub(Cg);const s=e.distanceTo(n)*.5,o=-this.direction.dot(af),c=ya.dot(this.direction),u=-ya.dot(af),f=ya.lengthSq(),h=Math.abs(1-o*o);let p,m,v,_;if(h>0)if(p=o*u-c,m=o*c-u,_=s*h,p>=0)if(m>=-_)if(m<=_){const w=1/h;p*=w,m*=w,v=p*(p+o*m+2*c)+m*(o*p+m+2*u)+f}else m=s,p=Math.max(0,-(o*m+c)),v=-p*p+m*(m+2*u)+f;else m=-s,p=Math.max(0,-(o*m+c)),v=-p*p+m*(m+2*u)+f;else m<=-_?(p=Math.max(0,-(-o*s+c)),m=p>0?-s:Math.min(Math.max(-s,-u),s),v=-p*p+m*(m+2*u)+f):m<=_?(p=0,m=Math.min(Math.max(-s,-u),s),v=m*(m+2*u)+f):(p=Math.max(0,-(o*s+c)),m=p>0?s:Math.min(Math.max(-s,-u),s),v=-p*p+m*(m+2*u)+f);else m=o>0?-s:s,p=Math.max(0,-(o*m+c)),v=-p*p+m*(m+2*u)+f;return i&&i.copy(this.origin).addScaledVector(this.direction,p),r&&r.copy(Cg).addScaledVector(af,m),v}intersectSphere(e,n){Rs.subVectors(e.center,this.origin);const i=Rs.dot(this.direction),r=Rs.dot(Rs)-i*i,s=e.radius*e.radius;if(r>s)return null;const o=Math.sqrt(s-r),c=i-o,u=i+o;return u<0?null:c<0?this.at(u,n):this.at(c,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 i=-(this.origin.dot(e.normal)+e.constant)/n;return i>=0?i:null}intersectPlane(e,n){const i=this.distanceToPlane(e);return i===null?null:this.at(i,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let i,r,s,o,c,u;const f=1/this.direction.x,h=1/this.direction.y,p=1/this.direction.z,m=this.origin;return f>=0?(i=(e.min.x-m.x)*f,r=(e.max.x-m.x)*f):(i=(e.max.x-m.x)*f,r=(e.min.x-m.x)*f),h>=0?(s=(e.min.y-m.y)*h,o=(e.max.y-m.y)*h):(s=(e.max.y-m.y)*h,o=(e.min.y-m.y)*h),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o<r||isNaN(r))&&(r=o),p>=0?(c=(e.min.z-m.z)*p,u=(e.max.z-m.z)*p):(c=(e.max.z-m.z)*p,u=(e.min.z-m.z)*p),i>u||c>r)||((c>i||i!==i)&&(i=c),(u<r||r!==r)&&(r=u),r<0)?null:this.at(i>=0?i:r,n)}intersectsBox(e){return this.intersectBox(e,Rs)!==null}intersectTriangle(e,n,i,r,s){Rg.subVectors(n,e),of.subVectors(i,e),Pg.crossVectors(Rg,of);let o=this.direction.dot(Pg),c;if(o>0){if(r)return null;c=1}else if(o<0)c=-1,o=-o;else return null;ya.subVectors(this.origin,e);const u=c*this.direction.dot(of.crossVectors(ya,of));if(u<0)return null;const f=c*this.direction.dot(Rg.cross(ya));if(f<0||u+f>o)return null;const h=-c*ya.dot(Pg);return h<0?null:this.at(h/o,s)}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 uR extends zh{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Mn(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 To,this.combine=VC,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 UE=new Yn,Ja=new qH,lf=new i_,FE=new me,cf=new me,uf=new me,df=new me,kg=new me,ff=new me,OE=new me,hf=new me;let us=class extends er{constructor(e=new ps,n=new uR){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,i=Object.keys(n);if(i.length>0){const r=n[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const c=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=s}}}}getVertexPosition(e,n){const i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,o=i.morphTargetsRelative;n.fromBufferAttribute(r,e);const c=this.morphTargetInfluences;if(s&&c){ff.set(0,0,0);for(let u=0,f=s.length;u<f;u++){const h=c[u],p=s[u];h!==0&&(kg.fromBufferAttribute(p,e),o?ff.addScaledVector(kg,h):ff.addScaledVector(kg.sub(n),h))}n.add(ff)}return n}raycast(e,n){const i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),lf.copy(i.boundingSphere),lf.applyMatrix4(s),Ja.copy(e.ray).recast(e.near),!(lf.containsPoint(Ja.origin)===!1&&(Ja.intersectSphere(lf,FE)===null||Ja.origin.distanceToSquared(FE)>(e.far-e.near)**2))&&(UE.copy(s).invert(),Ja.copy(e.ray).applyMatrix4(UE),!(i.boundingBox!==null&&Ja.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,n,Ja)))}_computeIntersections(e,n,i){let r;const s=this.geometry,o=this.material,c=s.index,u=s.attributes.position,f=s.attributes.uv,h=s.attributes.uv1,p=s.attributes.normal,m=s.groups,v=s.drawRange;if(c!==null)if(Array.isArray(o))for(let _=0,w=m.length;_<w;_++){const y=m[_],x=o[y.materialIndex],M=Math.max(y.start,v.start),A=Math.min(c.count,Math.min(y.start+y.count,v.start+v.count));for(let T=M,D=A;T<D;T+=3){const I=c.getX(T),U=c.getX(T+1),S=c.getX(T+2);r=pf(this,x,e,i,f,h,p,I,U,S),r&&(r.faceIndex=Math.floor(T/3),r.face.materialIndex=y.materialIndex,n.push(r))}}else{const _=Math.max(0,v.start),w=Math.min(c.count,v.start+v.count);for(let y=_,x=w;y<x;y+=3){const M=c.getX(y),A=c.getX(y+1),T=c.getX(y+2);r=pf(this,o,e,i,f,h,p,M,A,T),r&&(r.faceIndex=Math.floor(y/3),n.push(r))}}else if(u!==void 0)if(Array.isArray(o))for(let _=0,w=m.length;_<w;_++){const y=m[_],x=o[y.materialIndex],M=Math.max(y.start,v.start),A=Math.min(u.count,Math.min(y.start+y.count,v.start+v.count));for(let T=M,D=A;T<D;T+=3){const I=T,U=T+1,S=T+2;r=pf(this,x,e,i,f,h,p,I,U,S),r&&(r.faceIndex=Math.floor(T/3),r.face.materialIndex=y.materialIndex,n.push(r))}}else{const _=Math.max(0,v.start),w=Math.min(u.count,v.start+v.count);for(let y=_,x=w;y<x;y+=3){const M=y,A=y+1,T=y+2;r=pf(this,o,e,i,f,h,p,M,A,T),r&&(r.faceIndex=Math.floor(y/3),n.push(r))}}}};function YH(t,e,n,i,r,s,o,c){let u;if(e.side===Gi?u=i.intersectTriangle(o,s,r,!0,c):u=i.intersectTriangle(r,s,o,e.side===La,c),u===null)return null;hf.copy(c),hf.applyMatrix4(t.matrixWorld);const f=n.ray.origin.distanceTo(hf);return f<n.near||f>n.far?null:{distance:f,point:hf.clone(),object:t}}function pf(t,e,n,i,r,s,o,c,u,f){t.getVertexPosition(c,cf),t.getVertexPosition(u,uf),t.getVertexPosition(f,df);const h=YH(t,e,n,i,cf,uf,df,OE);if(h){const p=new me;Vc.getBarycoord(OE,cf,uf,df,p),r&&(h.uv=Vc.getInterpolatedAttribute(r,c,u,f,p,new bn)),s&&(h.uv1=Vc.getInterpolatedAttribute(s,c,u,f,p,new bn)),o&&(h.normal=Vc.getInterpolatedAttribute(o,c,u,f,p,new me),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const m={a:c,b:u,c:f,normal:new me,materialIndex:0};Vc.getNormal(cf,uf,df,m.normal),h.face=m,h.barycoord=p}return h}class KH extends Li{constructor(e=null,n=1,i=1,r,s,o,c,u,f=pi,h=pi,p,m){super(null,o,c,u,f,h,r,s,p,m),this.isDataTexture=!0,this.image={data:e,width:n,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Lg=new me,ZH=new me,JH=new jt;class io{constructor(e=new me(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,i,r){return this.normal.set(e,n,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,i){const r=Lg.subVectors(i,n).cross(ZH.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(r,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 i=e.delta(Lg),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:n.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const n=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return n<0&&i>0||i<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 i=n||JH.getNormalMatrix(e),r=this.coplanarPoint(Lg).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),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 Qa=new i_,QH=new bn(.5,.5),mf=new me;class dR{constructor(e=new io,n=new io,i=new io,r=new io,s=new io,o=new io){this.planes=[e,n,i,r,s,o]}set(e,n,i,r,s,o){const c=this.planes;return c[0].copy(e),c[1].copy(n),c[2].copy(i),c[3].copy(r),c[4].copy(s),c[5].copy(o),this}copy(e){const n=this.planes;for(let i=0;i<6;i++)n[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,n=Qr,i=!1){const r=this.planes,s=e.elements,o=s[0],c=s[1],u=s[2],f=s[3],h=s[4],p=s[5],m=s[6],v=s[7],_=s[8],w=s[9],y=s[10],x=s[11],M=s[12],A=s[13],T=s[14],D=s[15];if(r[0].setComponents(f-o,v-h,x-_,D-M).normalize(),r[1].setComponents(f+o,v+h,x+_,D+M).normalize(),r[2].setComponents(f+c,v+p,x+w,D+A).normalize(),r[3].setComponents(f-c,v-p,x-w,D-A).normalize(),i)r[4].setComponents(u,m,y,T).normalize(),r[5].setComponents(f-u,v-m,x-y,D-T).normalize();else if(r[4].setComponents(f-u,v-m,x-y,D-T).normalize(),n===Qr)r[5].setComponents(f+u,v+m,x+y,D+T).normalize();else if(n===yh)r[5].setComponents(u,m,y,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(),Qa.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Qa.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Qa)}intersectsSprite(e){Qa.center.set(0,0,0);const n=QH.distanceTo(e.center);return Qa.radius=.7071067811865476+n,Qa.applyMatrix4(e.matrixWorld),this.intersectsSphere(Qa)}intersectsSphere(e){const n=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const n=this.planes;for(let i=0;i<6;i++){const r=n[i];if(mf.x=r.normal.x>0?e.max.x:e.min.x,mf.y=r.normal.y>0?e.max.y:e.min.y,mf.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(mf)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let i=0;i<6;i++)if(n[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class fR extends Li{constructor(e=[],n=Eo,i,r,s,o,c,u,f,h){super(e,n,i,r,s,o,c,u,f,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class _u extends Li{constructor(e,n,i=cs,r,s,o,c=pi,u=pi,f,h=Vs,p=1){if(h!==Vs&&h!==ho)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:n,depth:p};super(m,r,s,o,c,u,h,i,f),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new n_(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 eG extends _u{constructor(e,n=cs,i=Eo,r,s,o=pi,c=pi,u,f=Vs){const h={width:e,height:e,depth:1},p=[h,h,h,h,h,h];super(e,e,n,i,r,s,o,c,u,f),this.image=p,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class hR extends Li{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Nu extends ps{constructor(e=1,n=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};const c=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const u=[],f=[],h=[],p=[];let m=0,v=0;_("z","y","x",-1,-1,i,n,e,o,s,0),_("z","y","x",1,-1,i,n,-e,o,s,1),_("x","z","y",1,1,e,i,n,r,o,2),_("x","z","y",1,-1,e,i,-n,r,o,3),_("x","y","z",1,-1,e,n,i,r,s,4),_("x","y","z",-1,-1,e,n,-i,r,s,5),this.setIndex(u),this.setAttribute("position",new Os(f,3)),this.setAttribute("normal",new Os(h,3)),this.setAttribute("uv",new Os(p,2));function _(w,y,x,M,A,T,D,I,U,S,R){const V=T/U,F=D/S,j=T/2,Z=D/2,H=I/2,q=U+1,J=S+1;let Q=0,W=0;const X=new me;for(let K=0;K<J;K++){const B=K*F-Z;for(let ie=0;ie<q;ie++){const ve=ie*V-j;X[w]=ve*M,X[y]=B*A,X[x]=H,f.push(X.x,X.y,X.z),X[w]=0,X[y]=0,X[x]=I>0?1:-1,h.push(X.x,X.y,X.z),p.push(ie/U),p.push(1-K/S),Q+=1}}for(let K=0;K<S;K++)for(let B=0;B<U;B++){const ie=m+B+q*K,ve=m+B+q*(K+1),Ce=m+(B+1)+q*(K+1),we=m+(B+1)+q*K;u.push(ie,ve,we),u.push(ve,Ce,we),W+=6}c.addGroup(v,W,R),v+=W,m+=Q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Nu(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Vh extends ps{constructor(e=1,n=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:i,heightSegments:r};const s=e/2,o=n/2,c=Math.floor(i),u=Math.floor(r),f=c+1,h=u+1,p=e/c,m=n/u,v=[],_=[],w=[],y=[];for(let x=0;x<h;x++){const M=x*m-o;for(let A=0;A<f;A++){const T=A*p-s;_.push(T,-M,0),w.push(0,0,1),y.push(A/c),y.push(1-x/u)}}for(let x=0;x<u;x++)for(let M=0;M<c;M++){const A=M+f*x,T=M+f*(x+1),D=M+1+f*(x+1),I=M+1+f*x;v.push(A,T,I),v.push(T,D,I)}this.setIndex(v),this.setAttribute("position",new Os(_,3)),this.setAttribute("normal",new Os(w,3)),this.setAttribute("uv",new Os(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vh(e.width,e.height,e.widthSegments,e.heightSegments)}}function Gl(t){const e={};for(const n in t){e[n]={};for(const i in t[n]){const r=t[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(Ht("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null):e[n][i]=r.clone():Array.isArray(r)?e[n][i]=r.slice():e[n][i]=r}}return e}function Ci(t){const e={};for(let n=0;n<t.length;n++){const i=Gl(t[n]);for(const r in i)e[r]=i[r]}return e}function tG(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function pR(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:fn.workingColorSpace}const nG={clone:Gl,merge:Ci};var iG=`void main() {
509
509
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
510
510
  }`,rG=`void main() {
511
511
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
@@ -4860,4 +4860,4 @@ void main() {
4860
4860
  vec4 color;
4861
4861
  mainImage(color, gl_FragCoord.xy);
4862
4862
  gl_FragColor = color;
4863
- }`;function D7({raysOrigin:t="top-center",raysColor:e="#ffffff",raysSpeed:n=1,lightSpread:i=1,rayLength:r=2,pulsating:s=!1,fadeDistance:o=1,saturation:c=1,followMouse:u=!0,mouseInfluence:f=.1,noiseAmount:h=0,distortion:p=0,className:m=""}){const v=k.useRef(null),_=k.useRef(null),w=k.useRef(null),y=k.useRef({x:.5,y:.5}),x=k.useRef({x:.5,y:.5}),M=k.useRef(null),A=k.useRef(null),T=k.useRef(null),[D,I]=k.useState(!1),U=k.useRef(null);return k.useEffect(()=>{if(v.current)return U.current=new IntersectionObserver(S=>{I(S[0].isIntersecting)},{threshold:.1}),U.current.observe(v.current),()=>{U.current&&(U.current.disconnect(),U.current=null)}},[]),k.useEffect(()=>!D||!v.current?void 0:(T.current&&(T.current(),T.current=null),(async()=>{if(!v.current||(await new Promise(Q=>setTimeout(Q,10)),!v.current))return;const R=new kW({dpr:Math.min(window.devicePixelRatio,2),alpha:!0});w.current=R;const V=R.gl;for(V.canvas.style.width="100%",V.canvas.style.height="100%";v.current.firstChild;)v.current.removeChild(v.current.firstChild);v.current.appendChild(V.canvas);const F={iTime:{value:0},iResolution:{value:[1,1]},rayPos:{value:[0,0]},rayDir:{value:[0,1]},raysColor:{value:A1(e)},raysSpeed:{value:n},lightSpread:{value:i},rayLength:{value:r},pulsating:{value:s?1:0},fadeDistance:{value:o},saturation:{value:c},mousePos:{value:[.5,.5]},mouseInfluence:{value:f},noiseAmount:{value:h},distortion:{value:p}};_.current=F;const j=new P7(V),Z=new TW(V,{vertex:k7,fragment:L7,uniforms:F}),H=new R7(V,{geometry:j,program:Z});A.current=H;const q=()=>{if(!v.current||!R)return;R.dpr=Math.min(window.devicePixelRatio,2);const{clientWidth:Q,clientHeight:W}=v.current;R.setSize(Q,W);const X=R.dpr,K=Q*X,B=W*X;F.iResolution.value=[K,B];const{anchor:ie,dir:ve}=C1(t,K,B);F.rayPos.value=ie,F.rayDir.value=ve},J=Q=>{if(!(!w.current||!_.current||!A.current)){F.iTime.value=Q*.001,u&&f>0&&(x.current.x=x.current.x*.92+y.current.x*(1-.92),x.current.y=x.current.y*.92+y.current.y*(1-.92),F.mousePos.value=[x.current.x,x.current.y]);try{R.render({scene:H}),M.current=requestAnimationFrame(J)}catch(W){console.warn("WebGL rendering error:",W)}}};window.addEventListener("resize",q),q(),M.current=requestAnimationFrame(J),T.current=()=>{if(M.current&&(cancelAnimationFrame(M.current),M.current=null),window.removeEventListener("resize",q),R)try{const Q=R.gl.getExtension("WEBGL_lose_context");Q&&Q.loseContext();const W=R.gl.canvas;W&&W.parentNode&&W.parentNode.removeChild(W)}catch(Q){console.warn("Error during WebGL cleanup:",Q)}w.current=null,_.current=null,A.current=null}})(),()=>{T.current&&(T.current(),T.current=null)}),[D,t,e,n,i,r,s,o,c,u,f,h,p]),k.useEffect(()=>{if(!_.current||!v.current||!w.current)return;const S=_.current,R=w.current;S.raysColor.value=A1(e),S.raysSpeed.value=n,S.lightSpread.value=i,S.rayLength.value=r,S.pulsating.value=s?1:0,S.fadeDistance.value=o,S.saturation.value=c,S.mouseInfluence.value=f,S.noiseAmount.value=h,S.distortion.value=p;const{clientWidth:V,clientHeight:F}=v.current,j=R.dpr,{anchor:Z,dir:H}=C1(t,V*j,F*j);S.rayPos.value=Z,S.rayDir.value=H},[e,n,i,t,r,s,o,c,f,h,p]),k.useEffect(()=>{if(!u)return;const S=R=>{if(!v.current)return;const V=v.current.getBoundingClientRect();y.current={x:(R.clientX-V.left)/V.width,y:(R.clientY-V.top)/V.height}};return window.addEventListener("mousemove",S),()=>window.removeEventListener("mousemove",S)},[u]),O.jsx("div",{ref:v,className:`w-full h-full pointer-events-none z-[3] overflow-hidden relative ${m}`.trim()})}function N7({className:t}){return O.jsx("svg",{viewBox:"0 0 384 512",className:t,fill:"currentColor",children:O.jsx("path",{d:"M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"})})}function I7({className:t}){return O.jsx("svg",{viewBox:"0 0 16 16",className:t,fill:"currentColor",children:O.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})})}function U7({className:t}){return O.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[O.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),O.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function F7({className:t}){return O.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:O.jsx("polyline",{points:"20 6 9 17 4 12"})})}const R1="https://github.com/mm7894215/TokenTracker",O7="https://github.com/mm7894215/TokenTracker/releases/latest";function B7(t="default",e="md",n){const i="inline-flex items-center justify-center rounded font-medium transition-colors duration-200 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-oai-gray-950",r={default:"bg-oai-gray-900 text-white hover:bg-oai-gray-800 active:bg-oai-gray-950 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 dark:active:bg-oai-gray-200",ghost:"text-oai-gray-600 hover:text-oai-gray-900 hover:bg-oai-gray-100 active:bg-oai-gray-200 dark:text-oai-gray-400 dark:hover:text-white dark:hover:bg-oai-gray-800 dark:active:bg-oai-gray-700"},s={sm:"h-9 px-4 text-sm",md:"h-11 px-6 text-sm",lg:"h-12 px-8 text-base"};return Si(i,r[t],s[e],n)}function z7({copy:t,signInUrl:e,signUpUrl:n,installCommand:i,installCopied:r,onCopyInstallCommand:s}){const o=V5(),[c,u]=k.useState(!1);k.useEffect(()=>{const w=()=>u(window.scrollY>10);return window.addEventListener("scroll",w,{passive:!0}),()=>window.removeEventListener("scroll",w)},[]);const f=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),{signedIn:h,loading:p}=Ro(),m=k.useMemo(()=>({codex:t("landing.v2.models.agent.codex"),claude_code:t("landing.v2.models.agent.claude_code"),cursor:t("landing.v2.models.agent.cursor"),gemini:t("landing.v2.models.agent.gemini"),opencode:t("landing.v2.models.agent.opencode"),openclaw:t("landing.v2.models.agent.openclaw")}),[t]),v=k.useMemo(()=>[{id:"codex",icon:"/brand-logos/codex.svg"},{id:"claude_code",icon:"/brand-logos/claude-code.svg"},{id:"cursor",icon:"/brand-logos/cursor.svg"},{id:"gemini",icon:"/brand-logos/gemini.svg"},{id:"opencode",icon:"/brand-logos/opencode.svg"},{id:"openclaw",icon:"/brand-logos/openclaw.svg"}],[]),_=o?{duration:0}:void 0;return O.jsxs("div",{className:"relative min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark",children:[O.jsx("div",{className:"absolute inset-0 z-0 pointer-events-none",style:{height:"100vh"},children:O.jsx(D7,{raysOrigin:"top-center",raysColor:"#b8b3ff",raysSpeed:1,lightSpread:.5,rayLength:3,pulsating:!1,fadeDistance:1,saturation:1,followMouse:!0,mouseInfluence:.1,noiseAmount:0,distortion:0})}),O.jsx("header",{className:Si("sticky top-0 z-50 transition-all duration-300",c?"bg-oai-gray-950/80 backdrop-blur-md border-b border-oai-gray-900":"bg-transparent border-b border-transparent"),children:O.jsxs("div",{className:"mx-auto flex h-14 max-w-7xl items-center justify-between px-4 sm:px-6",children:[O.jsxs("div",{className:"flex items-center gap-5",children:[O.jsxs(po,{to:n||"/",className:"flex items-center gap-3 no-underline outline-none rounded focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:ring-offset-oai-gray-950 transition-opacity hover:opacity-80",children:[O.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),O.jsx("span",{className:"text-sm font-semibold tracking-wide text-white uppercase",children:"Token Tracker"})]}),O.jsx("div",{className:"hidden sm:block",children:O.jsx(BV,{})})]}),f&&O.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 sm:gap-3",children:[O.jsxs(po,{to:FV(),className:Si(B7(h||p?"default":"ghost","sm"),"no-underline px-5 rounded-full group",h||p?"shadow-sm ring-1 ring-white/10":"ring-1 ring-oai-gray-700"),children:[t("landing.v2.cta.primary"),O.jsx("span",{className:"ml-2 inline-block transition-transform duration-200 group-hover:translate-x-0.5",children:"→"})]}),O.jsx(WV,{})]})]})}),O.jsxs("main",{children:[O.jsx("section",{className:"relative py-16 sm:py-24 lg:py-32 overflow-hidden",children:O.jsxs("div",{className:"relative z-10 mx-auto max-w-7xl px-4 sm:px-6 flex flex-col items-center text-center gap-20 lg:gap-36",children:[O.jsxs(Is.div,{initial:o?!1:{opacity:0,y:20},animate:{opacity:1,y:0},transition:_||{duration:.5},className:"w-full max-w-3xl relative z-20",children:[O.jsxs("h1",{className:"text-balance text-5xl font-semibold tracking-tight text-white sm:text-6xl lg:text-[4rem] lg:leading-[1.05]",children:[t("landing.v2.hero.title_line1"),O.jsx("br",{}),O.jsx("span",{className:"bg-gradient-to-b from-white via-oai-gray-200 to-oai-gray-500 bg-clip-text text-transparent font-bold tracking-tight",style:{WebkitTextStroke:"1px rgba(255, 255, 255, 0.15)"},children:t("landing.v2.hero.title_line2")})]}),O.jsx("p",{className:"mt-6 text-lg leading-relaxed text-oai-gray-400",children:t("landing.v2.hero.subtagline")}),O.jsxs("div",{className:"mt-8 w-full max-w-lg mx-auto",children:[O.jsxs(Is.div,{whileHover:{scale:1.01,y:-1},transition:{type:"spring",stiffness:400,damping:25},className:"group relative inline-block w-full overflow-hidden rounded-2xl",style:{padding:"1.5px 0"},children:[O.jsx("div",{className:"absolute w-[300%] h-[50%] opacity-70 bottom-[-11px] right-[-250%] rounded-full animate-star-movement-bottom z-0",style:{background:"radial-gradient(circle, #fbdfff, transparent 10%)",animationDuration:"6s"}}),O.jsx("div",{className:"absolute w-[300%] h-[50%] opacity-70 top-[-10px] left-[-250%] rounded-full animate-star-movement-top z-0",style:{background:"radial-gradient(circle, #fbdfff, transparent 10%)",animationDuration:"6s"}}),O.jsxs("div",{className:"relative z-[1] flex items-center justify-between w-full bg-[#0a0a0a] border border-oai-gray-800 rounded-2xl p-1.5 pl-5 shadow-2xl shadow-black/50",children:[O.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[O.jsx("span",{className:"text-oai-gray-600 font-mono select-none","aria-hidden":"true",children:"›"}),O.jsx("code",{className:"font-mono text-sm text-oai-gray-200 overflow-x-auto whitespace-nowrap py-2 [scrollbar-width:none]",children:i?i.split(" ").map((w,y)=>O.jsxs("span",{className:w==="npx"||w==="tokentracker-cli"?"text-white font-medium":w==="--yes"?"text-oai-gray-500":"text-oai-brand-400",children:[w," "]},y)):null})]}),O.jsx("button",{type:"button",onClick:s,"aria-label":t(r?"landing.install.action.copied":"landing.install.action.copy"),className:"shrink-0 flex h-9 w-9 items-center justify-center text-oai-gray-200 bg-oai-gray-900 border border-oai-gray-700 rounded-lg hover:bg-oai-gray-800 hover:text-white active:scale-95 transition-all duration-200 shadow-sm",children:r?O.jsx(F7,{className:"h-4 w-4 text-green-400","aria-hidden":!0}):O.jsx(U7,{className:"h-4 w-4 opacity-70","aria-hidden":!0})})]})]}),O.jsxs("div",{className:"mt-8 flex flex-wrap items-center justify-center gap-x-6 gap-y-4",children:[O.jsxs("a",{href:O7,target:"_blank",rel:"noopener noreferrer",className:"group flex items-center gap-2 text-sm font-medium text-oai-gray-400 hover:text-white transition-colors",children:[O.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-oai-gray-800 group-hover:bg-oai-gray-700 transition-colors",children:O.jsx(N7,{className:"h-4 w-4 text-oai-gray-400 group-hover:text-white"})}),t("landing.v2.install.mac_cta")]}),O.jsxs("a",{href:R1,target:"_blank",rel:"noopener noreferrer",className:"group flex items-center gap-2 text-sm font-medium text-oai-gray-400 hover:text-white transition-colors",children:[O.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-oai-gray-800 group-hover:bg-oai-gray-700 transition-colors",children:O.jsx(I7,{className:"h-4 w-4 text-oai-gray-400 group-hover:text-white"})}),t("landing.cta.secondary")]})]}),O.jsx("span",{className:"sr-only","aria-live":"polite",children:r?t("landing.install.action.copied"):""})]})]}),O.jsx("div",{className:"relative group w-full",children:O.jsxs(Is.div,{initial:o?!1:{opacity:0,y:24},animate:{opacity:1,y:0},transition:_||{duration:.6,delay:.1},className:"relative w-full",children:[O.jsx("div",{style:{position:"absolute",top:"-256px",left:0,right:0,height:"510px",zIndex:3,pointerEvents:"none"},children:O.jsx(aW,{color:"#8a7aff",wispDensity:2,flowSpeed:.28,verticalSizing:2.2,horizontalSizing:1.22,fogIntensity:4,fogScale:.1,wispSpeed:18,wispIntensity:10,flowStrength:.12,decay:1.1,falloffStart:1.1,fogFallSpeed:.5,horizontalBeamOffset:.22,verticalBeamOffset:0,style:{width:"100%",height:"100%"}})}),O.jsx("div",{className:"relative rounded-xl p-[1px] shadow-2xl bg-gradient-to-b from-[rgba(138,122,255,0.6)] via-[rgba(138,122,255,0.15)] to-[rgba(138,122,255,0.05)]",style:{position:"relative",zIndex:10,boxShadow:"0 20px 60px -10px rgba(138,122,255,0.15), 0 4px 20px rgba(0,0,0,0.4)"},children:O.jsxs("div",{className:"relative rounded-[11px] overflow-hidden bg-oai-gray-950",children:[O.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"180px",background:"linear-gradient(to bottom, rgba(138,122,255,0.35) 0%, rgba(138,122,255,0.12) 40%, transparent 100%)",mixBlendMode:"screen",zIndex:20,pointerEvents:"none"}}),O.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"1px",background:"linear-gradient(90deg, transparent 0%, rgba(138,122,255,0.9) 30%, rgba(180,168,255,1) 50%, rgba(138,122,255,0.9) 70%, transparent 100%)",zIndex:25,pointerEvents:"none"}}),O.jsx("img",{src:"/dashboard-dark.png",alt:t("landing.screenshot.alt"),className:"block h-auto w-full object-cover",style:{position:"relative",zIndex:10},loading:"eager",decoding:"async"})]})})]})})]})}),O.jsx("section",{className:"border-y border-oai-gray-900 bg-oai-gray-950/50 py-12 lg:py-16",children:O.jsx("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:O.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-8",children:[O.jsx("p",{className:"text-sm font-semibold uppercase tracking-wider text-oai-gray-400 shrink-0",children:t("landing.v2.models.title")}),O.jsx("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-6 opacity-60 hover:opacity-100 transition-opacity duration-500 grayscale hover:grayscale-0",children:v.map(w=>O.jsxs("div",{className:"flex items-center gap-2.5 transition-transform hover:-translate-y-0.5 duration-300",children:[O.jsx("img",{src:w.icon,alt:"",width:20,height:20,className:`h-5 w-5 object-contain ${w.id==="cursor"?"dark:invert":""}`,loading:"lazy"}),O.jsx("span",{className:"text-sm font-medium text-oai-gray-300",children:m[w.id]})]},w.id))})]})})}),O.jsx("section",{className:"py-20 lg:py-32",children:O.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6 grid grid-cols-1 md:grid-cols-2 gap-16 lg:gap-24 items-start",children:[O.jsxs("div",{className:"max-w-md",children:[O.jsx("p",{className:"text-xs font-bold tracking-widest uppercase text-oai-brand-500 mb-4",children:t("landing.v2.compare.kicker")}),O.jsx("h2",{className:"text-3xl font-semibold tracking-tight text-white sm:text-4xl text-balance",children:t("landing.v2.compare.title")}),O.jsx("p",{className:"mt-6 text-lg leading-relaxed text-oai-gray-400",children:t("landing.v2.compare.subtitle")}),O.jsx("p",{className:"mt-6 text-base leading-relaxed text-oai-gray-500",children:t("landing.v2.distill.body")})]}),O.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-10",children:[O.jsxs("div",{className:"space-y-4",children:[O.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-white border-b border-oai-gray-800 pb-3",children:t("landing.v2.compare.with.title")}),O.jsxs("ul",{className:"space-y-3 text-sm text-oai-gray-400",children:[O.jsxs("li",{className:"flex gap-2",children:[O.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),O.jsx("span",{children:t("landing.v2.compare.with.p1")})]}),O.jsxs("li",{className:"flex gap-2",children:[O.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),O.jsx("span",{children:t("landing.v2.compare.with.p2")})]}),O.jsxs("li",{className:"flex gap-2",children:[O.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),O.jsx("span",{children:t("landing.v2.compare.with.p3")})]})]})]}),O.jsxs("div",{className:"space-y-4",children:[O.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-oai-gray-500 border-b border-oai-gray-800/50 pb-3",children:t("landing.v2.compare.without.title")}),O.jsxs("ul",{className:"space-y-3 text-sm text-oai-gray-500",children:[O.jsxs("li",{className:"flex gap-2",children:[O.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),O.jsx("span",{children:t("landing.v2.compare.without.p1")})]}),O.jsxs("li",{className:"flex gap-2",children:[O.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),O.jsx("span",{children:t("landing.v2.compare.without.p2")})]}),O.jsxs("li",{className:"flex gap-2",children:[O.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),O.jsx("span",{children:t("landing.v2.compare.without.p3")})]})]})]})]})]})})]}),O.jsx("footer",{className:"border-t border-oai-gray-900 bg-oai-gray-950 py-12",children:O.jsxs("div",{className:"mx-auto flex max-w-6xl flex-col items-center justify-between gap-6 px-4 sm:px-6 text-sm text-oai-gray-400 sm:flex-row",children:[O.jsx("p",{children:t("landing.v2.footer.line")}),O.jsxs("div",{className:"flex items-center gap-6",children:[O.jsx("a",{href:R1,className:"font-medium text-oai-gray-400 hover:text-white transition-colors",target:"_blank",rel:"noopener noreferrer",children:t("landing.v2.nav.github")}),f&&O.jsxs(po,{to:e,className:"font-medium text-oai-brand-500 hover:text-oai-brand-400 transition-colors",children:[t("landing.cta.primary")," →"]})]})]})})]})}function V7({prefersReducedMotion:t,screenshotMode:e}){return!(e||t)}function H7(){return k.useMemo(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function G7(t=0,e=!0){const[n,i]=k.useState(()=>!e);return k.useEffect(()=>{if(!e){i(!0);return}let r=null,s=null;const o=()=>i(!0);return typeof window<"u"&&"requestIdleCallback"in window?(s=window.requestIdleCallback(o,{timeout:t||200}),()=>{typeof window.cancelIdleCallback=="function"&&s!=null&&window.cancelIdleCallback(s)}):(r=window.setTimeout(o,t),()=>{r!=null&&window.clearTimeout(r)})},[t,e]),n}function j7({signInUrl:t,signUpUrl:e}){const n=qt("landing.handle.special"),i=qt("landing.handle.default");qt("landing.nav.login"),qt("landing.nav.signup");const[r,s]=k.useState(i),o=H7(),c=k.useMemo(()=>typeof window>"u"?!1:UC(window.location.search),[]),u=V7({prefersReducedMotion:o,screenshotMode:c});G7(250,u);const f="tokentracker.dashboard.from_landing.v1";k.useEffect(()=>{if(!(typeof window>"u"))try{window.sessionStorage.setItem(f,"1")}catch{}},[f]),k.useMemo(()=>qt("landing.handle.placeholder",{handle:n}),[n]),k.useMemo(()=>{const _=qt(r===n?"landing.rank.singularity":"landing.rank.unranked");return qt("landing.rank.expectation",{rank:_})},[r,n]);const h=qt("landing.install.command"),[p,m]=k.useState(!1),v=async()=>{await IV(h)&&(m(!0),window.setTimeout(()=>m(!1),2e3))};return O.jsx(z7,{copy:qt,reduceMotion:o,signInUrl:t,signUpUrl:e,installCommand:h,installCopied:p,onCopyInstallCommand:v})}function W7(t){const e=new URLSearchParams(t).get("next");return typeof e!="string"||e.length===0||!e.startsWith("/")||e.startsWith("//")?"/dashboard":e}const P1={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",linkedin:"LinkedIn",facebook:"Facebook",instagram:"Instagram",tiktok:"TikTok",apple:"Apple",x:"X",spotify:"Spotify"};function k1(t){const e=String(t||"").trim();return P1[e]?P1[e]:e.replace(/-/g," ")}function $7(){const t=Eh(),[e,n]=DL(),{enabled:i,loading:r,signedIn:s,refreshUser:o,signInWithPassword:c,signUp:u,signInWithOAuth:f,getPublicAuthConfig:h}=Ro(),p=k.useMemo(()=>W7(e.toString()),[e]),[m,v]=k.useState("signin"),[_,w]=k.useState(""),[y,x]=k.useState(""),[M,A]=k.useState(""),[T,D]=k.useState(!1),[I,U]=k.useState(null),[S,R]=k.useState(null),[V,F]=k.useState(!0),[j,Z]=k.useState([]),[H,q]=k.useState([]),[J,Q]=k.useState(8);k.useEffect(()=>{const we=e.get("insforge_status"),ne=e.get("insforge_type"),_e=e.get("insforge_error");we==="success"&&ne==="verify_email"?R(qt("login.verify_email_success")):we==="error"&&ne==="verify_email"&&_e&&R(qt("shared.error.prefix",{error:_e}))},[e]),k.useEffect(()=>{if(!i){F(!1);return}let we=!0;return(async()=>{const{data:ne,error:_e}=await h();we&&(_e||!ne?(Z(["google","github"]),q([])):(Z(Array.isArray(ne.oAuthProviders)?ne.oAuthProviders:[]),q(Array.isArray(ne.customOAuthProviders)?ne.customOAuthProviders:[]),typeof ne.passwordMinLength=="number"&&ne.passwordMinLength>0&&Q(ne.passwordMinLength)),F(!1))})(),()=>{we=!1}},[i,h]),k.useEffect(()=>{if(!(!i||r)&&s){if(W){window.location.href="/auth/native-callback";return}t(p,{replace:!0})}},[i,r,s,t,p,W]),k.useEffect(()=>{i&&o()},[i,o]);const W=k.useMemo(()=>e.get("native")==="1",[e]),X=k.useMemo(()=>e.get("provider")||null,[e]),K=k.useMemo(()=>typeof window>"u"||W?"":`${window.location.origin}/`,[W]),B=k.useMemo(()=>typeof window>"u"?"":`${window.location.origin}/`,[]),ie=k.useCallback(async we=>{we.preventDefault(),U(null),D(!0);try{if(m==="signup"){const{data:_e,error:Se}=await u({email:_.trim(),password:y,name:M.trim()||void 0,redirectTo:B});if(Se){U(Se.message||String(Se));return}if(_e?.requireEmailVerification){R(qt("login.verify_email_pending")),v("signin");return}t(p,{replace:!0});return}const{error:ne}=await c({email:_.trim(),password:y});if(ne){U(ne.message||String(ne));return}t(p,{replace:!0})}finally{D(!1)}},[m,_,y,M,u,c,t,p,B]),ve=k.useCallback(async we=>{U(null),D(!0);try{const{error:ne}=await f(we,K);ne&&U(ne.message||String(ne))}finally{D(!1)}},[f,K]);k.useEffect(()=>{if(W&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[W]),k.useEffect(()=>{if(!i||r||s||V||!W||!X)return;[...j,...H].includes(X)&&ve(X)},[i,r,s,V,W,X,j,H,ve]);const Ce=k.useCallback(()=>{n(we=>{const ne=new URLSearchParams(we);return ne.delete("insforge_status"),ne.delete("insforge_type"),ne.delete("insforge_error"),ne},{replace:!0}),R(null)},[n]);return i?O.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[O.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:O.jsx(po,{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:qt("login.back_home")})}),O.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:O.jsxs("div",{className:"w-full max-w-md space-y-8",children:[O.jsxs("div",{className:"text-center",children:[O.jsx("h1",{className:"text-2xl font-semibold text-white tracking-tight",children:qt("login.title")}),O.jsx("p",{className:"mt-2 text-sm text-oai-gray-500",children:qt("login.subtitle")})]}),S?O.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:[O.jsx("span",{children:S}),O.jsx("button",{type:"button",onClick:Ce,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:qt("login.dismiss")})]}):null,I?O.jsx("p",{className:"text-sm text-red-400",role:"alert",children:qt("shared.error.prefix",{error:I})}):null,O.jsx("div",{className:"space-y-3",children:V?O.jsx("div",{className:"h-11 rounded-lg bg-oai-gray-900 animate-pulse","aria-hidden":!0}):O.jsxs(O.Fragment,{children:[j.map(we=>O.jsx("button",{type:"button",disabled:T,onClick:()=>ve(we),className:Si("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:qt("login.oauth.continue",{provider:k1(we)})},we)),H.map(we=>O.jsx("button",{type:"button",disabled:T,onClick:()=>ve(we),className:Si("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:qt("login.oauth.continue",{provider:k1(we)})},we))]})}),O.jsxs("div",{className:"relative",children:[O.jsx("div",{className:"absolute inset-0 flex items-center","aria-hidden":!0,children:O.jsx("span",{className:"w-full border-t border-oai-gray-800"})}),O.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:O.jsx("span",{className:"bg-oai-gray-950 px-3 text-oai-gray-600",children:qt("login.divider")})})]}),O.jsxs("div",{className:"flex rounded-lg border border-oai-gray-800 p-0.5 bg-oai-gray-900/50",children:[O.jsx("button",{type:"button",className:Si("flex-1 py-2 text-sm font-medium rounded-md transition-colors",m==="signin"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{v("signin"),U(null)},children:qt("login.tab.sign_in")}),O.jsx("button",{type:"button",className:Si("flex-1 py-2 text-sm font-medium rounded-md transition-colors",m==="signup"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{v("signup"),U(null)},children:qt("login.tab.sign_up")})]}),O.jsxs("form",{onSubmit:ie,className:"space-y-4",children:[m==="signup"?O.jsxs("div",{children:[O.jsx("label",{htmlFor:"login-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:qt("login.field.name")}),O.jsx("input",{id:"login-name",type:"text",autoComplete:"name",value:M,onChange:we=>A(we.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:qt("login.field.name_placeholder")})]}):null,O.jsxs("div",{children:[O.jsx("label",{htmlFor:"login-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:qt("login.field.email")}),O.jsx("input",{id:"login-email",type:"email",autoComplete:"email",required:!0,value:_,onChange:we=>w(we.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"})]}),O.jsxs("div",{children:[O.jsx("label",{htmlFor:"login-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:qt("login.field.password")}),O.jsx("input",{id:"login-password",type:"password",autoComplete:m==="signup"?"new-password":"current-password",required:!0,minLength:m==="signup"?J:void 0,value:y,onChange:we=>x(we.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"?O.jsx("p",{className:"mt-1 text-xs text-oai-gray-600",children:qt("login.password_hint",{min:String(J)})}):null]}),O.jsx("button",{type:"submit",disabled:T||r,className:"w-full h-11 rounded-lg bg-white text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:qt(m==="signup"?"login.submit.sign_up":"login.submit.sign_in")})]})]})})]}):O.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[O.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:O.jsx(po,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:qt("login.back_home")})}),O.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:O.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",children:qt("login.cloud_only")})})]})}const X7=typeof window<"u"?window.location.search:"",L1=new URLSearchParams(X7),xf=L1.get("insforge_code")||L1.get("code")||null;function q7(){const{loading:t,signedIn:e}=Ro(),n=Eh(),[i,r]=k.useState("processing"),[s,o]=k.useState(null),c=k.useRef(!1);return k.useEffect(()=>{!xf||c.current||(c.current=!0,(async()=>{try{const f=await(await fetch("/api/auth-bridge/verifier")).json();o(!!f?.native)}catch{o(!1)}})())},[]),k.useEffect(()=>{if(s!==!0||!xf)return;r("redirecting");const u=setTimeout(()=>{window.location.href=`tokentracker://auth/callback?insforge_code=${encodeURIComponent(xf)}`},200);return()=>clearTimeout(u)},[s]),k.useEffect(()=>{if(s!==!1||t)return;if(e){n("/dashboard",{replace:!0});return}const u=setTimeout(()=>{e||r("failed")},5e3);return()=>clearTimeout(u)},[s,t,e,n]),k.useEffect(()=>{if(!xf&&s===null){const u=setTimeout(()=>r("failed"),3e3);return()=>clearTimeout(u)}},[s]),i==="processing"&&s!==!0&&(s===null||s===!1&&t)?O.jsx("div",{className:"min-h-screen bg-oai-gray-950"}):O.jsx("div",{className:"min-h-screen bg-oai-gray-950 text-white font-oai antialiased dark flex items-center justify-center",children:O.jsxs("div",{className:"text-center space-y-4 max-w-sm px-4",children:[i==="processing"&&O.jsxs(O.Fragment,{children:[O.jsx("div",{className:"w-8 h-8 border-2 border-oai-gray-600 border-t-white rounded-full animate-spin mx-auto"}),O.jsx("p",{className:"text-oai-gray-400 text-sm",children:"Processing…"})]}),i==="redirecting"&&O.jsxs(O.Fragment,{children:[O.jsx("div",{className:"w-12 h-12 mx-auto rounded-full bg-green-500/15 flex items-center justify-center",children:O.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:O.jsx("path",{d:"M20 6 9 17l-5-5"})})}),O.jsx("p",{className:"text-white text-sm font-medium",children:"Signed in successfully"}),O.jsx("p",{className:"text-oai-gray-500 text-xs",children:"Returning to TokenTracker…"})]}),i==="failed"&&O.jsxs("div",{className:"space-y-3",children:[O.jsx("p",{className:"text-oai-gray-300 text-sm",children:"Sign-in incomplete. Please try again."}),O.jsx("button",{type:"button",onClick:()=>window.close(),className:"px-4 py-2 rounded-lg bg-oai-gray-800 text-sm text-white hover:bg-oai-gray-700 transition-colors",children:"Close this page"})]})]})})}const Y7=jl.lazy(()=>ly(()=>import("./DashboardPage-vIxKP44Z.js"),__vite__mapDeps([0,1])).then(t=>({default:t.DashboardPage}))),K7=jl.lazy(()=>ly(()=>import("./LeaderboardPage-VXJBiwkB.js"),__vite__mapDeps([2,3,1])).then(t=>({default:t.LeaderboardPage}))),Z7=jl.lazy(()=>ly(()=>import("./LeaderboardProfilePage-DPeOBsNk.js"),__vite__mapDeps([4,3,1])).then(t=>({default:t.LeaderboardProfilePage})));function J7(){const t=zr(),e=Ro();DV();const n=_r(),i=k.useMemo(()=>typeof window>"u"?!1:UC(window.location.search),[]),r=t?.pathname||"/",s=new URL(window.location.href),o=s.pathname.replace(/\/+$/,"")||"/",u=o.match(/^\/share\/([^/?#]+)$/i)?.[1]||null,f=s.searchParams.get("token")||null,h=u||f,p=o==="/share"||o==="/share.html"||o.startsWith("/share/"),m=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),v=r.replace(/\/+$/,"")||"/",_=v.match(/^\/leaderboard\/u\/([^/]+)$/i),w=_?_[1]:null,y=v==="/leaderboard"||!!w,x=!!(e.enabled&&e.signedIn),M=m||x,A=!1,T=Qz(),D=k.useMemo(()=>!e.enabled||!x?null:{getAccessToken:()=>e.getAccessToken()},[e,x]);let I=m||n||i?"dashboard":"landing";v==="/landing"&&(I="landing"),v==="/dashboard"&&(I="dashboard"),y&&(I="dashboard");const U=w?Z7:v==="/leaderboard"?K7:Y7,S=O.jsx("div",{className:"min-h-screen bg-oai-white dark:bg-[#050505]"});let R=null;return v==="/auth/callback"||v==="/auth/native-callback"?R=O.jsx(q7,{}):v==="/login"?R=O.jsx($7,{}):I==="landing"?R=O.jsx(j7,{signInUrl:"/login",signUpUrl:"/login"}):R=O.jsx(k.Suspense,{fallback:S,children:O.jsx(U,{baseUrl:T,auth:D,signedIn:M,sessionSoftExpired:A,signOut:()=>e.enabled?e.signOut():Promise.resolve(),publicMode:p,publicToken:h,userId:w,signInUrl:"/login",signUpUrl:"/login"})}),O.jsx(OU,{children:O.jsx(HU,{children:O.jsxs(GU,{children:[R,O.jsx(Zz,{}),O.jsx(OI,{}),O.jsx(YI,{})]})})})}const Q7=TL([{path:"*",element:O.jsx(J7,{})}]);p2.createRoot(document.getElementById("root")).render(O.jsx(jl.StrictMode,{children:O.jsx(EI,{children:O.jsx(zL,{router:Q7})})}));export{nU as $,k$ as A,kC as B,qt as C,O as D,fy as E,oU as F,wT as G,Nv as H,SU as I,ch as J,OS as K,IS as L,zy as M,u$ as N,dy as O,Sl as P,uy as Q,N1 as R,BL as S,pT as T,TU as U,BS as V,Xl as W,yT as X,US as Y,mT as Z,KI as _,hi as a,tU as a0,ZI as a1,c0 as a2,vT as a3,o$ as a4,eU as a5,l$ as a6,gT as a7,c$ as a8,WV as a9,zr as aA,Eh as aB,f$ as aC,aT as aD,Hd as aE,T$ as aF,BV as aG,FV as aH,PV as aI,A$ as aJ,vI as aK,C$ as aL,BU as aM,po as aa,OV as ab,V5 as ac,Is as ad,gU as ae,jl as af,b$ as ag,x$ as ah,AT as ai,Ro as aj,I0 as ak,UC as al,ro as am,R$ as an,h$ as ao,p$ as ap,S$ as aq,sV as ar,m$ as as,g$ as at,P$ as au,_$ as av,ly as aw,w$ as ax,IV as ay,Si as az,CT as b,ka as c,iw as d,Fh as e,Tn as f,LC as g,_r as h,BF as i,a$ as j,SI as k,U$ as l,Ol as m,lV as n,cV as o,L$ as p,y$ as q,k as r,M$ as s,D$ as t,py as u,N$ as v,v$ as w,kn as x,E$ as y,I$ as z};
4863
+ }`;function D7({raysOrigin:t="top-center",raysColor:e="#ffffff",raysSpeed:n=1,lightSpread:i=1,rayLength:r=2,pulsating:s=!1,fadeDistance:o=1,saturation:c=1,followMouse:u=!0,mouseInfluence:f=.1,noiseAmount:h=0,distortion:p=0,className:m=""}){const v=k.useRef(null),_=k.useRef(null),w=k.useRef(null),y=k.useRef({x:.5,y:.5}),x=k.useRef({x:.5,y:.5}),M=k.useRef(null),A=k.useRef(null),T=k.useRef(null),[D,I]=k.useState(!1),U=k.useRef(null);return k.useEffect(()=>{if(v.current)return U.current=new IntersectionObserver(S=>{I(S[0].isIntersecting)},{threshold:.1}),U.current.observe(v.current),()=>{U.current&&(U.current.disconnect(),U.current=null)}},[]),k.useEffect(()=>!D||!v.current?void 0:(T.current&&(T.current(),T.current=null),(async()=>{if(!v.current||(await new Promise(Q=>setTimeout(Q,10)),!v.current))return;const R=new kW({dpr:Math.min(window.devicePixelRatio,2),alpha:!0});w.current=R;const V=R.gl;for(V.canvas.style.width="100%",V.canvas.style.height="100%";v.current.firstChild;)v.current.removeChild(v.current.firstChild);v.current.appendChild(V.canvas);const F={iTime:{value:0},iResolution:{value:[1,1]},rayPos:{value:[0,0]},rayDir:{value:[0,1]},raysColor:{value:A1(e)},raysSpeed:{value:n},lightSpread:{value:i},rayLength:{value:r},pulsating:{value:s?1:0},fadeDistance:{value:o},saturation:{value:c},mousePos:{value:[.5,.5]},mouseInfluence:{value:f},noiseAmount:{value:h},distortion:{value:p}};_.current=F;const j=new P7(V),Z=new TW(V,{vertex:k7,fragment:L7,uniforms:F}),H=new R7(V,{geometry:j,program:Z});A.current=H;const q=()=>{if(!v.current||!R)return;R.dpr=Math.min(window.devicePixelRatio,2);const{clientWidth:Q,clientHeight:W}=v.current;R.setSize(Q,W);const X=R.dpr,K=Q*X,B=W*X;F.iResolution.value=[K,B];const{anchor:ie,dir:ve}=C1(t,K,B);F.rayPos.value=ie,F.rayDir.value=ve},J=Q=>{if(!(!w.current||!_.current||!A.current)){F.iTime.value=Q*.001,u&&f>0&&(x.current.x=x.current.x*.92+y.current.x*(1-.92),x.current.y=x.current.y*.92+y.current.y*(1-.92),F.mousePos.value=[x.current.x,x.current.y]);try{R.render({scene:H}),M.current=requestAnimationFrame(J)}catch(W){console.warn("WebGL rendering error:",W)}}};window.addEventListener("resize",q),q(),M.current=requestAnimationFrame(J),T.current=()=>{if(M.current&&(cancelAnimationFrame(M.current),M.current=null),window.removeEventListener("resize",q),R)try{const Q=R.gl.getExtension("WEBGL_lose_context");Q&&Q.loseContext();const W=R.gl.canvas;W&&W.parentNode&&W.parentNode.removeChild(W)}catch(Q){console.warn("Error during WebGL cleanup:",Q)}w.current=null,_.current=null,A.current=null}})(),()=>{T.current&&(T.current(),T.current=null)}),[D,t,e,n,i,r,s,o,c,u,f,h,p]),k.useEffect(()=>{if(!_.current||!v.current||!w.current)return;const S=_.current,R=w.current;S.raysColor.value=A1(e),S.raysSpeed.value=n,S.lightSpread.value=i,S.rayLength.value=r,S.pulsating.value=s?1:0,S.fadeDistance.value=o,S.saturation.value=c,S.mouseInfluence.value=f,S.noiseAmount.value=h,S.distortion.value=p;const{clientWidth:V,clientHeight:F}=v.current,j=R.dpr,{anchor:Z,dir:H}=C1(t,V*j,F*j);S.rayPos.value=Z,S.rayDir.value=H},[e,n,i,t,r,s,o,c,f,h,p]),k.useEffect(()=>{if(!u)return;const S=R=>{if(!v.current)return;const V=v.current.getBoundingClientRect();y.current={x:(R.clientX-V.left)/V.width,y:(R.clientY-V.top)/V.height}};return window.addEventListener("mousemove",S),()=>window.removeEventListener("mousemove",S)},[u]),O.jsx("div",{ref:v,className:`w-full h-full pointer-events-none z-[3] overflow-hidden relative ${m}`.trim()})}function N7({className:t}){return O.jsx("svg",{viewBox:"0 0 384 512",className:t,fill:"currentColor",children:O.jsx("path",{d:"M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"})})}function I7({className:t}){return O.jsx("svg",{viewBox:"0 0 16 16",className:t,fill:"currentColor",children:O.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})})}function U7({className:t}){return O.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[O.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),O.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function F7({className:t}){return O.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:O.jsx("polyline",{points:"20 6 9 17 4 12"})})}const R1="https://github.com/mm7894215/TokenTracker",O7="https://github.com/mm7894215/TokenTracker/releases/latest";function B7(t="default",e="md",n){const i="inline-flex items-center justify-center rounded font-medium transition-colors duration-200 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-oai-gray-950",r={default:"bg-oai-gray-900 text-white hover:bg-oai-gray-800 active:bg-oai-gray-950 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 dark:active:bg-oai-gray-200",ghost:"text-oai-gray-600 hover:text-oai-gray-900 hover:bg-oai-gray-100 active:bg-oai-gray-200 dark:text-oai-gray-400 dark:hover:text-white dark:hover:bg-oai-gray-800 dark:active:bg-oai-gray-700"},s={sm:"h-9 px-4 text-sm",md:"h-11 px-6 text-sm",lg:"h-12 px-8 text-base"};return Si(i,r[t],s[e],n)}function z7({copy:t,signInUrl:e,signUpUrl:n,installCommand:i,installCopied:r,onCopyInstallCommand:s}){const o=V5(),[c,u]=k.useState(!1);k.useEffect(()=>{const w=()=>u(window.scrollY>10);return window.addEventListener("scroll",w,{passive:!0}),()=>window.removeEventListener("scroll",w)},[]);const f=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),{signedIn:h,loading:p}=Ro(),m=k.useMemo(()=>({codex:t("landing.v2.models.agent.codex"),claude_code:t("landing.v2.models.agent.claude_code"),cursor:t("landing.v2.models.agent.cursor"),gemini:t("landing.v2.models.agent.gemini"),opencode:t("landing.v2.models.agent.opencode"),openclaw:t("landing.v2.models.agent.openclaw")}),[t]),v=k.useMemo(()=>[{id:"codex",icon:"/brand-logos/codex.svg"},{id:"claude_code",icon:"/brand-logos/claude-code.svg"},{id:"cursor",icon:"/brand-logos/cursor.svg"},{id:"gemini",icon:"/brand-logos/gemini.svg"},{id:"opencode",icon:"/brand-logos/opencode.svg"},{id:"openclaw",icon:"/brand-logos/openclaw.svg"}],[]),_=o?{duration:0}:void 0;return O.jsxs("div",{className:"relative min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark",children:[O.jsx("div",{className:"absolute inset-0 z-0 pointer-events-none",style:{height:"100vh"},children:O.jsx(D7,{raysOrigin:"top-center",raysColor:"#b8b3ff",raysSpeed:1,lightSpread:.5,rayLength:3,pulsating:!1,fadeDistance:1,saturation:1,followMouse:!0,mouseInfluence:.1,noiseAmount:0,distortion:0})}),O.jsx("header",{className:Si("sticky top-0 z-50 transition-all duration-300",c?"bg-oai-gray-950/80 backdrop-blur-md border-b border-oai-gray-900":"bg-transparent border-b border-transparent"),children:O.jsxs("div",{className:"mx-auto flex h-14 max-w-7xl items-center justify-between px-4 sm:px-6",children:[O.jsxs("div",{className:"flex items-center gap-5",children:[O.jsxs(po,{to:n||"/",className:"flex items-center gap-3 no-underline outline-none rounded focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:ring-offset-oai-gray-950 transition-opacity hover:opacity-80",children:[O.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),O.jsx("span",{className:"text-sm font-semibold tracking-wide text-white uppercase",children:"Token Tracker"})]}),O.jsx("div",{className:"hidden sm:block",children:O.jsx(BV,{})})]}),f&&O.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 sm:gap-3",children:[O.jsxs(po,{to:FV(),className:Si(B7(h||p?"default":"ghost","sm"),"no-underline px-5 rounded-full group",h||p?"shadow-sm ring-1 ring-white/10":"ring-1 ring-oai-gray-700"),children:[t("landing.v2.cta.primary"),O.jsx("span",{className:"ml-2 inline-block transition-transform duration-200 group-hover:translate-x-0.5",children:"→"})]}),O.jsx(WV,{})]})]})}),O.jsxs("main",{children:[O.jsx("section",{className:"relative py-16 sm:py-24 lg:py-32 overflow-hidden",children:O.jsxs("div",{className:"relative z-10 mx-auto max-w-7xl px-4 sm:px-6 flex flex-col items-center text-center gap-20 lg:gap-36",children:[O.jsxs(Is.div,{initial:o?!1:{opacity:0,y:20},animate:{opacity:1,y:0},transition:_||{duration:.5},className:"w-full max-w-3xl relative z-20",children:[O.jsxs("h1",{className:"text-balance text-5xl font-semibold tracking-tight text-white sm:text-6xl lg:text-[4rem] lg:leading-[1.05]",children:[t("landing.v2.hero.title_line1"),O.jsx("br",{}),O.jsx("span",{className:"bg-gradient-to-b from-white via-oai-gray-200 to-oai-gray-500 bg-clip-text text-transparent font-bold tracking-tight",style:{WebkitTextStroke:"1px rgba(255, 255, 255, 0.15)"},children:t("landing.v2.hero.title_line2")})]}),O.jsx("p",{className:"mt-6 text-lg leading-relaxed text-oai-gray-400",children:t("landing.v2.hero.subtagline")}),O.jsxs("div",{className:"mt-8 w-full max-w-lg mx-auto",children:[O.jsxs(Is.div,{whileHover:{scale:1.01,y:-1},transition:{type:"spring",stiffness:400,damping:25},className:"group relative inline-block w-full overflow-hidden rounded-2xl",style:{padding:"1.5px 0"},children:[O.jsx("div",{className:"absolute w-[300%] h-[50%] opacity-70 bottom-[-11px] right-[-250%] rounded-full animate-star-movement-bottom z-0",style:{background:"radial-gradient(circle, #fbdfff, transparent 10%)",animationDuration:"6s"}}),O.jsx("div",{className:"absolute w-[300%] h-[50%] opacity-70 top-[-10px] left-[-250%] rounded-full animate-star-movement-top z-0",style:{background:"radial-gradient(circle, #fbdfff, transparent 10%)",animationDuration:"6s"}}),O.jsxs("div",{className:"relative z-[1] flex items-center justify-between w-full bg-[#0a0a0a] border border-oai-gray-800 rounded-2xl p-1.5 pl-5 shadow-2xl shadow-black/50",children:[O.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[O.jsx("span",{className:"text-oai-gray-600 font-mono select-none","aria-hidden":"true",children:"›"}),O.jsx("code",{className:"font-mono text-sm text-oai-gray-200 overflow-x-auto whitespace-nowrap py-2 [scrollbar-width:none]",children:i?i.split(" ").map((w,y)=>O.jsxs("span",{className:w==="npx"||w==="tokentracker-cli"?"text-white font-medium":w==="--yes"?"text-oai-gray-500":"text-oai-brand-400",children:[w," "]},y)):null})]}),O.jsx("button",{type:"button",onClick:s,"aria-label":t(r?"landing.install.action.copied":"landing.install.action.copy"),className:"shrink-0 flex h-9 w-9 items-center justify-center text-oai-gray-200 bg-oai-gray-900 border border-oai-gray-700 rounded-lg hover:bg-oai-gray-800 hover:text-white active:scale-95 transition-all duration-200 shadow-sm",children:r?O.jsx(F7,{className:"h-4 w-4 text-green-400","aria-hidden":!0}):O.jsx(U7,{className:"h-4 w-4 opacity-70","aria-hidden":!0})})]})]}),O.jsxs("div",{className:"mt-8 flex flex-wrap items-center justify-center gap-x-6 gap-y-4",children:[O.jsxs("a",{href:O7,target:"_blank",rel:"noopener noreferrer",className:"group flex items-center gap-2 text-sm font-medium text-oai-gray-400 hover:text-white transition-colors",children:[O.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-oai-gray-800 group-hover:bg-oai-gray-700 transition-colors",children:O.jsx(N7,{className:"h-4 w-4 text-oai-gray-400 group-hover:text-white"})}),t("landing.v2.install.mac_cta")]}),O.jsxs("a",{href:R1,target:"_blank",rel:"noopener noreferrer",className:"group flex items-center gap-2 text-sm font-medium text-oai-gray-400 hover:text-white transition-colors",children:[O.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-oai-gray-800 group-hover:bg-oai-gray-700 transition-colors",children:O.jsx(I7,{className:"h-4 w-4 text-oai-gray-400 group-hover:text-white"})}),t("landing.cta.secondary")]})]}),O.jsx("span",{className:"sr-only","aria-live":"polite",children:r?t("landing.install.action.copied"):""})]})]}),O.jsx("div",{className:"relative group w-full",children:O.jsxs(Is.div,{initial:o?!1:{opacity:0,y:24},animate:{opacity:1,y:0},transition:_||{duration:.6,delay:.1},className:"relative w-full",children:[O.jsx("div",{style:{position:"absolute",top:"-256px",left:0,right:0,height:"510px",zIndex:3,pointerEvents:"none"},children:O.jsx(aW,{color:"#8a7aff",wispDensity:2,flowSpeed:.28,verticalSizing:2.2,horizontalSizing:1.22,fogIntensity:4,fogScale:.1,wispSpeed:18,wispIntensity:10,flowStrength:.12,decay:1.1,falloffStart:1.1,fogFallSpeed:.5,horizontalBeamOffset:.22,verticalBeamOffset:0,style:{width:"100%",height:"100%"}})}),O.jsx("div",{className:"relative rounded-xl p-[1px] shadow-2xl bg-gradient-to-b from-[rgba(138,122,255,0.6)] via-[rgba(138,122,255,0.15)] to-[rgba(138,122,255,0.05)]",style:{position:"relative",zIndex:10,boxShadow:"0 20px 60px -10px rgba(138,122,255,0.15), 0 4px 20px rgba(0,0,0,0.4)"},children:O.jsxs("div",{className:"relative rounded-[11px] overflow-hidden bg-oai-gray-950",children:[O.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"180px",background:"linear-gradient(to bottom, rgba(138,122,255,0.35) 0%, rgba(138,122,255,0.12) 40%, transparent 100%)",mixBlendMode:"screen",zIndex:20,pointerEvents:"none"}}),O.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"1px",background:"linear-gradient(90deg, transparent 0%, rgba(138,122,255,0.9) 30%, rgba(180,168,255,1) 50%, rgba(138,122,255,0.9) 70%, transparent 100%)",zIndex:25,pointerEvents:"none"}}),O.jsx("img",{src:"/dashboard-dark.png",alt:t("landing.screenshot.alt"),className:"block h-auto w-full object-cover",style:{position:"relative",zIndex:10},loading:"eager",decoding:"async"})]})})]})})]})}),O.jsx("section",{className:"border-y border-oai-gray-900 bg-oai-gray-950/50 py-12 lg:py-16",children:O.jsx("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:O.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-8",children:[O.jsx("p",{className:"text-sm font-semibold uppercase tracking-wider text-oai-gray-400 shrink-0",children:t("landing.v2.models.title")}),O.jsx("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-6 opacity-60 hover:opacity-100 transition-opacity duration-500 grayscale hover:grayscale-0",children:v.map(w=>O.jsxs("div",{className:"flex items-center gap-2.5 transition-transform hover:-translate-y-0.5 duration-300",children:[O.jsx("img",{src:w.icon,alt:"",width:20,height:20,className:`h-5 w-5 object-contain ${w.id==="cursor"?"dark:invert":""}`,loading:"lazy"}),O.jsx("span",{className:"text-sm font-medium text-oai-gray-300",children:m[w.id]})]},w.id))})]})})}),O.jsx("section",{className:"py-20 lg:py-32",children:O.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6 grid grid-cols-1 md:grid-cols-2 gap-16 lg:gap-24 items-start",children:[O.jsxs("div",{className:"max-w-md",children:[O.jsx("p",{className:"text-xs font-bold tracking-widest uppercase text-oai-brand-500 mb-4",children:t("landing.v2.compare.kicker")}),O.jsx("h2",{className:"text-3xl font-semibold tracking-tight text-white sm:text-4xl text-balance",children:t("landing.v2.compare.title")}),O.jsx("p",{className:"mt-6 text-lg leading-relaxed text-oai-gray-400",children:t("landing.v2.compare.subtitle")}),O.jsx("p",{className:"mt-6 text-base leading-relaxed text-oai-gray-500",children:t("landing.v2.distill.body")})]}),O.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-10",children:[O.jsxs("div",{className:"space-y-4",children:[O.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-white border-b border-oai-gray-800 pb-3",children:t("landing.v2.compare.with.title")}),O.jsxs("ul",{className:"space-y-3 text-sm text-oai-gray-400",children:[O.jsxs("li",{className:"flex gap-2",children:[O.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),O.jsx("span",{children:t("landing.v2.compare.with.p1")})]}),O.jsxs("li",{className:"flex gap-2",children:[O.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),O.jsx("span",{children:t("landing.v2.compare.with.p2")})]}),O.jsxs("li",{className:"flex gap-2",children:[O.jsx("span",{className:"text-oai-brand-500 shrink-0",children:"✦"}),O.jsx("span",{children:t("landing.v2.compare.with.p3")})]})]})]}),O.jsxs("div",{className:"space-y-4",children:[O.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-oai-gray-500 border-b border-oai-gray-800/50 pb-3",children:t("landing.v2.compare.without.title")}),O.jsxs("ul",{className:"space-y-3 text-sm text-oai-gray-500",children:[O.jsxs("li",{className:"flex gap-2",children:[O.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),O.jsx("span",{children:t("landing.v2.compare.without.p1")})]}),O.jsxs("li",{className:"flex gap-2",children:[O.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),O.jsx("span",{children:t("landing.v2.compare.without.p2")})]}),O.jsxs("li",{className:"flex gap-2",children:[O.jsx("span",{className:"opacity-50 shrink-0",children:"✕"}),O.jsx("span",{children:t("landing.v2.compare.without.p3")})]})]})]})]})]})})]}),O.jsx("footer",{className:"border-t border-oai-gray-900 bg-oai-gray-950 py-12",children:O.jsxs("div",{className:"mx-auto flex max-w-6xl flex-col items-center justify-between gap-6 px-4 sm:px-6 text-sm text-oai-gray-400 sm:flex-row",children:[O.jsx("p",{children:t("landing.v2.footer.line")}),O.jsxs("div",{className:"flex items-center gap-6",children:[O.jsx("a",{href:R1,className:"font-medium text-oai-gray-400 hover:text-white transition-colors",target:"_blank",rel:"noopener noreferrer",children:t("landing.v2.nav.github")}),f&&O.jsxs(po,{to:e,className:"font-medium text-oai-brand-500 hover:text-oai-brand-400 transition-colors",children:[t("landing.cta.primary")," →"]})]})]})})]})}function V7({prefersReducedMotion:t,screenshotMode:e}){return!(e||t)}function H7(){return k.useMemo(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function G7(t=0,e=!0){const[n,i]=k.useState(()=>!e);return k.useEffect(()=>{if(!e){i(!0);return}let r=null,s=null;const o=()=>i(!0);return typeof window<"u"&&"requestIdleCallback"in window?(s=window.requestIdleCallback(o,{timeout:t||200}),()=>{typeof window.cancelIdleCallback=="function"&&s!=null&&window.cancelIdleCallback(s)}):(r=window.setTimeout(o,t),()=>{r!=null&&window.clearTimeout(r)})},[t,e]),n}function j7({signInUrl:t,signUpUrl:e}){const n=qt("landing.handle.special"),i=qt("landing.handle.default");qt("landing.nav.login"),qt("landing.nav.signup");const[r,s]=k.useState(i),o=H7(),c=k.useMemo(()=>typeof window>"u"?!1:UC(window.location.search),[]),u=V7({prefersReducedMotion:o,screenshotMode:c});G7(250,u);const f="tokentracker.dashboard.from_landing.v1";k.useEffect(()=>{if(!(typeof window>"u"))try{window.sessionStorage.setItem(f,"1")}catch{}},[f]),k.useMemo(()=>qt("landing.handle.placeholder",{handle:n}),[n]),k.useMemo(()=>{const _=qt(r===n?"landing.rank.singularity":"landing.rank.unranked");return qt("landing.rank.expectation",{rank:_})},[r,n]);const h=qt("landing.install.command"),[p,m]=k.useState(!1),v=async()=>{await IV(h)&&(m(!0),window.setTimeout(()=>m(!1),2e3))};return O.jsx(z7,{copy:qt,reduceMotion:o,signInUrl:t,signUpUrl:e,installCommand:h,installCopied:p,onCopyInstallCommand:v})}function W7(t){const e=new URLSearchParams(t).get("next");return typeof e!="string"||e.length===0||!e.startsWith("/")||e.startsWith("//")?"/dashboard":e}const P1={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",linkedin:"LinkedIn",facebook:"Facebook",instagram:"Instagram",tiktok:"TikTok",apple:"Apple",x:"X",spotify:"Spotify"};function k1(t){const e=String(t||"").trim();return P1[e]?P1[e]:e.replace(/-/g," ")}function $7(){const t=Eh(),[e,n]=DL(),{enabled:i,loading:r,signedIn:s,refreshUser:o,signInWithPassword:c,signUp:u,signInWithOAuth:f,getPublicAuthConfig:h}=Ro(),p=k.useMemo(()=>W7(e.toString()),[e]),[m,v]=k.useState("signin"),[_,w]=k.useState(""),[y,x]=k.useState(""),[M,A]=k.useState(""),[T,D]=k.useState(!1),[I,U]=k.useState(null),[S,R]=k.useState(null),[V,F]=k.useState(!0),[j,Z]=k.useState([]),[H,q]=k.useState([]),[J,Q]=k.useState(8);k.useEffect(()=>{const we=e.get("insforge_status"),ne=e.get("insforge_type"),_e=e.get("insforge_error");we==="success"&&ne==="verify_email"?R(qt("login.verify_email_success")):we==="error"&&ne==="verify_email"&&_e&&R(qt("shared.error.prefix",{error:_e}))},[e]),k.useEffect(()=>{if(!i){F(!1);return}let we=!0;return(async()=>{const{data:ne,error:_e}=await h();we&&(_e||!ne?(Z(["google","github"]),q([])):(Z(Array.isArray(ne.oAuthProviders)?ne.oAuthProviders:[]),q(Array.isArray(ne.customOAuthProviders)?ne.customOAuthProviders:[]),typeof ne.passwordMinLength=="number"&&ne.passwordMinLength>0&&Q(ne.passwordMinLength)),F(!1))})(),()=>{we=!1}},[i,h]),k.useEffect(()=>{if(!(!i||r)&&s){if(W){window.location.href="/auth/native-callback";return}t(p,{replace:!0})}},[i,r,s,t,p,W]),k.useEffect(()=>{i&&o()},[i,o]);const W=k.useMemo(()=>e.get("native")==="1",[e]),X=k.useMemo(()=>e.get("provider")||null,[e]),K=k.useMemo(()=>typeof window>"u"||W?"":`${window.location.origin}/`,[W]),B=k.useMemo(()=>typeof window>"u"?"":`${window.location.origin}/`,[]),ie=k.useCallback(async we=>{we.preventDefault(),U(null),D(!0);try{if(m==="signup"){const{data:_e,error:Se}=await u({email:_.trim(),password:y,name:M.trim()||void 0,redirectTo:B});if(Se){U(Se.message||String(Se));return}if(_e?.requireEmailVerification){R(qt("login.verify_email_pending")),v("signin");return}t(p,{replace:!0});return}const{error:ne}=await c({email:_.trim(),password:y});if(ne){U(ne.message||String(ne));return}t(p,{replace:!0})}finally{D(!1)}},[m,_,y,M,u,c,t,p,B]),ve=k.useCallback(async we=>{U(null),D(!0);try{const{error:ne}=await f(we,K);ne&&U(ne.message||String(ne))}finally{D(!1)}},[f,K]);k.useEffect(()=>{if(W&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[W]),k.useEffect(()=>{if(!i||r||s||V||!W||!X)return;[...j,...H].includes(X)&&ve(X)},[i,r,s,V,W,X,j,H,ve]);const Ce=k.useCallback(()=>{n(we=>{const ne=new URLSearchParams(we);return ne.delete("insforge_status"),ne.delete("insforge_type"),ne.delete("insforge_error"),ne},{replace:!0}),R(null)},[n]);return i?O.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[O.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:O.jsx(po,{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:qt("login.back_home")})}),O.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:O.jsxs("div",{className:"w-full max-w-md space-y-8",children:[O.jsxs("div",{className:"text-center",children:[O.jsx("h1",{className:"text-2xl font-semibold text-white tracking-tight",children:qt("login.title")}),O.jsx("p",{className:"mt-2 text-sm text-oai-gray-500",children:qt("login.subtitle")})]}),S?O.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:[O.jsx("span",{children:S}),O.jsx("button",{type:"button",onClick:Ce,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:qt("login.dismiss")})]}):null,I?O.jsx("p",{className:"text-sm text-red-400",role:"alert",children:qt("shared.error.prefix",{error:I})}):null,O.jsx("div",{className:"space-y-3",children:V?O.jsx("div",{className:"h-11 rounded-lg bg-oai-gray-900 animate-pulse","aria-hidden":!0}):O.jsxs(O.Fragment,{children:[j.map(we=>O.jsx("button",{type:"button",disabled:T,onClick:()=>ve(we),className:Si("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:qt("login.oauth.continue",{provider:k1(we)})},we)),H.map(we=>O.jsx("button",{type:"button",disabled:T,onClick:()=>ve(we),className:Si("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:qt("login.oauth.continue",{provider:k1(we)})},we))]})}),O.jsxs("div",{className:"relative",children:[O.jsx("div",{className:"absolute inset-0 flex items-center","aria-hidden":!0,children:O.jsx("span",{className:"w-full border-t border-oai-gray-800"})}),O.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:O.jsx("span",{className:"bg-oai-gray-950 px-3 text-oai-gray-600",children:qt("login.divider")})})]}),O.jsxs("div",{className:"flex rounded-lg border border-oai-gray-800 p-0.5 bg-oai-gray-900/50",children:[O.jsx("button",{type:"button",className:Si("flex-1 py-2 text-sm font-medium rounded-md transition-colors",m==="signin"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{v("signin"),U(null)},children:qt("login.tab.sign_in")}),O.jsx("button",{type:"button",className:Si("flex-1 py-2 text-sm font-medium rounded-md transition-colors",m==="signup"?"bg-oai-gray-800 text-white":"text-oai-gray-500 hover:text-oai-gray-300"),onClick:()=>{v("signup"),U(null)},children:qt("login.tab.sign_up")})]}),O.jsxs("form",{onSubmit:ie,className:"space-y-4",children:[m==="signup"?O.jsxs("div",{children:[O.jsx("label",{htmlFor:"login-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:qt("login.field.name")}),O.jsx("input",{id:"login-name",type:"text",autoComplete:"name",value:M,onChange:we=>A(we.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:qt("login.field.name_placeholder")})]}):null,O.jsxs("div",{children:[O.jsx("label",{htmlFor:"login-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:qt("login.field.email")}),O.jsx("input",{id:"login-email",type:"email",autoComplete:"email",required:!0,value:_,onChange:we=>w(we.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"})]}),O.jsxs("div",{children:[O.jsx("label",{htmlFor:"login-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:qt("login.field.password")}),O.jsx("input",{id:"login-password",type:"password",autoComplete:m==="signup"?"new-password":"current-password",required:!0,minLength:m==="signup"?J:void 0,value:y,onChange:we=>x(we.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"?O.jsx("p",{className:"mt-1 text-xs text-oai-gray-600",children:qt("login.password_hint",{min:String(J)})}):null]}),O.jsx("button",{type:"submit",disabled:T||r,className:"w-full h-11 rounded-lg bg-white text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:qt(m==="signup"?"login.submit.sign_up":"login.submit.sign_in")})]})]})})]}):O.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[O.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:O.jsx(po,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:qt("login.back_home")})}),O.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:O.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",children:qt("login.cloud_only")})})]})}const X7=typeof window<"u"?window.location.search:"",L1=new URLSearchParams(X7),xf=L1.get("insforge_code")||L1.get("code")||null;function q7(){const{loading:t,signedIn:e}=Ro(),n=Eh(),[i,r]=k.useState("processing"),[s,o]=k.useState(null),c=k.useRef(!1);return k.useEffect(()=>{!xf||c.current||(c.current=!0,(async()=>{try{const f=await(await fetch("/api/auth-bridge/verifier")).json();o(!!f?.native)}catch{o(!1)}})())},[]),k.useEffect(()=>{if(s!==!0||!xf)return;r("redirecting");const u=setTimeout(()=>{window.location.href=`tokentracker://auth/callback?insforge_code=${encodeURIComponent(xf)}`},200);return()=>clearTimeout(u)},[s]),k.useEffect(()=>{if(s!==!1||t)return;if(e){n("/dashboard",{replace:!0});return}const u=setTimeout(()=>{e||r("failed")},5e3);return()=>clearTimeout(u)},[s,t,e,n]),k.useEffect(()=>{if(!xf&&s===null){const u=setTimeout(()=>r("failed"),3e3);return()=>clearTimeout(u)}},[s]),i==="processing"&&s!==!0&&(s===null||s===!1&&t)?O.jsx("div",{className:"min-h-screen bg-oai-gray-950"}):O.jsx("div",{className:"min-h-screen bg-oai-gray-950 text-white font-oai antialiased dark flex items-center justify-center",children:O.jsxs("div",{className:"text-center space-y-4 max-w-sm px-4",children:[i==="processing"&&O.jsxs(O.Fragment,{children:[O.jsx("div",{className:"w-8 h-8 border-2 border-oai-gray-600 border-t-white rounded-full animate-spin mx-auto"}),O.jsx("p",{className:"text-oai-gray-400 text-sm",children:"Processing…"})]}),i==="redirecting"&&O.jsxs(O.Fragment,{children:[O.jsx("div",{className:"w-12 h-12 mx-auto rounded-full bg-green-500/15 flex items-center justify-center",children:O.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:O.jsx("path",{d:"M20 6 9 17l-5-5"})})}),O.jsx("p",{className:"text-white text-sm font-medium",children:"Signed in successfully"}),O.jsx("p",{className:"text-oai-gray-500 text-xs",children:"Returning to TokenTracker…"})]}),i==="failed"&&O.jsxs("div",{className:"space-y-3",children:[O.jsx("p",{className:"text-oai-gray-300 text-sm",children:"Sign-in incomplete. Please try again."}),O.jsx("button",{type:"button",onClick:()=>window.close(),className:"px-4 py-2 rounded-lg bg-oai-gray-800 text-sm text-white hover:bg-oai-gray-700 transition-colors",children:"Close this page"})]})]})})}const Y7=jl.lazy(()=>ly(()=>import("./DashboardPage-Bv4UcOEZ.js"),__vite__mapDeps([0,1])).then(t=>({default:t.DashboardPage}))),K7=jl.lazy(()=>ly(()=>import("./LeaderboardPage-CbvvPyY_.js"),__vite__mapDeps([2,3,1])).then(t=>({default:t.LeaderboardPage}))),Z7=jl.lazy(()=>ly(()=>import("./LeaderboardProfilePage-Co4mAr4h.js"),__vite__mapDeps([4,3,1])).then(t=>({default:t.LeaderboardProfilePage})));function J7(){const t=zr(),e=Ro();DV();const n=_r(),i=k.useMemo(()=>typeof window>"u"?!1:UC(window.location.search),[]),r=t?.pathname||"/",s=new URL(window.location.href),o=s.pathname.replace(/\/+$/,"")||"/",u=o.match(/^\/share\/([^/?#]+)$/i)?.[1]||null,f=s.searchParams.get("token")||null,h=u||f,p=o==="/share"||o==="/share.html"||o.startsWith("/share/"),m=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),v=r.replace(/\/+$/,"")||"/",_=v.match(/^\/leaderboard\/u\/([^/]+)$/i),w=_?_[1]:null,y=v==="/leaderboard"||!!w,x=!!(e.enabled&&e.signedIn),M=m||x,A=!1,T=Qz(),D=k.useMemo(()=>!e.enabled||!x?null:{getAccessToken:()=>e.getAccessToken()},[e,x]);let I=m||n||i?"dashboard":"landing";v==="/landing"&&(I="landing"),v==="/dashboard"&&(I="dashboard"),y&&(I="dashboard");const U=w?Z7:v==="/leaderboard"?K7:Y7,S=O.jsx("div",{className:"min-h-screen bg-oai-white dark:bg-[#050505]"});let R=null;return v==="/auth/callback"||v==="/auth/native-callback"?R=O.jsx(q7,{}):v==="/login"?R=O.jsx($7,{}):I==="landing"?R=O.jsx(j7,{signInUrl:"/login",signUpUrl:"/login"}):R=O.jsx(k.Suspense,{fallback:S,children:O.jsx(U,{baseUrl:T,auth:D,signedIn:M,sessionSoftExpired:A,signOut:()=>e.enabled?e.signOut():Promise.resolve(),publicMode:p,publicToken:h,userId:w,signInUrl:"/login",signUpUrl:"/login"})}),O.jsx(OU,{children:O.jsx(HU,{children:O.jsxs(GU,{children:[R,O.jsx(Zz,{}),O.jsx(OI,{}),O.jsx(YI,{})]})})})}const Q7=TL([{path:"*",element:O.jsx(J7,{})}]);p2.createRoot(document.getElementById("root")).render(O.jsx(jl.StrictMode,{children:O.jsx(EI,{children:O.jsx(zL,{router:Q7})})}));export{nU as $,k$ as A,kC as B,qt as C,O as D,fy as E,oU as F,wT as G,Nv as H,SU as I,ch as J,OS as K,IS as L,zy as M,u$ as N,dy as O,Sl as P,uy as Q,N1 as R,BL as S,pT as T,TU as U,BS as V,Xl as W,yT as X,US as Y,mT as Z,KI as _,hi as a,tU as a0,ZI as a1,c0 as a2,vT as a3,o$ as a4,eU as a5,l$ as a6,gT as a7,c$ as a8,WV as a9,zr as aA,Eh as aB,f$ as aC,aT as aD,Hd as aE,T$ as aF,BV as aG,FV as aH,PV as aI,A$ as aJ,vI as aK,C$ as aL,BU as aM,po as aa,OV as ab,V5 as ac,Is as ad,gU as ae,jl as af,b$ as ag,x$ as ah,AT as ai,Ro as aj,I0 as ak,UC as al,ro as am,R$ as an,h$ as ao,p$ as ap,S$ as aq,sV as ar,m$ as as,g$ as at,P$ as au,_$ as av,ly as aw,w$ as ax,IV as ay,Si as az,CT as b,ka as c,iw as d,Fh as e,Tn as f,LC as g,_r as h,BF as i,a$ as j,SI as k,U$ as l,Ol as m,lV as n,cV as o,L$ as p,y$ as q,k as r,M$ as s,D$ as t,py as u,N$ as v,v$ as w,kn as x,E$ as y,I$ as z};