@probnaya/057-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +55 -0
- package/NOTICE.md +109 -0
- package/README.md +196 -0
- package/bin/057.mjs +36 -0
- package/dist/057-mark.svg +9 -0
- package/dist/assets/index-57shDcHR.css +1 -0
- package/dist/assets/index-s97wO9Og.js +626 -0
- package/dist/favicon-16.png +0 -0
- package/dist/favicon-32.png +0 -0
- package/dist/index.html +17 -0
- package/dist-server/057.mjs +132 -0
- package/package.json +66 -0
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))l(u);new MutationObserver(u=>{for(const f of u)if(f.type==="childList")for(const d of f.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&l(d)}).observe(document,{childList:!0,subtree:!0});function r(u){const f={};return u.integrity&&(f.integrity=u.integrity),u.referrerPolicy&&(f.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?f.credentials="include":u.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function l(u){if(u.ep)return;u.ep=!0;const f=r(u);fetch(u.href,f)}})();var Ec={exports:{}},Pr={};var Om;function dx(){if(Om)return Pr;Om=1;var n=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function r(l,u,f){var d=null;if(f!==void 0&&(d=""+f),u.key!==void 0&&(d=""+u.key),"key"in u){f={};for(var h in u)h!=="key"&&(f[h]=u[h])}else f=u;return u=f.ref,{$$typeof:n,type:l,key:d,ref:u!==void 0?u:null,props:f}}return Pr.Fragment=i,Pr.jsx=r,Pr.jsxs=r,Pr}var zm;function hx(){return zm||(zm=1,Ec.exports=dx()),Ec.exports}var v=hx(),Ac={exports:{}},pe={};var _m;function px(){if(_m)return pe;_m=1;var n=Symbol.for("react.transitional.element"),i=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),f=Symbol.for("react.consumer"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),D=Symbol.iterator;function $(w){return w===null||typeof w!="object"?null:(w=D&&w[D]||w["@@iterator"],typeof w=="function"?w:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,V={};function Z(w,U,q){this.props=w,this.context=U,this.refs=V,this.updater=q||k}Z.prototype.isReactComponent={},Z.prototype.setState=function(w,U){if(typeof w!="object"&&typeof w!="function"&&w!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,w,U,"setState")},Z.prototype.forceUpdate=function(w){this.updater.enqueueForceUpdate(this,w,"forceUpdate")};function I(){}I.prototype=Z.prototype;function F(w,U,q){this.props=w,this.context=U,this.refs=V,this.updater=q||k}var Y=F.prototype=new I;Y.constructor=F,N(Y,Z.prototype),Y.isPureReactComponent=!0;var P=Array.isArray;function he(){}var M={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function j(w,U,q){var K=q.ref;return{$$typeof:n,type:w,key:U,ref:K!==void 0?K:null,props:q}}function W(w,U){return j(w.type,U,w.props)}function te(w){return typeof w=="object"&&w!==null&&w.$$typeof===n}function le(w){var U={"=":"=0",":":"=2"};return"$"+w.replace(/[=:]/g,function(q){return U[q]})}var $e=/\/+/g;function de(w,U){return typeof w=="object"&&w!==null&&w.key!=null?le(""+w.key):U.toString(36)}function se(w){switch(w.status){case"fulfilled":return w.value;case"rejected":throw w.reason;default:switch(typeof w.status=="string"?w.then(he,he):(w.status="pending",w.then(function(U){w.status==="pending"&&(w.status="fulfilled",w.value=U)},function(U){w.status==="pending"&&(w.status="rejected",w.reason=U)})),w.status){case"fulfilled":return w.value;case"rejected":throw w.reason}}throw w}function R(w,U,q,K,oe){var fe=typeof w;(fe==="undefined"||fe==="boolean")&&(w=null);var me=!1;if(w===null)me=!0;else switch(fe){case"bigint":case"string":case"number":me=!0;break;case"object":switch(w.$$typeof){case n:case i:me=!0;break;case x:return me=w._init,R(me(w._payload),U,q,K,oe)}}if(me)return oe=oe(w),me=K===""?"."+de(w,0):K,P(oe)?(q="",me!=null&&(q=me.replace($e,"$&/")+"/"),R(oe,U,q,"",function(gn){return gn})):oe!=null&&(te(oe)&&(oe=W(oe,q+(oe.key==null||w&&w.key===oe.key?"":(""+oe.key).replace($e,"$&/")+"/")+me)),U.push(oe)),1;me=0;var Pe=K===""?".":K+":";if(P(w))for(var De=0;De<w.length;De++)K=w[De],fe=Pe+de(K,De),me+=R(K,U,q,fe,oe);else if(De=$(w),typeof De=="function")for(w=De.call(w),De=0;!(K=w.next()).done;)K=K.value,fe=Pe+de(K,De++),me+=R(K,U,q,fe,oe);else if(fe==="object"){if(typeof w.then=="function")return R(se(w),U,q,K,oe);throw U=String(w),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(w).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return me}function H(w,U,q){if(w==null)return w;var K=[],oe=0;return R(w,K,"","",function(fe){return U.call(q,fe,oe++)}),K}function ae(w){if(w._status===-1){var U=w._result;U=U(),U.then(function(q){(w._status===0||w._status===-1)&&(w._status=1,w._result=q)},function(q){(w._status===0||w._status===-1)&&(w._status=2,w._result=q)}),w._status===-1&&(w._status=0,w._result=U)}if(w._status===1)return w._result.default;throw w._result}var Te=typeof reportError=="function"?reportError:function(w){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof w=="object"&&w!==null&&typeof w.message=="string"?String(w.message):String(w),error:w});if(!window.dispatchEvent(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",w);return}console.error(w)},Re={map:H,forEach:function(w,U,q){H(w,function(){U.apply(this,arguments)},q)},count:function(w){var U=0;return H(w,function(){U++}),U},toArray:function(w){return H(w,function(U){return U})||[]},only:function(w){if(!te(w))throw Error("React.Children.only expected to receive a single React element child.");return w}};return pe.Activity=b,pe.Children=Re,pe.Component=Z,pe.Fragment=r,pe.Profiler=u,pe.PureComponent=F,pe.StrictMode=l,pe.Suspense=m,pe.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=M,pe.__COMPILER_RUNTIME={__proto__:null,c:function(w){return M.H.useMemoCache(w)}},pe.cache=function(w){return function(){return w.apply(null,arguments)}},pe.cacheSignal=function(){return null},pe.cloneElement=function(w,U,q){if(w==null)throw Error("The argument must be a React element, but you passed "+w+".");var K=N({},w.props),oe=w.key;if(U!=null)for(fe in U.key!==void 0&&(oe=""+U.key),U)!E.call(U,fe)||fe==="key"||fe==="__self"||fe==="__source"||fe==="ref"&&U.ref===void 0||(K[fe]=U[fe]);var fe=arguments.length-2;if(fe===1)K.children=q;else if(1<fe){for(var me=Array(fe),Pe=0;Pe<fe;Pe++)me[Pe]=arguments[Pe+2];K.children=me}return j(w.type,oe,K)},pe.createContext=function(w){return w={$$typeof:d,_currentValue:w,_currentValue2:w,_threadCount:0,Provider:null,Consumer:null},w.Provider=w,w.Consumer={$$typeof:f,_context:w},w},pe.createElement=function(w,U,q){var K,oe={},fe=null;if(U!=null)for(K in U.key!==void 0&&(fe=""+U.key),U)E.call(U,K)&&K!=="key"&&K!=="__self"&&K!=="__source"&&(oe[K]=U[K]);var me=arguments.length-2;if(me===1)oe.children=q;else if(1<me){for(var Pe=Array(me),De=0;De<me;De++)Pe[De]=arguments[De+2];oe.children=Pe}if(w&&w.defaultProps)for(K in me=w.defaultProps,me)oe[K]===void 0&&(oe[K]=me[K]);return j(w,fe,oe)},pe.createRef=function(){return{current:null}},pe.forwardRef=function(w){return{$$typeof:h,render:w}},pe.isValidElement=te,pe.lazy=function(w){return{$$typeof:x,_payload:{_status:-1,_result:w},_init:ae}},pe.memo=function(w,U){return{$$typeof:g,type:w,compare:U===void 0?null:U}},pe.startTransition=function(w){var U=M.T,q={};M.T=q;try{var K=w(),oe=M.S;oe!==null&&oe(q,K),typeof K=="object"&&K!==null&&typeof K.then=="function"&&K.then(he,Te)}catch(fe){Te(fe)}finally{U!==null&&q.types!==null&&(U.types=q.types),M.T=U}},pe.unstable_useCacheRefresh=function(){return M.H.useCacheRefresh()},pe.use=function(w){return M.H.use(w)},pe.useActionState=function(w,U,q){return M.H.useActionState(w,U,q)},pe.useCallback=function(w,U){return M.H.useCallback(w,U)},pe.useContext=function(w){return M.H.useContext(w)},pe.useDebugValue=function(){},pe.useDeferredValue=function(w,U){return M.H.useDeferredValue(w,U)},pe.useEffect=function(w,U){return M.H.useEffect(w,U)},pe.useEffectEvent=function(w){return M.H.useEffectEvent(w)},pe.useId=function(){return M.H.useId()},pe.useImperativeHandle=function(w,U,q){return M.H.useImperativeHandle(w,U,q)},pe.useInsertionEffect=function(w,U){return M.H.useInsertionEffect(w,U)},pe.useLayoutEffect=function(w,U){return M.H.useLayoutEffect(w,U)},pe.useMemo=function(w,U){return M.H.useMemo(w,U)},pe.useOptimistic=function(w,U){return M.H.useOptimistic(w,U)},pe.useReducer=function(w,U,q){return M.H.useReducer(w,U,q)},pe.useRef=function(w){return M.H.useRef(w)},pe.useState=function(w){return M.H.useState(w)},pe.useSyncExternalStore=function(w,U,q){return M.H.useSyncExternalStore(w,U,q)},pe.useTransition=function(){return M.H.useTransition()},pe.version="19.2.8",pe}var Um;function cf(){return Um||(Um=1,Ac.exports=px()),Ac.exports}var Q=cf(),Tc={exports:{}},Wr={},Mc={exports:{}},Dc={};var Nm;function mx(){return Nm||(Nm=1,(function(n){function i(R,H){var ae=R.length;R.push(H);e:for(;0<ae;){var Te=ae-1>>>1,Re=R[Te];if(0<u(Re,H))R[Te]=H,R[ae]=Re,ae=Te;else break e}}function r(R){return R.length===0?null:R[0]}function l(R){if(R.length===0)return null;var H=R[0],ae=R.pop();if(ae!==H){R[0]=ae;e:for(var Te=0,Re=R.length,w=Re>>>1;Te<w;){var U=2*(Te+1)-1,q=R[U],K=U+1,oe=R[K];if(0>u(q,ae))K<Re&&0>u(oe,q)?(R[Te]=oe,R[K]=ae,Te=K):(R[Te]=q,R[U]=ae,Te=U);else if(K<Re&&0>u(oe,ae))R[Te]=oe,R[K]=ae,Te=K;else break e}}return H}function u(R,H){var ae=R.sortIndex-H.sortIndex;return ae!==0?ae:R.id-H.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;n.unstable_now=function(){return f.now()}}else{var d=Date,h=d.now();n.unstable_now=function(){return d.now()-h}}var m=[],g=[],x=1,b=null,D=3,$=!1,k=!1,N=!1,V=!1,Z=typeof setTimeout=="function"?setTimeout:null,I=typeof clearTimeout=="function"?clearTimeout:null,F=typeof setImmediate<"u"?setImmediate:null;function Y(R){for(var H=r(g);H!==null;){if(H.callback===null)l(g);else if(H.startTime<=R)l(g),H.sortIndex=H.expirationTime,i(m,H);else break;H=r(g)}}function P(R){if(N=!1,Y(R),!k)if(r(m)!==null)k=!0,he||(he=!0,le());else{var H=r(g);H!==null&&se(P,H.startTime-R)}}var he=!1,M=-1,E=5,j=-1;function W(){return V?!0:!(n.unstable_now()-j<E)}function te(){if(V=!1,he){var R=n.unstable_now();j=R;var H=!0;try{e:{k=!1,N&&(N=!1,I(M),M=-1),$=!0;var ae=D;try{t:{for(Y(R),b=r(m);b!==null&&!(b.expirationTime>R&&W());){var Te=b.callback;if(typeof Te=="function"){b.callback=null,D=b.priorityLevel;var Re=Te(b.expirationTime<=R);if(R=n.unstable_now(),typeof Re=="function"){b.callback=Re,Y(R),H=!0;break t}b===r(m)&&l(m),Y(R)}else l(m);b=r(m)}if(b!==null)H=!0;else{var w=r(g);w!==null&&se(P,w.startTime-R),H=!1}}break e}finally{b=null,D=ae,$=!1}H=void 0}}finally{H?le():he=!1}}}var le;if(typeof F=="function")le=function(){F(te)};else if(typeof MessageChannel<"u"){var $e=new MessageChannel,de=$e.port2;$e.port1.onmessage=te,le=function(){de.postMessage(null)}}else le=function(){Z(te,0)};function se(R,H){M=Z(function(){R(n.unstable_now())},H)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(R){R.callback=null},n.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<R?Math.floor(1e3/R):5},n.unstable_getCurrentPriorityLevel=function(){return D},n.unstable_next=function(R){switch(D){case 1:case 2:case 3:var H=3;break;default:H=D}var ae=D;D=H;try{return R()}finally{D=ae}},n.unstable_requestPaint=function(){V=!0},n.unstable_runWithPriority=function(R,H){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var ae=D;D=R;try{return H()}finally{D=ae}},n.unstable_scheduleCallback=function(R,H,ae){var Te=n.unstable_now();switch(typeof ae=="object"&&ae!==null?(ae=ae.delay,ae=typeof ae=="number"&&0<ae?Te+ae:Te):ae=Te,R){case 1:var Re=-1;break;case 2:Re=250;break;case 5:Re=1073741823;break;case 4:Re=1e4;break;default:Re=5e3}return Re=ae+Re,R={id:x++,callback:H,priorityLevel:R,startTime:ae,expirationTime:Re,sortIndex:-1},ae>Te?(R.sortIndex=ae,i(g,R),r(m)===null&&R===r(g)&&(N?(I(M),M=-1):N=!0,se(P,ae-Te))):(R.sortIndex=Re,i(m,R),k||$||(k=!0,he||(he=!0,le()))),R},n.unstable_shouldYield=W,n.unstable_wrapCallback=function(R){var H=D;return function(){var ae=D;D=H;try{return R.apply(this,arguments)}finally{D=ae}}}})(Dc)),Dc}var Lm;function gx(){return Lm||(Lm=1,Mc.exports=mx()),Mc.exports}var Rc={exports:{}},wt={};var km;function yx(){if(km)return wt;km=1;var n=cf();function i(m){var g="https://react.dev/errors/"+m;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)g+="&args[]="+encodeURIComponent(arguments[x])}return"Minified React error #"+m+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var l={d:{f:r,r:function(){throw Error(i(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},u=Symbol.for("react.portal");function f(m,g,x){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:u,key:b==null?null:""+b,children:m,containerInfo:g,implementation:x}}var d=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(m,g){if(m==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return wt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=l,wt.createPortal=function(m,g){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(i(299));return f(m,g,null,x)},wt.flushSync=function(m){var g=d.T,x=l.p;try{if(d.T=null,l.p=2,m)return m()}finally{d.T=g,l.p=x,l.d.f()}},wt.preconnect=function(m,g){typeof m=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,l.d.C(m,g))},wt.prefetchDNS=function(m){typeof m=="string"&&l.d.D(m)},wt.preinit=function(m,g){if(typeof m=="string"&&g&&typeof g.as=="string"){var x=g.as,b=h(x,g.crossOrigin),D=typeof g.integrity=="string"?g.integrity:void 0,$=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;x==="style"?l.d.S(m,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:b,integrity:D,fetchPriority:$}):x==="script"&&l.d.X(m,{crossOrigin:b,integrity:D,fetchPriority:$,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},wt.preinitModule=function(m,g){if(typeof m=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var x=h(g.as,g.crossOrigin);l.d.M(m,{crossOrigin:x,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0})}}else g==null&&l.d.M(m)},wt.preload=function(m,g){if(typeof m=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var x=g.as,b=h(x,g.crossOrigin);l.d.L(m,x,{crossOrigin:b,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},wt.preloadModule=function(m,g){if(typeof m=="string")if(g){var x=h(g.as,g.crossOrigin);l.d.m(m,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:x,integrity:typeof g.integrity=="string"?g.integrity:void 0})}else l.d.m(m)},wt.requestFormReset=function(m){l.d.r(m)},wt.unstable_batchedUpdates=function(m,g){return m(g)},wt.useFormState=function(m,g,x){return d.H.useFormState(m,g,x)},wt.useFormStatus=function(){return d.H.useHostTransitionStatus()},wt.version="19.2.8",wt}var jm;function vx(){if(jm)return Rc.exports;jm=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(i){console.error(i)}}return n(),Rc.exports=yx(),Rc.exports}var Gm;function bx(){if(Gm)return Wr;Gm=1;var n=gx(),i=cf(),r=vx();function l(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function u(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function f(e){var t=e,a=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(a=t.return),e=t.return;while(e)}return t.tag===3?a:null}function d(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function h(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function m(e){if(f(e)!==e)throw Error(l(188))}function g(e){var t=e.alternate;if(!t){if(t=f(e),t===null)throw Error(l(188));return t!==e?null:e}for(var a=e,s=t;;){var o=a.return;if(o===null)break;var c=o.alternate;if(c===null){if(s=o.return,s!==null){a=s;continue}break}if(o.child===c.child){for(c=o.child;c;){if(c===a)return m(o),e;if(c===s)return m(o),t;c=c.sibling}throw Error(l(188))}if(a.return!==s.return)a=o,s=c;else{for(var p=!1,y=o.child;y;){if(y===a){p=!0,a=o,s=c;break}if(y===s){p=!0,s=o,a=c;break}y=y.sibling}if(!p){for(y=c.child;y;){if(y===a){p=!0,a=c,s=o;break}if(y===s){p=!0,s=c,a=o;break}y=y.sibling}if(!p)throw Error(l(189))}}if(a.alternate!==s)throw Error(l(190))}if(a.tag!==3)throw Error(l(188));return a.stateNode.current===a?e:t}function x(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=x(e),t!==null)return t;e=e.sibling}return null}var b=Object.assign,D=Symbol.for("react.element"),$=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),Z=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),F=Symbol.for("react.context"),Y=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),he=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),j=Symbol.for("react.activity"),W=Symbol.for("react.memo_cache_sentinel"),te=Symbol.iterator;function le(e){return e===null||typeof e!="object"?null:(e=te&&e[te]||e["@@iterator"],typeof e=="function"?e:null)}var $e=Symbol.for("react.client.reference");function de(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===$e?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case N:return"Fragment";case Z:return"Profiler";case V:return"StrictMode";case P:return"Suspense";case he:return"SuspenseList";case j:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case F:return e.displayName||"Context";case I:return(e._context.displayName||"Context")+".Consumer";case Y:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case M:return t=e.displayName||null,t!==null?t:de(e.type)||"Memo";case E:t=e._payload,e=e._init;try{return de(e(t))}catch{}}return null}var se=Array.isArray,R=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae={pending:!1,data:null,method:null,action:null},Te=[],Re=-1;function w(e){return{current:e}}function U(e){0>Re||(e.current=Te[Re],Te[Re]=null,Re--)}function q(e,t){Re++,Te[Re]=e.current,e.current=t}var K=w(null),oe=w(null),fe=w(null),me=w(null);function Pe(e,t){switch(q(fe,t),q(oe,e),q(K,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Jp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Jp(t),e=em(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}U(K),q(K,e)}function De(){U(K),U(oe),U(fe)}function gn(e){e.memoizedState!==null&&q(me,e);var t=K.current,a=em(t,e.type);t!==a&&(q(oe,e),q(K,a))}function Wn(e){oe.current===e&&(U(K),U(oe)),me.current===e&&(U(me),Xr._currentValue=ae)}var Mt,Tn;function be(e){if(Mt===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);Mt=t&&t[1]||"",Tn=-1<a.stack.indexOf(`
|
|
2
|
+
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
+
`+Mt+e+Tn}var yn=!1;function fn(e,t){if(!e||yn)return"";yn=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var s={DetermineComponentFrameRoot:function(){try{if(t){var B=function(){throw Error()};if(Object.defineProperty(B.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(B,[])}catch(_){var z=_}Reflect.construct(e,[],B)}else{try{B.call()}catch(_){z=_}e.call(B.prototype)}}else{try{throw Error()}catch(_){z=_}(B=e())&&typeof B.catch=="function"&&B.catch(function(){})}}catch(_){if(_&&z&&typeof _.stack=="string")return[_.stack,z.stack]}return[null,null]}};s.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var o=Object.getOwnPropertyDescriptor(s.DetermineComponentFrameRoot,"name");o&&o.configurable&&Object.defineProperty(s.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var c=s.DetermineComponentFrameRoot(),p=c[0],y=c[1];if(p&&y){var S=p.split(`
|
|
4
|
+
`),O=y.split(`
|
|
5
|
+
`);for(o=s=0;s<S.length&&!S[s].includes("DetermineComponentFrameRoot");)s++;for(;o<O.length&&!O[o].includes("DetermineComponentFrameRoot");)o++;if(s===S.length||o===O.length)for(s=S.length-1,o=O.length-1;1<=s&&0<=o&&S[s]!==O[o];)o--;for(;1<=s&&0<=o;s--,o--)if(S[s]!==O[o]){if(s!==1||o!==1)do if(s--,o--,0>o||S[s]!==O[o]){var L=`
|
|
6
|
+
`+S[s].replace(" at new "," at ");return e.displayName&&L.includes("<anonymous>")&&(L=L.replace("<anonymous>",e.displayName)),L}while(1<=s&&0<=o);break}}}finally{yn=!1,Error.prepareStackTrace=a}return(a=e?e.displayName||e.name:"")?be(a):""}function ee(e,t){switch(e.tag){case 26:case 27:case 5:return be(e.type);case 16:return be("Lazy");case 13:return e.child!==t&&t!==null?be("Suspense Fallback"):be("Suspense");case 19:return be("SuspenseList");case 0:case 15:return fn(e.type,!1);case 11:return fn(e.type.render,!1);case 1:return fn(e.type,!0);case 31:return be("Activity");default:return""}}function J(e){try{var t="",a=null;do t+=ee(e,a),a=e,e=e.return;while(e);return t}catch(s){return`
|
|
7
|
+
Error generating stack: `+s.message+`
|
|
8
|
+
`+s.stack}}var ye=Object.prototype.hasOwnProperty,Ce=n.unstable_scheduleCallback,Qe=n.unstable_cancelCallback,Ke=n.unstable_shouldYield,Qt=n.unstable_requestPaint,Ve=n.unstable_now,dn=n.unstable_getCurrentPriorityLevel,xt=n.unstable_ImmediatePriority,Lt=n.unstable_UserBlockingPriority,Mn=n.unstable_NormalPriority,ra=n.unstable_LowPriority,Dn=n.unstable_IdlePriority,Oi=n.log,At=n.unstable_setDisableYieldValue,ct=null,He=null;function St(e){if(typeof Oi=="function"&&At(e),He&&typeof He.setStrictMode=="function")try{He.setStrictMode(ct,e)}catch{}}var tt=Math.clz32?Math.clz32:rr,zi=Math.log,_i=Math.LN2;function rr(e){return e>>>=0,e===0?32:31-(zi(e)/_i|0)|0}var gs=256,ys=262144,vs=4194304;function Ui(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function bs(e,t,a){var s=e.pendingLanes;if(s===0)return 0;var o=0,c=e.suspendedLanes,p=e.pingedLanes;e=e.warmLanes;var y=s&134217727;return y!==0?(s=y&~c,s!==0?o=Ui(s):(p&=y,p!==0?o=Ui(p):a||(a=y&~e,a!==0&&(o=Ui(a))))):(y=s&~c,y!==0?o=Ui(y):p!==0?o=Ui(p):a||(a=s&~e,a!==0&&(o=Ui(a)))),o===0?0:t!==0&&t!==o&&(t&c)===0&&(c=o&-o,a=t&-t,c>=a||c===32&&(a&4194048)!==0)?t:o}function sr(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Jy(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Nf(){var e=vs;return vs<<=1,(vs&62914560)===0&&(vs=4194304),e}function cu(e){for(var t=[],a=0;31>a;a++)t.push(e);return t}function lr(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ev(e,t,a,s,o,c){var p=e.pendingLanes;e.pendingLanes=a,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=a,e.entangledLanes&=a,e.errorRecoveryDisabledLanes&=a,e.shellSuspendCounter=0;var y=e.entanglements,S=e.expirationTimes,O=e.hiddenUpdates;for(a=p&~a;0<a;){var L=31-tt(a),B=1<<L;y[L]=0,S[L]=-1;var z=O[L];if(z!==null)for(O[L]=null,L=0;L<z.length;L++){var _=z[L];_!==null&&(_.lane&=-536870913)}a&=~B}s!==0&&Lf(e,s,0),c!==0&&o===0&&e.tag!==0&&(e.suspendedLanes|=c&~(p&~t))}function Lf(e,t,a){e.pendingLanes|=t,e.suspendedLanes&=~t;var s=31-tt(t);e.entangledLanes|=t,e.entanglements[s]=e.entanglements[s]|1073741824|a&261930}function kf(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var s=31-tt(a),o=1<<s;o&t|e[s]&t&&(e[s]|=t),a&=~o}}function jf(e,t){var a=t&-t;return a=(a&42)!==0?1:fu(a),(a&(e.suspendedLanes|t))!==0?0:a}function fu(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function du(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Gf(){var e=H.p;return e!==0?e:(e=window.event,e===void 0?32:Em(e.type))}function Bf(e,t){var a=H.p;try{return H.p=e,t()}finally{H.p=a}}var Jn=Math.random().toString(36).slice(2),mt="__reactFiber$"+Jn,Dt="__reactProps$"+Jn,sa="__reactContainer$"+Jn,hu="__reactEvents$"+Jn,tv="__reactListeners$"+Jn,nv="__reactHandles$"+Jn,$f="__reactResources$"+Jn,ur="__reactMarker$"+Jn;function pu(e){delete e[mt],delete e[Dt],delete e[hu],delete e[tv],delete e[nv]}function la(e){var t=e[mt];if(t)return t;for(var a=e.parentNode;a;){if(t=a[sa]||a[mt]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=lm(e);e!==null;){if(a=e[mt])return a;e=lm(e)}return t}e=a,a=e.parentNode}return null}function ua(e){if(e=e[mt]||e[sa]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function or(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(l(33))}function oa(e){var t=e[$f];return t||(t=e[$f]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function ft(e){e[ur]=!0}var Vf=new Set,If={};function Ni(e,t){ca(e,t),ca(e+"Capture",t)}function ca(e,t){for(If[e]=t,e=0;e<t.length;e++)Vf.add(t[e])}var iv=RegExp("^[: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]*$"),Ff={},Hf={};function av(e){return ye.call(Hf,e)?!0:ye.call(Ff,e)?!1:iv.test(e)?Hf[e]=!0:(Ff[e]=!0,!1)}function xs(e,t,a){if(av(t))if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var s=t.toLowerCase().slice(0,5);if(s!=="data-"&&s!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+a)}}function Ss(e,t,a){if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+a)}}function Rn(e,t,a,s){if(s===null)e.removeAttribute(a);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(t,a,""+s)}}function Kt(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function qf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function rv(e,t,a){var s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var o=s.get,c=s.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(p){a=""+p,c.call(this,p)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return a},setValue:function(p){a=""+p},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function mu(e){if(!e._valueTracker){var t=qf(e)?"checked":"value";e._valueTracker=rv(e,t,""+e[t])}}function Yf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),s="";return e&&(s=qf(e)?e.checked?"true":"false":e.value),e=s,e!==a?(t.setValue(e),!0):!1}function ws(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var sv=/[\n"\\]/g;function Zt(e){return e.replace(sv,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function gu(e,t,a,s,o,c,p,y){e.name="",p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"?e.type=p:e.removeAttribute("type"),t!=null?p==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Kt(t)):e.value!==""+Kt(t)&&(e.value=""+Kt(t)):p!=="submit"&&p!=="reset"||e.removeAttribute("value"),t!=null?yu(e,p,Kt(t)):a!=null?yu(e,p,Kt(a)):s!=null&&e.removeAttribute("value"),o==null&&c!=null&&(e.defaultChecked=!!c),o!=null&&(e.checked=o&&typeof o!="function"&&typeof o!="symbol"),y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?e.name=""+Kt(y):e.removeAttribute("name")}function Xf(e,t,a,s,o,c,p,y){if(c!=null&&typeof c!="function"&&typeof c!="symbol"&&typeof c!="boolean"&&(e.type=c),t!=null||a!=null){if(!(c!=="submit"&&c!=="reset"||t!=null)){mu(e);return}a=a!=null?""+Kt(a):"",t=t!=null?""+Kt(t):a,y||t===e.value||(e.value=t),e.defaultValue=t}s=s??o,s=typeof s!="function"&&typeof s!="symbol"&&!!s,e.checked=y?e.checked:!!s,e.defaultChecked=!!s,p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(e.name=p),mu(e)}function yu(e,t,a){t==="number"&&ws(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function fa(e,t,a,s){if(e=e.options,t){t={};for(var o=0;o<a.length;o++)t["$"+a[o]]=!0;for(a=0;a<e.length;a++)o=t.hasOwnProperty("$"+e[a].value),e[a].selected!==o&&(e[a].selected=o),o&&s&&(e[a].defaultSelected=!0)}else{for(a=""+Kt(a),t=null,o=0;o<e.length;o++){if(e[o].value===a){e[o].selected=!0,s&&(e[o].defaultSelected=!0);return}t!==null||e[o].disabled||(t=e[o])}t!==null&&(t.selected=!0)}}function Qf(e,t,a){if(t!=null&&(t=""+Kt(t),t!==e.value&&(e.value=t),a==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=a!=null?""+Kt(a):""}function Kf(e,t,a,s){if(t==null){if(s!=null){if(a!=null)throw Error(l(92));if(se(s)){if(1<s.length)throw Error(l(93));s=s[0]}a=s}a==null&&(a=""),t=a}a=Kt(t),e.defaultValue=a,s=e.textContent,s===a&&s!==""&&s!==null&&(e.value=s),mu(e)}function da(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}var lv=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Zf(e,t,a){var s=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?s?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":s?e.setProperty(t,a):typeof a!="number"||a===0||lv.has(t)?t==="float"?e.cssFloat=a:e[t]=(""+a).trim():e[t]=a+"px"}function Pf(e,t,a){if(t!=null&&typeof t!="object")throw Error(l(62));if(e=e.style,a!=null){for(var s in a)!a.hasOwnProperty(s)||t!=null&&t.hasOwnProperty(s)||(s.indexOf("--")===0?e.setProperty(s,""):s==="float"?e.cssFloat="":e[s]="");for(var o in t)s=t[o],t.hasOwnProperty(o)&&a[o]!==s&&Zf(e,o,s)}else for(var c in t)t.hasOwnProperty(c)&&Zf(e,c,t[c])}function vu(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var uv=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),ov=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Es(e){return ov.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Cn(){}var bu=null;function xu(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ha=null,pa=null;function Wf(e){var t=ua(e);if(t&&(e=t.stateNode)){var a=e[Dt]||null;e:switch(e=t.stateNode,t.type){case"input":if(gu(e,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),t=a.name,a.type==="radio"&&t!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Zt(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var s=a[t];if(s!==e&&s.form===e.form){var o=s[Dt]||null;if(!o)throw Error(l(90));gu(s,o.value,o.defaultValue,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name)}}for(t=0;t<a.length;t++)s=a[t],s.form===e.form&&Yf(s)}break e;case"textarea":Qf(e,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&fa(e,!!a.multiple,t,!1)}}}var Su=!1;function Jf(e,t,a){if(Su)return e(t,a);Su=!0;try{var s=e(t);return s}finally{if(Su=!1,(ha!==null||pa!==null)&&(cl(),ha&&(t=ha,e=pa,pa=ha=null,Wf(t),e)))for(t=0;t<e.length;t++)Wf(e[t])}}function cr(e,t){var a=e.stateNode;if(a===null)return null;var s=a[Dt]||null;if(s===null)return null;a=s[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(s=!s.disabled)||(e=e.type,s=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!s;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(l(231,t,typeof a));return a}var On=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wu=!1;if(On)try{var fr={};Object.defineProperty(fr,"passive",{get:function(){wu=!0}}),window.addEventListener("test",fr,fr),window.removeEventListener("test",fr,fr)}catch{wu=!1}var ei=null,Eu=null,As=null;function ed(){if(As)return As;var e,t=Eu,a=t.length,s,o="value"in ei?ei.value:ei.textContent,c=o.length;for(e=0;e<a&&t[e]===o[e];e++);var p=a-e;for(s=1;s<=p&&t[a-s]===o[c-s];s++);return As=o.slice(e,1<s?1-s:void 0)}function Ts(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Ms(){return!0}function td(){return!1}function Rt(e){function t(a,s,o,c,p){this._reactName=a,this._targetInst=o,this.type=s,this.nativeEvent=c,this.target=p,this.currentTarget=null;for(var y in e)e.hasOwnProperty(y)&&(a=e[y],this[y]=a?a(c):c[y]);return this.isDefaultPrevented=(c.defaultPrevented!=null?c.defaultPrevented:c.returnValue===!1)?Ms:td,this.isPropagationStopped=td,this}return b(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Ms)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Ms)},persist:function(){},isPersistent:Ms}),t}var Li={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ds=Rt(Li),dr=b({},Li,{view:0,detail:0}),cv=Rt(dr),Au,Tu,hr,Rs=b({},dr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Du,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==hr&&(hr&&e.type==="mousemove"?(Au=e.screenX-hr.screenX,Tu=e.screenY-hr.screenY):Tu=Au=0,hr=e),Au)},movementY:function(e){return"movementY"in e?e.movementY:Tu}}),nd=Rt(Rs),fv=b({},Rs,{dataTransfer:0}),dv=Rt(fv),hv=b({},dr,{relatedTarget:0}),Mu=Rt(hv),pv=b({},Li,{animationName:0,elapsedTime:0,pseudoElement:0}),mv=Rt(pv),gv=b({},Li,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),yv=Rt(gv),vv=b({},Li,{data:0}),id=Rt(vv),bv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},xv={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Sv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function wv(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Sv[e])?!!t[e]:!1}function Du(){return wv}var Ev=b({},dr,{key:function(e){if(e.key){var t=bv[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Ts(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?xv[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Du,charCode:function(e){return e.type==="keypress"?Ts(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ts(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Av=Rt(Ev),Tv=b({},Rs,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ad=Rt(Tv),Mv=b({},dr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Du}),Dv=Rt(Mv),Rv=b({},Li,{propertyName:0,elapsedTime:0,pseudoElement:0}),Cv=Rt(Rv),Ov=b({},Rs,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),zv=Rt(Ov),_v=b({},Li,{newState:0,oldState:0}),Uv=Rt(_v),Nv=[9,13,27,32],Ru=On&&"CompositionEvent"in window,pr=null;On&&"documentMode"in document&&(pr=document.documentMode);var Lv=On&&"TextEvent"in window&&!pr,rd=On&&(!Ru||pr&&8<pr&&11>=pr),sd=" ",ld=!1;function ud(e,t){switch(e){case"keyup":return Nv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function od(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ma=!1;function kv(e,t){switch(e){case"compositionend":return od(t);case"keypress":return t.which!==32?null:(ld=!0,sd);case"textInput":return e=t.data,e===sd&&ld?null:e;default:return null}}function jv(e,t){if(ma)return e==="compositionend"||!Ru&&ud(e,t)?(e=ed(),As=Eu=ei=null,ma=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return rd&&t.locale!=="ko"?null:t.data;default:return null}}var Gv={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function cd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Gv[e.type]:t==="textarea"}function fd(e,t,a,s){ha?pa?pa.push(s):pa=[s]:ha=s,t=yl(t,"onChange"),0<t.length&&(a=new Ds("onChange","change",null,a,s),e.push({event:a,listeners:t}))}var mr=null,gr=null;function Bv(e){Xp(e,0)}function Cs(e){var t=or(e);if(Yf(t))return e}function dd(e,t){if(e==="change")return t}var hd=!1;if(On){var Cu;if(On){var Ou="oninput"in document;if(!Ou){var pd=document.createElement("div");pd.setAttribute("oninput","return;"),Ou=typeof pd.oninput=="function"}Cu=Ou}else Cu=!1;hd=Cu&&(!document.documentMode||9<document.documentMode)}function md(){mr&&(mr.detachEvent("onpropertychange",gd),gr=mr=null)}function gd(e){if(e.propertyName==="value"&&Cs(gr)){var t=[];fd(t,gr,e,xu(e)),Jf(Bv,t)}}function $v(e,t,a){e==="focusin"?(md(),mr=t,gr=a,mr.attachEvent("onpropertychange",gd)):e==="focusout"&&md()}function Vv(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Cs(gr)}function Iv(e,t){if(e==="click")return Cs(t)}function Fv(e,t){if(e==="input"||e==="change")return Cs(t)}function Hv(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var kt=typeof Object.is=="function"?Object.is:Hv;function yr(e,t){if(kt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),s=Object.keys(t);if(a.length!==s.length)return!1;for(s=0;s<a.length;s++){var o=a[s];if(!ye.call(t,o)||!kt(e[o],t[o]))return!1}return!0}function yd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function vd(e,t){var a=yd(e);e=0;for(var s;a;){if(a.nodeType===3){if(s=e+a.textContent.length,e<=t&&s>=t)return{node:a,offset:t-e};e=s}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=yd(a)}}function bd(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?bd(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function xd(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=ws(e.document);t instanceof e.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)e=t.contentWindow;else break;t=ws(e.document)}return t}function zu(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var qv=On&&"documentMode"in document&&11>=document.documentMode,ga=null,_u=null,vr=null,Uu=!1;function Sd(e,t,a){var s=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Uu||ga==null||ga!==ws(s)||(s=ga,"selectionStart"in s&&zu(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),vr&&yr(vr,s)||(vr=s,s=yl(_u,"onSelect"),0<s.length&&(t=new Ds("onSelect","select",null,t,a),e.push({event:t,listeners:s}),t.target=ga)))}function ki(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var ya={animationend:ki("Animation","AnimationEnd"),animationiteration:ki("Animation","AnimationIteration"),animationstart:ki("Animation","AnimationStart"),transitionrun:ki("Transition","TransitionRun"),transitionstart:ki("Transition","TransitionStart"),transitioncancel:ki("Transition","TransitionCancel"),transitionend:ki("Transition","TransitionEnd")},Nu={},wd={};On&&(wd=document.createElement("div").style,"AnimationEvent"in window||(delete ya.animationend.animation,delete ya.animationiteration.animation,delete ya.animationstart.animation),"TransitionEvent"in window||delete ya.transitionend.transition);function ji(e){if(Nu[e])return Nu[e];if(!ya[e])return e;var t=ya[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in wd)return Nu[e]=t[a];return e}var Ed=ji("animationend"),Ad=ji("animationiteration"),Td=ji("animationstart"),Yv=ji("transitionrun"),Xv=ji("transitionstart"),Qv=ji("transitioncancel"),Md=ji("transitionend"),Dd=new Map,Lu="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Lu.push("scrollEnd");function hn(e,t){Dd.set(e,t),Ni(t,[e])}var Os=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Pt=[],va=0,ku=0;function zs(){for(var e=va,t=ku=va=0;t<e;){var a=Pt[t];Pt[t++]=null;var s=Pt[t];Pt[t++]=null;var o=Pt[t];Pt[t++]=null;var c=Pt[t];if(Pt[t++]=null,s!==null&&o!==null){var p=s.pending;p===null?o.next=o:(o.next=p.next,p.next=o),s.pending=o}c!==0&&Rd(a,o,c)}}function _s(e,t,a,s){Pt[va++]=e,Pt[va++]=t,Pt[va++]=a,Pt[va++]=s,ku|=s,e.lanes|=s,e=e.alternate,e!==null&&(e.lanes|=s)}function ju(e,t,a,s){return _s(e,t,a,s),Us(e)}function Gi(e,t){return _s(e,null,null,t),Us(e)}function Rd(e,t,a){e.lanes|=a;var s=e.alternate;s!==null&&(s.lanes|=a);for(var o=!1,c=e.return;c!==null;)c.childLanes|=a,s=c.alternate,s!==null&&(s.childLanes|=a),c.tag===22&&(e=c.stateNode,e===null||e._visibility&1||(o=!0)),e=c,c=c.return;return e.tag===3?(c=e.stateNode,o&&t!==null&&(o=31-tt(a),e=c.hiddenUpdates,s=e[o],s===null?e[o]=[t]:s.push(t),t.lane=a|536870912),c):null}function Us(e){if(50<$r)throw $r=0,Xo=null,Error(l(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ba={};function Kv(e,t,a,s){this.tag=e,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function jt(e,t,a,s){return new Kv(e,t,a,s)}function Gu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function zn(e,t){var a=e.alternate;return a===null?(a=jt(e.tag,t,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=t,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&65011712,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,t=e.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a.refCleanup=e.refCleanup,a}function Cd(e,t){e.flags&=65011714;var a=e.alternate;return a===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=a.childLanes,e.lanes=a.lanes,e.child=a.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=a.memoizedProps,e.memoizedState=a.memoizedState,e.updateQueue=a.updateQueue,e.type=a.type,t=a.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ns(e,t,a,s,o,c){var p=0;if(s=e,typeof e=="function")Gu(e)&&(p=1);else if(typeof e=="string")p=ex(e,a,K.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case j:return e=jt(31,a,t,o),e.elementType=j,e.lanes=c,e;case N:return Bi(a.children,o,c,t);case V:p=8,o|=24;break;case Z:return e=jt(12,a,t,o|2),e.elementType=Z,e.lanes=c,e;case P:return e=jt(13,a,t,o),e.elementType=P,e.lanes=c,e;case he:return e=jt(19,a,t,o),e.elementType=he,e.lanes=c,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case F:p=10;break e;case I:p=9;break e;case Y:p=11;break e;case M:p=14;break e;case E:p=16,s=null;break e}p=29,a=Error(l(130,e===null?"null":typeof e,"")),s=null}return t=jt(p,a,t,o),t.elementType=e,t.type=s,t.lanes=c,t}function Bi(e,t,a,s){return e=jt(7,e,s,t),e.lanes=a,e}function Bu(e,t,a){return e=jt(6,e,null,t),e.lanes=a,e}function Od(e){var t=jt(18,null,null,0);return t.stateNode=e,t}function $u(e,t,a){return t=jt(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var zd=new WeakMap;function Wt(e,t){if(typeof e=="object"&&e!==null){var a=zd.get(e);return a!==void 0?a:(t={value:e,source:t,stack:J(t)},zd.set(e,t),t)}return{value:e,source:t,stack:J(t)}}var xa=[],Sa=0,Ls=null,br=0,Jt=[],en=0,ti=null,vn=1,bn="";function _n(e,t){xa[Sa++]=br,xa[Sa++]=Ls,Ls=e,br=t}function _d(e,t,a){Jt[en++]=vn,Jt[en++]=bn,Jt[en++]=ti,ti=e;var s=vn;e=bn;var o=32-tt(s)-1;s&=~(1<<o),a+=1;var c=32-tt(t)+o;if(30<c){var p=o-o%5;c=(s&(1<<p)-1).toString(32),s>>=p,o-=p,vn=1<<32-tt(t)+o|a<<o|s,bn=c+e}else vn=1<<c|a<<o|s,bn=e}function Vu(e){e.return!==null&&(_n(e,1),_d(e,1,0))}function Iu(e){for(;e===Ls;)Ls=xa[--Sa],xa[Sa]=null,br=xa[--Sa],xa[Sa]=null;for(;e===ti;)ti=Jt[--en],Jt[en]=null,bn=Jt[--en],Jt[en]=null,vn=Jt[--en],Jt[en]=null}function Ud(e,t){Jt[en++]=vn,Jt[en++]=bn,Jt[en++]=ti,vn=t.id,bn=t.overflow,ti=e}var gt=null,Ie=null,Me=!1,ni=null,tn=!1,Fu=Error(l(519));function ii(e){var t=Error(l(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw xr(Wt(t,e)),Fu}function Nd(e){var t=e.stateNode,a=e.type,s=e.memoizedProps;switch(t[mt]=e,t[Dt]=s,a){case"dialog":Se("cancel",t),Se("close",t);break;case"iframe":case"object":case"embed":Se("load",t);break;case"video":case"audio":for(a=0;a<Ir.length;a++)Se(Ir[a],t);break;case"source":Se("error",t);break;case"img":case"image":case"link":Se("error",t),Se("load",t);break;case"details":Se("toggle",t);break;case"input":Se("invalid",t),Xf(t,s.value,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name,!0);break;case"select":Se("invalid",t);break;case"textarea":Se("invalid",t),Kf(t,s.value,s.defaultValue,s.children)}a=s.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||s.suppressHydrationWarning===!0||Pp(t.textContent,a)?(s.popover!=null&&(Se("beforetoggle",t),Se("toggle",t)),s.onScroll!=null&&Se("scroll",t),s.onScrollEnd!=null&&Se("scrollend",t),s.onClick!=null&&(t.onclick=Cn),t=!0):t=!1,t||ii(e,!0)}function Ld(e){for(gt=e.return;gt;)switch(gt.tag){case 5:case 31:case 13:tn=!1;return;case 27:case 3:tn=!0;return;default:gt=gt.return}}function wa(e){if(e!==gt)return!1;if(!Me)return Ld(e),Me=!0,!1;var t=e.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||uc(e.type,e.memoizedProps)),a=!a),a&&Ie&&ii(e),Ld(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Ie=sm(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Ie=sm(e)}else t===27?(t=Ie,yi(e.type)?(e=hc,hc=null,Ie=e):Ie=t):Ie=gt?an(e.stateNode.nextSibling):null;return!0}function $i(){Ie=gt=null,Me=!1}function Hu(){var e=ni;return e!==null&&(_t===null?_t=e:_t.push.apply(_t,e),ni=null),e}function xr(e){ni===null?ni=[e]:ni.push(e)}var qu=w(null),Vi=null,Un=null;function ai(e,t,a){q(qu,t._currentValue),t._currentValue=a}function Nn(e){e._currentValue=qu.current,U(qu)}function Yu(e,t,a){for(;e!==null;){var s=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,s!==null&&(s.childLanes|=t)):s!==null&&(s.childLanes&t)!==t&&(s.childLanes|=t),e===a)break;e=e.return}}function Xu(e,t,a,s){var o=e.child;for(o!==null&&(o.return=e);o!==null;){var c=o.dependencies;if(c!==null){var p=o.child;c=c.firstContext;e:for(;c!==null;){var y=c;c=o;for(var S=0;S<t.length;S++)if(y.context===t[S]){c.lanes|=a,y=c.alternate,y!==null&&(y.lanes|=a),Yu(c.return,a,e),s||(p=null);break e}c=y.next}}else if(o.tag===18){if(p=o.return,p===null)throw Error(l(341));p.lanes|=a,c=p.alternate,c!==null&&(c.lanes|=a),Yu(p,a,e),p=null}else p=o.child;if(p!==null)p.return=o;else for(p=o;p!==null;){if(p===e){p=null;break}if(o=p.sibling,o!==null){o.return=p.return,p=o;break}p=p.return}o=p}}function Ea(e,t,a,s){e=null;for(var o=t,c=!1;o!==null;){if(!c){if((o.flags&524288)!==0)c=!0;else if((o.flags&262144)!==0)break}if(o.tag===10){var p=o.alternate;if(p===null)throw Error(l(387));if(p=p.memoizedProps,p!==null){var y=o.type;kt(o.pendingProps.value,p.value)||(e!==null?e.push(y):e=[y])}}else if(o===me.current){if(p=o.alternate,p===null)throw Error(l(387));p.memoizedState.memoizedState!==o.memoizedState.memoizedState&&(e!==null?e.push(Xr):e=[Xr])}o=o.return}e!==null&&Xu(t,e,a,s),t.flags|=262144}function ks(e){for(e=e.firstContext;e!==null;){if(!kt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ii(e){Vi=e,Un=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function yt(e){return kd(Vi,e)}function js(e,t){return Vi===null&&Ii(e),kd(e,t)}function kd(e,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},Un===null){if(e===null)throw Error(l(308));Un=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Un=Un.next=t;return a}var Zv=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(a,s){e.push(s)}};this.abort=function(){t.aborted=!0,e.forEach(function(a){return a()})}},Pv=n.unstable_scheduleCallback,Wv=n.unstable_NormalPriority,rt={$$typeof:F,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Qu(){return{controller:new Zv,data:new Map,refCount:0}}function Sr(e){e.refCount--,e.refCount===0&&Pv(Wv,function(){e.controller.abort()})}var wr=null,Ku=0,Aa=0,Ta=null;function Jv(e,t){if(wr===null){var a=wr=[];Ku=0,Aa=Jo(),Ta={status:"pending",value:void 0,then:function(s){a.push(s)}}}return Ku++,t.then(jd,jd),t}function jd(){if(--Ku===0&&wr!==null){Ta!==null&&(Ta.status="fulfilled");var e=wr;wr=null,Aa=0,Ta=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function eb(e,t){var a=[],s={status:"pending",value:null,reason:null,then:function(o){a.push(o)}};return e.then(function(){s.status="fulfilled",s.value=t;for(var o=0;o<a.length;o++)(0,a[o])(t)},function(o){for(s.status="rejected",s.reason=o,o=0;o<a.length;o++)(0,a[o])(void 0)}),s}var Gd=R.S;R.S=function(e,t){Sp=Ve(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Jv(e,t),Gd!==null&&Gd(e,t)};var Fi=w(null);function Zu(){var e=Fi.current;return e!==null?e:Be.pooledCache}function Gs(e,t){t===null?q(Fi,Fi.current):q(Fi,t.pool)}function Bd(){var e=Zu();return e===null?null:{parent:rt._currentValue,pool:e}}var Ma=Error(l(460)),Pu=Error(l(474)),Bs=Error(l(542)),$s={then:function(){}};function $d(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Vd(e,t,a){switch(a=e[a],a===void 0?e.push(t):a!==t&&(t.then(Cn,Cn),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Fd(e),e;default:if(typeof t.status=="string")t.then(Cn,Cn);else{if(e=Be,e!==null&&100<e.shellSuspendCounter)throw Error(l(482));e=t,e.status="pending",e.then(function(s){if(t.status==="pending"){var o=t;o.status="fulfilled",o.value=s}},function(s){if(t.status==="pending"){var o=t;o.status="rejected",o.reason=s}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Fd(e),e}throw qi=t,Ma}}function Hi(e){try{var t=e._init;return t(e._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(qi=a,Ma):a}}var qi=null;function Id(){if(qi===null)throw Error(l(459));var e=qi;return qi=null,e}function Fd(e){if(e===Ma||e===Bs)throw Error(l(483))}var Da=null,Er=0;function Vs(e){var t=Er;return Er+=1,Da===null&&(Da=[]),Vd(Da,e,t)}function Ar(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Is(e,t){throw t.$$typeof===D?Error(l(525)):(e=Object.prototype.toString.call(t),Error(l(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Hd(e){function t(T,A){if(e){var C=T.deletions;C===null?(T.deletions=[A],T.flags|=16):C.push(A)}}function a(T,A){if(!e)return null;for(;A!==null;)t(T,A),A=A.sibling;return null}function s(T){for(var A=new Map;T!==null;)T.key!==null?A.set(T.key,T):A.set(T.index,T),T=T.sibling;return A}function o(T,A){return T=zn(T,A),T.index=0,T.sibling=null,T}function c(T,A,C){return T.index=C,e?(C=T.alternate,C!==null?(C=C.index,C<A?(T.flags|=67108866,A):C):(T.flags|=67108866,A)):(T.flags|=1048576,A)}function p(T){return e&&T.alternate===null&&(T.flags|=67108866),T}function y(T,A,C,G){return A===null||A.tag!==6?(A=Bu(C,T.mode,G),A.return=T,A):(A=o(A,C),A.return=T,A)}function S(T,A,C,G){var ue=C.type;return ue===N?L(T,A,C.props.children,G,C.key):A!==null&&(A.elementType===ue||typeof ue=="object"&&ue!==null&&ue.$$typeof===E&&Hi(ue)===A.type)?(A=o(A,C.props),Ar(A,C),A.return=T,A):(A=Ns(C.type,C.key,C.props,null,T.mode,G),Ar(A,C),A.return=T,A)}function O(T,A,C,G){return A===null||A.tag!==4||A.stateNode.containerInfo!==C.containerInfo||A.stateNode.implementation!==C.implementation?(A=$u(C,T.mode,G),A.return=T,A):(A=o(A,C.children||[]),A.return=T,A)}function L(T,A,C,G,ue){return A===null||A.tag!==7?(A=Bi(C,T.mode,G,ue),A.return=T,A):(A=o(A,C),A.return=T,A)}function B(T,A,C){if(typeof A=="string"&&A!==""||typeof A=="number"||typeof A=="bigint")return A=Bu(""+A,T.mode,C),A.return=T,A;if(typeof A=="object"&&A!==null){switch(A.$$typeof){case $:return C=Ns(A.type,A.key,A.props,null,T.mode,C),Ar(C,A),C.return=T,C;case k:return A=$u(A,T.mode,C),A.return=T,A;case E:return A=Hi(A),B(T,A,C)}if(se(A)||le(A))return A=Bi(A,T.mode,C,null),A.return=T,A;if(typeof A.then=="function")return B(T,Vs(A),C);if(A.$$typeof===F)return B(T,js(T,A),C);Is(T,A)}return null}function z(T,A,C,G){var ue=A!==null?A.key:null;if(typeof C=="string"&&C!==""||typeof C=="number"||typeof C=="bigint")return ue!==null?null:y(T,A,""+C,G);if(typeof C=="object"&&C!==null){switch(C.$$typeof){case $:return C.key===ue?S(T,A,C,G):null;case k:return C.key===ue?O(T,A,C,G):null;case E:return C=Hi(C),z(T,A,C,G)}if(se(C)||le(C))return ue!==null?null:L(T,A,C,G,null);if(typeof C.then=="function")return z(T,A,Vs(C),G);if(C.$$typeof===F)return z(T,A,js(T,C),G);Is(T,C)}return null}function _(T,A,C,G,ue){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return T=T.get(C)||null,y(A,T,""+G,ue);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case $:return T=T.get(G.key===null?C:G.key)||null,S(A,T,G,ue);case k:return T=T.get(G.key===null?C:G.key)||null,O(A,T,G,ue);case E:return G=Hi(G),_(T,A,C,G,ue)}if(se(G)||le(G))return T=T.get(C)||null,L(A,T,G,ue,null);if(typeof G.then=="function")return _(T,A,C,Vs(G),ue);if(G.$$typeof===F)return _(T,A,C,js(A,G),ue);Is(A,G)}return null}function ne(T,A,C,G){for(var ue=null,Oe=null,re=A,ve=A=0,Ae=null;re!==null&&ve<C.length;ve++){re.index>ve?(Ae=re,re=null):Ae=re.sibling;var ze=z(T,re,C[ve],G);if(ze===null){re===null&&(re=Ae);break}e&&re&&ze.alternate===null&&t(T,re),A=c(ze,A,ve),Oe===null?ue=ze:Oe.sibling=ze,Oe=ze,re=Ae}if(ve===C.length)return a(T,re),Me&&_n(T,ve),ue;if(re===null){for(;ve<C.length;ve++)re=B(T,C[ve],G),re!==null&&(A=c(re,A,ve),Oe===null?ue=re:Oe.sibling=re,Oe=re);return Me&&_n(T,ve),ue}for(re=s(re);ve<C.length;ve++)Ae=_(re,T,ve,C[ve],G),Ae!==null&&(e&&Ae.alternate!==null&&re.delete(Ae.key===null?ve:Ae.key),A=c(Ae,A,ve),Oe===null?ue=Ae:Oe.sibling=Ae,Oe=Ae);return e&&re.forEach(function(wi){return t(T,wi)}),Me&&_n(T,ve),ue}function ce(T,A,C,G){if(C==null)throw Error(l(151));for(var ue=null,Oe=null,re=A,ve=A=0,Ae=null,ze=C.next();re!==null&&!ze.done;ve++,ze=C.next()){re.index>ve?(Ae=re,re=null):Ae=re.sibling;var wi=z(T,re,ze.value,G);if(wi===null){re===null&&(re=Ae);break}e&&re&&wi.alternate===null&&t(T,re),A=c(wi,A,ve),Oe===null?ue=wi:Oe.sibling=wi,Oe=wi,re=Ae}if(ze.done)return a(T,re),Me&&_n(T,ve),ue;if(re===null){for(;!ze.done;ve++,ze=C.next())ze=B(T,ze.value,G),ze!==null&&(A=c(ze,A,ve),Oe===null?ue=ze:Oe.sibling=ze,Oe=ze);return Me&&_n(T,ve),ue}for(re=s(re);!ze.done;ve++,ze=C.next())ze=_(re,T,ve,ze.value,G),ze!==null&&(e&&ze.alternate!==null&&re.delete(ze.key===null?ve:ze.key),A=c(ze,A,ve),Oe===null?ue=ze:Oe.sibling=ze,Oe=ze);return e&&re.forEach(function(fx){return t(T,fx)}),Me&&_n(T,ve),ue}function Ge(T,A,C,G){if(typeof C=="object"&&C!==null&&C.type===N&&C.key===null&&(C=C.props.children),typeof C=="object"&&C!==null){switch(C.$$typeof){case $:e:{for(var ue=C.key;A!==null;){if(A.key===ue){if(ue=C.type,ue===N){if(A.tag===7){a(T,A.sibling),G=o(A,C.props.children),G.return=T,T=G;break e}}else if(A.elementType===ue||typeof ue=="object"&&ue!==null&&ue.$$typeof===E&&Hi(ue)===A.type){a(T,A.sibling),G=o(A,C.props),Ar(G,C),G.return=T,T=G;break e}a(T,A);break}else t(T,A);A=A.sibling}C.type===N?(G=Bi(C.props.children,T.mode,G,C.key),G.return=T,T=G):(G=Ns(C.type,C.key,C.props,null,T.mode,G),Ar(G,C),G.return=T,T=G)}return p(T);case k:e:{for(ue=C.key;A!==null;){if(A.key===ue)if(A.tag===4&&A.stateNode.containerInfo===C.containerInfo&&A.stateNode.implementation===C.implementation){a(T,A.sibling),G=o(A,C.children||[]),G.return=T,T=G;break e}else{a(T,A);break}else t(T,A);A=A.sibling}G=$u(C,T.mode,G),G.return=T,T=G}return p(T);case E:return C=Hi(C),Ge(T,A,C,G)}if(se(C))return ne(T,A,C,G);if(le(C)){if(ue=le(C),typeof ue!="function")throw Error(l(150));return C=ue.call(C),ce(T,A,C,G)}if(typeof C.then=="function")return Ge(T,A,Vs(C),G);if(C.$$typeof===F)return Ge(T,A,js(T,C),G);Is(T,C)}return typeof C=="string"&&C!==""||typeof C=="number"||typeof C=="bigint"?(C=""+C,A!==null&&A.tag===6?(a(T,A.sibling),G=o(A,C),G.return=T,T=G):(a(T,A),G=Bu(C,T.mode,G),G.return=T,T=G),p(T)):a(T,A)}return function(T,A,C,G){try{Er=0;var ue=Ge(T,A,C,G);return Da=null,ue}catch(re){if(re===Ma||re===Bs)throw re;var Oe=jt(29,re,null,T.mode);return Oe.lanes=G,Oe.return=T,Oe}}}var Yi=Hd(!0),qd=Hd(!1),ri=!1;function Wu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ju(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function si(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function li(e,t,a){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(_e&2)!==0){var o=s.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),s.pending=t,t=Us(e),Rd(e,null,a),t}return _s(e,s,t,a),Us(e)}function Tr(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var s=t.lanes;s&=e.pendingLanes,a|=s,t.lanes=a,kf(e,a)}}function eo(e,t){var a=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,a===s)){var o=null,c=null;if(a=a.firstBaseUpdate,a!==null){do{var p={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};c===null?o=c=p:c=c.next=p,a=a.next}while(a!==null);c===null?o=c=t:c=c.next=t}else o=c=t;a={baseState:s.baseState,firstBaseUpdate:o,lastBaseUpdate:c,shared:s.shared,callbacks:s.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}var to=!1;function Mr(){if(to){var e=Ta;if(e!==null)throw e}}function Dr(e,t,a,s){to=!1;var o=e.updateQueue;ri=!1;var c=o.firstBaseUpdate,p=o.lastBaseUpdate,y=o.shared.pending;if(y!==null){o.shared.pending=null;var S=y,O=S.next;S.next=null,p===null?c=O:p.next=O,p=S;var L=e.alternate;L!==null&&(L=L.updateQueue,y=L.lastBaseUpdate,y!==p&&(y===null?L.firstBaseUpdate=O:y.next=O,L.lastBaseUpdate=S))}if(c!==null){var B=o.baseState;p=0,L=O=S=null,y=c;do{var z=y.lane&-536870913,_=z!==y.lane;if(_?(Ee&z)===z:(s&z)===z){z!==0&&z===Aa&&(to=!0),L!==null&&(L=L.next={lane:0,tag:y.tag,payload:y.payload,callback:null,next:null});e:{var ne=e,ce=y;z=t;var Ge=a;switch(ce.tag){case 1:if(ne=ce.payload,typeof ne=="function"){B=ne.call(Ge,B,z);break e}B=ne;break e;case 3:ne.flags=ne.flags&-65537|128;case 0:if(ne=ce.payload,z=typeof ne=="function"?ne.call(Ge,B,z):ne,z==null)break e;B=b({},B,z);break e;case 2:ri=!0}}z=y.callback,z!==null&&(e.flags|=64,_&&(e.flags|=8192),_=o.callbacks,_===null?o.callbacks=[z]:_.push(z))}else _={lane:z,tag:y.tag,payload:y.payload,callback:y.callback,next:null},L===null?(O=L=_,S=B):L=L.next=_,p|=z;if(y=y.next,y===null){if(y=o.shared.pending,y===null)break;_=y,y=_.next,_.next=null,o.lastBaseUpdate=_,o.shared.pending=null}}while(!0);L===null&&(S=B),o.baseState=S,o.firstBaseUpdate=O,o.lastBaseUpdate=L,c===null&&(o.shared.lanes=0),di|=p,e.lanes=p,e.memoizedState=B}}function Yd(e,t){if(typeof e!="function")throw Error(l(191,e));e.call(t)}function Xd(e,t){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)Yd(a[e],t)}var Ra=w(null),Fs=w(0);function Qd(e,t){e=Fn,q(Fs,e),q(Ra,t),Fn=e|t.baseLanes}function no(){q(Fs,Fn),q(Ra,Ra.current)}function io(){Fn=Fs.current,U(Ra),U(Fs)}var Gt=w(null),nn=null;function ui(e){var t=e.alternate;q(nt,nt.current&1),q(Gt,e),nn===null&&(t===null||Ra.current!==null||t.memoizedState!==null)&&(nn=e)}function ao(e){q(nt,nt.current),q(Gt,e),nn===null&&(nn=e)}function Kd(e){e.tag===22?(q(nt,nt.current),q(Gt,e),nn===null&&(nn=e)):oi()}function oi(){q(nt,nt.current),q(Gt,Gt.current)}function Bt(e){U(Gt),nn===e&&(nn=null),U(nt)}var nt=w(0);function Hs(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||fc(a)||dc(a)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Ln=0,ge=null,ke=null,st=null,qs=!1,Ca=!1,Xi=!1,Ys=0,Rr=0,Oa=null,tb=0;function We(){throw Error(l(321))}function ro(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!kt(e[a],t[a]))return!1;return!0}function so(e,t,a,s,o,c){return Ln=c,ge=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,R.H=e===null||e.memoizedState===null?_h:wo,Xi=!1,c=a(s,o),Xi=!1,Ca&&(c=Pd(t,a,s,o)),Zd(e),c}function Zd(e){R.H=zr;var t=ke!==null&&ke.next!==null;if(Ln=0,st=ke=ge=null,qs=!1,Rr=0,Oa=null,t)throw Error(l(300));e===null||lt||(e=e.dependencies,e!==null&&ks(e)&&(lt=!0))}function Pd(e,t,a,s){ge=e;var o=0;do{if(Ca&&(Oa=null),Rr=0,Ca=!1,25<=o)throw Error(l(301));if(o+=1,st=ke=null,e.updateQueue!=null){var c=e.updateQueue;c.lastEffect=null,c.events=null,c.stores=null,c.memoCache!=null&&(c.memoCache.index=0)}R.H=Uh,c=t(a,s)}while(Ca);return c}function nb(){var e=R.H,t=e.useState()[0];return t=typeof t.then=="function"?Cr(t):t,e=e.useState()[0],(ke!==null?ke.memoizedState:null)!==e&&(ge.flags|=1024),t}function lo(){var e=Ys!==0;return Ys=0,e}function uo(e,t,a){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a}function oo(e){if(qs){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}qs=!1}Ln=0,st=ke=ge=null,Ca=!1,Rr=Ys=0,Oa=null}function Tt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return st===null?ge.memoizedState=st=e:st=st.next=e,st}function it(){if(ke===null){var e=ge.alternate;e=e!==null?e.memoizedState:null}else e=ke.next;var t=st===null?ge.memoizedState:st.next;if(t!==null)st=t,ke=e;else{if(e===null)throw ge.alternate===null?Error(l(467)):Error(l(310));ke=e,e={memoizedState:ke.memoizedState,baseState:ke.baseState,baseQueue:ke.baseQueue,queue:ke.queue,next:null},st===null?ge.memoizedState=st=e:st=st.next=e}return st}function Xs(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Cr(e){var t=Rr;return Rr+=1,Oa===null&&(Oa=[]),e=Vd(Oa,e,t),t=ge,(st===null?t.memoizedState:st.next)===null&&(t=t.alternate,R.H=t===null||t.memoizedState===null?_h:wo),e}function Qs(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Cr(e);if(e.$$typeof===F)return yt(e)}throw Error(l(438,String(e)))}function co(e){var t=null,a=ge.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var s=ge.alternate;s!==null&&(s=s.updateQueue,s!==null&&(s=s.memoCache,s!=null&&(t={data:s.data.map(function(o){return o.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=Xs(),ge.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(e),s=0;s<e;s++)a[s]=W;return t.index++,a}function kn(e,t){return typeof t=="function"?t(e):t}function Ks(e){var t=it();return fo(t,ke,e)}function fo(e,t,a){var s=e.queue;if(s===null)throw Error(l(311));s.lastRenderedReducer=a;var o=e.baseQueue,c=s.pending;if(c!==null){if(o!==null){var p=o.next;o.next=c.next,c.next=p}t.baseQueue=o=c,s.pending=null}if(c=e.baseState,o===null)e.memoizedState=c;else{t=o.next;var y=p=null,S=null,O=t,L=!1;do{var B=O.lane&-536870913;if(B!==O.lane?(Ee&B)===B:(Ln&B)===B){var z=O.revertLane;if(z===0)S!==null&&(S=S.next={lane:0,revertLane:0,gesture:null,action:O.action,hasEagerState:O.hasEagerState,eagerState:O.eagerState,next:null}),B===Aa&&(L=!0);else if((Ln&z)===z){O=O.next,z===Aa&&(L=!0);continue}else B={lane:0,revertLane:O.revertLane,gesture:null,action:O.action,hasEagerState:O.hasEagerState,eagerState:O.eagerState,next:null},S===null?(y=S=B,p=c):S=S.next=B,ge.lanes|=z,di|=z;B=O.action,Xi&&a(c,B),c=O.hasEagerState?O.eagerState:a(c,B)}else z={lane:B,revertLane:O.revertLane,gesture:O.gesture,action:O.action,hasEagerState:O.hasEagerState,eagerState:O.eagerState,next:null},S===null?(y=S=z,p=c):S=S.next=z,ge.lanes|=B,di|=B;O=O.next}while(O!==null&&O!==t);if(S===null?p=c:S.next=y,!kt(c,e.memoizedState)&&(lt=!0,L&&(a=Ta,a!==null)))throw a;e.memoizedState=c,e.baseState=p,e.baseQueue=S,s.lastRenderedState=c}return o===null&&(s.lanes=0),[e.memoizedState,s.dispatch]}function ho(e){var t=it(),a=t.queue;if(a===null)throw Error(l(311));a.lastRenderedReducer=e;var s=a.dispatch,o=a.pending,c=t.memoizedState;if(o!==null){a.pending=null;var p=o=o.next;do c=e(c,p.action),p=p.next;while(p!==o);kt(c,t.memoizedState)||(lt=!0),t.memoizedState=c,t.baseQueue===null&&(t.baseState=c),a.lastRenderedState=c}return[c,s]}function Wd(e,t,a){var s=ge,o=it(),c=Me;if(c){if(a===void 0)throw Error(l(407));a=a()}else a=t();var p=!kt((ke||o).memoizedState,a);if(p&&(o.memoizedState=a,lt=!0),o=o.queue,go(th.bind(null,s,o,e),[e]),o.getSnapshot!==t||p||st!==null&&st.memoizedState.tag&1){if(s.flags|=2048,za(9,{destroy:void 0},eh.bind(null,s,o,a,t),null),Be===null)throw Error(l(349));c||(Ln&127)!==0||Jd(s,t,a)}return a}function Jd(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=ge.updateQueue,t===null?(t=Xs(),ge.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function eh(e,t,a,s){t.value=a,t.getSnapshot=s,nh(t)&&ih(e)}function th(e,t,a){return a(function(){nh(t)&&ih(e)})}function nh(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!kt(e,a)}catch{return!0}}function ih(e){var t=Gi(e,2);t!==null&&Ut(t,e,2)}function po(e){var t=Tt();if(typeof e=="function"){var a=e;if(e=a(),Xi){St(!0);try{a()}finally{St(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:kn,lastRenderedState:e},t}function ah(e,t,a,s){return e.baseState=a,fo(e,ke,typeof s=="function"?s:kn)}function ib(e,t,a,s,o){if(Ws(e))throw Error(l(485));if(e=t.action,e!==null){var c={payload:o,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(p){c.listeners.push(p)}};R.T!==null?a(!0):c.isTransition=!1,s(c),a=t.pending,a===null?(c.next=t.pending=c,rh(t,c)):(c.next=a.next,t.pending=a.next=c)}}function rh(e,t){var a=t.action,s=t.payload,o=e.state;if(t.isTransition){var c=R.T,p={};R.T=p;try{var y=a(o,s),S=R.S;S!==null&&S(p,y),sh(e,t,y)}catch(O){mo(e,t,O)}finally{c!==null&&p.types!==null&&(c.types=p.types),R.T=c}}else try{c=a(o,s),sh(e,t,c)}catch(O){mo(e,t,O)}}function sh(e,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(s){lh(e,t,s)},function(s){return mo(e,t,s)}):lh(e,t,a)}function lh(e,t,a){t.status="fulfilled",t.value=a,uh(t),e.state=a,t=e.pending,t!==null&&(a=t.next,a===t?e.pending=null:(a=a.next,t.next=a,rh(e,a)))}function mo(e,t,a){var s=e.pending;if(e.pending=null,s!==null){s=s.next;do t.status="rejected",t.reason=a,uh(t),t=t.next;while(t!==s)}e.action=null}function uh(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function oh(e,t){return t}function ch(e,t){if(Me){var a=Be.formState;if(a!==null){e:{var s=ge;if(Me){if(Ie){t:{for(var o=Ie,c=tn;o.nodeType!==8;){if(!c){o=null;break t}if(o=an(o.nextSibling),o===null){o=null;break t}}c=o.data,o=c==="F!"||c==="F"?o:null}if(o){Ie=an(o.nextSibling),s=o.data==="F!";break e}}ii(s)}s=!1}s&&(t=a[0])}}return a=Tt(),a.memoizedState=a.baseState=t,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:oh,lastRenderedState:t},a.queue=s,a=Ch.bind(null,ge,s),s.dispatch=a,s=po(!1),c=So.bind(null,ge,!1,s.queue),s=Tt(),o={state:t,dispatch:null,action:e,pending:null},s.queue=o,a=ib.bind(null,ge,o,c,a),o.dispatch=a,s.memoizedState=e,[t,a,!1]}function fh(e){var t=it();return dh(t,ke,e)}function dh(e,t,a){if(t=fo(e,t,oh)[0],e=Ks(kn)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var s=Cr(t)}catch(p){throw p===Ma?Bs:p}else s=t;t=it();var o=t.queue,c=o.dispatch;return a!==t.memoizedState&&(ge.flags|=2048,za(9,{destroy:void 0},ab.bind(null,o,a),null)),[s,c,e]}function ab(e,t){e.action=t}function hh(e){var t=it(),a=ke;if(a!==null)return dh(t,a,e);it(),t=t.memoizedState,a=it();var s=a.queue.dispatch;return a.memoizedState=e,[t,s,!1]}function za(e,t,a,s){return e={tag:e,create:a,deps:s,inst:t,next:null},t=ge.updateQueue,t===null&&(t=Xs(),ge.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=e.next=e:(s=a.next,a.next=e,e.next=s,t.lastEffect=e),e}function ph(){return it().memoizedState}function Zs(e,t,a,s){var o=Tt();ge.flags|=e,o.memoizedState=za(1|t,{destroy:void 0},a,s===void 0?null:s)}function Ps(e,t,a,s){var o=it();s=s===void 0?null:s;var c=o.memoizedState.inst;ke!==null&&s!==null&&ro(s,ke.memoizedState.deps)?o.memoizedState=za(t,c,a,s):(ge.flags|=e,o.memoizedState=za(1|t,c,a,s))}function mh(e,t){Zs(8390656,8,e,t)}function go(e,t){Ps(2048,8,e,t)}function rb(e){ge.flags|=4;var t=ge.updateQueue;if(t===null)t=Xs(),ge.updateQueue=t,t.events=[e];else{var a=t.events;a===null?t.events=[e]:a.push(e)}}function gh(e){var t=it().memoizedState;return rb({ref:t,nextImpl:e}),function(){if((_e&2)!==0)throw Error(l(440));return t.impl.apply(void 0,arguments)}}function yh(e,t){return Ps(4,2,e,t)}function vh(e,t){return Ps(4,4,e,t)}function bh(e,t){if(typeof t=="function"){e=e();var a=t(e);return function(){typeof a=="function"?a():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function xh(e,t,a){a=a!=null?a.concat([e]):null,Ps(4,4,bh.bind(null,t,e),a)}function yo(){}function Sh(e,t){var a=it();t=t===void 0?null:t;var s=a.memoizedState;return t!==null&&ro(t,s[1])?s[0]:(a.memoizedState=[e,t],e)}function wh(e,t){var a=it();t=t===void 0?null:t;var s=a.memoizedState;if(t!==null&&ro(t,s[1]))return s[0];if(s=e(),Xi){St(!0);try{e()}finally{St(!1)}}return a.memoizedState=[s,t],s}function vo(e,t,a){return a===void 0||(Ln&1073741824)!==0&&(Ee&261930)===0?e.memoizedState=t:(e.memoizedState=a,e=Ep(),ge.lanes|=e,di|=e,a)}function Eh(e,t,a,s){return kt(a,t)?a:Ra.current!==null?(e=vo(e,a,s),kt(e,t)||(lt=!0),e):(Ln&42)===0||(Ln&1073741824)!==0&&(Ee&261930)===0?(lt=!0,e.memoizedState=a):(e=Ep(),ge.lanes|=e,di|=e,t)}function Ah(e,t,a,s,o){var c=H.p;H.p=c!==0&&8>c?c:8;var p=R.T,y={};R.T=y,So(e,!1,t,a);try{var S=o(),O=R.S;if(O!==null&&O(y,S),S!==null&&typeof S=="object"&&typeof S.then=="function"){var L=eb(S,s);Or(e,t,L,It(e))}else Or(e,t,s,It(e))}catch(B){Or(e,t,{then:function(){},status:"rejected",reason:B},It())}finally{H.p=c,p!==null&&y.types!==null&&(p.types=y.types),R.T=p}}function sb(){}function bo(e,t,a,s){if(e.tag!==5)throw Error(l(476));var o=Th(e).queue;Ah(e,o,t,ae,a===null?sb:function(){return Mh(e),a(s)})}function Th(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:kn,lastRenderedState:ae},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:kn,lastRenderedState:a},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Mh(e){var t=Th(e);t.next===null&&(t=e.alternate.memoizedState),Or(e,t.next.queue,{},It())}function xo(){return yt(Xr)}function Dh(){return it().memoizedState}function Rh(){return it().memoizedState}function lb(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var a=It();e=si(a);var s=li(t,e,a);s!==null&&(Ut(s,t,a),Tr(s,t,a)),t={cache:Qu()},e.payload=t;return}t=t.return}}function ub(e,t,a){var s=It();a={lane:s,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Ws(e)?Oh(t,a):(a=ju(e,t,a,s),a!==null&&(Ut(a,e,s),zh(a,t,s)))}function Ch(e,t,a){var s=It();Or(e,t,a,s)}function Or(e,t,a,s){var o={lane:s,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Ws(e))Oh(t,o);else{var c=e.alternate;if(e.lanes===0&&(c===null||c.lanes===0)&&(c=t.lastRenderedReducer,c!==null))try{var p=t.lastRenderedState,y=c(p,a);if(o.hasEagerState=!0,o.eagerState=y,kt(y,p))return _s(e,t,o,0),Be===null&&zs(),!1}catch{}if(a=ju(e,t,o,s),a!==null)return Ut(a,e,s),zh(a,t,s),!0}return!1}function So(e,t,a,s){if(s={lane:2,revertLane:Jo(),gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Ws(e)){if(t)throw Error(l(479))}else t=ju(e,a,s,2),t!==null&&Ut(t,e,2)}function Ws(e){var t=e.alternate;return e===ge||t!==null&&t===ge}function Oh(e,t){Ca=qs=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function zh(e,t,a){if((a&4194048)!==0){var s=t.lanes;s&=e.pendingLanes,a|=s,t.lanes=a,kf(e,a)}}var zr={readContext:yt,use:Qs,useCallback:We,useContext:We,useEffect:We,useImperativeHandle:We,useLayoutEffect:We,useInsertionEffect:We,useMemo:We,useReducer:We,useRef:We,useState:We,useDebugValue:We,useDeferredValue:We,useTransition:We,useSyncExternalStore:We,useId:We,useHostTransitionStatus:We,useFormState:We,useActionState:We,useOptimistic:We,useMemoCache:We,useCacheRefresh:We};zr.useEffectEvent=We;var _h={readContext:yt,use:Qs,useCallback:function(e,t){return Tt().memoizedState=[e,t===void 0?null:t],e},useContext:yt,useEffect:mh,useImperativeHandle:function(e,t,a){a=a!=null?a.concat([e]):null,Zs(4194308,4,bh.bind(null,t,e),a)},useLayoutEffect:function(e,t){return Zs(4194308,4,e,t)},useInsertionEffect:function(e,t){Zs(4,2,e,t)},useMemo:function(e,t){var a=Tt();t=t===void 0?null:t;var s=e();if(Xi){St(!0);try{e()}finally{St(!1)}}return a.memoizedState=[s,t],s},useReducer:function(e,t,a){var s=Tt();if(a!==void 0){var o=a(t);if(Xi){St(!0);try{a(t)}finally{St(!1)}}}else o=t;return s.memoizedState=s.baseState=o,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:o},s.queue=e,e=e.dispatch=ub.bind(null,ge,e),[s.memoizedState,e]},useRef:function(e){var t=Tt();return e={current:e},t.memoizedState=e},useState:function(e){e=po(e);var t=e.queue,a=Ch.bind(null,ge,t);return t.dispatch=a,[e.memoizedState,a]},useDebugValue:yo,useDeferredValue:function(e,t){var a=Tt();return vo(a,e,t)},useTransition:function(){var e=po(!1);return e=Ah.bind(null,ge,e.queue,!0,!1),Tt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,a){var s=ge,o=Tt();if(Me){if(a===void 0)throw Error(l(407));a=a()}else{if(a=t(),Be===null)throw Error(l(349));(Ee&127)!==0||Jd(s,t,a)}o.memoizedState=a;var c={value:a,getSnapshot:t};return o.queue=c,mh(th.bind(null,s,c,e),[e]),s.flags|=2048,za(9,{destroy:void 0},eh.bind(null,s,c,a,t),null),a},useId:function(){var e=Tt(),t=Be.identifierPrefix;if(Me){var a=bn,s=vn;a=(s&~(1<<32-tt(s)-1)).toString(32)+a,t="_"+t+"R_"+a,a=Ys++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=tb++,t="_"+t+"r_"+a.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:xo,useFormState:ch,useActionState:ch,useOptimistic:function(e){var t=Tt();t.memoizedState=t.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=So.bind(null,ge,!0,a),a.dispatch=t,[e,t]},useMemoCache:co,useCacheRefresh:function(){return Tt().memoizedState=lb.bind(null,ge)},useEffectEvent:function(e){var t=Tt(),a={impl:e};return t.memoizedState=a,function(){if((_e&2)!==0)throw Error(l(440));return a.impl.apply(void 0,arguments)}}},wo={readContext:yt,use:Qs,useCallback:Sh,useContext:yt,useEffect:go,useImperativeHandle:xh,useInsertionEffect:yh,useLayoutEffect:vh,useMemo:wh,useReducer:Ks,useRef:ph,useState:function(){return Ks(kn)},useDebugValue:yo,useDeferredValue:function(e,t){var a=it();return Eh(a,ke.memoizedState,e,t)},useTransition:function(){var e=Ks(kn)[0],t=it().memoizedState;return[typeof e=="boolean"?e:Cr(e),t]},useSyncExternalStore:Wd,useId:Dh,useHostTransitionStatus:xo,useFormState:fh,useActionState:fh,useOptimistic:function(e,t){var a=it();return ah(a,ke,e,t)},useMemoCache:co,useCacheRefresh:Rh};wo.useEffectEvent=gh;var Uh={readContext:yt,use:Qs,useCallback:Sh,useContext:yt,useEffect:go,useImperativeHandle:xh,useInsertionEffect:yh,useLayoutEffect:vh,useMemo:wh,useReducer:ho,useRef:ph,useState:function(){return ho(kn)},useDebugValue:yo,useDeferredValue:function(e,t){var a=it();return ke===null?vo(a,e,t):Eh(a,ke.memoizedState,e,t)},useTransition:function(){var e=ho(kn)[0],t=it().memoizedState;return[typeof e=="boolean"?e:Cr(e),t]},useSyncExternalStore:Wd,useId:Dh,useHostTransitionStatus:xo,useFormState:hh,useActionState:hh,useOptimistic:function(e,t){var a=it();return ke!==null?ah(a,ke,e,t):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:co,useCacheRefresh:Rh};Uh.useEffectEvent=gh;function Eo(e,t,a,s){t=e.memoizedState,a=a(s,t),a=a==null?t:b({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Ao={enqueueSetState:function(e,t,a){e=e._reactInternals;var s=It(),o=si(s);o.payload=t,a!=null&&(o.callback=a),t=li(e,o,s),t!==null&&(Ut(t,e,s),Tr(t,e,s))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var s=It(),o=si(s);o.tag=1,o.payload=t,a!=null&&(o.callback=a),t=li(e,o,s),t!==null&&(Ut(t,e,s),Tr(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=It(),s=si(a);s.tag=2,t!=null&&(s.callback=t),t=li(e,s,a),t!==null&&(Ut(t,e,a),Tr(t,e,a))}};function Nh(e,t,a,s,o,c,p){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(s,c,p):t.prototype&&t.prototype.isPureReactComponent?!yr(a,s)||!yr(o,c):!0}function Lh(e,t,a,s){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,s),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,s),t.state!==e&&Ao.enqueueReplaceState(t,t.state,null)}function Qi(e,t){var a=t;if("ref"in t){a={};for(var s in t)s!=="ref"&&(a[s]=t[s])}if(e=e.defaultProps){a===t&&(a=b({},a));for(var o in e)a[o]===void 0&&(a[o]=e[o])}return a}function kh(e){Os(e)}function jh(e){console.error(e)}function Gh(e){Os(e)}function Js(e,t){try{var a=e.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(s){setTimeout(function(){throw s})}}function Bh(e,t,a){try{var s=e.onCaughtError;s(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(o){setTimeout(function(){throw o})}}function To(e,t,a){return a=si(a),a.tag=3,a.payload={element:null},a.callback=function(){Js(e,t)},a}function $h(e){return e=si(e),e.tag=3,e}function Vh(e,t,a,s){var o=a.type.getDerivedStateFromError;if(typeof o=="function"){var c=s.value;e.payload=function(){return o(c)},e.callback=function(){Bh(t,a,s)}}var p=a.stateNode;p!==null&&typeof p.componentDidCatch=="function"&&(e.callback=function(){Bh(t,a,s),typeof o!="function"&&(hi===null?hi=new Set([this]):hi.add(this));var y=s.stack;this.componentDidCatch(s.value,{componentStack:y!==null?y:""})})}function ob(e,t,a,s,o){if(a.flags|=32768,s!==null&&typeof s=="object"&&typeof s.then=="function"){if(t=a.alternate,t!==null&&Ea(t,a,o,!0),a=Gt.current,a!==null){switch(a.tag){case 31:case 13:return nn===null?fl():a.alternate===null&&Je===0&&(Je=3),a.flags&=-257,a.flags|=65536,a.lanes=o,s===$s?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([s]):t.add(s),Zo(e,s,o)),!1;case 22:return a.flags|=65536,s===$s?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([s])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([s]):a.add(s)),Zo(e,s,o)),!1}throw Error(l(435,a.tag))}return Zo(e,s,o),fl(),!1}if(Me)return t=Gt.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=o,s!==Fu&&(e=Error(l(422),{cause:s}),xr(Wt(e,a)))):(s!==Fu&&(t=Error(l(423),{cause:s}),xr(Wt(t,a))),e=e.current.alternate,e.flags|=65536,o&=-o,e.lanes|=o,s=Wt(s,a),o=To(e.stateNode,s,o),eo(e,o),Je!==4&&(Je=2)),!1;var c=Error(l(520),{cause:s});if(c=Wt(c,a),Br===null?Br=[c]:Br.push(c),Je!==4&&(Je=2),t===null)return!0;s=Wt(s,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,e=o&-o,a.lanes|=e,e=To(a.stateNode,s,e),eo(a,e),!1;case 1:if(t=a.type,c=a.stateNode,(a.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||c!==null&&typeof c.componentDidCatch=="function"&&(hi===null||!hi.has(c))))return a.flags|=65536,o&=-o,a.lanes|=o,o=$h(o),Vh(o,e,a,s),eo(a,o),!1}a=a.return}while(a!==null);return!1}var Mo=Error(l(461)),lt=!1;function vt(e,t,a,s){t.child=e===null?qd(t,null,a,s):Yi(t,e.child,a,s)}function Ih(e,t,a,s,o){a=a.render;var c=t.ref;if("ref"in s){var p={};for(var y in s)y!=="ref"&&(p[y]=s[y])}else p=s;return Ii(t),s=so(e,t,a,p,c,o),y=lo(),e!==null&&!lt?(uo(e,t,o),jn(e,t,o)):(Me&&y&&Vu(t),t.flags|=1,vt(e,t,s,o),t.child)}function Fh(e,t,a,s,o){if(e===null){var c=a.type;return typeof c=="function"&&!Gu(c)&&c.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=c,Hh(e,t,c,s,o)):(e=Ns(a.type,null,s,t,t.mode,o),e.ref=t.ref,e.return=t,t.child=e)}if(c=e.child,!No(e,o)){var p=c.memoizedProps;if(a=a.compare,a=a!==null?a:yr,a(p,s)&&e.ref===t.ref)return jn(e,t,o)}return t.flags|=1,e=zn(c,s),e.ref=t.ref,e.return=t,t.child=e}function Hh(e,t,a,s,o){if(e!==null){var c=e.memoizedProps;if(yr(c,s)&&e.ref===t.ref)if(lt=!1,t.pendingProps=s=c,No(e,o))(e.flags&131072)!==0&&(lt=!0);else return t.lanes=e.lanes,jn(e,t,o)}return Do(e,t,a,s,o)}function qh(e,t,a,s){var o=s.children,c=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.mode==="hidden"){if((t.flags&128)!==0){if(c=c!==null?c.baseLanes|a:a,e!==null){for(s=t.child=e.child,o=0;s!==null;)o=o|s.lanes|s.childLanes,s=s.sibling;s=o&~c}else s=0,t.child=null;return Yh(e,t,c,a,s)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Gs(t,c!==null?c.cachePool:null),c!==null?Qd(t,c):no(),Kd(t);else return s=t.lanes=536870912,Yh(e,t,c!==null?c.baseLanes|a:a,a,s)}else c!==null?(Gs(t,c.cachePool),Qd(t,c),oi(),t.memoizedState=null):(e!==null&&Gs(t,null),no(),oi());return vt(e,t,o,a),t.child}function _r(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Yh(e,t,a,s,o){var c=Zu();return c=c===null?null:{parent:rt._currentValue,pool:c},t.memoizedState={baseLanes:a,cachePool:c},e!==null&&Gs(t,null),no(),Kd(t),e!==null&&Ea(e,t,s,!0),t.childLanes=o,null}function el(e,t){return t=nl({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Xh(e,t,a){return Yi(t,e.child,null,a),e=el(t,t.pendingProps),e.flags|=2,Bt(t),t.memoizedState=null,e}function cb(e,t,a){var s=t.pendingProps,o=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Me){if(s.mode==="hidden")return e=el(t,s),t.lanes=536870912,_r(null,e);if(ao(t),(e=Ie)?(e=rm(e,tn),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ti!==null?{id:vn,overflow:bn}:null,retryLane:536870912,hydrationErrors:null},a=Od(e),a.return=t,t.child=a,gt=t,Ie=null)):e=null,e===null)throw ii(t);return t.lanes=536870912,null}return el(t,s)}var c=e.memoizedState;if(c!==null){var p=c.dehydrated;if(ao(t),o)if(t.flags&256)t.flags&=-257,t=Xh(e,t,a);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(l(558));else if(lt||Ea(e,t,a,!1),o=(a&e.childLanes)!==0,lt||o){if(s=Be,s!==null&&(p=jf(s,a),p!==0&&p!==c.retryLane))throw c.retryLane=p,Gi(e,p),Ut(s,e,p),Mo;fl(),t=Xh(e,t,a)}else e=c.treeContext,Ie=an(p.nextSibling),gt=t,Me=!0,ni=null,tn=!1,e!==null&&Ud(t,e),t=el(t,s),t.flags|=4096;return t}return e=zn(e.child,{mode:s.mode,children:s.children}),e.ref=t.ref,t.child=e,e.return=t,e}function tl(e,t){var a=t.ref;if(a===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(l(284));(e===null||e.ref!==a)&&(t.flags|=4194816)}}function Do(e,t,a,s,o){return Ii(t),a=so(e,t,a,s,void 0,o),s=lo(),e!==null&&!lt?(uo(e,t,o),jn(e,t,o)):(Me&&s&&Vu(t),t.flags|=1,vt(e,t,a,o),t.child)}function Qh(e,t,a,s,o,c){return Ii(t),t.updateQueue=null,a=Pd(t,s,a,o),Zd(e),s=lo(),e!==null&&!lt?(uo(e,t,c),jn(e,t,c)):(Me&&s&&Vu(t),t.flags|=1,vt(e,t,a,c),t.child)}function Kh(e,t,a,s,o){if(Ii(t),t.stateNode===null){var c=ba,p=a.contextType;typeof p=="object"&&p!==null&&(c=yt(p)),c=new a(s,c),t.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=Ao,t.stateNode=c,c._reactInternals=t,c=t.stateNode,c.props=s,c.state=t.memoizedState,c.refs={},Wu(t),p=a.contextType,c.context=typeof p=="object"&&p!==null?yt(p):ba,c.state=t.memoizedState,p=a.getDerivedStateFromProps,typeof p=="function"&&(Eo(t,a,p,s),c.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof c.getSnapshotBeforeUpdate=="function"||typeof c.UNSAFE_componentWillMount!="function"&&typeof c.componentWillMount!="function"||(p=c.state,typeof c.componentWillMount=="function"&&c.componentWillMount(),typeof c.UNSAFE_componentWillMount=="function"&&c.UNSAFE_componentWillMount(),p!==c.state&&Ao.enqueueReplaceState(c,c.state,null),Dr(t,s,c,o),Mr(),c.state=t.memoizedState),typeof c.componentDidMount=="function"&&(t.flags|=4194308),s=!0}else if(e===null){c=t.stateNode;var y=t.memoizedProps,S=Qi(a,y);c.props=S;var O=c.context,L=a.contextType;p=ba,typeof L=="object"&&L!==null&&(p=yt(L));var B=a.getDerivedStateFromProps;L=typeof B=="function"||typeof c.getSnapshotBeforeUpdate=="function",y=t.pendingProps!==y,L||typeof c.UNSAFE_componentWillReceiveProps!="function"&&typeof c.componentWillReceiveProps!="function"||(y||O!==p)&&Lh(t,c,s,p),ri=!1;var z=t.memoizedState;c.state=z,Dr(t,s,c,o),Mr(),O=t.memoizedState,y||z!==O||ri?(typeof B=="function"&&(Eo(t,a,B,s),O=t.memoizedState),(S=ri||Nh(t,a,S,s,z,O,p))?(L||typeof c.UNSAFE_componentWillMount!="function"&&typeof c.componentWillMount!="function"||(typeof c.componentWillMount=="function"&&c.componentWillMount(),typeof c.UNSAFE_componentWillMount=="function"&&c.UNSAFE_componentWillMount()),typeof c.componentDidMount=="function"&&(t.flags|=4194308)):(typeof c.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=s,t.memoizedState=O),c.props=s,c.state=O,c.context=p,s=S):(typeof c.componentDidMount=="function"&&(t.flags|=4194308),s=!1)}else{c=t.stateNode,Ju(e,t),p=t.memoizedProps,L=Qi(a,p),c.props=L,B=t.pendingProps,z=c.context,O=a.contextType,S=ba,typeof O=="object"&&O!==null&&(S=yt(O)),y=a.getDerivedStateFromProps,(O=typeof y=="function"||typeof c.getSnapshotBeforeUpdate=="function")||typeof c.UNSAFE_componentWillReceiveProps!="function"&&typeof c.componentWillReceiveProps!="function"||(p!==B||z!==S)&&Lh(t,c,s,S),ri=!1,z=t.memoizedState,c.state=z,Dr(t,s,c,o),Mr();var _=t.memoizedState;p!==B||z!==_||ri||e!==null&&e.dependencies!==null&&ks(e.dependencies)?(typeof y=="function"&&(Eo(t,a,y,s),_=t.memoizedState),(L=ri||Nh(t,a,L,s,z,_,S)||e!==null&&e.dependencies!==null&&ks(e.dependencies))?(O||typeof c.UNSAFE_componentWillUpdate!="function"&&typeof c.componentWillUpdate!="function"||(typeof c.componentWillUpdate=="function"&&c.componentWillUpdate(s,_,S),typeof c.UNSAFE_componentWillUpdate=="function"&&c.UNSAFE_componentWillUpdate(s,_,S)),typeof c.componentDidUpdate=="function"&&(t.flags|=4),typeof c.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof c.componentDidUpdate!="function"||p===e.memoizedProps&&z===e.memoizedState||(t.flags|=4),typeof c.getSnapshotBeforeUpdate!="function"||p===e.memoizedProps&&z===e.memoizedState||(t.flags|=1024),t.memoizedProps=s,t.memoizedState=_),c.props=s,c.state=_,c.context=S,s=L):(typeof c.componentDidUpdate!="function"||p===e.memoizedProps&&z===e.memoizedState||(t.flags|=4),typeof c.getSnapshotBeforeUpdate!="function"||p===e.memoizedProps&&z===e.memoizedState||(t.flags|=1024),s=!1)}return c=s,tl(e,t),s=(t.flags&128)!==0,c||s?(c=t.stateNode,a=s&&typeof a.getDerivedStateFromError!="function"?null:c.render(),t.flags|=1,e!==null&&s?(t.child=Yi(t,e.child,null,o),t.child=Yi(t,null,a,o)):vt(e,t,a,o),t.memoizedState=c.state,e=t.child):e=jn(e,t,o),e}function Zh(e,t,a,s){return $i(),t.flags|=256,vt(e,t,a,s),t.child}var Ro={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Co(e){return{baseLanes:e,cachePool:Bd()}}function Oo(e,t,a){return e=e!==null?e.childLanes&~a:0,t&&(e|=Vt),e}function Ph(e,t,a){var s=t.pendingProps,o=!1,c=(t.flags&128)!==0,p;if((p=c)||(p=e!==null&&e.memoizedState===null?!1:(nt.current&2)!==0),p&&(o=!0,t.flags&=-129),p=(t.flags&32)!==0,t.flags&=-33,e===null){if(Me){if(o?ui(t):oi(),(e=Ie)?(e=rm(e,tn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ti!==null?{id:vn,overflow:bn}:null,retryLane:536870912,hydrationErrors:null},a=Od(e),a.return=t,t.child=a,gt=t,Ie=null)):e=null,e===null)throw ii(t);return dc(e)?t.lanes=32:t.lanes=536870912,null}var y=s.children;return s=s.fallback,o?(oi(),o=t.mode,y=nl({mode:"hidden",children:y},o),s=Bi(s,o,a,null),y.return=t,s.return=t,y.sibling=s,t.child=y,s=t.child,s.memoizedState=Co(a),s.childLanes=Oo(e,p,a),t.memoizedState=Ro,_r(null,s)):(ui(t),zo(t,y))}var S=e.memoizedState;if(S!==null&&(y=S.dehydrated,y!==null)){if(c)t.flags&256?(ui(t),t.flags&=-257,t=_o(e,t,a)):t.memoizedState!==null?(oi(),t.child=e.child,t.flags|=128,t=null):(oi(),y=s.fallback,o=t.mode,s=nl({mode:"visible",children:s.children},o),y=Bi(y,o,a,null),y.flags|=2,s.return=t,y.return=t,s.sibling=y,t.child=s,Yi(t,e.child,null,a),s=t.child,s.memoizedState=Co(a),s.childLanes=Oo(e,p,a),t.memoizedState=Ro,t=_r(null,s));else if(ui(t),dc(y)){if(p=y.nextSibling&&y.nextSibling.dataset,p)var O=p.dgst;p=O,s=Error(l(419)),s.stack="",s.digest=p,xr({value:s,source:null,stack:null}),t=_o(e,t,a)}else if(lt||Ea(e,t,a,!1),p=(a&e.childLanes)!==0,lt||p){if(p=Be,p!==null&&(s=jf(p,a),s!==0&&s!==S.retryLane))throw S.retryLane=s,Gi(e,s),Ut(p,e,s),Mo;fc(y)||fl(),t=_o(e,t,a)}else fc(y)?(t.flags|=192,t.child=e.child,t=null):(e=S.treeContext,Ie=an(y.nextSibling),gt=t,Me=!0,ni=null,tn=!1,e!==null&&Ud(t,e),t=zo(t,s.children),t.flags|=4096);return t}return o?(oi(),y=s.fallback,o=t.mode,S=e.child,O=S.sibling,s=zn(S,{mode:"hidden",children:s.children}),s.subtreeFlags=S.subtreeFlags&65011712,O!==null?y=zn(O,y):(y=Bi(y,o,a,null),y.flags|=2),y.return=t,s.return=t,s.sibling=y,t.child=s,_r(null,s),s=t.child,y=e.child.memoizedState,y===null?y=Co(a):(o=y.cachePool,o!==null?(S=rt._currentValue,o=o.parent!==S?{parent:S,pool:S}:o):o=Bd(),y={baseLanes:y.baseLanes|a,cachePool:o}),s.memoizedState=y,s.childLanes=Oo(e,p,a),t.memoizedState=Ro,_r(e.child,s)):(ui(t),a=e.child,e=a.sibling,a=zn(a,{mode:"visible",children:s.children}),a.return=t,a.sibling=null,e!==null&&(p=t.deletions,p===null?(t.deletions=[e],t.flags|=16):p.push(e)),t.child=a,t.memoizedState=null,a)}function zo(e,t){return t=nl({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function nl(e,t){return e=jt(22,e,null,t),e.lanes=0,e}function _o(e,t,a){return Yi(t,e.child,null,a),e=zo(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Wh(e,t,a){e.lanes|=t;var s=e.alternate;s!==null&&(s.lanes|=t),Yu(e.return,t,a)}function Uo(e,t,a,s,o,c){var p=e.memoizedState;p===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:s,tail:a,tailMode:o,treeForkCount:c}:(p.isBackwards=t,p.rendering=null,p.renderingStartTime=0,p.last=s,p.tail=a,p.tailMode=o,p.treeForkCount=c)}function Jh(e,t,a){var s=t.pendingProps,o=s.revealOrder,c=s.tail;s=s.children;var p=nt.current,y=(p&2)!==0;if(y?(p=p&1|2,t.flags|=128):p&=1,q(nt,p),vt(e,t,s,a),s=Me?br:0,!y&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Wh(e,a,t);else if(e.tag===19)Wh(e,a,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(o){case"forwards":for(a=t.child,o=null;a!==null;)e=a.alternate,e!==null&&Hs(e)===null&&(o=a),a=a.sibling;a=o,a===null?(o=t.child,t.child=null):(o=a.sibling,a.sibling=null),Uo(t,!1,o,a,c,s);break;case"backwards":case"unstable_legacy-backwards":for(a=null,o=t.child,t.child=null;o!==null;){if(e=o.alternate,e!==null&&Hs(e)===null){t.child=o;break}e=o.sibling,o.sibling=a,a=o,o=e}Uo(t,!0,a,null,c,s);break;case"together":Uo(t,!1,null,null,void 0,s);break;default:t.memoizedState=null}return t.child}function jn(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),di|=t.lanes,(a&t.childLanes)===0)if(e!==null){if(Ea(e,t,a,!1),(a&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(l(153));if(t.child!==null){for(e=t.child,a=zn(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=zn(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function No(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&ks(e)))}function fb(e,t,a){switch(t.tag){case 3:Pe(t,t.stateNode.containerInfo),ai(t,rt,e.memoizedState.cache),$i();break;case 27:case 5:gn(t);break;case 4:Pe(t,t.stateNode.containerInfo);break;case 10:ai(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,ao(t),null;break;case 13:var s=t.memoizedState;if(s!==null)return s.dehydrated!==null?(ui(t),t.flags|=128,null):(a&t.child.childLanes)!==0?Ph(e,t,a):(ui(t),e=jn(e,t,a),e!==null?e.sibling:null);ui(t);break;case 19:var o=(e.flags&128)!==0;if(s=(a&t.childLanes)!==0,s||(Ea(e,t,a,!1),s=(a&t.childLanes)!==0),o){if(s)return Jh(e,t,a);t.flags|=128}if(o=t.memoizedState,o!==null&&(o.rendering=null,o.tail=null,o.lastEffect=null),q(nt,nt.current),s)break;return null;case 22:return t.lanes=0,qh(e,t,a,t.pendingProps);case 24:ai(t,rt,e.memoizedState.cache)}return jn(e,t,a)}function ep(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps)lt=!0;else{if(!No(e,a)&&(t.flags&128)===0)return lt=!1,fb(e,t,a);lt=(e.flags&131072)!==0}else lt=!1,Me&&(t.flags&1048576)!==0&&_d(t,br,t.index);switch(t.lanes=0,t.tag){case 16:e:{var s=t.pendingProps;if(e=Hi(t.elementType),t.type=e,typeof e=="function")Gu(e)?(s=Qi(e,s),t.tag=1,t=Kh(null,t,e,s,a)):(t.tag=0,t=Do(null,t,e,s,a));else{if(e!=null){var o=e.$$typeof;if(o===Y){t.tag=11,t=Ih(null,t,e,s,a);break e}else if(o===M){t.tag=14,t=Fh(null,t,e,s,a);break e}}throw t=de(e)||e,Error(l(306,t,""))}}return t;case 0:return Do(e,t,t.type,t.pendingProps,a);case 1:return s=t.type,o=Qi(s,t.pendingProps),Kh(e,t,s,o,a);case 3:e:{if(Pe(t,t.stateNode.containerInfo),e===null)throw Error(l(387));s=t.pendingProps;var c=t.memoizedState;o=c.element,Ju(e,t),Dr(t,s,null,a);var p=t.memoizedState;if(s=p.cache,ai(t,rt,s),s!==c.cache&&Xu(t,[rt],a,!0),Mr(),s=p.element,c.isDehydrated)if(c={element:s,isDehydrated:!1,cache:p.cache},t.updateQueue.baseState=c,t.memoizedState=c,t.flags&256){t=Zh(e,t,s,a);break e}else if(s!==o){o=Wt(Error(l(424)),t),xr(o),t=Zh(e,t,s,a);break e}else for(e=t.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,Ie=an(e.firstChild),gt=t,Me=!0,ni=null,tn=!0,a=qd(t,null,s,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if($i(),s===o){t=jn(e,t,a);break e}vt(e,t,s,a)}t=t.child}return t;case 26:return tl(e,t),e===null?(a=fm(t.type,null,t.pendingProps,null))?t.memoizedState=a:Me||(a=t.type,e=t.pendingProps,s=vl(fe.current).createElement(a),s[mt]=t,s[Dt]=e,bt(s,a,e),ft(s),t.stateNode=s):t.memoizedState=fm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return gn(t),e===null&&Me&&(s=t.stateNode=um(t.type,t.pendingProps,fe.current),gt=t,tn=!0,o=Ie,yi(t.type)?(hc=o,Ie=an(s.firstChild)):Ie=o),vt(e,t,t.pendingProps.children,a),tl(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Me&&((o=s=Ie)&&(s=Vb(s,t.type,t.pendingProps,tn),s!==null?(t.stateNode=s,gt=t,Ie=an(s.firstChild),tn=!1,o=!0):o=!1),o||ii(t)),gn(t),o=t.type,c=t.pendingProps,p=e!==null?e.memoizedProps:null,s=c.children,uc(o,c)?s=null:p!==null&&uc(o,p)&&(t.flags|=32),t.memoizedState!==null&&(o=so(e,t,nb,null,null,a),Xr._currentValue=o),tl(e,t),vt(e,t,s,a),t.child;case 6:return e===null&&Me&&((e=a=Ie)&&(a=Ib(a,t.pendingProps,tn),a!==null?(t.stateNode=a,gt=t,Ie=null,e=!0):e=!1),e||ii(t)),null;case 13:return Ph(e,t,a);case 4:return Pe(t,t.stateNode.containerInfo),s=t.pendingProps,e===null?t.child=Yi(t,null,s,a):vt(e,t,s,a),t.child;case 11:return Ih(e,t,t.type,t.pendingProps,a);case 7:return vt(e,t,t.pendingProps,a),t.child;case 8:return vt(e,t,t.pendingProps.children,a),t.child;case 12:return vt(e,t,t.pendingProps.children,a),t.child;case 10:return s=t.pendingProps,ai(t,t.type,s.value),vt(e,t,s.children,a),t.child;case 9:return o=t.type._context,s=t.pendingProps.children,Ii(t),o=yt(o),s=s(o),t.flags|=1,vt(e,t,s,a),t.child;case 14:return Fh(e,t,t.type,t.pendingProps,a);case 15:return Hh(e,t,t.type,t.pendingProps,a);case 19:return Jh(e,t,a);case 31:return cb(e,t,a);case 22:return qh(e,t,a,t.pendingProps);case 24:return Ii(t),s=yt(rt),e===null?(o=Zu(),o===null&&(o=Be,c=Qu(),o.pooledCache=c,c.refCount++,c!==null&&(o.pooledCacheLanes|=a),o=c),t.memoizedState={parent:s,cache:o},Wu(t),ai(t,rt,o)):((e.lanes&a)!==0&&(Ju(e,t),Dr(t,null,null,a),Mr()),o=e.memoizedState,c=t.memoizedState,o.parent!==s?(o={parent:s,cache:s},t.memoizedState=o,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=o),ai(t,rt,s)):(s=c.cache,ai(t,rt,s),s!==o.cache&&Xu(t,[rt],a,!0))),vt(e,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(l(156,t.tag))}function Gn(e){e.flags|=4}function Lo(e,t,a,s,o){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(o&335544128)===o)if(e.stateNode.complete)e.flags|=8192;else if(Dp())e.flags|=8192;else throw qi=$s,Pu}else e.flags&=-16777217}function tp(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!gm(t))if(Dp())e.flags|=8192;else throw qi=$s,Pu}function il(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?Nf():536870912,e.lanes|=t,La|=t)}function Ur(e,t){if(!Me)switch(e.tailMode){case"hidden":t=e.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var s=null;a!==null;)a.alternate!==null&&(s=a),a=a.sibling;s===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:s.sibling=null}}function Fe(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,s=0;if(t)for(var o=e.child;o!==null;)a|=o.lanes|o.childLanes,s|=o.subtreeFlags&65011712,s|=o.flags&65011712,o.return=e,o=o.sibling;else for(o=e.child;o!==null;)a|=o.lanes|o.childLanes,s|=o.subtreeFlags,s|=o.flags,o.return=e,o=o.sibling;return e.subtreeFlags|=s,e.childLanes=a,t}function db(e,t,a){var s=t.pendingProps;switch(Iu(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Fe(t),null;case 1:return Fe(t),null;case 3:return a=t.stateNode,s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),Nn(rt),De(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(wa(t)?Gn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Hu())),Fe(t),null;case 26:var o=t.type,c=t.memoizedState;return e===null?(Gn(t),c!==null?(Fe(t),tp(t,c)):(Fe(t),Lo(t,o,null,s,a))):c?c!==e.memoizedState?(Gn(t),Fe(t),tp(t,c)):(Fe(t),t.flags&=-16777217):(e=e.memoizedProps,e!==s&&Gn(t),Fe(t),Lo(t,o,e,s,a)),null;case 27:if(Wn(t),a=fe.current,o=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==s&&Gn(t);else{if(!s){if(t.stateNode===null)throw Error(l(166));return Fe(t),null}e=K.current,wa(t)?Nd(t):(e=um(o,s,a),t.stateNode=e,Gn(t))}return Fe(t),null;case 5:if(Wn(t),o=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==s&&Gn(t);else{if(!s){if(t.stateNode===null)throw Error(l(166));return Fe(t),null}if(c=K.current,wa(t))Nd(t);else{var p=vl(fe.current);switch(c){case 1:c=p.createElementNS("http://www.w3.org/2000/svg",o);break;case 2:c=p.createElementNS("http://www.w3.org/1998/Math/MathML",o);break;default:switch(o){case"svg":c=p.createElementNS("http://www.w3.org/2000/svg",o);break;case"math":c=p.createElementNS("http://www.w3.org/1998/Math/MathML",o);break;case"script":c=p.createElement("div"),c.innerHTML="<script><\/script>",c=c.removeChild(c.firstChild);break;case"select":c=typeof s.is=="string"?p.createElement("select",{is:s.is}):p.createElement("select"),s.multiple?c.multiple=!0:s.size&&(c.size=s.size);break;default:c=typeof s.is=="string"?p.createElement(o,{is:s.is}):p.createElement(o)}}c[mt]=t,c[Dt]=s;e:for(p=t.child;p!==null;){if(p.tag===5||p.tag===6)c.appendChild(p.stateNode);else if(p.tag!==4&&p.tag!==27&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===t)break e;for(;p.sibling===null;){if(p.return===null||p.return===t)break e;p=p.return}p.sibling.return=p.return,p=p.sibling}t.stateNode=c;e:switch(bt(c,o,s),o){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}s&&Gn(t)}}return Fe(t),Lo(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,a),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==s&&Gn(t);else{if(typeof s!="string"&&t.stateNode===null)throw Error(l(166));if(e=fe.current,wa(t)){if(e=t.stateNode,a=t.memoizedProps,s=null,o=gt,o!==null)switch(o.tag){case 27:case 5:s=o.memoizedProps}e[mt]=t,e=!!(e.nodeValue===a||s!==null&&s.suppressHydrationWarning===!0||Pp(e.nodeValue,a)),e||ii(t,!0)}else e=vl(e).createTextNode(s),e[mt]=t,t.stateNode=e}return Fe(t),null;case 31:if(a=t.memoizedState,e===null||e.memoizedState!==null){if(s=wa(t),a!==null){if(e===null){if(!s)throw Error(l(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(557));e[mt]=t}else $i(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Fe(t),e=!1}else a=Hu(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return t.flags&256?(Bt(t),t):(Bt(t),null);if((t.flags&128)!==0)throw Error(l(558))}return Fe(t),null;case 13:if(s=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(o=wa(t),s!==null&&s.dehydrated!==null){if(e===null){if(!o)throw Error(l(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(l(317));o[mt]=t}else $i(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Fe(t),o=!1}else o=Hu(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=o),o=!0;if(!o)return t.flags&256?(Bt(t),t):(Bt(t),null)}return Bt(t),(t.flags&128)!==0?(t.lanes=a,t):(a=s!==null,e=e!==null&&e.memoizedState!==null,a&&(s=t.child,o=null,s.alternate!==null&&s.alternate.memoizedState!==null&&s.alternate.memoizedState.cachePool!==null&&(o=s.alternate.memoizedState.cachePool.pool),c=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(c=s.memoizedState.cachePool.pool),c!==o&&(s.flags|=2048)),a!==e&&a&&(t.child.flags|=8192),il(t,t.updateQueue),Fe(t),null);case 4:return De(),e===null&&ic(t.stateNode.containerInfo),Fe(t),null;case 10:return Nn(t.type),Fe(t),null;case 19:if(U(nt),s=t.memoizedState,s===null)return Fe(t),null;if(o=(t.flags&128)!==0,c=s.rendering,c===null)if(o)Ur(s,!1);else{if(Je!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(c=Hs(e),c!==null){for(t.flags|=128,Ur(s,!1),e=c.updateQueue,t.updateQueue=e,il(t,e),t.subtreeFlags=0,e=a,a=t.child;a!==null;)Cd(a,e),a=a.sibling;return q(nt,nt.current&1|2),Me&&_n(t,s.treeForkCount),t.child}e=e.sibling}s.tail!==null&&Ve()>ul&&(t.flags|=128,o=!0,Ur(s,!1),t.lanes=4194304)}else{if(!o)if(e=Hs(c),e!==null){if(t.flags|=128,o=!0,e=e.updateQueue,t.updateQueue=e,il(t,e),Ur(s,!0),s.tail===null&&s.tailMode==="hidden"&&!c.alternate&&!Me)return Fe(t),null}else 2*Ve()-s.renderingStartTime>ul&&a!==536870912&&(t.flags|=128,o=!0,Ur(s,!1),t.lanes=4194304);s.isBackwards?(c.sibling=t.child,t.child=c):(e=s.last,e!==null?e.sibling=c:t.child=c,s.last=c)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Ve(),e.sibling=null,a=nt.current,q(nt,o?a&1|2:a&1),Me&&_n(t,s.treeForkCount),e):(Fe(t),null);case 22:case 23:return Bt(t),io(),s=t.memoizedState!==null,e!==null?e.memoizedState!==null!==s&&(t.flags|=8192):s&&(t.flags|=8192),s?(a&536870912)!==0&&(t.flags&128)===0&&(Fe(t),t.subtreeFlags&6&&(t.flags|=8192)):Fe(t),a=t.updateQueue,a!==null&&il(t,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),s=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),s!==a&&(t.flags|=2048),e!==null&&U(Fi),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Nn(rt),Fe(t),null;case 25:return null;case 30:return null}throw Error(l(156,t.tag))}function hb(e,t){switch(Iu(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Nn(rt),De(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Wn(t),null;case 31:if(t.memoizedState!==null){if(Bt(t),t.alternate===null)throw Error(l(340));$i()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Bt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(l(340));$i()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return U(nt),null;case 4:return De(),null;case 10:return Nn(t.type),null;case 22:case 23:return Bt(t),io(),e!==null&&U(Fi),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Nn(rt),null;case 25:return null;default:return null}}function np(e,t){switch(Iu(t),t.tag){case 3:Nn(rt),De();break;case 26:case 27:case 5:Wn(t);break;case 4:De();break;case 31:t.memoizedState!==null&&Bt(t);break;case 13:Bt(t);break;case 19:U(nt);break;case 10:Nn(t.type);break;case 22:case 23:Bt(t),io(),e!==null&&U(Fi);break;case 24:Nn(rt)}}function Nr(e,t){try{var a=t.updateQueue,s=a!==null?a.lastEffect:null;if(s!==null){var o=s.next;a=o;do{if((a.tag&e)===e){s=void 0;var c=a.create,p=a.inst;s=c(),p.destroy=s}a=a.next}while(a!==o)}}catch(y){Le(t,t.return,y)}}function ci(e,t,a){try{var s=t.updateQueue,o=s!==null?s.lastEffect:null;if(o!==null){var c=o.next;s=c;do{if((s.tag&e)===e){var p=s.inst,y=p.destroy;if(y!==void 0){p.destroy=void 0,o=t;var S=a,O=y;try{O()}catch(L){Le(o,S,L)}}}s=s.next}while(s!==c)}}catch(L){Le(t,t.return,L)}}function ip(e){var t=e.updateQueue;if(t!==null){var a=e.stateNode;try{Xd(t,a)}catch(s){Le(e,e.return,s)}}}function ap(e,t,a){a.props=Qi(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(s){Le(e,t,s)}}function Lr(e,t){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var s=e.stateNode;break;case 30:s=e.stateNode;break;default:s=e.stateNode}typeof a=="function"?e.refCleanup=a(s):a.current=s}}catch(o){Le(e,t,o)}}function xn(e,t){var a=e.ref,s=e.refCleanup;if(a!==null)if(typeof s=="function")try{s()}catch(o){Le(e,t,o)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(o){Le(e,t,o)}else a.current=null}function rp(e){var t=e.type,a=e.memoizedProps,s=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&s.focus();break e;case"img":a.src?s.src=a.src:a.srcSet&&(s.srcset=a.srcSet)}}catch(o){Le(e,e.return,o)}}function ko(e,t,a){try{var s=e.stateNode;Lb(s,e.type,a,t),s[Dt]=t}catch(o){Le(e,e.return,o)}}function sp(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&yi(e.type)||e.tag===4}function jo(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||sp(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&yi(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Go(e,t,a){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(e,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(e),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=Cn));else if(s!==4&&(s===27&&yi(e.type)&&(a=e.stateNode,t=null),e=e.child,e!==null))for(Go(e,t,a),e=e.sibling;e!==null;)Go(e,t,a),e=e.sibling}function al(e,t,a){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(s!==4&&(s===27&&yi(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(al(e,t,a),e=e.sibling;e!==null;)al(e,t,a),e=e.sibling}function lp(e){var t=e.stateNode,a=e.memoizedProps;try{for(var s=e.type,o=t.attributes;o.length;)t.removeAttributeNode(o[0]);bt(t,s,a),t[mt]=e,t[Dt]=a}catch(c){Le(e,e.return,c)}}var Bn=!1,ut=!1,Bo=!1,up=typeof WeakSet=="function"?WeakSet:Set,dt=null;function pb(e,t){if(e=e.containerInfo,sc=Tl,e=xd(e),zu(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var s=a.getSelection&&a.getSelection();if(s&&s.rangeCount!==0){a=s.anchorNode;var o=s.anchorOffset,c=s.focusNode;s=s.focusOffset;try{a.nodeType,c.nodeType}catch{a=null;break e}var p=0,y=-1,S=-1,O=0,L=0,B=e,z=null;t:for(;;){for(var _;B!==a||o!==0&&B.nodeType!==3||(y=p+o),B!==c||s!==0&&B.nodeType!==3||(S=p+s),B.nodeType===3&&(p+=B.nodeValue.length),(_=B.firstChild)!==null;)z=B,B=_;for(;;){if(B===e)break t;if(z===a&&++O===o&&(y=p),z===c&&++L===s&&(S=p),(_=B.nextSibling)!==null)break;B=z,z=B.parentNode}B=_}a=y===-1||S===-1?null:{start:y,end:S}}else a=null}a=a||{start:0,end:0}}else a=null;for(lc={focusedElem:e,selectionRange:a},Tl=!1,dt=t;dt!==null;)if(t=dt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,dt=e;else for(;dt!==null;){switch(t=dt,c=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(a=0;a<e.length;a++)o=e[a],o.ref.impl=o.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&c!==null){e=void 0,a=t,o=c.memoizedProps,c=c.memoizedState,s=a.stateNode;try{var ne=Qi(a.type,o);e=s.getSnapshotBeforeUpdate(ne,c),s.__reactInternalSnapshotBeforeUpdate=e}catch(ce){Le(a,a.return,ce)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,a=e.nodeType,a===9)cc(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":cc(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(l(163))}if(e=t.sibling,e!==null){e.return=t.return,dt=e;break}dt=t.return}}function op(e,t,a){var s=a.flags;switch(a.tag){case 0:case 11:case 15:Vn(e,a),s&4&&Nr(5,a);break;case 1:if(Vn(e,a),s&4)if(e=a.stateNode,t===null)try{e.componentDidMount()}catch(p){Le(a,a.return,p)}else{var o=Qi(a.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(o,t,e.__reactInternalSnapshotBeforeUpdate)}catch(p){Le(a,a.return,p)}}s&64&&ip(a),s&512&&Lr(a,a.return);break;case 3:if(Vn(e,a),s&64&&(e=a.updateQueue,e!==null)){if(t=null,a.child!==null)switch(a.child.tag){case 27:case 5:t=a.child.stateNode;break;case 1:t=a.child.stateNode}try{Xd(e,t)}catch(p){Le(a,a.return,p)}}break;case 27:t===null&&s&4&&lp(a);case 26:case 5:Vn(e,a),t===null&&s&4&&rp(a),s&512&&Lr(a,a.return);break;case 12:Vn(e,a);break;case 31:Vn(e,a),s&4&&dp(e,a);break;case 13:Vn(e,a),s&4&&hp(e,a),s&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=Eb.bind(null,a),Fb(e,a))));break;case 22:if(s=a.memoizedState!==null||Bn,!s){t=t!==null&&t.memoizedState!==null||ut,o=Bn;var c=ut;Bn=s,(ut=t)&&!c?In(e,a,(a.subtreeFlags&8772)!==0):Vn(e,a),Bn=o,ut=c}break;case 30:break;default:Vn(e,a)}}function cp(e){var t=e.alternate;t!==null&&(e.alternate=null,cp(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&pu(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var qe=null,Ct=!1;function $n(e,t,a){for(a=a.child;a!==null;)fp(e,t,a),a=a.sibling}function fp(e,t,a){if(He&&typeof He.onCommitFiberUnmount=="function")try{He.onCommitFiberUnmount(ct,a)}catch{}switch(a.tag){case 26:ut||xn(a,t),$n(e,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:ut||xn(a,t);var s=qe,o=Ct;yi(a.type)&&(qe=a.stateNode,Ct=!1),$n(e,t,a),Hr(a.stateNode),qe=s,Ct=o;break;case 5:ut||xn(a,t);case 6:if(s=qe,o=Ct,qe=null,$n(e,t,a),qe=s,Ct=o,qe!==null)if(Ct)try{(qe.nodeType===9?qe.body:qe.nodeName==="HTML"?qe.ownerDocument.body:qe).removeChild(a.stateNode)}catch(c){Le(a,t,c)}else try{qe.removeChild(a.stateNode)}catch(c){Le(a,t,c)}break;case 18:qe!==null&&(Ct?(e=qe,im(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),Fa(e)):im(qe,a.stateNode));break;case 4:s=qe,o=Ct,qe=a.stateNode.containerInfo,Ct=!0,$n(e,t,a),qe=s,Ct=o;break;case 0:case 11:case 14:case 15:ci(2,a,t),ut||ci(4,a,t),$n(e,t,a);break;case 1:ut||(xn(a,t),s=a.stateNode,typeof s.componentWillUnmount=="function"&&ap(a,t,s)),$n(e,t,a);break;case 21:$n(e,t,a);break;case 22:ut=(s=ut)||a.memoizedState!==null,$n(e,t,a),ut=s;break;default:$n(e,t,a)}}function dp(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Fa(e)}catch(a){Le(t,t.return,a)}}}function hp(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Fa(e)}catch(a){Le(t,t.return,a)}}function mb(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new up),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new up),t;default:throw Error(l(435,e.tag))}}function rl(e,t){var a=mb(e);t.forEach(function(s){if(!a.has(s)){a.add(s);var o=Ab.bind(null,e,s);s.then(o,o)}})}function Ot(e,t){var a=t.deletions;if(a!==null)for(var s=0;s<a.length;s++){var o=a[s],c=e,p=t,y=p;e:for(;y!==null;){switch(y.tag){case 27:if(yi(y.type)){qe=y.stateNode,Ct=!1;break e}break;case 5:qe=y.stateNode,Ct=!1;break e;case 3:case 4:qe=y.stateNode.containerInfo,Ct=!0;break e}y=y.return}if(qe===null)throw Error(l(160));fp(c,p,o),qe=null,Ct=!1,c=o.alternate,c!==null&&(c.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)pp(t,e),t=t.sibling}var pn=null;function pp(e,t){var a=e.alternate,s=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ot(t,e),zt(e),s&4&&(ci(3,e,e.return),Nr(3,e),ci(5,e,e.return));break;case 1:Ot(t,e),zt(e),s&512&&(ut||a===null||xn(a,a.return)),s&64&&Bn&&(e=e.updateQueue,e!==null&&(s=e.callbacks,s!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?s:a.concat(s))));break;case 26:var o=pn;if(Ot(t,e),zt(e),s&512&&(ut||a===null||xn(a,a.return)),s&4){var c=a!==null?a.memoizedState:null;if(s=e.memoizedState,a===null)if(s===null)if(e.stateNode===null){e:{s=e.type,a=e.memoizedProps,o=o.ownerDocument||o;t:switch(s){case"title":c=o.getElementsByTagName("title")[0],(!c||c[ur]||c[mt]||c.namespaceURI==="http://www.w3.org/2000/svg"||c.hasAttribute("itemprop"))&&(c=o.createElement(s),o.head.insertBefore(c,o.querySelector("head > title"))),bt(c,s,a),c[mt]=e,ft(c),s=c;break e;case"link":var p=pm("link","href",o).get(s+(a.href||""));if(p){for(var y=0;y<p.length;y++)if(c=p[y],c.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&c.getAttribute("rel")===(a.rel==null?null:a.rel)&&c.getAttribute("title")===(a.title==null?null:a.title)&&c.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){p.splice(y,1);break t}}c=o.createElement(s),bt(c,s,a),o.head.appendChild(c);break;case"meta":if(p=pm("meta","content",o).get(s+(a.content||""))){for(y=0;y<p.length;y++)if(c=p[y],c.getAttribute("content")===(a.content==null?null:""+a.content)&&c.getAttribute("name")===(a.name==null?null:a.name)&&c.getAttribute("property")===(a.property==null?null:a.property)&&c.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&c.getAttribute("charset")===(a.charSet==null?null:a.charSet)){p.splice(y,1);break t}}c=o.createElement(s),bt(c,s,a),o.head.appendChild(c);break;default:throw Error(l(468,s))}c[mt]=e,ft(c),s=c}e.stateNode=s}else mm(o,e.type,e.stateNode);else e.stateNode=hm(o,s,e.memoizedProps);else c!==s?(c===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):c.count--,s===null?mm(o,e.type,e.stateNode):hm(o,s,e.memoizedProps)):s===null&&e.stateNode!==null&&ko(e,e.memoizedProps,a.memoizedProps)}break;case 27:Ot(t,e),zt(e),s&512&&(ut||a===null||xn(a,a.return)),a!==null&&s&4&&ko(e,e.memoizedProps,a.memoizedProps);break;case 5:if(Ot(t,e),zt(e),s&512&&(ut||a===null||xn(a,a.return)),e.flags&32){o=e.stateNode;try{da(o,"")}catch(ne){Le(e,e.return,ne)}}s&4&&e.stateNode!=null&&(o=e.memoizedProps,ko(e,o,a!==null?a.memoizedProps:o)),s&1024&&(Bo=!0);break;case 6:if(Ot(t,e),zt(e),s&4){if(e.stateNode===null)throw Error(l(162));s=e.memoizedProps,a=e.stateNode;try{a.nodeValue=s}catch(ne){Le(e,e.return,ne)}}break;case 3:if(Sl=null,o=pn,pn=bl(t.containerInfo),Ot(t,e),pn=o,zt(e),s&4&&a!==null&&a.memoizedState.isDehydrated)try{Fa(t.containerInfo)}catch(ne){Le(e,e.return,ne)}Bo&&(Bo=!1,mp(e));break;case 4:s=pn,pn=bl(e.stateNode.containerInfo),Ot(t,e),zt(e),pn=s;break;case 12:Ot(t,e),zt(e);break;case 31:Ot(t,e),zt(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,rl(e,s)));break;case 13:Ot(t,e),zt(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(ll=Ve()),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,rl(e,s)));break;case 22:o=e.memoizedState!==null;var S=a!==null&&a.memoizedState!==null,O=Bn,L=ut;if(Bn=O||o,ut=L||S,Ot(t,e),ut=L,Bn=O,zt(e),s&8192)e:for(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,o&&(a===null||S||Bn||ut||Ki(e)),a=null,t=e;;){if(t.tag===5||t.tag===26){if(a===null){S=a=t;try{if(c=S.stateNode,o)p=c.style,typeof p.setProperty=="function"?p.setProperty("display","none","important"):p.display="none";else{y=S.stateNode;var B=S.memoizedProps.style,z=B!=null&&B.hasOwnProperty("display")?B.display:null;y.style.display=z==null||typeof z=="boolean"?"":(""+z).trim()}}catch(ne){Le(S,S.return,ne)}}}else if(t.tag===6){if(a===null){S=t;try{S.stateNode.nodeValue=o?"":S.memoizedProps}catch(ne){Le(S,S.return,ne)}}}else if(t.tag===18){if(a===null){S=t;try{var _=S.stateNode;o?am(_,!0):am(S.stateNode,!1)}catch(ne){Le(S,S.return,ne)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}s&4&&(s=e.updateQueue,s!==null&&(a=s.retryQueue,a!==null&&(s.retryQueue=null,rl(e,a))));break;case 19:Ot(t,e),zt(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,rl(e,s)));break;case 30:break;case 21:break;default:Ot(t,e),zt(e)}}function zt(e){var t=e.flags;if(t&2){try{for(var a,s=e.return;s!==null;){if(sp(s)){a=s;break}s=s.return}if(a==null)throw Error(l(160));switch(a.tag){case 27:var o=a.stateNode,c=jo(e);al(e,c,o);break;case 5:var p=a.stateNode;a.flags&32&&(da(p,""),a.flags&=-33);var y=jo(e);al(e,y,p);break;case 3:case 4:var S=a.stateNode.containerInfo,O=jo(e);Go(e,O,S);break;default:throw Error(l(161))}}catch(L){Le(e,e.return,L)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function mp(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;mp(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Vn(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)op(e,t.alternate,t),t=t.sibling}function Ki(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ci(4,t,t.return),Ki(t);break;case 1:xn(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&ap(t,t.return,a),Ki(t);break;case 27:Hr(t.stateNode);case 26:case 5:xn(t,t.return),Ki(t);break;case 22:t.memoizedState===null&&Ki(t);break;case 30:Ki(t);break;default:Ki(t)}e=e.sibling}}function In(e,t,a){for(a=a&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var s=t.alternate,o=e,c=t,p=c.flags;switch(c.tag){case 0:case 11:case 15:In(o,c,a),Nr(4,c);break;case 1:if(In(o,c,a),s=c,o=s.stateNode,typeof o.componentDidMount=="function")try{o.componentDidMount()}catch(O){Le(s,s.return,O)}if(s=c,o=s.updateQueue,o!==null){var y=s.stateNode;try{var S=o.shared.hiddenCallbacks;if(S!==null)for(o.shared.hiddenCallbacks=null,o=0;o<S.length;o++)Yd(S[o],y)}catch(O){Le(s,s.return,O)}}a&&p&64&&ip(c),Lr(c,c.return);break;case 27:lp(c);case 26:case 5:In(o,c,a),a&&s===null&&p&4&&rp(c),Lr(c,c.return);break;case 12:In(o,c,a);break;case 31:In(o,c,a),a&&p&4&&dp(o,c);break;case 13:In(o,c,a),a&&p&4&&hp(o,c);break;case 22:c.memoizedState===null&&In(o,c,a),Lr(c,c.return);break;case 30:break;default:In(o,c,a)}t=t.sibling}}function $o(e,t){var a=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==a&&(e!=null&&e.refCount++,a!=null&&Sr(a))}function Vo(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Sr(e))}function mn(e,t,a,s){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)gp(e,t,a,s),t=t.sibling}function gp(e,t,a,s){var o=t.flags;switch(t.tag){case 0:case 11:case 15:mn(e,t,a,s),o&2048&&Nr(9,t);break;case 1:mn(e,t,a,s);break;case 3:mn(e,t,a,s),o&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Sr(e)));break;case 12:if(o&2048){mn(e,t,a,s),e=t.stateNode;try{var c=t.memoizedProps,p=c.id,y=c.onPostCommit;typeof y=="function"&&y(p,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(S){Le(t,t.return,S)}}else mn(e,t,a,s);break;case 31:mn(e,t,a,s);break;case 13:mn(e,t,a,s);break;case 23:break;case 22:c=t.stateNode,p=t.alternate,t.memoizedState!==null?c._visibility&2?mn(e,t,a,s):kr(e,t):c._visibility&2?mn(e,t,a,s):(c._visibility|=2,_a(e,t,a,s,(t.subtreeFlags&10256)!==0||!1)),o&2048&&$o(p,t);break;case 24:mn(e,t,a,s),o&2048&&Vo(t.alternate,t);break;default:mn(e,t,a,s)}}function _a(e,t,a,s,o){for(o=o&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var c=e,p=t,y=a,S=s,O=p.flags;switch(p.tag){case 0:case 11:case 15:_a(c,p,y,S,o),Nr(8,p);break;case 23:break;case 22:var L=p.stateNode;p.memoizedState!==null?L._visibility&2?_a(c,p,y,S,o):kr(c,p):(L._visibility|=2,_a(c,p,y,S,o)),o&&O&2048&&$o(p.alternate,p);break;case 24:_a(c,p,y,S,o),o&&O&2048&&Vo(p.alternate,p);break;default:_a(c,p,y,S,o)}t=t.sibling}}function kr(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=e,s=t,o=s.flags;switch(s.tag){case 22:kr(a,s),o&2048&&$o(s.alternate,s);break;case 24:kr(a,s),o&2048&&Vo(s.alternate,s);break;default:kr(a,s)}t=t.sibling}}var jr=8192;function Ua(e,t,a){if(e.subtreeFlags&jr)for(e=e.child;e!==null;)yp(e,t,a),e=e.sibling}function yp(e,t,a){switch(e.tag){case 26:Ua(e,t,a),e.flags&jr&&e.memoizedState!==null&&tx(a,pn,e.memoizedState,e.memoizedProps);break;case 5:Ua(e,t,a);break;case 3:case 4:var s=pn;pn=bl(e.stateNode.containerInfo),Ua(e,t,a),pn=s;break;case 22:e.memoizedState===null&&(s=e.alternate,s!==null&&s.memoizedState!==null?(s=jr,jr=16777216,Ua(e,t,a),jr=s):Ua(e,t,a));break;default:Ua(e,t,a)}}function vp(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Gr(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var s=t[a];dt=s,xp(s,e)}vp(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)bp(e),e=e.sibling}function bp(e){switch(e.tag){case 0:case 11:case 15:Gr(e),e.flags&2048&&ci(9,e,e.return);break;case 3:Gr(e);break;case 12:Gr(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,sl(e)):Gr(e);break;default:Gr(e)}}function sl(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var s=t[a];dt=s,xp(s,e)}vp(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:ci(8,t,t.return),sl(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,sl(t));break;default:sl(t)}e=e.sibling}}function xp(e,t){for(;dt!==null;){var a=dt;switch(a.tag){case 0:case 11:case 15:ci(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var s=a.memoizedState.cachePool.pool;s!=null&&s.refCount++}break;case 24:Sr(a.memoizedState.cache)}if(s=a.child,s!==null)s.return=a,dt=s;else e:for(a=e;dt!==null;){s=dt;var o=s.sibling,c=s.return;if(cp(s),s===a){dt=null;break e}if(o!==null){o.return=c,dt=o;break e}dt=c}}}var gb={getCacheForType:function(e){var t=yt(rt),a=t.data.get(e);return a===void 0&&(a=e(),t.data.set(e,a)),a},cacheSignal:function(){return yt(rt).controller.signal}},yb=typeof WeakMap=="function"?WeakMap:Map,_e=0,Be=null,xe=null,Ee=0,Ne=0,$t=null,fi=!1,Na=!1,Io=!1,Fn=0,Je=0,di=0,Zi=0,Fo=0,Vt=0,La=0,Br=null,_t=null,Ho=!1,ll=0,Sp=0,ul=1/0,ol=null,hi=null,ot=0,pi=null,ka=null,Hn=0,qo=0,Yo=null,wp=null,$r=0,Xo=null;function It(){return(_e&2)!==0&&Ee!==0?Ee&-Ee:R.T!==null?Jo():Gf()}function Ep(){if(Vt===0)if((Ee&536870912)===0||Me){var e=ys;ys<<=1,(ys&3932160)===0&&(ys=262144),Vt=e}else Vt=536870912;return e=Gt.current,e!==null&&(e.flags|=32),Vt}function Ut(e,t,a){(e===Be&&(Ne===2||Ne===9)||e.cancelPendingCommit!==null)&&(ja(e,0),mi(e,Ee,Vt,!1)),lr(e,a),((_e&2)===0||e!==Be)&&(e===Be&&((_e&2)===0&&(Zi|=a),Je===4&&mi(e,Ee,Vt,!1)),Sn(e))}function Ap(e,t,a){if((_e&6)!==0)throw Error(l(327));var s=!a&&(t&127)===0&&(t&e.expiredLanes)===0||sr(e,t),o=s?xb(e,t):Ko(e,t,!0),c=s;do{if(o===0){Na&&!s&&mi(e,t,0,!1);break}else{if(a=e.current.alternate,c&&!vb(a)){o=Ko(e,t,!1),c=!1;continue}if(o===2){if(c=t,e.errorRecoveryDisabledLanes&c)var p=0;else p=e.pendingLanes&-536870913,p=p!==0?p:p&536870912?536870912:0;if(p!==0){t=p;e:{var y=e;o=Br;var S=y.current.memoizedState.isDehydrated;if(S&&(ja(y,p).flags|=256),p=Ko(y,p,!1),p!==2){if(Io&&!S){y.errorRecoveryDisabledLanes|=c,Zi|=c,o=4;break e}c=_t,_t=o,c!==null&&(_t===null?_t=c:_t.push.apply(_t,c))}o=p}if(c=!1,o!==2)continue}}if(o===1){ja(e,0),mi(e,t,0,!0);break}e:{switch(s=e,c=o,c){case 0:case 1:throw Error(l(345));case 4:if((t&4194048)!==t)break;case 6:mi(s,t,Vt,!fi);break e;case 2:_t=null;break;case 3:case 5:break;default:throw Error(l(329))}if((t&62914560)===t&&(o=ll+300-Ve(),10<o)){if(mi(s,t,Vt,!fi),bs(s,0,!0)!==0)break e;Hn=t,s.timeoutHandle=tm(Tp.bind(null,s,a,_t,ol,Ho,t,Vt,Zi,La,fi,c,"Throttled",-0,0),o);break e}Tp(s,a,_t,ol,Ho,t,Vt,Zi,La,fi,c,null,-0,0)}}break}while(!0);Sn(e)}function Tp(e,t,a,s,o,c,p,y,S,O,L,B,z,_){if(e.timeoutHandle=-1,B=t.subtreeFlags,B&8192||(B&16785408)===16785408){B={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Cn},yp(t,c,B);var ne=(c&62914560)===c?ll-Ve():(c&4194048)===c?Sp-Ve():0;if(ne=nx(B,ne),ne!==null){Hn=c,e.cancelPendingCommit=ne(Up.bind(null,e,t,c,a,s,o,p,y,S,L,B,null,z,_)),mi(e,c,p,!O);return}}Up(e,t,c,a,s,o,p,y,S)}function vb(e){for(var t=e;;){var a=t.tag;if((a===0||a===11||a===15)&&t.flags&16384&&(a=t.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var s=0;s<a.length;s++){var o=a[s],c=o.getSnapshot;o=o.value;try{if(!kt(c(),o))return!1}catch{return!1}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function mi(e,t,a,s){t&=~Fo,t&=~Zi,e.suspendedLanes|=t,e.pingedLanes&=~t,s&&(e.warmLanes|=t),s=e.expirationTimes;for(var o=t;0<o;){var c=31-tt(o),p=1<<c;s[c]=-1,o&=~p}a!==0&&Lf(e,a,t)}function cl(){return(_e&6)===0?(Vr(0),!1):!0}function Qo(){if(xe!==null){if(Ne===0)var e=xe.return;else e=xe,Un=Vi=null,oo(e),Da=null,Er=0,e=xe;for(;e!==null;)np(e.alternate,e),e=e.return;xe=null}}function ja(e,t){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,Gb(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),Hn=0,Qo(),Be=e,xe=a=zn(e.current,null),Ee=t,Ne=0,$t=null,fi=!1,Na=sr(e,t),Io=!1,La=Vt=Fo=Zi=di=Je=0,_t=Br=null,Ho=!1,(t&8)!==0&&(t|=t&32);var s=e.entangledLanes;if(s!==0)for(e=e.entanglements,s&=t;0<s;){var o=31-tt(s),c=1<<o;t|=e[o],s&=~c}return Fn=t,zs(),a}function Mp(e,t){ge=null,R.H=zr,t===Ma||t===Bs?(t=Id(),Ne=3):t===Pu?(t=Id(),Ne=4):Ne=t===Mo?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,$t=t,xe===null&&(Je=1,Js(e,Wt(t,e.current)))}function Dp(){var e=Gt.current;return e===null?!0:(Ee&4194048)===Ee?nn===null:(Ee&62914560)===Ee||(Ee&536870912)!==0?e===nn:!1}function Rp(){var e=R.H;return R.H=zr,e===null?zr:e}function Cp(){var e=R.A;return R.A=gb,e}function fl(){Je=4,fi||(Ee&4194048)!==Ee&&Gt.current!==null||(Na=!0),(di&134217727)===0&&(Zi&134217727)===0||Be===null||mi(Be,Ee,Vt,!1)}function Ko(e,t,a){var s=_e;_e|=2;var o=Rp(),c=Cp();(Be!==e||Ee!==t)&&(ol=null,ja(e,t)),t=!1;var p=Je;e:do try{if(Ne!==0&&xe!==null){var y=xe,S=$t;switch(Ne){case 8:Qo(),p=6;break e;case 3:case 2:case 9:case 6:Gt.current===null&&(t=!0);var O=Ne;if(Ne=0,$t=null,Ga(e,y,S,O),a&&Na){p=0;break e}break;default:O=Ne,Ne=0,$t=null,Ga(e,y,S,O)}}bb(),p=Je;break}catch(L){Mp(e,L)}while(!0);return t&&e.shellSuspendCounter++,Un=Vi=null,_e=s,R.H=o,R.A=c,xe===null&&(Be=null,Ee=0,zs()),p}function bb(){for(;xe!==null;)Op(xe)}function xb(e,t){var a=_e;_e|=2;var s=Rp(),o=Cp();Be!==e||Ee!==t?(ol=null,ul=Ve()+500,ja(e,t)):Na=sr(e,t);e:do try{if(Ne!==0&&xe!==null){t=xe;var c=$t;t:switch(Ne){case 1:Ne=0,$t=null,Ga(e,t,c,1);break;case 2:case 9:if($d(c)){Ne=0,$t=null,zp(t);break}t=function(){Ne!==2&&Ne!==9||Be!==e||(Ne=7),Sn(e)},c.then(t,t);break e;case 3:Ne=7;break e;case 4:Ne=5;break e;case 7:$d(c)?(Ne=0,$t=null,zp(t)):(Ne=0,$t=null,Ga(e,t,c,7));break;case 5:var p=null;switch(xe.tag){case 26:p=xe.memoizedState;case 5:case 27:var y=xe;if(p?gm(p):y.stateNode.complete){Ne=0,$t=null;var S=y.sibling;if(S!==null)xe=S;else{var O=y.return;O!==null?(xe=O,dl(O)):xe=null}break t}}Ne=0,$t=null,Ga(e,t,c,5);break;case 6:Ne=0,$t=null,Ga(e,t,c,6);break;case 8:Qo(),Je=6;break e;default:throw Error(l(462))}}Sb();break}catch(L){Mp(e,L)}while(!0);return Un=Vi=null,R.H=s,R.A=o,_e=a,xe!==null?0:(Be=null,Ee=0,zs(),Je)}function Sb(){for(;xe!==null&&!Ke();)Op(xe)}function Op(e){var t=ep(e.alternate,e,Fn);e.memoizedProps=e.pendingProps,t===null?dl(e):xe=t}function zp(e){var t=e,a=t.alternate;switch(t.tag){case 15:case 0:t=Qh(a,t,t.pendingProps,t.type,void 0,Ee);break;case 11:t=Qh(a,t,t.pendingProps,t.type.render,t.ref,Ee);break;case 5:oo(t);default:np(a,t),t=xe=Cd(t,Fn),t=ep(a,t,Fn)}e.memoizedProps=e.pendingProps,t===null?dl(e):xe=t}function Ga(e,t,a,s){Un=Vi=null,oo(t),Da=null,Er=0;var o=t.return;try{if(ob(e,o,t,a,Ee)){Je=1,Js(e,Wt(a,e.current)),xe=null;return}}catch(c){if(o!==null)throw xe=o,c;Je=1,Js(e,Wt(a,e.current)),xe=null;return}t.flags&32768?(Me||s===1?e=!0:Na||(Ee&536870912)!==0?e=!1:(fi=e=!0,(s===2||s===9||s===3||s===6)&&(s=Gt.current,s!==null&&s.tag===13&&(s.flags|=16384))),_p(t,e)):dl(t)}function dl(e){var t=e;do{if((t.flags&32768)!==0){_p(t,fi);return}e=t.return;var a=db(t.alternate,t,Fn);if(a!==null){xe=a;return}if(t=t.sibling,t!==null){xe=t;return}xe=t=e}while(t!==null);Je===0&&(Je=5)}function _p(e,t){do{var a=hb(e.alternate,e);if(a!==null){a.flags&=32767,xe=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(e=e.sibling,e!==null)){xe=e;return}xe=e=a}while(e!==null);Je=6,xe=null}function Up(e,t,a,s,o,c,p,y,S){e.cancelPendingCommit=null;do hl();while(ot!==0);if((_e&6)!==0)throw Error(l(327));if(t!==null){if(t===e.current)throw Error(l(177));if(c=t.lanes|t.childLanes,c|=ku,ev(e,a,c,p,y,S),e===Be&&(xe=Be=null,Ee=0),ka=t,pi=e,Hn=a,qo=c,Yo=o,wp=s,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Tb(Mn,function(){return Gp(),null})):(e.callbackNode=null,e.callbackPriority=0),s=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||s){s=R.T,R.T=null,o=H.p,H.p=2,p=_e,_e|=4;try{pb(e,t,a)}finally{_e=p,H.p=o,R.T=s}}ot=1,Np(),Lp(),kp()}}function Np(){if(ot===1){ot=0;var e=pi,t=ka,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=R.T,R.T=null;var s=H.p;H.p=2;var o=_e;_e|=4;try{pp(t,e);var c=lc,p=xd(e.containerInfo),y=c.focusedElem,S=c.selectionRange;if(p!==y&&y&&y.ownerDocument&&bd(y.ownerDocument.documentElement,y)){if(S!==null&&zu(y)){var O=S.start,L=S.end;if(L===void 0&&(L=O),"selectionStart"in y)y.selectionStart=O,y.selectionEnd=Math.min(L,y.value.length);else{var B=y.ownerDocument||document,z=B&&B.defaultView||window;if(z.getSelection){var _=z.getSelection(),ne=y.textContent.length,ce=Math.min(S.start,ne),Ge=S.end===void 0?ce:Math.min(S.end,ne);!_.extend&&ce>Ge&&(p=Ge,Ge=ce,ce=p);var T=vd(y,ce),A=vd(y,Ge);if(T&&A&&(_.rangeCount!==1||_.anchorNode!==T.node||_.anchorOffset!==T.offset||_.focusNode!==A.node||_.focusOffset!==A.offset)){var C=B.createRange();C.setStart(T.node,T.offset),_.removeAllRanges(),ce>Ge?(_.addRange(C),_.extend(A.node,A.offset)):(C.setEnd(A.node,A.offset),_.addRange(C))}}}}for(B=[],_=y;_=_.parentNode;)_.nodeType===1&&B.push({element:_,left:_.scrollLeft,top:_.scrollTop});for(typeof y.focus=="function"&&y.focus(),y=0;y<B.length;y++){var G=B[y];G.element.scrollLeft=G.left,G.element.scrollTop=G.top}}Tl=!!sc,lc=sc=null}finally{_e=o,H.p=s,R.T=a}}e.current=t,ot=2}}function Lp(){if(ot===2){ot=0;var e=pi,t=ka,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=R.T,R.T=null;var s=H.p;H.p=2;var o=_e;_e|=4;try{op(e,t.alternate,t)}finally{_e=o,H.p=s,R.T=a}}ot=3}}function kp(){if(ot===4||ot===3){ot=0,Qt();var e=pi,t=ka,a=Hn,s=wp;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?ot=5:(ot=0,ka=pi=null,jp(e,e.pendingLanes));var o=e.pendingLanes;if(o===0&&(hi=null),du(a),t=t.stateNode,He&&typeof He.onCommitFiberRoot=="function")try{He.onCommitFiberRoot(ct,t,void 0,(t.current.flags&128)===128)}catch{}if(s!==null){t=R.T,o=H.p,H.p=2,R.T=null;try{for(var c=e.onRecoverableError,p=0;p<s.length;p++){var y=s[p];c(y.value,{componentStack:y.stack})}}finally{R.T=t,H.p=o}}(Hn&3)!==0&&hl(),Sn(e),o=e.pendingLanes,(a&261930)!==0&&(o&42)!==0?e===Xo?$r++:($r=0,Xo=e):$r=0,Vr(0)}}function jp(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Sr(t)))}function hl(){return Np(),Lp(),kp(),Gp()}function Gp(){if(ot!==5)return!1;var e=pi,t=qo;qo=0;var a=du(Hn),s=R.T,o=H.p;try{H.p=32>a?32:a,R.T=null,a=Yo,Yo=null;var c=pi,p=Hn;if(ot=0,ka=pi=null,Hn=0,(_e&6)!==0)throw Error(l(331));var y=_e;if(_e|=4,bp(c.current),gp(c,c.current,p,a),_e=y,Vr(0,!1),He&&typeof He.onPostCommitFiberRoot=="function")try{He.onPostCommitFiberRoot(ct,c)}catch{}return!0}finally{H.p=o,R.T=s,jp(e,t)}}function Bp(e,t,a){t=Wt(a,t),t=To(e.stateNode,t,2),e=li(e,t,2),e!==null&&(lr(e,2),Sn(e))}function Le(e,t,a){if(e.tag===3)Bp(e,e,a);else for(;t!==null;){if(t.tag===3){Bp(t,e,a);break}else if(t.tag===1){var s=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(hi===null||!hi.has(s))){e=Wt(a,e),a=$h(2),s=li(t,a,2),s!==null&&(Vh(a,s,t,e),lr(s,2),Sn(s));break}}t=t.return}}function Zo(e,t,a){var s=e.pingCache;if(s===null){s=e.pingCache=new yb;var o=new Set;s.set(t,o)}else o=s.get(t),o===void 0&&(o=new Set,s.set(t,o));o.has(a)||(Io=!0,o.add(a),e=wb.bind(null,e,t,a),t.then(e,e))}function wb(e,t,a){var s=e.pingCache;s!==null&&s.delete(t),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,Be===e&&(Ee&a)===a&&(Je===4||Je===3&&(Ee&62914560)===Ee&&300>Ve()-ll?(_e&2)===0&&ja(e,0):Fo|=a,La===Ee&&(La=0)),Sn(e)}function $p(e,t){t===0&&(t=Nf()),e=Gi(e,t),e!==null&&(lr(e,t),Sn(e))}function Eb(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),$p(e,a)}function Ab(e,t){var a=0;switch(e.tag){case 31:case 13:var s=e.stateNode,o=e.memoizedState;o!==null&&(a=o.retryLane);break;case 19:s=e.stateNode;break;case 22:s=e.stateNode._retryCache;break;default:throw Error(l(314))}s!==null&&s.delete(t),$p(e,a)}function Tb(e,t){return Ce(e,t)}var pl=null,Ba=null,Po=!1,ml=!1,Wo=!1,gi=0;function Sn(e){e!==Ba&&e.next===null&&(Ba===null?pl=Ba=e:Ba=Ba.next=e),ml=!0,Po||(Po=!0,Db())}function Vr(e,t){if(!Wo&&ml){Wo=!0;do for(var a=!1,s=pl;s!==null;){if(e!==0){var o=s.pendingLanes;if(o===0)var c=0;else{var p=s.suspendedLanes,y=s.pingedLanes;c=(1<<31-tt(42|e)+1)-1,c&=o&~(p&~y),c=c&201326741?c&201326741|1:c?c|2:0}c!==0&&(a=!0,Hp(s,c))}else c=Ee,c=bs(s,s===Be?c:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),(c&3)===0||sr(s,c)||(a=!0,Hp(s,c));s=s.next}while(a);Wo=!1}}function Mb(){Vp()}function Vp(){ml=Po=!1;var e=0;gi!==0&&jb()&&(e=gi);for(var t=Ve(),a=null,s=pl;s!==null;){var o=s.next,c=Ip(s,t);c===0?(s.next=null,a===null?pl=o:a.next=o,o===null&&(Ba=a)):(a=s,(e!==0||(c&3)!==0)&&(ml=!0)),s=o}ot!==0&&ot!==5||Vr(e),gi!==0&&(gi=0)}function Ip(e,t){for(var a=e.suspendedLanes,s=e.pingedLanes,o=e.expirationTimes,c=e.pendingLanes&-62914561;0<c;){var p=31-tt(c),y=1<<p,S=o[p];S===-1?((y&a)===0||(y&s)!==0)&&(o[p]=Jy(y,t)):S<=t&&(e.expiredLanes|=y),c&=~y}if(t=Be,a=Ee,a=bs(e,e===t?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s=e.callbackNode,a===0||e===t&&(Ne===2||Ne===9)||e.cancelPendingCommit!==null)return s!==null&&s!==null&&Qe(s),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||sr(e,a)){if(t=a&-a,t===e.callbackPriority)return t;switch(s!==null&&Qe(s),du(a)){case 2:case 8:a=Lt;break;case 32:a=Mn;break;case 268435456:a=Dn;break;default:a=Mn}return s=Fp.bind(null,e),a=Ce(a,s),e.callbackPriority=t,e.callbackNode=a,t}return s!==null&&s!==null&&Qe(s),e.callbackPriority=2,e.callbackNode=null,2}function Fp(e,t){if(ot!==0&&ot!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(hl()&&e.callbackNode!==a)return null;var s=Ee;return s=bs(e,e===Be?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s===0?null:(Ap(e,s,t),Ip(e,Ve()),e.callbackNode!=null&&e.callbackNode===a?Fp.bind(null,e):null)}function Hp(e,t){if(hl())return null;Ap(e,t,!0)}function Db(){Bb(function(){(_e&6)!==0?Ce(xt,Mb):Vp()})}function Jo(){if(gi===0){var e=Aa;e===0&&(e=gs,gs<<=1,(gs&261888)===0&&(gs=256)),gi=e}return gi}function qp(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Es(""+e)}function Yp(e,t){var a=t.ownerDocument.createElement("input");return a.name=t.name,a.value=t.value,e.id&&a.setAttribute("form",e.id),t.parentNode.insertBefore(a,t),e=new FormData(e),a.parentNode.removeChild(a),e}function Rb(e,t,a,s,o){if(t==="submit"&&a&&a.stateNode===o){var c=qp((o[Dt]||null).action),p=s.submitter;p&&(t=(t=p[Dt]||null)?qp(t.formAction):p.getAttribute("formAction"),t!==null&&(c=t,p=null));var y=new Ds("action","action",null,s,o);e.push({event:y,listeners:[{instance:null,listener:function(){if(s.defaultPrevented){if(gi!==0){var S=p?Yp(o,p):new FormData(o);bo(a,{pending:!0,data:S,method:o.method,action:c},null,S)}}else typeof c=="function"&&(y.preventDefault(),S=p?Yp(o,p):new FormData(o),bo(a,{pending:!0,data:S,method:o.method,action:c},c,S))},currentTarget:o}]})}}for(var ec=0;ec<Lu.length;ec++){var tc=Lu[ec],Cb=tc.toLowerCase(),Ob=tc[0].toUpperCase()+tc.slice(1);hn(Cb,"on"+Ob)}hn(Ed,"onAnimationEnd"),hn(Ad,"onAnimationIteration"),hn(Td,"onAnimationStart"),hn("dblclick","onDoubleClick"),hn("focusin","onFocus"),hn("focusout","onBlur"),hn(Yv,"onTransitionRun"),hn(Xv,"onTransitionStart"),hn(Qv,"onTransitionCancel"),hn(Md,"onTransitionEnd"),ca("onMouseEnter",["mouseout","mouseover"]),ca("onMouseLeave",["mouseout","mouseover"]),ca("onPointerEnter",["pointerout","pointerover"]),ca("onPointerLeave",["pointerout","pointerover"]),Ni("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ni("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ni("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ni("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ni("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ni("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ir="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),zb=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ir));function Xp(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var s=e[a],o=s.event;s=s.listeners;e:{var c=void 0;if(t)for(var p=s.length-1;0<=p;p--){var y=s[p],S=y.instance,O=y.currentTarget;if(y=y.listener,S!==c&&o.isPropagationStopped())break e;c=y,o.currentTarget=O;try{c(o)}catch(L){Os(L)}o.currentTarget=null,c=S}else for(p=0;p<s.length;p++){if(y=s[p],S=y.instance,O=y.currentTarget,y=y.listener,S!==c&&o.isPropagationStopped())break e;c=y,o.currentTarget=O;try{c(o)}catch(L){Os(L)}o.currentTarget=null,c=S}}}}function Se(e,t){var a=t[hu];a===void 0&&(a=t[hu]=new Set);var s=e+"__bubble";a.has(s)||(Qp(t,e,2,!1),a.add(s))}function nc(e,t,a){var s=0;t&&(s|=4),Qp(a,e,s,t)}var gl="_reactListening"+Math.random().toString(36).slice(2);function ic(e){if(!e[gl]){e[gl]=!0,Vf.forEach(function(a){a!=="selectionchange"&&(zb.has(a)||nc(a,!1,e),nc(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[gl]||(t[gl]=!0,nc("selectionchange",!1,t))}}function Qp(e,t,a,s){switch(Em(t)){case 2:var o=rx;break;case 8:o=sx;break;default:o=vc}a=o.bind(null,t,a,e),o=void 0,!wu||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(o=!0),s?o!==void 0?e.addEventListener(t,a,{capture:!0,passive:o}):e.addEventListener(t,a,!0):o!==void 0?e.addEventListener(t,a,{passive:o}):e.addEventListener(t,a,!1)}function ac(e,t,a,s,o){var c=s;if((t&1)===0&&(t&2)===0&&s!==null)e:for(;;){if(s===null)return;var p=s.tag;if(p===3||p===4){var y=s.stateNode.containerInfo;if(y===o)break;if(p===4)for(p=s.return;p!==null;){var S=p.tag;if((S===3||S===4)&&p.stateNode.containerInfo===o)return;p=p.return}for(;y!==null;){if(p=la(y),p===null)return;if(S=p.tag,S===5||S===6||S===26||S===27){s=c=p;continue e}y=y.parentNode}}s=s.return}Jf(function(){var O=c,L=xu(a),B=[];e:{var z=Dd.get(e);if(z!==void 0){var _=Ds,ne=e;switch(e){case"keypress":if(Ts(a)===0)break e;case"keydown":case"keyup":_=Av;break;case"focusin":ne="focus",_=Mu;break;case"focusout":ne="blur",_=Mu;break;case"beforeblur":case"afterblur":_=Mu;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":_=nd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":_=dv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":_=Dv;break;case Ed:case Ad:case Td:_=mv;break;case Md:_=Cv;break;case"scroll":case"scrollend":_=cv;break;case"wheel":_=zv;break;case"copy":case"cut":case"paste":_=yv;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":_=ad;break;case"toggle":case"beforetoggle":_=Uv}var ce=(t&4)!==0,Ge=!ce&&(e==="scroll"||e==="scrollend"),T=ce?z!==null?z+"Capture":null:z;ce=[];for(var A=O,C;A!==null;){var G=A;if(C=G.stateNode,G=G.tag,G!==5&&G!==26&&G!==27||C===null||T===null||(G=cr(A,T),G!=null&&ce.push(Fr(A,G,C))),Ge)break;A=A.return}0<ce.length&&(z=new _(z,ne,null,a,L),B.push({event:z,listeners:ce}))}}if((t&7)===0){e:{if(z=e==="mouseover"||e==="pointerover",_=e==="mouseout"||e==="pointerout",z&&a!==bu&&(ne=a.relatedTarget||a.fromElement)&&(la(ne)||ne[sa]))break e;if((_||z)&&(z=L.window===L?L:(z=L.ownerDocument)?z.defaultView||z.parentWindow:window,_?(ne=a.relatedTarget||a.toElement,_=O,ne=ne?la(ne):null,ne!==null&&(Ge=f(ne),ce=ne.tag,ne!==Ge||ce!==5&&ce!==27&&ce!==6)&&(ne=null)):(_=null,ne=O),_!==ne)){if(ce=nd,G="onMouseLeave",T="onMouseEnter",A="mouse",(e==="pointerout"||e==="pointerover")&&(ce=ad,G="onPointerLeave",T="onPointerEnter",A="pointer"),Ge=_==null?z:or(_),C=ne==null?z:or(ne),z=new ce(G,A+"leave",_,a,L),z.target=Ge,z.relatedTarget=C,G=null,la(L)===O&&(ce=new ce(T,A+"enter",ne,a,L),ce.target=C,ce.relatedTarget=Ge,G=ce),Ge=G,_&&ne)t:{for(ce=_b,T=_,A=ne,C=0,G=T;G;G=ce(G))C++;G=0;for(var ue=A;ue;ue=ce(ue))G++;for(;0<C-G;)T=ce(T),C--;for(;0<G-C;)A=ce(A),G--;for(;C--;){if(T===A||A!==null&&T===A.alternate){ce=T;break t}T=ce(T),A=ce(A)}ce=null}else ce=null;_!==null&&Kp(B,z,_,ce,!1),ne!==null&&Ge!==null&&Kp(B,Ge,ne,ce,!0)}}e:{if(z=O?or(O):window,_=z.nodeName&&z.nodeName.toLowerCase(),_==="select"||_==="input"&&z.type==="file")var Oe=dd;else if(cd(z))if(hd)Oe=Fv;else{Oe=Vv;var re=$v}else _=z.nodeName,!_||_.toLowerCase()!=="input"||z.type!=="checkbox"&&z.type!=="radio"?O&&vu(O.elementType)&&(Oe=dd):Oe=Iv;if(Oe&&(Oe=Oe(e,O))){fd(B,Oe,a,L);break e}re&&re(e,z,O),e==="focusout"&&O&&z.type==="number"&&O.memoizedProps.value!=null&&yu(z,"number",z.value)}switch(re=O?or(O):window,e){case"focusin":(cd(re)||re.contentEditable==="true")&&(ga=re,_u=O,vr=null);break;case"focusout":vr=_u=ga=null;break;case"mousedown":Uu=!0;break;case"contextmenu":case"mouseup":case"dragend":Uu=!1,Sd(B,a,L);break;case"selectionchange":if(qv)break;case"keydown":case"keyup":Sd(B,a,L)}var ve;if(Ru)e:{switch(e){case"compositionstart":var Ae="onCompositionStart";break e;case"compositionend":Ae="onCompositionEnd";break e;case"compositionupdate":Ae="onCompositionUpdate";break e}Ae=void 0}else ma?ud(e,a)&&(Ae="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(Ae="onCompositionStart");Ae&&(rd&&a.locale!=="ko"&&(ma||Ae!=="onCompositionStart"?Ae==="onCompositionEnd"&&ma&&(ve=ed()):(ei=L,Eu="value"in ei?ei.value:ei.textContent,ma=!0)),re=yl(O,Ae),0<re.length&&(Ae=new id(Ae,e,null,a,L),B.push({event:Ae,listeners:re}),ve?Ae.data=ve:(ve=od(a),ve!==null&&(Ae.data=ve)))),(ve=Lv?kv(e,a):jv(e,a))&&(Ae=yl(O,"onBeforeInput"),0<Ae.length&&(re=new id("onBeforeInput","beforeinput",null,a,L),B.push({event:re,listeners:Ae}),re.data=ve)),Rb(B,e,O,a,L)}Xp(B,t)})}function Fr(e,t,a){return{instance:e,listener:t,currentTarget:a}}function yl(e,t){for(var a=t+"Capture",s=[];e!==null;){var o=e,c=o.stateNode;if(o=o.tag,o!==5&&o!==26&&o!==27||c===null||(o=cr(e,a),o!=null&&s.unshift(Fr(e,o,c)),o=cr(e,t),o!=null&&s.push(Fr(e,o,c))),e.tag===3)return s;e=e.return}return[]}function _b(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Kp(e,t,a,s,o){for(var c=t._reactName,p=[];a!==null&&a!==s;){var y=a,S=y.alternate,O=y.stateNode;if(y=y.tag,S!==null&&S===s)break;y!==5&&y!==26&&y!==27||O===null||(S=O,o?(O=cr(a,c),O!=null&&p.unshift(Fr(a,O,S))):o||(O=cr(a,c),O!=null&&p.push(Fr(a,O,S)))),a=a.return}p.length!==0&&e.push({event:t,listeners:p})}var Ub=/\r\n?/g,Nb=/\u0000|\uFFFD/g;function Zp(e){return(typeof e=="string"?e:""+e).replace(Ub,`
|
|
9
|
+
`).replace(Nb,"")}function Pp(e,t){return t=Zp(t),Zp(e)===t}function je(e,t,a,s,o,c){switch(a){case"children":typeof s=="string"?t==="body"||t==="textarea"&&s===""||da(e,s):(typeof s=="number"||typeof s=="bigint")&&t!=="body"&&da(e,""+s);break;case"className":Ss(e,"class",s);break;case"tabIndex":Ss(e,"tabindex",s);break;case"dir":case"role":case"viewBox":case"width":case"height":Ss(e,a,s);break;case"style":Pf(e,s,c);break;case"data":if(t!=="object"){Ss(e,"data",s);break}case"src":case"href":if(s===""&&(t!=="a"||a!=="href")){e.removeAttribute(a);break}if(s==null||typeof s=="function"||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(a);break}s=Es(""+s),e.setAttribute(a,s);break;case"action":case"formAction":if(typeof s=="function"){e.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof c=="function"&&(a==="formAction"?(t!=="input"&&je(e,t,"name",o.name,o,null),je(e,t,"formEncType",o.formEncType,o,null),je(e,t,"formMethod",o.formMethod,o,null),je(e,t,"formTarget",o.formTarget,o,null)):(je(e,t,"encType",o.encType,o,null),je(e,t,"method",o.method,o,null),je(e,t,"target",o.target,o,null)));if(s==null||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(a);break}s=Es(""+s),e.setAttribute(a,s);break;case"onClick":s!=null&&(e.onclick=Cn);break;case"onScroll":s!=null&&Se("scroll",e);break;case"onScrollEnd":s!=null&&Se("scrollend",e);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(l(61));if(a=s.__html,a!=null){if(o.children!=null)throw Error(l(60));e.innerHTML=a}}break;case"multiple":e.multiple=s&&typeof s!="function"&&typeof s!="symbol";break;case"muted":e.muted=s&&typeof s!="function"&&typeof s!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(s==null||typeof s=="function"||typeof s=="boolean"||typeof s=="symbol"){e.removeAttribute("xlink:href");break}a=Es(""+s),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(a,""+s):e.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":s&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":s===!0?e.setAttribute(a,""):s!==!1&&s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(a,s):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":s!=null&&typeof s!="function"&&typeof s!="symbol"&&!isNaN(s)&&1<=s?e.setAttribute(a,s):e.removeAttribute(a);break;case"rowSpan":case"start":s==null||typeof s=="function"||typeof s=="symbol"||isNaN(s)?e.removeAttribute(a):e.setAttribute(a,s);break;case"popover":Se("beforetoggle",e),Se("toggle",e),xs(e,"popover",s);break;case"xlinkActuate":Rn(e,"http://www.w3.org/1999/xlink","xlink:actuate",s);break;case"xlinkArcrole":Rn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",s);break;case"xlinkRole":Rn(e,"http://www.w3.org/1999/xlink","xlink:role",s);break;case"xlinkShow":Rn(e,"http://www.w3.org/1999/xlink","xlink:show",s);break;case"xlinkTitle":Rn(e,"http://www.w3.org/1999/xlink","xlink:title",s);break;case"xlinkType":Rn(e,"http://www.w3.org/1999/xlink","xlink:type",s);break;case"xmlBase":Rn(e,"http://www.w3.org/XML/1998/namespace","xml:base",s);break;case"xmlLang":Rn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",s);break;case"xmlSpace":Rn(e,"http://www.w3.org/XML/1998/namespace","xml:space",s);break;case"is":xs(e,"is",s);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=uv.get(a)||a,xs(e,a,s))}}function rc(e,t,a,s,o,c){switch(a){case"style":Pf(e,s,c);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(l(61));if(a=s.__html,a!=null){if(o.children!=null)throw Error(l(60));e.innerHTML=a}}break;case"children":typeof s=="string"?da(e,s):(typeof s=="number"||typeof s=="bigint")&&da(e,""+s);break;case"onScroll":s!=null&&Se("scroll",e);break;case"onScrollEnd":s!=null&&Se("scrollend",e);break;case"onClick":s!=null&&(e.onclick=Cn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!If.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(o=a.endsWith("Capture"),t=a.slice(2,o?a.length-7:void 0),c=e[Dt]||null,c=c!=null?c[a]:null,typeof c=="function"&&e.removeEventListener(t,c,o),typeof s=="function")){typeof c!="function"&&c!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(t,s,o);break e}a in e?e[a]=s:s===!0?e.setAttribute(a,""):xs(e,a,s)}}}function bt(e,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Se("error",e),Se("load",e);var s=!1,o=!1,c;for(c in a)if(a.hasOwnProperty(c)){var p=a[c];if(p!=null)switch(c){case"src":s=!0;break;case"srcSet":o=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:je(e,t,c,p,a,null)}}o&&je(e,t,"srcSet",a.srcSet,a,null),s&&je(e,t,"src",a.src,a,null);return;case"input":Se("invalid",e);var y=c=p=o=null,S=null,O=null;for(s in a)if(a.hasOwnProperty(s)){var L=a[s];if(L!=null)switch(s){case"name":o=L;break;case"type":p=L;break;case"checked":S=L;break;case"defaultChecked":O=L;break;case"value":c=L;break;case"defaultValue":y=L;break;case"children":case"dangerouslySetInnerHTML":if(L!=null)throw Error(l(137,t));break;default:je(e,t,s,L,a,null)}}Xf(e,c,y,S,O,p,o,!1);return;case"select":Se("invalid",e),s=p=c=null;for(o in a)if(a.hasOwnProperty(o)&&(y=a[o],y!=null))switch(o){case"value":c=y;break;case"defaultValue":p=y;break;case"multiple":s=y;default:je(e,t,o,y,a,null)}t=c,a=p,e.multiple=!!s,t!=null?fa(e,!!s,t,!1):a!=null&&fa(e,!!s,a,!0);return;case"textarea":Se("invalid",e),c=o=s=null;for(p in a)if(a.hasOwnProperty(p)&&(y=a[p],y!=null))switch(p){case"value":s=y;break;case"defaultValue":o=y;break;case"children":c=y;break;case"dangerouslySetInnerHTML":if(y!=null)throw Error(l(91));break;default:je(e,t,p,y,a,null)}Kf(e,s,o,c);return;case"option":for(S in a)a.hasOwnProperty(S)&&(s=a[S],s!=null)&&(S==="selected"?e.selected=s&&typeof s!="function"&&typeof s!="symbol":je(e,t,S,s,a,null));return;case"dialog":Se("beforetoggle",e),Se("toggle",e),Se("cancel",e),Se("close",e);break;case"iframe":case"object":Se("load",e);break;case"video":case"audio":for(s=0;s<Ir.length;s++)Se(Ir[s],e);break;case"image":Se("error",e),Se("load",e);break;case"details":Se("toggle",e);break;case"embed":case"source":case"link":Se("error",e),Se("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(O in a)if(a.hasOwnProperty(O)&&(s=a[O],s!=null))switch(O){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:je(e,t,O,s,a,null)}return;default:if(vu(t)){for(L in a)a.hasOwnProperty(L)&&(s=a[L],s!==void 0&&rc(e,t,L,s,a,void 0));return}}for(y in a)a.hasOwnProperty(y)&&(s=a[y],s!=null&&je(e,t,y,s,a,null))}function Lb(e,t,a,s){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var o=null,c=null,p=null,y=null,S=null,O=null,L=null;for(_ in a){var B=a[_];if(a.hasOwnProperty(_)&&B!=null)switch(_){case"checked":break;case"value":break;case"defaultValue":S=B;default:s.hasOwnProperty(_)||je(e,t,_,null,s,B)}}for(var z in s){var _=s[z];if(B=a[z],s.hasOwnProperty(z)&&(_!=null||B!=null))switch(z){case"type":c=_;break;case"name":o=_;break;case"checked":O=_;break;case"defaultChecked":L=_;break;case"value":p=_;break;case"defaultValue":y=_;break;case"children":case"dangerouslySetInnerHTML":if(_!=null)throw Error(l(137,t));break;default:_!==B&&je(e,t,z,_,s,B)}}gu(e,p,y,S,O,L,c,o);return;case"select":_=p=y=z=null;for(c in a)if(S=a[c],a.hasOwnProperty(c)&&S!=null)switch(c){case"value":break;case"multiple":_=S;default:s.hasOwnProperty(c)||je(e,t,c,null,s,S)}for(o in s)if(c=s[o],S=a[o],s.hasOwnProperty(o)&&(c!=null||S!=null))switch(o){case"value":z=c;break;case"defaultValue":y=c;break;case"multiple":p=c;default:c!==S&&je(e,t,o,c,s,S)}t=y,a=p,s=_,z!=null?fa(e,!!a,z,!1):!!s!=!!a&&(t!=null?fa(e,!!a,t,!0):fa(e,!!a,a?[]:"",!1));return;case"textarea":_=z=null;for(y in a)if(o=a[y],a.hasOwnProperty(y)&&o!=null&&!s.hasOwnProperty(y))switch(y){case"value":break;case"children":break;default:je(e,t,y,null,s,o)}for(p in s)if(o=s[p],c=a[p],s.hasOwnProperty(p)&&(o!=null||c!=null))switch(p){case"value":z=o;break;case"defaultValue":_=o;break;case"children":break;case"dangerouslySetInnerHTML":if(o!=null)throw Error(l(91));break;default:o!==c&&je(e,t,p,o,s,c)}Qf(e,z,_);return;case"option":for(var ne in a)z=a[ne],a.hasOwnProperty(ne)&&z!=null&&!s.hasOwnProperty(ne)&&(ne==="selected"?e.selected=!1:je(e,t,ne,null,s,z));for(S in s)z=s[S],_=a[S],s.hasOwnProperty(S)&&z!==_&&(z!=null||_!=null)&&(S==="selected"?e.selected=z&&typeof z!="function"&&typeof z!="symbol":je(e,t,S,z,s,_));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var ce in a)z=a[ce],a.hasOwnProperty(ce)&&z!=null&&!s.hasOwnProperty(ce)&&je(e,t,ce,null,s,z);for(O in s)if(z=s[O],_=a[O],s.hasOwnProperty(O)&&z!==_&&(z!=null||_!=null))switch(O){case"children":case"dangerouslySetInnerHTML":if(z!=null)throw Error(l(137,t));break;default:je(e,t,O,z,s,_)}return;default:if(vu(t)){for(var Ge in a)z=a[Ge],a.hasOwnProperty(Ge)&&z!==void 0&&!s.hasOwnProperty(Ge)&&rc(e,t,Ge,void 0,s,z);for(L in s)z=s[L],_=a[L],!s.hasOwnProperty(L)||z===_||z===void 0&&_===void 0||rc(e,t,L,z,s,_);return}}for(var T in a)z=a[T],a.hasOwnProperty(T)&&z!=null&&!s.hasOwnProperty(T)&&je(e,t,T,null,s,z);for(B in s)z=s[B],_=a[B],!s.hasOwnProperty(B)||z===_||z==null&&_==null||je(e,t,B,z,s,_)}function Wp(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function kb(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,a=performance.getEntriesByType("resource"),s=0;s<a.length;s++){var o=a[s],c=o.transferSize,p=o.initiatorType,y=o.duration;if(c&&y&&Wp(p)){for(p=0,y=o.responseEnd,s+=1;s<a.length;s++){var S=a[s],O=S.startTime;if(O>y)break;var L=S.transferSize,B=S.initiatorType;L&&Wp(B)&&(S=S.responseEnd,p+=L*(S<y?1:(y-O)/(S-O)))}if(--s,t+=8*(c+p)/(o.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var sc=null,lc=null;function vl(e){return e.nodeType===9?e:e.ownerDocument}function Jp(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function em(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function uc(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var oc=null;function jb(){var e=window.event;return e&&e.type==="popstate"?e===oc?!1:(oc=e,!0):(oc=null,!1)}var tm=typeof setTimeout=="function"?setTimeout:void 0,Gb=typeof clearTimeout=="function"?clearTimeout:void 0,nm=typeof Promise=="function"?Promise:void 0,Bb=typeof queueMicrotask=="function"?queueMicrotask:typeof nm<"u"?function(e){return nm.resolve(null).then(e).catch($b)}:tm;function $b(e){setTimeout(function(){throw e})}function yi(e){return e==="head"}function im(e,t){var a=t,s=0;do{var o=a.nextSibling;if(e.removeChild(a),o&&o.nodeType===8)if(a=o.data,a==="/$"||a==="/&"){if(s===0){e.removeChild(o),Fa(t);return}s--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")s++;else if(a==="html")Hr(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,Hr(a);for(var c=a.firstChild;c;){var p=c.nextSibling,y=c.nodeName;c[ur]||y==="SCRIPT"||y==="STYLE"||y==="LINK"&&c.rel.toLowerCase()==="stylesheet"||a.removeChild(c),c=p}}else a==="body"&&Hr(e.ownerDocument.body);a=o}while(a);Fa(t)}function am(e,t){var a=e;e=0;do{var s=a.nextSibling;if(a.nodeType===1?t?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(t?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),s&&s.nodeType===8)if(a=s.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=s}while(a)}function cc(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var a=t;switch(t=t.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":cc(a),pu(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function Vb(e,t,a,s){for(;e.nodeType===1;){var o=a;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!s&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(s){if(!e[ur])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(c=e.getAttribute("rel"),c==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(c!==o.rel||e.getAttribute("href")!==(o.href==null||o.href===""?null:o.href)||e.getAttribute("crossorigin")!==(o.crossOrigin==null?null:o.crossOrigin)||e.getAttribute("title")!==(o.title==null?null:o.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(c=e.getAttribute("src"),(c!==(o.src==null?null:o.src)||e.getAttribute("type")!==(o.type==null?null:o.type)||e.getAttribute("crossorigin")!==(o.crossOrigin==null?null:o.crossOrigin))&&c&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var c=o.name==null?null:""+o.name;if(o.type==="hidden"&&e.getAttribute("name")===c)return e}else return e;if(e=an(e.nextSibling),e===null)break}return null}function Ib(e,t,a){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=an(e.nextSibling),e===null))return null;return e}function rm(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=an(e.nextSibling),e===null))return null;return e}function fc(e){return e.data==="$?"||e.data==="$~"}function dc(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Fb(e,t){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||a.readyState!=="loading")t();else{var s=function(){t(),a.removeEventListener("DOMContentLoaded",s)};a.addEventListener("DOMContentLoaded",s),e._reactRetry=s}}function an(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var hc=null;function sm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(t===0)return an(e.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}e=e.nextSibling}return null}function lm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(t===0)return e;t--}else a!=="/$"&&a!=="/&"||t++}e=e.previousSibling}return null}function um(e,t,a){switch(t=vl(a),e){case"html":if(e=t.documentElement,!e)throw Error(l(452));return e;case"head":if(e=t.head,!e)throw Error(l(453));return e;case"body":if(e=t.body,!e)throw Error(l(454));return e;default:throw Error(l(451))}}function Hr(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);pu(e)}var rn=new Map,om=new Set;function bl(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var qn=H.d;H.d={f:Hb,r:qb,D:Yb,C:Xb,L:Qb,m:Kb,X:Pb,S:Zb,M:Wb};function Hb(){var e=qn.f(),t=cl();return e||t}function qb(e){var t=ua(e);t!==null&&t.tag===5&&t.type==="form"?Mh(t):qn.r(e)}var $a=typeof document>"u"?null:document;function cm(e,t,a){var s=$a;if(s&&typeof t=="string"&&t){var o=Zt(t);o='link[rel="'+e+'"][href="'+o+'"]',typeof a=="string"&&(o+='[crossorigin="'+a+'"]'),om.has(o)||(om.add(o),e={rel:e,crossOrigin:a,href:t},s.querySelector(o)===null&&(t=s.createElement("link"),bt(t,"link",e),ft(t),s.head.appendChild(t)))}}function Yb(e){qn.D(e),cm("dns-prefetch",e,null)}function Xb(e,t){qn.C(e,t),cm("preconnect",e,t)}function Qb(e,t,a){qn.L(e,t,a);var s=$a;if(s&&e&&t){var o='link[rel="preload"][as="'+Zt(t)+'"]';t==="image"&&a&&a.imageSrcSet?(o+='[imagesrcset="'+Zt(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(o+='[imagesizes="'+Zt(a.imageSizes)+'"]')):o+='[href="'+Zt(e)+'"]';var c=o;switch(t){case"style":c=Va(e);break;case"script":c=Ia(e)}rn.has(c)||(e=b({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:e,as:t},a),rn.set(c,e),s.querySelector(o)!==null||t==="style"&&s.querySelector(qr(c))||t==="script"&&s.querySelector(Yr(c))||(t=s.createElement("link"),bt(t,"link",e),ft(t),s.head.appendChild(t)))}}function Kb(e,t){qn.m(e,t);var a=$a;if(a&&e){var s=t&&typeof t.as=="string"?t.as:"script",o='link[rel="modulepreload"][as="'+Zt(s)+'"][href="'+Zt(e)+'"]',c=o;switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":c=Ia(e)}if(!rn.has(c)&&(e=b({rel:"modulepreload",href:e},t),rn.set(c,e),a.querySelector(o)===null)){switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Yr(c)))return}s=a.createElement("link"),bt(s,"link",e),ft(s),a.head.appendChild(s)}}}function Zb(e,t,a){qn.S(e,t,a);var s=$a;if(s&&e){var o=oa(s).hoistableStyles,c=Va(e);t=t||"default";var p=o.get(c);if(!p){var y={loading:0,preload:null};if(p=s.querySelector(qr(c)))y.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":t},a),(a=rn.get(c))&&pc(e,a);var S=p=s.createElement("link");ft(S),bt(S,"link",e),S._p=new Promise(function(O,L){S.onload=O,S.onerror=L}),S.addEventListener("load",function(){y.loading|=1}),S.addEventListener("error",function(){y.loading|=2}),y.loading|=4,xl(p,t,s)}p={type:"stylesheet",instance:p,count:1,state:y},o.set(c,p)}}}function Pb(e,t){qn.X(e,t);var a=$a;if(a&&e){var s=oa(a).hoistableScripts,o=Ia(e),c=s.get(o);c||(c=a.querySelector(Yr(o)),c||(e=b({src:e,async:!0},t),(t=rn.get(o))&&mc(e,t),c=a.createElement("script"),ft(c),bt(c,"link",e),a.head.appendChild(c)),c={type:"script",instance:c,count:1,state:null},s.set(o,c))}}function Wb(e,t){qn.M(e,t);var a=$a;if(a&&e){var s=oa(a).hoistableScripts,o=Ia(e),c=s.get(o);c||(c=a.querySelector(Yr(o)),c||(e=b({src:e,async:!0,type:"module"},t),(t=rn.get(o))&&mc(e,t),c=a.createElement("script"),ft(c),bt(c,"link",e),a.head.appendChild(c)),c={type:"script",instance:c,count:1,state:null},s.set(o,c))}}function fm(e,t,a,s){var o=(o=fe.current)?bl(o):null;if(!o)throw Error(l(446));switch(e){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=Va(a.href),a=oa(o).hoistableStyles,s=a.get(t),s||(s={type:"style",instance:null,count:0,state:null},a.set(t,s)),s):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=Va(a.href);var c=oa(o).hoistableStyles,p=c.get(e);if(p||(o=o.ownerDocument||o,p={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},c.set(e,p),(c=o.querySelector(qr(e)))&&!c._p&&(p.instance=c,p.state.loading=5),rn.has(e)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},rn.set(e,a),c||Jb(o,e,a,p.state))),t&&s===null)throw Error(l(528,""));return p}if(t&&s!==null)throw Error(l(529,""));return null;case"script":return t=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Ia(a),a=oa(o).hoistableScripts,s=a.get(t),s||(s={type:"script",instance:null,count:0,state:null},a.set(t,s)),s):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,e))}}function Va(e){return'href="'+Zt(e)+'"'}function qr(e){return'link[rel="stylesheet"]['+e+"]"}function dm(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function Jb(e,t,a,s){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?s.loading=1:(t=e.createElement("link"),s.preload=t,t.addEventListener("load",function(){return s.loading|=1}),t.addEventListener("error",function(){return s.loading|=2}),bt(t,"link",a),ft(t),e.head.appendChild(t))}function Ia(e){return'[src="'+Zt(e)+'"]'}function Yr(e){return"script[async]"+e}function hm(e,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var s=e.querySelector('style[data-href~="'+Zt(a.href)+'"]');if(s)return t.instance=s,ft(s),s;var o=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return s=(e.ownerDocument||e).createElement("style"),ft(s),bt(s,"style",o),xl(s,a.precedence,e),t.instance=s;case"stylesheet":o=Va(a.href);var c=e.querySelector(qr(o));if(c)return t.state.loading|=4,t.instance=c,ft(c),c;s=dm(a),(o=rn.get(o))&&pc(s,o),c=(e.ownerDocument||e).createElement("link"),ft(c);var p=c;return p._p=new Promise(function(y,S){p.onload=y,p.onerror=S}),bt(c,"link",s),t.state.loading|=4,xl(c,a.precedence,e),t.instance=c;case"script":return c=Ia(a.src),(o=e.querySelector(Yr(c)))?(t.instance=o,ft(o),o):(s=a,(o=rn.get(c))&&(s=b({},a),mc(s,o)),e=e.ownerDocument||e,o=e.createElement("script"),ft(o),bt(o,"link",s),e.head.appendChild(o),t.instance=o);case"void":return null;default:throw Error(l(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(s=t.instance,t.state.loading|=4,xl(s,a.precedence,e));return t.instance}function xl(e,t,a){for(var s=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),o=s.length?s[s.length-1]:null,c=o,p=0;p<s.length;p++){var y=s[p];if(y.dataset.precedence===t)c=y;else if(c!==o)break}c?c.parentNode.insertBefore(e,c.nextSibling):(t=a.nodeType===9?a.head:a,t.insertBefore(e,t.firstChild))}function pc(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function mc(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Sl=null;function pm(e,t,a){if(Sl===null){var s=new Map,o=Sl=new Map;o.set(a,s)}else o=Sl,s=o.get(a),s||(s=new Map,o.set(a,s));if(s.has(e))return s;for(s.set(e,null),a=a.getElementsByTagName(e),o=0;o<a.length;o++){var c=a[o];if(!(c[ur]||c[mt]||e==="link"&&c.getAttribute("rel")==="stylesheet")&&c.namespaceURI!=="http://www.w3.org/2000/svg"){var p=c.getAttribute(t)||"";p=e+p;var y=s.get(p);y?y.push(c):s.set(p,[c])}}return s}function mm(e,t,a){e=e.ownerDocument||e,e.head.insertBefore(a,t==="title"?e.querySelector("head > title"):null)}function ex(e,t,a){if(a===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;return t.rel==="stylesheet"?(e=t.disabled,typeof t.precedence=="string"&&e==null):!0;case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function gm(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function tx(e,t,a,s){if(a.type==="stylesheet"&&(typeof s.media!="string"||matchMedia(s.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var o=Va(s.href),c=t.querySelector(qr(o));if(c){t=c._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=wl.bind(e),t.then(e,e)),a.state.loading|=4,a.instance=c,ft(c);return}c=t.ownerDocument||t,s=dm(s),(o=rn.get(o))&&pc(s,o),c=c.createElement("link"),ft(c);var p=c;p._p=new Promise(function(y,S){p.onload=y,p.onerror=S}),bt(c,"link",s),a.instance=c}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(e.count++,a=wl.bind(e),t.addEventListener("load",a),t.addEventListener("error",a))}}var gc=0;function nx(e,t){return e.stylesheets&&e.count===0&&Al(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var s=setTimeout(function(){if(e.stylesheets&&Al(e,e.stylesheets),e.unsuspend){var c=e.unsuspend;e.unsuspend=null,c()}},6e4+t);0<e.imgBytes&&gc===0&&(gc=62500*kb());var o=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Al(e,e.stylesheets),e.unsuspend)){var c=e.unsuspend;e.unsuspend=null,c()}},(e.imgBytes>gc?50:800)+t);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(s),clearTimeout(o)}}:null}function wl(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Al(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var El=null;function Al(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,El=new Map,t.forEach(ix,e),El=null,wl.call(e))}function ix(e,t){if(!(t.state.loading&4)){var a=El.get(e);if(a)var s=a.get(null);else{a=new Map,El.set(e,a);for(var o=e.querySelectorAll("link[data-precedence],style[data-precedence]"),c=0;c<o.length;c++){var p=o[c];(p.nodeName==="LINK"||p.getAttribute("media")!=="not all")&&(a.set(p.dataset.precedence,p),s=p)}s&&a.set(null,s)}o=t.instance,p=o.getAttribute("data-precedence"),c=a.get(p)||s,c===s&&a.set(null,o),a.set(p,o),this.count++,s=wl.bind(this),o.addEventListener("load",s),o.addEventListener("error",s),c?c.parentNode.insertBefore(o,c.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(o,e.firstChild)),t.state.loading|=4}}var Xr={$$typeof:F,Provider:null,Consumer:null,_currentValue:ae,_currentValue2:ae,_threadCount:0};function ax(e,t,a,s,o,c,p,y,S){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=cu(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=cu(0),this.hiddenUpdates=cu(null),this.identifierPrefix=s,this.onUncaughtError=o,this.onCaughtError=c,this.onRecoverableError=p,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=S,this.incompleteTransitions=new Map}function ym(e,t,a,s,o,c,p,y,S,O,L,B){return e=new ax(e,t,a,p,S,O,L,B,y),t=1,c===!0&&(t|=24),c=jt(3,null,null,t),e.current=c,c.stateNode=e,t=Qu(),t.refCount++,e.pooledCache=t,t.refCount++,c.memoizedState={element:s,isDehydrated:a,cache:t},Wu(c),e}function vm(e){return e?(e=ba,e):ba}function bm(e,t,a,s,o,c){o=vm(o),s.context===null?s.context=o:s.pendingContext=o,s=si(t),s.payload={element:a},c=c===void 0?null:c,c!==null&&(s.callback=c),a=li(e,s,t),a!==null&&(Ut(a,e,t),Tr(a,e,t))}function xm(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function yc(e,t){xm(e,t),(e=e.alternate)&&xm(e,t)}function Sm(e){if(e.tag===13||e.tag===31){var t=Gi(e,67108864);t!==null&&Ut(t,e,67108864),yc(e,67108864)}}function wm(e){if(e.tag===13||e.tag===31){var t=It();t=fu(t);var a=Gi(e,t);a!==null&&Ut(a,e,t),yc(e,t)}}var Tl=!0;function rx(e,t,a,s){var o=R.T;R.T=null;var c=H.p;try{H.p=2,vc(e,t,a,s)}finally{H.p=c,R.T=o}}function sx(e,t,a,s){var o=R.T;R.T=null;var c=H.p;try{H.p=8,vc(e,t,a,s)}finally{H.p=c,R.T=o}}function vc(e,t,a,s){if(Tl){var o=bc(s);if(o===null)ac(e,t,s,Ml,a),Am(e,s);else if(ux(o,e,t,a,s))s.stopPropagation();else if(Am(e,s),t&4&&-1<lx.indexOf(e)){for(;o!==null;){var c=ua(o);if(c!==null)switch(c.tag){case 3:if(c=c.stateNode,c.current.memoizedState.isDehydrated){var p=Ui(c.pendingLanes);if(p!==0){var y=c;for(y.pendingLanes|=2,y.entangledLanes|=2;p;){var S=1<<31-tt(p);y.entanglements[1]|=S,p&=~S}Sn(c),(_e&6)===0&&(ul=Ve()+500,Vr(0))}}break;case 31:case 13:y=Gi(c,2),y!==null&&Ut(y,c,2),cl(),yc(c,2)}if(c=bc(s),c===null&&ac(e,t,s,Ml,a),c===o)break;o=c}o!==null&&s.stopPropagation()}else ac(e,t,s,null,a)}}function bc(e){return e=xu(e),xc(e)}var Ml=null;function xc(e){if(Ml=null,e=la(e),e!==null){var t=f(e);if(t===null)e=null;else{var a=t.tag;if(a===13){if(e=d(t),e!==null)return e;e=null}else if(a===31){if(e=h(t),e!==null)return e;e=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ml=e,null}function Em(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(dn()){case xt:return 2;case Lt:return 8;case Mn:case ra:return 32;case Dn:return 268435456;default:return 32}default:return 32}}var Sc=!1,vi=null,bi=null,xi=null,Qr=new Map,Kr=new Map,Si=[],lx="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Am(e,t){switch(e){case"focusin":case"focusout":vi=null;break;case"dragenter":case"dragleave":bi=null;break;case"mouseover":case"mouseout":xi=null;break;case"pointerover":case"pointerout":Qr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Kr.delete(t.pointerId)}}function Zr(e,t,a,s,o,c){return e===null||e.nativeEvent!==c?(e={blockedOn:t,domEventName:a,eventSystemFlags:s,nativeEvent:c,targetContainers:[o]},t!==null&&(t=ua(t),t!==null&&Sm(t)),e):(e.eventSystemFlags|=s,t=e.targetContainers,o!==null&&t.indexOf(o)===-1&&t.push(o),e)}function ux(e,t,a,s,o){switch(t){case"focusin":return vi=Zr(vi,e,t,a,s,o),!0;case"dragenter":return bi=Zr(bi,e,t,a,s,o),!0;case"mouseover":return xi=Zr(xi,e,t,a,s,o),!0;case"pointerover":var c=o.pointerId;return Qr.set(c,Zr(Qr.get(c)||null,e,t,a,s,o)),!0;case"gotpointercapture":return c=o.pointerId,Kr.set(c,Zr(Kr.get(c)||null,e,t,a,s,o)),!0}return!1}function Tm(e){var t=la(e.target);if(t!==null){var a=f(t);if(a!==null){if(t=a.tag,t===13){if(t=d(a),t!==null){e.blockedOn=t,Bf(e.priority,function(){wm(a)});return}}else if(t===31){if(t=h(a),t!==null){e.blockedOn=t,Bf(e.priority,function(){wm(a)});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Dl(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=bc(e.nativeEvent);if(a===null){a=e.nativeEvent;var s=new a.constructor(a.type,a);bu=s,a.target.dispatchEvent(s),bu=null}else return t=ua(a),t!==null&&Sm(t),e.blockedOn=a,!1;t.shift()}return!0}function Mm(e,t,a){Dl(e)&&a.delete(t)}function ox(){Sc=!1,vi!==null&&Dl(vi)&&(vi=null),bi!==null&&Dl(bi)&&(bi=null),xi!==null&&Dl(xi)&&(xi=null),Qr.forEach(Mm),Kr.forEach(Mm)}function Rl(e,t){e.blockedOn===t&&(e.blockedOn=null,Sc||(Sc=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,ox)))}var Cl=null;function Dm(e){Cl!==e&&(Cl=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Cl===e&&(Cl=null);for(var t=0;t<e.length;t+=3){var a=e[t],s=e[t+1],o=e[t+2];if(typeof s!="function"){if(xc(s||a)===null)continue;break}var c=ua(a);c!==null&&(e.splice(t,3),t-=3,bo(c,{pending:!0,data:o,method:a.method,action:s},s,o))}}))}function Fa(e){function t(S){return Rl(S,e)}vi!==null&&Rl(vi,e),bi!==null&&Rl(bi,e),xi!==null&&Rl(xi,e),Qr.forEach(t),Kr.forEach(t);for(var a=0;a<Si.length;a++){var s=Si[a];s.blockedOn===e&&(s.blockedOn=null)}for(;0<Si.length&&(a=Si[0],a.blockedOn===null);)Tm(a),a.blockedOn===null&&Si.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(s=0;s<a.length;s+=3){var o=a[s],c=a[s+1],p=o[Dt]||null;if(typeof c=="function")p||Dm(a);else if(p){var y=null;if(c&&c.hasAttribute("formAction")){if(o=c,p=c[Dt]||null)y=p.formAction;else if(xc(o)!==null)continue}else y=p.action;typeof y=="function"?a[s+1]=y:(a.splice(s,3),s-=3),Dm(a)}}}function Rm(){function e(c){c.canIntercept&&c.info==="react-transition"&&c.intercept({handler:function(){return new Promise(function(p){return o=p})},focusReset:"manual",scroll:"manual"})}function t(){o!==null&&(o(),o=null),s||setTimeout(a,20)}function a(){if(!s&&!navigation.transition){var c=navigation.currentEntry;c&&c.url!=null&&navigation.navigate(c.url,{state:c.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var s=!1,o=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(a,100),function(){s=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),o!==null&&(o(),o=null)}}}function wc(e){this._internalRoot=e}Ol.prototype.render=wc.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(l(409));var a=t.current,s=It();bm(a,s,e,t,null,null)},Ol.prototype.unmount=wc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;bm(e.current,2,null,e,null,null),cl(),t[sa]=null}};function Ol(e){this._internalRoot=e}Ol.prototype.unstable_scheduleHydration=function(e){if(e){var t=Gf();e={blockedOn:null,target:e,priority:t};for(var a=0;a<Si.length&&t!==0&&t<Si[a].priority;a++);Si.splice(a,0,e),a===0&&Tm(e)}};var Cm=i.version;if(Cm!=="19.2.8")throw Error(l(527,Cm,"19.2.8"));H.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(l(188)):(e=Object.keys(e).join(","),Error(l(268,e)));return e=g(t),e=e!==null?x(e):null,e=e===null?null:e.stateNode,e};var cx={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:R,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var zl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zl.isDisabled&&zl.supportsFiber)try{ct=zl.inject(cx),He=zl}catch{}}return Wr.createRoot=function(e,t){if(!u(e))throw Error(l(299));var a=!1,s="",o=kh,c=jh,p=Gh;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(s=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(c=t.onCaughtError),t.onRecoverableError!==void 0&&(p=t.onRecoverableError)),t=ym(e,1,!1,null,null,a,s,null,o,c,p,Rm),e[sa]=t.current,ic(e),new wc(t)},Wr.hydrateRoot=function(e,t,a){if(!u(e))throw Error(l(299));var s=!1,o="",c=kh,p=jh,y=Gh,S=null;return a!=null&&(a.unstable_strictMode===!0&&(s=!0),a.identifierPrefix!==void 0&&(o=a.identifierPrefix),a.onUncaughtError!==void 0&&(c=a.onUncaughtError),a.onCaughtError!==void 0&&(p=a.onCaughtError),a.onRecoverableError!==void 0&&(y=a.onRecoverableError),a.formState!==void 0&&(S=a.formState)),t=ym(e,1,!0,t,a??null,s,o,S,c,p,y,Rm),t.context=vm(null),a=t.current,s=It(),s=fu(s),o=si(s),o.callback=null,li(a,o,s),a=s,t.current.lanes=a,lr(t,a),Sn(t),e[sa]=t.current,ic(e),new Ol(t)},Wr.version="19.2.8",Wr}var Bm;function xx(){if(Bm)return Tc.exports;Bm=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(i){console.error(i)}}return n(),Tc.exports=bx(),Tc.exports}var Sx=xx();const Xe={interactions:"interactions",steps:"steps",errors:"errors",retries:"retries",cpuMs:"cpu.ms",tokensInput:"tokens.input",tokensOutput:"tokens.output",tokensCacheRead:"tokens.cacheRead",tokensReasoning:"tokens.reasoning"};function An(n,i){const r=n[i];return typeof r=="number"&&Number.isFinite(r)?r:void 0}function Kl(n,i){for(const[r,l]of Object.entries(i)){if(typeof l!="number"||!Number.isFinite(l))continue;const u=r;n[u]=(n[u]??0)+l}}const wx=[Xe.tokensInput,Xe.tokensOutput,Xe.tokensCacheRead];function qt(n){let i=0,r=!1;for(const l of wx){const u=An(n,l);u!==void 0&&(r=!0,i+=u)}return r?i:void 0}function Za(n){return{input:An(n,Xe.tokensInput)??0,output:An(n,Xe.tokensOutput)??0,cacheRead:An(n,Xe.tokensCacheRead)??0,reasoning:An(n,Xe.tokensReasoning)??0}}function O0(n){const i=qt(n.measures);if(i!==void 0)return $m(i/1e3,200);const r=An(n.measures,Xe.cpuMs);if(r!==void 0)return $m(r/1e3,200)}function un(n){return An(n.measures,Xe.interactions)}function ff(n){return An(n.measures,Xe.steps)??0}function ta(n){return An(n.measures,Xe.errors)??0}function Yc(n){return An(n.measures,Xe.retries)??0}function $m(n,i){return Math.min(1,Math.log1p(Math.max(0,n))/Math.log1p(i))}const Ex=new Set(["running","waiting"]);function z0(n){return Ex.has(n)}function $l(n,i){return{now:n,dayStart:n,dayEnd:i,machines:new Map,sources:new Map,sessions:new Map,executions:new Map,processes:new Map,artifacts:new Map,transfers:new Map,relationships:[],active:new Set,seen:new Set}}const _0=9e4;function Vm(n,i){if(n.waitingSince===void 0)return;const r=n.waitingSince,l=Math.max(r,i);n.waitingMs+=l-r,n.waits.push({start:r,end:l})}function Ax(n,i){const r=`${i.source.id}:${i.source.instance}`;let l=n.sources.get(r);l||(l={id:i.source.id,instance:i.source.instance,origin:i.source.instance,firstSeenAt:i.occurredAt,lastSeenAt:i.occurredAt,events:0,strata:{}},n.sources.set(r,l)),l.events++,i.occurredAt<l.firstSeenAt&&(l.firstSeenAt=i.occurredAt),i.occurredAt>l.lastSeenAt&&(l.lastSeenAt=i.occurredAt),i.stratum&&(l.strata[i.stratum]=(l.strata[i.stratum]??0)+1);const u=i.provenance?.sourceVersion;u&&(l.sourceVersions?l.sourceVersions.includes(u)||l.sourceVersions.push(u):l.sourceVersions=[u])}function Tx(n,i){if(n.seen.has(i.id))return;n.seen.add(i.id),i.occurredAt>n.now&&(n.now=i.occurredAt),Ax(n,i);const r=i.core??{},l=i.occurredAt;switch(i.subject.type){case"machine":{if(n.machines.has(i.subject.id))break;const u={id:i.subject.id,name:r.machineName??i.subject.id,kind:r.machineKind??"laptop",parentId:r.parentId,firstSeenAt:l};n.machines.set(u.id,u);break}case"session":{if(i.kind==="began"){const u=n.sessions.get(i.subject.id);if(u){u.parentId===void 0&&r.parentId&&(u.parentId=r.parentId);break}const f={id:i.subject.id,machineId:r.machineId??"",label:r.label,context:i.attrs?.context??r.label??"",executor:r.executor,model:r.model,startedAt:l,executionIds:[],parentId:r.parentId};n.sessions.set(f.id,f)}else if(i.kind==="ended"){const u=n.sessions.get(i.subject.id);u&&(u.endedAt=l)}break}case"execution":Mx(n,i,l);break;case"process":Dx(n,i,l);break;case"artifact":{if(n.artifacts.has(i.subject.id))break;n.artifacts.set(i.subject.id,{id:i.subject.id,kind:"file",path:r.label??i.subject.id,firstSeenAt:l});break}}}function Mx(n,i,r){const l=i.core??{},u=i.subject.id;if(i.kind==="began"){if(n.executions.has(u))return;const d={id:u,sessionId:l.sessionId??l.parentId??"",machineId:l.machineId??"",label:l.label??u,executor:l.executor??"unknown",model:l.model,status:"running",startedAt:r,lastActivityAt:r,measures:{},waitingMs:0,waits:[],parentId:l.parentId,depth:l.depth??0,startBasis:i.basis,boundsAssumption:i.assumption};l.measures&&Kl(d.measures,l.measures),n.executions.set(u,d),n.active.add(u),n.sessions.get(d.sessionId)?.executionIds.push(u);return}const f=n.executions.get(u);if(f)switch(i.kind){case"progressed":{l.measures&&Kl(f.measures,l.measures),f.lastActivityAt=r,f.status==="idle"&&(f.status="running",n.active.add(u));break}case"blocked":{if(!z0(f.status))break;f.status="waiting",f.waitingSince=r,f.waitReason=l.blockedOn??"input",f.lastActivityAt=r;break}case"resumed":{Vm(f,r),f.status="running",f.waitingSince=void 0,f.waitReason=void 0,f.lastActivityAt=r,n.active.add(u);break}case"ended":{const d=l.outcome==="error";f.status=d?"failed":"completed",f.endedAt=r,f.endBasis=i.basis,i.assumption&&!f.boundsAssumption&&(f.boundsAssumption=i.assumption),f.lastActivityAt=r,f.outcome=l.outcome??"completed",d&&(f.failure={code:l.failureCode??"ERROR",message:l.failureMessage??"Execution failed"}),Vm(f,r),f.waitingSince=void 0,f.waitReason=void 0,n.active.delete(u);break}case"observed":f.lastActivityAt=Math.max(f.lastActivityAt,r);break}}function Dx(n,i,r){const l=i.core??{},u=i.subject.id,f=Number(i.attrs?.["os.pid"]??0);if(i.kind==="began"){if(n.processes.has(u))return;const h={id:u,machineId:l.machineId??"",pid:f,ppid:typeof i.attrs?.["os.ppid"]=="number"?i.attrs["os.ppid"]:void 0,command:l.label??l.executor??String(f),startedAt:r,lastSeenAt:r,status:"running",measures:{}};l.measures&&Kl(h.measures,l.measures),n.processes.set(u,h);return}const d=n.processes.get(u);if(d)if(i.kind==="observed"||i.kind==="progressed"){if(d.lastSeenAt=Math.max(d.lastSeenAt,r),l.measures){const h=l.measures[Xe.cpuMs];typeof h=="number"&&(d.measures[Xe.cpuMs]=h);const{[Xe.cpuMs]:m,...g}=l.measures;Kl(d.measures,g)}}else i.kind==="ended"&&(d.endedAt=r,d.lastSeenAt=Math.max(d.lastSeenAt,r),d.status="exited",d.endInferred=i.basis==="inferred")}function Rx(n,i){for(let r=0;r<i.length;r++)Tx(n,i[r])}function Cx(n,i){if(!(i<=n.now)){n.now=i;for(const r of n.active){const l=n.executions.get(r);if(!l){n.active.delete(r);continue}l.status==="running"&&i-l.lastActivityAt>_0&&(l.status="idle")}}}const Ft=n=>({value:n,basis:"measured"}),_l=(n,i)=>({value:n,basis:"inferred",assumption:i});function df(n){if(n.length===0)return[];n.sort((r,l)=>r.start-l.start);const i=[{start:n[0].start,end:n[0].end}];for(let r=1;r<n.length;r++){const l=n[r],u=i[i.length-1];l.start<=u.end?l.end>u.end&&(u.end=l.end):i.push({start:l.start,end:l.end})}return i}function Im(n){let i=0;for(const r of n)i+=r.end-r.start;return i}function Ox(n,i){const r=[];let l=0,u=0;for(;l<n.length&&u<i.length;){const f=Math.max(n[l].start,i[u].start),d=Math.min(n[l].end,i[u].end);f<d&&r.push({start:f,end:d}),n[l].end<i[u].end?l++:u++}return r}function U0(n){if(n.length===0)return{peak:0,at:0};const i=[];for(const f of n)i.push({t:f.start,d:1}),i.push({t:f.end,d:-1});i.sort((f,d)=>f.t-d.t||f.d-d.d);let r=0,l=0,u=i[0].t;for(const f of i)r+=f.d,r>l&&(l=r,u=f.t);return{peak:l,at:u}}const N0=6e4;function zx(n,i){return{start:n.startedAt,end:n.endedAt??i}}function _x(n){const i=[];for(const r of n.executions.values()){r.depth===0&&i.push({start:r.startedAt-N0,end:r.startedAt});for(const l of r.waits)i.push({start:l.start,end:l.end});r.waitingSince!==void 0&&i.push({start:r.waitingSince,end:n.now})}return df(i)}function L0(n){const i=n.now,r=[...n.executions.values()];let l=0,u=0,f=0,d=0,h=0,m=0,g=0,x=0;const b=[],D=new Map;for(const P of r){l+=ff(P),u+=qt(P.measures)??0,f+=un(P)??0,P.status==="completed"?d++:P.status==="failed"?h++:P.status==="waiting"?m++:P.status==="idle"&&g++;const he=zx(P,i);b.push(he),x+=P.waitingMs,P.waitingSince!==void 0&&(x+=Math.max(0,i-P.waitingSince));let M=D.get(P.machineId);M||(M={machineId:P.machineId,executions:0,tokens:0,computeTime:0},D.set(P.machineId,M)),M.executions++,M.tokens+=qt(P.measures)??0,M.computeTime+=he.end-he.start}const $=df(b.map(P=>({...P}))),k=_x(n),N=Im(Ox($,k)),{peak:V,at:Z}=U0(b),I=Ux(n),F=Math.max(0,I.length-1);let Y=null;for(const P of I)(!Y||P.end-P.start>Y.end-Y.start)&&(Y=P);return{requests:Ft(l),sessions:Ft(n.sessions.size),executions:Ft(r.length),tokens:Ft(u),toolCalls:Ft(f),autonomousCompute:_l(Im($),"Wall-clock time during which at least one run was in flight, merged so parallel runs are not double-counted."),humanAgentOverlap:_l(N,`Compute time intersecting a window when you were plausibly present: the ${N0/1e3}s before you sent a message, and any approval from ask to answer.`),peakConcurrency:Ft(V),peakConcurrencyAt:Ft(Z),contextSwitches:_l(F,"Transitions between working directories, ordered by time. A directory is the closest thing the source has to a project."),longestFocus:_l(Y,"Longest unbroken stretch spent in one working directory."),waitingOnYou:Ft(x),completed:Ft(d),failed:Ft(h),waiting:Ft(m),idle:Ft(g),byMachine:D,contextSpans:I,transfers:Ft(n.transfers.size)}}function Ux(n){const i=[];for(const l of n.executions.values()){const u=n.sessions.get(l.sessionId);u&&i.push({context:u.context,start:l.startedAt,end:l.endedAt??n.now})}i.sort((l,u)=>l.start-u.start);const r=[];for(const l of i){const u=r[r.length-1];u&&u.context===l.context&&l.start<=u.end?l.end>u.end&&(u.end=l.end):u&&u.context===l.context?l.start-u.end<=Nx?u.end=Math.max(u.end,l.end):r.push({context:l.context,start:l.start,end:l.end}):r.push({context:l.context,start:l.start,end:l.end})}return r}const Nx=15*6e4;function Lx(n){return{key:n,runs:0,tokens:0,tokenRuns:0,computeMs:0,failed:0,waitingMs:0,toolCalls:0}}function Cc(n,i){const r=new Map;for(const l of n.executions.values()){const u=i(l,n.sessions.get(l.sessionId));if(u===void 0)continue;let f=r.get(u);f||(f=Lx(u),r.set(u,f)),f.runs++;const d=qt(l.measures);d!==void 0&&(f.tokens+=d,f.tokenRuns++),f.computeMs+=(l.endedAt??n.now)-l.startedAt,f.waitingMs+=l.waitingMs,f.toolCalls+=un(l)??0,l.status==="failed"&&f.failed++}return[...r.values()].sort((l,u)=>u.computeMs-l.computeMs)}function kx(n){const i={input:0,output:0,cacheRead:0,reasoning:0,total:0};for(const r of n.executions.values()){const l=Za(r.measures);i.input+=l.input,i.output+=l.output,i.cacheRead+=l.cacheRead,i.reasoning+=l.reasoning}return i.total=i.input+i.output+i.cacheRead+i.reasoning,i}function jx(n){const i={count:0,totalMs:0,longestMs:0,openNow:0};for(const r of n.executions.values()){for(const l of r.waits){i.count++;const u=l.end-l.start;i.totalMs+=u,u>i.longestMs&&(i.longestMs=u)}if(r.waitingSince!==void 0){i.openNow++;const l=n.now-r.waitingSince;i.totalMs+=l,l>i.longestMs&&(i.longestMs=l)}}return i}function Gx(n){const i={toolCalls:0,toolErrors:0,retries:0,failed:0,interrupted:0,completed:0};for(const r of n.executions.values())i.toolCalls+=un(r)??0,i.toolErrors+=ta(r),i.retries+=Yc(r),r.status==="failed"?i.failed++:r.outcome==="interrupted"?i.interrupted++:r.outcome==="completed"&&i.completed++;return i}function Bx(n){const i=[];for(const f of n.executions.values())i.push({start:f.startedAt,end:f.endedAt??n.now});if(i.length===0)return[];const r=df(i.map(f=>({...f}))),l=new Date(n.dayStart);l.setMinutes(0,0,0);const u=[];for(let f=l.getTime();f<n.now;f+=36e5){const d=f+36e5;let h=0;for(const x of r){const b=Math.max(x.start,f),D=Math.min(x.end,d);D>b&&(h+=D-b)}let m=0;const g=[];for(const x of i)x.start<d&&x.end>f&&(m++,g.push({start:Math.max(x.start,f),end:Math.min(x.end,d)}));u.push({hour:new Date(f).getHours(),runs:m,computeMs:h,peak:U0(g).peak})}return u}const k0=1e3,Fm=60*k0;function Ye(n){if(!Number.isFinite(n)||n<=0)return"0m";if(n<Fm)return`${Math.max(1,Math.round(n/k0))}s`;const i=Math.round(n/Fm),r=Math.floor(i/60),l=i%60;return r===0?`${l}m`:l===0?`${r}h`:`${r}h ${l}m`}function pt(n){if(!Number.isFinite(n))return"—";const i=Math.abs(n);return i>=1e9?`${(n/1e9).toFixed(i>=1e10?0:2)}B`:i>=1e6?`${(n/1e6).toFixed(i>=1e7?0:2)}M`:i>=1e3?`${(n/1e3).toFixed(i>=1e4?0:1)}k`:String(Math.round(n))}function Wa(n,i="NOT OBSERVED"){return n===void 0?i:pt(n)}function $x(n){return n===void 0||!Number.isFinite(n)?"—":n>=1e9?`${(n/1e9).toFixed(1)} GB`:n>=1e6?`${(n/1e6).toFixed(0)} MB`:n>=1e3?`${(n/1e3).toFixed(0)} KB`:`${n} B`}function Pa(n){const i=new Date(n);return`${String(i.getHours()).padStart(2,"0")}:${String(i.getMinutes()).padStart(2,"0")}`}function us(n){const i=n.split("/").filter(Boolean);return i[i.length-1]??n}const Vl=6e4,Vx=60*Vl;function j0(n,i){const r=[],l=i.contextSpans,u=i.longestFocus.value,f=Math.max(1,n.now-n.dayStart),d=i.autonomousCompute.value/f;let h;if(i.executions.value===0)return{headline:"QUIET",clauses:["No computation observed in this window."]};if(i.peakConcurrency.value>=3?h="PARALLEL":l.length>=6?h="FRAGMENTED":u&&u.end-u.start>2*Vx?h="SUSTAINED":d<.15?h="SPARSE":h="SERIAL",i.peakConcurrency.value>=2?r.push(`Up to ${i.peakConcurrency.value} runs in flight at once; ${Ye(i.autonomousCompute.value)} of wall-clock time had computation running.`):r.push(`Runs happened one at a time, across ${Ye(i.autonomousCompute.value)} of wall-clock time.`),u&&r.push(`The longest unbroken stretch was ${Ye(u.end-u.start)} in ${us(u.context)}.`),l.length>1){const m=new Set(l.map(g=>g.context)).size;r.push(`Attention moved ${i.contextSwitches.value} ${i.contextSwitches.value===1?"time":"times"} across ${m} ${m===1?"context":"contexts"}.`)}if(i.waitingOnYou.value>Vl&&r.push(`${Ye(i.waitingOnYou.value)} was spent with a run waiting on your answer.`),i.humanAgentOverlap.value>Vl){const m=Math.round(i.humanAgentOverlap.value/Math.max(1,i.autonomousCompute.value)*100);r.push(`About ${m}% of that computation overlapped a window when you were present; the rest ran without you.`)}else i.autonomousCompute.value>5*Vl&&r.push("Computation ran almost entirely outside the moments you were present.");if(i.failed.value>0&&r.push(`${i.failed.value} of ${i.executions.value} runs ended in failure; ${i.completed.value} completed.`),i.byMachine.size>1){const m=[...i.byMachine.values()].sort((g,x)=>x.computeTime-g.computeTime).map(g=>`${n.machines.get(g.machineId)?.name??g.machineId} ${Ye(g.computeTime)}`);r.push(`Compute was split across ${m.join(", ")}.`)}return{headline:h,clauses:r}}function Ix(n){let i=2166136261;for(let r=0;r<n.length;r++)i^=n.charCodeAt(r),i=Math.imul(i,16777619);return i>>>0}function Zl(n,i=0){return Ix(n+"#"+i)%1e5/1e5}const Oc=[{x:430,y:508,extentX:300,extentY:186},{x:838,y:322,extentX:186,extentY:116}];function Fx(n){if(n<Oc.length)return Oc[n];const r=-.9+(n-Oc.length)*1.15;return{x:620+Math.cos(r)*520,y:300+Math.sin(r)*250,extentX:150,extentY:94}}function Hx(n){const i=r=>r==="laptop"?0:r==="desktop"?1:2;return[...n].sort((r,l)=>i(r.kind)-i(l.kind)||r.firstSeenAt-l.firstSeenAt||(r.id<l.id?-1:r.id>l.id?1:0))}function Hm(n,i){const r=Zl(i,1),l=Zl(i,2),u=r*Math.PI*2+l*2.399963,f=.34+.46*Math.sqrt(l);return{x:n.x+Math.cos(u)*n.extentX*f,y:n.y+Math.sin(u)*n.extentY*f}}const wn={spanX:1160,strataTop:812,strataHeight:360},G0=3,qx=4,qm=30,Yx=74;function B0(n){return qm+n*(Yx-qm)}function Ym(n,i,r){let l=null,u=1/0;for(const d of n.disturbances){const h=B0(d.extent),m=i-d.x,g=(r-d.y)*1.5,x=Math.hypot(m,g);x<h*1.3&&x<u&&(u=x,l={kind:"disturbance",id:d.id,x:d.x,y:d.y})}if(l)return l;for(const d of n.couplings){const h=n.masses.find(N=>N.id===d.fromMassId),m=n.masses.find(N=>N.id===d.toMassId);if(!h||!m)continue;const g=m.x-h.x,x=m.y-h.y,b=g*g+x*x;if(b===0)continue;const D=((i-h.x)*g+(r-h.y)*x)/b;if(D<.05||D>.95)continue;const $=h.x+g*D,k=h.y+x*D;if(Math.hypot(i-$,(r-k)*1.5)<50)return{kind:"coupling",id:d.id,x:$,y:k}}for(const d of n.masses){const h=(i-d.x)/d.extentX,m=(r-d.y)/d.extentY;if(h*h+m*m<1.1)return{kind:"mass",id:d.id,x:d.x,y:d.y}}const f=wn.strataTop;if(r>=f&&r<=f+wn.strataHeight){const d=Math.max(1,n.masses.length),h=wn.strataHeight/d,m=Math.min(d-1,Math.floor((r-f)/h)),g=i/wn.spanX;let x=null,b=1/0;const D=G0/wn.spanX,$=qx/wn.spanX;for(const k of n.strata){if(k.lane!==m)continue;const N=Math.max(D,k.endFraction-k.startFraction);g<k.startFraction-$||g>k.startFraction+N+$||N<b&&(b=N,x={kind:"stratum",id:k.id,x:i,y:r})}if(x)return x}return null}const Xm=64,Xx=8,Qx=8,Qm=16,Km=.45;function Kx(n,i){switch(n.status){case"running":{const r=i-n.lastActivityAt;return .55+.45*Math.exp(-r/45e3)}case"waiting":return .08;case"failed":return .9;case"completed":return 0;case"idle":return .03}}const Zm=.32;function Zx(n){const i=O0(n),r=n.depth>0?.62:1;return i===void 0?Zm*r:Math.min(1,(Zm+.68*i)*r)}function Px(n,i){const r=Math.max(1,(n.endedAt??i)-n.startedAt),l=(un(n)??0)/(r/6e4);return Math.min(1,.25+l/24)}function Pm(n){return(n.status==="failed"?3:n.status==="waiting"?2:n.status==="running"?1:0)*1e15+n.lastActivityAt}function Wx(n){const i=new Set,r=new Set,l=new Map,u=new Map,f=(d,h,m)=>{const g=d.get(h);g?g.push(m):d.set(h,[m])};for(const d of n.relationships){const{from:h,to:m,kind:g}=d;g==="ran-as"?(h.type==="execution"&&i.add(h.id),m.type==="execution"&&i.add(m.id),h.type==="session"&&m.type==="process"&&r.add(h.id),m.type==="session"&&h.type==="process"&&r.add(m.id),h.type==="execution"&&m.type==="session"?l.set(h.id,m.id):h.type==="session"&&m.type==="execution"&&l.set(m.id,h.id)):g==="same-as"&&h.type==="execution"&&m.type==="execution"&&(i.add(h.id),i.add(m.id),f(u,h.id,m.id),f(u,m.id,h.id))}return{resolvedExecutions:i,sessionsWithProcess:r,runObservesSession:l,sameExecution:u}}function Jx(n,i){const l=n.startBasis===void 0?.5:n.startBasis==="measured"?1:0,u=n.endBasis===void 0?.5:n.endBasis==="measured"?1:0,f=n.endedAt===void 0?l:(l+u)/2,d=O0(n)===void 0?0:1,h=i.resolvedExecutions.has(n.id)||i.sessionsWithProcess.has(n.sessionId)?1:0;return(1+f+d+h)/4}function Wm(n){let i=1;for(const r of n)i*=1-Math.min(1,Math.max(0,r));return 1-i}function Jm(n,i,r,l){const u=Math.max(n,r),f=Math.min(i,l);if(f<u)return 0;const d=Math.max(i,l)-Math.min(n,r);return d<=0?1:(f-u)/d}function e1(n){const i=n.now,r=Hx(n.machines.values()).slice(0,Xx),l=new Map,u=[];let f=1;const d=new Map;for(const M of n.executions.values()){const E=(d.get(M.machineId)??0)+1;d.set(M.machineId,E),E>f&&(f=E)}r.forEach((M,E)=>{const j=Fx(E);l.set(M.id,j),u.push({id:M.id,name:M.name,kind:M.kind,x:j.x,y:j.y,extentX:j.extentX,extentY:j.extentY,prominence:(d.get(M.id)??0)/f,seed:Zl(M.id,7)})});const h=45e3,m=[];for(const M of n.executions.values())(M.status==="completed"||M.status==="failed")&&i-(M.endedAt??i)>h||M.status==="idle"&&i-M.lastActivityAt>h*4||l.has(M.machineId)&&m.push(M);m.length>Xm&&(m.sort((M,E)=>Pm(E)-Pm(M)),m.length=Xm);const g=Wx(n),x=M=>{const E=l.get(M.machineId),{x:j,y:W}=Hm(E,M.id);return{id:M.id,massId:M.machineId,sessionId:M.sessionId,x:j,y:W,extent:Zx(M),energy:Kx(M,i),rate:Px(M,i),phase:Zl(M.id,3)*Math.PI*2,status:M.status,label:M.label,statusSince:M.waitingSince??M.endedAt??M.startedAt,articulation:Jx(M,g),shoulder:0,observers:1}},b=new Set(m.map(M=>M.id)),D=new Set,$=[],k=M=>[M.startedAt,M.endedAt??i];for(const M of[...m].sort((E,j)=>E.id<j.id?-1:1)){if(D.has(M.id))continue;const E=[M];D.add(M.id);for(let de=0;de<E.length;de++)for(const se of g.sameExecution.get(E[de].id)??[])!b.has(se)||D.has(se)||(D.add(se),E.push(n.executions.get(se)));if(E.length===1){$.push(x(M));continue}const j=E.map(x),W=j.reduce((de,se)=>se.articulation>de.articulation||se.articulation===de.articulation&&se.id<de.id?se:de);let te=1;const[le,$e]=k(n.executions.get(W.id));for(const de of E){const[se,R]=k(de);te=Math.min(te,Jm(le,$e,se,R))}$.push({...W,extent:Math.max(...j.map(de=>de.extent)),energy:Math.max(...j.map(de=>de.energy)),articulation:Wm(j.map(de=>de.articulation)),shoulder:Math.min(Km,1-te),observers:E.length})}const N=new Map;for(const M of $){if(g.runObservesSession.has(M.id))continue;const E=N.get(M.sessionId);E?E.push(M):N.set(M.sessionId,[M])}const V=new Map,Z=[];for(const M of $){const E=g.runObservesSession.get(M.id),j=E?N.get(E):void 0;if(!E||!j||j.length===0){if(Z.push(M),E){const R=N.get(M.sessionId);R?R.push(M):N.set(M.sessionId,[M])}continue}const W=n.executions.get(M.id);let te=1/0,le=-1/0;for(const R of j){const[H,ae]=k(n.executions.get(R.id));te=Math.min(te,H),le=Math.max(le,ae)}const[$e,de]=k(W),se=V.get(E)??{articulations:[],coincidence:1};se.articulations.push(M.articulation),se.coincidence=Math.min(se.coincidence,Jm($e,de,te,le)),V.set(E,se)}const I=[];for(const M of[...N.keys()].sort()){const E=N.get(M),j=n.sessions.get(M);if(!j||E.length===0)continue;let W=0,te=0;for(const R of E)W+=R.x,te+=R.y;W/=E.length,te/=E.length;let le=0,$e=0;for(const R of E){const H=B0(R.extent);le=Math.max(le,Math.abs(R.x-W)+H*1.5),$e=Math.max($e,Math.abs(R.y-te)+H)}const de=V.get(M),se=Math.max(...E.map(R=>R.articulation));I.push({id:M,massId:E[0].massId,x:W,y:te,extentX:Math.max(le,52),extentY:Math.max($e,36),presence:1,articulation:de?Wm([se,...de.articulations]):se,parentId:j.parentId,empty:!1,shoulder:de?Math.min(Km,1-de.coincidence):0,observers:1+(de?.articulations.length??0),label:j.label??j.executor??M})}for(const M of[...n.sessions.values()].sort((E,j)=>E.id<j.id?-1:1)){if(M.executionIds.length>0||M.endedAt!==void 0&&i-M.endedAt>h)continue;const E=l.get(M.machineId);if(!E)continue;const{x:j,y:W}=Hm(E,`session-presence:${M.id}`);I.push({id:M.id,massId:M.machineId,x:j,y:W,extentX:64,extentY:42,presence:1,articulation:g.sessionsWithProcess.has(M.id)?.5:.25,parentId:M.parentId,empty:!0,shoulder:0,observers:1,label:M.label??M.executor??M.id})}if(I.length>Qm){const M=E=>E.empty?0:N.get(E.id)?.length??0;I.sort((E,j)=>M(j)-M(E)||(E.id<j.id?-1:1)),I.length=Qm}const F=[];for(const M of n.transfers.values())if(M.endedAt===void 0&&!(!l.has(M.fromMachineId)||!l.has(M.toMachineId))){if(F.length>=Qx)break;F.push({id:M.id,fromMassId:M.fromMachineId,toMassId:M.toMachineId,energy:1,label:M.label})}const Y=new Map;r.forEach((M,E)=>Y.set(M.id,E));const P=Math.max(1,n.dayEnd-n.dayStart),he=[];for(const M of n.executions.values()){const E=Y.get(M.machineId);if(E===void 0)continue;const j=(M.startedAt-n.dayStart)/P,W=((M.endedAt??i)-n.dayStart)/P;he.push({id:M.id,massId:M.machineId,lane:E,startFraction:Math.max(0,Math.min(1,j)),endFraction:Math.max(0,Math.min(1,W)),status:M.status,label:M.label})}return{time:i,masses:u,disturbances:Z,plinths:I,couplings:F,strata:he}}const Il="synthetic";let t1=0;const Nt=(n,i,r,l)=>({id:`syn:${(t1++).toString(36)}`,source:{id:Il,instance:"replay"},occurredAt:n,observedAt:n,clock:"wall",kind:i,subject:r,core:l,basis:"measured",stratum:"stored-semantics"});function n1(n){let i=n>>>0;return()=>{i=i+1831565813>>>0;let r=Math.imul(i^i>>>15,1|i);return r=r+Math.imul(r^r>>>7,61|r)^r,((r^r>>>14)>>>0)/4294967296}}const qa=6e4,i1=60*qa,eg=["~/atlas","~/harbour-cli","~/ledger","~/studio-site"],tg=[{id:"macbook",name:"MACBOOK",kind:"laptop",firstSeenAt:0},{id:"mini",name:"MINI-PC",kind:"desktop",firstSeenAt:0}];function ng(n,i){return{[Xe.tokensInput]:Math.round(400+i()*3e3*n),[Xe.tokensOutput]:Math.round(60+i()*500*n),[Xe.tokensCacheRead]:Math.round(1200+i()*9e3*n),[Xe.tokensReasoning]:Math.round(20+i()*300*n)}}function a1(n={}){const i=n.seed??57,r=n.dayStart??Date.parse("2026-08-29T07:00:00Z"),l=n.duration??15*i1,u=n.runCount??24,f=n.failureRate??.09,d=n.waitRate??.2,h=r+l,m=n1(i),g=[];for(const $ of tg)g.push(Nt(r,"began",{type:"machine",id:$.id},{machineName:$.name,machineKind:$.kind}));const x=Math.max(1,Math.round(u/4));let b=0,D=0;for(let $=0;$<x;$++){const k=r+$/x*l+m()*20*qa,N=2+Math.floor(m()*4);for(let V=0;V<N;V++){const Z=tg[m()<.66?0:1],I=eg[Math.floor(m()*eg.length)],F=`syn-session-${b++}`,Y=k+V*(2+m()*9)*qa;if(Y>h)continue;const P=m()<.7?"deepseek-v4-flash":"deepseek-v4";g.push({...Nt(Y,"began",{type:"session",id:F},{machineId:Z.id,executor:Il,model:P}),attrs:{context:I}});const he=`syn-proc-${D++}`,M=I.split("/").pop().toUpperCase();g.push(Nt(Y,"began",{type:"execution",id:he},{machineId:Z.id,sessionId:F,label:M,executor:Il,model:P,depth:0}));const E=m()<.35,j=(E?25+m()*95:2+m()*14)*qa,W=Math.max(1,Math.ceil(j/(_0*.6))),te=E?4:1;let le=Y;const $e=j/W;for(let se=0;se<W&&(le+=$e,!(le>h));se++)g.push(Nt(le,"progressed",{type:"execution",id:he},{measures:{...ng(te,m),[Xe.interactions]:Math.floor(m()*4),[Xe.errors]:m()<.06?1:0,[Xe.steps]:1}}));if(m()<d){const se=Y+j*(.35+m()*.3),R=se+(1+m()*18)*qa;se<h&&(g.push(Nt(se,"blocked",{type:"execution",id:he},{blockedOn:"approval"})),R<h&&g.push(Nt(R,"resumed",{type:"execution",id:he})))}if(E&&m()<.5){const se=`syn-proc-${D++}`,R=Y+j*.25,H=R+j*.4;R<h&&g.push(Nt(R,"began",{type:"execution",id:se},{machineId:Z.id,sessionId:F,label:`${M} · SUB`,executor:Il,model:P,parentId:he,depth:1}),Nt((R+H)/2,"progressed",{type:"execution",id:se},{measures:{...ng(1,m),[Xe.interactions]:3,[Xe.steps]:4}}),Nt(Math.min(h,H),"ended",{type:"execution",id:se},{outcome:"completed"}))}const de=Math.min(h,Y+j);if(m()<f?g.push(Nt(de,"ended",{type:"execution",id:he},{outcome:"error",failureCode:"TRANSPORT",failureMessage:"Provider request failed"})):g.push(Nt(de,"ended",{type:"execution",id:he},{outcome:"completed"})),g.push(Nt(de,"ended",{type:"session",id:F})),Z.id==="mini"&&m()<.3){const se=de+3e4,R=se+(1+m()*4)*qa;if(R<h){const H=`syn-xfer-${D}`;g.push({...Nt(se,"began",{type:"artifact",id:H},{label:"ARTIFACT SYNC",machineId:"mini"}),attrs:{"syn.transfer":!0,"syn.from":"mini","syn.to":"macbook","syn.bytes":Math.round(2e8+m()*3e9)}},{...Nt(R,"ended",{type:"artifact",id:H}),attrs:{"syn.transfer":!0}})}}}}return g.sort(($,k)=>$.occurredAt-k.occurredAt),{events:g,dayStart:r,dayEnd:h}}class r1{constructor(i={},r=180){this.timeScale=r;const l=a1(i);this.script=l.events,this.dayStart=l.dayStart,this.dayEnd=l.dayEnd,this.simNow=l.dayStart}timeScale;script;dayStart;dayEnd;cursor=0;simNow;timer=null;listener=null;batch=[];info(){return{id:"synthetic",name:"SYNTHETIC",kind:"synthetic",detail:`${this.script.length} events · ${this.timeScale}× replay`}}bounds(){return{dayStart:this.dayStart,dayEnd:this.dayEnd}}now(){return this.simNow}advanceTo(i){for(this.simNow=Math.max(this.simNow,i),this.batch.length=0;this.cursor<this.script.length&&this.script[this.cursor].occurredAt<=i;)this.batch.push(this.script[this.cursor++]);return this.batch.length&&this.listener&&this.listener(this.batch),this.batch}get exhausted(){return this.cursor>=this.script.length}subscribe(i){this.listener=i;const r=Date.now();return this.timer=setInterval(()=>{const l=this.dayStart+(Date.now()-r)*this.timeScale;this.advanceTo(l),this.exhausted&&this.timer&&(clearInterval(this.timer),this.timer=null)},250),()=>{this.timer&&clearInterval(this.timer),this.timer=null,this.listener=null}}simTimeAt(i,r){return this.dayStart+(r-i)*this.timeScale}}function ig(n){const i=$l(n.dayStart,n.dayEnd);i.now=n.now;for(const r of n.machines)i.machines.set(r.id,r);for(const r of n.sources)i.sources.set(`${r.id}:${r.instance}`,r);for(const r of n.sessions)i.sessions.set(r.id,r);for(const r of n.executions)i.executions.set(r.id,r),z0(r.status)&&i.active.add(r.id);for(const r of n.processes)i.processes.set(r.id,r);return i.processTotals=n.processTotals,i.relationships=n.relationships,i}async function s1(){const n=await fetch("/api/state");if(!n.ok)throw new Error(`state failed: ${n.status}`);return n.json()}async function Xc(n,i){try{const r=await fetch(`/api/collect?from=${n}&to=${i}`),l=await r.json().catch(()=>({}));return{ok:r.ok,fault:l.fault,error:l.error}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}async function Qc(n,i){const r=await fetch(`/api/world?from=${n}&to=${i}`);if(!r.ok)throw new Error(`world failed: ${r.status}`);return r.json()}async function l1(n,i){const r=await fetch(`/api/detail?type=${n}&id=${encodeURIComponent(i)}`);if(!r.ok)throw new Error(`detail failed: ${r.status}`);return r.json()}const u1=4e3,o1=3;class c1{constructor(i,r,l={}){this.initial=i,this.state=r,this.options=l,this.lastCollect=i.to}initial;state;options;timer=null;stopped=!1;lastCollect;generation=0;failures=0;trouble=null;get pollMs(){return this.options.pollMs??u1}get inFlight(){return this.running}running=!1;report(i){this.trouble?.kind===i?.kind&&this.trouble?.consecutiveFailures===i?.consecutiveFailures||(this.trouble=i,this.options.onTrouble?.(i))}info(){return{id:"capture",name:"CAPTURE",kind:"live",detail:this.state.store.bySource.filter(r=>r.source!=="host").map(r=>`${r.source} ${r.events}`).join(" · ")||"no sources have contributed yet"}}bounds(){return{dayStart:this.initial.from,dayEnd:this.initial.to}}now(){return Date.now()}relationships(){return this.initial.world.relationships}subscribe(i){queueMicrotask(()=>{this.stopped||i(ig(this.initial.world))});const r=async()=>{if(this.stopped)return;this.running=!0;const l=++this.generation;try{const u=Date.now(),f=await Xc(this.lastCollect,u);f.fault&&this.report({kind:"store-fault",message:f.fault.message,detail:f.fault.remedy,consecutiveFailures:0});const d=await Qc(this.initial.from,u);if(this.stopped||l!==this.generation)return;this.lastCollect=u,this.failures=0,f.fault||this.report(null),i(ig(d.world))}catch(u){this.failures++,this.failures>=o1&&this.report({kind:"capture-failing",message:`capture has failed ${this.failures} times in a row`,detail:u instanceof Error?u.message:String(u),consecutiveFailures:this.failures})}finally{this.running=!1,this.stopped||(this.timer=setTimeout(()=>{r()},this.pollMs))}};return this.timer=setTimeout(()=>{r()},this.pollMs),()=>{this.stopped=!0,this.timer&&clearTimeout(this.timer),this.timer=null}}}let hf=class extends Error{code;severity;fix;where;cause;detail;constructor(i){super(i.message,{cause:i.cause}),this.name="VGPUError",this.code=i.code,this.severity=i.severity??"error",this.fix=i.fix,this.where=i.where,this.cause=i.cause,this.detail=i.detail}};class cn extends hf{constructor(i){super({...i,severity:"error"}),this.name="ValidationError"}}function f1(n){return new hf({code:"VGPU-FEATURE-UNSUPPORTED",message:`Adapter does not support requested feature(s): ${n.map(i=>`"${i}"`).join(", ")}.`,fix:"Remove the unsupported name(s) from init({ requiredFeatures: [...] }) or run on an adapter that supports them; gate optional code paths on device.features after init.",where:"init"})}function d1(n,i){if(!n)return;const r=(i??[]).filter(l=>!n.has(l));if(r.length)throw f1(r)}const h1={map_read:1,map_write:2,copy_src:4,copy_dst:8,index:16,vertex:32,uniform:64,storage:128,indirect:256,query_resolve:512};function ds(n){const i=globalThis.GPUBufferUsage;return n.reduce((r,l)=>r|p1(l,i),0)}function p1(n,i){const r=n.toUpperCase();return i?.[r]??h1[n]}function ag(){return globalThis.GPUMapMode?.READ??1}const m1={copy_src:1,copy_dst:2,texture_binding:4,storage_binding:8,render_attachment:16};function g1(n){const i=globalThis.GPUTextureUsage;return n.reduce((r,l)=>r|y1(l,i),0)}function y1(n,i){const r=n.toUpperCase();return i?.[r]??m1[n]}function $0(n){return"__vgpuMockBytes"in n}function rg(n){return"__vgpuMockBytes"in n}let v1=1;function ru(n){return Object.freeze({kind:n,id:v1++})}class su{callbacks=new Set;destroyed=!1;onDestroy(i,r){return this.destroyed?(r(i),()=>{}):(this.callbacks.add(r),()=>{this.callbacks.delete(r)})}emit(i){if(this.destroyed)return!1;this.destroyed=!0;const r=[...this.callbacks];this.callbacks.clear();for(const l of r)l(i);return!0}}class Di{device;gpu;options;ownership;destroySignal=new su;identity=ru("buffer");destroyed=!1;constructor(i,r,l,u="owned"){this.device=i,this.gpu=r,this.options=l,this.ownership=u,Object.defineProperty(this,"assertUsable",{value:f=>this.#e(f)})}get resourceIdentity(){return this.identity}onDestroy(i){return this.destroySignal.onDestroy(this,i)}#e(i="Buffer"){if(this.destroyed)throw new cn({code:"VGPU-BUFFER-DISPOSED",message:"Buffer is destroyed.",where:i,fix:"Wrap or create a live GPUBuffer before using it."});this.device.assertUsable(i)}write(i,r=0){this.#e("Buffer.write"),this.ownership==="external"&&this.validateExternalOperation("write",r,i.byteLength,"copy_dst");try{this.device.queue.writeBuffer(this.gpu,r,i)}catch(l){throw this.ownership!=="external"?l:Ul("Buffer.write","The external GPUBuffer rejected the write operation.",l)}}async read(i,r=0){this.#e("Buffer.read"),this.ownership==="external"&&this.validateExternalOperation("read",r,i,"copy_src");try{const l=await this.device.readback.read(this.gpu,i,r);return this.#e("Buffer.read"),l}catch(l){throw l instanceof cn||this.ownership!=="external"?l:Ul("Buffer.read","The external GPUBuffer rejected the read operation.",l)}}destroy(){this.destroyed||(this.destroyed=!0,this.destroySignal.emit(this),this.ownership==="owned"&&!$0(this.gpu)&&this.gpu.destroy())}dispose(){this.destroy()}validateExternalOperation(i,r,l,u){if(!(Number.isSafeInteger(r)&&r>=0&&r%4===0&&Number.isSafeInteger(l)&&l>=0&&l%4===0&&r<=this.options.size&&l<=this.options.size-r))throw Ul(`Buffer.${i}`,"External buffer offsets and lengths must be non-negative, 4-byte aligned, and within the buffer size.");if((this.gpu.usage&ds([u]))===0)throw Ul(`Buffer.${i}`,`External buffer is missing ${u.toUpperCase()} usage.`)}}function Ul(n,i,r){return new cn({code:"VGPU-EXTERNAL-BUFFER-VALIDATION",message:i,where:n,cause:r,fix:"Use a buffer with the required usage flags and an aligned in-range operation."})}function b1(n){if(w1(n))throw E1();const i={version:1,mappings:[]},r={version:1,modules:[{path:"<runtime>",text:n}],diagnostics:[],sourceMap:i,cacheKey:x1(n)};return{kind:"wgsl",wgsl:n,source:{text:n,path:"<runtime>",imports:[]},ast:r,sourceMap:i,diagnostics:[],cacheKey:r.cacheKey,entryPoints:S1(n),stats:{lines:n.split(/\r?\n/).length,bytes:new TextEncoder().encode(n).byteLength,bindGroups:0}}}function x1(n){let i=2166136261;for(let r=0;r<n.length;r++)i=Math.imul(i^n.charCodeAt(r),16777619);return{default:`vgpu-wgsl-1:${(i>>>0).toString(16).padStart(8,"0")}`}}function S1(n){const i=[],r=/@(vertex|fragment|compute)\s+fn\s+([A-Za-z_][A-Za-z0-9_]*)/g;for(const l of n.matchAll(r))i.push(l[2]);return i}function w1(n){const i=n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").trimStart();return i.startsWith("import ")||i.startsWith("import{")}function E1(){const n=new Error("Runtime WGSL strings cannot contain import statements. Use a build-time loader or @vgpu/wgsl/runtime.");return n.name="VGPUWGSLRuntimeImportError",n.code="VGPU-WGSL-RUNTIME-IMPORT",n.severity="error",n.source="wgsl",n}const sg=ds(["copy_dst","map_read"]);class A1{device;constructor(i){this.device=i}async read(i,r,l){if($0(i))return i.__vgpuMockBytes.slice(l,l+r).buffer;const u=this.device.createBuffer({size:r,usage:sg});try{const f=this.device.createCommandEncoder();f.copyBufferToBuffer(i,l,u,0,r),this.device.queue.submit([f.finish()]),await u.mapAsync(ag());const d=u.getMappedRange().slice(0);return lg(u),d}finally{ug(u)}}async readTexture(i,r,l){const[u,f]=r,d=Pl(l,"Readback.readTexture"),h=d.bytesPerPixel,m=T1(u*h,256),g=m*f,x=this.device.createBuffer({size:g,usage:sg});let b;try{const D=this.device.createCommandEncoder();D.copyTextureToBuffer({texture:i},{buffer:x,bytesPerRow:m,rowsPerImage:f},{width:u,height:f}),this.device.queue.submit([D.finish()]),await x.mapAsync(ag());const $=new Uint8Array(x.getMappedRange());b=new Uint8Array(u*f*h);for(let k=0;k<f;k++){const N=k*m,V=k*u*h;b.set($.subarray(N,N+u*h),V)}lg(x)}finally{ug(x)}return d.swizzle==="bgra-to-rgba"&&V0(b),b}destroy(){}}function lg(n){try{n.unmap()}catch{}}function ug(n){try{n.destroy()}catch{}}function T1(n,i){return Math.ceil(n/i)*i}const og={r8unorm:{bytesPerPixel:1,components:1,componentType:"unorm8"},rg8unorm:{bytesPerPixel:2,components:2,componentType:"unorm8"},rgba8unorm:{bytesPerPixel:4,components:4,componentType:"unorm8"},"rgba8unorm-srgb":{bytesPerPixel:4,components:4,componentType:"unorm8"},bgra8unorm:{bytesPerPixel:4,components:4,componentType:"unorm8",swizzle:"bgra-to-rgba"},"bgra8unorm-srgb":{bytesPerPixel:4,components:4,componentType:"unorm8",swizzle:"bgra-to-rgba"},r16float:{bytesPerPixel:2,components:1,componentType:"float16"},rg16float:{bytesPerPixel:4,components:2,componentType:"float16"},rgba16float:{bytesPerPixel:8,components:4,componentType:"float16"},r32float:{bytesPerPixel:4,components:1,componentType:"float32"},rg32float:{bytesPerPixel:8,components:2,componentType:"float32"},rgba32float:{bytesPerPixel:16,components:4,componentType:"float32"}};function Pl(n,i){const r=og[n];if(r)return r;throw new cn({code:"VGPU-CORE-UNSUPPORTED-FORMAT",message:`Texture.read does not support format ${n}. Supported formats: ${Object.keys(og).join(", ")}.`,where:i})}function M1(n,i,r="Texture.readFloats"){const l=Pl(i,r),u=l.bytesPerPixel/l.components,f=Math.floor(n.byteLength/u),d=new Float32Array(f),h=new DataView(n.buffer,n.byteOffset,n.byteLength);for(let m=0;m<f;m++)l.componentType==="unorm8"?d[m]=h.getUint8(m)/255:l.componentType==="float16"?d[m]=D1(h.getUint16(m*2,!0)):d[m]=h.getFloat32(m*4,!0);return d}function D1(n){const i=n&32768?-1:1,r=n>>10&31,l=n&1023;return r===0?i*l*2**-24:r===31?l===0?i*Number.POSITIVE_INFINITY:Number.NaN:i*(l+1024)*2**(r-25)}function R1(n,i,r){const l=n.slice(0,i[0]*i[1]*r.bytesPerPixel);return r.swizzle==="bgra-to-rgba"&&V0(l),l}function V0(n){for(let i=0;i<n.length;i+=4){const r=n[i];n[i]=n[i+2],n[i+2]=r}}function C1(n){return{size:n,usage:ds(["copy_src","copy_dst"])}}class O1{gpu;guard;constructor(i,r=()=>{}){this.gpu=i,this.guard=r}writeBuffer(i,r,l){this.guard("Queue.writeBuffer"),this.gpu.writeBuffer(i,r,l)}async flush(){this.guard("Queue.flush"),await this.gpu.onSubmittedWorkDone?.(),this.guard("Queue.flush")}}class z1{gpu;resolved;constructor(i,r){this.gpu=i,this.resolved=r}dispose(){}get kind(){return this.resolved.kind}get source(){return this.resolved.source}get code(){return this.resolved.wgsl}get entryPoints(){return this.resolved.entryPoints}get stats(){return this.resolved.stats}}const _1=Symbol.for("vgpu/Texture"),U1=Symbol.for("vgpu/Texture/resizeLock");class nr{device;ownership;[_1]=!0;destroySignal=new su;identity=ru("texture");currentGpu;currentOptions;defaultView=null;resizeLock;destroyed=!1;constructor(i,r,l,u="owned"){this.device=i,this.ownership=u,this.currentGpu=r,this.currentOptions=l,Object.defineProperty(this,U1,{value:f=>{this.resizeLock=f}})}get gpu(){return this.currentGpu}get options(){return this.currentOptions}get size(){return this.options.size}get format(){return this.options.format}get usage(){return this.options.usage}get mipLevelCount(){return this.options.mipLevelCount??1}get sampleCount(){return this.options.sampleCount??1}get dimension(){return this.options.dimension??"2d"}get viewFormats(){return this.options.viewFormats??[]}get label(){return this.options.label}get resourceIdentity(){return this.identity}onDestroy(i){return this.destroySignal.onDestroy(this,i)}get view(){return this.assertAlive(),this.defaultView??=this.createView(),this.defaultView}createView(i){return this.assertAlive("Texture.createView"),this.gpu.createView(i)}resize(i){if(this.assertAlive(),this.ownership==="external")throw new cn({code:"VGPU-CORE-EXTERNAL-TEXTURE",message:"Texture wraps an externally owned GPUTexture and cannot be resized.",where:"Texture.resize"});if(this.resizeLock)throw new cn({code:"VGPU-CORE-TEXTURE-RESIZE-LOCKED",message:this.resizeLock,where:"Texture.resize"});const r=this.options.size[2]??1,l=i[2]??r;if(this.options.size[0]===i[0]&&this.options.size[1]===i[1]&&r===l)return!1;const u=i[2]===void 0&&this.options.size[2]===void 0?[i[0],i[1]]:[i[0],i[1],l],f={...this.options,size:u},d=this.gpu;return this.currentGpu=this.device.gpu.createTexture(I0(f)),this.currentOptions=f,this.defaultView=null,d.destroy(),!0}async read(){this.assertAlive("Texture.read");const i=Pl(this.options.format,"Texture.read");if(rg(this.gpu))return R1(this.gpu.__vgpuMockBytes,this.options.size,i);const r=await this.device.readback.readTexture(this.gpu,this.options.size,this.options.format);return this.assertAlive("Texture.read"),r}async readFloats(){return Pl(this.options.format,"Texture.readFloats"),M1(await this.read(),this.options.format)}destroy(){this.destroyed||(this.destroyed=!0,this.defaultView=null,this.destroySignal.emit(this),this.ownership!=="external"&&(rg(this.gpu)||this.gpu.destroy()))}dispose(){this.destroy()}assertAlive(i="Texture"){if(this.destroyed)throw new cn({code:"VGPU-CORE-TEXTURE-DESTROYED",message:"Texture is destroyed",where:i});this.device.assertUsable?.(i)}}function I0(n){const i={label:n.label,size:{width:n.size[0],height:n.size[1],depthOrArrayLayers:n.size[2]??1},format:n.format,usage:g1(n.usage)};return n.mipLevelCount!==void 0&&(i.mipLevelCount=n.mipLevelCount),n.sampleCount!==void 0&&(i.sampleCount=n.sampleCount),n.dimension!==void 0&&(i.dimension=n.dimension),n.viewFormats!==void 0&&(i.viewFormats=[...n.viewFormats]),i}class N1{gpu;adapterInfo;queue;readback;isCompatibilityMode;scopes=[];ownership;state="alive";lossInfo;observeLoss=!0;constructor(i,r=null,l="owned",u={}){this.gpu=i,this.adapterInfo=r,Object.defineProperty(this,"assertUsable",{value:h=>this.#e(h)}),this.ownership=typeof l=="string"?l:"owned";const f=typeof l=="string"?u:l;this.isCompatibilityMode=f.isCompatibilityMode??!1,this.queue=new O1(i.queue,h=>this.#e(h)),this.readback=new A1(i);const d=i.lost;d&&typeof d.then=="function"&&Promise.resolve(d).then(h=>{!this.observeLoss||this.state!=="alive"||(this.lossInfo=h,this.state="lost")},()=>{})}get limits(){return this.#e("Device.limits"),this.gpu.limits}get features(){return this.#e("Device.features"),this.gpu.features}createShader(i){this.#e("Device.createShader");const r=typeof i=="string"?b1(i):i;return new z1(this.gpu.createShaderModule({code:r.wgsl}),r)}createTexture(i){return this.#e("Device.createTexture"),new nr(this,this.gpu.createTexture(I0(i)),i)}createBuffer(i){this.#e("Device.createBuffer");const r=L1(i);r&&this.captureError(r);const l=r?C1(Math.max(4,i.size||4)):k1(i);return new Di(this,this.gpu.createBuffer(l),i)}wrapBuffer(i){if(this.#e("Device.wrapBuffer"),!G1(i))throw new cn({code:"VGPU-EXTERNAL-BUFFER-INVALID",message:"Device.wrapBuffer requires a GPUBuffer with finite size and usage properties.",where:"Device.wrapBuffer",fix:"Pass a live GPUBuffer created for this GPUDevice."});const r={size:i.size,usage:$1(i.usage),...i.label?{label:i.label}:{}};return new Di(this,i,r,"external")}pushErrorScope(i){this.#e("Device.pushErrorScope"),this.scopes.push([]),this.gpu.pushErrorScope?.(i)}async popErrorScope(){this.#e("Device.popErrorScope");const i=this.scopes.pop(),r=await this.gpu.popErrorScope?.();return this.#e("Device.popErrorScope"),i?.[0]??j1(r)??null}#e(i){if(this.state==="alive")return;if(this.state==="disposed")throw new cn({code:"VGPU-DEVICE-DISPOSED",message:"The GPU device wrapper has been disposed.",where:i,fix:"Create a new Gpu instance before performing more work."});const r=this.lossInfo?.reason,l=this.lossInfo?.message;throw new cn({code:"VGPU-DEVICE-LOST",message:`The GPU device was lost${r?` (${r})`:""}${l?`: ${l}`:"."}`,where:i,cause:this.lossInfo})}destroy(){if(this.state==="disposed")return;const i=this.state==="lost";this.state="disposed",this.observeLoss=!1,this.scopes.length=0,this.readback.destroy(),this.ownership==="owned"&&!i&&this.gpu.destroy()}dispose(){this.destroy()}captureError(i){const r=this.scopes.at(-1);if(r)r.push(i);else throw i}}function L1(n){return!Number.isFinite(n.size)||n.size<=0?cg("Buffer size must be greater than zero."):n.usage.length===0?cg("Buffer usage must not be empty."):null}function cg(n){return new cn({code:"VGPU-CORE-INVALID-USAGE",message:n,where:"Device.createBuffer"})}function k1(n){return{label:n.label,size:n.size,usage:ds(n.usage)}}function j1(n){return n?new cn({code:"VGPU-CORE-VALIDATION",message:n.message,where:"GPUDevice.popErrorScope",cause:n}):null}function G1(n){if(typeof n!="object"&&typeof n!="function"||n===null)return!1;const i=n;return Number.isSafeInteger(i.size)&&(i.size??-1)>=0&&Number.isSafeInteger(i.usage)&&(i.usage??-1)>=0&&typeof i.destroy=="function"}const B1=["map_read","map_write","copy_src","copy_dst","index","vertex","uniform","storage","indirect","query_resolve"];function $1(n){return B1.filter(i=>(n&ds([i]))!==0)}const F0=new WeakMap,V1=new WeakMap;function I1(n,i){return F0.set(n,F1(i)),n}function ss(n){return F0.get(n)}function H0(n){return V1.get(n)}function F1(n){return{entries:n.entries.map(i=>({...i}))}}let ie=class extends hf{};function H1(n,i,r,l,u,f){const d=i==="vertex"?"Vertex":"Fragment",h=i==="vertex"?"VERTEX":"FRAGMENT",m=`maxStorageBuffersIn${d}Stage`;return new ie({code:`VGPU-LIMIT-STORAGE-${h}`,message:`${d} entry '${r}' in '${n}' uses ${l} storage buffer(s), but device limit ${m} is ${u}.`,fix:i==="vertex"?`Request init({ requiredLimits: { ${m}: ${l} } }) if the adapter supports it, or move vertex data to geometry(gpu, ...) vertex streams.`:`Request init({ requiredLimits: { ${m}: ${l} } }) if the adapter supports it, or reduce fragment storage buffers.`,where:`${n}.pipelineLayout`,detail:{stage:i,entryPoint:r,count:l,limit:u,bindings:f.map(({name:g,group:x,binding:b})=>({name:g,group:x,binding:b}))}})}function q1(n,i,r,l,u){return new ie({code:"VGPU-SET-TEXTURE-FILTERABILITY",message:`${l} (${r}) cannot satisfy filtering texture '${i.name}' @group(${i.group}) @binding(${i.binding}).`,fix:"Use a filterable format; request float32-filterable for rgba32float when supported; or use textureLoad without a sampler.",where:`${n}.set`,detail:{format:r,group:i.group,binding:i.binding,bindingName:i.name,resourceName:l,samplerName:u?.name,samplerGroup:u?.group,samplerBinding:u?.binding}})}function Y1(n,i){const r=xS(n,i);return new ie({code:"VGPU-R1-BINDING-NEVER-SET",message:`Unset \`${i.name}\` @group(${i.group}) @binding(${i.binding}) in '${n}'. Fix: ${r}; or ${n}.group(${i.group}, bindGroup).`,where:`${n}.draw`})}function q0(n,i){const r=i==="lib"?"lib-owned by its first JS set()":"user-owned by its first resource set()",l=i==="lib"?`Fix: pass a resource from the start: wave.set({ ${n}: new Uniform(gpu.device, { size: 4 }) }).`:`Fix: pass JS values from the first set(): wave.set({ ${n}: jsValue }).`;return new ie({code:"VGPU-R1-OWNERSHIP-FLIP",message:`\`${n}\` is ${r}; ownership cannot change. ${l}`,where:"set"})}function X1(n,i){return new ie({code:"VGPU-R4-GROUP-CLAIMED",message:`group ${i} of '${n}' is claimed; set() cannot update it.`,fix:`Call set() first, or build from ${n}.layout(${i}); pass dynamic offsets to p.draw().`,where:`${n}.set`})}function Q1(n,i,r,l){return new ie({code:"VGPU-R4-GROUP-INCOMPATIBLE",message:`claimed group ${i} in '${n}' is incompatible: ${r}.`,fix:`Build from ${n}.layout(${i}, { dynamicOffsets? }) then call ${n}.group(${i}, bindGroup).`,where:`${n}.group`,cause:l})}function tr(n,i,r){return new ie({code:"VGPU-R4-GROUP-VALIDATION",message:`WebGPU rejected claimed group ${i} in '${n}'.`,fix:`Build from ${n}.layout(${i}); pass offsets via p.draw(draw, { offsets: { ${i}: [...] } }).`,where:`${n}.draw`,cause:r,detail:{drawLabel:n,group:i}})}function fg(n,i){return new ie({code:"VGPU-BLEND-INVALID",message:`Invalid blend '${String(i)}' in '${n}'.`,fix:'Use "alpha", "additive", "premultiplied", or { color, alpha? } components.',where:"draw"})}function dg(n,i){return new ie({code:"VGPU-BLEND-CONSTANT-INVALID",message:`Invalid blendConstant in '${n}': ${i}`,fix:'Use [r, g, b, a] finite numbers with a blend whose color or alpha uses "constant"/"one-minus-constant"; omit it to keep the pass default (0, 0, 0, 0).',where:"draw"})}function hg(n,i){return new ie({code:"VGPU-WRITEMASK-INVALID",message:`Invalid writeMask ${i} in '${n}'.`,fix:"Use an array of r/g/b/a; omit it for all channels.",where:"draw"})}function Kc(n,i,r="draw"){return new ie({code:"VGPU-COLORS-INVALID",message:`Invalid colors in '${n}': ${i}`,fix:"Use one { blend?, writeMask? } or null entry per color attachment of the target, aligned by index; omit colors to apply the top-level blend/writeMask to every attachment.",where:r})}function K1(n,i){return new ie({code:"VGPU-CULL-INVALID",message:`Invalid cull '${String(i)}' in '${n}'.`,fix:'Use "none", "front", or "back"; omit it for no culling.',where:"draw"})}function Z1(n,i){return new ie({code:"VGPU-FRONTFACE-INVALID",message:`Invalid frontFace '${String(i)}' in '${n}'.`,fix:'Use "ccw" or "cw"; omit it for counter-clockwise.',where:"draw"})}function pg(n,i){return new ie({code:"VGPU-UNCLIPPED-DEPTH-INVALID",message:`Invalid unclippedDepth in '${n}': ${i}`,fix:'Use a boolean. unclippedDepth: true needs the "depth-clip-control" device feature — request it with init({ requiredFeatures: ["depth-clip-control"] }) on an adapter that supports it. Omit the option to keep depth clipping.',where:"draw"})}function Yn(n,i){return new ie({code:"VGPU-DEPTH-INVALID",message:`Invalid depth in '${n}': ${i}`,fix:'Use false or { write?, compare?, bias?, biasSlopeScale?, biasClamp? }; omit it for { write: true, compare: "less-equal" }.',where:"draw"})}function Ja(n,i,r="draw"){return new ie({code:"VGPU-STENCIL-INVALID",message:`Invalid stencil in '${n}': ${i}`,fix:`Use { front?, back?, readMask?, writeMask?, ref? } with GPUCompareFunction/GPUStencilOperation faces and u32 masks, against a target whose depth format has a stencil aspect (depth: "depth24plus-stencil8"); omit it for WebGPU's pass-through defaults.`,where:r})}function Fl(n,i,r="draw"){return new ie({code:"VGPU-MULTISAMPLE-INVALID",message:`Invalid multisample in '${n}': ${i}`,fix:"Use { alphaToCoverage?, mask? }: alphaToCoverage needs a target created with msaa: true, and mask must be an integer in [0, 0xFFFFFFFF] (bits above the target's sampleCount are ignored). Omit multisample for full-coverage defaults.",where:r})}function Nl(n,i,r="draw"){return new ie({code:"VGPU-CONSTANTS-INVALID",message:`Invalid constants in '${n}': ${i}`,fix:"Key WGSL `override` constants by name, or by the decimal string of N when the declaration has @id(N); values are finite numbers or booleans, converted to the override's WGSL type (bool/i32/u32/f32/f16). Every override without a default value must be provided. Omit constants to keep the WGSL defaults.",where:r})}function Hl(n,i,r="draw"){return new ie({code:"VGPU-ENTRY-INVALID",message:`Invalid entry in '${n}': ${i}`,fix:"Name an entry point declared in the shader with the matching stage — { vertex?, fragment? } strings for draw, one @compute name string for compute. Omit entry (or a field) to use the first entry point of that stage.",where:r})}function Ya(n,i,r){return new ie({code:"VGPU-INDIRECT-INVALID",message:`Invalid indirect in '${n}': ${i}`,fix:"Pass a storage buffer created with storage(gpu, bytes, { indirect: true }) — bare, or as { buffer, offset? } with a 4-aligned byte offset — sized so the GPU-read arguments fit: 16 bytes for drawIndirect, 20 for drawIndexedIndirect, 12 for dispatchWorkgroupsIndirect. Omit indirect to use CPU-side counts.",where:r})}function P1(){return new ie({code:"VGPU-PASS-PRESERVE-MSAA",message:"clear:false cannot preserve MSAA; use a non-MSAA target.",fix:"Use non-MSAA for accumulation.",where:"Frame.pass"})}function mg(n,i="expected a number in [0, 1].",r='Use 1 (default), or 0 with depth: { compare: "greater" } for reversed-Z.'){return new ie({code:"VGPU-PASS-CLEARDEPTH-INVALID",message:`clearDepth received ${String(n)}; ${i}`,fix:r,where:"Frame.pass"})}function Xn(n){return new ie({code:"VGPU-PASS-VIEWPORT-INVALID",message:`Invalid viewport: ${n}`,fix:"Use { x?, y?, width, height, minDepth?, maxDepth? } finite numbers within device limits; omit it for the full target.",where:"Frame.pass"})}function zc(n){return new ie({code:"VGPU-PASS-SCISSOR-INVALID",message:`Invalid scissor: ${n}`,fix:"Use [x, y, width, height] non-negative integers with x + width and y + height within the target's current pixel size; omit it for the full target.",where:"Frame.pass"})}function W1(){return new ie({code:"VGPU-PASS-PRESERVE-CLEARDEPTH",message:"clear:false preserves depth; clearDepth cannot apply.",fix:"Remove clearDepth, or let the pass clear.",where:"Frame.pass"})}function gg(n){return new ie({code:"VGPU-PASS-CLEARSTENCIL-INVALID",message:`clearStencil ${n}`,fix:`Use an integer in [0, 0xFFFFFFFF] on a target whose depth format has a stencil aspect, e.g. depth: "depth24plus-stencil8"; the value is masked to the stencil aspect's bit width.`,where:"Frame.pass"})}function J1(){return new ie({code:"VGPU-PASS-PRESERVE-CLEARSTENCIL",message:"clear:false preserves stencil; clearStencil cannot apply.",fix:"Remove clearStencil, or let the pass clear.",where:"Frame.pass"})}function ea(n,i,r="Frame.pass"){return new ie({code:"VGPU-PASS-DEPTH-READONLY",message:`depthReadOnly ${n}`,fix:i,where:r})}function eS(){return new ie({code:"VGPU-PASS-DEPTH-READONLY-MSAA",message:`depthReadOnly cannot read an MSAA target's depth: multisampled depth is stored with storeOp "discard", so a read-only pass tests against discarded contents.`,fix:"Use a non-MSAA target for read-only depth, or drop depthReadOnly and let the pass own its depth.",where:"Frame.pass"})}function Xa(n,i,r="timer"){return new ie({code:"VGPU-TIMER-INVALID",message:`Invalid timer use: ${n}`,fix:i,where:r})}function tS(n,i){return new ie({code:"VGPU-TIMER-CAPACITY",message:`frame exceeds ${n} timed spans; a timer holds one timestamp query set and WebGPU createQuerySet requires count <= ${i} (2 queries per span).`,fix:"Time fewer passes per frame, or spread timing across frames.",where:"Frame.pass"})}function nS(n,i,r="visibility"){return new ie({code:"VGPU-VIS-INVALID",message:`Invalid visibility use: ${n}`,fix:i,where:r})}function iS(){return new ie({code:"VGPU-QUERY-NO-VISIBILITY",message:"occlusion() needs the pass to be opened with a visibility instance; the render pass has no occlusionQuerySet to write into.",fix:"Open the pass with f.pass({ target, visibility: vis }, ...) using the visibility(gpu) instance that created the query handle.",where:"FramePass.occlusion"})}function aS(){return new ie({code:"VGPU-QUERY-NESTED",message:"occlusion() cannot nest inside an active occlusion() body; WebGPU allows one active occlusion query per pass at a time.",fix:"Encode each occlusion scope sequentially: p.occlusion(a, ...); p.occlusion(b, ...).",where:"FramePass.occlusion"})}function Zc(n="Frame.pass"){return new ie({code:"VGPU-TARGET-REQUIRED",message:"Target required. Fix: pass surface(gpu, canvas) or target(gpu, { size }) as { target }.",where:n})}function rS(n,i,r,l){return new ie({code:n,message:`${n}: ${r}`,fix:l,where:i})}function pf(n,i){return rS("VGPU-MESH-RANGE-INVALID",n,i,"Use index ranges for indexed geometries, vertex ranges otherwise, within geometry counts.")}function sS(n){return new ie({code:"VGPU-PIPELINE-LAYOUT-GAP",message:`Pipeline bind group ${n} is missing.`,fix:"Use consecutive @group() indices starting at 0.",where:"pipeline layout"})}function Jr(n,i,r){return new ie({code:"VGPU-COMPILE-FAILED",message:"WebGPU pipeline compilation failed.",fix:"Check WGSL, vertex layouts, and target signature.",where:n,cause:i,detail:r?{signature:r}:void 0})}function yg(n){return new ie({code:"VGPU-COMPILE-DISPOSED",message:"GPU disposed during pipeline compilation.",where:n})}function Ll(n,i){return new ie({code:"VGPU-COMPILE-SIGNATURE-INVALID",message:`Invalid TargetSignature: ${i}`,fix:"Pass { colors, depth?, sampleCount?:1|4 } or a Target.",where:n})}function lS(n){return new ie({code:"VGPU-TARGET-DEPTH-STENCIL-ONLY",message:`depth received '${n}'; stencil-only depth targets are not supported yet.`,fix:'Use a format with a depth aspect such as "depth24plus" or "depth24plus-stencil8".',where:"target"})}function Y0(){return new ie({code:"VGPU-TARGET-SIZE-REQUIRED",message:"Target size required. Fix: target(gpu, { size: [w,h] }); update surface-derived targets in onResize.",where:"target"})}function X0(n){return new ie({code:"VGPU-SURFACE-NOT-IN-FRAME",message:"Surface targets are only available inside frame(gpu).",fix:"surface passes must run inside frame(gpu, ...); precompile against an offscreen target(gpu, ...) instead",where:n})}function uS(){return new ie({code:"VGPU-SURFACE-CONTEXT",message:"Canvas WebGPU context failed. Fix: check navigator.gpu and remove any existing 2d/webgl context.",where:"surface"})}function oS(n){return new ie({code:"VGPU-SURFACE-DUPLICATE",message:`Canvas already has surface${n?` '${n}'`:""}. Fix: reuse or dispose it.`,where:"surface"})}function cS(n){return new ie({code:"VGPU-SURFACE-DISPOSED",message:`Surface '${n??"surface"}' is disposed. Fix: call surface(gpu, canvas).`,where:"surface"})}function fS(){return new ie({code:"VGPU-SURFACE-AUTORESIZE-UNSUPPORTED",message:"autoResize needs clientWidth. Fix: call surface.resize([w,h]) for OffscreenCanvas; onResize still fires.",where:"surface"})}function dS(n){return new ie({code:"VGPU-SURFACE-RESIZE-REENTRANT",message:`Cannot resize this surface${n?` '${n}'`:""} in onResize. Fix: resize derived targets only.`,where:"surface.resize"})}function hS(n){return new ie({code:"VGPU-CLEAR-COLOR-INVALID",message:`Invalid ${n}: expected four finite numbers.`,fix:"Assign [r, g, b, a] or a GPUColor object ({ r, g, b, a }).",where:n})}function Q0(){return new ie({code:"VGPU-FRAME-REENTRANT",message:"Nested frame(gpu) is invalid. Fix: queue work for the next frame.",where:"frame"})}function pS(n,i){return new ie({code:"VGPU-QUERY-READBACK",message:`${n} dropped a query readback: ${yS(i)}`,fix:"Usually a lost or destroyed device: recreate the gpu (and the timer/visibility instance) before reading queries again. Results resume on the next successful readback; the frame itself is unaffected.",where:"QueryRing.onSubmitted",cause:i})}function vg(n){return new ie({code:"VGPU-FRAME-CANCELED",message:"the frame was canceled; its command encoder was dropped and nothing more can be encoded or submitted on it.",fix:"Open a new frame(gpu) for further work; cancel() is the last operation on a frame.",where:n})}function mS(n){return new ie({code:"VGPU-FRAME-PASS-ACTIVE",message:"the frame cannot be canceled while a pass callback is active.",fix:"Return from the frame.pass(...) callback first, then call frame.cancel(); this keeps pass descriptor resources alive until the pass is closed.",where:n})}function gS(n){return new ie({code:"VGPU-FRAME-SUBMITTED",message:"the frame was already submitted; submitted GPU work cannot be canceled.",fix:"Call cancel() only on a frame you decided not to submit; the frame you did submit needs no cleanup.",where:n})}function Kn(n,i,r){return new ie({code:"VGPU-R1-BINDING-INCOMPATIBLE-RESOURCE",message:`binding \`${n.name}\` @group(${n.group}) @binding(${n.binding}) needs ${i}.`,fix:r,where:"set"})}function Yt(n,i,r){return new ie({code:"VGPU-RING1-UNSUPPORTED",message:i,fix:r,where:n})}function kl(n){return vS(n)&&n.version!==1?new ie({code:"VGPU-SHADER-SOURCE-INVALID",message:`VGPU-SHADER-SOURCE-INVALID: unsupported ShaderSource v${String(n.version)}; expected v1. Fix: update vgpu or regenerate it.`,where:"shader source"}):new ie({code:"VGPU-SHADER-SOURCE-INVALID",message:`VGPU-SHADER-SOURCE-INVALID: expected WGSL or { version, wgsl }, got ${bS(n)}. Fix: configure @vgpu/wgsl loader-vite or loader-webpack.`,where:"shader source"})}function yS(n){return n instanceof Error?`${n.name}: ${n.message}`:String(n)}function vS(n){return typeof n=="object"&&n!==null&&"version"in n}function bS(n){if(typeof n!="object"||n===null)return typeof n;try{const i=JSON.stringify(n);return i.length>80?`${i.slice(0,77)}...`:i}catch{return"object"}}function xS(n,i){switch(i.kind){case"sampler":return`${n}.set({${i.name}:sampler(gpu)})`;case"texture":return`${n}.set({${i.name}:scene.color})`;case"buffer":return i.addressSpace==="uniform"?`${n}.set({${i.name}:{ /* values */ }})`:`${n}.set({${i.name}:buffer})`;default:return`${n}.set({${i.name}:resource})`}}const bg=["scheduler","resource","service"];function lu(n){return{name:n}}const K0=new WeakMap;function SS(n){const i=K0.get(n);if(!i)throw new ie({code:"VGPU-GPU-FOREIGN",message:"This object was not created by init(); it has no vgpu kernel.",fix:"Pass the gpu returned by init() from vgpu, vgpu/node or vgpu/mock.",where:"gpu"});return i}class wS{device;#e=new Map;#t=new Map(bg.map(i=>[i,new Set]));#n=new Set;#i=new Set;#a=new Set;#r=!1;constructor(i){this.device=i}get disposed(){return this.#r}service(i,r){const l=this.#e.get(i);if(l!==void 0)return l;const u=r(this);return this.#e.set(i,u),u}peekService(i){return this.#e.get(i)}own(i,r){const l=this.#t.get(i);return l.add(r),()=>{l.delete(r)}}addErrorListener(i){return this.#n.add(i),()=>{this.#n.delete(i)}}reportError(i){if(this.#r)return Promise.resolve();const r=Promise.resolve().then(()=>{const l=[...this.#n];if(!l.length){console.error(i);return}for(const u of l)try{u(i)}catch(f){console.error(f)}});return this.trackDelivery(r)}trackDelivery(i){const r=Promise.resolve(i).then(()=>{},l=>{console.error(l)});return this.#i.add(r),r.finally(()=>this.#i.delete(r)),r}registerSettledSource(i){return this.#a.add(i),()=>{this.#a.delete(i)}}async settled(){const i=[...this.#i,...[...this.#a].flatMap(r=>r())];await Promise.allSettled(i)}dispose(){if(!this.#r){this.#r=!0;for(const i of bg){const r=this.#t.get(i);for(const l of[...r])l();r.clear()}this.#e.clear(),this.#a.clear(),this.#n.clear(),this.device.dispose()}}}function ES(n){const i=new wS(n),r={device:n,gpu:n.gpu,get disposed(){return i.disposed},onError:l=>i.addErrorListener(l),settled:()=>i.settled(),dispose:()=>{i.dispose()}};return K0.set(r,i),r}async function AS(n,i={},r){return ES(await TS(n,i,r))}async function TS(n,i,r){return i.adapter||r?(i.adapter??r()).requestDevice(i):MS(i)}async function MS(n){const r=await globalThis.navigator.gpu?.requestAdapter({powerPreference:n.powerPreference});if(!r)throw Yt("init","navigator.gpu.requestAdapter() returned null.");d1(r.features,n.requiredFeatures);const l=await r.requestDevice({requiredFeatures:n.requiredFeatures,requiredLimits:n.requiredLimits});return new N1(l,r.info??null)}function ht(n,i){n.assertUsable(i)}function xg(n,i){n.assertUsable(i)}const Z0=Symbol("vgpu.bindingResource");function DS(n){return typeof(typeof n=="object"&&n!==null?n[Z0]:void 0)=="function"?n:void 0}const Pc=Symbol("vgpu.geometry.layoutResolver");function Pn(n,i){const r=SS(n);if(r.disposed)throw RS(i);return r}function RS(n){return new ie({code:"VGPU-GPU-DISPOSED",message:`${n}() ran after gpu.dispose(); the device and everything it owned are gone.`,fix:"Create resources before disposing the gpu, or init() a new one.",where:n})}function CS(n,i){let r=()=>{};const l=i({trackSettled:u=>{n.trackDelivery(u)},errorSink:u=>n.reportError(u),onDispose:()=>{r()}});return r=n.own("resource",()=>l.dispose()),l}function P0(n,i,r,l){const u=n.own("resource",()=>r(i));return l?.(u),i}class W0 extends Error{code;line;column;severity;metadata;relatedDiagnostics;fix;where;cause;constructor(i,r,l=1,u=1,f="error"){super(r),this.name="VGPUError",this.code=i,this.line=l,this.column=u,this.severity=f}}function OS(n,i,r={}){const l=new W0(n,i,r.line??1,r.column??1,r.severity??"error");return r.fix!==void 0&&(l.fix=r.fix),r.where!==void 0&&(l.where=r.where),r.cause!==void 0&&(l.cause=r.cause),r.metadata!==void 0&&(l.metadata=r.metadata),l}function et(n,i,r=1,l=1){return new W0(n,i,r,l)}const zS=new Set(["fn","struct","const","alias","var","override"]);function _S(n){const i=[],r=[],l=[];let u=0,f=!1,d=0;for(;u<n.length;){const h=n[u];if(h.text==="{"){d++,u++;continue}if(h.text==="}"){d=Math.max(0,d-1),u++;continue}if(J0(h)){u++;continue}if(d>0){u++;continue}if(h.text==="import"){if(f)throw et("VGPU-WGSL-IMP-ORDER","Imports must precede declarations",h.line,h.column);const[b,D]=US(n,u);i.push(b),u=D;continue}if(h.text==="export"&&n[u+1]?.text==="{")throw et("VGPU-WGSL-EXP-REEXPORT-CYCLE","Re-export cycles are not supported",h.line,h.column);if(h.text==="@"&&n[u+2]?.text==="export"&&n[u+3]?.text==="@")throw et("VGPU-WGSL-EXP-NOTDECL","Repeated export attributes",h.line,h.column);const m=h.text==="export"||h.text==="@"&&n[u+2]?.text==="export",g=m?NS(n,h.text==="export"?u+1:u+3):u,x=n[g];if(x&&zS.has(x.text)){const b=LS(n,g);r.push({name:b,localName:b,kind:x.text}),m&&l.push({name:b,localName:b,kind:x.text}),f=!0}u++}return{imports:i,exports:l,locals:r}}function US(n,i){let r=i+1;const l=[];if(n[r]?.text==="{"){for(r++;n[r]&&n[r].text!=="}";){if(J0(n[r])){r++;continue}const d=Uc(n[r]);let h=d;r++,n[r]?.text==="as"&&(h=Uc(n[r+1]),r+=2),l.push({imported:d,local:h}),n[r]?.text===","&&r++}r++,_c(n[r],"from"),r++}else if(n[r]?.text==="*")_c(n[r+1],"as"),l.push({imported:"*",local:Uc(n[r+2]),namespace:!0}),r+=3,_c(n[r],"from"),r++;else throw n[r]?.kind==="string"?et("VGPU-WGSL-IMP-SIDEEFFECT","Side-effect imports are not supported",n[r].line,n[r].column):et("VGPU-WGSL-IMP-DEFAULT","Default imports are not supported",n[r]?.line,n[r]?.column);const u=n[r];if(u?.kind!=="string")throw et("VGPU-WGSL-RES-NOTFOUND","Import path must be a string",u?.line,u?.column);const f=u.text.slice(1,-1);return r++,n[r]?.text===";"&&r++,[{from:f,bindings:l,start:n[i].start,end:n[r-1].end},r]}function NS(n,i){for(;n[i]?.text==="@";){if(i+=2,n[i]?.text==="(")for(;n[i]&&n[i].text!==")";)i++;n[i]?.text===")"&&i++}return i}function LS(n,i){let r=i+1;if(n[i]?.text==="var"&&n[r]?.text==="<")for(;n[r]&&n[r].text!==">";)r++;for(;r<n.length;r++)if(n[r].kind==="ident")return n[r].text;throw et("VGPU-WGSL-EXP-NOTDECL","Exported declaration has no name",n[i]?.line,n[i]?.column)}function _c(n,i){if(n?.text!==i)throw et("VGPU-WGSL-IMP-DEFAULT",`Expected ${i}`,n?.line,n?.column)}function Uc(n){if(n?.kind!=="ident")throw et("VGPU-WGSL-IMP-DEFAULT","Expected identifier",n?.line,n?.column);return n.text}function J0(n){return n.kind==="lineComment"||n.kind==="blockComment"}function kS(n,i){return i==="uniform"||i==="storage"?"buffer":n.kind==="sampler"?"sampler":n.kind==="texture"?n.textureKind==="texture_external"?"externalTexture":"texture":"unknown"}function jS(n,i,r,l,u){if(n==="buffer")return GS(i,r,u);if(l.kind==="sampler")return BS(l);if(l.kind==="texture")return l.textureKind==="texture_external"?{kind:"externalTexture",externalTexture:{}}:l.textureKind.startsWith("texture_storage_")?$S(l):VS(l)}function GS(n,i,r){return{kind:"buffer",buffer:{type:n==="uniform"?"uniform":i==="read"?"read-only-storage":"storage",hasDynamicOffset:!1,minBindingSize:r?.size}}}function BS(n){return{kind:"sampler",sampler:{type:n.comparison?"comparison":"filtering"}}}function $S(n){return{kind:"storageTexture",storageTexture:{access:FS(n.access),format:n.texelFormat??"rgba8unorm",viewDimension:ey(n.dimension)}}}function VS(n){return{kind:"texture",texture:{sampleType:IS(n),viewDimension:ey(n.dimension),multisampled:n.dimension==="multisampled_2d"||n.dimension==="depth_multisampled_2d"}}}function IS(n){if(n.textureKind.startsWith("texture_depth_"))return"depth";const i=n.sampleType;return i?.kind==="scalar"&&i.name==="i32"?"sint":i?.kind==="scalar"&&i.name==="u32"?"uint":"unfilterable-float"}function ey(n){switch(n){case"1d":return"1d";case"2d_array":case"depth_2d_array":return"2d-array";case"cube":case"depth_cube":return"cube";case"cube_array":case"depth_cube_array":return"cube-array";case"3d":return"3d";default:return"2d"}}function FS(n){return n==="read"?"read-only":n==="read_write"?"read-write":"write-only"}const ln=(1n<<64n)-1n,Ji=11400714785074694791n,is=14029467366897019727n,Sg=1609587929392839161n,ty=9650029242287828579n,wg=2870177450012600261n;function HS(n,i=0n){const r=new TextEncoder().encode(n);let l=0,u;if(r.length>=32){let f=i+Ji+is,d=i+is,h=i,m=i-Ji;const g=r.length-32;do f=Qa(f,es(r,l)),l+=8,d=Qa(d,es(r,l)),l+=8,h=Qa(h,es(r,l)),l+=8,m=Qa(m,es(r,l)),l+=8;while(l<=g);u=Mi(f,1n)+Mi(d,7n)+Mi(h,12n)+Mi(m,18n),u=jl(u,f),u=jl(u,d),u=jl(u,h),u=jl(u,m)}else u=i+wg;for(u=u+BigInt(r.length)&ln;l+8<=r.length;)u^=Qa(0n,es(r,l)),u=Mi(u,27n)*Ji+ty&ln,l+=8;for(l+4<=r.length&&(u^=qS(r,l)*Ji&ln,u=Mi(u,23n)*is+Sg&ln,l+=4);l<r.length;)u^=BigInt(r[l])*wg&ln,u=Mi(u,11n)*Ji&ln,l++;return u^=u>>33n,u=u*is&ln,u^=u>>29n,u=u*Sg&ln,u^=u>>32n,u.toString(16).padStart(16,"0")}function Qa(n,i){return Mi(n+i*is&ln,31n)*Ji&ln}function jl(n,i){return n^=Qa(0n,i),n*Ji+ty&ln}function Mi(n,i){return(n<<i|n>>64n-i)&ln}function es(n,i){let r=0n;for(let l=7;l>=0;l--)r=(r<<8n)+BigInt(n[i+l]);return r}function qS(n,i){return BigInt(n[i])|BigInt(n[i+1])<<8n|BigInt(n[i+2])<<16n|BigInt(n[i+3])<<24n}function YS(n){return HS(n)}function XS(n){return YS(n).slice(0,8)}function QS(n,i){return`_vgsl_${XS(n)}__${i}`}function Xt(n,i){const r=n.find(f=>f.name===i);if(!r)return;const l=r.args.map(f=>f.text).join(""),u=Number(l.replace(/[ui]$/,""));return Number.isFinite(u)?u:void 0}function mf(n){const i=[[]];let r=0,l=0;for(const u of n){if(u.text==="<"?r++:u.text===">"?r=Math.max(0,r-1):u.text==="("?l++:u.text===")"&&(l=Math.max(0,l-1)),u.text===","&&r===0&&l===0){i.push([]);continue}i[i.length-1].push(u)}return i.map(ny).filter(u=>u.length>0)}function ny(n){let i=0,r=n.length;for(;i<r&&n[i].text===",";)i++;for(;r>i&&n[r-1].text===",";)r--;return n.slice(i,r)}function KS(n){if(n!==void 0&&iy(n))return Number(n.replace(/[ui]$/,""))}function iy(n){return/^(0|[1-9][0-9]*)([ui])?$/.test(n)}function ay(n){if(n==="read"||n==="write"||n==="read_write")return n}function ZS(n){return["f32","f16","i32","u32","bool"].find(i=>i===n)}function PS(n){return{kind:"scalar",name:n==="f"?"f32":n==="h"?"f16":n==="i"?"i32":"u32"}}function ry(n){return n==="f16"?2:4}function ia(n,i){return Math.ceil(i/n)*n}function En(n){const i=ny(n);if(i.length===0)throw et("VGPU-WGSL-REFLECT-TYPE","Expected WGSL type");const r=i.map(f=>f.text).join(""),l=WS(r);if(l)return l;if(i[1]?.text==="<"){const f=i[0].text,d=mf(i.slice(2,-1)),h=JS(f,d);if(h)return h}const u=ew(r);return u||tw(r)}function WS(n){const i=ZS(n);if(i)return{kind:"scalar",name:i};const r=n.match(/^vec([234])([fiuh])$/);if(r)return{kind:"vector",width:Number(r[1]),element:PS(r[2])};const l=n.match(/^mat([234])x([234])([fh])$/);if(l){const u=l[3]==="h"?{kind:"scalar",name:"f16"}:{kind:"scalar",name:"f32"};return{kind:"matrix",columns:Number(l[1]),rows:Number(l[2]),element:u}}}function JS(n,i){if(n==="array"){const r=i[1]?.map(u=>u.text).join(""),l=r===void 0?void 0:KS(r);return{kind:"array",element:En(i[0]??[]),count:l,countExpression:r}}if(n==="atomic")return{kind:"atomic",element:En(i[0]??[])};if(n==="vec2"||n==="vec3"||n==="vec4")return{kind:"vector",width:Number(n.slice(3)),element:En(i[0]??[])};if(/^mat[234]x[234]$/.test(n))return{kind:"matrix",columns:Number(n[3]),rows:Number(n[5]),element:En(i[0]??[])};if(n==="ptr")return{kind:"ptr",addressSpace:i[0]?.map(r=>r.text).join("")??"",element:En(i[1]??[]),access:i[2]?.map(r=>r.text).join("")};if(n==="sampler")return{kind:"sampler",comparison:!1};if(n.startsWith("texture_storage_"))return{kind:"texture",textureKind:n,dimension:n.slice(16),texelFormat:i[0]?.map(r=>r.text).join(""),access:ay(i[1]?.map(r=>r.text).join(""))};if(n.startsWith("texture_"))return{kind:"texture",textureKind:n,dimension:n.slice(8),sampleType:i[0]?En(i[0]):void 0}}function ew(n){if(n==="sampler"||n==="sampler_comparison")return{kind:"sampler",comparison:n==="sampler_comparison"};if(n==="texture_external")return{kind:"texture",textureKind:n};if(n.startsWith("texture_depth_"))return{kind:"texture",textureKind:n,dimension:n.slice(8)};if(n.startsWith("texture_"))return{kind:"texture",textureKind:n,dimension:n.slice(8)}}function tw(n){return{kind:"identifier",name:n}}function Ci(n){if(n?.kind!=="ident"&&n?.kind!=="keyword")throw et("VGPU-WGSL-REFLECT-PARSE","Expected identifier",n?.line,n?.column);return n.text}function aa(n,i,r){for(let l=i;l<n.length;l++)if(n[l].text===r)return l;throw et("VGPU-WGSL-REFLECT-PARSE",`Expected ${r}`,n[i]?.line,n[i]?.column)}function nw(n,i,r,l){for(let u=i;u<r;u++)if(n[u].text===l)return u}function uu(n,i,r){let l=0;for(let u=i;u<n.length;u++)if((n[u].text==="{"||n[u].text==="(")&&l++,(n[u].text==="}"||n[u].text===")")&&(l=Math.max(0,l-1)),l===0&&n[u].text===r)return u;return n.length}function gf(n,i){const r=n[i].text,l=r==="("?")":r==="{"?"}":">";let u=0;for(let f=i;f<n.length;f++)if(n[f].text===r&&u++,n[f].text===l&&(u--,u===0))return f;throw et("VGPU-WGSL-REFLECT-PARSE",`Unclosed ${r}`,n[i]?.line,n[i]?.column)}function yf(n,i){const r=[];let l=i;for(;n[l]?.text==="@";){const u=n[l],f=Ci(n[l+1]);l+=2;let d=[];if(n[l]?.text==="("){const h=gf(n,l);d=n.slice(l+1,h),l=h+1}r.push({name:f,args:d,token:u})}return[r,l]}function er(n){switch(n.kind){case"scalar":return n.name;case"identifier":return n.name;case"vector":return`vec${n.width}<${er(n.element)}>`;case"matrix":return`mat${n.columns}x${n.rows}<${er(n.element)}>`;case"array":return`array<${er(n.element)}${n.count===void 0?"":`,${n.count}`}>`;default:return n.kind}}function iw(n){const i=n.find(l=>l.name==="workgroup_size");if(!i)return;const r=mf(i.args).map(l=>Number(l.map(u=>u.text).join("")));return[r[0]??1,r[1]??1,r[2]??1]}function aw(n,i){if(n[i]?.text!=="<")return{after:i};const r=aa(n,i,">"),l=mf(n.slice(i+1,r)).map(u=>u.map(f=>f.text).join(""));return{addressSpace:l[0],access:ay(l[1]),after:r+1}}function rw(n){const i=[],r=[],l=[],u=[],f=[],d=[],h=n.tokens.filter(x=>x.kind!=="lineComment"&&x.kind!=="blockComment");let m=0,g=0;for(;m<h.length;){const x=h[m];if(x.text==="{"){g++,m++;continue}if(x.text==="}"){g=Math.max(0,g-1),m++;continue}if(g>0){m++;continue}const b=m,[D,$]=yf(h,m);m=$,h[m]?.text==="export"&&m++;const k=h[m]?.text;if(k==="enable"){h[m+1]?.kind==="ident"&&d.push(h[m+1].text),m=uu(h,m,";")+1;continue}if(k==="struct"){const N=sw(n,h,m);N.item&&i.push(N.item),m=N.next;continue}if(k==="alias"){const N=lw(n,h,m);N.item&&r.push(N.item),m=N.next;continue}if(k==="var"){const N=uw(n,h,m,D);N.item&&l.push(N.item),m=N.next;continue}if(k==="fn"){const N=ow(n,h,m,D);N.item&&u.push(N.item),m=N.next;continue}if(k==="override"){const N=fw(h,m,D);N.item&&f.push(N.item),m=N.next;continue}m=Math.max(b+1,m+1)}return{structs:i,aliases:r,vars:l,entries:u,overrides:f,features:d}}function sw(n,i,r,l){const u=Ci(i[r+1]),f=aa(i,r+2,"{"),d=gf(i,f);return{item:{name:u,originalName:u,mangledName:vf(n,u,"struct"),members:dw(i.slice(f+1,d)),path:n.path},next:d+1}}function lw(n,i,r,l){const u=Ci(i[r+1]),f=aa(i,r+2,"="),d=uu(i,f+1,";");return{item:{name:u,originalName:u,mangledName:vf(n,u,"alias"),target:En(i.slice(f+1,d)),path:n.path},next:d+1}}function uw(n,i,r,l){const{addressSpace:u,access:f,after:d}=aw(i,r+1),h=Ci(i[d]),m=aa(i,d+1,":"),g=uu(i,m+1,";");return{item:{path:n.path,name:h,mangledName:hw(l)?h:vf(n,h,"var"),attrs:l,addressSpace:u,access:f,type:En(i.slice(m+1,g))},next:g+1}}function ow(n,i,r,l){const u=Ci(i[r+1]),f=l.find(m=>m.name==="vertex"||m.name==="fragment"||m.name==="compute")?.name;if(!f)return{item:void 0,next:r+1};const d=aa(i,r+2,"("),h=gf(i,d);return{item:{name:u,mangledName:u,stage:f,workgroupSize:iw(l),path:n.path,params:cw(i.slice(d+1,h))},next:h+1}}function cw(n){const i=[];let r=0;for(;r<n.length;){const[l,u]=yf(n,r);if(r=u,!n[r]||n[r].text===","){r++;continue}const f=Ci(n[r]),d=aa(n,r+1,":");let h=d+1,m=0;for(;h<n.length&&(n[h].text==="<"&&m++,n[h].text===">"&&(m=Math.max(0,m-1)),!(m===0&&n[h].text===","));)h++;i.push({name:f,attrs:l,type:En(n.slice(d+1,h))}),r=h+1}return i}function fw(n,i,r){const l=Ci(n[i+1]),u=uu(n,i+1,";"),f=nw(n,i+2,u,"=");return{item:{name:l,mangledName:l,id:Xt(r,"id"),defaultValue:f===void 0?void 0:n.slice(f+1,u).map(d=>d.text).join("")},next:u+1}}function dw(n){const i=[];let r=0;for(;r<n.length;){const[l,u]=yf(n,r);if(r=u,!n[r]||n[r].text===","||n[r].text===";"){r++;continue}const f=Ci(n[r]),d=aa(n,r+1,":");let h=d+1,m=0;for(;h<n.length&&(n[h].text==="<"&&m++,n[h].text===">"&&(m=Math.max(0,m-1)),!(m===0&&(n[h].text===","||n[h].text===";")));)h++;i.push({name:f,attrs:l,type:En(n.slice(d+1,h)),align:Xt(l,"align"),size:Xt(l,"size")}),r=h+1}return i}function vf(n,i,r){return r==="override"?i:QS(n.path,i)}function hw(n){return Xt(n,"group")!==void 0||Xt(n,"binding")!==void 0}const pw="literal length required for auto layout; use draw.group(n, bg) manual binding",mw="VGPUError: `bool` is not host-shareable in uniform/storage. Fix: use `u32` (0 | 1) → struct Params { enabled: u32 }",sy="use a manual group claim (`draw.group(n, bg)`)";function gw(n=1,i=1){return et("VGPU-WGSL-REFLECT-ARRAY-LENGTH",pw,n,i)}function ly(n=1,i=1){return et("VGPU-WGSL-REFLECT-BOOL-HOST-SHAREABLE",mw,n,i)}function Wl(n,i,r=1,l=1){return et("VGPU-WGSL-REFLECT-UNKNOWN-TYPE",`type '${n}' is unknown in ${i}; ${sy}`,r,l)}function Eg(n,i,r=1,l=1){return et("VGPU-WGSL-REFLECT-NS-TYPE",`type '${n}' is a namespace-member import; use a named import or manual @group(1+) binding`,r,l)}function uy(n,i=1,r=1){return et("VGPU-WGSL-REFLECT-NON-HOST-SHAREABLE",`Type ${n} is not host-shareable; ${sy}`,i,r)}const ir="naga-standard";function yw(n,i,r){const l=new Map;for(const d of i){const h=new Map;for(const m of[...d.structs,...d.aliases])h.set(m.originalName,{path:m.path,name:m.originalName,mangledName:m.mangledName,kind:"members"in m?"struct":"alias"});l.set(d.structs[0]?.path??d.aliases[0]?.path??d.vars[0]?.path??"",h)}const u=new Map(n.map(d=>[d.path,l.get(d.path)??new Map])),f=new Map;for(const d of n){const h=new Map(u.get(d.path));for(const m of d.parsed.imports)vw(d,m,h,n,u);f.set(d.path,h)}return f}function vw(n,i,r,l,u,f){const d=xw(i,n.path,l),h=u.get(d);for(const m of i.bindings){if(m.namespace){r.set(m.local,{path:d,name:m.local,mangledName:m.local,kind:"namespace"});continue}const g=h?.get(m.imported);g&&r.set(m.local,g)}}function bw(n,i){const r=new Map,l=new Map,u=new Map;for(const f of n){for(const d of f.structs){const h={name:d.name,mangledName:d.mangledName,members:d.members.map(m=>({name:m.name,type:na(m.type,d.path,i),align:m.align,size:m.size}))};r.set(d.mangledName,h),u.set(d.mangledName,h)}for(const d of f.aliases){const h={name:d.name,mangledName:d.mangledName,target:na(d.target,d.path,i)};l.set(d.mangledName,h),u.set(d.mangledName,h)}}return{structs:r,aliases:l,byMangled:u}}function na(n,i,r,l){switch(n.kind){case"identifier":{const u=n.name.indexOf(".");if(u>0){const d=n.name.slice(0,u);if(r.get(i)?.get(d)?.kind==="namespace")throw Eg(n.name)}const f=r.get(i)?.get(n.name);if(f?.kind==="namespace")throw Eg(n.name);if(!f)throw Wl(n.name,i);return{kind:"identifier",name:f.name,mangledName:f.mangledName}}case"array":case"atomic":case"vector":case"matrix":case"ptr":return{...n,element:na(n.element,i,r)};case"texture":return{...n,sampleType:n.sampleType?na(n.sampleType,i,r):void 0};default:return n}}function ar(n,i){if(!i||n.kind!=="identifier")return n;const r=i.aliases.get(n.mangledName??n.name);return r?ar(r.target,i):n}function Wc(n,i){const r=ar(n,i);switch(r.kind){case"array":case"atomic":case"vector":case"matrix":case"ptr":return{...r,element:Wc(r.element,i)};case"texture":return{...r,sampleType:r.sampleType?Wc(r.sampleType,i):void 0};default:return r}}function xw(n,i,r,l){const u=void 0;if(u!==void 0&&r.some(g=>g.path===u))return u;const f=n.from,d=i.slice(0,i.lastIndexOf("/")+1),h=f.startsWith("/")?f:Sw(`${d}${f}`);return[f,h].find(g=>r.some(x=>x.path===g))??u??h}function Sw(n){const i=n.startsWith("/"),r=[];for(const l of n.split("/"))!l||l==="."||(l===".."?r.pop():r.push(l));return`${i?"/":""}${r.join("/")}`}function hs(n,i,r=er(n),l=r,u){const f=u?Wc(n,u):n;return ww(f,i,r,l,u)}function ww(n,i,r,l,u){switch(n.kind){case"scalar":return Ew(n,i,r,l);case"atomic":return Aw(n,i,r,l);case"vector":return Tw(n,i,r,l,u);case"matrix":return Mw(n,i,r,l,u);case"array":return Dw(n,i,r,l,u);case"identifier":return Cw(n,i,r,l,u);default:throw uy(er(n))}}function Ew(n,i,r,l){const u=ry(n.name);if(n.name==="bool")throw ly();return{name:r,mangledName:l,addressSpace:i,layoutMode:ir,type:n,align:u,size:u}}function Aw(n,i,r,l){return{name:r,mangledName:l,addressSpace:i,layoutMode:ir,type:n,align:4,size:4}}function Tw(n,i,r,l,u){const d=hs(n.element,i,r,l,u).size??4,h=n.width===2?d*2:d*4;return{name:r,mangledName:l,addressSpace:i,layoutMode:ir,type:n,align:h,size:d*n.width}}function Mw(n,i,r,l,u){const f={kind:"vector",width:n.rows,element:n.element},d=hs(f,i,`${r}[]`,`${l}[]`,u),h=ia(d.align,d.size??0);return{name:r,mangledName:l,addressSpace:i,layoutMode:ir,type:n,align:d.align,size:h*n.columns,stride:h,element:d}}function Dw(n,i,r,l,u){Rw(n.countExpression);const f=hs(n.element,i,`${r}[]`,`${l}[]`,u),d=ia(os(n.element,i,u),f.size??0);return{name:r,mangledName:l,addressSpace:i,layoutMode:ir,type:n,align:os(n,i,u),size:n.count===void 0?void 0:d*n.count,stride:d,element:f,runtimeSized:n.count===void 0}}function Rw(n){if(n!==void 0&&!iy(n))throw gw()}function Cw(n,i,r,l,u){if(!u)throw Wl(n.name,"<unknown>");const f=u.structs.get(n.mangledName??n.name);if(!f)throw Wl(n.name,"<unknown>");const d=[];let h=0,m=1;for(const x of f.members){const b=Ow(x,i,h,u);d.push(b.member),h=zw(i,x.type,b.offset,b.member.size??0,u),m=Math.max(m,b.member.align)}const g=Uw(i,m);return{name:r,mangledName:l,addressSpace:i,layoutMode:ir,type:n,align:g,size:ia(g,h),members:d}}function Ow(n,i,r,l){const u=hs(n.type,i,n.name,n.name,l),f=Math.max(os(n.type,i,l),n.align??1),d=Math.max(u.size??0,n.size??0),h=ia(f,r);return{member:{name:n.name,offset:h,align:f,size:d,type:n.type,layout:u,explicitAlign:n.align,explicitSize:n.size},offset:h}}function zw(n,i,r,l,u){return r+(n==="uniform"&&_w(i,u)?ia(16,l):l)}function _w(n,i){const r=ar(n,i);return r.kind==="identifier"&&i.structs.has(r.mangledName??r.name)}function Uw(n,i){return n==="uniform"?ia(16,i):i}function os(n,i,r){const l=r?ar(n,r):n,u=ql(l,i,r);return i==="uniform"&&Nw(l,r)?ia(16,u):u}function Nw(n,i){return n.kind==="array"||n.kind==="identifier"&&!!i?.structs.get(n.mangledName??n.name)}function ql(n,i,r){const l=r?ar(n,r):n;switch(l.kind){case"scalar":return Lw(l.name);case"atomic":return 4;case"vector":return l.width===2?ql(l.element,i,r)*2:ql(l.element,i,r)*4;case"matrix":return ql({kind:"vector",width:l.rows,element:l.element},i,r);case"array":return os(l.element,i,r);case"identifier":return kw(l,i,r);default:throw uy(er(l))}}function Lw(n){if(n==="bool")throw ly();return ry(n)}function kw(n,i,r){const l=r?.structs.get(n.mangledName??n.name);if(!l)throw Wl(n.name,"<unknown>");return Math.max(1,...l.members.map(u=>Math.max(os(u.type,i,r),u.align??1)))}const jw=new Set(["alias","break","case","const","const_assert","continue","continuing","default","diagnostic","discard","else","enable","false","fn","for","if","let","loop","override","requires","return","struct","switch","true","var","while"]),Gw=new Set(["import","export","from","as"]),oy=new Set([...jw,...Gw]),Bw=new Set(["NULL","Self","abstract","active","alignas","alignof","as","asm","asm_fragment","async","attribute","auto","await","become","cast","catch","class","co_await","co_return","co_yield","coherent","column_major","common","compile","compile_fragment","concept","const_cast","consteval","constexpr","constinit","crate","debugger","decltype","delete","demote","demote_to_helper","do","dynamic_cast","enum","explicit","export","extends","extern","external","fallthrough","filter","final","finally","friend","from","fxgroup","get","goto","groupshared","highp","impl","implements","import","inline","instanceof","interface","layout","lowp","macro","macro_rules","match","mediump","meta","mod","module","move","mut","mutable","namespace","new","nil","noexcept","noinline","nointerpolation","non_coherent","noncoherent","noperspective","null","nullptr","of","operator","package","packoffset","partition","pass","patch","pixelfragment","precise","precision","premerge","priv","protected","pub","public","readonly","ref","regardless","register","reinterpret_cast","require","resource","restrict","self","set","shared","sizeof","smooth","snorm","static","static_assert","static_cast","std","subroutine","super","target","template","this","thread_local","throw","trait","try","type","typedef","typeid","typename","typeof","union","unless","unorm","unsafe","unsized","use","using","varying","virtual","volatile","wgsl","where","with","writeonly","yield"]),$w=new Set(["binding_array"]),Vw=new Set(["array","atomic","bool","f16","f32","i32","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","ptr","sampler","sampler_comparison","texture_1d","texture_2d","texture_2d_array","texture_3d","texture_cube","texture_cube_array","texture_depth_2d","texture_depth_2d_array","texture_depth_cube","texture_depth_cube_array","texture_depth_multisampled_2d","texture_external","texture_multisampled_2d","texture_storage_1d","texture_storage_2d","texture_storage_2d_array","texture_storage_3d","u32","vec2","vec2f","vec2h","vec2i","vec2u","vec3","vec3f","vec3h","vec3i","vec3u","vec4","vec4f","vec4h","vec4i","vec4u"]),Iw=new Set(["abs","acos","acosh","all","any","arrayLength","asin","asinh","atan","atan2","atanh","ceil","clamp","cos","cosh","countLeadingZeros","countOneBits","countTrailingZeros","cross","degrees","determinant","distance","dot","dot4I8Packed","dot4U8Packed","dpdx","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","exp","exp2","extractBits","faceForward","firstLeadingBit","firstTrailingBit","floor","fma","fract","frexp","fwidth","fwidthCoarse","fwidthFine","insertBits","inverseSqrt","ldexp","length","log","log2","max","min","mix","modf","normalize","pack2x16float","pack2x16snorm","pack2x16unorm","pack4x8snorm","pack4x8unorm","pack4xI8","pack4xU8","pack4xI8Clamp","pack4xU8Clamp","pow","quantizeToF16","radians","reflect","refract","reverseBits","round","saturate","select","sign","sin","sinh","smoothstep","sqrt","step","storageBarrier","tan","tanh","textureBarrier","textureDimensions","textureGather","textureGatherCompare","textureLoad","textureNumLayers","textureNumLevels","textureNumSamples","textureSample","textureSampleBaseClampToEdge","textureSampleBias","textureSampleCompare","textureSampleCompareLevel","textureSampleGrad","textureSampleLevel","textureStore","transpose","trunc","unpack2x16float","unpack2x16snorm","unpack2x16unorm","unpack4x8snorm","unpack4x8unorm","unpack4xI8","unpack4xU8","workgroupBarrier"]),Fw=new Set(["frag_depth","front_facing","global_invocation_id","instance_index","local_invocation_id","local_invocation_index","num_workgroups","position","sample_index","sample_mask","subgroup_invocation_id","subgroup_size","vertex_index","workgroup_id"]),Hw=new Set(["align","binding","blend_src","builtin","compute","diagnostic","fragment","group","id","interpolate","invariant","location","must_use","size","vertex","workgroup_size"]),qw=new Set(["function","private","storage","uniform","workgroup"]),Yw=new Set(["read","read_write","write"]),Xw=new Set(["bgra8unorm","r32float","r32sint","r32uint","rg32float","rg32sint","rg32uint","rgba16float","rgba16sint","rgba16uint","rgba32float","rgba32sint","rgba32uint","rgba8sint","rgba8snorm","rgba8uint","rgba8unorm"]);[...oy,...Bw,...$w,...Vw,...Iw,...Fw,...Hw,...qw,...Yw,...Xw];const Qw="VGPU-WGSL-IDENT-NONASCII",Kw="https://github.com/vercel-labs/vgpu/issues/294";function Zw(n,i){const r=[];let l=0,u=1,f=1;const d=(m,g,x,b,D)=>r.push({kind:m,text:n.slice(g,x),start:g,end:x,line:b,column:D}),h=()=>{n[l]===`
|
|
10
|
+
`?(u++,f=1):f++,l++};for(;l<n.length;){const m=n[l];if(/\s/.test(m)){h();continue}const g=l,x=u,b=f;if(m==="/"&&n[l+1]==="/"){for(;l<n.length&&n[l]!==`
|
|
11
|
+
`;)h();d("lineComment",g,l,x,b);continue}if(m==="/"&&n[l+1]==="*"){let D=0;for(;l<n.length;){if(n[l]==="/"&&n[l+1]==="*"){D++,h(),h();continue}if(n[l]==="*"&&n[l+1]==="/"){if(D--,h(),h(),D===0){d("blockComment",g,l,x,b);break}continue}h()}if(D!==0)throw et("VGPU-WGSL-LEX-UNTERM-COMMENT","Unterminated block comment",x,b);continue}if(m==='"'||m==="'"){const D=m;for(h();l<n.length&&n[l]!==D;){if(n[l]===`
|
|
12
|
+
`)throw et("VGPU-WGSL-LEX-UNTERM-STRING","Unterminated string",x,b);n[l]==="\\"&&h(),h()}if(l>=n.length)throw et("VGPU-WGSL-LEX-UNTERM-STRING","Unterminated string",x,b);h(),d("string",g,l,x,b);continue}if(/[A-Za-z_]/.test(m)){for(;l<n.length&&/[A-Za-z0-9_]/.test(n[l]);)h();const D=n.slice(g,l);d(oy.has(D)?"keyword":"ident",g,l,x,b);continue}if(/[0-9]/.test(m)||m==="."&&/[0-9]/.test(n[l+1]??"")){for(m==="."&&h();l<n.length;){const D=n[l];if(/[A-Za-z0-9_.]/.test(D)){h();continue}if((D==="+"||D==="-")&&Ww(n[l-1])&&/[0-9]/.test(n[l+1]??"")){h();continue}break}d("number",g,l,x,b);continue}if(m.charCodeAt(0)>127)throw Pw(n,l,u,f,i);h(),d("punct",g,l,x,b)}return r}function Pw(n,i,r,l,u){let f=i;for(;f>0&&Ag(n[f-1]);)f--;let d=i+1;for(;d<n.length&&Ag(n[d]);)d++;const h=n.slice(f,d),m=l-(i-f),g=u===void 0?"":` in ${u}`,x=OS(Qw,`Non-ASCII identifier '${h}'${g} at line ${r} column ${m}; vgpu's WGSL pipeline supports ASCII identifiers only`,{fix:`Rename '${h}' using ASCII letters, digits and '_'. Unicode (XID) identifiers are tracked in ${Kw}`,line:r,column:m});return x.range={file:u,start:{line:r,column:m}},x}function Ag(n){return n.charCodeAt(0)>127||/[A-Za-z0-9_]/.test(n)}function Ww(n){return n==="e"||n==="E"||n==="p"||n==="P"}const Jw=/^_vgsl_[0-9a-f]{8,16}__[A-Za-z_][A-Za-z0-9_]*$/,e2=new Set(["fn","struct","const","alias","var","override"]);function cy(n){return new t2(n).analyze()}class t2{tokens;scopes=[];declarations=[];references=[];functions=[];preserved=new Map;symbolsByScope=new Map;moduleFallbackReasons=[];pendingSymbols=[];moduleScopeId;constructor(i){this.tokens=i,this.moduleScopeId=this.createScope("module",void 0,void 0,0)}analyze(){this.collectTopLevel();for(const i of this.functions)this.walkFunction(i);return{tokens:this.tokens,scopes:this.scopes,declarations:this.declarations,references:this.references,functions:this.functions,preservedTokens:[...this.preserved.entries()].map(([i,r])=>({tokenIndex:i,reason:r})),fallback:{wholeModule:this.moduleFallbackReasons.length>0,reasons:this.moduleFallbackReasons}}}collectTopLevel(){let i=0;for(let r=0;r<this.tokens.length;r++){const l=this.tokens[r];if(!Qn(l)){if(l.text==="{"){i++;continue}if(l.text==="}"){i--,i<0&&(this.moduleFallback("unmatched top-level closing brace",r),i=0);continue}if(i===0){if(l.text==="@"){r=this.preserveAttribute(r);continue}if(l.text==="enable"||l.text==="requires"||l.text==="diagnostic"||l.text==="const_assert"){r=this.preserveStatement(r,"directive");continue}if(l.text!=="export"){if(l.text==="struct"){r=this.collectStruct(r);continue}if(l.text==="fn"){r=this.collectFunction(r);continue}if(l.text==="const"||l.text==="alias"||l.text==="var"||l.text==="override"){r=this.preserveGlobalDeclaration(r);continue}l.kind==="keyword"&&!e2.has(l.text)&&this.moduleFallback(`unexpected top-level keyword '${l.text}'`,r)}}}}i!==0&&this.moduleFallback("unclosed top-level brace",this.tokens.length-1),this.scopes[this.moduleScopeId].endToken=Math.max(0,this.tokens.length-1)}collectStruct(i){const r=this.nextSig(i);if(r===void 0||this.tokens[r]?.kind!=="ident")return this.moduleFallback("struct without name",i),i;this.preserveToken(r,"global");const l=this.nextSig(r);if(l===void 0||this.tokens[l]?.text!=="{")return this.moduleFallback("struct without body",i),r;const u=this.findMatching(l,"{","}");if(u===void 0)return this.moduleFallback("unclosed struct body",l),l;for(let f=l;f<=u;f++)this.tokens[f]?.kind==="ident"&&this.preserveToken(f,"struct");return u}collectFunction(i){const r=this.nextSig(i);if(r===void 0||this.tokens[r]?.kind!=="ident")return this.moduleFallback("function without name",i),i;const l=this.tokens[r].text,u=Jw.test(l)&&!this.hasEntryAttributeBefore(i);this.addDeclaration(l,"function",r,this.moduleScopeId,void 0,u),u||this.preserveToken(r,"global");const f=this.nextSig(r);if(f===void 0||this.tokens[f]?.text!=="(")return this.moduleFallback("function without parameter list",r),r;const d=this.findMatching(f,"(",")");if(d===void 0)return this.moduleFallback("unclosed function parameter list",f),f;const h=this.findNextText(d+1,"{");if(h===void 0)return this.moduleFallback("function without body",d),d;this.preserveFunctionSignatureTail(d+1,h);const m=this.findMatching(h,"{","}");if(m===void 0)return this.moduleFallback("unclosed function body",h),h;const g=this.createScope("function",this.moduleScopeId,this.functions.length,f);return this.functions.push({id:this.functions.length,name:l,nameTokenIndex:r,scopeId:g,bodyStartToken:h,bodyEndToken:m,skipped:!1,fallbackReasons:[]}),this.collectParams(f,d,g,this.functions.length-1),this.scopes[g].endToken=m,m}collectParams(i,r,l,u){for(let f=i+1;f<r;f++){const d=this.tokens[f];if(!Qn(d)){if(d.text==="@"){f=this.preserveAttribute(f);continue}if(d.kind==="ident"&&this.nextSig(f)!==void 0&&this.tokens[this.nextSig(f)]?.text===":"){this.addDeclaration(d.text,"param",f,l,u,!0);const h=this.nextSig(f);f=this.preserveTypeFrom(h+1,[",",")"],r)}}}}preserveFunctionSignatureTail(i,r){for(let l=i;l<r;l++){const u=this.tokens[l];if(!Qn(u)){if(u.text==="@"){l=this.preserveAttribute(l);continue}u.kind==="ident"&&this.preserveToken(l,"type")}}}preserveGlobalDeclaration(i){let r=i+1;if(this.tokens[i]?.text==="var"){const f=this.nextSig(i);if(f!==void 0&&this.tokens[f]?.text==="<"){const d=this.findMatching(f,"<",">");if(d===void 0)return this.moduleFallback("unparseable top-level var template",f),f;this.preserveRange(f,d,"type"),r=d+1}}const l=this.findNextIdent(r);l!==void 0&&(this.preserveToken(l,"global"),this.addDeclaration(this.tokens[l].text,"global",l,this.moduleScopeId,void 0,!1));const u=this.findStatementEnd(i);for(let f=i;f<=u;f++)this.tokens[f]?.kind==="ident"&&this.preserveToken(f,"global");return u}walkFunction(i){const r=[this.moduleScopeId,i.scopeId],l=[],u=(h,m)=>{const g=this.createScope(h,r[r.length-1],i.id,m);return r.push(g),g},f=h=>{if(r.length<=2){this.functionFallback(i,"scope frame underflow",h);return}const m=r.pop();return this.scopes[m].endToken=h,m};u("block",i.bodyStartToken);let d=1;for(let h=i.bodyStartToken+1;h<i.bodyEndToken;h++){this.activatePendingSymbols(h);const m=this.tokens[h];if(Qn(m))continue;if(m.text==="@"){h=this.preserveAttribute(h);continue}if(m.text==="."){const x=this.nextSig(h);x!==void 0&&this.tokens[x]?.kind==="ident"&&this.preserveToken(x,"member");continue}if(m.text==="enable"||m.text==="requires"||m.text==="diagnostic"){h=this.preserveStatement(h,"directive");continue}if(m.text==="for"){const x=u("for-init",h),b=this.nextSig(h);(b===void 0||this.tokens[b]?.text!=="(")&&this.functionFallback(i,"for without parenthesized header",h),l.push({scopeId:x,headerDepth:0,awaitingBody:!1});continue}const g=l[l.length-1];if(g&&g.bodyDepth===void 0&&(m.text==="("&&g.headerDepth++,m.text===")"&&(g.headerDepth--,g.headerDepth<=0&&(g.awaitingBody=!0))),m.text==="{"){d++;const x=n2(l,b=>b.awaitingBody&&b.bodyDepth===void 0);x&&(x.bodyDepth=d),u("block",h);continue}if(m.text==="}"){const x=d;for(f(h),d--;l.length>0&&l[l.length-1].bodyDepth===x;)f(h),l.pop();d<0&&this.functionFallback(i,"unmatched closing brace",h);continue}if(m.text===":"){h=this.preserveTypeFrom(h+1,["=",";",",",")","{"],i.bodyEndToken);continue}if(m.text==="-"&&this.tokens[this.nextSig(h)??-1]?.text===">"){h=this.preserveTypeFrom((this.nextSig(h)??h)+1,["{"],i.bodyEndToken);continue}if(m.text==="let"||m.text==="const"||m.text==="var"){h=this.collectLocalDeclaration(h,r[r.length-1],i);continue}if(m.kind==="ident"&&!this.preserved.has(h)){const x=this.resolve(m.text,r);x!==void 0?this.references.push({name:m.text,tokenIndex:h,declarationId:x,scopeId:r[r.length-1],functionId:i.id}):this.preserveToken(h,"unknown")}}for(;r.length>2;)f(i.bodyEndToken)}collectLocalDeclaration(i,r,l){const u=this.tokens[i].text;let f=i+1;if(u==="var"){const m=this.nextSig(i);if(m!==void 0&&this.tokens[m]?.text==="<"){const g=this.findMatching(m,"<",">");if(g===void 0)return this.functionFallback(l,"unparseable var template",m),m;this.preserveRange(m,g,"type"),f=g+1}}const d=this.findNextIdent(f);if(d===void 0||d>=l.bodyEndToken)return this.functionFallback(l,`${u} without identifier`,i),i;this.addDeclaration(this.tokens[d].text,u,d,r,l.id,!0,this.findStatementEnd(i));const h=this.nextSig(d);return h!==void 0&&this.tokens[h]?.text===":"?this.preserveTypeFrom(h+1,["=",";",",",")"],l.bodyEndToken):d}addDeclaration(i,r,l,u,f,d,h){const m=this.declarations.length;return this.declarations.push({id:m,name:i,kind:r,tokenIndex:l,scopeId:u,functionId:f,safeToRename:d}),h!==void 0?this.pendingSymbols.push({name:i,id:m,scopeId:u,activateAfter:h}):this.activateSymbol(i,m,u),m}activatePendingSymbols(i){for(let r=this.pendingSymbols.length-1;r>=0;r--){const l=this.pendingSymbols[r];l.activateAfter>=i||(this.activateSymbol(l.name,l.id,l.scopeId),this.pendingSymbols.splice(r,1))}}activateSymbol(i,r,l){let u=this.symbolsByScope.get(l);u||(u=new Map,this.symbolsByScope.set(l,u)),u.has(i)||u.set(i,r)}resolve(i,r){for(let l=r.length-1;l>=0;l--){const u=this.symbolsByScope.get(r[l])?.get(i);if(u!==void 0)return u}}preserveAttribute(i){this.preserveToken(i,"attribute");const r=this.nextSig(i);if(r===void 0)return i;this.preserveToken(r,"attribute");const l=this.nextSig(r);if(l===void 0||this.tokens[l]?.text!=="(")return r;const u=this.findMatching(l,"(",")");return u===void 0?(this.preserveRange(l,l,"attribute"),l):(this.preserveRange(l,u,"attribute"),u)}preserveTypeFrom(i,r,l){let u=0,f=0,d=0,h=i-1;for(let m=i;m<l;m++){const g=this.tokens[m];if(!Qn(g)){if(u===0&&f===0&&d===0&&r.includes(g.text))return Math.max(i-1,m-1);if(g.text==="<")u++;else if(g.text===">")u=Math.max(0,u-1);else if(g.text==="(")f++;else if(g.text===")"){if(f===0&&r.includes(")"))return Math.max(i-1,m-1);f=Math.max(0,f-1)}else g.text==="["?d++:g.text==="]"&&(d=Math.max(0,d-1));g.kind==="ident"&&this.preserveToken(m,"type"),h=m}}return h}preserveStatement(i,r){const l=this.findStatementEnd(i);return this.preserveRange(i,l,r),l}preserveRange(i,r,l){for(let u=i;u<=r;u++)this.tokens[u]&&this.tokens[u].kind!=="lineComment"&&this.tokens[u].kind!=="blockComment"&&this.preserveToken(u,l)}preserveToken(i,r){this.preserved.has(i)||this.preserved.set(i,r)}createScope(i,r,l,u){const f=this.scopes.length;return this.scopes.push({id:f,kind:i,parentId:r,functionId:l,startToken:u}),f}nextSig(i){for(let r=i+1;r<this.tokens.length;r++)if(!Qn(this.tokens[r]))return r}findNextIdent(i){for(let r=i;r<this.tokens.length;r++){const l=this.tokens[r];if(!Qn(l)){if(l.kind==="ident")return r;if(l.text!=="@")return}}}findNextText(i,r){for(let l=i;l<this.tokens.length;l++)if(!Qn(this.tokens[l])&&this.tokens[l].text===r)return l}findStatementEnd(i){let r=0;for(let l=i;l<this.tokens.length;l++){const u=this.tokens[l].text;if(u==="(")r++;else if(u===")")r=Math.max(0,r-1);else if(r===0&&(u===";"||u==="{"||u==="}"))return l}return this.tokens.length-1}findMatching(i,r,l){let u=0;for(let f=i;f<this.tokens.length;f++){const d=this.tokens[f].text;if(d===r&&u++,d===l&&(u--,u===0))return f}}hasEntryAttributeBefore(i){for(let r=i-1;r>=0;r--){const l=this.tokens[r];if(!Qn(l)){if(l.text===")"||l.kind==="ident"||l.text==="@"){const u=l.text;if(u==="compute"||u==="vertex"||u==="fragment")return!0;continue}break}}return!1}moduleFallback(i,r){this.moduleFallbackReasons.push(`${i} at token ${r}`)}functionFallback(i,r,l){i.skipped=!0,i.fallbackReasons.push(`${r} at token ${l}`)}}function n2(n,i){for(let r=n.length-1;r>=0;r--)if(i(n[r]))return n[r]}function Qn(n){return n.kind==="lineComment"||n.kind==="blockComment"}const i2=new Set(["textureSample","textureSampleBias","textureSampleLevel","textureSampleGrad","textureGather","textureSampleBaseClampToEdge"]),a2=new Set(["textureSampleCompare","textureSampleCompareLevel","textureGatherCompare"]);function r2(n,i,r){const l=new Map;for(let u=0;u<n.length;u++){const f=n[u],d=i[u],h=cy(f.tokens),m=new Map;for(const x of d.vars){const b=Xt(x.attrs,"group"),D=Xt(x.attrs,"binding"),$=h.declarations.find(k=>k.kind==="global"&&k.name===x.name);b!==void 0&&D!==void 0&&$&&m.set($.id,{group:b,binding:D})}const g=new Map;for(const x of h.declarations){if(x.kind!=="function")continue;const b=h.functions.find(D=>D.nameTokenIndex===x.tokenIndex);b&&g.set(x.id,b.id)}for(const x of d.entries){const b=h.functions.find(N=>N.name===x.name),D=[];let $=h.fallback.wholeModule||!b;!$&&b&&($=!fy(b.id,new Map,new Set,h,m,g,D));const k=b?c2(b.id,h,m,g):r.map(Jc);l.set(x,$?f2(r,k):d2(D))}}return l}function fy(n,i,r,l,u,f,d){const h=l.functions[n];if(!h||h.skipped)return!1;const m=`${n}|${[...i].map(([b,D])=>`${b}:${D.group}:${D.binding}`).join(",")}`;if(r.has(m))return!0;r.add(m);const g=l.references.filter(b=>b.functionId===n),x=new Map(g.map(b=>[b.tokenIndex,b]));for(let b=h.bodyStartToken+1;b<h.bodyEndToken;b++){const D=l.tokens[b]?.text,$=i2.has(D??"")?"filtering":a2.has(D??"")?"comparison":void 0,k=x.get(b),N=k&&f.get(k.declarationId);if(!$&&N===void 0)continue;const V=o2(l,b);if(V===void 0||l.tokens[V]?.text!=="(")continue;const Z=u2(l,V);if(!Z)return!1;const I=Z.map(([F,Y])=>s2(F,Y,l,u,i));if($){const F=D==="textureGather"&&!l2(Z[0],l,u,i)?1:0,Y=I[F],P=I[F+1];if(!Y||!P)return!1;d.push({texture:Y,sampler:P,mode:$})}else{const F=l.declarations.filter(P=>P.kind==="param"&&P.functionId===N).sort((P,he)=>P.tokenIndex-he.tokenIndex),Y=new Map;for(let P=0;P<F.length;P++)I[P]&&Y.set(F[P].id,I[P]);if(!fy(N,Y,r,l,u,f,d))return!1}}return!0}function s2(n,i,r,l,u){for(const f of r.references){if(f.tokenIndex<n||f.tokenIndex>i)continue;const d=l.get(f.declarationId)??u.get(f.declarationId);if(d)return d}}function l2(n,i,r,l){const u=i.references.find(f=>f.tokenIndex>=n[0]&&f.tokenIndex<=n[1]);return u?.tokenIndex===n[0]?r.get(u.declarationId)??l.get(u.declarationId):void 0}function u2(n,i){const r=[];let l=1,u=0,f=0,d=0,h=i+1;for(let m=i+1;m<n.tokens.length;m++){const g=n.tokens[m].text;if(g==="(")l++;else if(g===")"){if(l--,l===0)return r.push([h,m-1]),r}else g==="["?u++:g==="]"?u--:g==="{"?f++:g==="}"?f--:g==="<"?d++:g===">"?d--:g===","&&l===1&&u===0&&f===0&&d===0&&(r.push([h,m-1]),h=m+1)}}function o2(n,i){for(let r=i+1;r<n.tokens.length;r++)if(n.tokens[r].kind!=="lineComment"&&n.tokens[r].kind!=="blockComment")return r}function c2(n,i,r,l){const u=[n],f=new Set,d=new Map;for(;u.length;){const h=u.pop();if(!f.has(h)){f.add(h);for(const m of i.references){if(m.functionId!==h)continue;const g=r.get(m.declarationId);g&&d.set(`${g.group}:${g.binding}`,g);const x=l.get(m.declarationId);x!==void 0&&u.push(x)}}}return[...d.values()]}function f2(n,i){const r=new Set(i.map(d=>`${d.group}:${d.binding}`)),l=n.filter(d=>r.has(`${d.group}:${d.binding}`)),u=l.filter(d=>d.bindingLayout?.kind==="texture"&&d.bindingLayout.texture.sampleType==="unfilterable-float"&&!d.bindingLayout.texture.multisampled),f=l.filter(d=>d.bindingLayout?.kind==="sampler"&&d.bindingLayout.sampler.type==="filtering");return u.flatMap(d=>f.map(h=>({texture:Jc(d),sampler:Jc(h),mode:"filtering"})))}function Jc(n){return{group:n.group,binding:n.binding}}function d2(n){const i=new Set;return n.filter(r=>{const l=`${r.texture.group}:${r.texture.binding}:${r.sampler.group}:${r.sampler.binding}:${r.mode}`;return i.has(l)?!1:(i.add(l),!0)})}function h2(n,i){const r=n.map(rw),l=yw(n,r),u=bw(r,l),f=[],d=[];for(const g of r)for(const x of g.vars){const b=Xt(x.attrs,"group"),D=Xt(x.attrs,"binding");if(b===void 0||D===void 0)continue;const $=na(x.type,x.path,l),k=kS($,x.addressSpace),N=x.addressSpace==="uniform"||x.addressSpace==="storage"?hs($,x.addressSpace,x.name,x.mangledName,u):void 0;N&&d.push(N),f.push({group:b,binding:D,name:x.name,mangledName:x.mangledName,type:$,kind:k,addressSpace:x.addressSpace,access:x.access,struct:$.kind==="identifier"?u.structs.get($.mangledName??$.name):void 0,layout:N,bindingLayout:jS(k,x.addressSpace,x.access,$,N)})}f.sort((g,x)=>g.group-x.group||g.binding-x.binding);const h=p2(n,r,f),m=r2(n,r,f);return{bindings:f,entryPoints:r.flatMap(g=>g.entries.map(x=>m2(x,r.flatMap(b=>b.structs),l,u,h.get(x)??f,m.get(x)??[]))),overrides:r.flatMap(g=>g.overrides),featuresRequired:[...new Set(r.flatMap(g=>g.features))],aliases:[...u.aliases.values()],structs:[...u.structs.values()],hostShareableLayouts:d}}function p2(n,i,r){const l=new Map;for(let u=0;u<n.length;u++){const f=n[u],d=i[u],h=cy(f.tokens),m=h.fallback.wholeModule,g=new Map;for(const b of h.declarations){if(b.kind!=="function")continue;const D=h.functions.find($=>$.nameTokenIndex===b.tokenIndex);D&&g.set(b.id,D.id)}const x=new Map;for(const b of d.vars){const D=Xt(b.attrs,"group"),$=Xt(b.attrs,"binding");if(D===void 0||$===void 0)continue;const k=h.declarations.find(N=>N.kind==="global"&&N.name===b.name);k&&x.set(k.id,{group:D,binding:$})}for(const b of d.entries){const D=h.functions.find(V=>V.name===b.name);if(m||!D){l.set(b,r);continue}const $=[D.id],k=new Set,N=new Map;for(;$.length;){const V=$.pop();if(!k.has(V)&&(k.add(V),!!h.functions[V]))for(const Z of h.references){if(Z.functionId!==V)continue;const I=x.get(Z.declarationId);I&&N.set(`${I.group}:${I.binding}`,I);const F=g.get(Z.declarationId);F!==void 0&&$.push(F)}}l.set(b,[...N.values()].sort((V,Z)=>V.group-Z.group||V.binding-Z.binding))}}return l}function m2(n,i,r,l,u,f){return{name:n.name,mangledName:n.mangledName,stage:n.stage,...n.workgroupSize?{workgroupSize:n.workgroupSize}:{},bindings:u.map(({group:d,binding:h})=>({group:d,binding:h})),samplingPairs:f,...n.stage==="vertex"?{inputs:g2(n,i,r,l)}:{}}}function g2(n,i,r,l){const u=[];for(const f of n.params){if(Tg(f.attrs,"builtin"))continue;const d=na(f.type,n.path,r),h=Xt(f.attrs,"location");if(h!==void 0){u.push({name:f.name,location:h,type:d});continue}const m=ar(d,l);if(m.kind!=="identifier")continue;const g=i.find(b=>b.mangledName===(m.mangledName??m.name)),x=l.structs.get(m.mangledName??m.name);if(g)for(let b=0;b<g.members.length;b++){const D=g.members[b];if(Tg(D.attrs,"builtin"))continue;const $=Xt(D.attrs,"location");$!==void 0&&u.push({name:D.name,location:$,type:x?.members[b]?.type??na(D.type,g.path,r)})}}return u}function Tg(n,i){return n.some(r=>r.name===i)}function dy(n,i="<runtime>"){const r=Zw(n,i),l=_S(r);if(l.imports.length>0)throw et("VGPU-WGSL-REFLECT-SOURCE-IMPORT","reflectSource() accepts a single raw WGSL string; use resolveShader() for WGSL import graphs.");return h2([{path:i,source:n,tokens:r,parsed:l}])}function hy(){const n=new Map;return{getOrCreate(i,r,l,u){const f=l.map(ef),d=`${i}:${r}:${f.join("|")}`,h=n.get(d);if(h)return h.bindGroup;const m=u();return n.set(d,{identities:f,bindGroup:m}),m},evictIdentity(i){const r=ef(i);for(const[l,u]of n)u.identities.includes(r)&&n.delete(l)},clearDraw(i){const r=`${i}:`;for(const l of n.keys())l.startsWith(r)&&n.delete(l)},dispose(){n.clear()}}}function ef(n){return typeof n=="string"||typeof n=="number"?String(n):`${n.kind}:${n.id}`}function Jl(n,i,r){const l=n[i];if(!l)throw new ie({code:"VGPU-REFLECT-ENTRY-METADATA-MISSING",message:`Entry point '${n.name}' has no reflected ${i}.`,fix:"Pass the reflection from reflectSource()/resolveShader().",where:r});return l}const eu=new WeakMap;function ls(n,i){if(!n.gpu.pushErrorScope||!n.gpu.popErrorScope)return;n.gpu.pushErrorScope("validation");const r=eu.get(n.gpu);r?r.push(i):eu.set(n.gpu,[i])}function on(n){const i=eu.get(n.gpu);if(!i?.length||!n.gpu.popErrorScope)return;const r=i.pop();return i.length||eu.delete(n.gpu),{context:r,error:n.gpu.popErrorScope()}}function py(n){const i=[];let r=on(n);for(;r;)i.push(r),r=on(n);return i}function y2(n){const i=on(n);i&&xf(i)}function my(n){for(const i of py(n))xf(i)}function Ht(n){for(const i of n)xf(i)}function bf(n){return n.gpu.queue.onSubmittedWorkDone?.()??Promise.resolve()}function gy(n,i=[],r={}){return b2(n,i,r.errorSink??x2)}function tu(n,i){return{context:n.context,error:v2(n.error,i.error)}}async function v2(n,i){const r=await Promise.allSettled([n,i]);for(const u of r)if(u.status==="fulfilled"&&u.value)return u.value;const l=r.find(u=>u.status==="rejected");if(l?.status==="rejected")throw l.reason;return null}async function b2(n,i,r){await bf(n);for(const l of i)try{const u=await l.error;u&&await r(tr(l.context.label,l.context.group,u))}catch(u){await r(tr(l.context.label,l.context.group,u))}}function xf(n){n.error.catch(()=>{})}function x2(n){console.error(n)}function yy(n,i,r,l){try{i.end()}catch(u){const f=py(n);Ht(r),Ht(f),r.length=0;const d=f[0]?.context??l;throw d?tr(d.label,d.group,u):u}}let S2=1;const Mg=new WeakMap;function w2(n){return n===null||typeof n!="object"||ArrayBuffer.isView(n)||n instanceof ArrayBuffer||Array.isArray(n)?!0:n instanceof Di||n instanceof nr?!1:!by(n)}function tf(n){return typeof n!="object"||n===null||Array.isArray(n)||ArrayBuffer.isView(n)||n instanceof ArrayBuffer||n instanceof Di||n instanceof nr?!1:!by(n)}function Dg(n,i,r){switch(n.bindingLayout?.kind){case"buffer":return E2(n,i,r);case"texture":return A2(n,i,r);case"sampler":return T2(n,i);case"storageTexture":throw Kn(n,"storage texture","Pass a storage-compatible texture.");case"externalTexture":throw Kn(n,"external texture","Pass a compatible GPUExternalTexture.");default:throw Kn(n,"reflected resource","Fix shader reflection bindingLayout.")}}function E2(n,i,r){const l=DS(i);if(l)return l[Z0](n,r.sourceHint);if(i instanceof Di)return xg(i,`${r.sourceHint}.set`),D2(n,i.options.usage),{resource:{buffer:i.gpu},identity:i.resourceIdentity,unsubscribe:u=>i.onDestroy(u)};if(C2(i))return xg(i.buffer,`${r.sourceHint}.set`),{resource:{buffer:i.gpu,offset:0,size:i.size},identity:i.buffer.resourceIdentity,unsubscribe:u=>i.buffer.onDestroy(u)};if(Sy(i))return{resource:i,identity:cs(i.buffer)};if(Sf(i))return{resource:{buffer:i},identity:cs(i)};throw Kn(n,"buffer",`Pass a compatible Buffer/Uniform: ${n.name}.set({ ${n.name}: gpu.device.createBuffer(...) }).`)}function A2(n,i,r){const l=vy(i);if(l){const u=l.color;Rg(n,u,r);const f=l.onTexturesRecreated?.bind(l);return{resource:u.createView(),identity:u.resourceIdentity,unsubscribe:d=>l.onDestroy(d),onRecreate:f?d=>f(d):void 0}}if(i instanceof nr)return R2(n,i.usage),Rg(n,i,r),{resource:i.createView(),identity:i.resourceIdentity,unsubscribe:u=>i.onDestroy(u)};if(xy(i))return{resource:i.createView(),identity:i.resourceIdentity??cs(i)};if(typeof i=="object"&&i!==null)return{resource:i,identity:cs(i)};throw Kn(n,"texture/target",`Pass a Texture or Target: ${n.name}.set({ ${n.name}: scene.color }) or set({ ${n.name}: scene }).`)}function T2(n,i){if(M2(i))return{resource:i,identity:cs(i)};throw Kn(n,"sampler",`Use the cached sampler: set({ ${n.name}: sampler(gpu) }).`)}function M2(n){return typeof n!="object"||n===null||n instanceof Di||n instanceof nr?!1:!Sf(n)&&!Sy(n)&&!xy(n)&&!vy(n)}function D2(n,i){const r=n.bindingLayout?.kind==="buffer"?n.bindingLayout.buffer.type:void 0;if(r==="uniform"&&!i.includes("uniform"))throw Kn(n,"uniform buffer","Create with usage: ['uniform','copy_dst'].");if((r==="storage"||r==="read-only-storage")&&!i.includes("storage"))throw Kn(n,"storage buffer","Create with usage: ['storage','copy_dst'].")}function R2(n,i){if(!i.includes("texture_binding")&&!i.includes("render_attachment"))throw Kn(n,"sampled texture","Use texture_binding usage or a sampleable Target.")}function Rg(n,i,r){if(!(!r.filterableTexture||r.float32Filterable)&&(i.format==="r32float"||i.format==="rg32float"||i.format==="rgba32float"))throw q1(r.sourceHint,n,i.format,i.label??"texture",r.pairedSampler)}function vy(n){if(typeof n!="object"||n===null)return;const i=n;if(!(!i.resourceIdentity||!i.color||typeof i.onDestroy!="function"))return i}function by(n){const i=n;return"gpu"in i||"bindGroup"in i||"createView"in i||"resourceIdentity"in i}function cs(n){if(typeof n!="object"||n===null)return`value:${String(n)}`;let i=Mg.get(n);return i||(i={kind:"external",id:S2++},Mg.set(n,i)),i}function C2(n){return typeof n=="object"&&n!==null&&"gpu"in n&&"size"in n&&"buffer"in n&&n.buffer instanceof Di}function xy(n){return typeof n=="object"&&n!==null&&typeof n.createView=="function"}function Sy(n){return typeof n=="object"&&n!==null&&"buffer"in n&&Sf(n.buffer)}function Sf(n){return typeof n=="object"&&n!==null&&"size"in n&&"usage"in n&&typeof n.destroy=="function"}function O2(n,i){z2(n);const r=new ArrayBuffer(n.size);return wf(new DataView(r),n,0,i),r}function z2(n){if(n.size===void 0)throw Yt("set",`No se puede inferir byteLength para layout runtime-sized '${n.name}'.`)}function wf(n,i,r,l){if(i.members)return _2(n,i.members,r,l);U2(n,i,r,l)}function _2(n,i,r,l){const u=l;for(const f of i)wf(n,f.layout,r+f.offset,u?.[f.name])}function U2(n,i,r,l){switch(i.type.kind){case"scalar":return Ef(n,r,i.type.name,l);case"vector":return N2(n,r,i.type,l);case"matrix":return L2(n,i,r,l);case"array":return k2(n,i,r,l);default:throw Yt("set",`No hay writer para layout ${i.type.kind}.`)}}function Ef(n,i,r,l){r==="f32"?n.setFloat32(i,Number(l??0),!0):r==="i32"?n.setInt32(i,Number(l??0),!0):r==="u32"||r==="bool"?n.setUint32(i,r==="bool"?l?1:0:Number(l??0),!0):n.setUint16(i,j2(Number(l??0)),!0)}function N2(n,i,r,l){const u=l,f=wy(r.element);for(let d=0;d<r.width;d++)Ef(n,i+d*f,Af(r.element),u?.[d]??0)}function L2(n,i,r,l){const u=i.type,f=l,d=wy(u.element),h=i.stride??16;for(let m=0;m<u.columns;m++)for(let g=0;g<u.rows;g++)Ef(n,r+m*h+g*d,Af(u.element),f?.[m*u.rows+g]??0)}function k2(n,i,r,l){const u=l,f=i.stride??i.element?.size??0;if(!i.element)throw Yt("set","Array layout sin element layout.");for(let d=0;d<(u?.length??0);d++)wf(n,i.element,r+d*f,u[d])}function wy(n){return Af(n)==="f16"?2:4}function Af(n){if(n.kind!=="scalar")throw Yt("set",`Expected scalar, got ${n.kind}`);return n.name}function j2(n){const i=new Float32Array(1),r=new Uint32Array(i.buffer);i[0]=n;const l=r[0],u=l>>16&32768,f=l&8388607,d=l>>23&255;if(d===255)return u|(f?32256:31744);const h=d-127+15;return h>=31?u|31744:h<=0?h<-10?u:u|(f|8388608)>>1-h+13:u|h<<10|f>>13}const Cg=new WeakMap;function G2(n,i){const r=new Map,l=new Set;for(const f of i){const d=f.stage==="vertex"?1:f.stage==="fragment"?2:4;for(const h of Jl(f,"bindings","visibility")){const m=`${h.group}:${h.binding}`;r.set(m,(r.get(m)??0)|d)}for(const h of Jl(f,"samplingPairs","visibility"))h.mode==="filtering"&&l.add(`${h.texture.group}:${h.texture.binding}`)}const u=f=>r.get(`${f.group}:${f.binding}`)??0;return Object.defineProperty(u,"filterable",{value:l}),u}function Ey(n,i,r=Tf){return n.flatMap(l=>{if(l.group!==i)return[];const u=r(l);return u===0?[]:[{binding:l.binding,visibility:u,...V2(l,r.filterable?.has(`${l.group}:${l.binding}`)??!1)}]})}function B2(n,i,r,l=Tf){const u=new Map,f=r.bindings.filter(h=>l(h)!==0).map(h=>h.group),d=Math.max(-1,...f);for(let h=0;h<=d;h++)u.set(h,$2(n,i,r,h,l));return u}function $2(n,i,r,l,u=Tf){return Ay(n,`${i}.group${l}.bgl`,Ey(r.bindings,l,u))}function Ay(n,i,r){let l=Cg.get(n.gpu);l||(l=new Map,Cg.set(n.gpu,l));const u=JSON.stringify(r),f=l.get(u);if(f)return f;const d=I1(n.gpu.createBindGroupLayout({label:i,entries:r}),{entries:r});return l.set(u,d),d}function V2(n,i){const r=n.bindingLayout;if(!r)throw Yt("bindGroupLayout",`Binding '${n.name}' does not have a reflected bindingLayout.`);return i&&r.kind==="texture"&&r.texture.sampleType==="unfilterable-float"&&!r.texture.multisampled?{texture:{...r.texture,sampleType:"float"}}:I2(r)}function I2(n){switch(n.kind){case"buffer":return{buffer:{...n.buffer}};case"sampler":return{sampler:{...n.sampler}};case"texture":return{texture:{...n.texture}};case"storageTexture":return{storageTexture:{...n.storageTexture}};case"externalTexture":return{externalTexture:{}}}}function Tf(n){const i=globalThis.GPUShaderStage,r=i?.VERTEX??1,l=i?.FRAGMENT??2,u=i?.COMPUTE??4;return n.kind==="buffer"?r|l|u:l|u}function F2(n){const i=H2(n.reflection),r=[...n.bindGroupLayouts.keys()].sort((E,j)=>E-j),l=new Map;function u(E){const j=[];for(const[W,te]of Object.entries(E))j.push(...d(W,te));return j}function f(E){const j=n.bindGroupLayouts.get(E.info.group);return!!j&&!!ss(j)?.entries.some(W=>W.binding===E.info.binding)}function d(E,j){const W=i.get(E);if(W)return h(W,E,j);const te=q2(E,i,n.label);if(!te)throw Yt(`${n.label}.set`,`Binding '${E}' does not exist in '${n.label}'.`);return m(te,E,j)}function h(E,j,W){P(E.info.group);const te=Og(E.info,W);zg(E,j,te);const le=Yl(E.identity);return te==="lib"?g(E,K2(E.libValue,W)):b(E,W),f(E)?Nc(E,le):[]}function m(E,j,W){P(E.info.group);const te=Og(E.info,W);if(zg(E,j,te),Y2(E,j,te),te!=="lib")throw Yt(`${n.label}.set`,`Member '${j}' needs a JS value; set resource '${E.info.name}' instead.`);const le=Yl(E.identity);return g(E,{...Z2(E.libValue),[j]:W}),f(E)?Nc(E,le):[]}function g(E,j){const W=M(E);E.libValue=j;const te=O2(W,j);E.buffer||he(E,W.size),E.bytes=te,E.buffer.write(te,0)}function x(E){const j=ss(n.bindGroupLayouts.get(E.group))?.entries.find(le=>le.binding===E.binding),W=n.reflection.entryPoints.flatMap(le=>Jl(le,"samplingPairs",n.label)).find(le=>le.mode==="filtering"&&le.texture.group===E.group&&le.texture.binding===E.binding),te=W&&n.reflection.bindings.find(le=>le.group===W.sampler.group&&le.binding===W.sampler.binding);return{sourceHint:n.label,filterableTexture:j?.texture?.sampleType==="float",float32Filterable:n.device.features.has("float32-filterable"),pairedSampler:te}}function b(E,j){const W=Dg(E.info,j,x(E.info));E.unsubscribe?.(),E.unsubscribeRecreate?.(),E.resource=W.resource,E.identity=W.identity,E.unsubscribe=W.unsubscribe?.(()=>{E.identity&&n.cache.evictIdentity(E.identity)}),E.unsubscribeRecreate=W.onRecreate?.(()=>D(E,j))}function D(E,j){const W=Yl(E.identity);E.identity&&n.cache.evictIdentity(E.identity);const te=Dg(E.info,j,x(E.info));if(E.unsubscribe?.(),E.unsubscribeRecreate?.(),E.resource=te.resource,E.identity=te.identity,E.unsubscribe=te.unsubscribe?.(()=>{E.identity&&n.cache.evictIdentity(E.identity)}),E.unsubscribeRecreate=te.onRecreate?.(()=>D(E,j)),f(E))for(const le of Nc(E,W))n.onIdentityChange?.(le)}function $(E,j,W){k(E),X2(n.label,E,j,W);const te=l.has(E)?`claimed-group:${E}`:void 0;return l.set(E,j),te}function k(E){const j=n.bindGroupLayouts.get(E);if(!j)throw Yt(`${n.label}.layout`,`@group(${E}) does not exist in '${n.label}'.`);return j}function N(){return r.map(V)}function V(E){const j=l.get(E);if(j)return{group:E,bindGroup:j,offsets:[],claimValidation:Z(j,E)};const W=new Set(ss(k(E))?.entries.map(se=>se.binding)),te=n.reflection.bindings.filter(se=>se.group===E&&W.has(se.binding)),le=I(te),$e=F(te),de=n.cache.getOrCreate(n.drawId,E,$e,()=>n.device.gpu.createBindGroup({label:`${n.label}.group${E}`,layout:k(E),entries:le}));return{group:E,bindGroup:de,offsets:[]}}function Z(E,j){return H0(E)?void 0:{label:n.label,group:j}}function I(E){return E.map(j=>{const W=Y(j);return{binding:j.binding,resource:W.resource}})}function F(E){return E.map(j=>Y(j).identity)}function Y(E){const j=i.get(E.name);if(!j?.resource||!j.identity)throw Y1(n.label,E);return j}function P(E){if(l.has(E))throw X1(n.label,E)}function he(E,j){E.buffer=n.device.createBuffer({size:j,usage:["uniform","copy_dst"],label:`${n.label}.${E.info.name}`}),E.resource={buffer:E.buffer.gpu,offset:0,size:j},E.identity=E.buffer.resourceIdentity,E.unsubscribe=E.buffer.onDestroy(()=>n.cache.evictIdentity(E.buffer.resourceIdentity))}function M(E){if(E.info.kind!=="buffer"||!E.info.layout?.size)throw Yt(`${n.label}.set`,`Binding '${E.info.name}' needs a compatible resource, not JS.`);return E.info.layout}return{get groups(){return r},set:u,claimGroup:$,layout:k,bindGroups:N,bindingState(E){const j=i.get(E);if(!(!j?.ownership||!j.resource||!j.identity))return{info:j.info,ownership:j.ownership,resource:j.resource,identity:j.identity}}}}function H2(n){return new Map(n.bindings.map(i=>[i.name,{info:i,memberOwnership:new Map}]))}function q2(n,i,r){let l;for(const u of i.values())if(u.info.layout?.members?.some(f=>f.name===n)){if(l)throw Yt(`${r}.set`,`Binding member '${n}' is ambiguous in '${r}'; set the complete binding.`);l=u}return l}function Og(n,i){return n.bindingLayout?.kind==="buffer"&&w2(i)?"lib":"user"}function zg(n,i,r){if(n.ownership&&n.ownership!==r)throw q0(i,n.ownership);n.ownership??=r}function Y2(n,i,r){const l=n.memberOwnership.get(i);if(l&&l!==r)throw q0(i,l);n.memberOwnership.set(i,r)}function X2(n,i,r,l){const u=H0(r);if(!u)return;const f=ss(l);if(!f)return;const d=Q2(f.entries,u.layout.entries);if(d)throw Q1(n,i,d)}function Q2(n,i){if(n.length!==i.length)return`expected ${n.length} bindings and received ${i.length}`;const r=_g(n),l=_g(i);for(const[u,f]of r){const d=l.get(u);if(!d)return`missing @binding(${u})`;if(Ug(f)!==Ug(d))return`@binding(${u}) does not match the reflected layout`}}function _g(n){return new Map(n.map(i=>[i.binding,i]))}function Ug(n){return JSON.stringify({binding:n.binding,visibility:n.visibility,buffer:n.buffer,sampler:n.sampler,texture:n.texture,storageTexture:n.storageTexture,externalTexture:n.externalTexture?{}:void 0})}function Nc(n,i){const r=Yl(n.identity);return!r||i===r?[]:[{group:n.info.group,binding:n.info.binding,bindingName:n.info.name,bindingKind:n.info.kind,previousIdentity:i,newIdentity:r}]}function Yl(n){return n===void 0?void 0:ef(n)}function K2(n,i){return tf(n)&&tf(i)?{...n,...i}:i}function Z2(n){return tf(n)?n:{}}const P2="rgba8unorm",Mf=Object.freeze([0,0,0,1]);function nu(n,i){const r=n,l=Array.isArray(n)?n:[r?.r,r?.g,r?.b,r?.a];if(l.length!==4||!l.every(u=>typeof u=="number"&&Number.isFinite(u)))throw hS(i);return Df(n)}function Df(n){const i=n;return Array.isArray(n)?[n[0],n[1],n[2],n[3]]:{r:i.r,g:i.g,b:i.b,a:i.a}}function Xl(n){return n.colors??[{format:n.format??P2}]}function Ty(n){return n.depth===!0?"depth24plus":n.depth||void 0}function My(n){const i=n.msaa;if(i===!0||i===4)return 4;if(i===void 0||i===!1)return 1;const r=Y0();throw r.code="VGPU-TARGET-MSAA-INVALID",r.message=`msaa received ${i}; WebGPU 1|4; use true`,r}function W2(n,i){if(!n?.size)throw Y0();const r=Ty(n);if(r==="stencil8")throw lS(r);if(My(n)===4)for(const l of Xl(n))J2(l.format,i)}function J2(n,i){if(i.isCompatibilityMode&&n==="rgba16float")throw Yt("target","Dawn compatibility mode does not support rgba16float+msaa.","Use rgba8unorm for MSAA here, or disable msaa.")}function eE(n,i,r,l){const u={view:(i??n).createView(),resolveTarget:i?n.createView():void 0,loadOp:l?"load":"clear",storeOp:i?"discard":"store"};return l||(u.clearValue=Dy(r)),u}function tE(n,i,r,l,u){if(u){const d={view:n.createView(),depthReadOnly:!0};return fs(n.format)&&(d.stencilReadOnly=!0),d}const f={view:n.createView(),depthLoadOp:i?"load":"clear",depthStoreOp:n.sampleCount>1?"discard":"store"};return i||(f.depthClearValue=r??1),n.format&&fs(n.format)&&(f.stencilLoadOp=i?"load":"clear",f.stencilStoreOp=n.sampleCount>1?"discard":"store",i||(f.stencilClearValue=l??0)),f}function fs(n){return!!n&&n.includes("stencil")}function Dy(n){return Array.isArray(n)?{r:n[0],g:n[1],b:n[2],a:n[3]}:n}function Ry(n,i){return n[0]===i[0]&&n[1]===i[1]}function ou(n){return typeof n=="object"&&n!==null&&typeof n.renderPassDescriptor=="function"}let nE=1,iE=1;const aE=new WeakMap,rE=new WeakMap;function sE(n){return ou(n)?{colors:n.colors.map(i=>i.format),depth:n.depth?.format,sampleCount:n.sampleCount}:typeof n!="object"||n===null?{colors:[]}:{colors:Array.isArray(n.colors)?[...n.colors]:n.colors??[],depth:n.depth,sampleCount:n.sampleCount??1}}function Cy(n){return`${n.colors.join(",")}:${n.depth??"none"}:${n.sampleCount??1}`}function lE(n,i){if(!Array.isArray(n.colors)||n.colors.length===0)throw Ll(i,"colors must be a non-empty array.");const r=n.colors.find(u=>typeof u!="string"||u.length===0);if(r!==void 0)throw Ll(i,`colors must contain only GPUTextureFormat strings; received ${String(r)}.`);if(n.depth!==void 0&&(typeof n.depth!="string"||n.depth.length===0))throw Ll(i,"depth must be a GPUTextureFormat string.");const l=n.sampleCount??1;if(l!==1&&l!==4)throw Ll(i,`sampleCount must be 1 or 4; received ${String(l)}.`)}function uE(n){const i=`${jg(aE,n.module,()=>nE++)}|${jg(rE,n.pipelineLayout,()=>iE++)}|${pE(n.vertexBufferLayouts??[])}|${Cy(n.signature)}`,r=n.topology||n.stripIndexFormat?`${i}|${n.topology??"triangle-list"}|${n.stripIndexFormat??"none"}`:i,l=n.cullMode||n.frontFace?`${r}|${n.cullMode??"none"}|${n.frontFace??"ccw"}`:r,u=n.unclippedDepth?`${l}|unclipped`:l,f=n.depthKey?`${u}|${n.depthKey}`:u,d=n.stencilKey?`${f}|${n.stencilKey}`:f,h=n.multisampleKey?`${d}|${n.multisampleKey}`:d,m=n.constantsKey?`${h}|${n.constantsKey}`:h,g=n.entryKey?`${m}|${n.entryKey}`:m;return n.fragmentKey?`${g}|${n.fragmentKey}`:g}function Ng(n,i,r,l,u){if(l===void 0)return i.find(d=>d.stage===r);if(typeof l!="string")throw Hl(n,`${r} received ${nf(l)}; expected an entry point name string.`,u);const f=i.find(d=>d.name===l);if(!f)throw Hl(n,`"${l}" matches no entry point in the shader; available entry points: ${Lg(i)}.`,u);if(f.stage!==r)throw Hl(n,`"${l}" is a @${f.stage} entry point, not @${r}; available entry points: ${Lg(i)}.`,u);return f}function Lg(n){return n.length?n.map(i=>`"${i.name}" (@${i.stage})`).join(", "):"none"}function oE(n,i,r,l){if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw Nl(n,`received ${nf(i)}; expected { overrideNameOrId: number | boolean }.`,l);const u=new Map(r.map(d=>[kg(d),d])),f={};for(const[d,h]of Object.entries(i??{})){if(!u.has(d))throw Nl(n,`"${d}" matches no override in the shader; available overrides: ${cE(r)}.`,l);if(typeof h=="boolean"){f[d]=h?1:0;continue}if(typeof h!="number"||!Number.isFinite(h))throw Nl(n,`"${d}" received ${nf(h)}; use a finite number or a boolean (WebGPU converts the value to the override's WGSL type, and NaN/Infinity fail that conversion).`,l);f[d]=h}for(const d of r){const h=kg(d);if(d.defaultValue===void 0&&!(h in f))throw Nl(n,`override '${d.name}' has no default value and must be provided; add constants: { "${h}": value }.`,l)}return Object.keys(f).length===0?{}:{constants:f,constantsKey:fE(f)}}function kg(n){return n.id!==void 0?String(n.id):n.name}function cE(n){return n.length?n.map(i=>i.id!==void 0?`"${i.id}" (@id of ${i.name})`:`"${i.name}"`).join(", "):"none"}function fE(n){return`cn~${Object.entries(n).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>`${i}=${r}`).join("~")}`}function nf(n){if(typeof n=="string")return`"${n}"`;try{return JSON.stringify(n)??String(n)}catch{return String(n)}}function Oy(n){const i=new Map;return{get(r,l){let u=i.get(r);return u||(u=n.gpu.createShaderModule({label:l,code:r}),i.set(r,u)),u},dispose(){i.clear()}}}function zy(n){const i=new Map;return{get(r){const l=mE(r);let u=i.get(l);return u||(u=n.gpu.createPipelineLayout({bindGroupLayouts:gE(r)}),i.set(l,u)),u},dispose(){i.clear()}}}function _y(n,i={}){return new dE(n,i)}class dE{device;#e=new Map;#t=new Set;#n;#i;#a=!1;constructor(i,r){this.device=i,this.#n=r.errorSink??(()=>{}),this.#i=r.registerSettledSource?.(()=>[...this.#t])}getReady(i){return this.#e.get(i)?.pipeline}getSync(i,r,l){this.#u(l.where);const u=this.#e.get(i);if(u?.pipeline)return u.pipeline;const f=u??{};u||this.#e.set(i,f);const d=this.#r(i,f,r,l);if(!d){f.pending||this.#e.delete(i);return}return f.pipeline=d,f.pending?.resolve(d),f.pending=void 0,d}getAsync(i,r,l){this.#u(l.where);const u=this.#e.get(i);if(u?.pipeline)return Promise.resolve(u.pipeline);if(u?.pending)return u.pending.promise;const f={},d=hE();f.pending=d,this.#e.set(i,f);let h;try{h=r()}catch(m){const g=Jr(l.where,m,l.signature);return d.reject(g),this.#e.delete(i),d.promise}return this.#o(h),h.then(m=>{this.#e.get(i)!==f||f.pipeline||f.pending!==d||(f.pipeline=m,f.pending=void 0,d.resolve(m))},m=>{this.#e.get(i)!==f||f.pipeline||f.pending!==d||(f.pending=void 0,this.#e.delete(i),d.reject(Jr(l.where,m,l.signature)))}),d.promise}dispose(){if(this.#a)return;this.#a=!0;const i=yg("gpu.dispose");for(const r of this.#e.values())r.pending?.reject(i);this.#e.clear(),this.#t.clear(),this.#i?.()}#r(i,r,l,u){const f=this.device.gpu,d=typeof f.pushErrorScope=="function"&&typeof f.popErrorScope=="function";d&&f.pushErrorScope("validation");try{const h=l();return d&&this.#l(i,r,u),h}catch(h){d&&this.#c();const m=Jr(u.where,h,u.signature);this.#n(m);return}}#l(i,r,l){const u=this.device.gpu.popErrorScope().then(f=>{if(!f)return;const d=Jr(l.where,f,l.signature);return this.#e.get(i)===r&&this.#e.delete(i),this.#n(d)},f=>{const d=Jr(l.where,f,l.signature);return this.#e.get(i)===r&&this.#e.delete(i),this.#n(d)});this.#o(u)}#c(){const i=this.device.gpu.popErrorScope?.();i&&i.catch(()=>{})}#u(i){if(this.#a)throw yg(i)}#o(i){this.#t.add(i),i.catch(()=>{}).then(()=>this.#t.delete(i),()=>this.#t.delete(i))}}function hE(){let n,i;const r=new Promise((l,u)=>{n=l,i=u});return r.catch(()=>{}),{promise:r,resolve:n,reject:i}}function jg(n,i,r){let l=n.get(i);return l||(l=r(),n.set(i,l)),l}function pE(n){return JSON.stringify(n.map(i=>({arrayStride:i.arrayStride,stepMode:i.stepMode??"vertex",attributes:[...i.attributes].map(r=>({shaderLocation:r.shaderLocation,offset:r.offset,format:r.format}))})))}function mE(n){return JSON.stringify([...n.entries()].map(([i,r])=>({group:i,entries:vE(r)})))}function gE(n){const i=Math.max(-1,...n.keys()),r=[];for(let l=0;l<=i;l++)r.push(yE(n,l));return r}function yE(n,i){const r=n.get(i);if(!r)throw sS(i);return r}function vE(n){return(ss(n)?.entries??[]).map(i=>({binding:i.binding,visibility:i.visibility,buffer:i.buffer?{...i.buffer}:void 0,sampler:i.sampler?{...i.sampler}:void 0,texture:i.texture?{...i.texture}:void 0,storageTexture:i.storageTexture?{...i.storageTexture}:void 0,externalTexture:i.externalTexture?{...i.externalTexture}:void 0}))}const bE=lu("frame-state");function Uy(n){return n.service(bE,xE)}function xE(){const n=new Set;let i=Gg(),r=!1,l=!1;const u={time:0,deltaTime:0,frameCount:0,advanceBy(f){u.deltaTime=f,u.time+=f,l=!0},tick(){if(r)throw Q0();r=!0;try{const f=Gg();l?l=!1:(u.deltaTime=Math.max(0,(f-i)/1e3),u.time+=u.deltaTime),i=f,u.frameCount+=1;for(const d of[...n])d()}finally{r=!1}},onAdvance(f){return n.add(f),()=>{n.delete(f)}}};return u}function Gg(){return globalThis.performance?.now?.()??Date.now()}function SE(n,i,r={}){const l=Pn(n,"surface"),u=EE(l),f=u.get(i);if(f&&!f.disposed)throw oS(f.label);const d=new Ly(l.device,i,r,g=>{u.get(g.canvas)===g&&u.delete(g.canvas),h(),m()}),h=Uy(l).onAdvance(()=>d.applyAutoResize()),m=l.own("resource",()=>d.dispose());return u.set(i,d),d}const wE=lu("surfaces");function EE(n){return n.service(wE,()=>new Map)}let as=0,Rf=0;function AE(){return as>0}function TE(){return Rf>0}function ME(){Rf+=1}function DE(){Rf-=1}function Ny(n){return n instanceof Ly}class Ly{device;canvas;options;unregister;resourceIdentity=ru("render-target");label;context;autoResize;layoutBacked;format;#e=new su;#t=new Set;#n=new Set;#i;#a;#r=!1;#l=!1;constructor(i,r,l,u){this.device=i,this.canvas=r,this.options=l,this.unregister=u,this.label=l.label,this.#a=l.clearColor===void 0?Mf:nu(l.clearColor,"surface.clearColor");const f=r.getContext("webgpu");if(!f)throw uS();if(this.context=f,this.layoutBacked=RE(r),l.autoResize===!0&&!this.layoutBacked)throw fS();this.autoResize=l.autoResize??(l.size?!1:this.layoutBacked),this.#i=$g(l.dpr),this.format=l.format??OE();const d=CE(r,l,this.layoutBacked,this.#i);(l.size||this.layoutBacked)&&Bg(r,d),f.configure({device:i.gpu,format:this.format,alphaMode:l.alphaMode??"premultiplied",colorSpace:l.colorSpace??"srgb",usage:zE()})}get gpu(){return this.context}get size(){return this.#s(),Ql(this.canvas)}get texelSize(){const i=this.size;return[1/i[0],1/i[1]]}get color(){return this.#s(),new nr(this.device,this.context.getCurrentTexture(),{size:this.size,format:this.format,usage:["render_attachment","texture_binding","copy_src"],label:this.options.label?`${this.options.label}.color`:"surface.color"},"external")}get colors(){return[this.color]}get depth(){this.#s()}get sampleCount(){return this.#s(),1}get dpr(){return this.#i}get clearColor(){return Df(this.#a)}set clearColor(i){this.#a=nu(i,"surface.clearColor")}get disposed(){return this.#r}resize(i){if(this.#s(),this.#l)throw dS(this.options.label);this.#c(iu(i),this.#i,!0)}applyAutoResize(){if(this.#r||!this.autoResize||!this.layoutBacked)return;const i=$g(this.options.dpr),r=ky(this.canvas,i);this.#c(r,i,!0)}onResize(i){this.#s(),this.#t.add(i),this.#l=!0,as+=1;try{i(this.#f())}finally{as-=1,this.#l=!1}return()=>{this.#t.delete(i)}}async read(){return this.#s(),this.color.read()}async readFloats(){return this.#s(),this.color.readFloats()}onDestroy(i){return this.#s(),this.#e.onDestroy(this,i)}onTexturesRecreated(i){return this.#s(),this.#n.add(i),()=>{this.#n.delete(i)}}renderPassDescriptor(i={}){const{clear:r=[0,0,0,1],preserve:l}=i;this.#s();const u={view:this.context.getCurrentTexture().createView(),loadOp:l?"load":"clear",storeOp:"store"};return l||(u.clearValue=Dy(r)),{colorAttachments:[u]}}dispose(){if(!this.#r){this.#r=!0;try{this.context.unconfigure?.()}catch{}this.unregister(this),this.#t.clear(),this.#n.clear(),this.#e.emit(this)}}#c(i,r,l){const u=!Ry(Ql(this.canvas),i);this.#i=r,u&&(Bg(this.canvas,i),this.#u(),l&&this.#o())}#u(){for(const i of[...this.#n])i()}#o(){this.#l=!0,as+=1;try{const i=this.#f();for(const r of[...this.#t])r(i)}finally{as-=1,this.#l=!1}}#f(){const i=Ql(this.canvas);return{width:i[0],height:i[1],dpr:this.#i,surface:this}}#s(){if(this.#r)throw cS(this.options.label)}}function RE(n){return typeof n.clientWidth=="number"}function CE(n,i,r,l){return i.size?iu(i.size):r?ky(n,l):iu(Ql(n))}function ky(n,i){const r=n;return iu([Math.round(r.clientWidth*i),Math.round(r.clientHeight*i)])}function Ql(n){const i=n;return[i.width,i.height]}function Bg(n,i){const r=n;r.width=i[0],r.height=i[1]}function iu(n){return[Math.max(1,Math.floor(n[0])),Math.max(1,Math.floor(n[1]))]}function $g(n){const i=globalThis.devicePixelRatio??1;return Array.isArray(n)?Math.min(n[1],Math.max(n[0],i)):typeof n=="number"?n:i}function OE(){return globalThis.navigator?.gpu?.getPreferredCanvasFormat?.()??"bgra8unorm"}function zE(){const n=globalThis.GPUTextureUsage;return n?n.RENDER_ATTACHMENT|n.TEXTURE_BINDING|n.COPY_SRC:void 0}const _E={drawIndirect:{bytes:16,args:"4 u32 values: vertexCount, instanceCount, firstVertex, firstInstance"},drawIndexedIndirect:{bytes:20,args:"5 32-bit values: indexCount, instanceCount, firstIndex, baseVertex (signed), firstInstance"},dispatchWorkgroupsIndirect:{bytes:12,args:"3 u32 values: workgroupCountX, workgroupCountY, workgroupCountZ"}};function UE(n,i,r,l){const u=typeof r=="object"&&r!==null?r.buffer:void 0,f=Vg(r)?r:Vg(u)?u:void 0;if(!f)throw Ya(n,`received ${Ig(r)}; expected a StorageBuffer or { buffer, offset? }.`,i);const d=f===r?0:r.offset??0;if(typeof d!="number"||!Number.isInteger(d)||d<0)throw Ya(n,`offset must be an integer >= 0; received ${Ig(d)}.`,i);if(d%4!==0)throw Ya(n,`offset must be a multiple of 4 (WebGPU requires "indirectOffset is a multiple of 4"); received ${d}.`,i);if(!f.buffer.options.usage.includes("indirect"))throw Ya(n,`the buffer lacks the "indirect" usage (WebGPU requires "indirectBuffer.usage contains INDIRECT"); create it with storage(gpu, ${f.size}, { indirect: true }).`,i);const{bytes:h,args:m}=_E[l];if(d+h>f.size)throw Ya(n,`${l} reads ${h} bytes (${m}) at offset ${d}, but offset + ${h} = ${d+h} exceeds the buffer size ${f.size}.`,i);return{buffer:f.gpu,offset:d}}function Vg(n){return typeof n=="object"&&n!==null&&"gpu"in n&&"size"in n&&n.buffer instanceof Di}function Ig(n){if(typeof n=="string")return`"${n}"`;try{return JSON.stringify(n)??String(n)}catch{return String(n)}}const au=Symbol("vgpu.frame.drawable");function NE(n){return n?.[au]}const LE=Symbol("vgpu.frame.bundle");function kE(n){return n?.[LE]}const Cf=Symbol("vgpu.frame.passAttachment");function jE(n){return typeof n?.[Cf]=="function"?n:void 0}function GE(n,i){return Of(Pn(n,"sampler")).sampler(i)}let Fg=1;function BE(n){const i=new Map,r=new WeakMap;return{sampler(l={}){const u=af(l);let f=i.get(u);return f||(f=n.gpu.createSampler(l),i.set(u,f),r.set(f,{kind:"sampler",id:Fg++})),f},identity(l){let u=r.get(l);return u||(u={kind:"sampler",id:Fg++},r.set(l,u)),u}}}function af(n){if(n===null||typeof n!="object")return JSON.stringify(n);if(Array.isArray(n))return`[${n.map(af).join(",")}]`;const i=n;return`{${Object.keys(i).sort().map(r=>`${JSON.stringify(r)}:${af(i[r])}`).join(",")}}`}const $E=lu("render-service");function Of(n){return n.service($E,VE)}function VE(n){const i=n.device,r=hy(),l=_y(i,{errorSink:h=>n.reportError(h),registerSettledSource:h=>n.registerSettledSource(h)}),u=Oy(i),f=zy(i),d=BE(i);return n.own("service",()=>{l.dispose(),u.dispose(),f.dispose(),r.dispose()}),{binds:r,pipelines:l,shaderModules:u,pipelineLayouts:f,sampler:h=>d.sampler(h)}}function jy(n){if(typeof n=="string")return n;if(!IE(n)||!("version"in n)||n.version!==1)throw kl(n);const r=n.wgsl;if(typeof r!="string")throw kl(n);return r}function IE(n){return typeof n=="object"&&n!==null}function Lc(n,i){const r=Pn(n,"draw"),l=Of(r),u=jy(i.shader);return new By(r.device,u,{...i,shader:u},l.binds,void 0,l.pipelines,l.shaderModules,l.pipelineLayouts,f=>r.reportError(f),f=>{r.trackDelivery(f)})}let FE=1;const Gy=new WeakMap;class By{source;label;#e=new Map;constructor(i,r,l,u=hy(),f,d=_y(i),h=Oy(i),m=zy(i),g,x){this.source=r,ht(i,"Draw.constructor"),this.label=l.label??"draw";const b=FE++,D=dy(r,`${this.label}.wgsl`),$=WE(this.label,l.entry),k=Ng(this.label,D.entryPoints,"vertex",$.vertex,"draw"),N=Ng(this.label,D.entryPoints,"fragment",$.fragment,"draw"),V=JE(D,k,N),Z=[k,N].filter(ae=>!!ae),I=G2(D.bindings,Z);HE(i,this.label,D.bindings,Z,I);const F=l.geometry,Y=k?Jl(k,"inputs",this.label):[],P=F&&Pc in F?F[Pc](Y,`${this.label}.geometry`):F?.vertexBufferLayouts,he=new Map(B2(i,this.label,D,I)),M=m.get(he),E=h.get(r,`${this.label}.shader`),j=gA(),W=XE(this.label,l),te=KE(this.label,l,W),le=eA(i,this.label,l),$e=aA(i,this.label,l),de=uA(this.label,l),se=cA(this.label,l),R=oE(this.label,l.constants,D.overrides,"draw"),H=F2({device:i,label:this.label,drawId:b,reflection:D,bindGroupLayouts:he,cache:u,onIdentityChange:ae=>j.markStale({kind:"binding-identity",drawLabel:this.label,...ae})});Gy.set(this,{id:b,device:i,opts:l,vertexBufferLayouts:P,cache:u,defaultTarget:f,reflection:D,visibility:I,vertexEntry:k?.name??"vs_main",fragmentEntry:N?.name??"fs_main",entryKey:V,setCore:H,bindGroupLayouts:he,pipelineLayout:M,shaderModule:E,pipelineStore:d,pipelineLayouts:m,errorSink:g,trackSettled:x,resolvedPipelineKeys:new Set,recordedIn:j,...W,...te,...le,...$e,...de,...se,...R}),l.set&&this.set(l.set);for(const ae of l.targets??[])this.compileSync(ae)}get gpu(){const i=we(this);for(const r of i.resolvedPipelineKeys){const l=i.pipelineStore.getReady(r);if(l)return l}}get targets(){return we(this).opts.targets}get[au](){return this}writesDepth(){return hA(this)}stencilWritingOps(){return pA(this)}set(i){const r=we(this);ht(r.device,`${this.label}.set`);for(const l of r.setCore.set(i))r.recordedIn.markStale({kind:"binding-identity",drawLabel:this.label,...l});return this}group(i,r){const l=we(this);ht(l.device,`${this.label}.group`);const u=this.#e.get(i)??this.layout(i),f=l.setCore.claimGroup(i,r,u);return l.recordedIn.markStale({kind:"group-claim",drawLabel:this.label,group:i,previousIdentity:f,newIdentity:`claimed-group:${i}`}),this}layout(i,r={}){return ht(we(this).device,`${this.label}.layout`),r.dynamicOffsets?this.#t(i):we(this).setCore.layout(i)}#t(i){const r=we(this);r.setCore.layout(i);const l=this.#e.get(i);if(l)return l;const u=vA(this,i),f=Ay(r.device,`${this.label}.group${i}.dynamic.bgl`,u);return this.#e.set(i,f),r.bindGroupLayouts.set(i,f),r.pipelineLayout=r.pipelineLayouts.get(r.bindGroupLayouts),f}draw(i={}){ht(we(this).device,`${this.label}.draw`);const r=ou(i)?{target:i}:i,l=we(this),u=r.target??l.defaultTarget;if(!u)throw Zc(`${this.label}.draw`);i0(u,`${this.label}.draw`);const f=l.device.gpu.createCommandEncoder(),d=f.beginRenderPass(u.renderPassDescriptor()),h=[];try{this.encode(d,u,r,b=>h.push(b))}catch(b){Ht(h),my(l.device);try{d.end()}catch{}throw b}yy(l.device,d,h,h[0]?.context);let m;const g=h[0]?.context;g&&ls(l.device,g);try{m=f.finish()}catch(b){const D=g?on(l.device):void 0;Ht(h),D&&Ht([D]);const $=D?.context??g;if($){n0(l,$.label,$.group,b);return}throw b}if(g){const b=on(l.device);b&&(h[0]=h[0]?tu(b,h[0]):b)}const x=h[0]?.context;x&&ls(l.device,x);try{l.device.gpu.queue.submit([m])}catch(b){const D=x?on(l.device):void 0;Ht(h),D&&Ht([D]);const $=D?.context??x;if($){n0(l,$.label,$.group,b);return}throw b}if(x){const b=on(l.device);b&&(h[0]=h[0]?tu(b,h[0]):b)}if(h.length){const b=gy(l.device,h,{errorSink:l.errorSink});l.trackSettled?.(b)}}encode(i,r,l={},u){ht(we(this).device,`${this.label}.encode`);const f=this.pipelineFor(r,!0);if(!f)return;i.setPipeline(f);const d=we(this);d.blendConstant&&i.setBlendConstant(d.blendConstant),d.stencilRef!==void 0&&i.setStencilReference(d.stencilRef);for(const h of d.setCore.bindGroups())this.#n(i,h,l,u);this.#l(i,l)}#n(i,r,l,u){const f=yA(l.offsets,r.group,r.offsets);if(!r.claimValidation||!u){i.setBindGroup(r.group,r.bindGroup,f);return}ls(we(this).device,r.claimValidation);try{i.setBindGroup(r.group,r.bindGroup,f)}catch(h){throw y2(we(this).device),tr(r.claimValidation.label,r.claimValidation.group,h)}const d=on(we(this).device);d&&u(d)}compile(i){ht(we(this).device,`${this.label}.compile`);const{key:r,signature:l,signatureKey:u}=this.#i(i,`${this.label}.compile`);return we(this).pipelineStore.getAsync(r,()=>this.#o(l),{where:`${this.label}.compile`,signature:u}).then(()=>(ht(we(this).device,`${this.label}.compile`),we(this).resolvedPipelineKeys.add(r),this))}compileSync(i){ht(we(this).device,`${this.label}.compileSync`);const{key:r,signature:l,signatureKey:u}=this.#i(i,`${this.label}.compileSync`);return we(this).pipelineStore.getSync(r,()=>this.#u(l),{where:`${this.label}.compileSync`,signature:u})&&we(this).resolvedPipelineKeys.add(r),this}pipelineFor(i,r=!1){ht(we(this).device,`${this.label}.pipelineFor`);const{key:l,signature:u,signatureKey:f}=this.#i(i,`${this.label}.pipelineFor`,r),d=we(this).pipelineStore.getSync(l,()=>this.#u(u),{where:`${this.label}.pipelineFor`,signature:f});return d&&we(this).resolvedPipelineKeys.add(l),d}pipelineForAsync(i){ht(we(this).device,`${this.label}.pipelineForAsync`);const{key:r,signature:l,signatureKey:u}=this.#i(i,`${this.label}.pipelineForAsync`);return we(this).pipelineStore.getAsync(r,()=>this.#o(l),{where:`${this.label}.pipelineForAsync`,signature:u}).then(d=>(ht(we(this).device,`${this.label}.pipelineForAsync`),we(this).resolvedPipelineKeys.add(r),d))}#i(i,r,l=!1){const u=this.#a(i,r,l),f=Cy(u);return{signature:u,signatureKey:f,key:this.#r(u)}}#a(i,r,l=!1){const u=we(this),f=i??u.defaultTarget;if(!f)throw Zc(r);l||i0(f,r);const d=sE(f);if(lE(d,r),u.colorStates&&u.colorStates.length!==d.colors.length)throw Kc(this.label,`expected one entry per color attachment; colors has ${u.colorStates.length}, but the target signature has ${d.colors.length}.`,r);if(u.multisampleState?.alphaToCoverageEnabled&&(d.sampleCount??1)<=1)throw Fl(this.label,`alphaToCoverage requires a multisampled target, but the target signature has sampleCount ${d.sampleCount??1}; create the target with msaa: true.`,r);if((u.stencilState||u.stencilRef!==void 0)&&!fs(d.depth))throw Ja(this.label,`stencil requires a depth format with a stencil aspect, but the target signature has ${d.depth?`"${d.depth}"`:"no depth"}; create the target with depth: "depth24plus-stencil8".`,r);return d}#r(i){const r=we(this),l=r.opts.geometry;return uE({module:r.shaderModule,pipelineLayout:r.pipelineLayout,vertexBufferLayouts:r.vertexBufferLayouts,signature:i,fragmentKey:r.fragmentKey,topology:l?.topology,stripIndexFormat:$y(l),cullMode:r.cullMode,frontFace:r.frontFace,unclippedDepth:r.unclippedDepth,depthKey:r.depthKey,stencilKey:r.stencilKey,multisampleKey:r.multisampleKey,constantsKey:r.constantsKey,entryKey:r.entryKey})}#l(i,r={}){const l=we(this).opts.geometry;if(l?.vertexBuffers&&l.vertexBuffers.forEach((f,d)=>i.setVertexBuffer(d,f)),r.indirect!==void 0)return this.#c(i,l,r);const u=YE(this.label,l,we(this).opts,r);if(!l?.indexBuffer)return i.draw(u.vertexCount,u.instanceCount,u.firstVertex,u.firstInstance);i.setIndexBuffer(l.indexBuffer,l.indexFormat??"uint32"),i.drawIndexed(u.indexCount,u.instanceCount,u.firstIndex,u.baseVertex,u.firstInstance)}#c(i,r,l){const u=`${this.label}.draw`,f=qE.find(g=>l[g]!==void 0);if(f!==void 0)throw Ya(this.label,`indirect cannot be combined with ${f} in the same call; the GPU reads the draw arguments from the buffer, so the CPU-side value would be ignored.`,u);const d=!!r?.indexBuffer,{buffer:h,offset:m}=UE(this.label,u,l.indirect,d?"drawIndexedIndirect":"drawIndirect");if(!d)return i.drawIndirect(h,m);i.setIndexBuffer(r.indexBuffer,r.indexFormat??"uint32"),i.drawIndexedIndirect(h,m)}#u(i){const r=we(this);return r.device.gpu.createRenderPipeline({label:`${this.label}.pipeline`,layout:r.pipelineLayout,vertex:{module:r.shaderModule,entryPoint:r.vertexEntry,buffers:[...r.vertexBufferLayouts??[]],...r.constants?{constants:r.constants}:{}},fragment:{module:r.shaderModule,entryPoint:r.fragmentEntry,targets:Hg(i,r),...r.constants?{constants:r.constants}:{}},primitive:qg(r.opts.geometry,r.cullMode,r.frontFace,r.unclippedDepth),depthStencil:Pg(i,r),multisample:e0(i,r)})}#o(i){const r=we(this);return r.device.gpu.createRenderPipelineAsync({label:`${this.label}.pipeline`,layout:r.pipelineLayout,vertex:{module:r.shaderModule,entryPoint:r.vertexEntry,buffers:[...r.vertexBufferLayouts??[]],...r.constants?{constants:r.constants}:{}},fragment:{module:r.shaderModule,entryPoint:r.fragmentEntry,targets:Hg(i,r),...r.constants?{constants:r.constants}:{}},primitive:qg(r.opts.geometry,r.cullMode,r.frontFace,r.unclippedDepth),depthStencil:Pg(i,r),multisample:e0(i,r)})}}function HE(n,i,r,l,u){const f=n.limits;for(const[d,h,m]of[["vertex",1,"maxStorageBuffersInVertexStage"],["fragment",2,"maxStorageBuffersInFragmentStage"]]){const g=l.find(D=>D.stage===d);if(!g)continue;const x=r.filter(D=>D.bindingLayout?.kind==="buffer"&&D.bindingLayout.buffer.type!=="uniform"&&u(D)&h),b=f[m]??f.maxStorageBuffersPerShaderStage;if(b!==void 0&&x.length>b)throw H1(i,d,g.name,x.length,b,x)}}const qE=["vertices","indices","instances","firstVertex","firstIndex","baseVertex","firstInstance"];function Hg(n,i){return n.colors.map((r,l)=>{const u=i.colorStates?.[l],f=u?.blendState??i.blendState,d=u?.writeMask??i.writeMask,h={format:r};return f&&(h.blend=f),d!==void 0&&(h.writeMask=d),h})}function YE(n,i,r,l){Ai(n,"DrawOptions.instances",r.instances),Ai(n,"DrawOptions.vertices",r.vertices),Ai(n,"DrawOptions.firstInstance",r.firstInstance),Ai(n,"DrawCallOptions.instances",l.instances),Ei(n,"DrawCallOptions.vertices",l.vertices),Ei(n,"DrawCallOptions.indices",l.indices),Ei(n,"DrawCallOptions.firstVertex",l.firstVertex),Ei(n,"DrawCallOptions.firstIndex",l.firstIndex),Ei(n,"DrawCallOptions.baseVertex",l.baseVertex),Ai(n,"DrawCallOptions.firstInstance",l.firstInstance),Ai(n,"GeometryLike.vertexCount",i?.vertexCount),Ai(n,"GeometryLike.indexCount",i?.indexCount),Ai(n,"GeometryLike.instanceCount",i?.instanceCount),Ei(n,"GeometryLike.firstVertex",i?.firstVertex),Ei(n,"GeometryLike.firstIndex",i?.firstIndex),Ei(n,"GeometryLike.baseVertex",i?.baseVertex);const u=!!i?.indexBuffer,d=i?.geometry??(i&&Pc in i?i:void 0),h=l.firstVertex??i?.firstVertex??0,m=l.vertices??i?.vertexCount??r.vertices??3,g=l.firstIndex??i?.firstIndex??0,x=l.indices??i?.indexCount??0,b=l.baseVertex??i?.baseVertex??0;if(u)Yg(n,"index",g,x,d?.indexCount);else if(l.indices!==void 0||l.firstIndex!==void 0||l.baseVertex!==void 0)throw pf(`${n}.draw`,"Index range needs an indexed geometry.");return u||Yg(n,"vertex",h,m,d?.vertexCount),{instanceCount:l.instances??r.instances??i?.instanceCount??1,firstInstance:l.firstInstance??r.firstInstance??0,vertexCount:m,firstVertex:h,indexCount:x,firstIndex:g,baseVertex:b}}function $y(n){const i=n?.topology??"triangle-list";return n?.stripIndexFormat??(i.endsWith("strip")?n?.indexFormat:void 0)}function qg(n,i,r,l){const u=n?.topology??"triangle-list",f=$y(n),d=f?{topology:u,stripIndexFormat:f}:{topology:u};return i!==void 0&&(d.cullMode=i),r!==void 0&&(d.frontFace=r),l&&(d.unclippedDepth=!0),d}function Yg(n,i,r,l,u){if(!(u===void 0||r+l<=u))throw pf(`${n}.draw`,`${i} range [${r}, ${r+l}) exceeds parent geometry ${i} count ${u}.`)}function Ei(n,i,r){if(!(r===void 0||Number.isInteger(r)&&r>=0))throw pf(`${n}.draw`,`${i} must be an integer >= 0; received ${String(r)}.`)}function Ai(n,i,r){if(r!==void 0&&!(Number.isInteger(r)&&r>=0))throw new ie({code:"VGPU-R1-DRAW-COUNT",message:`${i} of '${n}' must be an integer >= 0; received ${String(r)}. Use 0 only when you want to issue a valid draw with no vertices/instances.`,where:`${n}.draw`})}function XE(n,i){const r=i.blend===void 0?void 0:Vy(n,i.blend),l=i.writeMask===void 0?void 0:Hy(n,i.writeMask),u=i.colors===void 0?void 0:QE(n,i.colors),f=u?`${t0(r,l)}@${u.map(dA).join("@")}`:r||l!==void 0?t0(r,l):void 0;return{blendState:r,writeMask:l,colorStates:u,fragmentKey:f}}function QE(n,i){if(!Array.isArray(i))throw Kc(n,`colors must be an array; received ${Ze(i)}.`);return i.map((r,l)=>{if(r==null)return null;if(typeof r!="object"||Array.isArray(r))throw Kc(n,`colors[${l}] must be null or { blend?, writeMask? }; received ${Ze(r)}.`);const u=r.blend===void 0?void 0:Vy(`${n}.colors[${l}]`,r.blend),f=r.writeMask===void 0?void 0:Hy(`${n}.colors[${l}]`,r.writeMask);return!u&&f===void 0?null:{blendState:u,writeMask:f}})}function Vy(n,i){if(i==="alpha")return Gl({src:"src-alpha",dst:"one-minus-src-alpha"},{src:"one",dst:"one-minus-src-alpha"});if(i==="premultiplied")return Gl({src:"one",dst:"one-minus-src-alpha"},{src:"one",dst:"one-minus-src-alpha"});if(i==="additive")return Gl({src:"one",dst:"one"},{src:"one",dst:"one"});if(typeof i!="object"||i===null||!Xg(i.color))throw fg(n,i);const r=i.color,l=i.alpha;if(l!==void 0&&!Xg(l))throw fg(n,i);return Gl(r,l??r)}function Xg(n){return typeof n=="object"&&n!==null&&typeof n.src=="string"&&typeof n.dst=="string"}function Gl(n,i){return{color:Qg(n),alpha:Qg(i)}}function Qg(n){return{srcFactor:n.src,dstFactor:n.dst,operation:n.op??"add"}}function KE(n,i,r){if(i.blendConstant===void 0)return{};const l=i.blendConstant;if(!Array.isArray(l)||l.length!==4||l.some(u=>typeof u!="number"||!Number.isFinite(u)))throw dg(n,`received ${Ze(l)}; expected [r, g, b, a] finite numbers.`);if(!ZE(r).some(u=>u&&PE(u)))throw dg(n,`no color target's effective blend uses a "constant"/"one-minus-constant" factor (colors[i].blend replaces the top-level blend for that target), so blendConstant would have no effect.`);return{blendConstant:{r:l[0],g:l[1],b:l[2],a:l[3]}}}function ZE(n){return n.colorStates?n.colorStates.map(i=>i?.blendState??n.blendState):[n.blendState]}function PE(n){return[n.color.srcFactor,n.color.dstFactor,n.alpha.srcFactor,n.alpha.dstFactor].some(i=>i==="constant"||i==="one-minus-constant")}function WE(n,i){if(i===void 0)return{};if(typeof i!="object"||i===null||Array.isArray(i))throw Hl(n,`received ${Ze(i)}; expected { vertex?, fragment? } entry point names.`);return i}function JE(n,i,r){const l=n.entryPoints.find(f=>f.stage==="vertex"),u=n.entryPoints.find(f=>f.stage==="fragment");if(!(i===l&&r===u))return`en~${i?.name??""}~${r?.name??""}`}function eA(n,i,r){const l=r.cull===void 0?void 0:nA(i,r.cull),u=r.frontFace===void 0?void 0:iA(i,r.frontFace),f=r.unclippedDepth===void 0?void 0:tA(n,i,r.unclippedDepth);return{cullMode:l,frontFace:u,unclippedDepth:f}}function tA(n,i,r){if(typeof r!="boolean")throw pg(i,`received ${Ze(r)}; expected a boolean.`);if(r){if(!n.features.has("depth-clip-control"))throw pg(i,'the device lacks the "depth-clip-control" feature; request it at init: init({ requiredFeatures: ["depth-clip-control"] }) on an adapter that supports it.');return!0}}function nA(n,i){if(i==="none"||i==="front"||i==="back")return i;throw K1(n,i)}function iA(n,i){if(i==="ccw"||i==="cw")return i;throw Z1(n,i)}const Iy={depthWriteEnabled:!0,depthCompare:"less-equal"},Fy=["never","less","equal","less-equal","greater","not-equal","greater-equal","always"],Kg=-2147483648,Zg=2147483647;function Pg(n,i){if(n.depth)return{format:n.depth,...i.depthState??Iy,...i.stencilState??{}}}function aA(n,i,r){if(r.depth===void 0)return{};const l=rA(n,i,r.depth,r.geometry?.topology??"triangle-list");return{depthState:l,depthKey:sA(l)}}function rA(n,i,r,l){if(r===!1)return{depthWriteEnabled:!1,depthCompare:"always"};if(typeof r!="object"||r===null)throw Yn(i,`received ${Ze(r)}.`);if(r.write!==void 0&&typeof r.write!="boolean")throw Yn(i,`write must be a boolean; received ${Ze(r.write)}.`);if(r.compare!==void 0&&!Fy.includes(r.compare))throw Yn(i,`compare must be a GPUCompareFunction; received ${Ze(r.compare)}.`);if(r.bias!==void 0&&!Number.isInteger(r.bias))throw Yn(i,`bias must be an integer (WebGPU depthBias is i32); received ${Ze(r.bias)}.`);if(r.bias!==void 0&&(r.bias<Kg||r.bias>Zg))throw Yn(i,`bias must fit in the i32 range [${Kg}, ${Zg}] (WebGPU depthBias is i32); received ${Ze(r.bias)}.`);if(r.biasSlopeScale!==void 0&&!Number.isFinite(r.biasSlopeScale))throw Yn(i,`biasSlopeScale must be a finite number; received ${Ze(r.biasSlopeScale)}.`);if(r.biasClamp!==void 0&&!Number.isFinite(r.biasClamp))throw Yn(i,`biasClamp must be a finite number; received ${Ze(r.biasClamp)}.`);const u=r.bias??0,f=r.biasSlopeScale??0,d=r.biasClamp??0;if((u!==0||f!==0||d!==0)&&!l.startsWith("triangle"))throw Yn(i,`bias, biasSlopeScale, and biasClamp must be 0 for "${l}" topology.`);if(d!==0&&n.isCompatibilityMode)throw Yn(i,`biasClamp must be 0 on a compatibility-mode device; received ${Ze(r.biasClamp)}.`);return{depthWriteEnabled:r.write??!0,depthCompare:r.compare??"less-equal",...u!==0?{depthBias:u}:{},...f!==0?{depthBiasSlopeScale:f}:{},...d!==0?{depthBiasClamp:d}:{}}}function sA(n){return`${n.depthWriteEnabled?1:0}~${n.depthCompare}~${n.depthBias??0}~${n.depthBiasSlopeScale??0}~${n.depthBiasClamp??0}`}const lA=["keep","zero","replace","invert","increment-clamp","decrement-clamp","increment-wrap","decrement-wrap"];function uA(n,i){if(i.stencil===void 0)return{};const r=i.stencil;if(typeof r!="object"||r===null||Array.isArray(r))throw Ja(n,`received ${Ze(r)}; expected { front?, back?, readMask?, writeMask?, ref? }.`);const l=r.front===void 0?void 0:Wg(n,"front",r.front),u=r.back===void 0?void 0:Wg(n,"back",r.back);kc(n,"readMask",r.readMask),kc(n,"writeMask",r.writeMask),kc(n,"ref",r.ref);const f={...l?{stencilFront:l}:{},...u??l?{stencilBack:u??{...l}}:{},...r.readMask!==void 0?{stencilReadMask:r.readMask}:{},...r.writeMask!==void 0?{stencilWriteMask:r.writeMask}:{}},d=f.stencilFront!==void 0||f.stencilBack!==void 0||f.stencilReadMask!==void 0||f.stencilWriteMask!==void 0;return!d&&r.ref===void 0?{}:{...d?{stencilState:f,stencilKey:oA(f)}:{},...r.ref!==void 0?{stencilRef:r.ref}:{}}}function Wg(n,i,r){if(typeof r!="object"||r===null||Array.isArray(r))throw Ja(n,`${i} must be a { compare?, fail?, depthFail?, pass? } object; received ${Ze(r)}.`);if(r.compare!==void 0&&!Fy.includes(r.compare))throw Ja(n,`${i}.compare must be a GPUCompareFunction; received ${Ze(r.compare)}.`);for(const[l,u]of[["fail",r.fail],["depthFail",r.depthFail],["pass",r.pass]])if(u!==void 0&&!lA.includes(u))throw Ja(n,`${i}.${l} must be a GPUStencilOperation; received ${Ze(u)}.`);return{compare:r.compare??"always",failOp:r.fail??"keep",depthFailOp:r.depthFail??"keep",passOp:r.pass??"keep"}}function kc(n,i,r){if(r!==void 0&&(typeof r!="number"||!Number.isInteger(r)||r<0||r>4294967295))throw Ja(n,`${i} must be an integer in [0, 0xFFFFFFFF] (WebGPU GPUStencilValue is u32); received ${Ze(r)}.`)}function oA(n){return`st~${Jg(n.stencilFront)}~${Jg(n.stencilBack)}~${n.stencilReadMask??4294967295}~${n.stencilWriteMask??4294967295}`}function Jg(n){return n?`${n.compare},${n.failOp},${n.depthFailOp},${n.passOp}`:"default"}function e0(n,i){return{count:n.sampleCount??1,...i.multisampleState??{}}}function cA(n,i){if(i.multisample===void 0)return{};const r=i.multisample;if(typeof r!="object"||r===null||Array.isArray(r))throw Fl(n,`received ${Ze(r)}; expected { alphaToCoverage?, mask? }.`);if(r.alphaToCoverage!==void 0&&typeof r.alphaToCoverage!="boolean")throw Fl(n,`alphaToCoverage must be a boolean; received ${Ze(r.alphaToCoverage)}.`);if(r.mask!==void 0&&(typeof r.mask!="number"||!Number.isInteger(r.mask)||r.mask<0||r.mask>4294967295))throw Fl(n,`mask must be an integer in [0, 0xFFFFFFFF] (WebGPU GPUSampleMask is u32); received ${Ze(r.mask)}.`);const l={...r.alphaToCoverage!==void 0?{alphaToCoverageEnabled:r.alphaToCoverage}:{},...r.mask!==void 0?{mask:r.mask}:{}};return l.alphaToCoverageEnabled===void 0&&l.mask===void 0?{}:{multisampleState:l,multisampleKey:fA(l)}}function fA(n){return`ms~${n.alphaToCoverageEnabled?1:0}~${n.mask??4294967295}`}function Hy(n,i){if(!Array.isArray(i))throw hg(n,Ze(i));let r=0;for(const l of i)if(l==="r")r|=1;else if(l==="g")r|=2;else if(l==="b")r|=4;else if(l==="a")r|=8;else throw hg(n,Ze(l));return r}function t0(n,i){return`${qy(n)};${i??15}`}function qy(n){if(!n)return"none;none";const i=n.color,r=n.alpha;return`${i.srcFactor},${i.dstFactor},${i.operation};${r.srcFactor},${r.dstFactor},${r.operation}`}function dA(n){return n?`${n.blendState?qy(n.blendState):"inherit"};${n.writeMask??"inherit"}`:"inherit"}function Ze(n){if(typeof n=="string")return`"${n}"`;try{return JSON.stringify(n)??String(n)}catch{return String(n)}}function hA(n){return(we(n).depthState??Iy).depthWriteEnabled}function pA(n){const i=we(n),r=i.stencilState;if(!r||r.stencilWriteMask===0)return[];const l=i.cullMode??"none",u=[],f=(d,h)=>{if(h)for(const[m,g]of[["fail",h.failOp],["depthFail",h.depthFailOp],["pass",h.passOp]])g!==void 0&&g!=="keep"&&u.push(`${d}.${m}: "${g}"`)};return l!=="front"&&f("front",r.stencilFront),l!=="back"&&f("back",r.stencilBack),u}function mA(n,i,r,l={},u){n.encode(i,r,l,u)}function we(n){const i=Gy.get(n);if(!i)throw new TypeError("Invalid Draw instance");return i}function n0(n,i,r,l){const u=(async()=>{await bf(n.device),ht(n.device,`${i}.validation`);const f=tr(i,r,l);n.errorSink?await n.errorSink(f):console.error(f)})();return n.trackSettled?.(u),u}function gA(){const n=new Set;return{add(i){n.add(i)},delete(i){n.delete(i)},list(){return[...n]},markStale(i){for(const r of n)r.markStale(i)}}}function yA(n,i,r){return n?Array.isArray(n)?n:n[i]??r:r}function vA(n,i){const r=we(n);return Ey(r.reflection.bindings,i,r.visibility).map(bA)}function bA(n){return n.buffer?{...n,buffer:{...n.buffer,hasDynamicOffset:!0}}:n}function i0(n,i){if(Ny(n)&&!TE())throw X0(i)}function a0(n,i,r={}){if("geometry"in r)throw Yt("effect","effect() never accepts vertex buffers; use draw(gpu, { shader, geometry: geometry(gpu, descriptor) }).");const l=Pn(n,"effect"),u=Of(l);return new xA(l.device,jy(i),r,u.binds,void 0,u.pipelines,u.shaderModules,u.pipelineLayouts,f=>l.reportError(f),f=>{l.trackDelivery(f)})}const Yy=new WeakMap;class xA{get gpu(){return Pi(this).gpu}constructor(i,r,l={},u,f,d,h,m,g,x){const b=SA(r),D=new By(i,b,{shader:b,set:l.set,label:l.label??"effect",blend:l.blend,writeMask:l.writeMask},u,f,d,h,m,g,x);Yy.set(this,D)}set(i){return Pi(this).set(i),this}draw(i={}){Pi(this).draw(ou(i)?{target:i}:i)}compile(i){return Pi(this).compile(i).then(()=>this)}compileSync(i){return Pi(this).compileSync(i),this}encode(i,r,l={},u){mA(Pi(this),i,r,l,u)}get[au](){return Pi(this)[au]}}function Pi(n){const i=Yy.get(n);if(!i)throw new TypeError("Invalid Effect instance");return i}function SA(n){return wA(n)?n:`
|
|
13
|
+
struct VgpuFullscreenVertexOut {
|
|
14
|
+
@builtin(position) position: vec4f,
|
|
15
|
+
@location(0) uv: vec2f,
|
|
16
|
+
};
|
|
17
|
+
@vertex fn vgpu_fullscreen_vs(@builtin(vertex_index) vi: u32) -> VgpuFullscreenVertexOut {
|
|
18
|
+
var pos = array<vec2f, 3>(vec2f(-1.0, -1.0), vec2f(3.0, -1.0), vec2f(-1.0, 3.0));
|
|
19
|
+
var uv = array<vec2f, 3>(vec2f(0.0, 1.0), vec2f(2.0, 1.0), vec2f(0.0, -1.0));
|
|
20
|
+
var out: VgpuFullscreenVertexOut;
|
|
21
|
+
out.position = vec4f(pos[vi], 0.0, 1.0);
|
|
22
|
+
out.uv = uv[vi];
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
${n}`}function wA(n){return dy(n,"effect.wgsl").entryPoints.some(i=>i.stage==="vertex")}function EA(n,i){return TA(Pn(n,"frame")).frame(i)}const AA=lu("frame-runner");function TA(n){return n.service(AA,i=>{const r=Uy(i);return new kA(()=>{let l=()=>{};const u=new MA(i.device,void 0,f=>i.reportError(f),f=>{i.trackDelivery(f)},()=>l());return l=i.own("scheduler",()=>u.cancel()),u},()=>r.tick(),l=>i.own("scheduler",()=>l.stop()))})}class MA{device;defaultTarget;errorSink;trackSettled;releaseLifecycle;done=Promise.resolve();#e;#t=[];#n=new Set;#i=new Set;#a=!1;#r=!1;#l=!1;constructor(i,r,l,u,f){this.device=i,this.defaultTarget=r,this.errorSink=l,this.trackSettled=u,this.releaseLifecycle=f,ht(i,"Frame.constructor"),this.#e=i.gpu.createCommandEncoder({label:"vgpu.frame"})}pass(i,r){if(this.#r)throw vg("Frame.pass");ht(this.device,"Frame.pass");const l=ou(i),u=typeof r=="function"?r:N=>N.draw(r),f=l?i:i.target??this.defaultTarget;if(!f)throw Zc("Frame.pass");if(Ny(f)&&this.#a)throw X0("Frame.pass");const d=l?void 0:i.clear,h=d===!1;if(h&&f.sampleCount===4)throw P1();const m=l?void 0:i.clearDepth;if(m!==void 0){if(typeof m!="number"||!(m>=0&&m<=1))throw mg(m);if(h)throw W1();if(!f.depth)throw mg(m,"but the target has no depth attachment, so clearDepth would have no effect.","Create the target with depth: true (or a depth format), or drop clearDepth.")}const g=l?void 0:i.clearStencil;if(g!==void 0){if(typeof g!="number"||!Number.isInteger(g)||g<0||g>4294967295)throw gg(`received ${String(g)}; expected an integer in [0, 0xFFFFFFFF] (WebGPU GPUStencilValue).`);if(h)throw J1();const N=f.depth?.format;if(!fs(N))throw gg(`received ${String(g)}, but the target's depth format ${N?`"${N}"`:"(none)"} has no stencil aspect, so clearStencil would have no effect.`)}const x=l?void 0:i.depthReadOnly;if(x!==void 0&&typeof x!="boolean")throw ea(`received ${Ri(x)}; expected a boolean.`,"Pass depthReadOnly: true to open the pass with a read-only depth attachment, or omit it.");if(x){if(!f.depth)throw ea("is set, but the target has no depth attachment, so there is nothing to make read-only.","Create the target with depth: true (or a depth format), or drop depthReadOnly.");if(f.sampleCount===4)throw eS();if(m!==void 0)throw ea("cannot be combined with clearDepth; a read-only depth aspect omits its load/store ops and is never cleared.","Remove clearDepth, or drop depthReadOnly.");if(g!==void 0)throw ea("cannot be combined with clearStencil; a read-only stencil aspect omits its load/store ops and is never cleared.","Remove clearStencil, or drop depthReadOnly.")}const b=l?void 0:UA(i.viewport,this.device.gpu.limits,f.size),D=l?void 0:NA(i.scissor,f.size),$=[];let k;try{const N=l||i.timer===void 0?void 0:this.#s(i.timer,f,$,zA),Z=(l||i.visibility===void 0?void 0:this.#s(i.visibility,f,$,_A))?.occlusion;let I=f.renderPassDescriptor({clear:d===void 0||d===!0||d===!1?f.clearColor??Mf:d,preserve:h,clearDepth:m,clearStencil:g,depthReadOnly:x});N?.timestampWrites&&(I={...I,timestampWrites:N.timestampWrites}),Z&&(I={...I,occlusionQuerySet:Z.querySet}),k=this.#e.beginRenderPass(I),b&&k.setViewport(b.x,b.y,b.width,b.height,b.minDepth,b.maxDepth),D&&k.setScissorRect(D[0],D[1],D[2],D[3]),this.#l=!0;try{u(new DA(k,f,this.#t,x===!0,Z,this,F=>{if(ht(this.device,F),this.#r)throw vg(F)}))}finally{this.#l=!1}}catch(N){this.#o($),Ht(this.#t),this.#t.length=0,my(this.device);try{k?.end()}catch{}throw N}yy(this.device,k,this.#t)}submit(){if(this.#a||this.#r)return;ht(this.device,"Frame.submit"),this.#a=!0,this.releaseLifecycle?.();for(const u of this.#f())u.finalizeFrame(this,this.#e);let i;const r=this.#t[0]?.context;r&&ls(this.device,r);try{i=this.#e.finish()}catch(u){this.#c(this.#u());const f=r?on(this.device):void 0;Ht(this.#t),f&&Ht([f]);const d=f?.context??r;if(!d)throw u;this.done=this.#h(this.#d(d.label,d.group,u));return}if(r){const u=on(this.device);u&&(this.#t[0]=this.#t[0]?tu(u,this.#t[0]):u)}const l=this.#t[0]?.context;l&&ls(this.device,l);try{this.device.gpu.queue.submit([i])}catch(u){this.#c(this.#u());const f=l?on(this.device):void 0;Ht(this.#t),f&&Ht([f]);const d=f?.context??l;if(!d)throw u;this.done=this.#h(this.#d(d.label,d.group,u));return}if(l){const u=on(this.device);u&&(this.#t[0]=this.#t[0]?tu(u,this.#t[0]):u)}for(const u of this.#f())u.frameSubmitted(this);this.#c(this.#i),this.done=this.#h(gy(this.device,this.#t,{errorSink:this.errorSink}))}cancel(){if(!this.#r){if(this.#a)throw gS("Frame.cancel");if(this.#l)throw mS("Frame.cancel");this.#r=!0,this.releaseLifecycle?.(),this.#c(this.#u()),this.#n.clear(),this.#i.clear(),Ht(this.#t),this.#t.length=0}}#c(i){for(const r of[...i])r.frameAbandoned(this)}#u(){return[...this.#n,...this.#i]}#o(i){for(const r of[...i])this.#n.delete(r),this.#i.add(r)}#f(){return[...this.#n].filter(i=>!this.#i.has(i))}#s(i,r,l,u){const f=jE(i);if(!f)throw u(i);let d;try{d=f[Cf]({frame:this,device:this.device,target:r})}catch(h){throw this.#o(this.#n),h}return this.#n.add(d.owner),l.push(d.owner),d}async#d(i,r,l){await bf(this.device),ht(this.device,"Frame.validation");const u=tr(i,r,l);this.errorSink?await this.errorSink(u):console.error(u)}#h(i){return this.trackSettled?.(i),i}}class DA{encoder;target;validations;depthReadOnly;occlusionSource;frame;assertFrameOpen;#e=!1;constructor(i,r,l,u=!1,f,d,h){this.encoder=i,this.target=r,this.validations=l,this.depthReadOnly=u,this.occlusionSource=f,this.frame=d,this.assertFrameOpen=h}draw(i,r={}){this.assertFrameOpen?.("FramePass.draw");const l=CA(i);this.depthReadOnly&&RA(l,this.target),l.encode(this.encoder,this.target,r,u=>this.validations.push(u))}occlusion(i,r){if(this.assertFrameOpen?.("FramePass.occlusion"),!this.occlusionSource)throw iS();if(this.#e)throw aS();const l=this.occlusionSource.beginQuery(i,this.frame);this.encoder.beginOcclusionQuery(l),this.#e=!0;try{typeof r=="function"?r():this.draw(r)}finally{this.#e=!1,this.encoder.endOcclusionQuery()}}bundles(...i){if(this.assertFrameOpen?.("FramePass.bundles"),this.depthReadOnly)throw ea("pass cannot replay bundles: bundle records bundles with writable depth/stencil, and WebGPU only executes read-only-recorded bundles in a read-only pass.","Encode the draws directly with pass.draw(...) inside the depthReadOnly pass.","FramePass.bundles");const r=i.map(l=>kE(l)??OA());for(const l of r)l.assertReplayable(this.target);this.encoder.executeBundles(r.map(l=>l.gpu))}}function RA(n,i){if(n.writesDepth())throw ea(`pass cannot encode draw '${n.label}': its depth state writes depth (the default is write: true). Give the draw depth: { write: false } (or depth: false to disable depth testing).`,"Use depth: { write: false } on the draw, or open the pass without depthReadOnly.","FramePass.draw");if(fs(i.depth?.format)){const r=n.stencilWritingOps();if(r.length)throw ea(`pass cannot encode draw '${n.label}': its stencil ops can write (${r.join(", ")}), and the pass's stencil aspect is read-only too.`,'Use "keep" for those ops or stencil writeMask: 0, or open the pass without depthReadOnly.',"FramePass.draw")}}function CA(n){const i=NE(n);if(!i)throw new TypeError("Invalid Effect instance: pass.draw() expects a Draw or an Effect created by this library.");return i}function OA(){throw new ie({code:"VGPU-R3-BUNDLE-INVALID",message:"p.bundles() expected bundles created by bundle(gpu, { target }, cb).",where:"FramePass.bundles"})}function zA(n){return Xa(`FramePassOptions.timer received ${Ri(n)}; expected a TimerSpan from timer.span(name).`,'Create const passTimer = timer(gpu) once, then pass passTimer.span("name") per pass.',"Frame.pass")}function _A(n){return nS(`FramePassOptions.visibility received ${Ri(n)}; expected a Visibility from visibility(gpu).`,"Create const vis = visibility(gpu) once, then pass { target, visibility: vis } per pass.","Frame.pass")}function UA(n,i,r){if(n===void 0)return;if(typeof n!="object"||n===null||Array.isArray(n))throw Xn(`received ${Ri(n)}; expected { x?, y?, width, height, minDepth?, maxDepth? }.`);const{x:l=0,y:u=0,width:f,height:d,minDepth:h=0,maxDepth:m=1}=n;for(const[D,$]of[["x",l],["y",u],["width",f],["height",d],["minDepth",h],["maxDepth",m]])if(typeof $!="number"||!Number.isFinite($))throw Xn(`${D} received ${Ri($)}; expected a finite number.`);const g=i.maxTextureDimension2D,x=g*2,b=`target is ${r[0]}x${r[1]}px, device maxTextureDimension2D is ${g}`;if(!(f>=0&&f<=g))throw Xn(`width ${f} is outside [0, ${g}] (${b}).`);if(!(d>=0&&d<=g))throw Xn(`height ${d} is outside [0, ${g}] (${b}).`);if(!(l>=-x&&l+f<=x-1))throw Xn(`x ${l} with width ${f} is outside [${-x}, ${x-1}] (${b}).`);if(!(u>=-x&&u+d<=x-1))throw Xn(`y ${u} with height ${d} is outside [${-x}, ${x-1}] (${b}).`);if(!(h>=0&&h<=1))throw Xn(`minDepth ${h} is outside [0, 1].`);if(!(m>=0&&m<=1))throw Xn(`maxDepth ${m} is outside [0, 1].`);if(!(h<=m))throw Xn(`minDepth ${h} exceeds maxDepth ${m}.`);return{x:l,y:u,width:f,height:d,minDepth:h,maxDepth:m}}function NA(n,i){if(n===void 0)return;if(!Array.isArray(n)||n.length!==4)throw zc(`received ${Ri(n)}; expected [x, y, width, height].`);const[r,l,u,f]=n;for(const[m,g]of[["x",r],["y",l],["width",u],["height",f]])if(typeof g!="number"||!Number.isInteger(g)||g<0)throw zc(`${m} received ${Ri(g)}; expected a non-negative integer.`);const[d,h]=i;if(r+u>d||l+f>h)throw zc(`[${r}, ${l}, ${u}, ${f}] exceeds the target's current size ${d}x${h}px (x + width <= ${d}, y + height <= ${h}).`);return[r,l,u,f]}function Ri(n){return typeof n=="string"?`'${n}'`:Array.isArray(n)?`[${n.map(i=>Ri(i)).join(", ")}]`:typeof n=="object"&&n!==null?"an object":String(n)}function LA(n){const i=n?.code;return i==="VGPU-DEVICE-DISPOSED"||i==="VGPU-DEVICE-LOST"}class kA{createFrame;advance;trackLoop;#e=!1;constructor(i,r,l){this.createFrame=i,this.advance=r,this.trackLoop=l}frame(i){if(this.#e||AE())throw Q0();this.#e=!0,ME();try{this.advance();const r=this.createFrame();if(i)try{i(r)}finally{try{r.submit()}catch(l){if(!LA(l))throw l}}return r}finally{DE(),this.#e=!1}}loop(i,r={}){let l=!1;const u=globalThis.requestAnimationFrame??(D=>setTimeout(()=>D(performance.now()),16)),f=globalThis.cancelAnimationFrame??(D=>clearTimeout(D)),d=r.fps&&r.fps>0?1e3/r.fps:0;let h,m=0;const g=D=>{l||(jA(D,h,d)&&(h=D,this.frame(i)),l||(m=u(g)))};m=u(g);let x;const b={stop(){l=!0,f(m),x?.(),x=void 0}};return x=this.trackLoop?.(b),b}}function jA(n,i,r){return i===void 0||r<=0?!0:n-i>=r}function r0(n,i){return new rf(Pn(n,"target").device,i)}class rf{device;options;resourceIdentity=ru("render-target");#e=new su;#t=new Set;#n;#i;#a;#r;#l;constructor(i,r){this.device=i,this.options=r,W2(r,i),this.#l=r.clearColor===void 0?Mf:nu(r.clearColor,"target.clearColor"),this.#n=r.size,this.#i=this.#f(),this.#a=this.sampleCount===4?this.#s():void 0,this.#r=this.#d()}get gpu(){return this.color.gpu}get size(){return this.#n}get texelSize(){return[1/this.#n[0],1/this.#n[1]]}get color(){return this.#i[0]}get colors(){return this.#i}get depth(){return this.#r}get format(){return Xl(this.options)[0]?.format??"rgba8unorm"}get clearColor(){return Df(this.#l)}set clearColor(i){this.#l=nu(i,"target.clearColor")}get sampleCount(){return My(this.options)}resize(i){Ry(this.#n,i)||this.#c(i)}async read(){return this.color.read()}async readFloats(){return this.color.readFloats()}onDestroy(i){return this.#e.onDestroy(this,i)}onTexturesRecreated(i){return this.#t.add(i),()=>{this.#t.delete(i)}}destroy(){this.#e.emit(this),this.#t.clear(),this.#o()}renderPassDescriptor(i={}){const{clear:r=[0,0,0,1],preserve:l,clearDepth:u,clearStencil:f,depthReadOnly:d}=i;return{colorAttachments:this.#i.map((h,m)=>eE(h,this.#a?.[m],r,l)),depthStencilAttachment:this.#r?tE(this.#r,l,u,f,d):void 0}}#c(i){this.#o(),this.#n=[i[0],i[1]],this.#i=this.#f(),this.#a=this.sampleCount===4?this.#s():void 0,this.#r=this.#d(),this.#u()}#u(){for(const i of[...this.#t])i()}#o(){for(const i of this.#i)i.destroy();for(const i of this.#a??[])i.destroy();this.#r?.destroy()}#f(){return Xl(this.options).map((i,r)=>this.device.createTexture({size:this.#n,format:i.format,usage:["render_attachment","texture_binding","copy_src"],sampleCount:1,label:this.options.label?`${this.options.label}.color${r}.resolve`:void 0}))}#s(){return Xl(this.options).map((i,r)=>this.device.createTexture({size:this.#n,format:i.format,usage:["render_attachment"],sampleCount:4,label:this.options.label?`${this.options.label}.color${r}`:void 0}))}#d(){const i=Ty(this.options);return i?this.device.createTexture({size:this.#n,format:i,usage:["render_attachment","texture_binding"],sampleCount:this.sampleCount,label:this.options.label?`${this.options.label}.depth`:void 0}):void 0}}function Ha(n,i,r="read-write"){const l=Pn(n,"storage"),u=typeof r=="string"?{access:r}:r,f=GA(l.device,i,u.access??"read-write",void 0,u.indirect??!1);return P0(l,f,d=>d.destroy(),d=>{f.onDestroy(d)})}class zf{size;access;buffer;constructor(i,r){this.buffer=i,this.access=r,this.size=i.options.size}static create(i,r,l,u,f=!1){const d=f?["storage","copy_dst","copy_src","indirect"]:["storage","copy_dst","copy_src"],h=i.createBuffer({size:r,usage:d,label:u});return new zf(h,l)}read(){return this.buffer.read(this.size)}write(i,r=0){this.buffer.write(BA(i),r)}get gpu(){return this.buffer.gpu}get resourceIdentity(){return this.buffer.resourceIdentity}onDestroy(i){return this.buffer.onDestroy(i)}destroy(){this.buffer.destroy()}}function GA(n,i,r,l,u=!1){return zf.create(n,i,r,l,u)}function BA(n){if(n instanceof ArrayBuffer||ArrayBuffer.isView(n))return n;throw new TypeError("StorageBuffer.write() requires ArrayBuffer or ArrayBufferView.")}function $A(n,i,r,l={}){const u=Pn(n,"pingPong");return IA(u.device,i,r,l,f=>VA(u,f))}function VA(n,i){return P0(n,i,r=>r.destroy(),r=>{i.onDestroy(r)})}function IA(n,i,r,l={},u=FA){const f=[s0(i),s0(r)],d={...l,size:f},h=u(new rf(n,l0(d,l.label,"ping"))),m=u(new rf(n,l0(d,l.label,"pong")));return new HA([h,m])}function FA(n){return n}class HA{halves;#e=0;constructor(i){this.halves=i}get read(){return this.halves[this.#e]}get write(){return this.halves[this.#e^1]}swap(){this.#e^=1}}function s0(n){return Math.max(1,Math.floor(n))}function l0(n,i,r){return i?{...n,label:`${i}.${r}`}:n}const jc=8,qA=globalThis.GPUMapMode?.READ??1;function YA(n,i){return new XA(n,i)}class XA{querySet;capacity;#e;#t;#n;#i;#a;#r=0;#l=0;#c=-1;#u;#o=0;#f=0;#s=!1;#d=!1;constructor(i,r){this.capacity=r.capacity;const l=r.label??"vgpu.query-ring";this.#e=l;const u=r.capacity*jc;this.querySet=i.gpu.createQuerySet({type:r.type,count:r.capacity,label:l}),this.#t=i.createBuffer({size:u,usage:["query_resolve","copy_src"],label:`${l}.resolve`}),this.#n=Array.from({length:r.depth??3},(f,d)=>({buffer:i.createBuffer({size:u,usage:["map_read","copy_dst"],label:`${l}.staging${d}`}),mapPending:!1,retired:!1})),this.#i=r.trackSettled,this.#a=r.errorSink}encodeResolve(i,r){if(this.#u=void 0,this.#s||r<=0)return!1;const l=this.#h();if(!l)return!1;const u=Math.min(r,this.capacity);return i.resolveQuerySet(this.querySet,0,u,this.#t.gpu,0),i.copyBufferToBuffer(this.#t.gpu,0,l.buffer.gpu,0,u*jc),this.#u={staging:l,usedCount:u,seq:this.#l},this.#l+=1,this.#r+=1,!0}onSubmitted(i){const r=this.#u;if(this.#u=void 0,!r)return;r.staging.mapPending=!0,this.#o+=1;const l=r.staging.buffer.gpu.mapAsync(qA).then(()=>{const u=this.#m(r);r.seq<=this.#c||(this.#c=r.seq,i(u))}).catch(u=>{this.#y(u)}).finally(()=>{r.staging.mapPending=!1,this.#o-=1,this.#g()});this.#i?.(l)}#h(){for(let i=0;i<this.#n.length;i+=1){const r=this.#n[this.#r%this.#n.length];if(!r.retired)return r.mapPending?void 0:r;this.#r+=1}}#m(i){let r;try{r=new BigUint64Array(i.staging.buffer.gpu.getMappedRange().slice(0,i.usedCount*jc))}catch(l){throw this.#p(i.staging),l}try{i.staging.buffer.gpu.unmap()}catch(l){throw i.staging.retired=!0,l}return r}#p(i){try{i.buffer.gpu.unmap()}catch{i.retired=!0}}retain(){this.#f+=1}release(){this.#f>0&&(this.#f-=1),this.#g()}dispose(){this.#s||(this.#s=!0,this.#u=void 0,this.#g())}#g(){if(!(!this.#s||this.#d||this.#o>0||this.#f>0)){this.#d=!0,this.querySet.destroy(),this.#t.dispose();for(const i of this.#n)i.buffer.dispose()}}#y(i){const r=pS(this.#e,i),l=this.#a;if(!l){console.error(r);return}try{Promise.resolve(l(r)).catch(u=>{console.error(u)})}catch(u){console.error(u)}}}const u0=32,sf=4096,o0=sf/2,QA=1/1e6;class KA{name;owner;constructor(i,r){this.name=i,this.owner=r}[Cf](i){return{owner:this.owner,timestampWrites:this.owner.attachSpan(this,i.frame,i.device)}}}function ZA(n){const i=Pn(n,"timer");return CS(i,r=>new PA(i.device,r))}class PA{#e;#t;#n=new Map;#i=new Set;#a;#r=u0*2;#l=u0*2;#c;#u=[];#o=new Set;#f=0;#s;#d=0;#h=-1;#m=new Map;#p=!1;constructor(i,r={}){if(!i.features.has("timestamp-query"))throw Xa('timer(gpu) needs the "timestamp-query" device feature — request it at init: init({ requiredFeatures: ["timestamp-query"] }).','Pass init({ requiredFeatures: ["timestamp-query"] }) on an adapter that supports it; gate optional timing on gpu.device.features.has("timestamp-query").');this.#e=i,this.#t=r,this.#a=this.#x()}span(i){if(this.#v("Timer.span"),typeof i!="string"||i.length===0)throw Xa(`span name received ${JA(i)}; expected a non-empty string.`,'Name each timed pass, e.g. timer.span("shadows").',"Timer.span");let r=this.#n.get(i);return r||(r=new KA(i,this),this.#n.set(i,r)),r}onResults(i){return this.#v("Timer.onResults"),this.#i.add(i),()=>{this.#i.delete(i)}}dispose(){this.#p||(this.#p=!0,this.#i.clear(),this.#n.clear(),this.#o.clear(),this.#u=[],this.#s=void 0,this.#a.dispose(),this.#t.onDispose?.())}attachSpan(i,r,l){if(this.#v("Frame.pass"),l!==this.#e)throw Xa(`span '${i.name}' belongs to a timer created on a different gpu; timestamp queries cannot cross devices.`,"Create one timer(gpu) per gpu and use its spans only with that gpu's frames.","Frame.pass");if(r!==this.#c&&this.#g(r),this.#o.has(i.name))throw Xa(`duplicate span '${i.name}' in one frame; each result key holds a single begin/end pair per frame.`,`Use one timer.span(name) per pass per frame, e.g. timer.span("${i.name}-2") for the second pass.`,"Frame.pass");if(this.#o.size>=o0)throw tS(o0,sf);this.#o.add(i.name);const u=this.#o.size*2-2;if(this.#l<u+2&&(this.#l=u+2),!(u+2>this.#a.capacity))return this.#f=u+2,this.#u.push({name:i.name,begin:u}),this.#S(r),{querySet:this.#a.querySet,beginningOfPassWriteIndex:u,endOfPassWriteIndex:u+1}}finalizeFrame(i,r){this.#s=void 0,!(this.#p||i!==this.#c||this.#f===0)&&this.#a.encodeResolve(r,this.#f)&&(this.#s=[...this.#u])}frameSubmitted(i){if(this.#b(i),i!==this.#c||this.#p)return;const r=this.#s;if(this.#s=void 0,!r||r.length===0)return;const l=this.#d;this.#d+=1,this.#a.onSubmitted(u=>{l<=this.#h||(this.#h=l,this.#y(r,u))})}frameAbandoned(i){i===this.#c&&(this.#s=void 0),this.#b(i)}#g(i){this.#l>this.#a.capacity&&(this.#a.dispose(),this.#r=Math.min(sf,WA(this.#l)),this.#a=this.#x()),this.#l=this.#r,this.#c=i,this.#u=[],this.#o.clear(),this.#f=0}#y(i,r){const l={};for(const{name:f,begin:d}of i){const h=r[d]??0n,m=r[d+1]??0n;l[f]=m>h?Number(m-h)*QA:0}const u=Object.freeze(l);for(const f of[...this.#i])try{f(u)}catch(d){console.error(d)}}#S(i){this.#m.has(i)||(this.#m.set(i,this.#a),this.#a.retain())}#b(i){const r=this.#m.get(i);r&&(this.#m.delete(i),r.release())}#x(){return YA(this.#e,{type:"timestamp",capacity:this.#r,label:"vgpu.timer",trackSettled:this.#t.trackSettled,errorSink:this.#t.errorSink})}#v(i){if(this.#p)throw Xa("the timer is disposed.","Create a new timer with timer(gpu).",i)}}function WA(n){let i=1;for(;i<n;)i*=2;return i}function JA(n){return typeof n=="string"?`'${n}'`:String(n)}function c0(n){return AS("browser",n)}const f0=8,d0=64,h0=8,lf=16,rs={x0:0,y0:0,x1:1160,y1:812},p0=256,ps=`
|
|
26
|
+
struct Params {
|
|
27
|
+
// visible world rect: x0, y0, x1, y1
|
|
28
|
+
rect : vec4f,
|
|
29
|
+
// viewportW, viewportH, scale (px per world unit), time (seconds)
|
|
30
|
+
view : vec4f,
|
|
31
|
+
// massCount, disturbanceCount, couplingCount, dt
|
|
32
|
+
counts : vec4f,
|
|
33
|
+
// rowsScreen, stepScreen, amp, alpha
|
|
34
|
+
layer : vec4f,
|
|
35
|
+
// lineWidth, dz, parallaxX, showResidue
|
|
36
|
+
layer2 : vec4f,
|
|
37
|
+
// columns, rows, laneCount, plinthCount
|
|
38
|
+
grid : vec4f,
|
|
39
|
+
fill : vec4f,
|
|
40
|
+
// padded field rect used by the field texture: x0, y0, x1, y1
|
|
41
|
+
fieldRect : vec4f,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Storage rather than uniform: every array below is packed by hand into a Float32Array, and this
|
|
45
|
+
// keeps the whole parameter block on the same footing instead of splitting the packing across two
|
|
46
|
+
// binding conventions.
|
|
47
|
+
@group(0) @binding(0) var<storage, read> P : Params;
|
|
48
|
+
|
|
49
|
+
// masses: 3 vec4 each
|
|
50
|
+
// 0: pos.xy, extent.xy
|
|
51
|
+
// 1: depth, rim, pull, lobe
|
|
52
|
+
// 2: phase, tint.rgb
|
|
53
|
+
@group(0) @binding(1) var<storage, read> massData : array<vec4f>;
|
|
54
|
+
|
|
55
|
+
// disturbances: 3 vec4 each
|
|
56
|
+
// 0: x, y, radius, amplitude
|
|
57
|
+
// 1: frequency, phase, statusIndex, energy
|
|
58
|
+
// 2: articulation, shoulder, unused, unused
|
|
59
|
+
@group(0) @binding(2) var<storage, read> distData : array<vec4f>;
|
|
60
|
+
|
|
61
|
+
// couplings: 1 vec4 each — fromMassIndex, toMassIndex, energy, unused
|
|
62
|
+
@group(0) @binding(3) var<storage, read> coupData : array<vec4f>;
|
|
63
|
+
|
|
64
|
+
// WGSL's pow() is exp2(y * log2(x)) and returns NaN for a negative base. The approved material
|
|
65
|
+
// squares plenty of signed quantities — offsets from a rim, distances either side of a ridge — so
|
|
66
|
+
// every one of those must be a multiplication, not a pow. A single NaN propagates through the
|
|
67
|
+
// baked field texture and blanks the entire sheet.
|
|
68
|
+
fn sq(x: f32) -> f32 { return x * x; }
|
|
69
|
+
fn quad(x: f32) -> f32 { let s = x * x; return s * s; }
|
|
70
|
+
|
|
71
|
+
fn massPos(i: u32) -> vec2f { return massData[i * 3u].xy; }
|
|
72
|
+
fn massExtent(i: u32) -> vec2f { return massData[i * 3u].zw; }
|
|
73
|
+
fn massShape(i: u32) -> vec4f { return massData[i * 3u + 1u]; }
|
|
74
|
+
fn massPhase(i: u32) -> f32 { return massData[i * 3u + 2u].x; }
|
|
75
|
+
fn massTint(i: u32) -> vec3f { return massData[i * 3u + 2u].yzw; }
|
|
76
|
+
`,eT=`
|
|
77
|
+
${ps}
|
|
78
|
+
|
|
79
|
+
@group(0) @binding(4) var prevTex : texture_2d<f32>;
|
|
80
|
+
@group(0) @binding(5) var prevSamp : sampler;
|
|
81
|
+
|
|
82
|
+
const DEPOSIT_RATE : f32 = 0.02;
|
|
83
|
+
const DECAY_RATE : f32 = 0.05;
|
|
84
|
+
|
|
85
|
+
@fragment
|
|
86
|
+
fn fs_main(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
87
|
+
let prev = textureSampleLevel(prevTex, prevSamp, uv, 0.0);
|
|
88
|
+
let dt = P.counts.w;
|
|
89
|
+
|
|
90
|
+
// Texel back to world space over the fixed residue rect.
|
|
91
|
+
let world = vec2f(
|
|
92
|
+
mix(P.fieldRect.x, P.fieldRect.z, uv.x),
|
|
93
|
+
mix(P.fieldRect.y, P.fieldRect.w, uv.y)
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
// --- process deposition -------------------------------------------------
|
|
97
|
+
var deposit = 0.0;
|
|
98
|
+
let dn = u32(P.counts.y);
|
|
99
|
+
for (var i = 0u; i < dn; i = i + 1u) {
|
|
100
|
+
let a = distData[i * 3u];
|
|
101
|
+
let b = distData[i * 3u + 1u];
|
|
102
|
+
let radius = a.z;
|
|
103
|
+
let energy = b.w;
|
|
104
|
+
if (energy <= 0.001) { continue; }
|
|
105
|
+
let d = length(vec2f(world.x - a.x, (world.y - a.y) * 1.5));
|
|
106
|
+
if (d > radius * 2.4) { continue; }
|
|
107
|
+
let falloff = exp(-sq(d / (radius * 1.7)));
|
|
108
|
+
deposit = deposit + energy * falloff;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// --- transfer deposition ------------------------------------------------
|
|
112
|
+
var coupleDeposit = 0.0;
|
|
113
|
+
let cn = u32(P.counts.z);
|
|
114
|
+
for (var i = 0u; i < cn; i = i + 1u) {
|
|
115
|
+
let c = coupData[i];
|
|
116
|
+
let a = massPos(u32(c.x));
|
|
117
|
+
let b = massPos(u32(c.y));
|
|
118
|
+
let v = b - a;
|
|
119
|
+
let l2 = dot(v, v);
|
|
120
|
+
if (l2 < 1.0) { continue; }
|
|
121
|
+
let u = dot(world - a, v) / l2;
|
|
122
|
+
if (u < -0.05 || u > 1.05) { continue; }
|
|
123
|
+
let proj = a + v * u;
|
|
124
|
+
let p = length(world - proj) / 44.0;
|
|
125
|
+
coupleDeposit = coupleDeposit + c.z * exp(-p * p * 1.4)
|
|
126
|
+
* exp(-quad((u - 0.5) / 0.5));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let r = prev.r + (deposit * DEPOSIT_RATE - prev.r * DECAY_RATE) * dt;
|
|
130
|
+
let g = prev.g + (coupleDeposit * DEPOSIT_RATE * 1.5 - prev.g * DECAY_RATE) * dt;
|
|
131
|
+
|
|
132
|
+
// Clamped so a pathological source can never drive residue unbounded.
|
|
133
|
+
return vec4f(clamp(r, 0.0, 4.0), clamp(g, 0.0, 4.0), 0.0, 1.0);
|
|
134
|
+
}
|
|
135
|
+
`,tT=`
|
|
136
|
+
${ps}
|
|
137
|
+
|
|
138
|
+
@group(0) @binding(4) var residueTex : texture_2d<f32>;
|
|
139
|
+
@group(0) @binding(5) var residueSamp : sampler;
|
|
140
|
+
|
|
141
|
+
// plinths: 3 vec4 each — session presence (FIELD-SPEC §15)
|
|
142
|
+
// 0: x, y, extentX, extentY
|
|
143
|
+
// 1: presence, articulation, parentIndex + 1 (0 = none), empty flag
|
|
144
|
+
// 2: shoulder, nested flag, unused, unused
|
|
145
|
+
@group(0) @binding(6) var<storage, read> plinthData : array<vec4f>;
|
|
146
|
+
|
|
147
|
+
const MAX_PLINTHS : u32 = ${lf}u;
|
|
148
|
+
|
|
149
|
+
const RES_X0 : f32 = ${rs.x0}.0;
|
|
150
|
+
const RES_Y0 : f32 = ${rs.y0}.0;
|
|
151
|
+
const RES_X1 : f32 = ${rs.x1}.0;
|
|
152
|
+
const RES_Y1 : f32 = ${rs.y1}.0;
|
|
153
|
+
|
|
154
|
+
fn residueAt(world: vec2f) -> vec2f {
|
|
155
|
+
let uv = vec2f(
|
|
156
|
+
(world.x - RES_X0) / (RES_X1 - RES_X0),
|
|
157
|
+
(world.y - RES_Y0) / (RES_Y1 - RES_Y0)
|
|
158
|
+
);
|
|
159
|
+
if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) { return vec2f(0.0); }
|
|
160
|
+
return textureSampleLevel(residueTex, residueSamp, uv, 0.0).rg;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** FIELD-SPEC §7 — the sheet sags toward mass. */
|
|
164
|
+
fn shiftAt(world: vec2f, t: f32) -> f32 {
|
|
165
|
+
var dy = 0.0;
|
|
166
|
+
let mn = u32(P.counts.x);
|
|
167
|
+
for (var i = 0u; i < mn; i = i + 1u) {
|
|
168
|
+
let pos = massPos(i);
|
|
169
|
+
let ext = massExtent(i);
|
|
170
|
+
let n = (world - pos) / ext;
|
|
171
|
+
let g = exp(-dot(n, n) * 0.85);
|
|
172
|
+
dy = dy + massShape(i).z * n.y * g * 1.6;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Coupling flattens the sheet between two machines (FIELD-SPEC §8).
|
|
176
|
+
let cn = u32(P.counts.z);
|
|
177
|
+
let res = residueAt(world);
|
|
178
|
+
for (var i = 0u; i < cn; i = i + 1u) {
|
|
179
|
+
let c = coupData[i];
|
|
180
|
+
let a = massPos(u32(c.x));
|
|
181
|
+
let b = massPos(u32(c.y));
|
|
182
|
+
let v = b - a;
|
|
183
|
+
let l2 = dot(v, v);
|
|
184
|
+
if (l2 < 1.0) { continue; }
|
|
185
|
+
let u = dot(world - a, v) / l2;
|
|
186
|
+
if (u < -0.05 || u > 1.05) { continue; }
|
|
187
|
+
let proj = a + v * u;
|
|
188
|
+
let off = (world.y - proj.y) / 62.0;
|
|
189
|
+
let env = exp(-off * off) * exp(-quad((u - 0.5) / 0.55));
|
|
190
|
+
dy = dy - off * 62.0 * 0.42 * env * (0.7 + 0.3 * sin(t * 2.4 - u * 6.0)) * c.z;
|
|
191
|
+
dy = dy - off * 10.0 * env * res.g;
|
|
192
|
+
}
|
|
193
|
+
return dy;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** FIELD-SPEC §6 — the height field. */
|
|
197
|
+
fn heightAt(world: vec2f, t: f32) -> f32 {
|
|
198
|
+
let x = world.x;
|
|
199
|
+
let y = world.y;
|
|
200
|
+
|
|
201
|
+
// Base medium.
|
|
202
|
+
var v = 3.1 * sin(x * 0.021 + y * 0.013) * sin(y * 0.017 - x * 0.008)
|
|
203
|
+
+ 1.7 * sin(x * 0.045 - y * 0.031)
|
|
204
|
+
+ 1.1 * sin(y * 0.062 + x * 0.017);
|
|
205
|
+
|
|
206
|
+
// Mass: a lobed well with a raised rim. Permanent.
|
|
207
|
+
let mn = u32(P.counts.x);
|
|
208
|
+
for (var i = 0u; i < mn; i = i + 1u) {
|
|
209
|
+
let pos = massPos(i);
|
|
210
|
+
let ext = massExtent(i);
|
|
211
|
+
let shape = massShape(i);
|
|
212
|
+
let ph = massPhase(i);
|
|
213
|
+
let n = (world - pos) / ext;
|
|
214
|
+
let r = length(n);
|
|
215
|
+
let th = atan2(n.y, n.x);
|
|
216
|
+
let lobe = shape.w;
|
|
217
|
+
let wob = 1.0 + lobe * sin(3.0 * th + ph) * 0.5 + lobe * 0.3 * sin(5.0 * th - ph);
|
|
218
|
+
let rr = r / max(0.35, wob);
|
|
219
|
+
v = v - shape.x * exp(-rr * rr * 1.05);
|
|
220
|
+
v = v + shape.y * exp(-sq((rr - 1.02) / 0.42));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Activity: temporary, local, independent. Anisotropic — wider than tall.
|
|
224
|
+
//
|
|
225
|
+
// Articulation (FIELD-SPEC §16) is spent on definition only: it damps the ripple terms, softens
|
|
226
|
+
// and widens the collar so the rim stops closing, and — when co-observing sources disagree on
|
|
227
|
+
// extent — raises a faint doubled shoulder inside the object's own trough. The bulge amplitude
|
|
228
|
+
// itself is NEVER scaled by articulation: unknown stays heavy.
|
|
229
|
+
let dn = u32(P.counts.y);
|
|
230
|
+
for (var i = 0u; i < dn; i = i + 1u) {
|
|
231
|
+
let a = distData[i * 3u];
|
|
232
|
+
let b = distData[i * 3u + 1u];
|
|
233
|
+
let c = distData[i * 3u + 2u];
|
|
234
|
+
let amp = a.w;
|
|
235
|
+
if (amp <= 0.01) { continue; }
|
|
236
|
+
let radius = a.z;
|
|
237
|
+
let freq = b.x;
|
|
238
|
+
let phase = b.y;
|
|
239
|
+
let artic = c.x;
|
|
240
|
+
let rip = 0.15 + 0.85 * artic;
|
|
241
|
+
let d = length(vec2f(x - a.x, (y - a.y) * 1.5));
|
|
242
|
+
if (d > radius * 4.0) { continue; }
|
|
243
|
+
let e = exp(-sq(d / radius));
|
|
244
|
+
v = v + amp * e * (0.78 + 0.22 * sin(t * freq + phase) * rip);
|
|
245
|
+
v = v - amp * 0.34 * (0.25 + 0.75 * artic)
|
|
246
|
+
* exp(-sq((d - radius * 1.5) / (radius * 0.62 * (1.0 + (1.0 - artic) * 1.4))));
|
|
247
|
+
v = v + amp * 0.16 * rip * exp(-d / (radius * 2.1)) * sin(d * 0.13 - t * freq * 2.6 + phase);
|
|
248
|
+
if (c.y > 0.02) {
|
|
249
|
+
v = v + amp * 0.11 * exp(-sq((d - radius * (0.72 + c.y)) / (radius * 0.3)));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// SESSION PRESENCE (FIELD-SPEC §15): a flat-topped plinth per live session raises grouped
|
|
254
|
+
// executions onto one platform, so an existing contour closes around the set. A spawned child
|
|
255
|
+
// is a plinth growing out of the parent plinth. An empty-but-known session keeps only its rim.
|
|
256
|
+
let pn = min(u32(P.grid.w), MAX_PLINTHS);
|
|
257
|
+
var lv : array<f32, MAX_PLINTHS>;
|
|
258
|
+
for (var i = 0u; i < pn; i = i + 1u) {
|
|
259
|
+
let pa = plinthData[i * 3u];
|
|
260
|
+
let pb = plinthData[i * 3u + 1u];
|
|
261
|
+
let pc = plinthData[i * 3u + 2u];
|
|
262
|
+
let n = (world - pa.xy) / pa.zw;
|
|
263
|
+
let r2 = dot(n, n);
|
|
264
|
+
let presence = pb.x;
|
|
265
|
+
let plateau = 1.0 / (1.0 + pow(max(r2, 1e-5), 2.6));
|
|
266
|
+
lv[i] = plateau * presence;
|
|
267
|
+
if (pb.w > 0.5) {
|
|
268
|
+
// Presence without content: the rim of a session nothing ever ran in.
|
|
269
|
+
v = v + 4.5 * presence * exp(-sq((sqrt(r2) - 1.0) / 0.3));
|
|
270
|
+
} else {
|
|
271
|
+
let plinth = select(17.0, 13.0, pc.y > 0.5) * presence;
|
|
272
|
+
v = v + plinth * plateau;
|
|
273
|
+
if (pc.x > 0.02) {
|
|
274
|
+
// Co-observation shoulder: sources agree on the computation, not exactly on its extent.
|
|
275
|
+
// A concentric bench inside the plateau edge — never a separate closed rim.
|
|
276
|
+
v = v + plinth * 0.3 * pc.x * exp(-sq((sqrt(r2) - 0.78) / 0.13));
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// THE KEEL: where two unrelated plateaus overlap, the ground between them drops — the same
|
|
282
|
+
// trough vocabulary already used around bulges, so contours cannot bridge it and proximity alone
|
|
283
|
+
// can never close a line. Parent and spawned child are exempt and still share a wall. Shallow by
|
|
284
|
+
// design: it must never read as a machine-level rift.
|
|
285
|
+
for (var i = 0u; i < pn; i = i + 1u) {
|
|
286
|
+
for (var j = i + 1u; j < pn; j = j + 1u) {
|
|
287
|
+
if (lv[i] < 0.02 || lv[j] < 0.02) { continue; }
|
|
288
|
+
let pi = u32(plinthData[i * 3u + 1u].z);
|
|
289
|
+
let pj = u32(plinthData[j * 3u + 1u].z);
|
|
290
|
+
if (pi == j + 1u || pj == i + 1u) { continue; }
|
|
291
|
+
let lo = min(lv[i], lv[j]);
|
|
292
|
+
let o = lo / max(lv[i], lv[j]);
|
|
293
|
+
v = v - 30.0 * o * sqrt(o) * lo;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Residue: what the field remembers. One texture read, not a walk through history.
|
|
298
|
+
if (P.layer2.w > 0.5) {
|
|
299
|
+
let res = residueAt(world);
|
|
300
|
+
v = v + 62.0 * 0.15 * res.r;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Coupling ridge.
|
|
304
|
+
let cn = u32(P.counts.z);
|
|
305
|
+
let resC = residueAt(world);
|
|
306
|
+
for (var i = 0u; i < cn; i = i + 1u) {
|
|
307
|
+
let c = coupData[i];
|
|
308
|
+
let a = massPos(u32(c.x));
|
|
309
|
+
let b = massPos(u32(c.y));
|
|
310
|
+
let vv = b - a;
|
|
311
|
+
let l2 = dot(vv, vv);
|
|
312
|
+
if (l2 < 1.0) { continue; }
|
|
313
|
+
let u = dot(world - a, vv) / l2;
|
|
314
|
+
if (u < -0.05 || u > 1.05) { continue; }
|
|
315
|
+
let proj = a + vv * u;
|
|
316
|
+
let p = length(world - proj) / 44.0;
|
|
317
|
+
let envc = exp(-p * p) * exp(-quad((u - 0.5) / 0.56));
|
|
318
|
+
v = v + 34.0 * envc * (0.5 + 0.5 * sin(u * 13.0 - t * 4.6)) * c.z;
|
|
319
|
+
v = v - 14.0 * exp(-sq(abs(p) - 1.5)) * envc * c.z;
|
|
320
|
+
v = v + 9.0 * resC.g * exp(-p * p * 1.4) * exp(-quad((u - 0.5) / 0.5));
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return v;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Local articulation (FIELD-SPEC §16): the sheet resolves coarser near unresolved objects, so line
|
|
328
|
+
* cadence carries the meaning. Weighted blend over disturbances and plinths, with a prior toward 1
|
|
329
|
+
* so the empty medium — and everything far from an observed object — keeps its full cadence.
|
|
330
|
+
*/
|
|
331
|
+
fn articAt(world: vec2f) -> f32 {
|
|
332
|
+
var num = 0.0;
|
|
333
|
+
var den = 0.35;
|
|
334
|
+
let dn = u32(P.counts.y);
|
|
335
|
+
for (var i = 0u; i < dn; i = i + 1u) {
|
|
336
|
+
let a = distData[i * 3u];
|
|
337
|
+
let b = distData[i * 3u + 1u];
|
|
338
|
+
if (b.w <= 0.001) { continue; }
|
|
339
|
+
let dx = (world.x - a.x) / (a.z * 2.0);
|
|
340
|
+
let dy = (world.y - a.y) * 1.5 / (a.z * 2.0);
|
|
341
|
+
let w = exp(-(dx * dx + dy * dy)) * b.w;
|
|
342
|
+
num = num + w * distData[i * 3u + 2u].x;
|
|
343
|
+
den = den + w;
|
|
344
|
+
}
|
|
345
|
+
let pn = min(u32(P.grid.w), MAX_PLINTHS);
|
|
346
|
+
for (var i = 0u; i < pn; i = i + 1u) {
|
|
347
|
+
let pa = plinthData[i * 3u];
|
|
348
|
+
let pb = plinthData[i * 3u + 1u];
|
|
349
|
+
if (pb.x <= 0.01) { continue; }
|
|
350
|
+
let dx = (world.x - pa.x) / (pa.z * 1.3);
|
|
351
|
+
let dy = (world.y - pa.y) / (pa.w * 1.3);
|
|
352
|
+
let w = exp(-(dx * dx + dy * dy)) * pb.x * 0.8;
|
|
353
|
+
num = num + w * pb.y;
|
|
354
|
+
den = den + w;
|
|
355
|
+
}
|
|
356
|
+
return clamp((num + 0.35) / den, 0.1, 1.0);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
@fragment
|
|
360
|
+
fn fs_main(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
361
|
+
let world = vec2f(
|
|
362
|
+
mix(P.fieldRect.x, P.fieldRect.z, uv.x),
|
|
363
|
+
mix(P.fieldRect.y, P.fieldRect.w, uv.y)
|
|
364
|
+
);
|
|
365
|
+
let t = P.view.w;
|
|
366
|
+
return vec4f(heightAt(world, t), shiftAt(world, t), articAt(world), 1.0);
|
|
367
|
+
}
|
|
368
|
+
`,nT=`
|
|
369
|
+
${ps}
|
|
370
|
+
|
|
371
|
+
@group(0) @binding(4) var fieldTex : texture_2d<f32>;
|
|
372
|
+
@group(0) @binding(5) var fieldSamp : sampler;
|
|
373
|
+
|
|
374
|
+
struct VOut {
|
|
375
|
+
@builtin(position) pos : vec4f,
|
|
376
|
+
@location(0) color : vec4f,
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
fn fieldSample(world: vec2f) -> vec3f {
|
|
380
|
+
let uv = vec2f(
|
|
381
|
+
(world.x - P.fieldRect.x) / (P.fieldRect.z - P.fieldRect.x),
|
|
382
|
+
(world.y - P.fieldRect.y) / (P.fieldRect.w - P.fieldRect.y)
|
|
383
|
+
);
|
|
384
|
+
// r: height, g: shift, b: local articulation.
|
|
385
|
+
return textureSampleLevel(fieldTex, fieldSamp, clamp(uv, vec2f(0.0), vec2f(1.0)), 0.0).rgb;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** FIELD-SPEC §10 — line colour is the base ink pulled toward nearby mass tints. */
|
|
389
|
+
fn tintMix(world: vec2f) -> vec3f {
|
|
390
|
+
var acc = vec3f(226.0, 223.0, 215.0);
|
|
391
|
+
var w = 1.0;
|
|
392
|
+
let mn = u32(P.counts.x);
|
|
393
|
+
for (var i = 0u; i < mn; i = i + 1u) {
|
|
394
|
+
let pos = massPos(i);
|
|
395
|
+
let ext = massExtent(i) * 1.5;
|
|
396
|
+
let n = (world - pos) / ext;
|
|
397
|
+
let k = exp(-dot(n, n)) * 0.85;
|
|
398
|
+
acc = acc + massTint(i) * k;
|
|
399
|
+
w = w + k;
|
|
400
|
+
}
|
|
401
|
+
return acc / w / 255.0;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** Screen-space y of the sheet at world x on the given row baseline. */
|
|
405
|
+
fn rowPoint(x: f32, by: f32, dzW: f32, ampF: f32) -> f32 {
|
|
406
|
+
let wy = by + dzW;
|
|
407
|
+
let sh = fieldSample(vec2f(x, wy)).g;
|
|
408
|
+
let yy = wy + sh * ampF;
|
|
409
|
+
let hv = fieldSample(vec2f(x, yy)).r * ampF;
|
|
410
|
+
let worldY = by - hv + sh * 0.55 * ampF;
|
|
411
|
+
return (worldY - P.rect.y) * P.view.z;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
@vertex
|
|
415
|
+
fn vs_main(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VOut {
|
|
416
|
+
let cols = u32(P.grid.x);
|
|
417
|
+
let isLine = ii & 1u;
|
|
418
|
+
let seg = ii >> 1u;
|
|
419
|
+
let row = seg / cols;
|
|
420
|
+
let col = seg % cols;
|
|
421
|
+
|
|
422
|
+
let k = P.view.z;
|
|
423
|
+
let stepW = P.layer.y / k;
|
|
424
|
+
let rowsW = P.layer.x / k;
|
|
425
|
+
let dzW = P.layer2.y / k;
|
|
426
|
+
// FIELD-SPEC §10 — amplitude compensation when zoomed in.
|
|
427
|
+
let ampF = P.layer.z * select(1.0, 1.6 / k, k > 1.0);
|
|
428
|
+
|
|
429
|
+
let x0 = P.rect.x - stepW * 2.0 + f32(col) * stepW;
|
|
430
|
+
let x1 = x0 + stepW;
|
|
431
|
+
let by = P.rect.y - rowsW * 0.6 + f32(row) * rowsW;
|
|
432
|
+
|
|
433
|
+
let sy0 = rowPoint(x0, by, dzW, ampF);
|
|
434
|
+
let sy1 = rowPoint(x1, by, dzW, ampF);
|
|
435
|
+
let sx0 = (x0 - P.rect.x) * k + P.layer2.z;
|
|
436
|
+
let sx1 = (x1 - P.rect.x) * k + P.layer2.z;
|
|
437
|
+
|
|
438
|
+
var p = vec2f(0.0);
|
|
439
|
+
var color = vec4f(0.0);
|
|
440
|
+
|
|
441
|
+
if (isLine == 0u) {
|
|
442
|
+
// Fill: from this segment down past the bottom of the viewport. Occludes farther rows.
|
|
443
|
+
let bottom = P.view.y + 60.0;
|
|
444
|
+
switch (vi) {
|
|
445
|
+
case 0u: { p = vec2f(sx0, sy0); }
|
|
446
|
+
case 1u: { p = vec2f(sx1, sy1); }
|
|
447
|
+
case 2u: { p = vec2f(sx1, bottom); }
|
|
448
|
+
case 3u: { p = vec2f(sx0, sy0); }
|
|
449
|
+
case 4u: { p = vec2f(sx1, bottom); }
|
|
450
|
+
default: { p = vec2f(sx0, bottom); }
|
|
451
|
+
}
|
|
452
|
+
color = P.fill;
|
|
453
|
+
} else {
|
|
454
|
+
// Line: a quad along the segment, width and alpha from local slope (FIELD-SPEC §10).
|
|
455
|
+
let slope = min(1.0, abs(sy1 - sy0) / max(0.001, P.layer.y));
|
|
456
|
+
var bucketA = 0.17;
|
|
457
|
+
var bucketW = 0.75;
|
|
458
|
+
if (slope > 0.62) { bucketA = 0.98; bucketW = 1.80; }
|
|
459
|
+
else if (slope > 0.30) { bucketA = 0.60; bucketW = 1.35; }
|
|
460
|
+
else if (slope > 0.11) { bucketA = 0.32; bucketW = 1.00; }
|
|
461
|
+
|
|
462
|
+
// OBSERVATION RESOLUTION (FIELD-SPEC §16): near an unresolved object the sheet's own line
|
|
463
|
+
// cadence loosens — segments dash out, thin and dim. Never the height: mass stays, definition
|
|
464
|
+
// varies. The blend prior keeps the empty medium at full cadence, so a fully resolved field
|
|
465
|
+
// renders exactly as it did before articulation existed.
|
|
466
|
+
let art = fieldSample(vec2f((x0 + x1) * 0.5, by)).b;
|
|
467
|
+
if (art <= 0.85) {
|
|
468
|
+
let dash = (1.0 - art) * 9.0 + 1.5;
|
|
469
|
+
// World-anchored phase (scaled to screen), so the cadence sits still under panning.
|
|
470
|
+
let phase = fract(x0 * k * 0.7 / (dash * 2.2)) * dash * 2.2;
|
|
471
|
+
if (phase > dash * 1.15) {
|
|
472
|
+
var cut: VOut;
|
|
473
|
+
cut.pos = vec4f(-10.0, -10.0, 0.0, 1.0);
|
|
474
|
+
cut.color = vec4f(0.0);
|
|
475
|
+
return cut;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
let artA = 0.34 + 0.66 * art;
|
|
479
|
+
let artW = 0.7 + 0.3 * art;
|
|
480
|
+
|
|
481
|
+
let width = max(0.6, bucketW * artW * min(2.1, k) * P.layer2.x);
|
|
482
|
+
let dir = normalize(vec2f(sx1 - sx0, sy1 - sy0) + vec2f(0.0001, 0.0));
|
|
483
|
+
let nrm = vec2f(-dir.y, dir.x) * (width * 0.5);
|
|
484
|
+
|
|
485
|
+
switch (vi) {
|
|
486
|
+
case 0u: { p = vec2f(sx0, sy0) - nrm; }
|
|
487
|
+
case 1u: { p = vec2f(sx1, sy1) - nrm; }
|
|
488
|
+
case 2u: { p = vec2f(sx1, sy1) + nrm; }
|
|
489
|
+
case 3u: { p = vec2f(sx0, sy0) - nrm; }
|
|
490
|
+
case 4u: { p = vec2f(sx1, sy1) + nrm; }
|
|
491
|
+
default: { p = vec2f(sx0, sy0) + nrm; }
|
|
492
|
+
}
|
|
493
|
+
let rgb = tintMix(vec2f((x0 + x1) * 0.5, by));
|
|
494
|
+
color = vec4f(rgb, bucketA * artA * P.layer.w);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
var out: VOut;
|
|
498
|
+
out.pos = vec4f(p.x / P.view.x * 2.0 - 1.0, 1.0 - p.y / P.view.y * 2.0, 0.0, 1.0);
|
|
499
|
+
out.color = color;
|
|
500
|
+
return out;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
@fragment
|
|
504
|
+
fn fs_main(in: VOut) -> @location(0) vec4f {
|
|
505
|
+
return vec4f(in.color.rgb * in.color.a, in.color.a);
|
|
506
|
+
}
|
|
507
|
+
`,iT=`
|
|
508
|
+
${ps}
|
|
509
|
+
|
|
510
|
+
struct VOut {
|
|
511
|
+
@builtin(position) pos : vec4f,
|
|
512
|
+
@location(0) local : vec2f,
|
|
513
|
+
@location(1) color : vec3f,
|
|
514
|
+
@location(2) weight : f32,
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
fn statusColor(idx: f32) -> vec3f {
|
|
518
|
+
if (idx < 0.5) { return vec3f(240.0, 195.0, 116.0) / 255.0; } // running
|
|
519
|
+
if (idx < 1.5) { return vec3f(150.0, 175.0, 196.0) / 255.0; } // waiting
|
|
520
|
+
if (idx < 2.5) { return vec3f(206.0, 104.0, 90.0) / 255.0; } // failed
|
|
521
|
+
if (idx < 3.5) { return vec3f(180.0, 210.0, 175.0) / 255.0; } // completed
|
|
522
|
+
return vec3f(230.0, 227.0, 219.0) / 255.0; // idle
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
fn statusPulse(idx: f32, t: f32, freq: f32, phase: f32) -> f32 {
|
|
526
|
+
if (idx < 0.5) { return 0.55 + 0.35 * sin(t * freq * 2.0 + phase); }
|
|
527
|
+
if (idx < 1.5) { return 0.40 + 0.08 * sin(t * 0.6); }
|
|
528
|
+
if (idx < 2.5) { return 0.50 + 0.50 * sin(t * 30.0); }
|
|
529
|
+
if (idx < 3.5) { return 0.35; }
|
|
530
|
+
return 0.15;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
@vertex
|
|
534
|
+
fn vs_main(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VOut {
|
|
535
|
+
let a = distData[ii * 3u];
|
|
536
|
+
let b = distData[ii * 3u + 1u];
|
|
537
|
+
let k = P.view.z;
|
|
538
|
+
let t = P.view.w;
|
|
539
|
+
|
|
540
|
+
let statusIdx = b.z;
|
|
541
|
+
let failed = select(1.0, 1.3, statusIdx > 1.5 && statusIdx < 2.5);
|
|
542
|
+
let radius = max(2.4, 3.4 * k) * failed * 3.2;
|
|
543
|
+
|
|
544
|
+
let centre = vec2f((a.x - P.rect.x) * k, (a.y - P.rect.y) * k);
|
|
545
|
+
let corner = vec2f(
|
|
546
|
+
select(-1.0, 1.0, (vi == 1u) || (vi == 2u) || (vi == 4u)),
|
|
547
|
+
select(-1.0, 1.0, (vi == 2u) || (vi == 4u) || (vi == 5u))
|
|
548
|
+
);
|
|
549
|
+
let p = centre + corner * radius;
|
|
550
|
+
|
|
551
|
+
var out: VOut;
|
|
552
|
+
out.pos = vec4f(p.x / P.view.x * 2.0 - 1.0, 1.0 - p.y / P.view.y * 2.0, 0.0, 1.0);
|
|
553
|
+
out.local = corner;
|
|
554
|
+
out.color = statusColor(statusIdx);
|
|
555
|
+
// Articulation dims the core's confidence, never the field's mass (FIELD-SPEC §16).
|
|
556
|
+
let artic = distData[ii * 3u + 2u].x;
|
|
557
|
+
out.weight = statusPulse(statusIdx, t, b.x, b.y) * 0.9 * clamp(b.w, 0.0, 1.0)
|
|
558
|
+
* (0.22 + 0.78 * artic);
|
|
559
|
+
return out;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
@fragment
|
|
563
|
+
fn fs_main(in: VOut) -> @location(0) vec4f {
|
|
564
|
+
let d = length(in.local);
|
|
565
|
+
if (d > 1.0) { discard; }
|
|
566
|
+
// Radial falloff matching the design's gradient stops.
|
|
567
|
+
let a = (1.0 - d) * (1.0 - d) * in.weight;
|
|
568
|
+
return vec4f(in.color * a, a);
|
|
569
|
+
}
|
|
570
|
+
`,aT=`
|
|
571
|
+
${ps}
|
|
572
|
+
|
|
573
|
+
// per stratum: startFraction, endFraction, lane, statusIndex
|
|
574
|
+
@group(0) @binding(4) var<storage, read> strataData : array<vec4f>;
|
|
575
|
+
|
|
576
|
+
struct VOut {
|
|
577
|
+
@builtin(position) pos : vec4f,
|
|
578
|
+
@location(0) t : f32,
|
|
579
|
+
@location(1) color : vec3f,
|
|
580
|
+
@location(2) alpha : f32,
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
const STRATA_TOP : f32 = 812.0;
|
|
584
|
+
const STRATA_H : f32 = 360.0;
|
|
585
|
+
const SPAN_X : f32 = 1160.0;
|
|
586
|
+
const MIN_W : f32 = ${G0}.0;
|
|
587
|
+
|
|
588
|
+
@vertex
|
|
589
|
+
fn vs_main(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VOut {
|
|
590
|
+
let s = strataData[ii];
|
|
591
|
+
let laneCount = max(1.0, P.grid.z);
|
|
592
|
+
let laneH = STRATA_H / laneCount;
|
|
593
|
+
let top = STRATA_TOP + s.z * laneH;
|
|
594
|
+
|
|
595
|
+
let wx0 = s.x * SPAN_X;
|
|
596
|
+
let wx1 = max(wx0 + MIN_W, s.y * SPAN_X);
|
|
597
|
+
let k = P.view.z;
|
|
598
|
+
|
|
599
|
+
let sx0 = (wx0 - P.rect.x) * k;
|
|
600
|
+
let sx1 = (wx1 - P.rect.x) * k;
|
|
601
|
+
let sy0 = (top - P.rect.y) * k;
|
|
602
|
+
let sy1 = (top + laneH - P.rect.y) * k;
|
|
603
|
+
|
|
604
|
+
let right = (vi == 1u) || (vi == 2u) || (vi == 4u);
|
|
605
|
+
let lower = (vi == 2u) || (vi == 4u) || (vi == 5u);
|
|
606
|
+
let p = vec2f(select(sx0, sx1, right), select(sy0, sy1, lower));
|
|
607
|
+
|
|
608
|
+
// Failed runs read red; otherwise the lane's machine tint.
|
|
609
|
+
var col = massTint(u32(s.z)) / 255.0;
|
|
610
|
+
if (s.w > 1.5 && s.w < 2.5) { col = vec3f(206.0, 104.0, 90.0) / 255.0; }
|
|
611
|
+
|
|
612
|
+
var out: VOut;
|
|
613
|
+
out.pos = vec4f(p.x / P.view.x * 2.0 - 1.0, 1.0 - p.y / P.view.y * 2.0, 0.0, 1.0);
|
|
614
|
+
out.t = select(0.0, 1.0, right);
|
|
615
|
+
out.color = col;
|
|
616
|
+
out.alpha = 0.30;
|
|
617
|
+
return out;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
@fragment
|
|
621
|
+
fn fs_main(in: VOut) -> @location(0) vec4f {
|
|
622
|
+
// Left-to-right gradient to transparent, as in the approved design.
|
|
623
|
+
let a = in.alpha * (1.0 - in.t);
|
|
624
|
+
return vec4f(in.color * a, a);
|
|
625
|
+
}
|
|
626
|
+
`,Xy=.34,Qy=3.4,m0={zoom:1,cx:580,cy:406},rT=-260,sT=1420,lT=-260,uT=1300,oT=.58,cT=.72,uf=1.7,fT=1.45;function dT(n,i){return n==="strata"?i>cT?"environment":"strata":n==="proximity"?i<fT?"environment":"proximity":i<oT?"strata":i>uf?"proximity":"environment"}function hT(n){return n.width/wn.spanX}function Zn(n,i){return hT(i)*n.zoom}function ms(n){return n.zoom=Math.max(Xy,Math.min(Qy,n.zoom)),n.cx=Math.max(rT,Math.min(sT,n.cx)),n.cy=Math.max(lT,Math.min(uT,n.cy)),n}function pT(n,i,r){const l=Zn(n,i),u=i.width/l,f=i.height/l;return r.x0=n.cx-u/2,r.y0=n.cy-f/2,r.x1=n.cx+u/2,r.y1=n.cy+f/2,r}function of(n,i,r,l){const u=Zn(r,l),f=l.width/u,d=l.height/u;return[r.cx-f/2+n/u,r.cy-d/2+i/u]}function Gc(n,i,r,l){const u=Zn(r,l),f=l.width/u,d=l.height/u;return[(n-(r.cx-f/2))*u,(i-(r.cy-d/2))*u]}function Bc(n,i,r,l,u){const[f,d]=of(r,l,n,u);n.zoom=Math.max(Xy,Math.min(Qy,n.zoom*i));const h=Zn(n,u);n.cx=f-r/h+u.width/h/2,n.cy=d-l/h+u.height/h/2,ms(n)}function g0(n,i,r,l){const u=Zn(n,l);n.cx+=i/u,n.cy+=r/u,ms(n)}function mT(n,i,r,l=7){const u=1-Math.exp(-l*r),f=i.zoom-n.zoom,d=i.cx-n.cx,h=i.cy-n.cy;n.zoom+=f*u,n.cx+=d*u,n.cy+=h*u;const m=Math.abs(f)<.001&&Math.abs(d)<.4&&Math.abs(h)<.4;return m&&(n.zoom=i.zoom,n.cx=i.cx,n.cy=i.cy),m}function gT(n,i,r){return ms({zoom:r,cx:n,cy:i})}const Bl=120;class yT{intervalMs=new Float32Array(Bl);cpuMs=new Float32Array(Bl);cursor=0;filled=0;lastFrameAt=0;frames=0;lastIntervalMs=0;lastCpuMs=0;gpuMs={};disturbances=0;fps=0;resolutionScale=1;get canAdapt(){return this.totalGpuMs>0}lastAdjustAt=0;pendingResize=!1;sample(i,r,l){if(this.lastFrameAt>0){const u=i-this.lastFrameAt;this.intervalMs[this.cursor]=u,this.cpuMs[this.cursor]=r,this.cursor=(this.cursor+1)%Bl,this.filled<Bl&&this.filled++,this.lastIntervalMs=u}this.lastFrameAt=i,this.lastCpuMs=r,this.frames++,this.disturbances=l,this.fps=this.averageInterval>0?1e3/this.averageInterval:0,this.maybeAdapt(i)}resetPacing(){this.lastFrameAt=0}get averageInterval(){if(this.filled===0)return 0;let i=0;for(let r=0;r<this.filled;r++)i+=this.intervalMs[r];return i/this.filled}get averageCpuMs(){if(this.filled===0)return 0;let i=0;for(let r=0;r<this.filled;r++)i+=this.cpuMs[r];return i/this.filled}get totalGpuMs(){let i=0;for(const r in this.gpuMs)i+=this.gpuMs[r];return i}frameCost(){return this.totalGpuMs}maybeAdapt(i){if(i-this.lastAdjustAt<2e3||this.filled<45)return;const r=this.frameCost();r<=0||(r>13&&this.resolutionScale>.5?(this.resolutionScale=Math.max(.5,this.resolutionScale-.15),this.lastAdjustAt=i,this.pendingResize=!0):r<6&&this.resolutionScale<1&&(this.resolutionScale=Math.min(1,this.resolutionScale+.1),this.lastAdjustAt=i,this.pendingResize=!0))}wantsResize(){return this.pendingResize?(this.pendingResize=!1,!0):!1}snapshot(){return{fps:this.fps,intervalMs:this.averageInterval,cpuMs:this.averageCpuMs,gpuMs:this.totalGpuMs,frames:this.frames,scale:this.resolutionScale,disturbances:this.disturbances}}}const ts=[{rows:22,step:11,amp:.5,alpha:.4,lw:.75,dz:-190,px:44,fill:[5,6,8,.9]},{rows:14,step:9,amp:.74,alpha:.72,lw:.9,dz:-92,px:18,fill:[5,6,8,.94]},{rows:9,step:7.5,amp:1,alpha:1,lw:1,dz:0,px:0,fill:[4,5,7,.965]}],y0={running:0,waiting:1,failed:2,completed:3,idle:4},v0={laptop:[214,176,116],desktop:[168,186,150],server:[150,190,175]},b0=512,x0=0,S0=1,ns=2,w0=1,E0=2,vT=4,bT=1600,A0=.004;function xT(n){return n.msSinceInteraction<bT?w0:n.couplings>0||n.maxEnergy>A0?E0:n.maxSettling>A0?vT:n.dirty?w0:1/0}class ST{gpu;surf=null;output;residue;fieldTarget;gpuTimer=null;sheetSpan=null;residueFx;fieldFx;sheetDraw;coresDraw;strataDraw;paramsBufs=[];massBuf;distBuf;coupBuf;strataBuf;plinthBuf;params=new Float32Array(32);massArr=new Float32Array(f0*3*4);distArr=new Float32Array(d0*3*4);coupArr=new Float32Array(h0*4);strataArr=new Float32Array(b0*4);plinthArr=new Float32Array(lf*3*4);rect={x0:0,y0:0,x1:0,y1:0};landscape={time:0,masses:[],disturbances:[],plinths:[],couplings:[],strata:[]};massIndex=new Map;runtime=new Map;plinthRuntime=new Map;plinthStatics=new Map;frameSubscribers=new Set;generation=0;lastInstances=0;strataCount=0;disturbanceCount=0;couplingCount=0;massCount=0;plinthCount=0;raf=0;refreshCount=0;nextDrawAt=0;dirty=!0;running=!1;lastFrameAt=0;simTime=0;lastInteractionAt=0;disposed=!1;landscapeDirty=!0;perf=new yT;camera;canvas;headless;maxDpr;initGpu;view={width:1,height:1};constructor(i){if(this.canvas=i.canvas??null,this.headless=i.headless??null,this.camera=i.camera,this.maxDpr=i.maxDpr??1.25,this.initGpu=i.initGpu??(async()=>{try{return await c0({requiredFeatures:["timestamp-query"]})}catch{return await c0()}}),!this.canvas&&!this.headless)throw new Error("FieldRenderer needs either a canvas or a headless size")}async init(){this.gpu=await this.initGpu();try{this.gpuTimer=ZA(this.gpu),this.sheetSpan=this.gpuTimer.span("field"),this.gpuTimer.onResults(f=>{this.perf.gpuMs=f})}catch{this.gpuTimer=null,this.sheetSpan=null}if(this.headless)this.output=r0(this.gpu,{size:[this.headless.width,this.headless.height],format:"rgba8unorm"});else{const f=this.canvas;await wT(f);const d=Math.min(this.maxDpr,globalThis.devicePixelRatio||1),[h,m]=this.cssSize();f.width=Math.round(h*d),f.height=Math.round(m*d),this.surf=SE(this.gpu,f,{dpr:d,autoResize:!0}),this.output=this.surf,this.view.width=h,this.view.height=m}this.residue=$A(this.gpu,p0,p0,{format:"rgba16float"});const[i,r]=this.fieldSize();this.fieldTarget=r0(this.gpu,{size:[i,r],format:"rgba16float"}),this.paramsBufs=Array.from({length:5},()=>Ha(this.gpu,this.params.byteLength,"read")),this.massBuf=Ha(this.gpu,this.massArr.byteLength,"read"),this.distBuf=Ha(this.gpu,this.distArr.byteLength,"read"),this.coupBuf=Ha(this.gpu,this.coupArr.byteLength,"read"),this.strataBuf=Ha(this.gpu,this.strataArr.byteLength,"read"),this.plinthBuf=Ha(this.gpu,this.plinthArr.byteLength,"read");const l=GE(this.gpu,{minFilter:"linear",magFilter:"linear"});this.residueFx=a0(this.gpu,eT,{set:{P:this.paramsBufs[x0],massData:this.massBuf,distData:this.distBuf,coupData:this.coupBuf,prevTex:this.residue.read,prevSamp:l}}),this.fieldFx=a0(this.gpu,tT,{set:{P:this.paramsBufs[S0],massData:this.massBuf,distData:this.distBuf,coupData:this.coupBuf,residueTex:this.residue.read,residueSamp:l,plinthData:this.plinthBuf}}),this.sheetDraw=Lc(this.gpu,{shader:nT,vertices:6,blend:"premultiplied",set:{P:this.paramsBufs[ns],massData:this.massBuf,fieldTex:this.fieldTarget,fieldSamp:l}}),this.coresDraw=Lc(this.gpu,{shader:iT,vertices:6,blend:"additive",set:{P:this.paramsBufs[ns],distData:this.distBuf}}),this.strataDraw=Lc(this.gpu,{shader:aT,vertices:6,blend:"premultiplied",set:{P:this.paramsBufs[ns],massData:this.massBuf,strataData:this.strataBuf}});const u={colors:[this.output.format]};await Promise.all([this.residueFx.compile(this.residue.write),this.fieldFx.compile(this.fieldTarget),this.sheetDraw.compile(u),this.coresDraw.compile(u),this.strataDraw.compile(u)])}cssSize(){const i=this.canvas;if(!i)return[this.headless.width,this.headless.height];const r=i.parentElement,l=i.clientWidth||r?.clientWidth||1280,u=i.clientHeight||r?.clientHeight||720;return[Math.max(1,l),Math.max(1,u)]}fieldSize(){const i=this.perf.resolutionScale,r=this.headless?.width??this.canvas?.clientWidth??640,l=this.headless?.height??this.canvas?.clientHeight??480,u=Math.max(160,Math.round(Math.min(768,r)*i)),f=Math.max(120,Math.round(Math.min(576,l)*i));return[u,f]}setLandscape(i){this.landscape=i,this.landscapeDirty=!0,this.generation++;const r=this.generation;for(const l of i.disturbances){let u=this.runtime.get(l.id);u||(u={energy:0,target:l.energy,status:l.status,statusSince:l.statusSince,seen:r},this.runtime.set(l.id,u)),u.target=l.energy,u.status=l.status,u.statusSince=l.statusSince,u.seen=r}for(const[l,u]of this.runtime)u.seen!==r&&(u.target=0,u.energy<.002&&this.runtime.delete(l));for(const l of i.plinths){let u=this.plinthRuntime.get(l.id);u||(u={presence:0,target:l.presence,x:l.x,y:l.y,extentX:l.extentX,extentY:l.extentY,toX:l.x,toY:l.y,toExtentX:l.extentX,toExtentY:l.extentY,seen:r},this.plinthRuntime.set(l.id,u)),u.target=l.presence,u.toX=l.x,u.toY=l.y,u.toExtentX=l.extentX,u.toExtentY=l.extentY,u.seen=r,this.plinthStatics.set(l.id,l)}for(const[l,u]of this.plinthRuntime)u.seen!==r&&(u.target=0,u.presence<.002&&(this.plinthRuntime.delete(l),this.plinthStatics.delete(l)))}noteInteraction(){this.lastInteractionAt=performance.now(),this.dirty=!0}onFrame(i){return this.frameSubscribers.add(i),()=>this.frameSubscribers.delete(i)}start(){if(this.running||this.disposed)return;this.running=!0,this.lastFrameAt=performance.now(),this.refreshCount=0,this.nextDrawAt=0;const i=r=>{if(!this.running)return;this.raf=requestAnimationFrame(i),this.refreshCount++;const l=this.currentStride(r);if(l===1/0){this.perf.resetPacing(),this.lastFrameAt=r,this.nextDrawAt=this.refreshCount+1;return}if(this.refreshCount<this.nextDrawAt)return;this.nextDrawAt=this.refreshCount+l;const u=r-this.lastFrameAt;this.lastFrameAt=r,this.renderFrame(Math.min(.1,u/1e3))};this.raf=requestAnimationFrame(i)}stop(){this.running=!1,this.raf&&cancelAnimationFrame(this.raf),this.raf=0}invalidate(){this.dirty=!0}currentStride(i){let r=0,l=0;for(const u of this.runtime.values()){u.energy>r&&(r=u.energy);const f=Math.abs(u.target-u.energy);f>l&&(l=f)}for(const u of this.plinthRuntime.values()){const f=Math.abs(u.target-u.presence);f>l&&(l=f)}return xT({dirty:this.dirty||this.landscapeDirty,msSinceInteraction:i-this.lastInteractionAt,couplings:this.couplingCount,maxEnergy:r,maxSettling:l})}stepPhysics(i){const r=this.simTime;for(const l of this.runtime.values()){let u=l.target;if(l.status==="failed"){const d=Math.max(0,r-l.statusSince/1e3);d<1.4?u=l.target*(1+.45*Math.sin(d*44)):u=l.target*Math.max(0,1-(d-1.4)/2.2)*.22}const f=u>l.energy?2.6:1.1;l.energy+=(u-l.energy)*(1-Math.exp(-f*i)),l.energy<5e-4&&u===0&&(l.energy=0)}for(const l of this.plinthRuntime.values()){const u=l.target>l.presence?1.8:.9;l.presence+=(l.target-l.presence)*(1-Math.exp(-u*i)),l.presence<5e-4&&l.target===0&&(l.presence=0);const f=1-Math.exp(-3*i);l.x+=(l.toX-l.x)*f,l.y+=(l.toY-l.y)*f,l.extentX+=(l.toExtentX-l.extentX)*f,l.extentY+=(l.toExtentY-l.extentY)*f}}packStatics(){const{masses:i,couplings:r,strata:l}=this.landscape;this.massIndex.clear(),this.massArr.fill(0),this.massCount=Math.min(i.length,f0);for(let u=0;u<this.massCount;u++){const f=i[u];this.massIndex.set(f.id,u);const d=u*12;this.massArr[d+0]=f.x,this.massArr[d+1]=f.y,this.massArr[d+2]=f.extentX,this.massArr[d+3]=f.extentY;const h=f.extentX/300;this.massArr[d+4]=72*h,this.massArr[d+5]=27*h,this.massArr[d+6]=30*h,this.massArr[d+7]=.34+f.seed*.12,this.massArr[d+8]=f.seed*Math.PI*2;const m=v0[f.kind]??v0.laptop;this.massArr[d+9]=m[0],this.massArr[d+10]=m[1],this.massArr[d+11]=m[2]}this.massBuf.write(this.massArr),this.coupArr.fill(0),this.couplingCount=0;for(const u of r){if(this.couplingCount>=h0)break;const f=this.massIndex.get(u.fromMassId),d=this.massIndex.get(u.toMassId);if(f===void 0||d===void 0)continue;const h=this.couplingCount*4;this.coupArr[h+0]=f,this.coupArr[h+1]=d,this.coupArr[h+2]=u.energy,this.couplingCount++}this.coupBuf.write(this.coupArr),this.strataArr.fill(0),this.strataCount=Math.min(l.length,b0);for(let u=0;u<this.strataCount;u++){const f=l[u],d=u*4;this.strataArr[d+0]=f.startFraction,this.strataArr[d+1]=f.endFraction,this.strataArr[d+2]=Math.min(f.lane,this.massCount-1),this.strataArr[d+3]=y0[f.status]}this.strataBuf.write(this.strataArr)}packDisturbances(){this.distArr.fill(0);let i=0;for(const r of this.landscape.disturbances){if(i>=d0)break;const l=this.runtime.get(r.id),u=l?l.energy:r.energy;if(u<=5e-4)continue;const f=30+r.extent*44,d=f*(.62+.22*r.extent),h=i*12;this.distArr[h+0]=r.x,this.distArr[h+1]=r.y,this.distArr[h+2]=f,this.distArr[h+3]=d*u,this.distArr[h+4]=.9+r.rate*1.15,this.distArr[h+5]=r.phase,this.distArr[h+6]=y0[r.status],this.distArr[h+7]=u,this.distArr[h+8]=r.articulation,this.distArr[h+9]=r.shoulder,i++}this.disturbanceCount=i,this.distBuf.write(this.distArr)}packPlinths(){this.plinthArr.fill(0);const i=[];let r=0;for(const[l,u]of this.plinthRuntime){if(r>=lf)break;if(u.presence<=5e-4)continue;const f=this.plinthStatics.get(l);if(!f)continue;const d=r*12;this.plinthArr[d+0]=u.x,this.plinthArr[d+1]=u.y,this.plinthArr[d+2]=u.extentX,this.plinthArr[d+3]=u.extentY,this.plinthArr[d+4]=u.presence,this.plinthArr[d+5]=f.articulation,this.plinthArr[d+7]=f.empty?1:0,this.plinthArr[d+8]=f.shoulder,i.push({id:l,parentId:f.parentId}),r++}for(let l=0;l<i.length;l++){const u=i[l].parentId,f=u?i.findIndex(d=>d.id===u):-1;this.plinthArr[l*12+6]=f+1,this.plinthArr[l*12+9]=f>=0?1:0}this.plinthCount=r,this.plinthBuf.write(this.plinthArr)}packParams(i,r,l,u){const f=this.params,d=Zn(this.camera,this.view);f[0]=this.rect.x0,f[1]=this.rect.y0,f[2]=this.rect.x1,f[3]=this.rect.y1,f[4]=this.view.width,f[5]=this.view.height,f[6]=d,f[7]=this.simTime,f[8]=this.massCount,f[9]=this.disturbanceCount,f[10]=this.couplingCount,f[11]=r;const h=ts[u]??ts[0];f[12]=h.rows,f[13]=h.step,f[14]=h.amp,f[15]=h.alpha,f[16]=h.lw,f[17]=h.dz,f[18]=h.px,f[19]=1,f[20]=this.colsFor(h.step,d),f[21]=this.rowsFor(h.rows,d),f[22]=Math.max(1,this.massCount),f[23]=this.plinthCount,f[24]=h.fill[0]/255*h.fill[3],f[25]=h.fill[1]/255*h.fill[3],f[26]=h.fill[2]/255*h.fill[3],f[27]=h.fill[3],f[28]=l.x0,f[29]=l.y0,f[30]=l.x1,f[31]=l.y1,this.paramsBufs[i].write(f)}colsFor(i,r){const l=i/r,u=this.rect.x1-this.rect.x0+l*4;return Math.max(2,Math.min(1024,Math.ceil(u/l)))}rowsFor(i,r){const l=i/r,f=Math.min(this.rect.y1,832)+90/r-(this.rect.y0-l*.6);return Math.max(2,Math.min(512,Math.ceil(f/l)))}renderOnce(i){this.renderFrame(Math.min(.25,i))}async debugField(){const i=await this.fieldTarget.readFloats();let r=1/0,l=-1/0,u=0;for(let f=0;f<i.length;f+=4){const d=i[f];Number.isNaN(d)?u++:(d<r&&(r=d),d>l&&(l=d))}return{min:r,max:l,nan:u,sample:Array.from(i.slice(0,16))}}stats(){return{runtimeEntries:this.runtime.size,disturbances:this.disturbanceCount,plinths:this.plinthCount,strata:this.strataCount,couplings:this.couplingCount,instances:this.lastInstances}}renderFrame(i){if(this.disposed)return;const r=performance.now();if(this.simTime+=i,ms(this.camera),this.headless){const[h,m]=this.output.size;this.view.width=h,this.view.height=m}else{const[h,m]=this.cssSize();if(h!==this.view.width||m!==this.view.height){this.view.width=h,this.view.height=m;const g=Math.min(this.maxDpr,globalThis.devicePixelRatio||1);this.canvas.width=Math.round(h*g),this.canvas.height=Math.round(m*g),this.surf?.resize([h,m]);const[x,b]=this.fieldSize();this.fieldTarget.resize([x,b])}}pT(this.camera,this.view,this.rect),this.stepPhysics(i),this.landscapeDirty&&(this.packStatics(),this.landscapeDirty=!1),this.packDisturbances(),this.packPlinths();const l=(this.rect.x1-this.rect.x0)*.12,u=(this.rect.y1-this.rect.y0)*.16,f={x0:this.rect.x0-l,y0:this.rect.y0-u,x1:this.rect.x1+l,y1:this.rect.y1+u},d=Zn(this.camera,this.view);this.packParams(x0,i,rs,0),this.packParams(S0,i,f,0);for(let h=0;h<ts.length;h++)this.packParams(ns+h,i,f,h);EA(this.gpu,h=>{this.residueFx.set({prevTex:this.residue.read}),h.pass({target:this.residue.write,clear:!1},this.residueFx),this.fieldFx.set({residueTex:this.residue.write}),h.pass({target:this.fieldTarget,clear:!0},this.fieldFx),h.pass(this.sheetSpan?{target:this.output,clear:[.024,.027,.035,1],timer:this.sheetSpan}:{target:this.output,clear:[.024,.027,.035,1]},m=>{let g=0;for(let x=0;x<ts.length;x++){const b=ts[x],D=this.colsFor(b.step,d)*this.rowsFor(b.rows,d)*2;g+=D,this.sheetDraw.set({P:this.paramsBufs[ns+x]}),m.draw(this.sheetDraw,{instances:D})}this.strataCount>0&&m.draw(this.strataDraw,{instances:this.strataCount}),this.disturbanceCount>0&&m.draw(this.coresDraw,{instances:this.disturbanceCount}),this.lastInstances=g+this.strataCount+this.disturbanceCount})}),this.residue.swap(),this.dirty=!1;for(const h of this.frameSubscribers)h(this.view);if(this.perf.sample(r,performance.now()-r,this.disturbanceCount),this.perf.wantsResize()){const[h,m]=this.fieldSize(),[g,x]=this.fieldTarget.size;(h!==g||m!==x)&&this.fieldTarget.resize([h,m])}}dispose(){this.stop(),this.disposed=!0,this.runtime.clear(),this.plinthRuntime.clear(),this.plinthStatics.clear(),this.massIndex.clear(),this.frameSubscribers.clear(),this.gpuTimer?.dispose(),this.gpuTimer=null,this.gpu?.dispose()}}function wT(n,i=2e3){return n.clientWidth>0&&n.clientHeight>0?Promise.resolve():new Promise(r=>{let l=!1;const u=()=>{l||(l=!0,f.disconnect(),clearTimeout(d),r())},f=new ResizeObserver(()=>{n.clientWidth>0&&n.clientHeight>0&&u()});f.observe(n);const d=setTimeout(u,i)})}const X={bg:"#050608",ink:"#e6e3db",accent:"#d9a441",accentBright:"#f0c374",hoverInk:"#f5cf8b",panel:"rgba(7,8,11,0.94)",panelBorder:"rgba(230,227,219,0.4)",hairline:"rgba(230,227,219,0.14)",chrome:"rgba(230,227,219,0.62)",chromeDim:"rgba(230,227,219,0.4)",chromeMid:"rgba(230,227,219,0.7)",chromeStrong:"rgba(230,227,219,0.82)",body:"rgba(230,227,219,0.88)"},at={running:"rgba(240,195,116,0.85)",waiting:"rgba(150,175,196,0.85)",failed:"rgba(206,104,90,0.9)",completed:"rgba(180,210,175,0.75)",idle:"rgba(230,227,219,0.62)"},Et="'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace",Ka="0 0 6px rgba(5,6,8,0.95)",ET={backgroundImage:"radial-gradient(rgba(230,227,219,0.05) 0.5px, rgba(0,0,0,0) 0.6px)",backgroundSize:"3px 3px"},AT={background:"radial-gradient(96% 82% at 44% 56%, rgba(0,0,0,0) 42%, rgba(3,3,5,0.9) 100%)"},TT={background:"linear-gradient(to bottom, rgba(6,8,11,0.7), rgba(6,8,11,0))"};let $c=Promise.resolve();function MT({landscape:n,onHover:i,onSelect:r,anchor:l,children:u,onBand:f,onReady:d,depth:h,overlay:m,inset:g,keepVisible:x,compact:b=!1}){const D=Q.useRef(null),$=Q.useRef(null),k=Q.useRef(null),N=Q.useRef({...m0}),V=Q.useRef(n),Z=Q.useRef(new Map),I=Q.useRef(null),F=Q.useRef(null),Y=Q.useRef(null),P=Q.useRef(null),he=Q.useRef(null),M=Q.useRef(new Map),E=Q.useRef(null),j=Q.useRef({key:"",w:0,h:0,label:!1}),[W,te]=Q.useState("init"),[le,$e]=Q.useState(null),[de,se]=Q.useState("environment"),[R,H]=Q.useState([]),[ae,Te]=Q.useState("grab");V.current=n,Q.useEffect(()=>{const ee=$.current;if(!ee)return;let J=!1,ye=null;const Ce=$c.then(async()=>{if(!J){if(ye=new ST({canvas:ee,camera:N.current}),await ye.init(),J){ye.dispose(),ye=null;return}k.current=ye,ye.setLandscape(V.current),ye.start(),te("ready"),d?.(ye)}}).catch(Qe=>{J||($e(Qe instanceof Error?Qe.message:String(Qe)),te("failed"))});return $c=Ce,()=>{J=!0,k.current=null,$c=Ce.then(()=>{ye?.dispose(),ye=null})}},[]),Q.useEffect(()=>{k.current?.setLandscape(n)},[n]),Q.useEffect(()=>{const ee=[];for(const J of n.masses)ee.push({id:`mass:${J.id}`,wx:J.x,wy:J.y+J.extentY+26,text:J.name,color:"rgba(230,227,219,0.78)",size:10});if(de==="proximity"){for(const J of n.disturbances)J.energy<.02&&J.status!=="completed"||ee.push({id:`dist:${J.id}`,wx:J.x,wy:J.y-30-J.extent*40,text:`${J.label} · ${J.status}`,color:at[J.status],size:9});for(const J of n.plinths)ee.push({id:`plinth:${J.id}`,wx:J.x,wy:J.y-J.extentY-16,text:`${J.parentId?"└ ":""}${J.label}${J.observers>1?` · ${J.observers} obs`:""}`,color:`rgba(240,195,116,${(.16+.5*J.articulation).toFixed(2)})`,size:9})}H(ee)},[n,de]),Q.useLayoutEffect(()=>{const ee=k.current;if(!ee)return;let J=0;const ye=Ce=>{const Qe=N.current,Ke=performance.now(),Qt=J===0?1/60:Math.min(.1,(Ke-J)/1e3);J=Ke,P.current&&(mT(Qe,P.current,Qt)&&(P.current=null),ee.noteInteraction());const Ve=dT(Re.current,Qe.zoom);Ve!==Re.current&&(Re.current=Ve,se(Ve),f?.(Ve));for(const[At,ct]of Z.current){const He=U.current.get(At);if(!He)continue;const[St,tt]=Gc(He.wx,He.wy,Qe,Ce),zi=St>-200&&St<Ce.width+200&&tt>-80&&tt<Ce.height+80;ct.style.visibility=zi?"visible":"hidden",ct.style.transform=`translate3d(${St}px, ${tt}px, 0) translate(-50%, -100%)`}const dn=I.current,xt=w.current;if(dn&&xt){const[At,ct]=Gc(xt.x,xt.y,Qe,Ce),He=dn.firstElementChild;He&&j.current.key!==xt.id&&(j.current={key:xt.id,w:He.offsetWidth,h:He.offsetHeight,label:He.dataset.anchorPlacement==="label"});const{w:St,h:tt,label:zi}=j.current;let _i=zi?-St/2:18,rr=zi?-tt-14:-tt/2;!zi&&At+_i+St>Ce.width-12&&(_i=-St-18),_i=Math.max(12-At,_i),rr=Math.min(Math.max(12-ct,rr),Ce.height-12-tt-ct),dn.style.transform=`translate3d(${At+_i}px, ${ct+rr}px, 0)`,dn.style.visibility=At>-300&&At<Ce.width+300&&ct>-300&&ct<Ce.height+300?"visible":"hidden"}const Lt=Qe.cy+Ce.height/Zn(Qe,Ce)/2,Mn=Lt>wn.strataTop+40,ra=Lt>wn.strataTop+wn.strataHeight*.7,Dn=F.current,Oi=Dn?.querySelector("[data-depth-label]");if(Oi){const At=Mn?ra?"FIELD — TODAY":"FIELD — SURFACE + TODAY":"FIELD — LIVE";Oi.textContent!==At&&(Oi.textContent=At)}if(Dn){const At=Dn.querySelector("[data-depth-summary]"),ct=Dn.querySelector("[data-depth-deep]");if(At&&(At.style.display=Mn?"inline-flex":"none"),ct){const He=ct.dataset.depthSuppressed==="true";ct.style.display=ra&&!He?"block":"none"}}};return ee.onFrame(ye)},[W,f]);const Re=Q.useRef("environment"),w=Q.useRef(null),U=Q.useRef(new Map);w.current=l,Q.useEffect(()=>{U.current=new Map(R.map(ee=>[ee.id,ee]))},[R]);const q=Q.useCallback(()=>{const ee=D.current;return{width:ee?.clientWidth??1,height:ee?.clientHeight??1}},[]),K=g?.right??0,oe=g?.bottom??0,fe=x?.id??null,me=x?.x??0,Pe=x?.y??0;Q.useEffect(()=>{const ee=k.current;if(!ee||!fe||K===0&&oe===0)return;const J=q(),ye={...P.current??N.current},Ce=Zn(ye,J);if(Ce<=0)return;const[Qe,Ke]=Gc(me,Pe,ye,J);let Qt=!1;if(K>0){const Ve=J.width-K-40;Qe>Ve&&(ye.cx+=(Qe-(J.width-K)/2)/Ce,Qt=!0)}if(oe>0){const Ve=J.height-oe-40;Ke>Ve&&(ye.cy+=(Ke-(Ve-60))/Ce,Qt=!0)}Ke<70&&(ye.cy-=(110-Ke)/Ce,Qt=!0),Qt&&(P.current=ms(ye),ee.noteInteraction())},[fe,me,Pe,K,oe,q]);const De=Q.useCallback(ee=>{const J=D.current.getBoundingClientRect();return[ee.clientX-J.left,ee.clientY-J.top]},[]),gn=Q.useCallback(ee=>{const J=k.current;if(!J)return;const[ye,Ce]=De(ee);P.current=null,ee.ctrlKey||ee.metaKey?Bc(N.current,Math.exp(-ee.deltaY*.012),ye,Ce,q()):g0(N.current,ee.deltaX,ee.deltaY,q()),J.noteInteraction()},[De,q]);Q.useEffect(()=>{const ee=D.current;if(!ee)return;const J=ye=>ye.preventDefault();return ee.addEventListener("wheel",J,{passive:!1}),()=>ee.removeEventListener("wheel",J)},[]);const Wn=Q.useCallback(ee=>{const J=De(ee);ee.isPrimary&&M.current.clear(),M.current.set(ee.pointerId,J),P.current=null;try{D.current?.setPointerCapture(ee.pointerId)}catch{}if(M.current.size===1)Y.current={x:J[0],y:J[1],moved:!1},Te("grabbing");else if(M.current.size===2){const[ye,Ce]=[...M.current.values()];E.current={distance:Math.hypot(ye[0]-Ce[0],ye[1]-Ce[1]),zoom:N.current.zoom},Y.current=null}k.current?.noteInteraction()},[De]),Mt=Q.useCallback(ee=>{const J=k.current;if(!J)return;const ye=De(ee),Ce=M.current.has(ee.pointerId);Ce&&M.current.set(ee.pointerId,ye);const Qe=E.current;if(Qe&&M.current.size>=2){const[xt,Lt]=[...M.current.values()],Mn=Math.hypot(xt[0]-Lt[0],xt[1]-Lt[1]),ra=(xt[0]+Lt[0])/2,Dn=(xt[1]+Lt[1])/2,Oi=Qe.zoom*(Mn/Math.max(12,Qe.distance));Bc(N.current,Oi/N.current.zoom,ra,Dn,q()),J.noteInteraction();return}const Ke=Y.current;if(Ce&&Ke){const xt=ye[0]-Ke.x,Lt=ye[1]-Ke.y;(Math.abs(xt)>4||Math.abs(Lt)>4)&&(Ke.moved=!0),g0(N.current,-xt,-Lt,q()),Ke.x=ye[0],Ke.y=ye[1],J.noteInteraction();return}if(ee.pointerType==="touch")return;const[Qt,Ve]=of(ye[0],ye[1],N.current,q()),dn=Ym(V.current,Qt,Ve);Te(dn?"pointer":"grab"),(dn||he.current)&&J.noteInteraction(),he.current=dn,i(dn)},[De,i,q]),Tn=Q.useCallback(ee=>{const J=M.current.get(ee.pointerId)??De(ee);M.current.delete(ee.pointerId),M.current.size<2&&(E.current=null);const ye=Y.current;if(Y.current=null,Te("grab"),!ye||ye.moved)return;const[Ce,Qe]=of(J[0],J[1],N.current,q()),Ke=Ym(V.current,Ce,Qe);if(r(Ke),Ke&&Ke.kind!=="stratum"){const Qt=Ke.kind==="mass"?uf:uf+.5;P.current=gT(Ke.x,Ke.y,Math.max(N.current.zoom,Qt))}k.current?.noteInteraction()},[De,r,q]),be=Q.useCallback(()=>{Y.current=null,E.current=null,M.current.clear(),Te("grab")},[]),yn=Q.useCallback(()=>{P.current={...m0},k.current?.noteInteraction(),r(null)},[r]),fn=Q.useCallback(ee=>{const J=q();Bc(N.current,ee,J.width/2,J.height/2,J),k.current?.noteInteraction()},[q]);return v.jsxs("div",{style:{position:"relative",flex:1,minHeight:0},children:[v.jsxs("div",{ref:D,onWheel:gn,onPointerDown:Wn,onPointerMove:Mt,onPointerUp:Tn,onPointerCancel:Tn,onLostPointerCapture:ee=>{M.current.delete(ee.pointerId),M.current.size<2&&(E.current=null)},onPointerLeave:ee=>{ee.pointerType!=="touch"&&(be(),i(null))},style:{position:"absolute",inset:0,overflow:"hidden",background:X.bg,cursor:ae},children:[v.jsx("canvas",{ref:$,style:{display:"block",width:"100%",height:"100%"}}),v.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",...ET}}),v.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",...AT}}),v.jsx("div",{style:{position:"absolute",left:0,right:0,top:0,height:"16%",pointerEvents:"none",...TT}}),v.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:[R.map(ee=>v.jsx("div",{ref:J=>{J?Z.current.set(ee.id,J):Z.current.delete(ee.id)},style:{position:"absolute",left:0,top:0,willChange:"transform",visibility:"hidden",fontFamily:Et,fontSize:ee.size,letterSpacing:"0.22em",color:ee.color,whiteSpace:"nowrap",textTransform:"uppercase"},children:ee.text},ee.id)),l&&v.jsx("div",{ref:I,style:{position:"absolute",left:0,top:0,willChange:"transform",visibility:"hidden",pointerEvents:"auto"},children:u})]}),m&&v.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:m}),h&&v.jsx("div",{ref:F,style:{position:"absolute",inset:0,pointerEvents:"none"},children:h}),W==="failed"&&v.jsx("div",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center",fontFamily:Et,fontSize:11,letterSpacing:"0.18em",color:at.failed,textAlign:"center",padding:40},children:v.jsxs("div",{children:[v.jsx("div",{children:"FIELD UNAVAILABLE — WEBGPU DID NOT START"}),v.jsx("div",{style:{marginTop:10,color:X.chrome,letterSpacing:"0.08em"},children:le})]})})]}),v.jsx(DT,{onSurface:yn,onZoom:fn,compact:b})]})}function DT({onSurface:n,onZoom:i,compact:r}){if(r)return v.jsx("div",{style:{position:"absolute",right:14,bottom:18},children:v.jsx("button",{onClick:n,style:{width:52,height:52,borderRadius:"50%",background:"rgba(7,8,11,0.9)",border:"1px solid rgba(230,227,219,0.5)",color:X.ink,fontFamily:Et,fontSize:8.5,letterSpacing:"0.1em",cursor:"pointer"},children:"SURF"})});const l={background:"transparent",border:`1px solid ${X.chromeDim}`,color:X.chromeStrong,fontFamily:Et,fontSize:10,letterSpacing:"0.14em",padding:"7px 12px",cursor:"pointer"};return v.jsxs("div",{style:{position:"absolute",right:16,bottom:16,display:"flex",gap:8},children:[v.jsx("button",{style:l,onClick:()=>i(1.35),"aria-label":"Zoom in",children:"+"}),v.jsx("button",{style:l,onClick:()=>i(1/1.35),"aria-label":"Zoom out",children:"−"}),v.jsx("button",{style:l,onClick:n,children:"SURFACE"})]})}const T0="(no model)";function sn({name:n,value:i,measure:r,accent:l,note:u}){const f=r?.basis==="inferred";return v.jsxs("div",{title:f?r?.assumption:void 0,style:{display:"flex",flexDirection:"column",gap:5,padding:"12px 0",borderTop:`1px solid ${X.hairline}`,cursor:f?"help":"default"},children:[v.jsxs("div",{style:{fontSize:9.5,letterSpacing:"0.22em",color:X.chrome,display:"flex",alignItems:"baseline",gap:6},children:[n,f&&v.jsx("span",{style:{color:X.chromeDim,letterSpacing:"0.1em"},children:"inferred"})]}),v.jsx("div",{style:{fontSize:21,letterSpacing:"0.02em",color:l??X.ink,fontVariantNumeric:"tabular-nums"},children:i}),u&&v.jsx("div",{style:{fontSize:9.5,color:X.chromeDim},children:u})]})}function Wi({title:n,children:i}){return v.jsxs("div",{style:{marginTop:40},children:[v.jsx("div",{style:{fontSize:9.5,letterSpacing:"0.24em",color:X.chrome},children:n}),v.jsx("div",{style:{marginTop:12},children:i})]})}function Ky({fraction:n,color:i}){return v.jsx("div",{style:{height:3,background:"rgba(230,227,219,0.08)",width:"100%"},children:v.jsx("div",{style:{height:"100%",width:`${Math.max(.5,Math.min(1,n)*100)}%`,background:i}})})}function Vc({rows:n,max:i,label:r,color:l}){return v.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:n.map(u=>v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[v.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16,fontSize:11,fontVariantNumeric:"tabular-nums"},children:[v.jsx("span",{style:{color:X.body},children:r(u.key)}),v.jsxs("span",{style:{color:X.chromeMid},children:[u.runs," ",u.runs===1?"run":"runs",u.tokenRuns>0?` · ${pt(u.tokens)} tok`:""," · ",Ye(u.computeMs),u.failed>0&&v.jsxs("span",{style:{color:at.failed},children:[" · ",u.failed," failed"]})]})]}),v.jsx(Ky,{fraction:i>0?u.computeMs/i:0,color:l})]},u.key))})}function RT({world:n}){const i=Q.useMemo(()=>L0(n),[n]),r=Q.useMemo(()=>j0(n,i),[n,i]),l=Q.useMemo(()=>kx(n),[n]),u=Q.useMemo(()=>jx(n),[n]),f=Q.useMemo(()=>Gx(n),[n]),d=Q.useMemo(()=>Bx(n),[n]),h=Q.useMemo(()=>Cc(n,(I,F)=>F?.context),[n]),m=Q.useMemo(()=>Cc(n,I=>I.model??T0),[n]),g=Q.useMemo(()=>Cc(n,I=>I.machineId),[n]),x=Q.useMemo(()=>[...n.executions.values()].filter(I=>I.status==="failed").sort((I,F)=>F.startedAt-I.startedAt),[n]),b=i.longestFocus.value,D=Q.useMemo(()=>[...n.executions.values()].filter(I=>qt(I.measures)===void 0).length,[n]),$=h[0]?.computeMs??0,k=m[0]?.computeMs??0,N=g[0]?.computeMs??0,V=d.reduce((I,F)=>F.computeMs>I.computeMs?F:I,d[0]),Z=[...n.executions.values()].filter(I=>I.depth>0).length;return v.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"28px 48px 80px",fontFamily:Et,color:X.ink},children:[v.jsxs("div",{style:{marginBottom:34,maxWidth:900},children:[v.jsx("div",{style:{fontSize:9.5,letterSpacing:"0.24em",color:X.chrome},children:"WORK SHAPE"}),v.jsx("div",{style:{fontSize:34,letterSpacing:"0.08em",marginTop:10,color:X.accentBright},children:r.headline}),v.jsx("div",{style:{marginTop:14,display:"flex",flexDirection:"column",gap:7},children:r.clauses.map(I=>v.jsx("div",{style:{fontSize:12,lineHeight:1.65,color:X.body,letterSpacing:"0.02em"},children:I},I))})]}),v.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(190px, 1fr))",gap:"0 40px"},children:[v.jsx(sn,{name:"REQUESTS",value:pt(i.requests.value),measure:i.requests}),v.jsx(sn,{name:"RUNS",value:String(i.executions.value),measure:i.executions,note:Z>0?`${Z} of them sub-agents`:void 0}),v.jsx(sn,{name:"SESSIONS",value:String(i.sessions.value),measure:i.sessions}),v.jsx(sn,{name:"TOKENS",value:pt(i.tokens.value),measure:i.tokens,note:`${Math.round(l.cacheRead/Math.max(1,l.total)*100)}% cache reads`+(D>0?` · ${D} ${D===1?"run reports":"runs report"} no accounting`:"")}),v.jsx(sn,{name:"TOOL CALLS",value:pt(f.toolCalls),measure:i.toolCalls,note:f.toolErrors>0?`${f.toolErrors} failed`:void 0}),v.jsx(sn,{name:"AUTONOMOUS COMPUTE",value:Ye(i.autonomousCompute.value),measure:i.autonomousCompute}),v.jsx(sn,{name:"HUMAN + AGENT OVERLAP",value:Ye(i.humanAgentOverlap.value),measure:i.humanAgentOverlap,note:`${Math.round(i.humanAgentOverlap.value/Math.max(1,i.autonomousCompute.value)*100)}% of compute`}),v.jsx(sn,{name:"PEAK CONCURRENCY",value:i.peakConcurrency.value>0?`${i.peakConcurrency.value} · ${Pa(i.peakConcurrencyAt.value)}`:"0",measure:i.peakConcurrency}),v.jsx(sn,{name:"CONTEXT SWITCHES",value:String(i.contextSwitches.value),measure:i.contextSwitches,note:`across ${h.length} ${h.length===1?"context":"contexts"}`}),v.jsx(sn,{name:"LONGEST FOCUS",value:b?Ye(b.end-b.start):"—",measure:i.longestFocus,note:b?`${us(b.context)} · ${Pa(b.start)}–${Pa(b.end)}`:void 0}),v.jsx(sn,{name:"WAITING ON YOU",value:Ye(i.waitingOnYou.value),measure:i.waitingOnYou,accent:i.waitingOnYou.value>0?at.waiting:void 0,note:u.count>0?`${u.count} ${u.count===1?"block":"blocks"} · longest ${Ye(u.longestMs)}`:void 0}),v.jsx(sn,{name:"FAILED",value:String(f.failed),accent:f.failed>0?at.failed:void 0,note:f.interrupted>0||f.retries>0?`${f.interrupted} stopped · ${f.retries} retries`:void 0})]}),d.length>0&&v.jsxs(Wi,{title:"HOUR BY HOUR",children:[v.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:3,height:84},children:d.map((I,F)=>{const Y=I.computeMs/36e5;return v.jsx("div",{title:`${String(I.hour).padStart(2,"0")}:00 — ${Ye(I.computeMs)} of compute, ${I.runs} runs, peak ${I.peak}`,style:{flex:1,minWidth:4,height:"100%",display:"flex",flexDirection:"column",justifyContent:"flex-end"},children:v.jsx("div",{style:{height:`${Math.max(1,Y*100)}%`,background:I.peak>1?"rgba(240,195,116,0.75)":"rgba(214,176,116,0.38)"}})},F)})}),v.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:6,fontSize:9,letterSpacing:"0.16em",color:X.chromeDim},children:[v.jsxs("span",{children:[String(d[0].hour).padStart(2,"0"),":00"]}),v.jsxs("span",{children:["busiest ",String(V.hour).padStart(2,"0"),":00 · ",Ye(V.computeMs)," ","of that hour"]}),v.jsxs("span",{children:[String(d[d.length-1].hour).padStart(2,"0"),":00"]})]})]}),v.jsx(Wi,{title:"WHERE THE TIME WENT",children:v.jsx(Vc,{rows:h,max:$,label:us,color:"rgba(240,195,116,0.6)"})}),g.length>0&&v.jsx(Wi,{title:"BY MACHINE",children:v.jsx(Vc,{rows:g,max:N,label:I=>n.machines.get(I)?.name??I,color:"rgba(168,186,150,0.6)"})}),m.length>0&&v.jsx(Wi,{title:"BY MODEL",children:v.jsx(Vc,{rows:m,max:k,label:I=>I===T0?"model not observed":I,color:"rgba(150,175,196,0.6)"})}),v.jsxs(Wi,{title:"TOKEN COMPOSITION",children:[v.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[["CACHE READS",l.cacheRead,"rgba(150,175,196,0.6)"],["INPUT",l.input,"rgba(240,195,116,0.6)"],["OUTPUT",l.output,"rgba(180,210,175,0.7)"],["REASONING",l.reasoning,"rgba(214,176,116,0.5)"]].map(([I,F,Y])=>v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[v.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,fontVariantNumeric:"tabular-nums"},children:[v.jsx("span",{style:{color:X.body},children:I}),v.jsxs("span",{style:{color:X.chromeMid},children:[pt(F)," · ",Math.round(F/Math.max(1,l.total)*100),"%"]})]}),v.jsx(Ky,{fraction:F/Math.max(1,l.total),color:Y})]},I))}),v.jsx("div",{style:{marginTop:12,fontSize:10,lineHeight:1.7,color:X.chromeDim},children:"Cache reads are context replayed into each request, not work generated. They dominate the total, which is why the headline token figure is much larger than it feels."})]}),x.length>0&&v.jsx(Wi,{title:"FAILURES",children:v.jsx("div",{style:{display:"flex",flexDirection:"column",gap:9},children:x.slice(0,12).map(I=>v.jsxs("div",{style:{display:"flex",gap:16,fontSize:11,borderTop:`1px solid ${X.hairline}`,paddingTop:8},children:[v.jsx("span",{style:{color:X.chromeMid,minWidth:46},children:Pa(I.startedAt)}),v.jsx("span",{style:{color:X.body,minWidth:160},children:I.label}),v.jsxs("span",{style:{color:at.failed},children:[I.failure?.code,": ",I.failure?.message]})]},I.id))})}),v.jsx(CT,{})]})}function CT(){return v.jsx(Wi,{title:"NOT AVAILABLE FROM THESE SOURCES",children:v.jsxs("div",{style:{maxWidth:760,fontSize:10.5,lineHeight:1.8,color:X.chromeDim},children:[v.jsx("div",{children:"COST — every source here reports tokens or CPU time; none reports money. Converting one to the other needs a price table 057 does not have, so no cost figure is shown anywhere."}),v.jsx("div",{style:{marginTop:8},children:"TOKENS, FROM SOME SOURCES — Cursor persists no usage and 0x2F records none; their runs read NOT OBSERVED rather than 0, and the token totals sum only the runs that report."}),v.jsx("div",{style:{marginTop:8},children:"MACHINE-TO-MACHINE TRANSFER — every observed source is single-host. Transfers are modelled and the field renders them, but no real adapter emits one; only the synthetic source does."}),v.jsx("div",{style:{marginTop:8},children:"PROCESS EXITS — the OS collector samples; an exit is inferred from disappearance between samples, never witnessed."}),v.jsx("div",{style:{marginTop:8},children:"OUTCOME QUALITY — the log records that a run completed, not whether the work was any good."})]})})}const Ic=100,M0="58px minmax(180px,1.4fr) 104px 132px 84px 68px 62px 70px 56px";function OT(n){return n.outcome==="interrupted"?"STOPPED":n.status}function zT(n){return n.outcome==="interrupted"?X.chromeMid:at[n.status]}function Ti({children:n,align:i="left",color:r}){return v.jsx("div",{style:{textAlign:i,color:r??X.chromeMid,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n})}function _T({p:n,session:i,onShowInField:r}){const l=qt(n.measures),u=n.startBasis==="inferred"||n.endBasis==="inferred",f=[["CONTEXT",i?i.context:"—"],["PROVIDER",n.executor],["MODEL",n.model??"not observed"],["STARTED",`${n.startBasis==="inferred"?"~":""}${new Date(n.startedAt).toLocaleTimeString()}`],["ENDED",n.endedAt?`${n.endBasis==="inferred"?"~":""}${new Date(n.endedAt).toLocaleTimeString()}`:"still open"],...l===void 0?[["TOKENS","not observed"]]:[["INPUT",pt(Za(n.measures).input)],["OUTPUT",pt(Za(n.measures).output)],["CACHE READ",pt(Za(n.measures).cacheRead)],["REASONING",pt(Za(n.measures).reasoning)]],["REQUESTS",String(ff(n))],["TOOL CALLS",Wa(un(n),"not observed")]];return ta(n)>0&&f.push(["TOOL ERRORS",String(ta(n)),at.failed]),Yc(n)>0&&f.push(["PROVIDER RETRIES",String(Yc(n)),at.waiting]),(n.waits.length>0||n.waitingMs>0)&&f.push(["BLOCKED ON YOU",`${Ye(n.waitingMs)} across ${n.waits.length||1}`,at.waiting]),n.depth>0&&f.push(["SUB-AGENT",`depth ${n.depth}`]),v.jsxs("div",{style:{gridColumn:"1 / -1",display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"6px 28px",padding:"12px 0 14px 16px",borderLeft:`1px solid ${X.panelBorder}`,margin:"2px 0 6px",background:"rgba(230,227,219,0.02)"},children:[f.map(([d,h,m])=>v.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[v.jsx("span",{style:{fontSize:9.5,letterSpacing:"0.16em",color:X.chrome},children:d}),v.jsx("span",{style:{fontSize:10.5,color:m??X.body,fontVariantNumeric:"tabular-nums",overflow:"hidden",textOverflow:"ellipsis"},children:h})]},d)),n.failure&&v.jsxs("div",{style:{gridColumn:"1 / -1",fontSize:10.5,color:at.failed},children:[n.failure.code,": ",n.failure.message]}),u&&n.boundsAssumption&&v.jsxs("div",{style:{gridColumn:"1 / -1",fontSize:9.5,color:X.chromeMid},children:["timing inferred — ",n.boundsAssumption]}),v.jsx("div",{style:{gridColumn:"1 / -1",marginTop:4},children:v.jsx("button",{onClick:d=>{d.stopPropagation(),r()},style:{background:"transparent",border:`1px solid ${X.hairline}`,color:X.chromeMid,fontFamily:Et,fontSize:9,letterSpacing:"0.16em",padding:"5px 10px",cursor:"pointer"},children:"SHOW IN FIELD →"})})]})}function UT({world:n,selectedId:i,onSelect:r}){const[l,u]=Q.useState("all"),[f,d]=Q.useState("time"),[h,m]=Q.useState(Ic),[g,x]=Q.useState(null),b=Q.useMemo(()=>{let V=[...n.executions.values()];l==="stopped"?V=V.filter(F=>F.outcome==="interrupted"):l!=="all"&&(V=V.filter(F=>F.status===l&&F.outcome!=="interrupted"));const Z=F=>(F.endedAt??n.now)-F.startedAt,I={time:(F,Y)=>Y.startedAt-F.startedAt,duration:(F,Y)=>Z(Y)-Z(F),tokens:(F,Y)=>(qt(Y.measures)??0)-(qt(F.measures)??0),tools:(F,Y)=>(un(Y)??0)-(un(F)??0),waited:(F,Y)=>Y.waitingMs-F.waitingMs};return V.sort(I[f])},[n,l,f]),D=Q.useMemo(()=>{const V={all:n.executions.size,stopped:0};for(const Z of n.executions.values())Z.outcome==="interrupted"?V.stopped++:V[Z.status]=(V[Z.status]??0)+1;return V},[n]),$=Q.useMemo(()=>{let V=0,Z=0,I=0,F=0;for(const Y of b)V+=qt(Y.measures)??0,Z+=(Y.endedAt??n.now)-Y.startedAt,I+=un(Y)??0,F+=Y.waitingMs;return{tokens:V,compute:Z,tools:I,waited:F}},[b,n]),k=b.slice(0,h),N=(V,Z,I="left")=>v.jsxs("div",{onClick:()=>d(V),style:{textAlign:I,cursor:"pointer",color:f===V?X.ink:X.chrome},children:[Z,f===V?" ↓":""]});return v.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px 48px 80px",fontFamily:Et,color:X.ink},children:[v.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap",marginBottom:14},children:["all","running","waiting","idle","completed","failed","stopped"].map(V=>{const Z=l===V,I=D[V]??0;return v.jsxs("button",{onClick:()=>{u(V),m(Ic)},style:{background:"transparent",border:`1px solid ${Z?"rgba(230,227,219,0.6)":X.hairline}`,color:Z?X.ink:X.chromeMid,fontFamily:Et,fontSize:9.5,letterSpacing:"0.16em",padding:"6px 11px",cursor:"pointer",textTransform:"uppercase"},children:[V," ",I>0&&v.jsx("span",{style:{color:X.chromeDim},children:I})]},V)})}),v.jsxs("div",{style:{fontSize:10,letterSpacing:"0.12em",color:X.chromeDim,marginBottom:14,fontVariantNumeric:"tabular-nums"},children:[b.length," ",b.length===1?"run":"runs"," shown · ",pt($.tokens)," tok ·"," ",Ye($.compute)," of run time · ",pt($.tools)," tool calls",$.waited>0&&` · ${Ye($.waited)} blocked on you`]}),v.jsxs("div",{style:{display:"grid",gridTemplateColumns:M0,gap:"0 14px",fontSize:9,letterSpacing:"0.18em",color:X.chrome,paddingBottom:8,borderBottom:`1px solid ${X.hairline}`},children:[N("time","START"),v.jsx("div",{children:"RUN"}),v.jsx("div",{children:"CONTEXT"}),v.jsx("div",{children:"MODEL"}),v.jsx("div",{children:"STATUS"}),N("duration","DUR","right"),N("tokens","TOKENS","right"),N("waited","WAITED","right"),N("tools","TOOLS","right")]}),k.map(V=>{const Z=n.sessions.get(V.sessionId),I=V.id===i,F=g===V.id;return v.jsxs("div",{children:[v.jsxs("div",{onClick:()=>x(F?null:V.id),style:{display:"grid",gridTemplateColumns:M0,gap:"0 14px",fontSize:11,padding:"9px 0",borderBottom:"1px solid rgba(230,227,219,0.05)",cursor:"pointer",background:I||F?"rgba(240,195,116,0.07)":"transparent",fontVariantNumeric:"tabular-nums"},children:[v.jsx(Ti,{children:Pa(V.startedAt)}),v.jsxs(Ti,{color:I||F?X.accentBright:X.body,children:[V.depth>0&&v.jsx("span",{style:{color:X.chromeDim},children:"└ "}),V.label]}),v.jsx(Ti,{children:Z?us(Z.context):"—"}),v.jsx(Ti,{color:V.model?void 0:X.chromeDim,children:V.model??"—"}),v.jsx("div",{style:{fontSize:9,letterSpacing:"0.14em",color:zT(V),textTransform:"uppercase"},children:OT(V)}),v.jsxs(Ti,{align:"right",children:[V.startBasis==="inferred"||V.endBasis==="inferred"?"~":"",Ye((V.endedAt??n.now)-V.startedAt)]}),v.jsx(Ti,{align:"right",color:qt(V.measures)===void 0?X.chromeDim:void 0,children:Wa(qt(V.measures),"—")}),v.jsx(Ti,{align:"right",color:V.waitingMs>0?at.waiting:X.chromeDim,children:V.waitingMs>0?Ye(V.waitingMs):"—"}),v.jsxs(Ti,{align:"right",color:un(V)===void 0?X.chromeDim:void 0,children:[Wa(un(V),"—"),ta(V)>0&&v.jsxs("span",{style:{color:at.failed},children:[" /",ta(V)]})]})]}),F&&v.jsx(_T,{p:V,session:Z,onShowInField:()=>r(V.id)})]},V.id)}),b.length===0&&v.jsx("div",{style:{padding:"28px 0",fontSize:11,color:X.chromeMid},children:"Nothing matching in this window."}),b.length>h&&v.jsxs("button",{onClick:()=>m(V=>V+Ic),style:{marginTop:18,background:"transparent",border:`1px solid ${X.hairline}`,color:X.chromeMid,fontFamily:Et,fontSize:9.5,letterSpacing:"0.16em",padding:"8px 14px",cursor:"pointer"},children:["SHOW MORE — ",b.length-h," REMAINING"]})]})}const Fc={display:"flex",flexDirection:"column",gap:5,background:X.panel,borderLeft:`1px solid ${X.panelBorder}`,padding:"9px 13px",minWidth:170,maxWidth:320,fontFamily:Et,backdropFilter:"blur(2px)"};function Ue({name:n,detail:i,color:r,title:l,tag:u}){return v.jsxs("div",{title:l,style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:16,fontSize:10.5,cursor:l?"help":void 0},children:[v.jsxs("span",{style:{color:X.chromeMid,letterSpacing:"0.1em",whiteSpace:"nowrap"},children:[n,u&&v.jsxs("span",{style:{color:X.chromeDim,letterSpacing:"0.06em"},children:[" ",u]})]}),v.jsx("span",{style:{fontSize:10,fontWeight:500,letterSpacing:"0.14em",color:r??X.chromeStrong,whiteSpace:"nowrap",textAlign:"right",overflow:"hidden",textOverflow:"ellipsis",maxWidth:190},children:i})]})}function Hc({text:n,onClose:i}){return v.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:14},children:[v.jsx("div",{style:{fontSize:10,letterSpacing:"0.18em",color:X.ink,textTransform:"uppercase"},children:n}),v.jsx("div",{onClick:i,role:"button",style:{fontSize:11,color:X.chromeMid,cursor:"pointer"},children:"×"})]})}function _f({label:n}){return v.jsx("div",{style:{marginTop:5,paddingTop:5,borderTop:"1px solid rgba(230,227,219,0.08)",fontSize:8.5,letterSpacing:"0.2em",color:X.chromeDim},children:n})}function NT(n){if(n.basis==="measured")return{label:"recorded",grade:"recorded"};const i=n.via?.split("|")[0];return i==="agent.session"?{label:"session identity",grade:"identity"}:i==="os.process"?{label:"process identity",grade:"identity"}:i==="fs.cwd"?{label:"directory overlap",grade:"contextual"}:{label:"inferred",grade:"contextual"}}function LT(n,i){switch(i.type){case"process":{const r=n.processes.get(i.id);return r?`PID ${r.pid} · ${r.command}`:i.id}case"session":return n.sessions.get(i.id)?.label??i.id;case"execution":return n.executions.get(i.id)?.label??i.id;case"machine":return n.machines.get(i.id)?.name??i.id;default:return i.id}}const D0={"ran-as":"RAN AS","same-as":"SAME AS",spawned:"SPAWNED",contains:"CONTAINS",produced:"PRODUCED"};function R0({world:n,subject:i}){const r=n.relationships.filter(l=>l.from.type===i.type&&l.from.id===i.id||l.to.type===i.type&&l.to.id===i.id);return r.length===0?null:v.jsxs(v.Fragment,{children:[v.jsx(_f,{label:"RELATED"}),r.slice(0,6).map((l,u)=>{const f=l.from.type===i.type&&l.from.id===i.id,d=f?l.to:l.from,h=f?D0[l.kind]:l.kind==="spawned"?"SPAWNED BY":D0[l.kind],m=NT(l);return v.jsx(Ue,{name:h,tag:m.grade==="contextual"?`${m.label} · inferred`:m.label,detail:LT(n,d),color:m.grade==="contextual"?X.chromeMid:void 0,title:l.assumption??(l.via?`via ${l.via}`:void 0)},`${l.kind}:${d.type}:${d.id}:${u}`)})]})}function kT({type:n,id:i}){const[r,l]=Q.useState(null);return Q.useEffect(()=>{let u=!1;l(null);const f=setTimeout(()=>{l1(n,i).then(({events:d})=>{u||l(jT(d))}).catch(()=>{u||l(null)})},180);return()=>{u=!0,clearTimeout(f)}},[n,i]),!r||r.facts.length===0&&!r.provenance?null:v.jsxs(v.Fragment,{children:[v.jsx(_f,{label:"NATIVE RECORD"}),r.facts.map(([u,f])=>v.jsx(Ue,{name:u,detail:f,color:X.chromeMid},u)),r.provenance&&v.jsxs("div",{title:r.provenance,style:{fontSize:8.5,letterSpacing:"0.04em",color:X.chromeDim,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"help"},children:["read from ",r.provenance]})]})}function jT(n){const i=new Map;let r;for(const u of n){for(const[f,d]of Object.entries(u.attrs??{}))!f.includes(".")||d===void 0||d===null||d===""||i.set(f,d);!r&&u.provenance?.path&&(r=u.provenance.path)}return{facts:[...i.entries()].slice(0,10).map(([u,f])=>[u,typeof f=="object"?JSON.stringify(f):String(f)]),provenance:r}}function GT({p:n,now:i}){const r=(n.endedAt??i)-n.startedAt,l=n.startBasis==="inferred",u=n.endBasis==="inferred",f=l||u;return v.jsxs(v.Fragment,{children:[v.jsx(Ue,{name:"STARTED",tag:l?"inferred":void 0,detail:Pa(n.startedAt),title:l?n.boundsAssumption:void 0}),v.jsx(Ue,{name:"ELAPSED",tag:f?"inferred":void 0,detail:Ye(r),title:f?n.boundsAssumption:void 0})]})}function Uf({hit:n,world:i,landscape:r,band:l,density:u,onClose:f}){if(n.kind==="mass"){const k=i.machines.get(n.id);if(!k)return null;const N=[];let V=0,Z;for(const Y of i.executions.values()){if(Y.machineId!==k.id)continue;const P=qt(Y.measures);P!==void 0&&(Z=(Z??0)+P),Y.status==="running"||Y.status==="waiting"?N.push({id:Y.id,label:Y.label,status:Y.status}):V++}const I=i.processTotals,F=new Set;for(const Y of i.relationships)Y.kind==="ran-as"&&(Y.from.type==="process"&&F.add(Y.from.id),Y.to.type==="process"&&F.add(Y.to.id));return v.jsxs("div",{style:Fc,children:[v.jsx(Hc,{text:k.name,onClose:f}),N.length===0?v.jsx("div",{style:{fontSize:10,color:X.chrome},children:"idle — nothing active"}):N.slice(0,8).map(Y=>v.jsx(Ue,{name:Y.label,detail:Y.status.toUpperCase(),color:at[Y.status]},Y.id)),v.jsx("div",{style:{height:4}}),v.jsx(Ue,{name:"RAN TODAY",detail:String(V)}),v.jsx(Ue,{name:"TOKENS",detail:Wa(Z),title:Z===void 0?"No execution in this window reported token accounting.":void 0}),I&&v.jsxs(v.Fragment,{children:[v.jsx(_f,{label:"MACHINE STRATUM"}),v.jsx(Ue,{name:"PROCESSES OBSERVED",detail:String(I.observed)}),v.jsx(Ue,{name:"SEEN IN LAST 5 MIN",detail:String(I.recentlySeen),title:"Processes with a liveness observation in the last five minutes. The sampler only records a process when it is doing something, and never witnesses an exit — so recency is the honest liveness signal, not an unexpired status."}),v.jsx(Ue,{name:"ATTRIBUTED",detail:`${F.size} of ${I.observed}`,title:"Processes tied to a session or execution by resolved identity. The rest are machine activity with no known semantic identity — observed, not explained."}),I.exitsInferred>0&&v.jsx(Ue,{name:"EXITS",tag:"inferred",detail:String(I.exitsInferred),title:"An exit is never witnessed by the sampler; it is inferred from disappearance between samples."})]})]})}if(n.kind==="coupling"){const k=i.transfers.get(n.id);if(!k)return null;const N=i.machines.get(k.fromMachineId)?.name??k.fromMachineId,V=i.machines.get(k.toMachineId)?.name??k.toMachineId;return v.jsxs("div",{style:Fc,children:[v.jsx(Hc,{text:`${N} → ${V}`,onClose:f}),v.jsx(Ue,{name:"STATUS",detail:"TRANSFERRING",color:at.running}),v.jsx(Ue,{name:"WHAT",detail:k.label}),v.jsx(Ue,{name:"SIZE",detail:$x(k.bytes)}),v.jsx(Ue,{name:"ELAPSED",detail:Ye(i.now-k.startedAt)})]})}const d=i.executions.get(n.id);if(!d)return null;const h=i.sessions.get(d.sessionId),m=i.machines.get(d.machineId),g=r.disturbances.find(k=>k.id===n.id),x=u==="full"||u!=="compact"&&(l==="proximity"||n.kind==="stratum"),b=x,D=qt(d.measures),$=Za(d.measures);return v.jsxs("div",{style:Fc,children:[v.jsx(Hc,{text:d.label,onClose:f}),v.jsx(Ue,{name:"STATUS",detail:d.status.toUpperCase(),color:at[d.status]}),v.jsx(Ue,{name:"MACHINE",detail:m?.name??d.machineId}),v.jsx(GT,{p:d,now:i.now}),b&&v.jsxs(v.Fragment,{children:[v.jsx(Ue,{name:"TOKENS",detail:Wa(D),title:D===void 0?"This source does not persist token accounting.":void 0}),v.jsx(Ue,{name:"REQUESTS",detail:String(ff(d))}),v.jsx(Ue,{name:"TOOL CALLS",detail:Wa(un(d)),title:un(d)===void 0?"This source does not count discrete operations.":void 0})]}),x&&v.jsxs(v.Fragment,{children:[v.jsx("div",{style:{height:4}}),h&&v.jsx(Ue,{name:"CONTEXT",detail:us(h.context)}),v.jsx(Ue,{name:"PROVIDER",detail:d.executor}),v.jsx(Ue,{name:"MODEL",detail:d.model??"NOT OBSERVED",color:d.model?void 0:X.chromeMid,title:d.model?void 0:"This source does not record the model."}),D!==void 0&&v.jsxs(v.Fragment,{children:[v.jsx(Ue,{name:"CACHE READ",detail:pt($.cacheRead)}),v.jsx(Ue,{name:"REASONING",detail:pt($.reasoning)})]}),ta(d)>0&&v.jsx(Ue,{name:"TOOL ERRORS",detail:String(ta(d)),color:at.failed}),d.waitingMs>0&&v.jsx(Ue,{name:"WAITED ON YOU",detail:Ye(d.waitingMs),color:at.waiting}),d.depth>0&&v.jsx(Ue,{name:"SUB-AGENT",detail:`depth ${d.depth}`}),h?.parentId&&v.jsx(Ue,{name:"SESSION SPAWNED BY",tag:"recorded",detail:i.sessions.get(h.parentId)?.label??h.parentId,title:"The session's own runtime recorded which session started it."}),g&&v.jsx(Ue,{name:"FIELD ENERGY",detail:g.energy.toFixed(2)}),v.jsx(R0,{world:i,subject:{type:"execution",id:d.id}}),h&&v.jsx(R0,{world:i,subject:{type:"session",id:h.id}}),v.jsx(kT,{type:"execution",id:d.id})]}),d.failure&&v.jsxs("div",{style:{marginTop:4,fontSize:9.5,letterSpacing:"0.06em",color:at.failed,maxWidth:280},children:[d.failure.code,": ",d.failure.message]}),d.outcome==="interrupted"&&!d.failure&&v.jsx("div",{style:{marginTop:4,fontSize:9.5,color:X.chromeMid},children:"stopped before finishing"})]})}function BT({hit:n,world:i}){let r="",l="",u=X.chromeMid;if(n.kind==="mass")r=i.machines.get(n.id)?.name??n.id;else if(n.kind==="coupling"){const f=i.transfers.get(n.id),d=f?i.machines.get(f.fromMachineId)?.name??"":"",h=f?i.machines.get(f.toMachineId)?.name??"":"";r=`${d} → ${h}`,l="TRANSFERRING",u=at.running}else{const f=i.executions.get(n.id);if(!f)return null;r=f.label,l=f.status.toUpperCase(),u=at[f.status]}return v.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:2,pointerEvents:"none",whiteSpace:"nowrap",fontFamily:Et},children:[v.jsx("div",{style:{fontSize:10.5,fontWeight:500,letterSpacing:"0.18em",color:X.hoverInk,background:"rgba(5,6,8,0.88)",padding:"4px 9px"},children:r}),l&&v.jsx("div",{style:{fontSize:9.5,letterSpacing:"0.22em",color:u,textShadow:Ka},children:l})]})}function $T(n){return[`${pt(n.requests.value)} REQ`,`${n.sessions.value} SESS`,`${Ye(n.autonomousCompute.value)}`,`${pt(n.tokens.value)} TOK`].join(" · ")}function VT(n){return[`${pt(n.requests.value)} REQUESTS`,`${n.sessions.value} SESSIONS`,`${Ye(n.autonomousCompute.value)} AUTONOMOUS`,`${Ye(n.humanAgentOverlap.value)} OVERLAP`,`PEAK ${n.peakConcurrency.value}`,`${n.contextSwitches.value} SWITCHES`,`${pt(n.tokens.value)} TOK`].join(" · ")}function IT({metrics:n,shape:i,compact:r=!1}){return v.jsxs("div",{style:{position:"absolute",left:20,bottom:16,right:r?82:236,display:"flex",flexDirection:"column",gap:8,pointerEvents:"none",fontFamily:Et},children:[v.jsxs("div",{"data-depth-deep":!0,"data-depth-suppressed":r?"true":void 0,style:{display:"none",maxWidth:720,background:"linear-gradient(to right, rgba(5,6,8,0.92) 0%, rgba(5,6,8,0.86) 70%, rgba(5,6,8,0) 100%)",padding:"10px 42px 10px 0",margin:"0 0 -2px -6px",paddingLeft:6},children:[v.jsxs("div",{style:{fontSize:9.5,letterSpacing:"0.24em",color:X.chrome,textShadow:Ka},children:["WORK SHAPE — ",i.headline]}),v.jsx("div",{style:{marginTop:6,display:"flex",flexDirection:"column",gap:3},children:i.clauses.slice(0,3).map(l=>v.jsx("div",{style:{fontSize:10.5,lineHeight:1.6,color:X.chromeMid,textShadow:Ka},children:l},l))}),v.jsx("div",{style:{marginTop:7,fontSize:9.5,lineHeight:1.6,color:X.chromeDim,textShadow:Ka,maxWidth:620},children:"NOT AVAILABLE FROM THESE SOURCES — cost (every source reports tokens or CPU time, none reports money) and machine-to-machine transfer (every observed source is single-host)."})]}),v.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap",background:"linear-gradient(to right, rgba(5,6,8,0.92) 0%, rgba(5,6,8,0.86) 80%, rgba(5,6,8,0) 100%)",padding:"4px 42px 4px 6px",margin:"0 0 0 -6px"},children:[v.jsx("span",{"data-depth-label":!0,style:{fontSize:10.5,letterSpacing:"0.18em",color:"rgba(230,227,219,0.74)",textShadow:Ka},children:"FIELD — LIVE"}),v.jsxs("span",{"data-depth-summary":!0,style:{display:"none",alignItems:"baseline",gap:10},children:[v.jsx("span",{style:{color:X.chromeDim},children:"·"}),v.jsx("span",{style:{fontSize:10.5,letterSpacing:"0.18em",color:"rgba(230,227,219,0.6)",textShadow:Ka},children:r?$T(n):VT(n)})]})]})]})}const FT=560;function C0(n,i,r){return Math.min(n,i)<FT||r?i>=n?"portrait":"landscape":"desktop"}function HT(){const[n,i]=Q.useState(()=>typeof window>"u"?"desktop":C0(window.innerWidth,window.innerHeight,window.matchMedia("(pointer: coarse)").matches));return Q.useEffect(()=>{const r=window.matchMedia("(pointer: coarse)"),l=()=>i(C0(window.innerWidth,window.innerHeight,r.matches));return l(),window.addEventListener("resize",l),window.addEventListener("orientationchange",l),r.addEventListener("change",l),()=>{window.removeEventListener("resize",l),window.removeEventListener("orientationchange",l),r.removeEventListener("change",l)}},[]),n}const Zy=250,Py=150;function qT(n,i,r,l){return i?n==="landscape"?{right:Zy,bottom:0}:n==="portrait"?{right:0,bottom:r?Math.round(l*.6):Py}:{right:0,bottom:0}:{right:0,bottom:0}}const Wy={fontSize:9,letterSpacing:"0.16em",color:X.chromeMid};function YT(n){return v.jsxs("div",{style:{position:"absolute",right:0,top:0,bottom:0,width:Zy,boxSizing:"border-box",background:X.panel,borderLeft:`1px solid ${X.panelBorder}`,padding:"16px 16px 14px",display:"flex",flexDirection:"column",gap:10,fontFamily:Et,pointerEvents:"auto"},children:[v.jsx(Uf,{...n,density:"full"}),v.jsx("div",{style:{marginTop:"auto",...Wy},children:"TAP FIELD TO DISMISS"})]})}function XT({detent:n,onToggleDetent:i,viewportHeight:r,...l}){const u=n==="expanded",f=u?Math.round(r*.6):Py;return v.jsxs("div",{style:{position:"absolute",left:0,right:0,bottom:0,height:f,boxSizing:"border-box",background:"rgba(7,8,11,0.96)",borderTop:`1px solid ${X.panelBorder}`,padding:"10px 18px 18px",display:"flex",flexDirection:"column",gap:10,fontFamily:Et,pointerEvents:"auto",transition:"height 180ms ease-out"},children:[v.jsx("button",{onClick:i,"aria-label":u?"Collapse":"Expand",style:{alignSelf:"center",width:44,height:4,borderRadius:2,border:"none",padding:0,background:"rgba(230,227,219,0.42)",cursor:"pointer",marginBottom:2,flexShrink:0}}),v.jsx("div",{style:{overflow:"hidden",flex:1,minHeight:0},children:v.jsx(Uf,{...l,density:u?"full":"compact"})}),v.jsx("div",{style:{marginTop:"auto",...Wy},children:u?"TAP HANDLE TO COLLAPSE":"TAP HANDLE FOR FULL TELEMETRY"})]})}function QT(n){return`${n.message}. ${n.remedy} Nothing observed since this appeared has been saved.`}const qc={label:"TODAY",tone:"normal",detail:"Midnight to now."},KT={normal:X.chromeMid,warn:"rgba(240,195,116,0.9)",error:"rgba(206,104,90,0.9)"};function ZT(){const n=Date.now(),i=new Date(n);return i.setHours(0,0,0,0),{start:i.getTime(),now:n}}const PT=250,WT={time:0,masses:[],disturbances:[],plinths:[],couplings:[],strata:[]};function JT(){const[n,i]=Q.useState("capture"),[r,l]=Q.useState("field"),[u,f]=Q.useState(null),[d,h]=Q.useState(qc),[m,g]=Q.useState(WT),[x,b]=Q.useState(0),[D,$]=Q.useState(null),[k,N]=Q.useState(null),[V,Z]=Q.useState("environment"),[I,F]=Q.useState(null),[Y,P]=Q.useState("peek"),he=HT(),M=Q.useRef($l(Date.now(),Date.now())),E=Q.useRef(null),j=Q.useRef(null),W=Q.useRef(!1);Q.useEffect(()=>{let w=!1,U=null;h(qc);async function q(){if(n==="synthetic"){const be=new r1({seed:57});if(h({label:"REPLAY",tone:"normal",detail:"A deterministic synthetic day, replayed at speed. Not your telemetry."}),w)return;const yn=be.bounds();M.current=$l(yn.dayStart,yn.dayEnd),E.current=be,f(be.info()),N(null),$(null),U=be.subscribe(fn=>{Rx(M.current,fn),W.current=!0}),W.current=!0;return}const{start:K,now:oe}=ZT();await Xc(K,oe);const fe=await s1();let me=await Qc(K,oe);if(me.world.executions.length===0&&me.world.sessions.length===0){const be=oe-2592e5;await Xc(be,oe),me=await Qc(be,oe),(me.world.executions.length>0||me.world.sessions.length>0)&&h({label:"LAST 72H",tone:"warn",detail:"Nothing ran today, so the window was widened to the last 72 hours."})}const Pe=Object.entries(fe.observation??{}).flatMap(([be,yn])=>Object.entries(yn.strata).filter(([fn,ee])=>ee==="partial"||ee==="failed"&&fn!=="live-semantics").map(([fn,ee])=>`${be} ${fn} ${ee}`)),De=Object.entries(fe.sources).filter(([,be])=>(be.presence??(be.available?"observing":"not-installed"))==="failed").map(([be])=>be),gn=Object.entries(fe.sources).filter(([,be])=>be.presence==="not-installed").map(([be])=>be),Wn=fe.store.bySource.filter(be=>be.source!=="host"),Mt=fe.health;fe.fault?h({label:"STORE LOST",tone:"error",detail:QT(fe.fault)}):Mt&&!Mt.store.ok?h({label:"STORE DEGRADED",tone:"error",detail:Mt.store.remedy??"Some stored rows could not be read."}):Mt&&Mt.failingSources.length>0?h({label:"SOURCE FAILING",tone:"error",detail:`Installed and failing every collection round: ${Mt.failingSources.join(", ")}. `+(Mt.collection[Mt.failingSources[0]]?.lastError??"")+" Other sources and captured history are unaffected."}):fe.mode==="os-only"?h({label:"OS ONLY",tone:"normal",detail:"Observing this machine’s processes. No AI runtime state was found here"+(gn.length?` (looked for ${gn.join(", ")})`:"")+" — that is a valid mode, not a fault. Install or use one and its sessions appear here."}):Wn.length===0?h({label:"NOTHING YET",tone:"warn",detail:"Nothing has been captured yet. OS processes are sampled locally every few seconds; AI runtime state is read from each runtime’s own files when it exists."}):(De.length||Pe.length)&&h({label:"PARTIAL",tone:"warn",detail:[De.length?`Installed but unreadable: ${De.join(", ")}.`:"",Pe.length?`Reduced observation depth: ${Pe.join("; ")}. The computation is still observed; some semantics are not.`:"","Captured history is intact."].filter(Boolean).join(" ")});const Tn=new c1(me,fe,{onTrouble:be=>{if(!w){if(!be)return h(qc);h(be.kind==="store-fault"?{label:"STORE LOST",tone:"error",detail:`${be.message} ${be.detail}`}:{label:"CAPTURE FAILING",tone:"error",detail:`${be.message}. ${be.detail}. The field is showing the last world it received.`})}}});w||(M.current=$l(me.from,me.to),E.current=Tn,f(Tn.info()),N(null),$(null),U=Tn.subscribe(be=>{M.current=be,W.current=!0}),W.current=!0)}return q().catch(K=>{w||h({label:"SOURCE FAILED",tone:"error",detail:K instanceof Error?K.message:String(K)})}),()=>{w=!0,E.current=null,U?.()}},[n]),Q.useEffect(()=>{const w=setInterval(()=>{const U=M.current,q=E.current?.now()??Date.now();Cx(U,Math.max(U.now,q)),W.current&&(W.current=!1,g(e1(U)),b(K=>K+1))},PT);return()=>clearInterval(w)},[]),Q.useEffect(()=>{const w=setInterval(()=>{const U=j.current?.perf.snapshot();U&&F({fps:U.fps,gpuMs:U.gpuMs,scale:U.scale})},1e3);return()=>clearInterval(w)},[]);const te=M.current,le=Q.useMemo(()=>L0(te),[x]),$e=Q.useMemo(()=>j0(te,le),[le]),de=Q.useCallback(w=>$(w),[]),se=Q.useCallback(w=>{const U=m.disturbances.find(K=>K.id===w),q=m.strata.find(K=>K.id===w);!U&&!q||(N({kind:U?"disturbance":"stratum",id:w,x:U?.x??0,y:U?.y??0}),l("field"))},[m]),R=k??D,H=he!=="desktop",ae=typeof window>"u"?800:window.innerHeight,Te=Q.useMemo(()=>qT(he,!!k,Y==="expanded",ae),[he,k,Y,ae]),Re=R&&(!k&&R.kind==="disturbance"?v.jsx("div",{"data-anchor-placement":"label",children:v.jsx(BT,{hit:R,world:te})}):v.jsx("div",{"data-anchor-placement":"panel",children:v.jsx(Uf,{hit:R,world:te,landscape:m,band:V,onClose:()=>N(null)})}));return v.jsxs("div",{style:{position:"fixed",inset:0,display:"flex",flexDirection:"column",background:X.bg,color:X.ink,fontFamily:Et},children:[v.jsx(eM,{view:r,setView:l,feed:n,setFeed:i,sourceInfo:u,window:d}),r==="today"&&v.jsx(RT,{world:te}),r==="log"&&v.jsx(UT,{world:te,selectedId:k?.id??null,onSelect:se}),v.jsx("div",{style:{display:r==="field"?"contents":"none"},children:v.jsx(MT,{landscape:m,onHover:de,onSelect:N,anchor:H?null:R,onBand:Z,compact:H,inset:Te,keepVisible:k,overlay:H&&k?he==="landscape"?v.jsx(YT,{hit:k,world:te,landscape:m,band:V,onClose:()=>N(null)}):v.jsx(XT,{hit:k,world:te,landscape:m,band:V,detent:Y,onToggleDetent:()=>P(w=>w==="peek"?"expanded":"peek"),viewportHeight:ae,onClose:()=>N(null)}):null,onReady:w=>{j.current=w},depth:v.jsx(IT,{metrics:le,shape:$e,compact:H}),children:Re})}),v.jsx(tM,{view:r,perf:I,touch:H})]})}function eM({view:n,setView:i,feed:r,setFeed:l,sourceInfo:u,window:f}){const d=(g,x)=>{const b=n===g;return v.jsx("button",{onClick:()=>i(g),style:{background:"transparent",border:"none",padding:0,cursor:"pointer",fontFamily:Et,letterSpacing:"0.22em",fontSize:b?12.5:9.5,color:b?X.ink:X.chromeDim},children:x},g)},h=r==="synthetic",m=[f.detail,u?.detail].filter(Boolean).join(" ");return v.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"16px 24px 15px",borderBottom:`1px solid ${X.hairline}`,flexWrap:"nowrap",overflow:"hidden"},children:[v.jsx("div",{style:{fontSize:11,letterSpacing:"0.3em",color:"rgba(230,227,219,0.5)",flexShrink:0},children:"057"}),v.jsx("div",{className:"hdr-tagline",style:{fontSize:8.5,letterSpacing:"0.24em",color:X.chromeDim,flexShrink:0,whiteSpace:"nowrap"},children:"PERSONAL COMPUTATIONAL TELEMETRY"}),v.jsx("div",{className:"hdr-tagline",style:{width:1,height:12,background:"rgba(230,227,219,0.12)",flexShrink:0,margin:"0 10px"}}),v.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:20,flexShrink:0},children:[d("field","FIELD"),d("today","TODAY"),d("log","PROCESS LOG")]}),v.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:22,minWidth:0},children:[v.jsxs("div",{title:m,style:{display:"flex",alignItems:"center",gap:9,flexShrink:0,cursor:"help"},children:[v.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:KT[f.tone],flexShrink:0}}),v.jsx("span",{style:{fontSize:10,letterSpacing:"0.2em",color:X.chromeStrong,whiteSpace:"nowrap"},children:f.label})]}),v.jsxs("button",{onClick:()=>l(h?"capture":"synthetic"),title:h?"Switch to CAPTURE":"Switch to SYNTHETIC",style:{background:"transparent",border:"none",padding:"3px 0",cursor:"pointer",display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[v.jsx("span",{style:{fontSize:10,color:h?X.chromeDim:X.accent},children:h?"○":"●"}),v.jsx("span",{style:{fontSize:9.5,letterSpacing:"0.16em",color:X.chrome},children:h?"SYNTHETIC":"CAPTURE"})]})]})]})}function tM({view:n,perf:i,touch:r}){return v.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:14,padding:"10px 24px 14px",borderTop:`1px solid ${X.hairline}`,fontSize:10.5,letterSpacing:"0.16em",color:X.chrome,flexWrap:"wrap"},children:[v.jsx("span",{children:n==="field"?r?"DRAG TO PAN · PINCH TO ZOOM · TAP TO INSPECT":"SCROLL TO PAN · ⌃SCROLL / PINCH TO ZOOM · CLICK TO INSPECT · ZOOM OUT FOR TODAY":n==="log"?"CLICK A ROW FOR THE FULL RECORD · CLICK A COLUMN TO SORT":"HOVER AN INFERRED MEASURE FOR THE ASSUMPTION BEHIND IT"}),v.jsx("span",{style:{marginLeft:"auto",color:X.chromeDim,fontSize:9.5},children:n==="field"&&i&&i.fps>0?`${Math.round(i.fps)}FPS${i.gpuMs>0?` · ${i.gpuMs.toFixed(1)}MS GPU`:""}${i.scale<1?` · ${Math.round(i.scale*100)}%`:""}`:""})]})}Sx.createRoot(document.getElementById("root")).render(v.jsx(Q.StrictMode,{children:v.jsx(JT,{})}));
|