diff --git "a/src/flow/ui/ui/assets/index-BhlCCkwM.js" "b/src/flow/ui/ui/assets/index-BhlCCkwM.js" new file mode 100644--- /dev/null +++ "b/src/flow/ui/ui/assets/index-BhlCCkwM.js" @@ -0,0 +1,260 @@ +var Uu=e=>{throw TypeError(e)};var Bi=(e,t,n)=>t.has(e)||Uu("Cannot "+n);var y=(e,t,n)=>(Bi(e,t,"read from private field"),n?n.call(e):t.get(e)),F=(e,t,n)=>t.has(e)?Uu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),M=(e,t,n,r)=>(Bi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),V=(e,t,n)=>(Bi(e,t,"access private method"),n);var oa=(e,t,n,r)=>({set _(s){M(e,t,s,n)},get _(){return y(e,t,r)}});function Fp(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function Id(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Fd={exports:{}},vi={},Dd={exports:{}},H={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ta=Symbol.for("react.element"),Dp=Symbol.for("react.portal"),Ap=Symbol.for("react.fragment"),$p=Symbol.for("react.strict_mode"),Up=Symbol.for("react.profiler"),Bp=Symbol.for("react.provider"),Qp=Symbol.for("react.context"),Vp=Symbol.for("react.forward_ref"),Kp=Symbol.for("react.suspense"),Hp=Symbol.for("react.memo"),Wp=Symbol.for("react.lazy"),Bu=Symbol.iterator;function qp(e){return e===null||typeof e!="object"?null:(e=Bu&&e[Bu]||e["@@iterator"],typeof e=="function"?e:null)}var Ad={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},$d=Object.assign,Ud={};function Gr(e,t,n){this.props=e,this.context=t,this.refs=Ud,this.updater=n||Ad}Gr.prototype.isReactComponent={};Gr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Gr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Bd(){}Bd.prototype=Gr.prototype;function Ro(e,t,n){this.props=e,this.context=t,this.refs=Ud,this.updater=n||Ad}var Mo=Ro.prototype=new Bd;Mo.constructor=Ro;$d(Mo,Gr.prototype);Mo.isPureReactComponent=!0;var Qu=Array.isArray,Qd=Object.prototype.hasOwnProperty,zo={current:null},Vd={key:!0,ref:!0,__self:!0,__source:!0};function Kd(e,t,n){var r,s={},a=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(a=""+t.key),t)Qd.call(t,r)&&!Vd.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,le=L[te];if(0>>1;tes(B,$))res(xe,B)?(L[te]=xe,L[re]=$,te=re):(L[te]=B,L[E]=$,te=E);else if(res(xe,$))L[te]=xe,L[re]=$,te=re;else break e}}return D}function s(L,D){var $=L.sortIndex-D.sortIndex;return $!==0?$:L.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var u=[],c=[],p=1,f=null,h=3,x=!1,w=!1,j=!1,S=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(L){for(var D=n(c);D!==null;){if(D.callback===null)r(c);else if(D.startTime<=L)r(c),D.sortIndex=D.expirationTime,t(u,D);else break;D=n(c)}}function g(L){if(j=!1,m(L),!w)if(n(u)!==null)w=!0,Wt(_);else{var D=n(c);D!==null&&Ae(g,D.startTime-L)}}function _(L,D){w=!1,j&&(j=!1,v(b),b=-1),x=!0;var $=h;try{for(m(D),f=n(u);f!==null&&(!(f.expirationTime>D)||L&&!U());){var te=f.callback;if(typeof te=="function"){f.callback=null,h=f.priorityLevel;var le=te(f.expirationTime<=D);D=e.unstable_now(),typeof le=="function"?f.callback=le:f===n(u)&&r(u),m(D)}else r(u);f=n(u)}if(f!==null)var R=!0;else{var E=n(c);E!==null&&Ae(g,E.startTime-D),R=!1}return R}finally{f=null,h=$,x=!1}}var N=!1,C=null,b=-1,z=5,O=-1;function U(){return!(e.unstable_now()-OL||125te?(L.sortIndex=$,t(c,L),n(u)===null&&L===n(c)&&(j?(v(b),b=-1):j=!0,Ae(g,$-te))):(L.sortIndex=le,t(u,L),w||x||(w=!0,Wt(_))),L},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(L){var D=h;return function(){var $=h;h=D;try{return L.apply(this,arguments)}finally{h=$}}}})(Jd);Gd.exports=Jd;var im=Gd.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var lm=k,Je=im;function T(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),jl=Object.prototype.hasOwnProperty,om=/^[: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]*$/,Ku={},Hu={};function um(e){return jl.call(Hu,e)?!0:jl.call(Ku,e)?!1:om.test(e)?Hu[e]=!0:(Ku[e]=!0,!1)}function cm(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function dm(e,t,n,r){if(t===null||typeof t>"u"||cm(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Fe(e,t,n,r,s,a,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=l}var _e={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){_e[e]=new Fe(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];_e[t]=new Fe(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){_e[e]=new Fe(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){_e[e]=new Fe(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){_e[e]=new Fe(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){_e[e]=new Fe(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){_e[e]=new Fe(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){_e[e]=new Fe(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){_e[e]=new Fe(e,5,!1,e.toLowerCase(),null,!1,!1)});var Do=/[\-:]([a-z])/g;function Ao(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Do,Ao);_e[t]=new Fe(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Do,Ao);_e[t]=new Fe(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Do,Ao);_e[t]=new Fe(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){_e[e]=new Fe(e,1,!1,e.toLowerCase(),null,!1,!1)});_e.xlinkHref=new Fe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){_e[e]=new Fe(e,1,!1,e.toLowerCase(),null,!0,!0)});function $o(e,t,n,r){var s=_e.hasOwnProperty(t)?_e[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==a[o]){var u=` +`+s[l].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=l&&0<=o);break}}}finally{Ki=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?cs(e):""}function fm(e){switch(e.tag){case 5:return cs(e.type);case 16:return cs("Lazy");case 13:return cs("Suspense");case 19:return cs("SuspenseList");case 0:case 2:case 15:return e=Hi(e.type,!1),e;case 11:return e=Hi(e.type.render,!1),e;case 1:return e=Hi(e.type,!0),e;default:return""}}function Nl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case dr:return"Fragment";case cr:return"Portal";case wl:return"Profiler";case Uo:return"StrictMode";case kl:return"Suspense";case Sl:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Zd:return(e.displayName||"Context")+".Consumer";case Xd:return(e._context.displayName||"Context")+".Provider";case Bo:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Qo:return t=e.displayName||null,t!==null?t:Nl(e.type)||"Memo";case Jt:t=e._payload,e=e._init;try{return Nl(e(t))}catch{}}return null}function hm(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Nl(t);case 8:return t===Uo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Nn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function tf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function pm(e){var t=tf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,a.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function da(e){e._valueTracker||(e._valueTracker=pm(e))}function nf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=tf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ba(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}}function Cl(e,t){var n=t.checked;return ce({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function qu(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Nn(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function rf(e,t){t=t.checked,t!=null&&$o(e,"checked",t,!1)}function _l(e,t){rf(e,t);var n=Nn(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?bl(e,t.type,n):t.hasOwnProperty("defaultValue")&&bl(e,t.type,Nn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Gu(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function bl(e,t,n){(t!=="number"||Ba(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ds=Array.isArray;function kr(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=fa.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function bs(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ms={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},mm=["Webkit","ms","Moz","O"];Object.keys(ms).forEach(function(e){mm.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ms[t]=ms[e]})});function of(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ms.hasOwnProperty(e)&&ms[e]?(""+t).trim():t+"px"}function uf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=of(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var vm=ce({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Tl(e,t){if(t){if(vm[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(T(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(T(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(T(61))}if(t.style!=null&&typeof t.style!="object")throw Error(T(62))}}function Ol(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";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 Ll=null;function Vo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Rl=null,Sr=null,Nr=null;function Xu(e){if(e=sa(e)){if(typeof Rl!="function")throw Error(T(280));var t=e.stateNode;t&&(t=wi(t),Rl(e.stateNode,e.type,t))}}function cf(e){Sr?Nr?Nr.push(e):Nr=[e]:Sr=e}function df(){if(Sr){var e=Sr,t=Nr;if(Nr=Sr=null,Xu(e),t)for(e=0;e>>=0,e===0?32:31-(bm(e)/Em|0)|0}var ha=64,pa=4194304;function fs(e){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: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Ha(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,a=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=fs(o):(a&=l,a!==0&&(r=fs(a)))}else l=n&~s,l!==0?r=fs(l):a!==0&&(r=fs(a));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,a=t&-t,s>=a||s===16&&(a&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function na(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-mt(t),e[t]=n}function Lm(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=xs),lc=" ",oc=!1;function Of(e,t){switch(e){case"keyup":return iv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Lf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var fr=!1;function ov(e,t){switch(e){case"compositionend":return Lf(t);case"keypress":return t.which!==32?null:(oc=!0,lc);case"textInput":return e=t.data,e===lc&&oc?null:e;default:return null}}function uv(e,t){if(fr)return e==="compositionend"||!Xo&&Of(e,t)?(e=Pf(),La=Go=cn=null,fr=!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)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=fc(n)}}function If(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?If(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ff(){for(var e=window,t=Ba();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ba(e.document)}return t}function Zo(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")}function yv(e){var t=Ff(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&If(n.ownerDocument.documentElement,n)){if(r!==null&&Zo(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,a=Math.min(r.start,s);r=r.end===void 0?a:Math.min(r.end,s),!e.extend&&a>r&&(s=r,r=a,a=s),s=hc(n,a);var l=hc(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,hr=null,Al=null,gs=null,$l=!1;function pc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;$l||hr==null||hr!==Ba(r)||(r=hr,"selectionStart"in r&&Zo(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),gs&&Rs(gs,r)||(gs=r,r=Ga(Al,"onSelect"),0vr||(e.current=Hl[vr],Hl[vr]=null,vr--)}function ne(e,t){vr++,Hl[vr]=e.current,e.current=t}var Cn={},Oe=bn(Cn),Ve=bn(!1),Xn=Cn;function Ur(e,t){var n=e.type.contextTypes;if(!n)return Cn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},a;for(a in n)s[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function Ke(e){return e=e.childContextTypes,e!=null}function Ya(){ae(Ve),ae(Oe)}function wc(e,t,n){if(Oe.current!==Cn)throw Error(T(168));ne(Oe,t),ne(Ve,n)}function Hf(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(T(108,hm(e)||"Unknown",s));return ce({},n,r)}function Xa(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Cn,Xn=Oe.current,ne(Oe,e),ne(Ve,Ve.current),!0}function kc(e,t,n){var r=e.stateNode;if(!r)throw Error(T(169));n?(e=Hf(e,t,Xn),r.__reactInternalMemoizedMergedChildContext=e,ae(Ve),ae(Oe),ne(Oe,e)):ae(Ve),ne(Ve,n)}var Ot=null,ki=!1,il=!1;function Wf(e){Ot===null?Ot=[e]:Ot.push(e)}function Tv(e){ki=!0,Wf(e)}function En(){if(!il&&Ot!==null){il=!0;var e=0,t=X;try{var n=Ot;for(X=1;e>=l,s-=l,It=1<<32-mt(t)+s|n<b?(z=C,C=null):z=C.sibling;var O=h(v,C,m[b],g);if(O===null){C===null&&(C=z);break}e&&C&&O.alternate===null&&t(v,C),d=a(O,d,b),N===null?_=O:N.sibling=O,N=O,C=z}if(b===m.length)return n(v,C),ie&&Ln(v,b),_;if(C===null){for(;bb?(z=C,C=null):z=C.sibling;var U=h(v,C,O.value,g);if(U===null){C===null&&(C=z);break}e&&C&&U.alternate===null&&t(v,C),d=a(U,d,b),N===null?_=U:N.sibling=U,N=U,C=z}if(O.done)return n(v,C),ie&&Ln(v,b),_;if(C===null){for(;!O.done;b++,O=m.next())O=f(v,O.value,g),O!==null&&(d=a(O,d,b),N===null?_=O:N.sibling=O,N=O);return ie&&Ln(v,b),_}for(C=r(v,C);!O.done;b++,O=m.next())O=x(C,v,b,O.value,g),O!==null&&(e&&O.alternate!==null&&C.delete(O.key===null?b:O.key),d=a(O,d,b),N===null?_=O:N.sibling=O,N=O);return e&&C.forEach(function(P){return t(v,P)}),ie&&Ln(v,b),_}function S(v,d,m,g){if(typeof m=="object"&&m!==null&&m.type===dr&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case ca:e:{for(var _=m.key,N=d;N!==null;){if(N.key===_){if(_=m.type,_===dr){if(N.tag===7){n(v,N.sibling),d=s(N,m.props.children),d.return=v,v=d;break e}}else if(N.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===Jt&&Cc(_)===N.type){n(v,N.sibling),d=s(N,m.props),d.ref=is(v,N,m),d.return=v,v=d;break e}n(v,N);break}else t(v,N);N=N.sibling}m.type===dr?(d=Gn(m.props.children,v.mode,g,m.key),d.return=v,v=d):(g=$a(m.type,m.key,m.props,null,v.mode,g),g.ref=is(v,d,m),g.return=v,v=g)}return l(v);case cr:e:{for(N=m.key;d!==null;){if(d.key===N)if(d.tag===4&&d.stateNode.containerInfo===m.containerInfo&&d.stateNode.implementation===m.implementation){n(v,d.sibling),d=s(d,m.children||[]),d.return=v,v=d;break e}else{n(v,d);break}else t(v,d);d=d.sibling}d=pl(m,v.mode,g),d.return=v,v=d}return l(v);case Jt:return N=m._init,S(v,d,N(m._payload),g)}if(ds(m))return w(v,d,m,g);if(ts(m))return j(v,d,m,g);wa(v,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,d!==null&&d.tag===6?(n(v,d.sibling),d=s(d,m),d.return=v,v=d):(n(v,d),d=hl(m,v.mode,g),d.return=v,v=d),l(v)):n(v,d)}return S}var Qr=Yf(!0),Xf=Yf(!1),ti=bn(null),ni=null,gr=null,ru=null;function su(){ru=gr=ni=null}function au(e){var t=ti.current;ae(ti),e._currentValue=t}function Gl(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function _r(e,t){ni=e,ru=gr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Qe=!0),e.firstContext=null)}function it(e){var t=e._currentValue;if(ru!==e)if(e={context:e,memoizedValue:t,next:null},gr===null){if(ni===null)throw Error(T(308));gr=e,ni.dependencies={lanes:0,firstContext:e}}else gr=gr.next=e;return t}var In=null;function iu(e){In===null?In=[e]:In.push(e)}function Zf(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,iu(t)):(n.next=s.next,s.next=n),t.interleaved=n,Qt(e,r)}function Qt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Yt=!1;function lu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function eh(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function At(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function yn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,G&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Qt(e,n)}return s=r.interleaved,s===null?(t.next=t,iu(r)):(t.next=s.next,s.next=t),r.interleaved=t,Qt(e,n)}function Ma(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ho(e,n)}}function _c(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?s=a=l:a=a.next=l,n=n.next}while(n!==null);a===null?s=a=t:a=a.next=t}else s=a=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ri(e,t,n,r){var s=e.updateQueue;Yt=!1;var a=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var u=o,c=u.next;u.next=null,l===null?a=c:l.next=c,l=u;var p=e.alternate;p!==null&&(p=p.updateQueue,o=p.lastBaseUpdate,o!==l&&(o===null?p.firstBaseUpdate=c:o.next=c,p.lastBaseUpdate=u))}if(a!==null){var f=s.baseState;l=0,p=c=u=null,o=a;do{var h=o.lane,x=o.eventTime;if((r&h)===h){p!==null&&(p=p.next={eventTime:x,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var w=e,j=o;switch(h=t,x=n,j.tag){case 1:if(w=j.payload,typeof w=="function"){f=w.call(x,f,h);break e}f=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=j.payload,h=typeof w=="function"?w.call(x,f,h):w,h==null)break e;f=ce({},f,h);break e;case 2:Yt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,h=s.effects,h===null?s.effects=[o]:h.push(o))}else x={eventTime:x,lane:h,tag:o.tag,payload:o.payload,callback:o.callback,next:null},p===null?(c=p=x,u=f):p=p.next=x,l|=h;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;h=o,o=h.next,h.next=null,s.lastBaseUpdate=h,s.shared.pending=null}}while(!0);if(p===null&&(u=f),s.baseState=u,s.firstBaseUpdate=c,s.lastBaseUpdate=p,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else a===null&&(s.shared.lanes=0);tr|=l,e.lanes=l,e.memoizedState=f}}function bc(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ol.transition;ol.transition={};try{e(!1),t()}finally{X=n,ol.transition=r}}function xh(){return lt().memoizedState}function Mv(e,t,n){var r=jn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},yh(e))gh(t,n);else if(n=Zf(e,t,n,r),n!==null){var s=ze();vt(n,e,r,s),jh(n,t,r)}}function zv(e,t,n){var r=jn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(yh(e))gh(t,s);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var l=t.lastRenderedState,o=a(l,n);if(s.hasEagerState=!0,s.eagerState=o,xt(o,l)){var u=t.interleaved;u===null?(s.next=s,iu(t)):(s.next=u.next,u.next=s),t.interleaved=s;return}}catch{}finally{}n=Zf(e,t,s,r),n!==null&&(s=ze(),vt(n,e,r,s),jh(n,t,r))}}function yh(e){var t=e.alternate;return e===ue||t!==null&&t===ue}function gh(e,t){js=ai=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function jh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ho(e,n)}}var ii={readContext:it,useCallback:be,useContext:be,useEffect:be,useImperativeHandle:be,useInsertionEffect:be,useLayoutEffect:be,useMemo:be,useReducer:be,useRef:be,useState:be,useDebugValue:be,useDeferredValue:be,useTransition:be,useMutableSource:be,useSyncExternalStore:be,useId:be,unstable_isNewReconciler:!1},Iv={readContext:it,useCallback:function(e,t){return jt().memoizedState=[e,t===void 0?null:t],e},useContext:it,useEffect:Pc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ia(4194308,4,fh.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ia(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ia(4,2,e,t)},useMemo:function(e,t){var n=jt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=jt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Mv.bind(null,ue,e),[r.memoizedState,e]},useRef:function(e){var t=jt();return e={current:e},t.memoizedState=e},useState:Ec,useDebugValue:mu,useDeferredValue:function(e){return jt().memoizedState=e},useTransition:function(){var e=Ec(!1),t=e[0];return e=Rv.bind(null,e[1]),jt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ue,s=jt();if(ie){if(n===void 0)throw Error(T(407));n=n()}else{if(n=t(),Se===null)throw Error(T(349));er&30||sh(r,t,n)}s.memoizedState=n;var a={value:n,getSnapshot:t};return s.queue=a,Pc(ih.bind(null,r,a,e),[e]),r.flags|=2048,Us(9,ah.bind(null,r,a,n,t),void 0,null),n},useId:function(){var e=jt(),t=Se.identifierPrefix;if(ie){var n=Ft,r=It;n=(r&~(1<<32-mt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=As++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Nt]=t,e[Is]=r,Th(e,t,!1,!1),t.stateNode=e;e:{switch(l=Ol(n,r),n){case"dialog":se("cancel",e),se("close",e),s=r;break;case"iframe":case"object":case"embed":se("load",e),s=r;break;case"video":case"audio":for(s=0;sHr&&(t.flags|=128,r=!0,ls(a,!1),t.lanes=4194304)}else{if(!r)if(e=si(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ls(a,!0),a.tail===null&&a.tailMode==="hidden"&&!l.alternate&&!ie)return Ee(t),null}else 2*pe()-a.renderingStartTime>Hr&&n!==1073741824&&(t.flags|=128,r=!0,ls(a,!1),t.lanes=4194304);a.isBackwards?(l.sibling=t.child,t.child=l):(n=a.last,n!==null?n.sibling=l:t.child=l,a.last=l)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=pe(),t.sibling=null,n=oe.current,ne(oe,r?n&1|2:n&1),t):(Ee(t),null);case 22:case 23:return wu(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?We&1073741824&&(Ee(t),t.subtreeFlags&6&&(t.flags|=8192)):Ee(t),null;case 24:return null;case 25:return null}throw Error(T(156,t.tag))}function Vv(e,t){switch(tu(t),t.tag){case 1:return Ke(t.type)&&Ya(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Vr(),ae(Ve),ae(Oe),cu(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return uu(t),null;case 13:if(ae(oe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(T(340));Br()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ae(oe),null;case 4:return Vr(),null;case 10:return au(t.type._context),null;case 22:case 23:return wu(),null;case 24:return null;default:return null}}var Sa=!1,Te=!1,Kv=typeof WeakSet=="function"?WeakSet:Set,I=null;function jr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){fe(e,t,r)}else n.current=null}function so(e,t,n){try{n()}catch(r){fe(e,t,r)}}var $c=!1;function Hv(e,t){if(Ul=Wa,e=Ff(),Zo(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break e}var l=0,o=-1,u=-1,c=0,p=0,f=e,h=null;t:for(;;){for(var x;f!==n||s!==0&&f.nodeType!==3||(o=l+s),f!==a||r!==0&&f.nodeType!==3||(u=l+r),f.nodeType===3&&(l+=f.nodeValue.length),(x=f.firstChild)!==null;)h=f,f=x;for(;;){if(f===e)break t;if(h===n&&++c===s&&(o=l),h===a&&++p===r&&(u=l),(x=f.nextSibling)!==null)break;f=h,h=f.parentNode}f=x}n=o===-1||u===-1?null:{start:o,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Bl={focusedElem:e,selectionRange:n},Wa=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var w=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var j=w.memoizedProps,S=w.memoizedState,v=t.stateNode,d=v.getSnapshotBeforeUpdate(t.elementType===t.type?j:ut(t.type,j),S);v.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var m=t.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(T(163))}}catch(g){fe(t,t.return,g)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return w=$c,$c=!1,w}function ws(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var a=s.destroy;s.destroy=void 0,a!==void 0&&so(t,n,a)}s=s.next}while(s!==r)}}function Ci(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ao(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Rh(e){var t=e.alternate;t!==null&&(e.alternate=null,Rh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Nt],delete t[Is],delete t[Kl],delete t[Ev],delete t[Pv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Mh(e){return e.tag===5||e.tag===3||e.tag===4}function Uc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Mh(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.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 io(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ja));else if(r!==4&&(e=e.child,e!==null))for(io(e,t,n),e=e.sibling;e!==null;)io(e,t,n),e=e.sibling}function lo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(lo(e,t,n),e=e.sibling;e!==null;)lo(e,t,n),e=e.sibling}var Ne=null,ft=!1;function qt(e,t,n){for(n=n.child;n!==null;)zh(e,t,n),n=n.sibling}function zh(e,t,n){if(Ct&&typeof Ct.onCommitFiberUnmount=="function")try{Ct.onCommitFiberUnmount(xi,n)}catch{}switch(n.tag){case 5:Te||jr(n,t);case 6:var r=Ne,s=ft;Ne=null,qt(e,t,n),Ne=r,ft=s,Ne!==null&&(ft?(e=Ne,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ne.removeChild(n.stateNode));break;case 18:Ne!==null&&(ft?(e=Ne,n=n.stateNode,e.nodeType===8?al(e.parentNode,n):e.nodeType===1&&al(e,n),Os(e)):al(Ne,n.stateNode));break;case 4:r=Ne,s=ft,Ne=n.stateNode.containerInfo,ft=!0,qt(e,t,n),Ne=r,ft=s;break;case 0:case 11:case 14:case 15:if(!Te&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var a=s,l=a.destroy;a=a.tag,l!==void 0&&(a&2||a&4)&&so(n,t,l),s=s.next}while(s!==r)}qt(e,t,n);break;case 1:if(!Te&&(jr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){fe(n,t,o)}qt(e,t,n);break;case 21:qt(e,t,n);break;case 22:n.mode&1?(Te=(r=Te)||n.memoizedState!==null,qt(e,t,n),Te=r):qt(e,t,n);break;default:qt(e,t,n)}}function Bc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Kv),t.forEach(function(r){var s=tx.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function ot(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~a}if(r=s,r=pe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*qv(r/1960))-r,10e?16:e,dn===null)var r=!1;else{if(e=dn,dn=null,ui=0,G&6)throw Error(T(331));var s=G;for(G|=4,I=e.current;I!==null;){var a=I,l=a.child;if(I.flags&16){var o=a.deletions;if(o!==null){for(var u=0;upe()-gu?qn(e,0):yu|=n),He(e,t)}function Qh(e,t){t===0&&(e.mode&1?(t=pa,pa<<=1,!(pa&130023424)&&(pa=4194304)):t=1);var n=ze();e=Qt(e,t),e!==null&&(na(e,t,n),He(e,n))}function ex(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Qh(e,n)}function tx(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(T(314))}r!==null&&r.delete(t),Qh(e,n)}var Vh;Vh=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ve.current)Qe=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Qe=!1,Bv(e,t,n);Qe=!!(e.flags&131072)}else Qe=!1,ie&&t.flags&1048576&&qf(t,ei,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Fa(e,t),e=t.pendingProps;var s=Ur(t,Oe.current);_r(t,n),s=fu(null,t,r,e,s,n);var a=hu();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ke(r)?(a=!0,Xa(t)):a=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,lu(t),s.updater=Ni,t.stateNode=s,s._reactInternals=t,Yl(t,r,e,n),t=eo(null,t,r,!0,a,n)):(t.tag=0,ie&&a&&eu(t),Re(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Fa(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=rx(r),e=ut(r,e),s){case 0:t=Zl(null,t,r,e,n);break e;case 1:t=Fc(null,t,r,e,n);break e;case 11:t=zc(null,t,r,e,n);break e;case 14:t=Ic(null,t,r,ut(r.type,e),n);break e}throw Error(T(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ut(r,s),Zl(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ut(r,s),Fc(e,t,r,s,n);case 3:e:{if(bh(t),e===null)throw Error(T(387));r=t.pendingProps,a=t.memoizedState,s=a.element,eh(e,t),ri(t,r,null,n);var l=t.memoizedState;if(r=l.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){s=Kr(Error(T(423)),t),t=Dc(e,t,r,n,s);break e}else if(r!==s){s=Kr(Error(T(424)),t),t=Dc(e,t,r,n,s);break e}else for(qe=xn(t.stateNode.containerInfo.firstChild),Ge=t,ie=!0,ht=null,n=Xf(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Br(),r===s){t=Vt(e,t,n);break e}Re(e,t,r,n)}t=t.child}return t;case 5:return th(t),e===null&&ql(t),r=t.type,s=t.pendingProps,a=e!==null?e.memoizedProps:null,l=s.children,Ql(r,s)?l=null:a!==null&&Ql(r,a)&&(t.flags|=32),_h(e,t),Re(e,t,l,n),t.child;case 6:return e===null&&ql(t),null;case 13:return Eh(e,t,n);case 4:return ou(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Qr(t,null,r,n):Re(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ut(r,s),zc(e,t,r,s,n);case 7:return Re(e,t,t.pendingProps,n),t.child;case 8:return Re(e,t,t.pendingProps.children,n),t.child;case 12:return Re(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,a=t.memoizedProps,l=s.value,ne(ti,r._currentValue),r._currentValue=l,a!==null)if(xt(a.value,l)){if(a.children===s.children&&!Ve.current){t=Vt(e,t,n);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var o=a.dependencies;if(o!==null){l=a.child;for(var u=o.firstContext;u!==null;){if(u.context===r){if(a.tag===1){u=At(-1,n&-n),u.tag=2;var c=a.updateQueue;if(c!==null){c=c.shared;var p=c.pending;p===null?u.next=u:(u.next=p.next,p.next=u),c.pending=u}}a.lanes|=n,u=a.alternate,u!==null&&(u.lanes|=n),Gl(a.return,n,t),o.lanes|=n;break}u=u.next}}else if(a.tag===10)l=a.type===t.type?null:a.child;else if(a.tag===18){if(l=a.return,l===null)throw Error(T(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),Gl(l,n,t),l=a.sibling}else l=a.child;if(l!==null)l.return=a;else for(l=a;l!==null;){if(l===t){l=null;break}if(a=l.sibling,a!==null){a.return=l.return,l=a;break}l=l.return}a=l}Re(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,_r(t,n),s=it(s),r=r(s),t.flags|=1,Re(e,t,r,n),t.child;case 14:return r=t.type,s=ut(r,t.pendingProps),s=ut(r.type,s),Ic(e,t,r,s,n);case 15:return Nh(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ut(r,s),Fa(e,t),t.tag=1,Ke(r)?(e=!0,Xa(t)):e=!1,_r(t,n),wh(t,r,s),Yl(t,r,s,n),eo(null,t,r,!0,e,n);case 19:return Ph(e,t,n);case 22:return Ch(e,t,n)}throw Error(T(156,t.tag))};function Kh(e,t){return yf(e,t)}function nx(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function rt(e,t,n,r){return new nx(e,t,n,r)}function Su(e){return e=e.prototype,!(!e||!e.isReactComponent)}function rx(e){if(typeof e=="function")return Su(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Bo)return 11;if(e===Qo)return 14}return 2}function wn(e,t){var n=e.alternate;return n===null?(n=rt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function $a(e,t,n,r,s,a){var l=2;if(r=e,typeof e=="function")Su(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case dr:return Gn(n.children,s,a,t);case Uo:l=8,s|=8;break;case wl:return e=rt(12,n,t,s|2),e.elementType=wl,e.lanes=a,e;case kl:return e=rt(13,n,t,s),e.elementType=kl,e.lanes=a,e;case Sl:return e=rt(19,n,t,s),e.elementType=Sl,e.lanes=a,e;case ef:return bi(n,s,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Xd:l=10;break e;case Zd:l=9;break e;case Bo:l=11;break e;case Qo:l=14;break e;case Jt:l=16,r=null;break e}throw Error(T(130,e==null?e:typeof e,""))}return t=rt(l,n,t,s),t.elementType=e,t.type=r,t.lanes=a,t}function Gn(e,t,n,r){return e=rt(7,e,r,t),e.lanes=n,e}function bi(e,t,n,r){return e=rt(22,e,r,t),e.elementType=ef,e.lanes=n,e.stateNode={isHidden:!1},e}function hl(e,t,n){return e=rt(6,e,null,t),e.lanes=n,e}function pl(e,t,n){return t=rt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function sx(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=qi(0),this.expirationTimes=qi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qi(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Nu(e,t,n,r,s,a,l,o,u){return e=new sx(e,t,n,o,u),t===1?(t=1,a===!0&&(t|=8)):t=0,a=rt(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},lu(a),e}function ax(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Gh)}catch(e){console.error(e)}}Gh(),qd.exports=Ye;var cx=qd.exports,Jc=cx;gl.createRoot=Jc.createRoot,gl.hydrateRoot=Jc.hydrateRoot;var Xr=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},dx={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},en,Lo,Cd,fx=(Cd=class{constructor(){F(this,en,dx);F(this,Lo,!1)}setTimeoutProvider(e){M(this,en,e)}setTimeout(e,t){return y(this,en).setTimeout(e,t)}clearTimeout(e){y(this,en).clearTimeout(e)}setInterval(e,t){return y(this,en).setInterval(e,t)}clearInterval(e){y(this,en).clearInterval(e)}},en=new WeakMap,Lo=new WeakMap,Cd),Dn=new fx;function hx(e){setTimeout(e,0)}var rr=typeof window>"u"||"Deno"in globalThis;function Me(){}function px(e,t){return typeof e=="function"?e(t):e}function ho(e){return typeof e=="number"&&e>=0&&e!==1/0}function Jh(e,t){return Math.max(e+(t||0)-Date.now(),0)}function kn(e,t){return typeof e=="function"?e(t):e}function et(e,t){return typeof e=="function"?e(t):e}function Yc(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:a,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==Eu(l,t.options))return!1}else if(!Qs(t.queryKey,l))return!1}if(n!=="all"){const u=t.isActive();if(n==="active"&&!u||n==="inactive"&&u)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||a&&!a(t))}function Xc(e,t){const{exact:n,status:r,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(sr(t.options.mutationKey)!==sr(a))return!1}else if(!Qs(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function Eu(e,t){return((t==null?void 0:t.queryKeyHashFn)||sr)(e)}function sr(e){return JSON.stringify(e,(t,n)=>po(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function Qs(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Qs(e[n],t[n])):!1}var mx=Object.prototype.hasOwnProperty;function Yh(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=Zc(e)&&Zc(t);if(!r&&!(po(e)&&po(t)))return t;const a=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,u=r?new Array(o):{};let c=0;for(let p=0;p{Dn.setTimeout(t,e)})}function mo(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Yh(e,t):t}function xx(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function yx(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Pu=Symbol();function Xh(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Pu?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Tu(e,t){return typeof e=="function"?e(...t):!!e}function gx(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var An,tn,Er,_d,jx=(_d=class extends Xr{constructor(){super();F(this,An);F(this,tn);F(this,Er);M(this,Er,t=>{if(!rr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,tn)||this.setEventListener(y(this,Er))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,tn))==null||t.call(this),M(this,tn,void 0))}setEventListener(t){var n;M(this,Er,t),(n=y(this,tn))==null||n.call(this),M(this,tn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,An)!==t&&(M(this,An,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,An)=="boolean"?y(this,An):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},An=new WeakMap,tn=new WeakMap,Er=new WeakMap,_d),Ou=new jx;function vo(){let e,t;const n=new Promise((s,a)=>{e=s,t=a});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var wx=hx;function kx(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=wx;const a=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(u=>{n(u)})})})};return{batch:o=>{let u;t++;try{u=o()}finally{t--,t||l()}return u},batchCalls:o=>(...u)=>{a(()=>{o(...u)})},schedule:a,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var ge=kx(),Pr,nn,Tr,bd,Sx=(bd=class extends Xr{constructor(){super();F(this,Pr,!0);F(this,nn);F(this,Tr);M(this,Tr,t=>{if(!rr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,nn)||this.setEventListener(y(this,Tr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,nn))==null||t.call(this),M(this,nn,void 0))}setEventListener(t){var n;M(this,Tr,t),(n=y(this,nn))==null||n.call(this),M(this,nn,t(this.setOnline.bind(this)))}setOnline(t){y(this,Pr)!==t&&(M(this,Pr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Pr)}},Pr=new WeakMap,nn=new WeakMap,Tr=new WeakMap,bd),hi=new Sx;function Nx(e){return Math.min(1e3*2**e,3e4)}function Zh(e){return(e??"online")==="online"?hi.isOnline():!0}var xo=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function ep(e){let t=!1,n=0,r;const s=vo(),a=()=>s.status!=="pending",l=j=>{var S;if(!a()){const v=new xo(j);h(v),(S=e.onCancel)==null||S.call(e,v)}},o=()=>{t=!0},u=()=>{t=!1},c=()=>Ou.isFocused()&&(e.networkMode==="always"||hi.isOnline())&&e.canRun(),p=()=>Zh(e.networkMode)&&e.canRun(),f=j=>{a()||(r==null||r(),s.resolve(j))},h=j=>{a()||(r==null||r(),s.reject(j))},x=()=>new Promise(j=>{var S;r=v=>{(a()||c())&&j(v)},(S=e.onPause)==null||S.call(e)}).then(()=>{var j;r=void 0,a()||(j=e.onContinue)==null||j.call(e)}),w=()=>{if(a())return;let j;const S=n===0?e.initialPromise:void 0;try{j=S??e.fn()}catch(v){j=Promise.reject(v)}Promise.resolve(j).then(f).catch(v=>{var N;if(a())return;const d=e.retry??(rr?0:3),m=e.retryDelay??Nx,g=typeof m=="function"?m(n,v):m,_=d===!0||typeof d=="number"&&nc()?void 0:x()).then(()=>{t?h(v):w()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:u,canStart:p,start:()=>(p()?w():x().then(w),s)}}var $n,Ed,tp=(Ed=class{constructor(){F(this,$n)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ho(this.gcTime)&&M(this,$n,Dn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(rr?1/0:5*60*1e3))}clearGcTimeout(){y(this,$n)&&(Dn.clearTimeout(y(this,$n)),M(this,$n,void 0))}},$n=new WeakMap,Ed),Un,Or,Ze,Bn,we,Js,Qn,ct,Pt,Pd,Cx=(Pd=class extends tp{constructor(t){super();F(this,ct);F(this,Un);F(this,Or);F(this,Ze);F(this,Bn);F(this,we);F(this,Js);F(this,Qn);M(this,Qn,!1),M(this,Js,t.defaultOptions),this.setOptions(t.options),this.observers=[],M(this,Bn,t.client),M(this,Ze,y(this,Bn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,M(this,Un,nd(this.options)),this.state=t.state??y(this,Un),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,we))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,Js),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=nd(this.options);n.data!==void 0&&(this.setState(td(n.data,n.dataUpdatedAt)),M(this,Un,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,Ze).remove(this)}setData(t,n){const r=mo(this.state.data,t,this.options);return V(this,ct,Pt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){V(this,ct,Pt).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,we))==null?void 0:r.promise;return(s=y(this,we))==null||s.cancel(t),n?n.then(Me).catch(Me):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,Un))}isActive(){return this.observers.some(t=>et(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Pu||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>kn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Jh(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,we))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,we))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,Ze).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,we)&&(y(this,Qn)?y(this,we).cancel({revert:!0}):y(this,we).cancelRetry()),this.scheduleGc()),y(this,Ze).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||V(this,ct,Pt).call(this,{type:"invalidate"})}async fetch(t,n){var u,c,p,f,h,x,w,j,S,v,d,m;if(this.state.fetchStatus!=="idle"&&((u=y(this,we))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,we))return y(this,we).continueRetry(),y(this,we).promise}if(t&&this.setOptions(t),!this.options.queryFn){const g=this.observers.find(_=>_.options.queryFn);g&&this.setOptions(g.options)}const r=new AbortController,s=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(M(this,Qn,!0),r.signal)})},a=()=>{const g=Xh(this.options,n),N=(()=>{const C={client:y(this,Bn),queryKey:this.queryKey,meta:this.meta};return s(C),C})();return M(this,Qn,!1),this.options.persister?this.options.persister(g,N,this):g(N)},o=(()=>{const g={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Bn),state:this.state,fetchFn:a};return s(g),g})();(c=this.options.behavior)==null||c.onFetch(o,this),M(this,Or,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=o.fetchOptions)==null?void 0:p.meta))&&V(this,ct,Pt).call(this,{type:"fetch",meta:(f=o.fetchOptions)==null?void 0:f.meta}),M(this,we,ep({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:g=>{g instanceof xo&&g.revert&&this.setState({...y(this,Or),fetchStatus:"idle"}),r.abort()},onFail:(g,_)=>{V(this,ct,Pt).call(this,{type:"failed",failureCount:g,error:_})},onPause:()=>{V(this,ct,Pt).call(this,{type:"pause"})},onContinue:()=>{V(this,ct,Pt).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const g=await y(this,we).start();if(g===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(g),(x=(h=y(this,Ze).config).onSuccess)==null||x.call(h,g,this),(j=(w=y(this,Ze).config).onSettled)==null||j.call(w,g,this.state.error,this),g}catch(g){if(g instanceof xo){if(g.silent)return y(this,we).promise;if(g.revert){if(this.state.data===void 0)throw g;return this.state.data}}throw V(this,ct,Pt).call(this,{type:"error",error:g}),(v=(S=y(this,Ze).config).onError)==null||v.call(S,g,this),(m=(d=y(this,Ze).config).onSettled)==null||m.call(d,this.state.data,g,this),g}finally{this.scheduleGc()}}},Un=new WeakMap,Or=new WeakMap,Ze=new WeakMap,Bn=new WeakMap,we=new WeakMap,Js=new WeakMap,Qn=new WeakMap,ct=new WeakSet,Pt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...np(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...td(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return M(this,Or,t.manual?s:void 0),s;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),ge.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,Ze).notify({query:this,type:"updated",action:t})})},Pd);function np(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Zh(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function td(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function nd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var $e,q,Ys,Le,Vn,Lr,Lt,rn,Xs,Rr,Mr,Kn,Hn,sn,zr,Y,ps,yo,go,jo,wo,ko,So,No,rp,Td,_x=(Td=class extends Xr{constructor(t,n){super();F(this,Y);F(this,$e);F(this,q);F(this,Ys);F(this,Le);F(this,Vn);F(this,Lr);F(this,Lt);F(this,rn);F(this,Xs);F(this,Rr);F(this,Mr);F(this,Kn);F(this,Hn);F(this,sn);F(this,zr,new Set);this.options=n,M(this,$e,t),M(this,rn,null),M(this,Lt,vo()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,q).addObserver(this),rd(y(this,q),this.options)?V(this,Y,ps).call(this):this.updateResult(),V(this,Y,wo).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Co(y(this,q),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Co(y(this,q),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,V(this,Y,ko).call(this),V(this,Y,So).call(this),y(this,q).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,q);if(this.options=y(this,$e).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof et(this.options.enabled,y(this,q))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");V(this,Y,No).call(this),y(this,q).setOptions(this.options),n._defaulted&&!fi(this.options,n)&&y(this,$e).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,q),observer:this});const s=this.hasListeners();s&&sd(y(this,q),r,this.options,n)&&V(this,Y,ps).call(this),this.updateResult(),s&&(y(this,q)!==r||et(this.options.enabled,y(this,q))!==et(n.enabled,y(this,q))||kn(this.options.staleTime,y(this,q))!==kn(n.staleTime,y(this,q)))&&V(this,Y,yo).call(this);const a=V(this,Y,go).call(this);s&&(y(this,q)!==r||et(this.options.enabled,y(this,q))!==et(n.enabled,y(this,q))||a!==y(this,sn))&&V(this,Y,jo).call(this,a)}getOptimisticResult(t){const n=y(this,$e).getQueryCache().build(y(this,$e),t),r=this.createResult(n,t);return Ex(this,r)&&(M(this,Le,r),M(this,Lr,this.options),M(this,Vn,y(this,q).state)),r}getCurrentResult(){return y(this,Le)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,Lt).status==="pending"&&y(this,Lt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,zr).add(t)}getCurrentQuery(){return y(this,q)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,$e).defaultQueryOptions(t),r=y(this,$e).getQueryCache().build(y(this,$e),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return V(this,Y,ps).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,Le)))}createResult(t,n){var z;const r=y(this,q),s=this.options,a=y(this,Le),l=y(this,Vn),o=y(this,Lr),c=t!==r?t.state:y(this,Ys),{state:p}=t;let f={...p},h=!1,x;if(n._optimisticResults){const O=this.hasListeners(),U=!O&&rd(t,n),P=O&&sd(t,r,n,s);(U||P)&&(f={...f,...np(p.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:w,errorUpdatedAt:j,status:S}=f;x=f.data;let v=!1;if(n.placeholderData!==void 0&&x===void 0&&S==="pending"){let O;a!=null&&a.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(O=a.data,v=!0):O=typeof n.placeholderData=="function"?n.placeholderData((z=y(this,Mr))==null?void 0:z.state.data,y(this,Mr)):n.placeholderData,O!==void 0&&(S="success",x=mo(a==null?void 0:a.data,O,n),h=!0)}if(n.select&&x!==void 0&&!v)if(a&&x===(l==null?void 0:l.data)&&n.select===y(this,Xs))x=y(this,Rr);else try{M(this,Xs,n.select),x=n.select(x),x=mo(a==null?void 0:a.data,x,n),M(this,Rr,x),M(this,rn,null)}catch(O){M(this,rn,O)}y(this,rn)&&(w=y(this,rn),x=y(this,Rr),j=Date.now(),S="error");const d=f.fetchStatus==="fetching",m=S==="pending",g=S==="error",_=m&&d,N=x!==void 0,b={status:S,fetchStatus:f.fetchStatus,isPending:m,isSuccess:S==="success",isError:g,isInitialLoading:_,isLoading:_,data:x,dataUpdatedAt:f.dataUpdatedAt,error:w,errorUpdatedAt:j,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>c.dataUpdateCount||f.errorUpdateCount>c.errorUpdateCount,isFetching:d,isRefetching:d&&!m,isLoadingError:g&&!N,isPaused:f.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:g&&N,isStale:Lu(t,n),refetch:this.refetch,promise:y(this,Lt),isEnabled:et(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=b.data!==void 0,U=b.status==="error"&&!O,P=De=>{U?De.reject(b.error):O&&De.resolve(b.data)},A=()=>{const De=M(this,Lt,b.promise=vo());P(De)},ee=y(this,Lt);switch(ee.status){case"pending":t.queryHash===r.queryHash&&P(ee);break;case"fulfilled":(U||b.data!==ee.value)&&A();break;case"rejected":(!U||b.error!==ee.reason)&&A();break}}return b}updateResult(){const t=y(this,Le),n=this.createResult(y(this,q),this.options);if(M(this,Vn,y(this,q).state),M(this,Lr,this.options),y(this,Vn).data!==void 0&&M(this,Mr,y(this,q)),fi(n,t))return;M(this,Le,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!y(this,zr).size)return!0;const l=new Set(a??y(this,zr));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,Le)).some(o=>{const u=o;return y(this,Le)[u]!==t[u]&&l.has(u)})};V(this,Y,rp).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&V(this,Y,wo).call(this)}},$e=new WeakMap,q=new WeakMap,Ys=new WeakMap,Le=new WeakMap,Vn=new WeakMap,Lr=new WeakMap,Lt=new WeakMap,rn=new WeakMap,Xs=new WeakMap,Rr=new WeakMap,Mr=new WeakMap,Kn=new WeakMap,Hn=new WeakMap,sn=new WeakMap,zr=new WeakMap,Y=new WeakSet,ps=function(t){V(this,Y,No).call(this);let n=y(this,q).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Me)),n},yo=function(){V(this,Y,ko).call(this);const t=kn(this.options.staleTime,y(this,q));if(rr||y(this,Le).isStale||!ho(t))return;const r=Jh(y(this,Le).dataUpdatedAt,t)+1;M(this,Kn,Dn.setTimeout(()=>{y(this,Le).isStale||this.updateResult()},r))},go=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,q)):this.options.refetchInterval)??!1},jo=function(t){V(this,Y,So).call(this),M(this,sn,t),!(rr||et(this.options.enabled,y(this,q))===!1||!ho(y(this,sn))||y(this,sn)===0)&&M(this,Hn,Dn.setInterval(()=>{(this.options.refetchIntervalInBackground||Ou.isFocused())&&V(this,Y,ps).call(this)},y(this,sn)))},wo=function(){V(this,Y,yo).call(this),V(this,Y,jo).call(this,V(this,Y,go).call(this))},ko=function(){y(this,Kn)&&(Dn.clearTimeout(y(this,Kn)),M(this,Kn,void 0))},So=function(){y(this,Hn)&&(Dn.clearInterval(y(this,Hn)),M(this,Hn,void 0))},No=function(){const t=y(this,$e).getQueryCache().build(y(this,$e),this.options);if(t===y(this,q))return;const n=y(this,q);M(this,q,t),M(this,Ys,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},rp=function(t){ge.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,Le))}),y(this,$e).getQueryCache().notify({query:y(this,q),type:"observerResultsUpdated"})})},Td);function bx(e,t){return et(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function rd(e,t){return bx(e,t)||e.state.data!==void 0&&Co(e,t,t.refetchOnMount)}function Co(e,t,n){if(et(t.enabled,e)!==!1&&kn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Lu(e,t)}return!1}function sd(e,t,n,r){return(e!==t||et(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Lu(e,n)}function Lu(e,t){return et(t.enabled,e)!==!1&&e.isStaleByTime(kn(t.staleTime,e))}function Ex(e,t){return!fi(e.getCurrentResult(),t)}function ad(e){return{onFetch:(t,n)=>{var p,f,h,x,w;const r=t.options,s=(h=(f=(p=t.fetchOptions)==null?void 0:p.meta)==null?void 0:f.fetchMore)==null?void 0:h.direction,a=((x=t.state.data)==null?void 0:x.pages)||[],l=((w=t.state.data)==null?void 0:w.pageParams)||[];let o={pages:[],pageParams:[]},u=0;const c=async()=>{let j=!1;const S=m=>{gx(m,()=>t.signal,()=>j=!0)},v=Xh(t.options,t.fetchOptions),d=async(m,g,_)=>{if(j)return Promise.reject();if(g==null&&m.pages.length)return Promise.resolve(m);const C=(()=>{const U={client:t.client,queryKey:t.queryKey,pageParam:g,direction:_?"backward":"forward",meta:t.options.meta};return S(U),U})(),b=await v(C),{maxPages:z}=t.options,O=_?yx:xx;return{pages:O(m.pages,b,z),pageParams:O(m.pageParams,g,z)}};if(s&&a.length){const m=s==="backward",g=m?Px:id,_={pages:a,pageParams:l},N=g(r,_);o=await d(_,N,m)}else{const m=e??a.length;do{const g=u===0?l[0]??r.initialPageParam:id(r,o);if(u>0&&g==null)break;o=await d(o,g),u++}while(u{var j,S;return(S=(j=t.options).persister)==null?void 0:S.call(j,c,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=c}}}function id(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Px(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var Zs,wt,Pe,Wn,kt,Gt,Od,Tx=(Od=class extends tp{constructor(t){super();F(this,kt);F(this,Zs);F(this,wt);F(this,Pe);F(this,Wn);M(this,Zs,t.client),this.mutationId=t.mutationId,M(this,Pe,t.mutationCache),M(this,wt,[]),this.state=t.state||sp(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,wt).includes(t)||(y(this,wt).push(t),this.clearGcTimeout(),y(this,Pe).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){M(this,wt,y(this,wt).filter(n=>n!==t)),this.scheduleGc(),y(this,Pe).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,wt).length||(this.state.status==="pending"?this.scheduleGc():y(this,Pe).remove(this))}continue(){var t;return((t=y(this,Wn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,u,c,p,f,h,x,w,j,S,v,d,m,g,_,N,C;const n=()=>{V(this,kt,Gt).call(this,{type:"continue"})},r={client:y(this,Zs),meta:this.options.meta,mutationKey:this.options.mutationKey};M(this,Wn,ep({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(b,z)=>{V(this,kt,Gt).call(this,{type:"failed",failureCount:b,error:z})},onPause:()=>{V(this,kt,Gt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Pe).canRun(this)}));const s=this.state.status==="pending",a=!y(this,Wn).canStart();try{if(s)n();else{V(this,kt,Gt).call(this,{type:"pending",variables:t,isPaused:a}),y(this,Pe).config.onMutate&&await y(this,Pe).config.onMutate(t,this,r);const z=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));z!==this.state.context&&V(this,kt,Gt).call(this,{type:"pending",context:z,variables:t,isPaused:a})}const b=await y(this,Wn).start();return await((c=(u=y(this,Pe).config).onSuccess)==null?void 0:c.call(u,b,t,this.state.context,this,r)),await((f=(p=this.options).onSuccess)==null?void 0:f.call(p,b,t,this.state.context,r)),await((x=(h=y(this,Pe).config).onSettled)==null?void 0:x.call(h,b,null,this.state.variables,this.state.context,this,r)),await((j=(w=this.options).onSettled)==null?void 0:j.call(w,b,null,t,this.state.context,r)),V(this,kt,Gt).call(this,{type:"success",data:b}),b}catch(b){try{await((v=(S=y(this,Pe).config).onError)==null?void 0:v.call(S,b,t,this.state.context,this,r))}catch(z){Promise.reject(z)}try{await((m=(d=this.options).onError)==null?void 0:m.call(d,b,t,this.state.context,r))}catch(z){Promise.reject(z)}try{await((_=(g=y(this,Pe).config).onSettled)==null?void 0:_.call(g,void 0,b,this.state.variables,this.state.context,this,r))}catch(z){Promise.reject(z)}try{await((C=(N=this.options).onSettled)==null?void 0:C.call(N,void 0,b,t,this.state.context,r))}catch(z){Promise.reject(z)}throw V(this,kt,Gt).call(this,{type:"error",error:b}),b}finally{y(this,Pe).runNext(this)}}},Zs=new WeakMap,wt=new WeakMap,Pe=new WeakMap,Wn=new WeakMap,kt=new WeakSet,Gt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),ge.batch(()=>{y(this,wt).forEach(r=>{r.onMutationUpdate(t)}),y(this,Pe).notify({mutation:this,type:"updated",action:t})})},Od);function sp(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Rt,dt,ea,Ld,Ox=(Ld=class extends Xr{constructor(t={}){super();F(this,Rt);F(this,dt);F(this,ea);this.config=t,M(this,Rt,new Set),M(this,dt,new Map),M(this,ea,0)}build(t,n,r){const s=new Tx({client:t,mutationCache:this,mutationId:++oa(this,ea)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,Rt).add(t);const n=_a(t);if(typeof n=="string"){const r=y(this,dt).get(n);r?r.push(t):y(this,dt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,Rt).delete(t)){const n=_a(t);if(typeof n=="string"){const r=y(this,dt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,dt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=_a(t);if(typeof n=="string"){const r=y(this,dt).get(n),s=r==null?void 0:r.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=_a(t);if(typeof n=="string"){const s=(r=y(this,dt).get(n))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ge.batch(()=>{y(this,Rt).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,Rt).clear(),y(this,dt).clear()})}getAll(){return Array.from(y(this,Rt))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Xc(n,r))}findAll(t={}){return this.getAll().filter(n=>Xc(t,n))}notify(t){ge.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return ge.batch(()=>Promise.all(t.map(n=>n.continue().catch(Me))))}},Rt=new WeakMap,dt=new WeakMap,ea=new WeakMap,Ld);function _a(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Mt,an,Ue,zt,$t,Ua,_o,Rd,Lx=(Rd=class extends Xr{constructor(n,r){super();F(this,$t);F(this,Mt);F(this,an);F(this,Ue);F(this,zt);M(this,Mt,n),this.setOptions(r),this.bindMethods(),V(this,$t,Ua).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,Mt).defaultMutationOptions(n),fi(this.options,r)||y(this,Mt).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,Ue),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&sr(r.mutationKey)!==sr(this.options.mutationKey)?this.reset():((s=y(this,Ue))==null?void 0:s.state.status)==="pending"&&y(this,Ue).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,Ue))==null||n.removeObserver(this)}onMutationUpdate(n){V(this,$t,Ua).call(this),V(this,$t,_o).call(this,n)}getCurrentResult(){return y(this,an)}reset(){var n;(n=y(this,Ue))==null||n.removeObserver(this),M(this,Ue,void 0),V(this,$t,Ua).call(this),V(this,$t,_o).call(this)}mutate(n,r){var s;return M(this,zt,r),(s=y(this,Ue))==null||s.removeObserver(this),M(this,Ue,y(this,Mt).getMutationCache().build(y(this,Mt),this.options)),y(this,Ue).addObserver(this),y(this,Ue).execute(n)}},Mt=new WeakMap,an=new WeakMap,Ue=new WeakMap,zt=new WeakMap,$t=new WeakSet,Ua=function(){var r;const n=((r=y(this,Ue))==null?void 0:r.state)??sp();M(this,an,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},_o=function(n){ge.batch(()=>{var r,s,a,l,o,u,c,p;if(y(this,zt)&&this.hasListeners()){const f=y(this,an).variables,h=y(this,an).context,x={client:y(this,Mt),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,zt)).onSuccess)==null||s.call(r,n.data,f,h,x)}catch(w){Promise.reject(w)}try{(l=(a=y(this,zt)).onSettled)==null||l.call(a,n.data,null,f,h,x)}catch(w){Promise.reject(w)}}else if((n==null?void 0:n.type)==="error"){try{(u=(o=y(this,zt)).onError)==null||u.call(o,n.error,f,h,x)}catch(w){Promise.reject(w)}try{(p=(c=y(this,zt)).onSettled)==null||p.call(c,void 0,n.error,f,h,x)}catch(w){Promise.reject(w)}}}this.listeners.forEach(f=>{f(y(this,an))})})},Rd),St,Md,Rx=(Md=class extends Xr{constructor(t={}){super();F(this,St);this.config=t,M(this,St,new Map)}build(t,n,r){const s=n.queryKey,a=n.queryHash??Eu(s,n);let l=this.get(a);return l||(l=new Cx({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,St).has(t.queryHash)||(y(this,St).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,St).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,St).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ge.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,St).get(t)}getAll(){return[...y(this,St).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Yc(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>Yc(t,r)):n}notify(t){ge.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){ge.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ge.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},St=new WeakMap,Md),de,ln,on,Ir,Fr,un,Dr,Ar,zd,Mx=(zd=class{constructor(e={}){F(this,de);F(this,ln);F(this,on);F(this,Ir);F(this,Fr);F(this,un);F(this,Dr);F(this,Ar);M(this,de,e.queryCache||new Rx),M(this,ln,e.mutationCache||new Ox),M(this,on,e.defaultOptions||{}),M(this,Ir,new Map),M(this,Fr,new Map),M(this,un,0)}mount(){oa(this,un)._++,y(this,un)===1&&(M(this,Dr,Ou.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,de).onFocus())})),M(this,Ar,hi.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,de).onOnline())})))}unmount(){var e,t;oa(this,un)._--,y(this,un)===0&&((e=y(this,Dr))==null||e.call(this),M(this,Dr,void 0),(t=y(this,Ar))==null||t.call(this),M(this,Ar,void 0))}isFetching(e){return y(this,de).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,ln).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,de).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,de).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(kn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,de).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,de).get(r.queryHash),a=s==null?void 0:s.state.data,l=px(t,a);if(l!==void 0)return y(this,de).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return ge.batch(()=>y(this,de).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,de).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,de);ge.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,de);return ge.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=ge.batch(()=>y(this,de).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Me).catch(Me)}invalidateQueries(e,t={}){return ge.batch(()=>(y(this,de).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=ge.batch(()=>y(this,de).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,n);return n.throwOnError||(a=a.catch(Me)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Me)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,de).build(this,t);return n.isStaleByTime(kn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Me).catch(Me)}fetchInfiniteQuery(e){return e.behavior=ad(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Me).catch(Me)}ensureInfiniteQueryData(e){return e.behavior=ad(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return hi.isOnline()?y(this,ln).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,de)}getMutationCache(){return y(this,ln)}getDefaultOptions(){return y(this,on)}setDefaultOptions(e){M(this,on,e)}setQueryDefaults(e,t){y(this,Ir).set(sr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,Ir).values()],n={};return t.forEach(r=>{Qs(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,Fr).set(sr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,Fr).values()],n={};return t.forEach(r=>{Qs(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,on).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Eu(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Pu&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,on).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,de).clear(),y(this,ln).clear()}},de=new WeakMap,ln=new WeakMap,on=new WeakMap,Ir=new WeakMap,Fr=new WeakMap,un=new WeakMap,Dr=new WeakMap,Ar=new WeakMap,zd),ap=k.createContext(void 0),Pn=e=>{const t=k.useContext(ap);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},zx=({client:e,children:t})=>(k.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),i.jsx(ap.Provider,{value:e,children:t})),ip=k.createContext(!1),Ix=()=>k.useContext(ip);ip.Provider;function Fx(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Dx=k.createContext(Fx()),Ax=()=>k.useContext(Dx),$x=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Tu(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ux=e=>{k.useEffect(()=>{e.clearReset()},[e])},Bx=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Tu(n,[e.error,r])),Qx=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Vx=(e,t)=>e.isLoading&&e.isFetching&&!t,Kx=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,ld=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Hx(e,t,n){var h,x,w,j;const r=Ix(),s=Ax(),a=Pn(),l=a.defaultQueryOptions(e);(x=(h=a.getDefaultOptions().queries)==null?void 0:h._experimental_beforeQuery)==null||x.call(h,l);const o=a.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",Qx(l),$x(l,s,o),Ux(s);const u=!a.getQueryCache().get(l.queryHash),[c]=k.useState(()=>new t(a,l)),p=c.getOptimisticResult(l),f=!r&&e.subscribed!==!1;if(k.useSyncExternalStore(k.useCallback(S=>{const v=f?c.subscribe(ge.batchCalls(S)):Me;return c.updateResult(),v},[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),k.useEffect(()=>{c.setOptions(l)},[l,c]),Kx(l,p))throw ld(l,c,s);if(Bx({result:p,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw p.error;if((j=(w=a.getDefaultOptions().queries)==null?void 0:w._experimental_afterQuery)==null||j.call(w,l,p),l.experimental_prefetchInRender&&!rr&&Vx(p,r)){const S=u?ld(l,c,s):o==null?void 0:o.promise;S==null||S.catch(Me).finally(()=>{c.updateResult()})}return l.notifyOnChangeProps?p:c.trackResult(p)}function ve(e,t){return Hx(e,_x)}function at(e,t){const n=Pn(),[r]=k.useState(()=>new Lx(n,e));k.useEffect(()=>{r.setOptions(e)},[r,e]);const s=k.useSyncExternalStore(k.useCallback(l=>r.subscribe(ge.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=k.useCallback((l,o)=>{r.mutate(l,o).catch(Me)},[r]);if(s.error&&Tu(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Vs(){return Vs=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function Ru(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function qx(){return Math.random().toString(36).substr(2,8)}function ud(e,t){return{usr:e.state,key:e.key,idx:t}}function bo(e,t,n,r){return n===void 0&&(n=null),Vs({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?Zr(t):t,{state:n,key:t&&t.key||r||qx()})}function pi(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function Zr(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function Gx(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:a=!1}=r,l=s.history,o=fn.Pop,u=null,c=p();c==null&&(c=0,l.replaceState(Vs({},l.state,{idx:c}),""));function p(){return(l.state||{idx:null}).idx}function f(){o=fn.Pop;let S=p(),v=S==null?null:S-c;c=S,u&&u({action:o,location:j.location,delta:v})}function h(S,v){o=fn.Push;let d=bo(j.location,S,v);c=p()+1;let m=ud(d,c),g=j.createHref(d);try{l.pushState(m,"",g)}catch(_){if(_ instanceof DOMException&&_.name==="DataCloneError")throw _;s.location.assign(g)}a&&u&&u({action:o,location:j.location,delta:1})}function x(S,v){o=fn.Replace;let d=bo(j.location,S,v);c=p();let m=ud(d,c),g=j.createHref(d);l.replaceState(m,"",g),a&&u&&u({action:o,location:j.location,delta:0})}function w(S){let v=s.location.origin!=="null"?s.location.origin:s.location.href,d=typeof S=="string"?S:pi(S);return d=d.replace(/ $/,"%20"),he(v,"No window.location.(origin|href) available to create URL for href: "+d),new URL(d,v)}let j={get action(){return o},get location(){return e(s,l)},listen(S){if(u)throw new Error("A history only accepts one active listener");return s.addEventListener(od,f),u=S,()=>{s.removeEventListener(od,f),u=null}},createHref(S){return t(s,S)},createURL:w,encodeLocation(S){let v=w(S);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:h,replace:x,go(S){return l.go(S)}};return j}var cd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(cd||(cd={}));function Jx(e,t,n){return n===void 0&&(n="/"),Yx(e,t,n)}function Yx(e,t,n,r){let s=typeof t=="string"?Zr(t):t,a=Wr(s.pathname||"/",n);if(a==null)return null;let l=lp(e);Xx(l);let o=null;for(let u=0;o==null&&u{let u={relativePath:o===void 0?a.path||"":o,caseSensitive:a.caseSensitive===!0,childrenIndex:l,route:a};u.relativePath.startsWith("/")&&(he(u.relativePath.startsWith(r),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(r.length));let c=Sn([r,u.relativePath]),p=n.concat(u);a.children&&a.children.length>0&&(he(a.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+c+'".')),lp(a.children,t,p,c)),!(a.path==null&&!a.index)&&t.push({path:c,score:ay(c,a.index),routesMeta:p})};return e.forEach((a,l)=>{var o;if(a.path===""||!((o=a.path)!=null&&o.includes("?")))s(a,l);else for(let u of op(a.path))s(a,l,u)}),t}function op(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return s?[a,""]:[a];let l=op(r.join("/")),o=[];return o.push(...l.map(u=>u===""?a:[a,u].join("/"))),s&&o.push(...l),o.map(u=>e.startsWith("/")&&u===""?"/":u)}function Xx(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:iy(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const Zx=/^:[\w-]+$/,ey=3,ty=2,ny=1,ry=10,sy=-2,dd=e=>e==="*";function ay(e,t){let n=e.split("/"),r=n.length;return n.some(dd)&&(r+=sy),t&&(r+=ty),n.filter(s=>!dd(s)).reduce((s,a)=>s+(Zx.test(a)?ey:a===""?ny:ry),r)}function iy(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function ly(e,t,n){let{routesMeta:r}=e,s={},a="/",l=[];for(let o=0;o{let{paramName:h,isOptional:x}=p;if(h==="*"){let j=o[f]||"";l=a.slice(0,a.length-j.length).replace(/(.)\/+$/,"$1")}const w=o[f];return x&&!w?c[h]=void 0:c[h]=(w||"").replace(/%2F/g,"/"),c},{}),pathname:a,pathnameBase:l,pattern:e}}function oy(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Ru(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,u)=>(r.push({paramName:o,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function uy(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ru(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Wr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const cy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,dy=e=>cy.test(e);function fy(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?Zr(e):e,a;if(n)if(dy(n))a=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Ru(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?a=fd(n.substring(1),"/"):a=fd(n,t)}else a=t;return{pathname:a,search:my(r),hash:vy(s)}}function fd(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function ml(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function hy(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function up(e,t){let n=hy(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function cp(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=Zr(e):(s=Vs({},e),he(!s.pathname||!s.pathname.includes("?"),ml("?","pathname","search",s)),he(!s.pathname||!s.pathname.includes("#"),ml("#","pathname","hash",s)),he(!s.search||!s.search.includes("#"),ml("#","search","hash",s)));let a=e===""||s.pathname==="",l=a?"/":s.pathname,o;if(l==null)o=n;else{let f=t.length-1;if(!r&&l.startsWith("..")){let h=l.split("/");for(;h[0]==="..";)h.shift(),f-=1;s.pathname=h.join("/")}o=f>=0?t[f]:"/"}let u=fy(s,o),c=l&&l!=="/"&&l.endsWith("/"),p=(a||l===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(c||p)&&(u.pathname+="/"),u}const Sn=e=>e.join("/").replace(/\/\/+/g,"/"),py=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),my=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,vy=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function xy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const dp=["post","put","patch","delete"];new Set(dp);const yy=["get",...dp];new Set(yy);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Ks(){return Ks=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),k.useCallback(function(c,p){if(p===void 0&&(p={}),!o.current)return;if(typeof c=="number"){r.go(c);return}let f=cp(c,JSON.parse(l),a,p.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Sn([t,f.pathname])),(p.replace?r.replace:r.push)(f,p.state,p)},[t,r,l,a,e])}const wy=k.createContext(null);function ky(e){let t=k.useContext(Ht).outlet;return t&&k.createElement(wy.Provider,{value:e},t)}function Mi(){let{matches:e}=k.useContext(Ht),t=e[e.length-1];return t?t.params:{}}function zi(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=k.useContext(Tn),{matches:s}=k.useContext(Ht),{pathname:a}=es(),l=JSON.stringify(up(s,r.v7_relativeSplatPath));return k.useMemo(()=>cp(e,JSON.parse(l),a,n==="path"),[e,l,a,n])}function Sy(e,t){return Ny(e,t)}function Ny(e,t,n,r){ia()||he(!1);let{navigator:s}=k.useContext(Tn),{matches:a}=k.useContext(Ht),l=a[a.length-1],o=l?l.params:{};l&&l.pathname;let u=l?l.pathnameBase:"/";l&&l.route;let c=es(),p;if(t){var f;let S=typeof t=="string"?Zr(t):t;u==="/"||(f=S.pathname)!=null&&f.startsWith(u)||he(!1),p=S}else p=c;let h=p.pathname||"/",x=h;if(u!=="/"){let S=u.replace(/^\//,"").split("/");x="/"+h.replace(/^\//,"").split("/").slice(S.length).join("/")}let w=Jx(e,{pathname:x}),j=Py(w&&w.map(S=>Object.assign({},S,{params:Object.assign({},o,S.params),pathname:Sn([u,s.encodeLocation?s.encodeLocation(S.pathname).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?u:Sn([u,s.encodeLocation?s.encodeLocation(S.pathnameBase).pathname:S.pathnameBase])})),a,n,r);return t&&j?k.createElement(Ri.Provider,{value:{location:Ks({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:fn.Pop}},j):j}function Cy(){let e=Ry(),t=xy(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return k.createElement(k.Fragment,null,k.createElement("h2",null,"Unexpected Application Error!"),k.createElement("h3",{style:{fontStyle:"italic"}},t),n?k.createElement("pre",{style:s},n):null,null)}const _y=k.createElement(Cy,null);class by extends k.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?k.createElement(Ht.Provider,{value:this.props.routeContext},k.createElement(hp.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Ey(e){let{routeContext:t,match:n,children:r}=e,s=k.useContext(Li);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),k.createElement(Ht.Provider,{value:t},r)}function Py(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var a;if(!n)return null;if(n.errors)e=n.matches;else if((a=r)!=null&&a.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let p=l.findIndex(f=>f.route.id&&(o==null?void 0:o[f.route.id])!==void 0);p>=0||he(!1),l=l.slice(0,Math.min(l.length,p+1))}let u=!1,c=-1;if(n&&r&&r.v7_partialHydration)for(let p=0;p=0?l=l.slice(0,c+1):l=[l[0]];break}}}return l.reduceRight((p,f,h)=>{let x,w=!1,j=null,S=null;n&&(x=o&&f.route.id?o[f.route.id]:void 0,j=f.route.errorElement||_y,u&&(c<0&&h===0?(zy("route-fallback"),w=!0,S=null):c===h&&(w=!0,S=f.route.hydrateFallbackElement||null)));let v=t.concat(l.slice(0,h+1)),d=()=>{let m;return x?m=j:w?m=S:f.route.Component?m=k.createElement(f.route.Component,null):f.route.element?m=f.route.element:m=p,k.createElement(Ey,{match:f,routeContext:{outlet:p,matches:v,isDataRoute:n!=null},children:m})};return n&&(f.route.ErrorBoundary||f.route.errorElement||h===0)?k.createElement(by,{location:n.location,revalidation:n.revalidation,component:j,error:x,children:d(),routeContext:{outlet:null,matches:v,isDataRoute:!0}}):d()},null)}var mp=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(mp||{}),vp=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(vp||{});function Ty(e){let t=k.useContext(Li);return t||he(!1),t}function Oy(e){let t=k.useContext(fp);return t||he(!1),t}function Ly(e){let t=k.useContext(Ht);return t||he(!1),t}function xp(e){let t=Ly(),n=t.matches[t.matches.length-1];return n.route.id||he(!1),n.route.id}function Ry(){var e;let t=k.useContext(hp),n=Oy(),r=xp();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function My(){let{router:e}=Ty(mp.UseNavigateStable),t=xp(vp.UseNavigateStable),n=k.useRef(!1);return pp(()=>{n.current=!0}),k.useCallback(function(s,a){a===void 0&&(a={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Ks({fromRouteId:t},a)))},[e,t])}const hd={};function zy(e,t,n){hd[e]||(hd[e]=!0)}function Iy(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function Fy(e){return ky(e.context)}function gt(e){he(!1)}function Dy(e){let{basename:t="/",children:n=null,location:r,navigationType:s=fn.Pop,navigator:a,static:l=!1,future:o}=e;ia()&&he(!1);let u=t.replace(/^\/*/,"/"),c=k.useMemo(()=>({basename:u,navigator:a,static:l,future:Ks({v7_relativeSplatPath:!1},o)}),[u,o,a,l]);typeof r=="string"&&(r=Zr(r));let{pathname:p="/",search:f="",hash:h="",state:x=null,key:w="default"}=r,j=k.useMemo(()=>{let S=Wr(p,u);return S==null?null:{location:{pathname:S,search:f,hash:h,state:x,key:w},navigationType:s}},[u,p,f,h,x,w,s]);return j==null?null:k.createElement(Tn.Provider,{value:c},k.createElement(Ri.Provider,{children:n,value:j}))}function Ay(e){let{children:t,location:n}=e;return Sy(Po(t),n)}new Promise(()=>{});function Po(e,t){t===void 0&&(t=[]);let n=[];return k.Children.forEach(e,(r,s)=>{if(!k.isValidElement(r))return;let a=[...t,s];if(r.type===k.Fragment){n.push.apply(n,Po(r.props.children,a));return}r.type!==gt&&he(!1),!r.props.index||!r.props.children||he(!1);let l={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Po(r.props.children,a)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function mi(){return mi=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function $y(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Uy(e,t){return e.button===0&&(!t||t==="_self")&&!$y(e)}const By=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Qy=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],Vy="6";try{window.__reactRouterVersion=Vy}catch{}const Ky=k.createContext({isTransitioning:!1}),Hy="startTransition",pd=Zp[Hy];function Wy(e){let{basename:t,children:n,future:r,window:s}=e,a=k.useRef();a.current==null&&(a.current=Wx({window:s,v5Compat:!0}));let l=a.current,[o,u]=k.useState({action:l.action,location:l.location}),{v7_startTransition:c}=r||{},p=k.useCallback(f=>{c&&pd?pd(()=>u(f)):u(f)},[u,c]);return k.useLayoutEffect(()=>l.listen(p),[l,p]),k.useEffect(()=>Iy(r),[r]),k.createElement(Dy,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const qy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Gy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Hs=k.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:a,replace:l,state:o,target:u,to:c,preventScrollReset:p,viewTransition:f}=t,h=yp(t,By),{basename:x}=k.useContext(Tn),w,j=!1;if(typeof c=="string"&&Gy.test(c)&&(w=c,qy))try{let m=new URL(window.location.href),g=c.startsWith("//")?new URL(m.protocol+c):new URL(c),_=Wr(g.pathname,x);g.origin===m.origin&&_!=null?c=_+g.search+g.hash:j=!0}catch{}let S=gy(c,{relative:s}),v=Yy(c,{replace:l,state:o,target:u,preventScrollReset:p,relative:s,viewTransition:f});function d(m){r&&r(m),m.defaultPrevented||v(m)}return k.createElement("a",mi({},h,{href:w||S,onClick:j||a?r:d,ref:n,target:u}))}),md=k.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:a="",end:l=!1,style:o,to:u,viewTransition:c,children:p}=t,f=yp(t,Qy),h=zi(u,{relative:f.relative}),x=es(),w=k.useContext(fp),{navigator:j,basename:S}=k.useContext(Tn),v=w!=null&&Xy(h)&&c===!0,d=j.encodeLocation?j.encodeLocation(h).pathname:h.pathname,m=x.pathname,g=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;s||(m=m.toLowerCase(),g=g?g.toLowerCase():null,d=d.toLowerCase()),g&&S&&(g=Wr(g,S)||g);const _=d!=="/"&&d.endsWith("/")?d.length-1:d.length;let N=m===d||!l&&m.startsWith(d)&&m.charAt(_)==="/",C=g!=null&&(g===d||!l&&g.startsWith(d)&&g.charAt(d.length)==="/"),b={isActive:N,isPending:C,isTransitioning:v},z=N?r:void 0,O;typeof a=="function"?O=a(b):O=[a,N?"active":null,C?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let U=typeof o=="function"?o(b):o;return k.createElement(Hs,mi({},f,{"aria-current":z,className:O,ref:n,style:U,to:u,viewTransition:c}),typeof p=="function"?p(b):p)});var To;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(To||(To={}));var vd;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(vd||(vd={}));function Jy(e){let t=k.useContext(Li);return t||he(!1),t}function Yy(e,t){let{target:n,replace:r,state:s,preventScrollReset:a,relative:l,viewTransition:o}=t===void 0?{}:t,u=Et(),c=es(),p=zi(e,{relative:l});return k.useCallback(f=>{if(Uy(f,n)){f.preventDefault();let h=r!==void 0?r:pi(c)===pi(p);u(e,{replace:h,state:s,preventScrollReset:a,relative:l,viewTransition:o})}},[c,u,p,r,s,n,e,a,l,o])}function Xy(e,t){t===void 0&&(t={});let n=k.useContext(Ky);n==null&&he(!1);let{basename:r}=Jy(To.useViewTransitionState),s=zi(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=Wr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Wr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Eo(s.pathname,l)!=null||Eo(s.pathname,a)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var Zy={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const eg=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),J=(e,t)=>{const n=k.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:a=2,absoluteStrokeWidth:l,className:o="",children:u,...c},p)=>k.createElement("svg",{ref:p,...Zy,width:s,height:s,stroke:r,strokeWidth:l?Number(a)*24/Number(s):a,className:["lucide",`lucide-${eg(e)}`,o].join(" "),...c},[...t.map(([f,h])=>k.createElement(f,h)),...Array.isArray(u)?u:[u]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const tg=J("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ng=J("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const rg=J("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const sg=J("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ag=J("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ig=J("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const lg=J("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const og=J("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ns=J("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ug=J("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const cg=J("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const dg=J("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const fg=J("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const hg=J("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const pg=J("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ii=J("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const mg=J("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const vg=J("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const xg=J("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fi=J("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gp=J("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yg=J("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gg=J("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ws=J("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const jp=J("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wp=J("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const jg=J("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wg=J("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kg=J("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kp=J("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sp=J("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sg=J("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Di=J("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Ng={},xd=e=>{let t;const n=new Set,r=(p,f)=>{const h=typeof p=="function"?p(t):p;if(!Object.is(h,t)){const x=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(w=>w(t,x))}},s=()=>t,u={setState:r,getState:s,getInitialState:()=>c,subscribe:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(Ng?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=t=e(r,s,u);return u},Cg=e=>e?xd(e):xd;var Np={exports:{}},Cp={},_p={exports:{}},bp={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var qr=k;function _g(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var bg=typeof Object.is=="function"?Object.is:_g,Eg=qr.useState,Pg=qr.useEffect,Tg=qr.useLayoutEffect,Og=qr.useDebugValue;function Lg(e,t){var n=t(),r=Eg({inst:{value:n,getSnapshot:t}}),s=r[0].inst,a=r[1];return Tg(function(){s.value=n,s.getSnapshot=t,vl(s)&&a({inst:s})},[e,n,t]),Pg(function(){return vl(s)&&a({inst:s}),e(function(){vl(s)&&a({inst:s})})},[e]),Og(n),n}function vl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!bg(e,n)}catch{return!0}}function Rg(e,t){return t()}var Mg=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Rg:Lg;bp.useSyncExternalStore=qr.useSyncExternalStore!==void 0?qr.useSyncExternalStore:Mg;_p.exports=bp;var zg=_p.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Ai=k,Ig=zg;function Fg(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Dg=typeof Object.is=="function"?Object.is:Fg,Ag=Ig.useSyncExternalStore,$g=Ai.useRef,Ug=Ai.useEffect,Bg=Ai.useMemo,Qg=Ai.useDebugValue;Cp.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var a=$g(null);if(a.current===null){var l={hasValue:!1,value:null};a.current=l}else l=a.current;a=Bg(function(){function u(x){if(!c){if(c=!0,p=x,x=r(x),s!==void 0&&l.hasValue){var w=l.value;if(s(w,x))return f=w}return f=x}if(w=f,Dg(p,x))return w;var j=r(x);return s!==void 0&&s(w,j)?(p=x,w):(p=x,f=j)}var c=!1,p,f,h=n===void 0?null:n;return[function(){return u(t())},h===null?void 0:function(){return u(h())}]},[t,n,r,s]);var o=Ag(e,a[0],a[1]);return Ug(function(){l.hasValue=!0,l.value=o},[o]),Qg(o),o};Np.exports=Cp;var Vg=Np.exports;const Kg=Id(Vg),Ep={},{useDebugValue:Hg}=Fo,{useSyncExternalStoreWithSelector:Wg}=Kg;let yd=!1;const qg=e=>e;function Gg(e,t=qg,n){(Ep?"production":void 0)!=="production"&&n&&!yd&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),yd=!0);const r=Wg(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Hg(r),r}const gd=e=>{(Ep?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?Cg(e):e,n=(r,s)=>Gg(t,r,s);return Object.assign(n,t),n},Mu=e=>e?gd(e):gd,$i="/api",zu="flow_auth_token",Iu="flow_auth_expires",Fu="flow_auth_username";function qs(){const e=localStorage.getItem(zu),t=localStorage.getItem(Iu);return!e||!t?null:new Date(t)<=new Date?(Jn(),null):e}function jd(e,t,n){localStorage.setItem(zu,e),localStorage.setItem(Iu,t),localStorage.setItem(Fu,n)}function Jn(){localStorage.removeItem(zu),localStorage.removeItem(Iu),localStorage.removeItem(Fu)}function Du(){return localStorage.getItem(Fu)}let ar=null;function Jg(e){ar=e}async function Q(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const a=qs();a&&(r.Authorization=`Bearer ${a}`)}const s=await fetch(`${$i}${e}`,{...t,headers:r});if(s.status===401){Jn(),ar&&ar();const a=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(a.detail||"Not authenticated")}if(!s.ok){const a=await s.json().catch(()=>({detail:s.statusText}));throw new Error(a.detail||"API request failed")}if(s.status!==204)return s.json()}const ur={getConfig:()=>Q("/auth/config",void 0,!0),login:e=>Q("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${$i}/auth/github`,getCurrentUser:()=>Q("/auth/me"),logout:()=>Q("/auth/logout",{method:"POST"})},Yn={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return Q(`/configs${n?`?${n}`:""}`)},get:e=>Q(`/configs/${e}`),create:e=>Q("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Q(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Q(`/configs/${e}`,{method:"DELETE"}),generateCandidates:e=>Q("/configs/generate-candidates",{method:"POST",body:JSON.stringify(e)})},Dt={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return Q(`/tasks${n?`?${n}`:""}`)},get:e=>Q(`/tasks/${e}`),create:e=>Q("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Q(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Q(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>Q("/tasks/suites"),importSuite:e=>Q(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},bt={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return Q(`/jobs${n?`?${n}`:""}`)},get:e=>Q(`/jobs/${e}`),create:e=>Q("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Q(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=qs();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${$i}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Jn(),ar&&ar(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const a=new TextDecoder;let l="";for(;;){const{done:u,value:c}=await s.read();if(u)break;l+=a.decode(c,{stream:!0});const p=l.split(` +`);l=p.pop()||"";for(const f of p)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>Q(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>Q(`/jobs/${e}`,{method:"DELETE"})},Oo={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return Q(`/runs${n?`?${n}`:""}`)},get:e=>Q(`/runs/${e}`),getJobSummary:e=>Q(`/runs/job/${e}/summary`)},Cs={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return Q(`/tests${n?`?${n}`:""}`)},get:e=>Q(`/tests/${e}`),create:e=>Q("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=qs();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${$i}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Jn(),ar&&ar(),new Error("Not authenticated");if(!r.ok){const u=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(u.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const a=new TextDecoder;let l="";for(;;){const{done:u,value:c}=await s.read();if(u)break;l+=a.decode(c,{stream:!0});const p=l.split(` +`);l=p.pop()||"";for(const f of p)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>Q(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>Q(`/tests/${e}`,{method:"DELETE"})},Yg={list:()=>Q("/llm-configs"),get:e=>Q(`/llm-configs/${e}`),getDefault:()=>Q("/llm-configs/default"),create:e=>Q("/llm-configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Q(`/llm-configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Q(`/llm-configs/${e}`,{method:"DELETE"}),setDefault:e=>Q(`/llm-configs/${e}/set-default`,{method:"POST"}),test:e=>Q(`/llm-configs/${e}/test`,{method:"POST"})},Pp={list:()=>Q("/tools"),get:e=>Q(`/tools/${e}`)},Au=Mu((e,t)=>(Jg(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const n=await ur.getConfig();if(e({authConfig:n,isLoadingConfig:!1}),n.enabled){const r=qs(),s=Du();if(r&&s)try{const a=await ur.getCurrentUser();e({isAuthenticated:!0,user:a})}catch{Jn(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(n){console.error("Failed to load auth config:",n),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(n,r)=>{e({isLoading:!0,error:null});try{const s=await ur.login({username:n,password:r});return jd(s.access_token,s.expires_at,s.username),e({isAuthenticated:!0,isLoading:!1,user:{username:s.username,auth_mode:"basic"}}),!0}catch(s){return e({isLoading:!1,error:s instanceof Error?s.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=ur.getGitHubAuthUrl()},handleOAuthCallback:()=>{const n=new URLSearchParams(window.location.search),r=n.get("auth_error");if(r)return e({error:r}),window.history.replaceState({},"",window.location.pathname),!0;if(n.get("auth_callback")==="true"){const s=n.get("token"),a=n.get("expires_at"),l=n.get("username");return s&&a&&l&&(jd(s,a,l),e({isAuthenticated:!0,user:{username:l,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await ur.logout()}catch{}Jn(),e({isAuthenticated:!1,user:null,error:null})},checkAuth:async()=>{const{authConfig:n}=t();if(!(n!=null&&n.enabled)){e({isAuthenticated:!0});return}if(!qs()){e({isAuthenticated:!1,user:null});return}try{const s=await ur.getCurrentUser();e({isAuthenticated:!0,user:s})}catch{Jn(),e({isAuthenticated:!1,user:null})}},clearError:()=>e({error:null})}));function K({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:a=!1,children:l,disabled:o,...u}){const c="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5",p={primary:"bg-[var(--accent)] text-black hover:bg-[#16a34a]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},f={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},h=t==="sm"?14:16;return i.jsxs("button",{className:`${c} ${p[e]} ${f[t]} ${n}`,disabled:o||a,...u,children:[a?i.jsx(Fi,{size:h,className:"animate-spin"}):r?i.jsx(r,{size:h}):null,l,s&&!a&&i.jsx(s,{size:h})]})}const Xg={};function Zg(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var a;const l=u=>u===null?null:JSON.parse(u,void 0),o=(a=n.getItem(s))!=null?a:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,a)=>n.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>n.removeItem(s)}}const Gs=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return Gs(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return Gs(r)(n)}}}},e0=(e,t)=>(n,r,s)=>{let a={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:S=>S,version:0,merge:(S,v)=>({...v,...S}),...t},l=!1;const o=new Set,u=new Set;let c;try{c=a.getStorage()}catch{}if(!c)return e((...S)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...S)},r,s);const p=Gs(a.serialize),f=()=>{const S=a.partialize({...r()});let v;const d=p({state:S,version:a.version}).then(m=>c.setItem(a.name,m)).catch(m=>{v=m});if(v)throw v;return d},h=s.setState;s.setState=(S,v)=>{h(S,v),f()};const x=e((...S)=>{n(...S),f()},r,s);let w;const j=()=>{var S;if(!c)return;l=!1,o.forEach(d=>d(r()));const v=((S=a.onRehydrateStorage)==null?void 0:S.call(a,r()))||void 0;return Gs(c.getItem.bind(c))(a.name).then(d=>{if(d)return a.deserialize(d)}).then(d=>{if(d)if(typeof d.version=="number"&&d.version!==a.version){if(a.migrate)return a.migrate(d.state,d.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return d.state}).then(d=>{var m;return w=a.merge(d,(m=r())!=null?m:x),n(w,!0),f()}).then(()=>{v==null||v(w,void 0),l=!0,u.forEach(d=>d(w))}).catch(d=>{v==null||v(void 0,d)})};return s.persist={setOptions:S=>{a={...a,...S},S.getStorage&&(c=S.getStorage())},clearStorage:()=>{c==null||c.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>j(),hasHydrated:()=>l,onHydrate:S=>(o.add(S),()=>{o.delete(S)}),onFinishHydration:S=>(u.add(S),()=>{u.delete(S)})},j(),w||x},t0=(e,t)=>(n,r,s)=>{let a={storage:Zg(()=>localStorage),partialize:j=>j,version:0,merge:(j,S)=>({...S,...j}),...t},l=!1;const o=new Set,u=new Set;let c=a.storage;if(!c)return e((...j)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...j)},r,s);const p=()=>{const j=a.partialize({...r()});return c.setItem(a.name,{state:j,version:a.version})},f=s.setState;s.setState=(j,S)=>{f(j,S),p()};const h=e((...j)=>{n(...j),p()},r,s);s.getInitialState=()=>h;let x;const w=()=>{var j,S;if(!c)return;l=!1,o.forEach(d=>{var m;return d((m=r())!=null?m:h)});const v=((S=a.onRehydrateStorage)==null?void 0:S.call(a,(j=r())!=null?j:h))||void 0;return Gs(c.getItem.bind(c))(a.name).then(d=>{if(d)if(typeof d.version=="number"&&d.version!==a.version){if(a.migrate)return[!0,a.migrate(d.state,d.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,d.state];return[!1,void 0]}).then(d=>{var m;const[g,_]=d;if(x=a.merge(_,(m=r())!=null?m:h),n(x,!0),g)return p()}).then(()=>{v==null||v(x,void 0),x=r(),l=!0,u.forEach(d=>d(x))}).catch(d=>{v==null||v(void 0,d)})};return s.persist={setOptions:j=>{a={...a,...j},j.storage&&(c=j.storage)},clearStorage:()=>{c==null||c.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>w(),hasHydrated:()=>l,onHydrate:j=>(o.add(j),()=>{o.delete(j)}),onFinishHydration:j=>(u.add(j),()=>{u.delete(j)})},a.skipHydration||w(),x||h},n0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((Xg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),e0(e,t)):t0(e,t),r0=n0,s0=Mu()(r0((e,t)=>({theme:"dark",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function a0(){const{theme:e,toggleTheme:t}=s0();return i.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?i.jsx(kg,{size:16}):i.jsx(gg,{size:16})})}const i0=[{path:"/agents",label:"Agents",icon:sg},{path:"/tasks",label:"Tasks",icon:vg},{path:"/jobs",label:"Jobs",icon:Ws}];function l0(){const e=es(),{authConfig:t,user:n,logout:r}=Au(),s=l=>l==="/agents"?e.pathname==="/"||e.pathname==="/agents":e.pathname.startsWith(l),a=async()=>{await r()};return i.jsxs("div",{className:"min-h-screen flex flex-col",children:[i.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:i.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-3 flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-8",children:[i.jsxs(md,{to:"/",className:"text-lg font-bold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[i.jsx(Di,{size:20}),"flow",i.jsx("span",{className:"text-[var(--text-secondary)]",children:"/optimize"})]}),i.jsx("nav",{className:"flex gap-1",children:i0.map(l=>i.jsxs(md,{to:l.path,className:`px-3 py-1.5 rounded text-sm transition-colors flex items-center gap-2 ${s(l.path)?"bg-[var(--accent)] text-black font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"}`,children:[i.jsx(l.icon,{size:16}),l.label]},l.path))})]}),i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(a0,{}),(t==null?void 0:t.enabled)&&n&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[i.jsx(Sp,{size:14}),i.jsx("span",{children:n.username})]}),i.jsx(K,{variant:"ghost",size:"sm",icon:yg,onClick:a,title:"Sign out",children:"Sign out"})]})]})]})}),i.jsx("main",{className:"flex-1 bg-[var(--bg-primary)]",children:i.jsx("div",{className:"max-w-7xl mx-auto p-4",children:i.jsx(Fy,{})})})]})}const o0=["maf","miniagent","langgraph"],u0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},c0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"};function Z({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const a="bg-[var(--bg-secondary)] border border-[var(--border)] p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return i.jsx("div",{className:`${a} ${l} ${o} ${t}`,onClick:n,children:e})}function W({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-green-600 text-white",warning:"bg-yellow-500 text-black",error:"bg-red-600 text-white",info:"bg-blue-600 text-white"};return i.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded ${n[t]}`,children:e})}const d0={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};function Tp({job:e,onDelete:t}){const n=Et(),r=e.total_experiments>0?e.completed_experiments/e.total_experiments*100:0;return i.jsxs(Z,{className:"cursor-pointer hover:border-[var(--accent-dim)] flex flex-col",onClick:()=>n(`/jobs/${e.id}`),children:[i.jsxs("div",{className:"flex items-start justify-between mb-3",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsx(W,{variant:d0[e.status]||"default",children:e.status}),e.is_public&&i.jsxs(W,{variant:"info",children:[i.jsx(Ii,{className:"w-3 h-3 mr-1 inline"}),"Public"]}),e.pareto_frontier.length>0&&i.jsxs(W,{variant:"success",children:[e.pareto_frontier.length," Pareto"]}),e.use_llm_eval&&i.jsx(W,{children:"LLM"})]}),i.jsx("h3",{className:"font-medium mt-2 truncate",title:e.name||`Job ${e.id.slice(0,8)}`,children:e.name||`Job ${e.id.slice(0,8)}`}),i.jsxs("code",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[e.id.slice(0,8),"..."]})]}),t&&i.jsx(K,{variant:"ghost",size:"sm",onClick:s=>{s.stopPropagation(),confirm("Delete this job?")&&t(e.id)},disabled:e.status==="running",children:"×"})]}),(e.status==="running"||e.status==="completed")&&i.jsxs("div",{className:"mb-3",children:[i.jsxs("div",{className:"flex justify-between text-xs text-[var(--text-secondary)] mb-1",children:[i.jsx("span",{children:"Progress"}),i.jsxs("span",{children:[e.completed_experiments,"/",e.total_experiments]})]}),i.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-1.5 rounded-full overflow-hidden",children:i.jsx("div",{className:`h-full transition-all ${e.status==="completed"?"bg-green-500":"bg-[var(--accent)]"}`,style:{width:`${r}%`}})})]}),e.status==="failed"&&e.error&&i.jsx("div",{className:"mb-3 px-2 py-1.5 bg-red-500/10 border border-red-500/30 rounded text-xs text-red-400 line-clamp-2",children:e.error}),i.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center py-2 border-t border-[var(--border)] mt-auto",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-lg font-bold",children:e.candidate_ids.length}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"candidates"})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-lg font-bold",children:e.task_ids.length}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"tasks"})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-lg font-bold",children:e.total_experiments}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"runs"})]})]}),i.jsxs("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)] flex justify-between items-center",children:[i.jsxs("span",{children:[new Date(e.created_at).toLocaleDateString()," ",new Date(e.created_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]}),e.is_public&&e.created_by_name&&i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["by ",e.created_by_name]})]})]})}function la({isOpen:e,onClose:t,title:n,children:r}){return k.useEffect(()=>{const s=a=>{a.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",s),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",s),document.body.style.overflow=""}},[e,t]),e?i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[i.jsx("div",{className:"absolute inset-0 bg-black/80",onClick:t}),i.jsxs("div",{className:"relative bg-[var(--bg-secondary)] border border-[var(--border)] max-w-lg w-full mx-4 max-h-[80vh] overflow-y-auto",children:[i.jsxs("div",{className:"sticky top-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[i.jsx("h2",{className:"font-semibold",children:n}),i.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),i.jsx("div",{className:"p-4",children:r})]})]}):null}function pt({label:e,className:t="",...n}){return i.jsxs("div",{className:"space-y-1",children:[e&&i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:e}),i.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function f0({label:e,className:t="",...n}){return i.jsxs("div",{className:"space-y-1",children:[e&&i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:e}),i.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function Mn({label:e,className:t="",...n}){return i.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[i.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] accent-[var(--accent)]",...n}),i.jsx("span",{className:"text-sm",children:e})]})}function wd(){const e=Et(),t=Pn(),[n,r]=k.useState(!1),[s,a]=k.useState(null),{data:l=[],isLoading:o}=ve({queryKey:["configs"],queryFn:()=>Yn.list()}),{data:u=[]}=ve({queryKey:["jobs"],queryFn:()=>bt.list()}),c=at({mutationFn:Yn.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),p=at({mutationFn:Yn.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),f=h=>{const x=u.filter(S=>S.candidate_ids.includes(h)),w=x.filter(S=>S.status==="running").length,j=x.filter(S=>S.status==="completed").length;return{running:w,completed:j,total:x.length}};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),i.jsx(K,{variant:"primary",icon:jp,onClick:()=>r(!0),children:"New Agent"})]}),o?i.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[i.jsx(Fi,{size:16,className:"animate-spin"}),"Loading agents..."]}):l.length===0?i.jsx(h0,{onCreateClick:()=>r(!0)}):i.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:l.map(h=>{const x=f(h.id);return i.jsx(m0,{agent:h,stats:x,onClick:()=>e(`/agents/${h.id}`),onOptimize:()=>a(h),onDelete:()=>{confirm(`Delete agent "${h.name}"?`)&&p.mutate(h.id)}},h.id)})}),u.length>0&&i.jsxs("div",{className:"mt-8",children:[i.jsx("h3",{className:"text-lg font-medium mb-4",children:"Recent Optimization Jobs"}),i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:u.slice(0,6).map(h=>i.jsx(Tp,{job:h},h.id))}),u.length>6&&i.jsxs(K,{variant:"ghost",className:"mt-4",onClick:()=>e("/jobs"),children:["View all ",u.length," jobs →"]})]}),i.jsx(v0,{isOpen:n,onClose:()=>r(!1),onSubmit:h=>c.mutate(h),isLoading:c.isPending}),s&&i.jsx(x0,{agent:s,isOpen:!!s,onClose:()=>a(null)})]})}function h0({onCreateClick:e}){return i.jsxs("div",{className:"text-center py-16 border border-dashed border-[var(--border)] rounded-lg",children:[i.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)] mb-4",children:i.jsx(wp,{size:24,className:"text-[var(--text-secondary)]"})}),i.jsx("h3",{className:"text-lg font-medium mb-2",children:"No agents yet"}),i.jsx("p",{className:"text-[var(--text-secondary)] mb-4 max-w-md mx-auto",children:"Create your first agent to start optimizing. Each agent defines instructions, model, compaction strategy, and tool settings."}),i.jsx(K,{variant:"primary",icon:jp,onClick:e,children:"Create Your First Agent"})]})}function p0(e){return typeof e=="string"?`tools: ${e}`:Array.isArray(e)?`tools: [${e.length}]`:typeof e=="object"?`tools: [${Object.keys(e).length}]`:"tools: standard"}function m0({agent:e,stats:t,onClick:n,onOptimize:r,onDelete:s}){const a=e.config.compaction,l=(a==null?void 0:a.strategy)==="head_tail"?`compaction ${a.params.head_size}/${a.params.tail_size}`:(a==null?void 0:a.strategy)==="none"?null:(a==null?void 0:a.strategy)||null,o=p0(e.config.tools),u=e.config.framework||"maf";return i.jsxs(Z,{className:"flex flex-col cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:n,children:[i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-start justify-between mb-3",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium text-lg",children:e.name}),e.description&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:e.description})]}),i.jsx(K,{variant:"ghost",size:"sm",icon:kp,onClick:c=>{c.stopPropagation(),s()}})]}),i.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-4",children:[i.jsx(W,{variant:u==="miniagent"?"success":"default",children:u}),l&&i.jsx(W,{children:l}),i.jsx(W,{children:o})]}),t.total>0&&i.jsxs("div",{className:"text-xs text-[var(--text-secondary)] mb-3",children:[t.running>0&&i.jsxs("span",{className:"text-[var(--accent)]",children:[t.running," running "]}),t.completed>0&&i.jsxs("span",{children:[t.completed," completed"]})]})]}),i.jsx("div",{className:"flex gap-2",children:i.jsx(K,{variant:"primary",icon:Di,onClick:c=>{c.stopPropagation(),r()},className:"flex-1",children:"Optimize"})})]})}function v0({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var C,b,z,O,U;const s=["read_file","write_file","edit_file","bash","grep","think"],[a,l]=k.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"maf",llm_config_id:null}),[o,u]=k.useState(!1),[c,p]=k.useState("custom"),[f,h]=k.useState([...s]),[x,w]=k.useState(!1),{data:j=[]}=ve({queryKey:["llm-configs"],queryFn:()=>Yg.list()}),{data:S}=ve({queryKey:["tools"],queryFn:()=>Pp.list()}),v=((C=S==null?void 0:S.tools)==null?void 0:C.map(P=>P.name))??s,d=(S==null?void 0:S.presets)??{},m=Object.keys(d),g=P=>{if(P.preventDefault(),!a.name.trim())return;const A={...a};c==="custom"&&(A.tools=f),n(A)},_=((b=a.compaction)==null?void 0:b.strategy)!=="none",N=P=>{h(A=>A.includes(P)?A.filter(ee=>ee!==P):[...A,P])};return i.jsx(la,{isOpen:e,onClose:t,title:"Create Agent",children:i.jsxs("form",{onSubmit:g,className:"space-y-4",children:[i.jsx(pt,{label:"Name",value:a.name,onChange:P=>l({...a,name:P.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),i.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:a.llm_config_id||"",onChange:P=>l({...a,llm_config_id:P.target.value||null}),children:[i.jsx("option",{value:"",children:"Use environment variables"}),j.map(P=>i.jsxs("option",{value:P.id,children:[P.name," (",c0[P.provider],P.model_id?` - ${P.model_id}`:"",")",P.is_default?" (default)":""]},P.id))]}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:j.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":a.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:a.framework||"maf",onChange:P=>l({...a,framework:P.target.value}),children:o0.map(P=>i.jsx("option",{value:P,children:u0[P]},P))}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:a.framework==="miniagent"?"Lightweight agent with token-aware context management.":a.framework==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation."})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(Mn,{label:"Custom instructions",checked:o,onChange:P=>{u(P.target.checked),P.target.checked||l({...a,instructions:null})}}),i.jsx(Mn,{label:"Enable compaction",checked:_,onChange:P=>l({...a,compaction:P.target.checked?{strategy:"head_tail",params:{head_size:10,tail_size:40}}:{strategy:"none",params:{}}})})]}),o&&i.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:a.instructions||"",onChange:P=>l({...a,instructions:P.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),_&&i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsx(pt,{label:"Head size",type:"number",value:((z=a.compaction)==null?void 0:z.params.head_size)??10,onChange:P=>l({...a,compaction:{strategy:"head_tail",params:{...a.compaction.params,head_size:parseInt(P.target.value)||10}}}),min:1}),i.jsx(pt,{label:"Tail size",type:"number",value:((O=a.compaction)==null?void 0:O.params.tail_size)??40,onChange:P=>l({...a,compaction:{strategy:"head_tail",params:{...a.compaction.params,tail_size:parseInt(P.target.value)||40}}}),min:1})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium",children:"Tools"}),i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"radio",checked:c==="custom",onChange:()=>p("custom"),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:"Custom"})]}),i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"radio",checked:c==="preset",onChange:()=>p("preset"),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:"Preset"})]})]}),c==="custom"?i.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:v.map(P=>i.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[i.jsx("input",{type:"checkbox",checked:f.includes(P),onChange:()=>N(P),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"font-mono text-xs",children:P})]},P))}):i.jsxs(i.Fragment,{children:[i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof a.tools=="string"?a.tools:"standard",onChange:P=>l({...a,tools:P.target.value}),children:m.map(P=>i.jsx("option",{value:P,children:P},P))}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((U=d[typeof a.tools=="string"?a.tools:"standard"])==null?void 0:U.join(", "))??""})]})]}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>w(!x),children:[i.jsx(Ns,{size:14,className:`transition-transform ${x?"rotate-90":""}`}),"More options"]}),x&&i.jsx("div",{className:"mt-3",children:i.jsx(pt,{label:"Description (optional)",value:a.description,onChange:P=>l({...a,description:P.target.value}),placeholder:"Brief description of this agent"})})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(K,{type:"submit",variant:"primary",disabled:!a.name.trim(),loading:r,children:"Create Agent"})]})]})})}function x0({agent:e,isOpen:t,onClose:n}){var te,le,R;const r=Et(),s=Pn(),[a,l]=k.useState("suite"),[o,u]=k.useState("quick"),[c,p]=k.useState(!1),[f,h]=k.useState([]),[x,w]=k.useState({base_name:e.name,vary_compaction:!0,vary_tools:!0,vary_compaction_head:!1,vary_compaction_tail:!1,tool_presets:["standard","minimal"],compaction_head_values:[5,10,20],compaction_tail_values:[20,40,60]}),[j,S]=k.useState(4),[v,d]=k.useState(!1),[m,g]=k.useState(null),{data:_=[]}=ve({queryKey:["tasks"],queryFn:()=>Dt.list()}),{data:N=[]}=ve({queryKey:["suites"],queryFn:()=>Dt.listSuites()}),C=N.map(E=>({value:E.name,label:E.name.charAt(0).toUpperCase()+E.name.slice(1),description:E.description,tasks:E.task_count})),{data:b}=ve({queryKey:["tools"],queryFn:()=>Pp.list()}),z=b!=null&&b.presets?Object.keys(b.presets):["standard","minimal","full","readonly"],O=at({mutationFn:Dt.importSuite,onSuccess:E=>{s.invalidateQueries({queryKey:["tasks"]}),h(E.map(B=>B.id))}}),U=at({mutationFn:Yn.generateCandidates,onSuccess:()=>{s.invalidateQueries({queryKey:["configs"]})}}),P=at({mutationFn:async E=>{const B=await bt.create(E);return bt.start(B.id).next(),B},onSuccess:E=>{s.invalidateQueries({queryKey:["jobs"]}),g(E.id),l("success")}}),A=()=>{var B,re,xe;let E=1;return x.vary_compaction&&(E*=2),x.vary_tools&&(E*=((B=x.tool_presets)==null?void 0:B.length)||3),x.vary_compaction_head&&(E*=((re=x.compaction_head_values)==null?void 0:re.length)||3),x.vary_compaction_tail&&(E*=((xe=x.compaction_tail_values)==null?void 0:xe.length)||3),E},ee=x.vary_compaction||x.vary_tools||x.vary_compaction_head||x.vary_compaction_tail,De=async()=>{l("starting");let E=f,B=[e.id];if(!c)try{E=(await O.mutateAsync(o)).map(Ui=>Ui.id)}catch(On){console.error("Failed to import suite:",On),alert(`Failed to import task suite: ${o}`),l("candidates");return}if(E.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("candidates");return}try{B=(await U.mutateAsync({...x,base_name:e.name})).map(Ui=>Ui.id)}catch(On){console.error("Failed to generate candidates:",On),alert("Failed to generate candidates"),l("candidates");return}const re=A(),xe={name:`${e.name} optimization (${re} candidates × ${E.length} tasks)`,candidate_ids:B,task_ids:E,parallel:j,use_llm_eval:v};P.mutate(xe)},Wt=E=>{h(B=>B.includes(E)?B.filter(re=>re!==E):[...B,E])},Ae=()=>{l("suite"),g(null),n()},L=A(),D=c?f.length:((te=C.find(E=>E.value===o))==null?void 0:te.tasks)||3,$=L*D;return i.jsx(la,{isOpen:t,onClose:Ae,title:`Optimize: ${e.name}`,children:a==="success"&&m?i.jsxs("div",{className:"flex flex-col items-center py-8",children:[i.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:i.jsx(Di,{size:24,className:"text-green-500"})}),i.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),i.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:"Optimization job is now running"}),i.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono mb-6",children:["ID: ",m.slice(0,8),"..."]}),i.jsxs("div",{className:"flex gap-3",children:[i.jsx(K,{variant:"secondary",onClick:Ae,children:"Close"}),i.jsx(K,{variant:"primary",icon:Ws,onClick:()=>{Ae(),r(`/jobs/${m}`)},children:"View Job"})]})]}):a==="starting"?i.jsxs("div",{className:"flex flex-col items-center py-8",children:[i.jsx(Fi,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:U.isPending?"Generating candidates...":O.isPending?"Importing tasks...":"Creating optimization job..."})]}):a==="candidates"?i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[i.jsx("span",{className:"text-[var(--text-primary)]",children:"1. Tasks"}),i.jsx(Ns,{size:14}),i.jsx("span",{className:"text-[var(--accent)] font-medium",children:"2. Candidates"})]}),i.jsxs("div",{className:"space-y-4 p-4 border border-[var(--border)] bg-[var(--bg-secondary)]",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h4",{className:"font-medium text-sm",children:"Select dimensions to explore:"}),i.jsxs(W,{variant:"info",children:[L," candidate",L!==1?"s":""]})]}),!ee&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:"Select at least one dimension to generate candidate variations. Without variations, only the baseline agent will be tested."}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Mn,{label:"Compaction (on/off)",checked:x.vary_compaction,onChange:E=>w({...x,vary_compaction:E.target.checked})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-1",children:"Test with compaction enabled vs disabled"}),i.jsx(Mn,{label:"Tool Presets",checked:x.vary_tools,onChange:E=>w({...x,vary_tools:E.target.checked})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-1",children:"Test different tool configurations (standard, minimal, full)"}),x.vary_tools&&i.jsx("div",{className:"ml-6 flex flex-wrap gap-2",children:z.map(E=>{var B;return i.jsxs("label",{className:"flex items-center gap-1 text-xs",children:[i.jsx("input",{type:"checkbox",checked:(B=x.tool_presets)==null?void 0:B.includes(E),onChange:re=>{const xe=x.tool_presets||[];w({...x,tool_presets:re.target.checked?[...xe,E]:xe.filter(On=>On!==E)})},className:"accent-[var(--accent)]"}),i.jsx("span",{children:E})]},E)})})]}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-3 mt-3 space-y-2",children:[i.jsx(Mn,{label:"Compaction Head Size",checked:x.vary_compaction_head,onChange:E=>w({...x,vary_compaction_head:E.target.checked})}),x.vary_compaction_head&&i.jsx(pt,{label:"Head sizes (comma-separated)",value:((le=x.compaction_head_values)==null?void 0:le.join(", "))||"5, 10, 20",onChange:E=>w({...x,compaction_head_values:E.target.value.split(",").map(B=>parseInt(B.trim())).filter(B=>!isNaN(B))})}),i.jsx(Mn,{label:"Compaction Tail Size",checked:x.vary_compaction_tail,onChange:E=>w({...x,vary_compaction_tail:E.target.checked})}),x.vary_compaction_tail&&i.jsx(pt,{label:"Tail sizes (comma-separated)",value:((R=x.compaction_tail_values)==null?void 0:R.join(", "))||"20, 40, 60",onChange:E=>w({...x,compaction_tail_values:E.target.value.split(",").map(B=>parseInt(B.trim())).filter(B=>!isNaN(B))})})]}),i.jsxs("div",{className:"bg-[var(--bg-tertiary)] p-3 rounded text-sm",children:[i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{children:"Candidates:"}),i.jsx("span",{className:"font-mono",children:L})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{children:"Tasks:"}),i.jsx("span",{className:"font-mono",children:D})]}),i.jsxs("div",{className:"flex justify-between font-medium border-t border-[var(--border)] pt-2 mt-2",children:[i.jsx("span",{children:"Total experiments:"}),i.jsx("span",{className:"font-mono text-[var(--accent)]",children:$})]})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(pt,{label:"Parallel Workers",type:"number",value:j,onChange:E=>S(parseInt(E.target.value)||1),min:1,max:16}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(Mn,{label:"Use LLM evaluation",checked:v,onChange:E=>d(E.target.checked)}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6",children:v?"GPT-4o scores task completion (0-1)":"Simple pass/fail based on task success"})]})]}),i.jsxs("div",{className:"flex justify-between gap-2 pt-4 border-t border-[var(--border)]",children:[i.jsx(K,{variant:"secondary",icon:og,onClick:()=>l("suite"),children:"Back"}),i.jsxs(K,{variant:"primary",icon:Ws,onClick:De,children:["Start Optimization (",$," runs)"]})]})]}):i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[i.jsx("span",{className:"text-[var(--accent)] font-medium",children:"1. Tasks"}),i.jsx(Ns,{size:14}),i.jsx("span",{children:"2. Candidates"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium mb-3 block",children:"Select Task Suite"}),i.jsx("div",{className:"space-y-2",children:C.map(E=>{const B=_.filter(re=>re.suite===E.value).length;return i.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer transition-colors ${o===E.value&&!c?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"radio",name:"suite",value:E.value,checked:o===E.value&&!c,onChange:()=>{u(E.value),p(!1)},className:"accent-[var(--accent)]"}),i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium",children:E.label}),i.jsxs(W,{children:[E.tasks," tasks"]}),B>0&&i.jsxs(W,{variant:"success",children:[B," imported"]})]}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:E.description})]})]},E.value)})})]}),_.length>0&&i.jsxs("div",{children:[i.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer transition-colors ${c?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"radio",checked:c,onChange:()=>p(!0),className:"accent-[var(--accent)]"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("span",{className:"font-medium",children:"Custom Selection"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Choose specific tasks from your library"})]})]}),c&&i.jsx("div",{className:"mt-3 max-h-48 overflow-y-auto border border-[var(--border)] p-2 space-y-1",children:_.map(E=>i.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:f.includes(E.id),onChange:()=>Wt(E.id),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:E.name}),E.suite&&i.jsx(W,{children:E.suite})]},E.id))})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-[var(--border)]",children:[i.jsx(K,{variant:"secondary",onClick:n,children:"Cancel"}),i.jsx(K,{variant:"primary",icon:Ns,onClick:()=>l("candidates"),disabled:c&&f.length===0,children:"Next: Candidates"})]})]})})}function y0(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const a=n(s);if(a)t.push(a);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function Op(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const a=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(a):n.push(a)}const r=s=>{s.sort((a,l)=>(a.span.start_time||0)-(l.span.start_time||0)),s.forEach(a=>r(a.children))};return r(n),n}function g0(e){return e.includes("Agent")||e.includes("agent")?"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200"}function j0(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function $u({node:e,depth:t=0}){var f,h;const[n,r]=k.useState(t<2),[s,a]=k.useState(!1),{span:l}=e,o=e.children.length>0,u=(f=l.attributes)==null?void 0:f["gen_ai.usage.input_tokens"],c=(h=l.attributes)==null?void 0:h["gen_ai.usage.output_tokens"],p=u!==void 0||c!==void 0;return i.jsxs("div",{className:"relative",children:[t>0&&i.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),i.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):a(!s),children:[i.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${g0(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&i.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:j0(l.duration_ms)}),p&&i.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[u!==void 0&&i.jsxs("span",{className:"text-blue-400",children:["↑",String(u)]}),u!==void 0&&c!==void 0&&i.jsx("span",{className:"mx-0.5",children:"/"}),c!==void 0&&i.jsxs("span",{className:"text-green-400",children:["↓",String(c)]})]})]}),s&&!o&&i.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:i.jsxs("div",{className:"space-y-1",children:[l.span_id&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),i.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),i.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),i.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&i.jsxs("div",{className:"mt-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),i.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&i.jsx("div",{children:e.children.map((x,w)=>i.jsx($u,{node:x,depth:t+1},x.span.span_id||w))})]})}function Lp({trace:e}){const[t,n]=k.useState("tree"),r=k.useMemo(()=>y0(e),[e]),s=k.useMemo(()=>Op(r),[r]);return Object.keys(e).length===0?null:i.jsxs(Z,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"font-medium",children:"Trace Data"}),i.jsxs("div",{className:"flex gap-1",children:[i.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),i.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?i.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:i.jsxs("div",{className:"p-2",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs(W,{variant:"default",children:[r.length," spans"]}),i.jsx("span",{children:"•"}),i.jsx("span",{children:"Click to expand details"})]}),s.map((a,l)=>i.jsx($u,{node:a,depth:0},a.span.span_id||l))]})}):i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):i.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function w0({spans:e,isLive:t=!1}){const n=k.useRef(null),r=k.useMemo(()=>Op(e),[e]);return k.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),i.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[i.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[i.jsxs(W,{variant:"default",children:[e.length," spans"]}),t&&i.jsx("span",{className:"animate-pulse",children:i.jsx(W,{variant:"info",children:"Live"})})]}),i.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,a)=>i.jsx($u,{node:s,depth:0},s.span.span_id||a)):i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function k0({agent:e}){const[t,n]=k.useState(""),[r,s]=k.useState(null),[a,l]=k.useState("idle"),[o,u]=k.useState(null),[c,p]=k.useState(""),[f,h]=k.useState([]),[x,w]=k.useState(null),[j,S]=k.useState(null),[v,d]=k.useState([]),m=k.useRef(null),{data:g=[]}=ve({queryKey:["tasks"],queryFn:()=>Dt.list()});k.useEffect(()=>{m.current&&a==="running"&&(m.current.scrollTop=m.current.scrollHeight)},[c,a]);const _=P=>{if(s(P),P){const A=g.find(ee=>ee.id===P);A&&n(A.prompt)}},N=async()=>{if(t.trim()){l("running"),p(""),h([]),w(null),S(null),d([]);try{const P=await Cs.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});u(P.id);for await(const A of Cs.start(P.id))C(A)}catch(P){S(P instanceof Error?P.message:"Test failed"),l("failed")}}},C=P=>{switch(P.event){case"started":break;case"execution":P.execution_event==="text_delta"&&P.content?p(A=>A+P.content):P.execution_event==="tool_call_start"&&P.tool_name?d(A=>[...A,{name:P.tool_name}]):P.execution_event==="tool_result"&&P.content&&d(A=>{if(A.length>0){const ee=[...A];return ee[ee.length-1]={...ee[ee.length-1],content:P.content},ee}return A});break;case"span":if(P.span){const A=P.span;if(A.data){const ee={span_id:A.data.span_id||"",trace_id:A.data.trace_id||"",parent_span_id:A.data.parent_span_id||null,operation_name:A.data.operation_name||"",start_time:A.timestamp?new Date(A.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:A.data.duration_ms||0,status:A.data.status||"OK",attributes:A.data.attributes||{}};h(De=>[...De,ee])}}break;case"complete":l("completed"),P.result&&w(P.result);break;case"error":S(P.message),l("failed");break}},b=async()=>{if(o)try{await Cs.cancel(o)}catch{}l("idle")},z=()=>{l("idle"),u(null),p(""),h([]),w(null),S(null),d([])},O=a==="running",U=a==="completed"||a==="failed";return i.jsxs("div",{className:"h-full flex flex-col",children:[!O&&!U&&i.jsxs("div",{className:"mb-4 space-y-3",children:[i.jsxs("div",{className:"flex gap-3",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("label",{className:"block text-sm font-medium mb-1",children:"Select Task (optional)"}),i.jsxs("select",{value:r||"",onChange:P=>_(P.target.value||null),className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",children:[i.jsx("option",{value:"",children:"Custom prompt..."}),g.map(P=>i.jsx("option",{value:P.id,children:P.name},P.id))]})]}),i.jsx("div",{className:"flex items-end",children:i.jsx(K,{variant:"primary",icon:Ws,onClick:N,disabled:!t.trim(),children:"Run Test"})})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium mb-1",children:"Prompt"}),i.jsx("textarea",{value:t,onChange:P=>n(P.target.value),placeholder:"Enter a test prompt for the agent...",className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-none"})]})]}),(O||U)&&i.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[O&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"animate-pulse",children:i.jsx(W,{variant:"info",children:"Running"})}),i.jsx(K,{variant:"ghost",size:"sm",icon:wg,onClick:b,children:"Cancel"})]}),a==="completed"&&i.jsx(W,{variant:"success",children:"Completed"}),a==="failed"&&i.jsx(W,{variant:"error",children:"Failed"})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[x&&i.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(ug,{size:12}),x.duration_seconds.toFixed(2),"s"]}),i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(cg,{size:12}),x.tokens_total," tokens"]}),x.passed!==null&&(x.passed?i.jsx(ag,{size:14,className:"text-green-500"}):i.jsx(Sg,{size:14,className:"text-red-500"}))]}),U&&i.jsx(K,{variant:"secondary",size:"sm",onClick:z,children:"New Test"})]})]}),i.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-4 min-h-0",children:[i.jsxs("div",{className:"flex flex-col border border-[var(--border)] rounded overflow-hidden",children:[i.jsx("div",{className:"px-3 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] text-sm font-medium",children:"Output"}),i.jsxs("div",{ref:m,className:"flex-1 overflow-auto p-3 font-mono text-sm whitespace-pre-wrap bg-[var(--bg-primary)]",children:[c||(O?"Waiting for response...":"No output"),v.length>0&&i.jsxs("div",{className:"mt-3 space-y-2 border-t border-[var(--border)] pt-3",children:[i.jsx("div",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Tool Calls"}),v.map((P,A)=>i.jsxs("div",{className:"p-2 bg-green-500/10 border border-green-500/20 rounded text-xs",children:[i.jsx(W,{variant:"success",children:P.name}),P.content&&i.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full",children:[P.content.substring(0,200),P.content.length>200&&"..."]})]},A))]})]})]}),i.jsx(w0,{spans:f,isLive:O})]}),j&&i.jsx("div",{className:"mt-3 p-3 bg-red-500/10 border border-red-500/20 rounded text-sm text-red-400",children:j}),U&&o&&i.jsx("div",{className:"mt-3 flex items-center justify-end pt-3 border-t border-[var(--border)]",children:i.jsx(Hs,{to:`/tests/${o}`,children:i.jsx(K,{variant:"primary",iconRight:fg,children:"View Full Details"})})})]})]})}function S0(){const{agentId:e}=Mi(),t=Et(),n=Pn(),[r,s]=k.useState("overview"),{data:a,isLoading:l}=ve({queryKey:["configs",e],queryFn:()=>Yn.get(e),enabled:!!e}),{data:o=[]}=ve({queryKey:["tests",{agent_id:e}],queryFn:()=>Cs.list({agent_id:e}),enabled:!!e}),{data:u=[]}=ve({queryKey:["jobs"],queryFn:()=>bt.list()}),c=at({mutationFn:f=>Yn.delete(f),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),p=u.filter(f=>f.candidate_ids.includes(e||""));return l?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):a?i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx("div",{className:"flex items-center gap-3 mb-2",children:i.jsx("button",{onClick:()=>t("/agents"),className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"← Back to Agents"})}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:a.name}),a.is_auto_generated&&i.jsx(W,{variant:"info",children:"Auto-generated"})]}),i.jsx("div",{className:"flex gap-2",children:i.jsx(K,{variant:"secondary",icon:kp,onClick:()=>{confirm(`Delete agent "${a.name}"?`)&&c.mutate(a.id)},children:"Delete"})})]}),a.description&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:a.description})]}),i.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[i.jsx(xl,{active:r==="overview",onClick:()=>s("overview"),icon:i.jsx(wp,{size:16}),children:"Overview"}),i.jsx(xl,{active:r==="test",onClick:()=>s("test"),icon:i.jsx(Ws,{size:16}),children:"Test"}),i.jsx(xl,{active:r==="history",onClick:()=>s("history"),icon:i.jsx(mg,{size:16}),badge:o.length,children:"History"})]}),i.jsxs("div",{className:"flex-1 min-h-0",children:[r==="overview"&&i.jsx(N0,{agent:a,recentTests:o,jobs:p}),r==="test"&&i.jsx(k0,{agent:a}),r==="history"&&i.jsx(C0,{tests:o})]})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function xl({active:e,onClick:t,icon:n,badge:r,children:s}){return i.jsxs("button",{onClick:t,className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&i.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function N0({agent:e,recentTests:t,jobs:n}){var l,o,u,c,p,f;const r=Et(),s=e.config,a=()=>{const h=s.tools;return typeof h=="string"?h:Array.isArray(h)?h.join(", "):typeof h=="object"?Object.keys(h).join(", "):"standard"};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs(Z,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"Configuration"}),i.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Model:"}),i.jsx("div",{className:"font-mono",children:s.model||"default"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Compaction:"}),i.jsx("div",{className:"font-mono",children:((l=s.compaction)==null?void 0:l.strategy)==="none"?"disabled":`${(o=s.compaction)==null?void 0:o.strategy} (${((c=(u=s.compaction)==null?void 0:u.params)==null?void 0:c.head_size)||0}/${((f=(p=s.compaction)==null?void 0:p.params)==null?void 0:f.tail_size)||0})`})]}),i.jsxs("div",{className:"col-span-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tools:"}),i.jsx("div",{className:"font-mono",children:a()})]}),s.instructions&&i.jsxs("div",{className:"col-span-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Instructions:"}),i.jsx("pre",{className:"mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs whitespace-pre-wrap max-h-32 overflow-auto",children:s.instructions})]})]})]}),i.jsxs(Z,{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"font-medium",children:"Recent Tests"}),t.length>0&&i.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:[t.length," total"]})]}),t.length===0?i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:'No tests yet. Click the "Test" tab to run one.'}):i.jsx("div",{className:"space-y-2",children:t.slice(0,5).map(h=>i.jsxs(Hs,{to:`/tests/${h.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded hover:border-[var(--accent-dim)] transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Rp,{status:h.status}),i.jsxs("span",{className:"text-sm truncate max-w-[200px]",children:[h.prompt.slice(0,50),"..."]})]}),i.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[h.duration_seconds.toFixed(1),"s"]}),i.jsxs("span",{children:[h.tokens_total," tok"]})]})]},h.id))})]}),i.jsxs(Z,{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"font-medium",children:"Optimization Jobs"}),i.jsx(K,{variant:"secondary",size:"sm",icon:Di,onClick:()=>r("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),n.length===0?i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):i.jsx("div",{className:"space-y-2",children:n.slice(0,5).map(h=>i.jsxs(Hs,{to:`/jobs/${h.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded hover:border-[var(--accent-dim)] transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(W,{variant:h.status==="completed"?"success":h.status==="running"?"info":"default",children:h.status}),i.jsx("span",{className:"text-sm",children:h.name})]}),i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(h.created_at).toLocaleDateString()})]},h.id))})]})]})}function C0({tests:e}){return e.length===0?i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Run a test to see results here."}):i.jsx("div",{className:"space-y-2",children:e.map(t=>i.jsxs(Hs,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded hover:border-[var(--accent-dim)] transition-colors",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(Rp,{status:t.status}),t.score!==null&&i.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-green-400":"text-red-400"}`,children:[(t.score*100).toFixed(0),"%"]})]}),i.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),i.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),i.jsx("span",{children:"•"}),i.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function Rp({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return i.jsx(W,{variant:t[e]||"default",children:e})}const Mp=Mu(e=>({tasks:[],selectedTaskIds:[],setTasks:t=>e({tasks:t}),toggleTaskSelection:t=>e(n=>({selectedTaskIds:n.selectedTaskIds.includes(t)?n.selectedTaskIds.filter(r=>r!==t):[...n.selectedTaskIds,t]})),jobs:[],setJobs:t=>e({jobs:t})}));function _0(){const e=Pn(),[t,n]=k.useState(!1),[r,s]=k.useState(!1),[a,l]=k.useState(new Set(["custom"])),{selectedTaskIds:o,toggleTaskSelection:u,setTasks:c}=Mp(),p=d=>{l(m=>{const g=new Set(m);return g.has(d)?g.delete(d):g.add(d),g})},{data:f=[],isLoading:h}=ve({queryKey:["tasks"],queryFn:()=>Dt.list()});k.useEffect(()=>{f.length>0&&c(f)},[f,c]);const x=at({mutationFn:Dt.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),w=at({mutationFn:Dt.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),j=at({mutationFn:Dt.delete,onSuccess:()=>e.invalidateQueries({queryKey:["tasks"]})}),S=f.reduce((d,m)=>{const g=m.suite||"custom";return d[g]||(d[g]=[]),d[g].push(m),d},{}),v=Object.keys(S).sort((d,m)=>d==="custom"?-1:m==="custom"?1:d.localeCompare(m));return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Tasks"}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Define tasks to evaluate agent configurations.",o.length>0&&i.jsxs("span",{className:"ml-2 text-[var(--accent)]",children:[o.length," selected"]})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(K,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),i.jsx(K,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),h?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):f.length===0?i.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):i.jsx("div",{className:"space-y-4",children:v.map(d=>{const m=S[d],g=a.has(d),_=m.filter(N=>o.includes(N.id)).length;return i.jsxs("div",{children:[i.jsxs("button",{onClick:()=>p(d),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[g?i.jsx(lg,{size:16,className:"text-[var(--text-secondary)]"}):i.jsx(Ns,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:d==="custom"?"Custom Tasks":`${d} Suite`}),i.jsx(W,{variant:d==="custom"?"default":"info",children:m.length}),_>0&&i.jsxs(W,{variant:"success",children:[_," selected"]})]}),g&&i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3 mt-2",children:m.map(N=>i.jsx(Z,{selectable:!0,selected:o.includes(N.id),onClick:()=>u(N.id),children:i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsx("span",{className:"font-medium",children:N.name}),o.includes(N.id)&&i.jsx(W,{variant:"success",children:"Selected"}),N.category&&N.category!=="default"&&i.jsx(W,{variant:"default",children:N.category})]}),i.jsx(K,{variant:"ghost",size:"sm",onClick:C=>{C.stopPropagation(),confirm("Delete this task?")&&j.mutate(N.id)},children:"Delete"})]}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-2 line-clamp-3 flex-1",children:N.prompt}),N.criteria.length>0&&i.jsx("div",{className:"flex gap-1 mt-2 flex-wrap",children:N.criteria.map(C=>i.jsx(W,{variant:"default",children:C.name},C.name))})]})},N.id))})]},d)})}),i.jsx(b0,{isOpen:t,onClose:()=>n(!1),onSubmit:d=>x.mutate(d),isLoading:x.isPending}),i.jsx(E0,{isOpen:r,onClose:()=>s(!1),onSubmit:d=>w.mutate(d),isLoading:w.isPending})]})}function b0({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,a]=k.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{a({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(p,f)=>{const h=[...s.criteria];h[p]={...h[p],...f},a({...s,criteria:h})},u=p=>{a({...s,criteria:s.criteria.filter((f,h)=>h!==p)})},c=p=>{p.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(f=>f.name.trim()&&f.instruction.trim())})};return i.jsx(la,{isOpen:e,onClose:t,title:"Create Task",children:i.jsxs("form",{onSubmit:c,className:"space-y-4",children:[i.jsx(pt,{label:"Name",value:s.name,onChange:p=>a({...s,name:p.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),i.jsx(f0,{label:"Prompt",value:s.prompt,onChange:p=>a({...s,prompt:p.target.value}),placeholder:"The task description for the agent...",required:!0}),i.jsx(pt,{label:"Category",value:s.category,onChange:p=>a({...s,category:p.target.value}),placeholder:"e.g., coding, research"}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),i.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),i.jsx("div",{className:"space-y-2",children:s.criteria.map((p,f)=>i.jsxs("div",{className:"flex gap-2 items-start",children:[i.jsx(pt,{value:p.name,onChange:h=>o(f,{name:h.target.value}),placeholder:"Name",className:"w-32"}),i.jsx(pt,{value:p.instruction,onChange:h=>o(f,{instruction:h.target.value}),placeholder:"Instruction",className:"flex-1"}),i.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>u(f),children:"×"})]},f))})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(K,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function E0({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,a]=k.useState(""),{data:l=[],isLoading:o}=ve({queryKey:["suites"],queryFn:()=>Dt.listSuites(),enabled:e});return k.useEffect(()=>{l.length>0&&!s&&a(l[0].name)},[l,s]),i.jsx(la,{isOpen:e,onClose:t,title:"Import Task Suite",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):i.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(u=>i.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===u.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"radio",name:"suite",value:u.name,checked:s===u.name,onChange:()=>a(u.name),className:"accent-[var(--accent)]"}),i.jsxs("span",{className:"capitalize",children:[u.name.replace(/_/g," ")," (",u.task_count," tasks) - ",u.description]})]},u.name))}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(K,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}function P0(){const e=Et(),t=Pn(),[n,r]=k.useState(!1),{setJobs:s}=Mp(),a=Du(),{data:l=[],isLoading:o}=ve({queryKey:["jobs",n],queryFn:()=>bt.list({include_public:n}),refetchInterval:5e3});k.useEffect(()=>{l.length>0&&s(l)},[l,s]);const u=at({mutationFn:bt.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})});return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Optimization Jobs"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new jobs from the Agents page."})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:n,onChange:c=>r(c.target.checked),className:"rounded border-[var(--border)]"}),i.jsx(Ii,{className:"w-4 h-4"}),"Show public"]}),i.jsx(K,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),o?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):l.length===0?i.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No jobs yet. Go to Agents page to start an optimization."}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:l.map(c=>{const p=!c.user_id||c.user_id==="anonymous"||a&&c.created_by_name===a;return i.jsx(Tp,{job:c,onDelete:p?f=>u.mutate(f):void 0},c.id)})})]})}function T0(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function O0(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function zp(e,t){return t===0?0:(e-t)/t*100}function us({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const a=t[n];return i.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[i.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const u=zp(l,a),c=o===n;return i.jsxs("td",{className:"py-2 px-4 text-right",children:[i.jsx("div",{className:"font-mono",children:r(l)}),!c&&i.jsx("div",{className:`text-xs ${T0(u,s)}`,children:O0(u)}),c&&i.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function L0({runs:e,baselineRunId:t}){const n=k.useMemo(()=>{if(t){const a=e.findIndex(l=>l.id===t);if(a>=0)return a}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(a=>a.tokens_total)),s=Math.max(...e.map(a=>a.score));return i.jsxs(Z,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-[var(--border)]",children:[i.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((a,l)=>i.jsx("th",{className:"pb-2 px-4 text-right",children:i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[i.jsx("span",{className:"font-medium",children:a.candidate_name}),a.is_pareto&&i.jsx(W,{variant:"success",children:"Pareto"}),l===n&&i.jsx(W,{variant:"info",children:"Base"})]})},a.id))]})}),i.jsxs("tbody",{children:[i.jsx(us,{label:"Total Tokens",values:e.map(a=>a.tokens_total),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(us,{label:"Input Tokens",values:e.map(a=>a.tokens_input),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(us,{label:"Output Tokens",values:e.map(a=>a.tokens_output),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(us,{label:"Duration",values:e.map(a=>a.duration_seconds),baselineIndex:n,formatter:a=>`${a.toFixed(1)}s`,isLowerBetter:!0}),i.jsx(us,{label:"Score",values:e.map(a=>a.score*100),baselineIndex:n,formatter:a=>`${a.toFixed(1)}%`,isLowerBetter:!1})]})]})}),i.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[i.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),i.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(a=>{const l=zp(a.tokens_total,e[n].tokens_total);return a.tokens_total===r&&l<-5?i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-green-400",children:"✓"}),i.jsxs("span",{children:[i.jsx("strong",{children:a.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${a.id}`):null}),e.map(a=>a.score===s&&a.passed?i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-green-400",children:"✓"}),i.jsxs("span",{children:[i.jsx("strong",{children:a.candidate_name})," achieved highest score (",(a.score*100).toFixed(0),"%)"]})]},`score-${a.id}`):null),e.filter(a=>a.is_pareto).length>0&&i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-purple-400",children:"★"}),i.jsxs("span",{children:["Pareto-optimal candidates:"," ",e.filter(a=>a.is_pareto).map(a=>a.candidate_name).join(", ")]})]})]})]}),i.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[i.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),i.jsx("div",{className:"space-y-2",children:e.map(a=>{const l=a.tokens_total/e[n].tokens_total*100,o=a.tokens_total<=r;return i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-24 text-sm truncate",title:a.candidate_name,children:a.candidate_name}),i.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:i.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),i.jsx("div",{className:"w-20 text-right font-mono text-sm",children:a.tokens_total.toLocaleString()})]},a.id)})})]})]})}function R0({summaries:e,height:t=350}){const n=k.useRef(null),[r,s]=k.useState(600),[a,l]=k.useState("tokens"),[o,u]=k.useState(null),[c,p]=k.useState({x:0,y:0});k.useEffect(()=>{const N=()=>{n.current&&s(n.current.clientWidth)};return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[]);const f={top:30,right:30,bottom:50,left:60},h=r-f.left-f.right,x=t-f.top-f.bottom,w=N=>a==="tokens"?N.avg_tokens:N.avg_duration,{xScale:j,yScale:S,xTicks:v,yTicks:d,paretoLine:m}=k.useMemo(()=>{if(e.length===0||h<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const N=e.map(w),C=e.map(L=>L.avg_score),b=Math.min(...N)*.9,z=Math.max(...N)*1.1,O=Math.min(...C,.5),U=Math.min(Math.max(...C)*1.05,1),P=L=>(L-b)/(z-b)*h,A=L=>x-(L-O)/(U-O)*x,ee=Array.from({length:5},(L,D)=>b+D/4*(z-b)),De=Array.from({length:5},(L,D)=>O+D/4*(U-O)),Ae=e.filter(L=>L.is_pareto).sort((L,D)=>w(L)-w(D)).map(L=>({x:P(w(L)),y:A(L.avg_score)}));return{xScale:P,yScale:A,xTicks:ee,yTicks:De,paretoLine:Ae}},[e,h,x,a]);if(e.length===0)return i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const g=N=>a==="tokens"?N>=1e6?`${(N/1e6).toFixed(1)}M`:N>=1e3?`${(N/1e3).toFixed(0)}K`:N.toFixed(0):`${N.toFixed(1)}s`,_=(N,C)=>{var z;const b=(z=n.current)==null?void 0:z.getBoundingClientRect();b&&p({x:C.clientX-b.left,y:C.clientY-b.top}),u(N)};return i.jsxs("div",{ref:n,className:"w-full relative",children:[i.jsx("div",{className:"flex justify-end mb-2",children:i.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[i.jsx("button",{className:`px-3 py-1 ${a==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),i.jsx("button",{className:`px-3 py-1 ${a==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),i.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:i.jsxs("g",{transform:`translate(${f.left}, ${f.top})`,children:[v.map((N,C)=>i.jsx("line",{x1:j(N),y1:0,x2:j(N),y2:x,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${C}`)),d.map((N,C)=>i.jsx("line",{x1:0,y1:S(N),x2:h,y2:S(N),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${C}`)),m.length>1&&i.jsx("polyline",{points:m.map(N=>`${N.x},${N.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((N,C)=>(N.is_pareto?1:0)-(C.is_pareto?1:0)).map(N=>{const C=j(w(N)),b=S(N.avg_score),z=N.is_pareto,O=(o==null?void 0:o.candidate_name)===N.candidate_name;return i.jsxs("g",{onMouseEnter:U=>_(N,U),onMouseLeave:()=>u(null),children:[i.jsx("circle",{cx:C,cy:b,r:O?10:z?8:6,fill:z?"var(--accent)":"transparent",stroke:O?"var(--text-primary)":z?"var(--accent)":"var(--text-secondary)",strokeWidth:O?3:2,className:"cursor-pointer transition-all"}),z&&!O&&i.jsx("text",{x:C,y:b-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:N.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},N.candidate_name)}),i.jsx("line",{x1:0,y1:x,x2:h,y2:x,stroke:"var(--text-secondary)"}),v.map((N,C)=>i.jsxs("g",{transform:`translate(${j(N)}, ${x})`,children:[i.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),i.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:g(N)})]},`x-tick-${C}`)),i.jsx("text",{x:h/2,y:x+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:a==="tokens"?"Tokens (cost)":"Duration (latency)"}),i.jsx("line",{x1:0,y1:0,x2:0,y2:x,stroke:"var(--text-secondary)"}),d.map((N,C)=>i.jsxs("g",{transform:`translate(0, ${S(N)})`,children:[i.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),i.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(N*100).toFixed(0),"%"]})]},`y-tick-${C}`)),i.jsx("text",{transform:`translate(-45, ${x/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&i.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(c.x+15,r-200),top:c.y-10,maxWidth:220},children:[i.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),i.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),i.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),i.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),i.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),i.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&i.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Pareto optimal"})]})]})}function M0(e=2e3){const[t,n]=k.useState(!1),[r,s]=k.useState(null),a=k.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=k.useCallback(()=>{n(!1),s(null)},[]);return{copy:a,copied:t,error:r,reset:l}}function z0({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:a,createdByName:l,onTogglePublic:o}){const[u,c]=k.useState(!1),{copy:p,copied:f}=M0(),h=`${window.location.origin}/${s}s/${r}`,x=async()=>{c(!0);try{await o(!a)}finally{c(!1)}},w=()=>{p(h)};return i.jsx(la,{isOpen:e,onClose:t,title:n,children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[a?i.jsx(Ii,{className:"w-5 h-5 text-[var(--accent)]"}):i.jsx(gp,{className:"w-5 h-5 text-[var(--text-secondary)]"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:a?"Public":"Private"}),i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:a?"Anyone with the link can view":"Only you can access"})]})]}),i.jsx("button",{onClick:x,disabled:u,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${a?"bg-[var(--accent)]":"bg-[var(--border)]"} ${u?"opacity-50 cursor-not-allowed":""}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${a?"translate-x-6":"translate-x-1"}`})})]}),a&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",readOnly:!0,value:h,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),i.jsx(K,{variant:"secondary",onClick:w,children:f?i.jsxs(i.Fragment,{children:[i.jsx(ig,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(dg,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&i.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",i.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:a?i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),i.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):i.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function I0({job:e,onUpdate:t}){const[n,r]=k.useState(!1),s=async a=>{await bt.update(e.id,{is_public:a}),t()};return i.jsxs(i.Fragment,{children:[i.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[i.jsx(jg,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),i.jsx(z0,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function F0(){const{jobId:e}=Mi(),t=Et(),n=Pn(),[r,s]=k.useState(null),[a,l]=k.useState(!1),[o,u]=k.useState(null),[c,p]=k.useState([]),[f,h]=k.useState(null),[x,w]=k.useState(null),[j,S]=k.useState("results"),[v,d]=k.useState("score"),[m,g]=k.useState("desc"),[_,N]=k.useState(!1),{data:C,isLoading:b}=ve({queryKey:["jobs",e],queryFn:()=>bt.get(e),enabled:!!e,refetchInterval:a?2e3:!1}),{data:z=[]}=ve({queryKey:["runs",e],queryFn:()=>Oo.list({job_id:e}),enabled:!!e,refetchInterval:a?2e3:!1}),{data:O}=ve({queryKey:["job-summary",e],queryFn:()=>Oo.getJobSummary(e),enabled:!!e&&(C==null?void 0:C.status)==="completed"}),U=at({mutationFn:async()=>{l(!0),p([]),h(null),w(null);for await(const R of bt.start(e))s(R),R.current_candidate&&R.current_task&&h(E=>(E&&(E.candidate!==R.current_candidate||E.task!==R.current_task)&&p(B=>[...B,{candidate_name:E.candidate,task_name:E.task,completed_at:Date.now()}]),{candidate:R.current_candidate,task:R.current_task})),R.event==="error"&&(w(R.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),R.event==="complete"&&(h(E=>(E&&p(B=>[...B,{candidate_name:E.candidate,task_name:E.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),P=at({mutationFn:()=>bt.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});k.useEffect(()=>{(C==null?void 0:C.status)==="running"&&l(!0)},[C==null?void 0:C.status]);const A=k.useMemo(()=>{const R=new Map;for(const E of z)R.has(E.task_name)||R.set(E.task_name,[]),R.get(E.task_name).push(E);return R},[z]),ee=k.useMemo(()=>Array.from(A.keys()),[A]),De=k.useMemo(()=>{if(!(O!=null&&O.candidate_summaries))return[];let R=[...O.candidate_summaries];return _&&(R=R.filter(E=>E.is_pareto)),R.sort((E,B)=>{let re,xe;switch(v){case"score":re=E.avg_score,xe=B.avg_score;break;case"tokens":re=E.avg_tokens,xe=B.avg_tokens;break;case"duration":re=E.avg_duration,xe=B.avg_duration;break;case"pass_rate":re=E.passed_runs/E.total_runs,xe=B.passed_runs/B.total_runs;break}return m==="desc"?xe-re:re-xe}),R},[O,v,m,_]),Wt=R=>{v===R?g(m==="desc"?"asc":"desc"):(d(R),g(R==="tokens"||R==="duration"?"asc":"desc"))},Ae=({label:R,sortKeyVal:E})=>i.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>Wt(E),children:i.jsxs("div",{className:"flex items-center gap-1",children:[R,v===E&&i.jsx(ng,{size:12,className:m==="asc"?"rotate-180":""})]})});if(b)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!C)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const L=Du(),D=!C.user_id||C.user_id==="anonymous"||L&&C.created_by_name===L,$=C.is_public&&!D,te=()=>{n.invalidateQueries({queryKey:["jobs",e]})},le=R=>{const E={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return i.jsx(W,{variant:E[R]||"default",children:R})};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("button",{onClick:()=>t("/jobs"),className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"← Jobs"}),i.jsx("h2",{className:"text-xl font-bold",children:C.name||`Job ${C.id.slice(0,8)}`}),le(C.status),C.is_public&&i.jsxs(W,{variant:"info",children:[i.jsx(Ii,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),i.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[C.id.slice(0,8),"..."]}),i.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[C.candidate_ids.length," candidates × ",C.task_ids.length," tasks = ",C.total_experiments," experiments"]}),C.is_public&&C.created_by_name&&i.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",i.jsx("span",{className:"text-[var(--text-primary)]",children:C.created_by_name})]})]})]}),i.jsxs("div",{className:"flex gap-2",children:[D&&i.jsx(I0,{job:C,onUpdate:te}),$&&i.jsx(W,{variant:"default",children:"View Only"}),D&&C.status==="pending"&&i.jsx(K,{variant:"primary",onClick:()=>U.mutate(),disabled:U.isPending,children:U.isPending?"Starting...":"Start"}),D&&C.status==="running"&&i.jsx(K,{variant:"danger",onClick:()=>P.mutate(),disabled:P.isPending,children:"Cancel"})]})]}),(x||C.error)&&i.jsx(Z,{className:"mb-6 border-red-500/50 bg-red-500/10",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:x||C.error})]})]})}),(a||r)&&i.jsxs(Z,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"font-medium",children:"Progress"}),i.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||C.completed_experiments,"/",(r==null?void 0:r.total)||C.total_experiments]})]}),i.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:i.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||C.completed_experiments)/((r==null?void 0:r.total)||C.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),a&&i.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&i.jsxs("div",{className:"mb-3",children:[i.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),i.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[i.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),i.jsx("span",{className:"font-medium",children:r.current_candidate}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{children:r.current_task})]})]}),c.length>0&&i.jsxs("div",{children:[i.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",c.length,")"]}),i.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:c.map((R,E)=>i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[i.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),i.jsx("span",{className:"font-medium",children:R.candidate_name}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{children:R.task_name})]},`${R.candidate_name}-${R.task_name}-${E}`))})]})]})]}),(C.status==="completed"||z.length>0)&&i.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[i.jsxs("button",{onClick:()=>S("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${j==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(rg,{size:16}),"Results"]}),i.jsxs("button",{onClick:()=>S("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${j==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(hg,{size:16}),"Compare"]}),i.jsxs("button",{onClick:()=>S("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${j==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(xg,{size:16}),"Runs (",z.length,")"]})]}),j==="results"&&i.jsxs(i.Fragment,{children:[O&&O.candidate_summaries.length>1&&i.jsxs(Z,{className:"mb-6",children:[i.jsx("div",{className:"flex items-start justify-between mb-4",children:i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium",children:"Pareto Frontier"}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",i.jsx("strong",{children:"Pareto optimal"})," - no other candidate beats them on both score AND cost."]})]})}),i.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[i.jsx("strong",{className:"text-[var(--text-primary)]",children:"How Pareto optimal is calculated:"})," A candidate is Pareto optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are Pareto optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",i.jsx("em",{children:"not"})," Pareto optimal because B beats it on both metrics."]}),i.jsx(R0,{summaries:O.candidate_summaries,height:350})]}),O&&i.jsxs(Z,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"font-medium",children:"Results Summary"}),i.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:_,onChange:R=>N(R.target.checked),className:"rounded border-[var(--border)]"}),"Pareto only"]})]}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[i.jsx("th",{className:"pb-2",children:"Candidate"}),i.jsx(Ae,{label:"Score",sortKeyVal:"score"}),i.jsx(Ae,{label:"Tokens",sortKeyVal:"tokens"}),i.jsx(Ae,{label:"Duration",sortKeyVal:"duration"}),i.jsx(Ae,{label:"Pass Rate",sortKeyVal:"pass_rate"}),i.jsx("th",{className:"pb-2",children:"Pareto"})]})}),i.jsx("tbody",{children:De.map((R,E)=>i.jsxs("tr",{className:`border-b border-[var(--border)] ${E===0?"bg-[var(--accent)]/10":""}`,children:[i.jsxs("td",{className:"py-2 font-medium",children:[E===0&&i.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),R.candidate_name.replace(/^baseline_/,"")]}),i.jsxs("td",{className:"py-2",children:[(R.avg_score*100).toFixed(1),"%"]}),i.jsxs("td",{className:"py-2",children:[(R.avg_tokens/1e3).toFixed(1),"K"]}),i.jsxs("td",{className:"py-2",children:[R.avg_duration.toFixed(1),"s"]}),i.jsxs("td",{className:"py-2",children:[R.passed_runs,"/",R.total_runs]}),i.jsx("td",{className:"py-2",children:R.is_pareto&&i.jsx(W,{variant:"success",children:"Pareto"})})]},R.candidate_name))})]})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!O&&i.jsx(Z,{children:i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),j==="compare"&&i.jsxs(Z,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),ee.length>0?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:ee.map(R=>i.jsx("button",{onClick:()=>u(o===R?null:R),className:`px-3 py-1 text-sm rounded border transition-colors ${o===R?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:R},R))}),o&&A.get(o)?i.jsx(L0,{runs:A.get(o).map(R=>({id:R.id,candidate_name:R.candidate_name,tokens_input:0,tokens_output:0,tokens_total:R.tokens_total,duration_seconds:R.duration_seconds,score:R.score,passed:R.passed,is_pareto:R.is_pareto}))}):i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),j==="runs"&&i.jsxs(Z,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),z.length===0?i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:z.map(R=>i.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${R.id}`),children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("span",{className:`text-lg font-bold ${R.passed?"text-green-400":"text-red-400"}`,children:[(R.score*100).toFixed(0),"%"]}),R.is_pareto&&i.jsx(W,{variant:"success",children:"Pareto"})]}),i.jsx("div",{className:"text-sm font-medium truncate",title:R.candidate_name,children:R.candidate_name.replace(/^baseline_/,"")}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:R.task_name}),i.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[(R.tokens_total/1e3).toFixed(1),"K tokens"]}),i.jsxs("span",{children:[R.duration_seconds.toFixed(1),"s"]})]})]},R.id))})]})]})}const hn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function kd(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Sd({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const a=e+t;if(a===0)return i.jsx("div",{className:"flex items-center gap-2 w-full",children:i.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?a/n*100:100;return i.jsxs("div",{className:"flex items-center gap-3 w-full",children:[i.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:i.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[i.jsx("div",{className:`h-full ${hn.input} transition-all`,style:{width:`${e/a*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),i.jsx("div",{className:`h-full ${hn.output} transition-all`,style:{width:`${t/a*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&i.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[i.jsxs("span",{className:hn.inputText,children:["↑",kd(e)]}),i.jsx("span",{children:"/"}),i.jsxs("span",{className:hn.outputText,children:["↓",kd(t)]})]})]})}function yl({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:hn.inputText,output:hn.outputText}[n];return i.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[i.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),i.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function Ip({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,a=n>0?Math.round(t/n*100):0,l=k.useMemo(()=>{if(!r||r.length===0)return null;let u=0,c=0;return r.map(p=>(u+=p.input,c+=p.output,{input:u,output:c,total:u+c}))},[r]),o=l?Math.max(...l.map(u=>u.total)):n;return i.jsxs(Z,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),i.jsx("div",{className:"mb-4",children:i.jsx(Sd,{input:e,output:t,maxValue:n,height:32})}),i.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-3 h-3 rounded ${hn.input}`}),i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-3 h-3 rounded ${hn.output}`}),i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",a,"%)"]})]})]}),i.jsxs("div",{className:"flex gap-3 mb-4",children:[i.jsx(yl,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),i.jsx(yl,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),i.jsx(yl,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&i.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[i.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),i.jsx("div",{className:"space-y-2",children:r.map((u,c)=>i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:c+1}),i.jsx("div",{className:"flex-1",children:i.jsx(Sd,{input:l[c].input,output:l[c].output,maxValue:o,height:16})})]},c))})]}),i.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function D0(){const{runId:e}=Mi(),t=Et(),{data:n,isLoading:r}=ve({queryKey:["runs",e],queryFn:()=>Oo.get(e),enabled:!!e});return r?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):n?i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsx("div",{className:"flex items-center gap-3 mb-2",children:i.jsx("button",{onClick:()=>t(`/jobs/${n.job_id}`),className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"← Back to Job"})}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:n.candidate_name}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{className:"text-lg",children:n.task_name}),n.is_pareto&&i.jsx(W,{variant:"success",children:"Pareto Optimal"})]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(ba,{label:"Score",value:`${(n.score*100).toFixed(1)}%`,status:n.passed?"success":"error"}),i.jsx(ba,{label:"Total Tokens",value:n.tokens_total.toLocaleString()}),i.jsx(ba,{label:"Duration",value:`${n.duration_seconds.toFixed(1)}s`}),i.jsx(ba,{label:"Status",value:n.passed?"Passed":"Failed",status:n.passed?"success":"error"})]}),i.jsx(Ip,{tokensInput:n.tokens_input,tokensOutput:n.tokens_output,tokensTotal:n.tokens_total}),i.jsxs(Z,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),n.reasoning&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:n.reasoning}),n.criteria_results.length>0&&i.jsx("div",{className:"space-y-2",children:n.criteria_results.map(s=>i.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium",children:s.name}),i.jsxs(W,{variant:s.passed?"success":"error",children:[(s.score*100).toFixed(0),"%"]})]}),s.reasoning&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:s.reasoning})]})},s.name))})]}),i.jsxs(Z,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:n.output||"(no output)"})]}),n.files_created.length>0&&i.jsxs(Z,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),i.jsx("div",{className:"space-y-1",children:n.files_created.map(s=>i.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:s},s))})]}),Object.keys(n.trace).length>0&&i.jsx(Lp,{trace:n.trace})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function ba({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return i.jsxs(Z,{children:[i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),i.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function A0(){const{testId:e}=Mi(),t=Et(),{data:n,isLoading:r}=ve({queryKey:["tests",e],queryFn:()=>Cs.get(e),enabled:!!e}),{data:s}=ve({queryKey:["configs",n==null?void 0:n.agent_id],queryFn:()=>Yn.get(n.agent_id),enabled:!!(n!=null&&n.agent_id)});if(r)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!n)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const a={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsx("div",{className:"flex items-center gap-3 mb-2",children:i.jsx("button",{onClick:()=>t("/agents"),className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"← Back to Agents"})}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),s&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),i.jsx("span",{className:"text-lg",children:s.name})]}),i.jsx(W,{variant:a[n.status]||"default",children:n.status})]}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",n.id.slice(0,8),"..."]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(Ea,{label:"Duration",value:`${n.duration_seconds.toFixed(2)}s`}),i.jsx(Ea,{label:"Total Tokens",value:n.tokens_total.toLocaleString()}),n.score!==null&&i.jsx(Ea,{label:"Score",value:`${(n.score*100).toFixed(1)}%`,status:n.passed?"success":"error"}),i.jsx(Ea,{label:"Status",value:n.status.charAt(0).toUpperCase()+n.status.slice(1),status:n.status==="completed"?"success":n.status==="failed"?"error":void 0})]}),i.jsx(Ip,{tokensInput:n.tokens_input,tokensOutput:n.tokens_output,tokensTotal:n.tokens_total}),i.jsxs(Z,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:n.prompt})]}),n.error&&i.jsxs(Z,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[i.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),i.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:n.error})]}),n.reasoning&&i.jsxs(Z,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:n.reasoning})]}),i.jsxs(Z,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:n.output||"(no output)"})]}),n.files_created&&n.files_created.length>0&&i.jsxs(Z,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),i.jsx("div",{className:"space-y-1",children:n.files_created.map(l=>i.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:l},l))})]}),n.trace&&Object.keys(n.trace).length>0&&i.jsx(Lp,{trace:n.trace}),i.jsxs(Z,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),i.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),i.jsx("div",{className:"font-mono",children:new Date(n.created_at).toLocaleString()})]}),n.started_at&&i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),i.jsx("div",{className:"font-mono",children:new Date(n.started_at).toLocaleString()})]}),n.completed_at&&i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),i.jsx("div",{className:"font-mono",children:new Date(n.completed_at).toLocaleString()})]})]})]})]})}function Ea({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return i.jsxs(Z,{children:[i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),i.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function $0(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:a}=Au(),[l,o]=k.useState(""),[u,c]=k.useState("");k.useEffect(()=>{n&&a()},[l,u]);const p=async h=>{h.preventDefault(),!(!l||!u)&&await r(l,u)},f=()=>{s()};return i.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:i.jsxs("div",{className:"w-full max-w-md",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),i.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[i.jsx(tg,{size:18,className:"mt-0.5 flex-shrink-0"}),i.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&i.jsxs("form",{onSubmit:p,className:"space-y-4",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),i.jsxs("div",{className:"relative",children:[i.jsx(Sp,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),i.jsx("input",{type:"text",value:l,onChange:h=>o(h.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),i.jsxs("div",{className:"relative",children:[i.jsx(gp,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),i.jsx("input",{type:"password",value:u,onChange:h=>c(h.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),i.jsx(K,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!u,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),i.jsx(K,{onClick:f,variant:"secondary",className:"w-full justify-center",icon:pg,children:"Continue with GitHub"})]})]})]})})}function U0({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:a}=Au();return k.useEffect(()=>{s()},[s]),k.useEffect(()=>{n||a()},[n,a]),n?i.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:i.jsxs("div",{className:"text-center",children:[i.jsx(Fi,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?i.jsx($0,{}):i.jsx(i.Fragment,{children:e})}function B0(){return i.jsx(Wy,{children:i.jsx(U0,{children:i.jsx(Ay,{children:i.jsxs(gt,{path:"/",element:i.jsx(l0,{}),children:[i.jsx(gt,{index:!0,element:i.jsx(wd,{})}),i.jsx(gt,{path:"agents",element:i.jsx(wd,{})}),i.jsx(gt,{path:"agents/:agentId",element:i.jsx(S0,{})}),i.jsx(gt,{path:"tasks",element:i.jsx(_0,{})}),i.jsx(gt,{path:"jobs",element:i.jsx(P0,{})}),i.jsx(gt,{path:"jobs/:jobId",element:i.jsx(F0,{})}),i.jsx(gt,{path:"runs/:runId",element:i.jsx(D0,{})}),i.jsx(gt,{path:"tests/:testId",element:i.jsx(A0,{})})]})})})})}const Nd=localStorage.getItem("flow-theme");if(Nd)try{const{state:e}=JSON.parse(Nd);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const Q0=new Mx({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});gl.createRoot(document.getElementById("root")).render(i.jsx(Fo.StrictMode,{children:i.jsx(zx,{client:Q0,children:i.jsx(B0,{})})}));